From 8da5477c689f64d8633f240772d15408f0d95bfa Mon Sep 17 00:00:00 2001 From: mkzero Date: Sat, 14 Oct 2017 22:10:40 +0200 Subject: [PATCH 1/4] Added travis config --- .travis.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..108586d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: python + +python: + - '2.7' + - '3.3' + - '3.4' + - '3.5' + - '3.6' + - pypy + +before_install: + - pip install flake8 + +install: + - pip install -r requirements.txt + +script: + - flake8 . From 4994f7afc26937c1bfed7376b662c9a94ecd3a9c Mon Sep 17 00:00:00 2001 From: mkzero Date: Sat, 14 Oct 2017 22:32:05 +0200 Subject: [PATCH 2/4] Removed overly specific requirements --- requirements.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8bc1c62..81d50f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1 @@ -nose==1.3.7 -numpy==1.13.3 -protobuf==3.4.1 -pycairo==1.15.3 -twitter==1.17.1 -yasm==0.0 -zenmap==7.60 +twitter \ No newline at end of file From 9208a34ea47ec1c5eb3a85e682a741f3a6735d02 Mon Sep 17 00:00:00 2001 From: mkzero Date: Sat, 14 Oct 2017 22:40:47 +0200 Subject: [PATCH 3/4] Simplified wordlist(), PEP8 fixes --- wordlist.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/wordlist.py b/wordlist.py index 6f6c605..6d3d4a7 100644 --- a/wordlist.py +++ b/wordlist.py @@ -9,8 +9,6 @@ class MissingTranslationException(Exception): pass -translations = {} - def wordlist(language="en_US"): """ Returns a list of lists containing words to be used in a status update @@ -23,21 +21,18 @@ def wordlist(language="en_US"): * fill words - good * fill words - bad """ - if language in translations: - return translations[language] - else: - path = './words/{0}/wordlist.json'.format( - language) - if os.path.exists(path): + translations = {} + path = './words/{0}/wordlist.json'.format( + language) - with open(path) as wordfile: - translations[language] = json.load(wordfile) + if os.path.exists(path): - # fixup space name - translations[language][0].append(config.SPACE_NAME) - return translations[language] - else: - raise MissingTranslationException( - "No translation for %s found" % - language) + with open(path) as wordfile: + translations[language] = json.load(wordfile) + # fixup space name + translations[language][0].append(config.SPACE_NAME) + return translations[language] + else: + raise MissingTranslationException( + "No translation for %s found" % language) From c10a40aab9e55b64d25c5139b2a39ddd0418f12c Mon Sep 17 00:00:00 2001 From: mkzero Date: Sat, 14 Oct 2017 22:47:17 +0200 Subject: [PATCH 4/4] Fixed exception handling for Python 2 --- twitterstatus.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/twitterstatus.py b/twitterstatus.py index 1d3af83..8a2ba59 100755 --- a/twitterstatus.py +++ b/twitterstatus.py @@ -12,6 +12,11 @@ except ImportError as e: print("ERROR: Could not import config. Make sure config.py exists.") +try: + FileNotFoundError +except NameError: + FileNotFoundError = IOError + try: from wordlist import wordlist