Skip to content

Commit d28cb76

Browse files
authored
Merge pull request hed-standard#1086 from VisLab/develop
Updated schema handling to account for extra sections
2 parents 6da7b5c + 9ee5b28 commit d28cb76

27 files changed

Lines changed: 14421 additions & 765 deletions

hed/schema/hed_schema_constants.py

Lines changed: 163 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,163 @@
1-
from enum import Enum
2-
3-
4-
class HedSectionKey(Enum):
5-
""" Keys designating specific sections in a HedSchema object.
6-
"""
7-
# overarching category listing all tags
8-
Tags = 'tags'
9-
# Overarching category listing all unit classes
10-
UnitClasses = 'unitClasses'
11-
# Overarching category listing all units(not divided by type)
12-
Units = 'units'
13-
# Overarching category listing all unit modifiers.
14-
UnitModifiers = 'unitModifiers'
15-
# Overarching category listing all value classes
16-
ValueClasses = "valueClasses"
17-
# These are the allowed attributes list, gathered from the schema on load.
18-
Attributes = 'attributes'
19-
# These are the allowed attribute property list, gathered from the schema on load.
20-
Properties = 'properties'
21-
22-
23-
class HedKey:
24-
""" Known property and attribute names.
25-
26-
Notes:
27-
- These names should match the attribute values in the XML/wiki.
28-
29-
"""
30-
# Tag attributes
31-
ExtensionAllowed = 'extensionAllowed'
32-
Recommended = 'recommended'
33-
Required = 'required'
34-
RequireChild = 'requireChild'
35-
TagGroup = 'tagGroup'
36-
TakesValue = 'takesValue'
37-
TopLevelTagGroup = 'topLevelTagGroup'
38-
Unique = 'unique'
39-
UnitClass = 'unitClass'
40-
ValueClass = "valueClass"
41-
RelatedTag = "relatedTag"
42-
SuggestedTag = "suggestedTag"
43-
Rooted = "rooted"
44-
DeprecatedFrom = "deprecatedFrom"
45-
ConversionFactor = "conversionFactor"
46-
Reserved = "reserved"
47-
48-
SIUnit = 'SIUnit'
49-
UnitSymbol = 'unitSymbol'
50-
# Default Units for Type
51-
DefaultUnits = 'defaultUnits'
52-
UnitPrefix = 'unitPrefix'
53-
54-
SIUnitModifier = 'SIUnitModifier'
55-
SIUnitSymbolModifier = 'SIUnitSymbolModifier'
56-
57-
# value class attributes
58-
AllowedCharacter = 'allowedCharacter'
59-
60-
# Node attributes
61-
InLibrary = "inLibrary"
62-
HedID = 'hedId'
63-
64-
UnitClassDomain = "unitClassDomain"
65-
UnitDomain = "unitDomain"
66-
UnitModifierDomain = "unitModifierDomain"
67-
ValueClassDomain = "valueClassDomain"
68-
ElementDomain = "elementDomain"
69-
TagDomain = "tagDomain"
70-
AnnotationProperty = "annotationProperty"
71-
72-
BoolRange = "boolRange"
73-
TagRange = "tagRange"
74-
NumericRange = "numericRange"
75-
StringRange = "stringRange"
76-
UnitClassRange = "unitClassRange"
77-
UnitRange = "unitRange"
78-
ValueClassRange = "valueClassRange"
79-
80-
81-
class HedKeyOld:
82-
# Fully Deprecated properties
83-
BoolProperty = 'boolProperty'
84-
UnitClassProperty = 'unitClassProperty'
85-
UnitProperty = 'unitProperty'
86-
UnitModifierProperty = 'unitModifierProperty'
87-
ValueClassProperty = 'valueClassProperty'
88-
ElementProperty = 'elementProperty'
89-
NodeProperty = 'nodeProperty'
90-
IsInheritedProperty = 'isInheritedProperty'
91-
92-
93-
VERSION_ATTRIBUTE = 'version'
94-
LIBRARY_ATTRIBUTE = 'library'
95-
WITH_STANDARD_ATTRIBUTE = "withStandard"
96-
UNMERGED_ATTRIBUTE = "unmerged"
97-
NS_ATTRIB = "xmlns:xsi"
98-
NO_LOC_ATTRIB = "xsi:noNamespaceSchemaLocation"
99-
100-
# A list of all attributes that can appear in the header line
101-
valid_header_attributes = {
102-
VERSION_ATTRIBUTE,
103-
LIBRARY_ATTRIBUTE,
104-
WITH_STANDARD_ATTRIBUTE,
105-
NS_ATTRIB,
106-
NO_LOC_ATTRIB,
107-
UNMERGED_ATTRIBUTE
108-
}
109-
110-
character_types = {
111-
"ascii": set([chr(x) for x in range(0, 127)]),
112-
"nonascii": "nonascii", # Special case for all other printable unicode characters
113-
"printable": set([chr(x) for x in range(32, 127)]),
114-
"lowercase": set("abcdefghijklmnopqrstuvwxyz"),
115-
"uppercase": set("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
116-
"digits": set("0123456789"),
117-
"tab": set("\t"),
118-
"newline": set("\n"),
119-
"blank": set(" "),
120-
"exclamation": set("!"),
121-
"double-quote": set('"'),
122-
"number-sign": set("#"),
123-
"dollar": set("$"),
124-
"percent-sign": set("%"),
125-
"ampersand": set("&"),
126-
"single-quote": set("'"),
127-
"left-paren": set("("),
128-
"right-paren": set(")"),
129-
"asterisk": set("*"),
130-
"plus": set("+"),
131-
"comma": set(","),
132-
"hyphen": set("-"),
133-
"period": set("."),
134-
"slash": set("/"),
135-
"colon": set(":"),
136-
"semicolon": set(";"),
137-
"less-than": set("<"),
138-
"equals": set("="),
139-
"greater-than": set(">"),
140-
"question-mark": set("?"),
141-
"at-sign": set("@"),
142-
"backslash": set("\\"),
143-
"caret": set("^"),
144-
"underscore": set("_"),
145-
"vertical-bar": set("|"),
146-
"tilde": set("~"),
147-
}
148-
149-
banned_delimiters = set(",[]{}")
150-
151-
# Compound types
152-
character_types["letters"] = character_types["lowercase"] | character_types["uppercase"]
153-
character_types["alphanumeric"] = character_types["letters"] | character_types["digits"]
154-
character_types["text"] = character_types["printable"].copy()
155-
character_types["text"].add("nonascii")
156-
character_types["text"] -= banned_delimiters
157-
character_types["name"] = (character_types["alphanumeric"] | character_types["hyphen"] |
158-
character_types["period"] | character_types["underscore"])
159-
character_types["name"].add("nonascii")
1+
from enum import Enum
2+
3+
4+
class HedSectionKey(Enum):
5+
""" Keys designating specific sections in a HedSchema object.
6+
"""
7+
# overarching category listing all tags
8+
Tags = 'tags'
9+
# Overarching category listing all unit classes
10+
UnitClasses = 'unitClasses'
11+
# Overarching category listing all units(not divided by type)
12+
Units = 'units'
13+
# Overarching category listing all unit modifiers.
14+
UnitModifiers = 'unitModifiers'
15+
# Overarching category listing all value classes
16+
ValueClasses = "valueClasses"
17+
# These are the allowed attributes list, gathered from the schema on load.
18+
Attributes = 'attributes'
19+
# These are the allowed attribute property list, gathered from the schema on load.
20+
Properties = 'properties'
21+
22+
23+
class HedKey:
24+
""" Known property and attribute names.
25+
26+
Notes:
27+
- These names should match the attribute values in the XML/wiki.
28+
29+
"""
30+
# Tag attributes
31+
ExtensionAllowed = 'extensionAllowed'
32+
Recommended = 'recommended'
33+
Required = 'required'
34+
RequireChild = 'requireChild'
35+
TagGroup = 'tagGroup'
36+
TakesValue = 'takesValue'
37+
TopLevelTagGroup = 'topLevelTagGroup'
38+
Unique = 'unique'
39+
UnitClass = 'unitClass'
40+
ValueClass = "valueClass"
41+
RelatedTag = "relatedTag"
42+
SuggestedTag = "suggestedTag"
43+
Rooted = "rooted"
44+
DeprecatedFrom = "deprecatedFrom"
45+
ConversionFactor = "conversionFactor"
46+
Reserved = "reserved"
47+
48+
SIUnit = 'SIUnit'
49+
UnitSymbol = 'unitSymbol'
50+
# Default Units for Type
51+
DefaultUnits = 'defaultUnits'
52+
UnitPrefix = 'unitPrefix'
53+
54+
SIUnitModifier = 'SIUnitModifier'
55+
SIUnitSymbolModifier = 'SIUnitSymbolModifier'
56+
57+
# value class attributes
58+
AllowedCharacter = 'allowedCharacter'
59+
60+
# Node attributes
61+
InLibrary = "inLibrary"
62+
HedID = 'hedId'
63+
64+
UnitClassDomain = "unitClassDomain"
65+
UnitDomain = "unitDomain"
66+
UnitModifierDomain = "unitModifierDomain"
67+
ValueClassDomain = "valueClassDomain"
68+
ElementDomain = "elementDomain"
69+
TagDomain = "tagDomain"
70+
AnnotationProperty = "annotationProperty"
71+
72+
BoolRange = "boolRange"
73+
TagRange = "tagRange"
74+
NumericRange = "numericRange"
75+
StringRange = "stringRange"
76+
UnitClassRange = "unitClassRange"
77+
UnitRange = "unitRange"
78+
ValueClassRange = "valueClassRange"
79+
80+
81+
class HedKeyOld:
82+
# Fully Deprecated properties
83+
BoolProperty = 'boolProperty'
84+
UnitClassProperty = 'unitClassProperty'
85+
UnitProperty = 'unitProperty'
86+
UnitModifierProperty = 'unitModifierProperty'
87+
ValueClassProperty = 'valueClassProperty'
88+
ElementProperty = 'elementProperty'
89+
NodeProperty = 'nodeProperty'
90+
IsInheritedProperty = 'isInheritedProperty'
91+
92+
93+
VERSION_ATTRIBUTE = 'version'
94+
LIBRARY_ATTRIBUTE = 'library'
95+
WITH_STANDARD_ATTRIBUTE = "withStandard"
96+
UNMERGED_ATTRIBUTE = "unmerged"
97+
NS_SPEC = 'xmlns'
98+
NS_ATTRIB = "xmlns:xsi"
99+
NO_LOC_ATTRIB = "xsi:noNamespaceSchemaLocation"
100+
LOC_ATTRIB = 'xsi:schemaLocation'
101+
102+
# A list of all attributes that can appear in the header line
103+
valid_header_attributes = {
104+
VERSION_ATTRIBUTE,
105+
LIBRARY_ATTRIBUTE,
106+
WITH_STANDARD_ATTRIBUTE,
107+
NS_ATTRIB,
108+
NS_SPEC,
109+
NO_LOC_ATTRIB,
110+
LOC_ATTRIB,
111+
UNMERGED_ATTRIBUTE
112+
}
113+
114+
character_types = {
115+
"ascii": set([chr(x) for x in range(0, 127)]),
116+
"nonascii": "nonascii", # Special case for all other printable unicode characters
117+
"printable": set([chr(x) for x in range(32, 127)]),
118+
"lowercase": set("abcdefghijklmnopqrstuvwxyz"),
119+
"uppercase": set("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
120+
"digits": set("0123456789"),
121+
"tab": set("\t"),
122+
"newline": set("\n"),
123+
"blank": set(" "),
124+
"exclamation": set("!"),
125+
"double-quote": set('"'),
126+
"number-sign": set("#"),
127+
"dollar": set("$"),
128+
"percent-sign": set("%"),
129+
"ampersand": set("&"),
130+
"single-quote": set("'"),
131+
"left-paren": set("("),
132+
"right-paren": set(")"),
133+
"asterisk": set("*"),
134+
"plus": set("+"),
135+
"comma": set(","),
136+
"hyphen": set("-"),
137+
"period": set("."),
138+
"slash": set("/"),
139+
"colon": set(":"),
140+
"semicolon": set(";"),
141+
"less-than": set("<"),
142+
"equals": set("="),
143+
"greater-than": set(">"),
144+
"question-mark": set("?"),
145+
"at-sign": set("@"),
146+
"backslash": set("\\"),
147+
"caret": set("^"),
148+
"underscore": set("_"),
149+
"vertical-bar": set("|"),
150+
"tilde": set("~"),
151+
}
152+
153+
banned_delimiters = set(",[]{}")
154+
155+
# Compound types
156+
character_types["letters"] = character_types["lowercase"] | character_types["uppercase"]
157+
character_types["alphanumeric"] = character_types["letters"] | character_types["digits"]
158+
character_types["text"] = character_types["printable"].copy()
159+
character_types["text"].add("nonascii")
160+
character_types["text"] -= banned_delimiters
161+
character_types["name"] = (character_types["alphanumeric"] | character_types["hyphen"] |
162+
character_types["period"] | character_types["underscore"])
163+
character_types["name"].add("nonascii")

0 commit comments

Comments
 (0)