Exemple #1
0
    def parse_recipe_template(self):
        """Parses the recipe template file."""
        ipkeys = self.input_options.get_sections()
        if 'personal_recipe' in ipkeys:
            raise MASTError(
                self.__class__.__name__,
                "Personal recipe section still exists in input.inp. Remove this section and try the command again."
            )
            return
        recipe_file_contents = self.input_options.get_item(
            'recipe', 'recipe_file')

        parser_obj = RecipeTemplateParser(templateFile=recipe_file_contents,
                                          inputOptions=self.input_options,
                                          personalRecipe=os.path.join(
                                              self.recdir, 'input.inp'),
                                          working_directory=self.recdir)
        personal_recipe_list = parser_obj.parse()
        #print personal_recipe_list
        if not personal_recipe_list:
            self.logger.info(
                "Within mast/parse_recipe_template: Personal Recipe List is empty. Check whether input.inp has a personal_recipe section!"
            )
        else:
            self.input_options.set_item('personal_recipe',
                                        'personal_recipe_list',
                                        personal_recipe_list)
Exemple #2
0
 def test_parse(self):
     #ipfile='small_workflow_with_scaling.inp'
     ipfile = 'phonon_with_neb.inp'
     workdir = os.path.join(testdir, 'workdir')
     shutil.copy(os.path.join(testdir, ipfile), workdir)
     input_file = os.path.join(workdir, ipfile)
     parser_obj = InputParser(inputfile=input_file)
     input_options = parser_obj.parse()
     recipe_file_contents = input_options.get_item('recipe', 'recipe_file')
     myrtp = RecipeTemplateParser(inputOptions=input_options,
                                  working_directory=workdir,
                                  templateFile=recipe_file_contents,
                                  personalRecipe=input_file)
     parsed_lines = myrtp.parse()
     output_parsed = MASTFile()
     output_parsed.data = list(parsed_lines)
     output_parsed.to_file('workdir/personal_recipe_test_output.txt')
     self.assertEquals(len(myrtp.chunks), 5)
     #mypr = MASTFile(pr)
     #for line in mypr.data:
     #    print line.rstrip()
     compare_pr = MASTFile(
         os.path.join(testdir, 'compare',
                      'personal_recipe_test_output.txt'))
     self.assertEquals(parsed_lines, compare_pr.data)
Exemple #3
0
    def parse_recipe_template(self):
        """Parses the recipe template file."""

        recipe_file_contents = self.input_options.get_item('recipe', 'recipe_file')

        parser_obj = RecipeTemplateParser(templateFile=recipe_file_contents, 
            inputOptions=self.input_options,
            personalRecipe=os.path.join(self.working_directory,'input.inp'),
            working_directory=self.working_directory
            )
        personal_recipe_list = parser_obj.parse()
        #print personal_recipe_list
        if not personal_recipe_list:
            self.logger.info("Within mast/parse_recipe_template: Personal Recipe List is empty. Check whether input.inp has a personal_recipe section!")
        else:
            self.input_options.set_item('personal_recipe','personal_recipe_list',personal_recipe_list)
Exemple #4
0
    def parse_recipe_template(self):
        """Parses the recipe template file."""
        ipkeys = self.input_options.get_sections()
        if 'personal_recipe' in ipkeys:
            raise MASTError(self.__class__.__name__, "Personal recipe section still exists in input.inp. Remove this section and try the command again.")
            return
        recipe_file_contents = self.input_options.get_item('recipe', 'recipe_file')

        parser_obj = RecipeTemplateParser(templateFile=recipe_file_contents, 
            inputOptions=self.input_options,
            personalRecipe=os.path.join(self.recdir,'input.inp'),
            working_directory=self.recdir
            )
        personal_recipe_list = parser_obj.parse()
        #print personal_recipe_list
        if not personal_recipe_list:
            self.logger.info("Within mast/parse_recipe_template: Personal Recipe List is empty. Check whether input.inp has a personal_recipe section!")
        else:
            self.input_options.set_item('personal_recipe','personal_recipe_list',personal_recipe_list)
Exemple #5
0
 def test___init__(self):
     raise SkipTest
     rt = os.path.join(testdir, 'new_template.txt')
     wd = os.path.join(testdir, 'workdir')
     iopt = InputOptions()
     pr = os.path.join(testdir, 'workdir', 'personal_recipe.txt')
     myrtp = RecipeTemplateParser(inputOptions=iopt,
                                  working_directory=wd,
                                  templateFile=rt,
                                  personalRecipe=pr)
     self.assertTrue(os.path.isfile, myrtp.metafile)
Exemple #6
0
    def parse_recipe_template(self):
        """Parses the recipe template file."""

        recipe_file_contents = self.input_options.get_item(
            'recipe', 'recipe_file')

        parser_obj = RecipeTemplateParser(
            templateFile=recipe_file_contents,
            inputOptions=self.input_options,
            personalRecipe=os.path.join(self.working_directory, 'input.inp'),
            working_directory=self.working_directory)
        personal_recipe_list = parser_obj.parse()
        #print personal_recipe_list
        if not personal_recipe_list:
            self.logger.info(
                "Within mast/parse_recipe_template: Personal Recipe List is empty. Check whether input.inp has a personal_recipe section!"
            )
        else:
            self.input_options.set_item('personal_recipe',
                                        'personal_recipe_list',
                                        personal_recipe_list)
 def test_parse(self):
     #ipfile='small_workflow_with_scaling.inp'
     ipfile='phonon_with_neb.inp'
     workdir = os.path.join(testdir,'workdir')
     shutil.copy(os.path.join(testdir,ipfile),workdir)
     input_file = os.path.join(workdir,ipfile)
     parser_obj = InputParser(inputfile=input_file)
     input_options = parser_obj.parse()
     recipe_file_contents = input_options.get_item('recipe','recipe_file')
     myrtp = RecipeTemplateParser(inputOptions=input_options,
         working_directory=workdir,
         templateFile=recipe_file_contents,
         personalRecipe=input_file)
     parsed_lines = myrtp.parse()
     output_parsed = MASTFile()
     output_parsed.data = list(parsed_lines)
     output_parsed.to_file('workdir/personal_recipe_test_output.txt')
     self.assertEquals(len(myrtp.chunks),5)
     #mypr = MASTFile(pr)
     #for line in mypr.data:
     #    print line.rstrip()
     compare_pr = MASTFile(os.path.join(testdir,'compare','personal_recipe_test_output.txt'))
     self.assertEquals(parsed_lines, compare_pr.data)