|
|
@ -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 pubsdir is None:
|
|
|
|
|
|
|
|
pubsdir = '~/.papers'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pubsdir = os.path.normpath(os.path.abspath(os.path.expanduser(pubsdir)))
|
|
|
|
|
|
|
|
|
|
|
|
if path is not None:
|
|
|
|
if os.path.exists(pubsdir) and len(os.listdir(pubsdir)) > 0:
|
|
|
|
config().papers_dir = files.clean_path(os.getcwd(), path)
|
|
|
|
|
|
|
|
ppd = config().papers_dir
|
|
|
|
|
|
|
|
if os.path.exists(ppd) and len(os.listdir(ppd)) > 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)
|
|
|
|