Permalink
Browse files

Add --cite_url to tool_init.

Allows bootstrapping some of the bibtex boilerplate.
  • Loading branch information...
jmchilton committed Nov 2, 2015
1 parent 6b8a67b commit fdb1b5132b1fcde0c146fff983a55b6623250cd7
Showing with 54 additions and 0 deletions.
  1. +8 −0 planemo/commands/cmd_tool_init.py
  2. +44 −0 planemo/tool_builder.py
  3. +2 −0 tests/test_build_and_lint.py
@@ -165,6 +165,14 @@
help=("Supply a DOI (http://www.doi.org/) easing citation of the tool "
"for Galxy users (e.g. 10.1101/014043).")
)
@click.option(
"--cite_url",
type=click.STRING,
default=None,
multiple=True,
prompt=False,
help=("Supply a URL for citation.")
)
@click.option(
"--test_case",
is_flag=True,
@@ -104,6 +104,9 @@
<citations>
{%- for single_doi in doi %}
<citation type="doi">{{ single_doi }}</citation>
{%- endfor %}
{%- for bibtex_citation in bibtex_citations %}
<citation type="bibtex">{{ bibtex_citation }}</citation>
{%- endfor %}
<yield />
</citations>
@@ -126,6 +129,12 @@ def build(**kwds):

_handle_help(kwds)

# process raw cite urls
cite_urls = kwds.get("cite_url", [])
del kwds["cite_url"]
citations = map(UrlCitation, cite_urls)
kwds["bibtex_citations"] = citations

# process raw inputs
inputs = kwds.get("input", [])
del kwds["input"]
@@ -274,6 +283,41 @@ def _find_command(kwds):
return command


class UrlCitation(object):

def __init__(self, url):
self.url = url

def __str__(self):
if "github.com" in self.url:
return self._github_str()
else:
return self._url_str()

def _github_str(self):
url = self.url
title = url.split("/")[-1]
return '''
@misc{github%s,
author = {LastTODO, FirstTODO},
year = {TODO},
title = {%s},
publisher = {GitHub},
journal = {GitHub repository},
url = {%s},
}''' % (title, title, url)

def _url_str(self):
url = self.url
return '''
@misc{renameTODO,
author = {LastTODO, FirstTODO},
year = {TODO},
title = {TODO},
url = {%s},
}''' % (url)


class ToolDescription(object):

def __init__(self, contents, macro_contents, test_files):
@@ -52,6 +52,8 @@ def _init_command(test_case=True, help_text=True, doi=True, macros=False):
command.extend(["--help_text", "The help text."])
if doi:
command.extend(["--doi", "10.1101/014043"])
command.extend(["--cite_url", "https://github.com/ekg/vcflib"])
command.extend(["--cite_url", "http://wiki.hpc.ufl.edu/doc/Seqtk"])
if macros:
command.append("--macros")
return command

0 comments on commit fdb1b51

Please sign in to comment.