Skip to content

Commit 4ee1b4e

Browse files
committed
Search all .cpp files for flags, restoring the Brazil Gay Pride Flag
1 parent b26fe9c commit 4ee1b4e

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

flagordr.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Generated by py\sort_flags.py
12
class Flag far *PRIDE_FLAGS[]={
23
&abrosexual_flag,
34
&aegosexual_flag,
@@ -18,6 +19,7 @@ class Flag far *PRIDE_FLAGS[]={
1819
&femme_lesbian_flag,
1920
&five_stripe_gay_men_flag,
2021
&five_stripe_lesbian_flag,
22+
&gay_brazil_flag,
2123
&gay_flag_of_south_africa,
2224
&gay_men_flag,
2325
&genderfluid_flag,

py/sort_flags.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
import re
2-
with open('..\\flagdefs.cpp','r') as f:
3-
data=f.read()
4-
#\n\s*\"([^"]+)\"
5-
out=[]
6-
for identifier,name in re.findall(r'^static Flag ([a-z0-9_]+) = Flag\(\n\s*\"([^"]+)\"',data,re.DOTALL|re.MULTILINE):
7-
out.append((name,identifier))
8-
9-
out.sort()
10-
11-
print 'class Flag far *PRIDE_FLAGS[]={'
12-
for name,identifier in out:
13-
print '\t&{},'.format(identifier)
14-
print '\tNULL\n};\n'
1+
import re, os, glob
2+
3+
4+
prideflags=[]
5+
for filepath in glob.glob(os.path.join('..','*.cpp')):
6+
with open(filepath,'r') as f:
7+
data=f.read()
8+
seenfile=False
9+
for identifier,name in re.findall(r'^(?:static )?Flag ([a-z0-9_]+) = Flag\(\n\s*\"([^"]+)\"',data,re.DOTALL|re.MULTILINE):
10+
if not seenfile:
11+
seenfile=True
12+
print '{}:'.format(filepath)
13+
14+
print ' * Found "{}"'.format(name)
15+
prideflags.append((name,identifier))
16+
17+
prideflags.sort()
18+
19+
with open(os.path.join('..','flagordr.h'),'w') as f:
20+
print >>f,'// Generated by py\\sort_flags.py'
21+
print >>f,'class Flag far *PRIDE_FLAGS[]={'
22+
for name, identifier in prideflags:
23+
print >>f,'\t&{},'.format(identifier)
24+
print >>f,'\tNULL\n};\n'

0 commit comments

Comments
 (0)