Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ Supports the following info. Parsed info in bold:

- Hop
- **Hop counter**
- **[AS\#]**
- Probe
- **[AS\#]**
- **Hostname**
- **(IP address)**
- **RTT**
- **!Annotation**

# Usage

```
```python
import trparse
s = <some_output_from_traceroute>
s = "<some_output_from_traceroute>"
# 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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions trparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down