Fetch blink component from crbug. Fixes #480
This commit is contained in:
Родитель
b5d53b165f
Коммит
6abd28890d
24
admin.py
24
admin.py
|
@ -26,7 +26,9 @@ import os
|
|||
import re
|
||||
import sys
|
||||
import webapp2
|
||||
import xml.dom.minidom
|
||||
from bs4 import BeautifulSoup
|
||||
from HTMLParser import HTMLParser
|
||||
from xml.dom import minidom
|
||||
|
||||
# Appengine imports.
|
||||
import cloudstorage
|
||||
|
@ -198,7 +200,7 @@ class HistogramsHandler(webapp2.RequestHandler):
|
|||
return
|
||||
|
||||
histograms_content = result.content.decode('base64')
|
||||
dom = xml.dom.minidom.parseString(histograms_content)
|
||||
dom = minidom.parseString(histograms_content)
|
||||
|
||||
# The enums.xml file looks like this:
|
||||
# <enum name="FeatureObserver">
|
||||
|
@ -243,6 +245,17 @@ class FeatureHandler(common.ContentHandler):
|
|||
param = int(param)
|
||||
return param
|
||||
|
||||
def __get_blink_component_from_bug(self, blink_components, bug_url):
|
||||
if blink_components[0] == models.BlinkComponent.DEFAULT_COMPONENT and bug_url:
|
||||
result = urlfetch.fetch(bug_url)
|
||||
if result.status_code == 200:
|
||||
soup = BeautifulSoup(result.content, 'html.parser')
|
||||
components = soup.find_all(string=re.compile('^Blink'))
|
||||
|
||||
h = HTMLParser()
|
||||
return [h.unescape(unicode(c)) for c in components]
|
||||
return blink_components
|
||||
|
||||
def get(self, path, feature_id=None):
|
||||
user = users.get_current_user()
|
||||
if user is None:
|
||||
|
@ -377,6 +390,13 @@ class FeatureHandler(common.ContentHandler):
|
|||
feature.sample_links = sample_links
|
||||
feature.search_tags = search_tags
|
||||
else:
|
||||
# Check bug for existing blink component(s) used to label the bug. If
|
||||
# found, use the first component name instead of the generic "Blink" name.
|
||||
try:
|
||||
blink_components = self.__get_blink_component_from_bug(blink_components, bug_url)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
feature = models.Feature(
|
||||
category=int(self.request.get('category')),
|
||||
name=self.request.get('name'),
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
"deps": "rm -rf static/bower_components && bower install && pip install -t lib -r requirements.txt",
|
||||
"lint": "gulp lint",
|
||||
"build": "gulp",
|
||||
"deploy": "./scripts/deploy_site.sh"
|
||||
"deploy": "./scripts/deploy_site.sh",
|
||||
"start": "./scripts/start_server.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Django==1.4
|
||||
beautifulsoup4
|
Загрузка…
Ссылка в новой задаче