def b2a_qp(data, quotetabs=False, istext=True, header=False):

MAXLINESIZE = <NUM_LIT><EOL>lf = data.find('<STR_LIT:\n>')<EOL>crlf = lf > <NUM_LIT:0> and data[lf-<NUM_LIT:1>] == '<STR_LIT:\r>'<EOL>inp = <NUM_LIT:0><EOL>linelen = <NUM_LIT:0><EOL>odata = []<EOL>while inp < len(data):<EOL><INDENT>c = data[inp]<EOL>if (c > '<STR_LIT>' or<EOL>c == '<STR_LIT:=>' or<EOL>(header and c == '<STR_LIT:_>') or<EOL>(c == '<STR_LIT:.>' and linelen == <NUM_LIT:0> and (inp+<NUM_LIT:1> == len(data) or<EOL>data[inp+<NUM_LIT:1>] == '<STR_LIT:\n>' or<EOL>data[inp+<NUM_LIT:1>] == '<STR_LIT:\r>')) or<EOL>(not istext and (c == '<STR_LIT:\r>' or c == '<STR_LIT:\n>')) or<EOL>((c == '<STR_LIT:\t>' or c == '<STR_LIT:U+0020>') and (inp + <NUM_LIT:1> == len(data))) or<EOL>(c <= '<STR_LIT:U+0020>' and c != '<STR_LIT:\r>' and c != '<STR_LIT:\n>' and<EOL>(quotetabs or (not quotetabs and (c != '<STR_LIT:\t>' and c != '<STR_LIT:U+0020>'))))):<EOL><INDENT>linelen += <NUM_LIT:3><EOL>if linelen >= MAXLINESIZE:<EOL><INDENT>odata.append('<STR_LIT:=>')<EOL>if crlf: odata.append('<STR_LIT:\r>')<EOL>odata.append('<STR_LIT:\n>')<EOL>linelen = <NUM_LIT:3><EOL><DEDENT>odata.append('<STR_LIT:=>' + two_hex_digits(ord(c)))<EOL>inp += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if (istext and<EOL>(c == '<STR_LIT:\n>' or (inp+<NUM_LIT:1> < len(data) and c == '<STR_LIT:\r>' and<EOL>data[inp+<NUM_LIT:1>] == '<STR_LIT:\n>'))):<EOL><INDENT>linelen = <NUM_LIT:0><EOL>if (len(odata) > <NUM_LIT:0> and<EOL>(odata[-<NUM_LIT:1>] == '<STR_LIT:U+0020>' or odata[-<NUM_LIT:1>] == '<STR_LIT:\t>')):<EOL><INDENT>ch = ord(odata[-<NUM_LIT:1>])<EOL>odata[-<NUM_LIT:1>] = '<STR_LIT:=>'<EOL>odata.append(two_hex_digits(ch))<EOL><DEDENT>if crlf: odata.append('<STR_LIT:\r>')<EOL>odata.append('<STR_LIT:\n>')<EOL>if c == '<STR_LIT:\r>':<EOL><INDENT>inp += <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>inp += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if (inp + <NUM_LIT:1> < len(data) and<EOL>data[inp+<NUM_LIT:1>] != '<STR_LIT:\n>' and<EOL>(linelen + <NUM_LIT:1>) >= MAXLINESIZE):<EOL><INDENT>odata.append('<STR_LIT:=>')<EOL>if crlf: odata.append('<STR_LIT:\r>')<EOL>odata.append('<STR_LIT:\n>')<EOL>linelen = <NUM_LIT:0><EOL><DEDENT>linelen += <NUM_LIT:1><EOL>if header and c == '<STR_LIT:U+0020>':<EOL><INDENT>c = '<STR_LIT:_>'<EOL><DEDENT>odata.append(c)<EOL>inp += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>return '<STR_LIT>'.join(odata)<EOL>

quotetabs=True means that tab and space characters are always
       quoted.
       istext=False means that \r and \n are treated as regular characters
       header=True encodes space characters with '_' and requires
       real '_' characters to be quoted.


if not s:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>result = []<EOL>prev = s[<NUM_LIT:0>]<EOL>count = <NUM_LIT:1><EOL>if s[-<NUM_LIT:1>] == '<STR_LIT:!>':<EOL><INDENT>s = s[<NUM_LIT:1>:] + '<STR_LIT:?>'<EOL><DEDENT>else:<EOL><INDENT>s = s[<NUM_LIT:1>:] + '<STR_LIT:!>'<EOL><DEDENT>for c in s:<EOL><INDENT>if c == prev and count < <NUM_LIT:255>:<EOL><INDENT>count += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if count == <NUM_LIT:1>:<EOL><INDENT>if prev != '<STR_LIT>':<EOL><INDENT>result.append(prev)<EOL><DEDENT>else:<EOL><INDENT>result += ['<STR_LIT>', '<STR_LIT:\x00>']<EOL><DEDENT><DEDENT>elif count < <NUM_LIT:4>:<EOL><INDENT>if prev != '<STR_LIT>':<EOL><INDENT>result += [prev] * count<EOL><DEDENT>else:<EOL><INDENT>result += ['<STR_LIT>', '<STR_LIT:\x00>'] * count<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if prev != '<STR_LIT>':<EOL><INDENT>result += [prev, '<STR_LIT>', chr(count)]<EOL><DEDENT>else:<EOL><INDENT>result += ['<STR_LIT>', '<STR_LIT:\x00>', '<STR_LIT>', chr(count)]<EOL><DEDENT><DEDENT>count = <NUM_LIT:1><EOL>prev = c<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(result)<EOL>

Run length encoding for binhex4.
The CPython implementation does not do run length encoding
of \x90 characters. This implementation does.


imax = len(list) // <NUM_LIT:4><EOL>hl = [<NUM_LIT:0>] * imax<EOL>j = <NUM_LIT:0><EOL>i = <NUM_LIT:0><EOL>while i < imax:<EOL><INDENT>b0 = ord(list[j])<EOL>b1 = ord(list[j + <NUM_LIT:1>]) << <NUM_LIT:8><EOL>b2 = ord(list[j + <NUM_LIT:2>]) << <NUM_LIT:16><EOL>b3 = ord(list[j + <NUM_LIT:3>]) << <NUM_LIT><EOL>hl[i] = b0 | b1 | b2 | b3<EOL>i = i + <NUM_LIT:1><EOL>j = j + <NUM_LIT:4><EOL><DEDENT>return hl<EOL>

Transform a list of characters into a list of longs.


return (x << n) | (x >> (<NUM_LIT:32> - n))<EOL>

Rotate x (32 bit) left n bits circularly.


res = <NUM_LIT:0><EOL>res = res + a + func(b, c, d)<EOL>res = res + x<EOL>res = res + ac<EOL>res = res & <NUM_LIT><EOL>res = _rotateLeft(res, s)<EOL>res = res & <NUM_LIT><EOL>res = res + b<EOL>return res & <NUM_LIT><EOL>

Wrapper for call distribution to functions F, G, H and I.

    This replaces functions FF, GG, HH and II from "Appl. Crypto."
    Rotation is separate from addition to prevent recomputation
    (now summed-up in one function).


crypto = MD5Type()<EOL>if arg:<EOL><INDENT>crypto.update(arg)<EOL><DEDENT>return crypto<EOL>

Return a new md5 crypto object.
    If arg is present, the method call update(arg) is made.


<EOL>self.length = <NUM_LIT:0><EOL>self.count = [<NUM_LIT:0>, <NUM_LIT:0>]<EOL>self.input = []<EOL>self.init()<EOL>


self.length = <NUM_LIT:0><EOL>self.count = [<NUM_LIT:0>, <NUM_LIT:0>]<EOL>self.input = []<EOL>self.A = <NUM_LIT><EOL>self.B = <NUM_LIT><EOL>self.C = <NUM_LIT><EOL>self.D = <NUM_LIT><EOL>

Initialize the message-digest and set all fields to zero.code


a, b, c, d = A, B, C, D = self.A, self.B, self.C, self.D<EOL>S11, S12, S13, S14 = <NUM_LIT:7>, <NUM_LIT:12>, <NUM_LIT>, <NUM_LIT><EOL>a = XX(F, a, b, c, d, inp[<NUM_LIT:0>], S11, <NUM_LIT>)  <EOL>d = XX(F, d, a, b, c, inp[<NUM_LIT:1>], S12, <NUM_LIT>)  <EOL>c = XX(F, c, d, a, b, inp[<NUM_LIT:2>], S13, <NUM_LIT>)  <EOL>b = XX(F, b, c, d, a, inp[<NUM_LIT:3>], S14, <NUM_LIT>)  <EOL>a = XX(F, a, b, c, d, inp[<NUM_LIT:4>], S11, <NUM_LIT>)  <EOL>d = XX(F, d, a, b, c, inp[<NUM_LIT:5>], S12, <NUM_LIT>)  <EOL>c = XX(F, c, d, a, b, inp[<NUM_LIT:6>], S13, <NUM_LIT>)  <EOL>b = XX(F, b, c, d, a, inp[<NUM_LIT:7>], S14, <NUM_LIT>)  <EOL>a = XX(F, a, b, c, d, inp[<NUM_LIT:8>], S11, <NUM_LIT>)  <EOL>d = XX(F, d, a, b, c, inp[<NUM_LIT:9>], S12, <NUM_LIT>)  <EOL>c = XX(F, c, d, a, b, inp[<NUM_LIT:10>], S13, <NUM_LIT>)  <EOL>b = XX(F, b, c, d, a, inp[<NUM_LIT:11>], S14, <NUM_LIT>)  <EOL>a = XX(F, a, b, c, d, inp[<NUM_LIT:12>], S11, <NUM_LIT>)  <EOL>d = XX(F, d, a, b, c, inp[<NUM_LIT>], S12, <NUM_LIT>)  <EOL>c = XX(F, c, d, a, b, inp[<NUM_LIT>], S13, <NUM_LIT>)  <EOL>b = XX(F, b, c, d, a, inp[<NUM_LIT:15>], S14, <NUM_LIT>)  <EOL>S21, S22, S23, S24 = <NUM_LIT:5>, <NUM_LIT:9>, <NUM_LIT>, <NUM_LIT:20><EOL>a = XX(G, a, b, c, d, inp[<NUM_LIT:1>], S21, <NUM_LIT>)  <EOL>d = XX(G, d, a, b, c, inp[<NUM_LIT:6>], S22, <NUM_LIT>)  <EOL>c = XX(G, c, d, a, b, inp[<NUM_LIT:11>], S23, <NUM_LIT>)  <EOL>b = XX(G, b, c, d, a, inp[<NUM_LIT:0>], S24, <NUM_LIT>)  <EOL>a = XX(G, a, b, c, d, inp[<NUM_LIT:5>], S21, <NUM_LIT>)  <EOL>d = XX(G, d, a, b, c, inp[<NUM_LIT:10>], S22, <NUM_LIT>)  <EOL>c = XX(G, c, d, a, b, inp[<NUM_LIT:15>], S23, <NUM_LIT>)  <EOL>b = XX(G, b, c, d, a, inp[<NUM_LIT:4>], S24, <NUM_LIT>)  <EOL>a = XX(G, a, b, c, d, inp[<NUM_LIT:9>], S21, <NUM_LIT>)  <EOL>d = XX(G, d, a, b, c, inp[<NUM_LIT>], S22, <NUM_LIT>)  <EOL>c = XX(G, c, d, a, b, inp[<NUM_LIT:3>], S23, <NUM_LIT>)  <EOL>b = XX(G, b, c, d, a, inp[<NUM_LIT:8>], S24, <NUM_LIT>)  <EOL>a = XX(G, a, b, c, d, inp[<NUM_LIT>], S21, <NUM_LIT>)  <EOL>d = XX(G, d, a, b, c, inp[<NUM_LIT:2>], S22, <NUM_LIT>)  <EOL>c = XX(G, c, d, a, b, inp[<NUM_LIT:7>], S23, <NUM_LIT>)  <EOL>b = XX(G, b, c, d, a, inp[<NUM_LIT:12>], S24, <NUM_LIT>)  <EOL>S31, S32, S33, S34 = <NUM_LIT:4>, <NUM_LIT:11>, <NUM_LIT:16>, <NUM_LIT><EOL>a = XX(H, a, b, c, d, inp[<NUM_LIT:5>], S31, <NUM_LIT>)  <EOL>d = XX(H, d, a, b, c, inp[<NUM_LIT:8>], S32, <NUM_LIT>)  <EOL>c = XX(H, c, d, a, b, inp[<NUM_LIT:11>], S33, <NUM_LIT>)  <EOL>b = XX(H, b, c, d, a, inp[<NUM_LIT>], S34, <NUM_LIT>)  <EOL>a = XX(H, a, b, c, d, inp[<NUM_LIT:1>], S31, <NUM_LIT>)  <EOL>d = XX(H, d, a, b, c, inp[<NUM_LIT:4>], S32, <NUM_LIT>)  <EOL>c = XX(H, c, d, a, b, inp[<NUM_LIT:7>], S33, <NUM_LIT>)  <EOL>b = XX(H, b, c, d, a, inp[<NUM_LIT:10>], S34, <NUM_LIT>)  <EOL>a = XX(H, a, b, c, d, inp[<NUM_LIT>], S31, <NUM_LIT>)  <EOL>d = XX(H, d, a, b, c, inp[<NUM_LIT:0>], S32, <NUM_LIT>)  <EOL>c = XX(H, c, d, a, b, inp[<NUM_LIT:3>], S33, <NUM_LIT>)  <EOL>b = XX(H, b, c, d, a, inp[<NUM_LIT:6>], S34, <NUM_LIT>)  <EOL>a = XX(H, a, b, c, d, inp[<NUM_LIT:9>], S31, <NUM_LIT>)  <EOL>d = XX(H, d, a, b, c, inp[<NUM_LIT:12>], S32, <NUM_LIT>)  <EOL>c = XX(H, c, d, a, b, inp[<NUM_LIT:15>], S33, <NUM_LIT>)  <EOL>b = XX(H, b, c, d, a, inp[<NUM_LIT:2>], S34, <NUM_LIT>)  <EOL>S41, S42, S43, S44 = <NUM_LIT:6>, <NUM_LIT:10>, <NUM_LIT:15>, <NUM_LIT><EOL>a = XX(I, a, b, c, d, inp[<NUM_LIT:0>], S41, <NUM_LIT>)  <EOL>d = XX(I, d, a, b, c, inp[<NUM_LIT:7>], S42, <NUM_LIT>)  <EOL>c = XX(I, c, d, a, b, inp[<NUM_LIT>], S43, <NUM_LIT>)  <EOL>b = XX(I, b, c, d, a, inp[<NUM_LIT:5>], S44, <NUM_LIT>)  <EOL>a = XX(I, a, b, c, d, inp[<NUM_LIT:12>], S41, <NUM_LIT>)  <EOL>d = XX(I, d, a, b, c, inp[<NUM_LIT:3>], S42, <NUM_LIT>)  <EOL>c = XX(I, c, d, a, b, inp[<NUM_LIT:10>], S43, <NUM_LIT>)  <EOL>b = XX(I, b, c, d, a, inp[<NUM_LIT:1>], S44, <NUM_LIT>)  <EOL>a = XX(I, a, b, c, d, inp[<NUM_LIT:8>], S41, <NUM_LIT>)  <EOL>d = XX(I, d, a, b, c, inp[<NUM_LIT:15>], S42, <NUM_LIT>)  <EOL>c = XX(I, c, d, a, b, inp[<NUM_LIT:6>], S43, <NUM_LIT>)  <EOL>b = XX(I, b, c, d, a, inp[<NUM_LIT>], S44, <NUM_LIT>)  <EOL>a = XX(I, a, b, c, d, inp[<NUM_LIT:4>], S41, <NUM_LIT>)  <EOL>d = XX(I, d, a, b, c, inp[<NUM_LIT:11>], S42, <NUM_LIT>)  <EOL>c = XX(I, c, d, a, b, inp[<NUM_LIT:2>], S43, <NUM_LIT>)  <EOL>b = XX(I, b, c, d, a, inp[<NUM_LIT:9>], S44, <NUM_LIT>)  <EOL>A = (A + a) & <NUM_LIT><EOL>B = (B + b) & <NUM_LIT><EOL>C = (C + c) & <NUM_LIT><EOL>D = (D + d) & <NUM_LIT><EOL>self.A, self.B, self.C, self.D = A, B, C, D<EOL>

