@@ -40,19 +40,22 @@ def feature_class(self, input_fc, output_workbook, use_field_alias_as_column_hea
4040 raise ValueError ("output_workbook already exists." )
4141
4242 # get input feature class description for copy process
43- d = arcpy .Describe (input_fc )
43+ input_fc_desc = arcpy .Describe (input_fc )
4444
45- if not d .dataType == "FeatureClass" :
45+ if not input_fc_desc .dataType == "FeatureClass" :
4646 raise ValueError ("input_fc is not of type 'FeatureClass'." )
4747
4848 output_workbook = xlsxwriter .Workbook (str (output_workbook ))
4949
50- sheet_name = self ._feature_class_default_name (d , output_workbook )
50+ sheet_name = self ._feature_class_default_name (input_fc_desc , output_workbook )
5151
52- self ._feature_class (d , output_workbook , sheet_name , use_field_alias_as_column_header )
52+ self ._feature_class (input_fc_desc , output_workbook , sheet_name , use_field_alias_as_column_header )
5353
5454 output_workbook .close ()
5555
56+ del input_fc_desc
57+ arcpy .management .ClearWorkspaceCache ()
58+
5659 def table (self , input_table , output_workbook , use_field_alias_as_column_header = False ):
5760 if not arcpy .Exists (input_table ):
5861 raise ValueError ("input_table does not exist." )
@@ -63,55 +66,68 @@ def table(self, input_table, output_workbook, use_field_alias_as_column_header=F
6366 raise ValueError ("output_table already exists." )
6467
6568 # get input feature class description for copy process
66- d = arcpy .Describe (input_table )
69+ input_table_desc = arcpy .Describe (input_table )
6770
68- if not d .dataType == "Table" :
71+ if not input_table_desc .dataType == "Table" :
6972 raise ValueError ("input_table is not of type 'Table'." )
7073
7174 output_workbook = xlsxwriter .Workbook (str (output_workbook ))
7275
73- sheet_name = self ._table_default_name (d , output_workbook )
76+ sheet_name = self ._table_default_name (input_table_desc , output_workbook )
7477
75- self ._table (d , output_workbook , sheet_name , use_field_alias_as_column_header )
78+ self ._table (input_table_desc , output_workbook , sheet_name , use_field_alias_as_column_header )
7679
7780 output_workbook .close ()
7881
82+ del input_table_desc
83+ arcpy .management .ClearWorkspaceCache ()
84+
7985 def relationship_class (self , input_rel , output_rel ):
8086 return super ().relationship_class (input_rel , output_rel )
8187
8288 def workspace (self , input_workspace , output_path , use_field_alias_as_column_header = False ):
8389 if not arcpy .Exists (input_workspace ):
8490 raise ValueError ("input_workspace does not exist." )
8591
86- d = arcpy .Describe (input_workspace )
92+ input_workspace_desc = arcpy .Describe (input_workspace )
8793
88- if not d .dataType == "Workspace" :
94+ if not input_workspace_desc .dataType == "Workspace" :
8995 raise ValueError ("input_workspace is not of type 'Workspace'." )
9096
9197 # get output_path as a Path object
9298 output_path = Path (output_path ).resolve ()
9399
94100 output_workbook = self ._create_output_workspace (
95- output_path , use_field_alias_as_column_header = use_field_alias_as_column_header )
101+ output_path , use_field_alias_as_column_header = use_field_alias_as_column_header
102+ )
96103
97- for c in d .children :
104+ for c in input_workspace_desc .children :
98105 if c .dataType == 'FeatureClass' :
99- self ._feature_class (c ,
100- output_workbook ,
101- self ._feature_class_default_name (c , output_workbook ),
102- use_field_alias_as_column_header = use_field_alias_as_column_header )
106+ self ._feature_class (
107+ c ,
108+ output_workbook ,
109+ self ._feature_class_default_name (c , output_workbook ),
110+ use_field_alias_as_column_header = use_field_alias_as_column_header
111+ )
103112 elif c .dataType == 'Table' :
104- self ._table (c ,
105- output_workbook ,
106- self ._table_default_name (c , output_workbook ),
107- use_field_alias_as_column_header = use_field_alias_as_column_header )
113+ self ._table (
114+ c ,
115+ output_workbook ,
116+ self ._table_default_name (c , output_workbook ),
117+ use_field_alias_as_column_header = use_field_alias_as_column_header
118+ )
108119 elif c .dataType == 'RelationshipClass' :
109- self ._relationship_class (c ,
110- self ._relationship_class_default_name (c , output_path ),
111- use_field_alias_as_column_header = use_field_alias_as_column_header )
120+ self ._relationship_class (
121+ c ,
122+ self ._relationship_class_default_name (c , output_path ),
123+ use_field_alias_as_column_header = use_field_alias_as_column_header
124+ )
112125
113126 output_workbook .close ()
114127
128+ del input_workspace_desc
129+ arcpy .management .ClearWorkspaceCache ()
130+
115131 #endregion
116132
117133 #region Private overrides
@@ -167,10 +183,12 @@ def _dataset_to_ooxml(self, dataset, workbook, sheet_name, use_field_alias_as_co
167183 # create table layout, if any data was written
168184 if row_no > 0 :
169185 header_attr = "name" if use_field_alias_as_column_header == False else "aliasName"
170- worksheet .add_table (0 , 0 , row_no - 1 ,
171- len (fields ) - 1 , {"columns" : [{
172- "header" : getattr (f , header_attr )
173- } for f in fields ]})
186+ worksheet .add_table (
187+ 0 , 0 , row_no - 1 ,
188+ len (fields ) - 1 , {"columns" : [{
189+ "header" : getattr (f , header_attr )
190+ } for f in fields ]}
191+ )
174192
175193 def _get_default_name (self , desc , output_workbook , ** kwargs ):
176194 # get the default name for OOXML, respecting the 31 character limit and avoiding collisions
0 commit comments