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
|
Index: pychecker-0.8.17/pychecker/warn.py
===================================================================
--- pychecker-0.8.17.orig/pychecker/warn.py
+++ pychecker-0.8.17/pychecker/warn.py
@@ -391,16 +391,26 @@ def getBlackList(moduleList) :
pass
return blacklist
-def getStandardLibrary() :
+def getStandardLibraries() :
+ """
+ Return a list of standard libraries.
+
+ @rtype: list of str or None
+ """
if cfg().ignoreStandardLibrary :
try :
from distutils import sysconfig
- std_lib = sysconfig.get_python_lib()
- path = os.path.split(std_lib)
- if path[1] == 'site-packages' :
- std_lib = path[0]
- return std_lib
+ std_libs = [
+ sysconfig.get_python_lib(plat_specific=0),
+ sysconfig.get_python_lib(plat_specific=1)
+ ]
+ ret = []
+ for std_lib in std_libs:
+ path = os.path.split(std_lib)
+ if path[1] == 'site-packages' :
+ ret.append(path[0])
+ return ret
except ImportError :
return None
@@ -409,12 +419,20 @@ def normalize_path(path):
def removeWarnings(warnings, blacklist, std_lib, cfg):
if std_lib is not None:
- std_lib = normalize_path(std_lib)
+ std_lib = [normalize_path(p) for p in std_lib]
for index in range(len(warnings)-1, -1, -1) :
filename = normalize_path(warnings[index].file)
- if filename in blacklist or (std_lib is not None and
- utils.startswith(filename, std_lib)) :
+ if filename in blacklist:
del warnings[index]
+ elif std_lib:
+ found = False
+ for path in std_lib:
+ if utils.startswith(filename, path) :
+ del warnings[index]
+ found = True
+ break
+ if found:
+ continue
elif cfg.only:
# ignore files not specified on the cmd line if requested
if os.path.abspath(filename) not in cfg.files:
@@ -721,7 +739,7 @@ def find(moduleList, initialCfg, suppres
std_lib = None
if cfg().ignoreStandardLibrary :
- std_lib = getStandardLibrary()
+ std_lib = getStandardLibraries()
return removeWarnings(warnings, getBlackList(cfg().blacklist), std_lib,
cfg())
|