Adds possibility to create repo when instance initialized.
This avoids having to manually call _create on filebroker.
This commit is contained in:
parent
b51477fc58
commit
2f1a8ae42a
@ -6,6 +6,7 @@ from .. import databroker
|
||||
from ..configs import config
|
||||
from ..uis import get_ui
|
||||
from .. import color
|
||||
from ..repo import Repository
|
||||
|
||||
|
||||
def parser(subparsers):
|
||||
@ -28,19 +29,19 @@ def command(args):
|
||||
|
||||
if pubsdir is None:
|
||||
pubsdir = '~/.pubs'
|
||||
|
||||
|
||||
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(
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
ui.exit()
|
||||
ui.error('directory {} is not empty.'.format(
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
ui.exit()
|
||||
|
||||
ui.print_('Initializing pubs in {}.'.format(
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
|
||||
config().pubsdir = pubsdir
|
||||
config().docsdir = docsdir
|
||||
config().save()
|
||||
|
||||
databroker.DataBroker(pubsdir, create=True)
|
||||
Repository(config(), create=True)
|
||||
|
@ -21,10 +21,11 @@ class InvalidReference(Exception):
|
||||
|
||||
class Repository(object):
|
||||
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, create=False):
|
||||
self.config = config
|
||||
self._citekeys = None
|
||||
self.databroker = datacache.DataCache(self.config.pubsdir)
|
||||
self.databroker = datacache.DataCache(self.config.pubsdir,
|
||||
create=create)
|
||||
|
||||
@property
|
||||
def citekeys(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user