Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../site-pac.../yaml
File: constructor.py
[0] Fix | Delete
__all__ = ['BaseConstructor', 'SafeConstructor', 'Constructor',
[1] Fix | Delete
'ConstructorError']
[2] Fix | Delete
[3] Fix | Delete
from .error import *
[4] Fix | Delete
from .nodes import *
[5] Fix | Delete
[6] Fix | Delete
import collections, datetime, base64, binascii, re, sys, types
[7] Fix | Delete
[8] Fix | Delete
class ConstructorError(MarkedYAMLError):
[9] Fix | Delete
pass
[10] Fix | Delete
[11] Fix | Delete
class BaseConstructor:
[12] Fix | Delete
[13] Fix | Delete
yaml_constructors = {}
[14] Fix | Delete
yaml_multi_constructors = {}
[15] Fix | Delete
[16] Fix | Delete
def __init__(self):
[17] Fix | Delete
self.constructed_objects = {}
[18] Fix | Delete
self.recursive_objects = {}
[19] Fix | Delete
self.state_generators = []
[20] Fix | Delete
self.deep_construct = False
[21] Fix | Delete
[22] Fix | Delete
def check_data(self):
[23] Fix | Delete
# If there are more documents available?
[24] Fix | Delete
return self.check_node()
[25] Fix | Delete
[26] Fix | Delete
def get_data(self):
[27] Fix | Delete
# Construct and return the next document.
[28] Fix | Delete
if self.check_node():
[29] Fix | Delete
return self.construct_document(self.get_node())
[30] Fix | Delete
[31] Fix | Delete
def get_single_data(self):
[32] Fix | Delete
# Ensure that the stream contains a single document and construct it.
[33] Fix | Delete
node = self.get_single_node()
[34] Fix | Delete
if node is not None:
[35] Fix | Delete
return self.construct_document(node)
[36] Fix | Delete
return None
[37] Fix | Delete
[38] Fix | Delete
def construct_document(self, node):
[39] Fix | Delete
data = self.construct_object(node)
[40] Fix | Delete
while self.state_generators:
[41] Fix | Delete
state_generators = self.state_generators
[42] Fix | Delete
self.state_generators = []
[43] Fix | Delete
for generator in state_generators:
[44] Fix | Delete
for dummy in generator:
[45] Fix | Delete
pass
[46] Fix | Delete
self.constructed_objects = {}
[47] Fix | Delete
self.recursive_objects = {}
[48] Fix | Delete
self.deep_construct = False
[49] Fix | Delete
return data
[50] Fix | Delete
[51] Fix | Delete
def construct_object(self, node, deep=False):
[52] Fix | Delete
if node in self.constructed_objects:
[53] Fix | Delete
return self.constructed_objects[node]
[54] Fix | Delete
if deep:
[55] Fix | Delete
old_deep = self.deep_construct
[56] Fix | Delete
self.deep_construct = True
[57] Fix | Delete
if node in self.recursive_objects:
[58] Fix | Delete
raise ConstructorError(None, None,
[59] Fix | Delete
"found unconstructable recursive node", node.start_mark)
[60] Fix | Delete
self.recursive_objects[node] = None
[61] Fix | Delete
constructor = None
[62] Fix | Delete
tag_suffix = None
[63] Fix | Delete
if node.tag in self.yaml_constructors:
[64] Fix | Delete
constructor = self.yaml_constructors[node.tag]
[65] Fix | Delete
else:
[66] Fix | Delete
for tag_prefix in self.yaml_multi_constructors:
[67] Fix | Delete
if node.tag.startswith(tag_prefix):
[68] Fix | Delete
tag_suffix = node.tag[len(tag_prefix):]
[69] Fix | Delete
constructor = self.yaml_multi_constructors[tag_prefix]
[70] Fix | Delete
break
[71] Fix | Delete
else:
[72] Fix | Delete
if None in self.yaml_multi_constructors:
[73] Fix | Delete
tag_suffix = node.tag
[74] Fix | Delete
constructor = self.yaml_multi_constructors[None]
[75] Fix | Delete
elif None in self.yaml_constructors:
[76] Fix | Delete
constructor = self.yaml_constructors[None]
[77] Fix | Delete
elif isinstance(node, ScalarNode):
[78] Fix | Delete
constructor = self.__class__.construct_scalar
[79] Fix | Delete
elif isinstance(node, SequenceNode):
[80] Fix | Delete
constructor = self.__class__.construct_sequence
[81] Fix | Delete
elif isinstance(node, MappingNode):
[82] Fix | Delete
constructor = self.__class__.construct_mapping
[83] Fix | Delete
if tag_suffix is None:
[84] Fix | Delete
data = constructor(self, node)
[85] Fix | Delete
else:
[86] Fix | Delete
data = constructor(self, tag_suffix, node)
[87] Fix | Delete
if isinstance(data, types.GeneratorType):
[88] Fix | Delete
generator = data
[89] Fix | Delete
data = next(generator)
[90] Fix | Delete
if self.deep_construct:
[91] Fix | Delete
for dummy in generator:
[92] Fix | Delete
pass
[93] Fix | Delete
else:
[94] Fix | Delete
self.state_generators.append(generator)
[95] Fix | Delete
self.constructed_objects[node] = data
[96] Fix | Delete
del self.recursive_objects[node]
[97] Fix | Delete
if deep:
[98] Fix | Delete
self.deep_construct = old_deep
[99] Fix | Delete
return data
[100] Fix | Delete
[101] Fix | Delete
def construct_scalar(self, node):
[102] Fix | Delete
if not isinstance(node, ScalarNode):
[103] Fix | Delete
raise ConstructorError(None, None,
[104] Fix | Delete
"expected a scalar node, but found %s" % node.id,
[105] Fix | Delete
node.start_mark)
[106] Fix | Delete
return node.value
[107] Fix | Delete
[108] Fix | Delete
def construct_sequence(self, node, deep=False):
[109] Fix | Delete
if not isinstance(node, SequenceNode):
[110] Fix | Delete
raise ConstructorError(None, None,
[111] Fix | Delete
"expected a sequence node, but found %s" % node.id,
[112] Fix | Delete
node.start_mark)
[113] Fix | Delete
return [self.construct_object(child, deep=deep)
[114] Fix | Delete
for child in node.value]
[115] Fix | Delete
[116] Fix | Delete
def construct_mapping(self, node, deep=False):
[117] Fix | Delete
if not isinstance(node, MappingNode):
[118] Fix | Delete
raise ConstructorError(None, None,
[119] Fix | Delete
"expected a mapping node, but found %s" % node.id,
[120] Fix | Delete
node.start_mark)
[121] Fix | Delete
mapping = {}
[122] Fix | Delete
for key_node, value_node in node.value:
[123] Fix | Delete
key = self.construct_object(key_node, deep=deep)
[124] Fix | Delete
if not isinstance(key, collections.Hashable):
[125] Fix | Delete
raise ConstructorError("while constructing a mapping", node.start_mark,
[126] Fix | Delete
"found unhashable key", key_node.start_mark)
[127] Fix | Delete
value = self.construct_object(value_node, deep=deep)
[128] Fix | Delete
mapping[key] = value
[129] Fix | Delete
return mapping
[130] Fix | Delete
[131] Fix | Delete
def construct_pairs(self, node, deep=False):
[132] Fix | Delete
if not isinstance(node, MappingNode):
[133] Fix | Delete
raise ConstructorError(None, None,
[134] Fix | Delete
"expected a mapping node, but found %s" % node.id,
[135] Fix | Delete
node.start_mark)
[136] Fix | Delete
pairs = []
[137] Fix | Delete
for key_node, value_node in node.value:
[138] Fix | Delete
key = self.construct_object(key_node, deep=deep)
[139] Fix | Delete
value = self.construct_object(value_node, deep=deep)
[140] Fix | Delete
pairs.append((key, value))
[141] Fix | Delete
return pairs
[142] Fix | Delete
[143] Fix | Delete
@classmethod
[144] Fix | Delete
def add_constructor(cls, tag, constructor):
[145] Fix | Delete
if not 'yaml_constructors' in cls.__dict__:
[146] Fix | Delete
cls.yaml_constructors = cls.yaml_constructors.copy()
[147] Fix | Delete
cls.yaml_constructors[tag] = constructor
[148] Fix | Delete
[149] Fix | Delete
@classmethod
[150] Fix | Delete
def add_multi_constructor(cls, tag_prefix, multi_constructor):
[151] Fix | Delete
if not 'yaml_multi_constructors' in cls.__dict__:
[152] Fix | Delete
cls.yaml_multi_constructors = cls.yaml_multi_constructors.copy()
[153] Fix | Delete
cls.yaml_multi_constructors[tag_prefix] = multi_constructor
[154] Fix | Delete
[155] Fix | Delete
class SafeConstructor(BaseConstructor):
[156] Fix | Delete
[157] Fix | Delete
def construct_scalar(self, node):
[158] Fix | Delete
if isinstance(node, MappingNode):
[159] Fix | Delete
for key_node, value_node in node.value:
[160] Fix | Delete
if key_node.tag == 'tag:yaml.org,2002:value':
[161] Fix | Delete
return self.construct_scalar(value_node)
[162] Fix | Delete
return super().construct_scalar(node)
[163] Fix | Delete
[164] Fix | Delete
def flatten_mapping(self, node):
[165] Fix | Delete
merge = []
[166] Fix | Delete
index = 0
[167] Fix | Delete
while index < len(node.value):
[168] Fix | Delete
key_node, value_node = node.value[index]
[169] Fix | Delete
if key_node.tag == 'tag:yaml.org,2002:merge':
[170] Fix | Delete
del node.value[index]
[171] Fix | Delete
if isinstance(value_node, MappingNode):
[172] Fix | Delete
self.flatten_mapping(value_node)
[173] Fix | Delete
merge.extend(value_node.value)
[174] Fix | Delete
elif isinstance(value_node, SequenceNode):
[175] Fix | Delete
submerge = []
[176] Fix | Delete
for subnode in value_node.value:
[177] Fix | Delete
if not isinstance(subnode, MappingNode):
[178] Fix | Delete
raise ConstructorError("while constructing a mapping",
[179] Fix | Delete
node.start_mark,
[180] Fix | Delete
"expected a mapping for merging, but found %s"
[181] Fix | Delete
% subnode.id, subnode.start_mark)
[182] Fix | Delete
self.flatten_mapping(subnode)
[183] Fix | Delete
submerge.append(subnode.value)
[184] Fix | Delete
submerge.reverse()
[185] Fix | Delete
for value in submerge:
[186] Fix | Delete
merge.extend(value)
[187] Fix | Delete
else:
[188] Fix | Delete
raise ConstructorError("while constructing a mapping", node.start_mark,
[189] Fix | Delete
"expected a mapping or list of mappings for merging, but found %s"
[190] Fix | Delete
% value_node.id, value_node.start_mark)
[191] Fix | Delete
elif key_node.tag == 'tag:yaml.org,2002:value':
[192] Fix | Delete
key_node.tag = 'tag:yaml.org,2002:str'
[193] Fix | Delete
index += 1
[194] Fix | Delete
else:
[195] Fix | Delete
index += 1
[196] Fix | Delete
if merge:
[197] Fix | Delete
node.value = merge + node.value
[198] Fix | Delete
[199] Fix | Delete
def construct_mapping(self, node, deep=False):
[200] Fix | Delete
if isinstance(node, MappingNode):
[201] Fix | Delete
self.flatten_mapping(node)
[202] Fix | Delete
return super().construct_mapping(node, deep=deep)
[203] Fix | Delete
[204] Fix | Delete
def construct_yaml_null(self, node):
[205] Fix | Delete
self.construct_scalar(node)
[206] Fix | Delete
return None
[207] Fix | Delete
[208] Fix | Delete
bool_values = {
[209] Fix | Delete
'yes': True,
[210] Fix | Delete
'no': False,
[211] Fix | Delete
'true': True,
[212] Fix | Delete
'false': False,
[213] Fix | Delete
'on': True,
[214] Fix | Delete
'off': False,
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
def construct_yaml_bool(self, node):
[218] Fix | Delete
value = self.construct_scalar(node)
[219] Fix | Delete
return self.bool_values[value.lower()]
[220] Fix | Delete
[221] Fix | Delete
def construct_yaml_int(self, node):
[222] Fix | Delete
value = self.construct_scalar(node)
[223] Fix | Delete
value = value.replace('_', '')
[224] Fix | Delete
sign = +1
[225] Fix | Delete
if value[0] == '-':
[226] Fix | Delete
sign = -1
[227] Fix | Delete
if value[0] in '+-':
[228] Fix | Delete
value = value[1:]
[229] Fix | Delete
if value == '0':
[230] Fix | Delete
return 0
[231] Fix | Delete
elif value.startswith('0b'):
[232] Fix | Delete
return sign*int(value[2:], 2)
[233] Fix | Delete
elif value.startswith('0x'):
[234] Fix | Delete
return sign*int(value[2:], 16)
[235] Fix | Delete
elif value[0] == '0':
[236] Fix | Delete
return sign*int(value, 8)
[237] Fix | Delete
elif ':' in value:
[238] Fix | Delete
digits = [int(part) for part in value.split(':')]
[239] Fix | Delete
digits.reverse()
[240] Fix | Delete
base = 1
[241] Fix | Delete
value = 0
[242] Fix | Delete
for digit in digits:
[243] Fix | Delete
value += digit*base
[244] Fix | Delete
base *= 60
[245] Fix | Delete
return sign*value
[246] Fix | Delete
else:
[247] Fix | Delete
return sign*int(value)
[248] Fix | Delete
[249] Fix | Delete
inf_value = 1e300
[250] Fix | Delete
while inf_value != inf_value*inf_value:
[251] Fix | Delete
inf_value *= inf_value
[252] Fix | Delete
nan_value = -inf_value/inf_value # Trying to make a quiet NaN (like C99).
[253] Fix | Delete
[254] Fix | Delete
def construct_yaml_float(self, node):
[255] Fix | Delete
value = self.construct_scalar(node)
[256] Fix | Delete
value = value.replace('_', '').lower()
[257] Fix | Delete
sign = +1
[258] Fix | Delete
if value[0] == '-':
[259] Fix | Delete
sign = -1
[260] Fix | Delete
if value[0] in '+-':
[261] Fix | Delete
value = value[1:]
[262] Fix | Delete
if value == '.inf':
[263] Fix | Delete
return sign*self.inf_value
[264] Fix | Delete
elif value == '.nan':
[265] Fix | Delete
return self.nan_value
[266] Fix | Delete
elif ':' in value:
[267] Fix | Delete
digits = [float(part) for part in value.split(':')]
[268] Fix | Delete
digits.reverse()
[269] Fix | Delete
base = 1
[270] Fix | Delete
value = 0.0
[271] Fix | Delete
for digit in digits:
[272] Fix | Delete
value += digit*base
[273] Fix | Delete
base *= 60
[274] Fix | Delete
return sign*value
[275] Fix | Delete
else:
[276] Fix | Delete
return sign*float(value)
[277] Fix | Delete
[278] Fix | Delete
def construct_yaml_binary(self, node):
[279] Fix | Delete
try:
[280] Fix | Delete
value = self.construct_scalar(node).encode('ascii')
[281] Fix | Delete
except UnicodeEncodeError as exc:
[282] Fix | Delete
raise ConstructorError(None, None,
[283] Fix | Delete
"failed to convert base64 data into ascii: %s" % exc,
[284] Fix | Delete
node.start_mark)
[285] Fix | Delete
try:
[286] Fix | Delete
if hasattr(base64, 'decodebytes'):
[287] Fix | Delete
return base64.decodebytes(value)
[288] Fix | Delete
else:
[289] Fix | Delete
return base64.decodestring(value)
[290] Fix | Delete
except binascii.Error as exc:
[291] Fix | Delete
raise ConstructorError(None, None,
[292] Fix | Delete
"failed to decode base64 data: %s" % exc, node.start_mark)
[293] Fix | Delete
[294] Fix | Delete
timestamp_regexp = re.compile(
[295] Fix | Delete
r'''^(?P<year>[0-9][0-9][0-9][0-9])
[296] Fix | Delete
-(?P<month>[0-9][0-9]?)
[297] Fix | Delete
-(?P<day>[0-9][0-9]?)
[298] Fix | Delete
(?:(?:[Tt]|[ \t]+)
[299] Fix | Delete
(?P<hour>[0-9][0-9]?)
[300] Fix | Delete
:(?P<minute>[0-9][0-9])
[301] Fix | Delete
:(?P<second>[0-9][0-9])
[302] Fix | Delete
(?:\.(?P<fraction>[0-9]*))?
[303] Fix | Delete
(?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
[304] Fix | Delete
(?::(?P<tz_minute>[0-9][0-9]))?))?)?$''', re.X)
[305] Fix | Delete
[306] Fix | Delete
def construct_yaml_timestamp(self, node):
[307] Fix | Delete
value = self.construct_scalar(node)
[308] Fix | Delete
match = self.timestamp_regexp.match(node.value)
[309] Fix | Delete
values = match.groupdict()
[310] Fix | Delete
year = int(values['year'])
[311] Fix | Delete
month = int(values['month'])
[312] Fix | Delete
day = int(values['day'])
[313] Fix | Delete
if not values['hour']:
[314] Fix | Delete
return datetime.date(year, month, day)
[315] Fix | Delete
hour = int(values['hour'])
[316] Fix | Delete
minute = int(values['minute'])
[317] Fix | Delete
second = int(values['second'])
[318] Fix | Delete
fraction = 0
[319] Fix | Delete
if values['fraction']:
[320] Fix | Delete
fraction = values['fraction'][:6]
[321] Fix | Delete
while len(fraction) < 6:
[322] Fix | Delete
fraction += '0'
[323] Fix | Delete
fraction = int(fraction)
[324] Fix | Delete
delta = None
[325] Fix | Delete
if values['tz_sign']:
[326] Fix | Delete
tz_hour = int(values['tz_hour'])
[327] Fix | Delete
tz_minute = int(values['tz_minute'] or 0)
[328] Fix | Delete
delta = datetime.timedelta(hours=tz_hour, minutes=tz_minute)
[329] Fix | Delete
if values['tz_sign'] == '-':
[330] Fix | Delete
delta = -delta
[331] Fix | Delete
data = datetime.datetime(year, month, day, hour, minute, second, fraction)
[332] Fix | Delete
if delta:
[333] Fix | Delete
data -= delta
[334] Fix | Delete
return data
[335] Fix | Delete
[336] Fix | Delete
def construct_yaml_omap(self, node):
[337] Fix | Delete
# Note: we do not check for duplicate keys, because it's too
[338] Fix | Delete
# CPU-expensive.
[339] Fix | Delete
omap = []
[340] Fix | Delete
yield omap
[341] Fix | Delete
if not isinstance(node, SequenceNode):
[342] Fix | Delete
raise ConstructorError("while constructing an ordered map", node.start_mark,
[343] Fix | Delete
"expected a sequence, but found %s" % node.id, node.start_mark)
[344] Fix | Delete
for subnode in node.value:
[345] Fix | Delete
if not isinstance(subnode, MappingNode):
[346] Fix | Delete
raise ConstructorError("while constructing an ordered map", node.start_mark,
[347] Fix | Delete
"expected a mapping of length 1, but found %s" % subnode.id,
[348] Fix | Delete
subnode.start_mark)
[349] Fix | Delete
if len(subnode.value) != 1:
[350] Fix | Delete
raise ConstructorError("while constructing an ordered map", node.start_mark,
[351] Fix | Delete
"expected a single mapping item, but found %d items" % len(subnode.value),
[352] Fix | Delete
subnode.start_mark)
[353] Fix | Delete
key_node, value_node = subnode.value[0]
[354] Fix | Delete
key = self.construct_object(key_node)
[355] Fix | Delete
value = self.construct_object(value_node)
[356] Fix | Delete
omap.append((key, value))
[357] Fix | Delete
[358] Fix | Delete
def construct_yaml_pairs(self, node):
[359] Fix | Delete
# Note: the same code as `construct_yaml_omap`.
[360] Fix | Delete
pairs = []
[361] Fix | Delete
yield pairs
[362] Fix | Delete
if not isinstance(node, SequenceNode):
[363] Fix | Delete
raise ConstructorError("while constructing pairs", node.start_mark,
[364] Fix | Delete
"expected a sequence, but found %s" % node.id, node.start_mark)
[365] Fix | Delete
for subnode in node.value:
[366] Fix | Delete
if not isinstance(subnode, MappingNode):
[367] Fix | Delete
raise ConstructorError("while constructing pairs", node.start_mark,
[368] Fix | Delete
"expected a mapping of length 1, but found %s" % subnode.id,
[369] Fix | Delete
subnode.start_mark)
[370] Fix | Delete
if len(subnode.value) != 1:
[371] Fix | Delete
raise ConstructorError("while constructing pairs", node.start_mark,
[372] Fix | Delete
"expected a single mapping item, but found %d items" % len(subnode.value),
[373] Fix | Delete
subnode.start_mark)
[374] Fix | Delete
key_node, value_node = subnode.value[0]
[375] Fix | Delete
key = self.construct_object(key_node)
[376] Fix | Delete
value = self.construct_object(value_node)
[377] Fix | Delete
pairs.append((key, value))
[378] Fix | Delete
[379] Fix | Delete
def construct_yaml_set(self, node):
[380] Fix | Delete
data = set()
[381] Fix | Delete
yield data
[382] Fix | Delete
value = self.construct_mapping(node)
[383] Fix | Delete
data.update(value)
[384] Fix | Delete
[385] Fix | Delete
def construct_yaml_str(self, node):
[386] Fix | Delete
return self.construct_scalar(node)
[387] Fix | Delete
[388] Fix | Delete
def construct_yaml_seq(self, node):
[389] Fix | Delete
data = []
[390] Fix | Delete
yield data
[391] Fix | Delete
data.extend(self.construct_sequence(node))
[392] Fix | Delete
[393] Fix | Delete
def construct_yaml_map(self, node):
[394] Fix | Delete
data = {}
[395] Fix | Delete
yield data
[396] Fix | Delete
value = self.construct_mapping(node)
[397] Fix | Delete
data.update(value)
[398] Fix | Delete
[399] Fix | Delete
def construct_yaml_object(self, node, cls):
[400] Fix | Delete
data = cls.__new__(cls)
[401] Fix | Delete
yield data
[402] Fix | Delete
if hasattr(data, '__setstate__'):
[403] Fix | Delete
state = self.construct_mapping(node, deep=True)
[404] Fix | Delete
data.__setstate__(state)
[405] Fix | Delete
else:
[406] Fix | Delete
state = self.construct_mapping(node)
[407] Fix | Delete
data.__dict__.update(state)
[408] Fix | Delete
[409] Fix | Delete
def construct_undefined(self, node):
[410] Fix | Delete
raise ConstructorError(None, None,
[411] Fix | Delete
"could not determine a constructor for the tag %r" % node.tag,
[412] Fix | Delete
node.start_mark)
[413] Fix | Delete
[414] Fix | Delete
SafeConstructor.add_constructor(
[415] Fix | Delete
'tag:yaml.org,2002:null',
[416] Fix | Delete
SafeConstructor.construct_yaml_null)
[417] Fix | Delete
[418] Fix | Delete
SafeConstructor.add_constructor(
[419] Fix | Delete
'tag:yaml.org,2002:bool',
[420] Fix | Delete
SafeConstructor.construct_yaml_bool)
[421] Fix | Delete
[422] Fix | Delete
SafeConstructor.add_constructor(
[423] Fix | Delete
'tag:yaml.org,2002:int',
[424] Fix | Delete
SafeConstructor.construct_yaml_int)
[425] Fix | Delete
[426] Fix | Delete
SafeConstructor.add_constructor(
[427] Fix | Delete
'tag:yaml.org,2002:float',
[428] Fix | Delete
SafeConstructor.construct_yaml_float)
[429] Fix | Delete
[430] Fix | Delete
SafeConstructor.add_constructor(
[431] Fix | Delete
'tag:yaml.org,2002:binary',
[432] Fix | Delete
SafeConstructor.construct_yaml_binary)
[433] Fix | Delete
[434] Fix | Delete
SafeConstructor.add_constructor(
[435] Fix | Delete
'tag:yaml.org,2002:timestamp',
[436] Fix | Delete
SafeConstructor.construct_yaml_timestamp)
[437] Fix | Delete
[438] Fix | Delete
SafeConstructor.add_constructor(
[439] Fix | Delete
'tag:yaml.org,2002:omap',
[440] Fix | Delete
SafeConstructor.construct_yaml_omap)
[441] Fix | Delete
[442] Fix | Delete
SafeConstructor.add_constructor(
[443] Fix | Delete
'tag:yaml.org,2002:pairs',
[444] Fix | Delete
SafeConstructor.construct_yaml_pairs)
[445] Fix | Delete
[446] Fix | Delete
SafeConstructor.add_constructor(
[447] Fix | Delete
'tag:yaml.org,2002:set',
[448] Fix | Delete
SafeConstructor.construct_yaml_set)
[449] Fix | Delete
[450] Fix | Delete
SafeConstructor.add_constructor(
[451] Fix | Delete
'tag:yaml.org,2002:str',
[452] Fix | Delete
SafeConstructor.construct_yaml_str)
[453] Fix | Delete
[454] Fix | Delete
SafeConstructor.add_constructor(
[455] Fix | Delete
'tag:yaml.org,2002:seq',
[456] Fix | Delete
SafeConstructor.construct_yaml_seq)
[457] Fix | Delete
[458] Fix | Delete
SafeConstructor.add_constructor(
[459] Fix | Delete
'tag:yaml.org,2002:map',
[460] Fix | Delete
SafeConstructor.construct_yaml_map)
[461] Fix | Delete
[462] Fix | Delete
SafeConstructor.add_constructor(None,
[463] Fix | Delete
SafeConstructor.construct_undefined)
[464] Fix | Delete
[465] Fix | Delete
class Constructor(SafeConstructor):
[466] Fix | Delete
[467] Fix | Delete
def construct_python_str(self, node):
[468] Fix | Delete
return self.construct_scalar(node)
[469] Fix | Delete
[470] Fix | Delete
def construct_python_unicode(self, node):
[471] Fix | Delete
return self.construct_scalar(node)
[472] Fix | Delete
[473] Fix | Delete
def construct_python_bytes(self, node):
[474] Fix | Delete
try:
[475] Fix | Delete
value = self.construct_scalar(node).encode('ascii')
[476] Fix | Delete
except UnicodeEncodeError as exc:
[477] Fix | Delete
raise ConstructorError(None, None,
[478] Fix | Delete
"failed to convert base64 data into ascii: %s" % exc,
[479] Fix | Delete
node.start_mark)
[480] Fix | Delete
try:
[481] Fix | Delete
if hasattr(base64, 'decodebytes'):
[482] Fix | Delete
return base64.decodebytes(value)
[483] Fix | Delete
else:
[484] Fix | Delete
return base64.decodestring(value)
[485] Fix | Delete
except binascii.Error as exc:
[486] Fix | Delete
raise ConstructorError(None, None,
[487] Fix | Delete
"failed to decode base64 data: %s" % exc, node.start_mark)
[488] Fix | Delete
[489] Fix | Delete
def construct_python_long(self, node):
[490] Fix | Delete
return self.construct_yaml_int(node)
[491] Fix | Delete
[492] Fix | Delete
def construct_python_complex(self, node):
[493] Fix | Delete
return complex(self.construct_scalar(node))
[494] Fix | Delete
[495] Fix | Delete
def construct_python_tuple(self, node):
[496] Fix | Delete
return tuple(self.construct_sequence(node))
[497] Fix | Delete
[498] Fix | Delete
def find_python_module(self, name, mark):
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function