commit:     1bf062247723f546500c59f60c8869c1b30a4e23
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 17:36:20 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 17:36:20 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1bf06224

reposconf.py: Adds check to write all ovelays to blank file

If a user has a blank repos.conf file then a check should be
make to ensure that the user has all his/her installed overlays
written to that repos.conf file.

---
 layman/config_modules/reposconf/reposconf.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/layman/config_modules/reposconf/reposconf.py 
b/layman/config_modules/reposconf/reposconf.py
index 344c779..864e86b 100644
--- a/layman/config_modules/reposconf/reposconf.py
+++ b/layman/config_modules/reposconf/reposconf.py
@@ -109,7 +109,7 @@ class ConfigHandler:
         '''
         self.repo_conf.remove_section(overlay.name)
 
-        return self.write()
+        return self.write(delete=overlay.name)
 
 
     def disable(self, overlay):
@@ -162,7 +162,7 @@ class ConfigHandler:
         return self.write()
 
 
-    def write(self, disable=None):
+    def write(self, delete=None, disable=None):
         '''
         Writes changes from ConfigParser to 
/etc/portage/repos.conf/layman.conf.
 
@@ -171,6 +171,12 @@ class ConfigHandler:
         '''
         try:
             with fileopen(self.path, 'w') as laymanconf:
+                # If the repos.conf is empty check to see if we can write
+                # all the overlays to the file.
+                if not self.repo_conf.sections():
+                    for i in self.overlays:
+                        if not i == delete:
+                            self.add(self.overlays[i])
                 self.repo_conf.write(laymanconf)
             if disable:
                 # comments out section header of the overlay.

Reply via email to