Refactored Caching, Refactored BnfNodeParser, Introduced Sphinx
This commit is contained in:
+4
-2
@@ -261,7 +261,7 @@ def decode_enum(enum_repr: str):
|
||||
return None
|
||||
|
||||
|
||||
def str_concept(t):
|
||||
def str_concept(t, skip_key=None):
|
||||
"""
|
||||
The key,id identifiers of a concept are stored in a tuple
|
||||
we want to return the key and the id, separated by a pipe
|
||||
@@ -272,7 +272,9 @@ def str_concept(t):
|
||||
>>> assert str_concept(("key", None)) == "c:key:"
|
||||
>>> assert str_concept((None, None)) == ""
|
||||
>>> assert str_concept(Concept(key="foo", id="bar")) == "c:foo|bar:"
|
||||
>>> assert str_concept(Concept(key="foo", id="bar"), skip_key=True) == "c:|bar:"
|
||||
:param t:
|
||||
:param skip_key: True if we only want the id (and not the key)
|
||||
:return:
|
||||
"""
|
||||
if isinstance(t, tuple):
|
||||
@@ -283,7 +285,7 @@ def str_concept(t):
|
||||
if key is None and id_ is None:
|
||||
return ""
|
||||
|
||||
result = 'c:' if key is None else "c:" + key
|
||||
result = 'c:' if (key is None or skip_key) else "c:" + key
|
||||
if id_:
|
||||
result += "|" + id_
|
||||
return result + ":"
|
||||
|
||||
Reference in New Issue
Block a user