2013-02-07 16:07:30 -05:00
|
|
|
import os
|
|
|
|
|
|
|
|
def mkdir_noerror(d):
|
|
|
|
try:
|
|
|
|
os.mkdir(d)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2013-02-08 14:25:20 -05:00
|
|
|
def language_by_filename(name):
|
|
|
|
extension = name.rsplit(".")[-1]
|
|
|
|
if extension in ["v", "vh", "vo"]:
|
|
|
|
return "verilog"
|
|
|
|
if extension in ["vhd", "vhdl", "vho"]:
|
|
|
|
return "vhdl"
|
|
|
|
return None
|
|
|
|
|
2014-04-14 11:19:53 -04:00
|
|
|
def write_to_file(filename, contents, force_unix=False):
|
|
|
|
newline = None
|
|
|
|
if force_unix:
|
|
|
|
newline = "\n"
|
|
|
|
f = open(filename, "w", newline=newline)
|
2013-02-07 16:07:30 -05:00
|
|
|
f.write(contents)
|
|
|
|
f.close()
|