def to_python(self, data): if isinstance(data, six.string_types): up = urlparse.urlparse(data) # if it looks like a file path if os.path.isfile(data) or up.scheme in ['http', 'https']: return libcnml.CNMLParser(data) else: raise ParserError('Could not decode CNML data') elif isinstance(data, libcnml.CNMLParser): return data else: raise ParserError('Could not find valid data to parse')
def setUp(self): filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), self.cnml_file) self.parser = libcnml.CNMLParser(filename)
def test_cnml_argument(self): cnml = libcnml.CNMLParser(cnml1) CnmlParser(cnml)
def test_invalid(self): filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data/54284_invalid.cnml') parser = libcnml.CNMLParser(filename) self.assertFalse(parser.loaded)