aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/diff.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/diff.py')
-rw-r--r--libbe/diff.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/libbe/diff.py b/libbe/diff.py
index c2f9c8e..fe83881 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -32,6 +32,12 @@ from libbe.storage.util.settings_object import setting_name_to_attr_name
from libbe.util.utility import time_to_str
+# https://stackoverflow.com/a/56719588/164233
+def cmp(a, b):
+ return (int(a) > int(b)) - (int(a) < int(b))
+
+
+
class SubscriptionType (libbe.util.tree.Tree):
"""Trees of subscription types to allow users to select exactly what
notifications they want to subscribe to.
@@ -132,7 +138,7 @@ def subscriptions_from_string(string=None, subscription_sep=',', id_sep=':'):
...
ValueError: Invalid subscription "DIR::new", should be ID:TYPE
"""
- if string == None:
+ if string is None:
return [Subscription(BUGDIR_ID, BUGDIR_TYPE_ALL)]
subscriptions = []
for subscription in string.split(','):
@@ -196,7 +202,7 @@ class DiffTree (libbe.util.tree.Tree):
self.masked = masked
def paths(self, parent_path=None):
paths = []
- if parent_path == None:
+ if parent_path is None:
path = self.name
else:
path = '%s/%s' % (parent_path, self.name)
@@ -225,16 +231,16 @@ class DiffTree (libbe.util.tree.Tree):
raise KeyError('%s points to child not in %s' % (names, [c.name for c in self]))
def report_string(self):
report = self.report()
- if report == None:
+ if report is None:
return ''
return '\n'.join(report)
def report(self, root=None, parent=None, depth=0):
- if root == None:
+ if root is None:
root = self.make_root()
- if self.masked == True:
+ if self.masked:
return root
data_part = self.data_part(depth)
- if self.requires_children == True \
+ if self.requires_children \
and len([c for c in self if c.masked == False]) == 0:
pass
else:
@@ -250,12 +256,12 @@ class DiffTree (libbe.util.tree.Tree):
if data_part != None:
root.append(data_part)
def data_part(self, depth, indent=True):
- if self.data == None:
+ if self.data is None:
return None
if hasattr(self, '_cached_data_part'):
return self._cached_data_part
data_part = self.data_part_fn(self.data)
- if indent == True:
+ if indent:
data_part_lines = data_part.splitlines()
indent = ' '*(depth)
line_sep = '\n'+indent
@@ -574,11 +580,11 @@ class Diff (object):
can pass in a DiffTree subclass via diff_tree to override the
default report assembly process.
"""
- if allow_cached == True \
+ if allow_cached \
and hasattr(self, '_cached_full_report') \
and diff_tree == self._cached_full_report_diff_tree:
return self._sub_report(subscriptions)
- if subscriptions == None:
+ if subscriptions is None:
subscriptions = [Subscription(BUGDIR_ID, BUGDIR_TYPE_ALL)]
bugdir_settings = sorted(self.new_bugdir.settings_properties)
root = diff_tree('bugdir')