making-with-code-cli 5.0.0__tar.gz → 5.0.2__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 (41) hide show
  1. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/PKG-INFO +1 -1
  2. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/pyproject.toml +1 -1
  3. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/mwc_backend.py +18 -14
  4. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/settings.py +2 -2
  5. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/__init__.py +4 -4
  6. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/tasks.py +11 -11
  7. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/update/__init__.py +17 -2
  8. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/README.md +0 -0
  9. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/__init__.py +0 -0
  10. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/cli.py +0 -0
  11. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/curriculum.py +0 -0
  12. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/decorators.py +0 -0
  13. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/errors.py +0 -0
  14. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/__init__.py +0 -0
  15. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/base_backend.py +0 -0
  16. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_wrapper.py +0 -0
  17. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/helpers.py +0 -0
  18. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/mwc_accounts_api.py +0 -0
  19. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/styles.py +0 -0
  20. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/submit.py +0 -0
  21. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/__init__.py +0 -0
  22. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/assess.py +0 -0
  23. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/check/__init__.py +0 -0
  24. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/check/check_module.py +0 -0
  25. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/gitea_api/api.py +0 -0
  26. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/gitea_api/exceptions.py +0 -0
  27. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/log.py +0 -0
  28. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/patch.py +0 -0
  29. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/__init__.py +0 -0
  30. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/create.py +0 -0
  31. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/edit.py +0 -0
  32. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/show.py +0 -0
  33. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/setup.py +0 -0
  34. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/status.py +0 -0
  35. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/__init__.py +0 -0
  36. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/create.py +0 -0
  37. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/update.py +0 -0
  38. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student_repo_functions.py +0 -0
  39. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student_repos.py +0 -0
  40. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/update.py +0 -0
  41. {making_with_code_cli-5.0.0 → making_with_code_cli-5.0.2}/src/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: 5.0.0
3
+ Version: 5.0.2
4
4
  Summary: Courseware for Making With Code
5
5
  Author: Chris Proctor
6
6
  Author-email: Chris Proctor <chris@chrisproctor.net>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "making-with-code-cli"
3
- version = "5.0.0"
3
+ version = "5.0.2"
4
4
  description = "Courseware for Making With Code"
5
5
  authors = [{ name = "Chris Proctor", email = "chris@chrisproctor.net" }]
6
6
  requires-python = ">=3.11,<4.0"
@@ -1,5 +1,6 @@
1
1
  from .base_backend import GitBackend
2
- from subprocess import run
2
+ from subprocess import run, CalledProcessError
3
+ import traceback
3
4
  from pathlib import Path
4
5
  from urllib.parse import urlparse
5
6
  import click
@@ -8,7 +9,11 @@ import os
8
9
  import requests
9
10
  from making_with_code_cli.helpers import cd
10
11
  from making_with_code_cli.styles import (
12
+ address,
11
13
  confirm,
14
+ debug,
15
+ error,
16
+ info,
12
17
  )
