mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Group same domains and subdomains together
This commit is contained in:
parent
3cecc7cb30
commit
c8e24d898a
1 changed files with 16 additions and 4 deletions
|
@ -59,10 +59,22 @@ def domain_list(exclude_subdomains=False):
|
||||||
parent_domain = domain.split(".", 1)[1]
|
parent_domain = domain.split(".", 1)[1]
|
||||||
if parent_domain in result:
|
if parent_domain in result:
|
||||||
continue
|
continue
|
||||||
result_list.append(".".join(reversed(domain.split("."))))
|
|
||||||
result_list = sorted(result_list)
|
result_list.append(domain)
|
||||||
for i in range(len(result_list)):
|
|
||||||
result_list[i] = ".".join(reversed(result_list[i].split(".")))
|
|
||||||
|
def cmp_domain(domain1, domain2):
|
||||||
|
# Keep the main part of the domain and the extension together
|
||||||
|
# eg: this.is.an.example.com -> ['example.com', 'an', 'is', 'this']
|
||||||
|
domain1 = domain1.split('.')
|
||||||
|
domain2 = domain2.split('.')
|
||||||
|
domain1[-1] = domain1[-2] + domain1.pop()
|
||||||
|
domain2[-1] = domain2[-2] + domain2.pop()
|
||||||
|
domain1 = list(reversed(domain1))
|
||||||
|
domain2 = list(reversed(domain2))
|
||||||
|
return cmp(domain1, domain2)
|
||||||
|
|
||||||
|
result_list = sorted(result_list, cmp_domain)
|
||||||
|
|
||||||
return {'domains': result_list}
|
return {'domains': result_list}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue