aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse-help-patches.pl
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-09-30 20:51:16 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-09-30 20:51:16 +0000
commit0951f26857344ca947e4f8556d1dec1ebd1dd831 (patch)
tree5f8c0f5ad49d247e40f759655aa06e7a2dca9d11 /scripts/parse-help-patches.pl
parent0aea397c725aca6cbf6a086d7043fd14b5116557 (diff)
final tweaks after first test, and yes, this script got even uglier
svn path=/trunk/; revision=8779
Diffstat (limited to 'scripts/parse-help-patches.pl')
-rwxr-xr-xscripts/parse-help-patches.pl128
1 files changed, 91 insertions, 37 deletions
diff --git a/scripts/parse-help-patches.pl b/scripts/parse-help-patches.pl
index 1511686a..b3ad33bb 100755
--- a/scripts/parse-help-patches.pl
+++ b/scripts/parse-help-patches.pl
@@ -4,6 +4,7 @@
use strict;
use warnings;
+use Text::CSV_PP;
my $line = "";
my @lines;
@@ -12,69 +13,75 @@ my $column;
my $lastColumn = 0;
my $printText = "";
+my %classnames = ();
my %xyhash = ();
my $library = "";
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
+# 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 /Applications/Pd-extended.app/Contents/Resources/doc/5.reference/ -type f -name '*.pd'`) {
+foreach (`/sw/bin/find /Users/hans/Desktop/wiki_files_hacked/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");
+ if (m|.*/5\.reference/([a-zA-Z0-9_-]+)/(.+)-help\.pd|) {
+# print("$1 , $2\t");
$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");
+ } elsif (m|.*/5\.reference/([a-zA-Z0-9_-]+)/(.+)\.pd|) {
+# print("$1 , $2 (no -help)\t");
$library = lc($1);
$name = $2;
$fileName = $_;
@@ -82,6 +89,9 @@ foreach (`/sw/bin/find /Applications/Pd-extended.app/Contents/Resources/doc/5.re
# print "filename: $fileName\n";
if ($fileName) {
+ $printText = ""; # init container
+ %xyhash = (); # init sorting hash
+
open(HELPPATCH, "$fileName");
undef $/; # $/ defines the "end of record" character
$_ = <HELPPATCH>; # read the whole file into the scalar
@@ -103,24 +113,68 @@ foreach (`/sw/bin/find /Applications/Pd-extended.app/Contents/Resources/doc/5.re
$lineCount++;
}
- $printText = "";
for ($column = -300; $column < 1501; $column += 300) {
foreach my $yKey ( sort {$a <=> $b} keys(%xyhash) ) {
foreach my $xKey ( keys(%{$xyhash{$yKey}}) ) {
if ( ($xKey > $lastColumn) && ($xKey < $column) ) {
$printText .= "$xyhash{$yKey}{$xKey}\n\n";
- #$printText .= "$xKey,$yKey: $xyhash{$yKey}{$xKey}\n";
+ #print("TEST $xKey,$yKey: $xyhash{$yKey}{$xKey}\n");
}
}
}
$lastColumn = $column;
}
- #print("\n\n\nPRINTTEXT:\n$printText\n\n");
-
+
+ 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);
- open(OBJECTCLASS, ">$library/${name}.txt");
+ 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;
}
}