13
18
  from making_with_code_cli.errors import (
14
19
  MissingSetting,
@@ -40,26 +45,25 @@ class MWCBackend(GitBackend):
40
45
  if (modpath / self.COMMIT_TEMPLATE).exists():
41
46
  run(f"git config commit.template {self.COMMIT_TEMPLATE}", shell=True,
42
47
  check=True, cwd=modpath)
43
- run("uv venv", shell=True, check=True, cwd=modpath)
48
+ run("uv venv", shell=True, check=True, cwd=modpath, capture_output=True)
44
49
  self.init_direnv(modpath)
45
50
 
46
51
  def update(self, module, modpath, install=True):
47
52
  if (modpath / ".git").is_dir():
48
53
  with cd(modpath):
49
54
  relpath = self.relative_path(modpath)
50
- try:
51
- click.echo(address(f"Checking {relpath} for updates.", preformatted=True))
52
- gitresult = run("git pull", shell=True, check=True, capture_output=True,
53
- text=True)
54
- click.echo(info(gitresult.stdout))
55
- if install and Path("pyproject.toml").exists():
56
- result = run("uv sync", shell=True, check=True,
57
- capture_output=True, text=True)
55
+ click.echo(address(f"Checking {relpath} for updates.", preformatted=True))
56
+ gitresult = run("git pull", shell=True, check=True, capture_output=True,
57
+ text=True)
58
+ click.echo(info(gitresult.stdout))
59
+ if install and Path("pyproject.toml").exists():
60
+ result = run("uv sync", shell=True, capture_output=True, text=True, cwd=modpath)
61
+ if result.returncode != 0:
62
+ click.echo(debug("Error running uv sync:"))
63
+ click.echo(debug(result.stderr, preformatted=True))
64
+ click.echo(error(f"There was a problem updating {relpath}. Ask a teacher."))
65
+ else:
58
66
  self.init_direnv(modpath)
59
- click.echo(info(result.stdout, preformatted=True))
60
- except CalledProcessError as e:
61
- click.echo(error(f"There was a problem updating {relpath}. Ask a teacher."))
62
- raise e
63
67
 
64
68
  def init_direnv(self, modpath):
65
69
  if not (modpath / ".envrc").exists():
@@ -1,5 +1,5 @@
1
1
  from pathlib import Path
2
- import tomllib
2
+ import tomlkit
3
3
  import os
4
4
 
5
5
 
@@ -24,7 +24,7 @@ def read_settings(settings_path=None):
24
24
  sp = get_settings_path(settings_path)
25
25
  if sp.exists():
26
26
  with open(sp, "rb") as f:
27
- return tomllib.load(f)
27
+ return tomlkit.load(f)
28
28
  else:
29
29
  return {}
30
30
 
@@ -1,7 +1,7 @@
1
1
  import click
2
2
  from subprocess import run
3
+ from pprint import pformat
3
4
  import traceback
4
- import yaml
5
5
  from making_with_code_cli.mwc_accounts_api import MWCAccountsAPI
6
6
  from making_with_code_cli.git_backend import get_backend
7
7
  from making_with_code_cli.update import update
@@ -95,9 +95,9 @@ def setup(ctx, config, debug, git_name, git_email, mwc_accounts_url):
95
95
  if settings.get('mwc_accounts_url'):
96
96
  click.echo(debug_fmt(f"Using custom MWC accounts server: {settings['mwc_accounts_url']}"))
97
97
  click.echo(debug_fmt("MWC Accounts Server status:"))
98
- click.echo(debug_fmt(str(status)))
99
- click.echo(info("MWC settings:"))
100
- click.echo(info(yaml.dump(settings), preformatted=True))
98
+ click.echo(debug_fmt(str(status), preformatted=True))
99
+ click.echo(debug_fmt("MWC settings:"))
100
+ click.echo(debug_fmt(settings, preformatted=True))
101
101
  write_settings(settings, config)
102
102
 
103
103
  task_classes = [
@@ -10,7 +10,7 @@ from making_with_code_cli.mwc_accounts_api import MWCAccountsAPI
10
10
  from making_with_code_cli.styles import (
11
11
  address,
12
12
  question,
13
- debug,
13
+ debug as debug_fmt,
14
14
  confirm,
15
15
  info,
16
16
  success,
@@ -177,7 +177,7 @@ def get_mwc_rc_path():
177
177
  xdg_config_home = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"))
178
178
  return xdg_config_home / "mwc" / "shell_config.sh"
179
179
 
180
- def platform_rc_file():
180
+ def platform_rc_file(debug=False):
181
181
  shell = get_shell_name()
182
182
  if shell == "zsh":
183
183
  dothome = Path(os.environ.get("ZDOTDIR", Path.home()))
@@ -195,7 +195,7 @@ def platform_rc_file():
195
195
  ]
196
196
  for sh, rc in candidates:
197
197
  if shell == sh and rc.exists():
198
- click.echo(debug(f"Shell identified as {sh}. Using {rc} as rc file."))
198
+ click.echo(debug_fmt(f"Shell identified as {sh}. Using {rc} as rc file."))
199
199
  return rc
200
200
  raise IOError("Can't find an rc file.")
201
201
 
@@ -223,20 +223,21 @@ class SetupTask:
223
223
  pass
224
224
 
225
225
  def report_not_needed(self):
226
- click.echo(info(f"{self.description} is already complete."))
226
+ click.echo(info(f"{self.description} is already complete.", preformatted=True))
227
227
 
228
228
  def report_complete(self):
229
- click.echo(success(f"{self.description} is complete!"))
229
+ click.echo(success(f"{self.description} is complete.", preformatted=True))
230
230
 
231
231
  def debug_log(self, message):
232
232
  if self.debug:
233
- click.echo(debug(message))
233
+ click.echo(debug_fmt(message))
234
234
 
235
235
  def executable_on_path(self, name):
236
236
  return bool(run(f"which {name}", shell=True, capture_output=True).stdout)
237
237
 
238
238
  class WriteMWCShellConfig(SetupTask):
239
239
  description = "Write the MWC shell config file to ~/.config/mwc/shell_config.sh or XDG_CONFIG_HOME"
240
+ docs_url = "https://docs.makingwithcode.org/making-with-code-cli/students.html#configuration"
240
241
 
241
242
  def is_complete(self):
242
243
  p = get_mwc_rc_path()
@@ -246,13 +247,15 @@ class WriteMWCShellConfig(SetupTask):
246
247
  mwc_rc_path = get_mwc_rc_path()
247
248
  config_text = self.generate_shell_config()
248
249
  self.debug_log(f"Writing to {mwc_rc_path}:\n\n{config_text}\n\n")
250
+ mwc_rc_path.parent.mkdir(parents=True, exist_ok=True)
249
251
  mwc_rc_path.write_text(config_text)
250
252
 
251
253
  def generate_shell_config(self):
252
254
  "Generates the shell configuration file contents"
253
255
  f = ""
254
256
  shell = get_shell_name()
255
- f += "# Making With Code RC File\n\n"
257
+ f += "# Making With Code RC File\n"
258
+ f += f"# See {self.docs_url}\n\n"
256
259
  f += "## Hook direnv into shell\n"
257
260
  f += f'eval "$(direnv hook {shell})"\n\n'
258
261
 
@@ -277,13 +280,10 @@ class SourceMWCShellConfig(SetupTask):
277
280
  return f"source {get_mwc_rc_path()}" in platform_rc_file().read_text()
278
281
 
279
282
  def run_task(self):
280
- rc_file = platform_rc_file()
283
+ rc_file = platform_rc_file(self.debug)
281
284
  self.debug_log(f"Adding `mwc` path to {rc_file}")
282
285
  with rc_file.open('a') as fh:
283
- result = run("which mwc", shell=True, check=True, text=True, capture_output=True)
284
- mwcpath = Path(result.stdout).parent
285
286
  fh.write(f"\n# MAKING WITH CODE\n")
286
- fh.write(f'export PATH="$PATH:{mwcpath}"\n')
287
287
  fh.write(f"source {get_mwc_rc_path()}\n")
288
288
  click.echo(info(f"Updated your shell login file ({rc_file}). You may need to close and reopen Terminal."))
289
289
 
@@ -2,7 +2,7 @@ import click
2
2
  import traceback
3
3
  from pathlib import Path
4
4
  from subprocess import run
5
- from making_with_code_cli.settings import read_settings
5
+ from making_with_code_cli.settings import read_settings, get_settings_path
6
6
  from making_with_code_cli.curriculum import get_curriculum
7
7
  from making_with_code_cli.git_backend import get_backend
8
8
  from making_with_code_cli.mwc_accounts_api import MWCAccountsAPI
@@ -18,13 +18,19 @@ from making_with_code_cli.styles import (
18
18
 
19
19
  @click.command()
20
20
  @click.option("--config", help="Path to config file (default: ~/.mwc)")
21
- def update(config):
21
+ @click.option("--debug", is_flag=True, help="Show debug-level output")
22
+ def update(config, debug):
22
23
  """Update the MWC work directory"""
23
24
  settings = read_settings(config)
25
+ sp = get_settings_path(config)
26
+ if debug:
27
+ click.echo(debug_fmt(f"Reading settings from {sp}"))
24
28
  if not settings:
25
29
  click.echo(error(f"Please run mwc setup first."))
26
30
  return
27
31
  mwc_home = Path(settings["work_dir"])
32
+ if debug:
33
+ click.echo(debug_fmt(f"mwc home is {mwc_home}."))
28
34
  if not mwc_home.exists():
29
35
  mwc_home.mkdir(mode=WORK_DIR_PERMISSIONS, parents=True)
30
36
  api = MWCAccountsAPI(settings.get('mwc_accounts_url'))
@@ -33,6 +39,15 @@ def update(config):
33
39
  except api.RequestFailed as bad_token:
34
40
  click.echo(error(f"Error logging into MWC accounts server. Please run mwc setup."))
35
41
  return
42
+ if debug:
43
+ if settings.get('mwc_accounts_url'):
44
+ click.echo(debug_fmt(f"Using custom MWC accounts server: {settings['mwc_accounts_url']}"))
45
+ click.echo(debug_fmt("MWC Accounts Server status:"))
46
+ click.echo(debug_fmt(str(status), preformatted=True))
47
+ click.echo(debug_fmt("MWC settings:"))
48
+ click.echo(debug_fmt(settings, preformatted=True))
49
+ if len(status['student_section_memberships']) == 0:
50
+ click.echo(info("There are no updates to run because you are not a student in any courses."))
36
51
  for course in status['student_section_memberships']:
37
52
  curr = get_curriculum(course['curriculum_site_url'], course['course_name'])
38
53
  git_backend = get_backend(curr['git_backend'])(settings)