def _normalize_and_hash(self, input_str):
        normalized = " "

        if input_str and len(input_str) > 0:
            normalized = self._strip_invalid_entities(input_str)
            normalized = GLib.utf8_normalize(normalized, -1, GLib.NormalizeMode.NFKD)
            normalized = normalized.lower()

        return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, normalized, -1)
Beispiel #2
0
    def _normalize_and_hash(self, input_str):
        normalized = ' '

        if input_str and len(input_str) > 0:
            normalized = self._strip_invalid_entities(input_str)
            normalized = GLib.utf8_normalize(normalized, -1,
                                             GLib.NormalizeMode.NFKD)
            normalized = normalized.lower()

        return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5,
                                                normalized, -1)
    def normalizeAndHash(self, input_str):
        normalized = " "

        if input_str is not None and input_str.length() > 0:
            normalized = self.stripInvalidEntities(input_str)
            normalized = GLib.utf8_normalize(normalized, -1,
                                             GLib.NormalizeMode.NFKD)
            normalized = normalized.toLowerCase()

        return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5,
                                                normalized, -1)
    def __init__(self, filename):
        self.filename = filename
        self.file = Gio.file_new_for_path(self.filename)
        self.id = deque()

        # only an unique instance of this app is runnable for each json file.
        # identify the opened file by the md5 digest of its full path
        Gtk.Application.__init__(self, application_id=APP_ID +
                GLib.compute_checksum_for_string(GLib.ChecksumType.MD5,
                self.file.get_path(), -1),
                flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.connect('activate', self.on_activate)