Skip to content

Commit 21c0f48

Browse files
committed
add file provider, catch type error for inheritance, remove debug line
1 parent d9b63f1 commit 21c0f48

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

django_seed/guessers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def guess_format(self, field):
101101
return lambda x: provider.comma_sep_ints()
102102

103103
if isinstance(field, BinaryField): return lambda x: provider.binary()
104-
if isinstance(field, ImageField): return lambda x: None
104+
if isinstance(field, ImageField): return lambda x: provider.file_name()
105105
if isinstance(field, FilePathField): return lambda x: provider.file_name()
106-
if isinstance(field, FileField): return lambda x: None
106+
if isinstance(field, FileField): return lambda x: provider.file_name()
107107

108108
if isinstance(field, CharField):
109109
if field.choices:

django_seed/management/commands/seed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def handle_app_config(self, app_config, **options):
3030
seeder = Seed.seeder()
3131

3232
for model in self.sorted_models(app_config):
33-
print(model)
3433
seeder.add_entity(model, number)
3534
print('Seeding %i %ss' % (number, model.__name__))
3635

django_seed/providers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88

99

10-
file_extenstions = ( "flac", "mp3", "wav", "bmp", "gif", "jpeg", "jpg", "png",
10+
file_extensions = ( "flac", "mp3", "wav", "bmp", "gif", "jpeg", "jpg", "png",
1111
"tiff", "css", "csv", "html", "js", "json", "txt", "mp4",
1212
"avi", "mov", "webm" )
1313

@@ -45,7 +45,7 @@ def rand_float(self):
4545

4646
def file_name(self):
4747
filename = self.faker.word()
48-
extension = random.choice(file_extenstions)
48+
extension = random.choice(file_extensions)
4949
return '{0}.{1}'.format(filename, extension)
5050

5151
def comma_sep_ints(self):

django_seed/toposort.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,8 @@ def toposort_flatten(data, sort=True):
6565

6666
result = []
6767
for d in toposort(data):
68-
result.extend((sorted if sort else list)(d))
68+
try:
69+
result.extend((sorted if sort else list)(d))
70+
except TypeError as e:
71+
result.extend(list(d))
6972
return result

0 commit comments

Comments
 (0)