How to use _resolve_refpath method in localstack

Best Python code snippet using localstack_python

helpers.py

Source:helpers.py Github

copy

Full Screen

...112 refpath = "/".join((self.current_path, refpath))113 self._refpaths.append(refpath)114 yield115 self._refpaths.pop()116 def _resolve_refpath(self, refpath: str) -> dict:117 if refpath in self._refpaths and not self.allow_recursive:118 raise Exception("recursion detected with allow_recursive=False")119 if refpath in self._cache:120 return self._cache.get(refpath)121 with self._pathctx(refpath):122 if self._is_internal_ref(self.current_path):123 cur = self.document124 else:125 raise NotImplementedError("External references not yet supported.")126 for step in self.current_path.split("/")[1:]:127 cur = cur.get(step)128 self._cache[self.current_path] = cur129 return cur130 def _namespaced_resolution(self, namespace: str, data: Union[dict, list]) -> Union[dict, list]:131 with self._pathctx(namespace):132 return self._resolve_references(data)133 def _resolve_references(self, data) -> Union[dict, list]:134 if self._is_ref(data):135 return self._resolve_refpath(data["$ref"])136 if isinstance(data, dict):137 for k, v in data.items():138 data[k] = self._namespaced_resolution(k, v)139 elif isinstance(data, list):140 for i, v in enumerate(data):141 data[i] = self._namespaced_resolution(str(i), v)142 return data143 def resolve_references(self) -> dict:144 return self._resolve_references(self.document)145def resolve_references(data: dict, allow_recursive=True) -> dict:146 resolver = Resolver(data, allow_recursive=allow_recursive)147 return resolver.resolve_references()148def make_json_response(message):149 return requests_response(json.dumps(message), headers={"Content-Type": APPLICATION_JSON})...

Full Screen

Full Screen

s.py

Source:s.py Github

copy

Full Screen

...46class EnumClass(Reference):47 def __init__(self, name, path, values):48 super().__init__(name, path)49 self.values = values50def _resolve_refpath(namespace, path):51 if "." in path:52 path = path.split(".")53 return path[-1], ".".join(path[:-1])54 return path, namespace.name55def create_types(namespace, name, desc):56 if namespace is None:57 namespace = Namespace(desc["namespace"], dict())58 for k, v in desc["types"].items():59 create_types(namespace, k, v)60 return namespace61 struct = copy.deepcopy(desc)62 if "enum" in struct:63 res = EnumClass(name, namespace.name, struct["enum"])64 namespace.types[res.name] = res65 return res66 if "structure" in struct:67 struct = struct["structure"]68 if type(struct) is str:69 if struct not in Primitive.map:70 return Reference(*_resolve_refpath(namespace, struct))71 res = Primitive(struct)72 if type(struct) is dict:73 fields = dict()74 for k, v in struct.items():75 if k[-1] == "?":76 k = k[:-1]77 v = Optional(create_types(namespace, name + _camel_case(k), v))78 else:79 v = create_types(namespace, name + _camel_case(k), v)80 fields[k] = v81 res = Object(name, namespace.name, fields)82 if type(struct) is list:83 assert len(struct) == 1, str(struct)84 res = Array(...

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