How to use _try_iter method in autotest

Best Python code snippet using autotest_python

server.py

Source:server.py Github

copy

Full Screen

...53 self.document = self.workspace.get_document(document.uri)54 if not self.document.source: return55 self.matches = [ (match, sub)56 for name, sub in self.substructures.items() if self.substructure_config.get(name)57 for match in self._try_iter(sub, self.document.source)58 ]59 diagnostics = [60 self._make_diagnostic(match.text_range, substrcture)61 for match, substrcture in self.matches62 ]63 self.publish_diagnostics(self.document.uri, diagnostics)64 def hover(self, position: Position):65 hover_match = [ (match.text_range, substructure)66 for match, substructure in self.matches if self._contains(match.text_range, position)67 ]68 if not hover_match: return69 text_range, substructure = hover_match[0]70 content = MarkupContent(71 kind=MarkupKind.Markdown,72 value=substructure.description.content,73 )74 hover_range = Range(75 start=Position(line=text_range.from_line-1, character=text_range.from_offset),76 end=Position(line=text_range.to_line-1, character=text_range.to_offset),77 )78 return Hover(contents=content, range=hover_range)79 @staticmethod80 def _make_diagnostic(text_range: TextRange, substructure: Substructure):81 diagnostic_range = Range(82 start=Position(line=text_range.from_line-1, character=text_range.from_offset),83 end=Position(line=text_range.to_line-1, character=text_range.to_offset),84 )85 return Diagnostic(86 range=diagnostic_range,87 message=substructure.name,88 code=substructure.technical_description,89 source=PyDeodoriserServer.DIAGNOSTIC_SOURCE,90 severity = DiagnosticSeverity.Warning,91 )92 @staticmethod93 def _try_iter(substructure: Substructure, source: str):94 try:95 return substructure.iter_matches(source)96 except:97 return []98 @staticmethod99 def _contains(text_range: TextRange, position: Position):100 return text_range.from_line <= position.line+1 <= text_range.to_line101pyDeodoriser = PyDeodoriserServer()102@pyDeodoriser.feature(TEXT_DOCUMENT_DID_CHANGE)103async def did_change(ls: PyDeodoriserServer, params: DidChangeTextDocumentParams):104 """Text document did change notification."""105 await ls.get_config_substructure()106 ls.validate(params.text_document)107@pyDeodoriser.feature(TEXT_DOCUMENT_DID_OPEN)...

Full Screen

Full Screen

helpers.py

Source:helpers.py Github

copy

Full Screen

1from typing import List, Dict, Any, Mapping, Union, Iterable2def _try_iter(obj: Any) -> Iterable:3 if isinstance(obj, str):4 return [obj]5 try:6 return iter(obj)7 except TypeError:8 pass9 return [obj]10def _format(items: Union[List, Dict], pattern: str) -> str:11 if isinstance(items, dict):12 return pattern.format(**items)13 return pattern.format(*_try_iter(items))14def multi_extract(key: str, container: Mapping[str, Any], subkeys: List[str]) -> List[Any]:15 return [container[key][subkey] for subkey in subkeys]16class FilterModule:17 def filters(self):...

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