← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:unused-classes into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:unused-classes into launchpad:master.

Commit message:
Remove several unused classes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396736
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:unused-classes into launchpad:master.
diff --git a/lib/lp/answers/tests/test_question_notifications.py b/lib/lp/answers/tests/test_question_notifications.py
index 184b254..1ac77ee 100644
--- a/lib/lp/answers/tests/test_question_notifications.py
+++ b/lib/lp/answers/tests/test_question_notifications.py
@@ -69,13 +69,6 @@ class StubQuestion:
         self.messages = []
 
 
-class StubQuestionMessage:
-    """Question message with only a subject attribute."""
-
-    def __init__(self, subject='Message subject'):
-        self.subject = subject
-
-
 @implementer(IPerson)
 class FakeUser:
     """A fake user."""
diff --git a/lib/lp/app/widgets/textwidgets.py b/lib/lp/app/widgets/textwidgets.py
index 4532762..f4dd12c 100644
--- a/lib/lp/app/widgets/textwidgets.py
+++ b/lib/lp/app/widgets/textwidgets.py
@@ -1,24 +1,16 @@
 # Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-import datetime
 import re
 
-import pytz
 import six
 from zope.browserpage import ViewPageTemplateFile
-from zope.datetime import (
-    DateTimeError,
-    parse,
-    )
-from zope.formlib.interfaces import ConversionError
 from zope.formlib.textwidgets import (
     TextAreaWidget,
     TextWidget,
     )
 
 from lp.app.errors import UnexpectedFormData
-from lp.services.utils import round_half_up
 
 
 class StrippedTextWidget(TextWidget):
@@ -64,88 +56,6 @@ class NoneableTextWidget(StrippedTextWidget):
             return value
 
 
-class LocalDateTimeWidget(TextWidget):
-    """A datetime widget that uses a particular time zone."""
-
-    timeZoneName = 'UTC'
-
-    def _toFieldValue(self, input):
-        """Convert a string to a datetime value.
-
-          >>> from zope.publisher.browser import TestRequest
-          >>> from zope.schema import Field
-          >>> field = Field(__name__='foo', title=u'Foo')
-          >>> widget = LocalDateTimeWidget(field, TestRequest())
-
-        The widget converts an empty string to the missing value:
-
-          >>> widget._toFieldValue('') == field.missing_value
-          True
-
-        By default, the date is interpreted as UTC:
-
-          >>> print(widget._toFieldValue('2006-01-01 12:00:00'))
-          2006-01-01 12:00:00+00:00
-
-        But it will handle other time zones:
-
-          >>> widget.timeZoneName = 'Australia/Perth'
-          >>> print(widget._toFieldValue('2006-01-01 12:00:00'))
-          2006-01-01 12:00:00+08:00
-
-        Invalid dates result in a ConversionError:
-
-          >>> print(widget._toFieldValue('not a date'))  #doctest: +ELLIPSIS
-          Traceback (most recent call last):
-            ...
-          ConversionError: ('Invalid date value', ...)
-        """
-        if input == self._missing:
-            return self.context.missing_value
-        try:
-            year, month, day, hour, minute, second, dummy_tz = parse(input)
-            second, micro = divmod(second, 1.0)
-            micro = round_half_up(micro * 1000000)
-            dt = datetime.datetime(year, month, day,
-                                   hour, minute, int(second), micro)
-        except (DateTimeError, ValueError, IndexError) as v:
-            raise ConversionError('Invalid date value', v)
-        tz = pytz.timezone(self.timeZoneName)
-        return tz.localize(dt)
-
-    def _toFormValue(self, value):
-        """Convert a date to its string representation.
-
-          >>> from zope.publisher.browser import TestRequest
-          >>> from zope.schema import Field
-          >>> field = Field(__name__='foo', title=u'Foo')
-          >>> widget = LocalDateTimeWidget(field, TestRequest())
-
-        The 'missing' value is converted to an empty string:
-
-          >>> print(widget._toFormValue(field.missing_value))
-          <BLANKLINE>
-
-        Dates are displayed without an associated time zone:
-
-          >>> dt = datetime.datetime(2006, 1, 1, 12, 0, 0,
-          ...                        tzinfo=pytz.timezone('UTC'))
-          >>> widget._toFormValue(dt)
-          '2006-01-01 12:00:00'
-
-        The date value will be converted to the widget's time zone
-        before being displayed:
-
-          >>> widget.timeZoneName = 'Australia/Perth'
-          >>> widget._toFormValue(dt)
-          '2006-01-01 20:00:00'
-        """
-        if value == self.context.missing_value:
-            return self._missing
-        tz = pytz.timezone(self.timeZoneName)
-        return value.astimezone(tz).strftime('%Y-%m-%d %H:%M:%S')
-
-
 class URIWidget(StrippedTextWidget):
     """A widget that represents a URI."""
 
diff --git a/lib/lp/archivepublisher/tests/test_dist_upgrader.py b/lib/lp/archivepublisher/tests/test_dist_upgrader.py
index 2c5c13b..60e69d0 100644
--- a/lib/lp/archivepublisher/tests/test_dist_upgrader.py
+++ b/lib/lp/archivepublisher/tests/test_dist_upgrader.py
@@ -33,12 +33,6 @@ from lp.testing import TestCaseWithFactory
 from lp.testing.layers import ZopelessDatabaseLayer
 
 
-class FakeConfig:
-    """A fake publisher configuration."""
-    def __init__(self, archiveroot):
-        self.archiveroot = archiveroot
-
-
 class TestDistUpgrader(RunPartsMixin, TestCaseWithFactory):
 
     layer = ZopelessDatabaseLayer
diff --git a/lib/lp/bugs/browser/tests/test_expose.py b/lib/lp/bugs/browser/tests/test_expose.py
index 4e656e0..3ee4951 100644
--- a/lib/lp/bugs/browser/tests/test_expose.py
+++ b/lib/lp/bugs/browser/tests/test_expose.py
@@ -86,18 +86,6 @@ class DemoEnum(DBEnumeratedType):
     TRES = DBItem(3, """Three""")
 
 
-class DemoContext:
-
-    return_value = None
-
-    def __init__(self, user):
-        self.user = user
-
-    def userHasBugSubscriptions(self, user):
-        assert user is self.user
-        return self.return_value
-
-
 class TestExposeAdministeredTeams(TestCaseWithFactory):
     """Test the function to expose administered team."""
 
diff --git a/lib/lp/registry/browser/person.py b/lib/lp/registry/browser/person.py
index 1d1c2fb..c07a1c2 100644
--- a/lib/lp/registry/browser/person.py
+++ b/lib/lp/registry/browser/person.py
@@ -1176,32 +1176,6 @@ class RedirectToEditLanguagesView(LaunchpadView):
             '%s/+editlanguages' % canonical_url(self.user))
 
 
-@delegate_to(IPerson, context='person')
-class PersonWithKeysAndPreferredEmail:
-    """A decorated person that includes GPG keys and preferred emails."""
-
-    # These need to be predeclared to avoid delegates taking them over.
-    # Would be nice if there was a way of allowing writes to just work
-    # (i.e. no proxying of __set__).
-    gpgkeys = None
-    sshkeys = None
-    preferredemail = None
-
-    def __init__(self, person):
-        self.person = person
-        self.gpgkeys = []
-        self.sshkeys = []
-
-    def addGPGKey(self, key):
-        self.gpgkeys.append(key)
-
-    def addSSHKey(self, key):
-        self.sshkeys.append(key)
-
-    def setPreferredEmail(self, email):
-        self.preferredemail = email
-
-
 class PersonRdfView(BaseRdfView):
     """A view that embeds PersonRdfContentsView in a standalone page."""
 
diff --git a/lib/lp/scripts/utilities/js/jsbuild.py b/lib/lp/scripts/utilities/js/jsbuild.py
index 84f76fd..22f7220 100644
--- a/lib/lp/scripts/utilities/js/jsbuild.py
+++ b/lib/lp/scripts/utilities/js/jsbuild.py
@@ -8,7 +8,6 @@ from __future__ import absolute_import, print_function, unicode_literals
 __metaclass__ = type
 __all__ = [
     'CSSComboFile',
-    'JSComboFile',
     ]
 
 from glob import glob
@@ -112,23 +111,6 @@ class ComboFile:
         return file_content
 
 
-class JSComboFile(ComboFile):
-    """ComboFile for JavaScript files.
-
-    Outputs the filename before each combined file and make sure that
-    each file content has a new line.
-    """
-
-    def get_comment(self, msg):
-        return b"// %s\n" % msg.encode("UTF-8")
-
-    def get_file_header(self, path):
-        return self.get_comment(relative_path(self.target_file, path))
-
-    def filter_file_content(self, file_content, path):
-        return file_content + b'\n'
-
-
 class CSSComboFile(ComboFile):
     """FileCombiner for CSS files.
 
diff --git a/lib/lp/services/features/browser/tests/test_feature_editor.py b/lib/lp/services/features/browser/tests/test_feature_editor.py
index 4feb8c1..6f47241 100644
--- a/lib/lp/services/features/browser/tests/test_feature_editor.py
+++ b/lib/lp/services/features/browser/tests/test_feature_editor.py
@@ -31,11 +31,6 @@ from lp.testing.pages import (
     )
 
 
-class FauxForm:
-    """The simplest fake form, used for testing."""
-    context = None
-
-
 class TestFeatureControlPage(BrowserTestCase):
 
     layer = DatabaseFunctionalLayer
diff --git a/lib/lp/services/xml.py b/lib/lp/services/xml.py
index 2d87537..e2d2bea 100644
--- a/lib/lp/services/xml.py
+++ b/lib/lp/services/xml.py
@@ -5,7 +5,6 @@
 
 __all__ = [
     'XMLValidator',
-    'RelaxNGValidator',
     ]
 
 
@@ -88,9 +87,3 @@ class XMLValidator:
         error_log is the empty string.
         """
         return self._errors
-
-
-class RelaxNGValidator(XMLValidator):
-    """A validator for Relax NG schemas."""
-
-    SCHEMA_ARGUMENT = 'relaxng'