Ejemplo n.º 1
0
def save_path(site, dir, leaf, create=1):
    filer=basedir.load_first_config(SITE, 'ROX-Filer')

    if filer and os.path.isdir(filer):
        path=basedir.save_config_path(site, dir)
        path=os.path.join(path, leaf)
    else:
        path=choices.save(dir, leaf, create)

    return path
Ejemplo n.º 2
0
def save_path(site, dir, leaf, create=1):
    filer = basedir.load_first_config(SITE, 'ROX-Filer')

    if filer and os.path.isdir(filer):
        path = basedir.save_config_path(site, dir)
        path = os.path.join(path, leaf)
    else:
        path = choices.save(dir, leaf, create)

    return path
Ejemplo n.º 3
0
	def testMigrateNormal(self):
		save = choices.save('Edit', 'Options')
		self.assertEquals(save, '/tmp/choices/Edit/Options')
		file(save, 'w').close()
		choices.migrate('Edit', 'rox.sourceforge.net')

		assert os.path.isfile(
				'/tmp/config/rox.sourceforge.net/Edit/Options')
		assert os.path.islink('/tmp/choices/Edit')

		assert os.path.isfile('/tmp/choices/Edit/Options')
Ejemplo n.º 4
0
	def testFailedMigration(self):
		save = choices.save('Edit', 'Options')
		file(save, 'w').close()
		save2 = basedir.save_config_path('rox.sourceforge.net', 'Edit')
		file(os.path.join(save2, 'Options'), 'w').close()
		old, sys.stderr = sys.stderr, null
		try:
			choices.migrate('Edit', 'rox.sourceforge.net')
		finally:
			sys.stderr = old
		assert os.path.isdir('/tmp/choices/Edit')
		assert os.path.isdir('/tmp/config/rox.sourceforge.net/Edit')
Ejemplo n.º 5
0
    def save(self):
        """Save all option values. Usually called by OptionsBox()."""
        assert self.too_late_for_registrations

        if self.site:
            d = basedir.save_config_path(self.site, self.program)
            path = os.path.join(d, self.leaf)
        else:
            path = choices.save(self.program, self.leaf)
        if not path:
            return  # Saving is disabled

        from xml.dom.minidom import Document
        doc = Document()
        root = doc.createElement('Options')
        doc.appendChild(root)

        for option in self:
            if option.store:
                option._to_xml(root)

        stream = open(path, 'w')
        doc.writexml(stream)
        stream.close()
Ejemplo n.º 6
0
	def save(self):
		"""Save all option values. Usually called by OptionsBox()."""
		assert self.too_late_for_registrations

		if self.site:
			d = basedir.save_config_path(self.site, self.program)
			path = os.path.join(d, self.leaf)
		else:
			path = choices.save(self.program, self.leaf)
		if not path:
			return	# Saving is disabled

		from xml.dom.minidom import Document
		doc = Document()
		root = doc.createElement('Options')
		doc.appendChild(root)

		for option in self:
			if option.store:
				option._to_xml(root)

		stream = open(path, 'w')
		doc.writexml(stream)
		stream.close()