How to use _find_paths method in prospector

Best Python code snippet using prospector_python

spec_loader.py

Source:spec_loader.py Github

copy

Full Screen

...8_CONF = get_config()9def get_schema_names():10 """Return a dict of vertex and edge base names."""11 names = [] # type: list12 for path in _find_paths(_CONF['spec_paths']['schemas'], '*.yaml'):13 names.append(_get_file_name(path))14 return names15def get_stored_query_names():16 """Return an array of all stored queries base names."""17 names = [] # type: list18 for path in _find_paths(_CONF['spec_paths']['stored_queries'], '*.yaml'):19 names.append(_get_file_name(path))20 return names21def get_schema(name):22 """Get YAML content for a specific schema. Throws an error if nonexistent."""23 try:24 path = _find_paths(_CONF['spec_paths']['schemas'], name + '.yaml')[0]25 except IndexError:26 raise SchemaNonexistent(name)27 with open(path) as fd:28 return yaml.safe_load(fd)29def get_schema_for_doc(doc_id):30 """Get the schema for a particular document by its full ID."""31 (coll_name, _) = doc_id.split('/')32 ret = get_schema(coll_name)33 return ret34def get_stored_query(name):35 """Get AQL content for a specific stored query. Throws an error if nonexistent."""36 try:37 path = _find_paths(_CONF['spec_paths']['stored_queries'], name + '.yaml')[0]38 except IndexError:39 raise StoredQueryNonexistent(name)40 with open(path) as fd:41 return yaml.safe_load(fd)42def _find_paths(dir_path, file_pattern):43 """44 Return all file paths from a filename pattern, starting from a parent45 directory and looking in all subdirectories.46 """47 pattern = os.path.join(dir_path, '**', file_pattern)48 return glob.glob(pattern, recursive=True)49def _get_file_name(path):50 """51 Get the file base name without extension from a file path.52 """53 return os.path.splitext(os.path.basename(path))[0]54class StoredQueryNonexistent(Exception):55 """Requested stored query is not in the spec."""56 def __init__(self, name):...

Full Screen

Full Screen

joltage.py

Source:joltage.py Github

copy

Full Screen

1from pprint import pprint2def combine_adapters(adapters):3 return _find_paths(adapters, {}, -1)4def _find_paths(adapters, cache, ndx):5 if ndx == len(adapters) - 1:6 return 17 if ndx == -1:8 curr_adapt = 09 else:10 curr_adapt = adapters[ndx]11 if curr_adapt in cache:12 return cache[curr_adapt]13 paths_num = _find_paths(adapters, cache, ndx + 1)14 if (ndx + 1 < len(adapters) and ndx + 2 < len(adapters) and15 adapters[ndx + 1] - curr_adapt in [1, 2] and16 adapters[ndx + 2] - curr_adapt < 4):17 paths_num += _find_paths(adapters, cache, ndx + 2)18 if (ndx + 2 < len(adapters) and ndx + 3 < len(adapters) and19 adapters[ndx + 2] - curr_adapt in [1, 2] and20 adapters[ndx + 3] - curr_adapt < 4):21 22 paths_num += _find_paths(adapters, cache, ndx + 3)23 cache[curr_adapt] = paths_num24 return paths_num25def chain_adapters(adapters):26 jolt_start = 027 jolt_diffs = {1: 0, 2: 0, 3: 1}28 for adapter in adapters:29 jolt_diffs[adapter - jolt_start] += 130 jolt_start = adapter31 return jolt_diffs[1], jolt_diffs[3]32with open("adapters.txt", "r", encoding="utf-8") as input_file:33 adapters = list(map(int, input_file.readlines()))34adapters = sorted(adapters)...

Full Screen

Full Screen

binary_tree_path.py

Source:binary_tree_path.py Github

copy

Full Screen

...6# self.right = right7class Solution:8 def binaryTreePaths(self, root: Optional[TreeNode]) -> List[str]:9 res = []10 self._find_paths(root, [], res)11 return res12 13 def _find_paths(self, node, path, res):14 path.append(str(node.val))15 if node.left is None and node.right is None:16 res.append("->".join(path))17 path.pop()18 return 19 20 if node.left is not None:21 self._find_paths(node.left, path, res)22 if node.right is not None:23 self._find_paths(node.right, path, res)24 path.pop()...

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