pypas-cli 0.4.2__tar.gz → 0.4.4__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.4.2/src/pypas_cli.egg-info → pypas_cli-0.4.4}/PKG-INFO +1 -1
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/pyproject.toml +1 -1
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/console.py +1 -1
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/exercise.py +18 -13
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/sysutils.py +32 -3
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/main.py +2 -5
- {pypas_cli-0.4.2 → pypas_cli-0.4.4/src/pypas_cli.egg-info}/PKG-INFO +1 -1
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/LICENSE +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/README.md +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/setup.cfg +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/__init__.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/auth.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/config.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/decorators.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/monads.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/lib/network.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas/settings.py +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas_cli.egg-info/SOURCES.txt +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas_cli.egg-info/dependency_links.txt +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas_cli.egg-info/entry_points.txt +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas_cli.egg-info/requires.txt +0 -0
- {pypas_cli-0.4.2 → pypas_cli-0.4.4}/src/pypas_cli.egg-info/top_level.txt +0 -0
|
@@ -7,6 +7,7 @@ import subprocess
|
|
|
7
7
|
import tempfile
|
|
8
8
|
import zipfile
|
|
9
9
|
from pathlib import Path
|
|
10
|
+
from typing import List
|
|
10
11
|
|
|
11
12
|
import pathspec
|
|
12
13
|
import pytest
|
|
@@ -101,18 +102,22 @@ class Exercise:
|
|
|
101
102
|
)
|
|
102
103
|
for dirpath, dirs, files in os.walk(src_dir):
|
|
103
104
|
for filename in files:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
incoming_file = Path(dirpath) / filename
|
|
106
|
+
current_file = incoming_file.relative_to(src_dir)
|
|
107
|
+
if current_file.exists():
|
|
108
|
+
if filecmp.cmp(current_file, incoming_file, shallow=False):
|
|
109
|
+
continue
|
|
110
|
+
console.info(f'[highlight][U][/highlight] {current_file}', cr=False)
|
|
111
|
+
if backup:
|
|
112
|
+
if backup_files.match_file(str(current_file)):
|
|
113
|
+
backup_file = current_file.with_suffix(current_file.suffix + '.bak')
|
|
114
|
+
console.debug(f' (Backup {current_file} → {backup_file})', cr=False)
|
|
115
|
+
shutil.copy(current_file, backup_file)
|
|
116
|
+
console.info('')
|
|
117
|
+
else:
|
|
118
|
+
console.info(f'[highlight][A][/highlight] {current_file}')
|
|
119
|
+
current_file.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
shutil.copy(incoming_file, current_file)
|
|
116
121
|
shutil.rmtree(src_dir, ignore_errors=True)
|
|
117
122
|
console.success('Exercise has been updated to the last version')
|
|
118
123
|
|
|
@@ -129,7 +134,7 @@ class Exercise:
|
|
|
129
134
|
console.error(monad.payload)
|
|
130
135
|
zipfile.unlink(missing_ok=True)
|
|
131
136
|
|
|
132
|
-
def test(self, args:
|
|
137
|
+
def test(self, args: List[str]):
|
|
133
138
|
if test_cmd := self.config.get('test_cmd'):
|
|
134
139
|
test_cmd = f'{test_cmd} {" ".join(args)}' if args else test_cmd
|
|
135
140
|
console.info(f'Running tests with: [note]{test_cmd}[/note]')
|
|
@@ -73,10 +73,17 @@ def get_package_data(package: str = 'pypas-cli') -> dict[str, str]:
|
|
|
73
73
|
return {}
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def
|
|
76
|
+
def show_package_info(package: str = 'pypas-cli') -> None:
|
|
77
77
|
if data := get_package_data(package):
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
console.print(
|
|
79
|
+
dedent(f"""\
|
|
80
|
+
Package: {data.get('name')}
|
|
81
|
+
Version: [note]{data.get('version')}[/note]
|
|
82
|
+
Path: {data.get('location')}\
|
|
83
|
+
""")
|
|
84
|
+
)
|
|
85
|
+
else:
|
|
86
|
+
console.error(f"Package '{package}' is not yet installed")
|
|
80
87
|
|
|
81
88
|
|
|
82
89
|
def get_latest_package_version(package: str = 'pypas-cli') -> str | None:
|
|
@@ -152,3 +159,25 @@ def unzip(zip_path: Path, extract_to: Path | None = None) -> Path:
|
|
|
152
159
|
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
|
153
160
|
zip_ref.extractall(extract_to)
|
|
154
161
|
return extract_to
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def handle_upgrade_pypas():
|
|
165
|
+
latest_version = get_latest_package_version()
|
|
166
|
+
package_data = get_package_data()
|
|
167
|
+
current_version = package_data.get('version')
|
|
168
|
+
# current_version = '0.0.0' # Temporary hardcoded version for testing
|
|
169
|
+
if latest_version and current_version:
|
|
170
|
+
if latest_version != current_version:
|
|
171
|
+
if upgrade_pypas():
|
|
172
|
+
console.success(
|
|
173
|
+
f'Upgraded pypas-cli from [note]v{current_version}[/note] to [note]v{latest_version}[/note]'
|
|
174
|
+
)
|
|
175
|
+
else:
|
|
176
|
+
console.error('Error upgrading pypas')
|
|
177
|
+
else:
|
|
178
|
+
console.success(
|
|
179
|
+
f"You're on the latest version of pypas-cli: [note]v{current_version}[/note]",
|
|
180
|
+
emphasis=False,
|
|
181
|
+
)
|
|
182
|
+
else:
|
|
183
|
+
console.error('Could not determine pypas-cli version information')
|
|
@@ -27,7 +27,7 @@ def default(
|
|
|
27
27
|
):
|
|
28
28
|
if version:
|
|
29
29
|
sysutils.handle_package_version()
|
|
30
|
-
|
|
30
|
+
sysutils.show_package_info()
|
|
31
31
|
# https://typer.tiangolo.com/tutorial/commands/context/#exclusive-executable-callback
|
|
32
32
|
elif ctx.invoked_subcommand is None:
|
|
33
33
|
typer.echo(ctx.get_help())
|
|
@@ -94,10 +94,7 @@ def auth(token: str = typer.Argument(help='Access token')):
|
|
|
94
94
|
@app.command()
|
|
95
95
|
def upgrade():
|
|
96
96
|
"""Upgrade pypas-cli from PyPI."""
|
|
97
|
-
|
|
98
|
-
print(sysutils.get_package_info())
|
|
99
|
-
else:
|
|
100
|
-
console.error('Error upgrading pypas')
|
|
97
|
+
sysutils.handle_upgrade_pypas()
|
|
101
98
|
|
|
102
99
|
|
|
103
100
|
@app.command()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|