Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2014-07-26 14:15:57 +0400
committerAlessandro Ranellucci <aar@cpan.org>2014-07-26 14:16:33 +0400
commitc4df4051a0bdf3d7d225d50054edd7f75b298f92 (patch)
treeeef755a32fc9b0fdd5880ed4c06449a07ed88c09 /utils
parentd68192749fa2aea9a70bce86ee3f523a1311d473 (diff)
New utility script to convert config bundles into a single config file
Diffstat (limited to 'utils')
-rwxr-xr-xutils/config-bundle-to-config.pl57
1 files changed, 57 insertions, 0 deletions
diff --git a/utils/config-bundle-to-config.pl b/utils/config-bundle-to-config.pl
new file mode 100755
index 000000000..beecd666f
--- /dev/null
+++ b/utils/config-bundle-to-config.pl
@@ -0,0 +1,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";
+}
+
+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__