installer.py

sysdirs.installer

Copyright (C) 2018 Mathias Stelzer

sysdirs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

sysdirs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

exception sysdirs.installer.NotInstalled[source]

Bases: Exception

exception sysdirs.installer.InstallationError[source]

Bases: Exception

class sysdirs.installer.BaseInstaller[source]

Bases: object

Base class to install and access system directories.

Subclass it to configure your project:

>>> from sysdirs import BaseInstaller, FHS, XDG, DevDir
>>> class Installer(BaseInstaller):
...     project_name = 'myproject'
...     specifications = [
...         FHS(force=True),
...         XDG,
...         DevDir(__file__)
...     ]
...
>>> installer = Installer()
>>> dirs = installer.install()
>>> dirs = installer.load()
project_name = None

str - Name of your project

multiple_installations = True

bool - Allow multiple installations, set to False to raise if already installed

interface_class

alias of sysdirs.interfaces.TerminalInterface

input_timeout = None

int - Seconds to wait for user input before using default values. Required in automated installations (e.g. debian packages)! This ensures the installation won’t halt in case the interface is shown where it shouldn’t.

config_mode = 488
data_mode = 493
cache_mode = 504
var_mode = 504
run_mode = 504
log_mode = 504
specifications = []

list - Directory specifications your project supports

get_specifications()[source]
find_specification_by_name(name)[source]
find_installation_specification()[source]
specification_format_callback(specification)[source]
get_interface_class()[source]
get_interface()[source]
get_uninstall_directories()[source]
load(require=True)[source]
is_installed()[source]
install(specification=None)[source]
uninstall()[source]
setup_subparser(subparsers)[source]
setup_argument_parser(parser)[source]
class sysdirs.installer.Installer(project_name, specifications=None, config=False, data=False, cache=False, var=False, run=False, log=False)[source]

Bases: sysdirs.installer.BaseInstaller

Class to install and access system directories.

Usage:

>>> from sysdirs import Installer, FHS, XDG
>>> installer = Installer('myproject', specifications=[FHS, XDG], config=True)
>>> dirs = installer.install()
specifications = [<class 'sysdirs.specifications.XDG'>]
install(specification=None)[source]