=== modified file 'doc/pykhtml.htm' --- doc/pykhtml.htm 2007-04-09 16:59:53 +0000 +++ doc/pykhtml.htm 2007-04-09 17:52:29 +0000 @@ -31,7 +31,7 @@

startEventLoop()

Starts the PyKHTML event loop. PyKHTML works with an asynchronous callback mechanism – a little like Twisted does. Calls to open a new webpage aren't synchronous, as with urllib, for example.

stopEventLoop()

Stop the event loop and hence exit the scraper.

timer(time, func)

Call the given function after the alloted time. The PyKHTML event loop needs to be running.
-

init(display=1, registerExceptionHandler=True, _sleep=1, _stopKWallet=True, _supressQtDebug=True)

Initiate the system if necessary (start Xvfb if it's not running, connect to it, start our program instance). This is called automatically when you create a Browser instance, so you shouldn't have to worry about it unless you want to set some of the values of the arguments. You can specify use of a certain X display by setting the `display` parameter, and can stop pykhtml registering its exception handler (the excepthook function) by setting `registerExceptionHandler` to False.
+

init(display=1, registerExceptionHandler=True, _sleep=1, _stopKWallet=True, _supressQtDebug=True, _stopCookieDialogs=True)

Initiate the system if necessary (start Xvfb if it's not running, connect to it, start our program instance). This is called automatically when you create a Browser instance, so you shouldn't have to worry about it unless you want to set some of the values of the arguments. You can specify use of a certain X display by setting the `display` parameter, and can stop pykhtml registering its exception handler (the excepthook function) by setting `registerExceptionHandler` to False.

excepthook(type, value, trace)

Our exception hook that prints out the traceback, powers down the pykhtml engine, and then exits.

pathSearch(name)

Utility function to search for and get the full path of a file in $PATH.

running(name)

Check whether a process of the given name is running.
=== modified file 'pykhtml/__init__.py' --- pykhtml/__init__.py 2007-04-09 16:59:53 +0000 +++ pykhtml/__init__.py 2007-04-09 17:52:29 +0000 @@ -64,23 +64,30 @@ class _PyKHTMLDialog(kdeui.KMainWindow): pass -def _startGraphicalApplication(): - global application, dialog +def _createApplication(): + global application if not application: - about = kdecore.KAboutData("pykhtml", "PyKHTML", "9.9", "PyKHTML library", kdecore.KAboutData.License_BSD, "(c) 2006, Paul Giannaros") - kdecore.KCmdLineArgs.init([sys.argv[0]], about) + #about = kdecore.KAboutData("pykhtml", "PyKHTML", "0.1", "PyKHTML library", kdecore.KAboutData.License_BSD, "(c) 2006, Paul Giannaros", "PyKHTML library", "http://paul.giannaros.org/pykhtml", "paul@giannaros.org") + #kdecore.KCmdLineArgs.init(sys.argv[:1], about) + kdecore.KCmdLineArgs.init(sys.argv[:1], "pykhtml", "PyKHTML Library", "N") application = kdecore.KApplication() global _config _config = _ConfigurationHandler() # the widget that will host the KHTMLParts + +def _createDialog(): + global dialog if not dialog: + print application.name() dialog = _PyKHTMLDialog(None) + #dialog.setCaption("PyKHTML") application.setMainWidget(dialog) if debugWithGUI: dialog.show() #dialog.layout = qt.QVBoxLayout(dialog) _weDisabledKWallet = False + def _disableKWallet(): wallet = kdecore.KConfig("kwalletrc") wallet.setGroup("Wallet") @@ -93,7 +100,6 @@ # kick kwallet kded = dcopext.DCOPApp("kded", application.dcopClient()) kded.kwalletd.reconfigure() - #print kded.kwalletd.reconfigure() def _reEnableKWallet(): wallet = kdecore.KConfig("kwalletrc") @@ -104,6 +110,15 @@ kded = dcopext.DCOPApp("kded", kdecore.KApplication.kApplication().dcopClient()) print kded.kwalletd.reconfigure() +def _acceptCookiesGlobally(): + jar = kdecore.KConfig("kcookiejarrc") + jar.setGroup("Cookie Policy") + advice = str(jar.readEntry("CookieGlobalAdvice")) + if advice != "Accept": + advice.writeEntry("CookieGlobalAdvice", "Accept") + advice.sync() + + def excepthook(type, value, trace): """ Our exception hook that prints out the traceback, powers down the pykhtml engine, and then exits """ import traceback @@ -119,7 +134,7 @@ else: sys.stderr.write("Qt debug: %s\n" % message) -def init(display=1, registerExceptionHandler=True, _sleep=1, _stopKWallet=True, _supressQtDebug=True): +def init(display=1, registerExceptionHandler=True, _sleep=1, _stopKWallet=True, _supressQtDebug=True, _stopCookieDialogs=True): """ Initiate the system if necessary (start Xvfb if it's not running, connect to it, start our program instance). This is called automatically when you create a Browser instance, so you shouldn't have to worry about it unless you want to set some of the values of the arguments. You can specify use of a certain X display by setting the `display` parameter, and can stop pykhtml registering its exception handler (the [[excepthook]] function) by setting `registerExceptionHandler` to False. """ global initSuccessful if not initSuccessful: @@ -152,9 +167,12 @@ initSuccessful = True if registerExceptionHandler: sys.excepthook = excepthook - _startGraphicalApplication() + _createApplication() if _stopKWallet: _disableKWallet() + if _stopCookieDialogs: + _acceptCookiesGlobally() + _createDialog() @@ -241,9 +259,9 @@ dialog.setCentralWidget(self.part.view()) self.part.show() # disable images, java, and stylesheets so things load quicker - self.part.setJavaEnabled(True) - self.part.setPluginsEnabled(True) - self.part.setAutoloadImages(True) + self.part.setJavaEnabled(False) + self.part.setPluginsEnabled(False) + self.part.setAutoloadImages(False) # sore finger remedy: self.connect = self.part.connect self.disconnect = self.part.disconnect === modified file 'todo.txt' --- todo.txt 2007-03-25 23:58:49 +0000 +++ todo.txt 2007-04-09 17:52:29 +0000 @@ -16,5 +16,4 @@ Bugs: + When having two calls to startEventLoop/stopEventLoop: exceptions.RuntimeError: underlying C/C++ object has been deleted - + First running of KDE-based stuff, Konqueror pops open a dialog about cookies. Write to the config file ourselves