Skip to content

Commit 4ca625e

Browse files
committed
applied code formatting
1 parent 9b09821 commit 4ca625e

File tree

5 files changed

+58
-61
lines changed

5 files changed

+58
-61
lines changed

src/TTMp32Gme/Build/FileHandler.pm

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ sub cleanup_filename {
143143
$filename =~ s/[^A-Za-z0-9_\-\.]//g;
144144
$filename =~ s/\.\./\./g;
145145
$filename =~ s/\.$//g;
146-
_utf8_off($filename); #prevent perl from messing up filenames with non-ascii characters because of perl open() bug: https://github.com/perl/perl5/issues/15883
146+
_utf8_off($filename)
147+
; #prevent perl from messing up filenames with non-ascii characters because of perl open() bug: https://github.com/perl/perl5/issues/15883
147148
return $filename;
148149
}
149150

@@ -243,7 +244,7 @@ sub get_tiptoi_dir {
243244
sub get_gmes_already_on_tiptoi {
244245
my $tiptoi_path = get_tiptoi_dir();
245246
if ($tiptoi_path) {
246-
my @gme_list = grep( !$_->is_dir && $_->basename =~ /^(?!\._).*\.gme\z/, $tiptoi_path->children() );
247+
my @gme_list = grep( !$_->is_dir && $_->basename =~ /^(?!\._).*\.gme\z/, $tiptoi_path->children() );
247248
my %gme_names = map { $_->basename => 1 } @gme_list;
248249
return %gme_names;
249250
} else {
@@ -269,20 +270,20 @@ sub delete_gme_tiptoi {
269270

270271
sub move_library {
271272
my ( $from, $to, $dbh, $httpd, $debug ) = @_;
272-
debug('raw: '.$to, $debug);
273+
debug( 'raw: ' . $to, $debug );
273274
my $library = dir($to);
274275
unless ( -w $library || $library->mkpath() ) {
275276
return 'error: could not write to target directory';
276277
}
277-
debug('mkdir: '.$library, $debug);
278+
debug( 'mkdir: ' . $library, $debug );
278279
$library->resolve;
279-
debug('resolved: '.$library, $debug);
280+
debug( 'resolved: ' . $library, $debug );
280281
if ( $library->children() ) {
281282
return 'error: target directory not empty';
282283
}
283-
my $albums = $dbh->selectall_hashref(q( SELECT path, oid FROM gme_library ), 'oid');
284-
my $qh = $dbh->prepare('UPDATE gme_library SET path=? WHERE oid=?');
285-
local($dbh->{AutoCommit}) = 0;
284+
my $albums = $dbh->selectall_hashref( q( SELECT path, oid FROM gme_library ), 'oid' );
285+
my $qh = $dbh->prepare('UPDATE gme_library SET path=? WHERE oid=?');
286+
local ( $dbh->{AutoCommit} ) = 0;
286287
my $escFrom = $from;
287288
$escFrom =~ s/\\/\\\\/g;
288289
foreach my $oid ( sort keys %{$albums} ) {
@@ -292,14 +293,14 @@ sub move_library {
292293
$dbh->rollback();
293294
return 'error: could not update album path in database';
294295
} else {
295-
if (dirmove( $from, $library )) {
296+
if ( dirmove( $from, $library ) ) {
296297
$dbh->commit();
297-
return 'Success.';
298+
return 'Success.';
298299
} else {
299300
my $errMsg = $!;
300301
$dbh->rollback();
301-
return 'error: could not move files: '.$errMsg;
302-
};
302+
return 'error: could not move files: ' . $errMsg;
303+
}
303304
}
304305
}
305306

src/TTMp32Gme/LibraryHandler.pm

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ sub sortByDiscTrackFilename {
132132
}
133133

134134
sub sortTracks {
135-
my ($track_data) = @_;
135+
my ($track_data) = @_;
136136
my @tracks = map( $_->{'track'}, @{$track_data} );
137137
my @sorted_track_data = sort sortByDiscTrackFilename @{$track_data};
138138
foreach my $track_no ( 0 .. $#sorted_track_data ) {
@@ -162,9 +162,9 @@ sub updateTableEntry {
162162
my $qh = $dbh->prepare( sprintf( 'UPDATE %s SET %s=? WHERE %s', $table, join( "=?, ", @fields ), $keyname ) );
163163
push( @values, @{$search_keys} );
164164
if ( $^O =~ /MSWin/ ) {
165-
@values = map {encode("cp".Win32::GetACP(), $_)} @values; #fix encoding problems on windows
165+
@values = map { encode( "cp" . Win32::GetACP(), $_ ) } @values; #fix encoding problems on windows
166166
} else {
167-
@values = map {encode_utf8($_)} @values; #fix encoding problems on mac
167+
@values = map { encode_utf8($_) } @values; #fix encoding problems on mac
168168
}
169169
$qh->execute(@values);
170170
return !$dbh->errstr;
@@ -204,20 +204,20 @@ sub createLibraryEntry {
204204

205205
#fill in album info
206206
if ( !$album_data{'album_title'} && $info->album() ) {
207-
if ($^O =~ /MSWin/ ) {
208-
$album_data{'album_title'} = encode("cp".Win32::GetACP(), $info->album());
207+
if ( $^O =~ /MSWin/ ) {
208+
$album_data{'album_title'} = encode( "cp" . Win32::GetACP(), $info->album() );
209209
} else {
210210
$album_data{'album_title'} = $info->album();
211211
}
212-
$album_data{'path'} = cleanup_filename( $album_data{'album_title'} );
212+
$album_data{'path'} = cleanup_filename( $album_data{'album_title'} );
213213
}
214214
if ( !$album_data{'album_artist'} && $info->albumartist() ) {
215215
$album_data{'album_artist'} = $info->albumartist();
216216
} elsif ( !$album_data{'album_artist'} && $info->artist() ) {
217217
$album_data{'album_artist'} = $info->artist();
218218
}
219-
if ($^O =~ /MSWin/ ) {
220-
$album_data{'album_artist'} = encode("cp".Win32::GetACP(), $album_data{'album_artist'});
219+
if ( $^O =~ /MSWin/ ) {
220+
$album_data{'album_artist'} = encode( "cp" . Win32::GetACP(), $album_data{'album_artist'} );
221221
}
222222
if ( !$album_data{'album_year'} && $info->year() ) {
223223
$album_data{'album_year'} = $info->get_year();
@@ -240,7 +240,7 @@ sub createLibraryEntry {
240240
my $mp3 = MP3::Tag->new( $album->{$fileId} );
241241
$mp3->get_tags();
242242

243-
debug( Dumper($mp3), $debug > 2);
243+
debug( Dumper($mp3), $debug > 2 );
244244
my $id3v2_tagdata = $mp3->{ID3v2};
245245
if ($id3v2_tagdata) {
246246
my $apic = $id3v2_tagdata->get_frame("APIC");
@@ -271,9 +271,9 @@ sub createLibraryEntry {
271271
"WARNING: id3 tag missing or incomplete for $album->{$fileId}.\nPlease add an id3v2 tag containing at least album, title and track number to your mp3 file in order to get proper album and track info."
272272
);
273273
}
274-
if ($^O =~ /MSWin/ ) {
275-
foreach my $key (keys %trackInfo) {
276-
$trackInfo{$key} = encode("cp".Win32::GetACP(), $trackInfo{$key});
274+
if ( $^O =~ /MSWin/ ) {
275+
foreach my $key ( keys %trackInfo ) {
276+
$trackInfo{$key} = encode( "cp" . Win32::GetACP(), $trackInfo{$key} );
277277
}
278278
}
279279
push( @track_data, \%trackInfo );
@@ -319,10 +319,10 @@ sub createLibraryEntry {
319319
sub get_album_list {
320320
my ( $dbh, $httpd, $debug ) = @_;
321321
my @albumList;
322-
my $albums = $dbh->selectall_hashref( q( SELECT * FROM gme_library ORDER BY oid DESC ), 'oid' );
323-
debug( Dumper( $albums ), $debug > 2 );
322+
my $albums = $dbh->selectall_hashref( q( SELECT * FROM gme_library ORDER BY oid DESC ), 'oid' );
323+
debug( Dumper($albums), $debug > 2 );
324324
my %gmes_on_tiptoi = get_gmes_already_on_tiptoi();
325-
debug( 'Found gme files on tiptoi: ' . Dumper( \%gmes_on_tiptoi ), $debug > 1);
325+
debug( 'Found gme files on tiptoi: ' . Dumper( \%gmes_on_tiptoi ), $debug > 1 );
326326
foreach my $oid ( sort keys %{$albums} ) {
327327
$albums->{$oid} = get_tracks( $albums->{$oid}, $dbh );
328328
if ( $albums->{$oid}->{'gme_file'} ) {

src/TTMp32Gme/PrintHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sub format_tracks {
3232
put_file_online( $oid_file, $oid_path, $httpd );
3333
$content .= "<li class='list-group-item'>";
3434
$content .=
35-
"<table width='100%'><tr><td><div class='img-6mm track-img-container'><img class='img-24mm' src='$oid_path' alt='oid $oid[0]'></div></td>";
35+
"<table width='100%'><tr><td><div class='img-6mm track-img-container'><img class='img-24mm' src='$oid_path' alt='oid $oid[0]'></div></td>";
3636
$content .= sprintf(
3737
"<td class='track-title'>%d. %s</td><td class='runtime'>(<strong>%02d:%02d</strong>)</td></tr></table></li>\n",
3838
$i + 1,

src/TTMp32Gme/TttoolHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ sub make_gme {
244244
my $fh = $yaml_file->openw();
245245
print $fh "#this file was generated automatically by ttmp32gme\n";
246246
print $fh "product-id: $oid\n";
247-
print $fh 'comment: "CHOMPTECH DATA FORMAT CopyRight 2019 Ver0.00.0001"' . "\n";
247+
print $fh 'comment: "CHOMPTECH DATA FORMAT CopyRight 2019 Ver0.00.0001"' . "\n";
248248
print $fh "gme-lang: $config->{'pen_language'}\n";
249249
close($fh);
250250
my $media_path = convert_tracks( $album, $yaml_file, $config, $dbh );

src/ttmp32gme.pl

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,21 @@ sub fetchConfig {
118118
$tempConfig{ $$cfgParam[0] } = $$cfgParam[1];
119119
}
120120
$tempConfig{'library_path'} = $tempConfig{'library_path'} ? $tempConfig{'library_path'} : get_default_library_path();
121-
debug('fetched config: '.Dumper( \%tempConfig ), $debug );
121+
debug( 'fetched config: ' . Dumper( \%tempConfig ), $debug );
122122
return %tempConfig;
123123
}
124124

125125
sub save_config {
126126
my ($configParams) = @_;
127-
debug('raw new conf:'.Dumper($configParams), $debug);
128-
my $qh = $dbh->prepare('UPDATE config SET value=? WHERE param=?');
129-
my $answer = 'Success.';
127+
debug( 'raw new conf:' . Dumper($configParams), $debug );
128+
my $qh = $dbh->prepare('UPDATE config SET value=? WHERE param=?');
129+
my $answer = 'Success.';
130130
if ( defined $configParams->{'library_path'} ) {
131131
my $new_path = dir( $configParams->{'library_path'} )->stringify(); #make sure to remove slashes from end of path
132-
if ($^O =~ /MSWin/ ) {
133-
$new_path = encode("cp".Win32::GetACP(), $new_path); #fix encoding for filename on windows
132+
if ( $^O =~ /MSWin/ ) {
133+
$new_path = encode( "cp" . Win32::GetACP(), $new_path ); #fix encoding for filename on windows
134134
} else {
135-
$new_path = encode_utf8($new_path); #fix encoding for filename on macOS
135+
$new_path = encode_utf8($new_path); #fix encoding for filename on macOS
136136
}
137137
$configParams->{'library_path'} = $new_path;
138138
if ( $config{'library_path'} ne $configParams->{'library_path'} ) {
@@ -141,12 +141,12 @@ sub save_config {
141141
if ( $answer ne 'Success.' ) {
142142
$configParams->{'library_path'} = $config{'library_path'};
143143
} else {
144-
my $albums = get_album_list( $dbh, $httpd, $debug ); #update image paths for cover images
144+
my $albums = get_album_list( $dbh, $httpd, $debug ); #update image paths for cover images
145145
}
146146
}
147147
}
148-
debug('old conf:'.Dumper(\%config), $debug);
149-
debug('new conf:'.Dumper($configParams), $debug);
148+
debug( 'old conf:' . Dumper( \%config ), $debug );
149+
debug( 'new conf:' . Dumper($configParams), $debug );
150150
if ( defined $configParams->{'tt_dpi'}
151151
&& ( int( $configParams->{'tt_dpi'} ) / int( $configParams->{'tt_pixel-size'} ) ) < 200 )
152152
{
@@ -331,8 +331,7 @@ sub getNavigation {
331331
$content->{'tiptoi_connected'} = \1;
332332
}
333333
} elsif ( $req->parm('action') =~ /(update|delete|cleanup|make_gme|copy_gme|delete_gme_tiptoi)/ ) {
334-
my $postData =
335-
decode_json( $req->parm('data') );
334+
my $postData = decode_json( $req->parm('data') );
336335
if ( $req->parm('action') eq 'update' ) {
337336
$statusMessage = 'Could not update database.';
338337
my $old_player_mode = $postData->{'old_player_mode'};
@@ -378,7 +377,7 @@ sub getNavigation {
378377
$statusMessage = $dbh->errstr;
379378
}
380379
}
381-
debug( Dumper( $content ), $debug > 1 );
380+
debug( Dumper($content), $debug > 1 );
382381
$content = encode_json($content);
383382
if ( $^O !~ /(MSWin)/ ) {
384383
$content = decode_utf8($content);
@@ -389,8 +388,7 @@ sub getNavigation {
389388
'/print' => sub {
390389
my ( $httpd, $req ) = @_;
391390
if ( $req->method() eq 'GET' ) {
392-
my $getData =
393-
decode_json( $req->parm('data') );
391+
my $getData = decode_json( $req->parm('data') );
394392
my $content = create_print_layout( $getData->{'oids'}, $templates{'printing_contents'}, \%config, $httpd, $dbh );
395393
if ( $^O =~ /(MSWin)/ ) {
396394
$content = encode_utf8($content);
@@ -406,7 +404,7 @@ sub getNavigation {
406404
'strippedTitle' => 'Print',
407405
'navigation' => getNavigation( $req->url, \%siteMap, \%siteMapOrder ),
408406
'print_button' => format_print_button(),
409-
'content' => $content
407+
'content' => $content
410408
}
411409
)
412410
]
@@ -424,8 +422,7 @@ sub getNavigation {
424422
$statusMessage = 'OK';
425423
} elsif ( $req->parm('action') =~ /(save_config|save_pdf)/ ) {
426424
$statusMessage = 'Could not parse POST data.';
427-
my $postData =
428-
decode_json( $req->parm('data') );
425+
my $postData = decode_json( $req->parm('data') );
429426
if ( $req->parm('action') eq 'save_config' ) {
430427
$statusMessage = 'Could not save configuration.';
431428
my $cnf;
@@ -444,7 +441,7 @@ sub getNavigation {
444441
if ( $statusMessage eq 'OK' ) {
445442
$content->{'success'} = \1;
446443
}
447-
debug( Dumper( $content ), $debug > 1 );
444+
debug( Dumper($content), $debug > 1 );
448445
$content = encode_json($content);
449446
if ( $^O !~ /(MSWin)/ ) {
450447
$content = decode_utf8($content);
@@ -493,9 +490,8 @@ sub getNavigation {
493490
my $statusMessage = 'Error saving/loading config. Try restarting ttmp32gme.';
494491
if ( $req->parm('action') eq 'update' ) {
495492
$statusMessage = 'Could not save config. Try restarting ttmp32gme.';
496-
debug($req->parm('data'), $debug);
497-
my $configParams =
498-
decode_json( $req->parm('data') );
493+
debug( $req->parm('data'), $debug );
494+
my $configParams = decode_json( $req->parm('data') );
499495
my $cnf;
500496
( $cnf, $statusMessage ) = save_config($configParams);
501497
%config = %$cnf;
@@ -504,26 +500,26 @@ sub getNavigation {
504500
}
505501
if ( !$dbh->errstr && $statusMessage eq 'Success.' ) {
506502
$content->{'config'} = {
507-
'host' => $config{'host'},
508-
'port' => $config{'port'},
509-
'open_browser' => $config{'open_browser'},
510-
'audio_format' => $config{'audio_format'},
511-
'pen_language' => $config{'pen_language'},
512-
'library_path' => $config{'library_path'}
503+
'host' => $config{'host'},
504+
'port' => $config{'port'},
505+
'open_browser' => $config{'open_browser'},
506+
'audio_format' => $config{'audio_format'},
507+
'pen_language' => $config{'pen_language'},
508+
'library_path' => $config{'library_path'}
513509
};
514510
$content->{'success'} = \1;
515-
$statusCode = 200;
511+
$statusCode = 200;
516512
} else {
517513
if ( $dbh->errstr ) {
518514
$statusMessage = $dbh->errstr;
519515
}
520516
}
521-
debug( Dumper( $content ), $debug > 1 );
517+
debug( Dumper($content), $debug > 1 );
522518
$content = encode_json($content);
523-
debug('json config content: '.$content, $debug);
519+
debug( 'json config content: ' . $content, $debug );
524520
if ( $^O !~ /(MSWin)/ ) {
525521
$content = decode_utf8($content);
526-
debug('decoded json config content: '.$content, $debug);
522+
debug( 'decoded json config content: ' . $content, $debug );
527523
}
528524
$req->respond( [ $statusCode, $statusMessage, { 'Content-Type' => 'application/json' }, $content ] );
529525
}

0 commit comments

Comments
 (0)