Spaces:
Runtime error
Runtime error
add project.append()
Browse files- nbs/00_project.ipynb +55 -19
- nbs/index.ipynb +10 -6
- uoh_software_project_time_report/_modidx.py +2 -0
- uoh_software_project_time_report/project.py +15 -2
nbs/00_project.ipynb
CHANGED
@@ -94,8 +94,8 @@
|
|
94 |
"\n",
|
95 |
"class Project(__Project):\n",
|
96 |
" def __init__(self,\n",
|
97 |
-
" fn:
|
98 |
-
" super(Project, self).__init__(SCOPES,
|
99 |
]
|
100 |
},
|
101 |
{
|
@@ -147,7 +147,11 @@
|
|
147 |
{
|
148 |
"data": {
|
149 |
"text/plain": [
|
150 |
-
"[['3/1/2022', '4000'],
|
|
|
|
|
|
|
|
|
151 |
]
|
152 |
},
|
153 |
"execution_count": null,
|
@@ -179,18 +183,6 @@
|
|
179 |
" response = request.execute()"
|
180 |
]
|
181 |
},
|
182 |
-
{
|
183 |
-
"cell_type": "code",
|
184 |
-
"execution_count": null,
|
185 |
-
"metadata": {},
|
186 |
-
"outputs": [],
|
187 |
-
"source": [
|
188 |
-
"data = [[\"3/1/2022\", \"4000\"],[\"4/4/2022\", \"3000\"],[\"7/12/2022\", \"7000\"]]\n",
|
189 |
-
"pr.put(data, \"Test\")\n",
|
190 |
-
"pr.get(\"Test\")\n",
|
191 |
-
"test_eq(pr.get(\"Test\"), data)"
|
192 |
-
]
|
193 |
-
},
|
194 |
{
|
195 |
"cell_type": "code",
|
196 |
"execution_count": null,
|
@@ -199,9 +191,11 @@
|
|
199 |
{
|
200 |
"data": {
|
201 |
"text/plain": [
|
202 |
-
"[['
|
203 |
-
" ['
|
204 |
-
" ['
|
|
|
|
|
205 |
]
|
206 |
},
|
207 |
"execution_count": null,
|
@@ -210,7 +204,49 @@
|
|
210 |
}
|
211 |
],
|
212 |
"source": [
|
213 |
-
"pr.get()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
]
|
215 |
}
|
216 |
],
|
|
|
94 |
"\n",
|
95 |
"class Project(__Project):\n",
|
96 |
" def __init__(self,\n",
|
97 |
+
" fn:str=SERVICE_ACCOUNT_FILE): # service account file name\n",
|
98 |
+
" super(Project, self).__init__(SCOPES, fn, SPREADSHEET_ID)"
|
99 |
]
|
100 |
},
|
101 |
{
|
|
|
147 |
{
|
148 |
"data": {
|
149 |
"text/plain": [
|
150 |
+
"[['3/1/2022', '4000'],\n",
|
151 |
+
" ['4/4/2022', '3000'],\n",
|
152 |
+
" ['7/12/2022', '7000'],\n",
|
153 |
+
" ['7/12/2022', '9999'],\n",
|
154 |
+
" ['7/12/2022', '9999']]"
|
155 |
]
|
156 |
},
|
157 |
"execution_count": null,
|
|
|
183 |
" response = request.execute()"
|
184 |
]
|
185 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
{
|
187 |
"cell_type": "code",
|
188 |
"execution_count": null,
|
|
|
191 |
{
|
192 |
"data": {
|
193 |
"text/plain": [
|
194 |
+
"[['3/1/2022', '4000'],\n",
|
195 |
+
" ['4/4/2022', '3000'],\n",
|
196 |
+
" ['7/12/2022', '7000'],\n",
|
197 |
+
" ['7/12/2022', '9999'],\n",
|
198 |
+
" ['7/12/2022', '9999']]"
|
199 |
]
|
200 |
},
|
201 |
"execution_count": null,
|
|
|
204 |
}
|
205 |
],
|
206 |
"source": [
|
207 |
+
"pr.get(\"Test\")"
|
208 |
+
]
|
209 |
+
},
|
210 |
+
{
|
211 |
+
"cell_type": "code",
|
212 |
+
"execution_count": null,
|
213 |
+
"metadata": {},
|
214 |
+
"outputs": [],
|
215 |
+
"source": [
|
216 |
+
"data = [[\"3/1/2022\", \"4000\"],[\"4/4/2022\", \"3000\"],[\"7/12/2022\", \"7000\"]]\n",
|
217 |
+
"pr.put(data, \"Test\")\n",
|
218 |
+
"test_eq(pr.get(\"Test\")[:3], data)"
|
219 |
+
]
|
220 |
+
},
|
221 |
+
{
|
222 |
+
"cell_type": "code",
|
223 |
+
"execution_count": null,
|
224 |
+
"metadata": {},
|
225 |
+
"outputs": [],
|
226 |
+
"source": [
|
227 |
+
"#| export\n",
|
228 |
+
"@patch\n",
|
229 |
+
"def append(self:Project,\n",
|
230 |
+
" data:list,\n",
|
231 |
+
" sname:str=\"\") -> None: # a worksheet name can be specified. If not the 1st sheet is choosen.\n",
|
232 |
+
" range = f\"{sname}!\" if sname else \"\"\n",
|
233 |
+
" range += \"A:E\"\n",
|
234 |
+
" request = self.sheet.values().append(spreadsheetId=self.sid,\n",
|
235 |
+
" range=range,\n",
|
236 |
+
" valueInputOption=\"USER_ENTERED\",\n",
|
237 |
+
" body={\"values\":data})\n",
|
238 |
+
" response = request.execute()"
|
239 |
+
]
|
240 |
+
},
|
241 |
+
{
|
242 |
+
"cell_type": "code",
|
243 |
+
"execution_count": null,
|
244 |
+
"metadata": {},
|
245 |
+
"outputs": [],
|
246 |
+
"source": [
|
247 |
+
"data = [\"7/12/2022\", \"9999\"]\n",
|
248 |
+
"pr.append([data], \"Test\")\n",
|
249 |
+
"test_eq(pr.get(\"Test\")[-1], data)"
|
250 |
]
|
251 |
}
|
252 |
],
|
nbs/index.ipynb
CHANGED
@@ -73,7 +73,7 @@
|
|
73 |
}
|
74 |
],
|
75 |
"source": [
|
76 |
-
"pr = Project('
|
77 |
"pr"
|
78 |
]
|
79 |
},
|
@@ -85,9 +85,11 @@
|
|
85 |
{
|
86 |
"data": {
|
87 |
"text/plain": [
|
88 |
-
"[['name', 'backlog item #', 'hours spent', 'date'],\n",
|
89 |
" ['Hiroshi Doyu', '25', '1', '2022/1/16'],\n",
|
90 |
-
" ['Michihito Mizutani', '28', '1', '2022/1/16']
|
|
|
|
|
91 |
]
|
92 |
},
|
93 |
"execution_count": null,
|
@@ -116,9 +118,11 @@
|
|
116 |
{
|
117 |
"data": {
|
118 |
"text/plain": [
|
119 |
-
"[['name', 'backlog item #', 'hours spent', 'date'],\n",
|
120 |
" ['Hiroshi Doyu', '25', '1', '2022/1/16'],\n",
|
121 |
-
" ['Michihito Mizutani', '28', '1', '2022/1/16']
|
|
|
|
|
122 |
]
|
123 |
},
|
124 |
"execution_count": null,
|
@@ -131,7 +135,7 @@
|
|
131 |
"df.columns = df.iloc[0]\n",
|
132 |
"df = df[1:]\n",
|
133 |
"df['backlog item #'] = df['backlog item #'].astype(int)\n",
|
134 |
-
"df['hours spent'] = df['hours spent'].astype(
|
135 |
"df.date = pd.to_datetime(df.date)\n",
|
136 |
"df.date = df.date.dt.strftime(\"%Y-%m-%d\")\n",
|
137 |
"pr.put([df.columns.tolist()] + df.values.tolist())\n",
|
|
|
73 |
}
|
74 |
],
|
75 |
"source": [
|
76 |
+
"pr = Project('../keys.json')\n",
|
77 |
"pr"
|
78 |
]
|
79 |
},
|
|
|
85 |
{
|
86 |
"data": {
|
87 |
"text/plain": [
|
88 |
+
"[['name', 'backlog item #', 'hours spent', 'date', 'comment'],\n",
|
89 |
" ['Hiroshi Doyu', '25', '1', '2022/1/16'],\n",
|
90 |
+
" ['Michihito Mizutani', '28', '1', '2022/1/16'],\n",
|
91 |
+
" ['Hiroshi Doyu', '25', '1', '2022/1/17'],\n",
|
92 |
+
" ['Hiroshi Doyu', '27', '1.5', '2023-01-30', 'test']]"
|
93 |
]
|
94 |
},
|
95 |
"execution_count": null,
|
|
|
118 |
{
|
119 |
"data": {
|
120 |
"text/plain": [
|
121 |
+
"[['name', 'backlog item #', 'hours spent', 'date', 'comment'],\n",
|
122 |
" ['Hiroshi Doyu', '25', '1', '2022/1/16'],\n",
|
123 |
+
" ['Michihito Mizutani', '28', '1', '2022/1/16'],\n",
|
124 |
+
" ['Hiroshi Doyu', '25', '1', '2022/1/17'],\n",
|
125 |
+
" ['Hiroshi Doyu', '27', '1.5', '2023-01-30', 'test']]"
|
126 |
]
|
127 |
},
|
128 |
"execution_count": null,
|
|
|
135 |
"df.columns = df.iloc[0]\n",
|
136 |
"df = df[1:]\n",
|
137 |
"df['backlog item #'] = df['backlog item #'].astype(int)\n",
|
138 |
+
"df['hours spent'] = df['hours spent'].astype(float)\n",
|
139 |
"df.date = pd.to_datetime(df.date)\n",
|
140 |
"df.date = df.date.dt.strftime(\"%Y-%m-%d\")\n",
|
141 |
"pr.put([df.columns.tolist()] + df.values.tolist())\n",
|
uoh_software_project_time_report/_modidx.py
CHANGED
@@ -9,6 +9,8 @@ d = { 'settings': { 'branch': 'main',
|
|
9 |
'uoh_software_project_time_report/project.py'),
|
10 |
'uoh_software_project_time_report.project.Project.__init__': ( 'project.html#project.__init__',
|
11 |
'uoh_software_project_time_report/project.py'),
|
|
|
|
|
12 |
'uoh_software_project_time_report.project.Project.get': ( 'project.html#project.get',
|
13 |
'uoh_software_project_time_report/project.py'),
|
14 |
'uoh_software_project_time_report.project.Project.put': ( 'project.html#project.put',
|
|
|
9 |
'uoh_software_project_time_report/project.py'),
|
10 |
'uoh_software_project_time_report.project.Project.__init__': ( 'project.html#project.__init__',
|
11 |
'uoh_software_project_time_report/project.py'),
|
12 |
+
'uoh_software_project_time_report.project.Project.append': ( 'project.html#project.append',
|
13 |
+
'uoh_software_project_time_report/project.py'),
|
14 |
'uoh_software_project_time_report.project.Project.get': ( 'project.html#project.get',
|
15 |
'uoh_software_project_time_report/project.py'),
|
16 |
'uoh_software_project_time_report.project.Project.put': ( 'project.html#project.put',
|
uoh_software_project_time_report/project.py
CHANGED
@@ -31,8 +31,8 @@ SPREADSHEET_ID = '1DNoNf4glcuMxKoVzHVrFo-MktmsVji1wf4IHeraWH84'
|
|
31 |
|
32 |
class Project(__Project):
|
33 |
def __init__(self,
|
34 |
-
fn:
|
35 |
-
super(Project, self).__init__(SCOPES,
|
36 |
|
37 |
# %% ../nbs/00_project.ipynb 10
|
38 |
@patch
|
@@ -57,3 +57,16 @@ def put(self:Project,
|
|
57 |
valueInputOption="USER_ENTERED",
|
58 |
body={"values":data})
|
59 |
response = request.execute()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
class Project(__Project):
|
33 |
def __init__(self,
|
34 |
+
fn:str=SERVICE_ACCOUNT_FILE): # service account file name
|
35 |
+
super(Project, self).__init__(SCOPES, fn, SPREADSHEET_ID)
|
36 |
|
37 |
# %% ../nbs/00_project.ipynb 10
|
38 |
@patch
|
|
|
57 |
valueInputOption="USER_ENTERED",
|
58 |
body={"values":data})
|
59 |
response = request.execute()
|
60 |
+
|
61 |
+
# %% ../nbs/00_project.ipynb 16
|
62 |
+
@patch
|
63 |
+
def append(self:Project,
|
64 |
+
data:list,
|
65 |
+
sname:str="") -> None: # a worksheet name can be specified. If not the 1st sheet is choosen.
|
66 |
+
range = f"{sname}!" if sname else ""
|
67 |
+
range += "A:E"
|
68 |
+
request = self.sheet.values().append(spreadsheetId=self.sid,
|
69 |
+
range=range,
|
70 |
+
valueInputOption="USER_ENTERED",
|
71 |
+
body={"values":data})
|
72 |
+
response = request.execute()
|