Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fastkml
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
fastkml
Commits
365ed6e5
Commit
365ed6e5
authored
Jul 17, 2014
by
Christian Ledermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13 from IanLee1521/pep8
Pep8
parents
9eac7e71
d8d77db0
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
827 additions
and
642 deletions
+827
-642
.travis.yml
.travis.yml
+2
-1
docs/CONTRIBUTORS.txt
docs/CONTRIBUTORS.txt
+1
-1
docs/HISTORY.txt
docs/HISTORY.txt
+2
-0
fastkml/__init__.py
fastkml/__init__.py
+15
-15
fastkml/atom.py
fastkml/atom.py
+48
-47
fastkml/base.py
fastkml/base.py
+29
-23
fastkml/config.py
fastkml/config.py
+12
-12
fastkml/geometry.py
fastkml/geometry.py
+81
-61
fastkml/gx.py
fastkml/gx.py
+15
-18
fastkml/kml.py
fastkml/kml.py
+127
-92
fastkml/styles.py
fastkml/styles.py
+103
-101
fastkml/test_main.py
fastkml/test_main.py
+356
-241
requirements/test.txt
requirements/test.txt
+1
-0
setup.py
setup.py
+35
-30
No files found.
.travis.yml
View file @
365ed6e5
...
...
@@ -17,7 +17,8 @@ install:
# command to run tests, e.g. python setup.py test
script
:
coverage run --source=fastkml setup.py test
-
pep8 --exclude test_main.py fastkml
-
coverage run --source=fastkml setup.py test
after_success
:
coveralls
...
...
docs/CONTRIBUTORS.txt
View file @
365ed6e5
...
...
@@ -5,4 +5,4 @@ Contributors
- Jeremy Blalock
- Denis Krienbühl
- Egil Möller
- Ian Lee
- Ian Lee
<IanLee1521@gmail.com>
docs/HISTORY.txt
View file @
365ed6e5
...
...
@@ -6,6 +6,8 @@ Changelog
----------------
- test case additions and lxml warning [Ian Lee]
- pep8-ify source code (except test_main.py) [Ian Lee]
- pyflakes-ify source code (except __init__.py) [Ian Lee]
0.6 (2014/05/29)
----------------
...
...
fastkml/__init__.py
View file @
365ed6e5
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Christian Ledermann
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
...
fastkml/atom.py
View file @
365ed6e5
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Christian Ledermann
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
...
@@ -82,10 +82,11 @@ class Link(object):
length
=
None
# the length of the resource, in bytes
def
__init__
(
self
,
ns
=
None
,
href
=
None
,
rel
=
None
,
type
=
None
,
hreflang
=
None
,
title
=
None
,
length
=
None
):
if
ns
==
None
:
def
__init__
(
self
,
ns
=
None
,
href
=
None
,
rel
=
None
,
type
=
None
,
hreflang
=
None
,
title
=
None
,
length
=
None
):
if
ns
is
None
:
self
.
ns
=
NS
else
:
self
.
ns
=
ns
...
...
@@ -99,7 +100,6 @@ class Link(object):
def
from_string
(
self
,
xml_string
):
self
.
from_element
(
etree
.
XML
(
xml_string
))
def
from_element
(
self
,
element
):
if
self
.
ns
+
self
.
__name__
.
lower
()
!=
element
.
tag
:
raise
TypeError
...
...
@@ -120,7 +120,6 @@ class Link(object):
if
element
.
get
(
'length'
):
self
.
length
=
element
.
get
(
'length'
)
def
etree_element
(
self
):
element
=
etree
.
Element
(
self
.
ns
+
self
.
__name__
.
lower
())
if
self
.
href
:
...
...
@@ -142,10 +141,13 @@ class Link(object):
def
to_string
(
self
,
prettyprint
=
True
):
""" Return the ATOM Object as serialized xml """
if
LXML
and
prettyprint
:
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
pretty_print
=
True
).
decode
(
'UTF-8'
)
else
:
return
etree
.
tostring
(
self
.
etree_element
(),
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
).
decode
(
'UTF-8'
)
...
...
@@ -159,16 +161,16 @@ class _Person(object):
ns
=
None
name
=
None
#conveys a human-readable name for the person.
#
conveys a human-readable name for the person.
uri
=
None
#contains a home page for the person.
#
contains a home page for the person.
email
=
None
#contains an email address for the person.
#
contains an email address for the person.
def
__init__
(
self
,
ns
=
None
,
name
=
None
,
uri
=
None
,
email
=
None
):
if
ns
==
None
:
if
ns
is
None
:
self
.
ns
=
NS
else
:
self
.
ns
=
ns
...
...
@@ -176,27 +178,24 @@ class _Person(object):
self
.
uri
=
uri
self
.
email
=
email
def
etree_element
(
self
):
element
=
etree
.
Element
(
self
.
ns
+
self
.
__name__
.
lower
())
if
self
.
name
:
name
=
etree
.
SubElement
(
element
,
"%sname"
%
self
.
ns
)
name
=
etree
.
SubElement
(
element
,
"%sname"
%
self
.
ns
)
name
.
text
=
self
.
name
#else:
#
else:
# logger.critical('No Name for person defined')
# raise TypeError
if
self
.
uri
:
#XXX validate uri
uri
=
etree
.
SubElement
(
element
,
"%suri"
%
self
.
ns
)
#
XXX validate uri
uri
=
etree
.
SubElement
(
element
,
"%suri"
%
self
.
ns
)
uri
.
text
=
self
.
uri
if
self
.
email
:
if
check_email
(
self
.
email
):
email
=
etree
.
SubElement
(
element
,
"%semail"
%
self
.
ns
)
email
=
etree
.
SubElement
(
element
,
"%semail"
%
self
.
ns
)
email
.
text
=
self
.
email
return
element
def
from_string
(
self
,
xml_string
):
self
.
from_element
(
etree
.
XML
(
xml_string
))
...
...
@@ -204,13 +203,13 @@ class _Person(object):
if
self
.
ns
+
self
.
__name__
.
lower
()
!=
element
.
tag
:
raise
TypeError
else
:
name
=
element
.
find
(
'%sname'
%
self
.
ns
)
name
=
element
.
find
(
'%sname'
%
self
.
ns
)
if
name
is
not
None
:
self
.
name
=
name
.
text
uri
=
element
.
find
(
'%suri'
%
self
.
ns
)
uri
=
element
.
find
(
'%suri'
%
self
.
ns
)
if
uri
is
not
None
:
self
.
uri
=
uri
.
text
email
=
element
.
find
(
'%semail'
%
self
.
ns
)
email
=
element
.
find
(
'%semail'
%
self
.
ns
)
if
email
is
not
None
:
if
check_email
(
email
.
text
):
self
.
email
=
email
.
text
...
...
@@ -218,21 +217,23 @@ class _Person(object):
def
to_string
(
self
,
prettyprint
=
True
):
""" Return the ATOM Object as serialized xml """
if
LXML
and
prettyprint
:
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
pretty_print
=
True
).
decode
(
'UTF-8'
)
else
:
return
etree
.
tostring
(
self
.
etree_element
(),
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
).
decode
(
'UTF-8'
)
class
Author
(
_Person
):
""" Names one author of the feed/entry. A feed/entry may have
multiple authors."""
__name__
=
"Author"
class
Contributor
(
_Person
):
""" Names one contributor to the feed/entry. A feed/entry may have
multiple contributor elements."""
__name__
=
"Contributor"
fastkml/base.py
View file @
365ed6e5
...
...
@@ -20,6 +20,7 @@
import
fastkml.config
as
config
from
fastkml.config
import
etree
class
_XMLObject
(
object
):
""" XML Baseclass"""
...
...
@@ -27,7 +28,7 @@ class _XMLObject(object):
ns
=
None
def
__init__
(
self
,
ns
=
None
):
if
ns
==
None
:
if
ns
is
None
:
self
.
ns
=
config
.
NS
else
:
self
.
ns
=
ns
...
...
@@ -36,12 +37,16 @@ class _XMLObject(object):
if
self
.
__name__
:
element
=
etree
.
Element
(
self
.
ns
+
self
.
__name__
)
else
:
raise
NotImplementedError
(
"Call of abstract base class, subclasses implement this!"
)
raise
NotImplementedError
(
"Call of abstract base class, subclasses implement this!"
)
return
element
def
from_element
(
self
,
element
):
if
self
.
ns
+
self
.
__name__
!=
element
.
tag
:
raise
TypeError
(
"Call of abstract base class, subclasses implement this!"
)
raise
TypeError
(
"Call of abstract base class, subclasses implement this!"
)
def
from_string
(
self
,
xml_string
):
self
.
from_element
(
etree
.
XML
(
xml_string
))
...
...
@@ -49,12 +54,16 @@ class _XMLObject(object):
def
to_string
(
self
,
prettyprint
=
True
):
""" Return the KML Object as serialized xml """
if
config
.
LXML
and
prettyprint
:
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
,
pretty_print
=
True
).
decode
(
'UTF-8'
)
else
:
return
etree
.
tostring
(
self
.
etree_element
(),
return
etree
.
tostring
(
self
.
etree_element
(),
encoding
=
'utf-8'
).
decode
(
'UTF-8'
)
class
_BaseObject
(
_XMLObject
):
""" This is an abstract base class and cannot be used directly in a
KML file. It provides the id attribute, which allows unique
...
...
@@ -68,7 +77,7 @@ class _BaseObject(_XMLObject):
def
__init__
(
self
,
ns
=
None
,
id
=
None
):
super
(
_BaseObject
,
self
).
__init__
(
ns
)
self
.
id
=
id
if
ns
==
None
:
if
ns
is
None
:
self
.
ns
=
config
.
NS
else
:
self
.
ns
=
ns
...
...
@@ -81,12 +90,9 @@ class _BaseObject(_XMLObject):
element
.
set
(
'targetId'
,
self
.
targetId
)
return
element
def
from_element
(
self
,
element
):
super
(
_BaseObject
,
self
).
from_element
(
element
)
if
element
.
get
(
'id'
):
self
.
id
=
element
.
get
(
'id'
)
if
element
.
get
(
'targetId'
):
self
.
targetId
=
element
.
get
(
'targetId'
)
fastkml/config.py
View file @
365ed6e5
fastkml/geometry.py
View file @
365ed6e5
This diff is collapsed.
Click to expand it.
fastkml/gx.py
View file @
365ed6e5
...
...
@@ -76,9 +76,6 @@ located at http://developers.google.com/kml/schema/kml22gx.xsd.
import
logging
logger
=
logging
.
getLogger
(
'fastkml.gx'
)
from
.config
import
etree
from
.config
import
GXNS
as
NS
from
.config
import
LXML
# from .config import etree
# from .config import GXNS as NS
# from .config import LXML
fastkml/kml.py
View file @
365ed6e5
This diff is collapsed.
Click to expand it.
fastkml/styles.py
View file @
365ed6e5
This diff is collapsed.
Click to expand it.
fastkml/test_main.py
View file @
365ed6e5
This diff is collapsed.
Click to expand it.
requirements/test.txt
View file @
365ed6e5
-r common.txt
pytest
pep8
coveralls
setup.py
View file @
365ed6e5
from
setuptools
import
setup
,
find_packages
from
setuptools.command.test
import
test
as
TestCommand
import
sys
,
os
import
sys
import
os
class
PyTest
(
TestCommand
):
def
finalize_options
(
self
):
TestCommand
.
finalize_options
(
self
)
self
.
test_args
=
[]
self
.
test_suite
=
True
def
run_tests
(
self
):
#import here, cause outside the eggs aren't loaded
#
import here, cause outside the eggs aren't loaded
import
pytest
errno
=
pytest
.
main
(
self
.
test_args
)
sys
.
exit
(
errno
)
...
...
@@ -16,13 +19,15 @@ class PyTest(TestCommand):
version
=
'0.7'
setup
(
name
=
'fastkml'
,
setup
(
name
=
'fastkml'
,
version
=
version
,
description
=
"Fast KML processing in python"
,
long_description
=
open
(
"README.rst"
).
read
()
+
"
\
n
"
+
long_description
=
(
open
(
"README.rst"
).
read
()
+
"
\
n
"
+
open
(
os
.
path
.
join
(
"docs"
,
"HISTORY.txt"
)).
read
()
+
"
\
n
"
+
open
(
os
.
path
.
join
(
"docs"
,
"TODO.txt"
)).
read
(),
open
(
os
.
path
.
join
(
"docs"
,
"TODO.txt"
)).
read
()
),
classifiers
=
[
"Topic :: Scientific/Engineering :: GIS"
,
"Programming Language :: Python"
,
...
...
@@ -56,4 +61,4 @@ setup(name='fastkml',
entry_points
=
"""
# -*- Entry points: -*-
"""
,
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment