mirror of https://github.com/Nonannet/pelfy.git
column alignment for markdown output added
This commit is contained in:
parent
02460dcc43
commit
fd650d3dff
|
@ -51,7 +51,7 @@ elf.sections
|
||||||
elf.functions
|
elf.functions
|
||||||
```
|
```
|
||||||
| index | name | info | size | stb | description |
|
| index | name | info | size | stb | description |
|
||||||
|-------|--------------------|----------|-----:|------------|-------------------------|
|
|------:|--------------------|----------|-----:|------------|-------------------------|
|
||||||
| 11 | result_float | STT_FUNC | 8 | STB_GLOBAL | Symbol is a code object |
|
| 11 | result_float | STT_FUNC | 8 | STB_GLOBAL | Symbol is a code object |
|
||||||
| 12 | result_float_float | STT_FUNC | 12 | STB_GLOBAL | Symbol is a code object |
|
| 12 | result_float_float | STT_FUNC | 12 | STB_GLOBAL | Symbol is a code object |
|
||||||
| 13 | add_float_float | STT_FUNC | 12 | STB_GLOBAL | Symbol is a code object |
|
| 13 | add_float_float | STT_FUNC | 12 | STB_GLOBAL | Symbol is a code object |
|
||||||
|
@ -61,7 +61,7 @@ elf.functions
|
||||||
elf.symbols['read_float'].get_relocations()
|
elf.symbols['read_float'].get_relocations()
|
||||||
```
|
```
|
||||||
| index | symbol name | type | calculation |
|
| index | symbol name | type | calculation |
|
||||||
|-------|--------------------|----------------------|-------------|
|
|------:|--------------------|----------------------|-------------|
|
||||||
| 4 | .LANCHOR0 | R_RISCV_PCREL_HI20 | S + A - P |
|
| 4 | .LANCHOR0 | R_RISCV_PCREL_HI20 | S + A - P |
|
||||||
| 5 | | R_RISCV_RELAX | |
|
| 5 | | R_RISCV_RELAX | |
|
||||||
| 6 | .L0 | R_RISCV_PCREL_LO12_I | S - P |
|
| 6 | .L0 | R_RISCV_PCREL_LO12_I | S - P |
|
||||||
|
|
|
@ -302,6 +302,9 @@ class elf_list(Generic[_T]):
|
||||||
def _repr_html_(self) -> str:
|
def _repr_html_(self) -> str:
|
||||||
return self._repr_table('html')
|
return self._repr_table('html')
|
||||||
|
|
||||||
|
def _repr_markdown_(self) -> str:
|
||||||
|
return self._repr_table('markdown')
|
||||||
|
|
||||||
|
|
||||||
class section_list(elf_list[elf_section]):
|
class section_list(elf_list[elf_section]):
|
||||||
"""A class for representing a list of ELF section
|
"""A class for representing a list of ELF section
|
||||||
|
|
|
@ -11,7 +11,7 @@ def generate_table(data: list[list[Any]], columns: list[str],
|
||||||
elif format == 'markdown':
|
elif format == 'markdown':
|
||||||
return generate_md_table(data, columns, right_adj_col)
|
return generate_md_table(data, columns, right_adj_col)
|
||||||
else:
|
else:
|
||||||
return generate_md_table(data, columns, right_adj_col).replace('|', '')
|
return generate_md_table(data, columns, right_adj_col).replace('|', '').replace(':', '-')
|
||||||
|
|
||||||
|
|
||||||
def generate_md_table(data: list[list[Any]], columns: list[str], right_adj_col: list[str] = []) -> str:
|
def generate_md_table(data: list[list[Any]], columns: list[str], right_adj_col: list[str] = []) -> str:
|
||||||
|
@ -22,7 +22,7 @@ def generate_md_table(data: list[list[Any]], columns: list[str], right_adj_col:
|
||||||
formatted_row = ' | '.join(f"{str(item):<{column_widths[i]}}" for i, item in enumerate(columns))
|
formatted_row = ' | '.join(f"{str(item):<{column_widths[i]}}" for i, item in enumerate(columns))
|
||||||
table += '| ' + formatted_row + ' |\n'
|
table += '| ' + formatted_row + ' |\n'
|
||||||
|
|
||||||
table += '|-' + '-|-'.join('-' * width for width in column_widths) + '-|\n'
|
table += '|' + '|'.join('-' * width + '-:' if c in right_adj_col else ':-' + '-' * width for width, c in zip(column_widths, columns)) + '|\n'
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
formatted_row = ''
|
formatted_row = ''
|
||||||
|
|
Loading…
Reference in New Issue