diff options
author | Brett Smith <brettcsmith@brettcsmith.org> | 2012-03-26 13:40:35 -0400 |
---|---|---|
committer | Brett Smith <brettcsmith@brettcsmith.org> | 2012-03-26 13:40:35 -0400 |
commit | 28f364bd6d488955952aebe86033e5ba148da2fb (patch) | |
tree | 9ce9739012ffec3a357684a50d5aeb5d7ffe0f0e /mediagoblin/processing.py | |
parent | 84725abd6439b6be42cccc074b8f2b63536fa30e (diff) | |
download | mediagoblin-28f364bd6d488955952aebe86033e5ba148da2fb.tar.lz mediagoblin-28f364bd6d488955952aebe86033e5ba148da2fb.tar.xz mediagoblin-28f364bd6d488955952aebe86033e5ba148da2fb.zip |
Rename to FilenameBuilder, with a main method named fill.
I think these names better convey what's actually going on. I updated the
documentation a bit while I was at it.
Diffstat (limited to 'mediagoblin/processing.py')
-rw-r--r-- | mediagoblin/processing.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/mediagoblin/processing.py b/mediagoblin/processing.py index fa9192d9..718351d5 100644 --- a/mediagoblin/processing.py +++ b/mediagoblin/processing.py @@ -43,28 +43,30 @@ def create_pub_filepath(entry, filename): # Media processing initial steps ################################ -class FilenameMunger(object): +class FilenameBuilder(object): """Easily slice and dice filenames. - Initialize this class with an original filename, then use the munge() + Initialize this class with an original file path, then use the fill() method to create new filenames based on the original. """ MAX_FILENAME_LENGTH = 255 # VFAT's maximum filename length def __init__(self, path): - """Initialize a munger with one original filename.""" + """Initialize a builder from an original file path.""" self.dirpath, self.basename = os.path.split(path) self.basename, self.ext = os.path.splitext(self.basename) self.ext = self.ext.lower() - def munge(self, fmtstr): - """Return a new filename based on the initialized original. + def fill(self, fmtstr): + """Build a new filename based on the original. - The fmtstr argumentcan include {basename} and {ext}, which will - fill in components of the original filename. The extension will - always be lowercased. The filename will also be trunacted to this - class' MAX_FILENAME_LENGTH characters. + The fmtstr argument can include the following: + {basename} -- the original basename, with the extension removed + {ext} -- the original extension, always lowercase + + If necessary, {basename} will be truncated so the filename does not + exceed this class' MAX_FILENAME_LENGTH in length. """ basename_len = (self.MAX_FILENAME_LENGTH - |