-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtension.py
More file actions
60 lines (51 loc) · 1.78 KB
/
Copy pathStringExtension.py
File metadata and controls
60 lines (51 loc) · 1.78 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
from datetime import datetime
# Get the current local date
current_date = datetime.now()
# Format the date as a string in the desired format
formatted_date = current_date.strftime('%-m/%-d/%Y')
numbers = {
"case": "caseImage",
"repeat": "repeatImage",
"return": "returnImage",
"0": "zero",
"1": "one",
"2": "two",
"3": "three",
"4": "four",
"5": "five",
"6": "six",
"7": "seven",
"8": "eight",
"9": "nine"
}
file = open("Sources/SFSymbolsKit/String+Extension.swift", "w")
file.write("//\n")
file.write("// String+Extension.swift\n")
file.write("// SFSymbols\n")
file.write("//\n")
file.write(f"// Generated by SFSymbolsKit on {formatted_date}\n")
file.write("//\n")
file.write("\n")
file.write("public extension String {\n")
file.write(" /// This enum provides static properties, each corresponding to an SFSymbol and returning a `String`. The corresponding SFSybmol to each property can be found in the SFSybmols App.\n")
file.write(" enum SFSymbols {\n")
with open('SFSymbols.txt') as topo_file:
for line in topo_file:
parts = line.split('.')
camel_case_name = ""
for part in parts:
if part == parts[0]:
if part.rstrip() in numbers:
camel_case_name += numbers[part.rstrip()]
continue
elif part[0] in numbers:
camel_case_name += numbers[part[0]] + part[1:]
continue
camel_case_name += part
continue
camel_case_name += part.capitalize()
result = " public static let {}: String = SFSymbol.{}.rawValue\n".format(camel_case_name.rstrip(), camel_case_name.rstrip())
file.write(result)
file.write(" }\n")
file.write("}\n")
file.close()