Commits

Henrik Stuart committed 791f04f

cmdutil: update replace logic for metadata configuration files

Review: Sune Foldager

  • Participants
  • Parent commits 0776d39

Comments (0)

Files changed (1)

repoman/cmdutil.py

     return data.replace('{GMD}', f.gmd_path)
 
 def update_configurations(ui, f):
-    header = '\n########### DO NOT EDIT BELOW THIS LINE ###########\n'
-    footer = '########### DO NOT EDIT ABOVE THIS LINE ###########\n'
+    header = '########### DO NOT EDIT BELOW THIS LINE ###########'
+    footer = '########### DO NOT EDIT ABOVE THIS LINE ###########'
 
     modconfig = f.module_configurations
     for mod in f:
         with codecs.open(modconfig[mod], 'rb', 'utf-8') as fh:
             data = _parse_configuration(fh.read(), f)
 
-        data = header + data + footer
+        data = '\n%s\n%s\n%s\n' % (header, data, footer)
 
         repo = f[mod]
         try:
                 origdata = fh.read()
 
         idx1 = origdata.find(header)
-        if idx1 == -1:
-            idx1 = origdata.find(header[1:])
-        idx2 = origdata.find(footer)
+        idx2 = origdata.find(footer, idx1)
         if idx1 != -1 and idx2 != -1:
             origdata = origdata[:idx1] + origdata[idx2 + len(footer):]