diff --git a/perl/Gnome-Tomboy/lib/Tomboy/Directory.pm b/perl/Gnome-Tomboy/lib/Tomboy/Directory.pm index b8869028974dd8b1c7a0c94b430008830ea9e21d..333e28018cd4e7ab2bac04dbd429fdb6801a56d4 100644 --- a/perl/Gnome-Tomboy/lib/Tomboy/Directory.pm +++ b/perl/Gnome-Tomboy/lib/Tomboy/Directory.pm @@ -20,8 +20,9 @@ use strict; use Tomboy::Note::Simple; -my @TB_note_attrs= qw(title create-date last-change-date last-metadata-change-date); -my @TB_meta_attrs= qw(uid mtime size notebook is_template); +# attributes read from the note itself or from the filesystem +my @TB_note_attrs= qw(title create-date last-change-date last-metadata-change-date notebook is_template fnm); +my @TB_meta_attrs= qw(uuid mtime size); sub TB_attrs { return (@TB_meta_attrs, @TB_note_attrs) } sub new @@ -46,6 +47,7 @@ sub scan_dir my $obj= shift; my $dir= shift; + $dir=~ s#/+$##; unless (opendir (DIR, $dir)) { print "ATTN: can't read directory [$dir]\n"; @@ -57,7 +59,7 @@ sub scan_dir { next NOTE if ($e eq '.' || $e eq '..'); next NOTE unless ($e =~ /(.+)\.note$/); - my $uid= $1; + my $fnm_uuid= $1; my $fp= join ('/', $dir, $e); # print "reading note [$fp]\n"; # TODO: if verbose... @@ -75,18 +77,25 @@ sub scan_dir print "ATTN: parsing [$fp] returned undefined note!\n"; next NOTE; } + # print "n: ", main::Dumper ($n); my %rec= map { $_ => $n->{$_} } @TB_note_attrs; - $rec{'uid'}= $uid; + $rec{'uuid'}= $fnm_uuid; $rec{'mtime'}= $st[9]; $rec{'size'}= $st[7]; +=begin comment + +... this is now part of Tomboy::Note::Simple foreach my $tag (@{$n->{'tags'}}) { - if ($tag =~ m#system:notebook:(.+)#) { $rec{'notebook'}= $1 } - elsif ($tag eq 'system:template') { $rec{'is_template'}= 1; } + if ($tag =~ m#system:notebook:(.+)#) { $rec{'notebook'}= $1 } + elsif ($tag eq 'system:template') { $rec{'is_template'}= 1 } } +=end comment +=cut + push (@res, \%rec); } diff --git a/perl/Gnome-Tomboy/s2.pl b/perl/Gnome-Tomboy/s2.pl index 8158829446d73e8fd6f27f84201327cf18fbfc8e..86d6186b32d50ba59917b26c93b337816167d0cb 100755 --- a/perl/Gnome-Tomboy/s2.pl +++ b/perl/Gnome-Tomboy/s2.pl @@ -1,5 +1,17 @@ #!/usr/bin/perl +=head1 NAME + + s2.pl + +=head1 DESCRIPTION + +Script to play with Tomboy::Directory for testing. + +Generates a CSV file as TOC (table of contents) which might be useful. + +=cut + use strict; use lib 'lib'; @@ -16,6 +28,7 @@ my $toc_file= 'Tomboy-TOC.csv'; die "no note dir specified" unless ($note_dir); +$note_dir=~ s#/+$##; my $tb_d= new Tomboy::Directory ('dir' => $note_dir); print "tb_d: ", Dumper ($tb_d); @@ -26,7 +39,7 @@ my $toc_data= $tb_d->scan_dir ($note_dir); my $toc= new Util::Simple_CSV ('UTF8' => 1, 'no_hash' => 1); $toc->define_columns (Tomboy::Directory::TB_attrs()); $toc->{'data'}= $toc_data; -$toc->save_csv_file ('filename' => $toc_file); +$toc->save_csv_file ('filename' => $toc_file, 'separator' => "\t", 'UTF8' => 1); exit (0);