Coverage for datapool/yaml_stuff.py : 71%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# encoding: utf-8
obj = tuple(bunchify(item) for item in obj) obj = set(bunchify(item) for item in obj)
path = os.path.abspath(path) result = [] with open(path, "rb") as fh: data = yaml.load(fh) if data is None: return None for item in data: result.append(Bunch(item or {})) return result
except ValueError: continue raise FormatError("invalid date format: could not parse {!r}".format(s))
def check_yaml_fields_exist(bunch, path, check_attributes): """ "bunch" is a Bunch object holding data, eg site data. "path" is the location of the yaml file on on the file system, we need this for reporting errors "check_attributes" is a list of strings. every string may containt "." to check for chained attributes. """
# if we already complained about parent we skip this check: continue
# we record attribute alone, makes testing easier: parent, field = attribute.rsplit(".", 1) yield ConsistencyError("{}: attribute {} has no field '{}'".format(path, parent, field)) else: |