Package: iotree
A many-in-one tool for managing your Markup Language files.What is it?iotreeis a tool for managing your Markup Language files. It is capable to write and read files in the following formats:JSONYAMLTOMLXMLAnd soon more... 😉The basic goal was to have a small package anyone could add to their project and use it to manage their files. It is also possible to use it as a CLI tool.InstallationYou cannot install the CLI tool separately for now. You can install it with the following command:pipinstalliotreeUsageAs a CLI toolTo see what the display function can do, you can use the following command:iotreedemoFor example, the following JSON file (displayed in VSCode){"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}}will be displayed like this:While the following YAML file (displayed in VSCode)---doe:"adeer,afemaledeer"ray:"adropofgoldensun"pi:3.14159xmas:truefrench-hens:3calling-birds:-huey-dewey-louie-fredxmas-fifth-day:calling-birds:fourfrench-hens:3golden-rings:5partridges:count:1location:"apeartree"turtle-doves:twowill be displayed like this:Note: The CLI tool is not yet finished. It is still in development.If this just looks like a wrapper aroundrich trees) to you, it almost because it is. :wink:As a CLI tool, the key difference I want to bring is the ability to configurethemesandstyles.Just run the following command to interactively create a theme:iotreeconfiginitBut if you're lazy, just use a file:iotreeconfiginitfrom-jsonmy_theme.jsonFor example, the following JSON file{"name":"My super pseudonym","username":"my.username","symbol":"lgpoint","theme":"bright-blue-green"}Doesnotimmediately affect the display of the files. You need to use the following command:To understand why, you can runiotreeconfigls# same as iotree cfg lsThis is what the output looks like:You can see that the theme is registered, but willnotbe used by default.
The best proof of this is to ask who the current user is:iotreecfggetlast_user#> ✅ Config found for user arnov#> arnovSo the current user isarnov. To useYOURtheme, you need to run the following command:iotreecfgsetlast_usermy.username#> 👷 Config: last_user ===> my.usernameNow, if you try to render a file, you will see that the theme is used:iotreerender.\iotree\examples\example.tomlHere's what the output looks like:The theme is now used. 🎉🎉As a Python packageYou can use the package in your Python project. Here's an example:fromiotree.core.renderimportbuildmydict={"super":{"dict":{"just":{"for":{"example":"🤷‍♂️"}}}}}# Build the tree from the dict without hassletree=build(mydict)# or build(mydict, theme="my_style", symbol="my_symbol")# Display the rich tree laterconsole.print(tree)# or rich.print(tree)But there is more. You can also use the 'all in one' IO from the package:fromiotree.core.ioimportreader,writer# Read a file, any extension is supported from the listdict_one=reader.read("my_file.json")dict_two=reader.read("my_file.yaml")dict_three=reader.read("my_file.toml")dict_four=reader.read("my_file.xml")dict_five=reader.read("my_file.html")# ... do some manipulations, like possibly merging the dicts or creating a new one# Write the dict to a filewriter.write("my_file.json",dict_one)writer.write("my_file.yaml",dict_two)writer.write("my_file.toml",dict_three)writer.write("my_file.xml",dict_four)# writer.write("my_file.html", dict_five) # Not supported yetAnother small feature is the ability todetect the type of a file:dict_guess=reader.read("mysterious_file.not_a_real_extension")# if the content of the file is one of the supported types, it will be read correctlyThere's also a functional package, which is not yet documented.It allows you to compose functions while displaying rich progress usingrich.progress.ContributingIf you want to contribute, you can do so by forking the repository and creating a pull request.You can also help me pick the new themes and symbols.To see the possibilities, just run either of the following commands:iotreeviewthemes# oriotreeviewsymbols# oriotreeviewcolors