old_contents: #!/usr/bin/env python
  
  """
  Creates or regenerates a Makefile with special planex-init comments
  """
  
  import os
  import logging
  
  MAKEFILE_PATH = "/usr/share/planex"
  
  log = logging.getLogger(__name__)
  logging.basicConfig(level=logging.ERROR)
  
  
  def create_makefile():
      """ Checks if a Makefile exists with special planex-init comments in it.
      If not, it creates or regenerates the Makefile while preserving its
      existing contents.
      """
      name = "Makefile"
  
      firstline = "# Start generated by planex-init\n"
      autogen = "include %s/Makefile.rules\n" % (MAKEFILE_PATH)
      endline = "# End generated by planex-init\n"
  
      if not os.path.exists(name):
          log.debug("Creating Makefile")
          with open(name, 'w') as h:
              h.write(firstline)
              h.write(autogen)
              h.write(endline)
          return
  
      with open(name, 'r') as h:
          lines = h.readlines()
  
      try:
          s = lines.index(firstline)
          e = lines.index(endline)
  
          lines = lines[:s+1] + [autogen] + lines[e:]
      except ValueError:
          log.error("Couldn't find planex-init autogenerated stanza in Makefile")
  
      with open(name, 'w') as h:
          h.writelines(lines)
  
  
  def main():
      create_makefile()
  
  if __name__ == "__main__":
      main()
  
new_contents: #!/usr/bin/env python
  
  """
  Creates or regenerates a Makefile with special planex-init comments
  """
  
  import os
  import logging
  
  MAKEFILE_PATH = "/usr/share/planex"
  
  log = logging.getLogger(__name__)
  logging.basicConfig(level=logging.ERROR)
  
  
  def create_makefile():
      """ Checks if a Makefile exists with special planex-init comments in it.
      If not, it creates or regenerates the Makefile while preserving its
      existing contents.
      """
      name = "Makefile"
  
      firstline = "# Start generated by planex-init\n"
      autogen = "include %s/Makefile.rules\n" % (MAKEFILE_PATH)
      endline = "# End generated by planex-init\n"
  
      if not os.path.exists(name):
          log.debug("Creating Makefile")
          with open(name, 'w') as makefile:
              makefile.write(firstline)
              makefile.write(autogen)
              makefile.write(endline)
          return
  
      with open(name, 'r') as makefile:
          lines = makefile.readlines()
  
      try:
          start = lines.index(firstline)
          end = lines.index(endline)
          lines = lines[:start+1] + [autogen] + lines[end:]
  
      except ValueError:
          log.error("Couldn't find planex-init autogenerated stanza in Makefile")
  
      with open(name, 'w') as makefile:
          makefile.writelines(lines)
  
  
  def main():
      """
      Main entry point
      """
      create_makefile()
  
  if __name__ == "__main__":
      main()
  
subject: Fix pylint warnings