Skip to content

Commit ca40daf

Browse files
committed
Fix print statement to print function
Closes #98
1 parent 10814fc commit ca40daf

10 files changed

+120
-122
lines changed

README.rst

+16-16
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ Arithmetic
175175
>>> import bitmath
176176
>>> log_size = bitmath.kB(137.4)
177177
>>> log_zipped_size = bitmath.Byte(987)
178-
>>> print "Compression saved %s space" % (log_size - log_zipped_size)
178+
>>> print("Compression saved %s space" % (log_size - log_zipped_size))
179179
Compression saved 136.413kB space
180180
>>> thumb_drive = bitmath.GiB(12)
181181
>>> song_size = bitmath.MiB(5)
182182
>>> songs_per_drive = thumb_drive / song_size
183-
>>> print songs_per_drive
183+
>>> print(songs_per_drive)
184184
2457.6
185185
186186
@@ -193,7 +193,7 @@ File size unit conversion:
193193
194194
>>> from bitmath import *
195195
>>> dvd_size = GiB(4.7)
196-
>>> print "DVD Size in MiB: %s" % dvd_size.to_MiB()
196+
>>> print("DVD Size in MiB: %s" % dvd_size.to_MiB())
197197
DVD Size in MiB: 4812.8 MiB
198198
199199
@@ -205,9 +205,9 @@ Select a human-readable unit
205205
>>> small_number = kB(100)
206206
>>> ugly_number = small_number.to_TiB()
207207
208-
>>> print ugly_number
208+
>>> print(ugly_number)
209209
9.09494701773e-08 TiB
210-
>>> print ugly_number.best_prefix()
210+
>>> print(ugly_number.best_prefix())
211211
97.65625 KiB
212212
213213
@@ -235,7 +235,7 @@ Sorting
235235
KiB(2326.0), KiB(4003.0), KiB(48.0), KiB(1770.0),
236236
KiB(7892.0), KiB(4190.0)]
237237
238-
>>> print sorted(sizes)
238+
>>> print(sorted(sizes))
239239
[KiB(48.0), KiB(1441.0), KiB(1770.0), KiB(2126.0), KiB(2178.0),
240240
KiB(2326.0), KiB(4003.0), KiB(4190.0), KiB(7337.0), KiB(7892.0)]
241241
@@ -261,7 +261,7 @@ Example:
261261
...: The instance is {bits} bits large
262262
...: bytes/bits without trailing decimals: {bytes:.0f}/{bits:.0f}""" % str(ugly_number)
263263
264-
>>> print ugly_number.format(longer_format)
264+
>>> print(ugly_number.format(longer_format))
265265
Formatting attributes for 5.96046447754 MiB
266266
This instances prefix unit is MiB, which is a NIST type unit
267267
The unit value is 5.96046447754
@@ -280,7 +280,7 @@ Utility Functions
280280

281281
.. code-block:: python
282282
283-
>>> print bitmath.getsize('python-bitmath.spec')
283+
>>> print(bitmath.getsize('python-bitmath.spec'))
284284
3.7060546875 KiB
285285
286286
**bitmath.parse_string()**
@@ -291,9 +291,9 @@ Parse a string with standard units:
291291
292292
>>> import bitmath
293293
>>> a_dvd = bitmath.parse_string("4.7 GiB")
294-
>>> print type(a_dvd)
294+
>>> print(type(a_dvd))
295295
<class 'bitmath.GiB'>
296-
>>> print a_dvd
296+
>>> print(a_dvd)
297297
4.7 GiB
298298
299299
**bitmath.parse_string_unsafe()**
@@ -304,7 +304,7 @@ Parse a string with ambiguous units:
304304
305305
>>> import bitmath
306306
>>> a_gig = bitmath.parse_string_unsafe("1gb")
307-
>>> print type(a_gig)
307+
>>> print(type(a_gig))
308308
<class 'bitmath.GB'>
309309
>>> a_gig == bitmath.GB(1)
310310
True
@@ -319,7 +319,7 @@ Parse a string with ambiguous units:
319319
>>> import bitmath
320320
>>> with open('/dev/sda') as fp:
321321
... root_disk = bitmath.query_device_capacity(fp)
322-
... print root_disk.best_prefix()
322+
... print(root_disk.best_prefix())
323323
...
324324
238.474937439 GiB
325325
@@ -328,7 +328,7 @@ Parse a string with ambiguous units:
328328
.. code-block:: python
329329
330330
>>> for i in bitmath.listdir('./tests/', followlinks=True, relpath=True, bestprefix=True):
331-
... print i
331+
... print(i)
332332
...
333333
('tests/test_file_size.py', KiB(9.2900390625))
334334
('tests/test_basic_math.py', KiB(7.1767578125))
@@ -364,7 +364,7 @@ Formatting
364364
365365
>>> with bitmath.format(fmt_str="[{value:.3f}@{unit}]"):
366366
... for i in bitmath.listdir('./tests/', followlinks=True, relpath=True, bestprefix=True):
367-
... print i[1]
367+
... print(i[1])
368368
...
369369
[9.290@KiB]
370370
[7.177@KiB]
@@ -409,9 +409,9 @@ argparser argument type:
409409
required=True)
410410
411411
results = parser.parse_args()
412-
print "Parsed in: {PARSED}; Which looks like {TOKIB} as a Kibibit".format(
412+
print("Parsed in: {PARSED}; Which looks like {TOKIB} as a Kibibit".format(
413413
PARSED=results.block_size,
414-
TOKIB=results.block_size.Kib)
414+
TOKIB=results.block_size.Kib))
415415
416416
If ran as a script the results would be similar to this:
417417

bitmath/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
# pragma: no cover
4242
"""
4343

44-
from __future__ import print_function
45-
4644
import argparse
4745
import contextlib
4846
import fnmatch
@@ -370,7 +368,7 @@ def from_other(cls, item):
370368
371369
>>> import bitmath
372370
>>> kib = bitmath.KiB.from_other(bitmath.MiB(1))
373-
>>> print kib
371+
>>> print(kib)
374372
KiB(1024.0)
375373
376374
"""
@@ -1228,7 +1226,7 @@ def query_device_capacity(device_fd):
12281226
# Confirm this character is right by running (on Linux):
12291227
#
12301228
# >>> import struct
1231-
# >>> print 8 == struct.calcsize('L')
1229+
# >>> print(8 == struct.calcsize('L'))
12321230
#
12331231
# The result should be true as long as your kernel
12341232
# headers define BLKGETSIZE64 as a u64 type (please

docsite/source/appendices/mixed_math.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Let's look at an example of this in action:
160160
161161
In [9]: bm = PiB(24)
162162
163-
In [10]: print num + bm
163+
In [10]: print(num + bm)
164164
66.0
165165
166166
Equivalently, divorcing the bitmath instance from it's value (this is
@@ -170,7 +170,7 @@ coercion):
170170
171171
In [12]: bm_value = bm.value
172172
173-
In [13]: print num + bm_value
173+
In [13]: print(num + bm_value)
174174
66.0
175175
176176
What it all boils down to is this: if we don't provide a unit then

docsite/source/classes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ bitmath class, however that is a valid use case.
201201
>>> a_mebibyte == a_mebibyte_sized_kibibyte
202202
True
203203
204-
>>> print a_mebibyte, a_mebibyte_sized_kibibyte
204+
>>> print(a_mebibyte, a_mebibyte_sized_kibibyte)
205205
1.0 MiB 1024.0 KiB
206206
207207
Or, using the :py:meth:`BitMathClass.from_other` class method:
@@ -216,5 +216,5 @@ bitmath class, however that is a valid use case.
216216
>>> a_mebibyte == a_big_kibibyte
217217
True
218218
219-
>>> print a_mebibyte, a_big_kibibyte
219+
>>> print(a_mebibyte, a_big_kibibyte)
220220
1.0 MiB 1024.0 KiB

docsite/source/index.rst

+16-16
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ Arithmetic
136136
>>> import bitmath
137137
>>> log_size = bitmath.kB(137.4)
138138
>>> log_zipped_size = bitmath.Byte(987)
139-
>>> print "Compression saved %s space" % (log_size - log_zipped_size)
139+
>>> print("Compression saved %s space" % (log_size - log_zipped_size))
140140
Compression saved 136.413kB space
141141
>>> thumb_drive = bitmath.GiB(12)
142142
>>> song_size = bitmath.MiB(5)
143143
>>> songs_per_drive = thumb_drive / song_size
144-
>>> print songs_per_drive
144+
>>> print(songs_per_drive)
145145
2457.6
146146
147147
@@ -154,7 +154,7 @@ File size unit conversion:
154154
155155
>>> from bitmath import *
156156
>>> dvd_size = GiB(4.7)
157-
>>> print "DVD Size in MiB: %s" % dvd_size.to_MiB()
157+
>>> print("DVD Size in MiB: %s" % dvd_size.to_MiB())
158158
DVD Size in MiB: 4812.8 MiB
159159
160160
@@ -166,9 +166,9 @@ Select a human-readable unit
166166
>>> small_number = kB(100)
167167
>>> ugly_number = small_number.to_TiB()
168168
169-
>>> print ugly_number
169+
>>> print(ugly_number)
170170
9.09494701773e-08 TiB
171-
>>> print ugly_number.best_prefix()
171+
>>> print(ugly_number.best_prefix())
172172
97.65625 KiB
173173
174174
@@ -196,7 +196,7 @@ Sorting
196196
KiB(2326.0), KiB(4003.0), KiB(48.0), KiB(1770.0),
197197
KiB(7892.0), KiB(4190.0)]
198198
199-
>>> print sorted(sizes)
199+
>>> print(sorted(sizes))
200200
[KiB(48.0), KiB(1441.0), KiB(1770.0), KiB(2126.0), KiB(2178.0),
201201
KiB(2326.0), KiB(4003.0), KiB(4190.0), KiB(7337.0), KiB(7892.0)]
202202
@@ -222,7 +222,7 @@ Example:
222222
...: The instance is {bits} bits large
223223
...: bytes/bits without trailing decimals: {bytes:.0f}/{bits:.0f}""" % str(ugly_number)
224224
225-
>>> print ugly_number.format(longer_format)
225+
>>> print(ugly_number.format(longer_format))
226226
Formatting attributes for 5.96046447754 MiB
227227
This instances prefix unit is MiB, which is a NIST type unit
228228
The unit value is 5.96046447754
@@ -241,7 +241,7 @@ Utility Functions
241241

