Store flags as images - #156
Conversation
|
Thank you so much for the refactoring to make image-based flag rendering possible! This is a very significant update, and I'd like to ensure that I thoroughly understand everything before integrating. I appreciate your patience as we work toward incorporating these changes for the next release. |
| tty = importlib.import_module("tty") | ||
| signal = importlib.import_module("signal") | ||
| termios = importlib.import_module("termios") | ||
| select = importlib.import_module("select").select |
There was a problem hiding this comment.
Here you can actually achieve the same effect by just moving the import statements inside the function. Dynamic importing using importlib is only required if the module name is a string that you don't know beforehand.
| from __future__ import annotations | ||
|
|
There was a problem hiding this comment.
Also please don't remove from __future__ import annotations, they're required for Python 3.7-8 compatibility. Thanks!
|
Just added the fixes! |
| files = os.listdir('hyfetch/flags') | ||
| # Remove file extensions | ||
| files_no_ext = [f.split('.')[0] for f in os.listdir('hyfetch/flags')] | ||
| # Get index of file in list of files without extensions, raise error if it doesn't exist |
There was a problem hiding this comment.
Using relative directories like this actually wouldn't work when you're outside the hyfetch directory. For example, if you use pip install . to install hyfetch and run hyfetch -c outside of the hyfetch directory, it would raise a FileNotFound error. You should use paths relative to the current file instead. (e.g. Path(__file__).parent / 'flags')
| from __future__ import annotations | ||
|
|
||
| from typing_extensions import Literal | ||
|
|
||
| AnsiMode = Literal['default', 'ansi', '8bit', 'rgb'] | ||
| LightDark = Literal['light', 'dark'] | ||
| BackendLiteral = Literal["neofetch", "fastfetch"] |
There was a problem hiding this comment.
There is already hyfetch/types.py.
|
Updated! |
|
Applied merges! |
|
Is this still active? |
Looks like no |
bdb5086 to
1160be7
Compare

Description
The current system for storing flags only stores striped patterns. This pull request changes it to storing flags as images, allowing for non-stripe patterns and custom flags.
Relevant Links
This adds the demisexual flag #30 and allows for custom flags to be added #46.
Screenshots
Additional context
Future versions could add a command line utility for managing custom flags.