[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Renaming 'BandwidthMetric' to 'BandwidthFile'
commit 6a122f615b9e8f09b2e56f06a6512ded48f9333f
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sat Jan 19 16:15:54 2019 -0800
Renaming 'BandwidthMetric' to 'BandwidthFile'
Juga and teor indicated they'd like for us to standardize on the name of
'BandwidthFile'. Tracking the spec update on...
https://trac.torproject.org/projects/tor/ticket/29137
---
stem/descriptor/__init__.py | 10 +++++-----
stem/descriptor/{bandwidth_metric.py => bandwidth_file.py} | 10 +++++-----
test/settings.cfg | 4 ++--
test/unit/descriptor/__init__.py | 2 +-
.../descriptor/{bandwidth_metric.py => bandwidth_file.py} | 14 +++++++-------
.../descriptor/data/{bwauth_v1.0 => bandwidth_file_v1.0} | 0
.../descriptor/data/{bwauth_v1.2 => bandwidth_file_v1.2} | 0
7 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index e587f9d1..f926c45a 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -108,7 +108,7 @@ except ImportError:
from stem.util.ordereddict import OrderedDict
__all__ = [
- 'bandwidth_metric',
+ 'bandwidth_file',
'export',
'reader',
'remote',
@@ -442,10 +442,10 @@ def _parse_metrics_file(descriptor_type, major_version, minor_version, descripto
for desc in stem.descriptor.hidden_service_descriptor._parse_file(descriptor_file, validate = validate, **kwargs):
yield desc
- elif descriptor_type == stem.descriptor.bandwidth_metric.BandwidthMetric.TYPE_ANNOTATION_NAME and major_version == 1:
- document_type = stem.descriptor.bandwidth_metric.BandwidthMetric
+ elif descriptor_type == stem.descriptor.bandwidth_file.BandwidthFile.TYPE_ANNOTATION_NAME and major_version == 1:
+ document_type = stem.descriptor.bandwidth_file.BandwidthFile
- for desc in stem.descriptor.bandwidth_metric._parse_file(descriptor_file, validate = validate, **kwargs):
+ for desc in stem.descriptor.bandwidth_file._parse_file(descriptor_file, validate = validate, **kwargs):
yield desc
else:
raise TypeError("Unrecognized metrics descriptor format. type: '%s', version: '%i.%i'" % (descriptor_type, major_version, minor_version))
@@ -1418,7 +1418,7 @@ def _descriptor_components(raw_contents, validate, extra_keywords = (), non_asci
# importing at the end to avoid circular dependencies on our Descriptor class
-import stem.descriptor.bandwidth_metric
+import stem.descriptor.bandwidth_file
import stem.descriptor.extrainfo_descriptor
import stem.descriptor.hidden_service_descriptor
import stem.descriptor.microdescriptor
diff --git a/stem/descriptor/bandwidth_metric.py b/stem/descriptor/bandwidth_file.py
similarity index 93%
rename from stem/descriptor/bandwidth_metric.py
rename to stem/descriptor/bandwidth_file.py
index 900a9d2e..97210d7b 100644
--- a/stem/descriptor/bandwidth_metric.py
+++ b/stem/descriptor/bandwidth_file.py
@@ -9,7 +9,7 @@ Parsing for Bandwidth Authority metrics as described in Tor's
::
- BandwidthMetric - Tor bandwidth authority measurements.
+ BandwidthFile - Tor bandwidth authority measurements.
.. versionadded:: 1.8.0
"""
@@ -73,14 +73,14 @@ def _parse_file(descriptor_file, validate = False, **kwargs):
**True**, skips these checks otherwise
:param dict kwargs: additional arguments for the descriptor constructor
- :returns: :class:`stem.descriptor.bandwidth_file.BandwidthMetric` object
+ :returns: :class:`stem.descriptor.bandwidth_file.BandwidthFile` object
:raises:
* **ValueError** if the contents is malformed and validate is **True**
* **IOError** if the file can't be read
"""
- yield BandwidthMetric(descriptor_file.read(), validate, **kwargs)
+ yield BandwidthFile(descriptor_file.read(), validate, **kwargs)
def _parse_header(descriptor, entries):
@@ -119,7 +119,7 @@ def _parse_timestamp(descriptor, entries):
raise ValueError("First line should be a unix timestamp, but was '%s'" % first_line)
-class BandwidthMetric(Descriptor):
+class BandwidthFile(Descriptor):
"""
Tor bandwidth authroity measurements.
@@ -156,7 +156,7 @@ class BandwidthMetric(Descriptor):
ATTRIBUTES.update(dict([(k, (None, _parse_header)) for k in HEADER_ATTR.keys()]))
def __init__(self, raw_content, validate = False):
- super(BandwidthMetric, self).__init__(raw_content, lazy_load = not validate)
+ super(BandwidthFile, self).__init__(raw_content, lazy_load = not validate)
if validate:
pass # TODO: implement eager load
diff --git a/test/settings.cfg b/test/settings.cfg
index a5e60e08..d463cac9 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -138,7 +138,7 @@ pycodestyle.ignore E131
pycodestyle.ignore E722
pycodestyle.ignore stem/__init__.py => E402: import stem.util.connection
-pycodestyle.ignore stem/descriptor/__init__.py => E402: import stem.descriptor.bandwidth_metric
+pycodestyle.ignore stem/descriptor/__init__.py => E402: import stem.descriptor.bandwidth_file
pycodestyle.ignore stem/descriptor/__init__.py => E402: import stem.descriptor.extrainfo_descriptor
pycodestyle.ignore stem/descriptor/__init__.py => E402: import stem.descriptor.hidden_service_descriptor
pycodestyle.ignore stem/descriptor/__init__.py => E402: import stem.descriptor.microdescriptor
@@ -225,7 +225,7 @@ test.unit_tests
|test.unit.descriptor.networkstatus.bridge_document.TestBridgeNetworkStatusDocument
|test.unit.descriptor.hidden_service_descriptor.TestHiddenServiceDescriptor
|test.unit.descriptor.certificate.TestEd25519Certificate
-|test.unit.descriptor.bandwidth_metric.TestBandwidthMetric
+|test.unit.descriptor.bandwidth_file.TestBandwidthFile
|test.unit.exit_policy.rule.TestExitPolicyRule
|test.unit.exit_policy.policy.TestExitPolicy
|test.unit.endpoint.TestEndpoint
diff --git a/test/unit/descriptor/__init__.py b/test/unit/descriptor/__init__.py
index 0fe107dd..a2c03f1d 100644
--- a/test/unit/descriptor/__init__.py
+++ b/test/unit/descriptor/__init__.py
@@ -5,7 +5,7 @@ Unit tests for stem.descriptor.
import os
__all__ = [
- 'bandwidth_metric',
+ 'bandwidth_file',
'export',
'extrainfo_descriptor',
'microdescriptor',
diff --git a/test/unit/descriptor/bandwidth_metric.py b/test/unit/descriptor/bandwidth_file.py
similarity index 84%
rename from test/unit/descriptor/bandwidth_metric.py
rename to test/unit/descriptor/bandwidth_file.py
index 45739ed7..b8fdf01b 100644
--- a/test/unit/descriptor/bandwidth_metric.py
+++ b/test/unit/descriptor/bandwidth_file.py
@@ -1,23 +1,23 @@
"""
-Unit tests for stem.descriptor.bandwidth_metric.
+Unit tests for stem.descriptor.bandwidth_file.
"""
import datetime
import unittest
import stem.descriptor
-import stem.descriptor.bandwidth_metric
+import stem.descriptor.bandwidth_file
import test.unit.descriptor
-class TestBandwidthMetric(unittest.TestCase):
+class TestBandwidthFile(unittest.TestCase):
def test_format_v1_0(self):
"""
- Parse version 1.0 formatted metrics.
+ Parse version 1.0 formatted files.
"""
- desc = list(stem.descriptor.parse_file(test.unit.descriptor.get_resource('bwauth_v1.0'), 'badnwidth-file 1.0'))[0]
+ desc = list(stem.descriptor.parse_file(test.unit.descriptor.get_resource('bandwidth_file_v1.0'), 'badnwidth-file 1.0'))[0]
self.assertEqual(datetime.datetime(2019, 1, 14, 17, 41, 29), desc.timestamp)
self.assertEqual('1.0.0', desc.version)
@@ -38,10 +38,10 @@ class TestBandwidthMetric(unittest.TestCase):
def test_format_v1_2(self):
"""
- Parse version 1.2 formatted metrics.
+ Parse version 1.2 formatted files.
"""
- desc = list(stem.descriptor.parse_file(test.unit.descriptor.get_resource('bwauth_v1.2'), 'badnwidth-file 1.2'))[0]
+ desc = list(stem.descriptor.parse_file(test.unit.descriptor.get_resource('bandwidth_file_v1.2'), 'badnwidth-file 1.2'))[0]
self.assertEqual(datetime.datetime(2019, 1, 14, 5, 34, 59), desc.timestamp)
self.assertEqual('1.2.0', desc.version)
diff --git a/test/unit/descriptor/data/bwauth_v1.0 b/test/unit/descriptor/data/bandwidth_file_v1.0
similarity index 100%
rename from test/unit/descriptor/data/bwauth_v1.0
rename to test/unit/descriptor/data/bandwidth_file_v1.0
diff --git a/test/unit/descriptor/data/bwauth_v1.2 b/test/unit/descriptor/data/bandwidth_file_v1.2
similarity index 100%
rename from test/unit/descriptor/data/bwauth_v1.2
rename to test/unit/descriptor/data/bandwidth_file_v1.2
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits