LeMyst / WikibaseIntegrator

A Python module to manipulate data on a Wikibase instance (like Wikidata) through the MediaWiki Wikibase API and the Wikibase SPARQL endpoint.
MIT License
67 stars 12 forks source link

Rewrite user-agent handling #638

Closed dpriskorn closed 7 months ago

dpriskorn commented 7 months ago

Hi, I wrote https://github.com/dpriskorn/LexDanNet today and it complained about user agent.

I really dislike the dictionary thing because it is not easy to handle with classes.

I want helper methods instead to set all the necessary parameters.

Perhaps on the Login object which could be renamed to WikibaseConnection?

LeMyst commented 7 months ago

Hello @dpriskorn ,

I'm not against having an helper method for this, but did you test to put the wbi_config['...'] = '...' just below the imports, outside any class/method ?

from wikibaseintegrator import wbi_login
from wikibaseintegrator.wbi_config import config as wbi_config

wbi_config['MEDIAWIKI_API_URL'] = 'http://localhost/api.php'

class SomeThird():
    def main(self):
        # This part fail because MEDIAWIKI_API_URL is not a valid URL
        wbi_login.Login(user='adminqsdsqdsqdsqd', password='change-this-password')

third = SomeThird()
third.main()
dpriskorn commented 7 months ago

Yes, that solved it.

LeMyst commented 7 months ago

Yes, that solved it.

Thanks, but does this solution is good for you?

dpriskorn commented 7 months ago

yes, lets keep it like this for now