Skip to content

Commit

Permalink
Merge branch 'master' into dockerhub
Browse files Browse the repository at this point in the history
* master: (33 commits)
  Fix wrong-import-order, leave enabled
  Disable wrong-import-order
  Fix wrong-import-order
  Fix unused-import
  Revert "Clean up unused-imports"
  Backtrack wrong-import-position; it gives conflicting advise on the location of imported modules.
  Fix wrong-import-position
  Fix wrong-import-order, trying wrong-import-position
  Clean up unused-imports
  Enable unused-export linting
  lint.sh: revise to also work as pre-commit hook
  lint: pydocstyle for config.py
  lint: add convenience lint.sh script
  lint: update travis.yml
  Cleanup lint
  Add pycodestyle to CI
  Lint cleanup
  lint: pycodestyle misc
  lint: pycodestyle exclude gae-python from jQuery-File-Upload
  Fix mongodb error reporting
  ...
  • Loading branch information
jeremydouglass committed Aug 8, 2018
2 parents 1b6f140 + 41bea94 commit d234677
Show file tree
Hide file tree
Showing 22 changed files with 626 additions and 1,598 deletions.
64 changes: 64 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[MESSAGES CONTROL]

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=duplicate-code,
# # PASSING
# bad-whitespace,
# empty-docstring,
# import-error,
# len-as-condition,
# missing-docstring,
# no-member,
# redefined-builtin,
# redefined-outer-name,
# reimported,
# undefined-variable,
# ungrouped-imports,
# unnecessary-pass,
# unused-variable,
# useless-import-alias,
# # NEXT
# protected-access,
# # IMPORTS
# unused-import,
# wrong-import-order,
# wrong-import-position,
# # EXCEPTS
bare-except,
# # CLEAN LOGIC
inconsistent-return-statements,
no-else-return,
pointless-string-statement,
simplifiable-if-statement,
unused-argument,
# # SPACE
line-too-long,
bad-continuation,
# # STRICT NAMING
invalid-name,
# # IGNORE
consider-using-in,
consider-using-set-comprehension,
no-self-use,
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-function-args,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-nested-blocks,
too-many-statements

18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: python
python:
- "3.6"
cache: pip
install:
- pip install -r requirements.txt
- pip install -r dev_requirements.txt
script:
# At the moment only test files under Blueprint modules.
- pycodestyle
- pylint app/
- pydocstyle --match-dir='(?!(static|[^\.].*))'

# Test for javascript code style - not yet implemented
# - cd ./app/static
# - .\node_modules\.bin\eslint ./js/*.js
# - ./node_modules/.bin/eslint ./js/upload.js
# - cd ../..
20 changes: 13 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""Flask app init.py
"""
"""Flask app init.py."""

# ----------------------------------------------------------------------------#
# Imports
# ----------------------------------------------------------------------------#

# import: standard
import json
import os
import re
import urllib

import markdown

# import: third-party
from flask import Flask, render_template, request

import markdown
# import: app
from .sources import sources
from .corpus import corpus
from .projects import projects
Expand Down Expand Up @@ -50,11 +49,13 @@

@app.route('/todo')
def todo():
"""Load To Do page."""
return render_template('todo.html')


@app.route('/thought-experiments/<name>')
def thought_experiments(name):
"""Load Thought Experiments page."""
filename = os.path.join('app/static/markdown', name + '.md')
with open(filename, 'r') as f:
md = f.read()
Expand All @@ -64,17 +65,19 @@ def thought_experiments(name):

@app.route('/')
def home():
"""Load Home page."""
return render_template('index.html')


@app.route('/guide')
def guide():
"""Load Guide page."""
breadcrumbs = [{'link': '/guide', 'label': 'Guide'}]
return render_template('guide.html', breadcrumbs=breadcrumbs)


def add_links(doc):
""" Helper for /schema """
"""Add links to headers on /schema page."""
pats = ['(<h1>)(.+?)(</h1>)', '(<h2>)(.+?)(</h2>)', '(<h3>)(.+?)(</h3>)', '(<h4>)(.+?)(</h4>)', '(<h5>)(.+?)(</h5>)']
for p in pats:
doc = re.sub(p, r'\g<1><a id="user-content-\g<2>" class="anchor" aria-hidden="true" href="#\g<2>"></a>\g<2>\g<3>', doc)
Expand All @@ -83,6 +86,7 @@ def add_links(doc):

@app.route('/schema')
def schema():
"""Load Schema page."""
breadcrumbs = [{'link': '/schema', 'label': 'Manifest Schema Documentation'}]
f = urllib.request.urlopen('https://github.com/whatevery1says/manifest/raw/master/we1s-manifest-schema-2.0.md')
md = f.read().decode('utf-8')
Expand All @@ -98,11 +102,13 @@ def schema():

@app.errorhandler(500)
def internal_error(error):
"""Load 500 Error page."""
return render_template('errors/500.html'), 500


@app.errorhandler(404)
def not_found_error(error):
"""Load 404 Error page."""
return render_template('errors/404.html'), 404


Expand Down
Loading

0 comments on commit d234677

Please sign in to comment.