Commit Graph

8554 Commits

Author SHA1 Message Date
Dunedan 230c7ca27d Add EditorConfig options for Python
While the desired options for indent size and style are Python's
defaults, let's make it explicit by specifying it in the EditorConfig.

As part of this, this also removes unnecessary inline formatting options
for Python files.
2024-09-17 11:03:15 +02:00
Dunedan cd8b4266a4 Fix class name in xmlvalidator 2024-09-13 11:04:06 +02:00
Dunedan 8c7cc7373d Fix variable names in SPIRV compile.py 2024-09-13 11:04:06 +02:00
Dunedan 0d3e3fbc29 Rename simple-example.py 2024-09-13 11:04:05 +02:00
Dunedan 661328ab15 Fix variable naming for map compatibility file 2024-09-13 11:04:05 +02:00
Dunedan 616f2e134b Fix variable names in checkrefs.py 2024-09-13 11:04:04 +02:00
Dunedan ea4b580527 Simplify JSON parsing 2024-09-11 17:52:10 +02:00
Dunedan 0e84957979 Simplify XML parsing by iterating only once
This simplifies the XML parsing, by iterating over the DOM tree only
once. Curiously this doesn't result in significant performance gains.

As the keywords are now found in the order they appear in the
document instead of the order they are mentioned in messages.json, the
order of a few strings in the PO-templates changes caused by the changes
in this commit.
2024-09-11 17:52:10 +02:00
Dunedan eeb502c115 Simplify code by making use of early returns 2024-09-11 17:52:10 +02:00
Dunedan f4c40b740c Remove unnecessary extractors package
This simplifies the code structure, by removing the extractors package,
which only contained a single module, the extractors module. This module
is now located in the i18n_helper package.
2024-09-11 17:52:09 +02:00
Dunedan 20ab96a0f4 Make some attribute names PEP 8 compatible 2024-09-11 17:52:09 +02:00
Dunedan ac48b72550 Move imports to the top of the file 2024-09-11 17:52:09 +02:00
Dunedan 4d3be23bac Remove broken and unused ini-file extractor
The ini-file extractor has been broken since the transition to Python 3
and nobody noticed, because it isn't used nowadays. Therefore, let's
remove it.
2024-09-11 17:52:09 +02:00
Dunedan f856a7663f Add a cache for mask patterns
This increases the performance of updating the PO-templates
significantly by adding a cache for the building of mask patterns. In
non-representative tests it increased the performance of updating the
PO-templates by >25%.
2024-09-11 17:52:09 +02:00
Dunedan 7575dfe3c8 Remove unnecessary use of codecs module 2024-09-11 17:52:08 +02:00
Dunedan e86fd58524 Simplify and speed up finding of messages.json 2024-09-11 17:51:58 +02:00
Dunedan 04aa01a39b Speed up fetching of translations from Transifex
This increases the number of workers to use when fetching translations
from Transifex from 5 (the default) to 12. While the Transifex CLI
allows up to 20 workers, using more workers results in frequent request
throttling, which hurts performance more than it improves it.
2024-09-10 07:34:48 +02:00
Dunedan ccb1d747f0 Use PEP 8 naming conventions for templatesanalyzer 2024-09-10 07:29:33 +02:00
Dunedan 10e7513bba Revert changes in check_diff.py in batches
This is to avoid running into errors caused by the limited length of
command line input when reverting lots of files.
2024-09-08 11:39:08 +02:00
Itms 34a209b680 Update glad to 2.0.7
Release: https://github.com/Dav1dde/glad/releases/tag/v2.0.7
2024-09-08 09:31:14 +02:00
Itms 0f87124b98 Some glad improvements
- Silence a MSVC warning in vulkan.cpp, refs #6987
- Document the patching of gl.h for macOS, from r26094
- Fix shellcheck warnings in the generation script
2024-09-08 09:26:46 +02:00
Itms 35d998694f Move glad from source-libs to source/third_party
Improve definition of the gladwrapper project in premake.
2024-09-08 09:18:45 +02:00
Itms 8d0af4b184 Unify Windows scripts for getting nightly binaries
The new script merges existing scripts for downloading translations and
SPIR-V shaders, and also exports game binaries from the latest nightly
build into the git repo.

This allows contributors, especially artists, to obtain a working build
of the game without learning how to build the game for Windows, refs #1814.
2024-09-04 17:20:50 +02:00
Dunedan eb499b4c5c Fix a regression introduced with 4a049c5f3a 2024-09-04 15:03:21 +02:00
Dunedan 19e7d14506 Use PEP 8 naming conventions for fontbuilder2 2024-09-03 14:01:47 +02:00
Dunedan 4a049c5f3a Use PEP 8 naming conventions for i18n tools 2024-09-03 13:51:27 +02:00
Dunedan 80f808df4a Markdown format for fontbuilder2 README
The fontbuilder2 README file was already partially formatted with
Markdown, but didn't indicate that via its file extension. This commit
changes that and improves the formatting of the README itself.
2024-09-03 13:39:28 +02:00
Dunedan bcf97b608b Enable ruff rules for docstrings and comments
This enables some ruff rules for docstrings and comments. The idea is to
not enforce the presence of docstrings, but to ensure they are properly
formatted if they're present.

