Exemplo n.º 1
0
from calibre.utils.config import JSONConfig
from calibre_plugins.EmbedComicMetadata.ini import (
    get_configuration, CONFIG_NAME, CONFIG_TITLE, CONFIG_DEFAULT, CONFIG_COLUMN_TYPE)


# This is where all preferences for this plugin will be stored
# Remember that this name (i.e. plugins/interface_demo) is also
# in a global namespace, so make it as unique as possible.
# You should always prefix your config file name with plugins/,
# so as to ensure you dont accidentally clobber a calibre config file
prefs = JSONConfig('plugins/EmbedComicMetadata')

config = get_configuration()

# set defaults
prefs.defaults = {item[CONFIG_NAME]: item[CONFIG_DEFAULT]
                  for group in config for item in group["Items"]}


class ConfigWidget(QWidget):

    def __init__(self, ia):
        QWidget.__init__(self)
        self.ia = ia
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        # make the config menu as a widget
        self.config_menu = self.make_menu()

        # make a scroll area to hold the menu and add it to the layout
        self.scroll = QScrollArea()
import sys
# other system-wide
sys.path.append('venv/lib/python2.7/site-packages')

import termcolor
import datetime

from calibre.utils.config import JSONConfig


class Const:
    NCBI_EMAIL       = 'email_for_NCBI'
    CROSSREF_API_KEY = 'CROSSREF_API_KEY'
    # PLOS_API_KEY     = 'PLoS_API_KEY'

prefs = JSONConfig('plugins/CitationGetter')
prefs.defaults = dict([(key, '') for key in Const.__dict__ if not key.startswith('__')])

DLOG_OUT_FILE = "/tmp/cglog.txt"
DLOG_OUT_FILE = None

def dlog(*s):
    str_out = "\n".join([" %s %s %s\n" % (datetime.datetime.now(), termcolor.colored(">>>", "green", None, ["bold"]), line) for line in s]) + "\n"
    if DLOG_OUT_FILE:
        with open(DLOG_OUT_FILE, 'a') as ofile:
            ofile.write(str_out)
    else:
        sys.stderr.write(str_out)
        sys.stderr.flush()
Exemplo n.º 3
0
from calibre.utils.config import JSONConfig
from calibre_plugins.EmbedComicMetadata.ini import *


# This is where all preferences for this plugin will be stored
# Remember that this name (i.e. plugins/interface_demo) is also
# in a global namespace, so make it as unique as possible.
# You should always prefix your config file name with plugins/,
# so as to ensure you dont accidentally clobber a calibre config file
prefs = JSONConfig('plugins/EmbedComicMetadata')

config = get_configuration()

# set defaults
prefs.defaults = {item[CONFIG_NAME]: item[CONFIG_DEFAULT]
                  for group in config for item in group["Items"]}


class ConfigWidget(QWidget):

    def __init__(self, ia):
        QWidget.__init__(self)
        self.ia = ia
        self.l = QVBoxLayout()
        self.setLayout(self.l)

        # make the config menu
        for group in config:
            self.make_submenu(group)

        # make menu button choices exclusive
import sys
import termcolor
import datetime

from calibre.utils.config import JSONConfig


class Const:
    NCBI_EMAIL = 'email_for_NCBI'
    CROSSREF_API_KEY = 'CROSSREF_API_KEY'
    # PLOS_API_KEY     = 'PLoS_API_KEY'


prefs = JSONConfig('plugins/CitationGetter')
prefs.defaults = dict([(key, '') for key in Const.__dict__
                       if not key.startswith('__')])

DLOG_OUT_FILE = "/tmp/cglog.txt"
DLOG_OUT_FILE = None


def dlog(*s):
    str_out = "\n".join([
        " %s %s %s\n" %
        (datetime.datetime.now(),
         termcolor.colored(">>>", "green", None, ["bold"]), line) for line in s
    ]) + "\n"
    if DLOG_OUT_FILE:
        with open(DLOG_OUT_FILE, 'a') as ofile:
            ofile.write(str_out)
    else:
Exemplo n.º 5
0
def get_prefs():
    prefs = JSONConfig('plugins/{}'.format(IDENTIFIER))
    prefs.defaults = setting_defaults
    return prefs