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
194
195
196
197
198
199
200
201
|
--- paver/deps/path2.py.orig 2014-07-16 12:48:36 UTC
+++ paver/deps/path2.py
@@ -39,10 +39,10 @@ for f in d.files('*.py'):
This module requires Python 2.3 or later.
"""
-from __future__ import generators
-import __builtin__
+import builtins
+
import sys
import warnings
import os
@@ -75,16 +75,16 @@ _base = str
_getcwd = os.getcwd
try:
if os.path.supports_unicode_filenames:
- _base = unicode
- _getcwd = os.getcwdu
+ _base = str
+ _getcwd = os.getcwd
except AttributeError:
pass
# Pre-2.3 workaround for basestring.
try:
- basestring
+ str
except NameError:
- basestring = (str, unicode)
+ str = (str, str)
# Universal newline support
_textmode = 'U'
@@ -116,7 +116,7 @@ class path(_base):
# On python 2, unicode result breaks os.path.join
# if we are inheriting from str
# see https://github.com/paver/paver/issues/78
- if isinstance(resultStr, unicode) and not os.path.supports_unicode_filenames:
+ if isinstance(resultStr, str) and not os.path.supports_unicode_filenames:
resultStr = resultStr.encode('utf-8')
if resultStr is NotImplemented:
@@ -124,7 +124,7 @@ class path(_base):
return self.__class__(resultStr)
def __radd__(self, other):
- if isinstance(other, basestring):
+ if isinstance(other, str):
return self.__class__(other.__add__(self))
else:
return NotImplemented
@@ -604,11 +604,11 @@ class path(_base):
t = f.read()
finally:
f.close()
- return (t.replace(u'\r\n', u'\n')
- .replace(u'\r\x85', u'\n')
- .replace(u'\r', u'\n')
- .replace(u'\x85', u'\n')
- .replace(u'\u2028', u'\n'))
+ return (t.replace('\r\n', '\n')
+ .replace('\r\x85', '\n')
+ .replace('\r', '\n')
+ .replace('\x85', '\n')
+ .replace('\u2028', '\n'))
def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False):
r""" Write the given text to this file.
@@ -674,16 +674,16 @@ class path(_base):
conversion.
"""
- if isinstance(text, unicode):
+ if isinstance(text, str):
if linesep is not None:
# Convert all standard end-of-line sequences to
# ordinary newline characters.
- text = (text.replace(u'\r\n', u'\n')
- .replace(u'\r\x85', u'\n')
- .replace(u'\r', u'\n')
- .replace(u'\x85', u'\n')
- .replace(u'\u2028', u'\n'))
- text = text.replace(u'\n', linesep)
+ text = (text.replace('\r\n', '\n')
+ .replace('\r\x85', '\n')
+ .replace('\r', '\n')
+ .replace('\x85', '\n')
+ .replace('\u2028', '\n'))
+ text = text.replace('\n', linesep)
if encoding is None:
encoding = sys.getdefaultencoding()
bytes = text.encode(encoding, errors)
@@ -766,15 +766,15 @@ class path(_base):
f = self.open(mode)
try:
for line in lines:
- isUnicode = isinstance(line, unicode)
+ isUnicode = isinstance(line, str)
if linesep is not None:
# Strip off any existing line-end and add the
# specified linesep string.
if isUnicode:
- if line[-2:] in (u'\r\n', u'\x0d\x85'):
+ if line[-2:] in ('\r\n', '\x0d\x85'):
line = line[:-2]
- elif line[-1:] in (u'\r', u'\n',
- u'\x85', u'\u2028'):
+ elif line[-1:] in ('\r', '\n',
+ '\x85', '\u2028'):
line = line[:-1]
else:
if line[-2:] == '\r\n':
@@ -893,7 +893,7 @@ class path(_base):
self, win32security.OWNER_SECURITY_INFORMATION)
sid = desc.GetSecurityDescriptorOwner()
account, domain, typecode = win32security.LookupAccountSid(None, sid)
- return domain + u'\\' + account
+ return domain + '\\' + account
else:
if pwd is None:
raise NotImplementedError("path.owner is not implemented on this platform.")
@@ -936,25 +936,25 @@ class path(_base):
#
# --- Create/delete operations on directories
- def mkdir(self, mode=0777):
+ def mkdir(self, mode=0o777):
if not self.exists():
os.mkdir(self, mode)
- def mkdir_p(self, mode=0777):
+ def mkdir_p(self, mode=0o777):
try:
self.mkdir(mode)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
- def makedirs(self, mode=0777):
+ def makedirs(self, mode=0o777):
if not self.exists():
os.makedirs(self, mode)
- def makedirs_p(self, mode=0777):
+ def makedirs_p(self, mode=0o777):
try:
self.makedirs(mode)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
@@ -965,7 +965,7 @@ class path(_base):
def rmdir_p(self):
try:
self.rmdir()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
raise
@@ -976,7 +976,7 @@ class path(_base):
def removedirs_p(self):
try:
self.removedirs()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
raise
@@ -986,7 +986,7 @@ class path(_base):
""" Set the access/modified times of this file to the current time.
Create the file if it does not exist.
"""
- fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0666)
+ fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0o666)
os.close(fd)
os.utime(self, None)
@@ -997,7 +997,7 @@ class path(_base):
def remove_p(self):
try:
self.unlink()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
@@ -1058,7 +1058,7 @@ class path(_base):
def rmtree_p(self):
try:
self.rmtree()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
|