Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Python 3/2 compatibility: Convert Byte-str to Str | Radostin Stoyanov | 2017-07-21 | 1 | -7/+8 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Encoded Unicode in Python 3 is represented as binary data. The difference with Python2 is that any attempt to mix text and data in Python 3.0 raises TypeError, whereas if you were to mix Unicode and 8-bit strings in Python 2.x, it would work if the 8-bit string happened to contain only 7-bit (ASCII) bytes, but you would get UnicodeDecodeError if it contained non-ASCII values. Reference: https://docs.python.org/release/3.0.1/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit Example: Python 2: >>> b'foo.bar'.split('.') ['foo', 'bar'] Python 3: >>> b'foo.bar'.split('.') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: a bytes-like object is required, not 'str' >>> b'foo.bar'.split(b'.') [b'foo', b'bar'] | ||||
* | utils: bytes_to_size remove trailing space | Radostin Stoyanov | 2017-07-18 | 1 | -1/+1 |
| | | | | | Remove traling space which occurs when the number is smaller than kibibyte. | ||||
* | utils: size_to_bytes convert from int | Radostin Stoyanov | 2017-07-18 | 1 | -2/+2 |
| | | | | | | | | | | | | When converting 0 KB with string input the result will be string with zeroes. >>> print(size_to_bytes('0', 'KB')) 000000... Instead convert the string input to integer and then perform the conversion. Rename the variable from "string" to "number" to avoid confusion. | ||||
* | Rename format_number() into bytes_to_size() | Cédric Bosdonnat | 2017-07-05 | 1 | -2/+2 |
| | | | | rename the function to match its counterpart size_to_bytes(). | ||||
* | Gather common utility functions in "utils" module | Radostin Stoyanov | 2017-07-05 | 1 | -0/+346 |
Add new module to collect utility functions used in virt-bootstrap. Move the function definitions from "sources" and "virt_bootstrap" to the new module. |