Change call for command from "cmds[cmd].command(**vars(args))" to "cmds[cmd].command(args)".
Applied the corresponding changes to command files. AMakes it possible to declare and use additional parser inside subparsers. May be useful for tag command. Will be implemented in texnote plugin.
This commit is contained in:
parent
d02155af4e
commit
31cf4de9d3
@ -19,11 +19,18 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, bibfile, docfile, tags, copy):
|
def command(args):
|
||||||
"""
|
"""
|
||||||
:param bibfile: bibtex file (in .bib, .bibml or .yaml format.
|
:param bibfile: bibtex file (in .bib, .bibml or .yaml format.
|
||||||
:param docfile: path (no url yet) to a pdf or ps file
|
:param docfile: path (no url yet) to a pdf or ps file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
bibfile = args.bibfile
|
||||||
|
docfile = args.docfile
|
||||||
|
tags = args.tags
|
||||||
|
copy = args.copy
|
||||||
|
|
||||||
if copy is None:
|
if copy is None:
|
||||||
copy = config().import_copy
|
copy = config().import_copy
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
|
@ -9,10 +9,14 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, bibfile):
|
def command(args):
|
||||||
"""
|
"""
|
||||||
:param bibtex bibtex file (in .bib, .bibml or .yaml format.
|
:param bibfile bibtex file (in .bib, .bibml or .yaml format.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
bibfile = args.bibfile
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
for p in Paper.many_from_bib(bibfile):
|
for p in Paper.many_from_bib(bibfile):
|
||||||
rp.add_paper(p)
|
rp.add_paper(p)
|
||||||
|
@ -16,11 +16,18 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, copy, reference, document):
|
def command(args):
|
||||||
"""
|
"""
|
||||||
:param bibfile: bibtex file (in .bib, .bibml or .yaml format.
|
:param bibfile: bibtex file (in .bib, .bibml or .yaml format.
|
||||||
:param docfile: path (no url yet) to a pdf or ps file
|
:param docfile: path (no url yet) to a pdf or ps file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
copy = args.copy
|
||||||
|
reference = args.reference
|
||||||
|
document = args.document
|
||||||
|
|
||||||
|
|
||||||
if copy is None:
|
if copy is None:
|
||||||
copy = config().import_copy
|
copy = config().import_copy
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
|
@ -14,7 +14,12 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, meta, reference):
|
def command(args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
meta = args.meta
|
||||||
|
reference = args.reference
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
key = parse_reference(ui, rp, reference)
|
key = parse_reference(ui, rp, reference)
|
||||||
paper = rp.get_paper(key)
|
paper = rp.get_paper(key)
|
||||||
|
@ -16,10 +16,15 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, bib_format, references):
|
def command(args):
|
||||||
"""
|
"""
|
||||||
:param bib_format (in 'bibtex', 'yaml')
|
:param bib_format (in 'bibtex', 'yaml')
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
bib_format = args.bib_format
|
||||||
|
references = args.references
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
papers = [rp.get_paper(c)
|
papers = [rp.get_paper(c)
|
||||||
for c in parse_references(ui, rp, references)]
|
for c in parse_references(ui, rp, references)]
|
||||||
|
@ -15,10 +15,15 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, bibpath, copy):
|
def command(args):
|
||||||
"""
|
"""
|
||||||
:param bibpath: path (no url yet) to a bibliography file
|
:param bibpath: path (no url yet) to a bibliography file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
bibpath = args.bibpath
|
||||||
|
copy = agrs.copy
|
||||||
|
|
||||||
if copy is None:
|
if copy is None:
|
||||||
copy = config().import_copy
|
copy = config().import_copy
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
|
@ -18,8 +18,13 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, path, doc_dir):
|
def command(args):
|
||||||
"""Create a .papers directory"""
|
"""Create a .papers directory"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
path = args.path
|
||||||
|
doc_dir = args.doc_dir
|
||||||
|
|
||||||
if path is not None:
|
if path is not None:
|
||||||
config().papers_dir = files.clean_path(os.getcwd(), path)
|
config().papers_dir = files.clean_path(os.getcwd(), path)
|
||||||
ppd = config().papers_dir
|
ppd = config().papers_dir
|
||||||
|
@ -15,7 +15,12 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, citekeys, query):
|
def command(args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
citekeys = args.citekeys
|
||||||
|
query = args.query
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
papers = [(n, p) for n, p in enumerate(rp.all_papers())
|
papers = [(n, p) for n, p in enumerate(rp.all_papers())
|
||||||
if test_paper(query, p)]
|
if test_paper(query, p)]
|
||||||
|
@ -16,7 +16,12 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, with_command, reference):
|
def command(args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
with_command = args.with_command
|
||||||
|
reference = args.reference
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
key = parse_reference(ui, rp, reference)
|
key = parse_reference(ui, rp, reference)
|
||||||
paper = rp.get_paper(key)
|
paper = rp.get_paper(key)
|
||||||
|
@ -14,7 +14,12 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, force, references):
|
def command(args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
force = args.force
|
||||||
|
references = args.references
|
||||||
|
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
citekeys = parse_references(ui, rp, references)
|
citekeys = parse_references(ui, rp, references)
|
||||||
if force is None:
|
if force is None:
|
||||||
|
@ -28,7 +28,7 @@ def parser(subparsers):
|
|||||||
'tag.')
|
'tag.')
|
||||||
parser.add_argument('tags', nargs='?', default = None,
|
parser.add_argument('tags', nargs='?', default = None,
|
||||||
help='If the previous argument was a reference, then '
|
help='If the previous argument was a reference, then '
|
||||||
'then a list of tags separated by commas.')
|
'then a list of tags separated by a +.')
|
||||||
# TODO find a way to display clear help for multiple command semantics,
|
# TODO find a way to display clear help for multiple command semantics,
|
||||||
# indistinguisable for argparse. (fabien, 201306)
|
# indistinguisable for argparse. (fabien, 201306)
|
||||||
return parser
|
return parser
|
||||||
@ -64,8 +64,14 @@ def _tag_groups(tags):
|
|||||||
minus_tags.append(tag[1:])
|
minus_tags.append(tag[1:])
|
||||||
return set(plus_tags), set(minus_tags)
|
return set(plus_tags), set(minus_tags)
|
||||||
|
|
||||||
def command(ui, referenceOrTag, tags):
|
def command(args):
|
||||||
"""Add, remove and show tags"""
|
"""Add, remove and show tags"""
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
referenceOrTag = args.referenceOrTag
|
||||||
|
tags = args.tags
|
||||||
|
|
||||||
|
|
||||||
rp = Repository(config())
|
rp = Repository(config())
|
||||||
|
|
||||||
if referenceOrTag is None:
|
if referenceOrTag is None:
|
||||||
@ -94,4 +100,4 @@ def command(ui, referenceOrTag, tags):
|
|||||||
papers_list.append((p, n))
|
papers_list.append((p, n))
|
||||||
|
|
||||||
ui.print_('\n'.join(helpers.paper_oneliner(p, n)
|
ui.print_('\n'.join(helpers.paper_oneliner(p, n)
|
||||||
for p, n in papers_list))
|
for p, n in papers_list))
|
||||||
|
@ -10,7 +10,10 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui):
|
def command(args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
|
||||||
code_version = __version__
|
code_version = __version__
|
||||||
repo_version = int(config().version)
|
repo_version = int(config().version)
|
||||||
|
|
||||||
|
@ -10,8 +10,11 @@ def parser(subparsers):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def command(ui, search_string):
|
def command(args):
|
||||||
print search_string
|
|
||||||
|
ui = args.ui
|
||||||
|
search_string = args.search_string
|
||||||
|
|
||||||
url = ("https://scholar.google.fr/scholar?q=%s&lr="
|
url = ("https://scholar.google.fr/scholar?q=%s&lr="
|
||||||
% (urllib.quote_plus(' '.join(search_string))))
|
% (urllib.quote_plus(' '.join(search_string))))
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
@ -52,4 +52,4 @@ def execute(raw_args = sys.argv):
|
|||||||
cmd = args.command
|
cmd = args.command
|
||||||
del args.command
|
del args.command
|
||||||
|
|
||||||
cmds[cmd].command(**vars(args))
|
cmds[cmd].command(args)
|
||||||
|
@ -29,7 +29,14 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
parser.add_argument('-v', '--view', action='store_true', help='open the paper in a pdf viewer', default=None)
|
parser.add_argument('-v', '--view', action='store_true', help='open the paper in a pdf viewer', default=None)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def command(self, ui, texcmd, reference, view):
|
def command(self, args):
|
||||||
|
|
||||||
|
ui = args.ui
|
||||||
|
texcmd = args.texcmd
|
||||||
|
reference = args.reference
|
||||||
|
view = args.view
|
||||||
|
|
||||||
|
|
||||||
if view is not None:
|
if view is not None:
|
||||||
subprocess.Popen(['papers', 'open', reference])
|
subprocess.Popen(['papers', 'open', reference])
|
||||||
if texcmd == 'edit':
|
if texcmd == 'edit':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user