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