karolherbst / Gamekeeper-Framework

Library for hooking up game stores and merging them into one single library
GNU Lesser General Public License v2.1
2 stars 0 forks source link

Config file parsing improvements #136

Closed karolherbst closed 9 years ago

karolherbst commented 9 years ago

can be tested with following files:

info:

store
{
        name "desura"
        homepage "http://www.desura.com/"
        format "xml"
}

auth
{
        method "http_post"
        loginurl "https://secure.desura.com/3/memberlogin"
        logouturl "https://secure.desura.com/1/memberlogout"
}

authfield
{
        username "username"
        password "password"
}

authtoken
{
        keys "freeman,masterchief"
}

games
{
        url "https://secure.desura.com/1/memberdata"
        list "/memberdata/games//game"
}

game
{
        id "@siteareaid"
        name "name/text()"
        description "summary/text()"
        homepage "homepage/text()"
        platforms "/memberdata/platforms/platform/games/game[@siteareaid=$game.id]/../.."
}

platform
{
        id "@id"
        win32 "100"
        mac32 "130"
        lin32 "110"
        lin64 "120"
}

ini:

[store]
name=desura
homepage=http://www.desura.com/
format=xml

[auth]
method=http_post
loginurl=https://secure.desura.com/3/memberlogin
logouturl=https://secure.desura.com/1/memberlogout

[authfield]
username=username
password=password

[authtoken]
keys=freeman,masterchief

[games]
url=https://secure.desura.com/1/memberdata
list=/memberdata/games//game

[game]
id=@siteareaid
name=name/text()
description=summary/text()
homepage=homepage/text()
platforms=/memberdata/platforms/platform/games/game[@siteareaid=$game.id]/../..

[platform]
id=@id
win32=100
mac32=130
lin32=110
lin64=120

json:

{
        "store":
        {
                "name": "desura",
                "homepage": "http://www.desura.com/",
                "format": "xml"
        },

        "auth":
        {
                "method": "http_post",
                "loginurl": "https://secure.desura.com/3/memberlogin",
                "logouturl": "https://secure.desura.com/1/memberlogout"
        },

        "authfield":
        {
                "username": "username",
                "password": "password"
        },

        "authtoken":
        {
                "keys": "freeman,masterchief"
        },

        "games":
        {
                "url": "https://secure.desura.com/1/memberdata",
                "list": "/memberdata/games//game"
        },

        "game":
        {
                "id": "@siteareaid",
                "name": "name/text()",
                "description": "summary/text()",
                "homepage": "homepage/text()",
                "platforms": "/memberdata/platforms/platform/games/game[@siteareaid=$game.id]/../.."
        },

        "platform":
        {
                "id": "@id",
                "win32": "100",
                "mac32": "130",
                "lin32": "110",
                "lin64": "120"
        }
}

xml:

<store>
        <name>desura</desura>
        <homepage>http://www.desura.com/</homepage>
        <format>xml</format>
</store>

<auth>
        <method>http_post</method>
        <loginurl>https://secure.desura.com/3/memberlogin</loginurl>
        <logouturl>https://secure.desura.com/1/memberlogout</logouturl>
</auth>

<authfield>
        <username>username</username>
        <password>password</password>
</authfield>

<authtoken>
        <keys>freeman,masterchief</keys>
</authtoken>

<games>
        <url>https://secure.desura.com/1/memberdata</url>
        <list>/memberdata/games//game</list>
</games>

<game>
        <id>@siteareaid</id>
        <name>name/text()</name>
        <description>summary/text()</description>
        <homepage>homepage/text()</homepage>
        <platforms>/memberdata/platforms/platform/games/game[@siteareaid=$game.id]/../..</platforms>
</game>

<platform>
        <id>@id</id>
        <win32>100</win32>
        <mac32>130</mac32>
        <lin32>110</lin32>
        <lin64>120</lin64>
</platform>
Jookia commented 9 years ago

I can't see a reason to have the enum and its function if it's only going to be used once and require changing in three places when formats are changed rather than just one.

karolherbst commented 9 years ago

I was thinking about having a global util function later somewhere, that coul give us a list of formats for a given file name.

Jookia commented 9 years ago

That sounds like an idea that's also useful for games, but would require some more thought to go in to it, perhaps like the Unix file command.

karolherbst commented 9 years ago

maybe there is a library for that already.

karolherbst commented 9 years ago

I think I will keep it that way, because I will change that part later anyway if we use our new property format. But with these changes, we can use xml/json/info to already read the new files without changing too much, so it is easier to change.

karolherbst commented 9 years ago

@Jookia I've added some error handling stuff. I think this is a good start to implement the new scheme. I think I will start with the source part, because it should integrate pretty well in the current scheme