<commit_before>/* global google,gapi */
import { getLanguage } from '../lang';
import { observer as globalObserver } from '../utils/observer';
import { errLogger, loadExternalScript } from '../utils/tools';
import GD_CONFIG from '../../botPage/common/google_drive_config';
import { load } from '../../botPage/view/blockly';
import { TrackJSError } from '../../botPage/view/logger';
import { translate } from '../i18n';

const getPickerLanguage = () => {
    const language = getLanguage();

    if (language === 'zhTw') return 'zh-TW';
    if (language === 'zhCn') return 'zh-CN';

    return language;
};

// [TODO]: Refactor to a function or improve it by TS
class GoogleDriveUtil {
    constructor(
        clientId = GD_CONFIG.CLIENT_ID,
        apiKey = GD_CONFIG.API_KEY,
        appId = GD_CONFIG.APP_ID,
        apiUrl = GD_CONFIG.API_URL,
        authScope = GD_CONFIG.AUTH_SCOPE,
        scope = GD_CONFIG.SCOPE,
        discoveryDocs = GD_CONFIG.DISCOVERY_DOCS,
        botFolder = `Binary Bot - ${translate('Strategies')}`
    ) {
        this.clientId = clientId;
        this.apiKey = apiKey;
        this.appId = appId;
        this.apiUrl = apiUrl;
        this.authScope = authScope;
        this.scope = scope;
        this.discoveryDocs = discoveryDocs;
        this.botFolder = botFolder;
        this.auth = null;
        this.isAuthorized = false;
        this.profile = null;
        // Fetch Google API script and initialize class fields
        loadExternalScript(this.apiUrl)
            .then(this.init)
            .catch(err => errLogger(err, translate('There was an error loading Google API script.')));
    }

    init = () => {
        gapi.load(this.authScope, {
            callback: () => {
                gapi.client
                    .init({
                        apiKey       : this.apiKey,
                        clientId     : this.clientId,
                        scope        : this.scope,
                        discoveryDocs: this.discoveryDocs,
                    })
                    .then(
                        () => {
                            if (this.auth !== null && this.auth !== undefined) {
                            this.auth = gapi.auth2.getAuthInstance();
                                this.auth.isSignedIn.listen(isLoggedIn => this.updateLoginStatus(isLoggedIn));
                                this.updateLoginStatus(this.auth.isSignedIn.get());<commit_msg>circle ci changes<commit_after>/* global google,gapi */
import { getLanguage } from '../lang';
import { observer as globalObserver } from '../utils/observer';
import { errLogger, loadExternalScript } from '../utils/tools';
import GD_CONFIG from '../../botPage/common/google_drive_config';
import { load } from '../../botPage/view/blockly';
import { TrackJSError } from '../../botPage/view/logger';
import { translate } from '../i18n';

const getPickerLanguage = () => {
    const language = getLanguage();

    if (language === 'zhTw') return 'zh-TW';
    if (language === 'zhCn') return 'zh-CN';

    return language;
};

// [TODO]: Refactor to a function or improve it by TS
class GoogleDriveUtil {
    constructor(
        clientId = GD_CONFIG.CLIENT_ID,
        apiKey = GD_CONFIG.API_KEY,
        appId = GD_CONFIG.APP_ID,
        apiUrl = GD_CONFIG.API_URL,
        authScope = GD_CONFIG.AUTH_SCOPE,
        scope = GD_CONFIG.SCOPE,
        discoveryDocs = GD_CONFIG.DISCOVERY_DOCS,
        botFolder = `Binary Bot - ${translate('Strategies')}`
    ) {
        this.clientId = clientId;
        this.apiKey = apiKey;
        this.appId = appId;
        this.apiUrl = apiUrl;
        this.authScope = authScope;
        this.scope = scope;
        this.discoveryDocs = discoveryDocs;
        this.botFolder = botFolder;
        this.auth = null;
        this.isAuthorized = false;
        this.profile = null;
        // Fetch Google API script and initialize class fields
        loadExternalScript(this.apiUrl)
            .then(this.init)
            .catch(err => errLogger(err, translate('There was an error loading Google API script.')));
    }

    init = () => {
        gapi.load(this.authScope, {
            callback: () => {
                gapi.client
                    .init({
                        apiKey       : this.apiKey,
                        clientId     : this.clientId,
                        scope        : this.scope,
                        discoveryDocs: this.discoveryDocs,
                    })
                    .then(
                        () => {
                            if (this.auth !== null && this.auth !== undefined) {
                                this.auth = gapi.auth2.getAuthInstance();
                                this.auth.isSignedIn.listen(isLoggedIn => this.updateLoginStatus(isLoggedIn));
                                this.updateLoginStatus(this.auth.isSignedIn.get());
{'fraction_non_alphanumeric': 0.12085210979106924, 'fraction_numerical': 0.0012290045063498567, 'mean_word_length': 1.7325125909345271, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '807873', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1334, 'n_words': 297}