Skip to content

Commit a9fb721

Browse files
committed
Use options.get
1 parent b781d56 commit a9fb721

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cities_light/management/commands/cities_light.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def handle(self, *args, **options):
9090

9191
translation_hack_path = os.path.join(DATA_DIR, 'translation_hack')
9292

93-
self.noinsert = options['noinsert']
93+
self.noinsert = options.get('noinsert', False)
9494
self.widgets = [
9595
'RAM used: ',
9696
MemoryUsageWidget(),
@@ -104,13 +104,13 @@ def handle(self, *args, **options):
104104
for url in SOURCES:
105105
destination_file_name = url.split('/')[-1]
106106

107-
force = options['force_all'] or \
108-
destination_file_name in options['force']
107+
force = options.get('force_all', False) or \
108+
destination_file_name in options.get('force', [])
109109

110110
geonames = Geonames(url, force=force)
111111
downloaded = geonames.downloaded
112112

113-
force_import = options['force_import_all']
113+
force_import = options.get('force_import_all', False)
114114

115115
if not force_import:
116116
for f in options['force_import']:
@@ -122,7 +122,7 @@ def handle(self, *args, **options):
122122
self.logger.info('Importing %s' % destination_file_name)
123123

124124
if url in TRANSLATION_SOURCES:
125-
if options['hack_translations']:
125+
if options.get('hack_translations', False):
126126
if os.path.exists(translation_hack_path):
127127
self.logger.debug(
128128
'Using translation parsed data: %s' %
@@ -150,11 +150,11 @@ def handle(self, *args, **options):
150150

151151
progress.finish()
152152

153-
if url in TRANSLATION_SOURCES and options['hack_translations']:
153+
if url in TRANSLATION_SOURCES and options.get('hack_translations', False):
154154
with open(translation_hack_path, 'w+') as f:
155155
pickle.dump(self.translation_data, f)
156156

157-
if options['hack_translations']:
157+
if options.get('hack_translations', False):
158158
with open(translation_hack_path, 'r') as f:
159159
self.translation_data = pickle.load(f)
160160

0 commit comments

Comments
 (0)