mozilla / active-data-recipes

A repository of various activedata queries and recipes
Mozilla Public License 2.0
8 stars 24 forks source link

Issue40 #83

Open MadinaB opened 5 years ago

MadinaB commented 5 years ago

The idea is to force each recipe to rely only on logic to post proceed the data.

Currently, these recipes were updated to fit the needs:

and these queries:

The basic idea is that a good help message has all necessary information in it to make a parser. (docopt)

Recipe holds information about all the processing requiring things. In order to allow to treat one list of input differently with recipe argument_parser logic and query argument_parser logic modified_docopt was created. It simply overrides main docopt in last 3 lines: from:

if matched and left == []:  # better error message if left?
return Dict((a.name, a.value) for a in (pattern.flat() + collected))
raise DocoptExit()

to

if matched:
return Dict((a.name, a.value) for a in (pattern.flat() + collected))
DocoptExit()

This is done because if there are some arguments which can not be parsed (left != []) docopt exits. This update forces docopt to return everything that was matched since one argument list will be used to get data for both recipe and the query.


As well, update provides support for not updated queries and recipes: If no "argument_parser" field is loaded from query on load_query step, program treats recipe as not updated one.


I just had this idea in my mind and wanted to share it :)

I will be very glad for any discussions and critics

Thanks for always being helpful :)

MadinaB commented 5 years ago
screen shot 2018-11-11 at 9 08 59 pm screen shot 2018-11-11 at 9 09 09 pm screen shot 2018-11-11 at 9 09 14 pm