-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
poetry update. Added helper funcions for colors with colorama. Added …
…lod_count methods (#90) * poetry update * Added helper funcions for colors with colorama * Added tests to count * Improved doc with new methods
- Loading branch information
Showing
9 changed files
with
1,112 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ chapters: | |
- file: percentage | ||
- file: myjsonencoder | ||
- file: pylatex | ||
- file: colors | ||
- file: changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
jupytext: | ||
formats: md:myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.11.5 | ||
kernelspec: | ||
display_name: Python 3 | ||
language: python | ||
name: python3 | ||
--- | ||
# Colors | ||
|
||
```{code-cell} | ||
:tags: [remove-input] | ||
from pydicts import colors | ||
help(colors) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from colorama import Style,Fore | ||
from pydicts.currency import Currency | ||
from pydicts.percentage import Percentage | ||
|
||
def blue(s): | ||
""" | ||
Shows a string in blue bright color | ||
""" | ||
return Style.BRIGHT + Fore.BLUE + str(s) + Style.RESET_ALL | ||
|
||
def red(s): | ||
""" | ||
Shows a string in red bright color | ||
""" | ||
return Style.BRIGHT + Fore.RED + str(s) + Style.RESET_ALL | ||
|
||
def green(s): | ||
""" | ||
Shows a string in green bright color | ||
""" | ||
return Style.BRIGHT + Fore.GREEN + str(s) + Style.RESET_ALL | ||
|
||
def magenta(s): | ||
""" | ||
Shows a string in magenta bright color | ||
""" | ||
return Style.BRIGHT + Fore.MAGENTA + str(s) + Style.RESET_ALL | ||
|
||
def yellow(s): | ||
""" | ||
Shows a string in yellow bright color | ||
""" | ||
return Style.BRIGHT + Fore.YELLOW + str(s) + Style.RESET_ALL | ||
|
||
def white(s): | ||
""" | ||
Shows a string in white bright color | ||
""" | ||
return Style.BRIGHT + str(s) + Style.RESET_ALL | ||
|
||
def cyan(s): | ||
""" | ||
Shows a string in cyan bright color | ||
""" | ||
return Style.BRIGHT + Fore.CYAN + str(s) + Style.RESET_ALL | ||
|
||
def currency_color(value, currency_): | ||
""" | ||
Shows a currency string in green or red color | ||
""" | ||
if value>=0: | ||
return green(Currency(value,currency_)) | ||
else: | ||
return red(Currency(value,currency_)) | ||
|
||
def percentage_color(value): | ||
""" | ||
Shows a percentage string in green or red color | ||
""" | ||
if value>=0: | ||
return green(Percentage(value,1)) | ||
else: | ||
return red(Currency(value,1)) | ||
|
||
def value_color(value): | ||
""" | ||
Shows a value string in green or red color | ||
""" | ||
if value>=0: | ||
return green(value) | ||
else: | ||
return red(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
from shutil import which | ||
from os import remove | ||
# from shutil import which | ||
# from os import remove | ||
|
||
if which("pdflatex") is not None: | ||
from pydicts import pylatex | ||
from pylatex import Document, Section, Subsection | ||
from pylatex.package import Package | ||
from pylatex.utils import italic, NoEscape | ||
lod=[ | ||
{"year": 2022, "month": 1, "my_sum": 12}, | ||
{"year": 2021, "month": 2, "my_sum": 123}, | ||
{"year": 2019, "month": 5, "my_sum": 1}, | ||
{"year": 2022, "month": 12, "my_sum": 12}, | ||
] | ||
def tests_pylatex_table_header(): | ||
# if which("pdflatex") is not None: | ||
# from pydicts import pylatex | ||
# from pylatex import Document, Section, Subsection | ||
# from pylatex.package import Package | ||
# from pylatex.utils import italic, NoEscape | ||
# lod=[ | ||
# {"year": 2022, "month": 1, "my_sum": 12}, | ||
# {"year": 2021, "month": 2, "my_sum": 123}, | ||
# {"year": 2019, "month": 5, "my_sum": 1}, | ||
# {"year": 2022, "month": 12, "my_sum": 12}, | ||
# ] | ||
# def tests_pylatex_table_header(): | ||
|
||
doc = Document() | ||
doc.packages.append(Package('xcolor')) | ||
# doc = Document() | ||
# doc.packages.append(Package('xcolor')) | ||
|
||
with doc.create(Section('A section')): | ||
doc.append('Some regular text and some ') | ||
doc.append(italic('italic text. ')) | ||
# with doc.create(Section('A section')): | ||
# doc.append('Some regular text and some ') | ||
# doc.append(italic('italic text. ')) | ||
|
||
with doc.create(Subsection('A subsection')): | ||
doc.append('Also some crazy characters: $&#{}') | ||
# with doc.create(Subsection('A subsection')): | ||
# doc.append('Also some crazy characters: $&#{}') | ||
|
||
doc.append(NoEscape("\\centering")) | ||
pylatex.pylatex_table(doc, lod) | ||
pylatex.pylatex_table(doc, []) | ||
pylatex.pylatex_table_with_matched_values(doc, [2022, 2, 12], lod, code_="|l|c|r|", match_color="teal", unmatch_color="red") | ||
doc.generate_pdf('test_pylatex_table_header', clean_tex=False) | ||
remove("test_pylatex_table_header.pdf") | ||
remove("test_pylatex_table_header.tex") | ||
# doc.append(NoEscape("\\centering")) | ||
# pylatex.pylatex_table(doc, lod) | ||
# pylatex.pylatex_table(doc, []) | ||
# pylatex.pylatex_table_with_matched_values(doc, [2022, 2, 12], lod, code_="|l|c|r|", match_color="teal", unmatch_color="red") | ||
# doc.generate_pdf('test_pylatex_table_header', clean_tex=False) | ||
# remove("test_pylatex_table_header.pdf") | ||
# remove("test_pylatex_table_header.tex") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters