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

Side by Side Diff: recipe_engine/config_types.py

Issue 2829273002: Fix Path.__ne__ (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 self.base = base 168 self.base = base
169 self.pieces = pieces 169 self.pieces = pieces
170 self.platform_ext = kwargs.get('platform_ext', {}) 170 self.platform_ext = kwargs.get('platform_ext', {})
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 == other
179 179
180 def join(self, *pieces, **kwargs): 180 def join(self, *pieces, **kwargs):
181 if not pieces and not kwargs: 181 if not pieces and not kwargs:
182 return self 182 return self
183 kwargs.setdefault('platform_ext', self.platform_ext) 183 kwargs.setdefault('platform_ext', self.platform_ext)
184 return Path(self.base, *filter(bool, self.pieces + pieces), **kwargs) 184 return Path(self.base, *filter(bool, self.pieces + pieces), **kwargs)
185 185
186 def is_parent_of(self, child): 186 def is_parent_of(self, child):
187 """True if |child| is in a subdirectory of this path.""" 187 """True if |child| is in a subdirectory of this path."""
188 # Assumes base paths are not nested. 188 # Assumes base paths are not nested.
189 # TODO(vadimsh): We should not rely on this assumption. 189 # TODO(vadimsh): We should not rely on this assumption.
190 if self.base != child.base: 190 if self.base != child.base:
191 return False 191 return False
192 # A path is not a parent to itself. 192 # A path is not a parent to itself.
193 if len(self.pieces) >= len(child.pieces): 193 if len(self.pieces) >= len(child.pieces):
194 return False 194 return False
195 return child.pieces[:len(self.pieces)] == self.pieces 195 return child.pieces[:len(self.pieces)] == self.pieces
196 196
197 def __repr__(self): 197 def __repr__(self):
198 s = "Path(%r" % self.base 198 s = "Path(%r" % self.base
199 if self.pieces: 199 if self.pieces:
200 s += ", %s" % ",".join(repr(x) for x in self.pieces) 200 s += ", %s" % ",".join(repr(x) for x in self.pieces)
201 201
202 return s + ")" 202 return s + ")"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698