AnsweredAssumed Answered

Conditional Statement UnregisterAsVersioned

Question asked by LarryAdgate on Jul 2, 2018
Latest reply on Jul 3, 2018 by jborgion

I need assistance writing a conditional statement that says if the dataset is already Unregistered to skip the balance and go directly to comp = arcpy.Compress_management(editDB)  

Thank You in advance........Larry Adgate

 

import arcpy
editDB = "Database Connections\\Arden@gsw_sde.sde"
workspace = editDB

arcpy.env.workspace = workspace

#Need a conditonal Statment: if dataset is already UnregisterAsVersioned to go directly to comp
datasets = arcpy.ListDatasets("*", "Feature")
print datasets
for dataset in datasets:
fcList = arcpy.ListFeatureClasses("*","",dataset)
for fc in fcList:
print fc
arcpy.UnregisterAsVersioned_management(fc,"NO_KEEP_EDIT","COMPRESS_DEFAULT")

#if already Unregistered, skip the balance and go to below:   

comp = arcpy.Compress_management(editDB)

datasets = arcpy.ListDatasets("*", "Feature")
for dataset in datasets:
fcList = arcpy.ListFeatureClasses("*","",dataset)
for fc in fcList:
arcpy.RegisterAsVersioned_management(fc, "NO_EDITS_TO_BASE")

Outcomes