# Path: script_file.py
# class ScriptFile():
#   def __init__(self, filename = None, scene_info = None):
#     self.translated = ""
#     self.translated_notags = ""
#     self.original = ""
#     self.original_notags = ""
#     self.comments = ""
#     
#     self.filename = None
#     
#     if not filename == None:
#       self.open(filename)
#     
#       if scene_info == None:
#         # Squeeze the file ID out of the filename.
#         scene_info = SceneInfo(file_id = int(os.path.splitext(os.path.basename(filename))[0]))
#     
#     self.scene_info = scene_info
#   
#   def open(self, filename):
#     
#     if not filename or not os.path.isfile(filename):
#       return
#     
#     text = load_text(filename)
#     
#     self.from_data(text)
#     
#     self.filename = filename
#   
#   def from_data(self, data):
#     
#     self.filename = None
#     self.translated = ""
#     self.translated_notags = ""
#     self.original = ""
#     self.original_notags = ""
#     self.comments = ""
#     
#     # Sanitize our line-breaks. The game handles \r\n in some instances,
#     # but not all. It always handles \n properly.
#     text = LINE_BREAKS.sub("\n", data)
#     
#     match = TEXT_PARSER.search(text)
#     
#     if match:
#       # Remove any trailing linebreaks, because 
#       first_part = match.group(1)
#       second_part = match.group(2)
#       third_part = match.group(4)
#       
#       if not second_part:
#         self.original = first_part
#       else:
#         self.translated = first_part
#         self.original = second_part
#       
#       if third_part:
#         self.comments = third_part
#     
#     self.original_notags = TAG_KILLER.sub("", self.original)
#     self.translated_notags = TAG_KILLER.sub("", self.translated)
#   
#   ##############################################################################
#   ### @fn    pack()
#   ### @desc  Converts all the data into the script file format.
#   ### @param for_game -- Whether to include the original, untranslated data.
#   ###                    True = exclude untranslated, since we don't need it.
#   ##############################################################################
#   def pack(self, for_game = False):
#   
#     if self.translated == "":
#       output = u"\ufeff" + self.original + u"\u0000"
#       
#       if self.comments != "" and not for_game:
#         output += "\n[" + self.comments + "]"
#     else:
#       output = u"\ufeff" + self.translated + u"\u0000"
#       
#       if not for_game:
#         output +=  "\n" + self.original
#         if self.comments != "":
#           # We want a newline, but not a thousand.
#           if not self.original[-1] == '\n':
#             output += "\n"
#           
#           output += "[" + self.comments + "]"
#     
#     # Sanitize our line breaks, just in case.
#     output = LINE_BREAKS.sub("\n", output)
#     
#     return output
#   
#   def save(self, filename = None):
#     
#     if filename == None:
#       if self.filename == None:
#         return
#       else:
#         filename = self.filename
#     
#     output = self.pack(for_game = False)
#     
#     save_text(output, filename)


from PyQt4 import QtCore, QtGui, Qt
from PyQt4.QtGui import QProgressDialog
from script_file import ScriptFile
from word_count import count_words
import os
import re
import time
import common
import dupe_db
import list_files
import script_file
import script_analytics
  import sys
    "\n" +
    ("Japanese Characters: %d / %d (%0.2f%%)\n" % (translated_chars, total_chars, chars_percent)) + 
    ("Unique Characters: %d / %d (%0.2f%%)\n" % (translated_unique_chars, unique_chars, unique_chars_percent)) +
    #"\n" +
    #("Bytes: %d / %d (%0.2f%%)\n" % (translated_bytes, total_bytes, bytes_percent)) + 
    #("Unique Bytes: %d / %d (%0.2f%%)\n" % (translated_unique_bytes, unique_bytes, unique_bytes_percent)) +
    "\n" +
    ("English Words: %d\n" % (translated_words)) + 
    ("Unique Words: %d\n" % (translated_unique_words)) +
    "\n" +
    "NOTE: Unique X is lazy for \"X in all unique files\"\n" +
    "and not what it seems to imply." +
    "",
    buttons = QtGui.QMessageBox.Ok,
    defaultButton = QtGui.QMessageBox.Ok
  )

def list_untranslated():
  
  files = list_files.list_all_files(common.editor_config.umdimage_dir)
  #files = list_files.list_all_files("X:\\Danganronpa\\FULL_TEST\\best-normal")
  
  text_files = []
  
  for i, file in enumerate(files):
    if os.path.splitext(file)[1] == ".txt":
      text_files.append(file)
  
  for file in text_files:
    try:

