aboutsummaryrefslogtreecommitdiff
path: root/src/ee/xml/uris.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/xml/uris.py')
-rw-r--r--src/ee/xml/uris.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ee/xml/uris.py b/src/ee/xml/uris.py
index 7bf0487..f0a1022 100644
--- a/src/ee/xml/uris.py
+++ b/src/ee/xml/uris.py
@@ -1,3 +1,5 @@
+from typing import Optional
+
CAPACITOR = "http://purl.org/ee/part-type#capacitor"
RESISTOR = "http://purl.org/ee/part-type#resistor"
DIODE = "http://purl.org/ee/part-type#diode"
@@ -5,3 +7,28 @@ INDUCTOR = "http://purl.org/ee/part-type#inductor"
CRYSTAL = "http://purl.org/ee/part-type#inductor"
DIGIKEY_URI = "https://digikey.com"
+
+_DIGIKEY_FACT_KEY_PREFIX = "http://purl.org/trygvis/ee/digikey-fact-key#"
+
+
+def make_digikey_fact_key(key: int) -> str:
+ return _DIGIKEY_FACT_KEY_PREFIX + str(key)
+
+
+def is_digikey_fact_key(uri: str) -> bool:
+ return uri.startswith(_DIGIKEY_FACT_KEY_PREFIX)
+
+
+def parse_digikey_fact_key(uri: str) -> Optional[int]:
+ if uri.startswith(_DIGIKEY_FACT_KEY_PREFIX):
+ try:
+ return int(uri[len(_DIGIKEY_FACT_KEY_PREFIX):])
+ except ValueError:
+ pass
+
+
+_FACT_KEY_PREFIX = "http://purl.org/trygvis/ee/fact-key#"
+
+
+def make_fact_key(name: str) -> str:
+ return "{}{}".format(_FACT_KEY_PREFIX, name)