o 3Ûøaã@sDddlZddlZddlZddlmZddlmZGdd„deƒZdS)éN)ÚPath)ÚBaseDatabaseCreationc@sLeZdZedd„ƒZdd„Zddd„Zdd „Zdd d „Zd d „Z dd„Z dS)ÚDatabaseCreationcCst|tƒ o |dkp d|vS)Nú:memory:z mode=memory)Ú isinstancer)Ú database_name©rúE/usr/lib/python3/dist-packages/django/db/backends/sqlite3/creation.pyÚis_in_memory_db s ÿz DatabaseCreation.is_in_memory_dbcCs,|jjddp d}|dkrd|jjS|S)NÚTESTÚNAMErz)file:memorydb_%s?mode=memory&cache=shared)Ú connectionÚ settings_dictÚalias)ÚselfÚtest_database_namerrr Ú_get_test_db_names z"DatabaseCreation._get_test_db_nameFc CsÌ| ¡}|r|S| |¡sd|dkr| d| ||¡f¡t |tj¡rd|s,td|ƒ}|s2|dkrZzt |¡W|St yY}z| d|¡t   d¡WYd}~|Sd}~ww| d¡t   d¡|S)Néú,Destroying old test database for alias %s...zXType 'yes' if you would like to try deleting the test database '%s', or 'no' to cancel: Úyesú/Got an error deleting the old test database: %sézTests cancelled.) rr ÚlogÚ_get_database_display_strÚosÚaccessÚF_OKÚinputÚremoveÚ ExceptionÚsysÚexit)rÚ verbosityÚ autoclobberÚkeepdbrÚconfirmÚerrr Ú_create_test_dbs8  ÿÿÿ  ú€ú  z DatabaseCreation._create_test_dbcCsL|jj}|d}| |¡r|Stj |d¡\}}i|¥dd |||¡i¥S)Nr z{}_{}.{})r rr rÚpathÚsplitextÚformat)rÚsuffixÚorig_settings_dictÚsource_database_nameÚrootÚextrrr Úget_test_db_clone_settings3s  z+DatabaseCreation.get_test_db_clone_settingsc Csü|jjd}| |¡d}| |¡s|t |tj¡rS|rdS|dkr-| d| ||¡f¡zt  |¡Wnt yR}z| d|¡t   d¡WYd}~nd}~wwz t  ||¡WdSt y{}z| d|¡t   d¡WYd}~dSd}~wwdS)Nr rrrrz*Got an error cloning the test database: %s)r rr0r rrrrrrrr r!ÚshutilÚcopy)rr+r"r$r-Útarget_database_namer&rrr Ú_clone_test_db<s2   ÿ€þ€þðzDatabaseCreation._clone_test_dbcCs$|r| |¡st |¡dSdSdS)N)r rr)rrr"rrr Ú_destroy_test_dbTsþz!DatabaseCreation._destroy_test_dbcCsH| ¡}|jjdg}| |¡r| |jj¡t|ƒS| |¡t|ƒS)a  Return a tuple that uniquely identifies a test database. This takes into account the special cases of ":memory:" and "" for SQLite since the databases will be distinct despite having the same TEST NAME. See https://www.sqlite.org/inmemorydb.html r )rr rr ÚappendrÚtuple)rrÚsigrrr Útest_db_signatureYs  ÿz"DatabaseCreation.test_db_signatureN)F) Ú__name__Ú __module__Ú __qualname__Ú staticmethodr rr'r0r4r5r9rrrr r s    r)rr1r ÚpathlibrÚ django.db.backends.base.creationrrrrrr Ús