本文整理汇总了Python中tools.rewrite函数的典型用法代码示例。如果您正苦于以下问题:Python rewrite函数的具体用法?Python rewrite怎么用?Python rewrite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rewrite函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: make_doxygen
def make_doxygen(name, source, modules):
file = os.path.join("doxygen", name, "Doxyfile")
template_file = os.path.join(source, "tools", "build", "doxygen_templates", "Doxyfile.in")
template = open(template_file, "r").read()
template = template.replace("@[email protected]", source)
template = template.replace("@[email protected]", "0")
template = template.replace("@[email protected]", name)
template = template.replace("@[email protected]",
'"The Integrative Modeling Platform"')
template = template.replace("@[email protected]", "YES")
template = template.replace("@[email protected]", "*/tutorial/*")
template = template.replace("@[email protected]", "YES")
template = template.replace("@[email protected]", "IMP."+name)
template = template.replace("@[email protected]", "../../doc/html/" + name)
template = template.replace("@[email protected]", "tags")
template = template.replace("@[email protected]", "YES")
template = template.replace("@[email protected]", "xml")
template = template.replace("@[email protected]",
"%s/doc/doxygen/module_layout.xml" % source)
template = template.replace("@[email protected]", "README.md")
template = template.replace("@[email protected]", "")
template = template.replace("@[email protected]", "")
template = template.replace("@[email protected]", "")
template = template.replace("@[email protected]", "*.dox *.md")
template = template.replace("@[email protected]", "warnings.txt")
# include lib and doxygen in imput
inputs = []
inputs.append(source + "/applications/" + name + "/doc")
template = template.replace("@[email protected]", " \\\n ".join(inputs))
tags = []
for m in modules:
tags.append(os.path.join("../", m, "tags") + "=" + "../"+m)
template = template.replace("@[email protected]", " \\\n ".join(tags))
tools.rewrite(file, template)
开发者ID:apolitis,项目名称:imp,代码行数:34,代码来源:setup_application.py
示例2: setup_one
def setup_one(module, ordered, build_system, swig):
info = tools.get_module_info(module, "/")
if not info["ok"]:
tools.rewrite("src/%s_swig.deps" % module, "", False)
return
includepath = get_dep_merged([module], "includepath", ordered)
swigpath = get_dep_merged([module], "swigpath", ordered)
depf = open("src/%s_swig.deps.in" % module, "w")
cmd = [swig, "-MM", "-Iinclude", "-Iswig", "-ignoremissing"]\
+ ["-I" + x for x in swigpath] + ["-I" + x for x in includepath]\
+ ["swig/IMP_%s.i" % module]
lines = tools.run_subprocess(cmd).split("\n")
names = []
for x in lines:
if x.endswith("\\"):
x = x[:-1]
x = x.strip()
if not x.endswith(".h") and not x.endswith(".i") and not x.endswith(".i-in"):
continue
names.append(x)
final_names = [_fix(x, build_system) for x in names]
final_list = "\n".join(final_names)
tools.rewrite("src/%s_swig.deps" % module, final_list)
开发者ID:AljGaber,项目名称:imp,代码行数:26,代码来源:setup_swig_deps.py
示例3: make_version
def make_version(source, bindir):
forced = os.path.join(source, "VERSION")
if os.path.exists(forced):
version = open(forced, "r").read()
elif os.path.exists(os.path.join(source, '.git')):
process = subprocess.Popen(
['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
cwd=source, stdout=subprocess.PIPE, universal_newlines=True)
branch, err = process.communicate()
branch = branch.strip()
if branch == "develop" or branch.startswith("feature"):
version = branch + "-" + get_short_rev(source)
elif branch == "master" or branch.startswith("release"):
process = subprocess.Popen(['git', 'describe'], cwd=source,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
version, err = process.communicate()
if err:
version = branch + "-" + get_short_rev(source)
else:
version = get_short_rev(source)
else:
version = 'unknown'
tools.rewrite(os.path.join(bindir, "VERSION"), version)
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:27,代码来源:make_version.py
示例4: setup_one
def setup_one(module, ordered, build_system, swig):
info = tools.get_module_info(module, "/")
if not info["ok"]:
tools.rewrite("src/%s_swig.deps"%module, "")
return
includepath = get_dep_merged([module], "includepath", ordered)
swigpath = get_dep_merged([module], "swigpath", ordered)
depf= open("src/%s_swig.deps.in"%module, "w")
cmd= [swig, "-MM", "-Iinclude", "-Iswig", "-ignoremissing"]\
+ ["-I"+x for x in swigpath] + ["-I"+x for x in includepath]\
+ ["swig/IMP_%s.i"%module]
ret = subprocess.call(cmd, stdout=depf)
del depf
if ret != 0:
raise OSError("subprocess failed with return code %d: %s" \
% (ret, str(cmd)))
lines= open("src/%s_swig.deps.in"%module, "r").readlines()
names= [x[:-2].strip() for x in lines[1:]]
final_names=[_fix(x, build_system) for x in names]
final_list= "\n".join(final_names)
tools.rewrite("src/%s_swig.deps"%module, final_list)
开发者ID:drussel,项目名称:imp,代码行数:25,代码来源:setup_swig_deps.py
示例5: write_no_ok
def write_no_ok(module):
print "no"
apps= tools.split(open(applist, "r").read(), "\n")
apps= [a for a in apps if a != module]
tools.rewrite(applist, "\n".join(apps))
tools.rewrite(os.path.join("data", "build_info", "IMP."+module), "ok=False\n")
sys.exit(1)
开发者ID:apolitis,项目名称:imp,代码行数:7,代码来源:setup_application.py
示例6: main
def main():
(options, args) = parser.parse_args()
sorted_order = tools.get_sorted_order()
if options.module != "":
if options.module == "kernel":
tools.rewrite("lib/IMP/__init__.py", imp_init)
build_wrapper(
options.module, os.path.join(
options.source, "modules", options.module),
options.source, sorted_order,
tools.get_module_description(
options.source,
options.module,
options.datapath),
os.path.join("swig", "IMP_" + options.module + ".i"),
options.datapath)
else:
tools.rewrite("lib/IMP/__init__.py", imp_init)
for m, path in tools.get_modules(options.source):
build_wrapper(m, path, options.source, sorted_order,
tools.get_module_description(
options.source,
m,
options.datapath),
os.path.join("swig", "IMP_" + m + ".i"),
options.datapath)
开发者ID:newtonjoo,项目名称:imp,代码行数:26,代码来源:setup_swig_wrappers.py
示例7: write_ok
def write_ok(
module, modules, unfound_modules, dependencies, unfound_dependencies,
swig_includes, swig_wrapper_includes):
print("yes")
config = ["ok=True"]
if len(modules) > 0:
config.append("modules = \"" + ":".join(modules) + "\"")
if len(unfound_modules) > 0:
config.append(
"unfound_modules = \"" +
":".join(
unfound_modules) +
"\"")
if len(dependencies) > 0:
config.append("dependencies = \"" + ":".join(dependencies) + "\"")
if len(unfound_dependencies) > 0:
config.append(
"unfound_dependencies = \"" +
":".join(
unfound_dependencies) +
"\"")
if len(swig_includes) > 0:
config.append("swig_includes = \"" + ":".join(swig_includes) + "\"")
if len(swig_wrapper_includes) > 0:
config.append(
"swig_wrapper_includes = \"" +
":".join(
swig_wrapper_includes) +
"\"")
tools.rewrite(
os.path.join("data",
"build_info",
"IMP." + module),
"\n".join(config))
开发者ID:newtonjoo,项目名称:imp,代码行数:34,代码来源:setup_module.py
示例8: make_overview
def make_overview(app, source):
rmd = open(os.path.join(source, "applications", app, "README.md"), "r").read()
tools.rewrite(os.path.join("doxygen", "generated", "IMP_%s.dox" % app),
"""/** \\page imp%s IMP.%s
\\tableofcontents
%s
*/
""" %(app, app, rmd))
开发者ID:apolitis,项目名称:imp,代码行数:9,代码来源:setup_application.py
示例9: generate_applications_list
def generate_applications_list(source):
apps= tools.get_glob([os.path.join(source, "applications", "*")])
names=[]
for a in apps:
if os.path.isdir(a):
name= os.path.split(a)[1]
names.append(name)
path=os.path.join("data", "build_info", "applications")
tools.rewrite(path, "\n".join(names))
开发者ID:drussel,项目名称:imp,代码行数:9,代码来源:setup.py
示例10: generate_all_cpp
def generate_all_cpp(source):
target=os.path.join("src")
tools.mkdir(target)
for module, g in tools.get_modules(source):
sources= tools.get_glob([os.path.join(g, "src", "*.cpp")])\
+tools.get_glob([os.path.join(g, "src", "internal", "*.cpp")])
targetf=os.path.join(target, module+"_all.cpp")
sources.sort()
tools.rewrite(targetf, "\n".join(["#include <%s>"%os.path.abspath(s) for s in sources]) + '\n')
开发者ID:apolitis,项目名称:imp,代码行数:9,代码来源:setup_all.py
示例11: make_check
def make_check(path, module, module_path):
name = os.path.splitext(os.path.split(path)[1])[0]
cppsource = open(path, "r").read()
macro = "IMP_COMPILER_%s" % name.upper()
output = check_template % {"macro": macro, "cppsource": tools.quote(cppsource), "module": module, "name": name}
filename = os.path.join(module_path, "CMakeModules", "Check" + name + ".cmake")
tools.rewrite(filename, output)
defr = "%s=${%s}" % (macro, macro)
return filename, defr
开发者ID:jennystone,项目名称:imp,代码行数:9,代码来源:setup_cmake.py
示例12: write_no_ok
def write_no_ok(module):
new_order = [x for x in tools.get_sorted_order() if x != module]
tools.set_sorted_order(new_order)
tools.rewrite(
os.path.join(
"data",
"build_info",
"IMP." + module),
"ok=False\n",
verbose=False)
开发者ID:newtonjoo,项目名称:imp,代码行数:10,代码来源:setup_module.py
示例13: alias_headers
def alias_headers(fromdir, kerneldir, basedir, incdir,
kernel_headers, base_renames):
kernel_headers = dict.fromkeys(kernel_headers)
for g in glob.glob(os.path.join(fromdir, '*.h')):
if "Include all non-deprecated headers" not in open(g).read():
fname = os.path.basename(g)
contents = get_header_contents(incdir, fname)
if fname in kernel_headers:
tools.rewrite(os.path.join(kerneldir, fname), contents)
else:
to_name = base_renames.get(fname, fname)
tools.rewrite(os.path.join(basedir, to_name), contents)
开发者ID:AljGaber,项目名称:imp,代码行数:12,代码来源:setup_module_alias.py
示例14: main
def main():
alias_headers(os.path.join('include', 'IMP'),
os.path.join('include', 'IMP', 'kernel'),
os.path.join('include', 'IMP', 'base'),
'IMP', [ 'AttributeOptimizer.h', 'base_types.h',
'Configuration.h', 'ConfigurationSet.h', 'constants.h',
'Constraint.h', 'container_base.h', 'container_macros.h',
'Decorator.h', 'decorator_macros.h', 'dependency_graph.h',
'DerivativeAccumulator.h', 'doxygen.h', 'FloatIndex.h',
'functor.h', 'generic.h', 'input_output.h', 'io.h', 'Key.h',
'macros.h', 'Model.h', 'ModelObject.h', 'model_object_helpers.h',
'Optimizer.h', 'OptimizerState.h', 'Particle.h', 'particle_index.h',
'ParticleTuple.h', 'python_only.h', 'Refiner.h', 'Restraint.h',
'RestraintSet.h', 'Sampler.h', 'scoped.h', 'ScoreAccumulator.h',
'ScoreState.h', 'ScoringFunction.h', 'UnaryFunction.h',
'Undecorator.h', 'utility.h' ],
{'base_utility.h': 'utility.h' })
alias_headers(os.path.join('include', 'IMP', 'internal'),
os.path.join('include', 'IMP', 'kernel', 'internal'),
os.path.join('include', 'IMP', 'base', 'internal'),
'IMP/internal', [ 'AccumulatorScoreModifier.h',
'AttributeTable.h', 'attribute_tables.h', 'constants.h',
'ContainerConstraint.h', 'container_helpers.h', 'ContainerRestraint.h',
'ContainerScoreState.h', 'create_decomposition.h',
'DynamicListContainer.h', 'evaluate_utility.h', 'ExponentialNumber.h',
'functors.h', 'graph_utility.h', 'IndexingIterator.h',
'input_output_exception.h', 'key_helpers.h', 'ListLikeContainer.h',
'NestedIterator.h', 'pdb.h', 'PrefixStream.h',
'restraint_evaluation.h', 'RestraintsScoringFunction.h',
'scoring_functions.h', 'static.h', 'StaticListContainer.h', 'swig.h',
'swig_helpers.h', 'TupleConstraint.h', 'TupleRestraint.h',
'Unit.h', 'units.h', 'utility.h' ],
{'base_graph_utility.h': 'graph_utility.h',
'base_static.h': 'static.h',
'swig_base.h': 'swig.h',
'swig_helpers_base.h': 'swig_helpers.h'})
tools.rewrite(os.path.join('include', 'IMP', 'base', 'base_config.h'),
get_header_contents('IMP', 'kernel_config.h'))
tools.link(os.path.join('include', 'IMP.h'),
os.path.join('include', 'IMP', 'kernel.h'))
tools.link(os.path.join('include', 'IMP.h'),
os.path.join('include', 'IMP', 'base.h'))
for mod in ('base', 'kernel'):
subdir = os.path.join('lib', 'IMP', mod)
if not os.path.exists(subdir):
os.mkdir(subdir)
pymod = os.path.join(subdir, '__init__.py')
with open(pymod, 'w') as fh:
fh.write("""import sys
sys.stderr.write('IMP.%s is deprecated - use "import IMP" instead\\n')
from IMP import *
""" % mod)
开发者ID:AljGaber,项目名称:imp,代码行数:52,代码来源:setup_module_alias.py
示例15: make_version_check
def make_version_check(options):
dir= os.path.join("lib", "IMP", options.name)
tools.mkdir(dir, clean=False)
outf= os.path.join(dir, "_version_check.py")
template="""def check_version(myversion):
def _check_one(name, expected, found):
if expected != found:
raise RuntimeError('Expected version '+expected+' but got '+ found \
+' when loading module '+name\
+'. Please make sure IMP is properly built and installed and that matching python and C++ libraries are used.')
_check_one('%s', '%s', myversion)
"""
tools.rewrite(outf, template%(options.name, get_version(options)))
开发者ID:drussel,项目名称:imp,代码行数:13,代码来源:setup_module.py
示例16: make_cpp
def make_cpp(options):
dir= os.path.join("src", options.name)
file=os.path.join(dir, "config.cpp")
try:
os.makedirs(dir)
except:
# exists
pass
data={}
data["filename"]="IMP/%s/%s_config.h"%(options.name, options.name)
data["cppprefix"]="IMP%s"%options.name.upper().replace("_", "")
data["name"]= options.name
data["version"]= get_version(options)
tools.rewrite(file, cpp_template%data)
开发者ID:drussel,项目名称:imp,代码行数:14,代码来源:setup_module.py
示例17: make_version_check
def make_version_check(options):
dir= os.path.join("lib", "IMP", options.name)
tools.mkdir(dir, clean=False)
version = tools.get_module_version(options.name, options.source)
outf= os.path.join(dir, "_version_check.py")
template="""def check_version(myversion):
def _check_one(name, expected, found):
if expected != found:
message = "Expected version " + expected + " but got " + found + " when loading module " + name + ". Please make sure IMP is properly built and installed and that matching python and C++ libraries are used."
raise RuntimeError(message)
version = '%s'
_check_one('%s', version, myversion)
"""
tools.rewrite(outf, template%(version, version))
开发者ID:apolitis,项目名称:imp,代码行数:14,代码来源:make_module_version.py
示例18: setup_application
def setup_application(options, name, ordered):
contents = []
path = os.path.join("applications", name)
local = os.path.join(path, "Setup.cmake")
if os.path.exists(local):
contents.append("include(%s)" % tools.to_cmake_path(local))
values = {"name": name}
values["NAME"] = name.upper()
data = tools.get_application_description(".", name, "")
all_modules = data["required_modules"] + tools.get_all_modules(".", data["required_modules"], "", ordered)
all_dependencies = tools.get_all_dependencies(".", all_modules, "", ordered)
modules = ["${IMP_%s_LIBRARY}" % s for s in all_modules]
dependencies = ["${%s_LIBRARIES}" % s.upper() for s in all_dependencies]
values["modules"] = "\n".join(modules)
values["tags"] = "\n".join(["${IMP_%s_DOC}" % m for m in all_modules])
values["dependencies"] = "\n".join(dependencies)
values["module_deps"] = "\n".join("${IMP_%s}" % m for m in all_modules)
exes = tools.get_application_executables(path)
exedirs = list(set(sum([x[1] for x in exes], [])))
exedirs.sort()
localincludes = "\n ".join(["${CMAKE_SOURCE_DIR}/" + tools.to_cmake_path(x) for x in exedirs])
bintmpl = """
add_executable("IMP.%(name)s-%(cname)s" %(cpps)s)
target_link_libraries(IMP.%(name)s-%(cname)s
%(modules)s
%(dependencies)s)
set_target_properties(IMP.%(name)s-%(cname)s PROPERTIES OUTPUT_NAME %(cname)s RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set_property(TARGET "IMP.%(name)s-%(cname)s" PROPERTY FOLDER "IMP.%(name)s")
install(TARGETS IMP.%(name)s-%(cname)s DESTINATION ${CMAKE_INSTALL_BINDIR})
set(bins ${bins} IMP.%(name)s-%(cname)s)
"""
bins = []
for e in exes:
cpps = e[0]
cname = os.path.splitext(os.path.split(cpps[0])[1])[0]
values["cname"] = cname
values["cpps"] = "\n".join(["${CMAKE_SOURCE_DIR}/%s" % tools.to_cmake_path(c) for c in cpps])
bins.append(bintmpl % values)
values["bins"] = "\n".join(bins)
values["includepath"] = get_dep_merged(all_modules, "include_path", ordered) + " " + localincludes
values["libpath"] = get_dep_merged(all_modules, "link_path", ordered)
values["swigpath"] = get_dep_merged(all_modules, "swig_path", ordered)
values["pybins"] = get_app_sources(path, ["*.py"])
values["pytests"] = get_app_sources(os.path.join(path, "test"), ["test_*.py", "expensive_test_*.py"])
contents.append(application_template % values)
out = os.path.join(path, "CMakeLists.txt")
tools.rewrite(out, "\n".join(contents))
return out
开发者ID:jennystone,项目名称:imp,代码行数:49,代码来源:setup_cmake.py
示例19: make_cpp
def make_cpp(options):
dir= os.path.join("src")
file=os.path.join(dir, "%s_config.cpp"%options.name)
cpp_template = open(os.path.join(options.source, "tools", "build", "config_templates", "src.cpp"), "r").read()
try:
os.makedirs(dir)
except:
# exists
pass
data={}
data["filename"]="IMP/%s/%s_config.h"%(options.name, options.name)
data["cppprefix"]="IMP%s"%options.name.upper().replace("_", "")
data["name"]= options.name
data["version"]= tools.get_module_version(options.name, options.source)
tools.rewrite(file, cpp_template%data)
开发者ID:apolitis,项目名称:imp,代码行数:15,代码来源:make_module_version.py
示例20: generate_overview_pages
def generate_overview_pages(source):
name = os.path.join("doxygen", "generated", "all.dox")
contents = []
contents.append("/** ")
contents.append("\\page allmod All IMP Modules and Applications")
contents.append("<table><tr>")
contents.append("<th>Modules</th><th>Applications</th></tr><tr><td>")
for bs, g in tools.get_modules(source):
contents.append("- \\subpage imp%s \"IMP.%s\""%(bs,bs))
contents.append("</td><td style=\"vertical-align:top;\">")
for bs, g in tools.get_applications(source):
contents.append("- \subpage imp%s \"IMP.%s\""%(bs,bs))
contents.append("</td></tr></table>")
contents.append("*/")
tools.rewrite(name, "\n".join(contents))
开发者ID:apolitis,项目名称:imp,代码行数:15,代码来源:setup_doxygen_config.py
注:本文中的tools.rewrite函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论