Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise LoadError('unsupported asciicast format')
return Asciicast(
attrs['stdout'],
attrs['width'],
attrs['height'],
attrs['duration'],
attrs['command'],
attrs['title']
)
except (OSError, urllib.error.HTTPError) as e:
raise LoadError(str(e))
except JSONDecodeError as e:
raise LoadError('JSON decoding error: ' + str(e))
except KeyError as e:
raise LoadError('asciicast is missing key ' + str(e))
def load(filename):
try:
attrs = json.loads(fetch(filename))
if type(attrs) != dict:
raise LoadError('unsupported asciicast format')
return Asciicast(
attrs['stdout'],
attrs['width'],
attrs['height'],
attrs['duration'],
attrs['command'],
attrs['title']
)
except (OSError, urllib.error.HTTPError) as e:
raise LoadError(str(e))
except JSONDecodeError as e:
raise LoadError('JSON decoding error: ' + str(e))
except KeyError as e:
raise LoadError('asciicast is missing key ' + str(e))
if url == "-":
return sys.stdin.read()
if url.startswith("http:") or url.startswith("https:"):
response = urllib.request.urlopen(url)
data = response.read().decode(errors='replace')
content_type = response.headers['Content-Type']
if content_type and content_type.startswith('text/html'):
parser = Parser()
parser.feed(data)
url = parser.url
if not url:
raise LoadError(""" not found in fetched HTML document""")
return fetch(url)
return data
with open(url, 'r') as f:
return f.read()
try:
attrs = json.loads(fetch(filename))
if type(attrs) != dict:
raise LoadError('unsupported asciicast format')
return Asciicast(
attrs['stdout'],
attrs['width'],
attrs['height'],
attrs['duration'],
attrs['command'],
attrs['title']
)
except (OSError, urllib.error.HTTPError) as e:
raise LoadError(str(e))
except JSONDecodeError as e:
raise LoadError('JSON decoding error: ' + str(e))
except KeyError as e:
raise LoadError('asciicast is missing key ' + str(e))