guess the backend from a given identifier string for the device
770059
def guess_backend(identifier):
    
    if identifier.startswith('usb://') or identifier.startswith('0x'):
        return 'pyusb'
    elif identifier.startswith('file://') or identifier.startswith('/dev/usb/') or identifier.startswith('lp'):
        return 'linux_kernel'
    elif identifier.startswith('tcp://'):
        return 'network'
    else:
        raise ValueError('Cannot guess backend for given identifier: %s' % identifier)
792684
def get(self, dev_id):
        """"""
        path = '/'.join(['device', dev_id])
        return self.rachio.get(path)
381002
def device_id(self):
        
        if self.is_block:
            for filename in self._P.Block.Symlinks:
                parts = decode_ay(filename).split('/')
                if parts[-2] == 'by-id':
                    return parts[-1]
        elif self.is_drive:
            return self._assocdrive._P.Drive.Id
        return ''
1185542
def device_id_from_name(device_name, nodes):
        
        device_id = None
        for node in nodes:
            if device_name == node['properties']['name']:
                device_id = node['id']
                break
        return device_id
915399
def identifier(self):
        
        if self.primary_key not in self._data:
            return 'Unknown'
        return str(self._data[self.primary_key])
64806
def getRnaQuantificationById(self, rnaQuantificationId):
        
        sql = ("SELECT * FROM RnaQuantification WHERE id = ?")
        query = self._dbconn.execute(sql, (rnaQuantificationId,))
        try:
            return sqlite_backend.fetchOne(query)
        except AttributeError:
            raise exceptions.RnaQuantificationNotFoundException(
                rnaQuantificationId)
176609
def get_name(self, origin=None):
        """"""

        token = self.get()
        if not token.is_identifier():
            raise dns.exception.SyntaxError('expecting an identifier')
        return dns.name.from_text(token.value, origin)
94057
def get_backend(backend):
    """"""
    if backend == "random":
        backends = list_backends()
        random.shuffle(backends)
        return backends[0]

    return backend
741984
function getUniqueIdentifier( root, libs, com ) {
  var id = root.attribs.id || ( com.name + ID++ );
  com.attr.id = id;
}
450039
def fromString(self, inString):
        
        box = parseString(inString)[0]
        return Identifier(shareID=box['shareID'].decode('utf-8'),
                          localpart=box['localpart'].decode('utf-8'),
                          domain=box['domain'].decode('utf-8'))
27795
def _extract_device_uuid(cls, slug):
        

        if len(slug) != 22:
            raise ArgumentError("Invalid device slug", slug=slug)

        hexdigits = slug[3:]
        hexdigits = hexdigits.replace('-', '')

        try:
            rawbytes = binascii.unhexlify(hexdigits)
            words = struct.unpack(">LL", rawbytes)
            return (words[0] << 32) | (words[1])
        except ValueError as exc:
            raise ArgumentError("Could not convert device slug to hex integer", slug=slug, error=str(exc))
405377
def _get_device_id(self, bus):
        
        _dbus = bus.get(SERVICE_BUS, PATH)
        devices = _dbus.devices()

        if self.device is None and self.device_id is None and len(devices) == 1:
            return devices[0]

        for id in devices:
            self._dev = bus.get(SERVICE_BUS, DEVICE_PATH + "/%s" % id)
            if self.device == self._dev.name:
                return id

        return None
548496
def mount(self, identifier):
        

        driver = self.client.info()['Driver']
        driver_mount_fn = getattr(self, "_mount_" + driver,
                                  self._unsupported_backend)
        cid = driver_mount_fn(identifier)

        # Return mount path so it can be later unmounted by path
        return self.mountpoint, cid
1139627
def GetDeviceStringProperty(dev_ref, key):
  """"""
  cf_key = CFStr(key)
  type_ref = iokit.IOHIDDeviceGetProperty(dev_ref, cf_key)
  cf.CFRelease(cf_key)
  if not type_ref:
    return None

  if cf.CFGetTypeID(type_ref) != cf.CFStringGetTypeID():
    raise errors.OsHidError('Expected string type, got {}'.format(
        cf.CFGetTypeID(type_ref)))

  type_ref = ctypes.cast(type_ref, CF_STRING_REF)
  out = ctypes.create_string_buffer(DEVICE_STRING_PROPERTY_BUFFER_SIZE)
  ret = cf.CFStringGetCString(type_ref, out, DEVICE_STRING_PROPERTY_BUFFER_SIZE,
                              K_CF_STRING_ENCODING_UTF8)
  if not ret:
    return None

  return out.value.decode('utf8')
142648
def get_identifier(cmd_args, endpoint=''):
    
    student_email = get_student_email(cmd_args, endpoint)
    if not student_email:
        return "Unknown"
    return hashlib.md5(student_email.encode()).hexdigest()
964820
def _check_backend(self, backend, endpoint):
        
        # First check against hacks for old backend names
        original_backend = backend
        backend = backend.lower()
        if endpoint == 'experiment':
            if backend in self.__names_backend_ibmqxv2:
                return 'real'
            elif backend in self.__names_backend_ibmqxv3:
                return 'ibmqx3'
            elif backend in self.__names_backend_simulator:
                return 'sim_trivial_2'

        # Check for new-style backends
        backends = self.available_backends()
        for backend in backends:
            if backend['name'] == original_backend:
              return original_backend
        # backend unrecognized
        return None
180278
def match(self, device):
        """"""
        return all(match_value(getattr(device, k), v)
                   for k, v in self._match.items())