⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediainfo.py

📁 Progra,, das sehr viele Medien formate spielt und sehr bekannt ist.
💻 PY
字号:
#!/usr/bin/env python# -*- coding: iso-8859-15 -*-# metaPackage.py#  #  Author: Laudeci Oliveira <laudeci@gmail.com>#          Rafael Proen莽a   <cypherbios@ubuntu.com># #  This program is free software; you can redistribute it and/or #  modify it under the terms of the GNU General Public License as #  published by the Free Software Foundation; either version 2 of the#  License, or (at your option) any later version.# #  This program is distributed in the hope that it will be useful,#  but WITHOUT ANY WARRANTY; without even the implied warranty of#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#  GNU General Public License for more details.# #  You should have received a copy of the GNU General Public License#  along with this program; if not, write to the Free Software#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307#  USAimport configimport datetimeimport osimport stringimport utilsimport sysimport rfc822import StringIOAOC_VERSION = 'aocversion'DISTRIBUTION = 'distribution'CODENAME = 'codename'ARCHITECTURE = 'architecture'FILE_DATE = 'date'class mediaBase(object):	"""This class is used as a base class to all media information classes."""	def __init__(self, filename="", media="CD1", totalmedia="1"):		util = utils.SystemInfo()				self.fileName = filename		self.aocversion = config.VERSION		self.distro = util.distro		self.codename = util.codename		self.arch = util.architecture		self.date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')		self.media = media		self.totalmedia = totalmedia		self.disklabel = "APTonCD for " + self.distro + ' ' + self.codename + ' - ' + self.arch + ' (' + self.date + ') '			def __get_value(self,source, string, default = ''):		try:			return source[string]		except:			return default				class mediaInfo(mediaBase):	"""This class writes some infomation about the media created."""	def __init__(self, filename=""):		super(mediaInfo,self).__init__(filename)			def __get_value(self,source, string, default = ''):		try:			return source[string]		except:			return default			def infoFromFile(self):		if self.fileName == "":			return False , "File name cannot be empty."				if not os.path.isfile(self.fileName):			return False , "'" + self.fileName + "' doesn't exist."		try:			aptfile=open(self.fileName)			aptdata=aptfile.read()		except IOError, msg:			return False , "File doesn't seems to be valid."				infos = string.split(aptdata,"\n\n")		for info in infos:			if info:				tmp=StringIO.StringIO(info)				p=rfc822.Message(tmp)				self.aocversion = self.__get_value(p,AOC_VERSION)				self.distro = self.__get_value(p,DISTRIBUTION)				self.codename = self.__get_value(p,CODENAME)				self.arch = self.__get_value(p,ARCHITECTURE)				self.date = self.__get_value(p,FILE_DATE)		return True, None	def compare_version(self):		util = utils.SystemInfo()		try :			info = "This media was created in an %s %s system, and is not suitable for your running system (%s %s), please add a compatible APTonCD media created in an system like yours."			if self.distro != util.distro or self.codename != util.codename:				return False, (info % (self.distro,self.codename,util.distro,util.codename)) 			elif self.arch != util.architecture:				return False, (info % (self.codename, self.arch,util.codename, util.architecture))			else:				return True, None		except Exception, ex :			return False, str(ex)										def write(self):		i= 0		try:			mFile = open(self.fileName,"w")			mFile.write("aocversion: " + self.aocversion \			+ "\ndistribution: " + self.distro \			+ "\ncodename: " + self.codename \			+ "\narchitecture: " + self.arch \			+ "\ndate: " + self.date + "\n")			return True		except IOError:			print "The file does not exist"			return False			class aptDiskInfo(mediaBase):	"""This class writes some infomation for apt about de disk source."""	def __init__(self, filename="", media="CD1"):		super(aptDiskInfo,self).__init__(filename, media)		def write(self):		i= 0		try:			mFile = open(self.fileName,"w")			content = self.disklabel + self.media			mFile.write(content)			return True		except IOError:			print "The file does not exist"			return Falseclass aptDiskDefines(mediaBase):	"""This class writes some infomation for apt about de disk source."""	def __init__(self, filename="", media="1", totalmedia="1"):		super(aptDiskDefines,self).__init__(filename, media, totalmedia)		def write(self):		i= 0		try:			mFile = open(self.fileName,"w")			content = "#define DISKNAME  " + self.disklabel \			+ "\n#define TYPE  binary" \			+ "\n#define TYPEbinary  " + self.media \			+ "\n#define ARCH  " + self.arch \			+ "\n#define ARCH" + self.arch + '  ' + self.media \			+ "\n#define DISKNUM  " + self.media \			+ "\n#define DISKNUM" + self.media + '  '  + self.media \			+ "\n#define TOTALNUM  " + self.media \			+ "\n#define TOTALNUM" + self.media + "  " + self.media +"\n"			mFile.write(content)			return True		except IOError:			print "The file does not exist"			return False

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -