httk.httkio.cif module¶
- httk.httkio.cif.maketrans_()¶
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
- httk.httkio.cif.read_cif(ioa, pragmatic=True, use_types=False)[source]¶
Generic cif reader, given a filename / ioadapter it places all data in a python dictionary.
It returns a tuple: (header, list) Where list are pairs of data blocks names and data blocks
Each data block is a dictionary with tag_name:value
For loops, value is another dictionary with format column_name:value
The optional parameter pragmatic regulates handling of some counter-intuitive aspects of the cif specification, where the default pragmatic=True handles these features the way people usually use them, whereas pragmatic=False means to read the cif file precisely according to the spec. For example, in a multiline text field:
; some text ;
Means the string ‘nsome text’. For this specific case pragmatic=True removes the leading newline.
set use_types to True to convert things that look like floats and integers to those respective types
- httk.httkio.cif.write_cif(ioa, data, header=None, max_line_length=80, use_types=False)[source]¶
Generic cif writer, given a filename / ioadapter
data = the cif data to write as an (ordered) dictionary of tag_name:value
header = the header (comment) segment
max_line_length = the maximum number of characters allowed on each line. This should not be set < 80 (there is no point, and the length calculating algorithm breaks down at some small line length)
use_types =
if True: always quote values that are of string type. Numeric values are put in the file unquoted (as they should) if False (default): also strings that look like cif numbers are put in the file unquoted
For loops, value is another dictionary with format column_name:value
The optional parameter pragmatic regulates handling of some counter-intuitive aspects of the cif specification, where the default pragmatic=True handles these features the way people usually use them, whereas pragmatic=False means to read the cif file precisely according to the spec. For example, in a multiline text field:
; some text ;
Means the string ‘nsome text’. For this specific case pragmatic=True removes the leading newline.
set use_types to True to convert things that look like floats and integers to those respective types