diff --git a/src/files.py b/src/files.py index 5c39ce1..a78d394 100644 --- a/src/files.py +++ b/src/files.py @@ -5,7 +5,6 @@ # Odile Coeur-Joly, Toulouse, France # """ - src.filenames Created on 13 déc. 2017 """ import os @@ -61,39 +60,28 @@ class PireneaFiles(object): raise ValueError("Not a valid prefix for a PIRENEA setup : (P0, P1 or P2 only)") -class PireneaDir(object): - """ - Manage the files generated by PIRENEA : naming, converting - """ - - def __init__(self, folder="", year=2002): - """ - Constructor - """ - self.folder = folder - self.year = int(year) - - if __name__ == '__main__': - - """ test within one directory """ + """ + test within one directory """ try: - root = input("Root directory for Pirenea: ") - p = PireneaFiles(root) + input_folder = input("Root directory for Pirenea: ") + p = PireneaFiles(input_folder) print("Working directory is: {0}".format(os.path.abspath(p.folder))) - c = input("Add or Remove a prefix (A/R): ") - if "A" in c.upper(): - """ Add a prefix """ - prefix = input("Choose a prefix to rename files (P0, P1, P2): ") - print("Your input prefix is: {} ".format(prefix)) - p.add_prefix(prefix) + do_prefix = input("Add or Remove a prefix (A/R): ") + if "A" in do_prefix.upper(): + """ + Add a prefix """ + input_prefix = input("Choose a prefix to rename files (P0, P1, P2): ") + print("Your input prefix is: {} ".format(input_prefix)) + p.add_prefix(input_prefix) print("... renaming with prefix is DONE !") - elif "R" in c.upper(): - """ Remove a prefix """ - prefix = input("Choose a prefix to remove (P0, P1, P2): ") - print("Your input prefix is: {} ".format(prefix)) - p.remove_prefix(prefix) + elif "R" in do_prefix.upper(): + """ + Remove a prefix """ + input_prefix = input("Choose a prefix to remove (P0, P1, P2): ") + print("Your input prefix is: {} ".format(input_prefix)) + p.remove_prefix(input_prefix) print("... removing the prefix is DONE !") except ValueError as err: diff --git a/tests/test_files.py b/tests/test_files.py index ae16d11..1ef65eb 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -8,9 +8,7 @@ tests.test_files Created on 18 dec. 2017 """ - import unittest - from src.files import PireneaFiles @@ -37,5 +35,6 @@ class PireneaFilesTestCase(unittest.TestCase): self.pirenea.__init__(self.folder) self.pirenea.remove_prefix(self.empty) + if __name__ == "__main__": unittest.main() -- libgit2 0.21.2