### Passage à enumerate

Dark-Storm 4 years ago
parent
commit
e27a26590b
Signed by: Darks
GPG Key ID: F61F10FA138E797C
1 changed files with 6 additions and 8 deletions
1. 14
sprite-optimizer.py

#### 14 sprite-optimizer.py Unescape Escape View File

 `@ -50,11 +50,11 @@ def get_lines(img):` ``` ``` `def removing_doubles(lines):` ` results = []` ` i, n = 0, len(lines)` ` n = len(lines)` ``` ``` ` if progress:` ` print("Remove duplicated lines:", end = "")` ` for l in lines:` ` for i, l in enumerate(lines):` ` s = sorted(l)` ` same = False` ` for o in results:` `@ -63,9 +63,8 @@ def removing_doubles(lines):` ` break` ` if same == False:` ` results.append(l)` ` i += 1` ` if progress:` ` print("\rRemove double lines: {:.0%}".format(i / n), end = "")` ` print("\rRemove double lines: {:.1%}".format(i / n), end = "")` ` if progress:` ` print("\rRemove double lines: complete")` ``` ``` `@ -76,11 +75,11 @@ def removing_doubles(lines):` ``` ``` `def removing_useless(lines):` ` results = []` ` i, n = 0, len(lines)` ` n = len(lines)` ``` ``` ` if progress:` ` print("Remove useless lines:", end = "")` ` for l in lines:` ` for i, l in enumerate(lines):` ` inclusions = 0` ` others = (x for x in lines if x != l)` ` for k in others:` `@ -89,9 +88,8 @@ def removing_useless(lines):` ` break` ` if inclusions == 0 or len(l) == 1:` ` results.append((len(l), l))` ` i += 1` ` if progress:` ` print("\rRemove useless lines: {:.0%}".format(i / n), end = "")` ` print("\rRemove useless lines: {:.1%}".format(i / n), end = "")` ` if progress:` ` print("\rRemove useless lines: complete")` ``` ```