Scanning¶
modelmap.scanner
¶
Run the providers and the tree scans and return one :class:Scan.
Order of work, which is also the order files are charged in:
- Each provider's stores, in the order of
PROVIDERS. - Paths the user named.
- With no paths named, a sweep of the home directory for loose models.
A directory is scanned once. A root that is the same directory as one already scanned, or lies inside one, is skipped: the ledger would keep the totals right, but every model would be listed a second time at size 0.
Options(paths=(), only=None, defaults=True, sweep=None, excludes=(), min_size=MIN_UNVERIFIED_SIZE, max_depth=None)
dataclass
¶
What to scan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Sequence[str]
|
Files or directories the user named. |
()
|
only
|
Sequence[str] | None
|
Provider names to run; None for all. |
None
|
defaults
|
bool
|
Scan the known stores. |
True
|
sweep
|
bool | None
|
Sweep the home directory for loose models. None means yes when neither paths nor providers are named. |
None
|
excludes
|
Sequence[str]
|
Glob patterns skipped in tree scans. |
()
|
min_size
|
int
|
Smallest file to list when only its extension says it is a model. |
MIN_UNVERIFIED_SIZE
|
max_depth
|
int | None
|
Levels to descend below a named path; None for all. |
None
|
redact(scan, home)
¶
Remove what identifies the machine and its user, in place.
The home directory becomes ~ wherever it appears: in paths, in
warning and issue text, and in the names of loose records, which start
with the name of their parent directory. The host name is dropped. Use
before sending an inventory to someone else.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan
|
Scan
|
The scan to change. |
required |
home
|
str | PathLike[str]
|
The home directory to hide, as configured and as resolved. |
required |
Returns:
| Type | Description |
|---|---|
Scan
|
The same scan. |
Source code in src/modelmap/scanner.py
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
scan(ctx=None, options=None)
¶
Scan a machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context | None
|
The machine to scan; the running one by default. |
None
|
options
|
Options | None
|
What to scan; the known stores and a home sweep by default. |
None
|
Returns:
| Type | Description |
|---|---|
Scan
|
Everything found. If the scan is interrupted, what was found so far, with a warning. |
Source code in src/modelmap/scanner.py
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 | |