scippneutron.io.cif.Block#
- class scippneutron.io.cif.Block(name, content=None, *, comment='', schema=None)[source]#
A CIF data block.
A block contains an ordered sequence of loops and chunks (groups of key-value-pairs). The contents are written to file in the order specified in the block.
- __init__(name, content=None, *, comment='', schema=None)[source]#
Create a new CIF data block.
- Parameters:
name (
str
) – Name of the block. Can contain any non-whitespace characters. Can be at most 75 characters long.content (
Optional
[Iterable
[Mapping
[str
,Any
] |Loop
|Chunk
]], default:None
) – Initial loops and chunks.dicts
are converted toscippneutron.io.cif.Chunk
.comment (
str
, default:''
) – Optional comment that can be written above the block in the file.schema (
Union
[CIFSchema
,Iterable
[CIFSchema
],None
], default:None
) – CIF schemas used for the block. Content is not checked against the schema, but the schema is written to the file.
Methods
__init__
(name[, content, comment, schema])Create a new CIF data block.
add
(content, /[, comment])Add a chunk or loop to the end of the block.
copy
()Return a shallow copy of the block.
write
(f)Write this block to a file.
Attributes
comment
Optional comment that can be written above the object in the file.
Name of the block.
CIF schemas used for the block.
- write(f)[source]#
Write this block to a file.
Used mainly internally, use
scippneutron.io.cif.save_cif()
instead.- Parameters:
f (
TextIOBase
) – File handle.- Return type: