How to use the py3status.private.PrivateHide function in py3status

To help you get started, we’ve selected a few py3status examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ultrabug / py3status / py3status / parse_config.py View on Github external
"""
        # 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
github ultrabug / py3status / py3status / parse_config.py View on Github external
# check we are in a module definition etc
        if not self.current_module:
            self.notify_user("%s(..) used outside of module or section" % function)
            return None

        module = self.current_module[-1].split()[0]
        if module in CONFIG_FILE_SPECIAL_SECTIONS + I3S_MODULE_NAMES:
            self.notify_user(
                "%s(..) cannot be used outside of py3status module "
                "configuration" % function
            )
            return None

        value = self.value_convert(value, value_type)
        module_name = self.current_module[-1]
        return PrivateHide(value, module_name)
github ultrabug / py3status / py3status / private.py View on Github external
class PrivateHide(Private):
    """
    This does not encode the data in any way but it does keep it from being
    shown in the log files, i3bar etc
    """

    def _decode(self, key):
        if self._encoded is None:
            return
        self._value = self._encoded
        self._decoded = True


if __name__ == "__main__":
    # This module can read this
    x = PrivateHide("test", "__main__")
    print(x)
    print(x.upper())
    print(x.split("e"))
    # This module cannot read this
    x = PrivateHide("test", "xxx")
    print(x)
    print(x.upper())
    print(x.split("e"))
github ultrabug / py3status / py3status / private.py View on Github external
def _decode(self, key):
        if self._encoded is None:
            return
        self._value = self._encoded
        self._decoded = True


if __name__ == "__main__":
    # This module can read this
    x = PrivateHide("test", "__main__")
    print(x)
    print(x.upper())
    print(x.split("e"))
    # This module cannot read this
    x = PrivateHide("test", "xxx")
    print(x)
    print(x.upper())
    print(x.split("e"))