How to use the vcard.vcard_errors.UsageError function in vcard

To help you get started, we’ve selected a few vcard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github l0b0 / vcard / vcard / vcard.py View on Github external
def parse_arguments(arguments):
    argument_parser = argparse.ArgumentParser()
    argument_parser.add_argument('--verbose', default=False, action='store_true', help=VERBOSE_OPTION_HELP)
    argument_parser.add_argument('paths', metavar='path', nargs='+', help=PATH_ARGUMENT_HELP)
    try:
        parsed_arguments = argument_parser.parse_args(args=arguments)
    except argparse.ArgumentError as error:
        raise UsageError(str(error))
    return parsed_arguments
github l0b0 / vcard / vcard / vcard.py View on Github external
def main():
    try:
        arguments = parse_arguments(sys.argv[1:])
    except UsageError as error:
        sys.stderr.write('{0}\n'.format(str(error)))
        return 2

    return_code = 0
    for filename in arguments.paths:
        result = VcardValidator(filename, arguments.verbose).result
        if result is not None:
            print(result)
            return_code = 1

    return return_code