<commit_before>#!/usr/bin/python

from __future__ import unicode_literals

import copy
import re
import os
import time
import threading
from contextlib import contextmanager
try:
  from BaseHTTPServer import BaseHTTPRequestHandler
except ImportError:
  # Python 3
  from http.server import BaseHTTPRequestHandler
from functools import wraps
from threading import Lock

__all__ = ['Counter', 'Gauge', 'Summary', 'Histogram']

_METRIC_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_METRIC_LABEL_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_RESERVED_METRIC_LABEL_NAME_RE = re.compile(r'^__.*$')
_INF = float("inf")
_MINUS_INF = float("-inf")



class CollectorRegistry(object):
  '''Metric collector registry.
  
  Collectors must have a no-argument method 'collect' that returns a list of
  Metric objects. The returned metrics should be consistent with the Prometheus
  exposition formats.
  '''
  def __init__(self):
    self._collectors = set()
    self._lock = Lock()

  def register(self, collector):
    '''Add a collector to the registry.'''
    with self._lock:
      self._collectors.add(collector)

  def unregister(self, metric):
    '''Remove a collector from the registry.'''
    with self._lock:
      self._collectors.remove(collector)

  def collect(self):
    '''Yields metrics from the collectors in the registry.'''
    collectors = None
    with self._lock:
      collectors = copy.copy(self._collectors)
    for collector in collectors:<commit_msg>Fix argument name<commit_after>#!/usr/bin/python

from __future__ import unicode_literals

import copy
import re
import os
import time
import threading
from contextlib import contextmanager
try:
  from BaseHTTPServer import BaseHTTPRequestHandler
except ImportError:
  # Python 3
  from http.server import BaseHTTPRequestHandler
from functools import wraps
from threading import Lock

__all__ = ['Counter', 'Gauge', 'Summary', 'Histogram']

_METRIC_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_METRIC_LABEL_NAME_RE = re.compile(r'^[a-zA-Z_:][a-zA-Z0-9_:]*$')
_RESERVED_METRIC_LABEL_NAME_RE = re.compile(r'^__.*$')
_INF = float("inf")
_MINUS_INF = float("-inf")



class CollectorRegistry(object):
  '''Metric collector registry.
  
  Collectors must have a no-argument method 'collect' that returns a list of
  Metric objects. The returned metrics should be consistent with the Prometheus
  exposition formats.
  '''
  def __init__(self):
    self._collectors = set()
    self._lock = Lock()

  def register(self, collector):
    '''Add a collector to the registry.'''
    with self._lock:
      self._collectors.add(collector)

  def unregister(self, collector):
    '''Remove a collector from the registry.'''
    with self._lock:
      self._collectors.remove(collector)

  def collect(self):
    '''Yields metrics from the collectors in the registry.'''
    collectors = None
    with self._lock:
      collectors = copy.copy(self._collectors)
    for collector in collectors:
{'fraction_non_alphanumeric': 0.11182216234422364, 'fraction_numerical': 0.003368137420006736, 'mean_word_length': 4.3130590339892665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7294218', 'n_tokens_mistral': 984, 'n_tokens_neox': 928, 'n_words': 271}