Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
c61d1361
Kaydet (Commit)
c61d1361
authored
May 30, 2017
tarafından
Adam Johnson
Kaydeden (comit)
Tim Graham
May 30, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
DRY'd startapp and startproject management commands.
üst
b3e55109
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
38 deletions
+31
-38
startapp.py
django/core/management/commands/startapp.py
+2
-17
startproject.py
django/core/management/commands/startproject.py
+2
-16
templates.py
django/core/management/templates.py
+27
-5
No files found.
django/core/management/commands/startapp.py
Dosyayı görüntüle @
c61d1361
from
importlib
import
import_module
from
django.core.management.base
import
CommandError
from
django.core.management.templates
import
TemplateCommand
...
...
@@ -12,18 +9,6 @@ class Command(TemplateCommand):
missing_args_message
=
"You must provide an application name."
def
handle
(
self
,
**
options
):
app_name
,
target
=
options
.
pop
(
'name'
),
options
.
pop
(
'directory'
)
self
.
validate_name
(
app_name
,
"app"
)
# Check that the app_name cannot be imported.
try
:
import_module
(
app_name
)
except
ImportError
:
pass
else
:
raise
CommandError
(
"
%
r conflicts with the name of an existing Python module and "
"cannot be used as an app name. Please try another name."
%
app_name
)
app_name
=
options
.
pop
(
'name'
)
target
=
options
.
pop
(
'directory'
)
super
()
.
handle
(
'app'
,
app_name
,
target
,
**
options
)
django/core/management/commands/startproject.py
Dosyayı görüntüle @
c61d1361
from
importlib
import
import_module
from
django.core.management.base
import
CommandError
from
django.core.management.templates
import
TemplateCommand
from
..utils
import
get_random_secret_key
...
...
@@ -14,19 +11,8 @@ class Command(TemplateCommand):
missing_args_message
=
"You must provide a project name."
def
handle
(
self
,
**
options
):
project_name
,
target
=
options
.
pop
(
'name'
),
options
.
pop
(
'directory'
)
self
.
validate_name
(
project_name
,
"project"
)
# Check that the project_name cannot be imported.
try
:
import_module
(
project_name
)
except
ImportError
:
pass
else
:
raise
CommandError
(
"
%
r conflicts with the name of an existing Python module and "
"cannot be used as a project name. Please try another name."
%
project_name
)
project_name
=
options
.
pop
(
'name'
)
target
=
options
.
pop
(
'directory'
)
# Create a random SECRET_KEY to put it in the main settings.
options
[
'secret_key'
]
=
get_random_secret_key
()
...
...
django/core/management/templates.py
Dosyayı görüntüle @
c61d1361
...
...
@@ -7,6 +7,7 @@ import shutil
import
stat
import
sys
import
tempfile
from
importlib
import
import_module
from
os
import
path
from
urllib.request
import
urlretrieve
...
...
@@ -210,14 +211,35 @@ class TemplateCommand(BaseCommand):
(
self
.
app_or_project
,
template
))
def
validate_name
(
self
,
name
,
app_or_project
):
a_or_an
=
'an'
if
app_or_project
==
'app'
else
'a'
if
name
is
None
:
raise
CommandError
(
"you must provide
%
s
%
s name"
%
(
"an"
if
app_or_project
==
"app"
else
"a"
,
app_or_project
))
# If it's not a valid directory name.
raise
CommandError
(
'you must provide {an} {app} name'
.
format
(
an
=
a_or_an
,
app
=
app_or_project
,
))
# Check it's a valid directory name.
if
not
name
.
isidentifier
():
raise
CommandError
(
"
%
r is not a valid
%
s name. Please make sure the name is "
"a valid identifier."
%
(
name
,
app_or_project
)
"'{name}' is not a valid {app} name. Please make sure the "
"name is a valid identifier."
.
format
(
name
=
name
,
app
=
app_or_project
,
)
)
# Check it cannot be imported.
try
:
import_module
(
name
)
except
ImportError
:
pass
else
:
raise
CommandError
(
"'{name}' conflicts with the name of an existing Python "
"module and cannot be used as {an} {app} name. Please try "
"another name."
.
format
(
name
=
name
,
an
=
a_or_an
,
app
=
app_or_project
,
)
)
def
download
(
self
,
url
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment