Commit 4d87a601 authored by heltonbiker's avatar heltonbiker

Changed "NS" to "KMLNS" for legibility

parent c682997d
...@@ -36,7 +36,7 @@ import logging ...@@ -36,7 +36,7 @@ import logging
logger = logging.getLogger('fastkml.atom') logger = logging.getLogger('fastkml.atom')
from .config import etree from .config import etree
from .config import ATOMNS as NS from .config import ATOMNS
from .config import LXML from .config import LXML
import re import re
...@@ -88,7 +88,7 @@ class Link(object): ...@@ -88,7 +88,7 @@ class Link(object):
hreflang=None, title=None, length=None hreflang=None, title=None, length=None
): ):
if ns is None: if ns is None:
self.ns = NS self.ns = ATOMNS
else: else:
self.ns = ns self.ns = ns
self.href = href self.href = href
...@@ -172,7 +172,7 @@ class _Person(object): ...@@ -172,7 +172,7 @@ class _Person(object):
def __init__(self, ns=None, name=None, uri=None, email=None): def __init__(self, ns=None, name=None, uri=None, email=None):
if ns is None: if ns is None:
self.ns = NS self.ns = ATOMNS
else: else:
self.ns = ns self.ns = ns
self.name = name self.name = name
......
...@@ -29,7 +29,7 @@ class _XMLObject(object): ...@@ -29,7 +29,7 @@ class _XMLObject(object):
def __init__(self, ns=None): def __init__(self, ns=None):
if ns is None: if ns is None:
self.ns = config.NS self.ns = config.KMLNS
else: else:
self.ns = ns self.ns = ns
...@@ -78,7 +78,7 @@ class _BaseObject(_XMLObject): ...@@ -78,7 +78,7 @@ class _BaseObject(_XMLObject):
super(_BaseObject, self).__init__(ns) super(_BaseObject, self).__init__(ns)
self.id = id self.id = id
if ns is None: if ns is None:
self.ns = config.NS self.ns = config.KMLNS
else: else:
self.ns = ns self.ns = ns
......
...@@ -29,12 +29,12 @@ except ImportError: ...@@ -29,12 +29,12 @@ except ImportError:
LXML = False LXML = False
NS = '{http://www.opengis.net/kml/2.2}' KMLNS = '{http://www.opengis.net/kml/2.2}'
ATOMNS = '{http://www.w3.org/2005/Atom}' ATOMNS = '{http://www.w3.org/2005/Atom}'
GXNS = '{http://www.google.com/kml/ext/2.2}' GXNS = '{http://www.google.com/kml/ext/2.2}'
if hasattr(etree, 'register_namespace'): if hasattr(etree, 'register_namespace'):
etree.register_namespace('kml', NS[1:-1]) etree.register_namespace('kml', KMLNS[1:-1])
etree.register_namespace('atom', ATOMNS[1:-1]) etree.register_namespace('atom', ATOMNS[1:-1])
etree.register_namespace('gx', GXNS[1:-1]) etree.register_namespace('gx', GXNS[1:-1])
......
...@@ -79,7 +79,7 @@ class KML(object): ...@@ -79,7 +79,7 @@ class KML(object):
self._features = [] self._features = []
if ns is None: if ns is None:
self.ns = config.NS self.ns = config.KMLNS
else: else:
self.ns = ns self.ns = ns
......
...@@ -45,7 +45,7 @@ class BaseClassesTestCase(unittest.TestCase): ...@@ -45,7 +45,7 @@ class BaseClassesTestCase(unittest.TestCase):
def test_base_object(self): def test_base_object(self):
bo = base._BaseObject(id='id0') bo = base._BaseObject(id='id0')
self.assertEqual(bo.id, 'id0') self.assertEqual(bo.id, 'id0')
self.assertEqual(bo.ns, config.NS) self.assertEqual(bo.ns, config.KMLNS)
self.assertEqual(bo.targetId, None) self.assertEqual(bo.targetId, None)
self.assertEqual(bo.__name__, None) self.assertEqual(bo.__name__, None)
bo.targetId = 'target' bo.targetId = 'target'
...@@ -55,17 +55,17 @@ class BaseClassesTestCase(unittest.TestCase): ...@@ -55,17 +55,17 @@ class BaseClassesTestCase(unittest.TestCase):
self.assertEqual(bo.id, None) self.assertEqual(bo.id, None)
self.assertEqual(bo.ns, '') self.assertEqual(bo.ns, '')
self.assertRaises(NotImplementedError, bo.etree_element) self.assertRaises(NotImplementedError, bo.etree_element)
element = etree.Element(config.NS + 'Base') element = etree.Element(config.KMLNS + 'Base')
self.assertRaises(TypeError, bo.from_element) self.assertRaises(TypeError, bo.from_element)
self.assertRaises(TypeError, bo.from_element, element) self.assertRaises(TypeError, bo.from_element, element)
bo.__name__ = 'NotABaseObject' bo.__name__ = 'NotABaseObject'
self.assertRaises(TypeError, bo.from_element, element) self.assertRaises(TypeError, bo.from_element, element)
# Note that we can coax baseclasses not to throw errors # Note that we can coax baseclasses not to throw errors
bo.__name__ = 'Base' bo.__name__ = 'Base'
bo.ns = config.NS bo.ns = config.KMLNS
bo.from_element(element) bo.from_element(element)
self.assertEqual(bo.id, None) self.assertEqual(bo.id, None)
self.assertEqual(bo.ns, config.NS) self.assertEqual(bo.ns, config.KMLNS)
self.assertFalse(bo.etree_element(), None) self.assertFalse(bo.etree_element(), None)
self.assertTrue(len(bo.to_string()) > 1) self.assertTrue(len(bo.to_string()) > 1)
...@@ -808,7 +808,7 @@ class KmlFromStringTestCase(unittest.TestCase): ...@@ -808,7 +808,7 @@ class KmlFromStringTestCase(unittest.TestCase):
k.from_string(doc1) k.from_string(doc1)
d = list(k.features())[0] d = list(k.features())[0]
s2 = list(d.schemata())[0] s2 = list(d.schemata())[0]
s.ns = config.NS s.ns = config.KMLNS
self.assertEqual(s.to_string(), s2.to_string()) self.assertEqual(s.to_string(), s2.to_string())
k1 = kml.KML() k1 = kml.KML()
k1.from_string(k.to_string()) k1.from_string(k.to_string())
...@@ -948,7 +948,7 @@ class StyleTestCase(unittest.TestCase): ...@@ -948,7 +948,7 @@ class StyleTestCase(unittest.TestCase):
f.styleUrl = '#somestyle' f.styleUrl = '#somestyle'
self.assertEqual(f.styleUrl, '#somestyle') self.assertEqual(f.styleUrl, '#somestyle')
self.assertTrue(isinstance(f._styleUrl, styles.StyleUrl)) self.assertTrue(isinstance(f._styleUrl, styles.StyleUrl))
s = styles.StyleUrl(config.NS, url='#otherstyle') s = styles.StyleUrl(config.KMLNS, url='#otherstyle')
f.styleUrl = s f.styleUrl = s
self.assertTrue(isinstance(f._styleUrl, styles.StyleUrl)) self.assertTrue(isinstance(f._styleUrl, styles.StyleUrl))
self.assertEqual(f.styleUrl, '#otherstyle') self.assertEqual(f.styleUrl, '#otherstyle')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment