Example #1
0
    def __init__(self):

        cream.Module.__init__(self, 'org.cream.Chronos')

        self.events = {}
        self.calendars = ordereddict()
        self.colors = find_colors(.57, .72, .79)

        self.calendar = cream.ipc.get_object('org.cream.PIM', '/org/cream/PIM/Calendar')
        self.calendar.search_for_calendars()

        self.calendar.connect_to_signal('calendar_added', self.add_calendar)
        self.calendar.connect_to_signal('event_added', lambda u,e: self.add_events([e]))
        self.calendar.connect_to_signal('event_removed', lambda u,e: self.remove_events([e]))
        self.calendar.connect_to_signal('event_updated', lambda u,e: self.update_events([e]))

        self.calendar_ui = CalendarUI()

        self.calendar_ui.window.connect('delete_event', lambda *x: self.quit())
        self.calendar_ui.connect('calendar-state-changed', self.calendar_state_change_cb)


        for calendar in self.calendar.get_calendars():
            self.add_calendar(calendar['uid'], calendar)

        def add_events():
            events = self.calendar.query({})
            self.add_events(events)
        gobject.timeout_add(1, add_events)
Example #2
0
    def read_scheme(self):

        if not os.path.isfile(self.scheme_path):
            from . import MissingConfigurationDefinitionFile
            raise MissingConfigurationDefinitionFile("Could not find %r." % self.scheme_path)

        tree = parse_xml(self.scheme_path)
        root = tree.getroot()
        scheme = ordereddict()

        for child in root.getchildren():
            option_name = child.tag
            attributes = dict(child.attrib)
            option_type = attributes.pop('type')
            if option_type.startswith('multioption'):
                # TODO: Hrm
                attributes['default'] = child.attrib.pop('default', None)
                attributes['options'] = unserialize_atomic(child, FIELD_TYPE_MAP)
            else:
                if not (
                    FIELD_TYPE_MAP.get(option_type) in ('list', 'tuple', 'dict')
                    and not child.getchildren()
                ):
                    attributes['default'] = unserialize_atomic(child, FIELD_TYPE_MAP)
            scheme[option_name] = get_field(option_type)(**attributes)

        return scheme
Example #3
0
    def add_calendar(self, uid, calendar):

        color = self.colors.next()

        calendar.update({'color': color, 'active': True})
        self.calendars[calendar['uid']] = calendar

        new = ordereddict()
        for key in sorted(self.calendars, key=lambda k: self.calendars[k]['name']):
            new[key] = self.calendars[key]

        self.calendars = new

        self.calendar_ui.set_calendars(self.calendars.values())
Example #4
0
    def stream_urls(self):
        """
        A dictionary of directly streamable URLs in all resolutions that are
        known to be available for this video.

        (``request_video_info`` has to be called before accessing this property)
        """
        urls = list()
        for item in self.video_info['fmt_url_map'][0].split(','):
            resolution_id, stream_url = item.split('|')
            try:
                resolution_name = RESOLUTIONS[int(resolution_id)]
            except KeyError:
                self._warn_unknown_resolution(resolution_id)
            else:
                urls.append((resolution_name, self._cleanup_stream_url(stream_url)))
        return ordereddict(urls)
Example #5
0
    def __init__(self, path):

        gobject.GObject.__init__(self)

        self.path = path

        self.address = indicator_object_new_from_file(path)
        self.indicator = capi.pygobject_new(self.address)

        if not self.indicator:
            raise IndicatorLoadingFailed

        self.indicator.connect('entry-added', self.entry_added_cb)
        self.indicator.connect('entry-removed', self.entry_removed_cb)

        self.entries = ordereddict()

        _entries = glist(indicator_object_get_entries(self.address))
        for _entry in _entries:
            self.entries[_entry] = IndicatorObjectEntry(_entry)
Example #6
0
    def __init__(self, path):

        gobject.GObject.__init__(self)

        self.path = path

        self.address = indicator_object_new_from_file(path)
        self.indicator = capi.pygobject_new(self.address)
        
        if not self.indicator:
            raise IndicatorLoadingFailed


        self.indicator.connect('entry-added', self.entry_added_cb)
        self.indicator.connect('entry-removed', self.entry_removed_cb)

        self.entries = ordereddict()

        _entries = glist(indicator_object_get_entries(self.address))
        for _entry in _entries:
            self.entries[_entry] = IndicatorObjectEntry(_entry)
Example #7
0
Please file a bug at http://github.com/sbillaudelle/youtube-player/issues
or send a mail to [email protected]" including the following information:
    Video-ID: {video_id}
Thank you!"""

# Ordering options
SORT_BY_RELEVANCE  = 'relevance'
SORT_BY_VIEW_COUNT = 'viewCount'
SORT_BY_PUBLISHED  = 'published'
SORT_BY_RATING     = 'rating'

RESOLUTIONS = ordereddict((
    (38, '4K'),
    (37, '1080p'),
    (22, '720p'),
    (35, '480p+'),
    (34, '480p'),
    (18, '360p'),
    (5,  'FLV1')
))


class YouTubeError(Exception):
    pass

class _VideoInfoProperty(property):
    """
    Property used to hide the ``Video.video_info`` dict
    (which is not a pretty API at all).

        foo = _VideoInfoProperty('blah')