<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import json

APPS_ROOT = 'apps'
WEB2PY_ROOT = 'web2py'
SUBFOLDERS = [ 'models', 'views', 'controllers', 'static', 'modules' ]

class ImportAbstraction( object ):
	
	def __init__( self, app_name, app_model, app_desc ):
		self.app_desc = app_desc
		self.app_name = app_name
		self.app_model = app_model
		self.app_path = '{}/{}'.format( APPS_ROOT, app_name )
		self.data_path = '{}/{}/data/{}'.format( APPS_ROOT, app_name, app_model )
		self.web2py_path = '{}/applications/{}'.format( WEB2PY_ROOT, app_name )
		self.database_path = '{}/{}/databases'.format( APPS_ROOT, app_name )
	
	def AddAppFolder( self ):
		if os.path.exists( self.data_path ):
			return False
		
		print '--------------------------------------------------------------------------------'
		print 'Import "{}" as a web2py application...'.format( self.app_desc )
		print '          app = {}'.format( self.app_name )
		print '        model = {}'.format( self.app_model )
		print '     app_path = {}'.format( self.app_path )
		print '    data_path = {}'.format( self.data_path )
		print 'database_path = {}'.format( self.database_path )
		print '  web2py_path = {}'.format( self.web2py_path )
		print '--------------------------------------------------------------------------------'
		
		if not os.path.exists( self.app_path ):
			print 'Creating app folder: {}'.format( self.app_path )
			os.makedirs( self.app_path )
		
		if not os.path.exists( self.data_path ):
			print 'Creating data subfolder: {}'.format( self.data_path )
			os.makedirs( self.data_path )
		
		if not os.path.exists( self.database_path ):
			print 'Creating database subfolder: {}'.format( self.database_path )
			os.makedirs( self.database_path )
		
		for subfolder in SUBFOLDERS:
			app_subpath = '{}/{}'.format( self.app_path, subfolder )
			if not os.path.exists( app_subpath ):
				print 'Linking subfolder: {}'.format( app_subpath )
				os.system( 'ln -s ../../server_src/{} {}/{}'.format( subfolder, self.app_path, subfolder ) )
		
		filename = '{}/__init__.py'.format( self.app_path )
		if not os.path.exists( filename ):
			print 'Setting up __init__.py'
			os.system( 'touch {}'.format( filename ) )
		
		return True
	<commit_msg>More robust ordering of setting up a new app.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import json

APPS_ROOT = 'apps'
WEB2PY_ROOT = 'web2py'
SUBFOLDERS = [ 'models', 'views', 'controllers', 'static', 'modules' ]

class ImportAbstraction( object ):
	
	def __init__( self, app_name, app_model, app_desc ):
		self.app_desc = app_desc
		self.app_name = app_name
		self.app_model = app_model
		self.app_path = '{}/{}'.format( APPS_ROOT, app_name )
		self.data_path = '{}/{}/data/{}'.format( APPS_ROOT, app_name, app_model )
		self.web2py_path = '{}/applications/{}'.format( WEB2PY_ROOT, app_name )
		self.database_path = '{}/{}/databases'.format( APPS_ROOT, app_name )
	
	def AddAppFolder( self ):
		if os.path.exists( self.data_path ):
			return False
		
		print '--------------------------------------------------------------------------------'
		print 'Import "{}" as a web2py application...'.format( self.app_desc )
		print '          app = {}'.format( self.app_name )
		print '        model = {}'.format( self.app_model )
		print '     app_path = {}'.format( self.app_path )
		print '    data_path = {}'.format( self.data_path )
		print 'database_path = {}'.format( self.database_path )
		print '  web2py_path = {}'.format( self.web2py_path )
		print '--------------------------------------------------------------------------------'
		
		if not os.path.exists( self.app_path ):
			print 'Creating app folder: {}'.format( self.app_path )
			os.makedirs( self.app_path )
		
		if not os.path.exists( self.database_path ):
			print 'Creating database subfolder: {}'.format( self.database_path )
			os.makedirs( self.database_path )
		
		for subfolder in SUBFOLDERS:
			app_subpath = '{}/{}'.format( self.app_path, subfolder )
			if not os.path.exists( app_subpath ):
				print 'Linking subfolder: {}'.format( app_subpath )
				os.system( 'ln -s ../../server_src/{} {}/{}'.format( subfolder, self.app_path, subfolder ) )
		
		filename = '{}/__init__.py'.format( self.app_path )
		if not os.path.exists( filename ):
			print 'Setting up __init__.py'
			os.system( 'touch {}'.format( filename ) )

		if not os.path.exists( self.data_path ):
			print 'Creating data subfolder: {}'.format( self.data_path )
			os.makedirs( self.data_path )

		return True
	
{'fraction_non_alphanumeric': 0.21797703180212014, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 2.5661417322834645, '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': '4510363', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1479, 'n_words': 346}