pydsigner / anchovy

A minimal, unopinionated framework for static website generation.
Apache License 2.0
2 stars 0 forks source link

Custodian.degenericize_path cannot process bare ContextDirs #66

Closed pydsigner closed 1 year ago

pydsigner commented 1 year ago

The issue mentioned in #60, and worked around by removing directories from custody tracking, can still appear in other places, such as in testing for #65, where a glob in the root directory is resulting in a key of glob_manifest:working_dir:*.py, which includes a 'working_dir' component that must be degenericized. Presently, that results in explosions:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "<snip>\.venv\Scripts\anchovy.exe\__main__.py", line 7, in <module>
  File "<snip>\anchovy\src\anchovy\cli.py", line 232, in main
    run_from_rules(settings, rules, custodian, argv=remaining, prog=f'anchovy {label}')
  File "<snip>\anchovy\src\anchovy\cli.py", line 119, in run_from_rules
    context.run()
  File "<snip>\anchovy\src\anchovy\core.py", line 190, in run
    self.process(input_paths)
  File "<snip>\anchovy\src\anchovy\core.py", line 176, in process
    self.process(further_processing)
  File "<snip>\anchovy\src\anchovy\core.py", line 159, in process
    stale, msg = self.custodian.refresh_needed(path, output_paths)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<snip>\anchovy\src\anchovy\custody.py", line 310, in refresh_needed
    if not self.check_prior(up_key):
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<snip>\anchovy\src\anchovy\custody.py", line 277, in check_prior
    return checker(CustodyEntry(ptype, key, pmeta))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "examples\code_index.py", line 77, in glob_manifest_stale
    parent = context.custodian.degenericize_path(path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<snip>\anchovy\src\anchovy\custody.py", line 119, in degenericize_path
    dir_key = t.cast('ContextDir', str(path.parents[-2]))
                                       ~~~~~~~~~~~~^^^^
  File "<snip>\pathlib.py", line 445, in __getitem__
    raise IndexError(idx)
IndexError: -2