diff options
| -rw-r--r-- | examples/allnoconfig.py | 4 | ||||
| -rw-r--r-- | examples/allyesconfig.py | 13 | ||||
| -rw-r--r-- | examples/help_grep.py | 4 | ||||
| -rw-r--r-- | examples/menuconfig.py | 4 | ||||
| -rw-r--r-- | examples/print_tree.py | 4 |
5 files changed, 14 insertions, 15 deletions
diff --git a/examples/allnoconfig.py b/examples/allnoconfig.py index 467f681..47a8026 100644 --- a/examples/allnoconfig.py +++ b/examples/allnoconfig.py @@ -18,7 +18,7 @@ def do_allnoconfig(node): # entries in the menuconfig interface, setting each to n (or the lowest # assignable value). - while node is not None: + while node: if isinstance(node.item, Symbol): sym = node.item @@ -33,7 +33,7 @@ def do_allnoconfig(node): changed = True # Recursively lower children - if node.list is not None: + if node.list: do_allnoconfig(node.list) node = node.next diff --git a/examples/allyesconfig.py b/examples/allyesconfig.py index 1c85d60..b1d2cf6 100644 --- a/examples/allyesconfig.py +++ b/examples/allyesconfig.py @@ -40,19 +40,19 @@ while 1: # template for how you can avoid recursing on both. The same logic is found # in the C implementation. - if node.list is not None: + if node.list: # Jump to child node if available node = node.list - elif node.next is not None: + elif node.next: # Otherwise, jump to next node if available node = node.next else: # Otherwise, look for parents with next nodes to jump to - while node.parent is not None: + while node.parent: node = node.parent - if node.next is not None: + if node.next: node = node.next break else: @@ -60,7 +60,7 @@ while 1: break # Collect all symbols that are not in choices -non_choice_syms = [sym for sym in conf.defined_syms if sym.choice is None] +non_choice_syms = [sym for sym in conf.defined_syms if not sym.choice] while 1: no_changes = True @@ -87,8 +87,7 @@ while 1: # Does the choice have a default selection that we haven't already # selected? - if selection is not None and \ - selection is not choice.user_selection: + if selection and selection is not choice.user_selection: # Yup, select it selection.set_value(2) diff --git a/examples/help_grep.py b/examples/help_grep.py index 6f54583..b9e1440 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -44,7 +44,7 @@ if len(sys.argv) < 3: search = re.compile(sys.argv[2], re.IGNORECASE).search def search_tree(node): - while node is not None: + while node: match = False if isinstance(node.item, (Symbol, Choice)) and \ @@ -63,7 +63,7 @@ def search_tree(node): if match: print("location: {}:{}\n".format(node.filename, node.linenr)) - if node.list is not None: + if node.list: search_tree(node.list) node = node.next diff --git a/examples/menuconfig.py b/examples/menuconfig.py index a4038f8..e98ff43 100644 --- a/examples/menuconfig.py +++ b/examples/menuconfig.py @@ -221,12 +221,12 @@ def print_menuconfig_nodes(node, indent): Prints a tree with all the menu entries rooted at node. Child menu entries are indented. """ - while node is not None: + while node: string = node_str(node) if string: indent_print(string, indent) - if node.list is not None: + if node.list: print_menuconfig_nodes(node.list, indent + 8) node = node.next diff --git a/examples/print_tree.py b/examples/print_tree.py index 9d9eac2..cda9ce2 100644 --- a/examples/print_tree.py +++ b/examples/print_tree.py @@ -45,7 +45,7 @@ def indent_print(s, indent): print((" " * indent) + s) def print_items(node, indent): - while node is not None: + while node: if isinstance(node.item, Symbol): indent_print("config " + node.item.name, indent) @@ -58,7 +58,7 @@ def print_items(node, indent): elif node.item == COMMENT: indent_print('comment "{0}"'.format(node.prompt[0]), indent) - if node.list is not None: + if node.list: print_items(node.list, indent + 2) node = node.next |
