How to use _read_overrides method in autotest

Best Python code snippet using autotest_python

monitors_util.py

Source:monitors_util.py Github

copy

Full Screen

...64def _assert_is_all_blank_lines(lines, source_file):65 if sum(len(line.strip()) for line in lines) > 0:66 raise ValueError('warning patterns are not separated by blank lines '67 'in %s' % source_file)68def _read_overrides(overrides_file):69 """70 Read pattern overrides from overrides_file, which may be None. Overrides71 files are expected to have the format:72 <old regex> <newline> <new regex> <newline> <newline>73 old regex = a regex from the patterns file74 new regex = the regex to replace it75 Lines beginning with # are ignored.76 Returns a dict mapping old regexes to their replacements.77 """78 if not overrides_file:79 return {}80 overrides_lines = [line for line in overrides_file.readlines()81 if not line.startswith('#')]82 overrides_pairs = zip(overrides_lines[0::3], overrides_lines[1::3])83 _assert_is_all_blank_lines(overrides_lines[2::3], overrides_file)84 return dict(overrides_pairs)85def build_alert_hooks(patterns_file, warnfile, overrides_file=None):86 """Parse data in patterns file and transform into alert_hook list.87 Args:88 patterns_file: file; File to read alert pattern definitions from.89 warnfile: file; File to configure alert function to write warning to.90 Returns:91 list; Regex to alert function mapping.92 [(regex, alert_function), ...]93 """94 pattern_lines = patterns_file.readlines()95 # expected pattern format:96 # <msgtype> <newline> <regex> <newline> <alert> <newline> <newline>97 # msgtype = a string categorizing the type of the message - used for98 # enabling/disabling specific categories of warnings99 # regex = a python regular expression100 # alert = a string describing the alert message101 # if the regex matches the line, this displayed warning will102 # be the result of (alert % match.groups())103 patterns = zip(pattern_lines[0::4], pattern_lines[1::4],104 pattern_lines[2::4])105 _assert_is_all_blank_lines(pattern_lines[3::4], patterns_file)106 overrides_map = _read_overrides(overrides_file)107 hooks = []108 for msgtype, regex, alert in patterns:109 regex = overrides_map.get(regex, regex)110 regex = re.compile(regex.rstrip('\n'))111 alert_function = make_alert(warnfile, msgtype.rstrip('\n'),112 alert.rstrip('\n'))113 hooks.append((regex, alert_function))114 return hooks115def build_alert_hooks_from_path(patterns_path, warnfile):116 """117 Same as build_alert_hooks, but accepts a path to a patterns file and118 automatically finds the corresponding site overrides file if one exists.119 """120 dirname, basename = os.path.split(patterns_path)...

Full Screen

Full Screen

extra_pkgs.py

Source:extra_pkgs.py Github

copy

Full Screen

...3 def __init__(self, extra_pkgs_file):4 self.extra_pkgs_file = extra_pkgs_file5 with open(self.extra_pkgs_file, "r") as f:6 extra_info = json.load(f)7 self.overrides = self._read_overrides(extra_info)8 self.hiddens = set(extra_info.get("hiddens", []))9 def _read_overrides(self, extra_info) -> dict:10 if "overrides" in extra_info:11 overrides = extra_info["overrides"]12 return {pkg["name"]: pkg for pkg in overrides}13 else:14 return {}15 def override_pkg_infos(self, pkg_infos: list) -> list:16 for pkg_info in pkg_infos:17 if pkg_info["name"] in self.overrides:18 # mark pkg_info as overridden19 self.overrides[pkg_info["name"]]["_overridden"] = True20 override_pkg = self.overrides[pkg_info["name"]]21 # get all properties from override_pkg22 attrs = set(override_pkg.keys()).union(23 {"version", "license", "homepage", "description"}...

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 autotest 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