From e9eb486fae220903f039ffae5125894c1e156aa4 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sat, 12 Sep 2015 18:12:05 -0400 Subject: Move YAML parsing to external script so py11 doesn't have to worry about finding attributes.yaml at runtime. --- py11/attributes.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'py11/attributes.py') 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 -- cgit v1.2.3