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

Side by Side Diff: third_party/py_vulcanize/py_vulcanize/style_sheet.py

Issue 1376953005: Move tracing/third_party/tvcm -> third_party/py_vulcanize. (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 5 years, 2 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
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import base64 5 import base64
6 import os 6 import os
7 import re 7 import re
8 8
9 9
10 class Image(object): 10 class Image(object):
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 def _Load(self, containing_dirname): 68 def _Load(self, containing_dirname):
69 if self.contents.find('@import') != -1: 69 if self.contents.find('@import') != -1:
70 raise Exception('@imports are not supported') 70 raise Exception('@imports are not supported')
71 71
72 matches = re.findall( 72 matches = re.findall(
73 'url\((?:["|\']?)([^"\'()]*)(?:["|\']?)\)', 73 'url\((?:["|\']?)([^"\'()]*)(?:["|\']?)\)',
74 self.contents) 74 self.contents)
75 75
76 def resolve_url(url): 76 def resolve_url(url):
77 if os.path.isabs(url): 77 if os.path.isabs(url):
78 # FIXME: module is used here, but tvcm.module is never imported. 78 # FIXME: module is used here, but py_vulcanize.module is never imported.
79 # However, tvcm.module cannot be imported since tvcm.module may import 79 # However, py_vulcanize.module cannot be imported since py_vulcanize.mod ule may import
80 # style_sheet, leading to an import loop. 80 # style_sheet, leading to an import loop.
81 raise module.DepsException('URL references must be relative') 81 raise module.DepsException('URL references must be relative')
82 # URLS are relative to this module's directory 82 # URLS are relative to this module's directory
83 abs_path = os.path.abspath(os.path.join(containing_dirname, url)) 83 abs_path = os.path.abspath(os.path.join(containing_dirname, url))
84 image = self.loader.LoadImage(abs_path) 84 image = self.loader.LoadImage(abs_path)
85 image.aliases.append(url) 85 image.aliases.append(url)
86 return image 86 return image
87 87
88 self._images = [resolve_url(x) for x in matches] 88 self._images = [resolve_url(x) for x in matches]
89 89
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 def load(self): 128 def load(self):
129 self._InitParsedStyleSheetIfNeeded() 129 self._InitParsedStyleSheetIfNeeded()
130 130
131 def _InitParsedStyleSheetIfNeeded(self): 131 def _InitParsedStyleSheetIfNeeded(self):
132 if self._parsed_style_sheet: 132 if self._parsed_style_sheet:
133 return 133 return
134 module_dirname = os.path.dirname(self.resource.absolute_path) 134 module_dirname = os.path.dirname(self.resource.absolute_path)
135 self._parsed_style_sheet = ParsedStyleSheet( 135 self._parsed_style_sheet = ParsedStyleSheet(
136 self.loader, module_dirname, self.contents) 136 self.loader, module_dirname, self.contents)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698