dissect.target 3.17.dev20__py3-none-any.whl → 3.17.dev21__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
1
4
  import re
2
5
  from collections import defaultdict
3
6
  from configparser import ConfigParser, MissingSectionHeaderError
4
7
  from io import StringIO
5
8
  from re import compile, sub
6
- from typing import Any, Callable, Iterable, Match, Optional, Union
9
+ from typing import Any, Callable, Iterable, Match, Optional
7
10
 
8
11
  from defusedxml import ElementTree
9
12
 
@@ -11,6 +14,8 @@ from dissect.target.exceptions import PluginError
11
14
  from dissect.target.helpers.fsutil import TargetPath
12
15
  from dissect.target.target import Target
13
16
 
17
+ log = logging.getLogger(__name__)
18
+
14
19
  try:
15
20
  from ruamel.yaml import YAML
16
21
 
@@ -60,7 +65,7 @@ class Template:
60
65
  """
61
66
 
62
67
  if not path.exists() or path.is_dir():
63
- self.target.log.debug("Failed to get config file %s", path)
68
+ log.debug("Failed to get config file %s", path)
64
69
  config = None
65
70
 
66
71
  if self.name == "netplan":
@@ -85,7 +90,7 @@ class Template:
85
90
  if HAS_YAML:
86
91
  return self.parser(path.open("rb"))
87
92
  else:
88
- self.target.log.error("Failed to parse %s. Cannot import ruamel.yaml", self.name)
93
+ log.error("Failed to parse %s. Cannot import ruamel.yaml", self.name)
89
94
  return None
90
95
 
91
96
  def _parse_wicked_config(self, path: TargetPath) -> dict:
@@ -278,7 +283,7 @@ class Parser:
278
283
  if option in translation_values and value:
279
284
  return translation_key
280
285
 
281
- def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Union[str, Callable]:
286
+ def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Optional[str | Callable]:
282
287
  """Internal function to get arbitrary options values from a parsed (non-translated) dictionary.
283
288
 
284
289
  Args:
@@ -289,8 +294,13 @@ class Parser:
289
294
  Returns:
290
295
  Value(s) corrensponding to that network configuration option.
291
296
  """
297
+ if not config:
298
+ log.error("Cannot get option %s: No config to parse", option)
299
+ return
300
+
292
301
  if section:
293
- config = config[section]
302
+ config = config.get(section, {})
303
+
294
304
  for key, value in config.items():
295
305
  if key == option:
296
306
  return value
@@ -364,7 +374,7 @@ class NetworkManager:
364
374
  if self.registered:
365
375
  self.config = self.parser.parse()
366
376
  else:
367
- self.target.log.error("Network manager %s is not registered. Cannot parse config.", self.name)
377
+ log.error("Network manager %s is not registered. Cannot parse config.", self.name)
368
378
 
369
379
  @property
370
380
  def interface(self) -> set:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.17.dev20
3
+ Version: 3.17.dev21
4
4
  Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -57,7 +57,7 @@ dissect/target/helpers/loaderutil.py,sha256=kiyMWra_gVxfNSGwLlgxLcuuqAYuCMDc5NiC
57
57
  dissect/target/helpers/localeutil.py,sha256=Y4Fh4jDSGfm5356xSLMriUCN8SZP_FAHg_iodkAxNq4,1504
58
58
  dissect/target/helpers/mount.py,sha256=JxhUYyEbDnHfzPpfuWy4nV9OwCJPoDSGdHHNiyvd_l0,3949
59
59
  dissect/target/helpers/mui.py,sha256=i-7XoHbu4WO2fYapK9yGAMW04rFlgRispknc1KQIS5Q,22258
60
- dissect/target/helpers/network_managers.py,sha256=FSFYVuHsOzxLc68_LTzfFUd3IIBQQpI7rJRwTg7xznQ,24494
60
+ dissect/target/helpers/network_managers.py,sha256=OgrYhbBqM6K5OfUnCdTLG0RBrR-DcpR1CPezbNddK7k,24667
61
61
  dissect/target/helpers/polypath.py,sha256=h8p7m_OCNiQljGwoZh5Aflr9H2ot6CZr6WKq1OSw58o,2175
62
62
  dissect/target/helpers/protobuf.py,sha256=NwKrZD4q9v7J8GnZX9gbzMUMV5pR78eAV17jgWOz_EY,1730
63
63
  dissect/target/helpers/record.py,sha256=lWl7k2Mp9Axllm0tXzPGJx2zj2zONsyY_p5g424T0Lc,4826
@@ -336,10 +336,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
336
336
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
337
337
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
338
338
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
339
- dissect.target-3.17.dev20.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
- dissect.target-3.17.dev20.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
- dissect.target-3.17.dev20.dist-info/METADATA,sha256=w19ITKpjeWu52HPdEU4SD_axvpgGpBr8_nsETBOLeEw,11300
342
- dissect.target-3.17.dev20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
- dissect.target-3.17.dev20.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
- dissect.target-3.17.dev20.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
- dissect.target-3.17.dev20.dist-info/RECORD,,
339
+ dissect.target-3.17.dev21.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
+ dissect.target-3.17.dev21.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
+ dissect.target-3.17.dev21.dist-info/METADATA,sha256=B1cofOpEkgQ80qwI5_2CqiY7JJBYNaEarbvsbU4G9y8,11300
342
+ dissect.target-3.17.dev21.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
+ dissect.target-3.17.dev21.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
+ dissect.target-3.17.dev21.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
+ dissect.target-3.17.dev21.dist-info/RECORD,,