| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 417d27c commit fd45397
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,29 +30,37 @@ def _process_docstring(app, what, name, obj, options, lines): | |||
| 30 | 30 | class GitlabDocstring(GoogleDocstring): | |
| 31 | 31 | def _build_doc(self): | |
| 32 | 32 | cls = self._obj.obj_cls | |
| 33 | + opt_get_list = cls.optionalGetAttrs | ||
| 34 | + opt_list_list = cls.optionalListAttrs | ||
| 33 | 35 | md_create_list = list(itertools.chain(cls.requiredUrlAttrs, | |
| 34 | 36 | cls.requiredCreateAttrs)) | |
| 35 | 37 | opt_create_list = cls.optionalCreateAttrs | |
| 36 | 38 | ||
| 39 | + opt_get_keys = "None" | ||
| 40 | + if opt_get_list: | ||
| 41 | + opt_get_keys = ", ".join(['``%s``' % i for i in opt_get_list]) | ||
| 42 | + | ||
| 43 | + opt_list_keys = "None" | ||
| 44 | + if opt_list_list: | ||
| 45 | + opt_list_keys = ", ".join(['``%s``' % i for i in opt_list_list]) | ||
| 46 | + | ||
| 37 | 47 | md_create_keys = opt_create_keys = "None" | |
| 38 | 48 | if md_create_list: | |
| 39 | - md_create_keys = "%s" % ", ".join(['``%s``' % i for i in | ||
| 40 | - md_create_list]) | ||
| 49 | + md_create_keys = ", ".join(['``%s``' % i for i in md_create_list]) | ||
| 41 | 50 | if opt_create_list: | |
| 42 | - opt_create_keys = "%s" % ", ".join(['``%s``' % i for i in | ||
| 43 | - opt_create_list]) | ||
| 51 | + opt_create_keys = ", ".join(['``%s``' % i for i in | ||
| 52 | + opt_create_list]) | ||
| 44 | 53 | ||
| 45 | 54 | md_update_list = list(itertools.chain(cls.requiredUrlAttrs, | |
| 46 | 55 | cls.requiredUpdateAttrs)) | |
| 47 | 56 | opt_update_list = cls.optionalUpdateAttrs | |
| 48 | 57 | ||
| 49 | 58 | md_update_keys = opt_update_keys = "None" | |
| 50 | 59 | if md_update_list: | |
| 51 | - md_update_keys = "%s" % ", ".join(['``%s``' % i for i in | ||
| 52 | - md_update_list]) | ||
| 60 | + md_update_keys = ", ".join(['``%s``' % i for i in md_update_list]) | ||
| 53 | 61 | if opt_update_list: | |
| 54 | - opt_update_keys = "%s" % ", ".join(['``%s``' % i for i in | ||
| 55 | - opt_update_list]) | ||
| 62 | + opt_update_keys = ", ".join(['``%s``' % i for i in | ||
| 63 | + opt_update_list]) | ||
| 56 | 64 | ||
| 57 | 65 | tmpl_file = os.path.join(os.path.dirname(__file__), 'template.j2') | |
| 58 | 66 | with open(tmpl_file) as fd: | |
@@ -62,7 +70,9 @@ def _build_doc(self): | |||
| 62 | 70 | md_create_keys=md_create_keys, | |
| 63 | 71 | opt_create_keys=opt_create_keys, | |
| 64 | 72 | md_update_keys=md_update_keys, | |
| 65 | - opt_update_keys=opt_update_keys) | ||
| 73 | + opt_update_keys=opt_update_keys, | ||
| 74 | + opt_get_keys=opt_get_keys, | ||
| 75 | + opt_list_keys=opt_list_keys) | ||
| 66 | 76 | ||
| 67 | 77 | return output.split('\n') | |
| 68 | 78 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,3 +19,11 @@ Mandatory arguments for object update: {{ md_create_keys }} | |||
| 19 | 19 | ||
| 20 | 20 | Optional arguments for object update: {{ opt_create_keys }} | |
| 21 | 21 | {% endif %} | |
| 22 | + | ||
| 23 | + {% if cls.canList %} | ||
| 24 | + Optional arguments for object listing: {{ opt_list_keys }} | ||
| 25 | + {% endif %} | ||
| 26 | + | ||
| 27 | + {% if cls.canGet %} | ||
| 28 | + Optional arguments for object listing: {{ opt_get_keys }} | ||
| 29 | + {% endif %} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -313,7 +313,7 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 313 | 313 | sub_parser_action.add_argument("--page", required=False) | |
| 314 | 314 | sub_parser_action.add_argument("--per-page", required=False) | |
| 315 | 315 | ||
| 316 | - elif action_name in ["get", "delete"]: | ||
| 316 | + if action_name in ["get", "delete"]: | ||
| 317 | 317 | if cls not in [gitlab.CurrentUser]: | |
| 318 | 318 | if cls.getRequiresId: | |
| 319 | 319 | id_attr = cls.idAttr.replace('_', '-') | |
@@ -323,15 +323,25 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 323 | 323 | required=True) | |
| 324 | 324 | for x in cls.requiredGetAttrs if x != cls.idAttr] | |
| 325 | 325 | ||
| 326 | - elif action_name == "create": | ||
| 326 | + if action_name == "get": | ||
| 327 | + [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | ||
| 328 | + required=False) | ||
| 329 | + for x in cls.optionalGetAttrs] | ||
| 330 | + | ||
| 331 | + if action_name == "list": | ||
| 332 | + [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | ||
| 333 | + required=False) | ||
| 334 | + for x in cls.optionalListAttrs] | ||
| 335 | + | ||
| 336 | + if action_name == "create": | ||
| 327 | 337 | [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | |
| 328 | 338 | required=True) | |
| 329 | 339 | for x in cls.requiredCreateAttrs] | |
| 330 | 340 | [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | |
| 331 | 341 | required=False) | |
| 332 | 342 | for x in cls.optionalCreateAttrs] | |
| 333 | 343 | ||
| 334 | - elif action_name == "update": | ||
| 344 | + if action_name == "update": | ||
| 335 | 345 | id_attr = cls.idAttr.replace('_', '-') | |
| 336 | 346 | sub_parser_action.add_argument("--%s" % id_attr, | |
| 337 | 347 | required=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,6 +183,10 @@ class GitlabObject(object): | |||
| 183 | 183 | requiredUrlAttrs = [] | |
| 184 | 184 | #: Attributes that are required when retrieving list of objects. | |
| 185 | 185 | requiredListAttrs = [] | |
| 186 | + #: Attributes that are optional when retrieving list of objects. | ||
| 187 | + optionalListAttrs = [] | ||
| 188 | + #: Attributes that are optional when retrieving single object. | ||
| 189 | + optionalGetAttrs = [] | ||
| 186 | 190 | #: Attributes that are required when retrieving single object. | |
| 187 | 191 | requiredGetAttrs = [] | |
| 188 | 192 | #: Attributes that are required when deleting object. | |
@@ -754,6 +758,9 @@ class License(GitlabObject): | |||
| 754 | 758 | canCreate = False | |
| 755 | 759 | idAttr = 'key' | |
| 756 | 760 | ||
| 761 | + optionalListAttrs = ['popular'] | ||
| 762 | + optionalGetAttrs = ['project', 'fullname'] | ||
| 763 | + | ||
| 757 | 764 | ||
| 758 | 765 | class LicenseManager(BaseManager): | |
| 759 | 766 | obj_cls = License | |
| Back | FazBrowse Home | New Git URL |
0 commit comments