Skip to content

Commit

Permalink
[irods#43] PEP8 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
adetorcy committed Aug 18, 2016
1 parent bb2db71 commit 7363ac0
Show file tree
Hide file tree
Showing 36 changed files with 1,470 additions and 420 deletions.
6 changes: 3 additions & 3 deletions irods/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

# iRODS settings
IRODS_VERSION = {'major':4, 'minor':1, 'patchlevel':6, 'api':'d'}
IRODS_VERSION = {'major': 4, 'minor': 1, 'patchlevel': 6, 'api': 'd'}

# Magic Numbers
MAX_PASSWORD_LENGTH = 50
Expand All @@ -15,7 +15,7 @@
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
h = logging.StreamHandler()
f = logging.Formatter("%(asctime)s %(name)s-%(levelname)s [%(pathname)s %(lineno)d] %(message)s")
f = logging.Formatter(
"%(asctime)s %(name)s-%(levelname)s [%(pathname)s %(lineno)d] %(message)s")
h.setFormatter(f)
logger.addHandler(h)

5 changes: 3 additions & 2 deletions irods/account.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class iRODSAccount(object):
def __init__(self, host, port, user, zone, password, client_user=None,
client_zone=None):

def __init__(self, host, port, user, zone, password, client_user=None,
client_zone=None):

self.host = host
self.port = port
Expand Down
16 changes: 10 additions & 6 deletions irods/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from irods.data_object import iRODSDataObject
from irods.meta import iRODSMetaCollection


class iRODSCollection(object):

def __init__(self, manager, result=None):
self.manager = manager
if result:
Expand All @@ -18,8 +20,8 @@ def __init__(self, manager, result=None):
@property
def metadata(self):
if not self._meta:
self._meta = iRODSMetaCollection(self.manager.sess.metadata,
Collection, self.path)
self._meta = iRODSMetaCollection(self.manager.sess.metadata,
Collection, self.path)
return self._meta

@property
Expand All @@ -34,22 +36,24 @@ def data_objects(self):
query = self.manager.sess.query(DataObject)\
.filter(DataObject.collection_id == self.id)
results = query.get_results()
grouped = itertools.groupby(results, operator.itemgetter(DataObject.id))
grouped = itertools.groupby(
results, operator.itemgetter(DataObject.id))
return [
iRODSDataObject(self.manager.sess.data_objects, self, list(replicas))
iRODSDataObject(
self.manager.sess.data_objects, self, list(replicas))
for _, replicas in grouped
]

def remove(self, recurse=True, force=False, additional_flags={}):
self.manager.remove(self.path, recurse, force, additional_flags)

def move(self, path):
self.manager.move(self.path, path)

def walk(self, topdown=True):
"""
Collection tree generator.
For each subcollection in the directory tree, starting at the
collection, yield a 3-tuple
"""
Expand Down
29 changes: 23 additions & 6 deletions irods/column.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from datetime import datetime
from calendar import timegm


class QueryKey(object):

def __init__(self, type):
self.type = type

Expand All @@ -23,33 +25,42 @@ def __gt__(self, other):
def __ge__(self, other):
return Criterion('>=', self, other)


class Criterion(object):

def __init__(self, op, query_key, value):
self.op = op
self.query_key = query_key
self.value = self.query_key.type.to_irods(value)


class Column(QueryKey):

def __init__(self, type, icat_key, icat_id):
self.icat_key = icat_key
self.icat_id = icat_id
super(Column, self).__init__(type)

def __repr__(self):
return "<%s.%s %d %s>" % (
self.__class__.__module__,
self.__class__.__name__,
self.icat_id,
self.__class__.__module__,
self.__class__.__name__,
self.icat_id,
self.icat_key
)


class Keyword(QueryKey):

def __init__(self, type, icat_key):
self.icat_key = icat_key
super(Keyword, self).__init__(type)

#consider renaming columnType

# consider renaming columnType


class ColumnType(object):

@staticmethod
def to_python(self):
pass
Expand All @@ -58,16 +69,20 @@ def to_python(self):
def to_irods(data):
pass


class Integer(ColumnType):

@staticmethod
def to_python(str):
return int(str)
return int(str)

@staticmethod
def to_irods(data):
return "'%s'" % str(data)


class String(ColumnType):

@staticmethod
def to_python(str):
return str
Expand All @@ -76,7 +91,9 @@ def to_python(str):
def to_irods(data):
return "'%s'" % data


class DateTime(ColumnType):

@staticmethod
def to_python(str):
return datetime.utcfromtimestamp(int(str))
Expand Down
11 changes: 9 additions & 2 deletions irods/data_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


class iRODSReplica(object):

def __init__(self, status, resource_name, path):
self.status = status
self.resource_name = resource_name
Expand All @@ -20,7 +21,9 @@ def __repr__(self):
self.resource_name
)


class iRODSDataObject(object):

def __init__(self, manager, parent=None, results=None):
self.manager = manager
if parent and results:
Expand All @@ -33,7 +36,8 @@ def __init__(self, manager, parent=None, results=None):
# backward compatibility with pre iRODS 4
sys.exc_clear()
self.path = self.collection.path + '/' + self.name
replicas = sorted(results, key=lambda r: r[DataObject.replica_number])
replicas = sorted(
results, key=lambda r: r[DataObject.replica_number])
self.replicas = [iRODSReplica(
r[DataObject.replica_status],
r[DataObject.resource_name],
Expand All @@ -47,7 +51,8 @@ def __repr__(self):
@property
def metadata(self):
if not self._meta:
self._meta = iRODSMetaCollection(self.manager.sess.metadata, DataObject, self.path)
self._meta = iRODSMetaCollection(
self.manager.sess.metadata, DataObject, self.path)
return self._meta

def open(self, mode='r'):
Expand Down Expand Up @@ -75,7 +80,9 @@ def replicate(self, resource):
options[kw.DEST_RESC_NAME_KW] = resource
self.manager.replicate(self.path, options)


class iRODSDataObjectFileRaw(RawIOBase):

def __init__(self, conn, descriptor):
self.conn = conn
self.desc = descriptor
Expand Down

0 comments on commit 7363ac0

Please sign in to comment.