{
    "content": [
        {
            "type": "text",
            "text": "# pkgutil (pydoc)\n\n## TLDR\n\n> Query and manipulate Mac OS X Installer packages and receipts.\n\n- List package IDs for all installed packages:\n  `pkgutil --pkgs`\n- Verify cryptographic signatures of a package file:\n  `pkgutil --check-signature {{path/to/file.pkg}}`\n- List all the files for an installed package given its ID:\n  `pkgutil --files {{com.microsoft.Word}}`\n- Extract the contents of a package file into a directory:\n  `pkgutil --expand-full {{path/to/file.pkg}} {{path/to/directory}}`\n\n*Source: tldr-pages*\n\n---\n\n**Summary:** pkgutil - Utilities to support packages.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **CLASSES** (6 lines) — 3 subsections\n  - class ImpImporter (29 lines)\n  - class ImpLoader (37 lines)\n  - class ModuleInfo (118 lines)\n- **FUNCTIONS** (1 lines) — 9 subsections\n  - extend_path (31 lines)\n  - find_loader (6 lines)\n  - get_data (20 lines)\n  - get_importer (8 lines)\n  - get_loader (6 lines)\n  - iter_importers (11 lines)\n  - iter_modules (9 lines)\n  - read_code (1 lines)\n  - walk_packages (27 lines)\n- **DATA** (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\npkgutil - Utilities to support packages.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/pkgutil.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### CLASSES\n\nbuiltins.object\nImpImporter\nImpLoader\nbuiltins.tuple(builtins.object)\nModuleInfo\n\n#### class ImpImporter\n\n|  ImpImporter(path=None)\n|\n|  PEP 302 Finder that wraps Python's \"classic\" import algorithm\n|\n|  ImpImporter(dirname) produces a PEP 302 finder that searches that\n|  directory.  ImpImporter(None) produces a PEP 302 finder that searches\n|  the current sys.path, plus any modules that are frozen or built-in.\n|\n|  Note that ImpImporter does not currently support being used by placement\n|  on sys.metapath.\n|\n|  Methods defined here:\n|\n|  init(self, path=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  findmodule(self, fullname, path=None)\n|\n|  itermodules(self, prefix='')\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n\n#### class ImpLoader\n\n|  ImpLoader(fullname, file, filename, etc)\n|\n|  PEP 302 Loader that wraps Python's \"classic\" import algorithm\n|\n|  Methods defined here:\n|\n|  init(self, fullname, file, filename, etc)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  getcode(self, fullname=None)\n|\n|  getdata(self, pathname)\n|\n|  getfilename(self, fullname=None)\n|\n|  getsource(self, fullname=None)\n|\n|  ispackage(self, fullname)\n|\n|  loadmodule(self, fullname)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  code = None\n|\n|  source = None\n\n#### class ModuleInfo\n\n|  ModuleInfo(modulefinder, name, ispkg)\n|\n|  A namedtuple with minimal info about a module.\n|\n|  Method resolution order:\n|      ModuleInfo\n|      builtins.tuple\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  getnewargs(self)\n|      Return self as a plain tuple.  Used by copy and pickle.\n|\n|  repr(self)\n|      Return a nicely formatted representation string\n|\n|  asdict(self)\n|      Return a new dict which maps field names to their values.\n|\n|  replace(self, /, kwds)\n|      Return a new ModuleInfo object replacing specified fields with new values\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  make(iterable) from builtins.type\n|      Make a new ModuleInfo object from a sequence or iterable\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(cls, modulefinder, name, ispkg)\n|      Create new instance of ModuleInfo(modulefinder, name, ispkg)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  modulefinder\n|      Alias for field number 0\n|\n|  name\n|      Alias for field number 1\n|\n|  ispkg\n|      Alias for field number 2\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  matchargs = ('modulefinder', 'name', 'ispkg')\n|\n|  fielddefaults = {}\n|\n|  fields = ('modulefinder', 'name', 'ispkg')\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.tuple:\n|\n|  add(self, value, /)\n|      Return self+value.\n|\n|  contains(self, key, /)\n|      Return key in self.\n|\n|  eq(self, value, /)\n|      Return self==value.\n|\n|  ge(self, value, /)\n|      Return self>=value.\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  getitem(self, key, /)\n|      Return self[key].\n|\n|  gt(self, value, /)\n|      Return self>value.\n|\n|  hash(self, /)\n|      Return hash(self).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  le(self, value, /)\n|      Return self<=value.\n|\n|  len(self, /)\n|      Return len(self).\n|\n|  lt(self, value, /)\n|      Return self<value.\n|\n|  mul(self, value, /)\n|      Return self*value.\n|\n|  ne(self, value, /)\n|      Return self!=value.\n|\n|  rmul(self, value, /)\n|      Return value*self.\n|\n|  count(self, value, /)\n|      Return number of occurrences of value.\n|\n|  index(self, value, start=0, stop=9223372036854775807, /)\n|      Return first index of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from builtins.tuple:\n|\n|  classgetitem(...) from builtins.type\n|      See PEP 585\n\n### FUNCTIONS\n\n#### extend_path\n\nExtend a package's path.\n\nIntended use is to place the following code in a package's init.py:\n\nfrom pkgutil import extendpath\npath = extendpath(path, name)\n\nThis will add to the package's path all subdirectories of\ndirectories on sys.path named after the package.  This is useful\nif one wants to distribute different parts of a single logical\npackage as multiple directories.\n\nIt also looks for *.pkg files beginning where * matches the name\nargument.  This feature is similar to *.pth files (see site.py),\nexcept that it doesn't special-case lines starting with 'import'.\nA *.pkg file is trusted at face value: apart from checking for\nduplicates, all entries found in a *.pkg file are added to the\npath, regardless of whether they are exist the filesystem.  (This\nis a feature.)\n\nIf the input path is not a list (as is the case for frozen\npackages) it is returned unchanged.  The input path is not\nmodified; an extended copy is returned.  Items are only appended\nto the copy at the end.\n\nIt is assumed that sys.path is a sequence.  Items of sys.path that\nare not (unicode or 8-bit) strings referring to existing\ndirectories are ignored.  Unicode items of sys.path that cause\nerrors when used as filenames may cause this function to raise an\nexception (in line with os.path.isdir() behavior).\n\n#### find_loader\n\nFind a \"loader\" object for fullname\n\nThis is a backwards compatibility wrapper around\nimportlib.util.findspec that converts most failures to ImportError\nand only returns the loader rather than the full spec\n\n#### get_data\n\nGet a resource from a package.\n\nThis is a wrapper round the PEP 302 loader getdata API. The package\nargument should be the name of a package, in standard module format\n(foo.bar). The resource argument should be in the form of a relative\nfilename, using '/' as the path separator. The parent directory name '..'\nis not allowed, and nor is a rooted name (starting with a '/').\n\nThe function returns a binary string, which is the contents of the\nspecified resource.\n\nFor packages located in the filesystem, which have already been imported,\nthis is the rough equivalent of\n\nd = os.path.dirname(sys.modules[package].file)\ndata = open(os.path.join(d, resource), 'rb').read()\n\nIf the package cannot be located or loaded, or it uses a PEP 302 loader\nwhich does not support getdata(), then None is returned.\n\n#### get_importer\n\nRetrieve a finder for the given path item\n\nThe returned finder is cached in sys.pathimportercache\nif it was newly created by a path hook.\n\nThe cache (or part of it) can be cleared manually if a\nrescan of sys.pathhooks is necessary.\n\n#### get_loader\n\nGet a \"loader\" object for moduleorname\n\nReturns None if the module cannot be found or imported.\nIf the named module is not already imported, its containing package\n(if any) is imported, in order to establish the package path.\n\n#### iter_importers\n\nYield finders for the given module name\n\nIf fullname contains a '.', the finders will be for the package\ncontaining fullname, otherwise they will be all registered top level\nfinders (i.e. those on both sys.metapath and sys.pathhooks).\n\nIf the named module is in a package, that package is imported as a side\neffect of invoking this function.\n\nIf no module name is specified, all top level finders are produced.\n\n#### iter_modules\n\nYields ModuleInfo for all submodules on path,\nor, if path is None, all top-level modules on sys.path.\n\n'path' should be either None or a list of paths to look for\nmodules in.\n\n'prefix' is a string to output on the front of every module name\non output.\n\n#### read_code\n\n#### walk_packages\n\nYields ModuleInfo for all modules recursively\non path, or, if path is None, all accessible modules.\n\n'path' should be either None or a list of paths to look for\nmodules in.\n\n'prefix' is a string to output on the front of every module name\non output.\n\nNote that this function must import all *packages* (NOT all\nmodules!) on the given path, in order to access the path\nattribute to find submodules.\n\n'onerror' is a function which gets called with one argument (the\nname of the package which was being imported) if any exception\noccurs while trying to import a package.  If no onerror function is\nsupplied, ImportErrors are caught and ignored, while all other\nexceptions are propagated, terminating the search.\n\nExamples:\n\n# list all modules python can access\nwalkpackages()\n\n# list all submodules of ctypes\nwalkpackages(ctypes.path, ctypes.name+'.')\n\n### DATA\n\nall = ['getimporter', 'iterimporters', 'getloader', 'findloade...\n\n### FILE\n\n/usr/lib/python3.10/pkgutil.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "pkgutil",
        "section": "",
        "mode": "pydoc",
        "summary": "pkgutil - Utilities to support packages.",
        "synopsis": null,
        "tldr_summary": "Query and manipulate Mac OS X Installer packages and receipts.",
        "tldr_examples": [
            {
                "description": "List package IDs for all installed packages",
                "command": "pkgutil --pkgs"
            },
            {
                "description": "Verify cryptographic signatures of a package file",
                "command": "pkgutil --check-signature {{path/to/file.pkg}}"
            },
            {
                "description": "List all the files for an installed package given its ID",
                "command": "pkgutil --files {{com.microsoft.Word}}"
            },
            {
                "description": "Extract the contents of a package file into a directory",
                "command": "pkgutil --expand-full {{path/to/file.pkg}} {{path/to/directory}}"
            }
        ],
        "tldr_source": "official",
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 6,
                "subsections": [
                    {
                        "name": "class ImpImporter",
                        "lines": 29
                    },
                    {
                        "name": "class ImpLoader",
                        "lines": 37
                    },
                    {
                        "name": "class ModuleInfo",
                        "lines": 118
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "extend_path",
                        "lines": 31
                    },
                    {
                        "name": "find_loader",
                        "lines": 6
                    },
                    {
                        "name": "get_data",
                        "lines": 20
                    },
                    {
                        "name": "get_importer",
                        "lines": 8
                    },
                    {
                        "name": "get_loader",
                        "lines": 6
                    },
                    {
                        "name": "iter_importers",
                        "lines": 11
                    },
                    {
                        "name": "iter_modules",
                        "lines": 9
                    },
                    {
                        "name": "read_code",
                        "lines": 1
                    },
                    {
                        "name": "walk_packages",
                        "lines": 27
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}