Loading data_repo_renderer/__init__.py +51 −3 Original line number Diff line number Diff line Loading @@ -354,6 +354,8 @@ class ReadmeRenderer(Renderer): People: {{people}} {{repo_description}} {{acknowledgement_parsed}} {{citations_parsed}} ## Known problems Loading Loading @@ -395,6 +397,15 @@ class ReadmeRenderer(Renderer): def __init__(self, yaml_dict=None, *args, **kwargs): """Add credentials file info but use super's init otherwise.""" yaml_dict = self._maybe_include_credentials(yaml_dict) yaml_dict = self._maybe_include_acknowledgements(yaml_dict) yaml_dict = self._maybe_include_citations(yaml_dict) super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args, **kwargs) @static def _maybe_include_credentials(yaml_dict): if "credential_files" not in yaml_dict: yaml_dict["maybe_credentials"] = "" else: Loading @@ -404,9 +415,46 @@ class ReadmeRenderer(Renderer): "- \"{}\"".format(el) for el in yaml_dict["credential_files"])) yaml_dict["maybe_credentials"] = textwrap.dedent(cred_string) return yaml_dict super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args, **kwargs) @static def _maybe_include_acknowledgements(yaml_dict): if "acknowledgements" not in yaml_dict: yaml_dict["acknowledgements_parsed"] = "" else: ack_string = """\ ## How to acknowledge the original data set? Please consider to include the following in the acknowledgements of any manuscript that uses the data: > {acknowledgements} """.format(yaml_dict["acknowledgements"]) yaml_dict["acknowledgements_parsed"] = textwrap.dedent( ack_string) return yaml_dict @static def _maybe_include_citations(yaml_dict): if ("citations" not in yaml_dict or len(yaml_dict["citations"]) == 0): yaml_dict["citations_parsed"] = "" else: cite_string = """\ ## How to cite the data set? The following references provide details about the data set: """.format(yaml_dict["citations"]) yaml_dict["citations_parsed"] = textwrap.dedent( cite_string) for ct in yaml_dict["citations"]: yaml_dict["citations_parsed"] += """\ - {text}, doi:{doi} """.format(ct) return yaml_dict def _make_file_executable(file_name): Loading tests/test_full_yaml_file_and_cli.py +12 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,18 @@ repo_description: | asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf acknowledgement: | The TEST_REPO data was provided by EXAMPLE.COM. citations: - text: Doe, J., J. Doe, A new TEST dataset, J. Alchemy, doi:12.345/987654asdf11, 2017 doi: 12.345/987654asdf11 - text: Doe, J., J. Doe, An old TEST dataset, J. Alchemy, doi:12.345/987654asdf10, 2011 doi: 12.345/987654asdf10 prefixes: data doc pre_processing: Loading Loading
data_repo_renderer/__init__.py +51 −3 Original line number Diff line number Diff line Loading @@ -354,6 +354,8 @@ class ReadmeRenderer(Renderer): People: {{people}} {{repo_description}} {{acknowledgement_parsed}} {{citations_parsed}} ## Known problems Loading Loading @@ -395,6 +397,15 @@ class ReadmeRenderer(Renderer): def __init__(self, yaml_dict=None, *args, **kwargs): """Add credentials file info but use super's init otherwise.""" yaml_dict = self._maybe_include_credentials(yaml_dict) yaml_dict = self._maybe_include_acknowledgements(yaml_dict) yaml_dict = self._maybe_include_citations(yaml_dict) super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args, **kwargs) @static def _maybe_include_credentials(yaml_dict): if "credential_files" not in yaml_dict: yaml_dict["maybe_credentials"] = "" else: Loading @@ -404,9 +415,46 @@ class ReadmeRenderer(Renderer): "- \"{}\"".format(el) for el in yaml_dict["credential_files"])) yaml_dict["maybe_credentials"] = textwrap.dedent(cred_string) return yaml_dict super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args, **kwargs) @static def _maybe_include_acknowledgements(yaml_dict): if "acknowledgements" not in yaml_dict: yaml_dict["acknowledgements_parsed"] = "" else: ack_string = """\ ## How to acknowledge the original data set? Please consider to include the following in the acknowledgements of any manuscript that uses the data: > {acknowledgements} """.format(yaml_dict["acknowledgements"]) yaml_dict["acknowledgements_parsed"] = textwrap.dedent( ack_string) return yaml_dict @static def _maybe_include_citations(yaml_dict): if ("citations" not in yaml_dict or len(yaml_dict["citations"]) == 0): yaml_dict["citations_parsed"] = "" else: cite_string = """\ ## How to cite the data set? The following references provide details about the data set: """.format(yaml_dict["citations"]) yaml_dict["citations_parsed"] = textwrap.dedent( cite_string) for ct in yaml_dict["citations"]: yaml_dict["citations_parsed"] += """\ - {text}, doi:{doi} """.format(ct) return yaml_dict def _make_file_executable(file_name): Loading
tests/test_full_yaml_file_and_cli.py +12 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,18 @@ repo_description: | asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf acknowledgement: | The TEST_REPO data was provided by EXAMPLE.COM. citations: - text: Doe, J., J. Doe, A new TEST dataset, J. Alchemy, doi:12.345/987654asdf11, 2017 doi: 12.345/987654asdf11 - text: Doe, J., J. Doe, An old TEST dataset, J. Alchemy, doi:12.345/987654asdf10, 2011 doi: 12.345/987654asdf10 prefixes: data doc pre_processing: Loading