set()'s .intersection for list and str
This commit is contained in:
parent
c55d36380b
commit
87ead88610
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@hook(str)
|
||||
def intersection(self, *args) -> str:
|
||||
ret = set(self).intersection(*args)
|
||||
return "".join(list(ret))
|
||||
Loading…
Reference in New Issue
Block a user