add spec --generate option for generating specs, fix regression in tree for python 3.x