示例#1
0
	def __init__(self, news):
		self.title = common.strip_tags(news['Title'])
		self.agency = common.strip_tags(news['Agency'])
		self.ago = common.strip_tags(news['Ago'])
		self.body = common.strip_tags(news['Body'])
		self.time = news['Time']
		self.label = news['Label']
示例#2
0
 def on_remove_click_cb(self,widget):
   win = self.tree.get_widget("window")
   row = self.tv.get_row()
   # its category
   if self.tv.get_model().get_path(self.tv.iter)[0] < self.tv.categoryNum:
     #category must be empty
     if self.db.isCategoryEmpty(row[0]):
       if confirmation(win,u"Opravdu chcete smazat kategorii '"+common.strip_tags(row[1])+"'?", "Ano", "Ne"):
         self.db.removeCategory(row[0])
         self.tv.remove_row()
         self.modified = True
         self.remove.set_sensitive(False)
         self.edit.set_sensitive(False)
     else:
       note(win,'Nemohu smazat neprázdnou kategorii.','OK')
   #its item
   else:
     #item must not be in cart
     if int(self.db.getCartCount(row[0])) > 0:
       note(win,'Nemohu položku smazat. Část jich je v košíku.','OK')
     elif confirmation(win,u"Opravdu chcete smazat položku '"+common.strip_tags(row[1])+"'?", "Ano", "Ne"):
       self.db.removeItem(row[0])
       self.tv.remove_row()
       self.modified = True
       self.remove.set_sensitive(False)
       self.edit.set_sensitive(False)
示例#3
0
文件: ad.py 项目: hsinmiao00/adfisher
 def __init__(self, ad):
     self.title = common.strip_tags(ad['Title'])
     self.url = common.strip_tags(ad['URL'])
     self.body = common.strip_tags(ad['Body'])
     self.cat = ad['cat']
     self.time = ad['Time']
     self.label = ad['label']
示例#4
0
文件: kget.py 项目: omusico/lyric-get
    def parse_song_info(self, url, html):
        ret = True

        pattern = '<h1.*?>(.*)</h1>'
        title = common.get_first_group_by_pattern(html, pattern)
        if title:
            title = common.htmlspecialchars_decode(common.strip_tags(title)).strip()
            self.title = title
        else:
            logging.warning('Failed to parse title of url [%s]', url)
            ret = False

        patterns = {
            'artist': '">([^<]*)</a></span></td></tr>',
            'lyricist': 'td>([^<]*)<br></td></tr><tr>',
            'composer': 'td>([^<]*)<br></td></tr></table>',
        }

        prefix = '<table class="lyric-data">'
        suffix = '</table>'
        info_table = common.find_string_by_prefix_suffix(html, prefix, suffix)
        info_table = info_table.replace('\n', '')

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(info_table, pattern)
            if value:
                value = common.htmlspecialchars_decode(common.strip_tags(value)).strip()
                setattr(self, key, value)
            else:
                logging.warning('Failed to get %s', key)
                ret = False

        return ret
示例#5
0
    def find_song_info(self, url):
        ret = True
        resp = common.get_url_content(url)

        encoding = 'sjis'
        html = resp.decode(encoding, 'ignore')

        prefix = '<table border=0 cellpadding=0 cellspacing=5>'
        suffix = '</td></table>'
        infoString = common.get_string_by_start_end_string(prefix, suffix, html)

        self.title = common.strip_tags(
            common.get_string_by_start_end_string('<td>', '</td>', infoString)
        )

        self.artist = common.strip_tags(
            common.get_string_by_start_end_string('<td><a href=', '</a></td>', infoString)
        )

        prefix = '<table border=0 cellpadding=0 cellspacing=0>'
        suffix = '</td></table>'
        lyricAndMusic = common.get_string_by_start_end_string(prefix, suffix, infoString)

        pattern = u'作詞 : (.*)<br>'
        self.lyricist = common.get_first_group_by_pattern(lyricAndMusic, pattern)

        pattern = u'作曲 : (.*)</td>'
        self.composer = common.get_first_group_by_pattern(lyricAndMusic, pattern)

        return ret
