Get new data, parses it and returns a device.
515431
def parse(self):
        """"""
        # fetch data
        sess = requests.session()
        request = sess.get('https://{}/{}'.format(self.locale,
                                                  self.product_id),
                           allow_redirects=True,
                           timeout=2)
        sess.close()

        # raise exception, e.g. if we are blocked because of too many requests
        request.raise_for_status()

        soup = BeautifulSoup(request.text, 'html.parser')

        # parse name
        raw = soup.find('h1', attrs={'class': 'gh-headline'})
        self.device.name = raw.string.replace('\n', '')

        # parse prices
        self.device.prices = []
        for tmp in soup.select('div.offer__price .gh_price'):
            matches = re.search(_REGEX, tmp.string)
            raw = '{}.{}'.format(matches.group(1),
                                 matches.group(2))
            self.device.prices += [float(raw)]

        # parse unit
        price_match = soup.find('span', attrs={'class': 'gh_price'})
        matches = re.search(r'€|£|PLN', price_match.string)
        self.device.price_currency = matches.group()

        return self.device
1297110
def parse_phone(phone):
    """"""
    if isinstance(phone, int):
        return str(phone)
    else:
        phone = re.sub(r'[+()\s-]', '', str(phone))
        if phone.isdigit():
            return phone
221777
def _fetch(self):
        """"""
        if 'uri' in self._meta_data:
            error = "There was an attempt to assign a new uri to this "\
                    "resource, the _meta_data['uri'] is %s and it should"\
                    " not be changed." % (self._meta_data['uri'])
            raise URICreationCollision(error)
        # Make convenience variable with short names for this method.
        _create_uri = self._meta_data['container']._meta_data['uri']
        session = self._meta_data['bigip']._meta_data['icr_session']
        # Invoke the REST operation on the device.
        response = session.post(_create_uri, json={})
        # Make new instance of self
        return self._produce_instance(response)
457153
def _get_data(self, read_size):
        """"""
        if NIX:
            return super(Keyboard, self)._get_data(read_size)
        return self._pipe.recv_bytes()
676686
def parse(data)
      game = GameItem.new(get_title(data), get_genres(data),
        get_download_size(data), get_release_date(data), get_description(data),
        get_price(data), get_avg_rating(data), get_avg_ratings_count(data),
        get_platforms(data), get_languages(data), get_developer(data),
        get_publisher(data), get_modes(data), get_bonus_content(data),
        get_reviews(data), get_pegi_age(data))      

      game
    end
171632
def getDevice(self, id):
        
        return next(iter([d for d in self.devices.values() if d.deviceId == id]), None)
751630
def __read_device(self):
        """"""
        state = XinputState()
        res = self.manager.xinput.XInputGetState(
            self.__device_number, ctypes.byref(state))
        if res == XINPUT_ERROR_SUCCESS:
            return state
        if res != XINPUT_ERROR_DEVICE_NOT_CONNECTED:
            raise RuntimeError(
                "Unknown error %d attempting to get state of device %d" % (
                    res, self.__device_number))
        # else (device is not connected)
        return None
635348
def get_device(self, device_id):
        
        def process_result(result):
            return Device(result)

        return Command('get', [ROOT_DEVICES, device_id],
                       process_result=process_result)
704424
def read(self):
        """"""
        data = bytearray()
        while True:
            incoming_bytes = self.comport.inWaiting()
            if incoming_bytes == 0:
                break
            else:
                content = self.comport.read(size=incoming_bytes)
                data.extend(bytearray(content))
        return data
511048
def data(self):
        """"""
        if self._data is None:
            # reset after possible parsing failure
            self.__init__(self.tokens)
            return self._parse()
        else:
            return self._data
1151215
def new_data(self, mem, addr, data):
        """"""
        if mem.id == self.id:
            logger.debug(
                "Got new data from the LED driver, but we don't care.")
871373
def get_data(self):
        

        target = DeviceTarget(self.device_id)
        return self._fssapi.get_file(target, self.path)[self.device_id]
