mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #860 from cyxae/enh-1355-sort-alphabetically-domains
[enh] Sort alphabetically the domain list
This commit is contained in:
commit
f36a17d645
1 changed files with 15 additions and 0 deletions
|
@ -59,8 +59,23 @@ def domain_list(exclude_subdomains=False):
|
|||
parent_domain = domain.split(".", 1)[1]
|
||||
if parent_domain in result:
|
||||
continue
|
||||
|
||||
result_list.append(domain)
|
||||
|
||||
|
||||
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}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue