2022-06-15 17:49:42 +09:00
|
|
|
import json
|
|
|
|
|
2022-06-15 14:39:54 +09:00
|
|
|
def get_item(index, words):
|
|
|
|
try:
|
|
|
|
word = words[index]
|
|
|
|
except IndexError:
|
|
|
|
word = None
|
|
|
|
else:
|
|
|
|
if not word:
|
|
|
|
raise NoParse(f'empty word at position {index}')
|
|
|
|
return word
|
|
|
|
|
2022-06-15 17:49:42 +09:00
|
|
|
def json_dumps_contiguous(obj, **kwargs):
|
|
|
|
return json.dumps(obj, **kwargs).replace(' ', r'\u0020')
|
|
|
|
|
2022-06-15 14:39:54 +09:00
|
|
|
def startswith(string, prefix):
|
|
|
|
if string is None or prefix is None:
|
|
|
|
return string is prefix
|
|
|
|
return string.startswith(prefix)
|