Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Aug 12, 2018
1 parent f633ba5 commit 608045e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
16 changes: 12 additions & 4 deletions doc/sphinx/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,23 @@ Hack, Hack, Hack

.. note::

Follow the Style Guide, basically `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_.
Follow the Style Guide, basically `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_.

We prefer to use double quotes and allow a max. line length of 99 characters.
Since version 3.x source formatting rules are delegated to the
`Black library <https://black.readthedocs.io/en/stable/>`_.

Failing tests or not follwing PEP 8 will break builds on
`travis <https://travis-ci.org/mar10/wsgidav>`_ and therefore be
automatically rejected.
automatically rejected:

Run ``$ flake8`` and ``$ tox`` frequently and before you commit!
- Run ``$ tox -e black`` to re-format the code, or
`look for plugins for your favorite editor <https://black.readthedocs.io/en/stable/editor_integration.html>`_
that format on-save.

- Run ``$ tox -e check`` frequently and before you commit.

- Don't forget to run ``$ tox`` to run the hole test suite before
you commit.


Test, Test, Test
Expand Down
22 changes: 19 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
basepython = python3.6
#envlist = clean, py27, py34, py35, stats
envlist = black, py27, py34, py35, py36, py37
envlist = check, py27, py34, py35, py36, py37

[testenv]
passenv = LC_ALL LANG TRAVIS TRAVIS_BRANCH TRAVIS_OS_NAME TRAVIS_BUILD_ID
Expand All @@ -27,16 +27,31 @@ deps =
requests
webtest

[testenv:black]

[testenv:check]
description = Check Black formatting compliance and add flake8-bugbear checks
basepython = python3.6
changedir = {toxinidir}
skip_install = true
deps =
black
flake8-bugbear
commands =
black --check wsgidav tests
black --check --diff wsgidav tests
flake8 wsgidav tests


[testenv:black]
description = Reformat python code using Black
basepython = python3.6
changedir = {toxinidir}
skip_install = true
deps =
black
commands =
black wsgidav tests


[testenv:docs]
description = Build Sphinx documentation (output directory: docs/sphinx-build)
basepython = python3.6
Expand All @@ -49,6 +64,7 @@ commands =
# http://www.sphinx-doc.org/en/master/man/sphinx-build.html
sphinx-build -b html sphinx sphinx-build


# [testenv:clean]
# commands =
# coverage erase
Expand Down
17 changes: 4 additions & 13 deletions wsgidav/dav_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,10 @@ def get_property_value(self, name):

elif name.startswith("{DAV:}"):
# Standard live property (raises HTTP_NOT_FOUND if not supported)
if (
name == "{DAV:}creationdate"
and self.get_creation_date() is not None
):
if name == "{DAV:}creationdate" and self.get_creation_date() is not None:
# Note: uses RFC3339 format (ISO 8601)
return util.get_rfc3339_time(self.get_creation_date())
elif (
name == "{DAV:}getcontenttype"
and self.get_content_type() is not None
):
elif name == "{DAV:}getcontenttype" and self.get_content_type() is not None:
return self.get_content_type()
elif name == "{DAV:}resourcetype":
if self.is_collection:
Expand All @@ -698,8 +692,7 @@ def get_property_value(self, name):
return resourcetypeEL
return ""
elif (
name == "{DAV:}getlastmodified"
and self.get_last_modified() is not None
name == "{DAV:}getlastmodified" and self.get_last_modified() is not None
):
# Note: uses RFC1123 format
return util.get_rfc1123_time(self.get_last_modified())
Expand All @@ -711,9 +704,7 @@ def get_property_value(self, name):
return str(self.get_content_length())
elif name == "{DAV:}getetag" and self.get_etag() is not None:
return self.get_etag()
elif (
name == "{DAV:}displayname" and self.get_display_name() is not None
):
elif name == "{DAV:}displayname" and self.get_display_name() is not None:
return self.get_display_name()

# Unsupported, no persistence available, or property not found
Expand Down

0 comments on commit 608045e

Please sign in to comment.