def __init__(self, user_mode):
self.user_mode = user_mode
self.interface = None
self.quota = None
self.is_online = None
self.new_api = None
self.json_decoder = json.JSONDecoder()
self.session = requests.Session()
self.csrf_token = None
self.resolver = dns.resolver.Resolver()
self.resolver.nameservers = ['172.16.0.1']
self.api_host_ip = self.resolve_url(self.api_host)
self.api_host_new_ip = self.resolve_url(self.api_host_new)
python类JSONDecoder()的实例源码
addon_updater.py 文件源码
项目:Blender-WMO-import-export-scripts
作者: WowDevTools
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def get_api(self, url):
# return the json version
get = None
get = self.get_api_raw(url) # this can fail by self-created error raising
if get is not None:
return json.JSONDecoder().decode( get )
else:
return None
# create a working directory and download the new files
def __init__(self, ctrl, vimx):
import logging
self.logger = logging.getLogger(__name__)
self.ctrl = ctrl
self.vimx = vimx
self.state = OrderedDict()
self.internal = {}
self.json_decoder = json.JSONDecoder(object_pairs_hook=OrderedDict)
self.help_flags = {"new": False, "launch_prompt": True, "session_show": True}
self.bpid_map = {}
def _read_stdin(self):
loads = json.JSONDecoder(parse_float=unicode, parse_int=unicode).decode
while True:
yield select.select([sys.stdin], [], [])
line = sys.stdin.readline()
if not line:
break
if not line.strip():
continue
in_dict = loads(line)
yield idiokit.send(events.Event(in_dict))
def json_decode(self, encoded_json):
json_decoder = json.JSONDecoder()
try:
return json_decoder.decode(encoded_json)
except:
logging.debug("JSON error from {} container \n==\n {} \n==\n".format(self.module_cls_name, encoded_json))
return None
def __init__(self, malware, module_cls_name, task_id,
cuckoo_url, all_result=False):
self.json_decoder = json.JSONDecoder()
self._malware = malware
self._module_cls_name = module_cls_name
self._task_id = task_id
self._all = all_result
self._ms = malware.get_module_status(self._module_cls_name)
self._cuckoo_url = cuckoo_url
def __init__(self, malware, module_cls_name, task_id,
cuckoo_url, all_result=False):
self.json_decoder = json.JSONDecoder()
self._malware = malware
self._module_cls_name = module_cls_name
self._task_id = task_id
self._all = all_result
self._ms = malware.get_module_status(self._module_cls_name)
self._cuckoo_url = cuckoo_url
def json_iter_parse(response_text):
decoder = json.JSONDecoder(strict=False)
idx = 0
while idx < len(response_text):
obj, idx = decoder.raw_decode(response_text, idx)
yield obj
def __init__(self):
json.JSONDecoder.__init__(
self,
object_hook=self.dict_to_object,
)
def jsons(r, p=0):
dec = json.JSONDecoder(encoding='utf-8')
while True:
obj,p = dec.scan_once(r.text,p)
yield obj
def wiki(self, ctx, *, search_query):
logger.info('!wiki ' + search_query + ' - User: ' + str(ctx.message.author))
data = self.utils.search_wiki(search_query)
if len(data) == 1:
result_id = 0
else:
if 1 < len(data) <= 10:
# Display all results then await choice
i = 1
text = ''
for entry in data:
text += str(i) + ') **' + entry[1] + '** - *Category: ' + str(entry[2]) + '*\n'
i += 1
em = discord.Embed(title='Please enter the number of the targeted wiki entry',
description=text,
colour=0x3D9900)
await self.bot.send_message(ctx.message.channel, '', embed=em)
msg = await self.bot.wait_for_message(author=ctx.message.author)
if int(msg.content) >= i or int(msg.content) < 1:
await self.bot.say('Invalid choice')
return
result_id = int(msg.content) - 1
else:
await self.bot.send_message(ctx.message.channel, 'No matching entry found.')
return
temp = json.JSONDecoder().decode(data[result_id][3])
tempembed = discord.Embed().from_data(temp)
await self.bot.send_message(ctx.message.channel, '', embed=tempembed)
def get_json(self):
try:
return json.loads(self.request.body.decode('utf-8'))
except (json.JSONDecoder, ValueError):
return {}
def json_to_prolog(jstr):
return json.JSONDecoder(object_hook = _prolog_from_json).decode(jstr)
def get_api(self, url):
# return the json version
get = None
get = self.get_api_raw(url) # this can fail by self-created error raising
if get != None:
return json.JSONDecoder().decode( get )
else:
return None
# create a working directory and download the new files
def get_api(self, url):
# return the json version
get = None
get = self.get_api_raw(url) # this can fail by self-created error raising
if get != None:
return json.JSONDecoder().decode( get )
else:
return None
# create a working directory and download the new files
def __init__(self, *args, **kwargs):
json.JSONDecoder.__init__(self, object_hook=self.object_hook, *args, **kwargs)
def __init__(self):
self.buf = ""
self.raw_decode = json.JSONDecoder().raw_decode
def fromjsons(values, generator=None, fillables=None, pointer_fromequal=False):
if hasattr(values, "read"):
def iterator():
j = json.JSONDecoder()
buf = ""
while True:
try:
obj, i = j.raw_decode(buf)
except ValueError:
extra = values.read(8192)
if len(extra) == 0:
break
else:
buf = buf.lstrip() + extra
else:
yield obj
buf = buf[i:].lstrip()
else:
def iterator():
j = json.JSONDecoder()
index = 0
while True:
try:
obj, i = j.raw_decode(values[index:])
except ValueError:
break
yield obj
_, index = fromjsons._pattern.match(values, index + i).span()
return fromiterdata(iterator(), generator=generator, fillables=fillables, pointer_fromequal=pointer_fromequal)
def __init__(self, date_format, *args, **kwargs):
self.date_format = date_format
json.JSONDecoder.__init__(self, object_hook=self.date_to_object, *args, **kwargs)
def __init__(self, base_url, key_contains=[], *args, **kwargs):
self.base_url = base_url
self.key_contains = key_contains
json.JSONDecoder.__init__(self, object_hook=self.url_to_object, *args, **kwargs)