def isContentChecked(self, tagType, tagContent): key = decoder.smart_unicode(tagType) + '||' + decoder.smart_unicode(tagContent) if key in self.CheckTagNames : checked = self.CheckTagNames[ key ] else : self.CheckTagNames[ key ] = 0 checked = 0 return checked
def __get_xmp_metadata(self, dirname, picfile): #xmptag = 'x:xmpmeta' xmptag = 'rdf:RDF' self.get_xmp_dirname = dirname self.get_xmp_picfile = picfile try: f = open(join(dirname,picfile), 'rb') except: path = join(dirname.encode('utf-8'),picfile.encode('utf-8')) path = decoder.smart_unicode(path).encode('utf-8') f = open(path, 'rb') content = f.read() f.close() start = content.find("<" + xmptag) end = content.rfind("</" + xmptag) + 4 + len(xmptag) inner = content[start:end] self.get_xmp_inner = inner """
def onAction( self, action ): #try: # Cancel if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CANCEL and action.getId() in SELECT_ITEM ): array = [] self.close() # Okay if ( self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM ): self.close() # Select or deselect item in list if ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST ): item = self.getControl( TAGS_LIST ).getSelectedItem() pos = self.getControl( TAGS_LIST ).getSelectedPosition() kb = xbmc.Keyboard(item.getLabel2(), _(30623)%( decoder.smart_utf8(item.getLabel())), False) kb.doModal() if (kb.isConfirmed()): item.setLabel2(kb.getText()) MPDB.setTranslatedTagType(decoder.smart_unicode(item.getLabel()), decoder.smart_unicode(item.getLabel2())) self.getControl( TAGS_LIST ).setVisible(False) self.getControl( TAGS_LIST ).setVisible(True)
def onAction( self, action ): #try: # Cancel if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CANCEL and action.getId() in SELECT_ITEM ): arraytrue = [] arrayfalse = [] self.filter (arraytrue,arrayfalse,False) self.close() # Okay if ( self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM ): arraytrue = [] arrayfalse = [] for key, value in self.CheckTagNames.iteritems(): if value == 1: arraytrue.append( key) if value == -1: arrayfalse.append( key) self.filter (arraytrue, arrayfalse, self.bAnd ) self.close() # Match all button if ( action.getId() in SELECT_ITEM and self.getFocusId() == BUTTON_MATCHALL ): self.bAnd = not self.bAnd # Select or deselect item in TagTypes list if ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST ): item = self.getControl( TAGS_LIST ).getSelectedItem() pos = self.getControl( TAGS_LIST ).getSelectedPosition() if self.CurrentlySelectedTagType != self.TagTypes[pos]: self.loadTagContentList(self.TagTypes[pos]) # Select or deselect item in TagContents list if ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_CONTENT_LIST ): item = self.getControl( TAGS_CONTENT_LIST ).getSelectedItem() pos = self.getControl( TAGS_CONTENT_LIST ).getSelectedPosition() if pos != -1 and item != None: checked = item.getProperty("checked") key = decoder.smart_unicode(self.CurrentlySelectedTagType) + '||' + decoder.smart_unicode(item.getLabel2()) if checked == "checkbutton.png": self.checkGUITagContent(item, -1) self.CheckTagNames[ key ] = -1 elif checked == "uncheckbutton.png": self.checkGUITagContent(item, 0) self.CheckTagNames[ key ] = 0 else : self.checkGUITagContent(item, 1) self.CheckTagNames[ key ] = 1 if self.checkedTags == 1: self.getControl( CHECKED_LABEL ).setLabel( _(30611) ) else: self.getControl( CHECKED_LABEL ).setLabel( _(30612)% (self.checkedTags) ) self.getControl( CHECKED_LABEL ).setVisible(False) self.getControl( CHECKED_LABEL ).setVisible(True)
def load_map(self): #google geolocalisation static_url = "http://maps.google.com/maps/api/staticmap?" param_dic = {#location parameters (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html) "center":"", #(required if markers not present) "zoom":self.zoomlevel, # 0 to 21+ (req if no markers #map parameters "size":"640x640", #widthxheight (required) "format":"jpg", #"png8","png","png32","gif","jpg","jpg-baseline" (opt) "maptype":"hybrid", #"roadmap","satellite","hybrid","terrain" (opt) "language":"", #Feature Parameters: "markers" :"color:red|label:P|%s",#(opt) #markers=color:red|label:P|lyon|12%20rue%20madiraa|marseille|Lille #&markers=color:blue|label:P|Australie "path" : "", #(opt) "visible" : "", #(opt) #Reporting Parameters: "sensor" : "false" #is there a gps on system ? (req) } param_dic["markers"]=param_dic["markers"]%self.place request_headers = { 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10' } request = Request(static_url+urlencode(param_dic), None, request_headers) try: urlfile = urlopen(request) except: dialog = xbmcgui.Dialog() dialog.ok('XBMC Network Error', 'Google maps is not reachable') self.close() return extension = urlfile.info().getheader("Content-Type","").split("/")[1] filesize = int(urlfile.info().getheader("Content-Length","")) mappath = xbmc.translatePath(self.DATA_PATH) mapfile = join(self.DATA_PATH,basename(self.picfile).split(".")[0]+"_maps%s."%self.zoomlevel+extension) mapfile = xbmc.translatePath(mapfile) # test existence of path if not os.path.exists(mappath): os.makedirs(mappath) if not isfile(mapfile): #mapfile is not downloaded yet, download it now... try: #f=open(unicode(mapfile, 'utf-8'),"wb") f=open(decoder.smart_unicode(mapfile), "wb") except: try: f=open(decoder.smart_utf8(mapfile), "wb") except: print_exc() #print "GEO Exception: "+mapfile for i in range(1+(filesize/10)): f.write(urlfile.read(10)) self.lbl_info.setLabel(__language__(30221)%(100*(float(i*10)/filesize)))#getting map... (%0.2f%%) urlfile.close() #pDialog.close() try: f.close() except: print_exc() pass self.set_pic(self.picfile) self.set_map(mapfile) self.lbl_info.setLabel(__language__(30222)%int(100*(float(self.zoomlevel)/self.ZMAX)))#Zoom level %s