Deb-Parse
A simple parser for Debian control file formats.
Once initialized, it exposes three attributes with information from the input Control File, and one method to export the information to a JSON file.
A CLI functionality may be added later.
Installation
Install using pip:
$ pip install --user deb-parse
Usage
Import it in your project
from deb_parse.parser import Parser
Initialze it with a valid Control File path or a string that follows the schema:
my_parser = Parse("/var/lib/dpkg/status")
- Note: A
TypeErroris raised if the input is notstr - Note: A
ValueErroris raised if the input string or path don't follow the schema
If everything goes well, my_parser will now have three accessible attributes:
my_parser.pkg_namesoutputs alistof package names in the inputmy_parser.raw_pkg_infooutputs alistof rawdictobjects as seen in inputmy_parser.clean_pkg_infooutputs alistof cleaned updictobjects with more useful information
Examples:
print(my_parser.pkg_names)
['libws-commons-util-java', 'python-pkg-resources', 'tcpd', ... ]
print(my_parser.raw_pkg_info)
[{'name': 'libws-commons-util-java', 'details': {'status': 'install ok installed', 'priority': 'optional', 'section': 'java', 'installed-size': '101', 'maintainer': 'Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>', 'architecture': 'all', 'version': '1.0.1-7', 'description': 'Common utilities from the Apache Web Services Project\n This is a small collection of utility classes, that allow high\n performance XML processing based on SAX.', 'original-maintainer': 'Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>', 'homepage': 'http://ws.apache.org/commons/util/'}}, ... ]
print(my_parser.clean_pkg_info)
[{'name': 'libws-commons-util-java', 'details': {'version': '1.0.1-7', 'synopsis': 'Common utilities from the Apache Web Services Project', 'description': 'This is a small collection of utility classes, that allow high\nperformance XML processing based on SAX.', 'depends': None, 'alt_depends': None, 'reverse_depends': None}}, ... ]
If you want, you can also dump the parsed information in a JSON file using .to_json_file():
Attributes:
outfile=str, default:'./datastore/dpkgs.json'names_only=bool, default:False(ifTrueoutputs list of names and cancelsrawoption)raw=bool, default:False(ifTrueoutputs raw parse)
If both options are False, JSON will be based on clean package information
Development
For working on deb-parse, you will need Python >= 3.7 and pipenv installed. Configure pipenv to create its .venv in the current folder if you want to use the VS-Code settings. With these installed, run the following command to create a virtualenv for the project and fetch the dependencies:
$ pipenv install --dev
...
Next, activate the virtual environment and get to work:
$ pipenv shell
...
(deb-parse) $
Metadata
Release files for deb-parse 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deb_parse-0.1.1.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deb_parse-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / deb_parse-0.1.1.tar.gz
| Download URL | deb_parse-0.1.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c7944aa18d0430b4f750f6b555d15c2e62e799f190b7911157873ba5f3c354c
|
|
BLAKE2b-256 checksum How to use checksums |
e4b0ef08ad957e326e04944946923de3ee25c86bc4a297ad7f60373c0d934d78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3
|
Release files / deb_parse-0.1.1-py3-none-any.whl
| Download URL | deb_parse-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ba521302b5058b22f86736e22d279800fa9d4038d88d21d559b07683bb45504
|
|
BLAKE2b-256 checksum How to use checksums |
927f606e47408f4fd44b91512ac58b42cf93518fabe847bb57c1d8dcd31ec89f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3
|