Skip to content

Commit

Permalink
[qa] Reformat with openwisp-qa-format
Browse files Browse the repository at this point in the history
Signed-off-by: Konrad Kreitmair <[email protected]>
  • Loading branch information
kkreitmair committed Aug 7, 2020
1 parent 0b10eef commit c31b3b7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion netjsonconfig/backends/openwrt/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .ddns import Ddns
from .default import Default
from .general import General
from .interfaces import Interfaces
Expand All @@ -9,7 +10,6 @@
from .rules import Rules
from .switch import Switch
from .wireless import Wireless
from .ddns import Ddns

__all__ = [
'Default',
Expand Down
10 changes: 4 additions & 6 deletions netjsonconfig/backends/openwrt/converters/ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class Ddns(OpenWrtConverter):
def to_intermediate_loop(self, block, result, index=None):
if block:
provider_list = self.__intermediate_providers(block.pop('providers', {}))
block.update({
'.type': 'ddns',
'.name': block.pop('id', 'global'),
})
block.update(
{'.type': 'ddns', '.name': block.pop('id', 'global'),}
)
result.setdefault('ddns', [])
result['ddns'] = [self.sorted_dict(block)] + provider_list
return result
Expand All @@ -29,8 +28,7 @@ def __intermediate_providers(self, providers):
result = []
for provider in providers:
uci_name = self._get_uci_name(provider['lookup_host'])
resultdict = OrderedDict((('.name', uci_name),
('.type', 'service')))
resultdict = OrderedDict((('.name', uci_name), ('.type', 'service')))
resultdict.update(provider)
result.append(resultdict)
return result
Expand Down
49 changes: 22 additions & 27 deletions netjsonconfig/backends/openwrt/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@
"type": "boolean",
"title": "upd_privateip",
"description": "disallow/allow sending of private/special IP's to the DDNS provider; "
"blocked IPv4: 0/8, 10/8, 100.64/10, 127/8, 169.254/16, 172.16/12, "
"192.168/16; blocked IPv6: ::/32, f000::/4",
"blocked IPv4: 0/8, 10/8, 100.64/10, 127/8, 169.254/16, 172.16/12, "
"192.168/16; blocked IPv6: ::/32, f000::/4",
"default": False,
"format": "checkbox",
"propertyOrder": 1,
Expand Down Expand Up @@ -434,7 +434,7 @@
"type": "boolean",
"title": "use_curl",
"description": "if both wget and curl are installed, wget is used for communication "
"by default",
"by default",
"default": False,
"format": "checkbox",
"propertyOrder": 6,
Expand Down Expand Up @@ -470,21 +470,16 @@
"type": "string",
"title": "interface",
"description": "network from /etc/config/network to monitor for up/down "
"events to start the ddns update script via hotplug",
"events to start the ddns update script via hotplug",
"propertyOrder": 2,
},
"ip_source": {
"type": "string",
"title": "ip_source",
"description": "specifies the source to detect the local IP: 'network' uses "
"'ip_network', 'web' uses 'ip_url', 'interface' uses "
"'ip_interface', 'script' uses 'ip_script'",
"enum": [
"network",
"web",
"interface",
"script"
],
"'ip_network', 'web' uses 'ip_url', 'interface' uses "
"'ip_interface', 'script' uses 'ip_script'",
"enum": ["network", "web", "interface", "script"],
"default": "network",
"propertyOrder": 3,
},
Expand All @@ -498,8 +493,8 @@
"type": "string",
"title": "domain",
"description": "the DNS name to update; this property can also be used for "
"special multihost update configurations supported by"
" some providers",
"special multihost update configurations supported by"
" some providers",
"propertyOrder": 5,
},
"username": {
Expand Down Expand Up @@ -536,29 +531,29 @@
"type": "string",
"title": "ip_network",
"description": "network from /etc/config/network to use for detecting the IP "
"if 'ip_source' is set to 'network'",
"if 'ip_source' is set to 'network'",
"default": "wan",
"propertyOrder": 11,
},
"ip_url": {
"type": "string",
"title": "ip_url",
"description": "url to use for detecting the IP if 'ip_source' is set to "
"'web'",
"'web'",
"propertyOrder": 12,
},
"ip_interface": {
"type": "string",
"title": "ip_interface",
"description": "local interface to use for detecting the IP if 'ip_source' is"
" set to 'interface'",
" set to 'interface'",
"propertyOrder": 13,
},
"ip_script": {
"type": "string",
"title": "ip_script",
"description": "script to use for detecting the IP if 'ip_source' is set to "
"'script'",
"'script'",
"propertyOrder": 14,
},
"use_syslog": {
Expand All @@ -572,7 +567,7 @@
"1 - info, notice, warning, errors",
"2 - notice, warning, errors",
"3 - warning, errors",
"4 - errors"
"4 - errors",
]
},
"default": 0,
Expand All @@ -584,14 +579,14 @@
"description": "disable/enable logging to logfile",
"default": True,
"propertyOrder": 16,
}
}
}
}
}
}
}
}
},
},
},
},
},
},
},
},
)


Expand Down
2 changes: 1 addition & 1 deletion tests/openwrt/test_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestDdns(unittest.TestCase, _TabsMixin):
"ddns_loglines": 250,
"ddns_rundir": "/var/run/ddns",
"upd_privateip": False,
"use_curl": False
"use_curl": False,
}
}
_ddns_uci_global = """package ddns
Expand Down

0 comments on commit c31b3b7

Please sign in to comment.