Skip to content

Commit

Permalink
Flake8 (#43)
Browse files Browse the repository at this point in the history
* Enabled flake8 in caom2tools
  • Loading branch information
andamian authored Oct 6, 2017
1 parent 98c59f0 commit f02e5c1
Show file tree
Hide file tree
Showing 45 changed files with 1,790 additions and 1,448 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ install:
- pip install coveralls

script:
- for i in $(ls -d */); do cd $i; pytest --cov $i || exit 1; cd ..; done
- for i in $(ls -d */);
do
cd $i;
pytest --cov $i || break -1;
if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then
flake8 -v $i || brake -1;
fi;
cd ..;
done

after_success:
# If coveralls.io is set up for this package, uncomment the line
Expand Down
26 changes: 13 additions & 13 deletions caom2/caom2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@

"""
This library implements the Common Archive Observation Model (CAOM), a general
purpose data model for use as the core data model of an astronomical data centre.
The details about the model and its components can be found at:
purpose data model for use as the core data model of an astronomical data
centre. The details about the model and its components can be found at:
http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2/
"""
from .caom_util import *
from .common import *
from .wcs import *
from .shape import *
from .chunk import *
from .part import *
from .artifact import *
from .plane import *
from .observation import *
from .obs_reader_writer import *
from .checksum import *
from .artifact import * # noqa
from .caom_util import * # noqa
from .checksum import * # noqa
from .chunk import * # noqa
from .common import * # noqa
from .obs_reader_writer import * # noqa
from .observation import * # noqa
from .part import * # noqa
from .plane import * # noqa
from .shape import * # noqa
from .wcs import * # noqa
15 changes: 7 additions & 8 deletions caom2/caom2/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from six.moves.urllib.parse import urlparse
from builtins import str, int

from aenum import Enum
from builtins import str, int
from six.moves.urllib.parse import urlparse

from . import caom_util
from .chunk import ProductType
Expand Down Expand Up @@ -135,7 +134,7 @@ def __init__(self,
self.content_length = content_length
self.content_checksum = content_checksum
if parts is None:
parts = caom_util.TypedOrderedDict(Part,)
parts = caom_util.TypedOrderedDict(Part, )
self.parts = parts

def _key(self):
Expand Down Expand Up @@ -225,16 +224,16 @@ def content_length(self, value):
caom_util.type_check(value, int, "content_length")
caom_util.value_check(value, 0, 1E10, "content_length")
self._content_length = value

@property
def content_checksum(self):
"""the checksum value for the artifact data
type: ChecksumURI
"""
return self._content_checksum

@content_checksum.setter
def content_checksum(self, value):
if value is None:
Expand Down
26 changes: 15 additions & 11 deletions caom2/caom2/caom_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,29 @@

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from builtins import bytes, int
import six

import collections
import struct
import sys
import uuid
from datetime import datetime

__all__ = ['TypedList', 'TypedSet', 'TypedOrderedDict', 'ClassProperty']
import six
from builtins import bytes, int

__all__ = ['TypedList', 'TypedSet', 'TypedOrderedDict', 'ClassProperty']

# TODO both these are very bad, implement more sensibly
IVOA_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"


class int_32(int):
"""
The checksum algorithm must distinguished between 32 bit integers and 64 bit
integers. This subtype of int is used to tell the algorithm to use only 4 bytes
in the checksum of an attribute of this type.
The checksum algorithm must distinguished between 32 bit integers and 64
bit integers. This subtype of int is used to tell the algorithm to use
only 4 bytes in the checksum of an attribute of this type.
"""

def __new__(cls, *args, **kwargs):
return int.__new__(cls, *args, **kwargs)

Expand Down Expand Up @@ -174,7 +176,7 @@ def long2uuid(l):
if l.bit_length() > 63:
raise ValueError("expected 64 bit long {}".format(l))
if l < 0:
l = (1<<64) + l
l = (1 << 64) + l
return uuid.UUID(int=l)


Expand Down Expand Up @@ -206,8 +208,9 @@ def value_check(value, min_value, max_value, variable, override=None):
"""Check if value is inside allowed range, or override"""

sys.tracebacklimit = None
if value != override and not ((min_value is not None) and (min_value <= value) and
(max_value is not None) and (value <= max_value)):
if value != override and not (
(min_value is not None) and (min_value <= value) and
(max_value is not None) and (value <= max_value)):
if override is not False:
raise ValueError(
"Expected {} <= {} <= {} or {}, received {}".format(
Expand Down Expand Up @@ -389,7 +392,8 @@ def __str__(self):

def __repr__(self):
return "TypeOrderedDict((%r))," % self._oktypes + (
"(".join(["(%r,%r)" % (k, v) for k, v in six.iteritems(self)]) + ")")
"(".join(
["(%r,%r)" % (k, v) for k, v in six.iteritems(self)]) + ")")

def check(self, key, value):
"""
Expand Down Expand Up @@ -426,6 +430,6 @@ def __setitem__(self, key, value):

class ClassProperty(property):
""" """

def __get__(self, cls, owner):
return self.fget.__get__(None, owner)()

Loading

0 comments on commit f02e5c1

Please sign in to comment.