config.py 文件源码

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

项目:hoaxy-backend 作者: IUNetSci 项目源码 文件源码
def run(cls, args):
        samples = """
conf.sample.yaml                    Hoaxy configuration file
domains_claim.sample.txt            Claim domains
domains_factchecking.sample.txt     Factchecking domains
site.sample.yaml                    Claim and/or factchecking sites
crontab.sample.txt                  Crontab sample
"""
        if args['--home'] is None:
            hoaxy_home = HOAXY_HOME
            msg = """
Sample files are put into the default location:
  '{}'.
Please edit and rename sample files to make Hoaxy work with them.
{}"""
            msg = msg.format(hoaxy_home, samples)
        else:
            hoaxy_home = os.path.expanduser(args['--home'])
            if not hoaxy_home.endswith('/'):
                hoaxy_home += '/'
            msg = """
Sample files are put into folder
'{}'.
You need to set environment
HOAXY_HOME={}
to activate this path.

Also please edit and rename samples to make Hoaxy work with them.
{}"""
            msg = msg.format(hoaxy_home, hoaxy_home, samples)
        if not os.path.exists(hoaxy_home):
            try:
                org_umask = os.umask(0)
                os.makedirs(hoaxy_home, 0755)
            finally:
                os.umask(org_umask)
        samples = resource_listdir('hoaxy.data', 'samples')
        for sample in samples:
            if not sample.startswith('__init__.'):
                sample = resource_filename('hoaxy.data.samples', sample)
                shutil.copy(sample, hoaxy_home)
                os.chmod(
                    os.path.join(hoaxy_home, os.path.basename(sample)), 0644)
        print(msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号