tis-vscode-lp-fr

1.67.2-19
French Language Pack for Visual Studio Code
6032 downloads
Download
View on luti logo
tis-vscode-lp-fr icon

  Description 

  • package : tis-vscode-lp-fr
  • version : 1.67.2-19
  • architecture : all
  • categories : Development
  • maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
  • description : French Language Pack for Visual Studio Code
  • locale :
  • target_os : all
  • min_wapt_version : 2.0
  • sources : https://marketplace.visualstudio.com/items/MS-CEINTL.vscode-language-pack-fr
  • installed_size : 2107328
  • impacted_process :
  • description_fr : Module linguistique français pour Visual Studio Code
  • description_pl :
  • description_de :
  • description_es :
  • description_pt :
  • description_it :
  • description_nl :
  • description_ru :
  • editor : Microsoft
  • licence :
  • signature_date : 2022-05-09T05:00:13.801195
  • Depends :

  Setup.py 

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import requests
import time

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
ext_uid_name = "MS-CEINTL.vscode-language-pack-fr"
ext_file_name = "%s.vsix" % ext_uid_name
default_locale = ""  # "" to avoid automatic change, force locale only if needed


def install():
    # Initializing variables
    package_version = control.get_software_version()
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Linux":
        app_dir = makepath("/", "usr", "share", "code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Darwin":
        app_dir = makepath("/", "Applications", "Visual Studio Code.app")
        app_bin_path = makepath(app_dir, "Contents", "Resources", "app", "bin", "code")
    ext_path = makepath(app_dir, ext_file_name)

    # Copying extension to app_dir
    print("Copying: %s (%s)" % (ext_path, package_version))
    filecopyto(ext_file_name, app_dir)


def session_setup():

    # Initializing variables
    package_version = control.get_software_version()
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Linux":
        app_dir = makepath("/", "usr", "share", "code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Darwin":
        app_dir = makepath("/", "Applications", "Visual Studio Code.app")
        app_bin_path = makepath(app_dir, "Contents", "Resources", "app", "bin", "code")
    ext_path = makepath(app_dir, ext_file_name)
    user_app_dir = makepath(user_home_directory, ".vscode")
    user_argv_conf_file = makepath(user_app_dir, "argv.json")

    # Installing extension in user env
    print("Installing: %s (%s) extension in user env" % (ext_file_name, package_version))
    try:
        run('"%s" --install-extension "%s"' % (app_bin_path, ext_path))
    except:
        print("Unable to install extension with: %s" % ext_path)
        try:
            run('"%s" --install-extension "%s" --force' % (app_bin_path, ext_uid_name))
        except:
            print("Unable to force install %s extension" % ext_uid_name)

    # Applying locale as default
    if default_locale:
        print("Applying: %s as default locale" % default_locale)
        user_argv_conf_content = '{"locale": "%s"}' % default_locale
        user_argv_conf_data = json.loads(user_argv_conf_content)
        if not isdir(user_app_dir):
            mkdirs(user_app_dir)
        if not isfile(user_argv_conf_file):
            print("Creating: %s" % user_argv_conf_file)
            json_write_file(user_argv_conf_file, user_argv_conf_data)
        else:
            with open(user_argv_conf_file, "r+") as opened_file_lines:
                file_changed = False
                locale_found = False
                new_data = []
                for line in opened_file_lines.readlines():
                    if '"crash-reporter-id"' in line:
                        if not "," in line:
                            line = line.replace("\n", ",\n")
                            file_changed = True
                    if '"locale"' in line:
                        locale_found = True
                        if not '"locale": "%s"' % default_locale in line:
                            line = '\t"locale": "%s",\n' % default_locale
                            file_changed = True
                    new_data.append(line)
                if file_changed:
                    print("Updating: %s" % user_argv_conf_file)
                    opened_file_lines.seek(0)  # Return to the top of the file
                    opened_file_lines.truncate(0)  # Erase next content of the file
                    opened_file_lines.writelines(new_data[0:])  # Writing new data to the file
            if not locale_found:
                print("Updating: %s" % user_argv_conf_file)
                with open(user_argv_conf_file, "r+") as opened_file:
                    file_content = opened_file.read()
                    file_content = file_content.replace("}", '\t"locale": "%s",\n}' % default_locale)
                    opened_file.seek(0)  # Return to the top of the file
                    opened_file.truncate(0)  # Erase next content of the file
                    opened_file.write(file_content)
    else:
        print("Resetting default locale")
        with open(user_argv_conf_file, "r") as opened_file:
            file_content = opened_file.read()
            if '"locale"' in file_content:
                print("Updating: %s" % user_argv_conf_file)
                with open(user_argv_conf_file, "r+") as opened_file_lines:
                    new_data = []
                    for line in opened_file_lines.readlines():
                        if "locale" in line:
                            line = ""
                        new_data.append(line)
                    opened_file_lines.seek(0)  # Return to the top of the file
                    opened_file_lines.truncate(0)  # Erase next content of the file
                    opened_file_lines.writelines(new_data[0:])  # Writing new data to the file
    """
    # Dirty way to make sure that the LP is applied on first run
    run("code")
    time.sleep(15)
    killalltasks("code") """


def audit():
    # Initializing variables
    package_version = control.get_software_version()
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Linux":
        app_dir = makepath("/", "usr", "share", "code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Darwin":
        app_dir = makepath("/", "Applications", "Visual Studio Code.app")
        app_bin_path = makepath(app_dir, "Contents", "Resources", "app", "bin", "code")
    ext_path = makepath(app_dir, ext_file_name)

    if isfile(ext_path):
        print("OK: %s (%s) extension present" % (ext_file_name, package_version))
        return "OK"
    else:
        print("ERROR: %s (%s) extension absent" % (ext_file_name, package_version))
        return "ERROR"


def uninstall():
    # Initializing variables
    package_version = control.get_software_version()
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Linux":
        app_dir = makepath("/", "usr", "share", "code")
        app_bin_path = makepath(app_dir, "bin", "code")
    elif get_os_name() == "Darwin":
        app_dir = makepath("/", "Applications", "Visual Studio Code.app")
        app_bin_path = makepath(app_dir, "Contents", "Resources", "app", "bin", "code")
    ext_path = makepath(app_dir, ext_file_name)

    # Removing extension from app_dir
    print("Removing: %s" % ext_path)
    remove_file(ext_path)

    # removing extension from user profiles
    print(remove_tree_for_all_users(makepath(".vscode", "extensions", "%s-*" % ext_uid_name)))


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    url = "https://marketplace.visualstudio.com/items/%s" % ext_uid_name
    app_name = control.name
    api_url = "https://api.github.com/repos/microsoft/vscode-loc/releases/latest"

    # Getting latest version information from official sources
    print("API used is: %s" % api_url)
    json_load = json.loads(wgets(api_url, proxies=proxies))
    for download in json_load["assets"]:
        if "vscode-language-pack-fr-" in download["name"]:
            download_url = download["browser_download_url"]
            version = json_load["tag_name"].split("/")[-1]
            latest_bin = ext_file_name
            break

    print("Latest %s version is: %s" % (app_name, version))
    print("Download URL is: %s" % download_url)

    # Downloading latest binaries
    print("Downloading: %s" % latest_bin)
    wget(download_url, latest_bin, proxies=proxies)

    # Changing version of the package
    if Version(version) > control.get_software_version():
        print("Software version updated from: %s to: %s" % (control.get_software_version(), Version(version)))
        result = True
    control.version = "%s-%s" % (Version(version), control.version.split("-", 1)[-1])
    # control.set_software_version(Version(version))
    control.save_control_to_wapt()

    # Validating update-package-sources
    return result


def remove_tree_for_all_users(user_folder_relative_path, ignored_users=None, ignore_system_users=True):
    r"""Remove a specific folder or folders for all user's profiles

    Args:
        user_folder_relative_path (str): relative path to user folder, glob patterns can be used
        ignored_users (str or list of str): ignore specified users
        ignore_system_users (bool): ignore default, public, all users, etc. True by default

    Returns:
        list: list of deleted folders

    >>> print(remove_tree_for_all_users(makepath(".vscode", "extensions", "ms-toolsai.jupyter-*")))
    ['C:\\Users\\username\\.vscode\\extensions\\ms-toolsai.jupyter-2022.2.1001817079', 'C:\\Users\\username\\.vscode\\extensions\\ms-toolsai.jupyter-keymap-1.0.0', 'C:\\Users\\username\\.vscode\\extensions\\ms-toolsai.jupyter-renderers-1.0.6']

    >>> print(remove_tree_for_all_users(makepath(".vscode", "extensions", "ms-toolsai.jupyter-")))
    []

    >>> print(remove_tree_for_all_users(makepath(".vscode", "extensions", "ms-toolsai.jupyter-[a-z]*")))
    ['C:\\Users\\username\\.vscode\\extensions\\ms-toolsai.jupyter-keymap-1.0.0', 'C:\\Users\\username\\.vscode\\extensions\\ms-toolsai.jupyter-renderers-1.0.6']

    >>> print(remove_tree_for_all_users(makepath(".vscode", "extensions", "ms-toolsai.jupyter-1.0.0")))
    ['/home/username/.vscode/extensions/ms-toolsai.jupyter-keymap-1.0.0']

    .. versionadded:: 2.3

    """
    system_users_list = ["All Users", "Default", "Default User", "Public", "Shared"]
    if ignored_users is None:
        ignored_users = []
    if type(ignored_users) != list:
        ignored_users = [ignored_users]

    deleted_folders = []
    skipped_users = []
    if ignored_users:
        skipped_users.extend(ignored_users)
    if ignore_system_users:
        skipped_users.extend(system_users_list)

    if get_os_name() == "Windows":
        users_dir = makepath(systemdrive, "Users")
    elif get_os_name() == "Linux":
        users_dir = "/home"
    elif get_os_name() == "Darwin":
        users_dir = "/Users"

    for user_profile in glob.glob("%s/*/" % users_dir):
        for ignored_user in ignored_users:
            if user_profile.rstrip(os.path.sep).split(os.path.sep)[-1] == ignored_user:
                continue
        for user_folder_to_delete in glob.glob(r"%s" % makepath(user_profile, user_folder_relative_path)):
            deleted_folders.append(user_folder_to_delete)
            remove_tree(user_folder_to_delete)
    return deleted_folders

										

  Changelog 



Changelog software url : https://marketplace.visualstudio.com/items/MS-CEINTL.vscode-language-pack-fr/changelog



No changelog.txt.
									
  manifest.sha256