diff --git a/java_tools/net_list_merge/.idea/.name b/java_tools/net_list_merge/.idea/.name deleted file mode 100644 index 200ae01762..0000000000 --- a/java_tools/net_list_merge/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -net_list_merge \ No newline at end of file diff --git a/java_tools/net_list_merge/.idea/compiler.xml b/java_tools/net_list_merge/.idea/compiler.xml deleted file mode 100644 index 217af471a9..0000000000 --- a/java_tools/net_list_merge/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/java_tools/net_list_merge/.idea/copyright/profiles_settings.xml b/java_tools/net_list_merge/.idea/copyright/profiles_settings.xml deleted file mode 100644 index 3572571ad8..0000000000 --- a/java_tools/net_list_merge/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/java_tools/net_list_merge/.idea/encodings.xml b/java_tools/net_list_merge/.idea/encodings.xml deleted file mode 100644 index e206d70d85..0000000000 --- a/java_tools/net_list_merge/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/java_tools/net_list_merge/.idea/misc.xml b/java_tools/net_list_merge/.idea/misc.xml deleted file mode 100644 index 35c8035430..0000000000 --- a/java_tools/net_list_merge/.idea/misc.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/java_tools/net_list_merge/.idea/modules.xml b/java_tools/net_list_merge/.idea/modules.xml deleted file mode 100644 index 0f98b42d17..0000000000 --- a/java_tools/net_list_merge/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/java_tools/net_list_merge/.idea/scopes/scope_settings.xml b/java_tools/net_list_merge/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b843..0000000000 --- a/java_tools/net_list_merge/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/java_tools/net_list_merge/.idea/uiDesigner.xml b/java_tools/net_list_merge/.idea/uiDesigner.xml deleted file mode 100644 index 3b00020308..0000000000 --- a/java_tools/net_list_merge/.idea/uiDesigner.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java_tools/net_list_merge/.idea/vcs.xml b/java_tools/net_list_merge/.idea/vcs.xml deleted file mode 100644 index ebabb34f16..0000000000 --- a/java_tools/net_list_merge/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/java_tools/net_list_merge/build.xml b/java_tools/net_list_merge/build.xml deleted file mode 100644 index 4c69927e8b..0000000000 --- a/java_tools/net_list_merge/build.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/java_tools/net_list_merge/net_list_merge.iml b/java_tools/net_list_merge/net_list_merge.iml deleted file mode 100644 index d5c0743275..0000000000 --- a/java_tools/net_list_merge/net_list_merge.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/java_tools/net_list_merge/src/rusefi/NetListMerge.java b/java_tools/net_list_merge/src/rusefi/NetListMerge.java deleted file mode 100644 index 57611b023f..0000000000 --- a/java_tools/net_list_merge/src/rusefi/NetListMerge.java +++ /dev/null @@ -1,123 +0,0 @@ -package rusefi; - -import java.io.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static rusefi.NetListMergeUtil.validateSection; - -/** - * 12/8/13 - * (c) Andrey Belomutskiy - */ -public class NetListMerge { - private static final Pattern GET_HEADER = Pattern.compile("(.*)\\(components(.*)\\s*$", Pattern.DOTALL); - - private static final Pattern GET_COMPONENTS = Pattern.compile("(.*)\\)\\s*\\(libparts(.*)\\)\\)\\s*$", Pattern.DOTALL); - - private static final Pattern GET_LIBRARTS = Pattern.compile("(.*)\\)\\s*\\(libraries(.*)", Pattern.DOTALL); - private static final Pattern GET_LIBRARIES = Pattern.compile("(.*)\\)\\s*\\(nets(.*)", Pattern.DOTALL); - - - private NetListMerge() { - } - - public static void main(String[] args) throws IOException { - if (args.length < 2) { - System.out.println("This tool takes 'components' sections of multiple KiCad .net files and merges them into one"); - System.out.println("usage:"); - System.out.println("NetListMerge DEST_FILE SOURCE_1 SOURCE_2 [SOURCE_x]*"); - return; - } - - String destinationFile = args[0]; - NetContent destination = parse(NetListMergeUtil.readFile(destinationFile)); - - StringBuilder components = new StringBuilder(); - StringBuilder libparts = new StringBuilder(); - StringBuilder libraries = new StringBuilder(); - StringBuilder nets = new StringBuilder(); - for (int i = 1; i < args.length; i++) { - String sourceFile = args[i]; - NetContent source = parse(NetListMergeUtil.readFile(sourceFile)); - components.append(source.components); - libparts.append(source.libparts); - libraries.append(source.libraries); - nets.append(source.nets); - } - - System.out.println("Total " + components.length() + " bytes of components"); - System.out.println("Total " + libparts.length() + " bytes of libparts"); - System.out.println("Total " + libraries.length() + " bytes of libraries"); - System.out.println("Total " + nets.length() + " bytes of nets"); - - StringBuilder result = new StringBuilder(destination.header); - result.append(" (components").append(components).append(")\r\n"); - result.append(" (libparts").append(libparts).append(")\n"); - result.append(" (libraries").append(libraries).append(")\n"); - result.append(" (nets").append(nets).append(")"); - result.append(")"); - validateSection(result.toString()); - NetListMergeUtil.writeResult(result.toString(), "out.txt"); - } - - private static class NetContent { - private final String header; - private final String components; - private final String libparts; - private final String nets; - private final String libraries; - - private NetContent(String header, String components, String libparts, String libraries, String nets) { - this.header = header; - this.components = components; - this.libparts = libparts; - this.nets = nets; - this.libraries = libraries; - System.out.println("Got " + components.length() + " bytes of components"); - System.out.println("Got " + libparts.length() + " bytes of libparts"); - System.out.println("Got " + libraries.length() + " bytes of libraries"); - System.out.println("Got " + nets.length() + " bytes of nets"); - } - } - - private static NetContent parse(String content) { - Matcher headerMatcher = GET_HEADER.matcher(content); - headerMatcher.find(); - if (!headerMatcher.matches()) - throw new IllegalStateException("Does not match expected patten for header"); - - String header = headerMatcher.group(1); - String nonHeader = headerMatcher.group(2); - - Matcher componentsMatcher = GET_COMPONENTS.matcher(nonHeader); - if (!componentsMatcher.matches()) - throw new IllegalStateException("Does not match expected patten for components"); - - String components = componentsMatcher.group(1); - String nonComponents = componentsMatcher.group(2); - validateSection(components); - - Matcher libpartsMatcher = GET_LIBRARTS.matcher(nonComponents); - if (!libpartsMatcher.matches()) - throw new IllegalStateException("Does not match expected patten for libparts"); - - String libparts = libpartsMatcher.group(1); - String nonlibparts = libpartsMatcher.group(2); - validateSection(libparts); - - Matcher librariesMatcher = GET_LIBRARIES.matcher(nonlibparts); - if (!librariesMatcher.matches()) - throw new IllegalStateException("Does not match expected patten for nets"); - - String libraries = librariesMatcher.group(1); - String nets = librariesMatcher.group(2); - validateSection(libraries); - validateSection(nets); - -// System.out.println("components: " + components); - - return new NetContent(header, components, libparts, libraries, nets); - } - -} diff --git a/java_tools/net_list_merge/src/rusefi/NetListMergeUtil.java b/java_tools/net_list_merge/src/rusefi/NetListMergeUtil.java deleted file mode 100644 index 0295a01da2..0000000000 --- a/java_tools/net_list_merge/src/rusefi/NetListMergeUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package rusefi; - -import java.io.*; - -/** - * 12/8/13 - * (c) Andrey Belomutskiy - */ -public class NetListMergeUtil { - static void writeResult(String content, String fileName) throws IOException { - System.out.println("Writing result into " + fileName); - BufferedWriter bw = new BufferedWriter(new FileWriter(fileName)); - bw.write(content); - bw.close(); - } - - static String readFile(String fileName) throws IOException { - checkExistence(fileName); - - System.out.println("Reading " + fileName); - StringBuilder sb = new StringBuilder(); - String line; - BufferedReader br = new BufferedReader(new FileReader(fileName)); - - while (((line = br.readLine()) != null)) - sb.append(line).append("\r\n"); - return sb.toString(); - } - - private static void checkExistence(String fileName) { - if (!new File(fileName).isFile()) { - System.err.println("File not found: " + fileName); - System.exit(-1); - } - } - - static void validateSection(String section) { - int counter = 0; - for (int i = 0; i < section.length(); i++) { - char c = section.charAt(i); - if (c == '(') - counter++; - else if (c == ')') - counter--; - if (counter < 0) - throw new IllegalStateException("Invalid section: " + section); - } - if (counter != 0) - throw new IllegalStateException("Invalid section: " + section + " balance: " + counter); - } -}