Commit be14c6411addc7062dde3150f1f7f007fc285563
1 parent
a060e194
Exists in
master
changes for unittest
Showing
2 changed files
with
18 additions
and
31 deletions
Show diff stats
src/files.py
... | ... | @@ -5,7 +5,6 @@ |
5 | 5 | # Odile Coeur-Joly, Toulouse, France |
6 | 6 | # |
7 | 7 | """ |
8 | - | |
9 | 8 | src.filenames Created on 13 déc. 2017 |
10 | 9 | """ |
11 | 10 | import os |
... | ... | @@ -61,39 +60,28 @@ class PireneaFiles(object): |
61 | 60 | raise ValueError("Not a valid prefix for a PIRENEA setup : (P0, P1 or P2 only)") |
62 | 61 | |
63 | 62 | |
64 | -class PireneaDir(object): | |
65 | - """ | |
66 | - Manage the files generated by PIRENEA : naming, converting | |
67 | - """ | |
68 | - | |
69 | - def __init__(self, folder="", year=2002): | |
70 | - """ | |
71 | - Constructor | |
72 | - """ | |
73 | - self.folder = folder | |
74 | - self.year = int(year) | |
75 | - | |
76 | - | |
77 | 63 | if __name__ == '__main__': |
78 | - | |
79 | - """ test within one directory """ | |
64 | + """ | |
65 | + test within one directory """ | |
80 | 66 | try: |
81 | - root = input("Root directory for Pirenea: ") | |
82 | - p = PireneaFiles(root) | |
67 | + input_folder = input("Root directory for Pirenea: ") | |
68 | + p = PireneaFiles(input_folder) | |
83 | 69 | print("Working directory is: {0}".format(os.path.abspath(p.folder))) |
84 | 70 | |
85 | - c = input("Add or Remove a prefix (A/R): ") | |
86 | - if "A" in c.upper(): | |
87 | - """ Add a prefix """ | |
88 | - prefix = input("Choose a prefix to rename files (P0, P1, P2): ") | |
89 | - print("Your input prefix is: {} ".format(prefix)) | |
90 | - p.add_prefix(prefix) | |
71 | + do_prefix = input("Add or Remove a prefix (A/R): ") | |
72 | + if "A" in do_prefix.upper(): | |
73 | + """ | |
74 | + Add a prefix """ | |
75 | + input_prefix = input("Choose a prefix to rename files (P0, P1, P2): ") | |
76 | + print("Your input prefix is: {} ".format(input_prefix)) | |
77 | + p.add_prefix(input_prefix) | |
91 | 78 | print("... renaming with prefix is DONE !") |
92 | - elif "R" in c.upper(): | |
93 | - """ Remove a prefix """ | |
94 | - prefix = input("Choose a prefix to remove (P0, P1, P2): ") | |
95 | - print("Your input prefix is: {} ".format(prefix)) | |
96 | - p.remove_prefix(prefix) | |
79 | + elif "R" in do_prefix.upper(): | |
80 | + """ | |
81 | + Remove a prefix """ | |
82 | + input_prefix = input("Choose a prefix to remove (P0, P1, P2): ") | |
83 | + print("Your input prefix is: {} ".format(input_prefix)) | |
84 | + p.remove_prefix(input_prefix) | |
97 | 85 | print("... removing the prefix is DONE !") |
98 | 86 | |
99 | 87 | except ValueError as err: |
... | ... |
tests/test_files.py
... | ... | @@ -8,9 +8,7 @@ |
8 | 8 | |
9 | 9 | tests.test_files Created on 18 dec. 2017 |
10 | 10 | """ |
11 | - | |
12 | 11 | import unittest |
13 | - | |
14 | 12 | from src.files import PireneaFiles |
15 | 13 | |
16 | 14 | |
... | ... | @@ -37,5 +35,6 @@ class PireneaFilesTestCase(unittest.TestCase): |
37 | 35 | self.pirenea.__init__(self.folder) |
38 | 36 | self.pirenea.remove_prefix(self.empty) |
39 | 37 | |
38 | + | |
40 | 39 | if __name__ == "__main__": |
41 | 40 | unittest.main() |
... | ... |