c-client.py: Fix python-3 AttributeError: 'dict' object has no attribute 'iteritems'
[free-sw/xcb/libxcb] / src / c_client.py
index d006d30..9952a09 100644 (file)
@@ -5,6 +5,7 @@ from functools import reduce
 import getopt
 import os
 import sys
+import errno
 import time
 import re
 
@@ -175,6 +176,9 @@ def c_open(self):
     _h('')
     _h('#include "xcb.h"')
 
+    _c('#ifdef HAVE_CONFIG_H')
+    _c('#include "config.h"')
+    _c('#endif')
     _c('#include <stdlib.h>')
     _c('#include <string.h>')
     _c('#include <assert.h>')
@@ -2612,7 +2616,7 @@ def _man_request(self, name, cookie_type, void, aux):
                 (cookie_type, self.c_reply_name, base_func_name))
     f.write('.SH ERRORS\n')
     if hasattr(self, "doc") and self.doc:
-        for errtype, errtext in self.doc.errors.iteritems():
+        for errtype, errtext in self.doc.errors.items():
             f.write('.IP \\fI%s\\fP 1i\n' % (_t(('xcb', errtype, 'error'))))
             errtext = re.sub(r'`([^`]+)`', r'\\fI\1\\fP', errtext)
             f.write('%s\n' % (errtext))
@@ -2630,7 +2634,7 @@ def _man_request(self, name, cookie_type, void, aux):
         see = ['.BR %s (3)' % 'xcb-requests']
         if self.doc.example:
             see.append('.BR %s (3)' % 'xcb-examples')
-        for seename, seetype in self.doc.see.iteritems():
+        for seename, seetype in self.doc.see.items():
             if seetype == 'program':
                 see.append('.BR %s (1)' % seename)
             elif seetype == 'event':
@@ -2760,7 +2764,7 @@ def _man_event(self, name):
         see = ['.BR %s (3)' % 'xcb_generic_event_t']
         if self.doc.example:
             see.append('.BR %s (3)' % 'xcb-examples')
-        for seename, seetype in self.doc.see.iteritems():
+        for seename, seetype in self.doc.see.items():
             if seetype == 'program':
                 see.append('.BR %s (1)' % seename)
             elif seetype == 'event':
@@ -2902,8 +2906,11 @@ Refer to the README file in xcb/proto for more info.
     raise
 
 # Ensure the man subdirectory exists
-if not os.path.exists('man'):
+try:
     os.mkdir('man')
+except OSError, e:
+    if e.errno != errno.EEXIST:
+        raise
 
 today = time.strftime('%Y-%m-%d', time.gmtime(os.path.getmtime(args[0])))