[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Check descriptor types via type_annotation()
commit a79b7c72d5cbfc79cec39a37f9639b710fbf6706
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Aug 14 18:44:39 2019 -0700
Check descriptor types via type_annotation()
Oops! I completely forgot that descriptors have this method. The method, unlike
the constant, recognizes our different consensus types.
---
stem/descriptor/collector.py | 5 +----
stem/descriptor/networkstatus.py | 2 --
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/stem/descriptor/collector.py b/stem/descriptor/collector.py
index 7c2447a2..99d02242 100644
--- a/stem/descriptor/collector.py
+++ b/stem/descriptor/collector.py
@@ -285,9 +285,7 @@ class File(object):
# filtering to what we're after.
for desc in stem.descriptor.parse_file(path, document_handler = document_handler):
- desc_annotation = type(desc).TYPE_ANNOTATION_NAME
-
- if descriptor_type is None or (desc_annotation and descriptor_type.startswith(desc_annotation)):
+ if descriptor_type is None or descriptor_type.startswith(desc.type_annotation().name):
yield desc
def download(self, directory, decompress = True, timeout = None, retries = 3):
@@ -538,7 +536,6 @@ class CollecTor(object):
raise ValueError('Only v2 and v3 router status entries are available (not version %s)' % version)
# TODO: support bridge variants ('bridge-network-status' type)
- # TODO: document vs router status entries (ie. DocumentType)?
for f in self.files(desc_type, start, end):
for desc in f.read(cache_to, desc_type, document_handler, timeout = timeout, retries = retries):
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index dd7759f5..b0589f2a 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -1032,8 +1032,6 @@ class NetworkStatusDocumentV3(NetworkStatusDocument):
Added the bandwidth_file_digest attributbute.
"""
- TYPE_ANNOTATION_NAME = 'network-status-consensus-3' # TODO: can also be network-status-vote-3
-
ATTRIBUTES = {
'version': (None, _parse_header_network_status_version_line),
'version_flavor': ('ns', _parse_header_network_status_version_line),
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits