Skip to content

Commit

Permalink
Add flake8 check
Browse files Browse the repository at this point in the history
  • Loading branch information
tankywoo committed Mar 26, 2017
1 parent 83db9a0 commit 3653160
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ tox: clean

test: clean
nosetests -v --no-byte-compile --with-coverage --cover-package=simiki --cover-erase -s
flake8 --version
flake8 simiki/ tests/

covhtml: clean
# coverage run setup.py nosetests
Expand Down
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nose==1.3.3
coverage==3.7.1
tox==2.3.1
mock==1.3.0
flake8>=2.5.4
1 change: 1 addition & 0 deletions simiki/conf_templates/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def get_rsync_configs():
return item
return None


# cannot put this block in deploy_rsync() for env.hosts
rsync_configs = get_rsync_configs()
if rsync_configs:
Expand Down
2 changes: 1 addition & 1 deletion simiki/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io
import logging
import datetime
from copy import deepcopy
from pprint import pprint
import yaml

Expand Down Expand Up @@ -69,6 +68,7 @@ def parse_config(config_file):

return config


if __name__ == "__main__":
# pylint: disable=pointless-string-statement
"""
Expand Down
4 changes: 2 additions & 2 deletions simiki/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _set_markdown_extensions(self):
# Handle pygments
markdown_extensions_config.update(self._set_pygments())
# Handle markdown_ext
# Ref: https://pythonhosted.org/Markdown/extensions/index.html#officially-supported-extensions
# Ref: https://pythonhosted.org/Markdown/extensions/index.html#officially-supported-extensions # noqa
if "markdown_ext" in self.site_config:
markdown_extensions_config.update(self.site_config["markdown_ext"])

Expand Down Expand Up @@ -330,7 +330,7 @@ def _cmp(arg1, arg2):
arg2 = arg2[1]["title"] if "title" in arg2[1] else arg2[0]
# cmp not exists in py3
# via <https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons> # noqa
cmp = lambda x, y: (x > y) - (x < y)
cmp = lambda x, y: (x > y) - (x < y) # noqa: E731
return cmp(arg1.lower(), arg2.lower())

if is_py2:
Expand Down
2 changes: 2 additions & 0 deletions simiki/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def get_dir_md5(dirname):
md5_hash = md5_hash.hexdigest()
return md5_hash


def import_string(import_name, silent=False):
"""Imports an object based on a string. This is useful if you want to
use import paths as endpoints or something similar. An import path can
Expand Down Expand Up @@ -182,6 +183,7 @@ def import_string(import_name, silent=False):
if not silent:
raise ImportError(e)


if __name__ == "__main__":
print(color_msg("black", "Black"))
print(color_msg("red", "Red"))
Expand Down
3 changes: 2 additions & 1 deletion tests/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def test_to_html(self):
'foo_page_中文.md')
html_generator_config = self.config
html_generator_config["markdown_ext"] = {"wikilinks": None}
html_generator_generator = PageGenerator(html_generator_config, self.wiki_path)
html_generator_generator = PageGenerator(html_generator_config,
self.wiki_path)
html = html_generator_generator.to_html(src_file).strip()
# trip page updated and site generated paragraph
html = re.sub('(?sm)\\n\s*<span class="updated">Updated.*?<\/span>',
Expand Down
1 change: 1 addition & 0 deletions tests/test_initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ def tearDown(self):
if os.path.exists(self.target_path):
shutil.rmtree(self.target_path)


if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ def tearDown(self):
nose.plugins.logcapture.MyMemoryHandler):
self.logger.removeHandler(handler)


if __name__ == "__main__":
unittest.main()
3 changes: 2 additions & 1 deletion tests/test_parse_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def setUp(self):
"author": "Tanky Woo",
"debug": True,
"default_ext": "markdown",
"description": "This is a simiki's config sample, \u6d4b\u8bd5\u6837\u4f8b",
"description": "This is a simiki's config sample,"
" \u6d4b\u8bd5\u6837\u4f8b",
"destination": "destination",
"keywords": "wiki, simiki, python, \u7ef4\u57fa",
"root": "/wiki/",
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ envlist = py26,py27,py33,py34,py35
deps =
-rrequirements.txt
-rdev_requirements.txt
commands = nosetests
commands =
nosetests
flake8 --version
flake8 simiki/ tests/

0 comments on commit 3653160

Please sign in to comment.