summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Gallo <aamsgallo@gmail.com>2018-03-27 20:21:03 +0200
committerAlejandro Gallo <aamsgallo@gmail.com>2018-03-27 20:21:03 +0200
commit6d6e3224e1fa4f06235ed2b34e8c2cde396a9f0f (patch)
treeefe593b9d08b702ec44dccff76bd29092ee062b4
parentba83e45fdd3fa0ddf6ad64061b4e310e0cf20cf3 (diff)
Fix export
-rw-r--r--papis/commands/export.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/papis/commands/export.py b/papis/commands/export.py
index 37db8cea..7b4f2334 100644
--- a/papis/commands/export.py
+++ b/papis/commands/export.py
@@ -181,10 +181,12 @@ class Command(papis.commands.Command):
return 0
documents = [document]
- if self.args.out and not self.get_args().folder:
+ if self.args.out and not self.get_args().folder \
+ and not self.args.file:
self.args.out = open(self.get_args().out, 'a+')
- if not self.args.out and not self.get_args().folder:
+ if not self.args.out and not self.get_args().folder \
+ and not self.args.file:
self.args.out = sys.stdout
ret_string = run(
@@ -215,12 +217,20 @@ class Command(papis.commands.Command):
).write(papis.document.to_bibtex(document))
elif self.args.file:
files = document.get_files()
- file_to_open = papis.api.pick(
- files,
- pick_config=dict(
- header_filter=lambda x: x.replace(
- document.get_main_folder(), ""
+ if self.args.all:
+ files_to_open = files
+ else:
+ files_to_open = [papis.api.pick(
+ files,
+ pick_config=dict(
+ header_filter=lambda x: x.replace(
+ document.get_main_folder(), ""
+ )
)
+ )]
+ for file_to_open in filter(lambda x: x, files_to_open):
+ print(file_to_open)
+ shutil.copyfile(
+ file_to_open,
+ self.args.out or os.path.basename(file_to_open)
)
- )
- shutil.copyfile(file_to_open, self.args.out)