X-Git-Url: http://git.tpope.net/?p=tpope-extra.git;a=blobdiff_plain;f=perl%2Fsct6;h=01767610a3bdb6fcc7d4b009215f68bab869ad6e;hp=f8a539a16a051fbd6f28c1db21868beea97c82a1;hb=5670812ab058f2a364bd0d690fd4ed4e3e3d3dc6;hpb=d0e0875970a27f0a7926b249ddfca9e61de4e18a diff --git a/perl/sct6 b/perl/sct6 index f8a539a..0176761 100755 --- a/perl/sct6 +++ b/perl/sct6 @@ -6,6 +6,9 @@ # Create a ~/.sct6rc that has SID=yourssn and PIN=yourpin # You'll need to change the url below if you go anywhere but TAMUK. +# Update: This tool now only outputs in XML. For other formats, convert +# with schedproc + use strict; use Date::Calc::Object qw(Day_of_Week Decode_Day_of_Week Decode_Month Week_of_Year Monday_of_Week Day_of_Week_Abbreviation Delta_Days Add_Delta_Days Nth_Weekday_of_Month_Year Gmtime Mktime); use Date::Calendar::Profiles qw($Profiles); @@ -380,67 +383,12 @@ sub do_html_schedule { print "\n"; } -sub do_html_grades { - my @readheaders = ("Section ID", "Course Title", "Grade", "Earned Hours", "Quality Hours", "Quality Points", "GPA"); - @readheaders = ("Section", "Course Title", "FinalGrade", "Earned Hours", "Quality Hours", "Quality Points", "GPA") if($opts{'school'} eq 'tamuk'); - my @showheaders = ("Section ID", "Course Title", "Grade", "EarnedHours", "QualityHours", "QualityPoints"); - my ($row, $lastrow); - my $shade = "dark"; - my $te = new HTML::TableExtract( headers => [ @readheaders ] ); - my $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=rgrdterm.cfg"); # Valid grading terms - die $response->status_line unless $response->is_success; - #my @terms = reverse grep {s/^.*/$1/} (split( /\r\n/, $response->content)); - my @terms = (); - my $year = Date::Calc->localtime->year; - for(my $y=$year-4;$y<=$year;$y++) { push @terms, ($y.2,$y."F",$y.3,$y.4,$y.1,$y."S"); } - foreach(@_ ? @_ : @terms) { - $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=rgrades.cfg&Term=".($_) ); - die $response->status_line unless $response->is_success; - $te->parse($response->content); - } - print ''."\n"; - print '', $showheaders[0]; - print '', $showheaders[1]; - print ''; - print join('',@showheaders[2 .. 5]); - print "\n"; - foreach my $ts ($te->table_states) { - foreach my $row ($ts->rows) { - map { s/^\s+//; s/\xa0|\r//g; s/\n//g; $_} @$row; - $row->[1] = capitalize($row->[1]); - $row->[1] =~ s/&/&/g; - $row->[0] =~ s/Cumulative through/Cumulative: through/; - $row->[0] =~ s/Cumulative:(.*) (\d{4}) (.*)/Cumulative:$1 $3 $2/; - $lastrow=$row; - next if $row->[0] =~ /:|Current Term/; - print ''; - $shade = ($shade eq "dark"?"light":"dark"); - print '', $$row[0], ''; - print '', $$row[1], ''; - print ''; - #print join('', @$row[0 .. 1]); - print join('', @$row[2 .. 5]); - print "\n"; - } - } - print '', capitalize($lastrow->[0]); - #shift @$lastrow; shift @$lastrow; - print ''; - print $$lastrow[6]; - print ''; - print join('', @$lastrow[3 .. 5]); - print "\n"; - print "\n"; +sub do_xml_grades { + print "\n\n"; } sub do_transcripts { - $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN&tserve_trans_config=rtranscr.cfg&CareerReqNum=1"); - foreach (split /\n/, $response->content) { - next unless s/^\ |// || s/\ / /; - s/<\/?([Hh]\d|[Bb])>//g; - next if /<\/td>/; - print "$_\n"; - } + print "Not implemented.\n"; } if ($arg eq "-s" || $arg eq "-h") { @@ -452,10 +400,8 @@ if ($arg eq "-s" || $arg eq "-h") { } elsif ($arg eq "-v") { do_vcalendar_schedule(@ARGV); } elsif ($arg eq "-g") { - die "Grade support currently broken.\n"; - do_html_grades(@ARGV); + do_xml_grades(@ARGV); } elsif ($arg eq "-t") { - die "Transcript support currently broken.\n"; do_transcripts; } elsif ($arg eq "-x" || 1) { do_xml_schedule(@ARGV);
// || s/\ / /; - s/<\/?([Hh]\d|[Bb])>//g; - next if /<\/td>/; - print "$_\n"; - } + print "Not implemented.\n"; } if ($arg eq "-s" || $arg eq "-h") { @@ -452,10 +400,8 @@ if ($arg eq "-s" || $arg eq "-h") { } elsif ($arg eq "-v") { do_vcalendar_schedule(@ARGV); } elsif ($arg eq "-g") { - die "Grade support currently broken.\n"; - do_html_grades(@ARGV); + do_xml_grades(@ARGV); } elsif ($arg eq "-t") { - die "Transcript support currently broken.\n"; do_transcripts; } elsif ($arg eq "-x" || 1) { do_xml_schedule(@ARGV);