Skip to content

Commit

Permalink
Almost working report in pm
Browse files Browse the repository at this point in the history
* Still missing checkbox in the GUI
  • Loading branch information
dkratzert committed Sep 15, 2024
1 parent 7aa13d7 commit 82e64b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions finalcif/report/report_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@ def get_inf_article(next_word: str) -> str:
return 'an' if next_word[0].lower() in voc else 'a'


def get_distance_unit(picometers: bool) -> str:
if picometers:
return 'pm'
else:
return angstrom


def format_float_with_decimal_places(number: float, places=2) -> str:
try:
fnum = float(number)
Expand Down
5 changes: 4 additions & 1 deletion finalcif/report/templated_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from finalcif.report.report_text import (math_to_word, gstr, format_radiation, MachineType)
from finalcif.report.symm import SymmetryElement
from finalcif.tools.misc import (isnumeric, this_or_quest, timessym, angstrom, protected_space,
less_or_equal, halbgeviert, minus_sign, ellipsis_mid)
less_or_equal, halbgeviert, minus_sign, ellipsis_mid, angstrom_to_pm)
from finalcif.tools.options import Options
from finalcif.tools.space_groups import SpaceGroups

Expand Down Expand Up @@ -924,6 +924,7 @@ def make_templated_docx_report(self,
jinja_env = jinja2.Environment()
jinja_env.globals.update(strip=str.strip)
jinja_env.filters['inv_article'] = report_text.get_inf_article
jinja_env.filters['to_pm'] = angstrom_to_pm
jinja_env.filters['float_num'] = report_text.format_float_with_decimal_places
# foo[1,2] bar[3]:
jinja_env.filters['ref_num'] = self.count_reference
Expand Down Expand Up @@ -953,6 +954,7 @@ def make_templated_html_report(self,
autoescape=select_autoescape(['html', 'htm', 'xml']))
# Add zip() method to global namespace of the template:
jinja_env.globals.update(zip=zip)
jinja_env.filters['to_pm'] = angstrom_to_pm
jinja_env.filters['inv_article'] = report_text.get_inf_article
jinja_env.filters['utf8'] = report_text.utf8
jinja_env.filters['float_num'] = report_text.format_float_with_decimal_places
Expand Down Expand Up @@ -1068,6 +1070,7 @@ def get_context(self, cif: CifContainer, options: Options, picfile: Path, tpl_do
'atomic_coordinates' : self.text_formatter.get_atomic_coordinates(cif),
'displacement_parameters': self.text_formatter.get_displacement_parameters(cif),
'hydrogen_atoms' : self.text_formatter.hydrogen_atoms(cif),
'dist_unit' : report_text.get_distance_unit(self.cif.picometer),
'bonds' : self.text_formatter.get_bonds(),
'angles' : self.text_formatter.get_angles(),
'ba_symminfo' : self.text_formatter.get_bonds_angles_symminfo(),
Expand Down
Binary file added finalcif/template/template_text_pm.docx
Binary file not shown.

0 comments on commit 82e64b3

Please sign in to comment.