cr-proc 0.1.9__py3-none-any.whl → 0.1.10__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.
@@ -1,10 +1,38 @@
1
1
  """Document resolution and filtering utilities."""
2
2
  import difflib
3
3
  import sys
4
- from pathlib import Path
4
+ from pathlib import Path, PureWindowsPath, PurePosixPath
5
5
  from typing import Any
6
6
 
7
7
 
8
+ def _normalize_document_path(doc_path: str) -> tuple[str, str]:
9
+ """
10
+ Normalize a document path to extract filename and stem.
11
+
12
+ Handles both Windows-style (backslash) and Unix-style (forward slash) paths
13
+ regardless of the current platform.
14
+
15
+ Parameters
16
+ ----------
17
+ doc_path : str
18
+ Document path string (may use Windows or Unix separators)
19
+
20
+ Returns
21
+ -------
22
+ tuple[str, str]
23
+ (filename, stem) extracted from the path
24
+ """
25
+ # Try to detect if this is a Windows path (contains backslashes)
26
+ if "\\" in doc_path:
27
+ # Windows-style path
28
+ path_obj = PureWindowsPath(doc_path)
29
+ else:
30
+ # Unix-style path (or just a filename)
31
+ path_obj = PurePosixPath(doc_path)
32
+
33
+ return path_obj.name, path_obj.stem
34
+
35
+
8
36
  def find_matching_template(
9
37
  template_dir: Path, document_path: str
10
38
  ) -> Path | None:
@@ -31,8 +59,7 @@ def find_matching_template(
31
59
  if not template_dir.is_dir():
32
60
  return None
33
61
 
34
- doc_name = Path(document_path).name
35
- doc_stem = Path(document_path).stem
62
+ doc_name, doc_stem = _normalize_document_path(document_path)
36
63
 
37
64
  # First, try exact filename match
38
65
  exact_match = template_dir / doc_name
@@ -81,19 +108,25 @@ def get_normalized_document_key(doc_path: str) -> tuple[str, str]:
81
108
  Get a normalized key for a document based on filename and extension.
82
109
 
83
110
  This helps identify documents that are the same but with different paths.
111
+ Handles both Windows and Unix style paths correctly.
84
112
 
85
113
  Parameters
86
114
  ----------
87
115
  doc_path : str
88
- Document path
116
+ Document path (may use Windows or Unix separators)
89
117
 
90
118
  Returns
91
119
  -------
92
120
  tuple[str, str]
93
121
  (filename_with_extension, extension) for grouping similar documents
94
122
  """
95
- path_obj = Path(doc_path)
96
- return (path_obj.name, path_obj.suffix)
123
+ filename, _ = _normalize_document_path(doc_path)
124
+ # Get extension from filename
125
+ if '.' in filename:
126
+ extension = '.' + filename.rsplit('.', 1)[1]
127
+ else:
128
+ extension = ''
129
+ return (filename, extension)
97
130
 
98
131
 
99
132
  def group_documents_by_name(docs: list[str]) -> dict[tuple[str, str], list[str]]:
@@ -205,7 +238,8 @@ def resolve_document(
205
238
 
206
239
  if override:
207
240
  matches = [
208
- d for d in unique_docs if d.endswith(override) or Path(d).name == override
241
+ d for d in unique_docs
242
+ if d.endswith(override) or _normalize_document_path(d)[0] == override
209
243
  ]
210
244
  if not matches:
211
245
  raise ValueError(
@@ -220,7 +254,10 @@ def resolve_document(
220
254
  # If template_path is provided and is a file (not directory), use its extension for matching
221
255
  if template_path and template_path.is_file():
222
256
  template_ext = template_path.suffix
223
- ext_matches = [d for d in unique_docs if Path(d).suffix == template_ext]
257
+ ext_matches = [
258
+ d for d in unique_docs
259
+ if _normalize_document_path(d)[0].endswith(template_ext)
260
+ ]
224
261
  if len(ext_matches) == 1:
225
262
  return ext_matches[0]
226
263
  if len(ext_matches) > 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cr_proc
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: A tool for processing BYU CS code recording files.
5
5
  Author: Ethan Dye
6
6
  Author-email: mrtops03@gmail.com
@@ -1,13 +1,13 @@
1
1
  code_recorder_processor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  code_recorder_processor/api/build.py,sha256=tljtuEFH-ZU-hSFYmlAMSY61W-DSptQo_D5-GjAasco,7951
3
- code_recorder_processor/api/document.py,sha256=mBvATBZs8yyCY_nDOX2qhw0Gp1mmwI3PgOAzFgHUiSY,9486
3
+ code_recorder_processor/api/document.py,sha256=DOQ0H1dQJtMs2P9E2qnKgg2iKQT9msgdE9oJXl36SnY,10622
4
4
  code_recorder_processor/api/load.py,sha256=Br-USpFQJ6W8c5hjmCnunM3V0_MURKZp5Yyl1IJdahc,5514
5
5
  code_recorder_processor/api/output.py,sha256=H2SC3pQ0C9V8YyN4yeA_KmvSoWXy_3T3TKWKhywIax4,2161
6
6
  code_recorder_processor/api/verify.py,sha256=9GpeoFQIiTzZd-DNSyN5OUM6YB5iMslO85oAjc0yoSU,34073
7
7
  code_recorder_processor/cli.py,sha256=ardcM3bLNhf6abOQ1Aj746x4hp8gerdklfDwszLlYKc,20504
8
8
  code_recorder_processor/display.py,sha256=IVTNFB3Vjzpc5ZHceAFQI2-o-N6bvjYmotLDaEy0KoU,7368
9
9
  code_recorder_processor/playback.py,sha256=6-OJtQOHKgfutxUNBMunWl-VVSIB0zUDENSl0EsPCh4,4008
10
- cr_proc-0.1.9.dist-info/METADATA,sha256=3yqgqvpe1juNoinP6Xn59UiowZen06mgFTh1eG2ZC8M,8915
11
- cr_proc-0.1.9.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
12
- cr_proc-0.1.9.dist-info/entry_points.txt,sha256=xb5dPAAWN1Z9NUHpvZgNakaslR1MVOERf_IfpG_M04M,77
13
- cr_proc-0.1.9.dist-info/RECORD,,
10
+ cr_proc-0.1.10.dist-info/METADATA,sha256=KYL9rim_NIa2ke0Xao0k8H4Y5QmD1Rw6u2OuT07dlhs,8916
11
+ cr_proc-0.1.10.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
12
+ cr_proc-0.1.10.dist-info/entry_points.txt,sha256=xb5dPAAWN1Z9NUHpvZgNakaslR1MVOERf_IfpG_M04M,77
13
+ cr_proc-0.1.10.dist-info/RECORD,,