Remove need for translate/maketrans due to py3 differences
* translate() has a different api for text vs byte strings * maketrans must be imported from a different location on py2 vs py3 Since this is such a small string outside of a loop we don't have to worry too much about speed so it's better to have a single piece of code that works on both py2 and py3
This commit is contained in:
parent
c2f4e7c852
commit
4d3fec908b
1 changed files with 1 additions and 6 deletions
|
@ -278,7 +278,6 @@ except ImportError:
|
|||
pass
|
||||
|
||||
import os
|
||||
import string
|
||||
import time
|
||||
from netaddr import IPNetwork, IPAddress
|
||||
|
||||
|
@ -757,11 +756,7 @@ class PyVmomiHelper(object):
|
|||
if [x for x in pspec.keys() if x.startswith('size_') or x == 'size']:
|
||||
# size_tb, size_gb, size_mb, size_kb, size_b ...?
|
||||
if 'size' in pspec:
|
||||
# http://stackoverflow.com/a/1451407
|
||||
trans = string.maketrans('', '')
|
||||
chars = trans.translate(trans, string.digits)
|
||||
expected = pspec['size'].translate(trans, chars)
|
||||
expected = expected
|
||||
expected = ''.join(c for c in pspec['size'] if c.isdigit())
|
||||
unit = pspec['size'].replace(expected, '').lower()
|
||||
expected = int(expected)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue