-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcreate-commit-python-pip.py
49 lines (41 loc) · 1.62 KB
/
create-commit-python-pip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""
Module Docstring
"""
__author__ = "David Morris ([email protected])"
__version__ = "0.1.0"
__license__ = "MIT"
import os
import json
import string
import base64
import argparse
import logging
import thepower
from pathlib import Path
from datetime import datetime
def main(args):
power_config = thepower.read_dotcom_config(args.power_config)
args.extension = power_config.get('dummy_section','file_extension').strip('"')
args.default_committer = power_config.get('dummy_section','default_committer',).strip('"')
p = Path('test-data/python/pip/requirements.txt_')
json_file = f"""tmp/requirements.json"""
filename_in_repo = f"""requirements.txt"""
with open(p, 'rb') as ct:
t = {}
chapter_content = ct.read()
chapter_base64 = base64.encodebytes(chapter_content)
t["message"] = f"""A python requirements.txt file."""
t["committer"] = {}
t["committer"]["name"] = args.default_committer
t["committer"]["email"] = f"noreply+{args.default_committer}@example.com"
t["content"] = chapter_base64.decode('UTF-8')
with open(json_file, 'w') as out_file:
out_file.write(json.dumps(t))
if __name__ == "__main__":
""" This is executed when run from the command line """
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--power-config", action="store", dest="power_config", default=".gh-api-examples.conf", help="This is the config file to use to access variables for the power.")
parser.add_argument("-e", "--extension", action="store", dest="extension", default="c")
args = parser.parse_args()
main(args)