本文整理汇总了Python中IPython.__file__方法的典型用法代码示例。如果您正苦于以下问题:Python IPython.__file__方法的具体用法?Python IPython.__file__怎么用?Python IPython.__file__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython
的用法示例。
在下文中一共展示了IPython.__file__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: teardown_environment
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def teardown_environment():
"""Restore things that were remembered by the setup_environment function
"""
(oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff
os.chdir(old_wd)
reload(path)
for key in env.keys():
if key not in oldenv:
del env[key]
env.update(oldenv)
if hasattr(sys, 'frozen'):
del sys.frozen
if os.name == 'nt':
(wreg.OpenKey, wreg.QueryValueEx,) = platformstuff
# Build decorator that uses the setup_environment/setup_environment
示例2: setup_environment
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def setup_environment():
"""Setup testenvironment for some functions that are tested
in this module. In particular this functions stores attributes
and other things that we need to stub in some test functions.
This needs to be done on a function level and not module level because
each testfunction needs a pristine environment.
"""
global oldstuff, platformstuff
oldstuff = (env.copy(), os.name, sys.platform, path.get_home_dir, IPython.__file__, os.getcwd())
if os.name == 'nt':
platformstuff = (wreg.OpenKey, wreg.QueryValueEx,)
示例3: test_get_home_dir_1
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def test_get_home_dir_1():
"""Testcase for py2exe logic, un-compressed lib
"""
unfrozen = path.get_home_dir()
sys.frozen = True
#fake filename for IPython.__init__
IPython.__file__ = abspath(join(HOME_TEST_DIR, "Lib/IPython/__init__.py"))
home_dir = path.get_home_dir()
nt.assert_equal(home_dir, unfrozen)
示例4: test_get_home_dir_2
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def test_get_home_dir_2():
"""Testcase for py2exe logic, compressed lib
"""
unfrozen = path.get_home_dir()
sys.frozen = True
#fake filename for IPython.__init__
IPython.__file__ = abspath(join(HOME_TEST_DIR, "Library.zip/IPython/__init__.py")).lower()
home_dir = path.get_home_dir(True)
nt.assert_equal(home_dir, unfrozen)
示例5: get_ipython_package_dir
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def get_ipython_package_dir():
"""Get the base directory where IPython itself is installed."""
ipdir = os.path.dirname(IPython.__file__)
return py3compat.cast_unicode(ipdir, fs_encoding)
示例6: write_index
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def write_index():
"""This is to write the docs for the index automatically."""
here = os.path.dirname(__file__)
filename = os.path.join(here, '_generated', 'version_text.txt')
try:
os.makedirs(os.path.dirname(filename))
except FileExistsError:
pass
text = text_version if '+' not in oggm.__version__ else text_dev
with open(filename, 'w') as f:
f.write(text)
示例7: write_gdir_doc
# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import __file__ [as 别名]
def write_gdir_doc():
"""This is to write the docs for glacierdir automatically."""
here = os.path.dirname(__file__)
origfile = os.path.join(here, '_templates', 'basenames.txt')
filename = os.path.join(here, '_generated', 'basenames.txt')
try:
os.makedirs(os.path.dirname(filename))
except FileExistsError:
pass
shutil.copyfile(origfile, filename)
from oggm.cfg import BASENAMES
cnt = [' ']
for k in sorted(BASENAMES.keys()):
cnt += [BASENAMES.info_str(k)] + [' ']
cnt = '\n'.join(cnt)
file = open(filename, 'a')
try:
file.write(cnt)
finally:
file.close()