Changeset 65969 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Mar 7, 2017 11:01:44 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r65958 r65969 187 187 continue; 188 188 sLine = sLine.strip() 189 if len(sLine) > 0:189 if sLine: 190 190 sVersion += ' / ' + sPrefix + sLine; 191 191 break; … … 199 199 oFile.close(); 200 200 sLast = sLast.strip(); 201 if len(sLast) > 0:201 if sLast: 202 202 sVersion += ' (' + sLast + ')'; 203 203 except: … … 430 430 431 431 if asArgs[0].endswith('.py'): 432 if sys.executable is not None and len(sys.executable) > 0:432 if sys.executable: 433 433 asArgs.insert(0, sys.executable); 434 434 else: … … 742 742 return False; 743 743 sCurName = sCurName.strip(); 744 if sCurName is '':744 if not sCurName: 745 745 return False; 746 746 … … 915 915 sRet = self.sImage if self.sName is None else self.sName; 916 916 if sRet is None: 917 if self.asArgs is None or len(self.asArgs) == 0:917 if not self.asArgs: 918 918 return None; 919 919 sRet = self.asArgs[0]; 920 if len(sRet) == 0:920 if not sRet: 921 921 return None; 922 922 return os.path.basename(sRet); … … 1286 1286 if cSecs > 0: 1287 1287 sRet += '%ss ' % (cSecs,); 1288 assert len(sRet) > 0; assert sRet[-1] == ' ';1288 assert sRet; assert sRet[-1] == ' '; 1289 1289 return sRet[:-1]; 1290 1290 … … 1294 1294 data is usually already string form. 1295 1295 """ 1296 if isinstance(oSeconds, int) or isinstance(oSeconds, long):1296 if isinstance(oSeconds, (int, long)): 1297 1297 return formatIntervalSeconds(oSeconds); 1298 1298 if not isString(oSeconds): … … 1315 1315 # We might given non-strings, just return them without any fuss. 1316 1316 if not isString(sString): 1317 if isinstance(sString, int) or isinstance(sString, long) orsString is None:1317 if isinstance(sString, (int, long)) or sString is None: 1318 1318 return (sString, None); 1319 1319 ## @todo time/date objects? … … 1322 1322 # Strip it and make sure it's not empty. 1323 1323 sString = sString.strip(); 1324 if len(sString) == 0:1324 if not sString: 1325 1325 return (0, 'Empty interval string.'); 1326 1326 … … 1335 1335 for sPart in asRawParts: 1336 1336 sPart = sPart.strip(); 1337 if len(sPart) > 0:1337 if sPart: 1338 1338 asParts.append(sPart); 1339 if len(asParts) == 0:1339 if not asParts: 1340 1340 return (0, 'Empty interval string or something?'); 1341 1341 … … 1373 1373 else: 1374 1374 asErrors.append('Bad number "%s".' % (sNumber,)); 1375 return (cSeconds, None if len(asErrors) == 0else ' '.join(asErrors));1375 return (cSeconds, None if not asErrors else ' '.join(asErrors)); 1376 1376 1377 1377 def formatIntervalHours(cHours): … … 1393 1393 if cHours > 0: 1394 1394 sRet += '%sh ' % (cHours,); 1395 assert len(sRet) > 0; assert sRet[-1] == ' ';1395 assert sRet; assert sRet[-1] == ' '; 1396 1396 return sRet[:-1]; 1397 1397 … … 1405 1405 # We might given non-strings, just return them without any fuss. 1406 1406 if not isString(sString): 1407 if isinstance(sString, int) or isinstance(sString, long) orsString is None:1407 if isinstance(sString, (int, long)) or sString is None: 1408 1408 return (sString, None); 1409 1409 ## @todo time/date objects? … … 1412 1412 # Strip it and make sure it's not empty. 1413 1413 sString = sString.strip(); 1414 if len(sString) == 0:1414 if not sString: 1415 1415 return (0, 'Empty interval string.'); 1416 1416 … … 1425 1425 for sPart in asRawParts: 1426 1426 sPart = sPart.strip(); 1427 if len(sPart) > 0:1427 if sPart: 1428 1428 asParts.append(sPart); 1429 if len(asParts) == 0:1429 if not asParts: 1430 1430 return (0, 'Empty interval string or something?'); 1431 1431 … … 1459 1459 else: 1460 1460 asErrors.append('Bad number "%s".' % (sNumber,)); 1461 return (cHours, None if len(asErrors) == 0else ' '.join(asErrors));1461 return (cHours, None if not asErrors else ' '.join(asErrors)); 1462 1462 1463 1463 … … 1519 1519 asRet.append('internal-error: Hit exception #2! %s' % (traceback.format_exc(),)); 1520 1520 1521 if len(asRet) == 0:1521 if not asRet: 1522 1522 asRet.append('No exception info...'); 1523 1523 except: … … 1575 1575 """ 1576 1576 asArgs = argsSplit(sCmdLine); 1577 if asArgs is None or len(asArgs) == 0:1577 if not asArgs: 1578 1578 return None; 1579 1579 … … 1789 1789 try: os.unlink(sLinkFile); 1790 1790 except: pass; 1791 if sParentDir is not '' andnot os.path.exists(sParentDir):1791 if sParentDir and not os.path.exists(sParentDir): 1792 1792 os.makedirs(sParentDir); 1793 1793 try: os.link(sLinkTarget, sLinkFile);
Note:
See TracChangeset
for help on using the changeset viewer.