21 __all__ = [ |
25 __all__ = [ |
22 # imported modules |
26 # imported modules |
23 'os', 're', 'locale', |
27 'os', 're', 'locale', |
24 # version information from VERSION |
28 # version information from VERSION |
25 '__author__', '__date__', '__version__', |
29 '__author__', '__date__', '__version__', |
26 # error codes |
30 # defined stuff |
27 'ENCODING', 'ace2idna', 'check_domainname', 'check_localpart', 'exec_ok', |
31 'ENCODING', 'ace2idna', 'check_domainname', 'check_localpart', 'exec_ok', |
28 'expand_path', 'get_unicode', 'idn2ascii', 'is_dir', |
32 'expand_path', 'get_unicode', 'idn2ascii', 'is_dir', |
29 ] |
33 ] |
30 |
34 |
31 |
35 |
64 return os.path.expanduser(path) |
68 return os.path.expanduser(path) |
65 return path |
69 return path |
66 |
70 |
67 |
71 |
68 def is_dir(path): |
72 def is_dir(path): |
69 """Checks if ``path`` is a directory. |
73 """Checks if `path` is a directory. |
70 |
74 |
71 Throws a `VMMException` if ``path`` is not a directory. |
75 Throws a `VMMException` if `path` is not a directory. |
72 """ |
76 """ |
73 path = expand_path(path) |
77 path = expand_path(path) |
74 if not os.path.isdir(path): |
78 if not os.path.isdir(path): |
75 raise VMMException(_(u'“%s” is not a directory') % |
79 raise VMMException(_(u"'%s' is not a directory") % |
76 get_unicode(path), NO_SUCH_DIRECTORY) |
80 get_unicode(path), NO_SUCH_DIRECTORY) |
77 return path |
81 return path |
78 |
82 |
79 |
83 |
80 def exec_ok(binary): |
84 def exec_ok(binary): |
81 """Checks if the ``binary`` exists and if it is executable. |
85 """Checks if the `binary` exists and if it is executable. |
82 |
86 |
83 Throws a `VMMException` if the ``binary`` isn't a file or is not |
87 Throws a `VMMException` if the `binary` isn't a file or is not |
84 executable. |
88 executable. |
85 """ |
89 """ |
86 binary = expand_path(binary) |
90 binary = expand_path(binary) |
87 if not os.path.isfile(binary): |
91 if not os.path.isfile(binary): |
88 raise VMMException(_(u'“%s” is not a file') % get_unicode(binary), |
92 raise VMMException(_(u"'%s' is not a file") % get_unicode(binary), |
89 NO_SUCH_BINARY) |
93 NO_SUCH_BINARY) |
90 if not os.access(binary, os.X_OK): |
94 if not os.access(binary, os.X_OK): |
91 raise VMMException(_(u'File is not executable: “%s”') % |
95 raise VMMException(_(u"File is not executable: '%s'") % |
92 get_unicode(binary), NOT_EXECUTABLE) |
96 get_unicode(binary), NOT_EXECUTABLE) |
93 return binary |
97 return binary |
94 |
98 |
95 |
99 |
96 def idn2ascii(domainname): |
100 def idn2ascii(domainname): |