upref’s documentationΒΆ

upref 🐸¢

Upref is a small python module to grab and save some user data like login, password, url (mainly string data). After some projects, I want a simple method to find the right login and url from the user and save it in the personnal data of the user.

Wheel Status Latest Version License Build Status Documentation Status

InstallationΒΆ

Installing upref with pip:

$ pip install upref

Basic UsageΒΆ

Here is the first example. The code fetch the URL from the user parameter

import upref

user_data = upref.get_pref(
    {"url": {"label": "The application url"}},
    "example01")

print("URL is {}".format(user_data['url']))

This code create a file in the user folder. And this file will be read again during the next run.

url:
  label: The application url
  value: http://www.test.org/

Code exampleΒΆ

import upref
data = upref.get_pref(
    {
        'login': {'label': "Your login"},
        'passwd': {'label': "Your secret password",
                'type': "Password"},
    },
    name="example02")
print("Your login is %s" % data['login'])
print("Your password (not so secret) is %s" % data['passwd'])

At the first execution, there is a window to grab the data. The second execution, there will be no windows, the data are only read from the file.

All data are saved in a yaml file at %APPDATA%/.upref/example02.conf or ~/.local/share/.upref/example02.conf.

login:
  label: Your login
  value: My login
passwd:
  label: Your secret password
  value: Password

FeaturesΒΆ

  • Read and save small amount of data (url, login, )
  • Small gui to ask data from the user
  • Text option is avaible

LicenseΒΆ

The upref is licensed under the terms of the MIT license and is available for free.

MIT Β© Florent

MIT LicenseΒΆ

Copyright (c) 2019 Florent Tournois

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ExamplesΒΆ

Easy first ExamplesΒΆ

Read the interesting URL from the user. At the second run, nothing is asked to the user.

1
2
3
4
5
6
7
import upref

user_data = upref.get_pref(
    {"url": {"label": "The application url"}},
    "example01")

print("URL is {}".format(user_data['url']))

Here is the created file. The is located in the user folder.

example01.confΒΆ
1
2
3
url:
  label: The application url
  value: http://www.test.org/

Library APIΒΆ

Class HierarchyΒΆ

File HierarchyΒΆ

Full APIΒΆ

NamespacesΒΆ

Namespace uprefΒΆ

Copyright (c) 2018 Florent TOURNOIS.

Detailed DescriptionΒΆ

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Small tool to grab data from the user and to save it

Classes and StructsΒΆ

Class PrefDialogΒΆ
Inheritance RelationshipsΒΆ
Base TypeΒΆ
  • public Dialog
Class DocumentationΒΆ
class PrefDialogΒΆ

Main dialog in wxPython.

Public Functions

__init__(self self, parent parent, data data)ΒΆ
init_ui(self self)ΒΆ
on_ok(self self, event event)ΒΆ
on_close(self self, event event)ΒΆ

Public Members

data_descriptionΒΆ
panelΒΆ
data_widgetΒΆ

FunctionsΒΆ

Function upref::core::__get_this_filenameΒΆ
Function DocumentationΒΆ
upref.core.__get_this_filename()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the filename of THIS script.

Function upref::core::__get_this_folderΒΆ
Function DocumentationΒΆ
upref.core.__get_this_folder()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the folder of THIS script.

Function upref::core::__mainΒΆ
Function DocumentationΒΆ
upref.core.__main()ΒΆ

Main script call only if this script is runned directly.

Function upref::core::__set_logging_systemΒΆ
Function DocumentationΒΆ
upref.core.__set_logging_system()ΒΆ

Set up the logging system.

Function upref::core::all_values_are_setΒΆ
Function DocumentationΒΆ
upref.core.all_values_are_set(data_description data_description)ΒΆ

Conversion from the direct pref dict to a dict of descripiton.

Function upref::core::conv_description_to_rawΒΆ
Function DocumentationΒΆ
upref.core.conv_description_to_raw(data_description data_description)ΒΆ

Conversion from the direct pref dict to a dict of descripiton.

Function upref::core::conv_raw_to_descriptionΒΆ
Function DocumentationΒΆ
upref.core.conv_raw_to_description(data data)ΒΆ

Conversion from the direct pref dict to a dict of descripiton.

Function upref::core::current_uprefΒΆ
Function DocumentationΒΆ
upref.core.current_upref(name name)ΒΆ

Read the current upref of the user.

Return
the dict with the preference
Parameters
  • name: the name of the preference file (we add the extension .upref)

Function upref::core::default_confΒΆ
Function DocumentationΒΆ
upref.core.default_conf()ΒΆ

Read a conf file and return the dict.

Function upref::core::dict_mergeΒΆ
Function DocumentationΒΆ
upref.core.dict_merge(dct dct, merge_dct merge_dct, add_keys add_keys = True)ΒΆ

Recursive dict merge.

Inspired by :meth:dict.update(), instead of updating only top-level keys, dict_merge recurses down into dicts nested to an arbitrary depth, updating keys. The merge_dct is merged into dct.

This version will return a copy of the dictionary and leave the original arguments untouched.

The optional argument add_keys, determines whether keys which are present in merge_dict but not dct should be included in the new dict.

Code from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9

Args: dct (dict) onto which the merge is executed merge_dct (dict): dct merged into dct add_keys (bool): whether to add new keys

Returns: dict: updated dict

Function upref::core::get_prefΒΆ
Function DocumentationΒΆ
upref.core.get_pref(data_description data_description, name name, interface interface = "gui", force_renew force_renew = False, mandatory mandatory = True)ΒΆ

Get the value of preference or setting.

Function upref::core::is_frozenΒΆ
Function DocumentationΒΆ
upref.core.is_frozen()ΒΆ

Test the frozen situation of the executable.

Function upref::core::load_confΒΆ
Function DocumentationΒΆ
upref.core.load_conf(filename filename)ΒΆ

Read a conf file and return the dict.

Function upref::core::load_dataΒΆ
Function DocumentationΒΆ
upref.core.load_data(name name, default_data default_data = None)ΒΆ

Read the current upref of the user.

Return
the dict with the preference
Parameters
  • name: the name of the preference file (we add the extension .upref)

Function upref::core::remove_prefΒΆ
Function DocumentationΒΆ
upref.core.remove_pref(name name)ΒΆ

Remove the preference file.

Function upref::core::save_confΒΆ
Function DocumentationΒΆ
upref.core.save_conf(conf conf, filename filename)ΒΆ

Read a conf file and return the dict.

Function upref::core::save_dataΒΆ
Function DocumentationΒΆ
upref.core.save_data(data data, name name)ΒΆ

Read the current upref of the user.

Return
the dict with the preference
Parameters
  • name: the name of the preference file (we add the extension .upref)

Function upref::core::set_prefΒΆ
Function DocumentationΒΆ
upref.core.set_pref(data data, name name, data_description data_description = None)ΒΆ

Get the value of preference or setting.

Function upref::core::upref_filenameΒΆ
Function DocumentationΒΆ
upref.core.upref_filename(name name)ΒΆ

Read the current upref of the user.

Return
the complet filename of the upref file
Parameters
  • name: the name of the preference file (we add the extension .upref)

Function upref::gui::__get_this_filenameΒΆ
Function DocumentationΒΆ
upref.gui.__get_this_filename()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the filename of THIS script.

Function upref::gui::__get_this_folderΒΆ
Function DocumentationΒΆ
upref.gui.__get_this_folder()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the folder of THIS script.

Function upref::gui::__mainΒΆ
Function DocumentationΒΆ
upref.gui.__main()ΒΆ

Main script call only if this script is runned directly.

Function upref::gui::__set_logging_systemΒΆ
Function DocumentationΒΆ
upref.gui.__set_logging_system()ΒΆ

Set up the logging system.

Function upref::gui::get_dataΒΆ
Function DocumentationΒΆ
upref.gui.get_data(data_description data_description)ΒΆ
Function upref::gui::get_widgetΒΆ
Function DocumentationΒΆ
upref.gui.get_widget(parent parent, data data)ΒΆ

Build a widget to collect the data.

Function upref::gui::get_widget_styleΒΆ
Function DocumentationΒΆ
upref.gui.get_widget_style(style style)ΒΆ

Build a widget to collect the data.

