I am creating a script that walks through folders and scans for mxds. I use a set to get unique data sources and copy the data to a new folder keeping the same data format. I would then like to access the map document and repath all layers and tables to the copied data. I'm struggling to get the tables repathing code to work. In the below example, I have a fGDB table in the mxd and have copied the fGDB that it sits in to a new folder. I would thus like to repath to the table in the copied fGDB.
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os
mxdrep <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CURRENT"</SPAN><SPAN class="punctuation token">)</SPAN>
dfsrep <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListDataFrames<SPAN class="punctuation token">(</SPAN>mxdrep<SPAN class="punctuation token">)</SPAN>
ignoreStringList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Vendor"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"vendor"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">".sde"</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#Target folder containing the copied fGDB</SPAN>
dbFolder <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>projFolderPath<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Databases"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> dfrep <SPAN class="keyword token">in</SPAN> dfsrep<SPAN class="punctuation token">:</SPAN>
tablesRep <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListTableViews<SPAN class="punctuation token">(</SPAN>mxdrep<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> dfrep<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> tableRep <SPAN class="keyword token">in</SPAN> tablesRep<SPAN class="punctuation token">:</SPAN>
tablesRep <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListTableViews<SPAN class="punctuation token">(</SPAN>mxdrep<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> dfrep<SPAN class="punctuation token">)</SPAN>
tabRepDataSrc <SPAN class="operator token">=</SPAN> tableRep<SPAN class="punctuation token">.</SPAN>dataSource
tableRepView <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>TableView<SPAN class="punctuation token">(</SPAN>tabRepDataSrc<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> any<SPAN class="punctuation token">(</SPAN>folders <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>tabRepDataSrc<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> folders <SPAN class="keyword token">in</SPAN> ignoreStringList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
tabDirPath <SPAN class="operator token">=</SPAN> tableRep<SPAN class="punctuation token">.</SPAN>workspacePath
tabWsPath <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>dirname<SPAN class="punctuation token">(</SPAN>tabDirPath<SPAN class="punctuation token">)</SPAN>
tableRepView<SPAN class="punctuation token">.</SPAN>findAndReplaceWorkspacePath<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>tabWsPath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> dbFolder<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#arcpy.mapping.AddTableView(dfrep, tableRepView)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>