Commits

Ilja Heckmann committed 690d787

added routine for generation of derivative filenames

Comments (0)

Files changed (1)

     def __exit__(self, *args):
         self.close()
 
+def replace_ext(filename, newext):
+    """Remove extension form 'filename', if any, and append 'newext'."""
+    dotpos = filename.rfind('.')
+    if dotpos != -1:
+        filename = filename[:dotpos]
+    return filename + newext
+
 def memoize(f):
     """Take a function as parameter, memoize its results.