| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent de73ea7 commit 8224b40
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,12 +290,12 @@ def _compute_path(self, path: Optional[str] = None) -> Optional[str]: | |||
| 290 | 290 | path = self._path | |
| 291 | 291 | if path is None: | |
| 292 | 292 | return None | |
| 293 | - if self._parent is None or not hasattr(self, "_from_parent_attrs"): | ||
| 293 | + if self._parent is None or not self._from_parent_attrs: | ||
| 294 | 294 | return path | |
| 295 | 295 | ||
| 296 | 296 | data = { | |
| 297 | 297 | self_attr: getattr(self._parent, parent_attr, None) | |
| 298 | - for self_attr, parent_attr in self._from_parent_attrs.items() # type: ignore | ||
| 298 | + for self_attr, parent_attr in self._from_parent_attrs.items() | ||
| 299 | 299 | } | |
| 300 | 300 | self._parent_attrs = data | |
| 301 | 301 | return path % data | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,7 @@ def do_custom(self): | |||
| 69 | 69 | # Get the object (lazy), then act | |
| 70 | 70 | if in_obj: | |
| 71 | 71 | data = {} | |
| 72 | - if hasattr(self.mgr, "_from_parent_attrs"): | ||
| 72 | + if self.mgr._from_parent_attrs: | ||
| 73 | 73 | for k in self.mgr._from_parent_attrs: | |
| 74 | 74 | data[k] = self.args[k] | |
| 75 | 75 | if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.cls): | |
@@ -138,13 +138,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 138 | 138 | ||
| 139 | 139 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 140 | 140 | sub_parser_action.add_argument("--sudo", required=False) | |
| 141 | - if hasattr(mgr_cls, "_from_parent_attrs"): | ||
| 142 | - [ | ||
| 141 | + if mgr_cls._from_parent_attrs: | ||
| 142 | + for x in mgr_cls._from_parent_attrs: | ||
| 143 | 143 | sub_parser_action.add_argument( | |
| 144 | 144 | "--%s" % x.replace("_", "-"), required=True | |
| 145 | 145 | ) | |
| 146 | - for x in mgr_cls._from_parent_attrs | ||
| 147 | - ] | ||
| 148 | 146 | ||
| 149 | 147 | if action_name == "list": | |
| 150 | 148 | if hasattr(mgr_cls, "_list_filters"): | |
@@ -221,13 +219,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 221 | 219 | for action_name in cli.custom_actions[name]: | |
| 222 | 220 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 223 | 221 | # Get the attributes for URL/path construction | |
| 224 | - if hasattr(mgr_cls, "_from_parent_attrs"): | ||
| 225 | - [ | ||
| 222 | + if mgr_cls._from_parent_attrs: | ||
| 223 | + for x in mgr_cls._from_parent_attrs: | ||
| 226 | 224 | sub_parser_action.add_argument( | |
| 227 | 225 | "--%s" % x.replace("_", "-"), required=True | |
| 228 | 226 | ) | |
| 229 | - for x in mgr_cls._from_parent_attrs | ||
| 230 | - ] | ||
| 231 | 227 | sub_parser_action.add_argument("--sudo", required=False) | |
| 232 | 228 | ||
| 233 | 229 | # We need to get the object somehow | |
@@ -256,13 +252,11 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 256 | 252 | name = mgr_cls.__name__ | |
| 257 | 253 | for action_name in cli.custom_actions[name]: | |
| 258 | 254 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 259 | - if hasattr(mgr_cls, "_from_parent_attrs"): | ||
| 260 | - [ | ||
| 255 | + if mgr_cls._from_parent_attrs: | ||
| 256 | + for x in mgr_cls._from_parent_attrs: | ||
| 261 | 257 | sub_parser_action.add_argument( | |
| 262 | 258 | "--%s" % x.replace("_", "-"), required=True | |
| 263 | 259 | ) | |
| 264 | - for x in mgr_cls._from_parent_attrs | ||
| 265 | - ] | ||
| 266 | 260 | sub_parser_action.add_argument("--sudo", required=False) | |
| 267 | 261 | ||
| 268 | 262 | required, optional, dummy = cli.custom_actions[name][action_name] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments