<commit_before>#!python
# -*- coding: utf-8 -*-
"""
VRT Widesky low-level Password mix-in.
"""
import json
import hszinc
from six import string_types
from .....util.asyncexc import AsynchronousException

class PasswordOpsMixin(object):
    """
    The Password operations mix-in implements low-level support for
    modifying the current Widesky user's password.
    """
    def updatePassword(self, newPassword, callback=None):
        """
        Change the current logged in user's password.

        If the update is successful then True is returned.
        Otherwise False.

        :param newPassword: Password value.
        :param callback: The function to call after this operation
        is complete.
        """
        def onResp(response):
            updated = True
            if isinstance(response, AsynchronousException):
                updated = False

            return callback(updated)

        headers = self._client.headers.copy()
        headers["Content-Type"] = "application/json"

        resp = self._post(uri='user/updatePassword',
                        callback=onResp,
                        body=json.dumps({ "newPassword": newPassword }),
                        headers=headers,
                        api=False)<commit_msg>WC-2475: Apply review changes<commit_after>#!python
# -*- coding: utf-8 -*-
"""
VRT Widesky low-level Password mix-in.
"""
import json
import hszinc
from six import string_types
from .....util.asyncexc import AsynchronousException

class PasswordOpsMixin(object):
    """
    The Password operations mix-in implements low-level support for
    modifying the current Widesky user's password.
    """
    def updatePassword(self, newPassword, callback=None):
        """
        Change the current logged in user's password.

        If the update is successful then True is returned.
        Otherwise the AsynchronousException is reraised.

        :param newPassword: Password value.
        :param callback: The function to call after this operation
        is complete.
        """
        def onResp(response):
            if isinstance(response, AsynchronousException):
                response.reraise()

            return callback(True)

        headers = self._client.headers.copy()
        headers["Content-Type"] = "application/json"

        return self._post(uri='user/updatePassword',
                        callback=onResp,
                        body=json.dumps({ "newPassword": <PASSWORD> }),
                        headers=headers,
                        api=False)
{'fraction_non_alphanumeric': 0.0908379013312451, 'fraction_numerical': 0.0023492560689115116, 'mean_word_length': 2.1504315659679407, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5758582', 'n_tokens_mistral': 655, 'n_tokens_neox': 615, 'n_words': 194}