<commit_before>#!/usr/bin/env python3

import os
from os.path import join, abspath, dirname, islink, exists
import json

curdir = dirname(abspath(__file__))
os.chdir(curdir)
# os.symlink(src, dst)

extra_path = {
    'bootstrap': 'dist/css/',
    'katex': 'dist/',
    'lozad': 'dist/',
}

# remove symlinks
for fn in os.listdir('.'):
    if islink(fn):
        os.unlink(fn)

deps = json.load(open('package-lock.json'))["dependencies"]
versions = {}
for path, data in deps.items():
    if '/' in path:
        name = path.split('/')[-1]
    else:
        name = path
    extra = extra_path.get(name, '')
    src = join(curdir, "node_modules", path, extra)
    if not exists(src):
        raise Exception(
            f"target '{src}' does not exist -- did you forget to run 'npm ci' in '{curdir}'?"
        )
    version = data['version']
    dst = f"{name}-{version}"
    print(f"symlink with    version '{dst}' → '{src}'")
    os.symlink(src, dst)
    dst = f"{name}"
    print(f"symlink without version '{dst}' → '{src}'")<commit_msg>resources/setup: non-utf8 char in string<commit_after>#!/usr/bin/env python3

import os
from os.path import join, abspath, dirname, islink, exists
import json

curdir = dirname(abspath(__file__))
os.chdir(curdir)
# os.symlink(src, dst)

extra_path = {
    'bootstrap': 'dist/css/',
    'katex': 'dist/',
    'lozad': 'dist/',
}

# remove symlinks
for fn in os.listdir('.'):
    if islink(fn):
        os.unlink(fn)

deps = json.load(open('package-lock.json'))["dependencies"]
versions = {}
for path, data in deps.items():
    if '/' in path:
        name = path.split('/')[-1]
    else:
        name = path
    extra = extra_path.get(name, '')
    src = join(curdir, "node_modules", path, extra)
    if not exists(src):
        raise Exception(
            f"target '{src}' does not exist -- did you forget to run 'npm ci' in '{curdir}'?"
        )
    version = data['version']
    dst = f"{name}-{version}"
    print(f"symlink with    version '{dst}' -> '{src}'")
    os.symlink(src, dst)
    dst = f"{name}"
    print(f"symlink without version '{dst}' -> '{src}'")
{'fraction_non_alphanumeric': 0.17909738717339668, 'fraction_numerical': 0.0023752969121140144, 'mean_word_length': 2.951219512195122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6939740', 'n_tokens_mistral': 755, 'n_tokens_neox': 750, 'n_words': 195}