def loadTemplate(self,templateName):
     template=None
     #TODO: fill in stub
     if len(templateName) == 0:
         return False
     #check if step template is already loaded
     if templateName.upper() in self.jobtemplates:
         #if loaded, no more work to do
         return True;
     #if not found, check if template exists
     path2Template=os.path.join(PipelineUtil.templateDir(),templateName.upper()+".sjt")
     #print(path2Template)
     if os.path.isfile(path2Template):
         #if template exists
         template=PipelineTemplate.readTemplate(templateName.upper())
         self.jobtemplates[templateName.upper()]=template
         return True
     else:
         #if template doesn't exist, signal error
         return False
def main(argv=None):
    if argv is None:
        argv = sys.argv
    try:
        #try to parse option arguments
        try:
            opts=[]
            opts.append("variable|V=s@")
            opts.append("clearsuffixes|C")
            opts.append("suffix|S=s")
            opts.append("template|T=s")
            opts.append("subjob|J=s@")
            opts.append("cross|c")
            opts.append("help|h")
            opt_parser=DPyGetOpt.DPyGetOpt()
            opt_parser.setIgnoreCase(False)
            opt_parser.setAllowAbbreviations(False)
            opt_parser.setPosixCompliance(True)
            opt_parser.parseConfiguration(opts)
            opt_parser.processArguments(sys.argv)
            pipeline_vars=opt_parser.valueForOption("variable")
            pipeline_clearsuffixes=bool(opt_parser.valueForOption("clearsuffixes"))
            pipeline_crossjob=bool(opt_parser.valueForOption("cross"))
            pipeline_suffix=opt_parser.valueForOption("suffix")
            pipeline_templateName=opt_parser.valueForOption("template")
            pipeline_subjobs=opt_parser.valueForOption("subjob")
            help_flag=bool(opt_parser.valueForOption("help"))
            if help_flag:
                raise Usage(err=False)
            argv=opt_parser.freeValues
            print("defined vars:")
            if pipeline_vars is None:
                print("\t(No vars defined)")
            else:
                for var in pipeline_vars:
                    print("\t%s" % var)
            if pipeline_subjobs is None:
                raise Usage("Must define at least one subjob",err=True)
            else:
                print("defined subjob commands:")
                for job in pipeline_subjobs:
                    print("\t%s" % job)
            print("suffixes cleared after template:")
            print("\t%s" % pipeline_clearsuffixes)
            print("Is a CrossJob:")
            print("\t%s" % pipeline_crossjob)
            if pipeline_suffix is None:
                raise Usage("Must Specify a template suffix",err=True)
            print("Template Suffix:")
            print("\t%s" % pipeline_suffix)
            if pipeline_templateName is None:
                raise Usage("Must Specify a template name",err=True)
            print("Template Name:")
            print("\t%s" % pipeline_templateName)
            #TODO method stub
            temp=PipelineTemplate()
            temp.suffix=pipeline_suffix; 
            temp.clearsuffixes=pipeline_clearsuffixes;
            temp.isCrossJob=pipeline_crossjob;
            temp.name=pipeline_templateName;
            parseVars(temp,pipeline_vars);
            parseSubJobs(temp,pipeline_subjobs);
            #temp.ClusterJobs=[];
            #temp.vars={};
            #temp.var_keys=[];
            temp.writeTemplate()
        except DPyGetOpt.ArgumentError as DPyGetOptArgErr:
            raise Usage("DPyGetOptArgErr: " + DPyGetOptArgErr.__str__())
        except DPyGetOpt.SpecificationError as DPyGetOptSpecErr:
            raise Usage("DPyGetOptSpecErr: " + DPyGetOptSpecErr.__str__())
        except DPyGetOpt.TerminationError as DPyGetOptTermErr:
            raise Usage("DPyGetOptTermErr: " + DPyGetOptTermErr.__str__())
        except DPyGetOpt.Error as DPyGetOptErr:
            raise Usage("DPyGetOptErr: " + DPyGetOptErr.__str__())
        except PipelineError as pipe_err:
            sys.stderr.write (pipe_err.msg);
            return -1;
        print("PROGRAM EXECUTION REACHED END OF MAIN")
        return 0;
    except Usage as err:
        sys.stderr.write(err.msg)
        return err.exit_code