mirror of https://github.com/django/django.git
Refs #32317 -- Simplified find_fixtures() in loaddata command.
This always replaces 'fixture_name' with its base name, which preserves the previous behavior, because os.path.basename() was not called only on relative paths without os.path.sep i.e. when base name was equal to the file name. This also changes os.path.dirname() and os.path.basename() calls to the equivalent os.path.split() call.
This commit is contained in:
parent
1e655d35ad
commit
1557778121
|
@ -235,15 +235,14 @@ class Command(BaseCommand):
|
||||||
if self.verbosity >= 2:
|
if self.verbosity >= 2:
|
||||||
self.stdout.write("Loading '%s' fixtures..." % fixture_name)
|
self.stdout.write("Loading '%s' fixtures..." % fixture_name)
|
||||||
|
|
||||||
|
dirname, basename = os.path.split(fixture_name)
|
||||||
if os.path.isabs(fixture_name):
|
if os.path.isabs(fixture_name):
|
||||||
fixture_dirs = [os.path.dirname(fixture_name)]
|
fixture_dirs = [dirname]
|
||||||
fixture_name = os.path.basename(fixture_name)
|
|
||||||
else:
|
else:
|
||||||
fixture_dirs = self.fixture_dirs
|
fixture_dirs = self.fixture_dirs
|
||||||
if os.path.sep in os.path.normpath(fixture_name):
|
if os.path.sep in os.path.normpath(fixture_name):
|
||||||
fixture_dirs = [os.path.join(dir_, os.path.dirname(fixture_name))
|
fixture_dirs = [os.path.join(dir_, dirname) for dir_ in fixture_dirs]
|
||||||
for dir_ in fixture_dirs]
|
fixture_name = basename
|
||||||
fixture_name = os.path.basename(fixture_name)
|
|
||||||
|
|
||||||
suffixes = (
|
suffixes = (
|
||||||
'.'.join(ext for ext in combo if ext)
|
'.'.join(ext for ext in combo if ext)
|
||||||
|
|
Loading…
Reference in New Issue