pricecharts

track prices of consumer electronics
Log | Files | Refs | README

commit d901d8fcd0e1787e1f8b062179bbe3fe21c72ba2
parent 02d15038dc7454f7408056a2e3fb7642f3d0cfb1
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sat,  4 Apr 2015 12:09:09 -0600

PriceChart: remove xmkdir, use make_path instead

Diffstat:
MPriceChart.pm | 21++++++---------------
Mgen_svg | 3+--
2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/PriceChart.pm b/PriceChart.pm @@ -1,10 +1,11 @@ package PriceChart; use DBI; +use File::Path qw(make_path); use Exporter; @ISA = ("Exporter"); -@EXPORT = qw(get_config get_dom get_log get_dbh trunc_line new_ua xmkdir); +@EXPORT = qw(get_config get_dom get_log get_dbh trunc_line new_ua make_path); sub get_config @@ -57,7 +58,7 @@ sub get_dbh my $db_dir = shift || $cfg->{"chroot"} . $cfg->{"db_dir"}; my $verbose = shift || undef; - xmkdir($db_dir, $verbose); + make_path($db_dir, { verbose => $verbose }); print "info: get_dbh: opening $db_dir/pricechart.db\n" if ($verbose); my $dbh = DBI->connect( "dbi:SQLite:dbname=$db_dir/pricechart.db", @@ -125,8 +126,9 @@ sub get_log my $verbose = shift || 0; # if $log_path has a / in it, make sure the path to it is made - xmkdir(substr($log_path, 0, rindex($log_path, '/'))); - print "info: get_log: open'ing $log_path in append mode\n" if ($args{v}); + make_path(substr($log_path, 0, rindex($log_path, '/')), { verbose => $verbose }); + + print "info: get_log: opening $log_path, append mode\n" if ($verbose); open my $log, ">>", $log_path or die "can't open $log_path: $!"; if ($verbose) { @@ -160,15 +162,4 @@ sub trunc_line return $chopped . "..."; } -sub xmkdir -{ - my $dir = shift; - my $verbose = shift; - - unless (-d $dir) { - print "info: mkdir'ing $dir\n" if ($verbose); - mkdir $dir or die "couldn't mkdir $dir: $!"; - } -} - 1; diff --git a/gen_svg b/gen_svg @@ -19,7 +19,6 @@ my $cfg = get_config(); my $dbh = get_dbh($cfg->{http}, undef, $args{v}); my $svg_dir = $cfg->{http}{chroot} . $cfg->{http}{htdocs} . "/svg"; -xmkdir($svg_dir, $args{v}); # we don't output svg's when -n is given print "info: svg output dir is $svg_dir\n" if ($args{v} && !$args{n}); @@ -210,7 +209,7 @@ while (my ($manufacturer, $part_num) = $parts_sth->fetchrow_array()) { # giant hack, if the part number has / in it, make some directories if ($part_num =~ /\//) { my $needed_dirs = substr($part_num, 0, rindex($part_num, '/')); - xmkdir("$svg_dir/$needed_dirs", $args{v}); + make_path("$svg_dir/$needed_dirs", { verbose => $args{v} }); } open my $svg_fh, ">", "$svg_dir/$part_num.svg" or die "couldn't open $svg_dir/$part_num: $!";