Changeset a35b458 in mainline for tools/imgutil.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/imgutil.py

    r3061bc1 ra35b458  
    4040def align_up(size, alignment):
    4141        "Return size aligned up to alignment"
    42        
     42
    4343        if (size % alignment == 0):
    4444                return size
    45        
     45
    4646        return ((size // alignment) + 1) * alignment
    4747
    4848def count_up(size, alignment):
    4949        "Return units necessary to fit the size"
    50        
     50
    5151        if (size % alignment == 0):
    5252                return (size // alignment)
    53        
     53
    5454        return ((size // alignment) + 1)
    5555
    5656def num_of_trailing_bin_zeros(num):
    5757        "Return number of trailing zeros in binary representation"
    58        
     58
    5959        i = 0
    6060        if (num == 0): raise ValueError()
     
    6666def get_bit(number, n):
    6767        "Return True if n-th least-significant bit is set in the given number"
    68        
     68
    6969        return bool((number >> n) & 1)
    7070
    7171def set_bit(number, n):
    7272        "Return the number with n-th least-significant bit set"
    73        
     73
    7474        return number | (1 << n)
    7575
    7676class ItemToPack:
    7777        "Stores information about one directory item to be added to the image"
    78        
     78
    7979        def __init__(self, parent, name):
    8080                self.parent = parent
     
    8888def listdir_items(path):
    8989        "Return a list of items to be packed inside a fs image"
    90        
     90
    9191        for name in os.listdir(path):
    9292                if name in exclude_names:
    9393                        continue
    94                
     94
    9595                item = ItemToPack(path, name)
    96                
     96
    9797                if not (item.is_dir or item.is_file):
    9898                        continue
    99                
     99
    100100                yield item
    101101
    102102def chunks(item, chunk_size):
    103103        "Iterate contents of a file in chunks of a given size"
    104        
     104
    105105        inf = open(item.path, 'rb')
    106106        rd = 0
    107        
     107
    108108        while (rd < item.size):
    109109                data = bytes(inf.read(chunk_size))
    110110                yield data
    111111                rd += len(data)
    112        
     112
    113113        inf.close()
Note: See TracChangeset for help on using the changeset viewer.