コード例 #1
0
ファイル: objects.py プロジェクト: CharString/kupfer
	def get_description(self):
		# Use Application's description, else use executable
		# for "file-based" applications we show the path
		app_desc = tounicode(self.object.get_description())
		ret = tounicode(app_desc if app_desc else self.object.get_executable())
		if self.init_path:
			app_path = utils.get_display_path_for_bytestring(self.init_path)
			return u"(%s) %s" % (app_path, ret)
		return ret
コード例 #2
0
 def get_description(self):
     # Use Application's description, else use executable
     # for "file-based" applications we show the path
     app_desc = tounicode(self.object.get_description())
     ret = tounicode(app_desc if app_desc else self.object.get_executable())
     if self.init_path:
         app_path = utils.get_display_path_for_bytestring(self.init_path)
         return u"(%s) %s" % (app_path, ret)
     return ret
コード例 #3
0
ファイル: __init__.py プロジェクト: jablan/kupfer
def _load_tweets(api, user, count):
    pretty.print_debug(__name__, '_load_tweets', user, count)
    try:
        if user:
            timeline = api.GetUserTimeline(user, count)
        else:
            timeline = api.GetFriendsTimeline(count=count)
        for status in timeline:
            text = kupferstring.tounicode(status.text)
            name = kupferstring.tounicode(status.user.name)
            yield StatusLeaf(text, name, status.relative_created_at, status.id)
    except urllib2.HTTPError, err:
        pretty.print_error(__name__, '_load_tweets', user, count, err)
コード例 #4
0
ファイル: __init__.py プロジェクト: spiritedflow/kupfer
def _load_tweets(api, user, count):
	pretty.print_debug(__name__, '_load_tweets', user, count)
	try:
		if user:
			timeline = api.GetUserTimeline(user, count)
		else:
			timeline = api.GetFriendsTimeline(count=count)
		for status in timeline:
			text = kupferstring.tounicode(status.text)
			name = kupferstring.tounicode(status.user.name)
			yield StatusLeaf(text, name, status.relative_created_at,
					status.id)
	except urllib2.HTTPError, err:
		pretty.print_error(__name__, '_load_tweets', user, count, err)
コード例 #5
0
ファイル: preferences.py プロジェクト: cjparsons74/kupfer
	def _is_good_keystr(self, keystr):
		# Reject single letters so you can't bind 'A' etc
		if keystr is None:
			return
		label = gtk.accelerator_get_label(*gtk.accelerator_parse(keystr))
		ulabel = kupferstring.tounicode(label)
		return not (len(ulabel) == 1 and ulabel.isalnum())
コード例 #6
0
ファイル: selection.py プロジェクト: sagivmalihi/kupfer
	def __init__(self, text):
		text = kupferstring.tounicode(text)
		summary = self.get_first_text_line(text)
		maxlen = 10
		if len(summary) > maxlen:
			summary = summary[:maxlen] + u".."
		TextLeaf.__init__(self, text, _('Selected Text "%s"') % summary)
コード例 #7
0
ファイル: icons.py プロジェクト: engla/kupfer
def load_icon_from_func(plugin_name, icon_name, get_data_func, override=False):
    """
    Load icon from @icon_data into the name @icon_name

    @get_data_func: function to retrieve the data if needed
    @override: override the icon theme
    """
    icon_name = tounicode(icon_name)
    if not override and icon_name in kupfer_locally_installed_names:
        pretty.print_debug(__name__, "Skipping existing", icon_name)
        return
    if not override and _default_theme.has_icon(icon_name):
        pretty.print_debug(__name__, "Skipping themed icon", icon_name)
        return
    try:
        icon_data = get_data_func()
    except:
        pretty.print_error(__name__, "Error loading icon %r for %r" %
                           (icon_name, plugin_name))
        pretty.print_exc(__name__)
        return
    for size in (SMALL_SZ, LARGE_SZ):
        pixbuf = get_pixbuf_from_data(icon_data, size, size)
        Gtk.IconTheme.add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
                "for", plugin_name)
    kupfer_locally_installed_names.add(icon_name)
コード例 #8
0
ファイル: clipboard.py プロジェクト: jchtt/kupfer-adds
    def _clipboard_changed(self, clip, event, *args):
        is_selection = (event.selection == gtk.gdk.SELECTION_PRIMARY)

        max_len = __kupfer_settings__["max"]
        # receive clipboard as gtk text
        newtext = kupferstring.tounicode(clip.wait_for_text())

        is_valid = bool(newtext and newtext.strip())
        is_sync_selection = (is_selection
                             and __kupfer_settings__["sync_selection"])

        if not is_selection or __kupfer_settings__["use_selection"]:
            if is_valid:
                self._add_to_history(newtext, is_selection)

        if is_sync_selection and is_valid:
            gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(newtext)

        if is_selection:
            self.selected_text = newtext
        if not is_selection or is_sync_selection:
            self.clipboard_text = newtext
            if clip.wait_is_target_available(URI_TARGET):
                sdata = clip.wait_for_contents(URI_TARGET)
                self.clipboard_uris = list(sdata.get_uris())
            else:
                self.clipboard_uris = []
        self._prune_to_length(max_len)
        self.mark_for_update()
コード例 #9
0
ファイル: __init__.py プロジェクト: jablan/kupfer
def get_contacts():
    ''' load all contacts '''
    pretty.print_debug(__name__, 'get_contacts start')
    contacts = None
    start_time = time.time()
    try:
        gd_client = get_gclient()
        if gd_client is None:
            return None

        contacts = []
        query = gdata.contacts.service.ContactsQuery()
        query.max_results = 9999  # load all contacts
        for entry in gd_client.GetContactsFeed(query.ToUri()).entry:
            common_name = kupferstring.tounicode(entry.title.text)
            for email in entry.email:
                if email.address:
                    image = None
                    if __kupfer_settings__['loadicons']:
                        image = gd_client.GetPhoto(entry)
                    email = email.address
                    contacts.append(
                        GoogleContact(email, common_name or email, image))

    except (gdata.service.BadAuthentication,
            gdata.service.CaptchaRequired), err:
        pretty.print_error(__name__, 'get_contacts error',
                           'authentication error', err)
        contacts = [InvalidCredentialsLeaf(__name__, __kupfer_name__)]
コード例 #10
0
ファイル: preferences.py プロジェクト: guns/kupfer
 def _is_good_keystr(self, keystr):
     # Reject single letters so you can't bind 'A' etc
     if keystr is None:
         return
     label = Gtk.accelerator_get_label(*Gtk.accelerator_parse(keystr))
     ulabel = kupferstring.tounicode(label)
     return not (len(ulabel) == 1 and ulabel.isalnum())
コード例 #11
0
ファイル: __init__.py プロジェクト: cjparsons74/kupfer
def get_contacts():
	''' load all contacts '''
	pretty.print_debug(__name__, 'get_contacts start')
	contacts = None
	start_time = time.time()
	try:
		gd_client = get_gclient()
		if gd_client is None:
			return None

		contacts = []
		query = gdata.contacts.service.ContactsQuery()
		query.max_results = 9999 # load all contacts
		for entry in gd_client.GetContactsFeed(query.ToUri()).entry:
			common_name = kupferstring.tounicode(entry.title.text)
			for email in entry.email:
				if email.address:
					image = None
					if __kupfer_settings__['loadicons']:
						image = gd_client.GetPhoto(entry)
					email = email.address
					contacts.append(GoogleContact(email, common_name or email,
							image))

	except (gdata.service.BadAuthentication, gdata.service.CaptchaRequired), err:
		pretty.print_error(__name__, 'get_contacts error',
				'authentication error', err)
		contacts = [InvalidCredentialsLeaf(__name__, __kupfer_name__)]
コード例 #12
0
ファイル: icons.py プロジェクト: guns/kupfer
def load_icon_from_func(plugin_name, icon_name, get_data_func, override=False):
    """
    Load icon from @icon_data into the name @icon_name

    @get_data_func: function to retrieve the data if needed
    @override: override the icon theme
    """
    icon_name = tounicode(icon_name)
    if not override and icon_name in kupfer_locally_installed_names:
        pretty.print_debug(__name__, "Skipping existing", icon_name)
        return
    if not override and _default_theme.has_icon(icon_name):
        pretty.print_debug(__name__, "Skipping themed icon", icon_name)
        return
    try:
        icon_data = get_data_func()
    except:
        pretty.print_error(
            __name__,
            "Error loading icon %r for %r" % (icon_name, plugin_name))
        pretty.print_exc(__name__)
        return
    for size in (SMALL_SZ, LARGE_SZ):
        pixbuf = get_pixbuf_from_data(icon_data, size, size)
        Gtk.IconTheme.add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
                           "for", plugin_name)
    kupfer_locally_installed_names.add(icon_name)
コード例 #13
0
ファイル: objects.py プロジェクト: cjparsons74/kupfer
	def __init__(self, text, name=None):
		"""@text *must* be unicode or UTF-8 str"""
		text = tounicode(text)
		if not name:
			lines = [l for l in text.splitlines() if l.strip()]
			name = lines[0] if lines else text
		Leaf.__init__(self, text, name)
コード例 #14
0
ファイル: clipboard.py プロジェクト: pbx/kupfer
    def _clipboard_changed(self, clip, event, *args):
        is_selection = (event.selection == gtk.gdk.SELECTION_PRIMARY)

        max_len = __kupfer_settings__["max"]
        # receive clipboard as gtk text
        newtext = kupferstring.tounicode(clip.wait_for_text())

        is_valid = bool(newtext and newtext.strip())
        is_sync_selection = (is_selection and
                             __kupfer_settings__["sync_selection"])

        if not is_selection or __kupfer_settings__["use_selection"]:
            if is_valid:
                self._add_to_history(newtext, is_selection)

        if is_sync_selection and is_valid:
            gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(newtext)

        if is_selection:
            self.selected_text = newtext
        if not is_selection or is_sync_selection:
            self.clipboard_text = newtext
            if clip.wait_is_target_available(URI_TARGET):
                sdata = clip.wait_for_contents(URI_TARGET)
                self.clipboard_uris = list(sdata.get_uris())
            else:
                self.clipboard_uris = []
        self._prune_to_length(max_len)
        self.mark_for_update()
コード例 #15
0
ファイル: __init__.py プロジェクト: spiritedflow/kupfer
    def get_albums(cls, force=False):
        """ Load user albums, and albums users defined in 'showusers' setting. """
        pretty.print_debug(__name__, "get_albums", str(force))
        if not force:
            return cls.data
        start_time = time.time()
        gd_client = picasa_login()
        if not gd_client:
            return [InvalidCredentialsLeaf(__name__, __kupfer_name__)]

        pusers = []
        try:
            user = __kupfer_settings__["userpass"].username
            show_users = __kupfer_settings__["showusers"] or ""
            user_names = [U.strip() for U in show_users.split(",") if U.strip()]

            if user not in user_names:
                user_names.append(user)

            for user_name in user_names:
                pretty.print_debug(__name__, "get_albums: get album", user_name)
                # get user info
                picasa_user_leaf = get_user_leaf(gd_client, user_name)
                if picasa_user_leaf is None:
                    continue
                picasa_user_leaf.my_albums = user_name == user  # mark my albums
                # get albums
                user_albums = []
                for album in gd_client.GetUserFeed(user=user_name).entry:
                    # get album thumbnail:
                    thumb = None
                    if album.media.thumbnail and __kupfer_settings__["loadicons"]:
                        thumb = get_thumb(gd_client, album.media.thumbnail[0].url)
                    name = kupferstring.tounicode(album.title.text)
                    album = PicasaAlbum(
                        album.GetAlternateLink().href,
                        name,
                        album.numphotos.text,
                        album.gphoto_id.text,
                        thumb,
                        kupferstring.tounicode(user_name),
                    )
                    user_albums.append(album)
                picasa_user_leaf.update_albums(user_albums)
                pusers.append(picasa_user_leaf)
        except gdata.service.Error, err:
            pretty.print_error(__name__, "get_albums", err)
コード例 #16
0
 def __init__(self, text, name=None):
     """@text *must* be unicode or UTF-8 str"""
     text = tounicode(text)
     if not name:
         name = self.get_first_text_line(text)
     if len(text) == 0 or not name:
         name = _("(Empty Text)")
     Leaf.__init__(self, text, name)
コード例 #17
0
ファイル: selection.py プロジェクト: chmouel/kupfer
	def __init__(self, text):
		text = kupferstring.tounicode(text)
		lines = filter(None, text.splitlines())
		summary = lines[0] if lines else text
		maxlen = 10
		if len(summary) > maxlen:
			summary = summary[:maxlen] + u".."
		TextLeaf.__init__(self, text, _('Selected Text "%s"') % summary)
コード例 #18
0
ファイル: objects.py プロジェクト: CharString/kupfer
	def __init__(self, text, name=None):
		"""@text *must* be unicode or UTF-8 str"""
		text = tounicode(text)
		if not name:
			name = self.get_first_text_line(text)
		if len(text) == 0 or not name:
			name = _("(Empty Text)")
		Leaf.__init__(self, text, name)
コード例 #19
0
ファイル: __init__.py プロジェクト: CharString/kupfer
def get_contacts():
	''' load all contacts '''
	pretty.print_debug(__name__, 'get_contacts start')
	start_time = time.time()
	num_contacts = 0
	try:
		gd_client = get_gclient()
		if gd_client is None:
			return
		query = gdata.contacts.service.ContactsQuery()
		query.max_results = 9999  # load all contacts
		for entry in gd_client.GetContactsFeed(query.ToUri()).entry:
			if not entry.email:
				# skip contacts without email
				continue
			num_contacts += 1
			common_name = kupferstring.tounicode(entry.title.text)
			primary_mail_key = {contacts.EMAIL_KEY: entry.email[0].address}
			contact_id = None
			try:
				contact_id = entry.id.text.split('/')[-1]
			except:
				pass
			image = None
			if __kupfer_settings__['loadicons']:
				# Sometimes GetPhoto can't find appropriate image (404)
				try:
					image = gd_client.GetPhoto(entry)
				except:
					pass
			for email in entry.email:
				if email.address:
					email_str = email.address
					yield GoogleContact(email_str, common_name or email_str,
							image, contact_id, REL_LIST_EMAIL.get(email.rel))
			if not __kupfer_settings__['loadadditional']:
				continue
			for phone in entry.phone_number:
				if phone.text:
					yield contacts.PhoneContact(phone.text, common_name,
							REL_LIST_PHONE.get(phone.rel), slots=primary_mail_key,
							image=image)
			for address in entry.postal_address:
				if address.text:
					yield contacts.AddressContact(address.text, common_name,
							REL_LIST_PHONE.get(address.rel), slots=primary_mail_key,
							image=image)
			for im in entry.im:
				im_id = im.text or im.address
				protocol = im.protocol or im.rel
				if im_id and protocol in REL_LIST_IM:
					yield REL_LIST_IM[protocol](im_id, common_name,
							slots=primary_mail_key, image=image)
	except (gdata.service.BadAuthentication, gdata.service.CaptchaRequired), err:
		pretty.print_error(__name__, 'get_contacts error',
				'authentication error', err)
		yield InvalidCredentialsLeaf(__name__, __kupfer_name__)
コード例 #20
0
    def __init__(self, name=None):
        """ Init kupfer object with, where
		@name *should* be a unicode object but *may* be
		a UTF-8 encoded `str`
		"""
        if not name:
            name = self.__class__.__name__
        self.name = tounicode(name)
        folded_name = tofolded(self.name)
        self.kupfer_add_alias(folded_name)
コード例 #21
0
ファイル: triggers.py プロジェクト: spiritedflow/kupfer
def try_bind_key(keystr):
	label = gtk.accelerator_get_label(*gtk.accelerator_parse(keystr))
	ulabel = kupferstring.tounicode(label)
	if len(ulabel) == 1 and ulabel.isalnum():
		return False
	target = keybindings.KEYRANGE_TRIGGERS[-1] - 1
	succ = keybindings.bind_key(keystr, target)
	if succ:
		keybindings.bind_key(None, target)
	return succ
コード例 #22
0
ファイル: triggers.py プロジェクト: jchtt/kupfer-adds
def try_bind_key(keystr):
    label = gtk.accelerator_get_label(*gtk.accelerator_parse(keystr))
    ulabel = kupferstring.tounicode(label)
    if len(ulabel) == 1 and ulabel.isalnum():
        return False
    target = keybindings.KEYRANGE_TRIGGERS[-1] - 1
    succ = keybindings.bind_key(keystr, target)
    if succ:
        keybindings.bind_key(None, target)
    return succ
コード例 #23
0
ファイル: __init__.py プロジェクト: jchtt/kupfer-adds
	def get_albums(cls, force=False):
		''' Load user albums, and albums users defined in 'showusers' setting. '''
		pretty.print_debug(__name__, 'get_albums', str(force))
		if not force:
			return cls.data
		start_time = time.time()
		gd_client = picasa_login()
		if not gd_client:
			return [InvalidCredentialsLeaf(__name__, __kupfer_name__)]

		pusers = []
		try:
			user = __kupfer_settings__['userpass'].username
			show_users = (__kupfer_settings__['showusers'] or '')
			user_names = [U.strip() for U in show_users.split(',') if U.strip()]

			if user not in user_names:
				user_names.append(user)

			for user_name in user_names:
				pretty.print_debug(__name__, 'get_albums: get album', user_name)
				# get user info
				picasa_user_leaf = get_user_leaf(gd_client, user_name)
				if picasa_user_leaf is None:
					continue
				picasa_user_leaf.my_albums = (user_name == user) # mark my albums
				# get albums
				user_albums = []
				for album in gd_client.GetUserFeed(user=user_name).entry:
					# get album thumbnail:
					thumb = None
					if album.media.thumbnail and __kupfer_settings__['loadicons']:
						thumb = get_thumb(gd_client, album.media.thumbnail[0].url)
					name = kupferstring.tounicode(album.title.text)
					album = PicasaAlbum(album.GetAlternateLink().href,
							name, album.numphotos.text,
							album.gphoto_id.text, thumb,
							kupferstring.tounicode(user_name))
					user_albums.append(album)
				picasa_user_leaf.update_albums(user_albums)
				pusers.append(picasa_user_leaf)
		except gdata.service.Error, err:
			pretty.print_error(__name__, 'get_albums', err)
コード例 #24
0
ファイル: base.py プロジェクト: pbx/kupfer
 def __init__(self, name=None):
     """ Init kupfer object with, where
     @name *should* be a unicode object but *may* be
     a UTF-8 encoded `str`
     """
     if not name:
         name = self.__class__.__name__
     self.name = tounicode(name)
     folded_name = tofolded(self.name)
     self.kupfer_add_alias(folded_name)
コード例 #25
0
def get_googleDocsList():
    gclient = get_googleClient()
    if (gclient == None):
        return [PleaseConfigureLeaf(__name__, __kupfer_name__)]
    docList = []
    feed = gclient.GetDocList()
    for entry in feed.entry:
        doc = GoogleDocument(entry.GetAlternateLink().href , entry.title.text.encode('UTF-8'),
                entry.GetDocumentType(), entry.resource_id.text,
                kupferstring.tounicode(__kupfer_settings__['userpass'].username))
        docList.append(doc)
    return docList
コード例 #26
0
ファイル: __init__.py プロジェクト: spiritedflow/kupfer
def load_data():
	pretty.print_debug(__name__, 'load_data: start')
	start_time = time.time()
	api = get_twitter_api()
	result = []
	if api:
		for friend in api.GetFriends():
			image = None
			if __kupfer_settings__['loadicons']:
				image = download_image(friend.profile_image_url)
			screen_name = kupferstring.tounicode(friend.screen_name)
			name = kupferstring.tounicode(friend.name)
			fobj = Friend(screen_name, name, image)
			if __kupfer_settings__['loadtweets']:
				fobj.tweets = list(_load_tweets(api, friend.screen_name,
						MAX_STATUSES_COUNT))
			result.append(fobj)
	else:
		confl = PleaseConfigureLeaf(__name__, __kupfer_name__)
		result = [ confl ]

	pretty.print_debug(__name__, 'load_data: finished; load', len(result),
			time.time()-start_time)
	return result
