astwro.utils Module

astwro.utils.tmpdir(use_existing=None, prefix='astwro_tmp_', base_dir=None)[source]

Creates instance of TmpDir which creates and keeps lifetime of temporary directory :param str use_existing: If provided, instance will point to that directory and not delete it on destruct :param str prefix: Prefix for temporary dir :param str base_dir: Where to crate tem dir, in None system default is used :rtype: TmpDir

astwro.utils.cyclefile(path, basename, extension='', create_symlinks=True, symlink_suffix='_last', auto_close=True)[source]

Creates CycleFile which can create series of files with names containing counter, with symlink to newest one :param str path: patch to the file, absolute or relative, can be empty string ‘’ for current directory :param str basename: first part of file name before counter :param str extension: part of filename after counter :param str create_symlinks: whether to create symlink to newest file :param str symlink_suffix: part of suffix filename in place of counter value :param bool auto_close: close prev files on next_file nad destruction :rtype: CycleFile

astwro.utils.progressbar(total=100, prefix='', suffix='', decimals=1, bar_length=20, step=0)[source]

Creates Text console progress bar object, print progress using print_progress() method :param int total: total iterations (Int) :param str prefix: prefix string (Str) :param str suffix: suffix string (Str) :param int decimals: positive number of decimals in percent complete (Int) :param int bar_length: character length of bar (Int) :param int step: allows automatic progress increasing on parameter-less print_progress call :rtype:ProgressBar

Astwro tools are python scripts, ready to use from command line.

TmpDir

class astwro.utils.TmpDir.TmpDir(use_existing=None, prefix='astwro_tmp_', base_dir=None)[source]

instances of TmpDir keeps track and lifetime of temporary directory

Parameters:
  • use_existing (str) – If provided, instance will point to that directory and not delete it on destruct
  • prefix (str) – Prefix for temporary dir
  • base_dir (str) – Where to crate tem dir, in None system default is used

ProgressBar

Greenstick’s code form http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console encapsulated into class

CycleFile

class astwro.utils.CycleFile.CycleFile(path, basename, extension='', create_symlinks=True, symlink_suffix='_last', auto_close=True)[source]

Creates series of files with names containing counter, with symlink to newest one

Parameters:
  • auto_close (bool) –
  • path (str) – patch to the file, absolute or relative, can be empty string ‘’ for current directory
  • basename (str) – first part of file name before counter
  • extension (str) – part of filename after counter
  • create_symlinks (str) – whether to create symlink to newest file
  • symlink_suffix (str) – part of suffix filename in place of counter value
  • auto_close – close prev files on next_file nad destruction