diff options
Diffstat (limited to 'lib/kformula/scripts')
-rwxr-xr-x | lib/kformula/scripts/bycodes.py | 10 | ||||
-rwxr-xr-x | lib/kformula/scripts/bynames.py | 22 | ||||
-rwxr-xr-x | lib/kformula/scripts/oper-dict.py | 38 |
3 files changed, 35 insertions, 35 deletions
diff --git a/lib/kformula/scripts/bycodes.py b/lib/kformula/scripts/bycodes.py index 45b787a0..fdd84269 100755 --- a/lib/kformula/scripts/bycodes.py +++ b/lib/kformula/scripts/bycodes.py @@ -25,11 +25,11 @@ from TQt import qt def decode( fd, font, line ): begin = string.find( line, '"' ) end = string.find( line, '"', begin + 1) - unicode = line[begin + 2:end] # Remove 'U' from string aswell + str = line[begin + 2:end] # Remove 'U' from string aswell char_list = [] - separation = string.find( unicode, '-' ) + separation = string.find( str, '-' ) if separation != -1: - second = unicode + second = str while separation != -1: first = second[0:separation] second = second[separation + 2:] @@ -38,13 +38,13 @@ def decode( fd, font, line ): if separation == -1: char_list.append( string.atoi( second, 16 ) ) else: - char_list.append( string.atoi ( unicode, 16 ) ) + char_list.append( string.atoi ( str, 16 ) ) fm = qt.TQFontMetrics( qt.TQFont( font ) ) in_font = True for c in char_list: if not fm.inFont( qt.TQChar( c ) ): in_font = False - fd.write( unicode + ' ' + str( in_font ) + '\n') + fd.write( str + ' ' + str( in_font ) + '\n') def parse( file, font ): fd = open( file ) diff --git a/lib/kformula/scripts/bynames.py b/lib/kformula/scripts/bynames.py index 6b8c1d7a..fbd1ba5e 100755 --- a/lib/kformula/scripts/bynames.py +++ b/lib/kformula/scripts/bynames.py @@ -24,7 +24,7 @@ import time import os def write_header( f ): - print >> f, '''// + print('''// // Created: ''' + time.ctime(time.time()) + ''' // by: ''' + os.path.basename( sys.argv[0] ) + ''' // from: ''' + os.path.basename( sys.argv[1] ) + ''' @@ -49,10 +49,10 @@ def write_header( f ): the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -''' +''', file=f) def write_h( f ): - print >>f, ''' + print(''' #ifndef ENTITIES_H #define ENTITIES_H @@ -74,19 +74,19 @@ extern const entityMap entities[]; KFORMULA_NAMESPACE_END #endif // ENTITIES_H -''' +''', file=f) def write_cc( fr, fw ): - print >> fw, ''' + print(''' #include "entities.h" KFORMULA_NAMESPACE_BEGIN -const entityMap entities[] = {''' +const entityMap entities[] = {''', file=fw) parse( fr, fw ) - print >> fw, ''' + print(''' }; // Needed since sizeof is a macro and we cannot be used until size is known @@ -96,7 +96,7 @@ int entityMap::size() } KFORMULA_NAMESPACE_END - ''' + ''', file=fw) def name_cmp( a, b ): @@ -104,7 +104,7 @@ def name_cmp( a, b ): return -1 if a[0] > b[0]: return 1 - print 'WARNING: Same name in entity: ' + a[0] + ', ' + b[0] + print('WARNING: Same name in entity: ' + a[0] + ', ' + b[0]) return 0; def parse( fr, fw ): @@ -133,10 +133,10 @@ def parse( fr, fw ): while True: e = entries.pop() fd_list.write( e[0] + ' ' + e[1] + '\n') - print >> fw, ' {"' + e[0] + '", ' + e[1] + '}', + print(' {"' + e[0] + '", ' + e[1] + '}', end=' ', file=fw) if len( entries ) == 0: break - print >> fw, ',' + print(',', file=fw) fd_list.close() if __name__ == '__main__': diff --git a/lib/kformula/scripts/oper-dict.py b/lib/kformula/scripts/oper-dict.py index e9e10550..70f7868c 100755 --- a/lib/kformula/scripts/oper-dict.py +++ b/lib/kformula/scripts/oper-dict.py @@ -43,7 +43,7 @@ attr_list = [ def write_header( f ): - print >> f, '''// + print('''// // Created: ''' + time.ctime(time.time()) + ''' // by: ''' + os.path.basename( sys.argv[0] ) + ''' // from: ''' + os.path.basename( sys.argv[1] ) + ''' @@ -68,10 +68,10 @@ def write_header( f ): the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -''' +''', file=f) def write_h( f ): - print >>f, ''' + print(''' #ifndef OPERATORDICTIONARY_H #define OPERATORDICTIONARY_H @@ -119,20 +119,20 @@ extern const OperatorDictionary operators[]; KFORMULA_NAMESPACE_END #endif // OPERATORDICTIONARY_H -''' +''', file=f) def write_cc( fr, fw ): - print >> fw, ''' + print(''' #include "operatordictionary.h" KFORMULA_NAMESPACE_BEGIN -const OperatorDictionary operators[] = {''' +const OperatorDictionary operators[] = {''', file=fw) entities = get_entities() parse( fr, fw, entities ) - print >> fw, ''' + print(''' }; // Needed since sizeof is a macro and we cannot be used until size is known @@ -142,7 +142,7 @@ int OperatorDictionary::size() } KFORMULA_NAMESPACE_END - ''' + ''', file=fw) def get_entities(): # First, read entity list into a dict @@ -165,7 +165,7 @@ def key_cmp( a, b ): return -1 if a[1] > b[1]: return 1 - print 'WARNING: Same key in operator dictionary: ' + a[0] + ', ' + b[0] + print('WARNING: Same key in operator dictionary: ' + a[0] + ', ' + b[0]) return 0 def parse( fr, fw, entities ): @@ -203,8 +203,8 @@ def parse( fr, fw, entities ): # application. The best solution would probably to map to a single # character provided by the font in the private area of Unicode entity_name = name[begin + 1:end] - if entities.has_key( entity_name ) : - name = name.replace( '&' + entity_name + ';', unichr(entities[entity_name])); + if entity_name in entities : + name = name.replace( '&' + entity_name + ';', chr(entities[entity_name])); else: entities_found = False break @@ -213,9 +213,9 @@ def parse( fr, fw, entities ): fields.pop(0) # Remove form for f in fields: attr, value = string.split( f, '=' ) - if not attr_dict.has_key( attr ) : - print 'Unsupported attribute: ' + attr - print 'If it is valid, update attribute dictionary' + if attr not in attr_dict : + print('Unsupported attribute: ' + attr) + print('If it is valid, update attribute dictionary') sys.exit(-1) # Spec has a typo, fix it if string.count( value, '"' ) == 3: @@ -227,20 +227,20 @@ def parse( fr, fw, entities ): while True: e = entries.pop() - print >> fw, ' { {' + e[0] + ', ' + e[1] + '},' + print(' { {' + e[0] + ', ' + e[1] + '},', file=fw) d = e[2] for a in attr_list: # Convert, at least, bool values value = d[a] if value == '"true"' or value == '"false"': value = string.strip( value, '"' ) - print >> fw, '\t\t' + value, + print('\t\t' + value, end=' ', file=fw) if a != attr_list[len(attr_list) - 1]: - print >> fw, ',' - print >> fw, '}', + print(',', file=fw) + print('}', end=' ', file=fw) if len( entries ) == 0: break - print >> fw, ',\n' + print(',\n', file=fw) if __name__ == '__main__': fh = open( '../operatordictionary.h', 'w' ) |