Example #1
0
    def convert(self, query):
        result = []

        encode_result = base64.encodestring(query).replace('\n', '')
        result += [
            Item(title=u'Base64 Encode' + ': ' + query,
                 subtitle=encode_result,
                 arg=self.name + u'-encode:' + encode_result,
                 valid=True,
                 icon=self.icon_path())
        ]

        try:
            if re.search(
                    "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
                    query):
                decode_result = base64.decodestring(query).encode(
                    'utf-8').replace('\n', '')
                if base64.encodestring(decode_result).replace('\n',
                                                              '') == query:
                    result += [
                        Item(title=u'Base64 Decode' + ': ' + query,
                             subtitle=decode_result,
                             arg=self.name + u'-decode:' + decode_result,
                             valid=True,
                             icon=self.icon_path())
                    ]
        except:
            pass

        return result
Example #2
0
    def convert(self, query):
        result = []

        try:
            int_char = int(query)
            if 32 <= int_char <= 126:
                char = str(chr(int_char))
                if char:
                    result.append(
                        Item(title=u'Number to ASCII' + ': ' + query,
                             subtitle=char,
                             arg=self.name + u'-num2ascii:' + char,
                             valid=True,
                             icon=self.icon_path()))
        except ValueError:
            pass

        try:
            if len(query) == 1:
                result.append(
                    Item(title=u'ASCII to Number' + ': ' + query,
                         subtitle=str(ord(query[0])),
                         arg=self.name + u'-ascii2number:' +
                         str(ord(query[0])),
                         valid=True,
                         icon=self.icon_path()))
        except ValueError:
            pass

        return result
Example #3
0
 def convert(self, query):
     return [
         Item(title=u'Html Encode' + ': ' + query,
              subtitle=saxutils.escape(query),
              arg=saxutils.escape(query),
              valid=True),
         Item(title=u'Html Decode' + ': ' + query,
              subtitle=saxutils.unescape(query),
              arg=saxutils.unescape(query),
              valid=True)
     ]
Example #4
0
    def autocomplete(self, query):
        item = Item(title=self.desc, autocomplete=self.name + ' ')

        if not query:
            item.sort = 0
        elif self.name == query:
            item.sort = len(query) * 10
        elif self.name.find(query) == 0:
            item.sort = len(query)
        else:
            return []
        return [item]
Example #5
0
    def convert(self, query):
        sha1 = hashlib.sha1()
        sha1.update(query)
        sha1_result = sha1.hexdigest()

        sha224 = hashlib.sha224()
        sha224.update(query)
        sha224_result = sha224.hexdigest()

        sha256 = hashlib.sha256()
        sha256.update(query)
        sha256_result = sha256.hexdigest()

        sha384 = hashlib.sha384()
        sha384.update(query)
        sha384_result = sha384.hexdigest()

        sha512 = hashlib.sha512()
        sha512.update(query)
        sha512_result = sha512.hexdigest()

        return [
            Item(title="SHA1" + ': ' + query,
                 subtitle=sha1_result,
                 arg=self.name + u'-sha1:' + sha1_result,
                 valid=True,
                 icon=self.icon_path()),
            Item(title="SHA256" + ': ' + query,
                 subtitle=sha256_result,
                 arg=self.name + u'-sha256:' + sha256_result,
                 valid=True,
                 icon=self.icon_path()),
            Item(title="SHA512" + ': ' + query,
                 subtitle=sha512_result,
                 arg=self.name + u'-sha512:' + sha512_result,
                 valid=True,
                 icon=self.icon_path()),
            Item(title="SHA224" + ': ' + query,
                 subtitle=sha224_result,
                 arg=self.name + u'-sha224:' + sha224_result,
                 valid=True,
                 icon=self.icon_path()),
            Item(title="SHA384" + ': ' + query,
                 subtitle=sha384_result,
                 arg=self.name + u'-sha384:' + sha384_result,
                 valid=True,
                 icon=self.icon_path())
        ]
Example #6
0
 def convert(self, query):
     return [
         Item(title=u'JavaScript encodeURI' + ': ' + query,
              subtitle=urllib2.quote(
                  query, "!#$&'()*+,-./:;=?@_~").encode("utf-8"),
              arg=urllib2.quote(query,
                                "!#$&'()*+,-./:;=?@_~").encode("utf-8"),
              valid=True),
         Item(title=u'JavaScript encodeURIComponent' + ': ' + query,
              subtitle=urllib2.quote(query, "!'()*-._~").encode("utf-8"),
              arg=urllib2.quote(query, "!'()*-._~").encode("utf-8"),
              valid=True),
         Item(title=u'JavaScript decode' + ': ' + query,
              subtitle=urllib2.unquote(query).encode("utf-8"),
              arg=urllib2.unquote(query).encode("utf-8"),
              valid=True)
     ]
Example #7
0
 def convert(self, query):
     m = hashlib.md5()
     m.update(query)
     v = m.hexdigest()
     return [Item(
             title=self.name + ': ' + query,
             subtitle=v,
             arg=v,
             valid=True
     )]
Example #8
0
 def convert(self, query):
     try:
         q = int(query)
         v = IPAddr.ipaddr_ntoa(q)
         return [Item(
             title=self.name + ': ' + query,
             subtitle=v,
             arg=self.name + u' IPv4: ' + v,
             valid=True,
             icon=self.icon_path(),
         )]
     except:
         v = IPAddr.ipaddr_aton(query)
         return [Item(
             title=self.name + ': ' + query,
             subtitle=str(v),
             arg=self.name + u' IPv4: ' + str(v),
             valid=True,
             icon=self.icon_path(),
         )]
Example #9
0
 def convert(self, query):
     m = hashlib.md5()
     m.update(query)
     v = m.hexdigest()
     return [
         Item(title=self.name + ': ' + query,
              subtitle=v,
              arg=self.name + u'-md5:' + v,
              valid=True,
              icon=self.icon_path())
     ]
Example #10
0
    def convert(self, query):
        result = []

        if query:
            if query != query.lower():
                result += [
                    Item(title=u'String lowercase',
                         subtitle=query.lower(),
                         arg=self.name + u'-lowercase:' + query.lower(),
                         valid=True,
                         icon=self.icon_path())
                ]
            if query != query.upper():
                result += [
                    Item(title=u'String uppercase',
                         subtitle=query.upper(),
                         arg=self.name + u'-uppercase:' + query.upper(),
                         valid=True,
                         icon=self.icon_path())
                ]
        return result
Example #11
0
    def convert(self, query):
        result = []

        decSource = None
        try:
            decSource = int(query)
        except ValueError:
            pass

        try:
            result.append(
                Item(title=u'Bin to Dec' + ': ' + query,
                     subtitle=str(int(query, 2)),
                     arg=self.name + u'-bin2dec:' + str(int(query, 2)),
                     valid=True,
                     icon=self.icon_path()))
        except ValueError:
            pass

        try:
            result.append(
                Item(title=u'Oct to Dec' + ': ' + query,
                     subtitle=str(int(query, 8)),
                     arg=self.name + u'-oct2dec:' + str(int(query, 8)),
                     valid=True,
                     icon=self.icon_path()))
        except ValueError:
            pass

        try:
            result.append(
                Item(title=u'Hex to Dec' + ': ' + query,
                     subtitle=str(int(query, 16)),
                     arg=self.name + u'-hex2dec:' + str(int(query, 16)),
                     valid=True,
                     icon=self.icon_path()))
        except ValueError:
            pass

        if decSource:
            result.append(
                Item(title=u'Dec to Hex' + ': ' + query,
                     subtitle=hex(decSource),
                     arg=self.name + u'-dec2hex:' + hex(decSource),
                     valid=True,
                     icon=self.icon_path()))
            result.append(
                Item(title=u'Dec to Bin' + ': ' + query,
                     subtitle=bin(decSource),
                     arg=self.name + u'-dec2bin:' + bin(decSource),
                     valid=True,
                     icon=self.icon_path()))
            result.append(
                Item(title=u'Dec to Oct' + ': ' + query,
                     subtitle=oct(decSource),
                     arg=self.name + u'-dec2oct:' + oct(decSource),
                     valid=True,
                     icon=self.icon_path()))

        return result
Example #12
0
 def convert(self, query):
     return [
         Item(title=u'JavaScript encodeURI' + ': ' + query,
              subtitle=urllib2.quote(
                  query, "!#$&'()*+,-./:;=?@_~").encode("utf-8"),
              arg=self.name + u'-encodeURI:' +
              urllib2.quote(query, "!#$&'()*+,-./:;=?@_~").encode("utf-8"),
              valid=True,
              icon=self.icon_path()),
         Item(title=u'JavaScript encodeURIComponent' + ': ' + query,
              subtitle=urllib2.quote(query, "!'()*-._~").encode("utf-8"),
              arg=self.name + u'-encodeURIComponent:' +
              urllib2.quote(query, "!'()*-._~").encode("utf-8"),
              valid=True,
              icon=self.icon_path()),
         Item(title=u'JavaScript decode' + ': ' + query,
              subtitle=urllib2.unquote(query).encode("utf-8"),
              arg=self.name + u'-decode:' +
              urllib2.unquote(query).encode("utf-8"),
              valid=True,
              icon=self.icon_path())
     ]
