from pkg_resources import resource_string

from twisted.web.template import renderer, XMLString

from diamondash.widgets.widget.widget import Widget


class TextWidget(Widget):
    """A widget that simply displays static text."""

    loader = XMLString(resource_string(__name__, 'template.xml'))

    TYPE_NAME = 'text'
    MIN_COLUMN_SPAN = 2
    STYLESHEETS = ('text/style.css',)

    def __init__(self, text, **kwargs):
        super(TextWidget, self).__init__(**kwargs)
        self.text = text

    @renderer
    def text_renderer(self, request, tag):
        return tag(self.text)

from pkg_resources import resource_string

from twisted.web.template import renderer, XMLString

from diamondash.widgets.widget.widget import Widget, WidgetConfig


class TextWidgetConfig(WidgetConfig):
    TYPE_NAME = 'text'
    MIN_COLUMN_SPAN = 2


class TextWidget(Widget):
    """A widget that simply displays static text."""

    loader = XMLString(resource_string(__name__, 'template.xml'))

   
    STYLESHEETS = ('text/style.css',)

    def __init__(self, text, **kwargs):
        super(TextWidget, self).__init__(**kwargs)
        self.text = text

    @renderer
    def text_renderer(self, request, tag):
        return tag(self.text)

Refactor TextWidgetConfig out of TextWidget
Refactor TextWidgetConfig out of TextWidget

  from pkg_resources import resource_string
  
  from twisted.web.template import renderer, XMLString
  
- from diamondash.widgets.widget.widget import Widget
+ from diamondash.widgets.widget.widget import Widget, WidgetConfig
+ 
+ 
+ class TextWidgetConfig(WidgetConfig):
+     TYPE_NAME = 'text'
+     MIN_COLUMN_SPAN = 2
  
  
  class TextWidget(Widget):
      """A widget that simply displays static text."""
  
      loader = XMLString(resource_string(__name__, 'template.xml'))
  
+    
-     TYPE_NAME = 'text'
-     MIN_COLUMN_SPAN = 2
      STYLESHEETS = ('text/style.css',)
  
      def __init__(self, text, **kwargs):
          super(TextWidget, self).__init__(**kwargs)
          self.text = text
  
      @renderer
      def text_renderer(self, request, tag):
          return tag(self.text)
  
Refactor TextWidgetConfig out of TextWidget
## Code Before:
from pkg_resources import resource_string

from twisted.web.template import renderer, XMLString

from diamondash.widgets.widget.widget import Widget


class TextWidget(Widget):
    """A widget that simply displays static text."""

    loader = XMLString(resource_string(__name__, 'template.xml'))

    TYPE_NAME = 'text'
    MIN_COLUMN_SPAN = 2
    STYLESHEETS = ('text/style.css',)

    def __init__(self, text, **kwargs):
        super(TextWidget, self).__init__(**kwargs)
        self.text = text

    @renderer
    def text_renderer(self, request, tag):
        return tag(self.text)

## Instruction:
Refactor TextWidgetConfig out of TextWidget
## Code After:
from pkg_resources import resource_string

from twisted.web.template import renderer, XMLString

from diamondash.widgets.widget.widget import Widget, WidgetConfig


class TextWidgetConfig(WidgetConfig):
    TYPE_NAME = 'text'
    MIN_COLUMN_SPAN = 2


class TextWidget(Widget):
    """A widget that simply displays static text."""

    loader = XMLString(resource_string(__name__, 'template.xml'))

   
    STYLESHEETS = ('text/style.css',)

    def __init__(self, text, **kwargs):
        super(TextWidget, self).__init__(**kwargs)
        self.text = text

    @renderer
    def text_renderer(self, request, tag):
        return tag(self.text)
