14.1.21. crate_anon.anonymise.researcher_report
crate_anon/anonymise/researcher_report.py
Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CRATE.
CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.
Produce a researcher-oriented report about a destination database.
- class crate_anon.anonymise.researcher_report.ResearcherReportConfig(output_filename: str, anonconfig: crate_anon.anonymise.config.Config = None, base_font_size: str = '11pt', db_name: str = None, db_url: str = None, debug_pdf: bool = False, max_distinct_values: int = 20, max_value_length: int = 50, header_footer_spacing_mm: int = 3, margin_left_right: str = '15mm', margin_top_bottom: str = '18mm', page_size: str = 'A4', orientation: str = 'landscape', show_counts: bool = True, show_url: bool = True, show_values: bool = True, skip_values_if_too_many: bool = False, use_dd: bool = True, echo: bool = False)[source]
- __init__(output_filename: str, anonconfig: Config | None = None, base_font_size: str = '11pt', db_name: str | None = None, db_url: str | None = None, debug_pdf: bool = False, max_distinct_values: int = 20, max_value_length: int = 50, header_footer_spacing_mm: int = 3, margin_left_right: str = '15mm', margin_top_bottom: str = '18mm', page_size: str = 'A4', orientation: str = 'landscape', show_counts: bool = True, show_url: bool = True, show_values: bool = True, skip_values_if_too_many: bool = False, use_dd: bool = True, echo: bool = False) None
- get_annotation_when_no_ddr_found(col_name: str) str [source]
Returns best-guess CRATE annotation information when no data dictionary row is available.
- Parameters:
col_name – Column name.
- class crate_anon.anonymise.researcher_report.Templates[source]
Template filenames, within TEMPLATE_DIR.
- crate_anon.anonymise.researcher_report.get_values_summary(column: Column, reportcfg: ResearcherReportConfig, ddr: DataDictionaryRow | None = None) str [source]
Return a textual summary of values in a column (from a de-identified database).
- Parameters:
column – SQLAlchemy Column object to summarize. (It knows its own Table.)
reportcfg – ResearcherReportConfig object, governing the report.
ddr – Corresponding CRATE DataDictionaryRow, if there is one.
- crate_anon.anonymise.researcher_report.literal(value: Any, max_length: int = 50, truncated_suffix: str = '…') str [source]
Returns a rough-and-ready SQL literal, intended for human viewing only. Truncates long strings at a given length.
Some duplication from within cardinal_pythonlib.sqlalchemy.dump.get_literal_query.
Dates/times are NOT enclosed in quotes here.
- crate_anon.anonymise.researcher_report.mk_comment(reportcfg: ResearcherReportConfig, column: Column, ddr: DataDictionaryRow | None = None) str [source]
Return a comment. For databases that don’t support comments, we’ll want the CRATE DD one (unless that’s been disabled). For databases that do, we don’t want duplication.
- crate_anon.anonymise.researcher_report.mk_researcher_report_html(reportcfg: ResearcherReportConfig) Tuple[str, str, str] [source]
Produces a researcher-oriented report about a destination database, as HTML.
- Parameters:
reportcfg – ResearcherReportConfig object, governing the report.
- Returns:
header_html, html, footer_html
- Return type:
tuple
- crate_anon.anonymise.researcher_report.mk_researcher_report_pdf(reportcfg: ResearcherReportConfig) bool [source]
Produces a researcher-oriented report about a destination database, as a PDF.
- Parameters:
reportcfg – ResearcherReportConfig object, governing the report.
- Returns:
success
- crate_anon.anonymise.researcher_report.mk_table_html(table_name: str, reportcfg: ResearcherReportConfig) str [source]
Returns HTML for the per-table aspects of the report.
- Parameters:
table_name – Table to process.
reportcfg – ResearcherReportConfig object, governing the report.
- Returns:
HTML as a string.