RRtoolbox.lib package¶
Subpackages¶
Submodules¶
RRtoolbox.lib.cache module¶
RRtoolbox.lib.config module¶
RRtoolbox.lib.descriptors module¶
RRtoolbox.lib.directory module¶
This module holds all path manipulation methods and a string concept called directory (referenced paths and strings)
designed to support config
and be used with session
.
keywords:¶
path: it can be to a folder or file or url if specified filename: the file name without its path filepath: the path to a file dirname: the path to a folder url: Universal Resource Locator
-
class
RRtoolbox.lib.directory.
Directory
[source]¶ Bases:
str
semi-mutable string representation of a inmutable string with support for path representations.
Parameters: - data – list, directory instance, dictionary or string.
- ispath – True to add support for paths.
- copy – when data is a directory if copy is True then this instance data is independent of the passed directory otherwise both directories are a reference to the same dictionary data but they are not the same object.
- kwargs – additional data to add in directory.
-
correctSTRBuiltin
()[source]¶ Decorate all the built-in functions of class directory.
Returns: built-in decorated function.
-
static
filterdata
(data, ispath=None, kwargs=None)[source]¶ Adequate data for dictionary creation.
Parameters: - data – any supported object.
- ispath – True to add support for paths.
- kwargs – additional data to add in directory.
Returns: dictionary
-
static
repr2list
(data, level=0)[source]¶ Converts the representation of a directory.repr to pickleable.
Parameters: data – directory.repr of the form [“string”,directory,…,directory.repr]. Returns: pickleable list.
-
static
repr2str
(data, ispath=True)[source]¶ Converts the representation of a directory.repr to string.
Parameters: data – directory.repr of the form [“string”,directory,…,directory.repr]. Returns: converted string.
-
update
(data=None)[source]¶ Return an updated copy with provided data.
Parameters: data – any supported object. If None return updated and referenced copy of itself. Returns: new directory referenced to itself.
-
class
RRtoolbox.lib.directory.
FileDirectory
[source]¶ Bases:
RRtoolbox.lib.directory.Directory
Saves contents of a file as with directories.
Parameters: - data – list, directory instance, dictionary or string.
- filename – name of file.
- path – path to folder where file is (it must finish in /).
- notes – optional description string
- kwargs – additional data to add in directory.
-
RRtoolbox.lib.directory.
changedir
(filepath, dirname, ext=True)[source]¶ Change path to file with dirname.
Parameters: - filepath – path to file.
- dirname – new path to replace in filepath.
- ext – True to keep extension of file if any.
Returns: directory object of changed path.
-
RRtoolbox.lib.directory.
checkDir
(dirname)[source]¶ checks if dirname exists.
Parameters: dirname – path to folder Returns: True if exits, False if not
-
RRtoolbox.lib.directory.
checkFile
(path)[source]¶ checks if filepath or filename exists.
Parameters: path – filepath or filename Returns: True if exits, False if not
-
RRtoolbox.lib.directory.
checkPath
(path)[source]¶ checks if path exists.
Parameters: path – path to folder or file. Returns: True if exits, False if not
-
RRtoolbox.lib.directory.
checkURL
(url)[source]¶ checks if url exists. :param url: path to url :return: True if exits, False if not
-
RRtoolbox.lib.directory.
correctPath
(path, relative)[source]¶ Get path corrected from its relative path or level index.
Parameters: - path – path or file name.
- relative – pattern or level in directory.
Returns: corrected path.
-
RRtoolbox.lib.directory.
correctSep
(path='/home/docs/checkouts/readthedocs.org/user_builds/rrtools/checkouts/latest/RRtoolbox/lib/directory.py', separator='/')[source]¶ Replaces the path separators by custom or OS standard separator.
Parameters: - path – relative or absolute path (str). Default is __file__ or module’s path.
- separator – desired separators, By default uses system separator (os.path.sep).
Returns: path with corrected separator.
-
RRtoolbox.lib.directory.
decoratePath
(relative, sep='/')[source]¶ Decorated path is controlled to give absolute path from relative path.
Parameters: - relative – int or path.
- sep – path separator
Returns: decorator
-
RRtoolbox.lib.directory.
getData
(path='/home/docs/checkouts/readthedocs.org/user_builds/rrtools/checkouts/latest/RRtoolbox/lib/directory.py')[source]¶ Get standard path from path.
Parameters: path – it can be to a folder or file. Default is __file__ or module’s path. Returns: [drive,dirname,filename,ext]. 1. drive or UNC (Universal Naming Convention) 2. dirname is path to folder. 3. filename is name of file. 4. ext is extension of file.
-
RRtoolbox.lib.directory.
getFileHandle
(path)[source]¶ Gets a file handle from url or disk file.
Parameters: path – filepath or url Returns: file object
-
RRtoolbox.lib.directory.
getFileSize
(path)[source]¶ Gets a size from url or disk file.
Parameters: path – filepath or url Returns: size in bytes
-
RRtoolbox.lib.directory.
getPath
(path='/home/docs/checkouts/readthedocs.org/user_builds/rrtools/checkouts/latest/RRtoolbox/lib/directory.py')[source]¶ Get standard path from path. It supports ~ as home directory.
Parameters: path – it can be to a folder or file. Default is __file__ or module’s path. If file exists it selects its folder. Returns: dirname (path to a folder) Note
It is the same as os.path.dirname(os.path.abspath(path)).
-
RRtoolbox.lib.directory.
getSep
(path, pattern='/\\')[source]¶ Get path separator or indicator.
Parameters: - path – relative or absolute path (str).
- pattern – guess characters to compare path (str).
Returns: sep (str).
Note
It is equivalent to os.path.sep but obtained from the given path and patterns.
-
RRtoolbox.lib.directory.
getShortenedPath
(path, comp)[source]¶ Path is controlled to give absolute path from relative path or integer.
Parameters: - path – absolute path (str).
- comp – pattern or relative path (str) or integer representing level of folder determined by the separator Ex. “/level 1/level 2/…/level N or -1”.
Returns: path before matched to comp Ex: “C://level 1//comp –> C://level 1”
Example:
>>> path = 'LEVEL1/LEVEL2/LEVEL3/LEVEL4/LEVEL5' >>> print getShortenedPath(path,-2) # minus two levels LEVEL1/LEVEL2/LEVEL3 >>> print getShortenedPath(path,2) # until three levels LEVEL1/LEVEL2 >>> print getShortenedPath(path,'LEVEL1/LEVEL2/LEVEL3/') LEVEL1/LEVEL2/LEVEL3/ >>> print getShortenedPath(path,'LEVEL4/REPLACE5/NEWLEVEL') LEVEL1/LEVEL2/LEVEL3/LEVEL4/REPLACE5/NEWLEVEL >>> print getShortenedPath(path,'../../SHOULD_BE_LEVEL4') LEVEL1/LEVEL2/LEVEL3/SHOULD_BE_LEVEL4
-
RRtoolbox.lib.directory.
getSplitted
(path='/home/docs/checkouts/readthedocs.org/user_builds/rrtools/checkouts/latest/RRtoolbox/lib/directory.py')[source]¶ Splits a file path by its separators.
Parameters: path – it can be to a folder or file. Default is __file__ or module’s path. Returns: splitted path.
-
RRtoolbox.lib.directory.
increment_if_exits
(path, add='_{num}', force=None)[source]¶ Generates new name if it exits.
Parameters: - path – absolute path or filename
- add – if fn exists add pattern
- force – (None) force existent files even if they don’t. if True treats fn as existent or if it is a list it treats names from the list as existent names.
Returns: un-existent fn
-
RRtoolbox.lib.directory.
joinPath
(absolute, relative)[source]¶ Joins an absolute path to a relative path.
Parameters: - absolute – directory or path.
- relative – directory or path.
Returns: joined path.
Note
It is equivalent to os.path.join but works with directories.
-
RRtoolbox.lib.directory.
mkPath
(path)[source]¶ Make path (i.e. creating folder) for filepath.
Parameters: path – path to nonexistent folder or file. Returns: created path.
-
RRtoolbox.lib.directory.
quickOps
(path, comp)[source]¶ (IN DEVELOPMENT) make quick matching operations in path.
Parameters: - path – path to folder
- comp – pattern
Returns: Requirements:
path = 'LEVEL1/LEVEL2/LEVEL3/LEVEL4/LEVEL5' print quickOps(path,'../ROOT/../LEVEL1/../LEVEL2/LEVEL3/../../LEVEL4') 'LEVEL4' print quickOps(path,'ROOT/../LEVEL1/LEVEL2/../../LEVEL4') 'LEVEL3/LEVEL4' print quickOps(path,'../LEVEL2/../') 'LEVEL1/LEVEL3/LEVEL4/LEVEL5' print quickOps(path,'../LEVEL2/..') 'LEVEL1/LEVEL3/LEVEL4/LEVEL5/' print quickOps(path,'LEVEL2/../../LEVEL4/') 'LEVEL2/LEVEL3/LEVEL4/' print quickOps(path,'ROOT/../LEVEL2/../../LEVEL4') 'ROOT/LEVEL3/LEVEL4' print quickOps(path,'LEVEL-1/../NEW7/LEVEL8') 'LEVEL-1/LEVEL1/LEVEL2/LEVEL3/LEVEL4/LEVEL5/NEW7/LEVEL8' print
-
RRtoolbox.lib.directory.
resource_path
(relative_path='')[source]¶ Get absolute path to resource, works for dev and for PyInstaller
-
RRtoolbox.lib.directory.
rmFile
(filepath)[source]¶ Remove file.
Parameters: filepath – path to file. Returns: None
-
RRtoolbox.lib.directory.
rmPath
(path, ignore_errors=False, onerror=None)[source]¶ Remove path from path.
Parameters: path – path to nonexistent folder or file. Returns: None See also
shutil.rmtree
-
RRtoolbox.lib.directory.
strdifference
(s1, s2)[source]¶ Get string differences.
Parameters: - s1 – string 1
- s2 – string 2
Returns: (splitted string 1, splitted string 2, index). A splitted string is a list with the string parts. Index is a list containing the indexes of different parts of the two splitted strings.
RRtoolbox.lib.image module¶
RRtoolbox.lib.inspector module¶
This module is an all purpose intended for debugging, tracking, auto-documenting and self-introspecting the package
Made by Davtoh. Powered partially by pycallgraph. Dependent project: https://github.com/gak/pycallgraph/#python-call-graph
-
class
RRtoolbox.lib.inspector.
GraphTrace
(output=None, config=None)[source]¶ Bases:
pycallgraph.pycallgraph.PyCallGraph
-
source
¶
-
-
class
RRtoolbox.lib.inspector.
GraphTraceOutput
(source=None, saveflag=True, label='', **kwargs)[source]¶ Bases:
pycallgraph.output.graphviz.GraphvizOutput
-
class
RRtoolbox.lib.inspector.
Logger
(**kwargs)[source]¶ Bases:
future.types.newobject.newobject
Logger for decorated functions. Holds important information of an instanced object and can be used with @trace decorator for traceback purposes.
Parameters: - func – object reference.
- funcname – object name.
- inputs – inputs pass to the object.
- outputs – outputs given by the object execution.
- time – initial time of execution.
- exectime – time of execution in seconds.
- writer – writer function where messages are passed.
- eventHandle – event function where object is passed when Logger.broadcast() is called.
- msg_report – message format to use in reports.
- msg_no_executed – massage format to pass to writer when object has not been executed and Logger.report() is called.
- msg_executed – massage format to use when object is executed and Logger.broadcast() is called.
-
Time_
¶ returns formated time (str)
-
Type_
¶ returns type name (str)
-
eventHandle
= None¶
-
file
= <open file '<stdout>', mode 'w'>¶
-
tracer
¶
-
class
RRtoolbox.lib.inspector.
Syncronous
(outputs, config)[source]¶ Bases:
pycallgraph.tracer.SyncronousTracer
RRtoolbox.lib.plotter module¶
RRtoolbox.lib.root module¶
RRtoolbox.lib.serverServices module¶
RRtoolbox.lib.session module¶
Module contents¶
This module contains core-like, too-much-used and too-much-referenced modules