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

Side by Side Diff: recipe_engine/third_party/setuptools/py31compat.py

Issue 1344583003: Recipe package system. (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: Recompiled proto Created 5 years, 3 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 def get_path(name):
12 if name not in ('platlib', 'purelib'):
13 raise ValueError("Name must be purelib or platlib")
14 return get_python_lib(name=='platlib')
15
16 try:
17 # Python >=3.2
18 from tempfile import TemporaryDirectory
19 except ImportError:
20 import shutil
21 import tempfile
22 class TemporaryDirectory(object):
23 """"
24 Very simple temporary directory context manager.
25 Will try to delete afterward, but will also ignore OS and similar
26 errors on deletion.
27 """
28 def __init__(self):
29 self.name = None # Handle mkdtemp raising an exception
30 self.name = tempfile.mkdtemp()
31
32 def __enter__(self):
33 return self.name
34
35 def __exit__(self, exctype, excvalue, exctrace):
36 try:
37 shutil.rmtree(self.name, True)
38 except OSError: #removal errors are not the only possible
39 pass
40 self.name = None
41
42
43 unittest_main = unittest.main
44
45 _PY31 = (3, 1) <= sys.version_info[:2] < (3, 2)
46 if _PY31:
47 # on Python 3.1, translate testRunner==None to TextTestRunner
48 # for compatibility with Python 2.6, 2.7, and 3.2+
49 def unittest_main(*args, **kwargs):
50 if 'testRunner' in kwargs and kwargs['testRunner'] is None:
51 kwargs['testRunner'] = unittest.TextTestRunner
52 return unittest.main(*args, **kwargs)
OLDNEW
« no previous file with comments | « recipe_engine/third_party/setuptools/py27compat.py ('k') | recipe_engine/third_party/setuptools/sandbox.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698