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


Python OrderedSet.update方法代码示例

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


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

示例1: extract_target

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
def extract_target(java_targets, is_transitive, is_classpath, name = None):
  meta_target = bang.extract_target(java_targets, name)

  internal_deps, jar_deps = _extract_target(meta_target, is_transitive, is_classpath)

  # TODO(John Sirois): make an empty source set work in ant/compile.xml
  sources = [ '__no_source__' ]

  all_deps = OrderedSet()
  all_deps.update(internal_deps)
  all_deps.update(jar_deps)

  if is_java(meta_target):
    return JavaLibrary('ide',
                       sources,
                       dependencies = all_deps,
                       excludes = meta_target.excludes,
                       is_meta = True)
  elif is_scala(meta_target):
    return ScalaLibrary('ide',
                        sources,
                        dependencies = all_deps,
                        excludes = meta_target.excludes,
                        is_meta = True)
  else:
    raise TypeError("Cannot generate IDE configuration for targets: %s" % java_targets)
开发者ID:billwei,项目名称:commons,代码行数:28,代码来源:ide.py

示例2: minimum_path

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def minimum_path(cls):
    """
      Return as a tuple the emulated sys.path and sys.path_importer_cache of
      a bare python installation, a la python -S.
    """
    site_libs = set(cls._site_libs())
    for site_lib in site_libs:
      TRACER.log('Found site-library: %s' % site_lib)
    for extras_path in cls._extras_paths():
      TRACER.log('Found site extra: %s' % extras_path)
      site_libs.add(extras_path)
    site_libs = set(os.path.normpath(path) for path in site_libs)

    site_distributions = OrderedSet()
    for path_element in sys.path:
      if any(path_element.startswith(site_lib) for site_lib in site_libs):
        TRACER.log('Inspecting path element: %s' % path_element)
        site_distributions.update(dist.location for dist in find_distributions(path_element))

    user_site_distributions = OrderedSet(dist.location for dist in find_distributions(USER_SITE))

    for path in site_distributions:
      TRACER.log('Scrubbing from site-packages: %s' % path)
    for path in user_site_distributions:
      TRACER.log('Scrubbing from user site: %s' % path)

    scrub_paths = site_distributions | user_site_distributions
    scrubbed_sys_path = list(OrderedSet(sys.path) - scrub_paths)
    scrub_from_importer_cache = filter(
      lambda key: any(key.startswith(path) for path in scrub_paths),
      sys.path_importer_cache.keys())
    scrubbed_importer_cache = dict((key, value) for (key, value) in sys.path_importer_cache.items()
      if key not in scrub_from_importer_cache)
    return scrubbed_sys_path, scrubbed_importer_cache
开发者ID:BabyDuncan,项目名称:commons,代码行数:36,代码来源:pex.py

示例3: console_output

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def console_output(self, _):
    buildfiles = OrderedSet()
    if self._dependees_type:
      base_paths = OrderedSet()
      for dependees_type in self._dependees_type:
        # FIXME(pl): This should be a standard function provided by the plugin/BuildFileParser
        # machinery
        try:
          # Try to do a fully qualified import 1st for filtering on custom types.
          from_list, module, type_name = dependees_type.rsplit('.', 2)
          module = __import__('%s.%s' % (from_list, module), fromlist=[from_list])
          target_type = getattr(module, type_name)
        except (ImportError, ValueError):
          # Fall back on pants provided target types.
          registered_aliases = self.context.build_file_parser.registered_aliases()
          if dependees_type not in registered_aliases.targets:
            raise TaskError('Invalid type name: %s' % dependees_type)
          target_type = registered_aliases.targets[dependees_type]

        # Try to find the SourceRoot for the given input type
        try:
          roots = SourceRoot.roots(target_type)
          base_paths.update(roots)
        except KeyError:
          pass

      if not base_paths:
        raise TaskError('No SourceRoot set for any target type in %s.' % self._dependees_type +
                        '\nPlease define a source root in BUILD file as:' +
                        '\n\tsource_root(\'<src-folder>\', %s)' % ', '.join(self._dependees_type))
      for base_path in base_paths:
        buildfiles.update(BuildFile.scan_buildfiles(get_buildroot(),
                                                    os.path.join(get_buildroot(), base_path)))
    else:
      buildfiles = BuildFile.scan_buildfiles(get_buildroot())

    build_graph = self.context.build_graph
    build_file_parser = self.context.build_file_parser

    dependees_by_target = defaultdict(set)
    for build_file in buildfiles:
      build_file_parser.parse_build_file(build_file)
      for address in build_file_parser.addresses_by_build_file[build_file]:
        build_file_parser.inject_spec_closure_into_build_graph(address.spec, build_graph)
      for address in build_file_parser.addresses_by_build_file[build_file]:
        target = build_graph.get_target(address)
        # TODO(John Sirois): tighten up the notion of targets written down in a BUILD by a
        # user vs. targets created by pants at runtime.
        target = self.get_concrete_target(target)
        for dependency in target.dependencies:
          dependency = self.get_concrete_target(dependency)
          dependees_by_target[dependency].add(target)

    roots = set(self.context.target_roots)
    if self._closed:
      for root in roots:
        yield root.address.spec

    for dependant in self.get_dependants(dependees_by_target, roots):
      yield dependant.address.spec