For comments this adds checks that they don't contain code and verify
the formatting of comments with "TODO" tags.

As part of this, some commented out code which hasn't been touch in the
past 10 years gets removed as well.

The rules enabled enabled by this are:

- check formatting of existing docstrings (D200-)
- check comments for code (ERA)
- check formatting of TODO tags (TD001, TD004-)
2024-08-31 21:09:20 +02:00
Ralph Sennhauser 2634f8762e build-unix-win32.sh: move to posix shell
Convert non posix shell constructs and change shebang to /bin/sh

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-29 12:55:26 +02:00
Ralph Sennhauser 1c4a32baa4 build-archives.sh: move to posix shell
Convert various no posix constructs and change the shebang to /bin/sh.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-29 12:55:26 +02:00
Ralph Sennhauser 8ed1a0cb5a templatessorter.sh: move to posix shell
This one is already clean, so just change the shebang

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-29 12:55:26 +02:00
Dunedan f2bef8388a Use UTF-8 as encoding when working with files
This explicitly uses UTF-8 encoding when reading or writing files with
Python. This is necessary as the default locale varies between
operating systems.
2024-08-29 07:22:46 +02:00
Dunedan c3b99feb60 Enable ruff rules for code simplification
This enables ruff rules which check for code which can be simplified to
improve readability.

The additionally rules getting enabled by this are:

- remove unnecessary nesting of if-statements (SIM102)
- use contextlib.suppress() for no-op exception handling (SIM105)
- use enumerate() for counting in loops (SIM113)
- use context managers for opening files (SIM115)
2024-08-29 07:00:43 +02:00
Stan 028ec40165 Add a RC file to add metadata to the pyrogenesis executable 2024-08-28 23:37:36 +02:00
Ralph Sennhauser 6f5ac7c4ae Fix issues pointed out by shellcheck
Some are real bugs, some are bashisms, but most is zealous quoting of
variables.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-28 18:23:18 +02:00
Dunedan ea647067f0 Enable ruff rules to check for ambiguous code
This enables some ruff rules to check for ambiguous and dead Python
code, which might cause unintended side-effects.

The enabled rules are:

- a bunch of rules related to shadowing of builtin structures (A)
- a bunch of rules checking for unused arguments (ARG)
- a rule checking for useless expressions (B018)
- a rule checking for unbound loop variables (B023)
- a rule checking redefined function parameters (PLR1704)
2024-08-27 19:28:11 +02:00
Dunedan ae3fad73ce Add a markdownlint pre-commit hook
This adds a pre-commit hook to link Markdown files and fixes all
reported findings.
2024-08-27 10:06:31 +02:00
Ralph Sennhauser abdda50892 Format shell scripts using shfmt
This updates shell scripts to use a consistent style that can be enforced
via pre-commit hook.

As for choosing tabs over spaces, some arguments are:

- tabs can help people with visual impairment
- tabs allow for indenting heredocs in bash
- tabs are the default for the tool shfmt

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-26 09:03:00 +02:00
Dunedan 1800b5f1c0 Add executable bits for files with shebangs 2024-08-26 07:46:38 +02:00
Dunedan f58dc9b485 Remove unnecessary executable bits
This removes the executable bits from files which aren't supposed to
have them.

Also removes shebangs for files which aren't supposed to be executable.
2024-08-26 07:46:34 +02:00
Dunedan 05e708f987 Refactor check_* functions for better readability 2024-08-25 21:24:00 +02:00
Dunedan 75949e1f5a Replace use of os.path with pathlib 2024-08-25 21:24:00 +02:00
Dunedan 4b77d7bb74 Compile regex pattern once
This should slightly increase the performance as the pattern has to be
only compiled once, instead of so during every loop iteration.
2024-08-25 21:24:00 +02:00
Dunedan 87029f2a91 Replace uses of re.split() with str.split() 2024-08-25 21:23:59 +02:00
Dunedan 24e67746f9 Log a warning when a specified mod can't be found 2024-08-25 21:23:59 +02:00
Dunedan 92d92fac1b Remove unnecessary default value for dict.get() 2024-08-25 21:23:59 +02:00
Dunedan 0dea22285e Fix the exit codes of checkrefs.py 2024-08-25 21:23:59 +02:00
Dunedan 39f2889cf7 Support calling checkrefs.py from other dirs 2024-08-25 21:23:59 +02:00
phosit f22d0d899e Add final to classes introduced in f9114a87f2
A class which can not be derived from should tell that in the
declaration.
2024-08-25 13:38:09 +02:00
phosit 62c0080e1b Don't use std::shared_ptr in CStrIntern
Now there is less allocation and reference counting.
2024-08-25 11:58:22 +02:00