def get_data(): # path Leankit_input = setting.init() ipath = Leankit_input['input'] cron_path = Leankit_input['cron_data'] # token # chdir(ipath) input_f = path.join(ipath, 'input.json') credentials = import_data(input_f) auth = API.LeanKit_Auth() auth.get_token(**credentials) token = auth.token # data from API # chdir(cron_path) cards_data = API.Cards_info_aio(token, **credentials) board_data = API.Board_id(token, **credentials) filename = 'card_data_{}.json'.format(str(datetime.today())) filename = path.join(cron_path, filename) save_data(cards_data, filename) filename = 'board_data_{}.json'.format(str(datetime.today())) filename = path.join(cron_path, filename) save_data(board_data, filename)
def report(): input_f = path.join(ipath, 'input.json') # Generate data structure from the API Call dic = import_data(input_f) Board, Cards = Leankit_script(dic) print('API Call Done') # Make sure the API Call was successful if hasattr(Cards, 'cards_list'): # Generate Data Structure Users_Cards = cards_per_users(Cards) Projects_Cards = cards_per_projects(Cards) # Generate a project table projects_table = lst_projects(Cards) print(projects_table) table_to_xl(projects_table, path.join(opath, 'Projects_status.xlsx')) print('\n') # Generate Report per team for individual output for team, team_lst in teams_dic.items(): users_table = cvt_pretty(Users_Cards, team_lst, today) print(users_table.get_string(title="Cards & Points")) xlsx_name = '{}.xlsx'.format(team) xlsx_name = path.join(opath, xlsx_name) table_to_xl(users_table, xlsx_name) print('\n') # Generate a table Proj_lst, Proj = projects_contributors(Cards) print(Proj.get_string(title='Projects list')) lst_to_xl(Proj_lst, path.join(opath, 'Projects_stakeholders.xlsx')) print('\n') new_req = table_new_requests(Cards, cut_off) print(new_req.get_string(title='New Requests')) table_to_xl(new_req, path.join(opath, 'new_request.xlsx')) # generate a list of all the card assigned per users cards_users = table_cards_per_users(Users_Cards) tables_to_xl(cards_users, path.join(opath, 'users_activity.xlsx')) # generate a list of cards per projects lsts, Projects_tables = table_cards_per_projects(Projects_Cards) lsts_to_xl(lsts, path.join(opath, 'projects_cards.xlsx')) # delete the temp file opath_lst = listdir(opath) for item in opath_lst: if item.endswith(".csv"): item = path.join(opath, item) remove(item) return Board, Cards
def Dict_Cards_import(file_name, d_format): def f(key, value): a = cvt_d(key, d_format) tmp = Leankit_Cards(value, a) return tmp dump = import_data(file_name) dic = {cvt_d(key, d_format): Leankit_Cards(value) for key, value in dump.items()} return dic
def init(): global Leankit_input dir_c = listdir(getcwd()) Leankit_input = {} if input_n in dir_c: tmp = import_data(input_n) if needed_key <= set(tmp) and check_path(path_keys, tmp): Leankit_input = tmp else: Leankit_input = {} return Leankit_input
def Leankit_script(dic): # Getting the token to access leankit Auth = LeanKit_Auth() Auth.get_token(**dic) if Auth.status == 'Success': # Cards Data Cards_list = Cards_info_aio(Auth.token, **dic) with open('Cards_Data.json', 'w') as out: json.dump(Cards_list, out) Cards_list = import_data('Cards_Data.json') Cards = Leankit_Cards(Cards_list) # Boards Info Board_info = Board_id(Auth.token, **dic) with open('Board_Data.json', 'w') as out: json.dump(Board_info, out) Board_info = import_data('Board_Data.json') Board = Leankit_Board(Board_info) Auth.revoke_tokens(**dic) return Board, Cards
def import_cards(file): # Cards Data Cards_list = import_data(file) Cards = Leankit_Cards(Cards_list) return Cards