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

Commit

Permalink
Merge branch 'release/v2.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Aug 14, 2019
2 parents 99a1165 + 72c4808 commit 98e50bc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 29 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())
4 changes: 2 additions & 2 deletions src/models/identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class Identifier():
def __init__(self, uri_scheme, uri_value, canonical, score, work={}):
self.URI_parts = {'scheme': uri_scheme, 'value': uri_value}
def __init__(self, uri, canonical, score, work={}):
self.URI_parts = uri
self.canonical = canonical
self.score = score
self.URI = self.full_uri()
Expand Down
5 changes: 3 additions & 2 deletions src/models/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ def results_to_identifiers(results):

def result_to_identifier(result):
from .identifier import Identifier
uri = dict(scheme=result.get('uri_scheme'), value=result.get('uri_value'))
work = dict(work_id=result.get('work_id'),
work_type=result.get('work_type'))
return Identifier(result.get('uri_scheme'), result.get('uri_value'),
result.get('canonical'), result.get('score', 0), work)
return Identifier(uri, result.get('canonical'), result.get('score', 0),
work)


def result_to_work(result):
Expand Down
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 98e50bc

Please sign in to comment.