Philipp Hörist pushed to branch master at gajim / gajim
Commits: 0f3a42fd by lovetox at 2022-05-30T07:52:33+02:00 chore: Remove obsolete scripts
- - - - - be8659e7 by lovetox at 2022-05-30T07:52:33+02:00 chore: Script: Add type annotations
- - - - - 38b0f471 by lovetox at 2022-05-30T07:52:33+02:00 chore: Remove scripts/dev folder
- - - - - 313e50d3 by lovetox at 2022-05-30T07:53:23+02:00 chore: Setup.py: Add type annotations
- - - - - 72e5a16d by lovetox at 2022-05-30T07:53:23+02:00 chore: Update pyrightconfig.json
- - - - -
6 changed files:
- pyrightconfig.json - − scripts/dev/multisplit.scm - − scripts/dev/pngcrush - scripts/dev/generate_ui_types.py → scripts/generate_ui_types.py - scripts/dev/pre-push-tests.sh → scripts/pre-push-tests.sh - setup.py
Changes:
===================================== pyrightconfig.json ===================================== @@ -10,8 +10,11 @@ ".git" ], "include": [ - "win/*", + "launch.py", + "setup.py", ".ci/*", + "scripts/*", + "win/*", "gajim/gajim.py", "gajim/plugins/gajimplugin.py", "gajim/plugins/helpers.py",
===================================== scripts/dev/multisplit.scm deleted ===================================== @@ -1,74 +0,0 @@ -; multisplit: splits up a mavica multi (sprites in one layer) into layers -; so you make make from png/jpg sprite a gif animation -; put me in ~/.gimp-ver/scripts and find me script-fu>animators>MultiSplit - -(define (script-fu-multisplit multimg - drawable - horizontal - vertical - delay) - (let* ( - (width 0) - (height 0) - (img 0) - (layerNum 0) - (hpos 0) - (vpos 0) - (layer 0) - (floatingLayer 0) - ) - - (set! width (/ (car (gimp-image-width multimg)) horizontal)) - (set! height (/ (car (gimp-image-height multimg)) vertical)) - (set! img (car (gimp-image-new width height RGB))) - - (set! vpos 0) - (while (< vpos vertical) - (set! hpos 0) - (while (< hpos horizontal) - (set! layerNum (+ layerNum 1)) - (set! layer (car (gimp-layer-new img width height RGB - (string-append "Frame" delay "(replace)") - 100 NORMAL))) - - (gimp-layer-add-alpha layer) - (gimp-drawable-fill layer TRANSPARENT-FILL) - (gimp-image-add-layer img layer -1) - - (gimp-rect-select multimg - (* hpos width) (* vpos height) - width height - REPLACE FALSE 0) - - (gimp-edit-copy drawable) - - (gimp-selection-all img) - - (set! floatingLayer (car (gimp-edit-paste layer 0))) - (gimp-floating-sel-anchor floatingLayer) - - (gimp-selection-none img) - (gimp-selection-none multimg) - - (set! hpos (+ hpos 1)) - ) - (set! vpos (+ vpos 1)) - ) - - (gimp-display-new img) - ) -) - -(script-fu-register "script-fu-multisplit" - "<Image>/Script-Fu/Animators/MultiSplit" - "Split an image into layers" - "Rick Miller (Rick.Miller@Linux.org)" - "Rick Miller" - "05/19/2000" - "RGB RGBA GRAY GRAYA" - SF-IMAGE "Image" 0 - SF-DRAWABLE "Drawable" 0 - SF-VALUE "Horizontal Slices" "3" - SF-VALUE "Vertical Slices" "3" - SF-VALUE "Default Delay" ""250ms"") -
===================================== scripts/dev/pngcrush deleted ===================================== @@ -1,22 +0,0 @@ -#!/bin/sh - -# there can be as many input arguments as you want -# they are all assumed to be PNG file names - -# run as sh pngcrush $(ls *png) - -# loop through all arguments -while (( $# >= 1 )); do - # create temp output file - # output file has all colorspace chunks removed and optimized compression - pngcrush -l 9 "$1" "$1".tmp - # remove the original file - rm "$1" - # replace the original with the new optimized output file - mv "$1".tmp "$1" - shift -done - -exit 0 - -# from http://cvs.sourceforge.net/viewcvs.py/tom7misc/vstplugins/scripts/fixpng?rev...
===================================== scripts/dev/generate_ui_types.py → scripts/generate_ui_types.py ===================================== @@ -3,6 +3,7 @@ # Reads all .ui files and creates builder.pyi # Excecute this script from the repo root dir
+from io import TextIOWrapper from pathlib import Path from xml.etree import ElementTree as ET
@@ -41,22 +42,22 @@ def get_builder(file_name: Literal['%s'], widgets: list[str] = ...) -> %s: ...'' def get_builder(file_name: str, widgets: list[str] = ...) -> Builder: ...'''
-def make_class_name(path): +def make_class_name(path: Path) -> str: name = path.name.removesuffix('.ui') names = name.split('_') names = map(lambda x: x.capitalize(), names) return ''.join(names) + 'Builder'
-def parse(path, file): +def parse(path: Path, file: TextIOWrapper) -> str: print('read', path) - lines = [] + lines: list[str] = [] tree = ET.parse(path) for node in tree.iter(tag='object'): id_ = node.attrib.get('id') if id_ is None: continue - klass = node.attrib.get('class') + klass = node.attrib['class'] if klass.startswith('GtkSource'): klass = f'GtkSource.{klass.removeprefix("GtkSource")}' elif klass.startswith('Atk'): @@ -78,7 +79,7 @@ def parse(path, file): return klass_name
-builder_names = [] +builder_names: list[tuple[str, str]] = []
with out_path.open(mode='w', encoding='utf8') as file: file.write(IMPORTS)
===================================== scripts/dev/pre-push-tests.sh → scripts/pre-push-tests.sh =====================================
===================================== setup.py ===================================== @@ -2,6 +2,8 @@
from __future__ import annotations
+from typing import cast + import os import sys
@@ -16,6 +18,9 @@ from setuptools.command.install import install as _install
+DataFilesT = list[tuple[str, list[str]]] + + MAN_FILES = [ 'gajim.1', 'gajim-remote.1' @@ -65,7 +70,7 @@ def build_translation() -> None: print('Compiling %s >> %s' % (po_file, mo_file))
-def install_trans(data_files) -> None: +def install_trans(data_files: DataFilesT) -> None: for lang in ALL_LINGUAS: mo_file = str(BUILD_DIR / 'mo' / lang / 'LC_MESSAGES' / 'gajim.mo') target = f'share/locale/{lang}/LC_MESSAGES' @@ -97,7 +102,7 @@ def build_man() -> None: print('Compiling %s >> %s' % (filename, man_file_gz))
-def install_man(data_files) -> None: +def install_man(data_files: DataFilesT) -> None: man_dir = BUILD_DIR / 'man' target = 'share/man/man1'
@@ -120,12 +125,15 @@ def build_intl() -> None: merge(Path(filename + '.in'), newfile, option)
-def install_intl(data_files) -> None: +def install_intl(data_files: DataFilesT) -> None: for filename, target, _ in META_FILES: data_files.append((target, [str(BUILD_DIR / filename)]))
-def merge(in_file, out_file, option, po_dir: str = 'po') -> None: +def merge(in_file: Path, + out_file: Path, + option: str, + po_dir: str = 'po') -> None: ''' Run the msgfmt command. ''' @@ -154,12 +162,12 @@ def run(self):
class install(_install): def run(self): - data_files = self.distribution.data_files + data_files = cast(DataFilesT, self.distribution.data_files) # pyright: ignore install_trans(data_files) if sys.platform != 'win32': install_man(data_files) install_intl(data_files) - _install.run(self) + _install.run(self) # pyright: ignore
# only install subdirectories of data @@ -170,7 +178,7 @@ def run(self): ["gajim/data/icons/hicolor/scalable/apps/org.gajim.Gajim-symbolic.svg"]) ]
-data_files = data_files_app_icon +data_files: DataFilesT = data_files_app_icon
setup( cmdclass={
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/44bcafaeece862d7eacc04af7f776343...