예제 #1
0
 def collect_inline_dependencies(item):
     for key, value in sorted(item._asdict().items(), key=_key_func):
         if not AddressableDescriptor.is_addressable(item, key):
             continue
         if isinstance(value, MutableMapping):
             for _, v in sorted(value.items(), key=_key_func):
                 maybe_append(key, v)
         elif isinstance(value, MutableSequence):
             for v in value:
                 maybe_append(key, v)
         else:
             maybe_append(key, value)
예제 #2
0
파일: graph.py 프로젝트: anubnair/pants
 def collect_dependencies(item):
   for key, value in sorted(item._asdict().items(), key=_key_func):
     if not AddressableDescriptor.is_addressable(item, key):
       continue
     if isinstance(value, collections.MutableMapping):
       for _, v in sorted(value.items(), key=_key_func):
         maybe_append(key, v)
     elif isinstance(value, collections.MutableSequence):
       for v in value:
         maybe_append(key, v)
     else:
       maybe_append(key, value)
예제 #3
0
  def consume_dependencies(item, args=None):
    hydrated_args = args or {}
    for key, value in sorted(item._asdict().items(), key=_key_func):
      if not AddressableDescriptor.is_addressable(item, key):
        hydrated_args[key] = value
        continue

      if isinstance(value, collections.MutableMapping):
        container_type = type(value)
        hydrated_args[key] = container_type((k, maybe_consume(key, v))
                                            for k, v in sorted(value.items(), key=_key_func))
      elif isinstance(value, collections.MutableSequence):
        container_type = type(value)
        hydrated_args[key] = container_type(maybe_consume(key, v) for v in value)
      else:
        hydrated_args[key] = maybe_consume(key, value)
    return _hydrate(type(item), address.spec_path, **hydrated_args)
예제 #4
0
파일: graph.py 프로젝트: anubnair/pants
  def consume_dependencies(item, args=None):
    hydrated_args = args or {}
    for key, value in sorted(item._asdict().items(), key=_key_func):
      if not AddressableDescriptor.is_addressable(item, key):
        hydrated_args[key] = value
        continue

      if isinstance(value, collections.MutableMapping):
        container_type = type(value)
        hydrated_args[key] = container_type((k, maybe_consume(key, v))
                                            for k, v in sorted(value.items(), key=_key_func))
      elif isinstance(value, collections.MutableSequence):
        container_type = type(value)
        hydrated_args[key] = container_type(maybe_consume(key, v) for v in value)
      else:
        hydrated_args[key] = maybe_consume(key, value)
    return _hydrate(type(item), address.spec_path, **hydrated_args)
예제 #5
0
    def consume_dependencies(item, args=None):
        hydrated_args = args or {}
        for key, value in sorted(item._asdict().items(), key=_key_func):
            if not AddressableDescriptor.is_addressable(item, key):
                hydrated_args[key] = value
                continue

            if isinstance(value, Mapping):
                hydrated_args[key] = {
                    k: maybe_consume(key, v)
                    for k, v in sorted(value.items(), key=_key_func)
                }
            elif isinstance(value, (list, tuple)):
                hydrated_args[key] = tuple(
                    maybe_consume(key, v) for v in value)
            else:
                hydrated_args[key] = maybe_consume(key, value)
        return _hydrate(type(item), address.spec_path, **hydrated_args)