update,
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def trim_last_newline(file_path):
|
||||
with open(file_path, 'r+') as file:
|
||||
file.seek(0, os.SEEK_END)
|
||||
file.seek(file.tell() - 1, os.SEEK_SET)
|
||||
file.truncate()
|
||||
|
||||
def process_pos_file(width, height):
|
||||
with open('pos.txt', 'r') as file:
|
||||
data = file.read()
|
||||
data = data.replace('.jpg', '.jpg 1 0 0 {} {}'.format(width, height))
|
||||
with open('pos.txt', 'w') as file:
|
||||
file.write(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
trim_last_newline('neg.txt')
|
||||
trim_last_newline('pos.txt')
|
||||
process_pos_file(sys.argv[1], sys.argv[1])
|
||||
|
Reference in New Issue
Block a user