Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nicotine-plus/nicotine-plus/llms.txt

Use this file to discover all available pages before exploring further.

The config module handles reading, writing, and managing application configuration.

Config Class

Manages configuration information with file persistence.

Attributes

config_file_path
str
Path to the configuration file
data_folder_path
str
Path to the application data folder
sections
dict
Two-level dictionary containing all configuration values. First-level keys are section names, second-level keys are parameter names.
defaults
dict
Default configuration values

Methods

get_user_folders()

@staticmethod
def get_user_folders()
Returns a tuple of (config_folder_path, data_folder_path).
config_folder_path
str
Path to configuration folder
data_folder_path
str
Path to data folder
from pynicotine.config import Config

config_folder, data_folder = Config.get_user_folders()
print(f"Config: {config_folder}")
print(f"Data: {data_folder}")

load_config()

def load_config(self, isolated_mode=False)
Loads configuration from file and applies defaults.
isolated_mode
bool
default:false
Whether to run in isolated mode

need_config()

def need_config(self)
Checks if username or password are missing from configuration.
result
bool
True if configuration is incomplete

write_configuration()

def write_configuration(self)
Writes current configuration to file with automatic backup.
Configuration is automatically backed up before writing. Legacy options are removed during the write process.

write_config_backup()

def write_config_backup(self, file_path)
Creates a compressed backup of the configuration file.
file_path
str
Destination path for backup file (will append .tar.bz2 if not present)
from pynicotine.config import config

config.write_config_backup("/path/to/backup")

Configuration Sections

Server Section

Server connection and authentication settings.
config.sections["server"]["server"]  # (hostname, port) tuple
config.sections["server"]["login"]   # Username
config.sections["server"]["passw"]   # Password
config.sections["server"]["portrange"]  # (min_port, max_port) tuple

Transfers Section

File transfer and sharing settings.
config.sections["transfers"]["downloaddir"]  # Download directory
config.sections["transfers"]["shared"]       # List of shared folders
config.sections["transfers"]["uploadslots"]  # Number of upload slots

Searches Section

Search-related settings.
config.sections["searches"]["maxresults"]  # Maximum search results
config.sections["searches"]["history"]     # Search history
from pynicotine.config import config

# Load configuration
config.load_config()

# Read values
username = config.sections["server"]["login"]
download_dir = config.sections["transfers"]["downloaddir"]

# Modify values
config.sections["transfers"]["uploadslots"] = 3

# Save changes
config.write_configuration()

Global Instance

from pynicotine.config import config
A global config instance is available for import.