How to read the .ini files in ./_libs/_data ?
Posted: Thu Jun 13, 2013 2:34 am
by BackRaw
Hey guys,
I'm trying SP for CSS with a little script, but I need to know how I can read the .ini files in the
./_libs/_data directory.
I wanna use the values for "t" and "ct" in
./_libs/_data/players/teams/cstrike.ini. How would I go about doing that?
Thank you

Posted: Thu Jun 13, 2013 4:30 am
by satoon101
The only module, I believe, that uses that file, is the filters.players module. This is how it reads the data:[python]_game_teams = ConfigObj(
DATA_PATH.joinpath('players', 'teams', GAME_NAME + '.ini'), unrepr=True)[/python]Note that you will need to import ConfigObj, DATA_PATH, and GAME_NAME if you use this method.
Satoon
Posted: Fri Jun 14, 2013 4:34 pm
by BackRaw
satoon101 wrote:The only module, I believe, that uses that file, is the filters.players module. This is how it reads the data:[python]_game_teams = ConfigObj(
DATA_PATH.joinpath('players', 'teams', GAME_NAME + '.ini'), unrepr=True)[/python]Note that you will need to import ConfigObj, DATA_PATH, and GAME_NAME if you use this method.
Satoon
Yeah, I already managed to do that. I thought there'd be some type of extra function/method for this

Posted: Sat Jun 15, 2013 12:21 am
by satoon101
This will possibly get moved to another module at some point, but you can always use the PlayerTeams dictionary from filters.players to get player teams for the current game:
Syntax: Select all
from filters.players import PlayerTeams
for team in PlayerTeams:
print(team + ': %s' % PlayerTeams[team].team)
Satoon