Best Python code snippet using lisa_python
collection.py
Source: collection.py
...35 del yamldoc['action']36 except KeyError:37 pass38 if action == "global":39 deep_update_dict(globalyaml, yamldoc)40 elif action == "reset":41 globalyaml = dict()42 elif action == "repeat":43 if prevrule is None:44 raise SigmaCollectionParseError("action 'repeat' is only applicable after first valid Sigma rule")45 newrule = prevrule.copy()46 deep_update_dict(newrule, yamldoc)47 if rulefilter is None or rulefilter is not None and not rulefilter.match(newrule):48 self.parsers.append(SigmaParser(newrule, config))49 prevrule = newrule50 else:51 deep_update_dict(yamldoc, globalyaml)52 if rulefilter is None or rulefilter is not None and rulefilter.match(yamldoc):53 self.parsers.append(SigmaParser(yamldoc, config))54 prevrule = yamldoc55 self.config = config56 def generate(self, backend):57 """Calls backend for all parsed rules"""58 return filter(59 lambda x: bool(x), # filter None's and empty strings60 [ backend.generate(parser) for parser in self.parsers ]61 )62 def __iter__(self):63 return iter([parser.parsedyaml for parser in self.parsers])64def deep_update_dict(dest, src):65 for key, value in src.items():66 if isinstance(value, dict) and key in dest and isinstance(dest[key], dict): # source is dict, destination key already exists and is dict: merge67 deep_update_dict(dest[key], value)68 else:...
init.py
Source: init.py
...13 raise Exception(f"config didn't exist,path:[{str(path)}]")14 with open(str(path), 'r') as f:15 file_type = judge_file_type(str(path))16 if file_type == "json":17 deep_update_dict(config, json.load(f))18 elif file_type == "yaml":19 deep_update_dict(config, yaml.load(f, yaml.FullLoader))20 return config21def judge_file_type(path: str) -> str:22 # exts = [".json", ".yaml", ".yml"]23 prev_ext = path.split(".")[-1]24 if prev_ext == "yaml" or prev_ext == "yml":25 return "yaml"26 elif prev_ext == "json":27 return "json"28 else:29 raise Exception(f"Didn't support this kind of config file:{path}")30def deep_update_dict(d1: Dict, d2: Dict):31 for k, v in d2.items():32 if k in d1:33 if isinstance(v, dict):34 deep_update_dict(d1[k], d2[k])35 elif isinstance(v, list):36 # TODO MERGE37 d1[k] = v38 else:39 d1[k] = v40 else:...
log.py
Source: log.py
1import typing2from pathlib import Path3def deep_update_dict(d: dict, f: typing.Callable[[typing.Any, typing.Any], typing.Any]) -> None:4 for k, v in d.items():5 if isinstance(v, dict):6 deep_update_dict(v, f)7 elif isinstance(v, list):8 for item in v:9 if isinstance(v, dict):10 deep_update_dict(item, f)11 else:12 d[k] = f(k, v)13def logging_config_update(config: dict, log_path: typing.Union[str, Path]) -> dict:14 log_path = Path(log_path)15 deep_update_dict(config, lambda k, v: log_path / Path(v) if k == 'filename' else v)...
Check out the latest blogs from LambdaTest on this topic:
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?
When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.
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!!