Exemple #1
0
    def process_value(self, name, value, module_name):
        """
        This method allow any encodings to be dealt with.
        Currently only base64 is supported.

        Note: If other encodings are added then this should be split so that
        there is a method for each encoding.
        """
        # if we have a colon in the name of a setting then it
        # indicates that it has been encoded.
        if ":" in name:

            if module_name.split(" ")[0] in I3S_MODULE_NAMES + ["general"]:
                self.error("Only py3status modules can use obfuscated")

            if type(value).__name__ not in ["str", "unicode"]:
                self.error("Only strings can be obfuscated")

            (name, scheme) = name.split(":")
            if scheme == "base64":
                value = PrivateBase64(value, module_name)
            elif scheme == "hide":
                value = PrivateHide(value, module_name)
            else:
                self.error("Unknown scheme {} for data".format(scheme))

        return name, value
Exemple #2
0
    def process_value(self, name, value, module_name):
        '''
        This method allow any encodings to be dealt with.
        Currently only base64 is supported.

        Note: If other encodings are added then this should be split so that
        there is a method for each encoding.
        '''
        # if we have a colon in the name of a setting then it
        # indicates that it has been encoded.
        if ':' in name:

            if module_name.split(' ')[0] in I3S_MODULE_NAMES + ['general']:
                self.error('Only py3status modules can use obfuscated')

            if type(value).__name__ not in ['str', 'unicode']:
                self.error('Only strings can be obfuscated')

            (name, scheme) = name.split(':')
            if scheme == 'base64':
                value = PrivateBase64(value, module_name)
            elif scheme == 'hide':
                value = PrivateHide(value, module_name)
            else:
                self.error('Unknown scheme {} for data'.format(scheme))

        return name, value