-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated CHIP REPL! This resurrects the chip-repl to be more usable and user-friendly, especially around how pretty printing, help text/documentation are generated. Notably, it leverages the 'rich' module to: - Provide capabilities to inspect the methods/values in any given class/module. - Pretty printing of cluster objects. * Missed a file * Restyled
- Loading branch information
1 parent
b775f8d
commit 1727587
Showing
5 changed files
with
98 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from rich import print | ||
from rich.pretty import pprint | ||
from rich import pretty | ||
from rich import inspect | ||
from rich.console import Console | ||
import logging | ||
from chip import ChipDeviceCtrl | ||
import chip.clusters as Clusters | ||
import coloredlogs | ||
import chip.logging | ||
import argparse | ||
import builtins | ||
|
||
|
||
def ReplInit(): | ||
# | ||
# Install the pretty printer that rich provides to replace the existing | ||
# printer. | ||
# | ||
pretty.install(indent_guides=True, expand_all=True) | ||
|
||
console = Console() | ||
|
||
console.rule('Matter REPL') | ||
console.print(''' | ||
[bold blue] | ||
Welcome to the Matter Python REPL! | ||
For help, please type [/][bold green]matterhelp()[/][bold blue] | ||
To get more information on a particular object/class, you can pass | ||
that into [bold green]matterhelp()[/][bold blue] as well. | ||
''') | ||
console.rule() | ||
|
||
coloredlogs.install(level='DEBUG') | ||
chip.logging.RedirectToPythonLogging() | ||
logging.getLogger().setLevel(logging.ERROR) | ||
|
||
|
||
def matterhelp(classOrObj=None): | ||
if (classOrObj == None): | ||
inspect(builtins.devCtrl, methods=True, help=True, private=False) | ||
else: | ||
inspect(classOrObj, methods=True, help=True, private=False) | ||
|
||
|
||
def mattersetlog(level): | ||
logging.getLogger().setLevel(level) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters