def test_is_patch_file(self): """Test for is_patch_file() function.""" testdir = os.path.dirname(os.path.abspath(__file__)) self.assertFalse( ft.is_patch_file( os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))) self.assertTrue( ft.is_patch_file( os.path.join(testdir, 'sandbox', 'sources', 'toy', 'toy-0.0_typo.patch')))
def categorize_files_by_type(paths): """ Splits list of filepaths into a 4 separate lists: easyconfigs, files to delete, patch files and files with extension .py """ res = { 'easyconfigs': [], 'files_to_delete': [], 'patch_files': [], 'py_files': [], } for path in paths: if path.startswith(':'): res['files_to_delete'].append(path[1:]) elif path.endswith('.py'): res['py_files'].append(path) # file must exist in order to check whether it's a patch file elif os.path.isfile(path) and is_patch_file(path): res['patch_files'].append(path) else: # anything else is considered to be an easyconfig file res['easyconfigs'].append(path) return res
def categorize_files_by_type(paths): """ Splits list of filepaths into a 4 separate lists: easyconfigs, files to delete, patch files and files with extension .py """ res = { 'easyconfigs': [], 'files_to_delete': [], 'patch_files': [], 'py_files': [], } for path in paths: if path.startswith(':'): res['files_to_delete'].append(path[1:]) elif path.endswith('.py'): res['py_files'].append(path) # file must exist in order to check whether it's a patch file elif os.path.isfile(path) and is_patch_file(path): res['patch_files'].append(path) elif path.endswith('.patch'): if not os.path.exists(path): raise EasyBuildError('File %s does not exist, did you mistype the path?', path) elif not os.path.isfile(path): raise EasyBuildError('File %s is expected to be a regular file, but is a folder instead', path) else: raise EasyBuildError('%s is not detected as a valid patch file. Please verify its contents!', path) else: # anything else is considered to be an easyconfig file res['easyconfigs'].append(path) return res
def categorize_files_by_type(paths): """ Splits list of filepaths into a 3 separate lists: easyconfigs, files to delete and patch files """ res = { 'easyconfigs': [], 'files_to_delete': [], 'patch_files': [], } for path in paths: if path.startswith(':'): res['files_to_delete'].append(path[1:]) # file must exist in order to check whether it's a patch file elif os.path.isfile(path) and is_patch_file(path): res['patch_files'].append(path) else: # anything else is considered to be an easyconfig file res['easyconfigs'].append(path) return res
def test_is_patch_file(self): """Test for is_patch_file() function.""" testdir = os.path.dirname(os.path.abspath(__file__)) self.assertFalse(ft.is_patch_file(os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))) self.assertTrue(ft.is_patch_file(os.path.join(testdir, 'sandbox', 'sources', 'toy', 'toy-0.0_typo.patch')))