When the VirtualMailManager module, or one of its sub modules, is imported, the following actions will be performed:
- locale.setlocale() (with locale.LC_ALL) is called, to set ENCODING
- gettext.install() is called, to have 18N support.
The systems current character encoding, e.g. 'UTF-8' or 'ANSI_X3.4-1968' (aka ASCII).
Converts the idn domain name domainname into punycode.
Parameters: | domainname (str) – the domain-ace representation (xn--…) |
---|---|
Return type: | unicode |
Returns the validated domain name domainname.
It also converts the name of the domain from IDN to ASCII, if necessary.
Parameters: | domainname (basestring) – the name of the domain |
---|---|
Return type: | str |
Raises VirtualMailManager.errors.VMMError: | |
if the domain name is too long or doesn’t look like a valid domain name (label.label.label). |
Returns the validated local-part localpart of an e-mail address.
Parameters: | localpart (str) – The local-part of an e-mail address. |
---|---|
Return type: | str |
Raises VirtualMailManager.errors.VMMError: | |
if the local-part is too long or contains invalid characters. |
Checks if the binary exists and if it is executable.
Parameters: | binary (str) – path to the binary |
---|---|
Return type: | str |
Raises VirtualMailManager.errors.VMMError: | |
if binary isn’t a file or is not executable. |
Expands paths, starting with . or ~, to an absolute path.
Parameters: | path (str) – Path to a file or directory |
---|---|
Return type: | str |
Converts string to unicode, if necessary.
Parameters: | string (str) – The string taht should be converted |
---|---|
Return type: | unicode |
Converts the idn domain name domainname into punycode.
Parameters: | domainname (unicode) – the unicode representation of the domain name |
---|---|
Return type: | str |
Checks if path is a directory.
Parameters: | path (str) – Path to a directory |
---|---|
Return type: | str |
Raises VirtualMailManager.errors.VMMError: | |
if path is not a directory. |
>>> from VirtualMailManager import *
>>> ace2idna('xn--pypal-4ve.tld')
u'p\u0430ypal.tld'
>>> idn2ascii(u'öko.de')
'xn--ko-eka.de'
>>> check_domainname(u'pаypal.tld')
'xn--pypal-4ve.tld'
>>> check_localpart('john.doe')
'john.doe'
>>> exec_ok('usr/bin/vim')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./VirtualMailManager/__init__.py", line 93, in exec_ok
NO_SUCH_BINARY)
VirtualMailManager.errors.VMMError: 'usr/bin/vim' is not a file
>>> exec_ok('/usr/bin/vim')
'/usr/bin/vim'
>>> expand_path('.')
'/home/user/hg/vmm'
>>> get_unicode('hello world')
u'hello world'
>>> is_dir('~/hg')
'/home/user/hg'
>>>