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

Unified Diff: reviewbot/util.py

Issue 23531026: Remove the review bot app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 3 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 | « reviewbot/third_party/google-api-python-client/uritemplate/__init__.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: reviewbot/util.py
===================================================================
--- reviewbot/util.py (revision 221173)
+++ reviewbot/util.py (working copy)
@@ -1,95 +0,0 @@
-# Copyright (c) 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import collections
-import email.utils
-
-
-def lazy_property(func):
- """A decorator for lazy properties."""
- name = '__lazy_' + func.__name__
-
- def get_property(self, *args, **kwargs):
- if not hasattr(self, name):
- setattr(self, name, func(self, *args, **kwargs))
- return getattr(self, name)
-
- return property(get_property)
-
-
-class LazyDict(collections.Mapping):
- """A simple immutable and lazy dictionary.
-
- This looks up the actual key values on first access to the key and caches the
- value to speed up subsequent accesses.
- """
-
- def __init__(self, lookup_fn):
- self.items = {}
- self.lookup = lookup_fn
-
- def __getitem__(self, name):
- if name not in self.items.keys():
- self.items[name] = self.lookup(name)
- return self.items[name]
-
- def __iter__(self):
- return self.items.iterkeys()
-
- def __len__(self):
- return len(self.items)
-
- def __repr__(self):
- return repr(self.items)
-
-
-class ObjectDict(collections.Mapping):
- """Wraps a dictionary to allow value retrieval in dot notation."""
-
- def __init__(self, data):
- self.__data = data
-
- def __getitem__(self, name):
- val = self.__data[name]
- return ObjectDict.wrap(val)
-
- def __getattr__(self, name):
- try:
- return self[name]
- except KeyError as e:
- raise AttributeError(e)
-
- def __iter__(self):
- return self.__data.iterkeys()
-
- def __len__(self):
- return len(self.__data)
-
- def __repr__(self):
- return repr(self.__data)
-
- @staticmethod
- def wrap(val):
- if isinstance(val, dict):
- return ObjectDict(val)
- return val
-
-
-def get_emails(string):
- """Normalizes a string containing a list of email recepients.
-
- Takes a string in the format present in mail headers and returns a list of
- email addresses. For example, the input
- 'test@example.com, committers <committers@chromium.org>
- will produce this return value:
- [ 'test@example.com', 'committers@chromium.org' ]
- """
- return [entry[1] for entry in email.utils.getaddresses([string])]
-
-
-def canonicalize_email(address):
- """Takes an email address and returns its canonicalized form."""
- emails = get_emails(address)
- assert len(emails) == 1
- return emails[0]
« no previous file with comments | « reviewbot/third_party/google-api-python-client/uritemplate/__init__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698