File: config-bundle-to-config.pl

package info (click to toggle)
slic3r 1.2.9%2Bdfsg-9~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,356 kB
  • sloc: cpp: 18,722; perl: 18,039; ansic: 2,568; makefile: 37
file content (57 lines) | stat: -rwxr-xr-x 1,336 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# This script extracts a full active config from a config bundle.
# (Often users reporting issues don't attach plain configs, but 
# bundles...)

use strict;
use warnings;

BEGIN {
    use FindBin;
    use lib "$FindBin::Bin/../lib", "/usr/lib/slic3r/";
}

use Getopt::Long qw(:config no_auto_abbrev);
use Slic3r;
use Slic3r::Test;
$|++;

my %opt = ();
{
    my %options = (
        'help'                  => sub { usage() },
        'output=s'              => \$opt{output},
    );
    GetOptions(%options) or usage(1);
    $ARGV[0] or usage(1);
}

($ARGV[0] && $opt{output}) or usage(1);

{
    my $bundle_ini = Slic3r::Config->read_ini($ARGV[0])
        or die "Failed to read $ARGV[0]\n";
    
    my $config_ini = { _ => {} };
    foreach my $section (qw(print filament printer)) {
        my $preset_name = $bundle_ini->{presets}{$section};
        $preset_name =~ s/\.ini$//;
        my $preset = $bundle_ini->{"$section:$preset_name"}
            or die "Failed to find preset $preset_name in bundle\n";
        $config_ini->{_}{$_} = $preset->{$_} for keys %$preset;
    }
    
    Slic3r::Config->write_ini($opt{output}, $config_ini);
}


sub usage {
    my ($exit_code) = @_;
    
    print <<"EOF";
Usage: config-bundle-to-config.pl --output config.ini bundle.ini
EOF
    exit ($exit_code || 0);
}

__END__