-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Add-ccleaner-missing-icon
- Loading branch information
Showing
8 changed files
with
58 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,17 @@ | |
PROJECT: ReactOS rapps-db validator | ||
LICENSE: MIT (https://spdx.org/licenses/MIT) | ||
PURPOSE: Validate all rapps-db files | ||
COPYRIGHT: Copyright 2020-2023 Mark Jansen <[email protected]> | ||
COPYRIGHT: Copyright 2020-2024 Mark Jansen <[email protected]> | ||
''' | ||
import os | ||
from pathlib import Path | ||
import sys | ||
from enum import Enum, unique | ||
import struct; | ||
|
||
|
||
# TODO: make this even nicer by using https://github.com/pytorch/add-annotations-github-action | ||
|
||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
REPO_ROOT = Path(__file__).parents[1] | ||
|
||
REQUIRED_SECTION_KEYS = [ | ||
b'Name', | ||
|
@@ -95,6 +97,10 @@ def add(self, line, column, problem): | |
idx = column - 1 + len("b'") # Offset the b' prefix | ||
print(' ' * idx + '^') | ||
|
||
def add_file(self, file, problem): | ||
self._problems += 1 | ||
print('{file}: {problem}'.format(file=file, problem=problem)) | ||
|
||
def problems(self): | ||
return self._problems > 0 | ||
|
||
|
@@ -227,11 +233,11 @@ def text(self): | |
class RappsFile: | ||
def __init__(self, fullname): | ||
self.path = fullname | ||
self.filename = os.path.basename(fullname) | ||
self.filename = fullname.name | ||
self._sections = [] | ||
|
||
def parse(self, reporter): | ||
with open(self.path, 'rb') as f: | ||
with open(str(self.path), 'rb') as f: | ||
lines = [RappsLine(self, idx + 1, line) for idx, line in enumerate(f.readlines())] | ||
|
||
# Create sections from all lines, and add keyvalue entries in their own section | ||
|
@@ -298,14 +304,38 @@ def verify_unique(reporter, lines, line, name): | |
else: | ||
lines[name] = line | ||
|
||
|
||
def validate_repo(dirname): | ||
def validate_single_icon(icon, reporter): | ||
try: | ||
with open(str(icon), 'rb') as f: | ||
header = f.read(4) | ||
# First we validate the header | ||
if header != b'\x00\x00\x01\x00': | ||
reporter.add_file('icons/' + icon.name, 'Bad icon header') | ||
return | ||
# Check that there is at least one icon | ||
num_icons, = struct.unpack('<H', f.read(2)) | ||
if num_icons == 0: | ||
reporter.add_file('icons/' + icon.name, 'Empty icon?') | ||
return | ||
# Should we validate / display individual icons? | ||
# See https://en.wikipedia.org/wiki/ICO_(file_format)#Structure_of_image_directory | ||
except Exception as e: | ||
reporter.add_file('icons/' + icon.name, 'Exception while reading icon: ' + str(e)) | ||
|
||
def validate_icons(ico_dir, reporter): | ||
for icon in ico_dir.glob('*.ico'): | ||
validate_single_icon(icon, reporter) | ||
|
||
|
||
def validate_repo(check_dir): | ||
reporter = Reporter() | ||
|
||
all_files = [RappsFile(filename) for filename in os.listdir(dirname) if filename.endswith('.txt')] | ||
all_files = [RappsFile(file) for file in check_dir.glob('*.txt')] | ||
for entry in all_files: | ||
entry.parse(reporter) | ||
|
||
validate_icons(check_dir / 'icons', reporter) | ||
|
||
if reporter.problems(): | ||
print('Please check https://reactos.org/wiki/RAPPS for details on the file format.') | ||
sys.exit(1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[Section] | ||
Name = Cheat Engine | ||
Version = 6.2 | ||
LicenseType = 1 | ||
Description = Cheat Engine is an open-source tool for modifying game variables by scanning and altering memory addresses. | ||
Category = 7 | ||
URLSite = https://cheatengine.org/ | ||
URLDownload = https://web.archive.org/web/20211225142624if_/https://cheatengine.org/download/CheatEngine62.exe | ||
SHA1 = 5042d797d7fa03425d3ad7e333f5435626ca6534 | ||
SizeBytes = 780088 | ||
[Section] | ||
Name = Cheat Engine | ||
Version = 6.2 | ||
LicenseType = 1 | ||
Description = Cheat Engine is an open-source tool for modifying game variables by scanning and altering memory addresses. | ||
Category = 7 | ||
URLSite = https://cheatengine.org/ | ||
URLDownload = https://web.archive.org/web/20211225142624if_/https://cheatengine.org/download/CheatEngine62.exe | ||
SHA1 = 5042d797d7fa03425d3ad7e333f5435626ca6534 | ||
SizeBytes = 780088 |
Binary file not shown.
Binary file not shown.
Binary file not shown.