예제 #1
0
    def remove_end_entries_by_pred(self, maccor_ast, pred):
        new_ast = copy.deepcopy(maccor_ast)
        steps = get(new_ast, "MaccorTestProcedure.ProcSteps.TestStep")
        if steps is None:
            print("Could not find any Maccor steps loaded")
            return maccor_ast

        for i, step in enumerate(steps):
            step_num = i + 1
            if get(step, "Ends.EndEntry") is None:
                continue
            elif type(get(step, "Ends.EndEntry")) == list:
                filtered = list(
                    filter(
                        lambda end_entry: pred(end_entry, step_num),
                        step["Ends"]["EndEntry"],
                    ))

                if len(filtered) == 0:
                    unset(step, "Ends.EndEntry")
                elif len(filtered) == 1:
                    set_(step, "Ends.EndEntry", filtered[0])
                else:
                    set_(step, "Ends.EndEntry", filtered)
            else:
                if not pred(get(step, "Ends.EndEntry"), step_num):
                    unset(step, "Ends.EndEntry")

        return new_ast
예제 #2
0
 def unset(self, key):
     """
     Remove key from object
     :param key: String
     :return: self
     """
     unset(self._data, key)
     return self
예제 #3
0
    def to_dict(self, discard_private_qualifiers: bool = True) -> Dict:
        """
        Turn the Box and sub Boxes back into a native python dictionary.
        :return: python dictionary of this Box
        """
        out_dict = copy.deepcopy(dict(self))
        for k, v in out_dict.items():
            if isinstance(v, Box):
                out_dict[k] = self.decode(v.to_dict())
            elif isinstance(v, BoxList):
                out_dict[k] = self.decode(v.to_list())

        if discard_private_qualifiers:
            chunks = self.chunks_as_lists(discard_private_qualifiers=False)
            for key, value in chunks:
                if any([x for x in self.PRIVATE_KEYS if x in key]):
                    pydash.unset(out_dict, key)

        return out_dict
예제 #4
0
 def from_dict(cls, obj, scale: int = None):
     parameters = obj.get('parameters', {})
     height = parameters.get('height', 200)
     unset(parameters, 'height')
     unset(parameters, 'width')
     component = TYPE_TO_COMPONENT[obj['type']](
         id_=obj['id'],
         height=height,
         width=scale,
         **{snake_case(k): v
            for k, v in parameters.items()})
     selections, container_ids, tags = obj.get('selections'), obj.get(
         'containerIds'), obj.get('tags')
     if selections:
         component.selections = [
             Selection.from_dict(selection) for selection in selections
         ]
     if container_ids:
         component.__container_ids = [
             containerId for containerId in container_ids
         ]
     if tags:
         component.tags = tags
     return component
예제 #5
0
 def remove_unwanted_fields(self, test_case):
     pydash.unset(test_case, "testLine")
     pydash.unset(test_case, "commented")
     pydash.unset(test_case, "GROUP")
예제 #6
0
 def remove_group(x):
     pydash.unset(x, 'GROUP')
     pydash.unset(x, 'commented')
     pydash.unset(x, 'testLine')
예제 #7
0
def test_unset(obj, path, expected, new_obj):
    assert _.unset(obj, path) == expected
    assert obj == new_obj
예제 #8
0
 def _unset(obj, path):
     pyd.unset(obj, path)
     return obj
예제 #9
0
 def unset(self, string):
     unset(self, string)
예제 #10
0
def test_unset(obj, path, expected, new_obj):
    assert _.unset(obj, path) == expected
    assert obj == new_obj
예제 #11
0
파일: objects.py 프로젝트: dgilland/pydash
 def _unset(obj, path):
     pyd.unset(obj, path)
     return obj
예제 #12
0
 def __delitem__(self, field):
     _.unset(self.storage, field)
     self.changed = True