-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathidentify_duplicate_categories.gd
More file actions
68 lines (68 loc) · 2.69 KB
/
Copy pathidentify_duplicate_categories.gd
File metadata and controls
68 lines (68 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
################################################################################
# get_duplicate_categories
#
# Parses the stdout of burrito_converter and extracts any category collisions
# if there are any that exist.
#
# Example Input
# =============
# Did not write due to duplicates in categories.
# This commonly occurs when attempting to read the same pack multiple times or when separate packs coincidentally have the same name.
# Please remove one of the packs or edit the name of the packs' top level category before running the program again.
# If you want to bypass this stop, use '--allow-duplicates'.
# The following top level categories had a conflict in IDs. For XML, these IDs may be generated from the 'name' attribute.
# Categories were found that share the ID "92RAfU6hdh4="
# In these files the Category 'name' is "mc"
# pack/xml_file.xml
# pack3/xml_file.xml
# In these files the Category 'name' is "mycategory"
# pack2/markers.guildpoint
#
# Example Output
# ==============
# {
# "ID": {
# "mc": [
# "pack/xml_file.xml",
# "pack3/xml_file.xml",
# ],
# "mycategory": [
# "pack2/markers.guildpoint",
# ]
# }
# }
################################################################################
static func get_duplicate_categories(stdin: String) -> Dictionary:
var lines: PoolStringArray = stdin.split("\n")
var capturing: bool = false
var collisions: Dictionary = {}
var category = null
var id = null
for line in lines:
if line == null:
continue
elif !capturing:
if line == "The following top level categories had a conflict in IDs. For XML, these IDs may be generated from the 'name' attribute.":
capturing = true
elif capturing:
if line.begins_with(" Categories"):
# Remove the first 44 characters from the message and the open quote
var line_without_prefix = line.substr(45)
var endquote_index = line_without_prefix.find("\"")
id = line_without_prefix.substr(0, endquote_index)
collisions[id] = {}
elif line.begins_with(" In these files no name was found"):
collisions[id][""] = []
elif line.begins_with(" "):
# Remove the first 12 spaces
var file_name = line.substr(12)
collisions[id][category].append(file_name)
elif line.begins_with(" In these files the Category 'name' is "):
# Remove the first 46 characters and the open quote
var line_without_prefix = line.substr(47)
var endquote_index = line_without_prefix.find("\"")
category = line_without_prefix.substr(0, endquote_index)
collisions[id][category] = []
else:
break
return collisions