<commit_before>/*******************************************************************************
 * Copyright (c) 2015 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.csstudio.display.builder.util;

import java.io.FileInputStream;
import java.io.InputStream;

/** Helper for loading icons
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class Icons
{
    /** @return Stream for icon's content
     *  @throws Exception on error
     */
    public static InputStream getStream(final String path) throws Exception
    {
        // TODO Handle "plugin://.." type path for icons inside Eclipse plugin
        // This only works for tests that execute in the 'main' directory of a plugin,
        // so "../" leads to the parent of all pluging sources, from which we
        // then locate "specific_plugin/dir/file.png"
        final String resolved = path.replace("platform:/plugin/", "../");
        return new FileInputStream(resolved);
    }
}
<commit_msg>Icon lookup<commit_after>/*******************************************************************************
 * Copyright (c) 2015 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.csstudio.display.builder.util;

import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;

/** Helper for loading icons
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class Icons
{
    /** @return Stream for icon's content
     *  @throws Exception on error
     */
    public static InputStream getStream(final String path) throws Exception
    {
        if (! path.startsWith("platform:"))
            throw new Exception("Only handling 'platform:' path");
        try
        {
            return new URL(path).openStream();
        }
        catch (Exception ex)
        {
            // Handle "platform://.." path during tests in the 'main' directory of a plugin,
            // so "../" leads to the parent of all plugin sources, from which we
            // then locate "specific_plugin/dir/file.png"
            final String resolved = path.replace("platform:/plugin/", "../");
            return new FileInputStream(resolved);
        }
    }
}

{'fraction_non_alphanumeric': 0.20649819494584837, 'fraction_numerical': 0.005776173285198556, 'mean_word_length': 3.230534351145038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1894471', 'n_tokens_mistral': 680, 'n_tokens_neox': 644, 'n_words': 240}