diff --git a/README.md b/README.md index 420a86a..eb4f383 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Supports the following info. Parsed info in bold: - Hop - **Hop counter** - - **[AS\#]** - Probe + - **[AS\#]** - **Hostname** - **(IP address)** - **RTT** @@ -26,20 +26,20 @@ Supports the following info. Parsed info in bold: # Usage -``` +```python import trparse -s = +s = "" # Parse the traceroute output traceroute = trparse.loads(s) # You can print the result -print traceroute +print(traceroute) # Save it as string tr_str = str(traceroute) # Or travel the tree hop = traceroute.hops[0] probe = hop.probes[0] # And print the IP address -print probe.ip +print(probe.ip) ``` # Data structures @@ -77,7 +77,7 @@ some tokens it expects to find in a specific format. For example: preceded by space characters). - **[AS\#]** must be surrounded by square brackets `[]` and start with `AS`. -- **Hostname** Can be a hostname or its IP address without parenthesis +- **Hostname** can be a hostname or its IP address without parenthesis. - **(IP address)** either IPv4 or IPv6 must surrounded by parenthesis `()`. - **RTT** must be in integer (without commas or dots) or float format diff --git a/setup.py b/setup.py index 2950670..43b75f1 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ ] setup(name='trparse', - version='0.3.0', + version='0.3.1', description='Traceroute parser', author='Luis Benitez', url='https://github.com/lbenitez000/trparse', diff --git a/trparse.py b/trparse.py index 5eb380b..5e88d7e 100644 --- a/trparse.py +++ b/trparse.py @@ -36,7 +36,7 @@ def add_hop(self, hop): self.hops.append(hop) def __str__(self): - text = "Traceroute for %s (%s)\n\n" % (self.dest_name, self.dest_ip) + text = "Traceroute for {} ({})\n\n".format(self.dest_name, self.dest_ip) for hop in self.hops: text += str(hop) return text @@ -47,7 +47,7 @@ class Hop(object): Abstraction of a hop in a traceroute. """ def __init__(self, idx): - self.idx = idx # Hop count, starting at 1 + self.idx = idx # Hop count, starting at 1 (usually) self.probes = [] # Series of Probe instances def add_probe(self, probe):