コード例 #1
0
def pack_txt(filename):
  
  if os.path.basename(os.path.dirname(filename)) in SCRIPT_NONSTOP:
    is_nonstop = True
  else:
    is_nonstop = False

  script = ScriptFile(filename)
  text = script[common.editor_config.lang_trans]
  if not text:
    text = script[common.editor_config.lang_orig]
  
  # Nonstop Debate lines need an extra newline at the end
  # so they show up in the backlog properly.
  if is_nonstop and not text[-1] == u"\n":
    text += u"\n"
  
  text = SCRIPT_BOM + text + SCRIPT_NULL
  text = BitStream(bytes = text.encode("UTF-16LE"))
  
  return text