Alter data in dm format devices
969223
def alter(data, system):
    """"""
    device = data[0]
    action = data[1]
    if data[2] == '*':
        data[2] = '.*'
    regex = re.compile(data[2])
    prop = data[3]
    value = float(data[4])
    if action == 'MUL':
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] *= value
    elif action == 'REP':
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] = value
    elif action == 'DIV':
        if not value:
            return
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] /= value
    elif action == 'SUM':
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] += value
    elif action == 'SUB':
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] -= value
    elif action == 'POW':
        for item in range(system.__dict__[device].n):
            if regex.search(system.__dict__[device].name[item]):
                system.__dict__[device].__dict__[prop][item] **= value
    else:
        print('ALTER action <%s> is not defined', action)
663414
def alter_db(name, character_set=None, collate=None, **connection_args):
    '''
    
    '''
    dbc = _connect(**connection_args)
    if dbc is None:
        return []
    cur = dbc.cursor()
    existing = db_get(name, **connection_args)
    qry = 'ALTER DATABASE `{0}` CHARACTER SET {1} COLLATE {2};'.format(
        name.replace('%', r'\%').replace('_', r'\_'),
        character_set or existing.get('character_set'),
        collate or existing.get('collate'))
    args = {}
    _execute(cur, qry, args)
1025452
def change_digital(self, pin_nr, value):
        
        if not self._board:
            return
        with self._lock:
            self._act_digital[pin_nr].pin.write(value)
137122
def _match_device(self):
        """"""
        for device in self.manager.all_devices:
            if (device.get_char_device_path() ==
                    self._character_device_path):
                self.device = device
                device.leds.append(self)
                break
72866
def set_conversion(self, idx):
        

        # First, determine the name
        if self.conv_begin:
            name = self.format[self.conv_begin:idx]
        else:
            name = self.format[idx]

        # Next, add the status code modifiers, as needed
        if self.codes:
            self.modifier.set_codes(self.codes, self.reject)

        # Append the conversion to the format
        self.fmt.append_conv(self.fmt._get_conversion(name, self.modifier))

        # Clear the conversion data
        self.param_begin = None
        self.conv_begin = None
        self.modifier = None
        self.codes = []
        self.reject = False
        self.code_last = False
906471
def _format_info(data):
    '''
    
    '''
    return {'gid': data.pw_gid,
            'groups': list_groups(data.pw_name),
            'home': data.pw_dir,
            'name': data.pw_name,
            'shell': data.pw_shell,
            'uid': data.pw_uid,
            'fullname': data.pw_gecos}
490064
def _ldp_id_adjustlen(pkt, x):
    """"""
    f, v = pkt.getfield_and_val('id')
    return len(_LLDPidField.i2m(f, pkt, v)) + 1
181686
def modify(dn, attributes)
      if attributes.kind_of?(Hash)
        attributes = normalize_attributes(attributes)
      else
        attributes = attributes.map do |(action, key, values)|
          [action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact]
        end
      end
      log_dispatch(:modify, dn, attributes)
      adapter.modify(dn, attributes) unless attributes.empty?
    end
515414
def _update_device_from_htm(self, device):
        
        htm_target_id, daplink_info = self._read_htm_ids(device["mount_point"])
        if htm_target_id:
            device["target_id"] = htm_target_id
        else:
            logger.debug(
                "Could not read htm on from usb id %s. Falling back to usb id",
                device["target_id_usb_id"],
            )
            device["target_id"] = device["target_id_usb_id"]
        device["target_id_mbed_htm"] = htm_target_id
444076
def modify_init(uid, data_dic):
        '''
        
        '''
        postinfo = MPost.get_by_uid(uid)
        entry = TabPost.update(
            time_update=tools.timestamp(),
            date=datetime.now(),
            kind=data_dic['kind'] if 'kind' in data_dic else postinfo.kind,
            keywords=data_dic['keywords'] if 'keywords' in data_dic else postinfo.keywords,
        ).where(TabPost.uid == uid)
        entry.execute()
        return uid
630172
def to_dhm_format(days=0, hours=0, minutes=0, seconds=0, milliseconds=0):
    
    minutes = to_minutes(days=days, hours=hours, minutes=minutes,
                         seconds=seconds, milliseconds=milliseconds)
    delta = timedelta(minutes=int(round(minutes)))
    d = delta.days
    h = delta.seconds // 3600
    m = (delta.seconds // 60) % 60
    m = m and "{}m ".format(str(m)) or ""
    d = d and "{}d ".format(str(d)) or ""
    if m and d:
        h = "{}h ".format(str(h))
    else:
        h = h and "{}h ".format(str(h)) or ""
    return "".join([d, h, m]).strip()
410012
private void setDataSegmentInternal(final String iName) {
    final int dataId = storage.getDataSegmentIdByName(iName);
    config.setDataSegmentId(dataId);
    storage.getConfiguration().update();
  }
164846
def edit(self, resource): # pylint: disable=invalid-name,redefined-builtin
        
        schema = AttachmentSchema(exclude=('id', 'created', 'updated', 'size', 'path', 'device_id'))
        json = self.service.encode(schema, resource)

        schema = AttachmentSchema()
        resp = self.service.edit(self._base(resource.device_id), resource.id, json)
        return self.service.decode(schema, resp)
1099653
def rdn_to_dn(changes: Changeset, name: str, base_dn: str) -> Changeset:
    
    dn = changes.get_value_as_single('dn')
    if dn is not None:
        return changes

    value = changes.get_value_as_single(name)
    if value is None:
        raise tldap.exceptions.ValidationError(
            "Cannot use %s in dn as it is None" % name)
    if isinstance(value, list):
        raise tldap.exceptions.ValidationError(
            "Cannot use %s in dn as it is a list" % name)

    assert base_dn is not None

    split_base = str2dn(base_dn)
    split_new_dn = [[(name, value, 1)]] + split_base

    new_dn = dn2str(split_new_dn)

    return changes.set('dn', new_dn)
1142507
def imu_changed(self, val):
        """"""
        self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val)
        self.update_data_display(self.get_current_data())
255855
def dre_dm(self, pars):
        
        """
        self._set_parameters(pars)
        terms = self.num / self.denom
        result = - self.sigmai * terms

        return result
761574
def update(self, data):
        """"""
        if data is None:
            for device in self.devices:
                device.clear_info()
        else:
            for device, device_info in zip(self.devices, data):
                device.device_info = device_info
                self.connection.log("Device information updated -> [{}]".format(device))