calcrepo/repos/cemetech.py
def updateFromArchivePage(self, archiveRoot, names, files, parent = "/", verbose=False):
		"""Helper function that works recursively over Cemetech file category/directory pages."""
		root = archiveRoot + parent
		archive = urllib.urlopen(root)
		archiveText = archive.read()
		archive.close()
				
		# Recursively call this function on all subdirectories
		working = archiveText
		folderString = 'solid #aaa;"><a href="index.php?mode=folder&path='
		while folderString in working:
			index = working.find(folderString) + len(folderString)
			folder = working[index:]
			folder = folder[:folder.find('>') - 1]
			working = working[index + len(folder):]
			if folder != "" and folder.count("/") > parent.count("/"):
				if verbose:
					self.printd("  Caching " + folder)
				self.updateFromArchivePage(archiveRoot, names, files, folder, verbose)
				
		# Now, step through all files and write them to the names and files objects
		working = archiveText
		fileString = "../scripts/countdown.php?" #/73/basic/games/aod73.zip&path=archives"
		while fileString in working:
			# Get the filename and path of the file
			index = working.find(fileString) + len(fileString)
			fileData = working[index:]
			fileData = fileData[:fileData.find("&path=archives")]
			
			# Get the proper name (title) of the file
			working = working[index:]
			nameData = working[working.find('1.25em;"><b>') + len('1.25em;"><b>'):]
			nameData = nameData[:nameData.find('</B>')]
			
			# Write files to index objects
			files.write(fileData + "\n")
			names.write(nameData + "\n")
Helper function that works recursively over Cemetech file category/directory pages.
Helper function that works recursively over Cemetech file category/directory pages.
Helper function that works recursively over Cemetech file category / directory pages .
def updateFromArchivePage(self, archiveRoot, names, files, parent = "/", verbose=False):
		root = archiveRoot + parent
		archive = urllib.urlopen(root)
		archiveText = archive.read()
		archive.close()
		working = archiveText
		folderString = 'solid #aaa;"><a href="index.php?mode=folder&path='
		while folderString in working:
			index = working.find(folderString) + len(folderString)
			folder = working[index:]
			folder = folder[:folder.find('>') - 1]
			working = working[index + len(folder):]
			if folder != "" and folder.count("/") > parent.count("/"):
				if verbose:
					self.printd("  Caching " + folder)
				self.updateFromArchivePage(archiveRoot, names, files, folder, verbose)
		working = archiveText
		fileString = "../scripts/countdown.php?" 
		while fileString in working:
			index = working.find(fileString) + len(fileString)
			fileData = working[index:]
			fileData = fileData[:fileData.find("&path=archives")]
			working = working[index:]
			nameData = working[working.find('1.25em;"><b>') + len('1.25em;"><b>'):]
			nameData = nameData[:nameData.find('</B>')]
			files.write(fileData + "\n")
			names.write(nameData + "\n")
def updateFromArchivePage ( self , archiveRoot , names , files , parent = "/" , verbose = False ) : root = archiveRoot + parent archive = urllib . urlopen ( root ) archiveText = archive . read ( ) archive . close ( ) working = archiveText folderString = 'solid #aaa;"><a href="index.php?mode=folder&path=' while folderString in working : index = working . find ( folderString ) + len ( folderString ) folder = working [ index : ] folder = folder [ : folder . find ( '>' ) - 1 ] working = working [ index + len ( folder ) : ] if folder != "" and folder . count ( "/" ) > parent . count ( "/" ) : if verbose : self . printd ( "  Caching " + folder ) self . updateFromArchivePage ( archiveRoot , names , files , folder , verbose ) working = archiveText fileString = "../scripts/countdown.php?" while fileString in working : index = working . find ( fileString ) + len ( fileString ) fileData = working [ index : ] fileData = fileData [ : fileData . find ( "&path=archives" ) ] working = working [ index : ] nameData = working [ working . find ( '1.25em;"><b>' ) + len ( '1.25em;"><b>' ) : ] nameData = nameData [ : nameData . find ( '</B>' ) ] files . write ( fileData + "\n" ) names . write ( nameData + "\n" )
Helper function that works recursively over Cemetech file category/directory pages.
Helper function that works recursively over Cemetech file category / directory pages .
"""Helper function that works recursively over Cemetech file category/directory pages.""" # Recursively call this function on all subdirectories # Now, step through all files and write them to the names and files objects #/73/basic/games/aod73.zip&path=archives" # Get the filename and path of the file # Get the proper name (title) of the file # Write files to index objects
self
archiveRoot
names
files
parent
verbose