From f6de8832362032c8379fa6a8df8a4034c0d1419b Mon Sep 17 00:00:00 2001 From: ENDERZOMBI102 Date: Sun, 24 Jul 2022 01:06:37 +0200 Subject: [PATCH] stuff and main file --- automate/README.md | 5 ++++ automate/src/data/emote.py | 1 + automate/src/generator.py | 16 ++++++----- automate/src/main.py | 55 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 automate/README.md create mode 100644 automate/src/main.py diff --git a/automate/README.md b/automate/README.md new file mode 100644 index 0000000..bcd4035 --- /dev/null +++ b/automate/README.md @@ -0,0 +1,5 @@ +To run +- +```bash +$ python src/main.py +``` \ No newline at end of file diff --git a/automate/src/data/emote.py b/automate/src/data/emote.py index e90c485..565aac4 100644 --- a/automate/src/data/emote.py +++ b/automate/src/data/emote.py @@ -21,6 +21,7 @@ class Emote: Emote( origin=[ origin ], **entry | { + 'base': 'base' if 'base' not in entry and 'src' not in entry else entry.get( 'base', None ), 'overwrites': Overwrite.load( entry.get( 'overwrites', [ ] ) ), 'objects': Object.load( entry.get( 'objects', [ ] ) ) } diff --git a/automate/src/generator.py b/automate/src/generator.py index 67d686c..58a1fc5 100644 --- a/automate/src/generator.py +++ b/automate/src/generator.py @@ -1,9 +1,9 @@ from pathlib import Path -import yaml +from PIL.Image import Image from cairosvg.surface import Surface - +from data.emote import Emote from data.variants import Variants @@ -20,17 +20,21 @@ class Generator: def load( self, declFile: Path ) -> Variants: return Variants( declFile, self ) - def generate( self, outputDir: Path = Path('.') ) -> None: + def generate( self, emote: Emote ) -> Image: + pass + + def export( self, sets: list[str], outputDir: Path = Path( '.' ) ) -> None: """ Generates the images in the given folder \t + :param sets: the sets to export to PNGs :param outputDir: output directory """ if not outputDir.exists(): outputDir.mkdir() - print( self.declarations['neugeme'] ) + for set in sets: + # for emote in emotes + pass -if __name__ == '__main__': - Generator( Path('./resources/neugeme.yml') ).generate( Path('./run') ) diff --git a/automate/src/main.py b/automate/src/main.py new file mode 100644 index 0000000..acbd2bf --- /dev/null +++ b/automate/src/main.py @@ -0,0 +1,55 @@ +import os +import sys +from argparse import ArgumentParser +from pathlib import Path +from typing import cast + +from generator import Generator + +parser = ArgumentParser( + prog=( 'automation' + '.exe' if 'win' in os.name.lower() else '' ) if getattr( sys, 'frozen', False ) else 'main.py', + description='Generates blobfoxes from yaml and svgs' +) + +parser.add_argument( + '-d', + '--declfile', + help='Declaration file to export', + action='store', + type=Path, + dest='declFile', + required=True +) +parser.add_argument( + '-e', + '--export', + help='A comma-separated list of emote to export', + action='store', + dest='exports', + default='' +) +parser.add_argument( + '-o', + '--output', + help='Output directory', + action='store', + type=Path, + dest='output', + default=Path('.') +) + + +class Arguments: + declFile: Path + exports: str + output: Path + + +if __name__ == '__main__': + args: Arguments = cast( parser.parse_args( sys.argv[1:] ), Arguments ) + + gen = Generator( args.declFile ) + + gen.export( args.exports.split(','), args.output ) + +