helper method to compare salt state info with the PagerDuty API json structure,
    and determine if we need to update.

    returns the dict to pass to the PD API to perform the update, or empty dict if no update.
778179
def _diff(state_data, resource_object):
    '''
    '''
    objects_differ = None

    for k, v in state_data['service'].items():
        if k == 'escalation_policy_id':
            resource_value = resource_object['escalation_policy']['id']
        elif k == 'service_key':
            # service_key on create must 'foo' but the GET will return 'foo@bar.pagerduty.com'
            resource_value = resource_object['service_key']
            if '@' in resource_value:
                resource_value = resource_value[0:resource_value.find('@')]
        else:
            resource_value = resource_object[k]
        if v != resource_value:
            objects_differ = '{0} {1} {2}'.format(k, v, resource_value)
            break

    if objects_differ:
        return state_data
    else:
        return {}
538306
def _update_state_from_response(self, response_json):
        
        power_strip = response_json.get('data')

        power_strip_reading = power_strip.get('last_reading')
        outlets = power_strip.get('outlets')
        for outlet in outlets:
            if outlet.get('outlet_id') == str(self.object_id()):
                outlet['last_reading']['connection'] = power_strip_reading.get('connection')
                self.json_state = outlet
1317199
def from_dict(d):
        
        if d is None:
            return None
        return Response(
            d.get('html'),
            CacheInfo.from_dict(d.get('cache_info')),
            d.get('scraped'),
            d.get('raw')
        )
121878
def refresh(self):
        
        params = {"f": "json"}
        uURL = self._url + "/refresh"
        res = self._get(url=uURL, param_dict=params,
                           securityHandler=self._securityHandler,
                           proxy_port=self._proxy_port,
                           proxy_url=self._proxy_url)
        self.__init()
        return res
85889
def refresh(self, scope_list=None):
        
        request_data = self.get_refresh_token_params(scope_list)
        res = self._session.post(**request_data)
        if res.status_code != 200:
            raise APIException(
                request_data['url'],
                res.status_code,
                response=res.content,
                request_param=request_data,
                response_header=res.headers
            )
        json_res = res.json()
        self.update_token(json_res)
        return json_res
21022
def update(self, uid):
        '''
        
        '''
        if self.userinfo.role[1] >= '3':
            pass
        else:
            return False
        post_data = self.get_post_data()

        post_data['user_name'] = self.get_current_user()

        if self.is_p:
            if MLink.update(uid, post_data):
                output = {
                    'addinfo ': 1,
                }
            else:
                output = {
                    'addinfo ': 0,
                }
            return json.dump(output, self)
        else:
            if MLink.update(uid, post_data):
                self.redirect('/link/list')
510477
def p_changeinfo(self):
        '''
        
        '''

        post_data, def_dic = self.fetch_post_data()

        usercheck = MUser.check_user(self.userinfo.uid, post_data['rawpass'])
        if usercheck == 1:
            MUser.update_info(self.userinfo.uid, post_data['user_email'], extinfo=def_dic)
            output = {'changeinfo ': usercheck}
        else:
            output = {'changeinfo ': 0}
        return json.dump(output, self)
882697
def update(self):
        '''
        
        '''
        self._json = self._request(
            method='GET',
            url=self.API
        )._json
297850
def api_version(profile=None, **connection_args):
    '''
    
    '''
    kwargs = _get_kwargs(profile=profile, **connection_args)
    auth_url = kwargs.get('auth_url', kwargs.get('endpoint', None))
    try:
        return salt.utils.http.query(auth_url, decode=True, decode_type='json',
                                     verify_ssl=False)['dict']['version']['id']
    except KeyError:
        return None
842624
def update_state(self):
        
        response = self.api_interface.get_device_state(self, id_override=self.parent.object_id(),
                                                       type_override=self.parent.object_type())
        self._update_state_from_response(response)
519021
def _nary_dict_update(dicts, **kwargs):
    
    copy = kwargs['copy']
    res = dicts[0].copy() if copy else dicts[0]
    if len(dicts) == 1:
        return res

    # decide what strategy to use when updating a dictionary
    # with the values from another: {(non)recursive} x {(non)overwriting}
    deep = kwargs['deep']
    overwrite = kwargs['overwrite']
    if deep:
        dict_update = curry(_recursive_dict_update, overwrite=overwrite)
    else:
        if overwrite:
            dict_update = res.__class__.update
        else:
            def dict_update(dict_, other):
                for k, v in iteritems(other):
                    dict_.setdefault(k, v)

    for d in dicts[1:]:
        dict_update(res, d)
    return res
431952
def update(self, params):
        
        dev_info = self.json_state.get('deviceInfo')
        dev_info.update({k: params[k] for k in params if dev_info.get(k)})
1366225
def compare_dicts(old=None, new=None):
    '''
    
    '''
    ret = {}
    for key in set((new or {})).union((old or {})):
        if key not in old:
            # New key
            ret[key] = {'old': '',
                        'new': new[key]}
        elif key not in new:
            # Key removed
            ret[key] = {'new': '',
                        'old': old[key]}
        elif new[key] != old[key]:
            # Key modified
            ret[key] = {'old': old[key],
                        'new': new[key]}
    return ret
706654
def _get_instance_changes(current, state):
    '''
    
    '''
    # get keys
    current_keys = set(current.keys())
    state_keys = set(state.keys())

    # compare configs
    changed = salt.utils.data.compare_dicts(current, state)
    for change in salt.utils.data.compare_dicts(current, state):
        if change in changed and changed[change]['old'] == "":
            del changed[change]
        if change in changed and changed[change]['new'] == "":
            del changed[change]

    return changed
230421
async def update(self) -> None:
        
        url = '{}{}'.format(self.url, ENDPOINT)

        try:
            async with self._session.get(url) as response:
                json_dict = demjson.decode(await response.text(), strict=False)
        except aiohttp.ClientError:
            json_dict = {'status': {'status1': SyncThru.OFFLINE}}
        except demjson.JSONDecodeError:
            raise ValueError("Invalid host, does not support SyncThru.")
        self.data = json_dict
1107631
function initState() {
        var result = $.Deferred();
        updateJsonHandler.parse()
            .done(function() {
                result.resolve();
            })
            .fail(function (code) {
                var logMsg;
                switch (code) {
                case StateHandlerMessages.FILE_NOT_FOUND:
                    logMsg = "AutoUpdate : updateHelper.json cannot be parsed, does not exist";
                    break;
                case StateHandlerMessages.FILE_NOT_READ:
                    logMsg = "AutoUpdate : updateHelper.json could not be read";
                    break;
                case StateHandlerMessages.FILE_PARSE_EXCEPTION:
                    logMsg = "AutoUpdate : updateHelper.json could not be parsed, exception encountered";
                    break;
                case StateHandlerMessages.FILE_READ_FAIL:
                    logMsg = "AutoUpdate : updateHelper.json could not be parsed";
                    break;
                }
                console.log(logMsg);
                result.reject();
            });
        return result.promise();
    }
1129175
def update():
    
    assert request.method == "POST", "POST request expected received {}".format(request.method)
    if request.method == 'POST':
        # Get figure stats
        selected_run = request.form['selected_run']
        variable_names = utils.get_variables(selected_run).items()

        if len(current_index) < 1:
            for _, v_n in variable_names:
                current_index[v_n] = 0

        logging.info("Current index: {}".format(current_index))
        data = utils.get_variable_update_dicts(current_index, variable_names, selected_run)

        return jsonify(data)