Changeset 59769 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Feb 22, 2016 12:14:21 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r59353 r59769 7 7 __copyright__ = \ 8 8 """ 9 Copyright (C) 2009-201 5Oracle Corporation9 Copyright (C) 2009-2016 Oracle Corporation 10 10 11 11 This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 xrange = range 33 33 long = int 34 import builtins35 print_ = getattr(builtins, 'print', None)36 elif sys.version_info >= (2, 6):37 import __builtin__38 print_ = getattr(__builtin__, 'print', None)39 else:40 def print_(*args, **kwargs):41 """The new-style print function for Python 2.4 and 2.5."""42 fp = kwargs.pop("file", sys.stdout)43 if fp is None:44 return45 46 def write(data):47 if not isinstance(data, basestring):48 data = str(data)49 # If the file has an encoding, encode unicode with it.50 if isinstance(fp, file) and isinstance(data, unicode) and fp.encoding is not None:51 errors = getattr(fp, "errors", None)52 if errors is None:53 errors = "strict"54 data = data.encode(fp.encoding, errors)55 fp.write(data)56 57 want_unicode = False58 sep = kwargs.pop("sep", None)59 if sep is not None:60 if isinstance(sep, unicode):61 want_unicode = True62 elif not isinstance(sep, str):63 raise TypeError("sep must be None or a string")64 end = kwargs.pop("end", None)65 if end is not None:66 if isinstance(end, unicode):67 want_unicode = True68 elif not isinstance(end, str):69 raise TypeError("end must be None or a string")70 if kwargs:71 raise TypeError("invalid keyword arguments to print()")72 if not want_unicode:73 for arg in args:74 if isinstance(arg, unicode):75 want_unicode = True76 break77 if want_unicode:78 newline = unicode("\n")79 space = unicode(" ")80 else:81 newline = "\n"82 space = " "83 if sep is None:84 sep = space85 if end is None:86 end = newline87 for i, arg in enumerate(args):88 if i:89 write(sep)90 write(arg)91 write(end)92 34 93 35 # … … 225 167 # Try case-insensitivity workaround for class attributes (COM methods). 226 168 sAttrLower = sAttr.lower() 227 for k in self.__class__.__dict__.keys():169 for k in list(self.__class__.__dict__.keys()): 228 170 if k.lower() == sAttrLower: 229 171 setattr(self.__class__, sAttr, self.__class__.__dict__[k])
Note:
See TracChangeset
for help on using the changeset viewer.