diff options
Diffstat (limited to 'libbe/command')
-rw-r--r-- | libbe/command/base.py | 48 | ||||
-rw-r--r-- | libbe/command/comment.py | 8 | ||||
-rw-r--r-- | libbe/command/commit.py | 8 | ||||
-rw-r--r-- | libbe/command/depend.py | 14 | ||||
-rw-r--r-- | libbe/command/diff.py | 8 | ||||
-rw-r--r-- | libbe/command/due.py | 2 | ||||
-rw-r--r-- | libbe/command/help.py | 2 | ||||
-rw-r--r-- | libbe/command/html.py | 22 | ||||
-rw-r--r-- | libbe/command/import_xml.py | 20 | ||||
-rw-r--r-- | libbe/command/list.py | 6 | ||||
-rw-r--r-- | libbe/command/merge.py | 2 | ||||
-rw-r--r-- | libbe/command/new.py | 10 | ||||
-rw-r--r-- | libbe/command/serve_commands.py | 2 | ||||
-rw-r--r-- | libbe/command/set.py | 6 | ||||
-rw-r--r-- | libbe/command/show.py | 2 | ||||
-rw-r--r-- | libbe/command/subscribe.py | 14 | ||||
-rw-r--r-- | libbe/command/tag.py | 4 | ||||
-rw-r--r-- | libbe/command/target.py | 16 | ||||
-rw-r--r-- | libbe/command/util.py | 18 |
19 files changed, 101 insertions, 111 deletions
diff --git a/libbe/command/base.py b/libbe/command/base.py index 806d880..b6a9e15 100644 --- a/libbe/command/base.py +++ b/libbe/command/base.py @@ -74,7 +74,7 @@ def get_command(command_name): >>> try: ... get_command('asdf') - ... except UnknownCommand, e: + ... except UnknownCommand as e: ... print(e) Unknown command 'asdf' (No module named asdf) @@ -99,7 +99,7 @@ def get_command_class(module=None, command_name=None): >>> repr(import_xml) "<class 'libbe.command.import_xml.Import_XML'>" """ - if module == None: + if module is None: module = get_command(command_name) try: cname = command_name.capitalize().replace('-', '_') @@ -121,7 +121,7 @@ def modname_to_command_name(modname): ... try: ... if issubclass(attr, Command): ... commands.append(attr) - ... except TypeError, e: + ... except TypeError as e: ... pass ... if len(commands) == 0: ... raise Exception('No Command classes in %s' % dir(mod)) @@ -163,7 +163,7 @@ class Argument (CommandInput): self.optional = optional self.repeatable = repeatable self.completion_callback = completion_callback - if self.metavar == None: + if self.metavar is None: self.metavar = self.name.upper() class Option (CommandInput): @@ -173,17 +173,17 @@ class Option (CommandInput): self.callback = callback self.short_name = short_name self.arg = arg - if self.arg == None and self.callback == None: + if self.arg is None and self.callback is None: # use an implicit boolean argument self.arg = Argument(name=self.name, help=self.help, default=False, type='bool') self.validate() def validate(self): - if self.arg == None: - assert self.callback != None, self.name + if self.arg is None: + assert self.callback is not None, self.name return - assert self.callback == None, '%s: %s' % (self.name, self.callback) + assert self.callback is None, '%s: %s' % (self.name, self.callback) assert self.arg.name == self.name, \ 'Name missmatch: %s != %s' % (self.arg.name, self.name) assert self.arg.optional == False, self.name @@ -208,13 +208,13 @@ class _DummyParser (optparse.OptionParser): # from libbe.ui.command_line.CmdOptionParser._add_option option.validate() long_opt = '--%s' % option.name - if option.short_name != None: + if option.short_name is not None: short_opt = '-%s' % option.short_name assert '_' not in option.name, \ 'Non-reconstructable option name %s' % option.name kwargs = {'dest':option.name.replace('-', '_'), 'help':option.help} - if option.arg == None or option.arg.type == 'bool': + if option.arg is None or option.arg.type == 'bool': kwargs['action'] = 'store_true' kwargs['metavar'] = None kwargs['default'] = False @@ -223,7 +223,7 @@ class _DummyParser (optparse.OptionParser): kwargs['action'] = 'store' kwargs['metavar'] = option.arg.metavar kwargs['default'] = option.arg.default - if option.short_name != None: + if option.short_name is not None: opt = optparse.Option(short_opt, long_opt, **kwargs) else: opt = optparse.Option(long_opt, **kwargs) @@ -291,7 +291,7 @@ class Command (object): pass else: params.pop('help') - if params['complete'] != None: + if params['complete'] is not None: pass else: params.pop('complete') @@ -303,16 +303,16 @@ class Command (object): return self.status def _parse_options_args(self, options=None, args=None): - if options == None: + if options is None: options = {} - if args == None: + if args is None: args = [] params = {} for option in self.options: assert option.name not in params, params[option.name] if option.name in options: params[option.name] = options.pop(option.name) - elif option.arg != None: + elif option.arg is not None: params[option.name] = option.arg.default else: # non-arg options are flags, set to default flag value params[option.name] = False @@ -385,13 +385,13 @@ class Command (object): return "A detailed help message." def complete(self, argument=None, fragment=None): - if argument == None: + if argument is None: ret = ['--%s' % o.name for o in self.options if o.name != 'complete'] - if len(self.args) > 0 and self.args[0].completion_callback != None: + if len(self.args) > 0 and self.args[0].completion_callback is not None: ret.extend(self.args[0].completion_callback(self, argument, fragment)) return ret - elif argument.completion_callback != None: + elif argument.completion_callback is not None: # finish a particular argument return argument.completion_callback(self, argument, fragment) return [] # the particular argument doesn't supply completion info @@ -413,7 +413,7 @@ class Command (object): >>> c = Command() >>> try: ... c._check_restricted_access(s, os.path.expanduser('~/.ssh/id_rsa')) - ... except UserError, e: + ... except UserError as e: ... assert str(e).startswith('file access restricted!'), str(e) ... print('we got the expected error') we got the expected error @@ -457,9 +457,9 @@ class StdInputOutput (InputOutput): InputOutput.__init__(self, stdin, stdout) def _get_io(self, input_encoding=None, output_encoding=None): - if input_encoding == None: + if input_encoding is None: input_encoding = libbe.util.encoding.get_input_encoding() - if output_encoding == None: + if output_encoding is None: output_encoding = libbe.util.encoding.get_output_encoding() stdin = codecs.getreader(input_encoding)(sys.stdin) stdin.encoding = input_encoding @@ -512,7 +512,7 @@ class UnconnectedStorageGetter (object): class StorageCallbacks (object): def __init__(self, location=None): - if location == None: + if location is None: location = '.' self.location = location self._get_unconnected_storage = UnconnectedStorageGetter(location) @@ -532,7 +532,7 @@ class StorageCallbacks (object): intended for the init command, which calls Storage.init(). """ if not hasattr(self, '_unconnected_storage'): - if self._get_unconnected_storage == None: + if self._get_unconnected_storage is None: raise NotImplementedError self._unconnected_storage = self._get_unconnected_storage() return self._unconnected_storage @@ -574,7 +574,7 @@ class StorageCallbacks (object): class UserInterface (object): def __init__(self, io=None, location=None): - if io == None: + if io is None: io = StringInputOutput() self.io = io self.storage_callbacks = StorageCallbacks(location) diff --git a/libbe/command/comment.py b/libbe/command/comment.py index bfd24fe..c579610 100644 --- a/libbe/command/comment.py +++ b/libbe/command/comment.py @@ -126,7 +126,7 @@ class Comment (libbe.command.Command): bugdir,bug,parent = ( libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['id'])) - if params['comment'] == None: + if params['comment'] is None: # try to launch an editor for comment-body entry try: if parent == bug.comment_root: @@ -144,7 +144,7 @@ class Comment (libbe.command.Command): if body is None: raise libbe.command.UserError('No comment entered.') elif params['comment'] == '-': # read body from stdin - binary = not (params['content-type'] == None + binary = not (params['content-type'] is None or params['content-type'].startswith("text/")) if not binary: body = self.stdin.read() @@ -156,12 +156,12 @@ class Comment (libbe.command.Command): body = params['comment'] if not body.endswith('\n'): body+='\n' - if params['author'] == None: + if params['author'] is None: params['author'] = self._get_user_id() new = parent.new_reply(body=body, content_type=params['content-type']) for key in ['alt-id', 'author']: - if params[key] != None: + if params[key] is not None: setattr(new, new._setting_name_to_attr_name(key), params[key]) if params['full-uuid']: comment_id = new.id.long_user() diff --git a/libbe/command/commit.py b/libbe/command/commit.py index 077980d..afe082d 100644 --- a/libbe/command/commit.py +++ b/libbe/command/commit.py @@ -71,10 +71,10 @@ class Commit (libbe.command.Command): summary = sys.stdin.readline() else: summary = params['summary'] - if summary == None and params['body'] == None: + if summary is None and params['body'] is None: params['body'] = 'EDITOR' storage = self._get_storage() - if params['body'] == None: + if params['body'] is None: body = None elif params['body'] == 'EDITOR': body = libbe.ui.util.editor.editor_string( @@ -83,8 +83,8 @@ class Commit (libbe.command.Command): self._check_restricted_access(storage, params['body']) body = libbe.util.encoding.get_file_contents( params['body'], decode=True) - if summary == None: # use the first body line as the summary - if body == None: + if summary is None: # use the first body line as the summary + if body is None: raise libbe.command.UserError( 'cannot commit without a summary') lines = body.splitlines() diff --git a/libbe/command/depend.py b/libbe/command/depend.py index 4cb0efd..fe02ce0 100644 --- a/libbe/command/depend.py +++ b/libbe/command/depend.py @@ -54,7 +54,7 @@ class Filter (object): else: target_bug = libbe.command.target.bug_target(bugdirs, bug) if self.target in ['none', None]: - if target_bug.summary != None: + if target_bug.summary is not None: return False else: if target_bug.summary != self.target: @@ -195,14 +195,14 @@ class Depend (libbe.command.Command): ]) def _run(self, **params): - if params['repair'] == True and params['bug-id'] != None: + if params['repair'] == True and params['bug-id'] is not None: raise libbe.command.UserError( 'No arguments with --repair calls.') - if params['repair'] == False and params['bug-id'] == None: + if params['repair'] == False and params['bug-id'] is None: raise libbe.command.UserError( 'Must specify either --repair or a BUG-ID') - if params['tree-depth'] != None \ - and params['blocking-bug-id'] != None: + if params['tree-depth'] is not None \ + and params['blocking-bug-id'] is not None: raise libbe.command.UserError( 'Only one bug id used in tree mode.') bugdirs = self._get_bugdirs() @@ -223,7 +223,7 @@ class Depend (libbe.command.Command): libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['bug-id'])) - if params['tree-depth'] != None: + if params['tree-depth'] is not None: dtree = DependencyTree(bugdirs, bugA, params['tree-depth'], filter) if len(dtree.blocked_by_tree()) > 0: print('%s blocked by:' % bugA.id.user(), file=self.stdout) @@ -241,7 +241,7 @@ class Depend (libbe.command.Command): % (' '*(depth), self.bug_string(node.bug, params))), file=self.stdout) return 0 - if params['blocking-bug-id'] != None: + if params['blocking-bug-id'] is not None: bugdirB,bugB,dummy_comment = ( libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['blocking-bug-id'])) diff --git a/libbe/command/diff.py b/libbe/command/diff.py index d8aea37..aca54c3 100644 --- a/libbe/command/diff.py +++ b/libbe/command/diff.py @@ -97,18 +97,18 @@ class Diff (libbe.command.Command): def diff(self, bugdir, subscriptions, params): - if params['repo'] == None: + if params['repo'] is None: if bugdir.storage.versioned == False: raise libbe.command.UserError( 'This repository is not revision-controlled.') - if params['revision'] == None: # get the most recent revision + if params['revision'] is None: # get the most recent revision params['revision'] = bugdir.storage.revision_id(-1) old_bd = libbe.bugdir.RevisionedBugDir(bugdir, params['revision']) else: old_storage = libbe.storage.get_storage(params['repo']) old_storage.connect() old_bd_current = libbe.bugdir.BugDir(old_storage, from_disk=True) - if params['revision'] == None: # use the current working state + if params['revision'] is None: # use the current working state old_bd = old_bd_current else: if old_bd_current.storage.versioned == False: @@ -127,7 +127,7 @@ class Diff (libbe.command.Command): print('\n'.join(uuids), file=self.stdout) else : rep = tree.report_string() - if rep != None: + if rep is not None: print(rep, file=self.stdout) return 0 diff --git a/libbe/command/due.py b/libbe/command/due.py index ddf111a..2f7d181 100644 --- a/libbe/command/due.py +++ b/libbe/command/due.py @@ -65,7 +65,7 @@ class Due (libbe.command.Command): bugdir,bug,comment = ( libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['bug-id'])) - if params['due'] == None: + if params['due'] is None: due_time = get_due(bug) if due_time is None: print('No due date assigned.', file=self.stdout) diff --git a/libbe/command/help.py b/libbe/command/help.py index 981ea1a..c7961ac 100644 --- a/libbe/command/help.py +++ b/libbe/command/help.py @@ -93,7 +93,7 @@ class Help (libbe.command.Command): ]) def _run(self, **params): - if params['topic'] == None: + if params['topic'] is None: if hasattr(self.ui, 'help'): print(self.ui.help().rstrip('\n'), file=self.stdout) elif params['topic'] in libbe.command.commands(command_names=True): diff --git a/libbe/command/html.py b/libbe/command/html.py index ed43808..5ec8691 100644 --- a/libbe/command/html.py +++ b/libbe/command/html.py @@ -100,21 +100,11 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, self.logger.log( self.log_level, 'generate {} index file for {} bugs'.format( bug_type, len(bugs))) - template_info = { - 'title': self.title, - 'charset': 'UTF-8', - 'stylesheet': 'style.css', - 'header': self.header, - 'active_class': 'tab nsel', - 'inactive_class': 'tab nsel', - 'target_class': 'tab nsel', - 'bugs': bugs, - 'bug_entry': self.template.get_template('index_bug_entry.html'), - 'bug_dir': self.bug_dir, - 'index_file': self._index_file, - 'generation_time': self._generation_time(), - } - template_info['{}_class'.format(bug_type)] = 'tab sel' + template_info = {'title': self.title, 'charset': 'UTF-8', 'stylesheet': 'style.css', 'header': self.header, + 'active_class': 'tab nsel', 'inactive_class': 'tab nsel', 'target_class': 'tab nsel', + 'bugs': bugs, 'bug_entry': self.template.get_template('index_bug_entry.html'), + 'bug_dir': self.bug_dir, 'index_file': self._index_file, + 'generation_time': self._generation_time(), '{}_class'.format(bug_type): 'tab sel'} if bug_type == 'target': template = self.template.get_template('target_index.html') template_info['targets'] = [ @@ -314,7 +304,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject, return time.ctime() def _escape(self, string): - if string == None: + if string is None: return '' return xml.sax.saxutils.escape(string) diff --git a/libbe/command/import_xml.py b/libbe/command/import_xml.py index 391b2ed..42b9b49 100644 --- a/libbe/command/import_xml.py +++ b/libbe/command/import_xml.py @@ -102,7 +102,7 @@ class Import_XML (libbe.command.Command): bugdirs = self._get_bugdirs() writeable = storage.writeable storage.writeable = False - if params['root'] != None: + if params['root'] is not None: root_bugdir,root_bug,root_comment = ( libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['root'])) @@ -136,7 +136,7 @@ class Import_XML (libbe.command.Command): comms = [] for c in root_bug.comments(): comms.append(c.uuid) - if c.alt_id != None: + if c.alt_id is not None: comms.append(c.alt_id) if root_comment.uuid == libbe.comment.INVALID_UUID: root_text = root_bug.id.user() @@ -496,13 +496,13 @@ if libbe.TESTING == True: c1 = bugB.comment_from_uuid('c1') comments.remove(c1) self.assertTrue(c1.uuid == 'c1', c1.uuid) - self.assertTrue(c1.alt_id == None, c1.alt_id) + self.assertTrue(c1.alt_id is None, c1.alt_id) self.assertTrue(c1.author == 'Jane', c1.author) self.assertTrue(c1.body == 'So long\n', c1.body) c2 = bugB.comment_from_uuid('c2') comments.remove(c2) self.assertTrue(c2.uuid == 'c2', c2.uuid) - self.assertTrue(c2.alt_id == None, c2.alt_id) + self.assertTrue(c2.alt_id is None, c2.alt_id) self.assertTrue(c2.author == 'Jess', c2.author) self.assertTrue(c2.body == 'World\n', c2.body) c4 = comments[0] @@ -530,13 +530,13 @@ if libbe.TESTING == True: c1 = bugB.comment_from_uuid('c1') comments.remove(c1) self.assertTrue(c1.uuid == 'c1', c1.uuid) - self.assertTrue(c1.alt_id == None, c1.alt_id) + self.assertTrue(c1.alt_id is None, c1.alt_id) self.assertTrue(c1.author == 'Jane', c1.author) self.assertTrue(c1.body == 'Hello\n', c1.body) c2 = bugB.comment_from_uuid('c2') comments.remove(c2) self.assertTrue(c2.uuid == 'c2', c2.uuid) - self.assertTrue(c2.alt_id == None, c2.alt_id) + self.assertTrue(c2.alt_id is None, c2.alt_id) self.assertTrue(c2.author == 'Jess', c2.author) self.assertTrue(c2.body == 'World\n', c2.body) c4 = comments[0] @@ -566,13 +566,13 @@ if libbe.TESTING == True: c1 = bugB.comment_from_uuid('c1') comments.remove(c1) self.assertTrue(c1.uuid == 'c1', c1.uuid) - self.assertTrue(c1.alt_id == None, c1.alt_id) + self.assertTrue(c1.alt_id is None, c1.alt_id) self.assertTrue(c1.author == 'Jane', c1.author) self.assertTrue(c1.body == 'So long\n', c1.body) c2 = bugB.comment_from_uuid('c2') comments.remove(c2) self.assertTrue(c2.uuid == 'c2', c2.uuid) - self.assertTrue(c2.alt_id == None, c2.alt_id) + self.assertTrue(c2.alt_id is None, c2.alt_id) self.assertTrue(c2.author == 'Jess', c2.author) self.assertTrue(c2.body == 'World\n', c2.body) c4 = comments[0] @@ -601,13 +601,13 @@ if libbe.TESTING == True: c1 = bugB.comment_from_uuid('c1') comments.remove(c1) self.assertTrue(c1.uuid == 'c1', c1.uuid) - self.assertTrue(c1.alt_id == None, c1.alt_id) + self.assertTrue(c1.alt_id is None, c1.alt_id) self.assertTrue(c1.author == 'Jane', c1.author) self.assertTrue(c1.body == 'Hello\n', c1.body) c2 = bugB.comment_from_uuid('c2') comments.remove(c2) self.assertTrue(c2.uuid == 'c2', c2.uuid) - self.assertTrue(c2.alt_id == None, c2.alt_id) + self.assertTrue(c2.alt_id is None, c2.alt_id) self.assertTrue(c2.author == 'Jess', c2.author) self.assertTrue(c2.body == 'World\n', c2.body) c4 = comments[0] diff --git a/libbe/command/list.py b/libbe/command/list.py index 41e1bed..567e3fe 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -156,7 +156,7 @@ class List (libbe.command.Command): def _parse_params(self, bugdirs, params): cmp_list = [] - if params['sort'] != None: + if params['sort'] is not None: for cmp in params['sort'].split(','): if cmp not in AVAILABLE_IDXS: raise libbe.command.UserError( @@ -167,7 +167,7 @@ class List (libbe.command.Command): severity = parse_severity(params['severity'], important=params['important']) # select assigned - if params['assigned'] == None: + if params['assigned'] is None: if params['mine'] == True: assigned = [self._get_user_id()] else: @@ -178,7 +178,7 @@ class List (libbe.command.Command): for i in range(len(assigned)): if assigned[i] == '-': assigned[i] = params['user-id'] - if params['extra-strings'] == None: + if params['extra-strings'] is None: extra_strings_regexps = [] else: extra_strings_regexps = [re.compile(x) diff --git a/libbe/command/merge.py b/libbe/command/merge.py index 4ee67cf..5100803 100644 --- a/libbe/command/merge.py +++ b/libbe/command/merge.py @@ -170,7 +170,7 @@ class Merge (libbe.command.Command): for comment in newCommTree.traverse(): # all descendant comments comment.bug = bugA # uuids must be unique in storage - if comment.alt_id == None: + if comment.alt_id is None: comment.storage = None comment.alt_id = comment.uuid comment.storage = storage diff --git a/libbe/command/new.py b/libbe/command/new.py index 4a0288b..6a5ac1f 100644 --- a/libbe/command/new.py +++ b/libbe/command/new.py @@ -126,19 +126,19 @@ class New (libbe.command.Command): 'Ambiguous bugdir {}'.format(sorted(bugdirs.values()))) storage.writeable = False bug = bugdir.new_bug(summary=summary.strip()) - if params['creator'] != None: + if params['creator'] is not None: bug.creator = params['creator'] else: bug.creator = self._get_user_id() - if params['reporter'] != None: + if params['reporter'] is not None: bug.reporter = params['reporter'] else: bug.reporter = bug.creator - if params['assigned'] != None: + if params['assigned'] is not None: bug.assigned = _parse_assigned(self, params['assigned']) - if params['status'] != None: + if params['status'] is not None: bug.status = params['status'] - if params['severity'] != None: + if params['severity'] is not None: bug.severity = params['severity'] storage.writeable = True bug.save() diff --git a/libbe/command/serve_commands.py b/libbe/command/serve_commands.py index dbdb76b..1541d12 100644 --- a/libbe/command/serve_commands.py +++ b/libbe/command/serve_commands.py @@ -202,7 +202,7 @@ if libbe.TESTING: ('Content-Type', 'application/octet-stream' ) in self.response_headers, self.response_headers) - self.assertTrue(self.exc_info == None, self.exc_info) + self.assertTrue(self.exc_info is None, self.exc_info) # TODO: integration tests on ServeCommands? unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) diff --git a/libbe/command/set.py b/libbe/command/set.py index 9ec7e2c..698e657 100644 --- a/libbe/command/set.py +++ b/libbe/command/set.py @@ -83,7 +83,7 @@ class Set (libbe.command.Command): else: raise libbe.command.UserError( 'Ambiguous bugdir {}'.format(sorted(bugdirs.values()))) - if params['setting'] == None: + if params['setting'] is None: keys = bugdir.settings_properties keys.sort() for key in keys: @@ -94,7 +94,7 @@ class Set (libbe.command.Command): msg += 'Allowed settings:\n ' msg += '\n '.join(bugdir.settings_properties) raise libbe.command.UserError(msg) - if params['value'] == None: + if params['value'] is None: print(_value_string(bugdir, params['setting'])) else: if params['value'] == 'none': @@ -181,7 +181,7 @@ def get_bugdir_settings(): lines = dstr.split('\n') while lines[0].startswith('This property defaults to') == False: lines.pop(0) - assert len(lines) != None, \ + assert len(lines) is not None, \ 'Unexpected vcs_name docstring:\n "%s"' % dstr lines.insert( 0, 'The name of the revision control system to use.\n') diff --git a/libbe/command/show.py b/libbe/command/show.py index c08fd1f..2e7d59e 100644 --- a/libbe/command/show.py +++ b/libbe/command/show.py @@ -166,7 +166,7 @@ def _xml_footer(): return ['</be-xml>'] def output(bugdirs, ids, encoding, as_xml=True, with_comments=True): - if ids == None or len(ids) == 0: + if ids is None or len(ids) == 0: ids = [] for bugdir in list(bugdirs.values()): bugdir.load_all_bugs() diff --git a/libbe/command/subscribe.py b/libbe/command/subscribe.py index 45cd0dd..b6f9cf0 100644 --- a/libbe/command/subscribe.py +++ b/libbe/command/subscribe.py @@ -127,17 +127,17 @@ class Subscribe (libbe.command.Command): if params['list-all'] == True: assert len(params['id']) == 0, params['id'] subscriber = params['subscriber'] - if subscriber == None: + if subscriber is None: subscriber = self._get_user_id() if params['unsubscribe'] == True: - if params['servers'] == None: + if params['servers'] is None: params['servers'] = 'INVALID' - if params['types'] == None: + if params['types'] is None: params['types'] = 'INVALID' else: - if params['servers'] == None: + if params['servers'] is None: params['servers'] = '*' - if params['types'] == None: + if params['types'] is None: params['types'] = 'all' servers = params['servers'].split(',') types = params['types'].split(',') @@ -247,7 +247,7 @@ def _get_subscriber(extra_strings, subscriber, type_root): def subscribe(extra_strings, subscriber, types, servers, type_root): args = _get_subscriber(extra_strings, subscriber, type_root) - if args == None: # no match + if args is None: # no match extra_strings.append(_generate_string(subscriber, types, servers)) return extra_strings # Alter matched string @@ -270,7 +270,7 @@ def subscribe(extra_strings, subscriber, types, servers, type_root): def unsubscribe(extra_strings, subscriber, types, servers, type_root): args = _get_subscriber(extra_strings, subscriber, type_root) - if args == None: # no match + if args is None: # no match return extra_strings # pass # Remove matched string i,s,ts,srvs = args diff --git a/libbe/command/tag.py b/libbe/command/tag.py index 51e2abe..bbffe09 100644 --- a/libbe/command/tag.py +++ b/libbe/command/tag.py @@ -104,9 +104,9 @@ class Tag (libbe.command.Command): ]) def _run(self, **params): - if params['id'] == None and params['list'] == False: + if params['id'] is None and params['list'] == False: raise libbe.command.UserError('Please specify a bug id.') - if params['id'] != None and params['list'] == True: + if params['id'] is not None and params['list'] == True: raise libbe.command.UserError( 'Do not specify a bug id with the --list option.') bugdirs = self._get_bugdirs() diff --git a/libbe/command/target.py b/libbe/command/target.py index b13647e..eb11c11 100644 --- a/libbe/command/target.py +++ b/libbe/command/target.py @@ -90,10 +90,10 @@ class Target (libbe.command.Command): def _run(self, **params): if params['resolve'] == False: - if params['id'] == None: + if params['id'] is None: raise libbe.command.UserError('Please specify a bug id.') else: - if params['target'] != None: + if params['target'] is not None: raise libbe.command.UserError('Too many arguments') params['target'] = params.pop('id') bugdirs = self._get_bugdirs() @@ -106,7 +106,7 @@ class Target (libbe.command.Command): raise libbe.command.UserError( 'Ambiguous bugdir {}'.format(sorted(bugdirs.values()))) bug = bug_from_target_summary(bugdirs, bugdir, params['target']) - if bug == None: + if bug is None: print('No target assigned.', file=self.stdout) else: print(bug.id.long_user(), file=self.stdout) @@ -114,9 +114,9 @@ class Target (libbe.command.Command): bugdir,bug,comment = ( libbe.command.util.bugdir_bug_comment_from_user_id( bugdirs, params['id'])) - if params['target'] == None: + if params['target'] is None: target = bug_target(bugdirs, bug) - if target == None: + if target is None: print('No target assigned.', file=self.stdout) else: print(target.summary, file=self.stdout) @@ -157,8 +157,8 @@ by UUID), try """ def bug_from_target_summary(bugdirs, bugdir, summary=None): - if summary == None: - if bugdir.target == None: + if summary is None: + if bugdir.target is None: return None else: return bugdir.bug_from_uuid(bugdir.target) @@ -196,7 +196,7 @@ def remove_target(bugdirs, bug): def add_target(bugdirs, bugdir, bug, summary): target = bug_from_target_summary(bugdirs, bugdir, summary) - if target == None: + if target is None: target = bugdir.new_bug(summary=summary) target.severity = 'target' libbe.command.depend.add_block(target, bug) diff --git a/libbe/command/util.py b/libbe/command/util.py index 49f3490..632e22c 100644 --- a/libbe/command/util.py +++ b/libbe/command/util.py @@ -38,7 +38,7 @@ def complete_command(command, argument, fragment=None): def comp_path(fragment=None): """List possible path completions for fragment.""" - if fragment == None: + if fragment is None: fragment = '.' comps = glob.glob(fragment+'*') + glob.glob(fragment+'/*') if len(comps) == 1 and os.path.isdir(comps[0]): @@ -64,14 +64,14 @@ def assignees(bugdirs): for bugdir in list(bugdirs.values()): bugdir.load_all_bugs() ret.update(set([bug.assigned for bug in bugdir - if bug.assigned != None])) + if bug.assigned is not None])) return list(ret) def complete_assigned(command, argument, fragment=None): return assignees(command._get_bugdirs()) def complete_extra_strings(command, argument, fragment=None): - if fragment == None: + if fragment is None: return [] return [fragment] @@ -88,7 +88,7 @@ def complete_bug_comment_id(command, argument, fragment=None, import libbe.bugdir import libbe.util.id bugdirs = command._get_bugdirs() - if fragment == None or len(fragment) == 0: + if fragment is None or len(fragment) == 0: fragment = '/' try: p = libbe.util.id.parse_user(bugdirs, fragment) @@ -101,7 +101,7 @@ def complete_bug_comment_id(command, argument, fragment=None, except libbe.util.id.NoIDMatches: return [] except libbe.util.id.MultipleIDMatches as e: - if e.common == None: + if e.common is None: # choose among bugdirs return e.matches common = e.common @@ -109,7 +109,7 @@ def complete_bug_comment_id(command, argument, fragment=None, root,residual = libbe.util.id.residual(common, fragment) p = libbe.util.id.parse_user(bugdirs, e.common) bug = None - if matches == None: # fragment was complete, get a list of children uuids + if matches is None: # fragment was complete, get a list of children uuids if p['type'] == 'bugdir': bugdir = bugdirs[p['bugdir']] matches = bugdir.uuids() @@ -131,11 +131,11 @@ def complete_bug_comment_id(command, argument, fragment=None, if comments == False: return[fragment] bugdir = bugdirs[p['bugdir']] - if bug == None: + if bug is None: bug = bugdir.bug_from_uuid(p['bug']) child_fn = bug.comment_from_uuid elif p['type'] == 'comment': - assert matches == None, matches + assert matches is None, matches return [fragment] possible = [] common += '/' @@ -180,7 +180,7 @@ def select_values(string, possible_values, name="unkown"): ['abc', 'def', 'hij'] """ possible_values = list(possible_values) # don't alter the original - if string == None: + if string is None: pass elif string.startswith('-'): blacklisted_values = set(string[1:].split(',')) |