entangled-cli 2.3.0__py3-none-any.whl → 2.3.2__py3-none-any.whl

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.
@@ -40,7 +40,7 @@ def reset():
40
40
  for path in input_file_list:
41
41
  logging.debug("reading `%s`", path)
42
42
  t.update(path)
43
- _, _ = read_markdown_file(path, refs=refs, hooks=hooks)
43
+ _, _ = read_markdown_file(t, path, refs=refs, hooks=hooks)
44
44
 
45
45
  for h in hooks:
46
46
  h.pre_tangle(refs)
@@ -46,17 +46,16 @@ def stitch(*, force: bool = False, show: bool = False):
46
46
  refs = ReferenceMap()
47
47
  content: dict[Path, list[Content]] = {}
48
48
  try:
49
- for path in input_file_list:
50
- logging.debug("reading `%s`", path)
51
- _, c = read_markdown_file(path, refs=refs, hooks=hooks)
52
- content[path] = c
53
-
54
49
  with transaction(mode) as t:
50
+ for path in input_file_list:
51
+ logging.debug("reading `%s`", path)
52
+ _, c = read_markdown_file(t, path, refs=refs, hooks=hooks)
53
+ content[path] = c
54
+
55
55
  for path in t.db.managed_files:
56
56
  logging.debug("reading `%s`", path)
57
57
  t.update(path)
58
- with open(path, "r") as f:
59
- CodeReader(path, refs).run(f.read())
58
+ _ = CodeReader(path, refs).run(t.read(path))
60
59
 
61
60
  for path in input_file_list:
62
61
  t.write(path, stitch_markdown(refs, content[path]), [])
