本文整理汇总了Python中bento.core.package.PackageDescription.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python PackageDescription.from_file方法的具体用法?Python PackageDescription.from_file怎么用?Python PackageDescription.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bento.core.package.PackageDescription
的用法示例。
在下文中一共展示了PackageDescription.from_file方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_error_string
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def test_error_string(self):
f = self.f
f.write("NName: foo")
f.flush()
try:
PackageDescription.from_file(f.name)
raise AssertionError("Should raise here !")
except ParseError:
e = extract_exception()
self.assertEqual(str(e), """\
File "%s", line 1
NName: foo
^
Syntax error""" % f.name)
示例2: run
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def run(self, ctx):
o, a = self.parser.parse_args(ctx.cmd_opts)
if o.help:
self.parser.print_help()
return
filename = BENTO_SCRIPT
if not len(a) > 0:
if not os.path.exists(filename):
raise UsageException("Missing %s file" % BENTO_SCRIPT)
pkg = PackageDescription.from_file(filename)
tarname = tarball_basename(pkg.name, pkg.version) + ".tar.gz"
self.tarname = os.path.abspath(os.path.join("dist", tarname))
self.topdir = "%s-%s" % (pkg.name, pkg.version)
create_tarball(pkg, ctx.top_node, self.tarname, self.topdir)
示例3: run
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def run(self, ctx):
argv = ctx.get_command_arguments()
p = ctx.options_context.parser
o, a = p.parse_args(argv)
if o.help:
p.print_help()
return
filename = BENTO_SCRIPT
if not len(a) > 0:
if not os.path.exists(filename):
raise UsageException("Missing %s file" % BENTO_SCRIPT)
pkg = PackageDescription.from_file(filename)
tarname = tarball_basename(pkg.name, pkg.version) + ".tar.gz"
self.tarname = os.path.abspath(os.path.join(o.output_dir, tarname))
self.topdir = "%s-%s" % (pkg.name, pkg.version)
create_tarball(pkg, ctx.top_node, self.tarname, self.topdir)
示例4: run
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def run(self, ctx):
argv = ctx.get_command_arguments()
p = ctx.options_context.parser
o, a = p.parse_args(argv)
if o.help:
p.print_help()
return
bento_script = ctx.top_node.find_node(BENTO_SCRIPT)
if not o.output:
pkg_info = "PKG-INFO"
else:
pkg_info = o.output
pkg = PackageDescription.from_file(bento_script.abspath())
fid = open(pkg_info, "w")
try:
write_pkg_info(pkg, fid)
finally:
fid.close()
示例5: __init__
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def __init__(self, attrs=None):
if attrs is None:
attrs = {}
if not "bento_info" in attrs:
bento_info = "bento.info"
else:
bento_info = attrs["bento.info"]
self.pkg = PackageDescription.from_file(bento_info)
self.package_options = PackageOptions.from_file(bento_info)
attrs = _setup_cmd_classes(attrs)
d = pkg_to_distutils_meta(self.pkg)
attrs.update(d)
Distribution.__init__(self, attrs)
self.packages = self.pkg.packages
self.py_modules = self.pkg.py_modules
if hasattr(self, "entry_points"):
if self.entry_points is None:
self.entry_points = {}
console_scripts = [e.full_representation() for e in self.pkg.executables.values()]
if "console_scripts" in self.entry_points:
self.entry_points["console_scripts"].extend(console_scripts)
else:
self.entry_points["console_scripts"] = console_scripts
source_root = os.getcwd()
build_root = os.path.join(source_root, "build")
root = create_root_with_source_tree(source_root, build_root)
self.top_node = root._ctx.srcnode
self.build_node = root._ctx.bldnode
self.run_node = root._ctx.srcnode
self.global_context = global_context_factory(self.package_options)
modules = set_main(self.top_node, self.build_node, self.pkg)
示例6: run
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def run(self, ctx):
o, a = self.parser.parse_args(ctx.cmd_opts)
if o.help:
self.parser.print_help()
return
if len(a) < 1:
raise UsageException("%s: error: %s subcommand require an argument" \
% (SCRIPT_NAME, "parse"))
else:
filename = a[0]
if not o.output:
pkg_info = "PKG-INFO"
else:
pkg_info = o.output
pkg = PackageDescription.from_file(filename)
fid = open(pkg_info, "w")
try:
write_pkg_info(pkg, fid)
finally:
fid.close()
示例7: TestInstalledSection
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
import \
PackageDescription
from bento.core.utils \
import \
subst_vars
from bento.installed_package_description \
import \
InstalledPkgDescription, InstalledSection, ipkg_meta_from_pkg, iter_files
import bento.tests.bentos
# FIXME: use correct install path instead of python package hack
BENTOS_DIR = os.path.dirname(bento.tests.bentos.__file__)
SPHINX_META = os.path.join(BENTOS_DIR, "sphinx_meta.info")
SPHINX_META_PKG = PackageDescription.from_file(SPHINX_META)
class TestInstalledSection(unittest.TestCase):
def test_simple(self):
files = [("scripts/foo.py", "scripts/foo"),
("scripts/bar.py", "scripts/bar.py")]
section = InstalledSection("pythonfiles", "section1", "source", "target", files)
def test_from_source_target(self):
files = [("scripts/foo.py", "scripts/foo.py"),
("scripts/bar.py", "scripts/bar.py")]
r_section = InstalledSection("pythonfiles", "section1", "source", "target", files)
files = ["scripts/foo.py", "scripts/bar.py"]
section = InstalledSection.from_source_target_directories("pythonfiles",
"section1", "source", "target", files)
示例8: test_simple_filename
# 需要导入模块: from bento.core.package import PackageDescription [as 别名]
# 或者: from bento.core.package.PackageDescription import from_file [as 别名]
def test_simple_filename(self):
f = self.f
f.write("NName: foo")
f.flush()
self.assertRaises(ParseError, lambda : PackageDescription.from_file(f.name))