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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# HG changeset patch
# User Alad Wenter <alad@archlinux.org>
# Date 1565311059 -7200
# Fri Aug 09 02:37:39 2019 +0200
# Node ID e92452338b542c3626f81db079610753f723c9b9
# Parent bf25f416f615a43267abecab4c599e86f363438b
python3: syntax changes
diff -r bf25f416f615 -r e92452338b54 asoundconf
--- a/asoundconf Sun May 31 20:26:03 2015 +0200
+++ b/asoundconf Fri Aug 09 02:37:39 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python3
# (C) 2005 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
@@ -98,7 +98,7 @@
open(our_conf_file, 'w').write(our_conf_header)
return True
except IOError:
- print >> sys.stderr, 'Error: could not create', our_conf_file
+ print('Error: could not create', our_conf_file, file=sys.stderr)
return False
@@ -116,7 +116,7 @@
open(asoundrc_file, 'w').write('%s\n%s\n<%s>\n\n' % (asoundrc_header, inclusion_comment, our_conf_file))
return True
except IOError:
- print >> sys.stderr, 'Error: could not create', asoundrc_file
+ print('Error: could not create', asoundrc_file, file=sys.stderr)
return False
@@ -229,7 +229,7 @@
for line in open(our_conf_file):
m = setting_re.match(line)
if m:
- print m.group(1).strip()
+ print(m.group(1).strip())
return True
return False
except IOError:
@@ -245,9 +245,9 @@
except IOError:
return False
- print "Names of available sound cards:"
+ print("Names of available sound cards:")
for cardname in card_lines:
- print cardname.id_
+ print(cardname.id_)
return True
@@ -262,13 +262,13 @@
except IOError:
return False
- print "Available devices for all sound cards:"
+ print("Available devices for all sound cards:")
for dev in dev_lines:
card = next(c for c in card_lines if c.card_num == dev.card_num) # find card by number
- print "hw:%d,%d: %s : %s : %s : %s" % (
+ print('hw:{},{}: {} : {} : {} : {}'.format(
dev.card_num, dev.dev_num,
card.id_, card.name,
- dev.id_, dev.name)
+ dev.id_, dev.name))
return True
@@ -294,7 +294,7 @@
return False
found = 0
- for i in xrange(len(lines)):
+ for i in range(len(lines)):
if setting_re.match(lines[i]):
del lines[i]
found = 1
@@ -340,7 +340,7 @@
# if setting is already present, change it
found = 0
- for i in xrange(len(lines)):
+ for i in range(len(lines)):
if setting_re.match(lines[i]):
lines[i] = newsetting
found = 1
@@ -426,10 +426,10 @@
##
if os.geteuid() == 0:
- print superuser_warn
+ print(superuser_warn)
if len(sys.argv) < 2 or sys.argv[1] == '--help' or sys.argv[1] == '-h':
- print usage
+ print(usage)
sys.exit(0)
if sys.argv[1] == 'is-active':
@@ -437,19 +437,19 @@
if sys.argv[1] == 'get':
if len(sys.argv) != 3:
- print usage
+ print(usage)
sys.exit(1)
exit_code(get(sys.argv[2]))
if sys.argv[1] == 'delete':
if len(sys.argv) != 3:
- print usage
+ print(usage)
sys.exit(1)
exit_code(delete(sys.argv[2]))
if sys.argv[1] == 'set':
if len(sys.argv) != 4:
- print usage
+ print(usage)
sys.exit(1)
exit_code(set(sys.argv[2], sys.argv[3]))
@@ -461,7 +461,7 @@
if sys.argv[1] == 'set-default-card':
if len(sys.argv) != 3:
- print needs_default_card
+ print(needs_default_card)
sys.exit(1)
exit_code(set_default_card(sys.argv[2]))
@@ -476,13 +476,13 @@
if sys.argv[1] == 'set-oss':
if len(sys.argv) != 3:
- print needs_oss_dev
+ print(needs_oss_dev)
sys.exit(1)
exit_code(set_oss(sys.argv[2]))
if sys.argv[1] == 'unset-oss':
exit_code(unset_oss())
-print usage
+print(usage)
sys.exit(1)
diff -r bf25f416f615 -r e92452338b54 asoundconf_common.py
--- a/asoundconf_common.py Sun May 31 20:26:03 2015 +0200
+++ b/asoundconf_common.py Fri Aug 09 02:37:39 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python3
# License: GNU General Public License, version 2 or any later version
#
@@ -38,6 +38,7 @@
lines = procfile.readlines()
for l in lines:
+ l = l.decode()
if cardline.match(l):
groups = cardline.match(l).groups()
c = SndCardInfo()
@@ -62,6 +63,7 @@
lines = procfile.readlines()
for l in lines:
+ l = l.decode()
fields = l.split(':')
if len(fields) >= 3:
if devnum.match(fields[0]):
@@ -73,4 +75,4 @@
d.name = fields[2].strip()
dev_lines.append(d)
- return dev_lines
\ No newline at end of file
+ return dev_lines
diff -r bf25f416f615 -r e92452338b54 setup.py
--- a/setup.py Sun May 31 20:26:03 2015 +0200
+++ b/setup.py Fri Aug 09 02:37:39 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
import os, sys
|