Пример #1
0
 def test_extract_scripts(self, patch_open):
     parser = CatParser(out_path='some/out/path')
     parser.cat_files_iterator = MagicMock(return_value=self.CAT_FILES)
     parser.extract_file = MagicMock()
     parser.extract(cat_filename='path/to/catfile.cat')
     parser.cat_files_iterator.assert_called_once_with(
         'path/to/catfile.cat')
     patch_open.assert_called_once_with('path/to/catfile.dat', 'rb')
     parser.extract_file.assert_called_once_with(
         patch_open.return_value.__enter__.return_value,
         'some/out/path/some path/filename1.xml', 0, 101)
Пример #2
0
 def test_extract_all_no_sig(self, patch_open):
     parser = CatParser(out_path='some/out/path', scripts_only=False)
     parser.cat_files_iterator = MagicMock(return_value=self.CAT_FILES)
     parser.extract_file = MagicMock()
     parser.extract(cat_filename='path/to/catfile.cat')
     parser.cat_files_iterator.assert_called_once_with(
         'path/to/catfile.cat')
     patch_open.assert_called_once_with('path/to/catfile.dat', 'rb')
     self.assertEqual(parser.extract_file.call_count, 2)
     parser.extract_file.assert_has_calls([
         call(patch_open.return_value.__enter__.return_value,
              'some/out/path/some path/filename1.xml', 0, 101),
         call(patch_open.return_value.__enter__.return_value,
              'some/out/path/some path/filename2.xmf', 311, 300),
     ])
Пример #3
0
def cmd_extract_x4(args):
    setup_logging(args.verbosity)
    config = get_config()

    if args.file:
        out_path = '{}/custom'.format(config.PWD)
    else:
        out_path = config.SRC

    parser = CatParser(
        out_path=out_path,
        scripts_only=args.scripts,
        signatures=args.signatures,
    )

    if args.file:
        parser.extract(cat_filename=args.file)

    else:
        method = parser.list if args.list else parser.extract
        cats = sorted(glob.iglob(f'{config.X4}/*.cat'))
        for cat in cats:
            method(cat_filename=cat)