Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
0.5.1 release (#9)
Browse files Browse the repository at this point in the history
Maintenance release:

Add eslint test
Replace scrutinizer by codacy
Improve Makefile and travis config.
Bugfix.
  • Loading branch information
ergoithz authored Nov 28, 2016
1 parent 10c08af commit ab5ec37
Show file tree
Hide file tree
Showing 28 changed files with 235 additions and 148 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ indent_style = tab
indent_style = space
indent_size = 2

[*.{py,js}]
quote_type = single

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.min.js
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"env": {
"browser": true,
"jquery": true
},
"extends": "eslint:recommended",
"installedESLint": true,
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2, {
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ doc/.build/*
env/*
env2/*
env3/*
node_modules/*
__pycache__/*
*.egg/*
*.egg-info/*
*.pyc
**.egg/*
**.egg-info/*
**.pyc
**/node_modules/*
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
language: python

sudo: false
addon:
apt:
nodejs

matrix:
include:
- python: "2.7"
env: PIP_PARAMS="--download-cache $HOME/.cache/pip"
- python: "pypy"
env: PIP_PARAMS=""
# pypy3 commented out until Flask 0.11.2 is out
#- python: "pypy3"
# env: PIP_PARAMS=""
- python: "3.3"
env: PIP_PARAMS="--download-cache $HOME/.cache/pip"
- python: "3.4"
env: PIP_PARAMS="--download-cache $HOME/.cache/pip"
- python: "3.5"
env: PIP_PARAMS=""
env: eslint=yes

install:
- pip install travis-sphinx pep8 coveralls . $PIP_PARAMS
- pip install --upgrade pip
- pip install travis-sphinx flake8 pep8 coveralls .
- |
if [ "$eslint" = "yes" ]; then
nvm install stable
nvm use stable
npm install eslint
fi
script:
- make travis-script
- |
if [ "$eslint" = "yes" ]; then
make eslint
fi
after_success:
- make travis-success
Expand Down
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: doc clean pep8 coverage travis

test: pep8
test: pep8 flake8 eslint
python -c 'import yaml;yaml.load(open(".travis.yml").read())'
ifdef debug
python setup.py test --debug=$(debug)
else
Expand All @@ -21,30 +22,40 @@ build-env:
build/env3/bin/pip install wheel

build: clean build-env
env3/bin/python setup.py bdist_wheel --require-scandir
env3/bin/python setup.py sdist
build/env3/bin/python setup.py bdist_wheel
build/env3/bin/python setup.py sdist

upload: clean build-env
env3/bin/python setup.py bdist_wheel upload --require-scandir
env3/bin/python setup.py sdist upload
build/env3/bin/python setup.py bdist_wheel upload
build/env3/bin/python setup.py sdist upload

doc:
$(MAKE) -C doc html
$(MAKE) -C doc html 2>&1 | grep -v \
'WARNING: more than one target found for cross-reference'

showdoc: doc
xdg-open file://${CURDIR}/doc/.build/html/index.html >> /dev/null

pep8:
find browsepy -type f -name "*.py" -exec pep8 --ignore=E123,E126,E121 {} +

eslint:
eslint \
--ignore-path .gitignore \
--ignore-pattern *.min.js \
${CURDIR}/browsepy

flake8:
flake8 browsepy/

coverage:
coverage run --source=browsepy setup.py test

showcoverage: coverage
coverage html
xdg-open file://${CURDIR}/htmlcov/index.html >> /dev/null

travis-script: pep8 coverage
travis-script: pep8 flake8 coverage
travis-sphinx --nowarn --source=doc build

travis-success:
Expand Down
46 changes: 22 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,23 @@ browsepy

.. image:: http://img.shields.io/travis/ergoithz/browsepy/master.svg?style=flat-square
:target: https://travis-ci.org/ergoithz/browsepy
:alt: Build status
:alt: Travis-CI badge

.. image:: http://img.shields.io/coveralls/ergoithz/browsepy/master.svg?style=flat-square
:target: https://coveralls.io/r/ergoithz/browsepy
:alt: Test coverage
:alt: Coveralls badge

.. image:: https://img.shields.io/scrutinizer/g/ergoithz/browsepy/master.svg?style=flat-square
:target: https://scrutinizer-ci.com/g/ergoithz/browsepy/
:alt: Code quality
.. image:: https://img.shields.io/codacy/grade/e27821fb6289410b8f58338c7e0bc686/master.svg?style=flat-square
:target: https://www.codacy.com/app/ergoithz/browsepy
:alt: Codacy badge

.. image:: http://img.shields.io/pypi/l/browsepy.svg?style=flat-square
:target: https://pypi.python.org/pypi/browsepy/
:alt: License
:alt: License: MIT

.. image:: http://img.shields.io/pypi/v/browsepy.svg?style=flat-square
:target: https://pypi.python.org/pypi/browsepy/
:alt: Latest Version

.. image:: http://img.shields.io/pypi/dm/browsepy.svg?style=flat-square
:target: https://pypi.python.org/pypi/browsepy/
:alt: Downloads
:alt: Version: 0.5.1

.. image:: https://img.shields.io/badge/python-2.7%2B%2C%203.3%2B-FFC100.svg?style=flat-square
:target: https://pypi.python.org/pypi/browsepy/
Expand All @@ -38,7 +34,7 @@ Head to http://ergoithz.github.io/browsepy/ for an online version of current
*master* documentation,

You can also build yourself from sphinx sources using the documentation
Makefile at the docs folder.
`Makefile` located at `docs` directory.

Screenshots
-----------
Expand Down Expand Up @@ -71,10 +67,10 @@ New in 0.5
* A raw HTML widget for maximum flexibility.

* Plugins can register command-line arguments now.
* Player plugin is now able to load m3u and pls playlists, and optionally
* Player plugin is now able to load `m3u` and `pls` playlists, and optionally
play everything on a directory (adding a command-line argument).
* Browsing now takes full advantage of scandir (already in Python 3.5 and an
external dependecy for older versions) providing faster directory listing.
* Browsing now takes full advantage of `scandir` (already in Python 3.5 and an
external dependency for older versions) providing faster directory listing.
* Custom file ordering while browsing directories.
* Easy multi-file uploads.
* Jinja2 template output minification, saving those precious bytes.
Expand Down Expand Up @@ -154,19 +150,22 @@ Using as library
----------------

It's a python module, so you can import **browsepy**, mount **app**, and serve
it (it's wsgi compliant) using your preferred server.
it (it's `WSGI`_ compliant) using
your preferred server.

Browsepy is a Flask application, so it can be served along with any wsgi app
Browsepy is a Flask application, so it can be served along with any `WSGI`_ app
just setting **APPLICATION_ROOT** in **browsepy.app** config to browsepy prefix
url, and mounting **browsepy.app** on the appropriate parent
*url-resolver*/*router*.

Browsepy app config (available at browsepy.app.config) uses the following
configuration options.
.. _WSGI: https://www.python.org/dev/peps/pep-0333/

Browsepy app config (available at :attr:`browsepy.app.config`) uses the
following configuration options.

* **directory_base**: anything under this directory will be served,
defaults to current path.
* **directory_start**: directory will be served when accessing root url
* **directory_start**: directory will be served when accessing root URL
* **directory_remove**: file removing will be available under this path,
defaults to **None**.
* **directory_upload**: file upload will be available under this path,
Expand All @@ -186,7 +185,7 @@ After editing `plugin_modules` value, plugin manager (available at module
plugin_manager and app.extensions['plugin_manager']) should be reloaded using
the `reload` method.

The other way of loading a plugin programatically is calling plugin manager's
The other way of loading a plugin programmatically is calling plugin manager's
`load_plugin` method.

Extend via plugin API
Expand All @@ -195,9 +194,8 @@ Extend via plugin API
Starting from version 0.4.0, browsepy is extensible via plugins. A functional
'player' plugin is provided as example, and some more are planned.

Plugins can add html content to browsepy's browsing view, using some
Plugins can add HTML content to browsepy's browsing view, using some
convenience abstraction for already used elements like external stylesheet and
javascript tags, links, buttons and file upload.

The plugin manager will look for two callables on your module
`register_arguments` and `register_plugin`.
More information at http://ergoithz.github.io/browsepy/plugins.html
1 change: 1 addition & 0 deletions browsepy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ def main(argv=sys.argv[1:], app=app, parser=ArgParse, run_fnc=flask.Flask.run):
threaded=True
)


if __name__ == '__main__':
main()
62 changes: 31 additions & 31 deletions browsepy/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

FS_ENCODING = sys.getfilesystemencoding()
PY_LEGACY = sys.version_info < (3, )
ENV_PATH = [] # populated later
TRUE_VALUES = frozenset(('true', 'yes', '1', 'enable', 'enabled', True, 1))

try:
Expand All @@ -35,32 +34,6 @@ def isexec(path):
return os.path.isfile(path) and os.access(path, os.X_OK)


def which(name,
env_path=ENV_PATH,
is_executable_fnc=isexec,
path_join_fnc=os.path.join):
'''
Get command absolute path.
:param name: name of executable command
:type name: str
:param env_path: OS environment executable paths, defaults to autodetected
:type env_path: list of str
:param is_executable_fnc: callable will be used to detect if path is
executable, defaults to `isexec`
:type is_executable_fnc: Callable
:param path_join_fnc: callable will be used to join path components
:type path_join_fnc: Callable
:return: absolute path
:rtype: str or None
'''
for path in env_path:
exe_file = path_join_fnc(path, name)
if is_executable_fnc(exe_file):
return exe_file
return None


def fsdecode(path, os_name=os.name, fs_encoding=FS_ENCODING, errors=None):
'''
Decode given path.
Expand Down Expand Up @@ -203,20 +176,47 @@ def inner(fnc):
return inner


ENV_PATH[:] = (
ENV_PATH = tuple(
fsdecode(path.strip('"').replace('<SCAPED-PATHSEP>', os.pathsep))
for path in os
.environ['PATH'] # noqa
.replace('\\%s' % os.pathsep, '<SCAPED-PATHSEP>')
.split(os.pathsep)
)


def which(name,
env_path=ENV_PATH,
is_executable_fnc=isexec,
path_join_fnc=os.path.join):
'''
Get command absolute path.
:param name: name of executable command
:type name: str
:param env_path: OS environment executable paths, defaults to autodetected
:type env_path: list of str
:param is_executable_fnc: callable will be used to detect if path is
executable, defaults to `isexec`
:type is_executable_fnc: Callable
:param path_join_fnc: callable will be used to join path components
:type path_join_fnc: Callable
:return: absolute path
:rtype: str or None
'''
for path in env_path:
exe_file = path_join_fnc(path, name)
if is_executable_fnc(exe_file):
return exe_file
return None


if PY_LEGACY:
FileNotFoundError = type('FileNotFoundError', (OSError,), {})
FileNotFoundError = type('FileNotFoundError', (OSError,), {}) # noqa
range = xrange # noqa
filter = itertools.ifilter
basestring = basestring
unicode = unicode
basestring = basestring # noqa
unicode = unicode # noqa
else:
FileNotFoundError = FileNotFoundError
range = range
Expand Down
2 changes: 1 addition & 1 deletion browsepy/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from werkzeug.utils import cached_property

from . import compat
from .compat import range, deprecated
from .compat import range


logger = logging.getLogger(__name__)
Expand Down
4 changes: 4 additions & 0 deletions browsepy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def init_app(self, app):
def reload(self):
'''
Clear plugin manager state and reload plugins.
This method will make use of :meth:`clear` and :meth:`load_plugin`,
so all internal state will be cleared, and all plugins defined in
:data:`self.app.config['plugin_modules']` will be loaded.
'''
self.clear()
for plugin in self.app.config.get('plugin_modules', ()):
Expand Down
Loading

0 comments on commit ab5ec37

Please sign in to comment.