# Path: djangui/forms/scripts.py
# class DjanguiForm(forms.Form):
# 
#     def add_djangui_fields(self):
#         # This adds fields such as job name, description that we like to validate on but don't want to include in
#         # form rendering
#         self.fields['job_name'] = forms.CharField()
#         self.fields['job_description'] = forms.CharField(required=False)
# 
# Path: djangui/backend/utils.py
# def sanitize_name(name):
# def sanitize_string(value):
# def get_storage(local=True):
# def get_job_commands(job=None):
# def create_djangui_job(user=None, script_pk=None, data=None):
# def get_master_form(model=None, pk=None):
# def get_form_groups(model=None, pk=None, initial=None):
# def validate_form(form=None, data=None, files=None):
# def load_scripts():
# def get_storage_object(path, local=False):
# def add_djangui_script(script=None, group=None):
# def valid_user(obj, user):
# def mkdirs(path):
# def get_file_info(filepath):
# def test_delimited(filepath):
# def test_fastx(filepath):
# def create_job_fileinfo(job):
# def get_file_previews(job):
#     CHOICE_MAPPING = {
# 
#     }


import copy
import json
import six
from collections import OrderedDict
from django import forms
from .scripts import DjanguiForm
from ..backend import utils
from ..models import ScriptParameter
            group['fields'][param.slug] = field
            group_map[group_id] = group
        # create individual forms for each group
        group_map = OrderedDict([(i, group_map[i]) for i in sorted(group_map.keys())])
        d = {'action': model.get_url()}
        d['groups'] = []
        pk = model.pk
        for group_index, group in enumerate(six.iteritems(group_map)):
            group_pk, group_info = group
            form = DjanguiForm()
            if group_index == 0:
                form.fields['djangui_type'] = script_id_field
                form.fields['djangui_type'].initial = pk
            for field_pk, field in six.iteritems(group_info['fields']):
                form.fields[field_pk] = field
            d['groups'].append({'group_name': group_info['group'], 'form': str(form)})
        try:
            self.djangui_forms[pk]['groups'] = d
        except KeyError:
            self.djangui_forms[pk] = {'groups': d}
        # if the master form doesn't exist, create it while we have the model
        if 'master' not in self.djangui_forms[pk]:
            self.get_master_form(model=model, pk=pk)
        return d

    def get_master_form(self, model=None, pk=None):
        pk = int(pk) if pk is not None else pk
        if pk is not None and pk in self.djangui_forms:
            if 'master' in self.djangui_forms[pk]:
                return copy.deepcopy(self.djangui_forms[pk]['master'])

# Path: djangui/forms/scripts.py
# class DjanguiForm(forms.Form):
# 
#     def add_djangui_fields(self):
#         # This adds fields such as job name, description that we like to validate on but don't want to include in
#         # form rendering
#         self.fields['job_name'] = forms.CharField()
#         self.fields['job_description'] = forms.CharField(required=False)
# 
# Path: djangui/backend/utils.py
# def sanitize_name(name):
# def sanitize_string(value):
# def get_storage(local=True):
# def get_job_commands(job=None):
# def create_djangui_job(user=None, script_pk=None, data=None):
# def get_master_form(model=None, pk=None):
# def get_form_groups(model=None, pk=None, initial=None):
# def validate_form(form=None, data=None, files=None):
# def load_scripts():
# def get_storage_object(path, local=False):
# def add_djangui_script(script=None, group=None):
# def valid_user(obj, user):
# def mkdirs(path):
# def get_file_info(filepath):
# def test_delimited(filepath):
# def test_fastx(filepath):
# def create_job_fileinfo(job):
# def get_file_previews(job):
#     CHOICE_MAPPING = {
# 
#     }


# Path: djangui/forms/factory.py
import copy
import json
import six
from collections import OrderedDict
from django import forms
from .scripts import DjanguiForm
from ..backend import utils
from ..models import ScriptParameter

            group['fields'][param.slug] = field
            group_map[group_id] = group
        # create individual forms for each group
        group_map = OrderedDict([(i, group_map[i]) for i in sorted(group_map.keys())])
        d = {'action': model.get_url()}
        d['groups'] = []
        pk = model.pk
        for group_index, group in enumerate(six.iteritems(group_map)):
            group_pk, group_info = group
            form = DjanguiForm()
            if group_index == 0:
                form.fields['djangui_type'] = script_id_field
                form.fields['djangui_type'].initial = pk
            for field_pk, field in six.iteritems(group_info['fields']):
                form.fields[field_pk] = field
            d['groups'].append({'group_name': group_info['group'], 'form': str(form)})
        try:
            self.djangui_forms[pk]['groups'] = d
        except KeyError:
            self.djangui_forms[pk] = {'groups': d}
        # if the master form doesn't exist, create it while we have the model
        if 'master' not in self.djangui_forms[pk]:
            self.get_master_form(model=model, pk=pk)
        return d

    def get_master_form(self, model=None, pk=None):
        pk = int(pk) if pk is not None else pk
        if pk is not None and pk in self.djangui_forms:
            if 'master' in self.djangui_forms[pk]:
                return copy.deepcopy(self.djangui_forms[pk]['master'])

        master_form = DjanguiForm()