<commit_before>import web
import sys
import importlib

programID = "Endpoint Simulator v0.1"
urls = ('/(.*)', 'base')

def importAllEndpointFiles(endpointDefinitions, urls):
	""" Import all python files from endpointDefinitions and 
	    add their urls to the presented ones.

		>>> importAllEndpointFiles (['Test'])
		('/(.*)', 'base', '/Test/(.*)', 'test')"""

	completeUrlList = ()
	for enpointFile in endpointDefinitions:
		print "Attempting to import {}".format(enpointFile)
		try:
			importlib.import_module(enpointFile)
			urlList = sys.modules[enpointFile].urls
			completeUrlList += urlList
			print "Imported {}.py presenting the endpoints {}".format(enpointFile, urlList)
		except ImportError:
			print "Cannot import {}".format(enpointFile)

	completeUrlList += urls
	return completeUrlList

#TODO Need to order these 
#So I'll want to be able to add to this and have them ordered by granualty, most fine-grained first
allUrls = importAllEndpointFiles(sys.argv[2:], urls)
print "Offering : \n{}".format(allUrls)

#Classes in 'urls' inside packages need to be prefixed with the package name, e.g. 'Test.test'
app = web.application(allUrls, locals())



################################
#  Endpoint Definition Classes #
################################

class base:        
    def GET(self, name):
        return programID

if __name__ == "__main__":
    app.run()<commit_msg>doctest comments aren't much use at the moment<commit_after>import web
import sys
import importlib

programID = "Endpoint Simulator v0.1"
urls = ('/(.*)', 'base')

def importAllEndpointFiles(endpointDefinitions, urls):
	""" Import all python files from endpointDefinitions and 
	add their urls to the presented ones."""

	completeUrlList = ()
	for enpointFile in endpointDefinitions:
		print "Attempting to import {}".format(enpointFile)
		try:
			importlib.import_module(enpointFile)
			urlList = sys.modules[enpointFile].urls
			completeUrlList += urlList
			print "Imported {}.py presenting the endpoints {}".format(enpointFile, urlList)
		except ImportError:
			print "Cannot import {}".format(enpointFile)

	completeUrlList += urls
	return completeUrlList

#TODO Need to order these 
#So I'll want to be able to add to this and have them ordered by granualty, most fine-grained first
allUrls = importAllEndpointFiles(sys.argv[2:], urls)
print "Offering : \n{}".format(allUrls)

#Classes in 'urls' inside packages need to be prefixed with the package name, e.g. 'Test.test'
app = web.application(allUrls, locals())



################################
#  Endpoint Definition Classes #
################################

class base:        
    def GET(self, name):
        return programID

if __name__ == "__main__":
	app.run()
{'fraction_non_alphanumeric': 0.15311004784688995, 'fraction_numerical': 0.002208317997791682, 'mean_word_length': 4.686192468619247, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 6, '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': '3460419', 'n_tokens_mistral': 847, 'n_tokens_neox': 793, 'n_words': 263}