Function upref::gui::is_frozenΒΆ
Function DocumentationΒΆ
upref.gui.is_frozen()ΒΆ

Test the frozen situation of the executable.

Function upref::gui::messageΒΆ
Function DocumentationΒΆ
upref.gui.message(msg_txt msg_txt, title title)ΒΆ

Display a message.

Function upref::tty::__get_this_filenameΒΆ
Function DocumentationΒΆ
upref.tty.__get_this_filename()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the filename of THIS script.

Function upref::tty::__get_this_folderΒΆ
Function DocumentationΒΆ
upref.tty.__get_this_folder()ΒΆ

Find the filename of this file (depend on the frozen or not) This function return the filename of this script.

The function is complex for the frozen system

Return
the folder of THIS script.

Function upref::tty::__mainΒΆ
Function DocumentationΒΆ
upref.tty.__main()ΒΆ

Main script call only if this script is runned directly.

Function upref::tty::__set_logging_systemΒΆ
Function DocumentationΒΆ
upref.tty.__set_logging_system()ΒΆ

Set up the logging system.

Function upref::tty::get_dataΒΆ
Function DocumentationΒΆ
upref.tty.get_data(data_description data_description)ΒΆ

Get the data from the user.

Function upref::tty::is_frozenΒΆ
Function DocumentationΒΆ
upref.tty.is_frozen()ΒΆ

Test the frozen situation of the executable.

Function upref::tty::messageΒΆ
Function DocumentationΒΆ
upref.tty.message(msg_txt msg_txt, title title)ΒΆ

Display a message.

VariablesΒΆ

Variable upref::__all__ΒΆ
Variable DocumentationΒΆ
list upref.__all__= [ 'get_pref', 'set_pref', 'remove_pref', 'upref_filename', 'load_conf', 'load_data', 'save_data', 'current_upref',]
Variable upref::__author__ΒΆ
Variable DocumentationΒΆ
string upref.__author__ = "Florent Tournois"
Variable upref::__credits__ΒΆ
Variable DocumentationΒΆ
list upref.__credits__ = ["Arnaud Boidard, Bernard Migaud"]
Variable upref::__email__ΒΆ
Variable DocumentationΒΆ
string upref.__email__ = "florent.tournois@gmail.fr"
Variable upref::__license__ΒΆ
Variable DocumentationΒΆ
string upref.__license__ = "MIT"
Variable upref::__maintainer__ΒΆ
Variable DocumentationΒΆ
string upref.__maintainer__ = "Florent Tournois"
Variable upref::__status__ΒΆ
Variable DocumentationΒΆ
string upref.__status__ = "Production"
Variable upref::__version__ΒΆ
Variable DocumentationΒΆ
string upref.__version__ = '.'.join(str(c) for c in __version_info__)
Variable upref::core::__DEFAULT_CONF_FILENAME__ΒΆ
Variable DocumentationΒΆ
string upref.core.__DEFAULT_CONF_FILENAME__ = "default.conf"

The filename of the default configuration.

Variable upref::core::__EXT_FILENAME__ΒΆ
Variable DocumentationΒΆ
string upref.core.__EXT_FILENAME__ = ".conf"

The filename of the default configuration.

Variable upref::core::__UPREF_FOLDER__ΒΆ
Variable DocumentationΒΆ
string upref.core.__UPREF_FOLDER__ = ".upref"

The filename of the default configuration.

Variable upref::gui::__all__ΒΆ
Variable DocumentationΒΆ
list upref.gui.__all__ = ['get_data']
Variable upref::tty::__all__ΒΆ
Variable DocumentationΒΆ
list upref.tty.__all__ = ['get_data']
Variable upref::version::__release_date__ΒΆ
Variable DocumentationΒΆ
string upref.version.__release_date__ = '2019-09-26'
Variable upref::version::__version_info__ΒΆ
Variable DocumentationΒΆ
tuple upref.version.__version_info__ = (1, 0, 13)

Class HierarchyΒΆ

File HierarchyΒΆ

Full APIΒΆ

NamespacesΒΆ

Classes and StructsΒΆ

FunctionsΒΆ

VariablesΒΆ

Indices and tablesΒΆ