mirror of https://gitlab.com/bashrc2/epicyon
Check the number of return values
parent
5c50bd713b
commit
5a86457382
3
blog.py
3
blog.py
|
|
@ -955,7 +955,8 @@ def path_contains_blog_link(base_dir: str,
|
||||||
return None, None
|
return None, None
|
||||||
message_id = local_actor_url(http_prefix, nickname, domain_full) + \
|
message_id = local_actor_url(http_prefix, nickname, domain_full) + \
|
||||||
'/statuses/' + user_ending2[1]
|
'/statuses/' + user_ending2[1]
|
||||||
return locate_post(base_dir, nickname, domain, message_id), nickname
|
filename = locate_post(base_dir, nickname, domain, message_id)
|
||||||
|
return filename, nickname
|
||||||
|
|
||||||
|
|
||||||
def get_blog_address(actor_json: {}) -> str:
|
def get_blog_address(actor_json: {}) -> str:
|
||||||
|
|
|
||||||
32
maps.py
32
maps.py
|
|
@ -386,21 +386,37 @@ def geocoords_from_map_link(url: str,
|
||||||
"""Returns geocoordinates from a map link url
|
"""Returns geocoordinates from a map link url
|
||||||
"""
|
"""
|
||||||
if osm_domain in url:
|
if osm_domain in url:
|
||||||
return _geocoords_from_osm_link(url, osm_domain)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_osm_link(url, osm_domain)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if 'osm.org' in url and 'mlat=' in url:
|
if 'osm.org' in url and 'mlat=' in url:
|
||||||
return _geocoords_from_osmorg_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_osmorg_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if 'osmand.net' in url and '/map' in url:
|
if 'osmand.net' in url and '/map' in url:
|
||||||
return _geocoords_from_osmand_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_osmand_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if '.google.co' in url:
|
if '.google.co' in url:
|
||||||
return _geocoords_from_gmaps_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_gmaps_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if '.bing.co' in url:
|
if '.bing.co' in url:
|
||||||
return _geocoords_from_bmaps_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_bmaps_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if '.waze.co' in url:
|
if '.waze.co' in url:
|
||||||
return _geocoords_from_waze_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_waze_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if 'wego.here.co' in url:
|
if 'wego.here.co' in url:
|
||||||
return _geocoords_from_wego_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_wego_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
if 'geo:' in url and ',' in url:
|
if 'geo:' in url and ',' in url:
|
||||||
return _geocoords_from_geo_link(url)
|
zoom, latitude, longitude = \
|
||||||
|
_geocoords_from_geo_link(url)
|
||||||
|
return zoom, latitude, longitude
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,8 @@ def speakable_text(http_prefix: str,
|
||||||
# replace all double spaces
|
# replace all double spaces
|
||||||
while ' ' in say_content:
|
while ' ' in say_content:
|
||||||
say_content = say_content.replace(' ', ' ')
|
say_content = say_content.replace(' ', ' ')
|
||||||
return say_content.replace(' . ', '. ').strip(), detected_links
|
say_str = say_content.replace(' . ', '. ').strip()
|
||||||
|
return say_str, detected_links
|
||||||
|
|
||||||
|
|
||||||
def _post_to_speaker_json(base_dir: str, http_prefix: str,
|
def _post_to_speaker_json(base_dir: str, http_prefix: str,
|
||||||
|
|
|
||||||
60
tests.py
60
tests.py
|
|
@ -5547,7 +5547,10 @@ def _test_functions():
|
||||||
method_args = []
|
method_args = []
|
||||||
module_line = 0
|
module_line = 0
|
||||||
curr_return_types = ''
|
curr_return_types = ''
|
||||||
|
is_comment = False
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if '"""' in line:
|
||||||
|
is_comment = not is_comment
|
||||||
module_line += 1
|
module_line += 1
|
||||||
# what group is this module in?
|
# what group is this module in?
|
||||||
if '__module_group__' in line:
|
if '__module_group__' in line:
|
||||||
|
|
@ -5587,16 +5590,44 @@ def _test_functions():
|
||||||
method_loc.append(loc_str)
|
method_loc.append(loc_str)
|
||||||
line_count = 0
|
line_count = 0
|
||||||
|
|
||||||
# check return statements are of the expected type
|
is_return_statement = False
|
||||||
if curr_return_types and \
|
if ' return' in line:
|
||||||
'"""' not in line and \
|
before_return = line.split(' return')[0].strip()
|
||||||
line.endswith(' return\n'):
|
if not before_return:
|
||||||
if curr_return_types != 'None':
|
is_return_statement = True
|
||||||
print(method_name + ' in module ' +
|
|
||||||
mod_name + ' has unexpected return')
|
if curr_return_types and is_return_statement and \
|
||||||
print('Expected: return ' + curr_return_types)
|
not is_comment and '#' not in line and \
|
||||||
print('Actual: ' + line.strip())
|
'"""' not in line:
|
||||||
assert False
|
# check return statements are of the expected type
|
||||||
|
if line.endswith(' return\n'):
|
||||||
|
if curr_return_types != 'None':
|
||||||
|
print(method_name + ' in module ' +
|
||||||
|
mod_name + ' has unexpected return')
|
||||||
|
print('Expected: return ' +
|
||||||
|
str(curr_return_types))
|
||||||
|
print('Actual: ' + line.strip())
|
||||||
|
assert False
|
||||||
|
elif (' return' in line and
|
||||||
|
not line.endswith(',\n') and
|
||||||
|
not line.endswith('\\\n') and
|
||||||
|
',' in curr_return_types):
|
||||||
|
# check the number of return values
|
||||||
|
ret_types = line.split(' return', 1)[1]
|
||||||
|
no_of_args1 = \
|
||||||
|
len(curr_return_types.split(','))
|
||||||
|
no_of_args2 = \
|
||||||
|
len(ret_types.split(','))
|
||||||
|
if no_of_args1 != no_of_args2:
|
||||||
|
print(method_name + ' in module ' +
|
||||||
|
mod_name +
|
||||||
|
' has unexpected ' +
|
||||||
|
'number of arguments')
|
||||||
|
print('Expected: return ' +
|
||||||
|
str(curr_return_types))
|
||||||
|
print('Actual: ' + line.strip())
|
||||||
|
assert False
|
||||||
|
|
||||||
prev_line = line
|
prev_line = line
|
||||||
continue
|
continue
|
||||||
# reading function def
|
# reading function def
|
||||||
|
|
@ -5606,15 +5637,18 @@ def _test_functions():
|
||||||
# get list of arguments with spaces removed
|
# get list of arguments with spaces removed
|
||||||
method_args = \
|
method_args = \
|
||||||
source_str.split('def ' + method_name + '(')[1]
|
source_str.split('def ' + method_name + '(')[1]
|
||||||
return_types = method_args.split(')')[1]
|
return_types = method_args.split(')', 1)[1]
|
||||||
if ':' in return_types:
|
if ':' in return_types:
|
||||||
return_types = return_types.split(':')[0]
|
return_types = return_types.split(':')[0]
|
||||||
if '->' in return_types:
|
if '->' in return_types:
|
||||||
return_types = return_types.split('->')[1].strip()
|
return_types = return_types.split('->')[1].strip()
|
||||||
|
if return_types.startswith('(') and \
|
||||||
|
not return_types.endswith(')'):
|
||||||
|
return_types += ')'
|
||||||
else:
|
else:
|
||||||
return_types = ''
|
return_types = []
|
||||||
curr_return_types = return_types
|
curr_return_types = return_types
|
||||||
method_args = method_args.split(')')[0]
|
method_args = method_args.split(')', 1)[0]
|
||||||
method_args = method_args.replace(' ', '').split(',')
|
method_args = method_args.replace(' ', '').split(',')
|
||||||
if function.get(mod_name):
|
if function.get(mod_name):
|
||||||
function[mod_name].append(method_name)
|
function[mod_name].append(method_name)
|
||||||
|
|
|
||||||
|
|
@ -667,7 +667,9 @@ def get_banner_file(base_dir: str,
|
||||||
"""Gets the image for the timeline banner
|
"""Gets the image for the timeline banner
|
||||||
"""
|
"""
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
return _get_image_file(base_dir, 'banner', account_dir, theme)
|
banner_file, banner_filename = \
|
||||||
|
_get_image_file(base_dir, 'banner', account_dir, theme)
|
||||||
|
return banner_file, banner_filename
|
||||||
|
|
||||||
|
|
||||||
def get_profile_background_file(base_dir: str,
|
def get_profile_background_file(base_dir: str,
|
||||||
|
|
@ -676,7 +678,9 @@ def get_profile_background_file(base_dir: str,
|
||||||
"""Gets the image for the profile background
|
"""Gets the image for the profile background
|
||||||
"""
|
"""
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
return _get_image_file(base_dir, 'image', account_dir, theme)
|
banner_file, banner_filename = \
|
||||||
|
_get_image_file(base_dir, 'image', account_dir, theme)
|
||||||
|
return banner_file, banner_filename
|
||||||
|
|
||||||
|
|
||||||
def get_search_banner_file(base_dir: str,
|
def get_search_banner_file(base_dir: str,
|
||||||
|
|
@ -685,7 +689,9 @@ def get_search_banner_file(base_dir: str,
|
||||||
"""Gets the image for the search banner
|
"""Gets the image for the search banner
|
||||||
"""
|
"""
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
return _get_image_file(base_dir, 'search_banner', account_dir, theme)
|
banner_file, banner_filename = \
|
||||||
|
_get_image_file(base_dir, 'search_banner', account_dir, theme)
|
||||||
|
return banner_file, banner_filename
|
||||||
|
|
||||||
|
|
||||||
def get_left_image_file(base_dir: str,
|
def get_left_image_file(base_dir: str,
|
||||||
|
|
@ -693,7 +699,9 @@ def get_left_image_file(base_dir: str,
|
||||||
"""Gets the image for the left column
|
"""Gets the image for the left column
|
||||||
"""
|
"""
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
return _get_image_file(base_dir, 'left_col_image', account_dir, theme)
|
banner_file, banner_filename = \
|
||||||
|
_get_image_file(base_dir, 'left_col_image', account_dir, theme)
|
||||||
|
return banner_file, banner_filename
|
||||||
|
|
||||||
|
|
||||||
def get_right_image_file(base_dir: str,
|
def get_right_image_file(base_dir: str,
|
||||||
|
|
@ -701,7 +709,9 @@ def get_right_image_file(base_dir: str,
|
||||||
"""Gets the image for the right column
|
"""Gets the image for the right column
|
||||||
"""
|
"""
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
return _get_image_file(base_dir, 'right_col_image', account_dir, theme)
|
banner_file, banner_filename = \
|
||||||
|
_get_image_file(base_dir, 'right_col_image', account_dir, theme)
|
||||||
|
return banner_file, banner_filename
|
||||||
|
|
||||||
|
|
||||||
def html_header_with_external_style(css_filename: str, instance_title: str,
|
def html_header_with_external_style(css_filename: str, instance_title: str,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue