File tree Expand file tree Collapse file tree
remove-json-keys/src/remove_json_keys/lib
translate-messages/src/translate_messages/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from urllib .request import urlopen
55
66def get (url , timeout = 5 , encoding = 'utf-8' ):
7- url = validate_url (url )
7+ url = validate (url )
88 try :
99 with urlopen (url , timeout = timeout ) as resp :
1010 return resp .read ().decode (encoding )
1111 except URLError as err :
1212 raise RuntimeError (f'Failed to fetch from { url } : { err } ' )
1313
1414def open (url ):
15- url = validate_url (url )
15+ url = validate (url )
1616 try :
1717 webbrowser .open (url )
1818 except Exception as err :
1919 print (f'Failed to open browser: { err } ' , file = sys .stderr )
2020 sys .exit (1 )
2121
22- def validate_url (url , allowed_schemes = ('http' , 'https' ), allowed_domains = []):
22+ def validate (url , allowed_schemes = ('http' , 'https' ), allowed_domains = []):
2323 parsed_url = urlparse (url )
2424
2525 if parsed_url .scheme not in allowed_schemes :
Original file line number Diff line number Diff line change 44from urllib .request import urlopen
55
66def get (url , timeout = 5 , encoding = 'utf-8' ):
7- url = validate_url (url )
7+ url = validate (url )
88 try :
99 with urlopen (url , timeout = timeout ) as resp :
1010 return resp .read ().decode (encoding )
1111 except URLError as err :
1212 raise RuntimeError (f'Failed to fetch from { url } : { err } ' )
1313
1414def open (url ):
15- url = validate_url (url )
15+ url = validate (url )
1616 try :
1717 webbrowser .open (url )
1818 except Exception as err :
1919 print (f'Failed to open browser: { err } ' , file = sys .stderr )
2020 sys .exit (1 )
2121
22- def validate_url (url , allowed_schemes = ('http' , 'https' ), allowed_domains = []):
22+ def validate (url , allowed_schemes = ('http' , 'https' ), allowed_domains = []):
2323 parsed_url = urlparse (url )
2424
2525 if parsed_url .scheme not in allowed_schemes :
You can’t perform that action at this time.
0 commit comments