@@ -52,7 +52,7 @@ def tangle(*, annotate: str | None = None, force: bool = False, show: bool = Fal
52
52
  for path in input_file_list:
53
53
  logging.debug("reading `%s`", path)
54
54
  t.update(path)
55
- _, _ = read_markdown_file(path, refs=refs, hooks=hooks)
55
+ _, _ = read_markdown_file(t, path, refs=refs, hooks=hooks)
56
56
 
57
57
  for h in hooks:
58
58
  h.pre_tangle(refs)
@@ -20,7 +20,12 @@ class EventHandler(FileSystemEventHandler):
20
20
  if event.event_type == "opened":
21
21
  return
22
22
  config.read()
23
- path = Path(event.src_path)
23
+
24
+ if isinstance(event.src_path, bytes):
25
+ path = Path(event.src_path.decode("utf-8"))
26
+ else:
27
+ path = Path(event.src_path)
28
+
24
29
  if path.absolute().is_relative_to(Path("./.entangled").absolute()):
25
30
  return
26
31
  if any(path.absolute().is_relative_to(p.absolute()) for p in self.watched):
entangled/io/stat.py CHANGED
@@ -55,7 +55,7 @@ class FileData:
55
55
  if stat is None:
56
56
  return None
57
57
 
58
- with open(path, "r") as f:
58
+ with open(path, "r", encoding="utf-8") as f:
59
59
  content = f.read()
60
60
  digest = hexdigest(content)
61
61
 
@@ -158,6 +158,9 @@ class Transaction:
158
158
  else:
159
159
  logging.debug("target `%s` unchanged", path)
160
160
 
161
+ def read(self, path: Path) -> str:
162
+ return self.fs[path].content
163
+
161
164
  def clear_orphans(self):
162
165
  orphans = self.db.managed_files - self.passed
163
166
  if not orphans:
entangled/io/virtual.py CHANGED
@@ -25,7 +25,7 @@ def atomic_write(target: Path, content: str, mode: int | None):
25
25
  """
26
26
  tmp_dir = Path() / ".entangled" / "tmp"
27
27
  tmp_dir.mkdir(exist_ok=True, parents=True)
28
- with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=tmp_dir) as f:
28
+ with tempfile.NamedTemporaryFile(mode="w", delete=False, dir=tmp_dir, encoding="utf-8") as f:
29
29
  _ = f.write(assure_final_newline(content))
30
30
  # Flush and sync contents to disk
31
31
  f.flush()
@@ -53,7 +53,7 @@ class FileCache:
53
53
  """
54
54
  if key not in self._data:
55
55
  if (s := stat(key)) is None:
56
- raise KeyError()
56
+ raise FileNotFoundError(key)
57
57
  self._data[key] = s
58
58
  return self._data[key]
59
59
 
@@ -8,6 +8,8 @@ import mawk
8
8
  import logging
9
9
 
10
10
  from entangled.config.language import Language
11
+ from entangled.io.transaction import Transaction
12
+ from entangled.io.virtual import FileCache
11
13
 
12
14
  from .config import config
13
15
  from .utility import first
@@ -146,8 +148,8 @@ class MarkdownLexer(mawk.RuleSet):
146
148
  self.flush_plain_text()
147
149
  return []
148
150
 
149
-
150
151
  def read_markdown_file(
152
+ t: Transaction,
151
153
  path: Path,
152
154
  refs: ReferenceMap | None = None,
153
155
  hooks: list[HookBase] | None = None) \
@@ -167,9 +169,8 @@ def read_markdown_file(
167
169
  content is a list of `PlainText | ReferenceId`. Each `ReferenceId` can be
168
170
  looked up in the reference map.
169
171
  """
170
- with open(path, "r") as f:
171
- rel_path = path.resolve().relative_to(Path.cwd())
172
- return read_markdown_string(f.read(), rel_path, refs, hooks)
172
+ rel_path = path.resolve().relative_to(Path.cwd())
173
+ return read_markdown_string(t.read(rel_path), rel_path, refs, hooks)
173
174
 
174
175
 
175
176
  def read_markdown_string(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: entangled-cli
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: Literate Programming toolbox
5
5
  Project-URL: Homepage, https://entangled.github.io/
6
6
  Project-URL: Repository, https://github.com/entangled/entangled.py
@@ -20,7 +20,7 @@ Requires-Dist: repl-session>=0.2.0
20
20
  Requires-Dist: rich-argparse<2,>=1.4.0
21
21
  Requires-Dist: rich<14,>=13.3.5
22
22
  Requires-Dist: tomlkit<0.13,>=0.12.1
23
- Requires-Dist: watchdog<4,>=3.0.0
23
+ Requires-Dist: watchdog>=6.0.0
24
24
  Description-Content-Type: text/markdown
25
25
 
26
26
  # Entangled
@@ -4,7 +4,7 @@ entangled/document.py,sha256=uKU0uvtJmsG4exxt2D4CGSmqiQYK2oTimGQyheTTxNM,4512
4
4
  entangled/from_str.py,sha256=rW2qXsfZxCuyypSE6FKb59KyfiqCp29ywxKnLa5Fil0,674
5
5
  entangled/logging.py,sha256=zbo8oMDeYbwMg0tom-aOMMqR_b6guwybpisOj4viVw0,1488
6
6
  entangled/main.py,sha256=8leHmSrVuMD9YP1_C_K2cYTnNnz-BRL9YpeT-J1QRJU,1514
7
- entangled/markdown_reader.py,sha256=5j-p43__EnLjSxa6neRl5YCUvT8Z7HbySzPjBjgd8aA,7495
7
+ entangled/markdown_reader.py,sha256=UUZyijrJpSCALbrKxB8ViuwCl5v5lrj9i8JzarzMwEI,7575
8
8
  entangled/parsing.py,sha256=HuIis_b5tEyVdfxprRtnhYNggx_SjDc5PzE5iJjPvoI,5440
9
9
  entangled/properties.py,sha256=sOzFigf_TuXCcT8cg-ilJCx3nqOBAifLU7oI36T9Cy8,2384
10
10
  entangled/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -16,12 +16,12 @@ entangled/version.py,sha256=RTD5BZt2bZcRpIcZQCepPi_KiJpK57KCNRK168jjZrM,85
16
16
  entangled/commands/__init__.py,sha256=dI8ZHT8j5Rt4lF5_GizqlCs7bUAvY5CZ5KmXF6zhLIw,316
17
17
  entangled/commands/brei.py,sha256=B3EYrD8IewVozyZOfUqJh0vTfm4l2SpebzGbzxQxaf4,1380
18
18
  entangled/commands/new.py,sha256=atvJa58tYkH9fL1-6iMrDElQedUTM2tit3GBKn6P99w,7065
19
- entangled/commands/reset.py,sha256=Py3zPtkR4GvN8lPa5tpoGFWGm2YNaN9O5eQMzbKb7fA,1916
19
+ entangled/commands/reset.py,sha256=OMmMH4LxBLAt2376KEtI-F9rKyFaSD0SRLwnbBxUfIQ,1919
20
20
  entangled/commands/status.py,sha256=KiQ1zr45m62NSOMDDGnSzy7i7QrSor3PLAhSdHzTZb4,1681
21
- entangled/commands/stitch.py,sha256=pAdA2n69gxjjruwfKqJZWchdGH2PiHE0lUx4Kgm9XsY,1990
21
+ entangled/commands/stitch.py,sha256=7XFzxwnh_HnIgYktOnQgEKJdc1Ag_rox8URF4OynQ4A,1970
22
22
  entangled/commands/sync.py,sha256=89poUlyfz_90_PkJrZMi22ze7D-b2mhfMi11GxZMPmY,1211
23
- entangled/commands/tangle.py,sha256=A-Cyqpqt0buYgJxuovJZx2r-NbU8da93rcIRDJs9EaU,2161
24
- entangled/commands/watch.py,sha256=CvcE9kEe1RweStz0gHrRQV0j76KdSPXBjhZ4G61d3wo,1642
23
+ entangled/commands/tangle.py,sha256=JOiM1e_Dk0p2mcq27mZ3bUc6MdbVBeNyxVjyQ-fw55w,2164
24
+ entangled/commands/watch.py,sha256=sEKI3vdRCkfdeACY9Ms9A2iXN-Z33atvDLdOFBYVyqA,1764
25
25
  entangled/config/__init__.py,sha256=HnhEyUn0p9dXjGdHz385I3UNjF5c8l1LNOS87pOLeYg,6321
26
26
  entangled/config/language.py,sha256=QuqyfWA5eAbhxk-NlpBtyqYTFC8457hmeLUaAcIgJ3I,1826
27
27
  entangled/config/templates.py,sha256=NPT5TaAczmLXXlFMaLeWO7YsRQZ5kHKki917LkFdlNM,1152
@@ -39,11 +39,11 @@ entangled/hooks/spdx_license.py,sha256=ptZlJ18AnneLbNprBlvu_PkvSxlLIQ4tnL5X55tl0
39
39
  entangled/hooks/task.py,sha256=0PXnJIfBCTpVAaSxGLdSWETnq1Q1YgYqeldKwX0fm8k,3847
40
40
  entangled/io/__init__.py,sha256=floq3Cc6jBBVJLzmeLYxW_-ebE1Ien76dKr1AzyOjGw,280
41
41
  entangled/io/filedb.py,sha256=eeLe_wqkHesof-nJknlEJIHjHLGwVJCHQ83ir2p1-ZQ,3913
42
- entangled/io/stat.py,sha256=L2BitRGewviJggkNmicMDwNMiC45CNEX600sp6lt2cY,1690
43
- entangled/io/transaction.py,sha256=Oyf59sOVdYvmWglNfTUanHCaVtdoZBKHgfbLqMRILkA,7622
44
- entangled/io/virtual.py,sha256=5xKEt1CmmwXXO23HNmfGlXPGD8HDHcaMlSMO9ZK5twQ,2965
45
- entangled_cli-2.3.0.dist-info/METADATA,sha256=-tkZRPoksrWVgTyFLh7zCtxoNTQAtSV3HWgRCy2igeA,18972
46
- entangled_cli-2.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- entangled_cli-2.3.0.dist-info/entry_points.txt,sha256=QekvPWFApAipNUVUT7jp-i7d_1V8INajgO8JeBK61y8,49
48
- entangled_cli-2.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
- entangled_cli-2.3.0.dist-info/RECORD,,
42
+ entangled/io/stat.py,sha256=vtfaqzCXlM0UwfrIB-yDYGiBcePVB1SWZ8D1CxTrlSE,1708
43
+ entangled/io/transaction.py,sha256=xPB_tqeVkYz6gLisz6AgDtgfECDuN_3CiInD3JBUfSs,7699
44
+ entangled/io/virtual.py,sha256=PjYzaizG1dTwEBAmXTTisekgU3k3TkX9VY7K8XLhDwQ,2995
45
+ entangled_cli-2.3.2.dist-info/METADATA,sha256=iXcjCDQHGJxC7zmFe5pdAw0TX-XpsF1Hfmt-99PF8i0,18969
46
+ entangled_cli-2.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ entangled_cli-2.3.2.dist-info/entry_points.txt,sha256=QekvPWFApAipNUVUT7jp-i7d_1V8INajgO8JeBK61y8,49
48
+ entangled_cli-2.3.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
+ entangled_cli-2.3.2.dist-info/RECORD,,