Skip to content

Instantly share code, notes, and snippets.

@lzkelley
Created July 10, 2016 19:48
Show Gist options
  • Save lzkelley/c3979c20eda7fedc011c4b565a894647 to your computer and use it in GitHub Desktop.
Save lzkelley/c3979c20eda7fedc011c4b565a894647 to your computer and use it in GitHub Desktop.
def some_task(catalog, ...):
...
data, changed = catalog.load_url(url, path)
# If the data is not changed, and we are updating... we're done
if not changed and catalog.args.update:
return
# Continue processing, update data blah blah blah
...
return
class Catalog:
...
def load_url(self, url, path, write=True):
# Load cached data...
if self.args.archive:
data = self._load_cached_url(path)
# Load data from url
else:
data = self._load_url_data(url)
# Check if the data is changed
...
changed = ...
# Save url data to cache
if write:
...
return data, changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment