[blivet][PATCH 1/5] Add support for returning machine word length
Vratislav Podzimek
vpodzime at redhat.com
Fri Nov 8 06:48:50 UTC 2013
On Thu, 2013-11-07 at 18:52 +0100, Martin Kolman wrote:
> Add support for returning machine word length to
> the arch module.
>
> This is needed as some filesystems, such as tmpfs,
> have maximum filesystem size that depends on the
> machine word size.
>
> Related: rhbz#918621
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
> blivet/arch.py | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/blivet/arch.py b/blivet/arch.py
> index 9fa7826..b63dc9f 100644
> --- a/blivet/arch.py
> +++ b/blivet/arch.py
> @@ -25,9 +25,17 @@
> # Dennis Gilmore <dgilmore at ausil.us>
> # David Marlin <dmarlin at redhat.com>
> #
> +from __future__ import absolute_import
> +# The absolute_import is needed so that we can
> +# import the "platform" module from the Python
> +# standard library but not the local blivet module
> +# that is also called "platform".
Could you please swap the import with the comment. I prefer reading from
the top to the bottom. :)
>
> import os
>
> +import logging
> +log = logging.getLogger("blivet")
> +
> from .flags import flags
>
> # DMI information paths
> @@ -318,3 +326,26 @@ def getArch():
> return 'arm'
> else:
> return os.uname()[4]
> +
> +def bits():
> + """Return an integer representing the length
> + of the "word" used by the current architecture
> + -> it is usually either 32 or 64
> +
> + :return: number of bits for the current architecture
> + or None if the number could not be determined
We usually indent docstring lines as blocks.
> + :rtype: integer or None
> + """
> + try:
> + import platform
> + bits = platform.architecture()[0]
> + # the string is in the format:
> + # "<number>bit"
> + # so we remove the bit suffix and convert the
> + # number to an integer
> + bits = bits.replace("bit", "")
Maybe 'bits.rstrip("bit")' here would better match the comment?
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list