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.
Previous | New |
---|---|
ApplicationID | application_id |
BatchScriptDirectory | batch_script_directory |
Category | category |
CategoryKey | category_key |
CheckStatus | check_status |
EpmHome | epm_home |
EpmInstanceHome | epm_instance_home |
ExportFlag | export_flag |
ExportMode | export_mode |
ExportStatus | export_status |
FileDirectory | file_directory |
FileName | file_name |
ImportFlag | import_flag |
ImportFormat | import_format |
ImportStatus | import_status |
InboxDirectory | inbox_directory |
LoadID | load_id |
LocationKey | location_key |
Location | location |
MultiPeriodLoad | multi_period_load |
OutboxDirectory | outbox_directory |
Period | period |
PeriodKey | period_key |
ProcessStatus | process_status |
Rule | rule |
RuleID | rule_id |
ScriptDirectory | script_directory |
SourceName | source_name |
SourceType | source_type |
TargetApp | target_app |
TargetAppDB | target_app_db |
TargetAppID | target_app_id |
ValidationStatus | validation_status |
Ok with that out of the way let's talk about the new stuff. [Francisco](http://fishingwithfdmee.blogspot.com/) recently released his [snippet](http://fishingwithfdmee.blogspot.com/p/fdmee-script.html) 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.