Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: third_party/google-endpoints/setuptools/py31compat.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 import sys
2 import unittest
3
4 __all__ = ['get_config_vars', 'get_path']
5
6 try:
7 # Python 2.7 or >=3.2
8 from sysconfig import get_config_vars, get_path
9 except ImportError:
10 from distutils.sysconfig import get_config_vars, get_python_lib
11
12 def get_path(name):
13 if name not in ('platlib', 'purelib'):
14 raise ValueError("Name must be purelib or platlib")
15 return get_python_lib(name == 'platlib')
16
17
18 try:
19 # Python >=3.2
20 from tempfile import TemporaryDirectory
21 except ImportError:
22 import shutil
23 import tempfile
24
25 class TemporaryDirectory(object):
26 """
27 Very simple temporary directory context manager.
28 Will try to delete afterward, but will also ignore OS and similar
29 errors on deletion.
30 """
31
32 def __init__(self):
33 self.name = None # Handle mkdtemp raising an exception
34 self.name = tempfile.mkdtemp()
35
36 def __enter__(self):
37 return self.name
38
39 def __exit__(self, exctype, excvalue, exctrace):
40 try:
41 shutil.rmtree(self.name, True)
42 except OSError: # removal errors are not the only possible
43 pass
44 self.name = None
45
46
47 unittest_main = unittest.main
48
49 _PY31 = (3, 1) <= sys.version_info[:2] < (3, 2)
50 if _PY31:
51 # on Python 3.1, translate testRunner==None to TextTestRunner
52 # for compatibility with Python 2.6, 2.7, and 3.2+
53 def unittest_main(*args, **kwargs):
54 if 'testRunner' in kwargs and kwargs['testRunner'] is None:
55 kwargs['testRunner'] = unittest.TextTestRunner
56 return unittest.main(*args, **kwargs)
OLDNEW
« no previous file with comments | « third_party/google-endpoints/setuptools/py27compat.py ('k') | third_party/google-endpoints/setuptools/py33compat.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698