def name_ascii(name,ext=''): spechars = '"',"'",'-','#','&','|',' ','.',',','!',':',';','%','£','$','*','(',')','[',']','{','}','=','+','^','§','°','`','@','?','/', '\xc2\xa0' for sp in spechars: name = name.replace(sp,'_') name = unac.unac_string(name) name = re.sub(r'([_])\1+', r'\1', name) # remove repeting name = re.sub(r'^([_])+', '', name) # remove starting if name[-1]=='_': name = name[:-1] return (name+ext).lower()
def name_ascii(name, ext=""): spechars = ( '"', "'", "-", "#", "&", "|", " ", ".", ",", "!", ":", ";", "%", "£", "$", "*", "(", ")", "[", "]", "{", "}", "=", "+", "^", "§", "°", "`", "@", "?", "/", "\xc2\xa0", ) for sp in spechars: name = name.replace(sp, "_") name = unac.unac_string(name) name = re.sub(r"([_])\1+", r"\1", name) # remove repeting name = re.sub(r"^([_])+", "", name) # remove starting if name[-1] == "_": name = name[:-1] return (name + ext).lower()
def remove_accents(s): #return unicodedata.normalize('NFKD',u).encode('ascii','ignore') return unac.unac_string(s)