bee-san/pyWhat

Add support for non-regex processing

Open

#115 opened on 2021年7月13日

GitHub で見る
 (0 comments) (3 reactions) (0 assignees)Python (382 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (6,228 stars)
PR merge metrics
 (30d に merged 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

コントリビューターガイド