Skip to content

Commit

Permalink
enhance TYPE-based query helper
Browse files Browse the repository at this point in the history
Provide an easy way to query for text representations:

In [4]: dnsknife.Checker('example.net').NS(text=True)
Out[4]: ['ns-6-c.example.net.', 'ns-1-a.example.net.', 'ns-5-b.example.net.']

might resolve #4
  • Loading branch information
kalou committed Feb 1, 2018
1 parent 06e9ad5 commit 295e7f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dnsknife/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ def as_dnssec(c):
class TypeAware(object):
"""Convenient trait"""
def partial_query(self, rtype):
def query_with_default_name(name=''):
return self.query_relative(name, rtype)
"""Returns an answer object"""
def query_with_default_name(name='', text=False):
ans = self.query_relative(name, rtype)
if not text:
return ans
return [rr.to_text() for rr in ans]
return query_with_default_name

def __getattribute__(self, name):
Expand Down

0 comments on commit 295e7f7

Please sign in to comment.