#115·pyWhat

Add support for non-regex processing

Author: ghostCreated Jul 13, 2021Updated Nov 20, 2021
Labelsenhancementhelp wanted

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:

python
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