Skip to content

Commit

Permalink
More linter/landscape.io cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 5, 2016
1 parent a32590f commit 5022123
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions eulfedora/management/commands/syncrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import glob
import logging
import os
import sys
from optparse import make_option

from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -72,7 +73,9 @@ def handle(self, *args, **options):

# FIXME/TODO: add count/summary info for content models objects created ?
if self.verbosity > 1:
print "Generating content models for %d classes" % len(DigitalObject.defined_types)
sys.stdout.write("Generating content models for %d classes"
% len(DigitalObject.defined_types))

for cls in DigitalObject.defined_types.itervalues():
self.process_class(cls)

Expand All @@ -81,11 +84,11 @@ def handle(self, *args, **options):
def process_class(self, cls):
try:
ContentModel.for_class(cls, self.repo)
except ValueError, v:
except ValueError as v:
# for_class raises a ValueError when a class has >1
# CONTENT_MODELS.
if self.verbosity > 1:
print v
sys.stderr.write(v)
except RequestFailed, rf:
if hasattr(rf, 'detail'):
if 'ObjectExistsException' in rf.detail:
Expand All @@ -99,7 +102,8 @@ def process_class(self, cls):
full_name)
else:
# if there is a detail message, display that
print "Error ingesting ContentModel for %s: %s" % (cls, rf.detail)
sys.stderr.write("Error ingesting ContentModel for %s: %s"
% (cls, rf.detail))

def load_initial_objects(self):
# look for any .xml files in apps under fixtures/initial_objects
Expand Down
20 changes: 10 additions & 10 deletions eulfedora/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def get_next_pid(self, namespace=None, count=None):
else:
return nextpids.pids


def ingest(self, text, log_message=None):
"""
Ingest a new object into Fedora. Returns the pid of the new object on
Expand All @@ -240,11 +239,11 @@ def ingest(self, text, log_message=None):
:param log_message: optional log message
:rtype: string
"""
kwargs = { 'text': text }
kwargs = {'text': text}
if log_message:
kwargs['logMessage'] = log_message
r = self.api.ingest(**kwargs)
return r.content
response = self.api.ingest(**kwargs)
return response.content

def purge_object(self, pid, log_message=None):
"""
Expand All @@ -254,11 +253,11 @@ def purge_object(self, pid, log_message=None):
:param log_message: optional log message
:rtype: boolean
"""
kwargs = { 'pid': pid }
kwargs = {'pid': pid}
if log_message:
kwargs['logMessage'] = log_message
r = self.api.purgeObject(**kwargs)
return r.status_code == requests.codes.ok
response = self.api.purgeObject(**kwargs)
return response.status_code == requests.codes.ok

def get_objects_with_cmodel(self, cmodel_uri, type=None):
"""
Expand All @@ -269,7 +268,7 @@ def get_objects_with_cmodel(self, cmodel_uri, type=None):
:rtype: list of objects
"""
uris = self.risearch.get_subjects(modelns.hasModel, cmodel_uri)
return [ self.get_object(uri, type) for uri in uris ]
return [self.get_object(uri, type) for uri in uris]

def get_object(self, pid=None, type=None, create=None):
"""
Expand All @@ -284,7 +283,7 @@ def get_object(self, pid=None, type=None, create=None):
:create: boolean: create a new object? (if not specified, defaults
to False when pid is specified, and True when it is not)
"""
type = type or self.default_object_type
objtype = type or self.default_object_type

if pid is None:
if create is None:
Expand All @@ -293,7 +292,8 @@ def get_object(self, pid=None, type=None, create=None):
if create is None:
create = False

return type(self.api, pid, create, default_pidspace=self.default_pidspace)
return objtype(self.api, pid, create,
default_pidspace=self.default_pidspace)

def infer_object_subtype(self, api, pid=None, create=False, default_pidspace=None):
"""Construct a DigitalObject or appropriate subclass, inferring the
Expand Down

0 comments on commit 5022123

Please sign in to comment.