ethspecify 0.1.3__py3-none-any.whl → 0.1.4__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.

Potentially problematic release.


This version of ethspecify might be problematic. Click here for more details.

ethspecify/core.py CHANGED
@@ -287,12 +287,28 @@ def replace_spec_tags(file_path):
287
287
  new_opening += f' hash="{hash_value}">'
288
288
  return new_opening
289
289
 
290
+ def rebuild_self_closing_tag(attributes, hash_value):
291
+ # Build a self-closing tag from attributes, forcing a single space before the slash.
292
+ new_tag = "<spec"
293
+ for key, val in attributes.items():
294
+ if key != "hash":
295
+ new_tag += f' {key}="{val}"'
296
+ new_tag += f' hash="{hash_value}" />'
297
+ return new_tag
298
+
290
299
  def replacer(match):
291
300
  # Always use the tag text from whichever group matched:
292
301
  if match.group("self") is not None:
293
302
  original_tag_text = match.group("self")
294
303
  else:
295
304
  original_tag_text = match.group("long")
305
+ # Determine the original opening tag (ignore inner content)
306
+ if match.group("self") is not None:
307
+ original_tag_text = match.group("self")
308
+ else:
309
+ long_tag_text = match.group("long")
310
+ opening_tag_match = re.search(r'<spec\b[^>]*>', long_tag_text)
311
+ original_tag_text = opening_tag_match.group(0) if opening_tag_match else long_tag_text
296
312
 
297
313
  attributes = extract_attributes(original_tag_text)
298
314
  print(f"spec tag: {attributes}")
@@ -301,18 +317,11 @@ def replace_spec_tags(file_path):
301
317
  hash_value = hashlib.sha256(spec.encode('utf-8')).hexdigest()[:8]
302
318
 
303
319
  if style == "hash":
304
- # For hash style, output a self-closing tag.
305
- if 'hash="' in original_tag_text:
306
- updated_tag = re.sub(
307
- r'(hash=")[^"]*(")',
308
- lambda m: f'{m.group(1)}{hash_value}{m.group(2)}',
309
- original_tag_text
310
- )
311
- else:
312
- updated_tag = re.sub(r'\s*/>$', f' hash="{hash_value}" />', original_tag_text)
320
+ # Rebuild a fresh self-closing tag.
321
+ updated_tag = rebuild_self_closing_tag(attributes, hash_value)
313
322
  return updated_tag
314
323
  else:
315
- # For full/diff styles, always rebuild as a long (paired) tag.
324
+ # For full/diff styles, rebuild as a long (paired) tag.
316
325
  new_opening = rebuild_opening_tag(attributes, hash_value)
317
326
  spec_content = get_spec_item(attributes)
318
327
  prefix = content[:match.start()].splitlines()[-1]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ethspecify
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -0,0 +1,9 @@
1
+ ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ethspecify/cli.py,sha256=TTKmSGUkuRdYlYS6t-cpVXpdpSKsYCWvmRDy8DcC10E,882
3
+ ethspecify/core.py,sha256=dJnhQpAhNpp_cY_fMj8k_cthXOVW_nagTl2oBZsIDc8,12654
4
+ ethspecify-0.1.4.dist-info/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
5
+ ethspecify-0.1.4.dist-info/METADATA,sha256=bALmnZ4tsQQ4ftX5JlwP06-i-O2jLcXowalbdEHa-2w,8790
6
+ ethspecify-0.1.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
+ ethspecify-0.1.4.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
8
+ ethspecify-0.1.4.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
9
+ ethspecify-0.1.4.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- ethspecify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ethspecify/cli.py,sha256=TTKmSGUkuRdYlYS6t-cpVXpdpSKsYCWvmRDy8DcC10E,882
3
- ethspecify/core.py,sha256=pUybFZnO8nDDQ-7tQjxbUjQHFTV4PEGFWJTyR3gy0hM,12194
4
- ethspecify-0.1.3.dist-info/LICENSE,sha256=Awxsr73mm9YMBVhBYnzeI7bNdRd-bH6RDtO5ItG0DaM,1071
5
- ethspecify-0.1.3.dist-info/METADATA,sha256=JI4igGfL54P1EEmtIG-54A1SV5mrhxIbCCOs2WufJmQ,8790
6
- ethspecify-0.1.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
- ethspecify-0.1.3.dist-info/entry_points.txt,sha256=09viGkCg9J3h0c9BFRN-BKaJUEaIc4JyULNgBP5EL_g,51
8
- ethspecify-0.1.3.dist-info/top_level.txt,sha256=0klaMvlVyOkXW09fwZTijJpdybITEp2c9zQKV5v30VM,11
9
- ethspecify-0.1.3.dist-info/RECORD,,