开发者ID:cheecheeo,项目名称:pants,代码行数:62,代码来源:dependees.py

示例4: extract_target

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
def extract_target(java_targets, is_classpath):
  primary_target = InternalTarget.sort_targets(java_targets)[0]

  with ParseContext.temp(primary_target.target_base):
    internal_deps, jar_deps = _extract_target(java_targets, is_classpath)

    # TODO(John Sirois): make an empty source set work in ant/compile.xml
    sources = [ '__no_source__' ]

    all_deps = OrderedSet()
    all_deps.update(internal_deps)
    all_deps.update(jar_deps)

    if is_java(primary_target):
      return JavaLibrary('ide',
                         sources,
                         dependencies = all_deps,
                         is_meta = True)
    elif is_scala(primary_target):
      return ScalaLibrary('ide',
                          sources,
                          dependencies = all_deps,
                          is_meta = True)
    else:
      raise TypeError("Cannot generate IDE configuration for targets: %s" % java_targets)
开发者ID:JoeEnnever,项目名称:commons,代码行数:27,代码来源:ide.py

示例5: parse_args

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def parse_args(args):
    goals = OrderedSet()
    specs = OrderedSet()
    help = False
    explicit_multi = False

    def is_spec(spec):
      return os.sep in spec or ':' in spec

    for i, arg in enumerate(args):
      help = help or 'help' == arg
      if not arg.startswith('-'):
        specs.add(arg) if is_spec(arg) else goals.add(arg)
      elif '--' == arg:
        if specs:
          raise GoalError('Cannot intermix targets with goals when using --. Targets should '
                          'appear on the right')
        explicit_multi = True
        del args[i]
        break

    if explicit_multi:
      spec_offset = len(goals) + 1 if help else len(goals)
      specs.update(arg for arg in args[spec_offset:] if not arg.startswith('-'))

    return goals, specs
开发者ID:soheilhy,项目名称:commons,代码行数:28,代码来源:goal.py

示例6: _resolve_java_deps

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def _resolve_java_deps(self, target):
    key = self._CONFIG_SECTION_BY_COMPILER[target.compiler]

    deps = OrderedSet()
    for dep in self.context.config.getlist(key, 'javadeps'):
        deps.update(self.context.resolve(dep))
    return deps
开发者ID:teddziuba,项目名称:commons,代码行数:9,代码来源:antlr_gen.py

示例7: dependents_of_addresses

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
 def dependents_of_addresses(self, addresses):
   """Given an iterable of addresses, yield all of those addresses dependents."""
   seen = OrderedSet(addresses)
   for address in addresses:
     seen.update(self._dependent_address_map[address])
     seen.update(self._implicit_dependent_address_map[address])
   return seen
开发者ID:cosmicexplorer,项目名称:pants,代码行数:9,代码来源:graph.py

示例8: _format_args_for_target

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def _format_args_for_target(self, target, target_workdir):
    """Calculate the arguments to pass to the command line for a single target."""

    relative_proto_files = OrderedSet()
    if target.payload.proto_files:
      relative_proto_files.update(target.payload.proto_files)
    else:
      sources = OrderedSet(target.sources_relative_to_buildroot())
      if not self.validate_sources_present(sources, [target]):
        return None
      # Compute the source path relative to the 'source root' which is the path used at the
      # root of imports
      for source in sources:
        source_root = self.context.source_roots.find_by_path(source).path
        relative_proto_files.add(os.path.relpath(source, source_root))

    args = ['--generated-source-directory', target_workdir]

    for root in target.payload.roots:
      args.extend(['--root', root])

    for path in self._calculate_proto_paths(target):
      # NB(gmalmquist): This isn't a typo. The --source argument is actually a proto path.
      args.extend(['--source', path])

    for source in relative_proto_files:
      args.extend(['--proto', source])

    return args
开发者ID:ericzundel,项目名称:mvn2pants,代码行数:31,代码来源:sake_wire_codegen.py

示例9: get_artifacts_for_jar_library

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def get_artifacts_for_jar_library(self, jar_library, memo=None):
    """Collects IvyArtifact instances for the passed jar_library.

    Because artifacts are only fetched for the "winning" version of a module, the artifacts
    will not always represent the version originally declared by the library.

    This method is transitive within the library's jar_dependencies, but will NOT
    walk into its non-jar dependencies.

    :param jar_library A JarLibrary to collect the transitive artifacts for.
    :param memo see `traverse_dependency_graph`
    """
    artifacts = OrderedSet()
    def create_collection(dep):
      return OrderedSet([dep])
    for jar in jar_library.jar_dependencies:
      jar_module_ref = IvyModuleRef(jar.org, jar.name, jar.rev)
      valid_classifiers = jar.artifact_classifiers
      artifacts_for_jar = []
      for module_ref in self.traverse_dependency_graph(jar_module_ref, create_collection, memo):
        artifacts_for_jar.extend(
          artifact for artifact in self._artifacts_by_ref[module_ref.unversioned]
          if artifact.classifier in valid_classifiers
        )

      artifacts.update(artifacts_for_jar)
    return artifacts
开发者ID:jinfeng,项目名称:jinfeng-pants-fork,代码行数:29,代码来源:ivy_utils.py

示例10: _flatten_type_constraints

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
 def _flatten_type_constraints(self, selection_products):
   type_constraints = filter(lambda o: isinstance(o, Exactly), selection_products)
   non_type_constraints = filter(lambda o: not isinstance(o, Exactly), selection_products)
   flattened_products = OrderedSet(non_type_constraints)
   for t in type_constraints:
     flattened_products.update(t.types)
   return flattened_products
开发者ID:kwlzn,项目名称:pants,代码行数:9,代码来源:rules.py

示例11: _detect_cycle

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def _detect_cycle(self, src, dest):
    """Given a src and a dest, each of which _might_ already exist in the graph, detect cycles.

    Return a path of Nodes that describe the cycle, or None.
    """
    path = OrderedSet()
    walked = set()
    def _walk(node):
      if node in path:
        return tuple(path) + (node,)
      if node in walked:
        return None
      path.add(node)
      walked.add(node)

      for dep in self.dependencies_of(node):
        found = _walk(dep)
        if found is not None:
          return found
      path.discard(node)
      return None

    # Initialize the path with src (since the edge from src->dest may not actually exist), and
    # then walk from the dest.
    path.update([src])
    return _walk(dest)
开发者ID:caveness,项目名称:pants,代码行数:28,代码来源:scheduler.py

示例12: create_geninfo

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
 def create_geninfo(key):
   gen_info = context.config.getdict('thrift-gen', key)
   gen = gen_info['gen']
   deps = OrderedSet()
   for dep in gen_info['deps']:
     deps.update(context.resolve(dep))
   return ThriftGen.GenInfo(gen, deps)
开发者ID:adamsxu,项目名称:commons,代码行数:9,代码来源:thrift_gen.py

