Get the reconstructed code as bytearray

        :rtype: bytearray
433907
def get_raw(self):
        
        code_raw = self.code.get_raw()
        self.insns_size = (len(code_raw) // 2) + (len(code_raw) % 2)

        buff = bytearray()
        buff += pack("<H", self.registers_size) + \
                pack("<H", self.ins_size) + \
                pack("<H", self.outs_size) + \
                pack("<H", self.tries_size) + \
                pack("<I", self.debug_info_off) + \
                pack("<I", self.insns_size) + \
                code_raw

        if self.tries_size > 0:
            if (self.insns_size % 2 == 1):
                buff += pack("<H", self.padding)

            for i in self.tries:
                buff += i.get_raw()
            buff += self.handlers.get_raw()

        return buff
418478
def from_byte_array(cls, bytes_):
        
        runs = cls._length_run_coding.parse(bytes_)
        pixels = (run.pixels for run in runs.data)
        data = "".join(itertools.chain.from_iterable(pixels))
        return cls(data)
758251
def clean_bytecode_extension(filename):
    
    path, extension = os.path.splitext(filename)
    if extension == '.pyc':
        filename = '%s.py' % path
    return filename
335010
def _ostaunicode(src):
    # type: (str) -> bytes
    '''
    
    '''
    if have_py_3:
        bytename = src
    else:
        bytename = src.decode('utf-8')  # type: ignore

    try:
        enc = bytename.encode('latin-1')
        encbyte = b'\x08'
    except (UnicodeEncodeError, UnicodeDecodeError):
        enc = bytename.encode('utf-16_be')
        encbyte = b'\x10'
    return encbyte + enc
75639
def unescape(s):
    """"""
    s = bytearray(s)
    i = 0
    while i < len(s):
        if s[i] == ord('%'):
            hex_bytes = bytes(s[i+1:i+3])
            value = int(hex_bytes.decode('ascii'), 16)
            s[i:i+3] = [value]
        i += 1
    return bytes(s)
269917
def get_raw(self):
        
        buff = bytearray()
        buff += writesleb128(self.size)
        for i in self.handlers:
            buff += i.get_raw()

        if self.size <= 0:
            buff += writeuleb128(self.catch_all_addr)

        return buff
1038368
def extract(binary):
    '''
    
    '''
    if len(binary) <= 8:
        raise Exception("Binary pyc must be greater than 8 bytes (got %i)" % len(binary))
    
    magic = binary[:4]
    MAGIC = get_magic()
    
    if magic != MAGIC:
        raise Exception("Python version mismatch (%r != %r) Is this a pyc file?" % (magic, MAGIC))
    
    modtime = time.asctime(time.localtime(struct.unpack('i', binary[4:8])[0]))

    code = marshal.loads(binary[8:])
    
    return modtime, code
1109426
def from_bytes(self, raw):
        ''''''
        if len(raw) < Arp._MINLEN:
            raise NotEnoughDataError("Not enough bytes ({}) to reconstruct an Arp object".format(len(raw)))
        fields = struct.unpack(Arp._PACKFMT, raw[:Arp._MINLEN])
        try:
            self._hwtype = ArpHwType(fields[0])
            self._prototype = EtherType(fields[1])
            self._hwaddrlen = fields[2]
            self._protoaddrlen = fields[3]
            self.operation = ArpOperation(fields[4])
            self.senderhwaddr = EthAddr(fields[5])
            self.senderprotoaddr = IPAddr(fields[6])
            self.targethwaddr = EthAddr(fields[7])
            self.targetprotoaddr = IPAddr(fields[8])
        except Exception as e:
            raise Exception("Error constructing Arp packet object from raw bytes: {}".format(str(e)))
        return raw[Arp._MINLEN:]
1306397
def encode_contents(self):
        

        if self.variable_size:
            resp_length = 1
        else:
            resp_length = self.fixed_response_size << 1

        header = struct.pack("<HBB", self.rpc_id, self.address, resp_length)
        return bytearray(header) + self.payload
1173106
private byte[] fetchDecoderOutput() {
        final CompositeByteBuf decoded = Unpooled.compositeBuffer();
        for (;;) {
            final ByteBuf buf = decoder.readInbound();
            if (buf == null) {
                break;
            }
            if (!buf.isReadable()) {
                buf.release();
                continue;
            }
            decoded.addComponent(true, buf);
        }
        final byte[] ret = ByteBufUtil.getBytes(decoded);
        decoded.release();
        return ret;
    }
1026298
def decompile(
        bytecode_version, co, out=None, showasm=None, showast=False,
        timestamp=None, showgrammar=False, code_objects={},
        source_size=None, is_pypy=None, magic_int=None,
        mapstream=None, do_fragments=False):
    
    if bytecode_version is None:
        bytecode_version = sysinfo2float()

    # store final output stream for case of error
    real_out = out or sys.stdout

    def write(s):
        s += '\n'
        real_out.write(s)

    assert iscode(co)

    co_pypy_str = 'PyPy ' if is_pypy else ''
    run_pypy_str = 'PyPy ' if IS_PYPY else ''
    sys_version_lines = sys.version.split('\n')
    write('# uncompyle6 version %s\n'
          '# %sPython bytecode %s%s\n# Decompiled from: %sPython %s' %
          (VERSION, co_pypy_str, bytecode_version,
               " (%s)" % str(magic_int) if magic_int else "",
          run_pypy_str, '\n# '.join(sys_version_lines)))
    if co.co_filename:
        write('# Embedded file name: %s' % co.co_filename,)
    if timestamp:
        write('# Compiled at: %s' % datetime.datetime.fromtimestamp(timestamp))
    if source_size:
        write('# Size of source mod 2**32: %d bytes' % source_size)

    debug_opts = {
        'asm': showasm,
        'ast': showast,
        'grammar': showgrammar
    }

    try:
        if mapstream:
            if isinstance(mapstream, str):
                mapstream = _get_outstream(mapstream)

            deparsed = deparse_code_with_map(bytecode_version, co, out, showasm, showast,
                                             showgrammar,
                                             code_objects = code_objects,
                                             is_pypy = is_pypy,
                                             )
            header_count = 3+len(sys_version_lines)
            linemap = [(line_no, deparsed.source_linemap[line_no]+header_count)
                        for line_no in
                        sorted(deparsed.source_linemap.keys())]
            mapstream.write("\n\n# %s\n" % linemap)
        else:
            if do_fragments:
                deparse_fn = code_deparse_fragments
            else:
                deparse_fn = code_deparse
            deparsed = deparse_fn(co, out, bytecode_version,
                                  debug_opts = debug_opts,
                                  is_pypy=is_pypy)
            pass
        return deparsed
    except pysource.SourceWalkerError as e:
        # deparsing failed
        raise pysource.SourceWalkerError(str(e))
1182317
def get_code(self):
        
        stub = []
        bases = ("(" + ", ".join(self.bases) + ")") if len(self.bases) > 0 else ""
        slots = {"n": self.name, "b": bases}
        if (len(self.children) == 0) and (len(self.variables) == 0):
            stub.append("class %(n)s%(b)s: ..." % slots)
        else:
            stub.append("class %(n)s%(b)s:" % slots)
            super_code = super().get_code() if PY3 else StubNode.get_code(self)
            for line in super_code:
                stub.append(INDENT + line)
        return stub
1095935
def object_to_bytes(obj):
    
    if isinstance(obj, str):
        return bytearray(obj, "UTF-8")
    elif isinstance(obj, bool):
        return bytearray()
    elif isinstance(obj, int):
        return pack("<L", obj)
    elif obj is None:
        return bytearray()
    elif isinstance(obj, bytearray):
        return obj
    else:
        return obj.get_raw()
381232
def _decode(self, obj):
        
        if self.decode_responses and isinstance(obj, bytes):
            try:
                return obj.decode(self.encoding)
            except UnicodeDecodeError:
                return obj
        return obj
1165354
def to_pycode(self):
        
        consts = self.consts
        names = self.names
        varnames = self.varnames
        freevars = self.freevars
        cellvars = self.cellvars
        bc = bytearray()
        for instr in self.instrs:
            bc.append(instr.opcode)  # Write the opcode byte.
            if isinstance(instr, LOAD_CONST):
                # Resolve the constant index.
                bc.extend(consts.index(instr.arg).to_bytes(argsize, 'little'))
            elif instr.uses_name:
                # Resolve the name index.
                bc.extend(names.index(instr.arg).to_bytes(argsize, 'little'))
            elif instr.uses_varname:
                # Resolve the local variable index.
                bc.extend(
                    varnames.index(instr.arg).to_bytes(argsize, 'little'),
                )
            elif instr.uses_free:
                # uses_free is really "uses freevars **or** cellvars".
                try:
                    # look for the name in cellvars
                    bc.extend(
                        cellvars.index(instr.arg).to_bytes(argsize, 'little'),
                    )
                except ValueError:
                    # fall back to freevars, incrementing the length of
                    # cellvars.
                    bc.extend(
                        (freevars.index(instr.arg) + len(cellvars)).to_bytes(
                            argsize,
                            'little',
                        )
                    )
            elif instr.absjmp:
                # Resolve the absolute jump target.
                bc.extend(
                    self.bytecode_offset(instr.arg).to_bytes(
                        argsize,
                        'little',
                    ),
                )
            elif instr.reljmp:
                # Resolve the relative jump target.
                # We do this by subtracting the curren't instructions's
                # sparse index from the sparse index of the argument.
                # We then subtract argsize - 1 to account for the bytes the
                # current instruction takes up.
                bytecode_offset = self.bytecode_offset
                bc.extend((
                    bytecode_offset(instr.arg) -
                    bytecode_offset(instr) -
                    argsize -
                    1
                ).to_bytes(argsize, 'little',))
            elif instr.have_arg:
                # Write any other arg here.
                bc.extend(instr.arg.to_bytes(argsize, 'little'))
            elif WORDCODE:
                # with wordcode, all instructions are padded to 2 bytes
                bc.append(0)

        return CodeType(
            self.argcount,
            self.kwonlyargcount,
            len(varnames),
            self.stacksize,
            self.py_flags,
            bytes(bc),
            consts,
            names,
            varnames,
            self.filename,
            self.name,
            self.firstlineno,
            self.py_lnotab,
            freevars,
            cellvars,
        )
934000
def _byteify(data):
    """"""

    # Unicode
    if isinstance(data, six.text_type):
        return data.encode("utf-8")

    # Members of lists
    if isinstance(data, list):
        return [_byteify(item) for item in data]

    # Members of dicts
    if isinstance(data, dict):
        return {
            _byteify(key): _byteify(value) for key, value in data.items()
        }

    # Anything else, return the original form
    return data
93466
def get_code(self):
        """"""

        result = ''
        if self._data_struct is not None:
            result = self._data_struct[KEY_CODE]
        return result