Update of /cvsroot/pure-data/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25343
Modified Files:
parse-help-patches.pl
Log Message:
final tweaks after first test, and yes, this script got even uglier
Index: parse-help-patches.pl
===================================================================
RCS file: /cvsroot/pure-data/scripts/parse-help-patches.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** parse-help-patches.pl 29 Sep 2007 21:40:24 -0000 1.1
--- parse-help-patches.pl 30 Sep 2007 20:51:16 -0000 1.2
***************
*** 5,8 ****
--- 5,9 ----
use strict;
use warnings;
+ use Text::CSV_PP;
my $line = "";
***************
*** 13,16 ****
--- 14,18 ----
my $printText = "";
+ my %classnames = ();
my %xyhash = ();
***************
*** 18,79 ****
my $name = "";
my $fileName = "";
-
#------------------------------------------------------------------------------#
# THE OUTPUT FORMAT
#------------------------------------------------------------------------------#
format OBJECTCLASS =
- {{Infobox Objectclass
- | name = ^*
- $name
- | library = ^*
- $library
- | author = {{^* author}}
- $library
- | status = {{^* status}}
- $library
- | website = {{^* website}}
- $library
- | release date = {{^* release date}}
- $library
- | license = {{^* license}}
- $library
- | platform = [[GNU/Linux]], [[Mac OS X]], [[Windows]]
- | language = English
- | distributions = {{^* distributions}}
- $library
- }}
- @*
- $printText
==Inlets==
==Outlets==
==Arguments==
==Messages==
{{objectclass-stub}}
[[Category:objectclass]]
- [[Category:^*]
- $library
.
#------------------------------------------------------------------------------#
! # THE PROGRAM
#------------------------------------------------------------------------------#
! foreach (`/sw/bin/find /Applications/Pd-extended.app/Contents/Resources/doc/5.reference/ -type f -name '*.pd'`) {
chop;
$fileName = "";
! if (m|.*/doc/5\.reference/([a-zA-Z0-9_-]+)/(.+)-help\.pd|) {
! print("library: $1 name: $2\n");
$library = lc($1);
$name = $2;
$fileName = $_;
! } elsif (m|.*/doc/5\.reference/([a-zA-Z0-9_-]+)/(.+)\.pd|) {
! print("library: $1 name: $2 \t\t(no -help)\n");
$library = lc($1);
$name = $2;
--- 20,86 ----
my $name = "";
my $fileName = "";
#------------------------------------------------------------------------------#
# THE OUTPUT FORMAT
#------------------------------------------------------------------------------#
format OBJECTCLASS =
==Inlets==
+
+
==Outlets==
+
+
==Arguments==
+
+
==Messages==
+
+
{{objectclass-stub}}
+
[[Category:objectclass]]
.
#------------------------------------------------------------------------------#
! # PARSE CSV
#------------------------------------------------------------------------------#
+ my $csvfile = '/Users/hans/Desktop/wiki_files_hacked/objectlist.csv';
+ my $csv = Text::CSV_PP->new();
+ my %csvhash = ();
! open (CSV, "<", $csvfile) or die $!;
! my @csvlines = split(/\012\015?|\015\012?/,(join '',<CSV>));
! foreach (@csvlines) {
! if ($csv->parse($_)) {
! my @columns = $csv->fields();
! $csvhash{ $columns[0] }{ $columns[2] } = "$columns[0],$columns[2],$columns[3],$columns[4],$columns[5],$columns[7]";
! #print("$columns[0],$columns[2] | ");
! } else {
! my $err = $csv->error_input;
! print "Failed to parse line: $err";
! }
! }
! close CSV;
!
! #------------------------------------------------------------------------------#
! # PARSE HELP FILES
! #------------------------------------------------------------------------------#
!
! foreach (`/sw/bin/find /Users/hans/Desktop/wiki_files_hacked/5.reference/ -type f -name '*.pd'`) {
chop;
$fileName = "";
! if (m|.*/5\.reference/([a-zA-Z0-9_-]+)/(.+)-help\.pd|) {
! # print("$1 , $2\t");
$library = lc($1);
$name = $2;
$fileName = $_;
! } elsif (m|.*/5\.reference/([a-zA-Z0-9_-]+)/(.+)\.pd|) {
! # print("$1 , $2 (no -help)\t");
$library = lc($1);
$name = $2;
***************
*** 83,86 ****
--- 90,96 ----
# print "filename: $fileName\n";
if ($fileName) {
+ $printText = ""; # init container
+ %xyhash = (); # init sorting hash
+
open(HELPPATCH, "$fileName");
undef $/; # $/ defines the "end of record" character
***************
*** 104,108 ****
}
- $printText = "";
for ($column = -300; $column < 1501; $column += 300) {
foreach my $yKey ( sort {$a <=> $b} keys(%xyhash) ) {
--- 114,117 ----
***************
*** 110,114 ****
if ( ($xKey > $lastColumn) && ($xKey < $column) ) {
$printText .= "$xyhash{$yKey}{$xKey}\n\n";
! #$printText .= "$xKey,$yKey: $xyhash{$yKey}{$xKey}\n";
}
}
--- 119,123 ----
if ( ($xKey > $lastColumn) && ($xKey < $column) ) {
$printText .= "$xyhash{$yKey}{$xKey}\n\n";
! #print("TEST $xKey,$yKey: $xyhash{$yKey}{$xKey}\n");
}
}
***************
*** 116,125 ****
$lastColumn = $column;
}
! #print("\n\n\nPRINTTEXT:\n$printText\n\n");
!
mkdir($library);
! open(OBJECTCLASS, ">$library/${name}.txt");
write(OBJECTCLASS);
close(OBJECTCLASS);
}
}
--- 125,179 ----
$lastColumn = $column;
}
!
! my $abbreviation = "";
! my $description = "";
! my $category = "";
! my $datatype = "";
! my $myColumns = $csvhash{$library}{$name};
! my @myColumns;
! if($myColumns) { @myColumns = split(',', $myColumns); }
! # print("csvhash{$library}{$name}: $csvhash{$library}{$name}\n");
! if($myColumns[0]) {
! if($myColumns[2]) { $abbreviation = $myColumns[2] }
! if($myColumns[3]) { $description = $myColumns[3] }
! if($myColumns[4]) { $category = $myColumns[4] }
! if($myColumns[5]) { $datatype = $myColumns[5] }
! # print("MYCOLUMNS: $myColumns[0] $myColumns[1] $myColumns[2] $myColumns[3] $myColumns[4] $myColumns[5]\n");
! }
!
mkdir($library);
! if( $classnames{$name} ) {
! open(OBJECTCLASS, ">$library/${name}_(${library}).txt");
! } else {
! open(OBJECTCLASS, ">$library/${name}.txt");
! }
! print(OBJECTCLASS "{{Infobox Objectclass\n");
! print(OBJECTCLASS "| name = $name\n");
! if($abbreviation) {
! print(OBJECTCLASS "| abbreviation = $abbreviation\n");}
! if($description) {
! print(OBJECTCLASS "| description = $description\n");}
! if($datatype) {
! print(OBJECTCLASS "| data type = $datatype\n");}
! print(OBJECTCLASS "| library = [[$library]]\n");
! print(OBJECTCLASS "| author = {{$library author}}\n");
! print(OBJECTCLASS "| license = {{$library license}}\n");
! print(OBJECTCLASS "| status = {{$library status}}\n");
! print(OBJECTCLASS "| website = {{$library website}}\n");
! print(OBJECTCLASS "| release date = {{$library release date}}\n");
! print(OBJECTCLASS "| distributions = {{$library distributions}}\n");
! print(OBJECTCLASS "| language = English\n");
! print(OBJECTCLASS "| platform = [[GNU/Linux]], [[Mac OS X]], [[Windows]]\n");
! print(OBJECTCLASS "}}\n\n");
! print(OBJECTCLASS "\n$printText\n");
write(OBJECTCLASS);
+ print(OBJECTCLASS "[[Category:$library]]\n");
+ if($category) {
+ print(OBJECTCLASS "[[Category:$category]]\n");
+ }
+ print(OBJECTCLASS "\n\n");
close(OBJECTCLASS);
+
+ $classnames{$name} = 1;
}
}