utils
index
/home/dlink/vlib/vlib/utils.py

 
Modules
       
os

 
Classes
       
exceptions.Exception(exceptions.BaseException)
MissingArguments
Str2DateError

 
class MissingArguments(exceptions.Exception)
    
Method resolution order:
MissingArguments
exceptions.Exception
exceptions.BaseException
__builtin__.object

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

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class Str2DateError(exceptions.Exception)
    
Method resolution order:
Str2DateError
exceptions.Exception
exceptions.BaseException
__builtin__.object

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

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
Functions
       
any_in(items, thing)
console_width()
Get the width of the console screen (if any).
echoif(switch)
Decorator - calls echoized
eq.:
  @echoif(DEBUG_CALLSTACK)
  class OrderPricing(objec):
     ...
echoized(func_or_cls)
Decorator
Echos a function's signature prior to evaluating it, of does the
 same for all methods of a class. 
 
 ISSUES:
   If used on a single method of a class, it fails to identify the
   arg names, and self is not distinguished from other args.
   
   (or in conjunction with @cached)
   
 eq.:
   op = OrderPricing()
   op = echoized(OrderPricing)()
 
   e = Editions(nid=nid)
   e = echoized(Editions)(nid=nid)
format_date(d)
Given a datetime object
Return a string in the form of "mm/dd/yyyy"
format_datetime(d, with_seconds=False, format=None)
Given a datetime object
Return formated String as follows:
 
   Format: None   : 11/22/2013 01:46[:00] am
           ISO8601: 2013-11-21T01:46:00-05:00 (EST)
formatdict(d, width=162, indent=0, keylen=0, color=False)
Recursively format contents of dictionaries in sorted tabular order.
Optionally a certain width, indented, and/or a specific key length.
 
>>> utils.formatdict(batch_item)
        active: 1
      batch_id: 3250
      on_press: None
      order_id: 2007372
     page_list: None
           qty: 2
  removed_date: None
lazyproperty(fn)
A decorator that computes a property variable and then caches.
http://stackoverflow.com/questions/3012421/python-lazy-property-decorator
list2csv(data)
Given a Table of data as a LIST of LISTs
Return in CSV format as a STR
pretty(X)
Return X formated nicely for the console
rev_move(src, dst, max_revs=20, copy=False, debug=False)
Rev destination file, if it exists, before moving src to dst.
Multiple calls to the same dst file might create this set of files:
      tanner
      tanner_1
      tanner_2
      tanner_3
shift(alist)
Shift the first element off of an array, and return it
str2date(s)
Convert str in the form of "2010-11-11" to a
datetime.date Object
str2datetime(s, format='%Y-%m-%d %H:%M:%S')
Convert str in the form of "2010-11-11 17:39:52" or
                           "2010-11-11"          to a
datetime.datetime Object
table2csv(data)
Give a LIST or TUPLE
Return: A CSV table as STRING or the input data if not LIST or TUPLE
uniqueId(with_millisec=False)
Return system time to the millisec as set of numbers
valid_email(email)
Given an email address
Return whether it is in valid format as BOOLEAN
validate_num_args(s, num_args, args)
word_wrap(string, width, ind1=0, ind2=0)
Wrap long lines of text.
Prefer spaces or non-alpha-numeric break points.
 
     ind1 = initial indentation
     ind2 = hanging indentation

 
Data
        BG_COLORS = {'blue': '\x1b[44m', 'gray': '\x1b[47m', 'green'...b[46m', 'magenta': '\x1b[45m', 'red': '\x1b[41m'}
COLORS = {'reset': '\x1b[0m', 'darkyellow': '\x1b[0;33m',...tred': '\x1b[31;1m', 'darkmagenta': '\x1b[0;35m'}
STYLES = {'bold': '\x1b[1m', 'blink': '\x1b[5m', 'underli...m', 'reverse': '\x1b[7m', 'concealed': '\x1b[8m'}
c = 'darkmagenta'
digits = '0123456789'
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'