making-with-code-cli 2.2.0__tar.gz → 2.2.1__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.
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/PKG-INFO +1 -1
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/curriculum.py +7 -4
- making_with_code_cli-2.2.1/making_with_code_cli/teach/check/__init__.py +44 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/check/check_module.py +22 -4
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/pyproject.toml +1 -1
- making_with_code_cli-2.2.0/making_with_code_cli/teach/check/__init__.py +0 -31
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/README.md +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/cli.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/errors.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_backend/__init__.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_backend/base_backend.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_backend/mwc_backend.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_wrapper.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/helpers.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/mwc_accounts_api.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/settings.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/__init__.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/tasks.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/styles.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/submit.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/__init__.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/assess.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/gitea_api/api.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/gitea_api/exceptions.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/log.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/patch.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/setup.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/status.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/student_repo_functions.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/student_repos.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/update.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/update/__init__.py +0 -0
- {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/version.py +0 -0
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/curriculum.py
RENAMED
|
@@ -7,7 +7,7 @@ from making_with_code_cli.errors import (
|
|
|
7
7
|
|
|
8
8
|
LIVE_RELOAD = '<script src="/livereload.js?port=1024&mindelay=10"></script>'
|
|
9
9
|
|
|
10
|
-
def get_curriculum(mwc_site_url, course_name):
|
|
10
|
+
def get_curriculum(mwc_site_url, course_name=None):
|
|
11
11
|
"""Fetches curriculum metadata from the site url specified in settings.
|
|
12
12
|
Returns the curriculum metadata for course_name.
|
|
13
13
|
"""
|
|
@@ -16,9 +16,12 @@ def get_curriculum(mwc_site_url, course_name):
|
|
|
16
16
|
if response.ok:
|
|
17
17
|
text = response.text.strip(LIVE_RELOAD)
|
|
18
18
|
metadata = json.loads(text)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if course_name:
|
|
20
|
+
for course in metadata["courses"]:
|
|
21
|
+
if course["name"] == course_name:
|
|
22
|
+
return course
|
|
23
|
+
else:
|
|
24
|
+
return metadata
|
|
22
25
|
raise CurriculumNotFound(mwc_site_url, course_name)
|
|
23
26
|
else:
|
|
24
27
|
raise CurriculumSiteNotAvailable(mwc_site_url)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from textwrap import fill
|
|
2
|
+
import click
|
|
3
|
+
import requests
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
from making_with_code_cli.curriculum import get_curriculum
|
|
7
|
+
from making_with_code_cli.teach.check.check_module import TestMWCModule
|
|
8
|
+
|
|
9
|
+
@click.command()
|
|
10
|
+
@click.argument("url")
|
|
11
|
+
@click.argument("repo_dir", type=click.Path(exists=True, file_okay=False, writable=True,
|
|
12
|
+
path_type=Path))
|
|
13
|
+
@click.option("--course", "-c", help="Course name to check")
|
|
14
|
+
@click.option("--module", "-m", help="Module slug to check")
|
|
15
|
+
@click.option("--json", "-j", 'use_json', is_flag=True, help="JSON-structured output")
|
|
16
|
+
def check(url, repo_dir, course, module, use_json):
|
|
17
|
+
"Test MWC curriuclum and modules"
|
|
18
|
+
if course:
|
|
19
|
+
courses = [get_curriculum(url, course)]
|
|
20
|
+
else:
|
|
21
|
+
courses = get_curriculum(url)['courses']
|
|
22
|
+
test_cases = []
|
|
23
|
+
for course in courses:
|
|
24
|
+
for unit in course['units']:
|
|
25
|
+
for mod in unit['modules']:
|
|
26
|
+
if not module or mod['slug'] == module:
|
|
27
|
+
full_slug = '/'.join([course['slug'], unit['slug'], mod['slug']])
|
|
28
|
+
path = repo_dir / full_slug
|
|
29
|
+
test_cases.append((mod, path, full_slug))
|
|
30
|
+
results = []
|
|
31
|
+
if not module:
|
|
32
|
+
test_cases = tqdm(test_cases)
|
|
33
|
+
for mod, path, slug in test_cases:
|
|
34
|
+
test = TestMWCModule(mod, path)
|
|
35
|
+
errors = test.run()
|
|
36
|
+
if errors:
|
|
37
|
+
results.append((slug, errors))
|
|
38
|
+
if use_json:
|
|
39
|
+
print([{'module': slug, 'errors': errors} for slug, errors in results])
|
|
40
|
+
else:
|
|
41
|
+
for slug, errors in results:
|
|
42
|
+
print(slug)
|
|
43
|
+
for error in errors:
|
|
44
|
+
print(fill(error, width=80, initial_indent="- ", subsequent_indent=" "))
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
# Defines a test case for a MWC module.
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from subprocess import run
|
|
6
7
|
import requests
|
|
7
8
|
import toml
|
|
8
9
|
from git import Repo, InvalidGitRepositoryError, GitCommandError
|
|
9
10
|
|
|
10
11
|
DEFAULT_BRANCH_NAME = "main"
|
|
11
|
-
PYTHON_VERSION = "
|
|
12
|
+
PYTHON_VERSION = ">=3.10"
|
|
12
13
|
|
|
13
14
|
class TestCouldNotContinue(Exception):
|
|
14
15
|
pass
|
|
@@ -25,6 +26,7 @@ class TestMWCModule:
|
|
|
25
26
|
self.fetch_repo()
|
|
26
27
|
self.test_curriculum_page_exists()
|
|
27
28
|
self.test_has_commit_template()
|
|
29
|
+
self.test_poetry()
|
|
28
30
|
self.test_module_metadata()
|
|
29
31
|
except TestCouldNotContinue as err:
|
|
30
32
|
self.errors.append(str(err))
|
|
@@ -58,14 +60,30 @@ class TestMWCModule:
|
|
|
58
60
|
if not ct.exists:
|
|
59
61
|
self.errors.append(".commit_template is missing")
|
|
60
62
|
|
|
63
|
+
def test_poetry(self):
|
|
64
|
+
result = run("poetry check", cwd=self.repo_path, shell=True, capture_output=True,
|
|
65
|
+
text=True)
|
|
66
|
+
if result.returncode:
|
|
67
|
+
for err in result.stderr.split('\n'):
|
|
68
|
+
if err.strip():
|
|
69
|
+
self.errors.append(err.strip())
|
|
70
|
+
|
|
61
71
|
def test_module_metadata(self):
|
|
62
72
|
md_file = self.repo_path/"pyproject.toml"
|
|
63
73
|
if not md_file.exists():
|
|
64
74
|
self.errors.append(f"pyproject.toml missing")
|
|
65
75
|
return
|
|
66
76
|
md = toml.load(md_file)
|
|
67
|
-
|
|
77
|
+
if not "project" in md:
|
|
78
|
+
self.errors.append("'project' section missing from pyproject.toml")
|
|
79
|
+
return
|
|
80
|
+
if "tool" in md:
|
|
81
|
+
self.errors.append("Deprecated 'tool' section found in pyproject.toml")
|
|
82
|
+
pyversion = md['project'].get('requires-python')
|
|
68
83
|
if not pyversion == PYTHON_VERSION:
|
|
69
84
|
self.errors.append(f"python version is {pyversion}, expected {PYTHON_VERSION}")
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
import requests
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from tqdm import tqdm
|
|
5
|
-
from making_with_code_cli.curriculum import get_curriculum
|
|
6
|
-
from making_with_code_cli.teach.check.check_module import TestMWCModule
|
|
7
|
-
|
|
8
|
-
@click.command()
|
|
9
|
-
@click.argument("url")
|
|
10
|
-
@click.argument("course_name")
|
|
11
|
-
@click.argument("repo_dir", type=click.Path(exists=True, file_okay=False, writable=True,
|
|
12
|
-
path_type=Path))
|
|
13
|
-
def check(url, course_name, repo_dir):
|
|
14
|
-
"Test MWC curriuclum and modules"
|
|
15
|
-
curriculum = get_curriculum(url, course_name)
|
|
16
|
-
test_cases = []
|
|
17
|
-
for unit in curriculum['units']:
|
|
18
|
-
for module in unit['modules']:
|
|
19
|
-
full_slug = '/'.join([curriculum['slug'], unit['slug'], module['slug']])
|
|
20
|
-
path = repo_dir / full_slug
|
|
21
|
-
test_cases.append((module, path, full_slug))
|
|
22
|
-
results = []
|
|
23
|
-
for mod, path, slug in tqdm(test_cases):
|
|
24
|
-
test = TestMWCModule(module, path)
|
|
25
|
-
errors = test.run()
|
|
26
|
-
if errors:
|
|
27
|
-
results.append((slug, errors))
|
|
28
|
-
for slug, errors in results:
|
|
29
|
-
print(slug)
|
|
30
|
-
for error in errors:
|
|
31
|
-
print(f" - {error}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/mwc_accounts_api.py
RENAMED
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/__init__.py
RENAMED
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/__init__.py
RENAMED
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/assess.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/patch.py
RENAMED
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/setup.py
RENAMED
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/update.py
RENAMED
|
File without changes
|
{making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/update/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|