diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 337: Merge lp:~lool/linaro-image-tools/no-size-suffix; fixes support for

Message ID 20110506194119.8669.20393.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

loic.minier@linaro.org May 6, 2011, 7:41 p.m. UTC
Merge authors:
  Loïc Minier (lool)
Related merge proposals:
  https://code.launchpad.net/~lool/linaro-image-tools/no-size-suffix/+merge/60183
  proposed by: Loïc Minier (lool)
  review: Approve - Mattias Backman (mabac)
------------------------------------------------------------
revno: 337 [merge]
committer: Loïc Minier <loic.minier@linaro.org>
branch nick: linaro-image-tools
timestamp: Fri 2011-05-06 21:39:05 +0200
message:
  Merge lp:~lool/linaro-image-tools/no-size-suffix; fixes support for
  --image_size without an unit suffix.
modified:
  linaro_image_tools/media_create/partitions.py
  linaro_image_tools/media_create/tests/test_media_create.py


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'linaro_image_tools/media_create/partitions.py'
--- linaro_image_tools/media_create/partitions.py	2011-04-29 11:02:39 +0000
+++ linaro_image_tools/media_create/partitions.py	2011-05-06 13:58:54 +0000
@@ -330,6 +330,9 @@ 
 def convert_size_to_bytes(size):
     """Convert a size string in Kbytes, Mbytes or Gbytes to bytes."""
     unit = size[-1].upper()
+    # no unit? (ends with a digit)
+    if unit in '0123456789':
+        return int(size)
     real_size = int(size[:-1])
     if unit == 'K':
         real_size = real_size * 1024

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2011-05-02 07:59:07 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2011-05-06 13:29:10 +0000
@@ -846,6 +846,9 @@ 
         return self._create_qemu_img_with_partitions(
             '16384,15746,0x0C,*\n32768,,,-')
 
+    def test_convert_size_no_suffix(self):
+        self.assertEqual(524288, convert_size_to_bytes('524288'))
+
     def test_convert_size_in_kbytes_to_bytes(self):
         self.assertEqual(512 * 1024, convert_size_to_bytes('512K'))