Example #1
0
    def initContent(data):
        conf.set_default_domain_by_inter(data['interpreter'])
        domain_data = conf.default_domain_data
        # if not domain_data.get('key'):
        #     raise CheckiOClientConfigError('Domain is not configure. Please do $ checkio config')
        if not domain_data.get('solutions'):
            raise CheckiOClientConfigError('Solutions are not synchronized yet. Please do $ checkio sync -h')

        paths = solutions_paths(domain_data['solutions'], domain_data['extension'])
        if data['slug'] in paths:

            filename = paths[data['slug']]

            with open(filename, 'r', encoding='utf-8') as fh:
                content = code_for_sync(fh.read())

            return {
                'do': 'initContent',
                'filename': filename,
                'content': content,
                'slug': data['slug']
            }
        else:
            filename = gen_filename(data['slug'], data['station'])
            init_code_file(filename, 
                gen_env_line(data['slug']) + '\n' + data['content'])

            return {
                'do': 'initContent',
                'filename': filename,
                'slug': data['slug'],
                'isNew': True
            }
Example #2
0
    def syncLocalContent(data):
        conf.set_default_domain_by_inter(data['interpreter'])
        domain_data = conf.default_domain_data

        with open(data['filename'], 'r', encoding='utf-8') as fh:
            content = code_for_sync(fh.read())

        return {'do': 'syncLocalContent', 'content': content}