This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
oneandoneemailconfig.py
79 lines (64 loc) · 2.91 KB
/
oneandoneemailconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
# coding=utf-8
"""Module to handle all the 1&1 Email Manager Config to make it usable for
every country where 1&1 provides his services"""
class OneAndOneConfig(object):
"""Config Class of 1&1 Email Accoutn Manager : it defines all the URL
used by the manager"""
# 1&1 Control Panel URL
baseURL = {
'loginURL' : 'https://{loginDom}/',
'createEmailURL': 'https://{CPDom}/create-basic-email',
'listEmailURL': 'https://{CPDom}/CenterCommunication?'\
'__render_href=txt/pages/CenterCommunication.xml&__render_part='\
'table-component-body&__render_module=frontend-common&page.size='\
'{size}&page.page={page}',
'pageCountURL': 'https://{CPDom}/CenterCommunication?'\
'__render_href=txt/pages/CenterCommunication.xml&__render_part='\
'email-overview-pagination-content&__render_module='\
'frontend-common&page.size={size}&page.page={page}&'\
'__reuse=1488715767183.__renderinclude__',
'deleteMailboxURL' : 'https://{CPDom}/email-delete-account',
'deleteRedirectURL' : 'https://{CPDom}/email-delete-account',
'accountDetailsURL': 'https://{CPDom}/email-account-details/mailbox/{id}',
'accountDetailsNameURL': 'https://{CPDom}/email-edit-name/mailbox/{id}',
'redirectDetailsURL': 'https://{CPDom}/email-account-details/forward/{id}',
'exchangeDetailsURL': 'https://{CPDom}/MsexchangeUpdate?id={id}'
}
domainConfig = {
'1and1.fr': {'loginDom': 'account.1and1.fr',
'CPDom': 'clients.1and1.fr'},
'1and1.co.uk': {'loginDom': 'account.1and1.co.uk',
'CPDom': 'my.1and1.co.uk'}
}
domain = None
# Version of the config file
version = '2017-11-30'
def __init__(self, domain):
"""Construstor used to generate the config"""
# Lower the domain and remove the 'www.' to prevent user issues
self.domain = domain.lower().replace('www.', '')
def get_provider(self):
"""Return the current 1and1 provider domain"""
return self.domain
def get_config(self):
"""Get the whole config"""
domain_list = self.domainConfig[self.domain]
config = {}
# get cookie from login page
for key, value in self.baseURL.items():
config[key] = value.format_map(StringFormatter(domain_list))
return config
@classmethod
def get_version(cls):
"""Return the version of the config file"""
return cls.version
class StringFormatter(dict):
"""Class used to format the URL as wanted : replace only the domain, but
keep the other placeholder"""
def __missing__(self, key):
"""In case of a placeholder missing a replacement, returns the
placeholder itself"""
return '{' + key + '}'
if __name__ == "__main__":
print("Module used to config the 1and1-Mail-account-Manager")