← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/delete-more into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/delete-more into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/delete-more/+merge/75179

Delete some unused code from canonical.*.
-- 
https://code.launchpad.net/~wgrant/launchpad/delete-more/+merge/75179
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/delete-more into lp:launchpad.
=== removed file 'lib/canonical/launchpad/components/storm_operators.py'
--- lib/canonical/launchpad/components/storm_operators.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/components/storm_operators.py	1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Operators and functions for Storm queries that are not in Storm.
-
-You can use these to do FTI queries like this:
-
-    >>> search_vector_column = <table.column>
-    >>> query_function = FTQ(search_term)
-    >>> rank = RANK(search_vector_column, query_function)
-    >>> select_spec = <required_columns, rank>
-    >>> results = store.find(
-    ...     (select_spec),
-    ...     Match(search_vector_column, query_function))
-    >>> results.order_by(Desc(rank))
-
-"""
-
-__metaclass__ = type
-
-__all__ = [
-    'FTQ',
-    'Match',
-    'RANK',
-    ]
-
-from storm.expr import (
-    CompoundOper,
-    NamedFunc,
-    )
-
-
-class FTQ(NamedFunc):
-    """Full Text Query function.
-
-    Implements the PostgreSQL ftq() function: ftq(search_string)
-    Returns a ts_query
-    """
-    __slots__ = ()
-    name = "FTQ"
-
-
-class RANK(NamedFunc):
-    """Full text rank function.
-
-    Implements the PostgreSQL ts_rank() function:
-    ts_rank(
-        [ weights float4[], ]
-        vector tsvector,
-        query tsquery [,
-        normalization integer ])
-
-    Returns a float4.
-    """
-    __slots__ = ()
-    name = "TS_RANK"
-
-
-class Match(CompoundOper):
-    """Full text match operator.
-
-    The full text match operator is used to compare a compiled search
-    (tsquery) expression to a text search vector (tsvector). In PostgreSQL, the
-    operator returns a "true" value if the tsvector matches the tsquery.
-    """
-    __slots__ = ()
-    oper = "@@"
-

=== modified file 'lib/canonical/launchpad/configure.zcml'
--- lib/canonical/launchpad/configure.zcml	2011-07-07 19:41:46 +0000
+++ lib/canonical/launchpad/configure.zcml	2011-09-13 13:37:24 +0000
@@ -12,7 +12,6 @@
 
   <include package="canonical.launchpad.webapp" />
   <include package="canonical.launchpad.vocabularies" />
-  <include file="links.zcml" />
   <include package="canonical.launchpad.zcml" />
   <authorizations module="canonical.launchpad.security" />
   <include package="canonical.launchpad.xmlrpc" />

=== removed file 'lib/canonical/launchpad/datetimeutils.py'
--- lib/canonical/launchpad/datetimeutils.py	2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/datetimeutils.py	1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Various functions that are useful for handling dates/datetimes."""
-
-__metaclass__ = type
-
-from datetime import (
-    date,
-    timedelta,
-    )
-
-
-def make_mondays_between(start, end):
-    """Iteration of dates that are mondays between start and end dates.
-
-    A friday to a monday.
-
-    >>> for monday in make_mondays_between(
-    ...         date(2005, 11, 25), date(2006, 1, 9)):
-    ...     print monday.isocalendar()
-    (2005, 48, 1)
-    (2005, 49, 1)
-    (2005, 50, 1)
-    (2005, 51, 1)
-    (2005, 52, 1)
-    (2006, 1, 1)
-    (2006, 2, 1)
-
-    Test from Tuesday to Monday.
-
-    >>> for day in range(22, 30):
-    ...     mondays = make_mondays_between(
-    ...         date(2005, 11, day), date(2005, 12, day))
-    ...     print date(2005, 11, day).isocalendar(), mondays.next().isoformat()
-    (2005, 47, 2) 2005-11-28
-    (2005, 47, 3) 2005-11-28
-    (2005, 47, 4) 2005-11-28
-    (2005, 47, 5) 2005-11-28
-    (2005, 47, 6) 2005-11-28
-    (2005, 47, 7) 2005-11-28
-    (2005, 48, 1) 2005-11-28
-    (2005, 48, 2) 2005-12-05
-    """
-    assert isinstance(start, date)
-    assert isinstance(end, date)
-    mondaystart = start + timedelta(days=(8 - start.isoweekday()) % 7)
-    currentdate = mondaystart
-    while currentdate <= end:
-        yield currentdate
-        currentdate += timedelta(days=7)
-
-def get_date_for_monday(year, week):
-    """Return the date of monday for the given iso week in the given year.
-
-    >>> get_date_for_monday(2005, 48).isoformat()
-    '2005-11-28'
-    >>> get_date_for_monday(2005, 50).isoformat()
-    '2005-12-12'
-    >>> get_date_for_monday(2005, 51).isoformat()
-    '2005-12-19'
-    >>> get_date_for_monday(2005, 52).isoformat()
-    '2005-12-26'
-    >>> get_date_for_monday(2005, 53).isoformat()
-    '2006-01-02'
-    >>> get_date_for_monday(2005, 54).isoformat()
-    '2006-01-09'
-    >>> get_date_for_monday(2006, 1).isoformat()
-    '2006-01-02'
-    >>> get_date_for_monday(2006, 2).isoformat()
-    '2006-01-09'
-    """
-    first_monday = first_monday_in_year(year)
-    fm_y, fm_w, fm_d = first_monday.isocalendar()
-    weeks_to_add = week - fm_w
-    assert weeks_to_add >= 0
-    return first_monday + timedelta(weeks=weeks_to_add)
-
-def first_monday_in_year(year):
-    """Return the date of the first monday in the year.
-
-    >>> for year in range(1999, 2009):
-    ...     first_monday_in_year(year).isoformat()
-    '1999-01-04'
-    '2000-01-03'
-    '2001-01-01'
-    '2002-01-07'
-    '2003-01-06'
-    '2004-01-05'
-    '2005-01-03'
-    '2006-01-02'
-    '2007-01-01'
-    '2008-01-07'
-    """
-    return date(year, 1, (8 - date(year, 1, 1).isoweekday()) % 7 + 1)
-

=== modified file 'lib/canonical/launchpad/doc/helpers.txt'
--- lib/canonical/launchpad/doc/helpers.txt	2009-01-13 16:56:48 +0000
+++ lib/canonical/launchpad/doc/helpers.txt	2011-09-13 13:37:24 +0000
@@ -5,35 +5,6 @@
 duplicating code in different parts of Launchpad.
 
 
-== Getting a valid name as our database asks for from a string ==
-
-    >>> from canonical.launchpad.helpers import getValidNameFromString
-
-The string has capital letters.
-
-    >>> original_string = 'EvilStringNotFollowingOurRules'
-    >>> getValidNameFromString(original_string)
-    'evilstringnotfollowingourrules'
-
-The string has underscores.
-
-    >>> original_string = 'evil_string_not_following_our_rules'
-    >>> getValidNameFromString(original_string)
-    'evil-string-not-following-our-rules'
-
-The string has white spaces.
-
-    >>> original_string = 'evil string not following our rules'
-    >>> getValidNameFromString(original_string)
-    'evil-string-not-following-our-rules'
-
-A mix of all previous cases.
-
-    >>> original_string = 'Evil String Not_Following_our rUles'
-    >>> getValidNameFromString(original_string)
-    'evil-string-not-following-our-rules'
-
-
 == Concatenating lists English-style ==
 
 The english_list function takes a list of strings and concatenates

=== modified file 'lib/canonical/launchpad/helpers.py'
--- lib/canonical/launchpad/helpers.py	2011-06-08 05:43:21 +0000
+++ lib/canonical/launchpad/helpers.py	2011-09-13 13:37:24 +0000
@@ -12,7 +12,6 @@
 
 from difflib import unified_diff
 import os
-import random
 import re
 from StringIO import StringIO
 import subprocess
@@ -95,83 +94,12 @@
     return str.decode('UTF-8').encode('ASCII', 'backslashreplace')
 
 
-def join_lines(*lines):
-    """Concatenate a list of strings, adding a newline at the end of each."""
-
-    return ''.join([x + '\n' for x in lines])
-
-
 def string_to_tarfile(s):
     """Convert a binary string containing a tar file into a tar file obj."""
 
     return tarfile.open('', 'r', StringIO(s))
 
 
-def shortest(sequence):
-    """Return a list with the shortest items in sequence.
-
-    Return an empty list if the sequence is empty.
-    """
-    shortest_list = []
-    shortest_length = None
-
-    for item in list(sequence):
-        new_length = len(item)
-
-        if shortest_length is None:
-            # First item.
-            shortest_list.append(item)
-            shortest_length = new_length
-        elif new_length == shortest_length:
-            # Same length than shortest item found, we append it to the list.
-            shortest_list.append(item)
-        elif min(new_length, shortest_length) != shortest_length:
-            # Shorter than our shortest length found, discard old values.
-            shortest_list = [item]
-            shortest_length = new_length
-
-    return shortest_list
-
-
-def getRosettaBestBinaryPackageName(sequence):
-    """Return the best binary package name from a list.
-
-    It follows the Rosetta policy:
-
-    We don't need a concrete value from binary package name, we use shortest
-    function as a kind of heuristic to choose the shortest binary package
-    name that we suppose will be the more descriptive one for our needs with
-    PO templates. That's why we get always the first element.
-    """
-    return shortest(sequence)[0]
-
-
-def getRosettaBestDomainPath(sequence):
-    """Return the best path for a concrete .pot file from a list of paths.
-
-    It follows the Rosetta policy for this path:
-
-    We don't need a concrete value from domain_paths list, we use shortest
-    function as a kind of heuristic to choose the shortest path if we have
-    more than one, usually, we will have only one element.
-    """
-    return shortest(sequence)[0]
-
-
-def getValidNameFromString(invalid_name):
-    """Return a valid name based on a string.
-
-    A name in launchpad has a set of restrictions that not all strings follow.
-    This function converts any string in another one that follows our name
-    restriction rules.
-
-    To know more about all restrictions, please, look at valid_name function
-    in the database.
-    """
-    # All chars should be lower case, underscores and spaces become dashes.
-    return text_replaced(invalid_name.lower(), {'_': '-', ' ': '-'})
-
-
 def browserLanguages(request):
     """Return a list of Language objects based on the browser preferences."""
     return IRequestPreferredLanguages(request).getPreferredLanguages()
@@ -214,36 +142,6 @@
         for mail_person in get_recipients(person))
 
 
-replacements = {0: {'.': ' |dot| ',
-                    '@': ' |at| '},
-                1: {'.': ' ! ',
-                    '@': ' {} '},
-                2: {'.': ' , ',
-                    '@': ' % '},
-                3: {'.': ' (!) ',
-                    '@': ' (at) '},
-                4: {'.': ' {dot} ',
-                    '@': ' {at} '},
-                }
-
-
-def obfuscateEmail(emailaddr, idx=None):
-    """Return an obfuscated version of the provided email address.
-
-    Randomly chose a set of replacements for some email address characters and
-    replace them. This will make harder for email harvesters to fetch email
-    address from launchpad.
-
-    >>> obfuscateEmail('foo@xxxxxxx', 0)
-    'foo |at| bar |dot| com'
-    >>> obfuscateEmail('foo.bar@xxxxxxxxxx', 1)
-    'foo ! bar {} xyz ! com ! br'
-    """
-    if idx is None:
-        idx = random.randint(0, len(replacements) - 1)
-    return text_replaced(emailaddr, replacements[idx])
-
-
 class ShortListTooBigError(Exception):
     """This error is raised when the shortlist hardlimit is reached"""
 
@@ -433,30 +331,6 @@
         return 0
 
 
-def positiveIntOrZero(value):
-    """Return 0 if int(value) fails or if int(value) is less than 0.
-
-    Return int(value) otherwise.
-
-    >>> positiveIntOrZero(None)
-    0
-    >>> positiveIntOrZero(-9)
-    0
-    >>> positiveIntOrZero(1)
-    1
-    >>> positiveIntOrZero('-3')
-    0
-    >>> positiveIntOrZero('5')
-    5
-    >>> positiveIntOrZero(3.1415)
-    3
-    """
-    value = intOrZero(value)
-    if value < 0:
-        return 0
-    return value
-
-
 def get_email_template(filename, app=None):
     """Returns the email template with the given file name.
 

=== removed file 'lib/canonical/launchpad/links.zcml'
--- lib/canonical/launchpad/links.zcml	2009-07-13 18:15:02 +0000
+++ lib/canonical/launchpad/links.zcml	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-<!-- Copyright 2009 Canonical Ltd.  This software is licensed under the
-     GNU Affero General Public License version 3 (see the file LICENSE).
--->
-
-<configure xmlns:browser="http://namespaces.zope.org/browser";>
-
-</configure>

=== removed directory 'lib/canonical/launchpad/locales'
=== removed file 'lib/canonical/launchpad/tests/test_datetimeutils.py'
--- lib/canonical/launchpad/tests/test_datetimeutils.py	2010-10-12 01:11:41 +0000
+++ lib/canonical/launchpad/tests/test_datetimeutils.py	1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-from doctest import DocTestSuite
-
-from canonical.launchpad import datetimeutils
-
-
-def test_suite():
-    return DocTestSuite(datetimeutils)

=== modified file 'lib/canonical/launchpad/tests/test_helpers.py'
--- lib/canonical/launchpad/tests/test_helpers.py	2011-03-30 20:08:42 +0000
+++ lib/canonical/launchpad/tests/test_helpers.py	2011-09-13 13:37:24 +0000
@@ -2,6 +2,7 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from doctest import DocTestSuite
+from textwrap import dedent
 import unittest
 
 from zope.interface import implements
@@ -67,17 +68,17 @@
     '# Test PO file.\n'
     '''
 
-    pot = helpers.join_lines(
-        '# Test POT file.',
-        'msgid "foo"',
-        'msgstr ""',
-        ),
+    pot = dedent("""
+        # Test POT file.
+        msgid "foo"
+        msgstr ""
+        """).strip()
 
-    po = helpers.join_lines(
-        '# Test PO file.',
-        'msgid "foo"',
-        'msgstr "bar"',
-        )
+    po = dedent("""
+        # Test PO file.
+        msgid "foo"
+        msgstr "bar"
+        """).strip()
 
     return LaunchpadWriteTarFile.files_to_tarfile({
         'test/test.pot': pot,
@@ -86,22 +87,6 @@
     })
 
 
-def test_join_lines():
-    r"""
-    >>> helpers.join_lines('foo', 'bar', 'baz')
-    'foo\nbar\nbaz\n'
-    """
-
-
-def test_shortest():
-    """
-    >>> helpers.shortest(['xyzzy', 'foo', 'blah'])
-    ['foo']
-    >>> helpers.shortest(['xyzzy', 'foo', 'bar'])
-    ['foo', 'bar']
-    """
-
-
 class DummyLanguage:
 
     def __init__(self, code, pluralforms):