提交 98bbd6d5 编写于 作者: G gaoruoshu

update

上级 87cb99af
import os
"""
This is main class for the tool
"""
import logging
import requests
import argparse
from gitee import Gitee
import gitee
def main():
......@@ -12,13 +16,18 @@ def main():
return
commands()
def commands():
gitee = Gitee("gitee.conf")
"""list all commands in tool"""
my_gitee = gitee.Gitee("gitee.conf")
parser = argparse.ArgumentParser(description="test argparse")
parser.add_argument("-O", "--organization", type=str, help="get info about an organization")
args = parser.parse_args()
if args.organization:
gitee.get_orgs_info(args.organization)
my_gitee.get_orgs_info(args.organization)
if __name__ == '__main__':
main()
main()
\ No newline at end of file
......@@ -4,13 +4,14 @@ from configparser import ConfigParser
def get_header(config):
"""url header"""
header = {}
for (each_key, each_val) in config.items("headers"):
header[each_key] = each_val
return header
class Gitee:
class Gitee(object):
"""gitee"""
def __init__(self, config_path):
config = ConfigParser()
......@@ -18,11 +19,8 @@ class Gitee:
self.headers = get_header(config)
self.baseurl = config.get("url", "baseurl")
def to_string(self):
print(self.headers)
print(self.baseurl)
def get_orgs_info(self, org_name):
"""get organization info"""
orgs_url = self.baseurl + "/orgs/" + org_name
response = requests.get(orgs_url)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册