Skip to content

Commit

Permalink
Try to just get rid of them
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Dec 11, 2024
1 parent b966672 commit f2c5181
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ public static void main(String[] args) throws Exception {
isWhiteSpace = new UnicodeSet(up.getSet("whitespace=Yes"));

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist_index.html",
MakeNamesChart.class.getResource("nameslist_index.html").getPath(),
Utility.UTF8,
NAMESLIST_DIR + "index.html");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, NAMESLIST_DIR + "charts.css");
MakeNamesChart.class.getResource("charts.css").getPath(),
Utility.LATIN1,
NAMESLIST_DIR + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist_help.html",
MakeNamesChart.class.getResource("nameslist_help.html").getPath(),
Utility.UTF8,
NAMESLIST_DIR + "help.html");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist.css",
MakeNamesChart.class.getResource("nameslist.css").getPath(),
Utility.LATIN1,
NAMESLIST_DIR + "nameslist.css");

Expand Down
76 changes: 56 additions & 20 deletions unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,27 @@ public static void collationChart(UCA uca) throws IOException {
final String folder = GEN_CHARTS_DIR + "collation/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null);
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css",
null);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "help.html", Utility.UTF8, folder + "help.html", null);
WriteCharts.class.getResource("help.html").getPath(),
Utility.UTF8,
folder + "help.html",
null);

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -319,18 +328,25 @@ public static void normalizationChart() throws IOException {
// System.out.println("File: " + new File(".").getCanonicalPath());

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "norm_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("norm_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -447,18 +463,27 @@ public static void caseChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "case/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null);
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css",
null);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "case_help.html", Utility.UTF8, folder + "help.html", null);
WriteCharts.class.getResource("case_help.html").getPath(),
Utility.UTF8,
folder + "help.html",
null);

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -574,18 +599,22 @@ public static void scriptChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "script/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "script_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("script_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "script_index_header.html",
WriteCharts.class.getResource("script_index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);
Expand Down Expand Up @@ -724,18 +753,25 @@ public static void indexChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "name/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "name_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("name_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

int columnCount = 0;
char lastInitial = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,11 @@ static void generateSpecialCasing(boolean normalize) throws IOException {
break;
case 6:
Utility.appendFile(
Settings.SRC_UCD_DIR + "SpecialCasingIota.txt", Utility.UTF8, out);
GenerateCaseFolding.class
.getResource("SpecialCasingIota.txt")
.getPath(),
Utility.UTF8,
out);
break;
case 7:
out.println(
Expand All @@ -888,7 +892,10 @@ static void generateSpecialCasing(boolean normalize) throws IOException {
}
out.println(line);
}
Utility.appendFile(Settings.SRC_UCD_DIR + "SpecialCasingFooter.txt", Utility.UTF8, out);
Utility.appendFile(
GenerateCaseFolding.class.getResource("SpecialCasingFooter.txt").getPath(),
Utility.UTF8,
out);
udf.close();
// Utility.renameIdentical(mostRecent, Utility.getOutputName(newFile), batName[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ public void writeSourceOrder(
if (appendFile) {
final String[] replacements = {"%date%", Default.getDate()};
Utility.appendFile(
Settings.SRC_UCD_DIR + "confusablesHeader.txt",
GenerateConfusables.class.getResource("confusablesHeader.txt").getPath(),
Utility.UTF8_WINDOWS,
out,
replacements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,9 @@ public void writeSourceOrder(
if (appendFile) {
final String[] replacements = {"%date%", Default.getDate()};
Utility.appendFile(
Settings.SRC_UCD_DIR + "confusablesHeader.txt",
GenerateConfusablesCopy.class
.getResource("confusablesHeader.txt")
.getPath(),
Utility.UTF8_WINDOWS,
out,
replacements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static void generate(String filename2) throws IOException {
};

Utility.appendFile(
Settings.SRC_UCD_DIR + "NamedSequences-Template.html",
GenerateNamedSequences.class.getResource("NamedSequences-Template.html").getPath(),
Utility.UTF8,
out,
replacementList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public static void generate() throws IOException {
};

Utility.appendFile(
Settings.SRC_UCD_DIR + "StandardizedVariants-Template.html",
GenerateStandardizedVariants.class
.getResource("StandardizedVariants-Template.html")
.getPath(),
Utility.UTF8,
out,
replacementList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ private void build() {
try {
br =
Utility.openReadFile(
Settings.SRC_UCD_DIR + "MakeUnicodeFiles.txt", Utility.UTF8);
MakeUnicodeFiles.class
.getResource("MakeUnicodeFiles.txt")
.getPath(),
Utility.UTF8);
String file = null, property = null, value = "", comments = "";
while (true) {
String line = br.readLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.PrintWriter;
import org.unicode.cldr.draft.FileUtilities;
import org.unicode.cldr.util.TransliteratorUtilities;
import org.unicode.text.utility.Settings;

public class UseTransliterator {
public static void main(String[] args) throws IOException {
Expand All @@ -15,7 +14,7 @@ public static void main(String[] args) throws IOException {
final File f2 = new File("org/unicode/text/UCD/");
System.out.println(f2.getAbsolutePath());
TransliteratorUtilities.registerTransliteratorFromFile(
Settings.SRC_UCD_DIR, "any-temp");
UseTransliterator.class.getResource("/").getPath(), "any-temp");
final Transliterator t = Transliterator.getInstance("any-temp");
final File f = new File(filename);
final String fileContents =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,4 @@ public static void ensureOutputDir(String dir) {
}
}
}

private static final String SRC_DIR = UnicodeTools.UNICODETOOLS_RSRC_DIR + "org/unicode/text/";

/** Used for data files */
public static final String SRC_UCA_DIR = SRC_DIR + "UCA/";

/** Used for data files */
public static final String SRC_UCD_DIR = SRC_DIR + "UCD/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ private UnicodeDataFile(String directory, String filename, boolean isHTML) throw
}
try {
Utility.appendFile(
Settings.SRC_UCD_DIR + filename + "Header" + fileType, Utility.UTF8_UNIX, out);
getClass().getResource(filename + "Header" + fileType).getPath(),
Utility.UTF8_UNIX,
out);
} catch (final RuntimeIOException e) {
if (!(e.getCause() instanceof FileNotFoundException)) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class TestTestUnicodeInvariants {
void testSRC_UCD_DIR() {
assertAll(
"assert that no components of Settings.SRC_UCD_DIR are null",
() -> assertNotNull(Settings.SRC_UCD_DIR, "Settings.SRC_UCD_DIR"),
() ->
assertNotNull(
Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR,
Expand All @@ -41,17 +40,9 @@ void testUnicodeInvariants() throws IOException {

@Test
void testAdditionComparisons() throws IOException {
final var directory =
new File(
Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR
+ "org/unicode/text/UCD/AdditionComparisons/");
final var directory = new File(getClass().getResource("AdditionComparisons").getPath());
if (!directory.exists()) {
throw new IOException(
"Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR="
+ Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR
+ ", "
+ directory.getAbsolutePath()
+ " does not exist");
throw new IOException(directory.getAbsolutePath() + " does not exist");
}
int rc = 0;
for (var file : directory.listFiles()) {
Expand Down

0 comments on commit f2c5181

Please sign in to comment.