Module pyinventory.site_survey
Functions
def add_cell_validation(worksheet: xlsxwriter.worksheet.Worksheet, row_index: int, column_index: int, full_question_path: Tuple[str, ...], question: Dict[str, Any], question_to_cell: Dict[Tuple[str, ...], str], bool_options: Dict[str, str], date_format: xlsxwriter.format.Format, black_format: xlsxwriter.format.Format) -> NoneType
def add_workbook_formats(workbook: xlsxwriter.workbook.Workbook) -> Tuple[xlsxwriter.format.Format, xlsxwriter.format.Format, xlsxwriter.format.Format, xlsxwriter.format.Format]
def adjust_column_and_row_sizes(worksheet: xlsxwriter.worksheet.Worksheet, rows: List[Tuple[str, ...]], num_columns: int) -> NoneType
-
Rows height: - Title row is thicker than data row - blank separator row is thinner than data row Columns width: - Each column width is wider enough all the text in cells it contains
:param worksheet: worksheet we operate on :param rows: list of tuples where each tuple represents a row in worksheet :param num_columns: number of columns in worksheet :return:
def break_and_validate_coordinates(value: str, invalid_type_err_msg: str) -> Tuple[float, float]
def build_site_survey_from_survey_response(survey: SurveyFragment) -> SiteSurvey
def delete_site_survey(client: SymphonyClient, site_survey: SiteSurvey) -> NoneType
def dependency_check(compare: str, value: Union[float, int, str, bool], result: str, bool_options: Dict[str, str]) -> bool
def export_to_excel(json_file_path: str, excel_file_path: str) -> NoneType
def get_response_value(full_representation_path: Tuple[str, ...], question_type: str, value: str, bool_options: Dict[str, str]) -> Dict[str, Any]
def get_site_surveys(client: SymphonyClient, location: Location) -> List[SiteSurvey]
-
Retrieve all site survey completed in the location.
Args
location (
Location
): could be retrieved from getLocation or addLocation apiReturns
List[
pyinventory.common.data_class.SiteSurvey
]Raises
EntityNotFoundError
: location does not exist def get_survey_response(category_name: str, form_name: str, form_index: int, full_representation_path: Tuple[str, ...], question_index: int, question_type: str, value: str, bool_options: Dict[str, str], form_description: Union[str, NoneType] = None) -> Dict[str, Any]
def rpad(l: List[str], char: str, size: int) -> List[str]
def upload_site_survey(client: SymphonyClient, location: Location, name: str, completion_date: datetime.datetime, excel_file_path: str, json_file_path: str) -> NoneType
-
Upload the site survey to the given completion with the data in the given excel file. We use the schema file to validate the input in the excel is as needed for upload.
Args
- location (
Location
): could be retrieved from getLocation or addLocation api name
:str
- name of the site survey
completion_date
:datetime.datetime object
- the time the site survey was completed
excel_file_path
:str
- the path for the excel with the site survey information The format of this excel should be created by calling site_survey.exportToExcel with the paremeter jsonFilePath (the next parameter of this function)
json_file_path(str): the path for the json file of the schema of the site survey the json file should comply to the schema found in survey_schema.json Example of the format:
{ "forms": [ { "formTitle": "Site Management - General Information", "questions": [ { "questionName": "Exact address", "questionType": "TEXT" }, { "questionName": "Reference for address", "questionType": "TEXT" }, { "questionName": "Ubigeo", "questionType": "TEXT" } ] } ] }
Raises
AssertionException
- if input values in the excel are incorrect
FailedOperationException
- internal inventory error
- location (
def write_column_titles(worksheet: xlsxwriter.worksheet.Worksheet, num_columns: int, title_format: xlsxwriter.format.Format, translations: Dict[str, str]) -> NoneType
def write_conditional_blank_color_if_dependency_fails(worksheet: xlsxwriter.worksheet.Worksheet, row_index: int, column_index: int, question: Dict[str, Any], full_question_path: Tuple[str, ...], question_to_cell: Dict[Tuple[str, ...], str], bool_options: Dict[str, str], black_format: xlsxwriter.format.Format) -> NoneType
def write_form_description_as_cell_comment(worksheet: xlsxwriter.worksheet.Worksheet, form_names: List[str], question_index_to_row_index: Dict[int, int], form_name_to_description: Dict[str, str]) -> NoneType