Changeset 2253 in ProjectBuilder for devel/pb/lib/ProjectBuilder/Filter.pm


Ignore:
Timestamp:
Aug 30, 2017, 5:07:33 PM (7 years ago)
Author:
Bruno Cornec
Message:

More YAML transformations

  • We now generate a .pbrc.yml if none exist
  • If no .pbrc.yml is found but a former .pbrc is there convert it automatically
  • Adds a function pb_conf_update_v0 to convert automatically v0 conf files into v1 conf files
  • pb_conf_cache now handles multi lines and can be used for filter management by pb_get_filters
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r2251 r2253  
    6868my $pbos = shift;
    6969my $ptr = undef; # returned value pointer on the hash of filters
    70 my %h;
     70my $h;
    7171
    7272pb_log(2,"Entering pb_get_filters - pbpkg: $pbpkg - pbos: ".Dumper($pbos)."\n");
     
    8888    foreach my $f (@ffiles) {
    8989        pb_log(3,"DEBUG processing filter file $f\n");
    90         open(CONF,$f) || next;
    91         while(<CONF>)  {
    92             if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
    93                 my ($what, $var, $value) = ($1, $2, $3);
    94                 pb_log(3,"DEBUG creating entry $what, key $var, value $value\n");
    95                 # Add support for multi-lines
    96                 while ($value =~ s/\\\s*$//o) {
    97                     $_ = <CONF>;
    98                     die "Still processing continuations for $what $var at EOF" if (not defined $_);
    99                     s/[\r\n]//go;
    100                     $value .= "\n$_";
    101                 }
    102                 $h{$what}{$var}=$value;
    103             } elsif ((/^\s*#/o) || (/^\s*$/o)) {
    104                 # ignore
    105             } else {
    106                 chomp();
    107                 warn "unexpected line '$_' in $f";
    108             }
    109         }
    110         close(CONF);
    111     }
    112     $ptr = $h{"filter"};
     90        $h = pb_conf_cache($f,$h);
     91    }
     92    $ptr = $h->{"filter"};
    11393
    11494    # TODO: find a place to document it. Why not in this file as pod and also documenting filters ?
    11595    # Handle transform
    116     if (defined $h{transform}) {
    117         while (my ($out_key,$spec) = each %{$h{transform}}) {
     96    if (defined $h->{transform}) {
     97        while (my ($out_key,$spec) = each %{$h->{transform}}) {
    11898            die "Unknown transform for $out_key '$spec' expected <out-key> <transform>" unless $spec =~ /^([\w\-]+)\s+(.+)$/;
    11999            my ($in_key, $expr) = ($1, $2);
Note: See TracChangeset for help on using the changeset viewer.