hkingsbury wrote:
Kicking myself I missed that indentation. @scarecrow this should work, you shouldn't need to be writing a .py file and calling it with a systemcaller
For completeness, heres the same code from @nordpil but in the class
import fme
import fmeobjects
import os, shutil
class FeatureProcessor(object):
"""Template Class Interface:
When using this class, make sure its name is set as the value of the 'Class
to Process Features' transformer parameter.
"""
def __init__(self):
"""Base constructor for class members."""
pass
def input(self, feature):
location = f.getAttribute('filepath')
dir = f.getAttribute('directory')
path = os.path.join(location, dir)
shutil.rmtree(path)
self.pyoutput(feature)
def close(self):
"""This method is called once all the FME Features have been processed
from input().
"""
pass
def process_group(self):
"""When 'Group By' attribute(s) are specified, this method is called
once all the FME Features in a current group have been sent to input().
FME Features sent to input() should generally be cached for group-by
processing in this method when knowledge of all Features is required.
The resulting Feature(s) from the group-by processing should be emitted
through self.pyoutput().
FME will continue calling input() a number of times followed
by process_group() for each 'Group By' attribute, so this
implementation should reset any class members for the next group.
"""
pass
def has_support_for(self, support_type):
"""This method returns whether this PythonCaller supports a certain type.
The only supported type is fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM.
:param int support_type: The support type being queried.
:returns: True if the passed in support type is supported.
:rtype: bool
"""
if support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM:
return False
return False
Hi hkingsbury thank you for your reply.
I tried the code you suggested but ger the following error:
Python Exception <NameError>: name 'f' is not defined
Traceback (most recent call last):
File "<string>", line 19, in input
NameError: name 'f' is not defined
Error encountered while calling method `input'
PythonCaller (PythonFactory): PythonFactory failed to process feature
I tried adding the code from nordpil, def delete_folder(f): I assume that this is defining 'f' but this didn't work.