mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-02 07:25:45 -04:00
Convert extract-pnames script to Python.
This commit is contained in:
parent
5abf2dccfe
commit
c9e8446050
2 changed files with 36 additions and 33 deletions
8
Makefile
8
Makefile
|
@ -69,13 +69,13 @@ textures/shareware/texture1.txt: textures/combined.txt
|
|||
$(CPP) -DSHAREWARE < $< > $@
|
||||
|
||||
textures/shareware/pnames.txt: textures/shareware/texture1.txt
|
||||
./extract-pnames.pl < $< > $@
|
||||
./extract-pnames.py < $< > $@
|
||||
textures/doom/pnames.txt: textures/doom/texture1.txt
|
||||
./extract-pnames.pl -a > $@
|
||||
./extract-pnames.py -a > $@
|
||||
textures/doom2/pnames.txt: textures/doom2/texture1.txt
|
||||
./extract-pnames.pl -a > $@
|
||||
./extract-pnames.py -a > $@
|
||||
textures/freedm/pnames.txt: textures/freedm/texture1.txt
|
||||
./extract-pnames.pl -a > $@
|
||||
./extract-pnames.py -a > $@
|
||||
|
||||
# update wadinfo.txt
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env perl
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Contributors to the Freedoom project. All rights reserved.
|
||||
#
|
||||
|
@ -27,44 +28,46 @@
|
|||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use strict;
|
||||
my %patches;
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import glob
|
||||
|
||||
texture_re = re.compile(r'\*\s+(\w+)')
|
||||
|
||||
# Parse a TEXTURE1 file and generate a list of patches
|
||||
|
||||
sub parse_texture_file {
|
||||
def parse_texture_file():
|
||||
patches = {}
|
||||
|
||||
while (<>) {
|
||||
if (/^\*/) {
|
||||
my ($name) = /^\*\s+(\w+)/;
|
||||
$name = uc $name;
|
||||
$patches{$name} = 1;
|
||||
}
|
||||
}
|
||||
for line in sys.stdin:
|
||||
match = texture_re.match(line)
|
||||
|
||||
print "; autogenerated patch list\n\n";
|
||||
if match:
|
||||
name = match.group(1)
|
||||
|
||||
foreach (sort keys %patches) { print "$_\n"; }
|
||||
}
|
||||
patches[name] = True
|
||||
|
||||
print "; autogenerated patch list\n"
|
||||
|
||||
for name in sorted(patches.keys()):
|
||||
print name
|
||||
|
||||
# Generate a full list of textures from the files in the
|
||||
# patches/ directory
|
||||
|
||||
sub list_all_textures {
|
||||
print "; autogenerated patch list\n\n";
|
||||
def list_all_textures():
|
||||
print "; autogenerated patch list\n"
|
||||
|
||||
foreach my $file (glob("patches/*.gif")) {
|
||||
if ($file =~ /\/(.*)\.gif/) {
|
||||
print "$1\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
for filename in sorted(glob.glob("patches/*.gif")):
|
||||
base = os.path.basename(filename)
|
||||
patch_name = base[0:-4]
|
||||
print patch_name
|
||||
|
||||
if (scalar @ARGV == 0) {
|
||||
parse_texture_file();
|
||||
} elsif ($ARGV[0] == "-a") {
|
||||
list_all_textures();
|
||||
} else {
|
||||
print "Usage: extract-pnames.pl [-a]\n";
|
||||
}
|
||||
if len(sys.argv) == 1:
|
||||
parse_texture_file()
|
||||
elif sys.argv[1] == "-a":
|
||||
list_all_textures()
|
||||
else:
|
||||
print "Usage: extract-pnames.pl [-a]"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue