Commit 243d5427 authored by Jason R. Coombs's avatar Jason R. Coombs

Move imports into header

--HG--
extra : amend_source : 371b48777dba5d8a4d62b5899944471752f830bd
extra : histedit_source : 0739a1da7f11a5f6e348a34b203a9328d0bc0f22
parent 088a7a48
...@@ -30,6 +30,9 @@ import symbol ...@@ -30,6 +30,9 @@ import symbol
import operator import operator
import platform import platform
import collections import collections
import plistlib
import email.parser
import tempfile
from pkgutil import get_importer from pkgutil import get_importer
try: try:
...@@ -234,11 +237,9 @@ def get_provider(moduleOrReq): ...@@ -234,11 +237,9 @@ def get_provider(moduleOrReq):
def _macosx_vers(_cache=[]): def _macosx_vers(_cache=[]):
if not _cache: if not _cache:
import platform
version = platform.mac_ver()[0] version = platform.mac_ver()[0]
# fallback for MacPorts # fallback for MacPorts
if version == '': if version == '':
import plistlib
plist = '/System/Library/CoreServices/SystemVersion.plist' plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist): if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'): if hasattr(plistlib, 'readPlist'):
...@@ -2576,9 +2577,8 @@ class DistInfoDistribution(Distribution): ...@@ -2576,9 +2577,8 @@ class DistInfoDistribution(Distribution):
try: try:
return self._pkg_info return self._pkg_info
except AttributeError: except AttributeError:
from email.parser import Parser
metadata = self.get_metadata(self.PKG_INFO) metadata = self.get_metadata(self.PKG_INFO)
self._pkg_info = Parser().parsestr(metadata) self._pkg_info = email.parser.Parser().parsestr(metadata)
return self._pkg_info return self._pkg_info
@property @property
...@@ -2646,8 +2646,7 @@ def issue_warning(*args,**kw): ...@@ -2646,8 +2646,7 @@ def issue_warning(*args,**kw):
level += 1 level += 1
except ValueError: except ValueError:
pass pass
from warnings import warn warnings.warn(stacklevel = level+1, *args, **kw)
warn(stacklevel = level+1, *args, **kw)
def parse_requirements(strs): def parse_requirements(strs):
...@@ -2840,12 +2839,11 @@ def split_sections(s): ...@@ -2840,12 +2839,11 @@ def split_sections(s):
yield section, content yield section, content
def _mkstemp(*args,**kw): def _mkstemp(*args,**kw):
from tempfile import mkstemp
old_open = os.open old_open = os.open
try: try:
# temporarily bypass sandboxing # temporarily bypass sandboxing
os.open = os_open os.open = os_open
return mkstemp(*args,**kw) return tempfile.mkstemp(*args,**kw)
finally: finally:
# and then put it back # and then put it back
os.open = old_open os.open = old_open
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment