Fixes path conversion for add_doc.
Note: in current state the non-copy addition of document is not implemented. This commit also adds the raise of a NotImplementedError if the behavior is requested.
This commit is contained in:
parent
506bb24e50
commit
53a0f0a86e
@ -100,12 +100,16 @@ def command(args):
|
|||||||
ui.warning(('Skipping document file from bib file '
|
ui.warning(('Skipping document file from bib file '
|
||||||
'{}, using {} instead.').format(bib_docfile, docfile))
|
'{}, using {} instead.').format(bib_docfile, docfile))
|
||||||
|
|
||||||
|
docfile = docfile
|
||||||
|
|
||||||
if docfile is not None:
|
if docfile is not None:
|
||||||
copy_doc = args.copy
|
copy_doc = args.copy
|
||||||
if copy_doc is None:
|
if copy_doc is None:
|
||||||
copy_doc = config().import_copy
|
copy_doc = config().import_copy
|
||||||
if copy_doc:
|
if copy_doc:
|
||||||
docfile = rp.databroker.add_doc(citekey, docfile)
|
docfile = rp.databroker.add_doc(citekey, docfile)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
# create the paper
|
# create the paper
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ def _check_system_path_is(nature, path, fail=True):
|
|||||||
return answer
|
return answer
|
||||||
|
|
||||||
|
|
||||||
|
def system_path(path):
|
||||||
|
return os.path.abspath(os.path.expanduser(path))
|
||||||
|
|
||||||
|
|
||||||
def check_file(path, fail=True):
|
def check_file(path, fail=True):
|
||||||
syspath = system_path(path)
|
syspath = system_path(path)
|
||||||
return (_check_system_path_exists(syspath, fail=fail)
|
return (_check_system_path_exists(syspath, fail=fail)
|
||||||
@ -64,10 +68,6 @@ def write_file(filepath, data):
|
|||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
def system_path(path):
|
|
||||||
return os.path.abspath(os.path.expanduser(path))
|
|
||||||
|
|
||||||
|
|
||||||
# dealing with formatless content
|
# dealing with formatless content
|
||||||
|
|
||||||
def content_type(path):
|
def content_type(path):
|
||||||
@ -117,7 +117,9 @@ def get_content(path, ui=None):
|
|||||||
return read_file(path)
|
return read_file(path)
|
||||||
|
|
||||||
|
|
||||||
def move_content(source, target, overwrite = False):
|
def move_content(source, target, overwrite=False):
|
||||||
|
source = system_path(source)
|
||||||
|
target = system_path(target)
|
||||||
if source == target:
|
if source == target:
|
||||||
return
|
return
|
||||||
if not overwrite and os.path.exists(target):
|
if not overwrite and os.path.exists(target):
|
||||||
@ -126,6 +128,8 @@ def move_content(source, target, overwrite = False):
|
|||||||
|
|
||||||
|
|
||||||
def copy_content(source, target, overwrite=False):
|
def copy_content(source, target, overwrite=False):
|
||||||
|
source = system_path(source)
|
||||||
|
target = system_path(target)
|
||||||
if source == target:
|
if source == target:
|
||||||
return
|
return
|
||||||
if not overwrite and os.path.exists(target):
|
if not overwrite and os.path.exists(target):
|
||||||
|
@ -145,8 +145,6 @@ class DocBroker(object):
|
|||||||
docpath = os.path.join(self.docdir, parsed.netloc)
|
docpath = os.path.join(self.docdir, parsed.netloc)
|
||||||
else:
|
else:
|
||||||
docpath = os.path.join(self.docdir, parsed.netloc, parsed.path[1:])
|
docpath = os.path.join(self.docdir, parsed.netloc, parsed.path[1:])
|
||||||
elif content_type(docpath) != 'file':
|
|
||||||
return docpath
|
|
||||||
return docpath
|
return docpath
|
||||||
|
|
||||||
def add_doc(self, citekey, source_path, overwrite=False):
|
def add_doc(self, citekey, source_path, overwrite=False):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user