summarylogtreecommitdiffstats
path: root/python3.patch
blob: 40863d92621d789e9e62c0c71b9a775fa8b355d0 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--- ./deheader	(original)
+++ ./deheader	(refactored)
@@ -31,7 +31,7 @@
 """
 # SPDX-License-Identifier: BSD-2-Clause
 
-import sys, os, getopt, time, re, operator, commands, subprocess
+import sys, os, getopt, time, re, operator, subprocess, subprocess
 
 BATON_DEBUG    = 1
 PROGRESS_DEBUG = 2
@@ -1244,20 +1244,20 @@
             if not os.path.isdir(root):
                 if excludes and excludes.search(root):
                     if verbose > 1:
-                        print "deheader: %s excluded" % root
+                        print("deheader: %s excluded" % root)
                 elif InclusionMap.c_source(root):
                     self.files.append(root)
                 else:
-                    print >>sys.stderr, "deheader: can't analyze %s" % root
+                    print("deheader: can't analyze %s" % root, file=sys.stderr)
             else:
                 sublist = []
                 for root, dirs, files in os.walk(root):
-                    dirs = filter(lambda x: not x.startswith("."), dirs)
+                    dirs = [x for x in dirs if not x.startswith(".")]
                     for name in files:
                         path = os.path.join(root, name)
                         if excludes and excludes.search(path):
                             if verbose > 1:
-                                print "deheader: %s excluded" % root
+                                print("deheader: %s excluded" % root)
                         elif InclusionMap.c_source(path):
                             sublist.append(path)
                 sublist.sort()
@@ -1280,15 +1280,15 @@
                     if f is not False:
                         if verbosity >= PROGRESS_DEBUG:
                             name = trim(f)
-                            print "deheader: %s includes %s" % (sourcefile, name)
+                            print("deheader: %s includes %s" % (sourcefile, name))
                         if ignore and ignore.search(line):
                             if verbosity >= PROGRESS_DEBUG:
-                                print "deheader: ignoring %s (exclusion match with %s)." % (name, ignore.pattern)
+                                print("deheader: ignoring %s (exclusion match with %s)." % (name, ignore.pattern))
                             continue
                         if not conditions or conditions == ["S_SPLINT_S"]:
                             includes.append(line)
                         elif verbose > 1:
-                            print "deheader: ignoring %s (conditional inclusion)" % name
+                            print("deheader: ignoring %s (conditional inclusion)" % name)
                 for (r, c, h) in compiled:
                     if c.search(line):
                         if not set(h).issubset(set(seen)):
@@ -1302,7 +1302,7 @@
                 trimmedcount[ref] = trimmedcount.get(ref, 0) + 1
             for ref in trimmedcount:
                 if trimmedcount[ref] > 1:
-                    print "deheader: %s has more than one inclusion of %s" % (sourcefile, ref)
+                    print("deheader: %s has more than one inclusion of %s" % (sourcefile, ref))
     def forget(self, sourcefile, header):
         "Forget a header dependency."
         self.depends_on[sourcefile].remove(header)
@@ -1367,7 +1367,7 @@
     if len(subdir) > 0:
         os.chdir(subdir)
     start = time.time()
-    (status, output) = commands.getstatusoutput(command)
+    (status, output) = subprocess.getstatusoutput(command)
     end = time.time()
     os.chdir(olddir)
     if verbosity >= COMMAND_DEBUG or (showerrs and os.WIFEXITED(status) and os.WEXITSTATUS(status) != 0):
@@ -1379,7 +1379,7 @@
     else:
         explain = "succeeded"
     if verbosity >= PROGRESS_DEBUG:
-        print "deheader: %s%s %s." % (source, msg, explain)
+        print("deheader: %s%s %s." % (source, msg, explain))
     if os.path.exists(derived):
         os.remove(derived)
     elif os.path.exists("CMakeList.txt"):
@@ -1406,7 +1406,7 @@
                     for required in requirements:
                         if required in header:
                             if verbosity >= PROGRESS_DEBUG:
-                                print "deheader: in %s, %s prevents uninclusion of %s" % (os.path.join(subdir, sourcefile), trigger, trim(header))
+                                print("deheader: in %s, %s prevents uninclusion of %s" % (os.path.join(subdir, sourcefile), trigger, trim(header)))
                             retain += 1
                 if not retain:
                     saveit.remove_headers(unneeded + [header])
@@ -1423,10 +1423,10 @@
             baton.end()
     # Missing-require detection.  Can't be merged with duplicate-header
     # detection because this has to be done after unneeded headers are removed.
-    stillhere = map(trim, includes)
+    stillhere = list(map(trim, includes))
     for (requirement, trigger) in requires:
         if not set(requirement).issubset(stillhere):
-            print "deheader: in %s, %s portability requires %s." % (os.path.join(subdir, sourcefile), trigger, ",".join(requirement))
+            print("deheader: in %s, %s portability requires %s." % (os.path.join(subdir, sourcefile), trigger, ",".join(requirement)))
     return unneeded
 
 def deheader(sourcefile, maker, includes, requires, remove, verbose):
@@ -1445,7 +1445,7 @@
                                  includes[:], requires, verbose, subdir=subdir)
         if unneeded:
             for line in unneeded:
-                print "deheader: remove %s from %s" % (trim(line), os.path.join(subdir, sourcefile))
+                print("deheader: remove %s from %s" % (trim(line), os.path.join(subdir, sourcefile)))
             if remove:
                 remove_it = SaveForModification(os.path.join(subdir, sourcefile))
                 remove_it.remove_headers(unneeded)
@@ -1453,7 +1453,7 @@
                 del remove_it
         return Summary([sourcefile], includes, unneeded)
     else:
-        print >>sys.stderr, "deheader: basic compilation failed on %s" % (sourcefile,)
+        print("deheader: basic compilation failed on %s" % (sourcefile,), file=sys.stderr)
         return Summary([sourcefile], includes, [])
 
 # After-action analysis starts here
@@ -1501,7 +1501,7 @@
         elif switch in ('-v', '--verbose'):
             verbose += 1
         elif switch in ('-V', '--version'):
-            print "deheader", version
+            print("deheader", version)
             raise SystemExit(0)
         elif switch in ('-x', '--exclude'):
             exclusions.append(val)
@@ -1527,7 +1527,7 @@
         stats = Summary()
         for summary in summaries:
             stats = stats + summary
-        print "deheader: saw", stats
+        print("deheader: saw", stats)
     raise SystemExit(0)
 
 # End