aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBTaskaya <batuhanosmantaskaya@gmail.com>2018-02-23 14:57:35 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-26 13:31:22 -0500
commit3adc1c63e288c3f60b1bdee461a0b15447901bcc (patch)
tree393b09e2d1b05d3ff56b22d7385bc7726e72ce14
parented820f47bc5f9336840a43b3542c0281812bec03 (diff)
tc: python3, string formattings
This patch converts old type string formattings to new type string formattings for adapting Linux Traffic Control (tc) unit testing suite python3. Linux Traffic Control (tc) unit testing suite's code quality improved is improved with this patch. According to python documentation; "The built-in string class provides the ability to do complex variable substitutions and value formatting via the format() method described in PEP 3101. " but the project was using old type formattings and new type string formattings together, this patch's main purpose is converting all old types to new types. Following files changed: 1. tools/testing/selftests/tc-testing/tdc.py 2. tools/testing/selftests/tc-testing/tdc_batch.py Following PEP rules applied: 1. PEP8 - Code Styling 2. PEP3101 - Advanced Code Formatting Signed-off-by: Batuhan Osman Taskaya <batuhanosmantaskaya@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rwxr-xr-xtools/testing/selftests/tc-testing/tdc.py2
-rwxr-xr-xtools/testing/selftests/tc-testing/tdc_batch.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index 6c220bc26d9f..7b50775abaf6 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -445,7 +445,7 @@ def generate_case_ids(alltests):
445 for c in alltests: 445 for c in alltests:
446 if (c["id"] == ""): 446 if (c["id"] == ""):
447 while True: 447 while True:
448 newid = str('%04x' % random.randrange(16**4)) 448 newid = str('{:04x}'.format(random.randrange(16**4)))
449 if (does_id_exist(alltests, newid)): 449 if (does_id_exist(alltests, newid)):
450 continue 450 continue
451 else: 451 else:
diff --git a/tools/testing/selftests/tc-testing/tdc_batch.py b/tools/testing/selftests/tc-testing/tdc_batch.py
index 707c6bfef689..52fa539dc662 100755
--- a/tools/testing/selftests/tc-testing/tdc_batch.py
+++ b/tools/testing/selftests/tc-testing/tdc_batch.py
@@ -49,13 +49,13 @@ index = 0
49for i in range(0x100): 49for i in range(0x100):
50 for j in range(0x100): 50 for j in range(0x100):
51 for k in range(0x100): 51 for k in range(0x100):
52 mac = ("%02x:%02x:%02x" % (i, j, k)) 52 mac = ("{:02x}:{:02x}:{:02x}".format(i, j, k))
53 src_mac = "e4:11:00:" + mac 53 src_mac = "e4:11:00:" + mac
54 dst_mac = "e4:12:00:" + mac 54 dst_mac = "e4:12:00:" + mac
55 cmd = ("filter add dev %s %s protocol ip parent ffff: flower %s " 55 cmd = ("filter add dev {} {} protocol ip parent ffff: flower {} "
56 "src_mac %s dst_mac %s action drop %s" % 56 "src_mac {} dst_mac {} action drop {}".format
57 (device, prio, skip, src_mac, dst_mac, share_action)) 57 (device, prio, skip, src_mac, dst_mac, share_action))
58 file.write("%s\n" % cmd) 58 file.write("{}\n".format(cmd))
59 index += 1 59 index += 1
60 if index >= number: 60 if index >= number:
61 file.close() 61 file.close()