summaryrefslogtreecommitdiffstats
path: root/lib/kformula/scripts/oper-dict.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kformula/scripts/oper-dict.py')
-rwxr-xr-xlib/kformula/scripts/oper-dict.py38
1 files changed, 19 insertions, 19 deletions
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' )