Skip to content

Commit

Permalink
PEP8 Tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Jarvis <jarvism@thisaddressdoesnotexist.co.uk>
  • Loading branch information
jarvisms committed Oct 5, 2018
1 parent 50e78fe commit 7c5faba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/pywws/filedata.py
Expand Up @@ -411,23 +411,28 @@ def _get_cache_path(self, target_date):
return path, lo, hi

def __iter__(self):
'''Return an iterator which yields all items in the data store sequntially. Equivalent: for item in dataset[:]: yield item'''
"""Return an iterator which yields all items in the data store
sequntially. Equivalent to: for item in dataset[:]: yield item"""
for item in self[:]: yield item

def update(self, E):
'''D.update(E) -> None. Update D from list-like iterable E containing dicts. Pre-existing items being overwritten.
dicts are assumed to contain all appropriate keys and values, and therefore: for k in E: D[ k["idx"] ] = k'''
"""D.update(E) -> None. Equivelent to: for k in E: D[ k['idx'] ] = k"
Update D from list-like iterable E containing dicts.
Pre-existing items being overwritten.
Dicts are assumed to contain all appropriate keys and values."""
for k in E:
self[ k['idx'] ] = k

def clear(self):
'''Clears all data from the data store permanently'''
"""Clears all data from the data store permanently"""
for root, dirs, files in os.walk(self._root_dir, topdown=False):
for file in files:
os.unlink(os.path.join(root, file))
os.rmdir(root)
# Get the root dir back and re-initialise to start again
root_dir = os.path.abspath(os.path.join(self._root_dir, os.pardir))
root_dir = os.path.abspath(
os.path.join(self._root_dir, os.pardir))
self.__init__(root_dir)

class RawStore(CoreStore):
Expand Down
6 changes: 4 additions & 2 deletions src/pywws/storage.py
Expand Up @@ -162,9 +162,11 @@ def __init__(self, data_dir, live_logging):
self.output_dir = os.path.join(self.work_dir, 'output')
if not os.path.isdir(self.output_dir):
os.makedirs(self.output_dir)
# Load whichever data store module was specified, defaulting to the original file store
# Load whichever data store module was specified,
# Defaults to the original file store
datastoretype = self.params.get('paths', 'datastoretype', 'filedata')
DataStoreModule = importlib.import_module('.'+datastoretype, package='pywws')
DataStoreModule = importlib.import_module(
'.'+datastoretype, package='pywws')
# open data file stores
self.raw_data = DataStoreModule.RawStore(data_dir)
self.calib_data = DataStoreModule.CalibStore(data_dir)
Expand Down

0 comments on commit 7c5faba

Please sign in to comment.