This is an automated email from the git hooks/post-receive script. johanvdw-guest pushed a commit to branch master in repository geolinks.
commit d9d4abe1d5f29ea8bf72b37f8f6c3497881e7348 Author: Johan Van de Wauw <johan.vandew...@gmail.com> Date: Tue Sep 30 14:19:06 2014 +0200 Imported Upstream version 0.0.1 --- PKG-INFO | 50 ++++++++++++++++++++++++ README.md | 31 +++++++++++++++ geolinks/__init__.py | 29 ++++++++++++++ geolinks/links.py | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 57 +++++++++++++++++++++++++++ 5 files changed, 275 insertions(+) diff --git a/PKG-INFO b/PKG-INFO new file mode 100644 index 0000000..4ef3abc --- /dev/null +++ b/PKG-INFO @@ -0,0 +1,50 @@ +Metadata-Version: 1.1 +Name: geolinks +Version: 0.0.1 +Summary: Utilities to deal with geospatial links +Home-page: https://github.com/geopython/geolinks +Author: Tom Kralidis +Author-email: tomkrali...@gmail.com +License: MIT +Description: [![Build Status](https://travis-ci.org/geopython/geolinks.png)](https://travis-ci.org/geopython/geolinks) + + geolinks + ======== + + Utilities to deal with geospatial links. Working implementation + of the Cat-Interop work at https://github.com/OSGeo/Cat-Interop + + Install + ------- + + ```bash + pip install geolinks + ``` + + Use + --- + + ```python + >>> from geolinks.links import sniff_link + >>> sniff_link('http://host/wms?service=WMS') + 'OGC:WMS' + >>> sniff_link('http://host/wms?service=WPS') + 'OGC:WPS' + >>> sniff_link('http://host/wms?service=CSW') + 'OGC:CSW' + >>> sniff_link('http://host/data/roads.kmz') + 'OGC:KML' + >>> sniff_link('http://host/data/roads.kml') + 'OGC:KML' + ``` + +Keywords: links geo protocol url href +Platform: all +Classifier: Development Status :: 4 - Beta +Classifier: Environment :: Console +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Topic :: Scientific/Engineering :: GIS diff --git a/README.md b/README.md new file mode 100644 index 0000000..ab061d0 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +[![Build Status](https://travis-ci.org/geopython/geolinks.png)](https://travis-ci.org/geopython/geolinks) + +geolinks +======== + +Utilities to deal with geospatial links. Working implementation +of the Cat-Interop work at https://github.com/OSGeo/Cat-Interop + +Install +------- + +```bash +pip install geolinks +``` + +Use +--- + +```python +>>> from geolinks.links import sniff_link +>>> sniff_link('http://host/wms?service=WMS') +'OGC:WMS' +>>> sniff_link('http://host/wms?service=WPS') +'OGC:WPS' +>>> sniff_link('http://host/wms?service=CSW') +'OGC:CSW' +>>> sniff_link('http://host/data/roads.kmz') +'OGC:KML' +>>> sniff_link('http://host/data/roads.kml') +'OGC:KML' +``` diff --git a/geolinks/__init__.py b/geolinks/__init__.py new file mode 100644 index 0000000..81670b7 --- /dev/null +++ b/geolinks/__init__.py @@ -0,0 +1,29 @@ +# ================================================================= +# +# Authors: Tom Kralidis <tomkrali...@gmail.com> +# +# Copyright (c) 2014 Tom Kralidis +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# ================================================================= +__version__ = '0.0.1' diff --git a/geolinks/links.py b/geolinks/links.py new file mode 100644 index 0000000..9fb2d06 --- /dev/null +++ b/geolinks/links.py @@ -0,0 +1,108 @@ +# ================================================================= +# +# Authors: Tom Kralidis <tomkrali...@gmail.com> +# +# Copyright (c) 2014 Tom Kralidis +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# ================================================================= + +import logging + +LOGGER = logging.getLogger(__name__) + + +def inurl(needles, haystack, position='any'): + """convenience function to make string.find return bool""" + + count = 0 + + # lowercase everything to do case-insensitive search + haystack2 = haystack.lower() + + for needle in needles: + needle2 = needle.lower() + if position == 'any': + if haystack2.find(needle2) > -1: + count += 1 + elif position == 'end': + if haystack2.endswith(needle2): + count += 1 + elif position == 'begin': + if haystack2.startswith(needle2): + count += 1 + + # assessment + if count > 0: + return True + return False + + +def sniff_link(url): + """performs basic heuristics to detect what the URL is""" + + protocol = None + link = url.strip() + + # heuristics begin + if inurl(['service=CSW', 'request=GetRecords'], link): + protocol = 'OGC:CSW' + elif inurl(['service=SOS', 'request=GetObservation'], link): + protocol = 'OGC:SOS' + elif inurl(['service=WCS', 'request=GetCoverage'], link): + protocol = 'OGC:WCS' + elif inurl(['service=WFS', 'request=GetFeature'], link): + protocol = 'OGC:WFS' + elif inurl(['service=WMS', 'request=GetMap'], link): + protocol = 'OGC:WMS' + elif inurl(['service=WPS', 'request=Execute'], link): + protocol = 'OGC:WPS' + elif inurl(['arcims'], link): + protocol = 'ESRI:ArcIMS' + elif inurl(['arcgis'], link): + protocol = 'ESRI:ArcGIS' + elif inurl(['mpk'], link, 'end'): + protocol = 'ESRI:MPK' + elif inurl(['opendap'], link): + protocol = 'OPeNDAP:OPeNDAP' + elif inurl(['ncss'], link): + protocol = 'UNIDATA:NCSS' + elif inurl(['cdmremote'], link): + protocol = 'UNIDATA:CDM' + elif inurl(['gml'], link, 'end'): + protocol = 'OGC:GML' + elif inurl(['htm', 'html', 'shtml'], link, 'end'): + protocol = 'WWW:LINK' + # extra tests + elif all([inurl(['census.gov/geo/tiger'], link), + inurl(['zip'], link, 'end')]): + protocol = 'ESRI:SHAPEFILE' + elif inurl(['7z', 'bz2', 'gz', 'rar', 'tar.gz', 'tgz', 'zip'], + link, 'end'): + protocol = 'WWW:DOWNLOAD' + elif inurl(['kml', 'kmz'], link, 'end'): + protocol = 'OGC:KML' + else: + LOGGER.info('No link type detected') + + return protocol diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a20461a --- /dev/null +++ b/setup.py @@ -0,0 +1,57 @@ +# ================================================================= +# +# Authors: Tom Kralidis <tomkrali...@gmail.com> +# +# Copyright (c) 2014 Tom Kralidis +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# ================================================================= + +from distutils.core import setup +from geolinks import __version__ as version + +setup( + name='geolinks', + version=version, + description='Utilities to deal with geospatial links', + long_description=open('README.md').read(), + license='MIT', + platforms='all', + keywords='links geo protocol url href', + author='Tom Kralidis', + author_email='tomkrali...@gmail.com', + maintainer='Tom Kralidis', + maintainer_email='tomkrali...@gmail.com', + url='https://github.com/geopython/geolinks', + packages=['geolinks'], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Topic :: Scientific/Engineering :: GIS', + ] +) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/geolinks.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel