summaryrefslogtreecommitdiff
path: root/scripts
authormickeyl <mickeyl>2004-04-26 12:25:42 (UTC)
committer mickeyl <mickeyl>2004-04-26 12:25:42 (UTC)
commita26e4da56923553a2f9e4da4db3b92bdb75479c8 (patch) (side-by-side diff)
treee936f193364176109edc0ae4cc05678a2549ca78 /scripts
parentcaf74b437544a95410bbd030045e15e4dcaa91f0 (diff)
downloadopie-a26e4da56923553a2f9e4da4db3b92bdb75479c8.zip
opie-a26e4da56923553a2f9e4da4db3b92bdb75479c8.tar.gz
opie-a26e4da56923553a2f9e4da4db3b92bdb75479c8.tar.bz2
update
Diffstat (limited to 'scripts') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/qdebug-odebug.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/qdebug-odebug.py b/scripts/qdebug-odebug.py
index 636c1b2..7a417e1 100755
--- a/scripts/qdebug-odebug.py
+++ b/scripts/qdebug-odebug.py
@@ -4,44 +4,49 @@
qdebug-odebug.py (C) 2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
This script helps to convert from the Qt debugging framework to the Opie debugging framework
Though it will take care of the most common usages, it may not recognize uncommon ones, hence
manual work may be needed after applying the script.
"""
import sys, sre
-qDebugExpression = sre.compile( '(.*)(qDebug)\(\s*(.*)\s*\);(.*)' )
-qWarningExpression = sre.compile( '(.*)(qWarning)\(\s*(.*)\s*\);(.*)' )
-qErrorExpression = sre.compile( '(.*)(qError)\(\s*(.*)\s*\);(.*)' )
-qFatalExpression = sre.compile( '(.*)(qFatal)\(\s*(.*)\s*\);(.*)' )
-printfExpression = sre.compile( '(.*)(printf)\(\s*(.*)\s*\);(.*)' )
+qDebugExpression = sre.compile( '(?P<head>.*)(?P<statement>qDebug)\(\s*(?P<content>.*)\s*\);(?P<tail>.*)' )
+qWarningExpression = sre.compile( '(?P<head>.*)(?P<statement>qWarning)\(\s*(?P<content>.*)\s*\);(?P<tail>.*)' )
+qErrorExpression = sre.compile( '(?P<head>.*)(?P<statement>qError)\(\s*(?P<content>.*)\s*\);(?P<tail>.*)' )
+qFatalExpression = sre.compile( '(?P<head>.*)(?P<statement>qFatal)\(\s*(?P<content>.*)\s*\);(?P<tail>.*)' )
+#printfExpression = sre.compile( '(?P<head>.*)(?![s\.])(?P<statement>printf)\(\s*(?P<content>.*)\s*\);(?P<tail>.*)' )
debugTable = { "qDebug" : "odebug",
"qWarning" : "owarn",
"qError" : "oerr",
"qFatal" : "ofatal",
"printf" : "odebug" }
-allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression, printfExpression )
+allExpressions = ( qDebugExpression, qWarningExpression, qErrorExpression, qFatalExpression ) #, printfExpression )
####################################################################################################
def convert( fname ):
print >>sys.stderr, "<NOTE>: Dealing with %s..." % fname
for line in file( fname ):
match = False
for expr in allExpressions:
m = expr.match( line )
if m is None:
continue
else:
match = True
- head, debug, content, tail = m.groups()
+
+ head = m.groupdict()["head"]
+ debug = m.groupdict()["statement"]
+ content = m.groupdict()["content"]
+ tail = m.groupdict()["tail"]
+
print >>sys.stderr, "<NOTE>: Groups = ", m.groups()
sys.stdout.write( head ) # don't strip() here, because we want to keep indentation
sys.stdout.write( debugTable[debug.strip()] )
sys.stdout.write( " << " )
sys.stdout.write( transform( content ).strip() )
sys.stdout.write( " << oendl; " )
sys.stdout.write( tail )
if not tail.endswith( "\n" ): sys.stdout.write( "\n" )
@@ -90,17 +95,17 @@ def transform( s ):
while i < len( formatstring ):
if formatstring[i] != "%":
result += formatstring[i]
i += 1
continue
else: # % in formatstring
indirective = True
i += 1
- while i < len( formatstring ) and formatstring[i] not in "%dDiouxXfegEscpn":
+ while i < len( formatstring ) and formatstring[i] not in "%dDiouxXfFegEscpn":
i += 1
if formatstring[i] == "%":
result += "%"
else:
result += '" << %s << "' % substitutions[0].replace( "(const char*)", "" ).replace( ".latin1()", "" )
del substitutions[0]
indirective = False
i += 1