How to use dummy_mark method in autotest

Best Python code snippet using autotest_python Github


Full Screen

1#! /usr/bin/env python2# -*- coding: utf-8 -*-3# Copyright (c) 2007-2008 PediaPress GmbH4# See README.txt for additional licensing information.5from __future__ import with_statement6import sys7import re8import os9from mwlib import magics10import mwlib.log11from pylru import lrudecorator12DEBUG = "DEBUG_EXPANDER" in os.environ13log = mwlib.log.Log("expander")14splitpattern = """15({{+) # opening braces16|(}}+) # closing braces17|(\[\[|\]\]) # link18|((?:<noinclude>.*?</noinclude>)|(?:</?includeonly>)) # noinclude, comments: usually ignore19|(?P<text>(?:<nowiki>.*?</nowiki>) # nowiki20|(?:<math>.*?</math>)21|(?:<imagemap[^<>]*>.*?</imagemap>)22|(?:<gallery[^<>]*>.*?</gallery>)23|(?:<source[^<>]*>.*?</source>)24|(?:<pre.*?>.*?</pre>)25|(?:=)26|(?:[\[\]\|{}<]) # all special characters27|(?:[^=\[\]\|{}<]*)) # all others28"""29splitrx = re.compile(splitpattern, re.VERBOSE | re.DOTALL | re.IGNORECASE)30onlyincluderx = re.compile("<onlyinclude>(.*?)</onlyinclude>", re.DOTALL | re.IGNORECASE)31commentrx = re.compile(r"(\n *)?<!--.*?-->( *\n)?", re.DOTALL)32def remove_comments(txt):33 def repl(m):34 #print "M:", repr(txt[m.start():m.end()])35 if txt[m.start()]=='\n' and txt[m.end()-1]=='\n':36 return '\n'37 return ( or "")+( or "")38 return commentrx.sub(repl, txt)39def preprocess(txt):40 #txt=txt.replace("\t", " ")41 txt=remove_comments(txt)42 return txt43class symbols:44 bra_open = 145 bra_close = 246 link = 347 noi = 448 txt = 549def tokenize(txt):50 txt = preprocess(txt)51 52 if "<onlyinclude>" in txt:53 # if onlyinclude tags are used, only use text between those tags. template 'legend' is a example54 txt = "".join(onlyincluderx.findall(txt))55 56 57 tokens = []58 for (v1, v2, v3, v4, v5) in splitrx.findall(txt):59 if v5:60 tokens.append((5, v5)) 61 elif v4:62 tokens.append((4, v4))63 elif v3:64 tokens.append((3, v3))65 elif v2:66 tokens.append((2, v2))67 elif v1:68 tokens.append((1, v1))69 tokens.append((None, ''))70 71 return tokens72def flatten(node, expander, variables, res):73 t=type(node)74 if t is unicode or t is str:75 res.append(node)76 elif t is list:77 for x in node:78 flatten(x, expander, variables, res)79 else:80 node.flatten(expander, variables, res)81 82class Node(object):83 def __init__(self):84 self.children = []85 def __repr__(self):86 return "<%s %s children>" % (self.__class__.__name__, len(self.children))87 def __iter__(self):88 for x in self.children:89 yield x90 def show(self, out=None):91 show(self, out=out)92 93 def flatten(self, expander, variables, res):94 for x in self.children:95 if isinstance(x, basestring):96 res.append(x)97 else:98 flatten(x, expander, variables, res)99 100 @property101 def descendants(self):102 """Iterator yielding all descendants of this Node which are Nodes"""103 104 for c in self.children:105 yield c106 if not isinstance(c, Node):107 continue108 for x in c.descendants:109 yield x 110 111 def find(self, tp):112 """Return instances of type tp in self.descendants"""113 114 return [x for x in self.descendants if isinstance(x, tp)]115 116class Variable(Node):117 def flatten(self, expander, variables, res):118 name = []119 flatten(self.children[0], expander, variables, name)120 name = u"".join(name).strip()121 if len(name)>256*1024:122 raise MemoryLimitError("template name too long: %s bytes" % (len(name),))123 v = variables.get(name, None)124 if v is None:125 if len(self.children)>1:126 flatten(self.children[1:], expander, variables, res)127 else:128 pass129 # FIXME. breaks If130 #res.append(u"{{{%s}}}" % (name,))131 else:132 res.append(v)133def _switch_split_node(node):134 if isinstance(node, basestring):135 if '=' in node:136 return node.split("=", 1) #FIXME137 138 return None, node139 try:140 idx = node.children.index(u"=")141 except ValueError:142 #FIXME143 return None, node144 k = node.children[:idx]145 v = node.children[idx+1:]146 147 return k, v148 149 150 151class Template(Node):152 def flatten(self, expander, variables, res):153 try:154 return self._flatten(expander, variables, res)155 except RuntimeError, err:156 # we expect a "RuntimeError: maximum recursion depth exceeded" here.157 # logging this error is rather hard...158 try:159 log.warn("error %s ignored" % (err,))160 except:161 pass162 163 164 def _flatten(self, expander, variables, res):165 name = []166 flatten(self.children[0], expander, variables, name)167 name = u"".join(name).strip()168 if len(name)>256*1024:169 raise MemoryLimitError("template name too long: %s bytes" % (len(name),))170 remainder = None171 if ":" in name:172 try_name, try_remainder = name.split(':', 1)173 if expander.resolver.has_magic(try_name):174 name=try_name175 remainder = try_remainder176 177 if name=='#if':178 remainder=remainder.strip()179 res.append(maybe_newline)180 tmp = []181 if remainder:182 if len(self.children)>=2:183 flatten(self.children[1], expander, variables, tmp)184 else:185 if len(self.children)>=3:186 flatten(self.children[2], expander, variables, tmp)187 res.append(u"".join(tmp).strip())188 res.append(dummy_mark)189 return190 elif name=='#ifeq':191 res.append(maybe_newline)192 tmp=[]193 if len(self.children)>=2:194 flatten(self.children[1], expander, variables, tmp)195 other = u"".join(tmp).strip()196 remainder = remainder.strip()197 tmp = []198 from mwlib.magics import maybe_numeric_compare199 if maybe_numeric_compare(remainder, other):200 if len(self.children)>=3:201 flatten(self.children[2], expander, variables, tmp)202 res.append(u"".join(tmp).strip())203 else:204 if len(self.children)>=4:205 flatten(self.children[3], expander, variables, tmp)206 res.append(u"".join(tmp).strip())207 res.append(dummy_mark)208 return209 elif name=='#switch':210 res.append(maybe_newline)211 212 remainder = remainder.strip()213 default = None214 for i in xrange(1, len(self.children)):215 c = self.children[i]216 k, v = _switch_split_node(c)217 if k is not None:218 tmp = []219 flatten(k, expander, variables, tmp)220 k=u"".join(tmp).strip()221 if k=='#default':222 default = v223 224 225 if (k is None and i==len(self.children)-1) or (k is not None and magics.maybe_numeric_compare(k, remainder)):226 tmp = []227 flatten(v, expander, variables, tmp)228 v = u"".join(tmp).strip()229 230 res.append(v)231 res.append(dummy_mark)232 return233 if default is not None:234 tmp=[]235 flatten(default, expander, variables, tmp)236 tmp = u"".join(tmp).strip()237 res.append(tmp)238 239 240 res.append(dummy_mark)241 return242 243 244 #print "NAME:", (name, remainder)245 246 var = ArgumentList()247 if remainder is not None:248 tmpnode=Node()249 tmpnode.children.append(remainder)250 var.append(LazyArgument(tmpnode, expander, variables))251 252 for x in self.children[1:]:253 var.append(LazyArgument(x, expander, variables))254 rep = expander.resolver(name, var)255 if rep is not None:256 res.append(maybe_newline)257 res.append(rep)258 res.append(dummy_mark)259 else: 260 p = expander.getParsedTemplate(name)261 if p:262 if DEBUG:263 msg = "EXPANDING %r %r ===> " % (name, var)264 oldidx = len(res)265 res.append(mark_start(repr(name)))266 res.append(maybe_newline)267 flatten(p, expander, var, res)268 res.append(mark_end(repr(name)))269 if DEBUG:270 msg += repr("".join(res[oldidx:]))271 print msg272def show(node, indent=0, out=None):273 if out is None:274 out=sys.stdout275 out.write("%s%r\n" % (" "*indent, node))276 if isinstance(node, basestring):277 return278 for x in node.children:279 show(x, indent+1, out)280def optimize(node):281 if isinstance(node, basestring):282 return node283 if type(node) is Node and len(node.children)==1:284 return optimize(node.children[0])285 for i, x in enumerate(node.children):286 node.children[i] = optimize(x)287 return node288 289class Parser(object):290 def __init__(self, txt):291 if isinstance(txt, str):292 txt = unicode(txt)293 294 self.txt = txt295 self.tokens = tokenize(txt)296 self.pos = 0297 def getToken(self):298 return self.tokens[self.pos]299 def setToken(self, tok):300 self.tokens[self.pos] = tok301 def variableFromChildren(self, children):302 v=Variable()303 name = Node()304 v.children.append(name)305 try:306 idx = children.index(u"|")307 except ValueError:308 name.children = children309 else:310 name.children = children[:idx] 311 v.children.extend(children[idx+1:])312 return v313 314 def _eatBrace(self, num):315 ty, txt = self.getToken()316 assert ty == symbols.bra_close317 assert len(txt)>= num318 newlen = len(txt)-num319 if newlen==0:320 self.pos+=1321 return322 323 if newlen==1:324 ty = symbols.txt325 txt = txt[:newlen]326 self.setToken((ty, txt))327 328 def templateFromChildren(self, children):329 t=Template()330 # find the name331 name = Node()332 t.children.append(name)333 # empty blocks are a fact of life334 if len(children) == 0:335 return t336 337 idx = 0338 for idx, c in enumerate(children):339 if c==u'|':340 break341 name.children.append(c)342 # find the arguments343 344 arg = Node()345 linkcount = 0346 for c in children[idx+1:]:347 if c==u'[[':348 linkcount += 1349 elif c==']]':350 linkcount -= 1351 elif c==u'|' and linkcount==0:352 t.children.append(arg)353 arg = Node()354 continue355 arg.children.append(c)356 if arg.children:357 t.children.append(arg)358 return t359 360 def parseOpenBrace(self):361 ty, txt = self.getToken()362 n = Node()363 numbraces = len(txt)364 self.pos += 1365 366 while 1:367 ty, txt = self.getToken()368 if ty==symbols.bra_open:369 n.children.append(self.parseOpenBrace())370 elif ty is None:371 break372 elif ty==symbols.bra_close:373 closelen = len(txt)374 if closelen==2 or numbraces==2:375 t=self.templateFromChildren(n.children)376 n=Node()377 n.children.append(t)378 self._eatBrace(2)379 numbraces-=2380 else:381 v=self.variableFromChildren(n.children)382 n=Node()383 n.children.append(v)384 self._eatBrace(3)385 numbraces -= 3386 if numbraces==0:387 break388 elif numbraces==1:389 n.children.insert(0, "{")390 break391 elif ty==symbols.noi:392 self.pos += 1 # ignore <noinclude>393 else: # link, txt394 n.children.append(txt)395 self.pos += 1 396 return n397 398 def parse(self):399 n = Node()400 while 1:401 ty, txt = self.getToken()402 if ty==symbols.bra_open:403 n.children.append(self.parseOpenBrace())404 elif ty is None:405 break406 elif ty==symbols.noi:407 self.pos += 1 # ignore <noinclude>408 else: # bra_close, link, txt 409 n.children.append(txt)410 self.pos += 1411 return n412def parse(txt):413 return optimize(Parser(txt).parse())414class MemoryLimitError(Exception):415 pass416class LazyArgument(object):417 def __init__(self, node, expander, variables):418 self.node = node419 self.expander = expander420 self._flatten = None421 self.variables = variables422 self._splitflatten = None423 def _flattennode(self, n):424 arg=[]425 flatten(n, self.expander, self.variables, arg)426 _insert_implicit_newlines(arg)427 arg = u"".join(arg)428 if len(arg)>256*1024:429 raise MemoryLimitError("template argument too long: %s bytes" % (len(arg),))430 return arg431 def splitflatten(self):432 if self._splitflatten is None:433 try:434 idx = self.node.children.index(u'=')435 except (ValueError, AttributeError):436 name = None437 val = self.node438 else:439 name = self.node440 val = Node()441 val.children[:] = self.node.children[idx+1:]442 oldchildren = self.node.children[:]443 del self.node.children[idx:]444 name = self._flattennode(name)445 self.node.children = oldchildren446 447 val = self._flattennode(val)448 self._splitflatten = name, val449 return self._splitflatten450 451 452 def flatten(self):453 if self._flatten is None: 454 self._flatten = self._flattennode(self.node).strip()455 456 arg=[]457 flatten(self.node, self.expander, self.variables, arg)458 _insert_implicit_newlines(arg)459 arg = u"".join(arg).strip()460 if len(arg)>256*1024:461 raise MemoryLimitError("template argument too long: %s bytes" % (len(arg),))462 463 self._flatten = arg464 return self._flatten465class ArgumentList(object):466 def __init__(self):467 self.args = []468 self.namedargs = {}469 def __repr__(self):470 return "<ARGLIST args=%r>" % ([x.flatten() for x in self.args],)471 def append(self, a):472 self.args.append(a)473 def __iter__(self):474 for x in self.args:475 yield x476 def __getslice__(self, i, j):477 for x in self.args[i:j]:478 yield x.flatten()479 480 def __len__(self):481 return len(self.args)482 def __getitem__(self, n):483 return self.get(n, None) or u''484 485 def get(self, n, default):486 if isinstance(n, (int, long)):487 try:488 a=self.args[n]489 except IndexError:490 return default491 return a.flatten()492 assert isinstance(n, basestring), "expected int or string"493 varcount=1494 if n not in self.namedargs:495 for x in self.args:496 name, val = x.splitflatten()497 498 499 if name is not None:500 name = name.strip()501 val = val.strip()502 self.namedargs[name] = val503 if n==name:504 return val505 else:506 name = str(varcount)507 varcount+=1508 self.namedargs[name] = val 509 if n==name:510 return val511 self.namedargs[n] = None512 val = self.namedargs[n]513 if val is None:514 return default515 return val516 517def is_implicit_newline(raw):518 """should we add a newline to templates starting with *, #, :, ;, {|519 see: """521 sw = raw.startswith522 for x in ('*', '#', ':', ';', '{|'):523 if sw(x):524 return True525 return False 526class mark(unicode):527 def __new__(klass, msg):528 r=unicode.__new__(klass)529 r.msg = msg530 return r531 532 def __repr__(self):533 return '<%s %r>' % (self.__class__.__name__, self.msg,)534class mark_start(mark): pass535class mark_end(mark): pass536class mark_maybe_newline(mark): pass537maybe_newline = mark_maybe_newline('maybe_newline')538dummy_mark = mark('dummy')539def _insert_implicit_newlines(res, maybe_newline=maybe_newline):540 # do not pass the second argument541 res.append(dummy_mark)542 res.append(dummy_mark)543 for i, p in enumerate(res):544 if p is maybe_newline:545 s1 = res[i+1]546 s2 = res[i+2]547 if isinstance(s1, mark):548 continue549 if len(s1)>=2:550 if is_implicit_newline(s1):551 res[i] = '\n'552 else:553 if is_implicit_newline(''.join([s1, s2])):554 res[i] = '\n'555 del res[-2:]556 557class Expander(object):558 def __init__(self, txt, pagename="", wikidb=None, templateprefix='Template:', templateblacklist=set(), lang='en'):559 assert wikidb is not None, "must supply wikidb argument in Expander.__init__"560 self.db = wikidb561 self.resolver = magics.MagicResolver(pagename=pagename)562 self.resolver.wikidb = wikidb563 self.templateprefix = templateprefix564 self.templateblacklist = templateblacklist565 self.lang = lang566 self.parsed = parse(txt)567 #show(self.parsed)568 self.parsedTemplateCache = {}569 @lrudecorator(100)570 def getParsedTemplate(self, name):571 if name.startswith("[["):572 return None573 if name == '':574 return ''575 if name.startswith(":"):576"including article")577 raw = self.db.getRawArticle(name[1:])578 else:579 if len(name) > 1:580 name = name[0].capitalize() + name[1:]581 name = self.templateprefix + name582 # Check to see if this is a template in our blacklist --583 # one that we don't want to bother rendering.584 if name in self.templateblacklist:585"Skipping template " + name.encode('utf8'))586 raw = None587 else:588 raw = self.db.getTemplate(name, True)589 if raw is None:590 log.warn("no template", repr(name))591 res = None592 else:593"parsing template", repr(name))594 res = parse(raw)595 if DEBUG:596 print "TEMPLATE:", name, repr(raw)597 599 return res600 601 602 def expandTemplates(self):603 res = []604 flatten(self.parsed, self, ArgumentList(), res)605 _insert_implicit_newlines(res)606 return u"".join(res)607class DictDB(object):608 """wikidb implementation used for testing"""609 def __init__(self, *args, **kw):610 if args:611 self.d, = args612 else:613 self.d = {}614 615 self.d.update(kw)616 normd = {}617 for k, v in self.d.items():618 normd[k.lower()] = v619 self.d = normd620 621 def getRawArticle(self, title):622 return self.d[title.lower()]623 def getTemplate(self, title, dummy):624 return self.d.get(title.lower(), u"")625 626def expandstr(s, expected=None, wikidb=None, pagename='thispage'):627 """debug function. expand templates in string s"""628 if wikidb:629 db = wikidb630 else:631 db = DictDB(dict(a=s))632 te = Expander(s, pagename=pagename, wikidb=db)633 res = te.expandTemplates()634 print "EXPAND: %r -> %r" % (s, res)635 if expected is not None:636 assert res==expected, "expected %r, got %r" % (expected, res)637 return res638if __name__=="__main__":639 #print splitrx.groupindex640 d=unicode(open(sys.argv[1]).read(), 'utf8')641 e = Expander(d)...

