mirror of
https://github.com/alvierahman90/capitals_quiz.git
synced 2024-11-27 19:59:54 +00:00
add every country in the world, apart from those which don't have capitals
This commit is contained in:
parent
2ffcd0d377
commit
6d721910d2
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
src/countries.json
|
||||
*/*.swp
|
7
Makefile
Normal file
7
Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
all: src/countries.json
|
||||
|
||||
src/countries.json:
|
||||
python scripts/generate_countries_list.py countries/countries.json > src/countries.json
|
||||
|
||||
clean:
|
||||
rm -rf src/countries.json
|
38
scripts/generate_countries_list.py
Executable file
38
scripts/generate_countries_list.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
|
||||
def get_args():
|
||||
""" Get command line arguments """
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('file', help="The countries.json file to generate the output from", type=str)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main(args):
|
||||
""" Entry point for script """
|
||||
with open(args.file) as fp:
|
||||
countries = json.load(fp)
|
||||
|
||||
r = {}
|
||||
|
||||
for country in countries:
|
||||
if len(country['capital']) < 1 or country['capital'][0] is None:
|
||||
continue
|
||||
r[country['name']['common']] = country['capital'][0]
|
||||
|
||||
print('capitals = ', end='')
|
||||
print(json.dumps(r))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
sys.exit(main(get_args()))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(0)
|
@ -1,13 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var capitals = {
|
||||
"England": "London",
|
||||
"France": "Paris",
|
||||
"the USA": "Washington D.C.",
|
||||
"India": "New Dehli",
|
||||
"Bangladesh": "Dhaka"
|
||||
}
|
||||
|
||||
var question_list = null;
|
||||
const capitals_list = Object.values(capitals);
|
||||
const date = new Date();
|
||||
|
@ -34,5 +34,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="game.js"></script>
|
||||
<script type="text/javascript" src="countries.json"></script>
|
||||
<script type="text/javascript" src="game.js"></script>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user