core.dfraw module¶
Modification of Dwarf Fortress raw files.
- class core.dfraw.DFRaw(path)[source]¶
Bases:
DFRawNode
Represents a Dwarf Fortress raw file.
- get_value(field)[source]¶
Gets the value of the first tag named <field>. Returns None if no such field exists.
- get_values(*fields)[source]¶
Returns the values of <fields> in a list. The nesting and order of the resulting list will match the nesting and order of <fields>. Equivalent to calling get_value for each field.
- class core.dfraw.DFRawComment(parent, text)[source]¶
Bases:
DFRawNode
Represents a comment (non-tag) in a raw file.
- class core.dfraw.DFRawNode(parent, node_id, value, node_type, **kwargs)[source]¶
Bases:
object
Class representing a node in a raw file.
- add_child(child, **kwargs)[source]¶
Adds <child> to the list of child nodes and sets its parent to this node. If <child> already has another parent, it is first removed from that parent. Has no effect if <child> is a root node.
- Params:
- child
The child node to add.
- Keyword Arguments:
after – If None, the node is inserted as the first child. Otherwise, it is inserted after the child node provided in this argument. If omitted, or if the provided child node does not exist, the child is added as the last child.
- property elements¶
Generator producing a flat view of this node and its subnodes. Yields raw nodes.
- property filename¶
Returns the filename for this raw file.
- find_first(field)[source]¶
Returns the first child node with the tag name field, or None if no such node exists.
- property fulltext¶
Returns the text for this node and all its children.
- property is_comment¶
Returns True if this is a comment node.
- property is_container¶
Returns True if this node represents a container (has children).
- property is_flag¶
Returns True if this node represents a flag (has no values).
- property is_root¶
Returns True if this is the root node for a raw file.
- property is_tag¶
Returns True if this node represents a tag.
- property parent¶
Returns the parent for this node, or itself if this is the root.
- property root¶
Returns the root node.
- property text¶
Returns the text for this node.
- property value¶
Returns the unparsed value for this node.
- property values¶
Returns a list of values associated with this node.
- class core.dfraw.DFRawTag(parent, tag, value)[source]¶
Bases:
DFRawNode
Represents a tag in a raw file.