bout_runners.make.read_makefile

Module containing the classes to read the makefile.

Classes

BoutMakefileReader(path)

Class which reads a BOUT++ Makefile.

BoutMakefileVariableReader(path, variable_name)

Class which reads a variable from a BOUT++ Makefile.

Exceptions

MakefileReaderError(variable, path)

Error class indicating that this is a ReadMakefile error.

class bout_runners.make.read_makefile.BoutMakefileReader(path: pathlib.Path)[source]

Class which reads a BOUT++ Makefile.

Attributes
pathPath

The path to the Makefile

contentstr

The content of the Makefile as a string

Methods

read()

Read the makefile.

Read the content of a Makefile and store it into self.content.

Parameters
pathPath or str

Path to the Makefile

Attributes
value

Get the value of the variable.

Methods

read()

Read the makefile.

read() → str[source]

Read the makefile.

Returns
str

Content of the Makefile

property value

Get the value of the variable.

class bout_runners.make.read_makefile.BoutMakefileVariableReader(path: pathlib.Path, variable_name: str)[source]

Class which reads a variable from a BOUT++ Makefile.

Examples

Makefile (remember to use TABS instead of SPACES in the Makefile)

>>> BOUT_SUPER = /super/path/to/BOUT-dev
... BOUT_TOP   = $(BOUT_SUPER)/BOUT-dev
...
... SOURCEC    = bout_model.cxx
...
... include $(BOUT_TOP)/make.config

Script

>>> BoutMakefileVariableReader('SOURCEC', 'Makefile').value
'bout_model.cxx'
Attributes
variable_namestr

Name of the variable belonging to the instance

valuestr

Get the value of the variable.

Methods

get_variable_value()

Get the value of the variable

Set the variable name of the instance.

Parameters
pathPath or str

The path to the Makefile

variable_namestr

The variable under consideration

Attributes
value

Get the value of the variable.

Methods

read()

Read the makefile.

read() → str

Read the makefile.

Returns
str

Content of the Makefile

property value

Get the value of the variable.

Returns
valuestr

The last match of the variable

Raises
MakefileReaderError

If self.variable is not found

Examples

Makefile

>>> # foo=bar
... foo = baz
... foo   = foobar.qux # foo = quux.quuz

Script

>>> BoutMakefileVariableReader('foo', 'Makefile').value
'foobar.qux'
exception bout_runners.make.read_makefile.MakefileReaderError(variable: str, path: pathlib.Path)[source]

Error class indicating that this is a ReadMakefile error.

Construct a string and call the super constructor.

Parameters
variablestr

Variable to searched for

pathPath or str

Path searched at

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.