Began pretty-print script.

This commit is contained in:
Jonathan Bernard 2009-06-23 18:43:38 -05:00
parent 1ff581d4a5
commit 04c4a2b6ac
6 changed files with 141 additions and 33 deletions

View File

@ -1,12 +0,0 @@
#!/bin/sh
./clean_trailing_whitespace.sh build.xml
./clean_trailing_whitespace.sh timestamper.config
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.java
./clean_trailing_whitespace.sh src/jdbernard/timestamper/*.form
./clean_trailing_whitespace.sh src/jdbernard/timestamper/resources/*.properties
./clean_trailing_whitespace.sh nbproject/*.xml
./clean_trailing_whitespace.sh nbproject/project.*
./clean_trailing_whitespace.sh nbproject/*.properties
./clean_trailing_whitespace.sh nbproject/configs/*.properties
./clean_trailing_whitespace.sh nbproject/private/private.*

View File

@ -1,9 +0,0 @@
#!/bin/bash
perl -pi -e 's/[\t\r\f ]+$//g' $@
for file in $@
do
rm "$file.bak"
echo "$file done!"
done

View File

@ -1,7 +1,7 @@
do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
jaxws.endorsed.dir=C:\\Program Files\\NetBeans 6.1\\java2\\modules\\ext\\jaxws21\\api
user.properties.file=C:\\Documents and Settings\\jbernard\\.netbeans\\6.1\\build.properties
axis2.deploy.war=C:\\Program Files\\glassfish-v2ur2\\domains\\domain1\\autodeploy\\axis2.war
do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
jaxws.endorsed.dir=C:\\Program Files\\NetBeans 6.5\\java2\\modules\\ext\\jaxws21\\api:C:\\Program Files\\NetBeans 6.5\\ide10\\modules\\ext\\jaxb\\api
user.properties.file=C:\\Documents and Settings\\jbernard\\.netbeans\\6.5\\build.properties
axis2.deploy.war=C:\\Program Files\\glassfish-v2ur2\\domains\\domain1\\autodeploy\\axis2.war

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>

View File

@ -0,0 +1,95 @@
#!/usr/bin/env groovy
import java.io.BufferedWriter
import java.io.FileInputStream
import java.io.FileWriter
import java.io.OutputStreamWriter
import java.util.Calendar
import java.util.Date
import java.text.SimpleDateFormat
//import jdbernard.timestamper.Timeline
SimpleDateFormat paramDateFormat = new SimpleDateFormat("yyyy-MM-dd")
def cl = new CliBuilder(usage: 'pretty_format.groovy [-i input_file] [-o output_file] [OPTIONS]')
cl.h(argName: 'help', 'Show usage information.')
cl.i(argName: 'input_file', longOpt: 'input-file', args: 1, 'Input timeline file (if not present, read from STDIN)')
cl.o(argName: 'output_file', longOpt: 'output-file', args: 1, 'File to write formatted output to (if not present, output is written to STOUT).')
cl.s(argName: 'start_date', longOpt: 'start-date', args: 1, 'Exclude all entries before this date (YYYY-MM-DD).')
cl.e(argName: 'end_date', longOpt: 'end-date', args: 1, 'Exclude all entries after this date (YYYY-MM-DD).')
cl.p(argName: 'entry_period', longOpt: 'period', args: 1, 'Shorthand notation for the period of entries to include in the output file. The format '
+ 'takes the following format: MUN where M = number of units between current time and start time, N = number of units between start time and '
+ 'end time, and U = time unit. Valid values for U are: D - day, W - week, M - month, and Y - year. For example: 0W1 means this week '
+ 'and the next. 2D5 means a five day period, starting two days from today. -1Y1 means last year, this year, and the next year.')
def opt = cl.parse(args)
if (!opt) System.exit(1);
is = System.in;
os = new BufferedWriter(new OutputStreamWriter(System.out));
start = false;
end = false;
if (opt.i) is = new FileInputStream(opt.i);
if (opt.o) os = new BufferedWriter(new FileWriter(opt.o));
if (opt.s) start = paramDateFormat.parse(opt.s);
if (opt.e) end = paramDateFormat.parse(opt.e);
if (opt.p) {
int offset
def unit
def lower_unit
int length
(opt.p =~ /([\-n]?)(\d+)([dwmyDWMY])(\d+)/).each { all, nx, x, y, z ->
offset = x.toInteger(); unit = y; length = z.toInteger() - 1;
if (nx) offset = -offset;
}
start = Calendar.getInstance()
start.set(Calendar.HOUR_OF_DAY, start.getMinimum(Calendar.HOUR_OF_DAY));
start.set(Calendar.MINUTE, start.getMinimum(Calendar.MINUTE));
start.set(Calendar.SECOND, start.getMinimum(Calendar.SECOND));
end = Calendar.getInstance()
end.set(Calendar.HOUR_OF_DAY, end.getMaximum(Calendar.HOUR_OF_DAY));
end.set(Calendar.MINUTE, end.getMaximum(Calendar.MINUTE));
end.set(Calendar.SECOND, end.getMaximum(Calendar.SECOND));
switch (unit) {
case 'd': case 'D': default:
unit = Calendar.DAY_OF_YEAR
lower_unit = Calendar.HOUR_OF_DAY
break
case 'w': case 'W':
unit = Calendar.WEEK_OF_YEAR
lower_unit = Calendar.DAY_OF_WEEK
break
case 'm': case 'M':
unit = Calendar.MONTH
lower_unit = Calendar.DAY_OF_MONTH
break
case 'y': case 'Y':
unit = Calendar.YEAR
lower_unit = Calendar.DAY_OF_YEAR
break
}
start.add(unit, offset)
start.set(lower_unit, start.getActualMinimum(lower_unit))
end.setTime(start.getTime())
end.add(unit, length)
end.set(lower_unit, end.getActualMaximum(lower_unit))
start = start.getTime()
end = end.getTime()
}
//Timeline timeline = Timeline.readFromStream(is);
print "Start: ${paramDateFormat.format(start)}\n"
print "End: ${paramDateFormat.format(end)}\n"

View File

@ -1 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?><TodoList name="TimeStamper Todo List"><Description>Features, bugfixes, things that need to be done.</Description><Owner>TimeStamper Development</Owner><TaskList name="unallocated"><Task created="20081023170946" name="WeekTimelineDisplay" priority="0"><Description>Create a display that shows a full week.</Description></Task><Task created="20081023171011" name="MonthTimelineDisplay" priority="0"><Description>Show a full month.</Description></Task><Task allocated="20081029175454" created="20081029180059" name="Add GUI Action Controlsto DayTimelineDisplay" priority="1"><Description>Allow the GUI actions of the component to be enabled/disabled programatically. For example, add setZoomAllowed(boolean allowed) function to enable/disable the ability to zoom with the mouse.</Description></Task></TaskList><TaskList name="old"><Task allocated="20081023170513" created="20081023221630" finished="20081023235630" name="Auto-scale DatyTimelineDisplay Time Scale" priority="1"><Description/></Task><Task allocated="20081023170513" created="20081023235727" finished="20081023235730" name="Click and Drag Scroll On the DayTimelineDisplay" priority="1"><Description>The user is able to click and drag on the timeline displayed and the timeline follows the mouse.</Description></Task><Task allocated="20081023170513" created="20081023193554" finished="20081023193602" name="Deselect markers in DayTimelineDisplay" priority="1"><Description>Allow the user to select no marker in the DayTimelineDisplay by clicking in a region of the display that is not covered by an activity.</Description></Task><Task allocated="20081023170513" created="20081023170924" finished="20081023221612" name="Zoom for DayTimelineDisplay" priority="1"><Description>When the user clicks and drags, the ui should zoom to the region the user covered in the vertical access. For example, if the display shows a full day and the user clicks in 9:00 and drags to 13:00, the ui should refresh to put 9:00 at the top, 13:00 at the bottom, and re-scale the rest in between.</Description></Task></TaskList><TaskList name="current"><Task allocated="20081029175454" created="20081024010642" finished="20081029175523" name="Update All Displays When One Changes" priority="1"><Description>When you make changes to the DayTimelineDisplay, for example, those changes need to be propogated through the tool back to the main display.</Description></Task></TaskList></TodoList>
<?xml version="1.0" encoding="UTF-8"?>
<TodoList name="TimeStamper Todo List">
<Description>Features, bugfixes, things that need to be done.</Description>
<Owner>TimeStamper Development</Owner>
<TaskList name="unallocated">
<Task created="20081023170946" name="WeekTimelineDisplay" priority="0">
<Description>Create a display that shows a full week.</Description>
</Task>
<Task created="20081023171011" name="MonthTimelineDisplay" priority="0">
<Description>Show a full month.</Description>
</Task>
<Task allocated="20081029175454" created="20081029180059" name="Add GUI Action Controlsto DayTimelineDisplay" priority="1">
<Description>Allow the GUI actions of the component to be enabled/disabled programatically. For example, add setZoomAllowed(boolean allowed) function to enable/disable the ability to zoom with the mouse.</Description>
</Task>
</TaskList>
<TaskList name="old">
<Task allocated="20081023170513" created="20081023221630" finished="20081023235630" name="Auto-scale DatyTimelineDisplay Time Scale" priority="1">
<Description/>
</Task>
<Task allocated="20081023170513" created="20081023235727" finished="20081023235730" name="Click and Drag Scroll On the DayTimelineDisplay" priority="1">
<Description>The user is able to click and drag on the timeline displayed and the timeline follows the mouse.</Description>
</Task>
<Task allocated="20081023170513" created="20081023193554" finished="20081023193602" name="Deselect markers in DayTimelineDisplay" priority="1">
<Description>Allow the user to select no marker in the DayTimelineDisplay by clicking in a region of the display that is not covered by an activity.</Description>
</Task>
<Task allocated="20081023170513" created="20081023170924" finished="20081023221612" name="Zoom for DayTimelineDisplay" priority="1">
<Description>When the user clicks and drags, the ui should zoom to the region the user covered in the vertical access. For example, if the display shows a full day and the user clicks in 9:00 and drags to 13:00, the ui should refresh to put 9:00 at the top, 13:00 at the bottom, and re-scale the rest in between.</Description>
</Task>
</TaskList>
<TaskList name="current">
<Task allocated="20081029175454" created="20081024010642" finished="20081029175523" name="Update All Displays When One Changes" priority="1">
<Description>When you make changes to the DayTimelineDisplay, for example, those changes need to be propogated through the tool back to the main display.</Description>
</Task>
</TaskList>
</TodoList>