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

贡献者指南