Basic MD5 step transforming the digest based on the input.

        Note that if the Mysterious Constants are arranged backwards
        in little-endian order and decrypted with the DES they produce
        OCCULT MESSAGES!


leninBuf = len(inBuf)<EOL>index = (self.count[<NUM_LIT:0>] >> <NUM_LIT:3>) & <NUM_LIT><EOL>self.count[<NUM_LIT:0>] = self.count[<NUM_LIT:0>] + (leninBuf << <NUM_LIT:3>)<EOL>if self.count[<NUM_LIT:0>] < (leninBuf << <NUM_LIT:3>):<EOL><INDENT>self.count[<NUM_LIT:1>] = self.count[<NUM_LIT:1>] + <NUM_LIT:1><EOL><DEDENT>self.count[<NUM_LIT:1>] = self.count[<NUM_LIT:1>] + (leninBuf >> <NUM_LIT>)<EOL>partLen = <NUM_LIT:64> - index<EOL>if leninBuf >= partLen:<EOL><INDENT>self.input[index:] = list(inBuf[:partLen])<EOL>self._transform(_bytelist2long(self.input))<EOL>i = partLen<EOL>while i + <NUM_LIT> < leninBuf:<EOL><INDENT>self._transform(_bytelist2long(list(inBuf[i:i + <NUM_LIT:64>])))<EOL>i = i + <NUM_LIT:64><EOL><DEDENT>else:<EOL><INDENT>self.input = list(inBuf[i:leninBuf])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i = <NUM_LIT:0><EOL>self.input = self.input + list(inBuf)<EOL><DEDENT>

Add to the current message.

        Update the md5 object with the string arg. Repeated calls
        are equivalent to a single call with the concatenation of all
        the arguments, i.e. m.update(a); m.update(b) is equivalent
        to m.update(a+b).

        The hash is immediately calculated for all full blocks. The final
        calculation is made in digest(). This allows us to keep an
        intermediate value for the hash, so that we only need to make
        minimal recalculation if we call update() to add moredata to
        the hashed string.


A = self.A<EOL>B = self.B<EOL>C = self.C<EOL>D = self.D<EOL>input = [] + self.input<EOL>count = [] + self.count<EOL>index = (self.count[<NUM_LIT:0>] >> <NUM_LIT:3>) & <NUM_LIT><EOL>if index < <NUM_LIT>:<EOL><INDENT>padLen = <NUM_LIT> - index<EOL><DEDENT>else:<EOL><INDENT>padLen = <NUM_LIT> - index<EOL><DEDENT>padding = [b'<STR_LIT>'] + [b'<STR_LIT>'] * <NUM_LIT><EOL>self.update(padding[:padLen])<EOL>bits = _bytelist2long(self.input[:<NUM_LIT>]) + count<EOL>self._transform(bits)<EOL>digest = struct.pack("<STR_LIT>", self.A, self.B, self.C, self.D)<EOL>self.A = A<EOL>self.B = B<EOL>self.C = C<EOL>self.D = D<EOL>self.input = input<EOL>self.count = count<EOL>return digest<EOL>

Terminate the message-digest computation and return digest.

        Return the digest of the strings passed to the update()
        method so far. This is a 16-byte string which may contain
        non-ASCII characters, including null bytes.


return '<STR_LIT>'.join([('<STR_LIT:0>' + hex(ord(c))[<NUM_LIT:2>:])[-<NUM_LIT:2>:] for c in self.digest()])<EOL>

Terminate and return digest in HEX form.

        Like digest() except the digest is returned as a string of
        length 32, containing only hexadecimal digits. This may be
        used to exchange the value safely in email or other non-
        binary environments.


if <NUM_LIT:0>:  <EOL><INDENT>return copy.deepcopy(self)<EOL><DEDENT>clone = self.__class__()<EOL>clone.length = self.length<EOL>clone.count = [] + self.count[:]<EOL>clone.input = [] + self.input<EOL>clone.A = self.A<EOL>clone.B = self.B<EOL>clone.C = self.C<EOL>clone.D = self.D<EOL>return clone<EOL>

Return a clone object.

        Return a copy ('clone') of the md5 object. This can be used
        to efficiently compute the digests of strings that share
        a common initial substring.


def register_dialect(name, dialect=None, **kwargs):

if not isinstance(name, basestring):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>dialect = _call_dialect(dialect, kwargs)<EOL>_dialects[name] = dialect<EOL>

Create a mapping from a string name to a dialect class.
    dialect = csv.register_dialect(name, dialect)


try:<EOL><INDENT>del _dialects[name]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise Error("<STR_LIT>")<EOL><DEDENT>

Delete the name/dialect mapping associated with a string name.\n
    csv.unregister_dialect(name)


try:<EOL><INDENT>return _dialects[name]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise Error("<STR_LIT>")<EOL><DEDENT>

Return the dialect instance associated with name.
    dialect = csv.get_dialect(name)


return list(_dialects)<EOL>

Return a list of all know dialect names
    names = csv.list_dialects()


return Reader(*args, **kwargs)<EOL>

csv_reader = reader(iterable [, dialect='excel']
                   [optional keyword args])
for row in csv_reader:
    process(row)

The "iterable" argument can be any object that returns a line
of input for each iteration, such as a file object or a list.  The
optional \"dialect\" parameter is discussed below.  The function
also accepts optional keyword arguments which override settings
provided by the dialect.

The returned object is an iterator.  Each iteration returns a row
of the CSV file (which can span multiple input lines)


return Writer(*args, **kwargs)<EOL>

csv_writer = csv.writer(fileobj [, dialect='excel']
                        [optional keyword args])
for row in sequence:
    csv_writer.writerow(row)

[or]

csv_writer = csv.writer(fileobj [, dialect='excel']
                        [optional keyword args])
csv_writer.writerows(rows)

The \"fileobj\" argument can be any object that supports the file API.


global _field_limit<EOL>old_limit = _field_limit<EOL>if limit is not undefined:<EOL><INDENT>if not isinstance(limit, (int, long)):<EOL><INDENT>raise TypeError("<STR_LIT>" %<EOL>(limit.__class__.__name__,))<EOL><DEDENT>_field_limit = limit<EOL><DEDENT>return old_limit<EOL>

Sets an upper limit on parsed fields.
    csv.field_size_limit([limit])

    Returns old limit. If limit is not given, no new limit is set and
    the old limit is returned


def compile(pattern, flags, code, groups=<NUM_LIT:0>, groupindex={}, indexgroup=[None]):

return SRE_Pattern(pattern, flags, code, groups, groupindex, indexgroup)<EOL>

Compiles (or rather just converts) a pattern descriptor to a SRE_Pattern
    object. Actual compilation to opcodes happens in sre_compile.


def match(self, string, pos=<NUM_LIT:0>, endpos=sys.maxsize):

state = _State(string, pos, endpos, self.flags)<EOL>if state.match(self._code):<EOL><INDENT>return SRE_Match(self, state)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

If zero or more characters at the beginning of string match this
        regular expression, return a corresponding MatchObject instance. Return
        None if the string does not match the pattern.


def search(self, string, pos=<NUM_LIT:0>, endpos=sys.maxsize):

state = _State(string, pos, endpos, self.flags)<EOL>if state.search(self._code):<EOL><INDENT>return SRE_Match(self, state)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Scan through string looking for a location where this regular
        expression produces a match, and return a corresponding MatchObject
        instance. Return None if no position in the string matches the
        pattern.


def findall(self, string, pos=<NUM_LIT:0>, endpos=sys.maxsize):

matchlist = []<EOL>state = _State(string, pos, endpos, self.flags)<EOL>while state.start <= state.end:<EOL><INDENT>state.reset()<EOL>state.string_position = state.start<EOL>if not state.search(self._code):<EOL><INDENT>break<EOL><DEDENT>match = SRE_Match(self, state)<EOL>if self.groups == <NUM_LIT:0> or self.groups == <NUM_LIT:1>:<EOL><INDENT>item = match.group(self.groups)<EOL><DEDENT>else:<EOL><INDENT>item = match.groups("<STR_LIT>")<EOL><DEDENT>matchlist.append(item)<EOL>if state.string_position == state.start:<EOL><INDENT>state.start += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>state.start = state.string_position<EOL><DEDENT><DEDENT>return matchlist<EOL>

Return a list of all non-overlapping matches of pattern in string.


def sub(self, repl, string, count=<NUM_LIT:0>):

return self._subx(repl, string, count, False)<EOL>

Return the string obtained by replacing the leftmost non-overlapping
        occurrences of pattern in string by the replacement repl.


def subn(self, repl, string, count=<NUM_LIT:0>):

return self._subx(repl, string, count, True)<EOL>

Return the tuple (new_string, number_of_subs_made) found by replacing
        the leftmost non-overlapping occurrences of pattern with the replacement
        repl.


def split(self, string, maxsplit=<NUM_LIT:0>):

splitlist = []<EOL>state = _State(string, <NUM_LIT:0>, sys.maxsize, self.flags)<EOL>n = <NUM_LIT:0><EOL>last = state.start<EOL>while not maxsplit or n < maxsplit:<EOL><INDENT>state.reset()<EOL>state.string_position = state.start<EOL>if not state.search(self._code):<EOL><INDENT>break<EOL><DEDENT>if state.start == state.string_position: <EOL><INDENT>if last == state.end:                <EOL><INDENT>break<EOL><DEDENT>state.start += <NUM_LIT:1><EOL>continue<EOL><DEDENT>splitlist.append(string[last:state.start])<EOL>if self.groups:<EOL><INDENT>match = SRE_Match(self, state)<EOL>splitlist += (list(match.groups(None)))<EOL><DEDENT>n += <NUM_LIT:1><EOL>last = state.start = state.string_position<EOL><DEDENT>splitlist.append(string[last:state.end])<EOL>return splitlist<EOL>

Split string by the occurrences of pattern.


def finditer(self, string, pos=<NUM_LIT:0>, endpos=sys.maxsize):

scanner = self.scanner(string, pos, endpos)<EOL>return iter(scanner.search, None)<EOL>


regs = [(state.start, state.string_position)]<EOL>for group in range(self.re.groups):<EOL><INDENT>mark_index = <NUM_LIT:2> * group<EOL>if mark_index + <NUM_LIT:1> < len(state.marks)and state.marks[mark_index] is not Noneand state.marks[mark_index + <NUM_LIT:1>] is not None:<EOL><INDENT>regs.append((state.marks[mark_index], state.marks[mark_index + <NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>regs.append((-<NUM_LIT:1>, -<NUM_LIT:1>))<EOL><DEDENT><DEDENT>return tuple(regs)<EOL>

Creates a tuple of index pairs representing matched groups.


return self.regs[self._get_index(group)][<NUM_LIT:0>]<EOL>

Returns the indices of the start of the substring matched by group;
        group defaults to zero (meaning the whole matched substring). Returns -1
        if group exists but did not contribute to the match.


return self.regs[self._get_index(group)][<NUM_LIT:1>]<EOL>

Returns the indices of the end of the substring matched by group;
        group defaults to zero (meaning the whole matched substring). Returns -1
        if group exists but did not contribute to the match.


return self.start(group), self.end(group)<EOL>

Returns the 2-tuple (m.start(group), m.end(group)).


raise NotImplementedError<EOL>

Return the string obtained by doing backslash substitution and
        resolving group references on template.


groups = []<EOL>for indices in self.regs[<NUM_LIT:1>:]:<EOL><INDENT>if indices[<NUM_LIT:0>] >= <NUM_LIT:0>:<EOL><INDENT>groups.append(self.string[indices[<NUM_LIT:0>]:indices[<NUM_LIT:1>]])<EOL><DEDENT>else:<EOL><INDENT>groups.append(default)<EOL><DEDENT><DEDENT>return tuple(groups)<EOL>

Returns a tuple containing all the subgroups of the match. The
        default argument is used for groups that did not participate in the
        match (defaults to None).


groupdict = {}<EOL>for key, value in list(self.re.groupindex.items()):<EOL><INDENT>groupdict[key] = self._get_slice(value, default)<EOL><DEDENT>return groupdict<EOL>

Return a dictionary containing all the named subgroups of the match.
        The default argument is used for groups that did not participate in the
        match (defaults to None).


if len(args) == <NUM_LIT:0>:<EOL><INDENT>args = (<NUM_LIT:0>,)<EOL><DEDENT>grouplist = []<EOL>for group in args:<EOL><INDENT>grouplist.append(self._get_slice(self._get_index(group), None))<EOL><DEDENT>if len(grouplist) == <NUM_LIT:1>:<EOL><INDENT>return grouplist[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return tuple(grouplist)<EOL><DEDENT>

Returns one or more subgroups of the match. Each argument is either a
        group index or a group name.


<EOL>flags = pattern_codes[<NUM_LIT:2>]<EOL>prefix_len = pattern_codes[<NUM_LIT:5>]<EOL>prefix_skip = pattern_codes[<NUM_LIT:6>] <EOL>prefix = pattern_codes[<NUM_LIT:7>:<NUM_LIT:7> + prefix_len]<EOL>overlap = pattern_codes[<NUM_LIT:7> + prefix_len - <NUM_LIT:1>:pattern_codes[<NUM_LIT:1>] + <NUM_LIT:1>]<EOL>pattern_codes = pattern_codes[pattern_codes[<NUM_LIT:1>] + <NUM_LIT:1>:]<EOL>i = <NUM_LIT:0><EOL>string_position = self.string_position<EOL>while string_position < self.end:<EOL><INDENT>while True:<EOL><INDENT>if ord(self.string[string_position]) != prefix[i]:<EOL><INDENT>if i == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>i = overlap[i]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL>if i == prefix_len:<EOL><INDENT>self.start = string_position + <NUM_LIT:1> - prefix_len<EOL>self.string_position = string_position + <NUM_LIT:1>- prefix_len + prefix_skip<EOL>if flags & SRE_INFO_LITERAL:<EOL><INDENT>return True <EOL><DEDENT>if self.match(pattern_codes[<NUM_LIT:2> * prefix_skip:]):<EOL><INDENT>return True<EOL><DEDENT>i = overlap[i]<EOL><DEDENT>break<EOL><DEDENT><DEDENT>string_position += <NUM_LIT:1><EOL><DEDENT>return False<EOL>

Skips forward in a string as fast as possible using information from
        an optimization info block.


child_context = _MatchContext(self.state,<EOL>self.pattern_codes[self.code_position + pattern_offset:])<EOL>self.state.context_stack.append(child_context)<EOL>return child_context<EOL>

Creates a new child context of this context and pushes it on the
        stack. pattern_offset is the offset off the current code position to
        start interpreting from.


while context.remaining_codes() > <NUM_LIT:0> and context.has_matched is None:<EOL><INDENT>opcode = context.peek_code()<EOL>if not self.dispatch(opcode, context):<EOL><INDENT>return None<EOL><DEDENT><DEDENT>if context.has_matched is None:<EOL><INDENT>context.has_matched = False<EOL><DEDENT>return context.has_matched<EOL>

Returns True if the current context matches, False if it doesn't and
        None if matching is not finished, ie must be resumed after child
        contexts have been matched.


if id(context) in self.executing_contexts:<EOL><INDENT>generator = self.executing_contexts[id(context)]<EOL>del self.executing_contexts[id(context)]<EOL>has_finished = next(generator)<EOL><DEDENT>else:<EOL><INDENT>method = self.DISPATCH_TABLE.get(opcode, _OpcodeDispatcher.unknown)<EOL>has_finished = method(self, context)<EOL>if hasattr(has_finished, "<STR_LIT>"): <EOL><INDENT>generator = has_finished<EOL>has_finished = next(generator)<EOL><DEDENT><DEDENT>if not has_finished:<EOL><INDENT>self.executing_contexts[id(context)] = generator<EOL><DEDENT>return has_finished<EOL>

Dispatches a context on a given opcode. Returns True if the context
        is done matching, False if it must be resumed when next encountered.


self.set_dispatcher.reset(char)<EOL>save_position = ctx.code_position<EOL>result = None<EOL>while result is None:<EOL><INDENT>result = self.set_dispatcher.dispatch(ctx.peek_code(), ctx)<EOL><DEDENT>ctx.code_position = save_position<EOL>return result<EOL>

Checks whether a character matches set of arbitrary length. Assumes
        the code pointer is at the first member of the set.


def count_repetitions(self, ctx, maxcount):

count = <NUM_LIT:0><EOL>real_maxcount = ctx.state.end - ctx.string_position<EOL>if maxcount < real_maxcount and maxcount != MAXREPEAT:<EOL><INDENT>real_maxcount = maxcount<EOL><DEDENT>code_position = ctx.code_position<EOL>string_position = ctx.string_position<EOL>ctx.skip_code(<NUM_LIT:4>)<EOL>reset_position = ctx.code_position<EOL>while count < real_maxcount:<EOL><INDENT>ctx.code_position = reset_position<EOL>self.dispatch(ctx.peek_code(), ctx)<EOL>if ctx.has_matched is False: <EOL><INDENT>break<EOL><DEDENT>count += <NUM_LIT:1><EOL><DEDENT>ctx.has_matched = None<EOL>ctx.code_position = code_position<EOL>ctx.string_position = string_position<EOL>return count<EOL>

Returns the number of repetitions of a single item, starting from the
        current string position. The code pointer is expected to point to a
        REPEAT_ONE operation (with the repeated 4 ahead).


return year % <NUM_LIT:4> == <NUM_LIT:0> and (year % <NUM_LIT:100> != <NUM_LIT:0> or year % <NUM_LIT> == <NUM_LIT:0>)<EOL>


y = year - <NUM_LIT:1><EOL>return y*<NUM_LIT> + y//<NUM_LIT:4> - y//<NUM_LIT:100> + y//<NUM_LIT><EOL>

year -> number of days before January 1st of year.


assert <NUM_LIT:1> <= month <= <NUM_LIT:12>, month<EOL>if month == <NUM_LIT:2> and _is_leap(year):<EOL><INDENT>return <NUM_LIT><EOL><DEDENT>return _DAYS_IN_MONTH[month]<EOL>

year, month -> number of days in that month in that year.


assert <NUM_LIT:1> <= month <= <NUM_LIT:12>, '<STR_LIT>'<EOL>return _DAYS_BEFORE_MONTH[month] + (month > <NUM_LIT:2> and _is_leap(year))<EOL>

year, month -> number of days in year preceding first day of month.


assert <NUM_LIT:1> <= month <= <NUM_LIT:12>, '<STR_LIT>'<EOL>dim = _days_in_month(year, month)<EOL>assert <NUM_LIT:1> <= day <= dim, ('<STR_LIT>' % dim)<EOL>return (_days_before_year(year) +<EOL>_days_before_month(year, month) +<EOL>day)<EOL>

year, month, day -> ordinal, considering 01-Jan-0001 as day 1.


<EOL>n -= <NUM_LIT:1><EOL>n400, n = divmod(n, _DI400Y)<EOL>year = n400 * <NUM_LIT> + <NUM_LIT:1>   <EOL>n100, n = divmod(n, _DI100Y)<EOL>n4, n = divmod(n, _DI4Y)<EOL>n1, n = divmod(n, <NUM_LIT>)<EOL>year += n100 * <NUM_LIT:100> + n4 * <NUM_LIT:4> + n1<EOL>if n1 == <NUM_LIT:4> or n100 == <NUM_LIT:4>:<EOL><INDENT>assert n == <NUM_LIT:0><EOL>return year-<NUM_LIT:1>, <NUM_LIT:12>, <NUM_LIT><EOL><DEDENT>leapyear = n1 == <NUM_LIT:3> and (n4 != <NUM_LIT> or n100 == <NUM_LIT:3>)<EOL>assert leapyear == _is_leap(year)<EOL>month = (n + <NUM_LIT:50>) >> <NUM_LIT:5><EOL>preceding = _DAYS_BEFORE_MONTH[month] + (month > <NUM_LIT:2> and leapyear)<EOL>if preceding > n:  <EOL><INDENT>month -= <NUM_LIT:1><EOL>preceding -= _DAYS_IN_MONTH[month] + (month == <NUM_LIT:2> and leapyear)<EOL><DEDENT>n -= preceding<EOL>assert <NUM_LIT:0> <= n < _days_in_month(year, month)<EOL>return year, month, n+<NUM_LIT:1><EOL>

ordinal -> (year, month, day), considering 01-Jan-0001 as day 1.


<EOL>return float(self._to_microseconds()) / float(<NUM_LIT:10>**<NUM_LIT:6>)<EOL>


return self._days<EOL>


return self._seconds<EOL>


return self._microseconds<EOL>


def __new__(cls, year, month=None, day=None):

<EOL>year, month, day = _check_date_fields(year, month, day)<EOL>self = object.__new__(cls)<EOL>self._year = year<EOL>self._month = month<EOL>self._day = day<EOL>self._hashcode = -<NUM_LIT:1><EOL>return self<EOL>

Constructor.

        Arguments:

        year, month, day (required, base 1)


y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t)<EOL>return cls(y, m, d)<EOL>

Construct a date from a POSIX timestamp (like time.time()).


t = _time.time()<EOL>return cls.fromtimestamp(t)<EOL>


y, m, d = _ord2ymd(n)<EOL>return cls(y, m, d)<EOL>

Contruct a date from a proleptic Gregorian ordinal.

        January 1 of year 1 is day 1.  Only the year, month and day are
        non-zero in the result.


module = "<STR_LIT>" if self.__class__ is date else "<STR_LIT>"<EOL>return "<STR_LIT>" % (module + self.__class__.__name__,<EOL>self._year,<EOL>self._month,<EOL>self._day)<EOL>

Convert to formal string, for repr().

        >>> dt = datetime(2010, 1, 1)
        >>> repr(dt)
        'datetime.datetime(2010, 1, 1, 0, 0)'

        >>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc)
        >>> repr(dt)
        'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)'


weekday = self.toordinal() % <NUM_LIT:7> or <NUM_LIT:7><EOL>return "<STR_LIT>" % (<EOL>_DAYNAMES[weekday],<EOL>_MONTHNAMES[self._month],<EOL>self._day, self._year)<EOL>


<EOL>return "<STR_LIT>" % (str(self._year).zfill(<NUM_LIT:4>), str(self._month).zfill(<NUM_LIT:2>), str(self._day).zfill(<NUM_LIT:2>))<EOL>

Return the date formatted according to ISO.

        This is 'YYYY-MM-DD'.

        References:
        - http://www.w3.org/TR/NOTE-datetime
        - http://www.cl.cam.ac.uk/~mgk25/iso-time.html


return self._year<EOL>


return self._month<EOL>


return self._day<EOL>


return _build_struct_time(self._year, self._month, self._day,<EOL><NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, -<NUM_LIT:1>)<EOL>

Return local time tuple compatible with time.localtime().


return _ymd2ord(self._year, self._month, self._day)<EOL>

Return proleptic Gregorian ordinal for the year, month and day.

        January 1 of year 1 is day 1.  Only the year, month and day values
        contribute to the result.


def replace(self, year=None, month=None, day=None):

if year is None:<EOL><INDENT>year = self._year<EOL><DEDENT>if month is None:<EOL><INDENT>month = self._month<EOL><DEDENT>if day is None:<EOL><INDENT>day = self._day<EOL><DEDENT>return date.__new__(type(self), year, month, day)<EOL>

Return a new date with new values for the specified fields.


if self._hashcode == -<NUM_LIT:1>:<EOL><INDENT>self._hashcode = hash(self._getstate())<EOL><DEDENT>return self._hashcode<EOL>


if isinstance(other, timedelta):<EOL><INDENT>return self._add_timedelta(other, <NUM_LIT:1>)<EOL><DEDENT>return NotImplemented<EOL>


if isinstance(other, date):<EOL><INDENT>days1 = self.toordinal()<EOL>days2 = other.toordinal()<EOL>return timedelta._create(days1 - days2, <NUM_LIT:0>, <NUM_LIT:0>, False)<EOL><DEDENT>if isinstance(other, timedelta):<EOL><INDENT>return self._add_timedelta(other, -<NUM_LIT:1>)<EOL><DEDENT>return NotImplemented<EOL>

Subtract two dates, or a date and a timedelta.


return (self.toordinal() + <NUM_LIT:6>) % <NUM_LIT:7><EOL>

Return day of the week, where Monday == 0 ... Sunday == 6.


<EOL>return self.toordinal() % <NUM_LIT:7> or <NUM_LIT:7><EOL>

Return day of the week, where Monday == 1 ... Sunday == 7.


year = self._year<EOL>week1monday = _isoweek1monday(year)<EOL>today = _ymd2ord(self._year, self._month, self._day)<EOL>week, day = divmod(today - week1monday, <NUM_LIT:7>)<EOL>if week < <NUM_LIT:0>:<EOL><INDENT>year -= <NUM_LIT:1><EOL>week1monday = _isoweek1monday(year)<EOL>week, day = divmod(today - week1monday, <NUM_LIT:7>)<EOL><DEDENT>elif week >= <NUM_LIT>:<EOL><INDENT>if today >= _isoweek1monday(year+<NUM_LIT:1>):<EOL><INDENT>year += <NUM_LIT:1><EOL>week = <NUM_LIT:0><EOL><DEDENT><DEDENT>return year, week+<NUM_LIT:1>, day+<NUM_LIT:1><EOL>

Return a 3-tuple containing ISO year, week number, and weekday.

        The first ISO week of the year is the (Mon-Sun) week
        containing the year's first Thursday; everything else derives
        from that.

        The first week is 1; Monday is 1 ... Sunday is 7.

        ISO calendar algorithm taken from
        http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm


raise NotImplementedError("<STR_LIT>")<EOL>


datetime -> minutes east of UTC (negative for west of UTC)


datetime -> DST offset in minutes east of UTC.

        Return 0 if DST not in effect.  utcoffset() must include the DST
        offset.


if not isinstance(dt, datetime):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if dt.tzinfo is not self:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>dtoff = dt.utcoffset()<EOL>if dtoff is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT:result>")<EOL><DEDENT>dtdst = dt.dst()<EOL>if dtdst is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>delta = dtoff - dtdst<EOL>if delta:<EOL><INDENT>dt += delta<EOL>dtdst = dt.dst()<EOL>if dtdst is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if dtdst:<EOL><INDENT>return dt + dtdst<EOL><DEDENT>else:<EOL><INDENT>return dt<EOL><DEDENT>

datetime in UTC -> datetime in local time.


def __new__(cls, hour=<NUM_LIT:0>, minute=<NUM_LIT:0>, second=<NUM_LIT:0>, microsecond=<NUM_LIT:0>, tzinfo=None):

<EOL>hour, minute, second, microsecond = _check_time_fields(<EOL>hour, minute, second, microsecond)<EOL>_check_tzinfo_arg(tzinfo)<EOL>self = object.__new__(cls)<EOL>self._hour = hour<EOL>self._minute = minute<EOL>self._second = second<EOL>self._microsecond = microsecond<EOL>self._tzinfo = tzinfo<EOL>self._hashcode = -<NUM_LIT:1><EOL>return self<EOL>

Constructor.

        Arguments:

        hour, minute (required)
        second, microsecond (default to zero)
        tzinfo (default to None)


return self._hour<EOL>


return self._minute<EOL>


return self._second<EOL>


return self._microsecond<EOL>


return self._tzinfo<EOL>


if self._hashcode == -<NUM_LIT:1>:<EOL><INDENT>tzoff = self._utcoffset()<EOL>if not tzoff:  <EOL><INDENT>self._hashcode = hash(self._getstate()[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>h, m = divmod(self.hour * <NUM_LIT> + self.minute - tzoff, <NUM_LIT>)<EOL>if <NUM_LIT:0> <= h < <NUM_LIT>:<EOL><INDENT>self._hashcode = hash(time(h, m, self.second, self.microsecond))<EOL><DEDENT>else:<EOL><INDENT>self._hashcode = hash((h, m, self.second, self.microsecond))<EOL><DEDENT><DEDENT><DEDENT>return self._hashcode<EOL>


off = self._utcoffset()<EOL>if off is not None:<EOL><INDENT>if off < <NUM_LIT:0>:<EOL><INDENT>sign = "<STR_LIT:->"<EOL>off = -off<EOL><DEDENT>else:<EOL><INDENT>sign = "<STR_LIT:+>"<EOL><DEDENT>hh, mm = divmod(off, <NUM_LIT>)<EOL>assert <NUM_LIT:0> <= hh < <NUM_LIT><EOL>off = "<STR_LIT>" % (sign, hh, sep, mm)<EOL><DEDENT>return off<EOL>

Return formatted timezone offset (+xx:xx) or None.


if self._microsecond != <NUM_LIT:0>:<EOL><INDENT>s = "<STR_LIT>" % (self._second, self._microsecond)<EOL><DEDENT>elif self._second != <NUM_LIT:0>:<EOL><INDENT>s = "<STR_LIT>" % self._second<EOL><DEDENT>else:<EOL><INDENT>s = "<STR_LIT>"<EOL><DEDENT>module = "<STR_LIT>" if self.__class__ is time else "<STR_LIT>"<EOL>s= "<STR_LIT>" % (module + self.__class__.__name__,<EOL>self._hour, self._minute, s)<EOL>if self._tzinfo is not None:<EOL><INDENT>assert s[-<NUM_LIT:1>:] == "<STR_LIT:)>"<EOL>s = s[:-<NUM_LIT:1>] + "<STR_LIT>" % self._tzinfo + "<STR_LIT:)>"<EOL><DEDENT>return s<EOL>


s = _format_time(self._hour, self._minute, self._second,<EOL>self._microsecond)<EOL>tz = self._tzstr()<EOL>if tz:<EOL><INDENT>s += tz<EOL><DEDENT>return s<EOL>

Return the time formatted according to ISO.

        This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
        self.microsecond == 0.


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>offset = self._tzinfo.utcoffset(None)<EOL>offset = _check_utc_offset("<STR_LIT>", offset)<EOL>if offset is not None:<EOL><INDENT>offset = timedelta._create(<NUM_LIT:0>, offset * <NUM_LIT>, <NUM_LIT:0>, True)<EOL><DEDENT>return offset<EOL>

Return the timezone offset in minutes east of UTC (negative west of
        UTC).


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>name = self._tzinfo.tzname(None)<EOL>_check_tzname(name)<EOL>return name<EOL>

Return the timezone name.

        Note that the name is 100% informational -- there's no requirement that
        it mean anything in particular. For example, "GMT", "UTC", "-500",
        "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>offset = self._tzinfo.dst(None)<EOL>offset = _check_utc_offset("<STR_LIT>", offset)<EOL>if offset is not None:<EOL><INDENT>offset = timedelta._create(<NUM_LIT:0>, offset * <NUM_LIT>, <NUM_LIT:0>, True)<EOL><DEDENT>return offset<EOL>

Return 0 if DST is not in effect, or the DST offset (in minutes
        eastward) if DST is in effect.

        This is purely informational; the DST offset has already been added to
        the UTC offset returned by utcoffset() if applicable, so there's no
        need to consult dst() unless you're interested in displaying the DST
        info.


def replace(self, hour=None, minute=None, second=None, microsecond=None,<EOL>tzinfo=True):

if hour is None:<EOL><INDENT>hour = self.hour<EOL><DEDENT>if minute is None:<EOL><INDENT>minute = self.minute<EOL><DEDENT>if second is None:<EOL><INDENT>second = self.second<EOL><DEDENT>if microsecond is None:<EOL><INDENT>microsecond = self.microsecond<EOL><DEDENT>if tzinfo is True:<EOL><INDENT>tzinfo = self.tzinfo<EOL><DEDENT>return time.__new__(type(self),<EOL>hour, minute, second, microsecond, tzinfo)<EOL>

Return a new time with new values for the specified fields.


@classmethod<EOL><INDENT>def fromtimestamp(cls, timestamp, tz=None):<DEDENT>

_check_tzinfo_arg(tz)<EOL>converter = _time.localtime if tz is None else _time.gmtime<EOL>self = cls._from_timestamp(converter, timestamp, tz)<EOL>if tz is not None:<EOL><INDENT>self = tz.fromutc(self)<EOL><DEDENT>return self<EOL>

Construct a datetime from a POSIX timestamp (like time.time()).

        A timezone info object may be passed in as well.


return cls._from_timestamp(_time.gmtime, t, None)<EOL>

Construct a UTC datetime from a POSIX timestamp (like time.time()).


t = _time.time()<EOL>return cls.fromtimestamp(t, tz)<EOL>

Construct a datetime from time.time() and optional time zone info.


t = _time.time()<EOL>return cls.utcfromtimestamp(t)<EOL>

Construct a UTC datetime from time.time().


@classmethod<EOL><INDENT>def combine(cls, date, time):<DEDENT>

if not isinstance(date, _date_class):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if not isinstance(time, _time_class):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>return cls(date.year, date.month, date.day,<EOL>time.hour, time.minute, time.second, time.microsecond,<EOL>time.tzinfo)<EOL>

Construct a datetime from a given date and a given time.


dst = self._dst()<EOL>if dst is None:<EOL><INDENT>dst = -<NUM_LIT:1><EOL><DEDENT>elif dst:<EOL><INDENT>dst = <NUM_LIT:1><EOL><DEDENT>return _build_struct_time(self.year, self.month, self.day,<EOL>self.hour, self.minute, self.second,<EOL>dst)<EOL>

Return local time tuple compatible with time.localtime().


y, m, d = self.year, self.month, self.day<EOL>hh, mm, ss = self.hour, self.minute, self.second<EOL>offset = self._utcoffset()<EOL>if offset:  <EOL><INDENT>mm -= offset<EOL>y, m, d, hh, mm, ss, _ = _normalize_datetime(<EOL>y, m, d, hh, mm, ss, <NUM_LIT:0>, ignore_overflow=True)<EOL><DEDENT>return _build_struct_time(y, m, d, hh, mm, ss, <NUM_LIT:0>)<EOL>

Return UTC time tuple compatible with time.gmtime().


return date(self._year, self._month, self._day)<EOL>


return time(self.hour, self.minute, self.second, self.microsecond)<EOL>


return time(self.hour, self.minute, self.second, self.microsecond,<EOL>self._tzinfo)<EOL>


def replace(self, year=None, month=None, day=None, hour=None,<EOL>minute=None, second=None, microsecond=None, tzinfo=True):

if year is None:<EOL><INDENT>year = self.year<EOL><DEDENT>if month is None:<EOL><INDENT>month = self.month<EOL><DEDENT>if day is None:<EOL><INDENT>day = self.day<EOL><DEDENT>if hour is None:<EOL><INDENT>hour = self.hour<EOL><DEDENT>if minute is None:<EOL><INDENT>minute = self.minute<EOL><DEDENT>if second is None:<EOL><INDENT>second = self.second<EOL><DEDENT>if microsecond is None:<EOL><INDENT>microsecond = self.microsecond<EOL><DEDENT>if tzinfo is True:<EOL><INDENT>tzinfo = self.tzinfo<EOL><DEDENT>return datetime.__new__(type(self),<EOL>year, month, day, hour, minute, second,<EOL>microsecond, tzinfo)<EOL>

Return a new datetime with new values for the specified fields.


weekday = self.toordinal() % <NUM_LIT:7> or <NUM_LIT:7><EOL>return "<STR_LIT>" % (<EOL>_DAYNAMES[weekday],<EOL>_MONTHNAMES[self._month],<EOL>self._day,<EOL>self._hour, self._minute, self._second,<EOL>self._year)<EOL>


s = ("<STR_LIT>" % (self._year, self._month, self._day, sep) +<EOL>_format_time(self._hour, self._minute, self._second,<EOL>self._microsecond))<EOL>off = self._utcoffset()<EOL>if off is not None:<EOL><INDENT>if off < <NUM_LIT:0>:<EOL><INDENT>sign = "<STR_LIT:->"<EOL>off = -off<EOL><DEDENT>else:<EOL><INDENT>sign = "<STR_LIT:+>"<EOL><DEDENT>hh, mm = divmod(off, <NUM_LIT>)<EOL>s += "<STR_LIT>" % (sign, hh, mm)<EOL><DEDENT>return s<EOL>

Return the time formatted according to ISO.

        This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if
        self.microsecond == 0.

        If self.tzinfo is not None, the UTC offset is also attached, giving
        'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'.

        Optional argument sep specifies the separator between date and
        time, default 'T'.


L = [self._year, self._month, self._day,  <EOL>self._hour, self._minute, self._second, self._microsecond]<EOL>if L[-<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>del L[-<NUM_LIT:1>]<EOL><DEDENT>if L[-<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>del L[-<NUM_LIT:1>]<EOL><DEDENT>s = "<STR_LIT:U+002CU+0020>".join(map(str, L))<EOL>module = "<STR_LIT>" if self.__class__ is datetime else "<STR_LIT>"<EOL>s = "<STR_LIT>" % (module + self.__class__.__name__, s)<EOL>if self._tzinfo is not None:<EOL><INDENT>assert s[-<NUM_LIT:1>:] == "<STR_LIT:)>"<EOL>s = s[:-<NUM_LIT:1>] + "<STR_LIT>" % self._tzinfo + "<STR_LIT:)>"<EOL><DEDENT>return s<EOL>


return self.isoformat(sep='<STR_LIT:U+0020>')<EOL>


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>offset = self._tzinfo.utcoffset(self)<EOL>offset = _check_utc_offset("<STR_LIT>", offset)<EOL>if offset is not None:<EOL><INDENT>offset = timedelta._create(<NUM_LIT:0>, offset * <NUM_LIT>, <NUM_LIT:0>, True)<EOL><DEDENT>return offset<EOL>


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>name = self._tzinfo.tzname(self)<EOL>_check_tzname(name)<EOL>return name<EOL>


if self._tzinfo is None:<EOL><INDENT>return None<EOL><DEDENT>offset = self._tzinfo.dst(self)<EOL>offset = _check_utc_offset("<STR_LIT>", offset)<EOL>if offset is not None:<EOL><INDENT>offset = timedelta._create(<NUM_LIT:0>, offset * <NUM_LIT>, <NUM_LIT:0>, True)<EOL><DEDENT>return offset<EOL>


if not isinstance(other, timedelta):<EOL><INDENT>return NotImplemented<EOL><DEDENT>return self._add_timedelta(other, <NUM_LIT:1>)<EOL>


if not isinstance(other, datetime):<EOL><INDENT>if isinstance(other, timedelta):<EOL><INDENT>return self._add_timedelta(other, -<NUM_LIT:1>)<EOL><DEDENT>return NotImplemented<EOL><DEDENT>delta_d = self.toordinal() - other.toordinal()<EOL>delta_s = (self._hour - other._hour) * <NUM_LIT> +(self._minute - other._minute) * <NUM_LIT> +(self._second - other._second)<EOL>delta_us = self._microsecond - other._microsecond<EOL>base = timedelta._create(delta_d, delta_s, delta_us, True)<EOL>if self._tzinfo is other._tzinfo:<EOL><INDENT>return base<EOL><DEDENT>myoff = self._utcoffset()<EOL>otoff = other._utcoffset()<EOL>if myoff == otoff:<EOL><INDENT>return base<EOL><DEDENT>if myoff is None or otoff is None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>return base + timedelta(minutes = otoff-myoff)<EOL>

Subtract two datetimes, or a datetime and a timedelta.


<EOL>s = b'<STR_LIT>'<EOL>pack = struct.pack<EOL>while n > <NUM_LIT:0>:<EOL><INDENT>s = pack('<STR_LIT>', n & <NUM_LIT>) + s<EOL>n = n >> <NUM_LIT:32><EOL><DEDENT>for i in range(len(s)):<EOL><INDENT>if s[i] != '<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>s = '<STR_LIT>'<EOL>i = <NUM_LIT:0><EOL><DEDENT>s = s[i:]<EOL>if blocksize > <NUM_LIT:0> and len(s) % blocksize:<EOL><INDENT>s = (blocksize - len(s) % blocksize) * '<STR_LIT>' + s<EOL><DEDENT>return s<EOL>

Convert a long integer to a byte string.

    If optional blocksize is given and greater than zero, pad the front
    of the byte string with binary zeros so that the length is a multiple
    of blocksize.


imax = len(list) // <NUM_LIT:4><EOL>hl = [<NUM_LIT:0>] * imax<EOL>j = <NUM_LIT:0><EOL>i = <NUM_LIT:0><EOL>while i < imax:<EOL><INDENT>b0 = ord(list[j]) << <NUM_LIT><EOL>b1 = ord(list[j+<NUM_LIT:1>]) << <NUM_LIT:16><EOL>b2 = ord(list[j+<NUM_LIT:2>]) << <NUM_LIT:8><EOL>b3 = ord(list[j+<NUM_LIT:3>])<EOL>hl[i] = b0 | b1 | b2 | b3<EOL>i = i+<NUM_LIT:1><EOL>j = j+<NUM_LIT:4><EOL><DEDENT>return hl<EOL>

Transform a list of characters into a list of longs.


return (x << n) | (x >> (<NUM_LIT:32>-n))<EOL>

Rotate x (32 bit) left n bits circularly.


crypto = sha()<EOL>if arg:<EOL><INDENT>crypto.update(arg)<EOL><DEDENT>return crypto<EOL>

Return a new sha crypto object.

    If arg is present, the method call update(arg) is made.


<EOL>self.length = <NUM_LIT:0><EOL>self.count = [<NUM_LIT:0>, <NUM_LIT:0>]<EOL>self.input = []<EOL>self.init()<EOL>


self.length = <NUM_LIT:0><EOL>self.input = []<EOL>self.H0 = <NUM_LIT><EOL>self.H1 = <NUM_LIT><EOL>self.H2 = <NUM_LIT><EOL>self.H3 = <NUM_LIT><EOL>self.H4 = <NUM_LIT><EOL>

Initialize the message-digest and set all fields to zero.


leninBuf = len(inBuf)<EOL>index = (self.count[<NUM_LIT:1>] >> <NUM_LIT:3>) & <NUM_LIT><EOL>self.count[<NUM_LIT:1>] = self.count[<NUM_LIT:1>] + (leninBuf << <NUM_LIT:3>)<EOL>if self.count[<NUM_LIT:1>] < (leninBuf << <NUM_LIT:3>):<EOL><INDENT>self.count[<NUM_LIT:0>] = self.count[<NUM_LIT:0>] + <NUM_LIT:1><EOL><DEDENT>self.count[<NUM_LIT:0>] = self.count[<NUM_LIT:0>] + (leninBuf >> <NUM_LIT>)<EOL>partLen = <NUM_LIT:64> - index<EOL>if leninBuf >= partLen:<EOL><INDENT>self.input[index:] = list(inBuf[:partLen])<EOL>self._transform(_bytelist2longBigEndian(self.input))<EOL>i = partLen<EOL>while i + <NUM_LIT> < leninBuf:<EOL><INDENT>self._transform(_bytelist2longBigEndian(list(inBuf[i:i+<NUM_LIT:64>])))<EOL>i = i + <NUM_LIT:64><EOL><DEDENT>else:<EOL><INDENT>self.input = list(inBuf[i:leninBuf])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i = <NUM_LIT:0><EOL>self.input = self.input + list(inBuf)<EOL><DEDENT>

Add to the current message.

        Update the md5 object with the string arg. Repeated calls
        are equivalent to a single call with the concatenation of all
        the arguments, i.e. m.update(a); m.update(b) is equivalent
        to m.update(a+b).

        The hash is immediately calculated for all full blocks. The final
        calculation is made in digest(). It will calculate 1-2 blocks,
        depending on how much padding we have to add. This allows us to
        keep an intermediate value for the hash, so that we only need to
        make minimal recalculation if we call update() to add more data
        to the hashed string.


H0 = self.H0<EOL>H1 = self.H1<EOL>H2 = self.H2<EOL>H3 = self.H3<EOL>H4 = self.H4<EOL>input = [] + self.input<EOL>count = [] + self.count<EOL>index = (self.count[<NUM_LIT:1>] >> <NUM_LIT:3>) & <NUM_LIT><EOL>if index < <NUM_LIT>:<EOL><INDENT>padLen = <NUM_LIT> - index<EOL><DEDENT>else:<EOL><INDENT>padLen = <NUM_LIT> - index<EOL><DEDENT>padding = ['<STR_LIT>'] + ['<STR_LIT>'] * <NUM_LIT><EOL>self.update(padding[:padLen])<EOL>bits = _bytelist2longBigEndian(self.input[:<NUM_LIT>]) + count<EOL>self._transform(bits)<EOL>digest = _long2bytesBigEndian(self.H0, <NUM_LIT:4>) +_long2bytesBigEndian(self.H1, <NUM_LIT:4>) +_long2bytesBigEndian(self.H2, <NUM_LIT:4>) +_long2bytesBigEndian(self.H3, <NUM_LIT:4>) +_long2bytesBigEndian(self.H4, <NUM_LIT:4>)<EOL>self.H0 = H0<EOL>self.H1 = H1<EOL>self.H2 = H2<EOL>self.H3 = H3<EOL>self.H4 = H4<EOL>self.input = input<EOL>self.count = count<EOL>return digest<EOL>

Terminate the message-digest computation and return digest.

        Return the digest of the strings passed to the update()
        method so far. This is a 16-byte string which may contain
        non-ASCII characters, including null bytes.


return '<STR_LIT>'.join([('<STR_LIT>' % ord(c))[-<NUM_LIT:2>:] for c in self.digest()])<EOL>

Terminate and return digest in HEX form.

        Like digest() except the digest is returned as a string of
        length 32, containing only hexadecimal digits. This may be
        used to exchange the value safely in email or other non-
        binary environments.


return copy.deepcopy(self)<EOL>

Return a clone object.

        Return a copy ('clone') of the md5 object. This can be used
        to efficiently compute the digests of strings that share
        a common initial substring.


leftblock = self.left<EOL>rightblock = self.right<EOL>leftindex = self.leftndx<EOL>rightindex = self.rightndx<EOL>for i in range(self.length // <NUM_LIT:2>):<EOL><INDENT>assert leftblock != rightblock or leftindex < rightindex<EOL>(rightblock[rightindex], leftblock[leftindex]) = (<EOL>leftblock[leftindex], rightblock[rightindex])<EOL>leftindex += <NUM_LIT:1><EOL>if leftindex == n:<EOL><INDENT>leftblock = leftblock[RGTLNK]<EOL>assert leftblock is not None<EOL>leftindex = <NUM_LIT:0><EOL><DEDENT>rightindex -= <NUM_LIT:1><EOL>if rightindex == -<NUM_LIT:1>:<EOL><INDENT>rightblock = rightblock[LFTLNK]<EOL>assert rightblock is not None<EOL>rightindex = n - <NUM_LIT:1><EOL><DEDENT><DEDENT>


return (type(self), (self.default_factory,), None, None, self.iteritems())<EOL>

__reduce__ must return a 5-tuple as follows:

   - factory function
   - tuple of args for the factory function
   - additional state (here None)
   - sequence iterator (here None)
   - dictionary iterator (yielding successive (key, value) pairs

   This API is used by pickle.py and copy.py.


return self.reason.format(**self.arguments)<EOL>


def render(self, only_line=False, colored=False):

source_line = self.location.source_line().rstrip("<STR_LIT:\n>")<EOL>highlight_line = bytearray(re.sub(r"<STR_LIT>", "<STR_LIT:U+0020>", source_line), "<STR_LIT:utf-8>")<EOL>for hilight in self.highlights:<EOL><INDENT>if hilight.line() == self.location.line():<EOL><INDENT>lft, rgt = hilight.column_range()<EOL>highlight_line[lft:rgt] = bytearray("<STR_LIT>", "<STR_LIT:utf-8>") * (rgt - lft)<EOL><DEDENT><DEDENT>lft, rgt = self.location.column_range()<EOL>if rgt == lft: <EOL><INDENT>rgt = lft + <NUM_LIT:1><EOL><DEDENT>highlight_line[lft:rgt] = bytearray("<STR_LIT>", "<STR_LIT:utf-8>") * (rgt - lft)<EOL>if only_line:<EOL><INDENT>location = "<STR_LIT>" % (self.location.source_buffer.name, self.location.line())<EOL><DEDENT>else:<EOL><INDENT>location = str(self.location)<EOL><DEDENT>notes = list(self.notes)<EOL>if self.level != "<STR_LIT>":<EOL><INDENT>expanded_location = self.location.expanded_from<EOL>while expanded_location is not None:<EOL><INDENT>notes.insert(<NUM_LIT:0>, Diagnostic("<STR_LIT>",<EOL>"<STR_LIT>", {},<EOL>self.location.expanded_from))<EOL>expanded_location = expanded_location.expanded_from<EOL><DEDENT><DEDENT>rendered_notes = reduce(list.__add__, [note.render(only_line, colored)<EOL>for note in notes], [])<EOL>if colored:<EOL><INDENT>if self.level in ("<STR_LIT:error>", "<STR_LIT>"):<EOL><INDENT>level_color = <NUM_LIT> <EOL><DEDENT>elif self.level == "<STR_LIT>":<EOL><INDENT>level_color = <NUM_LIT> <EOL><DEDENT>else: <EOL><INDENT>level_color = <NUM_LIT:30> <EOL><DEDENT>return [<EOL>"<STR_LIT>".<EOL>format(location, level_color, self.level, self.message()),<EOL>source_line,<EOL>"<STR_LIT>".format(highlight_line.decode("<STR_LIT:utf-8>"))<EOL>] + rendered_notes<EOL><DEDENT>else:<EOL><INDENT>return [<EOL>"<STR_LIT>".format(location, self.level, self.message()),<EOL>source_line,<EOL>highlight_line.decode("<STR_LIT:utf-8>")<EOL>] + rendered_notes<EOL><DEDENT>

Returns the human-readable location of the diagnostic in the source,
the formatted message, the source line corresponding
to ``location`` and a line emphasizing the problematic
locations in the source line using ASCII art, as a list of lines.
Appends the result of calling :meth:`render` on ``notes``, if any.

For example: ::

    <input>:1:8-9: error: cannot add integer and string
    x + (1 + "a")
         ~ ^ ~~~

:param only_line: (bool) If true, only print line number, not line and column range


diagnostic.notes += self._appended_notes<EOL>self.render_diagnostic(diagnostic)<EOL>if diagnostic.level == "<STR_LIT>" or(self.all_errors_are_fatal and diagnostic.level == "<STR_LIT:error>"):<EOL><INDENT>raise Error(diagnostic)<EOL><DEDENT>

The default implementation of :meth:`process` renders non-fatal
diagnostics to ``sys.stderr``, and raises fatal ones as a :class:`Error`.


self._appended_notes += notes<EOL>yield<EOL>del self._appended_notes[-len(notes):]<EOL>

A context manager that appends ``note`` to every diagnostic processed by
this engine.


def compare(left, right, compare_locs=False):

if type(left) != type(right):<EOL><INDENT>return False<EOL><DEDENT>if isinstance(left, ast.AST):<EOL><INDENT>for field in left._fields:<EOL><INDENT>if not compare(getattr(left, field), getattr(right, field)):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if compare_locs:<EOL><INDENT>for loc in left._locs:<EOL><INDENT>if getattr(left, loc) != getattr(right, loc):<EOL><INDENT>return False<EOL><DEDENT><DEDENT><DEDENT>return True<EOL><DEDENT>elif isinstance(left, list):<EOL><INDENT>if len(left) != len(right):<EOL><INDENT>return False<EOL><DEDENT>for left_elt, right_elt in zip(left, right):<EOL><INDENT>if not compare(left_elt, right_elt):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return left == right<EOL><DEDENT>

An AST comparison function. Returns ``True`` if all fields in
``left`` are equal to fields in ``right``; if ``compare_locs`` is
true, all locations should match as well.


for field_name in node._fields:<EOL><INDENT>self.visit(getattr(node, field_name))<EOL><DEDENT>

Called if no explicit visitor function exists for a node.


if isinstance(obj, list):<EOL><INDENT>return [self.visit(elt) for elt in obj]<EOL><DEDENT>elif isinstance(obj, ast.AST):<EOL><INDENT>return self._visit_one(obj)<EOL><DEDENT>

Visit a node or a list of nodes. Other values are ignored


for field_name in node._fields:<EOL><INDENT>setattr(node, field_name, self.visit(getattr(node, field_name)))<EOL><DEDENT>return node<EOL>


if isinstance(obj, list):<EOL><INDENT>return list(filter(lambda x: x is not None, map(self.visit, obj)))<EOL><DEDENT>elif isinstance(obj, ast.AST):<EOL><INDENT>return self._visit_one(obj)<EOL><DEDENT>else:<EOL><INDENT>return obj<EOL><DEDENT>


def decorator(mapper):<EOL><INDENT>@llrule(loc, inner_rule.expected)<EOL>def outer_rule(parser):<EOL><INDENT>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>if isinstance(result, tuple):<EOL><INDENT>return mapper(parser, *result)<EOL><DEDENT>else:<EOL><INDENT>return mapper(parser, result)<EOL><DEDENT><DEDENT>return outer_rule<EOL><DEDENT>return decorator<EOL>

A decorator returning a function that first runs ``inner_rule`` and then, if its
return value is not None, maps that value using ``mapper``.

If the value being mapped is a tuple, it is expanded into multiple arguments.

Similar to attaching semantic actions to rules in traditional parser generators.


@llrule(loc, lambda parser: [])<EOL>def rule(parser):<EOL><INDENT>return value<EOL><DEDENT>return rule<EOL>

A rule that accepts no tokens (epsilon) and returns ``value``.


@llrule(loc, lambda parser: [kind])<EOL>def rule(parser):<EOL><INDENT>return parser._accept(kind)<EOL><DEDENT>return rule<EOL>

A rule that accepts a token of kind ``kind`` and returns it, or returns None.


@llrule(loc, lambda parser: [kind])<EOL>def rule(parser):<EOL><INDENT>result = parser._accept(kind)<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>return result.loc<EOL><DEDENT>return rule<EOL>

A rule that accepts a token of kind ``kind`` and returns its location, or returns None.


@llrule(loc, lambda parser: getattr(parser, name).expected(parser))<EOL>def rule(parser):<EOL><INDENT>return getattr(parser, name)()<EOL><DEDENT>return rule<EOL>

A proxy for a rule called ``name`` which may not be yet defined.


@llrule(loc, inner_rule.expected)<EOL>def rule(parser):<EOL><INDENT>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>expected = reduce(list.__add__, [rule.expected(parser) for rule in parser._errrules])<EOL>expected = list(sorted(set(expected)))<EOL>if len(expected) > <NUM_LIT:1>:<EOL><INDENT>expected = "<STR_LIT>".join(["<STR_LIT:U+002CU+0020>".join(expected[<NUM_LIT:0>:-<NUM_LIT:1>]), expected[-<NUM_LIT:1>]])<EOL><DEDENT>elif len(expected) == <NUM_LIT:1>:<EOL><INDENT>expected = expected[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>expected = "<STR_LIT>"<EOL><DEDENT>error_tok = parser._tokens[parser._errindex]<EOL>error = diagnostic.Diagnostic(<EOL>"<STR_LIT>", "<STR_LIT>",<EOL>{"<STR_LIT>": error_tok.kind, "<STR_LIT>": expected},<EOL>error_tok.loc)<EOL>parser.diagnostic_engine.process(error)<EOL><DEDENT>return result<EOL><DEDENT>return rule<EOL>

A rule that executes ``inner_rule`` and emits a diagnostic error if it returns None.


def Seq(first_rule, *rest_of_rules, **kwargs):

@llrule(kwargs.get("<STR_LIT>", None), first_rule.expected)<EOL>def rule(parser):<EOL><INDENT>result = first_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>results = [result]<EOL>for rule in rest_of_rules:<EOL><INDENT>result = rule(parser)<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>results.append(result)<EOL><DEDENT>return tuple(results)<EOL><DEDENT>return rule<EOL>

A rule that accepts a sequence of tokens satisfying ``rules`` and returns a tuple
containing their return values, or None if the first rule was not satisfied.


@action(Seq(*inner_rules), loc=kwargs.get("<STR_LIT>", None))<EOL>def rule(parser, *values):<EOL><INDENT>return values[n]<EOL><DEDENT>return rule<EOL>

A rule that accepts a sequence of tokens satisfying ``rules`` and returns
the value returned by rule number ``n``, or None if the first rule was not satisfied.


loc = kwargs.get("<STR_LIT>", None)<EOL>expected = lambda parser: reduce(list.__add__, map(lambda x: x.expected(parser), inner_rules))<EOL>if loc is not None:<EOL><INDENT>@llrule(loc, expected, cases=len(inner_rules))<EOL>def rule(parser):<EOL><INDENT>data = parser._save()<EOL>for idx, inner_rule in enumerate(inner_rules):<EOL><INDENT>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>parser._restore(data, rule=inner_rule)<EOL><DEDENT>else:<EOL><INDENT>rule.covered[idx] = True<EOL>return result<EOL><DEDENT><DEDENT>return unmatched<EOL><DEDENT><DEDENT>else:<EOL><INDENT>@llrule(loc, expected, cases=len(inner_rules))<EOL>def rule(parser):<EOL><INDENT>data = parser._save()<EOL>for inner_rule in inner_rules:<EOL><INDENT>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>parser._restore(data, rule=inner_rule)<EOL><DEDENT>else:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>return unmatched<EOL><DEDENT><DEDENT>return rule<EOL>

A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence
(a rule is satisfied when it returns anything but None) and returns the return
value of that rule, or None if no rules were satisfied.


return Alt(inner_rule, Eps(), loc=loc)<EOL>

Shorthand for ``Alt(inner_rule, Eps())``


@llrule(loc, lambda parser: [])<EOL>def rule(parser):<EOL><INDENT>results = []<EOL>while True:<EOL><INDENT>data = parser._save()<EOL>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>parser._restore(data, rule=inner_rule)<EOL>return results<EOL><DEDENT>results.append(result)<EOL><DEDENT><DEDENT>return rule<EOL>

A rule that accepts a sequence of tokens satisfying ``inner_rule`` zero or more times,
and returns the returned values in a :class:`list`.


@llrule(loc, inner_rule.expected)<EOL>def rule(parser):<EOL><INDENT>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>results = [result]<EOL>while True:<EOL><INDENT>data = parser._save()<EOL>result = inner_rule(parser)<EOL>if result is unmatched:<EOL><INDENT>parser._restore(data, rule=inner_rule)<EOL>return results<EOL><DEDENT>results.append(result)<EOL><DEDENT><DEDENT>return rule<EOL>

A rule that accepts a sequence of tokens satisfying ``inner_rule`` one or more times,
and returns the returned values in a :class:`list`.


@llrule(loc, lambda parser: ["<STR_LIT>"])<EOL>def rule(parser):<EOL><INDENT>result = parser._accept("<STR_LIT>")<EOL>if result is unmatched:<EOL><INDENT>return result<EOL><DEDENT>return []<EOL><DEDENT>return rule<EOL>

A rule that accepts token of kind ``newline`` and returns an empty list.


@action(Seq(*map(Loc, kinds)), loc=kwargs.get("<STR_LIT>", None))<EOL>def rule(parser, *tokens):<EOL><INDENT>return klass(loc=tokens[<NUM_LIT:0>].join(tokens[-<NUM_LIT:1>]))<EOL><DEDENT>return rule<EOL>

A rule that accepts a sequence of tokens of kinds ``kinds`` and returns
an instance of ``klass`` with ``loc`` encompassing the entire sequence
or None if the first token is not of ``kinds[0]``.


@action(Expect(Alt(Newline(),<EOL>Rule("<STR_LIT>"),<EOL>SeqN(<NUM_LIT:0>, Rule("<STR_LIT>"), Newline()))))<EOL><INDENT>def single_input(self, body):<DEDENT>

loc = None<EOL>if body != []:<EOL><INDENT>loc = body[<NUM_LIT:0>].loc<EOL><DEDENT>return ast.Interactive(body=body, loc=loc)<EOL>

single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE


@action(Expect(SeqN(<NUM_LIT:0>, Star(Alt(Newline(), Rule("<STR_LIT>"))), Tok("<STR_LIT>"))))<EOL><INDENT>def file_input(parser, body):<DEDENT>

body = reduce(list.__add__, body, [])<EOL>loc = None<EOL>if body != []:<EOL><INDENT>loc = body[<NUM_LIT:0>].loc<EOL><DEDENT>return ast.Module(body=body, loc=loc)<EOL>


@action(Seq(Loc("<STR_LIT:@>"), List(Tok("<STR_LIT>"), "<STR_LIT:.>", trailing=False),<EOL>Opt(BeginEnd("<STR_LIT:(>", Opt(Rule("<STR_LIT>")), "<STR_LIT:)>",<EOL>empty=_empty_arglist)),<EOL>Loc("<STR_LIT>")))<EOL><INDENT>def decorator(self, at_loc, idents, call_opt, newline_loc):<DEDENT>

root = idents[<NUM_LIT:0>]<EOL>dec_loc = root.loc<EOL>expr = ast.Name(id=root.value, ctx=None, loc=root.loc)<EOL>for ident in idents[<NUM_LIT:1>:]:<EOL><INDENT>dot_loc = ident.loc.begin()<EOL>dot_loc.begin_pos -= <NUM_LIT:1><EOL>dec_loc = dec_loc.join(ident.loc)<EOL>expr = ast.Attribute(value=expr, attr=ident.value, ctx=None,<EOL>loc=expr.loc.join(ident.loc),<EOL>attr_loc=ident.loc, dot_loc=dot_loc)<EOL><DEDENT>if call_opt:<EOL><INDENT>call_opt.func = expr<EOL>call_opt.loc = dec_loc.join(call_opt.loc)<EOL>expr = call_opt<EOL><DEDENT>return at_loc, expr<EOL>

decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE


@action(Seq(Rule("<STR_LIT>"), Alt(Rule("<STR_LIT>"), Rule("<STR_LIT>"))))<EOL><INDENT>def decorated(self, decorators, classfuncdef):<DEDENT>

classfuncdef.at_locs = list(map(lambda x: x[<NUM_LIT:0>], decorators))<EOL>classfuncdef.decorator_list = list(map(lambda x: x[<NUM_LIT:1>], decorators))<EOL>classfuncdef.loc = classfuncdef.loc.join(decorators[<NUM_LIT:0>][<NUM_LIT:0>])<EOL>return classfuncdef<EOL>

decorated: decorators (classdef | funcdef)


@action(Seq(Loc("<STR_LIT>"), Tok("<STR_LIT>"), Rule("<STR_LIT>"), Loc("<STR_LIT::>"), Rule("<STR_LIT>")))<EOL><INDENT>def funcdef__26(self, def_loc, ident_tok, args, colon_loc, suite):<DEDENT>

return ast.FunctionDef(name=ident_tok.value, args=args, returns=None,<EOL>body=suite, decorator_list=[],<EOL>at_locs=[], keyword_loc=def_loc, name_loc=ident_tok.loc,<EOL>colon_loc=colon_loc, arrow_loc=None,<EOL>loc=def_loc.join(suite[-<NUM_LIT:1>].loc))<EOL>

(2.6, 2.7) funcdef: 'def' NAME parameters ':' suite


@action(Alt(Seq(Star(SeqN(<NUM_LIT:0>, varargslist__26_1, Tok("<STR_LIT:U+002C>"))),<EOL>Alt(varargslist__26_2, varargslist__26_3)),<EOL>Seq(List(varargslist__26_1, "<STR_LIT:U+002C>", trailing=True),<EOL>varargslist__26_4)))<EOL><INDENT>def varargslist__26(self, fparams, args):<DEDENT>

for fparam, default_opt in fparams:<EOL><INDENT>if default_opt:<EOL><INDENT>equals_loc, default = default_opt<EOL>args.equals_locs.append(equals_loc)<EOL>args.defaults.append(default)<EOL><DEDENT>elif len(args.defaults) > <NUM_LIT:0>:<EOL><INDENT>error = diagnostic.Diagnostic(<EOL>"<STR_LIT>", "<STR_LIT>", {},<EOL>fparam.loc, [args.args[-<NUM_LIT:1>].loc.join(args.defaults[-<NUM_LIT:1>].loc)])<EOL>self.diagnostic_engine.process(error)<EOL><DEDENT>args.args.append(fparam)<EOL><DEDENT>def fparam_loc(fparam, default_opt):<EOL><INDENT>if default_opt:<EOL><INDENT>equals_loc, default = default_opt<EOL>return fparam.loc.join(default.loc)<EOL><DEDENT>else:<EOL><INDENT>return fparam.loc<EOL><DEDENT><DEDENT>if args.loc is None:<EOL><INDENT>args.loc = fparam_loc(*fparams[<NUM_LIT:0>]).join(fparam_loc(*fparams[-<NUM_LIT:1>]))<EOL><DEDENT>elif len(fparams) > <NUM_LIT:0>:<EOL><INDENT>args.loc = args.loc.join(fparam_loc(*fparams[<NUM_LIT:0>]))<EOL><DEDENT>return args<EOL>


@action(List(Rule("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=True))<EOL><INDENT>def fplist(self, elts):<DEDENT>

return ast.Tuple(elts=elts, ctx=None, loc=None)<EOL>


@action(Seq(Rule("<STR_LIT>"), Alt(expr_stmt_2, expr_stmt_3)))<EOL><INDENT>def expr_stmt(self, lhs, rhs):<DEDENT>

if isinstance(rhs, ast.AugAssign):<EOL><INDENT>if isinstance(lhs, ast.Tuple) or isinstance(lhs, ast.List):<EOL><INDENT>error = diagnostic.Diagnostic(<EOL>"<STR_LIT>", "<STR_LIT>", {},<EOL>rhs.op.loc, [lhs.loc])<EOL>self.diagnostic_engine.process(error)<EOL><DEDENT>else:<EOL><INDENT>rhs.target = self._assignable(lhs)<EOL>rhs.loc = rhs.target.loc.join(rhs.value.loc)<EOL>return rhs<EOL><DEDENT><DEDENT>elif rhs is not None:<EOL><INDENT>rhs.targets = list(map(self._assignable, [lhs] + rhs.targets))<EOL>rhs.loc = lhs.loc.join(rhs.value.loc)<EOL>return rhs<EOL><DEDENT>else:<EOL><INDENT>return ast.Expr(value=lhs, loc=lhs.loc)<EOL><DEDENT>

(2.6, 2.7, 3.0, 3.1)
expr_stmt: testlist (augassign (yield_expr|testlist) |
                     ('=' (yield_expr|testlist))*)
(3.2-)
expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
                     ('=' (yield_expr|testlist_star_expr))*)


@action(Seq(Loc("<STR_LIT>"), Alt(print_stmt_1, print_stmt_2, print_stmt_3)))<EOL><INDENT>def print_stmt(self, print_loc, stmt):<DEDENT>

stmt.keyword_loc = print_loc<EOL>if stmt.loc is None:<EOL><INDENT>stmt.loc = print_loc<EOL><DEDENT>else:<EOL><INDENT>stmt.loc = print_loc.join(stmt.loc)<EOL><DEDENT>return stmt<EOL>


@action(Seq(Loc("<STR_LIT>"), List(Rule("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=True)))<EOL><INDENT>def del_stmt(self, stmt_loc, exprs):<EOL><DEDENT>

return ast.Delete(targets=[self._assignable(expr, is_delete=True) for expr in exprs],<EOL>loc=stmt_loc.join(exprs[-<NUM_LIT:1>].loc), keyword_loc=stmt_loc)<EOL>


return ast.Pass(loc=stmt_loc, keyword_loc=stmt_loc)<EOL>


return ast.Break(loc=stmt_loc, keyword_loc=stmt_loc)<EOL>


return ast.Continue(loc=stmt_loc, keyword_loc=stmt_loc)<EOL>


return ast.Expr(value=expr, loc=expr.loc)<EOL>


@action(Seq(Loc("<STR_LIT>"), Rule("<STR_LIT>")))<EOL><INDENT>def import_name(self, import_loc, names):<DEDENT>

return ast.Import(names=names,<EOL>keyword_loc=import_loc, loc=import_loc.join(names[-<NUM_LIT:1>].loc))<EOL>


@action(Seq(Loc("<STR_LIT>"), Alt(import_from_3, import_from_4, import_from_7),<EOL>Loc("<STR_LIT>"), Alt(import_from_5,<EOL>Seq(Loc("<STR_LIT:(>"), Rule("<STR_LIT>"), Loc("<STR_LIT:)>")),<EOL>import_from_6)))<EOL><INDENT>def import_from(self, from_loc, module_name, import_loc, names):<DEDENT>

(dots_loc, dots_count), dotted_name_opt = module_name<EOL>module_loc = module = None<EOL>if dotted_name_opt:<EOL><INDENT>module_loc, module = dotted_name_opt<EOL><DEDENT>lparen_loc, names, rparen_loc = names<EOL>loc = from_loc.join(names[-<NUM_LIT:1>].loc)<EOL>if rparen_loc:<EOL><INDENT>loc = loc.join(rparen_loc)<EOL><DEDENT>if module == "<STR_LIT>":<EOL><INDENT>self.add_flags([x.name for x in names])<EOL><DEDENT>return ast.ImportFrom(names=names, module=module, level=dots_count,<EOL>keyword_loc=from_loc, dots_loc=dots_loc, module_loc=module_loc,<EOL>import_loc=import_loc, lparen_loc=lparen_loc, rparen_loc=rparen_loc,<EOL>loc=loc)<EOL>

(2.6, 2.7)
import_from: ('from' ('.'* dotted_name | '.'+)
              'import' ('*' | '(' import_as_names ')' | import_as_names))
(3.0-)
# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
              'import' ('*' | '(' import_as_names ')' | import_as_names))


@action(Seq(Tok("<STR_LIT>"), Opt(Seq(Loc("<STR_LIT>"), Tok("<STR_LIT>")))))<EOL><INDENT>def import_as_name(self, name_tok, as_name_opt):<DEDENT>

asname_name = asname_loc = as_loc = None<EOL>loc = name_tok.loc<EOL>if as_name_opt:<EOL><INDENT>as_loc, asname = as_name_opt<EOL>asname_name = asname.value<EOL>asname_loc = asname.loc<EOL>loc = loc.join(asname.loc)<EOL><DEDENT>return ast.alias(name=name_tok.value, asname=asname_name,<EOL>loc=loc, name_loc=name_tok.loc, as_loc=as_loc, asname_loc=asname_loc)<EOL>


@action(Seq(Rule("<STR_LIT>"), Opt(Seq(Loc("<STR_LIT>"), Tok("<STR_LIT>")))))<EOL><INDENT>def dotted_as_name(self, dotted_name, as_name_opt):<DEDENT>

asname_name = asname_loc = as_loc = None<EOL>dotted_name_loc, dotted_name_name = dotted_name<EOL>loc = dotted_name_loc<EOL>if as_name_opt:<EOL><INDENT>as_loc, asname = as_name_opt<EOL>asname_name = asname.value<EOL>asname_loc = asname.loc<EOL>loc = loc.join(asname.loc)<EOL><DEDENT>return ast.alias(name=dotted_name_name, asname=asname_name,<EOL>loc=loc, name_loc=dotted_name_loc, as_loc=as_loc, asname_loc=asname_loc)<EOL>


@action(List(Tok("<STR_LIT>"), "<STR_LIT:.>", trailing=False))<EOL><INDENT>def dotted_name(self, idents):<DEDENT>

return idents[<NUM_LIT:0>].loc.join(idents[-<NUM_LIT:1>].loc),"<STR_LIT:.>".join(list(map(lambda x: x.value, idents)))<EOL>


@action(Seq(Loc("<STR_LIT>"), List(Tok("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=False)))<EOL><INDENT>def global_stmt(self, global_loc, names):<DEDENT>

return ast.Global(names=list(map(lambda x: x.value, names)),<EOL>name_locs=list(map(lambda x: x.loc, names)),<EOL>keyword_loc=global_loc, loc=global_loc.join(names[-<NUM_LIT:1>].loc))<EOL>


@action(Seq(Loc("<STR_LIT>"), List(Tok("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=False)))<EOL><INDENT>def nonlocal_stmt(self, nonlocal_loc, names):<DEDENT>

return ast.Nonlocal(names=list(map(lambda x: x.value, names)),<EOL>name_locs=list(map(lambda x: x.loc, names)),<EOL>keyword_loc=nonlocal_loc, loc=nonlocal_loc.join(names[-<NUM_LIT:1>].loc))<EOL>

(3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)*


@action(Alt(Rule("<STR_LIT>"), Rule("<STR_LIT>"), Rule("<STR_LIT>"),<EOL>Rule("<STR_LIT>"), Rule("<STR_LIT>"), Rule("<STR_LIT>"),<EOL>Rule("<STR_LIT>"), Rule("<STR_LIT>")))<EOL><INDENT>def compound_stmt(self, stmt):<DEDENT>

return [stmt]<EOL>

compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt |
                          funcdef | classdef | decorated


@action(Seq(Loc("<STR_LIT>"), Loc("<STR_LIT::>"), Rule("<STR_LIT>"), Alt(try_stmt_1, try_stmt_2)))<EOL><INDENT>def try_stmt(self, try_loc, try_colon_loc, body, stmt):<DEDENT>

stmt.keyword_loc, stmt.try_colon_loc, stmt.body =try_loc, try_colon_loc, body<EOL>stmt.loc = stmt.loc.join(try_loc)<EOL>return stmt<EOL>

try_stmt: ('try' ':' suite
           ((except_clause ':' suite)+
            ['else' ':' suite]
            ['finally' ':' suite] |
            'finally' ':' suite))


@action(Seq(Loc("<STR_LIT>"), List(Rule("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=False), Loc("<STR_LIT::>"),<EOL>Rule("<STR_LIT>")))<EOL><INDENT>def with_stmt__27(self, with_loc, items, colon_loc, body):<DEDENT>

return ast.With(items=items, body=body,<EOL>keyword_loc=with_loc, colon_loc=colon_loc,<EOL>loc=with_loc.join(body[-<NUM_LIT:1>].loc))<EOL>

(2.7, 3.1-) with_stmt: 'with' with_item (',' with_item)*  ':' suite


@action(Rule("<STR_LIT>"))<EOL><INDENT>def comparison(self, lhs, rhs):<DEDENT>

if len(rhs) > <NUM_LIT:0>:<EOL><INDENT>return ast.Compare(left=lhs, ops=list(map(lambda x: x[<NUM_LIT:0>], rhs)),<EOL>comparators=list(map(lambda x: x[<NUM_LIT:1>], rhs)),<EOL>loc=lhs.loc.join(rhs[-<NUM_LIT:1>][<NUM_LIT:1>].loc))<EOL><DEDENT>else:<EOL><INDENT>return lhs<EOL><DEDENT>

(2.6, 2.7) comparison: expr (comp_op expr)*
(3.0, 3.1) comparison: star_expr (comp_op star_expr)*
(3.2-) comparison: expr (comp_op expr)*


@action(Seq(Opt(Loc("<STR_LIT:*>")), Rule("<STR_LIT>")))<EOL><INDENT>def star_expr__30(self, star_opt, expr):<DEDENT>

if star_opt:<EOL><INDENT>return ast.Starred(value=expr, ctx=None,<EOL>star_loc=star_opt, loc=expr.loc.join(star_opt))<EOL><DEDENT>return expr<EOL>


@action(Seq(Loc("<STR_LIT:*>"), Rule("<STR_LIT>")))<EOL><INDENT>def star_expr__32(self, star_loc, expr):<DEDENT>

return ast.Starred(value=expr, ctx=None,<EOL>star_loc=star_loc, loc=expr.loc.join(star_loc))<EOL>


@action(Seq(Rule("<STR_LIT>"), Star(Rule("<STR_LIT>")), Opt(Seq(Loc("<STR_LIT>"), Rule("<STR_LIT>")))))<EOL><INDENT>def power(self, atom, trailers, factor_opt):<DEDENT>

for trailer in trailers:<EOL><INDENT>if isinstance(trailer, ast.Attribute) or isinstance(trailer, ast.Subscript):<EOL><INDENT>trailer.value = atom<EOL><DEDENT>elif isinstance(trailer, ast.Call):<EOL><INDENT>trailer.func = atom<EOL><DEDENT>trailer.loc = atom.loc.join(trailer.loc)<EOL>atom = trailer<EOL><DEDENT>if factor_opt:<EOL><INDENT>op_loc, factor = factor_opt<EOL>return ast.BinOp(left=atom, op=ast.Pow(loc=op_loc), right=factor,<EOL>loc=atom.loc.join(factor.loc))<EOL><DEDENT>return atom<EOL>


@action(List(Rule("<STR_LIT>"), "<STR_LIT:U+002C>", trailing=True))<EOL><INDENT>def subscriptlist(self, subscripts):<DEDENT>

if len(subscripts) == <NUM_LIT:1>:<EOL><INDENT>return ast.Subscript(slice=subscripts[<NUM_LIT:0>], ctx=None, loc=None)<EOL><DEDENT>elif all([isinstance(x, ast.Index) for x in subscripts]):<EOL><INDENT>elts  = [x.value for x in subscripts]<EOL>loc   = subscripts[<NUM_LIT:0>].loc.join(subscripts[-<NUM_LIT:1>].loc)<EOL>index = ast.Index(value=ast.Tuple(elts=elts, ctx=None,<EOL>begin_loc=None, end_loc=None, loc=loc),<EOL>loc=loc)<EOL>return ast.Subscript(slice=index, ctx=None, loc=None)<EOL><DEDENT>else:<EOL><INDENT>extslice = ast.ExtSlice(dims=subscripts,<EOL>loc=subscripts[<NUM_LIT:0>].loc.join(subscripts[-<NUM_LIT:1>].loc))<EOL>return ast.Subscript(slice=extslice, ctx=None, loc=None)<EOL><DEDENT>

subscriptlist: subscript (',' subscript)* [',']


return self._wrap_tuple(exprs)<EOL>

(2.6, 2.7) exprlist: expr (',' expr)* [',']
(3.0, 3.1) exprlist: star_expr (',' star_expr)* [',']
(3.2-) exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']


@action(Seq(Loc("<STR_LIT:class>"), Tok("<STR_LIT>"),<EOL>Opt(Seq(Loc("<STR_LIT:(>"), Rule("<STR_LIT>"), Loc("<STR_LIT:)>"))),<EOL>Loc("<STR_LIT::>"), Rule("<STR_LIT>")))<EOL><INDENT>def classdef__30(self, class_loc, name_tok, arglist_opt, colon_loc, body):<DEDENT>

arglist, lparen_loc, rparen_loc = [], None, None<EOL>bases, keywords, starargs, kwargs = [], [], None, None<EOL>star_loc, dstar_loc = None, None<EOL>if arglist_opt:<EOL><INDENT>lparen_loc, arglist, rparen_loc = arglist_opt<EOL>bases, keywords, starargs, kwargs =arglist.args, arglist.keywords, arglist.starargs, arglist.kwargs<EOL>star_loc, dstar_loc = arglist.star_loc, arglist.dstar_loc<EOL><DEDENT>return ast.ClassDef(name=name_tok.value, bases=bases, keywords=keywords,<EOL>starargs=starargs, kwargs=kwargs, body=body,<EOL>decorator_list=[], at_locs=[],<EOL>keyword_loc=class_loc, lparen_loc=lparen_loc,<EOL>star_loc=star_loc, dstar_loc=dstar_loc, rparen_loc=rparen_loc,<EOL>name_loc=name_tok.loc, colon_loc=colon_loc,<EOL>loc=class_loc.join(body[-<NUM_LIT:1>].loc))<EOL>

(3.0) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite


for arg in args:<EOL><INDENT>if isinstance(arg, ast.keyword):<EOL><INDENT>call.keywords.append(arg)<EOL><DEDENT>elif len(call.keywords) > <NUM_LIT:0>:<EOL><INDENT>error = diagnostic.Diagnostic(<EOL>"<STR_LIT>", "<STR_LIT>", {},<EOL>arg.loc, [call.keywords[-<NUM_LIT:1>].loc])<EOL>self.diagnostic_engine.process(error)<EOL><DEDENT>else:<EOL><INDENT>call.args.append(arg)<EOL><DEDENT><DEDENT>return call<EOL>

arglist: (argument ',')* (argument [','] |
                                     '*' test (',' argument)* [',' '**' test] |
                                     '**' test)


@action(Seq(Loc("<STR_LIT>"), Opt(Rule("<STR_LIT>"))))<EOL><INDENT>def yield_expr__33(self, yield_loc, arg):<DEDENT>

if isinstance(arg, ast.YieldFrom):<EOL><INDENT>arg.yield_loc = yield_loc<EOL>arg.loc = arg.loc.join(arg.yield_loc)<EOL>return arg<EOL><DEDENT>elif arg is not None:<EOL><INDENT>return ast.Yield(value=arg,<EOL>yield_loc=yield_loc, loc=yield_loc.join(arg.loc))<EOL><DEDENT>else:<EOL><INDENT>return ast.Yield(value=None,<EOL>yield_loc=yield_loc, loc=yield_loc)<EOL><DEDENT>


if len(self.queue) == <NUM_LIT:0>:<EOL><INDENT>self._refill(eof_token)<EOL><DEDENT>return self.queue.pop(<NUM_LIT:0>)<EOL>

Returns token at ``offset`` as a :class:`Token` and advances ``offset``
to point past the end of the token, where the token has:

- *range* which is a :class:`pythonparser.source.Range` that includes
  the token but not surrounding whitespace,
- *kind* which is a string containing one of Python keywords or operators,
  ``newline``, ``float``, ``int``, ``complex``, ``strbegin``,
  ``strdata``, ``strend``, ``ident``, ``indent``, ``dedent`` or ``eof``
  (if ``eof_token`` is True).
- *value* which is the flags as lowercase string if *kind* is ``strbegin``,
  the string contents if *kind* is ``strdata``,
  the numeric value if *kind* is ``float``, ``int`` or ``complex``,
  the identifier if *kind* is ``ident`` and ``None`` in any other case.

:param eof_token: if true, will return a token with kind ``eof``
    when the input is exhausted; if false, will raise ``StopIteration``.


if len(self.queue) == <NUM_LIT:0>:<EOL><INDENT>self._refill(eof_token)<EOL><DEDENT>return self.queue[-<NUM_LIT:1>]<EOL>

Same as :meth:`next`, except the token is not dequeued.


line_begins = self._extract_line_begins()<EOL>lineno = lineno - self.first_line<EOL>if lineno >= <NUM_LIT:0> and lineno + <NUM_LIT:1> < len(line_begins):<EOL><INDENT>first, last = line_begins[lineno:lineno + <NUM_LIT:2>]<EOL>return self.source[first:last]<EOL><DEDENT>elif lineno >= <NUM_LIT:0> and lineno < len(line_begins):<EOL><INDENT>return self.source[line_begins[-<NUM_LIT:1>]:]<EOL><DEDENT>else:<EOL><INDENT>raise IndexError<EOL><DEDENT>

Returns line ``lineno`` from source, taking ``first_line`` into account,
or raises :exc:`IndexError` if ``lineno`` is out of range.


line_begins = self._extract_line_begins()<EOL>lineno = bisect.bisect_right(line_begins, offset) - <NUM_LIT:1><EOL>if offset >= <NUM_LIT:0> and offset <= len(self.source):<EOL><INDENT>return lineno + self.first_line, offset - line_begins[lineno]<EOL><DEDENT>else:<EOL><INDENT>raise IndexError<EOL><DEDENT>

Returns a ``line, column`` tuple for a character offset into the source,
orraises :exc:`IndexError` if ``lineno`` is out of range.


return "<STR_LIT>" %(self.source_buffer.name, self.begin_pos, self.end_pos, repr(self.expanded_from))<EOL>

Returns a human-readable representation of this range.


return Range(self.source_buffer, self.begin_pos, self.begin_pos,<EOL>expanded_from=expanded_from)<EOL>

Returns a range identical to this one, but indicating that
it was expanded from the range `expanded_from`.


return Range(self.source_buffer, self.begin_pos, self.begin_pos,<EOL>expanded_from=self.expanded_from)<EOL>

Returns a zero-length range located just before the beginning of this range.


return Range(self.source_buffer, self.end_pos, self.end_pos,<EOL>expanded_from=self.expanded_from)<EOL>

Returns a zero-length range located just after the end of this range.


return self.end_pos - self.begin_pos<EOL>

Returns the amount of characters spanned by the range.


line, column = self.source_buffer.decompose_position(self.begin_pos)<EOL>return column<EOL>

Returns a zero-based column number of the beginning of this range.


if self.begin().line() == self.end().line():<EOL><INDENT>return self.begin().column(), self.end().column()<EOL><DEDENT>else:<EOL><INDENT>return self.begin().column(), len(self.begin().source_line()) - <NUM_LIT:1><EOL><DEDENT>

Returns a [*begin*, *end*) tuple describing the range of columns spanned
by this range. If range spans more than one line, returned *end* is
the last column of the line.


line, column = self.source_buffer.decompose_position(self.begin_pos)<EOL>return line<EOL>

Returns the line number of the beginning of this range.


if self.source_buffer != other.source_buffer:<EOL><INDENT>raise ValueError<EOL><DEDENT>if self.expanded_from == other.expanded_from:<EOL><INDENT>expanded_from = self.expanded_from<EOL><DEDENT>else:<EOL><INDENT>expanded_from = None<EOL><DEDENT>return Range(self.source_buffer,<EOL>min(self.begin_pos, other.begin_pos),<EOL>max(self.end_pos, other.end_pos),<EOL>expanded_from=expanded_from)<EOL>

Returns the smallest possible range spanning both this range and other.
Raises :exc:`ValueError` if the ranges do not belong to the same
:class:`Buffer`.


return self.source_buffer.source[self.begin_pos:self.end_pos]<EOL>

Returns the source code covered by this range.


return self.source_buffer.source_line(self.line())<EOL>

Returns the line of source code containing the beginning of this range.


return [self.source_buffer.source_line(line)<EOL>for line in range(self.line(), self.end().line() + <NUM_LIT:1>)]<EOL>

Returns the lines of source code containing the entirety of this range.


if self.begin_pos != self.end_pos:<EOL><INDENT>return "<STR_LIT>" % (self.source_buffer.name,<EOL>self.line(), self.column() + <NUM_LIT:1>,<EOL>self.end().line(), self.end().column() + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return "<STR_LIT>" % (self.source_buffer.name,<EOL>self.line(), self.column() + <NUM_LIT:1>)<EOL><DEDENT>

Returns a Clang-style string representation of the beginning of this range.


return (type(self) == type(other) and<EOL>self.source_buffer == other.source_buffer and<EOL>self.begin_pos == other.begin_pos and<EOL>self.end_pos == other.end_pos and<EOL>self.expanded_from == other.expanded_from)<EOL>

Returns true if the ranges have the same source buffer, start and end position.


return not (self == other)<EOL>


self.ranges.append((range, replacement))<EOL>

Remove `range` and replace it with string `replacement`.


self.replace(range, "<STR_LIT>")<EOL>


self.replace(range.begin(), text)<EOL>


self.replace(range.end(), text)<EOL>


self._sort()<EOL>self._check()<EOL>rewritten, pos = [], <NUM_LIT:0><EOL>for range, replacement in self.ranges:<EOL><INDENT>rewritten.append(self.buffer.source[pos:range.begin_pos])<EOL>rewritten.append(replacement)<EOL>pos = range.end_pos<EOL><DEDENT>rewritten.append(self.buffer.source[pos:])<EOL>return Buffer("<STR_LIT>".join(rewritten), self.buffer.name, self.buffer.first_line)<EOL>

Return the rewritten source. May raise :class:`RewriterConflict`.


def parse_buffer(buffer, mode="<STR_LIT>", flags=[], version=None, engine=None):

if version is None:<EOL><INDENT>version = sys.version_info[<NUM_LIT:0>:<NUM_LIT:2>]<EOL><DEDENT>if engine is None:<EOL><INDENT>engine = pythonparser_diagnostic.Engine()<EOL><DEDENT>lexer = pythonparser_lexer.Lexer(buffer, version, engine)<EOL>if mode in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>lexer.interactive = True<EOL><DEDENT>parser = pythonparser_parser.Parser(lexer, version, engine)<EOL>parser.add_flags(flags)<EOL>if mode == "<STR_LIT>":<EOL><INDENT>return parser.file_input(), lexer.comments<EOL><DEDENT>elif mode == "<STR_LIT>":<EOL><INDENT>return parser.single_input(), lexer.comments<EOL><DEDENT>elif mode == "<STR_LIT>":<EOL><INDENT>return parser.eval_input(), lexer.comments<EOL><DEDENT>

Like :meth:`parse`, but accepts a :class:`source.Buffer` instead of
source and filename, and returns comments as well.

:see: :meth:`parse`
:return: (:class:`ast.AST`, list of :class:`source.Comment`)
    Abstract syntax tree and comments


def parse(source, filename="<STR_LIT>", mode="<STR_LIT>",<EOL>flags=[], version=None, engine=None):

ast, comments = parse_buffer(pythonparser_source.Buffer(source, filename),<EOL>mode, flags, version, engine)<EOL>return ast<EOL>

Parse a string into an abstract syntax tree.
This is the replacement for the built-in :meth:`..ast.parse`.

:param source: (string) Source code in the correct encoding
:param filename: (string) Filename of the source (used in diagnostics)
:param mode: (string) Execution mode. Pass ``"exec"`` to parse a module,
    ``"single"`` to parse a single (interactive) statement,
    and ``"eval"`` to parse an expression. In the last two cases,
    ``source`` must be terminated with an empty line
    (i.e. end with ``"\\n\\n"``).
:param flags: (list of string) Future flags.
    Equivalent to ``from __future__ import <flags>``.
:param version: (2-tuple of int) Major and minor version of Python
    syntax to recognize, ``sys.version_info[0:2]`` by default.
:param engine: (:class:`diagnostic.Engine`) Diagnostic engine,
    a fresh one is created by default
:return: (:class:`ast.AST`) Abstract syntax tree
:raise: :class:`diagnostic.Error`
    if the source code is not well-formed


def _MakeParallelBenchmark(p, work_func, *args):

def Benchmark(b):  <EOL><INDENT>e = threading.Event()<EOL>def Target():<EOL><INDENT>e.wait()<EOL>for _ in xrange(b.N / p):<EOL><INDENT>work_func(*args)<EOL><DEDENT><DEDENT>threads = []<EOL>for _ in xrange(p):<EOL><INDENT>t = threading.Thread(target=Target)<EOL>t.start()<EOL>threads.append(t)<EOL><DEDENT>b.ResetTimer()<EOL>e.set()<EOL>for t in threads:<EOL><INDENT>t.join()<EOL><DEDENT><DEDENT>return Benchmark<EOL>

Create and return a benchmark that runs work_func p times in parallel.


h = hash  <EOL>for _ in xrange(b.N):<EOL><INDENT>h('<STR_LIT>')<EOL><DEDENT>

Hashes the same value repeatedly to exercise any hash caching logic.


def _WriteXmlFile(filename, suite_duration, results):

xml_file = open(filename, '<STR_LIT:w>')<EOL>xml_file.write('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(sys.argv[<NUM_LIT:0>], len(results), suite_duration))<EOL>for result in results:<EOL><INDENT>xml_file.write('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(result.name, result.duration))<EOL>if result.properties:<EOL><INDENT>xml_file.write('<STR_LIT>')<EOL>for name in result.properties:<EOL><INDENT>value = result.properties[name]<EOL>if isinstance(value, float):<EOL><INDENT>formatted = '<STR_LIT>' % value<EOL><DEDENT>else:<EOL><INDENT>formatted = str(value)<EOL><DEDENT>xml_file.write('<STR_LIT>' %<EOL>(name, formatted))<EOL><DEDENT>xml_file.write('<STR_LIT>')<EOL><DEDENT>xml_file.write('<STR_LIT>')<EOL><DEDENT>xml_file.write('<STR_LIT>')<EOL>xml_file.close()<EOL>

Given a list of _BenchmarkResults, writes XML test results to filename.


sys.exit(_RunAll('<STR_LIT>', _RunOneBenchmark))<EOL>

Benchmarks all functions in __main__ with names like BenchmarkXyz().


sys.exit(_RunAll('<STR_LIT>', _RunOneTest))<EOL>

Runs all functions in __main__ with names like TestXyz().


def __init__(self, bench_func, target_duration):

self.bench_func = bench_func<EOL>self.target_duration = target_duration<EOL>self.start_time = <NUM_LIT:0><EOL>self.N = <NUM_LIT:1><EOL>

Set up this benchmark to run bench_func to be run for target_duration.


small_duration = <NUM_LIT> * self.target_duration<EOL>self.N = <NUM_LIT:1><EOL>self._RunOnce()<EOL>while self.duration < self.target_duration:<EOL><INDENT>if self.duration < small_duration:<EOL><INDENT>N = self.N * <NUM_LIT:10><EOL><DEDENT>else:<EOL><INDENT>N = int(self.N * (<NUM_LIT> * self.target_duration / self.duration))<EOL><DEDENT>if self.N == N:<EOL><INDENT>self.N += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>self.N = N<EOL><DEDENT>self._RunOnce()<EOL><DEDENT>

Attempt to run this benchmark for the target duration.


self.start_time = time.time()<EOL>

Clears the current elapsed time to discount expensive setup steps.


if not os.environ.get('<STR_LIT>'):<EOL><INDENT>return map(lambda x: '<STR_LIT:%s>' % format(x).strip(), values)<EOL><DEDENT>return map(lambda x: u'<STR_LIT>' % (x, unichr(x)), sorted(values))<EOL>

Return string with unicodenames (unless that is disabled)


<EOL>path = get_from_cache('<STR_LIT>', EXTENSIS_LANG_XML)<EOL>try:<EOL><INDENT>xml_content = open(path, '<STR_LIT:r>').read()<EOL><DEDENT>except IOError:<EOL><INDENT>logging.error('<STR_LIT>')<EOL>xml_content = '<STR_LIT>'<EOL><DEDENT>content = re.sub('<STR_LIT>', '<STR_LIT>', xml_content)<EOL>doc = etree.fromstring(content.lstrip('<STR_LIT>'))<EOL>return doc.findall('<STR_LIT>')<EOL>

Return all XML <scanning-codepoints> in received XML


result = re.sub('<STR_LIT>', '<STR_LIT>', codepoint.text)<EOL>return Extension.convert_to_list_of_unicodes(result)<EOL>

Return list of unicodes for <scanning-codepoints>


with codecs.open(filename, encoding='<STR_LIT:utf-8>') as namFile:<EOL><INDENT>return _parseNamelist(namFile)<EOL><DEDENT>

Parse filename as Namelist and return a tuple of
      (Codepoints set, header data dict)


def _loadNamelistIncludes(item, unique_glyphs, cache):

includes = item["<STR_LIT>"] = []<EOL>charset = item["<STR_LIT>"] = set() | item["<STR_LIT>"]<EOL>noCharcode = item["<STR_LIT>"] = set() | item["<STR_LIT>"]<EOL>dirname =  os.path.dirname(item["<STR_LIT>"])<EOL>for include in item["<STR_LIT>"]["<STR_LIT>"]:<EOL><INDENT>includeFile = os.path.join(dirname, include)<EOL>try:<EOL><INDENT>includedItem = readNamelist(includeFile, unique_glyphs, cache)<EOL><DEDENT>except NamelistRecursionError:<EOL><INDENT>continue<EOL><DEDENT>if includedItem in includes:<EOL><INDENT>continue<EOL><DEDENT>includes.append(includedItem)<EOL>charset |= includedItem["<STR_LIT>"]<EOL>noCharcode |= includedItem["<STR_LIT>"]<EOL><DEDENT>return item<EOL>

Load the includes of an encoding Namelist files.

    This is an implementation detail of readNamelist.


def __readNamelist(cache, filename, unique_glyphs):

if filename in cache:<EOL><INDENT>item = cache[filename]<EOL><DEDENT>else:<EOL><INDENT>cps, header, noncodes = parseNamelist(filename)<EOL>item = {<EOL>"<STR_LIT>": filename<EOL>, "<STR_LIT>": cps<EOL>, "<STR_LIT>": header<EOL>, "<STR_LIT>": noncodes<EOL>, "<STR_LIT>": None <EOL>, "<STR_LIT>": None <EOL>, "<STR_LIT>": None<EOL>}<EOL>cache[filename] = item<EOL><DEDENT>if unique_glyphs or item["<STR_LIT>"] is not None:<EOL><INDENT>return item<EOL><DEDENT>_loadNamelistIncludes(item, unique_glyphs, cache)<EOL>return item<EOL>

Return a dict with the data of an encoding Namelist file.

    This is an implementation detail of readNamelist.


def _readNamelist(currentlyIncluding, cache, namFilename, unique_glyphs):

<EOL>filename = os.path.abspath(os.path.normcase(namFilename))<EOL>if filename in currentlyIncluding:<EOL><INDENT>raise NamelistRecursionError(filename)<EOL><DEDENT>currentlyIncluding.add(filename)<EOL>try:<EOL><INDENT>result = __readNamelist(cache, filename, unique_glyphs)<EOL><DEDENT>finally:<EOL><INDENT>currentlyIncluding.remove(filename)<EOL><DEDENT>return result<EOL>

Detect infinite recursion and prevent it.

    This is an implementation detail of readNamelist.

    Raises NamelistRecursionError if namFilename is in the process of being included


def readNamelist(namFilename, unique_glyphs=False, cache=None):

currentlyIncluding = set()<EOL>if not cache:<EOL><INDENT>cache = {}<EOL><DEDENT>return _readNamelist(currentlyIncluding, cache, namFilename, unique_glyphs)<EOL>

Args:
  namFilename: The path to the  Namelist file.
  unique_glyphs: Optional, whether to only include glyphs unique to subset.
  cache: Optional, a dict used to cache loaded Namelist files

Returns:
A dict with following keys:
"fileName": (string) absolut path to namFilename
"ownCharset": (set) the set of codepoints defined by the file itself
"header": (dict) the result of _parseNamelistHeader
"includes":
    (set) if unique_glyphs=False, the resulting dicts of readNamelist
          for each of the include files
    (None) if unique_glyphs=True
"charset":
    (set) if unique_glyphs=False, the union of "ownCharset" and all
          "charset" items of each included file
    (None) if unique_glyphs=True

If you are using  unique_glyphs=True and an external cache, don't expect
the keys "includes" and "charset" to have a specific value.
Depending on the state of cache, if unique_glyphs=True the returned
dict may have None values for its "includes" and "charset" keys.


def codepointsInNamelist(namFilename, unique_glyphs=False, cache=None):

key = '<STR_LIT>' if not unique_glyphs else '<STR_LIT>'<EOL>internals_dir = os.path.dirname(os.path.abspath(__file__))<EOL>target = os.path.join(internals_dir, namFilename)<EOL>result = readNamelist(target, unique_glyphs, cache)<EOL>return result[key]<EOL>

Returns the set of codepoints contained in a given Namelist file.

    This is a replacement CodepointsInSubset and implements the "#$ include"
    header format.

    Args:
      namFilename: The path to the  Namelist file.
      unique_glyphs: Optional, whether to only include glyphs unique to subset.
    Returns:
      A set containing the glyphs in the subset.


results = []<EOL>for charset in _library.charsets:<EOL><INDENT>if self._charsets:<EOL><INDENT>cn = getattr(charset, '<STR_LIT>', False)<EOL>abbr = getattr(charset, '<STR_LIT>', False)<EOL>nn = getattr(charset, '<STR_LIT>', False)<EOL>naive = getattr(charset, '<STR_LIT>', False)<EOL>if cn and cn.lower() in self._charsets:<EOL><INDENT>results.append(charset)<EOL><DEDENT>elif nn and nn.lower() in self._charsets:<EOL><INDENT>results.append(charset)<EOL><DEDENT>elif naive and naive.lower() in self._charsets:<EOL><INDENT>results.append(charset)<EOL><DEDENT>elif abbr and abbr.lower() in self._charsets:<EOL><INDENT>results.append(charset)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>results.append(charset)<EOL><DEDENT><DEDENT>for result in results:<EOL><INDENT>yield CharsetInfo(self, result)<EOL><DEDENT>

Returns list of CharsetInfo about supported orthographies


return "<STR_LIT>"<EOL>

TODO: Fix this so that pyfontaine falls back to using fontTools to get glyph names
if getGlyphNames() is really needed by the given mode of use.


def __init__(self, path_or_state, argv=None, workspace_url=None, policy='<STR_LIT>', **kwargs):

if isinstance(path_or_state, str):<EOL><INDENT>if not os.path.isfile(path_or_state):<EOL><INDENT>raise OSError(f'<STR_LIT>')<EOL><DEDENT>initial_state = _make_initial_state(path_or_state, argv=argv, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>initial_state = path_or_state<EOL><DEDENT>super().__init__(initial_state, workspace_url=workspace_url, policy=policy, **kwargs)<EOL>self.subscribe('<STR_LIT>', self._generate_testcase_callback)<EOL>

:param path_or_state: Path to binary or a state (object) to begin from.
:param argv: arguments passed to the binary.


@classmethod<EOL><INDENT>def linux(cls, path, argv=None, envp=None, entry_symbol=None, symbolic_files=None, concrete_start='<STR_LIT>', pure_symbolic=False, stdin_size=None, **kwargs):<DEDENT>

if stdin_size is None:<EOL><INDENT>stdin_size = consts.stdin_size<EOL><DEDENT>try:<EOL><INDENT>return cls(_make_linux(path, argv, envp, entry_symbol, symbolic_files, concrete_start, pure_symbolic, stdin_size), **kwargs)<EOL><DEDENT>except elftools.common.exceptions.ELFError:<EOL><INDENT>raise Exception(f'<STR_LIT>')<EOL><DEDENT>

Constructor for Linux binary analysis.

:param str path: Path to binary to analyze
:param argv: Arguments to provide to the binary
:type argv: list[str]
:param envp: Environment to provide to the binary
:type envp: dict[str, str]
:param entry_symbol: Entry symbol to resolve to start execution
:type envp: str
:param symbolic_files: Filenames to mark as having symbolic input
:type symbolic_files: list[str]
:param str concrete_start: Concrete stdin to use before symbolic input
:param int stdin_size: symbolic stdin size to use
:param kwargs: Forwarded to the Manticore constructor
:return: Manticore instance, initialized with a Linux State
:rtype: Manticore


@classmethod<EOL><INDENT>def decree(cls, path, concrete_start='<STR_LIT>', **kwargs):<DEDENT>

try:<EOL><INDENT>return cls(_make_decree(path, concrete_start), **kwargs)<EOL><DEDENT>except KeyError:  <EOL><INDENT>raise Exception(f'<STR_LIT>')<EOL><DEDENT>

Constructor for Decree binary analysis.

:param str path: Path to binary to analyze
:param str concrete_start: Concrete stdin to use before symbolic input
:param kwargs: Forwarded to the Manticore constructor
:return: Manticore instance, initialized with a Decree State
:rtype: Manticore


return self._initial_state.platform.program<EOL>

Assumes that self._initial_state.platform.program always
refers to current program. Might not be true in case program
calls execve().


def callback(manticore_obj, state):<EOL><INDENT>f(state)<EOL><DEDENT>self.subscribe('<STR_LIT>', types.MethodType(callback, self))<EOL>return f<EOL>

A decorator used to register a hook function to run before analysis begins. Hook
function takes one :class:`~manticore.core.state.State` argument.


def decorator(f):<EOL><INDENT>self.add_hook(pc, f)<EOL>return f<EOL><DEDENT>return decorator<EOL>

A decorator used to register a hook function for a given instruction address.
Equivalent to calling :func:`~add_hook`.

:param pc: Address of instruction to hook
:type pc: int or None


if not (isinstance(pc, int) or pc is None):<EOL><INDENT>raise TypeError(f"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self._hooks.setdefault(pc, set()).add(callback)<EOL>if self._hooks:<EOL><INDENT>self._executor.subscribe('<STR_LIT>', self._hook_callback)<EOL><DEDENT><DEDENT>

Add a callback to be invoked on executing a program counter. Pass `None`
for pc to invoke callback on every instruction. `callback` should be a callable
that takes one :class:`~manticore.core.state.State` argument.

:param pc: Address of instruction to hook
:type pc: int or None
:param callable callback: Hook function


def _hook_callback(self, state, pc, instruction):

<EOL>if issymbolic(pc):<EOL><INDENT>return<EOL><DEDENT>for cb in self._hooks.get(pc, []):<EOL><INDENT>cb(state)<EOL><DEDENT>for cb in self._hooks.get(None, []):<EOL><INDENT>cb(state)<EOL><DEDENT>


with open(self.binary_path, '<STR_LIT:rb>') as f:<EOL><INDENT>elffile = ELFFile(f)<EOL>for section in elffile.iter_sections():<EOL><INDENT>if not isinstance(section, SymbolTableSection):<EOL><INDENT>continue<EOL><DEDENT>symbols = section.get_symbol_by_name(symbol)<EOL>if not symbols:<EOL><INDENT>continue<EOL><DEDENT>return symbols[<NUM_LIT:0>].entry['<STR_LIT>']<EOL><DEDENT>raise ValueError(f"<STR_LIT>")<EOL><DEDENT>

A helper method used to resolve a symbol name into a memory address when
injecting hooks for analysis.

:param symbol: function name to be resolved
:type symbol: string

:param line: if more functions present, optional line number can be included
:type line: int or None