ethspecify 0.3.6__tar.gz → 0.3.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -875,7 +875,7 @@ def load_yaml_entries(yaml_file):
875
875
  return []
876
876
 
877
877
 
878
- def extract_spec_tag_key(spec_content):
878
+ def extract_spec_tag_key(spec_content, alias_groups=None, alias_preference=None):
879
879
  """Extract a unique key from spec tag to identify duplicates."""
880
880
  if not spec_content:
881
881
  return None
@@ -894,7 +894,14 @@ def extract_spec_tag_key(spec_content):
894
894
  for attr in ['fn', 'function', 'constant_var', 'config_var', 'preset_var',
895
895
  'container', 'ssz_object', 'dataclass', 'custom_type']:
896
896
  if attr in attributes:
897
- key_parts.append(f"{attr}:{attributes[attr]}")
897
+ normalized_attr = attr
898
+ if alias_groups:
899
+ for group_key, aliases in alias_groups.items():
900
+ if attr in aliases:
901
+ if alias_preference and group_key in alias_preference:
902
+ normalized_attr = alias_preference[group_key]
903
+ break
904
+ key_parts.append(f"{normalized_attr}:{attributes[attr]}")
898
905
  break
899
906
 
900
907
  if 'fork' in attributes:
@@ -923,18 +930,40 @@ def add_missing_entries_to_yaml(yaml_file, new_entries):
923
930
  # Load existing entries
924
931
  existing_entries = load_yaml_entries(yaml_file)
925
932
 
933
+ # Build alias preferences from the first existing entries in the file
934
+ alias_groups = {
935
+ 'function': ['fn', 'function'],
936
+ 'ssz_object': ['ssz_object', 'container'],
937
+ }
938
+ alias_preference = {}
939
+ for entry in existing_entries:
940
+ if not isinstance(entry, dict) or 'spec' not in entry:
941
+ continue
942
+ spec_content = entry.get('spec', '')
943
+ match = re.search(r'<spec\b([^>]*)>', spec_content)
944
+ if not match:
945
+ continue
946
+ attributes = extract_attributes(match.group(0))
947
+ for group_key, aliases in alias_groups.items():
948
+ if group_key in alias_preference:
949
+ continue
950
+ for alias in aliases:
951
+ if alias in attributes:
952
+ alias_preference[group_key] = alias
953
+ break
954
+
926
955
  # Build a set of existing spec tag keys
927
956
  existing_spec_keys = set()
928
957
  for entry in existing_entries:
929
958
  if isinstance(entry, dict) and 'spec' in entry:
930
- spec_key = extract_spec_tag_key(entry['spec'])
959
+ spec_key = extract_spec_tag_key(entry['spec'], alias_groups, alias_preference)
931
960
  if spec_key:
932
961
  existing_spec_keys.add(spec_key)
933
962
 
934
963
  # Filter out entries that already exist (based on spec tag, not name)
935
964
  entries_to_add = []
936
965
  for entry in new_entries:
937
- spec_key = extract_spec_tag_key(entry.get('spec', ''))
966
+ spec_key = extract_spec_tag_key(entry.get('spec', ''), alias_groups, alias_preference)
938
967
  if spec_key and spec_key not in existing_spec_keys:
939
968
  entries_to_add.append(entry)
940
969
  existing_spec_keys.add(spec_key) # Avoid duplicates within new entries
@@ -1862,6 +1891,10 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
1862
1891
  'dataclasses.yml': ('dataclasses', 'dataclass'),
1863
1892
  'types.yml': ('custom_types', 'custom_type'),
1864
1893
  }
1894
+ alias_groups = {
1895
+ 'functions': ['fn', 'function'],
1896
+ 'ssz_objects': ['container', 'ssz_object'],
1897
+ }
1865
1898
 
1866
1899
  for yaml_file in specrefs_files:
1867
1900
  yaml_path = os.path.join(project_dir, yaml_file)
@@ -1871,6 +1904,26 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
1871
1904
  continue
1872
1905
 
1873
1906
  category, spec_attr = filename_to_category[yaml_basename]
1907
+
1908
+ # Prefer the first alias used in the file for this category.
1909
+ if category in alias_groups:
1910
+ existing_entries = load_yaml_entries(yaml_path)
1911
+ preferred_attr = None
1912
+ for entry in existing_entries:
1913
+ if not isinstance(entry, dict) or 'spec' not in entry:
1914
+ continue
1915
+ match = re.search(r'<spec\b([^>]*)>', entry.get('spec', ''))
1916
+ if not match:
1917
+ continue
1918
+ attributes = extract_attributes(match.group(0))
1919
+ for alias in alias_groups[category]:
1920
+ if alias in attributes:
1921
+ preferred_attr = alias
1922
+ break
1923
+ if preferred_attr:
1924
+ break
1925
+ if preferred_attr:
1926
+ spec_attr = preferred_attr
1874
1927
  type_exceptions = []
1875
1928
  if isinstance(exceptions, dict) and category in category_exception_keys:
1876
1929
  for key in category_exception_keys[category]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
8
8
 
9
9
  setup(
10
10
  name="ethspecify",
11
- version="0.3.6",
11
+ version="0.3.7",
12
12
  description="A utility for processing Ethereum specification tags.",
13
13
  long_description=long_description,
14
14
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes