Exemplo n.º 1
0
def create_survey_from_path(path):
    """
    I think this should be phased out. [AD]
    """
    directory, file_name = os.path.split(path)
    main_section_name = file_utils._section_name(file_name)
    sections = file_utils.collect_compatible_files_in_directory(directory)
    pkg = {
        u'title': main_section_name,
        u'name_of_main_section': main_section_name,
        u'sections': sections
    }
    return create_survey(**pkg)
Exemplo n.º 2
0
def create_survey_from_path(path, include_directory=False):
    """
    include_directory -- Switch to indicate that all the survey forms in the
                         same directory as the specified file should be read
                         so they can be included through include types.
    @see: create_survey
    """
    directory, file_name = os.path.split(path)
    if include_directory:
        main_section_name = file_utils._section_name(file_name)
        sections = file_utils.collect_compatible_files_in_directory(directory)
    else:
        main_section_name, section = file_utils.load_file_to_dict(path)
        sections = {main_section_name: section}
    pkg = {u'name_of_main_section': main_section_name, u'sections': sections}

    return create_survey(**pkg)
Exemplo n.º 3
0
def create_survey_from_path(path, include_directory=False):
    """
    include_directory -- Switch to indicate that all the survey forms in the
                         same directory as the specified file should be read
                         so they can be included through include types.
    @see: create_survey
    """
    directory, file_name = os.path.split(path)
    if include_directory:
        main_section_name = file_utils._section_name(file_name)
        sections = file_utils.collect_compatible_files_in_directory(directory)
    else:
        main_section_name, section = file_utils.load_file_to_dict(path)
        sections = {main_section_name: section}
    pkg = {
        u'name_of_main_section': main_section_name,
        u'sections': sections
        }

    return create_survey(**pkg)