Skip to main content
Question

hardcode to not use FME MF DIR ?

  • January 25, 2024
  • 1 reply
  • 74 views

katt
Supporter
Forum|alt.badge.img+12
  • Supporter

My fmw is saved in a directory called C:\\DATA\\VariousTasks. A parameter called InputFolder is pointing to a subfolder of this directory. Is it possible not to use FME MF DIR predefined parameter ? I use a text parameter to point to C:\\DATA\\VariousTasks\\DEV but the script is replacing it automatically by "$(FME_MF_DIR_USERTYPED)DEV" when executing which translates to C:\\DATA\\VariousTasks/DEV . I am using a python script later and python is every sensitive to / and \\ . How can I force FME to use C:\\DATA\\VariousTasks\\DEV instead of $(FME_MF_DIR_USERTYPED)DEV (translating to C:\\DATA\\VariousTasks/DEV) ?

1 reply

david_r
Celebrity
  • January 25, 2024

The easiest is probably to simply let Python fix the path for you before using it, e.g.

from pathlib import WindowsPath
import fme
 
raw_path = FME_MacroValues['MY_PUBLISHED_PARAMETER_PATH']
input_path = fme.getAbsolutePath(raw_path)
win_path = str(WindowsPath(input_path).resolve())
with open(win_path) as f:
    # Do something here

See also https://docs.python.org/3/library/pathlib.html and https://docs.safe.com/fme/html/FME-Form-Documentation/FME-Form/Configuration/FME_BEGIN_PYTHON.htm


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings