本文整理汇总了Python中ucl.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hbds_release_branch
def hbds_release_branch(self) -> str:
"""Translate the release into a HardenedBSD release git branch name."""
if self._hbsd_release_branch is not None:
return self._hbsd_release_branch
if self.fetched is False:
raise libioc.errors.ReleaseNotFetched(
name=self.name,
logger=self.logger
)
root_dataset_mountpoint = self.root_dataset.mountpoint
source_file = f"{root_dataset_mountpoint}/etc/hbsd-update.conf"
if not os.path.isfile(source_file):
raise libioc.errors.ReleaseUpdateBranchLookup(
release_name=self.name,
reason=f"{source_file} not found",
logger=self.logger
)
libioc.helpers.require_no_symlink(source_file, logger=self.logger)
with open(source_file, "r", encoding="utf-8") as f:
import ucl
hbsd_update_conf = ucl.load(f.read())
self._hbsd_release_branch = hbsd_update_conf["branch"]
return str(self._hbsd_release_branch)
示例2: test_boolean
def test_boolean(self):
totest = (
"a : True;" \
"b : False"
)
correct = {"a" : True, "b" : False}
self.assertEqual(ucl.load(totest), correct)
示例3: test_every_type
def test_every_type(self):
data = ("""{
"key1": value;
"key2": value2;
"key3": "value;"
"key4": 1.0,
"key5": -0xdeadbeef
"key6": 0xdeadbeef.1
"key7": 0xreadbeef
"key8": -1e-10,
"key9": 1
"key10": true
"key11": no
"key12": yes
}""")
valid = {
'key1': 'value',
'key2': 'value2',
'key3': 'value;',
'key4': 1.0,
'key5': -3735928559,
'key6': '0xdeadbeef.1',
'key7': '0xreadbeef',
'key8': -1e-10,
'key9': 1,
'key10': True,
'key11': False,
'key12': True,
}
self.assertEqual(ucl.load(data), valid)
示例4: test_every_type
def test_every_type(self):
totest="""{
"key1": value;
"key2": value2;
"key3": "value;"
"key4": 1.0,
"key5": -0xdeadbeef
"key6": 0xdeadbeef.1
"key7": 0xreadbeef
"key8": -1e-10,
"key9": 1
"key10": true
"key11": no
"key12": yes
}"""
correct = {
'key1': 'value',
'key2': 'value2',
'key3': 'value;',
'key4': 1.0,
'key5': -3735928559,
'key6': '0xdeadbeef.1',
'key7': '0xreadbeef',
'key8': -1e-10,
'key9': 1,
'key10': 'true',
'key11': 'false',
'key12': 'true',
}
self.assertEqual(ucl.load(totest), correct)
示例5: test_boolean
def test_boolean(self):
data = (
"a : True;" \
"b : False"
)
valid = { "a" : True, "b" : False }
self.assertEqual(ucl.load(data), valid)
示例6: test_braced_int
def test_braced_int(self):
self.assertEqual(ucl.load("{a : 1}"), { "a" : 1 } )
示例7: test_int
def test_int(self):
r = ucl.load("a : 1")
self.assertEqual(ucl.load("a : 1"), { "a" : 1 } )
示例8: test_none
def test_none(self):
self.assertEqual(ucl.load(None), None)
示例9: test_braced_int
def test_braced_int(self):
data = "{a : 1}"
valid = { "a" : 1 }
self.assertEqual(ucl.load(data), valid)
示例10: test_single_brace
def test_single_brace(self):
self.assertEqual(ucl.load("{"), {})
示例11: test_float
def test_float(self):
self.assertEqual(ucl.load("a : 1.1"), {"a" : 1.1})
示例12: test_no_args
def test_no_args(self):
self.assertRaises(TypeError, lambda: ucl.load())
示例13: test_empty_ucl
def test_empty_ucl(self):
self.assertEqual(ucl.load("{}"), {})
示例14: test_float
def test_float(self):
data = "a : 1.1"
valid = {"a" : 1.1}
self.assertEqual(ucl.load(data), valid)
示例15: test_str
def test_str(self):
data = "a : b"
valid = { "a" : "b" }
self.assertEqual(ucl.load(data), valid)