Skip to content
Snippets Groups Projects
Commit 11489eb5 authored by Karl Hoffmann's avatar Karl Hoffmann
Browse files

Initial commit

parent 8763beac
No related branches found
No related tags found
No related merge requests found
utils.py 0 → 100644
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Utility functions
Karl Hoffmann, Max Planck Institute of Molecular Cell Biology and Genetics,
Dresden, Germany
"""
def str_filename(number, *args, **kwargs):
"""
Conversion of a number (or any other object) to a string that is compatible
with file name syntax.
Based on the built-in function str(), but replaces some characters that
have special meaning in filenames:
File extension separator '.' and path separators (both slash and backslash)
are each replaced with underscore '_'
"""
return str(number,*args,**kwargs).translate(str.maketrans({'.' : '_',
'/' : '_',
'\\' : '_' #note the escape to describe a single backslash
}))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment