forked from Charcoal-SE/SmokeDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_pickles.py
executable file
·24 lines (18 loc) · 908 Bytes
/
fix_pickles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
# coding=utf-8
import os
# Pickle files should be .p file extensions, not .txt. This script handles moving the file extensions
# to the correct names.
def fix_extension_on_pickles():
pickles = ['falsePositives.txt', 'whitelistedUsers.txt', 'blacklistedUsers.txt', 'ignoredPosts.txt',
'autoIgnoredPosts.txt', 'users.txt', 'notifications.txt', 'whyData.txt', 'whyDataAllspam.txt',
'latestMessages.txt', 'apiCalls.txt', 'bodyfetcherQueue.txt', 'bodyfetcherMaxIds.txt']
# Check if each of these is a file, and if it exists, rename it to .p extension.
for txt in pickles:
try:
if os.path.isfile(txt):
os.rename(txt, (txt[:-4] + '.p'))
except:
raise RuntimeError("Could not migrate Pickle file from .txt extension to .p extension.")
if __name__ == "__main__":
fix_extension_on_pickles()