[openrtm-commit:02901] r3060 - trunk/OpenRTM-aist/build

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 11月 6日 (月) 09:51:55 JST


Author: miyamoto
Date: 2017-11-06 09:51:55 +0900 (Mon, 06 Nov 2017)
New Revision: 3060

Modified:
   trunk/OpenRTM-aist/build/cmakeconfgen.py
   trunk/OpenRTM-aist/build/codegen.py
   trunk/OpenRTM-aist/build/ezt.py
   trunk/OpenRTM-aist/build/makedeffile.py
   trunk/OpenRTM-aist/build/makevcproj.py
   trunk/OpenRTM-aist/build/makewrapper.py
   trunk/OpenRTM-aist/build/makewxs.py
   trunk/OpenRTM-aist/build/pickupprojs.py
   trunk/OpenRTM-aist/build/setuptest.py
   trunk/OpenRTM-aist/build/slntool.py
   trunk/OpenRTM-aist/build/uuid.py
   trunk/OpenRTM-aist/build/vcprojtool.py
   trunk/OpenRTM-aist/build/vcxprojtool.py
   trunk/OpenRTM-aist/build/vsprops2cmake.py
   trunk/OpenRTM-aist/build/yat.py
Log:
[incompat] Python 3 support.

Modified: trunk/OpenRTM-aist/build/cmakeconfgen.py
===================================================================
--- trunk/OpenRTM-aist/build/cmakeconfgen.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/cmakeconfgen.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -156,12 +156,12 @@
 if __name__ == '__main__':
     import os
     if len(sys.argv) < 2:
-        print "please specify vsprops file"
+        print("please specify vsprops file")
         sys.exit(1)
 
     fname = sys.argv[1]
     if fname.split(".")[-1] != "vsprops":
-        print "please specify vsprops file"
+        print("please specify vsprops file")
         sys.exit(1)
 
     f = file(sys.argv[1], "r")

Modified: trunk/OpenRTM-aist/build/codegen.py
===================================================================
--- trunk/OpenRTM-aist/build/codegen.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/codegen.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -165,9 +165,9 @@
             return
         t = yat.Template(temp_txt)
         text = t.generate(data)
-	fd.write(text)
+        fd.write(text)
         fd.close()
-        print "\"" + fname + "\"" " was generated."
+        print("\"" + fname + "\"" " was generated.")
         return
 
     def gen_all(self):

Modified: trunk/OpenRTM-aist/build/ezt.py
===================================================================
--- trunk/OpenRTM-aist/build/ezt.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/ezt.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -167,7 +167,10 @@
 
 import string
 import re
-from types import StringType, IntType, FloatType
+#from types import StringType, IntType, FloatType
+StringType = str
+IntType = int
+FloatType = float
 import os
 
 #
@@ -365,7 +368,9 @@
     else:
       fp.write(value)
 
-  def _cmd_format(self, (valref, args), fp, ctx):
+  def _cmd_format(self, ref, fp, ctx):
+    valref = ref[0]
+    args = ref[1]
     fmt = _get_value(valref, ctx)
     parts = _re_subst.split(fmt)
     for i in range(len(parts)):
@@ -378,7 +383,9 @@
           piece = '<undef>'
       fp.write(piece)
 
-  def _cmd_include(self, (valref, reader), fp, ctx):
+  def _cmd_include(self, ref, fp, ctx):
+    valref = ref[0]
+    reader = ref[1]
     fname = _get_value(valref, ctx)
     ### note: we don't have the set of for_names to pass into this parse.
     ### I don't think there is anything to do but document it.
@@ -412,7 +419,7 @@
   def _cmd_is(self, args, fp, ctx):
     ((left_ref, right_ref), t_section, f_section) = args
     value = _get_value(right_ref, ctx)
-    value = string.lower(_get_value(left_ref, ctx)) == string.lower(value)
+    value = _get_value(left_ref, ctx).lower() == value.lower()
     self._do_if(value, t_section, f_section, fp, ctx)
 
   def _do_if(self, value, t_section, f_section, fp, ctx):
@@ -466,7 +473,7 @@
       if idx < len(file_args):
         return file_args[idx]
 
-  parts = string.split(refname, '.')
+  parts = refname.split('.')
   start = parts[0]
   rest = parts[1:]
   while rest and (start in for_names):
@@ -479,7 +486,10 @@
       break
   return refname, start, rest
 
-def _get_value((refname, start, rest), ctx):
+def _get_value(ref, ctx):
+  refname = ref[0]
+  start = ref[1]
+  rest = ref[2]
   """(refname, start, rest) -> a prepared `value reference' (see above).
   ctx -> an execution context instance.
 
@@ -490,10 +500,10 @@
   if rest is None:
     # it was a string constant
     return start
-  if ctx.for_index.has_key(start):
+  if start in ctx.for_index:
     list, idx = ctx.for_index[start]
     ob = list[idx]
-  elif ctx.data.has_key(start):
+  elif start in ctx.data:
     ob = ctx.data[start]
   else:
     raise UnknownReference(refname)

Modified: trunk/OpenRTM-aist/build/makedeffile.py
===================================================================
--- trunk/OpenRTM-aist/build/makedeffile.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/makedeffile.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -70,7 +70,7 @@
         sys.exit(1)
 
     cmd = "DUMPBIN.EXE /SYMBOLS %s" % libfile
-    print cmd
+    print(cmd)
     dumped = os.popen(cmd)
 
     definitions = {}
@@ -94,13 +94,13 @@
 
             definitions[symbol] = None
 
-    symbols = definitions.keys()
+    symbols = list(definitions.keys())
     symbols.sort()
 
-    print "Output %d symbols." % len(symbols)
+    print("Output %d symbols." % len(symbols))
 
     out = open(deffile, "w")
-    if string.lower(binname[4:]) == ".exe":
+    if binname[4:].lower() == ".exe":
         out.write("NAME %s\n" % binname)
     else:
         out.write("LIBRARY %s\n" % binname)

Modified: trunk/OpenRTM-aist/build/makevcproj.py
===================================================================
--- trunk/OpenRTM-aist/build/makevcproj.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/makevcproj.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -21,9 +21,9 @@
 import yaml
 
 def print_usage():
-    print """usage:
+    print("""usage:
 %s -i [input_file] -d [dictionary] -o [output_file]
-"""
+""")
 
 
 def load_dict(filename):
@@ -45,7 +45,7 @@
     try:
         opts, args = getopt.getopt(sys.argv[1:], "i:o:d:", [])
     except:
-        print "Error: Invalid option.", getopt.GetoptError
+        print("Error: Invalid option.", getopt.GetoptError)
         print_usage()
         sys.exit(-1)
         return

Modified: trunk/OpenRTM-aist/build/makewrapper.py
===================================================================
--- trunk/OpenRTM-aist/build/makewrapper.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/makewrapper.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -262,17 +262,17 @@
             newtext = re.sub(" \@date.*?\n", "", text)
             oldtext2 = re.sub(" \@date.*?\n", "", oldtext)
             if newtext == oldtext2:
-                print "\"", fname, \
-                    "\" already exists and it will be same as new one."
-                print "File is not need to be generated."
+                print("\"", fname, \
+                    "\" already exists and it will be same as new one.")
+                print ("File is not need to be generated.")
                 return
             else:
-                print "\"", fname, "\" already exists but contents are not same"
+                print("\"", fname, "\" already exists but contents are not same")
 
         f = file(fname, "w")
         f.write(text)
         f.close()
-        print "\"", fname, "\"" " was generated."
+        print("\"", fname, "\"" " was generated.")
         return
 
     def gen_all(self):

Modified: trunk/OpenRTM-aist/build/makewxs.py
===================================================================
--- trunk/OpenRTM-aist/build/makewxs.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/makewxs.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -101,7 +101,7 @@
         return self.comp + '%04d' % (self.count)
         
     def sn_num(self, name):
-        if self.shortnames.has_key(name):
+        if name in self.shortnames:
             self.shortnames[name] += 1
         else:
             self.shortnames[name] = 0
@@ -108,7 +108,7 @@
         return "%03d" % (self.shortnames[name])
 
     def se_num(self, ext):
-        if self.shortext.has_key(ext):
+        if ext in self.shortext:
             self.shortext[ext] += 1
         else:
             self.shortext[ext] = 0
@@ -158,7 +158,7 @@
 
 
 def usage():
-    print """makewxs.py cmd options
+    print("""makewxs.py cmd options
 commands:
   flist: make file list to be included wxs file
   wxs  : make wxs file from a input template file and yaml files 
@@ -165,7 +165,7 @@
 examples:
   makewxs.py flist -c ComponentName -p Path -o OutputFilename file_names...
   makewxs.py wxs -o Output.wxs -i InputTempalte input_yaml_files...
-"""
+""")
 
 
 def main(argv):

Modified: trunk/OpenRTM-aist/build/pickupprojs.py
===================================================================
--- trunk/OpenRTM-aist/build/pickupprojs.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/pickupprojs.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -38,4 +38,4 @@
     if name != "" and guid != "":
         break
 
-print name + "GUID:", guid
+print(name + "GUID:", guid)

Modified: trunk/OpenRTM-aist/build/setuptest.py
===================================================================
--- trunk/OpenRTM-aist/build/setuptest.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/setuptest.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -247,7 +247,7 @@
         text=t.generate(data)
         f.write(text)
         f.close()
-        print "\"", fname, "\"" " was generated."
+        print("\"", fname, "\"" " was generated.")
         return
 
     def gen_all(self):
@@ -271,7 +271,7 @@
 try:
     os.mkdir(class_name, 0755)
 except:
-    print "Directory \"" + class_name + "\" already exists."
+    print("Directory \"" + class_name + "\" already exists.")
     sys.exit(1)
 
 data = test_dict(class_name)

Modified: trunk/OpenRTM-aist/build/slntool.py
===================================================================
--- trunk/OpenRTM-aist/build/slntool.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/slntool.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -78,7 +78,7 @@
 
 
 def usage():
-    print """
+    print("""
 Usage:
   slntool.py --dep dep_file [--outfile outfile] vcproj_files...
 
@@ -107,7 +107,7 @@
 Lib2: Lib1
 -------------
 
-"""
+""")
 
 
 def get_projinfo(fname,vcversion="VC8"):
@@ -170,7 +170,7 @@
             i += 1
             if i < argc: vcversion = argv[i]
             else: raise InvalidOption(opt + " needs value")
-            if not vcversions.has_key(vcversion):
+            if not vcversion in vcversions:
                 allowedvers = vcversions.keys().__repr__()
                 raise InvalidOption("allowed vcversions are " + allowedvers)
         else:
@@ -189,7 +189,7 @@
 """
     for f in projfiles:
         pj = get_projinfo(f, vcversion)
-        if depdict.has_key(pj["Name"]):
+        if pj["Name"] in depdict:
             pj["Depend"] = depdict[pj["Name"]]
         projs.append(pj)
     def depsort(d0, d1):
@@ -198,8 +198,8 @@
         d0 == d1: return  0 
         d0  > d1: return  1 
         """
-        d0_depends = d0.has_key("Depend")
-        d1_depends = d1.has_key("Depend")
+        d0_depends = "Depend" in d0
+        d1_depends = "Depend" in d1
         if not d0_depends and not d1_depends:
             # both d0, d1 has no dependency 
             return 0
@@ -213,8 +213,8 @@
             return 1 
 
         # d0 and d1 has dependency
-        d0_in_dep = depdict.has_key(d0["Name"])
-        d1_in_dep = depdict.has_key(d1["Name"])
+        d0_in_dep = d0["Name"] in depdict
+        d1_in_dep = d1["Name"] in depdict
         if not d0_in_dep and not d1_in_dep:
             return 0
         if not d0_in_dep and d1_in_dep:
@@ -249,7 +249,7 @@
     GUID: &%s %s
     Depend:
 """ % (pj["Name"], pj["FileName"], pj["Name"], pj["GUID"])
-        if pj.has_key("Depend"):
+        if "Depend" in pj:
             for dep in pj["Depend"]:
                 dep = """      - *%s
 """ % (dep)
@@ -285,7 +285,7 @@
     try:
         res = parse_args(argv)
     except SlnToolException, e:
-        print "\n" + e.msg + "\n"
+        print("\n" + e.msg + "\n")
         usage()
         sys.exit(-1)
 
@@ -308,13 +308,13 @@
 #------------------------------------------------------------
 def test_getprojinfo():
     for f in sys.argv[1:]:
-        print get_projinfo(f)
+        print(get_projinfo(f))
 
 def test_getdep():
-    print get_dependencies(sys.argv[1])
+    print(get_dependencies(sys.argv[1]))
 
 def test_getslnyaml():
-    print gen_solution(get_slnyaml("dep.yaml", sys.argv[1:]))
+    print(gen_solution(get_slnyaml("dep.yaml", sys.argv[1:])))
 
 #------------------------------------------------------------
 # entry point

Modified: trunk/OpenRTM-aist/build/uuid.py
===================================================================
--- trunk/OpenRTM-aist/build/uuid.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/uuid.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -1,103 +1,48 @@
 #!/usr/bin/env python
+# -*- coding: euc-jp -*-
 
-r"""UUID objects (universally unique identifiers) according to RFC 4122.
+##
+# @file uuid.py
+# @brief 
+# @date $Date: 2006/06/12 $
+# @author Ka-Ping Yee <ping at zesty.ca>
+#
+# Copyright (C) 2008
+#     Task-intelligence Research Group,
+#     Intelligent Systems Research Institute,
+#     National Institute of
+#         Advanced Industrial Science and Technology (AIST), Japan
+#     All rights reserved.
 
-This module provides immutable UUID objects (class UUID) and the functions
-uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5
-UUIDs as specified in RFC 4122.
+import sys
 
-If all you want is a unique ID, you should probably call uuid1() or uuid4().
-Note that uuid1() may compromise privacy since it creates a UUID containing
-the computer's network address.  uuid4() creates a random UUID.
-
-Typical usage:
-
-    >>> import uuid
-
-    # make a UUID based on the host ID and current time
-    >>> uuid.uuid1()
-    UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
-
-    # make a UUID using an MD5 hash of a namespace UUID and a name
-    >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
-    UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
-
-    # make a random UUID
-    >>> uuid.uuid4()
-    UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
-
-    # make a UUID using a SHA-1 hash of a namespace UUID and a name
-    >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
-    UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
-
-    # make a UUID from a string of hex digits (braces and hyphens ignored)
-    >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
-
-    # convert a UUID to a string of hex digits in standard form
-    >>> str(x)
-    '00010203-0405-0607-0809-0a0b0c0d0e0f'
-
-    # get the raw 16 bytes of the UUID
-    >>> x.bytes
-    '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
-
-    # make a UUID from a 16-byte string
-    >>> uuid.UUID(bytes=x.bytes)
-    UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
-
-This module works with Python 2.3 or higher."""
-
-__author__ = 'Ka-Ping Yee <ping at zesty.ca>'
-__date__ = '$Date: 2007-07-20 15:38:13 $'.split()[1].replace('/', '-')
-__version__ = '$Revision: 1.1.2.1 $'.split()[1]
-
 RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [
     'reserved for NCS compatibility', 'specified in RFC 4122',
     'reserved for Microsoft compatibility', 'reserved for future definition']
 
-class UUID(object):
-    """Instances of the UUID class represent UUIDs as specified in RFC 4122.
-    UUID objects are immutable, hashable, and usable as dictionary keys.
-    Converting a UUID to a string with str() yields something in the form
-    '12345678-1234-1234-1234-123456789abc'.  The UUID constructor accepts
-    four possible forms: a similar string of hexadecimal digits, or a
-    string of 16 raw bytes as an argument named 'bytes', or a tuple of
-    six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and
-    48-bit values respectively) as an argument named 'fields', or a single
-    128-bit integer as an argument named 'int'.
-    
-    UUIDs have these read-only attributes:
 
-        bytes       the UUID as a 16-byte string
+if sys.version_info[0] == 3:
+    long = int
 
-        fields      a tuple of the six integer fields of the UUID,
-                    which are also available as six individual attributes
-                    and two derived attributes:
 
-            time_low                the first 32 bits of the UUID
-            time_mid                the next 16 bits of the UUID
-            time_hi_version         the next 16 bits of the UUID
-            clock_seq_hi_variant    the next 8 bits of the UUID
-            clock_seq_low           the next 8 bits of the UUID
-            node                    the last 48 bits of the UUID
 
-            time                    the 60-bit timestamp
-            clock_seq               the 14-bit sequence number
 
-        hex         the UUID as a 32-character hexadecimal string
 
-        int         the UUID as a 128-bit integer
+##
+# @if jp
+# @class UUID
+# @brief UUIDÊÝ»ý¥¯¥é¥¹
+# 
+# À¸À®¤·¤¿ UUID ¤Î¾ðÊó¤òÊÝ»ý¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹¡£
+#
+# @since 0.4.0
+#
+# @else
+#
+# @endif
+class UUID(object):
 
-        urn         the UUID as a URN as specified in RFC 4122
-
-        variant     the UUID variant (one of the constants RESERVED_NCS,
-                    RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE)
-
-        version     the UUID version number (1 through 5, meaningful only
-                    when the variant is RFC_4122)
-    """
-
-    def __init__(self, hex=None, bytes=None, fields=None, int=None,
+    def __init__(self, hex=None, bytes=None, fields=None, int_value=None,
                        version=None):
         r"""Create a UUID from either a string of 32 hexadecimal digits,
         a string of 16 bytes as the 'bytes' argument, a tuple of six
@@ -121,62 +66,68 @@
         overriding bits in the given 'hex', 'bytes', 'fields', or 'int'.
         """
 
-        if [hex, bytes, fields, int].count(None) != 3:
+            
+        if [hex, bytes, fields, int_value].count(None) != 3:
             raise TypeError('need just one of hex, bytes, fields, or int')
-        if hex is not None:
+        if hex:
             hex = hex.replace('urn:', '').replace('uuid:', '')
             hex = hex.strip('{}').replace('-', '')
             if len(hex) != 32:
                 raise ValueError('badly formed hexadecimal UUID string')
-            int = long(hex, 16)
-        if bytes is not None:
+            int_value = long(hex, 16)
+        if bytes:
             if len(bytes) != 16:
                 raise ValueError('bytes is not a 16-char string')
-            int = long(('%02x'*16) % tuple(map(ord, bytes)), 16)
-        if fields is not None:
+            def ord_func(v):
+                if sys.version_info[0] == 3:
+                    return ord(chr(v))
+                else:
+                    return ord(v)
+            int_value = long(('%02x'*16) % tuple(map(ord_func, bytes)), 16)
+        if fields:
             if len(fields) != 6:
                 raise ValueError('fields is not a 6-tuple')
             (time_low, time_mid, time_hi_version,
              clock_seq_hi_variant, clock_seq_low, node) = fields
-            if not 0 <= time_low < 1<<32L:
+            if not 0 <= time_low < 1<<32:
                 raise ValueError('field 1 out of range (need a 32-bit value)')
-            if not 0 <= time_mid < 1<<16L:
+            if not 0 <= time_mid < 1<<16:
                 raise ValueError('field 2 out of range (need a 16-bit value)')
-            if not 0 <= time_hi_version < 1<<16L:
+            if not 0 <= time_hi_version < 1<<16:
                 raise ValueError('field 3 out of range (need a 16-bit value)')
-            if not 0 <= clock_seq_hi_variant < 1<<8L:
+            if not 0 <= clock_seq_hi_variant < 1<<8:
                 raise ValueError('field 4 out of range (need an 8-bit value)')
-            if not 0 <= clock_seq_low < 1<<8L:
+            if not 0 <= clock_seq_low < 1<<8:
                 raise ValueError('field 5 out of range (need an 8-bit value)')
-            if not 0 <= node < 1<<48L:
+            if not 0 <= node < 1<<48:
                 raise ValueError('field 6 out of range (need a 48-bit value)')
-            clock_seq = (clock_seq_hi_variant << 8L) | clock_seq_low
-            int = ((time_low << 96L) | (time_mid << 80L) |
-                   (time_hi_version << 64L) | (clock_seq << 48L) | node)
-        if int is not None:
-            if not 0 <= int < 1<<128L:
+            clock_seq = (clock_seq_hi_variant << 8) | clock_seq_low
+            int_value = ((time_low << 96) | (time_mid << 80) |
+                   (time_hi_version << 64) | (clock_seq << 48) | node)
+        if int_value:
+            if not 0 <= int_value < 1<<128:
                 raise ValueError('int is out of range (need a 128-bit value)')
-        if version is not None:
+        if version:
             if not 1 <= version <= 5:
                 raise ValueError('illegal version number')
             # Set the variant to RFC 4122.
-            int &= ~(0xc000 << 48L)
-            int |= 0x8000 << 48L
+            int_value &= ~(0xc000 << 48)
+            int_value |= 0x8000 << 48
             # Set the version number.
-            int &= ~(0xf000 << 64L)
-            int |= version << 76L
-        self.__dict__['int'] = int
+            int_value &= ~(0xf000 << 64)
+            int_value |= version << 76
+        self.__dict__['int_value'] = int_value
 
     def __cmp__(self, other):
         if isinstance(other, UUID):
-            return cmp(self.int, other.int)
+            return cmp(self.int_value, other.int_value)
         return NotImplemented
 
     def __hash__(self):
-        return hash(self.int)
+        return hash(self.int_value)
 
     def __int__(self):
-        return self.int
+        return self.int_value
 
     def __repr__(self):
         return 'UUID(%r)' % str(self)
@@ -185,7 +136,7 @@
         raise TypeError('UUID objects are immutable')
 
     def __str__(self):
-        hex = '%032x' % self.int
+        hex = '%032x' % self.int_value
         return '%s-%s-%s-%s-%s' % (
             hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
 
@@ -192,7 +143,7 @@
     def get_bytes(self):
         bytes = ''
         for shift in range(0, 128, 8):
-            bytes = chr((self.int >> shift) & 0xff) + bytes
+            bytes = chr((self.int_value >> shift) & 0xff) + bytes
         return bytes
 
     bytes = property(get_bytes)
@@ -204,49 +155,49 @@
     fields = property(get_fields)
 
     def get_time_low(self):
-        return self.int >> 96L
+        return self.int_value >> 96
    
     time_low = property(get_time_low)
 
     def get_time_mid(self):
-        return (self.int >> 80L) & 0xffff
+        return (self.int_value >> 80) & 0xffff
 
     time_mid = property(get_time_mid)
 
     def get_time_hi_version(self):
-        return (self.int >> 64L) & 0xffff
+        return (self.int_value >> 64) & 0xffff
     
     time_hi_version = property(get_time_hi_version)
 
     def get_clock_seq_hi_variant(self):
-        return (self.int >> 56L) & 0xff
+        return (self.int_value >> 56) & 0xff
 
     clock_seq_hi_variant = property(get_clock_seq_hi_variant)
     
     def get_clock_seq_low(self):
-        return (self.int >> 48L) & 0xff
+        return (self.int_value >> 48) & 0xff
 
     clock_seq_low = property(get_clock_seq_low)
 
     def get_time(self):
-        return (((self.time_hi_version & 0x0fffL) << 48L) |
-                (self.time_mid << 32L) | self.time_low)
+        return (((self.time_hi_version & 0x0fff) << 48) |
+                (self.time_mid << 32) | self.time_low)
 
     time = property(get_time)
 
     def get_clock_seq(self):
-        return (((self.clock_seq_hi_variant & 0x3fL) << 8L) |
+        return (((self.clock_seq_hi_variant & 0x3f) << 8) |
                 self.clock_seq_low)
 
     clock_seq = property(get_clock_seq)
     
     def get_node(self):
-        return self.int & 0xffffffffffff
+        return self.int_value & 0xffffffffffff
 
     node = property(get_node)
 
     def get_hex(self):
-        return '%032x' % self.int
+        return '%032x' % self.int_value
 
     hex = property(get_hex)
 
@@ -256,11 +207,11 @@
     urn = property(get_urn)
 
     def get_variant(self):
-        if not self.int & (0x8000 << 48L):
+        if not self.int_value & (0x8000 << 48):
             return RESERVED_NCS
-        elif not self.int & (0x4000 << 48L):
+        elif not self.int_value & (0x4000 << 48):
             return RFC_4122
-        elif not self.int & (0x2000 << 48L):
+        elif not self.int_value & (0x2000 << 48):
             return RESERVED_MICROSOFT
         else:
             return RESERVED_FUTURE
@@ -270,7 +221,7 @@
     def get_version(self):
         # The version bits are only meaningful for RFC 4122 UUIDs.
         if self.variant == RFC_4122:
-            return int((self.int >> 76L) & 0xf)
+            return int((self.int_value >> 76) & 0xf)
 
     version = property(get_version)
 
@@ -277,17 +228,15 @@
 def _ifconfig_getnode():
     """Get the hardware address on Unix by running ifconfig."""
     import os
-    for dir in ['', '/sbin/', '/usr/sbin']:
-        try:
-            pipe = os.popen(os.path.join(dir, 'ifconfig'))
-        except IOError:
-            continue
-        for line in pipe:
-            words = line.lower().split()
-            for i in range(len(words)):
-                if words[i] in ['hwaddr', 'ether']:
-                    return int(words[i + 1].replace(':', ''), 16)
+    dir = '/sbin/'
+    pipe = os.popen(os.path.join(dir, 'ifconfig'))
 
+    for line in pipe:
+      words = line.lower().split()
+      for i in range(len(words)):
+        if words[i] in ['hwaddr', 'ether']:
+          return int(words[i + 1].replace(':', ''), 16)
+
 def _ipconfig_getnode():
     """Get the hardware address on Windows by running ipconfig.exe."""
     import os, re
@@ -335,8 +284,8 @@
             continue
         status._unpack()
         bytes = map(ord, status.adapter_address)
-        return ((bytes[0]<<40L) + (bytes[1]<<32L) + (bytes[2]<<24L) +
-                (bytes[3]<<16L) + (bytes[4]<<8L) + bytes[5])
+        return ((bytes[0]<<40) + (bytes[1]<<32) + (bytes[2]<<24) +
+                (bytes[3]<<16) + (bytes[4]<<8) + bytes[5])
 
 # Thanks to Thomas Heller for ctypes and for his help with its use here.
 
@@ -384,7 +333,7 @@
 def _random_getnode():
     """Get a random node ID, with eighth bit set as suggested by RFC 4122."""
     import random
-    return random.randrange(0, 1<<48L) | 0x010000000000L
+    return random.randrange(0, 1<<48) | 0x010000000000
 
 _node = None
 
@@ -395,7 +344,7 @@
     48-bit number with its eighth bit set to 1 as recommended in RFC 4122."""
 
     global _node
-    if _node is not None:
+    if _node:
         return _node
 
     import sys
@@ -409,7 +358,7 @@
             _node = getter()
         except:
             continue
-        if _node is not None:
+        if _node:
             return _node
 
 def uuid1(node=None, clock_seq=None):
@@ -428,15 +377,15 @@
     nanoseconds = int(time.time() * 1e9)
     # 0x01b21dd213814000 is the number of 100-ns intervals between the
     # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
-    timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
+    timestamp = int(nanoseconds/100) + 0x01b21dd213814000
     if clock_seq is None:
         import random
-        clock_seq = random.randrange(1<<14L) # instead of stable storage
-    time_low = timestamp & 0xffffffffL
-    time_mid = (timestamp >> 32L) & 0xffffL
-    time_hi_version = (timestamp >> 48L) & 0x0fffL
-    clock_seq_low = clock_seq & 0xffL
-    clock_seq_hi_variant = (clock_seq >> 8L) & 0x3fL
+        clock_seq = random.randrange(1<<14) # instead of stable storage
+    time_low = timestamp & 0xffffffff
+    time_mid = (timestamp >> 32) & 0xffff
+    time_hi_version = (timestamp >> 48) & 0x0fff
+    clock_seq_low = clock_seq & 0xff
+    clock_seq_hi_variant = (clock_seq >> 8) & 0x3f
     if node is None:
         node = getnode()
     return UUID(fields=(time_low, time_mid, time_hi_version,
@@ -477,7 +426,3 @@
 NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8')
 NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8')
 NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8')
-
-
-if __name__ == "__main__":
-    print str(uuid1()).upper()

Modified: trunk/OpenRTM-aist/build/vcprojtool.py
===================================================================
--- trunk/OpenRTM-aist/build/vcprojtool.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/vcprojtool.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -804,7 +804,7 @@
 
 
 def usage():
-    print """Usage:
+    print("""Usage:
   vcprojtool.py cmd options
 commands:
   vcproj: Generate vcproj
@@ -819,7 +819,7 @@
                      --resource *.txt
   vcprojtool.py yaml --type [exe|dll|nmake|lib] --output
   vcprojtool.py flist --out --source|--header|--resource *
-"""
+""")
 
 import sys
 
@@ -865,7 +865,7 @@
         return vcproj_template % (conf_type[type], self.tool_element(type))
 
     def escape_cmdline(self, dict):
-        if not dict.has_key("Configurations"): return
+        if not "Configurations" in dict: return
     
         def escape_cmd(text):
             text = text.replace("\"", """)
@@ -878,8 +878,8 @@
                 if isinstance(conf[tool], ListType):
                     for keyval in conf[tool]:
                         if isinstance(keyval, DictType) \
-                                and keyval.has_key("Key") \
-                                and keyval.has_key("Value") \
+                                and "Key" in keyval \
+                                and "Value" in keyval \
                                 and keyval["Key"] == "CommandLine":
                             keyval["Value"] = escape_cmd(keyval["Value"])
 
@@ -923,15 +923,15 @@
     def generate(self):
         text = ""
         loaded = ""
-        if self.flist.has_key("yaml") and len(self.flist["yaml"]) > 0:
+        if "yaml" in self.flist and len(self.flist["yaml"]) > 0:
             loaded = self.load_yamls(self.flist["yaml"])
 
         if loaded.find("ProjectType:") < 0: # No toplevel config
-            if self.yaml_template.has_key(self.type):
+            if self.type in self.yaml_template:
                 text = self.yaml_template[self.type]
                 text += loaded
             else:
-                print "type should be specified."
+                print("type should be specified.")
                 usage()
         else:
             text = loaded
@@ -1062,11 +1062,11 @@
             if i < argc: type = argv[i]
             else: raise InvalidOption(opt + " needs value")
             type = type.upper()
-            if not conf_type.has_key(type):
+            if not type in conf_type:
                 raise InvalidOption("unknown type: "
                                     + type + "\n" +
                                     "    --type should be [exe|dll|nmake|lib]")
-        elif opt[:2] == "--" and flist.has_key(opt[2:]):
+        elif opt[:2] == "--" and opt[2:] in flist:
             lname = opt[2:]
             i += 1
             if not i < argc: raise InvalidOption(opt + " need value") 
@@ -1092,7 +1092,7 @@
     try:
         res = parse_args(argv)
     except VCProjException, e:
-        print "\n" + e.msg + "\n"
+        print("\n" + e.msg + "\n")
         usage()
         sys.exit(-1)
 
@@ -1125,12 +1125,12 @@
 # tests
 #------------------------------------------------------------
 def test_filelist():
-    print FileList({"source": ["hoge.cpp", "hage.cpp", "fuga.cpp"],
+    print(FileList({"source": ["hoge.cpp", "hage.cpp", "fuga.cpp"],
                     "header": ["hoge.h", "hage.h", "fuga.h"],
-                    "resource": []}).generate()
+                    "resource": []}).generate())
 
 def test_yamlconfig():
-    print YamlConfig("EXE", "8.00", "Test", "0.9.1",
+    print(YamlConfig("EXE", "8.00", "Test", "0.9.1",
                      {"source":
                           ["hoge.cpp",
                            "hage.cpp",
@@ -1138,10 +1138,10 @@
                       "header":
                           ["hoge.h", "hage.h", "fuga.h"],
                       "resource":
-                          []}).generate()
+                          []}).generate())
 
 def test_vcproj():
-    print VCProject("EXE", YamlConfig("EXE", "8.00", "Test", "1.0.0",
+    print(VCProject("EXE", YamlConfig("EXE", "8.00", "Test", "1.0.0",
                                       {"source":
                                            ["hoge.cpp",
                                             "hage.cpp",
@@ -1151,7 +1151,7 @@
                                        "resource":
                                           [],
                                        "yaml":
-                                           []}).generate()).generate()
+                                           []}).generate()).generate())
 
 #------------------------------------------------------------
 # entry point

Modified: trunk/OpenRTM-aist/build/vcxprojtool.py
===================================================================
--- trunk/OpenRTM-aist/build/vcxprojtool.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/vcxprojtool.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -927,7 +927,7 @@
 
 
 def usage():
-    print """Usage:
+    print("""Usage:
   vcprojtool.py cmd options
 commands:
   vcproj: Generate vcproj
@@ -942,7 +942,7 @@
                      --resource *.txt
   vcprojtool.py yaml --type [exe|dll|nmake|lib] --output
   vcprojtool.py flist --out --source|--header|--resource *
-"""
+""")
 rtcdll_yaml = rtcdll_yaml + get_after_config(rtcdll_yaml)
 
 import sys
@@ -1026,7 +1026,7 @@
         return vcxproj_template % (conf_type[type], self.PreBuildEventtool_element(type), self.CLtool_element(type), self.Libtool_element(type), self.PreLinkEventtool_element(type), self.Linktool_element(type), self.PostBuildEventtool_element(type))
 
     def escape_cmdline(self, dict):
-        if not dict.has_key("Configurations"): return
+        if not "Configurations" in dict: return
     
         def escape_cmd(text):
             text = text.replace("\"", """)
@@ -1039,8 +1039,8 @@
                 if isinstance(conf[tool], ListType):
                     for keyval in conf[tool]:
                         if isinstance(keyval, DictType) \
-                                and keyval.has_key("Key") \
-                                and keyval.has_key("Value") \
+                                and "Key" in keyval \
+                                and "Value" in keyval \
                                 and keyval["Key"] == "Command":
                             keyval["Value"] = escape_cmd(keyval["Value"])
 
@@ -1084,20 +1084,20 @@
     def generate(self):
         text = ""
         loaded = ""
-        if self.flist.has_key("yaml") and len(self.flist["yaml"]) > 0:
+        if "yaml" in self.flist and len(self.flist["yaml"]) > 0:
             loaded = self.load_yamls(self.flist["yaml"])
 
         if loaded.find("ProjectType:") < 0: # No toplevel config
-            if self.yaml_template.has_key(self.type):
+            if self.type in self.yaml_template:
                 text = self.yaml_template[self.type]
                 text += loaded
             else:
-                print "type should be specified."
+                print("type should be specified.")
                 usage()
         else:
             text = loaded
 
-        print self.flist
+        print(self.flist)
 
         text += FileList(self.flist).generate()
 
@@ -1227,11 +1227,11 @@
             if i < argc: type = argv[i]
             else: raise InvalidOption(opt + " needs value")
             type = type.upper()
-            if not conf_type.has_key(type):
+            if not type in conf_type:
                 raise InvalidOption("unknown type: "
                                     + type + "\n" +
                                     "    --type should be [exe|dll|nmake|lib]")
-        elif opt[:2] == "--" and flist.has_key(opt[2:]):
+        elif opt[:2] == "--" and opt[2:] in flist:
             lname = opt[2:]
             i += 1
             if not i < argc: raise InvalidOption(opt + " need value") 
@@ -1257,7 +1257,7 @@
     try:
         res = parse_args(argv)
     except VCProjException, e:
-        print "\n" + e.msg + "\n"
+        print("\n" + e.msg + "\n")
         usage()
         sys.exit(-1)
 
@@ -1290,12 +1290,12 @@
 # tests
 #------------------------------------------------------------
 def test_filelist():
-    print FileList({"source": ["hoge.cpp", "hage.cpp", "fuga.cpp"],
+    print(FileList({"source": ["hoge.cpp", "hage.cpp", "fuga.cpp"],
                     "header": ["hoge.h", "hage.h", "fuga.h"],
-                    "resource": []}).generate()
+                    "resource": []}).generate())
 
 def test_yamlconfig():
-    print YamlConfig("EXE", "10.00", "Test", "0.9.1",
+    print(YamlConfig("EXE", "10.00", "Test", "0.9.1",
                      {"source":
                           ["hoge.cpp",
                            "hage.cpp",
@@ -1303,10 +1303,10 @@
                       "header":
                           ["hoge.h", "hage.h", "fuga.h"],
                       "resource":
-                          []}).generate()
+                          []}).generate())
 
 def test_vcproj():
-    print VCProject("EXE", YamlConfig("EXE", "10.00", "Test", "1.0.0",
+    print(VCProject("EXE", YamlConfig("EXE", "10.00", "Test", "1.0.0",
                                       {"source":
                                            ["hoge.cpp",
                                             "hage.cpp",
@@ -1316,7 +1316,7 @@
                                        "resource":
                                           [],
                                        "yaml":
-                                           []}).generate()).generate()
+                                           []}).generate()).generate())
 
 #------------------------------------------------------------
 # entry point

Modified: trunk/OpenRTM-aist/build/vsprops2cmake.py
===================================================================
--- trunk/OpenRTM-aist/build/vsprops2cmake.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/vsprops2cmake.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -7,12 +7,12 @@
 
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print "please specify vsprops file"
+        print("please specify vsprops file")
         sys.exit(1)
 
     fname = sys.argv[1]
     if fname.split(".")[-1] != "vsprops":
-        print "please specify vsprops file"
+        print("please specify vsprops file")
         sys.exit(1)
 
     f = file(sys.argv[1], "r")

Modified: trunk/OpenRTM-aist/build/yat.py
===================================================================
--- trunk/OpenRTM-aist/build/yat.py	2017-11-02 09:38:58 UTC (rev 3059)
+++ trunk/OpenRTM-aist/build/yat.py	2017-11-06 00:51:55 UTC (rev 3060)
@@ -168,7 +168,13 @@
 #
 import string
 import re
-from types import StringType, IntType, FloatType, DictType, ListType, ClassType
+#from types import StringType, IntType, FloatType, DictType, ListType, ClassType
+StringType = str
+IntType = int
+FloatType = float
+DictType = dict
+ListType = list
+#ClassType = class
 import sys
 
 class Template:
@@ -397,7 +403,7 @@
             self.__write_cmd("self.pop_dict()")
             self.__pop_level()
         except:
-            print args, self.lineno()
+            print(args, self.lineno())
             raise UnmatchedBlock(self.lineno(), "endfor")
         return
 
@@ -450,7 +456,7 @@
         cmd = args[3]
         if len(self.re_number.findall(cmd)) == 1:
             cmd_text = "if %s_index == %s:" % (key, cmd)
-        elif cmdlist.has_key(cmd):
+        elif cmd in cmdlist:
             if cmd == "last":
                 cmd_text = cmdlist[cmd] % (key,key)
             else:
@@ -474,7 +480,7 @@
         cmd = args[3]
         if len(self.re_number.findall(cmd)) == 1:
             cmd_text = "elif %s_index == %s:" % (key, cmd)
-        elif cmdlist.has_key(cmd):
+        elif cmd in cmdlist:
             if cmd == "last":
                 cmd_text = cmdlist[cmd] % (key,key)
             else:
@@ -525,19 +531,19 @@
     #------------------------------------------------------------
 
     def __print_error(self, e):
-        print "Parse Error: line", e.lineno, "in input data"
-        print "  " + ''.join(nesteditem(e.value))
+        print("Parse Error: line", e.lineno, "in input data")
+        print("  " + ''.join(nesteditem(e.value)))
         lines = self.template.split("\n")
         length = len(lines)
-        print "------------------------------------------------------------"
+        print("------------------------------------------------------------")
         for i in range(1,10):
             l = e.lineno - 6 + i
             if l > 0 and l < length:
-                print lines[l]
+                print(lines[l])
                 if i == 5:
                     uline = '~'*len(lines[l])
-                    print uline
-        print "------------------------------------------------------------"
+                    print(uline)
+        print("------------------------------------------------------------")
     
     def del_nl_after_cmd(self):
         # next text index after command
@@ -591,8 +597,8 @@
         self.text = ""
 
     def print_error(self, e):
-        print "\nTemplate Generation Error: line", e.lineno, "in input data"
-        print "  " + ''.join(nesteditem(e.value))
+        print("\nTemplate Generation Error: line", e.lineno, "in input data")
+        print("  " + ''.join(nesteditem(e.value)))
         temp = ""
         for i, s in enumerate(self.token):
             if s != None:
@@ -602,15 +608,15 @@
                     temp += s
         lines = temp.split("\n")
         length = len(lines)
-        print "------------------------------------------------------------"
+        print("------------------------------------------------------------")
         for i in range(1,10):
             l = e.lineno - 6 + i
             if l > 0 and l < length:
-                print lines[l]
+                print(lines[l])
                 if i == 5:
                     uline = '~'*len(lines[l])
-                    print uline
-        print "------------------------------------------------------------"
+                    print(uline)
+        print("------------------------------------------------------------")
         
     def set_index(self, index):
         self.index = index
@@ -678,7 +684,7 @@
         length = len(keys)
         d = dict
         for i in range(length):
-            if isinstance(d, DictType) and d.has_key(keys[i]):
+            if isinstance(d, DictType) and keys[i] in d:
                 d = d[keys[i]]
             else:
                 return None
@@ -818,18 +824,18 @@
     if len(dict) == len(template):
         for i in range(len(dict)-1,len(dict)):
             t = Template(template[i])
-            print "-" * 60
-            print "Example:", i
-            print "-" * 60
-            print "Template:\n"
-            print template[i]
-            print "-" * 60
-            print "Dictionary:\n"
-            print yaml.dump(dict[i], default_flow_style=False)
-            print "-" * 60
-            print "Generated Script:\n"
-            print t.get_script()
-            print "-" * 60
-            print "Generated Text:\n"
-            print t.generate(dict[i])
-            print ""
+            print("-" * 60)
+            print("Example:", i)
+            print("-" * 60)
+            print("Template:\n"
+            print(template[i])
+            print("-" * 60)
+            print("Dictionary:\n")
+            print(yaml.dump(dict[i], default_flow_style=False))
+            print("-" * 60)
+            print("Generated Script:\n")
+            print(t.get_script())
+            print("-" * 60)
+            print("Generated Text:\n")
+            print(t.generate(dict[i]))
+            print("")



More information about the openrtm-commit mailing list