Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Oct 12, 2023
0 parents commit 0f66257
Show file tree
Hide file tree
Showing 16 changed files with 2,367 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .ci/pythonPackagesToInstallFromGit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/tartley/colorama.git
https://github.com/tomerfiliba/plumbum.git
https://gitlab.com/dslackw/colored.git
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
end_of_line = lf

[*.{yml,yaml}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .github/.templateMarker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KOLANICH/python_project_boilerplate.py
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-type: "all"
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: typical python workflow
uses: KOLANICH-GHActions/typical-python-workflow@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__pycache__
*.pyc
*.pyo
/*.egg-info
/build
/dist
/.eggs
59 changes: 59 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
image: pypy:latest
#image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest
#image: registry.gitlab.com/kolanich-subgroups/docker-images/python_graal_docker:latest


variables:
DOCKER_DRIVER: overlay2
SAST_ANALYZER_IMAGE_TAG: latest
SAST_DISABLE_DIND: "true"
SAST_CONFIDENCE_LEVEL: 5
CODECLIMATE_VERSION: latest

include:
- template: SAST.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml

build:
tags:
- shared
- linux
stage: build
variables:
GIT_DEPTH: "1"
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages

before_script:
- export PATH="$PATH:$PYTHONUSERBASE/bin" # don't move into `variables`
- git clone https://github.com/pypa/setuptools.git
- cd setuptools
- pypy3 ./bootstrap.py
- pypy3 ./setup.py bdist_wheel
- pip install --upgrade --pre ./dist/*.whl
- cd ..
- rm -rf ./setuptools
- pip3 install --user --pre --upgrade git+https://github.com/pypa/setuptools_scm.git
- pip3 install --user --pre --upgrade git+https://github.com/pypa/pip.git git+https://github.com/pypa/wheel.git
- pip3 install --user --pre --upgrade pep517
- pip3 install --pre --upgrade --user git+https://github.com/pytest-dev/pytest.git

script:
- pypy3 -m pep517.build .
#- pypy3 ./setup.py bdist_wheel
- mv ./dist/*.whl ./dist/RichConsole-0.CI-py3-none-any.whl
- pip3 install --user --upgrade --pre "./dist/RichConsole-0.CI-py3-none-any.whl[colorama,plumbum,colored]"
- coverage run -a --branch --source=RichConsole -m pytest --junitxml=./rspec.xml ./tests/tests.py
- coverage run -a --branch --source=RichConsole -m RichConsole
- coverage xml

cache:
paths:
- /usr/local/site-packages
- /usr/local/lib/python*/site-packages

artifacts:
paths:
- dist
reports:
junit: ./rspec.xml
cobertura: ./coverage.xml
1 change: 1 addition & 0 deletions Code_Of_Conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No codes of conduct!
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include UNLICENSE
include *.md
include tests
include .editorconfig
50 changes: 50 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
RichConsole.py [![Unlicensed work](https://raw.githubusercontent.com/unlicense/unlicense.org/master/static/favicon.png)](https://unlicense.org/)
===============
~~[wheel (GHA via `nightly.link`)](https://nightly.link/KOLANICH-libs/RichConsole.py/workflows/CI/master/RichConsole-0.CI-py3-none-any.whl)~~
~~[![GitLab Build Status](https://gitlab.com/KOLANICH/RichConsole.py/badges/master/pipeline.svg)]( https://gitlab.com/KOLANICH/RichConsole.py/pipelines/master/latest)~~
~~![GitLab Coverage](https://gitlab.com/KOLANICH/RichConsole.py/badges/master/coverage.svg)~~
~~[![GitHub Actions](https://github.com/KOLANICH-libs/RichConsole.py/workflows/CI/badge.svg)](https://github.com/KOLANICH-libs/RichConsole.py/actions/)~~
![N∅ hard dependencies](https://shields.io/badge/-N∅_Ъ_deps!-0F0)
[![Libraries.io Status](https://img.shields.io/librariesio/github/KOLANICH-libs/RichConsole.py.svg)](https://libraries.io/github/KOLANICH-libs/RichConsole.py)
[![Code style: antiflash](https://img.shields.io/badge/code%20style-antiflash-FFF.svg)](https://github.com/KOLANICH-tools/antiflash.py)

>Yo dawg so we heard you like text styles so we put styles in your styles so you can style while you styling.
This is a tool to output "poor" (because it is limited by standardized control codes, which are very limited) rich text into a console. When dealing with control codes there is a problem with nesting styles because you have to restore the state, and the state you have to restore depends on the style of the level much distant from the one you are in. This library solves this problem.

You create a [directed acyclic graph](https://en.wikipedia.org/wiki/Directed_acyclic_graph) structure `RichStr` where each piece of string has its own [style`Sheet`](https://en.wikipedia.org/wiki/Style_sheet_(desktop_publishing)). After you have finished forming the output message you convert it into a string. The library does the rest.

How does it work?
-----------------

The algorithm is damn simple: it just traverses the directed acyclic graph in depth-first way, determines exact style of each string, computes differences between them and emits control codes to apply them.

Requirements
------------
* A terminal supporting color codes.
* Any Linux distro usually has one
* Windows:
* Windows 10 [has built-in support](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences)
* [ansicon](https://github.com/adoxa/ansicon) or [ConEmu](https://github.com/Maximus5/ConEmu) or [MinTTY](https://github.com/mintty/mintty) for older Windows
* you can call [colorama.init()](https://github.com/tartley/colorama) to enable filtering the output with python, but this is VERY glitchy. It raises exceptions even on simple strings. The good thing in it that it supports more codes than `ansicon`.

Optional requirements
---------------------
This library automatically imports colors and other control codes from the following libraries:
* [`colorama`](https://github.com/tartley/colorama/)
[![PyPi Status](https://img.shields.io/pypi/v/colorama.svg)](https://pypi.org/pypi/colorama)
[![Build Status](https://github.com/tartley/colorama/actions/workflows/test.yml/badge.svg)](https://github.com/tartley/colorama/actions/workflows/test.yml)
![License](https://img.shields.io/github/license/tartley/colorama.svg)

* [`plumbum.colorlib`](https://github.com/tomerfiliba/plumbum/)
[![PyPi Status](https://img.shields.io/pypi/v/plumbum.svg)](https://pypi.org/pypi/plumbum)
[![Build Status](https://img.shields.io/pypi/v/plumbum.svg)](https://github.com/tomerfiliba/plumbum/actions)
[![Docs](https://readthedocs.org/projects/plumbum/badge/)](https://plumbum.readthedocs.io/en/latest/)
![License](https://img.shields.io/github/license/tomerfiliba/plumbum.svg)

* [`colored`](https://gitlab.com/dslackw/colored/)
[![PyPi Status](https://img.shields.io/pypi/v/colored.svg)](https://pypi.org/pypi/colored)

Tutorial
--------
See [`Tutorial.ipynb`](./Tutorial.ipynb) ([NBViewer](https://nbviewer.jupyter.org/github/KOLANICH-libs/RichConsole.py/blob/master/Tutorial.ipynb)).
Loading

0 comments on commit 0f66257

Please sign in to comment.