bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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,900
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,901
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,902
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self, request): """Process the form submission, initating OpenID verification. """
32,903
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,904
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,905
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,906
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,907
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,908
def do_verify(self): """Process the form submission, initating OpenID verification. """
def do_verify(self): """Process the form submission, initating OpenID verification. """
32,909
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
def do_process(self, request): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
32,910
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
32,911
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
32,912
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
32,913
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
def do_process(self): """Handle the redirect from the OpenID server. """ oidconsumer = self.oidconsumer
32,914
def build_url(self, action, **query): """Build a URL relative to the server base_url, with the given query parameters added.""" base = urlparse.urljoin(self.base_url, self.auth_prefix + '/' + action) return appendArgs(base, query)
def build_url(self, action, **query): """Build a URL relative to the server base_url, with the given query parameters added.""" base = urlparse.urljoin(request['base_url'], self.auth_prefix + '/' + action) return appendArgs(base, query)
32,915
def redirect(self, redirect_url): """Send a redirect response to the given URL to the browser.""" response_headers = [('Content-type', 'text/plain'), ('Location', redirect_url)] self.start('302 REDIRECT', response_headers) return ["Redirecting to %s" % redirect_url]
def redirect(self, request, redirect_url): """Send a redirect response to the given URL to the browser.""" response_headers = [('Content-type', 'text/plain'), ('Location', redirect_url)] self.start('302 REDIRECT', response_headers) return ["Redirecting to %s" % redirect_url]
32,916
def redirect(self, redirect_url): """Send a redirect response to the given URL to the browser.""" response_headers = [('Content-type', 'text/plain'), ('Location', redirect_url)] self.start('302 REDIRECT', response_headers) return ["Redirecting to %s" % redirect_url]
def redirect(self, redirect_url): """Send a redirect response to the given URL to the browser.""" response_headers = [('Content-type', 'text/plain'), ('Location', redirect_url)] request['start']('302 REDIRECT', response_headers) return ["Redirecting to %s" % redirect_url]
32,917
def not_found(self): """Render a page with a 404 return code and a message.""" fmt = 'The path <q>%s</q> was not understood by this server.' msg = fmt % (self.parsed_uri,) openid_url = self.query.get('openid_url') return self.render(msg, 'error', openid_url, status='404 Not Found')
def not_found(self, request): """Render a page with a 404 return code and a message.""" fmt = 'The path <q>%s</q> was not understood by this server.' msg = fmt % (self.parsed_uri,) openid_url = self.query.get('openid_url') return self.render(msg, 'error', openid_url, status='404 Not Found')
32,918
def not_found(self): """Render a page with a 404 return code and a message.""" fmt = 'The path <q>%s</q> was not understood by this server.' msg = fmt % (self.parsed_uri,) openid_url = self.query.get('openid_url') return self.render(msg, 'error', openid_url, status='404 Not Found')
def not_found(self): """Render a page with a 404 return code and a message.""" fmt = 'The path <q>%s</q> was not understood by this server.' msg = fmt % (self.parsed_uri,) openid_url = self.query.get('openid_url') return self.render(msg, 'error', openid_url, status='404 Not Found')
32,919
def render(self, message=None, css_class='alert', form_contents=None, status='200 OK', title="Python OpenID Consumer"): """Render a page.""" response_headers = [('Content-type', 'text/html')] self.start(str(status), response_headers)
def render(self, message=None, css_class='alert', form_contents=None, status='200 OK', title="Python OpenID Consumer"): """Render a page.""" response_headers = [('Content-type', 'text/html')] self.start(str(status), response_headers)
32,920
def render(self, message=None, css_class='alert', form_contents=None, status='200 OK', title="Python OpenID Consumer"): """Render a page.""" response_headers = [('Content-type', 'text/html')] self.start(str(status), response_headers)
def render(self, message=None, css_class='alert', form_contents=None, status='200 OK', title="Python OpenID Consumer"): """Render a page.""" response_headers = [('Content-type', 'text/html')] self.start(str(status), response_headers)
32,921
def page_header(self, title): """Render the page header""" self.body.append('''\
def page_header(self, title): """Render the page header""" self.body.append('''\
32,922
def page_footer(self, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
def page_footer(self, request, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
32,923
def page_footer(self, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
def page_footer(self, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
32,924
def page_footer(self, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
def page_footer(self, form_contents): """Render the page footer""" if not form_contents: form_contents = ''
32,925
def __call__(self, environ, start_response): value = event.raise_event('call', self, environ, start_response) if value is not event.Continue: status, headers, app_iter = value start_response(status, headers) return app_iter self.environ = environ self.config = self.environ['paste.config'] if self.config.get('app_name')...
def __call__(self, environ, start_response): value = event.raise_event('call', self, environ, start_response) if value is not event.Continue: status, headers, app_iter = value start_response(status, headers) return app_iter self.environ = environ self.config = self.environ['paste.config'] if self.config.get('app_name')...
32,926
def title__get(self): return self.__class__.__name__
def title__get(self): return self.__class__.__name__
32,927
def title__set(self, value): # Get rid of the property: self.__dict__['title'] = value
def title__set(self, value): # Get rid of the property: self.__dict__['title'] = value
32,928
def handle_exception(exc_info, error_stream, html=True, debug_mode=False, error_email=None, error_log=None, show_exceptions_in_wsgi_errors=False, error_email_from='errors@localhost', smtp_server='localhost', error_subject_prefix='', error_message=None, simple_html_error=False, ): """ For exception handling outside of a...
def handle_exception(exc_info, error_stream, html=True, debug_mode=False, error_email=None, error_log=None, show_exceptions_in_wsgi_errors=False, error_email_from='errors@localhost', smtp_server='localhost', error_subject_prefix='', error_message=None, simple_html_error=False, ): """ For exception handling outside of a...
32,929
def __init__(self, applications, catch=(404,)): self.apps = applications self.catch_codes = {} self.catch_exceptions = [] for error in catch: if isinstance(error, str): error = int(error.split(None, 1)) if isinstance(error, httpexceptions.HTTPException): exc = error code = error.code else: exc = httpexceptions.get_exce...
def __init__(self, applications, catch=(404,)): self.apps = applications self.catch_codes = {} self.catch_exceptions = [] for error in catch: if isinstance(error, str): error = int(error.split(None, 1)[0]) if isinstance(error, httpexceptions.HTTPException): exc = error code = error.code else: exc = httpexceptions.get_e...
32,930
def installer(name): mkdirs(THIRD + "/" + name +"-files") cmd = '%s setup.py install -f --install-lib="%s/%s-files" --install-scripts="%s/%s-files/scripts" --no-compile' % (sys.executable, THIRD, name, THIRD, name) print cmd os.system(cmd)
def installer(name): mkdirs(THIRD + "/" + name +"-files") cmd = '%s setup.py install -f --install-lib="%s/%s-files" --install-scripts="%s/%s-files/scripts" --no-compile' % (sys.executable, THIRD, name, THIRD, name) print cmd os.system(cmd)
32,931
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
32,932
def add_slash(self, environ, start_response): """ This happens when you try to get to a directory without a trailing / """ url = request.construct_url(environ, with_query_string=False) url += '/' if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] exc = httpexceptions.HTTPMovedPermanently( 'The resourc...
def add_slash(self, environ, start_response): """ This happens when you try to get to a directory without a trailing / """ url = request.construct_url(environ, with_query_string=False) url += '/' if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] exc = httpexceptions.HTTPMovedPermanently( 'The resourc...
32,933
def add_slash(self, environ, start_response): """ This happens when you try to get to a directory without a trailing / """ url = request.construct_url(environ, with_query_string=False) url += '/' if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] exc = httpexceptions.HTTPMovedPermanently( 'The resourc...
def add_slash(self, environ, start_response): """ This happens when you try to get to a directory without a trailing / """ url = request.construct_url(environ, with_query_string=False) url += '/' if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] exc = httpexceptions.HTTPMovedPermanently( 'The resourc...
32,934
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,935
def command(self): any = False app_template_dir = os.path.join(os.path.dirname(__file__), 'app_templates') for name in os.listdir(app_template_dir): dir = os.path.join(app_template_dir, name) if not os.path.exists(os.path.join(dir, 'description.txt')): if self.options.verbose >= 2: print 'Skipping %s (no description.tx...
def command(self): any = False app_template_dir = os.path.join(os.path.dirname(__file__), 'app_templates') for name in os.listdir(app_template_dir): dir = os.path.join(app_template_dir, name) if not os.path.exists(os.path.join(dir, 'description.txt')): if self.options.verbose >= 2: print 'Skipping %s (no description.tx...
32,936
def command(self): any = False app_template_dir = os.path.join(os.path.dirname(__file__), 'app_templates') for name in os.listdir(app_template_dir): dir = os.path.join(app_template_dir, name) if not os.path.exists(os.path.join(dir, 'description.txt')): if self.options.verbose >= 2: print 'Skipping %s (no description.tx...
def command(self): any = False app_template_dir = os.path.join(os.path.dirname(__file__), 'app_templates') for name in os.listdir(app_template_dir): dir = os.path.join(app_template_dir, name) if not os.path.exists(os.path.join(dir, 'description.txt')): if self.options.verbose >= 2: print 'Skipping %s (no description.tx...
32,937
def template_description(self): f = open(os.path.join(self.template_dir, 'description.txt')) content = f.read().strip() f.close() return content
def template_description(self, dir): f = open(os.path.join(dir, 'description.txt')) content = f.read().strip() f.close() return content
32,938
def __call__(self, environ, start_response): body = "<html><body>simple</body></html>" start_response("200 OK",[('Content-Type','text/html'), ('Content-Length',len(body))]) return [body]
def __call__(self, environ, start_response): length = environ.get('CONTENT_LENGTH', 0) if length and int(length) > self.threshold: self.monitor.append(environ) environ[ENVIRON_RECEIVED] = 0 environ[REQUEST_STARTED] = time.time() environ[REQUEST_FINISHED] = None environ['wsgi.input'] = \ _ProgressFile(environ, environ[...
32,939
def __call__(self, environ, start_response): body = "<html><body>simple</body></html>" start_response("200 OK",[('Content-Type','text/html'), ('Content-Length',len(body))]) return [body]
def __call__(self, environ, start_response): body = "<html><body>simple</body></html>" start_response("200 OK",[('Content-Type','text/html'), ('Content-Length',len(body))]) return [body]
32,940
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,941
def / name
def / name
32,942
def Usage(): """ ----------------------------------------------------------------------------- PySourceColor.py ver: %s ----------------------------------------------------------------------------- Module summary: This module is designed to colorize python source code. Input--->python source Output-->colorized (html, h...
def Usage(): doc = """ ----------------------------------------------------------------------------- PySourceColor.py ver: %s ----------------------------------------------------------------------------- Module summary: This module is designed to colorize python source code. Input--->python source Output-->colorized (h...
32,943
def Usage(): """ ----------------------------------------------------------------------------- PySourceColor.py ver: %s ----------------------------------------------------------------------------- Module summary: This module is designed to colorize python source code. Input--->python source Output-->colorized (html, h...
def Usage(): """ ----------------------------------------------------------------------------- PySourceColor.py ver: %s ----------------------------------------------------------------------------- Module summary: This module is designed to colorize python source code. Input--->python source Output-->colorized (html, h...
32,944
def _doXHTMLEnd(self): self._doCSSEnd()
def _doXHTMLEnd(self): self._doCSSEnd()
32,945
def normalize_headers(response_headers, strict=True): """ sort headers as suggested by RFC 2616 This alters the underlying response_headers to use the common name for each header; as well as sorting them with general headers first, followed by request/response headers, then entity headers, and unknown headers last. "...
def normalize_headers(response_headers, strict=True): """ sort headers as suggested by RFC 2616 This alters the underlying response_headers to use the common name for each header; as well as sorting them with general headers first, followed by request/response headers, then entity headers, and unknown headers last. "...
32,946
def next(self): try: return self.app_iter.next() except StopIteration: if self.ok_callback: self.ok_callback() raise except self.catch: if hasattr(self.app_iterable, 'close'): try: self.app_iterable.close() except: # @@: Print to wsgi.errors? pass new_app_iterable = self.error_callback_app( self.environ, self.start_res...
def next(self): try: return self.app_iter.next() except StopIteration: if self.ok_callback: self.ok_callback() raise except self.catch: if hasattr(self.app_iterable, 'close'): try: self.app_iterable.close() except: # @@: Print to wsgi.errors? pass new_app_iterable = self.error_callback_app( self.environ, self.start_res...
32,947
def _add_positional(self, args): raise NotImplementedError
def _add_positional(self, args): raise NotImplementedError
32,948
def _html_attrs(self): attrs = self.attrs.items() attrs.insert(0, ('href', self.href)) if self.params.get('confirm'): attrs.append(('onclick', 'return prompt(%r)' % js_repr(self.params['confirm']))) return attrs
def _html_attrs(self): attrs = self.attrs.items() attrs.insert(0, ('href', self.href)) if self.params.get('confirm'): attrs.append(('onclick', 'return prompt(%s)' % js_repr(self.params['confirm']))) return attrs
32,949
def onclick_goto__get(self): return 'location.href=%r; return false' % js_repr(self.href)
def onclick_goto__get(self): return 'location.href=%r; return false' % js_repr(self.href)
32,950
def serve(conf, app): replacements = {} replacements['default_config_fn'] = os.path.abspath( server.default_config_fn) # Ideally, other_conf should be any options that came from the # command-line. # @@: This assumes too much about the ordering of namespaces. other_conf = dict(conf.namespaces[-2]) # Not a good idea to...
def serve(conf, app): replacements = {} replacements['default_config_fn'] = os.path.abspath( server.default_config_fn) # Ideally, other_conf should be any options that came from the # command-line. # @@: This assumes too much about the ordering of namespaces. other_conf = dict(conf.namespaces[-2]) # Not a good idea to...
32,951
def __init__ (self, *args, **kwargs): self.prefix = prefix self.app_obj = application SWAP.__init__(self, *args, **kwargs)
def __init__ (self, *args, **kwargs): self.prefix = prefix self.app_obj = application SWAP.__init__(self, *args, **kwargs)
32,952
def __init__(self, script, path=None, include_os_environ=True, query_string=None): self.script_filename = script if isinstance(path, (str, unicode)): path = [path] if path is None: path = os.environ.get('PATH', '').split(':') self.path = path if os.path.abspath(script) != script: # relative path for path_dir in self.pa...
def __init__(self, script, path=None, include_os_environ=True, query_string=None): self.script_filename = script if isinstance(path, (str, unicode)): path = [path] if path is None: path = os.environ.get('PATH', '').split(':') self.path = path if os.path.abspath(script) != script: # relative path for path_dir in self.pa...
32,953
def __call__(self, environ, start_response): if 'REQUEST_URI' not in environ: environ['REQUEST_URI'] = ( environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')) if self.include_os_environ: cgi_environ = os.environ.copy() else: cgi_environ = {} for name in environ: # Should unicode values be encoded? if (name.upp...
def __call__(self, environ, start_response): if 'REQUEST_URI' not in environ: environ['REQUEST_URI'] = ( environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')) if self.include_os_environ: cgi_environ = os.environ.copy() else: cgi_environ = {} for name in environ: # Should unicode values be encoded? if (name.upp...
32,954
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None): """ Define a cookie to be sent via the outgoing HTTP headers """ self.cookies[key] = value for var_name, var_value in [ ('max_age', max_age), ('path', path), ('domain', domain), ('secure', secure), ('expires', expires)]...
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None): """ Define a cookie to be sent via the outgoing HTTP headers """ self.cookies[key] = value for var_name, var_value in [ ('max_age', max_age), ('path', path), ('domain', domain), ('secure', secure), ('expires', expires)]...
32,955
def error_body_response(error_code, message, __warn=True): """ Returns a standard HTML response page for an HTTP error. **Note:** Deprecated """ if __warn: warnings.warn( 'wsgilib.error_body_response is deprecated; use the ' 'wsgi_application method on an HTTPException object ' 'instead', DeprecationWarning, 1) return ...
def error_body_response(error_code, message, __warn=True): """ Returns a standard HTML response page for an HTTP error. **Note:** Deprecated """ if __warn: warnings.warn( 'wsgilib.error_body_response is deprecated; use the ' 'wsgi_application method on an HTTPException object ' 'instead', DeprecationWarning, 2) return ...
32,956
def error_response(environ, error_code, message, debug_message=None, __warn=True): """ Returns the status, headers, and body of an error response. Use like:: status, headers, body = wsgilib.error_response( '301 Moved Permanently', 'Moved to <a href="%s">%s</a>' % (url, url)) start_response(status, headers) return [bo...
def error_response(environ, error_code, message, debug_message=None, __warn=True): """ Returns the status, headers, and body of an error response. Use like:: status, headers, body = wsgilib.error_response( '301 Moved Permanently', 'Moved to <a href="%s">%s</a>' % (url, url)) start_response(status, headers) return [bo...
32,957
def make_static(global_conf, document_root, cache_max_age=None): """ 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_...
def make_static(global_conf, document_root, cache_max_age=None): """ 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...
32,958
def change_response(status, headers, exc_info=None): status_code = status.split(' ') try: code = int(status_code[0]) except ValueError, TypeError: raise Exception( 'StatusBasedForward middleware ' 'received an invalid status code %s'%repr(status_code[0]) ) message = ' '.join(status_code[1:]) new_url = self.mapper( cod...
def change_response(status, headers, exc_info=None): status_code = status.split(' ') try: code = int(status_code[0]) except ValueError, TypeError: raise Exception( 'StatusBasedForward middleware ' 'received an invalid status code %s'%repr(status_code[0]) ) message = ' '.join(status_code[1:]) new_url = self.mapper( cod...
32,959
def change_response(status, headers, exc_info=None): status_code = status.split(' ') try: code = int(status_code[0]) except ValueError, TypeError: raise Exception( 'StatusBasedForward middleware ' 'received an invalid status code %s'%repr(status_code[0]) ) message = ' '.join(status_code[1:]) new_url = self.mapper( cod...
def change_response(status, headers, exc_info=None): status_code = status.split(' ') try: code = int(status_code[0]) except ValueError, TypeError: raise Exception( 'StatusBasedForward middleware ' 'received an invalid status code %s'%repr(status_code[0]) ) message = ' '.join(status_code[1:]) new_url = self.mapper( cod...
32,960
def get_data_files(relpath, files=None): files = files or [] for name in os.listdir(os.path.join(BASEDIR, relpath)): if name.startswith("."): 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) ...
def get_data_files(relpath, files=None): if files is None: files = [] for name in os.listdir(os.path.join(BASEDIR, relpath)): if name.startswith("."): 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.ap...
32,961
def get_data_files(relpath, files=None): files = files or [] for name in os.listdir(os.path.join(BASEDIR, relpath)): if name.startswith("."): 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) ...
defget_data_files(relpath,files=None):files=filesor[]fornameinos.listdir(os.path.join(BASEDIR,relpath)):ifname.startswith("."):continuefn=os.path.join(relpath,name)ifos.path.isdir(os.path.join(BASEDIR,fn)):get_data_files(fn,files)elifos.path.isfile(os.path.join(BASEDIR,fn)):files.append(fn)returnfiles
32,962
def __init__(self, start_response, compress_level): self.start_response = start_response self.compress_level = compress_level self.buffer = StringIO() self.compressible = False self.headers = None
def __init__(self, start_response, compress_level): self.start_response = start_response self.compress_level = compress_level self.buffer = StringIO() self.compressible = False self.headers = None
32,963
def gzip_start_response(self, status, headers, exc_info=None): self.headers = headers ct = header_value(headers,'content-type') ce = header_value(headers,'content-encoding') self.compressible = False if (ct.startswith('text') or ct.startswith('application')) \ and not 'z' in ct: self.compressible = True if ce: self.com...
def gzip_start_response(self, status, headers, exc_info=None): self.headers = headers ct = header_value(headers,'content-type') ce = header_value(headers,'content-encoding') self.compressible = False if (ct.startswith('text') or ct.startswith('application')) \ and not 'z' in ct: self.compressible = True if ce: self.com...
32,964
def write(self): out = self.buffer out.seek(0) s = out.getvalue() out.close() if self.compressible and self.headers is not None: CONTENT_LENGTH.update(self.headers, str(len(s))) return [s]
def write(self): out = self.buffer out.seek(0) s = out.getvalue() out.close() return [s]
32,965
def serve(conf, app): prefix = conf.get('scgi_prefix', '/') serve_application(app, prefix, port=int(conf.get('port', 4000)))
def serve(conf, app): prefix = conf.get('root_url', '') while prefix.endswith('/'): prefix = prefix[:-1] serve_application(app, prefix, port=int(conf.get('port', 4000)))
32,966
def __setattr__(self, attr, value): setattr(self.current_obj(), name, value)
def __setattr__(self, attr, value): setattr(self.current_obj(), attr, value)
32,967
def activate(self, environ): response = IncludedResponse def start_response(status, headers, exc_info=None): if exc_info: raise exc_info[0], exc_info[1], exc_info[2] response.status = status response.headers = headers return response.write app_iter = self.application(environ, start_response) try: for s in app_iter: res...
def activate(self, environ): response = IncludedResponse() def start_response(status, headers, exc_info=None): if exc_info: raise exc_info[0], exc_info[1], exc_info[2] response.status = status response.headers = headers return response.write app_iter = self.application(environ, start_response) try: for s in app_iter: r...
32,968
def write(self): assert self.output is not None, ( "This response has already been closed and no further data " "can be written.") self.output.write()
def write(self, s): assert self.output is not None, ( "This response has already been closed and no further data " "can be written.") self.output.write()
32,969
def write(self): assert self.output is not None, ( "This response has already been closed and no further data " "can be written.") self.output.write()
def write(self): assert self.output is not None, ( "This response has already been closed and no further data " "can be written.") self.output.write()
32,970
def forward(app, codes): for code in codes: if not isinstance(code, int): raise TypeError('All status codes should be type int. ' '%s is not valid'%repr(code)) def error_codes_mapper(code, message, environ, global_conf, codes): if codes.has_key(code): return codes[code] else: return None return custom_forward(app, erro...
def forward(app, codes): for code in codes: if not isinstance(code, int): raise TypeError('All status codes should be type int. ' '%s is not valid'%repr(code)) def error_codes_mapper(code, message, environ, global_conf, codes): if codes.has_key(code): return codes[code] else: return None return custom_forward(app, erro...
32,971
def replacement_app(environ, start_response): status, headers, body = capture_output( environ, application, lambda s, h: header_value(headers, 'content-type').startswith('text/html'), start_response) if status is None: return body body = re.sub(r'<.*?>', '', body) return [body]
def replacement_app(environ, start_response): status, headers, body = intercept_output( environ, application, lambda s, h: header_value(headers, 'content-type').startswith('text/html'), start_response) if status is None: return body body = re.sub(r'<.*?>', '', body) return [body]
32,972
def is_xhr(self): """Returns a boolean if X-Requested-With is present and a XMLHttpRequest""" return self.environ.get('X-Requested-With', '') == 'XMLHttpRequest'
def is_xhr(self): """Returns a boolean if X-Requested-With is present and a XMLHttpRequest""" return self.environ.get('X-Requested-With', '') == 'XMLHttpRequest'
32,973
def read_properties(self): props = self.properties = {} m = self._title_re.search(self.html) if m: props['title'] = m.group(1) else: print 'No title in %s' % self.filename props['title'] = ''
def read_properties(self): props = self.properties = {} m = self._title_re.search(self.html) if m: props['title'] = m.group(1) else: print 'No title in %s' % self.filename props['title'] = ''
32,974
def __init__(self, not_found_app=None): self.applications = [] self.not_found_application = self.not_found_app
def __init__(self, not_found_app=None): self.applications = [] self.not_found_application = self.not_found_app
32,975
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,976
def __call__(self, environ, start_response): scheme = environ['wsgi.url_scheme'] if self.force_host is None: conn_scheme = scheme else: conn_scheme = self.force_scheme if conn_scheme == 'http': ConnClass = httplib.HTTPConnection elif conn_scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "U...
def __call__(self, environ, start_response): scheme = environ['wsgi.url_scheme'] if self.force_host is None: conn_scheme = scheme else: conn_scheme = self.force_scheme if conn_scheme == 'http': ConnClass = httplib.HTTPConnection elif conn_scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "U...
32,977
def headers(self): """Access to incoming headers""" # @@ Just needs a header table object headertable = someheaderdict for key in self.environ.keys(): if key.startswith('HTTP'): headertable.add(key[5:], self.environ[key]) return headertable
def headers(self): """Access to incoming headers""" # @@ Just needs a header table objectheadertable = {} for key in self.environ.keys(): if key.startswith('HTTP'): headertable.add(key[5:], self.environ[key]) return headertable
32,978
def headers(self): """Access to incoming headers""" # @@ Just needs a header table object headertable = someheaderdict for key in self.environ.keys(): if key.startswith('HTTP'): headertable.add(key[5:], self.environ[key]) return headertable
def headers(self): """Access to incoming headers""" # @@ Just needs a header table object headertable = someheaderdict for key in self.environ.keys(): if key.startswith('HTTP'): headertable[key[5:]] = self.environ[key] return headertable
32,979
def headers(self): """Access to incoming headers""" # @@ Just needs a header table object headertable = someheaderdict for key in self.environ.keys(): if key.startswith('HTTP'): headertable.add(key[5:], self.environ[key]) return headertable
def headers(self): """Access to incoming headers""" # @@ Just needs a header table object headertable = someheaderdict for key in self.environ.keys(): if key.startswith('HTTP'): headertable.add(key[5:], self.environ[key]) return headertable
32,980
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
32,981
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
def _parse_fields(self): in_select = None in_textarea = None fields = {} for match in self._tag_re.finditer(self.text): end = match.group(1) == '/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): continue if tag == 'select' and end: assert in_select, ( '%r without startin...
32,982
def submit_fields(self, name=None, index=None): """ Return a list of ``[(name, value), ...]`` for the current state of the form. """ submit = [] if name is not None: field = self.get(name, index=index) submit.append((field.name, field.value_if_submitted())) for name, fields in self.fields.items(): for field in fields: ...
def submit_fields(self, name=None, index=None): """ Return a list of ``[(name, value), ...]`` for the current state of the form. """ submit = [] if name is not None: field = self.get(name, index=index) submit.append((field.name, field.value_if_submitted())) for name, fields in self.fields.items(): for field in fields: ...
32,983
def __init__(self, *args, **attrs): super(Checkbox, self).__init__(*args, **attrs) self.checked = attrs.get('checked') is not None
def __init__(self, *args, **attrs): super(Checkbox, self).__init__(*args, **attrs) self.checked = attrs.get('checked') is not None
32,984
def __init__(self, environ, cookie_name='_SID_', session_class=None, **session_class_kw): self.created = False self.used = False self.environ = environ self.cookie_name = cookie_name self.session = None self.session_class = session_class or FileSession self.session_class_kw = session_class_kw
def __init__(self, environ, cookie_name='_SID_', session_class=None, expiration=60*12, **session_class_kw): self.created = False self.used = False self.environ = environ self.cookie_name = cookie_name self.session = None self.session_class = session_class or FileSession self.session_class_kw = session_class_kw
32,985
def close(self): if self.session is not None: self.session.close()
def close(self): if self.session is not None: self.session.close()
32,986
def __init__(self, sid, create=False, session_file_path='/tmp', chmod=None): if chmod and isinstance(chmod, basestring): chmod = int(chmod, 8) self.chmod = chmod if not sid: # Invalid... raise KeyError self.session_file_path = session_file_path self.sid = sid if not create: if not os.path.exists(self.filename()): raise...
def __init__(self, sid, create=False, session_file_path='/tmp', chmod=None, expiration=2880, ): if chmod and isinstance(chmod, basestring): chmod = int(chmod, 8) self.chmod = chmod if not sid: # Invalid... raise KeyError self.session_file_path = session_file_path self.sid = sid if not create: if not os.path.exists(self...
32,987
def __init__(self, address): self.address = address self.parsed = urlparse.urlsplit(address) self.scheme = self.parsed[0].lower() self.host = self.parsed[1]
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]
32,988
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
32,989
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
32,990
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
32,991
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
def __call__(self, environ, start_response): if self.scheme == 'http': ConnClass = httplib.HTTPConnection elif self.scheme == 'https': ConnClass = httplib.HTTPSConnection else: raise ValueError( "Unknown scheme for %r: %r" % (self.address, self.scheme)) conn = ConnClass(self.host) headers = {} for key, value in environ...
32,992
def __call__(self, environ, start_response): if 'gzip' not in environ.get('HTTP_ACCEPT_ENCODING'): # nothing for us to do, so this middleware will # be a no-op: return self.application(environ, start_response) response = GzipResponse(start_response, self.compress_level) app_iter = self.application(environ, response.gzi...
def __call__(self, environ, start_response): if 'gzip' not in environ.get('HTTP_ACCEPT_ENCODING', ''): # nothing for us to do, so this middleware will # be a no-op: return self.application(environ, start_response) response = GzipResponse(start_response, self.compress_level) app_iter = self.application(environ, response...
32,993
def update(self, dict): if isinstance(dct, UserDict): self.data.update(dict.data) elif isinstance(dict, type(self.data)): self.data.update(dict) else: for k, v in dict.items(): if self.has_key(k) and isinstance(v, list): self[k].extend(v) elif self.has_key(k): self[k].append(v) elif not isinstance(v, list): self[k] = [...
def update(self, dict): if isinstance(dct, UserDict): self.data.update(dict.data) elif isinstance(dict, type(self.data)): self.data.update(dict) else: for k, v in dict.items(): if self.has_key(k) and isinstance(v, list): self[k].extend(v) elif self.has_key(k): self[k].append(v) elif not isinstance(v, list): self[k] = [...
32,994
def get_cookies(environ): """ Gets a cookie object (which is a dictionary-like object) from the request environment; caches this value in case get_cookies is called again for the same request. """ header = environ.get('HTTP_COOKIE', '') if environ.has_key('paste.cookies'): cookies, check_header = environ['paste.cookie...
def get_cookies(environ): """ Gets a cookie object (which is a dictionary-like object) from the request environment; caches this value in case get_cookies is called again for the same request. """ header = environ.get('HTTP_COOKIE', '') if environ.has_key('paste.cookies'): cookies, check_header = environ['paste.cookie...
32,995
def parse_querystring(environ): """ Parses a query string into a list like ``[(name, value)]``. Caches this value in case parse_querystring is called again for the same request. You can pass the result to ``dict()``, but be aware that keys that appear multiple times will be lost (only the last value will be preserved)...
def parse_querystring(environ): """ Parses a query string into a list like ``[(name, value)]``. Caches this value in case parse_querystring is called again for the same request. You can pass the result to ``dict()``, but be aware that keys that appear multiple times will be lost (only the last value will be preserved)...
32,996
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
32,997
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
32,998
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
def parse_dict_querystring(environ): """Parses a query string like parse_querystring, but returns a multidict Caches this value in case parse_dict_querystring is called again for the same request. Example:: #environ['QUERY_STRING'] - day=Monday&user=fred&user=jane >>> parsed = parse_dict_querystring(environ) >>> p...
32,999