packaging: Automatically generate zulip_bots MANIFEST.in.

Fixes #69.
This commit is contained in:
derAnfaenger 2017-08-16 18:45:00 +02:00 committed by Tim Abbott
parent e1d1c490c8
commit e4c34d77e7
4 changed files with 94 additions and 95 deletions

View file

@ -1,63 +0,0 @@
#!/usr/bin/env python
import os
import glob
def get_zulip_bots_test_fixtures():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/fixtures/*.json')
fixtures_paths = map(
lambda fp: os.path.join(*fp.split('/')[-5:]),
glob.glob(glob_pattern)
)
return fixtures_paths
def get_zulip_bots_logos():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/logo.*')
logo_paths = map(
lambda fp: os.path.join(*fp.split('/')[-4:]),
glob.glob(glob_pattern)
)
return logo_paths
def get_zulip_bots_docs():
# type: () -> List[str]
current_dir = os.path.abspath(os.path.dirname(__file__))
bots_dir = os.path.join(current_dir, '..', 'zulip_bots/zulip_bots/bots')
glob_pattern = os.path.join(bots_dir, '*/doc.md')
doc_paths = map(
lambda fp: os.path.join(*fp.split('/')[-4:]),
glob.glob(glob_pattern)
)
return doc_paths
def main():
# type: () -> None
current_dir = os.path.abspath(os.path.dirname(__file__))
manifest_path = os.path.join(current_dir, '..', 'zulip_bots/MANIFEST.in')
with open(manifest_path, 'w') as fp:
template = 'include {line}\n'
fixtures = map(lambda line: template.format(line=line),
get_zulip_bots_test_fixtures())
logos = map(lambda line: template.format(line=line),
get_zulip_bots_logos())
docs = map(lambda line: template.format(line=line),
get_zulip_bots_docs())
fp.writelines(fixtures)
fp.write('\n')
fp.writelines(logos)
fp.write('\n')
fp.writelines(docs)
fp.write('\n')
if __name__ == '__main__':
main()