Exemple #1
0
 def test_changing_extension(self, param_changing_extension_test: Callable) -> None:
     (in_data, new_extension, expected_name) = param_changing_extension_test
     clear_folder(folder_with_slash)
     create_file('', in_data)
     change_extension_to(in_data, new_extension, True)
     assert os.path.isfile(expected_name)
     remove_file(expected_name)
def get_result_file_name(name_prefix: str,
                         data_path: Optional[str] = None,
                         extension: EXTENSION = EXTENSION.PNG) -> str:
    if data_path:
        name_prefix += '_' + (
            get_file_and_parent_folder_names(data_path).replace('/', '_'))
    return change_extension_to(name_prefix, extension)
Exemple #3
0
 def is_source_file_correct(self, source_file: str) -> bool:
     args = ['kotlinc', source_file, '-include-runtime', '-d', change_extension_to(source_file, EXTENSION.JAR)]
     # to be sure there is enough time to create a jar, call is checked with timeout=None;
     # there was 'Error: Invalid or corrupt jarfile' even with 5 sec timeout
     is_correct = check_call_safely(args, None)
     log.info(f'Source code is correct: {is_correct}')
     return is_correct
Exemple #4
0
 def run_test(self, input: str, expected_output: str,
              source_file: str) -> bool:
     args = [
         'java', '-jar',
         change_extension_to(source_file, EXTENSION.JAR)
     ]
     return check_output_safely(input, expected_output, args)
Exemple #5
0
 def is_source_file_correct(self, source_file: str) -> bool:
     args = [
         'g++', '-o',
         change_extension_to(source_file, EXTENSION.OUT), source_file
     ]
     is_correct = check_call_safely(args, None)
     log.info(f'Source code is correct: {is_correct}')
     return is_correct
def save_plot(fig: go.Figure,
              path: str,
              plot_type: plot_consts.CHART_TYPE,
              plot_name: str = 'result_plot',
              format: consts.EXTENSION = consts.EXTENSION.HTML,
              auto_open: bool = False) -> None:
    file_name = create_directory_for_plots(
        path, plot_type.value, change_extension_to(plot_name, format))
    log.info(f'Plot destination: {file_name}')
    if format == consts.EXTENSION.HTML:
        plotly.offline.plot(fig, filename=file_name, auto_open=auto_open)
    else:
        # If you have an error during constructing plots, please install required dependencies:
        # https://plotly.com/python/static-image-export/
        fig.write_image(file_name)
def __write_key_result(statistics_value: StatisticsValue,
                       output_directory: str, file_name: str) -> None:
    file_path = os.path.join(
        output_directory,
        change_extension_to(file_name, consts.EXTENSION.PICKLE))
    serialize_data_and_write_to_file(file_path, statistics_value)