def csv(self, csv=None):
"""
Create CSV output from projects
Keyword arguments:
csv -- string, filename to save to OR file object OR None
"""
if len(self.tasks) == 0:
__LOG__.warning('** Empty project : {0}'.format(self.name))
return
if csv is not None:
csv_text = bytes.decode(codecs.BOM_UTF8, 'utf-8')
csv_text += '"State";"Task Name";"Start date";"End date";"Duration";"Resources";\r\n'
else:
csv_text = ''
for t in self.tasks:
c = t.csv()
if c is not None:
if sys.version_info[0] == 2:
try:
c = unicode(c, "utf-8")
except TypeError:
pass
csv_text += c
elif sys.version_info[0] == 3:
csv_text += c
else:
csv_text += c
if csv is not None:
test = False
import io
if sys.version_info[0] == 2:
test = type(csv) == types.FileType or type(csv) == types.InstanceType
elif sys.version_info[0] == 3:
test = type(csv) == io.TextIOWrapper
if test:
csv.write(csv_text)
else:
fileobj = io.open(csv, mode='w', encoding='utf-8')
fileobj.write(csv_text)
fileobj.close()
return csv_text
# MAIN -------------------
评论列表
文章目录