summaryrefslogtreecommitdiff
path: root/development/mkHelpSkeleton
authormickeyl <mickeyl>2003-10-29 22:07:36 (UTC)
committer mickeyl <mickeyl>2003-10-29 22:07:36 (UTC)
commitd53637f46cf217fc760d7aac58b4596843a73803 (patch) (unidiff)
tree25289be556fa1ce0ba8539b7f42aeaa037bdf7fd /development/mkHelpSkeleton
parent1af1f1d9f398d38a2bc666cd2edff5725da7a770 (diff)
downloadopie-d53637f46cf217fc760d7aac58b4596843a73803.zip
opie-d53637f46cf217fc760d7aac58b4596843a73803.tar.gz
opie-d53637f46cf217fc760d7aac58b4596843a73803.tar.bz2
merge development/* and help/*
Diffstat (limited to 'development/mkHelpSkeleton') (more/less context) (ignore whitespace changes)
-rwxr-xr-xdevelopment/mkHelpSkeleton116
1 files changed, 116 insertions, 0 deletions
diff --git a/development/mkHelpSkeleton b/development/mkHelpSkeleton
new file mode 100755
index 0000000..d7914fe
--- a/dev/null
+++ b/development/mkHelpSkeleton
@@ -0,0 +1,116 @@
1#!/usr/bin/env python
2"""
3This skript creates a help skeleton for a certain application
4(C) Michael 'Mickey' Lauer who did this even if he had a lot of other stuff to do... THANKS
5"""
6
7import os
8import sys
9
10COUNTRYCODES = "da de en fr nl pl hu no pt it pt_BR ja sl zh_CN es ko zh_TW".split()
11OPIEDIR = os.environ["OPIEDIR"]
12
13#Package: opie-appskey-help-en
14#Files: help/en/html/opie-appskey.html
15#Priority: optional
16#Section: opie/onlinedoc
17#Maintainer: ljp <llornkcor@handhelds.org>
18#Architecture: arm
19#Version: $QPE_VERSION-$SUB_VERSION
20#Depends: opie-appskey
21#License: GPL
22#Description: Application Key help files (english)
23
24def doit( name, cc ):
25 """Create a help skeleton corresponding to a package described by a desktop file."""
26
27 desktop = {}
28 for line in file( name ):
29 try:
30 key, value = line.split( '=' )
31 except ValueError:
32 pass
33 else:
34 desktop[key.strip()] = value.strip()
35
36 try:
37 application = desktop["Exec"]
38 except:
39 fail( "No Exec given in .desktop file" )
40
41 print "Generating help skeleton for application '%s'..." % application
42 helpdirname = "%s/help/%s/html" % ( OPIEDIR, cc )
43 helpappdirname = "%s/%s" % ( helpdirname, application )
44 makecontrol( helpdirname, application, cc, desktop )
45 makedir( helpappdirname )
46 makehtml( helpdirname, application, cc, desktop )
47
48#------------------------------------------------------#
49def makehtml( directory, application, cc, desktop ):
50 """Creates the help template file."""
51
52 helpfilename = "%s/%s.html" % ( directory, application )
53 print "Creating help file '%s'" % helpfilename
54 h = file( helpfilename, "w" )
55 print >> h, """<html> <head> <title>%s</title> </head>
56<body>
57 <center><h1>%s</h1></center>
58 <hr>
59</body>
60</html>
61""" % ( application, application )
62
63#------------------------------------------------------#
64def makecontrol( directory, application, cc, desktop ):
65 """Creates the .control file."""
66
67 controlfilename = "%s/opie-%s-help-%s.control" % ( directory, application, cc )
68 print "Creating control file '%s'" % controlfilename
69 c = file( controlfilename, "w" )
70 print >> c, "Package: opie-%s-help-%s" % ( application, cc )
71 print >> c, "Files: help/%s/html/%s.html help/%s/html/%s" % ( cc, application, cc, application )
72 print >> c, "Priority: optional"
73 print >> c, "Section: opie/onlinedoc"
74 print >> c, "Maintainer: %s" % desktop.get( "Maintainer", "Team Opie <opie@handhelds.org>" )
75 print >> c, "Version: $QPE_VERSION-$SUB_VERSION"
76 print >> c, "Depends: opie-%s" % application
77 print >> c, "License: GPL"
78 print >> c, "Description: %s help files (%s)" % ( application, cc )
79
80#------------------------------------------------------#
81def makedir( name ):
82 """Creates a directory."""
83
84 print "Creating directory '%s'" % name
85 if not os.path.exists( name ): os.mkdir( name )
86
87#------------------------------------------------------#
88def fail( reason ):
89 """Fails with a reason."""
90 print reason
91 sys.exit( -1 )
92
93#------------------------------------------------------#
94def checkUsage( args ):
95 """Checks calling syntax."""
96
97 if len( args ) < 2:
98 fail( """
99Usage: %s <application>.desktop [countrycode]
100
101If no countrycode is given, defaults to 'en'
102If countrycode 'all' is given, generates skeletons
103for all known countrycodes: %s""" % ( args[0], ", ".join( COUNTRYCODES ) ) )
104
105#------------------------------------------------------#
106
107if __name__ == "__main__":
108 checkUsage( sys.argv )
109
110 if len ( sys.argv ) == 2:
111 doit( sys.argv[1], "en" )
112 elif len( sys.argv ) == 3:
113 if sys.argv[2] == "all":
114 [ doit( sys.argv[1], x ) for x in split() ]
115 else:
116 doit( sys.argv[1], sys.argv[2] )