[SEBA-412] Automated reformat of Python code
Passes of modernize, autopep8, black, then check with flake8
flake8 + manual fixes:
lib/xos-config
lib/xos-kafka
lib/xos-util
xos/coreapi
xos/api
xos/xos_client
Change-Id: Ib23cf84cb13beb3c6381fa0d79594dc9131dc815
diff --git a/lib/xos-genx/xos-genx-tests/test_optimize.py b/lib/xos-genx/xos-genx-tests/test_optimize.py
index e31deb8..c86b736 100644
--- a/lib/xos-genx/xos-genx-tests/test_optimize.py
+++ b/lib/xos-genx/xos-genx-tests/test_optimize.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,81 +16,120 @@
import unittest
from xosgenx.jinja2_extensions.fol2 import FOL2Python
+
class XProtoOptimizeTest(unittest.TestCase):
def setUp(self):
self.f2p = FOL2Python()
- self.maxDiff=None
+ self.maxDiff = None
def test_constant(self):
- input = 'True'
+ input = "True"
output = self.f2p.hoist_outer(input)
self.assertEqual(output, input)
def test_exists(self):
- input = {'exists': ['X',{'|':['X.foo','y']}]}
+ input = {"exists": ["X", {"|": ["X.foo", "y"]}]}
output = self.f2p.hoist_outer(input)
- expected = {'|': ['y', {'&': [{'not': 'y'}, {'exists': ['X', 'X.foo']}]}]}
+ expected = {"|": ["y", {"&": [{"not": "y"}, {"exists": ["X", "X.foo"]}]}]}
self.assertEqual(output, expected)
-
+
def test_exists_implies(self):
- input = {'exists': ['Foo', {'&': [{'=': ('Foo.a', '1')}, {'->': ['write_access', {'=': ('Foo.b', '1')}]}]}]}
+ input = {
+ "exists": [
+ "Foo",
+ {
+ "&": [
+ {"=": ("Foo.a", "1")},
+ {"->": ["write_access", {"=": ("Foo.b", "1")}]},
+ ]
+ },
+ ]
+ }
output = self.f2p.hoist_outer(input)
- expected = {'|': [{'&': ['write_access', {'exists': ['Foo', {'&': [{'=': ['Foo.a', '1']}, {'=': ['Foo.b', '1']}]}]}]}, {'&': [{'not': 'write_access'}, {'exists': ['Foo', {'=': ['Foo.a', '1']}]}]}]}
+ expected = {
+ "|": [
+ {
+ "&": [
+ "write_access",
+ {
+ "exists": [
+ "Foo",
+ {"&": [{"=": ["Foo.a", "1"]}, {"=": ["Foo.b", "1"]}]},
+ ]
+ },
+ ]
+ },
+ {
+ "&": [
+ {"not": "write_access"},
+ {"exists": ["Foo", {"=": ["Foo.a", "1"]}]},
+ ]
+ },
+ ]
+ }
self.assertEqual(output, expected)
def test_forall(self):
- input = {'forall': ['X',{'|':['X.foo','y']}]}
+ input = {"forall": ["X", {"|": ["X.foo", "y"]}]}
output = self.f2p.hoist_outer(input)
- expected = {'|': ['y', {'&': [{'not': 'y'}, {'forall': ['X', 'X.foo']}]}]}
+ expected = {"|": ["y", {"&": [{"not": "y"}, {"forall": ["X", "X.foo"]}]}]}
self.assertEqual(output, expected)
def test_exists_embedded(self):
- input = {'&':['True',{'exists': ['X',{'|':['X.foo','y']}]}]}
+ input = {"&": ["True", {"exists": ["X", {"|": ["X.foo", "y"]}]}]}
output = self.f2p.hoist_outer(input)
- expected = {'|': ['y', {'&': [{'not': 'y'}, {'exists': ['X', 'X.foo']}]}]}
+ expected = {"|": ["y", {"&": [{"not": "y"}, {"exists": ["X", "X.foo"]}]}]}
self.assertEqual(output, expected)
-
+
def test_exists_equals(self):
- input = {'&':['True',{'exists': ['X',{'|':['X.foo',{'=':['y','z']}]}]}]}
+ input = {"&": ["True", {"exists": ["X", {"|": ["X.foo", {"=": ["y", "z"]}]}]}]}
output = self.f2p.hoist_outer(input)
- expected = {'|': [{'=': ['y', 'z']}, {'&': [{'not': {'=': ['y', 'z']}}, {'exists': ['X', 'X.foo']}]}]}
+ expected = {
+ "|": [
+ {"=": ["y", "z"]},
+ {"&": [{"not": {"=": ["y", "z"]}}, {"exists": ["X", "X.foo"]}]},
+ ]
+ }
self.assertEqual(output, expected)
def test_exists_nested_constant(self):
- input = {'&':['True',{'exists': ['X',{'|':['y',{'=':['y','X.foo']}]}]}]}
+ input = {"&": ["True", {"exists": ["X", {"|": ["y", {"=": ["y", "X.foo"]}]}]}]}
output = self.f2p.hoist_outer(input)
- expected = {'|': ['y', {'&': [{'not': 'y'}, {'exists': ['X', {'=': ['False', 'X.foo']}]}]}]}
+ expected = {
+ "|": [
+ "y",
+ {"&": [{"not": "y"}, {"exists": ["X", {"=": ["False", "X.foo"]}]}]},
+ ]
+ }
self.assertEqual(output, expected)
def test_exists_nested(self):
- input = {'exists': ['X',{'exists':['Y',{'=':['Y.foo','X.foo']}]}]}
+ input = {"exists": ["X", {"exists": ["Y", {"=": ["Y.foo", "X.foo"]}]}]}
output = self.f2p.hoist_outer(input)
expected = input
self.assertEqual(input, output)
def test_exists_nested2(self):
- input = {'exists': ['X',{'exists':['Y',{'=':['Z','Y']}]}]}
+ input = {"exists": ["X", {"exists": ["Y", {"=": ["Z", "Y"]}]}]}
output = self.f2p.hoist_outer(input)
- expected = {'exists': ['Y', {'=': ['Z', 'Y']}]}
+ expected = {"exists": ["Y", {"=": ["Z", "Y"]}]}
self.assertEqual(output, expected)
def test_exists_nested3(self):
- input = {'exists': ['X',{'exists':['Y',{'=':['Z','X']}]}]}
+ input = {"exists": ["X", {"exists": ["Y", {"=": ["Z", "X"]}]}]}
output = self.f2p.hoist_outer(input)
- expected = {'exists': ['X', {'=': ['Z', 'X']}]}
+ expected = {"exists": ["X", {"=": ["Z", "X"]}]}
self.assertEqual(output, expected)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
-
-