/** * Expand all supported variables and canonicalize (resolve ".." and ".") * a path. If the input path has no variables, it is returned unchanged. * rootDir and inputRootDir can be null. * @param path The path to expand * @param rootDir The directory to expand ${rootDir} into * @param inputRootDir The directory to expand ${inputRootDir} into * @return The expanded path * @throws IOException If canonicalizing fails */ public static String expandPath (String path, String rootDir, String inputRootDir) throws IOException { if (!path.contains("${")) return path; path = Util.fillSystemEnvars(path); path = Util.fillRootDirectoryVariable(path, rootDir); path = Util.fillInputRootDirectoryVariable(path, inputRootDir); path = new File(path).getCanonicalPath(); return path; }
@Override protected Event handleEndBatch (Event event) { extractor.completeExtraction(); String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir); LOGGER.info("Output: {}", finalPath); LOGGER.info("Candidate terms found = {}", extractor.getTerms().size()); if ( params.getAutoOpen() ) { Util.openURL((new File(finalPath)).getAbsolutePath()); } return event; }
/** * Generates the report file with the results. */ private void generateReport () { // Output the report PrintWriter writer = null; try { String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir); finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); Util.createDirectories(finalPath); writer = new PrintWriter(finalPath, "UTF-8"); for ( Entry<String, Integer> entry : terms.entrySet() ) { writer.println(String.format("%d\t%s", entry.getValue(), entry.getKey())); } } catch ( IOException e ) { throw new OkapiException("Error when writing output file.", e); } finally { if ( writer != null ) { writer.close(); writer = null; } } }
@Override protected Event handleStartBatchItem (Event event) { if(simpleTm == null){ simpleTm = new Database(); simpleTm.create(Util.fillRootDirectoryVariable(params.getTmPath(), rootDir), true, targetLocale); } return event; }
private void generateReport (String text) { // Output the report PrintWriter writer = null; try { String finalPath = Util.fillRootDirectoryVariable(params.getLogPath(), rootDir); finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); Util.createDirectories(finalPath); writer = new PrintWriter(finalPath, "UTF-8"); writer.println(text); } catch ( IOException e ) { throw new OkapiException("Error when writing output file.", e); } finally { if ( writer != null ) { writer.close(); writer = null; } } }
if ( propFile != null ) { propFile = propFile.trim(); propFile = Util.fillRootDirectoryVariable(propFile, rootDir); propFile = Util.fillInputRootDirectoryVariable(propFile, inputRootDir); propFile = LocaleId.replaceVariables(propFile, sourceLocale, targetLocale);
String finalPath = Util.fillRootDirectoryVariable(params.getReplacementsPath(), rootDir); finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); replacementWords = loadList(finalPath);
private void generateReport () { try { startWaiting("Generating report..."); String rootDir = (qcsPath==null ? null : Util.getDirectoryName(qcsPath)); session.generateReport(rootDir); String finalPath = Util.fillRootDirectoryVariable(session.getParameters().getOutputPath(), rootDir); if ( session.getParameters().getAutoOpen() ) { Util.openURL((new File(finalPath)).getAbsolutePath()); } } catch ( Throwable e ) { Dialogs.showError(shell, "Error while generating report.\n"+e.getMessage(), null); } finally { stopWaiting(); } }
String tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir); tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, sourceLocale, targetLocale); tmxWriter = new TMXWriter(tmxOutputPath);
@Override public void open () { db.open(Util.fillRootDirectoryVariable(params.getDbPath(), rootDir)); db.setPenalizeSourceWithDifferentCodes(params.getPenalizeSourceWithDifferentCodes()); db.setPenalizeTargetWithDifferentCodes(params.getPenalizeTargetWithDifferentCodes()); }
origin = Util.fillRootDirectoryVariable(origin, rootDir); origin = Util.fillInputRootDirectoryVariable(origin, inputRootDir); origin = LocaleId.replaceVariables(origin, manifest.getSourceLocale(), manifest.getTargetLocale());
private void initialize () { if ( params.getMakeTMX() ) { String tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir); tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir); tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, srcLoc, trgLoc); String existingTMPath = Util.fillRootDirectoryVariable(params.getExistingTm(), rootDir); existingTMPath = Util.fillInputRootDirectoryVariable(existingTMPath, inputRootDir); existingTMPath = LocaleId.replaceVariables(existingTMPath, srcLoc, trgLoc); if ( params.getSegment() ) { SRXDocument srxDoc = new SRXDocument(); String srxPath = Util.fillRootDirectoryVariable(params.getSrxPath(), rootDir); srxPath = Util.fillInputRootDirectoryVariable(srxPath, inputRootDir); srxPath = LocaleId.replaceVariables(srxPath, srcLoc, trgLoc);
resolvedOutputDir = Util.fillRootDirectoryVariable(resolvedOutputDir, rootDir); resolvedOutputDir = Util.fillInputRootDirectoryVariable(resolvedOutputDir, inputRootDir); resolvedOutputDir = LocaleId.replaceVariables(resolvedOutputDir, srcLoc, trgLoc);
String resolvedPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir); resolvedPath = Util.fillInputRootDirectoryVariable(resolvedPath, inputRootDir); resolvedPath = LocaleId.replaceVariables(resolvedPath, sourceLocale, targetLocale);
tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir); tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir); tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, sourceLocale, targetLocale);
String tmDir = Util.fillRootDirectoryVariable(params.getTmDirectory(), rootDir); tmDir = Util.fillInputRootDirectoryVariable(tmDir, inputRootDir); tmDir = LocaleId.replaceVariables(tmDir, srcLoc, trgLoc);
String realPath = Util.fillRootDirectoryVariable(params.getTMXPath(), rootDir); realPath = Util.fillInputRootDirectoryVariable(realPath, inputRootDir); realPath = LocaleId.replaceVariables(realPath, sourceLocale, targetLocale);
src = Util.fillRootDirectoryVariable(params.getSourceSrxPath(), rootDir); src = Util.fillInputRootDirectoryVariable(src, inputRootDir); srxDoc.loadRules(src); String trg = Util.fillRootDirectoryVariable(params.getTargetSrxPath(), rootDir); trg = Util.fillInputRootDirectoryVariable(trg, inputRootDir);