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

Side by Side Diff: tools/traffic_annotation/auditor/prepare_protobuf.py

Issue 2448133006: Tool added to extract network traffic annotations. (Closed)
Patch Set: Comments addressed. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """ This code is imported with modifications from
6 '//infra/recipes-py/recipe_engine/env.py' to import protobuf from third_party
7 directory instead of the one installed with current python libraries."""
8
9 import contextlib
10 import pkg_resources
11 import os
12 import sys
13
14
15 def PrepareProtobuf():
16 CHROME_SRC = os.path.abspath(
17 os.path.join(os.path.dirname(os.path.realpath(__file__)),
18 "..", "..", ".."))
19 THIRD_PARTY = os.path.join(CHROME_SRC, 'third_party')
20 sys.path.insert(0, os.path.join(THIRD_PARTY, 'protobuf', 'python'))
21 sys.path.insert(
22 1, os.path.join(THIRD_PARTY, 'protobuf', 'third_party', 'six'))
23
24 @contextlib.contextmanager
25 def temp_sys_path():
26 orig_path = sys.path[:]
27 try:
28 yield
29 finally:
30 sys.path = orig_path
31
32 with temp_sys_path():
33 sys.path = [THIRD_PARTY]
34 sys.modules.pop('google', None)
35 pkg_resources.declare_namespace('google')
36 pkg_resources.fixup_namespace_packages(THIRD_PARTY)
OLDNEW
« no previous file with comments | « tools/traffic_annotation/auditor/README.md ('k') | tools/traffic_annotation/auditor/traffic_annotation_auditor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698