PyXMake Developer Guide  1.0
PyXMake
PyXMake.Tools.Utility Namespace Reference

Module of basic functions. More...

Classes

class  ChangedWorkingDirectory
 Class to create 2to3 compatible pickling dictionary. More...
 
class  GetDataFromPickle
 Class to create 2to3 compatible pickling dictionary. More...
 
class  UpdateZIP
 Class to create 2to3 compatible pickling dictionary. More...
 

Functions

def TemporaryDirectory (default=None)
 
def ConsoleRedirect (to=os.devnull, stdout=None)
 
def MergedConsoleRedirect (f)
 
def FileOutput (FileName)
 
def GetPyXMakePath ()
 
def GetPlatform ()
 
def GetArchitecture ()
 
def GetTemporaryFileName (arg=None, filename="Temp", extension=".cpd", kwargs)
 
def GetIterableAsList (Iterable)
 
def IsNotEmpty (s)
 
def AsDrive (s, sep=os.path.sep)
 
def Popen (command, verbosity)
 
def SSHPopen (ssh_client, command, verbosity)
 
def ConcatenateFiles (filename, files, source=os.getcwd(), ending='')
 
def ReplaceTextinFile (filename, outname, replace, inend='', outend='', source=os.getcwd())
 
def DeleteFilesbyEnding (identifier)
 
def AddFunctionToObject (_func, _obj)
 
def PrepareObjectforPickling (_obj)
 
def RecoverDictionaryfromPickling (_dict)
 
def PathLeaf (path)
 
def ArbitraryFlattening (container)
 
def FileWalk (source, path=os.getcwd())
 
def PathWalk (path, exclude=False, startswith=None, endswith=None, contains=None)
 
def ObjectWalk (obj, path=(), memo=None)
 

Detailed Description

Module of basic functions.

Classes and functions defined for convenience.

@note: PyCODAC module                   
Created on 15.07.2016    

@version:  1.0    
----------------------------------------------------------------------------------------------
@requires:
      - 

@change: 
      -    
  
@author: garb_ma                                                     [DLR-FA,STM Braunschweig]
----------------------------------------------------------------------------------------------
Author
Marc Garbade
Date
15.07.2017
Notes/Changes
  • Added documentation // mg 29.03.2018

Function Documentation

◆ AddFunctionToObject()

def PyXMake.Tools.Utility.AddFunctionToObject (   _func,
  _obj 
)
Bind a function to an existing object.

Definition at line 447 of file Utility.py.

◆ ArbitraryFlattening()

def PyXMake.Tools.Utility.ArbitraryFlattening (   container)
Restore the original dictionary by converting python defaults to their 
numpy equivalents if required  (2to3 compatible).

Definition at line 494 of file Utility.py.

◆ AsDrive()

def PyXMake.Tools.Utility.AsDrive (   s,
  sep = os.path.sep 
)
Return s as drive to start an absolute path with path.join(...).

Definition at line 346 of file Utility.py.

◆ ConcatenateFiles()

def PyXMake.Tools.Utility.ConcatenateFiles (   filename,
  files,
  source = os.getcwd(),
  ending = '' 
)
Concatenate all files into one.

Definition at line 405 of file Utility.py.

◆ ConsoleRedirect()

def PyXMake.Tools.Utility.ConsoleRedirect (   to = os.devnull,
  stdout = None 
)
Redirect console output to a given file.

Definition at line 209 of file Utility.py.

◆ DeleteFilesbyEnding()

def PyXMake.Tools.Utility.DeleteFilesbyEnding (   identifier)
Delete all files from workspace

@author: Marc Garbade, 26.02.2018

@param: identifier: A tuple specifying the files to remove.
@type: Tuple

Definition at line 434 of file Utility.py.

◆ FileOutput()

def PyXMake.Tools.Utility.FileOutput (   FileName)
Redirect outputs to a given file.

Definition at line 276 of file Utility.py.

◆ FileWalk()

def PyXMake.Tools.Utility.FileWalk (   source,
  path = os.getcwd() 
)
Walk recursively through path. Check if all files listed in source are present. 
If True, return them. If False, return all files present in the given path.

Definition at line 506 of file Utility.py.

◆ GetArchitecture()

def PyXMake.Tools.Utility.GetArchitecture ( )
Get the underlying machine architecture. Returns either x86 or x64 which corresponds to 
32 or 64 bit systems.

Definition at line 303 of file Utility.py.

◆ GetIterableAsList()

def PyXMake.Tools.Utility.GetIterableAsList (   Iterable)
Walk through an iterable input set and store the results in a list.

Definition at line 331 of file Utility.py.

◆ GetPlatform()

def PyXMake.Tools.Utility.GetPlatform ( )
Get the underlying machine platform in lower cases.

Definition at line 297 of file Utility.py.

◆ GetPyXMakePath()

def PyXMake.Tools.Utility.GetPyXMakePath ( )
Get the PyXMake path from *__init__.

Definition at line 290 of file Utility.py.

◆ GetTemporaryFileName()

def PyXMake.Tools.Utility.GetTemporaryFileName (   arg = None,
  filename = "Temp",
  extension = ".cpd",
  kwargs 
)
Create a temporary file name with extension *.cpd by default. Optional argument: Seed for random number generation.

Definition at line 314 of file Utility.py.

◆ IsNotEmpty()

def PyXMake.Tools.Utility.IsNotEmpty (   s)
Check whether a string is empty and/or not given. Returns True otherwise.

Definition at line 340 of file Utility.py.

◆ MergedConsoleRedirect()

def PyXMake.Tools.Utility.MergedConsoleRedirect (   f)
Redirect all console outputs to a given stream

Definition at line 268 of file Utility.py.

◆ ObjectWalk()

def PyXMake.Tools.Utility.ObjectWalk (   obj,
  path = (),
  memo = None 
)
Walk recursively through nested python objects.

@author: Yaniv Aknin, 13.12.2011

@param: obj, path, memo
@type: object, list, boolean

Definition at line 558 of file Utility.py.

◆ PathLeaf()

def PyXMake.Tools.Utility.PathLeaf (   path)
Return the last item of an arbitrary path (its leaf).

Definition at line 487 of file Utility.py.

◆ PathWalk()

def PyXMake.Tools.Utility.PathWalk (   path,
  exclude = False,
  startswith = None,
  endswith = None,
  contains = None 
)
Walk recursively through path. Exclude both folders and files if requested. 

Definition at line 531 of file Utility.py.

◆ Popen()

def PyXMake.Tools.Utility.Popen (   command,
  verbosity 
)
Run command line string "command" in a separate subprocess. 
Show output in current console window in dependence of verbosity level:
- 0 --> Quiet
- 1 --> Only show errors
- 2 --> Show every command line output.

@author: garb_ma    
@param: command, verbosity
@type: string, integer

Definition at line 358 of file Utility.py.

◆ PrepareObjectforPickling()

def PyXMake.Tools.Utility.PrepareObjectforPickling (   _obj)
Prepare a object for pickling and convert all numpy  
arrays to python defaults (2to3 compatible). 

Definition at line 453 of file Utility.py.

◆ RecoverDictionaryfromPickling()

def PyXMake.Tools.Utility.RecoverDictionaryfromPickling (   _dict)
Restore the original dictionary by converting python defaults to their 
numpy equivalents if required  (2to3 compatible).

Definition at line 469 of file Utility.py.

◆ ReplaceTextinFile()

def PyXMake.Tools.Utility.ReplaceTextinFile (   filename,
  outname,
  replace,
  inend = '',
  outend = '',
  source = os.getcwd() 
)
Replace all occurrences of replace in filename.

Definition at line 422 of file Utility.py.

◆ SSHPopen()

def PyXMake.Tools.Utility.SSHPopen (   ssh_client,
  command,
  verbosity 
)
Run command line string "command" in a separate SSH client process. 
Show output in current console window in dependence of verbosity level:
- 0 --> Quiet
- 1 --> Only show errors
- 2 --> Show every command line output.

@author: garb_ma    
@param: command, verbosity
@type: string, integer

Definition at line 380 of file Utility.py.

◆ TemporaryDirectory()

def PyXMake.Tools.Utility.TemporaryDirectory (   default = None)
Create a temporary dictionary for use with the "with" statement. Its content is deleted after execution.

@param: default
@type: default: string

Definition at line 181 of file Utility.py.