<commit_before>"""Utilities to read and write CVS admin files (esp. CVS/Entries)"""

import string
import os
import time


class Entry:

	"""Class representing one (parsed) line from CVS/Entries"""
	
	def __init__(self, line):
		words = string.splitfields(line, '/')
		self.file = words[1]
		self.rev = words[2]
		dates = words[3] # ctime, mtime
		if len(dates) != 49 or dates[:7] == 'Initial':
			self.ctime = None
			self.mtime = None
			self.new = dates[:7] == 'Initial'
		else:
			self.ctime = unctime(dates[:24])
			self.mtime = unctime(dates[25:])
			self.new = 0
		self.extra = words[4]
		self.sum = None
	
	def unparse(self):
		if self.new:
			dates = "Initial %s" % self.file
		else:
			dates = gmctime(self.ctime) + ' ' + gmctime(self.mtime)
		return "/%s/%s/%s/%s/\n" % (
			self.file,
			self.rev,
			dates,
			self.extra)
	
	def setsum(self, sum):
		self.sum = sum
	
	def getsum(self):
		return self.sum
	
	def sethexsum(self, hexsum):
		self.setsum(unhexify(hexsum))
	
	def gethexsum(self):
		if self.sum:
			return hexify(self.sum)
		else:
			return None


class CVS:

	"""Class representing the contents of CVS/Entries (and CVS/Sums)"""
	
	def __init__(self):
		self.readentries()
	
	def readentries(self):
		self.entries = {}
		f = self.cvsopen("Entries")
		while 1:
			line = f.readline()
			if not line: break
			e = Entry(line)
			self.entries[e.file] = e
		f.close()
	
	def readsums(self):
		try:
			f = self.cvsopen("Sums")<commit_msg>added Entry.dump() method<commit_after>"""Utilities to read and write CVS admin files (esp. CVS/Entries)"""

import string
import os
import time


class Entry:

	"""Class representing one (parsed) line from CVS/Entries"""
	
	def __init__(self, line):
		words = string.splitfields(line, '/')
		self.file = words[1]
		self.rev = words[2]
		dates = words[3] # ctime, mtime
		if len(dates) != 49 or dates[:7] == 'Initial':
			self.ctime = None
			self.mtime = None
			self.new = dates[:7] == 'Initial'
		else:
			self.ctime = unctime(dates[:24])
			self.mtime = unctime(dates[25:])
			self.new = 0
		self.extra = words[4]
		self.sum = None
	
	def unparse(self):
		if self.new:
			dates = "Initial %s" % self.file
		else:
			dates = gmctime(self.ctime) + ' ' + gmctime(self.mtime)
		return "/%s/%s/%s/%s/\n" % (
			self.file,
			self.rev,
			dates,
			self.extra)
	
	def setsum(self, sum):
		self.sum = sum
	
	def getsum(self):
		return self.sum
	
	def sethexsum(self, hexsum):
		self.setsum(unhexify(hexsum))
	
	def gethexsum(self):
		if self.sum:
			return hexify(self.sum)
		else:
			return None
	
	def dump(self):
		keys = self.__dict__.keys()
		keys.sort()
		for key in keys:
			print "%-15s: %s" % (key, `self.__dict__[key]`)
		print '-'*45


class CVS:

	"""Class representing the contents of CVS/Entries (and CVS/Sums)"""
	
	def __init__(self):
		self.readentries()
	
	def readentries(self):
		self.entries = {}
		f = self.cvsopen("Entries")
		while 1:
			line = f.readline()
			if not line: break
			e = Entry(line)
			self.entries[e.file] = e
		f.close()
	
	def readsums(self):
		try:
			f = self.cvsopen("Sums")
{'fraction_non_alphanumeric': 0.15744957709824334, 'fraction_numerical': 0.01040988939492518, 'mean_word_length': 3.1330645161290325, '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': '3785250', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1178, 'n_words': 293}