Пример #1
0
def convname(newd):
    newd=retiraacentos(newd)
    newd=newd.replace('Documents and Settings','D_S')
    newd=newd.replace('Configuracoes locais','C_L')
    newd=newd.replace('Dados de aplicativos','D_A')
    newd=newd.replace('Local Settings','L_S')
    newd=newd.replace('Application Data','A_D')
    found=re.search('{[^}]+}',newd)
    if found:
        foundstring=found.group()
        if len(foundstring)>5:
            newd=newd.replace(foundstring,foundstring[0:5])
    return newd
Пример #2
0
def renameinplace(path):
    with open(path) as f:
        msg=rfc822.Message(f)
    dirname,basename=os.path.split(path)
    basename='%s_%s.eml'%(stritem(msg,'date'),stritem(msg,'subject').split('\n')[0])
    basename=retirabarra(retiraacentos(basename))[:255]
    newf=choosefilename(os.path.join(dirname,basename))
    assert(newf and not os.path.exists(newf))
    try:
        os.rename(path,newf)
    except OSError as e:
        print path
        print newf
        raise e
    return newf