当前位置: 首页>>代码示例>>Python>>正文


Python Connector.type方法代码示例

本文整理汇总了Python中peerdrive.Connector.type方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.type方法的具体用法?Python Connector.type怎么用?Python Connector.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在peerdrive.Connector的用法示例。


在下文中一共展示了Connector.type方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def update(self, updateItem = True):
		# reset everything
		self.__valid = False
		self.__icon = None
		for i in xrange(len(self.__columnDefs)):
			column = self.__columnDefs[i]
			if column.derived():
				self.__columnValues[i] = column.default()

		# determine revision
		needMerge = False
		isReplicated = False
		if self.__doc:
			l = Connector().lookupDoc(self.__doc)
			isReplicated = len(l.stores()) > 1
			revisions = l.revs()
			if len(revisions) == 0:
				return
			elif len(revisions) > 1:
				needMerge = True
			if updateItem:
				self.__item[''].update()

		self.__rev = self.__item[''].rev()

		# stat
		try:
			s = Connector().stat(self.__rev)
		except IOError:
			return
		self.__uti = s.type()
		if needMerge or isReplicated:
			image = QtGui.QImage(Registry().getIcon(s.type()))
			painter = QtGui.QPainter()
			painter.begin(image)
			if needMerge:
				painter.drawImage(0, 16, QtGui.QImage("icons/emblems/split.png"))
			elif isReplicated:
				painter.drawImage(0, 16, QtGui.QImage("icons/emblems/distributed.png"))
			painter.end()
			self.__icon = QtGui.QIcon(QtGui.QPixmap.fromImage(image))
		else:
			self.__icon = QtGui.QIcon(Registry().getIcon(s.type()))

		self.__isFolder = Registry().conformes(self.__uti, "org.peerdrive.folder")
		self.__replacable = not needMerge and not self.__isFolder
		self.__valid = True
		self.__updateColumns(s)
开发者ID:DavidAlphaFox,项目名称:chef-server,代码行数:50,代码来源:folder.py

示例2: load

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
 def load(self, store, rev):
     try:
         stat = Connector().stat(rev, [store])
         self.__typeLabel.setText(Registry().getDisplayString(stat.type()))
         self.__crtimeLabel.setText(str(stat.crtime()))
         self.__mtimeLabel.setText(str(stat.mtime()))
         size = stat.dataSize()
         for a in stat.attachments():
             size += stat.size(a)
         for unit in ["Bytes", "KiB", "MiB", "GiB"]:
             if size < (1 << 10):
                 break
             else:
                 size = size >> 10
         sizeText = "%d %s (%d attachments)" % (size, unit, len(stat.attachments()))
         self.__sizeLabel.setText(sizeText)
         if stat.flags():
             flagsText = reduce(
                 lambda x, y: x + ", " + y, [flagToText.get(f, "<" + str(f) + ">") for f in stat.flags()]
             )
         else:
             flagsText = "-"
         self.__flagsLabel.setText(flagsText)
     except IOError:
         self.__typeLabel.setText("n/a")
         self.__mtimeLabel.setText("n/a")
         self.__sizeLabel.setText("n/a")
开发者ID:peerdrive,项目名称:peerdrive,代码行数:29,代码来源:properties.py

示例3: test_update_keep

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def test_update_keep(self):
		w = self.create(self.store1, "test.format.foo")
		self.assertEqual(w.getType(), "test.format.foo")
		w.commit()
		doc = w.getDoc()
		rev1 = w.getRev()

		with Connector().update(self.store1, doc, rev1) as w:
			self.assertEqual(w.getType(), "test.format.foo")
			w.write('FILE', 'update')
			w.commit()
			rev2 = w.getRev()

		s = Connector().stat(rev1)
		self.assertEqual(s.type(), "test.format.foo")
		s = Connector().stat(rev2)
		self.assertEqual(s.type(), "test.format.foo")
开发者ID:wizzk42,项目名称:peerdrive,代码行数:19,代码来源:tests.py

示例4: test_create

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def test_create(self):
		w = self.create(self.store1, "test.format")
		self.assertEqual(w.getType(), "test.format")
		w.commit()
		doc = w.getDoc()
		rev = w.getRev()

		s = Connector().stat(rev)
		self.assertEqual(s.type(), "test.format")
开发者ID:wizzk42,项目名称:peerdrive,代码行数:11,代码来源:tests.py

示例5: test_fork_keep

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
    def test_fork_keep(self):
        w = self.create(self.store1, "test.format.foo")
        self.assertEqual(w.getType(), "test.format.foo")
        w.commit()
        doc1 = w.getDoc()
        rev1 = w.getRev()

        w = self.fork(self.store1, rev1)
        self.assertEqual(w.getType(), "test.format.foo")
        w.write("FILE", "update")
        w.commit()
        doc2 = w.getDoc()
        rev2 = w.getRev()

        s = Connector().stat(rev1)
        self.assertEqual(s.type(), "test.format.foo")
        s = Connector().stat(rev2)
        self.assertEqual(s.type(), "test.format.foo")
开发者ID:peerdrive,项目名称:peerdrive,代码行数:20,代码来源:tests.py

示例6: test_update_change

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
    def test_update_change(self):
        w = self.create(self.store1, "test.format.foo")
        self.assertEqual(w.getType(), "test.format.foo")
        w.commit()
        doc = w.getDoc()
        rev1 = w.getRev()

        with Connector().update(self.store1, doc, rev1) as w:
            self.assertEqual(w.getType(), "test.format.foo")
            w.write("FILE", "update")
            w.setType("test.format.bar")
            self.assertEqual(w.getType(), "test.format.bar")
            w.commit()
            rev2 = w.getRev()

        s = Connector().stat(rev1)
        self.assertEqual(s.type(), "test.format.foo")
        s = Connector().stat(rev2)
        self.assertEqual(s.type(), "test.format.bar")
