Commit d7165522 authored by Studer Brendan's avatar Studer Brendan
Browse files

added app_config

parent 54fe1d69
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -4,8 +4,10 @@ import os
import logging
import shutil

from config.AppConfig import AppConfig

logging.basicConfig(format='[%(name)s::%(levelname)s]\t\t%(message)s', level=logging.DEBUG)
_logger = logging.getLogger("EOLJsonParser")


def show_chapters(chapters):
    print("=============== CHAPITRES ===============-")
@@ -22,9 +24,14 @@ def normalize_string(text):


def main(argv):
    inputfile = 'Chapters.json'
    outputFolder = 'Output'
    
    app_config = AppConfig()
    _logger = logging.getLogger(__name__)
    
    inputfile = app_config.get("INPUT_FILE_NAME")
    outputFolder = app_config.get("OUTPUT_FOLDER_NAME")
    tree = False
    
    try:
        opts, args = getopt.getopt(argv,"hti:o:",["ifile=","ofile=","tree"])
    except getopt.GetoptError:

Errors/Errors.py

0 → 100644
+4 −0
Original line number Diff line number Diff line
class EnvironementVariableNotFoundError(Exception):
    """Raised when trying to get a .env variable that doesn't exists"""
    def __init__(self) -> None:
        super().__init__("The environement variable you're trying to get doesn't exist")
 No newline at end of file

README.md

0 → 100644
+23 −0
Original line number Diff line number Diff line
# EOLJsonParser
this project is meant to be a tool for the End Of Life unity project. It uses a JSON file to create Naninovel scripts.

## Input
A json file containing scenarios generated by the [EndOfLife-StoryBuilder](https://labinfo.ing.he-arc.ch/gitlab/ticd/17ticd05/endoflife-storybuilder) C# project.

## Output
A folder tree containing Naninovel scripts

# Installation
- Python 0.10.8
    - No tested for other versions.

# Run
run the following command
´´´bash
python .\EOLJsonParser.py
´´´

It's possible to add arguments
- -i or --ifile" to specified the input json file
- -o or --ofile to specify the name of the output folder
- -t or --tree to only print the tree of scenarios
 No newline at end of file

config/AppConfig.py

0 → 100644
+16 −0
Original line number Diff line number Diff line
from dotenv import load_dotenv, find_dotenv
import os

from Errors.Errors import EnvironementVariableNotFoundError

class AppConfig:
    def __init__(self) -> None:
        load_dotenv(find_dotenv())
        
    def get(self,name):
        var = os.getenv(name)
        
        if not var:
            raise EnvironementVariableNotFoundError()
        
        return var
 No newline at end of file