tis-vscode-lp-fr

1.63.3-15
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.63.3-15
  • 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 : Code
  • 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-02-02T13:03:42.113146
  • Depends :

  Setup.py 

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import platform
import bs4 as BeautifulSoup
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_name = "MS-CEINTL.vscode-language-pack-fr.vsix"
ext_unique_identifier = "MS-CEINTL.vscode-language-pack-fr"
app_from_path = "code"
default_locale = "fr"  # Change to "" to avoid automatic change


def install():
    # Declaring local variables
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
    elif get_os_name() == "Linux":
        app_dir = "/usr/share/code/"
    elif get_os_name() == "Darwin":
        app_dir = "/Applications/Visual Studio Code.app/"
    ext_path = makepath(app_dir, ext_name)

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


def session_setup():
    # Declaring local variables
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
        user_app_dir = makepath(user_home_directory, ".vscode")
        user_argv_conf_file = makepath(user_app_dir, "argv.json")
        user_conf_dir = makepath(user_appdata, "Code", "User")
    elif get_os_name() == "Linux":
        app_dir = "/usr/share/code/"
        user_app_dir = makepath(user_home_directory(), ".vscode")
        user_argv_conf_file = makepath(user_app_dir, "argv.json")
        user_conf_dir = makepath(user_home_directory(), ".config", "Code", "User")
    elif get_os_name() == "Darwin":
        app_dir = "/Applications/Visual Studio Code.app/"
        user_app_dir = makepath(user_home_directory(), ".vscode")
        user_argv_conf_file = makepath(user_app_dir, "argv.json")
        user_conf_dir = makepath(user_home_directory(), "Library", "Application Support", "Code", "User")
    ext_path = makepath(app_dir, ext_name)

    # Installing extension in user env
    print("Installing %s extension in user env" % ext_name)
    run_notfatal('%s --install-extension "%s"' % (app_from_path, ext_path))

    # 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


def uninstall():
    # Declaring local variables
    if get_os_name() == "Windows":
        app_dir = makepath(programfiles, "Microsoft VS Code")
    elif get_os_name() == "Linux":
        app_dir = "/usr/share/code/"
    elif get_os_name() == "Darwin":
        app_dir = "/Applications/Visual Studio Code.app/"
    ext_path = makepath(app_dir, ext_name)

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


def update_package():
    # Initializing variables
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    url = "https://marketplace.visualstudio.com/items/%s" % ext_unique_identifier

    """ # Getting latest version from official sources
    print("URL used is %s" % url)
    for bs_search in bs_find_all(
        url,
        "script",
        "type",
        "application/json",
        proxies=proxies,
        user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.68",
    ):
        if bs_search.string.startswith("{"):
            json_data = json.loads(bs_search.string)
            break

    version = json_data["Resources"]["Version"]
    download_url = "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/%s/vsextensions/%s/%s/vspackage" % (
        json_data["Resources"]["PublisherName"],
        json_data["Resources"]["ExtensionName"],
        version,
    ) """

    api_url = "https://update.code.visualstudio.com/api/update/win32-x64/stable/VERSION"

    # Getting latest version information from official sources
    print("API used is: %s" % api_url)
    json_load = json.loads(wgets(api_url, proxies=proxies))
    version = json_load["productVersion"]
    if version == "1.63.2":
        version = "1.63.3"
    download_url = (
        "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/MS-CEINTL/vsextensions/vscode-language-pack-fr/%s/vspackage" % version
    )
    latest_bin = ext_name

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

    # Downloading latest binaries
    print("Downloading %s" % latest_bin)
    content = requests.get(download_url, stream=True)
    nb_wait = 0
    max_wait = 3600
    while str(content.status_code) == "429":
        timewait = int(content.headers["Retry-After"])
        print("Wait %s" % timewait)
        nb_wait = nb_wait + timewait
        if nb_wait > max_wait:
            error("Max wait ...")
        time.sleep(timewait)
        content = requests.get(download_url, stream=True)

    with open(latest_bin, "wb") as f:
        for chunk in content.iter_content(chunk_size=1024 * 1024):
            f.write(chunk)

    # Changing version of the package
    control.version = "%s-%s" % (version, control.version.split("-", 1)[-1])
    control.save_control_to_wapt()
    print("Changing package version to %s in WAPT\\control" % control.version)


def get_os_name():
    return platform.system()


def get_proxies():
    r"""Return system proxy with the urllib python library

    >>> get_proxies()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

    """
    if platform.python_version_tuple()[0] == "3":
        from urllib.request import getproxies
    else:
        from urllib import getproxies
    return getproxies()


def get_proxies_from_wapt_console():
    r"""Return proxy information from the current user WAPT console

    >>> get_proxies_from_wapt_console()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

    """
    proxies = {}
    if platform.system() == "Windows":
        waptconsole_ini_path = makepath(user_local_appdata(), "waptconsole", "waptconsole.ini")
    else:
        waptconsole_ini_path = makepath(user_home_directory(), ".config", "waptconsole", "waptconsole.ini")
    if isfile(waptconsole_ini_path):
        proxy_wapt = inifile_readstring(waptconsole_ini_path, "global", "http_proxy")
        if proxy_wapt:
            proxies = {"http": proxy_wapt, "https": proxy_wapt}
    return proxies


def bs_find_all(url, element, attribute=None, value=None, user_agent=None, proxies=None, features="html.parser", **kwargs):
    r""" "Parse html web page with BeautifulSoup and get a list of the result

    Args:
        url (str): url of the web page to parse
        element (str): searched element
        attribute (str): selected attribute of the element
        value (str): value of the selected attribute
        user_agent (str): specify a user-agent if needed
        proxies (dict): specify your proxy if needed
        **kwargs (str): joker for requests parameters
        features (str): bs feature to use


    >>> bs_find_all('https://www.w3.org/', 'a', 'title', 'Open Web Platform testing')[0]['href']
    'https://web-platform-tests.org/'

    >>> bs_find_all('https://www.w3.org/', 'span', 'class', 'alt-logo')[0].string
    'W3C'

    .. versionadded:: 2.0

    """
    import requests

    if user_agent:
        page = requests.get(url, proxies=proxies, headers={"User-Agent": "%s" % user_agent}, **kwargs).text
    else:
        page = requests.get(url, proxies=proxies, **kwargs).text
    soup = BeautifulSoup.BeautifulSoup(page, features=features)
    if value:
        return soup.find_all(element, {attribute: value})
    else:
        return soup.find_all(element)

										

  Changelog 



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



No changelog.txt.
									
  manifest.sha256