X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kll_lib%2Fbackends.py;h=69c57b51c66304d70c5609431e1260634212bd48;hb=cf5bba703932f11bb686d9968d0c4bb9eab2a32c;hp=09d430da69769b9383aa1389483ab03d0dff210f;hpb=5af3e3a0b549e00eb84ac8bb038dc2b9a870f3aa;p=kiibohd-kll.git diff --git a/kll_lib/backends.py b/kll_lib/backends.py index 09d430d..69c57b5 100644 --- a/kll_lib/backends.py +++ b/kll_lib/backends.py @@ -36,15 +36,22 @@ WARNING = '\033[5;1;33mWARNING\033[0m:' ### Classes ### class BackendBase: + # Default templates and output files + templatePaths = [] + outputPaths = [] + # Initializes backend # Looks for template file and builds list of fill tags - def __init__( self, templatePaths=[] ): - self.templatePaths = templatePaths + def __init__( self, templatePaths ): + # Use defaults if no template is specified + if templatePaths is not None: + self.templatePaths = templatePaths + self.fill_dict = dict() # Process each template and add to tagList self.tagList = [] - for templatePath in templatePaths: + for templatePath in self.templatePaths: # Does template exist? if not os.path.isfile( templatePath ): print ( "{0} '{1}' does not exist...".format( ERROR, templatePath ) ) @@ -73,6 +80,10 @@ class BackendBase: # Generates the output keymap with fill tags filled def generate( self, outputPaths ): + # Use default if not specified + if outputPaths is None: + outputPaths = self.outputPaths + for templatePath, outputPath in zip( self.templatePaths, outputPaths ): # Process each line of the template, outputting to the target path with open( outputPath, 'w' ) as outputFile: