Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html report #84

Merged
merged 16 commits into from
Mar 4, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,4 @@ olex2
x64
test-data/1000007-multi-multitable.docx
test-data/report_1000007-multi-finalcif.docx
test.html
12 changes: 8 additions & 4 deletions finalcif/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from finalcif.gui.plaintextedit import MyQPlainTextEdit
from finalcif.gui.text_value_editor import MyTextTemplateEdit, TextEditItem
from finalcif.gui.vrf_classes import MyVRFContainer, VREF
from finalcif.report.templated_report import ReportFormat
from finalcif.template.templates import ReportTemplates
from finalcif.tools.download import MyDownloader
from finalcif.tools.dsrmath import my_isnumeric
Expand Down Expand Up @@ -1125,10 +1126,13 @@ def make_report_tables(self) -> None:
make_multi_tables(cif=self.cif, output_filename=str(multi_table_document))
else:
print('Report with templates')
t = TemplatedReport()
ok = t.make_templated_report(options=self.options, cif=self.cif,
output_filename=str(report_filename), picfile=picfile,
template_path=Path(self.get_checked_templates_list_text()))
t = TemplatedReport(format=ReportFormat.RICHTEXT, options=self.options, cif=self.cif)
ok = t.make_templated_docx_report(options=self.options,
output_filename=str(report_filename),
picfile=picfile,
template_path=Path(self.get_checked_templates_list_text()))
#t = TemplatedReport(format=ReportFormat.HTML, options=self.options, cif=self.cif)
#t.make_templated_html_report(options=self.options, picfile=picfile)
if not ok:
return None
except FileNotFoundError as e:
Expand Down
26 changes: 26 additions & 0 deletions finalcif/report/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ def richtext(self) -> RichText:
return r

@property
def html(self) -> str:
txt = ''
if self.authors:
txt += f'{self.authors}, '
if self.journal:
txt += f'<i>{self.journal}</i>'
if not self.journal.endswith('.'):
txt += ', '
else:
txt += ' '
if self.year:
txt += f'<b>{self.year}</b>'
txt += ', '
if self.volume:
txt += f'<i>{self.volume}</i>'
txt += ', '
if self.pages:
txt += f'{self.pages}'
if self.doi:
txt += ', '
if self.doi:
txt += f'{self.doi}'
if any([self.journal, self.pages, self.year, self.volume, self.doi]):
txt += '.'
return txt
@property
def short_ref(self) -> RichText:
"""
Adds a reference with (name year) instead of a number.
Expand Down
2 changes: 1 addition & 1 deletion finalcif/report/report_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SHELXLReference, SHELXTReference, SHELXSReference, FinalCifReference, ShelXleReference, Olex2Reference, \
SHELXDReference, SadabsTwinabsReference, CrysalisProReference, Nosphera2Reference, XDSReference, DSRReference2015, \
DSRReference2018, XRedReference
from finalcif.tools.misc import protected_space, angstrom, zero_width_space, remove_line_endings, flatten
from finalcif.tools.misc import protected_space, angstrom, zero_width_space, remove_line_endings, flatten, minus_sign


def math_to_word(eq: str) -> BaseOxmlElement:
Expand Down
Loading