v_sim.FileFormat

g GObject.Object GObject.Object v_sim.FileFormat v_sim.FileFormat GObject.Object->v_sim.FileFormat

Subclasses:

v_sim.DataLoader, v_sim.Dump, v_sim.ScalarFieldMethod

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (descr, patterns)

class

newRestricted (descr, patterns)

addOption (opt)

addPatterns (patterns)

addPropertyBoolean (name, label, defaultVal)

addPropertyDouble (name, label, defaultVal)

addPropertyInt (name, label, defaultVal)

canMatch ()

copy ()

getFilePatterns ()

getLabel ()

getName ()

getPropertyBoolean (name)

getPropertyInt (name)

iterNextProperty (iter)

match (filename)

setPropertiesFromCLI ()

setValidator (validate)

validate (filename)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

ignore-type

bool

r/w

Don’t restrict file matching to the given patterns.

label

str

r

Label used to show the file pattern.

name

str

r/w/co

File format description.

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

priv

v_sim.FileFormatPrivate

r

Class Details

class v_sim.FileFormat(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

v_sim.FileFormatClass

An opaque structure.

classmethod new(descr, patterns)
Parameters:
  • descr (str) – a short string to label a new file format.

  • patterns ([str]) – a set of patterns to identify files of this format.

Returns:

a newly allocated v_sim.FileFormat, or None if something goes wrong.

Return type:

v_sim.FileFormat

Allocate a new v_sim.FileFormat. The patterns argument is copied in the v_sim.FileFormat object and can be freed safely after the call to this method.

classmethod newRestricted(descr, patterns)
Parameters:
  • descr (str) – a short string to label a new file format.

  • patterns (str) – a set of patterns to identify files of this format.

Returns:

a newly allocated v_sim.FileFormat, or None if something goes wrong.

Return type:

v_sim.FileFormat

Allocate a new v_sim.FileFormat. The patterns argument is copied in the v_sim.FileFormat object and can be freed safely after the call to this method. The patterns list is not all the patterns supported by the format.

addOption(opt)
Parameters:

opt (v_sim.Option) – a v_sim.Option object.

File format may have options, like pseudo-potential pparameters in case of BigDFT calculations.

New in version 3.7.

addPatterns(patterns)
Parameters:

patterns ([str]) – a list of matching patterns.

A file format may have pattern for the naming scheme of files, like “*.jpg” and “*.jpeg” for JPEG files. It’s not mandatory for a file format to match its own pattern anyway.

New in version 3.7.

addPropertyBoolean(name, label, defaultVal)
Parameters:
  • name (str) – a name ;

  • label (str) – a description ;

  • defaultVal (bool) – a default value.

Returns:

a newly created v_sim.Option, free with v_sim.Option.free().

Return type:

v_sim.Option

Add a new boolean property to the file format self.

addPropertyDouble(name, label, defaultVal)
Parameters:
  • name (str) – a name ;

  • label (str) – a description ;

  • defaultVal (float) – a default value.

Returns:

a newly created v_sim.Option, free with v_sim.Option.free().

Return type:

v_sim.Option

Add a new integer property to the file format self.

New in version 3.7.

addPropertyInt(name, label, defaultVal)
Parameters:
  • name (str) – a name ;

  • label (str) – a description ;

  • defaultVal (int) – a default value.

Returns:

a newly created v_sim.Option, free with v_sim.Option.free().

Return type:

v_sim.Option

Add a new integer property to the file format self.

canMatch()
Returns:

True if a call to v_sim.FileFormat.match() is safe.

Return type:

bool

This method is used to know if the file pattern list can be used to match a given filename with v_sim.FileFormat.match().

New in version 3.6.

copy()
Returns:

a newly created v_sim.FileFormat. Should be freed with GObject.Object.unref().

Return type:

v_sim.FileFormat

Copy the given file format self a create a new one.

New in version 3.6.

getFilePatterns()
Returns:

a list with the file patterns. This list should not be freed.

Return type:

[str]

This method gives a list with the file patterns.

New in version 3.6.

getLabel()
Returns:

a string made by the name and all the paterns of the given format, given in parentethis. This string should not be freed.

Return type:

str

This method gives a label describing the file format.

getName()
Returns:

a string with the name. This string should not be freed.

Return type:

str

This method gives the name describing the file format.

getPropertyBoolean(name)
Parameters:

name (str) – a property name.

Returns:

the property value if exists, False otherwise.

Return type:

bool

Retrieves the value of property prop.

New in version 3.8.

getPropertyInt(name)
Parameters:

name (str) – a property name.

Returns:

the property value if exists, -1 otherwise.

Return type:

int

Retrieves the value of property prop.

New in version 3.8.

iterNextProperty(iter)
Parameters:

iter (v_sim.FileFormatIter) – an iterator.

Returns:

True if any.

Return type:

bool

Run to the next property of the file format self. The iterator attributes are updated so it’s convenient to access the property values and details, see v_sim.FileFormatIter.

New in version 3.6.

match(filename)
Parameters:

filename (str) – a string to match.

Returns:

the matching pattern, if any.

Return type:

str

This method try to match the given string to one of the patterns of the v_sim.FileFormat self.

setPropertiesFromCLI()

Scan all options from command line and affects values.

New in version 3.8.

setValidator(validate)
Parameters:

validate (v_sim.FileFormatValidate or None) – a pointer to a validator routine.

Set up a validating routine that do a minimal parsing to check that a provided file corresponds to this file format.

New in version 3.7.

validate(filename)
Parameters:

filename (str) – a string to match.

Returns:

True, if the file (after minimal parsing) is of this file format. If there is no validator routine, it is using a built-in one, based on pattern matching with file types, see v_sim.FileFormat.addPatterns().

Return type:

bool

This method runs a minimal parsing routine set with v_sim.FileFormat.setValidator() to check if the provided filename correspond to this file format.

New in version 3.7.

Property Details

v_sim.FileFormat.props.ignore_type
Name:

ignore-type

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Don’t restrict file matching to the given patterns.

v_sim.FileFormat.props.label
Name:

label

Type:

str

Default Value:

''

Flags:

READABLE

Label used to show the file pattern.

v_sim.FileFormat.props.name
Name:

name

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

File format description.