mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
Add v2 alpha
This commit is contained in:
parent
ec6352b0a0
commit
b7565b81a7
16 changed files with 2564 additions and 57 deletions
31
dist/src/common.py
vendored
Normal file
31
dist/src/common.py
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
|
||||
|
||||
def get_random_string(length=7, chars=string.ascii_lowercase + string.digits):
|
||||
return "".join(random.choice(chars) for _ in range(length))
|
||||
|
||||
|
||||
def parse_display_name_email(display_name_email):
|
||||
# Parse the name and email address from a string in the following format
|
||||
# Display Name <email@address.com>
|
||||
pattern = re.compile(r"^([^<]+)\s*<([^>]+)>$")
|
||||
|
||||
# Check we have a match
|
||||
match = pattern.match(display_name_email)
|
||||
if match is None:
|
||||
raise ValueError(
|
||||
f"The format of '{display_name_email}' is not a valid email address with display name"
|
||||
)
|
||||
|
||||
# Check that name and email are not just whitespace
|
||||
name = match.group(1).strip()
|
||||
email = match.group(2).strip()
|
||||
if len(name) == 0 or len(email) == 0:
|
||||
raise ValueError(
|
||||
f"The format of '{display_name_email}' is not a valid email address with display name"
|
||||
)
|
||||
|
||||
return name, email
|
Loading…
Add table
Add a link
Reference in a new issue