Return a binary string containing the raw HID report descriptor.
489230
def getRawReportDescriptor(self):
        
        descriptor = _hidraw_report_descriptor()
        size = ctypes.c_uint()
        self._ioctl(_HIDIOCGRDESCSIZE, size, True)
        descriptor.size = size
        self._ioctl(_HIDIOCGRDESC, descriptor, True)
        return ''.join(chr(x) for x in descriptor.value[:size.value])
1270222
def get_sig_info(hdr):
    
    string = '%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|'
    siginfo = hdr.sprintf(string)
    if siginfo != '(none)':
        error = 0
        sigtype, sigdate, sigid = siginfo.split(',')
    else:
        error = 101
        sigtype = 'MD5'
        sigdate = 'None'
        sigid = 'None'

    infotuple = (sigtype, sigdate, sigid)
    return error, infotuple
740360
def hid(manufacturer: str, serial_number: str, model: str) -> str:
        """"""
        return Naming.url_word(manufacturer) + '-' + Naming.url_word(serial_number) + '-' + Naming.url_word(model)
1186040
def desc(self):
        """"""
        return '{0} (ID: {1}) - {2} - {3}'.format(
            self.name, self.device_id, self.type, self.status)
246288
def serialize_hdr(self):
        
        return struct.pack(self._PACK_HDR_STR, self.auth_type, self.auth_len)
834136
def get_description(self, with_size=True, with_index=True):
        

        desc = ''

        if with_size and self.size:
            desc += '{0} '.format(self.get_formatted_size())

        s = self.info.get('statfstype') or self.info.get('fsdescription') or '-'
        if with_index:
            desc += '{1}:{0}'.format(s, self.index)
        else:
            desc += s

        if self.info.get('label'):
            desc += ' {0}'.format(self.info.get('label'))

        if self.info.get('version'):  # NTFS
            desc += ' [{0}]'.format(self.info.get('version'))

        return desc
1024477
def create_binary_descriptor(streamer):
    

    trigger = 0
    if streamer.automatic:
        trigger = 1
    elif streamer.with_other is not None:
        trigger = (1 << 7) | streamer.with_other

    return struct.pack("<8sHBBBx", streamer.dest.encode(), streamer.selector.encode(), trigger, streamer.KnownFormats[streamer.format], streamer.KnownTypes[streamer.report_type])
1142106
def guid(valu=None):
    '''
    
    '''
    if valu is None:
        return binascii.hexlify(os.urandom(16)).decode('utf8')
    # Generate a "stable" guid from the given item
    byts = s_msgpack.en(valu)
    return hashlib.md5(byts).hexdigest()
599622
def description_of(file, name='stdin'):
    """"""
    u = UniversalDetector()
    for line in file:
        u.feed(line)
    u.close()
    result = u.result
    if result['encoding']:
        return '%s: %s with confidence %s' % (name,
                                              result['encoding'],
                                              result['confidence'])
    else:
        return '%s: no result' % name
1062158
def send(self, raw_data = None):
        
        if self.__report_kind != HidP_Output \
                and self.__report_kind != HidP_Feature:
            raise HIDError("Only for output or feature reports")
        #valid length
        if raw_data and (len(raw_data) != self.__raw_report_size):
            raise HIDError("Report size has to be %d elements (bytes)" \
                % self.__raw_report_size)
        #should be valid report id
        if raw_data and raw_data[0] != self.__report_id.value:
            #hint, raw_data should be a plain list of integer values
            raise HIDError("Not matching report id")
        #
        if self.__report_kind != HidP_Output and \
                self.__report_kind != HidP_Feature:
            raise HIDError("Can only send output or feature reports")
        #
        if not raw_data:
            # we'll construct the raw report
            self.__prepare_raw_data()
        elif not ( isinstance(raw_data, ctypes.Array) and \
                issubclass(raw_data._type_, c_ubyte) ):
            # pre-memory allocation for performance
            self.__alloc_raw_data(raw_data)
        #reference proper object
        raw_data = self.__raw_data
        if self.__report_kind == HidP_Output:
            return self.__hid_object.send_output_report(raw_data)
        elif self.__report_kind == HidP_Feature:
            return self.__hid_object.send_feature_report(raw_data)
        else:
            pass
