mirror of
https://github.com/dw-0/kiauh.git
synced 2026-03-21 18:08:37 +05:00
refactor: add __repr__ to Klipper class
This commit adds a __repr__ method to the Klipper class. This method returns a JSON string representation of the instance, which can be used for debugging purposes. Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from subprocess import CalledProcessError, run
|
||||
from typing import List
|
||||
@@ -41,6 +41,20 @@ class Klipper(BaseInstance):
|
||||
self._serial = self.comms_dir.joinpath(KLIPPER_SERIAL_NAME)
|
||||
self._uds = self.comms_dir.joinpath(KLIPPER_UDS_NAME)
|
||||
|
||||
def __repr__(self):
|
||||
return json.dumps(
|
||||
{
|
||||
"suffix": self.suffix,
|
||||
"klipper_dir": self.klipper_dir.as_posix(),
|
||||
"env_dir": self.env_dir.as_posix(),
|
||||
"cfg_file": self.cfg_file.as_posix(),
|
||||
"log": self.log.as_posix(),
|
||||
"serial": self.serial.as_posix(),
|
||||
"uds": self.uds.as_posix(),
|
||||
},
|
||||
indent=4,
|
||||
)
|
||||
|
||||
@property
|
||||
def cfg_file(self) -> Path:
|
||||
return self._cfg_file
|
||||
|
||||
Reference in New Issue
Block a user