<commit_before>#!/usr/bin/env python

import sys
import string
import json
import urllib2
from urllib import urlencode

BASE_URL = 'https://prod-rel-ffc-ccm.oobesaas.adobe.com/adobe-ffc-external/core/v4/products/all'

def add_product(products, product):
    if product['id'] not in products:
        products[product['id']] = []

    products[product['id']].append(product)


def feed_url(channels, platforms):
    """Build the GET query parameters for the product feed."""
    params = [
        ('payload', 'true'),
        ('productType', 'Desktop'),
        ('_type', 'json')
    ]
    for ch in channels:
        params.append(('channel', ch))

    for pl in platforms:
        params.append(('platform', pl))

    return BASE_URL + '?' + urlencode(params)

def fetch(channels, platforms):
    """Fetch the feed contents."""
    url = feed_url(channels, platforms)
    print('Fetching from feed URL: {}'.format(url))

    req = urllib2.Request(url, headers={
        'User-Agent': 'Creative Cloud',
        'x-adobe-app-id': 'AUSST_4_0',
    })
    data = json.loads(urllib2.urlopen(req).read())

    return data

if __name__ == "__main__":
    data = fetch(['ccm'], ['osx10', 'osx10-64'])

    products = {}
    for channel in data['channel']:
        for product in channel['products']['product']:
            add_product(products, product)

    # print("Name:\t{}Code:\t{}\tBaseVersion:\t{}".format(product['displayName'], product['id'], product['platforms']['platform'][0]['languageSet'][0].get('baseVersion')))


    for sapcode, productVersions in products.iteritems():
        print("Code: {}".format(sapcode))

        for product in productVersions:
            print("\t{}BaseVersion:\t{}".format(product['displayName'], product['platforms']['platform'][0]['languageSet'][0].get('baseVersion')))<commit_msg>Show version in listfeed. Still unicode errors.<commit_after>#!/usr/bin/env python

import sys
import string
import json
import urllib2
from urllib import urlencode

BASE_URL = 'https://prod-rel-ffc-ccm.oobesaas.adobe.com/adobe-ffc-external/core/v4/products/all'

def add_product(products, product):
    if product['id'] not in products:
        products[product['id']] = []

    products[product['id']].append(product)


def feed_url(channels, platforms):
    """Build the GET query parameters for the product feed."""
    params = [
        ('payload', 'true'),
        ('productType', 'Desktop'),
        ('_type', 'json')
    ]
    for ch in channels:
        params.append(('channel', ch))

    for pl in platforms:
        params.append(('platform', pl))

    return BASE_URL + '?' + urlencode(params)

def fetch(channels, platforms):
    """Fetch the feed contents."""
    url = feed_url(channels, platforms)
    print('Fetching from feed URL: {}'.format(url))

    req = urllib2.Request(url, headers={
        'User-Agent': 'Creative Cloud',
        'x-adobe-app-id': 'AUSST_4_0',
    })
    data = json.loads(urllib2.urlopen(req).read())

    return data

if __name__ == "__main__":
    data = fetch(['ccm'], ['osx10', 'osx10-64'])

    products = {}
    for channel in data['channel']:
        for product in channel['products']['product']:
            add_product(products, product)

    # print("Name:\t{}Code:\t{}\tBaseVersion:\t{}".format(product['displayName'], product['id'], product['platforms']['platform'][0]['languageSet'][0].get('baseVersion')))


    for sapcode, productVersions in products.iteritems():
        print("Code: {}".format(sapcode))

        for product in productVersions:
            name = product['displayName'].decode('utf8')
            print("\t{}\t\tBaseVersion:\t{}\tVersion:\t{}".format(
                name,
                product['platforms']['platform'][0]['languageSet'][0].get('baseVersion'),
                product['version']
            ))
{'fraction_non_alphanumeric': 0.1750065496463191, 'fraction_numerical': 0.008645533141210375, 'mean_word_length': 3.358447488584475, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767551', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1171, 'n_words': 251}