Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 635131b

Browse files
author
Steve Canny
committed
img: add _Chunk
1 parent 8ab2f34 commit 635131b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docx/image/png.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,14 @@ def from_offset(cls, chunk_type, stream_rdr, offset):
292292
"""
293293
Return a default _Chunk instance that only knows its chunk type.
294294
"""
295-
raise NotImplementedError
295+
return cls(chunk_type)
296+
297+
@property
298+
def type_name(self):
299+
"""
300+
The chunk type name, e.g. 'IHDR', 'pHYs', etc.
301+
"""
302+
return self._chunk_type
296303

297304

298305
class _IHDRChunk(_Chunk):

tests/image/test_png.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,15 @@ def stream_rdr_(self, request):
506506
return instance_mock(request, StreamReader)
507507

508508

509+
class Describe_Chunk(object):
510+
511+
def it_can_construct_from_a_stream_and_offset(self):
512+
chunk_type = 'fOOB'
513+
chunk = _Chunk.from_offset(chunk_type, None, None)
514+
assert isinstance(chunk, _Chunk)
515+
assert chunk.type_name == chunk_type
516+
517+
509518
class Describe_IHDRChunk(object):
510519

511520
def it_can_construct_from_a_stream_and_offset(self, from_offset_fixture):

0 commit comments

Comments
 (0)