-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathexclude.py
More file actions
36 lines (26 loc) · 921 Bytes
/
exclude.py
File metadata and controls
36 lines (26 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Copyright (c) 2020-2022 Ayoub Malek and Vanessa Sochat
This source code is licensed under the terms of the MIT license.
For a copy, see <https://opensource.org/licenses/MIT>.
"""
def excluded(url, exclude_urls=None, exclude_patterns=None):
"""
Check if link is in the excluded URLs or patterns to ignore.
Args:
- url (str) : link to check.
- exclude_urls (list) : list of excluded urls.
- exclude_patterns (list) : list of excluded patterns.
Returns:
(bool) boolean for whether link is excluded or not.
"""
exclude_urls = exclude_urls or []
exclude_patterns = exclude_patterns or []
# check excluded urls
if url in exclude_urls:
return True
# check excluded patterns
for exclude_pattern in exclude_patterns:
if exclude_pattern in url:
return True
# default return
return False