143875
def receive_device_value(self, raw_value: int):
        

        new_value = self._input_to_raw_value(raw_value)
        self.__value = new_value
        if new_value > self.max:
            self.max = new_value
        elif new_value < self.min:
            self.min = new_value
597359
def get_changed_devices(self, timestamp):
        
        if timestamp is None:
            payload = {}
        else:
            payload = {
                'timeout': SUBSCRIPTION_WAIT,
                'minimumdelay': SUBSCRIPTION_MIN_WAIT
            }
            payload.update(timestamp)
        # double the timeout here so requests doesn't timeout before vera
        payload.update({
            'id': 'lu_sdata',
        })

        logger.debug("get_changed_devices() requesting payload %s", str(payload))
        r = self.data_request(payload, TIMEOUT*2)
        r.raise_for_status()

        # If the Vera disconnects before writing a full response (as lu_sdata
        # will do when interrupted by a Luup reload), the requests module will
        # happily return 200 with an empty string. So, test for empty response,
        # so we don't rely on the JSON parser to throw an exception.
        if r.text == "":
            raise PyveraError("Empty response from Vera")

        # Catch a wide swath of what the JSON parser might throw, within
        # reason. Unfortunately, some parsers don't specifically return
        # json.decode.JSONDecodeError, but so far most seem to derive what
        # they do throw from ValueError, so that's helpful.
        try:
            result = r.json()
        except ValueError as ex:
            raise PyveraError("JSON decode error: " + str(ex))

        if not ( type(result) is dict
                 and 'loadtime' in result and 'dataversion' in result ):
            raise PyveraError("Unexpected/garbled response from Vera")

        # At this point, all good. Update timestamp and return change data.
        device_data = result.get('devices')
        timestamp = {
            'loadtime': result.get('loadtime'),
            'dataversion': result.get('dataversion')
        }
        return [device_data, timestamp]
1312893
async def get_devices(self):
        """"""
        data = await self.api("devices")
        if self.connected and self.authenticated:
            self._devices = data
        else:
            self._devices = self._devices
        _LOGGER.debug(self._devices)
116173
def new_device(device_json, abode):
    """"""
    type_tag = device_json.get('type_tag')

    if not type_tag:
        raise AbodeException((ERROR.UNABLE_TO_MAP_DEVICE))

    generic_type = CONST.get_generic_type(type_tag.lower())
    device_json['generic_type'] = generic_type

    if generic_type == CONST.TYPE_CONNECTIVITY or \
       generic_type == CONST.TYPE_MOISTURE or \
       generic_type == CONST.TYPE_OPENING:
        return AbodeBinarySensor(device_json, abode)
    elif generic_type == CONST.TYPE_CAMERA:
        return AbodeCamera(device_json, abode)
    elif generic_type == CONST.TYPE_COVER:
        return AbodeCover(device_json, abode)
    elif generic_type == CONST.TYPE_LIGHT:
        return AbodeLight(device_json, abode)
    elif generic_type == CONST.TYPE_LOCK:
        return AbodeLock(device_json, abode)
    elif generic_type == CONST.TYPE_SWITCH:
        return AbodeSwitch(device_json, abode)
    elif generic_type == CONST.TYPE_VALVE:
        return AbodeValve(device_json, abode)
    elif generic_type == CONST.TYPE_UNKNOWN_SENSOR:
        return _new_sensor(device_json, abode)

    return None
707125
def newDevices(self, interface_id, dev_descriptions):
        """"""
        LOG.debug("RPCFunctions.newDevices: interface_id = %s, dev_descriptions = %s" % (
            interface_id, str(dev_descriptions)))
        remote = interface_id.split('-')[-1]
        if remote not in self._devices_raw:
            self._devices_raw[remote] = []
        if remote not in self._devices_raw_dict:
            self._devices_raw_dict[remote] = {}
        for d in dev_descriptions:
            self._devices_raw[remote].append(d)
            self._devices_raw_dict[remote][d['ADDRESS']] = d
        self.saveDevices(remote)
        self.createDeviceObjects(interface_id)
        if self.systemcallback:
            self.systemcallback('newDevices', interface_id, dev_descriptions)
        return True