mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-04 04:25:46 -04:00
Convert sanity-check script to Python.
This commit is contained in:
parent
c9e8446050
commit
ecb5d573d7
1 changed files with 63 additions and 36 deletions
97
sanity-check.pl → sanity-check.py
Normal file → Executable file
97
sanity-check.pl → sanity-check.py
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# perform sanity check on assignments lists; make sure everything in
|
# perform sanity check on assignments lists; make sure everything in
|
||||||
# the deutex tree is listed in the assignment lists
|
# the deutex tree is listed in the assignment lists
|
||||||
|
@ -31,49 +31,76 @@
|
||||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
sub sanitycheck {
|
import glob
|
||||||
my ($dir, $file) = @_;
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
print "Checking $dir\n";
|
# Find the file matching the given lump name:
|
||||||
|
|
||||||
open(LIST_FILE, $file) or die "cant open $file";
|
def find_file(dirname, lumpname):
|
||||||
|
|
||||||
while (<LIST_FILE>) {
|
if dirname == "musics":
|
||||||
chomp;
|
lumpname = "d_" + lumpname
|
||||||
|
|
||||||
next if /^\s*$/ or /^\#/;
|
files = glob.glob("%s/%s*" % (dirname, lumpname))
|
||||||
|
|
||||||
/^(\w+)/;
|
if len(files) > 0:
|
||||||
my $lumpname = $1;
|
return files[0]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
my @files;
|
# Perform sanity check on the given directory:
|
||||||
|
|
||||||
if ($dir eq 'musics') {
|
def sanity_check(dirname, filename):
|
||||||
@files = glob("$dir/d_$lumpname*");
|
|
||||||
} else {
|
|
||||||
@files = glob("$dir/$lumpname*");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/done/ or /in dev/) {
|
print "Checking %s" % dirname
|
||||||
if (scalar @files <= 0) {
|
|
||||||
print "$dir: files not found for $lumpname\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (scalar @files > 0) {
|
|
||||||
print "$dir: files found for $lumpname\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close(LIST_FILE);
|
f = file(filename)
|
||||||
|
|
||||||
|
for line in f:
|
||||||
|
|
||||||
|
# Strip newline
|
||||||
|
|
||||||
|
line = line[0:len(line)-1]
|
||||||
|
|
||||||
|
# Ignore comments and empty lines
|
||||||
|
|
||||||
|
if line == " " * len(line) or line[0] == "#":
|
||||||
|
continue
|
||||||
|
|
||||||
|
match = re.match(r'(\w+)', line)
|
||||||
|
|
||||||
|
resource = match.group(1)
|
||||||
|
|
||||||
|
# Find the file for this lump, if it exists
|
||||||
|
|
||||||
|
filename = find_file(dirname, resource)
|
||||||
|
|
||||||
|
# Is this resource supposed to be present? Check this
|
||||||
|
# matches what is present.
|
||||||
|
|
||||||
|
if re.search(r"(done|in dev)", line):
|
||||||
|
if filename is None:
|
||||||
|
print "%s: files not found for %s" % \
|
||||||
|
(dirname, resource)
|
||||||
|
else:
|
||||||
|
if filename is None:
|
||||||
|
print "%s: files found for %s" % \
|
||||||
|
(dirname, resource)
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
status_dir = "status"
|
||||||
|
|
||||||
|
sections = {
|
||||||
|
"sprites" : "sprites_list",
|
||||||
|
"patches" : "patches_list",
|
||||||
|
"flats" : "flats_list",
|
||||||
|
"graphics" : "graphics_list",
|
||||||
|
"sounds" : "sounds_list",
|
||||||
|
"musics" : "musics_list",
|
||||||
}
|
}
|
||||||
|
|
||||||
my $status_dir = "status";
|
for section in sections.keys():
|
||||||
|
sanity_check(section, "%s/%s" % (status_dir, sections[section]))
|
||||||
sanitycheck 'sprites', "$status_dir/sprites_list";
|
|
||||||
sanitycheck 'patches', "$status_dir/patches_list";
|
|
||||||
sanitycheck 'flats', "$status_dir/flats_list";
|
|
||||||
sanitycheck 'graphics', "$status_dir/graphics_list";
|
|
||||||
sanitycheck 'sounds', "$status_dir/sounds_list";
|
|
||||||
#sanitycheck 'musics', "$status_dir/musics_list";
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue