@@ -212,28 +212,7 @@ def _is_writable_dir(p):
212
212
p is a string pointing to a putative writable dir -- return True p
213
213
is such a string, else False
214
214
"""
215
- try :
216
- p + '' # test is string like
217
- except TypeError :
218
- return False
219
-
220
- # Test whether the operating system thinks it's a writable directory.
221
- # Note that this check is necessary on Google App Engine, because the
222
- # subsequent check will succeed even though p may not be writable.
223
- if not os .access (p , os .W_OK ) or not os .path .isdir (p ):
224
- return False
225
-
226
- # Also test that it is actually possible to write to a file here.
227
- try :
228
- t = tempfile .TemporaryFile (dir = p )
229
- try :
230
- t .write (b'1' )
231
- finally :
232
- t .close ()
233
- except :
234
- return False
235
-
236
- return True
215
+ return os .access (p , os .W_OK ) and os .path .isdir (p )
237
216
238
217
239
218
class Verbose (object ):
@@ -509,17 +488,12 @@ def _get_home():
509
488
:see:
510
489
http://mail.python.org/pipermail/python-list/2005-February/325395.html
511
490
"""
512
- try :
513
- if six .PY2 and sys .platform == 'win32' :
514
- path = os .path .expanduser (b"~" ).decode (sys .getfilesystemencoding ())
515
- else :
516
- path = os .path .expanduser ("~" )
517
- except ImportError :
518
- # This happens on Google App Engine (pwd module is not present).
519
- pass
491
+ if six .PY2 and sys .platform == 'win32' :
492
+ path = os .path .expanduser (b"~" ).decode (sys .getfilesystemencoding ())
520
493
else :
521
- if os .path .isdir (path ):
522
- return path
494
+ path = os .path .expanduser ("~" )
495
+ if os .path .isdir (path ):
496
+ return path
523
497
for evar in ('HOME' , 'USERPROFILE' , 'TMP' ):
524
498
path = os .environ .get (evar )
525
499
if path is not None and os .path .isdir (path ):
@@ -531,17 +505,9 @@ def _create_tmp_config_dir():
531
505
"""
532
506
If the config directory can not be created, create a temporary
533
507
directory.
534
-
535
- Returns None if a writable temporary directory could not be created.
536
508
"""
537
- try :
538
- tempdir = tempfile .gettempdir ()
539
- except NotImplementedError :
540
- # Some restricted platforms (such as Google App Engine) do not provide
541
- # gettempdir.
542
- return None
543
509
configdir = os .environ ['MPLCONFIGDIR' ] = (
544
- tempfile .mkdtemp (prefix = 'matplotlib-' , dir = tempdir ))
510
+ tempfile .mkdtemp (prefix = 'matplotlib-' ))
545
511
return configdir
546
512
547
513
0 commit comments