def upload(client, source_dir):
    """Upload inappproducts to play store."""
    print('')
    print('upload inappproducs')
    print('---------------------')

    products_folder = os.path.join(source_dir, 'products')
    product_files = filter(os.path.isfile, list_dir_abspath(products_folder))

    current_product_skus = map(lambda product: product['sku'], client.list_inappproducts())
    print(current_product_skus)
    for product_file in product_files:
        with open(product_file) as product_file:
            product = json.load(product_file)
        #check if the product is new
        sku = product['sku']
        product['packageName'] = client.package_name
        print(sku)
        if sku in current_product_skus:
            print("update product {0}".format(sku))
            client.update_inappproduct(product, sku)
        else:
            print("create product {0}".format(sku))
            client.insert_inappproduct(product)
Upload inappproducts to play store.