commit 55906cd95062d838f14620ed4f7e1f97aedbfaa4 Author: Damian Johnson atagar@torproject.org Date: Tue Feb 18 17:32:50 2020 -0800
Drop tor event version constants
I doubt anyone has ever used event versions from our Requirement constants. Retaining these within the event classes but dropping the clutter from our version module. --- stem/response/events.py | 38 ++++++++++++++++++------------------ stem/version.py | 52 ++++++------------------------------------------- 2 files changed, 25 insertions(+), 65 deletions(-)
diff --git a/stem/response/events.py b/stem/response/events.py index b82457e6..542c0f22 100644 --- a/stem/response/events.py +++ b/stem/response/events.py @@ -275,7 +275,7 @@ class BuildTimeoutSetEvent(Event): 'CLOSE_MS': 'close_timeout', 'CLOSE_RATE': 'close_rate', } - _VERSION_ADDED = stem.version.Requirement.EVENT_BUILDTIMEOUT_SET + _VERSION_ADDED = stem.version.Version('0.2.2.7-alpha')
def _parse(self): # convert our integer and float parameters @@ -412,7 +412,7 @@ class CircMinorEvent(Event): 'OLD_PURPOSE': 'old_purpose', 'OLD_HS_STATE': 'old_hs_state', } - _VERSION_ADDED = stem.version.Requirement.EVENT_CIRC_MINOR + _VERSION_ADDED = stem.version.Version('0.2.3.11-alpha')
def _parse(self): self.path = tuple(stem.control._parse_circ_path(self.path)) @@ -448,7 +448,7 @@ class ClientsSeenEvent(Event): 'CountrySummary': 'locales', 'IPVersions': 'ip_versions', } - _VERSION_ADDED = stem.version.Requirement.EVENT_CLIENTS_SEEN + _VERSION_ADDED = stem.version.Version('0.2.1.10-alpha')
def _parse(self): if self.start_time is not None: @@ -507,7 +507,7 @@ class ConfChangedEvent(Event): """
_SKIP_PARSING = True - _VERSION_ADDED = stem.version.Requirement.EVENT_CONF_CHANGED + _VERSION_ADDED = stem.version.Version('0.2.3.3-alpha')
def _parse(self): self.changed = {} @@ -538,7 +538,7 @@ class DescChangedEvent(Event): The DESCCHANGED event was introduced in tor version 0.1.2.2-alpha. """
- _VERSION_ADDED = stem.version.Requirement.EVENT_DESCCHANGED + _VERSION_ADDED = stem.version.Version('0.1.2.2-alpha')
class GuardEvent(Event): @@ -560,7 +560,7 @@ class GuardEvent(Event): :var stem.GuardStatus status: status of the guard relay """
- _VERSION_ADDED = stem.version.Requirement.EVENT_GUARD + _VERSION_ADDED = stem.version.Version('0.1.2.5-alpha') _POSITIONAL_ARGS = ('guard_type', 'endpoint', 'status')
def _parse(self): @@ -606,7 +606,7 @@ class HSDescEvent(Event): :var str index: computed index of the HSDir the descriptor was uploaded to or fetched from """
- _VERSION_ADDED = stem.version.Requirement.EVENT_HS_DESC + _VERSION_ADDED = stem.version.Version('0.2.5.2-alpha') _POSITIONAL_ARGS = ('action', 'address', 'authentication', 'directory', 'descriptor_id') _KEYWORD_ARGS = {'REASON': 'reason', 'REPLICA': 'replica', 'HSDIR_INDEX': 'index'}
@@ -647,7 +647,7 @@ class HSDescContentEvent(Event): :var stem.descriptor.hidden_service.HiddenServiceDescriptorV2 descriptor: descriptor that was retrieved """
- _VERSION_ADDED = stem.version.Requirement.EVENT_HS_DESC_CONTENT + _VERSION_ADDED = stem.version.Version('0.2.7.1-alpha') _POSITIONAL_ARGS = ('address', 'descriptor_id', 'directory')
def _parse(self): @@ -707,7 +707,7 @@ class NetworkStatusEvent(Event): """
_SKIP_PARSING = True - _VERSION_ADDED = stem.version.Requirement.EVENT_NS + _VERSION_ADDED = stem.version.Version('0.1.2.3-alpha')
def _parse(self): content = str(self).lstrip('NS\n').rstrip('\nOK') @@ -731,7 +731,7 @@ class NetworkLivenessEvent(Event): statuses in the future) """
- _VERSION_ADDED = stem.version.Requirement.EVENT_NETWORK_LIVENESS + _VERSION_ADDED = stem.version.Version('0.2.7.2-alpha') _POSITIONAL_ARGS = ('status',)
@@ -751,7 +751,7 @@ class NewConsensusEvent(Event): """
_SKIP_PARSING = True - _VERSION_ADDED = stem.version.Requirement.EVENT_NEWCONSENSUS + _VERSION_ADDED = stem.version.Version('0.2.1.13-alpha')
def _parse(self): self.consensus_content = str(self).lstrip('NEWCONSENSUS\n').rstrip('\nOK') @@ -885,7 +885,7 @@ class SignalEvent(Event): """
_POSITIONAL_ARGS = ('signal',) - _VERSION_ADDED = stem.version.Requirement.EVENT_SIGNAL + _VERSION_ADDED = stem.version.Version('0.2.3.1-alpha')
def _parse(self): # log if we recieved an unrecognized signal @@ -917,7 +917,7 @@ class StatusEvent(Event): """
_POSITIONAL_ARGS = ('runlevel', 'action') - _VERSION_ADDED = stem.version.Requirement.EVENT_STATUS + _VERSION_ADDED = stem.version.Version('0.1.2.3-alpha')
def _parse(self): if self.type == 'STATUS_GENERAL': @@ -1028,7 +1028,7 @@ class StreamBwEvent(Event): """
_POSITIONAL_ARGS = ('id', 'written', 'read', 'time') - _VERSION_ADDED = stem.version.Requirement.EVENT_STREAM_BW + _VERSION_ADDED = stem.version.Version('0.1.2.8-beta')
def _parse(self): if not tor_tools.is_valid_stream_id(self.id): @@ -1061,7 +1061,7 @@ class TransportLaunchedEvent(Event): """
_POSITIONAL_ARGS = ('type', 'name', 'address', 'port') - _VERSION_ADDED = stem.version.Requirement.EVENT_TRANSPORT_LAUNCHED + _VERSION_ADDED = stem.version.Version('0.2.5.0-alpha')
def _parse(self): if self.type not in ('server', 'client'): @@ -1103,7 +1103,7 @@ class ConnectionBandwidthEvent(Event): 'WRITTEN': 'written', }
- _VERSION_ADDED = stem.version.Requirement.EVENT_CONN_BW + _VERSION_ADDED = stem.version.Version('0.2.5.2-alpha')
def _parse(self): if not self.id: @@ -1162,7 +1162,7 @@ class CircuitBandwidthEvent(Event): 'TIME': 'time', }
- _VERSION_ADDED = stem.version.Requirement.EVENT_CIRC_BW + _VERSION_ADDED = stem.version.Version('0.2.5.2-alpha')
def _parse(self): if not self.id: @@ -1232,7 +1232,7 @@ class CellStatsEvent(Event): 'OutboundTime': 'outbound_time', }
- _VERSION_ADDED = stem.version.Requirement.EVENT_CELL_STATS + _VERSION_ADDED = stem.version.Version('0.2.5.2-alpha')
def _parse(self): if self.id and not tor_tools.is_valid_circuit_id(self.id): @@ -1278,7 +1278,7 @@ class TokenBucketEmptyEvent(Event): 'LAST': 'last_refill', }
- _VERSION_ADDED = stem.version.Requirement.EVENT_TB_EMPTY + _VERSION_ADDED = stem.version.Version('0.2.5.2-alpha')
def _parse(self): if self.id and not tor_tools.is_valid_connection_id(self.id): diff --git a/stem/version.py b/stem/version.py index e67a93b5..5369f1ad 100644 --- a/stem/version.py +++ b/stem/version.py @@ -26,32 +26,12 @@ easily parsed and compared, for instance...
Enumerations for the version requirements of features.
- ===================================== =========== - Requirement Description - ===================================== =========== - **DORMANT_MODE** **DORMANT** and **ACTIVE** :data:`~stem.Signal` - **EVENT_AUTHDIR_NEWDESCS** AUTHDIR_NEWDESC events - **EVENT_BUILDTIMEOUT_SET** BUILDTIMEOUT_SET events - **EVENT_CIRC_MINOR** CIRC_MINOR events - **EVENT_CLIENTS_SEEN** CLIENTS_SEEN events - **EVENT_CONF_CHANGED** CONF_CHANGED events - **EVENT_DESCCHANGED** DESCCHANGED events - **EVENT_GUARD** GUARD events - **EVENT_HS_DESC_CONTENT** HS_DESC_CONTENT events - **EVENT_NETWORK_LIVENESS** NETWORK_LIVENESS events - **EVENT_NEWCONSENSUS** NEWCONSENSUS events - **EVENT_NS** NS events - **EVENT_SIGNAL** SIGNAL events - **EVENT_STATUS** STATUS_GENERAL, STATUS_CLIENT, and STATUS_SERVER events - **EVENT_STREAM_BW** STREAM_BW events - **EVENT_TRANSPORT_LAUNCHED** TRANSPORT_LAUNCHED events - **EVENT_CONN_BW** CONN_BW events - **EVENT_CIRC_BW** CIRC_BW events - **EVENT_CELL_STATS** CELL_STATS events - **EVENT_TB_EMPTY** TB_EMPTY events - **EVENT_HS_DESC** HS_DESC events - **HSFETCH_V3** HSFETCH for version 3 hidden services - ===================================== =========== + ===================== =========== + Requirement Description + ===================== =========== + **DORMANT_MODE** **DORMANT** and **ACTIVE** :data:`~stem.Signal` + **HSFETCH_V3** HSFETCH for version 3 hidden services + ===================== =========== """
import functools @@ -312,25 +292,5 @@ class _VersionRequirements(object):
Requirement = stem.util.enum.Enum( ('DORMANT_MODE', Version('0.4.0.1-alpha')), - ('EVENT_AUTHDIR_NEWDESCS', Version('0.1.1.10-alpha')), - ('EVENT_BUILDTIMEOUT_SET', Version('0.2.2.7-alpha')), - ('EVENT_CIRC_MINOR', Version('0.2.3.11-alpha')), - ('EVENT_CLIENTS_SEEN', Version('0.2.1.10-alpha')), - ('EVENT_CONF_CHANGED', Version('0.2.3.3-alpha')), - ('EVENT_DESCCHANGED', Version('0.1.2.2-alpha')), - ('EVENT_GUARD', Version('0.1.2.5-alpha')), - ('EVENT_HS_DESC_CONTENT', Version('0.2.7.1-alpha')), - ('EVENT_NS', Version('0.1.2.3-alpha')), - ('EVENT_NETWORK_LIVENESS', Version('0.2.7.2-alpha')), - ('EVENT_NEWCONSENSUS', Version('0.2.1.13-alpha')), - ('EVENT_SIGNAL', Version('0.2.3.1-alpha')), - ('EVENT_STATUS', Version('0.1.2.3-alpha')), - ('EVENT_STREAM_BW', Version('0.1.2.8-beta')), - ('EVENT_TRANSPORT_LAUNCHED', Version('0.2.5.0-alpha')), - ('EVENT_CONN_BW', Version('0.2.5.2-alpha')), - ('EVENT_CIRC_BW', Version('0.2.5.2-alpha')), - ('EVENT_CELL_STATS', Version('0.2.5.2-alpha')), - ('EVENT_TB_EMPTY', Version('0.2.5.2-alpha')), - ('EVENT_HS_DESC', Version('0.2.5.2-alpha')), ('HSFETCH_V3', Version('0.4.1.1-alpha')), )
tor-commits@lists.torproject.org