Skip to content

Commit

Permalink
Give an example for generating ASCII outputs
Browse files Browse the repository at this point in the history
Show how to use standard Python functionality to
generate output that is ASCII or ISO-8859-1 rather
than UTF-8. Closes #131.
  • Loading branch information
benmwebb committed Dec 14, 2023
1 parent d211c1f commit 4fb3cf6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ihm/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,15 @@ def write(fh, systems, format='mmCIF', dumpers=[], variant=IHMVariant):
with open('output.bcif', 'wb') as fh:
ihm.dumper.write(fh, systems, format='BCIF')
If generating files for a tool that is sensitive to non-ASCII data,
a more restrictive encoding such as ASCII or ISO-8859-1 could also
be used (although note that this may lose some information such as
accented characters)::
with open('output.cif', 'w', encoding='ascii',
errors='replace') as fh:
ihm.dumper.write(fh, systems)
:param file fh: The file handle to write to.
:param list systems: The list of :class:`ihm.System` objects to write.
:param str format: The format of the file. This can be 'mmCIF' (the
Expand Down

0 comments on commit 4fb3cf6

Please sign in to comment.