Skip to content

Commit

Permalink
Merge pull request #40 from romanin-rf/dev
Browse files Browse the repository at this point in the history
Update 0.8.2
  • Loading branch information
romanin-rf authored Dec 8, 2023
2 parents a4525fa + c2b7c09 commit 9534024
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 90 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

| Version | Date | Tag | Changelog |
| ------- | ---- | --- | --------- |
| [v0.8.2](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.8.2) | 08.12.2023 | **STABLE** | - Added language merge (for translating plugins)<br>- Fixed in translation files (`Log Menu Enable` -> `Logging' )<br>- Changed `object.css` (classes will no longer be used to specify standard properties)<br>- Improved widget `FillLabel` |
| [v0.8.1](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.8.1) | 07.12.2023 | **STABLE** | - Revisioned of the LanguageLoader<br>- Added new language: `Українська` |
| [v0.8.0](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.8.0) | 07.12.2023 | **STABLE** | - Added a new experimental `PopUp` widget (pop-up window)<br>- Added new exception type `Error`<br>- Added language loader system<br>- Added full translate: English, Русский<br>- Added `changelog.md`<br>- Added `secrets`<br>- Added widgets: `DataRadioButton`, `ClikableButton` and `Rheostat (experemental)`<br>- Fixed: `self.last_playback_status` not is int<br>- Changed CSS for `LogMenu`<br>- Updated `build.py`<br>- Renamed `*.css` files to `.tcss`<br>- Removing excess in `DataOptions` (from past updates)<br>- Deprecated method `seaplayer.functions.check_status`<br>- The first part of the attempts to make the `Configurate Screen` understandable to the average user |
| [v0.7.5](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.5) | 02.12.2023 | **STABLE** | - Updated the `Rich Discord Status` plugin (v0.2.1)<br>- Updated the `PluginLoader` (v0.3.0)<br>- Changed the backlight in the logs<br>- Transferred some methods to `functions.py`<br>- Removed excess (remaining from other updates) |
| [v0.7.4](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.4) | 01.12.2023 | **HOTFIX** | - Correction of errors in custom modules |
| [v0.7.3](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.3) | 01.12.2023 | **DEPRECATED** | - Added log on loading of `SeaPlayer`<br>- Updated README.md<br>- Updated dependencies<br>- Updated class `Log`<br>- Fixed the `NotAContainer` bug<br>- Fixed *CLI* operation<br>- Fixed the `pip install` startup error |
| [v0.7.2](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.2) | 29.11.2023 | **DEPRECATED** | - Added small optimizations |
| [v0.7.1](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.1.post1) | 28.11.2023 | **DEPRECATED** | - Optimization due to more transplanting to a newer version of `playsoundsimple` |
| [v0.7.0](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.0) | 28.11.2023 | **DEPRECATED** | - Added installation of modules from a file `requirements.txt` in the folder of any plugin, if there is one<br>- Added more intuitive logging |
| [v0.7.0](https://github.com/romanin-rf/SeaPlayer/releases/tag/v0.7.0) | 28.11.2023 | **DEPRECATED** | - Added installation of modules from a file `requirements.txt` in the folder of any plugin, if there is one<br>- Added more intuitive logging |
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "SeaPlayer"
version = "0.8.1"
version = "0.8.2"
description = "SeaPlayer is a player that works in the terminal."
repository = "https://github.com/romanin-rf/SeaPlayer"
authors = ["Romanin <[email protected]>"]
Expand Down
47 changes: 23 additions & 24 deletions seaplayer/css/objects.tcss
Original file line number Diff line number Diff line change
@@ -1,67 +1,63 @@
/* ! Music List */
.music-list-view {
MusicListView {
height: 1fr;
}

.music-list-view-item {
MusicListViewItem {
height: 4;
}

.music-list-view-item-title-label {
MusicListViewItem .title-label {
height: 1;
color: #cacaca;
}

.music-list-view-item-subtitle-label {
MusicListViewItem .subtitle-label {
height: 1;
color: #a9a9a9;
}

.music-list-screen-add-box {
height: 3;
}

.music-list-screen-add-input {
width: 1fr;
}

/* ! IndeterminateProgress */
.indeterminate-progress-bar { height: 1; }
IndeterminateProgress { height: 1; }

/* ! Rheostat */
.rheostat-bar { height: 1; }
.rheostat { height: 4; }
.rheostat-horizontal {
RheostatBar { height: 1; }
Rheostat { height: 4; }
Rheostat Horizontal {
align-horizontal: center;
width: 1fr;
}

/* ! Image Label */
.image-label {
StandartImageLabel {
height: 1fr;
width: 1fr;
align: center middle;
text-align: center;
}

AsyncImageLabel {
height: 1fr;
width: 1fr;
align: center middle;
text-align: center;
}

/* ! Configurate List */
.configurate-list-view {
ConfigurateList {
border: solid cadetblue;
height: 1fr;
width: 1fr;
}

.configurate-list-view-item {
ConfigurateListItem {
border: solid dodgerblue;
background: #0000;
border-title-color: #aaaaaa;
border-subtitle-color: #6b6b6b;
height: auto;
}

/* ! Any Elements CSS */
.pass-one-width { width: 1; }

/* ! Log Menu */
LogMenu {
background: $surface;
Expand Down Expand Up @@ -114,7 +110,10 @@ PopUp {
}

/* ! FullLabel */
.full-label {
FillLabel {
height: 1fr;
width: 1fr;
}
}

/* ! Any Elements CSS */
.pass-one-width { width: 1; }
9 changes: 9 additions & 0 deletions seaplayer/css/seaplayer.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@
align: center middle;
text-align: center;
}

/* Playlist */
.music-list-screen-add-box {
height: 3;
}

.music-list-screen-add-input {
width: 1fr;
}
4 changes: 2 additions & 2 deletions seaplayer/langs/en-eng.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ configurate.playlist="Playlist"
configurate.playlist.recursive_search="Recursive Search"
configurate.playlist.recursive_search.desc="Recursive file search."
configurate.debug="Debug"
configurate.debug.log_menu_enable="Log Menu Enable"
configurate.debug.log_menu_enable.desc="Menu with logs for the current session."
configurate.debug.log_menu_enable="Logging"
configurate.debug.log_menu_enable.desc="Enabling/disabling logging."
configurate.keys="Keys"
configurate.keys.quit="Quit"
configurate.keys.quit.desc="Сlose the app."
Expand Down
4 changes: 2 additions & 2 deletions seaplayer/langs/ru-rus.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ configurate.playlist="Плейлист"
configurate.playlist.recursive_search="Рекурсивный поиск"
configurate.playlist.recursive_search.desc="Рекурсивный поиск файлов."
configurate.debug="Дебаг"
configurate.debug.log_menu_enable="Меню логов"
configurate.debug.log_menu_enable.desc="Меню с логом для текущей сессии."
configurate.debug.log_menu_enable="Логирование"
configurate.debug.log_menu_enable.desc="Включение/выключение логирования."
configurate.keys="Клавиши"
configurate.keys.quit="Выход"
configurate.keys.quit.desc="Закрыть приложение."
Expand Down
4 changes: 2 additions & 2 deletions seaplayer/langs/uk-ukr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ configurate.playlist="Плейлист"
configurate.playlist.recursive_search="Рекурсивний пошук"
configurate.playlist.recursive_search.desc="Рекурсивний пошук файлів."
configurate.debug="Дебаг"
configurate.debug.log_menu_enable="Меню логів"
configurate.debug.log_menu_enable.desc="Меню з логом для поточної сесії."
configurate.debug.log_menu_enable="Логування"
configurate.debug.log_menu_enable.desc="Включення/вимикання логування."
configurate.keys="Клавіші"
configurate.keys.quit="Вихід"
configurate.keys.quit.desc="Закрити програму."
Expand Down
83 changes: 73 additions & 10 deletions seaplayer/languages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import glob
import properties
from typing import Dict, Tuple, Optional
from typing import Dict, List, Tuple, Optional
# > Local Imports
from .functions import formater
from .exceptions import LanguageNotExistError, LanguageNotLoadedError
Expand Down Expand Up @@ -36,7 +36,8 @@ def __init__(self, language_filepath: str) -> None:

# ? Magic Methods
def __str__(self) -> str:
return f"{self.__class__.__name__}({formater(name=self.__name, title=self.__title, mark=self.__mark)})"
form = formater(name=self.__name, title=self.__title, mark=self.__mark, loaded=self.__loaded)
return f"{self.__class__.__name__}({form})"

def __repr__(self) -> str:
return self.__str__()
Expand Down Expand Up @@ -85,17 +86,18 @@ def get(self, key: str, default: Optional[str]=None) -> Optional[str]:
# ! Main Class
class LanguageLoader:
# ? Main Methods
def __search_langs(self, dlm: str, mlm: str) -> Tuple[Language, Language]:
def __search_langs(self, dlm: str, mlm: str) -> Tuple[Language, Optional[Language]]:
dl, ml = None, None
for lang in self.langs:
if lang.mark == dlm:
dl = lang
if lang.mark == mlm:
ml = lang
if (dl is None) or (ml is None):
raise LanguageNotExistError([dlm, mlm])
if dl is None:
raise LanguageNotExistError([dl])
dl.load()
ml.load()
if ml is not None:
ml.load()
return dl, ml

# ? Initialization
Expand All @@ -108,12 +110,73 @@ def __init__(
self.__name = os.path.abspath(langs_dirpath)
self.__mlm = main_lang_mark.lower()
self.__dlm = default_lang_mark.lower()
self.__alangs: List[LanguageLoader] = []
# * Checking
if not os.path.isdir(self.__name):
raise FileNotFoundError
# * Searching Languages
self.langs = [Language(lp) for lp in glob.glob(os.path.join(self.__name, "??-???.properties"))]
self.dlang, self.mlang = self.__search_langs(self.__dlm, self.__mlm)
# * Searching and loading languages
self.__langs: List[Language] = [Language(lp) for lp in glob.glob(os.path.join(self.__name, "??-???.properties"))]
self.__dlang, self.__mlang = self.__search_langs(self.__dlm, self.__mlm)

# ? Magic Methods
def __str__(self) -> str:
form = formater(
name=self.__name,
default_lang_mark=self.__dlm,
main_lang_mark=self.__mlm,
langs=self.__langs,
alangs=self.__alangs
)
return f"{self.__class__.__name__}({form})"

def __repr__(self) -> str:
return self.__str__()

# ? Propertys
@property
def name(self) -> str:
return self.__name

@property
def main_lang_mark(self) -> str:
return self.__mlm

@property
def default_lang_mark(self) -> str:
return self.__dlm

@property
def langs(self) -> List[Language]:
return self.__langs

@property
def default_lang(self) -> Language:
return self.__dlang

@property
def main_lang(self) -> Optional[Language]:
return self.__mlang

@property
def alangs(self):
"""Additional languages, for example, translation of plugins.
Returns:
List[LanguageLoader]: A language loader with its own list of languages, which is the last thing to get from.
"""
return self.__alangs

# ? Public Methods
def get(self, key: str) -> str:
return self.mlang.get(key, self.dlang.get(key, "<LTNF>"))
if self.__mlang is None:
data = self.__dlang.get(key)
data = self.__mlang.get(key, self.__dlang.get(key))
if data is None:
for alang in self.__alangs:
if (data:=alang.get(key)) is not None:
break
return data if data is not None else "<LTNF>"

def merge(self, ll) -> None:
assert isinstance(ll, LanguageLoader)
self.__alangs.append(ll)
8 changes: 3 additions & 5 deletions seaplayer/objects/Configurate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def __init__(
width: Union[int, str]="1fr",
height: Union[int, str]="1fr",
**kwargs
):
kwargs["classes"] = "configurate-list-view-item"
) -> None:
super().__init__(*children, **kwargs)
self.border_title = title
self.border_subtitle = desc
Expand All @@ -26,6 +25,5 @@ async def updating(self, title: Optional[str]="", desc: Optional[str]="") -> Non

# ! Main Class
class ConfigurateList(ScrollableContainer):
def __init__(self, *children, **kwargs):
kwargs["classes"] = "configurate-list-view"
super().__init__(*children, **kwargs)
def __init__(self, *children, **kwargs) -> None:
super().__init__(*children, **kwargs)
14 changes: 0 additions & 14 deletions seaplayer/objects/FullLabel.py

This file was deleted.

6 changes: 3 additions & 3 deletions seaplayer/objects/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(
image: Optional[Image.Image]=None,
*,
resample: Resampling=Resampling.NEAREST
):
super().__init__("<image not found>", classes="image-label")
) -> None:
super().__init__("<image not found>")
self.image_resample = resample
self.default_image: Image.Image = default_image
self.image: Optional[Image.Image] = image
Expand Down Expand Up @@ -51,7 +51,7 @@ def __init__(
self.image: Optional[Image.Image] = image
self.image_text: Union[str, AsyncPixels] = "<image not found>"
self.last_image_size: Optional[Tuple[int, int]] = None
super().__init__("<image not found>", classes="image-label")
super().__init__("<image not found>")

async def on_resize(self) -> None:
image, resample = (self.default_image, Resampling.NEAREST) if (self.image is None) else (self.image, self.image_resample)
Expand Down
24 changes: 24 additions & 0 deletions seaplayer/objects/Labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from textual.widgets import Label
from rich.segment import Segments, Segment
from rich.style import Style
# > Typing
from typing import Optional

# ! Main Class
class FillLabel(Label):
def _gen(self) -> Segments:
return Segments([Segment(self.__chr, self.__style) for i in range((self.size[0] * self.size[1]))])

def __init__(
self,
char: str="-",
style: Optional[Style]=None,
**kwargs
) -> None:
super().__init__(**kwargs)
self.__chr = char[:1]
self.__style = style
self.update(self._gen())

async def on_resize(self) -> None:
self.update(self._gen())
Loading

0 comments on commit 9534024

Please sign in to comment.