当前位置: 首页>>代码示例>>Python>>正文


Python OrderedSet.remove方法代码示例

本文整理汇总了Python中twitter.common.collections.OrderedSet.remove方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedSet.remove方法的具体用法?Python OrderedSet.remove怎么用?Python OrderedSet.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twitter.common.collections.OrderedSet的用法示例。


在下文中一共展示了OrderedSet.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: StepContext

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import remove [as 别名]
class StepContext(object):
  """Encapsulates external state and the details of creating Nodes.

  This avoids giving Nodes direct access to the task list or subject set.
  """

  def __init__(self, node_builder, project_tree, node_states, inline_nodes):
    self._node_builder = node_builder
    self.project_tree = project_tree
    self._node_states = dict(node_states)
    self._parents = OrderedSet()
    self._inline_nodes = inline_nodes
    self.snapshot_archive_root = os.path.join(project_tree.build_root, '.snapshots')

  def get(self, node):
    """Given a Node and computed node_states, gets the current state for the Node.

    Optionally inlines execution of inlineable dependencies if `inline_nodes=True`.
    """
    state = self._node_states.get(node, None)
    if state is not None:
      return state
    if self._inline_nodes and node.is_inlineable:
      if node in self._parents:
        return Noop.cycle(list(self._parents)[-1], node)
      self._parents.add(node)
      state = self._node_states[node] = node.step(self)
      self._parents.remove(node)
      return state
    else:
      return Waiting([node])

  def gen_nodes(self, subject, product, variants):
    """Yields Node instances which might be able to provide a value for the given inputs."""
    return self._node_builder.gen_nodes(subject, product, variants)

  def select_node(self, selector, subject, variants):
    """Constructs a Node for the given Selector and the given Subject/Variants.

    This method is decoupled from Selector classes in order to allow the `selector` package to not
    need a dependency on the `nodes` package.
    """
    selector_type = type(selector)
    if selector_type is Select:
      return SelectNode(subject, selector.product, variants, None)
    elif selector_type is SelectVariant:
      return SelectNode(subject, selector.product, variants, selector.variant_key)
    elif selector_type is SelectDependencies:
      return DependenciesNode(subject, selector.product, variants, selector.deps_product, selector.field)
    elif selector_type is SelectProjection:
      return ProjectionNode(subject, selector.product, variants, selector.projected_subject, selector.fields, selector.input_product)
    elif selector_type is SelectLiteral:
      # NB: Intentionally ignores subject parameter to provide a literal subject.
      return SelectNode(selector.subject, selector.product, variants, None)
    else:
      raise ValueError('Unrecognized Selector type "{}" for: {}'.format(selector_type, selector))
开发者ID:manasapte,项目名称:pants,代码行数:58,代码来源:nodes.py

示例2: StepContext

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import remove [as 别名]
class StepContext(object):
  """Encapsulates external state and the details of creating Nodes.

  This avoids giving Nodes direct access to the task list or subject set.
  """

  def __init__(self, node_builder, project_tree, node_states, inline_nodes):
    self._node_builder = node_builder
    self.project_tree = project_tree
    self._node_states = dict(node_states)
    self._parents = OrderedSet()
    self._inline_nodes = inline_nodes
    self.snapshot_archive_root = os.path.join(project_tree.build_root, '.snapshots')

  def get(self, node):
    """Given a Node and computed node_states, gets the current state for the Node.

    Optionally inlines execution of inlineable dependencies if `inline_nodes=True`.
    """
    state = self._node_states.get(node, None)
    if state is not None:
      return state
    if self._inline_nodes and node.is_inlineable:
      if node in self._parents:
        return Noop.cycle(list(self._parents)[-1], node)
      self._parents.add(node)
      state = self._node_states[node] = node.step(self)
      self._parents.remove(node)
      return state
    else:
      return Waiting([node])

  def get_nodes_and_states_for(self, subject, product, variants):
    for node in self._node_builder.gen_nodes(subject, product, variants):
      state = self.get(node)
      yield node, state

  def select_for(self, selector, subject, variants):
    """Returns the state for selecting a product via the provided selector."""
    dep_node = self._node_builder.select_node(selector, subject, variants)
    return self.get(dep_node)
开发者ID:CaitieM20,项目名称:pants,代码行数:43,代码来源:nodes.py


注:本文中的twitter.common.collections.OrderedSet.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。