Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed 57ff39c

Now reading the YAML in edit-yaml-gui.pl.

  • Participants
  • Parent commits 7e6450e

Comments (0)

Files changed (3)

File 1st-version-as-scripts/edit-yaml-gui.pl

 use strict;
 use warnings;
 
+package Flickr::WxPerlUploader::Photo;
+
+our $NUM_DESCRIPTION_PARTS = 5;
+
+use Class::XSAccessor
+    accessors => {
+        (map { $_ => $_ } 
+        (qw(
+            filename
+            tags
+            title
+            description_parts
+        )),
+        )
+    }
+    ;
+
+sub new
+{
+    my $class = shift;
+
+    my $self = {};
+    bless $self, $class;
+
+    $self->_init(@_);
+
+    return $self;
+}
+
+sub _init
+{
+    my $self = shift;
+    my $args = shift;
+
+    $self->filename($args->{'filename'});
+
+    if (! -e $self->filename())
+    {
+        die "Unknown filename '" . $self->filename() . "'!";
+    }
+
+    $self->tags([ @{$args->{'tags'}} ]);
+
+    $self->title($args->{'title'});
+
+    $self->description_parts([ @{$args->{'description_parts'}}]);
+
+    if (@{$self->description_parts()} != $NUM_DESCRIPTION_PARTS)
+    {
+        die ("Incorrect number of description parts - " 
+            . scalar(@{$self->description_parts()}) . "!"
+        );
+    }
+
+    return;
+}
+
 package Flickr::WxPerlUploader::App;
 
 use base 'Wx::App';
 use Wx ':everything';
 use Wx::Event qw(EVT_LISTBOX_DCLICK);
 
+use Class::XSAccessor
+    accessors => {
+        (map { $_ => $_ } 
+        (qw(
+            _common_tags
+            _photo_files
+        )),
+        )
+    }
+    ;
+
+use YAML::XS qw(LoadFile);
+
+sub _read_photos {
+    my $self = shift;
+
+    my $filename = "upload-spec.yml";
+
+    my $yaml = LoadFile($filename);
+
+    $self->_common_tags($yaml->{'common_tags'});
+
+    $self->_photo_files(
+        [ map { 
+            Flickr::WxPerlUploader::Photo->new(
+                $_,
+            )
+            } @{$yaml->{'files'}},
+        ]
+    );
+
+    return;
+}
+
 sub new
 {
     my ($class, $args) = @_;
 {
     my( $self ) = @_;
 
+    $self->_read_photos();
+
     my $frame = Wx::Frame->new( undef, -1, 'wxPerl', wxDefaultPosition, [ 200, 100 ] );
 
     my $menu_bar = Wx::MenuBar->new;
         -1,
         wxDefaultPosition(),
         wxDefaultSize(),
-        [qw(
-            surround_island
-            surrounded_by_blacks
-            adjacent_whites
-            distance_from_islands
-        )]
+        [ 
+            map { $_->filename() } @{$self->_photo_files()}
+        ],
     );
     $sizer->Add($frame->{list}, 1, wxALL(), 10);
 

File 1st-version-as-scripts/prepare-yaml.pl

 open my $yaml, ">", $yaml_fn;
 print {$yaml} Dump(
     {
-        common_tags => "",
+        common_tags => [],
         files =>
         [
             (map

File 1st-version-as-scripts/upload-spec.yml

 ---
-common_tags: ''
+common_tags: []
 files:
   - description_parts:
       - ''