feat: also publish GroupIDs as datafile (#19)
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,5 +1,8 @@
|
||||
/__pycache__/
|
||||
/.env/
|
||||
/dist/
|
||||
/sde/
|
||||
/esf_pb2.js
|
||||
/esf_pb2.py
|
||||
/node_modules/
|
||||
/package-lock.json
|
||||
/sde/
|
||||
|
||||
@@ -13,7 +13,7 @@ This is exported to Python and Javascript with the following commands:
|
||||
|
||||
```bash
|
||||
protoc --python_out=. esf.proto
|
||||
web/node_modules/.bin/pbjs -t static-module -w es6 -o esf_pb2.js esf.proto --no-create --no-encode --no-verify --no-convert --no-delimited --no-typeurl --no-beautify --no-comments --no-service
|
||||
npx pbjs -t static-module -w es6 -o esf_pb2.js esf.proto --no-create --no-encode --no-verify --no-convert --no-delimited --no-typeurl --no-beautify --no-comments --no-service
|
||||
```
|
||||
|
||||
## Converting
|
||||
|
||||
21
convert.py
21
convert.py
@@ -79,6 +79,26 @@ def convert_type_ids(path):
|
||||
return ships
|
||||
|
||||
|
||||
def convert_group_ids(path):
|
||||
print("Converting groupIDs ...")
|
||||
|
||||
with open(f"{path}/groupIDs.yaml") as fp:
|
||||
groupIDs = yaml.load(fp, Loader=yaml.CSafeLoader)
|
||||
|
||||
pb2 = esf_pb2.GroupIDs()
|
||||
ships = []
|
||||
|
||||
for id, entry in groupIDs.items():
|
||||
pb2.entries[id].name = entry["name"]["en"]
|
||||
pb2.entries[id].categoryID = entry["categoryID"]
|
||||
pb2.entries[id].published = entry["published"]
|
||||
|
||||
with open("dist/sde/groupIDs.pb2", "wb") as fp:
|
||||
fp.write(pb2.SerializeToString())
|
||||
|
||||
return ships
|
||||
|
||||
|
||||
def convert_dogma_attributes(path):
|
||||
print("Converting dogmaAttributes ...")
|
||||
|
||||
@@ -267,6 +287,7 @@ def convert_dogma_effects(path):
|
||||
fp.write(pb2.SerializeToString())
|
||||
|
||||
|
||||
convert_group_ids(path)
|
||||
ships = convert_type_ids(path)
|
||||
convert_type_dogma(path, ships)
|
||||
convert_dogma_attributes(path)
|
||||
|
||||
10
esf.proto
10
esf.proto
@@ -38,6 +38,16 @@ message TypeIDs {
|
||||
map<int32, TypeID> entries = 1;
|
||||
}
|
||||
|
||||
message GroupIDs {
|
||||
message GroupID {
|
||||
required string name = 1;
|
||||
required int32 categoryID = 2;
|
||||
required bool published = 3;
|
||||
}
|
||||
|
||||
map<int32, GroupID> entries = 1;
|
||||
}
|
||||
|
||||
message DogmaAttributes {
|
||||
message DogmaAttribute {
|
||||
required string name = 1;
|
||||
|
||||
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"protobufjs-cli": "^1.1.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user