开发者ID:peerdrive,项目名称:peerdrive,代码行数:21,代码来源:tests.py

示例7: test_fork_change

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def test_fork_change(self):
		w = self.create(self.store1, "test.format.foo")
		self.assertEqual(w.getType(), "test.format.foo")
		w.commit()
		doc1 = w.getDoc()
		rev1 = w.getRev()

		w = self.fork(self.store1, rev1)
		w.write('FILE', 'update')
		self.assertEqual(w.getType(), "test.format.foo")
		w.setType("test.format.bar")
		self.assertEqual(w.getType(), "test.format.bar")
		w.commit()
		doc2 = w.getDoc()
		rev2 = w.getRev()

		s = Connector().stat(rev1)
		self.assertEqual(s.type(), "test.format.foo")
		s = Connector().stat(rev2)
		self.assertEqual(s.type(), "test.format.bar")
开发者ID:wizzk42,项目名称:peerdrive,代码行数:22,代码来源:tests.py

示例8: __doCreate

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def __doCreate(self, srcStore, srcRev):
		info = Connector().stat(srcRev, [srcStore])
		dstStore = self.store()
		with Connector().create(dstStore, info.type(), info.creator()) as w:
			with Connector().peek(srcStore, srcRev) as r:
				for part in info.parts():
					w.write(part, r.readAll(part))
				w.setFlags(r.getFlags())
			w.commit()
			destDoc = w.getDoc()
			# add link
			self.model().insertLink(struct.DocLink(dstStore, destDoc))
			# save immediately
			self.save()
开发者ID:wizzk42,项目名称:peerdrive,代码行数:16,代码来源:folder.py

示例9: __doCreateFromTemplate

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def __doCreateFromTemplate(self, srcStore, srcRev, name):
		info = Connector().stat(srcRev, [srcStore])
		dstStore = self.store()
		with Connector().create(dstStore, info.type(), info.creator()) as w:
			with Connector().peek(srcStore, srcRev) as r:
				w.set_data('', r.get_data(''))
				for att in info.attachments():
					w.write(att, r.readAll(att))
				w.setFlags(r.stat().flags())
			w.commit("Created from template")
			destDoc = w.getDoc()
			# add link
			self.model().insertLink(connector.DocLink(dstStore, destDoc))
			# save immediately
			self.save("Added '"+name+"' from templates")
开发者ID:DavidAlphaFox,项目名称:chef-server,代码行数:17,代码来源:folder.py

示例10: load

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def load(self, store, rev):
		try:
			stat = Connector().stat(rev, [store])
			self.__typeLabel.setText(Registry().getDisplayString(stat.type()))
			self.__mtimeLabel.setText(str(stat.mtime()))
			size = 0
			for part in stat.parts():
				size += stat.size(part)
			for unit in ['Bytes', 'KiB', 'MiB', 'GiB']:
				if size < (1 << 10):
					break
				else:
					size = size >> 10
			sizeText = "%d %s (%d parts)" % (size, unit, len(stat.parts()))
			self.__sizeLabel.setText(sizeText)
		except IOError:
			self.__typeLabel.setText("n/a")
			self.__mtimeLabel.setText("n/a")
			self.__sizeLabel.setText("n/a")
开发者ID:wizzk42,项目名称:peerdrive,代码行数:21,代码来源:properties.py

示例11: docRead

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
	def docRead(self, readWrite, handle):
		stat = Connector().stat(self.rev())
		uti = stat.type()
		if uti not in FolderModel.UTIs:
			raise TypeError('Unhandled type code: %s' % (uti))
		model = FolderModel(self)

		self.__setModel(model)
		if self.__settings is not None:
			self.__applySettings(self.__settings)

		model.rowsInserted.connect(self._emitSaveNeeded)
		model.rowsRemoved.connect(self._emitSaveNeeded)
		model.dataChanged.connect(self.__dataChanged)
		model.modelReset.connect(self.__dataChanged)
		model.modelReset.connect(lambda: self.selectionChanged.emit())
		self.listView.selectionModel().selectionChanged.connect(
			lambda: self.selectionChanged.emit())

		autoClean = self.metaDataGetField(FolderModel.AUTOCLEAN, False)
		model.doLoad(handle, readWrite, autoClean)
		if model.hasChanged():
			self._emitSaveNeeded()
开发者ID:wizzk42,项目名称:peerdrive,代码行数:25,代码来源:folder.py

示例12: Connector

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import type [as 别名]
if not path:
	s = Connector().stat(link.rev())
	hash = s.hash('_')

	name = hash.encode('hex')
	ext = ""
	with Connector().peek(link.store(), link.rev()) as r:
		annotation = r.getData("/org.peerdrive.annotation")

	# read title
	if "title" in annotation:
		(name, ext) = os.path.splitext(annotation["title"])

	# try to get extension from Registry if title has none
	if not ext:
		extensions = Registry().search(s.type(), "extensions")
		if extensions:
			ext = extensions[0]

	# try to get extension from origin if we don't have one already
	if not ext and ("origin" in annotation):
		ext = os.path.splitext(annotation["origin"])[1]

	# copy out file (if necessary)
	path = os.path.join(tempfile.gettempdir(), hash.encode('hex'), name+ext)
	if not os.path.isdir(os.path.dirname(path)):
		os.makedirs(os.path.dirname(path))
	if not os.path.isfile(path):
		with open(path, "wb") as file:
			with Connector().peek(link.store(), link.rev()) as reader:
				file.write(reader.readAll('_'))
开发者ID:DavidAlphaFox,项目名称:chef-server,代码行数:33,代码来源:public.data.py


注:本文中的peerdrive.Connector.type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。