1073850
def get_quality_report_string(self):
    """"""
    if not self._quality_distro:
      self.analyze_quality()
    ostr = ""
    for type in sorted(self._quality_distro.keys()):
      total = sum([ord(x)*self._quality_distro[type][x] for x in self._quality_distro[type]])
      cnt = sum([self._quality_distro[type][x] for x in self._quality_distro[type]])
      if cnt == 0: continue
      print 'type: '+type+' '+str(cnt)+' '+str(float(total)/float(cnt))
    return ostr
420585
def description(self):
        

        if 'metrics' in self.raw:
            metrics = self.raw['metrics']
            head = metrics[0:-1] or metrics[0:1]
            text = ", ".join(head)
            if len(metrics) > 1:
                tail = metrics[-1]
                text = text + " and " + tail
        else:
            text = 'n/a'

        return text
1323764
def Description(self):
        """"""
        descr = " ".join((self.getId(), self.aq_parent.Title()))
        return safe_unicode(descr).encode('utf-8')
672966
def get_dump(self, fmap='', with_stats=False):
        

        length = ctypes.c_ulong()
        sarr = ctypes.POINTER(ctypes.c_char_p)()
        if self.feature_names is not None and fmap == '':
            flen = int(len(self.feature_names))

            fname = from_pystr_to_cstr(self.feature_names)

            if self.feature_types is None:
                # use quantitative as default
                # {'q': quantitative, 'i': indicator}
                ftype = from_pystr_to_cstr(['q'] * flen)
            else:
                ftype = from_pystr_to_cstr(self.feature_types)
            _check_call(_LIB.XGBoosterDumpModelWithFeatures(self.handle,
                                                            flen,
                                                            fname,
                                                            ftype,
                                                            int(with_stats),
                                                            ctypes.byref(length),
                                                            ctypes.byref(sarr)))
        else:
            if fmap != '' and not os.path.exists(fmap):
                raise ValueError("No such file: {0}".format(fmap))
            _check_call(_LIB.XGBoosterDumpModel(self.handle,
                                                c_str(fmap),
                                                int(with_stats),
                                                ctypes.byref(length),
                                                ctypes.byref(sarr)))
        res = from_cstr_to_pystr(sarr, length)
        return res
1161725
private static String getDecodedStr(byte[] decBytes) {

		// prepare StringBuilder with capacity being the smallest power of 2
		// greater than decBytes.length*6
		int n = decBytes.length * 6;
		int capacity = leastPowerOf2GreaterThanOrEqualTo(n);
		StringBuilder decStr = new StringBuilder(capacity);

		for (int i = 0; i < decBytes.length; i++) {

			int decByte = decBytes[i];
			String bitStr = Integer.toBinaryString(decByte);

			int padding = Math.max(0, 6 - bitStr.length());

			for (int j = 0; j < padding; j++) {
				decStr.append('0');
			}

			for (int j = 0; j < 6 - padding; j++) {
				decStr.append(bitStr.charAt(j));
			}
		}
		return decStr.toString();
	}
807162
def _get_raw_data(self, is_valid_key, data_key):
        

        result = None

        if self._read_imu():
            data = self._imu.getIMUData()
            if data[is_valid_key]:
                raw = data[data_key]
                result = {
                    'x': raw[0],
                    'y': raw[1],
                    'z': raw[2]
                }

        return result
311081
def getFeatureReport(self, report_num=0, length=63):
        
        length += 1
        buf = bytearray(length)
        buf[0] = report_num
        self._ioctl(
            _HIDIOCGFEATURE(length),
            (ctypes.c_char * length).from_buffer(buf),
            True,
        )
        return buf