def create_survey_from_fixture(fixture_name, filetype="xls", include_directory=False): fixture_path = path_to_text_fixture("%s.%s" % (fixture_name, filetype)) noop, section_dict = file_utils.load_file_to_dict(fixture_path) pkg = {"main_section": section_dict} if include_directory: directory, noop = os.path.split(fixture_path) pkg["sections"] = file_utils.collect_compatible_files_in_directory(directory) return create_survey(**pkg)
def create_survey_from_fixture(fixture_name, filetype="xls", include_directory=False): fixture_path = path_to_text_fixture("%s.%s" % (fixture_name, filetype)) noop, section_dict = file_utils.load_file_to_dict(fixture_path) pkg = {u'main_section': section_dict} if include_directory: directory, noop = os.path.split(fixture_path) pkg[u'sections'] = file_utils.collect_compatible_files_in_directory(directory) return create_survey(**pkg)
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)
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)