<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wikidata(self, title, wikibase=None):
 """ Returns Wikidata query string """

        self.domain = 'www.wikidata.org'
        self.uri = self.wiki_uri(self.domain)

        query = self.WIKIDATA.substitute(
            WIKI=self.uri,
            ENDPOINT=self.endpoint,
            LANG=self.variant or self.lang,
            PROPS="aliases|info|claims|descriptions|labels|sitelinks")

        if wikibase:
            query += "&ids=%s" % wikibase
        elif title:
            title = safequote(title)
            query += "&sites=%swiki" % self.lang
            query += "&titles=%s" % title

        self.set_status('wikidata', wikibase or title)

        return query