summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-06-23 16:07:53 +0000
committerKarl Berry <karl@freefriends.org>2015-06-23 16:07:53 +0000
commitc4d53b195d165e5e3b159ce5610dc66098eae735 (patch)
tree123e7dff9b0549310347b4965e3cc6c5a53a36a4
parent6e371df749819c2568786e88698c270894631674 (diff)
diadia bin
git-svn-id: svn://tug.org/texlive/trunk@37645 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/texlive/linked_scripts/Makefile.am1
-rw-r--r--Build/source/texk/texlive/linked_scripts/Makefile.in1
-rw-r--r--Build/source/texk/texlive/linked_scripts/diadia/diadia.lua298
-rw-r--r--Build/source/texk/texlive/linked_scripts/scripts.lst1
l---------Master/bin/alpha-linux/diadia1
l---------Master/bin/amd64-freebsd/diadia1
l---------Master/bin/amd64-netbsd/diadia1
l---------Master/bin/armel-linux/diadia1
l---------Master/bin/armhf-linux/diadia1
l---------Master/bin/i386-cygwin/diadia1
l---------Master/bin/i386-freebsd/diadia1
l---------Master/bin/i386-linux/diadia1
l---------Master/bin/i386-netbsd/diadia1
l---------Master/bin/i386-solaris/diadia1
l---------Master/bin/mipsel-linux/diadia1
l---------Master/bin/powerpc-linux/diadia1
l---------Master/bin/sparc-solaris/diadia1
l---------Master/bin/universal-darwin/diadia1
-rwxr-xr-xMaster/bin/win32/diadia.exebin0 -> 1536 bytes
l---------Master/bin/x86_64-cygwin/diadia1
l---------Master/bin/x86_64-darwin/diadia1
l---------Master/bin/x86_64-linux/diadia1
l---------Master/bin/x86_64-solaris/diadia1
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/diadia.tlpsrc1
25 files changed, 321 insertions, 0 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am
index f07382c7187..c2f28b67c1a 100644
--- a/Build/source/texk/texlive/linked_scripts/Makefile.am
+++ b/Build/source/texk/texlive/linked_scripts/Makefile.am
@@ -97,6 +97,7 @@ texmf_other_scripts = \
ctanify/ctanify \
ctanupload/ctanupload.pl \
de-macro/de-macro \
+ diadia/diadia.lua \
dosepsbin/dosepsbin.pl \
dviasm/dviasm.py \
ebong/ebong.py \
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in
index 17722f20426..ee7a773b90f 100644
--- a/Build/source/texk/texlive/linked_scripts/Makefile.in
+++ b/Build/source/texk/texlive/linked_scripts/Makefile.in
@@ -313,6 +313,7 @@ texmf_other_scripts = \
ctanify/ctanify \
ctanupload/ctanupload.pl \
de-macro/de-macro \
+ diadia/diadia.lua \
dosepsbin/dosepsbin.pl \
dviasm/dviasm.py \
ebong/ebong.py \
diff --git a/Build/source/texk/texlive/linked_scripts/diadia/diadia.lua b/Build/source/texk/texlive/linked_scripts/diadia/diadia.lua
new file mode 100644
index 00000000000..81d668499e7
--- /dev/null
+++ b/Build/source/texk/texlive/linked_scripts/diadia/diadia.lua
@@ -0,0 +1,298 @@
+#!/usr/bin/env texlua
+--
+-- diadia [options]
+--
+-- loads and processes a diadia data file
+--
+-- License: LPPL
+--
+local version = "v1.0 (2015/05/15)"
+
+local infile = ""
+local outfile = ""
+local mode = "*"
+local startdate = ""
+local enddate = ""
+local columns = ""
+local data = {}
+function pversion()
+ print("diadia.lua " .. version)
+ print("(C) Josef Kleber 2015 License: LPPL")
+ os.exit(0)
+end
+function phelp()
+ print([[
+diadia.lua [options]
+
+ allows you to
+
+ - cut a chunk out of the data file
+ e.g.: -i in.dat -o out.dat -s YYYY-MM-DD -e YYYY-MM-DD
+
+ - compose a new data file based on given columns of an
+ existing data file
+ e.g.: -i in.dat -o out.dat -c 1,2
+
+ - create a new data file with date and value (1st and
+ 2nd column of existing file) and added value average
+ columns of the last 7, 14, 30, 60 and 90 days
+ e.g.: -i in.dat -o out.dat [-s YYYY-MM-DD -e YYYY-MM-DD]
+
+ Options:
+
+ -m specify the mode (cut|compose|average)
+
+ -i specify the input file
+
+ -o specify the output file
+
+ -c specify the columns for compose mode
+
+ -s specify the start date (YYYY-MM-DD) in
+ cut and average mode
+
+ -e specify the end date
+
+ -v prints version information
+
+ -h prints help information
+
+]])
+ pversion()
+end
+function check_date(date)
+ if string.find(date, "(%d%d%d%d)-(%d%d)-(%d%d)") == nil
+ then
+ io.stderr:write ("Error 21: wrong date format (YYYY-MM-DD)\n")
+ os.exit(11)
+ end
+end
+function parse_date(date)
+ return string.match(date, "(%d%d%d%d)%-(%d%d)%-(%d%d)")
+end
+function parse_dateinline(line)
+ return string.match(line, "(%d%d%d%d%-%d%d%-%d%d)")
+end
+function daystring(unixtime)
+ return os.date("%Y-%m-%d", unixtime)
+end
+function unixtime(year,month,day)
+ return os.time{year=year, month=month, day=day}
+end
+function round(number)
+ return math.floor(number+0.5)
+end
+function ptd(value)
+ local val = tostring(value)
+ local slen = string.len(val)
+ if slen == 3
+ then
+ return val
+ else
+ return val .. " "
+ end
+end
+function calc_avg(data,date,days)
+ local sum = 0
+ local wdays = 0
+ local wday
+ local endday = unixtime(parse_date(date))
+ local startday = endday - 60*60*24*(days-1)
+ while startday <= endday
+ do
+ wday = daystring(startday)
+ if data[wday] ~= nil
+ then
+ sum = sum + data[wday]
+ wdays = wdays + 1
+ end
+ startday = startday + 60*60*24
+ end
+ if wdays == 0
+ then
+ return "nan"
+ else
+ return tostring(round(sum/wdays))
+ end
+end
+function read_data(file)
+ local data = {}
+ local date
+ local startdate
+ local enddate
+ local dat
+ local firstline = true
+ for line in io.lines(file)
+ do
+ if string.match(line, "date")
+ then
+ else
+ date, dat = string.match(line, "(%d%d%d%d%-%d%d%-%d%d)%s+(%S+)")
+ if firstline == true
+ then
+ startdate = date
+ firstline = false
+ end
+ if dat ~= "nan" and dat ~= "{}" and dat ~= ""
+ then
+ data[date] = dat
+ end
+ end
+ end
+ enddate = date
+ return data,startdate,enddate
+end
+function write_avg_file(data,file,startdate,enddate)
+ local sdate
+ local edate
+ local wday
+ sdate = unixtime(parse_date(startdate))
+ edate = unixtime(parse_date(enddate))
+ outfile = assert(io.open(file, "w"))
+ outfile:write("date value avg07 avg14 avg30 avg60 avg90")
+ while sdate <= edate+7200
+ do
+ wday = daystring(sdate)
+ if data[wday] ~= nil
+ then
+ outfile:write("\n" .. wday .. " "
+ .. ptd(data[wday]) .. " "
+ .. ptd(calc_avg(data,wday,7)) .. " "
+ .. ptd(calc_avg(data,wday,14)) .. " "
+ .. ptd(calc_avg(data,wday,30)) .. " "
+ .. ptd(calc_avg(data,wday,60)) .. " "
+ .. ptd(calc_avg(data,wday,90)))
+ end
+ sdate = sdate + 60*60*24
+ end
+ outfile:close()
+end
+do
+ local newarg = {}
+ local i, limit = 1, #arg
+ while (i <= limit) do
+ if arg[i] == "-i" then
+ infile = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-o" then
+ outfile = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-s" then
+ startdate = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-e" then
+ enddate = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-c" then
+ columns = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-m" then
+ mode = arg[i+1]
+ i = i + 1
+ elseif arg[i] == "-v" then
+ pversion()
+ elseif arg[i] == "-h" then
+ phelp()
+ else
+ newarg[#newarg+1] = arg[i]
+ end
+ i = i + 1
+ end
+ arg = newarg
+end
+if mode == "average"
+then
+ local startd
+ local endd
+
+ print("set mode to " .. mode)
+ print("reading data file " .. infile)
+ data,startd,endd = read_data(infile)
+ if startdate ~= ""
+ then
+ startd = startdate
+ end
+ if enddate ~= ""
+ then
+ endd = enddate
+ end
+ print("writing data file " .. outfile)
+ write_avg_file(data,outfile,startd,endd)
+ os.exit(0)
+end
+if mode == "compose"
+then
+ local row = 0
+ local column = 0
+ local ofile
+ local cols
+
+ print("set mode to " .. mode)
+ print("reading data file " .. infile)
+ for line in io.lines(infile)
+ do
+ row = row + 1
+ data[row] = {}
+ column = 0
+ for value in string.gmatch(line, "%S+")
+ do
+ column = column + 1
+ data[row][column] = value
+ end
+ end
+ cols = assert(load("return table.concat({"..columns:gsub("%d+","(...)[%0]").."},' ')"))
+ ofile = assert(io.open(outfile, "w"))
+ print("writing data file " .. outfile)
+ for irow = 1,row
+ do
+ if irow == row
+ then
+ ofile:write(cols(data[irow]))
+ else
+ ofile:write(cols(data[irow]).."\n")
+ end
+ end
+ ofile:close()
+ os.exit(0)
+end
+if mode == "cut"
+then
+ local ofile
+ local date
+ local sdate
+ local edate
+ local cdate
+
+ check_date(startdate)
+ check_date(enddate)
+ sdate = unixtime(parse_date(startdate))
+ edate = unixtime(parse_date(enddate))
+ print("set mode to " .. mode)
+ print("reading data file " .. infile)
+ print("writing data file " .. outfile)
+ ofile = assert(io.open(outfile, "w"))
+ for line in io.lines(infile)
+ do
+ if string.match(line, "date")
+ then
+ ofile:write(line)
+ else
+ date = parse_dateinline(line)
+ cdate = unixtime(parse_date(date))
+ if cdate >= sdate and cdate <= edate
+ then
+ ofile:write("\n" .. line)
+ end
+ end
+ end
+ ofile:close()
+ os.exit(0)
+end
+if mode == "*"
+then
+ io.stderr:write ("Error 11: no mode specified!")
+ os.exit(11)
+else
+ io.stderr:write ("Error 12: invalid mode " .. mode)
+ os.exit(12)
+end
diff --git a/Build/source/texk/texlive/linked_scripts/scripts.lst b/Build/source/texk/texlive/linked_scripts/scripts.lst
index af3198fe9a8..1e65a7e61be 100644
--- a/Build/source/texk/texlive/linked_scripts/scripts.lst
+++ b/Build/source/texk/texlive/linked_scripts/scripts.lst
@@ -43,6 +43,7 @@ crossrefware/ltx2crossrefxml.pl
ctanify/ctanify
ctanupload/ctanupload.pl
de-macro/de-macro
+diadia/diadia.lua
dosepsbin/dosepsbin.pl
dviasm/dviasm.py
ebong/ebong.py
diff --git a/Master/bin/alpha-linux/diadia b/Master/bin/alpha-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/alpha-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/amd64-freebsd/diadia b/Master/bin/amd64-freebsd/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/amd64-freebsd/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/amd64-netbsd/diadia b/Master/bin/amd64-netbsd/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/amd64-netbsd/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/armel-linux/diadia b/Master/bin/armel-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/armel-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/armhf-linux/diadia b/Master/bin/armhf-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/armhf-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/i386-cygwin/diadia b/Master/bin/i386-cygwin/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/i386-cygwin/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/i386-freebsd/diadia b/Master/bin/i386-freebsd/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/i386-freebsd/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/i386-linux/diadia b/Master/bin/i386-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/i386-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/i386-netbsd/diadia b/Master/bin/i386-netbsd/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/i386-netbsd/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/i386-solaris/diadia b/Master/bin/i386-solaris/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/i386-solaris/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/mipsel-linux/diadia b/Master/bin/mipsel-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/mipsel-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/powerpc-linux/diadia b/Master/bin/powerpc-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/powerpc-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/sparc-solaris/diadia b/Master/bin/sparc-solaris/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/sparc-solaris/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/universal-darwin/diadia b/Master/bin/universal-darwin/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/universal-darwin/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/win32/diadia.exe b/Master/bin/win32/diadia.exe
new file mode 100755
index 00000000000..5777d90a17a
--- /dev/null
+++ b/Master/bin/win32/diadia.exe
Binary files differ
diff --git a/Master/bin/x86_64-cygwin/diadia b/Master/bin/x86_64-cygwin/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/x86_64-cygwin/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/x86_64-darwin/diadia b/Master/bin/x86_64-darwin/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/x86_64-darwin/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/x86_64-linux/diadia b/Master/bin/x86_64-linux/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/x86_64-linux/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/bin/x86_64-solaris/diadia b/Master/bin/x86_64-solaris/diadia
new file mode 120000
index 00000000000..ab6014de87b
--- /dev/null
+++ b/Master/bin/x86_64-solaris/diadia
@@ -0,0 +1 @@
+../../texmf-dist/scripts/diadia/diadia.lua \ No newline at end of file
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 7d86b438ff2..0a9819c008a 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -2603,6 +2603,7 @@ $standardttf = '\.ttf|\.TTC';
'ctanify' => '^ctanify$',
'ctanupload' => '\.pl$',
'de-macro' => 'de-macro',
+ 'diadia' => '\.lua$',
'dosepsbin' => 'dosepsbin\.pl$',
'dtxgen' => 'dtxgen$',
'dviasm' => '\.py$',
diff --git a/Master/tlpkg/tlpsrc/diadia.tlpsrc b/Master/tlpkg/tlpsrc/diadia.tlpsrc
index e69de29bb2d..dca338c719c 100644
--- a/Master/tlpkg/tlpsrc/diadia.tlpsrc
+++ b/Master/tlpkg/tlpsrc/diadia.tlpsrc
@@ -0,0 +1 @@
+binpattern f bin/${ARCH}/${PKGNAME}