示例#6
0
  def on_edit_click_cb(self,event):
    tree = dlg_load_tree()
    win = self.tree.get_widget("window")
    row = self.tv.get_row()
    #category
    if self.tv.get_model().get_path(self.tv.iter)[0] < self.tv.categoryNum:
      dlg = tree.get_widget("category_dlg")
      tree.get_widget("category_title").set_text(common.strip_tags(row[1]))

      tree.get_widget("category_storno").connect('clicked',self.category_cancel_clicked,dlg,tree)
      tree.get_widget("category_ok").connect('clicked',self.category_ok_clicked,dlg,tree)
      r = dlg.run()
      if r == gtk.RESPONSE_OK:
        self.db.updateCategory(self.new_category_title,row[0])
        self.tv.modify_row([row[0],self.new_category_title,None,None])
    #item
    else:
      dlg = tree.get_widget("item_dlg")
      self.adjust_item_dlg(tree)
      i = self.db.fetchItem(row[0])
      self.item_title.set_text(common.strip_tags(row[1]))
      self.item_selling_price.set_text(str(roundPrice(i[2])))
      self.item_buying_price.set_text(str(roundPrice(i[3])))
      self.item_count.set_text(row[3])

      tree.get_widget("item_storno").connect('clicked',self.category_cancel_clicked,dlg,tree)
      tree.get_widget("item_ok").connect('clicked',self.item_ok_clicked,dlg,tree)
      self.data_ok = False
      dlg.connect('response',self.edit_item_dlg_response)
      r = dlg.run()
示例#7
0
	def __init__(self, ad):
		self.title = common.strip_tags(ad['Title'])
		self.url = common.strip_tags(ad['URL'])
		self.body = common.strip_tags(ad['Body'])
		self.cat = ad['cat']
		self.time = ad['Time']
		self.label = ad['Label']
示例#8
0
    def find_song_info(self, html):
        ret = True

        prefix = '<font color="#FFFFFF"><b>'
        suffix = "</b></font>"
        title = common.strip_tags(common.find_string_by_prefix_suffix(html, prefix, suffix)).strip()
        if title:
            self.title = title

        prefix = '<font size="-1" color="#FFFFFF">'
        suffix = "</font>"
        info = common.find_string_by_prefix_suffix(html, prefix, suffix)
        info = re.sub("     +", "", info)
        info = info.replace("\r", "").replace("\n", "")

        patterns = {"artist": u"歌:(.*?)/", "lyricist": u"詞:(.*?)/", "composer": u"曲:(.*?)<"}

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(info, pattern)
            if value:
                setattr(self, key, value)
            else:
                logging.info("Failed to get %s from info %s", key, info)
                return False

        return ret
示例#9
0
    def find_song_info(self, url):
        ret = True
        html = common.get_url_content(url)

        encoding = 'sjis'
        html = html.decode(encoding, 'ignore')

        patterns = {
            'title': u'<h2[^>]*>([^<]+)</h2>',
            'artist': u'歌手:<h3.*?><a href="/artist/[0-9]+/".*?>(.+?)</a></h3>',
            'lyricist': u'作詞:<h4.*?>([^<]+)</h4>',
            'composer': u'作曲:<h4.*?>([^<]+)</h4>'
        }

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(html, pattern)

            if not value:
                logging.info('Failed to get %s of url [%s]', key, url)
                ret = False
            else:
                value = common.unicode2string(common.strip_tags(value))
                setattr(self, key, value)

        return ret
示例#10
0
    def find_song_info(self, content):
#         content = content.decode('utf-8', 'ignore')

        pattern = u'<meta property="og:title" content="(.*?) 歌詞 \|'
        title = common.get_first_group_by_pattern(content, pattern)
        title = common.htmlspecialchars_decode(title)
        self.title = title

        pattern = u'<meta property="og:description" content="(.*?)が歌う'
        artist = common.get_first_group_by_pattern(content, pattern)
        artist = common.htmlspecialchars_decode(artist)
        self.artist = artist

        prefixes = {
            'lyricist': u'作詞</dt>',
            'composer': u'作曲</dt>',
        }
        suffix = '</dd>'

        for key in prefixes:
            prefix = prefixes[key]
            value = common.find_string_by_prefix_suffix(content, prefix, suffix, False)
            if value:
                value = common.strip_tags(value).strip()
                value = common.htmlspecialchars_decode(value)
                setattr(self, key, value)

        return True
