Advertisement
xah

Create New TL

xah
Mar 9th, 2017 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. def number(loop):
  2.     if  loop < 10:
  3.         loop = '0' + str(loop)
  4.  
  5.     else:
  6.         loop = str(loop)
  7.  
  8.     return str(loop)
  9.  
  10. def newTL(name):
  11.    
  12.     file = open(name + '.txt', 'w')
  13.     usuage = input('Usuage rights: ')
  14.     email = input('Contact email: ')
  15.     title = input('Chapter title: ')
  16.     legend = input('Legend of notes: ')
  17.    
  18.     if usuage:
  19.         file.write(usuage.upper())
  20.  
  21.     if email:
  22.         file.write('\n(' + email + ')')
  23.  
  24.     file.write('\n\n')
  25.  
  26.     if title:
  27.         file.write(title + '\n\n')
  28.  
  29.     if legend:
  30.         legend = []
  31.         note = input('Add note: ')
  32.         while note:
  33.             legend.append(note)
  34.             note = input('Add another note: ')
  35.         file.write('Legend of Notes:\n')
  36.         for l in legend:
  37.             file.write(l + '\n')
  38.         file.write('\n\n')
  39.  
  40.     print('''Formatting done. Now starting translation formatting...
  41. Begin new page by typing '-', blank page by typing '#', new panel by '/' and blank panels by typing '!'.
  42. Press enter to end.''')
  43.  
  44.     text = input()
  45.  
  46.     pageNum = '01'
  47.  
  48.     while text:
  49.         if text.startswith('-'):
  50.             file.write('\npg' + pageNum)
  51.             frameNum = '01'
  52.             pageNum = number(pageNum)
  53.         elif text.startswith('#'):
  54.             pageNum = str(int(pageNum) + 1)
  55.             continue
  56.         elif text.startswith('/'):
  57.             file.write('f' + frameNum + ': \t' + text[1:])
  58.             frameNum = number(frameNum)
  59.         elif text.startswith('!'):
  60.             frameNum = str(int(frameNum) + 1)
  61.             continue
  62.         else:
  63.             file.write('\t\t' + text)
  64.         file.write('\n')
  65.  
  66.         text = input()
  67.  
  68.     print('Translation formatting is done. Would you like to write final comments?')
  69.  
  70.     comment = input()
  71.  
  72.     if comment:
  73.         file.write('\n' + '{Comments: ' + comment + '}')
  74.  
  75.     file.close()
  76.  
  77. print('''To create new translation use newTL(name).
  78. To ignore a certain section, press enter and nothing else!''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement