{"id":21113,"library":"debian-inspector","title":"debian-inspector","description":"Utilities to parse Debian package, control, and copyright files. Current version 31.1.1, with a recent release cadence (multiple minor releases in 2025). Requires Python >=3.9.","status":"active","version":"31.1.1","language":"python","source_language":"en","source_url":"https://github.com/nexB/debian-inspector","tags":["debian","package-parsing","copyright","control-files"],"install":[{"cmd":"pip install debian-inspector","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"DpkgHandler is exposed at package level since v31","wrong":"from debian_inspector.dpkg import DpkgHandler","symbol":"DpkgHandler","correct":"from debian_inspector import DpkgHandler"},{"note":"Copyright class is at top-level; submodule not part of public API","wrong":"from debian_inspector.copyright import Copyright","symbol":"Copyright","correct":"from debian_inspector import Copyright"},{"note":"Function is at package level; avoid importing from internal modules","wrong":"","symbol":"get_license_detection_from_nameless_paragraph","correct":"from debian_inspector import get_license_detection_from_nameless_paragraph"}],"quickstart":{"code":"from debian_inspector import DpkgHandler, Copyright\n\n# Parse a Debian control file (e.g., debian/control)\nwith open('control', 'r') as f:\n    control_text = f.read()\nhandler = DpkgHandler(control_text)\nprint(handler.paragraphs[0].get('Package'))\n\n# Parse a copyright file (e.g., /usr/share/doc/*/copyright)\nwith open('copyright', 'r') as f:\n    copyright_text = f.read()\ncopyright_obj = Copyright(copyright_text)\nprint(copyright_obj.paragraphs_license_expression())","lang":"python","description":"Parses a control file and a copyright file using top-level API."},"warnings":[{"fix":"Update any code that references 'licence' field in copyright paragraphs to use 'license'.","message":"In v31.0.0, the function `get_license_detection_from_nameless_paragraph` was renamed from a previous name? Actually it's a fix: the `licence` field in copyright files is now normalized to `license`. Code relying on the old field name `licence` may break.","severity":"breaking","affected_versions":"<31.0.0"},{"fix":"Change imports to `from debian_inspector import DpkgHandler, Copyright, get_license_detection_from_nameless_paragraph`.","message":"Direct import from submodules like `debian_inspector.dpkg` or `debian_inspector.copyright` is discouraged. Use top-level imports.","severity":"deprecated","affected_versions":">=31.0.0"},{"fix":"Read the file content first: `with open('control') as f: text = f.read(); handler = DpkgHandler(text)`.","message":"The class `DpkgHandler` expects a single string (the full control file content), not a file path. Passing a file path will raise an error.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from debian_inspector import DpkgHandler` instead.","cause":"Old import path `from debian_inspector.dpkg import DpkgHandler` used; DpkgHandler is now at top level.","error":"AttributeError: module 'debian_inspector' has no attribute 'DpkgHandler'"},{"fix":"Open the file, read its content, and pass the content string: `DpkgHandler(open('file').read())`.","cause":"Passed a file path string instead of file content. DpkgHandler expects a single string content.","error":"TypeError: DpkgHandler.__init__() takes 1 positional argument but 2 were given"},{"fix":"Access the field using 'license' instead of 'licence'.","cause":"In v31.0.0, the 'licence' field in Debian copyright files is normalized to 'license'.","error":"KeyError: 'licence'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}