示例#11
0
    def find_song_info(self, content):
        prefix = "<div id='lyricBlock'>"
        suffix = '</table>'
        info_block = common.find_string_by_prefix_suffix(content, prefix, suffix, False)

        prefix = '<h2>'
        suffix = '</h2>'
        title = common.find_string_by_prefix_suffix(info_block, prefix, suffix, False)

        self.title = common.htmlspecialchars_decode(common.unicode2string(title))

        patterns = {
            'artist': u'>歌:(.*?)</td>',
            'lyricist': u'>作詞:(.*?)</td>',
            'composer': u'>作曲:(.*?)</td>'
        }

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(info_block, pattern)
            if value:
                value = common.strip_tags(common.htmlspecialchars_decode(value)).strip()
                setattr(self, key, value)
            else:
                logging.debug('Failed to get %s, pattern: %s' % (key, pattern, ))

        return True
示例#12
0
 def __update(self):
   if self.__titles:
     text = ''
     for title in self.__titles:
       text +=  '/' + common.strip_tags(title)
     self.__label.set_text(text)
   else:
     self.__label.set_text('')
示例#13
0
    def find_lyric(self, html):
        prefix = '<div id="lyrics">'
        suffix = '</div>'
        rawLyric = common.get_string_by_start_end_string(prefix, suffix, html)

        rawLyric = rawLyric.replace('<br/>', '\n')
        rawLyric = common.unicode2string(rawLyric)
        rawLyric = common.strip_tags(rawLyric).strip()

        self.lyric = rawLyric

        return True
示例#14
0
    def get_lyric_1st_part(self, html):
        prefix = '<canvas id="lyrics" '
        suffix = '</canvas>'

        rawLyric = common.get_string_by_start_end_string(prefix, suffix, html)
        if not rawLyric:
            logging.info('Failed to get lyric string')
            return None
        encodedLyric = common.strip_tags(rawLyric)
        lyric_1st = common.unicode2string(encodedLyric)

        return lyric_1st
示例#15
0
    def find_lyric(self, html):
        prefix = '<div id="lyrics-body-text">'
        suffix = '</div>'
        rawLyric = common.get_string_by_start_end_string(prefix, suffix, html)

        rawLyric = rawLyric.replace('<br />', '\n')
        rawLyric = rawLyric.replace("<p class='verse'>", '\n\n')
        rawLyric = common.strip_tags(rawLyric).strip()

        self.lyric = rawLyric

        return True
示例#16
0
def content_for_search_index(annotated_obj):
    contents = []
    contents.append(annotated_obj.name)
    contents.append(" ".join(annotated_obj.name.split('.')))
    contents.append(annotated_obj.summary_html)
    contents.extend([e.name for e in annotated_obj.events])
    contents.extend([m.name for m in annotated_obj.methods])
    contents.extend([p.name for p in annotated_obj.properties])
    contents.extend([e["title"] for e in annotated_obj.examples_html])
    if len(annotated_obj.description_html) > 0:
        contents.append(annotated_obj.description_html)
    return strip_tags(" ".join(contents))
示例#17
0
def content_for_search_index(annotated_obj):
	contents = []
	contents.append(annotated_obj.name)
	contents.append(" ".join(annotated_obj.name.split('.')))
	contents.append(annotated_obj.summary_html)
	contents.extend([e.name for e in annotated_obj.events])
	contents.extend([m.name for m in annotated_obj.methods])
	contents.extend([p.name for p in annotated_obj.properties])
	contents.extend([e["title"] for e in annotated_obj.examples_html])
	if len(annotated_obj.description_html) > 0:
		contents.append(annotated_obj.description_html)
	return strip_tags(" ".join(contents))
示例#18
0
    def find_lyric(self, html):
        prefix = "<!--HPSTART-->"
        suffix = "<!--HPEND-->"

        body = common.find_string_by_prefix_suffix(html, prefix, suffix)
        body = re.sub("     +", "", body)
        body = body.replace("\r", "")
        body = body.replace("\n", "")
        body = body.replace("<br>", "\n")
        body = common.strip_tags(body).strip()

        self.lyric = body

        return True
示例#19
0
    def find_lyric(self, html):
        prefix = "<div class='lyricbox'>"
        suffix = '<!--'
        line = common.find_string_by_prefix_suffix(html, prefix, suffix, True)

        prefix = '</script>'
        suffix = '<!--'
        lyric = common.find_string_by_prefix_suffix(line, prefix, suffix, False)

        lyric = lyric.replace('<br />', '\n')
        lyric = common.unicode2string(lyric).strip()
        lyric = common.strip_tags(lyric).strip()

        self.lyric = lyric
        return True
示例#20
0
文件: kget.py 项目: omusico/lyric-get
    def parse_lyric(self, url, html):

        prefix = '<div id="lyric-trunk">'
        suffix = '</div>'
        lyric = common.get_string_by_start_end_string(prefix, suffix, html)
        if not lyric:
            logging.error('Failed to parse lyric')
            return False

        lyric = common.strip_tags(lyric)

        lyric = common.unicode2string(lyric).strip()

        self.lyric = lyric
        return True
示例#21
0
    def find_lyric(self, content):
#         content = content.decode('utf-8', 'ignore')

        prefix = '<div class="lyricBody">'
        suffix = '</div>'

        lyric = common.find_string_by_prefix_suffix(content, prefix, suffix)

        pattern = '<span class="rt">(.*?)</span>'
        lyric = re.sub(pattern, r'(\1)', lyric)
        lyric = common.strip_tags(lyric)
        lyric = lyric.strip()

        self.lyric = lyric
        
        return True
示例#22
0
    def find_song_info(self, url):
        ret = True
        html = common.get_url_content(url)

        encoding = 'utf-8'
        html = html.decode(encoding, 'ignore')

        pattern = '<h1>(.*)</h1>'
        value = common.get_first_group_by_pattern(html, pattern).strip()
        if value:
            self.title = value
        else:
            logging.error('Failed to find title of url [%s]', url)
            ret = False

        prefix = '<div class="person_list">'
        suffix = '</div>'
        info_table = common.find_string_by_prefix_suffix(html, prefix, suffix)

        patterns = {
            'artist': u'歌手',
            'lyricist': u'作詞者',
            'composer': u'作曲者',
            'arranger': u'編曲者',
        }

        for key in patterns:
            pattern = patterns[key]

            prefix = u'<th>%s</th>' % (pattern)
            suffix = '</td>'

            value = common.find_string_by_prefix_suffix(info_table, prefix, suffix, False)
            if not value:
                continue
            value = common.strip_tags(value).strip()
            if value:
                setattr(self, key, value)

        return ret
示例#23
0
    def find_song_info(self, content):
        pattern = 'og:description" content="(.*)"'
        og_desc = common.get_first_group_by_pattern(content, pattern)
        if og_desc:
            pattern = u'(.*?)「(.*?)」'
            matches = common.get_matches_by_pattern(og_desc, pattern)
            if matches:
                artist = matches.group(1)
                artist = artist.replace(u'歌詞サーチ ', '')
                self.artist = artist
                self.title  = matches.group(2)
            else:
                logging.debug('og desc: %s' % (og_desc))

        prefix = '="lyrics_info_text"'
        suffix = '</div>'
        info_text = common.find_string_by_prefix_suffix(content, prefix, suffix, False)
        if not info_text:
            logging.info('Failed to find lyrics info text')
        one_line = info_text.replace('\n', '')

        patterns = {
            'lyricist': u'>作詞</p><p class="info_detail">(.*?)</p>',
            'composer': u'>作曲</p><p class="info_detail">(.*?)</p>',
        }

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(one_line, pattern)
            if value:
                value = common.strip_tags(common.htmlspecialchars_decode(value)).strip()
                setattr(self, key, value)
            else:
                logging.debug('Failed to get %s, pattern: %s' % (key, pattern, ))

        return True