]> git.donarmstrong.com Git - kiibohd-kll.git/commitdiff
Adding backend specific template and output defaults.
authorJacob Alexander <haata@kiibohd.com>
Sun, 22 Feb 2015 07:34:14 +0000 (23:34 -0800)
committerJacob Alexander <haata@kiibohd.com>
Sun, 22 Feb 2015 07:34:14 +0000 (23:34 -0800)
backends/kiibohd.py
kll.py
kll_lib/backends.py

index 34b570a8b3d9b5c270b2c5861cbc46ac574b70df..ca1f4fbb926a8d54fda481e9c9467645ea69aa1d 100644 (file)
@@ -36,6 +36,10 @@ from kll_lib.backends import *
 ### Classes ###
 
 class Backend( BackendBase ):
+       # Default templates and output files
+       templatePaths = ["templates/kiibohdKeymap.h", "templates/kiibohdDefs.h"]
+       outputPaths = ["generatedKeymap.h", "kll_defs.h"]
+
        # USB Code Capability Name
        def usbCodeCapability( self ):
                return "usbKeyOut";
diff --git a/kll.py b/kll.py
index eab30981aa6d4abdeeb318dd80074f26bf669482..2ddd35a672ec0d627efb9d7669fda02cb3972bdb 100755 (executable)
--- a/kll.py
+++ b/kll.py
@@ -83,7 +83,8 @@ def processCommandLineArgs():
        # Optional Arguments
        pArgs.add_argument( '-b', '--backend', type=str, default="kiibohd",
                help="Specify target backend for the KLL compiler.\n"
-               "Default: kiibohd" )
+               "Default: kiibohd\n"
+               "Options: kiibohd, json" )
        pArgs.add_argument( '-d', '--default', type=str, nargs='+',
                help="Specify .kll files to layer on top of the default map to create a combined map." )
        pArgs.add_argument( '-p', '--partial', type=str, nargs='+', action='append',
@@ -91,13 +92,11 @@ def processCommandLineArgs():
                "Each -p defines another partial map.\n"
                "Base .kll files (that define the scan code maps) must be defined for each partial map." )
        pArgs.add_argument( '-t', '--templates', type=str, nargs='+',
-               default=["templates/kiibohdKeymap.h", "templates/kiibohdDefs.h"],
                help="Specify template used to generate the keymap.\n"
-               "Default: templates/kiibohdKeymap.h templates/kiibohdDefs.h" )
+               "Default: <backend specific>" )
        pArgs.add_argument( '-o', '--outputs', type=str, nargs='+',
-               default=["generatedKeymap.h", "kll_defs.h"],
                help="Specify output file. Writes to current working directory by default.\n"
-               "Default: generatedKeymap.h kll_defs.h" )
+               "Default: <backend specific>" )
        pArgs.add_argument( '-h', '--help', action="help",
                help="This message." )
 
index 09d430da69769b9383aa1389483ab03d0dff210f..69c57b51c66304d70c5609431e1260634212bd48 100644 (file)
@@ -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: