A two dimensional gauge theory is canonically associated to every Drinfeld
double. For particular doubles, the theory turns out to be e.g. the ordinar
y Yang-Mills theory, the G/G gauged WZNW model or the Poisson a-model that
underlies the Kontsevich quantization formula. We calculate the arbitrary g
enus partition function of the latter. The result is the q-deformation of t
he ordinary Yang-Mills partition function in the sense that the series over
the weights is replaced by the same series over the q-weights. For q equal
to a root of unity the series acquires the affine Weyl symmetry and its tr
uncation to the alcove coincides with the Verlinde formula.