コード例 #1
0
ファイル: test_libmat2.py プロジェクト: atenart/mat2
    def test_deps(self):
        try:
            ret = check_dependencies()
        except RuntimeError:
            return  # this happens if not every dependency is installed

        for value in ret.values():
            self.assertTrue(value)
コード例 #2
0
ファイル: mat2.py プロジェクト: Anish-M-code/Metadata-Remover
def main() -> int:
    arg_parser = create_arg_parser()
    args = arg_parser.parse_args()

    if args.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    if not args.files:
        if args.list:
            show_parsers()
            return 0
        elif args.check_dependencies:
            print("Dependencies for mat2 %s:" % __version__)
            for key, value in sorted(check_dependencies().items()):
                print('- %s: %s %s' %
                      (key, 'yes' if value['found'] else 'no',
                       '(optional)' if not value['required'] else ''))
        else:
            arg_parser.print_help()
        return 0

    elif args.show:
        for f in __get_files_recursively(args.files):
            show_meta(f, args.sandbox)
        return 0

    else:
        inplace = args.inplace
        policy = UnknownMemberPolicy(args.unknown_members)
        if policy == UnknownMemberPolicy.KEEP:
            logging.warning(
                'Keeping unknown member files may leak metadata in the resulting file!'
            )

        no_failure = True
        files = __get_files_recursively(args.files)
        # We have to use Processes instead of Threads, since
        # we're using tempfile.mkdtemp, which isn't thread-safe.
        with concurrent.futures.ProcessPoolExecutor() as executor:
            futures = list()
            for f in files:
                future = executor.submit(clean_meta, f, args.lightweight,
                                         inplace, args.sandbox, policy)
                futures.append(future)
            for future in concurrent.futures.as_completed(futures):
                no_failure &= future.result()
        return 0 if no_failure is True else -1
コード例 #3
0
ファイル: test_libmat2.py プロジェクト: tpet/mat2
 def test_deps(self):
     ret = check_dependencies()
     for key, value in ret.items():
         if value['required']:
             self.assertTrue(value['found'],
                             "The value for %s is False" % key)