コード例 #1
0
ファイル: Song.py プロジェクト: etel/music-player
	def __setattr__(self, attr, value):
		if getattr(self, "_useDb", False):
			import songdb
			if attr in songdb.Attribs:
				songdb.updateSongAttribValue(self, attr, value)
		# Note that locally stored attribs might get outdated.
		# Thus, in getFast(), those will not be returned for accuracy=1.
		object.__setattr__(self, attr, value)
コード例 #2
0
ファイル: Song.py プロジェクト: damilare/music-player
	def update(self, attr, updateFunc, default=None):
		"updateFunc is supposed to be oldValue->newValue."
		"E.g. you can increment by one or so. While updateFunc is executed, the DB is blocked."
		import songdb
		if getattr(self, "_useDb", False) and attr in songdb.Attribs:
			value = songdb.updateSongAttribValue(self, attr, updateFunc, default=default)
		else:
			value = getattr(self, attr, default)
			value = updateFunc(value)
		# Note that locally stored attribs might get outdated.
		# Thus, in getFast(), those will not be returned for accuracy=1.
		object.__setattr__(self, attr, value)
コード例 #3
0
ファイル: Song.py プロジェクト: MechanisM/music-player
	def update(self, attr, updateFunc, default=None):
		"updateFunc is supposed to be oldValue->newValue."
		"E.g. you can increment by one or so. While updateFunc is executed, the DB is blocked."
		import songdb
		if getattr(self, "_useDb", False) and attr in songdb.Attribs:
			value = songdb.updateSongAttribValue(self, attr, updateFunc, default=default)
		else:
			# Note that we don't use getattr to get the old value for the updateFunc.
			# This is to avoid infinite recursion loops and also because
			# it doesn't exactly match the useDb-case where we don't use getattr
			# but the old value in the DB.
			value = updateFunc(default)
		# Note that locally stored attribs might get outdated.
		# Thus, in getFast(), those will not be returned for accuracy=1.
		object.__setattr__(self, attr, value)
コード例 #4
0
ファイル: Song.py プロジェクト: wzugang/music-player
	def update(self, attr, updateFunc, default=None):
		"updateFunc is supposed to be oldValue->newValue."
		"E.g. you can increment by one or so. While updateFunc is executed, the DB is blocked."
		import songdb
		if getattr(self, "_useDb", False) and attr in songdb.Attribs:
			value = songdb.updateSongAttribValue(self, attr, updateFunc, default=default)
		else:
			# Note that we don't use getattr to get the old value for the updateFunc.
			# This is to avoid infinite recursion loops and also because
			# it doesn't exactly match the useDb-case where we don't use getattr
			# but the old value in the DB.
			value = updateFunc(default)
		# Note that locally stored attribs might get outdated.
		# Thus, in getFast(), those will not be returned for accuracy=1.
		object.__setattr__(self, attr, value)
		self._updateEvent.push()