Skip to content

Commit 8b5b68c

Browse files
authored
Merge pull request #604 from petersontex/test_compliance
Test compliance
2 parents 9109b50 + 7b4b42c commit 8b5b68c

File tree

4 files changed

+981
-164
lines changed

4 files changed

+981
-164
lines changed

sarpy/io/general/nitf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,7 @@ def item_bytes(self, value: Union[bytes, Sequence]) -> None:
26952695
self._item_bytes = value
26962696
if self._item_size is None or self.item_size != len(value):
26972697
self.item_size = len(value)
2698+
26982699

26992700
@property
27002701
def item_written(self) -> bool:
@@ -4126,9 +4127,7 @@ def get_data_segments(self) -> List[DataSegment]:
41264127

41274128
def flush(self, force: bool = False) -> None:
41284129
self._validate_closed()
4129-
41304130
BaseWriter.flush(self, force=force)
4131-
41324131
try:
41334132
if self._in_memory:
41344133
if self._image_segment_data_segments is not None:

sarpy/io/xml/base.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,8 @@ def parse_complex(value, name, instance):
508508
value : ElementTree.Element|None|complex|dict
509509
The ElementTree.Element entity that you want to get the value from.
510510
None returns None.
511-
Float returns a float.
512-
A string value will return the float value for the string if it can be
513-
converted to a float.
511+
complex returns a complex.
512+
dict is a dictionary representation of a complex number.
514513
name : str
515514
Name of the field to return the value of. This is only used in the
516515
raised error message
@@ -520,7 +519,7 @@ def parse_complex(value, name, instance):
520519
Returns
521520
-------
522521
None | bool
523-
Returns None if value passed is None. Returns the float value
522+
Returns None if value passed is None. Returns the complex value
524523
of a node when passed an ElementTree.Element
525524
526525
Raises
@@ -574,6 +573,36 @@ def parse_complex(value, name, instance):
574573

575574

576575
def parse_datetime(value, name, instance, units='us'):
576+
"""
577+
The parse_datetime function is a helper function specifically for parsing
578+
datetime values within XML elements in sarpy.io.xml.base.
579+
The function is not intended for public use. This function is recursive.
580+
581+
Parameters
582+
----------
583+
value : ElementTree.Element|None|datetime|dict
584+
The ElementTree.Element entity that you want to get the value from.
585+
None returns None.
586+
datetime returns a datetime.
587+
A string value will return the datetime value for the string if it can be
588+
converted to a datetime.
589+
name : str
590+
Name of the field to return the value of. This is only used in the
591+
raised error message
592+
instance :
593+
The class of the variable. This is only used in the raised error message.
594+
595+
Returns
596+
-------
597+
None | bool
598+
Returns None if value passed is None. Returns the float value
599+
of a node when passed an ElementTree.Element
600+
601+
Raises
602+
-------
603+
TypeError
604+
When passed a value with a type other than the expected input types.
605+
"""
577606
if value is None:
578607
return None
579608
if isinstance(value, numpy.datetime64):

tests/io/xml/actor_test_data.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<name>John Cleese</name>
66
<fictional:character>Lancelot</fictional:character>
77
<fictional:character>Archie Leach</fictional:character>
8+
<born>1939-10-27</born>
89
</actor>
910
<actor>
1011
<name>Eric Idle</name>

0 commit comments

Comments
 (0)