API Reference / Source Code
Below is a list of all classes and functions used for CLA Bot. Those are considered to be 'internal', with no need for users to access any of these. Please use the CLI tools instead.
CLA Bot relies on third party modules to interface with GitLab, git,
SQLite, and csv. Please check pyproject.toml for more details on the
required packages.
'Core' components
src.bot.cla_bot
run(argv=sys.argv)
Wrapper to run CLA Bot, adds command line interface.
This will read all options from the command line or environment.
Source code in src/bot/cla_bot.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
src.bot.add_cla
run(argv=sys.argv)
Wrapper that adds a command line interface to CLA Bot adding signatures.
This will read all options from the command line. Input can also be taken from $CI_COMMIT_MESSAGE if run from within a pipeline.
Source code in src/bot/add_cla.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
src.bot.core
Adder
Core component of CLA Bot when adding signatures
Source code in src/bot/core.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
Bot
Core component of CLA Bot
Source code in src/bot/core.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
__init__(force, dry_run=False, gitlab_workflow=False, allow_list='', auto_allow='', store_branch='', store_scope='', store_type='', mr_iid=None, playground=None, home=None, store=None, payload=None)
Constructor of the bot.
Source code in src/bot/core.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
exec()
Main wrapper to run CLA Bot.
It will in turn connect to the different locations ('playground', 'store', 'home'), read the payload and then check if anything is to do. Then iterate (or pick one) over merge requests to check contributors, leave notes, close discussions, the lot.
Source code in src/bot/core.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
Payload
A class to hold 'payload' data from webhooks/triggers. This is used as configuration/input for CLA Bot.
The parameters extracted from the payload and stored for later use include
- a flag if the pipeline was actually triggered (we could be using a command line to force interaction)
- the project id (for the 'playground')
- the triggering event type (comments, MRs, commits, ...)
- the MR id (actually the project internal id)
- the user id of the user causing the event (might be the bot itself)
Source code in src/bot/core.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
Interacting with GitLab and git
src.bot.project
Project
Interact with GitLab and its projects
This class wraps all python-gitlab calls, combining them as suitable and
adding output. If called in 'dry mode', no changes will be made to the
project, instead only comments written to stdout.
Methods:
| Name | Description |
|---|---|
connect_to_project |
mandatory connection to GitLab, used for 'playground' and 'home' |
string_match |
compare (sub)strings, ignoring whitespace and case |
check_avatar |
check the bot's avatar, setting it |
convert_names_to_ids |
convert list of usernames to user ids |
convert_roles_to_ids |
convert access role to numeric id |
obtain_involved_users |
collect contributors for an MR |
add_comment |
add comments to issues, MRs, discussions |
start_discussion |
start discussion thread (unresolved) |
wait_until_its_our_turn |
wait out turn in current CI pipeline |
get_open_issues |
get all open issues |
get_open_mrs |
get all open MRs |
commented_before |
check if comment with same string already exists |
user_is_in_allow_list |
compare user to allow list |
role_is_in_auto_allow |
compare role to allow list |
CLA_is_signed |
check list of notes for signature string |
mark_thread_resolved |
resolve discussion thread |
Source code in src/bot/project.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
CLA_is_signed(notes, user, signature_string)
Check if a list of notes contains the 'signature string' added by a specific user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notes
|
list of notes to check |
required | |
user
|
int
|
user id to look for |
required |
signature_string
|
str
|
string that qualifies as signature |
required |
Returns:
| Name | Type | Description |
|---|---|---|
signed_in_note |
int
|
numeric id of note containing signature string |
Source code in src/bot/project.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
__init__(token=None, project=None, dry_run=False, allow_list='', auto_allow='', instance='', name='')
Constructor for Project
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
access token for project |
None
|
project
|
int
|
project's id |
None
|
dry_run
|
bool
|
toggle dry run, changing print mainly statements. |
False
|
allow_list
|
strings
|
list of allowed usernames |
''
|
auto_allow
|
int
|
numeric role that is allowed |
''
|
instance
|
str
|
URL of GitLab server to connect to |
''
|
name
|
str
|
identifier of project to connect to |
''
|
Source code in src/bot/project.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
add_comment(target, comment, name=None, url=None)
Add a comment to an issue, merge request, or discussion
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
object to comment on |
required | |
comment
|
str
|
comment to leave |
required |
name
|
str
|
user to address (optional) |
None
|
url
|
str
|
URL to refer to (optional) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
flag |
bool
|
true if comment added, false if wrong note type |
Source code in src/bot/project.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
check_avatar(gl)
Check our avatar, set correct one if necessary
Source code in src/bot/project.py
176 177 178 179 180 181 182 183 184 | |
commented_before(notes, search_str, name=None)
Check if similar comment was already made
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notes
|
list of notes to check |
required | |
search_str
|
str
|
string to look for as comment |
required |
name
|
str
|
user to address (optional) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ack |
bool
|
true if note with search_str already added |
Source code in src/bot/project.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
connect_to_project(instance, token, project_id, name='')
Connect to the project
Using the supplied token, this will connect to the project on the given GitLab instance. Can work with project access tokens or CI_JOB_TOKEN alike, the latter not allowing to query a user. Optionally include an indentifier for the project to connect to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
str
|
URL of GitLab instance to connect to |
required |
token
|
str
|
access token for project |
required |
project_id
|
int
|
project id to connect to |
required |
name
|
str
|
identifier of project to connect to |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
project |
connected GitLab project |
|
gluser |
current user, connected to the project |
|
gl |
connection to GitLab |
Source code in src/bot/project.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
convert_names_to_ids(allow_list)
Convert list of usernames to list of ids
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allow_list
|
str
|
csv list of user names on GitLab |
required |
Returns:
| Name | Type | Description |
|---|---|---|
id_list |
int
|
list of matching user ids on GitLab |
Source code in src/bot/project.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
convert_roles_to_ids(auto_allow)
Convert list of roles to list of access levels
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auto_allow
|
str
|
list of project roles |
required |
Returns:
| Type | Description |
|---|---|
|
lvl_list (): list of matching access levels |
Source code in src/bot/project.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
get_open_issues()
Get all (no pagination) open issues of the project
Returns:
| Name | Type | Description |
|---|---|---|
issues |
iterator
|
list of issues |
Source code in src/bot/project.py
382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_open_mrs()
Get all (no pagination) open merge request of the project, earliest first
Returns:
| Name | Type | Description |
|---|---|---|
mrs |
iterator
|
list of merge requests |
Source code in src/bot/project.py
396 397 398 399 400 401 402 403 404 405 406 407 408 | |
mark_thread_resolved(mr, search_str, ack_str=None, name=None, url=None)
Mark a thread as resolved
Will look for a thread started by the bot, including the correct search string, then resolve it with a matching comment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mr
|
merge request to work one |
required | |
search_str
|
str
|
string to look for in discussion |
required |
ack_str
|
str
|
string to respond with (optional) |
None
|
name
|
str
|
user to address (optional) |
None
|
url
|
str
|
URL to the signature (optional) |
None
|
Source code in src/bot/project.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
obtain_involved_users(mr)
Return list of user ids that show up in MR along with their names. At a minimum, it will return MR author.
Names that cannot be resolved (or are not unique) on the GitLab instance will be listed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mr
|
merge request to check |
required |
Returns:
| Name | Type | Description |
|---|---|---|
users |
int
|
list of user id |
names |
str
|
list of user names |
not_found |
str
|
list of names not found |
Source code in src/bot/project.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
role_is_in_auto_allow(user)
Check if user is project member and has required role. Will issue a free hall pass if allowed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
int
|
numeric user id |
required |
Returns:
| Name | Type | Description |
|---|---|---|
hall_pass |
bool
|
true if role is allowed |
Source code in src/bot/project.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
start_discussion(target, comment, name=None)
Start a discussion within a merge request, adding a comment
This will leave an unresolved thread in the process
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
merge request to comment on |
required | |
comment
|
str
|
comment to leave |
required |
name
|
str
|
user to address (optional) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
flag |
bool
|
true if comment added, false if wrong note type |
Source code in src/bot/project.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
string_match(string_to_search, string_to_match)
Check if one string is a substring anywhere within the other. Ignores any spaces and newlines, also ignores case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_to_search
|
str
|
string to search within |
required |
string_to_match
|
str
|
string to search for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
flag |
bool
|
true when search string found |
Source code in src/bot/project.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
user_is_in_allow_list(user)
Check if user is in allow list. Will issue a free hall pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
int
|
numeric user id |
required |
Returns:
| Name | Type | Description |
|---|---|---|
hall_pass |
bool
|
true if user is allowed |
Source code in src/bot/project.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
wait_until_its_our_turn(current_pipeline_id=None)
Wait until our pipeline is the one created first out of the running ones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_pipeline_id
|
str
|
active pipeline id, string taken from ENV |
None
|
Source code in src/bot/project.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
ProjectData
dataclass
Dataclass to store project data. Includes name and location (either GitLab internal id or URL) as well as necessary access tokens.
Source code in src/bot/project.py
20 21 22 23 24 25 26 27 28 29 30 | |
src.bot.repository
Repository
Interact with git.
Required to store signature database within the git repository, will track signatures over time. If used in 'dry mode', new/changed files will not be committed to the repository. The final git commit/push relies on the destructor being executed sucessfully.
Source code in src/bot/repository.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
__connect_to_project()
Connect to the project storing signatures.
Use access token to clone git repository and check out database file. Will be used from the class constructor.
Returns:
| Name | Type | Description |
|---|---|---|
repo |
Repo
|
instance pointing to the cloned directory |
Source code in src/bot/repository.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
__del__()
Destructor for Repository.
This will commit changed and untracked files. If there are any changes, those will be pushed to the repository. This will again rely on the access token and variables used in the constructor.
Source code in src/bot/repository.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
__init__(dry_run=False, token=None, store_url=None, store_branch='main')
Constructor for Repository.
This will clone the repository and check out the database file. Committing/pushing changes will happen in the class destructor!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dry_run
|
bool
|
toggle dry run w/o actually using a repository |
False
|
token
|
str
|
access token (read/write repo) to access repository |
None
|
store_url
|
str
|
URL of repository |
None
|
store_branch
|
str
|
branch to check out |
'main'
|
Source code in src/bot/repository.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
'Database' access
src.bot.csvlite
CSVLite
Interact with csv file acting as database that holds known contributors. The class will read all contents of the csv file into memory. Adding a new contributor will happen in memory and disk at the same time. 'dry mode' will still edit data on disk, the class relies on data not being committed to git in 'dry mode'.
Data stored for contributors
id: internal numberinguser_id: GitLab user idname: user's nameemail: user's emailindividual: 0/1 if signed as individual or instiutionstart_date: user first seencla_version: version of CLA that has been signed, ie. the date of itsigned_with_mr: if signed via comment, note the corresponding MRlast_sign_date: last time CLA has been signedend_date: if we want to expire the user
Methods:
| Name | Description |
|---|---|
connect_to_csvfile |
Open 'database' file, returns all contents. |
add_signature |
Adding entry to 'database'. |
signature_valid |
Check for valid contributor. |
Source code in src/bot/csvlite.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__del__()
Destructor for CSV.
If instantiated in dry_run mode, will print the final content of the database.
Source code in src/bot/csvlite.py
91 92 93 94 95 96 97 98 99 100 101 | |
__init__(dry_run=False, path=None, project_id=None)
Constructor for CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dry_run
|
bool
|
toggle dry run, effectively only changing print statements. |
False
|
path
|
str
|
path to store database file. |
None
|
project_id
|
int
|
numeric project id (used to extend database path). |
None
|
Source code in src/bot/csvlite.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
add_signature(user_id=None, name=None, email=None, individual=True, mr=None)
Add a signature for a single contributor to database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
user id in GitLab (to match commits/MRs) |
None
|
name
|
str
|
user's name in GitLab (human readable name) |
None
|
email
|
str
|
user's email in GitLab (contact email) |
None
|
individual
|
bool
|
signing as individual? (unless a legal entity) |
True
|
mr
|
int
|
numeric id of MR that had signature |
None
|
Source code in src/bot/csvlite.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
connect_to_csvfile()
Connect to the csv file (the 'database').
This will in fact either read the file and return a Dict or create an emtpy Dict and return that...
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict
|
all of the the csv data |
Source code in src/bot/csvlite.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
signature_valid(user_id=None)
Check if a signature is (still) valid. Will also fail for no entry in database for that user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
user id in GitLab (to match commits/MRs) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
is_valid |
bool
|
true if signature found and valid |
Source code in src/bot/csvlite.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
src.bot.sqlite
SQLite
Interact with SQLite file acting as database that holds known contributors. The class will open the SQLite file and use a handle to query or add data. Adding a new contributor will happen add an entry to the file, so 'dry mode' will still edit data on disk, the class relies on data not being committed to git in 'dry mode'.
Data stored for contributors
id: internal numberinguser_id: GitLab user idname: user's nameemail: user's emailindividual: 0/1 if signed as individual or instiutionstart_date: user first seencla_version: version of CLA that has been signed, ie. the date of itsigned_with_mr: if signed via comment, note the corresponding MRlast_sign_date: last time CLA has been signedend_date: if we want to expire the user
Methods:
| Name | Description |
|---|---|
connect_to_sqlite_db |
Open 'database' file, returns handle. |
add_signature |
Adding entry to 'database'. |
signature_valid |
Check for valid contributor. |
Source code in src/bot/sqlite.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
__del__()
Destructor for SQLite.
If instantiated in dry_run mode, will print the final content of the database.
Source code in src/bot/sqlite.py
68 69 70 71 72 73 74 75 76 77 78 79 | |
__init__(dry_run=False, path=None, project_id=None)
Constructor for SQLite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dry_run
|
bool
|
toggle dry run, effectively only changing print statements. |
False
|
path
|
str
|
path to store database file. |
None
|
project_id
|
int
|
numeric project id (used to extend database path). |
None
|
Source code in src/bot/sqlite.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
add_signature(user_id=None, name=None, email=None, individual=True, mr=None)
Add a signature for a single contributor to database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
user id in GitLab (to match commits/MRs) |
None
|
name
|
str
|
user's name in GitLab (human readable name) |
None
|
email
|
str
|
user's email in GitLab (contact email) |
None
|
individual
|
bool
|
signing as individual? (unless a legal entity) |
True
|
mr
|
int
|
numeric id of MR that had signature |
None
|
Source code in src/bot/sqlite.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
connect_to_sqlite_db()
Connect to the SQLite database file.
This will in fact either connect to an existing file or create a new emtpy one and return handles to that...
Returns:
| Name | Type | Description |
|---|---|---|
connection |
database connection |
|
db |
connection cursor for queries |
Source code in src/bot/sqlite.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
signature_valid(user_id=None)
Check if a signature is (still) valid. Will also fail for no entry in database for that user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
user id in GitLab (to match commits/MRs) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
is_valid |
bool
|
true if signature found and valid |
Source code in src/bot/sqlite.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |