|
8 | 8 | import platform
|
9 | 9 |
|
10 | 10 |
|
11 |
| -class BaseLength(int): |
| 11 | +class Length(int): |
12 | 12 | """
|
13 | 13 | Base class for length classes Inches, Emu, Cm, Mm, Pt, and Px. Provides
|
14 | 14 | properties for converting length values to convenient units.
|
@@ -79,66 +79,66 @@ def px(self):
|
79 | 79 | return int(round(self / float(self._EMUS_PER_PX)) + 0.1)
|
80 | 80 |
|
81 | 81 |
|
82 |
| -class Inches(BaseLength): |
| 82 | +class Inches(Length): |
83 | 83 | """
|
84 | 84 | Convenience constructor for length in inches
|
85 | 85 | """
|
86 | 86 | def __new__(cls, inches):
|
87 |
| - emu = int(inches * BaseLength._EMUS_PER_INCH) |
88 |
| - return BaseLength.__new__(cls, emu) |
| 87 | + emu = int(inches * Length._EMUS_PER_INCH) |
| 88 | + return Length.__new__(cls, emu) |
89 | 89 |
|
90 | 90 |
|
91 |
| -class Centipoints(BaseLength): |
| 91 | +class Centipoints(Length): |
92 | 92 | """
|
93 | 93 | Convenience constructor for length in hundredths of a point
|
94 | 94 | """
|
95 | 95 | def __new__(cls, centipoints):
|
96 |
| - emu = int(centipoints * BaseLength._EMUS_PER_CENTIPOINT) |
97 |
| - return BaseLength.__new__(cls, emu) |
| 96 | + emu = int(centipoints * Length._EMUS_PER_CENTIPOINT) |
| 97 | + return Length.__new__(cls, emu) |
98 | 98 |
|
99 | 99 |
|
100 |
| -class Cm(BaseLength): |
| 100 | +class Cm(Length): |
101 | 101 | """
|
102 | 102 | Convenience constructor for length in centimeters
|
103 | 103 | """
|
104 | 104 | def __new__(cls, cm):
|
105 |
| - emu = int(cm * BaseLength._EMUS_PER_CM) |
106 |
| - return BaseLength.__new__(cls, emu) |
| 105 | + emu = int(cm * Length._EMUS_PER_CM) |
| 106 | + return Length.__new__(cls, emu) |
107 | 107 |
|
108 | 108 |
|
109 |
| -class Emu(BaseLength): |
| 109 | +class Emu(Length): |
110 | 110 | """
|
111 | 111 | Convenience constructor for length in english metric units
|
112 | 112 | """
|
113 | 113 | def __new__(cls, emu):
|
114 |
| - return BaseLength.__new__(cls, int(emu)) |
| 114 | + return Length.__new__(cls, int(emu)) |
115 | 115 |
|
116 | 116 |
|
117 |
| -class Mm(BaseLength): |
| 117 | +class Mm(Length): |
118 | 118 | """
|
119 | 119 | Convenience constructor for length in millimeters
|
120 | 120 | """
|
121 | 121 | def __new__(cls, mm):
|
122 |
| - emu = int(mm * BaseLength._EMUS_PER_MM) |
123 |
| - return BaseLength.__new__(cls, emu) |
| 122 | + emu = int(mm * Length._EMUS_PER_MM) |
| 123 | + return Length.__new__(cls, emu) |
124 | 124 |
|
125 | 125 |
|
126 |
| -class Pt(BaseLength): |
| 126 | +class Pt(Length): |
127 | 127 | """
|
128 | 128 | Convenience value class for specifying a length in points
|
129 | 129 | """
|
130 | 130 | def __new__(cls, points):
|
131 |
| - emu = int(points * BaseLength._EMUS_PER_PT) |
132 |
| - return BaseLength.__new__(cls, emu) |
| 131 | + emu = int(points * Length._EMUS_PER_PT) |
| 132 | + return Length.__new__(cls, emu) |
133 | 133 |
|
134 | 134 |
|
135 |
| -class Px(BaseLength): |
| 135 | +class Px(Length): |
136 | 136 | """
|
137 | 137 | Convenience constructor for length in pixels
|
138 | 138 | """
|
139 | 139 | def __new__(cls, px):
|
140 |
| - emu = int(px * BaseLength._EMUS_PER_PX) |
141 |
| - return BaseLength.__new__(cls, emu) |
| 140 | + emu = int(px * Length._EMUS_PER_PX) |
| 141 | + return Length.__new__(cls, emu) |
142 | 142 |
|
143 | 143 |
|
144 | 144 | def lazyproperty(f):
|
|
0 commit comments