Exemplo n.º 1
0
    def load_headers(self, request, path):
        headers_path = path + ".sub.headers"
        if os.path.exists(headers_path):
            use_sub = True
        else:
            headers_path = path + ".headers"
            use_sub = False

        try:
            with open(headers_path) as headers_file:
                data = headers_file.read()
        except IOError:
            return []
        else:
            data = template(request, data)
            return [tuple(item.strip() for item in line.split(":", 1))
                    for line in data.splitlines() if line]
Exemplo n.º 2
0
    def load_headers(self, request, path):
        headers_path = path + ".sub.headers"
        if os.path.exists(headers_path):
            use_sub = True
        else:
            headers_path = path + ".headers"
            use_sub = False

        try:
            with open(headers_path) as headers_file:
                data = headers_file.read()
        except IOError:
            return []
        else:
            data = template(request, data)
            return [tuple(item.strip() for item in line.split(":", 1))
                    for line in data.splitlines() if line]