def get_mp_info(self, key): """ Retrieves a dictionary with the information of the MP with the given key Args: key (str): the MP identifier Returns: Dict {}: with the label of the info.glade dialog as key and the content of the label as values. """ mp = self.repository.get(key) data = set_manifest_json(mp) # General data['title_mp'] = data['title'] del data['title'] data['duration'] = readable.time((data['duration']) / 1000) data['size'] = readable.size(data['size']) data['created'] = readable.date(mp.getStartDateAsString(), "%B %d, %Y - %H:%M").replace( ' 0', ' ') if data.has_key('seriestitle'): data['isPartOf'] = data['seriestitle'] # Operations for op, status in data['operations'].iteritems(): data[op] = mediapackage.op_status[status] del data['operations'] # Tracks tracks = [] for track in data['media']['track']: t = {} t[_('Name:')] = track['id'] t[_('Type:')] = track['mimetype'] t[_('Flavor:')] = track['type'] t[_('File:')] = path.split(track['url'])[1] tracks.append(t) if tracks: data['tracks'] = tracks del data['media'] # Catalogs catalogs = [] for catalog in data['metadata']['catalog']: c = {} c[_('Name:')] = catalog['id'] c[_('Flavor:')] = catalog['type'] c[_('Type:')] = catalog['mimetype'] catalogs.append(c) if catalogs: data['catalogs'] = catalogs del data['metadata'] return data
def get_mp_info(self,key): """ Retrieves a dictionary with the information of the MP with the given key Args: key (str): the MP identifier Returns: Dict {}: with the label of the info.glade dialog as key and the content of the label as values. """ mp = self.repository.get(key) data = set_manifest_json(mp) # General data['title_mp'] = data['title'] del data['title'] data['duration'] = readable.time((data['duration'])/1000) data['size'] = readable.size(data['size']) data['created'] = readable.date(mp.getStartDateAsString(), "%B %d, %Y - %H:%M").replace(' 0',' ') if data.has_key('seriestitle'): data['isPartOf'] = data['seriestitle'] # Operations for op,status in data['operations'].iteritems(): data[op] = mediapackage.op_status[status] del data['operations'] # Tracks tracks = [] for track in data['media']['track']: t = {} t[_('Name:')] = track['id'] t[_('Type:')] = track['mimetype'] t[_('Flavor:')] = track['type'] t[_('File:')] = path.split(track['url'])[1] tracks.append(t) if tracks: data['tracks'] = tracks del data['media'] # Catalogs catalogs = [] for catalog in data['metadata']['catalog']: c = {} c[_('Name:')] = catalog['id'] c[_('Flavor:')] = catalog['type'] c[_('Type:')] = catalog['mimetype'] catalogs.append(c) if catalogs: data['catalogs'] = catalogs del data['metadata'] return data
def date_readable(self,column,cell,model,iterador,user_data): """ Generates date readable string from an isoformat datetime. """ novo=readable.date(cell.get_property('text')) cell.set_property('text',novo) return novo
def __init__(self, key, parent=None): if not parent: parent = context.get_mainwindow() size = context.get_mainwindow().get_size() self.wprop = size[0] / 1920.0 self.hprop = size[1] / 1080.0 width = int(size[0] / 3) height = int(size[1] / 2.5) gtk.Window.__init__(self) self.set_title("Mediapackage Info ") self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_default_size(width, height) self.set_modal(True) if parent: self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_transient_for(parent) self.set_destroy_with_parent(True) # INFO mp = context.get_repository().get(key) # Basic info basic, basic_table = self.add_framed_table("Basic") self.add_data(basic_table, "Title:", mp.title) self.add_data(basic_table, "Identifier:", mp.identifier) self.add_data(basic_table, "Folder:", mp.getURI()) self.add_data(basic_table, "Duration:", readable.time(int(mp.getDuration()) / 1000)) self.add_data(basic_table, "Size:", readable.size(mp.getSize())) self.add_data( basic_table, "Recorded on:", readable.date(mp.getStartDateAsString(), "%B %d, %Y - %H:%M").replace(' 0', ' ')) for parameter in mp.metadata_episode: if mp.metadata_episode[parameter] and parameter != 'title': self.add_data(basic_table, parameter.capitalize(), mp.metadata_episode[parameter]) # Operations info ops, ops_table = self.add_framed_table("Operations") self.add_data(ops_table, "Ingest:", mediapackage.op_status[mp.getOpStatus("ingest")]) self.add_data(ops_table, "Zipping:", mediapackage.op_status[mp.getOpStatus("exporttozip")]) self.add_data(ops_table, "Side by Side:", mediapackage.op_status[mp.getOpStatus("sidebyside")]) # Series info if mp.getSeries(): series, series_table = self.add_framed_table("Series") for parameter in mp.metadata_series: self.add_data(series_table, parameter.capitalize(), mp.metadata_series[parameter]) # Track info tracks, track_table = self.add_framed_table("Tracks", True) first = True for track in mp.getTracks(): if not first: self.add_data(track_table, "", "") first = False self.add_data(track_table, "Name:", track.getIdentifier()) self.add_data(track_table, "Flavor:", track.getFlavor()) self.add_data(track_table, "Type:", track.getMimeType()) filename = str(path.split(track.getURI())[1]) self.add_data(track_table, "File:", filename) # Catalog info cats, cat_table = self.add_framed_table("Catalogs", True) first = True for cat in mp.getCatalogs(): if not first: self.add_data(cat_table, "", "") first = False self.add_data(cat_table, "Name:", cat.getIdentifier()) self.add_data(cat_table, "Flavor:", cat.getFlavor()) self.add_data(cat_table, "Type:", cat.getMimeType()) filename = str(path.split(cat.getURI())[1]) self.add_data(cat_table, "File:", filename) #PACKING box = gtk.VBox() box.pack_start(basic, False, True, int(self.hprop * 10)) box.pack_start(ops, False, True, int(self.hprop * 10)) if mp.getSeries(): box.pack_start(series, False, True, int(self.hprop * 10)) box.pack_start(tracks, False, True, int(self.hprop * 10)) box.pack_start(cats, False, True, int(self.hprop * 10)) external_align = gtk.Alignment(0.5, 0, 0.8, 0.8) external_align.add(box) self.add(external_align) #BUTTONS self.buttons = gtk.HButtonBox() self.buttons.set_layout(gtk.BUTTONBOX_SPREAD) self.add_button("Close", self.close) self.add_button("Open Folder", self.openfolder, mp.getURI()) box.pack_end(self.buttons, False, False, int(self.hprop * 10)) self.show_all()
def __init__(self, key, parent = None): if not parent: parent = context.get_mainwindow() size = context.get_mainwindow().get_size() self.wprop = size[0]/1920.0 self.hprop = size[1]/1080.0 width = int(size[0]/3) height = int(size[1]/2.5) gtk.Window.__init__(self) self.set_title(_("Mediapackage Info ")) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_default_size(width,height) self.set_modal(True) if parent: self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_transient_for(parent) self.set_destroy_with_parent(True) # INFO mp = context.get_repository().get(key) # Metadata info data = {} data['title'] = mp.title data['identifier'] = mp.identifier data['folder'] = mp.getURI() data['duration'] = readable.time(int(mp.getDuration())/1000) data['size'] = readable.size(mp.getSize()) data['created'] = readable.date(mp.getStartDateAsString(), "%B %d, %Y - %H:%M").replace(' 0',' ') basic, basic_table = self.add_framed_table(_("Basic")) for item in ORDER_EPISODES: if item in data: self.add_data(basic_table,EPISODE_NAMES[item], data[item]) elif item in mp.metadata_episode: self.add_data(basic_table,EPISODE_NAMES[item], mp.metadata_episode[item]) # Operations info ops, ops_table = self.add_framed_table(_("Operations")) self.add_data(ops_table,_("Ingest:"), mediapackage.op_status[mp.getOpStatus("ingest")]) self.add_data(ops_table,_("Zipping:"), mediapackage.op_status[mp.getOpStatus("exporttozip")]) self.add_data(ops_table,_("Side by Side:"), mediapackage.op_status[mp.getOpStatus("sidebyside")]) # Series info if mp.getSeries(): series, series_table = self.add_framed_table(_("Series")) for item in ORDER_SERIES: if item in mp.metadata_series: self.add_data(series_table,SERIES_NAMES[item], mp.metadata_series[item]) # Track info tracks, track_table = self.add_framed_table(_("Tracks"), True) first = True for track in mp.getTracks(): if not first: self.add_data(track_table,"","") first = False self.add_data(track_table,_("Name:"),track.getIdentifier()) self.add_data(track_table,_("Flavor:"),track.getFlavor()) self.add_data(track_table,_("Type:"),track.getMimeType()) filename = str(path.split(track.getURI())[1]) self.add_data(track_table,_("File:"),filename) # Catalog info cats, cat_table = self.add_framed_table(_("Catalogs"), True) first = True for cat in mp.getCatalogs(): if not first: self.add_data(cat_table,"","") first = False self.add_data(cat_table,_("Name:"),cat.getIdentifier()) self.add_data(cat_table,_("Flavor:"),cat.getFlavor()) self.add_data(cat_table,_("Type:"),cat.getMimeType()) filename = str(path.split(cat.getURI())[1]) self.add_data(cat_table,_("File:"),filename) #PACKING box = gtk.VBox() box.pack_start(basic,False,True,int(self.hprop*10)) box.pack_start(ops,False,True,int(self.hprop*10)) if mp.getSeries(): box.pack_start(series,False,True,int(self.hprop*10)) box.pack_start(tracks,False,True,int(self.hprop*10)) box.pack_start(cats,False,True,int(self.hprop*10)) external_align=gtk.Alignment(0.5,0,0.8,0.8) external_align.add(box) self.add(external_align) #BUTTONS self.buttons = gtk.HButtonBox() self.buttons.set_layout(gtk.BUTTONBOX_SPREAD) self.add_button(_("Close"), self.close) self.add_button(_("Open Folder"), self.openfolder, mp.getURI()) box.pack_end(self.buttons, False, False, int(self.hprop*10)) self.show_all()
def date_readable(self, column, cell, model, iterador, user_data): """ Generates date readable string from an isoformat datetime. """ novo = readable.date(cell.get_property('text')) cell.set_property('text', novo) return novo
def date_readable(self, column, cell, model, iterator, index): """ Generates date readable string from an isoformat datetime. """ value = readable.date(model.get_value(iterator, index)) cell.set_property('text', value)
def test_date(self): self.assertEqual(readable.date('2015-12-12T14:14:14'), '12-12-2015 14:14')