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.
main
Olivier Mangin 11 years ago
parent 506bb24e50
commit 53a0f0a86e

@ -100,12 +100,16 @@ def command(args):
ui.warning(('Skipping document file from bib file '
'{}, using {} instead.').format(bib_docfile, docfile))
docfile = docfile
if docfile is not None:
copy_doc = args.copy
if copy_doc is None:
copy_doc = config().import_copy
if copy_doc:
docfile = rp.databroker.add_doc(citekey, docfile)
else:
raise NotImplementedError
# create the paper

@ -39,6 +39,10 @@ def _check_system_path_is(nature, path, fail=True):
return answer
def system_path(path):
return os.path.abspath(os.path.expanduser(path))
def check_file(path, fail=True):
syspath = system_path(path)
return (_check_system_path_exists(syspath, fail=fail)
@ -64,10 +68,6 @@ def write_file(filepath, data):
f.write(data)
def system_path(path):
return os.path.abspath(os.path.expanduser(path))
# dealing with formatless content
def content_type(path):
@ -117,7 +117,9 @@ def get_content(path, ui=None):
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:
return
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):
source = system_path(source)
target = system_path(target)
if source == target:
return
if not overwrite and os.path.exists(target):

@ -145,8 +145,6 @@ class DocBroker(object):
docpath = os.path.join(self.docdir, parsed.netloc)
else:
docpath = os.path.join(self.docdir, parsed.netloc, parsed.path[1:])
elif content_type(docpath) != 'file':
return docpath
return docpath
def add_doc(self, citekey, source_path, overwrite=False):

Loading…
Cancel
Save