Пример #1
0
def run(argv):
    """This function is the core-function using all the other components to
       do the expected work.

       This includes parsing the commandline, reading "config.ini", parsing
       the input-file and actual downloading of all the files.

       Called by ```run.py``` in base-dir.

    """
    # Parse arguments
    arg_parser = CLI()
    input_path, verbose = arg_parser.parse(argv[1:])  # argv[0] = script-name

    # Read config-file
    output_path = read_config()

    # Create and use input-parser
    parser = InputParser(input_path, output_path, verbose)

    # Create downloader
    downloader = Downloader(output_path, verbose)

    # Use downloader
    for url, filename in parser.get_url_targetname_pairs():
        downloader.download(url, filename)
Пример #2
0
    def test_valid_case(self):
        """All good case.

        """
        parser = InputParser(self.valid_f.name, self.valid_out_dir)
        parser_res = parser.get_url_targetname_pairs()
        self.assertEqual(parser_res[0][0], FIRST_URL)
        self.assertEqual(parser_res[1][0], SECOND_URL)
        self.assertEqual(parser_res[0][1], FIRST_FILE)
        self.assertEqual(parser_res[1][1], SECOND_FILE)
Пример #3
0
    def test_invalid_filenames(self):
        """Opening successfull, parsing successfull, but inferred filename is invalid.

        """
        with self.assertRaises(URLInferFilenameError):
            parser = InputParser(self.malformed_f_filename.name,
                                 self.valid_out_dir)
Пример #4
0
    def test_invalid_input_path(self):
        """Path does not lead to existing file.

        """
        with self.assertRaises(UtilsFileDoesNotExistError):
            parser = InputParser(self.valid_f.name + '_WRONG_PATH',
                                 self.valid_out_dir)
Пример #5
0
    def test_wrong_file_mode(self):
        """Opening fails (with high probability), as binary-file is opened in txt-mode.

        """
        with self.assertRaisesRegex(InputParserParseError,
                                    'Could not open input'):
            parser = InputParser(self.wrong_file_mode.name, self.valid_out_dir)
Пример #6
0
    def test_malformed_input_file(self):
        """Opening successfull, parsing successfull, but there is an empty-line!

        """
        with self.assertRaisesRegex(InputParserParseError,
                                    ("Input file-format looks wrong. Are there"
                                     " empty lines?")):
            parser = InputParser(self.malformed_f_empty_line.name,
                                 self.valid_out_dir)
Пример #7
0
    def test_invalid_input_urls(self):
        """Opening successfull, but parsing URL/filename fails.

        """
        with self.assertRaises(URLParsingError):
            parser = InputParser(self.malformed_f.name, self.valid_out_dir)
Пример #8
0
 def __init__(self):
     logging.getLogger().setLevel(logging.DEBUG)
     self.input_parser = InputParser(self.INPUT_ITEMS_FILE)
     self.ragial_job_generator = RagialJobGenerator(
         self.input_parser.inputs)
        Aim: Prove KB -> :math:`{\\alpha}`

        Code:
        * CLAUSES <- CONVERT_TO_CNF( KB + :math:`{\\alpha}` )
        * while EMPTY_RESOLVENT not in CLAUSES do
            * select two distinct clauses {c_i} and {c_j} in CLAUSES
            * compute a resolvent {r_ij} of {c_i} and {c_j}
            * CLAUSES <- CLAUSES + {r_ij}
        * end while
        * return satisfaction
        """
        pass


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-f',
                        '--file',
                        help='File name to parse and create problem base',
                        type=argparse.FileType('r'),
                        required=True)
    args = parser.parse_args()

    # Get filename
    _file = args.file

    # Parse problem state
    problem_state = InputParser.parse(_file)
    # Prove the theorem
    AutonomousTheoremProver(problem_state).prove()