示例13: execute_codegen

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
    def execute_codegen(self, target, target_workdir):
        sources_by_base = self._calculate_sources(target)
        sources = target.sources_relative_to_buildroot()

        bases = OrderedSet(sources_by_base.keys())
        bases.update(self._proto_path_imports([target]))

        gen_flag = "--java_out"

        gen = "{0}={1}".format(gen_flag, target_workdir)

        args = [self.protobuf_binary, gen]

        if self.plugins:
            for plugin in self.plugins:
                args.append("--{0}_out={1}".format(plugin, target_workdir))

        for base in bases:
            args.append("--proto_path={0}".format(base))

        args.extend(sources)

        # Tack on extra path entries. These can be used to find protoc plugins
        protoc_environ = os.environ.copy()
        if self._extra_paths:
            protoc_environ["PATH"] = os.pathsep.join(self._extra_paths + protoc_environ["PATH"].split(os.pathsep))

        # Note: The test_source_ordering integration test scrapes this output, so modify it with care.
        self.context.log.debug("Executing: {0}".format("\\\n  ".join(args)))
        with self.context.new_workunit(name="protoc", labels=[WorkUnitLabel.TOOL], cmd=" ".join(args)) as workunit:
            result = subprocess.call(
                args, env=protoc_environ, stdout=workunit.output("stdout"), stderr=workunit.output("stderr")
            )
            if result != 0:
                raise TaskError("{} ... exited non-zero ({})".format(self.protobuf_binary, result))
开发者ID:cevaris,项目名称:pants,代码行数:37,代码来源:protobuf_gen.py

示例14: _aggregate

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
  def _aggregate(cls, name, provides, apt_libs):
    all_deps = OrderedSet()
    all_excludes = OrderedSet()
    all_sources = []
    all_resources = []
    all_binary_resources = []
    all_annotation_processors = []

    for apt_lib in apt_libs:
      if apt_lib.resolved_dependencies:
        all_deps.update(dep for dep in apt_lib.jar_dependencies if dep.rev is not None)
      if apt_lib.excludes:
        all_excludes.update(apt_lib.excludes)
      if apt_lib.sources:
        all_sources.extend(apt_lib.sources)
      if apt_lib.resources:
        all_resources.extend(apt_lib.resources)
      if apt_lib.binary_resources:
        all_binary_resources.extend(apt_lib.binary_resources)
      if apt_lib.processors:
        all_annotation_processors.extend(apt_lib.processors)

    return AnnotationProcessor(name,
                               all_sources,
                               provides = provides,
                               dependencies = all_deps,
                               excludes = all_excludes,
                               resources = all_resources,
                               binary_resources = all_binary_resources,
                               processors = all_annotation_processors,
                               is_meta = True)
开发者ID:crnt,项目名称:commons,代码行数:33,代码来源:annotation_processor.py

示例15: targets

# 需要导入模块: from twitter.common.collections import OrderedSet [as 别名]
# 或者: from twitter.common.collections.OrderedSet import update [as 别名]
    def targets(self, predicate=None, postorder=False):
        """Selects targets in-play in this run from the target roots and their transitive dependencies.

    Also includes any new synthetic targets created from the target roots or their transitive
    dependencies during the course of the run.

    :param predicate: If specified, the predicate will be used to narrow the scope of targets
                      returned.
    :param bool postorder: `True` to gather transitive dependencies with a postorder traversal;
                          `False` or preorder by default.
    :returns: A list of matching targets.
    """
        target_root_addresses = [target.address for target in self.target_roots]
        target_set = self._collect_targets(self.target_roots, postorder=postorder)

        synthetics = OrderedSet()
        for derived_from, synthetic_targets in self._synthetic_targets.items():
            if derived_from in target_set or derived_from in synthetics:
                synthetics.update(synthetic_targets)

        synthetic_set = self._collect_targets(synthetics, postorder=postorder)

        target_set.update(synthetic_set)

        return filter(predicate, target_set)
开发者ID:pcurry,项目名称:pants,代码行数:27,代码来源:context.py


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