cape.tnakit.pkgutils: Tools for creating DataKit packages

This module provides a handle to setuptools.setup() with useful defaults. The goal is for most datakit packages to just be able to call setup() with no arguments.

cape.attdb.pkgutils.find_package_data(pkg, meta=True, db=True, rawdata=False, **kw)

Find extra data files for a datakit package

Call:
>>> pkg_files = find_package_data(pkg, **kw)
Inputs:
pkg: str

Name of package

meta: {True} | False

Flag to include meta.json

db: {True} | False

Flag to include processed db/ files

rawdata: True | {False}

Flg to include source data in rawdata/ folder

Outputs:
pkg_files: list[str]

List of files to include

Versions:
  • 2021-10-21 @ddalle: Version 1.0

cape.attdb.pkgutils.find_packages(where='.', **kw)

Find packages that appear to be datakit packages

In order for a package to qualify as a datakit package, it must satisfy 2 of the following 4 criteria:

  1. The package contains the file meta.json

  2. The __init__.py has a function read_db()

  3. The __init__.py has a function write_db()

  4. The __init__.py imports datakitloader

(A package created by dkit-quickstart will satisfy all of these criteria.)

Call:
>>> pkgs = find_packages(where=".", **kw)
Inputs:
where: {"."} | str

Location from which to search for packages

exclude: {()} | tuple[str]

List of globs to exclude from package search

include: {("*",)} | tuple[str]

List of globs to include during package search

re, regex, {None} | str

Only include packages including regular expression regex

Outputs:
pkgs: list[str]

List of packages that look like datakit packages

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.pkgutils.read_metadata(pkg)

Read metadata for a package

Call:
>>> meta = read_metadata(pkg)
Inputs:
pkg: str

Name of package

Outputs:
meta: ModuleMetadata

dict-like container for meta.json

Versions:
  • 2021-10-21 @ddalle: Version 1.0

cape.attdb.pkgutils.setup(**kw)

Create a package using setuptools and some extra defaults

Call:
>>> setup(**kw)
Inputs:
name: {None} | str

Name of the package (default from find_packages())

packages: {None} | list[str]

Packages to include (default from find_packages())

title: {None} | str

Short description (default from meta.json)

description: {title} | str

Description

package_data: {{}} | dict

Extra files to include for name

db: {True} | False

Search for db/ data files in package_data

meta: {True} | False

Automatically include meta.json in package_data

rawdata: True | {False}

Search for rawdata/ files in package_data

Versions:
  • 2021-10-21 @ddalle: Version 1.0