本文整理汇总了Python中pybuilder.utils.as_list函数的典型用法代码示例。如果您正苦于以下问题:Python as_list函数的具体用法?Python as_list怎么用?Python as_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了as_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_sphinx_build_command
def get_sphinx_build_command(project, logger, builder):
"""Builds the sphinx-build command using properties.
"""
options = ["sphinx",
"-b", builder
]
verbose = None
if project.get_property("verbose"):
verbose = "-v"
if logger.threshold == logger.DEBUG:
verbose = "-vvvv"
if verbose:
options.append(verbose)
options += as_list(project.get_property("sphinx_build_extra_args"))
options.append(project.expand_path("$sphinx_config_path"))
if len(as_list(project.get_property("sphinx_doc_builder"))) > 1 or \
project.get_property("sphinx_output_per_builder"):
options.append(project.expand_path("$sphinx_output_dir", builder))
else:
options.append(project.expand_path("$sphinx_output_dir"))
return options
开发者ID:wenlien,项目名称:pybuilder,代码行数:26,代码来源:sphinx_plugin.py
示例2: _prepare_tasks
def _prepare_tasks(self, tasks):
if not len(tasks):
if self.project.default_task:
tasks += as_list(self.project.default_task)
else:
raise PyBuilderException("No default task given.")
else:
new_tasks = [task for task in tasks if task[0] not in ("+", "^") or task in ("+", "^")]
append_tasks = [task[1:] for task in tasks if task[0] == "+" and task != "+"]
remove_tasks = [task[1:] for task in tasks if task[0] == "^" and task != "^"]
if len(new_tasks):
del tasks[:]
tasks.extend(new_tasks)
tasks.extend(append_tasks)
for task in remove_tasks:
try:
tasks.remove(task)
except ValueError:
pass
else:
del tasks[:]
if self.project.default_task:
tasks += as_list(self.project.default_task)
tasks += append_tasks
for task in remove_tasks:
try:
tasks.remove(task)
except ValueError:
pass
return tasks
开发者ID:arcivanov,项目名称:pybuilder,代码行数:32,代码来源:reactor.py
示例3: collect_tasks_and_actions_and_initializers
def collect_tasks_and_actions_and_initializers(self, project_module):
for name in dir(project_module):
candidate = getattr(project_module, name)
if hasattr(candidate, NAME_ATTRIBUTE):
name = getattr(candidate, NAME_ATTRIBUTE)
elif hasattr(candidate, "__name__"):
name = candidate.__name__
description = getattr(candidate, DESCRIPTION_ATTRIBUTE) if hasattr(
candidate, DESCRIPTION_ATTRIBUTE) else ""
if hasattr(candidate, TASK_ATTRIBUTE) and getattr(candidate, TASK_ATTRIBUTE):
dependencies = getattr(candidate, DEPENDS_ATTRIBUTE) if hasattr(candidate, DEPENDS_ATTRIBUTE) else None
required_dependencies = []
optional_dependencies = []
if dependencies:
dependencies = list(as_list(dependencies))
for d in dependencies:
if type(d) is optional:
d = as_list(d())
optional_dependencies += d
else:
required_dependencies.append(d)
self.logger.debug("Found task '%s' with required dependencies %s and optional dependencies %s", name,
required_dependencies, optional_dependencies)
self.execution_manager.register_task(
Task(name, candidate, required_dependencies, description, optional_dependencies))
elif hasattr(candidate, ACTION_ATTRIBUTE) and getattr(candidate, ACTION_ATTRIBUTE):
before = getattr(candidate, BEFORE_ATTRIBUTE) if hasattr(
candidate, BEFORE_ATTRIBUTE) else None
after = getattr(candidate, AFTER_ATTRIBUTE) if hasattr(
candidate, AFTER_ATTRIBUTE) else None
only_once = False
if hasattr(candidate, ONLY_ONCE_ATTRIBUTE):
only_once = getattr(candidate, ONLY_ONCE_ATTRIBUTE)
teardown = False
if hasattr(candidate, TEARDOWN_ATTRIBUTE):
teardown = getattr(candidate, TEARDOWN_ATTRIBUTE)
self.logger.debug("Found action %s", name)
self.execution_manager.register_action(
Action(name, candidate, before, after, description, only_once, teardown))
elif hasattr(candidate, INITIALIZER_ATTRIBUTE) and getattr(candidate, INITIALIZER_ATTRIBUTE):
environments = []
if hasattr(candidate, ENVIRONMENTS_ATTRIBUTE):
environments = getattr(candidate, ENVIRONMENTS_ATTRIBUTE)
self.execution_manager.register_initializer(
Initializer(name, candidate, environments, description))
开发者ID:jewishjeff,项目名称:pybuilder,代码行数:52,代码来源:reactor.py
示例4: build_pip_install_options
def build_pip_install_options(index_url=None, extra_index_url=None, upgrade=False, insecure_installs=None,
force_reinstall=False, target_dir=None, verbose=False, trusted_host=None,
constraint_file=None, eager_upgrade=False):
options = []
if index_url:
options.append("--index-url")
options.append(index_url)
if extra_index_url:
extra_index_urls = as_list(extra_index_url)
for url in extra_index_urls:
options.append("--extra-index-url")
options.append(url)
if trusted_host:
trusted_hosts = as_list(trusted_host)
for host in trusted_hosts:
options.append("--trusted-host")
options.append(host)
if upgrade:
options.append("--upgrade")
if pip_common.pip_version >= "9.0":
options.append("--upgrade-strategy")
if eager_upgrade:
options.append("eager")
else:
options.append("only-if-needed")
if verbose:
options.append("--verbose")
if force_reinstall:
options.append("--force-reinstall")
if target_dir:
options.append("-t")
options.append(target_dir)
if constraint_file:
options.append("-c")
options.append(constraint_file)
if insecure_installs:
for insecure_install in insecure_installs:
arguments_for_insecure_installation = ["--allow-unverified", insecure_install,
"--allow-external", insecure_install]
options.extend(arguments_for_insecure_installation)
return options
开发者ID:arcivanov,项目名称:pybuilder,代码行数:50,代码来源:pip_utils.py
示例5: do_decoration
def do_decoration(callable):
setattr(callable, INITIALIZER_ATTRIBUTE, True)
if "environments" in additional_arguments:
setattr(callable, ENVIRONMENTS_ATTRIBUTE, as_list(additional_arguments["environments"]))
return callable
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:7,代码来源:core.py
示例6: build_entry_points_string
def build_entry_points_string(project):
console_scripts = project.get_property('distutils_console_scripts')
entry_points = project.get_property('distutils_entry_points')
if console_scripts is not None and entry_points is not None:
raise BuildFailedException("'distutils_console_scripts' cannot be combined with 'distutils_entry_points'")
if entry_points is None:
entry_points = dict()
if console_scripts is not None:
entry_points['console_scripts'] = console_scripts
if len(entry_points) == 0:
return '{}'
indent = 8
result = "{\n"
for k in sorted(entry_points.keys()):
result += " " * (indent + 4)
result += "'%s': %s" % (k, build_string_from_array(as_list(entry_points[k]), indent + 8)) + ",\n"
result = result[:-2] + "\n"
result += (" " * indent) + "}"
return result
开发者ID:esc,项目名称:pybuilder,代码行数:26,代码来源:distutils_plugin.py
示例7: upload
def upload(project, logger):
repository = project.get_property("distutils_upload_repository")
repository_args = []
if repository:
repository_args = ["-r", repository]
upload_sign = project.get_property("distutils_upload_sign")
upload_sign_args = []
if upload_sign:
upload_sign_args = ["--sign"]
sign_identity = project.get_property("distutils_upload_sign_identity")
if sign_identity:
upload_sign_args += ["--identity", sign_identity]
# Unfortunately, distutils/setuptools doesn't throw error if register fails
# but upload command will fail if project will not be registered
logger.info("Registering project %s-%s%s", project.name, project.version,
(" into repository '%s'" % repository) if repository else "")
register_cmd_line = [["register"] + repository_args]
execute_distutils(project, logger, register_cmd_line, False)
logger.info("Uploading project %s-%s%s%s%s", project.name, project.version,
(" to repository '%s'" % repository) if repository else "",
get_dist_version_string(project, " as version %s"),
(" signing%s" % (" with %s" % sign_identity if sign_identity else "")) if upload_sign else "")
upload_cmd_line = [build_command_with_options(cmd, project.get_property("distutils_command_options")) + ["upload"] +
repository_args + upload_sign_args
for cmd in as_list(project.get_property("distutils_commands"))]
execute_distutils(project, logger, upload_cmd_line, True)
开发者ID:wenlien,项目名称:pybuilder,代码行数:29,代码来源:distutils_plugin.py
示例8: build_binary_distribution
def build_binary_distribution(project, logger):
reports_dir = project.expand_path("$dir_reports/distutils")
if not os.path.exists(reports_dir):
os.mkdir(reports_dir)
setup_script = project.expand_path("$dir_dist/setup.py")
logger.info("Building binary distribution in %s",
project.expand_path("$dir_dist"))
commands = as_list(project.get_property("distutils_commands"))
for command in commands:
logger.debug("Executing distutils command %s", command)
with open(os.path.join(reports_dir, command.replace("/", "")), "w") as output_file:
commands = [sys.executable, setup_script]
commands.extend(command.split())
process = subprocess.Popen(commands,
cwd=project.expand_path("$dir_dist"),
stdout=output_file,
stderr=output_file,
shell=False)
return_code = process.wait()
if return_code != 0:
raise BuildFailedException(
"Error while executing setup command %s", command)
开发者ID:sidwid,项目名称:pybuilder,代码行数:26,代码来源:distutils_plugin.py
示例9: build_binary_distribution
def build_binary_distribution(project, logger):
logger.info("Building binary distribution in %s",
project.expand_path("$dir_dist"))
commands = [build_command_with_options(cmd, project.get_property("distutils_command_options"))
for cmd in as_list(project.get_property("distutils_commands"))]
execute_distutils(project, logger, commands, True)
开发者ID:runt18,项目名称:pybuilder,代码行数:7,代码来源:distutils_plugin.py
示例10: pip_install
def pip_install(install_targets, index_url=None, extra_index_url=None, upgrade=False, insecure_installs=None,
force_reinstall=False, target_dir=None, verbose=False, trusted_host=None, constraint_file=None,
eager_upgrade=False,
logger=None, outfile_name=None, error_file_name=None, env=None, cwd=None):
pip_command_line = list()
pip_command_line.extend(PIP_EXEC_STANZA)
pip_command_line.append("install")
pip_command_line.extend(build_pip_install_options(index_url=index_url,
extra_index_url=extra_index_url,
upgrade=upgrade,
insecure_installs=insecure_installs,
force_reinstall=force_reinstall,
target_dir=target_dir,
verbose=verbose,
trusted_host=trusted_host,
constraint_file=constraint_file,
eager_upgrade=eager_upgrade
))
for install_target in as_list(install_targets):
pip_command_line.extend(as_pip_install_target(install_target))
if env is None:
env = os.environ
if logger:
logger.debug("Invoking pip: %s", pip_command_line)
return execute_command(pip_command_line, outfile_name=outfile_name, env=env, cwd=cwd,
error_file_name=error_file_name, shell=False)
开发者ID:arcivanov,项目名称:pybuilder,代码行数:28,代码来源:pip_utils.py
示例11: build_execution_plan
def build_execution_plan(self, task_names):
self.assert_dependencies_resolved()
execution_plan = []
dependency_edges = {}
for task in self.collect_all_transitive_tasks(as_list(task_names)):
dependency_edges[task.name] = [dependency.name for dependency in task.dependencies]
try:
Graph(dependency_edges).assert_no_cycles_present()
except GraphHasCycles as cycles:
raise CircularTaskDependencyException(str(cycles))
for task_name in as_list(task_names):
self._enqueue_task(execution_plan, task_name)
return execution_plan
开发者ID:runt18,项目名称:pybuilder,代码行数:16,代码来源:execution.py
示例12: build_execution_plan
def build_execution_plan(self, task_names):
self.assert_dependencies_resolved()
execution_plan = []
for name in as_list(task_names):
self.enqueue_task(execution_plan, name)
return execution_plan
开发者ID:B-Rich,项目名称:pybuilder,代码行数:7,代码来源:execution.py
示例13: add_task_dependency
def add_task_dependency(names, depends_on, optional):
for name in as_list(names):
if not isinstance(name, basestring):
name = normalize_candidate_name(name)
if name not in injected_task_dependencies:
injected_task_dependencies[name] = list()
injected_task_dependencies[name].append(TaskDependency(depends_on, optional))
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:7,代码来源:reactor.py
示例14: build
def build(self, tasks=None, environments=None):
if not tasks:
tasks = []
if not environments:
environments = []
Reactor._current_instance = self
if environments:
self.logger.info(
"Activated environments: %s", ", ".join(environments))
self.execution_manager.execute_initializers(
environments, logger=self.logger, project=self.project)
self.log_project_properties()
self.validate_project()
tasks = as_list(tasks)
if not len(tasks):
if self.project.default_task:
tasks += as_list(self.project.default_task)
else:
raise PyBuilderException("No default task given.")
execution_plan = self.execution_manager.build_execution_plan(tasks)
self.logger.debug("Execution plan is %s", ", ".join(
[task.name for task in execution_plan]))
self.logger.info(
"Building %s version %s", self.project.name, self.project.version)
self.logger.info("Executing build in %s", self.project.basedir)
if len(tasks) == 1:
self.logger.info("Going to execute task %s", tasks[0])
else:
list_of_tasks = ", ".join(tasks)
self.logger.info("Going to execute tasks: %s", list_of_tasks)
task_execution_summaries = self.execution_manager.execute_execution_plan(
execution_plan,
logger=self.logger,
project=self.project,
reactor=self)
return BuildSummary(self.project, task_execution_summaries)
开发者ID:jewishjeff,项目名称:pybuilder,代码行数:47,代码来源:reactor.py
示例15: as_task_name_list
def as_task_name_list(mixed):
result = []
for d in as_list(mixed):
if isinstance(d, types.FunctionType):
result.append(d.__name__)
else:
result.append(str(d))
return result
开发者ID:B-Rich,项目名称:pybuilder,代码行数:8,代码来源:execution.py
示例16: as_task_name_list
def as_task_name_list(mixed):
result = []
for item in as_list(mixed):
if isinstance(item, types.FunctionType):
result.append(item.__name__)
else:
result.append(str(item))
return result
开发者ID:brendawong,项目名称:pybuilder,代码行数:8,代码来源:execution.py
示例17: build_command_with_options
def build_command_with_options(command, distutils_command_options=None):
commands = [command]
if distutils_command_options:
try:
command_options = as_list(distutils_command_options[command])
commands.extend(command_options)
except KeyError:
pass
return commands
开发者ID:runt18,项目名称:pybuilder,代码行数:9,代码来源:distutils_plugin.py
示例18: build
def build(self, tasks=None, environments=None):
if not tasks:
tasks = []
else:
tasks = as_list(tasks)
if not environments:
environments = []
execution_plan = self.create_execution_plan(tasks, environments)
return self.build_execution_plan(tasks, execution_plan)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:10,代码来源:reactor.py
示例19: execute_tool_on_modules
def execute_tool_on_modules(project, name, command_and_arguments, extend_pythonpath=True):
source_dir = project.expand_path("$dir_source_main_python")
modules = discover_modules(source_dir)
command = as_list(command_and_arguments) + modules
report_file = project.expand_path("$dir_reports/%s" % name)
env = os.environ
if extend_pythonpath:
env["PYTHONPATH"] = source_dir
return execute_command(command, report_file, env=env), report_file
开发者ID:B-Rich,项目名称:pybuilder,代码行数:11,代码来源:python_plugin_helper.py
示例20: upload
def upload(project, logger):
repository = project.get_property("distutils_upload_repository")
repository_args = []
if repository:
repository_args = ["-r", repository]
logger.info("Uploading project %s-%s%s%s", project.name, project.version,
(" to repository '%s'" % repository) if repository else "",
get_dist_version_string(project, " as version %s"))
upload_cmd_line = [build_command_with_options(cmd, project.get_property("distutils_command_options")) + ["upload"] +
repository_args for cmd in as_list(project.get_property("distutils_commands"))]
execute_distutils(project, logger, upload_cmd_line, True)
开发者ID:Lucas-C,项目名称:pybuilder,代码行数:12,代码来源:distutils_plugin.py
注:本文中的pybuilder.utils.as_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论