Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../proc/self/root/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 = 20140917
[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
def __init__(self, msg, pattern=None, pos=None):
[34] Fix | Delete
self.msg = msg
[35] Fix | Delete
self.pattern = pattern
[36] Fix | Delete
self.pos = pos
[37] Fix | Delete
if pattern is not None and pos is not None:
[38] Fix | Delete
msg = '%s at position %d' % (msg, pos)
[39] Fix | Delete
if isinstance(pattern, str):
[40] Fix | Delete
newline = '\n'
[41] Fix | Delete
else:
[42] Fix | Delete
newline = b'\n'
[43] Fix | Delete
self.lineno = pattern.count(newline, 0, pos) + 1
[44] Fix | Delete
self.colno = pos - pattern.rfind(newline, 0, pos)
[45] Fix | Delete
if newline in pattern:
[46] Fix | Delete
msg = '%s (line %d, column %d)' % (msg, self.lineno, self.colno)
[47] Fix | Delete
else:
[48] Fix | Delete
self.lineno = self.colno = None
[49] Fix | Delete
super().__init__(msg)
[50] Fix | Delete
[51] Fix | Delete
[52] Fix | Delete
class _NamedIntConstant(int):
[53] Fix | Delete
def __new__(cls, value, name):
[54] Fix | Delete
self = super(_NamedIntConstant, cls).__new__(cls, value)
[55] Fix | Delete
self.name = name
[56] Fix | Delete
return self
[57] Fix | Delete
[58] Fix | Delete
def __str__(self):
[59] Fix | Delete
return self.name
[60] Fix | Delete
[61] Fix | Delete
__repr__ = __str__
[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 GROUPREF_IGNORE
[84] Fix | Delete
IN IN_IGNORE
[85] Fix | Delete
INFO
[86] Fix | Delete
JUMP
[87] Fix | Delete
LITERAL LITERAL_IGNORE
[88] Fix | Delete
MARK
[89] Fix | Delete
MAX_UNTIL
[90] Fix | Delete
MIN_UNTIL
[91] Fix | Delete
NOT_LITERAL NOT_LITERAL_IGNORE
[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
RANGE_IGNORE
[99] Fix | Delete
[100] Fix | Delete
MIN_REPEAT MAX_REPEAT
[101] Fix | Delete
""")
[102] Fix | Delete
del OPCODES[-2:] # remove MIN_REPEAT and MAX_REPEAT
[103] Fix | Delete
[104] Fix | Delete
# positions
[105] Fix | Delete
ATCODES = _makecodes("""
[106] Fix | Delete
AT_BEGINNING AT_BEGINNING_LINE AT_BEGINNING_STRING
[107] Fix | Delete
AT_BOUNDARY AT_NON_BOUNDARY
[108] Fix | Delete
AT_END AT_END_LINE AT_END_STRING
[109] Fix | Delete
AT_LOC_BOUNDARY AT_LOC_NON_BOUNDARY
[110] Fix | Delete
AT_UNI_BOUNDARY AT_UNI_NON_BOUNDARY
[111] Fix | Delete
""")
[112] Fix | Delete
[113] Fix | Delete
# categories
[114] Fix | Delete
CHCODES = _makecodes("""
[115] Fix | Delete
CATEGORY_DIGIT CATEGORY_NOT_DIGIT
[116] Fix | Delete
CATEGORY_SPACE CATEGORY_NOT_SPACE
[117] Fix | Delete
CATEGORY_WORD CATEGORY_NOT_WORD
[118] Fix | Delete
CATEGORY_LINEBREAK CATEGORY_NOT_LINEBREAK
[119] Fix | Delete
CATEGORY_LOC_WORD CATEGORY_LOC_NOT_WORD
[120] Fix | Delete
CATEGORY_UNI_DIGIT CATEGORY_UNI_NOT_DIGIT
[121] Fix | Delete
CATEGORY_UNI_SPACE CATEGORY_UNI_NOT_SPACE
[122] Fix | Delete
CATEGORY_UNI_WORD CATEGORY_UNI_NOT_WORD
[123] Fix | Delete
CATEGORY_UNI_LINEBREAK CATEGORY_UNI_NOT_LINEBREAK
[124] Fix | Delete
""")
[125] Fix | Delete
[126] Fix | Delete
[127] Fix | Delete
# replacement operations for "ignore case" mode
[128] Fix | Delete
OP_IGNORE = {
[129] Fix | Delete
GROUPREF: GROUPREF_IGNORE,
[130] Fix | Delete
IN: IN_IGNORE,
[131] Fix | Delete
LITERAL: LITERAL_IGNORE,
[132] Fix | Delete
NOT_LITERAL: NOT_LITERAL_IGNORE,
[133] Fix | Delete
RANGE: RANGE_IGNORE,
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
AT_MULTILINE = {
[137] Fix | Delete
AT_BEGINNING: AT_BEGINNING_LINE,
[138] Fix | Delete
AT_END: AT_END_LINE
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
AT_LOCALE = {
[142] Fix | Delete
AT_BOUNDARY: AT_LOC_BOUNDARY,
[143] Fix | Delete
AT_NON_BOUNDARY: AT_LOC_NON_BOUNDARY
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
AT_UNICODE = {
[147] Fix | Delete
AT_BOUNDARY: AT_UNI_BOUNDARY,
[148] Fix | Delete
AT_NON_BOUNDARY: AT_UNI_NON_BOUNDARY
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
CH_LOCALE = {
[152] Fix | Delete
CATEGORY_DIGIT: CATEGORY_DIGIT,
[153] Fix | Delete
CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT,
[154] Fix | Delete
CATEGORY_SPACE: CATEGORY_SPACE,
[155] Fix | Delete
CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE,
[156] Fix | Delete
CATEGORY_WORD: CATEGORY_LOC_WORD,
[157] Fix | Delete
CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD,
[158] Fix | Delete
CATEGORY_LINEBREAK: CATEGORY_LINEBREAK,
[159] Fix | Delete
CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
CH_UNICODE = {
[163] Fix | Delete
CATEGORY_DIGIT: CATEGORY_UNI_DIGIT,
[164] Fix | Delete
CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT,
[165] Fix | Delete
CATEGORY_SPACE: CATEGORY_UNI_SPACE,
[166] Fix | Delete
CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE,
[167] Fix | Delete
CATEGORY_WORD: CATEGORY_UNI_WORD,
[168] Fix | Delete
CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD,
[169] Fix | Delete
CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK,
[170] Fix | Delete
CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
# flags
[174] Fix | Delete
SRE_FLAG_TEMPLATE = 1 # template mode (disable backtracking)
[175] Fix | Delete
SRE_FLAG_IGNORECASE = 2 # case insensitive
[176] Fix | Delete
SRE_FLAG_LOCALE = 4 # honour system locale
[177] Fix | Delete
SRE_FLAG_MULTILINE = 8 # treat target as multiline string
[178] Fix | Delete
SRE_FLAG_DOTALL = 16 # treat target as a single string
[179] Fix | Delete
SRE_FLAG_UNICODE = 32 # use unicode "locale"
[180] Fix | Delete
SRE_FLAG_VERBOSE = 64 # ignore whitespace and comments
[181] Fix | Delete
SRE_FLAG_DEBUG = 128 # debugging
[182] Fix | Delete
SRE_FLAG_ASCII = 256 # use ascii "locale"
[183] Fix | Delete
[184] Fix | Delete
# flags for INFO primitive
[185] Fix | Delete
SRE_INFO_PREFIX = 1 # has prefix
[186] Fix | Delete
SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix)
[187] Fix | Delete
SRE_INFO_CHARSET = 4 # pattern starts with character from given set
[188] Fix | Delete
[189] Fix | Delete
if __name__ == "__main__":
[190] Fix | Delete
def dump(f, d, prefix):
[191] Fix | Delete
items = sorted(d)
[192] Fix | Delete
for item in items:
[193] Fix | Delete
f.write("#define %s_%s %d\n" % (prefix, item, item))
[194] Fix | Delete
with open("sre_constants.h", "w") as f:
[195] Fix | Delete
f.write("""\
[196] Fix | Delete
/*
[197] Fix | Delete
* Secret Labs' Regular Expression Engine
[198] Fix | Delete
*
[199] Fix | Delete
* regular expression matching engine
[200] Fix | Delete
*
[201] Fix | Delete
* NOTE: This file is generated by sre_constants.py. If you need
[202] Fix | Delete
* to change anything in here, edit sre_constants.py and run it.
[203] Fix | Delete
*
[204] Fix | Delete
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
[205] Fix | Delete
*
[206] Fix | Delete
* See the _sre.c file for information on usage and redistribution.
[207] Fix | Delete
*/
[208] Fix | Delete
[209] Fix | Delete
""")
[210] Fix | Delete
[211] Fix | Delete
f.write("#define SRE_MAGIC %d\n" % MAGIC)
[212] Fix | Delete
[213] Fix | Delete
dump(f, OPCODES, "SRE_OP")
[214] Fix | Delete
dump(f, ATCODES, "SRE")
[215] Fix | Delete
dump(f, CHCODES, "SRE")
[216] Fix | Delete
[217] Fix | Delete
f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE)
[218] Fix | Delete
f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE)
[219] Fix | Delete
f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE)
[220] Fix | Delete
f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE)
[221] Fix | Delete
f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL)
[222] Fix | Delete
f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE)
[223] Fix | Delete
f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
[224] Fix | Delete
f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG)
[225] Fix | Delete
f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII)
[226] Fix | Delete
[227] Fix | Delete
f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX)
[228] Fix | Delete
f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL)
[229] Fix | Delete
f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
[230] Fix | Delete
[231] Fix | Delete
print("done")
[232] Fix | Delete
[233] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function