diff --git a/pubs/commands/add_cmd.py b/pubs/commands/add_cmd.py index 8800b7a..56765b4 100644 --- a/pubs/commands/add_cmd.py +++ b/pubs/commands/add_cmd.py @@ -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 diff --git a/pubs/content.py b/pubs/content.py index bc33c4f..18f8c50 100644 --- a/pubs/content.py +++ b/pubs/content.py @@ -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): diff --git a/pubs/filebroker.py b/pubs/filebroker.py index 29faea2..53bdb75 100644 --- a/pubs/filebroker.py +++ b/pubs/filebroker.py @@ -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):