Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
remove redundant methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Aug 14, 2019
1 parent db95e91 commit 72c4808
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
5 changes: 5 additions & 0 deletions src/aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import web
import uuid
import logging


Expand Down Expand Up @@ -38,3 +39,7 @@ def is_get_request():

def get_input():
return web.input() if is_get_request() else web.data().decode('utf-8')


def generate_uuid():
return str(uuid.uuid4())
23 changes: 0 additions & 23 deletions src/models/work.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import web
import uuid
import psycopg2
from aux import logger_instance, debug_mode, strtolist
from api import db
Expand Down Expand Up @@ -176,28 +175,6 @@ def delete(self):
q = '''DELETE FROM work WHERE work_id = $work_id'''
db.query(q, dict(work_id=self.UUID))

@staticmethod
def generate_uuid():
return str(uuid.uuid4())

@staticmethod
def is_uuid(input_uuid):
try:
uuid.UUID(input_uuid)
return True
except ValueError:
return False

@staticmethod
def uuid_exists(work_id):
try:
options = dict(work_id=work_id)
result = db.select('work', options, what="work_id",
where="work_id = $work_id")
return result.first()["work_id"] == work_id
except BaseException:
return False

@staticmethod
def get_from_work_id(work_id):
params = dict(uuid=work_id)
Expand Down
5 changes: 3 additions & 2 deletions src/worksctrl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import web
from aux import logger_instance, debug_mode, sort_alphabetically, strtolist
from aux import (logger_instance, debug_mode, sort_alphabetically, strtolist,
generate_uuid)
from validation import validate_sorting_or_fail, require_params_or_fail
from api import json, json_response, api_response, check_token, build_parms
from errors import Error, BADPARAMS, NORESULT
Expand Down Expand Up @@ -81,7 +82,7 @@ def POST(self, name):
UriScheme.find_or_fail(scheme)

# instantiate a new work with the input data
uuid = Work.generate_uuid()
uuid = generate_uuid()
work = Work(uuid, wtype, titles, uris)

# check relatives and associate them with the work
Expand Down

0 comments on commit 72c4808

Please sign in to comment.