How to use _do_parse method in localstack

Best Python code snippet using localstack_python

_markupparser.py

Source:_markupparser.py Github

copy

Full Screen

...29 ... 'url_start': '<u><span fg_color="blue">',30 ... 'url_end': '</span></u>',31 ... }32 >>> parser = SimpleMarkupParser(custom_tags)33 >>> parser._do_parse('We have *bold*, _italics_ and `code`.')34 'We have <b>bold</b>, <i>italics</i> and <tt><span size="small">code</span></tt>.'35 >>> parser._do_parse('*I am _very_ excited* about this quest!')36 '<b>I am <i>very</i> excited</b> about this quest!'37 >>> parser._do_parse('I ~despise~ am not a fan of soup.')38 'I <s>despise</s> am not a fan of soup.'39 >>> parser._do_parse('Try setting `gravity = 0` in the code.')40 'Try setting <tt><span size="small">gravity = 0</span></tt> in the code.'41 >>> parser._do_parse('Checkout this site! https://www.w3.org/2000/svg')42 'Checkout this site! <u><span fg_color="blue">https://www.w3.org/2000/svg</span></u>'43 >>> parser._do_parse('Link with an underscore should not break: https://test.org/hello_world')44 'Link with an underscore should not break: \45<u><span fg_color="blue">https://test.org/hello_world</span></u>'46 >>> parser._do_parse('Mixing `code and *bold*` allowed')47 'Mixing <tt><span size="small">code and <b>bold</b></span></tt> allowed'48 >>> parser._do_parse('URL in code `https://www.hack-computer.com/` allowed')49 'URL in code <tt><span size="small"><u><span fg_color="blue">\50https://www.hack-computer.com/</span></u></span></tt> allowed'51 """52 DEFAULT_TAGS = {53 'bold_start': '<b>',54 'bold_end': '</b>',55 'italics_start': '<i>',56 'italics_end': '</i>',57 'strikethrough_start': '<s>',58 'strikethrough_end': '</s>',59 'inlinecode_start': ('<tt><span insert_hyphens="false" '60 'foreground="#287A8C" background="#FFFFFF">'),61 'inlinecode_end': '</span></tt>',62 'url_start': '<u><span insert_hyphens="false" foreground="#3584E4">',63 'url_end': '</span></u>',64 }65 _convertions = None66 _instance = None67 def __init__(self, custom_tags=None):68 tags = self.DEFAULT_TAGS.copy()69 if isinstance(custom_tags, dict):70 tags.update(custom_tags)71 self._convertions = [72 [re.compile(r'<', re.S), r'&lt;'],73 [re.compile(r'>', re.S), r'&gt;'],74 [re.compile(75 # From http://www.noah.org/wiki/RegEx_Python#URL_regex_pattern76 (r'(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|'77 r'(?:%[0-9a-fA-F][0-9a-fA-F]))+)'), re.S),78 f'{tags["url_start"]}\\1{tags["url_end"]}'],79 [re.compile(r'(?!<span[^>]*?>)(\*)(?=\S)(.+?)(?<=\S)\1(?![^<]*?</span>)', re.S),80 f'{tags["bold_start"]}\\2{tags["bold_end"]}'],81 [re.compile(r'(?!<span[^>]*?>)(_)(?=\S)(.+?)(?<=\S)\1(?![^<]*?</span>)', re.S),82 f'{tags["italics_start"]}\\2{tags["italics_end"]}'],83 [re.compile(r'(?!<span[^>]*?>)(~)(?=\S)(.+?)(?<=\S)\1(?![^<]*?</span>)', re.S),84 f'{tags["strikethrough_start"]}\\2{tags["strikethrough_end"]}'],85 [re.compile(r'(`)(?=\S)(.+?)(?<=\S)\1', re.S),86 f'{tags["inlinecode_start"]}\\2{tags["inlinecode_end"]}'],87 ]88 def _do_parse(self, text):89 for regex, replacement in self._convertions:90 text = regex.sub(replacement, text)91 return text92 @classmethod93 def parse(class_, text):94 if class_._instance is None:95 class_._instance = class_()96 return class_._instance._do_parse(text)97if __name__ == "__main__":98 import doctest...

Full Screen

Full Screen

_parser.py

Source:_parser.py Github

copy

Full Screen

...30 self._text = text31 def parse(self, add_ts_zero = False):32 seen_ts = {}33 all_tokens = []34 self._do_parse(all_tokens, seen_ts)35 self._resolve_ambiguity(all_tokens, seen_ts)36 self._create_objects_with_links_to_tabs(all_tokens, seen_ts)37 if add_ts_zero and 0 not in seen_ts:38 mark = all_tokens[-1][1].end # Last token is always EndOfText39 m1 = Position(mark.line, mark.col)40 TabStop(self._parent_to, 0, mark, m1)41 self._parent_to.replace_initital_text()42 #####################43 # Private Functions #44 #####################45 def _resolve_ambiguity(self, all_tokens, seen_ts):46 for parent, token in all_tokens:47 if isinstance(token, MirrorToken):48 if token.no not in seen_ts:49 seen_ts[token.no] = TabStop(parent, token)50 else:51 Mirror(parent, seen_ts[token.no], token)52 def _create_objects_with_links_to_tabs(self, all_tokens, seen_ts):53 for parent, token in all_tokens:54 if isinstance(token, TransformationToken):55 if token.no not in seen_ts:56 raise RuntimeError("Tabstop %i is not known but is used by a Transformation" % token.no)57 Transformation(parent, seen_ts[token.no], token)58 def _do_parse(self, all_tokens, seen_ts):59 tokens = list(tokenize(self._text, self._indent, self._parent_to.start))60 for token in tokens:61 all_tokens.append((self._parent_to, token))62 if isinstance(token, TabStopToken):63 ts = TabStop(self._parent_to, token)64 seen_ts[token.no] = ts65 k = TOParser(ts, token.initial_text, self._indent)66 k._do_parse(all_tokens, seen_ts)67 else:68 klass = self.TOKEN2TO.get(token.__class__, None)69 if klass is not None:...

Full Screen

Full Screen

test_issues.py

Source:test_issues.py Github

copy

Full Screen

...9 pkg_res_version = pkg_parse_version(version_str)10 assert str(pkg_res_version) == '1.0.0rc1'11 # use setuptools_scm to get a version object that we can modify to introduce the bug12 config = Configuration(root=join(__file__, pardir, pardir, pardir))13 s_version = _do_parse(config)14 # --make sure that internals of `setuptools_scm` have not changed: the .tag object is a pkg_resource Version15 assert isinstance(s_version.tag, type(pkg_res_version))16 # --now lets modify the version object so as to inject the issue17 s_version.tag = pkg_res_version18 # make sure that setuptools_scm did not fix the issue yet19 pb_ver = format_version(20 s_version,21 version_scheme=config.version_scheme,22 local_scheme=config.local_scheme,23 )24 assert str(pb_ver) != version_str25 assert str(pb_ver).startswith("1.0.0rc") # dash removed26 # make sure that with our fixed version scheme (used in our plugin) it works27 fixed_vers = format_version(...

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