The filex Command

The filex command manages chemical structure and reaction file I/O modules. In many cases, actively loading of I/O modules is not required because of the built-in auto-load mechanism. If the toolkit encounters a file of unknown type, an attempt is made to load a suitable module by constructing the name of the module from the file suffix. However, that mechanism fails in case the file does not have a suffix, or a non-standard suffix, or the data source is not a file but some other stream, such as a network connection, a pipe, or a standard I/O channel. In these cases, explicit managing of I/O modules is required.

The filex command has the following subcommands:

filex defined

filex defined format
Filex.Defined(format)

A check to determine whether the specified format is supported by an I/O module. In case the appropriate handler is not yet loaded, an attempt at auto-loading is made. For the equivalent command without auto-loading, see filex exists. The result value is a boolean status code.

filex exists

filex exists format
Filex.Exists(format)

A check to determine whether an I/O module for the specified format is currently loaded. This command variant does not attempt auto-loading. The format name may be either the primary name of a loaded module, or any of alias format name aliases the module recognizes. For the equivalent command with auto-loading, see filex defined . The result value is a boolean status code.

filex get

filex get format attribute
fx.get(attribute)
fx.attribute
fx[attribute]
Filex.Get(format,attribute)

Query the value of an attribute of the I/O module. The list of attributes is detailed in the paragraph on the filex set command.

In case the format argument cannot be resolved by an active module, an attempt to auto-load a suitable module is made.

filex list

filex list ?pattern?
Filex.List(?pattern=?)

List the names of all currently loaded I/O modules. A string match pattern may be used to filter the result list. The variant filex modules is an alias to this command.

filex load

filex load format ?objectfile?
filex load all
Filex.Load(format,?objectfile?,...)
Filex.Load(“all”)

Explicitly load an I/O module. If the module is already loaded, the current version is unloaded first. If no specific object file (a shared library on Unix/Linux, a DLL on Windows, a bundle file for OSX) is specified, the standard name of the module file is automatically constructed from the format name, and then the file searched in the directories in the I/O module path. The module path can be customized in the control variable ::cactvs(filexpath) .

For Tcl , the return value of the command is the slot in the module table the module has been loaded into. This corresponds to the value of the slot attribute which can be queried via filex get . For Python , the return value is a module reference.

The second form of the command scans the currently set I/O module extension search path and loads all accessible modules which are not yet in memory. Modules which are already active in the running application are not unloaded, and only a single instance of each I/O module, even if present under various alias names in the module directories, is loaded. This form of the command does not return a value.

filex modules

filex modules ?pattern?
Filex.Modules(?pattern=?)

This is an alias for filex list .

filex ref

Filex.Ref(format)

Python -only method to get a reference of the module, which allows terser attribute retrieval commands and other operations.

filex set

filex set format ?attribute value?...
filex set format dict
fx.set(?attribute,value?,...)
fx.set(dict)
fx.attribute = value
fx[attribute] = value
Filex.Set(format,?attribute,value?,...)
Filex.Set(format,dict)

Set attributes of the I/O module. Compared to other classes of modules, there are rather few attributes in a module which can be set in a meaningful manner. Some of the listed attributes are read-only. They are included in this section because it is cross-referenced from the filex get command. These are the supported attributes:

In case the format argument cannot be resolved by an active module, an attempt to auto-load a suitable module is made.

filex subcommands

filex subcommands
dir(Filex)

List all supported subcommands of the filex command in an installation.

filex unload

filex unload ?format?...
fx.unload()
Filex.Unload(?format?,...)

Unload zero or more I/O modules. It is an error to specify the name of a module which is not loaded.

Built-in I/O modules cannot be unloaded. If the use of one of these needs to be switched off, it is possible to set the disabled flag of the capabilities module attribute via the filex set command.

The command returns the number of unloaded I/O modules.