242242
.. code-block:: python
243243
244-
>>> print bitmath.getsize('python-bitmath.spec')
244+
>>> print(bitmath.getsize('python-bitmath.spec'))
245245
3.7060546875 KiB
246246
247247
**bitmath.parse_string()**
@@ -252,9 +252,9 @@ Parse a string with standard units:
252252
253253
>>> import bitmath
254254
>>> a_dvd = bitmath.parse_string("4.7 GiB")
255-
>>> print type(a_dvd)
255+
>>> print(type(a_dvd))
256256
<class 'bitmath.GiB'>
257-
>>> print a_dvd
257+
>>> print(a_dvd)
258258
4.7 GiB
259259
260260
**bitmath.parse_string_unsafe()**
@@ -265,7 +265,7 @@ Parse a string with ambiguous units:
265265
266266
>>> import bitmath
267267
>>> a_gig = bitmath.parse_string_unsafe("1gb")
268-
>>> print type(a_gig)
268+
>>> print(type(a_gig))
269269
<class 'bitmath.GB'>
270270
>>> a_gig == bitmath.GB(1)
271271
True
@@ -280,7 +280,7 @@ Parse a string with ambiguous units:
280280
>>> import bitmath
281281
>>> with open('/dev/sda') as fp:
282282
... root_disk = bitmath.query_device_capacity(fp)
283-
... print root_disk.best_prefix()
283+
... print(root_disk.best_prefix())
284284
...
285285
238.474937439 GiB
286286
@@ -289,7 +289,7 @@ Parse a string with ambiguous units:
289289
.. code-block:: python
290290
291291
>>> for i in bitmath.listdir('./tests/', followlinks=True, relpath=True, bestprefix=True):
292-
... print i
292+
... print(i)
293293
...
294294
('tests/test_file_size.py', KiB(9.2900390625))
295295
('tests/test_basic_math.py', KiB(7.1767578125))
@@ -325,7 +325,7 @@ Formatting
325325
326326
>>> with bitmath.format(fmt_str="[{value:.3f}@{unit}]"):
327327
... for i in bitmath.listdir('./tests/', followlinks=True, relpath=True, bestprefix=True):
328-
... print i[1]
328+
... print(i[1])
329329
...
330330
[9.290@KiB]
331331
[7.177@KiB]
@@ -370,9 +370,9 @@ argparser argument type:
370370
required=True)
371371
372372
results = parser.parse_args()
373-
print "Parsed in: {PARSED}; Which looks like {TOKIB} as a Kibibit".format(
373+
print("Parsed in: {PARSED}; Which looks like {TOKIB} as a Kibibit".format(
374374
PARSED=results.block_size,
375-
TOKIB=results.block_size.Kib)
375+
TOKIB=results.block_size.Kib))
376376
377377
If ran as a script the results would be similar to this:
378378

0 commit comments

Comments
 (0)