u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [gitdm v2] reports.py: Add very basic rST output
@ 2022-07-12 21:14 Tom Rini
  2022-07-13 15:28 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rini @ 2022-07-12 21:14 UTC (permalink / raw)
  To: u-boot; +Cc: wd, Heinrich Schuchardt

Add a -R option to gitdm to allow for reStructuredText output and add
some very simple table generation.  We assume that whatever uses this
output will be including it in other documents and we only concern
ourselves with making tables.  Give ourselves 36 characters to fill in
the nae field, as this tends to be long enough and can be corrected
manually in the cases where it's slightly too short still.

Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
Changes in v2:
- Rework how we declare a table, per Heinrich
---
 gitdm      |  5 ++++-
 reports.py | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gitdm b/gitdm
index b837f0aafe27..3568d08f55af 100755
--- a/gitdm
+++ b/gitdm
@@ -59,6 +59,7 @@ FileReport = None
 # -D		Output date statistics
 # -f file	Write touched-files report to <file>
 # -h hfile	HTML output to hfile
+# -R rfile      reStructuredText output to rfile
 # -H file   Export individual developer raw data as CSV
 # -l count	Maximum length for output lists
 # -n        Use numstats instead of generated patch from git log
@@ -80,7 +81,7 @@ def ParseOpts():
     global ReportByFileType, ReportUnknowns, CompanyFilter, FileReport
     global HackersCSV
 
-    opts, rest = getopt.getopt(sys.argv[1:], 'ab:dC:c:Df:H:h:l:no:p:r:stUuwx:yz')
+    opts, rest = getopt.getopt(sys.argv[1:], 'ab:dC:c:Df:H:h:l:no:p:r:R:stUuwx:yz')
     for opt in opts:
         if opt[0] == '-a':
             AkpmOverLt = 1
@@ -111,6 +112,8 @@ def ParseOpts():
         elif opt[0] == '-r':
             print('Filter on "%s"' % (opt[1]))
             FileFilter = re.compile(opt[1])
+        elif opt[0] == '-R':
+            reports.SetrSTOutput(open(opt[1], 'w'))
         elif opt[0] == '-s':
             AuthorSOBs = 0
         elif opt[0] == '-t':
diff --git a/reports.py b/reports.py
index 39c237bdae00..782ebb8fb032 100644
--- a/reports.py
+++ b/reports.py
@@ -14,6 +14,7 @@ import sys
 
 Outfile = sys.stdout
 HTMLfile = None
+rSTfile = None
 ListCount = 999999
 
 
@@ -25,6 +26,10 @@ def SetHTMLOutput(file):
     global HTMLfile
     HTMLfile = file
 
+def SetrSTOutput(file):
+    global rSTfile
+    rSTfile = file
+
 def SetMaxList(max):
     global ListCount
     ListCount = max
@@ -40,10 +45,21 @@ THead = '''<p>
 <tr><th colspan=3>%s</th></tr>
 '''
 
+RHead = '''
+.. table:: %s
+   :widths: auto
+
+   ====================================  =====
+   Name                                  Count
+   ====================================  =====
+'''
+
 def BeginReport(title):
     Outfile.write('\n%s\n' % title)
     if HTMLfile:
         HTMLfile.write(THead % title)
+    if rSTfile:
+        rSTfile.write(RHead % title)
 
 TRow = ' <tr><td>%s</td><td align="right">%d</td><td align="right">%.1f%%</td></tr>\n'
 TRowStr = ' <tr><td>%s</td><td align="right">%d</td><td>%s</td></tr>\n'
@@ -54,6 +70,8 @@ def ReportLine(text, count, pct):
     Outfile.write ('%-25s %4d (%.1f%%)\n' % (text, count, pct))
     if HTMLfile:
         HTMLfile.write(TRow % (text, count, pct))
+    if rSTfile:
+        rSTfile.write("   %-36s  %d (%.1f%%)\n" % (text.strip(), count, pct))
 
 def ReportLineStr(text, count, extra):
     if count == 0:
@@ -61,10 +79,14 @@ def ReportLineStr(text, count, extra):
     Outfile.write ('%-25s %4d %s\n' % (text, count, extra))
     if HTMLfile:
         HTMLfile.write(TRowStr % (text, count, extra))
+    if rSTfile:
+        rSTfile.write('%-36s %d %s\n' % (text, count, extra))
 
 def EndReport():
     if HTMLfile:
         HTMLfile.write('</table>\n\n')
+    if rSTfile:
+        rSTfile.write('   ====================================  =====\n\n')
         
 #
 # Comparison and report generation functions.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gitdm v2] reports.py: Add very basic rST output
  2022-07-12 21:14 [gitdm v2] reports.py: Add very basic rST output Tom Rini
@ 2022-07-13 15:28 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2022-07-13 15:28 UTC (permalink / raw)
  To: Tom Rini; +Cc: U-Boot Mailing List, Wolfgang Denk, Heinrich Schuchardt

On Tue, 12 Jul 2022 at 15:14, Tom Rini <trini@konsulko.com> wrote:
>
> Add a -R option to gitdm to allow for reStructuredText output and add
> some very simple table generation.  We assume that whatever uses this
> output will be including it in other documents and we only concern
> ourselves with making tables.  Give ourselves 36 characters to fill in
> the nae field, as this tends to be long enough and can be corrected
> manually in the cases where it's slightly too short still.
>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
> Changes in v2:
> - Rework how we declare a table, per Heinrich
> ---
>  gitdm      |  5 ++++-
>  reports.py | 22 ++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-13 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 21:14 [gitdm v2] reports.py: Add very basic rST output Tom Rini
2022-07-13 15:28 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).