Skip to content

Commit 323099c

Browse files
committed
Initial 2to3 pass
1 parent b2e7217 commit 323099c

6 files changed

Lines changed: 39 additions & 42 deletions

File tree

example/_find_fuse_parts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
try:
1212
import fuse
1313
except ImportError:
14-
raise RuntimeError, """
14+
raise RuntimeError("""
1515
1616
! Got exception:
1717
""" + "".join([ "> " + x for x in format_exception(*sys.exc_info()) ]) + """
1818
! Have you ran `python setup.py build'?
1919
!
2020
! We've done our best to find the necessary components of the FUSE bindings
2121
! even if it's not installed, we've got no clue what went wrong for you...
22-
"""
22+
""")

example/hello.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818

1919
if not hasattr(fuse, '__version__'):
20-
raise RuntimeError, \
21-
"your fuse-py doesn't know of fuse.__version__, probably it's too old."
20+
raise RuntimeError("your fuse-py doesn't know of fuse.__version__, probably it's too old.")
2221

2322
fuse.fuse_python_api = (0, 2)
2423

@@ -43,10 +42,10 @@ class HelloFS(Fuse):
4342
def getattr(self, path):
4443
st = MyStat()
4544
if path == '/':
46-
st.st_mode = stat.S_IFDIR | 0755
45+
st.st_mode = stat.S_IFDIR | 0o755
4746
st.st_nlink = 2
4847
elif path == hello_path:
49-
st.st_mode = stat.S_IFREG | 0444
48+
st.st_mode = stat.S_IFREG | 0o444
5049
st.st_nlink = 1
5150
st.st_size = len(hello_str)
5251
else:

example/xmp.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222

2323
if not hasattr(fuse, '__version__'):
24-
raise RuntimeError, \
25-
"your fuse-py doesn't know of fuse.__version__, probably it's too old."
24+
raise RuntimeError("your fuse-py doesn't know of fuse.__version__, probably it's too old.")
2625

2726
fuse.fuse_python_api = (0, 2)
2827

@@ -269,7 +268,7 @@ def main():
269268
if server.fuse_args.mount_expected():
270269
os.chdir(server.root)
271270
except OSError:
272-
print >> sys.stderr, "can't enter root of underlying filesystem"
271+
print("can't enter root of underlying filesystem", file=sys.stderr)
273272
sys.exit(1)
274273

275274
server.main()

fuse.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __getenv__(var, pattern = '.', trans = lambda x: x):
5656
rpat = re.compile(rpat)
5757
if not rpat.search(val):
5858
raise RuntimeError("env var %s doesn't match required pattern %s" % \
59-
(var, `pattern`))
59+
(var, repr(pattern)))
6060
return trans(val)
6161

6262
def get_fuse_python_api():
@@ -134,12 +134,12 @@ def assemble(self):
134134
args = [sys.argv and sys.argv[0] or "python"]
135135
if self.mountpoint:
136136
args.append(self.mountpoint)
137-
for m, v in self.modifiers.iteritems():
137+
for m, v in self.modifiers.items():
138138
if v:
139139
args.append(self.fuse_modifiers[m])
140140

141141
opta = []
142-
for o, v in self.optdict.iteritems():
142+
for o, v in self.optdict.items():
143143
opta.append(o + '=' + v)
144144
opta.extend(self.optlist)
145145

@@ -283,15 +283,15 @@ def __init__(self, *args, **kw):
283283

284284
if dsd == 'whine':
285285
def dsdcb(option, opt_str, value, parser):
286-
raise RuntimeError, """
286+
raise RuntimeError("""
287287
288288
! If you want the "-s" option to work, pass
289289
!
290290
! dash_s_do='setsingle'
291291
!
292292
! to the Fuse constructor. See docstring of the FuseOptParse class for an
293293
! explanation why is it not set by default.
294-
"""
294+
""")
295295

296296
elif dsd == 'setsingle':
297297
def dsdcb(option, opt_str, value, parser):
@@ -300,7 +300,7 @@ def dsdcb(option, opt_str, value, parser):
300300
elif dsd == 'undef':
301301
dsdcb = None
302302
else:
303-
raise ArgumentError, "key `dash_s_do': uninterpreted value " + str(dsd)
303+
raise ArgumentError("key `dash_s_do': uninterpreted value " + str(dsd))
304304

305305
if dsdcb:
306306
self.add_option('-s', action='callback', callback=dsdcb,
@@ -313,11 +313,11 @@ def exit(self, status=0, msg=None):
313313

314314
def error(self, msg):
315315
SubbedOptParse.error(self, msg)
316-
raise OptParseError, msg
316+
raise OptParseError(msg)
317317

318318
def print_help(self, file=sys.stderr):
319319
SubbedOptParse.print_help(self, file)
320-
print >> file
320+
print(file=file)
321321
self.fuse_args.setmod('showhelp')
322322

323323
def print_version(self, file=sys.stderr):
@@ -359,8 +359,8 @@ def __init__(self, func):
359359

360360
def __call__(self, *args, **kw):
361361
try:
362-
return apply(self.func, args, kw)
363-
except (IOError, OSError), detail:
362+
return self.func(*args, **kw)
363+
except (IOError, OSError) as detail:
364364
# Sometimes this is an int, sometimes an instance...
365365
if hasattr(detail, "errno"): detail = detail.errno
366366
return -detail
@@ -578,7 +578,7 @@ def resolve(args, maxva):
578578
mag = ma.groups()
579579
fp = re.compile(mag[1])
580580
neg = bool(mag[0])
581-
for f in fmap.keys() + [ 'has_' + a for a in Fuse._attrs ]:
581+
for f in list(fmap.keys()) + [ 'has_' + a for a in Fuse._attrs ]:
582582
if neg != bool(re.search(fp, f)):
583583
yield f
584584
continue
@@ -663,11 +663,11 @@ def __init__(self, *args, **kw):
663663
"""
664664

665665
if not fuse_python_api:
666-
raise RuntimeError, __name__ + """.fuse_python_api not defined.
666+
raise RuntimeError(__name__ + """.fuse_python_api not defined.
667667
668668
! Please define """ + __name__ + """.fuse_python_api internally (eg.
669669
!
670-
! (1) """ + __name__ + """.fuse_python_api = """ + `FUSE_PYTHON_API_VERSION` + """
670+
! (1) """ + __name__ + """.fuse_python_api = """ + repr(FUSE_PYTHON_API_VERSION) + """
671671
!
672672
! ) or in the enviroment (eg.
673673
!
@@ -678,22 +678,21 @@ def __init__(self, *args, **kw):
678678
! If you are actually developing a filesystem, probably (1) is the way to go.
679679
! If you are using a filesystem written before 2007 Q2, probably (2) is what
680680
! you want."
681-
"""
681+
""")
682682

683683
def malformed():
684-
raise RuntimeError, \
685-
"malformatted fuse_python_api value " + `fuse_python_api`
684+
raise RuntimeError("malformatted fuse_python_api value " + repr(fuse_python_api))
686685
if not isinstance(fuse_python_api, tuple):
687686
malformed()
688687
for i in fuse_python_api:
689688
if not isinstance(i, int) or i < 0:
690689
malformed()
691690

692691
if fuse_python_api > FUSE_PYTHON_API_VERSION:
693-
raise RuntimeError, """
694-
! You require FUSE-Python API version """ + `fuse_python_api` + """.
695-
! However, the latest available is """ + `FUSE_PYTHON_API_VERSION` + """.
696-
"""
692+
raise RuntimeError("""
693+
! You require FUSE-Python API version """ + repr(fuse_python_api) + """.
694+
! However, the latest available is """ + repr(FUSE_PYTHON_API_VERSION) + """.
695+
""")
697696

698697
self.fuse_args = \
699698
'fuse_args' in kw and kw.pop('fuse_args') or FuseArgs()
@@ -719,7 +718,7 @@ def parse(self, *args, **kw):
719718

720719
ev = 'errex' in kw and kw.pop('errex')
721720
if ev and not isinstance(ev, int):
722-
raise TypeError, "error exit value should be an integer"
721+
raise TypeError("error exit value should be an integer")
723722

724723
try:
725724
self.cmdline = self.parser.parse_args(*args, **kw)
@@ -893,7 +892,7 @@ def __getattr__(self, meth):
893892
if m:
894893
return m
895894

896-
raise AttributeError, "Fuse instance has no attribute '%s'" % meth
895+
raise AttributeError("Fuse instance has no attribute '%s'" % meth)
897896

898897

899898

fuseparts/subbedopts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self):
3030
def _str_core(self):
3131

3232
sa = []
33-
for k, v in self.optdict.iteritems():
33+
for k, v in self.optdict.items():
3434
sa.append(str(k) + '=' + str(v))
3535

3636
ra = (list(self.optlist) + sa) or ["(none)"]
@@ -47,7 +47,7 @@ def canonify(self):
4747
with True value to optlist, stringify other values.
4848
"""
4949

50-
for k, v in self.optdict.iteritems():
50+
for k, v in self.optdict.items():
5151
if v == False:
5252
self.optdict.pop(k)
5353
elif v == True:
@@ -84,7 +84,7 @@ def add(self, opt, val=None):
8484

8585
if (v):
8686
if val != None:
87-
raise AttributeError, "ambiguous option value"
87+
raise AttributeError("ambiguous option value")
8888
val = v
8989

9090
if val == False:

setup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def run_command(self, command):
3636
if command == 'sdist':
3737
for f in ('Changelog', 'README.new_fusepy_api.html'):
3838
if not os.path.exists(f):
39-
raise RuntimeError, 'file ' + `f` + \
40-
" doesn't exist, please generate it before creating a source distribution"
39+
raise RuntimeError('file ' + repr(f) + \
40+
" doesn't exist, please generate it before creating a source distribution")
4141

4242
return Distribution.run_command(self, command)
4343

@@ -57,12 +57,12 @@ def run_command(self, command):
5757

5858
else:
5959
if os.system('pkg-config --usage 2> /dev/null') == 0:
60-
print """pkg-config could not find fuse:
60+
print("""pkg-config could not find fuse:
6161
you might need to adjust PKG_CONFIG_PATH or your
62-
FUSE installation is very old (older than 2.1-pre1)"""
62+
FUSE installation is very old (older than 2.1-pre1)""")
6363

6464
else:
65-
print "pkg-config unavailable, build terminated"
65+
print("pkg-config unavailable, build terminated")
6666
sys.exit(1)
6767

6868
# there must be an easier way to set up these flags!
@@ -72,7 +72,7 @@ def run_command(self, command):
7272
libsonly = [x[2:] for x in libs.split() if x[0:2] == '-l']
7373

7474
try:
75-
import thread
75+
import _thread
7676
except ImportError:
7777
# if our Python doesn't have thread support, we enforce
7878
# linking against libpthread so that libfuse's pthread
@@ -93,13 +93,13 @@ def run_command(self, command):
9393
if sys.version_info < (2, 3):
9494
_setup = setup
9595
def setup(**kwargs):
96-
if kwargs.has_key("classifiers"):
96+
if "classifiers" in kwargs:
9797
del kwargs["classifiers"]
9898
_setup(**kwargs)
9999
setup (name = 'fuse-python',
100100
version = __version__,
101101
description = 'Bindings for FUSE',
102-
classifiers = filter(None, classifiers.split("\n")),
102+
classifiers = [_f for _f in classifiers.split("\n") if _f],
103103
license = 'LGPL',
104104
platforms = ['posix'],
105105
url = 'http://fuse.sourceforge.net/wiki/index.php/FusePython',

0 commit comments

Comments
 (0)