pypas-cli 0.2.6__tar.gz → 0.3.0__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.2.6 → pypas_cli-0.3.0}/PKG-INFO +1 -1
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/pyproject.toml +1 -1
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/exercise.py +9 -3
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/main.py +2 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/settings.py +0 -6
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/PKG-INFO +1 -1
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/LICENSE +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/README.md +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/setup.cfg +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/__init__.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/auth.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/config.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/console.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/decorators.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/monads.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/network.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas/lib/sysutils.py +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/SOURCES.txt +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/dependency_links.txt +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/entry_points.txt +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/requires.txt +0 -0
- {pypas_cli-0.2.6 → pypas_cli-0.3.0}/src/pypas_cli.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import fnmatch
|
|
3
4
|
import os
|
|
4
|
-
import re
|
|
5
5
|
import shutil
|
|
6
6
|
import subprocess
|
|
7
7
|
import tempfile
|
|
@@ -57,13 +57,14 @@ class Exercise:
|
|
|
57
57
|
|
|
58
58
|
def zip(self, to_tmp_dir: bool = False, verbose: bool = False) -> Path:
|
|
59
59
|
console.info('Compressing exercise contents', cr=verbose)
|
|
60
|
+
exclude_patterns = self.config.get('exclude_from_zip', [])
|
|
60
61
|
zip_path = tempfile.mkstemp(suffix='.zip')[1] if to_tmp_dir else self.zipname
|
|
61
62
|
zip_file = Path(zip_path)
|
|
62
63
|
with zipfile.ZipFile(zip_file, 'w') as archive:
|
|
63
64
|
for file in self.files:
|
|
64
65
|
if file.name == self.zipname:
|
|
65
66
|
continue
|
|
66
|
-
if
|
|
67
|
+
if any(fnmatch.fnmatch(str(file), pattern) for pattern in exclude_patterns):
|
|
67
68
|
if verbose:
|
|
68
69
|
console.warning(f'Ignoring {file}')
|
|
69
70
|
continue
|
|
@@ -92,10 +93,15 @@ class Exercise:
|
|
|
92
93
|
os.system(f'{sysutils.get_open_cmd()} docs/README.pdf')
|
|
93
94
|
|
|
94
95
|
def update(self, src_dir: Path, backup: bool = True):
|
|
96
|
+
backup_files = self.config.get('backup_on_update', [])
|
|
95
97
|
for file in src_dir.glob('**/*'):
|
|
96
98
|
if file.is_file():
|
|
97
99
|
rel_file = file.relative_to(src_dir)
|
|
98
|
-
if
|
|
100
|
+
if (
|
|
101
|
+
backup
|
|
102
|
+
and rel_file.exists()
|
|
103
|
+
and any(fnmatch.fnmatch(str(rel_file), pattern) for pattern in backup_files)
|
|
104
|
+
):
|
|
99
105
|
backup_file = rel_file.with_suffix(rel_file.suffix + '.bak')
|
|
100
106
|
console.debug(f'Backup {rel_file} → {backup_file}')
|
|
101
107
|
shutil.copy(rel_file, backup_file)
|
|
@@ -71,6 +71,7 @@ def update(
|
|
|
71
71
|
),
|
|
72
72
|
):
|
|
73
73
|
"""Update exercise."""
|
|
74
|
+
# Backup patterns follow fnmatch syntax: https://docs.python.org/3/library/fnmatch.html
|
|
74
75
|
config = Config()
|
|
75
76
|
if (exercise := Exercise.from_config()).download(config.get('token')):
|
|
76
77
|
dir = exercise.unzip(to_tmp_dir=True)
|
|
@@ -98,6 +99,7 @@ def upgrade():
|
|
|
98
99
|
@inside_exercise
|
|
99
100
|
def zip(verbose: bool = typer.Option(False, '--verbose', '-v', help='Increase verbosity.')):
|
|
100
101
|
"""Compress exercise contents."""
|
|
102
|
+
# Excluded patterns follow fnmatch syntax: https://docs.python.org/3/library/fnmatch.html
|
|
101
103
|
exercise = Exercise.from_config()
|
|
102
104
|
zipfile = exercise.zip(verbose=verbose)
|
|
103
105
|
size, str_size = sysutils.get_file_size(zipfile)
|
|
@@ -14,9 +14,3 @@ PYPAS_PULL_URLPATH = urljoin(PYPAS_BASE_URL, '/assignments/pull/{item_slug}/')
|
|
|
14
14
|
EXERCISE_CONFIG_FILE = config('EXERCISE_CONFIG_FILE', default='.pypas.toml')
|
|
15
15
|
MAIN_CONFIG_FILE = config('MAIN_CONFIG_FILE', default=Path.home() / '.pypas.toml', cast=Path)
|
|
16
16
|
LARGE_FILE_SIZE = config('LARGE_FILE_SIZE', default=1024 * 1024, cast=int)
|
|
17
|
-
ZIP_IGNORED_PATTERNS = config(
|
|
18
|
-
'ZIP_IGNORED_PATTERNS',
|
|
19
|
-
default=r'cache,node_modules,DS_Store,venv,\.git,\.idea',
|
|
20
|
-
cast=config.list,
|
|
21
|
-
)
|
|
22
|
-
ZIP_IGNORED_PATTERNS_RE = '|'.join(ZIP_IGNORED_PATTERNS)
|
|
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
|
|
File without changes
|