# Path: script_file.py
# class ScriptFile():
#   def __init__(self, filename = None, scene_info = None):
#     self.translated = ""
#     self.translated_notags = ""
#     self.original = ""
#     self.original_notags = ""
#     self.comments = ""
#     
#     self.filename = None
#     
#     if not filename == None:
#       self.open(filename)
#     
#       if scene_info == None:
#         # Squeeze the file ID out of the filename.
#         scene_info = SceneInfo(file_id = int(os.path.splitext(os.path.basename(filename))[0]))
#     
#     self.scene_info = scene_info
#   
#   def open(self, filename):
#     
#     if not filename or not os.path.isfile(filename):
#       return
#     
#     text = load_text(filename)
#     
#     self.from_data(text)
#     
#     self.filename = filename
#   
#   def from_data(self, data):
#     
#     self.filename = None
#     self.translated = ""
#     self.translated_notags = ""
#     self.original = ""
#     self.original_notags = ""
#     self.comments = ""
#     
#     # Sanitize our line-breaks. The game handles \r\n in some instances,
#     # but not all. It always handles \n properly.
#     text = LINE_BREAKS.sub("\n", data)
#     
#     match = TEXT_PARSER.search(text)
#     
#     if match:
#       # Remove any trailing linebreaks, because 
#       first_part = match.group(1)
#       second_part = match.group(2)
#       third_part = match.group(4)
#       
#       if not second_part:
#         self.original = first_part
#       else:
#         self.translated = first_part
#         self.original = second_part
#       
#       if third_part:
#         self.comments = third_part
#     
#     self.original_notags = TAG_KILLER.sub("", self.original)
#     self.translated_notags = TAG_KILLER.sub("", self.translated)
#   
#   ##############################################################################
#   ### @fn    pack()
#   ### @desc  Converts all the data into the script file format.
#   ### @param for_game -- Whether to include the original, untranslated data.
#   ###                    True = exclude untranslated, since we don't need it.
#   ##############################################################################
#   def pack(self, for_game = False):
#   
#     if self.translated == "":
#       output = u"\ufeff" + self.original + u"\u0000"
#       
#       if self.comments != "" and not for_game:
#         output += "\n[" + self.comments + "]"
#     else:
#       output = u"\ufeff" + self.translated + u"\u0000"
#       
#       if not for_game:
#         output +=  "\n" + self.original
#         if self.comments != "":
#           # We want a newline, but not a thousand.
#           if not self.original[-1] == '\n':
#             output += "\n"
#           
#           output += "[" + self.comments + "]"
#     
#     # Sanitize our line breaks, just in case.
#     output = LINE_BREAKS.sub("\n", output)
#     
#     return output
#   
#   def save(self, filename = None):
#     
#     if filename == None:
#       if self.filename == None:
#         return
#       else:
#         filename = self.filename
#     
#     output = self.pack(for_game = False)
#     
#     save_text(output, filename)


# Path: progress.py
from PyQt4 import QtCore, QtGui, Qt
from PyQt4.QtGui import QProgressDialog
from script_file import ScriptFile
from word_count import count_words
import os
import re
import time
import common
import dupe_db
import list_files
import script_file
import script_analytics
  import sys

    "\n" +
    ("Japanese Characters: %d / %d (%0.2f%%)\n" % (translated_chars, total_chars, chars_percent)) + 
    ("Unique Characters: %d / %d (%0.2f%%)\n" % (translated_unique_chars, unique_chars, unique_chars_percent)) +
    #"\n" +
    #("Bytes: %d / %d (%0.2f%%)\n" % (translated_bytes, total_bytes, bytes_percent)) + 
    #("Unique Bytes: %d / %d (%0.2f%%)\n" % (translated_unique_bytes, unique_bytes, unique_bytes_percent)) +
    "\n" +
    ("English Words: %d\n" % (translated_words)) + 
    ("Unique Words: %d\n" % (translated_unique_words)) +
    "\n" +
    "NOTE: Unique X is lazy for \"X in all unique files\"\n" +
    "and not what it seems to imply." +
    "",
    buttons = QtGui.QMessageBox.Ok,
    defaultButton = QtGui.QMessageBox.Ok
  )

def list_untranslated():
  
  files = list_files.list_all_files(common.editor_config.umdimage_dir)
  #files = list_files.list_all_files("X:\\Danganronpa\\FULL_TEST\\best-normal")
  
  text_files = []
  
  for i, file in enumerate(files):
    if os.path.splitext(file)[1] == ".txt":
      text_files.append(file)
  
  for file in text_files:
    try:

      script_file = ScriptFile(file)