Python effective TLD library bug fix

    Some cool people commented on bugs in the etld library in the previous post about it. I've taken the opportunity to fix the bug, and a new release is now available at http://www.stillhq.com/python/etld/etld.py. If you've got specific examples of domains which either didn't work previously, or don't work now, let me know. I want to add unit tests to this code ASAP.

posted at: 13:57 | path: /python/etld | permanent link to this entry

    ### Chris Hills

    Still not working for abc.def.example.auto.pl. The following works, assuming that the base tld always comes first in effective_tld_names.dat:-

    --- etld.py.1 2009-11-24 22:54:21.000000000 +0100
    +++ etld.py 2009-11-26 13:27:18.801134912 +0100
    @@ -53,11 +53,12 @@
    domain = ''
    etld = ''

    - for rule in self.rules[tld]:
    + for rule in reversed(self.rules[tld]):
    m = rule.match(hostname)
    if m and m.group(1) > etld:
    domain = m.group(2)[::-1]
    etld = m.group(1)[::-1]
    + break

    if not etld:
    raise Exception('Parse failed')

    ### Daniel

    (Sorry for the bad English)

    Hi,

    thanks for this library!

    Wouldn't it be better to set the default value for "datafile" to None (in __in it__) and to download the data if "datafile" is None?

    I can send you my changes if you want.

    Best regards,
    Daniel

    Add a comment to this post:

    Your name:

    Your email: Email me new comments on this post
      (Your email will not be published on this site, and will only be used to contact you directly with a reply to your comment if needed. Oh, and we'll use it to send you new comments on this post it you selected that checkbox.)


    Your website:

    Comments: