Merge pull request #12927 from OatmealDome/old-tools

Tools: Remove unused and broken scripts
This commit is contained in:
Admiral H. Curtiss 2024-07-14 04:13:19 +02:00 committed by GitHub
commit f23460ab42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 0 additions and 296 deletions

View File

@ -1,109 +0,0 @@
import codecs
import os
import glob
standard_sections = [
"Core",
"EmuState",
"OnLoad",
"OnFrame",
"ActionReplay",
"Video",
"Video_Settings",
"Video_Enhancements",
"Video_Hacks",
"Speedhacks",
]
standard_comments = {
"Core": "Values set here will override the main dolphin settings.",
"EmuState": "The Emulation State. 1 is worst, 5 is best, 0 is not set.",
"OnLoad": "Add memory patches to be loaded once on boot here.",
"OnFrame": "Add memory patches to be applied every frame here.",
"ActionReplay": "Add action replay cheats here.",
"Video": "",
"Video_Settings": "",
"Video_Enhancements": "",
"Video_Hacks": "",
"Speedhacks": "",
}
def normalize_comment(line):
line = line.strip().lstrip('#').lstrip()
if line:
return "# %s" % (line,)
else:
return ""
def normalize_ini_file(in_, out):
sections = {}
current_section = None
toplevel_comment = ""
wants_comment = False
for line in in_:
line = line.strip()
# strip utf8 bom
line = line.lstrip(u'\ufeff')
if line.startswith('#'):
line = normalize_comment(line)
if current_section is None:
toplevel_comment += line
continue
if line.startswith('['):
end = line.find(']')
section_name = line[1:end]
if section_name not in standard_sections:
continue
current_section = []
sections[section_name] = current_section
wants_comment = False
continue
if current_section is None and line:
raise ValueError("invalid junk")
if current_section is None:
continue
if line.startswith('#') and not wants_comment:
continue
current_section.append(line)
if line:
wants_comment = True
out.write(toplevel_comment.strip() + "\n\n")
for section in standard_sections:
lines = '\n'.join(sections.get(section, "")).strip()
comments = standard_comments[section]
if not lines and not comments:
continue
out.write("[%s]\n" % (section,))
if comments:
out.write("# %s\n" % (comments,))
if lines:
out.write(lines)
out.write('\n')
out.write('\n')
def main():
base_path = os.path.dirname(__file__)
pattern = os.path.join(base_path, "../Data/User/GameConfig/??????.ini")
for name in glob.glob(pattern):
in__name = name
out_name = name + '.new'
in_ = codecs.open(in__name, 'r', 'utf8')
out = codecs.open(out_name, 'w', 'utf8')
normalize_ini_file(in_, out)
os.rename(out_name, in__name)
if __name__ == "__main__":
main()

View File

@ -1,42 +0,0 @@
#! /bin/bash
#
# Submits a "buildbot try" message to the Dolphin buildbot with all the
# required options.
opt_file=$HOME/.buildbot/options
if ! [ -f "$opt_file" ]; then
echo >&2 "error: no .buildbot/options configuration file found"
echo >&2 "Read the docs: https://wiki.dolphin-emu.org/index.php?title=Buildbot"
exit 1
fi
if ! which buildbot >/dev/null 2>&1; then
echo >&2 "error: buildbot is not installed"
echo >&2 "Install it from your package manager, or use 'pip install buildbot'"
exit 1
fi
if ! git branch | grep -q '^* '; then
echo "Unable to determine the current Git branch. Input the Git branch name:"
read branchname
else
branchname=$(git branch | grep '^* ' | cut -d ' ' -f 2-)
fi
shortrev=$(git describe --always --long --dirty=+ | sed 's/-g[0-9a-f]*\(+*\)$/\1/')
author=$(grep try_username "$opt_file" | cut -d "'" -f 2)
remote=$(git remote -v | grep dolphin-emu/dolphin.git | head -n1 | cut -f1)
remote=${remote:-origin}
baserev=$(git merge-base HEAD $remote/master)
echo "Branch name: $branchname"
echo "Change author: $author"
echo "Short rev: $shortrev"
echo "Remote: $remote"
echo "Base rev: $baserev"
git diff --binary -r $baserev | buildbot try --properties=branchname=$branchname,author=$author,shortrev=$shortrev --diff=- -p1 --baserev $baserev $*

View File

@ -1,98 +0,0 @@
#! /usr/bin/env python
"""
check-includes.py <file...>
Checks if the includes are sorted properly and following the "system headers
before local headers" rule.
Ignores what is in #if blocks to avoid false negatives.
"""
import re
import sys
def exclude_if_blocks(lines):
'''Removes lines from #if ... #endif blocks.'''
level = 0
for l in lines:
if l.startswith('#if'):
level += 1
elif l.startswith('#endif'):
level -= 1
elif level == 0:
yield l
def filter_includes(lines):
'''Removes lines that are not #include and keeps only the file part.'''
for l in lines:
if l.startswith('#include'):
if 'NOLINT' not in l:
yield l.split(' ')[1]
class IncludeFileSorter(object):
def __init__(self, path):
self.path = path
def __lt__(self, other):
'''Sorting function for include files.
* System headers go before local headers (check the first character -
if it's different, then the one starting with " is the 'larger').
* Then, iterate on all the path components:
* If they are equal, try to continue to the next path component.
* If not, return whether the path component are smaller/larger.
* Paths with less components should go first, so after iterating, check
whether one path still has some / in it.
'''
a, b = self.path, other.path
if a[0] != b[0]:
return False if a[0] == '"' else True
a, b = a[1:-1].lower(), b[1:-1].lower()
while '/' in a and '/' in b:
ca, a = a.split('/', 1)
cb, b = b.split('/', 1)
if ca != cb:
return ca < cb
if '/' in a:
return False
elif '/' in b:
return True
else:
return a < b
def __eq__(self, other):
return self.path.lower() == other.path.lower()
def sort_includes(includes):
return sorted(includes, key=IncludeFileSorter)
def show_differences(bad, good):
bad = [' Current'] + bad
good = [' Should be'] + good
longest = max(len(i) for i in bad)
padded = [i + ' ' * (longest + 4 - len(i)) for i in bad]
return '\n'.join('%s%s' % t for t in zip(padded, good))
def check_file(path):
print('Checking %s' % path)
try:
try:
data = open(path, encoding='utf-8').read()
except TypeError: # py2
data = open(path).read().decode('utf-8')
except UnicodeDecodeError:
sys.stderr.write('%s: bad UTF-8 data\n' % path)
return
lines = (l.strip() for l in data.split('\n'))
lines = exclude_if_blocks(lines)
includes = list(filter_includes(lines))
sorted_includes = sort_includes(includes)
if includes != sorted_includes:
sys.stderr.write('%s: includes are incorrect\n' % path)
sys.stderr.write(show_differences(includes, sorted_includes) + '\n')
if __name__ == '__main__':
for path in sys.argv[1:]:
check_file(path)

View File

@ -1,47 +0,0 @@
#! /bin/bash
if [ "$#" -ne 1 ]; then
echo >&2 "usage: $0 <gameini-file>"
exit 1
fi
[ -z "$PGPASSWORD" ] && read -rs -p 'Enter PostgreSQL password: ' PGPASSWORD
export PGHOST=postgresql1.alwaysdata.com
export PGDATABASE=dolphin-emu_wiki
export PGUSER=dolphin-emu_wiki
export PGPASSWORD
sql() {
psql -A -t -F ',' -c "$1"
}
GAME_ID=$(basename "$1" | cut -c -6)
if ! echo "$GAME_ID" | grep -q '[A-Z0-9]\{6\}'; then
echo >&2 "Invalid game ID: $GAME_ID"
exit 1
fi
GAME_ID_GLOB=$(echo "$GAME_ID" | sed 's/\(...\).\(..\)/\1_\2/')
RATING=$(sql "
SELECT
rating_content.old_text
FROM
page gid_page
LEFT JOIN pagelinks gid_to_main
ON gid_to_main.pl_from = gid_page.page_id
LEFT JOIN page rating_page
ON rating_page.page_title = ('Ratings/' || gid_to_main.pl_title)
LEFT JOIN revision rating_rev
ON rating_rev.rev_id = rating_page.page_latest
LEFT JOIN pagecontent rating_content
ON rating_content.old_id = rating_rev.rev_text_id
WHERE
gid_page.page_title LIKE '$GAME_ID_GLOB'
LIMIT 1
" | grep '^[1-5]$')
if ! [ -z "$RATING" ]; then
sed -i "s/^EmulationStateId.*$/EmulationStateId = $RATING/" "$1"
fi