Refactoring header style code in TableView
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Same or similar code is present in `table_view.TableView` create a function to avoid repetitions.
* `render_header()`
```python
class_name = getattr(self.model, elem).__class__.__name__
if elem in self.style_header and class_name == 'TextField':
# atm header style con be applied only to TextField
# type. ( and class_name == 'TextField )
style_name = self.style_header[elem]['style']
commands = self.style_header[elem]['commands']
my_style = Styles.style(style=style_name,
commands=commands)
new_row.append(getattr(self.model,
elem).render(style=my_style))
else:
new_row.append(getattr(self.model, elem).render())
```
* `render_inner_table()`
```python
class_name = getattr(self.model, elem).__class__.__name__
if elem in self.style_header and class_name == 'TextField':
# atm header style con be applied only to TextField
# type. ( and class_name == 'TextField )
style_name = self.style_header[elem]['style']
commands = self.style_header[elem]['commands']
my_style = Styles.style(style=style_name,
commands=commands)
compliant_data[sr][sc] = getattr(self.model, elem).render(style=my_style)
else:
compliant_data[sr][sc] = getattr(self.model, elem).render()
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at table_view.TableView and compare render_header() with render_inner_table(), using the repeated style and render logic shown in the issue as the scope. Extract the shared behavior so both methods use it while preserving their existing outputs; done means the duplication is removed without changing header or inner-table rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100