How to use deep_update_dict method in lisa

Best Python code snippet using lisa_python

collection.py

Source:collection.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

init.py

Source:init.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

log.py

Source:log.py Github

copy

Full Screen

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)...

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