pypas-cli 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/.gitignore +3 -0
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/PKG-INFO +6 -1
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/pyproject.toml +10 -2
- pypas_cli-0.0.3/src/pypas/lib/console.py +13 -0
- pypas_cli-0.0.3/src/pypas/lib/utils.py +23 -0
- pypas_cli-0.0.3/src/pypas/main.py +40 -0
- pypas_cli-0.0.3/src/pypas/settings.py +6 -0
- pypas_cli-0.0.2/src/pypas/main.py +0 -16
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/CHANGELOG.md +0 -0
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/LICENSE +0 -0
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/README.md +0 -0
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/justfile +0 -0
- {pypas_cli-0.0.2 → pypas_cli-0.0.3}/requirements-dev.txt +0 -0
- /pypas_cli-0.0.2/requirements.txt → /pypas_cli-0.0.3/src/pypas/__init__.py +0 -0
- {pypas_cli-0.0.2/src/pypas → pypas_cli-0.0.3/src/pypas/lib}/core.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pypas-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Python Practical Assignments
|
|
5
5
|
Project-URL: homepage, https://pypas.es
|
|
6
6
|
Project-URL: repository, https://github.com/sdelquin/pypas-cli
|
|
@@ -33,7 +33,12 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
33
33
|
Classifier: Operating System :: OS Independent
|
|
34
34
|
Classifier: Programming Language :: Python :: 3
|
|
35
35
|
Requires-Python: >=3.10
|
|
36
|
+
Requires-Dist: prettyconf
|
|
37
|
+
Requires-Dist: pytest
|
|
38
|
+
Requires-Dist: requests
|
|
39
|
+
Requires-Dist: rich
|
|
36
40
|
Requires-Dist: setuptools
|
|
41
|
+
Requires-Dist: tqdm
|
|
37
42
|
Requires-Dist: typer
|
|
38
43
|
Description-Content-Type: text/markdown
|
|
39
44
|
|
|
@@ -4,9 +4,17 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pypas-cli"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.3"
|
|
8
8
|
license = { file = "LICENSE" }
|
|
9
|
-
dependencies = [
|
|
9
|
+
dependencies = [
|
|
10
|
+
'setuptools',
|
|
11
|
+
'typer',
|
|
12
|
+
'prettyconf',
|
|
13
|
+
'requests',
|
|
14
|
+
'rich',
|
|
15
|
+
'tqdm',
|
|
16
|
+
'pytest',
|
|
17
|
+
]
|
|
10
18
|
authors = [
|
|
11
19
|
{ email = "sdelquin@gmail.com" },
|
|
12
20
|
{ name = "Sergio Delgado Quintero" },
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import requests
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def download(url: str, fname: str, save_temp=False, chunk_size=1024) -> Path:
|
|
9
|
+
# https://gist.github.com/yanqd0/c13ed29e29432e3cf3e7c38467f42f51
|
|
10
|
+
if save_temp:
|
|
11
|
+
tmp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
12
|
+
target_file = tmp_file.name
|
|
13
|
+
else:
|
|
14
|
+
target_file = fname
|
|
15
|
+
resp = requests.get(url, stream=True)
|
|
16
|
+
total = int(resp.headers.get('content-length', 0))
|
|
17
|
+
with open(target_file, 'wb') as file, tqdm(
|
|
18
|
+
desc=fname, total=total, unit='iB', unit_scale=True, unit_divisor=1024
|
|
19
|
+
) as bar:
|
|
20
|
+
for data in resp.iter_content(chunk_size=chunk_size):
|
|
21
|
+
size = file.write(data)
|
|
22
|
+
bar.update(size)
|
|
23
|
+
return Path(target_file)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import zipfile
|
|
3
|
+
from urllib.parse import urljoin
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from rich import print
|
|
7
|
+
|
|
8
|
+
from pypas import settings
|
|
9
|
+
from pypas.lib import utils
|
|
10
|
+
from pypas.lib.console import console
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(
|
|
13
|
+
add_completion=False,
|
|
14
|
+
help='✨ pypas',
|
|
15
|
+
no_args_is_help=True,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.command()
|
|
20
|
+
def run():
|
|
21
|
+
print('Hi there!')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@app.command()
|
|
25
|
+
def get(exercise_slug: str):
|
|
26
|
+
exercise_url = urljoin(settings.PYPAS_EXERCISES_URLPATH, exercise_slug + '/')
|
|
27
|
+
console.print(f'Getting exercise from: {exercise_url}')
|
|
28
|
+
fname = utils.download(exercise_url, f'{exercise_slug}.zip', save_temp=True)
|
|
29
|
+
console.print('Inflating exercise bundle', end=' ')
|
|
30
|
+
with zipfile.ZipFile(fname) as zip_ref:
|
|
31
|
+
zip_ref.extractall()
|
|
32
|
+
console.print('✔', style='success')
|
|
33
|
+
os.remove(fname)
|
|
34
|
+
console.print(
|
|
35
|
+
f'Exercise is available at folder [info]./{exercise_slug}[/info] [success]✔[/success]'
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == '__main__':
|
|
40
|
+
app()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|