def load_json(self, f): from json import load if isinstance(f, basestring): with file(f, 'r') as fp: return load(fp) else: return load(f)
def load_raml(self, f): if isinstance(f, basestring): from pyraml.parser import load return load(f) else: from pyraml.parser import parse return parse(f.read(), dirname(f.name))
def parse(self): """ Parse the RAML file and return the InternalNode hierarchy from it """ description = prp.load(self.file) root = InternalNode("", None) if '/' in description.resources: res = description.resources['/'] del description.resources['/'] if res is not None: #FIXME: this duplicate code from _parse_resource if res.methods is not None: for method in res.methods: root.add_method(method) root.set_doc(res.description) if description.resources is not None: for name in description.resources: res = description.resources[name] self._parse_resource(root, name, res) return root
def _load_all_definitions(definition_path): if not definition_path: raise ValueError('Missing setting value" `RAML_PATH`.') return parser.load(definition_path)
def load(self, *parts): path = self.sample_path(*parts) return parser.load(path)