check.py : Fix directory handling.
This commit is contained in:
parent
f9f34b69fe
commit
c4cbc7ef65
1 changed files with 10 additions and 7 deletions
17
check.py
17
check.py
|
@ -7,6 +7,7 @@ import sys
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from os import path
|
||||||
import string
|
import string
|
||||||
import collections
|
import collections
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -249,10 +250,9 @@ def add_missing_platforms(filename):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("input_file", help="Database file to check, \
|
parser.add_argument("input_file", help="database file to check, \
|
||||||
ex. gamecontrollerdb.txt.")
|
ex. gamecontrollerdb.txt")
|
||||||
parser.add_argument("--format", help="Should be run before a pull \
|
parser.add_argument("--format", help="sorts, formats and removes duplicates",
|
||||||
request. Sorts, formats and removes duplicates.",
|
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
|
||||||
# Disable misc tools until refactor
|
# Disable misc tools until refactor
|
||||||
|
@ -314,7 +314,8 @@ def main():
|
||||||
|
|
||||||
if args.format:
|
if args.format:
|
||||||
print("\nFormatting db.")
|
print("\nFormatting db.")
|
||||||
out_file = open("gamecontrollerdb_formatted.txt", 'w')
|
out_filename = path.splitext(input_file.name)[0] + "_format.txt"
|
||||||
|
out_file = open(out_filename, 'w')
|
||||||
out_file.write(FILE_HEADER)
|
out_file.write(FILE_HEADER)
|
||||||
for platform,p_dict in mappings_dict.items():
|
for platform,p_dict in mappings_dict.items():
|
||||||
out_file.write("\n")
|
out_file.write("\n")
|
||||||
|
@ -326,8 +327,10 @@ def main():
|
||||||
out_file.write(mapping.serialize() + "\n")
|
out_file.write(mapping.serialize() + "\n")
|
||||||
|
|
||||||
out_file.close()
|
out_file.close()
|
||||||
shutil.copyfile(input_file.name, ".bak." + input_file.name)
|
backup_filename = (path.join(path.split(input_file.name)[0],
|
||||||
shutil.move("gamecontrollerdb_formatted.txt", "gamecontrollerdb.txt")
|
".bak." + path.split(input_file.name)[1]))
|
||||||
|
shutil.copyfile(input_file.name, backup_filename)
|
||||||
|
shutil.move(out_filename, input_file.name)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue