Beispiel #1
0
def getPlugins(repo, store):
	"""
	retrieve and store plugins from repository

	@param repo (list): repository dictionaries
	@param store (Store): TiddlyWeb store
	@return (bool): success
	"""
	if repo["type"] == "TiddlyWiki":
		try:
			html = urlopen(repo["URI"]).read() # TODO: deferred processing?!
			log.append("STATUS: retrieved repository '%s' (%s)" % (repo["name"], repo["URI"]))
		except IOError:
			log.append("ERROR: could not process repository '%s'" % repo["name"])
			return False
		bag = Bag(repo["name"])
		tw = TiddlyWiki(html)
		tw.convertStoreFormat()
		plugins = tw.getPluginTiddlers(repo)
		empty = "<html><body><div id='storeArea'>\n</div></body></html>" # XXX: ugly hack; cf. tiddlywiki.TiddlyWiki.getPluginTiddlers()
		if plugins != empty:
			savePlugins(store, bag)
			import_wiki(store, plugins, bag.name)
			return True
		else:
			log.append("WARNING: repository '%s' does not contain any plugins" % repo["name"])
			return False
	elif repo["type"] == "SVN":
		bag = Bag(repo["name"])
		svn = DirScraper(repo["URI"])
		try:
			plugins = svn.getPlugins("./", True)
			log.append("STATUS: retrieved repository '%s' (%s)" % (repo["name"], repo["URI"]))
		except IOError:
			log.append("ERROR: could not process repository '%s'" % repo["name"])
			return False
		if plugins:
			savePlugins(store, bag)
			for plugin in plugins:
				plugin.bag = bag.name
				store.put(plugin)
			return True
		else:
			log.append("WARNING: repository '%s' contains no plugins" % repo["name"])
			return False
	else:
		pass # XXX: TBD
Beispiel #2
0
 def as_bag(self, bag, input_string):
     """
     Turn a wiki into a bunch of tiddlers
     stored in the bag.
     """
     try:
         from tiddlyweb.importer import import_wiki
         return import_wiki(self.environ['tiddlyweb.store'], input_string, bag.name)
     except ImportError:
         raise NoSerializationError