-
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.
Remove click, requests. Add jsonargparse, httpx, loguru
- Loading branch information
1 parent
2660852
commit 0ec8f6b
Showing
8 changed files
with
1,171 additions
and
489 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 |
---|---|---|
@@ -1 +1 @@ | ||
3.11.1 | ||
3.12.2 |
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,7 +1,7 @@ | ||
# hypermodern-python | ||
Modern python environment | ||
|
||
poetry, pyenv, pytest, pytest-cov, pytest-mock, nox, flake8 (and plugins), black, safety, pre-commit, mypy, pytype (or pyre, pyright), desert, marshmallow, yypeguard, | ||
poetry, pyenv, pytest, pytest-cov, pytest-mock, nox, flake8 (and plugins), black, safety, pre-commit, mypy, pytype (or pyre, pyright), desert, marshmallow, typeguard, | ||
sphinx, sphinx-autodoc-typehints, git actions, codecov. | ||
|
||
And important, run in python v3.11 | ||
And important, run in python v3.12 |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "hypermodern-python" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
description = "My python modern config" | ||
authors = ["Duk <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -11,12 +11,14 @@ documentation = "https://hypermodern-python.readthedocs.io" | |
|
||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
click = "^8.1.3" | ||
requests = "^2.28.2" | ||
python = "^3.12" | ||
safety-db = "^2021.7.17" | ||
desert = "^2022.9.22" | ||
marshmallow = "^3.19.0" | ||
codecov = "^2.1.13" | ||
httpx = "^0.27.0" | ||
jsonargparse = {extras = ["all"], version = "^4.32.0"} | ||
loguru = "^0.7.2" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
|
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,2 +1,3 @@ | ||
"""The hypermodern Python project.""" | ||
__version__ = "0.1.0" | ||
|
||
__version__ = "0.2.0" |
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,23 +1,20 @@ | ||
"""Command-line interface.""" | ||
|
||
import textwrap | ||
|
||
import click | ||
from prettier import cprint | ||
|
||
from . import wikipedia | ||
|
||
|
||
def cmd(): | ||
from jsonargparse import CLI | ||
|
||
from . import __version__, wikipedia | ||
CLI(wikipedia.Fetcher) | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
"--language", | ||
"-l", | ||
default="en", | ||
help="Language edition of Wikipedia", | ||
metavar="LANG", | ||
show_default=True, | ||
) | ||
@click.version_option(version=__version__) | ||
def main(language: str) -> None: | ||
"""The hypermodern Python project.""" | ||
page = wikipedia.random_page(language=language) | ||
click.secho(page.title, fg="green") | ||
click.echo(textwrap.fill(page.extract)) | ||
cprint(page.title, fg="g") | ||
cprint(textwrap.fill(page.extract)) |
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,71 @@ | ||
import os | ||
|
||
# System call | ||
os.system("") | ||
|
||
|
||
def cprint(fmt, fg=None, bg=None, style=None): | ||
""" | ||
Colour-printer. | ||
cprint( 'Hello!' ) # normal | ||
cprint( 'Hello!', fg='g' ) # green | ||
cprint( 'Hello!', fg='r', bg='w', style='bx' ) # bold red blinking on white | ||
List of colours (for fg and bg): | ||
k black | ||
r red | ||
g green | ||
y yellow | ||
b blue | ||
m magenta | ||
c cyan | ||
w white | ||
List of styles: | ||
b bold | ||
i italic | ||
u underline | ||
s strikethrough | ||
x blinking | ||
r reverse | ||
y fast blinking | ||
f faint | ||
h hide | ||
""" | ||
|
||
COLCODE = { | ||
"k": 0, # black | ||
"r": 1, # red | ||
"g": 2, # green | ||
"y": 3, # yellow | ||
"b": 4, # blue | ||
"m": 5, # magenta | ||
"c": 6, # cyan | ||
"w": 7, # white | ||
} | ||
|
||
FMTCODE = { | ||
"b": 1, # bold | ||
"f": 2, # faint | ||
"i": 3, # italic | ||
"u": 4, # underline | ||
"x": 5, # blinking | ||
"y": 6, # fast blinking | ||
"r": 7, # reverse | ||
"h": 8, # hide | ||
"s": 9, # strikethrough | ||
} | ||
|
||
# properties | ||
props = [] | ||
if isinstance(style, str): | ||
props = [FMTCODE[s] for s in style] | ||
if isinstance(fg, str): | ||
props.append(30 + COLCODE[fg]) | ||
if isinstance(bg, str): | ||
props.append(40 + COLCODE[bg]) | ||
|
||
# display | ||
props = ";".join([str(x) for x in props]) | ||
if props: | ||
print("\x1b[%sm%s\x1b[0m" % (props, fmt)) | ||
else: | ||
print(fmt) |
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