def argument_parser():
    # Helper for argparse to match file and/or directory
    def helper_file_or_directory(parser):
        def _inner(path):
            # First, resolve
            path = os.path.realpath(path)

            # Then check path
            if not os.path.exists(path):
                parser.error("The file or directory '%s' does not exist" % path)
            else:
                if os.path.isdir(path):
                    return (True, path)
                else:
                    return (False, open(path, "rb"))
        return _inner

    # Helper for argparse to match file
    def helper_file(parser):
        def _inner(file):
            # First, resolve
            path = os.path.realpath(file)

            # Then check path
            if not os.path.exists(file) or os.path.isdir(file):
                parser.error(path % "The file '%s' does not exist")

            # Done
            return file
        return _inner

    # Create parser
    parser = argparse.ArgumentParser(description='Enroll, match and visualize 3D faces')

    # Add the arguments
    parser.add_argument('-d', '--database', default='database.db', help='path to cache file')
    parser.add_argument('-p', '--parameters', default='K=12,N=67', action='store', help='algorithm parameters, comma seperated')

    group = parser.add_argument_group(title="Face management")
    group.add_argument('--authenticate', type=helper_file(parser), help='authenticate a face to enrolled faces')
    group.add_argument('--enroll', type=helper_file_or_directory(parser),  help='enroll face from file or directory')
    group.add_argument('--person-id', action='store', help='number or name identifing person')
    group.add_argument('--auto-id', action='store_true', help='derrive person identifier from filename')
    group.add_argument('--reevaluate', action='store_true', help='reevaluation enrolled faces, but do not save')

    group = parser.add_argument_group(title="Visualization")
    group.add_argument('--depth-map', action='store', help='generate a depth map of enrolled faces')
    group.add_argument('--feature-map', action='store', help='generate a feature map of enrolled faces')
    group.add_argument('--similarity-matrix', action='store', help='generate a similarity matrix of all implemented methods')
    group.add_argument('--roc-curve', action='store', help='generate a ROC curve of all implemented methods')
    group.add_argument('--draw-key-points', action='store_true', help='include key points on depth map')

    # Done
    return parser.parse_args(), parser

# Application main
dataset/ETHPy150Open basilfx/Course-Face3D/Face3D.py/argument_parser/swapped operands of `%`