rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def end_fill(): _getpen.end_fill()
def end_fill(): _getpen().end_fill()
def end_fill(): _getpen.end_fill()
>>> d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ['abcdefGhijkl\n'], 0, 1) >>> print ''.join(d.results),
>>> results = d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ... ['abcdefGhijkl\n'], 0, 1) >>> print ''.join(results),
def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it.
>>> d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n', ... ' ^ ^ ^ ', '+ ^ ^ ^ ') >>> for line in d.results: print repr(line)
>>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n', ... ' ^ ^ ^ ', '+ ^ ^ ^ ') >>> for line in results: print repr(line)
def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs.
try: os.mkdir(homeDir) except os.error: pass
try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file)
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
try: os.mkdir(homeDir) except os.error: pass
try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file)
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD | self.envFla...
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.set_get_returns_none(2) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.set_get_returns_none(2) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
self.getDB().associate(secDB, self.getGenre)
self.getDB().associate(self.secDB, self.getGenre)
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
self.finish_test(secDB)
self.finish_test(self.secDB)
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
self.getDB().associate(secDB, self.getGenre, db.DB_CREATE) self.finish_test(secDB)
self.getDB().associate(self.secDB, self.getGenre, db.DB_CREATE) self.finish_test(self.secDB)
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
c = self.getDB().cursor(txn)
self.cur = self.getDB().cursor(txn)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
rec = c.first()
rec = self.cur.first()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
rec = c.next()
rec = self.cur.next()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c = secDB.cursor(txn)
self.cur = secDB.cursor(txn)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
vals = c.pget('Unknown', flags=db.DB_LAST)
vals = self.cur.pget('Unknown', flags=db.DB_LAST)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
vals = c.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
def test13_associateAutoCommit(self):
def txn_finish_test(self, sDB, txn): try: self.finish_test(sDB, txn=txn) finally: if self.cur: self.cur.close() self.cur = None if txn: txn.commit() def test13_associate_in_transaction(self):
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.set_get_returns_none(2) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.set_get_returns_none(2) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
self.getDB().associate(secDB, self.getGenre, txn=txn)
self.getDB().associate(self.secDB, self.getGenre, txn=txn)
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
self.finish_test(secDB, txn=txn) finally: txn.commit()
except: txn.abort() raise self.txn_finish_test(self.secDB, txn=txn)
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
raise DistutilsOptionsError, \
raise DistutilsOptionError, \
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
self.failUnlessEqual(3, getargs_b(3.14))
self.assertRaises(TypeError, getargs_b, 3.14)
def test_b(self): from _testcapi import getargs_b # b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX) self.failUnlessEqual(3, getargs_b(3.14)) self.failUnlessEqual(99, getargs_b(Long())) self.failUnlessEqual(99, getargs_b(Int()))
self.failUnlessEqual(3, getargs_B(3.14))
self.assertRaises(TypeError, getargs_B, 3.14)
def test_B(self): from _testcapi import getargs_B # B returns 'unsigned char', no range checking self.failUnlessEqual(3, getargs_B(3.14)) self.failUnlessEqual(99, getargs_B(Long())) self.failUnlessEqual(99, getargs_B(Int()))
self.failUnlessEqual(3, getargs_H(3.14))
self.assertRaises(TypeError, getargs_H, 3.14)
def test_H(self): from _testcapi import getargs_H # H returns 'unsigned short', no range checking self.failUnlessEqual(3, getargs_H(3.14)) self.failUnlessEqual(99, getargs_H(Long())) self.failUnlessEqual(99, getargs_H(Int()))
self.failUnlessEqual(3, getargs_I(3.14))
self.assertRaises(TypeError, getargs_I, 3.14)
def test_I(self): from _testcapi import getargs_I # I returns 'unsigned int', no range checking self.failUnlessEqual(3, getargs_I(3.14)) self.failUnlessEqual(99, getargs_I(Long())) self.failUnlessEqual(99, getargs_I(Int()))
self.failUnlessEqual(3, getargs_i(3.14))
self.assertRaises(TypeError, getargs_i, 3.14)
def test_i(self): from _testcapi import getargs_i # i returns 'int', and does range checking (INT_MIN ... INT_MAX) self.failUnlessEqual(3, getargs_i(3.14)) self.failUnlessEqual(99, getargs_i(Long())) self.failUnlessEqual(99, getargs_i(Int()))
self.failUnlessEqual(3, getargs_l(3.14))
self.assertRaises(TypeError, getargs_l, 3.14)
def test_l(self): from _testcapi import getargs_l # l returns 'long', and does range checking (LONG_MIN ... LONG_MAX) self.failUnlessEqual(3, getargs_l(3.14)) self.failUnlessEqual(99, getargs_l(Long())) self.failUnlessEqual(99, getargs_l(Int()))
self.rfile = self.connection.makefile('rb')
self.rfile = self.connection.makefile('rb', 0)
def setup(self):
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes:
def handle_args(doc): for node in find_all_elements(doc, "args"):
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren...
if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi:
if n.nodeType != xml.dom.core.ELEMENT or n.tagName != "args":
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren...
parent.insertBefore(doc.createText("\n "), node) else: parent.removeChild(node)
signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(node)
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren...
def handle_args(doc): rewrite_desc_entries(doc, "args") rewrite_desc_entries(doc, "constructor-args")
signature.appendChild(doc.createTextNode("\n ")) def methodline_to_signature(doc, methodline): signature = doc.createElement("signature") signature.appendChild(doc.createTextNode("\n ")) name = doc.createElement("name") name.appendChild(doc.createTextNode(methodline.getAttribute("name"))) signature.appendChild(na...
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren...
for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) p...
for label in find_all_elements(doc, "label"): id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) parent.removeChild(label)
def handle_labels(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.s...
if children[-1].data[-1:] == ".":
if children[-1].nodeType == xml.dom.core.TEXT \ and children[-1].data[-1:] == ".":
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == xml.dom.core.TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extrac...
for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT \ and node.tagName == "section": create_module_info(doc, node)
for node in find_all_elements(doc, "section"): create_module_info(doc, node)
def cleanup_synopses(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT \ and node.tagName == "section": create_module_info(doc, node)
for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: tables = child.getElementsByTagName("table") for table in tables: fixup_table(doc, table)
for table in find_all_elements(doc, "table"): fixup_table(doc, table)
def fixup_table_structures(doc): # must be done after remap_element_names(), or the tables won't be found for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: tables = child.getElementsByTagName("table") for table in tables: fixup_table(doc, table)
"paragraph", "subparagraph", "description", "opcodedesc", "classdesc", "funcdesc", "methoddesc", "excdesc", "datadesc", "funcdescni", "methoddescni", "excdescni", "datadescni",
"paragraph", "subparagraph", "excdesc", "datadesc", "excdescni", "datadescni", ) RECURSE_INTO_PARA_CONTAINERS = ( "chapter", "section", "subsection", "subsubsection", "paragraph", "subparagraph", "abstract", "memberdesc", "memberdescni", "datadesc", "datadescni",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
"funcdesc", "methoddesc", "excdesc", "datadesc", "funcdescni", "methoddescni", "excdescni", "datadescni",
"funcdesc", "methoddesc", "excdesc", "funcdescni", "methoddescni", "excdescni",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
"sectionauthor",
"sectionauthor", "seealso",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
"stindex", "obindex", "COMMENT", "label",
"stindex", "obindex", "COMMENT", "label", "input", "memberline", "memberlineni", "methodline", "methodlineni",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
and child.tagName in FIXUP_PARA_ELEMENTS:
and child.tagName in RECURSE_INTO_PARA_CONTAINERS:
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <descripti...
if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <description> element...\n")
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <descripti...
def fixup_paras_helper(doc, container):
def fixup_paras_helper(doc, container, depth=0):
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, sta...
start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i > start: nstart, i = skip_leading_nodes(container.childNodes, start, i) if i > nstart: build_para(do...
while len(children) > start: start = skip_leading_nodes(children, start) if start >= len(children): break if (children[start].nodeType == xml.dom.core.ELEMENT) \ and (children[start].tagName in RECURSE_INTO_PARA_CONTAINERS): fixup_paras_helper(doc, children[start]) start = skip_leading_nodes(children, start + 1) con...
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, sta...
children = parent.childNodes
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy...
node = children[j]
node = parent.childNodes[j]
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy...
def skip_leading_nodes(children, start, i): i = min(i, len(children))
return start + 1 def skip_leading_nodes(children, start): """Return index into children of a node at which paragraph building should begin or a recursive call to fixup_paras_helper() should be made (for subsections, etc.). When the return value >= len(children), we've built all the paras we can from this list of chi...
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy...
try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise
child = children[start]
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ...
if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT:
if nodeType == xml.dom.core.TEXT:
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ...
return start + 1, i + 1 break
return start + 1 return start
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ...
start = start + 1
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ...
if child.tagName in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: start = start + 1 else: break else: break return start, i
tagName = child.tagName if tagName in RECURSE_INTO_PARA_CONTAINERS: return start if tagName not in PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS: return start start = start + 1 return start
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ...
rfc_nodes = [] for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: kids = child.getElementsByTagName("rfc") for k in kids: rfc_nodes.append(k) for rfc_node in rfc_nodes: rfc_node.appendChild(doc.createTextNode( "RFC " + rfc_node.getAttribute("num")))
for rfcnode in find_all_elements(doc, "rfc"): rfcnode.appendChild(doc.createTextNode( "RFC " + rfcnode.getAttribute("num")))
def fixup_rfc_references(doc): rfc_nodes = [] for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: kids = child.getElementsByTagName("rfc") for k in kids: rfc_nodes.append(k) for rfc_node in rfc_nodes: rfc_node.appendChild(doc.createTextNode( "RFC " + rfc_node.getAttribute("num")))
instance.menuRecentFiles.delete(1,END)
menu = instance.menuRecentFiles menu.delete(1,END) i = 0 ; ul = 0; ullen = len(ullist)
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfLis...
instance.menuRecentFiles.add_command(label=fileName, command=instance.__RecentFileCallback(fileName))
callback = instance.__RecentFileCallback(fileName) if i > ullen: ul=None menu.add_command(label=ullist[i] + " " + fileName, command=callback, underline=ul) i += 1
def UpdateRecentFilesList(self,newFile=None): "Load or update the recent files list, and menu if required" rfList=[] if os.path.exists(self.recentFilesPath): RFfile=open(self.recentFilesPath,'r') try: rfList=RFfile.readlines() finally: RFfile.close() if newFile: newFile=os.path.abspath(newFile)+'\n' if newFile in rfLis...
for p in paramre.split(value):
for p in _parseparam(';' + value):
def _get_params_preserve(self, failobj, header): # Like get_params() but preserves the quoting of values. BAW: # should this be part of the public interface? missing = [] value = self.get(header, missing) if value is missing: return failobj params = [] for p in paramre.split(value): try: name, val = p.split('=', 1) na...
if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror())
if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror"))
def register_X_browsers(): # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser strin...
find_file(['/usr/include', '/usr/local/include'] + self.include_dirs, 'db_185.h') ):
find_file(inc_dirs, 'db_185.h') ):
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
exts.append( Extension('pyexpat', ['pyexpat.c'], libraries = ['expat']) )
defs = None if find_file(inc_dirs, 'expat.h'): defs = [('HAVE_EXPAT_H', 1)] elif find_file(inc_dirs, 'xmlparse.h'): defs = [] if defs is not None: exts.append( Extension('pyexpat', ['pyexpat.c'], define_macros = defs, libraries = ['expat']) )
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
while p:
while n:
def normalize(p): # Strip unnecessary zero coefficients n = len(p) while p: if p[n-1]: return p[:n] n = n-1 return []
if (type(args) is not TupleType):
if type(args) is not TupleType and args is not None:
def dump_special(self, callable, args, state = None):
if (type(arg_tup) is not TupleType):
if type(arg_tup) is not TupleType and arg_tup is not None:
def save(self, object, pers_save = 0): memo = self.memo
if (type(callable) is not ClassType): if (not safe_constructors.has_key(callable)):
if type(callable) is not ClassType: if not safe_constructors.has_key(callable):
def load_reduce(self): stack = self.stack
value = apply(callable, arg_tup)
if arg_tup is None: value = callable.__basicnew__() else: value = apply(callable, arg_tup)
def load_reduce(self): stack = self.stack
self.extra_dirs = install.extra_dirs self.path_file = install.path_file
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
root_dir = os.path.normpath (install.install_lib)
root_dir = os.path.normpath (install.install_purelib)
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
if (self.path_file): lines.append ("path_file=%s" % self.path_file) if (self.extra_dirs): lines.append ("extra_dirs=%s" % self.extra_dirs)
def get_inidata (self): # Return data describing the installation.
AAAA4AAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1v ZGUuDQ0KJAAAAAAAAADq05KMrrL8366y/N+usvzf1a7w36+y/N8trvLfrLL831GS+N+ssvzfzK3v 36ay/N+usv3fzrL8366y/N+jsvzfUZL236Oy/N9ptPrfr7L831JpY2iusvzfAAAAAAAAAABQRQAA TAEDAPimujkAAAAAAAAAAOAADwELAQYAAEAAAAAQAAAAkAAA4NUAAACgAAAA4AAAAABAAAAQAAAA AgAABAAAAAAA...
AAAA8AAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1v ZGUuDQ0KJAAAAAAAAADqs5WMrtL7367S+9+u0vvf1c7336/S+98tzvXfrNL731Hy/9+s0vvfzM3o 36bS+9+u0vrf89L7367S+9+j0vvfUfLx36PS+99p1P3fr9L731JpY2iu0vvfAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAUEUAAEwBAwD9e9Q5AAAAAAAAAADgAA8BCwEGAABAAAAAEAAAAJAAAADVAAAA oAAAAOAAAAAA...
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
bGwgUmlnaHRzIFJlc2VydmVkLiAkCgBVUFghDAkCCgSozNfnkDDP6bYAANQ1AAAAsAAAJgEAjf+/ /f9TVVaLdCQUhfZXdHaLfAi9EHBAAIA+AHRoalxWbP/29v8V/GANi/BZHll0V4AmAFcReP833//Y g/v/dR5qD3yFwHUROUQkHHQLV9na//9VagX/VCQog8QM9sMQdR1otwAAJID/T9itg10cACHGBlxG dZNqAVhfXr/7//9dW8NVi+yD7BCLRRRTVleLQBaLPYg0iUX4M/a79u7+d0PAOXUIdQfHRQgBDFZo gFYRY9/+9lZW...
bGwgUmlnaHRzIFJlc2VydmVkLiAkCgBVUFghDAkCCmbxMY8TFMU40bYAAPM0AAAAsAAAJgEABP+/ /f9TVVaLdCQUhfZXdHaLfAi9EHBAAIA+AHRoalxWbP/29v8V/GANi/BZHll0V4AmAFcRmP833//Y g/v/dR5qD5SFwHUROUQkHHQLV9na//9VagX/VCQog8QM9sMQdR1otwAAJJD/T9itg10cACHGBlxG dZNqAVhfXr/7//9dW8NVi+yD7BCLRRRTVleLQBaLPXg0iUX4M/a79u7+d0PAOXUIdQfHRQgBDFZo gFYRY9/+9lZW...
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
vb37yAONRfBQ3GaLSAoDQAxRYdj70HuESn38GQNQ4XVvppQ7+HUJC1Sdhy+U7psOVmoEVhBwhIs9 VN/X4CKQhg9oOIk8mu3WNusmrCsCUyp0U8/3W9uuCCV2CDvGdRcnECjChmYwhJURM8B8ti385FvJ OFOLXVKLIVeh2B4W/kYIZj0IAFGeADiayG1uu13sUOjWP+JMEDZXyLbLVrgiEkC7CMwWXgbYtvvP 3SVoqFgq8VCJXdQtFoze+/7CjVrAdHf/dChQaJCfGUtbutvnBBeslXQTGg18kvLPde4E0JH2IR8W PIXAHrqBHGTc...
vb37yAONRfBQ3GaLSAoDQAxRYdj70Ht0Sn38GQNQ4XVvpqQ7+HUJC4idhy+U7psOVmoEVhCghIs9 iN/X4CKQhg9oOIk8mu3WNusmrCsCUyqcU8/3W9uuCCV2CDvGdRcnECjChmYwhJURM8B8ti385FvJ OFOLXVKLIVeh2B4W/kYIZj0IAFGeADiayG1uu13sUOjWPpJMEDZXyLbLVrgiEkC7CMwWXgbYtvvP 3SVoqFgq8VCJXdQtFTze+/7CjVrAdHf/dChQaJCfGUtbutvnBBZclXQTGg18kvLPde4E0JH2IR8U 7IXAHrqBHGTc...
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
DUYcA1YaA8gDdlSKGh5shMYv7I2F6P6dXfQLgi1f92iw7lDM7hAfO9O72fRQjYQFDRdMGlDMbmFz GyUDAPAeDGG/DdjJSwRdV+hGFIC8BefCx+R3G1x0MP91FFhQ2JtrMLshAIZuFBsC7KmwM79WfAID
DUYcA1YaA8gDdlSKGh5shMYv7I2F6P6dXaQLgi1f92iw7lDMnhAfO9O72fRwjYQFDRdMGlDMbmFz GyUDAPAeDGG/DdjJSwRdV5hGFIC8BefCx+R3G1x0MP91FFhQ2JtrMLshAIZuFBsC7KmwM79WfAID
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
yf2A+S912Lcz/gPGAFxAde9zQFwMD3QXdiPdDI+cQclEYVIF49gbrU4KC8BXUBRAYfPfbAXHcUoM PGoKmVn39222/PkzyWi0cFEAHmi8AgAN0SyZhi80KyhQbramtjLXGg0UFSS+4IloS0fYBFYZWVAu DwF2ct3dIB0sGP/TaCnXKN7XDuw4YCMKARXTqZw5070LXyCfnjhdY2vN9PH2wj7auLC9+7YABgA9 /OFOdHCBBRB42jHLZ6OKfQjfYTR8+E/nBgDHBCSAm78A8P/Ac7jfwfDyNUwF0xrtW7s0CugDPzrW aECKFjayOdho...
yf2A+S912Lcz/gPGAFxAde9zQFwMD3QXdpEaDI+cQd1hUnHsjdYFTgoLwFdQFExhb7aC4/NxSgxI agqZWfs2W/73+TPJaLRwUQAeaLwCAA1olkzDLzArOFA3W1PbMtcaDRQVKL6AibSlI2wEVhlZUC4P ATu57m4gHSQY/9NoKdco72sHdiBgIwoBFdOpzpzpXgtfLJ+eRK6xtWb08fbCPtrY3n3buAAGAD2s 4U50cIEFEOjumGVno4p9CFdBYTR8+E/nBgDHBCQgm78A8P/A5nCf7fJgNVgF0xq7t3ZpCugDPzrW aODCaP3ayOZg...
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
AABFeGl0UHJvY2VzcwAAAFJlZ0Nsb3NlS2V5AAAAUHJvcGVydHlTaGVldEEAAFRleHRPdXRBAABm cmVlAABFbmRQYWludAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AABFeGl0UHJvY2VzcwAAAFJlZ0Nsb3NlS2V5AAAAUHJvcGVydHlTaGVldEEAAFRleHRPdXRBAABl eGl0AABFbmRQYWludAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
- list: list of article ids"""
- list: list of message ids"""
def newnews(self, group, date, time, file=None): """Process a NEWNEWS command. Arguments: - group: group name or '*' - date: string 'yymmdd' indicating the date - time: string 'hhmmss' indicating the time Return: - resp: server response if successful - list: list of article ids"""
- id: the article id"""
- id: the message id"""
def stat(self, id): """Process a STAT command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: the article number - id: the article id"""
del dir, L
del dir, dircase, L
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir)
if self.force or output_file is None or newer(source, output_file)):
if self.force or output_file is None or newer(source, output_file):
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm")) assert len(srpms) == 1, \ "unexpected number of SRPM files found: %s" % srpms dist_file = ('bdist_rpm', 'any', self._dist_path(srpms[0])) self.distribution.dist_files.append(dist_file) self.move_file(srpms[0], self.dist_dir)
srpm = os.path.join(rpm_dir['SRPMS'], source_rpm) assert(os.path.exists(srpm)) self.move_file(srpm, self.dist_dir)
def run (self):
rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm")) debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*debuginfo*.rpm")) if debuginfo: rpms.remove(debuginfo[0]) assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms dist_file = ('bdist_rpm', get_python_version(), self._dist_path(rpms[0])...
for rpm in binary_rpms: rpm = os.path.join(rpm_dir['RPMS'], rpm) if os.path.exists(rpm): self.move_file(rpm, self.dist_dir)
def run (self):
self.repr = "{}"
self.repr = "set()"
def setUp(self): self.case = "empty set" self.values = [] self.set = set(self.values) self.dup = set(self.values) self.length = 0 self.repr = "{}"
headers, 'file:'+file)
headers, urlfile)
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) hos...
"""parse the input lines from a robot.txt file.
"""parse the input lines from a robots.txt file.
def parse(self, lines): """parse the input lines from a robot.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.""" state = 0 linenumber = 0 entry = Entry()
_debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" %
_debug("Checking robots.txt allowance for:\n user agent: %s\n url: %s" %
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" % (useragent, url)) if self.disallow_all: return False if self.allow_all: return True # search for given user agent matches # the first match c...
for m in Pack.__dict__.keys():
methods = Pack.__dict__.keys() methods = methods + Grid.__dict__.keys() methods = methods + Place.__dict__.keys() for m in methods:
def __init__(self, master=None, cnf=None, **kw): if cnf is None: cnf = {} if kw: cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): if type(k) == ClassType or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = apply(Frame, (master,), fcnf) self.vbar = Scrollbar(self.frame, name='vbar') self.vbar.pack(side=RIG...
wordlist.sort(lambda a, b: len(b[1])-len(a[1]))
def cmpwords((aword, alist),(bword, blist)): r = -cmp(len(alist),len(blist)) if r: return r return cmp(aword, bword) wordlist.sort(cmpwords)
def makeunicodename(unicode, trace): FILE = "Modules/unicodename_db.h" print "--- Preparing", FILE, "..." # collect names names = [None] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: name = record[1].strip() if name and name[0] != "<": names[char] = name + chr(0) print len...
for i in range(0, 0xD800):
for i in range(0, 0x110000):
def __init__(self, filename, exclusions, expand=1): file = open(filename) table = [None] * 0x110000 while 1: s = file.readline() if not s: break s = s.strip().split(";") char = int(s[0], 16) table[char] = s
ix = h & 0xff000000
ix = h & 0xff000000L
def myhash(s, magic): h = 0 for c in map(ord, s.upper()): h = (h * magic) + c ix = h & 0xff000000 if ix: h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff return h
'unixware5':
'unixware7':
def printlist(x, width=70, indent=4): """Print the elements of iterable x to stdout. Optional arg width (default 70) is the maximum line length. Optional arg indent (default 4) is the number of blanks with which to begin each line. """ from textwrap import fill blanks = ' ' * indent print fill(' '.join(map(str, x)), ...
fp.write("\tif hasattr(v, '_superclassnames') and v._superclassnames:\n")
fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n")
fp.write("def getbaseclasses(v):\n")
fp.write("\t\tv._superclassnames = None\n")
fp.write("def getbaseclasses(v):\n")
f_month -- full weekday names (14-item list; dummy value in [0], which
f_month -- full month names (13-item list; dummy value in [0], which
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
a_month -- abbreviated weekday names (13-item list, dummy value in
a_month -- abbreviated month names (13-item list, dummy value in
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
* any RCS or CVS directories
* any RCS, CVS and .svn directories
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories ""...
self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
self.filelist.exclude_pattern(r'/(RCS|CVS|\.svn)/.*', is_regex=1)
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories ""...
SetDialogItemText(h, string.joinfields(list, '\r'))
h.data = string.joinfields(list, '\r') d.SelectDialogItemText(TEXT_ITEM, 0, 32767) d.SelectDialogItemText(TEXT_ITEM, 0, 0)
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, ...
tmp = string.splitfields(GetDialogItemText(h), '\r')
tmp = string.splitfields(h.data, '\r')
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, ...
s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!'
if type(vin.packfactor) == type(()): xpf, ypf = vin.packfactor s = string.rjust(`xpf`, 2) + ',' + \ string.rjust(`ypf`, 2)
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print ...
s = s + ' '
s = string.rjust(`vin.packfactor`, 2) if type(vin.packfactor) == type(0) and \ vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '! ' else: s = s + ' '
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print ...
print string.rjust(`int(n*10000.0/t)*0.1`, 5)
if t: print string.rjust(`int(n*10000.0/t)*0.1`, 5), print
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print ...
USE_FROZEN = hasattr(imp, "set_frozenmodules")
USE_ZIPIMPORT = "zipimport" in sys.builtin_module_names
def report(self): # XXX something decent pass