Skip to content

Commit

Permalink
Merge pull request #68 from csparpa/develop
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
csparpa committed Feb 11, 2015
2 parents 44b0a07 + bc31c5a commit 9d83e2f
Show file tree
Hide file tree
Showing 78 changed files with 2,169 additions and 340 deletions.
12 changes: 8 additions & 4 deletions .coveragerc
Expand Up @@ -8,9 +8,8 @@ exclude_lines =
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
def __str__
if self\.debug
def __repr__(self):
def __str__(self):

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
Expand All @@ -19,6 +18,11 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if 0:
if False:
if __name__ == .__main__.:
if __name__ == __main__:

# Exclude dump methods
def to_JSON(self):
def to_XML
def _to_DOM(self):

ignore_errors = True
8 changes: 7 additions & 1 deletion CONTRIBUTORS.md
@@ -1,4 +1,10 @@
Thanks to the contributors
==========================

* [Samuel Yap] (https://github.com/samuelyap) (code testing)
Code
----
* [Noid] (https://github.com/n0id)

Testing
-------
* [Samuel Yap] (https://github.com/samuelyap)
35 changes: 13 additions & 22 deletions README.md
Expand Up @@ -4,6 +4,8 @@ A Python wrapper around the OpenWeatherMap API

[![Build Status](https://travis-ci.org/csparpa/pyowm.png?branch=master)](https://travis-ci.org/csparpa/pyowm)
[![Coverage Status](https://coveralls.io/repos/csparpa/pyowm/badge.png?branch=develop)](https://coveralls.io/r/csparpa/pyowm?branch=develop)
[![Latest Version](https://pypip.in/version/pyowm/badge.svg)](https://pypi.python.org/pypi/pyowm/)
[![Downloads](https://pypip.in/download/pyowm/badge.svg?period=week)](https://pypi.python.org/pypi/pyowm/)

What is it?
------------
Expand All @@ -19,12 +21,8 @@ PyOWM currently supports _version 2.5_ of the OWM API (which is the latest one)

PyOWM runs on Python 2.7, 3.2 and 3.3

License
-------
[MIT](https://github.com/csparpa/pyowm/blob/master/LICENSE) license

Use it
------
Usage examples
--------------
```python
import pyowm

Expand All @@ -51,8 +49,8 @@ w.get_temperature('celsius') # {'temp_max': 10.5, 'temp': 9.7, 'temp_min': 9.0}
observation_list = owm.weather_around_coords(-22.57, -43.12)
```

Install it
----------
Installation
------------
**With [pip](https://pypi.python.org/pypi/pip)**

`pip install pyowm`
Expand All @@ -76,6 +74,10 @@ Install it

The installer is available on the [Python Package Index](https://pypi.python.org/pypi/pyowm)

License
-------
[MIT](https://github.com/csparpa/pyowm/blob/master/LICENSE) license

What's new
----------
Please read the [changelog](https://github.com/csparpa/pyowm/wiki/Changelog) page of the wiki
Expand All @@ -96,21 +98,10 @@ with [Coveralls.io](https://coveralls.io/r/csparpa/pyowm)

Development
-----------
Contributors (code enhancement, issue/bug reporting) are __welcome!__

*Branching model*

The project adopts [@nvie's branching model](http://nvie.com/posts/a-successful-git-branching-model/)

The "develop" branch contains work-in-progress code: the unit of branching is a feature/enhancement.
From the "develop" branch, new "feature" branches which will be opened.

The "master" branch will contain only stable code and the "develop" branch will be merged back into it only when a milestone is completed.

Bug fixes will be done as "hotfixes" stemming out of the "master" branch and then will be merged back in both "master" and "develop" branch.

"feature" and "hotfix" branches can be opened by any contributor: once terminated, please send a pull request and I'll merge. Merging of "develop" into "master" will be done by myself when releasing.
Contributors (code enhancement, issue/bug reporting) are __welcome!__. See the
[notes on development](https://github.com/csparpa/pyowm/wiki/Notes-on-development) to get started.

If you liked PyOWM, [consider giving me a tip](https://gratipay.com/csparpa)!

References
----------
Expand Down
2 changes: 2 additions & 0 deletions docs/build.md
Expand Up @@ -6,6 +6,8 @@ PyOWM release checklist
* update README.md
* update github wiki pages (including changelog)
* run tests locally using setup.py
* merge develop branch into master branch (no feature/hotfix branches left open)
* close milestone on github
* tag release on github
* upload release on pypi

Expand Down
4 changes: 1 addition & 3 deletions pyowm/abstractions/jsonparser.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing an abstract base class for JSON OWM web API responses parsing
"""
Expand Down Expand Up @@ -28,4 +26,4 @@ def parse_JSON(self, JSON_string):
data needed to build the resulting object
"""
pass
raise NotImplementedError
14 changes: 6 additions & 8 deletions pyowm/abstractions/linkedlist.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing abstractions for defining a linked list data structure
"""
Expand All @@ -24,7 +22,7 @@ def size(self):
:returns: an int
"""
pass
raise NotImplementedError

@abstractmethod
def add(self, data):
Expand All @@ -38,7 +36,7 @@ def add(self, data):
:type data: object
"""
pass
raise NotImplementedError

@abstractmethod
def remove(self, data):
Expand All @@ -52,7 +50,7 @@ def remove(self, data):
:type data: object
"""
pass
raise NotImplementedError

@abstractmethod
def contains(self, data):
Expand All @@ -64,7 +62,7 @@ def contains(self, data):
:returns: a boolean
"""
pass
raise NotImplementedError

@abstractmethod
def index_of(self, data):
Expand All @@ -77,7 +75,7 @@ def index_of(self, data):
:returns: the int index or -1 if the node is not in the list
"""
pass
raise NotImplementedError

@abstractmethod
def pop(self):
Expand All @@ -86,4 +84,4 @@ def pop(self):
:returns: the object data that was stored in the last node
"""
pass
raise NotImplementedError
11 changes: 5 additions & 6 deletions pyowm/abstractions/owm.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing the abstract PyOWM library main entry point interface
"""
Expand All @@ -24,7 +22,7 @@ def get_API_key(self):
:returns: the OWM API key string
"""
pass
raise NotImplementedError

@abstractmethod
def set_API_key(self, API_key):
Expand All @@ -35,7 +33,7 @@ def set_API_key(self, API_key):
:type API_key: str
"""
pass
raise NotImplementedError

@abstractmethod
def get_API_version(self):
Expand All @@ -45,7 +43,7 @@ def get_API_version(self):
:returns: the OWM web API version string
"""
pass
raise NotImplementedError

@abstractmethod
def get_version(self):
Expand All @@ -55,7 +53,7 @@ def get_version(self):
:returns: the current PyOWM library version string
"""
pass
raise NotImplementedError

@abstractmethod
def is_API_online(self):
Expand All @@ -66,3 +64,4 @@ def is_API_online(self):
:returns: bool
"""
raise NotImplementedError
6 changes: 2 additions & 4 deletions pyowm/abstractions/owmcache.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing the abstract PyOWM cache provider
"""
Expand Down Expand Up @@ -40,7 +38,7 @@ def get(self, request_url):
:returns: a JSON str in case of cache hit or ``None`` otherwise
"""
pass
raise NotImplementedError

@abstractmethod
def set(self, request_url, response_json):
Expand All @@ -54,4 +52,4 @@ def set(self, request_url, response_json):
:type response_json: str
"""
pass
raise NotImplementedError
2 changes: 0 additions & 2 deletions pyowm/caches/lrucache.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing LRU cache related class
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/caches/nullcache.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing a null-object cache for OWM web API responses
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/commons/frontlinkedlist.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing class related to the implementation of linked-list data
structure
Expand Down
2 changes: 0 additions & 2 deletions pyowm/commons/owmhttpclient.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing classes for HTTP client/server interactions
"""
Expand Down
4 changes: 1 addition & 3 deletions pyowm/constants.py
@@ -1,8 +1,6 @@
#!/usr/bin/env python

"""
Constants for the PyOWM library
"""

PYOWM_VERSION = '2.0.0'
PYOWM_VERSION = '2.2.0'
LATEST_OWM_API_VERSION = '2.5'
2 changes: 0 additions & 2 deletions pyowm/exceptions/api_call_error.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing APICallError class
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/exceptions/api_response_error.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing APIResponseError class
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/exceptions/not_found_error.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing NotFoundError class
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/exceptions/parse_response_error.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing ParseResponseError class
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/utils/temputils.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing utility functions for temperature units conversion
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/utils/timeformatutils.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing utility functions for time formats conversion
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/utils/timeutils.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing utility functions for time values generation/management
"""
Expand Down
2 changes: 0 additions & 2 deletions pyowm/utils/xmlutils.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
Module containing utility functions for generating XML strings
"""
Expand Down
22 changes: 12 additions & 10 deletions pyowm/webapi25/cityidregistry.py
@@ -1,6 +1,3 @@
#!/usr/bin/env python

from codecs import open
from pyowm.webapi25.location import Location
from pkg_resources import resource_stream

Expand Down Expand Up @@ -33,7 +30,7 @@ def id_for(self, city_name):
"""
line = self._lookup_line_by_city_name(city_name)
return long(line.split(",")[1]) if line is not None else None
return int(line.split(",")[1]) if line is not None else None

def location_for(self, city_name):
"""
Expand All @@ -49,7 +46,7 @@ def location_for(self, city_name):
return None
tokens = line.split(",")
return Location(tokens[0], float(tokens[3]), float(tokens[2]),
long(tokens[1]), 'NL')
int(tokens[1]), 'NL')

def _assess_subfile_from(self, city_name):
c = ord(city_name.lower()[0])
Expand All @@ -59,21 +56,26 @@ def _assess_subfile_from(self, city_name):
return self._filepath_regex % (97, 102)
elif c in range(103, 109): # from g to l
return self._filepath_regex % (103, 108)
return filename
elif c in range(109, 115): # from m to r
return self._filepath_regex % (109, 114)
return filename
elif c in range (115, 123): # from s to z
return self._filepath_regex % (115, 122)
else:
raise ValueError('Error: city name must start with a letter')

def _lookup_line_by_city_name(self, city_name):
filename = self._assess_subfile_from(city_name)
lines = self._get_lines(filename)
return self._match_line(city_name, lines)

def _get_lines(self, filename):
with resource_stream(__name__, filename) as f:
for line in f:
if line.startswith(city_name.lower()):
return line.strip()
return f.readlines()

def _match_line(self, city_name, lines):
for line in lines:
if line.startswith(city_name.lower()):
return line.strip()
return None

def __repr__(self):
Expand Down

0 comments on commit 9d83e2f

Please sign in to comment.