File format plugins#
A file format plugin is declared with a [[tool.avogadro.file-formats]]
entry in the plugin’s pyproject.toml (or avogadro.toml).
[[tool.avogadro.file-formats]]
identifier = "cp2k"
format-name = "CP2K"
file-extensions = ["out", "log", "cp2k"]
description = "Read CP2K main output files"
support.read = true
support.write = false
output-format = "cjson"
input-mode = "file"
bond = true
patterns = ["CP2K| version string"]
Key |
Type |
Meaning |
|---|---|---|
|
string |
Unique identifier for the format (required) |
|
string |
User-friendly name (required) |
|
string |
Description and help text for users |
|
array of strings |
Extensions the format reads and/or writes |
|
array of strings |
MIME types for the format |
|
boolean |
Which operations the plugin implements |
|
string |
Format the plugin produces when reading (e.g. |
|
string |
Format the plugin receives when writing |
|
string |
|
|
boolean |
Ask Avogadro to perceive bonds after reading |
|
array of strings, or a string |
Text that identifies the format by content (see below) |
Identifying a format by content: patterns#
Programs such as Gaussian, ORCA, CP2K or Psi4 all write their output to
generic files like output.out or job.log, so the file extension alone
cannot say which reader to use. Avogadro’s generic output reader looks inside
the file instead. A plugin can take part by listing patterns:
Each pattern is a literal substring, not a regular expression. Matching is case-sensitive and is done one line at a time.
A file matches the plugin if any one pattern occurs in any one line.
patternsmay be an array of strings, or a single string (treated as a list of one). Empty or whitespace-only entries are ignored.Choose text the program always prints near the top of its output, such as a version banner, and that other programs are unlikely to print.
Patterns are only consulted for the generic output extensions handled by
Avogadro’s generic output reader: out, output and log. They do not
change how other extensions are routed, and a plugin should still list the
extensions it supports in file-extensions.
The file is scanned from the top, line by line. Avogadro’s built-in readers (NWChem, GAMESS-US, Molden, ORCA and xtb) are checked first on each line, then the plugins’ patterns. The earliest matching line in the file wins; if several plugins match the same line, the one registered first is used. If no pattern matches, Avogadro falls back to the cclib plugin and then Open Babel, as before.
Older versions of Avogadro ignore the patterns key, so it is safe to include
it in a plugin that must also work with them.