Best Python code snippet using prospector_python
finder.py
Source:finder.py
...30 yield os.path.abspath(filepath) if abspath else filepath31 def iter_package_paths(self, abspath=True, include_ignored=False):32 for filepath in self.files:33 yield os.path.abspath(filepath) if abspath else filepath34 def iter_directory_paths(self, abspath=True, include_ignored=False):35 for filepath in self.files:36 filepath = os.path.dirname(filepath)37 yield os.path.abspath(filepath) if abspath else filepath38 def iter_module_paths(self, abspath=True, include_ignored=False):39 for filepath in self.files:40 yield os.path.abspath(filepath) if abspath else filepath41 def to_absolute_path(self, path):42 return os.path.abspath(os.path.join(self.rootpath, path))43 def get_minimal_syspath(self, absolute_paths=True):44 paths = list(set(map(os.path.dirname, self.files)))45 if absolute_paths:46 paths = list(map(os.path.abspath, paths))47 return [self.rootpath] + paths48class FoundFiles(object):49 def __init__(self, rootpath, files, modules, packages, directories, ignores):50 self.rootpath = rootpath51 self._files = files52 self._modules = modules53 self._packages = packages54 self._directories = directories55 self._ignores = ignores56 def _check(self, filepath, pathlist, abspath=True, even_if_ignored=False):57 path = os.path.relpath(filepath, self.rootpath) if abspath else filepath58 for checkpath, ignored in pathlist:59 if path == checkpath:60 if ignored and not even_if_ignored:61 break62 return True63 return False64 def check_module(self, filepath, abspath=True, even_if_ignored=False):65 return self._check(filepath, self._modules, abspath, even_if_ignored)66 def check_package(self, filepath, abspath=True, even_if_ignored=False):67 return self._check(filepath, self._packages, abspath, even_if_ignored)68 def check_file(self, filepath, abspath=True, even_if_ignored=False):69 return self._check(filepath, self._files, abspath, even_if_ignored)70 def _iter_paths(self, pathlist, abspath=True, include_ignored=False):71 for path, ignored in pathlist:72 if ignored and not include_ignored:73 continue74 if abspath:75 path = self.to_absolute_path(path)76 yield path77 def iter_file_paths(self, abspath=True, include_ignored=False):78 return self._iter_paths(self._files, abspath, include_ignored)79 def iter_package_paths(self, abspath=True, include_ignored=False):80 return self._iter_paths(self._packages, abspath, include_ignored)81 def iter_directory_paths(self, abspath=True, include_ignored=False):82 return self._iter_paths(self._directories, abspath, include_ignored)83 def iter_module_paths(self, abspath=True, include_ignored=False):84 return self._iter_paths(self._modules, abspath, include_ignored)85 def to_absolute_path(self, path):86 return os.path.abspath(os.path.join(self.rootpath, path))87 def get_minimal_syspath(self, absolute_paths=True):88 """89 Provide a list of directories that, when added to sys.path, would enable90 any of the discovered python modules to be found91 """92 # firstly, gather a list of the minimum path to each package93 package_list = set()94 packages = [p[0] for p in self._packages if not p[1]]95 for package in sorted(packages, key=len):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!