From 707eac508776dfb96a04ea76ca15ecc9b1d37aa8 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 12 May 2022 13:19:41 +0000 Subject: [PATCH 01/10] [U] guix: Update readme usage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72b258be..76162e8a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Currently, these distributions have existing packages for HyFetch: * ArchLinux: `yay -S hyfetch` (Thanks to @ Aleksana) * NixOS: `nix-env -i hyfetch` ([In Progress](https://github.com/NixOS/nixpkgs/pull/170309)) -* Guix: [In progress](https://issues.guix.gnu.org/54847#8-lineno27) +* Guix: `guix install hyfetch` (Thanks to @ WammKD) Currently, if you're using NixOS, you can use HyFetch with `nix-env -if https://github.com/hykilpikonna/hyfetch/tarball/master -A hyfetch` From 85eaad14f2d8b3108c78599541903a849fddc520 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sat, 2 Jul 2022 23:37:18 -0400 Subject: [PATCH 02/10] [F] AttributeError: 'dict' object has no attribute 'recolor_ascii' --- hyfetch/main.py | 2 +- hyfetch/models.py | 7 ++++++- hyfetch/neofetch_util.py | 8 +++++++- hyfetch/serializer.py | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index d60ac279..39044a37 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -27,7 +27,7 @@ def check_config() -> Config: :return: Config object """ if CONFIG_PATH.is_file(): - return Config(**json.loads(CONFIG_PATH.read_text('utf-8'))) + return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8'))) return create_config() diff --git a/hyfetch/models.py b/hyfetch/models.py index 2ad68835..faef1318 100644 --- a/hyfetch/models.py +++ b/hyfetch/models.py @@ -7,7 +7,7 @@ from typing_extensions import Literal from .color_util import AnsiMode from .constants import CONFIG_PATH from .neofetch_util import ColorAlignment -from .serializer import json_stringify +from .serializer import json_stringify, from_dict @dataclass @@ -18,6 +18,11 @@ class Config: lightness: float | None = None color_align: ColorAlignment = ColorAlignment('horizontal') + @classmethod + def from_dict(cls, d: dict): + d['color_align'] = ColorAlignment.from_dict(d['color_align']) + return from_dict(cls, d) + def save(self): CONFIG_PATH.parent.mkdir(exist_ok=True, parents=True) CONFIG_PATH.write_text(json_stringify(self), 'utf-8') diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index a6b80f8b..51d87bfe 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -1,5 +1,6 @@ from __future__ import annotations +import inspect import os import platform import re @@ -15,6 +16,7 @@ from typing_extensions import Literal from hyfetch.color_util import color from .constants import GLOBAL_CFG from .presets import ColorProfile +from .serializer import from_dict RE_NEOFETCH_COLOR = re.compile('\\${c[0-9]}') @@ -67,6 +69,10 @@ class ColorAlignment: # Foreground/background ascii color index fore_back: tuple[int, int] = () + @classmethod + def from_dict(cls, d: dict): + return from_dict(cls, d) + def recolor_ascii(self, asc: str, preset: ColorProfile) -> str: """ Use the color alignment to recolor an ascii art @@ -177,7 +183,7 @@ def run_neofetch(preset: ColorProfile, alignment: ColorAlignment): color_alignments = { 'fedora': ColorAlignment('horizontal', fore_back=(2, 1)), 'ubuntu': ColorAlignment('horizontal', fore_back=(2, 1)), - 'nixos': ColorAlignment('custom', {1: 1, 2: 0}), + 'NixOS.*': ColorAlignment('custom', {1: 1, 2: 0}), # 'arch': ColorAlignment('horizontal'), # 'centos': ColorAlignment('horizontal'), } diff --git a/hyfetch/serializer.py b/hyfetch/serializer.py index 28cf4f37..a392707c 100644 --- a/hyfetch/serializer.py +++ b/hyfetch/serializer.py @@ -1,6 +1,7 @@ from __future__ import annotations import dataclasses +import inspect import json from datetime import datetime, date @@ -41,3 +42,7 @@ def json_stringify(obj: object, indent: int | None = None) -> str: :return: Json strings """ return json.dumps(obj, indent=indent, cls=EnhancedJSONEncoder, ensure_ascii=False) + + +def from_dict(cls, d: dict): + return cls(**{k: v for k, v in d.items() if k in inspect.signature(cls).parameters}) From 887f7664647b6c8cec9813e5765d3f5ba5e43c60 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 3 Jul 2022 12:42:19 -0400 Subject: [PATCH 03/10] [+] Dynamically set lightness based on light_dark --- hyfetch/color_util.py | 23 +++++++++++++++++------ hyfetch/constants.py | 5 +++++ hyfetch/main.py | 31 ++++++++++++++++--------------- hyfetch/models.py | 4 ++-- hyfetch/presets.py | 32 +++++++++++++++++++++++++++----- 5 files changed, 67 insertions(+), 28 deletions(-) diff --git a/hyfetch/color_util.py b/hyfetch/color_util.py index 45081f8e..a5b60fcd 100644 --- a/hyfetch/color_util.py +++ b/hyfetch/color_util.py @@ -1,13 +1,14 @@ from __future__ import annotations import colorsys -from typing import NamedTuple +from typing import NamedTuple, Callable, Optional from typing_extensions import Literal from .constants import GLOBAL_CFG AnsiMode = Literal['default', 'ansi', '8bit', 'rgb'] +LightDark = Literal['light', 'dark'] MINECRAFT_COLORS = ["&0/\033[0;30m", "&1/\033[0;34m", "&2/\033[0;32m", "&3/\033[0;36m", "&4/\033[0;31m", @@ -176,16 +177,26 @@ class RGB(NamedTuple): """ return RGB(*redistribute_rgb(*[v * multiplier for v in self])) - def set_light(self, light: float) -> 'RGB': + def set_light(self, light: float, at_least: bool | None = None, at_most: bool | None = None) -> 'RGB': """ Set HSL lightness value :param light: Lightness value (0-1) + :param at_least: Set the lightness to at least this value (no change if greater) + :param at_most: Set the lightness to at most this value (no change if lesser) :return: New color (original isn't modified) """ + # Convert to HSL h, l, s = colorsys.rgb_to_hls(*[v / 255.0 for v in self]) - return RGB(*[round(v * 255.0) for v in colorsys.hls_to_rgb(h, light, s)]) - def set_min_light(self, light: float) -> 'RGB': - h, l, s = colorsys.rgb_to_hls(*[v / 255.0 for v in self]) - return RGB(*[round(v * 255.0) for v in colorsys.hls_to_rgb(h, max(l, light), s)]) + # Modify light value + if at_least is None and at_most is None: + l = light + else: + if at_most: + l = min(l, light) + if at_least: + l = max(l, light) + + # Convert back to RGB + return RGB(*[round(v * 255.0) for v in colorsys.hls_to_rgb(h, l, s)]) diff --git a/hyfetch/constants.py b/hyfetch/constants.py index e4e2e629..b2e6ef3f 100644 --- a/hyfetch/constants.py +++ b/hyfetch/constants.py @@ -4,6 +4,8 @@ import os from dataclasses import dataclass from pathlib import Path +from typing_extensions import Literal + CONFIG_PATH = Path.home() / '.config/hyfetch.json' VERSION = '1.0.7' @@ -37,5 +39,8 @@ class GlobalConfig: debug: bool is_light: bool + def light_dark(self) -> Literal['light', 'dark']: + return 'light' if self.is_light else 'dark' + GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False) diff --git a/hyfetch/main.py b/hyfetch/main.py index 39044a37..98e37389 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -10,7 +10,7 @@ from typing import Iterable from hyfetch import presets -from .color_util import printc, color, clear_screen +from .color_util import printc, color, clear_screen, LightDark from .constants import CONFIG_PATH, VERSION, TERM_LEN, TEST_ASCII_WIDTH, TEST_ASCII, GLOBAL_CFG from .models import Config from .neofetch_util import run_neofetch, get_distro_ascii, ColorAlignment, ascii_size, color_alignments @@ -98,7 +98,16 @@ def create_config() -> Config: title += f'\n&e1. Selected color mode: &r{color_system}' ############################## - # 2. Choose preset + # 2. Select light/dark mode + clear_screen(title) + light_dark = literal_input(f'2. Is your terminal in &gf(#85e7e9)light mode&r or &gf(#c471ed)dark mode&r?', + ['light', 'dark'], 'dark') + is_light = light_dark == 'light' + GLOBAL_CFG.is_light = is_light + title += f'\n&e3. Light/Dark: &r{light_dark}' + + ############################## + # 3. Choose preset clear_screen(title) printc('&a2. Let\'s choose a flag!') printc('Available flag presets:') @@ -122,19 +131,10 @@ def create_config() -> Config: print() print() - tmp = PRESETS['rainbow'].set_light(.7).color_text('preset') + tmp = PRESETS['rainbow'].set_light_dl_def(light_dark).color_text('preset') preset = literal_input(f'Which {tmp} do you want to use?', PRESETS.keys(), 'rainbow', show_ops=False) _prs = PRESETS[preset] - title += f'\n&e2. Selected flag: &r{_prs.color_text(preset)}' - - ############################## - # 3. Select light/dark mode - clear_screen(title) - light_dark = literal_input(f'3. Is your terminal in &gf(#85e7e9)light mode&r or &gf(#c471ed)dark mode&r?', - ['light', 'dark'], 'dark') - is_light = light_dark == 'light' - GLOBAL_CFG.is_light = is_light - title += f'\n&e3. Light/Dark: &r{light_dark}' + title += f'\n&e3. Selected flag: &r{_prs.color_text(preset)}' ############################# # 4. Dim/lighten colors @@ -148,7 +148,7 @@ def create_config() -> Config: ratios = [col / (num_cols - 1) for col in range(num_cols)] ratios = [r * 0.6 + 0.2 for r in ratios] lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace( - '{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light(r)).split('\n') for r in ratios] + '{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios] [printc(' '.join(line)) for line in zip(*lines)] while True: @@ -170,11 +170,12 @@ def create_config() -> Config: printc('&cUnable to parse lightness value, please input it as a decimal or percentage (e.g. 0.5 or 50%)') if lightness: - _prs = _prs.set_light(lightness) + _prs = _prs.set_light_dl(lightness, light_dark) title += f'\n&e4. Brightness: &r{f"{lightness:.2f}" if lightness else "unset"}' ############################# # 5. Color arrangement + color_alignment = None while True: clear_screen(title) printc(f'&a5. Let\'s choose a color arrangement!') diff --git a/hyfetch/models.py b/hyfetch/models.py index faef1318..b36fccfe 100644 --- a/hyfetch/models.py +++ b/hyfetch/models.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from typing_extensions import Literal -from .color_util import AnsiMode +from .color_util import AnsiMode, LightDark from .constants import CONFIG_PATH from .neofetch_util import ColorAlignment from .serializer import json_stringify, from_dict @@ -14,7 +14,7 @@ from .serializer import json_stringify, from_dict class Config: preset: str mode: AnsiMode - light_dark: Literal['light', 'dark'] = 'dark' + light_dark: LightDark = 'dark' lightness: float | None = None color_align: ColorAlignment = ColorAlignment('horizontal') diff --git a/hyfetch/presets.py b/hyfetch/presets.py index c1bdc97b..01eb7d55 100644 --- a/hyfetch/presets.py +++ b/hyfetch/presets.py @@ -4,7 +4,8 @@ from typing import Iterable from typing_extensions import Literal -from .color_util import RGB +from .color_util import RGB, LightDark +from .constants import GLOBAL_CFG def remove_duplicates(seq: Iterable) -> list: @@ -100,17 +101,38 @@ class ColorProfile: """ return ColorProfile([c.lighten(multiplier) for c in self.colors]) - def set_light(self, light: float): + def set_light_raw(self, light: float, at_least: bool | None = None, at_most: bool | None = None) -> 'ColorProfile': """ Set HSL lightness value :param light: Lightness value (0-1) + :param at_least: Set the lightness to at least this value (no change if greater) + :param at_most: Set the lightness to at most this value (no change if lesser) :return: New color profile (original isn't modified) """ - return ColorProfile([c.set_light(light) for c in self.colors]) + return ColorProfile([c.set_light(light, at_least, at_most) for c in self.colors]) - def set_min_light(self, light: float): - return ColorProfile([c.set_min_light(light) for c in self.colors]) + def set_light_dl(self, light: float, term: LightDark = GLOBAL_CFG.light_dark()): + """ + Set HSL lightness value with respect to dark/light terminals + + :param light: Lightness value (0-1) + :param term: Terminal color (can be "dark" or "light") + :return: New color profile (original isn't modified) + """ + assert term.lower() in ['light', 'dark'] + at_least, at_most = (True, None) if term.lower() == 'dark' else (None, True) + return self.set_light_raw(light, at_least, at_most) + + def set_light_dl_def(self, term: LightDark = GLOBAL_CFG.light_dark()): + """ + Set default lightness with respect to dark/light terminals + + :param term: Terminal color (can be "dark" or "light") + :return: New color profile (original isn't modified) + """ + light = 0.65 if term.lower() == 'dark' else 0.4 + return self.set_light_dl(light, term) def unique_colors(self) -> ColorProfile: """ From 66ff8d06d98a1d9f4cd7a895e8428e9f6522ec8a Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 3 Jul 2022 12:46:37 -0400 Subject: [PATCH 04/10] [F] Fix lightness config reading --- hyfetch/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index 98e37389..dc74478c 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -299,9 +299,9 @@ def run(): if args.scale: preset = preset.lighten(args.scale) if args.light: - preset = preset.set_light(args.light) + preset = preset.set_light_raw(args.light) if config.lightness: - preset = preset.set_light(config.lightness) + preset = preset.set_light_dl(config.lightness) # Debug recommendations if args.debug_list: From 2e20d4e5294af6a11e428dff550c4b3cca46576b Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 3 Jul 2022 12:47:45 -0400 Subject: [PATCH 05/10] [F] Fix numbering --- hyfetch/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index dc74478c..332b90fe 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -104,12 +104,12 @@ def create_config() -> Config: ['light', 'dark'], 'dark') is_light = light_dark == 'light' GLOBAL_CFG.is_light = is_light - title += f'\n&e3. Light/Dark: &r{light_dark}' + title += f'\n&e2. Light/Dark: &r{light_dark}' ############################## # 3. Choose preset clear_screen(title) - printc('&a2. Let\'s choose a flag!') + printc('&a3. Let\'s choose a flag!') printc('Available flag presets:') print() From 143bfd2db7645b8058963128d184a7c461fcf925 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 3 Jul 2022 12:54:24 -0400 Subject: [PATCH 06/10] [O] Add more characters for ascii cat --- hyfetch/constants.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hyfetch/constants.py b/hyfetch/constants.py index b2e6ef3f..cda8d8d7 100644 --- a/hyfetch/constants.py +++ b/hyfetch/constants.py @@ -16,18 +16,18 @@ except Exception: TERM_LEN = 40 TEST_ASCII = r""" - |\___/| - ) ( - =\ /= - )===( - / \ - | | - / {txt} \ - \ / -_/\_ _/_/\_ -| |( ( | | -| | ) ) | | -| |(_( | |""".strip('\n') +### |\___/| ### +### ) ( ### +## =\ /= ## +#### )===( #### +### / \ ### +### | | ### +## / {txt} \ ## +## \ / ## +_/\_\_ _/_/\_ +|##| ( ( |##| +|##| ) ) |##| +|##| (_( |##|""".strip('\n') TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n')) From b68e0ccf5237727f3822fa70206213e3da5f9515 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 3 Jul 2022 13:02:39 -0400 Subject: [PATCH 07/10] [+] Add reference for default brightness --- hyfetch/constants.py | 6 ++++++ hyfetch/main.py | 4 ++-- hyfetch/presets.py | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hyfetch/constants.py b/hyfetch/constants.py index cda8d8d7..526146fe 100644 --- a/hyfetch/constants.py +++ b/hyfetch/constants.py @@ -30,6 +30,7 @@ _/\_\_ _/_/\_ |##| (_( |##|""".strip('\n') TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n')) +DEFAULT_DARK_L = 0. @dataclass class GlobalConfig: @@ -42,5 +43,10 @@ class GlobalConfig: def light_dark(self) -> Literal['light', 'dark']: return 'light' if self.is_light else 'dark' + def default_lightness(self, term: Literal['light', 'dark'] | None = None) -> float: + if term is None: + term = self.light_dark() + return 0.65 if term.lower() == 'dark' else 0.4 + GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False) diff --git a/hyfetch/main.py b/hyfetch/main.py index 332b90fe..8f453f16 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -146,14 +146,14 @@ def create_config() -> Config: # Print cats num_cols = TERM_LEN // (TEST_ASCII_WIDTH + 2) ratios = [col / (num_cols - 1) for col in range(num_cols)] - ratios = [r * 0.6 + 0.2 for r in ratios] + ratios = [(r * 0.4 + 0.1) if is_light else (r * 0.4 + 0.5) for r in ratios] lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace( '{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios] [printc(' '.join(line)) for line in zip(*lines)] while True: print() - printc('Which brightness level look the best? (Default: unset)') + printc(f'Which brightness level look the best? (Default: left blank = {GLOBAL_CFG.default_lightness(light_dark):.2f} for {light_dark} mode)') lightness = input('> ').strip().lower() or None # Parse lightness diff --git a/hyfetch/presets.py b/hyfetch/presets.py index 01eb7d55..0551fca3 100644 --- a/hyfetch/presets.py +++ b/hyfetch/presets.py @@ -124,15 +124,14 @@ class ColorProfile: at_least, at_most = (True, None) if term.lower() == 'dark' else (None, True) return self.set_light_raw(light, at_least, at_most) - def set_light_dl_def(self, term: LightDark = GLOBAL_CFG.light_dark()): + def set_light_dl_def(self, term: LightDark | None = None): """ Set default lightness with respect to dark/light terminals :param term: Terminal color (can be "dark" or "light") :return: New color profile (original isn't modified) """ - light = 0.65 if term.lower() == 'dark' else 0.4 - return self.set_light_dl(light, term) + return self.set_light_dl(GLOBAL_CFG.default_lightness(term), term) def unique_colors(self) -> ColorProfile: """ From c9ed8e208808087c1f948e687c89e4d45e754d7d Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Mon, 25 Jul 2022 20:40:43 -0400 Subject: [PATCH 08/10] [F] Put labels below ascii --- hyfetch/main.py | 12 ++++++------ neofetch | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index 8f453f16..0cf87db7 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -185,8 +185,8 @@ def create_config() -> Config: asc = get_distro_ascii() asc_width = ascii_size(asc)[0] asciis = [ - ['Horizontal'.center(asc_width), *ColorAlignment('horizontal').recolor_ascii(asc, _prs).split('\n')], - ['Vertical'.center(asc_width), *ColorAlignment('vertical').recolor_ascii(asc, _prs).split('\n')], + [*ColorAlignment('horizontal').recolor_ascii(asc, _prs).split('\n'), 'Horizontal'.center(asc_width)], + [*ColorAlignment('vertical').recolor_ascii(asc, _prs).split('\n'), 'Vertical'.center(asc_width)], ] ascii_per_row = TERM_LEN // (asc_width + 2) @@ -196,10 +196,10 @@ def create_config() -> Config: while len(pis) < len(set(re.findall('(?<=\\${c)[0-9](?=})', asc))): pis += pis perm = list(permutations(pis)) - random_count = ascii_per_row - 2 + random_count = ascii_per_row * 2 - 2 choices = random.sample(perm, random_count) choices = [{i: n for i, n in enumerate(c)} for c in choices] - asciis += [[f'random{i}'.center(asc_width), *ColorAlignment('custom', r).recolor_ascii(asc, _prs).split('\n')] + asciis += [[*ColorAlignment('custom', r).recolor_ascii(asc, _prs).split('\n'), f'random{i}'.center(asc_width)] for i, r in enumerate(choices)] while asciis: @@ -220,7 +220,7 @@ def create_config() -> Config: if choice in ['horizontal', 'vertical']: color_alignment = ColorAlignment(choice) elif choice.startswith('random'): - color_alignment = ColorAlignment('custom', choices[int(choice[6]) - 1]) + color_alignment = ColorAlignment('custom', choices[int(choice[6])]) else: raise NotImplementedError() @@ -243,7 +243,7 @@ def create_config() -> Config: def run(): # Create CLI - hyfetch = color('&b&lhy&f&lfetch&r') + hyfetch = color('&b&lhyfetch&r') parser = argparse.ArgumentParser(description=color(f'{hyfetch} - neofetch with flags <3')) parser.add_argument('-c', '--config', action='store_true', help=color(f'Configure {hyfetch}')) diff --git a/neofetch b/neofetch index 576a35ff..8efe9c6a 100755 --- a/neofetch +++ b/neofetch @@ -11598,6 +11598,11 @@ main() { return 0 } +get_ascii_distro_name() { + get_distro + echo "$ascii_distro" +} + get_print_ascii() { cache_uname get_os From eb76b2f4748a7c5cb15101e31adc1d66b77026d8 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Mon, 25 Jul 2022 20:41:09 -0400 Subject: [PATCH 09/10] [U] Release v1.1.0 --- hyfetch/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyfetch/constants.py b/hyfetch/constants.py index 526146fe..fa6bf2d1 100644 --- a/hyfetch/constants.py +++ b/hyfetch/constants.py @@ -7,7 +7,7 @@ from pathlib import Path from typing_extensions import Literal CONFIG_PATH = Path.home() / '.config/hyfetch.json' -VERSION = '1.0.7' +VERSION = '1.1.0' # Obtain terminal size try: From 8d3a3cc7f07d412d762ec25955674584d6587b80 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Mon, 25 Jul 2022 20:43:52 -0400 Subject: [PATCH 10/10] [F] Fix config upgrade error --- hyfetch/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index 0cf87db7..47d7ba13 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -27,7 +27,10 @@ def check_config() -> Config: :return: Config object """ if CONFIG_PATH.is_file(): - return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8'))) + try: + return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8'))) + except KeyError: + return create_config() return create_config()