MCPcopy
hub / github.com/django/django / validate_name

Method validate_name

django/core/management/templates.py:262–291  ·  view source on GitHub ↗
(self, name, name_or_dir="name")

Source from the content-addressed store, hash-verified

260 )
261
262 def validate_name(self, name, name_or_dir="name"):
263 if name is None:
264 raise CommandError(
265 "you must provide {an} {app} name".format(
266 an=self.a_or_an,
267 app=self.app_or_project,
268 )
269 )
270 # Check it's a valid directory name.
271 if not name.isidentifier():
272 raise CommandError(
273 "'{name}' is not a valid {app} {type}. Please make sure the "
274 "{type} is a valid identifier.".format(
275 name=name,
276 app=self.app_or_project,
277 type=name_or_dir,
278 )
279 )
280 # Check that __spec__ doesn't exist.
281 if find_spec(name) is not None:
282 raise CommandError(
283 "'{name}' conflicts with the name of an existing Python "
284 "module and cannot be used as {an} {app} {type}. Please try "
285 "another {type}.".format(
286 name=name,
287 an=self.a_or_an,
288 app=self.app_or_project,
289 type=name_or_dir,
290 )
291 )
292
293 def download(self, url):
294 """

Callers 1

handleMethod · 0.95

Calls 2

CommandErrorClass · 0.90
formatMethod · 0.45

Tested by

no test coverage detected