@@ -15,8 +15,9 @@ def json_get(parsed_json, key):
15
15
16
16
class GogsUser (object ):
17
17
"""
18
- An immutable representation of a Gogs user.
18
+ An immutable representation of a Gogs user
19
19
"""
20
+
20
21
def __init__ (self , user_id , username , full_name , email , avatar_url ):
21
22
self ._id = user_id
22
23
self ._username = username
@@ -110,7 +111,7 @@ def from_json(parsed_json):
110
111
@property # named repo_id to avoid conflict with built-in id
111
112
def repo_id (self ):
112
113
"""
113
- The repository's id number
114
+ The repository's id
114
115
115
116
:rtype: int
116
117
"""
@@ -180,6 +181,7 @@ def __init__(self, html_url, clone_url, ssh_url):
180
181
def html_url (self ):
181
182
"""
182
183
URL for the repository's webpage
184
+
183
185
:rtype: str
184
186
"""
185
187
return self ._html_url
@@ -197,7 +199,8 @@ def clone_url(self):
197
199
def ssh_url (self ):
198
200
"""
199
201
URL for cloning the repository via SSH
200
- :rtype:
202
+
203
+ :rtype: str
201
204
"""
202
205
return self ._ssh_url
203
206
@@ -256,19 +259,8 @@ def from_json(parsed_json):
256
259
events = json_get (parsed_json , "events" )
257
260
active = json_get (parsed_json , "active" )
258
261
config = json_get (parsed_json , "config" )
259
-
260
- return GogsRepo .Hook (hook_id = hook_id , hook_type = hook_type , events = events , active = active ,
261
- config = config )
262
-
263
- def as_dict (self ):
264
- fields = {
265
- "id" : self ._id ,
266
- "type" : self ._type ,
267
- "events" : self ._events ,
268
- "config" : self ._config ,
269
- "active" : self ._active ,
270
- }
271
- return {k : v for (k , v ) in fields .items () if v is not None }
262
+ return GogsRepo .Hook (hook_id = hook_id , hook_type = hook_type , events = events , active = active ,
263
+ config = config )
272
264
273
265
@property # named hook_id to avoid conflict with built-in id
274
266
def hook_id (self ):
@@ -309,10 +301,7 @@ def active(self):
309
301
@property
310
302
def config (self ):
311
303
"""
312
- Config of the hook. Contains max. 3 keys:
313
- - content_type
314
- - url
315
- - secret
304
+ Config of the hook. Possible keys include ``"content_type"``, ``"url"``, ``"secret"``
316
305
317
306
:rtype: dict
318
307
"""
@@ -336,19 +325,8 @@ def from_json(parsed_json):
336
325
created_at = json_get (parsed_json , "created_at" )
337
326
read_only = json_get (parsed_json , "read_only" )
338
327
339
- return GogsRepo .DeployKey (key_id = key_id , key = key , url = url ,
340
- title = title , created_at = created_at , read_only = read_only )
341
-
342
- def as_dict (self ):
343
- fields = {
344
- "id" : self ._id ,
345
- "key" : self ._key ,
346
- "url" : self ._url ,
347
- "title" : self ._title ,
348
- "created_at" : self ._created_at ,
349
- "read_only" : self ._read_only ,
350
- }
351
- return {k : v for (k , v ) in fields .items () if v is not None }
328
+ return GogsRepo .DeployKey (key_id = key_id , key = key , url = url ,
329
+ title = title , created_at = created_at , read_only = read_only )
352
330
353
331
@property # named key_id to avoid conflict with built-in id
354
332
def key_id (self ):
@@ -371,7 +349,7 @@ def key(self):
371
349
@property
372
350
def url (self ):
373
351
"""
374
- Url where the key can be found
352
+ URL where the key can be found
375
353
376
354
:rtype: str
377
355
"""
@@ -389,23 +367,27 @@ def title(self):
389
367
@property
390
368
def created_at (self ):
391
369
"""
392
- Creation date of the key.
370
+ Creation date of the key
371
+
393
372
:rtype: str
394
373
"""
395
374
return self ._created_at
396
375
397
376
@property
398
377
def read_only (self ):
399
378
"""
400
- Whether key is read-only.
379
+ Whether key is read-only
380
+
401
381
:rtype: bool
402
382
"""
403
383
return self ._read_only
404
384
385
+
405
386
class GogsOrg (object ):
406
387
"""
407
- An immutable representation of a Gogs Organization.
388
+ An immutable representation of a Gogs Organization
408
389
"""
390
+
409
391
def __init__ (self , org_id , username , full_name , avatar_url , description , website , location ):
410
392
self ._id = org_id
411
393
self ._username = username
@@ -425,20 +407,8 @@ def from_json(parsed_json):
425
407
website = json_get (parsed_json , "website" )
426
408
location = json_get (parsed_json , "location" )
427
409
return GogsOrg (org_id = org_id , username = username , full_name = full_name ,
428
- avatar_url = avatar_url , description = description ,
429
- website = website , location = location )
430
-
431
- def as_dict (self ):
432
- fields = {
433
- "id" : self ._id ,
434
- "username" : self ._username ,
435
- "full_name" : self ._full_name ,
436
- "avatar_url" : self ._avatar_url ,
437
- "description" : self ._description ,
438
- "website" : self ._website ,
439
- "location" : self ._location
440
- }
441
- return {k : v for (k , v ) in fields .items () if v is not None }
410
+ avatar_url = avatar_url , description = description ,
411
+ website = website , location = location )
442
412
443
413
@property # named org_id to avoid conflict with built-in id
444
414
def org_id (self ):
@@ -449,7 +419,7 @@ def org_id(self):
449
419
"""
450
420
return self ._id
451
421
452
- @property
422
+ @property
453
423
def username (self ):
454
424
"""
455
425
Organization's username
@@ -458,111 +428,102 @@ def username(self):
458
428
"""
459
429
return self ._username
460
430
461
- @property
431
+ @property
462
432
def full_name (self ):
463
433
"""
464
434
Organization's full name
465
435
466
436
:rtype: str
467
437
"""
468
- return self ._full_name
438
+ return self ._full_name
469
439
470
- @property
440
+ @property
471
441
def avatar_url (self ):
472
442
"""
473
443
Organization's avatar url
474
444
475
445
:rtype: str
476
446
"""
477
- return self ._avatar_url
447
+ return self ._avatar_url
478
448
479
- @property
449
+ @property
480
450
def description (self ):
481
451
"""
482
452
Organization's description
483
453
484
454
:rtype: str
485
455
"""
486
- return self ._description
456
+ return self ._description
487
457
488
- @property
458
+ @property
489
459
def website (self ):
490
460
"""
491
461
Organization's website address
492
462
493
463
:rtype: str
494
464
"""
495
- return self ._website
465
+ return self ._website
496
466
497
- @property
467
+ @property
498
468
def location (self ):
499
469
"""
500
470
Organization's location
501
471
502
472
:rtype: str
503
473
"""
504
- return self ._location
474
+ return self ._location
505
475
506
- class Team (object ):
507
- """
508
- Team of an organization
509
- """
510
- def __init__ (self , team_id , name , description , permission ):
511
- self ._id = team_id
512
- self ._name = name
513
- self ._description = description
514
- self ._permission = permission
515
476
516
- @staticmethod
517
- def from_json (parsed_json ):
518
- team_id = json_get (parsed_json , "id" )
519
- name = json_get (parsed_json , "name" )
520
- description = json_get (parsed_json , "description" )
521
- permission = json_get (parsed_json , "permission" )
522
- return GogsOrg .Team (team_id = team_id , name = name , description = description , permission = permission )
523
-
524
- def as_dict (self ):
525
- fields = {
526
- "team_id" : self ._id ,
527
- "name" : self ._name ,
528
- "description" : self ._description ,
529
- "permission" : self ._permission ,
530
- }
531
- return {k : v for (k , v ) in fields .items () if v is not None }
532
-
533
- @property # named team_id to avoid conflict with built-in id
534
- def team_id (self ):
535
- """
536
- Team's id
477
+ class GogsTeam (object ):
478
+ """
479
+ An immutable representation of a Gogs organization team
480
+ """
481
+ def __init__ (self , team_id , name , description , permission ):
482
+ self ._id = team_id
483
+ self ._name = name
484
+ self ._description = description
485
+ self ._permission = permission
537
486
538
- :rtype: int
539
- """
540
- return self ._id
487
+ @staticmethod
488
+ def from_json (parsed_json ):
489
+ team_id = json_get (parsed_json , "id" )
490
+ name = json_get (parsed_json , "name" )
491
+ description = json_get (parsed_json , "description" )
492
+ permission = json_get (parsed_json , "permission" )
493
+ return GogsTeam (team_id = team_id , name = name , description = description , permission = permission )
541
494
542
- @ property
543
- def name (self ):
544
- """
545
- Team name
495
+ @ property # named team_id to avoid conflict with built-in id
496
+ def team_id (self ):
497
+ """
498
+ Team's id
546
499
547
- :rtype: str
548
- """
549
- return self ._name
500
+ :rtype: int
501
+ """
502
+ return self ._id
550
503
551
- @property
552
- def description (self ):
553
- """
554
- Description to the team
504
+ @property
505
+ def name (self ):
506
+ """
507
+ Team name
555
508
556
- :rtype: str
557
- """
558
- return self ._description
509
+ :rtype: str
510
+ """
511
+ return self ._name
559
512
560
- @property
561
- def permission (self ):
562
- """
563
- Team permission, can be read, write or admin, default is read
513
+ @property
514
+ def description (self ):
515
+ """
516
+ Description of the team
564
517
565
- :rtype: int
566
- """
567
- return self ._permission
518
+ :rtype: str
519
+ """
520
+ return self ._description
568
521
522
+ @property
523
+ def permission (self ):
524
+ """
525
+ Team permission, can be read, write or admin, default is read
526
+
527
+ :rtype: int
528
+ """
529
+ return self ._permission
0 commit comments