Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- """Reads from the BoI log file in live.
- Selectively displays stuff that modders care about.
- If you don't want your log filtered, use the "info" argument.
- The script must be ran after the game is started, and it must be restarted
- if the game has been shutdown and relaunched.
- It will read each line one after the other on an infinit loop.
- If the file gets updated (ie: a line is added) it will display it and
- lower the reading cooldown.
- If nothing happen on the reading loop, it increase the reading cooldown.
- author: gibonus
- """
- from os import path
- from sys import argv, platform
- from time import sleep
- SHOW_INFO_DEFAULT = False
- ERR_WORDS = ('Error', 'fail', 'ERR', 'error')
- DBG_WORDS = ('Debug',)
- WRN_WORDS = ('warn', 'lua', 'Lua', 'collectible')
- WINDOWS_LOCATION = path.expanduser(
- '~/Documents/My Games/Binding of Isaac Afterbirth+/log.txt')
- LINUX_LOCATION = path.expanduser(
- '~/.local/share/binding of isaac afterbirth+/log.txt')
- OSX_LOCATION = path.expanduser(
- '~/Library/Application Support/Binding of Isaac Afterbirth+ Mods/log.txt')
- SYSTEM_LOCATION = \
- WINDOWS_LOCATION if platform == 'win32' else \
- OSX_LOCATION if platform == 'darwin' else \
- LINUX_LOCATION
- print("Your Isaac log locations is: " + SYSTEM_LOCATION)
- showInfo = SHOW_INFO_DEFAULT
- if len(argv) > 1 and argv[1] == 'info':
- showInfo = True
- with open(SYSTEM_LOCATION, 'r') as f:
- stime = 0.08
- while True:
- t = f.readline()
- if t != '':
- t = t.replace('[INFO] - ', '')
- stime = 0.08
- hasIssue = False
- hasDebug = False
- if any((e in t) for e in ERR_WORDS):
- print('\033[1;31m', t, end='\033[0m',sep='')
- elif any((e in t) for e in DBG_WORDS):
- print('\033[1;32m', t, end='\033[0m',sep='')
- elif any((e in t) for e in WRN_WORDS):
- print('\033[1;33m', t, end='\033[0m',sep='')
- else:
- if showInfo: print(t,end='')
- else:
- stime = stime * 2 if stime < 1.2 else 1.2
- sleep(stime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement