utils (version 0.0.6)
index
utils.py

This tools run scripts and display the result in a Web Interface.
 
This file implement some tools for WebScripts server
and scripts (Logs, Namespace for configuration, ...).

 
Modules
       
json
locale
logging
ntpath
platform
win32evtlog

 
Classes
       
types.SimpleNamespace(builtins.object)
DefaultNamespace
_Logs(builtins.object)
WindowsLogs

 
class DefaultNamespace(types.SimpleNamespace)
    DefaultNamespace(required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
 
This class build simple namespace with default
attributs.
 
 
Method resolution order:
DefaultNamespace
types.SimpleNamespace
builtins.object

Methods defined here:
__getitem__(self, key: str)
Compatibility with dict.
__init__(self, required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
Initialize self.  See help(type(self)) for accurate signature.
build_types(self) -> None
This function build type from configuration values.
check_required(self) -> None
This function checks required attributes
if one of required attributes is missing this
function raise MissingAttributesError.
export_as_json(self, name: str = None) -> None
This function export namespace values (useful for debugging).
get(self, key: str, default=None)
Compatibility with dict.
get_dict(self) -> None
This function return a dict of attributes.
get_missings(self) -> List[str]
This function checks required attributes
and return a List[str] of missing required attributes.
get_unexpecteds(self, log: bool = True) -> List[str]
This function return a List[str] of
all attributes not in optional and
required attributes.
 
If log argument is True a Warning log message is
write for all unexpected attributes.
set_defaults(self) -> None
This function set defaults attribut with defaults values.
update(self, **kwargs)
This function add/update attributes with **kwargs arguments.

Class methods defined here:
default_build(**kwargs) -> ~DefaultNamespace from builtins.type
Default build for DefaultNamespace (set defaults, add values, check
requirements and unexpected values and build types).

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from types.SimpleNamespace:
__delattr__(self, name, /)
Implement delattr(self, name).
__eq__(self, value, /)
Return self==value.
__ge__(self, value, /)
Return self>=value.
__getattribute__(self, name, /)
Return getattr(self, name).
__gt__(self, value, /)
Return self>value.
__le__(self, value, /)
Return self<=value.
__lt__(self, value, /)
Return self<value.
__ne__(self, value, /)
Return self!=value.
__reduce__(...)
Return state information for pickling
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).

Static methods inherited from types.SimpleNamespace:
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.

Data descriptors inherited from types.SimpleNamespace:
__dict__

Data and other attributes inherited from types.SimpleNamespace:
__hash__ = None

 
Logs = class WindowsLogs(_Logs)
    This class log on Windows.
 
 
Method resolution order:
WindowsLogs
_Logs
builtins.object

Methods defined here:
critical(log: str) -> None
This function log criticals on Windows.
debug(log: str) -> None
This function log debugs on Windows.
error(log: str) -> None
This function log errors on Windows.
info(log: str) -> None
This function log infos on Windows.
warning(log: str) -> None
This function log warnings on Windows.

Data and other attributes defined here:
__annotations__ = {'app': <class 'str'>}
app = 'WebScripts'

Methods inherited from _Logs:
config(*args, **kwargs)
This function config ROOT logger.
exception(log: str) -> None
This function implement basic python exception (error) logs for WebScripts.
trace(log: str) -> None
This function implement trace logs for WebScripts.

Data descriptors inherited from _Logs:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from _Logs:
console = <Logger WebScripts.console (WARNING)>
file = <Logger WebScripts.file (WARNING)>
log_critical = <Logger WebScripts.critical (WARNING)>
log_debug = <Logger WebScripts.debug (WARNING)>
log_error = <Logger WebScripts.error (WARNING)>
log_info = <Logger WebScripts.info (WARNING)>
log_trace = <Logger WebScripts.trace (WARNING)>
log_warning = <Logger WebScripts.warning (WARNING)>

 
Functions
       
get_encodings()
This function returns the probable encodings.
get_file_content(file_path, *args, **kwargs) -> ~StrOrBytes
This function return the file content.
get_ini_dict(filename: str) -> Dict[str, Dict[str, str]]
This function return a dict from ini filename.
get_ip(environ: os._Environ) -> str
This function return the real IP.
get_real_path(file_path: str) -> str
This function return the real path for files.
log_trace(function: function)
This decorator trace functions (start and end)

 
Data
        __all__ = ['Logs', 'DefaultNamespace', 'log_trace', 'get_ip', 'get_file_content', 'get_real_path', 'get_encodings', 'get_ini_dict', 'server_path']
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nWebScripts Copyright (C) 2021 Maurice Lambert...ome to redistribute it\nunder certain conditions.\n'
__description__ = 'This tools run scripts and display the result in...scripts (Logs, Namespace for configuration, ...).'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/WebScripts'
server_path = r'C:\Users\CSU1\Documents\dev\modules\WebScripts\WebScripts'

 
Author
        Maurice Lambert