Thoughts, ideas and solutions from a few EPM consultants.

PEP 8 and Logging

Over the weekend I spent a little more time on the FDMEE framework, while implementing some new logging functionality I felt compelled to look into the Python Style Guide (PEP 8) and realized while my new logging code seemed to be in line with guide, our property names were not. With a big part of the reason writing this being to adhere to best practices, I felt we had to make a change. Functionality wise nothing is different but we removed the camel casing of properties and replaced it with underscores and all lowercase letters. Below is a table of all the properties that changed and what they are now.

PreviousNew
Emailemail
ApplicationIDapplication_id
BatchScriptDirectorybatch_script_directory
Categorycategory
CategoryKeycategory_key
CheckStatuscheck_status
EpmHomeepm_home
EpmInstanceHomeepm_instance_home
ExportFlagexport_flag
ExportModeexport_mode
ExportStatusexport_status
FileDirectoryfile_directory
FileNamefile_name
ImportFlagimport_flag
ImportFormatimport_format
ImportStatusimport_status
InboxDirectoryinbox_directory
LoadIDload_id
LocationKeylocation_key
Locationlocation
MultiPeriodLoadmulti_period_load
OutboxDirectoryoutbox_directory
Periodperiod
PeriodKeyperiod_key
ProcessStatusprocess_status
Rulerule
RuleIDrule_id
ScriptDirectoryscript_directory
SourceNamesource_name
SourceTypesource_type
TargetApptarget_app
TargetAppDBtarget_app_db
TargetAppIDtarget_app_id
ValidationStatusvalidation_status


Ok with that out of the way let's talk about the new stuff. Francisco recently released his snippet for logging the fdmContext, I had never considered writing a whole jython dictionary to the log. So we expanded on this idea a little bit and built a generic object parser that also happens to work for the fdmContext. Now the context can be written to the log by calling jf.log.context() and any other dictionary variable can be logged by calling fdmAPI.logDebug(jf.log.object(dictionary)). Last there are additional formatting options that can be passed to the object method if you have a particular display requirements; the default format separates the key from the value with a colon (:) and tab and each pair is on a line by itself.

Well that's probably it for this week, Happy Thanksgiving.