From 5a67c4d68124b337f507db6b896e5fbe7bd9d0b0 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 8 Nov 2012 12:16:02 +0200 Subject: [PATCH] Rename API classes Change API class names from BmapCreator/BmapFlasher to BmapCreate/BmapFlash. I plan to get rid of 'bmap-creator' and 'bmap-flasher' and instead, have a single 'bmap' tool with sub-commands: bmap create and bmap flash. Change-Id: I5b6fbb0b75954fc27ce39ad5e4317f4957461595 Signed-off-by: Artem Bityutskiy --- bmap-creator | 4 ++-- bmap-flasher | 10 +++++----- bmaptools/BmapCreate.py | 8 ++++---- bmaptools/BmapFlash.py | 10 +++++----- bmaptools/BmapHelpers.py | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bmap-creator b/bmap-creator index a770bb4..88829f7 100755 --- a/bmap-creator +++ b/bmap-creator @@ -123,9 +123,9 @@ def main(): output = setup_output_stream(args.output) try: - creator = BmapCreator.BmapCreator(args.image, output) + creator = BmapCreate.BmapCreate(args.image, output) creator.generate(not args.no_checksum) - except BmapCreator.Error as err: + except BmapCreate.Error as err: log.error(str(err)) raise SystemExit(1) diff --git a/bmap-flasher b/bmap-flasher index 9bb9dac..504eb1c 100755 --- a/bmap-flasher +++ b/bmap-flasher @@ -40,7 +40,7 @@ def parse_arguments(): # The first positional argument - image file text = "the image file to flash. Supported formats: uncompressed, " + \ - ", ".join(BmapFlasher.supported_image_formats) + ", ".join(BmapFlash.supported_image_formats) parser.add_argument("image", help = text) # The second positional argument - block device node @@ -96,8 +96,8 @@ def main(): log = setup_logger(logging.INFO) try: - flasher = BmapFlasher.BmapFlasher(args.image, args.bdev, args.bmap) - except BmapFlasher.Error as err: + flasher = BmapFlash.BmapFlash(args.image, args.bdev, args.bmap) + except BmapFlash.Error as err: log.error(str(err)) raise SystemExit(1) @@ -121,7 +121,7 @@ def main(): try: try: flasher.write(False, not args.no_verify) - except BmapFlasher.Error as err: + except BmapFlash.Error as err: log.error(str(err)) raise SystemExit(1) @@ -129,7 +129,7 @@ def main(): log.info("synchronizing block device '%s'" % args.bdev) try: flasher.sync() - except BmapFlasher.Error as err: + except BmapFlash.Error as err: log.error(str(err)) raise SystemExit(1) except KeyboardInterrupt: diff --git a/bmaptools/BmapCreate.py b/bmaptools/BmapCreate.py index 402930c..d3ef947 100644 --- a/bmaptools/BmapCreate.py +++ b/bmaptools/BmapCreate.py @@ -1,6 +1,6 @@ """ This module implements the block map (AKA bmap) generating functionality and -provides corresponding API (in a form of the BmapCreator class). +provides corresponding API (in a form of the BmapCreate class). The idea is that while images files may generally be very large (e.g., 4GiB), they may nevertheless contain only little real data, e.g., 512MiB. This data @@ -39,7 +39,7 @@ import array bmap_version = "1.2" class Error(Exception): - """ A class for exceptions of BmapCreator. We currently support only one + """ A class for exceptions of BmapCreate. We currently support only one type of exceptions, and we basically throw human-readable problem description in case of errors. """ @@ -51,10 +51,10 @@ class Error(Exception): def __str__(self): return self.strerror -class BmapCreator: +class BmapCreate: """ This class the bmap creation functionality. To generate a bmap for an image (which is supposedly a sparse file) you should first create an - instance of 'BmapCreator' and provide: + instance of 'BmapCreate' and provide: * full path to the image to create bmap for * a logger object to output the generated bmap to diff --git a/bmaptools/BmapFlash.py b/bmaptools/BmapFlash.py index 4be30a1..5e7f1d0 100644 --- a/bmaptools/BmapFlash.py +++ b/bmaptools/BmapFlash.py @@ -1,6 +1,6 @@ """ This module implements flashing with block map (AKA bmap) and provides flashing -API (in form of the 'BmapFlasher' class). +API (in form of the 'BmapFlash' class). The bmap contains list of blocks which have to be read from the image file and then written to the block device. The rest of the blocks are not required to be @@ -31,12 +31,12 @@ supported_image_formats = ('bz2', 'gz', 'tar.gz', 'tgz', 'tar.bz2') supported_bmap_version = 1 class Error(Exception): - """ A class for exceptions of BmapFlasher. We currently support only one + """ A class for exceptions of BmapFlash. We currently support only one type of exceptions, and we basically throw human-readable problem description in case of errors. """ pass -class BmapFlasher: +class BmapFlash: """ This class implemends all the bmap flashing functionality. To flash an image to a block device you should create an instance of this class and provide the following: @@ -53,12 +53,12 @@ class BmapFlasher: image. Compression type is defined by the image file extention. Supported types are listed by 'supported_image_formats'. - Once an instance of 'BmapFlasher' is created, all the 'bmap_*' + Once an instance of 'BmapFlash' is created, all the 'bmap_*' attributes are initialized and available. They are read from the bmap. However, in case of bmap-less flashing, some of them (all the image size-related) are available only after writing the image, but not after creating the instance. The reason for this is that when bmap is absent, - 'BmapFlasher' uses sensible fall-back values for 'bmap_*' attributes + 'BmapFlash' uses sensible fall-back values for 'bmap_*' attributes assuming the entire image is "mapped". And if the image is compressed, we cannot easily get the image size unless we decompress it, which is too time-consuming to do in '__init__()'. However, after the 'write()' diff --git a/bmaptools/BmapHelpers.py b/bmaptools/BmapHelpers.py index 64f7361..4d688fe 100644 --- a/bmaptools/BmapHelpers.py +++ b/bmaptools/BmapHelpers.py @@ -1,6 +1,6 @@ """ This module contains various helper functions which are shared between -BmapFlasher and BmapCreator or which are useful for users of bmaptools. +BmapFlash and BmapCreate or which are useful for users of bmaptools. """ def human_size(size): -- 2.7.4