mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-02 16:50:20 +03:00
refactor: replace percent formatting with format specifiers
This commit is contained in:
parent
06899c92fc
commit
95ada23395
@ -277,7 +277,7 @@ class DockerVM(BaseNode):
|
||||
|
||||
if not mac_address:
|
||||
# use the node UUID to generate a random MAC address
|
||||
self._mac_address = "02:42:%s:%s:%s:00" % (self.id[2:4], self.id[4:6], self.id[6:8])
|
||||
self._mac_address = "02:42:{}:{}:{}:00".format(self.id[2:4], self.id[4:6], self.id[6:8])
|
||||
else:
|
||||
self._mac_address = mac_address
|
||||
|
||||
|
||||
@ -52,4 +52,4 @@ def unpack_zip(filename, extract_dir=None):
|
||||
for fname, date_time in reversed(dirs):
|
||||
os.utime(fname, (date_time, date_time))
|
||||
except zipfile.BadZipFile:
|
||||
raise shutil.ReadError("%s is not a zip file" % filename)
|
||||
raise shutil.ReadError("{} is not a zip file".format(filename))
|
||||
|
||||
@ -59,10 +59,10 @@ class GUID(TypeDecorator):
|
||||
return str(value)
|
||||
else:
|
||||
if not isinstance(value, uuid.UUID):
|
||||
return "%.32x" % uuid.UUID(value).int
|
||||
return "{:032x}".format(uuid.UUID(value).int)
|
||||
else:
|
||||
# hexstring
|
||||
return "%.32x" % value.int
|
||||
return "{:032x}".format(value.int)
|
||||
|
||||
def process_result_value(self, value, dialect):
|
||||
if value is None:
|
||||
|
||||
@ -50,7 +50,7 @@ def int_to_macaddress(integer):
|
||||
"""
|
||||
Convert an integer to a mac address
|
||||
"""
|
||||
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
|
||||
return ":".join(textwrap.wrap("{:012x}".format(integer), width=2))
|
||||
|
||||
|
||||
def parse_version(version):
|
||||
|
||||
@ -183,7 +183,7 @@ class ZipFile(zipfile.ZipFile):
|
||||
"""
|
||||
|
||||
if not isinstance(comment, bytes):
|
||||
raise TypeError("comment: expected bytes, got %s" % type(comment))
|
||||
raise TypeError("comment: expected bytes, got {}".format(type(comment)))
|
||||
# check for valid comment length
|
||||
if len(comment) >= zipfile.ZIP_MAX_COMMENT:
|
||||
if self.debug:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user