lint format rank_hugo_themes.py

This commit is contained in:
Trent Palmer 2021-11-29 17:28:43 -08:00
parent ca15a18c53
commit bdfef627ac
1 changed files with 44 additions and 22 deletions

View File

@ -457,7 +457,8 @@ def coalesce_themes():
themes_toml_content=htfgitlab.themes_toml_content, themes_toml_content=htfgitlab.themes_toml_content,
)) ))
else: else:
if theme.url != htfgitlab.url: theme.url = htfgitlab.url if theme.url != htfgitlab.url:
theme.url = htfgitlab.url
if theme.commit_sha != htfgitlab.commit_sha: if theme.commit_sha != htfgitlab.commit_sha:
theme.commit_sha = htfgitlab.commit_sha theme.commit_sha = htfgitlab.commit_sha
if theme.commit_date != htfgitlab.commit_date: if theme.commit_date != htfgitlab.commit_date:
@ -475,7 +476,8 @@ def get_corrected_tags(tags):
result = [] result = []
correct = True correct = True
for tag in tags: for tag in tags:
if (len(tag) > 50): correct = False if (len(tag) > 50):
correct = False
if not correct: if not correct:
for tag in tags: for tag in tags:
result += [x.lstrip() for x in tag.split(',')] result += [x.lstrip() for x in tag.split(',')]
@ -509,13 +511,18 @@ def parse_themes_toml_for_each_hugo_themes():
if theme.tags_list != str(theme_tags): if theme.tags_list != str(theme_tags):
theme.tags_list = str(theme_tags) theme.tags_list = str(theme_tags)
else: else:
if theme.tags_list is not None: theme.tags_list = None if theme.tags_list is not None:
theme.tags_list = None
else: else:
if theme.tags_list is not None: theme.tags_list = None if theme.tags_list is not None:
if theme.num_tags != 0: theme.num_tags = 0 theme.tags_list = None
if theme.num_tags != 0:
theme.num_tags = 0
else: else:
if theme.tags_list is not None: theme.tags_list = None if theme.tags_list is not None:
if theme.num_tags != 0: theme.num_tags = 0 theme.tags_list = None
if theme.num_tags != 0:
theme.num_tags = 0
if 'features' in theme_toml: if 'features' in theme_toml:
if len(theme_toml['features']) > 0: if len(theme_toml['features']) > 0:
tf = [ tf = [
@ -534,40 +541,55 @@ def parse_themes_toml_for_each_hugo_themes():
else: else:
if theme.features_list is not None: if theme.features_list is not None:
theme.features_list = None theme.features_list = None
if theme.num_features != 0: theme.num_features = 0 if theme.num_features != 0:
theme.num_features = 0
else: else:
if theme.features_list is not None: theme.features_list = None if theme.features_list is not None:
if theme.num_features != 0: theme.num_features = 0 theme.features_list = None
if theme.num_features != 0:
theme.num_features = 0
if 'license' in theme_toml: if 'license' in theme_toml:
if theme.theme_license != theme_toml['license']: if theme.theme_license != theme_toml['license']:
theme.theme_license = theme_toml['license'] theme.theme_license = theme_toml['license']
else: else:
if theme.theme_license is not None: theme.theme_license = None if theme.theme_license is not None:
theme.theme_license = None
if 'min_version' in theme_toml: if 'min_version' in theme_toml:
corrected_mv = get_corrected_min_ver(theme_toml['min_version']) corrected_mv = get_corrected_min_ver(theme_toml['min_version'])
if theme.min_ver != corrected_mv: if theme.min_ver != corrected_mv:
theme.min_ver = corrected_mv theme.min_ver = corrected_mv
else: else:
if theme.min_ver is not None: theme.min_ver = None if theme.min_ver is not None:
theme.min_ver = None
if 'description' in theme_toml: if 'description' in theme_toml:
if theme.desc != theme_toml['description']: if theme.desc != theme_toml['description']:
theme.desc = theme_toml['description'] theme.desc = theme_toml['description']
else: else:
if theme.desc is not None: theme.desc = None if theme.desc is not None:
theme.desc = None
if 'name' in theme_toml: if 'name' in theme_toml:
if theme.cname != theme_toml['name']: if theme.cname != theme_toml['name']:
theme.cname = theme_toml['name'] theme.cname = theme_toml['name']
else: else:
if theme.cname is not None: theme.cname = None if theme.cname is not None:
theme.cname = None
else: else:
if theme.tags_list is not None: theme.tags_list = None if theme.tags_list is not None:
if theme.num_tags != 0: theme.num_tags = 0 theme.tags_list = None
if theme.features_list is not None: theme.features_list = None if theme.num_tags != 0:
if theme.num_features != 0: theme.num_features = 0 theme.num_tags = 0
if theme.theme_license is not None: theme.theme_license = None if theme.features_list is not None:
if theme.min_ver is not None: theme.min_ver = None theme.features_list = None
if theme.desc is not None: theme.desc = None if theme.num_features != 0:
if theme.cname is not None: theme.cname = None theme.num_features = 0
if theme.theme_license is not None:
theme.theme_license = None
if theme.min_ver is not None:
theme.min_ver = None
if theme.desc is not None:
theme.desc = None
if theme.cname is not None:
theme.cname = None
session.commit() session.commit()