"""
    groceries export
    module to produce Groceries.app importable output
"""

import json


class GroceriesExporter:
    """ Exporting a YAML groceries list as an import
        for Groceries.app
    """
    def __init__(self, aisles_json_file):
        try:
            aisles_json = json.loads(open(aisles_json_file).read())
        except IOError:
            return -1
        self.aisles_raw = aisles_json["aisles"]
        self.aisles_master = {}
        for aisle in aisles_raw:
            aisles_master[aisle["name"]] = aisle["id"]

    def set_groceries(self, groceries):
        """ set groceries list """
        self.groceries = groceries

    def export_list(self, groceries, filepath):
        """ export groceries to given file """
        return

    def convert_groceries(self, groceries_list):
        """ converts a groceries yaml list into the
            format needed by groceries.app
        """
        ret = {}
        for aisles in groceries_list.keys():
            for items in groceries_list[aisles]:
                try:


        return ret

@@ -849,13 +849,8 @@
 ies 
-yaml 
 list
@@ -897,24 +897,236 @@
 roceries.app
+%0A%0A            Params: groceries_list%0A            Format: %7B'aisle1': %5B'item1', 'item2'%5D,%0A                     'aisle2': %5B'item3', 'item4'%5D%7D%0A%0A            Return:%0A                array of groceries in correct format
 %0A        %22%22%22
@@ -1140,18 +1140,18 @@
   ret = 
-%7B%7D
+%5B%5D
 %0A       
@@ -1208,17 +1208,16 @@
 for item
-s
  in groc
@@ -1257,16 +1257,316 @@
    try:%0A
+                    aisle = self.aisles_master%5Baisles%5D%0A                except KeyError:%0A                    aisle = None%0A                new_item = %7B%7D%0A                if aisle:%0A                    new_item%5B%22aisle%22%5D = aisle%0A                new_item%5B%22name%22%5D = items%0A                ret.append(new_item)
 %0A%0A      

add converter method