Beispiel #1
0
    def subset(self, keys):
        only, exclude = process_fields(keys)

        if only and not exclude:
            return dictset([[k, v] for k, v in self.items() if k in only])

        if exclude:
            return dictset([[k, v] for k, v in self.items() if k not in exclude])

        return dictset()
Beispiel #2
0
    def subset(self, keys):
        only, exclude = process_fields(keys)

        if only and not exclude:
            return dictset([[k, v] for k, v in self.items() if k in only])

        if exclude:
            return dictset([[k, v] for k, v in self.items()
                            if k not in exclude])

        return dictset()
Beispiel #3
0
 def remove(self, keys):
     only, _ = process_fields(keys)
     return dictset([[k, v] for k, v in self.items() if k not in only])
Beispiel #4
0
 def test_process_fields_empty_field(self):
     only, exclude = utils.process_fields(['a', 'b', '-c', ''])
     assert only == ['a', 'b']
     assert exclude == ['c']
Beispiel #5
0
 def test_process_fields_string(self):
     only, exclude = utils.process_fields('a,b,-c')
     assert only == ['a', 'b']
     assert exclude == ['c']
Beispiel #6
0
 def test_process_fields_empty_field(self):
     only, exclude = utils.process_fields(['a', 'b', '-c', ''])
     assert only == ['a', 'b']
     assert exclude == ['c']
Beispiel #7
0
 def test_process_fields_string(self):
     only, exclude = utils.process_fields('a,b,-c')
     assert only == ['a', 'b']
     assert exclude == ['c']