Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 def setUp(self):
     filename = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             self.cnml_file)
     self.parser = libcnml.CNMLParser(filename)
Ejemplo n.º 3
0
 def test_cnml_argument(self):
     cnml = libcnml.CNMLParser(cnml1)
     CnmlParser(cnml)
Ejemplo n.º 4
0
 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)