import sys import os.path as op # -------------------------------------------------- VARIABLES = { '[PC Guild Rank]\nLike in \"[PC Guild Rank], what can be said. We are the few, the proud, the ... under-paid! HarHarHar!\"': '[PC Guild Rank]', '[Speaker\'s Name]\nLike in \"But perhaps [Speaker\'s Name] should not speak about this in public. And who would listen, anyway?\"': '[Speaker\'s Name]', '[PC Name]\nLike in \"[PC Name]. Once before, Lord Nerevar thought Dagoth Ur and all his kin were dead.\"': '[PC Name]', '[PC Race]\nLike in \"I don\'t like you, [PC Race]. You better stay out of this.\"': '[PC Race]', '[PC Rank]\nLike in \"What do you want, [PC Rank]?\"': '[PC Rank]', '[Next PC Rank]\nLike in "You are now [PC Name] the [Next PC Rank] in the Fighters Guild.\"': '[Next PC Rank]', '[Faction]\nLike in \"The [Faction] can forgive your actions this one time only, [PC Rank] [PC Name].\"': '[Faction]', '[Rank]\nLike in \"I\'ve risen to [Rank] rank in this outfit by being smart and careful.\"': '[Rank]', '[Name]\nLike in \"Hello, [PC Name]. I\'m [Name], and I\'m here to clean out this den of Daedra worshippers.\"': '[Name]' } # Replaces [macros] with strings you want def main(): with open('quotes.dat', 'r', encoding='utf-8') as file: quotes = file.readlines() replacer = '' if (input('Do you want to remove broken strings? y/n ') == 'y'): quotes.remove('The Elder Scrolls III: Morrowind\n') for quote in quotes: if (len(quote) < 5 or not quote.strip().endswith('\"') or not quote.strip().startswith('\"')): quotes.remove(quote) for to_print, to_replace in VARIABLES.items(): while not replacer.strip(): replacer = input('\n' + to_print + '\n Input what do you want to replace ' + to_replace + ' with:') for i, quote in enumerate(quotes): quotes[i] = quote.replace(to_replace, replacer) replacer = '' with open('quotes.dat', 'w', encoding='utf-8') as file: for quote in quotes: print(quote, file=file, end='') if __name__ == '__main__': sys.exit(main())