home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / util / primitives / misc.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  2.0 KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import subprocess
  5. import calendar
  6. import datetime
  7. import time
  8.  
  9. def clamp(number, min_ = None, max_ = None):
  10.     if None not in (min_, max_) and min_ > max_:
  11.         max_ = min_
  12.     
  13.     if min_ is not None:
  14.         number = max(min_, number)
  15.     
  16.     if max_ is not None:
  17.         number = min(max_, number)
  18.     
  19.     return number
  20.  
  21.  
  22. def backtick(cmd, check_retcode = True):
  23.     proc = subprocess.Popen(cmd.split(' '), stdout = subprocess.PIPE)
  24.     proc.wait()
  25.     if check_retcode and proc.returncode != 0:
  26.         raise Exception('subprocess returned nonzero: %s' % cmd)
  27.     proc.returncode != 0
  28.     return proc.stdout.read()
  29.  
  30.  
  31. class ysha(object):
  32.     h0 = 1732584193
  33.     h1 = 0xEFCDAB89L
  34.     h2 = 0x98BADCFEL
  35.     h3 = 271733878
  36.     h4 = 0xC3D2E1F0L
  37.  
  38.  
  39. def fromutc(t):
  40.     return datetime.datetime(*time.localtime(calendar.timegm(t.timetuple()))[:-2])
  41.  
  42.  
  43. def toutc(t):
  44.     return datetime.datetime(*time.gmtime(time.mktime(t.timetuple()))[:-2])
  45.  
  46.  
  47. class NonBool(object):
  48.     
  49.     def __nonzero__(self):
  50.         raise TypeError('NonBool cannot be bool()ed, use ==/is CONSTANT')
  51.  
  52.  
  53.