-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual.py
90 lines (78 loc) · 2.83 KB
/
manual.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
# Python
"""Copyright (c) Alexander Fedotov.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import json
import jsonlines
import os
from multilogue.utilities.githublog import creupdate_repo, creupdate_file
from grammateus import Grammateus
from dotenv import load_dotenv
load_dotenv()
def clean_up():
return {}
def load_agenda():
pass
def delete_record(file_path):
pass
def main():
human_says = input(f'Do you want to start a new conversation? [y/n/continue/restart/clean/publish] ')
if human_says == 'y':
this_agenda = clean_up()
delete_record(file_path=this_agenda['record_file'])
main(agenda=this_agenda)
elif human_says == 'n':
print("Not going to do anything. Goodbye!")
elif human_says == 'continue':
main(agenda=load_agenda())
elif human_says == 'restart':
main(agenda=load_agenda())
elif human_says == 'publish':
human_says = input('Branch name? ("Enter" for "main") ')
if human_says == '':
branch = 'main'
else:
branch = human_says
# Create the README.md file
this_agenda = load_agenda()
md_file = '' # make_md_file(this_agenda)
# Creupdate the repository
with open('./util/config.json', 'r') as file:
configuration = json.load(file)
organization = configuration['organization']
repository_object = creupdate_repo(repository_name=configuration['repository'],
description='Dialogue with an AI',
private=False)
try:
result = creupdate_file(repository=repository_object,
file_path='./README.md',
file_content=md_file,
branch=branch)
except Exception as e:
print('failed ', e)
try:
result = creupdate_file(repository=repository_object,
file_path='./agenda.json',
file_content=json.dumps(this_agenda),
branch=branch)
except Exception as e:
print('failed ', e)
elif human_says == 'clean':
this_agenda = clean_up()
delete_record(file_path=this_agenda['record_file'])
print("All have been cleaned up.")
exit()
if __name__ == "__main__":
try:
while True:
# This code may be interrupted by ^C on the keyboard.
main()
except KeyboardInterrupt:
# Clean shutdown
print(" Keyboard Interrupt detected. Exiting...")
# stop all the machines
pass # TODO implement STOP MACHINES
# quit
exit(0)