Révision 3544

TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CompressCQPIndexes.java (revision 3544)
128 128
			return false;
129 129
		}
130 130
		
131
		// remove .corpus files if the compression was succesful
131
		// remove .corpus files if the compression was successful
132 132
		int s = 0;
133 133
		int a = 0;
134 134
		for (File f : dataDirectory.listFiles()) {
......
151 151
			}
152 152
		}
153 153
		
154
		// remove .corpus.rdx and corpus.rev files if the compression was succesful
154
		// remove .corpus.rdx and corpus.rev files if the compression was successful
155 155
		for (File f : dataDirectory.listFiles()) {
156 156
			if (f.getName().endsWith(".corpus.rdx") ||f.getName().endsWith(".corpus.rev")) {
157 157
				
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/AddMacroMacro.groovy (revision 3544)
14 14

  
15 15
// BEGINNING OF PARAMETERS
16 16

  
17
@Field @Option(name="files", usage="an example file", widget="FilesOpen", metaVar="*.groovy;*.jar", required=true, def="")
18
def files
17
@Field @Option(name="groovyFiles", usage="Groovy files to install", widget="FilesOpen", metaVar="*.groovy", required=true, def="")
18
def groovyFiles
19 19

  
20 20
// Open the parameters input dialog box
21 21
if (!ParametersDialog.open(this)) return
......
24 24

  
25 25
File rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/")
26 26

  
27
for (File f : files) {
27
for (File f : groovyFiles) {
28 28

  
29 29
	if (!f.isFile()) continue;
30 30
	
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/AddLibraryMacro.groovy (revision 3544)
1
// Copyright © 2022 MY_INSTITUTION
2
// Licensed under the terms of the GNU General Public License version 3 (http://www.gnu.org/licenses/gpl-3.0.html)
3
// @author mdecorde
4

  
5
// STANDARD DECLARATIONS
6
package org.txm.macro
7

  
8
import org.kohsuke.args4j.*
9
import groovy.transform.Field
10
import org.txm.rcp.swt.widget.parameters.*
11
import org.txm.Toolbox;
12
import org.txm.utils.io.FileCopy
13
import org.txm.rcp.views.fileexplorer.MacroExplorer
14

  
15
// BEGINNING OF PARAMETERS
16

  
17
@Field @Option(name="jarFiles", usage="JAR files to install", widget="FilesOpen", metaVar="*.jar", required=true, def="")
18
def jarFiles
19

  
20
// Open the parameters input dialog box
21
if (!ParametersDialog.open(this)) return
22

  
23
// END OF PARAMETERS
24

  
25
File rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/")
26

  
27
for (File f : jarFiles) {
28

  
29
	if (!f.isFile()) continue;
30
	
31
	if (f.getName().endsWith(".jar")) {
32
	
33
		File f2 = new File(rootDir, "lib/"+f.getName())
34
		if (f2.exists()) {
35
			println "Updating library $f2"
36
			f2.delete()
37
		} else {
38
			println "New library: $f2"
39
		}
40
		FileCopy.copy(f, f2)
41
		
42
	} else if (f.getName().endsWith(".groovy")) {
43
	
44
		String ppackage = "org.txm.macro"
45
		def content = f.readLines("UTF-8")
46
		for (def line : content) {
47
			if (line.startsWith("package org.txm.macro")) {
48
				ppackage = line.substring(8)
49
				break
50
			}
51
		}
52
		
53
		File f2 = new File(rootDir, "user/"+ppackage.replace(".", "/")+ "/"+ f.getName())
54
		if (f2.exists()) {
55
			println "Update macro: $f2"
56
			f2.delete()
57
		} else {
58
			println "New macro: $f2"
59
		}
60
		f2.getParentFile().mkdirs()
61
		
62
		FileCopy.copy(f, f2)
63
		
64
	} else {
65
		println "Ignoring $f"
66
	}
67
}
68

  
69
// update macros view
70
monitor.syncExec(new Runnable() {
71
		public void run() {
72
			MacroExplorer.refresh();
73
		}
74
	});
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/cqp/CompressCQPIndexesMacro.groovy (revision 3544)
1
// Copyright © 2022 ENS de Lyon, CNRS, University of Franche-Comté
2
// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
3
// @author sheiden
4

  
5
package org.txm.macro.commands
6

  
7
// STANDARD DECLARATIONS
8
import org.txm.rcpapplication.swt.widget.parameters.*
9
import org.txm.searchengine.cqp.CQPPreferences
10
import org.txm.searchengine.cqp.corpus.MainCorpus
11
import org.txm.importer.cwb.CompressCQPIndexes
12
import org.txm.libs.cqp.CQPLibPreferences
13

  
14
// Open the parameters input dialog box
15
if (!ParametersDialog.open(this)) return false
16

  
17
if (!(corpusViewSelection instanceof MainCorpus)) {
18
	println "** $scriptName: please select a MainCorpus in the Corpus view."
19
	return 0
20
}
21

  
22
MainCorpus corpus = corpusViewSelection
23

  
24
File registry = corpus.getRegistryFile()
25
File data = corpus.getDataDirectory()
26

  
27
File wordCorpusFile = new File(data, "word.corpus")
28
if (!wordCorpusFile.exists()) {
29
	println "Corpus already compressed or broken"
30
	return
31
}
32

  
33
try {
34
			String userdir = System.getProperty("user.home");
35
			String cqilib = CQPLibPreferences.getInstance().getString(CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB);
36
			String exec_path = CQPLibPreferences.getInstance().getString(CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE);
37
			File toolsDir = null;
38
			if (!cqilib.isEmpty()) {
39
				toolsDir = new File(cqilib)
40
				if (!toolsDir.exists()) {
41
					toolsDir = null;
42
				}
43
			}
44
			
45
			if (!exec_path.isEmpty()) {
46
				toolsDir = new File(exec_path).getParentFile()
47
				if (!toolsDir.exists()) {
48
					toolsDir = null;
49
				}
50
			}
51
			
52
			if (toolsDir == null) {
53
				println "Could not findout the CQP tools directory. Aboorting."
54
				return;
55
			}
56
			
57
			
58
			
59
			CompressCQPIndexes.compressAll(toolsDir, registry, corpus.getProject().getName(), data, true);
60
			
61
		} catch (Exception e) {
62
			e.printStackTrace();
63
		}

Formats disponibles : Unified diff