def FuncParseHistory(): parser = XmlPropertyListParser() ihp = open('/tmp/InstallHistory.plist','r') plist = parser.parse(ihp) ihp.close #Build table columns prettyout = PrettyTable(["Application","Version","Installed By","Install Date"]) #prettyout.padding_width = 1 #For each result in the list add keys to table row for x in plist: prettyout.add_row([x['displayName'],x['displayVersion'],x['processName'],x['date']]) #Print the table to standard output print prettyout
def test_init(self): self.assert_(XmlPropertyListParser())
def parse(self, xmlin): parser = XmlPropertyListParser() return parser.parse(xmlin)
def parse(self, xmlin): parser = XmlPropertyListParser() return parser._parse_using_sax_parser(xmlin)
def parse_using_plist_parser_etree(): """plist_parser with xml.etree.cElementTree""" xmlin = StringIO(bytes) return XmlPropertyListParser()._parse_using_etree(xmlin)
def parse_using_plist_parser_sax(): """plist_parser with SAX parser""" xmlin = StringIO(bytes) return XmlPropertyListParser()._parse_using_sax_parser(xmlin)
def upload(server=None, db=None, appname=None, filedir=None): """uploads the contents of a local Cappuccino application directory as attachments to a CouchDB design document if 'server' is omitted than http://localhost:5984 is assumed if 'filedir' is empty, the pwd is assumed as the Cappuccino app root if 'db' and 'appname' are omitted then the application name is pulled from the CouchDBName and CouchDBAppName in the info.plist file. If those values are not found, CPBundleName is used. spaces are replaced with dashes""" if not server: server = "http://localhost:5984" if not filedir: filedir = os.getcwd() if not os.path.exists(filedir): raise UploadConfigurationError("filedir does not exist") plist_file = filedir + "/Info.plist" plist = None if os.path.exists(plist_file) & os.path.isfile(plist_file): parser = XmlPropertyListParser() stream = open(plist_file) try: plist = parser.parse(stream) finally: stream.close() plist_couch_db_name = None plist_couch_db_app_name = None plist_cp_bundle_name = None if plist: plist_couch_db_name = plist["CouchDBName"] plist_couch_db_app_name = plist["CouchDBAppName"] plist_cp_bundle_name = plist["CPBundleName"] if not db: if plist_couch_db_name: db = plist_couch_db_name elif plist_cp_bundle_name: db = plist_cp_bundle_name if not db: raise UploadConfigurationError("no db specified") if not appname: if plist_couch_db_app_name: appname = plist_couch_db_app_name elif plist_cp_bundle_name: appname = plist_cp_bundle_name if not appname: raise UploadConfigurationError("no appname specified") app_path = "/" + db + "/_design/" + appname app_url = server + app_path app_doc = "_design/" + appname print "server = " + server print "appname = " + appname print "db = " + db print "filedir = " + filedir print "app_url = " + app_url def is_visible_file(x): return os.path.isfile(x) & (x[0] <> ".") file_list = filter(is_visible_file, os.listdir(filedir)) print file_list mimetypes.init() mimetypes.add_type("application/javascript",".j") mimetypes.add_type("text/xml",".plist") def mime(x): return mimetypes.types_map[os.path.splitext(x)[1]] mime_list = map(mime,file_list) print mime_list c = Couch() for i in range(len(file_list)): print c.get_doc(db,app_doc)