tis-add-fonts

2.1.3.0-2
Install Fonts, install Inconsolata fonts by default
0 downloads
Download
View on luti logo
tis-add-fonts icon

  Description 

  • package : tis-add-fonts
  • version : 2.1.3.0-2
  • architecture : all
  • categories : Configuration
  • maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
  • description : Install Fonts, install Inconsolata fonts by default
  • locale : all
  • target_os : windows
  • min_wapt_version : 1.8.2
  • sources :
  • installed_size :
  • impacted_process :
  • description_fr : Installation de polices, installe les polices Inconsolata par défaut
  • description_pl :
  • description_de :
  • description_es :
  • description_pt :
  • description_it :
  • description_nl :
  • description_ru :
  • editor :
  • licence :
  • signature_date : 2022-04-20T11:06:43.178623
  • Conflicts :

  Setup.py 

# -*- coding: utf-8 -*-
from setuphelpers import *

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
bin_name_x86 = "FontReg32.exe"
bin_name_x64 = "FontReg64.exe"


def install():
    # Declaring local variables
    if iswin64():
        bin_name = bin_name_x64
    else:
        bin_name = bin_name_x86

    # Installing the fonts
    for fonts in glob.glob("fonts/*"):
        print("Installing Font: %s" % fonts.split("\\")[-1])
    run(r"cd fonts && ..\%s /copy" % bin_name)
    print("INFO: The PC must be rebooted for the fonts to appear")


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()

    # Downloading latest binaries
    if not isfile(bin_name_x64):
        print("Downloading: %s" % bin_name_x64)
        wget("https://raw.githubusercontent.com/jason-jxc/FontReg/master/bin.x86-64/FontReg.exe", bin_name_x64, proxies=proxies)
    if not isfile(bin_name_x86):
        print("Downloading: %s" % bin_name_x86)
        wget("https://raw.githubusercontent.com/jason-jxc/FontReg/master/bin.x86-32/FontReg.exe", bin_name_x86, proxies=proxies)

    # Downloading fonts
    if not isfile("Inconsolata.zip"):
        print("Downloading: %s" % "Inconsolata.zip")
        wget("https://fonts.google.com/download?family=Inconsolata", "Inconsolata.zip", proxies=proxies)
    unzip("Inconsolata.zip", "fonts", "*.ttf", extract_with_full_paths=False)
    remove_file("Inconsolata.zip")

    # Checking version from file
    version = get_version_from_binary(bin_name_x86)

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

    # Validating update-package-sources
    return result


def unzip(zipfn, target=None, filenames=None, extract_with_full_paths=True):
    r"""Unzip the files from zipfile with patterns in filenames to target directory
    Args:
        zipfn (str) : path to zipfile. (can be relative to temporary unzip location of package)
        target (str) : target location. Defaults to dirname(zipfile) + basename(zipfile)
        filenames (str or list of str): list of filenames / glob patterns (path sep is normally a slash)
        extract_with_full_paths (bool): keeping or not the subfolders of the archive as is
    Returns:
        list : list of extracted files
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt')
    ['C:\\example\\tis-7zip_9.2.0-15_all\\7z920-x64.msi',
     'C:\\example\\tis-7zip_9.2.0-15_all\\7z920.msi',
     'C:\\example\\tis-7zip_9.2.0-15_all\\setup.py',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/control',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/wapt.psproj',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/manifest.sha256',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/signature']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', filenames=['*.msi','*.py'])
    ['C:\\example\\tis-7zip_9.2.0-15_all\\7z920-x64.msi',
     'C:\\example\\tis-7zip_9.2.0-15_all\\7z920.msi',
     'C:\\example\\tis-7zip_9.2.0-15_all\\setup.py']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', target='test', filenames=['*.msi','*.py'])
    ['C:\\example\\test\\7z920-x64.msi',
     'C:\\example\\test\\7z920.msi',
     'C:\\example\\test\\setup.py']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', filenames='WAPT/*')
    ['C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/control',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/wapt.psproj',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/manifest.sha256',
     'C:\\example\\tis-7zip_9.2.0-15_all\\WAPT/signature']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', filenames='WAPT/control')
    ['C:\\example\\tis-7zip_9.2.0-15_all\\WAPT\\control']
    >>> unzip('tis-7zip_9.2.0-15_all.wapt', target='.', filenames='WAPT/control')
    ['.\\WAPT\\control']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', target=r'C:\example\', filenames='WAPT/control')
    ['C:\\example\\WAPT\\control']
    >>> unzip('tis-7zip_9.2.0-15_all.wapt', target=basedir, filenames='WAPT/control')
    ['C:\\example\\WAPT\\control']
    >>> unzip(r'C:\example\tis-7zip_9.2.0-15_all.wapt', filenames='WAPT/control', extract_with_full_paths=False)
    ['C:\\example\\control']
    .. versionadded:: 1.3.11
    .. versionchanged:: 2.2
        added extract_with_full_paths parameter
    """
    from waptutils import CustomZipFile
    import sys

    zipf = CustomZipFile(zipfn, allowZip64=True)
    if target is None:
        target = makepath(os.path.dirname(os.path.abspath(zipfn)), os.path.splitext(os.path.basename(zipfn))[0])

    if filenames is not None:
        filenames = [pattern.replace("\\", "/") for pattern in ensure_list(filenames)]

    def match(fn, filenames):
        # return True if fn matches one of the pattern in filenames
        if filenames is None:
            return True
        else:
            for pattern in filenames:
                if glob.fnmatch.fnmatch(fn, pattern):
                    return True
            return False

    if filenames is not None:
        files = [fn for fn in zipf.namelist() if match(fn, filenames)]
        members = files
    else:
        files = zipf.namelist()
        members = None

    if sys.platform != "darwin" and extract_with_full_paths:
        zipf.extractall(target, members)
    elif not extract_with_full_paths:
        files_to_extract = files
        files = []
        os.makedirs(target, exist_ok=True)
        for fn in files_to_extract:
            filename = os.path.basename(fn)
            # skip directories
            if not filename:
                continue

            # copy file (taken from zipfile's extract)
            source = zipf.open(fn)
            files.append(os.path.join(filename))
            dest = open(os.path.join(target, filename), "wb")
            with source, dest:
                shutil.copyfileobj(source, dest)
    else:  # the zipfile module doesn't support symlinks, and it's used in macOS packages
        try:
            members_str = " ".join('"{0}"'.format(m) for m in members) if members else ""
            unzip_cmd = "unzip -qq {zipfile} {members_str} -d {destination_dir}".format(
                zipfile=zipfn, members_str=members_str, destination_dir=target
            )
            run(unzip_cmd)
        except:
            print("Error : couldn't unzip {}".format(zipfn))
            return []

    return [makepath(target, fn.replace("/", os.sep)) for fn in files]

										

  Changelog 



2.1.3.0-2
Switch print to INFO term instead of WARING
Formating code
									
  manifest.sha256