@@ -90,7 +90,7 @@ def handle(self, *args, **options):
90
90
91
91
translation_hack_path = os .path .join (DATA_DIR , 'translation_hack' )
92
92
93
- self .noinsert = options [ 'noinsert' ]
93
+ self .noinsert = options . get ( 'noinsert' , False )
94
94
self .widgets = [
95
95
'RAM used: ' ,
96
96
MemoryUsageWidget (),
@@ -104,13 +104,13 @@ def handle(self, *args, **options):
104
104
for url in SOURCES :
105
105
destination_file_name = url .split ('/' )[- 1 ]
106
106
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' , [])
109
109
110
110
geonames = Geonames (url , force = force )
111
111
downloaded = geonames .downloaded
112
112
113
- force_import = options [ 'force_import_all' ]
113
+ force_import = options . get ( 'force_import_all' , False )
114
114
115
115
if not force_import :
116
116
for f in options ['force_import' ]:
@@ -122,7 +122,7 @@ def handle(self, *args, **options):
122
122
self .logger .info ('Importing %s' % destination_file_name )
123
123
124
124
if url in TRANSLATION_SOURCES :
125
- if options [ 'hack_translations' ] :
125
+ if options . get ( 'hack_translations' , False ) :
126
126
if os .path .exists (translation_hack_path ):
127
127
self .logger .debug (
128
128
'Using translation parsed data: %s' %
@@ -150,11 +150,11 @@ def handle(self, *args, **options):
150
150
151
151
progress .finish ()
152
152
153
- if url in TRANSLATION_SOURCES and options [ 'hack_translations' ] :
153
+ if url in TRANSLATION_SOURCES and options . get ( 'hack_translations' , False ) :
154
154
with open (translation_hack_path , 'w+' ) as f :
155
155
pickle .dump (self .translation_data , f )
156
156
157
- if options [ 'hack_translations' ] :
157
+ if options . get ( 'hack_translations' , False ) :
158
158
with open (translation_hack_path , 'r' ) as f :
159
159
self .translation_data = pickle .load (f )
160
160
0 commit comments