-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildworldowners.py
38 lines (30 loc) · 1.02 KB
/
buildworldowners.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
# The Nexus software is licensed under the BSD 2-Clause license.
#
# You should have recieved a copy of this license with the software.
# If you did not, you can find one at the following link.
#
# http://opensource.org/licenses/bsd-license.php
import os, sys, shutil
import cPickle
from ConfigParser import RawConfigParser as ConfigParser
worldowners = {}
worldlist = os.listdir("worlds/")
print "Building world-owner index of %s worlds..." % len(worldlist)
for world in worldlist:
if not world.startswith("."):
config = ConfigParser()
config.read('worlds/%s/world.meta' % world)
owner = "n/a"
if config.has_section("owner"):
owner = config.get("owner", "owner").lower()
if len(owner) == 0:
owner = "n/a"
if not owner in worldowners:
worldowners[owner] = [world]
else:
worldowners[owner].append(world)
fp = open("config/data/worldowners.dat", "w")
cPickle.dump(worldowners, fp)
fp.close()
print "Done"