DrSkippy / Gnacs

Gnip normalized social data activities json to csv parser.
DrSkippy.github.io/Gnacs
Other
5 stars 11 forks source link

Twitter field extractors, custom output template module, and a unit testing framework for publisher modules #34

Closed jrmontag closed 10 years ago

jrmontag commented 10 years ago

Twitter extractors

All key-path accessible payload keys from Twitter Activity Streams have been defined in a new module twitter_acs_fields.py. Each value is a accessible via an object that defines the path through the JSON payload to the appropriate value, which is stored in an attribute of the object. The twitter_acs_fields.py module handles the checks for existence of keys and stores a default value if the destination value isn't reached. This means the construction of the output for e.g. gnacs.py -z twitter is much cleaner.

Custom output (Twitter only)

The acscsv/ directory now includes a custom_output.py module that can be used for one-off projects with custom delimited output. To keep the master branch clean, the desired workflow is to pull all upstream changes to master, create a new branch, and mv or cp the custom_output.py module into one that is named appropriately for the task. The CustomCSV class inherits from the core AcsCSV class, so all of the helper methods and machinery are available to the custom class. For customized output fields and order, the developer only has to fill out the get_output_list() method defined in the new copy of the custom_output.py module. In this way, the developer can maintain a branch that includes any of their one-off projects, delete it at any point, or simply cherrypick from master when there are substantial changes there.

Unit testing

New modules have been added to the acscsv/ directory to implement Python's unit testing framework on each of the publisher-specific modules. For now, unittest boilerplate has been added to all modules, except for native-format Stocktwits, which includes ~10 test methods. The remaining modules should be filled out soon by other contributors.