papi-projects 0.1.2__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: papi-projects
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: PAPI is an API for managing projects
5
5
  License: MIT
6
6
  Author: sandyjmacdonald
@@ -18,6 +18,8 @@ Description-Content-Type: text/markdown
18
18
 
19
19
  PAPI is an API for managing projects.
20
20
 
21
+ <img src="https://imgur.com/lprJ3mP.jpg" alt="HAHA BUSINESS meme" height="250">
22
+
21
23
  It has functionality for creating User and Project instances, storing users in a TinyDB database, and generating project IDs in the format we use in the Data Science group (at the Bioscience Technology Facility at the University of York). It also has wrappers for Asana and Toggl Track, two tools we use for project management and time tracking, respectively.
22
24
 
23
25
  Much of the functionality is tailor-made to the way we manage projects in our group, but make of it what you will!
@@ -127,3 +129,101 @@ To collate your hours worked in August 2024:
127
129
  ```
128
130
  collate-toggl-hours -s 2024-08-01 -e 2024-08-31 -o august-2024-hours.tsv
129
131
  ```
132
+
133
+ ## API reference
134
+
135
+ ## project module
136
+
137
+ ## Project class
138
+
139
+ The `Project` class is central to the whole library. A `Project` instance can be created in a few different ways.
140
+
141
+ At the most basic level, a valid `user_id` (either three letter initials or two letter initials and an integer number from 1 to 9) can be provided when instantiating the class, and the prefix and suffix will be generated.
142
+
143
+ ```
144
+ from papi.project import Project
145
+
146
+ proj = Project(user_id="CRD")
147
+ ```
148
+
149
+ This will generate the project ID, `id` attribute using the current year, and a random four-letter suffix.
150
+
151
+ ```
152
+ print(proj.id)
153
+ print(proj.year)
154
+ print(proj.suffix)
155
+ ```
156
+
157
+ ```
158
+ P2024-CRD-FZLL
159
+ 2024
160
+ FZLL
161
+ ```
162
+
163
+ If a valid project ID has already been created, then a `Project` instance can be instantiated with the `id` attribute, and the `year`, `user_id`, and `suffix` attributes will be pulled out and set on the instance.
164
+
165
+ ```
166
+ proj = Project(id="P2024-CRD-FZLL")
167
+
168
+ print(proj.year)
169
+ print(proj.user_id)
170
+ print(proj.suffix)
171
+ ```
172
+
173
+ ```
174
+ 2024
175
+ CRD
176
+ FZLL
177
+ ```
178
+
179
+ If a grant code and/or project name are available, then these can be passed in when instantiating the class.
180
+
181
+ ```
182
+ proj = Project(user_id="CRD", grant_code="R12345", name="RNA-seq analysis")
183
+ ```
184
+
185
+ A version 4 UUID is also generated for the project when instantiated.
186
+
187
+ ```
188
+ proj = Project(user_id="CRD")
189
+
190
+ print(proj.p_uuid)
191
+ ```
192
+
193
+ ```
194
+ 6697e457-9785-4668-b78b-72616b27aede
195
+ ```
196
+
197
+ Or if a version 4 UUID has been generated separately then it can be provided when instantiating.
198
+
199
+ ```
200
+ proj = Project(user_id="CRD", p_uuid="6697e457-9785-4668-b78b-72616b27aede")
201
+ ```
202
+
203
+ ## project functions
204
+
205
+ A couple of functions are provided to check the validity of a project ID, to check the validity of a suffix, and to check for a valid version 4 UUID.
206
+
207
+ You can check the validity of a project ID as follows:
208
+
209
+ ```
210
+ from papi.project import check_project_id
211
+
212
+ print(check_project_id("P2024-CRD-FZLL"))
213
+ print(check_project_id("P2024-CRD-1234"))
214
+ ```
215
+
216
+ ```
217
+ True
218
+ False
219
+ ```
220
+
221
+ You can check the validity of a project suffix as follows:
222
+
223
+ ```
224
+ from papi.project import check_suffix
225
+
226
+ print(check_suffix("FZLL"))
227
+ print(check_suffix("1234"))
228
+ ```
229
+
@@ -1,5 +1,7 @@
1
1
  PAPI is an API for managing projects.
2
2
 
3
+ <img src="https://imgur.com/lprJ3mP.jpg" alt="HAHA BUSINESS meme" height="250">
4
+
3
5
  It has functionality for creating User and Project instances, storing users in a TinyDB database, and generating project IDs in the format we use in the Data Science group (at the Bioscience Technology Facility at the University of York). It also has wrappers for Asana and Toggl Track, two tools we use for project management and time tracking, respectively.
4
6
 
5
7
  Much of the functionality is tailor-made to the way we manage projects in our group, but make of it what you will!
@@ -108,4 +110,101 @@ To collate your hours worked in August 2024:
108
110
 
109
111
  ```
110
112
  collate-toggl-hours -s 2024-08-01 -e 2024-08-31 -o august-2024-hours.tsv
111
- ```
113
+ ```
114
+
115
+ ## API reference
116
+
117
+ ## project module
118
+
119
+ ## Project class
120
+
121
+ The `Project` class is central to the whole library. A `Project` instance can be created in a few different ways.
122
+
123
+ At the most basic level, a valid `user_id` (either three letter initials or two letter initials and an integer number from 1 to 9) can be provided when instantiating the class, and the prefix and suffix will be generated.
124
+
125
+ ```
126
+ from papi.project import Project
127
+
128
+ proj = Project(user_id="CRD")
129
+ ```
130
+
131
+ This will generate the project ID, `id` attribute using the current year, and a random four-letter suffix.
132
+
133
+ ```
134
+ print(proj.id)
135
+ print(proj.year)
136
+ print(proj.suffix)
137
+ ```
138
+
139
+ ```
140
+ P2024-CRD-FZLL
141
+ 2024
142
+ FZLL
143
+ ```
144
+
145
+ If a valid project ID has already been created, then a `Project` instance can be instantiated with the `id` attribute, and the `year`, `user_id`, and `suffix` attributes will be pulled out and set on the instance.
146
+
147
+ ```
148
+ proj = Project(id="P2024-CRD-FZLL")
149
+
150
+ print(proj.year)
151
+ print(proj.user_id)
152
+ print(proj.suffix)
153
+ ```
154
+
155
+ ```
156
+ 2024
157
+ CRD
158
+ FZLL
159
+ ```
160
+
161
+ If a grant code and/or project name are available, then these can be passed in when instantiating the class.
162
+
163
+ ```
164
+ proj = Project(user_id="CRD", grant_code="R12345", name="RNA-seq analysis")
165
+ ```
166
+
167
+ A version 4 UUID is also generated for the project when instantiated.
168
+
169
+ ```
170
+ proj = Project(user_id="CRD")
171
+
172
+ print(proj.p_uuid)
173
+ ```
174
+
175
+ ```
176
+ 6697e457-9785-4668-b78b-72616b27aede
177
+ ```
178
+
179
+ Or if a version 4 UUID has been generated separately then it can be provided when instantiating.
180
+
181
+ ```
182
+ proj = Project(user_id="CRD", p_uuid="6697e457-9785-4668-b78b-72616b27aede")
183
+ ```
184
+
185
+ ## project functions
186
+
187
+ A couple of functions are provided to check the validity of a project ID, to check the validity of a suffix, and to check for a valid version 4 UUID.
188
+
189
+ You can check the validity of a project ID as follows:
190
+
191
+ ```
192
+ from papi.project import check_project_id
193
+
194
+ print(check_project_id("P2024-CRD-FZLL"))
195
+ print(check_project_id("P2024-CRD-1234"))
196
+ ```
197
+
198
+ ```
199
+ True
200
+ False
201
+ ```
202
+
203
+ You can check the validity of a project suffix as follows:
204
+
205
+ ```
206
+ from papi.project import check_suffix
207
+
208
+ print(check_suffix("FZLL"))
209
+ print(check_suffix("1234"))
210
+ ```
@@ -1,6 +1,8 @@
1
+ import os
1
2
  from dotenv import dotenv_values
2
3
 
3
- config = dotenv_values(".env")
4
+ dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
5
+ config = dotenv_values(dotenv_path)
4
6
 
5
7
  ASANA_API_KEY = config["ASANA_API_KEY"]
6
8
  ASANA_PASSWORD = config["ASANA_PASSWORD"]
@@ -19,7 +19,7 @@ def check_project_id(id: str) -> bool:
19
19
  :rtype: bool
20
20
  """
21
21
  valid = False
22
- pattern = re.compile(r"^P[0-9]{4}-[A-Z]{2}[A-Z0-9]{1}-[A-Z]{4}$")
22
+ pattern = re.compile(r"^P[0-9]{4}-[A-Z]{2}[A-Z1-9]{1}-[A-Z]{4}$")
23
23
  if pattern.match(id):
24
24
  valid = True
25
25
  return valid
@@ -104,6 +104,9 @@ class Project(Protocol):
104
104
  self.generate_suffix()
105
105
  if id is not None and check_project_id(id):
106
106
  self.id = id
107
+ self.year = int(id[1:5])
108
+ self.user_id = id.split("-")[1]
109
+ self.suffix = id.split("-")[2]
107
110
  elif (
108
111
  isinstance(year, int)
109
112
  and check_user_id(user_id)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "papi-projects"
3
- version = "0.1.2"
3
+ version = "0.1.4"
4
4
  description = "PAPI is an API for managing projects"
5
5
  authors = ["sandyjmacdonald <sandyjmacdonald@gmail.com>"]
6
6
  license = "MIT"