I have a workspace that reads other workspaces, to do an inventory. I have looked for the Startup Python Script but I can't find it, does the FeatureReader not read that information?
You can read the .fmw as text. Look for FME_BEGIN_PYTHON / FME_END_PYTHON. You will need to decode the string.
@nielsgerrits is right, unfortunately the FMW reader does not return the startup or shutdown script. You have to read the .fmw file as a text file and look for lines starting with either FME_BEGIN_PYTHON or FME_END_PYTHON.
For decoding, you should use the following from the fmeobjects module:
decoded_str = fmeobjects.FMESession().decodeFromFMEParsableText(encoded_str)
While you're at it, you might also be interested in looking for a line that contains "PYTHON_COMPATIBILITY=" to complete your inventory.
@nielsgerrits is right, unfortunately the FMW reader does not return the startup or shutdown script. You have to read the .fmw file as a text file and look for lines starting with either FME_BEGIN_PYTHON or FME_END_PYTHON.
For decoding, you should use the following from the fmeobjects module:
decoded_str = fmeobjects.FMESession().decodeFromFMEParsableText(encoded_str)
While you're at it, you might also be interested in looking for a line that contains "PYTHON_COMPATIBILITY=" to complete your inventory.
Nooooooo David I almost had it solved myself
I was already puzzled why I had to first HTML decode and then FME decode it. Thanks for pointing this out. (But why is it also in the "#! BEGIN_PYTHON" row?)
This works:
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def input(self, feature: fmeobjects.FMEFeature):
parsed_string = fmeobjects.FMESession().decodeFromFMEParsableText(feature.getAttribute('text_line_data'))
feature.setAttribute('text_line_data', parsed_string)
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
Nooooooo David I almost had it solved myself
I was already puzzled why I had to first HTML decode and then FME decode it. Thanks for pointing this out. (But why is it also in the "#! BEGIN_PYTHON" row?)
This works:
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def input(self, feature: fmeobjects.FMEFeature):
parsed_string = fmeobjects.FMESession().decodeFromFMEParsableText(feature.getAttribute('text_line_data'))
feature.setAttribute('text_line_data', parsed_string)
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
Lol. Apparently you should've been at my FME UC 2023 presentation in Bonn, where I talked about this :-)
Nooooooo David I almost had it solved myself
I was already puzzled why I had to first HTML decode and then FME decode it. Thanks for pointing this out. (But why is it also in the "#! BEGIN_PYTHON" row?)
This works:
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def input(self, feature: fmeobjects.FMEFeature):
parsed_string = fmeobjects.FMESession().decodeFromFMEParsableText(feature.getAttribute('text_line_data'))
feature.setAttribute('text_line_data', parsed_string)
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
I was :) this was the reason I knew I needed to look for the fmeobject module .
Nooooooo David I almost had it solved myself
I was already puzzled why I had to first HTML decode and then FME decode it. Thanks for pointing this out. (But why is it also in the "#! BEGIN_PYTHON" row?)
This works:
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def input(self, feature: fmeobjects.FMEFeature):
parsed_string = fmeobjects.FMESession().decodeFromFMEParsableText(feature.getAttribute('text_line_data'))
feature.setAttribute('text_line_data', parsed_string)
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
Thank you so much for the very fast response!! :)