diff --git a/utils/wl_utils.py b/utils/wl_utils.py index 2e12aa3c6..986b3cbc2 100644 --- a/utils/wl_utils.py +++ b/utils/wl_utils.py @@ -33,17 +33,11 @@ def check_os(): return is_windows, is_macos, is_linux def get_wl_ver(): - wl_ver = '1.0.0' + with open('../VERSION', 'r', encoding = 'utf_8') as f: + for line in f: + if line.strip() and not line.startswith('#'): + wl_ver = line.strip() - try: - # Version file is generated on Windows - with open('../VERSION', 'r', encoding = 'utf_8', newline = '\r\n') as f: - for line in f: - if line.strip() and not line.startswith('#'): - wl_ver = line.strip() - - break - except (FileNotFoundError, PermissionError): - pass + break return wl_ver diff --git a/wordless/wl_main.py b/wordless/wl_main.py index d7abbbc86..445878b60 100644 --- a/wordless/wl_main.py +++ b/wordless/wl_main.py @@ -1085,110 +1085,107 @@ def __init__(self, main): changelog = [] - try: - with open(wl_paths.get_path_file('CHANGELOG.md'), 'r', encoding = 'utf_8') as f: - for line in f: - # Changelog headers - if line.startswith('## '): - release_ver = re.search(r'(?<=\[)[^\]]+?(?=\])', line).group() - release_link = re.search(r'(?<=\()[^\)]+?(?=\))', line).group() - release_date = re.search(r'(?<=\- )[0-9?]{2}/[0-9?]{2}/[0-9?]{4}', line).group() - - changelog.append({ - 'release_ver': release_ver, - 'release_link': release_link, - 'release_date': release_date, - 'changelog_sections': [] - }) - - # Changelog section headers - elif line.startswith('### '): - changelog[-1]['changelog_sections'].append({ - 'section_header': line.replace('###', '').strip(), - 'section_list': [] - }) - # Changelog section lists - elif line.startswith('- '): - line = re.sub(r'^- ', r'', line).strip() - - changelog[-1]['changelog_sections'][-1]['section_list'].append(line) - - font_size_custom = main.settings_custom['general']['ui_settings']['font_size'] - - changelog_text = f''' - - - - + with open(wl_paths.get_path_file('CHANGELOG.md'), 'r', encoding = 'utf_8') as f: + for line in f: + # Changelog headers + if line.startswith('## '): + release_ver = re.search(r'(?<=\[)[^\]]+?(?=\])', line).group() + release_link = re.search(r'(?<=\()[^\)]+?(?=\))', line).group() + release_date = re.search(r'(?<=\- )[0-9?]{2}/[0-9?]{2}/[0-9?]{4}', line).group() + + changelog.append({ + 'release_ver': release_ver, + 'release_link': release_link, + 'release_date': release_date, + 'changelog_sections': [] + }) + + # Changelog section headers + elif line.startswith('### '): + changelog[-1]['changelog_sections'].append({ + 'section_header': line.replace('###', '').strip(), + 'section_list': [] + }) + # Changelog section lists + elif line.startswith('- '): + line = re.sub(r'^- ', r'', line).strip() + + changelog[-1]['changelog_sections'][-1]['section_list'].append(line) + + font_size_custom = main.settings_custom['general']['ui_settings']['font_size'] + + changelog_text = f''' + + + + + ''' + + for release in changelog: + changelog_text += f''' +
+
{release['release_ver']} - {release['release_date']}
+
''' - for release in changelog: + for changelog_section in release['changelog_sections']: changelog_text += f''' -
-
{release['release_ver']} - {release['release_date']}
-
+
+
{changelog_section['section_header']}
+
    ''' - for changelog_section in release['changelog_sections']: + for item in changelog_section['section_list']: changelog_text += f''' -
    -
    {changelog_section['section_header']}
    -
      - ''' - - for item in changelog_section['section_list']: - changelog_text += f''' -
    • {item}
    • - ''' - - changelog_text += ''' -
    -
    +
  • {item}
  • ''' changelog_text += ''' +
''' changelog_text += ''' - +
''' - except (FileNotFoundError, PermissionError): - changelog_text = traceback.format_exc() + + changelog_text += ''' + + ''' text_edit_changelog = wl_editors.Wl_Text_Browser(self) text_edit_changelog.setHtml(changelog_text) diff --git a/wordless/wl_utils/wl_misc.py b/wordless/wl_utils/wl_misc.py index 5fdd5a901..ddb03d464 100644 --- a/wordless/wl_utils/wl_misc.py +++ b/wordless/wl_utils/wl_misc.py @@ -88,18 +88,12 @@ def get_linux_distro(): def get_wl_ver(): - wl_ver = '1.0.0' + with open(wl_paths.get_path_file('VERSION'), 'r', encoding = 'utf_8') as f: + for line in f: + if line.strip() and not line.startswith('#'): + wl_ver = line.strip() - try: - # Version file is generated on Windows - with open(wl_paths.get_path_file('VERSION'), 'r', encoding = 'utf_8', newline = '\r\n') as f: - for line in f: - if line.strip() and not line.startswith('#'): - wl_ver = line.strip() - - break - except (FileNotFoundError, PermissionError): - pass + break return packaging.version.Version(wl_ver)