

def getComic(self, id=None):
    'Background loop.'
    result = xJson(id)
    if (result is not None):
        self.title = result['title']
        self.img = result['img']
        self.alt = result['alt']
        self.num = result['num']
        try:
            local_img = ((((sublime.cache_path() + os.path.sep) + 'Xkcd') + os.path.sep) + self.img.split('/')[(- 1)])
            urllib.request.urlretrieve(self.img, local_img)
        except urllib.error.HTTPError as e:
            sublime.error_message(('Xkcd: %s: HTTP error %s retrieving image' % (__name__, str(e.code))))
        except urllib.error.URLError as e:
            sublime.error_message(('Xkcd: %s: URL error %s retrieving image' % (__name__, str(e.reason))))
        self.output = ((((('[' + str(self.num)) + '] ') + self.title) + '\n\n') + self.alt)
        panel = self.window.create_output_panel('xkcd_meta')
        panel.run_command('erase_view')
        self.window.run_command('show_panel', {
            'panel': 'output.xkcd_meta',
        })
        self.window.get_output_panel('xkcd_meta').run_command('append', {
            'characters': self.output,
        })
        panel.settings().set('word_wrap', True)
        self.window.open_file(local_img, sublime.TRANSIENT)
        global xkcd_open
        xkcd_open.append(self.num)
    else:
        sublime.error_message('Xkcd: Error reading API response')

dataset/ETHPy150Open eivind88/xkcd/xkcd.py XkcdGetComicCommand.getComic/original