Skip to content

Commit

Permalink
Include macros folder and templates in config
Browse files Browse the repository at this point in the history
  • Loading branch information
HafeezOJ committed Jan 16, 2025
1 parent 18c0952 commit d4d3c19
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 37 deletions.
10 changes: 5 additions & 5 deletions ldcoolp/curation/inspection/readme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def __init__(self, dn: DepositorName, config_dict=config_default_dict,
self.folderName = self.dn.folderName
self.article_id = self.dn.article_id
self.article_dict = self.dn.curation_dict
self.funders_dict = 'funders_dict.jinja'

if isinstance(log, type(None)):
self.log = log_stdout()
Expand Down Expand Up @@ -127,6 +126,7 @@ def __init__(self, dn: DepositorName, config_dict=config_default_dict,

self.curation_dict = self.config_dict['curation']
self.root_directory_main = self.curation_dict[self.curation_dict['parent_dir']]
self.funders_macro = join(self.curation_dict['macros_folder'], self.curation_dict['funders_macro'])

# Always obtain current data curation stage
self.mc = move.MoveClass(curation_dict=self.curation_dict)
Expand Down Expand Up @@ -262,9 +262,9 @@ def save_template(self):

dest_file = join(self.metadata_path, self.readme_template)

funders_dict_file_src = join(dirname(__file__), 'templates',
self.funders_dict)
funders_dict_file_dest = join(self.metadata_path, self.funders_dict)
funders_macro_file_src = join(dirname(__file__), 'templates',
self.funders_macro)
funders_macro_file_dest = join(self.metadata_path, self.curation_dict['funders_macro'])

if not exists(dest_file):
self.log.info(f"Saving {self.readme_template} template in METADATA ...")
Expand All @@ -277,7 +277,7 @@ def save_template(self):

self.log.info(f"Source file name: {src_file}")
shutil.copy(src_file, dest_file)
shutil.copy(funders_dict_file_src, funders_dict_file_dest)
shutil.copy(funders_macro_file_src, funders_macro_file_dest)
else:
self.log.info(f"{dest_file} exists. Not overwriting template!")

Expand Down
11 changes: 5 additions & 6 deletions ldcoolp/curation/inspection/readme/templates/DVC.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@ DOI:
{% endif %}
{% if figshare_dict.funders != [] %}
---------------------------------------------
## Funders
## Funding Information

{% import 'funders_dict.jinja' as funds %}
{% set ns = namespace(funder_found = false) %}
{% for funder in figshare_dict.funders %}
{% if funder.is_user_defined == 0 %}
{% import 'funders_macro.jinja' as funds %}
{% for funder in figshare_dict.funders -%}
{% if funder.is_user_defined == 0 -%}
{{ funds.funders_(funder) }}
{% else %}
- {{ funder.title }}
{% endif %}
{% endfor %}
{%- endfor %}



Expand Down
11 changes: 5 additions & 6 deletions ldcoolp/curation/inspection/readme/templates/Main.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ DOI:
{% endif %}
{% if figshare_dict.funders != [] %}
---------------------------------------------
## Funders
## Funding Information

{% import 'funders_dict.jinja' as funds %}
{% set ns = namespace(funder_found = false) %}
{% for funder in figshare_dict.funders %}
{% if funder.is_user_defined == 0 %}
{% import 'funders_macro.jinja' as funds %}
{% for funder in figshare_dict.funders -%}
{% if funder.is_user_defined == 0 -%}
{{ funds.funders_(funder) }}
{% else %}
- {{ funder.title }}
{% endif %}
{% endfor %}
{%- endfor %}



Expand Down
11 changes: 5 additions & 6 deletions ldcoolp/curation/inspection/readme/templates/Space_Grant.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ DOI:
{% endif %}
{% if figshare_dict.funders != [] %}
---------------------------------------------
## Funders
## Funding Information

{% import 'funders_dict.jinja' as funds %}
{% set ns = namespace(funder_found = false) %}
{% for funder in figshare_dict.funders %}
{% if funder.is_user_defined == 0 %}
{% import 'funders_macro.jinja' as funds %}
{% for funder in figshare_dict.funders -%}
{% if funder.is_user_defined == 0 -%}
{{ funds.funders_(funder) }}
{% else %}
- {{ funder.title }}
{% endif %}
{% endfor %}
{%- endfor %}



Expand Down
11 changes: 5 additions & 6 deletions ldcoolp/curation/inspection/readme/templates/WCCFL.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ DOI:
{% endif %}
{% if figshare_dict.funders != [] %}
---------------------------------------------
## Funders
## Funding Information

{% import 'funders_dict.jinja' as funds %}
{% set ns = namespace(funder_found = false) %}
{% for funder in figshare_dict.funders %}
{% if funder.is_user_defined == 0 %}
{% import 'funders_macro.jinja' as funds %}
{% for funder in figshare_dict.funders -%}
{% if funder.is_user_defined == 0 -%}
{{ funds.funders_(funder) }}
{% else %}
- {{ funder.title }}
{% endif %}
{% endfor %}
{%- endfor %}



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro funders_(given_funder) %}
{% macro funders_(given_funder) -%}
{% set funders = {
'National Science Foundation': ['Directorate for Biological Sciences',
'Directorate for Computer and Information Science and Engineering',
Expand All @@ -11,18 +11,18 @@
]
} %}
{% set ns = namespace(given_funder_found = false) %}
{% for funder, offices in funders.items() %}
{% if given_funder.funder_name in offices %}
{% for funder, offices in funders.items() -%}
{% if given_funder.funder_name in offices -%}
{% set ns.given_funder_found = true %}
- {{ funder }} (Grant no: {{ given_funder.grant_code }})
{{ given_funder.url }}
{% break %}
{% else %}
{% set ns.given_funder_found = false %}
{% endif %}
{% endfor %}
{% if ns.given_funder_found == false %}
{%- endif %}
{%- endfor %}
{% if ns.given_funder_found == false -%}
- {{ given_funder.funder_name}} (Grant no: {{ given_funder.grant_code }})
{{ given_funder.url }}
{% endif %}
{% endmacro %}
{%- endif %}
{%- endmacro %}

0 comments on commit d4d3c19

Please sign in to comment.