A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mail-archive.com/html5lib-discuss@googlegroups.com/msg00075.html below:

Who'd like to revert r818?

On Jun 25, 4:03 am, "Thomas Broyer" <[EMAIL PROTECTED]> wrote:
> > Modified:
> >    trunk/python/src/html5lib/serializer/htmlserializer.py
>
> > Log:
> > DRY
>
> > Modified: trunk/python/src/html5lib/serializer/htmlserializer.py
> > ==============================================================================
> > --- trunk/python/src/html5lib/serializer/htmlserializer.py      (original)
> > +++ trunk/python/src/html5lib/serializer/htmlserializer.py      Sun Jun 24 
> > 18:27:15 2007
> > @@ -76,12 +76,9 @@
> >      def __init__(self, **kwargs):
> >          if kwargs.has_key('quote_char'):
> >              self.use_best_quote_char = False
> > -        for attr in ("quote_attr_values", "quote_char", 
> > "use_best_quote_char",
> > -          "minimize_boolean_attributes", "use_trailing_solidus",
> > -          "space_before_trailing_solidus", "omit_optional_tags",
> > -          "strip_whitespace", "inject_meta_charset", "escape_lt_in_attrs",
> > -          "escape_rcdata"):
> > -            setattr(self, attr, kwargs.get(attr, getattr(self, attr)))
> > +        for name,value in kwargs.items():
> > +            if name in dir(self.__class__) and not name.startswith('_'):
> > +                setattr(self, name, value)
> >          self.errors = []
> >          self.strict = False
>
> There are implications behind this change:
> 1) with the original, default values defined at the class-level were
> copied within each instance's __dict__ (meaning that if you change
> HTMLSerializer.quote_attr_values you're not touching existing
> instances)
> 2) with the new version, you can replace the serialize, render and
> serializeError passing such named arguments to the constructor:
> HTMLSerializer(serialize=True).
>
> In a work: I hugely prefers r817 to r818.
>
> If you don't want to "repeat yourself", I'd have no problem moving all
> the default values into a 'defaults' dictionary and then using
> "self.options = defaults.copy(); self.options.update(kwargs)" bu it
> makes the code harder to read (you'd have to replace e.g.
> self.quote_attr_values with self.options['quote_attr_values'])
Reverted, but with with the options tuple moved out of __init__.  I'd
like to have a means of determining the available options externally
so that I can more easily make a Venus filter out of this.
Additionally, having the tuple outside of any method makes the
possibility of forgetting to update this list when adding a new option
a bit smaller.

Note: even if there were a class level default options dict, the
__init__ method could continue to copy the values to instance
members.  That's essentially the approach the Ruby port takes today.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"html5lib-discuss" group.
 To post to this group, send email to html5lib-discuss@googlegroups.com
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.com/group/html5lib-discuss?hl=en-GB
-~----------~----~----~----~------~----~------~--~---


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4