diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-02-26 23:14:22 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-02-26 23:14:22 +0100 |
commit | f14a40a4f80275daceeb73f944e1aa1f84d16c79 (patch) | |
tree | 9ce3cd2b8702214bc94ae3f38b568bf8bdd5eaa0 /src/ee/xml/uris.py | |
parent | 97c8bb9db96e27051f8746865f657408263db0b8 (diff) | |
download | ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.gz ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.bz2 ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.xz ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.zip |
o Removing digikey specific DistributionInfo element. Can be generic.
Diffstat (limited to 'src/ee/xml/uris.py')
-rw-r--r-- | src/ee/xml/uris.py | 27 |
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) |