[Notes] [Git][BuildStream/buildstream][danielsilverstone-ct/use-enumerate] _loader/loadelement.py: Use enumerate() in dependency extraction



Title: GitLab

Daniel Silverstone pushed to branch danielsilverstone-ct/use-enumerate at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_loader/loadelement.py
    ... ... @@ -146,8 +146,8 @@ def _extract_depends_from_node(node, *, key=None):
    146 146
         depends = _yaml.node_get(node, list, key, default_value=[])
    
    147 147
         output_deps = []
    
    148 148
     
    
    149
    -    for dep in depends:
    
    150
    -        dep_provenance = _yaml.node_get_provenance(node, key=key, indices=[depends.index(dep)])
    
    149
    +    for index, dep in enumerate(depends):
    
    150
    +        dep_provenance = _yaml.node_get_provenance(node, key=key, indices=[index])
    
    151 151
     
    
    152 152
             if isinstance(dep, str):
    
    153 153
                 dependency = Dependency(dep, provenance=dep_provenance, dep_type=default_dep_type)
    
    ... ... @@ -177,10 +177,8 @@ def _extract_depends_from_node(node, *, key=None):
    177 177
                                         provenance=dep_provenance)
    
    178 178
     
    
    179 179
             else:
    
    180
    -            index = depends.index(dep)
    
    181
    -            p = _yaml.node_get_provenance(node, key=key, indices=[index])
    
    182 180
                 raise LoadError(LoadErrorReason.INVALID_DATA,
    
    183
    -                            "{}: Dependency is not specified as a string or a dictionary".format(p))
    
    181
    +                            "{}: Dependency is not specified as a string or a dictionary".format(dep_provenance))
    
    184 182
     
    
    185 183
             output_deps.append(dependency)
    
    186 184
     
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]