def dump_a2pats(obj, folder): # type: (a2pats, PathLike) -> bool ''' Dump A2PATS object Parameters: * `obj`: (a2pats class object) A2PATS object * `folder`: (str or Path like object) Folder location to export **Returns**: (boolean) True on success ''' if isfile(folder): logger.error('{} is a filepath, a folder cannot be placed here. Aborting'.format(folder)) return False if not isdir(folder): logger.debug('{} does not exist, creating folder'.format(folder)) mkdir(folder) logger.info('Now exporting A2PATS to folder {}'.format(folder)) for model_ in obj.models: dump_a2pats_file(model_, folder) return True
converter) table = sort_table(table, headers) widths = determine_max_widths(table) table, size = split_header_auto(table) if add_sign: widths.insert(0, 3) for i in range(size): table[i].insert(0, str()) for i in range(size, len(table)): table[i].insert(0, '+/-') # NOTE: The following list is built with list comprehension. For the sake # of code readability it is advised to expand this eventually and it makes # the most sense to expand this when the above TODO is added. output_table = [ ''.join([item.center(widths[idx]) for idx, item in enumerate(row)]) for row in table ] return output_table def build_table_str(*args): # type: (dict) -> str ''' Builds the table and returns as a string ''' return '\n'.join(build_table(*args)) if __name__ == '__main__': logger.error('You cannot call this file directly!')