setup.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:lemongraph 作者: NationalSecurityAgency 项目源码 文件源码
def fetch_js():
    libs = {
        'd3.v3.min.js': 'https://d3js.org/d3.v3.min.js',
        'd3.v4.min.js': 'https://d3js.org/d3.v4.min.js',
        'svg-crowbar.js': 'https://nytimes.github.io/svg-crowbar/svg-crowbar.js',
    }
    for js, url in libs.iteritems():
        target = os.path.sep.join(('LemonGraph', 'data', js))
        source = os.path.sep.join(('deps', 'js', js))
        dotsource = os.path.sep.join(('deps', 'js', '.%s' % js))
        try:
            os.mkdir(os.path.sep.join(('deps', 'js')))
        except OSError:
            pass

        try:
            s1 = os.stat(source)
        except OSError:
            with open(dotsource, 'wb') as fh:
                for chunk in do_curl(url):
                    fh.write(chunk)
                s1 = os.fstat(fh.fileno())
                fh.close()
                os.link(dotsource, source)
                os.unlink(dotsource)

        try:
            s2 = os.stat(target)
        except OSError:
            print >> sys.stderr, "Hard linking: %s -> %s" % (source, target)
            os.link(source, target)
            continue

        for i in (stat.ST_INO, stat.ST_DEV):
            if s1[i] != s2[i]:
                os.unlink(target)
                print >> sys.stderr, "Hard linking: %s -> %s" % (source, target)
                os.link(source, target)
                break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号