bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _if_modified_since_request_handler(self, REQUEST, RESPONSE): # HTTP If-Modified-Since header handling: return True if # we can handle this request by returning a 304 response header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=header.split( ';')[0] # Some proxies seem to send invalid ...
def _if_modified_since_request_handler(self, REQUEST, RESPONSE): # HTTP If-Modified-Since header handling: return True if # we can handle this request by returning a 304 response header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=header.split( ';')[0] # Some proxies seem to send invalid ...
1,800
def _if_modified_since_request_handler(self, REQUEST, RESPONSE): # HTTP If-Modified-Since header handling: return True if # we can handle this request by returning a 304 response header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=header.split( ';')[0] # Some proxies seem to send invalid ...
def _if_modified_since_request_handler(self, REQUEST, RESPONSE): # HTTP If-Modified-Since header handling: return True if # we can handle this request by returning a 304 response header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=header.split( ';')[0] # Some proxies seem to send invalid ...
1,801
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
1,802
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
1,803
def field2int(v): try: v=v.read() except: v=str(v) return string.atoi(v)
def field2int(v): try: v=v.read() except: v=str(v) if v: return string.atoi(v) raise ValueError, 'Empty entry when integer expected'
1,804
def field2float(v): try: v=v.read() except: v=str(v) return string.atof(v)
def field2float(v): try: v=v.read() except: v=str(v) if v: return string.atof(v) raise ValueError, 'Empty entry when floating-point number expected'
1,805
def field2long(v): try: v=v.read() except: v=str(v) return string.atol(v)
def field2long(v): try: v=v.read() except: v=str(v) if v: return string.atol(v) raise ValueError, 'Empty entry when integer expected'
1,806
def uniqueValues( self, name=None, withLengths=0 ): """ Return a list of unique values for 'name'.
def uniqueValues( self, name=None, withLengths=0 ): """ Return a list of unique values for 'name'.
1,807
def MOVE(self, REQUEST, RESPONSE): """Move a resource to a new location.""" self.dav__init(REQUEST, RESPONSE) raise 'Forbidden', 'This resource cannot be moved.'
def MOVE(self, REQUEST, RESPONSE): """Move a resource to a new location.""" self.dav__init(REQUEST, RESPONSE) raise 'Forbidden', 'This resource cannot be moved.'
1,808
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified...
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified...
1,809
def logBadRefresh(productid): exc = sys.exc_info() try: LOG('Refresh', ERROR, 'Exception while refreshing %s' % productid, error=exc) if hasattr(exc[0], '__name__'): error_type = exc[0].__name__ else: error_type = str(exc[0]) error_value = str(exc[1]) info = format_exception(exc[0], exc[1], exc[2], limit=200) refresh_e...
def logBadRefresh(productid): exc = sys.exc_info() try: LOG('Refresh', ERROR, 'Exception while refreshing %s' % productid, error=exc) if hasattr(exc[0], '__name__'): error_type = exc[0].__name__ else: error_type = str(exc[0]) error_value = str(exc[1]) info = ''.join(format_exception(exc[0], exc[1], exc[2], limit=200)) ...
1,810
def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base self.insertBase()
def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base self.insertBase()
1,811
def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base self.insertBase()
def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base self.insertBase()
1,812
def insertBase(self, base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)', regex.casefold).search ): # Only insert a base tag if content appears to be html. if self.headers.get('content-type', '')[:9] != 'text/html': return
def insertBase(self, base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)', regex.casefold).search ): # Only insert a base tag if content appears to be html. content_type = self.headers.get('content-type', '')[:9] if content_type and (content_type != 'text/html'): return
1,813
def getOwner(self, info=0): """Get the owner
def getOwner(self, info=0, aq_get=aq_get, None=None, UnownableOwner=UnownableOwner, getSecurityManager=getSecurityManager, ): """Get the owner
1,814
def getOwner(self, info=0): """Get the owner
def getOwner(self, info=0): """Get the owner
1,815
def testStrftimeUnicode(self): dt = DateTime('2002-05-02T08:00:00+00:00') self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), u'Le 02/05/2002 \xe0 10h00')
def testStrftimeUnicode(self): dt = DateTime('2002-05-02T08:00:00+00:00') self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), u'Le 02/05/2002 \xe0 10h00')
1,816
def createInObjectManager(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) if not hasattr(i, 'id') or not i...
def createInObjectManager(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) if not hasattr(i, 'id') or not i...
1,817
def structured_text(v, name='(Unknown name)', md={}): global StructuredText if StructuredText is None: from StructuredText import html_with_references return str(html_with_references(str(v),level=3,header=0))
def structured_text(v, name='(Unknown name)', md={}): global StructuredText if StructuredText is None: from StructuredText.StructuredText import HTML return HTML(str(v),level=3,header=0)
1,818
def setAddNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface print "setting addNotificationTarget to %s" % f self._addCallback = f
def setAddNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface self._addCallback = f
1,819
def setDelNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface print "setting delNotificationTarget to %s" % f self._delCallback = f
def setDelNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface self._delCallback = f
1,820
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
1,821
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
1,822
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ...
1,823
def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ")
def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ")
1,824
def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ")
def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ")
1,825
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p...
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=get...
1,826
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p...
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p...
1,827
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p...
def return product initializeProduct(productp, return product name, return product home, return product app): return product # return product Initialize return product a return product levered return product product return product return product products=app.Control_Panel.Products return product return product if ret...
1,828
def marshal_long(name, val): return ('%s:long=%s' % (name, val))[:-1]
def marshal_long(name, val): value = '%s:long=%s' % (name, val) if value[-1] == 'L': value = value[:-1] return value
1,829
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
1,830
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
1,831
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match TH...
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match TH...
1,832
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUr...
1,833
def manage_edit(self, title, base, path, REQUEST=None): '''Set the title, base, and path''' self.__init__(title, base, path) if REQUEST: return MessageDialog(title='SiteRoot changed.', message='The title is now "%s"<br>' 'The base is now "%s"<br>' 'The path is now "%s"<br>' % map(escape, (title, base, path)), action='%...
def manage_edit(self, title, base, path, REQUEST=None): '''Set the title, base, and path''' self.__init__(title, base, path) if REQUEST: return MessageDialog(title='SiteRoot changed.', message='SiteRoot changed.', action='%s/manage_main' % REQUEST['URL1'])
1,834
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
1,835
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
1,836
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The spe...
1,837
def manage_addLocalRoles(self, userid, roles, REQUEST=None): """Set local roles for a user.""" if not roles: raise ValueError, 'One or more roles must be given!' dict=self.__ac_local_roles__ or {} local_roles = dict.get(userid, []) for r in roles: if r not in local_roles: local_roles.append(r) dict[userid] = local_role...
def manage_addLocalRoles(self, userid, roles, REQUEST=None): """Set local roles for a user.""" if not roles: raise ValueError, 'One or more roles must be given!' dict=self.__ac_local_roles__ or {} local_roles = list(dict.get(userid, [])) for r in roles: if r not in local_roles: local_roles.append(r) dict[userid] = loca...
1,838
def StructuredText(paragraphs, paragraph_delimiter=re.compile('\n\s*\n')): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [paragraph,[sub-paragraphs]] """ currentlevel = 0 currentindent = 0 ...
def StructuredText(paragraphs, delimiter=re.compile(para_delim)): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [paragraph,[sub-paragraphs]] """ currentlevel = 0 currentindent = 0 levels ...
1,839
def StructuredText(paragraphs, paragraph_delimiter=re.compile('\n\s*\n')): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [paragraph,[sub-paragraphs]] """ currentlevel = 0 currentindent = 0 ...
def StructuredText(paragraphs, paragraph_delimiter=re.compile('\n\s*\n')): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [paragraph,[sub-paragraphs]] """ currentlevel = 0 currentindent = 0 ...
1,840
def query(s, index, default_operator = Or, ws = (string.whitespace,)): # First replace any occurences of " and not " with " andnot " s = regsub.gsub('[%s]+and[%s]*not[%s]+' % (ws * 3), ' andnot ', s) q = parse(s) q = parse2(q, default_operator) return evaluate(q, index)
def query(s, index, default_operator = Or, ws = (string.whitespace,)): # First replace any occurences of " and not " with " andnot " s = ts_regex.gsub('[%s]+and[%s]*not[%s]+' % (ws * 3), ' andnot ', s) q = parse(s) q = parse2(q, default_operator) return evaluate(q, index)
1,841
def parens(s, parens_regex = regex.compile("(\|)")): '''Find the beginning and end of the first set of parentheses''' if (parens_regex.search(s) < 0): return None if (parens_regex.group(0) == ")"): raise QueryError, "Mismatched parentheses" open = parens_regex.regs[0][0] + 1 start = parens_regex.regs[0][1] p = 1 wh...
def parens(s, parens_re = regex.compile('(\|)').search): index=open_index=paren_count = 0 while 1: index = parens_re(s, index) if index < 0 : break if s[index] == '(': paren_count = paren_count + 1 if open_index == 0 : open_index = index + 1 else: paren_count = paren_count - 1 if paren_count == 0: return open_inde...
1,842
def quotes(s, ws = (string.whitespace,)): # split up quoted regions splitted = regsub.split(s, '[%s]*\"[%s]*' % (ws * 2)) split=string.split if (len(splitted) > 1): if ((len(splitted) % 2) == 0): raise QueryError, "Mismatched quotes" for i in range(1,len(splitted),2): # split the quoted region into words splitted[i] ...
def quotes(s, ws = (string.whitespace,)): # split up quoted regions splitted = ts_regex.split(s, '[%s]*\"[%s]*' % (ws * 2)) split=string.split if (len(splitted) > 1): if ((len(splitted) % 2) == 0): raise QueryError, "Mismatched quotes" for i in range(1,len(splitted),2): # split the quoted region into words splitted[i...
1,843
def emit(self, record): try: self.buffer.append(record) msg = self.format(record) self.stream.write("%s\n" % msg) self.flush() except: self.handleError()
def emit(self, record): try: self.buffer.append(record) msg = self.format(record) self.stream.write("%s\n" % msg) self.flush() except: self.handleError()
1,844
def traverse(self, path, response=None): """Traverse the object space
def traverse(self, path, response=None): """Traverse the object space
1,845
def traverse(self, path, response=None): """Traverse the object space
def traverse(self, path, response=None): """Traverse the object space
1,846
def __init__(self, id, title, bases): """Build a Zope class
def __init__(self, id, title, bases): """Build a Zope class
1,847
#def manage_workspace(self, URL1):
#def manage_workspace(self, URL1):
1,848
def __init__(self,id,title,file, precondition='',content_type='application/octet-stream'): try: headers=file.headers except: headers=None if headers is None: if not content_type: raise 'BadValue', 'No content type specified' self.content_type=content_type self.data=Pdata(file) else: if headers.has_key('content-type...
def __init__(self,id,title,file,content_type='application/octet-stream', precondition=''): try: headers=file.headers except: headers=None if headers is None: if not content_type: raise 'BadValue', 'No content type specified' self.content_type=content_type self.data=Pdata(file) else: if headers.has_key('content-type...
1,849
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
1,850
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
1,851
def numObjects(self): """ return the number of indexed objects""" try: return self._length() except AttributeError: # backward compatibility l = len(self._unindex) self._length = Length(l) return l
def numObjects(self): """ return the number of indexed objects""" try: return self._length() except AttributeError: # backward compatibility l = len(self._unindex) self._length = Length(l) return l
1,852
def handle_read (self): self.recv (8192) try: self.lock.acquire() for thunk in self.thunks: try: thunk() except: (file, fun, line), t, v, tbinfo = asyncore.compact_traceback() print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo) self.thunks = [] finally: self.lock.release()
def handle_read (self): self.recv (8192) try: self.lock.acquire() for thunk in self.thunks: try: thunk() except: (file, fun, line), t, v, tbinfo = asyncore.compact_traceback() print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo) self.thunks = [] finally: self.lock.release()
1,853
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
1,854
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: count += 1 a =...
1,855
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
1,856
def __init__ (self): a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # set TCP_NODELAY to true to avoid buffering w.setsockopt(socket.IPPROTO_TCP, 1, 1) # tricky: get a pair of connected sockets host='127.0.0.1' port=19999 while 1: try: self.address=(host,...
def__init__(self):a=socket.socket(socket.AF_INET,socket.SOCK_STREAM)w=socket.socket(socket.AF_INET,socket.SOCK_STREAM)#setTCP_NODELAYtotruetoavoidbufferingw.setsockopt(socket.IPPROTO_TCP,1,1)#tricky:getapairofconnectedsocketshost='127.0.0.1'port=19999while1:try:self.address=(host,port)a.bind(self.address)breakexcept:if...
1,857
def __repr__ (self): return '<select-trigger (loopback) at %x>' % id(self)
def __repr__(self): return '<select-trigger (loopback) at %x>' % id(self)
1,858
def readable (self): return 1
def readable(self): return 1
1,859
def writable (self): return 0
def writable(self): return 0
1,860
def handle_connect (self): pass
def handle_connect(self): pass
1,861
def pull_trigger (self, thunk=None): if thunk: try: self.lock.acquire() self.thunks.append (thunk) finally: self.lock.release() self.trigger.send ('x')
def pull_trigger(self, thunk=None): if thunk: try: self.lock.acquire() self.thunks.append (thunk) finally: self.lock.release() self.trigger.send ('x')
1,862
def handle_read (self): self.recv (8192) try: self.lock.acquire() for thunk in self.thunks: try: thunk() except: (file, fun, line), t, v, tbinfo = asyncore.compact_traceback() print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo) self.thunks = [] finally: self.lock.release()
def handle_read(self): self.recv(8192) try: self.lock.acquire() for thunk in self.thunks: try: thunk() except: (file, fun, line), t, v, tbinfo = asyncore.compact_traceback() print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo) self.thunks = [] finally: self.lock.release()
1,863
def testPublicFuncWithWrongAuth(self): """ testing PublicFunc"""
def testPublicFuncWithWrongAuth(self): """ testing PublicFunc"""
1,864
def testProtectedFunc(self): """ testing PrivateFunc"""
def testProtectedFunc(self): """ testing PrivateFunc"""
1,865
def _request(self,*args,**kw):
def _request(self,*args,**kw):
1,866
def _request(self,*args,**kw):
def _request(self,*args,**kw):
1,867
def __init__(self, aStructuredString, level=0, paragraph_divider=regex.compile('\(\n *\)+\n'), ): '''Convert a structured text string into a structured text object.
def __init__(self, aStructuredString, level=0, paragraph_divider=regex.compile('\(\n *\)+\n'), ): '''Convert a structured text string into a structured text object.
1,868
def __init__(self, aStructuredString, level=0, paragraph_divider=regex.compile('\(\n *\)+\n'), ): '''Convert a structured text string into a structured text object.
def __init__(self, aStructuredString, level=0, paragraph_divider=regex.compile('\(\n *\)+\n'), ): '''Convert a structured text string into a structured text object.
1,869
def oct12(i): i=oct(i) return '0'*(11-len(i))+i+' '
def oct12(i): i=oct(i) v = '0'*(11-len(i))+i+' ' if len(v) > 12: left = v[:-12] for c in left: if c != '0': raise ValueError, 'value too large for oct12' return v[-12:] return v
1,870
def manage_addFile(self,id,file,title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id, title = cookId(id, title, file) self=self.this() # First, we create the image without data: self._setObject(id, File(id,title,'',conte...
def manage_addFile(self,id,file,title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id, title = cookId(id, title, file) self=self.this() # First, we create the image without data: self._setObject(id, File(id,title,'',conte...
1,871
def __init__(self, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, environ=os.environ): self.environ=environ fp=None try: if environ['REQUEST_METHOD'] != 'GET': fp=stdin except: pass
def __init__(self, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, environ=os.environ): self.environ=environ fp=None try: if environ['REQUEST_METHOD'] != 'GET': fp=stdin except: pass
1,872
def getEntryForObject(self, documentId, default=None): """Takes a document ID and returns all the information we have on that specific object.""" if default is None: return self._unindex.get(documentId, default) else: return self._unindex.get(documentId)
def getEntryForObject(self, documentId, default=MV): """Takes a document ID and returns all the information we have on that specific object.""" if default is None: return self._unindex.get(documentId, default) else: return self._unindex.get(documentId)
1,873
def getEntryForObject(self, documentId, default=None): """Takes a document ID and returns all the information we have on that specific object.""" if default is None: return self._unindex.get(documentId, default) else: return self._unindex.get(documentId)
def getEntryForObject(self, documentId, default=None): """Takes a document ID and returns all the information we have on that specific object.""" if default is not MV: return self._unindex.get(documentId, default) else: return self._unindex.get(documentId)
1,874
def _cached_result(self, DB__, query, compressed=0):
def _cached_result(self, DB__, query, compressed=0):
1,875
def cb_isCopyable(self): pass # for now, we don't allow ZClasses to be copied.
def cb_isCopyable(self): pass # for now, we don't allow ZClasses to be copied.
1,876
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
1,877
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
1,878
def main(): # The "main" program for this module pass
def main(): # The "main" program for this module pass
1,879
def field2lines(v): try: v=v.read() except: v=str(v) return string.split(v,'\n')
def field2lines(v, crlf=regex.compile('\r\n\|\n\r')): try: v=v.read() except: v=str(v) return string.split(v,'\n')
1,880
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): """Call the database method
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): """Call the database method
1,881
def __init__(self,*args, **kw): """Return a new date-time object
def __init__(self,*args, **kw): """Return a new date-time object
1,882
def getLastChild(self): """The last child of this node. If ther is no such node this returns None.""" return None
def getLastChild(self): """The last child of this node. If ther is no such node this returns None.""" return None
1,883
def parseAttributeReplacements(arg): dict = {} for part in splitParts(arg): m = _attr_re.match(part) if not m: print "Bad syntax in z:attributes:", `part` continue name, expr = m.group(1, 2) if dict.has_key(name): print "Duplicate attribute name in z:attributes:", `part` continue dict[name] = expr return dict
def parseAttributeReplacements(arg): dict = {} for part in splitParts(arg): m = _attr_re.match(part) if not m: print "Bad syntax in attributes:", `part` continue name, expr = m.group(1, 2) if dict.has_key(name): print "Duplicate attribute name in z:attributes:", `part` continue dict[name] = expr return dict
1,884
def parseAttributeReplacements(arg): dict = {} for part in splitParts(arg): m = _attr_re.match(part) if not m: print "Bad syntax in z:attributes:", `part` continue name, expr = m.group(1, 2) if dict.has_key(name): print "Duplicate attribute name in z:attributes:", `part` continue dict[name] = expr return dict
def parseAttributeReplacements(arg): dict = {} for part in splitParts(arg): m = _attr_re.match(part) if not m: print "Bad syntax in z:attributes:", `part` continue name, expr = m.group(1, 2) if dict.has_key(name): print "Duplicate attribute name in attributes:", `part` continue dict[name] = expr return dict
1,885
def parseSubstitution(arg): m = _subst_re.match(arg) if not m: print "Bad syntax in z:insert/replace:", `arg` return None, None key, expr = m.group(1, 2) if not key: key = "text" return key, expr
def parseSubstitution(arg): m = _subst_re.match(arg) if not m: print "Bad syntax in insert/replace:", `arg` return None, None key, expr = m.group(1, 2) if not key: key = "text" return key, expr
1,886
def splitParts(arg): # Break in pieces at undoubled semicolons and # change double semicolons to singles: import string arg = string.replace(arg, ";;", "\0") parts = string.split(arg, ';') parts = map(lambda s, repl=string.replace: repl(s, "\0", ";;"), parts) if len(parts) > 1 and not string.strip(parts[-1]): del parts...
def splitParts(arg): # Break in pieces at undoubled semicolons and # change double semicolons to singles: import string arg = string.replace(arg, ";;", "\0") parts = string.split(arg, ';') parts = map(lambda s, repl=string.replace: repl(s, "\0", ";"), parts) if len(parts) > 1 and not string.strip(parts[-1]): del parts[...
1,887
def __init__(self, program, macros, engine, stream=None, debug=0, wrap=60, metal=1, tal=1, showtal=-1, strictinsert=1, stackLimit=100): self.program = program self.macros = macros self.engine = engine self.TALESError = engine.getTALESError() self.Default = engine.getDefault() self.stream = stream or sys.stdout self.deb...
def __init__(self, program, macros, engine, stream=None, debug=0, wrap=60, metal=1, tal=1, showtal=-1, strictinsert=1, stackLimit=100): self.program = program self.macros = macros self.engine = engine self.TALESError = engine.getTALESError() self.Default = engine.getDefault() self.stream = stream or sys.stdout self.deb...
1,888
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
1,889
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
1,890
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva...
1,891
## def dumpMacroStack(self, prefix, suffix, value):
## def dumpMacroStack(self, prefix, suffix, value):
1,892
def do_defineMacro(self, macroName, macro): save = self.definingMacro self.definingMacro = macroName self.interpret(macro) self.definingMacro = save
def do_defineMacro(self, macroName, macro): if not self.metal: self.interpret(macro) return self.pushMacro("define-macro", macroName, None) self.interpret(macro) self.definingMacro = save
1,893
def do_defineMacro(self, macroName, macro): save = self.definingMacro self.definingMacro = macroName self.interpret(macro) self.definingMacro = save
def do_defineMacro(self, macroName, macro): save = self.definingMacro self.definingMacro = macroName self.interpret(macro) self.definingMacro = save
1,894
def do_useMacro(self, macroName, macroExpr, compiledSlots, block): if not self.metal: self.interpret(block) return macro = self.engine.evaluateMacro(macroExpr) if macro is self.Default: self.interpret(block) return if not isCurrentVersion(macro): raise METALError("macro %s has incompatible version %s" % (`macroName`, `...
def do_useMacro(self, macroName, macroExpr, compiledSlots, block): if not self.metal: self.interpret(block) return macro = self.engine.evaluateMacro(macroExpr) if macro is self.Default: self.interpret(block) return if not isCurrentVersion(macro): raise METALError("macro %s has incompatible version %s" % (`macroName`, `...
1,895
def do_useMacro(self, macroName, macroExpr, compiledSlots, block): if not self.metal: self.interpret(block) return macro = self.engine.evaluateMacro(macroExpr) if macro is self.Default: self.interpret(block) return if not isCurrentVersion(macro): raise METALError("macro %s has incompatible version %s" % (`macroName`, `...
def do_useMacro(self, macroName, macroExpr, compiledSlots, block): if not self.metal: self.interpret(block) return macro = self.engine.evaluateMacro(macroExpr) if macro is self.Default: self.interpret(block) return if not isCurrentVersion(macro): raise METALError("macro %s has incompatible version %s" % (`macroName`, `...
1,896
def do_defineSlot(self, slotName, block): slot = None for macroName, slots in self.macroStack: slot = slots.get(slotName) or slot if slot: self.interpret(slot) else: self.interpret(block)
def do_defineSlot(self, slotName, block): slot = None for what, macroName, slots in self.macroStack: if what == "use-macro" and slots is not None: slot = slots.get(slotName, slot) self.pushMacro("define-slot", slotName, None) if slot: self.interpret(slot) else: self.interpret(block)
1,897
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=ts_regex.compile('[a-zA-Z]>').search):
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=ts_regex.compile('[a-zA-Z]>').search):
1,898
def testHybrid(self): '''Test hybrid path expressions''' ec = self.ec assert ec.evaluate('x | python:1+1') == 2
def testHybrid(self): '''Test hybrid path expressions''' ec = self.ec assert ec.evaluate('x | python:1+1') == 2
1,899