Add some docstrings.

This commit is contained in:
Vladimir Rusinov 2016-12-02 16:35:19 +00:00 committed by Brian Warner
parent 7faec2e10a
commit 0d47e12e40
3 changed files with 10 additions and 1 deletions

View File

@ -52,11 +52,13 @@ class DeepStats(object):
self.root = math.sqrt(10) self.root = math.sqrt(10)
def set_monitor(self, monitor): def set_monitor(self, monitor):
"""Sets a new monitor."""
self.monitor = monitor self.monitor = monitor
monitor.origin_si = self.origin.get_storage_index() monitor.origin_si = self.origin.get_storage_index()
monitor.set_status(self.get_results()) monitor.set_status(self.get_results())
def add_node(self, node, childpath): def add_node(self, node, childpath):
"""Adds a node's stats to calculation."""
if isinstance(node, UnknownNode): if isinstance(node, UnknownNode):
self.add("count-unknown") self.add("count-unknown")
elif IDirectoryNode.providedBy(node): elif IDirectoryNode.providedBy(node):
@ -80,6 +82,7 @@ class DeepStats(object):
self.max("largest-immutable-file", size) self.max("largest-immutable-file", size)
def enter_directory(self, parent, children): def enter_directory(self, parent, children):
"""Adds directory stats."""
dirsize_bytes = parent.get_size() dirsize_bytes = parent.get_size()
if dirsize_bytes is not None: if dirsize_bytes is not None:
self.add("size-directories", dirsize_bytes) self.add("size-directories", dirsize_bytes)
@ -118,6 +121,7 @@ class DeepStats(object):
h[bucket] += 1 h[bucket] += 1
def get_results(self): def get_results(self):
"""Returns deep-stats resutls."""
stats = self.stats.copy() stats = self.stats.copy()
for key in self.histograms: for key in self.histograms:
h = self.histograms[key] h = self.histograms[key]
@ -127,4 +131,5 @@ class DeepStats(object):
return stats return stats
def finish(self): def finish(self):
"""Finishes gathering stats."""
return self.get_results() return self.get_results()

View File

@ -28,7 +28,9 @@ from allmydata.util.dictutil import AuxValueDict
def update_metadata(metadata, new_metadata, now): def update_metadata(metadata, new_metadata, now):
"""Updates 'metadata' in-place with the information in 'new_metadata'. """Updates 'metadata' in-place with the information in 'new_metadata'.
Timestamps are set according to the time 'now'."""
Timestamps are set according to the time 'now'.
"""
if metadata is None: if metadata is None:
metadata = {} metadata = {}

View File

@ -1,3 +1,5 @@
"""Tests for the dirnode module."""
import time import time
import unicodedata import unicodedata
from zope.interface import implements from zope.interface import implements