# 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
        if initial is not None:
            field_kwargs['initial'] = initial
        field = getattr(forms, field)
        return field(**field_kwargs)

    def get_group_forms(self, model=None, pk=None, initial=None):
        pk = int(pk) if pk is not None else pk
        if pk is not None and pk in self.djangui_forms:
            if 'groups' in self.djangui_forms[pk]:
                return copy.deepcopy(self.djangui_forms[pk]['groups'])
        params = ScriptParameter.objects.filter(script=model).order_by('pk')
        # set a reference to the object type for POST methods to use
        script_id_field = forms.CharField(widget=forms.HiddenInput)
        group_map = {}
        for param in params:
            field = self.get_field(param, initial=initial.get(param.slug) if initial else None)
            group_id = -1 if param.required else param.parameter_group.pk
            group_name = 'Required' if param.required else param.parameter_group.group_name
            group = group_map.get(group_id, {
                'group': group_name,
                'fields': OrderedDict()
            })
            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)):

# 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

        if initial is not None:
            field_kwargs['initial'] = initial
        field = getattr(forms, field)
        return field(**field_kwargs)

    def get_group_forms(self, model=None, pk=None, initial=None):
        pk = int(pk) if pk is not None else pk
        if pk is not None and pk in self.djangui_forms:
            if 'groups' in self.djangui_forms[pk]:
                return copy.deepcopy(self.djangui_forms[pk]['groups'])
        params = ScriptParameter.objects.filter(script=model).order_by('pk')
        # set a reference to the object type for POST methods to use
        script_id_field = forms.CharField(widget=forms.HiddenInput)
        group_map = {}
        for param in params:
            field = self.get_field(param, initial=initial.get(param.slug) if initial else None)
            group_id = -1 if param.required else param.parameter_group.pk
            group_name = 'Required' if param.required else param.parameter_group.group_name
            group = group_map.get(group_id, {
                'group': group_name,
                'fields': OrderedDict()
            })
            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