Created
August 26, 2016 01:20
-
-
Save SupaHam/e9234d0fc909f1f18ea984a6291cad82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import csv | |
import yaml | |
COMMAND_BOOK_FILE = "plugins/CommandBook/warps.csv" | |
ESSENTIALS_OUTPUT_DIR = "plugins/Essentials/warps/" | |
def convertWarp(oldWarp): | |
name = oldWarp[0] | |
world = oldWarp[1] | |
owner = oldWarp[2] | |
x = float(oldWarp[3]) | |
y = float(oldWarp[4]) | |
z = float(oldWarp[5]) | |
pitch = float(oldWarp[6]) | |
yaw = float(oldWarp[7]) | |
yamlObj = { | |
"name": name, | |
"world": world, | |
"x": x, | |
"y": y, | |
"z": z, | |
"yaw": yaw, | |
"pitch": pitch, | |
"owner": owner | |
} | |
return yamlObj | |
def readCmdBook(): | |
with open(COMMAND_BOOK_FILE, 'rb') as csvfile: | |
warpreader = csv.reader(csvfile) | |
for row in warpreader: | |
converted = convertWarp(row) | |
yamlName = converted['name'].replace(" ", "_").lower() | |
with open(ESSENTIALS_OUTPUT_DIR + yamlName + '.yml', 'w') as warpfile: | |
yaml.dump(converted, warpfile, default_flow_style=True) | |
readCmdBook() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment