Skip to content

Commit

Permalink
[-] 移除不再需要的函数 zmirror.utils.assemble_domains_regex()
Browse files Browse the repository at this point in the history
  • Loading branch information
aploium committed Sep 13, 2016
1 parent 5ed8554 commit cce3fb6
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions zmirror/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,6 @@ def calc_domain_replace_prefix(_domain):
)


def assemble_domains_regex(domain_list):
root_domains = []
_buff = {}
for _domain in domain_list:
root, sub = extract_root_domain(_domain)
if not sub:
root_domains.append(re.escape(_domain))
else:
if root not in _buff:
_buff[root] = []

_buff[root].append(sub)

buff2 = []
for root, subs in sorted(_buff.items(), key=lambda x: len(x[0]), reverse=True):
if subs:
if len(subs) > 1:
buff3 = "(?:" + "|".join(re.escape(x) for x in subs) + ")"
else:
buff3 = re.escape(subs[0])

buff3 += r"\." + re.escape(root)
else:
# 对应 subs 为空的情况
buff3 = re.escape(root)

buff2.append(buff3)

return "(?:" + "|".join(buff2 + root_domains) + ")"


def current_line_number():
"""Returns the current line number in our program.
:return: current line number
Expand Down

0 comments on commit cce3fb6

Please sign in to comment.