Re: [Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)
On 10 December 2011 21:54, Romain d'Alverny wrote: >>> By the way, is there a "best" Web-based doc for MDK Perl libraries? >>> (could find one, but not at once, and I didn't count many). Or shall >>> we think about it? >> >> perldoc MDK::Common > > Thanks, this is cool for a local access. Looking for a way to export > this into HTML. see man pod2html
Re: [Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)
On Sat, Dec 10, 2011 at 20:37, Thierry Vignaud wrote: > On 10 December 2011 20:25, Romain d'Alverny wrote: >>> if ((@info{qw(name version release variant arch medium build >>> ext)}) = $name =~ >>> >>> m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) >>> { >>> $info{full} = $name; >>> } >> >> Looks much more compact, thanks. Added a "else { %info = (); }" to >> satisfy the expected behaviour (empty array returned if no match). > > This is wrong. > Once declared (aka "my %info"), %info is initialized and is equal to "()". Yes, but otherwise, testing the code you provided, even if the regexp test fails, returned %info is still populated with keys, pointing to undef values. >> By the way, is there a "best" Web-based doc for MDK Perl libraries? >> (could find one, but not at once, and I didn't count many). Or shall >> we think about it? > > perldoc MDK::Common Thanks, this is cool for a local access. Looking for a way to export this into HTML.
Re: [Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)
On 10 December 2011 20:25, Romain d'Alverny wrote: >> just do sg like this: >> [...] >> if ((@info{qw(name version release variant arch medium build >> ext)}) = $name =~ >> >> m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) >> { >> $info{full} = $name; >> } >> [...] > > Looks much more compact, thanks. Added a "else { %info = (); }" to > satisfy the expected behaviour (empty array returned if no match). This is wrong. Once declared (aka "my %info"), %info is initialized and is equal to "()". >>> open(my $file, "temp_media_on_iso.log") if -r "temp_media_on_iso.log"; >>> >>> while ($media = <$file>) { >> >> just reuse cat_() from MDK::Common (simpler, easier to read) > > Thanks! > > By the way, is there a "best" Web-based doc for MDK Perl libraries? > (could find one, but not at once, and I didn't count many). Or shall > we think about it? perldoc MDK::Common I've locally a branch adding doc for drakx but it's not finished.
Re: [Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)
On Sat, Dec 10, 2011 at 18:59, Thierry Vignaud wrote: > On 10 December 2011 18:29, wrote: >> coding style update (perl_checker) > > uh? Tools.pm doesn't currently pass perl_checker Right; but I couldn't see why that was a syntax error at that point (and the script did work). Anyway, now it looks much better (but for used modules or "not recognised yet"). > just do sg like this: > [...] > if ((@info{qw(name version release variant arch medium build > ext)}) = $name =~ > > m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) > { > $info{full} = $name; > } > [...] Looks much more compact, thanks. Added a "else { %info = (); }" to satisfy the expected behaviour (empty array returned if no match). >> open(my $file, "temp_media_on_iso.log") if -r "temp_media_on_iso.log"; >> >> while ($media = <$file>) { > > just reuse cat_() from MDK::Common (simpler, easier to read) Thanks! By the way, is there a "best" Web-based doc for MDK Perl libraries? (could find one, but not at once, and I didn't count many). Or shall we think about it?
Re: [Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)
On 10 December 2011 18:29, wrote: > Revision 2359 Author rda Date 2011-12-10 18:29:07 +0100 (Sat, 10 Dec 2011) > > Log Message > > coding style update (perl_checker) uh? Tools.pm doesn't currently pass perl_checker > Modified Paths > > isocheck/trunk/Tools.pm > isocheck/trunk/t/003_is_hybrid.t > isocheck/trunk/t_install_iso/010_check_autorun.t > isocheck/trunk/t_install_iso/012_check_ids.t > isocheck/trunk/t_install_iso/013_check_rpms.t > isocheck/trunk/t_install_iso/016_check_pubkey.t > > Modified: isocheck/trunk/Tools.pm > === > --- isocheck/trunk/Tools.pm 2011-12-10 17:27:16 UTC (rev 2358) > +++ isocheck/trunk/Tools.pm 2011-12-10 17:29:07 UTC (rev 2359) > @@ -33,18 +33,18 @@ > > sub parse_mageia_iso_name { > my ($name) = @_; > -my %info = (); > +my %info; > > -if ($name =~ > m/^(Mageia)-(\d+)(-(alpha|beta|RC)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BD))?(-(build\_\w+))?\.(.*)$/) > { > -$info{"full"}= $name; > -$info{"name"}= $1 if defined $1; > -$info{"version"} = $2 if defined $2; > -$info{"release"} = "$4$5" if defined $4; > -$info{"variant"} = $7 if defined $7; > -$info{"arch"}= $8 if defined $8; > -$info{"medium"} = $10 if defined $10; > -$info{"build"} = $12 if defined $12; > -$info{"ext"} = $13 if defined $13; > +if ($name =~ > m/^(Mageia)-(\d+)(-(alpha|beta|RC)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BD))?(-(build_\w+))?\.(.*)$/) > { > +$info{full}= $name; > +$info{name}= $1 if defined $1; > +$info{version} = $2 if defined $2; > +$info{release} = "$4$5" if defined $4; > +$info{variant} = $7 if defined $7; > +$info{arch}= $8 if defined $8; > +$info{medium} = $10 if defined $10; > +$info{build} = $12 if defined $12; > +$info{ext} = $13 if defined $13; You don't need all those tests since you already checked if the regexp matched or not. You only have to check for ()? groups. What's more your checks are inconsistant anyway (eg you don't check for $5) just do sg like this: sub parse_mageia_iso_name { my ($name) = @_; my %info; if ((@info{qw(name version release variant arch medium build ext)}) = $name =~ m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) { $info{full} = $name; } return %info; } > Modified: isocheck/trunk/t/003_is_hybrid.t > === > --- isocheck/trunk/t/003_is_hybrid.t 2011-12-10 17:27:16 UTC (rev 2358) > +++ isocheck/trunk/t/003_is_hybrid.t 2011-12-10 17:29:07 UTC (rev 2359) > @@ -24,7 +24,7 @@ > > my ($image_path) = @ARGV; > > -ok (is_hybrid($image_path, 0), "Is hybrid"); > +ok is_hybrid($image_path, 0), "Is hybrid"; please keep (), it's clearer. just remove the space between "ok" and "(" > Modified: isocheck/trunk/t_install_iso/016_check_pubkey.t > === > --- isocheck/trunk/t_install_iso/016_check_pubkey.t 2011-12-10 17:27:16 UTC > (rev 2358) > +++ isocheck/trunk/t_install_iso/016_check_pubkey.t 2011-12-10 17:29:07 UTC > (rev 2359) > @@ -39,17 +39,17 @@ > system "ls /media/iso_check/i586/media/ > temp_media_on_iso.log" if -r > "/media/iso_check/i586/media/"; > system "ls /media/iso_check/x86_64/media/ >> temp_media_on_iso.log" if -r > "/media/iso_check/x86_64/media/"; > > -ok (-r "temp_media_on_iso.log", "Got a log for media contents"); > +ok -r "temp_media_on_iso.log", "Got a log for media contents"; > > open(my $file, "temp_media_on_iso.log") if -r "temp_media_on_iso.log"; > > while ($media = <$file>) { just reuse cat_() from MDK::Common (simpler, easier to read)