Commits

Jason Scheirer  committed 52a7264

GetParameterAsText tweak, GetArgumentCount

  • Participants
  • Parent commits c8aa2ca

Comments (0)

Files changed (1)

 
 import arcpy
 
+# You can ignore/delete this code; these are basic utility functions to
+# streamline porting
+
 @contextlib.contextmanager:
 def fakefile(filename, args=None):
     oldpath = sys.path[:]
     ('AddWarning', 'messages.AddWarningMessage({})'),
     ('AddError', 'messages.AddErrorMessage({})'),
     ('AddIDMessage', 'messages.AddIDMessage({})'),
-    ('GetParameterAsText', 'get_parameter_as_text(parameters[{}])'),
+    ('GetParameterAsText', 'parameters[{}].valueAsText'),
     ('SetParameterAsText', 'set_parameter_as_text(parameters, {})'),
-    ('GetParameter', 'parameters[{}]')
+    ('GetParameter', 'parameters[{}]'),
+    ('GetArgumentCount', 'len(parameters)')
 )
 
 CALL_RE_TEMPLATE = "((?:[_a-z][_a-z0-9]* *[.] *)*{}\(([^)]*)\))"
             yield ""
         yield "        return [{}]".format(", ".join("param_{}".format(idx + 1) for idx in xrange(len(self._parameters))))
         yield "    def isLicensed(self):"
-        yield "        pass"
+        yield "        return True"
         yield "    def updateParameters(self, parameters):"
         yield "        pass"
         yield "    def updateMessages(self, parameters):"
 
 if __name__ == "__main__":
     import glob
-    for filename in glob.glob(r"c:\SupportFiles\ArcGIS\ArcToolbox\Toolboxes\Spatial*.tbx"):
+    for filename in [r'Toolboxes\My Toolboxes\OutScript.tbx']:
         print HEADER_SOURCE
         print PYTToolbox(filename).python_code.encode("ascii", "replace")