1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-12 12:23:50 +03:00

python: PEP8 fixup whitespace in getopt.py first

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Rob van der Linde
2023-10-05 11:27:40 +13:00
committed by Andrew Bartlett
parent 029e0457cc
commit 22316fea33

View File

@@ -364,17 +364,17 @@ class CredentialsOptionsDouble(CredentialsOptions):
self.creds2.set_cmdline_callbacks()
return self.creds2
# Custom option type to allow the input of sizes using byte, kb, mb ...
# units, e.g. 2Gb, 4KiB ...
# e.g. Option("--size", type="bytes", metavar="SIZE")
#
def check_bytes(option, opt, value):
multipliers = {
"B" : 1,
"KB" : 1024,
"MB" : 1024 * 1024,
"GB" : 1024 * 1024 * 1024}
multipliers = {"B": 1,
"KB": 1024,
"MB": 1024 * 1024,
"GB": 1024 * 1024 * 1024}
# strip out any spaces
v = value.replace(" ", "")
@@ -392,7 +392,6 @@ def check_bytes(option, opt, value):
"with an optional unit suffix").format(opt)
raise optparse.OptionValueError(msg)
# strip out the 'i' and convert to upper case so
# kib Kib kb KB are all equivalent
suffix = v.upper().replace("I", "")
@@ -403,6 +402,7 @@ def check_bytes(option, opt, value):
"should be B, Kb, Mb or Gb").format(opt, v)
raise optparse.OptionValueError(msg)
class SambaOption(optparse.Option):
TYPES = optparse.Option.TYPES + ("bytes",)
TYPE_CHECKER = copy(optparse.Option.TYPE_CHECKER)