<commit_before>import re
import os
import time

from webstore_manager.chrome_store import chrome_store
from webstore_manager import logging_helper, util

logger = logging_helper.get_logger(__file__)


class ChromeFunctions:
    @staticmethod
    def read_store(parser):
        try:
            return parser.variables['chrome_store']
        except KeyError:
            raise InvalidStateException('You must run chrome.new function before uploading an extension.')

    @staticmethod
    def init(parser, client_id, client_secret, refresh_token):
        parser.variables['client_id'] = client_id
        parser.variables['client_secret'] = client_secret
        parser.variables['refresh_token'] = refresh_token
        parser.variables['chrome_store'] = chrome_store.ChromeStore(client_id,
                                                                    client_secret,
                                                                    refresh_token)

    @staticmethod
    def set_app(parser, app_id):
        store = ChromeFunctions.read_store(parser)
        parser.variables['app_id'] = app_id
        store.app_id = app_id

    @staticmethod
    def new(parser, filename):
        store = ChromeFunctions.read_store(parser)
        store.upload(filename, True)

    @staticmethod
    def update(parser, filename):
        store = ChromeFunctions.read_store(parser)
        store.upload(filename, False)

    @staticmethod
    def publish(parser, target):
        store = ChromeFunctions.read_store(parser)
        if target == 'public':
            store.publish(chrome_store.ChromeStore.TARGET_PUBLIC)
        elif target == 'trusted':
            store.publish(chrome_store.ChromeStore.TARGET_TRUSTED)
        else:
            raise ValueError('Unknown value {}. Expected one of public, trusted.'.format(target))
<commit_msg>Reinitialize update_item_url in Chrome Store when using script mode.<commit_after>import re
import os
import time

from webstore_manager.chrome_store import chrome_store
from webstore_manager import logging_helper, util

logger = logging_helper.get_logger(__file__)


class ChromeFunctions:
    @staticmethod
    def read_store(parser):
        try:
            return parser.variables['chrome_store']
        except KeyError:
            raise InvalidStateException('You must run chrome.new function before uploading an extension.')

    @staticmethod
    def init(parser, client_id, client_secret, refresh_token):
        parser.variables['client_id'] = client_id
        parser.variables['client_secret'] = client_secret
        parser.variables['refresh_token'] = refresh_token
        parser.variables['chrome_store'] = chrome_store.ChromeStore(client_id,
                                                                    client_secret,
                                                                    refresh_token)

    @staticmethod
    def set_app(parser, app_id):
        store = ChromeFunctions.read_store(parser)
        parser.variables['app_id'] = app_id
        store.app_id = app_id
        store.update_item_url = "https://www.googleapis.com/upload/chromewebstore/v1.1/items/{}".format(app_id)

    @staticmethod
    def new(parser, filename):
        store = ChromeFunctions.read_store(parser)
        store.upload(filename, True)

    @staticmethod
    def update(parser, filename):
        store = ChromeFunctions.read_store(parser)
        store.upload(filename, False)

    @staticmethod
    def publish(parser, target):
        store = ChromeFunctions.read_store(parser)
        if target == 'public':
            store.publish(chrome_store.ChromeStore.TARGET_PUBLIC)
        elif target == 'trusted':
            store.publish(chrome_store.ChromeStore.TARGET_TRUSTED)
        else:
            raise ValueError('Unknown value {}. Expected one of public, trusted.'.format(target))

{'fraction_non_alphanumeric': 0.08231628148532849, 'fraction_numerical': 0.0005193456245131135, 'mean_word_length': 2.511394712853236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3819734', 'n_tokens_mistral': 991, 'n_tokens_neox': 969, 'n_words': 214}