rolfedh-doc-utils 0.1.12__py3-none-any.whl → 0.1.13__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.
- doc_utils/extract_link_attributes.py +24 -13
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/METADATA +1 -1
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/RECORD +7 -7
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/WHEEL +0 -0
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/entry_points.txt +0 -0
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/licenses/LICENSE +0 -0
- {rolfedh_doc_utils-0.1.12.dist-info → rolfedh_doc_utils-0.1.13.dist-info}/top_level.txt +0 -0
|
@@ -257,13 +257,14 @@ def collect_all_macros(scan_dirs: List[str] = None) -> List[Tuple[str, str, str,
|
|
|
257
257
|
|
|
258
258
|
def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
|
|
259
259
|
existing_attrs: Dict[str, str],
|
|
260
|
-
interactive: bool = True) -> Dict[str, str]:
|
|
260
|
+
interactive: bool = True) -> Tuple[Dict[str, str], Dict[str, str]]:
|
|
261
261
|
"""
|
|
262
|
-
Create new attributes for each unique URL.
|
|
262
|
+
Create new attributes for each unique URL and track existing ones.
|
|
263
263
|
|
|
264
|
-
Returns:
|
|
264
|
+
Returns: Tuple[new_attributes, existing_matching_attributes]
|
|
265
265
|
"""
|
|
266
266
|
new_attributes = {}
|
|
267
|
+
existing_matching_attributes = {}
|
|
267
268
|
existing_attr_names = set(existing_attrs.keys())
|
|
268
269
|
counter = 1
|
|
269
270
|
|
|
@@ -273,6 +274,7 @@ def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
|
|
|
273
274
|
for attr_name, attr_value in existing_attrs.items():
|
|
274
275
|
if url in attr_value:
|
|
275
276
|
existing_attr = attr_name
|
|
277
|
+
existing_matching_attributes[attr_name] = attr_value
|
|
276
278
|
break
|
|
277
279
|
|
|
278
280
|
if existing_attr:
|
|
@@ -296,7 +298,7 @@ def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
|
|
|
296
298
|
|
|
297
299
|
print(f"Created attribute: :{attr_name}: {attr_value}")
|
|
298
300
|
|
|
299
|
-
return new_attributes
|
|
301
|
+
return new_attributes, existing_matching_attributes
|
|
300
302
|
|
|
301
303
|
|
|
302
304
|
def update_attribute_file(file_path: str, new_attributes: Dict[str, str], dry_run: bool = False):
|
|
@@ -505,15 +507,15 @@ def extract_link_attributes(attributes_file: str = None,
|
|
|
505
507
|
url_groups = group_macros_by_url(all_macros)
|
|
506
508
|
spinner.stop(f"Grouped into {len(url_groups)} unique URLs")
|
|
507
509
|
|
|
508
|
-
# Create new attributes
|
|
509
|
-
new_attributes = create_attributes(url_groups, existing_attrs, interactive)
|
|
510
|
+
# Create new attributes and track existing ones
|
|
511
|
+
new_attributes, existing_matching_attributes = create_attributes(url_groups, existing_attrs, interactive)
|
|
510
512
|
|
|
511
|
-
if not new_attributes:
|
|
512
|
-
print("No new attributes to create.")
|
|
513
|
+
if not new_attributes and not existing_matching_attributes:
|
|
514
|
+
print("No new attributes to create and no existing attributes match found URLs.")
|
|
513
515
|
return True
|
|
514
516
|
|
|
515
517
|
# Validate new attributes before writing if requested
|
|
516
|
-
if validate_links and not dry_run:
|
|
518
|
+
if validate_links and not dry_run and new_attributes:
|
|
517
519
|
print("\nValidating new link attributes...")
|
|
518
520
|
spinner = Spinner("Validating new URLs")
|
|
519
521
|
spinner.start()
|
|
@@ -543,10 +545,11 @@ def extract_link_attributes(attributes_file: str = None,
|
|
|
543
545
|
print("\nStopping due to broken URLs in new attributes (--fail-on-broken)")
|
|
544
546
|
return False
|
|
545
547
|
|
|
546
|
-
# Update attribute file
|
|
547
|
-
|
|
548
|
+
# Update attribute file (only if there are new attributes)
|
|
549
|
+
if new_attributes:
|
|
550
|
+
update_attribute_file(attributes_file, new_attributes, dry_run)
|
|
548
551
|
|
|
549
|
-
# Prepare file updates
|
|
552
|
+
# Prepare file updates (include both new and existing matching attributes)
|
|
550
553
|
all_attributes = {**existing_attrs, **new_attributes}
|
|
551
554
|
file_updates = prepare_file_updates(url_groups, all_attributes)
|
|
552
555
|
|
|
@@ -560,6 +563,14 @@ def extract_link_attributes(attributes_file: str = None,
|
|
|
560
563
|
if dry_run:
|
|
561
564
|
print("\n[DRY RUN] No files were modified. Run without --dry-run to apply changes.")
|
|
562
565
|
else:
|
|
563
|
-
|
|
566
|
+
total_processed = len(new_attributes) + len(existing_matching_attributes)
|
|
567
|
+
if new_attributes and existing_matching_attributes:
|
|
568
|
+
print(f"\nSuccessfully processed {total_processed} link attributes:")
|
|
569
|
+
print(f" - Created {len(new_attributes)} new attributes")
|
|
570
|
+
print(f" - Replaced macros using {len(existing_matching_attributes)} existing attributes")
|
|
571
|
+
elif new_attributes:
|
|
572
|
+
print(f"\nSuccessfully extracted {len(new_attributes)} link attributes")
|
|
573
|
+
elif existing_matching_attributes:
|
|
574
|
+
print(f"\nSuccessfully replaced macros using {len(existing_matching_attributes)} existing link attributes")
|
|
564
575
|
|
|
565
576
|
return True
|
|
@@ -7,7 +7,7 @@ format_asciidoc_spacing.py,sha256=_XpHqxYWm1AnZLUK_cDpfAJtsDCDF0b66m3opfYnIuU,39
|
|
|
7
7
|
replace_link_attributes.py,sha256=ZkBqrrpIiYGccGMgRjDBrWQKgpfOzHIegURmcgTwaHg,6614
|
|
8
8
|
validate_links.py,sha256=409fTAyBGTUrp6iSWuJ9AXExcdz8dC_4QeA_RvCIhus,5845
|
|
9
9
|
doc_utils/__init__.py,sha256=qqZR3lohzkP63soymrEZPBGzzk6-nFzi4_tSffjmu_0,74
|
|
10
|
-
doc_utils/extract_link_attributes.py,sha256=
|
|
10
|
+
doc_utils/extract_link_attributes.py,sha256=IIEq2bQmACwDszmaCMeMnYnPKwxSOHWbu_spYOJezlE,20700
|
|
11
11
|
doc_utils/file_utils.py,sha256=fpTh3xx759sF8sNocdn_arsP3KAv8XA6cTQTAVIZiZg,4247
|
|
12
12
|
doc_utils/format_asciidoc_spacing.py,sha256=XnVJekaj39aDzjV3xFKl58flM41AaJzejxNYJIIAMz0,10139
|
|
13
13
|
doc_utils/replace_link_attributes.py,sha256=kBiePbxjQn3O2rzqmYY8Mqy_mJgZ6yw048vSZ5SSB5E,6587
|
|
@@ -18,9 +18,9 @@ doc_utils/unused_adoc.py,sha256=2cbqcYr1os2EhETUU928BlPRlsZVSdI00qaMhqjSIqQ,5263
|
|
|
18
18
|
doc_utils/unused_attributes.py,sha256=EjTtWIKW_aXsR1JOgw5RSDVAqitJ_NfRMVOXVGaiWTY,5282
|
|
19
19
|
doc_utils/unused_images.py,sha256=nqn36Bbrmon2KlGlcaruNjJJvTQ8_9H0WU9GvCW7rW8,1456
|
|
20
20
|
doc_utils/validate_links.py,sha256=iBGXnwdeLlgIT3fo3v01ApT5k0X2FtctsvkrE6E3VMk,19610
|
|
21
|
-
rolfedh_doc_utils-0.1.
|
|
22
|
-
rolfedh_doc_utils-0.1.
|
|
23
|
-
rolfedh_doc_utils-0.1.
|
|
24
|
-
rolfedh_doc_utils-0.1.
|
|
25
|
-
rolfedh_doc_utils-0.1.
|
|
26
|
-
rolfedh_doc_utils-0.1.
|
|
21
|
+
rolfedh_doc_utils-0.1.13.dist-info/licenses/LICENSE,sha256=vLxtwMVOJA_hEy8b77niTkdmQI9kNJskXHq0dBS36e0,1075
|
|
22
|
+
rolfedh_doc_utils-0.1.13.dist-info/METADATA,sha256=BijPKBcklacOn-2U2VTfcMEJBkyOMoI84Ce5ItNK-vc,7386
|
|
23
|
+
rolfedh_doc_utils-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
24
|
+
rolfedh_doc_utils-0.1.13.dist-info/entry_points.txt,sha256=2J4Ojc3kkuArpe2xcUOPc0LxSWCmnctvw8hy8zpnbO4,418
|
|
25
|
+
rolfedh_doc_utils-0.1.13.dist-info/top_level.txt,sha256=1w0JWD7w7gnM5Sga2K4fJieNZ7CHPTAf0ozYk5iIlmo,182
|
|
26
|
+
rolfedh_doc_utils-0.1.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|