biogeme.tools.files module

class biogeme.tools.files.TemporaryFile[source]

Bases: object

Class generating a temporary file, so that the user does not bother about its location, or even its name

Example:

with TemporaryFile() as filename:
    with open(filename, 'w') as f:
        print('stuff', file=f)
biogeme.tools.files.create_backup(filename, rename=True)[source]

If the file exist, we create a backup copy.

Parameters:
  • filename (str) – name of the file

  • rename (bool) – if True, the file is renamed. If False, a copy is made.

Return type:

str

biogeme.tools.files.is_valid_filename(filename)[source]

Verifies is a string is a valid filename

Return type:

tuple[bool, str]

Parameters:

filename (str)