Module Expr Str Import alias Import alias ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Raise Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr body Return NameLoad If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr body Return NameLoad TryExcept body With Call NameLoad AttributeLoad NameLoad attr Str NameStore body Assign NameStore Call AttributeLoad NameLoad attr NameLoad For NameStore Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad handlers ExceptHandler body Pass Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str With Call NameLoad AttributeLoad NameLoad attr Str NameStore body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Num Assign NameStore Call NameLoad For NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad For NameStore NameLoad body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad Return Call AttributeLoad Str attr NameLoad decorator_list decorator_list
N/A N/A 

.. moduleauthor:: Stephen Raymond Ferg and Robert Lugg (active)
.. default-domain:: py
.. highlight:: python

Version |release|
 N/A os N/A pickle EgStore N/A N/A N/A 
A class to support persistent storage.

You can use EgStore to support the storage and retrieval
of user settings for an EasyGui application.

**Example A: define a class named Settings as a subclass of EgStore**
::

    class Settings(EgStore):
        def __init__(self, filename):  # filename is required
            #-------------------------------------------------
            # Specify default/initial values for variables that
            # this particular application wants to remember.
            #-------------------------------------------------
            self.userId = ""
            self.targetServer = ""

            #-------------------------------------------------
            # For subclasses of EgStore, these must be
            # the last two statements in  __init__
            #-------------------------------------------------
            self.filename = filename  # this is required
            self.restore()            # restore values from the storage file if possible

**Example B: create settings, a persistent Settings object**
::

    settingsFile = "myApp_settings.txt"
    settings = Settings(settingsFile)

    user    = "obama_barak"
    server  = "whitehouse1"
    settings.userId = user
    settings.targetServer = server
    settings.store()    # persist the settings

    # run code that gets a new value for userId, and persist the settings
    user    = "biden_joe"
    settings.userId = user
    settings.store()

**Example C: recover the Settings instance, change an attribute, and store it again.**
::

    settings = Settings(settingsFile)
    settings.userId = "vanrossum_g"
    settings.store()

 __init__ N/A N/A self filename N/A N/A N/A N/A self filename None N/A N/A NotImplementedError N/A restore N/A N/A self N/A N/A N/A 
        Set the values of whatever attributes are recoverable
        from the pickle file.

        Populate the attributes (the __dict__) of the EgStore object
        from     the attributes (the __dict__) of the pickled object.

        If the pickled object has attributes that have been initialized
        in the EgStore object, then those attributes of the EgStore object
        will be replaced by the values of the corresponding attributes
        in the pickled object.

        If the pickled object is missing some attributes that have
        been initialized in the EgStore object, then those attributes
        of the EgStore object will retain the values that they were
        initialized with.

        If the pickled object has some attributes that were not
        initialized in the EgStore object, then those attributes
        will be ignored.

        IN SUMMARY:

        After the recover() operation, the EgStore object will have all,
        and only, the attributes that it had when it was initialized.

        Where possible, those attributes will have values recovered
        from the pickled object.
         N/A N/A N/A N/A N/A os path exists N/A self filename N/A N/A self N/A N/A N/A N/A N/A os path isfile N/A self filename N/A N/A self N/A N/A N/A N/A open N/A self filename rb f N/A N/A unpickledObject N/A N/A pickle load f N/A key N/A list N/A N/A N/A self __dict__ keys N/A N/A default N/A N/A self __dict__ N/A key N/A N/A N/A self __dict__ N/A key N/A N/A N/A unpickledObject __dict__ get key default N/A N/A N/A N/A N/A self N/A store N/A N/A self N/A N/A N/A 
        Save the attributes of the EgStore object to a pickle file.
        Note that if the directory for the pickle file does not already exist,
        the store operation will fail.
         N/A N/A open N/A self filename wb f N/A N/A N/A N/A pickle dump self f N/A kill N/A N/A self N/A N/A N/A 
        Delete my persistent file (i.e. pickle file), if it exists.
         N/A N/A N/A N/A os path isfile N/A self filename N/A N/A N/A N/A os remove N/A self filename N/A N/A __str__ N/A N/A self N/A N/A N/A 
        return my contents as a string in an easy-to-read format.
         N/A longest_key_length 0 N/A keys N/A list N/A key N/A N/A N/A self __dict__ keys N/A N/A N/A N/A keys append key N/A longest_key_length N/A max longest_key_length N/A len key N/A N/A N/A keys sort N/A lines N/A list N/A key keys N/A N/A value N/A N/A self __dict__ N/A key N/A key N/A N/A key ljust longest_key_length N/A N/A N/A lines append N/A %s : %s
 N/A key N/A repr value N/A N/A N/A join lines N/A N/A