def __generate_ps(lpi_value, cpi_value, font_name): if util.file_has_x_permission(PATH_PAPS) is not None: ps_content = util.run_command( PS_GENERATE % (lpi_value, cpi_value, font_name, PATH_ALPH)) file_name = font_name + '_' + str(lpi_value) + '_' + str(cpi_value) util.write_in_file(file_name + '/' + file_name + '.ps', ps_content) else: raise NotFound('Error: can not run paps command')
def __correct_box(arm_file, eng_file, out_file): lines = [] lines1 = util.read_from_file(arm_file); lines1 = ('\n'.join(lines1)).split(); lines2 = util.read_from_file(eng_file); content = '' if lines1 and lines2 and len(lines1) is len(lines2): for i in range (0,len(lines1)): if not (len(lines1[i]) == (2,1)): try: lines2[i] = lines2[i][lines2[i].index(' '):len(lines2[i])] content = content + lines1[i] + lines2[i] except ValueError: print(bcolors.FAIL + ' Incorrect box file coordinates ... ' + bcolors.ENDC) return else: print(bcolors.FAIL + ' Armenian file content is incorrect ... ' + bcolors.ENDC) return util.write_in_file(out_file, content) print (bcolors.OKGREEN + 'Done... \n' + 'Created ' + out_file + ' file ... ' + bcolors.ENDC) else: raise NotFound('Sizes of the ' + arm_file + ' and ' + eng_file + ' files are not equal ... or files are empty')