harnice 0.3.1__tar.gz → 0.3.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.
- {harnice-0.3.1 → harnice-0.3.2}/PKG-INFO +1 -1
- {harnice-0.3.1 → harnice-0.3.2}/pyproject.toml +1 -1
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/fileio.py +50 -7
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/rev_history.py +30 -24
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/library_utils.py +8 -2
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/PKG-INFO +1 -1
- {harnice-0.3.1 → harnice-0.3.2}/LICENSE +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/README.md +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/setup.cfg +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/__init__.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/__main__.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/cli.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/gui/launcher.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/channel_map.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/circuits_list.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/disconnect_map.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/formboard_graph.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/instances_list.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/library_history.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/manifest.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/post_harness_instances_list.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/lists/signals_list.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/__init__.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/cable.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/chtype.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/device.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/disconnect.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/flagnote.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/harness.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/macro.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/part.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/system.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/products/tblock.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/state.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/appearance.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/circuit_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/feature_tree_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/formboard_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/note_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/svg_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice/utils/system_utils.py +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/SOURCES.txt +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/dependency_links.txt +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/entry_points.txt +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/requires.txt +0 -0
- {harnice-0.3.1 → harnice-0.3.2}/src/harnice.egg-info/top_level.txt +0 -0
|
@@ -41,13 +41,15 @@ def path(target_value, structure_dict=None, base_directory=None):
|
|
|
41
41
|
|
|
42
42
|
# returns the filepath/filename of a filekey.
|
|
43
43
|
"""
|
|
44
|
-
|
|
44
|
+
Recursively searches for a value in a nested JSON structure and returns the path to the element containing that value.
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
It's complicated ... check out https://harnice.io/commands/fileio/ for more information.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
target_value (str): The value to search for.
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
Returns:
|
|
52
|
+
list: A list of container names leading to the element containing the target value, or None if not found.
|
|
51
53
|
"""
|
|
52
54
|
|
|
53
55
|
# FILES NOT DEPENDENT ON PRODUCT TYPE
|
|
@@ -65,7 +67,20 @@ def path(target_value, structure_dict=None, base_directory=None):
|
|
|
65
67
|
harnice_root = os.path.dirname(
|
|
66
68
|
os.path.dirname(os.path.dirname(harnice.__file__))
|
|
67
69
|
)
|
|
68
|
-
|
|
70
|
+
|
|
71
|
+
library_locations_path = os.path.join(harnice_root, "library_locations.csv")
|
|
72
|
+
|
|
73
|
+
if not os.path.exists(library_locations_path):
|
|
74
|
+
from harnice import cli
|
|
75
|
+
answer = cli.prompt(f"Library locations file not found at {library_locations_path}. Create it?", default="y")
|
|
76
|
+
if answer.lower() not in ("y", "yes", ""):
|
|
77
|
+
exit()
|
|
78
|
+
|
|
79
|
+
with open(library_locations_path, "w") as f:
|
|
80
|
+
f.write("repo_url,local_path\n")
|
|
81
|
+
f.write(f"https://github.com/harnice/harnice,{os.path.join(harnice_root, 'library_public')}\n")
|
|
82
|
+
|
|
83
|
+
return library_locations_path
|
|
69
84
|
|
|
70
85
|
if target_value == "project locations":
|
|
71
86
|
import harnice
|
|
@@ -73,6 +88,17 @@ def path(target_value, structure_dict=None, base_directory=None):
|
|
|
73
88
|
harnice_root = os.path.dirname(
|
|
74
89
|
os.path.dirname(os.path.dirname(harnice.__file__))
|
|
75
90
|
)
|
|
91
|
+
project_locations_path = os.path.join(harnice_root, "project_locations.csv")
|
|
92
|
+
if not os.path.exists(project_locations_path):
|
|
93
|
+
from harnice import cli
|
|
94
|
+
answer = cli.prompt(f"Project locations file not found at {project_locations_path}. Create it?", default="y")
|
|
95
|
+
if answer.lower() not in ("y", "yes", ""):
|
|
96
|
+
exit()
|
|
97
|
+
|
|
98
|
+
with open(project_locations_path, "w") as f:
|
|
99
|
+
f.write("traceable_key,local_path\n")
|
|
100
|
+
f.write("your project part number,local path to your project\n")
|
|
101
|
+
|
|
76
102
|
return os.path.join(harnice_root, "project_locations.csv")
|
|
77
103
|
|
|
78
104
|
if target_value == "drawnby":
|
|
@@ -81,7 +107,24 @@ def path(target_value, structure_dict=None, base_directory=None):
|
|
|
81
107
|
harnice_root = os.path.dirname(
|
|
82
108
|
os.path.dirname(os.path.dirname(harnice.__file__))
|
|
83
109
|
)
|
|
84
|
-
|
|
110
|
+
|
|
111
|
+
drawnby_path = os.path.join(harnice_root, "drawnby.json")
|
|
112
|
+
if not os.path.exists(drawnby_path):
|
|
113
|
+
from harnice import cli
|
|
114
|
+
answer = cli.prompt(f"Drawnby file not found at {drawnby_path}. Create it?", default="y")
|
|
115
|
+
if answer.lower() not in ("y", "yes", ""):
|
|
116
|
+
exit()
|
|
117
|
+
|
|
118
|
+
name = cli.prompt("Enter your name: (recommended: first inital, last name, all caps: K SHUTT)")
|
|
119
|
+
|
|
120
|
+
while not name:
|
|
121
|
+
print("Name cannot be empty. Please try again.")
|
|
122
|
+
name = cli.prompt("Enter your name")
|
|
123
|
+
|
|
124
|
+
with open(drawnby_path, "w") as f:
|
|
125
|
+
f.write(f"{name}\n")
|
|
126
|
+
|
|
127
|
+
return drawnby_path
|
|
85
128
|
|
|
86
129
|
# FILES INSIDE OF A STRUCURE DEFINED BY FILEIO
|
|
87
130
|
# look up from default structure state if not provided
|
|
@@ -32,32 +32,32 @@ Overwrite a revision history entry.
|
|
|
32
32
|
|
|
33
33
|
**Arguments:**
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
- `content_dict` (dict): The content to overwrite the revision history entry with.
|
|
36
|
+
- This should be a dictionary with the keys and values to overwrite.
|
|
37
|
+
- The keys should be the column names, and the values should be the new values.
|
|
38
|
+
- Some keys are protected and cannot be overwritten:
|
|
39
|
+
- `"product"`
|
|
40
|
+
- `"mfg"`
|
|
41
|
+
- `"pn"`
|
|
42
|
+
- `"rev"`
|
|
43
|
+
- `"releaseticket"`
|
|
44
|
+
- `"library_repo"`
|
|
45
|
+
- `"library_subpath"`
|
|
46
|
+
- `"datestarted"`
|
|
47
47
|
|
|
48
48
|
The function will update the revision history file as referenced by the current product file structure.
|
|
49
49
|
|
|
50
50
|
**Returns:**
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
- `None`
|
|
53
53
|
|
|
54
54
|
**Raises:**
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
- `KeyError`: If a key is provided that is not in the COLUMNS list.
|
|
57
|
+
- `KeyError`: If a protected key is provided.
|
|
58
|
+
- `ValueError`: If the revision history file is not found.
|
|
59
|
+
- `ValueError`: If the revision is not found in the revision history file.
|
|
60
|
+
- `RuntimeError`: If `state.rev` is not set.
|
|
61
61
|
"""
|
|
62
62
|
PROTECTED_KEYS = [
|
|
63
63
|
"product",
|
|
@@ -417,17 +417,24 @@ def append(next_rev=None):
|
|
|
417
417
|
# add lib_repo if filepath is found in library locations
|
|
418
418
|
library_repo = ""
|
|
419
419
|
library_subpath = ""
|
|
420
|
-
|
|
420
|
+
# Normalize path separators for comparison (handle both forward and backslashes)
|
|
421
|
+
cwd = str(os.getcwd()).lower().replace("\\", "/").strip("~")
|
|
421
422
|
|
|
422
423
|
for row in fileio.read_tsv("library locations", delimiter=","):
|
|
423
|
-
|
|
424
|
+
# Normalize path separators and expand user home directory if needed
|
|
425
|
+
lib_local_path_raw = str(row.get("local_path", "")).strip()
|
|
426
|
+
lib_local_path = (
|
|
427
|
+
os.path.expanduser(lib_local_path_raw).lower().replace("\\", "/").strip("~")
|
|
428
|
+
)
|
|
424
429
|
if lib_local_path in cwd:
|
|
425
430
|
library_repo = row.get("repo_url")
|
|
426
431
|
|
|
427
432
|
# keep only the portion AFTER local_path
|
|
428
433
|
idx = cwd.find(lib_local_path)
|
|
429
|
-
remainder = cwd[idx + len(lib_local_path) :]
|
|
430
|
-
|
|
434
|
+
remainder = cwd[idx + len(lib_local_path) :]
|
|
435
|
+
# Normalize path separators - handle both forward and backslashes
|
|
436
|
+
remainder = remainder.replace("\\", "/").lstrip("/")
|
|
437
|
+
parts = remainder.split("/") if remainder else []
|
|
431
438
|
|
|
432
439
|
# find the part number in the path
|
|
433
440
|
pn = str(state.partnumber("pn")).lower()
|
|
@@ -438,6 +445,7 @@ def append(next_rev=None):
|
|
|
438
445
|
core_parts = parts
|
|
439
446
|
|
|
440
447
|
# build library_subpath and product
|
|
448
|
+
# Use forward slashes for cross-platform compatibility (works in URLs and most contexts)
|
|
441
449
|
if core_parts:
|
|
442
450
|
library_subpath = (
|
|
443
451
|
"/".join(core_parts[1:]) + "/" if len(core_parts) > 1 else ""
|
|
@@ -510,8 +518,6 @@ def part_family_append(content_dict, rev_history_path):
|
|
|
510
518
|
fileio.get_git_hash_of_harnice_src()
|
|
511
519
|
)
|
|
512
520
|
|
|
513
|
-
rev = content_dict.get("rev")
|
|
514
|
-
|
|
515
521
|
if os.path.exists(rev_history_path):
|
|
516
522
|
rows = fileio.read_tsv(rev_history_path)
|
|
517
523
|
else:
|
|
@@ -303,7 +303,9 @@ def get_local_path(lib_repo):
|
|
|
303
303
|
os.makedirs(os.path.dirname(csv_path), exist_ok=True)
|
|
304
304
|
|
|
305
305
|
with open(csv_path, "w", encoding="utf-8") as f:
|
|
306
|
-
|
|
306
|
+
# Normalize the default path to ensure correct separators
|
|
307
|
+
normalized_path = os.path.normpath(default_local_path)
|
|
308
|
+
f.write(f"https://github.com/harnice/harnice,{normalized_path}\n")
|
|
307
309
|
|
|
308
310
|
print(f"[harnice] Created '{csv_path}'")
|
|
309
311
|
print(f"[harnice] Default library-public location: {default_local_path}")
|
|
@@ -328,6 +330,10 @@ def get_local_path(lib_repo):
|
|
|
328
330
|
if url.lower() == lib_repo.lower().strip():
|
|
329
331
|
if not local:
|
|
330
332
|
raise ValueError(f"No local path found for '{lib_repo}'")
|
|
331
|
-
|
|
333
|
+
# Expand user directory (~) and normalize path separators for current platform
|
|
334
|
+
expanded_path = os.path.expanduser(local)
|
|
335
|
+
# Normalize separators - os.path.normpath() converts forward slashes to
|
|
336
|
+
# backslashes on Windows, ensuring proper path format
|
|
337
|
+
return os.path.normpath(expanded_path)
|
|
332
338
|
|
|
333
339
|
raise ValueError(f"'{lib_repo}' not found in library locations")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|