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

Unified Diff: third_party/gsutil/gslib/plurality_checkable_iterator.py

Issue 2280023003: depot_tools: Remove third_party/gsutil (Closed)
Patch Set: Created 4 years, 4 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 | « third_party/gsutil/gslib/no_op_auth_plugin.py ('k') | third_party/gsutil/gslib/project_id.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/gslib/plurality_checkable_iterator.py
diff --git a/third_party/gsutil/gslib/plurality_checkable_iterator.py b/third_party/gsutil/gslib/plurality_checkable_iterator.py
deleted file mode 100644
index a24b93b1efb0ce2756450e2b8764131123e7f955..0000000000000000000000000000000000000000
--- a/third_party/gsutil/gslib/plurality_checkable_iterator.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2012 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-Iterator wrapper that allows you to check whether the wrapped iterator
-is empty and whether it has more than 1 element.
-"""
-
-class PluralityCheckableIterator(object):
-
- def __init__(self, it):
- self.it = it.__iter__()
- self.head = []
- # Populate first 2 elems into head so we can check whether iterator has
- # more than 1 item.
- for i in range(0, 2):
- self.__populate_head__()
-
- def __populate_head__(self):
- try:
- e = self.it.next()
- self.underlying_iter_empty = False
- self.head.append(e)
- except StopIteration:
- # Indicates we can no longer call next() on underlying iterator, but
- # there could still be elements left to iterate in head.
- self.underlying_iter_empty = True
-
- def __iter__(self):
- while len(self.head) > 0:
- yield self.next()
- else:
- raise StopIteration()
-
- def next(self):
- # Backfill into head each time we pop an element so we can always check
- # for emptiness and for has_plurality().
- self.__populate_head__()
- return self.head.pop(0)
-
- def is_empty(self):
- return len(self.head) == 0
-
- def has_plurality(self):
- return len(self.head) > 1
« no previous file with comments | « third_party/gsutil/gslib/no_op_auth_plugin.py ('k') | third_party/gsutil/gslib/project_id.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698