rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
content = open(filename).read()
content = open(filename,'rb').read()
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run)
The QUESTION strign ca be at most 255 characters.
The QUESTION string can be at most 255 characters.
def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Retur...
if os.name == "posix" and os.path.basename(sys.path[-1]) == "Modules":
if (os.name == "posix" and sys.path and os.path.basename(sys.path[-1]) == "Modules"):
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir)
return "lib%s%s" %( libname, self._static_lib_ext )
return "%s%s" %( libname, self._static_lib_ext )
def library_filename (self, libname): """Return the static library filename corresponding to the specified library name.""" return "lib%s%s" %( libname, self._static_lib_ext )
return "lib%s%s" %( libname, self._shared_lib_ext )
return "%s%s" %( libname, self._shared_lib_ext )
def shared_library_filename (self, libname): """Return the shared library filename corresponding to the specified library name.""" return "lib%s%s" %( libname, self._shared_lib_ext )
check_syntax("def f(): global time; import ")
check_syntax("def f(): global time; import ")
time.tzname = ("PDT", "PDT")
time.tzname = (tz_name, tz_name)
def test_bad_timezone(self): # Explicitly test possibility of bad timezone; # when time.tzname[0] == time.tzname[1] and time.daylight if sys.platform == "mac": return #MacOS9 has severely broken timezone support. try: original_tzname = time.tzname original_daylight = time.daylight time.tzname = ("PDT", "PDT") time.dayl...
tz_value = _strptime.strptime("PDT", "%Z")[8]
tz_value = _strptime.strptime(tz_name, "%Z")[8]
def test_bad_timezone(self): # Explicitly test possibility of bad timezone; # when time.tzname[0] == time.tzname[1] and time.daylight if sys.platform == "mac": return #MacOS9 has severely broken timezone support. try: original_tzname = time.tzname original_daylight = time.daylight time.tzname = ("PDT", "PDT") time.dayl...
if os.environ.get('TERM') in ('dumb', 'emacs'): return plainpager
def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.get('TERM') in ('dumb', 'emacs'): return plainpager if 'PAGER' in os.environ: if sys.platform == 'wi...
def __init__(self, completekey='tab'):
def __init__(self, completekey='tab', stdin=None, stdout=None):
def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework.
The optional argument is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. """
The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, ...
def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework.
print self.intro
self.stdout.write(str(self.intro)+"\n")
def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.
sys.stdout.write(self.prompt) sys.stdout.flush() line = sys.stdin.readline()
self.stdout.write(self.prompt) self.stdout.flush() line = self.stdin.readline()
def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.
print '*** Unknown syntax:', line
self.stdout.write('*** Unknown syntax: %s\n'%line)
def default(self, line): """Called on an input line when the command prefix is not recognized.
print doc
self.stdout.write("%s\n"%str(doc))
def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] he...
print self.nohelp % (arg,)
self.stdout.write("%s\n"%str(self.nohelp % (arg,)))
def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] he...
print self.doc_leader
self.stdout.write("%s\n"%str(self.doc_leader))
def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] he...
print header
self.stdout.write("%s\n"%str(header))
def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print
print self.ruler * len(header)
self.stdout.write("%s\n"%str(self.ruler * len(header)))
def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print
print
self.stdout.write("\n")
def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print
print "<empty>"
self.stdout.write("<empty>\n")
def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns.
print list[0]
self.stdout.write('%s\n'%str(list[0]))
def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns.
print " ".join(texts)
self.stdout.write("%s\n"%str(" ".join(texts)))
def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns.
_cache[alias] = entry
if not aliases.aliases.has_key(alias): aliases.aliases[alias] = modname
def search_function(encoding): # Cache lookup entry = _cache.get(encoding,_unknown) if entry is not _unknown: return entry # Import the module modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: mod = __import__(modname,globals(),locals(),'*') except ImportError,why: _cache[encodi...
self.addheaders = [('User-agent', server_version)]
self.addheaders = [('User-Agent', server_version)]
def __init__(self): server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-agent', server_version)] # manage the individual handlers self.handlers = [] self.handle_open = {} self.handle_error = {}
h.putheader(*args)
if name not in req.headers: h.putheader(*args)
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
self.__buf = self.__buf + \ (chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \ chr(int(x>>8 & 0xff)) + chr(int(x & 0xff))) if _USE_MACHINE_REP: def pack_uint(self, x): if type(x) == LongType: x = int((x + 0x80000000L) % 0x100000000L - 0x80000000L) self.__buf = self.__buf + struct.pack('l', x)
self.__buf = self.__buf + struct.pack('>L', x)
def pack_uint(self, x):
raise ConversionError('Not supported')
try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError(msg)
def pack_float(self, x):
raise ConversionError('Not supported') if _xdr: def pack_float(self, x): try: self.__buf = self.__buf + _xdr.pack_float(x) except _xdr.error, msg: raise ConversionError(msg) def pack_double(self, x): try: self.__buf = self.__buf + _xdr.pack_double(x) except _xdr.error, msg: raise ConversionError(msg)
try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError(msg)
def pack_double(self, x):
x = long(ord(data[0]))<<24 | ord(data[1])<<16 | \ ord(data[2])<<8 | ord(data[3]) if x < 0x80000000L: x = int(x) return x if _USE_MACHINE_REP: def unpack_uint(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('l', data)[0]
x = struct.unpack('>L', data)[0] try: return int(x) except OverflowError: return x
def unpack_uint(self):
x = self.unpack_uint() if x >= 0x80000000L: x = x - 0x100000000L return int(x)
i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>l', data)[0]
def unpack_int(self):
raise ConversionError('Not supported')
i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>f', data)[0]
def unpack_float(self):
raise ConversionError('Not supported') if _xdr: def unpack_float(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError try: return _xdr.unpack_float(data) except _xdr.error, msg: raise ConversionError(msg) def unpack_double(self): i = self.__pos self.__pos = j = i+8 data =...
i = self.__pos self.__pos = j = i+8 data = self.__buf[i:j] if len(data) < 8: raise EOFError return struct.unpack('>d', data)[0]
def unpack_double(self):
n[i] = n[i].split(os.sep) if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep)
n[i] = n[i].split("/")
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ...
return os.sep.join(prefix)
return "/".join(prefix)
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ...
elif usage.startswith("usage: "):
elif usage.lower().startswith("usage: "):
def set_usage (self, usage): if usage is None: self.usage = "%prog [options]" elif usage is SUPPRESS_USAGE: self.usage = None elif usage.startswith("usage: "): # for backwards compatibility with Optik 1.3 and earlier self.usage = usage[7:] else: self.usage = usage
data = convert_path(f[1])
data = convert_path(data)
def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # it's a simple file, so copy it f = convert_path(f) if self.warn_dir: self.warn("setup script did not provide a directory for " "'%s' -- installing right in '%s'" % (f, self.install_dir)) (out, _) = self.copy_file(f, self...
filename = words[-1] infostuff = words[-5:-1]
filename = string.join(words[8:]) infostuff = words[5:]
def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open...
del _active[_get_ident()]
if _sys.modules.has_key('dummy_threading'): try: del _active[_get_ident()] except KeyError: pass else: del _active[_get_ident()]
def __delete(self): _active_limbo_lock.acquire() del _active[_get_ident()] _active_limbo_lock.release()
self.packages = self.pimpdb.list()
packages = self.pimpdb.list() if show_hidden: self.packages = packages else: self.packages = [] for pkg in packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue self.packages.append(pkg)
def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv
if name[0] == '(' and name[-1] == ')' and not show_hidden: continue
def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv
result = f % val fields = string.split(result, ".")
result = f % abs(val) fields = result.split(".")
def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return field...
return fields[0]+localeconv()['decimal_point']+fields[1]
res = fields[0]+localeconv()['decimal_point']+fields[1]
def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return field...
return fields[0]
res = fields[0]
def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return field...
_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*", re.IGNORECASE)
_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*$", re.IGNORECASE)
def format_attrs(attrs, xml=0): attrs = attrs.items() attrs.sort() s = '' for name, value in attrs: if xml: s = '%s %s="%s"' % (s, name, escape(value)) else: # this is a little bogus, but should do for now if name == value and isnmtoken(value): s = "%s %s" % (s, value) elif istoken(value): s = "%s %s=%s" % (s, name, va...
_token_rx = re.compile("[a-z0-9][-._a-z0-9]*", re.IGNORECASE)
_token_rx = re.compile("[a-z0-9][-._a-z0-9]*$", re.IGNORECASE)
def isnmtoken(s): return _nmtoken_rx.match(s) is not None
output_dir=None):
output_dir=None, debug=0):
def link_static_lib (self, objects, output_libname, output_dir=None):
['response', ['mesg_num octets', ...]].
['response', ['mesg_num octets', ...], octets].
def list(self, which=None): """Request listing, return result.
frozendllmain_c, extensions_c] + files
frozendllmain_c, os.path.basename(extensions_c)] + files
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.p...
if s[0] in ('-', '+'):
if s[:1] in ('-', '+'):
def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s sign = '' if s[0] in ('-', '+'): sign, s = s[0], s[1:] return si...
elif sys.platform.startswith("netbsd"):
elif sys.platform.startswith("netbsd") or sys.platform.startswith("openbsd"):
def test_load(self): if os.name == "nt": name = "msvcrt" elif os.name == "ce": name = "coredll" elif sys.platform == "darwin": name = "libc.dylib" elif sys.platform.startswith("freebsd"): name = "libc.so" elif sys.platform == "sunos5": name = "libc.so" elif sys.platform.startswith("netbsd"): name = "libc.so" else: name...
If the population has repeated elements, then each occurence is
If the population has repeated elements, then each occurrence is
def sample(self, population, k, random=None, int=int): """Chooses k unique random elements from a population sequence.
if os.name == 'mac': def getproxies():
if sys.platform == 'darwin': def getproxies_internetconfig():
def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name...
def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars))
def translate(self, *args): return self.__class__(self.data.translate(*args))
def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars))
if re.match(e[1], result): continue
if re.match(escapestr(e[1], ampm), result): continue
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: t...
if re.match(e[1], result):
if re.match(escapestr(e[1], ampm), result):
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: t...
directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout."""
directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line s...
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' i...
except os.error, (errno, errstr):
except OSError, exc:
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' i...
"could not create '%s': %s" % (head, errstr)
"could not create '%s': %s" % (head, exc[-1])
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' i...
archive_basename = "%s.win32" % self.distribution.get_fullname()
fullname = self.distribution.get_fullname() archive_basename = os.path.join(self.bdist_dir, "%s.win32" % fullname)
def run (self):
self.create_exe (arcname)
self.create_exe (arcname, fullname)
def run (self):
def create_exe (self, arcname):
def create_exe (self, arcname, fullname):
def create_exe (self, arcname): import struct, zlib
installer_name = "%s.win32.exe" % self.distribution.get_fullname()
installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname)
def create_exe (self, arcname): import struct, zlib
dir = os.path.join(self.root, dir[1:])
dir = change_root(self.root, dir)
def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # its a simple file, so copy it self.copy_file(f, self.install_dir) else: # its a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): dir = os.path.join(self.install_dir, dir) elif self....
print "install_lib: compile=%s, optimize=%s" % \ (`self.compile`, `self.optimize`)
def finalize_options (self):
linelen = 0
def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd)
if linelen + len(c) >= MAXLINESIZE: if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = []
def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd)
linelen += len(c)
def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd)
prevline = EMPTYSTRING.join(outline) linelen = 0 outline = []
thisline = EMPTYSTRING.join(outline) while len(thisline) > MAXLINESIZE: write(thisline[:MAXLINESIZE-1], lineEnd='=\n') thisline = thisline[MAXLINESIZE-1:] prevline = thisline
def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd)
header.append(mapping[2*i]+256*mapping[2*i+1])
if sys.byteorder == 'big': header.append(256*mapping[2*i]+mapping[2*i+1]) else: header.append(mapping[2*i]+256*mapping[2*i+1])
def _optimize_unicode(charset, fixup): charmap = [0]*65536 negate = 0 for op, av in charset: if op is NEGATE: negate = 1 elif op is LITERAL: charmap[fixup(av)] = 1 elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): charmap[i] = 1 elif op is CATEGORY: # XXX: could expand category return charset # cannot com...
def create_inifile (self):
def get_inidata (self): lines = []
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
ini_name = "%s.ini" % metadata.get_fullname() self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w")
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("[metadata]\n")
lines.append ("[metadata]")
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("%s=%s\n" % (name, repr (data)[1:-1]))
lines.append ("%s=%s" % (name, repr (data)[1:-1]))
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("\n[Setup]\n") inifile.write ("info=%s\n" % repr (info)[1:-1]) inifile.write ("pthname=%s.%s\n" % (metadata.name, metadata.version))
lines.append ("\n[Setup]") lines.append ("info=%s" % repr (info)[1:-1]) lines.append ("pthname=%s.%s" % (metadata.name, metadata.version))
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("target_version=%s\n" % self.target_version)
lines.append ("target_version=%s" % self.target_version)
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
inifile.write ("title=%s\n" % repr (title)[1:-1]) inifile.close() return ini_name
lines.append ("title=%s" % repr (title)[1:-1]) return string.join (lines, "\n")
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
import struct cfgdata = open (self.create_inifile()).read()
import struct self.mkpath(self.dist_dir) cfgdata = self.get_inidata()
def create_exe (self, arcname, fullname): import struct#, zlib
def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self ) def parse(self, source): self.prepareParser(source) inf=open( source ) buffer = inf.read(self._bufsize)
def __init__(self, bufsize=2**16): self._bufsize = bufsize XMLReader.__init__(self) def _parseOpenFile(self, source): buffer = source.read(self._bufsize)
def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self )
buffer = inf.read(self._bufsize)
buffer = source.read(self._bufsize)
def parse(self, source): self.prepareParser(source) #FIXME: do some type checking: could be already stream, URL or # filename inf=open( source ) buffer = inf.read(self._bufsize) while buffer != "": self.feed(buffer) buffer = inf.read(self._bufsize) self.close() self.reset()
host = urlparse.urlparse(req.get_full_url())[1]
host = req.get_host()
def do_open(self, http_class, req): host = urlparse.urlparse(req.get_full_url())[1] if not host: raise URLError('no host given')
if not __debug__: expected = [ev for ev in expected if ev[0] != LINE]
def check_events(self, expected): events = self.get_events_wotime() if not __debug__: # Running under -O, so we don't get LINE events expected = [ev for ev in expected if ev[0] != LINE] if events != expected: self.fail( "events did not match expectation; got:\n%s\nexpected:\n%s" % (pprint.pformat(events), pprint.pforma...
def start_doctype_decl(self, name, pubid, sysid, has_internal_subset):
def start_doctype_decl(self, name, sysid, pubid, has_internal_subset):
def start_doctype_decl(self, name, pubid, sysid, has_internal_subset): self._lex_handler_prop.startDTD(name, pubid, sysid)
writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId))
writer.write("%s PUBLIC '%s'%s '%s'" % (newl, self.publicId, newl, self.systemId))
def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write...
writer.write("\n SYSTEM '%s'" % self.systemId)
writer.write("%s SYSTEM '%s'" % (newl, self.systemId))
def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write...
writer.write(">\n")
writer.write(">"+newl)
def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write...
writer.write('<?xml version="1.0" ?>\n') else: writer.write('<?xml version="1.0" encoding="%s"?>\n' % encoding)
writer.write('<?xml version="1.0" ?>'+newl) else: writer.write('<?xml version="1.0" encoding="%s"?>%s' % (encoding, newl))
def writexml(self, writer, indent="", addindent="", newl="", encoding = None): if encoding is None: writer.write('<?xml version="1.0" ?>\n') else: writer.write('<?xml version="1.0" encoding="%s"?>\n' % encoding) for node in self.childNodes: node.writexml(writer, indent, addindent, newl)
print 'shlex: reading from %s, line %d' % (self.instream,self.lineno)
print 'shlex: reading from %s, line %d' \ % (self.instream, self.lineno)
def __init__(self, instream=None, infile=None): if instream: self.instream = instream self.infile = infile else: self.instream = sys.stdin self.infile = None self.commenters = '#' self.wordchars = 'abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' self.whitespace = ' \t\r\n' self.quotes = '\'"' self.stat...
self.filestack = [(self.infile,self.instream,self.lineno)] + self.filestack
self.filestack.insert(0, (self.infile, self.instream, self.lineno))
def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok
print 'shlex: popping to %s, line %d' % (self.instream, self.lineno)
print 'shlex: popping to %s, line %d' \ % (self.instream, self.lineno)
def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok
print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar)
print "shlex: in state", repr(self.state), \ "I see character:", repr(nextchar)
def read_token(self): "Read a token from the input stream (no pushback or inclusions)" tok = '' while 1: nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 if self.debug >= 3: print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: sel...
lexer = shlex()
if len(sys.argv) == 1: lexer = shlex() else: file = sys.argv[1] lexer = shlex(open(file), file)
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno)
print "Token: " + repr(tt) if not tt:
if tt: print "Token: " + repr(tt) else:
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno)
if not size:
readsize = 1024 if not size:
def read(self,size=None):
self._read()
self._read(readsize) readsize = readsize * 2
def read(self,size=None):
def _read(self): buf = self.fileobj.read(1024)
def _unread(self, buf): self.extrabuf = buf + self.extrabuf self.extrasize = len(buf) + self.extrasize def _read(self, size=1024): try: buf = self.fileobj.read(size) except AttributeError: raise EOFError, "Reached EOF"
def _read(self):
line=""
bufs = [] readsize = 100
def readline(self):
c = self.read(1) line = line + c if c=='\n' or c=="": break return line
c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
def readline(self):
L=[] line = self.readline() while line!="": L.append(line) line = self.readline() return L
buf = self.read() return string.split(buf, '\n')
def readlines(self):
if islink(component): resolved = os.readlink(component) (dir, file) = split(component) resolved = normpath(join(dir, resolved)) newpath = join(*([resolved] + bits[i:])) return realpath(newpath)
if islink(component): resolved = _resolve_link(component) if resolved is None: return join(*([component] + bits[i:])) else: newpath = join(*([resolved] + bits[i:])) return realpath(newpath)
def realpath(filename): """Return the canonical path of the specified filename, eliminating any