Commit 0c3c21f3 authored by Tristan Gingold's avatar Tristan Gingold

makefile.py: simplify code.

parent d08cfef6
......@@ -150,23 +150,16 @@ class ToolMakefile(object):
self.writeln(tmp)
def initialize(self):
"""Open the Makefile file and print a header if not initialized"""
if not self._initialized:
if os.path.exists(self._filename):
if os.path.isfile(self._filename):
os.remove(self._filename)
elif os.path.isdir(self._filename):
os.rmdir(self._filename)
"""Open the Makefile file and print a header"""
if os.path.exists(self._filename):
os.remove(self._filename)
self._file = open(self._filename, "a+")
self._initialized = True
self.writeln("########################################")
self.writeln("# This file was generated by hdlmake #")
self.writeln("# http://ohwr.org/projects/hdl-make/ #")
self.writeln("########################################")
self.writeln()
elif not self._file:
self._file = open(self._filename, "a+")
self._file = open(self._filename, "w")
self.writeln("########################################")
self.writeln("# This file was generated by hdlmake #")
self.writeln("# http://ohwr.org/projects/hdl-make/ #")
self.writeln("########################################")
self.writeln()
def makefile_close(self):
self._file.close()
......@@ -175,6 +168,7 @@ class ToolMakefile(object):
def write(self, line=None):
"""Write a string in the manifest, no new line"""
if not self._initialized:
self._initialized = True
self.initialize()
if shell.check_windows():
self._file.write(line.replace('\\"', '"'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment