osx11

Quests preview

Jul 12th, 2021 (edited)
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from os import listdir, chdir, path, remove
  2.  
  3. def write(dir):
  4.     files = [f for f in listdir(f'quests/{dir}') if f[0] in '0123456789']
  5.     files = list(sorted(files, key=lambda x: float(x.split(' ')[0][:-1].split('-')[0])))
  6.  
  7.     with open('plot.md', 'a') as f:
  8.         f.write(f'# {dir}\n')
  9.  
  10.         for i in files:
  11.             f.write(f'### {i.replace(".txt", "")}\n')
  12.             f.write('```\n')
  13.  
  14.             with open(fr'quests/{dir}/{i}', encoding='utf-8') as qf:
  15.                 for l in qf:
  16.                     l = l.replace('#', '//')
  17.                     f.write(l)
  18.  
  19.             f.write('```\n')
  20.             for _ in range(3): f.write('\n')
  21.  
  22. if __name__ == '__main__':
  23.     if path.isfile('plot.md'):
  24.         remove('plot.md')
  25.  
  26.     write('Пролог')
  27.     write('Основная глава. Второе желание')
  28.     write('Основная глава. Третье желание')
  29.  
Add Comment
Please, Sign In to add comment