3434# Python-version dependent imports
3535ARCPY_2 = sys .version_info [0 ] < 3
3636if ARCPY_2 :
37- # import to get access to 'private' helper methds
37+ # import to get access to 'private' helper methods
3838 from . import _mapping2 as _mh
3939
4040 # import all 'public' methods into current namespace
4141 from ._mapping2 import *
4242else :
43- # import to get access to 'private' helper methds
43+ # import to get access to 'private' helper methods
4444 from . import _mapping3 as _mh
4545
4646 # import all 'public' methods into current namespace
@@ -121,8 +121,9 @@ def change_data_sources(mxd_or_proj, data_sources):
121121
122122 try :
123123 if not len (errors ) == 0 :
124- raise ChangeDataSourcesError ("A number of errors were encountered whilst change layer data sources." ,
125- errors )
124+ raise ChangeDataSourcesError (
125+ "A number of errors were encountered whilst change layer data sources." , errors
126+ )
126127
127128 if document_was_opened :
128129 # If the document was opened by this function, the map has to be saved for changes to be persisted
@@ -183,8 +184,9 @@ def freeze(d):
183184 def match_new_data_source (layer_or_table ):
184185 logger = _get_logger ()
185186
186- if layer_or_table == None or (layer_or_table .get ("isGroupLayer" ) == True
187- and layer_or_table .get ("isNetworkAnalystLayer" ) != True ):
187+ if layer_or_table == None or (
188+ layer_or_table .get ("isGroupLayer" ) == True and layer_or_table .get ("isNetworkAnalystLayer" ) != True
189+ ):
188190 # Layers that can't be described or are group layers (except NA layers) can't have their data updated
189191 return None
190192
@@ -208,12 +210,14 @@ def match_new_data_source(layer_or_table):
208210
209211 if tokens ["dataSet" ] is not None and tokens ["schema" ] is not None :
210212 logger .debug (1.11 )
211- new_conn ["workspacePath" ] = "{}\\ {}.{}.gdb" .format (new_conn ["workspacePath" ],
212- tokens ["schema" ], tokens ["dataSet" ])
213+ new_conn ["workspacePath" ] = "{}\\ {}.{}.gdb" .format (
214+ new_conn ["workspacePath" ], tokens ["schema" ], tokens ["dataSet" ]
215+ )
213216 elif tokens ["dataSet" ] is not None :
214217 logger .debug (1.12 )
215- new_conn ["workspacePath" ] = "{}\\ {}.gdb" .format (new_conn ["workspacePath" ],
216- tokens ["dataSet" ])
218+ new_conn ["workspacePath" ] = "{}\\ {}.gdb" .format (
219+ new_conn ["workspacePath" ], tokens ["dataSet" ]
220+ )
217221 else :
218222 logger .debug (1.13 )
219223 new_conn ["workspacePath" ] = "{}\\ {}.gdb" .format (new_conn ["workspacePath" ], tokens ["table" ])
@@ -224,10 +228,12 @@ def match_new_data_source(layer_or_table):
224228
225229 return new_conn
226230
227- return [{
228- "layers" : [match_new_data_source (layer ) for layer in df ["layers" ]],
229- "tables" : [match_new_data_source (table ) for table in df ["tables" ]]
230- } for df in map_desc ["maps" ]]
231+ return [
232+ {
233+ "layers" : [match_new_data_source (layer ) for layer in df ["layers" ]],
234+ "tables" : [match_new_data_source (table ) for table in df ["tables" ]]
235+ } for df in map_desc ["maps" ]
236+ ]
231237
232238
233239def describe (mxd_or_proj ):
@@ -315,14 +321,12 @@ def _match_layers(was_layers, now_layers):
315321 },
316322 {
317323 # same name and id, datasource changed
318- 'fn' :
319- lambda a , b : b
324+ 'fn' : lambda a , b : b
320325 if same_id (a , b ) and same_name (a , b ) and not is_resolved_was (a ) and not is_resolved_now (b ) else None
321326 },
322327 {
323328 # same id and datasource, name changed
324- 'fn' :
325- lambda a , b : b
329+ 'fn' : lambda a , b : b
326330 if same_id (a , b ) and same_datasource (a , b ) and not is_resolved_was (a ) and not is_resolved_now (b ) else None
327331 },
328332 {
@@ -332,8 +336,7 @@ def _match_layers(was_layers, now_layers):
332336 },
333337 {
334338 # same name and datasource, id changed
335- 'fn' :
336- lambda a , b : b
339+ 'fn' : lambda a , b : b
337340 if same_name (a , b ) and same_datasource (a , b ) and not is_resolved_was (a ) and not is_resolved_now (b ) else None
338341 },
339342 {
0 commit comments