Skip to content

Commit 3d1ddee

Browse files
author
Steve Canny
committed
img: rename existing Image to Image_OLD
New image object will be developed in increments until it can replace Image_OLD.
1 parent 9ca490f commit 3d1ddee

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

docx/image/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
from docx.shared import lazyproperty
2323

2424

25-
class Image(object):
25+
class Image_OLD(object):
2626
"""
2727
A helper object that knows how to analyze an image file.
2828
"""
2929
def __init__(
3030
self, blob, filename, content_type, px_width, px_height,
3131
horz_dpi, vert_dpi):
32-
super(Image, self).__init__()
32+
super(Image_OLD, self).__init__()
3333
self._blob = blob
3434
self._filename = filename
3535
self._content_type = content_type

docx/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from docx.opc.constants import RELATIONSHIP_TYPE as RT
1010
from docx.opc.package import OpcPackage
1111
from docx.opc.packuri import PackURI
12-
from docx.parts.image import Image, ImagePart
12+
from docx.parts.image import Image_OLD, ImagePart
1313
from docx.shared import lazyproperty
1414

1515

@@ -72,7 +72,7 @@ def get_or_add_image_part(self, image_descriptor):
7272
*image_descriptor*, newly created if a matching one is not present in
7373
the collection.
7474
"""
75-
image = Image.from_file(image_descriptor)
75+
image = Image_OLD.from_file(image_descriptor)
7676
matching_image_part = self._get_by_sha1(image.sha1)
7777
if matching_image_part is not None:
7878
return matching_image_part

docx/parts/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import hashlib
1212

13-
from docx.image import Image
13+
from docx.image import Image_OLD
1414
from docx.opc.package import Part
1515
from docx.shared import Emu, Inches
1616

@@ -70,7 +70,7 @@ def from_image(cls, image, partname):
7070
@property
7171
def image(self):
7272
if self._image is None:
73-
self._image = Image.from_blob(self.blob)
73+
self._image = Image_OLD.from_blob(self.blob)
7474
return self._image
7575

7676
@classmethod

tests/image/test_image.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@
88

99
import pytest
1010

11-
from docx.image import Image
11+
from docx.image import Image_OLD
1212
from docx.opc.constants import CONTENT_TYPE as CT
1313

1414
from ..unitutil import test_file
1515

1616

17-
class DescribeImage(object):
17+
class DescribeImage_OLD(object):
1818

1919
def it_can_construct_from_an_image_path(self):
2020
image_file_path = test_file('monty-truth.png')
21-
image = Image.from_file(image_file_path)
22-
assert isinstance(image, Image)
21+
image = Image_OLD.from_file(image_file_path)
22+
assert isinstance(image, Image_OLD)
2323
assert image.sha1 == '79769f1e202add2e963158b532e36c2c0f76a70c'
2424
assert image.filename == 'monty-truth.png'
2525

2626
def it_can_construct_from_an_image_stream(self):
2727
image_file_path = test_file('monty-truth.png')
2828
with open(image_file_path, 'rb') as image_file_stream:
29-
image = Image.from_file(image_file_stream)
30-
assert isinstance(image, Image)
29+
image = Image_OLD.from_file(image_file_stream)
30+
assert isinstance(image, Image_OLD)
3131
assert image.sha1 == '79769f1e202add2e963158b532e36c2c0f76a70c'
3232
assert image.filename == 'image.png'
3333

3434
def it_knows_the_extension_of_a_file_based_image(self):
3535
image_file_path = test_file('monty-truth.png')
36-
image = Image.from_file(image_file_path)
36+
image = Image_OLD.from_file(image_file_path)
3737
assert image.ext == '.png'
3838

3939
def it_knows_the_extension_of_a_stream_based_image(self):
4040
image_file_path = test_file('monty-truth.png')
4141
with open(image_file_path, 'rb') as image_file_stream:
42-
image = Image.from_file(image_file_stream)
42+
image = Image_OLD.from_file(image_file_stream)
4343
assert image.ext == '.png'
4444

4545
def it_correctly_characterizes_a_few_known_images(
@@ -49,7 +49,7 @@ def it_correctly_characterizes_a_few_known_images(
4949
characteristics
5050
)
5151
with open(test_file(image_path), 'rb') as stream:
52-
image = Image.from_file(stream)
52+
image = Image_OLD.from_file(stream)
5353
assert image.ext == ext
5454
assert image.content_type == content_type
5555
assert image.px_width == px_width

tests/parts/test_image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010

11-
from docx.image import Image
11+
from docx.image import Image_OLD
1212
from docx.opc.constants import CONTENT_TYPE as CT, RELATIONSHIP_TYPE as RT
1313
from docx.opc.package import PartFactory
1414
from docx.opc.packuri import PackURI
@@ -68,7 +68,7 @@ def blob_(self, request):
6868
@pytest.fixture(params=['loaded', 'new'])
6969
def dimensions_fixture(self, request):
7070
image_file_path = test_file('monty-truth.png')
71-
image = Image.from_file(image_file_path)
71+
image = Image_OLD.from_file(image_file_path)
7272
expected_cx, expected_cy = 1905000, 2717800
7373

7474
# case 1: image part is loaded by PartFactory w/no Image inst
@@ -102,7 +102,7 @@ def from_image_fixture(self, image_, partname_, ImagePart__init__):
102102

103103
@pytest.fixture
104104
def image_(self, request):
105-
return instance_mock(request, Image)
105+
return instance_mock(request, Image_OLD)
106106

107107
@pytest.fixture
108108
def ImagePart__init__(self, request):

tests/test_package.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from docx.opc.packuri import PackURI
1212
from docx.package import ImageParts, Package
13-
from docx.parts.image import Image, ImagePart
13+
from docx.parts.image import Image_OLD, ImagePart
1414

1515
from .unitutil import (
1616
docx_path, class_mock, instance_mock, method_mock
@@ -81,13 +81,13 @@ def get_image_part_fixture(self, Image_, image_part_, image_descriptor_):
8181

8282
@pytest.fixture
8383
def Image_(self, request, image_):
84-
Image_ = class_mock(request, 'docx.package.Image')
84+
Image_ = class_mock(request, 'docx.package.Image_OLD')
8585
Image_.from_file.return_value = image_
8686
return Image_
8787

8888
@pytest.fixture
8989
def image_(self, request, sha1):
90-
image_ = instance_mock(request, Image)
90+
image_ = instance_mock(request, Image_OLD)
9191
image_.sha1 = sha1
9292
return image_
9393

0 commit comments

Comments
 (0)