[svn r51329] rename special __package__ to __pkg__ because python 2.6 needs the former

(thanks to Ralf Schmitt)

--HG--
branch : trunk
This commit is contained in:
hpk 2008-02-08 09:43:05 +01:00
parent 37d357ff4c
commit f3f84fa36c
11 changed files with 32 additions and 30 deletions

View File

@ -16,7 +16,7 @@ from py.__.apigen.tracer import model
sorted = py.builtin.sorted sorted = py.builtin.sorted
def pkg_to_dict(module): def pkg_to_dict(module):
defs = module.__package__.exportdefs defs = module.__pkg__.exportdefs
d = {} d = {}
for key, value in defs.iteritems(): for key, value in defs.iteritems():
chain = key.split('.') chain = key.split('.')
@ -33,7 +33,7 @@ def get_star_import_tree(module, modname):
""" deal with '*' entries in an initpkg situation """ """ deal with '*' entries in an initpkg situation """
ret = {} ret = {}
modpath = py.path.local(inspect.getsourcefile(module)) modpath = py.path.local(inspect.getsourcefile(module))
pkgpath = module.__package__.getpath() pkgpath = module.__pkg__.getpath()
for objname in dir(module): for objname in dir(module):
if objname.startswith('_'): if objname.startswith('_'):
continue # also skip __*__ attributes continue # also skip __*__ attributes
@ -281,8 +281,8 @@ class DocStorageAccessor(AbstractDocStorageAccessor):
return "Lack of module info" return "Lack of module info"
try: try:
retval = module.__doc__ or "*undocumented*" retval = module.__doc__ or "*undocumented*"
retval = module.__package__.description retval = module.__pkg__.description
retval = module.__package__.long_description retval = module.__pkg__.long_description
except AttributeError: except AttributeError:
pass pass
return retval return retval

View File

@ -10,7 +10,7 @@
from _findpy import py from _findpy import py
import py import py
pypath = py.__package__.getpath() pypath = py.__pkg__.getpath()
def run_tests(path, envvars='', args=''): def run_tests(path, envvars='', args=''):
pytestpath = pypath.join('bin/py.test') pytestpath = pypath.join('bin/py.test')

View File

@ -147,9 +147,9 @@ def pytest_remote(address, url):
if __name__ == '__main__': if __name__ == '__main__':
py.magic.invoke(assertion=True) py.magic.invoke(assertion=True)
version = py.std.sys.argv[1] version = py.std.sys.argv[1]
assert py.__package__.version == version, ( assert py.__pkg__.version == version, (
"py package has version %s\nlocation: %s" % "py package has version %s\nlocation: %s" %
(py.__package__.version, pydir)) (py.__pkg__.version, pydir))
tmpdir = py.path.local.get_temproot().join('makepyrelease-%s' % version) tmpdir = py.path.local.get_temproot().join('makepyrelease-%s' % version)
if tmpdir.check(): if tmpdir.check():
@ -171,14 +171,14 @@ if __name__ == '__main__':
py.process.cmdexec("rsync -avz %(source)s/ %(remotedir)s" % locals()) py.process.cmdexec("rsync -avz %(source)s/ %(remotedir)s" % locals())
ddir = tmpdir.ensure('download', dir=1) ddir = tmpdir.ensure('download', dir=1)
URL = py.__package__.download_url # 'http://codespeak.net/download/py/' URL = py.__pkg__.download_url # 'http://codespeak.net/download/py/'
unpacked = unpackremotetar(ddir, URL) unpacked = unpackremotetar(ddir, URL)
assert unpacked == ddir.join("py-%s" % (version,)) assert unpacked == ddir.join("py-%s" % (version,))
#checksvnworks(unpacked) #checksvnworks(unpacked)
#pytest(unpacked) #pytest(unpacked)
pytest_remote('test@codespeak.net', py.__package__.download_url) pytest_remote('test@codespeak.net', py.__pkg__.download_url)

View File

