[Notes] [Git][BuildStream/buildstream][master] 2 commits: _yaml.py: Implement `get()` for `ChainMap`



Title: GitLab

Tristan Van Berkom pushed to branch master at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_yaml.py
    ... ... @@ -1049,6 +1049,12 @@ class ChainMap(collections.ChainMap):
    1049 1049
             for key in clearable:
    
    1050 1050
                 del self[key]
    
    1051 1051
     
    
    1052
    +    def get(self, key, default=None):
    
    1053
    +        try:
    
    1054
    +            return self[key]
    
    1055
    +        except KeyError:
    
    1056
    +            return default
    
    1057
    +
    
    1052 1058
     
    
    1053 1059
     def node_chain_copy(source):
    
    1054 1060
         copy = ChainMap({}, source)
    



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