<commit_before>import sublime

import json
import os
import re
import sys
import webbrowser
import tempfile

# Helper module
try:
    from .helper import H
except:
    from helper import H

# Settings variables
try:
    from . import settings as S
except:
    import settings as S

# Config module
from .config import get_value

# Log module
from .log import debug, info

def is_fs_case_sensitive():
    with tempfile.NamedTemporaryFile(prefix='TmP') as tmp_file:
        return(not os.path.exists(tmp_file.name.lower()))

def get_real_path(uri, server=False):
    """
    Get real path

    Keyword arguments:
    uri -- Uri of file that needs to be mapped and located
    server -- Map local path to server path

    TODO: Fix mapping for root (/) and drive letters (P:/)
    """
    if uri is None:
        return uri

    # URLdecode uri
    uri = H.url_decode(uri)

    # Split scheme from uri to get absolute path
    try:
        # scheme:///path/file => scheme, /path/file
        # scheme:///C:/path/file => scheme, C:/path/file
        transport, filename = uri.split(':///', 1)
    except:
        filename = uri

    #filename = try_get_local_path_from_mounted_paths(uri)
    filename = filename.replace('@', '') # remove lua @ which represents "a file" as opposed to something run inline/from a REPL

    # Normalize path for comparison and remove duplicate/trailing slashes
    uri = os.path.normpath(filename)

    # Pattern for checking if uri is a windows path
    windows_pattern = re.compile('.*\\.*')
    is_windows_pattern = windows_pattern.match(uri) != None

    # Prepend leading slash if filesystem is not Windows
    if is_windows_pattern and not os.path.isabs(uri):
        uri = os.path.normpath('/' + uri)

    path_mapping = get_value(S.KEY_PATH_MAPPING)
    if isinstance(path_mapping, dict):

        found_path_mapping = False
        found_parent_path_mapping = False
        
        # Go through path mappings
        for server_path, local_path in path_mapping.items():
            server_path = os.path.normpath(server_path)<commit_msg>fix inverted condition<commit_after>import sublime

import json
import os
import re
import sys
import webbrowser
import tempfile

# Helper module
try:
    from .helper import H
except:
    from helper import H

# Settings variables
try:
    from . import settings as S
except:
    import settings as S

# Config module
from .config import get_value

# Log module
from .log import debug, info

def is_fs_case_sensitive():
    with tempfile.NamedTemporaryFile(prefix='TmP') as tmp_file:
        return(not os.path.exists(tmp_file.name.lower()))

def get_real_path(uri, server=False):
    """
    Get real path

    Keyword arguments:
    uri -- Uri of file that needs to be mapped and located
    server -- Map local path to server path

    TODO: Fix mapping for root (/) and drive letters (P:/)
    """
    if uri is None:
        return uri

    # URLdecode uri
    uri = H.url_decode(uri)

    # Split scheme from uri to get absolute path
    try:
        # scheme:///path/file => scheme, /path/file
        # scheme:///C:/path/file => scheme, C:/path/file
        transport, filename = uri.split(':///', 1)
    except:
        filename = uri

    #filename = try_get_local_path_from_mounted_paths(uri)
    filename = filename.replace('@', '') # remove lua @ which represents "a file" as opposed to something run inline/from a REPL

    # Normalize path for comparison and remove duplicate/trailing slashes
    uri = os.path.normpath(filename)

    # Pattern for checking if uri is a windows path
    windows_pattern = re.compile('.*\\.*')
    is_windows_pattern = windows_pattern.match(uri) != None

    # Prepend leading slash if filesystem is not Windows
    if not is_windows_pattern and not os.path.isabs(uri):
        uri = os.path.normpath('/' + uri)

    path_mapping = get_value(S.KEY_PATH_MAPPING)
    if isinstance(path_mapping, dict):

        found_path_mapping = False
        found_parent_path_mapping = False
        
        # Go through path mappings
        for server_path, local_path in path_mapping.items():
            server_path = os.path.normpath(server_path)
{'fraction_non_alphanumeric': 0.09036289353520788, 'fraction_numerical': 0.0004806536890170632, 'mean_word_length': 2.8608534322820036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6044767', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1206, 'n_words': 412}