X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=bde%2Fcredits_duplicates.py;h=3669e8e51b336b3e4450e5f1c147b996cbc5904b;hb=f214da146daf305df5babdf646de5215ab76dcca;hp=ccda353b7f12943381c164237bedc56737dd82da;hpb=df22b413788ec4fe9655c0208b1d8bbe9120dbab;p=scripts-20-100.git diff --git a/bde/credits_duplicates.py b/bde/credits_duplicates.py index ccda353..3669e8e 100755 --- a/bde/credits_duplicates.py +++ b/bde/credits_duplicates.py @@ -107,6 +107,7 @@ def sort_by_blocks(data): l.sort() result = [", ".join([str(i) for i in l]) for l in result] result = list(set(result)) + result.sort(key=lambda x : int(x.split(",")[0])) return result def get_transactions(cur, ids): @@ -124,6 +125,7 @@ def interactive(blocks, cur, args): ou d'afficher une liste de toutes celles à dévalider. """ ids_to_devalidate = [] + total = 0 for b in blocks: lb = [int(i) for i in b.split(",")] l = get_transactions(cur, b) @@ -131,7 +133,7 @@ def interactive(blocks, cur, args): if not args.noless: p = subprocess.Popen(["less"], stdin=subprocess.PIPE) p.communicate(formatted.encode("utf-8")) - print formatted + print formatted.encode("utf-8") print "IDs : %s" % b idkeep = lb[0] question = "Ne garder que %s (= dévalider les autres) ? [o/N/s]" % idkeep @@ -145,8 +147,11 @@ def interactive(blocks, cur, args): elif ans.lower() in ["s"]: lb.remove(idkeep) ids_to_devalidate.extend(lb) + total += l[0]["montant"] * (len(l) - 1) if ids_to_devalidate: - print "\nIDs de transactions à dévalider :\n" + ",".join([str(i) for i in ids_to_devalidate]) + print "\nIDs de transactions à dévalider (%s) :" % len(ids_to_devalidate) + print ",".join([str(i) for i in ids_to_devalidate]) + print "Montant total : %s" % (total,) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Liste les crédits semblables trop proches dans le temps et propose de les dévalider tous sauf 1.")