Skip to content

Commit

Permalink
Update and document
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Dec 19, 2024
1 parent 4ae4e87 commit 0e86a14
Showing 1 changed file with 55 additions and 35 deletions.
90 changes: 55 additions & 35 deletions Tools/printLOD.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
import os.path


while 1:
print("Enter the DeviceList.txt filename: ")
filename=input()
if os.path.exists(filename):
break


nb = 0
with open( filename, 'r') as myfile2:
for line in myfile2:
if not line.strip() :
#Empty line
continue
(key, val) = line.split(":",1)
key = key.replace(" ","")
key = key.replace("'","")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

dlVal=eval(val)
print("%-10s %s" %('NwkID', key))
for i, j in dlVal.items():
if 'Ep' == i:
# Ep {'01': {'0000': {}, 'ClusterType': {'576': 'ColorControl'}, '0003': {}, '0004': {}, '0005': {}, '0006': '00', '0008': {}, '0300': {}, '0b05': {}, '1000': {}}}
print("Ep")
j = eval(str(j))
for k,l in j.items():
print(" %-10s %s" %(k,l))
else:
print("%-10s %s" %(i,j))

print("======")


myfile2.close()
import os.path

def main():
"""
Main function to prompt the user for a filename and process the DeviceList.txt file.
"""
while True:
print("Enter the DeviceList.txt filename: ")
filename = input()
if os.path.exists(filename):
break

process_file(filename)

def process_file(filename):
"""
Process the given DeviceList.txt file and print its contents in a formatted manner.
Args:
filename (str): The name of the DeviceList.txt file to process.
"""
with open(filename, 'r') as myfile2:
for line in myfile2:
if not line.strip():
# Empty line
continue
key, val = line.split(":", 1)
key = key.replace(" ", "").replace("'", "")

dlVal = eval(val)
print("%-10s %s" % ('NwkID', key))
for i, j in dlVal.items():
if i == 'Ep':
# Ep {'01': {'0000': {}, 'ClusterType': {'576': 'ColorControl'}, '0003': {}, '0004': {}, '0005': {}, '0006': '00', '0008': {}, '0300': {}, '0b05': {}, '1000': {}}}
print("Ep")
j = eval(str(j))
for k, l in j.items():
print(" %-10s %s" % (k, l))
else:
print("%-10s %s" % (i, j))

print("======")

if __name__ == "__main__":
main()

0 comments on commit 0e86a14

Please sign in to comment.