diff options
author | Matt Singleton <msingleton@aclu.org> | 2017-10-14 19:59:04 -0400 |
---|---|---|
committer | Matt Singleton <msingleton@aclu.org> | 2017-10-14 20:00:49 -0400 |
commit | 4e8bb9297e5e55bbd4aafacf1b77e63add5cbfe0 (patch) | |
tree | 81943f338beff3d77836982d3f936cc4078bd7ae | |
parent | 4317400d97abb928f584099516d8501c20f9d9b7 (diff) |
code cleanup
-rw-r--r-- | setup.py | 2 | ||||
-rwxr-xr-x | unbiased/main.py | 8 | ||||
-rw-r--r-- | unbiased/sources/__init__.py | 1 | ||||
-rw-r--r-- | unbiased/sources/base.py | 4 |
4 files changed, 10 insertions, 5 deletions
@@ -2,7 +2,7 @@ from setuptools import setup setup( name="unbiased", - version="1", + version="4", packages=['unbiased'], package_data={ 'unbiased': [ diff --git a/unbiased/main.py b/unbiased/main.py index 19fd05b..a0caa5e 100755 --- a/unbiased/main.py +++ b/unbiased/main.py @@ -4,6 +4,7 @@ import argparse import io import logging import logging.config +import os import time from unbiased.util import pickStories, pullImage, buildOutput, write_files, write_static_files @@ -46,6 +47,7 @@ logging_config = { } } + def main(): parser = argparse.ArgumentParser() parser.add_argument('webroot', help='location to write html output') @@ -78,6 +80,7 @@ def main(): if sleeptime > 0: time.sleep(sleeptime) + def run(webroot, source_names, debug_mode=False): logger.debug('Running with webroot="{}" for sources="{}"'.format(webroot, source_names)) @@ -122,7 +125,7 @@ def run(webroot, source_names, debug_mode=False): files_to_write[story.img] = img_jpg img_idx += 1 for story in middle_stories: - story.img, img_jpg = pullImage(story.img, img_idx, webroot, 150, 100) + story.img, img_jpg = pullImage(story.img, img_idx, webroot, 150, 100) files_to_write[story.img] = img_jpg img_idx += 1 @@ -134,5 +137,6 @@ def run(webroot, source_names, debug_mode=False): write_files(files_to_write, webroot) write_static_files(webroot) -if __name__=="__main__": + +if __name__ == "__main__": main() diff --git a/unbiased/sources/__init__.py b/unbiased/sources/__init__.py index e4a473a..fdabdd1 100644 --- a/unbiased/sources/__init__.py +++ b/unbiased/sources/__init__.py @@ -3,6 +3,7 @@ import pkgutil from unbiased.sources.base import NewsSource + def get_sources(): for loader, name, is_pkg in pkgutil.walk_packages(__path__): if name != 'base': diff --git a/unbiased/sources/base.py b/unbiased/sources/base.py index 9f51287..1d54f82 100644 --- a/unbiased/sources/base.py +++ b/unbiased/sources/base.py @@ -1,5 +1,3 @@ -import collections -import html import logging import urllib @@ -8,6 +6,7 @@ import requests logger = logging.getLogger('unbiased') + class Article(object): def __init__(self, source, title, author, description, url, img): @@ -21,6 +20,7 @@ class Article(object): def __repr__(self): return 'Article({}, {}, {}, {}, {}, {})'.format(self.source, self.title, self.author, self.description, self.url, self.img) + class NewsSource(object): """ Abstract base class. |