cleanup imports

This commit is contained in:
j 2014-08-12 10:16:57 +02:00
parent 1e0f93bbf2
commit 12440acd96
22 changed files with 119 additions and 122 deletions

View file

@ -25,7 +25,6 @@ Now checkout the source and prepare for use:
git clone https://git.0x2620.org/openmedialibrary_platform.git platform git clone https://git.0x2620.org/openmedialibrary_platform.git platform
ln -s openmedialibrary/ctl ctl ln -s openmedialibrary/ctl ctl
./ctl update_static ./ctl update_static
./ctl setup
# and start it # and start it
./ctl debug ./ctl debug

View file

@ -2,19 +2,18 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import logging
import json
from datetime import datetime from datetime import datetime
import json
import sqlalchemy as sa
from utils import valid, datetime2ts, ts2datetime from utils import valid, datetime2ts, ts2datetime
import settings
import db
import sqlalchemy as sa
import state
from websocket import trigger_event from websocket import trigger_event
import db
import settings
import state
import logging
logger = logging.getLogger('oml.changelog') logger = logging.getLogger('oml.changelog')
class Changelog(db.Model): class Changelog(db.Model):

View file

@ -2,26 +2,20 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import os
import json import json
import hashlib import hashlib
from oxtornado import actions
from sqlalchemy.orm import load_only 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 models
import query
import settings import settings
import state import state
from websocket import trigger_event
#import meta
import metaremote as meta
import utils import utils
from utils import cleanup_id
import logging import logging
logger = logging.getLogger('oml.item.api') logger = logging.getLogger('oml.item.api')
@ -175,6 +169,7 @@ def findMetadata(data):
return response return response
actions.register(findMetadata) actions.register(findMetadata)
def getMetadata(data): def getMetadata(data):
''' '''
takes { takes {
@ -198,6 +193,7 @@ def getMetadata(data):
return response return response
actions.register(getMetadata) actions.register(getMetadata)
def resetMetadata(data): def resetMetadata(data):
item = models.Item.get(data['id']) item = models.Item.get(data['id'])
if item and 'primaryid' in item.meta: if item and 'primaryid' in item.meta:
@ -207,6 +203,7 @@ def resetMetadata(data):
return {} return {}
actions.register(resetMetadata) actions.register(resetMetadata)
def download(data): def download(data):
''' '''
takes { takes {

View file

@ -2,15 +2,16 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, with_statement from __future__ import division, with_statement
from datetime import datetime
import mimetypes
import os import os
import zipfile import zipfile
import mimetypes
from datetime import datetime
import tornado.web
from models import Item from models import Item
import settings
import db import db
import settings
import tornado.web
class OMLHandler(tornado.web.RequestHandler): class OMLHandler(tornado.web.RequestHandler):

View file

@ -2,26 +2,24 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, with_statement from __future__ import division, with_statement
import sqlite3
from StringIO import StringIO from StringIO import StringIO
import Image import Image
import sqlite3
import tornado.concurrent
import tornado.gen
import tornado.ioloop import tornado.ioloop
import tornado.web import tornado.web
import tornado.gen
import tornado.concurrent
from oxtornado import run_async from oxtornado import run_async
from utils import resize_image
from settings import icons_db_path from settings import icons_db_path
from utils import resize_image
import db import db
import logging import logging
logger = logging.getLogger('oml.item.icons') logger = logging.getLogger('oml.item.icons')
class Icons(dict): class Icons(dict):
def __init__(self, db): def __init__(self, db):
self._db = db self._db = db

View file

@ -2,43 +2,35 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import os
import re
import base64
import json
import hashlib
from datetime import datetime from datetime import datetime
from StringIO import StringIO from StringIO import StringIO
import base64
import hashlib
import json
import os
import re
import shutil import shutil
import logging
import unicodedata import unicodedata
import Image import Image
import ox import ox
import db
from db import MutableDict
import sqlalchemy as sa import sqlalchemy as sa
import settings from changelog import Changelog
from settings import config from db import MutableDict
from icons import icons
from person import get_sort_name 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 media
#import meta
import metaremote as meta import metaremote as meta
import settings
import state import state
import utils import utils
import logging
from icons import icons
from changelog import Changelog
from websocket import trigger_event
from utils import remove_empty_folders
logger = logging.getLogger('oml.item.model') logger = logging.getLogger('oml.item.model')
user_items = sa.Table('useritem', db.metadata, user_items = sa.Table('useritem', db.metadata,

View file

@ -5,9 +5,10 @@ from __future__ import division
import unicodedata import unicodedata
import ox import ox
import sqlalchemy as sa
import db import db
import sqlalchemy as sa
def get_sort_name(name, sortname=None): def get_sort_name(name, sortname=None):
name = unicodedata.normalize('NFKD', name).strip() name = unicodedata.normalize('NFKD', name).strip()

View file

@ -2,13 +2,13 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import settings #does not work in sqlite
import models #from sqlalchemy.sql.expression import nullslast
import utils
from queryparser import Parser from queryparser import Parser
import models
import settings
from sqlalchemy.sql.expression import nullslast import utils
def parse(data): def parse(data):
query = {} query = {}

View file

@ -2,24 +2,22 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
from datetime import datetime
import os import os
import shutil import shutil
from datetime import datetime
import time import time
import ox import ox
import settings
import db
from item.models import File
from user.models import User, List
from changelog import Changelog from changelog import Changelog
from item.models import File
import media from user.models import List
from websocket import trigger_event
import state
from utils import remove_empty_folders from utils import remove_empty_folders
from websocket import trigger_event
import db
import media
import settings
import state
import logging import logging
logger = logging.getLogger('oml.item.scan') logger = logging.getLogger('oml.item.scan')

View file

@ -2,8 +2,9 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
from ox.cache import read_url
import re import re
from ox.cache import read_url
import lxml.html import lxml.html
import logging import logging

View file

@ -2,18 +2,19 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import ox
from ox.cache import read_url from ox.cache import read_url
import ox
import re import re
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from utils import normalize_isbn
from marc_countries import COUNTRIES
from dewey import get_classification from dewey import get_classification
from marc_countries import COUNTRIES
from utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.loc') logger = logging.getLogger('meta.loc')
def get_ids(key, value): def get_ids(key, value):
ids = [] ids = []
if key == 'isbn': if key == 'isbn':

View file

@ -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.cache import read_url
from ox import find_re, strip_tags, decode_html from ox import find_re, strip_tags, decode_html
import re
import stdnum.isbn import stdnum.isbn
from utils import find_isbns from utils import find_isbns
@ -8,6 +13,7 @@ from utils import find_isbns
import logging import logging
logger = logging.getLogger('meta.lookupbyisbn') logger = logging.getLogger('meta.lookupbyisbn')
base = 'http://www.lookupbyisbn.com' base = 'http://www.lookupbyisbn.com'
def get_ids(key, value): def get_ids(key, value):

View file

@ -2,19 +2,20 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
from datetime import datetime
from urllib import urlencode from urllib import urlencode
import json import json
from datetime import datetime
from ox.cache import read_url from ox.cache import read_url
from marc_countries import COUNTRIES
from dewey import get_classification from dewey import get_classification
from marc_countries import COUNTRIES
from utils import normalize_isbn from utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.openlibrary') logger = logging.getLogger('meta.openlibrary')
KEYS = { KEYS = {
'authors': 'author', 'authors': 'author',
'covers': 'cover', 'covers': 'cover',

View file

@ -1,6 +1,11 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
import re import re
import stdnum.isbn import stdnum.isbn
def normalize_isbn(value): def normalize_isbn(value):
return ''.join([s for s in value if s.isdigit() or s == 'X']) return ''.join([s for s in value if s.isdigit() or s == 'X'])

View file

@ -2,16 +2,19 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
from ox.cache import read_url
import lxml.html
import re import re
import hashlib import hashlib
from utils import normalize_isbn
from ox.cache import read_url
import lxml.html
import stdnum.isbn import stdnum.isbn
from .utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.worldcat') logger = logging.getLogger('meta.worldcat')
base_url = 'http://www.worldcat.org' base_url = 'http://www.worldcat.org'
def get_ids(key, value): def get_ids(key, value):

View file

@ -3,9 +3,10 @@
from __future__ import division from __future__ import division
import json import json
from ox.cache import read_url
from urllib import urlencode from urllib import urlencode
from ox.cache import read_url
import logging import logging
logger = logging.getLogger('metaremote') logger = logging.getLogger('metaremote')

View file

@ -1,11 +1,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
import os
import hashlib import hashlib
import os
import OpenSSL import OpenSSL
import settings import settings
def get_fingerprint(): def get_fingerprint():
with open(settings.ssl_cert_path) as fd: with open(settings.ssl_cert_path) as fd:
data = fd.read() data = fd.read()

View file

@ -2,12 +2,11 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import settings
from changelog import Changelog from changelog import Changelog
from user.models import User from user.models import User
import state
from websocket import trigger_event from websocket import trigger_event
import settings
import state
import logging import logging
logger = logging.getLogger('oml.node.nodeapi') logger = logging.getLogger('oml.node.nodeapi')

View file

@ -2,28 +2,28 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
import os import os
import tornado import tornado
from tornado.web import Application from tornado.web import Application
from tornado.httpserver import HTTPServer from tornado.httpserver import HTTPServer
from tornado.ioloop import PeriodicCallback from tornado.ioloop import PeriodicCallback
import settings from oxtornado import run_async
from utils import valid, get_public_ipv6
import directory from websocket import trigger_event
import cert
import db import db
import directory
import json
import nodeapi
import settings
import state import state
import user 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 import logging
logger = logging.getLogger('oml.node.server') logger = logging.getLogger('oml.node.server')
class NodeHandler(tornado.web.RequestHandler): class NodeHandler(tornado.web.RequestHandler):
def initialize(self): def initialize(self):
@ -101,7 +101,6 @@ class ShareHandler(tornado.web.RequestHandler):
pass pass
def get(self, id): def get(self, id):
import db
import item.models import item.models
with db.session(): with db.session():
i = item.models.Item.get(id) i = item.models.Item.get(id)

View file

@ -5,24 +5,24 @@ from __future__ import division, print_function
import os import os
import sys import sys
from tornado.web import StaticFileHandler, Application
from tornado.httpserver import HTTPServer from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop 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 from cache import Cache
import tasks
from item.icons import IconHandler
from item.handlers import EpubHandler, ReaderHandler, FileHandler from item.handlers import EpubHandler, ReaderHandler, FileHandler
from item.handlers import OMLHandler, serve_static 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): class MainHandler(OMLHandler):
@ -31,7 +31,6 @@ class MainHandler(OMLHandler):
serve_static(self, path, 'text/html') serve_static(self, path, 'text/html')
def run(): def run():
import setup
setup.create_db() setup.create_db()
root_dir = os.path.normpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')) 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 PID = sys.argv[2] if len(sys.argv) > 2 else None
@ -78,7 +77,6 @@ def run():
import user import user
import downloads import downloads
import nodes import nodes
import db
state.node = node.server.start() state.node = node.server.start()
state.nodes = nodes.Nodes() state.nodes = nodes.Nodes()
state.downloads = downloads.Downloads() state.downloads = downloads.Downloads()

View file

@ -2,20 +2,18 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import os
from copy import deepcopy from copy import deepcopy
import json import json
import os
from oxtornado import actions
import ox import ox
import models from changelog import Changelog
from oxtornado import actions
from utils import update_dict from utils import update_dict
import models
import settings import settings
import state import state
from changelog import Changelog
import logging import logging
logger = logging.getLogger('oml.user.api') logger = logging.getLogger('oml.user.api')
@ -192,7 +190,6 @@ def removeList(data):
actions.register(removeList, cache=False) actions.register(removeList, cache=False)
def addListItems(data): def addListItems(data):
''' '''
takes { takes {
@ -397,4 +394,3 @@ def getActivity(data):
''' '''
return state.activity return state.activity
actions.register(getActivity, cache=False) actions.register(getActivity, cache=False)

View file

@ -3,14 +3,13 @@
import json import json
import db
from db import MutableDict
import sqlalchemy as sa import sqlalchemy as sa
from queryparser import Parser
from changelog import Changelog from changelog import Changelog
from db import MutableDict
from queryparser import Parser
import db
import settings import settings
import state import state
import logging import logging