How to use the cbor2.CBORDecoder function in cbor2

To help you get started, we’ve selected a few cbor2 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 DNS-OARC / dnscap / contrib / cdsdump.py View on Github external
(options, args) = parser.parse_args()

    if options.verbose == True:
        log.setLevel(logging.DEBUG)
        log.debug('argv: %s', sys.argv)
        log.debug('options: %s', options)
        log.debug('args: %s', args)
    else:
        log.setLevel(logging.WARNING)

    if not args:
        parser.print_usage()
        exit(1)

    decoder = CBORDecoder()
    # if https://github.com/agronholm/cbor2/pull/5 is not merged/released yet
    if 0 not in decoder.special_decoders:
        decoder.special_decoders[0] = lambda self, fp, shareable_index=None: SimpleValue(0)
        decoder.special_decoders[1] = lambda self, fp, shareable_index=None: SimpleValue(1)
        decoder.special_decoders[2] = lambda self, fp, shareable_index=None: SimpleValue(2)
        decoder.special_decoders[3] = lambda self, fp, shareable_index=None: SimpleValue(3)
        decoder.special_decoders[4] = lambda self, fp, shareable_index=None: SimpleValue(4)
        decoder.special_decoders[5] = lambda self, fp, shareable_index=None: SimpleValue(5)
        decoder.special_decoders[6] = lambda self, fp, shareable_index=None: SimpleValue(6)
        decoder.special_decoders[7] = lambda self, fp, shareable_index=None: SimpleValue(7)
        decoder.special_decoders[8] = lambda self, fp, shareable_index=None: SimpleValue(8)
        decoder.special_decoders[9] = lambda self, fp, shareable_index=None: SimpleValue(9)
        decoder.special_decoders[10] = lambda self, fp, shareable_index=None: SimpleValue(10)
        decoder.special_decoders[11] = lambda self, fp, shareable_index=None: SimpleValue(11)
        decoder.special_decoders[12] = lambda self, fp, shareable_index=None: SimpleValue(12)
        decoder.special_decoders[13] = lambda self, fp, shareable_index=None: SimpleValue(13)
github DNS-OARC / dnscap / contrib / cdsidxchk.py View on Github external
(options, args) = parser.parse_args()

    if options.verbose == True:
        log.setLevel(logging.DEBUG)
        log.debug('argv: %s', sys.argv)
        log.debug('options: %s', options)
        log.debug('args: %s', args)
    else:
        log.setLevel(logging.WARNING)

    if not args:
        parser.print_usage()
        exit(1)

    decoder = CBORDecoder()
    # if https://github.com/agronholm/cbor2/pull/5 is not merged/released yet
    if 0 not in decoder.special_decoders:
        decoder.special_decoders[0] = lambda self, fp, shareable_index=None: SimpleValue(0)
        decoder.special_decoders[1] = lambda self, fp, shareable_index=None: SimpleValue(1)
        decoder.special_decoders[2] = lambda self, fp, shareable_index=None: SimpleValue(2)
        decoder.special_decoders[3] = lambda self, fp, shareable_index=None: SimpleValue(3)
        decoder.special_decoders[4] = lambda self, fp, shareable_index=None: SimpleValue(4)
        decoder.special_decoders[5] = lambda self, fp, shareable_index=None: SimpleValue(5)
        decoder.special_decoders[6] = lambda self, fp, shareable_index=None: SimpleValue(6)
        decoder.special_decoders[7] = lambda self, fp, shareable_index=None: SimpleValue(7)
        decoder.special_decoders[8] = lambda self, fp, shareable_index=None: SimpleValue(8)
        decoder.special_decoders[9] = lambda self, fp, shareable_index=None: SimpleValue(9)
        decoder.special_decoders[10] = lambda self, fp, shareable_index=None: SimpleValue(10)
        decoder.special_decoders[11] = lambda self, fp, shareable_index=None: SimpleValue(11)
        decoder.special_decoders[12] = lambda self, fp, shareable_index=None: SimpleValue(12)
        decoder.special_decoders[13] = lambda self, fp, shareable_index=None: SimpleValue(13)