Example #1
0
def init(args):
    fp = FileParser(log_parsers=[HuaweiLogParser, CheckPointLogParser],
                    max_processes=args.max_processes,
                    max_threads=args.max_threads,
                    parse_chunk_size=args.chunk_size,
                    delete_intermediate_result_dirs=(
                        not args.preserve_intermediate_results))
    fp.parse_file(src_file_path=args.src_file_path,
                  out_dir_path=args.out_dir_path)
Example #2
0
def pacman(input_file):
    """
    Input:
        1. input_file (String) =
            contains the name of a text file you need to read that is in the same directory,
            includes the ".txt" extension (ie. "input.txt")
    Outputs:
        1. final_pos_x (int) = final x location of Pacman
        2. final_pos_y (int) = final y location of Pacman
        3. coins_collected (int) =
            the number of coins that have been collected by Pacman across all movements
    """
    try:
        lines_of_file: List[str] = FileParser().parse(path_to_file=input_file)
        config_manager: ConfigManager = ConfigManager(inputs=lines_of_file)
        board: Board = Board(config=config_manager)
        for move in config_manager.moves:
            if board.allows(move):
                board.make_move(move)
        return (
            board.pacman_x,
            board.pacman_y,
            board.number_of_coins_collected,
        )
    except (IndexError, ValueError):
        return -1, -1, 0
Example #3
0
 def test_three_line(self):
     lines = FileParser().parse(
         os.path.join("tests", "resources", "three_lines.txt")
     )
     self.assertEqual(type(lines), list)
     self.assertEqual(len(lines), 3)
     self.assertEqual(lines, ["1line", "2line", "3line"])
Example #4
0
def main():
    # Instatiate objects
    twitter = TwitterSearch()
    queries = FileParser("./queries.txt").queries
    exporter = Exporter('results')
    amount = 250

    # Start time
    tic = time.perf_counter()

    # Search
    twitter.search(queries, amount)
    results = twitter.results

    # End time
    toc = time.perf_counter()
    print(
        f'Scraped {len(queries) * amount} tweets in: {toc - tic:0.2f} seconds')

    # Export results
    exporter.export(results)
Example #5
0
 def test_with_lines(self):
     lines = FileParser().parse(os.path.join("tests", "resources", "generic.txt"))
     expected = [
         "10 10",
         "1 5",
         "NNNESENNWESESSWSSENNENNEEEESESSWWSWSESS",
         "1 7",
         "1 8",
         "2 5",
         "3 4",
         "3 5",
         "3 6",
         "3 7",
         "5 6",
         "5 7",
         "7 3",
         "8 4",
         "9 4",
     ]
     self.assertEqual(type(lines), list)
     self.assertEqual(lines, expected)
Example #6
0
 def test_empty(self):
     lines = FileParser().parse(os.path.join("tests", "resources", "empty.txt"))
     expected = []
     self.assertEqual(type(lines), list)
     self.assertEqual(lines, expected)
Example #7
0
 def test_one_line(self):
     lines = FileParser().parse(os.path.join("tests", "resources", "one_line.txt"))
     self.assertEqual(type(lines), list)
     self.assertEqual(len(lines), 1)
     self.assertEqual(lines, ["1line"])