cleanup imports
This commit is contained in:
parent
1e0f93bbf2
commit
12440acd96
22 changed files with 119 additions and 122 deletions
|
@ -25,7 +25,6 @@ Now checkout the source and prepare for use:
|
|||
git clone https://git.0x2620.org/openmedialibrary_platform.git platform
|
||||
ln -s openmedialibrary/ctl ctl
|
||||
./ctl update_static
|
||||
./ctl setup
|
||||
|
||||
# and start it
|
||||
./ctl debug
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import logging
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from utils import valid, datetime2ts, ts2datetime
|
||||
|
||||
import settings
|
||||
import db
|
||||
import sqlalchemy as sa
|
||||
import state
|
||||
from websocket import trigger_event
|
||||
import db
|
||||
import settings
|
||||
import state
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.changelog')
|
||||
|
||||
class Changelog(db.Model):
|
||||
|
|
|
@ -2,26 +2,20 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import os
|
||||
import json
|
||||
import hashlib
|
||||
|
||||
from oxtornado import actions
|
||||
|
||||
from sqlalchemy.orm import load_only
|
||||
|
||||
import query
|
||||
|
||||
from oxtornado import actions
|
||||
from utils import cleanup_id
|
||||
from websocket import trigger_event
|
||||
import metaremote as meta
|
||||
import models
|
||||
import query
|
||||
import settings
|
||||
import state
|
||||
from websocket import trigger_event
|
||||
|
||||
#import meta
|
||||
import metaremote as meta
|
||||
|
||||
import utils
|
||||
from utils import cleanup_id
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.item.api')
|
||||
|
@ -175,6 +169,7 @@ def findMetadata(data):
|
|||
return response
|
||||
actions.register(findMetadata)
|
||||
|
||||
|
||||
def getMetadata(data):
|
||||
'''
|
||||
takes {
|
||||
|
@ -198,6 +193,7 @@ def getMetadata(data):
|
|||
return response
|
||||
actions.register(getMetadata)
|
||||
|
||||
|
||||
def resetMetadata(data):
|
||||
item = models.Item.get(data['id'])
|
||||
if item and 'primaryid' in item.meta:
|
||||
|
@ -207,6 +203,7 @@ def resetMetadata(data):
|
|||
return {}
|
||||
actions.register(resetMetadata)
|
||||
|
||||
|
||||
def download(data):
|
||||
'''
|
||||
takes {
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division, with_statement
|
||||
|
||||
from datetime import datetime
|
||||
import mimetypes
|
||||
import os
|
||||
import zipfile
|
||||
import mimetypes
|
||||
from datetime import datetime
|
||||
|
||||
import tornado.web
|
||||
from models import Item
|
||||
import settings
|
||||
import db
|
||||
import settings
|
||||
import tornado.web
|
||||
|
||||
|
||||
class OMLHandler(tornado.web.RequestHandler):
|
||||
|
||||
|
|
|
@ -2,26 +2,24 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division, with_statement
|
||||
|
||||
import sqlite3
|
||||
from StringIO import StringIO
|
||||
import Image
|
||||
import sqlite3
|
||||
|
||||
import tornado.concurrent
|
||||
import tornado.gen
|
||||
import tornado.ioloop
|
||||
import tornado.web
|
||||
import tornado.gen
|
||||
import tornado.concurrent
|
||||
|
||||
from oxtornado import run_async
|
||||
|
||||
from utils import resize_image
|
||||
|
||||
|
||||
from settings import icons_db_path
|
||||
from utils import resize_image
|
||||
import db
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.item.icons')
|
||||
|
||||
|
||||
class Icons(dict):
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
|
|
@ -2,43 +2,35 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import os
|
||||
import re
|
||||
import base64
|
||||
import json
|
||||
import hashlib
|
||||
from datetime import datetime
|
||||
from StringIO import StringIO
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import logging
|
||||
import unicodedata
|
||||
|
||||
import Image
|
||||
import ox
|
||||
|
||||
import db
|
||||
from db import MutableDict
|
||||
import sqlalchemy as sa
|
||||
|
||||
import settings
|
||||
from settings import config
|
||||
|
||||
from changelog import Changelog
|
||||
from db import MutableDict
|
||||
from icons import icons
|
||||
from person import get_sort_name
|
||||
|
||||
from settings import config
|
||||
from utils import remove_empty_folders
|
||||
from websocket import trigger_event
|
||||
import db
|
||||
import media
|
||||
|
||||
#import meta
|
||||
import metaremote as meta
|
||||
|
||||
import settings
|
||||
import state
|
||||
import utils
|
||||
|
||||
|
||||
from icons import icons
|
||||
from changelog import Changelog
|
||||
from websocket import trigger_event
|
||||
from utils import remove_empty_folders
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.item.model')
|
||||
|
||||
user_items = sa.Table('useritem', db.metadata,
|
||||
|
|
|
@ -5,9 +5,10 @@ from __future__ import division
|
|||
import unicodedata
|
||||
|
||||
import ox
|
||||
import sqlalchemy as sa
|
||||
|
||||
import db
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def get_sort_name(name, sortname=None):
|
||||
name = unicodedata.normalize('NFKD', name).strip()
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import settings
|
||||
import models
|
||||
import utils
|
||||
#does not work in sqlite
|
||||
#from sqlalchemy.sql.expression import nullslast
|
||||
|
||||
from queryparser import Parser
|
||||
|
||||
|
||||
from sqlalchemy.sql.expression import nullslast
|
||||
import models
|
||||
import settings
|
||||
import utils
|
||||
|
||||
def parse(data):
|
||||
query = {}
|
||||
|
|
|
@ -2,24 +2,22 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
from datetime import datetime
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
import ox
|
||||
|
||||
import settings
|
||||
import db
|
||||
from item.models import File
|
||||
from user.models import User, List
|
||||
|
||||
from changelog import Changelog
|
||||
|
||||
import media
|
||||
from websocket import trigger_event
|
||||
import state
|
||||
from item.models import File
|
||||
from user.models import List
|
||||
from utils import remove_empty_folders
|
||||
from websocket import trigger_event
|
||||
import db
|
||||
import media
|
||||
import settings
|
||||
import state
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.item.scan')
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
from ox.cache import read_url
|
||||
import re
|
||||
|
||||
from ox.cache import read_url
|
||||
import lxml.html
|
||||
|
||||
import logging
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import ox
|
||||
from ox.cache import read_url
|
||||
import ox
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from utils import normalize_isbn
|
||||
from marc_countries import COUNTRIES
|
||||
from dewey import get_classification
|
||||
from marc_countries import COUNTRIES
|
||||
from utils import normalize_isbn
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('meta.loc')
|
||||
|
||||
|
||||
def get_ids(key, value):
|
||||
ids = []
|
||||
if key == 'isbn':
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import re
|
||||
|
||||
from ox.cache import read_url
|
||||
from ox import find_re, strip_tags, decode_html
|
||||
import re
|
||||
import stdnum.isbn
|
||||
|
||||
from utils import find_isbns
|
||||
|
@ -8,6 +13,7 @@ from utils import find_isbns
|
|||
import logging
|
||||
logger = logging.getLogger('meta.lookupbyisbn')
|
||||
|
||||
|
||||
base = 'http://www.lookupbyisbn.com'
|
||||
|
||||
def get_ids(key, value):
|
||||
|
|
|
@ -2,19 +2,20 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
from datetime import datetime
|
||||
from urllib import urlencode
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from ox.cache import read_url
|
||||
|
||||
from marc_countries import COUNTRIES
|
||||
from dewey import get_classification
|
||||
from marc_countries import COUNTRIES
|
||||
from utils import normalize_isbn
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('meta.openlibrary')
|
||||
|
||||
|
||||
KEYS = {
|
||||
'authors': 'author',
|
||||
'covers': 'cover',
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import re
|
||||
import stdnum.isbn
|
||||
|
||||
|
||||
def normalize_isbn(value):
|
||||
return ''.join([s for s in value if s.isdigit() or s == 'X'])
|
||||
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
from ox.cache import read_url
|
||||
import lxml.html
|
||||
import re
|
||||
import hashlib
|
||||
from utils import normalize_isbn
|
||||
|
||||
from ox.cache import read_url
|
||||
import lxml.html
|
||||
import stdnum.isbn
|
||||
|
||||
from .utils import normalize_isbn
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('meta.worldcat')
|
||||
|
||||
|
||||
base_url = 'http://www.worldcat.org'
|
||||
|
||||
def get_ids(key, value):
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
from __future__ import division
|
||||
|
||||
import json
|
||||
from ox.cache import read_url
|
||||
from urllib import urlencode
|
||||
|
||||
from ox.cache import read_url
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('metaremote')
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
import os
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
import OpenSSL
|
||||
|
||||
import settings
|
||||
|
||||
|
||||
def get_fingerprint():
|
||||
with open(settings.ssl_cert_path) as fd:
|
||||
data = fd.read()
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import settings
|
||||
from changelog import Changelog
|
||||
from user.models import User
|
||||
|
||||
import state
|
||||
from websocket import trigger_event
|
||||
import settings
|
||||
import state
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.node.nodeapi')
|
||||
|
|
|
@ -2,28 +2,28 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
import os
|
||||
|
||||
import tornado
|
||||
from tornado.web import Application
|
||||
from tornado.httpserver import HTTPServer
|
||||
from tornado.ioloop import PeriodicCallback
|
||||
|
||||
import settings
|
||||
|
||||
import directory
|
||||
from oxtornado import run_async
|
||||
from utils import valid, get_public_ipv6
|
||||
from websocket import trigger_event
|
||||
import cert
|
||||
import db
|
||||
import directory
|
||||
import json
|
||||
import nodeapi
|
||||
import settings
|
||||
import state
|
||||
import user
|
||||
|
||||
import json
|
||||
from utils import valid, get_public_ipv6
|
||||
import nodeapi
|
||||
import cert
|
||||
from websocket import trigger_event
|
||||
from oxtornado import run_async
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.node.server')
|
||||
|
||||
|
||||
class NodeHandler(tornado.web.RequestHandler):
|
||||
|
||||
def initialize(self):
|
||||
|
@ -101,7 +101,6 @@ class ShareHandler(tornado.web.RequestHandler):
|
|||
pass
|
||||
|
||||
def get(self, id):
|
||||
import db
|
||||
import item.models
|
||||
with db.session():
|
||||
i = item.models.Item.get(id)
|
||||
|
|
|
@ -5,24 +5,24 @@ from __future__ import division, print_function
|
|||
import os
|
||||
import sys
|
||||
|
||||
from tornado.web import StaticFileHandler, Application
|
||||
from tornado.httpserver import HTTPServer
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.web import StaticFileHandler, Application
|
||||
|
||||
import settings
|
||||
import websocket
|
||||
import logging
|
||||
|
||||
import db
|
||||
import state
|
||||
import node.server
|
||||
import oxtornado
|
||||
from cache import Cache
|
||||
import tasks
|
||||
|
||||
from item.icons import IconHandler
|
||||
from item.handlers import EpubHandler, ReaderHandler, FileHandler
|
||||
from item.handlers import OMLHandler, serve_static
|
||||
from item.icons import IconHandler
|
||||
import db
|
||||
import node.server
|
||||
import oxtornado
|
||||
import settings
|
||||
import setup
|
||||
import state
|
||||
import tasks
|
||||
import websocket
|
||||
|
||||
import logging
|
||||
|
||||
class MainHandler(OMLHandler):
|
||||
|
||||
|
@ -31,7 +31,6 @@ class MainHandler(OMLHandler):
|
|||
serve_static(self, path, 'text/html')
|
||||
|
||||
def run():
|
||||
import setup
|
||||
setup.create_db()
|
||||
root_dir = os.path.normpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..'))
|
||||
PID = sys.argv[2] if len(sys.argv) > 2 else None
|
||||
|
@ -78,7 +77,6 @@ def run():
|
|||
import user
|
||||
import downloads
|
||||
import nodes
|
||||
import db
|
||||
state.node = node.server.start()
|
||||
state.nodes = nodes.Nodes()
|
||||
state.downloads = downloads.Downloads()
|
||||
|
|
|
@ -2,20 +2,18 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division
|
||||
|
||||
import os
|
||||
from copy import deepcopy
|
||||
import json
|
||||
import os
|
||||
|
||||
from oxtornado import actions
|
||||
import ox
|
||||
|
||||
import models
|
||||
|
||||
from changelog import Changelog
|
||||
from oxtornado import actions
|
||||
from utils import update_dict
|
||||
|
||||
import models
|
||||
import settings
|
||||
import state
|
||||
from changelog import Changelog
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.user.api')
|
||||
|
@ -192,7 +190,6 @@ def removeList(data):
|
|||
actions.register(removeList, cache=False)
|
||||
|
||||
|
||||
|
||||
def addListItems(data):
|
||||
'''
|
||||
takes {
|
||||
|
@ -397,4 +394,3 @@ def getActivity(data):
|
|||
'''
|
||||
return state.activity
|
||||
actions.register(getActivity, cache=False)
|
||||
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
import json
|
||||
|
||||
import db
|
||||
from db import MutableDict
|
||||
import sqlalchemy as sa
|
||||
from queryparser import Parser
|
||||
|
||||
from changelog import Changelog
|
||||
from db import MutableDict
|
||||
from queryparser import Parser
|
||||
import db
|
||||
import settings
|
||||
|
||||
import state
|
||||
|
||||
import logging
|
||||
|
|
Loading…
Reference in a new issue