|
|
@ -1,6 +1,8 @@
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import ConfigParser
|
|
|
|
import ConfigParser
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MAIN_SECTION = 'papers'
|
|
|
|
CONFIG_PATH = os.path.expanduser('~/.papersrc')
|
|
|
|
CONFIG_PATH = os.path.expanduser('~/.papersrc')
|
|
|
|
DEFAULT_PAPERS_DIRECTORY = os.path.expanduser('~/.papers')
|
|
|
|
DEFAULT_PAPERS_DIRECTORY = os.path.expanduser('~/.papers')
|
|
|
|
DEFAULT_OPEN_CMD = 'open'
|
|
|
|
DEFAULT_OPEN_CMD = 'open'
|
|
|
@ -12,7 +14,7 @@ except KeyError:
|
|
|
|
DEFAULT_IMPORT_COPY = 'yes'
|
|
|
|
DEFAULT_IMPORT_COPY = 'yes'
|
|
|
|
DEFAULT_IMPORT_MOVE = 'no'
|
|
|
|
DEFAULT_IMPORT_MOVE = 'no'
|
|
|
|
DEFAULT_COLOR = 'yes'
|
|
|
|
DEFAULT_COLOR = 'yes'
|
|
|
|
|
|
|
|
DEFAULT_PLUGINS = ''
|
|
|
|
|
|
|
|
|
|
|
|
CONFIG = ConfigParser.SafeConfigParser({
|
|
|
|
CONFIG = ConfigParser.SafeConfigParser({
|
|
|
|
'papers-directory': DEFAULT_PAPERS_DIRECTORY,
|
|
|
|
'papers-directory': DEFAULT_PAPERS_DIRECTORY,
|
|
|
@ -20,8 +22,9 @@ CONFIG = ConfigParser.SafeConfigParser({
|
|
|
|
'edit-cmd': DEFAULT_EDIT_CMD,
|
|
|
|
'edit-cmd': DEFAULT_EDIT_CMD,
|
|
|
|
'import-copy': DEFAULT_IMPORT_COPY,
|
|
|
|
'import-copy': DEFAULT_IMPORT_COPY,
|
|
|
|
'import-move': DEFAULT_IMPORT_MOVE,
|
|
|
|
'import-move': DEFAULT_IMPORT_MOVE,
|
|
|
|
'color': DEFAULT_COLOR})
|
|
|
|
'color': DEFAULT_COLOR,
|
|
|
|
CONFIG.add_section('papers')
|
|
|
|
'plugins': DEFAULT_PLUGINS})
|
|
|
|
|
|
|
|
CONFIG.add_section(MAIN_SECTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_config():
|
|
|
|
def read_config():
|
|
|
@ -42,6 +45,10 @@ def add_and_write_option(section, option, value):
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_plugins(cfg):
|
|
|
|
|
|
|
|
return cfg.get(MAIN_SECTION, 'plugins').split()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_boolean(value, default):
|
|
|
|
def get_boolean(value, default):
|
|
|
|
value = str(value).lower()
|
|
|
|
value = str(value).lower()
|
|
|
|
if value in ('yes', 'true', 't', 'y', '1'):
|
|
|
|
if value in ('yes', 'true', 't', 'y', '1'):
|
|
|
|