<commit_before>"""
cross platform utilities
"""
from __future__ import absolute_import, division, print_function
import os
import sys
import platform
import subprocess
import shlex
from os.path import exists, normpath, join
from os.path import expanduser
from .util_inject import inject
print, print_, printDBG, rrr, profile = inject(__name__, '[cplat]')

COMPUTER_NAME = platform.node()

WIN32  = sys.platform.startswith('win32')
LINUX  = sys.platform.startswith('linux')
DARWIN = sys.platform.startswith('darwin')

LIB_EXT_LIST = ['.so', '.dll', '.dylib']


def get_dynamic_lib_globstrs():
    return ['*' + libext for libext in LIB_EXT_LIST]


def get_computer_name():
    return COMPUTER_NAME


def getroot():
    root = {
        'WIN32': 'C:\\',
        'LINUX': '/',
        'DARWIN': '/',
    }[sys.platform]
    return root


def startfile(fpath):
    print('[cplat] startfile(%r)' % fpath)
    if not exists(fpath):
        raise Exception('Cannot start nonexistant file: %r' % fpath)
    if LINUX:
        out, err, ret = cmd(['xdg-open', fpath], detatch=True)
        if not ret:
            raise Exception(out + ' -- ' + err)
    elif DARWIN:
        out, err, ret = cmd(['open', fpath], detatch=True)
        if not ret:
            raise Exception(out + ' -- ' + err)
    else:
        os.startfile(fpath)
    pass


def view_directory(dname=None):
    """ view directory """
    print('[cplat] view_directory(%r) ' % dname)
    dname = os.getcwd() if dname is None else dname
    open_prog = {'win32': 'explorer.exe',
                 'linux2': 'nautilus',
                 'darwin': 'open'}[sys.platform]
    os.system(open_prog + ' ' + normpath(dname))


def get_resource_dir():
    """ Returns a directory which should be writable for any application """
    if WIN32:
        return normpath(expanduser('~/AppData/Roaming'))
    if LINUX:
        return normpath(expanduser('~/.config'))
    if DARWIN:
        return normpath(expanduser('~/Library/Application Support'))
<commit_msg>fixed viewdir quote problem<commit_after>"""
cross platform utilities
"""
from __future__ import absolute_import, division, print_function
import os
import sys
import platform
import subprocess
import shlex
from os.path import exists, normpath, join
from os.path import expanduser
from .util_inject import inject
print, print_, printDBG, rrr, profile = inject(__name__, '[cplat]')

COMPUTER_NAME = platform.node()

WIN32  = sys.platform.startswith('win32')
LINUX  = sys.platform.startswith('linux')
DARWIN = sys.platform.startswith('darwin')

LIB_EXT_LIST = ['.so', '.dll', '.dylib']


def get_dynamic_lib_globstrs():
    return ['*' + libext for libext in LIB_EXT_LIST]


def get_computer_name():
    return COMPUTER_NAME


def getroot():
    root = {
        'WIN32': 'C:\\',
        'LINUX': '/',
        'DARWIN': '/',
    }[sys.platform]
    return root


def startfile(fpath):
    print('[cplat] startfile(%r)' % fpath)
    if not exists(fpath):
        raise Exception('Cannot start nonexistant file: %r' % fpath)
    if LINUX:
        out, err, ret = cmd(['xdg-open', fpath], detatch=True)
        if not ret:
            raise Exception(out + ' -- ' + err)
    elif DARWIN:
        out, err, ret = cmd(['open', fpath], detatch=True)
        if not ret:
            raise Exception(out + ' -- ' + err)
    else:
        os.startfile(fpath)
    pass


def view_directory(dname=None):
    """ view directory """
    print('[cplat] view_directory(%r) ' % dname)
    dname = os.getcwd() if dname is None else dname
    open_prog = {'win32': 'explorer.exe',
                 'linux2': 'nautilus',
                 'darwin': 'open'}[sys.platform]
    dname = normpath(dname)
    if dname.find(' ') != -1 and not dname.startswith(('"', '\'')):
        dname = '"%s"' % dname
    os.system(open_prog + ' ' + dname)


def get_resource_dir():
    """ Returns a directory which should be writable for any application """
    if WIN32:
        return normpath(expanduser('~/AppData/Roaming'))
    if LINUX:
        return normpath(expanduser('~/.config'))
    if DARWIN:
        return normpath(expanduser('~/Library/Application Support'))

{'fraction_non_alphanumeric': 0.1419946872736054, 'fraction_numerical': 0.005554213957981164, 'mean_word_length': 3.0252672497570456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4360113', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1346, 'n_words': 354}