From 6190890646b25d37e001172f2c60946e010eaba9 Mon Sep 17 00:00:00 2001 From: Fabien Benureau Date: Sun, 10 Nov 2013 00:38:06 +0100 Subject: [PATCH] updated init cmd, configs + bumped to version 4 --- papers/__init__.py | 2 +- papers/commands/__init__.py | 22 +++++++++++----------- papers/commands/init_cmd.py | 36 ++++++++++++++++++++---------------- papers/configs.py | 26 ++++++++++++++------------ papers/papers_cmd.py | 22 +++++++++++----------- setup.py | 2 +- 6 files changed, 58 insertions(+), 52 deletions(-) diff --git a/papers/__init__.py b/papers/__init__.py index fe95ae2..b081b7c 100644 --- a/papers/__init__.py +++ b/papers/__init__.py @@ -1 +1 @@ -__version__ = 3 \ No newline at end of file +__version__ = 4 \ No newline at end of file diff --git a/papers/commands/__init__.py b/papers/commands/__init__.py index 466e2ea..03603a9 100644 --- a/papers/commands/__init__.py +++ b/papers/commands/__init__.py @@ -1,12 +1,12 @@ -import add_cmd -import import_cmd -import export_cmd import init_cmd -import list_cmd -import open_cmd -import edit_cmd -import remove_cmd -import websearch_cmd -import tag_cmd -import attach_cmd -import update_cmd +# import add_cmd +# import import_cmd +# import export_cmd +# import list_cmd +# import edit_cmd +# import remove_cmd +# import open_cmd +# import websearch_cmd +# import tag_cmd +# import attach_cmd +# import update_cmd diff --git a/papers/commands/init_cmd.py b/papers/commands/init_cmd.py index cfdb177..622581d 100644 --- a/papers/commands/init_cmd.py +++ b/papers/commands/init_cmd.py @@ -2,20 +2,20 @@ import os -from ..repo import Repository +from .. import databroker from ..configs import config from ..uis import get_ui from .. import color -from .. import files + def parser(subparsers): parser = subparsers.add_parser('init', 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)') - parser.add_argument('-d', '--doc-dir', default=None, - help=('path to document directory (if none, documents ' - 'are stored in the same directory)')) + parser.add_argument('-d', '--docsdir', default='docsdir://', + help=('path to document directory (if not specified, documents will' + 'be stored in /path/to/pubsdir/doc/)')) return parser @@ -23,20 +23,24 @@ def command(args): """Create a .papers directory""" ui = get_ui() - path = args.path - doc_dir = args.doc_dir + pubsdir = args.pubsdir + docsdir = args.docsdir + + if pubsdir is None: + pubsdir = '~/.papers' + + pubsdir = os.path.normpath(os.path.abspath(os.path.expanduser(pubsdir))) - if path is not None: - config().papers_dir = files.clean_path(os.getcwd(), path) - ppd = config().papers_dir - if os.path.exists(ppd) and len(os.listdir(ppd)) > 0: + if os.path.exists(pubsdir) and len(os.listdir(pubsdir)) > 0: ui.error('directory {} is not empty.'.format( - color.dye(ppd, color.filepath))) + color.dye(pubsdir, color.filepath))) ui.exit() ui.print_('Initializing papers in {}.'.format( - color.dye(ppd, color.filepath))) + color.dye(pubsdir, color.filepath))) - repo = Repository(config(), load = False) - repo.save() + config().pubsdir = pubsdir + config().docsdir = docsdir config().save() + + databroker.DataBroker(pubsdir, create=True) diff --git a/papers/configs.py b/papers/configs.py index ff48f0c..c538154 100644 --- a/papers/configs.py +++ b/papers/configs.py @@ -1,4 +1,6 @@ import os +import collections + from .p3 import configparser # constant stuff (DFT = DEFAULT) @@ -12,18 +14,18 @@ except KeyError: DFT_PLUGINS = '' -DFT_CONFIG = {'papers_dir' : os.path.expanduser('~/.papers'), - 'doc_dir' : 'doc', - 'import_copy' : True, - 'import_move' : False, - 'color' : True, - 'version' : 3, - 'version_warning' : True, - - 'open_cmd' : 'open', - 'edit_cmd' : DFT_EDIT_CMD, - 'plugins' : DFT_PLUGINS - } +DFT_CONFIG = collections.OrderedDict([ + ('pubsdir', os.path.expanduser('~/.papers')), + ('docsdir', ''), + ('import_copy', True), + ('import_move', False), + ('color', True), + ('version', 4), + ('version_warning', True), + ('open_cmd', 'open'), + ('edit_cmd', DFT_EDIT_CMD), + ('plugins', DFT_PLUGINS) + ]) BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'} diff --git a/papers/papers_cmd.py b/papers/papers_cmd.py index 5a4041e..dfd93e9 100644 --- a/papers/papers_cmd.py +++ b/papers/papers_cmd.py @@ -14,17 +14,17 @@ from .__init__ import __version__ CORE_CMDS = collections.OrderedDict([ ('init', commands.init_cmd), - ('add', commands.add_cmd), - ('import', commands.import_cmd), - ('export', commands.export_cmd), - ('list', commands.list_cmd), - ('edit', commands.edit_cmd), - ('remove', commands.remove_cmd), - ('open', commands.open_cmd), - ('websearch', commands.websearch_cmd), - ('tag', commands.tag_cmd), - ('attach', commands.attach_cmd), - ('update', commands.update_cmd), + # ('add', commands.add_cmd), + # ('import', commands.import_cmd), + # ('export', commands.export_cmd), + # ('list', commands.list_cmd), + # ('edit', commands.edit_cmd), + # ('remove', commands.remove_cmd), + # ('open', commands.open_cmd), + # ('websearch', commands.websearch_cmd), + # ('tag', commands.tag_cmd), + # ('attach', commands.attach_cmd), + # ('update', commands.update_cmd), ]) diff --git a/setup.py b/setup.py index 952f549..05fd26f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name='papers', - version='3', + version='4', author='Fabien Benureau, Olivier Mangin, Jonathan Grizou', author_email='fabien.benureau+inria@gmail.com', url='',