当前位置: 首页>>代码示例>>Python>>正文


Python MarkupParser.urlify方法代码示例

本文整理汇总了Python中MarkupParser.urlify方法的典型用法代码示例。如果您正苦于以下问题:Python MarkupParser.urlify方法的具体用法?Python MarkupParser.urlify怎么用?Python MarkupParser.urlify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MarkupParser的用法示例。


在下文中一共展示了MarkupParser.urlify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _pre_process_message

# 需要导入模块: import MarkupParser [as 别名]
# 或者: from MarkupParser import urlify [as 别名]
    def _pre_process_message(self, contact, message, incomming, cedict, cepath, tstamp=None, mtype=None, cstyle=None):
        '''Create a new gui.Message and calculates if it's first message
        '''
        msg = gui.Message.from_contact(contact,
                message, self.first, incomming, tstamp, mtype = mtype, mstyle=cstyle)

        if self.session.config.b_show_emoticons:
            msg.message = MarkupParser.replace_emotes(MarkupParser.escape(msg.message),
                        cedict, cepath, msg.sender)

        msg.message = MarkupParser.urlify(msg.message)

        b_nick_check = bool(self.last_incoming_nickname != msg.display_name)
        if b_nick_check:
            self.last_incoming_nickname = msg.display_name

        if msg.incoming:
            if self.last_incoming is None:
                self.last_incoming = False

            msg.first = not self.last_incoming

            if self.last_incoming_account != msg.sender or b_nick_check:
                msg.first = True
        else:
            if self.last_incoming is None:
                self.last_incoming = True

            msg.first = self.last_incoming

        return msg
开发者ID:arielj,项目名称:emesene,代码行数:33,代码来源:Conversation.py

示例2: replace

# 需要导入模块: import MarkupParser [as 别名]
# 或者: from MarkupParser import urlify [as 别名]
    def replace(self, template, msg, style=None, cedict={}, cedir=None):
        '''replace the variables on template for the values on msg
        '''

        msgtext = MarkupParser.replace_emotes(escape(msg.message), cedict, cedir)
        msgtext = MarkupParser.urlify(msgtext)

        if style is not None:
            msgtext = style_message(msgtext, style)

        template = template.replace('%sender%', escape(msg.alias))
        template = template.replace('%senderScreenName%', escape(msg.sender))
        template = template.replace('%senderDisplayName%',
            escape(msg.display_name))
        template = template.replace('%userIconPath%', escape(msg.image_path))
        template = template.replace('%senderStatusIcon%',
            escape(msg.status_path))
        template = template.replace('%messageDirection%',
            escape(msg.direction))
        template = template.replace('%message%', msgtext)
        template = template.replace('%time%',
            escape(time.strftime(self.timefmt)))
        template = re.sub("%time{(.*?)}%", replace_time, template)
        template = template.replace('%shortTime%',
            escape(time.strftime("%H:%M")))
        template = template.replace('%service%', escape(msg.service))
        template = template.replace('%messageClasses%', escape(msg.classes))
        template = template.replace('%status%', escape(msg.status))

        return template.replace('\n', '')
开发者ID:dkasak,项目名称:emesene,代码行数:32,代码来源:AdiumTheme.py

示例3: replace

