Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07e99cb

Browse files
committed
Whitespace normalization.
1 parent 88869f9 commit 07e99cb

18 files changed

Lines changed: 1991 additions & 1994 deletions

Lib/MimeWriter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MimeWriter:
3030
amounts of buffer space, so you have to write the parts in the
3131
order they should occur on the output file. It does buffer the
3232
headers you add, allowing you to rearrange their order.
33-
33+
3434
General usage is:
3535
3636
f = <open the output file>

Lib/getpass.py

Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -14,106 +14,105 @@
1414
import sys
1515

1616
def unix_getpass(prompt='Password: '):
17-
"""Prompt for a password, with echo turned off.
17+
"""Prompt for a password, with echo turned off.
1818
19-
Restore terminal settings at end.
20-
"""
19+
Restore terminal settings at end.
20+
"""
2121

22-
try:
23-
fd = sys.stdin.fileno()
24-
except:
25-
return default_getpass(prompt)
22+
try:
23+
fd = sys.stdin.fileno()
24+
except:
25+
return default_getpass(prompt)
2626

27-
getpass = default_getpass
28-
old = termios.tcgetattr(fd) # a copy to save
29-
new = old[:]
27+
getpass = default_getpass
28+
old = termios.tcgetattr(fd) # a copy to save
29+
new = old[:]
3030

31-
new[3] = new[3] & ~TERMIOS.ECHO # 3 == 'lflags'
32-
try:
33-
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new)
34-
passwd = _raw_input(prompt)
35-
finally:
36-
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old)
31+
new[3] = new[3] & ~TERMIOS.ECHO # 3 == 'lflags'
32+
try:
33+
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new)
34+
passwd = _raw_input(prompt)
35+
finally:
36+
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old)
3737

38-
sys.stdout.write('\n')
39-
return passwd
38+
sys.stdout.write('\n')
39+
return passwd
4040

4141

4242
def win_getpass(prompt='Password: '):
43-
"""Prompt for password with echo off, using Windows getch()."""
44-
import msvcrt
45-
for c in prompt:
46-
msvcrt.putch(c)
47-
pw = ""
48-
while 1:
49-
c = msvcrt.getch()
50-
if c == '\r' or c == '\n':
51-
break
52-
if c == '\003':
53-
raise KeyboardInterrupt
54-
if c == '\b':
55-
pw = pw[:-1]
56-
else:
57-
pw = pw + c
58-
msvcrt.putch('\r')
59-
msvcrt.putch('\n')
60-
return pw
43+
"""Prompt for password with echo off, using Windows getch()."""
44+
import msvcrt
45+
for c in prompt:
46+
msvcrt.putch(c)
47+
pw = ""
48+
while 1:
49+
c = msvcrt.getch()
50+
if c == '\r' or c == '\n':
51+
break
52+
if c == '\003':
53+
raise KeyboardInterrupt
54+
if c == '\b':
55+
pw = pw[:-1]
56+
else:
57+
pw = pw + c
58+
msvcrt.putch('\r')
59+
msvcrt.putch('\n')
60+
return pw
6161

6262

6363
def default_getpass(prompt='Password: '):
64-
print "Warning: Problem with getpass. Passwords may be echoed."
65-
return _raw_input(prompt)
64+
print "Warning: Problem with getpass. Passwords may be echoed."
65+
return _raw_input(prompt)
6666

6767

6868
def _raw_input(prompt=""):
69-
# A raw_input() replacement that doesn't save the string in the
70-
# GNU readline history.
71-
import sys
72-
prompt = str(prompt)
73-
if prompt:
74-
sys.stdout.write(prompt)
75-
line = sys.stdin.readline()
76-
if not line:
77-
raise EOFError
78-
if line[-1] == '\n':
79-
line = line[:-1]
80-
return line
69+
# A raw_input() replacement that doesn't save the string in the
70+
# GNU readline history.
71+
import sys
72+
prompt = str(prompt)
73+
if prompt:
74+
sys.stdout.write(prompt)
75+
line = sys.stdin.readline()
76+
if not line:
77+
raise EOFError
78+
if line[-1] == '\n':
79+
line = line[:-1]
80+
return line
8181

8282

8383
def getuser():
84-
"""Get the username from the environment or password database.
84+
"""Get the username from the environment or password database.
8585
86-
First try various environment variables, then the password
87-
database. This works on Windows as long as USERNAME is set.
86+
First try various environment variables, then the password
87+
database. This works on Windows as long as USERNAME is set.
8888
89-
"""
89+
"""
9090

91-
import os
91+
import os
9292

93-
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
94-
user = os.environ.get(name)
95-
if user:
96-
return user
93+
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
94+
user = os.environ.get(name)
95+
if user:
96+
return user
9797

98-
# If this fails, the exception will "explain" why
99-
import pwd
100-
return pwd.getpwuid(os.getuid())[0]
98+
# If this fails, the exception will "explain" why
99+
import pwd
100+
return pwd.getpwuid(os.getuid())[0]
101101

102102
# Bind the name getpass to the appropriate function
103103
try:
104-
import termios, TERMIOS
104+
import termios, TERMIOS
105105
except ImportError:
106-
try:
107-
import msvcrt
108-
except ImportError:
109-
try:
110-
from EasyDialogs import AskPassword
111-
except ImportError:
112-
getpass = default_getpass
113-
else:
114-
getpass = AskPassword
115-
else:
116-
getpass = win_getpass
106+
try:
107+
import msvcrt
108+
except ImportError:
109+
try:
110+
from EasyDialogs import AskPassword
111+
except ImportError:
112+
getpass = default_getpass
113+
else:
114+
getpass = AskPassword
115+
else:
116+
getpass = win_getpass
117117
else:
118-
getpass = unix_getpass
119-
118+
getpass = unix_getpass

Lib/gettext.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
_default_localedir = os.path.join(sys.prefix, 'share', 'locale')
5252

5353

54-
54+
5555
def _expand_lang(locale):
5656
from locale import normalize
5757
locale = normalize(locale)
@@ -94,7 +94,7 @@ def _expand_lang(locale):
9494
return ret
9595

9696

97-
97+
9898
class NullTranslations:
9999
def __init__(self, fp=None):
100100
self._info = {}
@@ -192,7 +192,7 @@ def ugettext(self, message):
192192
return unicode(tmsg, self._charset)
193193

194194

195-
195+
196196
# Locate a .mo file using the gettext strategy
197197
def find(domain, localedir=None, languages=None):
198198
# Get some reasonable defaults for arguments that were not supplied
@@ -223,7 +223,7 @@ def find(domain, localedir=None, languages=None):
223223
return None
224224

225225

226-
226+
227227
# a mapping between absolute .mo file path and Translation object
228228
_translations = {}
229229

@@ -243,12 +243,12 @@ def translation(domain, localedir=None, languages=None, class_=None):
243243
return t
244244

245245

246-
246+
247247
def install(domain, localedir=None, unicode=0):
248248
translation(domain, localedir).install(unicode)
249249

250250

251-
251+
252252
# a mapping b/w domains and locale directories
253253
_localedirs = {}
254254
# current global domain, `messages' used for compatibility w/ GNU gettext
@@ -275,7 +275,7 @@ def dgettext(domain, message):
275275
except IOError:
276276
return message
277277
return t.gettext(message)
278-
278+
279279

280280
def gettext(message):
281281
return dgettext(_current_domain, message)

Lib/glob.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@
66

77

88
def glob(pathname):
9-
"""Return a list of paths matching a pathname pattern.
10-
11-
The pattern may contain simple shell-style wildcards a la fnmatch.
12-
13-
"""
14-
if not has_magic(pathname):
15-
if os.path.exists(pathname):
16-
return [pathname]
17-
else:
18-
return []
19-
dirname, basename = os.path.split(pathname)
20-
if has_magic(dirname):
21-
list = glob(dirname)
22-
else:
23-
list = [dirname]
24-
if not has_magic(basename):
25-
result = []
26-
for dirname in list:
27-
if basename or os.path.isdir(dirname):
28-
name = os.path.join(dirname, basename)
29-
if os.path.exists(name):
30-
result.append(name)
31-
else:
32-
result = []
33-
for dirname in list:
34-
sublist = glob1(dirname, basename)
35-
for name in sublist:
36-
result.append(os.path.join(dirname, name))
37-
return result
9+
"""Return a list of paths matching a pathname pattern.
10+
11+
The pattern may contain simple shell-style wildcards a la fnmatch.
12+
13+
"""
14+
if not has_magic(pathname):
15+
if os.path.exists(pathname):
16+
return [pathname]
17+
else:
18+
return []
19+
dirname, basename = os.path.split(pathname)
20+
if has_magic(dirname):
21+
list = glob(dirname)
22+
else:
23+
list = [dirname]
24+
if not has_magic(basename):
25+
result = []
26+
for dirname in list:
27+
if basename or os.path.isdir(dirname):
28+
name = os.path.join(dirname, basename)
29+
if os.path.exists(name):
30+
result.append(name)
31+
else:
32+
result = []
33+
for dirname in list:
34+
sublist = glob1(dirname, basename)
35+
for name in sublist:
36+
result.append(os.path.join(dirname, name))
37+
return result
3838

3939
def glob1(dirname, pattern):
40-
if not dirname: dirname = os.curdir
41-
try:
42-
names = os.listdir(dirname)
43-
except os.error:
44-
return []
45-
result = []
46-
for name in names:
47-
if name[0] != '.' or pattern[0] == '.':
48-
if fnmatch.fnmatch(name, pattern):
49-
result.append(name)
50-
return result
40+
if not dirname: dirname = os.curdir
41+
try:
42+
names = os.listdir(dirname)
43+
except os.error:
44+
return []
45+
result = []
46+
for name in names:
47+
if name[0] != '.' or pattern[0] == '.':
48+
if fnmatch.fnmatch(name, pattern):
49+
result.append(name)
50+
return result
5151

5252

5353
magic_check = re.compile('[*?[]')
5454

5555
def has_magic(s):
56-
return magic_check.search(s) is not None
56+
return magic_check.search(s) is not None

0 commit comments

Comments
 (0)