24d8a1652b3bf99115c67ba9f47e06b172fe8e00,src/python/pants/engine/exp/mapper.py,AddressMap,parse,#Any#Any#Any#,33

Before Change


    
    parse = parse or parsers.parse_json
    with open(path, "r") as fp:
      objects = parse(fp.read())
      objects_by_name = {}
      for obj in objects:
        if not Serializable.is_serializable(obj) or not obj._asdict().get("name"):
          raise UnaddressableObjectError("Parsed a non-addressable object: {!r}".format(obj))
        attributes = obj._asdict()
        name = attributes["name"]
        if name in objects_by_name:
          raise DuplicateNameError("An object already exists at {!r} with name {!r}: {!r}.  Cannot "
                                   "map {!r}".format(path, name, objects_by_name[name], obj))
        objects_by_name[name] = obj
      return cls(path, objects_by_name)

  def __init__(self, path, objects_by_name):
    Not intended for direct use, instead see `parse`.

After Change


                  addressable Serializable objects parsed from it.
    
    parse = parser or parsers.parse_json
    objects = parse(path)
    objects_by_name = {}
    for obj in objects:
      if not Serializable.is_serializable(obj):
        raise UnaddressableObjectError("Parsed a non-serializable object: {!r}".format(obj))
      attributes = obj._asdict()

      name = attributes.get("name")
      if not name:
        raise UnaddressableObjectError("Parsed a non-addressable object: {!r}".format(obj))

      if name in objects_by_name:
        raise DuplicateNameError("An object already exists at {!r} with name {!r}: {!r}.  Cannot "
                                 "map {!r}".format(path, name, objects_by_name[name], obj))

      objects_by_name[name] = obj
    return cls(path, objects_by_name)

  def __init__(self, path, objects_by_name):
    Not intended for direct use, instead see `parse`.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: pantsbuild/pants
Commit Name: 24d8a1652b3bf99115c67ba9f47e06b172fe8e00
Time: 2015-10-09
Author: john.sirois@gmail.com
File Name: src/python/pants/engine/exp/mapper.py
Class Name: AddressMap
Method Name: parse


Project Name: graphbrain/graphbrain
Commit Name: a724c8a5d84f531c029fe3efd3d6d01b28880af1
Time: 2020-11-15
Author: telmo@telmomenezes.net
File Name: graphbrain/cognition/agents/txt_parser.py
Class Name: TxtParser
Method Name: run


Project Name: shibing624/pycorrector
Commit Name: 4e144c9f842d7415d8be5bdbb5912d88ae32cced
Time: 2018-04-16
Author: 507153809@qq.com
File Name: pycorrector/seq2seq/corpus_reader.py
Class Name: CGEDReader
Method Name: read_tokens