ethspecify 0.3.5__tar.gz → 0.3.6__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.5
3
+ Version: 0.3.6
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -184,11 +184,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
184
184
 
185
185
  ### `link`
186
186
 
187
- This style displays a GitHub link to the specification item.
187
+ This style displays an ethspec.tools link to the specification item.
188
188
 
189
189
  ```
190
190
  <spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
191
- https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
191
+ https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
192
192
  </spec>
193
193
  ```
194
194
 
@@ -158,11 +158,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
158
158
 
159
159
  ### `link`
160
160
 
161
- This style displays a GitHub link to the specification item.
161
+ This style displays an ethspec.tools link to the specification item.
162
162
 
163
163
  ```
164
164
  <spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
165
- https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
165
+ https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
166
166
  </spec>
167
167
  ```
168
168
 
@@ -235,14 +235,6 @@ def diff(a_name, a_content, b_name, b_content):
235
235
  return "\n".join(diff)
236
236
 
237
237
 
238
- @functools.lru_cache()
239
- def get_links(version="nightly"):
240
- url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/links.json"
241
- response = requests.get(url)
242
- response.raise_for_status()
243
- return response.json()
244
-
245
-
246
238
  @functools.lru_cache()
247
239
  def get_pyspec(version="nightly"):
248
240
  url = f"https://raw.githubusercontent.com/jtraglia/ethspecify/main/pyspec/{version}/pyspec.json"
@@ -563,23 +555,39 @@ def get_spec_item(attributes, config=None):
563
555
  raise Exception("there is no previous spec for this")
564
556
  return diff(previous_fork, strip_comments(previous_spec), fork, strip_comments(spec))
565
557
  if style == "link":
566
- if "function" in attributes or "fn" in attributes:
567
- if "function" in attributes and "fn" in attributes:
568
- raise Exception(f"cannot contain 'function' and 'fn'")
569
- if "function" in attributes:
570
- function_name = attributes["function"]
571
- else:
572
- function_name = attributes["fn"]
573
- for key, value in get_links(version).items():
574
- if fork in key and key.endswith(function_name):
575
- return value
576
- return "Could not find link"
577
- else:
558
+ link = build_spec_link(attributes, fork, version)
559
+ if link is None:
578
560
  return "Not available for this type of spec"
561
+ return link
579
562
  else:
580
563
  raise Exception("invalid style type")
581
564
 
582
565
 
566
+ def build_spec_link(attributes, fork, version):
567
+ base = f"https://ethspec.tools/#specs/{version}"
568
+ if "function" in attributes or "fn" in attributes:
569
+ if "function" in attributes and "fn" in attributes:
570
+ raise Exception(f"cannot contain 'function' and 'fn'")
571
+ function_name = attributes.get("function", attributes.get("fn"))
572
+ return f"{base}/functions-{function_name}-{fork}"
573
+ if "constant_var" in attributes:
574
+ return f"{base}/constant_vars-{attributes['constant_var']}-{fork}"
575
+ if "preset_var" in attributes:
576
+ return f"{base}/preset_vars-{attributes['preset_var']}-{fork}"
577
+ if "config_var" in attributes:
578
+ return f"{base}/config_vars-{attributes['config_var']}-{fork}"
579
+ if "custom_type" in attributes:
580
+ return f"{base}/custom_types-{attributes['custom_type']}-{fork}"
581
+ if "ssz_object" in attributes or "container" in attributes:
582
+ if "ssz_object" in attributes and "container" in attributes:
583
+ raise Exception(f"cannot contain 'ssz_object' and 'container'")
584
+ object_name = attributes.get("ssz_object", attributes.get("container"))
585
+ return f"{base}/ssz_objects-{object_name}-{fork}"
586
+ if "dataclass" in attributes:
587
+ return f"{base}/dataclasses-{attributes['dataclass']}-{fork}"
588
+ return None
589
+
590
+
583
591
  def extract_attributes(tag):
584
592
  attr_pattern = re.compile(r'(\w+)="(.*?)"')
585
593
  return dict(attr_pattern.findall(tag))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -184,11 +184,11 @@ def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch:
184
184
 
185
185
  ### `link`
186
186
 
187
- This style displays a GitHub link to the specification item.
187
+ This style displays an ethspec.tools link to the specification item.
188
188
 
189
189
  ```
190
190
  <spec fn="apply_pending_deposit" fork="electra" style="link" hash="83ee9126">
191
- https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#new-apply_pending_deposit
191
+ https://ethspec.tools/#specs/v1.7.0-alpha.1/functions-apply_pending_deposit-electra
192
192
  </spec>
193
193
  ```
194
194
 
@@ -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.5",
11
+ version="0.3.6",
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