Package: uciparse
UCI Parse LibraryPython 3 library and command line tools to parse, diff, and normalize OpenWRTUCIconfiguration files.These tools were written to ease OpenWRT upgrades, making it easier to see the
differences between two config files.  As of this writing (mid-2020), OpenWRT
upgrades often don't normalize upgraded config files in the same way from
version to version.  For instance, the new version fromopkg upgrade(saved
off with a-opkgfilename) might use single quotes on all lines, while the
original version on disk might not use quotes at all.  This makes it very
difficult understand the often-minimal differences between an upgraded file and
the original file.Installing the PackageInstalling this package on your OpenWRT router is not as simple as it could be.
A lot of routers do not have enough space available to install a full version
of Python includingpiporsetuptools.  If yours does have lots of space,
it's as simple as this:$ opkg update
$ opkg install python3-pip
$ pip3 install uciparseIf not, it gets a little ugly.  First, installwgetwith support for HTTPS:$ opkg update
$ opkg install wget ca-bundle ca-certificatesThen, go toPyPIand copy the
URL for the source package.tar.gzfile.  Retrieve the source package
withwgetand then manually extract it:$ wget https://files.pythonhosted.org/.../uciparse-0.1.2.tar.gz
$ tar zxvf uciparse-0.1.2.tar.gz
$ cd uciparse-0.1.2Finally, run the custom install script provided with the source package:$ sh ./scripts/installThis installs the OpenWRTpython3-lightpackage, then copies the Python
packages into the rightsite-packagesdirectory and theuciparseanducidiffscripts to/usr/bin.Using the ToolsOnce you have installed the package as described above, theuciparseanducidifftools will be available in your path.ucidiffTheucidifftool is probably the tool you'll use most often when updating
your router.  It reads two UCI configuration files from disk, normalizes both in
memory (without making changes on disk), and then compares them.  The result is
a unified diff, likediff -Naur.  This gives you a way to understand the real
differences between two files without ever having to change anything on disk.$ ucidiff --help
usage: ucidiff [-h] a b

Diff two UCI configuration files.

positional arguments:
  a           Path to the first UCI file to compare
  b           Path to the second UCI file to compare

optional arguments:
  -h, --help  show this help message and exit

The comparison is equivalent to a 'diff -Naur' between the normalized versions
of the files. If either file can't be parsed, then an error will be returned
and no diff will be shown.uciparseIf you would prefer to clean up and normalize your configuration files on disk,
then you can use theuciparsetool.  It reads a UCI config file from disk or
fromstdin, parses it, and prints normalized output tostdout.$ uciparse --help
usage: uciparse [-h] uci

Parse and normalize a UCI configuration file.

positional arguments:
  uci         Path to the UCI file to normalize, or '-' for stdin

optional arguments:
  -h, --help  show this help message and exit

Results will be printed to stdout. If the file can't be parsed then an error
will be returned and no output will be generated.Before usinguciparse, you should make a backup of any config file that you
are going to normalized.