Best Python code snippet using prospector_python
__init__.py
Source: __init__.py
...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 defaults154 to_run = set(DEFAULT_TOOLS)155 # we can also use any that the profiles dictate156 for tool in tools.TOOLS.keys():157 if profile.is_tool_enabled(tool):158 to_run.add(tool)159 else:160 to_run = set(config.tools)161 # profiles have no say in the list of tools run when162 # a command line is specified163 for tool in config.with_tools:164 to_run.add(tool)...
Check out the latest blogs from LambdaTest on this topic:
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Recently, I was going through some of the design patterns in Java by reading the book Head First Design Patterns by Eric Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra.
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!!