Skip to content

Commit 9f9fa34

Browse files
committed
lazy-load UCL dependency on usage
1 parent 3f6fbb7 commit 9f9fa34

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

iocage/Config/Jail/File/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import typing
2727
import os.path
2828

29-
import ucl
30-
3129
import iocage.helpers
3230
import iocage.helpers_object
3331
import iocage.LaunchableResource
@@ -161,6 +159,7 @@ def _read_file(
161159
self._file_content_changed = False
162160

163161
def _read(self, silent: bool=False) -> dict:
162+
import ucl
164163
data = dict(ucl.load(open(self.path).read()))
165164
self.logger.spam(f"{self._file} was read from {self.path}")
166165
return data
@@ -174,7 +173,7 @@ def save(self) -> bool:
174173
return False
175174

176175
with open(self.path, "w") as rcconf:
177-
176+
import ucl
178177
output = ucl.dump(self, ucl.UCL_EMIT_CONFIG)
179178
output = output.replace(" = \"", "=\"")
180179
output = output.replace("\";\n", "\"\n")

iocage/Config/Type/UCL.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
"""iocage configuration stored in an UCL file."""
2626
import typing
2727

28-
import ucl
29-
3028
import iocage.Config
3129
import iocage.Config.Prototype
3230
import iocage.Config.Dataset
@@ -40,6 +38,7 @@ class ConfigUCL(iocage.Config.Prototype.Prototype):
4038

4139
def map_input(self, data: typing.TextIO) -> typing.Dict[str, typing.Any]:
4240
"""Normalize data read from the UCL file."""
41+
import ucl
4342
result = ucl.load(data.read()) # type: typing.Dict[str, typing.Any]
4443
result["legacy"] = True
4544
return result

iocage/Pkg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import re
3030

3131
import libzfs
32-
import ucl
3332

3433
import iocage.events
3534
import iocage.helpers
@@ -369,6 +368,7 @@ def _update_pkg_conf(
369368
reason="Refusing to write to a symlink",
370369
logger=self.logger
371370
)
371+
import ucl
372372
with open(filename, "w") as f:
373373
f.write(ucl.dump(data, ucl.UCL_EMIT_JSON))
374374

iocage/Release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import re
3333

3434
import libzfs
35-
import ucl
3635

3736
import iocage.ZFS
3837
import iocage.errors
@@ -621,6 +620,7 @@ def hbds_release_branch(self) -> str:
621620
)
622621

623622
with open(source_file, "r") as f:
623+
import ucl
624624
hbsd_update_conf = ucl.load(f.read())
625625
self._hbsd_release_branch = hbsd_update_conf["branch"]
626626
return str(self._hbsd_release_branch)

iocage/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import re
3131
import subprocess # nosec: B404
3232
import sys
33-
import ucl
3433
import pty
3534
import select
3635

@@ -326,6 +325,7 @@ def to_ucl(data: typing.Dict[str, typing.Any]) -> str:
326325
false="off",
327326
none="none"
328327
)
328+
import ucl
329329
return str(ucl.dump(output_data))
330330

331331

0 commit comments

Comments
 (0)