4 #===============================================================================
5 # Define global imports
6 #===============================================================================
12 from . import constants
15 #===============================================================================
16 # Define module information
17 #===============================================================================
18 __author__
= constants
.__author
__
19 __license__
= constants
.__license
__
20 __copyright__
= constants
.__copyright
__
23 #===============================================================================
24 # Define global constants
25 #===============================================================================
26 PYTHON3
= constants
.PYTHON3
31 UTILS
= constants
.UTILS
32 MODES
= constants
.MODES
33 TESTS
= constants
.TESTS
34 compiler
= constants
.compiler
35 joinpath
= constants
.joinpath
36 cleaner
= constants
.cleaner
37 string
= constants
.string
40 isfile
= os
.path
.isfile
41 normpath
= os
.path
.normpath
42 relpath
= os
.path
.relpath
45 #===============================================================================
46 # Define GLError class
47 #===============================================================================
48 class GLError(Exception):
49 '''Exception handler for pygnulib classes.'''
51 def __init__(self
, errno
, errinfo
=None):
52 '''Each error has following parameters:
53 errno: code of error; used to catch error type
54 1: file does not exist in GLFileSystem: <file>
55 2: cannot patch file inside GLFileSystem: <file>
56 3: configure file does not exist: <configure.ac>
57 4: minimum supported autoconf version is 2.59, not <version>
58 5: <gnulib-comp.m4> is expected to contain gl_M4_BASE([<m4base>])
59 6: missing sourcebase argument
60 7: missing docbase argument
61 8: missing testsbase argument
62 9: missing libname argument
63 10: conddeps are not supported with inctests
64 11: incompatible licenses on modules: <modules>
65 12: cannot process empy filelist
66 13: cannot create the given directory: <directory>
67 14: cannot delete the given file: <file>
68 15: cannot create the given file: <file>
69 16: cannot transform the given file: <file>
70 17: cannot update the given file: <file>
71 18: module lacks a license: <module>
72 19: could not create destination directory: <directory>
73 errinfo: additional information;
74 style: 0 or 1, wheter old-style'''
76 self
.errinfo
= errinfo
77 self
.args
= (self
.errno
, self
.errinfo
)
80 errinfo
= self
.errinfo
82 [ # Begin list of errors
83 "file does not exist in GLFileSystem: %s" % repr(errinfo
),
84 "cannot patch file inside GLFileSystem: %s" % repr(errinfo
),
85 "configure file does not exist: %s" % repr(errinfo
),
86 "minimum supported autoconf version is 2.59, not %s" % repr(
88 "%s is expected to contain gl_M4_BASE([%s])" % \
89 (repr(os
.path
.join(errinfo
, 'gnulib-comp.m4')), repr(errinfo
)),
90 "missing sourcebase argument; cache file doesn't contain it,"
91 + " so you might have to set this argument",
92 "missing docbase argument; you might have to create GLImport" \
93 + " instance with mode 0 and docbase argument",
94 "missing testsbase argument; cache file doesn't contain it,"
95 + " so you might have to set this argument"
96 "missing libname argument; cache file doesn't contain it,"
97 + " so you might have to set this argument",
98 "conddeps are not supported with inctests",
99 "incompatible licenses on modules: %s" % repr(errinfo
),
100 "cannot process empy filelist",
101 "cannot create the given directory: %s" % repr(errinfo
),
102 "cannot remove the given file: %s" % repr(errinfo
),
103 "cannot create the given file: %s" % repr(errinfo
),
104 "cannot transform the given file: %s" % repr(errinfo
),
105 "cannot update/replace the given file: %s" % repr(errinfo
),
106 "module lacks a license: %s" % repr(errinfo
),
107 "error when running subprocess: %s" % repr(errinfo
),
108 ] # Complete list of errors
110 self
.message
= (b
'[Errno %d] %s' %
111 (self
.errno
, errors
[self
.errno
- 1].encode(ENCS
['default'])))
113 self
.message
= ('[Errno %d] %s' %
114 (self
.errno
, errors
[self
.errno
- 1]))