From bdb1938a029d77564f1a87b7cbee824693cbf039 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Tue, 10 Sep 2019 22:49:24 -0300 Subject: [PATCH] Cleaning code. --- ecolyzer/system/file.py | 18 +----------------- scripts/added_source_files.py | 25 ------------------------- scripts/added_source_files_todb.py | 26 -------------------------- tests/unit/file_test.py | 10 ++++++++++ 4 files changed, 11 insertions(+), 68 deletions(-) delete mode 100644 scripts/added_source_files.py delete mode 100644 scripts/added_source_files_todb.py diff --git a/ecolyzer/system/file.py b/ecolyzer/system/file.py index 1c30d2b..d153450 100644 --- a/ecolyzer/system/file.py +++ b/ecolyzer/system/file.py @@ -55,22 +55,7 @@ def fullpath(self, fullpath): if fullpath == None: return self._fullpath = None - path, file_with_ext = os.path.split(fullpath) - filename = '' - ext = '' - if '.' in file_with_ext: - split_list = file_with_ext.split('.') - if len(split_list) > 2: - ext = split_list.pop() - filename = '.'.join(split_list) - else: - if file_with_ext.startswith('.'): - filename = '.' + split_list[1] - else: - filename = split_list[0] - ext = split_list[1] - else: - filename = file_with_ext + path, filename, ext = File.Split(fullpath) self.path = path self.name = filename self.ext = ext @@ -99,7 +84,6 @@ def Extension(fullpath): else: if not file_with_ext.startswith('.'): ext = split_list[1] - return ext @staticmethod diff --git a/scripts/added_source_files.py b/scripts/added_source_files.py deleted file mode 100644 index 4302f2e..0000000 --- a/scripts/added_source_files.py +++ /dev/null @@ -1,25 +0,0 @@ -from ecolyzer import GitAnalyzer - -tags = [ - # None, - # '1.4.0', - # '1.5.0', - # '1.6.0', - # '2.0-BETA-1', - # '2.0-BETA-2', - # '2.0-BETA-3', - # '2.0-BETA-4', - # '2.0-BETA-5', - # '2.0-RC-1', - # '2.0-RC-2', - # '2.0-RC-3', - # '2.0-RC-4', - '2.0-RC-5', - '2.0-RC-6', - '2.0-RC-7' -] - -analyzer = GitAnalyzer('repo/terrame') -analyzer.set_tags(tags) -analyzer.extract_added_source_files() -analyzer.show_csv() \ No newline at end of file diff --git a/scripts/added_source_files_todb.py b/scripts/added_source_files_todb.py deleted file mode 100644 index 38ace20..0000000 --- a/scripts/added_source_files_todb.py +++ /dev/null @@ -1,26 +0,0 @@ -from ecolyzer import GitAnalyzer, Postgres - -tags = [ - # None, - # '1.4.0', - # '1.5.0', - # '1.6.0', - # '2.0-BETA-1', - # '2.0-BETA-2', - # '2.0-BETA-3', - # '2.0-BETA-4', - # '2.0-BETA-5', - # '2.0-RC-1', - # '2.0-RC-2', - # '2.0-RC-3', - # '2.0-RC-4', - '2.0-RC-5', - '2.0-RC-6', - '2.0-RC-7' -] - -analyzer = GitAnalyzer('repo/terrame') -analyzer.set_tags(tags) -analyzer.extract_added_source_files_todb(True) -analyzer.load_db(analyzer.repo_name) -analyzer.show_csv() diff --git a/tests/unit/file_test.py b/tests/unit/file_test.py index 2bbe7cb..1ac516e 100644 --- a/tests/unit/file_test.py +++ b/tests/unit/file_test.py @@ -64,3 +64,13 @@ def test_without_ext(): file2 = File('noextfile') assert file2.fullpath == 'noextfile' + +def test_extension(): + assert File.Extension('some/path/file.ext') == 'ext' + assert File.Extension('file') == '' + +def test_split(): + path, name, ext = File.Split('some/path/file.ext') + assert path == 'some/path' + assert name == 'file' + assert ext == 'ext'