aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-30 00:04:40 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-30 00:04:40 +0100
commit13f0256e7921a18a6f90c30226dd733db05bed25 (patch)
treeb223a703c74726d19d6e0b8bb563e8f96a9e964f
parentb638466e6a6ada7478758cf740c89650d0f70f59 (diff)
downloadbugseverywhere-13f0256e7921a18a6f90c30226dd733db05bed25.tar.gz
More cleanups.
-rw-r--r--libbe/bugdir.py50
-rw-r--r--libbe/command/base.py2
-rw-r--r--libbe/command/init.py4
3 files changed, 27 insertions, 29 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index 9ab8d69..a5d384d 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -47,7 +47,7 @@ import libbe.bug as bug
import libbe.util.utility as utility
import libbe.util.id
-if libbe.TESTING == True:
+if libbe.TESTING:
import doctest
import sys
import unittest
@@ -59,7 +59,7 @@ class NoBugMatches(libbe.util.id.NoIDMatches):
def __init__(self, *args, **kwargs):
libbe.util.id.NoIDMatches.__init__(self, *args, **kwargs)
def __str__(self):
- if self.msg == None:
+ if self.msg is None:
return 'No bug matches %s' % self.id
return self.msg
@@ -167,13 +167,13 @@ class BugDir (list, settings_object.SavedSettingsObject):
self.storage = storage
self.id = libbe.util.id.ID(self, 'bugdir')
self.uuid = uuid
- if from_storage == True:
- if self.uuid == None:
+ if from_storage:
+ if self.uuid is None:
self.uuid = [c for c in self.storage.children()
if c != 'version'][0]
self.load_settings()
else:
- if self.uuid == None:
+ if self.uuid is None:
self.uuid = libbe.util.id.uuid_gen()
if self.storage != None and self.storage.is_writeable():
self.save()
@@ -181,7 +181,7 @@ class BugDir (list, settings_object.SavedSettingsObject):
# methods for saving/loading/accessing settings and properties.
def load_settings(self, settings_mapfile=None):
- if settings_mapfile == None:
+ if settings_mapfile is None:
settings_mapfile = \
self.storage.get(self.id.storage('settings'), default='{}\n')
try:
@@ -210,7 +210,7 @@ class BugDir (list, settings_object.SavedSettingsObject):
Save any loaded contents to storage. Because of lazy loading
of bugs and comments, this is actually not too inefficient.
- However, if self.storage.is_writeable() == True, then any
+ However, if self.storage.is_writeable(), then any
changes are automatically written to storage as soon as they
happen, so calling this method will just waste time (unless
something else has been messing with your stored files).
@@ -227,7 +227,7 @@ class BugDir (list, settings_object.SavedSettingsObject):
# methods for managing bugs
def uuids(self, use_cached_disk_uuids=True):
- if use_cached_disk_uuids==False or not hasattr(self, '_uuids_cache'):
+ if not use_cached_disk_uuids or not hasattr(self, '_uuids_cache'):
self._refresh_uuid_cache()
self._uuids_cache = self._uuids_cache.union([bug.uuid for bug in self])
return self._uuids_cache
@@ -282,7 +282,7 @@ class BugDir (list, settings_object.SavedSettingsObject):
raise NoBugMatches(
uuid, self.uuids(),
'No bug matches %s in %s' % (uuid, self.storage))
- if self._bug_map[uuid] == None:
+ if self._bug_map[uuid] is None:
self._load_bug(uuid)
return self._bug_map[uuid]
@@ -517,7 +517,7 @@ class BugDir (list, settings_object.SavedSettingsObject):
'ignoring unknown tag {0} in {1}'.format(
child.tag, bugdir.tag))
if uuid != self.uuid:
- if not hasattr(self, 'alt_id') or self.alt_id == None:
+ if not hasattr(self, 'alt_id') or self.alt_id is None:
self.alt_id = uuid
self.extra_strings = estrs
@@ -691,22 +691,22 @@ class RevisionedBugDir (BugDir):
self.schanged = self.s.changed
self.r = default_revision
def get(self, *args, **kwargs):
- if not 'revision' in kwargs or kwargs['revision'] == None:
+ if not 'revision' in kwargs or kwargs['revision'] is None:
kwargs['revision'] = self.r
return self.sget(*args, **kwargs)
def ancestors(self, *args, **kwargs):
print('getting ancestors', args, kwargs)
- if not 'revision' in kwargs or kwargs['revision'] == None:
+ if not 'revision' in kwargs or kwargs['revision'] is None:
kwargs['revision'] = self.r
ret = self.sancestors(*args, **kwargs)
print('got ancestors', ret)
return ret
def children(self, *args, **kwargs):
- if not 'revision' in kwargs or kwargs['revision'] == None:
+ if not 'revision' in kwargs or kwargs['revision'] is None:
kwargs['revision'] = self.r
return self.schildren(*args, **kwargs)
def changed(self, *args, **kwargs):
- if not 'revision' in kwargs or kwargs['revision'] == None:
+ if not 'revision' in kwargs or kwargs['revision'] is None:
kwargs['revision'] = self.r
return self.schanged(*args, **kwargs)
rs = RevisionedStorage(s, revision)
@@ -720,7 +720,7 @@ class RevisionedBugDir (BugDir):
return self.storage.changed()
-if libbe.TESTING == True:
+if libbe.TESTING:
class SimpleBugDir (BugDir):
"""
For testing. Set ``memory=True`` for a memory-only bugdir.
@@ -733,12 +733,12 @@ if libbe.TESTING == True:
>>> bugdir.cleanup()
"""
def __init__(self, memory=True, versioned=False):
- if memory == True:
+ if memory:
storage = None
else:
dir = utility.Dir()
self._dir_ref = dir # postpone cleanup since dir.cleanup() removes dir.
- if versioned == False:
+ if not versioned:
storage = libbe.storage.base.Storage(dir.path)
else:
storage = libbe.storage.base.VersionedStorage(dir.path)
@@ -832,7 +832,7 @@ if libbe.TESTING == True:
# self.bugdir.save()
# self.versionTest()
# def testComments(self, sync_with_disk=False):
-# if sync_with_disk == True:
+# if sync_with_disk:
# self.bugdir.set_sync_with_disk(True)
# self.bugdir.new_bug(uuid="a", summary="Ant")
# bug = self.bugdir.bug_from_uuid("a")
@@ -895,9 +895,9 @@ if libbe.TESTING == True:
preexisting bugs.
"""
bugdir = SimpleBugDir(memory=False)
- self.assertTrue(bugdir.storage.is_readable() == True,
+ self.assertTrue(bugdir.storage.is_readable(),
bugdir.storage.is_readable())
- self.assertTrue(bugdir.storage.is_writeable() == True,
+ self.assertTrue(bugdir.storage.is_writeable(),
bugdir.storage.is_writeable())
uuids = sorted([bug.uuid for bug in bugdir])
self.assertTrue(uuids == ['a', 'b'], uuids)
@@ -916,7 +916,7 @@ if libbe.TESTING == True:
preexisting bugs.
"""
bugdir = SimpleBugDir(memory=True)
- self.assertTrue(bugdir.storage == None, bugdir.storage)
+ self.assertTrue(bugdir.storage is None, bugdir.storage)
uuids = sorted([bug.uuid for bug in bugdir])
self.assertTrue(uuids == ['a', 'b'], uuids)
uuids = sorted([bug.uuid for bug in bugdir])
@@ -933,8 +933,8 @@ if libbe.TESTING == True:
# def _get_settings(self, settings_path, for_duplicate_bugdir=False):
# allow_no_storage = not self.storage.path_in_root(settings_path)
-# if allow_no_storage == True:
-# assert for_duplicate_bugdir == True
+# if allow_no_storage:
+# assert for_duplicate_bugdir
# if self.sync_with_disk == False and for_duplicate_bugdir == False:
# # duplicates can ignore this bugdir's .sync_with_disk status
# raise DiskAccessRequired("_get settings")
@@ -947,8 +947,8 @@ if libbe.TESTING == True:
# def _save_settings(self, settings_path, settings,
# for_duplicate_bugdir=False):
# allow_no_storage = not self.storage.path_in_root(settings_path)
-# if allow_no_storage == True:
-# assert for_duplicate_bugdir == True
+# if allow_no_storage:
+# assert for_duplicate_bugdir
# if self.sync_with_disk == False and for_duplicate_bugdir == False:
# # duplicates can ignore this bugdir's .sync_with_disk status
# raise DiskAccessRequired("_save settings")
diff --git a/libbe/command/base.py b/libbe/command/base.py
index 269141f..806d880 100644
--- a/libbe/command/base.py
+++ b/libbe/command/base.py
@@ -492,9 +492,7 @@ class StringInputOutput (InputOutput):
"""
def __init__(self):
stdin = io.StringIO()
- stdin.encoding = 'utf-8'
stdout = io.StringIO()
- stdout.encoding = 'utf-8'
InputOutput.__init__(self, stdin, stdout)
def set_stdin(self, stdin_string):
diff --git a/libbe/command/init.py b/libbe/command/init.py
index 8640ae4..fe85707 100644
--- a/libbe/command/init.py
+++ b/libbe/command/init.py
@@ -38,7 +38,7 @@ class Init (libbe.command.Command):
>>> cmd = Init()
>>> dir = libbe.util.utility.Dir()
- >>> vcs = libbe.storage.vcs.vcs_by_name('None')
+ >>> vcs = libbe.storage.vcs.vcs_by_name(None)
>>> vcs.repo = dir.path
>>> try:
... vcs.connect()
@@ -98,7 +98,7 @@ class Init (libbe.command.Command):
self.ui.storage_callbacks.set_storage(storage)
bd = libbe.bugdir.BugDir(storage, from_storage=False)
self.ui.storage_callbacks.set_bugdirs({bd.uuid: bd})
- if bd.storage.name is not 'None':
+ if bd.storage.name is not None:
print('Using %s for revision control.' % storage.name, file=self.stdout)
else:
print('No revision control detected.', file=self.stdout)