Skip to content

Commit

Permalink
some code suggestions from pycharm
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Eardley committed Oct 17, 2023
1 parent 08ab561 commit 65e96a5
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions portality/bll/services/journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
from portality.lib import dates
from portality.lib.argvalidate import argvalidate
from portality.lib.dates import FMT_DATETIME_SHORT
from portality.store import StoreFactory, prune_container
from portality.store import StoreFactory, prune_container, StoreException


class JournalService(object):
"""
~~Journal:Service~~
"""

def journal_2_application(self, journal, account=None, keep_editors=False):
@staticmethod
def journal_2_application(journal, account=None, keep_editors=False):
"""
Function to convert a given journal into an application object.
Expand All @@ -35,6 +35,7 @@ def journal_2_application(self, journal, account=None, keep_editors=False):
:param journal: a journal to convert
:param account: an account doing the action - optional, if specified the application will only be created if the account is allowed to
:param keep_editors: maintain the same editor assigned to the resulting application
:return: Suggestion object
"""

Expand Down Expand Up @@ -86,18 +87,20 @@ def journal_2_application(self, journal, account=None, keep_editors=False):
"Completed journal_2_application; return application object")
return application

def journal(self, journal_id, lock_journal=False, lock_account=None, lock_timeout=None):
@staticmethod
def journal(journal_id, lock_journal=False, lock_account=None, lock_timeout=None):
"""
Function to retrieve a journal by its id, and to optionally lock the resource
May raise a Locked exception, if a lock is requested but can't be obtained.
:param journal_id: the id of the journal
:param: lock_journal: should we lock the resource on retrieval
:param: lock_account: which account is doing the locking? Must be present if lock_journal=True
:param: lock_timeout: how long to lock the resource for. May be none, in which case it will default
:return: Tuple of (Journal Object, Lock Object)
:param lock_journal: should we lock the resource on retrieval
:param lock_account: which account is doing the locking? Must be present if lock_journal=True
:param lock_timeout: how long to lock the resource for. May be none, in which case it will default
:return Tuple of (Journal Object, Lock Object)
"""

# first validate the incoming arguments to ensure that we've got the right thing
argvalidate("journal", [
{"arg": journal_id, "allow_none": False, "arg_name": "journal_id"},
Expand Down Expand Up @@ -126,10 +129,6 @@ def csv(self, prune=True, logger=None):
Generate the Journal CSV
~~-> JournalCSV:Feature~~
:param set_cache: whether to update the cache
:param out_dir: the directory to output the file to. If set_cache is True, this argument will be overridden by the cache container
:return: Tuple of (attachment_name, URL)
"""
# first validate the incoming arguments to ensure that we've got the right thing
argvalidate("csv", [
Expand Down Expand Up @@ -206,7 +205,7 @@ def usernames(j):
sub = unmap[o]
else:
sub = "".join(
random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for i in
random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in
range(account_sub_length))
unmap[o] = sub
return [("Owner", sub)]
Expand Down

0 comments on commit 65e96a5

Please sign in to comment.