Commit f52a297b authored by Tristan Gingold's avatar Tristan Gingold

sourcefileset: add more typechecking.

parent 314e9a61
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>. # along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
# #
from .dep_file import File
import logging import logging
class SourceFileSet(set): class SourceFileSet(set):
...@@ -35,16 +36,16 @@ class SourceFileSet(set): ...@@ -35,16 +36,16 @@ class SourceFileSet(set):
def add(self, files): def add(self, files):
"""Add a set of files to the source fileset instance""" """Add a set of files to the source fileset instance"""
if isinstance(files, str): if files is None:
raise RuntimeError("Expected object, not a string")
elif files is None:
logging.debug("Got None as a file.\n Ommiting") logging.debug("Got None as a file.\n Ommiting")
return
if isinstance(files, (SourceFileSet, set)):
for file_aux in files:
super(SourceFileSet, self).add(file_aux)
elif isinstance(files, File):
super(SourceFileSet, self).add(files)
else: else:
try: raise TypeError
for file_aux in files:
super(SourceFileSet, self).add(file_aux)
except TypeError: # single file, not a list
super(SourceFileSet, self).add(files)
def filter(self, filetype): def filter(self, filetype):
"""Method that filters and returns all of the HDL source files """Method that filters and returns all of the HDL source files
......
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