This might be enough to fix it - I just compare the values against each other rather than doing 4 explicit cases. I call bool() on them first before comparing them as we want a boolean comparison here, and that should work even if you pass None or "" or whatever I guess.
diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py
index 89cef642..d4e52c4d 100644
--- a/aptsources/sourceslist.py
+++ b/aptsources/sourceslist.py
@@ -332,10 +332,10 @@ class SourcesList(object):
for source in sources:
# if there is a repo with the same (type, uri, dist) just add the
# components
- if source.disabled and set(source.comps) == set(comps):
- source.disabled = False
+ if bool(source.disabled) != bool(disabled) and set(source.comps) == set(comps):
+ source.disabled = bool(disabled) return source
- elif not source.disabled:
+ elif bool(disabled) == bool(source.disabled): source.comps = uniq(source.comps + comps) return source
# there isn't any matching source, so create a new line and parse it
This might be enough to fix it - I just compare the values against each other rather than doing 4 explicit cases. I call bool() on them first before comparing them as we want a boolean comparison here, and that should work even if you pass None or "" or whatever I guess.
diff --git a/aptsources/ sourceslist. py b/aptsources/ sourceslist. py sourceslist. py sourceslist. py object) : disabled) != bool(disabled) and set(source.comps) == set(comps):
return source disabled) :
source. comps = uniq(source.comps + comps)
return source
index 89cef642..d4e52c4d 100644
--- a/aptsources/
+++ b/aptsources/
@@ -332,10 +332,10 @@ class SourcesList(
for source in sources:
# if there is a repo with the same (type, uri, dist) just add the
# components
- if source.disabled and set(source.comps) == set(comps):
- source.disabled = False
+ if bool(source.
+ source.disabled = bool(disabled)
- elif not source.disabled:
+ elif bool(disabled) == bool(source.
# there isn't any matching source, so create a new line and parse it