QA_ExportShapefiles_ValidationCode.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:SSURGO-QA 作者: ncss-tech 项目源码 文件源码
def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""

    try:

    # If there were bad areasymbol values, throw an error to the first parameter.  Tried assigning the 3rd paramater
        # the error but it didn't take.
        if str(self.params[3].value).find("The following OID records") > -1:
            self.params[0].setErrorMessage(self.params[3].value)
            #self.params[0].setErrorMessage("AREASYMBOL Error for the following OID record(s)")

        if self.params[0].value and not self.params[3].value:
            env.workspace = self.params[0].value
            fcList = arcpy.ListFeatureClasses("SAPOLYGON", "Polygon")

            if len(fcList) == 0:
                self.params[0].setErrorMessage("SAPOLYGON layer is missing from RTSD Feature Dataset")

            sapolyFC = os.path.join(env.workspace,"SAPOLYGON")
            if len([field for field in arcpy.ListFields(sapolyFC,"AREASYMBOL")]) == 0:
                self.params[0].setErrorMessage("SAPOLYGON layer is missing AREASYMBOL fileld")

            for fld in self.params[2].filter.list:
                if fld.find(' ') > -1:
                    self.params[2].setErrorMessage("Error in AREASYMBOL value(s) in SAPOLYGON layer")

                if not len(fld) == 5:
                    self.params[2].setErrorMessage("AREASYMBOL Value(s) Error! All Areasymbols must be 5 digits")

        return

    except:
      tb = sys.exc_info()[2]
      tbinfo = traceback.format_tb(tb)[0]
      self.params[0].value = tbinfo + " \n" + str(sys.exc_type) + ": " + str(sys.exc_value)
      return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号