<commit_before>import io
import re
from collections import defaultdict
from pprint import pp

extra_requirements = """
# FORMAT
# Put your extra requirements here in the following format
#
# package[version_required]: tag1, tag2, ...

ttkwidgets: ttkwidgets
tksheet: tksheet
tkinterweb: tkinterweb
tkintertable: tkintertable
tkcalendar: tkcalendar
AwesomeTkinter: awesometkinter
"""


def get_extra_requires(add_all=True):
    ifile = io.StringIO(extra_requirements)
    with ifile as fp:
        extra_deps = defaultdict(set)
        for k in fp:
            if k.strip() and not k.startswith("#"):
                tags = set()
                if ":" in k:
                    k, v = k.split(":")
                    tags.update(vv.strip() for vv in v.split(","))
                tags.add(re.split("[<=>]", k)[0])
                for t in tags:
                    extra_deps[t].add(k)
        # add tag `all` at the end
        if add_all:
            extra_deps["all"] = set(vv for v in extra_deps.values() for vv in v)

    return extra_deps


if __name__ == "__main__":
    pp(dict(get_extra_requires()))<commit_msg>fix script.<commit_after>import io
import re
from collections import defaultdict
from pprint import pp

extra_requirements = """
# FORMAT
# Put your extra requirements here in the following format
#
# package[version_required]: tag1, tag2, ...

ttkwidgets: ttkwidgets
tksheet: tksheet
tkinterweb: tkinterweb
tkintertable: tkintertable
tkcalendar: tkcalendar
AwesomeTkinter: awesometkinter
"""


def get_extra_requires(add_all=True):
    ifile = io.StringIO(extra_requirements)
    with ifile as fp:
        extra_deps = defaultdict(set)
        for k in fp:
            if k.strip() and not k.startswith("#"):
                tags = set()
                if ":" in k:
                    k, v = k.split(":")
                    tags.update(vv.strip() for vv in v.split(","))
                # tags.add(re.split("[<=>]", k)[0])
                for t in tags:
                    extra_deps[t].add(k)
        # add tag `all` at the end
        if add_all:
            extra_deps["all"] = set(vv for v in extra_deps.values() for vv in v)

    return extra_deps


if __name__ == "__main__":
    requires = get_extra_requires()
    for key, dep in requires.items():
        print(f"{key} = {list(dep)}")
{'fraction_non_alphanumeric': 0.11427339370418284, 'fraction_numerical': 0.00258732212160414, 'mean_word_length': 2.347763347763348, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2520424', 'n_tokens_mistral': 764, 'n_tokens_neox': 741, 'n_words': 210}