# Path: repositories/gae/blobstore.py
# def get_reader(key):
#     if not isinstance(key, str):
#         updated_key = str(urllib.unquote(key))
#     else:
#         updated_key = key
# 
#     return blobstore.BlobReader(updated_key)
# 
# Path: utils/zip_utils.py
# def all_matching_files(zip_reader, filename, pattern):
#     with zip_reader.open(filename) as file_reader:
#         (lno, mno) = (0, 0,)
#         for line in file_reader:
#             found_pattern = pattern.search(line)
#             lno += 1
#             if found_pattern:
#                 mno += 1
#                 yield lno, mno, found_pattern.group(1), found_pattern.group(2)


from google.appengine.ext.webapp import blobstore_handlers
from repositories.gae.blobstore import get_reader
from utils.zip_utils import all_matching_files
import urllib, zipfile, logging, re

url_file_pattern = re.compile('^."id":"([^"]*)","url":"([^"]*)".*')

class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
    def get(self, resource):
        blob_key = str(urllib.unquote(resource))

# Path: repositories/gae/blobstore.py
# def get_reader(key):
#     if not isinstance(key, str):
#         updated_key = str(urllib.unquote(key))
#     else:
#         updated_key = key
# 
#     return blobstore.BlobReader(updated_key)
# 
# Path: utils/zip_utils.py
# def all_matching_files(zip_reader, filename, pattern):
#     with zip_reader.open(filename) as file_reader:
#         (lno, mno) = (0, 0,)
#         for line in file_reader:
#             found_pattern = pattern.search(line)
#             lno += 1
#             if found_pattern:
#                 mno += 1
#                 yield lno, mno, found_pattern.group(1), found_pattern.group(2)


# Path: handlers/gae/server_handler.py
from google.appengine.ext.webapp import blobstore_handlers
from repositories.gae.blobstore import get_reader
from utils.zip_utils import all_matching_files
import urllib, zipfile, logging, re


url_file_pattern = re.compile('^."id":"([^"]*)","url":"([^"]*)".*')

class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
    def get(self, resource):
        blob_key = str(urllib.unquote(resource))

        blob_reader = get_reader(blob_key)