Skip to content

Commit

Permalink
Modify configuration file parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Gonzalez committed Sep 17, 2019
1 parent caaf75f commit dba16ee
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions demeter/demeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pyfiglet import Figlet
from git import Repo, Git
from github import Github
import configparser
import os.path
import logging
import github
Expand Down Expand Up @@ -175,8 +176,9 @@ def cherrypick(pull_requests, release_name):


if __name__ == "__main__":
if not os.path.isfile("../config.py"):
config = open("../config.py", "w")
config = configparser.ConfigParser()

if not os.path.isfile("config.ini"):
print(colored("Please enter your personal GitHub access token:\t", "yellow"))
GITHUB_TOKEN = input()
print(colored("Please enter the repository as it appears on Github(e.g. {User}/{Repository}:\t", "yellow"))
Expand All @@ -185,15 +187,19 @@ def cherrypick(pull_requests, release_name):
"\t", "yellow"))
REPO_PATH = input()

config.write('GITHUB_TOKEN = "' + GITHUB_TOKEN + '"\n')
config.write('GITHUB_REPO = "' + GITHUB_REPO + '"\n')
config.write('REPO_PATH = r"' + REPO_PATH + '"\n')
config.close()
config['CREDENTIALS'] = {
'GITHUB_TOKEN': GITHUB_TOKEN,
'GITHUB_REPO': GITHUB_REPO,
'REPO_PATH': REPO_PATH
}

with open('config.ini', 'w') as settings:
config.write(settings)

import config
git = Git(config.REPO_PATH)
repo = Repo(config.REPO_PATH)
g = Github(config.GITHUB_TOKEN)
r = g.get_repo(config.GITHUB_REPO)
config.read('config.ini')
git = Git(config.get('CREDENTIALS', 'repo_path'))
repo = Repo(config.get('CREDENTIALS', 'repo_path'))
g = Github(config.get('CREDENTIALS', 'github_token'))
r = g.get_repo(config.get('CREDENTIALS', 'github_repo'))

demeter_cli()

0 comments on commit dba16ee

Please sign in to comment.