Welcome to appcore’s documentation!

Contents:

Console namespace

Terminal utils

This is a backport of shutil.get_terminal_size from Python 3.3. The original implementation is in C, but here we use the ctypes and fcntl modules to create a pure Python version of os.get_terminal_size.

console.get_terminal_size.get_terminal_size(fallback=(80, 24))[source]

Get the size of the terminal window. For each of the two dimensions, the environment variable, COLUMNS and LINES respectively, is checked. If the variable is defined and the value is a positive integer, it is used. When COLUMNS or LINES is not defined, which is the common case, the terminal connected to sys.__stdout__ is queried by invoking os.get_terminal_size. If the terminal size cannot be successfully queried, either because the system doesn’t support querying, or because we are not connected to a terminal, the value given in fallback parameter is used. Fallback defaults to (80, 24) which is the default size used by many terminal emulators. The value returned is a named tuple of type os.terminal_size.

Progress Bar Object

class console.progress_bar.ProgressBarFormat[source]
class console.progress_bar.CharacterStyles[source]
class console.progress_bar.ProgressBarOptions(character_style=(' ', '='), progress_format='{begin_line}{text} {percents_done:>3}% [{filled}{empty}] {value}/{max} {items_per_sec} i/s')[source]
class console.progress_bar.ProgressBarStatus[source]
class console.progress_bar.ProgressBar(text, width, options=<console.progress_bar.ProgressBarOptions object>)[source]
progress(value, new_status=None)[source]

:type value int :type new_status str

progress_inc(step=1, new_status=None)[source]

:type step int :type new_status str

start(max_val)[source]

:arg max_val Maximum value :type max_val int

stop(hide_progress=False, new_status=None)[source]

:arg hide_progress Hide progress bar :type hide_progress bool :type new_status str

Core namespace

Configuration object

class core.config.CommandLineAST(args, out_tree)[source]
parse()[source]

Parse command line to out tree

class core.config.Configuration(in_memory=False, config_location=None, config_name=None)[source]
exists(path)[source]

Check for property existence :param path: path to the property with name including :return:

get(path, default=None, check_type=None, module=None)[source]

Get option property

Parameters:
  • path – full path to the property with name
  • default – default value if original is not present
  • check_type – cast param to passed type, if fail, default will returned
  • module – get property from module name
Returns:

get_module_config(name)[source]

Return module configuration loaded from separate file or None

load()[source]

Load application configuration

Logger object

class core.logger.aLogger[source]

Singleton object

class core.singlobj.Singleton(decorated)[source]
get_instance(*args, **kwargs)[source]
Returns instance of the class if any present, or create new one
Parameters:
  • args – arguments for class constructor
  • kwargs – kwargs for class constructor
Returns:

instance of the class

class core.singlobj.SingletonObject[source]

Net namespace

CURL Object

net.curl.curl(url, params=None, auth=None, req_type='GET', data=None, headers=None, timeout=None, use_gzip=True, use_stream=False)[source]

Make request to web resource

Parameters:
  • url – Url to endpoint
  • params – list of params after ”?”
  • auth – authorization tokens
  • req_type – column_type of the request
  • data – data which need to be posted
  • headers – headers which would be posted with request
  • timeout – Request timeout
  • use_gzip – Accept gzip and deflate response from the server
  • use_stream – Do not parse content of response ans stream it via raw property

:return Response object

:type url str :type params dict :type auth CURLAuth :type req_type str :type headers dict :type timeout int :type use_gzip bool :type use_stream bool :rtype CURLResponse

class net.curl.CURLResponse(director_open_result, is_stream=False)[source]
code
Returns:HTTP Request Response code
content
Returns:Text content of the response (unzipped and decoded)
from_json()[source]
Returns:Return parsed json object from the response, if possible. If operation fail, will be returned None

:rtype dict

headers
Returns:HTTP Response Headers
raw
Returns:Raw content of the response
class net.curl.CURLAuth(user, password, force=False, headers=None)[source]

Types namespace

Config Object

class appcore.types.config.ConfigObject(serialized_obj=None, **kwargs)[source]
clean()[source]

Replace not de-serialized types with none :return:

deserialize(d)[source]

:type d dict

serialize()[source]
Return type:dict

Utils namespace

Import Tools

String Utils

utils.string_utils.safe_format(s, **kwargs)[source]

:type s str

utils.string_utils.safe_format_sh(s, **kwargs)[source]

:type s str :type kwargs dict

Indices and tables