| | import requests |
| | import json |
| | import pandas as pd |
| | import API |
| | import numpy as np |
| | mcDictionaryurl='https://docs.google.com/spreadsheets/d/1I4P7wiCXTAwnld0YQfUJC8bPtuiETna1HGWVuHbuDBk/edit#gid=1080620551' |
| | def createDictionary(): |
| | DictionaryOfTemplates={ |
| | '1.0 substructure': [], |
| | '2.1 frames' : [], |
| | '2.2 upper floor':[], |
| | '2.3 roof':[], |
| | '2.4 stairs':[], |
| | '2.5 external walls':[], |
| | '2.6 external openings':[], |
| | '2.7 internal walls':[], |
| | '2.8 internal openings':[], |
| | '3.1 wall finishes':[], |
| | '3.2 floor finishes':[], |
| | '3.3 ceiling finishes':[], |
| | '4.0 fittings, furnishings and equipments':[], |
| | '5.0 services':[], |
| | '5.1 sanitary':[], |
| | '7.0 works to existing buildings':[], |
| | '8.1 site preparation works':[], |
| | '8.2 roads, paths, pavings':[], |
| | '8.3 soft landscaping':[], |
| | '8.4 fencing, railing, walls':[], |
| | '8.5 external fixtures':[], |
| | '8.6 external drainage':[], |
| | '8.7 external services':[], |
| | '8.8 minor buildings':[] |
| | } |
| | return DictionaryOfTemplates |
| |
|
| |
|
| | def APIValues(): |
| | query={"loginname":"Marthe","password":"marthemain"} |
| | |
| | head={'Content-Type':'application/json'} |
| | url = "https://httpbin.org/post" |
| |
|
| | response=requests.post(url="https://console.trevorsadd.co.uk/account/login",json=query,headers=head,verify=False) |
| | key=response.text |
| | |
| | head={'Content-Type':'application/json;charset=UTF-8',"Authorization":'Bearer {}'.format(key)} |
| | data={"pagesize": 1000000000} |
| | response=requests.post(url=" https://consoletest.trevorsadd.co.uk/template/getgridview?isarchive=false",json=data,headers=head,verify=False) |
| | dict1=response.json() |
| | return dict1 |
| |
|
| |
|
| | def RetrieveMC_Templates_API(): |
| | |
| | DictionaryOfTemplates=createDictionary() |
| | dict1=APIValues() |
| | for item in dict1.get('data') : |
| | if item.get('section'): |
| | section=item.get('section').lower() |
| | if section in DictionaryOfTemplates.keys(): |
| | if item.get('templatename') not in DictionaryOfTemplates[section]: |
| | DictionaryOfTemplates[section].append([item.get('templatename'),item.get('unit')]) |
| | |
| | |
| | |
| | return DictionaryOfTemplates |
| |
|
| | def mctoSheets( DictionaryOfTemplates): |
| | gc=API.AuthorizeGoogleSheets()[2] |
| | ws = gc.open_by_key('1I4P7wiCXTAwnld0YQfUJC8bPtuiETna1HGWVuHbuDBk') |
| |
|
| | MC_TNamesSheet=ws.worksheet_by_title('MC-T Names') |
| | MC_TNamesSheet.clear() |
| | |
| | MC_DF=pd.DataFrame({k: np.ravel(v) for k, v in DictionaryOfTemplates.items()}) |
| | |
| | MC_TNamesSheet.set_dataframe(start='A1',df=MC_DF) |
| |
|