labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1519467 - in /labs/panopticon: bin/check-email src/asf/data/ src/asf/data/__init__.py src/asf/data/aliases.py src/asf/utils/emails.py tests/test_emails.py
Date Mon, 02 Sep 2013 16:23:19 GMT
Author: adc
Date: Mon Sep  2 16:23:18 2013
New Revision: 1519467

URL: http://svn.apache.org/r1519467
Log:
Refactoring data sources into a data package

Added:
    labs/panopticon/src/asf/data/
    labs/panopticon/src/asf/data/__init__.py
    labs/panopticon/src/asf/data/aliases.py
      - copied, changed from r1519344, labs/panopticon/src/asf/utils/emails.py
Modified:
    labs/panopticon/bin/check-email
    labs/panopticon/src/asf/utils/emails.py
    labs/panopticon/tests/test_emails.py

Modified: labs/panopticon/bin/check-email
URL: http://svn.apache.org/viewvc/labs/panopticon/bin/check-email?rev=1519467&r1=1519466&r2=1519467&view=diff
==============================================================================
--- labs/panopticon/bin/check-email (original)
+++ labs/panopticon/bin/check-email Mon Sep  2 16:23:18 2013
@@ -21,8 +21,9 @@
 Mailing list moderator tool.
 """
 from asf.cli import entrypoint
+from asf.data.aliases import get_mail_aliases
 from asf.utils.committers import get_committer
-from asf.utils.emails import email_from_alias, is_apache_email_address, username_from_apache_email,
get_mail_aliases
+from asf.utils.emails import email_from_alias, is_apache_email_address, username_from_apache_email
 
 
 def cmd_lookup(args):

Added: labs/panopticon/src/asf/data/__init__.py
URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/data/__init__.py?rev=1519467&view=auto
==============================================================================
--- labs/panopticon/src/asf/data/__init__.py (added)
+++ labs/panopticon/src/asf/data/__init__.py Mon Sep  2 16:23:18 2013
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#

Copied: labs/panopticon/src/asf/data/aliases.py (from r1519344, labs/panopticon/src/asf/utils/emails.py)
URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/data/aliases.py?p2=labs/panopticon/src/asf/data/aliases.py&p1=labs/panopticon/src/asf/utils/emails.py&r1=1519344&r2=1519467&rev=1519467&view=diff
==============================================================================
--- labs/panopticon/src/asf/utils/emails.py (original)
+++ labs/panopticon/src/asf/data/aliases.py Mon Sep  2 16:23:18 2013
@@ -16,57 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-"""
-Provides access to https://id.apache.org/info/MailAlias.txt.
-"""
 from collections import defaultdict
+from restkit import Resource, BasicAuth
 
-from restkit import BasicAuth, Resource
-from brownie.caching import memoize
+from asf.utils.emails import canonical_email_address
 
 
 MAIL_ALIAS_URL = 'https://id.apache.org/info/MailAlias.txt'
 
 
-@memoize
-def canonical_email_address(email):
-    if '@' in email:
-        local, domain = email.split('@')
-        return '%s@%s' % (local, domain.lower())
-    else:
-        return email
-
-
-@memoize
-def is_apache_email_address(email):
-    return canonical_email_address(email).endswith('@apache.org')
-
-
-@memoize
-def username_from_apache_email(email):
-    if not is_apache_email_address(email):
-        raise ValueError('%s is not a valid Apache Software Foundation email' % email)
-
-    return email.split('@')[0]
-
-
-def aliases_for(apache_email, mail_aliases):
-    apache_email = canonical_email_address(apache_email)
-    if apache_email in mail_aliases:
-        return mail_aliases[apache_email]['aliases']
-    else:
-        raise ValueError('%s is not in the mail aliases file' % apache_email)
-
-
-def email_from_alias(alias_email, mail_aliases):
-    alias_email = canonical_email_address(alias_email)
-    for apache_email_address, data in mail_aliases.iteritems():
-        if alias_email in data['aliases']:
-            return apache_email_address
-    return None
-
-
 def get_mail_aliases(username, password):
+    """ Obtain the set of member emails and their email aliases
+    :param username: the username to use to access the emails and aliases
+    :param password: the password for the username
+    :return: the set of member emails and their email aliases
+    """
     mail_aliases = defaultdict(dict)
     for line in Resource(MAIL_ALIAS_URL, filters=[BasicAuth(username, password)], timeout=10).get().body_stream():
         apache_email, alias_email, member = [canonical_email_address(field.strip()) for field
in line.split(',')]

Modified: labs/panopticon/src/asf/utils/emails.py
URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/utils/emails.py?rev=1519467&r1=1519466&r2=1519467&view=diff
==============================================================================
--- labs/panopticon/src/asf/utils/emails.py (original)
+++ labs/panopticon/src/asf/utils/emails.py Mon Sep  2 16:23:18 2013
@@ -25,9 +25,6 @@ from restkit import BasicAuth, Resource
 from brownie.caching import memoize
 
 
-MAIL_ALIAS_URL = 'https://id.apache.org/info/MailAlias.txt'
-
-
 @memoize
 def canonical_email_address(email):
     if '@' in email:
@@ -64,15 +61,3 @@ def email_from_alias(alias_email, mail_a
         if alias_email in data['aliases']:
             return apache_email_address
     return None
-
-
-def get_mail_aliases(username, password):
-    mail_aliases = defaultdict(dict)
-    for line in Resource(MAIL_ALIAS_URL, filters=[BasicAuth(username, password)], timeout=10).get().body_stream():
-        apache_email, alias_email, member = [canonical_email_address(field.strip()) for field
in line.split(',')]
-        mail_aliases[apache_email]['member'] = bool(member)
-        if 'aliases' not in mail_aliases[apache_email]:
-            mail_aliases[apache_email]['aliases'] = set()
-        mail_aliases[apache_email]['aliases'].add(alias_email)
-
-    return mail_aliases

Modified: labs/panopticon/tests/test_emails.py
URL: http://svn.apache.org/viewvc/labs/panopticon/tests/test_emails.py?rev=1519467&r1=1519466&r2=1519467&view=diff
==============================================================================
--- labs/panopticon/tests/test_emails.py (original)
+++ labs/panopticon/tests/test_emails.py Mon Sep  2 16:23:18 2013
@@ -18,7 +18,8 @@
 #
 from nose.plugins.attrib import attr
 
-from asf.utils.emails import aliases_for, email_from_alias, canonical_email_address, is_apache_email_address,
get_mail_aliases
+from asf.data.aliases import get_mail_aliases
+from asf.utils.emails import aliases_for, email_from_alias, canonical_email_address, is_apache_email_address
 from asf.utils.test import ensure_credentials_stored
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message