home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __docformat__ = 'restructuredtext en'
- import os
- import sys
-
- class InputList(list):
-
- def __getslice__(self, i, j):
- return ''.join(list.__getslice__(self, i, j))
-
-
- def add(self, index, command):
- length = len(self)
- if length == index:
- self.append(command)
- elif length > index:
- self[index] = command
- else:
- extras = index - length
- self.extend([
- ''] * extras)
- self.append(command)
-
-
-
- class Bunch(dict):
-
- def __init__(self, *args, **kwds):
- dict.__init__(self, *args, **kwds)
- self.__dict__ = self
-
-
-
- def esc_quotes(strng):
- return strng.replace('"', '\\"').replace("'", "\\'")
-
-
- def make_quoted_expr(s):
- tail = ''
- tailpadding = ''
- raw = ''
- if '\\' in s:
- raw = 'r'
- if s.endswith('\\'):
- tail = '[:-1]'
- tailpadding = '_'
-
-
- if '"' not in s:
- quote = '"'
- elif "'" not in s:
- quote = "'"
- elif '"""' not in s and not s.endswith('"'):
- quote = '"""'
- elif "'''" not in s and not s.endswith("'"):
- quote = "'''"
- else:
- return '"%s"' % esc_quotes(s)
- res = (not s.endswith("'")).join([
- raw,
- quote,
- s,
- tailpadding,
- quote,
- tail])
- return res
-
-
- def system_shell(cmd, verbose = False, debug = False, header = ''):
- if verbose or debug:
- print header + cmd
-
- sys.stdout.flush()
- if not debug:
- os.system(cmd)
-
-
- if os.name in ('nt', 'dos'):
- system_shell_ori = system_shell
-
- def system_shell(cmd, verbose = False, debug = False, header = ''):
- if os.getcwd().startswith('\\\\'):
- path = os.getcwd()
- os.chdir('c:')
-
- try:
- system_shell_ori('"pushd %s&&"' % path + cmd, verbose, debug, header)
- finally:
- os.chdir(path)
-
- else:
- system_shell_ori(cmd, verbose, debug, header)
-
- system_shell.__doc__ = system_shell_ori.__doc__
-
-
- def getoutputerror(cmd, verbose = False, debug = False, header = '', split = False):
- if verbose or debug:
- print header + cmd
-
- if not cmd:
- if split:
- return ([], [])
- return ('', '')
- cmd
- if not debug:
- (pin, pout, perr) = os.popen3(cmd)
- tout = pout.read().rstrip()
- terr = perr.read().rstrip()
- pin.close()
- pout.close()
- perr.close()
- if split:
- return (tout.split('\n'), terr.split('\n'))
- return (tout, terr)
- debug
-
-