コード例 #27
0
ファイル: __init__.py プロジェクト: jablan/kupfer
def load_data():
    pretty.print_debug(__name__, 'load_data: start')
    start_time = time.time()
    api = get_twitter_api()
    result = []
    if api:
        for friend in api.GetFriends():
            image = None
            if __kupfer_settings__['loadicons']:
                image = download_image(friend.profile_image_url)
            screen_name = kupferstring.tounicode(friend.screen_name)
            name = kupferstring.tounicode(friend.name)
            fobj = Friend(screen_name, name, image)
            if __kupfer_settings__['loadtweets']:
                fobj.tweets = list(
                    _load_tweets(api, friend.screen_name, MAX_STATUSES_COUNT))
            result.append(fobj)
    else:
        confl = PleaseConfigureLeaf(__name__, __kupfer_name__)
        result = [confl]

    pretty.print_debug(__name__, 'load_data: finished; load', len(result),
                       time.time() - start_time)
    return result
コード例 #28
0
ファイル: tracker1.py プロジェクト: pbx/kupfer
    def decorate_item(cls, leaf):
        # FIXME: Very simplified .savedSearch parsing, so far we only support
        # the query, without additional filtering. The simplest form of
        # .savedSearch file is saved by nautilus as following:
        # <query version="1.0">
        #   <text>QUERY GOES HERE</text>
        # </query>

        if not leaf.object.endswith(".savedSearch"):
            return None
        try:
            et = ElementTree(file=leaf.object)
            query = et.getroot().find("text").text
            us_query = kupferstring.tounicode(query)
            return cls(us_query)
        except Exception:
            return None
コード例 #29
0
    def decorate_item(cls, leaf):
        # FIXME: Very simplified .savedSearch parsing, so far we only support
        # the query, without additional filtering. The simplest form of
        # .savedSearch file is saved by nautilus as following:
        # <query version="1.0">
        #   <text>QUERY GOES HERE</text>
        # </query>

        if not leaf.object.endswith(".savedSearch"):
            return None
        try:
            et = ElementTree(file=leaf.object)
            query = et.getroot().find("text").text
            us_query = kupferstring.tounicode(query)
            return cls(us_query)
        except Exception:
            return None
コード例 #30
0
    def __init__(self, obj, name=None, alias=None):
        """Construct a FileLeaf

        The display name of the file is normally derived from the full path,
        and @name should normally be left unspecified.

        @obj: byte string (file system encoding)
        @name: unicode name or None for using basename
        """
        if obj is None:
            raise InvalidDataError("File path for %s may not be None" % name)
        # Use glib filename reading to make display name out of filenames
        # this function returns a `unicode` object
        if not name:
            unicode_path = tounicode(obj)
            name = GLib.filename_display_basename(unicode_path)
        super(FileLeaf, self).__init__(obj, name)
        if alias:
            self.kupfer_add_alias(alias)
コード例 #31
0
ファイル: objects.py プロジェクト: engla/kupfer
    def __init__(self, obj, name=None, alias=None):
        """Construct a FileLeaf

        The display name of the file is normally derived from the full path,
        and @name should normally be left unspecified.

        @obj: byte string (file system encoding)
        @name: unicode name or None for using basename
        """
        if obj is None:
            raise InvalidDataError("File path for %s may not be None" % name)
        # Use glib filename reading to make display name out of filenames
        # this function returns a `unicode` object
        if not name:
            unicode_path = tounicode(obj)
            name = GLib.filename_display_basename(unicode_path)
        super(FileLeaf, self).__init__(obj, name)
        if alias:
            self.kupfer_add_alias(alias)
コード例 #32
0
ファイル: preferences.py プロジェクト: cjparsons74/kupfer
	def on_entry_plugins_filter_changed(self, widget):
		s_filter = widget.get_text()
		us_filter = kupferstring.tounicode(s_filter).lower()
		self._refresh_plugin_list(us_filter)
コード例 #33
0
	def password(self):
		return kupferstring.tounicode(self.entry_pass.get_text())
コード例 #34
0
	def username(self):
		return kupferstring.tounicode(self.entry_user.get_text())
