API Reference
Generated from docstrings. pkgforge is primarily a CLI, but its core types and dump helpers are importable.
Core types
pkgforge.common.FileType
Bases: str, Enum
Directory = 'directory'
class-attribute
instance-attribute
File = 'file'
class-attribute
instance-attribute
Symlink = 'symlink'
class-attribute
instance-attribute
from_path(path)
classmethod
Source code in src/pkgforge/common.py
68 69 70 71 72 73 74 75 76 77 | |
pkgforge.common.FileEntry
Bases: TypedDict
group
instance-attribute
meta
instance-attribute
mode
instance-attribute
owner
instance-attribute
type
instance-attribute
apply(path, chown=False, *, logger=None, usedefault=DEFAULT)
Source code in src/pkgforge/common.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
from_args(args, **overwrite)
classmethod
Source code in src/pkgforge/common.py
111 112 113 114 115 116 117 118 119 120 121 | |
from_path(path, meta=None)
classmethod
Source code in src/pkgforge/common.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
resolve_for(path, lookupval=AUTO, **overwrite)
Source code in src/pkgforge/common.py
149 150 151 152 153 154 155 156 157 | |
pkgforge.common.FileEntryArgs
Bases: Cmd
group = DEFAULT
class-attribute
instance-attribute
meta = {}
class-attribute
instance-attribute
mode = DEFAULT
class-attribute
instance-attribute
owner = DEFAULT
class-attribute
instance-attribute
type = None
class-attribute
instance-attribute
pkgforge.common.PkgForgeCmd
Bases: LoggingArgs, Cmd
Common base for every pkgforge subcommand.
Carries the two app-wide options (--db and --buildroot), the file-DB
read/write helpers, and the build-root <-> local-path translation. Each leaf
command subclasses this and implements __call__; a leaf attaches itself
to the :class:PkgForge root's subcommand tree via :meth:_register.
buildroot = Path(buildroot) if buildroot else Path('.')
class-attribute
instance-attribute
db = Path(filedb) if filedb else None
class-attribute
instance-attribute
db_format = os.environ.get('PKGFORGE_DB_FORMAT')
class-attribute
instance-attribute
__call__()
Source code in src/pkgforge/common.py
256 257 | |
add_entry(buildpath, entry)
Source code in src/pkgforge/common.py
250 251 | |
buildpath(localpath)
Source code in src/pkgforge/common.py
206 207 | |
compactdb()
Collapse the DB's redundant history (backend-specific; no-op if none).
Source code in src/pkgforge/common.py
224 225 226 227 228 | |
initdb()
Create or reset an empty DB (no-op for a stdout / unset DB).
Source code in src/pkgforge/common.py
230 231 232 233 234 | |
loaddb()
Source code in src/pkgforge/common.py
219 220 221 222 | |
localpath(buildpath)
Source code in src/pkgforge/common.py
203 204 | |
remove_entry(buildpath)
Source code in src/pkgforge/common.py
253 254 | |
Storage backends
pkgforge.db.DbProvider(path)
Bases: ABC
Storage backend for a file DB, bound to a filesystem path.
Source code in src/pkgforge/db.py
106 107 | |
format = ''
class-attribute
instance-attribute
path = path
instance-attribute
add(path, entry)
abstractmethod
Record entry for path.
Source code in src/pkgforge/db.py
113 114 115 | |
compact()
abstractmethod
Collapse redundant history (a no-op for backends without any).
Source code in src/pkgforge/db.py
121 122 123 | |
init()
abstractmethod
Create or reset an empty DB.
Source code in src/pkgforge/db.py
125 126 127 | |
load()
abstractmethod
Return the full DB as {path: entry-or-None}.
Source code in src/pkgforge/db.py
109 110 111 | |
remove(path)
abstractmethod
Mark path removed.
Source code in src/pkgforge/db.py
117 118 119 | |
pkgforge.db.register_provider(name, provider_cls, *, suffixes=(), sniff=None)
Register a file-DB backend so :func:open_db can select it.
This is the extension seam that keeps third-party backends OUT of core
pkgforge: an external package calls register_provider at import time
and its format becomes usable via --db-format <name>, a matching file
suffix, or content sniffing.
name-- the format name (used by--db-formatand error messages).provider_cls-- a :class:DbProvidersubclass constructed asprovider_cls(path).suffixes-- file suffixes (e.g.(".toml",), leading dot, case-insensitive) that infer this format from a--dbpath.sniff-- optionalsniff(head: bytes) -> boolthat inspects a file's first 16 bytes and returns True if this backend owns it. Registered sniffers are consulted newest-first, before the built-in heuristics, so a later registration can claim a shape an earlier one would.
Returns provider_cls so it can be used as a decorator. Re-registering a
name replaces the previous class for that name.
Source code in src/pkgforge/db.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
pkgforge.db.open_db(path, fmt=None, *, for_read=False)
Resolve and construct the :class:DbProvider for path.
Precedence: an explicit fmt wins; otherwise, when for_read and the
file already exists, its content is sniffed (so a mislabeled or legacy file
still loads); otherwise the suffix decides (defaulting to JSON Lines).
Source code in src/pkgforge/db.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
Commands
pkgforge.install.Install(**kwargs)
Bases: FileEntryArgs, PkgForgeCmd
Install a source into the build root and record its file entry.
Source code in src/pkgforge/install.py
108 109 110 111 112 113 114 115 116 117 118 | |
chown = False
class-attribute
instance-attribute
decompress = False
class-attribute
instance-attribute
destination
instance-attribute
exclude = []
class-attribute
instance-attribute
no_target_directory
instance-attribute
noentry = False
class-attribute
instance-attribute
parents
instance-attribute
remove_source = False
class-attribute
instance-attribute
source = []
class-attribute
instance-attribute
type = DEFAULT
class-attribute
instance-attribute
__call__()
Source code in src/pkgforge/install.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
install(src, dst)
Source code in src/pkgforge/install.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
pkgforge.scan.ScanCmd
Bases: FileEntryArgs, PkgForgeCmd
Scan a path under the build root and record each file's entry in the DB.
exclude = []
class-attribute
instance-attribute
missing = False
class-attribute
instance-attribute
path
instance-attribute
__call__()
Source code in src/pkgforge/scan.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
pkgforge.compact.Compact
Bases: PkgForgeCmd
Collapse the DB to one record per live path (drop superseded/removed).
__call__()
Source code in src/pkgforge/compact.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |
pkgforge.dbdump.DbDump
Bases: PkgForgeCmd
Dump the file DB into a packaging manifest (rpm or debian).
exclude = []
class-attribute
instance-attribute
format
instance-attribute
output = Path('-')
class-attribute
instance-attribute
__call__()
Source code in src/pkgforge/dbdump.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Dump formats
pkgforge.dbdump.rpmspecfile(path, entry)
Source code in src/pkgforge/dbdump.py
41 42 43 44 45 46 47 48 49 50 51 | |
pkgforge.dbdump.dump_formats()
All known format names, sorted (for --help / error messages).
Source code in src/pkgforge/dbdump.py
101 102 103 | |
Extraction helpers
pkgforge.install._is_tar_source(src)
True if src is a tar-family archive stdlib :mod:tarfile can extract.
Source code in src/pkgforge/install.py
52 53 54 55 | |
pkgforge.install._extract_tar(fileobj_or_name, dst)
Extract a tar-family archive into dst using stdlib :mod:tarfile.
Uses the safe data extraction filter where the interpreter supports it
(guards against absolute paths / traversal / special files); older
interpreters without filter= extract without it.
Source code in src/pkgforge/install.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |