Implements the swap-bytes functionality when building

        this is based on a copy of the Packet.self_build default method.
        The goal is to affect only the CAN layer data and keep
        under layers (e.g LinuxCooked) unchanged
3565
def post_build(self, pkt, pay):
        
        if conf.contribs['CAN']['swap-bytes']:
            return CAN.inv_endianness(pkt) + pay
        return pkt + pay
395671
def byte_order_option(default=BYTEORDER):
    

    def decorator(method):
        @wraps(method)
        def wrapper(*args, **kwargs):
            option = Option.byte_order.value
            kwargs[option] = kwargs.get(option, default)
            return method(*args, **kwargs)

        return wrapper

    return decorator
1354278
def processAndSetDefaults(self):
        
        # INPUT, OUTPUT, GIVEN + BUILDABLE DEPS
        if not self.input:
            raise ValueError(NO_INPUT_FILE)

        if not self.output:
            # Build directory must exist, right?
            if not self.build_directory:
                File()
            pass  # Can it be built? / reference self.output_format for this
        else:
            pass  # if it is not congruent with other info provided

        if not self.build_directory:
            pass  # Initialize it

        for dependency in self.given_dependencies:
            pass  # Check if the dependcy exists

        if self.output_format != self.output.getType():
            raise ValueError("")
        # Given dependencies must actually exist!
        # output_name must be at a lower extenion level than input_name
        # The build directory
        return
741525
def build_api_struct(self):
        
        data = super(AtlasChangeSource, self).build_api_struct()
        data.update({"action": self._action})
        return data
1277237
def to_bytes
      # set defaults
      self.sender ||= :pc
      self.receiver ||= 1

      bytes = []

      bytes.concat [0x00] * 5                               # start of command
      bytes.concat [0x01]                                   # <SOH>
      bytes.concat self.sender.to_bytes                     # Sender Address
      bytes.concat self.receiver.to_bytes                   # Reciver Address
      bytes.concat [0x02]                                   # <STX>
      bytes.concat string_to_ascii_bytes(command_code)      # Command Code
      bytes.concat command_payload_bytes                    # command specific payload
      bytes.concat [0x03]                                   # <ETX>
      bytes.concat generate_checksum_bytes(bytes[10..-1])   # Checksum bytes (4)
      bytes.concat [0x04]                                   # <EOT>

      bytes
    end
392770
def write_packet(self, payload):
        
        # Internal note: when you build packet manually and calls
        # _write_bytes() directly, you should set self._next_seq_id properly.
        data = pack_int24(len(payload)) + int2byte(self._next_seq_id) + payload
        self._write_bytes(data)
        self._next_seq_id = (self._next_seq_id + 1) % 256
1029002
def build(self, config=None):
        

        # If we are passed a config object, then rebuild that object instead of building a new lintconfig object from
        # scratch
        if not config:
            config = LintConfig()

        config._config_path = self._config_path

        # Set general options first as this might change the behavior or validity of the other options
        general_section = self._config_blueprint.get('general')
        if general_section:
            for option_name, option_value in general_section.items():
                config.set_general_option(option_name, option_value)

        for section_name, section_dict in self._config_blueprint.items():
            for option_name, option_value in section_dict.items():
                # Skip over the general section, as we've already done that above
                if section_name != "general":
                    config.set_rule_option(section_name, option_name, option_value)

        return config
1305145
function mkDefault(type) {
            if (typeof type === 'string')
                type = ProtoBuf.TYPES[type];
            if (typeof type.defaultValue === 'undefined')
                throw Error("default value for type "+type.name+" is not supported");
            if (type == ProtoBuf.TYPES["bytes"])
                return new ByteBuffer(0);
            return type.defaultValue;
        }
1264710
def _single_store(self, addr, offset, size, data):
        

        if offset == 0 and size == self.width:
            self._contents[addr] = data
        elif offset == 0:
            cur = self._single_load(addr, size, self.width - size)
            self._contents[addr] = data.concat(cur)
        elif offset + size == self.width:
            cur = self._single_load(addr, 0, offset)
            self._contents[addr] = cur.concat(data)
        else:
            cur = self._single_load(addr, 0, self.width)
            start = cur.get_bytes(0, offset)
            end = cur.get_bytes(offset+size, self.width-offset-size)
            self._contents[addr] = start.concat(data, end)
1035814
def init_argparser_build_dir(
            self, argparser, help=(
                'the build directory, where all sources will be copied to '
                'as part of the build process; if left unspecified, the '
                'default behavior is to create a new temporary directory '
                'that will be removed upon conclusion of the build; if '
                'specified, it must be an existing directory and all files '
                'for the build will be copied there instead, overwriting any '
                'existing file, with no cleanup done after.'
            )):
        

        argparser.add_argument(
            '--build-dir', default=None, dest=BUILD_DIR,
            metavar=metavar(BUILD_DIR), help=help,
        )
384669
def buildData(self, key, default=None):
        
        return self._buildData.get(nativestring(key), default)
497862
def _swap_bytes(data):
    """"""

    a, b = data[1::2], data[::2]
    data = bytearray().join(bytearray(x) for x in zip(a, b))
    if len(b) > len(a):
        data += b[-1:]
    return bytes(data)
728857
private void buildByteCopyStack(List<StackManipulation> stack, int iterations) throws NoSuchFieldException, NoSuchMethodException {
    final Method getByteMethod = Unsafe.class.getMethod("getByte", long.class);
    final Method putByteMethod = Unsafe.class.getMethod("putByte", Object.class, long.class, byte.class);

    buildCopyStack(stack, iterations, getByteMethod, putByteMethod, 1);
  }
1274370
def do_init_cached_fields(self):
        

        cls_name = self.__class__

        # Build the fields information
        if Packet.class_default_fields.get(cls_name, None) is None:
            self.prepare_cached_fields(self.fields_desc)

        # Use fields information from cache
        if not Packet.class_default_fields.get(cls_name, None) is None:
            self.default_fields = Packet.class_default_fields[cls_name]
            self.fieldtype = Packet.class_fieldtype[cls_name]
            self.packetfields = Packet.class_packetfields[cls_name]

            # Deepcopy default references
            for fname in Packet.class_default_fields_ref[cls_name]:
                value = copy.deepcopy(self.default_fields[fname])
                setattr(self, fname, value)
1309265
def build_from_packet(pkt):
        '''
        
        '''
        m = OpenflowMatch()
        for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
            for pktcls,field in pkttuple:
                if pkt.has_header(pktcls):
                    setattr(m, mf, getattr(pkt[pktcls], field))
                    continue
        return m
353867
def set_bytes_transferred(self, bytes_transferred):
        '''  '''
        _changed = False
        if bytes_transferred:
            _changed = (self._bytes_transferred != int(bytes_transferred))
            if _changed:
                self._bytes_transferred = int(bytes_transferred)
                logger.debug("(%s) BytesTransferred: %d" % (
                             self.session_id, self._bytes_transferred))
            if AsperaSession.PROGRESS_MSGS_SEND_ALL:
                return True
        return _changed
532124
def set_bytes_at_offset(self, offset, data):
        

        if not isinstance(data, bytes):
            raise TypeError('data should be of type: bytes')

        if 0 <= offset < len(self.__data__):
            self.__data__ = ( self.__data__[:offset] + data + self.__data__[offset+len(data):] )
        else:
            return False

        return True