# 需要导入模块: import MarkupParser [as 别名]
# 或者: from MarkupParser import urlify [as 别名]
    def replace(self, template, msg, style=None, cedict={}, cedir=None):
        '''replace the variables on template for the values on msg
        '''

        msg.alias = Plus.msnplus_strip(msg.alias)
        msg.display_name = Plus.msnplus_strip(msg.display_name)

        if(len(msg.alias) > DISPLAY_NAME_LIMIT):
            msg.alias = msg.alias.decode('utf-8')[0:DISPLAY_NAME_LIMIT] + "..."
        if(len(msg.display_name) > DISPLAY_NAME_LIMIT):
            msg.display_name = msg.display_name.decode('utf-8')[0:DISPLAY_NAME_LIMIT] + "..."

        msgtext = MarkupParser.replace_emotes(escape(msg.message), cedict, cedir, msg.sender)
        msgtext = MarkupParser.urlify(msgtext)
        image_path = escape(MarkupParser.path_to_url(msg.image_path))
        status_path = escape(MarkupParser.path_to_url(msg.status_path))

        if style is not None:
            msgtext = style_message(msgtext, style)
        if msg.alias:
            template = template.replace('%sender%', escape(msg.alias))
        else:
            template = template.replace('%sender%', escape(msg.display_name))

        template = template.replace('%senderScreenName%', escape(msg.sender))
        template = template.replace('%senderDisplayName%',
            escape(msg.display_name))
        template = template.replace('%userIconPath%', image_path)
        template = template.replace('%senderStatusIcon%',
            status_path)
        template = template.replace('%messageDirection%',
            escape(msg.direction))
        template = template.replace('%message%', msgtext)

        if msg.timestamp is None:
            template = template.replace('%time%',
                escape(time.strftime("%H:%M")))
        else:
            def utc_to_local(t):
                secs = calendar.timegm(t)
                return time.localtime(secs)
            l_time = utc_to_local(msg.timestamp.timetuple()) #time.struct_time
            d_time = datetime.datetime.fromtimestamp(time.mktime(l_time))
            template = template.replace('%time%',
                escape(d_time.strftime('%x %X')))

        template = re.sub("%time{(.*?)}%", replace_time, template)
        template = template.replace('%shortTime%',
            escape(time.strftime("%H:%M")))
        template = template.replace('%service%', escape(msg.service))
        template = template.replace('%messageClasses%', escape(msg.classes))
        template = template.replace('%status%', escape(msg.status))

        return template.replace('\n', '')
开发者ID:imfromksa,项目名称:emesene,代码行数:56,代码来源:AdiumTheme.py

示例4: replace

# 需要导入模块: import MarkupParser [as 别名]
# 或者: from MarkupParser import urlify [as 别名]
    def replace(self, template, msg, style=None, cedict={}, cedir=None):
        """replace the variables on template for the values on msg
        """

        msg.alias = Plus.msnplus_strip(msg.alias)
        msg.display_name = Plus.msnplus_strip(msg.display_name)

        msgtext = MarkupParser.replace_emotes(escape(msg.message), cedict, cedir, msg.sender)
        msgtext = MarkupParser.urlify(msgtext)
        image_path = escape(MarkupParser.path_to_url(msg.image_path))
        status_path = escape(MarkupParser.path_to_url(msg.status_path))

        if style is not None:
            msgtext = style_message(msgtext, style)
        if msg.alias:
            template = template.replace("%sender%", escape(msg.alias))
        else:
            template = template.replace("%sender%", escape(msg.display_name))

        template = template.replace("%senderScreenName%", escape(msg.sender))
        template = template.replace("%senderDisplayName%", escape(msg.display_name))
        template = template.replace("%userIconPath%", image_path)
        template = template.replace("%senderStatusIcon%", status_path)
        template = template.replace("%messageDirection%", escape(msg.direction))
        template = template.replace("%message%", msgtext)

        if msg.timestamp is None:
            template = template.replace("%time%", escape(time.strftime(self.timefmt)))
        else:

            def utc_to_local(t):
                secs = calendar.timegm(t)
                return time.localtime(secs)

            l_time = utc_to_local(msg.timestamp.timetuple())  # time.struct_time
            d_time = datetime.datetime.fromtimestamp(time.mktime(l_time))
            template = template.replace("%time%", escape(d_time.strftime("%x %X")))

        template = re.sub("%time{(.*?)}%", replace_time, template)
        template = template.replace("%shortTime%", escape(time.strftime("%H:%M")))
        template = template.replace("%service%", escape(msg.service))
        template = template.replace("%messageClasses%", escape(msg.classes))
        template = template.replace("%status%", escape(msg.status))

        return template.replace("\n", "")
开发者ID:Roger,项目名称:emesene,代码行数:47,代码来源:AdiumTheme.py


注:本文中的MarkupParser.urlify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。