Visar inlägg med etikett python. Visa alla inlägg
Visar inlägg med etikett python. Visa alla inlägg

2009-10-24

GCompris

Har du provat GCompris? Det är en samling enkla spel för barn.

Spelen är kul och finns på 40 språk, bland annat svenska men tyvärr är det lite fel på installationspaketen för Ubuntu. Två saker måste göras för att få det hela att fungera. Läs mer här och här.

2009-07-07

To create a SVN version tag in your code

This simple python code will extract the version information from svn and display it. Or at least I hope so based on the limited testing I have done so far... :-)
url = '$HeadURL: https://mysvnserver.somewhere.com/svn/myproject/branches/iso_mybranchortag/python_version.py $'
ver = '$Rev: 531 $'

print url
print ver

branch = url.find("branches")
tag = url.find("tags")
trunk = url.find("trunk")

if trunk > 0 :
    print "This version was taken from the trunk!"
elif tag > 0 :
    suburl = url[tag+5:tag+99]
    endindex = suburl.find("/")
    print "This version was taken from tag " + suburl[0:endindex]
elif branch > 0:
    suburl = url[branch+9:branch+99]
    endindex = suburl.find("/")
    print "This version was taken from branch " + suburl[0:endindex]
In order to make this work, you need to add keywords to your code. If you are working with Tortoise you can make these setting in the GUI.

An example of keyword substitution at work:

C:\Users\greger\test\tags\rc001>more version.txt
$Date: 2009-07-07 21:34:58 +0200 (ti, 07 jul 2009) $
$URL: http://localhost/svn/test/tags/rc001/version.txt $

This is a little text file

C:\Users\greger\test\tags\rc001>more ..\..\trunk\version.txt
$Date: 2009-07-07 21:34:58 +0200 (ti, 07 jul 2009) $
$URL: http://localhost/svn/test/trunk/version.txt $

This is a little text file
Both version.txt files above will be on the same revision. In my case "9".

Why keyword substitution might be a bad idea...