Module refinery.lib.inno

Library functions for processing of Inno Setup files.

Expand source code Browse git
"""
Library functions for processing of Inno Setup files.
"""
from collections.abc import MutableMapping


class CaseInsensitiveDict(MutableMapping):

    def __init__(self, data=None, **kwargs):
        if isinstance(data, CaseInsensitiveDict):
            self._fold = dict(data._fold)
            self._dict = dict(data._dict)
        else:
            self._fold = dict()
            self._dict = dict()
            self.update(data or {}, **kwargs)

    def __setitem__(self, key: str, value):
        kci = key.casefold()
        self._fold[kci] = key
        self._dict[key] = value

    def __getitem__(self, key: str):
        return self._dict[self._fold[key.casefold()]]

    def __delitem__(self, key: str):
        kci = key.casefold()
        key = self._fold[kci]
        del self._fold[kci]
        del self._dict[key]

    def __iter__(self):
        return iter(self._dict)

    def __len__(self):
        return len(self._dict)

    def casefold(self):
        for kci, key in self._fold.items():
            yield (kci, self._dict[key])

    def __eq__(self, other):
        try:
            other = CaseInsensitiveDict(other)
        except Exception:
            return False
        return dict(self.casefold()) == dict(other.casefold())

    def copy(self):
        return CaseInsensitiveDict(self)

    def __repr__(self):
        return repr(self._dict)

Sub-modules

refinery.lib.inno.archive

Data structures and methods for parsing Inno Setup installer archives. The design is based on [innoextract][IE] source code and its Python port in …

refinery.lib.inno.constants

Inno Setup constants as Setup expands them: how the end of a constant is found and its parameters are split, which names each version of Setup knows, …

refinery.lib.inno.delphi

Behavior of the Delphi run-time library that Inno Setup scripts reach: the exceptions and messages of refinery.lib.inno.delphi.errors, the …

refinery.lib.inno.emulation

What an emulation of an Inno Setup script reports and how it ends: the events that the emulators of refinery.lib.inno.emulator yield, and the …

refinery.lib.inno.emulator

An emulator for Inno Setup executables. The implementation is unlikely to be 100% correct as it was engineered by making various malicious scripts …

refinery.lib.inno.expressions

Setup's boolean expressions, as Inno Setup's TSimpleExpression evaluates them: the Check parameter of entries, the yes-or-no directives written as …

refinery.lib.inno.host

Inno Setup as the host of a script: what Setup decides on its own from its installer and the configuration, HostSetup, and the values of its …

refinery.lib.inno.ifps

The code is based on the logic implemented in IFPSTools: https://github.com/Wack0/IFPSTools

refinery.lib.inno.installation

Inno Setup's procedure as InnoSetupEmulator runs it: the walk of the wizard when the user clicks Next on every page, the …

refinery.lib.inno.pascal

Pascal Script's rules for the values of its types: how it reads a value of one type as another, stores a value into a variable, computes with two …

refinery.lib.inno.pathfunc

Setup's rules for paths: Inno Setup's PathFunc unit, which Setup and its support functions use, the wizard's tidying of folder and group names, and …

refinery.lib.inno.release

The release of Inno Setup that built an installer, as far as the installer tells it. Where releases of Setup behave differently, the emulator asks …

refinery.lib.inno.symbols

Contains a library of known external function symbols for the IFPS runtime in InnoSetup installers.

refinery.lib.inno.wizard

The wizard of Setup as the emulator models it: the order of its pages, the pages that the script creates, the page that is shown, the choices that its …

Classes

class CaseInsensitiveDict (data=None, **kwargs)

A MutableMapping is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for getitem, setitem, delitem, iter, and len.

Expand source code Browse git
class CaseInsensitiveDict(MutableMapping):

    def __init__(self, data=None, **kwargs):
        if isinstance(data, CaseInsensitiveDict):
            self._fold = dict(data._fold)
            self._dict = dict(data._dict)
        else:
            self._fold = dict()
            self._dict = dict()
            self.update(data or {}, **kwargs)

    def __setitem__(self, key: str, value):
        kci = key.casefold()
        self._fold[kci] = key
        self._dict[key] = value

    def __getitem__(self, key: str):
        return self._dict[self._fold[key.casefold()]]

    def __delitem__(self, key: str):
        kci = key.casefold()
        key = self._fold[kci]
        del self._fold[kci]
        del self._dict[key]

    def __iter__(self):
        return iter(self._dict)

    def __len__(self):
        return len(self._dict)

    def casefold(self):
        for kci, key in self._fold.items():
            yield (kci, self._dict[key])

    def __eq__(self, other):
        try:
            other = CaseInsensitiveDict(other)
        except Exception:
            return False
        return dict(self.casefold()) == dict(other.casefold())

    def copy(self):
        return CaseInsensitiveDict(self)

    def __repr__(self):
        return repr(self._dict)

Ancestors

  • collections.abc.MutableMapping
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Methods

def casefold(self)
Expand source code Browse git
def casefold(self):
    for kci, key in self._fold.items():
        yield (kci, self._dict[key])
def copy(self)
Expand source code Browse git
def copy(self):
    return CaseInsensitiveDict(self)