Changeset 59806 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Feb 24, 2016 8:21:39 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r59798 r59806 7 7 __copyright__ = \ 8 8 """ 9 Copyright (C) 2009-201 6Oracle Corporation9 Copyright (C) 2009-2015 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 builtins 35 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 return 45 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 = False 58 sep = kwargs.pop("sep", None) 59 if sep is not None: 60 if isinstance(sep, unicode): 61 want_unicode = True 62 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 = True 68 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 = True 76 break 77 if want_unicode: 78 newline = unicode("\n") 79 space = unicode(" ") 80 else: 81 newline = "\n" 82 space = " " 83 if sep is None: 84 sep = space 85 if end is None: 86 end = newline 87 for i, arg in enumerate(args): 88 if i: 89 write(sep) 90 write(arg) 91 write(end) 34 92 35 93 # … … 167 225 # Try case-insensitivity workaround for class attributes (COM methods). 168 226 sAttrLower = sAttr.lower() 169 for k in list(self.__class__.__dict__.keys()):227 for k in self.__class__.__dict__.keys(): 170 228 if k.lower() == sAttrLower: 171 229 setattr(self.__class__, sAttr, self.__class__.__dict__[k])
Note:
See TracChangeset
for help on using the changeset viewer.