Skip to content

Commit

Permalink
generate name randomly if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
wzdnzd committed Jul 17, 2024
1 parent 4610038 commit 4a89e97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions subscribe/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import json
import math
import os
import random
import re
import socket
import string
import urllib
from collections import defaultdict

Expand Down Expand Up @@ -162,6 +164,9 @@ def regularize(
records = defaultdict(list)
for proxy in proxies:
name = re.sub(r"(\d+|(\d+)?(-\d+)?[A-Z])$", "", proxy.get("name", "")).strip()
if not name:
name = "".join(random.sample(string.ascii_uppercase, 6))

proxy["name"] = name
records[name].append(proxy)

Expand Down
5 changes: 5 additions & 0 deletions tools/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import argparse
import math
import os
import random
import re
import string
from collections import defaultdict

import yaml
Expand Down Expand Up @@ -61,6 +63,9 @@ def main(args: argparse.Namespace) -> None:
records.add(key)

name = re.sub(r"(\d+|(\d+)?(-\d+)?[A-Z])$", "", item.get("name", "")).strip()
if not name:
name = "".join(random.sample(string.ascii_uppercase, 6))

item["name"] = name

if args.secure:
Expand Down

0 comments on commit 4a89e97

Please sign in to comment.