zulip_bots: Add script to generate zulip_bots/MANIFEST.in.
As a package maintainer, I have to exclude the test fixtures in MANIFEST.in so that they aren't shipped with the package release. But for the repo, we need to include fixtures, logos and docs so that Travis can run the tests after running `pip install ./zulip_bots`. Also, since we are installing zulip_bots off of this repo in our main repo, docs and logos should be included so that they can be rendered alongside our webhooks/integrations documentation, so we need to include them in MANIFEST.in as well. To automate this process, I just wrote this handy little script that future bot contributors can run instead of having to manually specify what to include in MANIFEST.in in the repo.
This commit is contained in:
parent
be87c04a8e
commit
a28fcbbaa9
63
tools/generate_zulip_bots_manifest.py
Executable file
63
tools/generate_zulip_bots_manifest.py
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/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()
|
|
@ -1,30 +1,47 @@
|
|||
include zulip_bots/bots/giphy/fixtures/test_1.json
|
||||
|
||||
include zulip_bots/bots/github_detail/fixtures/test_404.json
|
||||
include zulip_bots/bots/github_detail/fixtures/test_issue.json
|
||||
include zulip_bots/bots/github_detail/fixtures/test_pull.json
|
||||
|
||||
include zulip_bots/bots/define/fixtures/test_single_type_word.json
|
||||
include zulip_bots/bots/define/fixtures/test_multi_type_word.json
|
||||
include zulip_bots/bots/define/fixtures/test_incorrect_word.json
|
||||
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_single_word.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_multi_word.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_incorrect_query.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_number_query.json
|
||||
|
||||
include zulip_bots/bots/xkcd/fixtures/test_latest.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_random.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_specific_id.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id_2.json
|
||||
|
||||
include zulip_bots/bots/weather/fixtures/test_city_not_found.json
|
||||
include zulip_bots/bots/weather/fixtures/test_only_city.json
|
||||
include zulip_bots/bots/weather/fixtures/test_only_country.json
|
||||
include zulip_bots/bots/weather/fixtures/test_city_with_country.json
|
||||
include zulip_bots/bots/weather/fixtures/test_city_not_found.json
|
||||
|
||||
include zulip_bots/bots/yoda/fixtures/test_1.json
|
||||
include zulip_bots/bots/yoda/fixtures/test_2.json
|
||||
include zulip_bots/bots/github_detail/fixtures/test_issue.json
|
||||
include zulip_bots/bots/github_detail/fixtures/test_pull.json
|
||||
include zulip_bots/bots/github_detail/fixtures/test_404.json
|
||||
include zulip_bots/bots/yoda/fixtures/test_invalid_input.json
|
||||
include zulip_bots/bots/yoda/fixtures/test_only_numbers.json
|
||||
include zulip_bots/bots/yoda/fixtures/test_2.json
|
||||
include zulip_bots/bots/yoda/fixtures/test_1.json
|
||||
include zulip_bots/bots/define/fixtures/test_multi_type_word.json
|
||||
include zulip_bots/bots/define/fixtures/test_single_type_word.json
|
||||
include zulip_bots/bots/define/fixtures/test_incorrect_word.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_multi_word.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_incorrect_query.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_single_word.json
|
||||
include zulip_bots/bots/wikipedia/fixtures/test_number_query.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_specific_id.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_random.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_latest.json
|
||||
include zulip_bots/bots/xkcd/fixtures/test_not_existing_id_2.json
|
||||
|
||||
include zulip_bots/bots/github_detail/logo.svg
|
||||
include zulip_bots/bots/googlesearch/logo.png
|
||||
|
||||
include zulip_bots/bots/converter/doc.md
|
||||
include zulip_bots/bots/incrementor/doc.md
|
||||
include zulip_bots/bots/weather/doc.md
|
||||
include zulip_bots/bots/github_detail/doc.md
|
||||
include zulip_bots/bots/yoda/doc.md
|
||||
include zulip_bots/bots/git_hub_comment/doc.md
|
||||
include zulip_bots/bots/virtual_fs/doc.md
|
||||
include zulip_bots/bots/howdoi/doc.md
|
||||
include zulip_bots/bots/youtube/doc.md
|
||||
include zulip_bots/bots/john/doc.md
|
||||
include zulip_bots/bots/foursquare/doc.md
|
||||
include zulip_bots/bots/commute/doc.md
|
||||
include zulip_bots/bots/encrypt/doc.md
|
||||
include zulip_bots/bots/define/doc.md
|
||||
include zulip_bots/bots/helloworld/doc.md
|
||||
include zulip_bots/bots/tictactoe/doc.md
|
||||
include zulip_bots/bots/googlesearch/doc.md
|
||||
include zulip_bots/bots/xkcd/doc.md
|
||||
|
||||
|
|
Loading…
Reference in a new issue