How to use _iter_paths method in Slash

Best Python code snippet using slash

finder.py

Source:finder.py Github

copy

Full Screen

...66 def check_package(self, filepath, abspath=True, even_if_ignored=False):67 return self._check(filepath, self._packages, abspath, even_if_ignored)68 def check_file(self, filepath, abspath=True, even_if_ignored=False):69 return self._check(filepath, self._files, abspath, even_if_ignored)70 def _iter_paths(self, pathlist, abspath=True, include_ignored=False):71 for path, ignored in pathlist:72 if ignored and not include_ignored:73 continue74 if abspath:75 path = self.to_absolute_path(path)76 yield path77 def iter_file_paths(self, abspath=True, include_ignored=False):78 return self._iter_paths(self._files, abspath, include_ignored)79 def iter_package_paths(self, abspath=True, include_ignored=False):80 return self._iter_paths(self._packages, abspath, include_ignored)81 def iter_directory_paths(self, abspath=True, include_ignored=False):82 return self._iter_paths(self._directories, abspath, include_ignored)83 def iter_module_paths(self, abspath=True, include_ignored=False):84 return self._iter_paths(self._modules, abspath, include_ignored)85 def to_absolute_path(self, path):86 return os.path.abspath(os.path.join(self.rootpath, path))87 def get_minimal_syspath(self, absolute_paths=True):88 """89 Provide a list of directories that, when added to sys.path, would enable90 any of the discovered python modules to be found91 """92 # firstly, gather a list of the minimum path to each package93 package_list = set()94 packages = [p[0] for p in self._packages if not p[1]]95 for package in sorted(packages, key=len):96 parent = os.path.split(package)[0]97 if parent not in packages and parent not in package_list:98 package_list.add(parent)...

Full Screen

Full Screen

nsdict.py

Source:nsdict.py Github

copy

Full Screen

...79 else:80 return NamespaceDict(new_dict, sep=self._sep)81 @normpath82 def __setitem__(self, path, value):83 for part in self._iter_paths(path):84 if part in self._leaves():85 self.__delitem__(part)86 if path in self:87 self.__delitem__(path)88 dict.__setitem__(self, path, value)89 self._increment_path_references(path)90 @normpath91 def __getitem__(self, path):92 try:93 return dict.__getitem__(self, path)94 except KeyError:95 return self.extract(path)96 @normpath97 def __delitem__(self, name):98 for leaf in self._leaves():99 if leaf.startswith(name):100 self._decrement_parent_path_references(leaf)101 dict.__delitem__(self, leaf)102 def __len__(self):103 return len(self._ref_count)104 @normpath105 def __contains__(self, name):106 return name in self._ref_count107 def __repr__(self):108 return "NamespaceDict(%s)" % dict.__repr__(self)109 def __str__(self):110 return dict.__str__(self)111 @staticmethod112 def _args_as_items(*args, **kwds):113 return dict(*args, **kwds).items()114 def _join(self, *p):115 return self._sep.join(p)116 def _norm(self, path):117 return self._sep + self._sep.join(self._split(path))118 def _split(self, path):119 return [part for part in path.split(self._sep) if len(part) > 0]120 def _iter_paths(self, path):121 yield self._sep122 parts = self._split(path)123 base = ""124 for part in parts:125 base = self._join(base, part)126 yield base127 def _paths(self, path):128 return set(self._iter_paths(path))129 @normpath130 def _iter_sub_paths(self, base):131 if base == self._sep:132 base = ""133 for key in self._ref_count.keys():134 if key.startswith(base):135 try:136 yield key[len(base) + 1 :]137 except IndexError:138 yield key[len(base) :]139 def _sub_paths(self, base):140 return [name for name in self._iter_sub_paths(base)]141 def _increment_path_references(self, path):142 for part in self._iter_paths(path):143 self._ref_count[part] += 1144 def _decrement_parent_path_references(self, name):145 for part in self._iter_paths(name):146 self._ref_count[part] -= 1147 if self._ref_count[part] == 0:148 del self._ref_count[part]149 elif self._ref_count[part] < 0:150 raise KeyError(part)151 def _leaves(self):152 return set(dict.keys(self))153if __name__ == "__main__":154 import doctest...

Full Screen

Full Screen

cycle.py

Source:cycle.py Github

copy

Full Screen

...5 for a,b in edges:6 graph[a].add(b)7 graph[b].add(a)8 return graph9def _iter_paths(graph, start, length, path=None):10 if path is None:11 path = [start]12 if length == 1:13 yield path14 else:15 for neighbor in graph[start]:16 if len(path) < 2 or path[-2] != neighbor:17 for x in _iter_paths(graph, neighbor, length-1, path + [neighbor]):18 yield x19def _canonical(seq):20 """21 Rotates and flips a sequence into its minimal form.22 Useful for identifying node sequences that are identical except for starting point and direction.23 """24 def rotated(seq, i):25 return seq[i:] + seq[:i]26 def flipped(seq):27 return list(reversed(seq))28 candidates = []29 for i in range(len(seq)):30 for f in (flipped, lambda seq: seq):31 candidates.append(f(rotated(seq, i)))32 return tuple(min(candidates))33def get_minimal_cycles(graph):34 """35 detects all cycles of smallest size for a given graph.36 """37 nodes = list(graph)38 found = set()39 for i in range(3, len(graph)):40 for node in nodes:41 for path in _iter_paths(graph, node, i):42 if path[0] in graph[path[-1]]:43 found.add(_canonical(path))44 if found:45 break...

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