MCPcopy
hub / github.com/django/django / extract

Method extract

django/core/management/templates.py:365–381  ·  view source on GitHub ↗

Extract the given file to a temporary directory and return the path of the directory with the extracted content.

(self, filename)

Source from the content-addressed store, hash-verified

363 return base, ext
364
365 def extract(self, filename):
366 """
367 Extract the given file to a temporary directory and return
368 the path of the directory with the extracted content.
369 """
370 prefix = "django_%s_template_" % self.app_or_project
371 tempdir = tempfile.mkdtemp(prefix=prefix, suffix="_extract")
372 self.paths_to_remove.append(tempdir)
373 if self.verbosity >= 2:
374 self.stdout.write("Extracting %s" % filename)
375 try:
376 archive.extract(filename, tempdir)
377 return tempdir
378 except (archive.ArchiveException, OSError) as e:
379 raise CommandError(
380 "couldn't extract file %s to %s: %s" % (filename, tempdir, e)
381 )
382
383 def is_url(self, template):
384 """Return True if the name looks like a URL."""

Callers 1

handle_templateMethod · 0.95

Calls 4

CommandErrorClass · 0.90
mkdtempMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected