hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ed20b5895eeca2b422b734a6346e98b5049c2c0d | 1,128 | pm | Perl | lib/Google/Ads/GoogleAds/V4/Services/RecommendationService/ApplyRecommendationResponse.pm | PierrickVoulet/google-ads-perl | bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4 | [
"Apache-2.0"
] | null | null | null | lib/Google/Ads/GoogleAds/V4/Services/RecommendationService/ApplyRecommendationResponse.pm | PierrickVoulet/google-ads-perl | bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4 | [
"Apache-2.0"
] | null | null | null | lib/Google/Ads/GoogleAds/V4/Services/RecommendationService/ApplyRecommendationResponse.pm | PierrickVoulet/google-ads-perl | bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4 | [
"Apache-2.0"
] | null | null | null | # Copyright 2020, Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package Google::Ads::GoogleAds::V4::Services::RecommendationService::ApplyRecommendationResponse;
use strict;
use warnings;
use base qw(Google::Ads::GoogleAds::BaseEntity);
use Google::Ads::GoogleAds::Utils::GoogleAdsHelper;
sub new {
my ($class, $args) = @_;
my $self = {
partialFailureError => $args->{partialFailureError},
results => $args->{results}};
# Delete the unassigned fields in this object for a more concise JSON payload
remove_unassigned_fields($self, $args);
bless $self, $class;
return $self;
}
1;
| 30.486486 | 97 | 0.72961 |
ed7b1c4b0c20ad0af0288d2643787679640e4970 | 152 | t | Perl | t/01_placktest.t | pepl/Monoceros | a088e233ab5a175db13070c13641f19bec124b9a | [
"Artistic-1.0"
] | 12 | 2015-03-11T13:20:26.000Z | 2016-12-27T13:44:00.000Z | t/01_placktest.t | pepl/Monoceros | a088e233ab5a175db13070c13641f19bec124b9a | [
"Artistic-1.0"
] | 4 | 2015-03-11T13:10:07.000Z | 2021-09-22T07:52:12.000Z | t/01_placktest.t | pepl/Monoceros | a088e233ab5a175db13070c13641f19bec124b9a | [
"Artistic-1.0"
] | 7 | 2015-03-11T14:10:20.000Z | 2021-09-01T12:40:21.000Z | use strict;
use Test::More;
use Plack::Handler::Monoceros;
use Plack::Test::Suite;
Plack::Test::Suite->run_server_tests('Monoceros');
done_testing();
| 16.888889 | 50 | 0.736842 |
ed4ffbef82acecbc562854a0724eeedae78b31a2 | 3,800 | pm | Perl | lib/Perl/Critic/Policy/RegularExpressions/RequireBracesForMultiline.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
] | null | null | null | lib/Perl/Critic/Policy/RegularExpressions/RequireBracesForMultiline.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
] | null | null | null | lib/Perl/Critic/Policy/RegularExpressions/RequireBracesForMultiline.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
] | null | null | null | package Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline;
use 5.006001;
use strict;
use warnings;
use Readonly;
use English qw(-no_match_vars);
use Carp;
use Perl::Critic::Utils qw{ :booleans :severities };
use base 'Perl::Critic::Policy';
our $VERSION = '1.134';
#-----------------------------------------------------------------------------
Readonly::Scalar my $DESC => q<Use '{' and '}' to delimit multi-line regexps>;
Readonly::Scalar my $EXPL => [242];
Readonly::Array my @EXTRA_BRACKETS => qw{ () [] <> };
#-----------------------------------------------------------------------------
sub supported_parameters {
return (
{
name => 'allow_all_brackets',
description =>
q[In addition to allowing '{}', allow '()', '[]', and '{}'.],
behavior => 'boolean',
},
);
}
sub default_severity { return $SEVERITY_LOWEST }
sub default_themes { return qw( core pbp cosmetic ) }
sub applies_to { return qw(PPI::Token::Regexp::Match
PPI::Token::Regexp::Substitute
PPI::Token::QuoteLike::Regexp) }
#-----------------------------------------------------------------------------
sub initialize_if_enabled {
my ( $self, $config ) = @_;
my %delimiters = ( q<{}> => 1 );
if ( $self->{_allow_all_brackets} ) {
@delimiters{ @EXTRA_BRACKETS } = (1) x @EXTRA_BRACKETS;
}
$self->{_allowed_delimiters} = \%delimiters;
return $TRUE;
}
#-----------------------------------------------------------------------------
sub violates {
my ( $self, $elem, undef ) = @_;
my $re = $elem->get_match_string();
return if $re !~ m/\n/xms;
my ($match_delim) = $elem->get_delimiters();
return if $self->{_allowed_delimiters}{$match_delim};
return $self->violation( $DESC, $EXPL, $elem );
}
1;
__END__
#-----------------------------------------------------------------------------
=pod
=head1 NAME
Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline - Use C<{> and C<}> to delimit multi-line regexps.
=head1 AFFILIATION
This Policy is part of the core L<Perl::Critic|Perl::Critic>
distribution.
=head1 DESCRIPTION
Long regular expressions are hard to read. A good practice is to use
the C<x> modifier and break the regex into multiple lines with
comments explaining the parts. But, with the usual C<//> delimiters,
the beginning and end can be hard to match, especially in a C<s///>
regexp. Instead, try using C<{}> characters to delimit your
expressions.
Compare these:
s/
<a \s+ href="([^"]+)">
(.*?)
</a>
/link=$1, text=$2/xms;
vs.
s{
<a \s+ href="([^"]+)">
(.*?)
</a>
}
{link=$1, text=$2}xms;
Is that an improvement? Marginally, but yes. The curly braces lead
the eye better.
=head1 CONFIGURATION
There is one option for this policy, C<allow_all_brackets>. If this
is true, then, in addition to allowing C<{}>, the other matched pairs
of C<()>, C<[]>, and C<< <> >> are allowed.
=head1 CREDITS
Initial development of this policy was supported by a grant from the
Perl Foundation.
=head1 AUTHOR
Chris Dolan <cdolan@cpan.org>
=head1 COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
| 24.203822 | 118 | 0.558684 |
edae76074765e6e224ec3b29c17cba834c7896cf | 421 | t | Perl | t/LibreCat/Hook/new_research_data_email.t | datango/LibreCat | d59a09af0ccaeef4c5fab82c2171510990c8d004 | [
"Artistic-1.0"
] | 42 | 2015-09-15T12:02:11.000Z | 2022-02-14T07:47:33.000Z | t/LibreCat/Hook/new_research_data_email.t | datango/LibreCat | d59a09af0ccaeef4c5fab82c2171510990c8d004 | [
"Artistic-1.0"
] | 887 | 2015-10-08T11:38:41.000Z | 2021-12-09T15:51:26.000Z | t/LibreCat/Hook/new_research_data_email.t | datango/LibreCat | d59a09af0ccaeef4c5fab82c2171510990c8d004 | [
"Artistic-1.0"
] | 20 | 2016-05-18T09:15:59.000Z | 2021-10-30T13:31:27.000Z | use strict;
use warnings FATAL => 'all';
use Test::More;
use Test::Exception;
use LibreCat -load => {layer_paths => [qw(t/layer)]};
my $pkg;
BEGIN {
$pkg = 'LibreCat::Hook::new_research_data_email';
use_ok $pkg;
}
require_ok $pkg;
my $x;
lives_ok {$x = $pkg->new()} 'lives_ok';
can_ok $x, 'fix';
my $data = {type => 'research_data', status => 'submitted', year => '2017'};
ok $x->fix($data);
done_testing;
| 16.84 | 76 | 0.624703 |
eda3f3ab201168ae1d38120715c0777d7490da96 | 2,561 | pm | Perl | auto-lib/Paws/DeviceFarm/ListInstanceProfiles.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 164 | 2015-01-08T14:58:53.000Z | 2022-02-20T19:16:24.000Z | auto-lib/Paws/DeviceFarm/ListInstanceProfiles.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 348 | 2015-01-07T22:08:38.000Z | 2022-01-27T14:34:44.000Z | auto-lib/Paws/DeviceFarm/ListInstanceProfiles.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z |
package Paws::DeviceFarm::ListInstanceProfiles;
use Moose;
has MaxResults => (is => 'ro', isa => 'Int', traits => ['NameInRequest'], request_name => 'maxResults' );
has NextToken => (is => 'ro', isa => 'Str', traits => ['NameInRequest'], request_name => 'nextToken' );
use MooseX::ClassAttribute;
class_has _api_call => (isa => 'Str', is => 'ro', default => 'ListInstanceProfiles');
class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::DeviceFarm::ListInstanceProfilesResult');
class_has _result_key => (isa => 'Str', is => 'ro');
1;
### main pod documentation begin ###
=head1 NAME
Paws::DeviceFarm::ListInstanceProfiles - Arguments for method ListInstanceProfiles on L<Paws::DeviceFarm>
=head1 DESCRIPTION
This class represents the parameters used for calling the method ListInstanceProfiles on the
L<AWS Device Farm|Paws::DeviceFarm> service. Use the attributes of this class
as arguments to method ListInstanceProfiles.
You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to ListInstanceProfiles.
=head1 SYNOPSIS
my $devicefarm = Paws->service('DeviceFarm');
my $ListInstanceProfilesResult = $devicefarm->ListInstanceProfiles(
MaxResults => 1, # OPTIONAL
NextToken => 'MyPaginationToken', # OPTIONAL
);
# Results:
my $InstanceProfiles = $ListInstanceProfilesResult->InstanceProfiles;
my $NextToken = $ListInstanceProfilesResult->NextToken;
# Returns a L<Paws::DeviceFarm::ListInstanceProfilesResult> object.
Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.
For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/devicefarm/ListInstanceProfiles>
=head1 ATTRIBUTES
=head2 MaxResults => Int
An integer that specifies the maximum number of items you want to
return in the API response.
=head2 NextToken => Str
An identifier that was returned from the previous call to this
operation, which can be used to return the next set of items in the
list.
=head1 SEE ALSO
This class forms part of L<Paws>, documenting arguments for method ListInstanceProfiles in L<Paws::DeviceFarm>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 33.697368 | 249 | 0.729793 |
ed69cc2ece4accee8ed26c7b827f5896f1dcd28d | 456 | pl | Perl | java/java2py/antlr-3.1.3/runtime/Perl5/examples/zero-one/t.pl | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 3,266 | 2017-08-06T16:51:46.000Z | 2022-03-30T07:34:24.000Z | java/java2py/antlr-3.1.3/runtime/Perl5/examples/zero-one/t.pl | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 150 | 2017-08-28T14:59:36.000Z | 2022-03-11T23:21:35.000Z | java/java2py/antlr-3.1.3/runtime/Perl5/examples/zero-one/t.pl | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 1,449 | 2017-08-06T17:40:59.000Z | 2022-03-31T12:03:24.000Z | #!/usr/bin/perl
use blib;
use English qw( -no_match_vars );
use ANTLR::Runtime::ANTLRStringStream;
use TLexer;
use strict;
use warnings;
my $input = ANTLR::Runtime::ANTLRStringStream->new({ input => '010' });
my $lexer = TLexer->new($input);
while (1) {
my $token = $lexer->next_token();
last if $token->get_type() == $TLexer::EOF;
print "type: ", $token->get_type(), "\n";
print "text: ", $token->get_text(), "\n";
print "\n";
}
| 19.826087 | 71 | 0.611842 |
ed3df7b0fdf0d7948c6da19c3298b4970e635a56 | 10,784 | pl | Perl | perl/vendor/lib/auto/share/dist/DateTime-Locale/hy.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | null | null | null | perl/vendor/lib/auto/share/dist/DateTime-Locale/hy.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | 3 | 2021-01-27T10:09:28.000Z | 2021-05-11T21:20:12.000Z | perl/vendor/lib/auto/share/dist/DateTime-Locale/hy.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | null | null | null | {
am_pm_abbreviated => [
"AM",
"PM",
],
available_formats => {
Bh => "B h-\N{U+056b}\N{U+0576}",
Bhm => "B h:mm-\N{U+056b}\N{U+0576}",
Bhms => "B h:mm:ss",
E => "ccc",
EBhm => "E B h:mm-\N{U+056b}\N{U+0576}",
EBhms => "E B h:mm:ss",
EHm => "E, HH:mm",
EHms => "E, HH:mm:ss",
Ed => "d, ccc",
Ehm => "E, h:mm a",
Ehms => "E, h:mm:ss a",
Gy => "G y \N{U+0569}.",
GyMMM => "G y \N{U+0569}. MMM",
GyMMMEd => "G y \N{U+0569}. MMM d, E",
GyMMMd => "d MMM, y \N{U+0569}.",
H => "H",
Hm => "H:mm",
Hms => "H:mm:ss",
Hmsv => "HH:mm:ss v",
Hmv => "HH:mm v",
M => "L",
MEd => "dd.MM, E",
MMM => "LLL",
MMMEd => "d MMM, E",
"MMMMW-count-one" => "MMMM W-\N{U+056b}\N{U+0576} \N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
"MMMMW-count-other" => "MMMM W-\N{U+0580}\N{U+0564} \N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
MMMMd => "MMMM d",
MMMd => "d MMM",
Md => "dd.MM",
d => "d",
h => "h a",
hm => "h:mm a",
hms => "h:mm:ss a",
hmsv => "h:mm:ss a v",
hmv => "h:mm a v",
ms => "mm:ss",
y => "y",
yM => "MM.y",
yMEd => "d.MM.y \N{U+0569}., E",
yMMM => "y \N{U+0569}. LLL",
yMMMEd => "y \N{U+0569}. MMM d, E",
yMMMM => "y \N{U+0569}\N{U+2024} LLLL",
yMMMd => "d MMM, y \N{U+0569}.",
yMd => "dd.MM.y",
yQQQ => "y \N{U+0569}. QQQ",
yQQQQ => "y \N{U+0569}. QQQQ",
"yw-count-one" => "Y \N{U+0569}\N{U+2024} w-\N{U+056b}\N{U+0576} \N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
"yw-count-other" => "Y \N{U+0569}\N{U+2024} w-\N{U+0580}\N{U+0564} \N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
},
code => "hy",
date_format_full => "y \N{U+0569}. MMMM d, EEEE",
date_format_long => "dd MMMM, y \N{U+0569}.",
date_format_medium => "dd MMM, y \N{U+0569}.",
date_format_short => "dd.MM.yy",
datetime_format_full => "{1}, {0}",
datetime_format_long => "{1}, {0}",
datetime_format_medium => "{1}, {0}",
datetime_format_short => "{1}, {0}",
day_format_abbreviated => [
"\N{U+0565}\N{U+0580}\N{U+056f}",
"\N{U+0565}\N{U+0580}\N{U+0584}",
"\N{U+0579}\N{U+0580}\N{U+0584}",
"\N{U+0570}\N{U+0576}\N{U+0563}",
"\N{U+0578}\N{U+0582}\N{U+0580}",
"\N{U+0577}\N{U+0562}\N{U+0569}",
"\N{U+056f}\N{U+056b}\N{U+0580}",
],
day_format_narrow => [
"\N{U+0535}",
"\N{U+0535}",
"\N{U+0549}",
"\N{U+0540}",
"\N{U+0548}",
"\N{U+0547}",
"\N{U+053f}",
],
day_format_wide => [
"\N{U+0565}\N{U+0580}\N{U+056f}\N{U+0578}\N{U+0582}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0565}\N{U+0580}\N{U+0565}\N{U+0584}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0579}\N{U+0578}\N{U+0580}\N{U+0565}\N{U+0584}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0570}\N{U+056b}\N{U+0576}\N{U+0563}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0578}\N{U+0582}\N{U+0580}\N{U+0562}\N{U+0561}\N{U+0569}",
"\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
"\N{U+056f}\N{U+056b}\N{U+0580}\N{U+0561}\N{U+056f}\N{U+056b}",
],
day_stand_alone_abbreviated => [
"\N{U+0565}\N{U+0580}\N{U+056f}",
"\N{U+0565}\N{U+0580}\N{U+0584}",
"\N{U+0579}\N{U+0580}\N{U+0584}",
"\N{U+0570}\N{U+0576}\N{U+0563}",
"\N{U+0578}\N{U+0582}\N{U+0580}",
"\N{U+0577}\N{U+0562}\N{U+0569}",
"\N{U+056f}\N{U+056b}\N{U+0580}",
],
day_stand_alone_narrow => [
"\N{U+0535}",
"\N{U+0535}",
"\N{U+0549}",
"\N{U+0540}",
"\N{U+0548}",
"\N{U+0547}",
"\N{U+053f}",
],
day_stand_alone_wide => [
"\N{U+0565}\N{U+0580}\N{U+056f}\N{U+0578}\N{U+0582}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0565}\N{U+0580}\N{U+0565}\N{U+0584}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0579}\N{U+0578}\N{U+0580}\N{U+0565}\N{U+0584}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0570}\N{U+056b}\N{U+0576}\N{U+0563}\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0569}\N{U+056b}",
"\N{U+0578}\N{U+0582}\N{U+0580}\N{U+0562}\N{U+0561}\N{U+0569}",
"\N{U+0577}\N{U+0561}\N{U+0562}\N{U+0561}\N{U+0569}",
"\N{U+056f}\N{U+056b}\N{U+0580}\N{U+0561}\N{U+056f}\N{U+056b}",
],
era_abbreviated => [
"\N{U+0574}.\N{U+0569}.\N{U+0561}.",
"\N{U+0574}.\N{U+0569}.",
],
era_narrow => [
"\N{U+0574}.\N{U+0569}.\N{U+0561}.",
"\N{U+0574}.\N{U+0569}.",
],
era_wide => [
"\N{U+0554}\N{U+0580}\N{U+056b}\N{U+057d}\N{U+057f}\N{U+0578}\N{U+057d}\N{U+056b}\N{U+0581} \N{U+0561}\N{U+057c}\N{U+0561}\N{U+057b}",
"\N{U+0554}\N{U+0580}\N{U+056b}\N{U+057d}\N{U+057f}\N{U+0578}\N{U+057d}\N{U+056b}\N{U+0581} \N{U+0570}\N{U+0565}\N{U+057f}\N{U+0578}",
],
first_day_of_week => 1,
glibc_date_1_format => "%a %b %e %H:%M:%S %Z %Y",
glibc_date_format => "%m/%d/%y",
glibc_datetime_format => "%a %b %e %H:%M:%S %Y",
glibc_time_12_format => "%I:%M:%S %p",
glibc_time_format => "%H:%M:%S",
language => "Armenian",
month_format_abbreviated => [
"\N{U+0570}\N{U+0576}\N{U+057e}",
"\N{U+0583}\N{U+057f}\N{U+057e}",
"\N{U+0574}\N{U+0580}\N{U+057f}",
"\N{U+0561}\N{U+057a}\N{U+0580}",
"\N{U+0574}\N{U+0575}\N{U+057d}",
"\N{U+0570}\N{U+0576}\N{U+057d}",
"\N{U+0570}\N{U+056c}\N{U+057d}",
"\N{U+0585}\N{U+0563}\N{U+057d}",
"\N{U+057d}\N{U+0565}\N{U+057a}",
"\N{U+0570}\N{U+0578}\N{U+056f}",
"\N{U+0576}\N{U+0578}\N{U+0575}",
"\N{U+0564}\N{U+0565}\N{U+056f}",
],
month_format_narrow => [
"\N{U+0540}",
"\N{U+0553}",
"\N{U+0544}",
"\N{U+0531}",
"\N{U+0544}",
"\N{U+0540}",
"\N{U+0540}",
"\N{U+0555}",
"\N{U+054d}",
"\N{U+0540}",
"\N{U+0546}",
"\N{U+0534}",
],
month_format_wide => [
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+0576}\N{U+057e}\N{U+0561}\N{U+0580}\N{U+056b}",
"\N{U+0583}\N{U+0565}\N{U+057f}\N{U+0580}\N{U+057e}\N{U+0561}\N{U+0580}\N{U+056b}",
"\N{U+0574}\N{U+0561}\N{U+0580}\N{U+057f}\N{U+056b}",
"\N{U+0561}\N{U+057a}\N{U+0580}\N{U+056b}\N{U+056c}\N{U+056b}",
"\N{U+0574}\N{U+0561}\N{U+0575}\N{U+056b}\N{U+057d}\N{U+056b}",
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+0576}\N{U+056b}\N{U+057d}\N{U+056b}",
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+056c}\N{U+056b}\N{U+057d}\N{U+056b}",
"\N{U+0585}\N{U+0563}\N{U+0578}\N{U+057d}\N{U+057f}\N{U+0578}\N{U+057d}\N{U+056b}",
"\N{U+057d}\N{U+0565}\N{U+057a}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}\N{U+056b}",
"\N{U+0570}\N{U+0578}\N{U+056f}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}\N{U+056b}",
"\N{U+0576}\N{U+0578}\N{U+0575}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}\N{U+056b}",
"\N{U+0564}\N{U+0565}\N{U+056f}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}\N{U+056b}",
],
month_stand_alone_abbreviated => [
"\N{U+0570}\N{U+0576}\N{U+057e}",
"\N{U+0583}\N{U+057f}\N{U+057e}",
"\N{U+0574}\N{U+0580}\N{U+057f}",
"\N{U+0561}\N{U+057a}\N{U+0580}",
"\N{U+0574}\N{U+0575}\N{U+057d}",
"\N{U+0570}\N{U+0576}\N{U+057d}",
"\N{U+0570}\N{U+056c}\N{U+057d}",
"\N{U+0585}\N{U+0563}\N{U+057d}",
"\N{U+057d}\N{U+0565}\N{U+057a}",
"\N{U+0570}\N{U+0578}\N{U+056f}",
"\N{U+0576}\N{U+0578}\N{U+0575}",
"\N{U+0564}\N{U+0565}\N{U+056f}",
],
month_stand_alone_narrow => [
"\N{U+0540}",
"\N{U+0553}",
"\N{U+0544}",
"\N{U+0531}",
"\N{U+0544}",
"\N{U+0540}",
"\N{U+0540}",
"\N{U+0555}",
"\N{U+054d}",
"\N{U+0540}",
"\N{U+0546}",
"\N{U+0534}",
],
month_stand_alone_wide => [
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+0576}\N{U+057e}\N{U+0561}\N{U+0580}",
"\N{U+0583}\N{U+0565}\N{U+057f}\N{U+0580}\N{U+057e}\N{U+0561}\N{U+0580}",
"\N{U+0574}\N{U+0561}\N{U+0580}\N{U+057f}",
"\N{U+0561}\N{U+057a}\N{U+0580}\N{U+056b}\N{U+056c}",
"\N{U+0574}\N{U+0561}\N{U+0575}\N{U+056b}\N{U+057d}",
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+0576}\N{U+056b}\N{U+057d}",
"\N{U+0570}\N{U+0578}\N{U+0582}\N{U+056c}\N{U+056b}\N{U+057d}",
"\N{U+0585}\N{U+0563}\N{U+0578}\N{U+057d}\N{U+057f}\N{U+0578}\N{U+057d}",
"\N{U+057d}\N{U+0565}\N{U+057a}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}",
"\N{U+0570}\N{U+0578}\N{U+056f}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}",
"\N{U+0576}\N{U+0578}\N{U+0575}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}",
"\N{U+0564}\N{U+0565}\N{U+056f}\N{U+057f}\N{U+0565}\N{U+0574}\N{U+0562}\N{U+0565}\N{U+0580}",
],
name => "Armenian",
native_language => "\N{U+0570}\N{U+0561}\N{U+0575}\N{U+0565}\N{U+0580}\N{U+0565}\N{U+0576}",
native_name => "\N{U+0570}\N{U+0561}\N{U+0575}\N{U+0565}\N{U+0580}\N{U+0565}\N{U+0576}",
native_script => undef,
native_territory => undef,
native_variant => undef,
quarter_format_abbreviated => [
"1-\N{U+056b}\N{U+0576} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"2-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"3-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"4-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
],
quarter_format_narrow => [
1,
2,
3,
4,
],
quarter_format_wide => [
"1-\N{U+056b}\N{U+0576} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"2-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"3-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"4-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
],
quarter_stand_alone_abbreviated => [
"1-\N{U+056b}\N{U+0576} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"2-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"3-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
"4-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0574}\N{U+057d}.",
],
quarter_stand_alone_narrow => [
1,
2,
3,
4,
],
quarter_stand_alone_wide => [
"1-\N{U+056b}\N{U+0576} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"2-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"3-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
"4-\N{U+0580}\N{U+0564} \N{U+0565}\N{U+057c}\N{U+0561}\N{U+0574}\N{U+057d}\N{U+0575}\N{U+0561}\N{U+056f}",
],
script => undef,
territory => undef,
time_format_full => "HH:mm:ss zzzz",
time_format_long => "HH:mm:ss z",
time_format_medium => "HH:mm:ss",
time_format_short => "HH:mm",
variant => undef,
version => 36,
}
| 39.501832 | 138 | 0.510015 |
ed9391745bdd1db522528a3a40b38bb0476281b1 | 3,461 | pm | Perl | perl/vendor/lib/Mojo/EventEmitter.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 896 | 2015-01-01T10:56:31.000Z | 2018-09-06T02:12:44.000Z | perl/vendor/lib/Mojo/EventEmitter.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 488 | 2015-01-12T14:59:58.000Z | 2018-09-07T21:31:02.000Z | perl/vendor/lib/Mojo/EventEmitter.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 334 | 2015-01-12T14:34:48.000Z | 2018-09-06T10:15:38.000Z | package Mojo::EventEmitter;
use Mojo::Base -base;
use Scalar::Util qw(blessed weaken);
use constant DEBUG => $ENV{MOJO_EVENTEMITTER_DEBUG} || 0;
sub catch { $_[0]->on(error => $_[1]) and return $_[0] }
sub emit {
my ($self, $name) = (shift, shift);
if (my $s = $self->{events}{$name}) {
warn "-- Emit $name in @{[blessed $self]} (@{[scalar @$s]})\n" if DEBUG;
for my $cb (@$s) { $self->$cb(@_) }
}
else {
warn "-- Emit $name in @{[blessed $self]} (0)\n" if DEBUG;
die "@{[blessed $self]}: $_[0]" if $name eq 'error';
}
return $self;
}
sub has_subscribers { !!shift->{events}{shift()} }
sub on { push @{$_[0]{events}{$_[1]}}, $_[2] and return $_[2] }
sub once {
my ($self, $name, $cb) = @_;
weaken $self;
my $wrapper = sub {
$self->unsubscribe($name => __SUB__);
$cb->(@_);
};
$self->on($name => $wrapper);
return $wrapper;
}
sub subscribers { shift->{events}{shift()} //= [] }
sub unsubscribe {
my ($self, $name, $cb) = @_;
# One
if ($cb) {
$self->{events}{$name} = [grep { $cb ne $_ } @{$self->{events}{$name}}];
delete $self->{events}{$name} unless @{$self->{events}{$name}};
}
# All
else { delete $self->{events}{$name} }
return $self;
}
1;
=encoding utf8
=head1 NAME
Mojo::EventEmitter - Event emitter base class
=head1 SYNOPSIS
package Cat;
use Mojo::Base 'Mojo::EventEmitter', -signatures;
# Emit events
sub poke ($self) { $self->emit(roar => 3) }
package main;
# Subscribe to events
my $tiger = Cat->new;
$tiger->on(roar => sub ($tiger, $times) { say 'RAWR!' for 1 .. $times });
$tiger->poke;
=head1 DESCRIPTION
L<Mojo::EventEmitter> is a simple base class for event emitting objects.
=head1 EVENTS
L<Mojo::EventEmitter> can emit the following events.
=head2 error
$e->on(error => sub ($e, $err) {...});
This is a special event for errors, it will not be emitted directly by this class, but is fatal if unhandled.
Subclasses may choose to emit it, but are not required to do so.
$e->on(error => sub ($e, $err) { say "This looks bad: $err" });
=head1 METHODS
L<Mojo::EventEmitter> inherits all methods from L<Mojo::Base> and implements the following new ones.
=head2 catch
$e = $e->catch(sub {...});
Subscribe to L</"error"> event.
# Longer version
$e->on(error => sub {...});
=head2 emit
$e = $e->emit('foo');
$e = $e->emit('foo', 123);
Emit event.
=head2 has_subscribers
my $bool = $e->has_subscribers('foo');
Check if event has subscribers.
=head2 on
my $cb = $e->on(foo => sub {...});
Subscribe to event.
$e->on(foo => sub ($e, @args) {...});
=head2 once
my $cb = $e->once(foo => sub {...});
Subscribe to event and unsubscribe again after it has been emitted once.
$e->once(foo => sub ($e, @args) {...});
=head2 subscribers
my $subscribers = $e->subscribers('foo');
All subscribers for event.
# Unsubscribe last subscriber
$e->unsubscribe(foo => $e->subscribers('foo')->[-1]);
# Change order of subscribers
@{$e->subscribers('foo')} = reverse @{$e->subscribers('foo')};
=head2 unsubscribe
$e = $e->unsubscribe('foo');
$e = $e->unsubscribe(foo => $cb);
Unsubscribe from event.
=head1 DEBUGGING
You can set the C<MOJO_EVENTEMITTER_DEBUG> environment variable to get some advanced diagnostics information printed to
C<STDERR>.
MOJO_EVENTEMITTER_DEBUG=1
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
=cut
| 20.122093 | 119 | 0.60965 |
ed2e790bf92aff93f74fdc05985010a54fe22de0 | 3,884 | pl | Perl | png-test.pl | greg-kennedy/t7g-image-dump | 6edd77bbc91d59bda876e9e150542a3dd8042ac2 | [
"Unlicense"
] | null | null | null | png-test.pl | greg-kennedy/t7g-image-dump | 6edd77bbc91d59bda876e9e150542a3dd8042ac2 | [
"Unlicense"
] | 1 | 2021-10-17T17:57:46.000Z | 2021-10-17T17:57:46.000Z | png-test.pl | greg-kennedy/FPAdventuresBot | 6edd77bbc91d59bda876e9e150542a3dd8042ac2 | [
"Unlicense"
] | null | null | null | #!/usr/bin/env perl
use strict;
use warnings;
use v5.014;
use Data::Dumper;
### A tool to detect duplicate or problem PNG images.
### Recursively searches the folders for png images,
### decodes them to flat BMP, then stores the shasum
### in a hash along with dimensions.
### Solid-color frames are also detected and printed.
# fudge @INC
#use FindBin qw( $RealBin );
#use lib $RealBin;
use Image::PNG::Libpng qw(:all);
use Image::PNG::Const qw/PNG_TRANSFORM_EXPAND PNG_TRANSFORM_STRIP_ALPHA/;
use Digest::SHA qw(sha1_hex);
use File::Basename;
### Helper Functions
# Recursively read a directory and add results to an array.
sub rec_read_dir
{
my $d = shift;
my @files;
opendir(my $dh, $d) || die "Can't open directory $d: $!\n";
while (readdir $dh) {
next if substr($_,0,1) eq '.';
my $path = $d . '/' . $_;
if (-d $path) {
push @files, rec_read_dir($path);
} elsif (-f $path) {
if ($path =~ m/\.png$/) {
push @files, $path;
}
}
}
closedir($dh);
return @files;
}
# check args
if (scalar @ARGV != 1) { die "Usage: $0 /path/to/images" }
# Get complete list of files
my %contents;
my $peak_red = 0;
my $peak_green = 0;
my $peak_blue = 0;
my @files = rec_read_dir($ARGV[0]);
foreach my $file (@files) {
print STDERR ". Testing $file...";
# decode the image
my $png = read_png_file($file, transforms => PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_STRIP_ALPHA);
if ( $png->get_channels() == 1 ) {
say STDERR " Is grayscale, skipping.";
say "echo $file # GRAYSCALE";
next;
}
# get the rows
my $rows = $png->get_rows ();
# concatenated final file content
my $content;
# check for all pixels same as first
my $pixels_differ = 0;
my $hot_pixels = 0;
my $black_pixels = 0;
my $white_pixels = 0;
my @first_pixel = unpack 'C3', $rows->[0];
foreach my $row (@$rows) {
# append rows together
$content .= $row;
# search for black frame, hot pixel, and peak RGB
my @pixels = unpack 'C*', $row;
while (@pixels) {
my ($r, $g, $b) = splice @pixels, 0, 3;
if ($r == 0 && $g == 0 && $b == 0) { $black_pixels ++ }
elsif ($r == 255 && $g == 255 && $b == 255) { $white_pixels ++ }
elsif ( ( $r == 0 || $r == 255) &&
( $g == 0 || $g == 255) &&
( $b == 0 || $b == 255) ) {
$hot_pixels ++;
} else
{
# only test pixel-difference for not-hot, not-black, not-white pixels.
if ($first_pixel[0] != $r ||
$first_pixel[1] != $g ||
$first_pixel[2] != $b) {
$pixels_differ = 1;
if ($r > $peak_red) { $peak_red = $r }
if ($g > $peak_green) { $peak_green = $g }
if ($b > $peak_blue) { $peak_blue = $b }
}
}
}
}
# black frame
if (! $pixels_differ) {
say STDERR "Solid frame!";
say "rm $file";
next;
}
# lots of black (transparent frame?)
if ($black_pixels > 10000) {
print STDERR " ($black_pixels black_pixels) ";
say "echo $file # $black_pixels";
}
# checksum the data
my $sha1 = sha1_hex($content);
say STDERR $sha1;
push @{$contents{$sha1}}, $file;
}
# output some stats
say STDERR "====================================";
say STDERR "Peak RGB values were ($peak_red, $peak_green, $peak_blue)";
# print all dupes
foreach my $sum (sort keys %contents) {
if (scalar @{$contents{$sum}} > 1) {
say "# SUM: $sum";
my @dupes = sort @{$contents{$sum}};
# build the "mv" string to keep one file
my ($name,$path,$suffix) = fileparse($dupes[0],'\.png');
my $final_filename = $path;
$final_filename .= join('+', map { (fileparse($_, '\.png'))[0] } @dupes) . $suffix;
# output the mv string
say "mv $dupes[0] $final_filename";
for (my $i = 1; $i < scalar @dupes; $i ++) {
say "rm $dupes[$i]";
}
say "";
}
}
| 23.119048 | 97 | 0.556385 |
ed7a12a7e561e00b224bc120ddd5b1405efc5d45 | 473 | pm | Perl | lib/VMOMI/DasHostIsolatedEvent.pm | restump/p5-vmomi | e2571d72a1f552ddd0258ad289ec229d8d12a147 | [
"Apache-2.0"
] | 1 | 2020-07-22T21:56:34.000Z | 2020-07-22T21:56:34.000Z | lib/VMOMI/DasHostIsolatedEvent.pm | restump/p5-vmomi | e2571d72a1f552ddd0258ad289ec229d8d12a147 | [
"Apache-2.0"
] | null | null | null | lib/VMOMI/DasHostIsolatedEvent.pm | restump/p5-vmomi | e2571d72a1f552ddd0258ad289ec229d8d12a147 | [
"Apache-2.0"
] | 1 | 2016-07-19T19:56:09.000Z | 2016-07-19T19:56:09.000Z | package VMOMI::DasHostIsolatedEvent;
use parent 'VMOMI::ClusterEvent';
use strict;
use warnings;
our @class_ancestors = (
'ClusterEvent',
'Event',
'DynamicData',
);
our @class_members = (
['isolatedHost', 'HostEventArgument', 0, ],
);
sub get_class_ancestors {
return @class_ancestors;
}
sub get_class_members {
my $class = shift;
my @super_members = $class->SUPER::get_class_members();
return (@super_members, @class_members);
}
1;
| 16.892857 | 59 | 0.676533 |
edb542fca4866c3410911c425eb473f6ea309c91 | 24,076 | pm | Perl | vendor/Image-ExifTool-10.02/lib/Image/ExifTool/Photoshop.pm | mudasobwa/exifice | 804955d5104358f1e47589492220ae6fea8c0210 | [
"MIT"
] | 3 | 2016-09-01T13:09:37.000Z | 2019-10-22T04:27:32.000Z | vendor/Image-ExifTool-10.02/lib/Image/ExifTool/Photoshop.pm | mudasobwa/exifice | 804955d5104358f1e47589492220ae6fea8c0210 | [
"MIT"
] | 11 | 2020-03-03T20:32:27.000Z | 2022-03-30T22:14:53.000Z | tools/fits-1.2.0/tools/exiftool/perl/lib/Image/ExifTool/Photoshop.pm | uvalib/Libra2 | e7bb81b153ca0ac080ae2480ebf9b5e60e5b650a | [
"Apache-2.0"
] | null | null | null | #------------------------------------------------------------------------------
# File: Photoshop.pm
#
# Description: Read/write Photoshop IRB meta information
#
# Revisions: 02/06/2004 - P. Harvey Created
# 02/25/2004 - P. Harvey Added hack for problem with old photoshops
# 10/04/2004 - P. Harvey Added a bunch of tags (ref Image::MetaData::JPEG)
# but left most of them commented out until I have enough
# information to write PrintConv routines for them to
# display something useful
# 07/08/2005 - P. Harvey Added support for reading PSD files
# 01/07/2006 - P. Harvey Added PSD write support
# 11/04/2006 - P. Harvey Added handling of resource name
#
# References: 1) http://www.fine-view.com/jp/lab/doc/ps6ffspecsv2.pdf
# 2) http://www.ozhiker.com/electronics/pjmt/jpeg_info/irb_jpeg_qual.html
# 3) Matt Mueller private communication (tests with PS CS2)
# 4) http://www.fileformat.info/format/psd/egff.htm
# 5) http://www.telegraphics.com.au/svn/psdparse/trunk/resources.c
# 6) http://libpsd.graphest.com/files/Photoshop%20File%20Formats.pdf
# 7) http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
#------------------------------------------------------------------------------
package Image::ExifTool::Photoshop;
use strict;
use vars qw($VERSION $AUTOLOAD $iptcDigestInfo);
use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.47';
sub ProcessPhotoshop($$$);
sub WritePhotoshop($$$);
# map of where information is stored in PSD image
my %psdMap = (
IPTC => 'Photoshop',
XMP => 'Photoshop',
EXIFInfo => 'Photoshop',
IFD0 => 'EXIFInfo',
IFD1 => 'IFD0',
ICC_Profile => 'Photoshop',
ExifIFD => 'IFD0',
GPS => 'IFD0',
SubIFD => 'IFD0',
GlobParamIFD => 'IFD0',
PrintIM => 'IFD0',
InteropIFD => 'ExifIFD',
MakerNotes => 'ExifIFD',
);
# tag information for PhotoshopThumbnail and PhotoshopBGRThumbnail
my %thumbnailInfo = (
Writable => 'undef',
Protected => 1,
RawConv => 'my $img=substr($val,0x1c); $self->ValidateImage(\$img,$tag)',
ValueConvInv => q{
my $et = new Image::ExifTool;
my @tags = qw{ImageWidth ImageHeight FileType};
my $info = $et->ImageInfo(\$val, @tags);
my ($w, $h, $type) = @$info{@tags};
$w and $h and $type eq 'JPEG' or warn("Not a valid JPEG image\n"), return undef;
my $wbytes = int(($w * 24 + 31) / 32) * 4;
return pack('N6n2', 1, $w, $h, $wbytes, $wbytes * $h, length($val), 24, 1) . $val;
},
);
# Photoshop APP13 tag table
# (set Unknown flag for information we don't want to display normally)
%Image::ExifTool::Photoshop::Main = (
GROUPS => { 2 => 'Image' },
PROCESS_PROC => \&ProcessPhotoshop,
WRITE_PROC => \&WritePhotoshop,
0x03e8 => { Unknown => 1, Name => 'Photoshop2Info' },
0x03e9 => { Unknown => 1, Name => 'MacintoshPrintInfo' },
0x03ea => { Unknown => 1, Name => 'XMLData', Binary => 1 }, #PH
0x03eb => { Unknown => 1, Name => 'Photoshop2ColorTable' },
0x03ed => {
Name => 'ResolutionInfo',
SubDirectory => {
TagTable => 'Image::ExifTool::Photoshop::Resolution',
},
},
0x03ee => {
Name => 'AlphaChannelsNames',
ValueConv => 'Image::ExifTool::Photoshop::ConvertPascalString($self,$val)',
},
0x03ef => { Unknown => 1, Name => 'DisplayInfo' },
0x03f0 => { Unknown => 1, Name => 'PStringCaption' },
0x03f1 => { Unknown => 1, Name => 'BorderInformation' },
0x03f2 => { Unknown => 1, Name => 'BackgroundColor' },
0x03f3 => { Unknown => 1, Name => 'PrintFlags', Format => 'int8u' },
0x03f4 => { Unknown => 1, Name => 'BW_HalftoningInfo' },
0x03f5 => { Unknown => 1, Name => 'ColorHalftoningInfo' },
0x03f6 => { Unknown => 1, Name => 'DuotoneHalftoningInfo' },
0x03f7 => { Unknown => 1, Name => 'BW_TransferFunc' },
0x03f8 => { Unknown => 1, Name => 'ColorTransferFuncs' },
0x03f9 => { Unknown => 1, Name => 'DuotoneTransferFuncs' },
0x03fa => { Unknown => 1, Name => 'DuotoneImageInfo' },
0x03fb => { Unknown => 1, Name => 'EffectiveBW', Format => 'int8u' },
0x03fc => { Unknown => 1, Name => 'ObsoletePhotoshopTag1' },
0x03fd => { Unknown => 1, Name => 'EPSOptions' },
0x03fe => { Unknown => 1, Name => 'QuickMaskInfo' },
0x03ff => { Unknown => 1, Name => 'ObsoletePhotoshopTag2' },
0x0400 => { Unknown => 1, Name => 'TargetLayerID', Format => 'int16u' }, # (LayerStateInfo)
0x0401 => { Unknown => 1, Name => 'WorkingPath' },
0x0402 => { Unknown => 1, Name => 'LayersGroupInfo', Format => 'int16u' },
0x0403 => { Unknown => 1, Name => 'ObsoletePhotoshopTag3' },
0x0404 => {
Name => 'IPTCData',
SubDirectory => {
DirName => 'IPTC',
TagTable => 'Image::ExifTool::IPTC::Main',
},
},
0x0405 => { Unknown => 1, Name => 'RawImageMode' },
0x0406 => { #2
Name => 'JPEG_Quality',
SubDirectory => {
TagTable => 'Image::ExifTool::Photoshop::JPEG_Quality',
},
},
0x0408 => { Unknown => 1, Name => 'GridGuidesInfo' },
0x0409 => {
Name => 'PhotoshopBGRThumbnail',
Notes => 'this is a JPEG image, but in BGR format instead of RGB',
%thumbnailInfo,
Groups => { 2 => 'Preview' },
},
0x040a => {
Name => 'CopyrightFlag',
Writable => 'int8u',
Groups => { 2 => 'Author' },
ValueConv => 'join(" ",unpack("C*", $val))',
ValueConvInv => 'pack("C*",split(" ",$val))',
PrintConv => { #3
0 => 'False',
1 => 'True',
},
},
0x040b => {
Name => 'URL',
Writable => 'string',
Groups => { 2 => 'Author' },
},
0x040c => {
Name => 'PhotoshopThumbnail',
%thumbnailInfo,
Groups => { 2 => 'Preview' },
},
0x040d => {
Name => 'GlobalAngle',
Writable => 'int32u',
ValueConv => 'unpack("N",$val)',
ValueConvInv => 'pack("N",$val)',
},
0x040e => { Unknown => 1, Name => 'ColorSamplersResource' },
0x040f => {
Name => 'ICC_Profile',
SubDirectory => {
TagTable => 'Image::ExifTool::ICC_Profile::Main',
},
},
0x0410 => { Unknown => 1, Name => 'Watermark', Format => 'int8u' },
0x0411 => { Unknown => 1, Name => 'ICC_Untagged', Format => 'int8u' },
0x0412 => { Unknown => 1, Name => 'EffectsVisible', Format => 'int8u' },
0x0413 => { Unknown => 1, Name => 'SpotHalftone' },
0x0414 => { Unknown => 1, Name => 'IDsBaseValue', Description => 'IDs Base Value', Format => 'int32u' },
0x0415 => { Unknown => 1, Name => 'UnicodeAlphaNames' },
0x0416 => { Unknown => 1, Name => 'IndexedColourTableCount', Format => 'int16u' },
0x0417 => { Unknown => 1, Name => 'TransparentIndex', Format => 'int16u' },
0x0419 => {
Name => 'GlobalAltitude',
Writable => 'int32u',
ValueConv => 'unpack("N",$val)',
ValueConvInv => 'pack("N",$val)',
},
0x041a => { Unknown => 1, Name => 'Slices' },
0x041b => { Unknown => 1, Name => 'WorkflowURL' },
0x041c => { Unknown => 1, Name => 'JumpToXPEP' },
0x041d => { Unknown => 1, Name => 'AlphaIdentifiers' },
0x041e => { Unknown => 1, Name => 'URL_List' },
0x0421 => { Unknown => 1, Name => 'VersionInfo' },
0x0422 => {
Name => 'EXIFInfo', #PH (Found in EPS and PSD files)
SubDirectory => {
TagTable=> 'Image::ExifTool::Exif::Main',
ProcessProc => \&Image::ExifTool::ProcessTIFF,
WriteProc => \&Image::ExifTool::WriteTIFF,
},
},
0x0423 => { Unknown => 1, Name => 'ExifInfo2', Binary => 1 }, #5
0x0424 => {
Name => 'XMP',
SubDirectory => {
TagTable => 'Image::ExifTool::XMP::Main',
},
},
0x0425 => {
Name => 'IPTCDigest',
Writable => 'string',
Protected => 1,
Notes => q{
this tag indicates provides a way for XMP-aware applications to indicate
that the XMP is synchronized with the IPTC. When writing, special values of
"new" and "old" represent the digests of the IPTC from the edited and
original files respectively, and are undefined if the IPTC does not exist in
the respective file. Set this to "new" as an indication that the XMP is
synchronized with the IPTC
},
# also note the 'new' feature requires that the IPTC comes before this tag is written
ValueConv => 'unpack("H*", $val)',
ValueConvInv => q{
if (lc($val) eq 'new' or lc($val) eq 'old') {
{
local $SIG{'__WARN__'} = sub { };
return lc($val) if eval { require Digest::MD5 };
}
warn "Digest::MD5 must be installed\n";
return undef;
}
return pack('H*', $val) if $val =~ /^[0-9a-f]{32}$/i;
warn "Value must be 'new', 'old' or 32 hexadecimal digits\n";
return undef;
}
},
0x0426 => { Unknown => 1, Name => 'PrintScale' }, #5
0x0428 => { Unknown => 1, Name => 'PixelAspectRatio' }, #5
0x0429 => { Unknown => 1, Name => 'LayerComps' }, #5
0x042a => { Unknown => 1, Name => 'AlternateDuotoneColors' }, #5
0x042b => { Unknown => 1, Name => 'AlternateSpotColors' }, #5
0x042d => { #7
Name => 'LayerSelectionIDs',
Description => 'Layer Selection IDs',
Unknown => 1,
ValueConv => q{
my ($n, @a) = unpack("nN*",$val);
$#a = $n - 1 if $n > @a;
return join(' ', @a);
},
},
0x042e => { Unknown => 1, Name => 'HDRToningInfo' }, #7
0x042f => { Unknown => 1, Name => 'PrintInfo' }, #7
0x0430 => { Unknown => 1, Name => 'LayerGroupsEnabledID', Format => 'int8u' }, #7
0x0431 => { Unknown => 1, Name => 'ColorSamplersResource2' }, #7
0x0432 => { Unknown => 1, Name => 'MeasurementScale' }, #7
0x0433 => { Unknown => 1, Name => 'TimelineInfo' }, #7
0x0434 => { Unknown => 1, Name => 'SheetDisclosure' }, #7
0x0435 => { Unknown => 1, Name => 'DisplayInfo' }, #7
0x0436 => { Unknown => 1, Name => 'OnionSkins' }, #7
0x0438 => { Unknown => 1, Name => 'CountInfo' }, #7
0x043a => { Unknown => 1, Name => 'PrintInfo2' }, #7
0x043b => { Unknown => 1, Name => 'PrintStyle' }, #7
0x043c => { Unknown => 1, Name => 'MacintoshNSPrintInfo' }, #7
0x043d => { Unknown => 1, Name => 'WindowsDEVMODE' }, #7
0x043e => { Unknown => 1, Name => 'AutoSaveFilePath' }, #7
0x043f => { Unknown => 1, Name => 'AutoSaveFormat' }, #7
0x0440 => { Unknown => 1, Name => 'PathSelectionState' }, #7
# 0x07d0-0x0bb6 Path information
0x0bb7 => {
Name => 'ClippingPathName',
# convert from a Pascal string (ignoring 6 bytes of unknown data after string)
ValueConv => q{
my $len = ord($val);
$val = substr($val, 0, $len+1) if $len < length($val);
return Image::ExifTool::Photoshop::ConvertPascalString($self,$val);
},
},
0x0bb8 => { Unknown => 1, Name => 'OriginPathInfo' }, #7
# 0x0fa0-0x1387 - plug-in resources (ref 7)
0x1b58 => { Unknown => 1, Name => 'ImageReadyVariables' }, #7
0x1b59 => { Unknown => 1, Name => 'ImageReadyDataSets' }, #7
0x1f40 => { Unknown => 1, Name => 'LightroomWorkflow' }, #7
0x2710 => { Unknown => 1, Name => 'PrintFlagsInfo' },
);
# Photoshop JPEG quality record (ref 2)
%Image::ExifTool::Photoshop::JPEG_Quality = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
FORMAT => 'int16s',
GROUPS => { 2 => 'Image' },
0 => {
Name => 'PhotoshopQuality',
Writable => 1,
PrintConv => '$val + 4',
PrintConvInv => '$val - 4',
},
1 => {
Name => 'PhotoshopFormat',
PrintConv => {
0x0000 => 'Standard',
0x0001 => 'Optimised',
0x0101 => 'Progressive',
},
},
2 => {
Name => 'ProgressiveScans',
PrintConv => {
1 => '3 Scans',
2 => '4 Scans',
3 => '5 Scans',
},
},
);
# Photoshop resolution information #PH
%Image::ExifTool::Photoshop::Resolution = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
FORMAT => 'int16u',
FIRST_ENTRY => 0,
WRITABLE => 1,
GROUPS => { 2 => 'Image' },
0 => {
Name => 'XResolution',
Format => 'int32u',
Priority => 0,
ValueConv => '$val / 0x10000',
ValueConvInv => 'int($val * 0x10000 + 0.5)',
PrintConv => 'int($val * 100 + 0.5) / 100',
PrintConvInv => '$val',
},
2 => {
Name => 'DisplayedUnitsX',
PrintConv => {
1 => 'inches',
2 => 'cm',
},
},
4 => {
Name => 'YResolution',
Format => 'int32u',
Priority => 0,
ValueConv => '$val / 0x10000',
ValueConvInv => 'int($val * 0x10000 + 0.5)',
PrintConv => 'int($val * 100 + 0.5) / 100',
PrintConvInv => '$val',
},
6 => {
Name => 'DisplayedUnitsY',
PrintConv => {
1 => 'inches',
2 => 'cm',
},
},
);
# Photoshop PSD file header
%Image::ExifTool::Photoshop::Header = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
FORMAT => 'int16u',
GROUPS => { 2 => 'Image' },
NOTES => 'This information is found in the PSD file header.',
6 => 'NumChannels',
7 => { Name => 'ImageHeight', Format => 'int32u' },
9 => { Name => 'ImageWidth', Format => 'int32u' },
11 => 'BitDepth',
12 => {
Name => 'ColorMode',
PrintConvColumns => 2,
PrintConv => {
0 => 'Bitmap',
1 => 'Grayscale',
2 => 'Indexed',
3 => 'RGB',
4 => 'CMYK',
7 => 'Multichannel',
8 => 'Duotone',
9 => 'Lab',
},
},
);
# tags for unknown resource types
%Image::ExifTool::Photoshop::Unknown = (
GROUPS => { 2 => 'Unknown' },
);
# define reference to IPTCDigest tagInfo hash for convenience
$iptcDigestInfo = $Image::ExifTool::Photoshop::Main{0x0425};
#------------------------------------------------------------------------------
# AutoLoad our writer routines when necessary
#
sub AUTOLOAD
{
return Image::ExifTool::DoAutoLoad($AUTOLOAD, @_);
}
#------------------------------------------------------------------------------
# Convert pascal string(s) to something we can use
# Inputs: 1) Pascal string data
# Returns: Strings, concatenated with ', '
sub ConvertPascalString($$)
{
my ($et, $inStr) = @_;
my $outStr = '';
my $len = length($inStr);
my $i=0;
while ($i < $len) {
my $n = ord(substr($inStr, $i, 1));
last if $i + $n >= $len;
$i and $outStr .= ', ';
$outStr .= substr($inStr, $i+1, $n);
$i += $n + 1;
}
my $charset = $et->Options('CharsetPhotoshop') || 'Latin';
return $et->Decode($outStr, $charset);
}
#------------------------------------------------------------------------------
# Process Photoshop APP13 record
# Inputs: 0) ExifTool object reference, 1) Reference to directory information
# 2) Tag table reference
# Returns: 1 on success
sub ProcessPhotoshop($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
my $pos = $$dirInfo{DirStart};
my $dirEnd = $pos + $$dirInfo{DirLen};
my $verbose = $et->Options('Verbose');
my $success = 0;
SetByteOrder('MM'); # Photoshop is always big-endian
$verbose and $et->VerboseDir('Photoshop', 0, $$dirInfo{DirLen});
# scan through resource blocks:
# Format: 0) Type, 4 bytes - '8BIM' (or the rare 'PHUT', 'DCSR' or 'AgHg')
# 1) TagID,2 bytes
# 2) Name, pascal string padded to even no. bytes
# 3) Size, 4 bytes - N
# 4) Data, N bytes
while ($pos + 8 < $dirEnd) {
my $type = substr($$dataPt, $pos, 4);
my ($ttPtr, $extra, $val, $name);
if ($type eq '8BIM') {
$ttPtr = $tagTablePtr;
} elsif ($type =~ /^(PHUT|DCSR|AgHg)$/) {
$ttPtr = GetTagTable('Image::ExifTool::Photoshop::Unknown');
} else {
$type =~ s/([^\w])/sprintf("\\x%.2x",ord($1))/ge;
$et->Warn(qq{Bad Photoshop IRB resource "$type"});
last;
}
my $tag = Get16u($dataPt, $pos + 4);
$pos += 6; # point to start of name
my $nameLen = Get8u($dataPt, $pos);
my $namePos = ++$pos;
# skip resource block name (pascal string, padded to an even # of bytes)
$pos += $nameLen;
++$pos unless $nameLen & 0x01;
if ($pos + 4 > $dirEnd) {
$et->Warn("Bad Photoshop resource block");
last;
}
my $size = Get32u($dataPt, $pos);
$pos += 4;
if ($size + $pos > $dirEnd) {
$et->Warn("Bad Photoshop resource data size $size");
last;
}
$success = 1;
if ($nameLen) {
$name = substr($$dataPt, $namePos, $nameLen);
$extra = qq{, Name="$name"};
} else {
$name = '';
}
my $tagInfo = $et->GetTagInfo($ttPtr, $tag);
# append resource name to value if requested (braced by "/#...#/")
if ($tagInfo and defined $$tagInfo{SetResourceName} and
$$tagInfo{SetResourceName} eq '1' and $name !~ m{/#})
{
$val = substr($$dataPt, $pos, $size) . '/#' . $name . '#/';
}
$et->HandleTag($ttPtr, $tag, $val,
TagInfo => $tagInfo,
Extra => $extra,
DataPt => $dataPt,
DataPos => $$dirInfo{DataPos},
Size => $size,
Start => $pos,
Parent => $$dirInfo{DirName},
);
$size += 1 if $size & 0x01; # size is padded to an even # bytes
$pos += $size;
}
return $success;
}
#------------------------------------------------------------------------------
# extract information from Photoshop PSD file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 if this was a valid PSD file, -1 on write error
sub ProcessPSD($$)
{
my ($et, $dirInfo) = @_;
my $raf = $$dirInfo{RAF};
my $outfile = $$dirInfo{OutFile};
my ($data, $err, $tagTablePtr);
$raf->Read($data, 30) == 30 or return 0;
$data =~ /^8BPS\0([\x01\x02])/ or return 0;
SetByteOrder('MM');
$et->SetFileType($1 eq "\x01" ? 'PSD' : 'PSB'); # set the FileType tag
my %dirInfo = (
DataPt => \$data,
DirStart => 0,
DirName => 'Photoshop',
);
my $len = Get32u(\$data, 26);
if ($outfile) {
Write($outfile, $data) or $err = 1;
$raf->Read($data, $len) == $len or return -1;
Write($outfile, $data) or $err = 1; # write color mode data
# initialize map of where things are written
$et->InitWriteDirs(\%psdMap);
} else {
# process the header
$tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Header');
$dirInfo{DirLen} = 30;
$et->ProcessDirectory(\%dirInfo, $tagTablePtr);
$raf->Seek($len, 1) or $err = 1; # skip over color mode data
}
$raf->Read($data, 4) == 4 or $err = 1;
$len = Get32u(\$data, 0);
$raf->Read($data, $len) == $len or $err = 1;
$tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Main');
$dirInfo{DirLen} = $len;
my $rtnVal = 1;
if ($outfile) {
# rewrite IRB resources
$data = WritePhotoshop($et, \%dirInfo, $tagTablePtr);
if ($data) {
$len = Set32u(length $data);
Write($outfile, $len, $data) or $err = 1;
# look for trailer and edit if necessary
my $trailInfo = Image::ExifTool::IdentifyTrailer($raf);
if ($trailInfo) {
my $tbuf = '';
$$trailInfo{OutFile} = \$tbuf; # rewrite trailer(s)
# rewrite all trailers to buffer
if ($et->ProcessTrailers($trailInfo)) {
my $copyBytes = $$trailInfo{DataPos} - $raf->Tell();
if ($copyBytes >= 0) {
# copy remaining PSD file up to start of trailer
while ($copyBytes) {
my $n = ($copyBytes > 65536) ? 65536 : $copyBytes;
$raf->Read($data, $n) == $n or $err = 1;
Write($outfile, $data) or $err = 1;
$copyBytes -= $n;
}
# write the trailer (or not)
$et->WriteTrailerBuffer($trailInfo, $outfile) or $err = 1;
} else {
$et->Warn('Overlapping trailer');
undef $trailInfo;
}
} else {
undef $trailInfo;
}
}
unless ($trailInfo) {
# copy over the rest of the file
while ($raf->Read($data, 65536)) {
Write($outfile, $data) or $err = 1;
}
}
} else {
$err = 1;
}
$rtnVal = -1 if $err;
} elsif ($err) {
$et->Warn('File format error');
} else {
ProcessPhotoshop($et, \%dirInfo, $tagTablePtr);
# process trailers if they exist
my $trailInfo = Image::ExifTool::IdentifyTrailer($raf);
$et->ProcessTrailers($trailInfo) if $trailInfo;
}
return $rtnVal;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::Photoshop - Read/write Photoshop IRB meta information
=head1 SYNOPSIS
This module is loaded automatically by Image::ExifTool when required.
=head1 DESCRIPTION
Photoshop writes its own format of meta information called a Photoshop IRB
resource which is located in the APP13 record of JPEG files. This module
contains the definitions to read this information.
=head1 NOTES
Photoshop IRB blocks may have an associated resource name. These names are
usually just an empty string, but if not empty they are displayed in the
verbose level 2 (or greater) output. A special C<SetResourceName> flag may
be set to '1' in the tag information hash to cause the resource name to be
appended to the value when extracted. If this is done, the returned value
has the form "VALUE/#NAME#/". When writing, the writer routine looks for
this syntax (if C<SetResourceName> is defined), and and uses the embedded
name to set the name of the new resource. This allows the resource names to
be preserved when copying Photoshop information via user-defined tags.
=head1 AUTHOR
Copyright 2003-2015, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 REFERENCES
=over 4
=item L<http://www.fine-view.com/jp/lab/doc/ps6ffspecsv2.pdf>
=item L<http://www.ozhiker.com/electronics/pjmt/jpeg_info/irb_jpeg_qual.html>
=item L<http://www.fileformat.info/format/psd/egff.htm>
=item L<http://libpsd.graphest.com/files/Photoshop%20File%20Formats.pdf>
=item L<http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/>
=back
=head1 SEE ALSO
L<Image::ExifTool::TagNames/Photoshop Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>,
L<Image::MetaData::JPEG(3pm)|Image::MetaData::JPEG>
=cut
| 36.983103 | 108 | 0.523633 |
ed9760cd8e3425da092eec875c2626b026a4c511 | 16,802 | pm | Perl | Setup/Inno/Struct5601.pm | onitake/uninno | 0e7abb5436a3d30763acf7a2c523e8e0765d5f5c | [
"BSD-2-Clause"
] | 25 | 2015-02-04T12:30:51.000Z | 2021-12-10T21:18:47.000Z | Setup/Inno/Struct5601.pm | onitake/uninno | 0e7abb5436a3d30763acf7a2c523e8e0765d5f5c | [
"BSD-2-Clause"
] | 7 | 2015-12-01T00:59:25.000Z | 2017-08-25T06:45:33.000Z | Setup/Inno/Struct5601.pm | onitake/uninno | 0e7abb5436a3d30763acf7a2c523e8e0765d5f5c | [
"BSD-2-Clause"
] | 10 | 2015-02-04T12:33:55.000Z | 2020-05-07T19:26:13.000Z | package Setup::Inno::Struct5601;
use strict;
use base 'Setup::Inno::Struct';
sub TSetupHeader {
my ($self) = @_;
my $ret;
$ret = {
AppName => $self->ReadString(1),
AppVerName => $self->ReadString(1),
AppId => $self->ReadString(1),
AppCopyright => $self->ReadString(1),
AppPublisher => $self->ReadString(1),
AppPublisherURL => $self->ReadString(1),
AppSupportPhone => $self->ReadString(1),
AppSupportURL => $self->ReadString(1),
AppUpdatesURL => $self->ReadString(1),
AppVersion => $self->ReadString(1),
DefaultDirName => $self->ReadString(1),
DefaultGroupName => $self->ReadString(1),
BaseFilename => $self->ReadString(1),
UninstallFilesDir => $self->ReadString(1),
UninstallDisplayName => $self->ReadString(1),
UninstallDisplayIcon => $self->ReadString(1),
AppMutex => $self->ReadString(1),
DefaultUserInfoName => $self->ReadString(1),
DefaultUserInfoOrg => $self->ReadString(1),
DefaultUserInfoSerial => $self->ReadString(1),
AppReadmeFile => $self->ReadString(1),
AppContact => $self->ReadString(1),
AppComments => $self->ReadString(1),
AppModifyPath => $self->ReadString(1),
CreateUninstallRegKey => $self->ReadString(1),
Uninstallable => $self->ReadString(1),
CloseApplicationsFilter => $self->ReadString(1),
SetupMutex => $self->ReadString(1),
LicenseText => $self->ReadString(1),
InfoBeforeText => $self->ReadString(1),
InfoAfterText => $self->ReadString(1),
CompiledCodeText => $self->ReadString(1),
LeadBytes => $self->ReadSet(256),
NumLanguageEntries => $self->ReadInteger(),
NumCustomMessageEntries => $self->ReadInteger(),
NumPermissionEntries => $self->ReadInteger(),
NumTypeEntries => $self->ReadInteger(),
NumComponentEntries => $self->ReadInteger(),
NumTaskEntries => $self->ReadInteger(),
NumDirEntries => $self->ReadInteger(),
NumFileEntries => $self->ReadInteger(),
NumFileLocationEntries => $self->ReadInteger(),
NumIconEntries => $self->ReadInteger(),
NumIniEntries => $self->ReadInteger(),
NumRegistryEntries => $self->ReadInteger(),
NumInstallDeleteEntries => $self->ReadInteger(),
NumUninstallDeleteEntries => $self->ReadInteger(),
NumRunEntries => $self->ReadInteger(),
NumUninstallRunEntries => $self->ReadInteger(),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
BackColor => $self->ReadLongInt(),
BackColor2 => $self->ReadLongInt(),
WizardImageAlphaFormat => $self->ReadEnum([ 'afIgnored', 'afDefined', 'afPremultiplied' ]),
PasswordHash => $self->TSHA1Digest(),
PasswordSalt => [ map({ $self->ReadByte() } (0..7)) ],
ExtraDiskSpaceRequired => $self->ReadInt64(),
SlicesPerDisk => $self->ReadInteger(),
UninstallLogMode => $self->ReadEnum([ 'lmAppend', 'lmNew', 'lmOverwrite' ]),
DirExistsWarning => $self->ReadEnum([ 'ddAuto', 'ddNo', 'ddYes' ]),
PrivilegesRequired => $self->ReadEnum([ 'prNone', 'prPowerUser', 'prAdmin', 'prLowest' ]),
ShowLanguageDialog => $self->ReadEnum([ 'slYes', 'slNo', 'slAuto' ]),
LanguageDetectionMethod => $self->ReadEnum([ 'ldUILanguage', 'ldLocale', 'ldNone' ]),
CompressMethod => $self->ReadEnum([ 'cmStored', 'cmZip', 'cmBzip', 'cmLZMA', 'cmLZMA2' ]),
ArchitecturesAllowed => $self->ReadSet([ 'paUnknown', 'paX86', 'paX64', 'paIA64', 'paARM64' ]),
ArchitecturesInstallIn64BitMode => $self->ReadSet([ 'paUnknown', 'paX86', 'paX64', 'paIA64', 'paARM64' ]),
DisableDirPage => $self->ReadEnum([ 'dpAuto', 'dpNo', 'dpYes' ]),
DisableProgramGroupPage => $self->ReadEnum([ 'dpAuto', 'dpNo', 'dpYes' ]),
UninstallDisplaySize => $self->ReadInt64(),
Options => $self->ReadSet([ 'shDisableStartupPrompt', 'shCreateAppDir', 'shAllowNoIcons', 'shAlwaysRestart', 'shAlwaysUsePersonalGroup', 'shWindowVisible', 'shWindowShowCaption', 'shWindowResizable', 'shWindowStartMaximized', 'shEnableDirDoesntExistWarning', 'shPassword', 'shAllowRootDirectory', 'shDisableFinishedPage', 'shChangesAssociations', 'shUsePreviousAppDir', 'shBackColorHorizontal', 'shUsePreviousGroup', 'shUpdateUninstallLogAppName', 'shUsePreviousSetupType', 'shDisableReadyMemo', 'shAlwaysShowComponentsList', 'shFlatComponentsList', 'shShowComponentSizes', 'shUsePreviousTasks', 'shDisableReadyPage', 'shAlwaysShowDirOnReadyPage', 'shAlwaysShowGroupOnReadyPage', 'shAllowUNCPath', 'shUserInfoPage', 'shUsePreviousUserInfo', 'shUninstallRestartComputer', 'shRestartIfNeededByRun', 'shShowTasksTreeLines', 'shAllowCancelDuringInstall', 'shWizardImageStretch', 'shAppendDefaultDirName', 'shAppendDefaultGroupName', 'shEncryptionUsed', 'shChangesEnvironment', 'shShowUndisplayableLanguages', 'shSetupLogging', 'shSignedUninstaller', 'shUsePreviousLanguage', 'shDisableWelcomePage', 'shCloseApplications', 'shRestartApplications', 'shAllowNetworkDrive', 'shForceCloseApplications' ]),
};
return $ret;
}
sub TSetupLanguageEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
LanguageName => $self->ReadString(1),
DialogFontName => $self->ReadString(1),
TitleFontName => $self->ReadString(1),
WelcomeFontName => $self->ReadString(1),
CopyrightFontName => $self->ReadString(1),
Data => $self->ReadString(1),
LicenseText => $self->ReadString(1),
InfoBeforeText => $self->ReadString(1),
InfoAfterText => $self->ReadString(1),
LanguageID => $self->ReadCardinal(),
LanguageCodePage => $self->ReadCardinal(),
DialogFontSize => $self->ReadInteger(),
TitleFontSize => $self->ReadInteger(),
WelcomeFontSize => $self->ReadInteger(),
CopyrightFontSize => $self->ReadInteger(),
RightToLeft => $self->ReadByte(),
};
return $ret;
}
sub TSetupCustomMessageEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Value => $self->ReadString(1),
LangIndex => $self->ReadInteger(),
};
return $ret;
}
sub TSetupPermissionEntry {
my ($self) = @_;
my $ret;
$ret = {
Permissions => $self->ReadString(1),
};
return $ret;
}
sub TSetupTypeEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Description => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
Options => $self->ReadSet([ 'toIsCustom' ]),
Typ => $self->ReadEnum([ 'ttUser', 'ttDefaultFull', 'ttDefaultCompact', 'ttDefaultCustom' ]),
Size => $self->ReadInt64(),
};
return $ret;
}
sub TSetupComponentEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Description => $self->ReadString(1),
Types => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
ExtraDiskSpaceRequired => $self->ReadInt64(),
Level => $self->ReadInteger(),
Used => $self->ReadByte(),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
Options => $self->ReadSet([ 'coFixed', 'coRestart', 'coDisableNoUninstallWarning', 'coExclusive', 'coDontInheritCheck' ]),
Size => $self->ReadInt64(),
};
return $ret;
}
sub TSetupTaskEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Description => $self->ReadString(1),
GroupDescription => $self->ReadString(1),
Components => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
Level => $self->ReadInteger(),
Used => $self->ReadByte(),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
Options => $self->ReadSet([ 'toExclusive', 'toUnchecked', 'toRestart', 'toCheckedOnce', 'toDontInheritCheck' ]),
};
return $ret;
}
sub TSetupDirEntry {
my ($self) = @_;
my $ret;
$ret = {
DirName => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
Attribs => $self->ReadInteger(),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
PermissionsEntry => $self->ReadSmallInt(),
Options => $self->ReadSet([ 'doUninsNeverUninstall', 'doDeleteAfterInstall', 'doUninsAlwaysUninstall', 'doSetNTFSCompression', 'doUnsetNTFSCompression' ]),
};
return $ret;
}
sub TSetupFileEntry {
my ($self) = @_;
my $ret;
$ret = {
SourceFilename => $self->ReadString(1),
DestName => $self->ReadString(1),
InstallFontName => $self->ReadString(1),
StrongAssemblyName => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
LocationEntry => $self->ReadInteger(),
Attribs => $self->ReadInteger(),
ExternalSize => $self->ReadInt64(),
PermissionsEntry => $self->ReadSmallInt(),
Options => $self->ReadSet([ 'foConfirmOverwrite', 'foUninsNeverUninstall', 'foRestartReplace', 'foDeleteAfterInstall', 'foRegisterServer', 'foRegisterTypeLib', 'foSharedFile', 'foCompareTimeStamp', 'foFontIsntTrueType', 'foSkipIfSourceDoesntExist', 'foOverwriteReadOnly', 'foOverwriteSameVersion', 'foCustomDestName', 'foOnlyIfDestFileExists', 'foNoRegError', 'foUninsRestartDelete', 'foOnlyIfDoesntExist', 'foIgnoreVersion', 'foPromptIfOlder', 'foDontCopy', 'foUninsRemoveReadOnly', 'foRecurseSubDirsExternal', 'foReplaceSameVersionIfContentsDiffer', 'foDontVerifyChecksum', 'foUninsNoSharedFilePrompt', 'foCreateAllSubDirs', 'fo32Bit', 'fo64Bit', 'foExternalSizePreset', 'foSetNTFSCompression', 'foUnsetNTFSCompression', 'foGacInstall' ]),
FileType => $self->ReadEnum([ 'ftUserFile', 'ftUninstExe' ]),
};
return $ret;
}
sub TSetupIconEntry {
my ($self) = @_;
my $ret;
$ret = {
IconName => $self->ReadString(1),
Filename => $self->ReadString(1),
Parameters => $self->ReadString(1),
WorkingDir => $self->ReadString(1),
IconFilename => $self->ReadString(1),
Comment => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
AppUserModelID => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
IconIndex => $self->ReadInteger(),
ShowCmd => $self->ReadInteger(),
CloseOnExit => $self->ReadEnum([ 'icNoSetting', 'icYes', 'icNo' ]),
HotKey => $self->ReadWord(),
Options => $self->ReadSet([ 'ioUninsNeverUninstall', 'ioCreateOnlyIfFileExists', 'ioUseAppPaths', 'ioFolderShortcut', 'ioExcludeFromShowInNewInstall', 'ioPreventPinning' ]),
};
return $ret;
}
sub TSetupIniEntry {
my ($self) = @_;
my $ret;
$ret = {
Filename => $self->ReadString(1),
Section => $self->ReadString(1),
Entry => $self->ReadString(1),
Value => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
Options => $self->ReadSet([ 'ioCreateKeyIfDoesntExist', 'ioUninsDeleteEntry', 'ioUninsDeleteEntireSection', 'ioUninsDeleteSectionIfEmpty', 'ioHasValue' ]),
};
return $ret;
}
sub TSetupRegistryEntry {
my ($self) = @_;
my $ret;
$ret = {
Subkey => $self->ReadString(1),
ValueName => $self->ReadString(1),
ValueData => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
RootKey => $self->HKEY(),
PermissionsEntry => $self->ReadSmallInt(),
Typ => $self->ReadEnum([ 'rtNone', 'rtString', 'rtExpandString', 'rtDWord', 'rtBinary', 'rtMultiString', 'rtQWord' ]),
Options => $self->ReadSet([ 'roCreateValueIfDoesntExist', 'roUninsDeleteValue', 'roUninsClearValue', 'roUninsDeleteEntireKey', 'roUninsDeleteEntireKeyIfEmpty', 'roPreserveStringType', 'roDeleteKey', 'roDeleteValue', 'roNoError', 'roDontCreateKey', 'ro32Bit', 'ro64Bit' ]),
};
return $ret;
}
sub TSetupDeleteEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
DeleteType => $self->ReadEnum([ 'dfFiles', 'dfFilesAndOrSubdirs', 'dfDirIfEmpty' ]),
};
return $ret;
}
sub TSetupRunEntry {
my ($self) = @_;
my $ret;
$ret = {
Name => $self->ReadString(1),
Parameters => $self->ReadString(1),
WorkingDir => $self->ReadString(1),
RunOnceId => $self->ReadString(1),
StatusMsg => $self->ReadString(1),
Verb => $self->ReadString(1),
Description => $self->ReadString(1),
Components => $self->ReadString(1),
Tasks => $self->ReadString(1),
Languages => $self->ReadString(1),
Check => $self->ReadString(1),
AfterInstall => $self->ReadString(1),
BeforeInstall => $self->ReadString(1),
MinVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
OnlyBelowVersion => {
WinVersion => $self->ReadCardinal(),
NTVersion => $self->ReadCardinal(),
NTServicePack => $self->ReadWord(),
},
ShowCmd => $self->ReadInteger(),
Wait => $self->ReadEnum([ 'rwWaitUntilTerminated', 'rwNoWait', 'rwWaitUntilIdle' ]),
Options => $self->ReadSet([ 'roShellExec', 'roSkipIfDoesntExist', 'roPostInstall', 'roUnchecked', 'roSkipIfSilent', 'roSkipIfNotSilent', 'roHideWizard', 'roRun32Bit', 'roRun64Bit', 'roRunAsOriginalUser' ]),
};
return $ret;
}
sub TSetupFileLocationEntry {
my ($self) = @_;
my $ret;
$ret = {
FirstSlice => $self->ReadInteger(),
LastSlice => $self->ReadInteger(),
StartOffset => $self->ReadLongInt(),
ChunkSuboffset => $self->ReadInt64(),
OriginalSize => $self->ReadInt64(),
ChunkCompressedSize => $self->ReadInt64(),
SHA1Sum => $self->TSHA1Digest(),
SourceTimeStamp => $self->TFileTime(),
FileVersionMS => $self->DWORD(),
FileVersionLS => $self->DWORD(),
Flags => $self->ReadSet([ 'foVersionInfoValid', 'foVersionInfoNotValid', 'foTimeStampInUTC', 'foIsUninstExe', 'foCallInstructionOptimized', 'foApplyTouchDateTime', 'foChunkEncrypted', 'foChunkCompressed', 'foSolidBreak', 'foSign', 'foSignOnce' ]),
};
return $ret;
}
1;
| 38.360731 | 1,198 | 0.671765 |
73d7aea51d6ca9fe8bb9e0c1cbd3277daed15c0c | 2,439 | pm | Perl | auto-lib/Paws/CloudSearch/DocumentSuggesterOptions.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/CloudSearch/DocumentSuggesterOptions.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | 1 | 2021-05-26T19:13:58.000Z | 2021-05-26T19:13:58.000Z | auto-lib/Paws/CloudSearch/DocumentSuggesterOptions.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | package Paws::CloudSearch::DocumentSuggesterOptions;
use Moose;
has FuzzyMatching => (is => 'ro', isa => 'Str');
has SortExpression => (is => 'ro', isa => 'Str');
has SourceField => (is => 'ro', isa => 'Str', required => 1);
1;
### main pod documentation begin ###
=head1 NAME
Paws::CloudSearch::DocumentSuggesterOptions
=head1 USAGE
This class represents one of two things:
=head3 Arguments in a call to a service
Use the attributes of this class as arguments to methods. You shouldn't make instances of this class.
Each attribute should be used as a named argument in the calls that expect this type of object.
As an example, if Att1 is expected to be a Paws::CloudSearch::DocumentSuggesterOptions object:
$service_obj->Method(Att1 => { FuzzyMatching => $value, ..., SourceField => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::CloudSearch::DocumentSuggesterOptions object:
$result = $service_obj->Method(...);
$result->Att1->FuzzyMatching
=head1 DESCRIPTION
Options for a search suggester.
=head1 ATTRIBUTES
=head2 FuzzyMatching => Str
The level of fuzziness allowed when suggesting matches for a string:
C<none>, C<low>, or C<high>. With none, the specified string is treated
as an exact prefix. With low, suggestions must differ from the
specified string by no more than one character. With high, suggestions
can differ by up to two characters. The default is none.
=head2 SortExpression => Str
An expression that computes a score for each suggestion to control how
they are sorted. The scores are rounded to the nearest integer, with a
floor of 0 and a ceiling of 2^31-1. A document's relevance score is not
computed for suggestions, so sort expressions cannot reference the
C<_score> value. To sort suggestions using a numeric field or existing
expression, simply specify the name of the field or expression. If no
expression is configured for the suggester, the suggestions are sorted
with the closest matches listed first.
=head2 B<REQUIRED> SourceField => Str
The name of the index field you want to use for suggestions.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::CloudSearch>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 30.4875 | 114 | 0.751538 |
ed895773ec0c6dd2dfc26cc519851771bc952253 | 1,094 | t | Perl | t/001-basic-matching.t | git-the-cpan/MooseX-Role-Matcher | 0f747bf1361d55346695d8fa8b3f3628a0934ab8 | [
"Artistic-1.0"
] | null | null | null | t/001-basic-matching.t | git-the-cpan/MooseX-Role-Matcher | 0f747bf1361d55346695d8fa8b3f3628a0934ab8 | [
"Artistic-1.0"
] | null | null | null | t/001-basic-matching.t | git-the-cpan/MooseX-Role-Matcher | 0f747bf1361d55346695d8fa8b3f3628a0934ab8 | [
"Artistic-1.0"
] | null | null | null | #!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 9;
package Foo;
use Moose;
with 'MooseX::Role::Matcher' => { allow_missing_methods => 1 };
has [qw/a b c/] => (
is => 'ro',
isa => 'Str',
);
package main;
my $foo = Foo->new(a => 'foo', b => 'bar', c => 'baz');
ok($foo->match(a => 'foo', b => 'bar', c => 'baz'),
'string matching works');
ok($foo->match(a => qr/o/),
'regex matching works');
ok($foo->match(b => sub { length == 3 }),
'subroutine matching works');
ok($foo->match(a => 'foo', b => qr/a/, c => sub { substr($_, 2) eq 'z' }),
'combined matching works');
$foo = Foo->new(a => 'foo');
ok($foo->match(b => sub { !$_ }),
'subroutine matching against undef works');
ok($foo->match(a => 'foo', b => undef),
'matching against undef works');
ok($foo->match(a => 'foo', d => undef),
'matching against undef works even when the method doesn\'t exist');
ok(!$foo->match(a => undef),
'matching undef against a method with a value fails');
ok(!$foo->match(b => 'foo'),
'matching against a method with an undef value fails');
| 30.388889 | 74 | 0.575868 |
edaf749b079b08994979a757e093ac49571b37fc | 1,337 | pm | Perl | pdu-perl-api/Raritan/RPC/lhxmodel/Parameter_2_0_1/MetaDataChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 1 | 2021-04-29T23:04:17.000Z | 2021-04-29T23:04:17.000Z | pdu-perl-api/Raritan/RPC/lhxmodel/Parameter_2_0_1/MetaDataChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | null | null | null | pdu-perl-api/Raritan/RPC/lhxmodel/Parameter_2_0_1/MetaDataChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 2 | 2020-06-20T16:21:23.000Z | 2021-09-28T19:04:44.000Z | # SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from LhxParameter.idl.
use strict;
package Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaDataChangedEvent;
use constant typeId => "lhxmodel.Parameter_2_0_1.MetaDataChangedEvent:1.0.0";
use Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData;
use Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData;
use Raritan::RPC::idl::Event;
sub encode {
my ($in) = @_;
my $encoded = Raritan::RPC::idl::Event::encode($in);
$encoded->{'oldMetaData'} = Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData::encode($in->{'oldMetaData'});
$encoded->{'newMetaData'} = Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData::encode($in->{'newMetaData'});
return $encoded;
}
sub decode {
my ($agent, $in) = @_;
my $decoded = Raritan::RPC::idl::Event::decode($agent, $in);
$decoded->{'oldMetaData'} = Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData::decode($agent, $in->{'oldMetaData'});
$decoded->{'newMetaData'} = Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaData::decode($agent, $in->{'newMetaData'});
return $decoded;
}
Raritan::RPC::Registry::registerCodecClass('lhxmodel.Parameter_2_0_1.MetaDataChangedEvent', 1, 0, 0, 'Raritan::RPC::lhxmodel::Parameter_2_0_1::MetaDataChangedEvent');
1;
| 39.323529 | 166 | 0.709798 |
edad6a6557a1235424b2ed02c4aaecbb4fc87efb | 1,947 | pm | Perl | lib/Google/Ads/AdWords/v201409/LabelService/query.pm | gitpan/Google-Ads-AdWords-Client | 44c7408a1b7f8f16b22efa359c037d1f986f04f1 | [
"Apache-2.0"
] | null | null | null | lib/Google/Ads/AdWords/v201409/LabelService/query.pm | gitpan/Google-Ads-AdWords-Client | 44c7408a1b7f8f16b22efa359c037d1f986f04f1 | [
"Apache-2.0"
] | null | null | null | lib/Google/Ads/AdWords/v201409/LabelService/query.pm | gitpan/Google-Ads-AdWords-Client | 44c7408a1b7f8f16b22efa359c037d1f986f04f1 | [
"Apache-2.0"
] | null | null | null |
package Google::Ads::AdWords::v201409::LabelService::query;
use strict;
use warnings;
{ # BLOCK to scope variables
sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201409' }
__PACKAGE__->__set_name('query');
__PACKAGE__->__set_nillable();
__PACKAGE__->__set_minOccurs();
__PACKAGE__->__set_maxOccurs();
__PACKAGE__->__set_ref();
use base qw(
SOAP::WSDL::XSD::Typelib::Element
Google::Ads::SOAP::Typelib::ComplexType
);
our $XML_ATTRIBUTE_CLASS;
undef $XML_ATTRIBUTE_CLASS;
sub __get_attr_class {
return $XML_ATTRIBUTE_CLASS;
}
use Class::Std::Fast::Storable constructor => 'none';
use base qw(Google::Ads::SOAP::Typelib::ComplexType);
{ # BLOCK to scope variables
my %query_of :ATTR(:get<query>);
__PACKAGE__->_factory(
[ qw( query
) ],
{
'query' => \%query_of,
},
{
'query' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
},
{
'query' => 'query',
}
);
} # end BLOCK
} # end of BLOCK
1;
=pod
=head1 NAME
Google::Ads::AdWords::v201409::LabelService::query
=head1 DESCRIPTION
Perl data type class for the XML Schema defined element
query from the namespace https://adwords.google.com/api/adwords/cm/v201409.
Returns the list of {@link Label}s that match the query. @param query The SQL-like AWQL query string @returns The page containing the {@link Label}s which match the query. @throws ApiException when the query is invalid or there are errors processing the request.
=head1 PROPERTIES
The following properties may be accessed using get_PROPERTY / set_PROPERTY
methods:
=over
=item * query
$element->set_query($data);
$element->get_query();
=back
=head1 METHODS
=head2 new
my $element = Google::Ads::AdWords::v201409::LabelService::query->new($data);
Constructor. The following data structure may be passed to new():
{
query => $some_value, # string
},
=head1 AUTHOR
Generated by SOAP::WSDL
=cut
| 16.361345 | 263 | 0.691834 |
eda81b205cf457c1c7af8fc4c09c60938c45f6a7 | 7,879 | pm | Perl | seco_awesomerange/source/lib/Seco/AwesomeRange.pm | xadrnd/range | 49727d2fdba5b9bb3724189f5611c24b2c887405 | [
"BSD-3-Clause"
] | 28 | 2015-03-11T09:03:40.000Z | 2020-04-30T09:46:55.000Z | seco_awesomerange/source/lib/Seco/AwesomeRange.pm | eam/range | 78faff4fafb2b36be2af0ab9f5e8dec71d19b1a3 | [
"BSD-3-Clause"
] | 5 | 2015-01-25T20:30:10.000Z | 2020-04-13T19:22:09.000Z | seco_awesomerange/source/lib/Seco/AwesomeRange.pm | eam/range | 78faff4fafb2b36be2af0ab9f5e8dec71d19b1a3 | [
"BSD-3-Clause"
] | 10 | 2015-01-25T20:24:34.000Z | 2021-02-23T05:52:36.000Z | package Seco::AwesomeRange;
# Copyright (c) 2011, Yahoo! Inc. All rights reserved.
# Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
use 5.005_03;
use strict;
use warnings;
use Carp;
require Exporter;
use AutoLoader;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw/ expand_range range_set_altpath
compress_range sorted_expand_range
nodes_parser want_warnings want_caching
clear_caches get_version
expand compress sorted_expand test_range
/;
our %EXPORT_TAGS = (
'all' => [ @EXPORT_OK ],
'common' => [ qw/ expand_range compress_range
sorted_expand_range nodes_parser test_range / ],
);
our @EXPORT = qw( );
our $VERSION = '0.01';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function.
my $constname;
our $AUTOLOAD;
($constname = $AUTOLOAD) =~ s/.*:://;
croak "&Seco::AwesomeRange::constant not defined" if $constname eq 'constant';
my ($error, $val) = constant($constname);
if ($error) { croak $error; }
{
no strict 'refs';
*$AUTOLOAD = sub { $val };
}
goto &$AUTOLOAD;
}
our $raise_exceptions = 0;
our $errno = 0;
require XSLoader;
XSLoader::load('Seco::AwesomeRange', $VERSION);
# Preloaded methods go here.
*expand_range = \&range_expand;
*expand = \&range_expand;
*sorted_expand_range = \&range_expand_sorted;
*sorted_expand = \&range_expand_sorted;
*want_caching = \&range_want_caching;
*want_warnings_real = \&range_want_warnings;
*get_exception = \&range_get_exception;
*clear_exception = \&range_clear_exception;
*clear_caches = \&range_clear_caches;
*get_version = \&range_get_version;
sub range_compress {
my $ref = ref $_[0];
if (not $ref) {
return range_compress_xs(\@_, ",");
} elsif ($ref eq "ARRAY") {
return range_compress_xs($_[0], ",")
} elsif ($ref ne "HASH") {
croak "range_compress can only be called with an array, ref to array, or ref to hash";
}
# hash ref
my %settings = (
separator => ',',
level => 1,
readable => 0,
%{$_[0]}
);
my $nodes = $settings{nodes} || $settings{hosts};
croak "range_compress: the 'nodes' argument is required."
unless $nodes;
my $l = $settings{level};
my $sep = $settings{separator};
if ($l == 0) {
return join($sep, @$nodes);
} elsif ($l == 1) {
return range_compress_xs($nodes, $sep);
} elsif ($l == 2) {
return _extra_compress($nodes, $sep);
}
# do some extra work to achieve the extra compression
my %domain;
my @no_domains;
for my $node (@$nodes) {
my ($host, $domain) = split '\.', $node, 2;
if ($domain) {
push @{$domain{$domain}}, $node;
} else {
push @no_domains, $host;
}
}
my @result;
if (@no_domains) {
push @result, range_compress_xs(\@no_domains, $sep);
}
for my $domain (sort keys %domain) {
my $r = _extra_compress($domain{$domain}, ",");
for ($r) {
s/\.$domain$sep/$sep/g;
s/\.$domain$//;
$_ = "{$_}" if /,/;
}
push @result, "$r.$domain";
}
return join($sep, @result);
}
sub _extra_compress {
my ($nodes, $sep) = @_;
my @nodes = @{$nodes};
my %domains;
for (@nodes) {
s/^([a-z]+)(\d+)([a-z]\w+)\./$1$2.UNDOXXX$3./;
}
my $result = range_compress_xs(\@nodes, $sep);
for ($result) {
s/(\d+-\d+)\.UNDOXXX/{$1}/g;
s/(\d+)\.UNDOXXX/$1/g;
}
return $result;
}
*compress_range = \&range_compress;
*compress = \&range_compress;
sub nodes_parser {
my ($c, $r, $x) = @_;
my @range = ();
if (defined $r) {
push @range, $r;
}
if (defined $c) { push @range, '%' . $c; }
if (defined $x) { push @range, "-($x)" }
return range_expand_sorted(join(",", @range));
}
my $wanted_warnings = 0;
sub want_warnings {
my $prev = $wanted_warnings;
if (scalar @_) {
($wanted_warnings) = @_;
want_warnings_real(@_);
}
return $prev;
}
sub test_range {
my $w = want_warnings(0);
my ($b) = scalar(expand_range(@_));
want_warnings($w);
return $b ? 1 : 0;
}
want_caching(1);
want_warnings(-t STDIN && -t STDOUT);
# Autoload methods go after =cut, and are processed by the autosplit program.
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
Seco::AwesomeRange - Perl extension for dealing with Seco ranges
=head1 SYNOPSIS
use Seco::AwesomeRange qw/:common/;
my @nodes = expand_range('%ks301');
my $nodes = compress_range(\@nodes);
my $same_nodes = compress_range(@nodes);
my @sorted_nodes = sorted_expand_range('@ALL');
=head1 DESCRIPTION
Do stuff with ranges.
Expand ranges and cluster definitions.
Compress (a ref to) an array of nodes into a compact string rep.
=head1 COMMON USAGE
If you decide to import the most common functions into your name space:
use Seco::AwesomeRange qw/:common/;
That imports the functions
expand_range
compress_range
sorted_expand_range
nodes_parser
You can also decide which functions you prefer like:
use Seco::AwesomeRange qw/expand compress/
my @nodes = expand($range);
my $nodes_repr = compress(\@nodes);
=head2 CACHING
By default the library will cache the results of your expansions. This is
probably what most command line utilities want. But this will have unwanted
effects if your program is a long running one. In that case you can use the
default (C<want_caching(1)>) and explictily call the C<clear_caches()> function.
=head2 WARNINGS
By default the library will print warnings to STDERR if running under a tty,
and be quiet otherwise. You can be explicit about wanting to see the warnings using:
C<want_warnings()>
=head1 FUNCTIONS
=head2 compress_range
Returns the string representation of a given list of nodes. The input can be a
reference to an array or the the list of nodes. The input doesn't have to be
sorted.
$string = compress_range(\@nodes);
$string = compress_range(@nodes);
=head2 expand_range
Expands a string representation of nodes and returns a list of nodes. The
result is not guaranteed to be in any particular order. If you care about the
result being sorted use C<sorted_expand_range>, otherwise use this one (it'll be faster.)
@nodes = expand_range('%ks301-7 & @REDHAT')
=head2 sorted_expand_range
Same as C<expand_range> but the return list is sorted.
=head2 want_caching
want_caching(1) # caching enabled (default)
want_caching(0) # caching is disabled
=head2 want_warnings
want_warnings(1) # print warnings to STDERR
want_warnings(0) # be quiet
=head2 get_exception
=head2 clear_exception
=head2 clear_caches
Clear all caches used by librange.
clear_caches()
=head2 get_version
Returns the version for librange
my $version = Seco::AwesomeRange::get_version();
=head2 expand / compress
You can use the aliases expand/compress:
my @nodes = Seco::AwesomeRange::expand($range);
my $repr = Seco::AwesomeRange::compress(\@nodes);
=head2 nodes_parser
Function provided for compatibility with the old Seco.pm module (standardNodesParser).
my @nodes = nodes_parser(<cluster>,<range>,<excludes>);
=head1 RANGE SYNTAX
=head2 Simple Ranges
=head2 Union
=head2 Intersection
=head2 Difference
=head2 Expand clusters
=head2 Expand GROUPS/HOSTS
=head2 Named functions
=head1 SEE ALSO
perldoc Seco::Range
=head1 AUTHOR
Daniel Muino, E<lt>dmuino@yahoo-inc.comE<gt>
Evan Miller, E<lt>eam@yahoo-inc.comE<gt>
=cut
| 23.449405 | 94 | 0.635614 |
ed63dca9877efed624556522f066e1a156d87df2 | 1,660 | pm | Perl | network/ruckus/ap/snmp/plugin.pm | Rico29/centreon-plugins | 3fcaa41001c20fdc35df49db95e5ad0516137de6 | [
"Apache-2.0"
] | null | null | null | network/ruckus/ap/snmp/plugin.pm | Rico29/centreon-plugins | 3fcaa41001c20fdc35df49db95e5ad0516137de6 | [
"Apache-2.0"
] | null | null | null | network/ruckus/ap/snmp/plugin.pm | Rico29/centreon-plugins | 3fcaa41001c20fdc35df49db95e5ad0516137de6 | [
"Apache-2.0"
] | null | null | null | #
# Copyright 2017 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::ruckus::ap::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::ruckus::ap::snmp::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::ruckus::ap::snmp::mode::memory',
'users' => 'network::ruckus::ap::snmp::mode::users',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Ruckus AP (Unleashed and ZoneFlex) equipments in SNMP.
=cut
| 31.320755 | 89 | 0.626506 |
ed8c6fbb8d30ac47505c63d1d9682a41dfd1679f | 1,204 | pm | Perl | pdu-perl-api/Raritan/RPC/servermon/ServerMonitor/ServerSettings.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 1 | 2021-04-29T23:04:17.000Z | 2021-04-29T23:04:17.000Z | pdu-perl-api/Raritan/RPC/servermon/ServerMonitor/ServerSettings.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | null | null | null | pdu-perl-api/Raritan/RPC/servermon/ServerMonitor/ServerSettings.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 2 | 2020-06-20T16:21:23.000Z | 2021-09-28T19:04:44.000Z | # SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from ServerMonitor.idl.
use strict;
package Raritan::RPC::servermon::ServerMonitor::ServerSettings;
sub encode {
my ($in) = @_;
my $encoded = {};
$encoded->{'host'} = "$in->{'host'}";
$encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
$encoded->{'pingInterval'} = 1 * $in->{'pingInterval'};
$encoded->{'retryInterval'} = 1 * $in->{'retryInterval'};
$encoded->{'activationCount'} = 1 * $in->{'activationCount'};
$encoded->{'failureCount'} = 1 * $in->{'failureCount'};
$encoded->{'resumeDelay'} = 1 * $in->{'resumeDelay'};
return $encoded;
}
sub decode {
my ($agent, $in) = @_;
my $decoded = {};
$decoded->{'host'} = $in->{'host'};
$decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
$decoded->{'pingInterval'} = $in->{'pingInterval'};
$decoded->{'retryInterval'} = $in->{'retryInterval'};
$decoded->{'activationCount'} = $in->{'activationCount'};
$decoded->{'failureCount'} = $in->{'failureCount'};
$decoded->{'resumeDelay'} = $in->{'resumeDelay'};
return $decoded;
}
1;
| 31.684211 | 74 | 0.583887 |
edb7bcd7c41b07f1eddf22c672450859bad4337c | 1,817 | t | Perl | t/worksheet/sub_write_sheet_pr.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | 61 | 2015-02-03T02:49:53.000Z | 2022-02-13T09:17:53.000Z | t/worksheet/sub_write_sheet_pr.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | 167 | 2015-01-02T09:25:11.000Z | 2022-02-16T22:04:20.000Z | t/worksheet/sub_write_sheet_pr.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | 31 | 2015-02-16T12:06:45.000Z | 2021-10-14T13:03:22.000Z | ###############################################################################
#
# Tests for Excel::Writer::XLSX::Worksheet methods.
#
# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org
#
use lib 't/lib';
use TestFunctions '_new_worksheet';
use strict;
use warnings;
use Test::More tests => 3;
###############################################################################
#
# Tests setup.
#
my $expected;
my $got;
my $caption;
my $worksheet;
###############################################################################
#
# 1. Test the _write_sheet_pr() method.
#
$caption = " \tWorksheet: _write_sheet_pr()";
$expected = '<sheetPr><pageSetUpPr fitToPage="1"/></sheetPr>';
$worksheet = _new_worksheet(\$got);
$worksheet->{_fit_page} = 1;
$worksheet->_write_sheet_pr();
is( $got, $expected, $caption );
###############################################################################
#
# 2. Test the _write_sheet_pr() method.
#
$caption = " \tWorksheet: _write_sheet_pr()";
$expected = '<sheetPr><tabColor rgb="FFFF0000"/></sheetPr>';
$worksheet = _new_worksheet(\$got);
# Mock up the color palette.
$worksheet->{_palette}->[2] = [ 0xff, 0x00, 0x00, 0x00 ];
$worksheet->set_tab_color( 'red' );
$worksheet->_write_sheet_pr();
is( $got, $expected, $caption );
###############################################################################
#
# 3. Test the _write_sheet_pr() method.
#
$caption = " \tWorksheet: _write_sheet_pr()";
$expected = '<sheetPr><tabColor rgb="FFFF0000"/><pageSetUpPr fitToPage="1"/></sheetPr>';
$worksheet = _new_worksheet(\$got);
# Mock up the color palette.
$worksheet->{_palette}->[2] = [ 0xff, 0x00, 0x00, 0x00 ];
$worksheet->{_fit_page} = 1;
$worksheet->set_tab_color( 'red' );
$worksheet->_write_sheet_pr();
is( $got, $expected, $caption );
__END__
| 21.630952 | 88 | 0.52284 |
ed74032a8e4b95fefdbf6069878e691dcd3731d8 | 692 | t | Perl | openresty-win32-build/thirdparty/perl5-5.29.6/t/re/reg_60508.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
] | 2 | 2018-06-15T08:32:44.000Z | 2019-01-12T03:20:41.000Z | openresty-win32-build/thirdparty/perl5-5.29.6/t/re/reg_60508.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
] | null | null | null | openresty-win32-build/thirdparty/perl5-5.29.6/t/re/reg_60508.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
] | null | null | null | #!./perl
# This is a test for [perl #60508] which I can't figure out where else
# to put it or what the underlying problem is, but it has to go somewhere.
# --Schwern
BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
}
use utf8;
plan tests => 1;
{
my $expect = <<"EXPECT";
k1 = ....
k2.1 = >\x{2022}
k2.2 = \x{2022}
EXPECT
utf8::encode($expect);
#local $TODO = "[perl #60508]";
fresh_perl_is(<<'CODE', $expect, {});
binmode STDOUT, ":utf8";
sub f { $_[0] =~ s/([>X])//g; }
$k1 = "." x 4 . ">>";
f($k1);
print "k1 = $k1\n";
$k2 = "\x{f1}\x{2022}";
$k2 =~ s/([\360-\362])/>/g;
print "k2.1 = $k2\n";
f($k2);
print "k2.2 = $k2\n";
CODE
}
| 16.878049 | 74 | 0.524566 |
73d29e26c59004a4de56c5268250f1d21dbce352 | 5,348 | pm | Perl | lib/CXGN/Page/Form.pm | labroo2/sgn | c8a1a10e4ac2104d82c5fd2d986f1688d01b20be | [
"MIT"
] | 39 | 2015-02-03T15:47:55.000Z | 2022-03-23T13:34:05.000Z | lib/CXGN/Page/Form.pm | labroo2/sgn | c8a1a10e4ac2104d82c5fd2d986f1688d01b20be | [
"MIT"
] | 2,491 | 2015-01-07T05:49:17.000Z | 2022-03-31T15:31:05.000Z | lib/CXGN/Page/Form.pm | labroo2/sgn | c8a1a10e4ac2104d82c5fd2d986f1688d01b20be | [
"MIT"
] | 20 | 2015-06-30T19:10:09.000Z | 2022-03-23T13:34:09.000Z | package CXGN::Page::Form;
use Module::Find;
useall CXGN::Page::Form;
use strict;
use warnings;
=head1 NAME
CXGN::Form.pm -- classes to deal with user-modifiable web forms
=head1 DESCRIPTION
The form classes can be used to generate forms that can be either static (non-editable) or editable and know how to save the data. They can also be used to validate form entry (see below).
=head2 Form generation and rendering
There are two form classes: CXGN::Page::Form::Static and CXGN::Page::Form::Editable. Editable inherits from static and so shared all the functions, some of which are overridden so that an editable form is generated instead of a static one.
All form elements are defined by classes that also occur in two versions: a static class and an editable class. For a form field, for example, the static class is CXGN::Page::Form::Field and the editable class is CXGN::Page::Form::EditableField, which inherits from the former. All field elements inherit from the abstract class CXGN::Page::Form::ElementI, which essentially defines and interface for form elements.
The form classes have functions to add different form elements to the form. The functions in the Static form class will call the constructor for the static field element, and the Editable form class will call the constructor for the editable field element. It is therefore easy to change a static form to an editable one by just changing the call to the form constructor.
There are several ways in which forms can be rendered:
=over 5
=item (1)
Call the function as_table() on the form object. This will generate a simple table with field names and field values in the order they were added to the form object.
=item (2)
The function get_field_hash() on the form object will return a hash with the field names as hash keys and the representation of the field as the value. In the case of an editable field, the value will be html for input boxes, for example. In the case of a static form, it will usually just be a text representation of the contents of the field.
=back
=head2 Form validation
When creating a form element, a "validate" parameter can be supplied, such as:
$form->add_field(
display_name=>"Name: ",
field_name=>"name",
length=>20,
object=>$myobject,
getter=>"get_name", setter=>"set_name",
validate=>"string"
);
This will make sure that a string type has been entered and will $form->validate() will return the field name as a hash key with an appropriate hash value if there is no input. Other input types are "integer", "number" (any number, including floats etc), and "token", which is a string without spaces or special characters.
Field lengths are not yet enforced but will be in the future. The error codes that are returned from the validate function are defined as globals in CXGN::Insitu::ElementI.
Note that the function as_table() handles error conditions gracefully. It will print an error message next to the field when an error occurs.
=head1 EXAMPLES
A simple form with an entry field for first and last name could be created as follows:
if ($show_editable) {
$form = CXGN::Page::Form::Editable->new();
}
else {
$form=CXGN::Page::Form::Static->new();
}
$form->add_field( display_name=>"First name:", field_name=>"first_name",
contents=>"Joe", length=>20, $object=>$person,
getter=>"get_first_name", $setter=>"set_first_name" );
$form->add_field( display_name=>"Last name:", field_name=>"last_name",
contents=>"Sixpack", length=>20, $object=>$person,
getter=>"get_last_name", $setter=>"set_last_name" );
$page->header();
$form->as_table();
$page->footer();
To store the request from the form above, one could do the following:
%args = the apache get/post parameters as a hash
if ($action eq "store") {
$form->store(%args)
}
=head1 DB OBJECTS PROPERTIES
There are special requirements for the DB objects for some of the above functionality to work. Each DB object has to be represented by a Perl object (although it can map to several tables), and needs accessors for all the properties that can be specified in the add_field call. The DB function needs to implement a function called store() to store the object to the backstore.
An alternate way to represent the html would be to use the get_field_hash() function:
my %fields = $form->get_field_hash();
print $fields{FORM_START};
print "Name: ".$fields{last_name}."<br />\n";
print "First: ".$fields{first_name}."<br />\n";
print $fields{FORM_END};
=head1 MORE INFORMATION, SEE ALSO
For more information, see CXGN::Page::Form::Static and CXGN::Page::Form::Editable
For field definitions see the CXGN::Page::Form::ElementI interface.
Note that L<CXGN::Page::Form::SimpleFormPage> provides a framework for working with simple updatable forms. It knows how to handle input validation, editing, viewing, adding, and deleting database entries with the appropriate user access privilege checking. See L<CXGN::Page::Form::SimpleFormPage> for more information.
=head1 AUTHOR(S)
Lukas Mueller (lam87@cornell.edu)
=cut
1;
| 44.566667 | 416 | 0.714473 |
ed061605fe2edd5473d7ea3e0b0d554955c1d765 | 4,448 | t | Perl | test/nginx-tests/stream_realip.t | anguslee/asynch_mode_nginx | 1bb36fe7c93805028b5a2a599acc90b8ff53f44a | [
"Intel",
"OpenSSL"
] | 169 | 2017-11-20T03:10:48.000Z | 2022-03-28T23:56:53.000Z | test/nginx-tests/stream_realip.t | anguslee/asynch_mode_nginx | 1bb36fe7c93805028b5a2a599acc90b8ff53f44a | [
"Intel",
"OpenSSL"
] | 51 | 2018-05-28T03:30:15.000Z | 2022-03-30T08:39:27.000Z | test/nginx-tests/stream_realip.t | anguslee/asynch_mode_nginx | 1bb36fe7c93805028b5a2a599acc90b8ff53f44a | [
"Intel",
"OpenSSL"
] | 53 | 2018-03-12T06:57:51.000Z | 2022-01-10T12:27:14.000Z | #!/usr/bin/perl
# Copyright (C) Intel, Inc.
# (C) Sergey Kandaurov
# (C) Nginx, Inc.
# Tests for stream realip module, server side proxy protocol.
###############################################################################
use warnings;
use strict;
use Test::More;
use IO::Select;
use Socket qw/ $CRLF /;
BEGIN { use FindBin; chdir($FindBin::Bin); }
use lib 'lib';
use Test::Nginx;
use Test::Nginx::Stream qw/ stream /;
###############################################################################
select STDERR; $| = 1;
select STDOUT; $| = 1;
my $t = Test::Nginx->new()->has(qw/stream stream_return stream_realip/)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
daemon off;
events {
}
stream {
%%TEST_GLOBALS_STREAM%%
server {
listen 127.0.0.1:8083 proxy_protocol;
listen 127.0.0.1:8084;
return $proxy_protocol_addr:$proxy_protocol_port;
}
server {
listen 127.0.0.1:8085 proxy_protocol;
proxy_pass 127.0.0.1:8081;
}
server {
listen 127.0.0.1:8086 proxy_protocol;
listen [::1]:%%PORT_8086%% proxy_protocol;
return "$remote_addr:$remote_port:
$realip_remote_addr:$realip_remote_port";
set_real_ip_from ::1;
set_real_ip_from 127.0.0.2;
}
server {
listen 127.0.0.1:8087;
proxy_pass [::1]:%%PORT_8086%%;
}
server {
listen 127.0.0.1:8088 proxy_protocol;
listen [::1]:%%PORT_8088%% proxy_protocol;
return "$remote_addr:$remote_port:
$realip_remote_addr:$realip_remote_port";
set_real_ip_from 127.0.0.1;
set_real_ip_from ::2;
}
server {
listen 127.0.0.1:8089;
proxy_pass [::1]:%%PORT_8088%%;
}
}
EOF
$t->run_daemon(\&stream_daemon);
$t->try_run('no inet6 support')->plan(8);
$t->waitforsocket('127.0.0.1:' . port(8081));
###############################################################################
is(pp_get(8083, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
'192.0.2.1:1234', 'server');
is(stream('127.0.0.1:' . port(8084))->read(), ':', 'server off');
is(pp_get(8085, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}close"),
'close', 'server payload');
like(pp_get(8086, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server ipv6 realip - no match');
like(pp_get(8087, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
qr/\Q192.0.2.1:1234:\E\s+\Q::1:\E\d+/, 'server ipv6 realip');
like(pp_get(8088, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
qr/\Q192.0.2.1:1234:\E\s+\Q127.0.0.1:\E\d+/, 'server ipv4 realip');
like(pp_get(8089, "PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
qr/^(::1:\d+):\s+\1$/, 'server ipv4 realip - no match');
like(pp_get(8088, "PROXY UNKNOWN TCP4 192.0.2.1 192.0.2.2 1234 5678${CRLF}"),
qr/^(\Q127.0.0.1:\E\d+):\s+\1$/, 'server unknown');
###############################################################################
sub pp_get {
my ($port, $proxy) = @_;
stream(PeerPort => port($port))->io($proxy);
}
###############################################################################
sub stream_daemon {
my $server = IO::Socket::INET->new(
Proto => 'tcp',
LocalAddr => '127.0.0.1:' . port(8081),
Listen => 5,
Reuse => 1
)
or die "Can't create listening socket: $!\n";
my $sel = IO::Select->new($server);
local $SIG{PIPE} = 'IGNORE';
while (my @ready = $sel->can_read) {
foreach my $fh (@ready) {
if ($server == $fh) {
my $new = $fh->accept;
$new->autoflush(1);
$sel->add($new);
} elsif (stream_handle_client($fh)) {
$sel->remove($fh);
$fh->close;
}
}
}
}
sub stream_handle_client {
my ($client) = @_;
log2c("(new connection $client)");
$client->sysread(my $buffer, 65536) or return 1;
log2i("$client $buffer");
log2o("$client $buffer");
$client->syswrite($buffer);
return $buffer =~ /close/;
}
sub log2i { Test::Nginx::log_core('|| <<', @_); }
sub log2o { Test::Nginx::log_core('|| >>', @_); }
sub log2c { Test::Nginx::log_core('||', @_); }
###############################################################################
| 25.563218 | 79 | 0.493705 |
edaa2c9e6487352520dac9eb12933e38bbc45da4 | 339 | t | Perl | Dia/SQL/t/sql_do.t | degra/dia.pm | 68d4f07d1c88d4c3fd2c65ac25954f8b1144385f | [
"WTFPL"
] | 4 | 2015-04-14T16:38:09.000Z | 2021-09-08T14:17:43.000Z | Dia/SQL/t/sql_do.t | degra/dia.pm | 68d4f07d1c88d4c3fd2c65ac25954f8b1144385f | [
"WTFPL"
] | 4 | 2016-12-13T03:16:13.000Z | 2021-08-17T10:46:39.000Z | Dia/SQL/t/sql_do.t | degra/dia.pm | 68d4f07d1c88d4c3fd2c65ac25954f8b1144385f | [
"WTFPL"
] | 8 | 2018-09-21T08:09:44.000Z | 2021-01-23T11:18:27.000Z | use Test::More tests => 1;
my $table = 'testtesttesttable1';
sub cleanup {
eval {sql_do ("DROP TABLE $table")};
}
cleanup ();
sql_do ("CREATE TABLE $table (a CHAR (3))");
sql_do ("INSERT INTO $table (a) VALUES (?)", 'AAA');
is (sql_select_scalar ("SELECT a FROM $table"), 'AAA', 'SELECT 1');
END { cleanup (); } | 18.833333 | 68 | 0.581121 |
ed49929554525e4126cd757cc8151f034d6c2f77 | 1,453 | pl | Perl | chapter-08/exw08-05.pl | eliaskousk/Learning-Perl | acd1b5794861ffefd25e300daba76dbf061663a1 | [
"Unlicense"
] | 1 | 2020-09-17T00:54:18.000Z | 2020-09-17T00:54:18.000Z | chapter-08/exw08-05.pl | eliaskousk/Learning-Perl | acd1b5794861ffefd25e300daba76dbf061663a1 | [
"Unlicense"
] | null | null | null | chapter-08/exw08-05.pl | eliaskousk/Learning-Perl | acd1b5794861ffefd25e300daba76dbf061663a1 | [
"Unlicense"
] | 1 | 2020-09-17T00:55:18.000Z | 2020-09-17T00:55:18.000Z | #!/usr/bin/perl
###
# Chapter 08 Workbook Exercise 5
# Write a program (not just a regular expression) that can tell the
# difference between scalar, array, and hash variables, and have it
# report what it finds.
#
# usage:
# exw08-05.pl
#
# note:
# - to explicitly match ASCII characters in variable names, use the 'a' modifier.
# - to explicitly match UNICODE characters in variable names, use the 'u' modifier.
# - according to the answer key, you can also use the UNICODE properties
# p{XID_Start}
# p{XID_Continue}
# to match the appropriate characters for variable names.
use strict;
use warnings;
# Use this script as the input.
my $datafile = "./exw08-05.pl";
my $DATAFILEHANDLE;
# A hash of valid sigils
my %sigils = (
'$'=>'a scalar',
'@'=>'an array',
'%'=>'a hash'
);
# some other test variables names
my $fred = "Flinstone";
my @barney = ( 'betty', 'bam-bam' );
my %betty = (
'one' => 'thing',
'two' => 'other-things'
);
if ( ! open $DATAFILEHANDLE, "<", "$datafile" ) {
print "I couldn't find this script??!?\n";
exit 1;
} else {
while (<$DATAFILEHANDLE>) { # take one input line at a time
chomp;
if ( m/
my\ # look for a variable definition.
( # start of the variable capture.
([\$\@\%]) # capture the sigils.
[a-zA-Z_]* # the actual variable name.
) # finish the variable capture.
/x
) {
print " $1 is $sigils{$2}.\n";
}
}
} | 24.216667 | 83 | 0.613902 |
edadf21d84dc2cf1b2d612a6d34d5ead356b62a4 | 2,415 | pm | Perl | auto-lib/Paws/WAFRegional/CreateIPSet.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/WAFRegional/CreateIPSet.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/WAFRegional/CreateIPSet.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null |
package Paws::WAFRegional::CreateIPSet;
use Moose;
has ChangeToken => (is => 'ro', isa => 'Str', required => 1);
has Name => (is => 'ro', isa => 'Str', required => 1);
use MooseX::ClassAttribute;
class_has _api_call => (isa => 'Str', is => 'ro', default => 'CreateIPSet');
class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::WAFRegional::CreateIPSetResponse');
class_has _result_key => (isa => 'Str', is => 'ro');
1;
### main pod documentation begin ###
=head1 NAME
Paws::WAFRegional::CreateIPSet - Arguments for method CreateIPSet on L<Paws::WAFRegional>
=head1 DESCRIPTION
This class represents the parameters used for calling the method CreateIPSet on the
L<AWS WAF Regional|Paws::WAFRegional> service. Use the attributes of this class
as arguments to method CreateIPSet.
You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to CreateIPSet.
=head1 SYNOPSIS
my $waf-regional = Paws->service('WAFRegional');
# To create an IP set
# The following example creates an IP match set named MyIPSetFriendlyName.
my $CreateIPSetResponse = $waf -regional->CreateIPSet(
{
'ChangeToken' => 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'Name' => 'MyIPSetFriendlyName'
}
);
# Results:
my $ChangeToken = $CreateIPSetResponse->ChangeToken;
my $IPSet = $CreateIPSetResponse->IPSet;
# Returns a L<Paws::WAFRegional::CreateIPSetResponse> object.
Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.
For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/waf-regional/CreateIPSet>
=head1 ATTRIBUTES
=head2 B<REQUIRED> ChangeToken => Str
The value returned by the most recent call to GetChangeToken.
=head2 B<REQUIRED> Name => Str
A friendly name or description of the IPSet. You can't change C<Name>
after you create the C<IPSet>.
=head1 SEE ALSO
This class forms part of L<Paws>, documenting arguments for method CreateIPSet in L<Paws::WAFRegional>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 30.961538 | 249 | 0.711387 |
edb89641134c1bd51abb4ad64d2f59dcbbbc8348 | 7,065 | pm | Perl | Slim/Plugin/Deezer/Plugin.pm | DigitalDreamtimeLtd/slimserver | 0f86f3aa9accde2a7c22add61518e03f5e001ceb | [
"BSD-3-Clause"
] | 647 | 2015-01-02T14:39:47.000Z | 2022-03-26T03:35:54.000Z | Slim/Plugin/Deezer/Plugin.pm | DigitalDreamtimeLtd/slimserver | 0f86f3aa9accde2a7c22add61518e03f5e001ceb | [
"BSD-3-Clause"
] | 571 | 2015-01-13T17:35:32.000Z | 2022-03-31T04:22:16.000Z | Slim/Plugin/Deezer/Plugin.pm | DigitalDreamtimeLtd/slimserver | 0f86f3aa9accde2a7c22add61518e03f5e001ceb | [
"BSD-3-Clause"
] | 296 | 2015-01-20T13:10:18.000Z | 2022-03-20T12:39:05.000Z | package Slim::Plugin::Deezer::Plugin;
# Logitech Media Server Copyright 2001-2020 Logitech.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
use strict;
use base qw(Slim::Plugin::OPMLBased);
use JSON::XS::VersionOneAndTwo;
use URI::Escape qw(uri_escape_utf8);
use Slim::Plugin::Deezer::ProtocolHandler;
use Slim::Utils::Strings qw(cstring);
my $log = Slim::Utils::Log->addLogCategory( {
category => 'plugin.deezer',
defaultLevel => 'ERROR',
description => 'PLUGIN_DEEZER_MODULE_NAME',
} );
sub initPlugin {
my $class = shift;
Slim::Player::ProtocolHandlers->registerHandler(
deezer => 'Slim::Plugin::Deezer::ProtocolHandler'
);
$class->SUPER::initPlugin(
feed => Slim::Networking::SqueezeNetwork->url( '/api/deezer/v1/opml' ),
tag => 'deezer',
menu => 'music_services',
weight => 35,
is_app => 1,
);
Slim::Music::Import->addImporter('Plugins::Deezer::Importer', { use => 1 });
if ( main::WEBUI ) {
# Add a function to view trackinfo in the web
Slim::Web::Pages->addPageFunction(
'plugins/deezer/trackinfo.html',
sub {
my $client = $_[0];
my $params = $_[1];
my $url;
my $id = $params->{sess} || $params->{item};
if ( $id ) {
# The user clicked on a different URL than is currently playing
if ( my $track = Slim::Schema->find( Track => $id ) ) {
$url = $track->url;
}
# Pass-through track ID as sess param
$params->{sess} = $id;
}
else {
$url = Slim::Player::Playlist::url($client);
}
Slim::Web::XMLBrowser->handleWebIndex( {
client => $client,
feed => Slim::Plugin::Deezer::ProtocolHandler->trackInfoURL( $client, $url ),
path => 'plugins/deezer/trackinfo.html',
title => 'Deezer Track Info',
timeout => 35,
args => \@_
} );
},
);
}
}
sub postinitPlugin {
my $class = shift;
# if user has the Don't Stop The Music plugin enabled, register ourselves
if ( Slim::Utils::PluginManager->isEnabled('Slim::Plugin::DontStopTheMusic::Plugin') ) {
Slim::Plugin::DontStopTheMusic::Plugin->registerHandler('PLUGIN_DEEZER_SMART_RADIO', sub {
my ($client, $cb) = @_;
my $seedTracks = Slim::Plugin::DontStopTheMusic::Plugin->getMixableProperties($client, 50);
# don't seed from radio stations - only do if we're playing from some track based source
if ($seedTracks && ref $seedTracks && scalar @$seedTracks) {
main::INFOLOG && $log->info("Creating Deezer Smart Radio from random items in current playlist");
# get the most frequent artist in our list
my %artists;
foreach (@$seedTracks) {
$artists{$_->{artist}}++;
}
# split "feat." etc. artists
my @artists;
foreach (keys %artists) {
if ( my ($a1, $a2) = split(/\s*(?:\&|and|feat\S*)\s*/i, $_) ) {
push @artists, $a1, $a2;
}
}
unshift @artists, sort { $artists{$b} <=> $artists{$a} } keys %artists;
dontStopTheMusic($client, $cb, @artists);
}
else {
$cb->($client);
}
});
Slim::Plugin::DontStopTheMusic::Plugin->registerHandler('PLUGIN_DEEZER_FLOW', sub {
$_[1]->($_[0], ['deezer://flow.dzr']);
});
}
if ( Slim::Utils::PluginManager->isEnabled('Slim::Plugin::OnlineLibrary::Plugin') ) {
Slim::Plugin::OnlineLibrary::Plugin->addLibraryIconProvider('deezer', '/plugins/Deezer/html/images/logo.png');
require Slim::Plugin::Deezer::API;
Slim::Plugin::OnlineLibrary::BrowseArtist->registerBrowseArtistItem( deezer => sub {
my ( $client ) = @_;
return {
name => cstring($client, 'BROWSE_ON_SERVICE', 'Deezer'),
type => 'link',
icon => $class->_pluginDataFor('icon'),
url => \&browseArtistMenu,
};
} );
}
}
sub browseArtistMenu {
my ($client, $cb, $params, $args) = @_;
my $items = [];
my $artistId = $params->{artist_id} || $args->{artist_id};
if ( defined($artistId) && $artistId =~ /^\d+$/ && (my $artistObj = Slim::Schema->resultset("Contributor")->find($artistId))) {
my $searchParams = {
name => $artistObj->name
};
if (my ($extId) = grep /deezer:artist:(\d+)/, @{$artistObj->extIds}) {
my ($id) = $extId =~ /deezer:artist:(\d+)/;
$searchParams->{id} = $id;
}
Slim::Plugin::Deezer::API->getArtistMenu($client, $searchParams, sub {
my $result = shift || [];
$cb->([ map {
$_->{name} = delete $_->{text};
$_->{url} = delete $_->{URL};
$_;
} @$result ]);
});
return;
}
$cb->([{
type => 'text',
title => cstring($client, 'EMPTY'),
}]);
}
sub onlineLibraryNeedsUpdate {
my $class = shift;
require Slim::Plugin::Deezer::Importer;
return Slim::Plugin::Deezer::Importer->needsUpdate(@_);
}
sub getLibraryStats {
require Slim::Plugin::Deezer::Importer;
my $totals = Slim::Plugin::Deezer::Importer->getLibraryStats();
return wantarray ? ('PLUGIN_DEEZER_MODULE_NAME', $totals) : $totals;
}
sub dontStopTheMusic {
my $client = shift;
my $cb = shift;
my $nextArtist = shift;
my @artists = @_;
if ($nextArtist) {
Slim::Networking::SqueezeNetwork->new(
sub {
my $http = shift;
my $client = $http->params->{client};
my $artistRE = $http->params->{artistRE};
my $content = eval { from_json( $http->content ) };
my @tracks;
if ( $@ || ($content && $content->{error}) ) {
if ( main::DEBUGLOG && $log->is_debug ) {
$log->debug( 'Smart Mix failed: ' . ($@ || $content->{error}) );
}
$http->error( $@ || $content->{error} );
dontStopTheMusic($client, $http->params->{cb}, @{$http->params->{artists}});
}
elsif ( $content && ref $content && $content->{body} && (my $items = $content->{body}->{outline}) ) {
push @tracks, $items->[0]->{URL} if scalar @$items;
}
if (scalar @tracks) {
$cb->($client, \@tracks);
}
else {
dontStopTheMusic($client, $http->params->{cb}, @{$http->params->{artists}});
}
},
sub {
my $http = shift;
my $client = $http->params->{client};
if ( main::DEBUGLOG && $log->is_debug ) {
$log->debug( 'Smart Mix failed: ' . $http->error );
}
if (scalar @{$http->params->{artists}}) {
dontStopTheMusic($client, $http->params->{cb}, @{$http->params->{artists}});
}
else {
$http->params->{cb}->($client);
}
},
{
client => $client,
artists => \@artists,
artistRE=> qr/^$nextArtist/i,
cb => $cb,
timeout => 15,
},
)->get( Slim::Networking::SqueezeNetwork->url( '/api/deezer/v1/opml/smart_radio?q=' . uri_escape_utf8($nextArtist) ) );
}
else {
main::INFOLOG && $log->is_info && $log->info("No matching Smart Radio found for current playlist!");
$cb->($client);
}
}
sub getDisplayName {
return 'PLUGIN_DEEZER_MODULE_NAME';
}
# Don't add this item to any menu
sub playerMenu { }
1;
| 26.863118 | 128 | 0.606794 |
ed61ab592021e2328ba8859d97dc7e5f959abffd | 2,745 | t | Perl | test/net.t | jon-stumpf/bst | 92488380d3b7e1fd7aa3816d4fda65c03ae0a835 | [
"MIT"
] | 79 | 2020-05-13T16:00:33.000Z | 2022-03-29T18:35:14.000Z | test/net.t | jon-stumpf/bst | 92488380d3b7e1fd7aa3816d4fda65c03ae0a835 | [
"MIT"
] | 20 | 2020-07-16T05:55:51.000Z | 2021-09-26T11:32:31.000Z | test/net.t | jon-stumpf/bst | 92488380d3b7e1fd7aa3816d4fda65c03ae0a835 | [
"MIT"
] | 7 | 2020-06-04T00:23:39.000Z | 2021-09-10T14:29:27.000Z | #!/usr/bin/env cram.sh
Dummy interface
$ bst --nic dummy,type=dummy,address=fe:ed:de:ad:be:ef -- ip link show dummy
2: dummy: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether fe:ed:de:ad:be:ef brd ff:ff:ff:ff:ff:ff
MACVLANs
$ bst --nic invalid,type=macvlan,link=invalid,address=fe:ed:de:ad:be:ef -- false
bst: if_nametoindex invalid: No such device
[1]
$ bst --nic parent,dummy bst --nic macvlan0,type=macvlan,link=parent,mode=bridge,address=fe:ed:de:ad:be:ef -- ip link show macvlan0
2: macvlan0@if2: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether fe:ed:de:ad:be:ef brd ff:ff:ff:ff:ff:ff link-netnsid 0
IPVLANs
$ bst --nic parent,dummy,address=fe:ed:de:ad:be:ef bst --nic ipvlan,type=ipvlan,link=parent -- ip link show ipvlan
2: ipvlan@if2: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether fe:ed:de:ad:be:ef brd ff:ff:ff:ff:ff:ff link-netnsid 0
Adding addresses
$ bst --nic dummy,type=dummy,address=fe:ed:de:ad:be:ef --ip 172.20.0.1,dev=dummy -- ip addr show dummy
2: dummy: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether fe:ed:de:ad:be:ef brd ff:ff:ff:ff:ff:ff
inet 172.20.0.1/32 brd 172.20.0.1 scope global dummy
valid_lft forever preferred_lft forever
inet6 fe80::fced:deff:fead:beef/64 scope link tentative
valid_lft forever preferred_lft forever
$ bst --nic dummy,type=dummy,address=fe:ed:de:ad:be:ef --ip 172.20.0.1/16,dev=dummy -- ip addr show dummy
2: dummy: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether fe:ed:de:ad:be:ef brd ff:ff:ff:ff:ff:ff
inet 172.20.0.1/16 brd 172.20.255.255 scope global dummy
valid_lft forever preferred_lft forever
inet6 fe80::fced:deff:fead:beef/64 scope link tentative
valid_lft forever preferred_lft forever
Adding routes
$ bst --route gateway=1.1.1.1 -- ip route show
bst: route_add 0.0.0.0/0 via 1.1.1.1/32 src 0.0.0.0/0 dev metric 0: Network is unreachable
[1]
$ bst --ip 172.20.0.2/16,lo --route src=172.20.0.2,dst=10.0.0.0/8,gateway=172.20.0.1 -- ip route show
10.0.0.0/8 via 172.20.0.1 dev lo
$ bst --ip 172.20.0.2/16,lo --route src=172.20.0.2,gateway=172.20.0.1 -- ip route show
default via 172.20.0.1 dev lo
$ bst --ip 172.20.0.2/16,lo --route dst=10.0.0.0/8,gateway=172.20.0.1 -- ip route show
10.0.0.0/8 via 172.20.0.1 dev lo
$ bst --ip 172.20.0.2/16,lo --route gateway=172.20.0.1 -- ip route show
default via 172.20.0.1 dev lo
$ bst --route dev=lo -- ip route show
default dev lo scope link
| 43.571429 | 132 | 0.704554 |
ed3b2df4b947add0b9c2f559346fecf328fb5016 | 2,690 | pm | Perl | lib/Data/Unixish/uc.pm | gitpan/Data-Unixish | 65e7960a067777f657034330bee036cdc3d1e073 | [
"Artistic-1.0"
] | null | null | null | lib/Data/Unixish/uc.pm | gitpan/Data-Unixish | 65e7960a067777f657034330bee036cdc3d1e073 | [
"Artistic-1.0"
] | null | null | null | lib/Data/Unixish/uc.pm | gitpan/Data-Unixish | 65e7960a067777f657034330bee036cdc3d1e073 | [
"Artistic-1.0"
] | null | null | null | package Data::Unixish::uc;
use 5.010;
use strict;
use syntax 'each_on_array'; # to support perl < 5.12
use warnings;
#use Log::Any '$log';
use Data::Unixish::Util qw(%common_args);
our $VERSION = '1.49'; # VERSION
our %SPEC;
$SPEC{uc} = {
v => 1.1,
summary => 'Convert text to uppercase',
description => <<'_',
_
args => {
%common_args,
},
tags => [qw/text itemfunc/],
};
sub uc {
my %args = @_;
my ($in, $out) = ($args{in}, $args{out});
while (my ($index, $item) = each @$in) {
push @$out, _uc_item($item);
}
[200, "OK"];
}
sub _uc_item {
my $item = shift;
if (defined($item) && !ref($item)) {
return CORE::uc($item);
} else {
return $item;
}
}
1;
# ABSTRACT: Convert text to uppercase
__END__
=pod
=encoding UTF-8
=head1 NAME
Data::Unixish::uc - Convert text to uppercase
=head1 VERSION
This document describes version 1.49 of Data::Unixish::uc (from Perl distribution Data-Unixish), released on 2015-01-03.
=head1 SYNOPSIS
In Perl:
use Data::Unixish qw(lduxl);
my @res = lduxl('uc', 'januar', 'Januar'); # => ('JANUAR', 'JANUAR')
In command line:
% echo -e "januar" | dux uc
JANUAR
=head1 FUNCTIONS
=head2 uc(%args) -> [status, msg, result, meta]
Convert text to uppercase.
Arguments ('*' denotes required arguments):
=over 4
=item * B<in> => I<array>
Input stream (e.g. array or filehandle).
=item * B<out> => I<any>
Output stream (e.g. array or filehandle).
=back
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (result) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value: (any)
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Data-Unixish>.
=head1 SOURCE
Source repository is at L<https://github.com/sharyanto/perl-Data-Unixish>.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Unixish>
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
| 20.074627 | 134 | 0.679554 |
eda24c40a714d445119ed6d6ff0f11ed706ac8b6 | 4,543 | pl | Perl | src/main/resources/project/server/deployApp.pl | electric-cloud-community/EC-Cargo | 6f56e930670cc3f6f4272194d8278fa3556fe77f | [
"Apache-2.0"
] | null | null | null | src/main/resources/project/server/deployApp.pl | electric-cloud-community/EC-Cargo | 6f56e930670cc3f6f4272194d8278fa3556fe77f | [
"Apache-2.0"
] | null | null | null | src/main/resources/project/server/deployApp.pl | electric-cloud-community/EC-Cargo | 6f56e930670cc3f6f4272194d8278fa3556fe77f | [
"Apache-2.0"
] | null | null | null | # -------------------------------------------------------------------------
# File
# deployApp.pl
#
# Dependencies
# None
#
# Template Version
# 1.0
#
# Date
# 16/03/2012
#
# Engineer
# Rafael Sanchez
#
# Copyright (c) 2012 Electric Cloud, Inc.
# All rights reserved
# -------------------------------------------------------------------------
use warnings;
use ElectricCommander;
use strict;
use Cwd;
use File::Spec;
use ElectricCommander::PropDB;
use Time::Local;
use lib "$ENV{COMMANDER_PLUGINS}/@PLUGIN_NAME@/agent/lib";
use CargoCommon;
use Tomcat6xWrapper;
use Jetty8xWrapper;
use JBoss7xWrapper;
use WebLogic103xWrapper;
$|=1;
# -------------------------------------------------------------------------
# Variables
# -------------------------------------------------------------------------
$::gEC = new ElectricCommander();
$::gEC->abortOnError(0);
$::gAppPath = ($::gEC->getProperty("appPath") )->findvalue("//value");
$::gContextPath = ($::gEC->getProperty("contextPath") )->findvalue("//value");
$::gConfig = ($::gEC->getProperty("configname") )->findvalue("//value");
# -------------------------------------------------------------------------
# Main functions
# -------------------------------------------------------------------------
########################################################################
# main - contains the whole process to be done by the plugin, it builds
# the command line, sets the properties and the working directory
#
# Arguments:
# none
#
# Returns:
# none
#
########################################################################
sub main() {
#config
my %configuration;
my $container = '';
my $containerLocation = '';
my $containerPath = '';
my $user = '';
my $pass = '';
my $url = '';
#path of the pom.xml file
my $filePath = $::gAppPath . "\\pom.xml";
#getting all info from the configuration, url, user and pass
if($::gConfig ne ''){
%configuration = getConfiguration($::gConfig);
$container = $configuration{'container'};
$containerLocation = $configuration{'containerLocation'};
$containerPath = $configuration{'containerPath'};
$user = $configuration{'user'};
$pass = $configuration{'password'};
$url = $configuration{'url'};
}
if ($container eq CargoCommon->TOMCAT6X_TYPE) {
Tomcat6xWrapper->deployApp($filePath, $container, $containerLocation, $containerPath, $user, $pass, $url);
} elsif ($container eq CargoCommon->JETTY8X_TYPE) {
if ($containerLocation eq CargoCommon->REMOTE) {
print "Jetty remote deploy not supported";
$::gEC->setProperty("/myJobStep/outcome", 'error');
} else {
Jetty8xWrapper->deployApp($filePath, $container, $containerLocation, $containerPath, $user, $pass, $url);
}
} elsif ($container eq CargoCommon->JBOSS7X_TYPE) {
JBoss7xWrapper->deployApp($filePath, $container, $containerLocation, $containerPath, $user, $pass, $url);
} elsif ($container eq CargoCommon->WEBLOGIC10X_TYPE) {
if ($containerLocation eq CargoCommon->REMOTE) {
print "WebLogic remote deploy not supported";
$::gEC->setProperty("/myJobStep/outcome", 'error');
} else {
WebLogic103xWrapper->deployApp($filePath, $container, $containerLocation, $containerPath, $user, $pass, $url);
}
}
}
##########################################################################
# getConfiguration - get the information of the configuration given
#
# Arguments:
# -configName: name of the configuration to retrieve
#
# Returns:
# -configToUse: hash containing the configuration information
#
#########################################################################
sub getConfiguration($){
my ($configName) = @_;
my %configToUse;
my $proj = "$[/myProject/projectName]";
my $pluginConfigs = new ElectricCommander::PropDB($::gEC,"/projects/$proj/cargo_cfgs");
my %configRow = $pluginConfigs->getRow($configName);
# Check if configuration exists
unless(keys(%configRow)) {
print 'Error: Configuration doesn\'t exist';
exit CargoCommon->ERROR;
}
# Get user/password out of credential
my $xpath = $::gEC->getFullCredential($configRow{credential});
$configToUse{'user'} = $xpath->findvalue("//userName");
$configToUse{'password'} = $xpath->findvalue("//password");
foreach my $c (keys %configRow) {
#getting all values except the credential that was read previously
if($c ne CargoCommon->CREDENTIAL_ID){
$configToUse{$c} = $configRow{$c};
}
}
return %configToUse;
}
main();
1; | 29.309677 | 113 | 0.563284 |
ed20ad8c6b79c4fb98051cf1d92ee91184afc2cb | 12,026 | pm | Perl | lib/Convos/Controller/Events.pm | marcoarthur/convos | eef72e4480661fad92e5ec375a1f9d670279b9d7 | [
"Artistic-2.0"
] | null | null | null | lib/Convos/Controller/Events.pm | marcoarthur/convos | eef72e4480661fad92e5ec375a1f9d670279b9d7 | [
"Artistic-2.0"
] | null | null | null | lib/Convos/Controller/Events.pm | marcoarthur/convos | eef72e4480661fad92e5ec375a1f9d670279b9d7 | [
"Artistic-2.0"
] | null | null | null | package Convos::Controller::Events;
use Mojo::Base 'Mojolicious::Controller';
use Convos::Util 'DEBUG';
use Mojo::JSON 'encode_json';
use Mojo::Util;
use Time::HiRes 'time';
use Scalar::Util qw(blessed weaken);
use constant INACTIVE_TIMEOUT => $ENV{CONVOS_INACTIVE_TIMEOUT} || 60;
my %RESPONSE_EVENT_NAME = (ping => 'pong', send => 'sent');
sub start {
my $self = shift->inactivity_timeout(INACTIVE_TIMEOUT);
return $self->_err('Need to log in first.', {method => 'handshake'})->finish(1008)
unless my $user = $self->backend->user;
weaken $self;
my $uid = $user->id;
my $backend = $self->app->core->backend;
my $cb = $backend->on(
"user:$uid" => sub {
my ($backend, $event, $data) = @_;
my $ts = Mojo::Date->new($data->{ts} || time)->to_datetime;
warn "[Convos::Controller::Events] >>> $event @{[encode_json $data]}\n" if DEBUG >= 2;
$self->send({json => {%$data, ts => $ts, event => $event}});
}
);
$self->on(
finish => sub {
warn "[Convos::Controller::Events] !!! Finish\n" if DEBUG >= 2;
$backend->unsubscribe("user:$uid" => $cb);
}
);
$self->on(
json => sub {
my ($self, $data) = @_;
$data->{method} ||= 'ping';
my $method = sprintf '_event_%s', $data->{method};
$data->{id} //= Mojo::Util::steady_time();
warn "[Convos::Controller::Events] <<< @{[Mojo::JSON::encode_json($data)]}\n" if DEBUG >= 2;
my $res = $self->can($method) ? $self->$method($data) : $self->_err('Invalid method.', $data);
$res->catch(sub { $self->_err(shift, $data) }) if blessed $res and $res->can('catch');
}
);
}
sub _err {
my ($self, $err, $data) = @_;
my $res = {errors => [{message => $err}]};
$res->{$_} = $data->{$_} for grep { $data->{$_} } qw(connection_id message id);
$res->{event} = $RESPONSE_EVENT_NAME{$data->{method}} || $data->{method} || 'unknown';
$self->send({json => $res});
}
sub _event_debug {
my ($self, $data) = @_;
my $id = $data->{id} || time;
$self->log->warn('[ws] <<< ' . encode_json $data) if DEBUG;
$self->send({json => {event => 'debug', id => $id}});
}
sub _event_load {
my ($self, $data) = @_;
my $id = $data->{id} || time;
$self->backend->user->get_p($data->{params} || {})->then(sub {
my $user = shift;
$user->{rtc} = $self->app->core->settings->rtc;
$user->{default_connection} = $self->settings('default_connection')->to_string;
$user->{forced_connection} = $self->settings('forced_connection');
$self->send({json => {event => 'load', id => $id, user => $user}});
});
}
sub _event_ping {
my ($self, $data) = @_;
my $ts = time;
my $id = $data->{id} || $ts;
$self->send({json => {event => 'pong', id => $id, ts => $ts}});
}
sub _event_rtc {
my ($self, $data) = @_;
return $self->_err('Connection not found.', $data)
unless $data->{connection_id}
and my $connection = $self->backend->user->get_connection($data->{connection_id});
return $connection->rtc_p($data)->then(sub {
my $res = shift;
$res->{event} = 'rtc';
$self->send({json => $res});
});
}
sub _event_send {
my ($self, $data) = @_;
return $self->_err('Invalid input.', $data)
unless $data->{connection_id} and length $data->{message};
return $self->_err('Connection not found.', $data)
unless my $connection = $self->backend->user->get_connection($data->{connection_id});
return $connection->send_p($data->{dialog_id} // '', $data->{message})->then(sub {
my $res = shift;
$res = $res->TO_JSON if UNIVERSAL::can($res, 'TO_JSON');
$res ||= {};
$res->{event} = 'sent';
$res->{$_} ||= $data->{$_} for keys %$data;
$self->send({json => $res});
})->catch(sub {
$self->_err(shift, $data);
});
}
1;
=encoding utf8
=head1 NAME
Convos::Controller::Events - Stream events from Convos::Core to web
=head1 DESCRIPTION
L<Convos::Controller::Stream> is a L<Mojolicious::Controller> which can stream
events from the backend, and also act on instructions.
=head1 API
=head2 Overview
The WebSocket API is accessible from L<https://example.com/events>. The
endpoint requires an active L<session|Convos::Controller::User>, meaning the
WebSocket will be closed after sending back an L<error|/Errors> if an active
session is not present.
Once the WebSocket is opened, it will send and receive JSON encoded messages.
The messages sent to the WebSocket I<should> contain a "method" and an "id"
key.
All the code examples below are written in JavaScript, and might require that
the WebSocket is already successfully set up.
=over 2
=item * "id"
The "id" key will be echoed back in the response, so you can pair the request
with the response on the client side. It is highly suggested to pass in an "id"
since WebSocket responses can easily be out of order. The ID can be simply an
incremtal number, such as 1, 2, 3, ..., meaning it doesn't have to be globally
unique.
Note however that purly server side generated messages will not have an "id"
key.
=item * "method"
The default method is "ping", unless specified, though it is highly recommened
to always include a "method". See L</Methods> for a list of supported methods.
=back
=head2 Methods
=head3 debug
This method is only useful if the C<CONVOS_DEBUG> environment variable is set.
If so, this event will simply log whatever data is passed in. This is useful if
you are trying to debug a client where you do not have access to a developer
console. Example message:
ws.send(JSON.stringify({method: "debug", whatEver: 42, ts: new Date().toISOString()}));
=head3 ping
The "ping" method is used to keep the WebSocket open. Example:
ws.onmessage = (e) => {
// "ts" is a high precision epoch timestamp
// {event: "pong", ts: 1593647381.72949}
const data = JSON.parse(e.data);
};
ws.send(JSON.stringify({method: "ping"});
=head3 rtc
WebRTC communication is still experimental, so no documentation is available at
this time.
=head3 send
The "send" method is used to send messages or instructions to a connection. All
the input keys are echoed back, along with the response. Here are the input
keys you can use:
=over 2
=item * connection_id
Must be present and must be a known "connection_id". Will result in an error if
the "connection_id" is invalid.
=item * dialog_id
This key is optional, but must be present if you want to send a message to
specific channel or private conversation.
=item * message
The actual message or instruction to send. An instruction must start with "/", like
"/part", while everything else will be sent as a regular message. To force sending
a message you can use the instruction "/say". Example:
{
method: "send",
connection_id: "irc-freenode",
dialog_id: "#convos",
message: "/say /part is a command you can use to leave a conversation"
}
See the actual L<Convos::Core::Connection> to see which actions are supported
and not.
=back
Here is an example on how to use the "send" method:
ws.onmessage = (e) => {
// The response will be dependent on what the action actually does
// {event: "sent", id: 42, ...}
const data = JSON.parse(e.data);
};
ws.send(JSON.stringify({
method: "send",
connection_id: "irc-whatever",
dialog_id: "#dialog_name",
id: 42,
message: "some message"
});
=head2 Errors
Any invalid input or error while trying to handle the instructions will result
in an error structure like this:
{
// Required
event: "sent", # handshake, sent, ...
errors: [
{message: "some error", path: "/"}
],
// If present in input
connection_id: "irc-whatever",
id: 42,
message: "some message",
}
The "path" inside the error element might point to which part was actually
invalid. Example:
{message: "Missing connection ID.", path: "/connection_id"}
=head2 Server events
A server generated event for a given user will be be passed over the WebSocket.
=head3 Messages
A message sent in a channel, private conversation or generated by the server
will result in a "messsage" event. Example:
{
connection_id: "irc-whatever",
dialog_id: "superwoman",
from: "Superwoman",
highlight: false,
messsage: "Some message",
ts: 1593647381.72949,
type: "private",
}
Details:
=over 2
=item * connection_id
Identities from which connection the message originates from.
=item * dialog_id
An unique ID that identifies the conversation on a given connection.
=item * from
A human readable version of who sent the message.
=item * highlight
True if this message should be highlighted in the user interface. This is true
if your nick is mentioned or if the message matches any
L<Convos::Core::User/highlight_keywords>.
=item * message
The actual message that was sent.
=item * ts
A high precision epoch timestamp.
=item * type
Can be either "private", which is just a normal message, "notice" which is not
a very important message, "action" if the message should be prefixed with the
nickname and "error" if this is an error message.
The value of "type" might change in the future. Suggested values:
Old | New
--------|--------
private | normal
notice | notice
action | ?
error | error
=back
=head3 rtc
WebRTC communication is still experimental, so no documentation is available at
this time.
=head3 State changes
A state change is triggered when the connection, the user or another
participant changes state. It can be everything from when disconnected, nick
changes or join events. Example structure:
{
connection_id: "irc-whatever",
dialog_id: "#dialog_name"
nick: "Superwoman",
type: "join",
}
Details:
=over 2
=item * connection_id
Identities from which connection the message originates from.
=item * dialog_id
An unique ID that identifies the conversation on a given connection.
This key is only present in certain cases. See L</type> below.
=item * from, mode
"from" contains the nick that made the mode change, and "mode" contains the new
"mode".
This key is only present in certain cases. See L</type> below.
=item * frozen
Will contain a reason for why you are not enable to join/talk in a given
dialog. Empty string if everything is ok.
This key is only present in certain cases. See L</type> below.
=item * kicker
The nick of whom kicking "nick".
This key is only present in certain cases. See L</type> below.
=item * name
See L<Convos::Core::Dialog/name>.
This key is only present in certain cases. See L</type> below.
=item * nick
The target nick for this event.
This key is only present in certain cases. See L</type> below.
=item * new_nick, old_nick
Used to identify from what nick and to what nick in a "nick_change" event.
This key is only present in certain cases. See L</type> below.
=item * message
A human readable message with details of this event.
This key is only present in certain cases. See L</type> below.
=item * last_active
See L<Convos::Core::Dialog/last_active>.
This key is only present in certain cases. See L</type> below.
=item * last_read
See L<Convos::Core::Dialog/last_read>.
This key is only present in certain cases. See L</type> below.
=item * topic
See L<Convos::Core::Dialog/topic>.
This key is only present in certain cases. See L</type> below.
=item * type
Can be...
Type | Extra keys
-------------|---------------------------------------------------------------
me | nick, ...
frozen | dialog_id, frozen, name, last_active, last_read, topic, unread
join | dialog_id, nick
quit | dialog_id, nick, message
part | dialog_id, nick, message
part | dialog_id, kicker, nick, message
mode | dialog_id, from, mode, nick
nick_change | new_nick, old_nick
=back
=head1 METHODS
=head2 start
Will push L<Convos::Core::User> and L<Convos::Core::Connection> events as JSON
objects over a WebSocket connection and receive messages from the frontend.
=head1 SEE ALSO
L<Convos>:
=cut
| 26.086768 | 100 | 0.664061 |
ed9c3ae18f647c4b6203f3d5b4b63c3dc00d0678 | 4,894 | pl | Perl | extras/load_balancing/sender.pl | FelixWolf/Wakaba | d91006e2b52437d5c4105a09214072d3d0e785d9 | [
"Unlicense"
] | 13 | 2016-10-29T07:33:06.000Z | 2021-10-17T01:45:58.000Z | extras/load_balancing/sender.pl | FelixWolf/Wakaba | d91006e2b52437d5c4105a09214072d3d0e785d9 | [
"Unlicense"
] | null | null | null | extras/load_balancing/sender.pl | FelixWolf/Wakaba | d91006e2b52437d5c4105a09214072d3d0e785d9 | [
"Unlicense"
] | 2 | 2018-03-09T17:02:15.000Z | 2019-08-09T09:10:48.000Z | #!/usr/bin/perl
# TODO: * is parallelizing the connections a good idea or not?
# - larger bandwidth spike
# - more dependencies or more work
# - but faster
# * is the weighted selection of redir host working properly?
# - aka: do identical hashes always unroll in the same order?
# * is using strings_en.pl a good idea?
# - greater overhead
# - more files to edit when changing from strings_en.pl, if not overwritten
use strict;
use LWP;
use lib '.';
BEGIN { require "config.pl"; }
BEGIN { require "config_defaults.pl"; }
BEGIN { require "strings_en.pl"; }
# Constants
use constant URL => 0; # LOAD_HOSTS array ref
use constant PASS => 1; # ditto
use constant BANDWIDTH => 2; # ditto
use constant RETRIES => 3; # max retries for sending file
use constant MIN_TIMEOUT => 10; # in seconds
use constant FILENAME => 0; # ARGV ref
use constant DIR => 1; # ditto
use constant MD5 => 2; # ditto
# Prototypes
sub sendfile($$$$%);
sub deletefile($$);
sub generate_redir($$%);
#
# Main
#
{
my ($file, $filename, %goodhosts);
# set initial values
$file = $ARGV[FILENAME]; # file to send
my $img = IMG_DIR;
$file =~ /$img(.*)/;
$filename = $1;
# initialize user agent
my $ua = LWP::UserAgent->new;
$ua->agent("Wakaba");
$ua->max_size(2048);
if (@ARGV == 1)
{ # we're deleting files
unlink REDIR_DIR.$filename.".html";
$ua->timeout(MIN_TIMEOUT);
deletefile($ua, $filename);
}
elsif (@ARGV == 0)
{
print LOAD_SENDER_SCRIPT . " <file to send/delete> <root> <md5>\n";
}
else
{ # we're sending files
die "File not found." unless (-e $file);
srand(); # randomize timer
$goodhosts{$ARGV[DIR].$file} = LOAD_LOCAL; # first file host (the local)
generate_redir($filename, LOAD_LOCAL, %goodhosts); # initial redir file
$ua->timeout(MIN_TIMEOUT + (stat($file))[7] / LOAD_KBRATE); # determine max timeout based on filesize
sendfile($ua, $file, $filename, $ARGV[MD5], %goodhosts);
}
}
#
# Send file to list of hosts
#
sub sendfile($$$$%)
{
my ($ua, $file, $filename, $md5, %goodhosts) = @_;
my @load_hosts = LOAD_HOSTS;
my $total = LOAD_LOCAL;
my $retry = RETRIES;
# send file to each host
for (my $count=0; $count != @load_hosts; $count++) {
my $url = $load_hosts[$count]->[URL];
my $pass = $load_hosts[$count]->[PASS];
# post data
my $response = $ua->post($url,
Content_Type => 'form-data',
Content => [ task => 'post',
pass => $pass,
md5 => $md5,
file => [$file],
]);
# was the posting successful?
if ($response->decoded_content =~ /<body>OK<\/body>/)
{
$url =~ /(.*\/).*/;
my $hosturl = $1;
$goodhosts{$hosturl.$filename} = $load_hosts[$count]->[BANDWIDTH]; # **
$total += $load_hosts[$count]->[BANDWIDTH];
$retry = RETRIES;
generate_redir($filename, $total, %goodhosts);
}
# did receiver request a resend? Go for another round if not too many resends
elsif ($response->decoded_content =~ /<body>RESEND<\/body>/)
{
if ($retry != 0)
{
$retry--;
redo;
}
else
{
$retry = RETRIES;
}
}
# Was the post bad?
elsif ($response->decoded_content =~ /<body>TERM<\/body>/)
{
$retry = RETRIES;
}
}
generate_redir($filename, $total, %goodhosts);
}
#
# Delete the file on remote hosts
#
sub deletefile($$)
{
my ($ua, $filename) = @_;
my @load_hosts = LOAD_HOSTS;
# send delete request to each host
for (my $count=0; $count != @load_hosts; $count++) {
my $url = $load_hosts[$count]->[URL];
my $pass = $load_hosts[$count]->[PASS];
# post data
$ua->post($url,
Content_Type => 'form-data',
Content => [ task => 'delete',
pass => $pass,
file => $filename,
]);
}
}
#
# Generates the redir file
#
sub generate_redir($$%)
{
my ($filename, $total, %goodhosts) = @_;
my $redir_text = S_REDIR;
my $num = rand $total;
my $sum = 0;
my $selection;
foreach my $key (sort keys %goodhosts)
{
if ($num <= $goodhosts{$key} + $sum)
{
$selection = $key;
last;
}
$sum += $goodhosts{$key};
}
open FILE, ">", REDIR_DIR.$filename.".html";
#---------------------------------------------------
print FILE <<HEAD;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Refresh" content="1; $selection">
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
</head>
<body>
$redir_text<br />
HEAD
#---------------------------------------------------
my $i = 0;
foreach my $host (keys %goodhosts)
{
print FILE "<a href=\"$host\">-- $i --</a><br />\n";
$i++;
}
print FILE "</body></html>\n";
close FILE;
}
| 21.559471 | 109 | 0.565386 |
eda0a39b54473385cdec31ccee00e0a221c6bd56 | 468 | al | Perl | src/GaIA/pkgs/perl/ActivePerl-5.8.7.815-i686-linux-2.2.17-gcc-211909/perl/lib/site_perl/5.8.7/i686-linux-thread-multi/auto/Tk/Listbox/SHIFT.al | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/perl/ActivePerl-5.8.7.815-i686-linux-2.2.17-gcc-211909/perl/lib/site_perl/5.8.7/i686-linux-thread-multi/auto/Tk/Listbox/SHIFT.al | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/perl/ActivePerl-5.8.7.815-i686-linux-2.2.17-gcc-211909/perl/lib/site_perl/5.8.7/i686-linux-thread-multi/auto/Tk/Listbox/SHIFT.al | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | 1 | 2021-06-08T15:59:26.000Z | 2021-06-08T15:59:26.000Z | # NOTE: Derived from ../blib/lib/Tk/Listbox.pm.
# Changes made here will be lost when autosplit is run again.
# See AutoSplit.pm.
package Tk::Listbox;
#line 336 "../blib/lib/Tk/Listbox.pm (autosplit into ../blib/lib/auto/Tk/Listbox/SHIFT.al)"
# SHIFT
# -----
# Removes the first element and returns it
sub SHIFT {
my $class = shift;
my $value = ${$class->{OBJECT}}->get(0);
${$class->{OBJECT}}->delete(0);
return $value
}
# end of Tk::Listbox::SHIFT
1;
| 23.4 | 91 | 0.653846 |
edb8c1001d08147d75db3ea54d6743592b4f5871 | 912 | pl | Perl | pl.pl | GitHubMofaqAlotaibi/Prolog-Langange-Program-Min-Max | d084e5399fdeabe3e0d596b0337c591597e5e3fc | [
"MIT"
] | null | null | null | pl.pl | GitHubMofaqAlotaibi/Prolog-Langange-Program-Min-Max | d084e5399fdeabe3e0d596b0337c591597e5e3fc | [
"MIT"
] | null | null | null | pl.pl | GitHubMofaqAlotaibi/Prolog-Langange-Program-Min-Max | d084e5399fdeabe3e0d596b0337c591597e5e3fc | [
"MIT"
] | null | null | null | % Mofaq Alotaibi_April 24, 2017_524-02
% implementation of program minimum and maximum
% of a list of numbers, and returns
% the min and max in a list.
% MAX prefers the greater value
% MIN prefers the lesser value
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%minmax([1,2,3],Result).
minmax([H|T], Result):- %
maxList(T, H, Result2),
minList(T, H, Result1),
Result=[Result1,Result2].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
maxList([], Acc2, Acc2).
maxList([H2|T2], Acc2, Result2):-
(Acc2 > H2 -> NewAcc1 = Acc2; NewAcc1 = H2),
maxList(T2, NewAcc1, Result2).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
minList([], Acc1, Acc1).
minList([H1|T1], Acc1, Result1):-
(H1 < Acc1-> NewAcc = H1;NewAcc = Acc1),
minList(T1, NewAcc, Result1).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 39.652174 | 70 | 0.455044 |
ed3c8c6967a0e9f5d9e2339d76797afd85f59509 | 21,903 | pm | Perl | lib/WWW/SwaggerClient/JobsApi.pm | onlineconvert/onlineconvert-api-sdk-perl | 6203e8da4229a326b0d9a2066b38c1ba49b4587b | [
"Apache-2.0"
] | null | null | null | lib/WWW/SwaggerClient/JobsApi.pm | onlineconvert/onlineconvert-api-sdk-perl | 6203e8da4229a326b0d9a2066b38c1ba49b4587b | [
"Apache-2.0"
] | 1 | 2015-12-10T08:57:31.000Z | 2015-12-10T08:57:31.000Z | lib/WWW/SwaggerClient/JobsApi.pm | onlineconvert/onlineconvert-api-sdk-perl | 6203e8da4229a326b0d9a2066b38c1ba49b4587b | [
"Apache-2.0"
] | 2 | 2015-11-30T13:56:04.000Z | 2017-11-16T01:52:58.000Z | #
# Copyright 2015 SmartBear Software
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# NOTE: This class is auto generated by the swagger code generator program.
# Do not edit the class manually.
#
package WWW::SwaggerClient::JobsApi;
require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);
use WWW::SwaggerClient::ApiClient;
use WWW::SwaggerClient::Configuration;
use base "Class::Data::Inheritable";
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my (%self) = (
'api_client' => WWW::SwaggerClient::ApiClient->instance,
@_
);
#my $self = {
# #api_client => $options->{api_client}
# api_client => $default_api_client
#};
bless \%self, $class;
}
#
# jobs_get
#
# List of jobs active for the current user identified by the key.
#
# @param string $status Filter the status of the job. (optional)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
# @param number $page Pagination for list of elements. (optional)
{
my $params = {
'status' => {
data_type => 'string',
description => 'Filter the status of the job.',
required => '0',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
'page' => {
data_type => 'number',
description => 'Pagination for list of elements.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_get } = {
summary => 'List of jobs active for the current user identified by the key.',
params => $params,
returns => 'ARRAY[Job]',
};
}
# @return ARRAY[Job]
#
sub jobs_get {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/jobs';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# query params
if ( exists $args{'status'}) {
$query_params->{'status'} = $self->{api_client}->to_query_value($args{'status'});
}# query params
if ( exists $args{'page'}) {
$query_params->{'page'} = $self->{api_client}->to_query_value($args{'page'});
}
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[Job]', $response);
return $_response_object;
}
#
# jobs_post
#
# Creates a new Job with the user key.
#
# @param string $x_oc_api_key Api key for the user to filter. (required)
# @param Job $body Content of the job. (required)
{
my $params = {
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '1',
},
'body' => {
data_type => 'Job',
description => 'Content of the job.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ jobs_post } = {
summary => 'Creates a new Job with the user key.',
params => $params,
returns => 'Job',
};
}
# @return Job
#
sub jobs_post {
my ($self, %args) = @_;
# verify the required parameter 'x_oc_api_key' is set
unless (exists $args{'x_oc_api_key'}) {
croak("Missing the required parameter 'x_oc_api_key' when calling jobs_post");
}
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling jobs_post");
}
# parse inputs
my $_resource_path = '/jobs';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
my $_body_data;
# body params
if ( exists $args{'body'}) {
$_body_data = $args{'body'};
}
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Job', $response);
return $_response_object;
}
#
# jobs_job_id_get
#
# Get information about a Job
#
# @param string $job_id ID of job that needs to be fetched (required)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
{
my $params = {
'job_id' => {
data_type => 'string',
description => 'ID of job that needs to be fetched',
required => '1',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_job_id_get } = {
summary => 'Get information about a Job',
params => $params,
returns => 'Job',
};
}
# @return Job
#
sub jobs_job_id_get {
my ($self, %args) = @_;
# verify the required parameter 'job_id' is set
unless (exists $args{'job_id'}) {
croak("Missing the required parameter 'job_id' when calling jobs_job_id_get");
}
# parse inputs
my $_resource_path = '/jobs/{job_id}';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
# path params
if ( exists $args{'job_id'}) {
my $_base_variable = "{" . "job_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'job_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Job', $response);
return $_response_object;
}
#
# jobs_job_id_delete
#
# Cancels a job created that haven't been started. (Allow to cancel jobs in process.)
#
# @param string $job_id ID of job that needs to be fetched (required)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
{
my $params = {
'job_id' => {
data_type => 'string',
description => 'ID of job that needs to be fetched',
required => '1',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_job_id_delete } = {
summary => 'Cancels a job created that haven't been started. (Allow to cancel jobs in process.)',
params => $params,
returns => 'Job',
};
}
# @return Job
#
sub jobs_job_id_delete {
my ($self, %args) = @_;
# verify the required parameter 'job_id' is set
unless (exists $args{'job_id'}) {
croak("Missing the required parameter 'job_id' when calling jobs_job_id_delete");
}
# parse inputs
my $_resource_path = '/jobs/{job_id}';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'DELETE';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
# path params
if ( exists $args{'job_id'}) {
my $_base_variable = "{" . "job_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'job_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Job', $response);
return $_response_object;
}
#
# jobs_job_id_patch
#
# Modifies the job identified by the id, allows to start a created job.
#
# @param Job $body Content of the job. (required)
# @param string $job_id ID of job that needs to be fetched (required)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
{
my $params = {
'body' => {
data_type => 'Job',
description => 'Content of the job.',
required => '1',
},
'job_id' => {
data_type => 'string',
description => 'ID of job that needs to be fetched',
required => '1',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_job_id_patch } = {
summary => 'Modifies the job identified by the id, allows to start a created job.',
params => $params,
returns => 'Job',
};
}
# @return Job
#
sub jobs_job_id_patch {
my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling jobs_job_id_patch");
}
# verify the required parameter 'job_id' is set
unless (exists $args{'job_id'}) {
croak("Missing the required parameter 'job_id' when calling jobs_job_id_patch");
}
# parse inputs
my $_resource_path = '/jobs/{job_id}';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'PATCH';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
# path params
if ( exists $args{'job_id'}) {
my $_base_variable = "{" . "job_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'job_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# body params
if ( exists $args{'body'}) {
$_body_data = $args{'body'};
}
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Job', $response);
return $_response_object;
}
#
# jobs_job_id_history_get
#
# Get the change history for the current job.
#
# @param string $job_id ID of job that needs to be fetched (required)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
{
my $params = {
'job_id' => {
data_type => 'string',
description => 'ID of job that needs to be fetched',
required => '1',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_job_id_history_get } = {
summary => 'Get the change history for the current job.',
params => $params,
returns => 'ARRAY[History]',
};
}
# @return ARRAY[History]
#
sub jobs_job_id_history_get {
my ($self, %args) = @_;
# verify the required parameter 'job_id' is set
unless (exists $args{'job_id'}) {
croak("Missing the required parameter 'job_id' when calling jobs_job_id_history_get");
}
# parse inputs
my $_resource_path = '/jobs/{job_id}/history';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
# path params
if ( exists $args{'job_id'}) {
my $_base_variable = "{" . "job_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'job_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[History]', $response);
return $_response_object;
}
#
# jobs_job_id_threads_get
#
# Get list of threads defined for the current job.
#
# @param string $job_id ID of job that needs to be fetched (required)
# @param string $x_oc_token Token for authentication for the current job (optional)
# @param string $x_oc_api_key Api key for the user to filter. (optional)
{
my $params = {
'job_id' => {
data_type => 'string',
description => 'ID of job that needs to be fetched',
required => '1',
},
'x_oc_token' => {
data_type => 'string',
description => 'Token for authentication for the current job',
required => '0',
},
'x_oc_api_key' => {
data_type => 'string',
description => 'Api key for the user to filter.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ jobs_job_id_threads_get } = {
summary => 'Get list of threads defined for the current job.',
params => $params,
returns => 'ARRAY[Thread]',
};
}
# @return ARRAY[Thread]
#
sub jobs_job_id_threads_get {
my ($self, %args) = @_;
# verify the required parameter 'job_id' is set
unless (exists $args{'job_id'}) {
croak("Missing the required parameter 'job_id' when calling jobs_job_id_threads_get");
}
# parse inputs
my $_resource_path = '/jobs/{job_id}/threads';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# header params
if ( exists $args{'x_oc_token'}) {
$header_params->{'X-Oc-Token'} = $self->{api_client}->to_header_value($args{'x_oc_token'});
}# header params
if ( exists $args{'x_oc_api_key'}) {
$header_params->{'X-Oc-Api-Key'} = $self->{api_client}->to_header_value($args{'x_oc_api_key'});
}
# path params
if ( exists $args{'job_id'}) {
my $_base_variable = "{" . "job_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'job_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[Thread]', $response);
return $_response_object;
}
1;
| 30.548117 | 107 | 0.593206 |
eda1f97b4f811d741cf7b5a2e31d56aa933de337 | 101,908 | pl | Perl | demo/adpt-templ/scripts/Training.pl | airenas/hts-scripts | 212c0e59c019a1c863c8024f81b31890dec31aea | [
"BSD-3-Clause"
] | null | null | null | demo/adpt-templ/scripts/Training.pl | airenas/hts-scripts | 212c0e59c019a1c863c8024f81b31890dec31aea | [
"BSD-3-Clause"
] | null | null | null | demo/adpt-templ/scripts/Training.pl | airenas/hts-scripts | 212c0e59c019a1c863c8024f81b31890dec31aea | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/perl
# ----------------------------------------------------------------- #
# The HMM-Based Speech Synthesis System (HTS) #
# developed by HTS Working Group #
# http://hts.sp.nitech.ac.jp/ #
# ----------------------------------------------------------------- #
# #
# Copyright (c) 2001-2017 Nagoya Institute of Technology #
# Department of Computer Science #
# #
# 2001-2008 Tokyo Institute of Technology #
# Interdisciplinary Graduate School of #
# Science and Engineering #
# #
# 2008 University of Edinburgh #
# Centre for Speech Technology Research #
# #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or #
# without modification, are permitted provided that the following #
# conditions are met: #
# #
# - Redistributions of source code must retain the above copyright #
# notice, this list of conditions and the following disclaimer. #
# - Redistributions in binary form must reproduce the above #
# copyright notice, this list of conditions and the following #
# disclaimer in the documentation and/or other materials provided #
# with the distribution. #
# - Neither the name of the HTS working group nor the names of its #
# contributors may be used to endorse or promote products derived #
# from this software without specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND #
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, #
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS #
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED #
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON #
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, #
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY #
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
# POSSIBILITY OF SUCH DAMAGE. #
# ----------------------------------------------------------------- #
use lib '.';
$| = 1;
if ( @ARGV < 1 ) {
print "usage: Training.pl Config.pm\n";
exit(0);
}
# load configuration variables
require( $ARGV[0] );
# model structure
foreach $set (@SET) {
$vSize{$set}{'total'} = 0;
$nstream{$set}{'total'} = 0;
$nPdfStreams{$set} = 0;
foreach $type ( @{ $ref{$set} } ) {
$vSize{$set}{$type} = $nwin{$type} * $ordr{$type};
$vSize{$set}{'total'} += $vSize{$set}{$type};
$nstream{$set}{$type} = $stre{$type} - $strb{$type} + 1;
$nstream{$set}{'total'} += $nstream{$set}{$type};
$nPdfStreams{$set}++;
}
}
# File locations =========================
# data directory
$datdir = "$prjdir/data";
# data location file
$scp{'trn'} = "$datdir/scp/train.cmp.scp";
$scp{'gen'} = "$datdir/scp/gen.lab.scp";
$scp{'adp'} = "$datdir/scp/adapt.cmp.scp";
# model list files
$lst{'mon'} = "$datdir/lists/mono.list";
$lst{'ful'} = "$datdir/lists/full.list";
$lst{'all'} = "$datdir/lists/full_all.list";
# master label files
$mlf{'mon'} = "$datdir/labels/mono.mlf";
$mlf{'ful'} = "$datdir/labels/full.mlf";
# configuration variable files
$cfg{'trn'} = "$prjdir/configs/ver${ver}/trn.cnf";
$cfg{'nvf'} = "$prjdir/configs/ver${ver}/nvf.cnf";
$cfg{'syn'} = "$prjdir/configs/ver${ver}/syn.cnf";
foreach $type (@cmp) {
$cfg{$type} = "$prjdir/configs/ver${ver}/${type}.cnf";
}
foreach $type (@dur) {
$cfg{$type} = "$prjdir/configs/ver${ver}/${type}.cnf";
}
# configuration variable files for adaptation
$cfg{'adp'} = "$prjdir/configs/ver${ver}/adp.cnf";
$cfg{'map'} = "$prjdir/configs/ver${ver}/map.cnf";
$cfg{'aln'} = "$prjdir/configs/ver${ver}/aln.cnf";
$cfg{'sat'} = "$prjdir/configs/ver${ver}/sat.cnf";
foreach $set (@SET) {
$cfg{'dec'}{$set} = "$prjdir/configs/ver${ver}/dec_${set}.cnf";
}
# name of proto type definition file
$prtfile{'cmp'} = "$prjdir/proto/ver${ver}/state-${nState}_stream-$nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
$prtfile{'cmp'} .= "_${type}-$vSize{'cmp'}{$type}";
}
$prtfile{'cmp'} .= ".prt";
# model files
foreach $set (@SET) {
$model{$set} = "$prjdir/models/ver${ver}/${set}";
$hinit{$set} = "$model{$set}/HInit";
$hrest{$set} = "$model{$set}/HRest";
$vfloors{$set} = "$model{$set}/vFloors";
$avermmf{$set} = "$model{$set}/average.mmf";
$initmmf{$set} = "$model{$set}/init.mmf";
$monommf{$set} = "$model{$set}/monophone.mmf";
$fullmmf{$set} = "$model{$set}/fullcontext.mmf";
$clusmmf{$set} = "$model{$set}/clustered.mmf";
$untymmf{$set} = "$model{$set}/untied.mmf";
$reclmmf{$set} = "$model{$set}/re_clustered.mmf";
$rclammf{$set} = "$model{$set}/re_clustered_all.mmf";
$spatmmf{$set} = "$model{$set}/re_clustered_sat.mmf";
$satammf{$set} = "$model{$set}/re_clustered_sat_all.mmf";
$tiedlst{$set} = "$model{$set}/tiedlist";
}
# statistics files
foreach $set (@SET) {
$stats{$set} = "$prjdir/stats/ver${ver}/${set}.stats";
}
# model edit files
foreach $set (@SET) {
$hed{$set} = "$prjdir/edfiles/ver${ver}/${set}";
$lvf{$set} = "$hed{$set}/lvf.hed";
$m2f{$set} = "$hed{$set}/m2f.hed";
$mku{$set} = "$hed{$set}/mku.hed";
$unt{$set} = "$hed{$set}/unt.hed";
$upm{$set} = "$hed{$set}/upm.hed";
foreach $type ( @{ $ref{$set} } ) {
$cnv{$type} = "$hed{$set}/cnv_$type.hed";
$cxc{$type} = "$hed{$set}/cxc_$type.hed";
}
}
# questions about contexts
foreach $set (@SET) {
foreach $type ( @{ $ref{$set} } ) {
$qs{$type} = "$datdir/questions/questions_${qname}.hed";
$qs_utt{$type} = "$datdir/questions/questions_utt_${qname}.hed";
}
}
# decision tree files
foreach $set (@SET) {
$trd{$set} = "${prjdir}/trees/ver${ver}/${set}";
foreach $type ( @{ $ref{$set} } ) {
$mdl{$type} = "-m -a $mdlf{$type}" if ( $thr{$type} eq '000' );
$tre{$type} = "$trd{$set}/${type}.inf";
}
}
# converted model & tree files for hts_engine
$voice = "$prjdir/voices/ver${ver}";
foreach $set (@SET) {
foreach $type ( @{ $ref{$set} } ) {
$trv{$type} = "$voice/tree-${type}.inf";
$pdf{$type} = "$voice/${type}.pdf";
}
}
$type = 'lpf';
$trv{$type} = "$voice/tree-${type}.inf";
$pdf{$type} = "$voice/${type}.pdf";
# window files for parameter generation
$windir = "${datdir}/win";
foreach $type (@cmp) {
for ( $d = 1 ; $d <= $nwin{$type} ; $d++ ) {
$win{$type}[ $d - 1 ] = "${type}.win${d}";
}
}
$type = 'lpf';
$d = 1;
$win{$type}[ $d - 1 ] = "${type}.win${d}";
# global variance files and directories for parameter generation
$gvdir = "$prjdir/gv/ver${ver}";
$gvfaldir{'phn'} = "$gvdir/fal/phone";
$gvfaldir{'stt'} = "$gvdir/fal/state";
$gvdatdir = "$gvdir/dat";
$gvlabdir = "$gvdir/lab";
$gvmodels = "$gvdir/models";
$scp{'gv'} = "$gvdir/gv.scp";
$mlf{'gv'} = "$gvdir/gv.mlf";
$lst{'gv'} = "$gvdir/gv.list";
$stats{'gv'} = "$gvdir/stats/gv.stats";
$prtfile{'gv'} = "$gvdir/proto/state-1_stream-${nPdfStreams{'cmp'}}";
foreach $type (@cmp) {
$prtfile{'gv'} .= "_${type}-$ordr{$type}";
}
$prtfile{'gv'} .= ".prt";
$vfloors{'gv'} = "$gvmodels/vFloors";
$avermmf{'gv'} = "$gvmodels/average.mmf";
$fullmmf{'gv'} = "$gvmodels/fullcontext.mmf";
$clusmmf{'gv'} = "$gvmodels/clustered.mmf";
$clsammf{'gv'} = "$gvmodels/clustered_all.mmf";
$tiedlst{'gv'} = "$gvmodels/tiedlist";
$mku{'gv'} = "$gvdir/edfiles/mku.hed";
foreach $type (@cmp) {
$gvcnv{$type} = "$gvdir/edfiles/cnv_$type.hed";
$gvcxc{$type} = "$gvdir/edfiles/cxc_$type.hed";
$gvmdl{$type} = "-m -a $gvmdlf{$type}" if ( $gvthr{$type} eq '000' );
$gvtre{$type} = "$gvdir/trees/${type}.inf";
$gvpdf{$type} = "$voice/gv-${type}.pdf";
$gvtrv{$type} = "$voice/tree-gv-${type}.inf";
}
# adaptation-related files
foreach $set (@SET) {
$regtree{$set} = "$model{$set}/regTrees";
$xforms{$set} = "$model{$set}/xforms";
$mapmmf{$set} = "$model{$set}/mapmmf";
for $type ( 'reg', 'dec' ) { # reg -> regression tree, dec -> decision tree
$red{$set}{$type} = "$hed{$set}/${type}.hed";
$rbase{$set}{$type} = "$regtree{$set}/${type}.base";
$rtree{$set}{$type} = "$regtree{$set}/${type}.tree";
}
}
# files and directories for neural networks
$dnndir = "$prjdir/dnn/ver${ver}";
$dnnffidir{'ful'} = "$dnndir/ffi/full";
$dnnffidir{'gen'} = "$dnndir/ffi/gen";
$dnnmodels = "$dnndir/models";
$dnnmodelsdir{'adp'} = "$dnnmodels/adapt";
$scp{'tdn'} = "$dnndir/train.ffi-ffo.scp";
$scp{'sdn'} = "$dnndir/gen.ffi.scp";
$scp{'adn'} = "$dnndir/adapt.ffi-ffo.scp";
$cfg{'tdn'} = "$prjdir/configs/ver${ver}/trn_dnn.cnf";
$cfg{'sdn'} = "$prjdir/configs/ver${ver}/syn_dnn.cnf";
$cfg{'adn'} = "$prjdir/configs/ver${ver}/adp_dnn.cnf";
$qconf = "$datdir/configs/$qname.conf";
# HTS Commands & Options ========================
$HCompV{'cmp'} = "$HCOMPV -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -m ";
$HCompV{'gv'} = "$HCOMPV -A -C $cfg{'trn'} -D -T 1 -S $scp{'gv'} -m ";
$HList = "$HLIST -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -h -z ";
$HInit = "$HINIT -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -m 1 -u tmvw -w $wf ";
$HRest = "$HREST -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -m 1 -u tmvw -w $wf ";
$HERest{'mon'} = "$HEREST -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -I $mlf{'mon'} -m 1 -u tmvwdmv -w $wf -t $beam ";
$HERest{'ful'} = "$HEREST -A -B -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -I $mlf{'ful'} -m 1 -u tmvwdmv -w $wf -t $beam -h $spkrPat ";
$HERest{'gv'} = "$HEREST -A -C $cfg{'trn'} -D -T 1 -S $scp{'gv'} -I $mlf{'gv'} -m 1 ";
$HERest{'adp'} = "$HEREST -A -B -C $cfg{'trn'} -D -T 1 -S $scp{'adp'} -I $mlf{'ful'} -m 1 -u ada -w $wf -t $beam -h $spkrPat ";
$HERest{'map'} = "$HEREST -A -B -C $cfg{'trn'} -D -T 1 -S $scp{'adp'} -I $mlf{'ful'} -m 1 -u pmvwdpmv -w $wf -t $beam -h $spkrPat ";
$HHEd{'trn'} = "$HHED -A -B -C $cfg{'trn'} -D -T 1 -p -i ";
$HSMMAlign{'trn'} = "$HSMMALIGN -A -C $cfg{'trn'} -D -T 1 -S $scp{'trn'} -I $mlf{'ful'} -w 1.0 -t $beam ";
$HSMMAlign{'adp'} = "$HSMMALIGN -A -C $cfg{'trn'} -D -T 1 -S $scp{'adp'} -I $mlf{'ful'} -w 1.0 -t $beam ";
$HMGenS = "$HMGENS -A -B -C $cfg{'syn'} -D -T 1 -S $scp{'gen'} -t $beam -h $spkrPat ";
# =============================================================
# ===================== Main Program ==========================
# =============================================================
# preparing environments
if ($MKENV) {
print_time("preparing environments");
# make directories
foreach $dir ( 'models', 'stats', 'edfiles', 'trees', 'gv', 'dnn', 'voices', 'gen', 'proto', 'configs' ) {
mkdir "$prjdir/$dir", 0755;
mkdir "$prjdir/$dir/ver${ver}", 0755;
}
foreach $set (@SET) {
mkdir "$model{$set}", 0755;
mkdir "$hinit{$set}", 0755;
mkdir "$hrest{$set}", 0755;
mkdir "$hed{$set}", 0755;
mkdir "$trd{$set}", 0755;
mkdir "$regtree{$set}", 0755;
mkdir "$xforms{$set}", 0755;
mkdir "$mapmmf{$set}", 0755;
}
# make config files
make_config();
make_config_regtree();
make_config_adapt();
make_config_sat();
make_config_dnn();
# make model prototype definition file
make_proto();
}
# HCompV (computing variance floors)
if ($HCMPV) {
print_time("computing variance floors");
# make average model and compute variance floors
shell("$HCompV{'cmp'} -M $model{'cmp'} -o $avermmf{'cmp'} $prtfile{'cmp'}");
shell("head -n 1 $prtfile{'cmp'} > $initmmf{'cmp'}");
shell("cat $vfloors{'cmp'} >> $initmmf{'cmp'}");
make_duration_vfloor( $initdurmean, $initdurvari );
}
# HInit & HRest (initialization & reestimation)
if ($IN_RE) {
print_time("initialization & reestimation");
if ($daem) {
open( LIST, $lst{'mon'} ) || die "Cannot open $!";
while ( $phone = <LIST> ) {
# trimming leading and following whitespace characters
$phone =~ s/^\s+//;
$phone =~ s/\s+$//;
# skip a blank line
if ( $phone eq '' ) {
next;
}
print "=============== $phone ================\n";
print "use average model instead of $phone\n";
foreach $set (@SET) {
open( SRC, "$avermmf{$set}" ) || die "Cannot open $!";
open( TGT, ">$hrest{$set}/$phone" ) || die "Cannot open $!";
while ( $str = <SRC> ) {
if ( index( $str, "~h" ) == 0 ) {
print TGT "~h \"$phone\"\n";
}
else {
print TGT "$str";
}
}
close(TGT);
close(SRC);
}
}
close(LIST);
}
else {
open( LIST, $lst{'mon'} ) || die "Cannot open $!";
while ( $phone = <LIST> ) {
# trimming leading and following whitespace characters
$phone =~ s/^\s+//;
$phone =~ s/\s+$//;
# skip a blank line
if ( $phone eq '' ) {
next;
}
$lab = $mlf{'mon'};
if ( grep( $_ eq $phone, keys %mdcp ) <= 0 ) {
print "=============== $phone ================\n";
shell("$HInit -H $initmmf{'cmp'} -M $hinit{'cmp'} -I $lab -l $phone -o $phone $prtfile{'cmp'}");
shell("$HRest -H $initmmf{'cmp'} -M $hrest{'cmp'} -I $lab -l $phone -g $hrest{'dur'}/$phone $hinit{'cmp'}/$phone");
}
}
close(LIST);
open( LIST, $lst{'mon'} ) || die "Cannot open $!";
while ( $phone = <LIST> ) {
# trimming leading and following whitespace characters
$phone =~ s/^\s+//;
$phone =~ s/\s+$//;
# skip a blank line
if ( $phone eq '' ) {
next;
}
if ( grep( $_ eq $phone, keys %mdcp ) > 0 ) {
print "=============== $phone ================\n";
print "use $mdcp{$phone} instead of $phone\n";
foreach $set (@SET) {
open( SRC, "$hrest{$set}/$mdcp{$phone}" ) || die "Cannot open $!";
open( TGT, ">$hrest{$set}/$phone" ) || die "Cannot open $!";
while (<SRC>) {
s/~h \"$mdcp{$phone}\"/~h \"$phone\"/;
print TGT;
}
close(TGT);
close(SRC);
}
}
}
close(LIST);
}
}
# HHEd (making a monophone mmf)
if ($MMMMF) {
print_time("making a monophone mmf");
foreach $set (@SET) {
open( EDFILE, ">$lvf{$set}" ) || die "Cannot open $!";
# load variance floor macro
print EDFILE "// load variance flooring macro\n";
print EDFILE "FV \"$vfloors{$set}\"\n";
# tie stream weight macro
foreach $type ( @{ $ref{$set} } ) {
if ( $strw{$type} != 1.0 ) {
print EDFILE "// tie stream weights\n";
printf EDFILE "TI SW_all {*.state[%d-%d].weights}\n", 2, $nState + 1;
last;
}
}
close(EDFILE);
shell("$HHEd{'trn'} -d $hrest{$set} -w $monommf{$set} $lvf{$set} $lst{'mon'}");
shell("gzip -c $monommf{$set} > $monommf{$set}.nonembedded.gz");
}
}
# HERest (embedded reestimation (monophone))
if ($ERST0) {
print_time("embedded reestimation (monophone)");
if ($daem) {
for ( $i = 1 ; $i <= $daem_nIte ; $i++ ) {
for ( $j = 1 ; $j <= $nIte ; $j++ ) {
# embedded reestimation
$k = $j + ( $i - 1 ) * $nIte;
print("\n\nIteration $k of Embedded Re-estimation\n");
$k = ( $i / $daem_nIte )**$daem_alpha;
shell("$HERest{'mon'} -k $k -H $monommf{'cmp'} -N $monommf{'dur'} -M $model{'cmp'} -R $model{'dur'} $lst{'mon'} $lst{'mon'}");
}
}
}
else {
for ( $i = 1 ; $i <= $nIte ; $i++ ) {
# embedded reestimation
print("\n\nIteration $i of Embedded Re-estimation\n");
shell("$HERest{'mon'} -H $monommf{'cmp'} -N $monommf{'dur'} -M $model{'cmp'} -R $model{'dur'} $lst{'mon'} $lst{'mon'}");
}
}
# compress reestimated model
foreach $set (@SET) {
shell("gzip -c $monommf{$set} > ${monommf{$set}}.embedded.gz");
}
}
# HHEd (copying monophone mmf to fullcontext one)
if ($MN2FL) {
print_time("copying monophone mmf to fullcontext one");
foreach $set (@SET) {
open( EDFILE, ">$m2f{$set}" ) || die "Cannot open $!";
open( LIST, "$lst{'mon'}" ) || die "Cannot open $!";
print EDFILE "// copy monophone models to fullcontext ones\n";
print EDFILE "CL \"$lst{'ful'}\"\n\n"; # CLone monophone to fullcontext
print EDFILE "// tie state transition probability\n";
while ( $phone = <LIST> ) {
# trimming leading and following whitespace characters
$phone =~ s/^\s+//;
$phone =~ s/\s+$//;
# skip a blank line
if ( $phone eq '' ) {
next;
}
print EDFILE "TI T_${phone} {*-${phone}+*.transP}\n"; # TIe transition prob
}
close(LIST);
close(EDFILE);
shell("$HHEd{'trn'} -H $monommf{$set} -w $fullmmf{$set} $m2f{$set} $lst{'mon'}");
shell("gzip -c $fullmmf{$set} > $fullmmf{$set}.nonembedded.gz");
}
}
# HERest (embedded reestimation (fullcontext))
if ($ERST1) {
print_time("embedded reestimation (fullcontext)");
$opt = "-C $cfg{'nvf'} -s $stats{'cmp'} -w 0.0";
# embedded reestimation
print("\n\nEmbedded Re-estimation\n");
shell("$HERest{'ful'} -H $fullmmf{'cmp'} -N $fullmmf{'dur'} -M $model{'cmp'} -R $model{'dur'} $opt $lst{'ful'} $lst{'ful'}");
# compress reestimated model
foreach $set (@SET) {
shell("gzip -c $fullmmf{$set} > ${fullmmf{$set}}.embedded.gz");
}
}
# HHEd (tree-based context clustering)
if ($CXCL1) {
print_time("tree-based context clustering");
# convert cmp stats to duration ones
convstats();
# tree-based clustering
foreach $set (@SET) {
shell("cp $fullmmf{$set} $clusmmf{$set}");
$footer = "";
foreach $type ( @{ $ref{$set} } ) {
if ( $strw{$type} > 0.0 ) {
make_edfile_state($type);
shell("$HHEd{'trn'} -C $cfg{$type} -H $clusmmf{$set} $mdl{$type} -w $clusmmf{$set} $cxc{$type} $lst{'ful'}");
$footer .= "_$type";
shell("gzip -c $clusmmf{$set} > $clusmmf{$set}$footer.gz");
}
}
}
}
# HERest (embedded reestimation (clustered))
if ($ERST2) {
print_time("embedded reestimation (clustered)");
for ( $i = 1 ; $i <= $nIte ; $i++ ) {
print("\n\nIteration $i of Embedded Re-estimation\n");
shell("$HERest{'ful'} -H $clusmmf{'cmp'} -N $clusmmf{'dur'} -M $model{'cmp'} -R $model{'dur'} $lst{'ful'} $lst{'ful'}");
}
# compress reestimated mmfs
foreach $set (@SET) {
shell("gzip -c $clusmmf{$set} > $clusmmf{$set}.embedded.gz");
}
}
# HHEd (untying the parameter sharing structure)
if ($UNTIE) {
print_time("untying the parameter sharing structure");
foreach $set (@SET) {
make_edfile_untie($set);
shell("$HHEd{'trn'} -H $clusmmf{$set} -w $untymmf{$set} $unt{$set} $lst{'ful'}");
}
}
# fix variables
foreach $set (@SET) {
$stats{$set} .= ".untied";
foreach $type ( @{ $ref{$set} } ) {
$tre{$type} .= ".untied";
$cxc{$type} .= ".untied";
}
}
# HERest (embedded reestimation (untied))
if ($ERST3) {
print_time("embedded reestimation (untied)");
$opt = "-C $cfg{'nvf'} -s $stats{'cmp'} -w 0.0";
print("\n\nEmbedded Re-estimation for untied mmfs\n");
shell("$HERest{'ful'} -H $untymmf{'cmp'} -N $untymmf{'dur'} -M $model{'cmp'} -R $model{'dur'} $opt $lst{'ful'} $lst{'ful'}");
}
# HHEd (tree-based context clustering)
if ($CXCL2) {
print_time("tree-based context clustering");
# convert cmp stats to duration ones
convstats();
# tree-based clustering
foreach $set (@SET) {
shell("cp $untymmf{$set} $reclmmf{$set}");
$footer = "";
foreach $type ( @{ $ref{$set} } ) {
make_edfile_state($type);
shell("$HHEd{'trn'} -C $cfg{$type} -H $reclmmf{$set} $mdl{$type} -w $reclmmf{$set} $cxc{$type} $lst{'ful'}");
$footer .= "_$type";
shell("gzip -c $reclmmf{$set} > $reclmmf{$set}$footer.gz");
}
shell("gzip -c $reclmmf{$set} > $reclmmf{$set}.nonembedded.gz");
}
}
# fix variables
$stats{'cmp'} =~ s/untied/re-clustered/;
# HERest (embedded reestimation (re-clustered))
if ($ERST4) {
print_time("embedded reestimation (re-clustered)");
for ( $i = 1 ; $i <= $nIte ; $i++ ) {
if ( $i == $nIte ) {
$opt = "-s $stats{'cmp'}";
}
else {
$opt = "";
}
print("\n\nIteration $i of Embedded Re-estimation\n");
shell("$HERest{'ful'} -H $reclmmf{'cmp'} -N $reclmmf{'dur'} -M $model{'cmp'} -R $model{'dur'} $opt $lst{'ful'} $lst{'ful'}");
}
# compress reestimated mmfs
foreach $set (@SET) {
shell("gzip -c $reclmmf{$set} > $reclmmf{$set}.embedded.gz");
}
}
# HSMMAlign (forced alignment for no-silent GV)
if ($FALGN) {
print_time("forced alignment for no-silent GV");
if ( ( $useHmmGV && $nosilgv && @slnt > 0 ) || $useDNN ) {
# make directory
mkdir "$gvdir/fal", 0755;
mkdir "$gvfaldir{'phn'}", 0755;
mkdir "$gvfaldir{'stt'}", 0755;
foreach $sbase ( split / /, $trainSpkr ) {
mkdir "$gvfaldir{'phn'}/$sbase", 0755;
mkdir "$gvfaldir{'stt'}/$sbase", 0755;
}
# forced alignment
shell("$HSMMAlign{'trn'} -f -H $reclmmf{'cmp'} -N $reclmmf{'dur'} -m $gvfaldir{'stt'} $lst{'ful'} $lst{'ful'}");
# convert state alignment to phoneme alignment
convert_state2phone();
}
}
# making global variance
if ($MCDGV) {
print_time("making global variance");
if ($useHmmGV) {
# make directories
mkdir "$gvdatdir", 0755;
mkdir "$gvlabdir", 0755;
mkdir "$gvmodels", 0755;
mkdir "$gvdir/proto", 0755;
mkdir "$gvdir/stats", 0755;
mkdir "$gvdir/trees", 0755;
mkdir "$gvdir/edfiles", 0755;
foreach $sbase ( split / /, $trainSpkr ) {
mkdir "$gvdatdir/$sbase", 0755;
mkdir "$gvlabdir/$sbase", 0755;
}
# make proto
make_proto_gv();
# make training data, labels, scp, list, and mlf
make_data_gv();
# make average model
shell("$HCompV{'gv'} -o $avermmf{'gv'} -M $gvmodels $prtfile{'gv'}");
if ($cdgv) {
# make full context depdent model
copy_aver2full_gv();
shell("$HERest{'gv'} -C $cfg{'nvf'} -s $stats{'gv'} -w 0.0 -H $fullmmf{'gv'} -M $gvmodels $lst{'gv'}");
# context-clustering
my $s = 1;
shell("cp $fullmmf{'gv'} $clusmmf{'gv'}");
foreach $type (@cmp) {
make_edfile_state_gv( $type, $s );
shell("$HHEd{'trn'} -H $clusmmf{'gv'} $gvmdl{$type} -w $clusmmf{'gv'} $gvcxc{$type} $lst{'gv'}");
$s++;
}
# re-estimation
shell("$HERest{'gv'} -H $clusmmf{'gv'} -M $gvmodels $lst{'gv'}");
}
else {
copy_aver2clus_gv();
}
}
}
# HHEd (making unseen models (GV))
if ($MKUNG) {
print_time("making unseen models (GV)");
if ($useHmmGV) {
if ($cdgv) {
make_edfile_mkunseen_gv();
shell("$HHEd{'trn'} -H $clusmmf{'gv'} -w $clsammf{'gv'} $mku{'gv'} $lst{'gv'}");
}
else {
copy_clus2clsa_gv();
}
}
}
# HHEd (making unseen models (speaker independent))
if ($MKUN1) {
print_time("making unseen models (speaker independent)");
foreach $set (@SET) {
make_edfile_mkunseen($set);
shell("$HHEd{'trn'} -H $reclmmf{$set} -w $rclammf{$set} $mku{$set} $lst{'ful'}");
}
}
# HMGenS (generating speech parameter sequences (speaker independent))
if ($PGEN1) {
print_time("generating speech parameter sequences (speaker independent)");
$mix = 'SI';
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
mkdir "${prjdir}/gen/ver${ver}/$mix", 0755;
mkdir $dir, 0755;
# generate parameter
shell("$HMGenS -c $pgtype -H $rclammf{'cmp'} -N $rclammf{'dur'} -M $dir $tiedlst{'cmp'} $tiedlst{'dur'}");
}
# SPTK (synthesizing waveforms (speaker independent))
if ($WGEN1) {
print_time("synthesizing waveforms (speaker independent)");
$mix = 'SI';
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
if ( !$useHmmGV ) {
$pf = 1;
}
else {
$pf = 0;
}
gen_wave( "$dir", $pf );
}
# HHEd (building regression-class trees for adaptation)
if ($REGTR) {
print_time("building regression-class trees for adaptation");
foreach $set (@SET) {
foreach $type ( 'reg', 'dec' ) { # reg -> regression tree (k-means), dec -> decision tree
make_edfile_regtree( $type, $set );
shell("$HHEd{'trn'} -C $cfg{'dec'}{$set} -H $reclmmf{$set} -M $regtree{$set} $red{$set}{$type} $lst{'ful'}");
}
}
}
# HERest (speaker adaptation (speaker independent))
if ($ADPT1) {
print_time("speaker adaptation (speaker independent)");
$type = $tknd{'adp'};
$mllr = $tran;
for ( $i = 1 ; $i <= $nAdapt ; $i++ ) {
print("\n\nIteration $i of adaptation transform reestimation\n");
# Reestimate transform
$mix = "SI+${type}_${mllr}${i}";
$opt = "-C $cfg{'adp'} ";
$opt .= "-K $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-Z $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
if ( $i > 1 ) {
$mix2 = "SI+${type}_${mllr}" . ( ${i} - 1 );
$opt .= "-J $xforms{'cmp'} ${mix2} -Y $xforms{'dur'} ${mix2} -a -b ";
}
shell("$HERest{'adp'} -H $rclammf{'cmp'} -N $rclammf{'dur'} $opt $tiedlst{'cmp'} $tiedlst{'dur'}");
}
if ($addMAP) {
print("\n\nadditional MAP estimation\n");
$opt = "-C $cfg{'map'} ";
if ( $nAdapt > 0 ) {
$mix = "SI+${type}_${mllr}${nAdapt}";
$opt .= "-H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} -J $xforms{'cmp'} ${mix} -E $xforms{'cmp'} ${mix} -a ";
$opt .= "-N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} -Y $xforms{'dur'} ${mix} -W $xforms{'dur'} ${mix} -b ";
}
shell("$HERest{'map'} -H $rclammf{'cmp'} -N $rclammf{'dur'} -M $mapmmf{'cmp'} -R $mapmmf{'dur'} $opt $tiedlst{'cmp'} $tiedlst{'dur'}");
}
}
if ($addMAP) {
for $set (@SET) {
$rclammf{$set} = "$mapmmf{$set}/re_clustered_all.mmf";
}
}
# HMGenS (generating speech parameter sequences (speaker adapted))
if ($PGEN2) {
print_time("generating speech parameter sequences (speaker adapted)");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SI+${type}_${mllr}${nAdapt}";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
mkdir "${prjdir}/gen/ver${ver}/$mix", 0755;
mkdir $dir, 0755;
$opt = "-a -J $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-b -Y $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
# generate parameter
shell("$HMGenS -c $pgtype -H $rclammf{'cmp'} -N $rclammf{'dur'} -M $dir ${opt} $tiedlst{'cmp'} $tiedlst{'dur'}");
}
# SPTK (synthesizing waveforms (speaker adapted))
if ($WGEN2) {
print_time("synthesizing waveforms (speaker adapted)");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SI+${type}_${mllr}${nAdapt}";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
if ( !$useHmmGV ) {
$pf = 1;
}
else {
$pf = 0;
}
gen_wave( "$dir", $pf );
}
# HERest (Speaker adaptive training (SAT))
if ($SPKAT) {
print_time("Speaker adaptive training (SAT)");
for $set (@SET) {
shell("cp $reclmmf{$set} $spatmmf{$set}");
}
$type = $tknd{'sat'};
$mllr = 'sat';
for ( $i = 1 ; $i <= $nSAT ; $i++ ) {
print("\n\nIteration $i of Speaker Adaptive Training\n");
# Reestimate transform
$mix = "${type}_${mllr}${i}";
$opt = "-u ada -C $cfg{'sat'} ";
$opt .= "-K $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-Z $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
if ( $i > 1 ) {
$mix2 = "${type}_${mllr}" . ( ${i} - 1 );
$opt .= "-J $xforms{'cmp'} ${mix2} -Y $xforms{'dur'} ${mix2} -a -b ";
}
print("\nEstimating transform for iteration $i\n");
shell("$HERest{'ful'} -H $spatmmf{'cmp'} -N $spatmmf{'dur'} $opt $lst{'ful'} $lst{'ful'}");
# Reestimate HMM and duration models
$opt = "-C $cfg{'sat'} ";
$opt .= "-a -J $xforms{'cmp'} ${mix} -E $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-b -Y $xforms{'dur'} ${mix} -W $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
for ( $j = 1 ; $j <= $nIte ; $j++ ) {
print("\n\nIteration $j of Embedded Re-estimation in SAT\n");
shell("$HERest{'ful'} -H $spatmmf{'cmp'} -N $spatmmf{'dur'} -M $model{'cmp'} -R $model{'dur'} $opt $lst{'ful'} $lst{'ful'}");
}
# compress reestimated mmfs
for $set (@SET) {
shell("gzip -c $spatmmf{$set} > $spatmmf{$set}.${i}.embedded.gz");
}
}
}
# HHEd (making unseen models (SAT))
if ($MKUN2) {
print_time("making unseen models (SAT)");
foreach $set (@SET) {
make_edfile_mkunseen($set);
shell("$HHEd{'trn'} -H $spatmmf{$set} -w $satammf{$set} $mku{$set} $lst{'ful'}");
}
}
# HMGenS (generating speech parameter sequences (SAT))
if ($PGEN3) {
print_time("generating speech parameter sequences (SAT)");
$mix = 'SAT';
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
mkdir "${prjdir}/gen/ver${ver}/$mix", 0755;
mkdir $dir, 0755;
# generate parameter
shell("$HMGenS -c $pgtype -H $satammf{'cmp'} -N $satammf{'dur'} -M $dir $tiedlst{'cmp'} $tiedlst{'dur'}");
}
# SPTK (synthesizing waveforms (SAT))
if ($WGEN3) {
print_time("synthesizing waveforms (SAT)");
$mix = 'SAT';
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
if ( !$useHmmGV ) {
$pf = 1;
}
else {
$pf = 0;
}
gen_wave( "$dir", $pf );
}
# HERest (speaker adaptation (SAT))
if ($ADPT2) {
print_time("speaker adaptation (SAT)");
$type = $tknd{'adp'};
$mllr = $tran;
for ( $i = 1 ; $i <= $nAdapt ; $i++ ) {
print("\n\nIteration $i of adaptation transform estimation\n");
# Reestimate transform
$mix = "SAT+${type}_${mllr}${i}";
$opt = "-C $cfg{'adp'} ";
$opt .= "-K $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-Z $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
if ( $i > 1 ) {
$mix2 = "SAT+${type}_${mllr}" . ( ${i} - 1 );
$opt .= "-J $xforms{'cmp'} ${mix2} -Y $xforms{'dur'} ${mix2} -a -b ";
}
else {
$opt .= "-C $cfg{'aln'}";
}
shell("$HERest{'adp'} -H $satammf{'cmp'} -N $satammf{'dur'} $opt $tiedlst{'cmp'} $tiedlst{'dur'}");
}
if ($addMAP) {
print("\n\nadditional MAP estimation\n");
$opt = "-C $cfg{'map'} ";
if ( $nAdapt > 0 ) {
$mix = "SAT+${type}_${mllr}${nAdapt}";
$opt .= "-H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} -J $xforms{'cmp'} ${mix} -E $xforms{'cmp'} ${mix} -a ";
$opt .= "-N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} -Y $xforms{'dur'} ${mix} -W $xforms{'dur'} ${mix} -b ";
}
shell("$HERest{'map'} -H $satammf{'cmp'} -N $satammf{'dur'} -M $mapmmf{'cmp'} -R $mapmmf{'dur'} $opt $tiedlst{'cmp'} $tiedlst{'dur'}");
}
}
if ($addMAP) {
for $set (@SET) {
$satammf{$set} = "$mapmmf{$set}/re_clustered_sat_all.mmf";
}
}
# HMGenS (generate speech parameter sequences (SAT+adaptation))
if ($PGEN4) {
print_time("generate speech parameter sequences (SAT+adaptation)");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SAT+${type}_${mllr}${nAdapt}";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
mkdir "${prjdir}/gen/ver${ver}/$mix", 0755;
mkdir $dir, 0755;
$opt = "-a -J $xforms{'cmp'} ${mix} -H $rbase{'cmp'}{$type} -H $rtree{'cmp'}{$type} ";
$opt .= "-b -Y $xforms{'dur'} ${mix} -N $rbase{'dur'}{$type} -N $rtree{'dur'}{$type} ";
# generate parameters
shell("$HMGenS -c $pgtype -H $satammf{'cmp'} -N $satammf{'dur'} -M $dir ${opt} $tiedlst{'cmp'} $tiedlst{'dur'}");
}
# SPTK (synthesizing waveforms (SAT+adaptation))
if ($WGEN4) {
print_time("synthesizing waveforms (SAT+adaptation)");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SAT+${type}_${mllr}${nAdapt}";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
if ( !$useHmmGV ) {
$pf = 1;
}
else {
$pf = 0;
}
gen_wave( "$dir", $pf );
}
# HHEd (converting mmfs to the HTS voice format)
if ( $CONVM && !$usestraight ) {
print_time("converting mmfs to the HTS voice format");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SAT+${type}_${mllr}${nAdapt}";
# models and trees
foreach $set (@SET) {
$spxf = "$xforms{$set}/${spkr}.${mix}";
$mmfs = "-H $rbase{$set}{$type} -H $rtree{$set}{$type}";
foreach $type ( @{ $ref{$set} } ) {
make_edfile_convert( $type, $spxf );
shell("$HHEd{'trn'} -H $satammf{$set} $mmfs $cnv{$type} $tiedlst{$set}");
shell("mv $trd{$set}/trees.$strb{$type} $trv{$type}");
shell("mv $model{$set}/pdf.$strb{$type} $pdf{$type}");
}
}
# window coefficients
foreach $type (@cmp) {
shell("cp $windir/${type}.win* $voice");
}
# gv pdfs
if ($useHmmGV) {
my $s = 1;
foreach $type (@cmp) { # convert hts_engine format
make_edfile_convert_gv($type);
shell("$HHEd{'trn'} -H $clusmmf{'gv'} $gvcnv{$type} $lst{'gv'}");
shell("mv $gvdir/trees.$s $gvtrv{$type}");
shell("mv $gvdir/pdf.$s $gvpdf{$type}");
$s++;
}
}
# low-pass filter
make_lpf();
# make HTS voice
make_htsvoice( "$voice", "${dset}_${spkr}" );
}
# hts_engine (synthesizing waveforms using hts_engine)
if ( $ENGIN && !$usestraight ) {
print_time("synthesizing waveforms using hts_engine");
$type = $tknd{'adp'};
$mllr = $tran;
$mix = "SAT+${type}_${mllr}${nAdapt}";
$dir = "${prjdir}/gen/ver${ver}/$mix/hts_engine";
mkdir ${dir}, 0755;
# hts_engine command line & options
$hts_engine = "$ENGINE -m ${voice}/${dset}_${spkr}.htsvoice ";
if ( !$useHmmGV ) {
if ( $gm == 0 ) {
$hts_engine .= "-b " . ( $pf_mcp - 1.0 ) . " ";
}
else {
$hts_engine .= "-b " . $pf_lsp . " ";
}
}
# generate waveform using hts_engine
open( SCP, "$scp{'gen'}" ) || die "Cannot open $!";
while (<SCP>) {
$lab = $_;
chomp($lab);
$base = `basename $lab .lab`;
chomp($base);
print " Synthesizing a speech waveform from $lab using hts_engine...";
if ( $useAVocoder ) {
shell("$hts_engine -om ${dir}/${base}.mgc -of ${dir}/${base}.lf0 -ot ${dir}/${base}.trace $lab");
print " Synthesizing a speech waveform from ${dir}/${base}.mgc/lf0...";
# generate using ahodecoder
$line = "$AHODECODER ${dir}/${base}.lf0 ${dir}/${base}.mgc ${dir}/${base}.wav --lframe=$fs";
shell($line);
}
else {
shell("$hts_engine -or ${dir}/${base}.raw -ow ${dir}/${base}.wav -ot ${dir}/${base}.trace $lab");
}
print "done\n";
}
close(SCP);
}
# making training/adaptation data for deep neural network
if ($MKDAT) {
print_time("making training/adaptation data for deep neural network");
if ($useDNN) {
mkdir "$gvfaldir{'stt'}/$spkr", 0755;
mkdir "$dnndir/ffi", 0755;
mkdir "$dnnffidir{'ful'}", 0755;
mkdir "$dnnffidir{'ful'}/$spkr", 0755;
foreach $sbase ( split / /, $trainSpkr ) {
mkdir "$dnnffidir{'ful'}/$sbase", 0755;
}
# forced alignment
shell("$HSMMAlign{'adp'} -f -H $rclammf{'cmp'} -N $rclammf{'dur'} -m $gvfaldir{'stt'}/$spkr $tiedlst{'cmp'} $tiedlst{'dur'}");
make_train_data_dnn();
make_adapt_data_dnn();
}
}
# TensorFlow (training a deep neural network)
if ($TRDNN) {
print_time("training a deep neural network");
if ($useDNN) {
mkdir "$dnnmodels", 0755;
shell("$PYTHON $datdir/scripts/DNNTraining.py -C $cfg{'tdn'} -S $scp{'tdn'} -H $dnnmodels -z $datdir/stats");
}
}
# TensorFlow (speaker adaptation (DNN))
if ($ADPT3) {
print_time("speaker adaptation (DNN)");
if ($useDNN) {
mkdir "$dnnmodelsdir{'adp'}", 0755;
shell("cp $dnnmodels/model.ckpt.* $dnnmodelsdir{'adp'}");
shell("$PYTHON $datdir/scripts/DNNTraining.py -C $cfg{'adn'} -S $scp{'adn'} -H $dnnmodelsdir{'adp'} -z $datdir/stats");
}
}
# TensorFlow & SPTK (generating speech parameter sequences (DNN+adaptation))
if ($PGEN5) {
print_time("generating speech parameter sequences (DNN+adaptation)");
if ($useDNN) {
$mix = "DNN";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
mkdir "${prjdir}/gen/ver${ver}/$mix", 0755;
mkdir $dir, 0755;
# predict duration from HMMs
shell("$HMGenS -c $pgtype -H $rclammf{'cmp'} -N $rclammf{'dur'} -M $dir $tiedlst{'cmp'} $tiedlst{'dur'}");
foreach $type (@cmp) {
shell("rm -f $dir/*.$type");
}
mkdir "$dnnffidir{'gen'}", 0755;
mkdir "$dnnffidir{'gen'}/$spkr", 0755;
convert_dur2lab($dir);
make_gen_data_dnn($dir);
# generate parameter
shell("$PYTHON $datdir/scripts/DNNSynthesis.py -C $cfg{'sdn'} -S $scp{'sdn'} -H $dnnmodelsdir{'adp'} -M $dir");
# generate smooth parameter sequence
gen_param("$dir");
}
}
# SPTK (synthesizing waveforms (DNN+adaptation))
if ($WGEN5) {
print_time("synthesizing waveforms (DNN+adaptation)");
if ($useDNN) {
$mix = "DNN";
$dir = "${prjdir}/gen/ver${ver}/$mix/$pgtype";
$pf = 1;
gen_wave( "$dir", $pf );
}
}
# sub routines ============================
sub shell($) {
my ($command) = @_;
my ($exit);
$exit = system($command);
if ( $exit / 256 != 0 ) {
die "Error in $command\n";
}
}
sub print_time ($) {
my ($message) = @_;
my ($ruler);
$message .= `date`;
$ruler = '';
for ( $i = 0 ; $i <= length($message) + 10 ; $i++ ) {
$ruler .= '=';
}
print "\n$ruler\n";
print "Start @_ at " . `date`;
print "$ruler\n\n";
}
# sub routine for generating proto-type model
sub make_proto {
my ( $i, $j, $k, $s );
# output prototype definition
# open proto type definition file
open( PROTO, ">$prtfile{'cmp'}" ) || die "Cannot open $!";
# output header
# output vector size & feature type
print PROTO "~o <VecSize> $vSize{'cmp'}{'total'} <USER> <DIAGC>";
# output information about multi-space probability distribution (MSD)
print PROTO "<MSDInfo> $nstream{'cmp'}{'total'} ";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print PROTO " $msdi{$type} ";
}
}
# output information about stream
print PROTO "<StreamInfo> $nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
printf PROTO " %d", $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type};
}
}
print PROTO "\n";
# output HMMs
print PROTO "<BeginHMM>\n";
printf PROTO " <NumStates> %d\n", $nState + 2;
# output HMM states
for ( $i = 2 ; $i <= $nState + 1 ; $i++ ) {
# output state information
print PROTO " <State> $i\n";
# output stream weight
print PROTO " <SWeights> $nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print PROTO " $strw{$type}";
}
}
print PROTO "\n";
# output stream information
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print PROTO " <Stream> $s\n";
if ( $msdi{$type} == 0 ) { # non-MSD stream
# output mean vector
printf PROTO " <Mean> %d\n", $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type};
for ( $k = 1 ; $k <= $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "0.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
# output covariance matrix (diag)
printf PROTO " <Variance> %d\n", $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type};
for ( $k = 1 ; $k <= $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "1.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
}
else { # MSD stream
# output MSD
print PROTO " <NumMixes> 2\n";
# output 1st space (non 0-dimensional space)
# output space weights
print PROTO " <Mixture> 1 0.5000\n";
# output mean vector
printf PROTO " <Mean> %d\n", $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type};
for ( $k = 1 ; $k <= $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "0.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
# output covariance matrix (diag)
printf PROTO " <Variance> %d\n", $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type};
for ( $k = 1 ; $k <= $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "1.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
# output 2nd space (0-dimensional space)
print PROTO " <Mixture> 2 0.5000\n";
print PROTO " <Mean> 0\n";
print PROTO " <Variance> 0\n";
}
}
}
}
# output state transition matrix
printf PROTO " <TransP> %d\n", $nState + 2;
print PROTO " ";
for ( $j = 1 ; $j <= $nState + 2 ; $j++ ) {
print PROTO "1.000e+0 " if ( $j == 2 );
print PROTO "0.000e+0 " if ( $j != 2 );
}
print PROTO "\n";
print PROTO " ";
for ( $i = 2 ; $i <= $nState + 1 ; $i++ ) {
for ( $j = 1 ; $j <= $nState + 2 ; $j++ ) {
print PROTO "6.000e-1 " if ( $i == $j );
print PROTO "4.000e-1 " if ( $i == $j - 1 );
print PROTO "0.000e+0 " if ( $i != $j && $i != $j - 1 );
}
print PROTO "\n";
print PROTO " ";
}
for ( $j = 1 ; $j <= $nState + 2 ; $j++ ) {
print PROTO "0.000e+0 ";
}
print PROTO "\n";
# output footer
print PROTO "<EndHMM>\n";
close(PROTO);
}
sub make_duration_vfloor {
my ( $dm, $dv ) = @_;
my ( $i, $j );
# output variance flooring macro for duration model
open( VF, ">$vfloors{'dur'}" ) || die "Cannot open $!";
for ( $i = 1 ; $i <= $nState ; $i++ ) {
print VF "~v varFloor$i\n";
print VF "<Variance> 1\n";
$j = $dv * $vflr{'dur'};
print VF " $j\n";
}
close(VF);
# output average model for duration model
open( MMF, ">$avermmf{'dur'}" ) || die "Cannot open $!";
print MMF "~o\n";
print MMF "<STREAMINFO> $nState";
for ( $i = 1 ; $i <= $nState ; $i++ ) {
print MMF " 1";
}
print MMF "\n";
print MMF "<VECSIZE> ${nState}<NULLD><USER><DIAGC>\n";
print MMF "~h \"$avermmf{'dur'}\"\n";
print MMF "<BEGINHMM>\n";
print MMF "<NUMSTATES> 3\n";
print MMF "<STATE> 2\n";
for ( $i = 1 ; $i <= $nState ; $i++ ) {
print MMF "<STREAM> $i\n";
print MMF "<MEAN> 1\n";
print MMF " $dm\n";
print MMF "<VARIANCE> 1\n";
print MMF " $dv\n";
}
print MMF "<TRANSP> 3\n";
print MMF " 0.0 1.0 0.0\n";
print MMF " 0.0 0.0 1.0\n";
print MMF " 0.0 0.0 0.0\n";
print MMF "<ENDHMM>\n";
close(MMF);
}
# sub routine for generating proto-type model for GV
sub make_proto_gv {
my ( $s, $type, $k );
open( PROTO, "> $prtfile{'gv'}" ) || die "Cannot open $!";
$s = 0;
foreach $type (@cmp) {
$s += $ordr{$type};
}
print PROTO "~o <VecSize> $s <USER> <DIAGC>\n";
print PROTO "<MSDInfo> $nPdfStreams{'cmp'} ";
foreach $type (@cmp) {
print PROTO "0 ";
}
print PROTO "\n";
print PROTO "<StreamInfo> $nPdfStreams{'cmp'} ";
foreach $type (@cmp) {
print PROTO "$ordr{$type} ";
}
print PROTO "\n";
print PROTO "<BeginHMM>\n";
print PROTO " <NumStates> 3\n";
print PROTO " <State> 2\n";
$s = 1;
foreach $type (@cmp) {
print PROTO " <Stream> $s\n";
print PROTO " <Mean> $ordr{$type}\n";
for ( $k = 1 ; $k <= $ordr{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "0.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
print PROTO " <Variance> $ordr{$type}\n";
for ( $k = 1 ; $k <= $ordr{$type} ; $k++ ) {
print PROTO " " if ( $k % 10 == 1 );
print PROTO "1.0 ";
print PROTO "\n" if ( $k % 10 == 0 );
}
print PROTO "\n" if ( $k % 10 != 1 );
$s++;
}
print PROTO " <TransP> 3\n";
print PROTO " 0.000e+0 1.000e+0 0.000e+0 \n";
print PROTO " 0.000e+0 0.000e+0 1.000e+0 \n";
print PROTO " 0.000e+0 0.000e+0 0.000e+0 \n";
print PROTO "<EndHMM>\n";
close(PROTO);
}
# sub routine for making training data, labels, scp, list, and mlf for GV
sub make_data_gv {
my ( $type, $cmp, $base, $str, @arr, $start, $end, $find, $i, $j, $spkr, $pattern );
shell("rm -f $scp{'gv'}");
shell("touch $scp{'gv'}");
open( SCP, $scp{'trn'} ) || die "Cannot open $!";
if ($cdgv) {
open( LST, "> $gvdir/tmp.list" );
}
while (<SCP>) {
$cmp = $_;
chomp($cmp);
$sbase = `dirname $cmp`;
chomp($sbase);
$sbase = `basename $sbase`;
chomp($sbase);
$base = `basename $cmp .cmp`;
chomp($base);
print " Making data, labels, and scp from $base.lab for GV...";
shell("rm -f $gvdatdir/tmp.cmp");
shell("touch $gvdatdir/tmp.cmp");
$i = 0;
foreach $type (@cmp) {
if ( $nosilgv && @slnt > 0 ) {
shell("rm -f $gvdatdir/tmp.$type");
shell("touch $gvdatdir/tmp.$type");
open( F, "$gvfaldir{'phn'}/$sbase/$base.lab" ) || die "Cannot open $!";
while ( $str = <F> ) {
chomp($str);
@arr = split( / /, $str );
$find = 0;
for ( $j = 0 ; $j < @slnt ; $j++ ) {
if ( $arr[2] eq "$slnt[$j]" ) { $find = 1; last; }
}
if ( $find == 0 ) {
$start = int( $arr[0] * ( 1.0E-07 / ( $fs / $sr ) ) );
$end = int( $arr[1] * ( 1.0E-07 / ( $fs / $sr ) ) );
shell("$BCUT -s $start -e $end -l $ordr{$type} $datdir/$type/$sbase/$base.$type >> $gvdatdir/tmp.$type");
}
}
close(F);
}
else {
shell("cp $datdir/$type/$sbase/$base.$type $gvdatdir/tmp.$type");
}
if ( $msdi{$type} == 0 ) {
shell("cat $gvdatdir/tmp.$type | $VSTAT -d -l $ordr{$type} -o 2 >> $gvdatdir/tmp.cmp");
}
else {
shell("$X2X +fa $gvdatdir/tmp.$type | grep -v '1e+10' | $X2X +af | $VSTAT -d -l $ordr{$type} -o 2 >> $gvdatdir/tmp.cmp");
}
system("rm -f $gvdatdir/tmp.$type");
$i += 4 * $ordr{$type};
}
shell("$PERL $datdir/scripts/addhtkheader.pl $sr $fs $i 9 $gvdatdir/tmp.cmp > $gvdatdir/$sbase/$base.cmp");
$i = `$NAN $gvdatdir/$sbase/$base.cmp`;
chomp($i);
if ( length($i) > 0 ) {
shell("rm -f $gvdatdir/$sbase/$base.cmp");
}
else {
shell("echo $gvdatdir/$sbase/$base.cmp >> $scp{'gv'}");
if ($cdgv) {
open( LAB, "$datdir/labels/full/$sbase/$base.lab" ) || die "Cannot open $!";
$str = <LAB>;
close(LAB);
chomp($str);
while ( index( $str, " " ) >= 0 || index( $str, "\t" ) >= 0 ) { substr( $str, 0, 1 ) = ""; }
open( LAB, "> $gvlabdir/$sbase/$base.lab" ) || die "Cannot open $!";
print LAB "$str\n";
close(LAB);
print LST "$str\n";
}
}
system("rm -f $gvdatdir/tmp.cmp");
print "done\n";
}
if ($cdgv) {
close(LST);
system("sort -u $gvdir/tmp.list > $lst{'gv'}");
system("rm -f $gvdir/tmp.list");
}
else {
system("echo gv > $lst{'gv'}");
}
close(SCP);
# make mlf
open( MLF, "> $mlf{'gv'}" ) || die "Cannot open $!";
print MLF "#!MLF!#\n";
foreach $spkr ( split / /, $trainSpkr ) {
$pattern = $spkrPat;
$pattern =~ s/%+/$spkr/;
$pattern =~ s/"$//;
print MLF "$pattern.lab\" -> \"$gvlabdir/$spkr\"\n";
}
close(MLF);
}
# sub routine to copy average.mmf to full.mmf for GV
sub copy_aver2full_gv {
my ( $find, $head, $tail, $str );
$find = 0;
$head = "";
$tail = "";
open( MMF, "$avermmf{'gv'}" ) || die "Cannot open $!";
while ( $str = <MMF> ) {
if ( index( $str, "~h" ) >= 0 ) {
$find = 1;
}
elsif ( $find == 0 ) {
$head .= $str;
}
else {
$tail .= $str;
}
}
close(MMF);
$head .= `cat $vfloors{'gv'}`;
open( LST, "$lst{'gv'}" ) || die "Cannot open $!";
open( MMF, "> $fullmmf{'gv'}" ) || die "Cannot open $!";
print MMF "$head";
while ( $str = <LST> ) {
chomp($str);
print MMF "~h \"$str\"\n";
print MMF "$tail";
}
close(MMF);
close(LST);
}
sub copy_aver2clus_gv {
my ( $find, $head, $mid, $tail, $str, $tmp, $s, @pdfs );
# initaialize
$find = 0;
$head = "";
$mid = "";
$tail = "";
$s = 0;
@pdfs = ();
foreach $type (@cmp) {
push( @pdfs, "" );
}
# load
open( MMF, "$avermmf{'gv'}" ) || die "Cannot open $!";
while ( $str = <MMF> ) {
if ( index( $str, "~h" ) >= 0 ) {
$head .= `cat $vfloors{'gv'}`;
last;
}
else {
$head .= $str;
}
}
while ( $str = <MMF> ) {
if ( index( $str, "<STREAM>" ) >= 0 ) {
last;
}
else {
$mid .= $str;
}
}
while ( $str = <MMF> ) {
if ( index( $str, "<TRANSP>" ) >= 0 ) {
$tail .= $str;
last;
}
elsif ( index( $str, "<STREAM>" ) >= 0 ) {
$s++;
}
else {
$pdfs[$s] .= $str;
}
}
while ( $str = <MMF> ) {
$tail .= $str;
}
close(MMF);
# save
open( MMF, "> $clusmmf{'gv'}" ) || die "Cannot open $!";
print MMF "$head";
$s = 1;
foreach $type (@cmp) {
print MMF "~p \"gv_${type}_1\"\n";
print MMF "<STREAM> $s\n";
print MMF "$pdfs[$s-1]";
$s++;
}
print MMF "~h \"gv\"\n";
print MMF "$mid";
$s = 1;
foreach $type (@cmp) {
print MMF "<STREAM> $s\n";
print MMF "~p \"gv_${type}_1\"\n";
$s++;
}
print MMF "$tail";
close(MMF);
close(LST);
}
sub copy_clus2clsa_gv {
shell("cp $clusmmf{'gv'} $clsammf{'gv'}");
shell("cp $lst{'gv'} $tiedlst{'gv'}");
}
sub convert_state2phone {
my ( $pattern, $line, @FILE, $file, $dir, $spkr, $base, $s, $e, $phone, $ct, @ary );
$pattern = format_spkr_pattern($spkrPat);
@FILE = glob "$gvfaldir{'stt'}/*.lab";
foreach $file (@FILE) {
$dir = `dirname $file`;
chomp $dir;
if ( $file =~ /$pattern/ ) {
$spkr = $1;
shell("mv $file $dir/$spkr");
}
}
foreach $spkr ( split / /, $trainSpkr ) {
@FILE = glob "$gvfaldir{'stt'}/$spkr/*.lab";
foreach $file (@FILE) {
$base = `basename $file`;
chomp($base);
open( STATE, "$file" ) || die "Cannot open $!";
open( PHONE, ">$gvfaldir{'phn'}/$spkr/$base" ) || die "Cannot open $!";
$ct = 1;
while ( $line = <STATE> ) {
$line =~ s/^\s*(.*?)\s*$/$1/;
if ( $ct == 1 ) {
@ary = split /\s+/, $line;
$s = $ary[0];
$phone = ( $ary[2] =~ /^.+?-(.+?)\+/ ) ? $1 : "";
}
elsif ( $ct == $nState ) {
@ary = split /\s+/, $line;
$e = $ary[1];
$ct = 0;
print PHONE "$s $e $phone\n";
}
$ct++;
}
close(PHONE);
close(STATE);
}
}
}
sub convert_dur2lab($) {
my ($gendir) = @_;
my ( $line, @FILE, $file, $base, $s, $e, $model, $ct, $t, $p, @ary );
$p = int( 1.0E+07 * $fs / $sr );
@FILE = glob "$gendir/*.dur";
foreach $file (@FILE) {
$base = `basename $file .dur`;
chomp($base);
open( DUR, "$file" ) || die "Cannot open $!";
open( LAB, ">$gendir/$base.lab" ) || die "Cannot open $!";
$t = 0;
$ct = 1;
while ( $line = <DUR> ) {
if ( $ct <= $nState ) {
$line =~ s/^\s*(.*?)\s*$/$1/;
( $model, $dur, @ary ) = split /\s+/, $line;
$model =~ s/\.state\[\d+\]://;
$dur =~ s/duration=//;
$s = $t * $p;
$e = ( $t + $dur ) * $p;
$t += $dur;
print LAB "$s $e $model\[" . ( $ct + 1 ) . "\]";
print LAB " $model" if ( $ct == 1 );
print LAB "\n";
$ct++;
}
else {
$ct = 1;
}
}
close(LAB);
close(DUR);
}
}
sub format_spkr_pattern($) {
my ($pattern) = @_;
$pattern =~ s/^"//;
$pattern =~ s/"$//;
$pattern =~ s/\*/.*/g;
if ( $pattern =~ /%(%*)%/ ) {
$pattern =~ s/%(%*)%/(.$1.)/;
$pattern =~ s/%/./g;
}
else {
$pattern =~ s/%/(.)/;
}
return $pattern;
}
# sub routine for making labels and scp for DNN
sub make_train_data_dnn {
my ( $line, $base, $lab, $ffi, $ffo );
foreach $sbase ( split / /, $trainSpkr ) {
# make frame-by-frame input features
foreach $lab ( glob "$gvfaldir{'stt'}/$sbase/*.lab" ) {
$base = `basename $lab .lab`;
chomp($base);
print " Making data from $lab for neural network training...";
$line = "$PERL $datdir/scripts/makefeature.pl $qconf " . int( 10E+6 * $fs / $sr ) . " $lab | ";
$line .= "$X2X +af > $dnnffidir{'ful'}/$sbase/$base.ffi";
shell($line);
print "done\n";
}
}
# make scp
open( SCP, ">$scp{'tdn'}" ) || die "Cannot open $!";
foreach $sbase ( split / /, $trainSpkr ) {
foreach $ffi ( glob "$dnnffidir{'ful'}/$sbase/*.ffi" ) {
$base = `basename $ffi .ffi`;
chomp($base);
$ffo = "$datdir/ffo/$sbase/$base.ffo";
if ( -s $ffi && -s $ffo ) {
print SCP "$ffi $ffo\n";
}
}
}
close(SCP);
}
sub make_adapt_data_dnn {
my ( $line, $base, $lab, $ffi, $ffo );
# make frame-by-frame input features
foreach $lab ( glob "$gvfaldir{'stt'}/$spkr/*.lab" ) {
$base = `basename $lab .lab`;
chomp($base);
print " Making data from $lab for neural network training...";
$line = "$PERL $datdir/scripts/makefeature.pl $qconf " . int( 10E+6 * $fs / $sr ) . " $lab | ";
$line .= "$X2X +af > $dnnffidir{'ful'}/$spkr/$base.ffi";
shell($line);
print "done\n";
}
# make scp
open( SCP, ">$scp{'adn'}" ) || die "Cannot open $!";
foreach $ffi ( glob "$dnnffidir{'ful'}/$spkr/*.ffi" ) {
$base = `basename $ffi .ffi`;
chomp($base);
$ffo = "$datdir/ffo/$spkr/$base.ffo";
if ( -s $ffi && -s $ffo ) {
print SCP "$ffi $ffo\n";
}
}
close(SCP);
}
sub make_gen_data_dnn($) {
my ($gendir) = @_;
my ( $line, $base, $lab );
# make frame-by-frame input features
foreach $lab ( glob "$gendir/*.lab" ) {
$base = `basename $lab .lab`;
chomp($base);
print " Making data from $lab for neural network running...";
$line = "$PERL $datdir/scripts/makefeature.pl $qconf " . int( 10E+6 * $fs / $sr ) . " $lab 2> /dev/null | ";
$line .= "$X2X +af > $dnnffidir{'gen'}/$spkr/$base.ffi";
shell($line);
print "done\n";
}
# make scp
open( SCP, ">$scp{'sdn'}" ) || die "Cannot open $!";
print SCP "$_\n" for glob "$dnnffidir{'gen'}/$spkr/*.ffi";
close(SCP);
}
# sub routine for generating config files
sub make_config {
my ( $s, $type, @boolstring );
$boolstring[0] = 'FALSE';
$boolstring[1] = 'TRUE';
# config file for model training
open( CONF, ">$cfg{'trn'}" ) || die "Cannot open $!";
print CONF "APPLYVFLOOR = T\n";
print CONF "NATURALREADORDER = T\n";
print CONF "NATURALWRITEORDER = T\n";
print CONF "VFLOORSCALESTR = \"Vector $nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $vflr{$type}";
}
}
print CONF "\"\n";
printf CONF "DURVARFLOORPERCENTILE = %f\n", 100 * $vflr{'dur'};
print CONF "APPLYDURVARFLOOR = T\n";
print CONF "MAXSTDDEVCOEF = $maxdev\n";
print CONF "MINDUR = $mindur\n";
close(CONF);
# config file for model training (without variance flooring)
open( CONF, ">$cfg{'nvf'}" ) || die "Cannot open $!";
print CONF "APPLYVFLOOR = F\n";
print CONF "DURVARFLOORPERCENTILE = 0.0\n";
print CONF "APPLYDURVARFLOOR = F\n";
close(CONF);
# config file for model tying
foreach $type (@cmp) {
open( CONF, ">$cfg{$type}" ) || die "Cannot open $!";
print CONF "MINLEAFOCC = $mocc{$type}\n";
close(CONF);
}
foreach $type (@dur) {
open( CONF, ">$cfg{$type}" ) || die "Cannot open $!";
print CONF "MINLEAFOCC = $mocc{$type}\n";
close(CONF);
}
# config file for parameter generation
open( CONF, ">$cfg{'syn'}" ) || die "Cannot open $!";
print CONF "NATURALREADORDER = T\n";
print CONF "NATURALWRITEORDER = T\n";
print CONF "USEALIGN = T\n";
print CONF "HGEN: TRACE = 1\n";
print CONF "PDFSTRSIZE = \"IntVec $nPdfStreams{'cmp'}"; # PdfStream structure
foreach $type (@cmp) {
print CONF " $nstream{'cmp'}{$type}";
}
print CONF "\"\n";
print CONF "PDFSTRORDER = \"IntVec $nPdfStreams{'cmp'}"; # order of each PdfStream
foreach $type (@cmp) {
print CONF " $ordr{$type}";
}
print CONF "\"\n";
print CONF "PDFSTREXT = \"StrVec $nPdfStreams{'cmp'}"; # filename extension for each PdfStream
foreach $type (@cmp) {
print CONF " $type";
}
print CONF "\"\n";
print CONF "WINFN = \"";
foreach $type (@cmp) {
print CONF "StrVec $nwin{$type} @{$win{$type}} "; # window coefficients files for each PdfStream
}
print CONF "\"\n";
print CONF "WINDIR = $windir\n"; # directory which stores window coefficients files
print CONF "MAXEMITER = $maxEMiter\n";
print CONF "EMEPSILON = $EMepsilon\n";
print CONF "USEGV = $boolstring[$useHmmGV]\n";
print CONF "GVMODELMMF = $clsammf{'gv'}\n";
print CONF "GVHMMLIST = $tiedlst{'gv'}\n";
print CONF "MAXGVITER = $maxGViter\n";
print CONF "GVEPSILON = $GVepsilon\n";
print CONF "MINEUCNORM = $minEucNorm\n";
print CONF "STEPINIT = $stepInit\n";
print CONF "STEPINC = $stepInc\n";
print CONF "STEPDEC = $stepDec\n";
print CONF "HMMWEIGHT = $hmmWeight\n";
print CONF "GVWEIGHT = $gvWeight\n";
print CONF "OPTKIND = $optKind\n";
if ( $nosilgv && @slnt > 0 ) {
$s = @slnt;
print CONF "GVOFFMODEL = \"StrVec $s";
for ( $s = 0 ; $s < @slnt ; $s++ ) {
print CONF " $slnt[$s]";
}
print CONF "\"\n";
}
print CONF "CDGV = $boolstring[$cdgv]\n";
close(CONF);
}
sub make_config_regtree {
# config file for building regression tree
foreach $set (@SET) {
open( CONF, ">$cfg{'dec'}{$set}" ) || die "Cannot open $!";
print CONF "SHRINKOCCTHRESH = \"Vector $nstream{$set}{'total'}";
foreach $type ( @{ $ref{$set} } ) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $dect{$type}";
}
}
print CONF "\"\n";
close(CONF);
}
}
# sub routine for generating config files for adaptation
sub make_config_adapt {
my ( $s, $b, $type, $bSize );
# config file for adaptation
open( CONF, ">$cfg{'adp'}" ) || die "Cannot open $!";
print CONF "MAXSTDDEVCOEF = 10\n"; # expand max # of state durations
print CONF "ADAPTKIND = TREE\n";
print CONF "DURADAPTKIND = TREE\n";
print CONF "BASECLASS = \"$rbase{'cmp'}{$tknd{'adp'}}\"\n";
print CONF "REGTREE = \"$rtree{'cmp'}{$tknd{'adp'}}\"\n";
print CONF "DURBASECLASS = \"$rbase{'dur'}{$tknd{'adp'}}\"\n";
print CONF "DURREGTREE = \"$rtree{'dur'}{$tknd{'adp'}}\"\n";
# adaptation transform kind
if ( $tran eq "mean" ) {
print CONF "TRANSKIND = MLLRMEAN\n"; # mean transform
print CONF "USEBIAS = $bias{'cmp'}\n";
print CONF "DURTRANSKIND = MLLRMEAN\n";
print CONF "DURUSEBIAS = $bias{'dur'}\n";
print CONF "MLLRDIAGCOV = $dcov\n";
print CONF "USEMAPLR = $usemaplr\n";
print CONF "USEVBLR = $usevblr\n";
print CONF "USESTRUCTURALPRIOR = $sprior\n";
print CONF "PRIORSCALE = $priorscale\n";
}
elsif ( $tran eq "cov" ) {
print CONF "TRANSKIND = MLLRCOV\n"; # covariance transform
print CONF "USEBIAS = FALSE\n";
print CONF "DURTRANSKIND = MLLRCOV\n";
print CONF "DURUSEBIAS = FALSE\n";
print CONF "MLLRDIAGCOV = FALSE\n";
}
elsif ( $tran eq "feat" ) {
print CONF "TRANSKIND = CMLLR\n"; # feature transform
print CONF "USEBIAS = $bias{'cmp'}\n";
print CONF "DURTRANSKIND = CMLLR\n";
print CONF "DURUSEBIAS = $bias{'dur'}\n";
print CONF "MLLRDIAGCOV = FALSE\n";
print CONF "USEMAPLR = $usemaplr\n";
print CONF "USESTRUCTURALPRIOR = $sprior\n";
print CONF "PRIORSCALE = $priorscale\n";
}
else {
die "MLLR type $tran is not supported!";
}
# split threshold for adaptation
# HMM
print CONF "SPLITTHRESH = \"Vector $nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $adpt{$type}";
}
}
print CONF "\"\n";
# duration model
print CONF "DURSPLITTHRESH = \"Vector $nState";
foreach $type (@dur) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $adpt{$type}";
}
}
print CONF "\"\n";
# block size
print CONF "BLOCKSIZE = \"";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
$bSize = $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} / $nblk{$type};
print CONF "IntVec $nblk{$type} ";
for ( $b = 1 ; $b <= $nblk{$type} ; $b++ ) {
print CONF "$bSize ";
}
}
}
print CONF "\"\n";
# band width
print CONF "BANDWIDTH = \"";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
$bSize = $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} / $nblk{$type};
print CONF "IntVec $nblk{$type} ";
for ( $b = 1 ; $b <= $nblk{$type} ; $b++ ) {
print CONF "$band{$type} ";
}
}
}
print CONF "\"\n";
close(CONF);
# config file for MAP adaptation
open( CONF, ">$cfg{'map'}" ) || die "Cannot open $!";
print CONF "MAPTAU = $maptau{'cmp'}\n";
print CONF "DURMAPTAU = $maptau{'dur'}\n";
print CONF "MINEGS = 1\n";
print CONF "APPLYVFLOOR = T\n";
print CONF "MIXWEIGHTFLOOR = $wf\n";
print CONF "HMAP:TRACE = 02\n";
close(CONF);
# config file for alignment model
open( CONF, ">$cfg{'aln'}" ) || die "Cannot open $!";
if ($addMAP) {
print CONF "ALIGNMODELMMF = $mapmmf{'cmp'}/re_clustered_all.mmf\n";
print CONF "ALIGNDURMMF = $mapmmf{'dur'}/re_clustered_all.mmf\n";
}
else {
print CONF "ALIGNMODELMMF = $rclammf{'cmp'}\n";
print CONF "ALIGNDURMMF = $rclammf{'dur'}\n";
}
print CONF "ALIGNHMMLIST = $tiedlst{'cmp'}\n";
print CONF "ALIGNDURLIST = $tiedlst{'dur'}\n";
close(CONF);
}
# sub routine for generating config file for speaker adaptive training
sub make_config_sat {
my ( $s, $b, $type, $bSize );
# config file for SAT
open( CONF, ">$cfg{'sat'}" ) || die "Cannot open $!";
print CONF "ADAPTKIND = TREE\n";
print CONF "DURADAPTKIND = TREE\n";
print CONF "BASECLASS = \"$rbase{'cmp'}{$tknd{'sat'}}\"\n";
print CONF "REGTREE = \"$rtree{'cmp'}{$tknd{'sat'}}\"\n";
print CONF "DURBASECLASS = \"$rbase{'dur'}{$tknd{'sat'}}\"\n";
print CONF "DURREGTREE = \"$rtree{'dur'}{$tknd{'sat'}}\"\n";
# adaptation transform kind
print CONF "TRANSKIND = CMLLR\n"; # feature transform
print CONF "USEBIAS = $bias{'cmp'}\n";
print CONF "DURTRANSKIND = CMLLR\n";
print CONF "DURUSEBIAS = $bias{'dur'}\n";
print CONF "MLLRDIAGCOV = FALSE\n";
# split threshold for adaptation
# HMM
print CONF "SPLITTHRESH = \"Vector $nstream{'cmp'}{'total'}";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $satt{$type}";
}
}
print CONF "\"\n";
# duration model
print CONF "DURSPLITTHRESH = \"Vector $nState";
foreach $type (@dur) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
print CONF " $satt{$type}";
}
}
print CONF "\"\n";
# block size
print CONF "BLOCKSIZE = \"";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
$bSize = $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} / $nblk{$type};
print CONF "IntVec $nblk{$type} ";
for ( $b = 1 ; $b <= $nblk{$type} ; $b++ ) {
print CONF "$bSize ";
}
}
}
print CONF "\"\n";
# band width
print CONF "BANDWIDTH = \"";
foreach $type (@cmp) {
for ( $s = $strb{$type} ; $s <= $stre{$type} ; $s++ ) {
$bSize = $vSize{'cmp'}{$type} / $nstream{'cmp'}{$type} / $nblk{$type};
print CONF "IntVec $nblk{$type} ";
for ( $b = 1 ; $b <= $nblk{$type} ; $b++ ) {
print CONF "$band{$type} ";
}
}
}
print CONF "\"\n";
close(CONF);
}
# sub routine for generating config file for DNN
sub make_config_dnn {
my ( $nin, $nhid, $nout );
my @activations = qw(Linear Sigmoid Tanh ReLU);
my @optimizers = qw(SGD Momentum AdaGrad AdaDelta Adam RMSprop);
$nin = `$PERL $datdir/scripts/makefeature.pl $qconf`;
chomp $nin;
$nhid = join ", ", ( split /\s+/, $nHiddenUnits );
$nout = 0;
foreach $type (@cmp) {
if ( $msdi{$type} != 0 ) {
$nout += 1;
}
$nout += $vSize{'cmp'}{$type};
}
open( CONF, ">$cfg{'tdn'}" ) || die "Cannot open $!";
print CONF "[Architecture]\n";
print CONF "num_input_units: $nin\n";
print CONF "num_hidden_units: [$nhid]\n";
print CONF "num_output_units: $nout\n";
print CONF "hidden_activation: \"$activations[$activation]\"\n";
print CONF "output_activation: \"$activations[0]\"\n";
print CONF "\n[Strategy]\n";
print CONF "optimizer: \"$optimizers[$optimizer]\"\n";
print CONF "learning_rate: $learnRate\n";
print CONF "keep_prob: $keepProb\n";
print CONF "queue_size: $queueSize\n";
print CONF "batch_size: $batchSize\n";
print CONF "num_epochs: $nEpoch\n";
print CONF "num_threads: $nThread\n";
print CONF "random_seed: $randomSeed\n";
print CONF "frame_by_frame: 1\n";
print CONF "adaptation: 0\n";
print CONF "\n[Output]\n";
print CONF "num_models_to_keep: $nKeep\n";
print CONF "log_interval: $logInterval\n";
print CONF "save_interval: $saveInterval\n";
print CONF "\n[Others]\n";
print CONF "all_spkrs: [\"" . join( "\", \"", ( split /\s+/, $trainSpkr ), $spkr ) . "\"]\n";
print CONF "spkr_pattern: \"" . format_spkr_pattern($spkrPat) . "\"\n";
print CONF "num_feature_dimensions: [";
foreach $type (@cmp) {
print CONF "$ordr{$type}";
if ( $cmp[$#cmp] eq $type ) {
print CONF "]\n";
}
else {
print CONF ", ";
}
}
print CONF "restore_ckpt: -1\n";
close(CONF);
open( CONF, ">$cfg{'adn'}" ) || die "Cannot open $!";
print CONF "[Architecture]\n";
print CONF "num_input_units: $nin\n";
print CONF "num_hidden_units: [$nhid]\n";
print CONF "num_output_units: $nout\n";
print CONF "hidden_activation: \"$activations[$activation]\"\n";
print CONF "output_activation: \"$activations[0]\"\n";
print CONF "\n[Strategy]\n";
print CONF "optimizer: \"$optimizers[$optimizer]\"\n";
print CONF "learning_rate: $learnRate\n";
print CONF "keep_prob: $keepProb\n";
print CONF "queue_size: $queueSize\n";
print CONF "batch_size: $batchSize\n";
print CONF "num_epochs: $nAdaptEpoch\n";
print CONF "num_threads: $nThread\n";
print CONF "random_seed: $randomSeed\n";
print CONF "frame_by_frame: 1\n";
print CONF "adaptation: 1\n";
print CONF "\n[Output]\n";
print CONF "num_models_to_keep: $nKeep\n";
print CONF "log_interval: $logInterval\n";
print CONF "save_interval: $saveInterval\n";
print CONF "\n[Others]\n";
print CONF "all_spkrs: [\"" . join( "\", \"", ( split /\s+/, $trainSpkr ), $spkr ) . "\"]\n";
print CONF "spkr_pattern: \"" . format_spkr_pattern($spkrPat) . "\"\n";
print CONF "num_feature_dimensions: [";
foreach $type (@cmp) {
print CONF "$ordr{$type}";
if ( $cmp[$#cmp] eq $type ) {
print CONF "]\n";
}
else {
print CONF ", ";
}
}
print CONF "restore_ckpt: 0\n";
close(CONF);
open( CONF, ">$cfg{'sdn'}" ) || die "Cannot open $!";
print CONF "[Architecture]\n";
print CONF "num_input_units: $nin\n";
print CONF "num_hidden_units: [$nhid]\n";
print CONF "num_output_units: $nout\n";
print CONF "hidden_activation: \"$activations[$activation]\"\n";
print CONF "output_activation: \"$activations[0]\"\n";
print CONF "\n[Strategy]\n";
print CONF "num_threads: $nThread\n";
print CONF "frame_by_frame: 1\n";
print CONF "\n[Others]\n";
print CONF "all_spkrs: [\"" . join( "\", \"", ( split /\s+/, $trainSpkr ), $spkr ) . "\"]\n";
print CONF "num_feature_dimensions: [";
foreach $type (@cmp) {
print CONF "$ordr{$type}";
if ( $cmp[$#cmp] eq $type ) {
print CONF "]\n";
}
else {
print CONF ", ";
}
}
print CONF "restore_ckpt: 0\n";
close(CONF);
}
# sub routine for generating .hed files for decision-tree clustering
sub make_edfile_state($) {
my ($type) = @_;
my ( @lines, $i, @nstate );
$nstate{'cmp'} = $nState;
$nstate{'dur'} = 1;
open( QSFILE, "$qs{$type}" ) || die "Cannot open $!";
@lines = <QSFILE>;
close(QSFILE);
open( EDFILE, ">$cxc{$type}" ) || die "Cannot open $!";
print EDFILE "// load stats file\n";
print EDFILE "RO $gam{$type} \"$stats{$t2s{$type}}\"\n\n";
print EDFILE "TR 0\n\n";
print EDFILE "// questions for decision tree-based context clustering\n";
print EDFILE @lines;
print EDFILE "TR 3\n\n";
print EDFILE "// construct decision trees\n";
for ( $i = 2 ; $i <= $nstate{ $t2s{$type} } + 1 ; $i++ ) {
print EDFILE "TB $thr{$type} ${type}_s${i}_ {*.state[${i}].stream[$strb{$type}-$stre{$type}]}\n";
}
print EDFILE "\nTR 1\n\n";
print EDFILE "// output constructed trees\n";
print EDFILE "ST \"$tre{$type}\"\n";
close(EDFILE);
}
# sub routine for generating .hed files for decision-tree clustering of GV
sub make_edfile_state_gv($$) {
my ( $type, $s ) = @_;
my (@lines);
open( QSFILE, "$qs_utt{$type}" ) || die "Cannot open $!";
@lines = <QSFILE>;
close(QSFILE);
open( EDFILE, ">$gvcxc{$type}" ) || die "Cannot open $!";
if ($cdgv) {
print EDFILE "// load stats file\n";
print EDFILE "RO $gvgam{$type} \"$stats{'gv'}\"\n";
print EDFILE "TR 0\n\n";
print EDFILE "// questions for decision tree-based context clustering\n";
print EDFILE @lines;
print EDFILE "TR 3\n\n";
print EDFILE "// construct decision trees\n";
print EDFILE "TB $gvthr{$type} gv_${type}_ {*.state[2].stream[$s]}\n";
print EDFILE "\nTR 1\n\n";
print EDFILE "// output constructed trees\n";
print EDFILE "ST \"$gvtre{$type}\"\n";
}
else {
open( TREE, ">$gvtre{$type}" ) || die "Cannot open $!";
print TREE " {*}[2].stream[$s]\n \"gv_${type}_1\"\n";
close(TREE);
print EDFILE "// construct tying structure\n";
print EDFILE "TI gv_${type}_1 {*.state[2].stream[$s]}\n";
}
close(EDFILE);
}
# sub routine for untying structures
sub make_edfile_untie($) {
my ($set) = @_;
my ( $type, $i, @nstate );
$nstate{'cmp'} = $nState;
$nstate{'dur'} = 1;
open( EDFILE, ">$unt{$set}" ) || die "Cannot open $!";
print EDFILE "// untie parameter sharing structure\n";
foreach $type ( @{ $ref{$set} } ) {
for ( $i = 2 ; $i <= $nstate{$set} + 1 ; $i++ ) {
if ( $#{ $ref{$set} } eq 0 ) {
print EDFILE "UT {*.state[$i]}\n";
}
else {
if ( $strw{$type} > 0.0 ) {
print EDFILE "UT {*.state[$i].stream[$strb{$type}-$stre{$type}]}\n";
}
}
}
}
close(EDFILE);
}
# sub routine to increase the number of mixture components
sub make_edfile_upmix($) {
my ($set) = @_;
my ( $type, $i, @nstate );
$nstate{'cmp'} = $nState;
$nstate{'dur'} = 1;
open( EDFILE, ">$upm{$set}" ) || die "Cannot open $!";
print EDFILE "// increase the number of mixtures per stream\n";
foreach $type ( @{ $ref{$set} } ) {
for ( $i = 2 ; $i <= $nstate{$set} + 1 ; $i++ ) {
if ( $#{ $ref{$set} } eq 0 ) {
print EDFILE "MU +1 {*.state[$i].mix}\n";
}
else {
print EDFILE "MU +1 {*.state[$i].stream[$strb{$type}-$stre{$type}].mix}\n";
}
}
}
close(EDFILE);
}
# sub routine to convert statistics file for cmp into one for dur
sub convstats {
my @LINE;
open( IN, "$stats{'cmp'}" ) || die "Cannot open $!";
open( OUT, ">$stats{'dur'}" ) || die "Cannot open $!";
while (<IN>) {
@LINE = split(' ');
printf OUT ( "%4d %14s %4d %4d\n", $LINE[0], $LINE[1], $LINE[2], $LINE[2] );
}
close(IN);
close(OUT);
}
# sub routine for generating .hed files for mmf -> hts_engine conversion
sub make_edfile_convert($$) {
my ( $type, $spxf ) = @_;
open( EDFILE, ">$cnv{$type}" ) || die "Cannot open $!";
print EDFILE "\nTR 2\n\n";
print EDFILE "// load adaptation transforms\n";
print EDFILE "AX \"$spxf\"\n";
print EDFILE "// load trees for $type\n";
print EDFILE "LT \"$tre{$type}\"\n\n";
print EDFILE "// convert loaded trees for hts_engine format\n";
print EDFILE "CT \"$trd{$t2s{$type}}\"\n\n";
print EDFILE "// convert mmf for hts_engine format\n";
print EDFILE "CM \"$model{$t2s{$type}}\"\n";
close(EDFILE);
}
# sub routine for generating .hed files for GV mmf -> hts_engine conversion
sub make_edfile_convert_gv($) {
my ($type) = @_;
open( EDFILE, ">$gvcnv{$type}" ) || die "Cannot open $!";
print EDFILE "\nTR 2\n\n";
print EDFILE "// load trees for $type\n";
print EDFILE "LT \"$gvtre{$type}\"\n\n";
print EDFILE "// convert loaded trees for hts_engine format\n";
print EDFILE "CT \"$gvdir\"\n\n";
print EDFILE "// convert mmf for hts_engine format\n";
print EDFILE "CM \"$gvdir\"\n";
close(EDFILE);
}
# sub routine for generating .hed files for making unseen models
sub make_edfile_mkunseen($) {
my ($set) = @_;
my ($type);
open( EDFILE, ">$mku{$set}" ) || die "Cannot open $!";
print EDFILE "\nTR 2\n\n";
foreach $type ( @{ $ref{$set} } ) {
print EDFILE "// load trees for $type\n";
print EDFILE "LT \"$tre{$type}\"\n\n";
}
print EDFILE "// make unseen model\n";
print EDFILE "AU \"$lst{'all'}\"\n\n";
print EDFILE "// make model compact\n";
print EDFILE "CO \"$tiedlst{$set}\"\n\n";
close(EDFILE);
}
# sub routine for generating .hed files for constructing a regression tree
sub make_edfile_regtree($$) {
my ( $regtype, $set ) = @_;
my ($type);
open( EDFILE, ">$red{$set}{$regtype}" ) || die "Cannot open $!";
if ( $regtype eq 'reg' ) {
print EDFILE "// load stats file\n";
print EDFILE "LS \"$stats{$set}\"\n";
print EDFILE "// construct regression class tree\n";
print EDFILE "RC $nClass \"$regtype\"\n";
}
else {
print EDFILE "// load stats file\n";
print EDFILE "LS \"$stats{$set}\"\n";
foreach $type ( @{ $ref{$set} } ) {
print EDFILE "// load trees for $type\n";
print EDFILE "LT \"$tre{$type}\"\n\n";
}
print EDFILE "// convert decision trees to a regression class tree\n";
print EDFILE "DR \"$regtype\"\n";
}
close(EDFILE);
}
# sub routine for generating .hed files for making unseen models for GV
sub make_edfile_mkunseen_gv {
my ($type);
open( EDFILE, ">$mku{'gv'}" ) || die "Cannot open $!";
print EDFILE "\nTR 2\n\n";
foreach $type (@cmp) {
print EDFILE "// load trees for $type\n";
print EDFILE "LT \"$gvtre{$type}\"\n\n";
}
print EDFILE "// make unseen model\n";
print EDFILE "AU \"$lst{'all'}\"\n\n";
print EDFILE "// make model compact\n";
print EDFILE "CO \"$tiedlst{'gv'}\"\n\n";
close(EDFILE);
}
# sub routine for generating low pass filter of hts_engine API
sub make_lpf {
my ( $lfil, @coef, $coefSize, $i, $j );
$lfil = `$PERL $datdir/scripts/makefilter.pl $sr 0`;
@coef = split( '\s', $lfil );
$coefSize = @coef;
shell("rm -f $pdf{'lpf'}");
shell("touch $pdf{'lpf'}");
for ( $i = 0 ; $i < $nState ; $i++ ) {
shell("echo 1 | $X2X +ai >> $pdf{'lpf'}");
}
for ( $i = 0 ; $i < $nState ; $i++ ) {
for ( $j = 0 ; $j < $coefSize ; $j++ ) {
shell("echo $coef[$j] | $X2X +af >> $pdf{'lpf'}");
}
for ( $j = 0 ; $j < $coefSize ; $j++ ) {
shell("echo 0.0 | $X2X +af >> $pdf{'lpf'}");
}
}
open( INF, "> $trv{'lpf'}" );
for ( $i = 2 ; $i <= $nState + 1 ; $i++ ) {
print INF "{*}[${i}]\n";
print INF " \"lpf_s${i}_1\"\n";
}
close(INF);
open( WIN, "> $voice/lpf.win1" );
print WIN "1 1.0\n";
close(WIN);
}
# sub routine for generating HTS voice for hts_engine API
sub make_htsvoice($$) {
my ( $voicedir, $voicename ) = @_;
my ( $i, $type, $tmp, @coef, $coefSize, $file_index, $s, $e );
open( HTSVOICE, "> ${voicedir}/${voicename}.htsvoice" );
# global information
print HTSVOICE "[GLOBAL]\n";
print HTSVOICE "HTS_VOICE_VERSION:1.0\n";
print HTSVOICE "SAMPLING_FREQUENCY:${sr}\n";
print HTSVOICE "FRAME_PERIOD:${fs}\n";
print HTSVOICE "NUM_STATES:${nState}\n";
print HTSVOICE "NUM_STREAMS:" . ( ${ nPdfStreams { 'cmp' } } + 1 ) . "\n";
print HTSVOICE "STREAM_TYPE:";
for ( $i = 0 ; $i < @cmp ; $i++ ) {
if ( $i != 0 ) {
print HTSVOICE ",";
}
$tmp = get_stream_name( $cmp[$i] );
print HTSVOICE "${tmp}";
}
print HTSVOICE ",LPF\n";
print HTSVOICE "FULLCONTEXT_FORMAT:${fclf}\n";
print HTSVOICE "FULLCONTEXT_VERSION:${fclv}\n";
if ( $useHmmGV && $nosilgv && @slnt > 0 ) {
print HTSVOICE "GV_OFF_CONTEXT:";
for ( $i = 0 ; $i < @slnt ; $i++ ) {
if ( $i != 0 ) {
print HTSVOICE ",";
}
print HTSVOICE "\"*-${slnt[$i]}+*\"";
}
}
print HTSVOICE "\n";
print HTSVOICE "COMMENT:\n";
# stream information
print HTSVOICE "[STREAM]\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
print HTSVOICE "VECTOR_LENGTH[${tmp}]:${ordr{$type}}\n";
}
$type = "lpf";
$tmp = get_stream_name($type);
@coef = split( '\s', `$PERL $datdir/scripts/makefilter.pl $sr 0` );
$coefSize = @coef;
print HTSVOICE "VECTOR_LENGTH[${tmp}]:${coefSize}\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
print HTSVOICE "IS_MSD[${tmp}]:${msdi{$type}}\n";
}
$type = "lpf";
$tmp = get_stream_name($type);
print HTSVOICE "IS_MSD[${tmp}]:0\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
print HTSVOICE "NUM_WINDOWS[${tmp}]:${nwin{$type}}\n";
}
$type = "lpf";
$tmp = get_stream_name($type);
print HTSVOICE "NUM_WINDOWS[${tmp}]:1\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
if ($useHmmGV) {
print HTSVOICE "USE_GV[${tmp}]:1\n";
}
else {
print HTSVOICE "USE_GV[${tmp}]:0\n";
}
}
$type = "lpf";
$tmp = get_stream_name($type);
print HTSVOICE "USE_GV[${tmp}]:0\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
if ( $tmp eq "MCP" ) {
print HTSVOICE "OPTION[${tmp}]:ALPHA=$fw\n";
}
elsif ( $tmp eq "LSP" ) {
print HTSVOICE "OPTION[${tmp}]:ALPHA=$fw,GAMMA=$gm,LN_GAIN=$lg\n";
}
else {
print HTSVOICE "OPTION[${tmp}]:\n";
}
}
$type = "lpf";
$tmp = get_stream_name($type);
print HTSVOICE "OPTION[${tmp}]:\n";
# position
$file_index = 0;
print HTSVOICE "[POSITION]\n";
$file_size = get_file_size("${voicedir}/dur.pdf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "DURATION_PDF:${s}-${e}\n";
$file_index += $file_size;
$file_size = get_file_size("${voicedir}/tree-dur.inf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "DURATION_TREE:${s}-${e}\n";
$file_index += $file_size;
foreach $type (@cmp) {
$tmp = get_stream_name($type);
print HTSVOICE "STREAM_WIN[${tmp}]:";
for ( $i = 0 ; $i < $nwin{$type} ; $i++ ) {
$file_size = get_file_size("${voicedir}/$win{$type}[$i]");
$s = $file_index;
$e = $file_index + $file_size - 1;
if ( $i != 0 ) {
print HTSVOICE ",";
}
print HTSVOICE "${s}-${e}";
$file_index += $file_size;
}
print HTSVOICE "\n";
}
$type = "lpf";
$tmp = get_stream_name($type);
print HTSVOICE "STREAM_WIN[${tmp}]:";
$file_size = get_file_size("$voicedir/$win{$type}[0]");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "${s}-${e}";
$file_index += $file_size;
print HTSVOICE "\n";
foreach $type (@cmp) {
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/${type}.pdf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "STREAM_PDF[$tmp]:${s}-${e}\n";
$file_index += $file_size;
}
$type = "lpf";
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/${type}.pdf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "STREAM_PDF[$tmp]:${s}-${e}\n";
$file_index += $file_size;
foreach $type (@cmp) {
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/tree-${type}.inf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "STREAM_TREE[$tmp]:${s}-${e}\n";
$file_index += $file_size;
}
$type = "lpf";
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/tree-${type}.inf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "STREAM_TREE[$tmp]:${s}-${e}\n";
$file_index += $file_size;
if ($useHmmGV) {
foreach $type (@cmp) {
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/gv-${type}.pdf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "GV_PDF[$tmp]:${s}-${e}\n";
$file_index += $file_size;
}
}
if ( $useHmmGV && $cdgv ) {
foreach $type (@cmp) {
$tmp = get_stream_name($type);
$file_size = get_file_size("${voicedir}/tree-gv-${type}.inf");
$s = $file_index;
$e = $file_index + $file_size - 1;
print HTSVOICE "GV_TREE[$tmp]:${s}-${e}\n";
$file_index += $file_size;
}
}
# data information
print HTSVOICE "[DATA]\n";
open( I, "${voicedir}/dur.pdf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
open( I, "${voicedir}/tree-dur.inf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
foreach $type (@cmp) {
$tmp = get_stream_name($type);
for ( $i = 0 ; $i < $nwin{$type} ; $i++ ) {
open( I, "${voicedir}/$win{$type}[$i]" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
}
}
$type = "lpf";
$tmp = get_stream_name($type);
open( I, "${voicedir}/$win{$type}[0]" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
foreach $type (@cmp) {
$tmp = get_stream_name($type);
open( I, "${voicedir}/${type}.pdf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
}
$type = "lpf";
$tmp = get_stream_name($type);
open( I, "${voicedir}/${type}.pdf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
foreach $type (@cmp) {
$tmp = get_stream_name($type);
open( I, "${voicedir}/tree-${type}.inf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
}
$type = "lpf";
$tmp = get_stream_name($type);
open( I, "${voicedir}/tree-${type}.inf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
if ($useHmmGV) {
foreach $type (@cmp) {
$tmp = get_stream_name($type);
open( I, "${voicedir}/gv-${type}.pdf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
}
}
if ( $useHmmGV && $cdgv ) {
foreach $type (@cmp) {
$tmp = get_stream_name($type);
open( I, "${voicedir}/tree-gv-${type}.inf" ) || die "Cannot open $!";
@STAT = stat(I);
read( I, $DATA, $STAT[7] );
close(I);
print HTSVOICE $DATA;
}
}
close(HTSVOICE);
}
# sub routine for getting stream name for HTS voice
sub get_stream_name($) {
my ($from) = @_;
my ($to);
if ( $from eq 'mgc' ) {
if ( $gm == 0 ) {
$to = "MCP";
}
else {
$to = "LSP";
}
}
else {
$to = uc $from;
}
return $to;
}
# sub routine for getting file size
sub get_file_size($) {
my ($file) = @_;
my ($file_size);
$file_size = `$WC -c < $file`;
chomp($file_size);
return $file_size;
}
# sub routine for formant emphasis in Mel-cepstral domain
sub postfiltering_mcp($$) {
my ( $base, $gendir ) = @_;
my ( $i, $line );
# output postfiltering weight coefficient
$line = "echo 1 1 ";
for ( $i = 2 ; $i < $ordr{'mgc'} ; $i++ ) {
$line .= "$pf_mcp ";
}
$line .= "| $X2X +af > $gendir/weight";
shell($line);
# calculate auto-correlation of original mcep
$line = "$FREQT -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw -M $co -A 0 < $gendir/${base}.mgc | ";
$line .= "$C2ACR -m $co -M 0 -l $fl > $gendir/${base}.r0";
shell($line);
# calculate auto-correlation of postfiltered mcep
$line = "$VOPR -m -n " . ( $ordr{'mgc'} - 1 ) . " < $gendir/${base}.mgc $gendir/weight | ";
$line .= "$FREQT -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw -M $co -A 0 | ";
$line .= "$C2ACR -m $co -M 0 -l $fl > $gendir/${base}.p_r0";
shell($line);
# calculate MLSA coefficients from postfiltered mcep
$line = "$VOPR -m -n " . ( $ordr{'mgc'} - 1 ) . " < $gendir/${base}.mgc $gendir/weight | ";
$line .= "$MC2B -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw | ";
$line .= "$BCP -n " . ( $ordr{'mgc'} - 1 ) . " -s 0 -e 0 > $gendir/${base}.b0";
shell($line);
# calculate 0.5 * log(acr_orig/acr_post)) and add it to 0th MLSA coefficient
$line = "$VOPR -d < $gendir/${base}.r0 $gendir/${base}.p_r0 | ";
$line .= "$SOPR -LN -d 2 | ";
$line .= "$VOPR -a $gendir/${base}.b0 > $gendir/${base}.p_b0";
shell($line);
# generate postfiltered mcep
$line = "$VOPR -m -n " . ( $ordr{'mgc'} - 1 ) . " < $gendir/${base}.mgc $gendir/weight | ";
$line .= "$MC2B -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw | ";
$line .= "$BCP -n " . ( $ordr{'mgc'} - 1 ) . " -s 1 -e " . ( $ordr{'mgc'} - 1 ) . " | ";
$line .= "$MERGE -n " . ( $ordr{'mgc'} - 2 ) . " -s 0 -N 0 $gendir/${base}.p_b0 | ";
$line .= "$B2MC -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw > $gendir/${base}.p_mgc";
shell($line);
$line = "rm -f $gendir/weight $gendir/${base}.r0 $gendir/${base}.p_r0 $gendir/${base}.b0 $gendir/${base}.p_b0";
shell($line);
}
# sub routine for formant emphasis in LSP domain
sub postfiltering_lsp($$) {
my ( $base, $gendir ) = @_;
my ( $file, $lgopt, $line, $i, @lsp, $d_1, $d_2, $plsp, $data );
$file = "$gendir/${base}.mgc";
if ($lg) {
$lgopt = "-L";
}
else {
$lgopt = "";
}
$line = "$LSPCHECK -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt -c -r 0.1 -g -G 1.0E-10 $file | ";
$line .= "$LSP2LPC -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt | ";
$line .= "$MGC2MGC -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw -c $gm -n -u -M " . ( $fl - 1 ) . " -A 0.0 -G 1.0 | ";
$line .= "$SOPR -P | $VSUM -t $fl | $SOPR -LN -m 0.5 > $gendir/${base}.ene1";
shell($line);
# postfiltering
open( LSP, "$X2X +fa < $gendir/${base}.mgc |" );
open( GAIN, ">$gendir/${base}.gain" );
open( PLSP, ">$gendir/${base}.lsp" );
while (1) {
@lsp = ();
for ( $i = 0 ; $i < $ordr{'mgc'} && ( $line = <LSP> ) ; $i++ ) {
push( @lsp, $line );
}
if ( $ordr{'mgc'} != @lsp ) { last; }
$data = pack( "f", $lsp[0] );
print GAIN $data;
for ( $i = 1 ; $i < $ordr{'mgc'} ; $i++ ) {
if ( $i > 1 && $i < $ordr{'mgc'} - 1 ) {
$d_1 = $pf_lsp * ( $lsp[ $i + 1 ] - $lsp[$i] );
$d_2 = $pf_lsp * ( $lsp[$i] - $lsp[ $i - 1 ] );
$plsp = $lsp[ $i - 1 ] + $d_2 + ( $d_2 * $d_2 * ( ( $lsp[ $i + 1 ] - $lsp[ $i - 1 ] ) - ( $d_1 + $d_2 ) ) ) / ( ( $d_2 * $d_2 ) + ( $d_1 * $d_1 ) );
}
else {
$plsp = $lsp[$i];
}
$data = pack( "f", $plsp );
print PLSP $data;
}
}
close(PLSP);
close(GAIN);
close(LSP);
$line = "$MERGE -s 1 -l 1 -L " . ( $ordr{'mgc'} - 1 ) . " -N " . ( $ordr{'mgc'} - 2 ) . " $gendir/${base}.lsp < $gendir/${base}.gain | ";
$line .= "$LSPCHECK -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt -c -r 0.1 -g -G 1.0E-10 | ";
$line .= "$LSP2LPC -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt | ";
$line .= "$MGC2MGC -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw -c $gm -n -u -M " . ( $fl - 1 ) . " -A 0.0 -G 1.0 | ";
$line .= "$SOPR -P | $VSUM -t $fl | $SOPR -LN -m 0.5 > $gendir/${base}.ene2 ";
shell($line);
$line = "$VOPR -l 1 -d $gendir/${base}.ene2 $gendir/${base}.ene2 | $SOPR -LN -m 0.5 | ";
$line .= "$VOPR -a $gendir/${base}.gain | ";
$line .= "$MERGE -s 1 -l 1 -L " . ( $ordr{'mgc'} - 1 ) . " -N " . ( $ordr{'mgc'} - 2 ) . " $gendir/${base}.lsp > $gendir/${base}.p_mgc";
shell($line);
$line = "rm -f $gendir/${base}.ene1 $gendir/${base}.ene2 $gendir/${base}.gain $gendir/${base}.lsp";
shell($line);
}
# sub routine for generating parameter sequences using MLPG and neural network outputs
sub gen_param($) {
my ($gendir) = @_;
my ( $line, @FILE, $file, $base, $T, $s, $e, $t );
my $ffosize = 0;
foreach $type (@cmp) {
if ( $msdi{$type} != 0 ) {
$ffosize += 1;
}
$ffosize += $vSize{'cmp'}{$type};
}
$line = `ls $gendir/*.ffo`;
@FILE = split( '\n', $line );
print "Processing directory $gendir:\n";
foreach $file (@FILE) {
$base = `basename $file .ffo`;
chomp($base);
print " Generating parameter sequences from $base.ffo...";
$T = get_file_size("$gendir/${base}.ffo") / $ffosize / 4;
$s = 0;
$e = -1;
foreach my $type (@cmp) {
if ( $msdi{$type} != 0 ) {
$s = $e + 1;
$e = $s;
shell("$BCP +f -s $s -e $e -l $ffosize $file | $SOPR -s 0.5 -UNIT | $INTERPOLATE -l 1 -p $ordr{$type} -d > $gendir/$base.$type.msd1");
shell("$SOPR -s 1.0 -m 1.0E+10 < $gendir/$base.$type.msd1 > $gendir/$base.$type.msd2");
}
$s = $e + 1;
$e = $s + $vSize{'cmp'}{$type} - 1;
shell("$BCP +f -s $s -e $e -l $ffosize $file > $gendir/$base.$type.mean");
shell("rm -f $gendir/$base.$type.var");
for ( $t = 0 ; $t < $T ; $t++ ) {
shell("$BCUT +f -s $s -e $e $gendir/$base.var >> $gendir/$base.$type.var");
}
my $opt = "";
for ( my $d = 1 ; $d < $nwin{$type} ; $d++ ) {
shell("$X2X +af < $windir/$win{$type}[$d] | $BCUT -l 1 -s 1 +f > $gendir/$base.$type.win$d");
$opt .= " -d $gendir/$base.$type.win$d ";
}
$line = "$MERGE -l $vSize{'cmp'}{$type} -L $vSize{'cmp'}{$type} $gendir/$base.$type.mean < $gendir/$base.$type.var | ";
$line .= "$MLPG -l $ordr{$type} $opt ";
if ( $msdi{$type} != 0 ) {
$line .= " | $VOPR -l 1 -m $gendir/$base.$type.msd1 ";
$line .= " | $VOPR -l 1 -a $gendir/$base.$type.msd2 ";
}
$line .= "> $gendir/$base.$type";
shell($line);
shell("rm -f $gendir/$base.$type.mean $gendir/$base.$type.var $gendir/$base.$type.win* $gendir/$base.$type.msd*");
}
print "done\n";
}
}
# sub routine for speech synthesis from log f0 and Mel-cepstral coefficients
sub gen_wave($$) {
my ( $gendir, $pf ) = @_;
my ( $line, @FILE, $lgopt, $file, $base, $T, $mgc, $lf0, $bap );
$line = `ls $gendir/*.mgc`;
@FILE = split( '\n', $line );
if ($lg) {
$lgopt = "-L";
}
else {
$lgopt = "";
}
print "Processing directory $gendir:\n";
foreach $file (@FILE) {
$base = `basename $file .mgc`;
chomp($base);
if ( $gm == 0 ) {
# apply postfiltering
if ( $pf == 1 && $pf_mcp != 1.0 ) {
postfiltering_mcp( $base, $gendir );
$mgc = "$gendir/$base.p_mgc";
}
else {
$mgc = $file;
}
}
else {
# apply postfiltering
if ( $pf == 1 && $pf_lsp != 1.0 ) {
postfiltering_lsp( $base, $gendir );
$mgc = "$gendir/$base.p_mgc";
}
else {
$mgc = $file;
}
# MGC-LSPs -> MGC coefficients
$line = "$LSPCHECK -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt -c -r 0.1 -g -G 1.0E-10 $mgc | ";
$line .= "$LSP2LPC -m " . ( $ordr{'mgc'} - 1 ) . " -s " . ( $sr / 1000 ) . " $lgopt | ";
$line .= "$MGC2MGC -m " . ( $ordr{'mgc'} - 1 ) . " -a $fw -c $gm -n -u -M " . ( $ordr{'mgc'} - 1 ) . " -A $fw -C $gm " . " > $gendir/$base.c_mgc";
shell($line);
$mgc = "$gendir/$base.c_mgc";
}
$lf0 = "$gendir/$base.lf0";
$bap = "$gendir/$base.bap";
if ( $useAVocoder && -s $file && -s $lf0 ) {
print " Synthesizing a speech waveform from $mgc and $base.lf0...";
# generate using ahodecoder
$line = "$AHODECODER $lf0 $mgc $gendir/${base}.wav --lframe=$fs";
shell($line);
print "done\n";
}
elsif ( !$usestraight && -s $file && -s $lf0 ) {
print " Synthesizing a speech waveform from $base.mgc and $base.lf0...";
# convert log F0 to pitch
$line = "$SOPR -magic -1.0E+10 -EXP -INV -m $sr -MAGIC 0.0 $lf0 > $gendir/${base}.pit";
shell($line);
# synthesize waveform
$lfil = `$PERL $datdir/scripts/makefilter.pl $sr 0`;
$hfil = `$PERL $datdir/scripts/makefilter.pl $sr 1`;
$line = "$SOPR -m 0 $gendir/$base.pit | $EXCITE -n -p $fs | $DFS -b $hfil > $gendir/$base.unv";
shell($line);
$line = "$EXCITE -n -p $fs $gendir/$base.pit | ";
$line .= "$DFS -b $lfil | $VOPR -a $gendir/$base.unv | ";
$line .= "$MGLSADF -P 7 -m " . ( $ordr{'mgc'} - 1 ) . " -p $fs -a $fw -c $gm $mgc | ";
$line .= "$X2X +fs -o > $gendir/$base.raw";
shell($line);
$line = "$RAW2WAV -s " . ( $sr / 1000 ) . " -d $gendir $gendir/$base.raw";
shell($line);
$line = "rm -f $gendir/$base.unv";
shell($line);
print "done\n";
}
elsif ( $usestraight && -s $file && -s $lf0 && -s $bap ) {
print " Synthesizing a speech waveform from $base.mgc, $base.lf0, and $base.bap... ";
# convert log F0 to F0
$line = "$SOPR -magic -1.0E+10 -EXP -MAGIC 0.0 $lf0 > $gendir/${base}.f0 ";
shell($line);
$T = get_file_size("$gendir/${base}.f0") / 4;
# convert Mel-cepstral coefficients to spectrum
if ( $gm == 0 ) {
shell( "$MGC2SP -a $fw -g $gm -m " . ( $ordr{'mgc'} - 1 ) . " -l $ft -o 2 $mgc > $gendir/$base.sp" );
}
else {
shell( "$MGC2SP -a $fw -c $gm -m " . ( $ordr{'mgc'} - 1 ) . " -l $ft -o 2 $mgc > $gendir/$base.sp" );
}
# convert band-aperiodicity to aperiodicity
shell( "$MGC2SP -a $fw -g 0 -m " . ( $ordr{'bap'} - 1 ) . " -l $ft -o 0 $bap > $gendir/$base.ap" );
# synthesize waveform
open( SYN, ">$gendir/${base}.m" ) || die "Cannot open $!";
printf SYN "path(path,'%s');\n", ${STRAIGHT};
printf SYN "prm.spectralUpdateInterval = %f;\n", 1000.0 * $fs / $sr;
printf SYN "prm.levelNormalizationIndicator = 0;\n\n";
printf SYN "fprintf(1,'\\nSynthesizing %s\\n');\n", "$gendir/$base.wav";
printf SYN "fid1 = fopen('%s','r','%s');\n", "$gendir/$base.sp", "ieee-le";
printf SYN "fid2 = fopen('%s','r','%s');\n", "$gendir/$base.ap", "ieee-le";
printf SYN "fid3 = fopen('%s','r','%s');\n", "$gendir/$base.f0", "ieee-le";
printf SYN "sp = fread(fid1,[%d, %d],'float');\n", ( $ft / 2 + 1 ), $T;
printf SYN "ap = fread(fid2,[%d, %d],'float');\n", ( $ft / 2 + 1 ), $T;
printf SYN "f0 = fread(fid3,[%d, %d],'float');\n", 1, $T;
printf SYN "fclose(fid1);\n";
printf SYN "fclose(fid2);\n";
printf SYN "fclose(fid3);\n";
printf SYN "sp = sp/32768.0;\n";
printf SYN "[sy] = exstraightsynth(f0,sp,ap,%d,prm);\n", $sr;
printf SYN "wavwrite(sy,%d,'%s');\n\n", $sr, "$gendir/$base.wav";
printf SYN "quit;\n";
close(SYN);
shell("$MATLAB < $gendir/${base}.m");
$line = "rm -f $gendir/$base.m";
shell($line);
print "done\n";
}
}
}
##################################################################################################
| 32.40318 | 160 | 0.498057 |
eda6f4b9259eb9ac6903abd774ead9a8098dc5d5 | 309 | al | Perl | Mojoqq/perl/vendor/lib/auto/Net/SSLeay/want_read.al | ghuan/Mojo-webqq-for-windows | ad44014da4578f99aa3efad0b55f0fc3bc3af322 | [
"Unlicense"
] | null | null | null | Mojoqq/perl/vendor/lib/auto/Net/SSLeay/want_read.al | ghuan/Mojo-webqq-for-windows | ad44014da4578f99aa3efad0b55f0fc3bc3af322 | [
"Unlicense"
] | null | null | null | Mojoqq/perl/vendor/lib/auto/Net/SSLeay/want_read.al | ghuan/Mojo-webqq-for-windows | ad44014da4578f99aa3efad0b55f0fc3bc3af322 | [
"Unlicense"
] | null | null | null | # NOTE: Derived from blib\lib\Net\SSLeay.pm.
# Changes made here will be lost when autosplit is run again.
# See AutoSplit.pm.
package Net::SSLeay;
#line 463 "blib\lib\Net\SSLeay.pm (autosplit into blib\lib\auto\Net\SSLeay\want_read.al)"
sub want_read { want(shift) == 2 }
# end of Net::SSLeay::want_read
1;
| 30.9 | 89 | 0.731392 |
ed984446aef30a69e9317334e527385736ae6d65 | 26,386 | pm | Perl | lib/Excel/Writer/XLSX/Package/VML.pm | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | null | null | null | lib/Excel/Writer/XLSX/Package/VML.pm | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | null | null | null | lib/Excel/Writer/XLSX/Package/VML.pm | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
] | null | null | null | package Excel::Writer::XLSX::Package::VML;
###############################################################################
#
# VML - A class for writing the Excel XLSX VML files.
#
# Used in conjunction with Excel::Writer::XLSX
#
# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org
#
# Documentation after __END__
#
# perltidy with the following options: -mbl=2 -pt=0 -nola
use 5.008002;
use strict;
use warnings;
use Carp;
use Excel::Writer::XLSX::Package::XMLwriter;
our @ISA = qw(Excel::Writer::XLSX::Package::XMLwriter);
our $VERSION = '1.08';
###############################################################################
#
# Public and private API methods.
#
###############################################################################
###############################################################################
#
# new()
#
# Constructor.
#
sub new {
my $class = shift;
my $fh = shift;
my $self = Excel::Writer::XLSX::Package::XMLwriter->new( $fh );
bless $self, $class;
return $self;
}
###############################################################################
#
# _assemble_xml_file()
#
# Assemble and write the XML file.
#
sub _assemble_xml_file {
my $self = shift;
my $data_id = shift;
my $vml_shape_id = shift;
my $comments_data = shift;
my $buttons_data = shift;
my $header_images_data = shift;
my $z_index = 1;
$self->_write_xml_namespace;
# Write the o:shapelayout element.
$self->_write_shapelayout( $data_id );
if ( defined $buttons_data && @$buttons_data ) {
# Write the v:shapetype element.
$self->_write_button_shapetype();
for my $button ( @$buttons_data ) {
# Write the v:shape element.
$self->_write_button_shape( ++$vml_shape_id, $z_index++, $button );
}
}
if ( defined $comments_data && @$comments_data ) {
# Write the v:shapetype element.
$self->_write_comment_shapetype();
for my $comment ( @$comments_data ) {
# Write the v:shape element.
$self->_write_comment_shape( ++$vml_shape_id, $z_index++,
$comment );
}
}
if ( defined $header_images_data && @$header_images_data ) {
# Write the v:shapetype element.
$self->_write_image_shapetype();
my $index = 1;
for my $image ( @$header_images_data ) {
# Write the v:shape element.
$self->_write_image_shape( ++$vml_shape_id, $index++, $image );
}
}
$self->xml_end_tag( 'xml' );
# Close the XML writer filehandle.
$self->xml_get_fh()->close();
}
###############################################################################
#
# Internal methods.
#
###############################################################################
###############################################################################
#
# _pixels_to_points()
#
# Convert comment vertices from pixels to points.
#
sub _pixels_to_points {
my $self = shift;
my $vertices = shift;
my (
$col_start, $row_start, $x1, $y1,
$col_end, $row_end, $x2, $y2,
$left, $top, $width, $height
) = @$vertices;
for my $pixels ( $left, $top, $width, $height ) {
$pixels *= 0.75;
}
return ( $left, $top, $width, $height );
}
###############################################################################
#
# XML writing methods.
#
###############################################################################
###############################################################################
#
# _write_xml_namespace()
#
# Write the <xml> element. This is the root element of VML.
#
sub _write_xml_namespace {
my $self = shift;
my $schema = 'urn:schemas-microsoft-com:';
my $xmlns = $schema . 'vml';
my $xmlns_o = $schema . 'office:office';
my $xmlns_x = $schema . 'office:excel';
my @attributes = (
'xmlns:v' => $xmlns,
'xmlns:o' => $xmlns_o,
'xmlns:x' => $xmlns_x,
);
$self->xml_start_tag( 'xml', @attributes );
}
##############################################################################
#
# _write_shapelayout()
#
# Write the <o:shapelayout> element.
#
sub _write_shapelayout {
my $self = shift;
my $data_id = shift;
my $ext = 'edit';
my @attributes = ( 'v:ext' => $ext );
$self->xml_start_tag( 'o:shapelayout', @attributes );
# Write the o:idmap element.
$self->_write_idmap( $data_id );
$self->xml_end_tag( 'o:shapelayout' );
}
##############################################################################
#
# _write_idmap()
#
# Write the <o:idmap> element.
#
sub _write_idmap {
my $self = shift;
my $ext = 'edit';
my $data_id = shift;
my @attributes = (
'v:ext' => $ext,
'data' => $data_id,
);
$self->xml_empty_tag( 'o:idmap', @attributes );
}
##############################################################################
#
# _write_comment_shapetype()
#
# Write the <v:shapetype> element.
#
sub _write_comment_shapetype {
my $self = shift;
my $id = '_x0000_t202';
my $coordsize = '21600,21600';
my $spt = 202;
my $path = 'm,l,21600r21600,l21600,xe';
my @attributes = (
'id' => $id,
'coordsize' => $coordsize,
'o:spt' => $spt,
'path' => $path,
);
$self->xml_start_tag( 'v:shapetype', @attributes );
# Write the v:stroke element.
$self->_write_stroke();
# Write the v:path element.
$self->_write_comment_path( 't', 'rect' );
$self->xml_end_tag( 'v:shapetype' );
}
##############################################################################
#
# _write_button_shapetype()
#
# Write the <v:shapetype> element.
#
sub _write_button_shapetype {
my $self = shift;
my $id = '_x0000_t201';
my $coordsize = '21600,21600';
my $spt = 201;
my $path = 'm,l,21600r21600,l21600,xe';
my @attributes = (
'id' => $id,
'coordsize' => $coordsize,
'o:spt' => $spt,
'path' => $path,
);
$self->xml_start_tag( 'v:shapetype', @attributes );
# Write the v:stroke element.
$self->_write_stroke();
# Write the v:path element.
$self->_write_button_path( 't', 'rect' );
# Write the o:lock element.
$self->_write_shapetype_lock();
$self->xml_end_tag( 'v:shapetype' );
}
##############################################################################
#
# _write_image_shapetype()
#
# Write the <v:shapetype> element.
#
sub _write_image_shapetype {
my $self = shift;
my $id = '_x0000_t75';
my $coordsize = '21600,21600';
my $spt = 75;
my $o_preferrelative = 't';
my $path = 'm@4@5l@4@11@9@11@9@5xe';
my $filled = 'f';
my $stroked = 'f';
my @attributes = (
'id' => $id,
'coordsize' => $coordsize,
'o:spt' => $spt,
'o:preferrelative' => $o_preferrelative,
'path' => $path,
'filled' => $filled,
'stroked' => $stroked,
);
$self->xml_start_tag( 'v:shapetype', @attributes );
# Write the v:stroke element.
$self->_write_stroke();
# Write the v:formulas element.
$self->_write_formulas();
# Write the v:path element.
$self->_write_image_path();
# Write the o:lock element.
$self->_write_aspect_ratio_lock();
$self->xml_end_tag( 'v:shapetype' );
}
##############################################################################
#
# _write_stroke()
#
# Write the <v:stroke> element.
#
sub _write_stroke {
my $self = shift;
my $joinstyle = 'miter';
my @attributes = ( 'joinstyle' => $joinstyle );
$self->xml_empty_tag( 'v:stroke', @attributes );
}
##############################################################################
#
# _write_comment_path()
#
# Write the <v:path> element.
#
sub _write_comment_path {
my $self = shift;
my $gradientshapeok = shift;
my $connecttype = shift;
my @attributes = ();
push @attributes, ( 'gradientshapeok' => 't' ) if $gradientshapeok;
push @attributes, ( 'o:connecttype' => $connecttype );
$self->xml_empty_tag( 'v:path', @attributes );
}
##############################################################################
#
# _write_button_path()
#
# Write the <v:path> element.
#
sub _write_button_path {
my $self = shift;
my $shadowok = 'f';
my $extrusionok = 'f';
my $strokeok = 'f';
my $fillok = 'f';
my $connecttype = 'rect';
my @attributes = (
'shadowok' => $shadowok,
'o:extrusionok' => $extrusionok,
'strokeok' => $strokeok,
'fillok' => $fillok,
'o:connecttype' => $connecttype,
);
$self->xml_empty_tag( 'v:path', @attributes );
}
##############################################################################
#
# _write_image_path()
#
# Write the <v:path> element.
#
sub _write_image_path {
my $self = shift;
my $extrusionok = 'f';
my $gradientshapeok = 't';
my $connecttype = 'rect';
my @attributes = (
'o:extrusionok' => $extrusionok,
'gradientshapeok' => $gradientshapeok,
'o:connecttype' => $connecttype,
);
$self->xml_empty_tag( 'v:path', @attributes );
}
##############################################################################
#
# _write_shapetype_lock()
#
# Write the <o:lock> element.
#
sub _write_shapetype_lock {
my $self = shift;
my $ext = 'edit';
my $shapetype = 't';
my @attributes = (
'v:ext' => $ext,
'shapetype' => $shapetype,
);
$self->xml_empty_tag( 'o:lock', @attributes );
}
##############################################################################
#
# _write_rotation_lock()
#
# Write the <o:lock> element.
#
sub _write_rotation_lock {
my $self = shift;
my $ext = 'edit';
my $rotation = 't';
my @attributes = (
'v:ext' => $ext,
'rotation' => $rotation,
);
$self->xml_empty_tag( 'o:lock', @attributes );
}
##############################################################################
#
# _write_aspect_ratio_lock()
#
# Write the <o:lock> element.
#
sub _write_aspect_ratio_lock {
my $self = shift;
my $ext = 'edit';
my $aspectratio = 't';
my @attributes = (
'v:ext' => $ext,
'aspectratio' => $aspectratio,
);
$self->xml_empty_tag( 'o:lock', @attributes );
}
##############################################################################
#
# _write_comment_shape()
#
# Write the <v:shape> element.
#
sub _write_comment_shape {
my $self = shift;
my $id = shift;
my $z_index = shift;
my $comment = shift;
my $type = '#_x0000_t202';
my $insetmode = 'auto';
my $visibility = 'hidden';
# Set the shape index.
$id = '_x0000_s' . $id;
# Get the comment parameters
my $row = $comment->[0];
my $col = $comment->[1];
my $string = $comment->[2];
my $author = $comment->[3];
my $visible = $comment->[4];
my $fillcolor = $comment->[5];
my $vertices = $comment->[9];
my ( $left, $top, $width, $height ) = $self->_pixels_to_points( $vertices );
# Set the visibility.
$visibility = 'visible' if $visible;
my $style =
'position:absolute;'
. 'margin-left:'
. $left . 'pt;'
. 'margin-top:'
. $top . 'pt;'
. 'width:'
. $width . 'pt;'
. 'height:'
. $height . 'pt;'
. 'z-index:'
. $z_index . ';'
. 'visibility:'
. $visibility;
my @attributes = (
'id' => $id,
'type' => $type,
'style' => $style,
'fillcolor' => $fillcolor,
'o:insetmode' => $insetmode,
);
$self->xml_start_tag( 'v:shape', @attributes );
# Write the v:fill element.
$self->_write_comment_fill();
# Write the v:shadow element.
$self->_write_shadow();
# Write the v:path element.
$self->_write_comment_path( undef, 'none' );
# Write the v:textbox element.
$self->_write_comment_textbox();
# Write the x:ClientData element.
$self->_write_comment_client_data( $row, $col, $visible, $vertices );
$self->xml_end_tag( 'v:shape' );
}
##############################################################################
#
# _write_button_shape()
#
# Write the <v:shape> element.
#
sub _write_button_shape {
my $self = shift;
my $id = shift;
my $z_index = shift;
my $button = shift;
my $type = '#_x0000_t201';
# Set the shape index.
$id = '_x0000_s' . $id;
# Get the button parameters
my $row = $button->{_row};
my $col = $button->{_col};
my $vertices = $button->{_vertices};
my ( $left, $top, $width, $height ) = $self->_pixels_to_points( $vertices );
my $style =
'position:absolute;'
. 'margin-left:'
. $left . 'pt;'
. 'margin-top:'
. $top . 'pt;'
. 'width:'
. $width . 'pt;'
. 'height:'
. $height . 'pt;'
. 'z-index:'
. $z_index . ';'
. 'mso-wrap-style:tight';
my @attributes = (
'id' => $id,
'type' => $type,
'style' => $style,
'o:button' => 't',
'fillcolor' => 'buttonFace [67]',
'strokecolor' => 'windowText [64]',
'o:insetmode' => 'auto',
);
$self->xml_start_tag( 'v:shape', @attributes );
# Write the v:fill element.
$self->_write_button_fill();
# Write the o:lock element.
$self->_write_rotation_lock();
# Write the v:textbox element.
$self->_write_button_textbox( $button->{_font} );
# Write the x:ClientData element.
$self->_write_button_client_data( $button );
$self->xml_end_tag( 'v:shape' );
}
##############################################################################
#
# _write_image_shape()
#
# Write the <v:shape> element.
#
sub _write_image_shape {
my $self = shift;
my $id = shift;
my $index = shift;
my $image_data = shift;
my $type = '#_x0000_t75';
# Set the shape index.
$id = '_x0000_s' . $id;
# Get the image parameters
my $width = $image_data->[0];
my $height = $image_data->[1];
my $name = $image_data->[2];
my $position = $image_data->[3];
my $x_dpi = $image_data->[4];
my $y_dpi = $image_data->[5];
my $ref_id = $image_data->[6];
# Scale the height/width by the resolution, relative to 72dpi.
$width = $width * 72 / $x_dpi;
$height = $height * 72 / $y_dpi;
# Excel uses a rounding based around 72 and 96 dpi.
$width = 72/96 * int($width * 96/72 + 0.25);
$height = 72/96 * int($height * 96/72 + 0.25);
my $style =
'position:absolute;'
. 'margin-left:0;'
. 'margin-top:0;'
. 'width:'
. $width . 'pt;'
. 'height:'
. $height . 'pt;'
. 'z-index:'
. $index;
my @attributes = (
'id' => $position,
'o:spid' => $id,
'type' => $type,
'style' => $style,
);
$self->xml_start_tag( 'v:shape', @attributes );
# Write the v:imagedata element.
$self->_write_imagedata( $ref_id, $name );
# Write the o:lock element.
$self->_write_rotation_lock();
$self->xml_end_tag( 'v:shape' );
}
##############################################################################
#
# _write_comment_fill()
#
# Write the <v:fill> element.
#
sub _write_comment_fill {
my $self = shift;
my $color_2 = '#ffffe1';
my @attributes = ( 'color2' => $color_2 );
$self->xml_empty_tag( 'v:fill', @attributes );
}
##############################################################################
#
# _write_button_fill()
#
# Write the <v:fill> element.
#
sub _write_button_fill {
my $self = shift;
my $color_2 = 'buttonFace [67]';
my $detectmouseclick = 't';
my @attributes = (
'color2' => $color_2,
'o:detectmouseclick' => $detectmouseclick,
);
$self->xml_empty_tag( 'v:fill', @attributes );
}
##############################################################################
#
# _write_shadow()
#
# Write the <v:shadow> element.
#
sub _write_shadow {
my $self = shift;
my $on = 't';
my $color = 'black';
my $obscured = 't';
my @attributes = (
'on' => $on,
'color' => $color,
'obscured' => $obscured,
);
$self->xml_empty_tag( 'v:shadow', @attributes );
}
##############################################################################
#
# _write_comment_textbox()
#
# Write the <v:textbox> element.
#
sub _write_comment_textbox {
my $self = shift;
my $style = 'mso-direction-alt:auto';
my @attributes = ( 'style' => $style );
$self->xml_start_tag( 'v:textbox', @attributes );
# Write the div element.
$self->_write_div( 'left' );
$self->xml_end_tag( 'v:textbox' );
}
##############################################################################
#
# _write_button_textbox()
#
# Write the <v:textbox> element.
#
sub _write_button_textbox {
my $self = shift;
my $font = shift;
my $style = 'mso-direction-alt:auto';
my @attributes = ( 'style' => $style, 'o:singleclick' => 'f' );
$self->xml_start_tag( 'v:textbox', @attributes );
# Write the div element.
$self->_write_div( 'center', $font );
$self->xml_end_tag( 'v:textbox' );
}
##############################################################################
#
# _write_div()
#
# Write the <div> element.
#
sub _write_div {
my $self = shift;
my $align = shift;
my $font = shift;
my $style = 'text-align:' . $align;
my @attributes = ( 'style' => $style );
$self->xml_start_tag( 'div', @attributes );
if ( $font ) {
# Write the font element.
$self->_write_font( $font );
}
$self->xml_end_tag( 'div' );
}
##############################################################################
#
# _write_font()
#
# Write the <font> element.
#
sub _write_font {
my $self = shift;
my $font = shift;
my $caption = $font->{_caption};
my $face = 'Calibri';
my $size = 220;
my $color = '#000000';
my @attributes = (
'face' => $face,
'size' => $size,
'color' => $color,
);
$self->xml_data_element( 'font', $caption, @attributes );
}
##############################################################################
#
# _write_comment_client_data()
#
# Write the <x:ClientData> element.
#
sub _write_comment_client_data {
my $self = shift;
my $row = shift;
my $col = shift;
my $visible = shift;
my $vertices = shift;
my $object_type = 'Note';
my @attributes = ( 'ObjectType' => $object_type );
$self->xml_start_tag( 'x:ClientData', @attributes );
# Write the x:MoveWithCells element.
$self->_write_move_with_cells();
# Write the x:SizeWithCells element.
$self->_write_size_with_cells();
# Write the x:Anchor element.
$self->_write_anchor( $vertices );
# Write the x:AutoFill element.
$self->_write_auto_fill();
# Write the x:Row element.
$self->_write_row( $row );
# Write the x:Column element.
$self->_write_column( $col );
# Write the x:Visible element.
$self->_write_visible() if $visible;
$self->xml_end_tag( 'x:ClientData' );
}
##############################################################################
#
# _write_button_client_data()
#
# Write the <x:ClientData> element.
#
sub _write_button_client_data {
my $self = shift;
my $button = shift;
my $row = $button->{_row};
my $col = $button->{_col};
my $macro = $button->{_macro};
my $vertices = $button->{_vertices};
my $object_type = 'Button';
my @attributes = ( 'ObjectType' => $object_type );
$self->xml_start_tag( 'x:ClientData', @attributes );
# Write the x:Anchor element.
$self->_write_anchor( $vertices );
# Write the x:PrintObject element.
$self->_write_print_object();
# Write the x:AutoFill element.
$self->_write_auto_fill();
# Write the x:FmlaMacro element.
$self->_write_fmla_macro( $macro );
# Write the x:TextHAlign element.
$self->_write_text_halign();
# Write the x:TextVAlign element.
$self->_write_text_valign();
$self->xml_end_tag( 'x:ClientData' );
}
##############################################################################
#
# _write_move_with_cells()
#
# Write the <x:MoveWithCells> element.
#
sub _write_move_with_cells {
my $self = shift;
$self->xml_empty_tag( 'x:MoveWithCells' );
}
##############################################################################
#
# _write_size_with_cells()
#
# Write the <x:SizeWithCells> element.
#
sub _write_size_with_cells {
my $self = shift;
$self->xml_empty_tag( 'x:SizeWithCells' );
}
##############################################################################
#
# _write_visible()
#
# Write the <x:Visible> element.
#
sub _write_visible {
my $self = shift;
$self->xml_empty_tag( 'x:Visible' );
}
##############################################################################
#
# _write_anchor()
#
# Write the <x:Anchor> element.
#
sub _write_anchor {
my $self = shift;
my $vertices = shift;
my ( $col_start, $row_start, $x1, $y1, $col_end, $row_end, $x2, $y2 ) =
@$vertices;
my $data = join ", ",
( $col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2 );
$self->xml_data_element( 'x:Anchor', $data );
}
##############################################################################
#
# _write_auto_fill()
#
# Write the <x:AutoFill> element.
#
sub _write_auto_fill {
my $self = shift;
my $data = 'False';
$self->xml_data_element( 'x:AutoFill', $data );
}
##############################################################################
#
# _write_row()
#
# Write the <x:Row> element.
#
sub _write_row {
my $self = shift;
my $data = shift;
$self->xml_data_element( 'x:Row', $data );
}
##############################################################################
#
# _write_column()
#
# Write the <x:Column> element.
#
sub _write_column {
my $self = shift;
my $data = shift;
$self->xml_data_element( 'x:Column', $data );
}
##############################################################################
#
# _write_print_object()
#
# Write the <x:PrintObject> element.
#
sub _write_print_object {
my $self = shift;
my $data = 'False';
$self->xml_data_element( 'x:PrintObject', $data );
}
##############################################################################
#
# _write_text_halign()
#
# Write the <x:TextHAlign> element.
#
sub _write_text_halign {
my $self = shift;
my $data = 'Center';
$self->xml_data_element( 'x:TextHAlign', $data );
}
##############################################################################
#
# _write_text_valign()
#
# Write the <x:TextVAlign> element.
#
sub _write_text_valign {
my $self = shift;
my $data = 'Center';
$self->xml_data_element( 'x:TextVAlign', $data );
}
##############################################################################
#
# _write_fmla_macro()
#
# Write the <x:FmlaMacro> element.
#
sub _write_fmla_macro {
my $self = shift;
my $data = shift;
$self->xml_data_element( 'x:FmlaMacro', $data );
}
##############################################################################
#
# _write_imagedata()
#
# Write the <v:imagedata> element.
#
sub _write_imagedata {
my $self = shift;
my $index = shift;
my $o_title = shift;
my @attributes = (
'o:relid' => 'rId' . $index,
'o:title' => $o_title,
);
$self->xml_empty_tag( 'v:imagedata', @attributes );
}
##############################################################################
#
# _write_formulas()
#
# Write the <v:formulas> element.
#
sub _write_formulas {
my $self = shift;
$self->xml_start_tag( 'v:formulas' );
# Write the v:f elements.
$self->_write_f('if lineDrawn pixelLineWidth 0');
$self->_write_f('sum @0 1 0');
$self->_write_f('sum 0 0 @1');
$self->_write_f('prod @2 1 2');
$self->_write_f('prod @3 21600 pixelWidth');
$self->_write_f('prod @3 21600 pixelHeight');
$self->_write_f('sum @0 0 1');
$self->_write_f('prod @6 1 2');
$self->_write_f('prod @7 21600 pixelWidth');
$self->_write_f('sum @8 21600 0');
$self->_write_f('prod @7 21600 pixelHeight');
$self->_write_f('sum @10 21600 0');
$self->xml_end_tag( 'v:formulas' );
}
##############################################################################
#
# _write_f()
#
# Write the <v:f> element.
#
sub _write_f {
my $self = shift;
my $eqn = shift;
my @attributes = ( 'eqn' => $eqn );
$self->xml_empty_tag( 'v:f', @attributes );
}
1;
__END__
=pod
=head1 NAME
VML - A class for writing the Excel XLSX VML files.
=head1 SYNOPSIS
See the documentation for L<Excel::Writer::XLSX>.
=head1 DESCRIPTION
This module is used in conjunction with L<Excel::Writer::XLSX>.
=head1 AUTHOR
John McNamara jmcnamara@cpan.org
=head1 COPYRIGHT
(c) MM-MMXXI, John McNamara.
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
=head1 LICENSE
Either the Perl Artistic Licence L<http://dev.perl.org/licenses/artistic.html> or the GPL L<http://www.opensource.org/licenses/gpl-license.php>.
=head1 DISCLAIMER OF WARRANTY
See the documentation for L<Excel::Writer::XLSX>.
=cut
| 21.699013 | 144 | 0.474456 |
ed3821985acee4d13892460d412025c827ebe05f | 1,334 | pl | Perl | lib/profile/bboutparse.pl | aaliomer/exos | 6a37c41cad910c373322441a9f23cfabdbfae275 | [
"BSD-3-Clause"
] | 1 | 2018-01-23T23:07:19.000Z | 2018-01-23T23:07:19.000Z | lib/profile/bboutparse.pl | aaliomer/exos | 6a37c41cad910c373322441a9f23cfabdbfae275 | [
"BSD-3-Clause"
] | null | null | null | lib/profile/bboutparse.pl | aaliomer/exos | 6a37c41cad910c373322441a9f23cfabdbfae275 | [
"BSD-3-Clause"
] | null | null | null | #! /usr/bin/perl
# A simple parser to sort a bb.out file by frequency
#
# recommended usage:
# cat <infile> | bboutparse.pl | less
#
# simply takes standard input and writes to standard output
while (<STDIN>) {
unless (/.*executed(\s+)0.*/) {
unless (/~\s+$/) {
push @lines, $_;
}
}
}
sub order_lines{
$_ = $a;
/.*executed\s+(\d+).*/;
$a_key = $1;
$_ = $b;
/.*executed\s+(\d+).*/;
$b_key = $1;
return $b_key <=> $a_key;
}
@sorted = sort order_lines @lines;
printf "Basic Block counts, in decreasing order:\n\n";
printf"File: Function: Address: Line: Executed:\n\n";
format STDOUT =
@<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<< @<<<<<<<< @<<<<<<<<
$file, $function, $address, $line, $executed
.
foreach $line (@sorted) {
$fnd = 0;
$fnd = ($line =~ /.*executed\s+(\d+)\s+time\(s\)(.*)/);
$executed = $1;
$2 =~ /\s+address=\s+0x([\d|a-f]+)\s+(.*)/;
$address = $1;
$2 =~ /function=\s+(\S+)\s+(.*)/;
$function = $1;
$2 =~ /line=\s+(\d+)\s+(.*)/;
$line = $1;
$2 =~ /file=\s+.*\/([\d|\w|\_]+\.[c|s|S]).*/;
$file = $1;
# print $executed, "\t0x", $address, "\t", $file, "\t", $function, "\t", $line, "\n";
if ($fnd) {write};
}
| 26.156863 | 103 | 0.434033 |
ed60fed743a8167133bb6cb3ee175d3f16a1304b | 1,210 | pm | Perl | local/lib/perl5/DateTime/TimeZone/Asia/Dubai.pm | rosiro/wasarabi | 1016fb3a612fc4da3761c53c73473dd113a578d3 | [
"MIT"
] | null | null | null | local/lib/perl5/DateTime/TimeZone/Asia/Dubai.pm | rosiro/wasarabi | 1016fb3a612fc4da3761c53c73473dd113a578d3 | [
"MIT"
] | null | null | null | local/lib/perl5/DateTime/TimeZone/Asia/Dubai.pm | rosiro/wasarabi | 1016fb3a612fc4da3761c53c73473dd113a578d3 | [
"MIT"
] | null | null | null | # This file is auto-generated by the Perl DateTime Suite time zone
# code generator (0.07) This code generator comes with the
# DateTime::TimeZone module distribution in the tools/ directory
#
# Generated from /tmp/BU3Xn7v6Kb/asia. Olson data version 2015g
#
# Do not edit this file directly.
#
package DateTime::TimeZone::Asia::Dubai;
$DateTime::TimeZone::Asia::Dubai::VERSION = '1.94';
use strict;
use Class::Singleton 1.03;
use DateTime::TimeZone;
use DateTime::TimeZone::OlsonDB;
@DateTime::TimeZone::Asia::Dubai::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' );
my $spans =
[
[
DateTime::TimeZone::NEG_INFINITY, # utc_start
60557746728, # utc_end 1919-12-31 20:18:48 (Wed)
DateTime::TimeZone::NEG_INFINITY, # local_start
60557760000, # local_end 1920-01-01 00:00:00 (Thu)
13272,
0,
'LMT',
],
[
60557746728, # utc_start 1919-12-31 20:18:48 (Wed)
DateTime::TimeZone::INFINITY, # utc_end
60557761128, # local_start 1920-01-01 00:18:48 (Thu)
DateTime::TimeZone::INFINITY, # local_end
14400,
0,
'GST',
],
];
sub olson_version {'2015g'}
sub has_dst_changes {0}
sub _max_year {2025}
sub _new_instance {
return shift->_init( @_, spans => $spans );
}
1;
| 21.607143 | 85 | 0.693388 |
ed2f8ada97cbcadf0d0bbcdb6e84862107f40b56 | 329 | al | Perl | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/auto/POSIX/strlen.al | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/auto/POSIX/strlen.al | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/auto/POSIX/strlen.al | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | # NOTE: Derived from ..\..\lib\POSIX.pm.
# Changes made here will be lost when autosplit is run again.
# See AutoSplit.pm.
package POSIX;
#line 524 "..\..\lib\POSIX.pm (autosplit into ..\..\lib\auto\POSIX\strlen.al)"
sub strlen {
unimpl "strlen() is C-specific, use length instead";
}
# end of POSIX::strlen
1;
| 25.307692 | 79 | 0.650456 |
edbc0629cc372fd2287541ca9322322aff967fe1 | 9,905 | pm | Perl | lib/Sisimai/MSP/US/AmazonSES.pm | jcbf/Sisimai | f9b6e6da06e7aafaac66a31f12f55404bbee8d65 | [
"BSD-2-Clause"
] | 1 | 2015-06-19T16:36:44.000Z | 2015-06-19T16:36:44.000Z | lib/Sisimai/MSP/US/AmazonSES.pm | jcbf/Sisimai | f9b6e6da06e7aafaac66a31f12f55404bbee8d65 | [
"BSD-2-Clause"
] | null | null | null | lib/Sisimai/MSP/US/AmazonSES.pm | jcbf/Sisimai | f9b6e6da06e7aafaac66a31f12f55404bbee8d65 | [
"BSD-2-Clause"
] | null | null | null | package Sisimai::MSP::US::AmazonSES;
use parent 'Sisimai::MSP';
use feature ':5.10';
use strict;
use warnings;
# http://aws.amazon.com/ses/
my $Re0 = {
'from' => qr/\AMAILER-DAEMON[@]email[-]bounces[.]amazonses[.]com\z/,
'subject' => qr/\ADelivery Status Notification [(]Failure[)]\z/,
};
my $Re1 = {
'begin' => qr/\AThe following message to [<]/,
'rfc822' => qr|\Acontent-type: message/rfc822\z|,
'endof' => qr/\A__END_OF_EMAIL_MESSAGE__\z/,
};
my $ReFailure = {
'expired' => qr/Delivery[ ]expired/x,
};
my $Indicators = __PACKAGE__->INDICATORS;
sub description { 'Amazon SES(Sending): http://aws.amazon.com/ses/' };
sub smtpagent { 'US::AmazonSES' }
# X-SenderID: Sendmail Sender-ID Filter v1.0.0 nijo.example.jp p7V3i843003008
# X-Original-To: 000001321defbd2a-788e31c8-2be1-422f-a8d4-cf7765cc9ed7-000000@email-bounces.amazonses.com
# X-AWS-Outgoing: 199.255.192.156
sub headerlist { return [ 'X-AWS-Outgoing' ] }
sub pattern { return $Re0 }
sub scan {
# Detect an error from Amazon SES
# @param [Hash] mhead Message header of a bounce email
# @options mhead [String] from From header
# @options mhead [String] date Date header
# @options mhead [String] subject Subject header
# @options mhead [Array] received Received headers
# @options mhead [String] others Other required headers
# @param [String] mbody Message body of a bounce email
# @return [Hash, Undef] Bounce data list and message/rfc822 part
# or Undef if it failed to parse or the
# arguments are missing
# @since v4.0.2
my $class = shift;
my $mhead = shift // return undef;
my $mbody = shift // return undef;
return undef unless $mhead->{'x-aws-outgoing'};
my $dscontents = [ __PACKAGE__->DELIVERYSTATUS ];
my @hasdivided = split( "\n", $$mbody );
my $rfc822part = ''; # (String) message/rfc822-headers part
my $rfc822list = []; # (Array) Each line in message/rfc822 part string
my $blanklines = 0; # (Integer) The number of blank lines
my $readcursor = 0; # (Integer) Points the current cursor position
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
my $connvalues = 0; # (Integer) Flag, 1 if all the value of $connheader have been set
my $connheader = {
'lhost' => '', # The value of Reporting-MTA header
};
my $v = undef;
my $p = '';
for my $e ( @hasdivided ) {
# Read each line between $Re1->{'begin'} and $Re1->{'rfc822'}.
unless( $readcursor ) {
# Beginning of the bounce message or delivery status part
if( $e =~ $Re1->{'begin'} ) {
$readcursor |= $Indicators->{'deliverystatus'};
next;
}
}
unless( $readcursor & $Indicators->{'message-rfc822'} ) {
# Beginning of the original message part
if( $e =~ $Re1->{'rfc822'} ) {
$readcursor |= $Indicators->{'message-rfc822'};
next;
}
}
if( $readcursor & $Indicators->{'message-rfc822'} ) {
# After "message/rfc822"
unless( length $e ) {
$blanklines++;
last if $blanklines > 1;
next;
}
push @$rfc822list, $e;
} else {
# Before "message/rfc822"
next unless $readcursor & $Indicators->{'deliverystatus'};
next unless length $e;
if( $connvalues == scalar( keys %$connheader ) ) {
# Final-Recipient: rfc822;kijitora@example.jp
# Action: failed
# Status: 5.0.0 (permanent failure)
# Remote-MTA: dns; [192.0.2.9]
# Diagnostic-Code: smtp; 5.1.0 - Unknown address error 550-'5.7.1
# <000001321defbd2a-788e31c8-2be1-422f-a8d4-cf7765cc9ed7-000000@email-bounces.amazonses.com>...
# Access denied' (delivery attempts: 0)
#
# --JuU8e.4gyIcCrxq.1RFbQY.3Vu7Hs+
# content-type: message/rfc822
$v = $dscontents->[ -1 ];
if( $e =~ m/\A[Ff]inal-[Rr]ecipient:[ ]*(?:RFC|rfc)822;[ ]*([^ ]+)\z/ ) {
# Final-Recipient: RFC822; userunknown@example.jp
if( length $v->{'recipient'} ) {
# There are multiple recipient addresses in the message body.
push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
$v = $dscontents->[ -1 ];
}
$v->{'recipient'} = $1;
$recipients++;
} elsif( $e =~ m/\A[Xx]-[Aa]ctual-[Rr]ecipient:[ ]*(?:RFC|rfc)822;[ ]*([^ ]+)\z/ ) {
# X-Actual-Recipient: RFC822; kijitora@example.co.jp
$v->{'alias'} = $1;
} elsif( $e =~ m/\A[Aa]ction:[ ]*(.+)\z/ ) {
# Action: failed
$v->{'action'} = lc $1;
} elsif( $e =~ m/\A[Ss]tatus:[ ]*(\d[.]\d+[.]\d+)/ ) {
# Status: 5.1.1
# Status:5.2.0
# Status: 5.1.0 (permanent failure)
$v->{'status'} = $1;
$v->{'softbounce'} = 0 if $e =~ m/[(]permanent failure[)]/;
} elsif( $e =~ m/\A[Rr]emote-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/ ) {
# Remote-MTA: DNS; mx.example.jp
$v->{'rhost'} = lc $1;
} elsif( $e =~ m/\A[Ll]ast-[Aa]ttempt-[Dd]ate:[ ]*(.+)\z/ ) {
# Last-Attempt-Date: Fri, 14 Feb 2014 12:30:08 -0500
$v->{'date'} = $1;
} else {
if( $e =~ m/\A[Dd]iagnostic-[Cc]ode:[ ]*(.+?);[ ]*(.+)\z/ ) {
# Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
$v->{'spec'} = uc $1;
$v->{'diagnosis'} = $2;
} elsif( $p =~ m/\A[Dd]iagnostic-[Cc]ode:[ ]*/ && $e =~ m/\A[ \t]+(.+)\z/ ) {
# Continued line of the value of Diagnostic-Code header
$v->{'diagnosis'} .= ' '.$1;
$e = 'Diagnostic-Code: '.$e;
}
}
} else {
# The following message to <kijitora@example.jp> was undeliverable.
# The reason for the problem:
# 5.1.0 - Unknown address error 550-'5.7.1 <0000000000000000-00000000-0000-00=
# 00-0000-000000000000-000000@email-bounces.amazonses.com>... Access denied'
#
# --JuU8e.4gyIcCrxq.1RFbQY.3Vu7Hs+
# content-type: message/delivery-status
#
# Reporting-MTA: dns; a192-79.smtp-out.amazonses.com
#
if( $e =~ m/\A[Rr]eporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/ ) {
# Reporting-MTA: dns; mx.example.jp
next if length $connheader->{'lhost'};
$connheader->{'lhost'} = lc $1;
$connvalues++;
}
}
} # End of if: rfc822
} continue {
# Save the current line for the next loop
$p = $e;
}
return undef unless $recipients;
require Sisimai::String;
require Sisimai::SMTP::Status;
for my $e ( @$dscontents ) {
# Set default values if each value is empty.
map { $e->{ $_ } ||= $connheader->{ $_ } || '' } keys %$connheader;
$e->{'diagnosis'} =~ s{\\n}{ }g;
$e->{'diagnosis'} = Sisimai::String->sweep( $e->{'diagnosis'} );
if( $e->{'status'} =~ m/\A[45][.][01][.]0\z/ ) {
# Get other D.S.N. value from the error message
my $pseudostatus = '';
my $errormessage = $e->{'diagnosis'};
if( $e->{'diagnosis'} =~ m/["'](\d[.]\d[.]\d.+)['"]/ ) {
# 5.1.0 - Unknown address error 550-'5.7.1 ...
$errormessage = $1;
}
$pseudostatus = Sisimai::SMTP::Status->find( $errormessage );
$e->{'status'} = $pseudostatus if length $pseudostatus;
}
SESSION: for my $r ( keys %$ReFailure ) {
# Verify each regular expression of session errors
next unless $e->{'diagnosis'} =~ $ReFailure->{ $r };
$e->{'reason'} = $r;
last;
}
$e->{'reason'} ||= Sisimai::SMTP::Status->name( $e->{'status'} );
$e->{'agent'} = __PACKAGE__->smtpagent;
}
$rfc822part = Sisimai::RFC5322->weedout( $rfc822list );
return { 'ds' => $dscontents, 'rfc822' => $$rfc822part };
}
1;
__END__
=encoding utf-8
=head1 NAME
Sisimai::MSP::US::AmazonSES - bounce mail parser class for C<Amazon SES>.
=head1 SYNOPSIS
use Sisimai::MSP::US::AmazonSES;
=head1 DESCRIPTION
Sisimai::MSP::US::AmazonSES parses a bounce email which created by C<Amazon
Simple Email Service>. Methods in the module are called from only
Sisimai::Message.
=head1 CLASS METHODS
=head2 C<B<description()>>
C<description()> returns description string of this module.
print Sisimai::MSP::US::AmazonSES->description;
=head2 C<B<smtpagent()>>
C<smtpagent()> returns MTA name.
print Sisimai::MSP::US::AmazonSES->smtpagent;
=head2 C<B<scan( I<header data>, I<reference to body string>)>>
C<scan()> method parses a bounced email and return results as a array reference.
See Sisimai::Message for more details.
=head1 AUTHOR
azumakuniyuki
=head1 COPYRIGHT
Copyright (C) 2014-2016 azumakuniyuki, All rights reserved.
=head1 LICENSE
This software is distributed under The BSD 2-Clause License.
=cut
| 36.958955 | 112 | 0.508733 |
ed67a4f4ba991704ef21ba6fde6c42fe53d2a3f7 | 8,997 | t | Perl | test/t/06_vg_index.t | deliciouslytyped/vg | beea35e2e0b9a4bce32fa3f0f718938a5ecb3be1 | [
"MIT"
] | 1 | 2019-03-27T00:45:58.000Z | 2019-03-27T00:45:58.000Z | test/t/06_vg_index.t | deliciouslytyped/vg | beea35e2e0b9a4bce32fa3f0f718938a5ecb3be1 | [
"MIT"
] | 3 | 2018-04-18T03:14:13.000Z | 2021-03-05T20:54:48.000Z | test/t/06_vg_index.t | xchang1/vg | ac2eacff9596ead01cd879232fdd3d197bd1379c | [
"MIT"
] | null | null | null | #!/usr/bin/env bash
BASH_TAP_ROOT=../deps/bash-tap
. ../deps/bash-tap/bash-tap-bootstrap
PATH=../bin:$PATH # for vg
export LC_ALL="en_US.utf8" # force ekg's favorite sort order
plan tests 52
# Single graph without haplotypes
vg construct -r small/x.fa -v small/x.vcf.gz > x.vg
vg index -x x.xg x.vg
is $? 0 "building an XG index of a graph"
vg index -g x.gcsa x.vg
is $? 0 "building a GCSA index of a graph"
vg index -x x2.xg -g x2.gcsa x.vg
is $? 0 "building both indexes at once"
cmp x.xg x2.xg && cmp x.gcsa x2.gcsa && cmp x.gcsa.lcp x2.gcsa.lcp
is $? 0 "the indexes are identical when built one at a time and together"
vg index -g x3.gcsa x.xg
is $? 0 "building GCSA from XG"
cmp x.gcsa x3.gcsa && cmp x.gcsa.lcp x3.gcsa.lcp
is $? 0 "the GCSA indexes are identical when built from vg and from xg"
rm -f x.vg
rm -f x.xg x.gcsa x.gcsa.lcp
rm -f x2.xg x2.gcsa x2.gcsa.lcp
rm -f x3.gcsa x3.gcsa.lcp
# Single graph with haplotypes
vg construct -r small/x.fa -v small/x.vcf.gz -a > x.vg
vg index -G x.gbwt -v small/x.vcf.gz x.vg
is $? 0 "building a GBWT index of a graph with haplotypes"
vg index -x x.xg x.vg
is $? 0 "building an XG index of a graph with haplotypes"
is $(vg paths -x x.xg -L | wc -l) 1 "xg index does not contain alt paths by default"
vg index -x x-ap.xg x.vg -L
is $? 0 "building an XG index of a graph with haplotypes and alt paths included"
is $(vg paths -x x-ap.xg -L | wc -l) $(vg paths -v x.vg -L | wc -l) "xg index does contains alt paths with index -L"
vg index -g x.gcsa x.vg
is $? 0 "building a GCSA index of a graph with haplotypes"
vg index -x x2.xg -G x2.gbwt -v small/x.vcf.gz -g x2.gcsa x.vg
is $? 0 "building all indexes at once"
cmp x.xg x2.xg && cmp x.gbwt x2.gbwt && cmp x.gcsa x2.gcsa && cmp x.gcsa.lcp x2.gcsa.lcp
is $? 0 "the indexes are identical"
vg index -x x2-ap.xg -G x2-ap.gbwt -v small/x.vcf.gz -g x2-ap.gcsa x.vg -L
is $? 0 "building all indexes at once, while leaving alt paths in xg"
cmp x.gbwt x2-ap.gbwt && cmp x.gcsa x2-ap.gcsa && cmp x.gcsa.lcp x2-ap.gcsa.lcp
is $? 0 "the indexes are identical with -L"
is $(vg paths -x x2-ap.xg -L | wc -l) $(vg paths -v x.vg -L | wc -l) "xg index does contains alt paths with index -L all at once"
# Exclude a sample from the GBWT index
vg index -G empty.gbwt -v small/x.vcf.gz --exclude 1 x.vg
is $? 0 "samples can be excluded from haplotype indexing"
is $(vg gbwt -c empty.gbwt) 0 "excluded samples were not included in the GBWT index"
# Make GBWT from GAM
vg paths -v x.vg -X -Q _alt > x-alts.gam
vg index x.vg -M x-alts.gam -G x-gam.gbwt
# Make GBWT from GAF
vg convert x.vg -G x-alts.gam > x-alts.gaf
vg index x.vg -F x-alts.gaf -G x-gaf.gbwt
cmp x-gaf.gbwt x-gam.gbwt
is $? 0 "GBWT from GAF same as from GAM"
rm -f x.vg
rm -f x.xg x-ap.xg x.gbwtx.gcsa x.gcsa.lcp
rm -f x2.xg x2.gbwt x2.gcsa x2.gcsa.lcp
rm -f x2-ap.xg x2-ap.gbwt x2-ap.gcsa x2-ap.gcsa.lcp
rm -f empty.gbwt
rm -f x-alts.gam x-alts.gaf x-gam.gbwt x-gaf.gbwt
# Subregion graph with haplotypes
vg construct -r small/x.fa -v small/x.vcf.gz -a --region x:100-200 > x.part.vg
vg index -x x.part.xg -G x.part.gbwt --region x:100-200 -v small/x.vcf.gz x.part.vg 2>log.txt
is $? 0 "building GBWT index for a regional graph"
is "$(cat log.txt | wc -c)" "0" "no warnings about missing variants produced"
rm -f x.part.vg x.part.xg x.part.gbwt log.txt
# Multiple graphs without haplotypes
vg construct -r small/xy.fa -v small/xy2.vcf.gz -R x -C > x.vg 2> /dev/null
vg construct -r small/xy.fa -v small/xy2.vcf.gz -R y -C > y.vg 2> /dev/null
vg ids -j x.vg y.vg
vg index -x xy.xg x.vg y.vg
is $? 0 "building an XG index of multiple graphs"
vg index -g xy.gcsa -k 2 x.vg y.vg
is $? 0 "building a GCSA index of multiple graphs"
vg index -x xy2.xg -g xy2.gcsa -k 2 x.vg y.vg
is $? 0 "building both indexes at once"
cmp xy.xg xy2.xg && cmp xy.gcsa xy2.gcsa && cmp xy.gcsa.lcp xy2.gcsa.lcp
is $? 0 "the indexes are identical"
rm -f x.vg y.vg
rm -f xy.xg xy.gcsa xy.gcsa.lcp
rm -f xy2.xg xy2.gcsa xy2.gcsa.lcp
# Multiple graphs with haplotypes
vg construct -r small/xy.fa -v small/xy2.vcf.gz -R x -C -a > x.vg 2> /dev/null
vg construct -r small/xy.fa -v small/xy2.vcf.gz -R y -C -a > y.vg 2> /dev/null
vg ids -j x.vg y.vg
vg index -G x.gbwt -v small/xy2.vcf.gz x.vg && vg index -G y.gbwt -v small/xy2.vcf.gz y.vg && vg gbwt -m -f -o xy.gbwt x.gbwt y.gbwt
is $? 0 "building a GBWT index of multiple graphs with haplotypes"
vg index -x xy.xg x.vg y.vg
is $? 0 "building an XG index of multiple graphs with haplotypes"
vg index -g xy.gcsa -k 2 x.vg y.vg
is $? 0 "building a GCSA index of multiple graphs with haplotypes"
vg index -x xy2.xg -g xy2.gcsa -k 2 x.vg y.vg
is $? 0 "building XG and GCSA indexes at once"
vg index -x xy-alt.xg -L x.vg y.vg
is $? 0 "building an XG index with alt paths"
vg index -G xy2.gbwt -v small/xy2.vcf.gz xy-alt.xg
is $? 0 "building a GBWT index from an XG index"
cmp xy.xg xy2.xg && cmp xy.gcsa xy2.gcsa && cmp xy.gcsa.lcp xy2.gcsa.lcp && cmp xy.gbwt xy2.gbwt
is $? 0 "the indexes are identical"
rm -f x.vg y.vg
rm -f x.gbwt y.gbwt
rm -f xy.xg xy.gbwt xy.gcsa xy.gcsa.lcp
rm -f xy2.xg xy2.gbwt xy2.gcsa xy2.gcsa.lcp
rm -f xy-alt.xg
# GBWT construction options
vg construct -r small/xy.fa -v small/xy2.vcf.gz -R x -C -a > x.vg 2> /dev/null
vg index -G x_ref.gbwt -T x.vg
is $? 0 "GBWT can be built for paths"
rm -f x_ref.gbwt
# We do not test GBWT construction parameters (-B, -u, -n) because they matter only for large inputs.
# We do not test chromosome-length path generation (-P, -o) for the same reason.
# Other tests
vg construct -m 1000 -r small/x.fa -v small/x.vcf.gz >x.vg
vg index -x x.xg x.vg bogus123.vg 2>/dev/null
is $? 1 "fail with nonexistent file"
vg kmers -k 16 -gB x.vg >x.graph
vg index -i x.graph -g x.gcsa
is $? 0 "a prebuilt deBruijn graph in GCSA2 format may be used"
rm -f x.gcsa x.gcsa.lcp x.graph
vg index -x x.xg -g x.gcsa -k 11 x.vg
vg map -T <(vg sim -n 100 -x x.xg) -d x > x1337.gam
# Compare our indexes against gamsort's
vg gamsort -i x1337.sorted.gam.gai2 x1337.gam > x1337.sorted.gam
vg index --index-sorted-gam x1337.sorted.gam
is "$(md5sum <x1337.sorted.gam.gai)" "$(md5sum <x1337.sorted.gam.gai2)" "vg index and vg gamsort produce identical sorted GAM indexes"
rm -rf x1337.gam x1337.sorted.gam.gai2 x1337.sorted.gam.gai x1337.sorted.gam
vg construct -r small/x.fa -v small/x.vcf.gz >x.vg
vg construct -r small/x.fa -v small/x.vcf.gz >y.vg
vg construct -r small/x.fa -v small/x.vcf.gz >z.vg
vg concat x.vg y.vg z.vg >q.vg
vg index -x q.xg q.vg
is $? 0 "storage of multiple graphs in an index succeeds"
rm x.vg y.vg z.vg q.vg
rm -rf q.xg
# Now test backward nodes
vg index -x r.xg reversing/reversing_x.vg
is $? 0 "can index backward nodes"
vg index -k 11 -g r.gcsa reversing/reversing_x.vg
is $? 0 "can index kmers for backward nodes"
rm -rf r.xg r.gcsa
is $(vg index -g x.gcsa -k 16 -V <(vg view -Fv cyclic/two_node.gfa) 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 index works on cyclic graphs with heads and tails"
is $(vg index -g x.gcsa -k 16 -V cyclic/no_heads.vg 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 index works on cyclic graphs with no heads or tails"
is $(vg index -g x.gcsa -k 16 -V cyclic/self_loops.vg 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 index works on cyclic graphs with self loops"
is $(vg index -g x.gcsa -k 16 -V cyclic/all.vg 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 index works on general cyclic graphs"
rm -f x.gcsa x.gcsa.lcp
is $(vg construct -r tiny/tiny.fa -v tiny/tiny.vcf.gz | vg index -g t.gcsa -k 16 -V - 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 indexing of a tiny graph works"
is $(vg construct -r tiny/tiny.fa | vg index -g t.gcsa -k 16 -V - 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 indexing succeeds on a single-node graph"
is $(vg index -g t.gcsa reversing/cactus.vg -k 16 -V 2>&1 | grep 'Index verification complete' | wc -l) 1 "GCSA2 indexing succeeds on graph with heads but no tails"
vg construct -m 1025 -r 1mb1kgp/z.fa > big.vg
is $(vg index -g big.gcsa big.vg -k 16 2>&1 | head -n10 | grep 'Found kmer with offset' | wc -l) 1 "a useful error message is produced when nodes are too large"
rm -f big.vg
rm -f t.gcsa
rm -f x.vg x.xg
rm -f r.gcsa.lcp c.gcsa.lcp t.gcsa.lcp
# Test distance index
vg construct -r small/x.fa -v small/x.vcf.gz > x.vg
vg snarls -T x.vg > snarls.pb
is $? 0 "snarl finding with trivial snarls"
vg index -s snarls.pb -j distIndex -w 100 x.vg
is $? 0 "building a distance index of a graph"
vg index -s snarls.pb -j distIndex x.vg
is $? 0 "building a distance index of a graph without maximum index"
rm -f x.vg distIndex snarls.pb
# Test distance index with GBZ
vg gbwt -g graph.gbz --gbz-format -G graphs/components_walks.gfa
vg snarls -T -Z graph.gbz > graph.snarls
vg index -s graph.snarls -j graph.dist --gbz-format graph.gbz
is $? 0 "distance index construction from GBZ"
rm -f graph.gbz graph.snarls graph.dist
| 33.823308 | 179 | 0.687118 |
ed6e7eb7f29e54602ca3ba74fd73c9c1169d3f6e | 236 | t | Perl | t/001_base.t | greeneg/jafax.org | 9c16d7cbfd66d1b987ce7a84007c9ef88b793c9a | [
"Apache-2.0"
] | null | null | null | t/001_base.t | greeneg/jafax.org | 9c16d7cbfd66d1b987ce7a84007c9ef88b793c9a | [
"Apache-2.0"
] | 74 | 2019-10-27T22:53:26.000Z | 2021-04-05T21:46:00.000Z | t/001_base.t | greeneg/jafax.org | 9c16d7cbfd66d1b987ce7a84007c9ef88b793c9a | [
"Apache-2.0"
] | 1 | 2021-01-12T21:49:03.000Z | 2021-01-12T21:49:03.000Z | use strict;
use warnings;
use Test::More tests => 7;
open *STDERR, ">/dev/null";
use_ok 'Buyo';
use_ok 'Sys::Error';
use_ok 'File::IO';
use_ok 'Buyo::Constants';
use_ok 'Buyo::MkAccount';
use_ok 'Buyo::MkRole';
use_ok 'Buyo::Utils';
| 15.733333 | 27 | 0.673729 |
eda7f0b3827104772da63c6cbacc0d9566bbe6e9 | 8,374 | al | Perl | Modules/DevTools/TestFramework/TestLibraries/Any/src/Any.Codeunit.al | Ema-Falamas/ALAppExtensions | f9ee74c1e06c7382b1f8ff74a0e48ac3781646f6 | [
"MIT"
] | null | null | null | Modules/DevTools/TestFramework/TestLibraries/Any/src/Any.Codeunit.al | Ema-Falamas/ALAppExtensions | f9ee74c1e06c7382b1f8ff74a0e48ac3781646f6 | [
"MIT"
] | 3 | 2020-06-24T12:59:52.000Z | 2020-06-24T14:51:04.000Z | Modules/DevTools/TestFramework/TestLibraries/Any/src/Any.Codeunit.al | Ema-Falamas/ALAppExtensions | f9ee74c1e06c7382b1f8ff74a0e48ac3781646f6 | [
"MIT"
] | 1 | 2020-07-30T12:20:36.000Z | 2020-07-30T12:20:36.000Z | // ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
/// <summary>
/// This library should be used to generate Pseudo-random values for tests
/// This approach is needed to ensure that it is possible to reproduce the failures, since tests will be using the same values
/// To ensure that there are no cross test dependencies, this library must be added as a local variable to the test method
/// </summary>
codeunit 130500 "Any"
{
var
Seed: Integer;
/// <summary>
/// Provides an integer between 1 and the given value
/// </summary>
/// <param name="MaxValue">Upper value for the number, if the number is negative 1 is returned.</param>
/// <returns>Pseudo-random integer value</returns>
procedure IntegerInRange(MaxValue: Integer): Integer
begin
if MaxValue < 1 then
exit(1);
exit(GetNextValue(MaxValue));
end;
/// <summary>
/// Provides an integer between the given values
/// </summary>
/// <param name="MinValue">Lower value for the number</param>
/// <param name="MaxValue">Upper value for the number</param>
/// <returns>Pseudo-random integer value</returns>
procedure IntegerInRange(MinValue: Integer; MaxValue: Integer): Integer
begin
exit(MinValue - 1 + GetNextValue(MaxValue - MinValue + 1));
end;
/// <summary>
/// Provides a decimal between the given values
/// </summary>
/// <param name="MaxValue">Upper value for the number</param>
/// <param name="DecimalPlaces">Number of decimal places</param>
/// <returns>Pseudo-random decimal value</returns>
procedure DecimalInRange(MaxValue: Integer; DecimalPlaces: Integer): Decimal
begin
exit(IntegerInRange(MaxValue * Power(10, DecimalPlaces)) / Power(10, DecimalPlaces));
end;
/// <summary>
/// Provides a decimal between the given values
/// </summary>
/// <param name="MinValue">Lower value for the number</param>
/// <param name="MaxValue">Upper value for the number</param>
/// <param name="DecimalPlaces">Number of decimal places</param>
/// <returns>Pseudo-random decimal value</returns>
procedure DecimalInRange(MinValue: Integer; MaxValue: Integer; DecimalPlaces: Integer): Decimal
begin
exit(MinValue + DecimalInRange(MaxValue - MinValue, DecimalPlaces));
end;
/// <summary>
/// Provides a decimal between the given values
/// </summary>
/// <param name="MinValue">Lower value for the number</param>
/// <param name="MaxValue">Upper value for the number</param>
/// <param name="DecimalPlaces">Number of decimal places</param>
/// <returns>Pseudo-random decimal value</returns>
procedure DecimalInRange(MinValue: Decimal; MaxValue: Decimal; DecimalPlaces: Integer): Decimal
var
Min: Integer;
Max: Integer;
Pow: Integer;
begin
Pow := Power(10, DecimalPlaces);
Min := Round(MinValue * Pow, 1, '>');
Max := Round(MaxValue * Pow, 1, '<');
exit(IntegerInRange(Min, Max) / Pow);
end;
/// <summary>
/// Provides a date between current Workdate to <see cref="MaxNumberOfDays"/> of days
/// </summary>
/// <param name="MaxNumberOfDays">Max number of days for date</param>
/// <returns>Pseudo-random Date in range</returns>
procedure DateInRange(MaxNumberOfDays: Integer): Date
begin
exit(DateInRange(WorkDate(), 0, MaxNumberOfDays));
end;
/// <summary>
/// Provides a date between <see cref="StartingDate"/> to <see cref="MaxNumberOfDays"/> of days
/// </summary>
/// <param name="StartingDate">Date to calculate the values from</param>
/// <param name="MaxNumberOfDays">Max number of days for date</param>
/// <returns>Pseudo-random Date in range</returns>
procedure DateInRange(StartingDate: Date; MaxNumberOfDays: Integer): Date
begin
exit(DateInRange(StartingDate, 0, MaxNumberOfDays));
end;
/// <summary>
/// Provides a date between <see cref="StartingDate"/> + <see cref="MinNumberOfDays"/> to <see cref="MaxNumberOfDays"/> of days
/// </summary>
/// <param name="StartingDate">Date to calculate the values from</param>
/// <param name="MaxNumberOfDays">Max number of days from the StartingDate</param>
/// <param name="MinNumberOfDays">Minimum number of days from the StartingDate</param>
/// <returns>Pseudo-random Date in range</returns>
procedure DateInRange(StartingDate: Date; MinNumberOfDays: Integer; MaxNumberOfDays: Integer): Date
begin
if MinNumberOfDays >= MaxNumberOfDays then
exit(StartingDate);
exit(CalcDate(StrSubstNo('<+%1D>', IntegerInRange(MinNumberOfDays, MaxNumberOfDays)), StartingDate));
end;
/// <summary>
/// Provides an alphabetic text
/// </summary>
/// <param name="Length">Desired length of the text</param>
/// <returns>Pseudo-random alphabetic text</returns>
procedure AlphabeticText(Length: Integer): Text
var
ASCIICodeFrom: Integer;
ASCIICodeTo: Integer;
Number: Integer;
i: Integer;
TextValue: Text;
begin
ASCIICodeFrom := 97;
ASCIICodeTo := 122;
for i := 1 to Length do begin
Number := IntegerInRange(ASCIICodeFrom, ASCIICodeTo);
TextValue[i] := Number;
end;
exit(TextValue);
end;
/// <summary>
/// Provides an alphanumeric text
/// </summary>
/// <param name="Length">Desired length of the text</param>
/// <returns>A pseudo-random alphanumeric text</returns>
procedure AlphanumericText(Length: Integer): Text
var
GuidTxt: Text;
begin
while StrLen(GuidTxt) < Length do
GuidTxt += LowerCase(DelChr(Format(GuidValue()), '=', '{}-'));
exit(CopyStr(GuidTxt, 1, Length));
end;
/// <summary>
/// Provides a Unicode text
/// </summary>
/// <param name="Length">Desired length of the text</param>
/// <returns>Pseudo-random Unicode text</returns>
procedure UnicodeText(Length: Integer) String: Text
var
i: Integer;
begin
for i := 1 to Length do
String[i] := IntegerInRange(1072, 1103); // Cyrillic alphabet (to guarantee only printable chars)
exit(String)
end;
/// <summary>
/// Provides an Email
/// </summary>
/// <returns>Pseudo-random Email</returns>
procedure Email(): Text
begin
exit(Email(20, 20));
end;
/// <summary>
/// Provides an Email
/// </summary>
/// <param name="LocalPartLength">Desired length of the local-part</param>
/// <param name="DomainLength">Desired length of the domain</param>
/// <returns>Pseudo-random Email text</returns>
procedure Email(LocalPartLength: Integer; DomainLength: Integer): Text
begin
exit(AlphaNumericText(LocalPartLength) + '@' + AlphabeticText(DomainLength) + '.' + AlphabeticText(3));
end;
/// <summary>
/// Provides a Guid
/// Guid is not pseduo-random, it is random value
/// </summary>
/// <returns>Random Guid</returns>
procedure GuidValue(): Guid
begin
exit(CreateGuid());
end;
/// <summary>.
/// Sets the Seed for Pseudo-random number generation.
/// Setting this value will change the numbers returned.
/// </summary>
/// <param name="NewSeed">New seed to be used.</param>
procedure SetSeed(NewSeed: Integer)
begin
Seed := NewSeed;
Randomize(Seed);
end;
/// <summary>.
/// This function must be called from all functions that want to use Pseudo-random generation.
/// This function will call the SetSeed with the default value to ensure the same numbers are returned
/// </summary>
/// <param name="MaxValue">Upper range for the number</param>
/// <returns>Pseudo-random integer value</returns>
local procedure GetNextValue(MaxValue: Integer): Integer
begin
if Seed = 0 then
SetSeed(1);
exit(Random(MaxValue));
end;
}
| 36.72807 | 131 | 0.627538 |
edbbf9e40e19eab0f09a1205194879c7f4c1f5e8 | 364 | pm | Perl | auto-lib/Azure/Devices/UserSubscriptionQuota.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
] | null | null | null | auto-lib/Azure/Devices/UserSubscriptionQuota.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
] | null | null | null | auto-lib/Azure/Devices/UserSubscriptionQuota.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
] | 1 | 2021-04-08T15:26:39.000Z | 2021-04-08T15:26:39.000Z | package Azure::Devices::UserSubscriptionQuota;
use Moose;
has 'currentValue' => (is => 'ro', isa => 'Int' );
has 'id' => (is => 'ro', isa => 'Str' );
has 'limit' => (is => 'ro', isa => 'Int' );
has 'name' => (is => 'ro', isa => 'Azure::Devices::Name' );
has 'type' => (is => 'ro', isa => 'Str' );
has 'unit' => (is => 'ro', isa => 'Str' );
1;
| 33.090909 | 62 | 0.46978 |
edb3b95ab5dda9b66a412aefc04529b930223569 | 11,722 | pm | Perl | lib/Path/ScanINC.pm | kentnl/Path-ScanINC | f599e384e6ad4ad6c390d828ed98ffbb1f565bd2 | [
"Artistic-1.0"
] | null | null | null | lib/Path/ScanINC.pm | kentnl/Path-ScanINC | f599e384e6ad4ad6c390d828ed98ffbb1f565bd2 | [
"Artistic-1.0"
] | 5 | 2017-02-27T08:44:17.000Z | 2020-02-17T23:54:04.000Z | lib/Path/ScanINC.pm | kentnl/Path-ScanINC | f599e384e6ad4ad6c390d828ed98ffbb1f565bd2 | [
"Artistic-1.0"
] | 1 | 2021-07-12T15:53:20.000Z | 2021-07-12T15:53:20.000Z | use 5.008; # utf8
use strict;
use warnings;
use utf8;
package Path::ScanINC;
our $VERSION = '1.000004';
# ABSTRACT: Emulate Perls internal handling of @INC.
# AUTHORITY
# Sub Lazy-Aliases
use subs 'inc';
use Class::Tiny qw(inc immutable);
use Try::Tiny qw( try catch );
use Scalar::Util qw( blessed reftype );
use Carp qw( croak );
use Path::Tiny qw( path );
## no critic (Bangs::ProhibitDebuggingModules)
sub __pp { require Data::Dump; goto \&Data::Dump::pp; }
## no critic (RequireArgUnpacking)
sub __croakf { require Carp; @_ = ( sprintf $_[0], splice @_, 1 ); goto \&Carp::croak; }
## use critic
=method new
my $object = $class->new(
inc => [ 'x', 'y', 'z' , ],
immutable => 1 | undef
);
=cut
=method immutable
if( $inc->immutable ) {
print "We're working with a snapshotted version of @INC";
}
=cut
sub _bad_param {
my ( $self, $name, $expected, $got ) = @_;
my $format =
qq[Initialization parameter '%s' to \$object->new( ) ( %s->new() ) expects %s.\n] . qq[\tYou gave \$object->new( %s => %s )];
return __croakf( $format, $name, blessed($self), $expected, $name, __pp($got) );
}
sub _fix_immutable {
my ($self) = @_;
if ( exists $self->{immutable} ) {
return $self->_bad_param( 'immutable', 'undef/a true value', $self->{immutable} ) if ref $self->{immutable};
$self->{immutable} = !!( $self->{immutable} );
}
return;
}
sub _fix_inc {
my ($self) = @_;
if ( exists $self->{inc} ) {
return $self->_bad_param( 'inc', 'an array-reference', $self->{inc} )
if not try { scalar $self->{inc}->[0]; 1 } catch { undef };
}
if ( $self->immutable ) {
if ( exists $self->{inc} ) {
$self->{inc} = [ @{ $self->{inc} } ];
}
else {
$self->{inc} = [@INC];
}
}
return;
}
=begin Pod::Coverage
BUILD
=end Pod::Coverage
=cut
sub BUILD {
my ( $self, ) = @_;
$self->_fix_immutable;
$self->_fix_inc;
return;
}
=method inc
for my $i ( $inc->inc ) {
say "Plain: $incer" if not ref $incer;
say "Callback: $incer" if ref $incer;
}
Returns a copy of the internal version of C<@INC> it will be using.
If the object is C<immutable>, then this method will continue to report the same value as c<@INC>, or will be updated
every time the original array reference passed during construction gets updated:
my $ref = [];
my $a = Path::ScanINC->new( inc => $ref );
my $b = Path::ScanINC->new( inc => $ref, immutable => 1 );
push @{$ref} , 'a';
is( [ $a->inc ]->[0] , 'a' , "non-immutable references keep tracking their original" );
isnt( [ $b->inc ]->[0] , 'a' , "immutable references are shallow-copied at construction" );
Do note of course that is a B<SHALLOW> copy, so if you have multiple C<@INC> copies sharing the same C<array>/C<bless>
references, changes to those references will be shared amongst all C<@INC>'s .
=cut
sub inc {
my ( $self, ) = @_;
return @INC if ( not exists $self->{inc} );
return @{ $self->{inc} };
}
sub _pm_inc_path {
my ( undef, @path_parts ) = @_;
return join q[/], @path_parts;
}
# This method deals with the fact there are refs in @INC, and they have special magic behaviour.
#
# Perl itself, simply invokes special behaviours on those refs, passing the path given in `require`
#
# So in comparison
#
# $self->_ref_expand( $ref, @query )
#
# Invokes those methods, after converting @query to notional format.
#
sub _ref_expand {
my ( $self, $ref, @query ) = @_;
# See perldoc perlfunc / require
if ( blessed($ref) ) {
my (@result) = $ref->INC( $self->_pm_inc_path(@query) );
if ( not @result ) {
return [ undef, ];
}
return [ 1, @result ];
}
if ( 'CODE' eq reftype($ref) ) {
my (@result) = $ref->( $ref, $self->_pm_inc_path(@query) );
if ( not @result ) {
return [ undef, ];
}
return [ 1, @result ];
}
if ( 'ARRAY' eq reftype($ref) ) {
my $code = $ref->[0];
my (@result) = $code->( $ref, $self->_pm_inc_path(@query) );
if ( not @result ) {
return [ undef, ];
}
return [ 1, @result ];
}
## no critic (RequireInterpolationOfMetachars)
__croakf( 'Unknown type of ref in @INC not supported: %s', reftype($ref) );
return [ undef, ];
}
=method first_file
if( defined ( my $file = $inc->first_file('Moose.pm') ) {
print "Yep, Moose seems to be available in \@INC , its at $file, but its not loaded (yet)\n";
}
This proves to be a handy little gem that replaces the oft used
if( try { require Moose ; 1 } ){
Yadayadayada
}
And adds the benefit of not needing to actually source the file to see if it exists or not.
=head4 B<IMPORTANT>: PORTABILITIY
For best system portability, where possible, its suggested you specify paths as arrays
of strings, not slash-separated strings.
$inc->first_file('MooseX' , 'Declare.pm') # Good
$inc->first_file('MooseX/Declare.pm') # Bad.
This is for several reasons, all of which can be summarized as "Windows".
=over 4
=item * C<%INC> keys all use Unix notation.
=item * C<@INC> callbacks expect Unix notation.
=item * C<\> is a valid path part on Unix.
=item * On Win32, we have to use C<\> Separation, not C</> for resolving physical files.
=back
The sum of these means if you do this:
$inc->first_file('MooseX/Declare.pm')
On win32, it might just end up doing:
C:\some\path\here/MooseX/Declare.pm
Which may or may not work.
And additionally, if the above module is loaded, it will be loaded as
"MooseX/Declare.pm"
in C<%INC>, not what you'd expect, C<MooseX\Declare.pm>
=cut
sub first_file {
my ( $self, @args ) = @_;
for my $path ( $self->inc ) {
if ( ref $path ) {
my $result = $self->_ref_expand( $path, @args );
if ( $result->[0] ) {
shift @{$result};
return $result;
}
next;
}
my $fullpath = path($path)->child(@args);
if ( -e $fullpath and not -d $fullpath ) {
return $fullpath;
}
}
return;
}
=method all_files
Returns all matches in all C<@INC> paths.
my $inc = Path::ScanINC->new();
push @INC, 'lib';
my ( @files ) = $inc->all_files('Something','Im','Working','On.pm');
pp(\@files );
# [
# '/something/........./lib/Something/Im/Working/On.pm',
# '/something/....../share/per5/lib/site_perl/5.15.9/Something/Im/Working/On.pm',
# ]
Chances are if you understand how this can be useful, you'll do so immediately.
Useful for debugging what module is being loaded, and possibly introspecting information about
multiple parallel installs of modules in C<%ENV>, such as frequently the case with 'dual-life' modules.
perl -MPath::ScanINC -E 'my $scanner = Path::ScanINC->new(); say for $scanner->all_files(qw( Scalar Util.pm ))'
/usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux/Scalar/Util.pm
/usr/lib64/perl5/5.12.4/x86_64-linux/Scalar/Util.pm
Sort-of like ye' olde' C<perldoc -l>, but more like C<man -a>
I might even be tempted to make a sub-module to make one-liners easier like
perl -MPath::ScanINC::All=Scalar/Util.pm
B<REMINDER>: If there are C<REFS> in C<@INC> that match, they'll return C<array-ref>'s, not strings.
=cut
sub all_files {
my ( $self, @args ) = @_;
my @out;
for my $path ( $self->inc ) {
if ( ref $path ) {
my $result = $self->_ref_expand( $path, @args );
if ( $result->[0] ) {
shift @{$result};
push @out, $result;
}
next;
}
my $fullpath = path($path)->child(@args);
if ( -e $fullpath and not -d $fullpath ) {
push @out, $fullpath;
}
}
return @out;
}
=method first_dir
Just like C<first_file> except for locating directories.
=cut
sub first_dir {
my ( $self, @args ) = @_;
for my $path ( $self->inc ) {
if ( ref $path ) {
my $result = $self->_ref_expand( $path, @args );
if ( $result->[0] ) {
shift @{$result};
return $result;
}
next;
}
my $fullpath = path($path)->child(@args);
if ( -e $fullpath and -d $fullpath ) {
return $fullpath;
}
}
return;
}
=method all_dirs
Just like C<all_dirs> except for locating directories.
=cut
sub all_dirs {
my ( $self, @args ) = @_;
my @out;
for my $path ( $self->inc ) {
if ( ref $path ) {
my $result = $self->_ref_expand( $path, @args );
if ( $result->[0] ) {
shift @{$result};
push @out, $result;
}
next;
}
my $fullpath = path($path)->child(@args);
if ( -e $fullpath and -d $fullpath ) {
push @out, $fullpath;
}
}
return @out;
}
1;
=head1 SYNOPSIS
The Aim of this module is to fully implement everything Perl does with C<@INC>, to be feature compatible with it, including
the behavior with regard to C<sub refs> in C<@INC>.
use Path::ScanINC;
# Normal usage.
my $inc = Path::ScanINC->new( );
# In case you need something that isn't @INC
# but works like it
my $inc = Path::ScanINC->new( inc => \@INC );
# Freeze the value of @INC at the time of object instantiation
# with regard to behaviour so later changes to @INC have no effect
my $inc = Path::ScanINC->new( immutable => 1 );
# Return the first file in @INC that matches.
my $file = $inc->first_file('Path', 'ScanINC.pm' );
# Find all possible versions of modules in @INC
my ( @files ) = $inc->all_files('Path', 'ScanINC.pm');
# Try to discover a File::ShareDir 'module' root.
my $dir = $inc->first_dir('auto','share','module');
# Should return the same as File::ShareDir::module_dir('Path::ScanINC')
# ( assuming such a directory existed, which there is presently no plans of )
my $dir = $inc->first_dir('auto','share','module','Path-ScanINC');
# Find All File::ShareDir roots in @INC
my ( @dirs ) = $inc->all_dirs('auto', 'share');
=head1 DESCRIPTION
C<Path::ScanINC> is a basic tool for traversing C<@INC> in a C<perl>-like manner, stepping over some common
pitfalls with using it. It also has the property of being able to capture C<@INC> states to emulate a portable
isolated library resolver.
=head1 REF SUPPORT IN @INC
This module has elemental support for discovery of results in C<@INC> using C<CODE>/C<ARRAY>/C<BLESSED> entries in
C<@INC>. However, due to a limitation as to how C<perl> itself implements this functionality, the best we can do at present
is simply return what the above are expected to return. This means if you have any of the above ref-types in C<@INC>,
and one of those returns C<a true value>, you'll get handed back an C<ARRAY> reference instead of the file you were
expecting.
Fortunately, C<@INC> barely ever has refs in it. But in the event you I<need> to work with refs in C<@INC> and you
expect that those refs will return C<true>, you have to pick one of two options, either :
=over 4
=item a. Write your code to work with the C<array-ref> returned by the respective reference on a match
=item b. Use the C<all_> family of methods and try pretending that there are no C<array-refs> in the list it returns.
=back
Its possible in a future release we may have better choices how to handle this situation in future, but don't bet on it.
Given that the API as defined by Perl mandates C<code-ref>'s return lists containing C<file-handles> or iterative
C<code-ref>'s , not actual files, the best I can foresee at this time we'd be able to do to make life easier for you is
creating a fake library somewhere in a C<tempdir> and stuffing the result of the C<code-ref>'s into files in that directory
prior to returning a path to the generated file.
( And it also tells me that they have to be "Real" file handles, not tied or blessed ones, so being able to ask a
C<filehandle> what file it represents is equally slim.... if that is of course what you require )
For more details, see L<< C<perldoc perlfunc> or C<perldoc -f require> |perlfunc/require >>.
=cut
| 27.134259 | 129 | 0.642382 |
edac7c6407a110622d2a5c00f50604d8903f7b2f | 377 | pl | Perl | bin/test/textolatin1.pl | holtzermann17/Noosphere | 7be63c122f778ef00e56ffe847a6d40d004527dd | [
"MIT"
] | 1 | 2018-05-31T06:29:48.000Z | 2018-05-31T06:29:48.000Z | bin/test/textolatin1.pl | holtzermann17/Noosphere | 7be63c122f778ef00e56ffe847a6d40d004527dd | [
"MIT"
] | null | null | null | bin/test/textolatin1.pl | holtzermann17/Noosphere | 7be63c122f778ef00e56ffe847a6d40d004527dd | [
"MIT"
] | 1 | 2021-05-02T15:14:36.000Z | 2021-05-02T15:14:36.000Z | #!/usr/bin/perl
use strict;
use lib '/var/www/pm/lib';
use Noosphere;
use Noosphere::Util;
use Noosphere::Latex;
my @list=("ad\\`eles","H\\^opital's","ch\\`avtal",'K\\"onigsberg');
#foreach my $str (@list) {
# print Noosphere::TeXtoLatin1($str)."\n";
#}
my $x = Noosphere::htmlToLatin1('Noncompact covering properties (paracompact, Lindelöf, etc.)');
print "$x\n";
| 19.842105 | 101 | 0.655172 |
edbb4f59417acbd59090fd64dcd0971ef712bbc0 | 2,002 | pm | Perl | auto-lib/Paws/Lightsail/RelationalDatabaseEvent.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 164 | 2015-01-08T14:58:53.000Z | 2022-02-20T19:16:24.000Z | auto-lib/Paws/Lightsail/RelationalDatabaseEvent.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 348 | 2015-01-07T22:08:38.000Z | 2022-01-27T14:34:44.000Z | auto-lib/Paws/Lightsail/RelationalDatabaseEvent.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z | # Generated by default/object.tt
package Paws::Lightsail::RelationalDatabaseEvent;
use Moose;
has CreatedAt => (is => 'ro', isa => 'Str', request_name => 'createdAt', traits => ['NameInRequest']);
has EventCategories => (is => 'ro', isa => 'ArrayRef[Str|Undef]', request_name => 'eventCategories', traits => ['NameInRequest']);
has Message => (is => 'ro', isa => 'Str', request_name => 'message', traits => ['NameInRequest']);
has Resource => (is => 'ro', isa => 'Str', request_name => 'resource', traits => ['NameInRequest']);
1;
### main pod documentation begin ###
=head1 NAME
Paws::Lightsail::RelationalDatabaseEvent
=head1 USAGE
This class represents one of two things:
=head3 Arguments in a call to a service
Use the attributes of this class as arguments to methods. You shouldn't make instances of this class.
Each attribute should be used as a named argument in the calls that expect this type of object.
As an example, if Att1 is expected to be a Paws::Lightsail::RelationalDatabaseEvent object:
$service_obj->Method(Att1 => { CreatedAt => $value, ..., Resource => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::Lightsail::RelationalDatabaseEvent object:
$result = $service_obj->Method(...);
$result->Att1->CreatedAt
=head1 DESCRIPTION
Describes an event for a database.
=head1 ATTRIBUTES
=head2 CreatedAt => Str
The timestamp when the database event was created.
=head2 EventCategories => ArrayRef[Str|Undef]
The category that the database event belongs to.
=head2 Message => Str
The message of the database event.
=head2 Resource => Str
The database that the database event relates to.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::Lightsail>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 26 | 132 | 0.71978 |
eda9cc4bd7b45e459f0e5b9e56fe58a3fc311218 | 2,920 | pm | Perl | auto-lib/Paws/StorageGateway/RetrieveTapeArchive.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/StorageGateway/RetrieveTapeArchive.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/StorageGateway/RetrieveTapeArchive.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null |
package Paws::StorageGateway::RetrieveTapeArchive;
use Moose;
has GatewayARN => (is => 'ro', isa => 'Str', required => 1);
has TapeARN => (is => 'ro', isa => 'Str', required => 1);
use MooseX::ClassAttribute;
class_has _api_call => (isa => 'Str', is => 'ro', default => 'RetrieveTapeArchive');
class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::StorageGateway::RetrieveTapeArchiveOutput');
class_has _result_key => (isa => 'Str', is => 'ro');
1;
### main pod documentation begin ###
=head1 NAME
Paws::StorageGateway::RetrieveTapeArchive - Arguments for method RetrieveTapeArchive on L<Paws::StorageGateway>
=head1 DESCRIPTION
This class represents the parameters used for calling the method RetrieveTapeArchive on the
L<AWS Storage Gateway|Paws::StorageGateway> service. Use the attributes of this class
as arguments to method RetrieveTapeArchive.
You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to RetrieveTapeArchive.
=head1 SYNOPSIS
my $storagegateway = Paws->service('StorageGateway');
# To retrieve an archived tape from the VTS
# Retrieves an archived virtual tape from the virtual tape shelf (VTS) to a
# gateway-VTL. Virtual tapes archived in the VTS are not associated with any
# gateway.
my $RetrieveTapeArchiveOutput = $storagegateway->RetrieveTapeArchive(
{
'GatewayARN' =>
'arn:aws:storagegateway:us-east-1:999999999999:gateway/sgw-12A3456B',
'TapeARN' =>
'arn:aws:storagegateway:us-east-1:999999999999:tape/TEST0AA2AF'
}
);
# Results:
my $TapeARN = $RetrieveTapeArchiveOutput->TapeARN;
# Returns a L<Paws::StorageGateway::RetrieveTapeArchiveOutput> object.
Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.
For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/storagegateway/RetrieveTapeArchive>
=head1 ATTRIBUTES
=head2 B<REQUIRED> GatewayARN => Str
The Amazon Resource Name (ARN) of the gateway you want to retrieve the
virtual tape to. Use the ListGateways operation to return a list of
gateways for your account and region.
You retrieve archived virtual tapes to only one gateway and the gateway
must be a tape gateway.
=head2 B<REQUIRED> TapeARN => Str
The Amazon Resource Name (ARN) of the virtual tape you want to retrieve
from the virtual tape shelf (VTS).
=head1 SEE ALSO
This class forms part of L<Paws>, documenting arguments for method RetrieveTapeArchive in L<Paws::StorageGateway>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 33.953488 | 249 | 0.733904 |
eda81c753dcae43c750fd7a1dcd377052c60cdba | 1,177 | pm | Perl | lib/Business/CyberSource/Response/Role/ReasonCode.pm | gitpan/Business-CyberSource | 52db83c08628562136f01ff0392daa0b5af1ad1c | [
"Artistic-2.0"
] | null | null | null | lib/Business/CyberSource/Response/Role/ReasonCode.pm | gitpan/Business-CyberSource | 52db83c08628562136f01ff0392daa0b5af1ad1c | [
"Artistic-2.0"
] | null | null | null | lib/Business/CyberSource/Response/Role/ReasonCode.pm | gitpan/Business-CyberSource | 52db83c08628562136f01ff0392daa0b5af1ad1c | [
"Artistic-2.0"
] | null | null | null | package Business::CyberSource::Response::Role::ReasonCode;
use strict;
use warnings;
use namespace::autoclean;
use Module::Load qw( load );
our $VERSION = '0.010005'; # VERSION
use Moose::Role;
use MooseX::RemoteHelper;
use MooseX::Types::Common::String 0.001005 qw( NumericCode );
has reason_code => (
isa => NumericCode,
remote_name => 'reasonCode',
required => 1,
is => 'ro',
predicate => 'has_reason_code',
);
1;
# ABSTRACT: Role for ReasonCode
__END__
=pod
=encoding UTF-8
=head1 NAME
Business::CyberSource::Response::Role::ReasonCode - Role for ReasonCode
=head1 VERSION
version 0.010005
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website
https://github.com/xenoterracide/business-cybersource/issues
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 AUTHOR
Caleb Cushing <xenoterracide@gmail.com>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Caleb Cushing <xenoterracide@gmail.com>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut
| 19.616667 | 79 | 0.738318 |
ed9810be9698451a06b63dac9958af237f5303c1 | 5,772 | pm | Perl | modules/Bio/EnsEMBL/PaddedSlice.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/PaddedSlice.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/PaddedSlice.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | 1 | 2016-02-17T09:50:07.000Z | 2016-02-17T09:50:07.000Z | =head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
=head1 NAME
Bio::EnsEMBL::PaddedSlice
=head1 DESCRIPTION
Used when dumping Slices which represet a portion of the sequence region
they map to e.g. the first section of human Y. The code will return N
as sequence if an attempt is made to retrieve sequence not covered by the
Slice given. This makes the code very memory efficient if sequence dumping
is carried out using C<subseq()> calls.
=head1 METHODS
=cut
package Bio::EnsEMBL::PaddedSlice;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument qw/rearrange/;
use Bio::EnsEMBL::Utils::Scalar qw/assert_ref assert_strand/;
use base qw/Bio::EnsEMBL::Utils::Proxy/;
=head2 new()
Arg [SLICE] : The Slice to proxy
Example : my $newobj = Bio::EnsEMBL::PaddedSlice->new($myobj);
Description : Provides a new instance of a padded slice
Returntype : Bio::EnsEMBL::PaddedSlice
Exceptions : None
Caller : public
Status : -
=cut
sub new {
my ($class, @args) = @_;
my ($slice) = rearrange([qw/slice/], @args);
return $class->SUPER::new($slice);
}
=head2 start()
Example : $slice->start();
Description : Always returns 1 since all padded slices start at 1
Returntype : Int
Exceptions : None
Caller : public
Status : -
=cut
sub start {
my ($self) = @_;
return 1;
}
=head2 end()
Example : $slice->end();
Description : Always returns the backing slice sequence region length
Returntype : Int
Exceptions : None
Caller : public
Status : -
=cut
sub end {
my ($self) = @_;
return $self->seq_region_length();
}
=head2 length()
Example : $slice->length();
Description : Delegates to C<end()>
Returntype : Int
Exceptions : None
Caller : public
Status : -
=cut
sub length {
my ($self) = @_;
return $self->end();
}
=head2 seq()
Example : my $seq = $slice->seq()
Description : Returns the entire sequence of the backing slice but padded
with N's at the beginning and the end of the slice where
applicable
Returntype : Scalar string
Exceptions : None
Caller : public
Status : -
=cut
sub seq {
my ($self) = @_;
my $parent_slice = $self->__proxy();
my $pad_start = 'N' x ( $parent_slice->start() - 1 );
my $pad_end = 'N' x ( $parent_slice->seq_region_length() - $parent_slice->end() );
my $seq = $parent_slice->seq();
return $pad_start . $seq . $pad_end;
}
=head2 subseq()
Arg [1] : Int; start position of the subslice
Arg [2] : Int; end position of the subslice
Arg [3] : Int; strand of the subslice
Example : my $subseq = $slice->subseq(1, 1_000_000);
Description : Returns a portion of the sequence padded with N's if required
Returntype : Scalar string
Exceptions : None
Caller : public
Status : -
=cut
sub subseq {
my ( $self, $start, $end, $strand ) = @_;
if ( $end+1 < $start ) {
throw("End coord + 1 is less than start coord");
}
return '' if( $start == $end + 1);
$strand = 1 unless(defined $strand);
assert_strand($strand, 'strand');
my $parent_slice = $self->__proxy();
#Coords relative to the SeqRegion i.e. huge
my $parent_start = $parent_slice->start();
my $parent_end = $parent_slice->end();
#Return if we were upstream of overlap
if($start < $parent_start && $end < $parent_start) {
return 'N' x (( $end - $start )+1);
}
#Return if we were downstream of overlap
if($start > $parent_end && $end > $parent_end) {
return 'N' x (( $end - $start )+1);
}
my $prefix = '';
my $suffix = '';
my $subslice_start = ($start - $parent_start)+1;
my $subslice_end = ($end - $parent_start) + 1;
if($start < $parent_start) {
$prefix = 'N' x ($parent_start - $start);
$subslice_start = 1;
}
if($end > $parent_end) {
$suffix = 'N' x ($end - $parent_end);
$subslice_end = (($parent_end - $parent_start)+1);
}
my $subseq = $parent_slice->subseq($subslice_start, $subslice_end, $strand);
return $prefix . $subseq . $suffix;
}
=head2 subseq()
Arg [1] : Int; start position of the subslice
Arg [2] : Int; end position of the subslice
Arg [3] : Int; strand of the subslice
Example : my $subseq = $slice->subseq(1, 1_000_000);
Description : Returns a portion of the sequence padded with N's if required
Returntype : Scalar string
Exceptions : None
Caller : public
Status : -
=cut
sub sub_Slice {
die "Unsupported";
}
=head2 __resolver()
Description : Delegates all non-overriden actions onto the backing slice
Returntype : CodeRef
Exceptions : None
Caller : public
Status : -
=cut
sub __resolver {
my ($self, $package_name, $method) = @_;
return sub {
my ($local_self, @args) = @_;
return $local_self->__proxy()->$method(@args);
};
}
1;
| 23.950207 | 100 | 0.648822 |
edaf51d75398662a87e3a53d261024f84ed8a0f2 | 98 | pl | Perl | t/data/db4/003.third.pl | huntprod/nifty-migrant | 633fcc204e7225a95b6459b72b6c7d198a5b23ab | [
"MIT"
] | null | null | null | t/data/db4/003.third.pl | huntprod/nifty-migrant | 633fcc204e7225a95b6459b72b6c7d198a5b23ab | [
"MIT"
] | 1 | 2017-06-30T03:03:36.000Z | 2017-06-30T03:03:36.000Z | t/data/db4/003.third.pl | huntprod/nifty-migrant | 633fcc204e7225a95b6459b72b6c7d198a5b23ab | [
"MIT"
] | null | null | null | use Nifty::Migrant;
DEPLOY <<SQL;
ALTER TABLE sample ADD COLUMN col3 TEXT;
SQL
# no rollback
| 9.8 | 41 | 0.714286 |
edb83873377b1d97a2e4b0ff8ea7cd6cc51ab136 | 1,318 | pl | Perl | integration/logtalk_sicstus.pl | jfmc/logtalk3 | db3a4b39ab8480bf01f90f628bc99e67cd7e72d7 | [
"Apache-2.0"
] | null | null | null | integration/logtalk_sicstus.pl | jfmc/logtalk3 | db3a4b39ab8480bf01f90f628bc99e67cd7e72d7 | [
"Apache-2.0"
] | null | null | null | integration/logtalk_sicstus.pl | jfmc/logtalk3 | db3a4b39ab8480bf01f90f628bc99e67cd7e72d7 | [
"Apache-2.0"
] | null | null | null | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Integration file for SICStus Prolog
% Last updated on April 17, 2018
%
% This file is part of Logtalk <https://logtalk.org/>
% Copyright 1998-2020 Paulo Moura <pmoura@logtalk.org>
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load Logtalk core files
:- (( current_prolog_flag(informational, off) ->
compile('$LOGTALKHOME/adapters/sicstus.pl'),
compile('$LOGTALKHOME/paths/paths.pl'),
compile('$LOGTALKHOME/core/core.pl')
; set_prolog_flag(informational, off),
compile('$LOGTALKHOME/adapters/sicstus.pl'),
compile('$LOGTALKHOME/paths/paths.pl'),
set_prolog_flag(informational, on),
compile('$LOGTALKHOME/core/core.pl')
)).
| 37.657143 | 75 | 0.647951 |
ed8574ce3b6a8e8e8ed4607664dc0dd223c53a8b | 1,413 | t | Perl | templates/package/chakra-component/templates/src/component.ts.t | NicolaDeastra/saas-ui | dadf7880a37f78fce435473c14822a0a278ab80e | [
"MIT"
] | 107 | 2022-01-28T13:28:58.000Z | 2022-03-31T21:59:55.000Z | templates/package/chakra-component/templates/src/component.ts.t | NicolaDeastra/saas-ui | dadf7880a37f78fce435473c14822a0a278ab80e | [
"MIT"
] | 25 | 2022-02-06T02:25:04.000Z | 2022-03-25T16:32:43.000Z | templates/package/chakra-component/templates/src/component.ts.t | NicolaDeastra/saas-ui | dadf7880a37f78fce435473c14822a0a278ab80e | [
"MIT"
] | 12 | 2022-01-29T12:03:14.000Z | 2022-03-26T15:04:24.000Z | ---
to: "<%= h.packageDir(org, name) %>/src/<%= h.filename(name) %>.tsx"
---
<% component = h.inflection.camelize(name, false) -%>
/**
* 📝 Notes for Contributors:
*
* - When creating an interactive component, we recommend consuming the
* component hook created.
*
* For example, if you wanted to build an accordion component,
* you'll first create a `useAccordion` hook and then create an `Accordion` component
*
* - Ensure this component is properly themable by following [this guide](https://chakra-ui.com/docs/theming/component-style)
*
* - Ensure the component is composable and can adapt to multiple use-cases
*
* @see Guide https://chakra-ui.com/guides/component-guide
* @see Theming https://chakra-ui.com/docs/theming/component-style
*/
import * as React from 'react'
import {
chakra,
forwardRef,
useStyleConfig,
HTMLChakraProps,
ThemingProps,
omitThemingProps
} from '@chakra-ui/system'
interface <%= component %>Options {
}
export interface <%= component %>Props
extends <%= component %>Options,
HTMLChakraProps<'div'>,
ThemingProps<'<%= component %>'> {}
export const <%= component %> = forwardRef<<%= component %>Props, 'div'>((props, ref) => {
const styles = useStyleConfig('<%= component %>', props)
const { children, ...rest } = omitThemingProps(props)
return (
<chakra.div ref={ref} __css={styles} {...rest}>{children}</chakra.div>
)
})
| 28.26 | 125 | 0.678698 |
eda467f60da88dc75e8b79f6f109aee8bec1ce8b | 3,026 | t | Perl | qatest/frontend/12_get_entity_cert.t | adesso-as-a-service/openxpki | 0ef14d3d714a3f9d4f902ab8b5551e2b20a91eb0 | [
"Apache-2.0"
] | 357 | 2015-02-19T18:23:12.000Z | 2022-03-29T04:05:25.000Z | qatest/frontend/12_get_entity_cert.t | adesso-as-a-service/openxpki | 0ef14d3d714a3f9d4f902ab8b5551e2b20a91eb0 | [
"Apache-2.0"
] | 604 | 2015-01-19T11:58:44.000Z | 2022-03-14T13:38:42.000Z | qatest/frontend/12_get_entity_cert.t | adesso-as-a-service/openxpki | 0ef14d3d714a3f9d4f902ab8b5551e2b20a91eb0 | [
"Apache-2.0"
] | 108 | 2015-03-10T19:05:20.000Z | 2022-03-29T04:32:28.000Z | #!/usr/bin/perl
use lib qw(../lib);
use strict;
use warnings;
use JSON;
use English;
use Data::Dumper;
use Log::Log4perl qw(:easy);
use TestCGI;
use MIME::Base64;
use Crypt::X509;
use Test::More tests => 4;
package main;
my $result;
my $client = TestCGI::factory('democa');
# create temp dir
-d "tmp/" || mkdir "tmp/";
$result = $client->mock_request({
'page' => 'workflow!index!wf_type!certificate_signing_request_v2',
});
is($result->{main}->[0]->{content}->{fields}->[2]->{name}, 'wf_token');
$result = $client->mock_request({
'action' => 'workflow!index',
'wf_token' => undef,
'cert_profile' => 'tls_server',
'cert_subject_style' => '00_basic_style'
});
like($result->{goto}, qr/workflow!load!wf_id!\d+/, 'Got redirect');
my ($wf_id) = $result->{goto} =~ /workflow!load!wf_id!(\d+)/;
diag("Workflow Id is $wf_id");
$result = $client->mock_request({
'page' => $result->{goto},
});
$result = $client->mock_request({
'action' => 'workflow!select!wf_action!csr_upload_pkcs10!wf_id!'.$wf_id,
});
# Create the pkcs10
my $pkcs10 = `openssl req -new -subj "/CN=testbox.openxpki.org" -nodes -keyout /dev/null 2>/dev/null`;
$result = $client->mock_request({
'action' => 'workflow!index',
'pkcs10' => $pkcs10,
'wf_token' => undef
});
$result = $client->mock_request({
'action' => 'workflow!index',
'cert_subject_parts{hostname}' => 'testbox.openxpki.org',
'cert_subject_parts{hostname2}' => ['testbox.openxpki.net'],
'wf_token' => undef
});
$result = $client->mock_request({
'action' => 'workflow!index',
'cert_info{requestor_email}' => 'test@openxpki.local',
'wf_token' => undef
});
$result = $client->mock_request({
'action' => $result->{main}->[0]->{content}->{buttons}->[0]->{action}
});
if ($result->{main}->[0]->{content}->{fields} &&
$result->{main}->[0]->{content}->{fields}->[0]->{name} eq 'policy_comment') {
$result = $client->mock_request({
'action' => 'workflow!index',
'policy_comment' => 'Testing',
'wf_token' => undef
});
}
$result = $client->mock_request({
'action' => 'workflow!select!wf_action!csr_approve_csr!wf_id!' . $wf_id,
});
is ($result->{status}->{level}, 'success', 'Status is success');
my $cert_identifier = $result->{main}->[0]->{content}->{data}->[0]->{value}->{label};
$cert_identifier =~ s/\<br.*$//g;
# Download the certificate
$result = $client->mock_request({
'page' => 'certificate!download!format!pem!identifier!'.$cert_identifier
});
open(CERT, ">tmp/entity12.id");
print CERT $cert_identifier;
close CERT;
open(CERT, ">tmp/entity12.crt");
print CERT $result ;
close CERT;
if ($result =~ m{-----BEGIN[^-]*CERTIFICATE-----(.+)-----END[^-]*CERTIFICATE-----}xms) {
my $x509 = new Crypt::X509( cert => decode_base64($1) );
# ipaddress is a binary value and stringified in the crypt::x509 class so we can not check this easily
like(join(',', sort @{$x509->SubjectAltName()}),'/dNSName=testbox.openxpki.net,dNSName=testbox.openxpki.org/');
}
| 26.313043 | 115 | 0.6269 |
ed1f44ea36522b0fb14ea919253dcae1c945a72e | 415 | pm | Perl | lib/Moose/Meta/Method/Accessor/Native/Hash/kv.pm | mjemmeson/Moose | 500a1f3331d4a7187775f4b82cdc4f1af2e232d6 | [
"Artistic-1.0"
] | null | null | null | lib/Moose/Meta/Method/Accessor/Native/Hash/kv.pm | mjemmeson/Moose | 500a1f3331d4a7187775f4b82cdc4f1af2e232d6 | [
"Artistic-1.0"
] | null | null | null | lib/Moose/Meta/Method/Accessor/Native/Hash/kv.pm | mjemmeson/Moose | 500a1f3331d4a7187775f4b82cdc4f1af2e232d6 | [
"Artistic-1.0"
] | null | null | null | package Moose::Meta::Method::Accessor::Native::Hash::kv;
our $VERSION = '2.1803';
use strict;
use warnings;
use Moose::Role;
with 'Moose::Meta::Method::Accessor::Native::Reader';
sub _maximum_arguments { 0 }
sub _return_value {
my $self = shift;
my ($slot_access) = @_;
return 'map { [ $_, ' . $slot_access . '->{$_} ] } '
. 'keys %{ (' . $slot_access . ') }';
}
no Moose::Role;
1;
| 17.291667 | 56 | 0.578313 |
ed93ae51369bd45850fac9e7ef4b1efeb096bdfc | 1,714 | pl | Perl | PD/krucjata/zad3.pl | qwercik/Studia | 82a98256e107fe19330ef7d58f1dc47f633d94a1 | [
"MIT"
] | null | null | null | PD/krucjata/zad3.pl | qwercik/Studia | 82a98256e107fe19330ef7d58f1dc47f633d94a1 | [
"MIT"
] | null | null | null | PD/krucjata/zad3.pl | qwercik/Studia | 82a98256e107fe19330ef7d58f1dc47f633d94a1 | [
"MIT"
] | null | null | null | % Początek 23:18
% Koniec 23:48
% Wydawało się proste, ale jednak było trudniejsze. Debugowanie zajęło najdłużej oczywiście ;)
% Sam się dziwię, że udało mi się wpaść na pomysł jak to zrobić. Mam nadzieję że jest dobrze, ale jakoś bardzo wnikliwie nie sprawdzałem
alfabet([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, w, v, x, y, z]).
idx(H, N) :- alfabet(Alfabet), index(H, Alfabet, N).
index(H, [H | T], 0) :- !.
index(X, [H | T], N) :- index(X, T, NN), N is NN + 1.
odl(S1, S2, D) :- idx(S1, N1), idx(S2, N2), D is abs(N2 - N1).
min(Symbol, [X], D) :-
odl(Symbol, X, D),
!
.
min(Symbol, [X | T], D2) :-
min(Symbol, T, D1),
odl(Symbol, X, D2),
D2 =< D1,
!
.
min(Symbol, [_ | T], D) :-
min(Symbol, T, D)
.
scal([], [], []) :- !.
scal([H1 | T1], [H2 | T2], [[H1, H2] | T]) :- scal(T1, T2, T).
partition([_, _], [], [], []) :- !.
partition([PivotKey, _], [[Key, Value] | Tail], [[Key, Value] | Lewo], Prawo) :-
Key < PivotKey,
!,
partition([PivotKey, _], Tail, Lewo, Prawo)
.
partition([PivotKey, _], [[Key, Value] | Tail], Lewo, [[Key, Value] | Prawo]) :-
partition([PivotKey, _], Tail, Lewo, Prawo)
.
quicksort([], []) :- !.
quicksort([H | T], S) :-
partition(H, T, Lewo, Prawo),
quicksort(Lewo, LewoPosortowane),
quicksort(Prawo, PrawoPosortowane),
append(LewoPosortowane, [H], LewoIPivot),
append(LewoIPivot, PrawoPosortowane, S)
.
lista__min(_, [], []) :- !.
lista__min(T0, [H1 | T1], [H2 | T2]) :- append(T0, T1, CalaListaBezObecnego), min(H1, CalaListaBezObecnego, H2), lista__min([H1 | T0], T1, T2).
zadanie(Lista, Wynik) :-
lista__min([], Lista, Lista2),
scal(Lista2, Lista, Lista3),
quicksort(Lista3, ListaPosortowana),
scal(_, Wynik, ListaPosortowana)
.
| 27.645161 | 143 | 0.593932 |
edad8fb7afd6a2c7e06474883c280cdaa3e676ce | 2,565 | pl | Perl | dict/load_xiffus.pl | gfis/gramword | ff66a01935dfdb6230aa8ec3a9d439f99ff80330 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | dict/load_xiffus.pl | gfis/gramword | ff66a01935dfdb6230aa8ec3a9d439f99ff80330 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | dict/load_xiffus.pl | gfis/gramword | ff66a01935dfdb6230aa8ec3a9d439f99ff80330 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | #!/usr/bin/perl
#
# Copyright 2006 Dr. Georg Fischer <punctum at punctum dot kom>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# prepare for raw db table loading of
# reversed suffixes of words and their grammtical type
# @(#) $Id: load_xiffus.pl 36 2008-09-08 06:05:06Z gfis $
# must be stored in UTF-8: äöüÄÖÜß
# 2006-06-13: Georg Fischer
#-------------------------------------------------------------------------
use strict;
# use utf8;
# binmode(STDIN , ":utf8");
# binmode(STDOUT, ":utf8");
print STDOUT "# must be stored in UTF-8 äöüÄÖÜß\n";
my $lang = "de";
while (<>) {
next if m/^\#/ || m/^\s*$/; # skip comments and empty lines
if (m/^\%/) { # processing instruction
if (m/^\%lang\=(.+)$/) {
$lang = $1;
}
}
else { # suffix entry with morpholgy
s/\s//g;
s/\=/\,/;
if (m/^\,/) {
$_ = "-" . $_;
}
my ($entry, $morph, $descr) = split (/\,/);
$entry = & my_reverse ($entry);
$entry =~ s/\xa4\xc3/\xc3\xa4/g; # ä
$entry =~ s/\xb6\xc3/\xc3\xb6/g; # ö
$entry =~ s/\xbc\xc3/\xc3\xbc/g; # ü
$entry =~ s/\x84\xc3/\xc3\x84/g; # Ä
$entry =~ s/\x96\xc3/\xc3\x96/g; # Ö
$entry =~ s/\x9c\xc3/\xc3\x9c/g; # Ü
$entry =~ s/\x9f\xc3/\xc3\x9f/g; # ß
print STDOUT "$entry\t$morph\t$descr\n";
} # entry with morphology
} # while <>
sub my_reverse {
my ($word) = @_;
return join ("", reverse (split (/ */, $word)));
}
__DATA__
%lang=de
elnd =Ajg
# participe
ent =Ajp
ert =Ajp
elt =Ajp
# adverbs
erweise =Av
bar =Av
verlösche =VbSCt13,verlöschen
verlöschen =VbSCt91,verlöschen
verlöscht =VbSCt92,verlöschen
verlöschen =VbSCt93,verlöschen
vermaßen =VbSIn0,vermaßen
vermaße =VbSPr11,vermaßen
vermaßst =VbSPr12,vermaßen
vermaßst =VbSPr13,vermaßen
| 32.468354 | 76 | 0.538791 |
eda5a6cfa42ad2083ed588b0703996cf12004892 | 5,870 | pm | Perl | lib/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm | schwern/Perl-Critic | 55b2404328183a6487d5a3eceb67412c508f0eab | [
"Artistic-1.0"
] | 2 | 2016-08-27T09:29:20.000Z | 2019-04-19T23:05:50.000Z | lib/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm | schwern/Perl-Critic | 55b2404328183a6487d5a3eceb67412c508f0eab | [
"Artistic-1.0"
] | null | null | null | lib/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm | schwern/Perl-Critic | 55b2404328183a6487d5a3eceb67412c508f0eab | [
"Artistic-1.0"
] | null | null | null | ##############################################################################
# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm $
# $Date: 2010-06-22 16:14:07 -0400 (Tue, 22 Jun 2010) $
# $Author: clonezone $
# $Revision: 3843 $
##############################################################################
package Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer;
use 5.006001;
use strict;
use warnings;
use Readonly;
use version;
use Perl::Critic::Utils qw{ :severities :ppi };
use base 'Perl::Critic::Policy';
our $VERSION = '1.117';
#-----------------------------------------------------------------------------
Readonly::Scalar my $DESC => q{I/O layer ":utf8" used};
Readonly::Scalar my $EXPL => q{Use ":encoding(UTF-8)" to get strict validation};
Readonly::Scalar my $THREE_ARGUMENT_OPEN => 3;
Readonly::Hash my %RECOVER_ENCODING => (
binmode => \&_recover_binmode_encoding,
open => \&_recover_open_encoding,
);
#-----------------------------------------------------------------------------
sub supported_parameters { return () }
sub default_severity { return $SEVERITY_HIGHEST }
sub default_themes { return qw(core bugs security) }
sub applies_to { return 'PPI::Token::Word' }
#-----------------------------------------------------------------------------
sub violates {
my ($self, $elem, $document) = @_;
my $handler = $RECOVER_ENCODING{ $elem->content() }
or return; # If we don't have a handler, we're not interested.
my $encoding = $handler->( parse_arg_list( $elem ) )
or return; # If we can't recover an encoding, we give up.
return if $encoding !~ m/ (?: \A | : ) utf8 \b /smxi; # OK
return $self->violation( $DESC, $EXPL, $elem );
}
#-----------------------------------------------------------------------------
# my $string = _get_argument_string( $arg[1] );
#
# This subroutine returns the string from the given argument (which must
# be a reference to an array of PPI objects), _PROVIDED_ the array
# contains a single PPI::Token::Quote object. Otherwise it simply
# returns, since we're too stupid to analyze anything else.
sub _get_argument_string {
my ( $arg ) = @_;
ref $arg eq 'ARRAY' or return;
return if @{ $arg } == 0 || @{ $arg } > 1;
return $arg->[0]->string() if $arg->[0]->isa( 'PPI::Token::Quote' );
return;
}
#-----------------------------------------------------------------------------
# my $encoding = _recover_binmode_encoding( _parse_arg_list( $elem ) );
#
# This subroutine returns the encoding specified by the given $elem,
# which _MUST_ be the 'binmode' of a binmode() call.
sub _recover_binmode_encoding {
my ( @args ) = @_;
return _get_argument_string( $args[1] );
}
#-----------------------------------------------------------------------------
# my $encoding = _recover_open_encoding( _parse_arg_list( $elem ) );
#
# This subroutine returns the encoding specified by the given $elem,
# which _MUST_ be the 'open' of a open() call.
sub _recover_open_encoding {
my ( @args ) = @_;
@args < $THREE_ARGUMENT_OPEN
and return;
defined( my $string = _get_argument_string( $args[1] ) )
or return;
$string =~ s/ [+]? (?: < | >{1,2} ) //smx;
return $string;
}
1;
__END__
#-----------------------------------------------------------------------------
=pod
=for stopwords PerlIO PerlMonks Wiki
=head1 NAME
Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer - Write C<< open $fh, q{<:encoding(UTF-8)}, $filename; >> instead of C<< open $fh, q{{<:utf8}, $filename; >>.
=head1 AFFILIATION
This Policy is part of the core L<Perl::Critic|Perl::Critic>
distribution.
=head1 DESCRIPTION
Use of the C<:utf8> I/O layer (as opposed to C<:encoding(UTF8)> or
C<:encoding(UTF-8)>) was suggested in the Perl documentation up to
version 5.8.8. This may be OK for output, but on input C<:utf8> does not
validate the input, leading to unexpected results.
An exploit based on this behavior of C<:utf8> is exhibited on PerlMonks
at L<http://www.perlmonks.org/?node_id=644786>. The exploit involves a
string read from an external file and sanitized with C<m/^(\w+)$/>,
where C<$1> nonetheless ends up containing shell meta-characters.
To summarize:
open $fh, '<:utf8', 'foo.txt'; # BAD
open $fh, '<:encoding(UTF8)', 'foo.txt'; # GOOD
open $fh, '<:encoding(UTF-8)', 'foo.txt'; # BETTER
See the L<Encode|Encode> documentation for the difference between
C<UTF8> and C<UTF-8>. The short version is that C<UTF-8> implements the
Unicode standard, and C<UTF8> is liberalized.
For consistency's sake, this policy checks files opened for output as
well as input, For complete coverage it also checks C<binmode()> calls,
where the direction the operation can not be determined.
=head1 CONFIGURATION
This Policy is not configurable except for the standard options.
=head1 NOTES
Because C<Perl::Critic> does a static analysis, this policy can not
detect cases like
my $encoding = ':utf8';
binmode $fh, $encoding;
where the encoding is computed.
=head1 SEE ALSO
L<PerlIO|PerlIO>
L<Encode|Encode>
C<perldoc -f binmode>
L<http://www.socialtext.net/perl5/index.cgi?the_utf8_perlio_layer>
L<http://www.perlmonks.org/?node_id=644786>
=head1 AUTHOR
Thomas R. Wyant, III F<wyant at cpan dot org>
=head1 COPYRIGHT
Copyright (c) 2010-2011 Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
| 29.796954 | 173 | 0.600852 |
ed327f6e7152e30e12eb2ef1e844ce772fa86365 | 44,472 | pm | Perl | backend/Image-ExifTool-12.01/lib/Image/ExifTool/Qualcomm.pm | ch0c0l8ra1n/3dfy-v2 | dc90f02e9170c18e8d12725bb277a0d0fdfee9ac | [
"MIT"
] | 302 | 2017-01-02T20:21:45.000Z | 2022-03-29T23:02:32.000Z | backend/Image-ExifTool-12.01/lib/Image/ExifTool/Qualcomm.pm | ch0c0l8ra1n/3dfy-v2 | dc90f02e9170c18e8d12725bb277a0d0fdfee9ac | [
"MIT"
] | 111 | 2017-01-03T17:05:14.000Z | 2021-06-13T13:39:44.000Z | backend/Image-ExifTool-12.01/lib/Image/ExifTool/Qualcomm.pm | ch0c0l8ra1n/3dfy-v2 | dc90f02e9170c18e8d12725bb277a0d0fdfee9ac | [
"MIT"
] | 41 | 2017-01-03T02:52:41.000Z | 2021-06-06T09:47:54.000Z | #------------------------------------------------------------------------------
# File: Qualcomm.pm
#
# Description: Read Qualcomm APP7 meta information
#
# Revisions: 2012/02/14 - P. Harvey Created
#------------------------------------------------------------------------------
package Image::ExifTool::Qualcomm;
use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.01';
sub ProcessQualcomm($$$);
sub MakeNameAndDesc($$);
# Qualcomm format codes (ref PH (NC))
my @qualcommFormat = (
'int8u', 'int8s', 'int16u', 'int16s',
'int32u', 'int32s', 'float', 'double',
);
# information found in JPEG APP7 Qualcomm Camera Attributes segment
%Image::ExifTool::Qualcomm::Main = (
PROCESS_PROC => \&ProcessQualcomm,
GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
VARS => { NO_ID => 1, NO_LOOKUP => 1 }, # too long, too many, and too obscure
NOTES => q{
The tags below have been observed in the JPEG APP7 "Qualcomm Camera
Attributes" segment written by some cameras such as the HP iPAQ Voice
Messenger. ExifTool will extract any information found from this segment,
even if it is not listed in this table.
},
'aec_current_sensor_luma' => { },
'af_position' => { },
'aec_current_exp_index' => { },
'awb_sample_decision' => { },
'asf5_enable' => { },
'asf5_filter_mode' => { },
'asf5_exposure_index_1' => { },
'asf5_exposure_index_2' => { },
'asf5_max_exposure_index' => { },
'asf5_luma_filter[0]' => { },
'asf5_luma_filter[1]' => { },
'asf5_luma_filter[2]' => { },
'asf5_luma_filter[3]' => { },
'asf5_luma_filter[4]' => { },
'asf5_luma_filter[5]' => { },
'asf5_luma_filter[6]' => { },
'asf5_luma_filter[7]' => { },
'asf5_luma_filter[8]' => { },
'asf5_filter1_a11' => { },
'asf5_filter1_a12' => { },
'asf5_filter1_a13' => { },
'asf5_filter1_a14' => { },
'asf5_filter1_a15' => { },
'asf5_filter1_a21' => { },
'asf5_filter1_a22' => { },
'asf5_filter1_a23' => { },
'asf5_filter1_a24' => { },
'asf5_filter1_a25' => { },
'asf5_filter1_a31' => { },
'asf5_filter1_a32' => { },
'asf5_filter1_a33' => { },
'asf5_filter1_a34' => { },
'asf5_filter1_a35' => { },
'asf5_filter1_a41' => { },
'asf5_filter1_a42' => { },
'asf5_filter1_a43' => { },
'asf5_filter1_a44' => { },
'asf5_filter1_a45' => { },
'asf5_filter1_a51' => { },
'asf5_filter1_a52' => { },
'asf5_filter1_a53' => { },
'asf5_filter1_a54' => { },
'asf5_filter1_a55' => { },
'asf5_filter2_a11' => { },
'asf5_filter2_a12' => { },
'asf5_filter2_a13' => { },
'asf5_filter2_a14' => { },
'asf5_filter2_a15' => { },
'asf5_filter2_a21' => { },
'asf5_filter2_a22' => { },
'asf5_filter2_a23' => { },
'asf5_filter2_a24' => { },
'asf5_filter2_a25' => { },
'asf5_filter2_a31' => { },
'asf5_filter2_a32' => { },
'asf5_filter2_a33' => { },
'asf5_filter2_a34' => { },
'asf5_filter2_a35' => { },
'asf5_filter2_a41' => { },
'asf5_filter2_a42' => { },
'asf5_filter2_a43' => { },
'asf5_filter2_a44' => { },
'asf5_filter2_a45' => { },
'asf5_filter2_a51' => { },
'asf5_filter2_a52' => { },
'asf5_filter2_a53' => { },
'asf5_filter2_a54' => { },
'asf5_filter2_a55' => { },
'asf5_nrmize_factor1' => { },
'asf5_nrmize_factor2' => { },
'asf5_low_lo_thres' => { },
'asf5_low_up_thres' => { },
'asf5_low_shrp_deg_f1' => { },
'asf5_low_shrp_deg_f2' => { },
'asf5_low_smth_prcnt' => { },
'asf5_nrm_lo_thres' => { },
'asf5_nrm_up_thres' => { },
'asf5_nrm_shrp_deg_f1' => { },
'asf5_nrm_shrp_deg_f2' => { },
'asf5_nrm_smth_prcnt' => { },
'asf5_brt_lo_thres' => { },
'asf5_brt_up_thres' => { },
'asf5_brt_shrp_deg_f1' => { },
'asf5_brt_shrp_deg_f2' => { },
'asf5_brt_smth_percent' => { },
'asf3_enable' => { },
'asf3_edge_filter_a11' => { },
'asf3_edge_filter_a12' => { },
'asf3_edge_filter_a13' => { },
'asf3_edge_filter_a21' => { },
'asf3_edge_filter_a22' => { },
'asf3_edge_filter_a23' => { },
'asf3_edge_filter_a31' => { },
'asf3_edge_filter_a32' => { },
'asf3_edge_filter_a33' => { },
'asf3_noise_filter_a11' => { },
'asf3_noise_filter_a12' => { },
'asf3_noise_filter_a13' => { },
'asf3_noise_filter_a21' => { },
'asf3_noise_filter_a22' => { },
'asf3_noise_filter_a23' => { },
'asf3_noise_filter_a31' => { },
'asf3_noise_filter_a32' => { },
'asf3_noise_filter_a33' => { },
'asf3_lower_threshold' => { },
'asf3_upper_threshold' => { },
'asf3_edge_detect' => { },
'aec_enable' => { },
'aec_mode' => { },
'aec_aggressiveness' => { },
'aec_luma_target' => { },
'aec_luma_tolerance' => { },
'aec_indoor_idx' => { },
'aec_odoor_idx' => { },
'aec_exposure_index_adj_step' => { },
'aec_outdoor_gamma_index' => { },
'aec_vfe_luma' => { },
'aec_high_luma_region_threshold' => { },
'aec_snapshot_sensor_gain' => { },
'aec_snapshot_digital_gain' => { },
'aec_snapshot_line_count' => { },
'aec_snapshot_exposure_time_ms' => { },
'aec_outdoor_bright_enable' => { },
'aec_outdoor_bright_reduction' => { },
'aec_outdoor_bright_threshold_LO' => { },
'aec_outdoor_bright_threshold_HI' => { },
'aec_outdoor_bright_discarded' => { },
'aec_high_luma_region_count' => { },
'antibanding_enable' => { },
'anti_bading_pixel_clk' => { },
'anti_bading_pixel_clk_per_line' => { },
'afr_enable' => { },
'afr_faster_0_trigger' => { },
'afr_slower_0_trigger' => { },
'afr_faster_0_exp_mod' => { },
'afr_slower_0_exp_mod' => { },
'afr_faster_1_trigger' => { },
'afr_slower_1_trigger' => { },
'afr_faster_1_exp_mod' => { },
'afr_slower_1_exp_mod' => { },
'afr_faster_2_trigger' => { },
'afr_slower_2_trigger' => { },
'afr_faster_2_exp_mod' => { },
'afr_slower_2_exp_mod' => { },
'afr_faster_3_trigger' => { },
'afr_slower_3_trigger' => { },
'afr_faster_3_exp_mod' => { },
'afr_slower_3_exp_mod' => { },
'afr_faster_4_trigger' => { },
'afr_slower_4_trigger' => { },
'afr_faster_4_exp_mod' => { },
'afr_slower_4_exp_mod' => { },
'afr_possible_frame_cnt' => { },
'af_enable' => { },
'af_steps_near_far' => { },
'af_steps_near_infinity' => { },
'af_gross_step' => { },
'af_fine_step' => { },
'af_fine_srch_points' => { },
'af_process' => { },
'af_mode' => { },
'af_near_end' => { },
'af_boundary' => { },
'af_far_end' => { },
'af_collect_end_stat' => { },
'af_test_mode' => { },
'af_undershoot_protect' => { },
'af_reset_lens_after_snap' => { },
'clip_to_af_rato' => { },
'af_pos_def_macro' => { },
'af_pos_def_norm' => { },
'af_vfe_vert_offset' => { },
'af_vfe_horz_offset' => { },
'af_vfe_vert_height' => { },
'af_vfe_horz_width' => { },
'af_vfe_metric_max' => { },
'af_trace_positions[0]' => { },
'af_trace_positions[1]' => { },
'af_trace_positions[2]' => { },
'af_trace_positions[3]' => { },
'af_trace_positions[4]' => { },
'af_trace_positions[5]' => { },
'af_trace_positions[6]' => { },
'af_trace_positions[7]' => { },
'af_trace_positions[8]' => { },
'af_trace_positions[9]' => { },
'af_trace_positions[10]' => { },
'af_trace_positions[11]' => { },
'af_trace_positions[12]' => { },
'af_trace_positions[13]' => { },
'af_trace_positions[14]' => { },
'af_trace_positions[15]' => { },
'af_trace_positions[16]' => { },
'af_trace_positions[17]' => { },
'af_trace_positions[18]' => { },
'af_trace_positions[19]' => { },
'af_trace_positions[20]' => { },
'af_trace_positions[21]' => { },
'af_trace_positions[22]' => { },
'af_trace_positions[23]' => { },
'af_trace_positions[24]' => { },
'af_trace_positions[25]' => { },
'af_trace_positions[26]' => { },
'af_trace_positions[27]' => { },
'af_trace_positions[28]' => { },
'af_trace_positions[29]' => { },
'af_trace_positions[30]' => { },
'af_trace_positions[31]' => { },
'af_trace_positions[32]' => { },
'af_trace_positions[33]' => { },
'af_trace_positions[34]' => { },
'af_trace_positions[35]' => { },
'af_trace_positions[36]' => { },
'af_trace_positions[37]' => { },
'af_trace_positions[38]' => { },
'af_trace_positions[39]' => { },
'af_trace_positions[40]' => { },
'af_trace_positions[41]' => { },
'af_trace_positions[42]' => { },
'af_trace_positions[43]' => { },
'af_trace_positions[44]' => { },
'af_trace_positions[45]' => { },
'af_trace_positions[46]' => { },
'af_trace_positions[47]' => { },
'af_trace_positions[48]' => { },
'af_trace_positions[49]' => { },
'af_trace_stats[0]' => { },
'af_trace_stats[1]' => { },
'af_trace_stats[2]' => { },
'af_trace_stats[3]' => { },
'af_trace_stats[4]' => { },
'af_trace_stats[5]' => { },
'af_trace_stats[6]' => { },
'af_trace_stats[7]' => { },
'af_trace_stats[8]' => { },
'af_trace_stats[9]' => { },
'af_trace_stats[10]' => { },
'af_trace_stats[11]' => { },
'af_trace_stats[12]' => { },
'af_trace_stats[13]' => { },
'af_trace_stats[14]' => { },
'af_trace_stats[15]' => { },
'af_trace_stats[16]' => { },
'af_trace_stats[17]' => { },
'af_trace_stats[18]' => { },
'af_trace_stats[19]' => { },
'af_trace_stats[20]' => { },
'af_trace_stats[21]' => { },
'af_trace_stats[22]' => { },
'af_trace_stats[23]' => { },
'af_trace_stats[24]' => { },
'af_trace_stats[25]' => { },
'af_trace_stats[26]' => { },
'af_trace_stats[27]' => { },
'af_trace_stats[28]' => { },
'af_trace_stats[29]' => { },
'af_trace_stats[30]' => { },
'af_trace_stats[31]' => { },
'af_trace_stats[32]' => { },
'af_trace_stats[33]' => { },
'af_trace_stats[34]' => { },
'af_trace_stats[35]' => { },
'af_trace_stats[36]' => { },
'af_trace_stats[37]' => { },
'af_trace_stats[38]' => { },
'af_trace_stats[39]' => { },
'af_trace_stats[40]' => { },
'af_trace_stats[41]' => { },
'af_trace_stats[42]' => { },
'af_trace_stats[43]' => { },
'af_trace_stats[44]' => { },
'af_trace_stats[45]' => { },
'af_trace_stats[46]' => { },
'af_trace_stats[47]' => { },
'af_trace_stats[48]' => { },
'af_trace_stats[49]' => { },
'af_focus_time' => { },
'awb_enable' => { },
'awb_algorithm' => { },
'awb_aggressiveness' => { },
'awb_red_gain_ref1' => { },
'awb_blue_gain_ref1' => { },
'awb_red_gain_adj_ref1' => { },
'awb_blue_gain_adj_ref1' => { },
'awb_red_gain_ref2' => { },
'awb_blue_gain_ref2' => { },
'awb_red_gain_adj_ref2' => { },
'awb_blue_gain_adj_ref2' => { },
'awb_red_gain_ref3' => { },
'awb_blue_gain_ref3' => { },
'awb_red_gain_adj_ref3' => { },
'awb_blue_gain_adj_ref3' => { },
'awb_red_gain_ref4' => { },
'awb_blue_gain_ref4' => { },
'awb_red_gain_adj_ref4' => { },
'awb_blue_gain_adj_ref4' => { },
'awb_red_gain_ref5' => { },
'awb_blue_gain_ref5' => { },
'awb_red_gain_adj_ref5' => { },
'awb_blue_gain_adj_ref5' => { },
'awb_red_gain_ref6' => { },
'awb_blue_gain_ref6' => { },
'awb_red_gain_adj_ref6' => { },
'awb_blue_gain_adj_ref6' => { },
'awb_red_gain_ref7' => { },
'awb_blue_gain_ref7' => { },
'awb_red_gain_adj_ref7' => { },
'awb_blue_gain_adj_ref7' => { },
'awb_red_gain_ref8' => { },
'awb_blue_gain_ref8' => { },
'awb_red_gain_adj_ref8' => { },
'awb_blue_gain_adj_ref8' => { },
'awb_lo_vfe_max_y' => { },
'awb_lo_vfe_min_y' => { },
'awb_lo_vfe_m1' => { },
'awb_lo_vfe_m2' => { },
'awb_lo_vfe_m3' => { },
'awb_lo_vfe_m4' => { },
'awb_lo_vfe_c1' => { },
'awb_lo_vfe_c2' => { },
'awb_lo_vfe_c3' => { },
'awb_lo_vfe_c4' => { },
'awb_norm_vfe_max_y' => { },
'awb_norm_vfe_min_y' => { },
'awb_norm_vfe_m1' => { },
'awb_norm_vfe_m2' => { },
'awb_norm_vfe_m3' => { },
'awb_norm_vfe_m4' => { },
'awb_norm_vfe_c1' => { },
'awb_norm_vfe_c2' => { },
'awb_norm_vfe_c3' => { },
'awb_norm_vfe_c4' => { },
'awb_oudor_vfe_max_y' => { },
'awb_oudor_vfe_min_y' => { },
'awb_oudor_vfe_m1' => { },
'awb_oudor_vfe_m2' => { },
'awb_oudor_vfe_m3' => { },
'awb_oudor_vfe_m4' => { },
'awb_oudor_vfe_c1' => { },
'awb_oudor_vfe_c2' => { },
'awb_oudor_vfe_c3' => { },
'awb_oudor_vfe_c4' => { },
'awb_cc_bias' => { },
'awb_min_r_gain' => { },
'awb_min_g_gain' => { },
'awb_min_b_gain' => { },
'awb_max_r_gain' => { },
'awb_max_g_gain' => { },
'awb_max_b_gain' => { },
'awb_outdoor_sample_influence' => { },
'awb_indoor_sample_influence' => { },
'awb_low_lig_col_cor_ena' => { },
'awb_agw_grid_dist_2_thresh' => { },
'awb_ave_rg_ratio' => { },
'awb_ave_bg_ratio' => { },
'awb_compact_cluster_R2' => { },
'outlier_distance' => { },
'awb_green_offset_rg' => { },
'awb_green_offset_bg' => { },
'awb_prev_wb_rgain' => { },
'awb_prev_wb_ggain' => { },
'awb_prev_wb_bgain' => { },
'awb_snapshot_r_gain' => { },
'awb_snapshot_b_gain' => { },
'rolloff_enable' => { },
'r2_tl84_cx' => { },
'r2_tl84_cy' => { },
'r2_tl84_width' => { },
'r2_tl84_height' => { },
'r2_tl84_intervals' => { },
'r2_tl84_tbl[0]' => { },
'r2_tl84_tbl[1]' => { },
'r2_tl84_tbl[2]' => { },
'r2_tl84_tbl[3]' => { },
'r2_tl84_tbl[4]' => { },
'r2_tl84_tbl[5]' => { },
'r2_tl84_tbl[6]' => { },
'r2_tl84_tbl[7]' => { },
'r2_tl84_tbl[8]' => { },
'r2_tl84_tbl[9]' => { },
'r2_tl84_tbl[10]' => { },
'r2_tl84_tbl[11]' => { },
'r2_tl84_tbl[12]' => { },
'r2_tl84_tbl[13]' => { },
'r2_tl84_tbl[14]' => { },
'r2_tl84_tbl[15]' => { },
'r2_tl84_tbl[16]' => { },
'r2_tl84_tbl[17]' => { },
'r2_tl84_tbl[18]' => { },
'r2_tl84_tbl[19]' => { },
'r2_tl84_tbl[20]' => { },
'r2_tl84_tbl[21]' => { },
'r2_tl84_tbl[22]' => { },
'r2_tl84_tbl[23]' => { },
'r2_tl84_tbl[24]' => { },
'r2_tl84_tbl[25]' => { },
'r2_tl84_tbl[26]' => { },
'r2_tl84_tbl[27]' => { },
'r2_tl84_tbl[28]' => { },
'r2_tl84_tbl[29]' => { },
'r2_tl84_tbl[30]' => { },
'r2_tl84_tbl[31]' => { },
'r2_tl84_red_ctbl[0]' => { },
'r2_tl84_red_ctbl[1]' => { },
'r2_tl84_red_ctbl[2]' => { },
'r2_tl84_red_ctbl[3]' => { },
'r2_tl84_red_ctbl[4]' => { },
'r2_tl84_red_ctbl[5]' => { },
'r2_tl84_red_ctbl[6]' => { },
'r2_tl84_red_ctbl[7]' => { },
'r2_tl84_red_ctbl[8]' => { },
'r2_tl84_red_ctbl[9]' => { },
'r2_tl84_red_ctbl[10]' => { },
'r2_tl84_red_ctbl[11]' => { },
'r2_tl84_red_ctbl[12]' => { },
'r2_tl84_red_ctbl[13]' => { },
'r2_tl84_red_ctbl[14]' => { },
'r2_tl84_red_ctbl[15]' => { },
'r2_tl84_red_ctbl[16]' => { },
'r2_tl84_red_ctbl[17]' => { },
'r2_tl84_red_ctbl[18]' => { },
'r2_tl84_red_ctbl[19]' => { },
'r2_tl84_red_ctbl[20]' => { },
'r2_tl84_red_ctbl[21]' => { },
'r2_tl84_red_ctbl[22]' => { },
'r2_tl84_red_ctbl[23]' => { },
'r2_tl84_red_ctbl[24]' => { },
'r2_tl84_red_ctbl[25]' => { },
'r2_tl84_red_ctbl[26]' => { },
'r2_tl84_red_ctbl[27]' => { },
'r2_tl84_red_ctbl[28]' => { },
'r2_tl84_red_ctbl[29]' => { },
'r2_tl84_red_ctbl[30]' => { },
'r2_tl84_red_ctbl[31]' => { },
'r2_tl84_green_ctbl[0]' => { },
'r2_tl84_green_ctbl[1]' => { },
'r2_tl84_green_ctbl[2]' => { },
'r2_tl84_green_ctbl[3]' => { },
'r2_tl84_green_ctbl[4]' => { },
'r2_tl84_green_ctbl[5]' => { },
'r2_tl84_green_ctbl[6]' => { },
'r2_tl84_green_ctbl[7]' => { },
'r2_tl84_green_ctbl[8]' => { },
'r2_tl84_green_ctbl[9]' => { },
'r2_tl84_green_ctbl[10]' => { },
'r2_tl84_green_ctbl[11]' => { },
'r2_tl84_green_ctbl[12]' => { },
'r2_tl84_green_ctbl[13]' => { },
'r2_tl84_green_ctbl[14]' => { },
'r2_tl84_green_ctbl[15]' => { },
'r2_tl84_green_ctbl[16]' => { },
'r2_tl84_green_ctbl[17]' => { },
'r2_tl84_green_ctbl[18]' => { },
'r2_tl84_green_ctbl[19]' => { },
'r2_tl84_green_ctbl[20]' => { },
'r2_tl84_green_ctbl[21]' => { },
'r2_tl84_green_ctbl[22]' => { },
'r2_tl84_green_ctbl[23]' => { },
'r2_tl84_green_ctbl[24]' => { },
'r2_tl84_green_ctbl[25]' => { },
'r2_tl84_green_ctbl[26]' => { },
'r2_tl84_green_ctbl[27]' => { },
'r2_tl84_green_ctbl[28]' => { },
'r2_tl84_green_ctbl[29]' => { },
'r2_tl84_green_ctbl[30]' => { },
'r2_tl84_green_ctbl[31]' => { },
'r2_tl84_blue_ctbl[0]' => { },
'r2_tl84_blue_ctbl[1]' => { },
'r2_tl84_blue_ctbl[2]' => { },
'r2_tl84_blue_ctbl[3]' => { },
'r2_tl84_blue_ctbl[4]' => { },
'r2_tl84_blue_ctbl[5]' => { },
'r2_tl84_blue_ctbl[6]' => { },
'r2_tl84_blue_ctbl[7]' => { },
'r2_tl84_blue_ctbl[8]' => { },
'r2_tl84_blue_ctbl[9]' => { },
'r2_tl84_blue_ctbl[10]' => { },
'r2_tl84_blue_ctbl[11]' => { },
'r2_tl84_blue_ctbl[12]' => { },
'r2_tl84_blue_ctbl[13]' => { },
'r2_tl84_blue_ctbl[14]' => { },
'r2_tl84_blue_ctbl[15]' => { },
'r2_tl84_blue_ctbl[16]' => { },
'r2_tl84_blue_ctbl[17]' => { },
'r2_tl84_blue_ctbl[18]' => { },
'r2_tl84_blue_ctbl[19]' => { },
'r2_tl84_blue_ctbl[20]' => { },
'r2_tl84_blue_ctbl[21]' => { },
'r2_tl84_blue_ctbl[22]' => { },
'r2_tl84_blue_ctbl[23]' => { },
'r2_tl84_blue_ctbl[24]' => { },
'r2_tl84_blue_ctbl[25]' => { },
'r2_tl84_blue_ctbl[26]' => { },
'r2_tl84_blue_ctbl[27]' => { },
'r2_tl84_blue_ctbl[28]' => { },
'r2_tl84_blue_ctbl[29]' => { },
'r2_tl84_blue_ctbl[30]' => { },
'r2_tl84_blue_ctbl[31]' => { },
'r2_tl84_red_stbl[0]' => { },
'r2_tl84_red_stbl[1]' => { },
'r2_tl84_red_stbl[2]' => { },
'r2_tl84_red_stbl[3]' => { },
'r2_tl84_red_stbl[4]' => { },
'r2_tl84_red_stbl[5]' => { },
'r2_tl84_red_stbl[6]' => { },
'r2_tl84_red_stbl[7]' => { },
'r2_tl84_red_stbl[8]' => { },
'r2_tl84_red_stbl[9]' => { },
'r2_tl84_red_stbl[10]' => { },
'r2_tl84_red_stbl[11]' => { },
'r2_tl84_red_stbl[12]' => { },
'r2_tl84_red_stbl[13]' => { },
'r2_tl84_red_stbl[14]' => { },
'r2_tl84_red_stbl[15]' => { },
'r2_tl84_red_stbl[16]' => { },
'r2_tl84_red_stbl[17]' => { },
'r2_tl84_red_stbl[18]' => { },
'r2_tl84_red_stbl[19]' => { },
'r2_tl84_red_stbl[20]' => { },
'r2_tl84_red_stbl[21]' => { },
'r2_tl84_red_stbl[22]' => { },
'r2_tl84_red_stbl[23]' => { },
'r2_tl84_red_stbl[24]' => { },
'r2_tl84_red_stbl[25]' => { },
'r2_tl84_red_stbl[26]' => { },
'r2_tl84_red_stbl[27]' => { },
'r2_tl84_red_stbl[28]' => { },
'r2_tl84_red_stbl[29]' => { },
'r2_tl84_red_stbl[30]' => { },
'r2_tl84_red_stbl[31]' => { },
'r2_tl84_blue_stbl[0]' => { },
'r2_tl84_blue_stbl[1]' => { },
'r2_tl84_blue_stbl[2]' => { },
'r2_tl84_blue_stbl[3]' => { },
'r2_tl84_blue_stbl[4]' => { },
'r2_tl84_blue_stbl[5]' => { },
'r2_tl84_blue_stbl[6]' => { },
'r2_tl84_blue_stbl[7]' => { },
'r2_tl84_blue_stbl[8]' => { },
'r2_tl84_blue_stbl[9]' => { },
'r2_tl84_blue_stbl[10]' => { },
'r2_tl84_blue_stbl[11]' => { },
'r2_tl84_blue_stbl[12]' => { },
'r2_tl84_blue_stbl[13]' => { },
'r2_tl84_blue_stbl[14]' => { },
'r2_tl84_blue_stbl[15]' => { },
'r2_tl84_blue_stbl[16]' => { },
'r2_tl84_blue_stbl[17]' => { },
'r2_tl84_blue_stbl[18]' => { },
'r2_tl84_blue_stbl[19]' => { },
'r2_tl84_blue_stbl[20]' => { },
'r2_tl84_blue_stbl[21]' => { },
'r2_tl84_blue_stbl[22]' => { },
'r2_tl84_blue_stbl[23]' => { },
'r2_tl84_blue_stbl[24]' => { },
'r2_tl84_blue_stbl[25]' => { },
'r2_tl84_blue_stbl[26]' => { },
'r2_tl84_blue_stbl[27]' => { },
'r2_tl84_blue_stbl[28]' => { },
'r2_tl84_blue_stbl[29]' => { },
'r2_tl84_blue_stbl[30]' => { },
'r2_tl84_blue_stbl[31]' => { },
'r2_tl84_green_stbl[0]' => { },
'r2_tl84_green_stbl[1]' => { },
'r2_tl84_green_stbl[2]' => { },
'r2_tl84_green_stbl[3]' => { },
'r2_tl84_green_stbl[4]' => { },
'r2_tl84_green_stbl[5]' => { },
'r2_tl84_green_stbl[6]' => { },
'r2_tl84_green_stbl[7]' => { },
'r2_tl84_green_stbl[8]' => { },
'r2_tl84_green_stbl[9]' => { },
'r2_tl84_green_stbl[10]' => { },
'r2_tl84_green_stbl[11]' => { },
'r2_tl84_green_stbl[12]' => { },
'r2_tl84_green_stbl[13]' => { },
'r2_tl84_green_stbl[14]' => { },
'r2_tl84_green_stbl[15]' => { },
'r2_tl84_green_stbl[16]' => { },
'r2_tl84_green_stbl[17]' => { },
'r2_tl84_green_stbl[18]' => { },
'r2_tl84_green_stbl[19]' => { },
'r2_tl84_green_stbl[20]' => { },
'r2_tl84_green_stbl[21]' => { },
'r2_tl84_green_stbl[22]' => { },
'r2_tl84_green_stbl[23]' => { },
'r2_tl84_green_stbl[24]' => { },
'r2_tl84_green_stbl[25]' => { },
'r2_tl84_green_stbl[26]' => { },
'r2_tl84_green_stbl[27]' => { },
'r2_tl84_green_stbl[28]' => { },
'r2_tl84_green_stbl[29]' => { },
'r2_tl84_green_stbl[30]' => { },
'r2_tl84_green_stbl[31]' => { },
'r2_d65_cx' => { },
'r2_d65_cy' => { },
'r2_d65_width' => { },
'r2_d65_height' => { },
'r2_d65_intervals' => { },
'r2_d65_tbl[0]' => { },
'r2_d65_tbl[1]' => { },
'r2_d65_tbl[2]' => { },
'r2_d65_tbl[3]' => { },
'r2_d65_tbl[4]' => { },
'r2_d65_tbl[5]' => { },
'r2_d65_tbl[6]' => { },
'r2_d65_tbl[7]' => { },
'r2_d65_tbl[8]' => { },
'r2_d65_tbl[9]' => { },
'r2_d65_tbl[10]' => { },
'r2_d65_tbl[11]' => { },
'r2_d65_tbl[12]' => { },
'r2_d65_tbl[13]' => { },
'r2_d65_tbl[14]' => { },
'r2_d65_tbl[15]' => { },
'r2_d65_tbl[16]' => { },
'r2_d65_tbl[17]' => { },
'r2_d65_tbl[18]' => { },
'r2_d65_tbl[19]' => { },
'r2_d65_tbl[20]' => { },
'r2_d65_tbl[21]' => { },
'r2_d65_tbl[22]' => { },
'r2_d65_tbl[23]' => { },
'r2_d65_tbl[24]' => { },
'r2_d65_tbl[25]' => { },
'r2_d65_tbl[26]' => { },
'r2_d65_tbl[27]' => { },
'r2_d65_tbl[28]' => { },
'r2_d65_tbl[29]' => { },
'r2_d65_tbl[30]' => { },
'r2_d65_tbl[31]' => { },
'r2_d65_red_ctbl[0]' => { },
'r2_d65_red_ctbl[1]' => { },
'r2_d65_red_ctbl[2]' => { },
'r2_d65_red_ctbl[3]' => { },
'r2_d65_red_ctbl[4]' => { },
'r2_d65_red_ctbl[5]' => { },
'r2_d65_red_ctbl[6]' => { },
'r2_d65_red_ctbl[7]' => { },
'r2_d65_red_ctbl[8]' => { },
'r2_d65_red_ctbl[9]' => { },
'r2_d65_red_ctbl[10]' => { },
'r2_d65_red_ctbl[11]' => { },
'r2_d65_red_ctbl[12]' => { },
'r2_d65_red_ctbl[13]' => { },
'r2_d65_red_ctbl[14]' => { },
'r2_d65_red_ctbl[15]' => { },
'r2_d65_red_ctbl[16]' => { },
'r2_d65_red_ctbl[17]' => { },
'r2_d65_red_ctbl[18]' => { },
'r2_d65_red_ctbl[19]' => { },
'r2_d65_red_ctbl[20]' => { },
'r2_d65_red_ctbl[21]' => { },
'r2_d65_red_ctbl[22]' => { },
'r2_d65_red_ctbl[23]' => { },
'r2_d65_red_ctbl[24]' => { },
'r2_d65_red_ctbl[25]' => { },
'r2_d65_red_ctbl[26]' => { },
'r2_d65_red_ctbl[27]' => { },
'r2_d65_red_ctbl[28]' => { },
'r2_d65_red_ctbl[29]' => { },
'r2_d65_red_ctbl[30]' => { },
'r2_d65_red_ctbl[31]' => { },
'r2_d65_green_ctbl[0]' => { },
'r2_d65_green_ctbl[1]' => { },
'r2_d65_green_ctbl[2]' => { },
'r2_d65_green_ctbl[3]' => { },
'r2_d65_green_ctbl[4]' => { },
'r2_d65_green_ctbl[5]' => { },
'r2_d65_green_ctbl[6]' => { },
'r2_d65_green_ctbl[7]' => { },
'r2_d65_green_ctbl[8]' => { },
'r2_d65_green_ctbl[9]' => { },
'r2_d65_green_ctbl[10]' => { },
'r2_d65_green_ctbl[11]' => { },
'r2_d65_green_ctbl[12]' => { },
'r2_d65_green_ctbl[13]' => { },
'r2_d65_green_ctbl[14]' => { },
'r2_d65_green_ctbl[15]' => { },
'r2_d65_green_ctbl[16]' => { },
'r2_d65_green_ctbl[17]' => { },
'r2_d65_green_ctbl[18]' => { },
'r2_d65_green_ctbl[19]' => { },
'r2_d65_green_ctbl[20]' => { },
'r2_d65_green_ctbl[21]' => { },
'r2_d65_green_ctbl[22]' => { },
'r2_d65_green_ctbl[23]' => { },
'r2_d65_green_ctbl[24]' => { },
'r2_d65_green_ctbl[25]' => { },
'r2_d65_green_ctbl[26]' => { },
'r2_d65_green_ctbl[27]' => { },
'r2_d65_green_ctbl[28]' => { },
'r2_d65_green_ctbl[29]' => { },
'r2_d65_green_ctbl[30]' => { },
'r2_d65_green_ctbl[31]' => { },
'r2_d65_blue_ctbl[0]' => { },
'r2_d65_blue_ctbl[1]' => { },
'r2_d65_blue_ctbl[2]' => { },
'r2_d65_blue_ctbl[3]' => { },
'r2_d65_blue_ctbl[4]' => { },
'r2_d65_blue_ctbl[5]' => { },
'r2_d65_blue_ctbl[6]' => { },
'r2_d65_blue_ctbl[7]' => { },
'r2_d65_blue_ctbl[8]' => { },
'r2_d65_blue_ctbl[9]' => { },
'r2_d65_blue_ctbl[10]' => { },
'r2_d65_blue_ctbl[11]' => { },
'r2_d65_blue_ctbl[12]' => { },
'r2_d65_blue_ctbl[13]' => { },
'r2_d65_blue_ctbl[14]' => { },
'r2_d65_blue_ctbl[15]' => { },
'r2_d65_blue_ctbl[16]' => { },
'r2_d65_blue_ctbl[17]' => { },
'r2_d65_blue_ctbl[18]' => { },
'r2_d65_blue_ctbl[19]' => { },
'r2_d65_blue_ctbl[20]' => { },
'r2_d65_blue_ctbl[21]' => { },
'r2_d65_blue_ctbl[22]' => { },
'r2_d65_blue_ctbl[23]' => { },
'r2_d65_blue_ctbl[24]' => { },
'r2_d65_blue_ctbl[25]' => { },
'r2_d65_blue_ctbl[26]' => { },
'r2_d65_blue_ctbl[27]' => { },
'r2_d65_blue_ctbl[28]' => { },
'r2_d65_blue_ctbl[29]' => { },
'r2_d65_blue_ctbl[30]' => { },
'r2_d65_blue_ctbl[31]' => { },
'r2_d65_red_stbl[0]' => { },
'r2_d65_red_stbl[1]' => { },
'r2_d65_red_stbl[2]' => { },
'r2_d65_red_stbl[3]' => { },
'r2_d65_red_stbl[4]' => { },
'r2_d65_red_stbl[5]' => { },
'r2_d65_red_stbl[6]' => { },
'r2_d65_red_stbl[7]' => { },
'r2_d65_red_stbl[8]' => { },
'r2_d65_red_stbl[9]' => { },
'r2_d65_red_stbl[10]' => { },
'r2_d65_red_stbl[11]' => { },
'r2_d65_red_stbl[12]' => { },
'r2_d65_red_stbl[13]' => { },
'r2_d65_red_stbl[14]' => { },
'r2_d65_red_stbl[15]' => { },
'r2_d65_red_stbl[16]' => { },
'r2_d65_red_stbl[17]' => { },
'r2_d65_red_stbl[18]' => { },
'r2_d65_red_stbl[19]' => { },
'r2_d65_red_stbl[20]' => { },
'r2_d65_red_stbl[21]' => { },
'r2_d65_red_stbl[22]' => { },
'r2_d65_red_stbl[23]' => { },
'r2_d65_red_stbl[24]' => { },
'r2_d65_red_stbl[25]' => { },
'r2_d65_red_stbl[26]' => { },
'r2_d65_red_stbl[27]' => { },
'r2_d65_red_stbl[28]' => { },
'r2_d65_red_stbl[29]' => { },
'r2_d65_red_stbl[30]' => { },
'r2_d65_red_stbl[31]' => { },
'r2_d65_blue_stbl[0]' => { },
'r2_d65_blue_stbl[1]' => { },
'r2_d65_blue_stbl[2]' => { },
'r2_d65_blue_stbl[3]' => { },
'r2_d65_blue_stbl[4]' => { },
'r2_d65_blue_stbl[5]' => { },
'r2_d65_blue_stbl[6]' => { },
'r2_d65_blue_stbl[7]' => { },
'r2_d65_blue_stbl[8]' => { },
'r2_d65_blue_stbl[9]' => { },
'r2_d65_blue_stbl[10]' => { },
'r2_d65_blue_stbl[11]' => { },
'r2_d65_blue_stbl[12]' => { },
'r2_d65_blue_stbl[13]' => { },
'r2_d65_blue_stbl[14]' => { },
'r2_d65_blue_stbl[15]' => { },
'r2_d65_blue_stbl[16]' => { },
'r2_d65_blue_stbl[17]' => { },
'r2_d65_blue_stbl[18]' => { },
'r2_d65_blue_stbl[19]' => { },
'r2_d65_blue_stbl[20]' => { },
'r2_d65_blue_stbl[21]' => { },
'r2_d65_blue_stbl[22]' => { },
'r2_d65_blue_stbl[23]' => { },
'r2_d65_blue_stbl[24]' => { },
'r2_d65_blue_stbl[25]' => { },
'r2_d65_blue_stbl[26]' => { },
'r2_d65_blue_stbl[27]' => { },
'r2_d65_blue_stbl[28]' => { },
'r2_d65_blue_stbl[29]' => { },
'r2_d65_blue_stbl[30]' => { },
'r2_d65_blue_stbl[31]' => { },
'r2_d65_green_stbl[0]' => { },
'r2_d65_green_stbl[1]' => { },
'r2_d65_green_stbl[2]' => { },
'r2_d65_green_stbl[3]' => { },
'r2_d65_green_stbl[4]' => { },
'r2_d65_green_stbl[5]' => { },
'r2_d65_green_stbl[6]' => { },
'r2_d65_green_stbl[7]' => { },
'r2_d65_green_stbl[8]' => { },
'r2_d65_green_stbl[9]' => { },
'r2_d65_green_stbl[10]' => { },
'r2_d65_green_stbl[11]' => { },
'r2_d65_green_stbl[12]' => { },
'r2_d65_green_stbl[13]' => { },
'r2_d65_green_stbl[14]' => { },
'r2_d65_green_stbl[15]' => { },
'r2_d65_green_stbl[16]' => { },
'r2_d65_green_stbl[17]' => { },
'r2_d65_green_stbl[18]' => { },
'r2_d65_green_stbl[19]' => { },
'r2_d65_green_stbl[20]' => { },
'r2_d65_green_stbl[21]' => { },
'r2_d65_green_stbl[22]' => { },
'r2_d65_green_stbl[23]' => { },
'r2_d65_green_stbl[24]' => { },
'r2_d65_green_stbl[25]' => { },
'r2_d65_green_stbl[26]' => { },
'r2_d65_green_stbl[27]' => { },
'r2_d65_green_stbl[28]' => { },
'r2_d65_green_stbl[29]' => { },
'r2_d65_green_stbl[30]' => { },
'r2_d65_green_stbl[31]' => { },
'r2_a_cx' => { },
'r2_a_cy' => { },
'r2_a_width' => { },
'r2_a_height' => { },
'r2_a_intervals' => { },
'r2_a_tbl[0]' => { },
'r2_a_tbl[1]' => { },
'r2_a_tbl[2]' => { },
'r2_a_tbl[3]' => { },
'r2_a_tbl[4]' => { },
'r2_a_tbl[5]' => { },
'r2_a_tbl[6]' => { },
'r2_a_tbl[7]' => { },
'r2_a_tbl[8]' => { },
'r2_a_tbl[9]' => { },
'r2_a_tbl[10]' => { },
'r2_a_tbl[11]' => { },
'r2_a_tbl[12]' => { },
'r2_a_tbl[13]' => { },
'r2_a_tbl[14]' => { },
'r2_a_tbl[15]' => { },
'r2_a_tbl[16]' => { },
'r2_a_tbl[17]' => { },
'r2_a_tbl[18]' => { },
'r2_a_tbl[19]' => { },
'r2_a_tbl[20]' => { },
'r2_a_tbl[21]' => { },
'r2_a_tbl[22]' => { },
'r2_a_tbl[23]' => { },
'r2_a_tbl[24]' => { },
'r2_a_tbl[25]' => { },
'r2_a_tbl[26]' => { },
'r2_a_tbl[27]' => { },
'r2_a_tbl[28]' => { },
'r2_a_tbl[29]' => { },
'r2_a_tbl[30]' => { },
'r2_a_tbl[31]' => { },
'r2_a_red_ctbl[0]' => { },
'r2_a_red_ctbl[1]' => { },
'r2_a_red_ctbl[2]' => { },
'r2_a_red_ctbl[3]' => { },
'r2_a_red_ctbl[4]' => { },
'r2_a_red_ctbl[5]' => { },
'r2_a_red_ctbl[6]' => { },
'r2_a_red_ctbl[7]' => { },
'r2_a_red_ctbl[8]' => { },
'r2_a_red_ctbl[9]' => { },
'r2_a_red_ctbl[10]' => { },
'r2_a_red_ctbl[11]' => { },
'r2_a_red_ctbl[12]' => { },
'r2_a_red_ctbl[13]' => { },
'r2_a_red_ctbl[14]' => { },
'r2_a_red_ctbl[15]' => { },
'r2_a_red_ctbl[16]' => { },
'r2_a_red_ctbl[17]' => { },
'r2_a_red_ctbl[18]' => { },
'r2_a_red_ctbl[19]' => { },
'r2_a_red_ctbl[20]' => { },
'r2_a_red_ctbl[21]' => { },
'r2_a_red_ctbl[22]' => { },
'r2_a_red_ctbl[23]' => { },
'r2_a_red_ctbl[24]' => { },
'r2_a_red_ctbl[25]' => { },
'r2_a_red_ctbl[26]' => { },
'r2_a_red_ctbl[27]' => { },
'r2_a_red_ctbl[28]' => { },
'r2_a_red_ctbl[29]' => { },
'r2_a_red_ctbl[30]' => { },
'r2_a_red_ctbl[31]' => { },
'r2_a_green_ctbl[0]' => { },
'r2_a_green_ctbl[1]' => { },
'r2_a_green_ctbl[2]' => { },
'r2_a_green_ctbl[3]' => { },
'r2_a_green_ctbl[4]' => { },
'r2_a_green_ctbl[5]' => { },
'r2_a_green_ctbl[6]' => { },
'r2_a_green_ctbl[7]' => { },
'r2_a_green_ctbl[8]' => { },
'r2_a_green_ctbl[9]' => { },
'r2_a_green_ctbl[10]' => { },
'r2_a_green_ctbl[11]' => { },
'r2_a_green_ctbl[12]' => { },
'r2_a_green_ctbl[13]' => { },
'r2_a_green_ctbl[14]' => { },
'r2_a_green_ctbl[15]' => { },
'r2_a_green_ctbl[16]' => { },
'r2_a_green_ctbl[17]' => { },
'r2_a_green_ctbl[18]' => { },
'r2_a_green_ctbl[19]' => { },
'r2_a_green_ctbl[20]' => { },
'r2_a_green_ctbl[21]' => { },
'r2_a_green_ctbl[22]' => { },
'r2_a_green_ctbl[23]' => { },
'r2_a_green_ctbl[24]' => { },
'r2_a_green_ctbl[25]' => { },
'r2_a_green_ctbl[26]' => { },
'r2_a_green_ctbl[27]' => { },
'r2_a_green_ctbl[28]' => { },
'r2_a_green_ctbl[29]' => { },
'r2_a_green_ctbl[30]' => { },
'r2_a_green_ctbl[31]' => { },
'r2_a_blue_ctbl[0]' => { },
'r2_a_blue_ctbl[1]' => { },
'r2_a_blue_ctbl[2]' => { },
'r2_a_blue_ctbl[3]' => { },
'r2_a_blue_ctbl[4]' => { },
'r2_a_blue_ctbl[5]' => { },
'r2_a_blue_ctbl[6]' => { },
'r2_a_blue_ctbl[7]' => { },
'r2_a_blue_ctbl[8]' => { },
'r2_a_blue_ctbl[9]' => { },
'r2_a_blue_ctbl[10]' => { },
'r2_a_blue_ctbl[11]' => { },
'r2_a_blue_ctbl[12]' => { },
'r2_a_blue_ctbl[13]' => { },
'r2_a_blue_ctbl[14]' => { },
'r2_a_blue_ctbl[15]' => { },
'r2_a_blue_ctbl[16]' => { },
'r2_a_blue_ctbl[17]' => { },
'r2_a_blue_ctbl[18]' => { },
'r2_a_blue_ctbl[19]' => { },
'r2_a_blue_ctbl[20]' => { },
'r2_a_blue_ctbl[21]' => { },
'r2_a_blue_ctbl[22]' => { },
'r2_a_blue_ctbl[23]' => { },
'r2_a_blue_ctbl[24]' => { },
'r2_a_blue_ctbl[25]' => { },
'r2_a_blue_ctbl[26]' => { },
'r2_a_blue_ctbl[27]' => { },
'r2_a_blue_ctbl[28]' => { },
'r2_a_blue_ctbl[29]' => { },
'r2_a_blue_ctbl[30]' => { },
'r2_a_blue_ctbl[31]' => { },
'r2_a_red_stbl[0]' => { },
'r2_a_red_stbl[1]' => { },
'r2_a_red_stbl[2]' => { },
'r2_a_red_stbl[3]' => { },
'r2_a_red_stbl[4]' => { },
'r2_a_red_stbl[5]' => { },
'r2_a_red_stbl[6]' => { },
'r2_a_red_stbl[7]' => { },
'r2_a_red_stbl[8]' => { },
'r2_a_red_stbl[9]' => { },
'r2_a_red_stbl[10]' => { },
'r2_a_red_stbl[11]' => { },
'r2_a_red_stbl[12]' => { },
'r2_a_red_stbl[13]' => { },
'r2_a_red_stbl[14]' => { },
'r2_a_red_stbl[15]' => { },
'r2_a_red_stbl[16]' => { },
'r2_a_red_stbl[17]' => { },
'r2_a_red_stbl[18]' => { },
'r2_a_red_stbl[19]' => { },
'r2_a_red_stbl[20]' => { },
'r2_a_red_stbl[21]' => { },
'r2_a_red_stbl[22]' => { },
'r2_a_red_stbl[23]' => { },
'r2_a_red_stbl[24]' => { },
'r2_a_red_stbl[25]' => { },
'r2_a_red_stbl[26]' => { },
'r2_a_red_stbl[27]' => { },
'r2_a_red_stbl[28]' => { },
'r2_a_red_stbl[29]' => { },
'r2_a_red_stbl[30]' => { },
'r2_a_red_stbl[31]' => { },
'r2_a_blue_stbl[0]' => { },
'r2_a_blue_stbl[1]' => { },
'r2_a_blue_stbl[2]' => { },
'r2_a_blue_stbl[3]' => { },
'r2_a_blue_stbl[4]' => { },
'r2_a_blue_stbl[5]' => { },
'r2_a_blue_stbl[6]' => { },
'r2_a_blue_stbl[7]' => { },
'r2_a_blue_stbl[8]' => { },
'r2_a_blue_stbl[9]' => { },
'r2_a_blue_stbl[10]' => { },
'r2_a_blue_stbl[11]' => { },
'r2_a_blue_stbl[12]' => { },
'r2_a_blue_stbl[13]' => { },
'r2_a_blue_stbl[14]' => { },
'r2_a_blue_stbl[15]' => { },
'r2_a_blue_stbl[16]' => { },
'r2_a_blue_stbl[17]' => { },
'r2_a_blue_stbl[18]' => { },
'r2_a_blue_stbl[19]' => { },
'r2_a_blue_stbl[20]' => { },
'r2_a_blue_stbl[21]' => { },
'r2_a_blue_stbl[22]' => { },
'r2_a_blue_stbl[23]' => { },
'r2_a_blue_stbl[24]' => { },
'r2_a_blue_stbl[25]' => { },
'r2_a_blue_stbl[26]' => { },
'r2_a_blue_stbl[27]' => { },
'r2_a_blue_stbl[28]' => { },
'r2_a_blue_stbl[29]' => { },
'r2_a_blue_stbl[30]' => { },
'r2_a_blue_stbl[31]' => { },
'r2_a_green_stbl[0]' => { },
'r2_a_green_stbl[1]' => { },
'r2_a_green_stbl[2]' => { },
'r2_a_green_stbl[3]' => { },
'r2_a_green_stbl[4]' => { },
'r2_a_green_stbl[5]' => { },
'r2_a_green_stbl[6]' => { },
'r2_a_green_stbl[7]' => { },
'r2_a_green_stbl[8]' => { },
'r2_a_green_stbl[9]' => { },
'r2_a_green_stbl[10]' => { },
'r2_a_green_stbl[11]' => { },
'r2_a_green_stbl[12]' => { },
'r2_a_green_stbl[13]' => { },
'r2_a_green_stbl[14]' => { },
'r2_a_green_stbl[15]' => { },
'r2_a_green_stbl[16]' => { },
'r2_a_green_stbl[17]' => { },
'r2_a_green_stbl[18]' => { },
'r2_a_green_stbl[19]' => { },
'r2_a_green_stbl[20]' => { },
'r2_a_green_stbl[21]' => { },
'r2_a_green_stbl[22]' => { },
'r2_a_green_stbl[23]' => { },
'r2_a_green_stbl[24]' => { },
'r2_a_green_stbl[25]' => { },
'r2_a_green_stbl[26]' => { },
'r2_a_green_stbl[27]' => { },
'r2_a_green_stbl[28]' => { },
'r2_a_green_stbl[29]' => { },
'r2_a_green_stbl[30]' => { },
'r2_a_green_stbl[31]' => { },
'def_cor_c0' => { },
'def_cor_c1' => { },
'def_cor_c2' => { },
'def_cor_c3' => { },
'def_cor_c4' => { },
'def_cor_c5' => { },
'def_cor_c6' => { },
'def_cor_c7' => { },
'def_cor_c8' => { },
'def_cor_k0' => { },
'def_cor_k1' => { },
'def_cor_k2' => { },
'yhi_ylo_cor_c0' => { },
'yhi_ylo_cor_c1' => { },
'yhi_ylo_cor_c2' => { },
'yhi_ylo_cor_c3' => { },
'yhi_ylo_cor_c4' => { },
'yhi_ylo_cor_c5' => { },
'yhi_ylo_cor_c6' => { },
'yhi_ylo_cor_c7' => { },
'yhi_ylo_cor_c8' => { },
'yhi_ylo_cor_k0' => { },
'yhi_ylo_cor_k1' => { },
'yhi_ylo_cor_k2' => { },
'def_conv_chrm_a_m' => { },
'def_conv_chrm_a_p' => { },
'def_conv_chrm_b_m' => { },
'def_conv_chrm_b_p' => { },
'def_conv_chrm_c_m' => { },
'def_conv_chrm_c_p' => { },
'def_conv_chrm_d_m' => { },
'def_conv_chrm_d_p' => { },
'def_conv_chrm_k_cb' => { },
'def_conv_chrm_k_cr' => { },
'def_conv_luma_v0' => { },
'def_conv_luma_v1' => { },
'def_conv_luma_v2' => { },
'def_conv_luma_k' => { },
'tl84_conv_chrm_a_m' => { },
'tl84_conv_chrm_a_p' => { },
'tl84_conv_chrm_b_m' => { },
'tl84_conv_chrm_b_p' => { },
'tl84_conv_chrm_c_m' => { },
'tl84_conv_chrm_c_p' => { },
'tl84_conv_chrm_d_m' => { },
'tl84_conv_chrm_d_p' => { },
'tl84_conv_chrm_k_cb' => { },
'tl84_conv_chrm_k_cr' => { },
'tl84_conv_luma_v0' => { },
'tl84_conv_luma_v1' => { },
'tl84_conv_luma_v2' => { },
'tl84_conv_luma_k' => { },
'incand_conv_chrm_a_m' => { },
'incand_conv_chrm_a_p' => { },
'incand_conv_chrm_b_m' => { },
'incand_conv_chrm_b_p' => { },
'incand_conv_chrm_c_m' => { },
'incand_conv_chrm_c_p' => { },
'incand_conv_chrm_d_m' => { },
'incand_conv_chrm_d_p' => { },
'incand_conv_chrm_k_cb' => { },
'incand_conv_chrm_k_cr' => { },
'incand_conv_luma_v0' => { },
'incand_conv_luma_v1' => { },
'incand_conv_luma_v2' => { },
'incand_conv_luma_k' => { },
'daylt_conv_chrm_a_m' => { },
'daylt_conv_chrm_a_p' => { },
'daylt_conv_chrm_b_m' => { },
'daylt_conv_chrm_b_p' => { },
'daylt_conv_chrm_c_m' => { },
'daylt_conv_chrm_c_p' => { },
'daylt_conv_chrm_d_m' => { },
'daylt_conv_chrm_d_p' => { },
'daylt_conv_chrm_k_cb' => { },
'daylt_conv_chrm_k_cr' => { },
'daylt_conv_luma_v0' => { },
'daylt_conv_luma_v1' => { },
'daylt_conv_luma_v2' => { },
'daylt_conv_luma_k' => { },
'yhi_ylo_conv_chrm_a_m' => { },
'yhi_ylo_conv_chrm_a_p' => { },
'yhi_ylo_conv_chrm_b_m' => { },
'yhi_ylo_conv_chrm_b_p' => { },
'yhi_ylo_conv_chrm_c_m' => { },
'yhi_ylo_conv_chrm_c_p' => { },
'yhi_ylo_conv_chrm_d_m' => { },
'yhi_ylo_conv_chrm_d_p' => { },
'yhi_ylo_conv_chrm_k_cb' => { },
'yhi_ylo_conv_chrm_k_cr' => { },
'yhi_ylo_conv_luma_v0' => { },
'yhi_ylo_conv_luma_v1' => { },
'yhi_ylo_conv_luma_v2' => { },
'yhi_ylo_conv_luma_k' => { },
'gamma_enable' => { },
'def_luma_gamma_mode' => { },
'def_rgb_gamma_mode' => { },
'blck_lvl_even_cols' => { },
'blck_lvl_odd_cols' => { },
'defect_pix_min_thresh' => { },
'defect_pix_max_thresh' => { },
'defect_pix_cor_enable' => { },
'prview_resol' => { },
'snapshot_resol' => { },
'curr_resol' => { },
'sensor_fmt' => { },
'discard_frst_frm' => { },
'frm_skip_pttrn' => { },
'sensor_type' => { },
'max_video_fps' => { },
'video_fps' => { },
'max_prview_fps' => { },
'prview_fps' => { },
'nghtsht_fps' => { },
'sensr_ful_wdth' => { },
'sensr_ful_hght' => { },
'sensr_qtr_wdth' => { },
'sensr_qtr_hght' => { },
'nightshot_mode' => { },
'pclk_invert' => { },
'cam_mclk_hz' => { },
'chrom_supress' => { },
'chro_sup_luma_thres_1' => { },
'chro_sup_luma_thres_2' => { },
'chro_sup_luma_thres_3' => { },
'chro_sup_luma_thres_4' => { },
'chro_sup_chro_thres_1' => { },
'chro_sup_chro_thres_2' => { },
'la_detect' => { },
'la_enable' => { },
'HJR_enable' => { },
'HJR_max_num_frames' => { },
'HJR_one_to_two_offset' => { },
'HJR_n_reduction_flat' => { },
'HJR_n_reduction_texture' => { },
'HJR_texture_threshold' => { },
);
# generate tag names and descriptions
{
local $_;
my $table = \%Image::ExifTool::Qualcomm::Main;
MakeNameAndDesc($_, $$table{$_}) foreach TagTableKeys($table);
}
#------------------------------------------------------------------------------
# Generate tag Name and Description from a Qualcomm tag ID
# Inputs: 0) tag ID, 1) tagInfo ref
# Returns: true on success
sub MakeNameAndDesc($$)
{
local $_ = shift;
my $tagInfo = shift;
# capitalize various leading acronyms or just first letter...
s/^(asf|awb|aec|afr|af_|la_|r2_tl|tl)/\U$1/ or $_ = ucfirst;
s/_([a-z])/_\u$1/g; # capitalize first letter of each word
s/\[(\d+)\]$/sprintf("_%.2d",$1)/e; # use 2-digit subscripts (and remove brackets)
tr/-_a-zA-Z0-9//dc; # delete invalid characters
my $desc = $_;
# convert underlines to spaces in description
if ($desc =~ tr/_/ /) {
# remove unnecessary underlines from tag name...
s/_([A-Z][a-z])/$1/g;
s/([a-z0-9])_([A-Z])/$1$2/g;
s/([A-Za-z])_(\d)/$1$2/g;
}
return 0 unless length;
$$tagInfo{Name} = $_;
$$tagInfo{Description} = $desc;
return 1;
}
#------------------------------------------------------------------------------
# Process Qualcomm APP7 metadata (ref PH)
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: 1 on success
sub ProcessQualcomm($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
my $dataPos = $$dirInfo{DataPos};
my $pos = $$dirInfo{DirStart};
my $dirEnd = $pos + $$dirInfo{DirLen};
$et->VerboseDir('Qualcomm', undef, $$dirInfo{DirLen});
SetByteOrder('II');
while ($pos + 3 < $dirEnd) {
my $valLen = Get16u($dataPt, $pos);
my $tagLen = Get8u($dataPt, $pos + 2);
last if $pos + 8 + $tagLen + $valLen > $dirEnd;
my $tag = substr($$dataPt, $pos + 3, $tagLen);
$pos += 3 + $tagLen; # point to format byte
my $fmt = Get8u($dataPt, $pos);
# (not sure what these counts are for -- both are always 1 in my samples)
#my $cnt1 = Get16u($dataPt, $pos + 1);
#my $cnt2 = Get16u($dataPt, $pos + 3);
$pos += 5; # point to start of value data
my ($val, $format);
if ($fmt <= 7) {
$format = $qualcommFormat[$fmt];
$val = ReadValue($dataPt, $pos, $format, undef, $valLen);
} else {
$format = "format $fmt";
my $value = substr($$dataPt, $pos, $valLen);
$val = \$value;
}
unless (defined $$tagTablePtr{$tag} or $Image::ExifTool::specialTags{$tag}) {
my %tagInfo;
if (MakeNameAndDesc($tag, \%tagInfo)) {
$et->VPrint(0, $$et{INDENT}, "[adding Qualcomm:$tagInfo{Name}]\n");
AddTagToTable($tagTablePtr, $tag, \%tagInfo);
}
}
$et->HandleTag($tagTablePtr, $tag, $val,
DataPt => $dataPt,
DataPos => $dataPos,
Start => $pos,
Size => $valLen,
Format => $format,
);
$pos += $valLen; # point to start of next entry
}
return 1;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::Qualcomm - Read Qualcomm APP7 meta information
=head1 SYNOPSIS
This module is loaded automatically by Image::ExifTool when required.
=head1 DESCRIPTION
This module contains definitions required by Image::ExifTool to read
information from the APP7 Qualcomm segment in JPEG images.
=head1 AUTHOR
Copyright 2003-2020, Phil Harvey (philharvey66 at gmail.com)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 SEE ALSO
L<Image::ExifTool::TagNames/Qualcomm Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
| 33.064684 | 86 | 0.513559 |
ed59765a75754c06f936adb32f8c1f5d88bf0e7d | 3,341 | t | Perl | perl/t/lib/ftmp-tempfile.t | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | perl/t/lib/ftmp-tempfile.t | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | perl/t/lib/ftmp-tempfile.t | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | #!/usr/local/bin/perl -w
# Test for File::Temp - tempfile function
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Test; import Test;
plan(tests => 20);
}
use strict;
use File::Spec;
# Will need to check that all files were unlinked correctly
# Set up an END block here to do it
# Arrays containing list of dirs/files to test
my (@files, @dirs, @still_there);
# And a test for files that should still be around
# These are tidied up
END {
foreach (@still_there) {
ok( -f $_ );
ok( unlink( $_ ) );
ok( !(-f $_) );
}
}
# Loop over an array hoping that the files dont exist
END { foreach (@files) { ok( !(-e $_) )} }
# And a test for directories
END { foreach (@dirs) { ok( !(-d $_) )} }
# Need to make sure that the END blocks are setup before
# the ones that File::Temp configures since END blocks are evaluated
# in revers order and we need to check the files *after* File::Temp
# removes them
use File::Temp qw/ tempfile tempdir/;
# Now we start the tests properly
ok(1);
# Tempfile
# Open tempfile in some directory, unlink at end
my ($fh, $tempfile) = tempfile(
UNLINK => 1,
SUFFIX => '.txt',
);
ok( (-f $tempfile) );
# Should still be around after closing
ok( close( $fh ) );
ok( (-f $tempfile) );
# Check again at exit
push(@files, $tempfile);
# TEMPDIR test
# Create temp directory in current dir
my $template = 'tmpdirXXXXXX';
print "# Template: $template\n";
my $tempdir = tempdir( $template ,
DIR => File::Spec->curdir,
CLEANUP => 1,
);
print "# TEMPDIR: $tempdir\n";
ok( (-d $tempdir) );
push(@dirs, $tempdir);
# Create file in the temp dir
($fh, $tempfile) = tempfile(
DIR => $tempdir,
UNLINK => 1,
SUFFIX => '.dat',
);
print "# TEMPFILE: Created $tempfile\n";
ok( (-f $tempfile));
push(@files, $tempfile);
# Test tempfile
# ..and again
($fh, $tempfile) = tempfile(
DIR => $tempdir,
);
ok( (-f $tempfile ));
push(@files, $tempfile);
print "# TEMPFILE: Created $tempfile\n";
# and another (with template)
($fh, $tempfile) = tempfile( 'helloXXXXXXX',
DIR => $tempdir,
UNLINK => 1,
SUFFIX => '.dat',
);
print "# TEMPFILE: Created $tempfile\n";
ok( (-f $tempfile) );
push(@files, $tempfile);
# Create a temporary file that should stay around after
# it has been closed
($fh, $tempfile) = tempfile( 'permXXXXXXX', UNLINK => 0 );
print "# TEMPFILE: Created $tempfile\n";
ok( -f $tempfile );
ok( close( $fh ) );
push( @still_there, $tempfile); # check at END
# Would like to create a temp file and just retrieve the handle
# but the test is problematic since:
# - We dont know the filename so we cant check that it is tidied
# correctly
# - The unlink0 required on unix for tempfile creation will fail
# on NFS
# Try to do what we can.
# Tempfile croaks on error so we need an eval
$fh = eval { tempfile( 'ftmpXXXXX', DIR => File::Spec->tmpdir ) };
if ($fh) {
# print something to it to make sure something is there
ok( print $fh "Test\n" );
# Close it - can not check it is gone since we dont know the name
ok( close($fh) );
} else {
skip "Skip Failed probably due to NFS", 1;
skip "Skip Failed probably due to NFS", 1;
}
# Now END block will execute to test the removal of directories
print "# End of tests. Execute END blocks\n";
| 22.883562 | 68 | 0.631847 |
edae0c29d2792dfbec1d766c30c83d6d2ea0db02 | 3,848 | pm | Perl | perl/lib/IO/Compress/Zip/Constants.pm | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | 1,318 | 2019-07-11T10:34:39.000Z | 2022-03-29T15:05:19.000Z | perl/lib/IO/Compress/Zip/Constants.pm | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | 387 | 2019-09-05T16:33:09.000Z | 2022-03-31T10:43:39.000Z | perl/lib/IO/Compress/Zip/Constants.pm | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | 66 | 2019-11-11T15:33:12.000Z | 2022-03-01T07:55:55.000Z | package IO::Compress::Zip::Constants;
use strict ;
use warnings;
require Exporter;
our ($VERSION, @ISA, @EXPORT, %ZIP_CM_MIN_VERSIONS);
$VERSION = '2.093';
@ISA = qw(Exporter);
@EXPORT= qw(
ZIP_CM_STORE
ZIP_CM_DEFLATE
ZIP_CM_BZIP2
ZIP_CM_LZMA
ZIP_CM_PPMD
ZIP_LOCAL_HDR_SIG
ZIP_DATA_HDR_SIG
ZIP_CENTRAL_HDR_SIG
ZIP_END_CENTRAL_HDR_SIG
ZIP64_END_CENTRAL_REC_HDR_SIG
ZIP64_END_CENTRAL_LOC_HDR_SIG
ZIP64_ARCHIVE_EXTRA_SIG
ZIP64_DIGITAL_SIGNATURE_SIG
ZIP_GP_FLAG_ENCRYPTED_MASK
ZIP_GP_FLAG_STREAMING_MASK
ZIP_GP_FLAG_PATCHED_MASK
ZIP_GP_FLAG_STRONG_ENCRYPTED_MASK
ZIP_GP_FLAG_LZMA_EOS_PRESENT
ZIP_GP_FLAG_LANGUAGE_ENCODING
ZIP_EXTRA_ID_ZIP64
ZIP_EXTRA_ID_EXT_TIMESTAMP
ZIP_EXTRA_ID_INFO_ZIP_UNIX2
ZIP_EXTRA_ID_INFO_ZIP_UNIXN
ZIP_EXTRA_ID_INFO_ZIP_Upath
ZIP_EXTRA_ID_INFO_ZIP_Ucom
ZIP_EXTRA_ID_JAVA_EXE
ZIP_OS_CODE_UNIX
ZIP_OS_CODE_DEFAULT
ZIP_IFA_TEXT_MASK
%ZIP_CM_MIN_VERSIONS
ZIP64_MIN_VERSION
ZIP_A_RONLY
ZIP_A_HIDDEN
ZIP_A_SYSTEM
ZIP_A_LABEL
ZIP_A_DIR
ZIP_A_ARCHIVE
);
# Compression types supported
use constant ZIP_CM_STORE => 0 ;
use constant ZIP_CM_DEFLATE => 8 ;
use constant ZIP_CM_BZIP2 => 12 ;
use constant ZIP_CM_LZMA => 14 ; # Not Supported yet
use constant ZIP_CM_PPMD => 98 ; # Not Supported yet
# General Purpose Flag
use constant ZIP_GP_FLAG_ENCRYPTED_MASK => (1 << 0) ;
use constant ZIP_GP_FLAG_STREAMING_MASK => (1 << 3) ;
use constant ZIP_GP_FLAG_PATCHED_MASK => (1 << 5) ;
use constant ZIP_GP_FLAG_STRONG_ENCRYPTED_MASK => (1 << 6) ;
use constant ZIP_GP_FLAG_LZMA_EOS_PRESENT => (1 << 1) ;
use constant ZIP_GP_FLAG_LANGUAGE_ENCODING => (1 << 11) ;
# Internal File Attributes
use constant ZIP_IFA_TEXT_MASK => 1;
# Signatures for each of the headers
use constant ZIP_LOCAL_HDR_SIG => 0x04034b50;
use constant ZIP_DATA_HDR_SIG => 0x08074b50;
use constant packed_ZIP_DATA_HDR_SIG => pack "V", ZIP_DATA_HDR_SIG;
use constant ZIP_CENTRAL_HDR_SIG => 0x02014b50;
use constant ZIP_END_CENTRAL_HDR_SIG => 0x06054b50;
use constant ZIP64_END_CENTRAL_REC_HDR_SIG => 0x06064b50;
use constant ZIP64_END_CENTRAL_LOC_HDR_SIG => 0x07064b50;
use constant ZIP64_ARCHIVE_EXTRA_SIG => 0x08064b50;
use constant ZIP64_DIGITAL_SIGNATURE_SIG => 0x05054b50;
use constant ZIP_OS_CODE_UNIX => 3;
use constant ZIP_OS_CODE_DEFAULT => 3;
# Extra Field ID's
use constant ZIP_EXTRA_ID_ZIP64 => pack "v", 1;
use constant ZIP_EXTRA_ID_EXT_TIMESTAMP => "UT";
use constant ZIP_EXTRA_ID_INFO_ZIP_UNIX2 => "Ux";
use constant ZIP_EXTRA_ID_INFO_ZIP_UNIXN => "ux";
use constant ZIP_EXTRA_ID_INFO_ZIP_Upath => "up";
use constant ZIP_EXTRA_ID_INFO_ZIP_Ucom => "uc";
use constant ZIP_EXTRA_ID_JAVA_EXE => pack "v", 0xCAFE;
# DOS Attributes
use constant ZIP_A_RONLY => 0x01;
use constant ZIP_A_HIDDEN => 0x02;
use constant ZIP_A_SYSTEM => 0x04;
use constant ZIP_A_LABEL => 0x08;
use constant ZIP_A_DIR => 0x10;
use constant ZIP_A_ARCHIVE => 0x20;
use constant ZIP64_MIN_VERSION => 45;
%ZIP_CM_MIN_VERSIONS = (
ZIP_CM_STORE() => 20,
ZIP_CM_DEFLATE() => 20,
ZIP_CM_BZIP2() => 46,
ZIP_CM_LZMA() => 63,
ZIP_CM_PPMD() => 63,
);
1;
__END__
| 30.539683 | 77 | 0.635135 |
ed618c2c02c7cf51bf833e60c4128ba9199894d3 | 2,558 | pm | Perl | auto-lib/Paws/Chime/UpdatePhoneNumber.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 164 | 2015-01-08T14:58:53.000Z | 2022-02-20T19:16:24.000Z | auto-lib/Paws/Chime/UpdatePhoneNumber.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 348 | 2015-01-07T22:08:38.000Z | 2022-01-27T14:34:44.000Z | auto-lib/Paws/Chime/UpdatePhoneNumber.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
] | 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z |
package Paws::Chime::UpdatePhoneNumber;
use Moose;
has CallingName => (is => 'ro', isa => 'Str');
has PhoneNumberId => (is => 'ro', isa => 'Str', traits => ['ParamInURI'], uri_name => 'phoneNumberId', required => 1);
has ProductType => (is => 'ro', isa => 'Str');
use MooseX::ClassAttribute;
class_has _api_call => (isa => 'Str', is => 'ro', default => 'UpdatePhoneNumber');
class_has _api_uri => (isa => 'Str', is => 'ro', default => '/phone-numbers/{phoneNumberId}');
class_has _api_method => (isa => 'Str', is => 'ro', default => 'POST');
class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::Chime::UpdatePhoneNumberResponse');
1;
### main pod documentation begin ###
=head1 NAME
Paws::Chime::UpdatePhoneNumber - Arguments for method UpdatePhoneNumber on L<Paws::Chime>
=head1 DESCRIPTION
This class represents the parameters used for calling the method UpdatePhoneNumber on the
L<Amazon Chime|Paws::Chime> service. Use the attributes of this class
as arguments to method UpdatePhoneNumber.
You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to UpdatePhoneNumber.
=head1 SYNOPSIS
my $chime = Paws->service('Chime');
my $UpdatePhoneNumberResponse = $chime->UpdatePhoneNumber(
PhoneNumberId => 'MyString',
CallingName => 'MyCallingName', # OPTIONAL
ProductType => 'BusinessCalling', # OPTIONAL
);
# Results:
my $PhoneNumber = $UpdatePhoneNumberResponse->PhoneNumber;
# Returns a L<Paws::Chime::UpdatePhoneNumberResponse> object.
Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.
For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/chime/UpdatePhoneNumber>
=head1 ATTRIBUTES
=head2 CallingName => Str
The outbound calling name associated with the phone number.
=head2 B<REQUIRED> PhoneNumberId => Str
The phone number ID.
=head2 ProductType => Str
The product type.
Valid values are: C<"BusinessCalling">, C<"VoiceConnector">, C<"SipMediaApplicationDialIn">
=head1 SEE ALSO
This class forms part of L<Paws>, documenting arguments for method UpdatePhoneNumber in L<Paws::Chime>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 31.580247 | 249 | 0.711102 |
ed9f243494495d353c80b741275823a08a93c02d | 388 | pm | Perl | corpus/our.pm | briandfoy/PPI-App-ppi_version-BDFOY | 6a1e14f158bc91b87431f29c06eefbe257557a31 | [
"Artistic-2.0"
] | null | null | null | corpus/our.pm | briandfoy/PPI-App-ppi_version-BDFOY | 6a1e14f158bc91b87431f29c06eefbe257557a31 | [
"Artistic-2.0"
] | 1 | 2018-12-17T10:46:23.000Z | 2021-02-07T21:58:23.000Z | corpus/our.pm | briandfoy/ppi-app-ppi_version-bdfoy | f041e630efb490aacb32bfe989dd437eacd82f35 | [
"Artistic-2.0"
] | null | null | null | package Tie::Timely;
use strict;
use Carp qw(croak);
our $VERSION = '1.023';
sub TIESCALAR {
my $class = shift;
my $value = shift;
my $lifetime = shift;
my $self = bless [ undef, $lifetime, time ], $class;
$self->STORE( $value );
return $self;
}
sub FETCH { time - $_[0]->[2] > $_[0]->[1] ? () : $_[0]->[0] }
sub STORE { @{ $_[0] }[0,2] = ( $_[1], time ) }
1;
| 15.52 | 62 | 0.518041 |
ed46ec8d20f7df80adecefe5d5798b1fc4609514 | 12,080 | pm | Perl | lib/Test2/Tools/ClassicCompare.pm | j1n3l0/Test2-Suite | 4f3e172bcd0684a16843019f884c9587f5c59080 | [
"Artistic-1.0"
] | null | null | null | lib/Test2/Tools/ClassicCompare.pm | j1n3l0/Test2-Suite | 4f3e172bcd0684a16843019f884c9587f5c59080 | [
"Artistic-1.0"
] | null | null | null | lib/Test2/Tools/ClassicCompare.pm | j1n3l0/Test2-Suite | 4f3e172bcd0684a16843019f884c9587f5c59080 | [
"Artistic-1.0"
] | null | null | null | package Test2::Tools::ClassicCompare;
use strict;
use warnings;
our $VERSION = '0.000116';
our @EXPORT = qw/is is_deeply isnt like unlike cmp_ok/;
use base 'Exporter';
use Carp qw/carp/;
use Scalar::Util qw/reftype/;
use Test2::API qw/context/;
use Test2::Compare qw/compare strict_convert/;
use Test2::Util::Ref qw/rtype render_ref/;
use Test2::Util::Table qw/table/;
use Test2::Compare::Array();
use Test2::Compare::Bag();
use Test2::Compare::Custom();
use Test2::Compare::Event();
use Test2::Compare::Hash();
use Test2::Compare::Meta();
use Test2::Compare::Number();
use Test2::Compare::Object();
use Test2::Compare::OrderedSubset();
use Test2::Compare::Pattern();
use Test2::Compare::Ref();
use Test2::Compare::Regex();
use Test2::Compare::Scalar();
use Test2::Compare::Set();
use Test2::Compare::String();
use Test2::Compare::Undef();
use Test2::Compare::Wildcard();
sub is($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&is_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub isnt($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&isnt_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub is_convert {
my ($thing) = @_;
return Test2::Compare::Undef->new()
unless defined $thing;
return Test2::Compare::String->new(input => $thing);
}
sub isnt_convert {
my ($thing) = @_;
return Test2::Compare::Undef->new()
unless defined $thing;
my $str = Test2::Compare::String->new(input => $thing, negate => 1);
}
sub like($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my $delta = compare($got, $exp, \&like_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub unlike($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my $delta = compare($got, $exp, \&unlike_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub like_convert {
my ($thing) = @_;
return Test2::Compare::Pattern->new(
pattern => $thing,
stringify_got => 1,
);
}
sub unlike_convert {
my ($thing) = @_;
return Test2::Compare::Pattern->new(
negate => 1,
stringify_got => 1,
pattern => $thing,
);
}
sub is_deeply($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&strict_convert);
if ($delta) {
# Temporary thing.
my $count = 0;
my $implicit = 0;
my @deltas = ($delta);
while (my $d = shift @deltas) {
my $add = $d->children;
push @deltas => @$add if $add && @$add;
next if $d->verified;
$count++;
$implicit++ if $d->note && $d->note eq 'implicit end';
}
if ($implicit == $count) {
$ctx->ok(1, $name);
my $meth = $ENV{AUTHOR_TESTING} ? 'throw' : 'alert';
my $type = $delta->render_check;
$ctx->$meth(
join "\n",
"!!! NOTICE OF BEHAVIOR CHANGE !!!",
"This test uses at least 1 $type check without using end() or etc().",
"The exising behavior is to default to etc() when inside is_deeply().",
"The new behavior is to default to end().",
"This test will soon start to fail with the following diagnostics:",
$delta->diag,
"",
);
}
else {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
our %OPS = (
'==' => 'num',
'!=' => 'num',
'>=' => 'num',
'<=' => 'num',
'>' => 'num',
'<' => 'num',
'<=>' => 'num',
'eq' => 'str',
'ne' => 'str',
'gt' => 'str',
'lt' => 'str',
'ge' => 'str',
'le' => 'str',
'cmp' => 'str',
'!~' => 'str',
'=~' => 'str',
'&&' => 'logic',
'||' => 'logic',
'xor' => 'logic',
'or' => 'logic',
'and' => 'logic',
'//' => 'logic',
'&' => 'bitwise',
'|' => 'bitwise',
'~~' => 'match',
);
sub cmp_ok($$$;$@) {
my ($got, $op, $exp, $name, @diag) = @_;
my $ctx = context();
# Warnings and syntax errors should report to the cmp_ok call, not the test
# context. They may not be the same.
my ($pkg, $file, $line) = caller;
my $type = $OPS{$op};
if (!$type) {
carp "operator '$op' is not supported (you can add it to %Test2::Tools::ClassicCompare::OPS)";
$type = 'unsupported';
}
local ($@, $!, $SIG{__DIE__});
my $test;
my $lived = eval <<" EOT";
#line $line "(eval in cmp_ok) $file"
\$test = (\$got $op \$exp);
1;
EOT
my $error = $@;
$ctx->send_event('Exception', error => $error) unless $lived;
if ($test && $lived) {
$ctx->ok(1, $name);
$ctx->release;
return 1;
}
# Ugh, it failed. Do roughly the same thing Test::More did to try and show
# diagnostics, but make it better by showing both the overloaded and
# unoverloaded form if overloading is in play. Also unoverload numbers,
# Test::More only unoverloaded strings.
my ($display_got, $display_exp);
if($type eq 'str') {
$display_got = defined($got) ? "$got" : undef;
$display_exp = defined($exp) ? "$exp" : undef;
}
elsif($type eq 'num') {
$display_got = defined($got) ? $got + 0 : undef;
$display_exp = defined($exp) ? $exp + 0 : undef;
}
else { # Well, we did what we could.
$display_got = $got;
$display_exp = $exp;
}
my $got_ref = ref($got) ? render_ref($got) : $got;
my $exp_ref = ref($exp) ? render_ref($exp) : $exp;
my @table;
my $show_both = (
(defined($got) && $got_ref ne "$display_got")
||
(defined($exp) && $exp_ref ne "$display_exp")
);
if ($show_both) {
@table = table(
header => ['TYPE', 'GOT', 'OP', 'CHECK'],
rows => [
[$type, $display_got, $op, $lived ? $display_exp : '<EXCEPTION>'],
['orig', $got_ref, '', $exp_ref],
],
);
}
else {
@table = table(
header => ['GOT', 'OP', 'CHECK'],
rows => [[$display_got, $op, $lived ? $display_exp : '<EXCEPTION>']],
);
}
$ctx->ok(0, $name, [join("\n", @table), @diag]);
$ctx->release;
return 0;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test2::Tools::ClassicCompare - Classic (Test::More style) comparison tools.
=head1 DESCRIPTION
This provides comparison functions that behave like they did in L<Test::More>,
unlike the L<Test2::Tools::Compare> plugin which has modified them.
=head1 SYNOPSIS
use Test2::Tools::ClassicCompare qw/is is_deeply isnt like unlike cmp_ok/;
is($got, $expect, "These are the same when stringified");
isnt($got, $unexpect, "These are not the same when stringified");
like($got, qr/.../, "'got' matches the pattern");
unlike($got, qr/.../, "'got' does not match the pattern");
is_deeply($got, $expect, "These structures are same when checked deeply");
cmp_ok($GOT, $OP, $WANT, 'Compare these items using the specified operatr');
=head1 EXPORTS
=over 4
=item $bool = is($got, $expect)
=item $bool = is($got, $expect, $name)
=item $bool = is($got, $expect, $name, @diag)
This does a string comparison of the two arguments. If the two arguments are the
same after stringification the test passes. The test will also pass if both
arguments are undef.
The test C<$name> is optional.
The test C<@diag> is optional, it is extra diagnostics messages that will be
displayed if the test fails. The diagnostics are ignored if the test passes.
It is important to note that this tool considers C<"1"> and C<"1.0"> to not be
equal as it uses a string comparison.
See L<Test2::Tools::Compare> if you want an C<is()> function that tries
to be smarter for you.
=item $bool = isnt($got, $dont_expect)
=item $bool = isnt($got, $dont_expect, $name)
=item $bool = isnt($got, $dont_expect, $name, @diag)
This is the inverse of C<is()>, it passes when the strings are not the same.
=item $bool = like($got, $pattern)
=item $bool = like($got, $pattern, $name)
=item $bool = like($got, $pattern, $name, @diag)
Check if C<$got> matches the specified pattern. Will fail if it does not match.
The test C<$name> is optional.
The test C<@diag> is optional. It contains extra diagnostics messages that will
be displayed if the test fails. The diagnostics are ignored if the test passes.
=item $bool = unlike($got, $pattern)
=item $bool = unlike($got, $pattern, $name)
=item $bool = unlike($got, $pattern, $name, @diag)
This is the inverse of C<like()>. This will fail if C<$got> matches
C<$pattern>.
=item $bool = is_deeply($got, $expect)
=item $bool = is_deeply($got, $expect, $name)
=item $bool = is_deeply($got, $expect, $name, @diag)
This does a deep check, comparing the structures in C<$got> with those in
C<$expect>. It will recurse into hashrefs, arrayrefs, and scalar refs. All
other values will be stringified and compared as strings. It is important to
note that this tool considers C<"1"> and C<"1.0"> to not be equal as it uses a
string comparison.
This is the same as C<Test2::Tools::Compare::is()>.
=item cmp_ok($got, $op, $expect)
=item cmp_ok($got, $op, $expect, $name)
=item cmp_ok($got, $op, $expect, $name, @diag)
Compare C<$got> to C<$expect> using the operator specified in C<$op>. This is
effectively an C<eval "\$got $op \$expect"> with some other stuff to make it
more sane. This is useful for comparing numbers, overloaded objects, etc.
B<Overloading Note:> Your input is passed as-is to the comparison.
If the comparison fails between two overloaded objects, the diagnostics will
try to show you the overload form that was used in comparisons. It is possible
that the diagnostics will be wrong, though attempts have been made to improve
them since L<Test::More>.
B<Exceptions:> If the comparison results in an exception then the test will
fail and the exception will be shown.
C<cmp_ok()> has an internal list of operators it supports. If you provide an
unsupported operator it will issue a warning. You can add operators to the
C<%Test2::Tools::ClassicCompare::OPS> hash, the key should be the operator, and
the value should either be 'str' for string comparison operators, 'num' for
numeric operators, or any other true value for other operators.
Supported operators:
=over 4
=item == (num)
=item != (num)
=item >= (num)
=item <= (num)
=item > (num)
=item < (num)
=item <=> (num)
=item eq (str)
=item ne (str)
=item gt (str)
=item lt (str)
=item ge (str)
=item le (str)
=item cmp (str)
=item !~ (str)
=item =~ (str)
=item &&
=item ||
=item xor
=item or
=item and
=item //
=item &
=item |
=item ~~
=back
=back
=head1 SOURCE
The source code repository for Test2-Suite can be found at
F<https://github.com/Test-More/Test2-Suite/>.
=head1 MAINTAINERS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright 2018 Chad Granum E<lt>exodist@cpan.orgE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>
=cut
| 23.456311 | 102 | 0.579719 |
ed9384f6cc23c564d902216e1342bf6d3702fed6 | 1,111 | pm | Perl | lib/Rex/Helper/System.pm | theappleman/Rex | d756f5b1c269888e33ee965f55c40a5936e475e1 | [
"Apache-2.0"
] | null | null | null | lib/Rex/Helper/System.pm | theappleman/Rex | d756f5b1c269888e33ee965f55c40a5936e475e1 | [
"Apache-2.0"
] | 2 | 2015-07-27T21:11:31.000Z | 2015-08-03T21:31:14.000Z | lib/Rex/Helper/System.pm | theappleman/Rex | d756f5b1c269888e33ee965f55c40a5936e475e1 | [
"Apache-2.0"
] | null | null | null | #
# (c) Jan Gehring <jan.gehring@gmail.com>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:
package Rex::Helper::System;
use strict;
use warnings;
use Rex::Helper::Hash;
sub info {
return (
eval {
my %merge1 = ();
my %merge2 = Rex::Hardware->get(qw/ All /);
my %template_vars = ( %merge1, %merge2 );
for my $info_key (qw(Network Host Kernel Memory Swap)) {
my $flatten_info = {};
if ( $info_key eq "Memory" ) {
hash_flatten( $merge2{$info_key}, $flatten_info, "_", "memory" );
}
elsif ( $info_key eq "Swap" ) {
hash_flatten( $merge2{$info_key}, $flatten_info, "_", "swap" );
}
elsif ( $info_key eq "Network" ) {
hash_flatten( $merge2{$info_key}->{"networkconfiguration"},
$flatten_info, "_" );
}
else {
hash_flatten( $merge2{$info_key}, $flatten_info, "_" );
}
for my $key ( keys %{$flatten_info} ) {
$template_vars{$key} = $flatten_info->{$key};
}
}
return %template_vars;
}
);
}
1;
| 21.365385 | 75 | 0.518452 |
eda6f26b41b772a92e7dea35e4bfe383307a1fb5 | 2,753 | t | Perl | demo/broken/stereo.t | jameshegarty/rigel | 63bae94d8f2df675e0e36d1416f3f10c0b607368 | [
"MIT"
] | 56 | 2016-07-27T01:23:42.000Z | 2022-03-20T08:22:54.000Z | demo/broken/stereo.t | jameshegarty/rigel | 63bae94d8f2df675e0e36d1416f3f10c0b607368 | [
"MIT"
] | 87 | 2017-04-01T00:35:37.000Z | 2019-09-17T19:11:00.000Z | demo/broken/stereo.t | jameshegarty/rigel | 63bae94d8f2df675e0e36d1416f3f10c0b607368 | [
"MIT"
] | 7 | 2016-12-08T03:05:07.000Z | 2019-11-08T04:29:14.000Z | import "darkroom"
require "mapmachine"
require "image"
searchRadius = 60
windowRadius = 4
SADSize = (windowRadius*2+1)*(windowRadius*2+1)
W = 720
H = 405
W=64
H=32
--------------------------------
-- AD (int8,int8)->int32
A = d.input( darkroom.type.uint(8) )
B = d.input( darkroom.type.uint(8) )
AD = d.leaf( terra( out : &int32, A : &uint8, B : &uint8 ) @out = cstdlib.abs([int32](@A)-[int32](@B)) end, darkroom.type.int(32), A, B )
--------------------------------
-- SAD (uint8[SADSize], uint8[SADSize]) -> int32
A = d.input( darkroom.type.array( darkroom.type.uint(8),{SADSize}) )
B = d.input( darkroom.type.array( darkroom.type.uint(8),{SADSize}) )
ADMap = d.map( "admap", AD, A, B )
SAD = d.reduce( "sum", ADMap ) -- (int32[SADSize] -> uint32)
SAD = d.fn( "SAD", SAD, A, B )
--------------------------------
-- stereoKernel ( (uint8[SADSize])[searchRadius], (uint8[SADSize])[searchRadius] ) -> uint8 )
frame1stencils = d.input( darkroom.type.array( darkroom.type.uint(8), {SADSize, searchRadius}) )
frame2stencils = d.input( darkroom.type.array( darkroom.type.uint(8), {SADSize, searchRadius}) )
SADarray = d.map( "sadmap", SAD, frame1stencils, frame2stencils ) -- uint8[searchRadius)
indices = d.range( searchRadius, darkroom.type.uint(8) )
match = d.reduce( "argmin", SADarray, indices ) -- uint8
stereoKernel = d.fn( "stereoKernel", match, frame1stencils, frame2stencils )
-------------------------------
dupInput = d.input( darkroom.type.array( darkroom.type.uint(8), {SADSize} ) )
dupStencil = d.dup( dupInput, searchRadius )
dupStencil = d.fn( "dupStencil", dupStencil, dupInput )
-------------------------------
-- stereo (uint8[W*H], uint8[W*H]) -> uint8[W*H]
frame1 = d.input( darkroom.type.array( darkroom.type.uint(8), {W*H}) )
frame2 = d.input( darkroom.type.array( darkroom.type.uint(8), {W*H}) )
frame1st = d.extractStencils( "frame1st", frame1, W, -windowRadius*2, -windowRadius*2 ) -- (uint8[SADSize])[W*H]
frame1st = d.map( "dupmap", dupStencil, frame1st )
-- extractStencilArray is a function of extractStencils, slice
frame2st = d.extractStencilArray( "sadextract", frame2, W, -windowRadius*2, -windowRadius*2, searchRadius ) -- ((uint8[windowRadius*2+1][windowRadius*2+1])[searchRadius])[W*H]
print("SR",frame1st.type, frame2st.type)
stereoResult = d.map( "stereomap", stereoKernel, frame1st, frame2st )
stereo = d.fn( "stereo", stereoResult, frame1, frame2 )
---------------------
-- apply
stereo = d.compile( stereo )
terra doit()
var left : Image
left:load("left0224.bmp")
var right : Image
right:load("right0224.bmp")
var imOut : Image
imOut:load("left0224.bmp")
stereo( [&uint8[W*H]](imOut.data), [&uint8[W*H]](left.data), [&uint8[W*H]](right.data) )
imOut:save("stereo.bmp")
end
doit() | 34.848101 | 175 | 0.638213 |
ed370db441bb3aeee3c1c3302994dcfd031d8995 | 6,271 | pm | Perl | modules/Bio/EnsEMBL/Utils/Argument.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Utils/Argument.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Utils/Argument.pm | arnaudxk/ensembl | 2baa0f180dde74e9d89b7ac0495d15c79bc63ff3 | [
"Apache-2.0"
] | 1 | 2016-02-17T09:50:07.000Z | 2016-02-17T09:50:07.000Z | =head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
=head1 NAME
Bio::EnsEMBL::Utils::Argument - Utility functions for argument handling
=head1 SYNOPSIS
use Bio::EnsEMBL::Utils::Argument qw(rearrange)
package Feature;
sub new {
my $class = shift;
my ( $start, $end, $strand ) =
rearrange( [ 'START', 'END', 'STRAND' ], @_ );
return
bless( { 'start' => $start, 'end' => $end, 'strand' => $strand },
$class );
}
=head1 DESCRIPTION
This is derived from the Bio::Root module in BioPerl. The _rearrange
object method taken from BioPerl has been renamed rearrange and is now
a static class method. This method was originally written by Lincoln
Stein, and has since been refactored several times by various people (as
described below).
It is recommended that this package be used instead of inheriting
unnecessarily from the Bio::EnsEMBL::Root or Bio::Root object.
=head1 METHODS
=cut
package Bio::EnsEMBL::Utils::Argument;
use strict;
use warnings;
#
# Interface with some of the module function XS reimplementation
#
# If Bio::EnsEMBL::XS is installed, assign the function glob to
# the XS counterpart, otherwise assign to the original function
#
BEGIN {
if (eval { require Bio::EnsEMBL::XS; 1 }) {
*rearrange = \&Bio::EnsEMBL::XS::Utils::Argument::rearrange;
} else {
*rearrange = \&rearrange_pp;
}
}
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(rearrange);
=head2 rearrange_pp
Usage : rearrange( array_ref, list_of_arguments)
Purpose : Rearranges named parameters to requested order.
Example : use Bio::EnsEMBL::Utils::Argument qw(rearrange);
: rearrange([qw(SEQUENCE ID DESC)],@param);
: Where @param = (-sequence => $s,
: -id => $i,
: -desc => $d);
Returns : @params - an array of parameters in the requested order.
: The above example would return ($s, $i, $d)
Argument : $order : a reference to an array which describes the desired
: order of the named parameters.
: @param : an array of parameters, either as a list (in
: which case the function simply returns the list),
: or as an associative array with hyphenated tags
: (in which case the function sorts the values
: according to @{$order} and returns that new array.)
: The tags can be upper, lower, or mixed case
: but they must start with a hyphen (at least the
: first one should be hyphenated.)
Source : This function was taken from CGI.pm, written by Dr. Lincoln
: Stein, and adapted for use in Bio::Seq by Richard Resnick and
: then adapted for use in Bio::Root::Object.pm by Steve A. Chervitz.
: This has since been adapted as an exported static method in this
class Bio::EnsEMBL::Utils::Argument
Comments : (SAC)
: This method may not be appropriate for method calls that are
: within in an inner loop if efficiency is a concern.
:
: Parameters can be specified using any of these formats:
: @param = (-name=>'me', -color=>'blue');
: @param = (-NAME=>'me', -COLOR=>'blue');
: @param = (-Name=>'me', -Color=>'blue');
: A leading hyphenated argument is used by this function to
: indicate that named parameters are being used.
: Therefore, a ('me', 'blue') list will be returned as-is.
:
: Note that Perl will confuse unquoted, hyphenated tags as
: function calls if there is a function of the same name
: in the current namespace:
: -name => 'foo' is interpreted as -&name => 'foo'
:
: For ultimate safety, put single quotes around the tag:
: ('-name'=>'me', '-color' =>'blue');
: This can be a bit cumbersome and I find not as readable
: as using all uppercase, which is also fairly safe:
: (-NAME=>'me', -COLOR =>'blue');
:
: Personal note (SAC): I have found all uppercase tags to
: be more managable: it involves less single-quoting,
: the code is more readable, and there are no method naming
: conlicts.
: Regardless of the style, it greatly helps to line
: the parameters up vertically for long/complex lists.
=cut
sub rearrange_pp {
my $order = shift;
if ( $order eq "Bio::EnsEMBL::Utils::Argument" ) {
# skip object if one provided
$order = shift;
}
# If we've got parameters, we need to check to see whether
# they are named or simply listed. If they are listed, we
# can just return them.
unless ( @_ && $_[0] && substr( $_[0], 0, 1 ) eq '-' ) {
return @_;
}
# Push undef onto the end if % 2 != 0 to stop warnings
push @_,undef unless $#_ %2;
my %param;
while( @_ ) {
#deletes all dashes & uppercases at the same time
(my $key = shift) =~ tr/a-z\055/A-Z/d;
$param{$key} = shift;
}
# What we intend to do is loop through the @{$order} variable,
# and for each value, we use that as a key into our associative
# array, pushing the value at that key onto our return array.
return map { $param{uc($_)} } @$order;
}
1;
| 33.534759 | 100 | 0.630203 |
ed9f8a2ed106a8bc108159592c167c91164fb1bd | 4,027 | pm | Perl | misc-scripts/xref_mapping/XrefParser/Broad_GenericParser.pm | JAlvarezJarreta/ensembl | 1af1dce3518d6af00df04983993deefa01ec2276 | [
"Apache-2.0"
] | 49 | 2015-01-14T14:03:30.000Z | 2022-03-17T22:54:52.000Z | misc-scripts/xref_mapping/XrefParser/Broad_GenericParser.pm | JAlvarezJarreta/ensembl | 1af1dce3518d6af00df04983993deefa01ec2276 | [
"Apache-2.0"
] | 489 | 2015-01-14T14:53:47.000Z | 2022-03-29T18:30:48.000Z | misc-scripts/xref_mapping/XrefParser/Broad_GenericParser.pm | JAlvarezJarreta/ensembl | 1af1dce3518d6af00df04983993deefa01ec2276 | [
"Apache-2.0"
] | 115 | 2015-01-14T14:31:42.000Z | 2022-03-15T16:24:38.000Z | =head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2020] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
package XrefParser::Broad_GenericParser;
use strict;
use warnings;
use Carp;
use File::Basename;
use base qw( XrefParser::BaseParser );
#
# Broad gene annotation file with gene predictions, their gene names and descriptions
#
#
# This is the based Broad parser, with the logic code for parsing, but doesn't know anything about the URL and the source. Needs to add an extra module that inherits from it with the source logic.
#
sub parse {
my ($self, $ref_arg) = @_;
my $species_id = $ref_arg->{species_id};
my $source_id = $ref_arg->{source_id};
my $files = $ref_arg->{files};
my $verbose = $ref_arg->{verbose};
if( (!defined $species_id) or (!defined $files) ){
croak "Need to pass source_id, species_id and files as pairs";
}
$verbose |=0;
my $file = @{$files}[0];
# Very hacky code, but can't get better!
# Problem is that the filename from the URI is 'download', which turns up to be compressed
# so need to uncompress it after download.
# Because it doesn't match .gz, not done yet automatically, so we have to do it now
# Other problem is that should it not try to uncompress it when already uncompressed (ie when not downloaded again)
# Would be nice to capture the error code when trying to uncompress an already uncompressed file,
# but haven't figured out yet how to !
# To do so, it seems that somehow we need to capture STDERR
system ("mv $file $file.gz");
print STDERR "file: $file\n";
eval {
system ("gunzip", "-f", "$file.gz");
};
if ($@) {
# doesn't catch anything actually, why ?
print STDERR "catching eval error code!\n";
}
system ("mv $file.gz $file");
my @xrefs = ();
if ($verbose) {
print STDERR "Parsing broad source, $source_id\n";
}
my $file_io = $self->get_filehandle($file);
if ( !defined $file_io ) {
print STDERR "ERROR: Could not open $file\n";
return 1; # 1 is an error
}
while ( $_ = $file_io->getline() ) {
my $line = $_;
chomp $line;
next if ($line =~ /^LOCUS/); # skip header
my $xref = {};
my ($stable_id,$symbol,$synonym,$length,$start,$end,$strand,$desc,$chromosome) = $line =~ /^([^\t]+)\t([^\t]*)\t([^\t]*)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t*.*/ or warn("Can't parse Broad entry: $_\n");
# build the xref object and store it
$xref->{ACCESSION} = $stable_id;
$xref->{LABEL} = $stable_id;
$xref->{DESC} = $desc;
$xref->{SPECIES_ID} = $species_id;
$xref->{SOURCE_ID} = $source_id;
push @xrefs, $xref;
}
$file_io->close();
print STDERR scalar(@xrefs) . " BROAD_ xrefs succesfully parsed\n" if($verbose);
return \@xrefs;
}
sub store {
my ($self, $xrefs_aref) = @_;
foreach my $xref_href (@$xrefs_aref) {
my $gene_xref_id = $self->add_xref({ acc => $xref_href->{ACCESSION},
label => $xref_href->{LABEL},
desc => $xref_href->{DESC},
source_id => $xref_href->{SOURCE_ID},
species_id => $xref_href->{SPECIES_ID},
version => 1,
info_type => "DIRECT"} );
$self->add_direct_xref($gene_xref_id, $xref_href->{ACCESSION}, "Gene", "DIRECT");
}
return 0; # success
}
1;
| 29.82963 | 230 | 0.631239 |
ed363ab81411336ff05cfb741d536de9f803df64 | 441 | pl | Perl | ARTe/work/tools/cygwin/lib/perl5/5.14/unicore/lib/Blk/DominoTi.pl | melvin-mancini/Multitasking-RealTime-Arduino-System | 6999beaf28f69b4c4a8f8badcc60f66e6e118477 | [
"MIT"
] | 5 | 2018-12-18T20:19:43.000Z | 2022-02-21T21:53:09.000Z | Slic3r/Linux/lib/std/unicore/lib/Blk/DominoTi.pl | thomaspreece10/STLExtract | 2bea6d38135ebfda2558a33cc93565211e30a2bb | [
"MIT"
] | null | null | null | Slic3r/Linux/lib/std/unicore/lib/Blk/DominoTi.pl | thomaspreece10/STLExtract | 2bea6d38135ebfda2558a33cc93565211e30a2bb | [
"MIT"
] | 6 | 2016-09-23T02:54:47.000Z | 2022-03-10T22:04:19.000Z | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by lib/unicore/mktables from the Unicode
# database, Version 6.0.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by the Perl program only. The format and even
# the name or existence of this file are subject to change without notice.
# Don't use it directly.
return <<'END';
1F030 1F09F
END
| 31.5 | 78 | 0.680272 |
edb0b58115d0ab1b0f7af1bb7a2fc80f8a74bad6 | 5,670 | pm | Perl | perl/vendor/lib/Imager/Font/T1.pm | mnikolop/Thesis_project_CyberDoc | 9a37fdd5a31de24cb902ee31ef19eb992faa1665 | [
"Apache-2.0"
] | 4 | 2018-04-20T07:27:13.000Z | 2021-12-21T05:19:24.000Z | perl/vendor/lib/Imager/Font/T1.pm | mnikolop/Thesis_project_CyberDoc | 9a37fdd5a31de24cb902ee31ef19eb992faa1665 | [
"Apache-2.0"
] | 4 | 2021-03-10T19:10:00.000Z | 2021-05-11T14:58:19.000Z | perl/vendor/lib/Imager/Font/T1.pm | mnikolop/Thesis_project_CyberDoc | 9a37fdd5a31de24cb902ee31ef19eb992faa1665 | [
"Apache-2.0"
] | 1 | 2019-11-12T02:29:26.000Z | 2019-11-12T02:29:26.000Z | package Imager::Font::T1;
use strict;
use Imager::Color;
use vars qw(@ISA $VERSION);
@ISA = qw(Imager::Font);
use Scalar::Util ();
BEGIN {
$VERSION = "1.019";
require XSLoader;
XSLoader::load('Imager::Font::T1', $VERSION);
}
*_first = \&Imager::Font::_first;
my $t1aa = 2;
sub new {
my $class = shift;
my %hsh=(color=>Imager::Color->new(255,0,0,255),
size=>15,
@_);
unless ($hsh{file}) {
$Imager::ERRSTR = "No font file specified";
return;
}
unless (-e $hsh{file}) {
$Imager::ERRSTR = "Font file $hsh{file} not found";
return;
}
unless ($Imager::formats{t1}) {
$Imager::ERRSTR = "Type 1 fonts not supported in this build";
return;
}
# we want to avoid T1Lib's file search mechanism
unless ($hsh{file} =~ m!^/!
|| $hsh{file} =~ m!^\.\/?/!
|| $^O =~ /^(MSWin32|cygwin)$/ && $hsh{file} =~ /^[a-z]:/i) {
$hsh{file} = './' . $hsh{file};
}
if($hsh{afm}) {
unless (-e $hsh{afm}) {
$Imager::ERRSTR = "Afm file $hsh{afm} not found";
return;
}
unless ($hsh{afm} =~ m!^/!
|| $hsh{afm} =~ m!^\./!
|| $^O =~ /^(MSWin32|cygwin)$/ && $hsh{file} =~ /^[a-z]:/i) {
$hsh{file} = './' . $hsh{file};
}
} else {
$hsh{afm} = 0;
}
my $font = Imager::Font::T1xs->new($hsh{file},$hsh{afm});
unless ($font) { # the low-level code may miss some error handling
Imager->_set_error(Imager->_error_as_msg);
return;
}
return bless {
t1font => $font,
aa => $hsh{aa} || 0,
file => $hsh{file},
type => 't1',
size => $hsh{size},
color => $hsh{color},
t1aa => $t1aa,
}, $class;
}
sub _draw {
my $self = shift;
$self->_valid
or return;
my %input = @_;
my $flags = '';
$flags .= 'u' if $input{underline};
$flags .= 's' if $input{strikethrough};
$flags .= 'o' if $input{overline};
my $aa = $input{aa} ? $self->{t1aa} : 0;
if (exists $input{channel}) {
$self->{t1font}->cp($input{image}{IMG}, $input{'x'}, $input{'y'},
$input{channel}, $input{size},
$input{string}, length($input{string}), $input{align},
$input{utf8}, $flags, $aa)
or return;
} else {
$self->{t1font}->text($input{image}{IMG}, $input{'x'}, $input{'y'},
$input{color}, $input{size},
$input{string}, length($input{string}),
$input{align}, $input{utf8}, $flags, $aa)
or return;
}
return $self;
}
sub _bounding_box {
my $self = shift;
$self->_valid
or return;
my %input = @_;
my $flags = '';
$flags .= 'u' if $input{underline};
$flags .= 's' if $input{strikethrough};
$flags .= 'o' if $input{overline};
return $self->{t1font}->bbox($input{size}, $input{string},
length($input{string}), $input{utf8}, $flags);
}
# check if the font has the characters in the given string
sub has_chars {
my ($self, %hsh) = @_;
$self->_valid
or return;
unless (defined $hsh{string} && length $hsh{string}) {
$Imager::ERRSTR = "No string supplied to \$font->has_chars()";
return;
}
return $self->{t1font}->has_chars($hsh{string},
_first($hsh{'utf8'}, $self->{utf8}, 0));
}
sub utf8 {
1;
}
sub face_name {
my ($self) = @_;
$self->_valid
or return;
return $self->{t1font}->face_name();
}
sub glyph_names {
my ($self, %input) = @_;
$self->_valid
or return;
my $string = $input{string};
defined $string
or return Imager->_set_error("no string parameter passed to glyph_names");
my $utf8 = _first($input{utf8} || 0);
return $self->{t1font}->glyph_name($string, $utf8);
}
sub set_aa_level {
my ($self, $new_t1aa) = @_;
if (!defined $new_t1aa ||
($new_t1aa != 1 && $new_t1aa != 2)) {
Imager->_set_error("set_aa_level: parameter must be 1 or 2");
return;
}
if (ref $self) {
$self->_valid
or return;
$self->{t1aa} = $new_t1aa;
}
else {
$t1aa = $new_t1aa;
}
return 1;
}
sub _valid {
my $self = shift;
unless ($self->{t1font} && Scalar::Util::blessed($self->{t1font})) {
Imager->_set_error("font object was created in another thread");
return;
}
return 1;
}
1;
__END__
=head1 NAME
Imager::Font::Type1 - low-level functions for Type1 fonts
=head1 DESCRIPTION
Imager::Font creates a Imager::Font::Type1 object when asked to create
a font object based on a C<.pfb> file.
See Imager::Font to see how to use this type.
This class provides low-level functions that require the caller to
perform data validation
By default Imager no longer creates the F<t1lib.log> log file. You
can re-enable that by calling Imager::init() with the C<t1log> option:
Imager::init(t1log=>1);
This must be called before creating any fonts.
Currently specific to Imager::Font::Type1, you can use the following
flags when drawing text or calculating a bounding box:
=for stopwords overline strikethrough
=over
=item *
C<underline> - Draw the text with an underline.
=item *
C<overline> - Draw the text with an overline.
=item *
C<strikethrough> - Draw the text with a strikethrough.
=back
Obviously, if you're calculating the bounding box the size of the line
is included in the box, and the line isn't drawn :)
=head2 Anti-aliasing
T1Lib supports multiple levels of anti-aliasing, by default, if you
request anti-aliased output, Imager::Font::T1 will use the maximum
level.
You can override this with the set_t1_aa() method:
=over
=item set_aa_level()
Usage:
$font->set_aa_level(1);
Imager::Font::T1->set_aa_level(2);
Sets the T1Lib anti-aliasing level either for the specified font, or
for new font objects.
The only parameter must be 1 or 2.
Returns true on success.
=back
=head1 AUTHOR
Addi, Tony
=cut
| 20.693431 | 78 | 0.606878 |
ed70e98117385e3e55c019b4509ccf889ee78ccd | 4,405 | pm | Perl | tests/boot/grub2_test.pm | lansuse/os-autoinst-distri-opensuse | 8e8c532236f2436693ec1da426de563c9759d778 | [
"FSFAP"
] | null | null | null | tests/boot/grub2_test.pm | lansuse/os-autoinst-distri-opensuse | 8e8c532236f2436693ec1da426de563c9759d778 | [
"FSFAP"
] | null | null | null | tests/boot/grub2_test.pm | lansuse/os-autoinst-distri-opensuse | 8e8c532236f2436693ec1da426de563c9759d778 | [
"FSFAP"
] | null | null | null | # SUSE's openQA tests
#
# Copyright 2019-2020 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# Summary: Grub2 test
# - boot another menu entry
# - command & menu edit
# - boot into emergency shell
# - fips
# - password
# - with UEFI (secureboot enabled by default)
# Maintainer: Jozef Pupava <jpupava@suse.com>
use strict;
use warnings;
use base 'opensusebasetest';
use testapi;
use bootloader_setup qw(stop_grub_timeout boot_grub_item);
use utils qw(zypper_call zypper_ar);
use version_utils 'is_sle';
sub reboot {
enter_cmd "reboot";
reset_consoles;
assert_screen 'grub2', 120;
stop_grub_timeout;
}
sub edit_cmdline {
send_key 'e';
for (1 .. 13) { send_key 'down'; }
send_key_until_needlematch 'grub2-edit-linux-line', 'down';
send_key 'end';
}
sub grub2_boot {
sleep 1;
save_screenshot;
send_key 'f10';
}
sub run {
select_console 'root-console';
# remove splash and quiet parameters from cmdline, grub config will be updated with following kernel installation
assert_script_run 'sed -i \'/CMDLINE/s/ quiet//\' /etc/default/grub';
assert_script_run 'sed -i \'/CMDLINE/s/splash=silent //\' /etc/default/grub';
assert_script_run 'grep CMDLINE /etc/default/grub';
record_info 'grub2 menu entry', 'install another kernel, boot the previous one';
assert_script_run 'uname -r >kernel.txt';
assert_script_run q(sed -i '/BEGIN.*10_linux/a menuentry "SLES Fake boot" {\nlinux\n}' /boot/grub2/grub.cfg);
reboot;
boot_grub_item(2);
assert_screen 'linux-login', 200;
select_console 'root-console';
assert_script_run 'uname -r|grep $(cat kernel.txt)';
# install fips and reset the grub config
zypper_call 'in -t pattern fips';
reboot;
record_info 'grub2 command line', 'ls /boot and help command';
send_key 'c';
enter_cmd "ls /boot";
assert_screen 'grub2-command-line-ls';
enter_cmd "help";
assert_screen 'grub2-command-line-help';
send_key 'esc';
sleep 1;
record_info 'grub2 boot single user mode', 'add \'single\' boot parameter';
edit_cmdline;
type_string ' single';
grub2_boot;
assert_screen 'emergency-shell', 200;
type_password;
send_key 'ret';
assert_script_run 'grep \' single\' /proc/cmdline';
reboot;
if (get_var('HDD_1') !~ /lvm/) { # fips on lvm is not supported
record_info 'grub2 edit boot entry', 'boot with fips mode';
edit_cmdline;
type_string ' fips=1';
grub2_boot;
assert_screen 'linux-login', 300;
select_console 'root-console';
assert_script_run 'grep \'fips=1\' /proc/cmdline';
assert_script_run 'sysctl crypto.fips_enabled';
}
else {
send_key 'ret';
assert_screen 'linux-login', 200;
select_console 'root-console';
}
record_info 'grub2 password', 'set password to boot';
script_run "yast bootloader; echo yast-bootloader-status-\$? > /dev/$serialdev", 0;
assert_screen 'test-yast2_bootloader-1';
# on sle12sp1 will the schortcut change from 't' to 'l' after you press alt-t
send_key 'alt-t' if is_sle('=12-sp1');
send_key 'alt-l'; # bootloader options tab
assert_screen 'installation-bootloader-options';
my $protect_key = is_sle('=12-sp1') && !get_var('UEFI') ? 'a' : 'e';
send_key "alt-$protect_key"; # check protect boot loader with pw
send_key 'alt-r'; # uncheck protect entry modification only
send_key 'alt-p'; # selecet password field
type_password;
send_key 'tab';
type_password;
sleep 2;
save_screenshot;
send_key 'alt-o'; # OK
wait_serial 'yast-bootloader-status-0', 60 || die "'yast bootloader' didn't finish";
# verify password protect
assert_script_run 'grep \'password\' /boot/grub2/grub.cfg';
reboot;
record_info 'grub2 password', 'type login and password to boot';
assert_screen 'grub2';
send_key 'ret';
type_string 'root';
send_key 'ret';
type_password;
send_key 'ret';
assert_screen 'linux-login', 100;
}
1;
| 33.120301 | 117 | 0.652213 |
ed0af8dfd04d4c2a5485e719e1b7f732938c4a85 | 31,612 | pl | Perl | crypto/aes/asm/vpaes-x86_64.pl | JamesWP/openssl | 922241de76dce66a04e0217bfc270a5228b694f3 | [
"Apache-2.0"
] | 4 | 2017-07-18T18:24:43.000Z | 2018-01-28T19:26:37.000Z | crypto/aes/asm/vpaes-x86_64.pl | JamesWP/openssl | 922241de76dce66a04e0217bfc270a5228b694f3 | [
"Apache-2.0"
] | 1 | 2016-02-27T16:30:29.000Z | 2016-02-27T19:50:04.000Z | crypto/aes/asm/vpaes-x86_64.pl | JamesWP/openssl | 922241de76dce66a04e0217bfc270a5228b694f3 | [
"Apache-2.0"
] | 3 | 2016-02-27T14:35:30.000Z | 2017-03-13T03:38:09.000Z | #! /usr/bin/env perl
# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
######################################################################
## Constant-time SSSE3 AES core implementation.
## version 0.1
##
## By Mike Hamburg (Stanford University), 2009
## Public domain.
##
## For details see http://shiftleft.org/papers/vector_aes/ and
## http://crypto.stanford.edu/vpaes/.
######################################################################
# September 2011.
#
# Interface to OpenSSL as "almost" drop-in replacement for
# aes-x86_64.pl. "Almost" refers to the fact that AES_cbc_encrypt
# doesn't handle partial vectors (doesn't have to if called from
# EVP only). "Drop-in" implies that this module doesn't share key
# schedule structure with the original nor does it make assumption
# about its alignment...
#
# Performance summary. aes-x86_64.pl column lists large-block CBC
# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per
# byte processed with 128-bit key, and vpaes-x86_64.pl column -
# [also large-block CBC] encrypt/decrypt.
#
# aes-x86_64.pl vpaes-x86_64.pl
#
# Core 2(**) 29.6/41.1/14.3 21.9/25.2(***)
# Nehalem 29.6/40.3/14.6 10.0/11.8
# Atom 57.3/74.2/32.1 60.9/77.2(***)
# Silvermont 52.7/64.0/19.5 48.8/60.8(***)
# Goldmont 38.9/49.0/17.8 10.6/12.6
#
# (*) "Hyper-threading" in the context refers rather to cache shared
# among multiple cores, than to specifically Intel HTT. As vast
# majority of contemporary cores share cache, slower code path
# is common place. In other words "with-hyper-threading-off"
# results are presented mostly for reference purposes.
#
# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
#
# (***) Less impressive improvement on Core 2 and Atom is due to slow
# pshufb, yet it's respectable +36%/62% improvement on Core 2
# (as implied, over "hyper-threading-safe" code path).
#
# <appro@openssl.org>
# $output is the last argument if it looks like a file (it has an extension)
# $flavour is the first argument if it doesn't look like a file
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl";
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
or die "can't call $xlate: $!";
*STDOUT=*OUT;
$PREFIX="vpaes";
$code.=<<___;
.text
##
## _aes_encrypt_core
##
## AES-encrypt %xmm0.
##
## Inputs:
## %xmm0 = input
## %xmm9-%xmm15 as in _vpaes_preheat
## (%rdx) = scheduled keys
##
## Output in %xmm0
## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax
## Preserves %xmm6 - %xmm8 so you get some local vectors
##
##
.type _vpaes_encrypt_core,\@abi-omnipotent
.align 16
_vpaes_encrypt_core:
.cfi_startproc
mov %rdx, %r9
mov \$16, %r11
mov 240(%rdx),%eax
movdqa %xmm9, %xmm1
movdqa .Lk_ipt(%rip), %xmm2 # iptlo
pandn %xmm0, %xmm1
movdqu (%r9), %xmm5 # round0 key
psrld \$4, %xmm1
pand %xmm9, %xmm0
pshufb %xmm0, %xmm2
movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi
pshufb %xmm1, %xmm0
pxor %xmm5, %xmm2
add \$16, %r9
pxor %xmm2, %xmm0
lea .Lk_mc_backward(%rip),%r10
jmp .Lenc_entry
.align 16
.Lenc_loop:
# middle of middle round
movdqa %xmm13, %xmm4 # 4 : sb1u
movdqa %xmm12, %xmm0 # 0 : sb1t
pshufb %xmm2, %xmm4 # 4 = sb1u
pshufb %xmm3, %xmm0 # 0 = sb1t
pxor %xmm5, %xmm4 # 4 = sb1u + k
movdqa %xmm15, %xmm5 # 4 : sb2u
pxor %xmm4, %xmm0 # 0 = A
movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[]
pshufb %xmm2, %xmm5 # 4 = sb2u
movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
movdqa %xmm14, %xmm2 # 2 : sb2t
pshufb %xmm3, %xmm2 # 2 = sb2t
movdqa %xmm0, %xmm3 # 3 = A
pxor %xmm5, %xmm2 # 2 = 2A
pshufb %xmm1, %xmm0 # 0 = B
add \$16, %r9 # next key
pxor %xmm2, %xmm0 # 0 = 2A+B
pshufb %xmm4, %xmm3 # 3 = D
add \$16, %r11 # next mc
pxor %xmm0, %xmm3 # 3 = 2A+B+D
pshufb %xmm1, %xmm0 # 0 = 2B+C
and \$0x30, %r11 # ... mod 4
sub \$1,%rax # nr--
pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
.Lenc_entry:
# top of round
movdqa %xmm9, %xmm1 # 1 : i
movdqa %xmm11, %xmm5 # 2 : a/k
pandn %xmm0, %xmm1 # 1 = i<<4
psrld \$4, %xmm1 # 1 = i
pand %xmm9, %xmm0 # 0 = k
pshufb %xmm0, %xmm5 # 2 = a/k
movdqa %xmm10, %xmm3 # 3 : 1/i
pxor %xmm1, %xmm0 # 0 = j
pshufb %xmm1, %xmm3 # 3 = 1/i
movdqa %xmm10, %xmm4 # 4 : 1/j
pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
pshufb %xmm0, %xmm4 # 4 = 1/j
movdqa %xmm10, %xmm2 # 2 : 1/iak
pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
pshufb %xmm3, %xmm2 # 2 = 1/iak
movdqa %xmm10, %xmm3 # 3 : 1/jak
pxor %xmm0, %xmm2 # 2 = io
pshufb %xmm4, %xmm3 # 3 = 1/jak
movdqu (%r9), %xmm5
pxor %xmm1, %xmm3 # 3 = jo
jnz .Lenc_loop
# middle of last round
movdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo
movdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16
pshufb %xmm2, %xmm4 # 4 = sbou
pxor %xmm5, %xmm4 # 4 = sb1u + k
pshufb %xmm3, %xmm0 # 0 = sb1t
movdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[]
pxor %xmm4, %xmm0 # 0 = A
pshufb %xmm1, %xmm0
ret
.cfi_endproc
.size _vpaes_encrypt_core,.-_vpaes_encrypt_core
##
## Decryption core
##
## Same API as encryption core.
##
.type _vpaes_decrypt_core,\@abi-omnipotent
.align 16
_vpaes_decrypt_core:
.cfi_startproc
mov %rdx, %r9 # load key
mov 240(%rdx),%eax
movdqa %xmm9, %xmm1
movdqa .Lk_dipt(%rip), %xmm2 # iptlo
pandn %xmm0, %xmm1
mov %rax, %r11
psrld \$4, %xmm1
movdqu (%r9), %xmm5 # round0 key
shl \$4, %r11
pand %xmm9, %xmm0
pshufb %xmm0, %xmm2
movdqa .Lk_dipt+16(%rip), %xmm0 # ipthi
xor \$0x30, %r11
lea .Lk_dsbd(%rip),%r10
pshufb %xmm1, %xmm0
and \$0x30, %r11
pxor %xmm5, %xmm2
movdqa .Lk_mc_forward+48(%rip), %xmm5
pxor %xmm2, %xmm0
add \$16, %r9
add %r10, %r11
jmp .Ldec_entry
.align 16
.Ldec_loop:
##
## Inverse mix columns
##
movdqa -0x20(%r10),%xmm4 # 4 : sb9u
movdqa -0x10(%r10),%xmm1 # 0 : sb9t
pshufb %xmm2, %xmm4 # 4 = sb9u
pshufb %xmm3, %xmm1 # 0 = sb9t
pxor %xmm4, %xmm0
movdqa 0x00(%r10),%xmm4 # 4 : sbdu
pxor %xmm1, %xmm0 # 0 = ch
movdqa 0x10(%r10),%xmm1 # 0 : sbdt
pshufb %xmm2, %xmm4 # 4 = sbdu
pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbdt
pxor %xmm4, %xmm0 # 4 = ch
movdqa 0x20(%r10),%xmm4 # 4 : sbbu
pxor %xmm1, %xmm0 # 0 = ch
movdqa 0x30(%r10),%xmm1 # 0 : sbbt
pshufb %xmm2, %xmm4 # 4 = sbbu
pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbbt
pxor %xmm4, %xmm0 # 4 = ch
movdqa 0x40(%r10),%xmm4 # 4 : sbeu
pxor %xmm1, %xmm0 # 0 = ch
movdqa 0x50(%r10),%xmm1 # 0 : sbet
pshufb %xmm2, %xmm4 # 4 = sbeu
pshufb %xmm5, %xmm0 # MC ch
pshufb %xmm3, %xmm1 # 0 = sbet
pxor %xmm4, %xmm0 # 4 = ch
add \$16, %r9 # next round key
palignr \$12, %xmm5, %xmm5
pxor %xmm1, %xmm0 # 0 = ch
sub \$1,%rax # nr--
.Ldec_entry:
# top of round
movdqa %xmm9, %xmm1 # 1 : i
pandn %xmm0, %xmm1 # 1 = i<<4
movdqa %xmm11, %xmm2 # 2 : a/k
psrld \$4, %xmm1 # 1 = i
pand %xmm9, %xmm0 # 0 = k
pshufb %xmm0, %xmm2 # 2 = a/k
movdqa %xmm10, %xmm3 # 3 : 1/i
pxor %xmm1, %xmm0 # 0 = j
pshufb %xmm1, %xmm3 # 3 = 1/i
movdqa %xmm10, %xmm4 # 4 : 1/j
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
pshufb %xmm0, %xmm4 # 4 = 1/j
pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
movdqa %xmm10, %xmm2 # 2 : 1/iak
pshufb %xmm3, %xmm2 # 2 = 1/iak
movdqa %xmm10, %xmm3 # 3 : 1/jak
pxor %xmm0, %xmm2 # 2 = io
pshufb %xmm4, %xmm3 # 3 = 1/jak
movdqu (%r9), %xmm0
pxor %xmm1, %xmm3 # 3 = jo
jnz .Ldec_loop
# middle of last round
movdqa 0x60(%r10), %xmm4 # 3 : sbou
pshufb %xmm2, %xmm4 # 4 = sbou
pxor %xmm0, %xmm4 # 4 = sb1u + k
movdqa 0x70(%r10), %xmm0 # 0 : sbot
movdqa -0x160(%r11), %xmm2 # .Lk_sr-.Lk_dsbd=-0x160
pshufb %xmm3, %xmm0 # 0 = sb1t
pxor %xmm4, %xmm0 # 0 = A
pshufb %xmm2, %xmm0
ret
.cfi_endproc
.size _vpaes_decrypt_core,.-_vpaes_decrypt_core
########################################################
## ##
## AES key schedule ##
## ##
########################################################
.type _vpaes_schedule_core,\@abi-omnipotent
.align 16
_vpaes_schedule_core:
.cfi_startproc
# rdi = key
# rsi = size in bits
# rdx = buffer
# rcx = direction. 0=encrypt, 1=decrypt
call _vpaes_preheat # load the tables
movdqa .Lk_rcon(%rip), %xmm8 # load rcon
movdqu (%rdi), %xmm0 # load key (unaligned)
# input transform
movdqa %xmm0, %xmm3
lea .Lk_ipt(%rip), %r11
call _vpaes_schedule_transform
movdqa %xmm0, %xmm7
lea .Lk_sr(%rip),%r10
test %rcx, %rcx
jnz .Lschedule_am_decrypting
# encrypting, output zeroth round key after transform
movdqu %xmm0, (%rdx)
jmp .Lschedule_go
.Lschedule_am_decrypting:
# decrypting, output zeroth round key after shiftrows
movdqa (%r8,%r10),%xmm1
pshufb %xmm1, %xmm3
movdqu %xmm3, (%rdx)
xor \$0x30, %r8
.Lschedule_go:
cmp \$192, %esi
ja .Lschedule_256
je .Lschedule_192
# 128: fall though
##
## .schedule_128
##
## 128-bit specific part of key schedule.
##
## This schedule is really simple, because all its parts
## are accomplished by the subroutines.
##
.Lschedule_128:
mov \$10, %esi
.Loop_schedule_128:
call _vpaes_schedule_round
dec %rsi
jz .Lschedule_mangle_last
call _vpaes_schedule_mangle # write output
jmp .Loop_schedule_128
##
## .aes_schedule_192
##
## 192-bit specific part of key schedule.
##
## The main body of this schedule is the same as the 128-bit
## schedule, but with more smearing. The long, high side is
## stored in %xmm7 as before, and the short, low side is in
## the high bits of %xmm6.
##
## This schedule is somewhat nastier, however, because each
## round produces 192 bits of key material, or 1.5 round keys.
## Therefore, on each cycle we do 2 rounds and produce 3 round
## keys.
##
.align 16
.Lschedule_192:
movdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned)
call _vpaes_schedule_transform # input transform
movdqa %xmm0, %xmm6 # save short part
pxor %xmm4, %xmm4 # clear 4
movhlps %xmm4, %xmm6 # clobber low side with zeros
mov \$4, %esi
.Loop_schedule_192:
call _vpaes_schedule_round
palignr \$8,%xmm6,%xmm0
call _vpaes_schedule_mangle # save key n
call _vpaes_schedule_192_smear
call _vpaes_schedule_mangle # save key n+1
call _vpaes_schedule_round
dec %rsi
jz .Lschedule_mangle_last
call _vpaes_schedule_mangle # save key n+2
call _vpaes_schedule_192_smear
jmp .Loop_schedule_192
##
## .aes_schedule_256
##
## 256-bit specific part of key schedule.
##
## The structure here is very similar to the 128-bit
## schedule, but with an additional "low side" in
## %xmm6. The low side's rounds are the same as the
## high side's, except no rcon and no rotation.
##
.align 16
.Lschedule_256:
movdqu 16(%rdi),%xmm0 # load key part 2 (unaligned)
call _vpaes_schedule_transform # input transform
mov \$7, %esi
.Loop_schedule_256:
call _vpaes_schedule_mangle # output low result
movdqa %xmm0, %xmm6 # save cur_lo in xmm6
# high round
call _vpaes_schedule_round
dec %rsi
jz .Lschedule_mangle_last
call _vpaes_schedule_mangle
# low round. swap xmm7 and xmm6
pshufd \$0xFF, %xmm0, %xmm0
movdqa %xmm7, %xmm5
movdqa %xmm6, %xmm7
call _vpaes_schedule_low_round
movdqa %xmm5, %xmm7
jmp .Loop_schedule_256
##
## .aes_schedule_mangle_last
##
## Mangler for last round of key schedule
## Mangles %xmm0
## when encrypting, outputs out(%xmm0) ^ 63
## when decrypting, outputs unskew(%xmm0)
##
## Always called right before return... jumps to cleanup and exits
##
.align 16
.Lschedule_mangle_last:
# schedule last round key from xmm0
lea .Lk_deskew(%rip),%r11 # prepare to deskew
test %rcx, %rcx
jnz .Lschedule_mangle_last_dec
# encrypting
movdqa (%r8,%r10),%xmm1
pshufb %xmm1, %xmm0 # output permute
lea .Lk_opt(%rip), %r11 # prepare to output transform
add \$32, %rdx
.Lschedule_mangle_last_dec:
add \$-16, %rdx
pxor .Lk_s63(%rip), %xmm0
call _vpaes_schedule_transform # output transform
movdqu %xmm0, (%rdx) # save last key
# cleanup
pxor %xmm0, %xmm0
pxor %xmm1, %xmm1
pxor %xmm2, %xmm2
pxor %xmm3, %xmm3
pxor %xmm4, %xmm4
pxor %xmm5, %xmm5
pxor %xmm6, %xmm6
pxor %xmm7, %xmm7
ret
.cfi_endproc
.size _vpaes_schedule_core,.-_vpaes_schedule_core
##
## .aes_schedule_192_smear
##
## Smear the short, low side in the 192-bit key schedule.
##
## Inputs:
## %xmm7: high side, b a x y
## %xmm6: low side, d c 0 0
## %xmm13: 0
##
## Outputs:
## %xmm6: b+c+d b+c 0 0
## %xmm0: b+c+d b+c b a
##
.type _vpaes_schedule_192_smear,\@abi-omnipotent
.align 16
_vpaes_schedule_192_smear:
.cfi_startproc
pshufd \$0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0
pshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a
pxor %xmm1, %xmm6 # -> c+d c 0 0
pxor %xmm1, %xmm1
pxor %xmm0, %xmm6 # -> b+c+d b+c b a
movdqa %xmm6, %xmm0
movhlps %xmm1, %xmm6 # clobber low side with zeros
ret
.cfi_endproc
.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear
##
## .aes_schedule_round
##
## Runs one main round of the key schedule on %xmm0, %xmm7
##
## Specifically, runs subbytes on the high dword of %xmm0
## then rotates it by one byte and xors into the low dword of
## %xmm7.
##
## Adds rcon from low byte of %xmm8, then rotates %xmm8 for
## next rcon.
##
## Smears the dwords of %xmm7 by xoring the low into the
## second low, result into third, result into highest.
##
## Returns results in %xmm7 = %xmm0.
## Clobbers %xmm1-%xmm4, %r11.
##
.type _vpaes_schedule_round,\@abi-omnipotent
.align 16
_vpaes_schedule_round:
.cfi_startproc
# extract rcon from xmm8
pxor %xmm1, %xmm1
palignr \$15, %xmm8, %xmm1
palignr \$15, %xmm8, %xmm8
pxor %xmm1, %xmm7
# rotate
pshufd \$0xFF, %xmm0, %xmm0
palignr \$1, %xmm0, %xmm0
# fall through...
# low round: same as high round, but no rotation and no rcon.
_vpaes_schedule_low_round:
# smear xmm7
movdqa %xmm7, %xmm1
pslldq \$4, %xmm7
pxor %xmm1, %xmm7
movdqa %xmm7, %xmm1
pslldq \$8, %xmm7
pxor %xmm1, %xmm7
pxor .Lk_s63(%rip), %xmm7
# subbytes
movdqa %xmm9, %xmm1
pandn %xmm0, %xmm1
psrld \$4, %xmm1 # 1 = i
pand %xmm9, %xmm0 # 0 = k
movdqa %xmm11, %xmm2 # 2 : a/k
pshufb %xmm0, %xmm2 # 2 = a/k
pxor %xmm1, %xmm0 # 0 = j
movdqa %xmm10, %xmm3 # 3 : 1/i
pshufb %xmm1, %xmm3 # 3 = 1/i
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
movdqa %xmm10, %xmm4 # 4 : 1/j
pshufb %xmm0, %xmm4 # 4 = 1/j
pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
movdqa %xmm10, %xmm2 # 2 : 1/iak
pshufb %xmm3, %xmm2 # 2 = 1/iak
pxor %xmm0, %xmm2 # 2 = io
movdqa %xmm10, %xmm3 # 3 : 1/jak
pshufb %xmm4, %xmm3 # 3 = 1/jak
pxor %xmm1, %xmm3 # 3 = jo
movdqa %xmm13, %xmm4 # 4 : sbou
pshufb %xmm2, %xmm4 # 4 = sbou
movdqa %xmm12, %xmm0 # 0 : sbot
pshufb %xmm3, %xmm0 # 0 = sb1t
pxor %xmm4, %xmm0 # 0 = sbox output
# add in smeared stuff
pxor %xmm7, %xmm0
movdqa %xmm0, %xmm7
ret
.cfi_endproc
.size _vpaes_schedule_round,.-_vpaes_schedule_round
##
## .aes_schedule_transform
##
## Linear-transform %xmm0 according to tables at (%r11)
##
## Requires that %xmm9 = 0x0F0F... as in preheat
## Output in %xmm0
## Clobbers %xmm1, %xmm2
##
.type _vpaes_schedule_transform,\@abi-omnipotent
.align 16
_vpaes_schedule_transform:
.cfi_startproc
movdqa %xmm9, %xmm1
pandn %xmm0, %xmm1
psrld \$4, %xmm1
pand %xmm9, %xmm0
movdqa (%r11), %xmm2 # lo
pshufb %xmm0, %xmm2
movdqa 16(%r11), %xmm0 # hi
pshufb %xmm1, %xmm0
pxor %xmm2, %xmm0
ret
.cfi_endproc
.size _vpaes_schedule_transform,.-_vpaes_schedule_transform
##
## .aes_schedule_mangle
##
## Mangle xmm0 from (basis-transformed) standard version
## to our version.
##
## On encrypt,
## xor with 0x63
## multiply by circulant 0,1,1,1
## apply shiftrows transform
##
## On decrypt,
## xor with 0x63
## multiply by "inverse mixcolumns" circulant E,B,D,9
## deskew
## apply shiftrows transform
##
##
## Writes out to (%rdx), and increments or decrements it
## Keeps track of round number mod 4 in %r8
## Preserves xmm0
## Clobbers xmm1-xmm5
##
.type _vpaes_schedule_mangle,\@abi-omnipotent
.align 16
_vpaes_schedule_mangle:
.cfi_startproc
movdqa %xmm0, %xmm4 # save xmm0 for later
movdqa .Lk_mc_forward(%rip),%xmm5
test %rcx, %rcx
jnz .Lschedule_mangle_dec
# encrypting
add \$16, %rdx
pxor .Lk_s63(%rip),%xmm4
pshufb %xmm5, %xmm4
movdqa %xmm4, %xmm3
pshufb %xmm5, %xmm4
pxor %xmm4, %xmm3
pshufb %xmm5, %xmm4
pxor %xmm4, %xmm3
jmp .Lschedule_mangle_both
.align 16
.Lschedule_mangle_dec:
# inverse mix columns
lea .Lk_dksd(%rip),%r11
movdqa %xmm9, %xmm1
pandn %xmm4, %xmm1
psrld \$4, %xmm1 # 1 = hi
pand %xmm9, %xmm4 # 4 = lo
movdqa 0x00(%r11), %xmm2
pshufb %xmm4, %xmm2
movdqa 0x10(%r11), %xmm3
pshufb %xmm1, %xmm3
pxor %xmm2, %xmm3
pshufb %xmm5, %xmm3
movdqa 0x20(%r11), %xmm2
pshufb %xmm4, %xmm2
pxor %xmm3, %xmm2
movdqa 0x30(%r11), %xmm3
pshufb %xmm1, %xmm3
pxor %xmm2, %xmm3
pshufb %xmm5, %xmm3
movdqa 0x40(%r11), %xmm2
pshufb %xmm4, %xmm2
pxor %xmm3, %xmm2
movdqa 0x50(%r11), %xmm3
pshufb %xmm1, %xmm3
pxor %xmm2, %xmm3
pshufb %xmm5, %xmm3
movdqa 0x60(%r11), %xmm2
pshufb %xmm4, %xmm2
pxor %xmm3, %xmm2
movdqa 0x70(%r11), %xmm3
pshufb %xmm1, %xmm3
pxor %xmm2, %xmm3
add \$-16, %rdx
.Lschedule_mangle_both:
movdqa (%r8,%r10),%xmm1
pshufb %xmm1,%xmm3
add \$-16, %r8
and \$0x30, %r8
movdqu %xmm3, (%rdx)
ret
.cfi_endproc
.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle
#
# Interface to OpenSSL
#
.globl ${PREFIX}_set_encrypt_key
.type ${PREFIX}_set_encrypt_key,\@function,3
.align 16
${PREFIX}_set_encrypt_key:
.cfi_startproc
endbranch
___
$code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x20(%rsp)
movaps %xmm8,0x30(%rsp)
movaps %xmm9,0x40(%rsp)
movaps %xmm10,0x50(%rsp)
movaps %xmm11,0x60(%rsp)
movaps %xmm12,0x70(%rsp)
movaps %xmm13,0x80(%rsp)
movaps %xmm14,0x90(%rsp)
movaps %xmm15,0xa0(%rsp)
.Lenc_key_body:
___
$code.=<<___;
mov %esi,%eax
shr \$5,%eax
add \$5,%eax
mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5;
mov \$0,%ecx
mov \$0x30,%r8d
call _vpaes_schedule_core
___
$code.=<<___ if ($win64);
movaps 0x10(%rsp),%xmm6
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm8
movaps 0x40(%rsp),%xmm9
movaps 0x50(%rsp),%xmm10
movaps 0x60(%rsp),%xmm11
movaps 0x70(%rsp),%xmm12
movaps 0x80(%rsp),%xmm13
movaps 0x90(%rsp),%xmm14
movaps 0xa0(%rsp),%xmm15
lea 0xb8(%rsp),%rsp
.Lenc_key_epilogue:
___
$code.=<<___;
xor %eax,%eax
ret
.cfi_endproc
.size ${PREFIX}_set_encrypt_key,.-${PREFIX}_set_encrypt_key
.globl ${PREFIX}_set_decrypt_key
.type ${PREFIX}_set_decrypt_key,\@function,3
.align 16
${PREFIX}_set_decrypt_key:
.cfi_startproc
endbranch
___
$code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x20(%rsp)
movaps %xmm8,0x30(%rsp)
movaps %xmm9,0x40(%rsp)
movaps %xmm10,0x50(%rsp)
movaps %xmm11,0x60(%rsp)
movaps %xmm12,0x70(%rsp)
movaps %xmm13,0x80(%rsp)
movaps %xmm14,0x90(%rsp)
movaps %xmm15,0xa0(%rsp)
.Ldec_key_body:
___
$code.=<<___;
mov %esi,%eax
shr \$5,%eax
add \$5,%eax
mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5;
shl \$4,%eax
lea 16(%rdx,%rax),%rdx
mov \$1,%ecx
mov %esi,%r8d
shr \$1,%r8d
and \$32,%r8d
xor \$32,%r8d # nbits==192?0:32
call _vpaes_schedule_core
___
$code.=<<___ if ($win64);
movaps 0x10(%rsp),%xmm6
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm8
movaps 0x40(%rsp),%xmm9
movaps 0x50(%rsp),%xmm10
movaps 0x60(%rsp),%xmm11
movaps 0x70(%rsp),%xmm12
movaps 0x80(%rsp),%xmm13
movaps 0x90(%rsp),%xmm14
movaps 0xa0(%rsp),%xmm15
lea 0xb8(%rsp),%rsp
.Ldec_key_epilogue:
___
$code.=<<___;
xor %eax,%eax
ret
.cfi_endproc
.size ${PREFIX}_set_decrypt_key,.-${PREFIX}_set_decrypt_key
.globl ${PREFIX}_encrypt
.type ${PREFIX}_encrypt,\@function,3
.align 16
${PREFIX}_encrypt:
.cfi_startproc
endbranch
___
$code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x20(%rsp)
movaps %xmm8,0x30(%rsp)
movaps %xmm9,0x40(%rsp)
movaps %xmm10,0x50(%rsp)
movaps %xmm11,0x60(%rsp)
movaps %xmm12,0x70(%rsp)
movaps %xmm13,0x80(%rsp)
movaps %xmm14,0x90(%rsp)
movaps %xmm15,0xa0(%rsp)
.Lenc_body:
___
$code.=<<___;
movdqu (%rdi),%xmm0
call _vpaes_preheat
call _vpaes_encrypt_core
movdqu %xmm0,(%rsi)
___
$code.=<<___ if ($win64);
movaps 0x10(%rsp),%xmm6
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm8
movaps 0x40(%rsp),%xmm9
movaps 0x50(%rsp),%xmm10
movaps 0x60(%rsp),%xmm11
movaps 0x70(%rsp),%xmm12
movaps 0x80(%rsp),%xmm13
movaps 0x90(%rsp),%xmm14
movaps 0xa0(%rsp),%xmm15
lea 0xb8(%rsp),%rsp
.Lenc_epilogue:
___
$code.=<<___;
ret
.cfi_endproc
.size ${PREFIX}_encrypt,.-${PREFIX}_encrypt
.globl ${PREFIX}_decrypt
.type ${PREFIX}_decrypt,\@function,3
.align 16
${PREFIX}_decrypt:
.cfi_startproc
endbranch
___
$code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x20(%rsp)
movaps %xmm8,0x30(%rsp)
movaps %xmm9,0x40(%rsp)
movaps %xmm10,0x50(%rsp)
movaps %xmm11,0x60(%rsp)
movaps %xmm12,0x70(%rsp)
movaps %xmm13,0x80(%rsp)
movaps %xmm14,0x90(%rsp)
movaps %xmm15,0xa0(%rsp)
.Ldec_body:
___
$code.=<<___;
movdqu (%rdi),%xmm0
call _vpaes_preheat
call _vpaes_decrypt_core
movdqu %xmm0,(%rsi)
___
$code.=<<___ if ($win64);
movaps 0x10(%rsp),%xmm6
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm8
movaps 0x40(%rsp),%xmm9
movaps 0x50(%rsp),%xmm10
movaps 0x60(%rsp),%xmm11
movaps 0x70(%rsp),%xmm12
movaps 0x80(%rsp),%xmm13
movaps 0x90(%rsp),%xmm14
movaps 0xa0(%rsp),%xmm15
lea 0xb8(%rsp),%rsp
.Ldec_epilogue:
___
$code.=<<___;
ret
.cfi_endproc
.size ${PREFIX}_decrypt,.-${PREFIX}_decrypt
___
{
my ($inp,$out,$len,$key,$ivp,$enc)=("%rdi","%rsi","%rdx","%rcx","%r8","%r9");
# void AES_cbc_encrypt (const void char *inp, unsigned char *out,
# size_t length, const AES_KEY *key,
# unsigned char *ivp,const int enc);
$code.=<<___;
.globl ${PREFIX}_cbc_encrypt
.type ${PREFIX}_cbc_encrypt,\@function,6
.align 16
${PREFIX}_cbc_encrypt:
.cfi_startproc
endbranch
xchg $key,$len
___
($len,$key)=($key,$len);
$code.=<<___;
sub \$16,$len
jc .Lcbc_abort
___
$code.=<<___ if ($win64);
lea -0xb8(%rsp),%rsp
movaps %xmm6,0x10(%rsp)
movaps %xmm7,0x20(%rsp)
movaps %xmm8,0x30(%rsp)
movaps %xmm9,0x40(%rsp)
movaps %xmm10,0x50(%rsp)
movaps %xmm11,0x60(%rsp)
movaps %xmm12,0x70(%rsp)
movaps %xmm13,0x80(%rsp)
movaps %xmm14,0x90(%rsp)
movaps %xmm15,0xa0(%rsp)
.Lcbc_body:
___
$code.=<<___;
movdqu ($ivp),%xmm6 # load IV
sub $inp,$out
call _vpaes_preheat
cmp \$0,${enc}d
je .Lcbc_dec_loop
jmp .Lcbc_enc_loop
.align 16
.Lcbc_enc_loop:
movdqu ($inp),%xmm0
pxor %xmm6,%xmm0
call _vpaes_encrypt_core
movdqa %xmm0,%xmm6
movdqu %xmm0,($out,$inp)
lea 16($inp),$inp
sub \$16,$len
jnc .Lcbc_enc_loop
jmp .Lcbc_done
.align 16
.Lcbc_dec_loop:
movdqu ($inp),%xmm0
movdqa %xmm0,%xmm7
call _vpaes_decrypt_core
pxor %xmm6,%xmm0
movdqa %xmm7,%xmm6
movdqu %xmm0,($out,$inp)
lea 16($inp),$inp
sub \$16,$len
jnc .Lcbc_dec_loop
.Lcbc_done:
movdqu %xmm6,($ivp) # save IV
___
$code.=<<___ if ($win64);
movaps 0x10(%rsp),%xmm6
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm8
movaps 0x40(%rsp),%xmm9
movaps 0x50(%rsp),%xmm10
movaps 0x60(%rsp),%xmm11
movaps 0x70(%rsp),%xmm12
movaps 0x80(%rsp),%xmm13
movaps 0x90(%rsp),%xmm14
movaps 0xa0(%rsp),%xmm15
lea 0xb8(%rsp),%rsp
.Lcbc_epilogue:
___
$code.=<<___;
.Lcbc_abort:
ret
.cfi_endproc
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
___
}
$code.=<<___;
##
## _aes_preheat
##
## Fills register %r10 -> .aes_consts (so you can -fPIC)
## and %xmm9-%xmm15 as specified below.
##
.type _vpaes_preheat,\@abi-omnipotent
.align 16
_vpaes_preheat:
.cfi_startproc
lea .Lk_s0F(%rip), %r10
movdqa -0x20(%r10), %xmm10 # .Lk_inv
movdqa -0x10(%r10), %xmm11 # .Lk_inv+16
movdqa 0x00(%r10), %xmm9 # .Lk_s0F
movdqa 0x30(%r10), %xmm13 # .Lk_sb1
movdqa 0x40(%r10), %xmm12 # .Lk_sb1+16
movdqa 0x50(%r10), %xmm15 # .Lk_sb2
movdqa 0x60(%r10), %xmm14 # .Lk_sb2+16
ret
.cfi_endproc
.size _vpaes_preheat,.-_vpaes_preheat
########################################################
## ##
## Constants ##
## ##
########################################################
.type _vpaes_consts,\@object
.align 64
_vpaes_consts:
.Lk_inv: # inv, inva
.quad 0x0E05060F0D080180, 0x040703090A0B0C02
.quad 0x01040A060F0B0780, 0x030D0E0C02050809
.Lk_s0F: # s0F
.quad 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F
.Lk_ipt: # input transform (lo, hi)
.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808
.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81
.Lk_sb1: # sb1u, sb1t
.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544
.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF
.Lk_sb2: # sb2u, sb2t
.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD
.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A
.Lk_sbo: # sbou, sbot
.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878
.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA
.Lk_mc_forward: # mc_forward
.quad 0x0407060500030201, 0x0C0F0E0D080B0A09
.quad 0x080B0A0904070605, 0x000302010C0F0E0D
.quad 0x0C0F0E0D080B0A09, 0x0407060500030201
.quad 0x000302010C0F0E0D, 0x080B0A0904070605
.Lk_mc_backward:# mc_backward
.quad 0x0605040702010003, 0x0E0D0C0F0A09080B
.quad 0x020100030E0D0C0F, 0x0A09080B06050407
.quad 0x0E0D0C0F0A09080B, 0x0605040702010003
.quad 0x0A09080B06050407, 0x020100030E0D0C0F
.Lk_sr: # sr
.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908
.quad 0x030E09040F0A0500, 0x0B06010C07020D08
.quad 0x0F060D040B020900, 0x070E050C030A0108
.quad 0x0B0E0104070A0D00, 0x0306090C0F020508
.Lk_rcon: # rcon
.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81
.Lk_s63: # s63: all equal to 0x63 transformed
.quad 0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B
.Lk_opt: # output transform
.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808
.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0
.Lk_deskew: # deskew tables: inverts the sbox's "skew"
.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A
.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77
##
## Decryption stuff
## Key schedule constants
##
.Lk_dksd: # decryption key schedule: invskew x*D
.quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9
.quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E
.Lk_dksb: # decryption key schedule: invskew x*B
.quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99
.quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8
.Lk_dkse: # decryption key schedule: invskew x*E + 0x63
.quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086
.quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487
.Lk_dks9: # decryption key schedule: invskew x*9
.quad 0xB6116FC87ED9A700, 0x4AED933482255BFC
.quad 0x4576516227143300, 0x8BB89FACE9DAFDCE
##
## Decryption stuff
## Round function constants
##
.Lk_dipt: # decryption input transform
.quad 0x0F505B040B545F00, 0x154A411E114E451A
.quad 0x86E383E660056500, 0x12771772F491F194
.Lk_dsb9: # decryption sbox output *9*u, *9*t
.quad 0x851C03539A86D600, 0xCAD51F504F994CC9
.quad 0xC03B1789ECD74900, 0x725E2C9EB2FBA565
.Lk_dsbd: # decryption sbox output *D*u, *D*t
.quad 0x7D57CCDFE6B1A200, 0xF56E9B13882A4439
.quad 0x3CE2FAF724C6CB00, 0x2931180D15DEEFD3
.Lk_dsbb: # decryption sbox output *B*u, *B*t
.quad 0xD022649296B44200, 0x602646F6B0F2D404
.quad 0xC19498A6CD596700, 0xF3FF0C3E3255AA6B
.Lk_dsbe: # decryption sbox output *E*u, *E*t
.quad 0x46F2929626D4D000, 0x2242600464B4F6B0
.quad 0x0C55A6CDFFAAC100, 0x9467F36B98593E32
.Lk_dsbo: # decryption sbox final output
.quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D
.quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C
.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
.align 64
.size _vpaes_consts,.-_vpaes_consts
___
if ($win64) {
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
# CONTEXT *context,DISPATCHER_CONTEXT *disp)
$rec="%rcx";
$frame="%rdx";
$context="%r8";
$disp="%r9";
$code.=<<___;
.extern __imp_RtlVirtualUnwind
.type se_handler,\@abi-omnipotent
.align 16
se_handler:
push %rsi
push %rdi
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
pushfq
sub \$64,%rsp
mov 120($context),%rax # pull context->Rax
mov 248($context),%rbx # pull context->Rip
mov 8($disp),%rsi # disp->ImageBase
mov 56($disp),%r11 # disp->HandlerData
mov 0(%r11),%r10d # HandlerData[0]
lea (%rsi,%r10),%r10 # prologue label
cmp %r10,%rbx # context->Rip<prologue label
jb .Lin_prologue
mov 152($context),%rax # pull context->Rsp
mov 4(%r11),%r10d # HandlerData[1]
lea (%rsi,%r10),%r10 # epilogue label
cmp %r10,%rbx # context->Rip>=epilogue label
jae .Lin_prologue
lea 16(%rax),%rsi # %xmm save area
lea 512($context),%rdi # &context.Xmm6
mov \$20,%ecx # 10*sizeof(%xmm0)/sizeof(%rax)
.long 0xa548f3fc # cld; rep movsq
lea 0xb8(%rax),%rax # adjust stack pointer
.Lin_prologue:
mov 8(%rax),%rdi
mov 16(%rax),%rsi
mov %rax,152($context) # restore context->Rsp
mov %rsi,168($context) # restore context->Rsi
mov %rdi,176($context) # restore context->Rdi
mov 40($disp),%rdi # disp->ContextRecord
mov $context,%rsi # context
mov \$`1232/8`,%ecx # sizeof(CONTEXT)
.long 0xa548f3fc # cld; rep movsq
mov $disp,%rsi
xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
mov 8(%rsi),%rdx # arg2, disp->ImageBase
mov 0(%rsi),%r8 # arg3, disp->ControlPc
mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
mov 40(%rsi),%r10 # disp->ContextRecord
lea 56(%rsi),%r11 # &disp->HandlerData
lea 24(%rsi),%r12 # &disp->EstablisherFrame
mov %r10,32(%rsp) # arg5
mov %r11,40(%rsp) # arg6
mov %r12,48(%rsp) # arg7
mov %rcx,56(%rsp) # arg8, (NULL)
call *__imp_RtlVirtualUnwind(%rip)
mov \$1,%eax # ExceptionContinueSearch
add \$64,%rsp
popfq
pop %r15
pop %r14
pop %r13
pop %r12
pop %rbp
pop %rbx
pop %rdi
pop %rsi
ret
.size se_handler,.-se_handler
.section .pdata
.align 4
.rva .LSEH_begin_${PREFIX}_set_encrypt_key
.rva .LSEH_end_${PREFIX}_set_encrypt_key
.rva .LSEH_info_${PREFIX}_set_encrypt_key
.rva .LSEH_begin_${PREFIX}_set_decrypt_key
.rva .LSEH_end_${PREFIX}_set_decrypt_key
.rva .LSEH_info_${PREFIX}_set_decrypt_key
.rva .LSEH_begin_${PREFIX}_encrypt
.rva .LSEH_end_${PREFIX}_encrypt
.rva .LSEH_info_${PREFIX}_encrypt
.rva .LSEH_begin_${PREFIX}_decrypt
.rva .LSEH_end_${PREFIX}_decrypt
.rva .LSEH_info_${PREFIX}_decrypt
.rva .LSEH_begin_${PREFIX}_cbc_encrypt
.rva .LSEH_end_${PREFIX}_cbc_encrypt
.rva .LSEH_info_${PREFIX}_cbc_encrypt
.section .xdata
.align 8
.LSEH_info_${PREFIX}_set_encrypt_key:
.byte 9,0,0,0
.rva se_handler
.rva .Lenc_key_body,.Lenc_key_epilogue # HandlerData[]
.LSEH_info_${PREFIX}_set_decrypt_key:
.byte 9,0,0,0
.rva se_handler
.rva .Ldec_key_body,.Ldec_key_epilogue # HandlerData[]
.LSEH_info_${PREFIX}_encrypt:
.byte 9,0,0,0
.rva se_handler
.rva .Lenc_body,.Lenc_epilogue # HandlerData[]
.LSEH_info_${PREFIX}_decrypt:
.byte 9,0,0,0
.rva se_handler
.rva .Ldec_body,.Ldec_epilogue # HandlerData[]
.LSEH_info_${PREFIX}_cbc_encrypt:
.byte 9,0,0,0
.rva se_handler
.rva .Lcbc_body,.Lcbc_epilogue # HandlerData[]
___
}
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT or die "error closing STDOUT: $!";
| 25.309848 | 84 | 0.665444 |
73d56ddfa5091b7d830f74100875a68fd429aeb1 | 4,861 | pm | Perl | Git/usr/share/perl5/vendor_perl/URI/QueryParam.pm | DalalBassam/myrecipeswebsite | 1ac6e97b6bac19b6d8a06d8ebf36e1f1b79a18f4 | [
"MIT"
] | 2 | 2019-04-15T04:28:23.000Z | 2019-04-16T12:45:51.000Z | Git/usr/share/perl5/vendor_perl/URI/QueryParam.pm | DalalBassam/myrecipeswebsite | 1ac6e97b6bac19b6d8a06d8ebf36e1f1b79a18f4 | [
"MIT"
] | 16 | 2019-08-28T23:45:01.000Z | 2019-12-20T02:12:13.000Z | Git/usr/share/perl5/vendor_perl/URI/QueryParam.pm | DalalBassam/myrecipeswebsite | 1ac6e97b6bac19b6d8a06d8ebf36e1f1b79a18f4 | [
"MIT"
] | 1 | 2020-11-04T07:54:34.000Z | 2020-11-04T07:54:34.000Z | package URI::QueryParam;
use strict;
use warnings;
our $VERSION = '1.74';
sub URI::_query::query_param {
my $self = shift;
my @old = $self->query_form;
if (@_ == 0) {
# get keys
my (%seen, $i);
return grep !($i++ % 2 || $seen{$_}++), @old;
}
my $key = shift;
my @i = grep $_ % 2 == 0 && $old[$_] eq $key, 0 .. $#old;
if (@_) {
my @new = @old;
my @new_i = @i;
my @vals = map { ref($_) eq 'ARRAY' ? @$_ : $_ } @_;
while (@new_i > @vals) {
splice @new, pop @new_i, 2;
}
if (@vals > @new_i) {
my $i = @new_i ? $new_i[-1] + 2 : @new;
my @splice = splice @vals, @new_i, @vals - @new_i;
splice @new, $i, 0, map { $key => $_ } @splice;
}
if (@vals) {
#print "SET $new_i[0]\n";
@new[ map $_ + 1, @new_i ] = @vals;
}
$self->query_form(\@new);
}
return wantarray ? @old[map $_+1, @i] : @i ? $old[$i[0]+1] : undef;
}
sub URI::_query::query_param_append {
my $self = shift;
my $key = shift;
my @vals = map { ref $_ eq 'ARRAY' ? @$_ : $_ } @_;
$self->query_form($self->query_form, $key => \@vals); # XXX
return;
}
sub URI::_query::query_param_delete {
my $self = shift;
my $key = shift;
my @old = $self->query_form;
my @vals;
for (my $i = @old - 2; $i >= 0; $i -= 2) {
next if $old[$i] ne $key;
push(@vals, (splice(@old, $i, 2))[1]);
}
$self->query_form(\@old) if @vals;
return wantarray ? reverse @vals : $vals[-1];
}
sub URI::_query::query_form_hash {
my $self = shift;
my @old = $self->query_form;
if (@_) {
$self->query_form(@_ == 1 ? %{shift(@_)} : @_);
}
my %hash;
while (my($k, $v) = splice(@old, 0, 2)) {
if (exists $hash{$k}) {
for ($hash{$k}) {
$_ = [$_] unless ref($_) eq "ARRAY";
push(@$_, $v);
}
}
else {
$hash{$k} = $v;
}
}
return \%hash;
}
1;
__END__
=head1 NAME
URI::QueryParam - Additional query methods for URIs
=head1 SYNOPSIS
use URI;
use URI::QueryParam;
$u = URI->new("", "http");
$u->query_param(foo => 1, 2, 3);
print $u->query; # prints foo=1&foo=2&foo=3
for my $key ($u->query_param) {
print "$key: ", join(", ", $u->query_param($key)), "\n";
}
=head1 DESCRIPTION
Loading the C<URI::QueryParam> module adds some extra methods to
URIs that support query methods. These methods provide an alternative
interface to the $u->query_form data.
The query_param_* methods have deliberately been made identical to the
interface of the corresponding C<CGI.pm> methods.
The following additional methods are made available:
=over
=item @keys = $u->query_param
=item @values = $u->query_param( $key )
=item $first_value = $u->query_param( $key )
=item $u->query_param( $key, $value,... )
If $u->query_param is called with no arguments, it returns all the
distinct parameter keys of the URI. In a scalar context it returns the
number of distinct keys.
When a $key argument is given, the method returns the parameter values with the
given key. In a scalar context, only the first parameter value is
returned.
If additional arguments are given, they are used to update successive
parameters with the given key. If any of the values provided are
array references, then the array is dereferenced to get the actual
values.
Please note that you can supply multiple values to this method, but you cannot
supply multiple keys.
Do this:
$uri->query_param( widget_id => 1, 5, 9 );
Do NOT do this:
$uri->query_param( widget_id => 1, frobnicator_id => 99 );
=item $u->query_param_append($key, $value,...)
Adds new parameters with the given
key without touching any old parameters with the same key. It
can be explained as a more efficient version of:
$u->query_param($key,
$u->query_param($key),
$value,...);
One difference is that this expression would return the old values
of $key, whereas the query_param_append() method does not.
=item @values = $u->query_param_delete($key)
=item $first_value = $u->query_param_delete($key)
Deletes all key/value pairs with the given key.
The old values are returned. In a scalar context, only the first value
is returned.
Using the query_param_delete() method is slightly more efficient than
the equivalent:
$u->query_param($key, []);
=item $hashref = $u->query_form_hash
=item $u->query_form_hash( \%new_form )
Returns a reference to a hash that represents the
query form's key/value pairs. If a key occurs multiple times, then the hash
value becomes an array reference.
Note that sequence information is lost. This means that:
$u->query_form_hash($u->query_form_hash);
is not necessarily a no-op, as it may reorder the key/value pairs.
The values returned by the query_param() method should stay the same
though.
=back
=head1 SEE ALSO
L<URI>, L<CGI>
=head1 COPYRIGHT
Copyright 2002 Gisle Aas.
=cut
| 23.370192 | 79 | 0.63238 |
edaacd6f96cf724dd41357c88a071e7e647af736 | 1,373 | pm | Perl | pdu-perl-api/Raritan/RPC/assetmgrmodel/AssetStrip_2_0_2/StripInfoChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 1 | 2021-04-29T23:04:17.000Z | 2021-04-29T23:04:17.000Z | pdu-perl-api/Raritan/RPC/assetmgrmodel/AssetStrip_2_0_2/StripInfoChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | null | null | null | pdu-perl-api/Raritan/RPC/assetmgrmodel/AssetStrip_2_0_2/StripInfoChangedEvent.pm | gregoa/raritan-pdu-json-rpc-sdk | 76df982462742b97b52872aa34630140f5df7e58 | [
"BSD-3-Clause"
] | 2 | 2020-06-20T16:21:23.000Z | 2021-09-28T19:04:44.000Z | # SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from AssetStrip.idl.
use strict;
package Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfoChangedEvent;
use constant typeId => "assetmgrmodel.AssetStrip_2_0_2.StripInfoChangedEvent:1.0.0";
use Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo;
use Raritan::RPC::idl::Event;
use Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo;
sub encode {
my ($in) = @_;
my $encoded = Raritan::RPC::idl::Event::encode($in);
$encoded->{'oldInfo'} = Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo::encode($in->{'oldInfo'});
$encoded->{'newInfo'} = Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo::encode($in->{'newInfo'});
return $encoded;
}
sub decode {
my ($agent, $in) = @_;
my $decoded = Raritan::RPC::idl::Event::decode($agent, $in);
$decoded->{'oldInfo'} = Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo::decode($agent, $in->{'oldInfo'});
$decoded->{'newInfo'} = Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfo::decode($agent, $in->{'newInfo'});
return $decoded;
}
Raritan::RPC::Registry::registerCodecClass('assetmgrmodel.AssetStrip_2_0_2.StripInfoChangedEvent', 1, 0, 0, 'Raritan::RPC::assetmgrmodel::AssetStrip_2_0_2::StripInfoChangedEvent');
1;
| 40.382353 | 180 | 0.717407 |
ed7b39c8830b4a1dd7b4bc966682640f37a951be | 2,136 | pl | Perl | Scripts/1.preprocess/SplitFa2Chr_G4Predict.pl | dulunar/G4-miner | 23ff6c8a2403dee91862e5d3913eb2c1c974e294 | [
"MIT"
] | 4 | 2021-09-19T16:04:27.000Z | 2022-03-24T05:33:55.000Z | Scripts/1.preprocess/SplitFa2Chr_G4Predict.pl | dulunar/G4-miner | 23ff6c8a2403dee91862e5d3913eb2c1c974e294 | [
"MIT"
] | null | null | null | Scripts/1.preprocess/SplitFa2Chr_G4Predict.pl | dulunar/G4-miner | 23ff6c8a2403dee91862e5d3913eb2c1c974e294 | [
"MIT"
] | 1 | 2021-09-19T17:30:50.000Z | 2021-09-19T17:30:50.000Z | #!/usr/bin/perl -w
#########################################################################
# FileName: SplitFa2Chr_G4Predict.pl
# Version: 96a78e56-2c37-4de2-9a77-1ce128c2d58e
# Author: Luna <nlu@seu.edu.cn>
# CreatedTime: Thu Sep 9 16:58:20 2021
#########################################################################
use strict;
use Getopt::Long;
use File::Basename;
my $red = "\033[0;31m";
my $end = "\033[0m";
my ($in, $dir, $py2, $G4Predict, $help);
GetOptions
(
"i|in=s"=>\$in,
"d|dir=s"=>\$dir,
"p|py=s"=>\$py2,
"g|g4=s"=>\$G4Predict,
"help|?"=>\$help,
);
my $usage=<<INFO;
Usage:
${red}1. Split the whole genome reference fasta to each chr fasta$end
${red}2. Using g4predict intra for predicting putative G Quadruplexes in each chromosome$end
perl $0
-i <the whole genome reference fasta file>
${red}-d <the directory for saving the chromosome fa file> $end
-p <the absolute path of python2> (default: `which python2`)
-g <the absolute path of g4predict> (default: `which g4predict`)
INFO
die "$usage\n" if ($help || !$in || !$dir);
$py2 ||= `which python2`;
$py2=~s/^\s+|\s+$//g;
die "${red}There did not install python2 $py2$end\n" if(!$py2);
$G4Predict ||= `which g4predict`;
$G4Predict=~s/^\s+|\s+$//g;
die "${red}There did not install g4predict $G4Predict$end\n" if(!$G4Predict);
if($in =~ /\.gz$/)
{
open IN, "gzip -dc $in |" || die $!;
}
else
{
open IN,"$in" || die $!;
}
my @chrs = ();
while (<IN>)
{
chomp;
if ($_ =~ />(.*)/)
{
my $chr = $1;
my $out = "$chr.fa";
if(!-e "$dir/$chr")
{
`mkdir -p $dir/$chr` || die "${red}Error: can't create $dir/$chr$end\n";
}
push(@chrs, $chr);
open OUT, "> $dir/$chr/$out" || die $!;
print OUT "$_\n";
}
else
{
print OUT "$_\n";
}
}
close IN;
close OUT;
for my $chr(@chrs)
{
my $fa = "$dir/$chr/$chr.fa";
my $cmd = "$py2 $G4Predict intra -f $fa -b $dir/$chr/PQ_g4predict.bed -s -M";
print "NOTICE: run this command\n${red}$cmd$end\n";
system('$cmd');
}
print "${red}$in was splitted into chromosome fa in $dir$end\n";
print "${red}PQs of each chromosome were predicted by $G4Predict, saved into $dir/chr*$end\n";
| 22.967742 | 94 | 0.562734 |
ed1d0e195999b661208d7018552d2e09fcf78ef4 | 39,712 | pl | Perl | util/mk1mf.pl | lades-unb/openssl | 026e012b3d1aadb754e40b52250ea0d3be4eff6d | [
"OpenSSL"
] | null | null | null | util/mk1mf.pl | lades-unb/openssl | 026e012b3d1aadb754e40b52250ea0d3be4eff6d | [
"OpenSSL"
] | null | null | null | util/mk1mf.pl | lades-unb/openssl | 026e012b3d1aadb754e40b52250ea0d3be4eff6d | [
"OpenSSL"
] | null | null | null | #!/usr/bin/env perl
# A bit of an evil hack but it post processes the file ../MINFO which
# is generated by `make files` in the top directory.
# This script outputs one mega makefile that has no shell stuff or any
# funny stuff (if the target is not "copy").
# If the target is "copy", then it tries to create a makefile that can be
# safely used with the -j flag and that is compatible with the top-level
# Makefile, in the sense that it uses the same options and assembler files etc.
use Cwd;
$INSTALLTOP="/usr/local";
$OPENSSLDIR="/usr/local/ssl";
$OPTIONS="";
$ssl_version="";
$banner="\t\@echo Building OpenSSL";
my $no_static_engine = 1;
my $engines = "";
my @engines_obj = "";
my $otherlibs = "";
local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
local $zlib_lib = "";
local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
local $fips_canister_path = "";
my $fips_premain_dso_exe_path = "";
my $fips_premain_c_path = "";
my $fips_sha1_exe_path = "";
local $fipscanisterbuild = 0;
my $fipscanisteronly = 0;
my $fipslibdir = "";
my $baseaddr = "";
my $ex_l_libs = "";
my $build_targets = "lib exe";
my $libs_dep = "\$(O_CRYPTO) \$(O_SSL)";
# Options to import from top level Makefile
my %mf_import = (
VERSION => \$ssl_version,
OPTIONS => \$OPTIONS,
INSTALLTOP => \$INSTALLTOP,
OPENSSLDIR => \$OPENSSLDIR,
PLATFORM => \$mf_platform,
CC => \$mf_cc,
CFLAG => \$mf_cflag,
DEPFLAG => \$mf_depflag,
CPUID_OBJ => \$mf_cpuid_asm,
BN_ASM => \$mf_bn_asm,
DES_ENC => \$mf_des_asm,
AES_ENC => \$mf_aes_asm,
BF_ENC => \$mf_bf_asm,
CAST_ENC => \$mf_cast_asm,
RC4_ENC => \$mf_rc4_asm,
RC5_ENC => \$mf_rc5_asm,
MD5_ASM_OBJ => \$mf_md5_asm,
SHA1_ASM_OBJ => \$mf_sha_asm,
RMD160_ASM_OBJ => \$mf_rmd_asm,
WP_ASM_OBJ => \$mf_wp_asm,
CMLL_ENC => \$mf_cm_asm,
MODES_ASM_OBJ => \$mf_modes_asm,
ENGINES_ASM_OBJ=> \$mf_engines_asm,
PERLASM_SCHEME => \$mf_perlasm_scheme,
FIPSCANISTERONLY => \$mf_fipscanisteronly,
FIPSCANISTERINTERNAL => \$mf_fipscanisterinternal,
EC_ASM => \$mf_ec_asm,
);
open(IN,"<Makefile") || die "unable to open Makefile!\n";
while(<IN>) {
my ($mf_opt, $mf_ref);
while (($mf_opt, $mf_ref) = each %mf_import) {
if (/^$mf_opt\s*=\s*(.*)$/ && !defined($$mfref)) {
$$mf_ref = $1;
}
}
}
close(IN);
if ($mf_fipscanisterinternal eq "y") {
$fips = 1;
$fipscanisterbuild = 1;
$fipscanisteronly = 1;
}
die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
$infile="MINFO";
%ops=(
"VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
"VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
"VC-WIN64A", "Microsoft C/C++ - Win64/x64",
"VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
"VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
"Mingw32", "GNU C++ - Windows NT or 9x",
"Mingw32-files", "Create files with DOS copy ...",
"BC-NT", "Borland C++ 4.5 - Windows NT",
"linux-elf","Linux elf",
"ultrix-mips","DEC mips ultrix",
"FreeBSD","FreeBSD distribution",
"OS2-EMX", "EMX GCC OS/2",
"netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
"netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
"netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
"netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
"default","cc under unix",
"auto", "auto detect from top level Makefile",
"copy", "copy from top level Makefile"
);
$platform="";
my $xcflags="";
foreach (@ARGV)
{
if (!&read_options && !defined($ops{$_}))
{
print STDERR "unknown option - $_\n";
print STDERR "usage: perl mk1mf.pl [options] [system]\n";
print STDERR "\nwhere [system] can be one of the following\n";
foreach $i (sort keys %ops)
{ printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
print STDERR <<"EOF";
and [options] can be one of
no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
no-ripemd
no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
no-bf no-cast no-aes no-camellia no-seed
no-rsa no-dsa no-dh - Skip this public key cipher
no-ssl3 - Skip this version of SSL
just-ssl - remove all non-ssl keys/digest
no-asm - No x86 asm
no-srp - No SRP
no-ec - No EC
no-engine - No engine
no-egd - No EGD
no-hw - No hw
no-async - No Async (use NULL)
nasm - Use NASM for x86 asm
nw-nasm - Use NASM x86 asm for NetWare
nw-mwasm - Use Metrowerks x86 asm for NetWare
gaswin - Use GNU as with Mingw32
no-socks - No socket code
no-err - No error strings
dll/shlib - Build shared libraries (MS)
debug - Debug build
profile - Profiling build
gcc - Use Gcc (unix)
Values that can be set
TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
-L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
-<ex_cc_flags> - extra 'cc' flags,
added (MS), or replace (unix)
EOF
exit(1);
}
$platform=$_;
}
foreach (grep(!/^$/, split(/ /, $OPTIONS)))
{
print STDERR "unknown option - $_\n" if !&read_options;
}
$no_static_engine = 0 if (!$shlib);
$no_mdc2=1 if ($no_des);
$no_ssl3=1 if ($no_md5);
$no_ssl3=1 if ($no_rsa && $no_dh);
$out_def="out";
$inc_def="outinc";
$tmp_def="tmp";
$perl="perl" unless defined $perl;
$mkdir="-mkdir" unless defined $mkdir;
$mv="mv" unless defined $mv;
($ssl,$crypto)=("ssl","crypto");
$ranlib="echo ranlib";
$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}: $platform eq 'copy' ? getcwd() : '.';
$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
# $bin_dir.=$o causes a core dump on my sparc :-(
$NT=0;
push(@INC,"util/pl","pl");
if ($platform eq "auto" || $platform eq 'copy') {
$orig_platform = $platform;
$platform = $mf_platform;
print STDERR "Imported platform $mf_platform\n";
}
if (($platform =~ /VC-(.+)/))
{
$FLAVOR=$1;
$NT = 1 if $1 eq "NT";
require 'VC-32.pl';
}
elsif ($platform eq "Mingw32")
{
require 'Mingw32.pl';
}
elsif ($platform eq "Mingw32-files")
{
require 'Mingw32f.pl';
}
elsif ($platform eq "BC-NT")
{
$bc=1;
require 'BC-32.pl';
}
elsif ($platform eq "FreeBSD")
{
require 'unix.pl';
$cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
}
elsif ($platform eq "linux-elf")
{
require "unix.pl";
require "linux.pl";
$unix=1;
}
elsif ($platform eq "ultrix-mips")
{
require "unix.pl";
require "ultrix.pl";
$unix=1;
}
elsif ($platform eq "OS2-EMX")
{
$wc=1;
require 'OS2-EMX.pl';
}
elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
{
$LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
$BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
require 'netware.pl';
}
else
{
require "unix.pl";
$unix=1;
$cflags.=' -DTERMIO';
}
$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
$cflags= "$xcflags$cflags" if $xcflags ne "";
$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia;
$cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
$cflags.=" -DOPENSSL_NO_RMD160" if $no_ripemd;
$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
$cflags.=" -DOPENSSL_NO_DES" if $no_des;
$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
$cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
$cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
$cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
$cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
$cflags.=" -DOPENSSL_NO_ASYNC" if $no_async;
$cflags.=" -DOPENSSL_FIPS" if $fips;
$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
$cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m;
$cflags.= " -DZLIB" if $zlib_opt;
$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
if ($no_static_engine)
{
$cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
}
else
{
$cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
}
#$cflags.=" -DRSAref" if $rsaref ne "";
## if ($unix)
## { $cflags="$c_flags" if ($c_flags ne ""); }
##else
{ $cflags="$c_flags$cflags" if ($c_flags ne ""); }
if ($orig_platform eq 'copy') {
$cflags = $mf_cflag;
$cc = $mf_cc;
}
$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
"CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
if ($msdos)
{
$banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
$banner.="\t\@echo top level directory, if you don't have perl, you will\n";
$banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
$banner.="\t\@echo documentation for details.\n";
}
# have to do this to allow $(CC) under unix
$link="$bin_dir$link" if ($link !~ /^\$/);
$INSTALLTOP =~ s|/|$o|g;
$OPENSSLDIR =~ s|/|$o|g;
#############################################
# We parse in input file and 'store' info for later printing.
open(IN,"<$infile") || die "unable to open $infile:$!\n";
$_=<IN>;
for (;;)
{
s/\s*$//; # was chop, didn't work in mixture of perls for Windows...
($key,$val)=/^([^=]+)=(.*)/;
if ($key eq "RELATIVE_DIRECTORY")
{
if ($lib ne "")
{
if ($fips && $dir =~ /^fips/)
{
$uc = "FIPS";
}
else
{
$uc=$lib;
$uc =~ s/^lib(.*)\.a/$1/;
$uc =~ tr/a-z/A-Z/;
}
if (($uc ne "FIPS") || $fipscanisterbuild)
{
$lib_nam{$uc}=$uc;
$lib_obj{$uc}.=$libobj." ";
}
}
last if ($val eq "FINISHED");
$lib="";
$libobj="";
$dir=$val;
}
if ($key eq "ZLIB_INCLUDE")
{ $cflags .= " $val" if $val ne "";}
if ($key eq "LIBZLIB")
{ $zlib_lib = "$val" if $val ne "";}
if ($key eq "EX_LIBS")
{ $ex_libs .= " $val" if $val ne "";}
# There was a condition here before:
# !$fipscanisteronly || $dir =~ /^fips/
# It currently fills no function and needs to be rewritten anyway, so
# removed for now.
if ($dir eq "test" && $key eq "EXE")
{
foreach my $t (split /\s+/, $val) {
$test.=&var_add($dir,$t, 0) if $t; }
}
if ($key eq "EXE_OBJ")
{ $e_exe.=&var_add($dir,$val, 0); }
if ($key eq "LIB")
{
$lib=$val;
$lib =~ s/^.*\/([^\/]+)$/$1/;
}
if ($key eq "LIBNAME" && $no_static_engine)
{
$lib=$val;
$lib =~ s/^.*\/([^\/]+)$/$1/;
$otherlibs .= " $lib";
}
if ($key eq "HEADER")
{ $header.=&var_add($dir,$val, 1); }
if ($key eq "LIBOBJ")
{
if ($dir ne "engines" || !$no_static_engine)
{ $libobj=&var_add($dir,$val, 0); }
else
{ push(@engines_obj,split(/\s+/,&var_add($dir,$val,0))); }
}
if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
{ $engines.=$val }
if ($key eq "FIPS_EX_OBJ")
{
$fips_ex_obj=&var_add("crypto",$val,0);
}
if ($key eq "FIPSLIBDIR")
{
$fipslibdir=$val;
$fipslibdir =~ s/\/$//;
$fipslibdir =~ s/\//$o/g;
}
if ($key eq "BASEADDR")
{ $baseaddr=$val;}
if (!($_=<IN>))
{ $_="RELATIVE_DIRECTORY=FINISHED\n"; }
}
close(IN);
if ($orig_platform eq 'copy')
{
# Remove opensslconf.h so it doesn't get updated if we configure a
# different branch.
$header =~ s/[^ ]+\/opensslconf.h//;
}
if ($fips)
{
foreach (split " ", $fips_ex_obj)
{
$fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/);
}
foreach (split " ",
"$mf_cpuid_asm $mf_aes_asm $mf_sha_asm $mf_bn_asm " .
"$mf_des_asm $mf_modes_asm")
{
s/\.o//;
$fips_exclude_obj{$_} = 1;
}
my @ltmp = split " ", $lib_obj{"CRYPTO"};
$lib_obj{"CRYPTO"} = "";
foreach(@ltmp)
{
if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1})
{
if ($fipscanisterbuild)
{
$lib_obj{"FIPS"} .= "$_ ";
}
}
elsif (!$fipscanisteronly)
{
$lib_obj{"CRYPTO"} .= "$_ ";
}
}
}
if ($fipscanisterbuild)
{
$fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq "";
$fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c";
}
else
{
if ($fips_canister_path eq "")
{
$fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib";
}
if ($fips_premain_c_path eq "")
{
$fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
}
}
if ($fips)
{
if ($fips_sha1_exe_path eq "")
{
$fips_sha1_exe_path =
"\$(BIN_D)${o}fips_standalone_sha1$exep";
}
}
else
{
$fips_sha1_exe_path = "";
}
if ($fips_premain_dso_exe_path eq "")
{
$fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
}
# $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
if ($fips)
{
if (!$shlib)
{
$build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
$ex_l_libs .= " \$(O_FIPSCANISTER)";
$ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
}
if ($fipscanisterbuild)
{
$fipslibdir = "\$(LIB_D)";
}
else
{
if ($fipslibdir eq "")
{
open (IN, "util/fipslib_path.txt") || fipslib_error();
$fipslibdir = <IN>;
chomp $fipslibdir;
close IN;
}
fips_check_files($fipslibdir,
"fipscanister.lib", "fipscanister.lib.sha1",
"fips_premain.c", "fips_premain.c.sha1");
}
}
if ($fipscanisteronly)
{
$build_targets = "\$(O_FIPSCANISTER) \$(T_EXE)";
$libs_dep = "";
}
$cp2 = $cp unless defined $cp2;
$extra_install= <<"EOF";
\$(CP) \"include${o}openssl${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
\$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
\$(MKDIR) \"\$(OPENSSLDIR)\"
\$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
EOF
if ($fipscanisteronly)
{
$extra_install = <<"EOF";
\$(CP) \"\$(O_FIPSCANISTER)\" \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"\$(O_FIPSCANISTER).sha1\" \"\$(INSTALLTOP)${o}lib\"
\$(CP2) \"fips${o}fips_premain.c\" \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"fips${o}fips_premain.c.sha1\" \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"include${o}openssl${o}fips.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
\$(CP) \"include${o}openssl${o}fips_rand.h\" \"\$(INSTALLTOP)${o}include${o}openssl\"
\$(CP) "\$(BIN_D)${o}fips_standalone_sha1$exep" \"\$(INSTALLTOP)${o}bin\"
\$(CP) \"util${o}fipslink.pl\" \"\$(INSTALLTOP)${o}bin\"
EOF
}
elsif ($shlib)
{
$extra_install .= <<"EOF";
\$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
\$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
\$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
EOF
if ($no_static_engine)
{
$extra_install .= <<"EOF"
\$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
\$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
EOF
}
}
else
{
$extra_install .= <<"EOF";
\$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
\$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
EOF
$ex_libs .= " $zlib_lib" if $zlib_opt == 1;
}
my $asm_def = $orig_platform eq 'copy' ? "" : "ASM=$bin_dir$asm";
$defs= <<"EOF";
# N.B. You MUST use -j on FreeBSD.
# This makefile has been automatically generated from the OpenSSL distribution.
# This single makefile will build the complete OpenSSL distribution and
# by default leave the 'interesting' output files in .${o}out and the stuff
# that needs deleting in .${o}tmp.
# The file was generated by running 'make makefile.one', which
# does a 'make files', which writes all the environment variables from all
# the makefiles to the file call MINFO. This file is used by
# util${o}mk1mf.pl to generate makefile.one.
# The 'makefile per directory' system suites me when developing this
# library and also so I can 'distribute' indervidual library sections.
# The one monster makefile better suits building in non-unix
# environments.
EOF
$defs .= $preamble if defined $preamble;
$defs.= <<"EOF";
INSTALLTOP=$INSTALLTOP
OPENSSLDIR=$OPENSSLDIR
# Set your compiler options
PLATFORM=$platform
CC=$bin_dir${cc}
CFLAG=$cflags
APP_CFLAG=$app_cflag
LIB_CFLAG=$lib_cflag
SHLIB_CFLAG=$shl_cflag
APP_EX_OBJ=$app_ex_obj
SHLIB_EX_OBJ=$shlib_ex_obj
# add extra libraries to this define, for solaris -lsocket -lnsl would
# be added
EX_LIBS=$ex_libs
# The OpenSSL directory
SRC_D=$src_dir
LINK=$link
LFLAGS=$lflags
RSC=$rsc
FIPSLINK=\$(PERL) util${o}fipslink.pl
# The output directory for everything interesting
OUT_D=$out_dir
# The output directory for all the temporary muck
TMP_D=$tmp_dir
PERL=$perl
PERLASM_SCHEME=$mf_perlasm_scheme
CP=$cp
CP2=$cp2
RM=$rm
MV=$mv
RANLIB=$ranlib
MKDIR=$mkdir
MKLIB=$bin_dir$mklib
MLFLAGS=$mlflags
$asm_def
# FIPS validated module and support file locations
E_PREMAIN_DSO=fips_premain_dso
FIPSLIB_D=$fipslibdir
BASEADDR=$baseaddr
FIPS_PREMAIN_SRC=$fips_premain_c_path
O_FIPSCANISTER=$fips_canister_path
FIPS_SHA1_EXE=$fips_sha1_exe_path
PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
######################################################
# You should not need to touch anything below this point
######################################################
E_EXE=openssl
SSL=$ssl
CRYPTO=$crypto
# BIN_D - Binary output directory
# TEST_D - Binary test file output directory
# LIB_D - library output directory
# ENG_D - dynamic engine output directory
# Note: if you change these point to different directories then uncomment out
# the lines around the 'NB' comment below.
#
BIN_D=\$(OUT_D)
TEST_D=\$(OUT_D)
LIB_D=\$(OUT_D)
ENG_D=\$(OUT_D)
# INCL_D - local library directory
# OBJ_D - temp object file directory
OBJ_D=\$(TMP_D)
INCL_D=\$(TMP_D)
O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
SO_SSL= $plib\$(SSL)$so_shlibp
SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
######################################################
# Don't touch anything below this point
######################################################
INC=-I\$(SRC_D)${o}include -I\$(INCL_D) -I\$(SRC_D)${o}crypto${o}include
APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
LIBS_DEP=$libs_dep
#############################################
EOF
$rules=<<"EOF";
all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) headers \$(FIPS_SHA1_EXE) $build_targets
banner:
$banner
\$(TMP_D):
\$(MKDIR) \"\$(TMP_D)\"
# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
#\$(BIN_D):
# \$(MKDIR) \$(BIN_D)
#
#\$(TEST_D):
# \$(MKDIR) \$(TEST_D)
\$(LIB_D):
\$(MKDIR) \"\$(LIB_D)\"
# This needs to be invoked once, when the makefile is first constructed, or
# after cleaning.
init: \$(TMP_D) \$(LIB_D) \$(BIN_D) \$(TEST_D) headers
headers: \$(HEADER)
lib: \$(LIBS_DEP) \$(E_SHLIB)
exe: apps tools testapps
apps: \$(BIN_D)$o\$(E_EXE)$exep \$(BIN_D)${o}CA.pl
testapps: \$(T_EXE)
tools: \$(BIN_D)${o}c_rehash
install: all
\$(MKDIR) \"\$(INSTALLTOP)\"
\$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
\$(MKDIR) \"\$(INSTALLTOP)${o}include\"
\$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
\$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
$extra_install
clean:
\$(RM) \$(TMP_D)$o*.*
vclean:
\$(RM) \$(TMP_D)$o*.*
\$(RM) \$(OUT_D)$o*.*
reallyclean:
\$(RM) -rf \$(TMP_D)
\$(RM) -rf \$(BIN_D)
\$(RM) -rf \$(TEST_D)
\$(RM) -rf \$(LIB_D)
EOF
$rules .= &do_rehash_rule("rehash.time", "certs/demo apps tools");
$rules .= &do_test_rule("test", "rehash.time", "run_tests.pl");
my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
$platform_cpp_symbol =~ s/-/_/g;
if (open(IN,"crypto/buildinf.h"))
{
# Remove entry for this platform in existing file buildinf.h.
my $old_buildinf_h = "";
while (<IN>)
{
if (/^\#ifdef $platform_cpp_symbol$/)
{
while (<IN>) { last if (/^\#endif/); }
}
else
{
$old_buildinf_h .= $_;
}
}
close(IN);
open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
print OUT $old_buildinf_h;
close(OUT);
}
open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
printf OUT <<"EOF";
#ifdef $platform_cpp_symbol
/* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
#define CFLAGS "compiler: $cc $cflags"
#define PLATFORM "$platform"
EOF
printf OUT " #define DATE \"%s\"\n", scalar gmtime();
printf OUT "#endif\n";
close(OUT);
# Strip off trailing ' '
foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
$test=&clean_up_ws($test);
$e_exe=&clean_up_ws($e_exe);
$header=&clean_up_ws($header);
$defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
$rules.=&do_copy_rule("\$(INCL_D)",$header,"");
$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
# Special case rules for fips_start and fips_end fips_premain_dso
if ($fips)
{
if ($fipscanisterbuild)
{
$rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
"fips${o}fips_canister.c",
"-DFIPS_START \$(SHLIB_CFLAGS)");
$rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
"fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
}
$rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
"fips${o}sha${o}fips_standalone_sha1.c",
"\$(APP_CFLAGS)");
$rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
"fips${o}fips_premain.c",
"-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)");
}
sub fix_asm
{
my($asm, $dir) = @_;
$asm = " $asm";
$asm =~ s/\s+/ $dir\//g;
$asm =~ s/\.o//g;
$asm =~ s/^ //;
return $asm . ' ';
}
if ($orig_platform eq 'copy') {
$lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5');
$lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn');
# cpuid is included by the crypto dir
#$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto');
# AES asm files end up included by the aes dir itself
#$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes');
$lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha');
$lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines');
$lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4');
$lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes');
$lib_obj{CRYPTO} .= fix_asm($mf_ec_asm, 'crypto/ec');
}
foreach (values %lib_nam)
{
$lib_obj=$lib_obj{$_};
local($slib)=$shlib;
$defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
$lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
$rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
}
# hack to add version info on MSVC
if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
|| ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
$rules.= <<"EOF";
\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
\$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
\$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
EOF
}
$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
foreach (split(/\s+/,$test))
{
my $t_libs;
$t=&bname($_);
my $ltype;
# Check to see if test program is FIPS
if ($fips && /fips/)
{
# If fips perform static link to
# $(O_FIPSCANISTER)
$t_libs = "\$(O_FIPSCANISTER)";
$ltype = 2;
}
else
{
$t_libs = "\$(L_LIBS)";
$ltype = 0;
}
$tt="\$(OBJ_D)${o}$t${obj}";
$rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype);
}
$defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp);
foreach (split(/\s+/,$engines))
{
my $engine = $_;
my @objs = grep {/e_$engine/} @engines_obj;
$rules.=&do_compile_rule("\$(OBJ_D)",join(" ",@objs),$lib);
map {$_=~s/.*\/([^\/]+)$/\$(OBJ_D)${o}$1$obj/} @objs;
$rules.= &do_lib_rule(join(" ",@objs),"\$(ENG_D)$o$engine$shlibp","",$shlib,"");
}
$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
#$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
foreach (split(" ",$otherlibs))
{
my $uc = $_;
$uc =~ tr /a-z/A-Z/;
$rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, "");
}
if ($fips)
{
if ($shlib)
{
$rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
"\$(O_CRYPTO)", "$crypto",
$shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
}
else
{
$rules.= &do_lib_rule("\$(CRYPTOOBJ)",
"\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
$rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
"\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
}
}
else
{
$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
"\$(SO_CRYPTO)");
}
if ($fips)
{
if ($fipscanisterbuild)
{
$rules.= &do_rlink_rule("\$(O_FIPSCANISTER)",
"\$(OBJ_D)${o}fips_start$obj",
"\$(FIPSOBJ)",
"\$(OBJ_D)${o}fips_end$obj",
"\$(FIPS_SHA1_EXE)", "");
# FIXME
$rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
"\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj $sha1_asm_obj",
"","\$(EX_LIBS)", 1);
}
else
{
$rules.=&do_link_rule("\$(FIPS_SHA1_EXE)",
"\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)",
"","", 1);
}
$rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
}
$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
$rules.=&do_dofile_rule("\$(BIN_D)","c_rehash","tools/c_rehash.in");
$rules.=&do_dofile_rule("\$(BIN_D)","CA.pl","apps/CA.pl.in");
print $defs;
if ($platform eq "linux-elf") {
print <<"EOF";
# Generate perlasm output files
%.cpp:
(cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
EOF
}
print "###################################################################\n";
print $rules;
###############################################
# strip off any trailing .[och] and append the relative directory
# also remembering to do nothing if we are in one of the dropped
# directories
sub var_add
{
local($dir,$val,$keepext)=@_;
local(@a,$_,$ret);
return("") if $no_engine && $dir =~ /\/engine/;
return("") if $no_hw && $dir =~ /\/hw/;
return("") if $no_idea && $dir =~ /\/idea/;
return("") if $no_aes && $dir =~ /\/aes/;
return("") if $no_camellia && $dir =~ /\/camellia/;
return("") if $no_seed && $dir =~ /\/seed/;
return("") if $no_rc2 && $dir =~ /\/rc2/;
return("") if $no_rc4 && $dir =~ /\/rc4/;
return("") if $no_rc5 && $dir =~ /\/rc5/;
return("") if $no_rsa && $dir =~ /\/rsa/;
return("") if $no_rsa && $dir =~ /^rsaref/;
return("") if $no_dsa && $dir =~ /\/dsa/;
return("") if $no_dh && $dir =~ /\/dh/;
return("") if $no_ec && $dir =~ /\/ec/;
return("") if $no_cms && $dir =~ /\/cms/;
return("") if $no_jpake && $dir =~ /\/jpake/;
return("") if !$fips && $dir =~ /^fips/;
if ($no_des && $dir =~ /\/des/)
{
if ($val =~ /read_pwd/)
{ return("$dir/read_pwd "); }
else
{ return(""); }
}
return("") if $no_mdc2 && $dir =~ /\/mdc2/;
return("") if $no_sock && $dir =~ /\/proxy/;
return("") if $no_bf && $dir =~ /\/bf/;
return("") if $no_cast && $dir =~ /\/cast/;
return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
$val =~ s/^\s*(.*)\s*$/$1/;
@a=split(/\s+/,$val);
grep(s/\.[och]$//,@a) unless $keepext;
@a=grep(!/^e_.*_3d$/,@a) if $no_des;
@a=grep(!/^e_.*_d$/,@a) if $no_des;
@a=grep(!/^e_.*_ae$/,@a) if $no_idea;
@a=grep(!/^e_.*_i$/,@a) if $no_aes;
@a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
@a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
@a=grep(!/^e_.*_bf$/,@a) if $no_bf;
@a=grep(!/^e_.*_c$/,@a) if $no_cast;
@a=grep(!/^e_rc4$/,@a) if $no_rc4;
@a=grep(!/^e_camellia$/,@a) if $no_camellia;
@a=grep(!/^e_seed$/,@a) if $no_seed;
#@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
@a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
@a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
@a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
@a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
@a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
@a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
@a=grep(!/(^p_open$)/,@a) if $no_rsa;
@a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
@a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
@a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
@a=grep(!/_dhp$/,@a) if $no_dh;
@a=grep(!/_mdc2$/,@a) if $no_mdc2;
@a=grep(!/(srp)/,@a) if $no_srp;
@a=grep(!/^engine$/,@a) if $no_engine;
@a=grep(!/^hw$/,@a) if $no_hw;
@a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
@a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
@a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
grep($_="$dir/$_",@a);
@a=grep(!/(^|\/)s_/,@a) if $no_sock;
@a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
$ret=join(' ',@a)." ";
return($ret);
}
# change things so that each 'token' is only separated by one space
sub clean_up_ws
{
local($w)=@_;
$w =~ s/^\s*(.*)\s*$/$1/;
$w =~ s/\s+/ /g;
return($w);
}
sub do_defs
{
local($var,$files,$location,$postfix)=@_;
local($_,$ret,$pf);
local(*OUT,$tmp,$t);
$files =~ s/\//$o/g if $o ne '/';
$ret="$var=";
$n=1;
$Vars{$var}.="";
foreach (split(/ /,$files))
{
$orig=$_;
$_=&bname($_) unless /^\$/;
if ($n++ == 2)
{
$n=0;
$ret.="\\\n\t";
}
if (($_ =~ /bss_file/) && ($postfix eq ".h"))
{ $pf=".c"; }
else { $pf=$postfix; }
if ($_ =~ /BN_ASM/) { $t="$_ "; }
elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
else { $t="$location${o}$_$pf "; }
$Vars{$var}.="$t ";
$ret.=$t;
}
# hack to add version info on MSVC
if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
{
if ($var eq "CRYPTOOBJ")
{ $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
elsif ($var eq "SSLOBJ")
{ $ret.="\$(OBJ_D)\\\$(SSL).res "; }
}
chomp($ret);
$ret.="\n\n";
return($ret);
}
# return the name with the leading path removed
sub bname
{
local($ret)=@_;
$ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
return($ret);
}
# return the leading path
sub dname
{
my $ret=shift;
$ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
return($ret);
}
##############################################################
# do a rule for each file that says 'compile' to new direcory
# compile the files in '$files' into $to
sub do_compile_rule
{
local($to,$files,$ex)=@_;
local($ret,$_,$n,$d,$s);
$files =~ s/\//$o/g if $o ne '/';
foreach (split(/\s+/,$files))
{
$n=&bname($_);
$d=&dname($_);
if (-f "${_}.c")
{
$ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
}
elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
($s=~s/sha256/sha512/ and -f $s) or
-f ($s="${d}${o}${n}.pl"))
{
$ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
}
elsif (-f ($s="${d}${o}asm${o}${n}.S") or
-f ($s="${d}${o}${n}.S"))
{
$ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
}
elsif (defined &special_compile_target and
($s=special_compile_target($_)))
{
$ret.=$s;
}
else { die "no rule for $_"; }
}
return($ret);
}
##############################################################
# do a rule for each file that says 'compile' to new direcory
sub perlasm_compile_target
{
my($target,$source,$bname)=@_;
return platform_perlasm_compile_target($target, $source, $bname)
if defined &platform_perlasm_compile_target;
my($ret);
$bname =~ s/(.*)\.[^\.]$/$1/;
$ret ="\$(TMP_D)$o$bname$asm_suffix: $source\n";
$ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
if ($fipscanisteronly)
{
$ret .= "\t\$(PERL) util$o.pl . \$@ norunasm \$(CFLAG)\n";
}
$ret .= "\n";
$ret.="$target: \$(TMP_D)$o$bname$asm_suffix\n";
$ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname$asm_suffix\n\n";
return($ret);
}
sub Sasm_compile_target
{
my($target,$source,$bname)=@_;
my($ret);
$bname =~ s/(.*)\.[^\.]$/$1/;
$ret ="\$(TMP_D)$o$bname.asm: $source\n";
$ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n";
$ret.="\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n" if $fipscanisteronly;
$ret.="\n";
$ret.="$target: \$(TMP_D)$o$bname.asm\n";
$ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
return($ret);
}
sub cc_compile_target
{
local($target,$source,$ex_flags)=@_;
local($ret);
$ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
$target =~ s/\//$o/g if $o ne "/";
$source =~ s/\//$o/g if $o ne "/";
$ret ="$target: \$(SRC_D)$o$source\n\t";
$ret.="\$(CC)";
$ret.= " -MMD" if $orig_platform eq "copy";
$ret.= " ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
$target =~ s/\.o$/.d/;
$ret.=".sinclude \"$target\"\n\n" if $orig_platform eq "copy";
return($ret);
}
##############################################################
sub do_asm_rule
{
local($target,$src)=@_;
local($ret,@s,@t,$i);
$target =~ s/\//$o/g if $o ne "/";
$src =~ s/\//$o/g if $o ne "/";
@t=split(/\s+/,$target);
@s=split(/\s+/,$src);
for ($i=0; $i<=$#s; $i++)
{
my $objfile = $t[$i];
my $srcfile = $s[$i];
if ($perl_asm == 1)
{
my $plasm = $objfile;
$plasm =~ s/${obj}/.pl/;
$ret.="$srcfile: $plasm\n";
$ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
}
$ret.="$objfile: $srcfile\n";
$ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
}
return($ret);
}
sub do_shlib_rule
{
local($n,$def)=@_;
local($ret,$nn);
local($t);
($nn=$n) =~ tr/a-z/A-Z/;
$ret.="$n.dll: \$(${nn}OBJ)\n";
if ($vc && $w32)
{
$ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
}
$ret.="\n";
return($ret);
}
# do a rule for each file that says 'copy' to new direcory on change
sub do_copy_rule
{
local($to,$files,$p)=@_;
local($ret,$_,$n,$pp);
$files =~ s/\//$o/g if $o ne '/';
foreach (split(/\s+/,$files))
{
$n=&bname($_);
if ($n =~ /bss_file/)
{ $pp=".c"; }
else { $pp=$p; }
$ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(PERL) \$(SRC_D)${o}util${o}copy-if-different.pl \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
}
return($ret);
}
sub do_dofile_rule
{
(my $to, my $file, my $tmpl) = @_;
$file =~ s|/|$o|g if $o ne '/';
return <<"EOF";
$to${o}$file: $tmpl
\$(PERL) "-I." "-Mconfigdata" util/dofile.pl "$tmpl" > "$to${o}$file.new"
\$(MV) "$to${o}$file.new" "$to${o}$file"
EOF
}
# Options picked up from the OPTIONS line in the top level Makefile
# generated by Configure.
sub read_options
{
# Many options are handled in a similar way. In particular
# no-xxx sets zero or more scalars to 1.
# Process these using the %valid_options hash containing the option
# name and reference to the scalars to set. In some cases the option
# needs no special handling and can be ignored: this is done by
# setting the value to 0.
my %valid_options = (
"no-rc2" => \$no_rc2,
"no-rc4" => \$no_rc4,
"no-rc5" => \$no_rc5,
"no-idea" => \$no_idea,
"no-aes" => \$no_aes,
"no-camellia" => \$no_camellia,
"no-seed" => \$no_seed,
"no-des" => \$no_des,
"no-bf" => \$no_bf,
"no-cast" => \$no_cast,
"no-md2" => \$no_md2,
"no-md4" => \$no_md4,
"no-md5" => \$no_md5,
"no-ripemd" => \$no_ripemd,
"no-mdc2" => \$no_mdc2,
"no-whirlpool" => \$no_whirlpool,
"no-patents" =>
[\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
"no-rsa" => \$no_rsa,
"no-dsa" => \$no_dsa,
"no-dh" => \$no_dh,
"no-asm" => \$no_asm,
"nasm" => \$nasm,
"nw-nasm" => \$nw_nasm,
"nw-mwasm" => \$nw_mwasm,
"gaswin" => \$gaswin,
"no-ssl3" => \$no_ssl3,
"no-ssl3-method" => 0,
"no-srp" => \$no_srp,
"no-cms" => \$no_cms,
"no-jpake" => \$no_jpake,
"no-ec2m" => \$no_ec2m,
"no-ec_nistp_64_gcc_128" => 0,
"no-err" => \$no_err,
"no-sock" => \$no_sock,
"no-ec" => \$no_ec,
"no-gost" => \$no_gost,
"no-engine" => \$no_engine,
"no-egd" => 0,
"no-hw" => \$no_hw,
"no-async" => \$no_async,
"just-ssl" =>
[\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
\$no_md2, \$no_mdc2, \$no_dsa, \$no_dh,
\$no_err, \$no_ripemd, \$no_rc5,
\$no_aes, \$no_camellia, \$no_seed, \$no_srp],
"rsaref" => 0,
"gcc" => \$gcc,
"debug" => \$debug,
"--debug" => \$debug,
"profile" => \$profile,
"shlib" => \$shlib,
"dll" => \$shlib,
"shared" => 0,
"no-sctp" => 0,
"no-srtp" => 0,
"no-gmp" => 0,
"no-rfc3779" => 0,
"no-montasm" => 0,
"no-shared" => 0,
"no-store" => 0,
"no-zlib" => 0,
"no-zlib-dynamic" => 0,
"no-ssl-trace" => 0,
"no-unit-test" => 0,
"no-deprecated" => 0,
"no-ocb" => 0,
"no-crypto-mdebug" => 0,
"fips" => \$fips,
"fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
"fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
"fipscheck" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
);
if (exists $valid_options{$_})
{
my $r = $valid_options{$_};
if ( ref $r eq "SCALAR")
{ $$r = 1;}
elsif ( ref $r eq "ARRAY")
{
my $r2;
foreach $r2 (@$r)
{
$$r2 = 1;
}
}
}
elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
elsif (/^enable-zlib-dynamic$/)
{
$zlib_opt = 2;
}
elsif (/^no-static-engine/)
{
$no_static_engine = 1;
}
elsif (/^enable-static-engine/)
{
$no_static_engine = 0;
}
# There are also enable-xxx options which correspond to
# the no-xxx. Since the scalars are enabled by default
# these can be ignored.
elsif (/^enable-/)
{
my $t = $_;
$t =~ s/^enable/no/;
if (exists $valid_options{$t})
{return 1;}
return 0;
}
# experimental-xxx is mostly like enable-xxx, but opensslconf.v
# will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
# (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
elsif (/^experimental-/)
{
my $algo, $ALGO;
($algo = $_) =~ s/^experimental-//;
($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
$xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
}
elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
{ $c_flags.="$_ "; }
else { return(0); }
return(1);
}
sub fipslib_error
{
print STDERR "***FIPS module directory sanity check failed***\n";
print STDERR "FIPS module build failed, or was deleted\n";
print STDERR "Please rebuild FIPS module.\n";
exit 1;
}
sub fips_check_files
{
my $dir = shift @_;
my $ret = 1;
if (!-d $dir)
{
print STDERR "FIPS module directory $dir does not exist\n";
fipslib_error();
}
foreach (@_)
{
if (!-f "$dir${o}$_")
{
print STDERR "FIPS module file $_ does not exist!\n";
$ret = 0;
}
}
fipslib_error() if ($ret == 0);
}
| 25.854167 | 137 | 0.576199 |
eda2ddf8f7269febcbd608b94b372e7a30410580 | 1,608 | pm | Perl | auto-lib/Paws/Shield/SummarizedAttackVector.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | auto-lib/Paws/Shield/SummarizedAttackVector.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | 1 | 2021-05-26T19:13:58.000Z | 2021-05-26T19:13:58.000Z | auto-lib/Paws/Shield/SummarizedAttackVector.pm | galenhuntington/aws-sdk-perl | 13b775dcb5f0b3764f0a82f3679ed5c7721e67d3 | [
"Apache-2.0"
] | null | null | null | package Paws::Shield::SummarizedAttackVector;
use Moose;
has VectorCounters => (is => 'ro', isa => 'ArrayRef[Paws::Shield::SummarizedCounter]');
has VectorType => (is => 'ro', isa => 'Str', required => 1);
1;
### main pod documentation begin ###
=head1 NAME
Paws::Shield::SummarizedAttackVector
=head1 USAGE
This class represents one of two things:
=head3 Arguments in a call to a service
Use the attributes of this class as arguments to methods. You shouldn't make instances of this class.
Each attribute should be used as a named argument in the calls that expect this type of object.
As an example, if Att1 is expected to be a Paws::Shield::SummarizedAttackVector object:
$service_obj->Method(Att1 => { VectorCounters => $value, ..., VectorType => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::Shield::SummarizedAttackVector object:
$result = $service_obj->Method(...);
$result->Att1->VectorCounters
=head1 DESCRIPTION
A summary of information about the attack.
=head1 ATTRIBUTES
=head2 VectorCounters => ArrayRef[L<Paws::Shield::SummarizedCounter>]
The list of counters that describe the details of the attack.
=head2 B<REQUIRED> VectorType => Str
The attack type, for example, SNMP reflection or SYN flood.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::Shield>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: L<https://github.com/pplu/aws-sdk-perl>
Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues>
=cut
| 25.52381 | 107 | 0.736318 |
eda0e462ce3aa3ab447f71c037c253c0bbfda9ec | 3,229 | pl | Perl | Scripts/BlastPairwise.AAsubs.pl | tkiryuti/enveomics-R-doc-updates | e0571579a2c254765ff745da43d7b2ac7e537bc9 | [
"Artistic-2.0"
] | 29 | 2015-01-30T04:59:04.000Z | 2022-03-19T12:29:04.000Z | Scripts/BlastPairwise.AAsubs.pl | tkiryuti/enveomics-R-doc-updates | e0571579a2c254765ff745da43d7b2ac7e537bc9 | [
"Artistic-2.0"
] | 38 | 2015-07-22T16:05:29.000Z | 2021-04-03T06:24:32.000Z | Scripts/BlastPairwise.AAsubs.pl | tkiryuti/enveomics-R-doc-updates | e0571579a2c254765ff745da43d7b2ac7e537bc9 | [
"Artistic-2.0"
] | 33 | 2015-01-30T04:59:05.000Z | 2022-03-19T12:29:10.000Z | #!/usr/bin/env perl
#
# @authors Konstantinos Konstantinidis (initial version)
# modified to work with the BLASTp 2.2.25+ m0 output by
# Despina Tsementzi & Luis M. Rodriguez-R
# @updated Dec-21-2015
#
$/ = "Lambda ";
use strict;
my %hash_depth;
my @query;
my @subject;
my @similarity;
my $length = "0";
my($cigar_chr, $blast) = @ARGV;
($cigar_chr and $blast) or die "
.Description:
Counts the different AA substitutions in the best hit blast alignments, from
a BLASTP pairwise format output (-outfmt 0 in BLAST+, -m 0 in legacy BLAST).
.Usage: $0 cigar_char blast.m0.txt > aa-subs.list
cigar_char Use '+' for similar substitutions, use '_' for non similar
substitutions
blast.m0.txt Blast in 'text' format (-outfmt/-m 0).
aa-subs.list A tab-delimited raw file with one substitution per row and
columns:
(1) Name-of-query_Name-of-subject
(2) AA-in-subject
(3) AA-in-query
(4) Total-Align-Length
";
# For each blast result (i.e., for each query)
open BLAST, "<", $blast or die "Cannot read file: $blast: $!\n";
while(my $data=<BLAST>) {
$data =~ s/\r//g;
my ($data_q, @array_matches) = split(/>/,$data);
my ($name_query) = ($data_q =~ /Query\= (\S+?)(?:_GENE|\s)/);
my ($length_query) = ($data_q =~ /\(([\d,]+) letters/ );
($length_query) = ($data_q =~ /Length=([\d,]+)/) unless $length_query;
$length_query =~ tr/,//d;
# For each alignment (i.e., for each HSP),
# note the "last" at the end of the block,
# so only the best match is considered
foreach my $data_f (@array_matches) {
# Capture statistics
my ($length_match) = ($data_f =~ /Identities = \d+\/(\d+)/);
my ($identity_match) = ($data_f =~ /Identities = \d+\/\d+ \((\d+)%/);
my ($target_name) = ($data_f =~ /^\s?(\S+)/);
# If the alignment meets minimum requirements
if ($length_query >30 && ($length_match/$length_query > 0.7) && $identity_match > 60) {
$data_f =~ tr/ /_/;
my @array = split ("\n", $data_f);
my $blanks = 0;
my $prefix_size = 0;
# For each line in the alignment
for my $data_fff (@array) {
if ($data_fff =~ /(Query[:_]_+\d+_+)([^_]+)/){
# Query lines
$prefix_size = length($1);
$length = length($2);
@query = split (//, $2);
}elsif ($data_fff =~ /^_{11}/){
# Cigar lines
@similarity = split(//, substr($data_fff, $prefix_size, $length));
}elsif ($data_fff =~ /Sbjct[:_]_+\d+_+([^_]+)/){
# Subject lines
@subject = split(//, $1);
# For each alignment column
for(my $i=0; $i <= $length; $i++){
if ($similarity[$i] eq $cigar_chr) {
print "$name_query\_$target_name\t$subject[$i]\t$query[$i]\t$length_match\n";
}
}
undef @query;
undef @similarity;
undef @subject;
}
# Remove secondary alignments
if ($data_fff =~ /^$/){
$blanks++;
last if $blanks >= 3;
}else{
$blanks=0;
}
} # for my $data_fff (@array)
} # if ($length_query >30 ...
last; # <---- So it takes only the best match!
} # foreach my $data_f (@array_matches)
} # while(my $data=<>)
| 31.349515 | 93 | 0.562403 |
ed5e5a9a27fc663f0a35ddc7d6f37d7a7fceba58 | 6,354 | t | Perl | t/11-cluster.t | sestaton/Transposome | e615866e43cb5e7046a53cc617792c64e030bd1e | [
"MIT"
] | 31 | 2015-01-13T02:03:20.000Z | 2021-03-24T20:12:03.000Z | t/11-cluster.t | sestaton/Transposome | e615866e43cb5e7046a53cc617792c64e030bd1e | [
"MIT"
] | 33 | 2015-02-09T04:25:24.000Z | 2022-03-30T23:11:55.000Z | t/11-cluster.t | sestaton/Transposome | e615866e43cb5e7046a53cc617792c64e030bd1e | [
"MIT"
] | 5 | 2015-02-25T13:54:56.000Z | 2018-06-14T09:29:43.000Z | use 5.010;
use strict;
use warnings;
use File::Spec;
use File::Basename;
use File::Path qw(make_path remove_tree);
use Module::Path qw(module_path);
use Transposome::PairFinder;
use Transposome::Cluster;
use Transposome::SeqUtil;
use aliased 'Transposome::Test::TestFixture';
use Test::More 'no_plan';
my $seqfile = File::Spec->catfile('t', 'test_data', 't_reads.fas.gz');
my $repeatdb = File::Spec->catfile('t', 'test_data', 't_db.fas');
my $outdir = File::Spec->catdir('t', 'cluster_t');
my $report = 'cluster_test_rep.txt';
my $test = TestFixture->new( build_proper => 1, destroy => 0 );
my $blast = $test->blast_constructor;
my ($blfl) = @$blast;
my $tf_obj_keep = TestFixture->new(
seq_file => $seqfile,
seq_format => 'fasta',
repeat_db => $repeatdb,
output_directory => $outdir,
destroy => 0,
build_proper => 1
);
my $keep_conf = $tf_obj_keep->config_constructor;
my ($keep_conf_file) = @$keep_conf;
my $blast_res = Transposome::PairFinder->new(
config => $keep_conf_file,
file => $blfl,
dir => $outdir,
in_memory => 1,
percent_identity => 90.0,
fraction_coverage => 0.55,
verbose => 0,
log_to_screen => 0
);
my ( $idx_file, $int_file, $hs_file ) = $blast_res->parse_blast;
my $path = module_path("Transposome::Cluster");
my $file = Path::Class::File->new($path);
my $pdir = $file->dir;
my $bdir = Path::Class::Dir->new("$pdir/../../bin");
my $realbin = $bdir->resolve;
my $in_memory = 1;
cluster_analysis($in_memory);
$in_memory = 0;
cluster_analysis($in_memory);
sub cluster_analysis {
my ($in_memory) = @_;
my $cluster = Transposome::Cluster->new(
config => $keep_conf_file,
file => $int_file,
dir => $outdir,
merge_threshold => 0.029, # 70 * 0.029 = 2
cluster_size => 1,
bin_dir => $realbin,
verbose => 0,
in_memory => $in_memory,
log_to_screen => 0
);
ok( $cluster->louvain_method, 'Can perform clustering with Louvain method' );
my $comm = $cluster->louvain_method;
ok( defined($comm), 'Can successfully perform clustering' );
my $cluster_file = $cluster->make_clusters( $comm, $idx_file );
ok( defined($cluster_file),
'Can successfully make communities following clusters' );
{
local $/ = '>';
my $cls = File::Spec->catfile($outdir, $cluster_file);
open my $in, '<', $cls;
while ( my $line = <$in> ) {
$line =~ s/>//g;
next if !length($line);
my ( $clsid, $seqids ) = split /\n/, $line;
my ( $id, $seqct ) = split /\s/, $clsid;
my @ids = split /\s+/, $seqids;
my $clsct = scalar @ids;
if ( $seqct > 1 ) {
is( $seqct, $clsct, 'Correct number of reads in clusters' );
}
}
close $in;
}
my $memstore = Transposome::SeqUtil->new( file => $seqfile, in_memory => 1 );
my ( $seqs, $seqct ) = $memstore->store_seq;
my $pair_data =
$cluster->find_pairs({ cluster_file => $cluster_file,
cluster_log_file => $report,
total_seq_num => $seqct });
ok( defined($pair_data->{read_pairs}), 'Can find split paired reads for merging clusters' );
my %merge_args = (
graph_vertices => $pair_data->{graph_vertices},
sequence_hash => $seqs,
read_pairs => $pair_data->{read_pairs},
cluster_log_file => $report,
graph_unionfind_object => $pair_data->{graph_unionfind_object},
);
if ($in_memory) {
$merge_args{dbm_file} = $pair_data->{dbm_file};
}
my $cluster_data =
$cluster->merge_clusters(\%merge_args);
{
local $/ = '>';
open my $in, '<', $cluster_data->{merged_cluster_file};
while ( my $line = <$in> ) {
$line =~ s/>//g;
next if !length($line);
my ( $clsid, $seqids ) = split /\n/, $line;
my ( $id, $seqct ) = split /\s/, $clsid;
my @ids = split /\s+/, $seqids;
my $clsct = scalar @ids;
is( $seqct, $clsct, 'Correct number of reads in merged clusters' );
}
close $in;
}
ok( defined($cluster_data), 'Returned data from cluster merging process' );
ok( ref($cluster_data) eq 'HASH', 'Returned the correct data type from cluster merging' );
ok( defined($cluster_data->{cluster_directory}),
'Can successfully merge communities based on paired-end information' );
is( $cluster_data->{total_cluster_num}, 46, 'The expected number of reads went into clusters' );
my $repfile = File::Spec->catfile($outdir, $report);
open my $rep, '<', $repfile;
my ( $g1, $g0, $cls11, $cls12, $cls21, $cls22, $reads1, $reads2, $mems1,
$mems2 );
while (<$rep>) {
chomp;
if (/^# Cluster connections/) {
my $first = <$rep>;
chomp $first;
my $second = <$rep>;
chomp $second;
( $cls11, $cls12, $reads1 ) = split /\t/, $first;
( $cls21, $cls22, $reads2 ) = split /\t/, $second;
is( $reads1, $reads2,
'Expected number of reads went into each cluster grouping' );
}
if (/^# Cluster groupings/) {
my $first = <$rep>;
chomp $first;
my $second = <$rep>;
chomp $second;
( $g0, $mems1 ) = split /\t/, $first;
( $g1, $mems2 ) = split /\t/, $second;
my $cg0 = $cls11 . "," . $cls12;
my $cg1 = $cls12 . "," . $cls11;
my $cg2 = $cls21 . "," . $cls22;
my $cg3 = $cls22 . "," . $cls21;
like( $mems1, qr/$cg0|$cg1|$cg2|$cg3/,
'Expected clusters were joined (1)' );
like( $mems2, qr/$cg0|$cg1|$cg2|$cg3/,
'Expected clusters were joined (2)' );
}
}
close $rep;
my $single_ct = 0;
my $cluster_dir = $cluster_data->{cluster_directory};
my ($singles_file) = glob("$cluster_dir/singletons*.fas");
ok( defined($singles_file), 'Produced a file of singleton reads' );
open my $singfh, '<', $singles_file;
while (<$singfh>) {
$single_ct++ if /^>/;
}
close $singfh;
is( $single_ct, 24, 'Expected number of reads went into singletons file' );
is( $cluster_data->{total_cluster_num} + $single_ct, 70,
'Expected number of reads went into clusters and singletons file' );
}
END {
remove_tree( $outdir, { safe => 1 } );
unlink glob("t/*.bln");
unlink $keep_conf_file;
}
| 30.548077 | 100 | 0.576487 |
ed8a22bb977e5a99c5e2f549eaa4a4f6162c7a12 | 4,950 | pm | Perl | modules/Bio/EnsEMBL/Utils/Converter/bio_ens_featurePair.pm | Anacode/ensembl | d3cfe97706ed1d38ee6b561198dd592c9f4ea2ee | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Utils/Converter/bio_ens_featurePair.pm | Anacode/ensembl | d3cfe97706ed1d38ee6b561198dd592c9f4ea2ee | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Utils/Converter/bio_ens_featurePair.pm | Anacode/ensembl | d3cfe97706ed1d38ee6b561198dd592c9f4ea2ee | [
"Apache-2.0"
] | null | null | null | =head1 LICENSE
Copyright [1999-2013] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <dev@ensembl.org>.
Questions may also be sent to the Ensembl help desk at
<helpdesk@ensembl.org>.
=head1 AUTHOR
Juguang Xiao <juguang@tll.org.sg>
=cut
=head1 NAME
Bio::EnsEMBL::Utils::Converter::bio_ens_featurePair
=head1 SYNOPISIS
=head1 DESCRIPTION
=head1 METHODS
=cut
package Bio::EnsEMBL::Utils::Converter::bio_ens_featurePair;
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::RepeatConsensus;
use Bio::EnsEMBL::ProteinFeature;
use Bio::EnsEMBL::Utils::Converter;
use Bio::EnsEMBL::Utils::Converter::bio_ens;
@ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
sub _initialize {
my ($self, @args) = @_;
$self->SUPER::_initialize(@args);
my ($translation_id) = $self->_rearrange([qw(TRANSLATION_ID)], @args);
$self->translation_id($translation_id);
# internal converter for seqFeature
$self->{_bio_ens_seqFeature} = new Bio::EnsEMBL::Utils::Converter (
-in => 'Bio::SeqFeature::Generic',
-out => 'Bio::EnsEMBL::SeqFeature',
);
}
sub _convert_single {
my ($self, $pair) = @_;
unless($pair && $pair->isa('Bio::SeqFeature::FeaturePair')){
$self->throw('a Bio::SeqFeature::FeaturePair object needed');
}
if($self->out eq 'Bio::EnsEMBL::RepeatFeature'){
return $self->_convert_single_to_repeatFeature($pair);
}elsif($self->out eq 'Bio::EnsEMBL::FeaturePair'){
return $self->_convert_single_to_featurePair($pair);
}elsif($self->out eq 'Bio::EnsEMBL::ProteinFeature'){
return $self->_convert_single_to_proteinFeature($pair);
}else{
my $output_module = $self->out;
$self->throw("Cannot covert to [$output_module]");
}
}
sub _convert_single_to_featurePair {
my ($self, $pair) = @_;
my $feature1 = $pair->feature1;
my $feature2 = $pair->feature2;
$self->{_bio_ens_seqFeature}->contig($self->contig);
$self->{_bio_ens_seqFeature}->analysis($self->analysis);
my $ens_f1 = $self->{_bio_ens_seqFeature}->_convert_single($feature1);
my $ens_f2 = $self->{_bio_ens_seqFeature}->_convert_single($feature2);
my $ens_fp = Bio::EnsEMBL::FeaturePair->new(
-feature1 => $ens_f1,
-feature2 => $ens_f2
);
return $ens_fp;
}
sub _convert_single_to_proteinFeature {
my ($self, $pair) = @_;
my $featurePair = $self->_convert_single_to_featurePair($pair);
my $proteinFeature = Bio::EnsEMBL::ProteinFeature->new(
-feature1 => $featurePair->feature1,
-feature2 => $featurePair->feature2
);
$proteinFeature->seqname($self->translation_id);
return $proteinFeature;
}
sub _convert_single_to_repeatFeature {
my ($self, $pair) = @_;
my $feature1 = $pair->feature1;
my $feature2 = $pair->feature2;
my $ens_repeatfeature = new Bio::EnsEMBL::RepeatFeature(
-seqname => $feature1->seq_id,
-start => $feature1->start,
-end => $feature1->end,
-strand => $feature1->strand,
-source_tag => $feature1->source_tag,
);
my ($h_start, $h_end);
if($feature1->strand == 1){
$h_start = $feature2->start;
$h_end = $feature2->end;
}elsif($feature1->strand == -1){
$h_start = $feature2->end;
$h_end = $feature2->start;
}else{
$self->throw("strand cannot be outside of (1, -1)");
}
$ens_repeatfeature->hstart($h_start);
$ens_repeatfeature->hend($h_end);
my $repeat_name = $feature2->seq_id;
my $repeat_class = $feature1->primary_tag;
$repeat_class ||= $feature2->primary_tag;
$repeat_class ||= "not sure";
my $ens_repeat_consensus =
$self->_create_consensus($repeat_name, $repeat_class);
$ens_repeatfeature->repeat_consensus($ens_repeat_consensus);
my($contig) = ref ($self->contig) eq 'ARRAY' ? @{$self->contig} : $self->contig;
$ens_repeatfeature->attach_seq($contig);
$ens_repeatfeature->analysis($self->analysis);
return $ens_repeatfeature;
}
sub _create_consensus{
my ($self, $repeat_name, $repeat_class) = @_;
my $consensus = new Bio::EnsEMBL::RepeatConsensus;
$consensus->name($repeat_name);
$consensus->repeat_class($repeat_class);
return $consensus;
}
1;
| 30.182927 | 100 | 0.670505 |
edb0601f73b0ec4f03ea725a25f61903e391b994 | 2,152 | t | Perl | t/150_post_form.t | gitpan/HTTP-Tiny | f7df8d3fe17adcab0c06260ae18c670119df7d6c | [
"Artistic-1.0"
] | null | null | null | t/150_post_form.t | gitpan/HTTP-Tiny | f7df8d3fe17adcab0c06260ae18c670119df7d6c | [
"Artistic-1.0"
] | null | null | null | t/150_post_form.t | gitpan/HTTP-Tiny | f7df8d3fe17adcab0c06260ae18c670119df7d6c | [
"Artistic-1.0"
] | null | null | null | #!perl
use strict;
use warnings;
use open IN => ':raw';
use File::Basename;
use Test::More 0.88;
use t::Util qw[tmpfile rewind slurp monkey_patch dir_list parse_case
set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny;
BEGIN { monkey_patch() }
for my $file ( dir_list("corpus", qr/^form/ ) ) {
my $data = do { local (@ARGV,$/) = $file; <> };
my ($params, $expect_req, $give_res) = split /--+\n/, $data;
# cleanup source data
my $version = HTTP::Tiny->VERSION || 0;
$expect_req =~ s{VERSION}{$version};
s{\n}{$CRLF}g for ($expect_req, $give_res);
# figure out what request to make
my $case = parse_case($params);
my $url = $case->{url}[0];
my %options;
my %headers;
for my $line ( @{ $case->{headers} } ) {
my ($k,$v) = ($line =~ m{^([^:]+): (.*)$}g);
$headers{$k} = $v;
}
$options{headers} = \%headers if %headers;
my @params = split "\\|", $case->{content}[0];
my $formdata;
if ( $case->{datatype}[0] eq 'HASH' ) {
while ( @params ) {
my ($key, $value) = splice( @params, 0, 2 );
if ( ref $formdata->{$key} ) {
push @{$formdata->{$key}}, $value;
}
elsif ( exists $formdata->{$key} ) {
$formdata->{$key} = [ $formdata->{$key}, $value ];
}
else {
$formdata->{$key} = $value;
}
}
}
else {
$formdata = [ @params ];
}
# setup mocking and test
my $res_fh = tmpfile($give_res);
my $req_fh = tmpfile();
my $http = HTTP::Tiny->new( keep_alive => 0 );
set_socket_source($req_fh, $res_fh);
(my $url_basename = $url) =~ s{.*/}{};
my $response = $http->post_form( $url, $formdata, %options ? (\%options) : ());
my $got_req = slurp($req_fh);
my $label = basename($file);
is( sort_headers($got_req), sort_headers($expect_req), "$label request" );
my ($rc) = $give_res =~ m{\S+\s+(\d+)}g;
is( $response->{status}, $rc, "$label response code $rc" )
or diag $response->{content};
if ( substr($rc,0,1) eq '2' ) {
ok( $response->{success}, "$label success flag true" );
}
else {
ok( ! $response->{success}, "$label success flag false" );
}
}
done_testing;
| 25.317647 | 82 | 0.550186 |
eda0d029a20556cd8e70a532f06285fb434b3c75 | 5,674 | pm | Perl | modules/Bio/EnsEMBL/Hive/Examples/Kmer/RunnableDB/CountKmers.pm | kiwiroy/ensembl-hive | d4b860d9bd0e185328b97223023eabc16539afe8 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Hive/Examples/Kmer/RunnableDB/CountKmers.pm | kiwiroy/ensembl-hive | d4b860d9bd0e185328b97223023eabc16539afe8 | [
"Apache-2.0"
] | null | null | null | modules/Bio/EnsEMBL/Hive/Examples/Kmer/RunnableDB/CountKmers.pm | kiwiroy/ensembl-hive | d4b860d9bd0e185328b97223023eabc16539afe8 | [
"Apache-2.0"
] | null | null | null | =pod
=head1 NAME
Bio::EnsEMBL::Hive::Examples::Kmer::RunnableDB::CountKmers
=head1 SYNOPSIS
Please refer to Bio::EnsEMBL::Hive::Examples::Kmer::PipeConfig::Kmer_conf pipeline configuration file
to understand how this particular example pipeline is configured and ran.
=head1 DESCRIPTION
'Bio::EnsEMBL::Hive::Examples::Kmer::RunnableDB::CountKmers is a runnable that counts the number of k-mers in a DNA sequence.
As input, it takes the name of a file with a DNA sequence,
the format of that file (which must be supported by Bio::SeqIO),
k (in bases),
k must be >= 1.
It flows out each k-mer seen, and the count of the k-mer in the (sub)sequence as key-value pairs.
The key is the k-mer, and the value being the count.
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2018] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
=head1 CONTACT
Please subscribe to the Hive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss Hive-related questions or to be notified of our updates
=cut
package Bio::EnsEMBL::Hive::Examples::Kmer::RunnableDB::CountKmers;
use strict;
use warnings;
use Bio::SeqIO;
use Data::Dumper;
use base ('Bio::EnsEMBL::Hive::Process');
=head2 fetch_input
Description : Implements fetch_input() interface method of Bio::EnsEMBL::Hive::Process that is used to read in parameters and load data.
There are no hard and fast rules on whether to fetch parameters in fetch_input(), or to wait until run() to fetch them.
In general, fetch_input() is a place to validate parameter existence and values for errors before the worker get set into RUN state
from the FETCH_INPUT state. In this case, since it's a simple computation, we don't do anything in fetch_input() and instead just
handle the parameters in run()
=cut
sub fetch_input {
}
=head2 run
Description : Implements run() interface method of Bio::EnsEMBL::Hive::Process that is used to perform the main bulk of the job (minus input and output).
Here, run() reads in the filename of a file containing a DNA sequence,
the format of that file (e.g. 'FASTA' - the format must be supported by Bio::SeqIO),
and k,
param('sequence_file'): Name of the file containing the sequence
param('input_format'): Format of the sequence file (e.g. FASTA)
param('k'): k
=cut
sub run {
my $self = shift;
my $sequence_file = $self->param_required('sequence_file');
my $input_format = $self->param('input_format');
my $k = $self->param_required('k');
my $input_seqio;
if ( $sequence_file =~ /\.(?:gz|Z)$/) {
open(my $in_fh, '-|', "gunzip -c $sequence_file");
$input_seqio = Bio::SeqIO->new(-fh => $in_fh, -format => $self->param_required('input_format'));
$self->param('input_fh', $in_fh); # storing as a param so that it can be closed by post_cleanup if necessary
} else {
$input_seqio = Bio::SeqIO->new(-file => $sequence_file);
}
die "Could not open or parse '$sequence_file', please investigate" unless $input_seqio;
my $kmer_counts = _count_kmers($input_seqio, $k);
$self->param('kmer_counts', $kmer_counts);
}
=head2 write_output
Description: Implements the write_output() interface method of Bio::EnsEMBL::Hive::Process that is used to flow output to the rest of the pipeline.
This is where we dataflow the kmer counts out to the rest of the pipeline. We do this in three different ways on three
different branches. Later on, we can choose a runnable to work with the counts we've generated here -- we choose
one of the branches to match the output format here to the input format that runnable expects.
=cut
sub write_output {
my $self = shift @_;
my $kmer_counts = $self->param('kmer_counts');
# Output the entire hash of kmer counts on flow 3
$self->dataflow_output_id( {'counts' => $kmer_counts, 'sequence_file' => $self->param('sequence_file')},
3);
# Output each kmer and count, tagged with the name of the sequence file it was counted in,
# on flow 4. Unlike flow 3, we put the output in a loop, creating several dataflow events,
# one for each kmer
foreach my $kmer(keys(%{$kmer_counts})) {
$self->dataflow_output_id( {
'count' => $kmer_counts->{$kmer},
'sequence_file' => $self->param('sequence_file'),
'kmer' => $kmer,
}, 4);
}
}
=head2 _count_kmers
Description: Private method to identify and count k-mers in a sequence.
Arg [1] : A Bio::SeqIO input filehandle.
Arg [2] : k
Return : A hashref of k-mer counts. key = k-mer, value = count
=cut
sub _count_kmers {
my ($seqio, $k) = @_;
my %kmer_counts;
while (my $seqobj = $seqio->next_seq()) {
my $seq = $seqobj->seq();
my $last_kmer_start = (length($seq) - $k) + 1;
for (my $i = 0; $i < $last_kmer_start; $i++) {
my $kmer = substr($seq, $i, $k);
$kmer_counts{$kmer}++;
}
}
return \%kmer_counts;
}
1;
| 33.77381 | 172 | 0.685583 |
ed050d58f6d4fc9bccf70656033cf36e63f950db | 3,203 | pl | Perl | SNPs_dataset/final_dataset/final_ds.pl | katnastou/VGICs | 5e93b47d7f18773ff49ae5c9857bd55f95e7b111 | [
"MIT"
] | null | null | null | SNPs_dataset/final_dataset/final_ds.pl | katnastou/VGICs | 5e93b47d7f18773ff49ae5c9857bd55f95e7b111 | [
"MIT"
] | null | null | null | SNPs_dataset/final_dataset/final_ds.pl | katnastou/VGICs | 5e93b47d7f18773ff49ae5c9857bd55f95e7b111 | [
"MIT"
] | null | null | null | #!usr/bin/perl -w
open (IN,'clinvar_ds.txt');
open (IN1,'uniprot_ds.txt');
#CACNA1A O00555 I 1810 L Pathogenic
#CACNA1A O00555 R 1661 H Pathogenic
while (<IN>)
{
if ($_=~/(\S+\t\S+\t\w{1}\t\d+\t\w{1}).*/)
{
push (@all, $_);#ολη η γραμμη σαν value του πινακα
push (@clinvar, $1);#εδω δεν τραβαμε το clinical significance,ωστε να γινει η ανιχνευση των κοινων snp μετα
}
}
#print "$#clinvar\t$#all";
#KCNA1 Q09470 V 408 A Disease
#KCNA1 Q09470 I 400 V Unclassified
while (<IN1>)
{
if ($_=~/(\S+\t\S+\t\w{1}\t\d+\t\w{1}).*/)
{
push (@alles, $_);
push (@uniprot, $1);
}
}
#print "$#uniprot\t$#alles";
for ($i=0;$i<=$#uniprot;$i++)
{
for ($j=0;$j<=$#clinvar;$j++)
{
if ($clinvar[$j]=~/$uniprot[$i]/)
{
push (@unique, $clinvar[$j]); #κρατας σε πινακα τις κοινες εγγραφες μεταξυ των δυο βασεων.Στη συνεχεια θα απαλοιφθουν απο τη UniProt και θα μεινουν μονο οι αναφορες της ClinVar
push (@unique_info, $all[$j]);
}
}
}
#print $#unique;
for ($i=0;$i<=$#uniprot;$i++)
{
for ($j=0;$j<=$#unique;$j++)
{
if ($uniprot[$i]=~/$unique[$j]/)
{
undef $alles[$i];#σε περιπτωση που κανει match, κανει undef τη γραμμη στον πινακα alles
}
}
}
@uniqueUniProt = grep { defined($_)}@alles; #εδω κραταει σε νεο πινακα μονο τις defined εγγραφες που εχουν απομεινει απο τον πινακα alles. Στην ουσια ειναι και οι εγγραφες που ειναι μοναδικες στη βαση UniProt
#print $#uniqueUniProt."\n";
for ($a=0;$a<=$#uniqueUniProt;$a++)
{
$uniqueUniProt[$a]=~s/Disease/Pathogenic/;
print $uniqueUniProt[$a];
}
for ($i=0;$i<=$#clinvar;$i++)
{
for ($j=0;$j<=$#unique;$j++)
{
if ($clinvar[$i]=~/$unique[$j]/)
{
undef $all[$i];#σε περιπτωση που κανει match, κανει undef τη γραμμη στον πινακα all
}
}
}
@uniqueClinVar = grep { defined($_)}@all; #εδω κραταει σε νεο πινακα μονο τις defined εγγραφες που εχουν απομεινει απο τον πινακα all. Στην ουσια ειναι και οι εγγραφες που ειναι μοναδικες στη βαση ClinVar
#print $#uniqueClinVar."\n";
for ($b=0;$b<=$#uniqueClinVar;$b++)
{
$uniqueClinVar[$b]=~s/Likely\spathogenic/Pathogenic/;
$uniqueClinVar[$b]=~s/Likely\sbenign/Polymorphism/;
$uniqueClinVar[$b]=~s/Benign/Polymorphism/;
$uniqueClinVar[$b]=~s/risk\sfactor/Polymorphism/;
$uniqueClinVar[$b]=~s/not\sprovided/Unclassified/;
$uniqueClinVar[$b]=~s/not\sreported/Unclassified/;
$uniqueClinVar[$b]=~s/Uncertain\ssignificance/Unclassified/;
$uniqueClinVar[$b]=~s/Conflicting\sinterpretations\sof\spathogenicity/Unclassified/;
$uniqueClinVar[$b]=~s/no interpretation for the single variant/Unclassified/;
print $uniqueClinVar[$b];
}
for ($b=0;$b<=$#unique_info;$b++)
{
$unique_info[$b]=~s/Likely\spathogenic/Pathogenic/;
$unique_info[$b]=~s/Likely\sbenign/Polymorphism/;
$unique_info[$b]=~s/Benign/Polymorphism/;
$unique_info[$b]=~s/risk\sfactor/Polymorphism/;
$unique_info[$b]=~s/not\sprovided/Unclassified/;
$unique_info[$b]=~s/not\sreported/Unclassified/;
$unique_info[$b]=~s/Uncertain\ssignificance/Unclassified/;
$unique_info[$b]=~s/Conflicting\sinterpretations\sof\spathogenicity/Unclassified/;
$unique_info[$b]=~s/no interpretation for the single variant/Unclassified/;
print $unique_info[$b];
}
#το output 8elei sortasisma (entolh sort -u sth grammh entolwn) | 30.504762 | 208 | 0.6803 |
ed731ee82f96051d88b96933fc1994a843dd3a22 | 2,493 | pm | Perl | lib/Test2/Require/Module.pm | robkinyon/Test2-Suite | c98b641b0c7e5366e281c9f9a81ea258778783f2 | [
"Artistic-1.0"
] | null | null | null | lib/Test2/Require/Module.pm | robkinyon/Test2-Suite | c98b641b0c7e5366e281c9f9a81ea258778783f2 | [
"Artistic-1.0"
] | null | null | null | lib/Test2/Require/Module.pm | robkinyon/Test2-Suite | c98b641b0c7e5366e281c9f9a81ea258778783f2 | [
"Artistic-1.0"
] | null | null | null | package Test2::Require::Module;
use strict;
use warnings;
use base 'Test2::Require';
our $VERSION = '0.000119';
use Test2::Util qw/pkg_to_file/;
sub skip {
my $class = shift;
my ($module, $ver) = @_;
return "Module '$module' is not installed"
unless check_installed($module);
return undef unless defined $ver;
return check_version($module, $ver);
}
sub check_installed {
my ($mod) = @_;
my $file = pkg_to_file($mod);
return 1 if eval { require $file; 1 };
my $error = $@;
return 0 if $error =~ m/Can't locate \Q$file\E in \@INC/;
# Some other error, rethrow it.
die $error;
}
sub check_version {
my ($mod, $ver) = @_;
return undef if eval { $mod->VERSION($ver); 1 };
my $have = $mod->VERSION;
return "Need '$mod' version $ver, have $have.";
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test2::Require::Module - Skip tests if certain packages are not installed, or
insufficient versions.
=head1 DESCRIPTION
Sometimes you have tests that are nice to run, but depend on tools that may not
be available. Instead of adding the tool as a dep, or making the test always
skip, it is common to make the test run conditionally. This package helps make
that possible.
This module is modeled after L<Test::Requires>. The difference is that this
module is based on L<Test2> directly, and does not go through L<Test::Builder>.
Another difference is that the packages you check for are not imported into
your namespace for you. This is intentional.
=head1 SYNOPSIS
# The test will be skipped unless Some::Module is installed, any version.
use Test2::Require::Module 'Some::Module';
# The test will be skipped unless 'Other::Module' is installed and at
# version '5.555' or greater.
use Test2::Require::Module 'Other::Module' => '5.555';
# We now need to use them directly, Test2::Require::Module does not import
# them for us.
use Some::Module;
use Other::Module;
=head1 SOURCE
The source code repository for Test2-Suite can be found at
F<https://github.com/Test-More/Test2-Suite/>.
=head1 MAINTAINERS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright 2018 Chad Granum E<lt>exodist@cpan.orgE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>
=cut
| 21.868421 | 79 | 0.691937 |
ed8a1b7953a887af0eecb5cb8c73de1bd9fc7488 | 20 | t | Perl | plugins/robots/generators/trik/trikQtsGeneratorLibrary/templates/switch/default.t | AlekseiPrivalihin/trik-studio | d19246f7a71306d1f847eee137a7bcd2ac67186f | [
"Apache-2.0"
] | 39 | 2015-01-26T16:18:43.000Z | 2021-12-20T23:36:41.000Z | plugins/robots/generators/trik/trikQtsGeneratorLibrary/templates/switch/default.t | AlekseiPrivalihin/trik-studio | d19246f7a71306d1f847eee137a7bcd2ac67186f | [
"Apache-2.0"
] | 1,248 | 2019-02-21T19:32:09.000Z | 2022-03-29T16:50:04.000Z | plugins/robots/generators/trik/trikQtsGeneratorLibrary/templates/switch/default.t | AlekseiPrivalihin/trik-studio | d19246f7a71306d1f847eee137a7bcd2ac67186f | [
"Apache-2.0"
] | 58 | 2015-03-03T12:57:28.000Z | 2020-05-09T15:54:42.000Z | } else {
@@BODY@@
}
| 5 | 8 | 0.4 |
edb66bf3149d48c6423d9d434e2d328a66eb971a | 19 | pl | Perl | egs/wsj/s5/utils/lang/validate_lang.pl | mianmian3/kaldi | 47f14cbf5de70f9832bbf1a116b43f9beb090d27 | [
"Apache-2.0"
] | 805 | 2018-05-28T02:32:04.000Z | 2022-03-26T09:13:12.000Z | egs/wsj/s5/utils/lang/validate_lang.pl | mianmian3/kaldi | 47f14cbf5de70f9832bbf1a116b43f9beb090d27 | [
"Apache-2.0"
] | 59 | 2021-02-26T21:37:03.000Z | 2022-03-24T16:57:12.000Z | egs/wsj/s5/utils/lang/validate_lang.pl | mianmian3/kaldi | 47f14cbf5de70f9832bbf1a116b43f9beb090d27 | [
"Apache-2.0"
] | 267 | 2018-06-07T08:33:28.000Z | 2022-03-30T12:18:33.000Z | ../validate_lang.pl | 19 | 19 | 0.789474 |
ed790253927d80870aa4a94229575b8a83d8c2c0 | 5,325 | pl | Perl | perl/vendor/lib/auto/share/dist/DateTime-Locale/es-HN.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | null | null | null | perl/vendor/lib/auto/share/dist/DateTime-Locale/es-HN.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | 3 | 2021-01-27T10:09:28.000Z | 2021-05-11T21:20:12.000Z | perl/vendor/lib/auto/share/dist/DateTime-Locale/es-HN.pl | Light2027/OnlineCampusSandbox | 8dcaaf62af1342470f9e7be6d42bd0f16eb910b8 | [
"Apache-2.0"
] | null | null | null | {
am_pm_abbreviated => [
"a.\N{U+00a0}m.",
"p.\N{U+00a0}m.",
],
available_formats => {
Bh => "h B",
Bhm => "h:mm B",
Bhms => "h:mm:ss B",
E => "ccc",
EBhm => "E h:mm B",
EBhms => "E h:mm:ss B",
EHm => "E, HH:mm",
EHms => "E, HH:mm:ss",
Ed => "E d",
Ehm => "E, h:mm a",
Ehms => "E, h:mm:ss a",
Gy => "y G",
GyMMM => "MMM y G",
GyMMMEd => "E, d MMM y G",
GyMMMM => "MMMM 'de' y G",
GyMMMMEd => "E, d 'de' MMMM 'de' y G",
GyMMMMd => "d 'de' MMMM 'de' y G",
GyMMMd => "d 'de' MMM 'de' y G",
H => "HH",
Hm => "HH:mm",
Hms => "HH:mm:ss",
Hmsv => "H:mm:ss v",
Hmsvvvv => "H:mm:ss (vvvv)",
Hmv => "H:mm v",
M => "L",
MEd => "E, d/M",
MMM => "LLL",
MMMEd => "E, d MMM",
MMMMEd => "E, d 'de' MMMM",
"MMMMW-count-one" => "'semana' W 'de' MMMM",
"MMMMW-count-other" => "'semana' W 'de' MMMM",
MMMMd => "d 'de' MMMM",
MMMd => "d MMM",
MMMdd => "dd-MMM",
MMd => "d/M",
MMdd => "d/M",
Md => "d/M",
d => "d",
h => "h a",
hm => "h:mm a",
hms => "h:mm:ss a",
hmsv => "h:mm:ss a v",
hmsvvvv => "h:mm:ss a (vvvv)",
hmv => "h:mm a v",
ms => "mm:ss",
y => "y",
yM => "M/y",
yMEd => "E d/M/y",
yMM => "M/y",
yMMM => "MMMM 'de' y",
yMMMEd => "E, d 'de' MMM 'de' y",
yMMMM => "MMMM 'de' y",
yMMMMEd => "EEE, d 'de' MMMM 'de' y",
yMMMMd => "d 'de' MMMM 'de' y",
yMMMd => "d 'de' MMMM 'de' y",
yMd => "d/M/y",
yQQQ => "QQQ 'de' y",
yQQQQ => "QQQQ 'de' y",
"yw-count-one" => "'semana' w 'de' Y",
"yw-count-other" => "'semana' w 'de' Y",
},
code => "es-HN",
date_format_full => "EEEE dd 'de' MMMM 'de' y",
date_format_long => "dd 'de' MMMM 'de' y",
date_format_medium => "d MMM y",
date_format_short => "d/M/yy",
datetime_format_full => "{1} 'a' 'las' {0}",
datetime_format_long => "{1} 'a' 'las' {0}",
datetime_format_medium => "{1} {0}",
datetime_format_short => "{1} {0}",
day_format_abbreviated => [
"lun.",
"mar.",
"mi\N{U+00e9}.",
"jue.",
"vie.",
"s\N{U+00e1}b.",
"dom.",
],
day_format_narrow => [
"l",
"m",
"m",
"j",
"v",
"s",
"d",
],
day_format_wide => [
"lunes",
"martes",
"mi\N{U+00e9}rcoles",
"jueves",
"viernes",
"s\N{U+00e1}bado",
"domingo",
],
day_stand_alone_abbreviated => [
"lun.",
"mar.",
"mi\N{U+00e9}.",
"jue.",
"vie.",
"s\N{U+00e1}b.",
"dom.",
],
day_stand_alone_narrow => [
"L",
"M",
"M",
"J",
"V",
"S",
"D",
],
day_stand_alone_wide => [
"lunes",
"martes",
"mi\N{U+00e9}rcoles",
"jueves",
"viernes",
"s\N{U+00e1}bado",
"domingo",
],
era_abbreviated => [
"a. C.",
"d. C.",
],
era_narrow => [
"a. C.",
"d. C.",
],
era_wide => [
"antes de Cristo",
"despu\N{U+00e9}s de Cristo",
],
first_day_of_week => 7,
glibc_date_1_format => "%a %b %e %H:%M:%S %Z %Y",
glibc_date_format => "%d/%m/%y",
glibc_datetime_format => "%a %d %b %Y %T %Z",
glibc_time_12_format => "%I:%M:%S %p",
glibc_time_format => "%T",
language => "Spanish",
month_format_abbreviated => [
"ene.",
"feb.",
"mar.",
"abr.",
"may.",
"jun.",
"jul.",
"ago.",
"sep.",
"oct.",
"nov.",
"dic.",
],
month_format_narrow => [
"E",
"F",
"M",
"A",
"M",
"J",
"J",
"A",
"S",
"O",
"N",
"D",
],
month_format_wide => [
"enero",
"febrero",
"marzo",
"abril",
"mayo",
"junio",
"julio",
"agosto",
"septiembre",
"octubre",
"noviembre",
"diciembre",
],
month_stand_alone_abbreviated => [
"ene.",
"feb.",
"mar.",
"abr.",
"may.",
"jun.",
"jul.",
"ago.",
"sep.",
"oct.",
"nov.",
"dic.",
],
month_stand_alone_narrow => [
"E",
"F",
"M",
"A",
"M",
"J",
"J",
"A",
"S",
"O",
"N",
"D",
],
month_stand_alone_wide => [
"enero",
"febrero",
"marzo",
"abril",
"mayo",
"junio",
"julio",
"agosto",
"septiembre",
"octubre",
"noviembre",
"diciembre",
],
name => "Spanish Honduras",
native_language => "espa\N{U+00f1}ol",
native_name => "espa\N{U+00f1}ol Honduras",
native_script => undef,
native_territory => "Honduras",
native_variant => undef,
quarter_format_abbreviated => [
"T1",
"T2",
"T3",
"T4",
],
quarter_format_narrow => [
1,
2,
3,
4,
],
quarter_format_wide => [
"1.\N{U+00ba} trimestre",
"2.\N{U+00ba} trimestre",
"3.\N{U+00ba} trimestre",
"4.\N{U+00ba} trimestre",
],
quarter_stand_alone_abbreviated => [
"T1",
"T2",
"T3",
"T4",
],
quarter_stand_alone_narrow => [
1,
2,
3,
4,
],
quarter_stand_alone_wide => [
"1.\N{U+00ba} trimestre",
"2.\N{U+00ba} trimestre",
"3.\N{U+00ba} trimestre",
"4.\N{U+00ba} trimestre",
],
script => undef,
territory => "Honduras",
time_format_full => "HH:mm:ss zzzz",
time_format_long => "HH:mm:ss z",
time_format_medium => "HH:mm:ss",
time_format_short => "HH:mm",
variant => undef,
version => 36,
}
| 18.684211 | 51 | 0.445258 |
ed565f84dc6caa08d5f2b674c996a307f7c3091b | 2,278 | pl | Perl | script/enjusync/get-statusfile.pl | MiraitSystems/enju_trunk | 05ec8eb2d8c8e76ec33269925aac97b78c1431ca | [
"MIT"
] | null | null | null | script/enjusync/get-statusfile.pl | MiraitSystems/enju_trunk | 05ec8eb2d8c8e76ec33269925aac97b78c1431ca | [
"MIT"
] | null | null | null | script/enjusync/get-statusfile.pl | MiraitSystems/enju_trunk | 05ec8eb2d8c8e76ec33269925aac97b78c1431ca | [
"MIT"
] | 1 | 2018-12-12T08:57:51.000Z | 2018-12-12T08:57:51.000Z | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0;
my $pname = $0; $pname =~ s/.*\/(.*)/$1/s; # プログラム名取得
#
# ステータスファイル受信処理
#
# get-statusfile.pl
#
use strict;
use vars qw/$opt_d/;
use vars qw/$BucketDir $RecvDir $StatFileDir $LockFile/;
use Getopt::Std;
use Net::FTP;
use Cwd;
my $debug = 0;
getopts('d');
if ( $opt_d ) { $debug = 1; }
# コンフィグレーションの設定
require "./conf.pl";
# syslogモジュール
require "./logpkg.pl";
# グローバル変数
my $cur_dir = Cwd::cwd(); # カレントディレクトリ
my $get_bucket = "";
my $ctrl_file = "";
my $snd_host = "webopac";
my $ftp_user = "ftpenju";
my $ftp_pass = "gota2k12nda";
my $send_stat = "";
# 引数のチェック
my $opt = $#ARGV+1;
if ( $opt != 0 ) {
print STDERR "NG:usage get-statusfile.pl\n";
exit 1;
}
# 受信ディレクトリへ移動
#
unless (chdir $StatFileDir) {
wrt_log($pname, 'err', "Can not change $StatFileDir:$!");
exit 2;
}
# FTP受信開始
#
# FTPサーバへ接続
my $ftp = Net::FTP->new($snd_host);
if ($@) {
wrt_log($pname, 'err', "Can not access to $snd_host:$!");
close(LCK);
exit 2;
}
# FTPログイン
unless ($ftp->login($ftp_user, $ftp_pass)) {
wrt_log($pname, 'err', "Can not login '$snd_host:$ftp_user':" . $ftp->message);
close(LCK);
exit 2;
}
# FTPオプション
$ftp->pasv();
$ftp->binary;
# バケットのあるディレクトリへ移動
$ftp->cwd("$RecvDir");
if ($debug) {printf "current dir = %s\n", $ftp->pwd();}
# 受信開始
#
wrt_log($pname, 'info', "START receive status.marshal");
# 該当する status.marshal を検索
my @file_lst = $ftp->ls('*');
my @imp_lst = grep(/^\d*\/\d+.*-IMP-\d+\.ctl/, @file_lst);
if ($debug) {foreach my $imp ( @imp_lst ) { print "$imp\n"; }}
if ( @imp_lst ) {
# リストをソート (降順)
@imp_lst = map {$_->[0]}
sort {$b->[1] <=> $a->[1]}
map {[$_, /^(\d+)\/\w+/]} @imp_lst;
if ($debug) {my $i=0; foreach my $imp ( @imp_lst ) { printf "imp[%d] = %s\n", $i++, $imp; }}
}
# IDが一番大きい && コントロールファイルは"IMP"
# -> $imp_lst[0] を選択
#
# バケットディレクトリとコントロールファイルを分離
$imp_lst[0] =~ /(\d*)\/.*\.ctl/;
$get_bucket = $1;
if ($debug) {print "get_bucket = $get_bucket\n";}
# 該当するバケットへ移動
$ftp->cwd("$get_bucket");
if ($debug) {printf "current dir = %s\n", $ftp->pwd();}
# status.marshal を取得
unless ( $ftp->get("status.marshal") ) {
wrt_log($pname, 'err', "Can not receive status.marshal:" . $ftp->message);
$ftp->quit;
exit 2;
}
$ftp->quit;
wrt_log($pname, 'info', "END receive status.marshal");
exit;
| 19.142857 | 93 | 0.593942 |
ed44445c6ee9c7568d40f7d677f847fb41df9a32 | 91 | t | Perl | test/files/44-auth-basic-invalid.t | jferrant/libhtp | aff5fb54b5eaca4b82a097a6efc4c421c0962a15 | [
"BSD-3-Clause"
] | 203 | 2015-01-31T16:16:00.000Z | 2022-03-08T07:09:36.000Z | test/files/44-auth-basic-invalid.t | jferrant/libhtp | aff5fb54b5eaca4b82a097a6efc4c421c0962a15 | [
"BSD-3-Clause"
] | 167 | 2015-02-18T13:20:05.000Z | 2022-03-16T08:58:15.000Z | test/files/44-auth-basic-invalid.t | jferrant/libhtp | aff5fb54b5eaca4b82a097a6efc4c421c0962a15 | [
"BSD-3-Clause"
] | 96 | 2015-01-02T19:51:54.000Z | 2022-03-11T02:17:12.000Z | >>>
GET / HTTP/1.0
Host: www.example.com
Authorization: Basic notBase64:EncodedStuff
| 15.166667 | 44 | 0.714286 |
ed49384c02d042e4524e9b9ff06f18aa40bf08e2 | 2,734 | pm | Perl | perl/vendor/lib/IO/All/Filesys.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 2 | 2021-01-15T03:18:15.000Z | 2021-01-15T04:16:18.000Z | perl/vendor/lib/IO/All/Filesys.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 6 | 2021-11-18T00:39:48.000Z | 2021-11-20T00:31:40.000Z | perl/vendor/lib/IO/All/Filesys.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
] | 1 | 2021-01-15T03:18:16.000Z | 2021-01-15T03:18:16.000Z | use strict; use warnings;
package IO::All::Filesys;
use IO::All::Base -base;
use Fcntl qw(:flock);
my %spec_map = (
unix => 'Unix',
win32 => 'Win32',
vms => 'VMS',
mac => 'Mac',
os2 => 'OS2',
);
sub os {
my ($self, $type) = @_;
my ($v, $d, $f) = $self->_spec_class->splitpath($self->name);
my @d = $self->_spec_class->splitdir($d);
$self->_spec_class($spec_map{$type});
$self->name( $self->_spec_class->catfile( @d, $f ) );
return $self
}
sub exists { my $self = shift; -e $self->name }
sub filename {
my $self = shift;
my $filename;
(undef, undef, $filename) = $self->splitpath;
return $filename;
}
sub ext {
my $self = shift;
return $1 if $self->filename =~ m/\.([^\.]+)$/
}
{
no warnings 'once';
*extension = \&ext;
}
sub mimetype {
require File::MimeInfo;
return File::MimeInfo::mimetype($_[0]->filename)
}
sub is_absolute {
my $self = shift;
return *$self->{is_absolute} = shift if @_;
return *$self->{is_absolute}
if defined *$self->{is_absolute};
*$self->{is_absolute} = IO::All::is_absolute($self) ? 1 : 0;
}
sub is_executable { my $self = shift; -x $self->name }
sub is_readable { my $self = shift; -r $self->name }
sub is_writable { my $self = shift; -w $self->name }
{
no warnings 'once';
*is_writeable = \&is_writable;
}
sub pathname {
my $self = shift;
return *$self->{pathname} = shift if @_;
return *$self->{pathname} if defined *$self->{pathname};
return $self->name;
}
sub relative {
my $self = shift;
if (my $base = $_[0]) {
$self->pathname(File::Spec->abs2rel($self->pathname, $base))
} elsif ($self->is_absolute) {
$self->pathname(File::Spec->abs2rel($self->pathname))
}
$self->is_absolute(0);
return $self;
}
sub rename {
my $self = shift;
my $new = shift;
rename($self->name, "$new")
? UNIVERSAL::isa($new, 'IO::All')
? $new
: $self->_constructor->($new)
: undef;
}
sub set_lock {
my $self = shift;
return unless $self->_lock;
my $io_handle = $self->io_handle;
my $flag = $self->mode =~ /^>>?$/
? LOCK_EX
: LOCK_SH;
flock $io_handle, $flag;
}
sub stat {
my $self = shift;
return IO::All::stat($self, @_)
if $self->is_open;
CORE::stat($self->pathname);
}
sub touch {
my $self = shift;
$self->utime;
}
sub unlock {
my $self = shift;
flock $self->io_handle, LOCK_UN
if $self->_lock;
}
sub utime {
my $self = shift;
my $atime = shift;
my $mtime = shift;
$atime = time unless defined $atime;
$mtime = $atime unless defined $mtime;
utime($atime, $mtime, $self->name);
return $self;
}
1;
| 20.402985 | 67 | 0.561083 |
edad0a7283504597ea31a4a306942b379aefd73f | 7,462 | pm | Perl | apps/vmware/connector/mode/thinprovisioningvm.pm | centreon-lab/centreon-plugins | 68096c697a9e1baf89a712674a193d9a9321503c | [
"Apache-2.0"
] | null | null | null | apps/vmware/connector/mode/thinprovisioningvm.pm | centreon-lab/centreon-plugins | 68096c697a9e1baf89a712674a193d9a9321503c | [
"Apache-2.0"
] | null | null | null | apps/vmware/connector/mode/thinprovisioningvm.pm | centreon-lab/centreon-plugins | 68096c697a9e1baf89a712674a193d9a9321503c | [
"Apache-2.0"
] | null | null | null | #
# Copyright 2022 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::vmware::connector::mode::thinprovisioningvm;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"vm-hostname:s" => { name => 'vm_hostname' },
"filter" => { name => 'filter' },
"scope-datacenter:s" => { name => 'scope_datacenter' },
"scope-cluster:s" => { name => 'scope_cluster' },
"scope-host:s" => { name => 'scope_host' },
"filter-description:s" => { name => 'filter_description' },
"filter-os:s" => { name => 'filter_os' },
"filter-uuid:s" => { name => 'filter_uuid' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"nopoweredon-skip" => { name => 'nopoweredon_skip' },
"display-description" => { name => 'display_description' },
"thinprovisioning-status:s" => { name => 'thinprovisioning_status' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
if (defined($self->{option_results}->{thinprovisioning_status}) && $self->{option_results}->{thinprovisioning_status} ne '') {
($self->{thin_entry}, $self->{thin_status}) = split /,/, $self->{option_results}->{thinprovisioning_status};
if ($self->{thin_entry} !~ /^(notactive|active)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong thinprovisioning-status option. Can only be 'active' or 'noactive'. Not: '" . $self->{thin_entry} . "'.");
$self->{output}->option_exit();
}
if ($self->{output}->is_litteral_status(status => $self->{thin_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong thinprovisioning-status option. Not a good status: '" . $self->{thin_status} . "'.");
$self->{output}->option_exit();
}
}
}
sub display_verbose {
my ($self, %options) = @_;
foreach my $vm (sort keys %{$options{vms}}) {
my $prefix = $vm;
if (defined($options{vms}->{$vm}->{description}) && $options{vms}->{$vm}->{description} ne '') {
$prefix .= ' [' . $options{vms}->{$vm}->{description} . ']';
}
$self->{output}->output_add(long_msg => $prefix);
foreach my $disk (sort keys %{$options{vms}->{$vm}->{disks}}) {
$self->{output}->output_add(long_msg => ' ' . $disk);
}
}
}
sub run {
my ($self, %options) = @_;
my $response = $options{custom}->execute(params => $self->{option_results},
command => 'thinprovisioningvm');
my $multiple = 0;
if (scalar(keys %{$response->{data}}) > 1) {
$multiple = 1;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All thinprovisoning virtualdisks are ok.');
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => 'Thinprovisoning virtualdisks are ok.');
}
my $disks_vm = {};
my %maps_match = ('active' => { regexp => '^1$', output => 'VirtualDisks thinprovisioning actived' },
'notactive' => { regexp => '^(?!(1)$)', output => 'VirtualDisks thinprovisioning not actived' });
my $num = 0;
foreach my $vm_id (sort keys %{$response->{data}}) {
my $vm_name = $response->{data}->{$vm_id}->{name};
if ($options{custom}->entity_is_connected(state => $response->{data}->{$vm_id}->{connection_state}) == 0) {
my $output = "VM '" . $vm_name . "' not connected. Current Connection State: '$response->{data}->{$vm_id}->{connection_state}'.";
if ($multiple == 0 ||
!$self->{output}->is_status(value => $self->{option_results}->{disconnect_status}, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $self->{option_results}->{disconnect_status},
short_msg => $output);
}
next;
}
next if (defined($self->{option_results}->{nopoweredon_skip}) &&
$options{custom}->vm_is_running(power => $response->{data}->{$vm_id}->{power_state}) == 0);
foreach (@{$response->{data}->{$vm_id}->{disks}}) {
if (defined($self->{thin_entry}) && $_->{thin_provisioned} =~ /$maps_match{$self->{thin_entry}}->{regexp}/) {
$num++;
if (!defined($disks_vm->{$vm_name})) {
$disks_vm->{$vm_name} = { disks => {}, description => (defined($self->{option_results}->{display_description}) ? $options{custom}->strip_cr(value => $response->{data}->{$vm_id}->{'config.annotation'}) : undef) };
}
$disks_vm->{$vm_name}->{disks}->{$_->{name}} = 1;
}
}
}
if ($num > 0) {
$self->{output}->output_add(severity => $self->{thin_status},
short_msg => sprintf('%d %s', $num, $maps_match{$self->{thin_entry}}->{output}));
$self->display_verbose(vms => $disks_vm);
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check virtual machine thin provisioning option.
=over 8
=item B<--vm-hostname>
VM hostname to check.
If not set, we check all VMs.
=item B<--filter>
VM hostname is a regexp.
=item B<--filter-description>
Filter also virtual machines description (can be a regexp).
=item B<--filter-os>
Filter also virtual machines OS name (can be a regexp).
=item B<--scope-datacenter>
Search in following datacenter(s) (can be a regexp).
=item B<--scope-cluster>
Search in following cluster(s) (can be a regexp).
=item B<--scope-host>
Search in following host(s) (can be a regexp).
=item B<--disconnect-status>
Status if VM disconnected (default: 'unknown').
=item B<--nopoweredon-skip>
Skip check if VM is not poweredOn.
=item B<--display-description>
Display virtual machine description.
=item B<--thinprovisioning-status>
Thinprovisioning status (default: none)
Example: 'active,CRITICAL' or 'notactive,WARNING'
=back
=cut
| 36.4 | 232 | 0.574645 |
edc084ccb930aa042592f5cc4de6557fefa4958e | 1,613 | t | Perl | dist/scripts/io/imagewrite.t | PyryM/truss | 4ad0b098dc7c946bf4f9fdedc68a18ded199e6b2 | [
"MIT"
] | 3 | 2016-09-25T01:12:52.000Z | 2018-04-20T07:09:30.000Z | dist/scripts/io/imagewrite.t | PyryM/truss | 4ad0b098dc7c946bf4f9fdedc68a18ded199e6b2 | [
"MIT"
] | 16 | 2016-06-11T23:32:43.000Z | 2021-06-12T14:35:26.000Z | dist/scripts/io/imagewrite.t | PyryM/truss | 4ad0b098dc7c946bf4f9fdedc68a18ded199e6b2 | [
"MIT"
] | 3 | 2016-10-01T01:12:16.000Z | 2021-03-19T15:41:29.000Z | -- io/imagewrite.t
--
-- basic (pure lua/terra) image writing uncompressed images
local m = {}
struct m.TGAHeader {
idlength: uint8;
colourmaptype: uint8;
datatypecode: uint8;
nonsense: uint8[5];
x_origin: uint16;
y_origin: uint16;
width: uint16;
height: uint16;
bitsperpixel: uint8;
imagedescriptor: uint8;
}
function m.create_tga(width, height, data, dest_buff)
local header = terralib.new(m.TGAHeader)
header.idlength = 0
header.colourmaptype = 0
header.datatypecode = 2 -- uncompressed rgba
for i = 0,4 do header.nonsense[i] = 0 end
header.x_origin = 0
header.y_origin = 0
header.width = width
header.height = height
header.bitsperpixel = 32
header.imagedescriptor = 8 -- alpha??
local dsize = (width * height * 4) + 100
local bb = dest_buff or require("util/string.t").ByteBuffer(dsize)
bb:append_struct(header, sizeof(m.TGAHeader))
bb:append_bytes(data, width*height*4)
return bb
end
function m.flip_rgba_vertical(width, height, data)
local ipos = 0
local mid = math.floor(height / 2)
local rowsize = width*4
for r = 0, mid-1 do
local r_mirrored = (height - 1) - r
local p0 = r*width*4
local p1 = r_mirrored*width*4
for c = 0,rowsize do
local a,b = p0+c, p1+c
data[a], data[b] = data[b], data[a]
end
end
end
function m.write_tga(width, height, data, filename)
local bb = m.create_tga(width, height, data)
--bb:write_to_file(filename)
-- HACK: use Lua IO
local outfile = io.open(filename, "wb")
local data = ffi.string(bb._data, bb._cur_size)
outfile:write(data)
outfile:close()
end
return m
| 24.815385 | 68 | 0.682579 |
edae5f3ec8d6453be8ee36d10fe8b2338f921c26 | 36,894 | pm | Perl | src/Math-Random-0.69/Random.pm | biologic/stylus | ae642bbb7e2205bab1ab1b4703ea037e996e13db | [
"Apache-2.0"
] | null | null | null | src/Math-Random-0.69/Random.pm | biologic/stylus | ae642bbb7e2205bab1ab1b4703ea037e996e13db | [
"Apache-2.0"
] | null | null | null | src/Math-Random-0.69/Random.pm | biologic/stylus | ae642bbb7e2205bab1ab1b4703ea037e996e13db | [
"Apache-2.0"
] | null | null | null | package Math::Random;
use strict;
use Carp;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
require Exporter;
require DynaLoader;
require AutoLoader;
@ISA = qw(Exporter DynaLoader);
$VERSION = '0.69';
@EXPORT = qw(random_normal
random_permutation
random_permuted_index
random_uniform
random_uniform_integer
random_seed_from_phrase
random_get_seed
random_set_seed_from_phrase
random_set_seed
);
@EXPORT_OK = qw(random_beta
random_chi_square
random_exponential
random_f
random_gamma
random_multivariate_normal
random_multinomial
random_noncentral_chi_square
random_noncentral_f
random_normal
random_permutation
random_permuted_index
random_uniform
random_poisson
random_uniform_integer
random_negative_binomial
random_binomial
random_seed_from_phrase
random_get_seed
random_set_seed_from_phrase
random_set_seed
);
%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
my $constname;
($constname = $AUTOLOAD) =~ s/.*:://;
croak "& not defined" if $constname eq 'constant';
my $val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
croak "Your vendor has not defined Math::Random macro $constname";
}
}
*$AUTOLOAD = sub () { $val };
goto &$AUTOLOAD;
}
bootstrap Math::Random $VERSION;
### set seeds by default
salfph(scalar(localtime()));
#####################################################################
# RANDOM DEVIATE GENERATORS #
#####################################################################
sub random_beta { # Arguments: ($n,$aa,$bb)
croak "Usage: random_beta(\$n,\$aa,\$bb)" if scalar(@_) < 3;
my($n, $aa, $bb) = @_;
croak("($aa = \$aa < 1.0E-37) or ($bb = \$bb < 1.0E-37)\nin ".
"random_beta(\$n,\$aa,\$bb)")
if (($aa < 1.0E-37) or ($bb < 1.0E-37));
return genbet($aa,$bb) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = genbet($aa,$bb); }
return @ans;
}
sub random_chi_square { # Arguments: ($n,$df)
croak "Usage: random_chi_square(\$n,\$df)" if scalar(@_) < 2;
my($n, $df) = @_;
croak "$df = \$df <= 0\nin random_chi_square(\$n,\$df)" if ($df <= 0);
return genchi($df) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = genchi($df); }
return @ans;
}
sub random_exponential { # Arguments: ($n,$av), defaults (1,1)
return wantarray() ? (genexp(1)) : genexp(1)
if scalar(@_) == 0; # default behavior if no arguments
my($n, $av) = @_;
$av = 1 unless defined($av); # default $av is 1
croak "$av = \$av < 0\nin random_exponential(\$n,\$av)" if ($av < 0);
return genexp($av) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = genexp($av); }
return @ans;
}
sub random_f { # Arguments: ($n,$dfn,$dfd)
croak "Usage: random_f(\$n,\$dfn,\$dfd)" if scalar(@_) < 3;
my($n, $dfn, $dfd) = @_;
croak("($dfn = \$dfn <= 0) or ($dfd = \$dfd <= 0)\nin ".
"random_f(\$n,\$dfn,\$dfd)") if (($dfn <= 0) or ($dfd <= 0));
return genf($dfn,$dfd) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = genf($dfn,$dfd); }
return @ans;
}
sub random_gamma { # Arguments: ($n,$a,$r)
croak "Usage: random_gamma(\$n,\$a,\$r)" if scalar(@_) < 3;
my($n, $a, $r) = @_;
croak "($a = \$a <= 0) or ($r = \$r <= 0)\nin random_gamma(\$n,\$a,\$r)"
if (($a <= 0) or ($r <= 0));
return gengam($a,$r) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = gengam($a,$r); }
return @ans;
}
sub random_multivariate_normal { # Arguments: ($n, @mean, @covar(2-dim'l))
croak "Usage: random_multivariate_normal(\$n,\@mean,\@covar(2-dim'l))"
if (scalar(@_)) < 3;
my $n = shift(@_); # first element is number of obs. desired
my $p = scalar(@_)/2; # best guess at dimension of deviate
# check outline of arguments
croak("Sizes of \@mean and \@covar don't match\nin ".
"random_multivariate_normal(\$n, \@mean, \@covar(2-dim'l))")
unless (($p == int($p)) and ("$_[$p - 1]" !~ /^ARRAY/) and
("$_[$p]" =~ /^ARRAY/));
# linearize input - it seems faster to push
my @linear = ();
push @linear, splice(@_, 0, $p); # fill first $p slots w/ mean
# expand array references
my $ref;
foreach $ref (@_) { # for the rest of the input
# check length of row of @covariance
croak("\@covar is not a $p by $p array ($p is size of \@mean)\nin ".
"random_multivariate_normal(\$n, \@mean, \@covar(2-dim'l))")
unless (scalar(@{$ref}) == $p);
push @linear, @{$ref};
}
# load float working array with linearized input
putflt(@linear) or
croak "Unable to allocate memory\nin random_multivariate_normal";
# initialize parameter array for multivariate normal generator
psetmn($p) or
croak "Unable to allocate memory\nin random_multivariate_normal";
unless (wantarray()) {
### if called in a scalar context, returns single refernce to obs
pgenmn();
return [ getflt($p) ];
}
# otherwise return an $n by $p array of obs.
my @ans = (0) x $n;
foreach $ref (@ans) {
pgenmn();
$ref = [ getflt($p) ];
}
return @ans;
}
sub random_multinomial { # Arguments: ($n,@p)
my($n, @p) = @_;
my $ncat = scalar(@p); # number of categories
$n = int($n);
croak "$n = \$n < 0\nin random_multinomial(\$n,\@p)" if ($n < 0);
croak "$ncat = (length of \@p) < 2\nin random_multinomial(\$n,\@p)"
if ($ncat < 2);
rspriw($ncat) or croak "Unable to allocate memory\nin random_multinomial";
my($i,$sum,$val) = (0,0,0);
pop @p;
rsprfw(scalar(@p)) or
croak "Unable to allocate memory\nin random_multinomial";
foreach $val (@p) {
croak "$val = (some \$p[i]) < 0 or > 1\nin random_multinomial(\$n,\@p)"
if (($val < 0) or ($val > 1));
svprfw($i,$val);
$i++;
$sum += $val;
}
croak "Sum of \@p > 1\nin random_multinomial(\$n,\@p)" if ($sum > 0.99999);
pgnmul($n, $ncat);
### get the results
$i = 0;
foreach $val (@p) {
$val = gvpriw($i);
$i++;
}
push @p, gvpriw($i);
return @p;
}
sub random_noncentral_chi_square { # Arguments: ($n,$df,$nonc)
croak "Usage: random_noncentral_chi_square(\$n,\$df,\$nonc)"
if scalar(@_) < 3;
my($n, $df, $nonc) = @_;
croak("($df = \$df < 1) or ($nonc = \$nonc) < 0\n".
"in random_noncentral_chi_square(\$n,\$df,\$nonc)")
if (($df < 1) or ($nonc < 0));
return gennch($df,$nonc) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = gennch($df,$nonc); }
return @ans;
}
sub random_noncentral_f { # Arguments: ($n,$dfn,$dfd,$nonc)
croak "Usage: random_noncentral_f(\$n,\$dfn,\$dfd,\$nonc)"
if scalar(@_) < 4;
my($n, $dfn, $dfd, $nonc) = @_;
croak("($dfn = \$dfn < 1) or ($dfd = \$dfd <= 0) or ($nonc ".
"= \$nonc < 0)\nin random_noncentral_f(\$n,\$dfn,\$dfd,\$nonc)")
if (($dfn < 1) or ($dfd <= 0) or ($nonc < 0));
return gennf($dfn,$dfd,$nonc) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = gennf($dfn,$dfd,$nonc); }
return @ans;
}
sub random_normal { # Arguments: ($n,$av,$sd), defaults (1,0,1)
return wantarray() ? (gennor(0,1)) : gennor(0,1)
if scalar(@_) == 0; # default behavior if no arguments
my($n, $av, $sd) = @_;
$av = 0 unless defined($av); # $av defaults to 0
$sd = 1 unless defined($sd); # $sd defaults to 1, even if $av specified
croak "$sd = \$sd < 0\nin random_normal([\$n[,\$av[,\$sd]]])" if ($sd < 0);
return gennor($av,$sd) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = gennor($av,$sd); }
return @ans;
}
sub random_permutation { # Argument: (@array) - array to be permuted.
my $n = scalar(@_); # number of elements to be permuted
return () if $n == 0;
rspriw($n) or
croak "Unable to allocate memory\nin random_permutation";
pgnprm($n);
my($val, $i) = (0,0);
my @ans = (0) x $n;
foreach $val (@ans) {
$val = gvpriw($i);
$i++;
}
return @_[@ans];
}
sub random_permuted_index { # Argument: $n = scalar(@array) (for permutation)
croak "Usage: random_permuted_index(\$n)" if scalar(@_) < 1;
my $n = int(shift(@_)); # number of elements to be permuted
croak "$n = \$n < 0 in random_permuted_index(\$n)" if $n < 0;
return () if $n == 0;
rspriw($n) or
croak "Unable to allocate memory\nin random_permuted_index";
pgnprm($n);
my($val, $i) = (0,0);
my @ans = (0) x $n;
foreach $val (@ans) {
$val = gvpriw($i);
$i++;
}
return @ans;
}
sub random_uniform { # Arguments: ($n,$low,$high), defaults (1,0,1)
return wantarray() ? (genunf(0,1)) : genunf(0,1)
if scalar(@_) == 0;
croak "Usage: random_uniform([\$n,[\$low,\$high]])"
if scalar(@_) == 2; # only default is (0,1) for ($low,$high) both undef
my($n, $low, $high) = @_;
$low = 0 unless defined($low); # default for $low is 0
$high = 1 unless defined($high); # default for $high is 1
croak("$low = \$low > \$high = $high\nin ".
"random_uniform([\$n,[\$low,\$high]])") if ($low > $high);
return genunf($low,$high) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = genunf($low,$high); }
return @ans;
}
sub random_poisson { # Arguments: ($n, $mu)
croak "Usage: random_poisson(\$n,\$mu)" if scalar(@_) < 2;
my($n, $mu) = @_;
croak "$mu = \$mu < 0\nin random_poisson(\$n,\$mu)" if ($mu < 0);
return ignpoi($mu) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = ignpoi($mu); }
return @ans;
}
sub random_uniform_integer { # Arguments: ($n,$low,$high)
croak "Usage: random_uniform_integer(\$n,\$low,\$high)" if scalar(@_) < 3;
my($n, $low, $high) = @_;
$low = int($low);
$high = int($high);
croak("$low = \$low > \$high = $high\nin ".
"random_uniform_integer(\$n,\$low,\$high)") if ($low > $high);
my $range = $high - $low;
croak("$range = (\$high - \$low) > 2147483561\nin ".
"random_uniform_integer(\$n,\$low,\$high)") if ($range > 2147483561);
return ($low + ignuin(0,$range)) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = $low + ignuin(0,$range); }
return @ans;
}
sub random_negative_binomial { # Arguments: ($n,$ne,$p)
croak "Usage: random_negative_binomial(\$n,\$ne,\$p)" if scalar(@_) < 3;
my($n, $ne, $p) = @_;
$ne = int($ne);
croak("($ne = \$ne <= 0) or ($p = \$p <= 0 or >= 1)\nin ".
"random_negative_binomial(\$n,\$ne,\$p)")
if (($ne <= 0) or (($p <= 0) or ($p >= 1)));
return ignnbn($ne,$p) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = ignnbn($ne,$p); }
return @ans;
}
sub random_binomial { # Arguments: ($n,$nt,$p)
croak "Usage: random_binomial(\$n,\$nt,\$p)" if scalar(@_) < 3;
my($n, $nt, $p) = @_;
$nt = int($nt);
croak("($nt = \$nt < 0) or ($p = \$p < 0 or > 1)\nin ".
"random_binomial(\$n,\$nt,\$p)")
if (($nt < 0) or (($p < 0) or ($p > 1)));
return ignbin($nt,$p) unless wantarray();
my $val;
my @ans = (0) x $n;
foreach $val (@ans) { $val = ignbin($nt,$p); }
return @ans;
}
#####################################################################
# SEED HANDLER FUNCTIONS #
#####################################################################
sub random_seed_from_phrase { # Argument $phrase
my $phrase = shift(@_);
$phrase ||= "";
return phrtsd($phrase);
}
sub random_get_seed { # no argument
return getsd();
}
sub random_set_seed_from_phrase { # Argument $phrase
my $phrase = shift(@_);
$phrase ||= "";
salfph($phrase);
return 1;
}
sub random_set_seed { # Argument @seed
my($seed1,$seed2) = @_;
croak("Usage: random_set_seed(\@seed)\n\@seed[0,1] must be two integers ".
"in the range (1,1) to (2147483562,2147483398)\nand usually comes ".
"from a call to random_get_seed() ".
"or\nrandom_seed_from_phrase(\$phrase).")
unless (((($seed1 == int($seed1)) and ($seed2 == int($seed2))) and
(($seed1 > 0) and ($seed2 > 0))) and
(($seed1 < 2147483563) and ($seed2 < 2147483399)));
setall($seed1,$seed2);
return 1;
}
#####################################################################
# HELPER ROUTINES #
# These use the C work arrays and are not intended for export #
# (Currently only used in random_multivariate_normal) #
#####################################################################
sub getflt {
my $n = $_[0];
my $val;
my $i = 0;
my @junk = (0) x $n;
foreach $val (@junk) {
$val = gvprfw($i);
$i++;
}
return @junk;
}
sub putflt {
my $n = scalar(@_);
rsprfw($n) or return 0;
my $val;
my $i = 0;
foreach $val (@_) { # load up floats
svprfw($i,$val);
$i++;
}
return 1;
}
# Autoload methods go after =cut, and are processed by the autosplit program.
1;
__END__
=head1 NAME
B<Math::Random> - Random Number Generators
=head1 SYNOPSIS
=over 4
=item *
use Math::Random;
Exports the following routines by default (see L<DEFAULT ROUTINES>):
random_set_seed_from_phrase
random_get_seed
random_seed_from_phrase
random_set_seed
random_uniform
random_uniform_integer
random_permutation
random_permuted_index
random_normal
In this case the extended routines (see L<"EXTENDED ROUTINES">) can be
used by qualifying them explicitly with C<Math::Random::>, for
example: C<$stdexp = Math::Random::random_exponential();>
=item *
use Math::Random qw(random_beta
random_chi_square
random_exponential
random_f
random_gamma
random_multivariate_normal
random_multinomial
random_noncentral_chi_square
random_noncentral_f
random_normal
random_permutation
random_permuted_index
random_uniform
random_poisson
random_uniform_integer
random_negative_binomial
random_binomial
random_seed_from_phrase
random_get_seed
random_set_seed_from_phrase
random_set_seed );
Exports all the routines explicitly. Use a subset of the list for the
routines you want.
=item *
use Math::Random qw(:all);
Exports all the routines, as well.
=back
=head1 DESCRIPTION
B<Math::Random> is a B<Perl> port of the B<C> version of B<randlib>,
which is a suite of routines for generating random deviates. See
L<"RANDLIB"> for more information.
This port supports all of the distributions from which the B<Fortran>
and B<C> versions generate deviates. The major functionalities that
are excluded are the multiple generators/splitting facility and
antithetic random number generation. These facilities, along with
some of the distributions which I<are> included, are probably not of
interest except to the very sophisticated user. If there is
sufficient interest, the excluded facilities will be included in a
future release. The code to perform the excluded facilities is
available as B<randlib> in B<Fortran> and B<C> source.
=head2 Default routines:
The routines which are exported by default are the only ones that the
average Perl programmer is likely to need.
=over 4
=item C<random_set_seed_from_phrase($phrase)>
Sets the seed of the base generator to a value determined by
I<$phrase>. The value used for a given I<$phrase> is consistent from
implementation to implementation (it does not rely on the machine
collating sequence). B<Note:> When the Perl processor loads
package B<Math::Random> the seed is set to a value based on the
current time. The seed changes each time B<Math::Random> generates
something random.
The ability to set the seed is useful for debugging, or for those who
like reproducible runs.
=item C<random_get_seed()>
Returns an array of length two which contains the two integers
constituting the seed (assuming a call in array context). An
invocation in a scalar context returns the integer 2, which is
probably not useful.
=item C<random_seed_from_phrase($phrase)>
Returns an array of length two which contains the two integers
consituting the seed (assuming a call in array context). An
invocation in a scalar context returns the integer 2, which is
probably not useful. The seed generated is the seed used to set the
seed in a call to C<random_set_seed_from_phrase>.
B<Note:> the following two calls (for the same I<$phrase>) are
equivalent:
random_set_seed(random_seed_from_phrase($phrase));
and
random_set_seed_from_phrase($phrase);
=item C<random_set_seed(@seed)>
Sets the seed of the base generator to the value I<@seed>[0,1].
Usually, the argument I<@seed> should be the result of a call to
C<random_get_seed> or C<random_seed_from_phrase>. I<@seed>[0,1] must
be two integers in the range S<(1, 1)> to S<(2147483562, 2147483398)>,
inclusive.
=item C<random_uniform($n, $low, $high)>
=item C<random_uniform($n)>
=item C<random_uniform()>
When called in an array context, returns an array of I<$n> deviates
generated from a I<uniform($low,>S< >I<$high)> distribution. When
called in a scalar context, generates and returns only one such
deviate as a scalar, regardless of the value of I<$n>.
Argument restrictions: I<$low> must be less than or equal to I<$high>.
Defaults are (1, 0, 1). B<Note:> I<$high> must be specified if
I<$low> is specified.
=item C<random_uniform_integer($n, $low, $high)>
When called in an array context, returns an array of I<$n> integer
deviates generated from a I<uniform($low,>S< >I<$high)> distribution
on the integers. When called in a scalar context, generates and
returns only one such deviate as a scalar, regardless of the value of
I<$n>.
Argument restrictions: I<$low> and I<$high> are first rounded using
C<int()>; the resulting I<$low> must be less than or equal to I<$high>,
and the resulting range I<($high - $low)> must not be greater than
2147483561.
There are no defaults; all three arguments must be provided.
=item C<random_permutation(@array)>
Returns I<@array>, randomly permuted.
=item C<random_permuted_index($n)>
Returns an array of array indices, randomly permuted. The indices
used are S<(0, ... ,>(I<$n>S< - >1)). This produces the indices used
by C<random_permutation> for a given seed, without passing arrays.
B<Note:> the following are equivalent:
random_set_seed_from_phrase('jjv');
random_permutation(@array);
and
random_set_seed_from_phrase('jjv');
@array[(random_permuted_index(scalar(@array)))];
=item C<random_normal($n, $av, $sd)>
=item C<random_normal($n, $av)>
=item C<random_normal($n)>
=item C<random_normal()>
When called in an array context, returns an array of I<$n> deviates
generated from a I<normal($av, $sd^2)> distribution. When called in a
scalar context, generates and returns only one such deviate as a
scalar, regardless of the value of I<$n>.
Argument restrictions: I<$sd> must be non-negative.
Defaults are (1, 0, 1).
=back
=head2 Extended Routines:
These routines generate deviates from many other distributions.
B<Note:> The parameterizations of these deviates are standard (insofar
as there I<is> a standard ... ) but particular attention should be
paid to the distributions of the I<beta> and I<gamma> deviates (noted
in C<random_beta> and C<random_gamma> below).
=over 4
=item C<random_beta($n, $aa, $bb)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<beta> distribution with parameters I<$aa> and
I<$bb>. The density of the beta is:
X^(I<$aa> - 1) * (1 - X)^(I<$bb> - 1) / S<B>(I<$aa> , I<$bb>) for 0 < X <
1.
When called in a scalar context, generates and returns only one such
deviate as a scalar, regardless of the value of I<$n>.
Argument restrictions: Both I<$aa> and I<$bb> must not be less than
C<1.0E-37>.
There are no defaults; all three arguments must be provided.
=item C<random_binomial($n, $nt, $p)>
When called in an array context, returns an array of I<$n> outcomes
generated from the I<binomial> distribution with number of trials
I<$nt> and probability of an event in each trial I<$p>. When called
in a scalar context, generates and returns only one such outcome as a
scalar, regardless of the value of I<$n>.
Argument restrictions: I<$nt> is rounded using C<int()>; the result
must be non-negative. I<$p> must be between 0 and 1 inclusive.
There are no defaults; both arguments must be provided.
=item C<random_chi_square($n, $df)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<chi-square> distribution with I<$df> degrees of
freedom. When called in a scalar context, generates and returns only
one such deviate as a scalar, regardless of the value of I<$n>.
Argument restrictions: I<$df> must be positive.
There are no defaults; both arguments must be provided.
=item C<random_exponential($n, $av)>
=item C<random_exponential($n)>
=item C<random_exponential()>
When called in an array context, returns an array of I<$n> deviates
generated from the I<exponential> distribution with mean I<$av>. When
called in a scalar context, generates and returns only one such
deviate as a scalar, regardless of the value of I<$n>.
Argument restrictions: I<$av> must be non-negative.
Defaults are (1, 1).
=item C<random_f($n, $dfn, $dfd)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<F> (variance ratio) distribution with degrees of
freedom I<$dfn> (numerator) and I<$dfd> (denominator). When called in
a scalar context, generates and returns only one such deviate as a
scalar, regardless of the value of I<$n>.
Argument restrictions: Both I<$dfn> and I<$dfd> must be positive.
There are no defaults; all three arguments must be provided.
=item C<random_gamma($n, $a, $r)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<gamma> distribution with parameters I<$a> and
I<$r>. The density of the gamma is:
(I<$a>**I<$r>) / Gamma(I<$r>) * X**(I<$r> - 1) * Exp(-I<$a>*X)
When called in a scalar context, generates and returns only one such
deviate as a scalar, regardless of the value of I<$n>.
Argument restrictions: Both I<$a> and I<$r> must be positive.
There are no defaults; all three arguments must be provided.
=item C<random_multinomial($n, @p)>
When called in an array context, returns single observation from the
I<multinomial> distribution, with I<$n> events classified into as many
categories as the length of I<@p>. The probability of an event being
classified into category I<i> is given by the I<i>th element of I<@p>.
The observation is an array with length equal to I<@p>, so when called
in a scalar context it returns the length of @p. The sum of the
elements of the observation is equal to I<$n>.
Argument restrictions: I<$n> is rounded with C<int()> before it is
used; the result must be non-negative. I<@p> must have length at
least 2. All elements of I<@p> except the last must be between 0 and
1 inclusive, and sum to no more than 0.99999. B<Note:> The last
element of I<@p> is a dummy to indicate the number of categories, and
it is adjusted to bring the sum of the elements of I<@p> to 1.
There are no defaults; both arguments must be provided.
=item C<random_multivariate_normal($n, @mean, @covar)>
When called in an array context, returns an array of I<$n> deviates
(each deviate being an array reference) generated from the
I<multivariate normal> distribution with mean vector I<@mean> and
variance-covariance matrix I<@covar>. When called in a scalar
context, generates and returns only one such deviate as an array
reference, regardless of the value of I<$n>.
Argument restrictions: If the dimension of the deviate to be generated
is I<p>, I<@mean> should be a length I<p> array of real numbers.
I<@covar> should be a length I<p> array of references to length I<p>
arrays of real numbers (i.e. a I<p> by I<p> matrix). Further,
I<@covar> should be a symmetric positive-definite matrix, although the
B<Perl> code does not check positive-definiteness, and the underlying
B<C> code assumes the matrix is symmetric. Given that the
variance-covariance matrix is symmetric, it doesn't matter if the
references refer to rows or columns. If a non-positive definite
matrix is passed to the function, it will abort with the following
message:
COVM not positive definite in SETGMN
Also, a non-symmetric I<@covar> may produce deviates without
complaint, although they may not be from the expected distribution.
For these reasons, you are encouraged to I<verify the arguments
passed>.
The B<Perl> code I<does> check the dimensionality of I<@mean> and
I<@covar> for consistency. It does so by checking that the length of
the argument vector passed is odd, that what should be the last
element of I<@mean> and the first element of I<@covar> look like they
are a number followed by an array reference respectively, and that the
arrays referred to in I<@covar> are as long as I<@mean>.
There are no defaults; all three arguments must be provided.
=item C<random_negative_binomial($n, $ne, $p)>
When called in an array context, returns an array of I<$n> outcomes
generated from the I<negative binomial> distribution with number of
events I<$ne> and probability of an event in each trial I<$p>. When
called in a scalar context, generates and returns only one such
outcome as a scalar, regardless of the value of I<$n>.
Argument restrictions: I<$ne> is rounded using C<int()>, the result
must be positive. I<$p> must be between 0 and 1 exclusive.
There are no defaults; both arguments must be provided.
=item C<random_noncentral_chi_square($n, $df, $nonc)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<noncentral chi-square> distribution with I<$df>
degrees of freedom and noncentrality parameter I<$nonc>. When called
in a scalar context, generates and returns only one such deviate as a
scalar, regardless of the value of I<$n>.
Argument restrictions: I<$df> must be at least 1, I<$nonc> must be
non-negative.
There are no defaults; all three arguments must be provided.
=item C<random_noncentral_f($n, $dfn, $dfd, $nonc)>
When called in an array context, returns an array of I<$n> deviates
generated from the I<noncentral F> (variance ratio) distribution with
degrees of freedom I<$dfn> (numerator) and I<$dfd> (denominator); and
noncentrality parameter I<$nonc>. When called in a scalar context,
generates and returns only one such deviate as a scalar, regardless of
the value of I<$n>.
Argument restrictions: I<$dfn> must be at least 1, I<$dfd> must be
positive, and I<$nonc> must be non-negative.
There are no defaults; all four arguments must be provided.
=item C<random_poisson($n, $mu)>
When called in an array context, returns an array of I<$n> outcomes
generated from the I<Poisson> distribution with mean I<$mu>. When
called in a scalar context, generates and returns only one such
outcome as a scalar, regardless of the value of I<$n>.
Argument restrictions: I<$mu> must be non-negative.
There are no defaults; both arguments must be provided.
=back
=head1 ERROR HANDLING
The B<Perl> code should C<croak> if bad arguments are passed or if the
underlying B<C> code cannot allocate the necessary memory. The only
error which should kill the job without C<croak>ing is a non-positive
definite variance-covariance matrix passed to
C<random_multivarite_normal> (see L<"EXTENDED ROUTINES">).
=head1 RANDLIB
B<randlib> is available in B<Fortran> and B<C> source form, and will
soon be available in B<Fortran90> source as well. B<randlib.c> can be
obtained from B<statlib>. Send mail whose message is I<'send
randlib.c.shar from general'> to:
statlib@lib.stat.cmu.edu
B<randlib.c> can also be obtained by anonymous B<ftp> to:
odin.mdacc.tmc.edu (143.111.62.32)
where it is available as
/pub/source/randlib.c-1.3.tar.gz
For obvious reasons, the original B<randlib> (in B<Fortran>) has been
renamed to
/pub/source/randlib.f-1.3.tar.gz
on the same machine.
Our FTP index is on file C<./pub/index>.
If you have Internet access and a browser you might note the following
web site addresses:
University of Texas M. D. Anderson Cancer Center Home Page:
http://utmdacc.mdacc.tmc.edu/
Department of Biomathematics Home Page:
http://odin.mdacc.tmc.edu/
Available Software:
http://odin.mdacc.tmc.edu/anonftp/
=head1 SUPPORT
This work was supported in part by grant CA-16672 from the National
Cancer Institute. We are grateful to Larry and Pat McNeil of Corpus
Cristi for their generous support. Some equipment used in this effort
was provided by IBM as part of a cooperative study agreement; we thank
them.
=head1 CODE MANIPULATION
The B<C> version of B<randlib> was obtained by translating the
original B<Fortran> B<randlib> using B<PROMULA.FORTRAN>, and
performing some hand crafting of the result.
Information on B<PROMULA.FORTRAN> can be obtained from:
PROMULA Development Corporation
3620 N. High Street, Suite 301
Columbus, Ohio 43214
(614) 263-5454
F<wrapper.c> was created by using B<SWIG>, and performing some
modification of the result. B<SWIG> also produced the skeleton of
F<Random.pm>.
Information on B<SWIG> can be obtained from:
http://www.cs.utah.edu/~beazley/SWIG
and
ftp://ftp.cs.utah.edu/pub/beazley/SWIG
=head1 SOURCES
The following routines, which were written by others and lightly
modified for consistency in packaging, are included in B<randlib>.
=over 4
=item Bottom Level Routines
These routines are a transliteration of the B<Pascal> in the reference
to B<Fortran>, and thence to B<C>.
L'Ecuyer, P., and Cote, S. "Implementing a Random Number Package with
Splitting Facilities." ACM Transactions on Mathematical Software,
17:98-111 (1991).
=item Exponential
This code was obtained from Netlib.
Ahrens, J. H., and Dieter, U. "Computer Methods for Sampling from the
Exponential and Normal Distributions." Comm. ACM, 15,10 (Oct. 1972),
873-882.
=item Gamma
(Case R >= 1.0)
Ahrens, J. H., and Dieter, U. "Generating Gamma Variates by a Modified
Rejection Technique." Comm. ACM, 25,1 (Jan. 1982), 47-54.
Algorithm GD
(Case 0.0 <= R <= 1.0)
Ahrens, J. H., and Dieter, U. "Computer Methods for Sampling from
Gamma, Beta, Poisson and Binomial Distributions." Computing, 12 (1974),
223-246. Adaptation of algorithm GS.
=item Normal
This code was obtained from netlib.
Ahrens, J. H., and Dieter, U. "Extensions of Forsythe's Method for
Random Sampling from the Normal Distribution." Math. Comput., 27,124
(Oct. 1973), 927-937.
=item Binomial
This code was kindly sent to Dr. Brown by Dr. Kachitvichyanukul.
Kachitvichyanukul, V., and Schmeiser, B. W. "Binomial Random Variate
Generation." Comm. ACM, 31, 2 (Feb. 1988), 216.
=item Poisson
This code was obtained from netlib.
Ahrens, J. H., and Dieter, U. "Computer Generation of Poisson Deviates
from Modified Normal Distributions." ACM Trans. Math. Software, 8, 2
(June 1982), 163-179.
=item Beta
This code was written by us following the recipe in the following.
Cheng, R. C. H. "Generating Beta Variables with Nonintegral Shape
Parameters." Comm. ACM, 21:317-322 (1978). (Algorithms BB and BC)
=item Linpack
Routines C<SPOFA> and C<SDOT> are used to perform the Cholesky
decomposition of the covariance matrix in C<SETGMN> (used for the
generation of multivariate normal deviates).
Dongarra, J. J., Moler, C. B., Bunch, J. R., and Stewart, G. W.
Linpack User's Guide. SIAM Press, Philadelphia. (1979)
=item Multinomial
The algorithm is from page 559 of Devroye, Luc Non-Uniform Random
Variate Generation. New York: Springer-Verlag, 1986.
=item Negative Binomial
The algorithm is from page 480 of Devroye, Luc Non-Uniform Random
Variate Generation. New York: Springer-Verlag, 1986.
=back
=head1 VERSION
This POD documents B<Math::Random> version 0.69.
=head1 AUTHORS
=over 4
=item *
B<Math::Random> (the B<Perl> port of B<Randlib>) was put together by
John Venier and Barry W. Brown with help from B<SWIG>. For version
0.61, Geoffrey Rommel made various cosmetic changes. Version 0.64 uses
plain vanilla XS rather than SWIG.
=item *
B<randlib> was compiled and written by Barry W. Brown, James Lovato,
Kathy Russell, and John Venier.
=item *
Correspondence regarding B<Math::Random> or B<randlib> should be
addressed to John Venier by email to
venier@odin.mdacc.tmc.edu
=item *
Our address is:
Department of Biomathematics, Box 237
The University of Texas, M.D. Anderson Cancer Center
1515 Holcombe Boulevard
Houston, TX 77030
=item *
Geoffrey Rommel may be reached at grommel [at] cpan [dot] org.
=back
=head1 LEGALITIES
=over 4
=item *
The programs in the B<Perl> code distributed with B<Math::Random> and
in the B<C> code F<helper.c>, as well as the documentation, are
copyright by John Venier and Barry W. Brown for the University of
Texas M. D. Anderson Cancer Center in 1997. They may be distributed
and used under the same conditions as B<Perl>.
=item *
F<randlib.c>, F<com.c>, and F<randlib.h> are from B<randlib> (See
L<"RANDLIB">) and are distributed with the following legalities:
Code that appeared in an ACM publication is subject to their
algorithms policy:
Submittal of an algorithm for publication in one of the ACM
Transactions implies that unrestricted use of the algorithm within a
computer is permissible. General permission to copy and distribute
the algorithm without fee is granted provided that the copies are not
made or distributed for direct commercial advantage. The ACM
copyright notice and the title of the publication and its date appear,
and notice is given that copying is by permission of the Association
for Computing Machinery. To copy otherwise, or to republish, requires
a fee and/or specific permission.
Krogh, F. "Algorithms Policy." ACM Tran. Math. Softw. 13 (1987),
183-186.
Note, however, that only the particular expression of an algorithm can
be copyrighted, not the algorithm per se; see 17 USC 102.
We place the Randlib code that we have written in the public domain.
=item *
B<Math::Randlib> and B<randlib> are distributed with B<NO WARRANTY>.
See L<"NO WARRANTY">.
=back
=head1 NO WARRANTY
WE PROVIDE ABSOLUTELY NO WARRANTY OF ANY KIND EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD
THIS PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.
IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR ANY OF ITS COMPONENT
INSTITUTIONS INCLUDING M. D. ANDERSON HOSPITAL BE LIABLE TO YOU FOR
DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA OR
ITS ANALYSIS BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD
PARTIES FROM) THE PROGRAM.
(Above NO WARRANTY modified from the GNU NO WARRANTY statement.)
=cut
| 32.765542 | 79 | 0.650675 |
73f1f777996bdc48db5eee79beff756c5399a37d | 17,041 | pl | Perl | ecmd-core/bin/ecmdsetup.pl | thejta/eCMD | 702b73948e64a38a5a48e83106d1c79860180cbb | [
"Apache-2.0"
] | null | null | null | ecmd-core/bin/ecmdsetup.pl | thejta/eCMD | 702b73948e64a38a5a48e83106d1c79860180cbb | [
"Apache-2.0"
] | null | null | null | ecmd-core/bin/ecmdsetup.pl | thejta/eCMD | 702b73948e64a38a5a48e83106d1c79860180cbb | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/perl
# File ecmdsetup.pl created by Jason Albert,6A5244 at 13:50:19 on Fri May 13 2005.
# Why wouldn't you use strict???
use strict;
use Cwd 'chdir';
##########################################################################
# Figure out where the user is calling this script from
#
# return value
my $rc = 0;
my $callingPwd;
my $pwd;
BEGIN {
# Some plugins needs the directory the script was called from, save that here
#Commenting this out since this seems to be resolving the links in the path
#chomp($callingPwd = `pwd`);
#This keeps the directory intact.
chomp($callingPwd = `cd .;pwd`);
# Now do the rest
my @tempArr = split(/\/+/,$0);
pop(@tempArr); # The script name
$" = "/"; # Make it so the array below seperates on / instead of space
#If it starts with a ., it's being called with relative path
if (substr($0,0,1) ne "/") {
$pwd = $callingPwd; # Get where I got called from
$pwd = $pwd . "/" . "@tempArr"; # Now use the relative to find out where the script is
} else { # Absolute path
$pwd = "@tempArr";
}
$" = " "; # Reset
chomp($pwd = `cd $pwd;pwd`); # Get to where this script resides
}
# installpath points to root of install
my $installPath = $pwd;
$installPath =~ s/\/([^\/..]*\/?)$/\//;
# Remove the trailing slash if there
$installPath =~ s/\/$//;
#########################################
# Setup the modules to include
# Base support, always there
use lib "$pwd";
use ecmdsetup;
my $ecmd = new ecmdsetup();
# Any installed plugins are located a dir below where this script resides
# use lib that path so we can load those modules
# The load all those instances into a plugin hash that is used thru out
# This allows the code to be adaptable to any number of plugins
use lib "$pwd/plugins";
my %plugins;
my $pluginKey;
# Get a list of all plugins installed
my @tempArr = split(/\s+/, `ls $pwd/plugins`);
# Loop over that list and load everything in
for (my $x=0; $x <= $#tempArr; $x++) {
# Create the key into the hash and the name of the module to load
$pluginKey = $tempArr[$x];
my $pluginSetup = $tempArr[$x];
$pluginKey =~ s/setup.pm//g;
$pluginSetup =~ s/.pm//g;
# Load the module and create the object
eval "require $pluginSetup";
$plugins{$pluginKey} = new $pluginSetup();
}
##########################################################################
# Variables
#
my %modified; # 0 is no change, 1 set needed, -1 unset needed
my $shell;
my $release;
my $prevRelease;
my $plugin;
my $product;
my $bits = 64;
my $arch;
my $temp;
my $shortcut = 0;
my $singleInstall = 1; # Assume it's a single install and then disprove it by looking at the path
my $copyLocal = 0; # Does the user want ECMD_EXE and ECMD_DLL_FILE copied to /tmp and run from there?
my $cleanup = 0; # Call only cleanup on the plugins to remove anything they might have put out there.
my $noret = 0; # Don't insert a return statement into output string
#####################################################
# Call the main function, then add the rc from that to the output
#
$rc = main();
# Yet again, csh sucks and doesn't have a return value. They will have to go without
if ($shell eq "ksh" && !$noret) {
printf("return $rc;");
}
exit($rc);
sub main {
#####################################################
# Look to see if help was requested
#
if ("@ARGV" =~ /-h/) {
help();
foreach $pluginKey ( keys %plugins ) {
$plugins{$pluginKey}->help();
}
return 1;
}
##########################################################################
# Figure out if the user is on a multi-instance install
#
# $installPath will point to the root of this install
# In a single install this would be /<something>/ecmd
# In a multi install this would be /<something>/ecmd/<ver>
my @installPathArray = split(/\//, $installPath);
if ($installPathArray[$#installPathArray - 1] eq "ecmd") {
$singleInstall = 0;
}
##########################################################################
# Get the users shell
#
$shell = shift(@ARGV);
# If you add a shell here, you need to update the output printing below
if ($shell eq "ksh") {
} elsif ($shell eq "csh") {
} else {
ecmd_print("Your shell is unsupported!", 1);
return 1;
}
##########################################################################
# Get the release
#
# Save the previous release the user may have had
$prevRelease = $ENV{"ECMD_RELEASE"};
$release = shift(@ARGV);
# Here is where we put in the magic to allow the user to just put a period to cover all four ecmd parms
if ($release eq ".") {
if ($ENV{"ECMD_RELEASE"} eq "" || $ENV{"ECMD_PLUGIN"} eq "" || $ENV{"ECMD_PRODUCT"} eq "" || $ENV{"ECMD_ARCH"} eq "") {
ecmd_print("You can't specify the '.' shortcut without having specified the release, product and plugin previously!", 1);
return 1;
} else {
$shortcut = 1;
}
}
if ($shortcut) {
$release = $ENV{"ECMD_RELEASE"};
}
##########################################################################
# Get the plugin
#
if ($shortcut) {
$plugin = $ENV{"ECMD_PLUGIN"};
} else {
$plugin = shift(@ARGV);
}
# See if the plugin passed in matches any of the ones we have modules for
my $pluginFound = 0;
foreach $pluginKey ( keys %plugins ) {
if ($pluginKey eq $plugin) {
$pluginFound = 1;
}
}
if ($pluginFound == 0) {
ecmd_print("The eCMD plugin '$plugin' you specified is not known!", 1);
return 1;
}
##########################################################################
# Get the product
#
if ($shortcut) {
$product = $ENV{"ECMD_PRODUCT"};
} else {
$product = shift(@ARGV);
}
##########################################################################
# Loop through the args left and see if any are for ecmd
#
for (my $x = 0; $x <= $#ARGV;) {
if ($ARGV[$x] eq "copylocal") {
$copyLocal = 1;
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} elsif ($ARGV[$x] eq "cleanup") {
$cleanup = 1;
ecmd_print("Removing eCMD and Plugin settings from environment", 1);
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} elsif ($ARGV[$x] eq "64") {
$bits = 64;
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} elsif ($ARGV[$x] eq "32") {
$bits = 32;
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} elsif ($ARGV[$x] eq "quiet") {
$ecmdsetup::quiet = 1;
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} elsif ($ARGV[$x] eq "noret") {
$noret = 1;
splice(@ARGV,$x,1); # Remove so plugin doesn't see it
} else {
# We have to walk the array here because the splice shortens up the array
$x++;
}
}
##########################################################################
# Determine the desired architecture for $ECMD_ARCH
#
if ($shortcut) {
$arch = $ENV{"ECMD_ARCH"};
} else {
# AIX
if (`uname` eq "AIX\n") {
if ($bits eq "32") {
$arch = "aix";
}
elsif ($bits eq "64") {
$arch = "aix64";
}
else {
ecmd_print("'$bits' is not a valid bit value!", 1);
return 1;
}
# PPC64LE
} elsif (`uname -a|grep ppc64le` ne "") {
if ($bits eq "64") {
$arch = "ppc64le";
}
else {
ecmd_print("'$bits' is not a valid bit value!", 1);
return 1;
}
# PPC
} elsif (`uname -a|grep ppc` ne "") {
if ($bits eq "32") {
$arch = "ppc";
}
elsif ($bits eq "64") {
$arch = "ppc64";
}
else {
ecmd_print("'$bits' is not a valid bit value!", 1);
return 1;
}
# X86
} else {
if ($bits eq "32") {
$arch = "x86";
}
elsif ($bits eq "64") {
$arch = "x86_64";
}
else {
ecmd_print("'$bits' is not a valid bit value!", 1);
return 1;
}
}
}
##########################################################################
# Cleanup any ecmd bin dirs that might be in the path
#
# Pull out any of the matching cases
if ($singleInstall) {
$ENV{"PATH"} =~ s!$installPath/$arch/bin!:!g;
$ENV{"PATH"} =~ s!$installPath/bin!:!g;
} else {
# This expression matches anything after a : up to /<something>/ecmd/<ver>/bin and then a : or end of line
$ENV{"PATH"} =~ s!([^:]*?)/ecmd/([^\/]*?)/$arch/bin(:|$)!:!g;
$ENV{"PATH"} =~ s!([^:]*?)/ecmd/([^\/]*?)/bin(:|$)!:!g;
}
# Any multiple : cases, reduce to one
$ENV{"PATH"} =~ s/(:+)/:/g;
# We might have left a : on the front, remove it
$ENV{"PATH"} =~ s/^://g;
# Same with the back, might have left a :
$ENV{"PATH"} =~ s/:$//g;
# Now mark the path modifed
$modified{"PATH"} = 1;
##########################################################################
# Cleanup any old dirs that might be in the python path
#
# Pull out any of the matching cases
if ($singleInstall) {
$ENV{"PYTHONPATH"} =~ s!$installPath/$arch/python!:!g;
} else {
# This expression matches anything after a : up to /<something>/ecmd/<ver>/bin and then a : or end of line
$ENV{"PYTHONPATH"} =~ s!([^:]*?)/ecmd/([^\/]*?)/$arch/python(:|$)!:!g;
}
# Any multiple : cases, reduce to one
$ENV{"PYTHONPATH"} =~ s/(:+)/:/g;
# We might have left a : on the front, remove it
$ENV{"PYTHONPATH"} =~ s/^://g;
# Same with the back, might have left a :
$ENV{"PYTHONPATH"} =~ s/:$//g;
# Now mark the path modifed
$modified{"PYTHONPATH"} = 1;
##########################################################################
# Call cleanup on plugins
#
# Only do this if the plugin has changed from last time
if ($ENV{"ECMD_PLUGIN"} ne $plugin || $cleanup) {
foreach $pluginKey ( keys %plugins ) {
$rc = $plugins{$pluginKey}->cleanup(\%modified);
if ($rc) {
return $rc;
}
}
}
##########################################################################
# Flag the ECMD_* variables as modified if appropriate
#
if (!$shortcut) {
$ENV{"ECMD_RELEASE"} = $release;
$modified{"ECMD_RELEASE"} = 1;
$ENV{"ECMD_PLUGIN"} = $plugin;
$modified{"ECMD_PLUGIN"} = 1;
$ENV{"ECMD_PRODUCT"} = $product;
$modified{"ECMD_PRODUCT"} = 1;
$ENV{"ECMD_ARCH"} = $arch;
$modified{"ECMD_ARCH"} = 1;
}
if ($cleanup) {
$modified{"ECMD_RELEASE"} = -1;
$modified{"ECMD_PLUGIN"} = -1;
$modified{"ECMD_PRODUCT"} = -1;
$modified{"ECMD_ARCH"} = -1;
$modified{"ECMD_PATH"} = -1;
}
##########################################################################
# Call setup on plugin specified
#
if (!$cleanup) {
foreach $pluginKey ( keys %plugins ) {
if ($plugin eq $pluginKey) { # Only call setup on our selected plugin
$rc = $plugins{$pluginKey}->setup(\%modified,
{ ARGV => "@ARGV",
singleInstall => $singleInstall,
arch => $arch,
product => $product,
ecmdsetup => 1,
callingPwd => $callingPwd,
installPath => $installPath,
});
if ($rc) {
return $rc;
}
}
}
}
##########################################################################
# Figure out the ecmd release if the user passed in auto
# Calling ecmdVersion will work now that everything is setup
#
if ($ENV{"ECMD_RELEASE"} eq "auto") {
# Use the full path to get to ecmdVersion to dynamically establish the version
# We have to call the full path because PATH won't always be established
my $command = "$installPath/bin/ecmdVersion_$arch full";
$ENV{"ECMD_RELEASE"} = `/bin/sh -c \"$command\"`;
$modified{"ECMD_RELEASE"} = 1;
$release = $ENV{"ECMD_RELEASE"};
}
##########################################################################
# If release was set by plugin setup, change local variable
#
if ($modified{"ECMD_RELEASE"} == 1) {
$release = $ENV{"ECMD_RELEASE"};
}
# We'll see if the release is supported based upon the directory existing
my @releasePathArray = @installPathArray;
if (!$singleInstall) {
# Replace the release path for the script with the one passed in
$releasePathArray[$#releasePathArray] = $release;
$temp = sprintf join("/", @releasePathArray);
if (!(-d $temp)) {
ecmd_print("The eCMD release '$release' you specified is not known!", 1);
return 1;
}
}
# Setup release path for use throughout the rest of the script
my $releasePath = sprintf join("/", @releasePathArray);
##########################################################################
# Set ECMD_PATH based upon the releasePath figured out above
#
$ENV{"ECMD_PATH"} = $releasePath . "/";
$modified{"ECMD_PATH"} = 1;
##########################################################################
# Add bin directory to path
#
if (!$cleanup) {
$ENV{"PATH"} = $releasePath . "/bin:" . $ENV{"PATH"};
$ENV{"PATH"} = $releasePath . "/" . $arch . "/bin:" . $ENV{"PATH"};
$modified{"PATH"} = 1;
}
##########################################################################
# Change shared lib path to point to release
# This is because the release may have changed from the installPath that was used
#
if ((!$cleanup) && (!$singleInstall)) {
my $sharedLib;
if ($arch =~ m/aix/) {
$sharedLib = "LIBPATH";
} else {
$sharedLib = "LD_LIBRARY_PATH";
}
# This expression matches anything after a : up to /<something>/ecmd/<ver>/<arch>/lib and then a : or end of line
$ENV{"$sharedLib"} =~ s!([^:]*?)/ecmd/([^\/]*?)/([^\/]*?)/lib(:|$)!:!g;
# Any multiple : cases, reduce to one
$ENV{"$sharedLib"} =~ s/(:+)/:/g;
# We might have left a : on the front, remove it
$ENV{"$sharedLib"} =~ s/^://g;
# Same with the back, might have left a :
$ENV{"$sharedLib"} =~ s/:$//g;
# Now add the releasePath that we've determined to the sharedLib path
$ENV{"$sharedLib"} = $ENV{"$sharedLib"} . ":" . $releasePath . "/" . $arch . "/lib";
$modified{"$sharedLib"} = 1;
}
##########################################################################
# Add python directory to PYTHONPATH
#
if (!$cleanup) {
$ENV{"PYTHONPATH"} = $releasePath . "/" . $arch . "/python:" . $ENV{"PYTHONPATH"};
# Any multiple : cases, reduce to one
$ENV{"PYTHONPATH"} =~ s/(:+)/:/g;
# We might have left a : on the front, remove it
$ENV{"PYTHONPATH"} =~ s/^://g;
# Same with the back, might have left a :
$ENV{"PYTHONPATH"} =~ s/:$//g;
$modified{"PYTHONPATH"} = 1;
}
##########################################################################
# Updates setup scripts if release changed
# All we need to do is resource the setup scripts
#
if (($prevRelease ne $ENV{"ECMD_RELEASE"}) && !$singleInstall) {
my $file;
if ($shell eq "csh") {
$file = sprintf("%s/bin/ecmdaliases.csh", $releasePath);
printf("source $file;");
} else {
$file = sprintf("%s/bin/ecmdaliases.ksh", $releasePath);
printf(". $file;");
}
}
####################################################
# Do the copy to /tmp if local was given
#
if ($copyLocal) {
foreach $pluginKey ( keys %plugins ) {
if ($plugin eq $pluginKey) { # Only call setup on our selected plugin
$rc = $plugins{$pluginKey}->copyLocal(\%modified,
{ cleanup => $cleanup,
});
if ($rc) {
return $rc;
}
}
}
}
##########################################################################
# Write out the modified environment
#
$ecmd->write_environment($shell,\%modified);
}
# Umm.. yeah.. I'm going to need you to work this weekend on the help text. Mkay..
sub help {
ecmd_print("ecmdsetup <release> <plugin> <product> [32|64] [copylocal] [cleanup] <plugin options>");
ecmd_print("<release> - Any eCMD Version currently supported in CVS (ex rel, ver5, ver4-3)");
ecmd_print("<plugin> - varies based upon your ecmd install");
ecmd_print("<product> - varies based upon plugin");
ecmd_print("[32|64] - Use the 32 or 64-bit versions of eCMD and plugins. Defaults to 32.");
ecmd_print("[copylocal] - Copy the \$ECMD_EXE and \$ECMD_DLL_FILE to /tmp/\$ECMD_TARGET/");
ecmd_print("[cleanup] - Remove all eCMD and Plugin settings from environment");
ecmd_print("[quiet] - Disables status output");
ecmd_print("[noret] - Removes return code from variable set string");
ecmd_print("<plugin options> - anything else passed into the script is passed onto the plugin");
ecmd_print("-h - this help text");
}
| 33.08932 | 127 | 0.514582 |
73ee559bafc491308f947aef3263e706c8be1c7a | 9,371 | pl | Perl | bin/build_chromosome_synonyms.pl | Ensembl/format-transcriber | 3b53430efe1458a477b35f33b99cdbd89d9f13b3 | [
"Apache-2.0"
] | 2 | 2017-01-27T08:43:46.000Z | 2019-04-23T06:05:30.000Z | bin/build_chromosome_synonyms.pl | Ensembl/format-transcriber | 3b53430efe1458a477b35f33b99cdbd89d9f13b3 | [
"Apache-2.0"
] | 5 | 2018-02-19T13:59:27.000Z | 2021-01-21T10:06:30.000Z | bin/build_chromosome_synonyms.pl | Ensembl/format-transcriber | 3b53430efe1458a477b35f33b99cdbd89d9f13b3 | [
"Apache-2.0"
] | 1 | 2017-12-04T15:22:51.000Z | 2017-12-04T15:22:51.000Z | #!/bin/env perl
# Copyright [1999-2016] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
=head1 NAME
build_chromosome_synonyms.pl - build a structure of chromsome synonyms for UCSC's itendifiers
=head1 SYNOPSIS
build_chromosome_synonyms.pl -options
=head1 DESCRIPTION
This script will build a json structure of all the chromosome name mappings from
Ensembl names to UCSC names. The json structure will be printed on stdout, while
statistics on the run will be printed to stderr.
=head1 OPTIONS
--dbhost host name for database (gets put as host= in locator)
--dbport For RDBs, what port to connect to (port= in locator)
--dbuser For RDBs, what username to connect as (dbuser= in locator)
--dbpass For RDBs, what password to use (dbpass= in locator)
--release Ensembl release to search against, default is whichever your Ensembl libray uses
--help Usage information
=cut
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Data::Dumper;
use JSON;
use DBI;
use Bio::EnsEMBL::Registry;
my %ucsc_name_cache;
my %insdc_to_ucsc;
my %insdc_to_ensembl;
my %insdc;
my %ucsc;
my %has_gca;
my %has_chromosome;
my $ensembl2ucsc;
sub get_options {
my $db_host = 'mysql-ensembl-mirror.ebi.ac.uk';
# my $db_host = 'useastdb.ensembl.org';
my $db_user = 'anonymous';
my $db_pass;
my $db_port = 4240;
my $release;
my $help;
my @species;
my $group = 'core';
my $include_scaffold;
GetOptions(
"db_host|dbhost|host=s" => \$db_host,
"db_user|dbuser|user|username=s" => \$db_user,
"db_pass|dbpass|pass|password=s" => \$db_pass,
"db_port|dbport|port=s" => \$db_port,
"version|release=i" => \$release,
"species=s@" => \@species,
"help" => \$help,
"include_scaffold" => \$include_scaffold,
);
if ($help) {
exec('perldoc', $0);
}
my %args = (
-HOST => $db_host,
-USER => $db_user,
-PORT => $db_port
);
$args{-PASS} = $db_pass if $db_pass;
$args{-DB_VERSION} = $release if $release;
my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(%args);
# Get all the species available for core
my @dbas;
if(@species) {
print STDERR "Working against a restricted species list";
foreach my $s (@species) {
my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor($s, $group);
die "Cannot find a DBAdaptor for the species ${s}" unless $dba;
push(@dbas, $dba);
}
}
else {
print STDERR "Dumping chain file for all available species";
@dbas = @{Bio::EnsEMBL::Registry->get_all_DBAdaptors(-GROUP => 'core')};
}
return @dbas, $include_scaffold;
}
run();
sub run {
my @dbas = get_options();
my $include_scaffold = pop @dbas;
foreach my $dbadaptor (@dbas) {
fetch_meta($dbadaptor);
fetch_INSDC($dbadaptor, $include_scaffold);
fetch_UCSC($dbadaptor);
}
# Report what we've found and get a list of
# species that have both an Ensembl INSDC
# and a UCSC mapping
my @species = merge_and_report();
# Go through the species we know have both an Ensembl INSDC
# and a UCSC mapping
foreach my $species (@species) {
foreach my $insdc (keys %{$insdc_to_ensembl{$species}}) {
if($insdc_to_ucsc{$species}{$insdc}) {
$ucsc_name_cache{$species}{ $insdc_to_ensembl{$species}{$insdc} } = $insdc_to_ucsc{$species}{$insdc};
}
}
}
# Make the json for the structure and spit it out
my $json_str = to_json(\%ucsc_name_cache, { pretty => 1 });
print $json_str;
}
# Merge the sets of identifiers and return all the species
# that have both an Ensembl INSDC and a UCSC mapping,
# also report back on some general stats.
sub merge_and_report {
my @found_ucsc; my @missing_ucsc; my @nomap_ucsc;
foreach my $species (sort keys %ucsc) {
if($ucsc{$species} == 1) {
push @found_ucsc, $species;
} elsif($ucsc{$species} == -1) {
push @missing_ucsc, $species;
} elsif($ucsc{$species} == -2) {
push @nomap_ucsc, $species;
}
}
print STDERR "UCSC Mappings:\n";
print STDERR "Found mappings:\t" . join(', ', @found_ucsc) . "\n\n";
print STDERR "Missing from UCSC:\t" . join(', ', @missing_ucsc) . "\n\n";
print STDERR "No UCSC mapping:\t" . join(', ', @nomap_ucsc) . "\n\n";
my @found_insdc; my @missing_insdc;
foreach my $species (sort keys %insdc) {
if($insdc{$species} == 1) {
push @found_insdc, $species;
} else {
push @missing_insdc, $species;
}
}
print STDERR "INSDC Mappings:\n";
print STDERR "Found mappings:\t" . join(', ', @found_insdc) . "\n\n";
print STDERR "Missing INSDC\t" . join(', ', @missing_insdc) . "\n\n";
my @found_gca; my @missing_gca;
foreach my $species (sort keys %has_gca) {
if($has_gca{$species} == 1) {
push @found_gca, $species;
} else {
push @missing_gca, $species;
}
}
print STDERR "GCA Accessions:\n";
print STDERR "Found Accession:\t" . join(', ', @found_gca) . "\n";
print STDERR "Missing Accession:\t" . join(', ', @missing_gca) . "\n";
my %missing_insdc_map = map{$_ => 1} @missing_insdc;
my @has_gca_no_insdc = grep( $missing_insdc_map{$_}, @found_gca );
print STDERR "\nHave GCA accession, missing INSDC: " . join(', ', @has_gca_no_insdc) . "\n\n" ;
my @has_chromosome_and_no_insdc = grep( $has_chromosome{$_}, @has_gca_no_insdc );
print STDERR "Has GCA accessing, no INSDC, yet has a chromosome: " . join(', ', @has_chromosome_and_no_insdc) . "\n\n";
my %has_insdc_map = map{$_ => 1} @found_insdc;
my @has_insdc_and_ucsc = grep( $has_insdc_map{$_}, @found_ucsc );
print STDERR "Has Ensembl INSDC and UCSC: " . join(', ', @has_insdc_and_ucsc) . "\n\n";
return @has_insdc_and_ucsc;
}
sub fetch_meta {
my ($dbadaptor) = @_;
my $meta_adaptor = $dbadaptor->get_MetaContainerAdaptor();
my @accession_info =
@{ $meta_adaptor->list_value_by_key('assembly.accession') };
if(@accession_info) {
$has_gca{$dbadaptor->species()} = 1;
} else {
$has_gca{$dbadaptor->species()} = 0;
}
my @ucsc_mapping =
@{ $meta_adaptor->list_value_by_key('assembly.ucsc_alias') };
# Grab the UCSC db name if available
if(@ucsc_mapping) {
$ensembl2ucsc->{ $dbadaptor->species() } =
shift @ucsc_mapping;
}
}
# Go fetch all mappings for INSDC to our chromosome identifier
sub fetch_INSDC {
my ($dbadaptor, $include_scaffold) = @_;
print STDERR "Examining " . $dbadaptor->species() . "\n";
# Remember if we've found an insdc identifier in this database
my $found_insdc = 0;
# Fetch all the chromosome slices
my $slice_adaptor = $dbadaptor->get_SliceAdaptor();
my $slices;
if ($include_scaffold) {
$slices = $slice_adaptor->fetch_all('toplevel');
} else {
$slices = $slice_adaptor->fetch_all('chromosome');
}
my $species = $dbadaptor->species();
$has_chromosome{$species} = 0;
while(my $slice = shift @{$slices}) {
$has_chromosome{$species} = 1;
my $slice_name = $slice->seq_region_name;
# Store initial name as well
$insdc_to_ensembl{$species}{$slice_name} = $slice_name;
my $synonyms = $slice->get_all_synonyms('INSDC');
if(@{$synonyms}) {
# We have at least one INSDC synonym for this species
$found_insdc = 1;
# Based on older scripts we're going to assume it'll be
# the first (and only) synonym
$insdc_to_ensembl{$species}{$synonyms->[0]->name()} = $slice_name;
}
}
$insdc{$dbadaptor->species()} = $found_insdc;
}
# Go ask UCSC for all their mappings for INSDC to their chromosome name
sub fetch_UCSC {
my ($dbadaptor) = @_;
print STDERR "Examining " . $dbadaptor->species();
my $db_name = $ensembl2ucsc->{$dbadaptor->species()};
unless($db_name) {
print STDERR "\n";
print STDERR "Error, no UCSC database for ". $dbadaptor->species() . " known\n";
$ucsc{$dbadaptor->species()} = -1;
return;
}
print STDERR " ($db_name)\n";
my $dbh; my $fetch_chromosomes;
eval {
$dbh = DBI->connect("dbi:mysql:$db_name:genome-mysql.cse.ucsc.edu:3306:max_allowed_packet=1MB", 'genome', '', undef);
$fetch_chromosomes = $dbh->prepare(qq[SELECT chrom, name FROM ucscToINSDC]);
$fetch_chromosomes->execute() || die "Error with execute: $DBI::errstr\n";
};
if($@) {
print STDERR "Error fetching chromosomes for species " . $dbadaptor->species() . ": $@\n";
$ucsc{$dbadaptor->species()} = -2;
return;
}
while( my @row = $fetch_chromosomes->fetchrow_array() ) {
# Remember the mapping for later
$insdc_to_ucsc{$dbadaptor->species()}{$row[1]} = $row[0];
}
$ucsc{$dbadaptor->species()} = 1;
}
| 28.39697 | 123 | 0.644435 |
edb74a2b8753bc3b9b20f14ae96b4454b71c2ccb | 3,041 | t | Perl | t/analysis_tiddit_coverage.t | Clinical-Genomics/MIP | db2e89fec2674f5c12dbf6ec89eba181433fc742 | [
"MIT"
] | 22 | 2017-09-04T07:50:54.000Z | 2022-01-01T20:41:45.000Z | t/analysis_tiddit_coverage.t | Clinical-Genomics/MIP | db2e89fec2674f5c12dbf6ec89eba181433fc742 | [
"MIT"
] | 834 | 2017-09-05T07:18:38.000Z | 2022-03-31T15:27:49.000Z | t/analysis_tiddit_coverage.t | Clinical-Genomics/MIP | db2e89fec2674f5c12dbf6ec89eba181433fc742 | [
"MIT"
] | 11 | 2017-09-12T10:53:30.000Z | 2021-11-30T01:40:49.000Z | #!/usr/bin/env perl
use 5.026;
use Carp;
use charnames qw{ :full :short };
use English qw{ -no_match_vars };
use File::Basename qw{ dirname };
use File::Spec::Functions qw{ catdir catfile };
use FindBin qw{ $Bin };
use open qw{ :encoding(UTF-8) :std };
use Params::Check qw{ allow check last_error };
use Test::More;
use utf8;
use warnings qw{ FATAL utf8 };
## CPANM
use autodie qw { :all };
use Modern::Perl qw{ 2018 };
use Test::Trap;
## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COLON $COMMA $SPACE };
use MIP::Test::Fixtures qw{ test_add_io_for_recipe test_log test_mip_hashes };
BEGIN {
use MIP::Test::Fixtures qw{ test_import };
### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Recipes::Analysis::Tiddit_coverage} => [qw{ analysis_tiddit_coverage }],
q{MIP::Test::Fixtures} => [qw{ test_add_io_for_recipe test_log test_mip_hashes }],
);
test_import( { perl_module_href => \%perl_module, } );
}
use MIP::Recipes::Analysis::Tiddit_coverage qw{ analysis_tiddit_coverage };
diag( q{Test analysis_tiddit_coverage from Tiddit_coverage.pm}
. $COMMA
. $SPACE . q{Perl}
. $SPACE
. $PERL_VERSION
. $SPACE
. $EXECUTABLE_NAME );
my $log = test_log( { log_name => q{MIP}, no_screen => 1, } );
## Given analysis parameters
my $recipe_name = q{tiddit_coverage};
my $slurm_mock_cmd = catfile( $Bin, qw{ data modules slurm-mock.pl } );
my %active_parameter = test_mip_hashes(
{
mip_hash_name => q{active_parameter},
recipe_name => $recipe_name,
}
);
$active_parameter{$recipe_name} = 1;
$active_parameter{recipe_core_number}{$recipe_name} = 1;
$active_parameter{recipe_time}{$recipe_name} = 1;
$active_parameter{human_genome_reference} =
catfile( $Bin, qw{ data references grch37_homo_sapiens_-d5-.fasta} );
my $sample_id = $active_parameter{sample_ids}[0];
my %file_info = test_mip_hashes(
{
mip_hash_name => q{file_info},
recipe_name => $recipe_name,
}
);
my %job_id;
my %parameter = test_mip_hashes(
{
mip_hash_name => q{recipe_parameter},
recipe_name => $recipe_name,
}
);
test_add_io_for_recipe(
{
file_info_href => \%file_info,
id => $sample_id,
parameter_href => \%parameter,
recipe_name => $recipe_name,
step => q{bam},
}
);
my %sample_info;
my $is_ok = analysis_tiddit_coverage(
{
active_parameter_href => \%active_parameter,
file_info_href => \%file_info,
job_id_href => \%job_id,
parameter_href => \%parameter,
profile_base_command => $slurm_mock_cmd,
recipe_name => $recipe_name,
sample_id => $sample_id,
sample_info_href => \%sample_info,
}
);
## Then return TRUE
ok( $is_ok, q{ Executed analysis recipe } . $recipe_name );
done_testing();
| 26.911504 | 90 | 0.627754 |
ed5b3819097c82ec2873240f25009c5a0944fdd5 | 2,710 | t | Perl | T1/t/t20oo.t | andk/imager | 91aa1a92653c3d6702840519f0f068b9069fb231 | [
"Adobe-2006",
"Adobe-Glyph"
] | 11 | 2015-01-31T00:18:26.000Z | 2021-12-23T15:00:04.000Z | T1/t/t20oo.t | andk/imager | 91aa1a92653c3d6702840519f0f068b9069fb231 | [
"Adobe-2006",
"Adobe-Glyph"
] | 465 | 2020-12-20T04:18:47.000Z | 2022-01-25T01:38:28.000Z | T1/t/t20oo.t | andk/imager | 91aa1a92653c3d6702840519f0f068b9069fb231 | [
"Adobe-2006",
"Adobe-Glyph"
] | 6 | 2016-06-30T14:19:26.000Z | 2021-09-07T13:04:08.000Z | #!/usr/bin/perl -w
use strict;
use Imager;
use Imager::Test qw(isnt_image);
use Test::More tests => 14;
# extracted from t/t36oofont.t
my $fontname_pfb = "fontfiles/dcr10.pfb";
my $green=Imager::Color->new(92,205,92,128);
die $Imager::ERRSTR unless $green;
my $red=Imager::Color->new(205, 92, 92, 255);
die $Imager::ERRSTR unless $red;
-d "testout" or mkdir "testout";
ok(-d "testout", "make output directory");
Imager::init_log("testout/t20oo.log", 1);
my $img=Imager->new(xsize=>300, ysize=>100) or die "$Imager::ERRSTR\n";
my $font=Imager::Font->new(file=>$fontname_pfb,size=>25, type => "t1")
or die $img->{ERRSTR};
ok(1, "created font");
ok($img->string(font=>$font, text=>"XMCLH", 'x'=>100, 'y'=>100),
"draw text");
$img->line(x1=>0, x2=>300, y1=>50, y2=>50, color=>$green);
my $text="LLySja";
my @bbox=$font->bounding_box(string=>$text, 'x'=>0, 'y'=>50);
is(@bbox, 8, "bounding box list length");
$img->box(box=>\@bbox, color=>$green);
# "utf8" support
$text = pack("C*", 0x41, 0xE2, 0x80, 0x90, 0x41);
ok($img->string(font=>$font, text=>$text, 'x'=>100, 'y'=>50, utf8=>1,
overline=>1),
"draw 'utf8' hand-encoded text");
ok($img->string(font=>$font, text=>$text, 'x'=>140, 'y'=>50, utf8=>1,
underline=>1, channel=>2),
"channel 'utf8' hand-encoded text");
SKIP:
{
$] >= 5.006
or skip("perl too old for native utf8", 2);
eval q{$text = "A\x{2010}A"};
ok($img->string(font=>$font, text=>$text, 'x'=>180, 'y'=>50,
strikethrough=>1),
"draw native UTF8 text");
ok($img->string(font=>$font, text=>$text, 'x'=>220, 'y'=>50, channel=>1),
"channel native UTF8 text");
}
ok($img->write(file=>"testout/t36oofont1.ppm", type=>'pnm'),
"write t36oofont1.ppm")
or print "# ",$img->errstr,"\n";
{ # RT 71469
my $font1 = Imager::Font->new(file => $fontname_pfb, type => "t1");
my $font2 = Imager::Font::T1->new(file => $fontname_pfb);
for my $font ($font1, $font2) {
print "# ", join(",", $font->{color}->rgba), "\n";
my $im = Imager->new(xsize => 20, ysize => 20, channels => 4);
ok($im->string(text => "T", font => $font, y => 15),
"draw with default color")
or print "# ", $im->errstr, "\n";
my $work = Imager->new(xsize => 20, ysize => 20);
my $cmp = $work->copy;
$work->rubthrough(src => $im);
isnt_image($work, $cmp, "make sure something was drawn");
}
}
{ # open a non-font as a font (test open failure)
local $ENV{LANG} = "C";
local $ENV{LC_ALL} = "C";
my $font = Imager::Font->new(file => "t/t20oo.t", type => "t1");
ok(!$font, "should fail to open test script as a font");
print "# ", Imager->errstr, "\n";
}
unless ($ENV{IMAGER_KEEP_FILES}) {
unlink "testout/t36oofont1.ppm";
}
| 28.526316 | 75 | 0.593358 |
eda7724b532c162ed90ee5e98d8ea0909d6db251 | 109,808 | pm | Perl | clients/perl/generated/lib/WWW/OpenAPIClient/BlueOceanApi.pm | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/perl/generated/lib/WWW/OpenAPIClient/BlueOceanApi.pm | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/perl/generated/lib/WWW/OpenAPIClient/BlueOceanApi.pm | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | =begin comment
Swaggy Jenkins
Jenkins API clients generated from Swagger / Open API specification
The version of the OpenAPI document: 1.1.2-pre.0
Contact: blah@cliffano.com
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package WWW::OpenAPIClient::BlueOceanApi;
require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);
use WWW::OpenAPIClient::ApiClient;
use base "Class::Data::Inheritable";
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my $api_client;
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
bless { api_client => $api_client }, $class;
}
#
# delete_pipeline_queue_item
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $queue Name of the queue item (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'queue' => {
data_type => 'string',
description => 'Name of the queue item',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'delete_pipeline_queue_item' } = {
summary => '',
params => $params,
returns => undef,
};
}
# @return void
#
sub delete_pipeline_queue_item {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling delete_pipeline_queue_item");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling delete_pipeline_queue_item");
}
# verify the required parameter 'queue' is set
unless (exists $args{'queue'}) {
croak("Missing the required parameter 'queue' when calling delete_pipeline_queue_item");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/queue/{queue}';
my $_method = 'DELETE';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept();
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'queue'}) {
my $_base_variable = "{" . "queue" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'queue'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
}
#
# get_authenticated_user
#
#
#
# @param string $organization Name of the organization (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_authenticated_user' } = {
summary => '',
params => $params,
returns => 'User',
};
}
# @return User
#
sub get_authenticated_user {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_authenticated_user");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/user/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('User', $response);
return $_response_object;
}
#
# get_classes
#
#
#
# @param string $class Name of the class (required)
{
my $params = {
'class' => {
data_type => 'string',
description => 'Name of the class',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_classes' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub get_classes {
my ($self, %args) = @_;
# verify the required parameter 'class' is set
unless (exists $args{'class'}) {
croak("Missing the required parameter 'class' when calling get_classes");
}
# parse inputs
my $_resource_path = '/blue/rest/classes/{class}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'class'}) {
my $_base_variable = "{" . "class" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'class'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# get_json_web_key
#
#
#
# @param int $key Key ID received as part of JWT header field kid (required)
{
my $params = {
'key' => {
data_type => 'int',
description => 'Key ID received as part of JWT header field kid',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_json_web_key' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub get_json_web_key {
my ($self, %args) = @_;
# verify the required parameter 'key' is set
unless (exists $args{'key'}) {
croak("Missing the required parameter 'key' when calling get_json_web_key");
}
# parse inputs
my $_resource_path = '/jwt-auth/jwks/{key}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'key'}) {
my $_base_variable = "{" . "key" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'key'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# get_json_web_token
#
#
#
# @param int $expiry_time_in_mins Token expiry time in minutes, default: 30 minutes (optional)
# @param int $max_expiry_time_in_mins Maximum token expiry time in minutes, default: 480 minutes (optional)
{
my $params = {
'expiry_time_in_mins' => {
data_type => 'int',
description => 'Token expiry time in minutes, default: 30 minutes',
required => '0',
},
'max_expiry_time_in_mins' => {
data_type => 'int',
description => 'Maximum token expiry time in minutes, default: 480 minutes',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'get_json_web_token' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub get_json_web_token {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/jwt-auth/token';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'expiry_time_in_mins'}) {
$query_params->{'expiryTimeInMins'} = $self->{api_client}->to_query_value($args{'expiry_time_in_mins'});
}
# query params
if ( exists $args{'max_expiry_time_in_mins'}) {
$query_params->{'maxExpiryTimeInMins'} = $self->{api_client}->to_query_value($args{'max_expiry_time_in_mins'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# get_organisation
#
#
#
# @param string $organization Name of the organization (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_organisation' } = {
summary => '',
params => $params,
returns => 'Organisation',
};
}
# @return Organisation
#
sub get_organisation {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_organisation");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Organisation', $response);
return $_response_object;
}
#
# get_organisations
#
#
#
{
my $params = {
};
__PACKAGE__->method_documentation->{ 'get_organisations' } = {
summary => '',
params => $params,
returns => 'ARRAY[Organisation]',
};
}
# @return ARRAY[Organisation]
#
sub get_organisations {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/blue/rest/organizations/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[Organisation]', $response);
return $_response_object;
}
#
# get_pipeline
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline' } = {
summary => '',
params => $params,
returns => 'Pipeline',
};
}
# @return Pipeline
#
sub get_pipeline {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('Pipeline', $response);
return $_response_object;
}
#
# get_pipeline_activities
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_activities' } = {
summary => '',
params => $params,
returns => 'ARRAY[PipelineActivity]',
};
}
# @return ARRAY[PipelineActivity]
#
sub get_pipeline_activities {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_activities");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_activities");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/activities';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[PipelineActivity]', $response);
return $_response_object;
}
#
# get_pipeline_branch
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $branch Name of the branch (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'branch' => {
data_type => 'string',
description => 'Name of the branch',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_branch' } = {
summary => '',
params => $params,
returns => 'BranchImpl',
};
}
# @return BranchImpl
#
sub get_pipeline_branch {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_branch");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_branch");
}
# verify the required parameter 'branch' is set
unless (exists $args{'branch'}) {
croak("Missing the required parameter 'branch' when calling get_pipeline_branch");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/branches/{branch}/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'branch'}) {
my $_base_variable = "{" . "branch" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'branch'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('BranchImpl', $response);
return $_response_object;
}
#
# get_pipeline_branch_run
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $branch Name of the branch (required)
# @param string $run Name of the run (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'branch' => {
data_type => 'string',
description => 'Name of the branch',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_branch_run' } = {
summary => '',
params => $params,
returns => 'PipelineRun',
};
}
# @return PipelineRun
#
sub get_pipeline_branch_run {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_branch_run");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_branch_run");
}
# verify the required parameter 'branch' is set
unless (exists $args{'branch'}) {
croak("Missing the required parameter 'branch' when calling get_pipeline_branch_run");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_branch_run");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/branches/{branch}/runs/{run}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'branch'}) {
my $_base_variable = "{" . "branch" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'branch'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineRun', $response);
return $_response_object;
}
#
# get_pipeline_branches
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_branches' } = {
summary => '',
params => $params,
returns => 'MultibranchPipeline',
};
}
# @return MultibranchPipeline
#
sub get_pipeline_branches {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_branches");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_branches");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/branches';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('MultibranchPipeline', $response);
return $_response_object;
}
#
# get_pipeline_folder
#
#
#
# @param string $organization Name of the organization (required)
# @param string $folder Name of the folder (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'folder' => {
data_type => 'string',
description => 'Name of the folder',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_folder' } = {
summary => '',
params => $params,
returns => 'PipelineFolderImpl',
};
}
# @return PipelineFolderImpl
#
sub get_pipeline_folder {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_folder");
}
# verify the required parameter 'folder' is set
unless (exists $args{'folder'}) {
croak("Missing the required parameter 'folder' when calling get_pipeline_folder");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{folder}/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'folder'}) {
my $_base_variable = "{" . "folder" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'folder'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineFolderImpl', $response);
return $_response_object;
}
#
# get_pipeline_folder_pipeline
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $folder Name of the folder (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'folder' => {
data_type => 'string',
description => 'Name of the folder',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_folder_pipeline' } = {
summary => '',
params => $params,
returns => 'PipelineImpl',
};
}
# @return PipelineImpl
#
sub get_pipeline_folder_pipeline {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_folder_pipeline");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_folder_pipeline");
}
# verify the required parameter 'folder' is set
unless (exists $args{'folder'}) {
croak("Missing the required parameter 'folder' when calling get_pipeline_folder_pipeline");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{folder}/pipelines/{pipeline}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'folder'}) {
my $_base_variable = "{" . "folder" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'folder'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineImpl', $response);
return $_response_object;
}
#
# get_pipeline_queue
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_queue' } = {
summary => '',
params => $params,
returns => 'ARRAY[QueueItemImpl]',
};
}
# @return ARRAY[QueueItemImpl]
#
sub get_pipeline_queue {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_queue");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_queue");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/queue';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[QueueItemImpl]', $response);
return $_response_object;
}
#
# get_pipeline_run
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run' } = {
summary => '',
params => $params,
returns => 'PipelineRun',
};
}
# @return PipelineRun
#
sub get_pipeline_run {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineRun', $response);
return $_response_object;
}
#
# get_pipeline_run_log
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param int $start Start position of the log (optional)
# @param boolean $download Set to true in order to download the file, otherwise it's passed as a response body (optional)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'start' => {
data_type => 'int',
description => 'Start position of the log',
required => '0',
},
'download' => {
data_type => 'boolean',
description => 'Set to true in order to download the file, otherwise it's passed as a response body',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_log' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub get_pipeline_run_log {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_log");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_log");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_log");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/log';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'start'}) {
$query_params->{'start'} = $self->{api_client}->to_query_value($args{'start'});
}
# query params
if ( exists $args{'download'}) {
$query_params->{'download'} = $self->{api_client}->to_query_value($args{'download'});
}
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# get_pipeline_run_node
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param string $node Name of the node (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'node' => {
data_type => 'string',
description => 'Name of the node',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_node' } = {
summary => '',
params => $params,
returns => 'PipelineRunNode',
};
}
# @return PipelineRunNode
#
sub get_pipeline_run_node {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_node");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_node");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_node");
}
# verify the required parameter 'node' is set
unless (exists $args{'node'}) {
croak("Missing the required parameter 'node' when calling get_pipeline_run_node");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'node'}) {
my $_base_variable = "{" . "node" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'node'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineRunNode', $response);
return $_response_object;
}
#
# get_pipeline_run_node_step
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param string $node Name of the node (required)
# @param string $step Name of the step (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'node' => {
data_type => 'string',
description => 'Name of the node',
required => '1',
},
'step' => {
data_type => 'string',
description => 'Name of the step',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_node_step' } = {
summary => '',
params => $params,
returns => 'PipelineStepImpl',
};
}
# @return PipelineStepImpl
#
sub get_pipeline_run_node_step {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_node_step");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_node_step");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_node_step");
}
# verify the required parameter 'node' is set
unless (exists $args{'node'}) {
croak("Missing the required parameter 'node' when calling get_pipeline_run_node_step");
}
# verify the required parameter 'step' is set
unless (exists $args{'step'}) {
croak("Missing the required parameter 'step' when calling get_pipeline_run_node_step");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'node'}) {
my $_base_variable = "{" . "node" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'node'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'step'}) {
my $_base_variable = "{" . "step" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'step'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineStepImpl', $response);
return $_response_object;
}
#
# get_pipeline_run_node_step_log
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param string $node Name of the node (required)
# @param string $step Name of the step (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'node' => {
data_type => 'string',
description => 'Name of the node',
required => '1',
},
'step' => {
data_type => 'string',
description => 'Name of the step',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_node_step_log' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub get_pipeline_run_node_step_log {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_node_step_log");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_node_step_log");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_node_step_log");
}
# verify the required parameter 'node' is set
unless (exists $args{'node'}) {
croak("Missing the required parameter 'node' when calling get_pipeline_run_node_step_log");
}
# verify the required parameter 'step' is set
unless (exists $args{'step'}) {
croak("Missing the required parameter 'step' when calling get_pipeline_run_node_step_log");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}/log';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'node'}) {
my $_base_variable = "{" . "node" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'node'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'step'}) {
my $_base_variable = "{" . "step" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'step'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# get_pipeline_run_node_steps
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param string $node Name of the node (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'node' => {
data_type => 'string',
description => 'Name of the node',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_node_steps' } = {
summary => '',
params => $params,
returns => 'ARRAY[PipelineStepImpl]',
};
}
# @return ARRAY[PipelineStepImpl]
#
sub get_pipeline_run_node_steps {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_node_steps");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_node_steps");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_node_steps");
}
# verify the required parameter 'node' is set
unless (exists $args{'node'}) {
croak("Missing the required parameter 'node' when calling get_pipeline_run_node_steps");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'node'}) {
my $_base_variable = "{" . "node" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'node'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[PipelineStepImpl]', $response);
return $_response_object;
}
#
# get_pipeline_run_nodes
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_run_nodes' } = {
summary => '',
params => $params,
returns => 'ARRAY[PipelineRunNode]',
};
}
# @return ARRAY[PipelineRunNode]
#
sub get_pipeline_run_nodes {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_run_nodes");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_run_nodes");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling get_pipeline_run_nodes");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[PipelineRunNode]', $response);
return $_response_object;
}
#
# get_pipeline_runs
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipeline_runs' } = {
summary => '',
params => $params,
returns => 'ARRAY[PipelineRun]',
};
}
# @return ARRAY[PipelineRun]
#
sub get_pipeline_runs {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipeline_runs");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling get_pipeline_runs");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[PipelineRun]', $response);
return $_response_object;
}
#
# get_pipelines
#
#
#
# @param string $organization Name of the organization (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_pipelines' } = {
summary => '',
params => $params,
returns => 'ARRAY[Pipeline]',
};
}
# @return ARRAY[Pipeline]
#
sub get_pipelines {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_pipelines");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pipeline]', $response);
return $_response_object;
}
#
# get_scm
#
#
#
# @param string $organization Name of the organization (required)
# @param string $scm Name of SCM (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'scm' => {
data_type => 'string',
description => 'Name of SCM',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_scm' } = {
summary => '',
params => $params,
returns => 'GithubScm',
};
}
# @return GithubScm
#
sub get_scm {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_scm");
}
# verify the required parameter 'scm' is set
unless (exists $args{'scm'}) {
croak("Missing the required parameter 'scm' when calling get_scm");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/scm/{scm}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm'}) {
my $_base_variable = "{" . "scm" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('GithubScm', $response);
return $_response_object;
}
#
# get_scm_organisation_repositories
#
#
#
# @param string $organization Name of the organization (required)
# @param string $scm Name of SCM (required)
# @param string $scm_organisation Name of the SCM organization (required)
# @param string $credential_id Credential ID (optional)
# @param int $page_size Number of items in a page (optional)
# @param int $page_number Page number (optional)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'scm' => {
data_type => 'string',
description => 'Name of SCM',
required => '1',
},
'scm_organisation' => {
data_type => 'string',
description => 'Name of the SCM organization',
required => '1',
},
'credential_id' => {
data_type => 'string',
description => 'Credential ID',
required => '0',
},
'page_size' => {
data_type => 'int',
description => 'Number of items in a page',
required => '0',
},
'page_number' => {
data_type => 'int',
description => 'Page number',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'get_scm_organisation_repositories' } = {
summary => '',
params => $params,
returns => 'ARRAY[GithubOrganization]',
};
}
# @return ARRAY[GithubOrganization]
#
sub get_scm_organisation_repositories {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_scm_organisation_repositories");
}
# verify the required parameter 'scm' is set
unless (exists $args{'scm'}) {
croak("Missing the required parameter 'scm' when calling get_scm_organisation_repositories");
}
# verify the required parameter 'scm_organisation' is set
unless (exists $args{'scm_organisation'}) {
croak("Missing the required parameter 'scm_organisation' when calling get_scm_organisation_repositories");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/scm/{scm}/organizations/{scmOrganisation}/repositories';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'credential_id'}) {
$query_params->{'credentialId'} = $self->{api_client}->to_query_value($args{'credential_id'});
}
# query params
if ( exists $args{'page_size'}) {
$query_params->{'pageSize'} = $self->{api_client}->to_query_value($args{'page_size'});
}
# query params
if ( exists $args{'page_number'}) {
$query_params->{'pageNumber'} = $self->{api_client}->to_query_value($args{'page_number'});
}
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm'}) {
my $_base_variable = "{" . "scm" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm_organisation'}) {
my $_base_variable = "{" . "scmOrganisation" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm_organisation'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[GithubOrganization]', $response);
return $_response_object;
}
#
# get_scm_organisation_repository
#
#
#
# @param string $organization Name of the organization (required)
# @param string $scm Name of SCM (required)
# @param string $scm_organisation Name of the SCM organization (required)
# @param string $repository Name of the SCM repository (required)
# @param string $credential_id Credential ID (optional)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'scm' => {
data_type => 'string',
description => 'Name of SCM',
required => '1',
},
'scm_organisation' => {
data_type => 'string',
description => 'Name of the SCM organization',
required => '1',
},
'repository' => {
data_type => 'string',
description => 'Name of the SCM repository',
required => '1',
},
'credential_id' => {
data_type => 'string',
description => 'Credential ID',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'get_scm_organisation_repository' } = {
summary => '',
params => $params,
returns => 'ARRAY[GithubOrganization]',
};
}
# @return ARRAY[GithubOrganization]
#
sub get_scm_organisation_repository {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_scm_organisation_repository");
}
# verify the required parameter 'scm' is set
unless (exists $args{'scm'}) {
croak("Missing the required parameter 'scm' when calling get_scm_organisation_repository");
}
# verify the required parameter 'scm_organisation' is set
unless (exists $args{'scm_organisation'}) {
croak("Missing the required parameter 'scm_organisation' when calling get_scm_organisation_repository");
}
# verify the required parameter 'repository' is set
unless (exists $args{'repository'}) {
croak("Missing the required parameter 'repository' when calling get_scm_organisation_repository");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/scm/{scm}/organizations/{scmOrganisation}/repositories/{repository}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'credential_id'}) {
$query_params->{'credentialId'} = $self->{api_client}->to_query_value($args{'credential_id'});
}
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm'}) {
my $_base_variable = "{" . "scm" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm_organisation'}) {
my $_base_variable = "{" . "scmOrganisation" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm_organisation'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'repository'}) {
my $_base_variable = "{" . "repository" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'repository'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[GithubOrganization]', $response);
return $_response_object;
}
#
# get_scm_organisations
#
#
#
# @param string $organization Name of the organization (required)
# @param string $scm Name of SCM (required)
# @param string $credential_id Credential ID (optional)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'scm' => {
data_type => 'string',
description => 'Name of SCM',
required => '1',
},
'credential_id' => {
data_type => 'string',
description => 'Credential ID',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'get_scm_organisations' } = {
summary => '',
params => $params,
returns => 'ARRAY[GithubOrganization]',
};
}
# @return ARRAY[GithubOrganization]
#
sub get_scm_organisations {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_scm_organisations");
}
# verify the required parameter 'scm' is set
unless (exists $args{'scm'}) {
croak("Missing the required parameter 'scm' when calling get_scm_organisations");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/scm/{scm}/organizations';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'credential_id'}) {
$query_params->{'credentialId'} = $self->{api_client}->to_query_value($args{'credential_id'});
}
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'scm'}) {
my $_base_variable = "{" . "scm" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'scm'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[GithubOrganization]', $response);
return $_response_object;
}
#
# get_user
#
#
#
# @param string $organization Name of the organization (required)
# @param string $user Name of the user (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'user' => {
data_type => 'string',
description => 'Name of the user',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_user' } = {
summary => '',
params => $params,
returns => 'User',
};
}
# @return User
#
sub get_user {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_user");
}
# verify the required parameter 'user' is set
unless (exists $args{'user'}) {
croak("Missing the required parameter 'user' when calling get_user");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/users/{user}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'user'}) {
my $_base_variable = "{" . "user" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'user'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('User', $response);
return $_response_object;
}
#
# get_user_favorites
#
#
#
# @param string $user Name of the user (required)
{
my $params = {
'user' => {
data_type => 'string',
description => 'Name of the user',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_user_favorites' } = {
summary => '',
params => $params,
returns => 'ARRAY[FavoriteImpl]',
};
}
# @return ARRAY[FavoriteImpl]
#
sub get_user_favorites {
my ($self, %args) = @_;
# verify the required parameter 'user' is set
unless (exists $args{'user'}) {
croak("Missing the required parameter 'user' when calling get_user_favorites");
}
# parse inputs
my $_resource_path = '/blue/rest/users/{user}/favorites';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'user'}) {
my $_base_variable = "{" . "user" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'user'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[FavoriteImpl]', $response);
return $_response_object;
}
#
# get_users
#
#
#
# @param string $organization Name of the organization (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_users' } = {
summary => '',
params => $params,
returns => 'User',
};
}
# @return User
#
sub get_users {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling get_users");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/users/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('User', $response);
return $_response_object;
}
#
# post_pipeline_run
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'post_pipeline_run' } = {
summary => '',
params => $params,
returns => 'QueueItemImpl',
};
}
# @return QueueItemImpl
#
sub post_pipeline_run {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling post_pipeline_run");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling post_pipeline_run");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling post_pipeline_run");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/replay';
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('QueueItemImpl', $response);
return $_response_object;
}
#
# post_pipeline_runs
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'post_pipeline_runs' } = {
summary => '',
params => $params,
returns => 'QueueItemImpl',
};
}
# @return QueueItemImpl
#
sub post_pipeline_runs {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling post_pipeline_runs");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling post_pipeline_runs");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs';
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('QueueItemImpl', $response);
return $_response_object;
}
#
# put_pipeline_favorite
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param boolean $body Set JSON string body to {\"favorite\": true} to favorite, set value to false to unfavorite (required)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'body' => {
data_type => 'boolean',
description => 'Set JSON string body to {\"favorite\": true} to favorite, set value to false to unfavorite',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'put_pipeline_favorite' } = {
summary => '',
params => $params,
returns => 'FavoriteImpl',
};
}
# @return FavoriteImpl
#
sub put_pipeline_favorite {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling put_pipeline_favorite");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling put_pipeline_favorite");
}
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling put_pipeline_favorite");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/favorite';
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# body params
if ( exists $args{'body'}) {
$_body_data = $args{'body'};
}
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('FavoriteImpl', $response);
return $_response_object;
}
#
# put_pipeline_run
#
#
#
# @param string $organization Name of the organization (required)
# @param string $pipeline Name of the pipeline (required)
# @param string $run Name of the run (required)
# @param string $blocking Set to true to make blocking stop, default: false (optional)
# @param int $time_out_in_secs Timeout in seconds, default: 10 seconds (optional)
{
my $params = {
'organization' => {
data_type => 'string',
description => 'Name of the organization',
required => '1',
},
'pipeline' => {
data_type => 'string',
description => 'Name of the pipeline',
required => '1',
},
'run' => {
data_type => 'string',
description => 'Name of the run',
required => '1',
},
'blocking' => {
data_type => 'string',
description => 'Set to true to make blocking stop, default: false',
required => '0',
},
'time_out_in_secs' => {
data_type => 'int',
description => 'Timeout in seconds, default: 10 seconds',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'put_pipeline_run' } = {
summary => '',
params => $params,
returns => 'PipelineRun',
};
}
# @return PipelineRun
#
sub put_pipeline_run {
my ($self, %args) = @_;
# verify the required parameter 'organization' is set
unless (exists $args{'organization'}) {
croak("Missing the required parameter 'organization' when calling put_pipeline_run");
}
# verify the required parameter 'pipeline' is set
unless (exists $args{'pipeline'}) {
croak("Missing the required parameter 'pipeline' when calling put_pipeline_run");
}
# verify the required parameter 'run' is set
unless (exists $args{'run'}) {
croak("Missing the required parameter 'run' when calling put_pipeline_run");
}
# parse inputs
my $_resource_path = '/blue/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/stop';
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'blocking'}) {
$query_params->{'blocking'} = $self->{api_client}->to_query_value($args{'blocking'});
}
# query params
if ( exists $args{'time_out_in_secs'}) {
$query_params->{'timeOutInSecs'} = $self->{api_client}->to_query_value($args{'time_out_in_secs'});
}
# path params
if ( exists $args{'organization'}) {
my $_base_variable = "{" . "organization" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'organization'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'pipeline'}) {
my $_base_variable = "{" . "pipeline" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pipeline'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'run'}) {
my $_base_variable = "{" . "run" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'run'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('PipelineRun', $response);
return $_response_object;
}
#
# search
#
#
#
# @param string $q Query string (required)
{
my $params = {
'q' => {
data_type => 'string',
description => 'Query string',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'search' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub search {
my ($self, %args) = @_;
# verify the required parameter 'q' is set
unless (exists $args{'q'}) {
croak("Missing the required parameter 'q' when calling search");
}
# parse inputs
my $_resource_path = '/blue/rest/search/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'q'}) {
$query_params->{'q'} = $self->{api_client}->to_query_value($args{'q'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
#
# search_classes
#
#
#
# @param string $q Query string containing an array of class names (required)
{
my $params = {
'q' => {
data_type => 'string',
description => 'Query string containing an array of class names',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'search_classes' } = {
summary => '',
params => $params,
returns => 'string',
};
}
# @return string
#
sub search_classes {
my ($self, %args) = @_;
# verify the required parameter 'q' is set
unless (exists $args{'q'}) {
croak("Missing the required parameter 'q' when calling search_classes");
}
# parse inputs
my $_resource_path = '/blue/rest/classes/';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'q'}) {
$query_params->{'q'} = $self->{api_client}->to_query_value($args{'q'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(jenkins_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
1;
| 31.320023 | 135 | 0.596122 |
Subsets and Splits