def get_tt_name_from_ati_data(ct_file: str, language: consts.LANGUAGE,
                              files_from_at: List[str]) -> Tuple[str, bool]:
    """
    Try to find the current name of the code tracker file among those tracked by the activity tracker plugin.
    """
    log.info('Start getting project file name')
    extension = get_extension_by_language(language)
    hashed_file_name = get_name_from_path(ct_file)
    file_name = get_original_file_name_with_extension(hashed_file_name,
                                                      extension)
    does_contain_name = True
    if files_from_at is not None:
        log.info(
            f'Start searching the file_name {file_name} in activity tracker data'
        )
        if file_name not in files_from_at:
            log.info(
                f'Activity tracker data does not contain the original file {file_name}'
            )
            does_contain_name = False
        log.info(
            f'Finish searching the file_name {file_name} in activity tracker data'
        )

    log.info('Finish getting project file name')
    return file_name, does_contain_name
Exemplo n.º 2
0
 def get_file_path(self, suffix: Optional[str] = None, object_id: Optional[int] = None) -> str:
     extension = get_extension_by_language(self._language)
     file_name = f'{self._file_prefix}'
     if object_id is not None:
         file_name += f'_{str(object_id)}'
     if suffix is not None:
         file_name += f'_{suffix}'
     return os.path.join(self._folder_with_files, f'{file_name}{str(extension.value)}')
Exemplo n.º 3
0
def get_expected_files(graph_id: int, code_id: int, anon_tree_id: int, graph_prefix: str = GRAPH_FOLDER_PREFIX,
                       file_prefix: str = FILE_PREFIX,
                       language: LANGUAGE = LANGUAGE.PYTHON) -> List[str]:
    ext = get_extension_by_language(language).value
    graph_folder_name = f'{graph_prefix}_{graph_id}'
    code_file_prefix = f'{file_prefix}_{code_id}'
    return [os.path.join(GRAPHS_PARENT_FOLDER, graph_folder_name,
                         f'{code_file_prefix}_{TREE_TYPE.ANON.value}_{anon_tree_id}{ext}')]
Exemplo n.º 4
0
 def create_source_file_with_name(self, source_code: str, name: str) -> str:
     source_code_file = os.path.join(
         TASKS_TESTS_PATH, SOURCE_OBJECT_NAME,
         name + get_extension_by_language(self.language).value)
     create_file(source_code, source_code_file)
     return source_code_file