Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
a3191908dd | |||
125e2ac9ca | |||
27329865ee | |||
0ae7d01a1e | |||
5dc81a4508 | |||
925006e496 | |||
b9856a5e32 | |||
f7757d1fbf | |||
018f99c1d6 | |||
75e8940a43 | |||
e32da9d7fa |
14 changed files with 79 additions and 26 deletions
|
@ -5,8 +5,8 @@ __version__ = "0.0.1"
|
||||||
from os import linesep
|
from os import linesep
|
||||||
|
|
||||||
|
|
||||||
class Class:
|
class Object:
|
||||||
"""Root class."""
|
"""Root object."""
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return machine-readable state.
|
"""Return machine-readable state.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Handle errors."""
|
"""Handle errors."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Error(Class, Exception):
|
class Error(Object, Exception):
|
||||||
"""Parent class for all errors."""
|
"""Parent class for all errors."""
|
||||||
|
|
|
@ -139,11 +139,9 @@ def wipe(path: Path) -> None:
|
||||||
:type path: Path
|
:type path: Path
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
|
||||||
except NotADirectoryError:
|
|
||||||
path.unlink(missing_ok=True)
|
path.unlink(missing_ok=True)
|
||||||
except FileNotFoundError:
|
except IsADirectoryError:
|
||||||
pass
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
def write(file_path: Path, text: str, charset: str = CHARSET) -> None:
|
def write(file_path: Path, text: str, charset: str = CHARSET) -> None:
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class OS(Class, ABC):
|
class OS(Object, ABC):
|
||||||
"""Operating System."""
|
"""Operating System."""
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
from rwx.ps import Command
|
from rwx.ps import Command
|
||||||
|
|
||||||
|
|
||||||
class PM(Class, ABC):
|
class PM(Object, ABC):
|
||||||
"""Package Manager."""
|
"""Package Manager."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Project(Class):
|
class Project(Object):
|
||||||
"""Parent class for any type of project."""
|
"""Parent class for any type of project."""
|
||||||
|
|
||||||
def __init__(self, file: Path) -> None:
|
def __init__(self, file: Path) -> None:
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from rwx import Class, txt
|
from rwx import Object, txt
|
||||||
|
|
||||||
|
|
||||||
class Command(Class):
|
class Command(Object):
|
||||||
"""Command to run."""
|
"""Command to run."""
|
||||||
|
|
||||||
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
||||||
|
|
31
rwx/sw/freetube/authors.py
Normal file
31
rwx/sw/freetube/authors.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
"""FreeTube authors."""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from rwx import Object
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .playlists import Playlist
|
||||||
|
|
||||||
|
|
||||||
|
class Author(Object):
|
||||||
|
"""FreeTube author."""
|
||||||
|
|
||||||
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
"""Set uid & name.
|
||||||
|
|
||||||
|
:param uid: identifier
|
||||||
|
:type uid: str
|
||||||
|
:param name: label
|
||||||
|
:type name: str
|
||||||
|
"""
|
||||||
|
self.uid = uid
|
||||||
|
self.name = name
|
||||||
|
self.playlist: Playlist
|
||||||
|
|
||||||
|
def to_db(self) -> str:
|
||||||
|
"""Return non-breakable name.
|
||||||
|
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
return self.name.replace(" ", chr(0xA0))
|
|
@ -1,9 +1,9 @@
|
||||||
"""FreeTube channels."""
|
"""FreeTube channels."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Channel(Class):
|
class Channel(Object):
|
||||||
"""FreeTube channel."""
|
"""FreeTube channel."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
24
rwx/sw/freetube/languages.py
Normal file
24
rwx/sw/freetube/languages.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""FreeTube languages."""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from rwx import Object
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .playlists import Playlist
|
||||||
|
|
||||||
|
|
||||||
|
class Language(Object):
|
||||||
|
"""FreeTube language."""
|
||||||
|
|
||||||
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
"""Set uid & name.
|
||||||
|
|
||||||
|
:param uid: identifier
|
||||||
|
:type uid: str
|
||||||
|
:param name: label
|
||||||
|
:type name: str
|
||||||
|
"""
|
||||||
|
self.uid = uid
|
||||||
|
self.name = name
|
||||||
|
self.playlist: Playlist
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube playlists."""
|
"""FreeTube playlists."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .videos import Video
|
from .videos import Video
|
||||||
|
|
||||||
|
|
||||||
class Playlist(Class):
|
class Playlist(Object):
|
||||||
"""FreeTube playlist."""
|
"""FreeTube playlist."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube profiles."""
|
"""FreeTube profiles."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .channels import Channel
|
from .channels import Channel
|
||||||
|
|
||||||
|
|
||||||
class Profile(Class):
|
class Profile(Object):
|
||||||
"""FreeTube profile."""
|
"""FreeTube profile."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube settings."""
|
"""FreeTube settings."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .db import to_db
|
from .db import to_db
|
||||||
|
|
||||||
|
|
||||||
class Setting(Class):
|
class Setting(Object):
|
||||||
"""FreeTube setting."""
|
"""FreeTube setting."""
|
||||||
|
|
||||||
def __init__(self, uid: str, value: object) -> None:
|
def __init__(self, uid: str, value: object) -> None:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""FreeTube videos."""
|
"""FreeTube videos."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Video(Class):
|
class Video(Object):
|
||||||
"""FreeTube video."""
|
"""FreeTube video."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
Loading…
Reference in a new issue