Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: scripts/slave/recipe_modules/luci_config/api.py

Issue 2064453002: add recipe continuous builders for each repo with recipes (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Fix presubmit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « masters/master.chromium.infra/slaves.cfg ('k') | scripts/slave/recipe_modules/luci_config/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/luci_config/api.py
diff --git a/scripts/slave/recipe_modules/luci_config/api.py b/scripts/slave/recipe_modules/luci_config/api.py
index 5ccd0f39ad2f3b37e420c8c9e6d0ea8309547519..b265f73c79f4921b31a020895fa979210a680b68 100644
--- a/scripts/slave/recipe_modules/luci_config/api.py
+++ b/scripts/slave/recipe_modules/luci_config/api.py
@@ -5,6 +5,8 @@
from recipe_engine import recipe_api
import base64
+import collections
+import re
import json
class LuciConfigApi(recipe_api.RecipeApi):
@@ -71,3 +73,54 @@ class LuciConfigApi(recipe_api.RecipeApi):
result = json.loads(fetch_result)
result['content'] = base64.b64decode(result['content'])
return result
+
+ def parse_textproto(self, lines):
+ """(badly) parses a text protobuf.
+
+ This is not real protobuf parsing at the moment; eventually, maybe it could
dsansome-google 2017/03/03 03:48:24 ಠ_ಠ
iannucci1 2017/03/03 05:15:30 Yep, getting a protobuf library into all the envir
+ be. For now, it's enough to just get by.
+
+ We assume all fields are repeated since we don't have a proto spec to work
+ with.
+
+ Args:
+ lines: a list of the lines to parse
+ Returns:
+ A recursive dictionary of lists.
+ """
+ def parse_atom(text):
+ # NOTE: Assuming we only have numbers and strings to avoid using
+ # ast.literal_eval
+ try:
+ return int(text)
+ except ValueError:
+ return text.strip("'").strip('"')
+
+ ret = {}
+ while lines:
+ line = lines.pop(0).strip()
+
+ m = re.match(r'(\w+)\s*:\s*(.*)', line)
+ if m:
+ ret.setdefault(m.group(1), []).append(parse_atom(m.group(2)))
+ continue
+
+ m = re.match(r'(\w+)\s*{', line)
+ if m:
+ subparse = self.parse_textproto(lines)
+ ret.setdefault(m.group(1), []).append(subparse)
+ continue
+
+ if line == '}':
+ return ret
+ if line == '':
+ continue
+
+ raise ValueError(
+ 'Could not understand line: <%s>' % line) # pragma: no cover
+ return ret
+
+ def get_project_metadata(self, project):
+ mapping = self.get_projects()
+ return mapping.get(project)
+
« no previous file with comments | « masters/master.chromium.infra/slaves.cfg ('k') | scripts/slave/recipe_modules/luci_config/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698