wailord.io.xyz module

An xyz parser

This module implements a grammar for parsing xyz files.

Example

See the tests for more

$ poetry run

Some more details.

Todo

  • Make tests

  • Return interesting things

  • You have to also use sphinx.ext.todo extension

wailord.io.xyz.grammar_xyz = {'aline': <Sequence aline = atype ws cline>, 'atype': <OneOf atype = ~"[a-zA-Z]"u / ~"[0-9]"u>, 'cline': <Sequence cline = float ws float ws float>, 'coord_block': <OneOrMore coord_block = (aline ws)+>, 'float': <Sequence float = pm number "." number>, 'meta': <Sequence meta = number ws coord_block ws?>, 'natoms': <Regex number = ~"\d+"u>, 'number': <Regex number = ~"\d+"u>, 'pm': <Regex pm = ~"[+-]?"u>, 'ws': <Regex ws = ~"\s*"u>}

The xyz grammar.

Recall that by default the format specification for an xyz` The docstring may span multiple lines. The type may optionally be specified on the first line, separated by a colon.

Type

grammar_xyz

class wailord.io.xyz.xyzIO(filename)[source]

Bases: object

This class handles xyz files at a user level

property comment_line
read()[source]
write(outname)[source]
class wailord.io.xyz.xyzVisitor[source]

Bases: parsimonious.nodes.NodeVisitor

This class extends NodeVisitor

generic_visit(node, visited_children)[source]

Default visitor method

Parameters
  • node – The node we’re visiting

  • visited_children – The results of visiting the children of that node, in a list

I’m not sure there’s an implementation of this that makes sense across all (or even most) use cases, so we leave it to subclasses to implement for now.

visit_atype(node, visited_children)[source]

Makes a dict of the section (as key) and the key/value pairs.

visit_cline(node, visited_children)[source]

Makes a dict of the section (as key) and the key/value pairs.

visit_coord_block(node, visited_children)[source]

Makes a dict of the section (as key) and the key/value pairs.

visit_meta(node, visited_children)[source]

Returns the overall output.

visit_natoms(node, visited_children)[source]

Makes a dict of the section (as key) and the key/value pairs.