@ -24,7 +24,7 @@ def rsync(pkgpath, apidocspath, gateway, remotepath):
def run_tests(pkgpath, apigenpath, args='', captureouterr=False): def run_tests(pkgpath, apigenpath, args='', captureouterr=False):
""" run the unit tests and build the docs """ """ run the unit tests and build the docs """
pypath = py.__package__.getpath() pypath = py.__pkg__.getpath()
pytestpath = pypath.join('bin/py.test') pytestpath = pypath.join('bin/py.test')
# XXX this would need a Windows specific version if we want to allow # XXX this would need a Windows specific version if we want to allow
# running this script on that platform, but currently --apigen doesn't # running this script on that platform, but currently --apigen doesn't
@ -82,7 +82,7 @@ if __name__ == '__main__':
args.remove('--ignorefail') args.remove('--ignorefail')
ignorefail = True ignorefail = True
args = ' '.join(sys.argv[1:]) args = ' '.join(sys.argv[1:])
pkgpath = py.__package__.getpath() pkgpath = py.__pkg__.getpath()
apidocspath = pkgpath.dirpath().join('apigen') apidocspath = pkgpath.dirpath().join('apigen')
main(pkgpath, apidocspath, 'codespeak.net', main(pkgpath, apidocspath, 'codespeak.net',
'/home/guido/rsynctests', args, ignorefail) '/home/guido/rsynctests', args, ignorefail)

View File

@ -39,10 +39,12 @@ py.apigen
- refactor to produce intermediate data/files capturing - refactor to produce intermediate data/files capturing
info of test runs info of test runs
- refactor html renderer to work on intermediate - refactor html renderer to work on intermediate
data/files rather than on the live data data/files rather than on the live data
- check out CodeInvestigator
http://codeinvestigator.googlepages.com/main
ld (review and shift to above) ld (review and shift to above)
================================= =================================

View File

@ -311,7 +311,7 @@ def resolve_linkrole(name, text, check=True):
'to the py package') % (text,) 'to the py package') % (text,)
relpath = '/'.join(text.split('/')[1:]) relpath = '/'.join(text.split('/')[1:])
if check: if check:
pkgroot = py.__package__.getpath() pkgroot = py.__pkg__.getpath()
abspath = pkgroot.join(relpath) abspath = pkgroot.join(relpath)
assert pkgroot.join(relpath).check(), ( assert pkgroot.join(relpath).check(), (
'problem with linkrole :source:`%s`: ' 'problem with linkrole :source:`%s`: '

View File

@ -38,9 +38,9 @@ class Package(object):
self.name = name self.name = name
self.exportdefs = exportdefs self.exportdefs = exportdefs
self.module = pkgmodule self.module = pkgmodule
assert not hasattr(pkgmodule, '__package__'), \ assert not hasattr(pkgmodule, '__pkg__'), \
"unsupported reinitialization of %r" % pkgmodule "unsupported reinitialization of %r" % pkgmodule
pkgmodule.__package__ = self pkgmodule.__pkg__ = self
# make available pkgname.__ # make available pkgname.__
implname = name + '.' + '__' implname = name + '.' + '__'
@ -134,7 +134,7 @@ class Package(object):
from cStringIO import StringIO from cStringIO import StringIO
except ImportError: except ImportError:
from StringIO import StringIO from StringIO import StringIO
base = py.__package__.getpath().dirpath() base = py.__pkg__.getpath().dirpath()
outf = StringIO() outf = StringIO()
f = zipfile.ZipFile(outf, 'w', compression=zipfile.ZIP_DEFLATED) f = zipfile.ZipFile(outf, 'w', compression=zipfile.ZIP_DEFLATED)
try: try:
@ -164,14 +164,14 @@ def setmodule(modpath, module):
class Module(ModuleType): class Module(ModuleType):
def __init__(self, pkg, name): def __init__(self, pkg, name):
self.__package__ = pkg self.__pkg__ = pkg
self.__name__ = name self.__name__ = name
self.__map__ = {} self.__map__ = {}
def __getattr__(self, name): def __getattr__(self, name):
if '*' in self.__map__: if '*' in self.__map__:
extpy = self.__map__['*'][0], name extpy = self.__map__['*'][0], name
result = self.__package__._resolve(extpy) result = self.__pkg__._resolve(extpy)
else: else:
try: try:
extpy = self.__map__[name] extpy = self.__map__[name]
@ -179,7 +179,7 @@ class Module(ModuleType):
__tracebackhide__ = True __tracebackhide__ = True
raise AttributeError(name) raise AttributeError(name)
else: else:
result = self.__package__._resolve(extpy) result = self.__pkg__._resolve(extpy)
del self.__map__[name] del self.__map__[name]
setattr(self, name, result) setattr(self, name, result)
#self._fixinspection(result, name) #self._fixinspection(result, name)
@ -216,7 +216,7 @@ class Module(ModuleType):
assert not self.__map__, "%r not empty" % self.__map__ assert not self.__map__, "%r not empty" % self.__map__
else: else:
fsname = self.__map__['*'][0] fsname = self.__map__['*'][0]
dict.update(self.__package__._loadimpl(fsname[:-3]).__dict__) dict.update(self.__pkg__._loadimpl(fsname[:-3]).__dict__)
return dict return dict
__dict__ = property(getdict) __dict__ = property(getdict)

View File

@ -144,7 +144,7 @@ def setup(pkg, **kw):
params = Params(pkg) params = Params(pkg)
#dump(params) #dump(params)
source = getattr(pkg, '__package__', pkg) source = getattr(pkg, '__pkg__', pkg)
namelist = list(core.setup_keywords) namelist = list(core.setup_keywords)
namelist.extend(['packages', 'scripts', 'data_files']) namelist.extend(['packages', 'scripts', 'data_files'])
for name in namelist: for name in namelist:

View File

@ -33,7 +33,7 @@ def test_early__dict__access():
def test_resolve_attrerror(): def test_resolve_attrerror():
extpyish = "./initpkg.py", "hello" extpyish = "./initpkg.py", "hello"
excinfo = py.test.raises(AttributeError, "py.__package__._resolve(extpyish)") excinfo = py.test.raises(AttributeError, "py.__pkg__._resolve(extpyish)")
s = str(excinfo.value) s = str(excinfo.value)
assert s.find(extpyish[0]) != -1 assert s.find(extpyish[0]) != -1
assert s.find(extpyish[1]) != -1 assert s.find(extpyish[1]) != -1
@ -83,16 +83,16 @@ def check_import(modpath):
assert __import__(modpath) assert __import__(modpath)
def test_shahexdigest(): def test_shahexdigest():
hex = py.__package__.shahexdigest() hex = py.__pkg__.shahexdigest()
assert len(hex) == 40 assert len(hex) == 40
def test_getzipdata(): def test_getzipdata():
s = py.__package__.getzipdata() s = py.__pkg__.getzipdata()
def test_getrev(): def test_getrev():
if not py.path.local(py.__file__).dirpath('.svn').check(): if not py.path.local(py.__file__).dirpath('.svn').check():
py.test.skip("py package is not a svn checkout") py.test.skip("py package is not a svn checkout")
d = py.__package__.getrev() d = py.__pkg__.getrev()
svnversion = py.path.local.sysfind('svnversion') svnversion = py.path.local.sysfind('svnversion')
if svnversion is None: if svnversion is None:
py.test.skip("cannot test svnversion, 'svnversion' binary not found") py.test.skip("cannot test svnversion, 'svnversion' binary not found")
@ -255,9 +255,9 @@ class TestRealModule:
def test_url_of_version(): def test_url_of_version():
#py.test.skip("FAILING! - provide a proper URL or upload pylib tgz") #py.test.skip("FAILING! - provide a proper URL or upload pylib tgz")
from urllib import URLopener from urllib import URLopener
url = py.__package__.download_url url = py.__pkg__.download_url
if url.lower() == "xxx": if url.lower() == "xxx":
assert py.__package__.version.find("alpha") != -1 assert py.__pkg__.version.find("alpha") != -1
else: else:
URLopener().open(url) URLopener().open(url)

View File

@ -400,8 +400,8 @@ class LocalPath(common.FSPathBase, PlatformMixin):
self._prependsyspath(pkgpath.dirpath()) self._prependsyspath(pkgpath.dirpath())
pkg = __import__(pkgpath.basename, None, None, []) pkg = __import__(pkgpath.basename, None, None, [])
if hasattr(pkg, '__package__'): if hasattr(pkg, '__pkg__'):
modname = pkg.__package__.getimportname(self) modname = pkg.__pkg__.getimportname(self)
assert modname is not None, "package %s doesn't know %s" % ( assert modname is not None, "package %s doesn't know %s" % (
pkg.__name__, self) pkg.__name__, self)

View File

@ -356,7 +356,7 @@ class LocalReporter(AbstractReporter):
self.timestart = item.timestart self.timestart = item.timestart
self.out.line("executable: %s (%s)" % self.out.line("executable: %s (%s)" %
(py.std.sys.executable, repr_pythonversion())) (py.std.sys.executable, repr_pythonversion()))
rev = py.__package__.getrev() rev = py.__pkg__.getrev()
self.out.line("using py lib: %s <rev %s>" % ( self.out.line("using py lib: %s <rev %s>" % (
py.path.local(py.__file__).dirpath(), rev)) py.path.local(py.__file__).dirpath(), rev))
config = item.config config = item.config