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

Side by Side Diff: recipe_engine/config_types.py

Issue 2669033007: [recipe_engine] Fix a couple path-related bugs. (Closed)
Patch Set: Fix remainder of presubmit tests Created 3 years, 10 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
« no previous file with comments | « no previous file | recipe_engine/doc.py » ('j') | recipe_engine/doc.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import abc 5 import abc
6 import os 6 import os
7 import re 7 import re
8 8
9 from collections import namedtuple 9 from collections import namedtuple
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 def __eq__(self, other): 172 def __eq__(self, other):
173 return (self.base == other.base and 173 return (self.base == other.base and
174 self.pieces == other.pieces and 174 self.pieces == other.pieces and
175 self.platform_ext == other.platform_ext) 175 self.platform_ext == other.platform_ext)
176 176
177 def __ne__(self, other): 177 def __ne__(self, other):
178 return not self.base == other 178 return not self.base == other
179 179
180 def join(self, *pieces, **kwargs): 180 def join(self, *pieces, **kwargs):
181 if not pieces and not kwargs:
182 return self
181 kwargs.setdefault('platform_ext', self.platform_ext) 183 kwargs.setdefault('platform_ext', self.platform_ext)
182 return Path(self.base, *filter(bool, self.pieces + pieces), **kwargs) 184 return Path(self.base, *filter(bool, self.pieces + pieces), **kwargs)
183 185
184 def is_parent_of(self, child): 186 def is_parent_of(self, child):
185 """True if |child| is in a subdirectory of this path.""" 187 """True if |child| is in a subdirectory of this path."""
186 # Assumes base paths are not nested. 188 # Assumes base paths are not nested.
187 # TODO(vadimsh): We should not rely on this assumption. 189 # TODO(vadimsh): We should not rely on this assumption.
188 if self.base != child.base: 190 if self.base != child.base:
189 return False 191 return False
190 # A path is not a parent to itself. 192 # A path is not a parent to itself.
191 if len(self.pieces) >= len(child.pieces): 193 if len(self.pieces) >= len(child.pieces):
192 return False 194 return False
193 return child.pieces[:len(self.pieces)] == self.pieces 195 return child.pieces[:len(self.pieces)] == self.pieces
194 196
195 def __repr__(self): 197 def __repr__(self):
196 s = "Path(%r" % self.base 198 s = "Path(%r" % self.base
197 if self.pieces: 199 if self.pieces:
198 s += ", %s" % ",".join(repr(x) for x in self.pieces) 200 s += ", %s" % ",".join(repr(x) for x in self.pieces)
199 201
200 return s + ")" 202 return s + ")"
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/doc.py » ('j') | recipe_engine/doc.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698