コード例 #35
0
def get_contacts():
    ''' load all contacts '''
    pretty.print_debug(__name__, 'get_contacts start')
    start_time = time.time()
    num_contacts = 0
    try:
        gd_client = get_gclient()
        if gd_client is None:
            return
        query = gdata.contacts.service.ContactsQuery()
        query.max_results = 9999  # load all contacts
        for entry in gd_client.GetContactsFeed(query.ToUri()).entry:
            if not entry.email:
                # skip contacts without email
                continue
            num_contacts += 1
            common_name = kupferstring.tounicode(entry.title.text)
            primary_mail_key = {contacts.EMAIL_KEY: entry.email[0].address}
            contact_id = None
            try:
                contact_id = entry.id.text.split('/')[-1]
            except:
                pass
            image = None
            if __kupfer_settings__['loadicons']:
                # Sometimes GetPhoto can't find appropriate image (404)
                try:
                    image = gd_client.GetPhoto(entry)
                except:
                    pass
            for email in entry.email:
                if email.address:
                    email_str = email.address
                    yield GoogleContact(email_str, common_name or email_str,
                                        image, contact_id,
                                        REL_LIST_EMAIL.get(email.rel))
            if not __kupfer_settings__['loadadditional']:
                continue
            for phone in entry.phone_number:
                if phone.text:
                    yield contacts.PhoneContact(phone.text,
                                                common_name,
                                                REL_LIST_PHONE.get(phone.rel),
                                                slots=primary_mail_key,
                                                image=image)
            for address in entry.postal_address:
                if address.text:
                    yield contacts.AddressContact(address.text,
                                                  common_name,
                                                  REL_LIST_PHONE.get(
                                                      address.rel),
                                                  slots=primary_mail_key,
                                                  image=image)
            for im in entry.im:
                im_id = im.text or im.address
                protocol = im.protocol or im.rel
                if im_id and protocol in REL_LIST_IM:
                    yield REL_LIST_IM[protocol](im_id,
                                                common_name,
                                                slots=primary_mail_key,
                                                image=image)
    except (gdata.service.BadAuthentication,
            gdata.service.CaptchaRequired), err:
        pretty.print_error(__name__, 'get_contacts error',
                           'authentication error', err)
        yield InvalidCredentialsLeaf(__name__, __kupfer_name__)
コード例 #36
0
ファイル: commands.py プロジェクト: cjparsons74/kupfer
def unicode_shlex_split(ustr, **kwargs):
	"""shlex.split is depressingly broken on unicode input"""
	s_str = ustr.encode("UTF-8")
	return [kupferstring.tounicode(t) for t in shlex.split(s_str, **kwargs)]
コード例 #37
0
ファイル: preferences.py プロジェクト: guns/kupfer
 def on_entry_plugins_filter_changed(self, widget):
     s_filter = widget.get_text()
     us_filter = kupferstring.tounicode(s_filter).lower()
     self._refresh_plugin_list(us_filter)
コード例 #38
0
 def password(self):
     return kupferstring.tounicode(self.entry_pass.get_text())
コード例 #39
0
 def username(self):
     return kupferstring.tounicode(self.entry_user.get_text())
コード例 #40
0
ファイル: __init__.py プロジェクト: jchtt/kupfer-adds
	return thumb


def get_user_leaf(gd_client, user_name):
	''' Create PicasaUser obj for given @user_name. '''
	leaf = None
	try:
		user_info = gd_client.GetContacts(user_name)
	except gdata.photos.service.GooglePhotosException, err:
		pretty.print_info(__name__, 'get_uers_leaf', err)
	else:
		thumb = None
		if __kupfer_settings__['loadicons']:
			thumb = get_thumb(gd_client, user_info.thumbnail.text)
		user_url = USER_URL % dict(user=user_info.user.text)
		leaf = PicasaUser(user_url, kupferstring.tounicode(user_info.nickname.text),
				thumb)
	return leaf


class PicasaDataCache():
	data = []

	@classmethod
	def get_albums(cls, force=False):
		''' Load user albums, and albums users defined in 'showusers' setting. '''
		pretty.print_debug(__name__, 'get_albums', str(force))
		if not force:
			return cls.data
		start_time = time.time()
		gd_client = picasa_login()