[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Dropping duplicate constructors
commit b2d1d632696e5d47789ea9d1b4f817df8634e681
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Apr 10 08:25:13 2012 -0700
Dropping duplicate constructors
Bridge and relay server descriptor constructors are identical, moving to
parent.
---
stem/descriptor/server_descriptor.py | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 6895e5b..a0f688c 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -190,7 +190,7 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
(*) required fields, others are left as None if undefined
"""
- def __init__(self, raw_contents, annotations):
+ def __init__(self, raw_contents, validate = True, annotations = None):
"""
Version 3 server descriptor constructor, created from an individual relay's
descriptor content (as provided by "GETINFO desc/*", cached descriptors,
@@ -258,6 +258,11 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
else:
self._annotation_lines = []
self._annotation_dict = {}
+
+ contents = _DescriptorContents(raw_contents, validate)
+ self.exit_policy = contents.exit_policy
+ self._parse(contents.entries, validate)
+ if validate: self._check_constraints(contents)
def get_unrecognized_lines(self):
return list(self._unrecognized_lines)
@@ -512,15 +517,11 @@ class RelayDescriptorV3(ServerDescriptorV3):
"""
def __init__(self, raw_contents, validate = True, annotations = None):
- ServerDescriptorV3.__init__(self, raw_contents, annotations)
self.onion_key = None
self.signing_key = None
self.signature = None
- contents = _DescriptorContents(raw_contents, validate)
- self.exit_policy = contents.exit_policy
- self._parse(contents.entries, validate)
- if validate: self._check_constraints(contents)
+ ServerDescriptorV3.__init__(self, raw_contents, validate, annotations)
def is_valid(self):
"""
@@ -578,14 +579,6 @@ class BridgeDescriptorV3(ServerDescriptorV3):
https://metrics.torproject.org/formats.html#bridgedesc
"""
- def __init__(self, raw_contents, validate = True, annotations = None):
- ServerDescriptorV3.__init__(self, raw_contents, annotations)
-
- contents = _DescriptorContents(raw_contents, validate)
- self.exit_policy = contents.exit_policy
- self._parse(contents.entries, validate)
- if validate: self._check_constraints(contents)
-
def _parse(self, entries, validate):
ServerDescriptorV3._parse(self, entries, validate)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits