Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: sre_constants.py
#
[0] Fix | Delete
# Secret Labs' Regular Expression Engine
[1] Fix | Delete
#
[2] Fix | Delete
# various symbols used by the regular expression engine.
[3] Fix | Delete
# run this script to update the _sre include files!
[4] Fix | Delete
#
[5] Fix | Delete
# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
[6] Fix | Delete
#
[7] Fix | Delete
# See the sre.py file for information on usage and redistribution.
[8] Fix | Delete
#
[9] Fix | Delete
[10] Fix | Delete
"""Internal support module for sre"""
[11] Fix | Delete
[12] Fix | Delete
# update when constants are added or removed
[13] Fix | Delete
[14] Fix | Delete
MAGIC = 20171005
[15] Fix | Delete
[16] Fix | Delete
from _sre import MAXREPEAT, MAXGROUPS
[17] Fix | Delete
[18] Fix | Delete
# SRE standard exception (access as sre.error)
[19] Fix | Delete
# should this really be here?
[20] Fix | Delete
[21] Fix | Delete
class error(Exception):
[22] Fix | Delete
"""Exception raised for invalid regular expressions.
[23] Fix | Delete
[24] Fix | Delete
Attributes:
[25] Fix | Delete
[26] Fix | Delete
msg: The unformatted error message
[27] Fix | Delete
pattern: The regular expression pattern
[28] Fix | Delete
pos: The index in the pattern where compilation failed (may be None)
[29] Fix | Delete
lineno: The line corresponding to pos (may be None)
[30] Fix | Delete
colno: The column corresponding to pos (may be None)
[31] Fix | Delete
"""
[32] Fix | Delete
[33] Fix | Delete
__module__ = 're'
[34] Fix | Delete
[35] Fix | Delete
def __init__(self, msg, pattern=None, pos=None):
[36] Fix | Delete
self.msg = msg
[37] Fix | Delete
self.pattern = pattern
[38] Fix | Delete
self.pos = pos
[39] Fix | Delete
if pattern is not None and pos is not None:
[40] Fix | Delete
msg = '%s at position %d' % (msg, pos)
[41] Fix | Delete
if isinstance(pattern, str):
[42] Fix | Delete
newline = '\n'
[43] Fix | Delete
else:
[44] Fix | Delete
newline = b'\n'
[45] Fix | Delete
self.lineno = pattern.count(newline, 0, pos) + 1
[46] Fix | Delete
self.colno = pos - pattern.rfind(newline, 0, pos)
[47] Fix | Delete
if newline in pattern:
[48] Fix | Delete
msg = '%s (line %d, column %d)' % (msg, self.lineno, self.colno)
[49] Fix | Delete
else:
[50] Fix | Delete
self.lineno = self.colno = None
[51] Fix | Delete
super().__init__(msg)
[52] Fix | Delete
[53] Fix | Delete
[54] Fix | Delete
class _NamedIntConstant(int):
[55] Fix | Delete
def __new__(cls, value, name):
[56] Fix | Delete
self = super(_NamedIntConstant, cls).__new__(cls, value)
[57] Fix | Delete
self.name = name
[58] Fix | Delete
return self
[59] Fix | Delete
[60] Fix | Delete
def __repr__(self):
[61] Fix | Delete
return self.name
[62] Fix | Delete
[63] Fix | Delete
MAXREPEAT = _NamedIntConstant(MAXREPEAT, 'MAXREPEAT')
[64] Fix | Delete
[65] Fix | Delete
def _makecodes(names):
[66] Fix | Delete
names = names.strip().split()
[67] Fix | Delete
items = [_NamedIntConstant(i, name) for i, name in enumerate(names)]
[68] Fix | Delete
globals().update({item.name: item for item in items})
[69] Fix | Delete
return items
[70] Fix | Delete
[71] Fix | Delete
# operators
[72] Fix | Delete
# failure=0 success=1 (just because it looks better that way :-)
[73] Fix | Delete
OPCODES = _makecodes("""
[74] Fix | Delete
FAILURE SUCCESS
[75] Fix | Delete
[76] Fix | Delete
ANY ANY_ALL
[77] Fix | Delete
ASSERT ASSERT_NOT
[78] Fix | Delete
AT
[79] Fix | Delete
BRANCH
[80] Fix | Delete
CALL
[81] Fix | Delete
CATEGORY
[82] Fix | Delete
CHARSET BIGCHARSET
[83] Fix | Delete
GROUPREF GROUPREF_EXISTS
[84] Fix | Delete
IN
[85] Fix | Delete
INFO
[86] Fix | Delete
JUMP
[87] Fix | Delete
LITERAL
[88] Fix | Delete
MARK
[89] Fix | Delete
MAX_UNTIL
[90] Fix | Delete
MIN_UNTIL
[91] Fix | Delete
NOT_LITERAL
[92] Fix | Delete
NEGATE
[93] Fix | Delete
RANGE
[94] Fix | Delete
REPEAT
[95] Fix | Delete
REPEAT_ONE
[96] Fix | Delete
SUBPATTERN
[97] Fix | Delete
MIN_REPEAT_ONE
[98] Fix | Delete
[99] Fix | Delete
GROUPREF_IGNORE
[100] Fix | Delete
IN_IGNORE
[101] Fix | Delete
LITERAL_IGNORE
[102] Fix | Delete
NOT_LITERAL_IGNORE
[103] Fix | Delete
[104] Fix | Delete
GROUPREF_LOC_IGNORE
[105] Fix | Delete
IN_LOC_IGNORE
[106] Fix | Delete
LITERAL_LOC_IGNORE
[107] Fix | Delete
NOT_LITERAL_LOC_IGNORE
[108] Fix | Delete
[109] Fix | Delete
GROUPREF_UNI_IGNORE
[110] Fix | Delete
IN_UNI_IGNORE
[111] Fix | Delete
LITERAL_UNI_IGNORE
[112] Fix | Delete
NOT_LITERAL_UNI_IGNORE
[113] Fix | Delete
RANGE_UNI_IGNORE
[114] Fix | Delete
[115] Fix | Delete
MIN_REPEAT MAX_REPEAT
[116] Fix | Delete
""")
[117] Fix | Delete
del OPCODES[-2:] # remove MIN_REPEAT and MAX_REPEAT
[118] Fix | Delete
[119] Fix | Delete
# positions
[120] Fix | Delete
ATCODES = _makecodes("""
[121] Fix | Delete
AT_BEGINNING AT_BEGINNING_LINE AT_BEGINNING_STRING
[122] Fix | Delete
AT_BOUNDARY AT_NON_BOUNDARY
[123] Fix | Delete
AT_END AT_END_LINE AT_END_STRING
[124] Fix | Delete
[125] Fix | Delete
AT_LOC_BOUNDARY AT_LOC_NON_BOUNDARY
[126] Fix | Delete
[127] Fix | Delete
AT_UNI_BOUNDARY AT_UNI_NON_BOUNDARY
[128] Fix | Delete
""")
[129] Fix | Delete
[130] Fix | Delete
# categories
[131] Fix | Delete
CHCODES = _makecodes("""
[132] Fix | Delete
CATEGORY_DIGIT CATEGORY_NOT_DIGIT
[133] Fix | Delete
CATEGORY_SPACE CATEGORY_NOT_SPACE
[134] Fix | Delete
CATEGORY_WORD CATEGORY_NOT_WORD
[135] Fix | Delete
CATEGORY_LINEBREAK CATEGORY_NOT_LINEBREAK
[136] Fix | Delete
[137] Fix | Delete
CATEGORY_LOC_WORD CATEGORY_LOC_NOT_WORD
[138] Fix | Delete
[139] Fix | Delete
CATEGORY_UNI_DIGIT CATEGORY_UNI_NOT_DIGIT
[140] Fix | Delete
CATEGORY_UNI_SPACE CATEGORY_UNI_NOT_SPACE
[141] Fix | Delete
CATEGORY_UNI_WORD CATEGORY_UNI_NOT_WORD
[142] Fix | Delete
CATEGORY_UNI_LINEBREAK CATEGORY_UNI_NOT_LINEBREAK
[143] Fix | Delete
""")
[144] Fix | Delete
[145] Fix | Delete
[146] Fix | Delete
# replacement operations for "ignore case" mode
[147] Fix | Delete
OP_IGNORE = {
[148] Fix | Delete
LITERAL: LITERAL_IGNORE,
[149] Fix | Delete
NOT_LITERAL: NOT_LITERAL_IGNORE,
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
OP_LOCALE_IGNORE = {
[153] Fix | Delete
LITERAL: LITERAL_LOC_IGNORE,
[154] Fix | Delete
NOT_LITERAL: NOT_LITERAL_LOC_IGNORE,
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
OP_UNICODE_IGNORE = {
[158] Fix | Delete
LITERAL: LITERAL_UNI_IGNORE,
[159] Fix | Delete
NOT_LITERAL: NOT_LITERAL_UNI_IGNORE,
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
AT_MULTILINE = {
[163] Fix | Delete
AT_BEGINNING: AT_BEGINNING_LINE,
[164] Fix | Delete
AT_END: AT_END_LINE
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
AT_LOCALE = {
[168] Fix | Delete
AT_BOUNDARY: AT_LOC_BOUNDARY,
[169] Fix | Delete
AT_NON_BOUNDARY: AT_LOC_NON_BOUNDARY
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
AT_UNICODE = {
[173] Fix | Delete
AT_BOUNDARY: AT_UNI_BOUNDARY,
[174] Fix | Delete
AT_NON_BOUNDARY: AT_UNI_NON_BOUNDARY
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
CH_LOCALE = {
[178] Fix | Delete
CATEGORY_DIGIT: CATEGORY_DIGIT,
[179] Fix | Delete
CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT,
[180] Fix | Delete
CATEGORY_SPACE: CATEGORY_SPACE,
[181] Fix | Delete
CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE,
[182] Fix | Delete
CATEGORY_WORD: CATEGORY_LOC_WORD,
[183] Fix | Delete
CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD,
[184] Fix | Delete
CATEGORY_LINEBREAK: CATEGORY_LINEBREAK,
[185] Fix | Delete
CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
CH_UNICODE = {
[189] Fix | Delete
CATEGORY_DIGIT: CATEGORY_UNI_DIGIT,
[190] Fix | Delete
CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT,
[191] Fix | Delete
CATEGORY_SPACE: CATEGORY_UNI_SPACE,
[192] Fix | Delete
CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE,
[193] Fix | Delete
CATEGORY_WORD: CATEGORY_UNI_WORD,
[194] Fix | Delete
CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD,
[195] Fix | Delete
CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK,
[196] Fix | Delete
CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
# flags
[200] Fix | Delete
SRE_FLAG_TEMPLATE = 1 # template mode (disable backtracking)
[201] Fix | Delete
SRE_FLAG_IGNORECASE = 2 # case insensitive
[202] Fix | Delete
SRE_FLAG_LOCALE = 4 # honour system locale
[203] Fix | Delete
SRE_FLAG_MULTILINE = 8 # treat target as multiline string
[204] Fix | Delete
SRE_FLAG_DOTALL = 16 # treat target as a single string
[205] Fix | Delete
SRE_FLAG_UNICODE = 32 # use unicode "locale"
[206] Fix | Delete
SRE_FLAG_VERBOSE = 64 # ignore whitespace and comments
[207] Fix | Delete
SRE_FLAG_DEBUG = 128 # debugging
[208] Fix | Delete
SRE_FLAG_ASCII = 256 # use ascii "locale"
[209] Fix | Delete
[210] Fix | Delete
# flags for INFO primitive
[211] Fix | Delete
SRE_INFO_PREFIX = 1 # has prefix
[212] Fix | Delete
SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix)
[213] Fix | Delete
SRE_INFO_CHARSET = 4 # pattern starts with character from given set
[214] Fix | Delete
[215] Fix | Delete
if __name__ == "__main__":
[216] Fix | Delete
def dump(f, d, prefix):
[217] Fix | Delete
items = sorted(d)
[218] Fix | Delete
for item in items:
[219] Fix | Delete
f.write("#define %s_%s %d\n" % (prefix, item, item))
[220] Fix | Delete
with open("sre_constants.h", "w") as f:
[221] Fix | Delete
f.write("""\
[222] Fix | Delete
/*
[223] Fix | Delete
* Secret Labs' Regular Expression Engine
[224] Fix | Delete
*
[225] Fix | Delete
* regular expression matching engine
[226] Fix | Delete
*
[227] Fix | Delete
* NOTE: This file is generated by sre_constants.py. If you need
[228] Fix | Delete
* to change anything in here, edit sre_constants.py and run it.
[229] Fix | Delete
*
[230] Fix | Delete
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
[231] Fix | Delete
*
[232] Fix | Delete
* See the _sre.c file for information on usage and redistribution.
[233] Fix | Delete
*/
[234] Fix | Delete
[235] Fix | Delete
""")
[236] Fix | Delete
[237] Fix | Delete
f.write("#define SRE_MAGIC %d\n" % MAGIC)
[238] Fix | Delete
[239] Fix | Delete
dump(f, OPCODES, "SRE_OP")
[240] Fix | Delete
dump(f, ATCODES, "SRE")
[241] Fix | Delete
dump(f, CHCODES, "SRE")
[242] Fix | Delete
[243] Fix | Delete
f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE)
[244] Fix | Delete
f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE)
[245] Fix | Delete
f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE)
[246] Fix | Delete
f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE)
[247] Fix | Delete
f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL)
[248] Fix | Delete
f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE)
[249] Fix | Delete
f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
[250] Fix | Delete
f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG)
[251] Fix | Delete
f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII)
[252] Fix | Delete
[253] Fix | Delete
f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX)
[254] Fix | Delete
f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL)
[255] Fix | Delete
f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
[256] Fix | Delete
[257] Fix | Delete
print("done")
[258] Fix | Delete
[259] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function