updated init cmd, configs + bumped to version 4
This commit is contained in:
parent
a774a1604e
commit
6190890646
@ -1 +1 @@
|
|||||||
__version__ = 3
|
__version__ = 4
|
@ -1,12 +1,12 @@
|
|||||||
import add_cmd
|
|
||||||
import import_cmd
|
|
||||||
import export_cmd
|
|
||||||
import init_cmd
|
import init_cmd
|
||||||
import list_cmd
|
# import add_cmd
|
||||||
import open_cmd
|
# import import_cmd
|
||||||
import edit_cmd
|
# import export_cmd
|
||||||
import remove_cmd
|
# import list_cmd
|
||||||
import websearch_cmd
|
# import edit_cmd
|
||||||
import tag_cmd
|
# import remove_cmd
|
||||||
import attach_cmd
|
# import open_cmd
|
||||||
import update_cmd
|
# import websearch_cmd
|
||||||
|
# import tag_cmd
|
||||||
|
# import attach_cmd
|
||||||
|
# import update_cmd
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ..repo import Repository
|
from .. import databroker
|
||||||
from ..configs import config
|
from ..configs import config
|
||||||
from ..uis import get_ui
|
from ..uis import get_ui
|
||||||
from .. import color
|
from .. import color
|
||||||
from .. import files
|
|
||||||
|
|
||||||
def parser(subparsers):
|
def parser(subparsers):
|
||||||
parser = subparsers.add_parser('init',
|
parser = subparsers.add_parser('init',
|
||||||
help="initialize the papers directory")
|
help="initialize the papers directory")
|
||||||
parser.add_argument('-p', '--path', default=None,
|
parser.add_argument('-p', '--pubsdir', default=None,
|
||||||
help='path to papers directory (if none, ~/.papers is used)')
|
help='path to papers directory (if none, ~/.papers is used)')
|
||||||
parser.add_argument('-d', '--doc-dir', default=None,
|
parser.add_argument('-d', '--docsdir', default='docsdir://',
|
||||||
help=('path to document directory (if none, documents '
|
help=('path to document directory (if not specified, documents will'
|
||||||
'are stored in the same directory)'))
|
'be stored in /path/to/pubsdir/doc/)'))
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -23,20 +23,24 @@ def command(args):
|
|||||||
"""Create a .papers directory"""
|
"""Create a .papers directory"""
|
||||||
|
|
||||||
ui = get_ui()
|
ui = get_ui()
|
||||||
path = args.path
|
pubsdir = args.pubsdir
|
||||||
doc_dir = args.doc_dir
|
docsdir = args.docsdir
|
||||||
|
|
||||||
if path is not None:
|
if pubsdir is None:
|
||||||
config().papers_dir = files.clean_path(os.getcwd(), path)
|
pubsdir = '~/.papers'
|
||||||
ppd = config().papers_dir
|
|
||||||
if os.path.exists(ppd) and len(os.listdir(ppd)) > 0:
|
pubsdir = os.path.normpath(os.path.abspath(os.path.expanduser(pubsdir)))
|
||||||
|
|
||||||
|
if os.path.exists(pubsdir) and len(os.listdir(pubsdir)) > 0:
|
||||||
ui.error('directory {} is not empty.'.format(
|
ui.error('directory {} is not empty.'.format(
|
||||||
color.dye(ppd, color.filepath)))
|
color.dye(pubsdir, color.filepath)))
|
||||||
ui.exit()
|
ui.exit()
|
||||||
|
|
||||||
ui.print_('Initializing papers in {}.'.format(
|
ui.print_('Initializing papers in {}.'.format(
|
||||||
color.dye(ppd, color.filepath)))
|
color.dye(pubsdir, color.filepath)))
|
||||||
|
|
||||||
repo = Repository(config(), load = False)
|
config().pubsdir = pubsdir
|
||||||
repo.save()
|
config().docsdir = docsdir
|
||||||
config().save()
|
config().save()
|
||||||
|
|
||||||
|
databroker.DataBroker(pubsdir, create=True)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
import collections
|
||||||
|
|
||||||
from .p3 import configparser
|
from .p3 import configparser
|
||||||
|
|
||||||
# constant stuff (DFT = DEFAULT)
|
# constant stuff (DFT = DEFAULT)
|
||||||
@ -12,18 +14,18 @@ except KeyError:
|
|||||||
|
|
||||||
DFT_PLUGINS = ''
|
DFT_PLUGINS = ''
|
||||||
|
|
||||||
DFT_CONFIG = {'papers_dir' : os.path.expanduser('~/.papers'),
|
DFT_CONFIG = collections.OrderedDict([
|
||||||
'doc_dir' : 'doc',
|
('pubsdir', os.path.expanduser('~/.papers')),
|
||||||
'import_copy' : True,
|
('docsdir', ''),
|
||||||
'import_move' : False,
|
('import_copy', True),
|
||||||
'color' : True,
|
('import_move', False),
|
||||||
'version' : 3,
|
('color', True),
|
||||||
'version_warning' : True,
|
('version', 4),
|
||||||
|
('version_warning', True),
|
||||||
'open_cmd' : 'open',
|
('open_cmd', 'open'),
|
||||||
'edit_cmd' : DFT_EDIT_CMD,
|
('edit_cmd', DFT_EDIT_CMD),
|
||||||
'plugins' : DFT_PLUGINS
|
('plugins', DFT_PLUGINS)
|
||||||
}
|
])
|
||||||
|
|
||||||
BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'}
|
BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'}
|
||||||
|
|
||||||
|
@ -14,17 +14,17 @@ from .__init__ import __version__
|
|||||||
|
|
||||||
CORE_CMDS = collections.OrderedDict([
|
CORE_CMDS = collections.OrderedDict([
|
||||||
('init', commands.init_cmd),
|
('init', commands.init_cmd),
|
||||||
('add', commands.add_cmd),
|
# ('add', commands.add_cmd),
|
||||||
('import', commands.import_cmd),
|
# ('import', commands.import_cmd),
|
||||||
('export', commands.export_cmd),
|
# ('export', commands.export_cmd),
|
||||||
('list', commands.list_cmd),
|
# ('list', commands.list_cmd),
|
||||||
('edit', commands.edit_cmd),
|
# ('edit', commands.edit_cmd),
|
||||||
('remove', commands.remove_cmd),
|
# ('remove', commands.remove_cmd),
|
||||||
('open', commands.open_cmd),
|
# ('open', commands.open_cmd),
|
||||||
('websearch', commands.websearch_cmd),
|
# ('websearch', commands.websearch_cmd),
|
||||||
('tag', commands.tag_cmd),
|
# ('tag', commands.tag_cmd),
|
||||||
('attach', commands.attach_cmd),
|
# ('attach', commands.attach_cmd),
|
||||||
('update', commands.update_cmd),
|
# ('update', commands.update_cmd),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -3,7 +3,7 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(name='papers',
|
setup(name='papers',
|
||||||
version='3',
|
version='4',
|
||||||
author='Fabien Benureau, Olivier Mangin, Jonathan Grizou',
|
author='Fabien Benureau, Olivier Mangin, Jonathan Grizou',
|
||||||
author_email='fabien.benureau+inria@gmail.com',
|
author_email='fabien.benureau+inria@gmail.com',
|
||||||
url='',
|
url='',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user