whl2conda.settings
Settings for whl2conda.
Internally, the settings are accessed through the settings global variable, which is an instance of Whl2CondaSettings
The settings are loaded from a persistent JSON file, whose default location depends on the operating system, e.g.:
OS | Path |
---|---|
Windows | ~/AppData/Local/whl2conda/whl2conda/settings.json |
Linux | ~/.config/whl2conda/settings.json |
MacOS | ~/Library/Application Support/whl2conda/settings.json |
The location of the settings file may also be overridden by --settings
command line argument to whl2conda
.
Use the settings_file attribute to get the path used to load a given settings object.
Settings may be viewed and modified at the command line using whl2conda config.
Attributes
settings
module-attribute
settings = from_file()
User settings.
Classes
Whl2CondaSettings
dataclass
User settings for whl2conda.
These are accessed through the global settings variable.
The following settings are currently supported:
- auto_update_std_renames - whether to automatically update std rename mappings
- conda_format - default output conda package format
- pypi_indexes - table of known extra pypi indexes
Source code in src/whl2conda/settings.py
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 233 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 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
Attributes
DEFAULT_SETTINGS_FILE
class-attribute
DEFAULT_SETTINGS_FILE: Path = (
user_config_path("whl2conda") / SETTINGS_FILENAME
)
Default filepath for saved settings.
SETTINGS_FILENAME
class-attribute
SETTINGS_FILENAME: str = 'settings.json'
Default base filename for saved settings.
auto_update_std_renames
class-attribute
instance-attribute
auto_update_std_renames: _BoolField = _BoolField()
Whether to automatically update the standard renames for operations that need them. Default is false.
conda_format
class-attribute
instance-attribute
conda_format: _CondaPackageFormatField = (
_CondaPackageFormatField()
)
The default output conda package format if not specified. Default is V2.
pypi_indexes
class-attribute
instance-attribute
pypi_indexes: _SettingsField = _SettingsField(default=dict)
Dictionary of aliases for pypi package indexes from which wheels can be downloaded. Default is empty.
settings_file
property
settings_file: Path
Settings file for this settings object.
Set from from_file constructor or else will be DEFAULT_SETTINGS_FILE.
Functions
from_file
classmethod
from_file(
filename: Union[Path, str] = ""
) -> Whl2CondaSettings
Return settings read from file.
PARAMETER | DESCRIPTION |
---|---|
filename |
relative path to settings file (may start with '~') defaults to DEFAULT_SETTINGS_FILE if not specified. |
Source code in src/whl2conda/settings.py
328 329 330 331 332 333 334 335 336 337 338 339 |
|
get
get(key: str) -> Any
Get a value from the settings by string key.
The key may either be just the field name (e.g. 'conda-format') or can refer to am entry within dictionary-valued field (e.g. 'pypi-indexes.acme'). Note that the dashes in the first component of the key will be converted to underscores.
Source code in src/whl2conda/settings.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
load
load(
filename: Union[Path, str], reset_all: bool = False
) -> None
Reload settings from file
PARAMETER | DESCRIPTION |
---|---|
filename |
relative path to settings file (may start with '~') |
reset_all |
if True, then all settings will be unset and reverted to default value prior to loading.
TYPE:
|
Source code in src/whl2conda/settings.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
save
save(filename: Union[Path, str] = '') -> None
Write settings to specified file in JSON format.
PARAMETER | DESCRIPTION |
---|---|
filename |
file to write. Defaults to settings_file |
Source code in src/whl2conda/settings.py
367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
set
set(key: str, value: Any) -> None
Set a value in the settings by string key.
See get for details on key format.
This does not save the settings file.
Source code in src/whl2conda/settings.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
to_dict
to_dict() -> dict[str, Any]
Return dictionary containing public settings data.
Source code in src/whl2conda/settings.py
239 240 241 242 243 244 245 |
|
unset
unset(key: str) -> None
Unset attribute with given key.
The setting will revert to its original value.
See get for details on key format.
This does not save the settings file.
Source code in src/whl2conda/settings.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
unset_all
unset_all() -> None
Unset all settings, and revert to default values.
Source code in src/whl2conda/settings.py
317 318 319 320 321 322 |
|