bee-san/pyWhat

Add support for non-regex processing

Open

#115 建立於 2021年7月13日

在 GitHub 查看
 (0 留言) (3 反應) (0 負責人)Python (382 fork)batch import
enhancementhelp wanted

倉庫指標

Star
 (6,228 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Currently, pywhat only uses regular expressions to identify stuff. However, we may often want to update the description based on a match or to filter out false positives.

Some examples:

  • Pinging URLs to check if it is responding or if a certain resource exists, etc.
  • Parsing timestamps (https://github.com/bee-san/pyWhat/issues/234) (1637093119.558717 to November 16, 2021 8:05:19 PM)
  • Changing rarity based on a match
  • And many more

How it should be implemented?

I think the best idea would be to write a class for every regex pattern (so that it can save the state between several matches). That class should have a method like process() that gets a match object and can alter it and return it or return None to filter it out.

Example:

class URLProcessor:
    def process(match):
        if "http://trashurl.it" in match["url"]: # Or maybe we should create an actual Match class and do match.url
            return None

貢獻者指南