Skip to content

Commit 0fae971

Browse files
committed
Change license for code to CC-BY-NC-SA 3.0
1 parent 558e9a3 commit 0fae971

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tools/main.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//
2-
// main.swift
3-
// update
4-
//
52
// Created by Apollo Zhu on 3/12/17.
6-
// Copyright © 2017 WWITDC. All rights reserved.
3+
// This work is licensed under a
4+
// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
75
//
86

97
import Foundation
@@ -47,7 +45,7 @@ struct Resource: CustomStringConvertible {
4745
} else if let resType = ResourceType.all.first(where: { title.contains($0.rawValue) }) {
4846
type = resType
4947
} else {
50-
fatalError("Unknown Raw Type")
48+
fatalError("Unknown Raw Type \(rawType)")
5149
}
5250

5351
var parts: [String]
@@ -109,7 +107,11 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
109107

110108
func parser(_ parser: XMLParser, foundCDATA CDATABlock: Data) {
111109
if isParsingTitle {
112-
title = String(data: CDATABlock, encoding: .utf8)!
110+
if let title = String(data: CDATABlock, encoding: .utf8) {
111+
self.title = title
112+
} else {
113+
fatalError("Unable to parse title from \(CDATABlock)")
114+
}
113115
}
114116
}
115117

@@ -132,10 +134,9 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
132134

133135
var out = "[返回主页](../README.md) / [Back to Main Page](../en/README.md)\n\n"
134136
for (index, type) in ResourceType.all.enumerated() {
135-
if sorted[index].count > 0 {
136-
out += "# \(type)\n\n"
137-
+ "\(sorted[index].reduce("") { "\($0)\($1)\n" })\n"
138-
}
137+
guard !sorted[index].isEmpty else { fatalError("Missing Resources of Type \(type)") }
138+
out += "# \(type)\n\n"
139+
+ "\(sorted[index].reduce("") { "\($0)\($1)\n" })\n"
139140
}
140141

141142
let cwd = CommandLine.arguments.first { $0.contains(#file) } ?? FileManager.default.currentDirectoryPath

0 commit comments

Comments
 (0)