Allows move for import on explicit option.
- uses `copy` as a default (hence no need for the option), - does not use `doc_add` config for import.
This commit is contained in:
parent
7d1c678d3d
commit
668d30ffbf
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
### Implemented enhancements
|
### Implemented enhancements
|
||||||
|
|
||||||
|
- Adds `move`, and `link` options for handling of documents during import (copy being the default). [(#159)](https://github.com/pubs/pubs/pull/159)
|
||||||
|
|
||||||
- Better dialog after editing paper [(#142)](https://github.com/pubs/pubs/issues/142)
|
- Better dialog after editing paper [(#142)](https://github.com/pubs/pubs/issues/142)
|
||||||
|
|
||||||
- Add a command to open urls ([#139](https://github.com/pubs/pubs/issues/139) by [ksunden](https://github.com/ksunden))
|
- Add a command to open urls ([#139](https://github.com/pubs/pubs/issues/139) by [ksunden](https://github.com/ksunden))
|
||||||
|
@ -3,18 +3,16 @@ or help messages.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def add_doc_add_arguments(parser, move=True):
|
def add_doc_copy_arguments(parser, copy=True):
|
||||||
doc_add_group = parser.add_mutually_exclusive_group()
|
doc_add_group = parser.add_mutually_exclusive_group()
|
||||||
doc_add_group.add_argument(
|
doc_add_group.add_argument(
|
||||||
'-L', '--link', action='store_const', dest='doc_add', const='link',
|
'-L', '--link', action='store_const', dest='doc_copy', const='link',
|
||||||
default=None,
|
default=None,
|
||||||
help="don't copy document files, just create a link.")
|
help="don't copy document files, just create a link.")
|
||||||
|
if copy:
|
||||||
doc_add_group.add_argument(
|
doc_add_group.add_argument(
|
||||||
'-C', '--copy', action='store_const', dest='doc_add', const='copy',
|
'-C', '--copy', action='store_const', dest='doc_copy', const='copy',
|
||||||
default=None,
|
|
||||||
help="copy document (keep source).")
|
help="copy document (keep source).")
|
||||||
if move:
|
|
||||||
doc_add_group.add_argument(
|
doc_add_group.add_argument(
|
||||||
'-M', '--move', action='store_const', dest='doc_add', const='move',
|
'-M', '--move', action='store_const', dest='doc_copy', const='move',
|
||||||
default=None,
|
|
||||||
help="move document (copy and remove source).")
|
help="move document (copy and remove source).")
|
||||||
|
@ -12,7 +12,7 @@ from .. import apis
|
|||||||
from .. import pretty
|
from .. import pretty
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from .. import endecoder
|
from .. import endecoder
|
||||||
from ..command_utils import add_doc_add_arguments
|
from ..command_utils import add_doc_copy_arguments
|
||||||
from ..completion import CommaSeparatedTagsCompletion
|
from ..completion import CommaSeparatedTagsCompletion
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ def parser(subparsers, conf):
|
|||||||
).completer = CommaSeparatedTagsCompletion(conf)
|
).completer = CommaSeparatedTagsCompletion(conf)
|
||||||
parser.add_argument('-k', '--citekey', help='citekey associated with the paper;\nif not provided, one will be generated automatically.',
|
parser.add_argument('-k', '--citekey', help='citekey associated with the paper;\nif not provided, one will be generated automatically.',
|
||||||
default=None, type=p3.u_maybe)
|
default=None, type=p3.u_maybe)
|
||||||
add_doc_add_arguments(parser)
|
add_doc_copy_arguments(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ def command(conf, args):
|
|||||||
'{}, using {} instead.').format(bib_docfile, docfile))
|
'{}, using {} instead.').format(bib_docfile, docfile))
|
||||||
|
|
||||||
# create the paper
|
# create the paper
|
||||||
doc_add = args.doc_add
|
doc_add = args.doc_copy
|
||||||
if doc_add is None:
|
if doc_add is None:
|
||||||
doc_add = conf['main']['doc_add']
|
doc_add = conf['main']['doc_add']
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ from .. import repo
|
|||||||
from .. import endecoder
|
from .. import endecoder
|
||||||
from .. import bibstruct
|
from .. import bibstruct
|
||||||
from .. import color
|
from .. import color
|
||||||
|
from .. import content
|
||||||
from ..paper import Paper
|
from ..paper import Paper
|
||||||
from ..uis import get_ui
|
from ..uis import get_ui
|
||||||
from ..content import system_path, read_text_file
|
from ..content import system_path, read_text_file
|
||||||
from ..command_utils import add_doc_add_arguments
|
from ..command_utils import add_doc_copy_arguments
|
||||||
|
|
||||||
|
|
||||||
_ABORT_USE_IGNORE_MSG = "Aborting import. Use --ignore-malformed to ignore."
|
_ABORT_USE_IGNORE_MSG = "Aborting import. Use --ignore-malformed to ignore."
|
||||||
@ -33,7 +34,7 @@ def parser(subparsers, conf):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-i', '--ignore-malformed', action='store_true', default=False,
|
'-i', '--ignore-malformed', action='store_true', default=False,
|
||||||
help="Ignore malformed and unreadable files and entries")
|
help="Ignore malformed and unreadable files and entries")
|
||||||
add_doc_add_arguments(parser, move=False)
|
add_doc_copy_arguments(parser, copy=False)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -94,10 +95,7 @@ def command(conf, args):
|
|||||||
|
|
||||||
ui = get_ui()
|
ui = get_ui()
|
||||||
bibpath = args.bibpath
|
bibpath = args.bibpath
|
||||||
doc_add = args.doc_add
|
doc_import = args.doc_copy or 'copy'
|
||||||
if doc_add is None:
|
|
||||||
doc_add = conf['main']['doc_add']
|
|
||||||
copy = doc_add in ('copy', 'move')
|
|
||||||
|
|
||||||
rp = repo.Repository(conf)
|
rp = repo.Repository(conf)
|
||||||
# Extract papers from bib
|
# Extract papers from bib
|
||||||
@ -111,7 +109,9 @@ def command(conf, args):
|
|||||||
if docfile is None:
|
if docfile is None:
|
||||||
ui.warning("No file for {}.".format(p.citekey))
|
ui.warning("No file for {}.".format(p.citekey))
|
||||||
else:
|
else:
|
||||||
rp.push_doc(p.citekey, docfile, copy=copy)
|
rp.push_doc(p.citekey, docfile,
|
||||||
# FIXME should move the file if configured to do so.
|
copy=(doc_import in ('copy', 'move')))
|
||||||
|
if doc_import == 'move' and content.content_type(docfile) != 'url':
|
||||||
|
content.remove_file(docfile)
|
||||||
|
|
||||||
rp.close()
|
rp.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user