bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def __init__(self): | def __init__(self): | 32,800 |
def __init__(self): | def __init__(self): | 32,801 |
def on_device_added(self,dev): addr = dev['address'] name = dev['local_name'] self.dev_liststore.append([dev.path, addr, name+"\t("+addr+")",False,False]); | def on_device_added(self,dev): addr = dev['address'] name = dev['name'] self.dev_liststore.append([dev.path, addr, name+"\t("+addr+")",False,False]); | 32,802 |
def vfs_read_directory(self, handle, file_info, context): print "vfs_read_directory", handle, file_info, context handle.read_dir(file_info) | def vfs_read_directory(self, handle, file_info, context): print "vfs_read_directory", handle, context handle.read_dir(file_info) | 32,803 |
def vfs_get_file_info(self, uri, file_info, options, context): print "vfs_get_file_info", uri, file_info, options, context | def vfs_get_file_info(self, uri, file_info, options, context): print "vfs_get_file_info", uri, file_info, options, context | 32,804 |
def vfs_get_file_info_from_handle(self, handle, file_info, options, context): print "vfs_get_file_info_from_handle", handle, file_info, options, context handle.get_file_info(file_info) | def vfs_get_file_info_from_handle(self, handle, file_info, options, context): print "vfs_get_file_info_from_handle", handle, options, context handle.get_file_info(file_info) | 32,805 |
def vfs_open(self, uri, mode, context): print "------------------------> vfs_open", uri | def vfs_open(self, uri, mode, context): print "------------------------> vfs_open", uri | 32,806 |
def vfs_open(self, uri, mode, context): print "------------------------> vfs_open", uri | def vfs_open(self, uri, mode, context): print "------------------------> vfs_open", uri | 32,807 |
def cleanup(self): """Remove all objects from all StackedObjectProxy instances that were tracked at this Registry context""" for id, val in self.reglist[-1].iteritems(): stacked, obj = val stacked.pop_object(obj) self.reglist.pop() | def cleanup(self): """Remove all objects from all StackedObjectProxy instances that were tracked at this Registry context""" for id, val in self.reglist[-1].iteritems(): stacked, obj = val stacked.pop_object(obj) self.reglist.pop() | 32,808 |
def __call__(self, environ, start_response): global _threadedprint_installed if environ.get('paste.testing'): # In a testing environment this interception isn't # useful: return self.app(environ, start_response) if not _threadedprint_installed: # @@: Not strictly threadsafe _threadedprint_installed = True threadedprint... | def __call__(self, environ, start_response): global _threadedprint_installed if environ.get('paste.testing'): # In a testing environment this interception isn't # useful: return self.app(environ, start_response) if not _threadedprint_installed: # @@: Not strictly threadsafe _threadedprint_installed = True threadedprint... | 32,809 |
def run_app(): body.extend(self.app(environ, replace_start_response)) | def run_app(): body.extend(self.app(environ, replace_start_response)) | 32,810 |
def run_app(): body.extend(self.app(environ, replace_start_response)) | def run_app(): body.extend(self.app(environ, replace_start_response)) | 32,811 |
def profile(self, func, *args, **kw): ops = self.options prof_filename = ops.get('log_filename', 'profile_data.log.tmp') prof = hotshot.Profile(prof_filename) prof.addinfo('Function Call', self.format_function(func, *args, **kw)) if ops.get('add_info'): prof.addinfo('Extra info', ops['add_info']) exc_info = None try: s... | def profile(self, func, *args, **kw): ops = self.options prof_filename = ops.get('log_filename', 'profile_data.log.tmp') prof = hotshot.Profile(prof_filename) prof.addinfo('Function Call', self.format_function(func, *args, **kw)) if ops.get('add_info'): prof.addinfo('Extra info', ops['add_info']) exc_info = None try: s... | 32,812 |
def profile(self, func, *args, **kw): ops = self.options prof_filename = ops.get('log_filename', 'profile_data.log.tmp') prof = hotshot.Profile(prof_filename) prof.addinfo('Function Call', self.format_function(func, *args, **kw)) if ops.get('add_info'): prof.addinfo('Extra info', ops['add_info']) exc_info = None try: s... | def profile(self, func, *args, **kw): ops = self.options prof_filename = ops.get('log_filename', 'profile_data.log.tmp') prof = hotshot.Profile(prof_filename) prof.addinfo('Function Call', self.format_function(func, *args, **kw)) if ops.get('add_info'): prof.addinfo('Extra info', ops['add_info']) exc_info = None try: s... | 32,813 |
def __init__(self, test_env, args, stdin, stdout, stderr, returncode, files_before, files_after): self.test_env = test_env self.args = args self.stdin = stdin self.stdout = stdout self.stderr = stderr self.returncode = returncode self.files_before = files_before self.files_after = files_after self.files_created = {} se... | def __init__(self, test_env, args, stdin, stdout, stderr, returncode, files_before, files_after): self.test_env = test_env self.args = args self.stdin = stdin self.stdout = stdout self.stderr = stderr self.returncode = returncode self.files_before = files_before self.files_after = files_after self.files_deleted = {} se... | 32,814 |
def __contain__(self, s): return s in self.bytes | def __contains__(self, s): return s in self.bytes | 32,815 |
def detect_start_response(status, headers, exc_info=None): try: return start_response(status, headers, exc_info) except: raise else: started.append(True) | def detect_start_response(status, headers, exc_info=None): try: return start_response(status, headers, exc_info) except: raise else: started.append(True) | 32,816 |
def __init__(self, counter, exc_info, exc_data, base_path, environ): self.counter = counter self.exc_data = exc_data self.base_path = base_path self.environ = environ self.exc_type, self.exc_value, self.tb = exc_info __exception_formatter__ = 1 self.frames = [] n = 0 tb = self.tb while tb is not None and (limit is None... | def __init__(self, counter, exc_info, exc_data, base_path, environ, view_uri): self.counter = counter self.exc_data = exc_data self.base_path = base_path self.environ = environ self.exc_type, self.exc_value, self.tb = exc_info __exception_formatter__ = 1 self.frames = [] n = 0 tb = self.tb while tb is not None and (lim... | 32,817 |
def convert_commandline(self, value): try: return int(value) except ValueError: pass return value | def def setup_config(filename): conf = Config(with_default=True) conf.load(filename) if conf.get('sys_path'): update_sys_path(conf['sys_path'], conf['verbose']) from paste import CONFIG CONFIG.push_process_config(conf) return conf def update_sys_path(paths, verbose): if isinstance(paths, (str, unicode)): paths = [path... | 32,818 |
def __getattr__(self, attr): conf = self.__getconf() if not conf: raise AttributeError( "No configuration has been registered for this process " "or thread") return getattr(conf, attr) | def __getattr__(self, attr): conf = self.current_conf() if not conf: raise AttributeError( "No configuration has been registered for this process " "or thread") return getattr(conf, attr) | 32,819 |
def __getconf(self): thread_configs = local_dict()[self._local_key] if thread_configs: return thread_configs[-1] elif self._process_configs: return self._process_configs[-1] else: return None | def current_conf(self): thread_configs = local_dict().get(self._local_key) if thread_configs: return thread_configs[-1] elif self._process_configs: return self._process_configs[-1] else: return None | 32,820 |
def view(self, environ, start_response): id = int(wsgilib.path_info_pop(environ)) debug_info = self.debug_infos[id] return debug_info.wsgi_application(environ, start_response) | def view(self, environ, start_response): id = int(request.path_info_pop(environ)) if id not in self.debug_infos: start_response( '500 Server Error', [('Content-type', 'text/html')]) return [ "Traceback by id %s does not exist (maybe " "the server has been restarted?)" % id] debug_info = self.debug_infos[id] return debu... | 32,821 |
def detect_start_response(status, headers, exc_info=None): try: return start_response(status, headers, exc_info) except: raise else: started.append(True) | def detect_start_response(status, headers, exc_info=None): try: return start_response(status, headers, exc_info) except: raise else: started.append(True) | 32,822 |
def location(self): for name, value in self.headers: if name.lower() == 'location': return value else: raise KeyError("No location set for %s" % self) | def location(self): for name, value in self.headers: if name.lower() == 'location': return value else: raise KeyError("No location set for %s" % self) | 32,823 |
def parse_formvars(environ, include_get_vars=True): """Parses the request, returning a MultiDict of form variables. If ``include_get_vars`` is true then GET (query string) variables will also be folded into the MultiDict. All values should be strings, except for file uploads which are left as FieldStorage instances. ... | def parse_formvars(environ, include_get_vars=True): """Parses the request, returning a MultiDict of form variables. If ``include_get_vars`` is true then GET (query string) variables will also be folded into the MultiDict. All values should be strings, except for file uploads which are left as FieldStorage instances. ... | 32,824 |
def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.wfile = start_response self.base_url = request.construct_url(environ) path = re.sub(auth_prefix, '', environ['PATH_INFO']) self.parsed_uri = urlparse.urlparse(path) self.query = dict(request.p... | def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ) path = re.sub(auth_prefix, '', environ['PATH_INFO']) self.parsed_uri = urlparse.urlparse(path) self.query =... | 32,825 |
def redirect(self, redirect_url): """Send a redirect response to the given URL to the browser.""" response = """\ | def redirect(self, redirect_url): """Send a redirect response to the given URL to the browser.""" response = """\ | 32,826 |
def render(self, message=None, css_class='alert', form_contents=None, status=200, title="Python OpenID Consumer Example"): """Render a page.""" self.send_response(status) self.pageHeader(title) if message: self.wfile.write("<div class='%s'>" % (css_class,)) self.wfile.write(message) self.wfile.write("</div>") self.page... | def render(self, message=None, css_class='alert', form_contents=None, status=200, title="Python OpenID Consumer Example"): """Render a page.""" response_headers = [('Content-type', 'text/html')] self.start(status, response_headers) self.pageHeader(title) if message: self.wfile.write("<div class='%s'>" % (css_class,)) ... | 32,827 |
def render(self, message=None, css_class='alert', form_contents=None, status=200, title="Python OpenID Consumer Example"): """Render a page.""" self.send_response(status) self.pageHeader(title) if message: self.wfile.write("<div class='%s'>" % (css_class,)) self.wfile.write(message) self.wfile.write("</div>") self.page... | def render(self, message=None, css_class='alert', form_contents=None, status=200, title="Python OpenID Consumer Example"): """Render a page.""" self.send_response(status) self.pageHeader(title) if message: self.body.append("<div class='%s'>" % (css_class,)) self.body.append(message) self.body.append("</div>") self.page... | 32,828 |
def pageHeader(self, title): """Render the page header""" self.wfile.write('''\ | def pageHeader(self, title): """Render the page header""" self.wfile.write('''\ | 32,829 |
def pageFooter(self, form_contents): """Render the page footer""" if not form_contents: form_contents = '' | def pageFooter(self, form_contents): """Render the page footer""" if not form_contents: form_contents = '' | 32,830 |
def __init__(self, address, allowed_request_methods=()): self.address = address self.parsed = urlparse.urlsplit(address) self.scheme = self.parsed[0].lower() self.host = self.parsed[1] self.path = self.parsed[2] self.allowed_request_methods = [ x.lower() for x in allowed_request_methods if x] | def __init__(self, address, allowed_request_methods=(), suppress_http_headers=()): self.address = address self.parsed = urlparse.urlsplit(address) self.scheme = self.parsed[0].lower() self.host = self.parsed[1] self.path = self.parsed[2] self.allowed_request_methods = [ x.lower() for x in allowed_request_methods if x] | 32,831 |
def __call__(self, environ, start_response): if (self.allowed_request_methods and environ['REQUEST_METHOD'].lower() not in self.allowed_request_methods): return httpexceptions.HTTPBadRequest("Disallowed")(environ, start_response) | def __call__(self, environ, start_response): if (self.allowed_request_methods and environ['REQUEST_METHOD'].lower() not in self.allowed_request_methods): return httpexceptions.HTTPBadRequest("Disallowed")(environ, start_response) | 32,832 |
def make_proxy(global_conf, address, allowed_request_methods=""): """ Make a WSGI application that proxies to another address -- 'address' should be the full URL ending with a trailing / 'allowed_request_methods' is a space seperated list of request methods """ from paste.deploy.converters import aslist allowed_request... | def make_proxy(global_conf, address, allowed_request_methods="", suppress_http_headers=""): """ Make a WSGI application that proxies to another address -- 'address' should be the full URL ending with a trailing / 'allowed_request_methods' is a space seperated list of request methods """ from paste.deploy.converters imp... | 32,833 |
def make_proxy(global_conf, address, allowed_request_methods=""): """ Make a WSGI application that proxies to another address -- 'address' should be the full URL ending with a trailing / 'allowed_request_methods' is a space seperated list of request methods """ from paste.deploy.converters import aslist allowed_request... | def make_proxy(global_conf, address, allowed_request_methods=""): """ Make a WSGI application that proxies to another address -- 'address' should be the full URL ending with a trailing / 'allowed_request_methods' is a space seperated list of request methods """ from paste.deploy.converters import aslist allowed_request... | 32,834 |
def __delitem__(self, url): url = self.normalize_url(url) for app_url, app in self.applications: if app_url == url: self.applications.remove((app_url, url)) break else: raise KeyError( "No application with the url %r" % (url,)) | def __delitem__(self, url): url = self.normalize_url(url) for app_url, app in self.applications: if app_url == url: self.applications.remove((app_url, app)) break else: raise KeyError( "No application with the url %r" % (url,)) | 32,835 |
def middleware( application, global_conf, http_login=False, http_realm='Secure Website', http_overwrite_realm=True, http_and_cookie=True, cookie_prefix='', login_page='_login/login_form', logout_page='_login/logout_form', secret=None, authenticator=None, ): """ Configuration: http_login: If true, then we'll prefer HTT... | def middleware( application, global_conf=None, http_login=False, http_realm='Secure Website', http_overwrite_realm=True, http_and_cookie=True, cookie_prefix='', login_page='_login/login_form', logout_page='_login/logout_form', secret=None, authenticator=None, ): """ Configuration: http_login: If true, then we'll prefe... | 32,836 |
def update(self): stat = os.stat(self.filename) if stat.st_mtime == self.st_mtime: return self.st_mtime = stat.st_mtime if stat.st_size < CACHE_SIZE: fh = open(self.filename,"rb") self.set_content(fh.read()) fh.close() return self.content = None remote_header(self.headers,'content-length') self.headers.append(('conten... | def update(self): stat = os.stat(self.filename) if stat.st_mtime == self.st_mtime: return self.st_mtime = stat.st_mtime if stat.st_size < CACHE_SIZE: fh = open(self.filename,"rb") self.set_content(fh.read()) fh.close() return self.content = None remove_header(self.headers,'content-length') self.headers.append(('conten... | 32,837 |
def __call__(self, *args, **kwargs): """ converts ``values()`` into a string value | def __call__(self, *args, **kwargs): """ converts ``values()`` into a string value | 32,838 |
def parse(self, *args, **kwargs): """ return the time value (in seconds since 1970) """ value = self.__call__(*args, **kwargs) if value: try: return mktime_tz(parsedate_tz(value)) except TypeError: raise HTTPBadRequest(( "Received an ill-formed timestamp for %s: %s\r\n") % (self.name, value)) | def parse(self, *args, **kwargs): """ return the time value (in seconds since 1970) """ value = self.__call__(*args, **kwargs) if value: try: return mktime_tz(parsedate_tz(value)) except TypeError: raise HTTPBadRequest(( "Received an ill-formed timestamp for %s: %s\r\n") % (self.name, value)) | 32,839 |
def start_response(status, headers, exc_info=None): if exc_info: try: if headers_sent: # Re-raise original exception only if headers sent raise exc_info[0], exc_info[1], exc_info[2] else: print_exception(exc_info[0], exc_info[1], exc_info[2], file=errors) finally: # avoid dangling circular reference exc_info = None eli... | def start_response(status, headers, exc_info=None): if exc_info: try: if headers_sent: # Re-raise original exception only if headers sent raise exc_info[0], exc_info[1], exc_info[2] finally: # avoid dangling circular reference exc_info = None elif headers_set: # You cannot set the headers more than once, unless the # e... | 32,840 |
def jsonaction(self): request_body = self.servlet().request().rawInput().read() req_data = jsonToObj(request_body) req_id = req_data['id'] try: method_name = req_data['method'] if method_name not in self.jsonMethods(): raise HTTPForbidden( "The method %s is not public" % method_name) method = getattr(self.servlet(), me... | def jsonaction(self): request_body = self.servlet().request().rawInput().read() req_data = jsonToObj(request_body) req_id = req_data['id'] try: method_name = req_data['method'] if method_name not in self.jsonMethods(): raise HTTPForbidden( "The method %s is not public" % method_name) method = getattr(self.servlet(), me... | 32,841 |
def jsonaction(self): request_body = self.servlet().request().rawInput().read() req_data = jsonToObj(request_body) req_id = req_data['id'] try: method_name = req_data['method'] if method_name not in self.jsonMethods(): raise HTTPForbidden( "The method %s is not public" % method_name) method = getattr(self.servlet(), me... | def jsonaction(self): request_body = self.servlet().request().rawInput().read() req_data = jsonToObj(request_body) req_id = req_data['id'] try: method_name = req_data['method'] if method_name not in self.jsonMethods(): raise HTTPForbidden( "The method %s is not public" % method_name) method = getattr(self.servlet(), me... | 32,842 |
def jsonjs(self): env = self.servlet().request().environ() base = self.jsolaitURL lib = self.libURL here = wsgilib.construct_url(env, False) here += '?_action_=jsonaction'; if self.baseConfig: base_base = env['%s.base_url' % self.baseConfig] if not base.startswith('/'): base = base_base + '/' + base if not lib.startswi... | def jsonjs(self): env = self.servlet().request().environ() base = self.jsolaitURL lib = self.libURL here = wsgilib.construct_url(env, False) here += '?_action_=jsonaction'; if self.baseConfig: base_base = env['%s.base_url' % self.baseConfig] if not base.startswith('/'): base = base_base + '/' + base if not lib.startswi... | 32,843 |
def get_data_files(path, files = []): l = [] for name in os.listdir(path): if name[0] == ".": continue relpath = os.path.join(path, name) f = os.path.join(BASEDIR, relpath) if os.path.isdir(f): get_data_files(relpath, files) elif os.path.isfile(f): l.append(f) pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1... | def get_data_files(relpath, files=None): files = files or [] for name in os.listdir(os.path.join(BASEDIR, relpath)): if name.startswith("."): continue relpath = os.path.join(path, name) f = os.path.join(BASEDIR, relpath) if os.path.isdir(f): get_data_files(relpath, files) elif os.path.isfile(f): l.append(f) pref = sys... | 32,844 |
def get_data_files(path, files = []): l = [] for name in os.listdir(path): if name[0] == ".": continue relpath = os.path.join(path, name) f = os.path.join(BASEDIR, relpath) if os.path.isdir(f): get_data_files(relpath, files) elif os.path.isfile(f): l.append(f) pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1... | def get_data_files(path, files = []): l = [] for name in os.listdir(path): if name[0] == ".": continue fn = os.path.join(relpath, name) if os.path.isdir(os.path.join(BASEDIR, fn)): get_data_files(fn, files) elif os.path.isfile(os.path.join(BASEDIR, fn)): files.append(fn) return files | 32,845 |
def get_data_files(path, files = []): l = [] for name in os.listdir(path): if name[0] == ".": continue relpath = os.path.join(path, name) f = os.path.join(BASEDIR, relpath) if os.path.isdir(f): get_data_files(relpath, files) elif os.path.isfile(f): l.append(f) pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1... | def get_data_files(path, files = []): l = [] for name in os.listdir(path): if name[0] == ".": continue relpath = os.path.join(path, name) f = os.path.join(BASEDIR, relpath) if os.path.isdir(f): get_data_files(relpath, files) elif os.path.isfile(f): l.append(f) pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1... | 32,846 |
def __init__(self, default=None): """Create a new StackedObjectProxy If a default is given, its used in every thread if no other object has been pushed on. """ self.__dict__['local'] = threadinglocal.local() if default: self.__dict__['_default_object'] = default | def __init__(self, default=None, name="Default"): """Create a new StackedObjectProxy If a default is given, its used in every thread if no other object has been pushed on. """ self.__dict__['local'] = threadinglocal.local() if default: self.__dict__['_default_object'] = default | 32,847 |
def current_obj(self): """Returns the current active object being proxied to In the event that no object was pushed, the default object if provided will be used. Otherwise, a TypeError will be raised. """ objects = getattr(self.__dict__['local'], 'objects', None) if objects: return objects[-1] else: object = self.__d... | def current_obj(self): """Returns the current active object being proxied to In the event that no object was pushed, the default object if provided will be used. Otherwise, a TypeError will be raised. """ objects = getattr(self.__dict__['local'], 'objects', None) if objects: return objects[-1] else: object = self.__d... | 32,848 |
def _repl_nbsp(match): if len(match.group(2)) == 1: return ' ' return match.group(1) + ' ' * (len(match.group(2))-1) + ' ' | def _repl_nbsp(match): if len(match.group(2)) == 1: return ' ' return match.group(1) + ' ' * (len(match.group(2))-1) + ' ' | 32,849 |
def simplecatcher_app(environ, start_response): try: return application(environ, start_response) except: out = StringIO() traceback.print_exc(file=out) start_response('500 Server Error', [('content-type', 'text/html')], sys.exc_info()) res = out.getvalue() return ['<h3>Error</h3><pre>%s</pre>' % html_quote(out.getvalue... | def simplecatcher_app(environ, start_response): try: return application(environ, start_response) except: out = StringIO() traceback.print_exc(file=out) start_response('500 Server Error', [('content-type', 'text/html')], sys.exc_info()) res = out.getvalue() return ['<h3>Error</h3><pre>%s</pre>' % html_quote(out.getvalue... | 32,850 |
def app_wrapper(*args): # we get 3 args when this is a method, two when it is # a function :( if len(args) == 3: environ = args[1] start_response = args[2] args = [args[0]] else: environ, start_response = args args = [] def application(environ, start_response): form = wsgilib.parse_formvars(environ) headers = wsgilib.R... | def wsgiapp_wrapper(*args): # we get 3 args when this is a method, two when it is # a function :( if len(args) == 3: environ = args[1] start_response = args[2] args = [args[0]] else: environ, start_response = args args = [] def application(environ, start_response): form = wsgilib.parse_formvars(environ) headers = wsgil... | 32,851 |
def application(environ, start_response): form = wsgilib.parse_formvars(environ) headers = wsgilib.ResponseHeaderDict( {'content-type': 'text/html', 'status': '200 OK'}) form['environ'] = environ form['headers'] = headers res = func(*args, **form) status = headers.pop('status') start_response(status, headers.headeritem... | def application(environ, start_response): form = wsgilib.parse_formvars(environ) headers = wsgilib.ResponseHeaderDict( {'content-type': 'text/html', 'status': '200 OK'}) form['environ'] = environ form['headers'] = headers res = func(*args, **form) status = headers.pop('status') start_response(status, headers.headeritem... | 32,852 |
def replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = form.pop('debugcount') try: debugcount = int(debugcount) except ValueError: raise ValueError('Bad value for debugcount') if debugcount not in self.debug_infos: raise ValueError('Debu... | """ A decorator (meant to be used under ``wsgiapp()``) that resolves the ``debugcount`` variable to a ``DebugInfo`` object (or gives an error if it can't be found). """ def debug_info_replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = fo... | 32,853 |
def replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = form.pop('debugcount') try: debugcount = int(debugcount) except ValueError: raise ValueError('Bad value for debugcount') if debugcount not in self.debug_infos: raise ValueError('Debu... | def replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = form.pop('debugcount') try: debugcount = int(debugcount) except ValueError: raise ValueError('Bad value for debugcount') if debugcount not in self.debug_infos: raise ValueError( 'Deb... | 32,854 |
def replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = form.pop('debugcount') try: debugcount = int(debugcount) except ValueError: raise ValueError('Bad value for debugcount') if debugcount not in self.debug_infos: raise ValueError('Debu... | def replacement(self, **form): try: if 'debugcount' not in form: raise ValueError('You must provide a debugcount parameter') debugcount = form.pop('debugcount') try: debugcount = int(debugcount) except ValueError: raise ValueError('Bad value for debugcount') if debugcount not in self.debug_infos: raise ValueError('Debu... | 32,855 |
def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "The EvalException middleware is not usable in a multi-process environment") if environ.get('PATH_INFO', '').startswith('/_debug/'): return self.debug(environ, start_response) else: return self.respond(environ, start_response) | def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "The EvalException middleware is not usable in a " "multi-process environment") if environ.get('PATH_INFO', '').startswith('/_debug/'): return self.debug(environ, start_response) else: return self.respond(environ, start_response) | 32,856 |
def eval_javascript(self, base_path, counter): return ('<script type="text/javascript" src="%s/_debug/mochikit/MochiKit.js"></script>\n' '<script type="text/javascript" src="%s/_debug/media/debug.js"></script>\n' '<script type="text/javascript">\n' 'debug_base = %r;\n' 'debug_count = %r;\n' '\n</script>\n' % (base_path... | def eval_javascript(self, base_path, counter): return ('<script type="text/javascript" src="%s/_debug/mochikit/MochiKit.js"></script>\n' '<script type="text/javascript" src="%s/_debug/media/debug.js"></script>\n' '<script type="text/javascript">\n' 'debug_base = %r;\n' 'debug_count = %r;\n' '\n</script>\n' % (base_path... | 32,857 |
def make_table(items): if isinstance(items, dict): items = items.items() items.sort() rows = [] i = 0 for name, value in items: i += 1 out = StringIO() pprint.pprint(value, out) value = html_quote(out.getvalue()) if len(value) > 100: # @@: This can actually break the HTML :( # should I truncate before quoting? value = ... | def make_table(items): if isinstance(items, dict): items = items.items() items.sort() rows = [] i = 0 for name, value in items: i += 1 out = StringIO() pprint.pprint(value, out) value = html_quote(out.getvalue()) if len(value) > 100: # @@: This can actually break the HTML :( # should I truncate before quoting? value = ... | 32,858 |
def make_table(items): if isinstance(items, dict): items = items.items() items.sort() rows = [] i = 0 for name, value in items: i += 1 out = StringIO() pprint.pprint(value, out) value = html_quote(out.getvalue()) if len(value) > 100: # @@: This can actually break the HTML :( # should I truncate before quoting? value = ... | def make_table(items): if isinstance(items, dict): items = items.items() items.sort() rows = [] i = 0 for name, value in items: i += 1 out = StringIO() pprint.pprint(value, out) value = html_quote(out.getvalue()) if len(value) > 100: # @@: This can actually break the HTML :( # should I truncate before quoting? value = ... | 32,859 |
def params(self): """Uses cascading dict to pull from the params Return a key value from the parameters, they are checked in the following order: POST, GET, URL If a key is not found in the first dict, the next is checked. As with dict.get, None will be returned if the key is not found in all three. Additional metho... | def params(): doc = """\ MultiDict of keys from POST, GET, URL dicts Return a key value from the parameters, they are checked in the following order: POST, GET, URL Additional methods supported: getlist(key) Returns a list keyed by parameter location of all the values by that key in that parameter location""" def fg... | 32,860 |
def is_xhr(self): """Returns a boolean if X-Requested-With is present and a XMLHttpRequest""" return self.environ.get('HTTP_X-Requested-With', '') == 'XMLHttpRequest' | def is_xhr(self): """Returns a boolean if X-Requested-With is present and a XMLHttpRequest""" return self.environ.get('HTTP_X-Requested-With', '') == 'XMLHttpRequest' | 32,861 |
def set_default(self, name): """ This method sets the default middleware to be executed, if none of the rules apply. """ self.default = self.binding[name] | def set_default(self, name): """ set default authentication method """ self.default = self.binding[name] | 32,862 |
def set_query_argument(self, name, key = '*authmeth', value = None): """ This method indicates that the named middleware component should be executed if the given key/value pair occurs in the query args. """ lookfor = "%s=%s" % (key, value or name) self.add_predicate(name, lambda environ: lookfor in environ.get('QUERY_... | def set_query_argument(self, name, key = '*authmeth', value = None): """ choose authentication method based on a query argument """ lookfor = "%s=%s" % (key, value or name) self.add_predicate(name, lambda environ: lookfor in environ.get('QUERY_STRING','')) | 32,863 |
def __init__(self, directory, root_directory=None, cache_max_age=None): if os.path.sep != '/': directory = directory.replace(os.path.sep, '/') self.directory = directory self.root_directory = root_directory if root_directory is not None: self.root_directory = os.path.normpath(self.root_directory) else: self.root_direct... | defif os.path.sep != '/': directory = directory.replace('/', os.path.sep) self.root_directory = self.root_directory.replace('/', os.path.sep) __init__(self,if os.path.sep != '/': directory = directory.replace('/', os.path.sep) self.root_directory = self.root_directory.replace('/', os.path.sep) directory,if os.path.se... | 32,864 |
def get(self, url, params=None, headers={}, status=None): if params: if isinstance(params, dict): params = urllib.urlencode(params) if '?' in url: url += '&' else: url += '?' url += params environ = self.make_environ() for header, value in headers.items(): environ['HTTP_%s' % header.replace('-', '_').upper()] = value i... | def get(self, url, params=None, headers={}, status=None, expect_errors=False): if params: if isinstance(params, dict): params = urllib.urlencode(params) if '?' in url: url += '&' else: url += '?' url += params environ = self.make_environ() for header, value in headers.items(): environ['HTTP_%s' % header.replace('-', '_... | 32,865 |
def get(self, url, params=None, headers={}, status=None): if params: if isinstance(params, dict): params = urllib.urlencode(params) if '?' in url: url += '&' else: url += '?' url += params environ = self.make_environ() for header, value in headers.items(): environ['HTTP_%s' % header.replace('-', '_').upper()] = value i... | def get(self, url, params=None, headers={}, status=None): if params: if isinstance(params, dict): params = urllib.urlencode(params) if '?' in url: url += '&' else: url += '?' url += params environ = self.make_environ() for header, value in headers.items(): environ['HTTP_%s' % header.replace('-', '_').upper()] = value i... | 32,866 |
def post(self, url, params=None, headers={}, status=None, upload_files=None): environ = self.make_environ() if params and isinstance(params, dict): params = urllib.urlencode(params) if upload_files: params = cgi.parse_qsl(params, keep_blank_values=True) content_type, params = self.encode_multipart( params, upload_files... | def post(self, url, params=None, headers={}, status=None, upload_files=None, expect_errors=False): environ = self.make_environ() if params and isinstance(params, dict): params = urllib.urlencode(params) if upload_files: params = cgi.parse_qsl(params, keep_blank_values=True) content_type, params = self.encode_multipart(... | 32,867 |
def post(self, url, params=None, headers={}, status=None, upload_files=None): environ = self.make_environ() if params and isinstance(params, dict): params = urllib.urlencode(params) if upload_files: params = cgi.parse_qsl(params, keep_blank_values=True) content_type, params = self.encode_multipart( params, upload_files... | def post(self, url, params=None, headers={}, status=None, upload_files=None): environ = self.make_environ() if params and isinstance(params, dict): params = urllib.urlencode(params) if upload_files: params = cgi.parse_qsl(params, keep_blank_values=True) content_type, params = self.encode_multipart( params, upload_files... | 32,868 |
def do_request(self, req, status): if self.cookies: c = SimpleCookie() for name, value in self.cookies.items(): c[name] = value req.environ['HTTP_COOKIE'] = str(c).split(': ', 1)[1] app = lint.middleware(self.app) old_stdout = sys.stdout out = StringIO() try: sys.stdout = out start_time = time.time() raw_res = wsgilib.... | def do_request(self, req, status): if self.cookies: c = SimpleCookie() for name, value in self.cookies.items(): c[name] = value req.environ['HTTP_COOKIE'] = str(c).split(': ', 1)[1] app = lint.middleware(self.app) old_stdout = sys.stdout out = StringIO() try: sys.stdout = out start_time = time.time() raw_res = wsgilib.... | 32,869 |
def check_status(self, status, res): if status == '*': return if status is None: if res.status == 200 or ( res.status >= 300 and res.status < 400): return raise AppError( "Bad response: %s (not 200 OK or 3xx redirect)" % res.full_status) if status != res.status_int: raise AppError( "Bad response: %s (not %s)" % (res.fu... | def check_status(self, status, res): if status == '*': return if status is None: if res.status == 200 or ( res.status >= 300 and res.status < 400): return raise AppError( "Bad response: %s (not 200 OK or 3xx redirect)" % res.full_status) if status != res.status: raise AppError( "Bad response: %s (not %s)" % (res.full_s... | 32,870 |
def __init__(self, url, environ): self.url = url self.environ = environ if environ.get('QUERY_STRING'): self.full_url = url + '?' + environ['QUERY_STRING'] else: self.full_url = url | def __init__(self, url, environ, expect_errors=False): self.url = url self.environ = environ if environ.get('QUERY_STRING'): self.full_url = url + '?' + environ['QUERY_STRING'] else: self.full_url = url | 32,871 |
def __init__(self, url, environ): self.url = url self.environ = environ if environ.get('QUERY_STRING'): self.full_url = url + '?' + environ['QUERY_STRING'] else: self.full_url = url | defself.expect_errors = expect_errors __init__(self,self.expect_errors = expect_errors url,self.expect_errors = expect_errors environ):self.expect_errors = expect_errors self.urlself.expect_errors = expect_errors =self.expect_errors = expect_errors urlself.expect_errors = expect_errors self.environself.expect_errors = ... | 32,872 |
def parse_formvars(environ, all_as_list=False, include_get_vars=True): """Parses the request, returning a dictionary of the keys. If ``all_as_list`` is true, then all values will be lists. If not, then only values that show up multiple times will be lists. If ``include_get_vars`` is true and this was a POST request,... | def parse_formvars(environ, all_as_list=False, include_get_vars=True): """Parses the request, returning a dictionary of the keys. If ``all_as_list`` is true, then all values will be lists. If not, then only values that show up multiple times will be lists. If ``include_get_vars`` is true and this was a POST request,... | 32,873 |
def parse_formvars(environ, all_as_list=False, include_get_vars=True): """Parses the request, returning a dictionary of the keys. If ``all_as_list`` is true, then all values will be lists. If not, then only values that show up multiple times will be lists. If ``include_get_vars`` is true and this was a POST request,... | def parse_formvars(environ, all_as_list=False, include_get_vars=True): """Parses the request, returning a dictionary of the keys. If ``all_as_list`` is true, then all values will be lists. If not, then only values that show up multiple times will be lists. If ``include_get_vars`` is true and this was a POST request,... | 32,874 |
def html(self, environ): message = self.message args = environ.copy() if self.headers: environ.update(self.headers) message = message % args return ('<html><head><title>%(title)s</title></head>\n' '<body>\n' '<h1>%(title)s</h1>\n' '<p>%(message)s</p>\n' '<hr noshade>\n' '<div align="right">WSGI server</div>\n' '</body>... | def html(self, environ): message = self.message args = environ.copy() if self.headers: args.update(self.headers) message = message % args return ('<html><head><title>%(title)s</title></head>\n' '<body>\n' '<h1>%(title)s</h1>\n' '<p>%(message)s</p>\n' '<hr noshade>\n' '<div align="right">WSGI server</div>\n' '</body></h... | 32,875 |
def params(self): """MultiDict of keys from POST, GET, URL dicts | def params(self): """MultiDict of keys from POST, GET, URL dicts | 32,876 |
def params(self): """MultiDict of keys from POST, GET, URL dicts | def params(self): """MultiDict of keys from POST, GET, URL dicts | 32,877 |
def tell(self): return len(self.content) | def tell(self): return len(self.content) | 32,878 |
def make_wrappable(self, html, wrap_limit=50, split_on=';?&@!$#-/\\"\''): # Currently using <wbr>, maybe should use ​ # http://www.cs.tut.fi/~jkorpela/html/nobr.html words = html.split() new_words = [] for word in words: for char in split_on: if char in word: word = word.replace(char, char+'<wbr>') break new_wo... | def make_wrappable(self, html, wrap_limit=60, split_on=';?&@!$#-/\\"\''): # Currently using <wbr>, maybe should use ​ # http://www.cs.tut.fi/~jkorpela/html/nobr.html words = html.split() new_words = [] for word in words: for char in split_on: if char in word: word = word.replace(char, char+'<wbr>') break new_wo... | 32,879 |
def make_wrappable(self, html, wrap_limit=50, split_on=';?&@!$#-/\\"\''): # Currently using <wbr>, maybe should use ​ # http://www.cs.tut.fi/~jkorpela/html/nobr.html words = html.split() new_words = [] for word in words: for char in split_on: if char in word: word = word.replace(char, char+'<wbr>') break new_wo... | def make_wrappable(self, html, wrap_limit=50, split_on=';?&@!$#-/\\"\''): # Currently using <wbr>, maybe should use ​ # http://www.cs.tut.fi/~jkorpela/html/nobr.html words = html.split() new_words = [] for word in words: if len(word) > wrap_limit: for char in split_on: if char in word: words = [ self.make_wrapp... | 32,880 |
def get(self, url, params=None, headers=None, extra_environ=None, status=None, expect_errors=False): """ Get the given url (well, actually a path like ``'/page.html'``). | def get(self, url, params=None, headers=None, extra_environ=None, status=None, expect_errors=False): """ Get the given url (well, actually a path like ``'/page.html'``). | 32,881 |
def get(self, url, params=None, headers=None, extra_environ=None, status=None, expect_errors=False): """ Get the given url (well, actually a path like ``'/page.html'``). | def get(self, url, params=None, headers=None, extra_environ=None, status=None, expect_errors=False): """ Get the given url (well, actually a path like ``'/page.html'``). | 32,882 |
def post(self, url, params='', headers=None, extra_environ=None, status=None, upload_files=None, expect_errors=False): """ Do a POST request. Very like the ``.get()`` method. ``params`` are put in the body of the request. | def post(self, url, params='', headers=None, extra_environ=None, status=None, upload_files=None, expect_errors=False): """ Do a POST request. Very like the ``.get()`` method. ``params`` are put in the body of the request. | 32,883 |
def values(self, *args, **kwargs): """ find/construct field-value(s) for the given header | def values(self, *args, **kwargs): """ find/construct field-value(s) for the given header | 32,884 |
def wsgi_application(self, environ, start_response, exc_info=None): """ This exception as a WSGI application """ if 'html' in environ.get('HTTP_ACCEPT',''): headers = {'content-type': 'text/html'} content = self.html(environ) else: headers = {'content-type': 'text/plain'} content = self.plain(environ) if self.headers: ... | def wsgi_application(self, environ, start_response, exc_info=None): """ This exception as a WSGI application """ if 'html' in environ.get('HTTP_ACCEPT',''): headers = {'content-type': 'text/html'} content = self.html(environ) else: headers = {'content-type': 'text/plain'} content = self.plain(environ) if self.headers: ... | 32,885 |
def middleware(*args, **kw): import warnings # deprecated 13 dec 2005 warnings.warn('httpexceptions.middleware is deprecated; use ' 'HTTPExceptionHandler instead', DeprecationWarning, 1) return HTTPExceptionHandler(*args, **kw) | def middleware(*args, **kw): import warnings # deprecated 13 dec 2005 warnings.warn('httpexceptions.middleware is deprecated; use ' 'make_middleware or HTTPExceptionHandler instead', DeprecationWarning, 1) return HTTPExceptionHandler(*args, **kw) | 32,886 |
def middleware(*args, **kw): import warnings # deprecated 13 dec 2005 warnings.warn('httpexceptions.middleware is deprecated; use ' 'HTTPExceptionHandler instead', DeprecationWarning, 1) return HTTPExceptionHandler(*args, **kw) | def middleware(*args, **kw): import warnings # deprecated 13 dec 2005 warnings.warn('httpexceptions.middleware is deprecated; use ' 'HTTPExceptionHandler instead', DeprecationWarning, 1) return make_middleware(*args, **kw) | 32,887 |
def __init__(self, directory, root_directory=None): if os.path.sep != '/': directory = directory.replace(os.path.sep, '/') self.directory = directory self.root_directory = root_directory if root_directory is not None: self.root_directory = os.path.normpath(self.root_directory) | def __init__(self, directory, root_directory=None, cache_max_age=None): if os.path.sep != '/': directory = directory.replace(os.path.sep, '/') self.directory = directory self.root_directory = root_directory if root_directory is not None: self.root_directory = os.path.normpath(self.root_directory) | 32,888 |
def __init__(self, directory, root_directory=None): if os.path.sep != '/': directory = directory.replace(os.path.sep, '/') self.directory = directory self.root_directory = root_directory if root_directory is not None: self.root_directory = os.path.normpath(self.root_directory) | defself.cache_max_age = cache_max_age __init__(self,self.cache_max_age = cache_max_age directory,self.cache_max_age = cache_max_age root_directory=None):self.cache_max_age = cache_max_age ifself.cache_max_age = cache_max_age os.path.sepself.cache_max_age = cache_max_age !=self.cache_max_age = cache_max_age '/':s... | 32,889 |
def __call__(self, environ, start_response): path_info = environ.get('PATH_INFO', '') if not path_info: return self.add_slash(environ, start_response) if path_info == '/': # @@: This should obviously be configurable filename = 'index.html' else: # Handle quoted chars (e.g. %20) filename = urllib.unquote(request.path_in... | def __call__(self, environ, start_response): path_info = environ.get('PATH_INFO', '') if not path_info: return self.add_slash(environ, start_response) if path_info == '/': # @@: This should obviously be configurable filename = 'index.html' else: # Handle quoted chars (e.g. %20) filename = urllib.unquote(request.path_in... | 32,890 |
def __call__(self, environ, start_response): path_info = environ.get('PATH_INFO', '') if not path_info: return self.add_slash(environ, start_response) if path_info == '/': # @@: This should obviously be configurable filename = 'index.html' else: # Handle quoted chars (e.g. %20) filename = urllib.unquote(request.path_in... | def __call__(self, environ, start_response): path_info = environ.get('PATH_INFO', '') if not path_info: return self.add_slash(environ, start_response) if path_info == '/': # @@: This should obviously be configurable filename = 'index.html' else: # Handle quoted chars (e.g. %20) filename = urllib.unquote(request.path_in... | 32,891 |
def make_static(global_conf, document_root): """ Return a WSGI application that serves a directory (configured with document_root) """ return StaticURLParser(document_root) | def make_static(global_conf, document_root, cache_max_age=None): """ Return a WSGI application that serves a directory (configured with document_root) """ return StaticURLParser(document_root) | 32,892 |
def make_static(global_conf, document_root): """ Return a WSGI application that serves a directory (configured with document_root) """ return StaticURLParser(document_root) | def make_static(global_conf, document_root): """ Return a WSGI application that serves a directory (configured with document_root) max_cache_age - integer specifies CACHE_CONTROL max_age in seconds """ if cache_max_age is not None: cache_max_age = int(cache_max_age) return StaticURLParser(document_root, **kw) | 32,893 |
def fromlist(cls, seq): self = cls() for name, value in seq: self.add(key, value) return self | def fromlist(cls, seq): self = cls() for name, value in seq: self.add(name, value) return self | 32,894 |
def do_verify(self, request): """Process the form submission, initating OpenID verification. """ | def do_verify(self, request): """Process the form submission, initating OpenID verification. """ | 32,895 |
def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): request = dict(environ=environ, start=start_response, body=[]) request['base_url'] = paste.request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_... | 32,896 |
def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) re... | 32,897 |
def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | 32,898 |
def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | def __call__(self, environ, start_response): if environ['PATH_INFO'].startswith(self.auth_prefix): self.environ = environ self.start = start_response self.body = [] self.base_url = request.construct_url(environ, with_path_info=False, with_query_string=False) path = re.sub(self.auth_prefix, '', environ['PATH_INFO']) se... | 32,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.