How to use _find_used_libraries method in prospector

Best Python code snippet using prospector_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...20 self.paths = self._get_work_path(self.config, self.arguments)21 self.explicit_file_mode = all(map(os.path.isfile, self.paths))22 self.workdir = os.getcwd()23 self.profile, self.strictness = self._get_profile(self.workdir, self.config)24 self.libraries = self._find_used_libraries(self.config, self.profile)25 self.tools_to_run = self._determine_tool_runners(self.config, self.profile)26 self.ignores = self._determine_ignores(self.config, self.profile, self.libraries)27 self.configured_by = {}28 self.messages = []29 def get_tools(self, found_files):30 self.configured_by = {}31 runners = []32 for tool_name in self.tools_to_run:33 tool = tools.TOOLS[tool_name]()34 config_result = tool.configure(self, found_files)35 if config_result is None:36 configured_by = None37 messages = []38 else:39 configured_by, messages = config_result40 if messages is None:41 messages = []42 self.configured_by[tool_name] = configured_by43 self.messages += messages44 runners.append(tool)45 return runners46 def get_output_report(self):47 # Get the output formatter48 if self.config.output_format is not None:49 output_report = self.config.output_format50 else:51 output_report = [(self.profile.output_format, self.profile.output_target)]52 for index, report in enumerate(output_report):53 if not all(report):54 output_report[index] = (report[0] or "grouped", report[1] or [])55 return output_report56 def _configure_prospector(self):57 # first we will configure prospector as a whole58 mgr = cfg.build_manager()59 config = mgr.retrieve(*cfg.build_default_sources())60 return config, mgr.arguments61 def _get_work_path(self, config, arguments):62 # Figure out what paths we're prospecting63 if config["path"]:64 paths = [self.config["path"]]65 elif arguments["checkpath"]:66 paths = arguments["checkpath"]67 else:68 paths = [os.getcwd()]69 return paths70 def _get_profile(self, path, config):71 # Use the specified profiles72 profile_provided = False73 if len(config.profiles) > 0:74 profile_provided = True75 cmdline_implicit = []76 # if there is a '.prospector.ya?ml' or a '.prospector/prospector.ya?ml' or equivalent landscape config77 # file then we'll include that78 profile_name = None79 if not profile_provided:80 for possible_profile in AUTO_LOADED_PROFILES:81 prospector_yaml = os.path.join(path, possible_profile)82 if os.path.exists(prospector_yaml) and os.path.isfile(prospector_yaml):83 profile_provided = True84 profile_name = possible_profile85 break86 strictness = None87 if profile_provided:88 if profile_name is None:89 profile_name = config.profiles[0]90 extra_profiles = config.profiles[1:]91 else:92 extra_profiles = config.profiles93 strictness = "from profile"94 else:95 # Use the preconfigured prospector profiles96 profile_name = "default"97 extra_profiles = []98 if config.doc_warnings is not None and config.doc_warnings:99 cmdline_implicit.append("doc_warnings")100 if config.test_warnings is not None and config.test_warnings:101 cmdline_implicit.append("test_warnings")102 if config.no_style_warnings is not None and config.no_style_warnings:103 cmdline_implicit.append("no_pep8")104 if config.full_pep8 is not None and config.full_pep8:105 cmdline_implicit.append("full_pep8")106 if config.member_warnings is not None and config.member_warnings:107 cmdline_implicit.append("member_warnings")108 # Use the strictness profile only if no profile has been given109 if config.strictness is not None and config.strictness:110 cmdline_implicit.append("strictness_%s" % config.strictness)111 strictness = config.strictness112 # the profile path is113 # * anything provided as an argument114 # * a directory called .prospector in the check path115 # * the check path116 # * prospector provided profiles117 profile_path = config.profile_path118 prospector_dir = os.path.join(path, ".prospector")119 if os.path.exists(prospector_dir) and os.path.isdir(prospector_dir):120 profile_path.append(prospector_dir)121 profile_path.append(path)122 profile_path.append(BUILTIN_PROFILE_PATH)123 try:124 forced_inherits = cmdline_implicit + extra_profiles125 profile = ProspectorProfile.load(profile_name, profile_path, forced_inherits=forced_inherits)126 except CannotParseProfile as cpe:127 sys.stderr.write(128 "Failed to run:\nCould not parse profile %s as it is not valid YAML\n%s\n"129 % (cpe.filepath, cpe.get_parse_message())130 )131 sys.exit(1)132 except ProfileNotFound as nfe:133 sys.stderr.write(134 "Failed to run:\nCould not find profile %s. Search path: %s\n" % (nfe.name, ":".join(nfe.profile_path))135 )136 sys.exit(1)137 else:138 return profile, strictness139 def _find_used_libraries(self, config, profile):140 libraries = []141 # Bring in adaptors that we automatically detect are needed142 if config.autodetect and profile.autodetect is True:143 for found_dep in autodetect_libraries(self.workdir):144 libraries.append(found_dep)145 # Bring in adaptors for the specified libraries146 for name in set(config.uses + profile.uses):147 if name not in libraries:148 libraries.append(name)149 return libraries150 def _determine_tool_runners(self, config, profile):151 if config.tools is None:152 # we had no command line settings for an explicit list of153 # tools, so we use the defaults...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run prospector automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful