From 87ead886105b7066ec32836a5ddc84fdb49ac367 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sat, 3 Dec 2022 08:05:45 +0100 Subject: [PATCH] set()'s .intersection for list and str --- requirements.txt | 7 ++++--- tools/tools.py | 17 +++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index a558087..02300b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -requests~=2.26.0 bs4~=0.0.1 -beautifulsoup4~=4.10.0 -setuptools~=56.0.0 +beautifulsoup4==4.11.1 +fishhook~=0.2.5 +requests==2.28.1 +setuptools==65.6.3 diff --git a/tools/tools.py b/tools/tools.py index f70eeaa..94463e7 100644 --- a/tools/tools.py +++ b/tools/tools.py @@ -2,8 +2,9 @@ import datetime import inspect import os.path import sys +from fishhook import hook from functools import wraps -from typing import Any, Union, List +from typing import Any def get_script_dir(follow_symlinks: bool = True) -> str: @@ -78,9 +79,13 @@ def cache(func): return newfunc -def list_intersection(*args) -> list: - ret = set(args[0]) - for l in args[1:]: - ret = ret.intersection(l) +@hook(list) +def intersection(self, *args) -> list: + ret = set(self).intersection(*args) + return list(ret) - return list(ret) \ No newline at end of file + +@hook(str) +def intersection(self, *args) -> str: + ret = set(self).intersection(*args) + return "".join(list(ret)) \ No newline at end of file