From 45fb070665904c913d586751b92cec85d8851a15 Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 3 Nov 2022 18:24:30 +0300 Subject: [PATCH] Uh, some basic stuff --- mastoposter/mkconfig/__main__.py | 34 +++++++++++++++++++++++++++ mastoposter/mkconfig/backends/base.py | 19 +++++++++++++++ requirements.txt | 3 +++ 3 files changed, 56 insertions(+) create mode 100644 mastoposter/mkconfig/__main__.py create mode 100644 mastoposter/mkconfig/backends/base.py diff --git a/mastoposter/mkconfig/__main__.py b/mastoposter/mkconfig/__main__.py new file mode 100644 index 0000000..4c33a9a --- /dev/null +++ b/mastoposter/mkconfig/__main__.py @@ -0,0 +1,34 @@ +from argparse import ArgumentParser, Namespace +from os.path import exists +from rich.prompt import Confirm +from rich import print + +parser = ArgumentParser( + "mastoposter.mkconfig", + description="Configuration script for mastoposter", + epilog="For detailed description of configuration file, " + "visit https://github.com/hatkidchan/mastoposter", +) + +parser.add_argument( + "-o", dest="output", required=True, help="Path of output file" +) + +parser.add_argument( + "-f", dest="force", action="store_true", help="Force overwrite" +) + + +def main(args: Namespace): + if exists(args.output) and not args.force: + print("[red]File already exists. It will be overwritten in the end") + if not Confirm.ask("Continue?"): + return 1 + + # TODO + + +if __name__ == "__main__": + from sys import argv + + exit(main(parser.parse_args(argv[1:]))) diff --git a/mastoposter/mkconfig/backends/base.py b/mastoposter/mkconfig/backends/base.py new file mode 100644 index 0000000..3629214 --- /dev/null +++ b/mastoposter/mkconfig/backends/base.py @@ -0,0 +1,19 @@ +from abc import ABC, abstractmethod +from configparser import ConfigParser + + +class BaseBackend(ABC): + def __init__(self): + pass + + @abstractmethod + def pre_run(self): + raise NotImplementedError + + @abstractmethod + def configure(self): + raise NotImplementedError + + @abstractmethod + def generate_config(self) -> ConfigParser: + raise NotImplementedError diff --git a/requirements.txt b/requirements.txt index 985a2f1..3c78e6c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ anyio==3.6.1 beautifulsoup4==4.11.1 bs4==0.0.1 certifi==2022.6.15 +commonmark==0.9.1 emoji==2.0.0 h11==0.12.0 httpcore==0.15.0 @@ -10,7 +11,9 @@ idna==3.3 Jinja2==3.1.2 lxml==4.9.1 MarkupSafe==2.1.1 +Pygments==2.13.0 rfc3986==1.5.0 +rich==12.6.0 sniffio==1.2.0 soupsieve==2.3.2.post1 websockets==10.3