Add PEP8 check and fix related issues

- Add PEP8 section to tox.ini
- Add hacking to requirements to enforce OpenStack style requirements
- Fix formatting issues flagged by flake8 check
- Add copyright notices to all remaining files
- Update .gitignore file

Change-Id: I8133009ef5db8e98bb4aa00dbdd36d837eabe84f
This commit is contained in:
Levi Blackstone 2015-05-04 15:16:35 -05:00
parent 2230eb0f15
commit c5b313c297
5 changed files with 40 additions and 8 deletions

5
.gitignore vendored
View File

@ -52,3 +52,8 @@ coverage.xml
# Sphinx documentation
docs/_build/
# IDE Project Files
*.project
*.pydev*
*.idea

View File

@ -27,13 +27,13 @@ def now():
def dt_to_decimal(utc):
decimal.getcontext().prec = 30
return decimal.Decimal(str(calendar.timegm(utc.utctimetuple()))) + \
(decimal.Decimal(str(utc.microsecond)) /
decimal.Decimal("1000000.0"))
return (decimal.Decimal(str(calendar.timegm(utc.utctimetuple()))) +
(decimal.Decimal(str(utc.microsecond)) / decimal.Decimal(
"1000000.0")))
def dt_from_decimal(dec):
if dec == None:
if dec is None:
return "n/a"
integer = int(dec)
micro = (dec - decimal.Decimal(integer)) * decimal.Decimal(1000000)

View File

@ -1 +1,2 @@
hacking>=0.10.0,<0.11
dateutils

View File

@ -1,3 +1,19 @@
# Copyright (c) 2014 Dark Secret Software Inc.
# Copyright (c) 2015 Rackspace
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import datetime
import decimal
import unittest
@ -35,7 +51,8 @@ class TestDatetimeToDecimal(unittest.TestCase):
def test_decimal_to_datetime(self):
expected_decimal = decimal.Decimal('1356093296.123')
expected_datetime = datetime.datetime.utcfromtimestamp(expected_decimal)
expected_datetime = datetime.datetime.utcfromtimestamp(
expected_decimal)
actual_datetime = notification_utils.dt_from_decimal(expected_decimal)
self.assertEqual(actual_datetime, expected_datetime)

11
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py26, py27
envlist = py26, py27, pep8
[testenv]
deps =
@ -12,3 +12,12 @@ commands =
nosetests tests
sitepackages = False
[testenv:pep8]
commands =
flake8
[flake8]
ignore =
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,*db/__init__.py,*db/migrations/versions/*_.py
show-source = True