Skip to content

Commit

Permalink
Merge pull request #213 from cleder/develop
Browse files Browse the repository at this point in the history
1.0.alpha.4
  • Loading branch information
cleder authored Jan 14, 2023
2 parents 8f10458 + 09f0221 commit 20f5a6e
Show file tree
Hide file tree
Showing 28 changed files with 789 additions and 476 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["develop", "main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["develop"]
schedule:
- cron: '35 10 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
14 changes: 7 additions & 7 deletions .github/workflows/run-all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev']

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -23,7 +23,7 @@ jobs:
pip install -r test-requirements.txt
- name: Test with pytest
run: |
pytest fastkml
pytest tests
cpython-lxml:
runs-on: ubuntu-latest
Expand All @@ -32,7 +32,7 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -44,7 +44,7 @@ jobs:
pip install lxml
- name: Test with pytest
run: |
pytest fastkml --cov=fastkml --cov-fail-under=88 --cov-report=xml
pytest tests --cov=fastkml --cov=tests --cov-fail-under=88 --cov-report=xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
with:
Expand All @@ -57,7 +57,7 @@ jobs:
python-version: ['3.9']

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
matrix:
pypy-version: ['pypy-3.7', 'pypy-3.8', 'pypy-3.9']
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.pypy-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -104,7 +104,7 @@ jobs:
name: Build and publish to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.2.0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
exclude: ^fastkml/tests/base.py
exclude: ^tests/base.py
- id: no-commit-to-branch
- id: pretty-format-json
- id: requirements-txt-fixer
Expand All @@ -34,20 +34,20 @@ repos:
- id: unimport
args: [--remove, --include-star-import, --ignore-init, --gitignore]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.0
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py3-plus", "--py37-plus"]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.4
hooks:
- id: isort
- repo: https://github.com/mgedmin/check-manifest
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ include *.txt
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include tests *.py
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Geometry collection (MultiGeometry). You cannot assign different values of
Currently, the only major feature missing for the full Google Earth experience
is the `gx extension
<https://developers.google.com/kml/documentation/kmlreference#kmlextensions>`_.
Please submit a PR with the features you'd like to see implementd.
Please submit a PR with the features you'd like to see implemented.
4 changes: 2 additions & 2 deletions docs/installing.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

fastkml works with CPython and Pypy version 3.6+ and is
fastkml works with CPython and Pypy version 3.7+ and is
continually tested for these version.
Jython and IronPython are not tested but *should* work.

Expand All @@ -10,7 +10,7 @@ Jython and IronPython are not tested but *should* work.

fastkml works on Unix/Linux, OS X, and Windows.

Install it with ``pip install fastkml`` or ``easy_install fastkml``.
Install it with ``pip install fastkml``.

If you use fastkml extensively or need to process big KML files, consider
installing lxml_ as it speeds up processing.
Expand Down
16 changes: 16 additions & 0 deletions fastkml/data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright (C) 2022 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
"""Add Custom Data"""
from typing import Dict
from typing import List
from typing import Optional
Expand Down
27 changes: 27 additions & 0 deletions fastkml/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2023 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
from enum import Enum
from enum import unique


@unique
class DateTimeResolution(Enum):
"""Enum to represent the different date time resolutions."""

datetime = "dateTime"
date = "date"
year_month = "gYearMonth"
year = "gYear"
2 changes: 2 additions & 0 deletions fastkml/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def __init__(
3 meters above sea level, the placemark will appear
elevated above the terrain by 7 meters. A typical use
of this mode is for aircraft placement.
https://developers.google.com/kml/documentation/kmlreference#geometry
"""
super().__init__(ns, id)
self.extrude = extrude
Expand Down
52 changes: 3 additions & 49 deletions fastkml/kml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2012 Christian Ledermann
# Copyright (C) 2012-2022 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
Expand Down Expand Up @@ -38,6 +38,7 @@
from fastkml.data import ExtendedData
from fastkml.data import Schema
from fastkml.geometry import Geometry
from fastkml.mixins import TimeMixin
from fastkml.styles import Style
from fastkml.styles import StyleMap
from fastkml.styles import StyleUrl
Expand All @@ -51,7 +52,7 @@
logger = logging.getLogger(__name__)


class _Feature(_BaseObject):
class _Feature(TimeMixin, _BaseObject):
"""
abstract element; do not create
subclasses are:
Expand Down Expand Up @@ -200,53 +201,6 @@ def style_url(self, styleurl: Union[str, StyleUrl, None]) -> None:
else:
raise ValueError

@property
def time_stamp(self):
"""This just returns the datetime portion of the timestamp"""
if self._timestamp is not None:
return self._timestamp.timestamp[0]

@time_stamp.setter
def time_stamp(self, dt):
self._timestamp = None if dt is None else TimeStamp(timestamp=dt)
if self._timespan is not None:
logger.warning("Setting a TimeStamp, TimeSpan deleted")
self._timespan = None

@property
def begin(self):
if self._timespan is not None:
return self._timespan.begin[0]

@begin.setter
def begin(self, dt):
if self._timespan is None:
self._timespan = TimeSpan(begin=dt)
elif self._timespan.begin is None:
self._timespan.begin = [dt, None]
else:
self._timespan.begin[0] = dt
if self._timestamp is not None:
logger.warning("Setting a TimeSpan, TimeStamp deleted")
self._timestamp = None

@property
def end(self):
if self._timespan is not None:
return self._timespan.end[0]

@end.setter
def end(self, dt):
if self._timespan is None:
self._timespan = TimeSpan(end=dt)
elif self._timespan.end is None:
self._timespan.end = [dt, None]
else:
self._timespan.end[0] = dt
if self._timestamp is not None:
logger.warning("Setting a TimeSpan, TimeStamp deleted")
self._timestamp = None

@property
def camera(self):
return self._camera
Expand Down
Loading

0 comments on commit 20f5a6e

Please sign in to comment.