<commit_before># Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.
#
# Authors:
#   <NAME>

"""Chromium SPU, Node and Mothership classes used by the config tool.
This may eventually get rolled into the similar classes defined
in the mothership.
"""

# XXX eventually we'll rename these classes to match the mothership.
# That'll allow us to directly read Cr config files and build the
# mothership/node/spu data structures.


import wxPython
import re, string, sys
sys.path.append("../server")
import crconfig


# ----------------------------------------------------------------------

class Option:
	"""Class to describe an SPU/node/mothership option."""
	def __init__(self, name, description, type, count, default, mins, maxs):
		assert len(default) == count
		assert len(mins) == count or len(mins) == 0
		assert len(maxs) == count or len(maxs) == 0
		self.Name = name
		self.Description = description
		self.Type = type        # "BOOL", "INT", "FLOAT", "STRING" or "LABEL"
		self.Count = count
		self.Default = default  # vector[count]
		self.Mins = mins        # vector[count]
		self.Maxs = maxs        # vector[count]
		self.Value = default    # vector[count]

	def Clone(self):
		"""Return a new copy of this Option."""
		new = Option(self.Name, self.Description, self.Type, self.Count,
					 self.Default, self.Mins, self.Maxs)
		new.Value = self.Value[:]
		return new

class OptionList:
	"""Container for a group of Option objects."""
	def __init__(self, options=[]):
		self.__Options = []
		for opt in options:
			self.__Options.append(opt)

	def Clone(self):
		"""Return a new copy of this OptionList."""
		newList = []
		for opt in self.__Options:
			newList.append(opt.Clone())
		return OptionList(newList)

	def Options(self):
		"""Return list of Option objects"""
		return self.__Options<commit_msg>added __len__() function to OptionList class<commit_after># Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.
#
# Authors:
#   <NAME>

"""Chromium SPU, Node and Mothership classes used by the config tool.
This may eventually get rolled into the similar classes defined
in the mothership.
"""

# XXX eventually we'll rename these classes to match the mothership.
# That'll allow us to directly read Cr config files and build the
# mothership/node/spu data structures.


import wxPython
import re, string, sys
sys.path.append("../server")
import crconfig


# ----------------------------------------------------------------------

class Option:
	"""Class to describe an SPU/node/mothership option."""
	def __init__(self, name, description, type, count, default, mins, maxs):
		assert len(default) == count
		assert len(mins) == count or len(mins) == 0
		assert len(maxs) == count or len(maxs) == 0
		self.Name = name
		self.Description = description
		self.Type = type        # "BOOL", "INT", "FLOAT", "STRING" or "LABEL"
		self.Count = count
		self.Default = default  # vector[count]
		self.Mins = mins        # vector[count]
		self.Maxs = maxs        # vector[count]
		self.Value = default    # vector[count]

	def Clone(self):
		"""Return a new copy of this Option."""
		new = Option(self.Name, self.Description, self.Type, self.Count,
					 self.Default, self.Mins, self.Maxs)
		new.Value = self.Value[:]
		return new

class OptionList:
	"""Container for a group of Option objects."""
	def __init__(self, options=[]):
		self.__Options = []
		for opt in options:
			self.__Options.append(opt)

	def __len__(self):
		"""Return number of options in the list."""
		return len(self.__Options)

	def Clone(self):
		"""Return a new copy of this OptionList."""
		newList = []
		for opt in self.__Options:
			newList.append(opt.Clone())
		return OptionList(newList)

	def Options(self):
		"""Return list of Option objects"""
		return self.__Options
{'fraction_non_alphanumeric': 0.15113030226060453, 'fraction_numerical': 0.003048006096012192, 'mean_word_length': 3.2207931404072885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1433894', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1155, 'n_words': 419}