Skip to content

Commit

Permalink
Added black, python code formatter (NNTin#26)
Browse files Browse the repository at this point in the history
* WIP style checker

* style check reformat

* added stylechecking to travis

* travis stylecheck adjustment

* make ready for master pr
  • Loading branch information
NNTin authored Jan 26, 2019
1 parent 537058f commit 83e7f4c
Show file tree
Hide file tree
Showing 21 changed files with 618 additions and 342 deletions.
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
dist: xenial
language: python
cache: pip
notifications:
email: false
python:
- "3.6.0"
- "3.6.1"
- "3.6.2"
- "3.6.3"
- "3.6.4"
- "3.6.5"
- "3.6.6"
- "3.6.7"

install:
- pip install -r requirements.txt
env:
- CONSUMER_KEY=X CONSUMER_SECRET=X ACCESS_TOKEN=X-X ACCESS_TOKEN_SECRET=X
global:
- CONSUMER_KEY=X
- CONSUMER_SECRET=X
- ACCESS_TOKEN=X-X
- ACCESS_TOKEN_SECRET=X
jobs:
include:
- python: 3.6.6
name: "Stylecheck"
script: black --check --diff -l 99 -N `git ls-files "*.py"`
script:
- python -m unittest discover -s tests/test_config
- python -m unittest discover -s tests/test_options
Expand Down
35 changes: 23 additions & 12 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

false_strings = ["false", "False", "f", "F", "0", "", "n", "N", "no", "No", "NO", "FALSE"]

CONFIG_JSON = os.path.abspath(os.path.join(os.path.dirname(__file__), 'config.json'))
CONFIG_JSON = os.path.abspath(os.path.join(os.path.dirname(__file__), "config.json"))

if fileIO(CONFIG_JSON, "check"):
config = fileIO(CONFIG_JSON, "load")
Expand All @@ -19,18 +19,29 @@
"consumer_key": os.environ.get("CONSUMER_KEY", None),
"consumer_secret": os.environ.get("CONSUMER_SECRET", None),
"access_token": os.environ.get("ACCESS_TOKEN", None),
"access_token_secret": os.environ.get("ACCESS_TOKEN_SECRET", None)
"access_token_secret": os.environ.get("ACCESS_TOKEN_SECRET", None),
},
"Discord": [{
"IncludeReplyToUser": False if os.environ.get("INCLUDE_REPLY_TO_USER", None) in false_strings else True,
"IncludeRetweet": False if os.environ.get("INCLUDE_RETWEET", None) in false_strings else True,
"IncludeUserReply": False if os.environ.get("INCLUDE_USER_REPLY", None) in false_strings else True,
"webhook_urls": os.environ.get("WEBHOOK_URL", "").replace(" ", "").split(","),
"twitter_ids": os.environ.get("TWITTER_ID", "").replace(" ", "").split(","),
"custom_message": os.environ.get("CUSTOM_MESSAGE", None),
"keyword_sets": [keyword_set.split("+") for keyword_set in os.environ.get("KEYWORDS", "").replace(" ", "").split(",")]
}]
"Discord": [
{
"IncludeReplyToUser": False
if os.environ.get("INCLUDE_REPLY_TO_USER", None) in false_strings
else True,
"IncludeRetweet": False
if os.environ.get("INCLUDE_RETWEET", None) in false_strings
else True,
"IncludeUserReply": False
if os.environ.get("INCLUDE_USER_REPLY", None) in false_strings
else True,
"webhook_urls": os.environ.get("WEBHOOK_URL", "").replace(" ", "").split(","),
"twitter_ids": os.environ.get("TWITTER_ID", "").replace(" ", "").split(","),
"custom_message": os.environ.get("CUSTOM_MESSAGE", None),
"keyword_sets": [
keyword_set.split("+")
for keyword_set in os.environ.get("KEYWORDS", "").replace(" ", "").split(",")
],
}
],
}

if __name__ == '__main__':
if __name__ == "__main__":
print(config)
Loading

0 comments on commit 83e7f4c

Please sign in to comment.