def files_parse(some_list): files = [] for element in pull_local_info(some_list).split(): if path_isfile("{}/{}".format(getcwd(), element)): files.append("{}/{}".format(getcwd(), element)) if path_isfile("{}/{}".format(path_of('~'), element)): files.append("{}/{}".format(path_of('~'), element)) return " ".join(files)
def test_analysis_file_should_exist_when_jenkins_is_true(self): location_tmp_dir = mkdtemp() self.options['location'] = location_tmp_dir self.options['jenkins'] = 'True' # need to activate jenkins. with OutputCapture(): JSHint(self.options).run() file_exist = path_isfile(path_join(location_tmp_dir, 'jshint.xml')) rmtree(location_tmp_dir) self.assertTrue(file_exist)
def _win_dotnetcli_msbuild(): if not is_windows(): return None program_files = os_environ["ProgramW6432"] program_files_x86 = os_environ["ProgramFiles(x86)"] cli1 = path_join(program_files, 'dotnet', 'dotnet.exe') cli2 = path_join(program_files_x86, 'dotnet', 'dotnet.exe') results = [] if path_isfile(cli1): results += parse_dotnetcli_msbuild_ver_output(cli1, ARCH64) if path_isfile(cli2): results += parse_dotnetcli_msbuild_ver_output(cli2, ARCH32) return results
def setUp(self): # noqa super(TestJSHint, self).setUp() self.options.update({ 'jshint-bin': 'bin/jshint', 'jshint-exclude': '', 'jshint-suppress-warnings': 'True', 'jenkins': 'False', 'directory': self.test_dir, }) if path_isfile('../../bin/jshint'): # when cwd is parts/test self.options['jshint-bin'] = '../../bin/jshint' self.given_a_file_in_test_dir('correct.js', CORRECT_FILE)
def test_analysis_file_should_exist_when_jenkins_is_true(self): location_tmp_dir = mkdtemp() full_path = path_join(self.test_dir, 'correct.js') with file(full_path, 'w') as correct_code: correct_code.write(CORRECT_FILE) self.options['directory'] = self.test_dir self.options['location'] = location_tmp_dir self.options['jenkins'] = 'True' # need to activate jenkins. code_analysis_jshint(self.options) file_exist = path_isfile(path_join(location_tmp_dir, 'jshint.xml')) rmtree(location_tmp_dir) self.assertTrue(file_exist)
def test_analysis_file_should_exist_when_jenkins_is_true(self): location_tmp_dir = mkdtemp() correct_code = file(path_join(self.test_dir, 'correct.js'), 'w') correct_code.write( 'var number_ten=10;' 'var word_ten=\'ten\';' 'var sum_2_plus_2 = 2+2;') correct_code.close() self.options['directory'] = self.test_dir self.options['location'] = location_tmp_dir self.options['jenkins'] = 'True' # need to activate jenkins. code_analysis_jshint(self.options) file_exist = path_isfile(path_join(location_tmp_dir, 'jshint.xml')) rmtree(location_tmp_dir) self.assertTrue(file_exist)
def test_analysis_file_should_exist_when_jenkins_is_true(self): location_tmp_dir = mkdtemp() correct_code = file(path_join(self.test_dir, 'correct.css'), 'w') correct_code.write( 'a:link {color:blue}\n' 'h3 {color: red}\n' 'body {color: purple}') correct_code.close() self.options['directory'] = self.test_dir self.options['location'] = location_tmp_dir self.options['jenkins'] = 'True' # need to activate jenkins. code_analysis_csslint(self.options) file_exist = path_isfile(path_join(location_tmp_dir, 'csslint.xml')) rmtree(location_tmp_dir) self.assertTrue(file_exist)
def test_analysis_file_should_exist_when_jenkins_is_true(self): location_tmp_dir = mkdtemp() correct_code = file(path_join(self.test_dir, 'correct.py'), 'w') correct_code.write( 'class MyClass():\n' ' def __init__(self):\n' ' my_sum = 1 + 1\n' ' self.my_sum = my_sum\n') correct_code.close() self.options['directory'] = self.test_dir self.options['location'] = location_tmp_dir self.options['jenkins'] = 'True' # need to activate jenkins. code_analysis_flake8(self.options) file_exist = path_isfile(path_join(location_tmp_dir, 'flake8.log')) rmtree(location_tmp_dir) self.assertTrue(file_exist)
def find_packages(where=None, exclude=()): ret = [] if not where: where = getcwd() excl_set = set(e.strip('*.') for e in exclude) # rough overapproximation! for root, dirs, files in walk(where, followlinks=True): pkg_root = root[len(where):].lstrip(sep) if '.' in pkg_root: # avoid *.egg-info and the like/invalid pkg name dirs[:] = [] continue pkg_root = pkg_root.replace(sep, '.') dirs[:] = [ d for d in dirs if d not in excl_set and '.' not in d and path_isfile(path_join(root, d, '__init__.py')) ] ret.extend('.'.join((pkg_root, d)).lstrip('.') for d in dirs) return ret
def find_packages(where=None, exclude=()): ret = [] if not where: where = getcwd() excl_set = set(e.strip('*.') for e in exclude) # rough overapproximation! for root, dirs, files in walk(where, followlinks=True): pkg_root = root[len(where):].lstrip(sep) if '.' in pkg_root: # avoid *.egg-info and the like/invalid pkg name dirs[:] = [] continue pkg_root = pkg_root.replace(sep, '.') dirs[:] = [d for d in dirs if d not in excl_set and '.' not in d and path_isfile(path_join(root, d, '__init__.py'))] ret.extend('.'.join((pkg_root, d)).lstrip('.') for d in dirs) return ret
def set_psphinxtheme(name): """ Returns *P-SphinxTheme* related basic settings and checks also if ``name`` is a valid `PSphinxTheme` name. This is designed to be used within Sphinx's ``conf.py`` file. .. seealso:: The :ref:`P-SphinxTheme Usage Example <usage_example>`. :param name: (str) a valid *P-SphinxTheme* theme name :return: (tuple) [html_theme_path], html_theme, needs_sphinx """ needs_sphinx = '1.2' html_theme_path = path_join(get_psphinxtheme_root_dir(), 'themes') html_theme = '' if not path_isfile(path_join(html_theme_path, name, 'theme.conf')): raise Err('Utils.set_psphinxtheme()', [ 'name: <{}> seems not to be a valid `PSphinxTheme`: <{}>'.format(name, listdir(html_theme_path)) ] ) else: html_theme = name return [html_theme_path], html_theme, needs_sphinx
def run(self): need_normal_clean = True exclude_files = [ 'benchmark_it.c', 'disassemble_it.c', 'line_memory_profile_it.c', 'profile_it.c', 'speed_it.c', 'utils.c', '_version.c', ] remove_files = [] remove_dirs = [] # remove ONLY: `build/sphinx` if self.onlydocs: need_normal_clean = False dir_path = path_join(ROOT_PACKAGE_PATH, 'build', 'sphinx') if path_exists(dir_path): remove_dirs.append(dir_path) # remove also: DIRS: `build, dist, cover, *.egg-info, *._pyxbld` # and FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html if self.all: need_normal_clean = True for dir_ in {'build', 'dist', 'cover'}: dir_path = path_join(ROOT_PACKAGE_PATH, dir_) if path_exists(dir_path): remove_dirs.append(dir_path) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for dir_ in dirs_w: if '_pyxbld' in dir_ or 'egg-info' in dir_: remove_dirs.append(path_join(root, dir_)) # remove FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in {'.so', '.c'}: remove_files.append(path_join(root, file_)) tmp_name, tmp_ext = path_splitext(file_) if tmp_ext == '.pyx': # Check if we have a html with the same name check_html_path = path_join(root, tmp_name + '.html') if path_isfile(check_html_path): remove_files.append(check_html_path) # remove also: all files defined in exclude_files if self.excludefiles: for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ in exclude_files: remove_files.append(path_join(root, file_)) # do the general clean if need_normal_clean: for file_ in {'.coverage', 'MANIFEST'}: if path_exists(file_): remove_files.append(file_) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in {'.pyc', '.pyo', '.pyd', '.o', '.orig'}: remove_files.append(path_join(root, file_)) for dir_ in dirs_w: if '__pycache__' in dir_: remove_dirs.append(path_join(root, dir_)) # REMOVE ALL SELECTED # noinspection PyBroadException try: for file_ in remove_files: if path_exists(file_): os_remove(file_) for dir_ in remove_dirs: if path_exists(dir_): shutil_rmtree(dir_) except Exception: pass
def run(self): need_normal_clean = True exclude_files = [ 'lconf_classes.c', 'lconf_structure_classes.c', 'main_code.c', 'transform.c', 'utils.c', 'validator.c', '_version.c', ] remove_files = [] remove_dirs = [] # remove ONLY: `build/sphinx` if self.onlydocs: need_normal_clean = False dir_path = path_join(ROOT_PACKAGE_PATH, 'build', 'sphinx') if path_exists(dir_path): remove_dirs.append(dir_path) # remove also: DIRS: `build, dist, cover, *._pyxbld, *.egg-info` # and FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html if self.all: need_normal_clean = True for dir_ in {'build', 'dist', 'cover'}: dir_path = path_join(ROOT_PACKAGE_PATH, dir_) if path_exists(dir_path): remove_dirs.append(dir_path) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for dir_ in dirs_w: if '_pyxbld' in dir_ or 'egg-info' in dir_: remove_dirs.append(path_join(root, dir_)) # remove FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in {'.so', '.c'}: remove_files.append(path_join(root, file_)) tmp_name, tmp_ext = path_splitext(file_) if tmp_ext == '.pyx': # Check if we have a html with the same name check_html_path = path_join( root, tmp_name + '.html') if path_isfile(check_html_path): remove_files.append(check_html_path) # remove also: all files defined in exclude_files if self.excludefiles: for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ in exclude_files: remove_files.append(path_join(root, file_)) # do the general clean if need_normal_clean: for file_ in {'.coverage', 'MANIFEST'}: if path_exists(file_): remove_files.append(file_) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in { '.pyc', '.pyo', '.pyd', '.o', '.orig' }: remove_files.append(path_join(root, file_)) for dir_ in dirs_w: if '__pycache__' in dir_: remove_dirs.append(path_join(root, dir_)) # REMOVE ALL SELECTED # noinspection PyBroadException try: for file_ in remove_files: if path_exists(file_): os_remove(file_) for dir_ in remove_dirs: if path_exists(dir_): shutil_rmtree(dir_) except Exception: pass
def os_path_isfile(path): return path_isfile(path)
def run(self): need_normal_clean = True exclude_files = [ 'lconf_classes.c', 'structure_classes.c', 'main_code.c', 'transform.c', 'utilities.c', 'validator.c', '_version.c', ] remove_files = [] remove_dirs = [] # remove also: DIRS: `build, dist, cover, *._pyxbld, *.egg-info` # and FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html if self.all: need_normal_clean = True for dir_ in {'build', 'dist', 'cover'}: dir_path = path_join(ROOT_PACKAGE_PATH, dir_) if path_exists(dir_path): remove_dirs.append(dir_path) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for dir_ in dirs_w: if '_pyxbld' in dir_ or 'egg-info' in dir_: remove_dirs.append(path_join(root, dir_)) # remove FILES in MAIN_PACKAGE_PATH: `*.so, *.c` and cython annotate html for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in {'.so', '.c'}: remove_files.append(path_join(root, file_)) tmp_name, tmp_ext = path_splitext(file_) if tmp_ext == '.pyx': # Check if we have a html with the same name check_html_path = path_join(root, tmp_name + '.html') if path_isfile(check_html_path): remove_files.append(check_html_path) # remove also: all files defined in exclude_files if self.excludefiles: for root, dirs_w, files_w in os_walk(MAIN_PACKAGE_PATH): for file_ in files_w: if file_ in exclude_files: remove_files.append(path_join(root, file_)) # do the general clean if need_normal_clean: for file_ in {'.coverage', 'MANIFEST'}: if path_exists(file_): remove_files.append(file_) for root, dirs_w, files_w in os_walk(ROOT_PACKAGE_PATH): for file_ in files_w: if file_ not in exclude_files: if path_splitext(file_)[-1] in {'.pyc', '.pyo', '.pyd', '.o', '.orig'}: remove_files.append(path_join(root, file_)) for dir_ in dirs_w: if '__pycache__' in dir_: remove_dirs.append(path_join(root, dir_)) # REMOVE ALL SELECTED try: for file_ in remove_files: if path_exists(file_): os_remove(file_) for dir_ in remove_dirs: if path_exists(dir_): shutil_rmtree(dir_) except Exception: pass
def is_p_sphinx_theme(name): """ :return: (bool) True if name is a valid *P-SphinxTheme* theme name. """ html_theme_path = path_join(get_psphinxtheme_root_dir(), 'Themes') return path_isfile(path_join(html_theme_path, name, 'theme.conf'))