

def _format_file_name(self, format, activity):
    name_pattern = re.compile('#NAME', re.IGNORECASE)
    type_pattern = re.compile('#TYPE', re.IGNORECASE)
    name = activity.StartTime.strftime(format)
    name = name_pattern.sub((self._clean_activity_name(activity.Name) if (activity.Name and (len(activity.Name) > 0) and (activity.Name.lower() != activity.Type.lower())) else ''), name)
    name = type_pattern.sub(activity.Type, name)
    name = re.sub('([\\W_])\\1+', '\\1', name)
    name = re.sub('^([\\W_])|([\\W_])$', '', name)
    return name

dataset/ETHPy150Open cpfair/tapiriik/tapiriik/services/Dropbox/dropbox.py DropboxService._format_file_name/original