FileName¶
-
class
ndmapper.data.FileName(path=None, sep='_', strip=False, prefix=None, suffix=None, dirname=None, regex=None)[source] [edit on github]¶ Bases:
objectA class used by
DataFileand, potentially, user scripts for parsing filenames into components, modifying and reconstructing them. As a mutable class, it may also be used to keep that information synchronized between interested parties.Parameters: path : str or FileName, optional
Single filename to parse into a FileName object representation (defaults to an empty string).
sep : str or None, optional
Separator for suffix components (defaults to “_”).
strip : bool, optional
Remove any existing prefix and suffixes from the supplied path (prior to adding any specified prefix & suffix)?
prefix : str or None, optional
Prefix string to add before the base filename.
suffix : str or None, optional
Suffix string to add after the base filename (including any initial separator).
dirname : str or None, optional
Directory name to add to the path (replacing any existing directory).
regex : str or re or None
Regular expression matching base filename (without a file extension). By default this is None, causing the value of the package configuration variable “ndmapper.config[‘filename_regex’]” to be used, which defaults to Gemini’s “S20150101S0001”-style convention (thus allowing use of other conventions without having to override the regex every time a DataFile is instantiated, as well as optionally allowing the default to be pre-compiled).
Attributes
dir (str) Directory that the file resides in. prefix (str) Sequence of characters preceding the base name. base (str) Base filename in a standard format that can be recognized via the regex parameter, eg. S20150307S0001 for Gemini data. This is the original filename without the file extension, before any processing prefix/suffix are added. Not to be confused (due to lack of a clear alternative term) with the Unix “basename”, which would be equivalent to root + ext, where root = prefix + base + suffix. suffix (list) List of one or more suffixes following the base name, including any separator character (eg. _forStack). ext (str) File extension(s), eg. “fits” or “fits.gz”. sep (str or None) One or more characters specified as a suffix separator. orig (str) The original filename with no prefix, suffix or directory, equivalent to base+ext(read only). This is not one of the parsed components and exists for convenience in look-ups, list comprehensions etc.dotext (str) The file extension as a string, beginning with the separator (‘.’), unless blank. This read-only attribute is provided for convenience; the corresponding parsed filename component is ext(which excludes the separator and may be None, when there is no extension).root (str) The root filename (prefix + base + suffix). This read-only attribute is provided for convenience in list comprehensions etc. (eg. to help determine IRAF database names) and is not one of the parsed components. Attributes Summary
dotextorigrerootAttributes Documentation
-
dotext¶
-
orig¶
-
re¶
-
root¶
-