# Path: OGRgeoConverter/filesystem/filemanager.py
# def store_uploaded_file(job_id, file_data, file_name):
# def rename_file(folder_path, old_file_name, new_file_name):
# def create_job_folders(job_id):
# def remove_old_folders():
# def get_file_count(folder_path):
# def get_conversion_job_folder():
# def get_folder_path(job_id):
# def get_upload_folder_path(job_id):
# def get_extract_folder_path(job_id):
# def get_output_folder_path(job_id):
# def get_download_folder_path(job_id):
# def get_download_file_path(job_id):
# def download_file_exists(job_id):
# 
# Path: OGRgeoConverter/models.py
# class DownloadItem(models.Model):
#     job_identifier = models.ForeignKey(JobIdentifier)
# 
#     download_caption = models.CharField(max_length=100)
#     is_downloaded = models.BooleanField()
# 
#     class Meta:
#         db_table = 'ogrgeoconverter_conversion_job_download_items'
# 
#     @staticmethod
#     def get_download_item(job_identifier):
#         return DownloadItem.objects.filter(job_identifier=job_identifier)
# 
#     @staticmethod
#     def get_download_items(session_key):
#         return DownloadItem.objects.filter(
#             job_identifier__session_key=session_key).order_by(
#             'job_identifier__creation_time').reverse()


import os
from django.core.servers.basehttp import FileWrapper
from OGRgeoConverter.filesystem import filemanager
from OGRgeoConverter.models import DownloadItem

    download_item_list = []
    for download_item in download_items:
        job_identifier = download_item.job_identifier
        job_id = job_identifier.job_id
        download_caption = download_item.download_caption
        exists = filemanager.download_file_exists(job_identifier.job_id)
        is_downloaded = download_item.is_downloaded
        download_item_list.append(
            (job_id,
             download_caption,
             exists,
             is_downloaded))

    return download_item_list


class DownloadHandler:

    '''
    Class handling download items
    '''

    def __init__(self, job_identifier):
        if job_identifier is not None:
            self.__job_identifier = job_identifier
        else:
            raise Exception("job_identifier may not be None")

    def __get_download_item_query_set(self):

# Path: OGRgeoConverter/filesystem/filemanager.py
# def store_uploaded_file(job_id, file_data, file_name):
# def rename_file(folder_path, old_file_name, new_file_name):
# def create_job_folders(job_id):
# def remove_old_folders():
# def get_file_count(folder_path):
# def get_conversion_job_folder():
# def get_folder_path(job_id):
# def get_upload_folder_path(job_id):
# def get_extract_folder_path(job_id):
# def get_output_folder_path(job_id):
# def get_download_folder_path(job_id):
# def get_download_file_path(job_id):
# def download_file_exists(job_id):
# 
# Path: OGRgeoConverter/models.py
# class DownloadItem(models.Model):
#     job_identifier = models.ForeignKey(JobIdentifier)
# 
#     download_caption = models.CharField(max_length=100)
#     is_downloaded = models.BooleanField()
# 
#     class Meta:
#         db_table = 'ogrgeoconverter_conversion_job_download_items'
# 
#     @staticmethod
#     def get_download_item(job_identifier):
#         return DownloadItem.objects.filter(job_identifier=job_identifier)
# 
#     @staticmethod
#     def get_download_items(session_key):
#         return DownloadItem.objects.filter(
#             job_identifier__session_key=session_key).order_by(
#             'job_identifier__creation_time').reverse()


# Path: OGRgeoConverter/modelhandlers/downloadhandler.py
import os
from django.core.servers.basehttp import FileWrapper
from OGRgeoConverter.filesystem import filemanager
from OGRgeoConverter.models import DownloadItem


    download_item_list = []
    for download_item in download_items:
        job_identifier = download_item.job_identifier
        job_id = job_identifier.job_id
        download_caption = download_item.download_caption
        exists = filemanager.download_file_exists(job_identifier.job_id)
        is_downloaded = download_item.is_downloaded
        download_item_list.append(
            (job_id,
             download_caption,
             exists,
             is_downloaded))

    return download_item_list


class DownloadHandler:

    '''
    Class handling download items
    '''

    def __init__(self, job_identifier):
        if job_identifier is not None:
            self.__job_identifier = job_identifier
        else:
            raise Exception("job_identifier may not be None")

    def __get_download_item_query_set(self):

        download_items = DownloadItem.get_download_item(self.__job_identifier)