#!/usr/bin/env python # coding:utf-8 """ Author: Sir Garbagetruck -- Purpose: base class for Sahli file Created: 2020/04/09 """ import json ######################################################################## class sahlifile: """the Sahli file structure and classes to futz with""" # ---------------------------------------------------------------------- def __init__(self, filename): """Constructor""" self.valid_filetypes = [ "plain", "ansi", "xbin", "ice", "adf", "avatar", "bin", "idf", "pcboard", "tundra" ] self.valid_fonts = [ 'Propaz', 'ansifont', 'mOsOul', 'Microknight', 'p0t-nOodle' ] if filename is not None: with open(filename) as f: self.sahli = json.load(f) else: location = self.blank_location() slides = self.blank_slides() filedata = [] self.sahli = { 'location': location, 'slides': slides, 'filedata': filedata } def blank_slides(self): """blank slide structure""" slides = { 'background': '', 'template': '', 'css': '' } return slides def blank_location(self): """blank location structure""" return '' def blank_picture(self): """Blank picture structure""" return { 'file': '', 'name': '', 'amiga': False, 'filetype': 'image', 'width': '1600', 'author': '', 'font': 'Propaz', 'color': [0, 0, 0, 255], 'bg': [255, 255, 255, 255], 'line1': '', 'line2': '', 'text': '' } # ---------------------------------------------------------------------- def blank_amiga_ascii(self): """blank amiga ascii""" return { 'file': '', 'name': '', 'amiga': True, 'filetype': 'plain', 'width': '80', 'author': '', 'font': 'Propaz', 'color': [250, 250, 250, 255], 'bg': [0, 0, 0, 255], 'line1': '', 'line2': '', 'text': '' } # ---------------------------------------------------------------------- def blank_ansi(self): """blank PC Ansi""" return { 'file': '', 'name': '', 'amiga': False, 'filetype': 'ansi', 'width': '80', 'author': '', 'font': 'Propaz', 'color': [255, 255, 255, 255], 'bg': [0, 0, 0, 255], 'line1': '', 'line2': '', 'text': '' } def blank_filedata(self): """Blank filedata structure""" filedata = { 'file': '', 'name': '', 'amiga': False, 'filetype': 'image', 'width': '', 'author': '', 'font': 'Propaz', 'color': [0, 0, 0, 255], 'bg': [255, 255, 255, 255], 'line1': '', 'line2': '', 'text': '' } return filedata