-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.py
More file actions
49 lines (47 loc) · 1.92 KB
/
constants.py
File metadata and controls
49 lines (47 loc) · 1.92 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
import re
GITHUB_LINE_NUMBER_URL_REGEX = re.compile(
r"""
(?: # Discard any match not proceded by
(?<!\S) # a non-space character
| (?<=<) # a "<" character
| (?<=\|\|) # a "||"
)
https?://github\.com/
(?P<owner>[\w\-.]+)/ # Repo owner
(?P<repo>[\w\-.]+)/ # Repo name
blob/(?P<branch>[\w\-.]+)/ # Branch name or hash
(?P<file_path>.+?) # File path
(?:\.(?P<file_ext>\w+))? # Optional file extension
(?:\?.+)? # Optional query string
\#L(?P<l1>[0-9]+) # Line number
(?:-L(?P<l2>[0-9]+))? # Optional ending line number
(?: # Discard any match not followed by
(?!\S) # a non-space character
| (?=>) # a ">" character
| (?=\|\|) # a "||"
)
""",
flags=re.VERBOSE
)
DISCORD_MESSAGE_URL_REGEX = re.compile(
r"""
(?:
(?<!\S) # Discard any match proceded by a non-space character
| # Or
(?<=<) # Discard any match not proceded by a "<" character
)
https://
(?:ptb\.|canary\.)? # Optional PTB or Canary subdomain
discord.com/channels/
([0-9]+)/ # Guild ID
([0-9]+)/ # Channel ID
([0-9]+) # Message ID
/?
(?:
(?!\S) # Discard any match followed by a non-space character
| # Or
(?=>) # Discard any match not followed by a ">" character
)
""",
flags=re.VERBOSE
)