From: Tobias Grosser Date: Mon, 31 Oct 2011 02:06:50 +0000 (+0000) Subject: cindex.py: Remove more ternary operator + whitespace fixes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba5d10b82b3cc00b4d71b273a18c051a1f38f22f;p=clang cindex.py: Remove more ternary operator + whitespace fixes Another batch of ternary operators and some whitespace fixes (Getting in sync with the clang_complete version of this file) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143330 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 1c62cc9555..cd6ab45496 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -230,8 +230,8 @@ class Diagnostic(object): return int(_clang_getDiagnosticNumRanges(self.diag)) def __getitem__(self, key): - if (key >= len(self)): - raise IndexError + if (key >= len(self)): + raise IndexError return _clang_getDiagnosticRange(self.diag, key) return RangeIterator(self) @@ -1381,7 +1381,9 @@ class Index(ClangObject): def read(self, path): """Load the translation unit from the given AST file.""" ptr = TranslationUnit_read(self, path) - return TranslationUnit(ptr) if ptr else None + if ptr: + return TranslationUnit(ptr) + return None def parse(self, path, args = [], unsaved_files = [], options = 0): """ @@ -1414,7 +1416,9 @@ class Index(ClangObject): ptr = TranslationUnit_parse(self, path, arg_array, len(args), unsaved_files_array, len(unsaved_files), options) - return TranslationUnit(ptr) if ptr else None + if ptr: + return TranslationUnit(ptr) + return None class TranslationUnit(ClangObject): @@ -1533,8 +1537,9 @@ class TranslationUnit(ClangObject): unsaved_files_array, len(unsaved_files), options) - return CodeCompletionResults(ptr) if ptr else None - + if ptr: + return CodeCompletionResults(ptr) + return None class File(ClangObject): """