Example #13
0
    def convert(self, query):
        result = []

        if re.search('^\d+(\.\d?)?$', query):
            timestamp = float(query)
            local_datetime = datetime.fromtimestamp(timestamp)
            utc_datetime = datetime.utcfromtimestamp(timestamp)

            result += [
                Item(
                        title=u'TimeStamp to DataTime(Local)' + ': ' + query,
                        subtitle=str(local_datetime),
                        arg=str(local_datetime),
                        valid=True
                ),
                Item(
                        title=u'TimeStamp to DataTime(UTC)' + ': ' + query,
                        subtitle=str(utc_datetime),
                        arg=str(utc_datetime),
                        valid=True
                )
            ]
        return result
Example #14
0
    def convert(self, query):
        result = []

        if not query:
            new_uuid = str(uuid.uuid4())
            result += [
                Item(
                    title=u'New UUID',
                    subtitle=new_uuid,
                    arg=self.name + u'-uuid4:' + new_uuid,
                    valid=True,
                    icon=self.icon_path()
                ),
                Item(
                    title=u'New UUID without dash',
                    subtitle=new_uuid.replace('-', ''),
                    arg=self.name + u'-uuid4-without-dash:' + new_uuid.replace('-', ''),
                    valid=True,
                    icon=self.icon_path()
                ),
                Item(
                    title=u'New UUID (Hex)',
                    subtitle='0x' + new_uuid.replace('-', ''),
                    arg=self.name + u'-uuid4-hex:0x' + new_uuid.replace('-', ''),
                    valid=True,
                    icon=self.icon_path()
                ),
            ]
        else:
            uuid_type = None
            if "-" in query and len(query) == 36:
                uuid_type = "dash"
            elif len(query) == 34 and query[0:2] == "0x":
                uuid_type = "hex"
            elif len(query) == 32:
                uuid_type = "normal"

            if uuid_type:
                normal_uuid = query.replace('-', '').replace('0x', '')

                if uuid_type != "normal":
                    result += [
                        Item(
                            title=u'UUID without dash',
                            subtitle=normal_uuid,
                            arg=self.name + u'-uuid-without-dash:' + normal_uuid,
                            valid=True,
                            icon=self.icon_path()
                        )
                    ]

                if uuid_type != "dash":
                    formatted_uuid = "%s-%s-%s-%s-%s" % (normal_uuid[0:8], normal_uuid[8:12], normal_uuid[12:16], normal_uuid[16:20], normal_uuid[20:])
                    result += [
                        Item(
                            title=u'Formatted UUID',
                            subtitle=formatted_uuid,
                            arg=self.name + u'-uuid:' + formatted_uuid,
                            valid=True,
                            icon=self.icon_path()
                        )
                    ]

                if uuid_type != "hex":
                    result += [
                        Item(
                            title=u'UUID (Hex)',
                            subtitle='0x' + normal_uuid,
                            arg=self.name + u'-uuid-hex:0x' + normal_uuid,
                            valid=True,
                            icon=self.icon_path()
                        )
                    ]

        return result
Example #15
0
    def convert(self, query):
        result = []

        if not query:
            now = int(time.time())
            local_datetime = datetime.fromtimestamp(now)
            utc_datetime = datetime.utcfromtimestamp(now)

            result += [
                Item(title=u'Timestamp',
                     subtitle=str(now),
                     arg=self.name + u'-now-timestamp:' + str(now),
                     valid=True,
                     icon=self.icon_path()),
                Item(title=u'Local Datetime',
                     subtitle=str(local_datetime),
                     arg=self.name + u'-now-datetime-local:' +
                     str(local_datetime),
                     valid=True,
                     icon=self.icon_path()),
                Item(title=u'UTC Datetime',
                     subtitle=str(utc_datetime),
                     arg=self.name + u'-now-datetime--utc:' +
                     str(utc_datetime),
                     valid=True,
                     icon=self.icon_path())
            ]
        else:
            if re.search('^\d+(\.\d?)?$', query):
                timestamp = float(query)
                local_datetime = datetime.fromtimestamp(timestamp)
                utc_datetime = datetime.utcfromtimestamp(timestamp)

                result += [
                    Item(title=u'TimeStamp to DateTime(Local)' + ': ' + query,
                         subtitle=str(local_datetime),
                         arg=self.name + u'-timestamp-to-datetime-local:' +
                         str(local_datetime),
                         valid=True,
                         icon=self.icon_path()),
                    Item(title=u'TimeStamp to DateTime(UTC)' + ': ' + query,
                         subtitle=str(utc_datetime),
                         arg=self.name + u'-timestamp-to-datetime-utc:' +
                         str(utc_datetime),
                         valid=True,
                         icon=self.icon_path())
                ]
            else:
                try:
                    parsed_datetime = parse(query)
                    convert_result = str(self.totimestamp(parsed_datetime))
                    result += [
                        Item(title=u'TimeStamp to DateTime to TimeStamp' +
                             ': ' + query,
                             subtitle=convert_result,
                             arg=self.name + u'-datetime-to-timestamp:' +
                             convert_result,
                             valid=True,
                             icon=self.icon_path())
                    ]
                except:
                    pass

        return result