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.
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.
1 2 3 | url:
label: The application url
value: http://www.test.org/
|
Library APIΒΆ
Class HierarchyΒΆ
-
- Namespace upref
- Namespace upref::gui
- Class PrefDialog
- Namespace upref::gui
- Namespace upref
File HierarchyΒΆ
-
- Directory upref
- File __init__.py
- File core.py
- File gui.py
- File tty.py
- File version.py
- Directory upref
Full APIΒΆ
NamespacesΒΆ
Namespace uprefΒΆ
Copyright (c) 2018 Florent TOURNOIS.
Contents
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
NamespacesΒΆ
Namespace upref::coreΒΆ
FunctionsΒΆ
- Function upref::core::__get_this_filename
- Function upref::core::__get_this_folder
- Function upref::core::__main
- Function upref::core::__set_logging_system
- Function upref::core::all_values_are_set
- Function upref::core::conv_description_to_raw
- Function upref::core::conv_raw_to_description
- Function upref::core::current_upref
- Function upref::core::default_conf
- Function upref::core::dict_merge
- Function upref::core::get_pref
- Function upref::core::is_frozen
- Function upref::core::load_conf
- Function upref::core::load_data
- Function upref::core::remove_pref
- Function upref::core::save_conf
- Function upref::core::save_data
- Function upref::core::set_pref
- Function upref::core::upref_filename
Namespace upref::guiΒΆ
ClassesΒΆ
FunctionsΒΆ
- Function upref::gui::__get_this_filename
- Function upref::gui::__get_this_folder
- Function upref::gui::__main
- Function upref::gui::__set_logging_system
- Function upref::gui::get_data
- Function upref::gui::get_widget
- Function upref::gui::get_widget_style
- Function upref::gui::is_frozen
- Function upref::gui::message
VariablesΒΆ
Namespace upref::versionΒΆ
Contents
Classes and StructsΒΆ
Class PrefDialogΒΆ
- Defined in File gui.py
FunctionsΒΆ
Function upref::core::__get_this_filenameΒΆ
- Defined in File core.py
Function upref::core::__get_this_folderΒΆ
- Defined in File core.py
Function upref::core::__mainΒΆ
- Defined in File core.py
Function upref::core::__set_logging_systemΒΆ
- Defined in File core.py
Function upref::core::all_values_are_setΒΆ
- Defined in File core.py
Function upref::core::conv_description_to_rawΒΆ
- Defined in File core.py
Function upref::core::conv_raw_to_descriptionΒΆ
- Defined in File core.py
Function upref::core::current_uprefΒΆ
- Defined in File core.py
Function upref::core::default_confΒΆ
- Defined in File core.py
Function upref::core::dict_mergeΒΆ
- Defined in File core.py
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. Themerge_dct
is merged intodct
.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 inmerge_dict
but notdct
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ΒΆ
- Defined in File core.py
Function upref::core::is_frozenΒΆ
- Defined in File core.py
Function upref::core::load_confΒΆ
- Defined in File core.py
Function upref::core::load_dataΒΆ
- Defined in File core.py
Function upref::core::remove_prefΒΆ
- Defined in File core.py
Function upref::core::save_confΒΆ
- Defined in File core.py
Function upref::core::save_dataΒΆ
- Defined in File core.py
Function upref::core::set_prefΒΆ
- Defined in File core.py
Function upref::core::upref_filenameΒΆ
- Defined in File core.py
Function upref::gui::__get_this_filenameΒΆ
- Defined in File gui.py
Function upref::gui::__get_this_folderΒΆ
- Defined in File gui.py
Function upref::gui::__mainΒΆ
- Defined in File gui.py
Function upref::gui::__set_logging_systemΒΆ
- Defined in File gui.py
Function upref::gui::get_dataΒΆ
- Defined in File gui.py
Function upref::gui::get_widgetΒΆ
- Defined in File gui.py
Function upref::gui::get_widget_styleΒΆ
- Defined in File gui.py
Function upref::gui::is_frozenΒΆ
- Defined in File gui.py
Function upref::gui::messageΒΆ
- Defined in File gui.py
Function upref::tty::__get_this_filenameΒΆ
- Defined in File tty.py
Function upref::tty::__get_this_folderΒΆ
- Defined in File tty.py
Function upref::tty::__mainΒΆ
- Defined in File tty.py
Function upref::tty::__set_logging_systemΒΆ
- Defined in File tty.py
Function upref::tty::get_dataΒΆ
- Defined in File tty.py
Function upref::tty::is_frozenΒΆ
- Defined in File tty.py
Function upref::tty::messageΒΆ
- Defined in File tty.py
VariablesΒΆ
Variable upref::__all__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
list upref.__all__= [ 'get_pref', 'set_pref', 'remove_pref', 'upref_filename', 'load_conf', 'load_data', 'save_data', 'current_upref',]
Variable upref::__author__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__author__ = "Florent Tournois"
Variable upref::__copyright__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__copyright__ = "Copyright 2018, Florent Tournois"
Variable upref::__credits__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
list upref.__credits__ = ["Arnaud Boidard, Bernard Migaud"]
Variable upref::__email__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__email__ = "florent.tournois@gmail.fr"
Variable upref::__license__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__license__ = "MIT"
Variable upref::__maintainer__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__maintainer__ = "Florent Tournois"
Variable upref::__status__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__status__ = "Production"
Variable upref::__version__ΒΆ
- Defined in File __init__.py
Variable DocumentationΒΆ
-
string upref.__version__ = '.'.join(str(c) for c in __version_info__)
Variable upref::core::__DEFAULT_CONF_FILENAME__ΒΆ
- Defined in File core.py
Variable DocumentationΒΆ
-
string upref.core.__DEFAULT_CONF_FILENAME__ = "default.conf"
The filename of the default configuration.
Variable upref::core::__EXT_FILENAME__ΒΆ
- Defined in File core.py
Variable DocumentationΒΆ
-
string upref.core.__EXT_FILENAME__ = ".conf"
The filename of the default configuration.
Variable upref::core::__UPREF_FOLDER__ΒΆ
- Defined in File core.py
Variable DocumentationΒΆ
-
string upref.core.__UPREF_FOLDER__ = ".upref"
The filename of the default configuration.
Variable upref::gui::__all__ΒΆ
- Defined in File gui.py
Variable DocumentationΒΆ
-
list upref.gui.__all__ = ['get_data']
Variable upref::tty::__all__ΒΆ
- Defined in File tty.py
Variable DocumentationΒΆ
-
list upref.tty.__all__ = ['get_data']
Variable upref::version::__release_date__ΒΆ
- Defined in File version.py
Variable DocumentationΒΆ
-
string upref.version.__release_date__ = '2019-09-26'
Variable upref::version::__version_info__ΒΆ
- Defined in File version.py
Variable DocumentationΒΆ
-
tuple upref.version.__version_info__ = (1, 0, 13)
Class HierarchyΒΆ
-
- Namespace upref
- Namespace upref::gui
- Class PrefDialog
- Namespace upref::gui
- Namespace upref
File HierarchyΒΆ
-
- Directory upref
- File __init__.py
- File core.py
- File gui.py
- File tty.py
- File version.py
- Directory upref