diff options
author | Rob Austein <sra@hactrn.net> | 2015-09-12 18:12:05 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-09-12 18:12:05 -0400 |
commit | e9eb486fae220903f039ffae5125894c1e156aa4 (patch) | |
tree | 8b866f5bd0cc7342fcbb406af604967113db2058 /py11/attributes.py | |
parent | d4dd9a8becf0c8f28479f0e48cc7f6708f786ee4 (diff) |
Move YAML parsing to external script so py11 doesn't have to worry
about finding attributes.yaml at runtime.
Diffstat (limited to 'py11/attributes.py')
-rw-r--r-- | py11/attributes.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/py11/attributes.py b/py11/attributes.py index 00af79c..7c90768 100644 --- a/py11/attributes.py +++ b/py11/attributes.py @@ -48,24 +48,14 @@ class Attribute_biginteger(Attribute): class AttributeDB(object): - def __init__(self, initializer = None): + def __init__(self): + from .attribute_map import attribute_map self.db = {} - if isinstance(initializer, str): - initializer = self.parse_yaml(initializer) - for attribute_name, type_name in initializer: + for attribute_name, type_name in attribute_map.iteritems(): a = Attribute.new(attribute_name, type_name) self.db[a.name] = a self.db[a.code] = a - @staticmethod - def parse_yaml(yaml_filename): - from yaml import safe_load - with open(yaml_filename) as f: - for y in safe_load(f): - for k, v in y.iteritems(): - if k.startswith("CKA_") and "type" in v: - yield k, v["type"] - def encode(self, k, v): return self.db[k].encode(v) if k in self.db else v |