Full Screen

Full Screen Github


Full Screen

1# Copyright (c) 2007-2009 PediaPress GmbH2# See README.txt for additional licensing information.3from mwlib.templ import magics4class Node(tuple):5 def __eq__(self, other):6 return type(self)==type(other) and tuple.__eq__(self, other) 7 def __ne__(self, other):8 return type(self)!=type(other) or tuple.__ne__(self, other)9 10 def __repr__(self):11 return "%s%s" % (self.__class__.__name__, tuple.__repr__(self))12 13 def show(self, out=None):14 show(self, out=out)15 16 def flatten(self, expander, variables, res):17 for x in self:18 if isinstance(x, basestring):19 res.append(x)20 else:21 flatten(x, expander, variables, res)22 23class IfNode(Node):24 def flatten(self, expander, variables, res):25 cond = []26 flatten(self[0], expander, variables, cond)27 cond = u"".join(cond).strip()28 # template blacklisting results in 0xebad29 # see cond = cond.strip(unichr(0xebad))31 32 res.append(maybe_newline)33 tmp = []34 if cond:35 if len(self)>1:36 flatten(self[1], expander, variables, tmp)37 else:38 if len(self)>2:39 flatten(self[2], expander, variables, tmp)40 _insert_implicit_newlines(tmp)41 res.append(u"".join(tmp).strip())42 res.append(dummy_mark)43class IfeqNode(Node):44 def flatten(self, expander, variables, res): 45 v1 = []46 flatten(self[0], expander, variables, v1)47 v1 = u"".join(v1).strip()48 v2 = []49 if len(self)>1:50 flatten(self[1], expander, variables, v2)51 v2 = u"".join(v2).strip()52 from mwlib.templ.magics import maybe_numeric_compare53 res.append(maybe_newline)54 tmp = []55 56 if maybe_numeric_compare(v1,v2):57 if len(self)>2:58 flatten(self[2], expander, variables, tmp)59 else:60 if len(self)>3:61 flatten(self[3], expander, variables, tmp)62 63 _insert_implicit_newlines(tmp)64 res.append(u"".join(tmp).strip())65 res.append(dummy_mark)66def maybe_numeric(a):67 try:68 return int(a)69 except ValueError:70 pass71 72 try:73 return float(a)74 except ValueError:75 pass76 return None77 78class SwitchNode(Node):79 fast = None80 unresolved = None81 def _store_key(self, key, value, fast, unresolved):82 if isinstance(key, basestring):83 key = key.strip()84 if key in fast:85 return86 fast[key] = (len(unresolved), value)87 num_key = maybe_numeric(key)88 if num_key is not None and num_key not in fast:89 fast[num_key] = (len(unresolved), value)90 else:91 unresolved.append((key,value))92 93 def _init(self):94 args = [equalsplit(x) for x in self[1]]95 96 unresolved = []97 fast = {}98 nokey_seen = []99 100 for key, value in args:101 if key is not None:102 key = optimize(list(key))103 if type(value) is tuple:104 value = optimize(list(value))105 if key is None:106 nokey_seen.append(value)107 continue108 for k in nokey_seen:109 self._store_key(k, value, fast, unresolved)110 del nokey_seen[:]111 self._store_key(key, value, fast, unresolved)112 if nokey_seen:113 self._store_key(u'#default', nokey_seen[-1], fast, unresolved)114 115 self.unresolved = tuple(unresolved)116 = fast117 self.sentinel = (len(self.unresolved)+1, None)118 119 def flatten(self, expander, variables, res):120 if self.unresolved is None:121 self._init()122 res.append(maybe_newline)123 val = []124 flatten(self[0], expander, variables, val)125 val = u"".join(val).strip()126 num_val = maybe_numeric(val)127 128 t1 =, self.sentinel)129 t2 =, self.sentinel)130 pos, retval = min(t1, t2)131 132 if pos is None:133 pos = len(self.unresolved)+1134 135 for k, v in self.unresolved[:pos]:136 tmp = []137 flatten(k, expander, variables, tmp)138 tmp = u"".join(tmp).strip()139 if tmp==val:140 retval = v141 break142 if num_val is not None and maybe_numeric(tmp)==num_val:143 retval = v144 break145 146 if retval is None:147 retval ="#default", (None, u''))[1]148 149 tmp = []150 flatten(retval, expander, variables, tmp)151 _insert_implicit_newlines(tmp)152 tmp = u"".join(tmp).strip()153 res.append(tmp)154 res.append(dummy_mark)155class Variable(Node):156 def flatten(self, expander, variables, res):157 name = []158 flatten(self[0], expander, variables, name)159 name = u"".join(name).strip()160 if len(name)>256*1024:161 raise MemoryLimitError("template name too long: %s bytes" % (len(name),))162 v = variables.get(name, None)163 if v is None:164 if len(self)>1:165 flatten(self[1], expander, variables, res)166 else:167 # FIXME. breaks If ???168 res.append(u"{{{%s}}}" % (name,))169 else:170 res.append(v)171 172class Template(Node):173 def flatten(self, expander, variables, res):174 try:175 return self._flatten(expander, variables, res)176 except RuntimeError, err:177 # we expect a "RuntimeError: maximum recursion depth exceeded" here.178 # logging this error is rather hard...179 try:180 log.warn("error %s ignored" % (err,))181 except:182 pass183 184 185 def _flatten(self, expander, variables, res):186 187 name = []188 flatten(self[0], expander, variables, name)189 name = u"".join(name).strip()190 if len(name)>256*1024:191 raise MemoryLimitError("template name too long: %s bytes" % (len(name),))192 args = self[1]193 194 remainder = None195 if ":" in name:196 try_name, try_remainder = name.split(':', 1)197 from mwlib.templ import magic_nodes198 klass = magic_nodes.registry.get(try_name)199 if klass is not None:200 children = (try_remainder, )+args201 # print "MAGIC:", klass, children202 klass(children).flatten(expander, variables, res)203 return204 205 if expander.resolver.has_magic(try_name):206 name=try_name207 remainder = try_remainder208 209 if name=='#ifeq':210 res.append(maybe_newline)211 tmp=[]212 if len(args)>=1:213 flatten(args[0], expander, variables, tmp)214 other = u"".join(tmp).strip()215 remainder = remainder.strip()216 tmp = []217 if magics.maybe_numeric_compare(remainder, other):218 if len(args)>=2:219 flatten(args[1], expander, variables, tmp)220 res.append(u"".join(tmp).strip())221 else:222 if len(args)>=3:223 flatten(args[2], expander, variables, tmp)224 res.append(u"".join(tmp).strip())225 res.append(dummy_mark)226 return227 228 var = []229 if remainder is not None:230 var.append(remainder)231 232 for x in args:233 var.append(x)234 var = ArgumentList(args=var, expander=expander, variables=variables)235 236 rep = expander.resolver(name, var)237 if rep is not None:238 res.append(maybe_newline)239 res.append(rep)240 res.append(dummy_mark)241 else: 242 p = expander.getParsedTemplate(name)243 if p:244 if DEBUG:245 msg = "EXPANDING %r %r ===> " % (name, var)246 oldidx = len(res)247 res.append(mark_start(repr(name)))248 res.append(maybe_newline)249 flatten(p, expander, var, res)250 res.append(mark_end(repr(name)))251 if DEBUG:252 msg += repr("".join(res[oldidx:]))253 print msg254def show(node, indent=0, out=None):255 import sys256 257 if out is None:258 out=sys.stdout259 out.write("%s\n" % (node,))260 261from mwlib.templ.evaluate import maybe_newline, mark_start, mark_end, dummy_mark, flatten, MemoryLimitError, ArgumentList, equalsplit, _insert_implicit_newlines262from mwlib.templ import log, DEBUG...

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:


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?