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.
Files changed (33) hide show
  1. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/PKG-INFO +1 -1
  2. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/curriculum.py +7 -4
  3. making_with_code_cli-2.2.1/making_with_code_cli/teach/check/__init__.py +44 -0
  4. {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
  5. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/pyproject.toml +1 -1
  6. making_with_code_cli-2.2.0/making_with_code_cli/teach/check/__init__.py +0 -31
  7. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/README.md +0 -0
  8. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/cli.py +0 -0
  9. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/errors.py +0 -0
  10. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_backend/__init__.py +0 -0
  11. {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
  12. {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
  13. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/git_wrapper.py +0 -0
  14. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/helpers.py +0 -0
  15. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/mwc_accounts_api.py +0 -0
  16. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/settings.py +0 -0
  17. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/__init__.py +0 -0
  18. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/setup/tasks.py +0 -0
  19. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/styles.py +0 -0
  20. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/submit.py +0 -0
  21. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/__init__.py +0 -0
  22. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/assess.py +0 -0
  23. {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
  24. {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
  25. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/log.py +0 -0
  26. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/patch.py +0 -0
  27. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/setup.py +0 -0
  28. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/status.py +0 -0
  29. {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
  30. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/student_repos.py +0 -0
  31. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/teach/update.py +0 -0
  32. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/update/__init__.py +0 -0
  33. {making_with_code_cli-2.2.0 → making_with_code_cli-2.2.1}/making_with_code_cli/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: making-with-code-cli
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Courseware for Making With Code
5
5
  Home-page: https://github.com/cproctor/making-with-code-courseware
6
6
  License: MIT
@@ -7,7 +7,7 @@ from making_with_code_cli.errors import (
7
7
 
8
8
  LIVE_RELOAD = '<script src="/livereload.js?port=1024&amp;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
- for course in metadata["courses"]:
20
- if course["name"] == course_name:
21
- return course
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 = "^3.10"
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
- pyversion = md["tool"]["poetry"]["dependencies"]["python"]
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
- if "dev-dependencies" in md["tool"]["poetry"]:
71
- self.errors.append("pyproject.toml has deprecated tool.poetry.dev-dependencies")
85
+
86
+
87
+
88
+
89
+
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "making-with-code-cli"
3
- version = "2.2.0"
3
+ version = "2.2.1"
4
4
  description = "Courseware for Making With Code"
5
5
  authors = ["Chris Proctor <chris@chrisproctor.net>"]
6
6
  license = "MIT"
@@ -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}")