def process_response(self, request, response): if response is d.Http404: return response path = request.path[1:] if path == "favicon.ico" or path.endswith(".png"): return serve(request, path) if path.startswith("theme"): return serve(request, request.path[len("/theme/"):]) if path == "" or path.endswith("/"): path = path + "index.html" if os.path.exists(dotslash(path)) and os.path.isfile(dotslash(path)): return d.render_to_response( path, {}, d.RequestContext(request) ) ajax = read_yaml_file(dotslash("ajax.yaml")) if ajax: if request.GET: path = request.path + "?" + request.META["QUERY_STRING"] # TODO: make it immune to order of GET params if path in ajax: return JSONResponse(ajax[path]) if request.path in ajax: return JSONResponse(ajax[request.path]) if not request.path.endswith("/"): return d.HttpResponseRedirect(request.path + "/") return response
def process_response(self, request, response): if response is d.Http404: return response path = request.path[1:] if path == "favicon.ico" or path.endswith(".png"): return serve(request, path) if path.startswith("theme"): return serve(request, request.path[len("/theme/"):]) if path == "" or path.endswith("/"): path = path + "index.html" if os.path.exists(dotslash(path)) and os.path.isfile(dotslash(path)): return d.render_to_response(path, {}, d.RequestContext(request)) ajax = read_yaml_file(dotslash("ajax.yaml")) if ajax: if request.GET: path = request.path + "?" + request.META["QUERY_STRING"] # TODO: make it immune to order of GET params if path in ajax: return JSONResponse(ajax[path]) if request.path in ajax: return JSONResponse(ajax[request.path]) if not request.path.endswith("/"): return d.HttpResponseRedirect(request.path + "/") return response
def handle(request): path = request.path[1:] if path == "favicon.ico" or path.endswith(".png"): return serve(request, path) if path.startswith("static"): return serve(request, request.path[len("/static/"):]) if path.startswith("theme"): return serve(request, request.path[len("/theme/"):]) if path == "" or path.endswith("/"): path = path + "index.html" if os.path.exists(dotslash(path)) and os.path.isfile(dotslash(path)): return path ajax = read_yaml_file(dotslash("ajax.yaml")) if ajax: if request.GET: path = request.path + "?" + request.META["QUERY_STRING"] # TODO: make it immune to order of GET params if path in ajax: return JSONResponse(ajax[path]) if request.path in ajax: return JSONResponse(ajax[request.path]) if not request.path.endswith("/"): return d.HttpResponseRedirect(request.path + "/") raise d.Http404("File not found.")
def parse_bulk(self, bulk, command_args): # Known keys with special handling cont = False command_args.dry_run = False if "dry_run" in bulk: dry_run = bulk.pop("dry_run") command_args.dry_run = dry_run if "continue" in bulk: cont = True c = bulk.pop("continue") if bool(c): command_args.add("c") if "path" not in bulk: # Required until @file format is implemented self.ctx.die(107, "No path specified") path = bulk.pop("path") cols = None if "columns" in bulk: cols = bulk.pop("columns") if "include" in bulk: bulk.pop("include") # Now parse all other keys for key in bulk: command_args.add(key, bulk[key]) # All properties are set, yield for each path # to be imported in turn. The value for `cont` # is yielded so that the caller knows whether # or not an error should be fatal. if not cols: # No parsing necessary function = self.parse_text else: function = self.parse_shlex if path.endswith(".tsv"): function = self.parse_tsv elif path.endswith(".csv"): function = self.parse_csv for parts in function(path): if not cols: command_args.set_path(parts) else: for idx, col in enumerate(cols): if col == "path": command_args.set_path([parts[idx]]) else: command_args.add(col, parts[idx]) yield cont
def backcompat_paths(cls, path): if path.endswith('.html.xml'): path = path[:-9] + '.html' # backcompat--look for html instead of xml if path.endswith('.html.html'): path = path[:-5] # some people like to include .html in filenames.. candidates = [] while os.sep in path: candidates.append(path) _, _, path = path.partition(os.sep) # also look for .html versions instead of .xml nc = [] for candidate in candidates: if candidate.endswith('.xml'): nc.append(candidate[:-4] + '.html') return candidates + nc
def backcompat_paths(cls, path): dog_stats_api.increment(DEPRECATION_VSCOMPAT_EVENT, tags=["location:html_descriptor_backcompat_paths"]) if path.endswith(".html.xml"): path = path[:-9] + ".html" # backcompat--look for html instead of xml if path.endswith(".html.html"): path = path[:-5] # some people like to include .html in filenames.. candidates = [] while os.sep in path: candidates.append(path) _, _, path = path.partition(os.sep) # also look for .html versions instead of .xml nc = [] for candidate in candidates: if candidate.endswith(".xml"): nc.append(candidate[:-4] + ".html") return candidates + nc
def backcompat_paths(cls, path): dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=["location:html_descriptor_backcompat_paths"]) if path.endswith('.html.xml'): path = path[:-9] + '.html' # backcompat--look for html instead of xml if path.endswith('.html.html'): path = path[: -5] # some people like to include .html in filenames.. candidates = [] while os.sep in path: candidates.append(path) _, _, path = path.partition(os.sep) # also look for .html versions instead of .xml nc = [] for candidate in candidates: if candidate.endswith('.xml'): nc.append(candidate[:-4] + '.html') return candidates + nc