Skip to content

Commit

Permalink
Use configutil
Browse files Browse the repository at this point in the history
  • Loading branch information
Schamper committed Jul 18, 2024
1 parent 9ebc67b commit 045c563
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions dissect/target/plugins/os/unix/linux/android/_os.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from typing import Iterator, Optional, TextIO
from typing import Iterator, Optional

from dissect.target.filesystem import Filesystem
from dissect.target.helpers import configutil
from dissect.target.helpers.record import EmptyRecord
from dissect.target.plugin import OperatingSystem, export
from dissect.target.plugins.os.unix.linux._os import LinuxPlugin
Expand All @@ -16,7 +17,7 @@ def __init__(self, target: Target):

self.props = {}
if (build_prop := self.target.fs.path("/build.prop")).exists():
self.props = _read_props(build_prop.open("rt"))
self.props = configutil.parse(build_prop, separator=("=",), comment_prefixes=("#",)).parsed_data

@classmethod
def detect(cls, target: Target) -> Optional[Filesystem]:
Expand Down Expand Up @@ -58,18 +59,3 @@ def os(self) -> str:
@export(record=EmptyRecord)
def users(self) -> Iterator[EmptyRecord]:
yield from ()

Check warning on line 61 in dissect/target/plugins/os/unix/linux/android/_os.py

View check run for this annotation

Codecov / codecov/patch

dissect/target/plugins/os/unix/linux/android/_os.py#L61

Added line #L61 was not covered by tests


def _read_props(fh: TextIO) -> dict[str, str]:
result = {}

for line in fh:
line = line.strip()

if not line or line.startswith("#"):
continue

k, v = line.split("=")
result[k] = v

return result

0 comments on commit 045c563

Please sign in to comment.