mirror of git://gcc.gnu.org/git/gcc.git
check_GNU_style_lib.py: Suggest to install all missing pip3 packages at once
Instead of: ... $ ./contrib/check_GNU_style.py termcolor module is missing (run: pip3 install termcolor) $ pip3 install termcolor $ ./contrib/check_GNU_style.py unidiff module is missing (run: pip3 install unidiff) $ pip3 install unidiff $ ... Do: ... $ ./contrib/check_GNU_style.py termcolor and unidiff modules are missing (run: pip3 install termcolor unidiff) $ pip3 install termcolor unidiff $ ... 2017-05-29 Tom de Vries <tom@codesourcery.com> * check_GNU_style_lib.py: Use import_pip3 to import pip3 packages. (import_pip3): New function. From-SVN: r248554
This commit is contained in:
parent
bbe3927b62
commit
76baf5ca9d
|
|
@ -1,3 +1,8 @@
|
||||||
|
2017-05-29 Tom de Vries <tom@codesourcery.com>
|
||||||
|
|
||||||
|
* check_GNU_style_lib.py: Use import_pip3 to import pip3 packages.
|
||||||
|
(import_pip3): New function.
|
||||||
|
|
||||||
2017-05-24 Tom de Vries <tom@codesourcery.com>
|
2017-05-24 Tom de Vries <tom@codesourcery.com>
|
||||||
|
|
||||||
* check_GNU_style_lib.py: New file, factored out of ...
|
* check_GNU_style_lib.py: New file, factored out of ...
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,29 @@ import sys
|
||||||
import re
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
try:
|
def import_pip3(*args):
|
||||||
from termcolor import colored
|
missing=[]
|
||||||
except ImportError:
|
for (module, names) in args:
|
||||||
print('termcolor module is missing (run: pip3 install termcolor)')
|
try:
|
||||||
exit(3)
|
lib = __import__(module)
|
||||||
|
except ImportError:
|
||||||
|
missing.append(module)
|
||||||
|
continue
|
||||||
|
if not isinstance(names, list):
|
||||||
|
names=[names]
|
||||||
|
for name in names:
|
||||||
|
globals()[name]=getattr(lib, name)
|
||||||
|
if len(missing) > 0:
|
||||||
|
missing_and_sep = ' and '.join(missing)
|
||||||
|
missing_space_sep = ' '.join(missing)
|
||||||
|
print('%s %s missing (run: pip3 install %s)'
|
||||||
|
% (missing_and_sep,
|
||||||
|
("module is" if len(missing) == 1 else "modules are"),
|
||||||
|
missing_space_sep))
|
||||||
|
exit(3)
|
||||||
|
|
||||||
try:
|
import_pip3(('termcolor', 'colored'),
|
||||||
from unidiff import PatchSet
|
('unidiff', 'PatchSet'))
|
||||||
except ImportError:
|
|
||||||
print('unidiff module is missing (run: pip3 install unidiff)')
|
|
||||||
exit(3)
|
|
||||||
|
|
||||||
from itertools import *
|
from itertools import *
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue