]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Clean unused code
authorHenryk Plötz <henryk@ploetzli.ch>
Sat, 15 Sep 2018 23:20:26 +0000 (01:20 +0200)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:34:29 +0000 (19:34 +0100)
fints/fields.py
fints/types.py
tests/test_formals.py

index 4bf3c00c34d9477a81ea053143acf750a16e66d8..7519c91ccfd4b58d8de7ad04fc40eb148e6d536b 100644 (file)
@@ -20,15 +20,6 @@ class ContainerField(TypedField):
 
     def _default_value(self):
         return self.type()
-
-    @property
-    def flat_length(self):
-        result = 0
-        for name, field in self.type._fields.items():
-            if field.count is None:
-                raise TypeError("Cannot compute flat length of field {}.{} with variable count".format(self.__class__.__name__, name))
-            result = result + field.count * field.flat_length
-        return result
     
 
 class DataElementGroupField(DocTypeMixin, ContainerField):
index a49fb5b7bc3584852e7994e6b80c357c13e400fd..dca8d8a77c4cf4ef90fe72e11cbdfd34836c0aac 100644 (file)
@@ -87,8 +87,6 @@ class Field:
         return ""
 
 class TypedField(Field, SubclassesMixin):
-    flat_length = 1
-
     def __new__(cls, *args, **kwargs):
         target_cls = None
         fallback_cls = None
index 6292b544e4e9181b7dab852a6789d477305df79c..14b72a7c308cc26da0180efdc5b869c508989256 100644 (file)
@@ -218,36 +218,6 @@ def test_container_naive_parse():
     assert i1.a == 23
     assert i1.b == '42'
 
-def test_field_flat_length():
-    class A(Container):
-        a = NumericField()
-
-    class B(Container):
-        b1 = DataElementGroupField(type=A)
-        b2 = DataElementGroupField(type=A, count=3)
-        b3 = DataElementGroupField(type=A, min_count=2)
-
-    assert A._fields['a'].flat_length == 1
-    assert B._fields['b1'].flat_length == 1
-    assert B._fields['b2'].flat_length == 1
-
-    class C(Container):
-        c1 = DataElementGroupField(type=A)
-        c2 = DataElementGroupField(type=A, count=2)
-        c3 = DataElementGroupField(type=A, count=3)
-
-    class D(Container):
-        d1 = DataElementGroupField(type=C, count=4)
-
-    class E(Container):
-        e1 = DataElementGroupField(type=D)
-        e2 = DataElementGroupField(type=B)
-
-    assert E._fields['e1'].flat_length == 4*(1+2+3)
-
-    with pytest.raises(TypeError):
-        E._fields['e2'].flat_length
-
 def test_invalid_spec():
     with pytest.raises(ValueError):
         class A(Container):