Guest User

Untitled

a guest
May 20th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.04 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. ###############################################################################
  3. ##
  4. ## Create a CSV file showing a 2 dimensional view of all unique PNG drawables
  5. ## and the various configurations they are provided for.
  6. ##
  7. ###############################################################################
  8.  
  9. use strict;
  10. use Data::Dumper;
  11.  
  12. my $path = shift @ARGV || '.';
  13.  
  14. my $resDir = "$path/res";
  15. die "$path does not seem to contain an Android project" unless -d $resDir;
  16.  
  17. my %drawables;
  18. my @imageNames = map { chomp; $_ } qx#find "$resDir" -type f -name '*.png' -exec basename {} .png \\; | sort | uniq#;
  19.  
  20. my @drawableDirs = map { chomp; $_ } qx#find "$resDir" -maxdepth 1 -name 'drawable*' | cut -d/ -f3 | sort#;
  21.  
  22. print 'imageName,', join(',', @drawableDirs), "\n";
  23.  
  24. foreach my $imageName (@imageNames) {
  25.     my @dirs = map { chomp; $_ } qx#find "$resDir" -type f -name "$imageName.png" | cut -d/ -f3#;
  26.     my %dirs = map { $_ => 1 } @dirs;
  27.     print join(',', $imageName, map { $dirs{$_} ? 'x' : '' } @drawableDirs), "\n";
  28. }
Add Comment
Please, Sign In to add comment