Skip to content

Commit

Permalink
Merge a439916 into cf005f3
Browse files Browse the repository at this point in the history
  • Loading branch information
withoutwaxaryan committed Jul 15, 2020
2 parents cf005f3 + a439916 commit a9e73bd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.rst
Expand Up @@ -34,11 +34,11 @@ Fastkml is continually tested with *Travis CI*:

Is Maintained and documented:

.. image:: https://pypip.in/v/fastkml/badge.png
.. image:: https://img.shields.io/pypi/v/fastkml.svg
:target: https://pypi.python.org/pypi/fastkml
:alt: Latest PyPI version

.. image:: https://pypip.in/status/fastkml/badge.svg
.. image:: https://img.shields.io/pypi/status/fastkml.svg
:target: https://pypi.python.org/pypi/fastkml/
:alt: Development Status

Expand All @@ -56,11 +56,11 @@ Is Maintained and documented:

Supports python 2 and 3:

.. image:: https://pypip.in/py_versions/fastkml/badge.svg
.. image:: https://img.shields.io/pypi/pyversions/fastkml.svg
:target: https://pypi.python.org/pypi/fastkml/
:alt: Supported Python versions

.. image:: https://pypip.in/implementation/fastkml/badge.svg
.. image:: https://img.shields.io/pypi/implementation/fastkml.svg
:target: https://pypi.python.org/pypi/fastkml/
:alt: Supported Python implementations

Expand Down
10 changes: 8 additions & 2 deletions docs/usage_guide.rst
Expand Up @@ -93,7 +93,7 @@ Example how to build a simple KML file from the Python interpreter.
Read a KML File
Read a KML File/String
---------------

You can create a KML object by reading a KML file as a string
Expand All @@ -102,7 +102,13 @@ You can create a KML object by reading a KML file as a string
# Start by importing the kml module
>>> from fastkml import kml
#Read file into string and convert to UTF-8 (Python3 style)
>>> with open(kml_file, 'rt', encoding="utf-8") as myfile:
... doc=myfile.read()
# OR
# Setup the string which contains the KML file we want to read
>>> doc = """<?xml version="1.0" encoding="UTF-8"?>
... <kml xmlns="http://www.opengis.net/kml/2.2">
Expand Down
10 changes: 6 additions & 4 deletions fastkml/geometry.py
Expand Up @@ -132,10 +132,12 @@ def __init__(
def _set_altitude_mode(self, element):
if self.altitude_mode:
# XXX add 'relativeToSeaFloor', 'clampToSeaFloor',
assert(self.altitude_mode in [
'clampToGround',
'relativeToGround', 'absolute'
])
if self.altitude_mode not in ['clampToGround', 'relativeToGround',
'absolute']:
raise AssertionError("Altitude mode not in "
" not in clampToGround,"
"'relativeToGround' or"
"'absolute' mode")
if self.altitude_mode != 'clampToGround':
am_element = etree.SubElement(
element, "%saltitudeMode" % self.ns
Expand Down
18 changes: 12 additions & 6 deletions fastkml/kml.py
Expand Up @@ -408,7 +408,9 @@ def snippet(self):
if isinstance(self._snippet, dict):
text = self._snippet.get('text')
if text:
assert (isinstance(text, basestring))
if not (isinstance(text, basestring)):
raise TypeError("text should be of"
"type basestring")
max_lines = self._snippet.get('maxLines', None)
if max_lines is None:
return {'text': text}
Expand Down Expand Up @@ -490,7 +492,9 @@ def etree_element(self):
if isinstance(self.snippet, basestring):
snippet.text = self.snippet
else:
assert (isinstance(self.snippet['text'], basestring))
if not (isinstance(self.snippet['text'], basestring)):
raise TypeError("text snippet should be of"
"type basestring")
snippet.text = self.snippet['text']
if self.snippet.get('maxLines'):
snippet.set('maxLines', str(self.snippet['maxLines']))
Expand Down Expand Up @@ -641,7 +645,9 @@ def append(self, kmlobj):
"Features must be instances of "
"(Folder, Placemark, Document)"
)
assert(kmlobj != self)
if not (kmlobj != self):
raise AssertionError(" kml object should not be instance of class"
"(self)")


class _Overlay(_Feature):
Expand All @@ -656,7 +662,7 @@ class _Overlay(_Feature):

_color = None
# Color values expressed in hexadecimal notation, including opacity (alpha)
# values. The order of expression is alpOverlayha, blue, green, red
# values. The order of expression is alphaOverlay, blue, green, red
# (AABBGGRR). The range of values for any one color is 0 to 255 (00 to ff).
# For opacity, 00 is fully transparent and ff is fully opaque.

Expand Down Expand Up @@ -830,7 +836,7 @@ def altitudeMode(self):
@altitudeMode.setter
def altitudeMode(self, mode):
if mode in ('clampToGround', 'absolute'):
self._altitudeMode = str(mode)
self._altitudeMode = str(mode)
else:
self._altitudeMode = 'clampToGround'

Expand Down Expand Up @@ -1098,7 +1104,7 @@ def from_element(self, element):

logger.warn('No geometries found')
logger.debug(u'Problem with element: {}'.format(etree.tostring(element)))
#raise ValueError('No geometries found')
# raise ValueError('No geometries found')

def etree_element(self):
element = super(Placemark, self).etree_element()
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -25,6 +25,7 @@ def run_tests(self):
open("README.rst").read() + "\n" +
open(os.path.join("docs", "HISTORY.txt")).read()
),
long_description_content_type="text/x-rst",
classifiers=[
"Topic :: Scientific/Engineering :: GIS",
"Programming Language :: Python",
Expand Down

0 comments on commit a9e73bd

Please sign in to comment.