geopathfinder package


geopathfinder.file_naming module

class geopathfinder.file_naming.SmartFilename(fields, fields_def, ext=None, pad='-', delimiter='_', convert=False)[source]

Bases: object

SmartFilename class handles file names with pre-defined field names and field length.

classmethod from_filename(filename_str, fields_def, pad='-', delimiter='_', convert=False)[source]

Converts a filename given as a string into a SmartFilename class object.

  • filename_str (str) – Filename without any paths (e.g., “M20170725_test.tif”).
  • fields_def (OrderedDict) –
    Name of fields (keys) in right order and length (values). It must contain:
    • ”len”: int
      Length of filename part (must be given).
    • ”start”: int, optional
      Start index of filename part (default is 0).
    • ”delim”: str, optional
      Delimiter between this and the following filename part (default is the one from the parent class).
    • ”pad”: str,
      Padding for filename part (default is the one from the parent class).
  • pad (str, optional) – Padding symbol (default: ‘-‘).
  • delimiter (str, optional) – Delimiter (default: ‘_’)
  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Class representing a filename.

Return type:


class geopathfinder.file_naming.SmartFilenamePart(arg, start=0, length=None, delimiter='_', pad='-', decoder=None, encoder=None)[source]

Bases: object

Represents a part of filename.


Converts filename part to a decoded (object) representation.

Returns:Decoded (object) representation of a filename part.
Return type:object

Converts filename part to an encoded (string) representation.

Returns:Encoded (string) representation of a filename part.
Return type:str

Checks if a SmartFilenamePart instance is valid. It is valid if the specified length is equal to the length of the SmartFilenamePart.

Returns:True if SmartFilenamePart instance is valid, else False.
Return type:bool

geopathfinder.folder_naming module

Module contents