code
stringlengths
2
1.05M
repo_name
stringlengths
5
101
path
stringlengths
4
991
language
stringclasses
3 values
license
stringclasses
5 values
size
int64
2
1.05M
use v5.08; use strict; use warnings; use Contacts; use Test::More tests => 3; use List::Util qw/first/; my $home_book = Contacts::init(); my $work_book = Contacts::init(); Contacts::add_contact( $home_book, 'Tom', { lives_in => 'USA', email => 'tomthecat@gmail.com' }); Contacts::add_contact( $home_book, 'Bob', { lives_in => 'USA', email => 'bob@gmail.com' }); Contacts::add_contact( $work_book, 'Mike', { lives_in => 'Mars', email => 'mike@gmail.com' }); my @result = Contacts::contacts_by_country( $home_book, 'USA' ); ok( first { $_ eq 'Tom' } @result, "Tom is in \@result"); ok( first { $_ eq 'Bob' } @result, "Bob is in \@result"); is( @result, 2, "Result has 2 items");
ynonp/perl2-nov15
day2/sol_modules/lab2.pl
Perl
mit
689
=pod =head1 NAME asn1parse - ASN.1 parsing tool =head1 SYNOPSIS B<openssl> B<asn1parse> [B<-inform PEM|DER>] [B<-in filename>] [B<-out filename>] [B<-noout>] [B<-offset number>] [B<-length number>] [B<-i>] [B<-oid filename>] [B<-dump>] [B<-dlimit num>] [B<-strparse offset>] [B<-genstr string>] [B<-genconf file>] [B<-strictpem>] =head1 DESCRIPTION The B<asn1parse> command is a diagnostic utility that can parse ASN.1 structures. It can also be used to extract data from ASN.1 formatted data. =head1 OPTIONS =over 4 =item B<-inform> B<DER|PEM> the input format. B<DER> is binary format and B<PEM> (the default) is base64 encoded. =item B<-in filename> the input file, default is standard input =item B<-out filename> output file to place the DER encoded data into. If this option is not present then no data will be output. This is most useful when combined with the B<-strparse> option. =item B<-noout> don't output the parsed version of the input file. =item B<-offset number> starting offset to begin parsing, default is start of file. =item B<-length number> number of bytes to parse, default is until end of file. =item B<-i> indents the output according to the "depth" of the structures. =item B<-oid filename> a file containing additional OBJECT IDENTIFIERs (OIDs). The format of this file is described in the NOTES section below. =item B<-dump> dump unknown data in hex format. =item B<-dlimit num> like B<-dump>, but only the first B<num> bytes are output. =item B<-strparse offset> parse the contents octets of the ASN.1 object starting at B<offset>. This option can be used multiple times to "drill down" into a nested structure. =item B<-genstr string>, B<-genconf file> generate encoded data based on B<string>, B<file> or both using L<ASN1_generate_nconf(3)> format. If B<file> only is present then the string is obtained from the default section using the name B<asn1>. The encoded data is passed through the ASN1 parser and printed out as though it came from a file, the contents can thus be examined and written to a file using the B<out> option. =item B<-strictpem> If this option is used then B<-inform> will be ignored. Without this option any data in a PEM format input file will be treated as being base64 encoded and processed whether it has the normal PEM BEGIN and END markers or not. This option will ignore any data prior to the start of the BEGIN marker, or after an END marker in a PEM file. =back =head2 OUTPUT The output will typically contain lines like this: 0:d=0 hl=4 l= 681 cons: SEQUENCE ..... 229:d=3 hl=3 l= 141 prim: BIT STRING 373:d=2 hl=3 l= 162 cons: cont [ 3 ] 376:d=3 hl=3 l= 159 cons: SEQUENCE 379:d=4 hl=2 l= 29 cons: SEQUENCE 381:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier 386:d=5 hl=2 l= 22 prim: OCTET STRING 410:d=4 hl=2 l= 112 cons: SEQUENCE 412:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier 417:d=5 hl=2 l= 105 prim: OCTET STRING 524:d=4 hl=2 l= 12 cons: SEQUENCE ..... This example is part of a self signed certificate. Each line starts with the offset in decimal. B<d=XX> specifies the current depth. The depth is increased within the scope of any SET or SEQUENCE. B<hl=XX> gives the header length (tag and length octets) of the current type. B<l=XX> gives the length of the contents octets. The B<-i> option can be used to make the output more readable. Some knowledge of the ASN.1 structure is needed to interpret the output. In this example the BIT STRING at offset 229 is the certificate public key. The contents octets of this will contain the public key information. This can be examined using the option B<-strparse 229> to yield: 0:d=0 hl=3 l= 137 cons: SEQUENCE 3:d=1 hl=3 l= 129 prim: INTEGER :E5D21E1F5C8D208EA7A2166C7FAF9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9E1158A56E4A6F47E5897 135:d=1 hl=2 l= 3 prim: INTEGER :010001 =head1 NOTES If an OID is not part of OpenSSL's internal table it will be represented in numerical form (for example 1.2.3.4). The file passed to the B<-oid> option allows additional OIDs to be included. Each line consists of three columns, the first column is the OID in numerical format and should be followed by white space. The second column is the "short name" which is a single word followed by white space. The final column is the rest of the line and is the "long name". B<asn1parse> displays the long name. Example: C<1.2.3.4 shortName A long name> =head1 EXAMPLES Parse a file: openssl asn1parse -in file.pem Parse a DER file: openssl asn1parse -inform DER -in file.der Generate a simple UTF8String: openssl asn1parse -genstr 'UTF8:Hello World' Generate and write out a UTF8String, don't print parsed output: openssl asn1parse -genstr 'UTF8:Hello World' -noout -out utf8.der Generate using a config file: openssl asn1parse -genconf asn1.cnf -noout -out asn1.der Example config file: asn1=SEQUENCE:seq_sect [seq_sect] field1=BOOL:TRUE field2=EXP:0, UTF8:some random string =head1 BUGS There should be options to change the format of output lines. The output of some ASN.1 types is not well handled (if at all). =head1 SEE ALSO L<ASN1_generate_nconf(3)> =cut
vbloodv/blood
extern/openssl.orig/doc/apps/asn1parse.pod
Perl
mit
5,512
use strict; use Getopt::Long::Descriptive; use Data::Dumper; use Bio::KBase::GenomeAnnotation::CmdHelper qw(:all); =head1 NAME rast-annotate-special-proteins =head1 SYNOPSIS rast-annotate-special-proteins [--input genome-file] [--output genome-file] [< genome-file] [> genome-file] =head1 DESCRIPTION Annotate specialty protein genes. =head1 COMMAND-LINE OPTIONS rast-annotate-proteins-kmer-v2 [-io] [long options...] < input > output -i --input file from which the input is to be read -o --output file to which the output is to be written --help print usage message and exit =cut my @options = options_common(); my($opt, $usage) = describe_options("%c %o < input > output", @options); print($usage->text), exit if $opt->help; my $genome_in = load_input($opt); my $client = get_annotation_client($opt); my $genome_out = $client->annotate_special_proteins($genome_in); write_output($genome_out, $opt);
kbase/genome_annotation
scripts/rast-annotate-special-proteins.pl
Perl
mit
946
#! /usr/bin/perl use strict; my %opt = (); use Getopt::Long "GetOptions"; sub safesystem { print STDERR "Executing: @_\n"; system(@_); if ($? == -1) { print STDERR "Failed to execute: @_\n $!\n"; exit(1); } elsif ($? & 127) { printf STDERR "Execution of: @_\n died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; exit(1); } else { my $exitcode = $? >> 8; print STDERR "Exit code: $exitcode\n" if $exitcode; return ! $exitcode; } } sub init(){ # Command line options processing # GetOptions( "version"=> sub { VersionMessage() }, "help" => sub { HelpMessage() }, "debug:i" => \$opt{debug}, "verbose:i" =>\$opt{verbose}, "config=s" =>\$opt{config}, "i=s" => \$opt{inputfile}, "inputfile=s" => \$opt{inputfile}, "inputtype=s" => \$opt{inputtype}, 'w=s' => \$opt{w}, 'lm=s' => \$opt{lm}, 'tm=s' => \$opt{tm}, 'd=s' => \$opt{d}, 'I=s' => \$opt{I}, 'n-best-list=s' => \$opt{nbestlist}, ); DebugMessage("Debugging is level $opt{debug}.") if defined($opt{debug}); VerboseMessage("Verbose level is $opt{verbose}.") if defined($opt{verbose}); print_parameters() if defined($opt{verbose}) && $opt{verbose} > 1; } sub VersionMessage(){ print STDERR "moses-virtual version 1.0\n"; exit; } sub HelpMessage(){ print STDERR "moses-virtual simulates the standard behavior of Moses\n"; print STDERR "USAGE: moses-virtual\n"; print_parameters(1); exit; } sub DebugMessage(){ my ($msg) = @_; print STDERR "Debug: $msg\n"; } sub VerboseMessage(){ my ($msg) = @_; print STDERR "Verbose: $msg\n"; } sub print_parameters(){ my ($all) = @_; print STDERR "Parameters:\n"; if ($all){ foreach (sort keys %opt){ print STDERR "-$_\n"; } }else{ foreach (sort keys %opt){ print STDERR "-$_=$opt{$_}\n" if defined($opt{$_}); } } print STDERR "pass_through parameters: @ARGV\n" if $#ARGV>=0; } ###################### ### Script starts here ### init() reads prameters from the command line ### you always have to call it init(); my $pwd =`pwd`; chomp($pwd); my $archive_list = "$pwd/archive.list"; my $actual_index = "$pwd/actual.index"; print STDERR "archivelist: $archive_list\n"; print STDERR "actualindex is taken from: $actual_index\n"; my $index=0; if (-e $actual_index){ open(IN,"$actual_index"); $index=<IN>; chomp($index); close(IN); } print STDERR "actualindex: $index\n"; open(IN,"$archive_list"); my ($out,$nbest); for (my $i=0;$i<=$index;$i++){ chomp($_=<IN>); ($out,$nbest) = split(/[ \t]+/,$_); } close(IN); die "output filename is empty\n" if $out eq ""; die "nbest filename is empty\n" if $nbest eq ""; print STDERR "out: |$out|\n"; print STDERR "nbest: |$nbest|\n"; $opt{nbestlist} =~ s/\"//g; my ($nbestfile,$nbestsize) = split(/\|/,$opt{nbestlist}); print STDERR "n-best-list: |",$opt{nbestlist},"|\n"; print STDERR "nbestfile: |$nbestfile|\n"; print STDERR "nbestsize: |$nbestsize|\n"; open(OUT,">$actual_index"); $index++; print OUT "$index\n"; close(IN); safesystem("cp $pwd/$nbest $nbestfile"); safesystem("cat $pwd/$out");
shyamjvs/cs626_project
stat_moses/tools/moses/scripts/regression-testing/moses-virtual.pl
Perl
apache-2.0
3,285
package UI::User; # # # 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. # # # # JvD Note: you always want to put Utils as the first use. Sh*t don't work if it's after the Mojo lines. use UI::Utils; use Mojo::Base 'Mojolicious::Controller'; use Digest::SHA1 qw(sha1_hex); use Mojolicious::Validator; use Mojolicious::Validator::Validation; use Email::Valid; use Data::GUID; use Data::Dumper; # List of Users sub index { my $self = shift; &navbarpage($self); } # NOTE: Do NOT attempt to call this method 'new' or 'init' # because Mojo will death spiral. # Setup a New user for "Add User". sub add { my $self = shift; &stash_role($self); $self->stash( tm_user => {}, fbox_layout => 1, mode => 'add' ); } # Read sub read { my $self = shift; my @data; my $orderby = "username"; $orderby = $self->param('orderby') if ( defined $self->param('orderby') ); my $dbh = $self->db->resultset("TmUser")->search( undef, { prefetch => [ { 'role' => undef } ], order_by => 'me.' . $orderby } ); while ( my $row = $dbh->next ) { push( @data, { "id" => $row->id, "username" => $row->username, "public_ssh_key" => $row->public_ssh_key, "full_name" => $row->full_name, "company" => $row->company, "role" => $row->role->id, "uid" => 0, "gid" => 0, "email" => $row->email, "new_user" => $row->new_user, "rolename" => $row->role->name, "phone_number" => $row->phone_number, } ); } $self->render( json => \@data ); } # Renders the "Send Registration" screen sub register { my $self = shift; my $sent = $self->req->param('sent'); if ( defined($sent) ) { $sent = 'true'; } else { $sent = 'false'; } &stash_role($self); $self->stash( tm_user => {}, sent => $sent, fbox_layout => 1, mode => 'add' ); } # Reset the User Profile password sub reset_password { my $self = shift; my $id = $self->param('id'); my $email_to = $self->param('tm_user.email'); my $data = $self->db->resultset('TmUser')->search( { id => $id } )->single; &stash_role($self); my $email_notice = "Successfully sent reset password to: '" . $email_to . "'"; $self->app->log->info($email_notice); $self->flash( message => $email_notice ); my $token = $self->new_guid(); $self->send_password_reset_email( $email_to, $token ); my %delivery_services = get_delivery_services( $self, $id ); $self->stash( mode => 'edit', tm_user => $data, fbox_layout => 1, delivery_services => \%delivery_services ); return $self->render('user/edit'); } # Sends the email from the registration screen sub send_registration { my $self = shift; my $instance_name = $self->db->resultset('Parameter')->search( { -and => [ name => 'tm.instance_name', config_file => 'global' ] } )->get_column('value')->single(); $self->stash( instance_name => $instance_name ); if ( $self->is_send_register_valid() ) { my $token = $self->new_guid(); my $email_to = $self->param('tm_user.email'); $self->send_registration_email( $email_to, $token ); $self->create_registration_user( $email_to, $token ); return $self->redirect_to('/user/register?sent=true'); } else { $self->stash( tm_user => {}, fbox_layout => 1 ); return $self->render('user/register'); } } sub edit { my $self = shift; my $id = $self->param('id'); my $dbh = $self->db->resultset('TmUser')->search( { id => $id } ); my $data = $dbh->single; &stash_role($self); my %delivery_services = get_delivery_services( $self, $id ); $self->stash( tm_user => $data, mode => 'edit', fbox_layout => 1, delivery_services => \%delivery_services ); return $self->render('user/edit'); } sub get_delivery_services { my $self = shift; my $id = shift; my @ds_ids = $self->db->resultset('DeliveryserviceTmuser')->search( { tm_user_id => $id } )->get_column('deliveryservice')->all; my %delivery_services; for my $ds_id (@ds_ids) { my $desc = $self->db->resultset('Deliveryservice')->search( { id => $ds_id } )->get_column('xml_id')->single; $delivery_services{$ds_id} = $desc; } return %delivery_services; } # Update sub update { my $self = shift; my $tm_user_id = $self->param('id'); my @ds_ids = $self->param('deliveryservices'); $self->associated_delivery_services( $tm_user_id, \@ds_ids ); # Prevent these from getting updated # Do not modify the local_passwd if it comes across as blank. my $local_passwd = $self->param("tm_user.local_passwd"); my $confirm_local_passwd = $self->param("tm_user.confirm_local_passwd"); if ( $self->is_valid("edit") ) { my $dbh = $self->db->resultset('TmUser')->find( { id => $tm_user_id } ); $dbh->username( $self->param('tm_user.username') ); $dbh->public_ssh_key( $self->param('tm_user.public_ssh_key') ); $dbh->full_name( $self->param('tm_user.full_name') ); $dbh->role( $self->param('tm_user.role') ); $dbh->uid(0); $dbh->gid(0); # ignore the local_passwd and confirm_local_passwd if it comes across as blank (or it didn't change) if ( defined($local_passwd) && $local_passwd ne '' ) { $dbh->local_passwd( sha1_hex( $self->param('tm_user.local_passwd') ) ); } if ( defined($confirm_local_passwd) && $confirm_local_passwd ne '' ) { $dbh->confirm_local_passwd( sha1_hex( $self->param('tm_user.confirm_local_passwd') ) ); } $dbh->company( $self->param('tm_user.company') ); $dbh->email( $self->param('tm_user.email') ); $dbh->full_name( $self->param('tm_user.full_name') ); $dbh->address_line1( $self->param('tm_user.address_line1') ); $dbh->address_line2( $self->param('tm_user.address_line2') ); $dbh->city( $self->param('tm_user.city') ); $dbh->state_or_province( $self->param('tm_user.state_or_province') ); $dbh->phone_number( $self->param('tm_user.phone_number') ); $dbh->postal_code( $self->param('tm_user.postal_code') ); $dbh->country( $self->param('tm_user.country') ); $dbh->update(); $self->flash( message => "User was updated successfully." ); $self->stash( mode => 'edit' ); return $self->redirect_to( '/user/' . $tm_user_id . '/edit' ); } else { $self->edit(); } } sub associated_delivery_services { my $self = shift; my $tm_user_id = shift; my $ds_ids = shift; my $new_id = -1; # Sweep the existing DeliveryserviceTmUser relationships my $delete = $self->db->resultset('DeliveryserviceTmuser')->search( { tm_user_id => $tm_user_id } ); $delete->delete(); # Attached the saved delivery services foreach my $ds_id ( @{$ds_ids} ) { my $ds_name = $self->db->resultset('Deliveryservice')->search( { id => $ds_id } )->get_column('xml_id')->single(); my $insert = $self->db->resultset('DeliveryserviceTmuser')->create( { deliveryservice => $ds_id, tm_user_id => $tm_user_id } ); $new_id = $insert->tm_user_id; $insert->insert(); &log( $self, "Associated Delivery service " . $ds_name . " <-> with tm_user_id: " . $tm_user_id, "UICHANGE" ); } } # Create sub create { my $self = shift; &stash_role($self); $self->stash( fbox_layout => 1, mode => 'add', tm_user => {} ); if ( $self->is_valid("add") ) { my $new_id = $self->create_user(); if ( $new_id != -1 ) { $self->flash( message => 'User created successfully.' ); return $self->redirect_to('/close_fancybox.html'); } } else { return $self->render('user/add'); } } sub is_valid { my $self = shift; my $mode = shift; $self->field('tm_user.full_name')->is_required; $self->field('tm_user.username')->is_required; $self->field('tm_user.email')->is_required; if ( $mode =~ /add/ ) { $self->field('tm_user.local_passwd')->is_required; $self->field('tm_user.confirm_local_passwd')->is_required; $self->is_username_taken( $self->param('tm_user.username') ); $self->is_email_taken(); $self->is_email_format_valid(); } $self->field('tm_user.local_passwd')->is_equal( 'tm_user.confirm_local_passwd', "The 'Password' and 'Confirm Password' must match." ); $self->field('tm_user.local_passwd')->is_like( qr/^.{8,100}$/, "Password must be greater than 7 chars." ); return $self->valid; } sub is_send_register_valid { my $self = shift; $self->field('tm_user.email')->is_required; return $self->valid; } sub create_user { my $self = shift; my $new_id = -1; my $dbh = $self->db->resultset('TmUser')->create( { full_name => $self->param('tm_user.full_name'), username => $self->param('tm_user.username'), public_ssh_key => $self->param('tm_user.public_ssh_key'), phone_number => $self->param('tm_user.phone_number'), email => $self->param('tm_user.email'), local_passwd => sha1_hex( $self->param('tm_user.local_passwd') ), confirm_local_passwd => sha1_hex( $self->param('tm_user.confirm_local_passwd') ), role => $self->param('tm_user.role'), new_user => 0, uid => 0, gid => 0, company => $self->param('tm_user.company'), address_line1 => $self->param('tm_user.address_line1'), address_line2 => $self->param('tm_user.address_line2'), city => $self->param('tm_user.city'), state_or_province => $self->param('tm_user.state_or_province'), postal_code => $self->param('tm_user.postal_code'), country => $self->param('tm_user.country'), } ); $new_id = $dbh->insert(); # if the insert has failed, we don't even get here, we go to the exception page. &log( $self, "Create tm_user with name " . $self->param('tm_user.username'), "UICHANGE" ); return $new_id; } sub new_guid { return Data::GUID->new; } 1;
knutsel/traffic_control-1
traffic_ops/app/lib/UI/User.pm
Perl
apache-2.0
10,224
# # Copyright 2018 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::acmepacket::snmp::mode::components::voltage; use strict; use warnings; use network::acmepacket::snmp::mode::components::resources qw($map_status); my $mapping = { apEnvMonVoltageStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.3' }, apEnvMonVoltageStatusValue => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.4' }, apEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.5', map => $map_status }, }; my $oid_apEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9148.3.3.1.2.1.1'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_apEnvMonVoltageStatusEntry }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking voltages"); $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; return if ($self->check_filter(section => 'voltage')); my ($exit, $warn, $crit, $checked); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_apEnvMonVoltageStatusEntry}})) { next if ($oid !~ /^$mapping->{apEnvMonVoltageState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_apEnvMonVoltageStatusEntry}, instance => $instance); next if ($self->check_filter(section => 'voltage', instance => $instance)); next if ($result->{apEnvMonVoltageState} =~ /notPresent/i && $self->absent_problem(section => 'voltage', instance => $instance)); $result->{apEnvMonVoltageStatusValue} = sprintf("%.3f", $result->{apEnvMonVoltageStatusValue}); $self->{components}->{voltage}->{total}++; $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s, value = %s]", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState}, $instance, $result->{apEnvMonVoltageStatusValue})); $exit = $self->get_severity(label => 'default', section => 'voltage', value => $result->{apEnvMonVoltageState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Voltage '%s' status is '%s'", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState})); } ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{apEnvMonVoltageStatusValue}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Voltage '%s' is '%s' V", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageStatusValue})); } $self->{output}->perfdata_add(label => 'voltage_' . $result->{apEnvMonVoltageStatusDescr}, unit => 'V', value => $result->{apEnvMonVoltageStatusValue}, warning => $warn, critical => $crit ); } } 1;
wilfriedcomte/centreon-plugins
network/acmepacket/snmp/mode/components/voltage.pm
Perl
apache-2.0
4,137
# # Copyright 2021 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 hardware::pdu::emerson::snmp::mode::receptacles; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); use Digest::MD5 qw(md5_hex); sub custom_rcp_status_output { my ($self, %options) = @_; my $msg = sprintf( "operational state '%s' [power state: %s]", $self->{result_values}->{oper_state}, $self->{result_values}->{power_state} ); return $msg; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'rb', type => 3, cb_prefix_output => 'prefix_rb_output', cb_long_output => 'rb_long_output', indent_long_output => ' ', message_multiple => 'All receptacle branches are ok', group => [ { name => 'global', type => 0, skipped_code => { -10 => 1 } }, { name => 'rcp', display_long => 1, cb_prefix_output => 'prefix_rcp_output', message_multiple => 'All receptacles are ok', type => 1, skipped_code => { -10 => 1 } }, ] } ]; $self->{maps_counters}->{global} = [ { label => 'total-accumulated-energy', nlabel => 'receptaclebranch.total.accumulated.energy.kilowatthour', set => { key_values => [ { name => 'lgpPduRbEntryEnergyAccum', diff => 1 } ], output_template => 'total input power : %s kWh', perfdatas => [ { template => '%s', value => 'lgpPduRbEntryEnergyAccum', unit => 'kWh', min => 0, label_extra_instance => 1 }, ], } }, { label => 'line2neutral-real-power', nlabel => 'receptaclebranch.line2neutral.real.power.watt', set => { key_values => [ { name => 'lgpPduRbEntryPwr' } ], output_template => 'line-to-neutral real power : %s W', perfdatas => [ { template => '%s', value => 'lgpPduRbEntryPwr', unit => 'W', min => 0, label_extra_instance => 1 }, ], } }, { label => 'line2neutral-apparent-power', nlabel => 'receptaclebranch.line2neutral.apparent.power.voltampere', set => { key_values => [ { name => 'lgpPduRbEntryAp' } ], output_template => 'line-to-neutral apparent power : %s VA', perfdatas => [ { template => '%s', value => 'lgpPduRbEntryAp', unit => 'VA', min => 0, label_extra_instance => 1 }, ], } }, { label => 'current-neutral', nlabel => 'receptaclebranch.line2neutral.current.ampacrms', set => { key_values => [ { name => 'lgpPduRbEntryEcHundredths' } ], output_template => 'line-to-neutral current : %s Amp AC RMS', perfdatas => [ { value => 'lgpPduRbEntryEcHundredths', template => '%s', unit => 'AmpAcRMS', min => 0, label_extra_instance => 1 }, ], } }, { label => 'potential-neutral', nlabel => 'receptaclebranch.line2neutral.potential.voltrms', set => { key_values => [ { name => 'lgpPduRbEntryEpLNTenths' } ], output_template => 'line-to-neutral potential : %s VoltRMS', perfdatas => [ { value => 'lgpPduRbEntryEpLNTenths', template => '%s', unit => 'VoltRMS', min => 0, label_extra_instance => 1 }, ], } }, ]; $self->{maps_counters}->{rcp} = [ { label => 'rcp-status', threshold => 0, set => { key_values => [ { name => 'oper_state' }, { name => 'power_state' }, { name => 'display' } ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_rcp_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, } }, ]; } sub prefix_rb_output { my ($self, %options) = @_; return "Receptacle branch '" . $options{instance_value}->{display} . "' : "; } sub rb_long_output { my ($self, %options) = @_; return "checking receptacle branch '" . $options{instance_value}->{display} . "'"; } sub prefix_rcp_output { my ($self, %options) = @_; return "receptacle '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { 'filter-rb:s' => { name => 'filter_rb' }, 'unknown-rcp-status:s' => { name => 'unknown_rcp_status', default => '' }, 'warning-rcp-status:s' => { name => 'warning_rcp_status', default => '%{oper_state} =~ /warning|alarm/' }, 'critical-rcp-status:s' => { name => 'critical_rcp_status', default => '%{oper_state} =~ /abnormal/' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->change_macros(macros => ['unknown_rcp_status', 'warning_rcp_status', 'critical_rcp_status']); } my $rcp_power_state = { 0 => 'unknown', 1 => 'off', 2 => 'on', 3 => 'off-pending-on-delay' }; my $rcp_oper = { 1 => 'normal', 2 => 'warning', 3 => 'alarm', 4 => 'abnormal' }; sub manage_selection { my ($self, %options) = @_; my $mapping = { lgpPduEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.10' }, lgpPduEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.15' }, }; my $mapping2 = { lgpPduRbEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.8' }, lgpPduRbEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.20' }, lgpPduRbEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.85' }, # 0.1 Kilowatt-Hour lgpPduRbEntryEpLNTenths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.100' }, lgpPduRbEntryPwr => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.115' }, # Watt lgpPduRbEntryAp => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.120' }, # VA lgpPduRbEntryEcHundredths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.130' }, }; my $mapping3 = { lgpPduRcpEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.50.20.1.10' }, lgpPduRcpEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.50.20.1.25' }, lgpPduRcpEntryPwrState => { oid => '.1.3.6.1.4.1.476.1.42.3.8.50.20.1.95', map => $rcp_power_state }, lgpPduRcpEntryOperationCondition => { oid => '.1.3.6.1.4.1.476.1.42.3.8.50.20.1.210', map => $rcp_oper }, }; my $oid_lgpPduEntry = '.1.3.6.1.4.1.476.1.42.3.8.20.1'; my $oid_lgpPduRbEntry = '.1.3.6.1.4.1.476.1.42.3.8.40.20.1'; my $oid_lgpPduRcpEntry = '.1.3.6.1.4.1.476.1.42.3.8.50.20.1'; my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $oid_lgpPduEntry, start => $mapping->{lgpPduEntryUsrLabel}->{oid}, end => $mapping->{lgpPduEntrySysAssignLabel}->{oid} }, { oid => $oid_lgpPduRbEntry, start => $mapping2->{lgpPduRbEntryUsrLabel}->{oid}, end => $mapping2->{lgpPduRbEntryEcHundredths}->{oid} }, { oid => $oid_lgpPduRcpEntry, start => $mapping3->{lgpPduRcpEntryUsrLabel}->{oid}, end => $mapping3->{lgpPduRcpEntryOperationCondition}->{oid} }, ], nothing_quit => 1, ); $self->{rb} = {}; foreach my $oid (keys %{$snmp_result->{$oid_lgpPduRbEntry}}) { next if ($oid !~ /^$mapping2->{lgpPduRbEntrySysAssignLabel}->{oid}\.(.*?)\.(.*)$/); my ($pdu_index, $rb_index) = ($1, $2); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_lgpPduEntry}, instance => $pdu_index); my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_lgpPduRbEntry}, instance => $pdu_index . '.' . $rb_index); my $name = (defined($result->{lgpPduEntryUsrLabel}) && $result->{lgpPduEntryUsrLabel} ne '' ? $result->{lgpPduEntryUsrLabel} : $result->{lgpPduEntrySysAssignLabel}); $name .= '~' . (defined($result2->{lgpPduRbEntryUsrLabel}) && $result2->{lgpPduRbEntryUsrLabel} ne '' ? $result2->{lgpPduRbEntryUsrLabel} : $result2->{lgpPduRbEntrySysAssignLabel}); 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 receptacle branch '" . $name . "'.", debug => 1); next; } $result2->{lgpPduRbEntryEnergyAccum} /= 10; $result2->{lgpPduRbEntryEcHundredths} *= 0.01 if (defined($result2->{lgpPduRbEntryEcHundredths})); $result2->{lgpPduRbEntryEpLNTenths} *= 0.1 if (defined($result2->{lgpPduRbEntryEpLNTenths})); $self->{rb}->{$name} = { display => $name, global => { %$result2 }, rcp => {}, }; foreach (keys %{$snmp_result->{$oid_lgpPduRcpEntry}}) { next if (!/^$mapping3->{lgpPduRcpEntrySysAssignLabel}->{oid}\.$pdu_index\.$rb_index\.(.*)$/); my $rcp_index = $1; my $result3 = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result->{$oid_lgpPduRcpEntry}, instance => $pdu_index . '.' . $rb_index . '.' . $rcp_index); my $rcp_name = (defined($result3->{lgpPduRcpEntryUsrLabel}) && $result3->{lgpPduRcpEntryUsrLabel} ne '' ? $result3->{lgpPduRcpEntryUsrLabel} : $result3->{lgpPduRcpEntrySysAssignLabel}); $self->{rb}->{$name}->{rcp}->{$rcp_name} = { display => $rcp_name, power_state => $result3->{lgpPduRcpEntryPwrState}, oper_state => $result3->{lgpPduRcpEntryOperationCondition}, }; } } if (scalar(keys %{$self->{rb}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No receptacle branch found."); $self->{output}->option_exit(); } $self->{cache_name} = "pdu_liebert_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_rb}) ? md5_hex($self->{option_results}->{filter_rb}) : md5_hex('all')); } 1; __END__ =head1 MODE Check receptacles. =over 8 =item B<--filter-rb> Filter receptable branch name (can be a regexp). =item B<--unknown-rcp-status> Set warning threshold for status (Default: ''). Can used special variables like: %{oper_state}, %{power_state}, %{display} =item B<--warning-rcp-status> Set warning threshold for status (Default: '%{oper_state} =~ /warning|alarm/'). Can used special variables like: %{oper_state}, %{power_state}, %{display} =item B<--critical-rcp-status> Set critical threshold for status (Default: '%{oper_state} =~ /abnormal/'). Can used special variables like: %{oper_state}, %{power_state}, %{display} =item B<--warning-*> B<--critical-*> Thresholds. Can be: 'total-accumulated-energy', 'line2neutral-real-power', 'line2neutral-apparent-power'. =back =cut
Tpo76/centreon-plugins
hardware/pdu/emerson/snmp/mode/receptacles.pm
Perl
apache-2.0
12,377
use 5.008001; use Test::Roo; use lib 't/lib'; with 'LastTest'; test in_main => sub { pass("main"); }; run_me; done_testing; # # This file is part of Test-Roo # # This software is Copyright (c) 2013 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # # vim: ts=4 sts=4 sw=4 et:
gitpan/Test-Roo
t/bin/custom-order.pl
Perl
apache-2.0
348
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Authors : Roman Morandell - ivertix # package apps::backup::commvault::commserve::restapi::custom::api; use strict; use warnings; use centreon::plugins::http; use centreon::plugins::statefile; use JSON::XS; use Digest::MD5 qw(md5_hex); use MIME::Base64; sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; if (!defined($options{output})) { print "Class Custom: Need to specify 'output' argument.\n"; exit 3; } if (!defined($options{options})) { $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); $options{output}->option_exit(); } if (!defined($options{noptions})) { $options{options}->add_options(arguments => { 'hostname:s' => { name => 'hostname' }, 'port:s' => { name => 'port' }, 'proto:s' => { name => 'proto' }, 'url-path:s' => { name => 'url_path' }, 'api-username:s' => { name => 'api_username' }, 'api-password:s' => { name => 'api_password' }, 'user-domain:s' => { name => 'user_domain' }, 'timeout:s' => { name => 'timeout' }, 'cache-create' => { name => 'cache_create' }, 'cache-use' => { name => 'cache_use' } }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{http} = centreon::plugins::http->new(%options); $self->{cache} = centreon::plugins::statefile->new(%options); return $self; } sub set_options { my ($self, %options) = @_; $self->{option_results} = $options{option_results}; } sub set_defaults {} sub check_options { my ($self, %options) = @_; $self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/webconsole/api'; $self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : ''; $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30; $self->{user_domain} = (defined($self->{option_results}->{user_domain})) ? $self->{option_results}->{user_domain} : ''; $self->{cache_create} = $self->{option_results}->{cache_create}; $self->{cache_use} = $self->{option_results}->{cache_use}; if ($self->{hostname} eq '') { $self->{output}->add_option_msg(short_msg => 'Need to specify hostname option.'); $self->{output}->option_exit(); } if ($self->{api_username} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --api-username option."); $self->{output}->option_exit(); } if ($self->{api_password} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --api-password option."); $self->{output}->option_exit(); } $self->{cache}->check_options(option_results => $self->{option_results}); return 0; } sub get_connection_infos { my ($self, %options) = @_; return $self->{hostname} . '_' . $self->{http}->get_port(); } sub get_hostname { my ($self, %options) = @_; return $self->{hostname}; } sub get_port { my ($self, %options) = @_; return $self->{port}; } sub is_use_cache { my ($self, %options) = @_; return defined($self->{cache_use}) ? 1 : 0; } sub json_decode { my ($self, %options) = @_; $options{content} =~ s/\r//mg; my $decoded; eval { $decoded = JSON::XS->new->utf8->decode($options{content}); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); $self->{output}->option_exit(); } return $decoded; } sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; } sub settings { my ($self, %options) = @_; $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Accept', value => 'application/json'); $self->{http}->add_header(key => 'Content-Type', value => 'application/json'); $self->{http}->set_options(%{$self->{option_results}}); } sub clean_token { my ($self, %options) = @_; my $datas = {}; $options{statefile}->write(data => $datas); $self->{access_token} = undef; $self->{http}->add_header(key => 'Authorization', value => undef); } sub get_auth_token { my ($self, %options) = @_; my $has_cache_file = $options{statefile}->read(statefile => 'commvault_commserve_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); my $access_token = $options{statefile}->get(name => 'access_token'); # Token expires every 15 minutes if ($has_cache_file == 0 || !defined($access_token)) { my $json_request = { username => $self->{api_username}, password => MIME::Base64::encode_base64($self->{api_password}, '') }; $json_request->{domain} = $self->{user_domain} if ($self->{user_domain} ne ''); my $encoded; eval { $encoded = encode_json($json_request); }; if ($@) { $self->{output}->add_option_msg(short_msg => 'cannot encode json request'); $self->{output}->option_exit(); } my ($content) = $self->{http}->request( method => 'POST', url_path => $self->{url_path} . '/Login', query_form_post => $encoded, warning_status => '', unknown_status => '', critical_status => '' ); if ($self->{http}->get_code() != 200) { $self->{output}->add_option_msg(short_msg => "Authentication error [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); $self->{output}->option_exit(); } my $decoded = $self->json_decode(content => $content); if (!defined($decoded->{token})) { $self->{output}->add_option_msg(short_msg => "Cannot get token"); $self->{output}->option_exit(); } $access_token = $decoded->{token}; my $datas = { access_token => $access_token }; $options{statefile}->write(data => $datas); } $self->{access_token} = $access_token; $self->{http}->add_header(key => 'Authtoken', value => $self->{access_token}); } sub request_internal { my ($self, %options) = @_; $self->settings(); if (!defined($self->{access_token})) { $self->get_auth_token(statefile => $self->{cache}); } my $content = $self->{http}->request( url_path => $self->{url_path} . $options{endpoint}, get_param => $options{get_param}, warning_status => '', unknown_status => '', critical_status => '' ); # Maybe there is an issue with the token. So we retry. if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) { $self->clean_token(statefile => $self->{cache}); $self->get_auth_token(statefile => $self->{cache}); $content = $self->{http}->request( url_path => $self->{url_path} . $options{endpoint}, get_param => $options{get_param}, header => $options{header}, warning_status => '', unknown_status => '', critical_status => '' ); } my $decoded = $self->json_decode(content => $content); if (!defined($decoded)) { $self->{output}->add_option_msg(short_msg => 'Error while retrieving data (add --debug option for detailed message)'); $self->{output}->option_exit(); } if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) { $self->{output}->add_option_msg(short_msg => 'api request error'); $self->{output}->option_exit(); } return $decoded; } sub get_cache_file_response { my ($self, %options) = @_; $self->{cache}->read(statefile => 'cache_commvault_commserve_' . $options{type} . '_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); my $response = $self->{cache}->get(name => 'response'); my $update_time = $self->{cache}->get(name => 'update_time'); if (!defined($response)) { $self->{output}->add_option_msg(short_msg => 'Cache file missing'); $self->{output}->option_exit(); } return $response; } sub get_cache_file_update { my ($self, %options) = @_; $self->{cache}->read(statefile => 'cache_commvault_commserve_' . $options{type} . '_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); my $update_time = $self->{cache}->get(name => 'update_time'); return $update_time; } sub create_cache_file { my ($self, %options) = @_; $self->{cache}->read(statefile => 'cache_commvault_commserve_' . $options{type} . '_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); $self->{cache}->write(data => { response => $options{response}, update_time => time() }); $self->{output}->output_add( severity => 'ok', short_msg => 'Cache file created successfully' ); $self->{output}->display(); $self->{output}->exit(); } sub request { my ($self, %options) = @_; return $self->get_cache_file_response(type => $options{type}) if (defined($self->{cache_use})); my $response = $self->request_internal( endpoint => $options{endpoint} ); $self->create_cache_file(type => $options{type}, response => $response) if (defined($self->{cache_create})); return $response; } sub request_jobs { my ($self, %options) = @_; return $self->get_cache_file_response(type => 'jobs') if (defined($self->{cache_use})); my $lookup_time = $options{completed_job_lookup_time}; if (defined($self->{cache_create})) { my $update_time = $self->get_cache_file_update(type => 'jobs'); $lookup_time = 3600; if (defined($update_time)) { $lookup_time = time() - $update_time; } } my $response = $self->request_internal( endpoint => $options{endpoint}, get_param => ['completedJobLookupTime=' . $lookup_time] ); $self->create_cache_file(type => 'jobs', response => $response) if (defined($self->{cache_create})); return $response; } sub request_paging { my ($self, %options) = @_; return $self->get_cache_file_response(type => $options{type}) if (defined($self->{cache_use})); my ($page_num, $page_count) = (1, 200); my $alerts = []; while (1) { my $results = $self->request_internal( endpoint => $options{endpoint}, get_param => ['pageNo=' . $page_num, 'pageCount=' . $page_count], header => ['Cache-Control: private'] ); last if (!defined($results->{feedsList})); push @$alerts, @{$results->{feedsList}}; last if ($results->{totalNoOfAlerts} < ($page_num * $page_count)); $page_num++; } $self->create_cache_file(type => $options{type}, response => $alerts) if (defined($self->{cache_create})); return $alerts; } 1; __END__ =head1 NAME Commvault API =head1 SYNOPSIS Commvault api =head1 REST API OPTIONS =over 8 =item B<--hostname> API hostname. =item B<--url-path> API url path (Default: '/webconsole/api') =item B<--port> API port (Default: 443) =item B<--proto> Specify https if needed (Default: 'https') =item B<--api-username> Set API username =item B<--api-password> Set API password =item B<--timeout> Set HTTP timeout =item B<--cache-create> Create a cache file and quit. =item B<--cache-use> Use the cache file (created with --cache-create). =back =head1 DESCRIPTION B<custom>. =cut
centreon/centreon-plugins
apps/backup/commvault/commserve/restapi/custom/api.pm
Perl
apache-2.0
13,356
##************************************************************** ## ## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department, ## University of Wisconsin-Madison, WI. ## ## 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 SimpleJob; use CondorTest; $submitted = sub { CondorTest::debug("Job submitted\n",1); }; $aborted = sub { die "Abort event NOT expected\n"; }; $execute = sub { }; $ExitSuccess = sub { CondorTest::debug("Job completed\n",1); }; sub RunCheck { my %args = @_; my $testname = $args{test_name} || CondorTest::GetDefaultTestName(); my $universe = $args{universe} || "vanilla"; my $user_log = $args{user_log} || CondorTest::TempFileName("$testname.user_log"); my $append_submit_commands = $args{append_submit_commands} || ""; my $grid_resource = $args{grid_resource} || ""; my $should_transfer_files = $args{should_transfer_files} || ""; my $when_to_transfer_output = $args{when_to_transfer_output} || ""; CondorTest::RegisterAbort( $testname, $aborted ); CondorTest::RegisterExitedSuccess( $testname, $ExitSuccess ); CondorTest::RegisterExecute($testname, $execute); CondorTest::RegisterSubmit( $testname, $submitted ); my $submit_fname = CondorTest::TempFileName("$testname.submit"); open( SUBMIT, ">$submit_fname" ) || die "error writing to $submit_fname: $!\n"; print SUBMIT "universe = $universe\n"; print SUBMIT "executable = x_sleep.pl\n"; print SUBMIT "log = $user_log\n"; print SUBMIT "arguments = 1\n"; print SUBMIT "notification = never\n"; if( $grid_resource ne "" ) { print SUBMIT "GridResource = $grid_resource\n" } if( $should_transfer_files ne "" ) { print SUBMIT "ShouldTransferFiles = $should_transfer_files\n"; } if( $when_to_transfer_output ne "" ) { print SUBMIT "WhenToTransferOutput = $when_to_transfer_output\n"; } if( $append_submit_commands ne "" ) { print SUBMIT "\n" . $append_submit_commands . "\n"; } print SUBMIT "queue\n"; close( SUBMIT ); my $result = CondorTest::RunTest($testname, $submit_fname, 0); CondorTest::RegisterResult( $result, %args ); return $result; } 1;
clalancette/condor-dcloud
src/condor_tests/Check/SimpleJob.pm
Perl
apache-2.0
2,765
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package centreon::common::protocols::actuator::custom::standard; use strict; use warnings; use centreon::plugins::http; use JSON::XS; sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; if (!defined($options{output})) { print "Class Custom: Need to specify 'output' argument.\n"; exit 3; } if (!defined($options{options})) { $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); $options{output}->option_exit(); } if (!defined($options{noptions})) { $options{options}->add_options(arguments => { 'api-username:s' => { name => 'api_username' }, 'api-password:s' => { name => 'api_password' }, 'hostname:s' => { name => 'hostname' }, 'port:s' => { name => 'port' }, 'proto:s' => { name => 'proto' }, 'timeout:s' => { name => 'timeout' }, 'unknown-http-status:s' => { name => 'unknown_http_status' }, 'warning-http-status:s' => { name => 'warning_http_status' }, 'critical-http-status:s' => { name => 'critical_http_status' }, 'url-path:s' => { name => 'url_path' } }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{http} = centreon::plugins::http->new(%options); return $self; } sub set_options { my ($self, %options) = @_; $self->{option_results} = $options{option_results}; } sub set_defaults {} sub check_options { my ($self, %options) = @_; $self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8080; $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30; $self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : ''; $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : ''; $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300'; $self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : ''; $self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : ''; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/actuator'; if ($self->{hostname} eq '') { $self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.'); $self->{output}->option_exit(); } return 0; } sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; $self->{option_results}->{timeout} = $self->{timeout}; if (defined($self->{api_username}) && $self->{api_username} ne '') { $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{api_username}; $self->{option_results}->{password} = $self->{api_password}; } } sub settings { my ($self, %options) = @_; return if (defined($self->{settings_done})); $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Accept', value => 'application/json'); $self->{http}->set_options(%{$self->{option_results}}); $self->{settings_done} = 1; } sub get_connection_infos { my ($self, %options) = @_; return $self->{hostname} . '_' . $self->{http}->get_port(); } sub get_hostname { my ($self, %options) = @_; return $self->{hostname}; } sub request_api { my ($self, %options) = @_; $self->settings(); my $content = $self->{http}->request( url_path => $self->{url_path} . $options{endpoint}, get_param => $options{get_param}, unknown_status => $self->{unknown_http_status}, warning_status => $self->{warning_http_status}, critical_status => $self->{critical_http_status}, cookies_file => '' ); if (!defined($content) || $content eq '') { $self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); $self->{output}->option_exit(); } my $decoded; eval { $decoded = JSON::XS->new->utf8->decode($content); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); $self->{output}->option_exit(); } return $decoded; } 1; __END__ =head1 NAME Spring Boot Actuator Rest API =head1 REST API OPTIONS Spring Boot Actuator Rest API =over 8 =item B<--hostname> Hostname. =item B<--port> Port used (Default: 8080) =item B<--proto> Specify https if needed (Default: 'http') =item B<--api-username> Specify username for authentication (basic auth) =item B<--api-password> Specify password for authentication (basic auth) =item B<--timeout> Set timeout in seconds (Default: 30) =item B<--url-path> API url path (Default: '/actuator') =back =head1 DESCRIPTION B<custom>. =cut
centreon/centreon-plugins
centreon/common/protocols/actuator/custom/standard.pm
Perl
apache-2.0
6,732
#!/usr/bin/perl use strict; use warnings; use Getopt::Long; my $file = ''; my $make_examples = 0; my $make_latex = 0; GetOptions("file=s" => \$file, "make-examples" => \$make_examples, "make-latex" => \$make_latex); my $texfile = "tmp.tex"; my $MARKDOWNSYMBOL = "##"; my $document = do { local $/ = undef; open my $fh, "<", $file or die "could not open $file: $!"; <$fh>; }; #$document =~ s/^\s*\n//mg; my $rest = $document; #print $rest; # get first line my $firstline; #print $firstline; my %stuff; my %explanations; my $name; my %functions; my %examples; my %everything; my @subsections; my $introduction; my $expl; my $current_subsection = "none"; my $k = 0; while ( $rest !~ /^\s*$/s && $k > -1 ) { $k = $k + 1; $firstline = ( split /\n/, $rest )[0]; #print "New firstline:$firstline\n"; if ( $firstline =~ /^\\section/ ) { #print "I found a section\n"; $rest =~ m/\\section[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL\n?(.*)/s; $name = $1; $rest = $2; $name =~ s/\n//mg; #print "content: $name\n"; $stuff{name} = $name; } elsif ( $firstline =~ /^\\introduction/ ) { #print "Found an introduction\n"; $rest =~ m/\\introduction[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL\n?(.*)/s; $introduction = $1; $rest = $2; #$introduction =~ s/\n//mg; #print "context: $introduction\n"; $stuff{introduction} = $introduction; } elsif ( $firstline =~ /^\\subsection/ ) { #print "I found a subsection\n"; $rest =~ m/\\subsection[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL\n?(.*)/s; $name = $1; $expl = $2; $rest = $3; $name =~ s/\n//mg; #print "content: $name\n"; push(@subsections, $name); $current_subsection = $name; $explanations{$name} = $2; $functions{$current_subsection} = []; $examples{$current_subsection} = []; $everything{$current_subsection} = []; } elsif ( $firstline =~ /^\\randombla/ ) { $rest =~ m/\\randombla[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?$)/s; my $bla = $1; $rest = $2; push @{$everything{$current_subsection}}, [ $bla ]; } elsif ( $firstline =~ /^\\function/ ) { ##print "Found a function\n"; #if ($rest !~ m/\\function[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL/) #{ # #print " proper format\n"; #} $rest =~ m/\\function[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?$)/s; my $funname = $1; my $sign = $2; my $targ = $3; my $para = $4; my $desc = $5; $rest = $6; # print "name$funname\n"; # print "sign:$sign\n"; # print "targ:$targ\n"; # print "para:$para\n"; # print "desc:$desc\n"; # print "rest:$rest\n"; push @{$functions{$current_subsection}}, [$funname, $sign, $targ, $para, $desc]; push @{$everything{$current_subsection}}, [$funname, $sign, $targ, $para, $desc]; } elsif ( $firstline =~ /^\\exam/ ) { #print "Found an example"; $rest =~ m/\\exam[\w\n]*$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL(.*?)$MARKDOWNSYMBOL\n?(.*)/s; my $exam = $1; my $prop = $2; $rest = $3; push @{$examples{$current_subsection}}, [$exam, $prop]; push @{$everything{$current_subsection}}, [$exam, $prop]; } $rest =~ s/^\s*\n//mg; #print "restnow:$rest:restend"; #if ( $rest =~ /^\s*$/s ) #{ # print "rest is empty"; #} #print split /\n/, $rest ; # } #for my $sub (@subsections) #{ # print "subsection: $sub\n"; # #my @o = @{$functions{$_}}; # #my $l = @o; # #print $l; # # my @o = @{$everything{$sub}}; # my $l = @o; # #print $l; # print "da: @{$o[1]}\n"; # print_latex(@{$o[1]}); # # #print $#functions{$_}; #} if ($make_latex eq 1) { print "\\begin{document}\n"; print "\\section{$stuff{name}}\n"; print "\\subsection{Introduction}\n"; print "$introduction\n"; for my $sub (@subsections) { print "\\subsection{$sub}\n"; print "$explanations{$sub}"; my @k = @{$everything{$sub}}; my $l = @k; for (my $i =0; $i < $l; $i++) { print_latex(@{$k[$i]}); } } print "\\end{document}\n"; } if ($make_examples eq 1) { print "using hecke;\n"; for my $sub (@subsections) { print "#$sub \n"; my @k = @{$examples{$sub}}; my $l = @k; for (my $i =0; $i < $l; $i++) { my @exam = @{$k[$i]}; my $source = $exam[0]; #print "$source\n"; my @ar = split(/\n/, $source); for my $a (@ar) { if ($a =~ /julia>/) { $a =~ s/[ \t]*julia>//g; $a =~ s/^\s+//g; $a =~ s/ASSERT//g; my $b = $a; $a =~ s/"/\\"/g; print "println(\"julia> $a\")\n"; print "println(eval(parse(\"$a\")))\n"; } } print("\n"); } print("\n"); } } sub print_latex { my $k = @_; if ($k eq 5) { # I have to print a function " print "\\begin{lstlisting}\n"; print "$_[0]($_[1]) -> $_[2]\n"; print "\\end{lstlisting}\n"; print "\\vspace{-1em}\n"; if ( $_[3] !~ /^\s*$/s ) { print "\\vspace{0em}{\\small\\begin{lstlisting}\n"; my @ar = split /;/, $_[3]; for (my $j = 0; $j <= $#ar; $j++) { print " $ar[$j]\n"; } print "\\end{lstlisting}}\n"; } if ( $_[4] !~ /^\s*$/s ) { print "\\desc{"; print "$_[4]}\n"; print "\\vspace{1em}\n"; } # print "\\noindent\\hfil\\rule{0.8\\textwidth}{.4pt}\\hfil"; # print "\\hrulefill\n"; } if ($k eq 2) { # I have to print an example if ( $_[0] !~ /^\s*$/s ) { print "\\begin{center}\\rule{0.5\\textwidth}{.4pt}\\end{center}\n"; print "\\begin{quote}{ \\begin{verbatim}"; $_[0] =~ s/.*ASSERT.*\n//g; print "$_[0]"; print "\\end{verbatim}}\\end{quote}\n"; #print "\\vspace{-0.5em}\n"; print "\\begin{center}\\rule{0.5\\textwidth}{.4pt}\\end{center}\n"; #print "\\vspace{0.5em}\n"; #print "\\hrulefill\n"; } } if ($k eq 1) { # I have to print random bla #print "\\newline n"; print "$_[0]\n"; } }
fredrik-johansson/hecke
doc/doc.pl
Perl
bsd-2-clause
6,255
#!/usr/bin/perl -w # MGEL # Surya Saha 4/22/08 # UCSC table data from http://genome.ucsc.edu/cgi-bin/hgTables?org=Chicken&db=galGal3&hgsid=106560187&hgta_doMainPage=1 # Chicken May 2006 (galGal3) assembly # UCSC table data format # #name chrom strand txStart txEnd # NM_001080714 chr1 + 13751 20858 # NM_001031401 chr1 + 69103 83497 # NM_001031572 chr1 + 411337 412252 # CONVERTS TO # GFF v 2.0 fields are: # <seqname> <source> <feature> <start> <end> <score> <strand> <frame> [attributes] [comments] # chr1 RptSct-1.0.1 repeat_unit 9599047 9599208 606 + . R=825 # chr1 RptSct-1.0.1 repeat_unit 20233020 20233420 2669 + . R=825 # chr1 RptSct-1.0.1 repeat_unit 20233390 20233502 352 + . R=825 # chr1 RptSct-1.0.1 repeat_unit 20233477 20233567 237 + . R=825 # v1: use strict; use warnings; use POSIX; my $ver=1.0; unless (@ARGV == 2){ print "USAGE: $0 <input .ucsc file> <feature>\n"; exit; } my ($ifname,$identifier,$rec,@temp,@table,$tot_recs,$i,$ctr,$user_t,$system_t,$cuser_t,$csystem_t); $ifname=$ARGV[0]; chomp $ifname; unless(open(INFILEDATA,$ifname)){print "not able to open ".$ifname."\n\n";exit;} unless(open(OUTFILEDATA,">$ifname.gff")){print "not able to open $ifname.gff \n\n";exit;} $identifier=$ARGV[1]; chomp $identifier; print OUTFILEDATA "\##gff-version 2\n"; print OUTFILEDATA "\# ver:$ver\n"; #slurping in the whole report file $ctr=0; while($rec=<INFILEDATA>){ if($rec =~ /#/){next;} if(length ($rec) < 10){next;}#for avoiding last line push @table, [split(' ',$rec)]; $ctr++; } # record tot recs $tot_recs = $ctr; print OUTFILEDATA "\# Total records read: $tot_recs\n"; print OUTFILEDATA "\# <seqname> <source> <feature> <start> <end> <score> <strand> <frame> [attributes] [comments]\n"; #@table # NM_001080714 chr1 + 13751 20858 # NM_001031401 chr1 + 69103 83497 # 0 1 2 3 4 # GFF fields are: <seqname> <source> <feature> <start> <end> <score> <strand> <frame> [attributes] [comments] # printing to GFF format foreach $i (@table){ print OUTFILEDATA "$i->[1]\tUCSC-galGal3\t$i->[0]\t$i->[3]\t$i->[4]\t.\t$i->[2]\t.\t$identifier\n"; } #calculating time taken ($user_t,$system_t,$cuser_t,$csystem_t) = times; print OUTFILEDATA "\# Runtime details after printing: \n"; print OUTFILEDATA "\# System time for process: $system_t\n"; #print OUTFILEDATA "\# System time for children: $csystem_t\n"; print OUTFILEDATA "\# User time for process: $user_t\n"; #print OUTFILEDATA "\# User time for children: $cuser_t\n"; print STDERR "Runtime details after printing: \n"; print STDERR "System time for process: $system_t\n"; print STDERR "User time for process: $user_t\n"; close (INFILEDATA); close (OUTFILEDATA); exit;
suryasaha/ProxMiner
scripts/miner.ucsctable2gff.v1.pl
Perl
bsd-2-clause
2,696
#!/usr/bin/perl use IO::Socket; use strict; my($sock, $word, $port, $ipaddr, $hishost, $MAXLEN, $PORTNO, $TIMEOUT); $MAXLEN = 2048; $PORTNO = 6062; $TIMEOUT = 1; $sock = IO::Socket::INET->new(Proto => 'udp', PeerPort => $PORTNO, PeerAddr => 'localhost') or die "Creating socket: $!\n"; #open FILE, "<osszesfonev.txt" or die $!; #open FILE, "<adj/allmn2.txt" or die $!; #open FILE, "<verb/igek2.txt" or die $!; open FILE, "<$ARGV[0]" or die $!; #"</home/en/program/foma/tktest/tools/gyujtes/itek1nincsjo" or die $!; my $word2; while (<FILE>) { chomp; $_ =~ s/^\s+//; #remove leading spaces $_ =~ s/\s+$//; #remove trailing spaces my $word1 = $_; $sock->send("$_") or die "send: $!"; eval { local $SIG{ALRM} = sub { die "time out" }; # local $SIG{ALRM} = sub { die "time out" }; alarm $TIMEOUT; $sock->recv($word2, $MAXLEN) or die "recv: $!"; alarm 0; } or die "localhost timed out after $TIMEOUT seconds.\n"; print "$word1: $word2"; }
r0ller/hunmorph-foma
tools/chkwds/chkwdlistup.pl
Perl
bsd-3-clause
1,049
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # # Provides size breakdown of ACE, TAO, or orbsvcs libs. # # Assumes (or builds) the lib with debug=0. Allows other make args, # such as -j 4, to be passed on the command line. $usage = "$0 [-h, for html output] [-s, for shared libs] [-v] [make arguments]\n"; #### #### Configuration parameters. #### $build_args = 'debug=0 optimize=1 static_libs_only=1 DEFFLAGS=-DACE_USE_RCSID=0'; $ACE_COMPONENTS = 'OS Utils Logging Threads Demux Connection Sockets IPC Svcconf ' . 'Streams Memory Token Other'; $TAO_COMPONENTS = 'POA Pluggable_Protocols Default_Resources Interpretive_Marshaling ' . 'IDL_Compiler ORB_Core Dynamic_Any'; $ORBSVCS_COMPONENTS = 'Naming ImplRepo Time Concurrency Property Trader LifeCycle Sched ' . 'Event CosEvent Event2 AV'; #### The following are only used for VxWorks libraries, and #### only if the corresponding environment variable isn't set. $default_toolenv = '386'; $default_wind_base = '/project/doc/pkg/wind'; $default_host_type = 'sun4-solaris2'; #### Use gmake if it's on the user's PATH, otherwise use make. Use #### sh -c to avoid warning if gmake isn't found. $make = system ("sh -c \"gmake --version\" > /dev/null 2>&1") ? 'make' : 'gmake'; $ACE_ROOT = $ENV{'ACE_ROOT'} || die "$0: ACE_ROOT was not set!\n"; $html = $verbose = 0; $lib_extension = 'a'; #### #### Process command line args. #### while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) { if ($ARGV[0] eq '-h') { $html = 1; chop ($sysname = `uname -s`); chop ($sysrev = `uname -r`); shift; } elsif ($ARGV[0] eq '-s') { $lib_extension = 'so'; $build_args =~ s/ static_libs_only=1//; shift; } elsif ($ARGV[0] eq '-v') { $verbose = 1; shift; } elsif ($ARGV[0] eq '-?') { print "$usage"; exit; } else { #### Pass remaining args to make. } } $make_args = join (' ', @ARGV) . $build_args; chop ($pwd = `pwd`); if ($pwd =~ m%/ace$%) { #### libACE $COMPONENTS = "$ACE_COMPONENTS"; $LIB_COMPONENTS = 'ACE_COMPONENTS'; $libname = 'ACE'; } elsif ($pwd =~ m%/tao$%) { $COMPONENTS = "$TAO_COMPONENTS"; $LIB_COMPONENTS = 'TAO_COMPONENTS'; $libname = 'TAO'; } elsif ($pwd =~ m%/orbsvcs/orbsvcs$%) { $COMPONENTS = "$ORBSVCS_COMPONENTS"; $LIB_COMPONENTS = 'TAO_ORBSVCS'; $libname = 'orbsvcs'; } else { die "$0: unsupported directory; $pwd\n"; } $lib = "lib${libname}.$lib_extension"; #### #### Select the size command based on ACE_ROOT setting. #### if ($ACE_ROOT =~ /vxworks/) { $TOOLENV = $ENV{'TOOLENV'} || $default_toolenv; $WIND_BASE = $ENV{'WIND_BASE'} || $default_wind_base; $WIND_HOST_TYPE = $ENV{'WIND_HOST_TYPE'} || $default_host_type; $size = "$WIND_BASE/host/$WIND_HOST_TYPE/bin/size$TOOLENV"; } elsif ($ACE_ROOT =~ /lynx-ppc/) { $size = '/usr/lynx/3.0.0/ppc/cdk/sunos-xcoff-ppc/bin/size'; } elsif ($ACE_ROOT =~ /lynx/) { $size = '/usr/lynx/3.0.0/x86/cdk/sunos-coff-x86/bin/size'; } elsif ($ACE_ROOT =~ /chorus/) { $size = '/project/doc/mvme/green68k/gnu/bin/size'; } else { $size = 'size'; } #### #### Measure the size of the entire library. #### $sizeTotal = build_lib ("$LIB_COMPONENTS=\"$COMPONENTS\""); $components = " <th>Platform\n <th>Component\n <th>Total"; $componentSize = " <th>Size, bytes\n <td align=center>$sizeTotal"; $componentPercentage = " <th>Percentage of<br>total size\n <td align=center>100"; print "Total $sizeTotal (100)\n" unless $html; #### #### Measure the size of each library component. #### foreach my $i (split (' ', $COMPONENTS)) { $sizeLib = build_lib ("$LIB_COMPONENTS=\"$i\""); $components .= "\n <th>$i"; $componentSize .= "\n <td align=center>$sizeLib"; $thisPercentage = percentage ($sizeLib, $sizeTotal); $componentPercentage .= "\n <td align=center>$thisPercentage"; print "$i $sizeLib ($thisPercentage)\n" unless $html; } #### #### Produce HTML output, if requested. #### if ($html) { print '<center><table cellpadding=4 border=4>' . "\n"; print ' <tr>' . "\n"; print "$echoArgs $components\n"; print ' <tr>' . "\n"; print " <th rowspan=2>$sysname $sysrev $ACE_ROOT\n"; print "$echoArgs $componentSize\n"; print ' <tr>' . "\n"; print "$echoArgs $componentPercentage\n"; print '</table></center><p>' . "\n"; } #### #### Build library with componnents specified in argument. #### sub build_lib () { my ($lib_components) = @_; unlink "$lib"; print "$make $make_args $lib_components\n" if $verbose; system ("$make $make_args $lib_components >> make.log 2>&1") && die "$0: command failed; $make $make_args $lib_components\n"; my $libSize = 0; open (SIZE, "$size $lib |") || die "$0: unable to open $size\n"; while (<SIZE>) { my (@field) = split; $libSize += $field[3] if $field[3] =~ /\d/; #### Skip size header line. } close (SIZE); $libSize; } #### #### Return percentage of first argument as fraction of second. #### Returns a string with two-decimal place precision. #### sub percentage () { my ($size, $total) = @_; sprintf ("%.2f", $size * 100 / $total); }
wfnex/openbras
src/ace/ACE_wrappers/bin/libsize.pl
Perl
bsd-3-clause
5,159
#ExStart:1 use lib 'lib'; use strict; use warnings; use utf8; use File::Slurp; # From CPAN use JSON; use AsposeStorageCloud::StorageApi; use AsposeStorageCloud::ApiClient; use AsposeStorageCloud::Configuration; use AsposeSlidesCloud::SlidesApi; use AsposeSlidesCloud::ApiClient; use AsposeSlidesCloud::Configuration; my $configFile = '../Config/config.json'; my $configPropsText = read_file($configFile); my $configProps = decode_json($configPropsText); my $data_path = '../../../Data/'; my $out_path = $configProps->{'out_folder'}; $AsposeSlidesCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeSlidesCloud::Configuration::api_key = $configProps->{'api_key'}; $AsposeSlidesCloud::Configuration::debug = 1; $AsposeStorageCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeStorageCloud::Configuration::api_key = $configProps->{'api_key'}; # Instantiate Aspose.Storage and Aspose.Slides API SDK my $storageApi = AsposeStorageCloud::StorageApi->new(); my $slidesApi = AsposeSlidesCloud::SlidesApi->new(); # Set input file name my $name = 'sample-input.pptx'; my $slideIndex = 1; my $storage = 'AsposeDropboxStorage'; # Upload file to 3rd party cloud storage my $response = $storageApi->PutCreate(Path => $name, file => $data_path.$name, storage=>$storage); # Invoke Aspose.Slides Cloud SDK API to get PowerPoint document slide list $response = $slidesApi->GetSlidesSlidesList(name => $name, slideIndex=>$slideIndex, storage=>$storage); if($response->{'Status'} eq 'OK'){ print "\n Total Slides :: ". scalar(@{$response->{'Slides'}->{'SlideList'}}); } #ExEnd:1
aspose-slides/Aspose.Slides-for-Cloud
Examples/Perl/Slides/GetSlideCountUsingThirdPartyStorage.pl
Perl
mit
1,634
#!/usr/bin/perl -w # # Copyright (C) 2013 Genome Research Ltd. # # Author: James Bonfield <jkb@sanger.ac.uk> # # 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. # Compares two SAM files to report differences. # Optionally can skip header or ignore specific types of diff. use strict; use Getopt::Long; my %opts; GetOptions(\%opts, 'noqual', 'noaux', 'notemplate', 'unknownrg', 'nomd', 'template-1', 'noflag', 'Baux'); my ($fn1, $fn2) = @ARGV; open(my $fd1, "<", $fn1) || die $!; open(my $fd2, "<", $fn2) || die $!; # Headers my ($c1,$c2)=(1,1); my (@hd1, @hd2, $ln1, $ln2); while (<$fd1>) { if (/^@/) { push(@hd1, $_); } else { $ln1 = $_; last; } $c1++; } while (<$fd2>) { if (/^@/) { push(@hd2, $_); } else { $ln2 = $_; last; } $c2++; } # FIXME: to do #print "@hd1\n"; #print "@hd2\n"; # Compare lines while ($ln1 && $ln2) { chomp($ln1); chomp($ln2); # Java CRAM adds RG:Z:UNKNOWN when the read-group is absent if (exists $opts{unknownrg}) { $ln1 =~ s/\tRG:Z:UNKNOWN//; $ln2 =~ s/\tRG:Z:UNKNOWN//; } if (exists $opts{nomd}) { $ln1 =~ s/\tMD:Z:[A-Z0-9^]*//; $ln2 =~ s/\tMD:Z:[A-Z0-9^]*//; $ln1 =~ s/\tNM:i:\d+//; $ln2 =~ s/\tNM:i:\d+//; } my @ln1 = split("\t", $ln1); my @ln2 = split("\t", $ln2); # Fix BWA bug: unmapped data should have no alignments if ($ln1[1] & 4) { $ln1[4] = 0; $ln1[5] = "*"; } if ($ln2[1] & 4) { $ln2[4] = 0; $ln2[5] = "*"; } # Canonicalise floating point numbers map {s/^(..):f:(.*)/{"$1:f:".($2+0)}/e} @ln1[11..$#ln1]; map {s/^(..):f:(.*)/{"$1:f:".($2+0)}/e} @ln2[11..$#ln2]; if (exists $opts{Baux}) { # Turn ??:H:<hex> into ??:B:c,<vals> so we can compare # Cramtools.jar vs htslib encodings. Probably doable with (un)pack map {s/^(..):H:(.*)/{join(",", "$1:B:C", map {hex $_} $2=~m:..:g)}/e} @ln1[11..$#ln1]; map {s/^(..):H:(.*)/{join(",", "$1:B:C", map {hex $_} $2=~m:..:g)}/e} @ln2[11..$#ln2]; # Canonicalise ??:B:? data series to be unsigned map {s/^(..):B:c(,?)(.*)/{"$1:B:C$2".join(",",map {($_+256)&255} split(",",$3))}/e} @ln1[11..$#ln1]; map {s/^(..):B:c(,?)(.*)/{"$1:B:C$2".join(",",map {($_+256)&255} split(",",$3))}/e} @ln2[11..$#ln2]; map {s/^(..):B:s(,?)(.*)/{"$1:B:S$2".join(",",map {($_+65536)&65535} split(",",$3))}/e} @ln1[11..$#ln1]; map {s/^(..):B:s(,?)(.*)/{"$1:B:S$2".join(",",map {($_+65536)&65535} split(",",$3))}/e} @ln2[11..$#ln2]; map {s/^(..):B:i(,?)(.*)/{"$1:B:I$2".join(",",map {$_<0? ($_+4294967296) : $_} split(",",$3))}/e} @ln1[11..$#ln1]; map {s/^(..):B:i(,?)(.*)/{"$1:B:I$2".join(",",map {$_<0? ($_+4294967296) : $_} split(",",$3))}/e} @ln2[11..$#ln2]; } # Rationalise order of auxiliary fields if (exists $opts{noaux}) { @ln1 = @ln1[0..10]; @ln2 = @ln2[0..10]; } else { #my @a=@ln1[11..$#ln1];print "<<<@a>>>\n"; @ln1[11..$#ln1] = sort @ln1[11..$#ln1]; @ln2[11..$#ln2] = sort @ln2[11..$#ln2]; } if (exists $opts{noqual}) { $ln1[10] = "*"; $ln2[10] = "*"; } if (exists $opts{notemplate}) { @ln1[6..8] = qw/* 0 0/; @ln2[6..8] = qw/* 0 0/; } if (exists $opts{noflag}) { $ln1[1] = 0; $ln2[1] = 0; } if (exists $opts{'template-1'}) { if (abs($ln1[8] - $ln2[8]) == 1) { $ln1[8] = $ln2[8]; } } # Cram doesn't uppercase the reference $ln1[9] = uc($ln1[9]); $ln2[9] = uc($ln2[9]); # Cram will populate a sequence string that starts as "*" $ln2[9] = "*" if ($ln1[9] eq "*"); # Fix 0<op> cigar fields $ln1[5] =~ s/(\D|^)0\D/$1/g; $ln1[5] =~ s/^$/*/g; $ln2[5] =~ s/(\D|^)0\D/$1/g; $ln2[5] =~ s/^$/*/g; # Fix 10M10M cigar to 20M $ln1[5] =~ s/(\d+)(\D)(\d+)(\2)/$1+$3.$2/e; $ln2[5] =~ s/(\d+)(\D)(\d+)(\2)/$1+$3.$2/e; if ("@ln1" ne "@ln2") { print "Diff at lines $fn1:$c1, $fn2:$c2\n"; my @s1 = split("","@ln1"); my @s2 = split("","@ln2"); my $ptr = ""; for (my $i=0; $i < $#s1; $i++) { if ($s1[$i] eq $s2[$i]) { $ptr .= "-"; } else { last; } } print "1\t@ln1\n2\t@ln2\n\t$ptr^\n\n"; exit(1); } $ln1 = <$fd1>; $ln2 = <$fd2>; $c1++; $c2++; } if (defined($ln1)) { print "EOF on $fn1\n"; exit(1); } if (defined($ln2)) { print "EOF on $fn2\n"; exit(1); } close($fd1); close($fd2); exit(0);
SummerSchoolVN/SV_Materials
lib/samtools/htslib-1.5/test/compare_sam.pl
Perl
mit
5,641
/* ***************hyhtn8.pl *****************************/ /* 30 June 2003 */ /* HyHTN planning: do preprocess first */ /* make all method and operators primitive */ /* derived from hyhtn4, do forward graphplan heuristic */ /* add one level to achieve all initial states */ /********************************************************/ :-use_module(library(system)). /*********************** initialisation**************/ :- dynamic op_num/1, my_stats/1. :- dynamic node/7,final_node/1. :- dynamic methodC/7, opParent/6,operatorC/5,gOperator/3. :- dynamic tp_goal/3,tp_node/6,closed_node/6,solved_node/5. :- dynamic goal_related/4,goal_related_search/1. :- dynamic tn/6. % Used to store full expanded steps :- dynamic opCounter/1,temp/1. % Used for grounding operators :- dynamic objectsC/2,atomic_invariantsC/1.% Used only dynamic objects :- dynamic objectsOfSort/2,is_of_sort/2,is_of_primitive_sort/2. % Used to store all objects of a sort :- dynamic is_hierarchy/1. % the domain is hierarchy or not :- dynamic odds_in_subset_substates/3. %save the substates have subsets :- dynamic max_length/1,lowest_score/1. :- unknown(error,fail). % for boot.. :- dynamic kill_file/1,solution_file/1. solution_file('freds.pl'). % :- prolog_flag(single_var_warnings, _, off). %:-set_prolog_flag(unknown,fail). :- op(100,xfy,'=>'). op_num(0). my_stats(0). solve(Id) :- htn_task(Id,Goal,Init), planner_interface(Goal,Init,Sol,_,TNLst), solution_file(F), tell(F), write('TASK '),write(Id),nl, write('SOLUTION'),nl, display_sol(Sol), write('END FILE'),nl,nl, reverse(TNLst,TNForward), display_details(TNForward), write('END PLANNER RESULT'), told, tell(user), write('TASK '),write(Id),nl, write('SOLUTION'),nl, display_sol(Sol), write('END FILE'),nl,nl, clean. solve(Id) :- planner_task(Id,Goal,Init), planner_interface(Goal,Init,Sol,_,TNLst), solution_file(F), tell(F), write('TASK '),write(Id),nl, write('SOLUTION'),nl, display_sol(Sol), write('END FILE'),nl,nl, reverse(TNLst,TNForward), display_details(TNForward), write('END PLANNER RESULT'), told, tell(user), write('TASK '),write(Id),nl, write('SOLUTION'),nl, display_sol(Sol), write('END FILE'),nl,nl, clean. display_sol([]). display_sol([H|T]) :- write(H), nl, display_sol(T). display_details([]). display_details([tn(TN,Name,Pre,Post,Temp,Dec)|Rest]) :- % write('method::Description:'),write(';'), nl,write('BEGIN METHOD'),nl,write(TN),write(';'), nl,write('Name:'),write(Name),write(';'), nl,write('Pre-condition:'),write(Pre),write(';'), % write('Index Transitions:'),write(Pre),write('=>'),write(Post1),write(';'), % write('Static:'),write(';'), nl,write('Temporal Constraints:'),write(Temp),write(';'), nl,write('Decomposition:'),write(Dec),write(';'), nl, display_details(Rest). reverse(L,RL) :- revSlave(L,[],RL). revSlave([],RL,RL). revSlave([H|T],Sofar,Final) :- revSlave(T,[H|Sofar],Final). clean:- retractall(op_num(_)), retractall(my_stats(_)), retractall(current_num(_,_)), retractall(final_node(_)), retractall(node(_,_,_,_,_)), retractall(tn(_,_,_,_,_,_)), retractall(methodC(_,_,_,_,_,_,_)), retractall(operatorC(_,_,_,_,_)), retractall(gOperator(_,_,_)), retractall(opCounter(_)), retractall(opParent(_,_,_,_,_,_)), retractall(temp(_)), retractall(objectsOfSort(_,_)), retractall(related_op(_)), retractall(op_score(_,_)), retractall(objectsC(_,_)), retractall(goal_related(_,_,_,_)), retractall(goal_related_search(_)), retractall(solved_node(_,_)), retractall(tp_node(_,_,_,_,_,_)), retractall(closed_node(_,_,_,_,_,_)), retractall(is_hierarchy(_)), retractall(lowest_score(_)), retractall(max_length(_)), retractall(atomic_invariantsC(_)), retractall(is_of_sort(_,_)), retractall(is_of_primitive_sort(_,_)), retractall(objectsD(_,_)), retractall(odds_in_subset_substates(_,_,_)), assert(op_num(0)), assert(my_stats(0)). planner_interface(G,I, SOLN,OPNUM,TNList):- change_obj_list(I), ground_op, assert_is_of_sort, change_op_representation, check_for_substates, check_if_hierarchy, retract(op_num(_)), assert(op_num(0)), statistics(runtime,[_,Time]), (retract(my_stats(_)) ; true), assert(my_stats(Time)), make_problem_into_node(I, G, Node), assert(Node), start_solve(SOLN,OPNUM,TNList). planner_interface(G,I, SOLN,OPNUM,TNList):- tell(user),nl,write('failure in initial node'),!. /******************** Nodes *******************/ % node(Name, Precond ,Decomps, Temp, Statics) % Initial Node: node(root, Init, Decomps, Temp, Statics) getN_name(node(Name, _, _, _,_), Name). getN_pre(node(_,Pre, _, _, _), Pre). getN_decomp(node(_, _, Decomp,_,_), Decomp). getH_temp(node(_, _, _,Temps, _), Temps). getN_statics(node(_,_,_,_,Statics), Statics). %Ron 21/9/01 - Try to give a closedown method start_solve(SOLN,OPNUM,_):- kill_file(Kill), file_exists(Kill). % write('Found kill file'),nl. start_solve(Sol,OPNUM,TNList):- retract(final_node(Node)), retractall(current_num(_,_)), getN_statics(Node,Statics), statics_consist(Statics), extract_solution(Node,Sol,SIZE,TNList), statistics(runtime,[_,CP]), TIM is CP/1000, tell(user), retract(op_num(OPNUM)), assert(op_num(0)), nl, nl, write('CPU Time = '),write(CP),nl, write('TIME TAKEN = '),write(TIM), write(' SECONDS'),nl, write('Solution SIZE = '),write(SIZE),nl, write('Operator Used = '),write(OPNUM),nl, write('***************************************'), assert(time_taken(CP)), assert(soln_size(SIZE)), retractall(tn(_,_,_,_,_,_)),!. start_solve(Sol,OPNUM,TNList):- select_node(Node), % nl,write('processing '),write(Node),nl, % expand/prove its hps process_node(Node), start_solve(Sol,OPNUM,TNList). start_solve(Sol,OPNUM,TNList):- tell(user), write('+++ task FAILED +++'), clean. /******************************** MAIN LOOP **********/ % expand a node.. process_node(Node) :- getN_name(Node, Name), getN_pre(Node, Pre), getN_decomp(Node, Dec), getH_temp(Node, Temps), getN_statics(Node, Statics), expand_decomp(Dec,Pre,Post,Temps,Temp1,Statics,Statics1,Dec1), statics_consist(Statics), assert_node(Name,Pre,Dec1,Temp1,Statics1). assert_node(Name,Pre,Decomp,Temp,Statics):- all_HP_expanded(Decomp), assert(final_node(node(Name,Pre,Decomp,Temp,Statics))),!. assert_node(Name,Pre,Dec,Temp,Statics):- gensym(root,SYM), assert(node(SYM,Pre,Dec,Temp,Statics)),!. all_HP_expanded([]):-!. all_HP_expanded([step(HPid,Name,_,_,exp(TN))|THPS]):- all_HP_expanded(THPS),!. /************ expand every step in Dec *********************/ % expand_decomp(Dec,Pre,Post,Temps,Temp1,Statics,Statics1,Dec1) % Pre is the ground states before the action % Post is the ground states after the action % starts from Initial states to final ground states % 0. end, Post is the final ground states expand_decomp([],Post,Post,Temp,Temp,Statics,Statics,[]):-!. % 1. if the step has expand already, get the state change, go to next expand_decomp([step(HPid,Name,Pre,Post0,exp(TN))|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,Name,Pre,Post0,exp(TN))|Decomp1]):- % state_achieved(Pre0,Pre), % state_change(Pre,Pre0,Post0,State), statics_consist(Statics), expand_decomp(Decomp,Post0,Post,Temp,Temp1,Statics,Statics1,Decomp1),!. % 2. if it is an achieve goal expand_decomp([step(HPid,ACH,Pre0,Post0,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,Decomp1):- ACH=..[achieve|_], statics_consist(Statics), expand_decomp_ach([step(HPid,ACH,Pre,Post0,unexp)|Decomp],Pre,Post, Temp,Temp1,Statics,Statics1,Decomp1),!. % 3. if HP's name and it's Pre meet an operator, return operator's name expand_decomp([step(HPid,Name,undefd,undefd,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,Name,Pre,State,exp(Name))|Decomp1]):- apply_op(Name,HPid,Name,Pre,undefd,State,Statics,Statics2), expand_decomp(Decomp,State,Post,Temp,Temp1,Statics2,Statics1,Decomp1),!. % 1. it's matches name apply_op(Name,HPid,Name,Pre,Post,State,Statics,Statics1):- operatorC(Name,Pre0,Post0,Cond,Statics0), statics_append(Statics0,Statics,Statics2), % remove_unneed(Statics2,[],Statics1), post_instant(Post0,Cond,Statics2,Post), state_achieved(Pre0,Pre,Statics2), state_change(Pre,Pre0,Post0,State2), cond_state_change(State2,Cond,State), post_achieved(Post,State,Statics2), remove_unneed(Statics2,[],Statics1), statics_consist_instance(Statics0), % nl,write('step '),write(HPid), % write('can be expand by operator '),write(Name),nl, retract(op_num(N)), N1 is N+1, assert(op_num(N1)),!. % 4. if HP's name meet an method, and it's precondition achieved % expand it and make it to that TNs % the method can be achieved directly(without doing fwsearch). expand_decomp([step(HPid,Name,undefd,undefd,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,Name,Pre,State,exp(TN))|Decomp1]):- apply_method(TN,HPid,Name,Pre,undefd,State,Statics,Statics2), expand_decomp(Decomp,State,Post,Temp,Temp1,Statics2,Statics1,Decomp1),!. apply_method(TN,HPid,Name,Pre,Post,State,Statics,Statics1):- methodC(Name,Pre0,Post0,Statics0,Temp0,achieve(ACH0),Dec0), append_st(Statics0,Statics,Statics2), all_achieved(Pre0,Statics2,Pre), % rough_state_change(Pre,Pre0,Post0,State2),%State2 just for check if the % may_achieved(Post,Statics2,State2),%method can directly apply or not % remove_unneed(Statics2,[],Statics21), make_dec1(HPid,Pre,ACH0,Statics2,Temp0,Dec0,Temp2,Dec2), expand_decomp(Dec2,Pre,State,Temp2,Temp1,Statics2,Statics1,Dec1), post_achieved(Post,State,Statics1), % nl,write('step '),write(HPid), % write('can be expand by method '),write(Name),nl, retract(op_num(N)), N1 is N+1, assert(op_num(N1)), make_tn(TN,Name,Pre,State,Temp1,Dec1),!. % 5. if HP's name meet an method, and it's precondition achieved % expand it by add forward search, % and make it to that TNs expand_decomp([step(HPid,Name,undefd,undefd,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,Name,Pre,State,exp(TN))|Decomp1]):- apply_method_undir(TN,HPid,Name,Pre,undefd,State,Statics,Statics2), expand_decomp(Decomp,State,Post,Temp,Temp1,Statics2,Statics1,Decomp1),!. % if failed, fwsearch. apply_method_undir(TN,HPid,Name,Pre,Post,State,Statics,Statics1):- methodC(Name,Pre0,Post0,Statics0,Temp0,achieve(ACH0),Dec0), append_st(Statics0,Statics,Statics2), all_achieved(Pre0,Statics2,Pre), % rough_state_change(Pre,Pre0,Post0,State2),%State2 just for check if the % may_achieved(Post,Statics2,State2),%method can directly apply or not % remove_unneed(Statics2,[],Statics21), make_dec2(HPid,Pre,ACH0,Statics2,Temp0,Dec0,Temp2,Dec2), expand_decomp(Dec2,Pre,State,Temp2,Temp1,Statics2,Statics1,Dec1), post_achieved(Post,State,Statics1), % nl,write('step '),write(HPid), % write('can be expand by method '),write(Name),nl, retract(op_num(N)), N1 is N+1, assert(op_num(N1)), make_tn(TN,Name,Pre,State,Temp1,Dec1),!. % 6. get another step which matchs and not after it before it to give a try expand_decomp([step(HP,N,Pre0,Post0,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,Decomp1):- get_another_step(step(HP2,N2,Pre2,Post2,Exp),Pre,Statics, HP,Temp,Temp2,Decomp,Decomp2), expand_decomp([step(HP2,N2,Pre2,Post2,Exp),step(HP,N,Pre0,Post0,unexp)|Decomp2], Pre,Post,Temp2,Temp1,Statics,Statics1,Decomp1). % 7. all failed, expanding failed /************ end of expand_decomp *********************/ % get another step which is not after it before it get_another_step(A,Pre,Statics,HP,Temp,Temp1,[],Dec2):-fail. get_another_step(step(HP2,Name2,Pre2,Post2,Exp),Pre,Statics,HP,Temp,[before(HP2,HP)|Temp],Dec,Dec2):- member(step(HP2,Name2,Pre2,Post2,Exp),Dec), not(necessarily_before(HP,HP2, Temp)), state_achieved(Pre2,Pre,Statics), list_take(Dec,[step(HP2,Name2,Pre2,Post2,Exp)],Dec2). % ***********expand the achieve goal*********** % 1.if the ACH is achieved already % remove it from decomposion and do the next expand_decomp_ach([step(HPid,ACH,Pre0,Post0,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,Decomp1):- state_achieved(Post0,Pre), % nl,write('step '),write(HPid), % write('is already achieved'),nl, remove_temp(Temp,HPid,Temp,Temp2), expand_decomp(Decomp,Pre,Post,Temp2,Temp1,Statics,Statics1,Decomp1),!. % 2.do expanding achieve goal expand_decomp_ach([step(HPid,ACH,Pre,Post0,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,ACH,Pre,Post0,exp(TN))|Decomp1]):- expand_ach_goal(HPid,TN,ACH,Pre,Post0,State,Statics,Statics2), expand_decomp(Decomp,State,Post,Temp,Temp1,Statics2,Statics1,Decomp1),!. % 3. get another step which matchs and not after it before it to give a try expand_decomp_ach([step(HPid,ACH,Pre,Post0,unexp)|Decomp],Pre,Post,Temp,Temp1,Statics,Statics1,[step(HPid,ACH,Pre,Post0,exp(TN))|Decomp1]):- get_another_step(step(HP2,N2,Pre2,Post2,Exp),Pre,Statics, HP,Temp,Temp2,Decomp,Decomp2), expand_decomp([step(HP2,N2,Pre2,Post2,Exp),step(HPid,ACH,Pre,Post0,unexp)|Decomp2], Pre,Post,Temp2,Temp1,Statics,Statics1,Decomp1). % 4. all failed, expanding failed /************ end of expand_decomp_ach *********************/ %************ expand an achive goal *********************/ % 1. directly achieve goal's Pre and Post by operator,method or tn expand_ach_goal(HPid,TN,ACH,Pre,Post,State,Statics,Statics1):- direct_expand_ach_goal(HPid,TN,ACH,Pre,Post,State,Statics,Statics1),!. % 2. else, nothing directly can achieve HP's Pre and Post % assert a temporely node for forward search % tp_node(Name, Precond, Postcond, Statics,Score,Temp,Decomps) % take out the already achieved states first before expanding expand_ach_goal(HPid,TN,ACH,Pre,Post,State,Statics,Statics1):- make_tpnodes(Pre,Post,Statics), % statistics(runtime,[_,CP]), % TIM is CP/1000, % nl, write('preprosses time CPU= '),write(CP),nl, % write('preprosses time taken = '),write(TIM), % nl,write('start fwsearch'),nl, fwsearch(TN,State), clean_temp_nodes. % 3. else, fail expand /************ end of expand_ach_goal *********************/ % -------direct expand an achieve goal----------------------- %1. if an achieve action meets an TN Pre and post meet direct_expand_ach_goal(HPid,TN,ACH,Pre,Post,State,Statics,Statics):- apply_tn(TN,HPid,ACH,Pre,Post,State,Statics,Statics). %2. if an action's action meets an operator Pre and post direct_expand_ach_goal(HPid,OP,ACH,Pre,Post,State,Statics,Statics1):- dir_apply_op(OP,HPid,ACH,Pre,Post,State,Statics,Statics1). %3. if an achieve action meets a method's pre and post, % expand it and make it to that TNs direct_expand_ach_goal(HPid,TN,ACH,Pre,Post,State,Statics,Statics1):- dir_apply_method(TN,HPid,ACH,Pre,Post,State,Statics,Statics1),!. %4. else, fail for direct expand an achieve goal------ % apply an TN to an achieve goal that matches both pre and post conditions apply_tn(Tn0,HPid,ACH,Pre,Post,State,Statics,Statics):- tn(Tn0,Name,Pre0,Post0,Temp0,Decomp0), state_achieved(Pre0,Pre), state_change(Pre,Pre0,Post0,State), post_achieved(Post,State,Statics), % nl,write('step '),write(HPid), retract(op_num(N)), N1 is N+1, assert(op_num(N1)),!. % write('can be expand by tn '),write(Tn0),nl,!. % directly apply an operator % only when it's Pre and Post matches currect state and goal dir_apply_op(Name,HPid,ACH,Pre,Post,State,Statics,Statics1):- % ACH=..[achieve|Rest], operatorC(Name,Pre0,Post0,Cond,Statics0), state_related(Post0,Cond,Post), state_achieved(Pre0,Pre), statics_append(Statics0,Statics,Statics2), % post_instant(Post0,Cond,Statics2,Post), state_change(Pre,Pre0,Post0,State2), cond_state_change(State2,Cond,State), post_achieved(Post,State,Statics2), remove_unneed(Statics2,[],Statics1), statics_consist(Statics1), % nl,write('step '),write(HPid), % write('can be expand by operator '),write(Name),nl, retract(op_num(N)), N1 is N+1, assert(op_num(N1)),!. % apply an method,only Pre and Post condition matchs dir_apply_method(TN,HPid,ACH,Pre,Post,State,Statics,Statics1):- % ACH=..[achieve|Rest], methodC(Name,Pre0,Post0,Statics0,Temp0,achieve(ACH0),Dec0), append_st(Statics0,Statics,Statics2), % all_achieved(Pre0,Statics2,Pre), state_related(Post0,Post), post_instant(Post0,[],Statics2,Post), rough_state_change(Pre,Pre0,Post0,State2), may_achieved(Post,Statics2,State2), remove_unneed(Statics2,[],Statics21), make_dec1(HPid,Pre,ACH0,Statics21,Temp0,Dec0,Temp2,Dec2), expand_decomp(Dec2,Pre,State,Temp2,Temp1,Statics21,Statics1,Dec1), post_achieved(Post,State,Statics1), % nl,write('step '),write(HPid), % write('can be expand by method '),write(Name),nl, retract(op_num(N)), N1 is N+1, assert(op_num(N1)), make_tn(TN,Name,Pre,State,Temp1,Dec1),!. % make decomposition steps when expand a method directly make_dec1(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1):- var(HPid), gensym(hp,HPid), make_dec1(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1),!. make_dec1(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1):- all_achieved(ACH,Statics,Pre), make_dec01(HPid,1,Dec,Dec1), change_temp(HPid,Temp,[],Temp1),!. make_dec1(HPid,Pre,ACH,Statics,Temp,Dec,[before(STID0,STID1)|Temp1],[step(STID0,OP,Pre,Post,exp(OP))|Dec1]):- gensym_num(HPid,0,STID0), gensym_num(HPid,1,STID1), dir_apply_op(OP,STID0,ACH,Pre,ACH,Post,Statics,_), make_dec01(HPid,1,Dec,Dec1), change_temp(HPid,Temp,[],Temp1),!. % make decomposition steps when need fwsearch to expand a method make_dec2(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1):- var(HPid), gensym(hp,HPid), make_dec2(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1),!. make_dec2(HPid,Pre,ACH,Statics,Temp,Dec,Temp1,Dec1):- all_achieved(ACH,Statics,Pre), make_dec01(HPid,1,Dec,Dec1), change_temp(HPid,Temp,[],Temp1),!. make_dec2(HPid,Pre,ACH,Statics,Temp,Dec,[before(STID0,STID1)|Temp1],[step(STID0,achieve(ACH),Pre,ACH,unexp)|Dec1]):- gensym_num(HPid,0,STID0), gensym_num(HPid,1,STID1), make_dec01(HPid,1,Dec,Dec1), % dir_apply_op(OP,STID0,ACH,Pre,ACH,Post,Statics,_), change_temp(HPid,Temp,[],Temp1),!. make_dec01(HPid,_,[],[]):-!. make_dec01(HPid,Num,[HDec|TDec],[step(STID,HDec,undefd,undefd,unexp)|TDec0]):- operatorC(HDec,_,_,_,_), gensym_num(HPid,Num,STID), Num1 is Num + 1, make_dec01(HPid,Num1,TDec,TDec0). make_dec01(HPid,Num,[HDec|TDec],[step(STID,HDec,undefd,undefd,unexp)|TDec0]):- methodC(HDec,_,_,_,_,_,_), gensym_num(HPid,Num,STID), Num1 is Num + 1, make_dec01(HPid,Num1,TDec,TDec0). change_temp(HPid,[],Temp2,Temp2):-!. change_temp(HPid,[before(N1,N2)|Temp],Temp2,[before(ST1,ST2)|Temp0]):- gensym_num(HPid,N1,ST1), gensym_num(HPid,N2,ST2), change_temp(HPid,Temp,Temp2,Temp0),!. % ----------------forward searching-------------- % make tp_node(TPID, Pre,Statics,from(Parent),Score,Steps) make_tpnodes(Pre,Post, Statics):- opCounter(Num), Num>=1000, retractall(tp_goal(_,_,_)), retractall(related_op(_,_)), retractall(lowest_score(_)), assert(tp_goal(Pre,Post,Statics)), assert(lowest_score(0)), assert(tp_node(init,Pre,Statics,from(init),0,[])),!. make_tpnodes(Pre,Post, Statics):- retractall(tp_goal(_,_,_)), retractall(related_op(_,_)), retractall(lowest_score(_)), retractall(max_length(_)), assert(tp_goal(Pre,Post,Statics)), assert_goal_related_init(Pre,Post,Statics), assert(lowest_score(0)), find_all_related_goals(Post,Statics,1,N), % find_all_related_op, assert(tp_node(init,Pre,Statics,from(init),0,[])),!. %tp_node(TP,Pre,Statics,from(Parent),Score,Steps) % forward search for operators can't directly solved fwsearch(TN,State):- retract(solved_node(_,step(HP,Name,Pre,State,exp(TN)))). fwsearch(TN,State):- select_tnode(tp_node(TP,Pre,Statics,from(PR),Score,Steps)), assert(closed_node(TP,Pre,Statics,from(PR),Score,Steps)), expand_node(TP,OP,Statics,Statics1,Pre,Post,from(PR),Steps,Steps1), assert_tnode(TP,OP,PR,Score1,Post,Statics1,Steps1), solved_node(_,_),%expand every possible way until find solution fwsearch(TN,State). fwsearch(TN,State):- tp_node(_,_,_,_,_,_), fwsearch(TN,State). clean_temp_nodes:- retractall(tp_goal(_,_)), retractall(goal_related(_,_,_,_)), retractall(goal_related_search(_)), retractall(related_op(_)), retractall(op_score(_,_)), retractall(score_list(_)), retractall(solved_node(_,_)), retractall(current_num(tp,_)), retractall(tp_node(_,_,_,_,_,_)), retractall(closed_node(_,_,_,_,_,_)),!. % expand all way possible to achieve the Post % if Post is achieved by Pre, finish expand_node(TP,done,Statics,Statics,Pre,Pre,from(PR),List,List):- tp_goal(_,Goal,_), make_se_primitive(Goal,PGoal), post_achieved(PGoal,Pre,Statics),!.%post is uncomplet ss,so just see it % can achieved Pre or not expand_node(TP,TN,Statics,Statics1,Pre,State,from(PR),List,List1):- expand_node1(TN,Statics,Statics1,Pre,State,from(PR),List,List1). % check the Post can be solved by direct expand (Operator or Method) expand_node1(TN,Statics,Statics1,Pre,State,from(PR),List,List1):- tp_goal(_,Goal,_), make_se_primitive(Goal,PGoal), direct_expand(HP,TN,achieve(PGoal),Pre,PGoal,State,Statics,Statics1), % gensym(hp,HP), append(List,[step(HP,achieve(PGoal),Pre,State,exp(TN))],List1),!. % -------direct expand ----------------------- % if the goal canbe achieved by a method's pre and post, % expand it and make it to that TNs direct_expand(HPid,TN,ACH,Pre,Post,State,Statics,Statics1):- dir_apply_method(TN,HPid,ACH,Pre,Post,State,Statics,Statics1),!. % search forwards use ground operators only expand_node1(ID,Statics,Statics,Pre,State,from(PR),List,List1):- find_related_op(Pre,[],OPls), member(ID,OPls), gOperator(ID,_,OP), apply_ground_op(OP,Pre,State,List,List1). expand_node1(OP,Statics,Statics1,Pre,State,from(PR),List,List1):- not(goal_related(_,_,_,_)), operatorC(OP,Pre0,Post0,Cond,ST), apply_unground_op(OP,Pre0,Post0,Cond,ST,Statics,Statics1,Pre,State,List,List1). apply_ground_op(operator(OP,Prev,Nec,Cond),Pre,State,List,List1):- state_achieved(Prev,Pre), nec_state_change(Pre,Nec,State2), cond_state_change(State2,Cond,State), gensym(hp,HP), append(List,[step(HP,OP,Pre,State,exp(OP))],List1), retract(op_num(N)), N1 is N+1, assert(op_num(N1)),!. apply_unground_op(OP,Pre0,Post0,Cond,ST,Statics,Statics1,Pre,State,List,List1):- append_cut(ST,Statics,Statics2), state_achieved(Pre0,Pre,Statics2), state_change(Pre,Pre0,Post0,State2), cond_state_change(State2,Cond,State), statics_consist_instance(ST), remove_unneed(Statics2,[],Statics1), gensym(hp,HP), append(List,[step(HP,OP,Pre,State,exp(OP))],List1), retract(op_num(N)), N1 is N+1, assert(op_num(N1)). find_related_op([],Ops1,Ops):- remove_dup(Ops1,[],Ops),!. find_related_op([Head|Pre],List,Ops):- setof(OPls,Head^Level^Post^goal_related(Head,Post,OPls,Level),OPs0), flatten(OPs0,[],OPs1), append(List,OPs1,List1), find_related_op(Pre,List1,Ops),!. find_related_op([Head|Pre],List,Ops):- find_related_op(Pre,List,Ops),!. % select a tp_node with lowest score select_tnode(tp_node(TPid,Pre,Statics,Parents,Score,Dec)) :- lowest_score(Score), retract(tp_node(TPid,Pre,Statics,Parents,Score,Dec)), update_lowest_score(Score),!. % find the lowest_score of tp_node update_lowest_score(Score):- tp_node(HPid,Pre,Statics,Parents,Score,Dec),!. update_lowest_score(Score):- tp_node(HPid,Pre,Statics,Parents,Score0,Dec), Score1 is Score+1, update_lowest_score1(Score1),!. % if there isn't any tp_node, set lowest score maximal update_lowest_score(Score):- retract(lowest_score(_)), assert(lowest_score(10000)),!. update_lowest_score1(Score):- tp_node(HPid,Pre,Statics,Parents,Score,Dec), retract(lowest_score(_)), assert(lowest_score(Score)),!. update_lowest_score1(Score):- Score1 is Score+1, update_lowest_score1(Score1),!. % assert assert_tnode(TP,OP,PR,Score,Post,Statics1,Steps1), % if goal achieved, assert solved_node assert_tnode(TP,OP,PR,Score,Post,Statics,[]):-!. assert_tnode(TP,OP,PR,Score,Post,Statics,Steps):- tp_goal(Pre,Goal,Statics1), post_achieved(Goal,Post,Statics), combine_exp_steps(Post,Steps,OneStep), % write('solved_node '),write(OneStep),nl, assert(solved_node(Statics,OneStep)),!. assert_tnode(TP,OP,PR,Score,Post,Statics,Steps):- existing_node(Post,Statics),!. assert_tnode(TP,OP,PR,Score,Post,Statics,Steps):- get_score(PR,Post,Steps,Score), % op_score(OP,SS), % Score is Score1-SS, gensym(tp,TP1), % write(TP1),nl, % write(Steps),nl, % write(TP1),write(' '),write(Post), % write('from '),write(TP), % write(' '),write(Score),nl, % write(Steps),nl, update_low_score(Score), assert(tp_node(TP1,Post,Statics,from(TP),Score,Steps)),!. % if current score small than lowest_score, update it update_low_score(Score):- lowest_score(LS), LS>Score, retract(lowest_score(LS)), assert(lowest_score(Score)),!. update_low_score(Score):-!. combine_exp_steps(Post,Steps,step(HP,achieve(Goal),Pre,Post,exp(TN))):- tp_goal(Pre,Goal,Statics), get_action_list(Steps,[],ACTls), make_temp(ACTls,[],Temp), gensym(hp,HP), make_tn(TN,achieve(Goal),Pre,Post,Temp,Steps),!. % get the temperal from an ordered steps get_action_list([],ACTls,ACTls):-!. get_action_list([step(HP,_,_,_,_)|Steps],List,ACTls):- append_cut(List,[HP],List1), get_action_list(Steps,List1,ACTls),!. make_temp([HP|[]],Temp,Temp):-!. make_temp([HP1|[HP2|Rest]],List,Temp):- append_cut(List,[before(HP1,HP2)],List1), make_temp([HP2|Rest],List,Temp),!. existing_node(Post,Statics):- tp_node(_,Post,_,_,_,_). existing_node(Post,Statics):- closed_node(_,Post,_,_,_,_). %jun 20 start from beginning assert_goal_related_init([],Post,Statics):-!. %assert_goal_related_init(Pre,[se(Sort,Obj,SE)|Post],Statics):- % state_achieved([se(Sort,Obj,SE)],Pre,Statics),!. assert_goal_related_init([se(Sort,Obj,SE)|Pre],Post,Statics):- find_related_goal_init(se(Sort,Obj,SE)), assert_goal_related_init(Pre,Post,Statics),!. find_related_goal_init(se(Sort,Obj,SE)):- gOperator(OPID,ID,operator(Name,Prev,Nec,Cond)), % no need check Prev, become it doen't change states find_related_goal_nec_init(se(Sort,Obj,SE),OPID,Name,Nec), % do cond after nec successed find_related_goal_cond_init(se(Sort,Obj,SE),OPID,Name,Cond), fail. find_related_goal_init(se(Sort,Obj,SE)):- not(goal_related(se(Sort,Obj,_),_,_,_)), assert(goal_related(se(Sort,Obj,SE),se(Sort,Obj,SE),[],0)). find_related_goal_init(se(Sort,Obj,SE)). % no backtract for ground nec find_related_goal_nec_init(se(Sort,Obj,SE),ID,Name,[]):-!. find_related_goal_nec_init(se(Sort,Obj,SE),ID,Name,[sc(Sort,Obj,LHS=>RHS)|Nec]):- state_match(Sort,Obj,SE,RHS), assert_goal_related(se(Sort,Obj,LHS),se(Sort,Obj,RHS),ID,0),!. find_related_goal_nec_init(se(Sort,Obj,SE),ID,Name,[sc(Sort,Obj,LHS=>RHS)|Nec]):- find_related_goal_nec_init(se(Sort,Obj,SE),ID,Name,Nec). find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,[]):-!. find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,[sc(Sort,Obj,LHS=>RHS)|Cond]):- is_hierarchy(false), filterInvars(LHS,LInVars,LIsOfSorts,LNEs,FLHS), filterInvars(RHS,RInVars,RIsOfSorts,RNEs,FRHS), state_match(Sort,Obj,SE,FRHS), checkInVars(LInVars), checkInVars(RInVars), checkIsOfSorts(LIsOfSorts), checkIsOfSorts(RIsOfSorts), obeysNEs(LNEs), obeysNEs(RNEs), assert_goal_related(se(Sort,Obj,FLHS),se(Sort,Obj,FRHS),ID,0), find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,Cond). find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,[sc(Sort1,Obj,LHS=>RHS)|Cond]):- is_hierarchy(true), is_of_sort(Obj,Sort1), is_of_sort(Obj,Sort), %Sort is a primitive sort changed at init filterInvars(LHS,LInVars,LIsOfSorts,LNEs,FLHS), filterInvars(RHS,RInVars,RIsOfSorts,RNEs,FRHS), state_match(Sort,Obj,SE,FRHS), checkInVars(LInVars), checkInVars(RInVars), checkIsOfSorts(LIsOfSorts), checkIsOfSorts(RIsOfSorts), obeysNEs(LNEs), obeysNEs(RNEs), assert_goal_related(se(Sort,Obj,FLHS),se(Sort,Obj,FRHS),ID,0), find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,Cond). find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,[Head|Cond]):- find_related_goal_cond_init(se(Sort,Obj,SE),ID,Name,Cond). % find_all_related_goals: backward search % until all preconditions have found find_all_related_goals(Post,Statics,N,N):- get_all_state(Post,States), all_found(Post,States,Statics), assert(max_length(N)), assert(goal_related_search(succ)),!. find_all_related_goals(Post,Statics,I,N):- I1 is I-1, goal_related(_,_,_,I1), find_related_goal(I1,I), I2 is I+1, find_all_related_goals(Post,Statics,I2,N),!. find_all_related_goals(Post,Statics,N,N):- I is N-1, not(goal_related(_,_,_,I)), assert(goal_related_search(fail)), write('related goal search failed'), retractall(goal_related(_,_,_,_)),!. %fail to find out, don't search any more % fwsearch use all the ground ops. % get all the found goal related states get_all_state([],[]):-!. get_all_state([se(Sort,Obj,ST)|Post],[se(Sort,Obj,SEPostall)|States]):- setof(SEPost, Pre^Level^OP^goal_related(Pre,se(Sort,Obj,SEPost),OP,Level),SEPostall), get_all_state(Post,States),!. put_one_obj_together([],States,States):-!. put_one_obj_together([se(Sort,Obj,ST)|States1],List,States):- put_one_obj_together1(se(Sort,Obj,ST),List,List1), put_one_obj_together(States1,List1,States),!. put_one_obj_together1(se(Sort,Obj,ST),[],[se(Sort,Obj,ST)]):-!. put_one_obj_together1(se(Sort,Obj,ST),[se(Sort,Obj,ST00)|List],[se(Sort,Obj,ST1)|List]):- set_append_e(ST,ST00,ST1),!. put_one_obj_together1(se(Sort,Obj,ST),[se(Sort1,Obj1,ST1)|List],[se(Sort1,Obj1,ST1)|List1]):- Obj\==Obj1, put_one_obj_together1(se(Sort,Obj,ST),List,List1),!. % all the Precondition states in backward search can reach initial states all_found([],States,Statics):-!. all_found([se(Sort,Obj,SEPost)|Post],[se(Sort,Obj,STPost)|States],Statics):- all_found1(Sort,Obj,SEPost,STPost,Statics), all_found(Post,States,Statics),!. all_found1(Sort,Obj,SEPost,[Head|STPost],Statics):- state_achieved([se(Sort,Obj,SEPost)],[se(Sort,Obj,Head)],Statics),!. all_found1(Sort,Obj,SEPost,[Head|STPost],Statics):- all_found1(Sort,Obj,SEPost,STPost,Statics),!. % find all the states that can achieve the goal state % separete ground operators to related-op and unrelated op find_related_goal(I1,I):- gOperator(OPID,ID,operator(Name,Prev,Nec,Cond)), % no need check Prev, become it doen't change states achieved_prev(Prev), find_related_goal_nec(Nec,GRNec), assert_related_goal_nec(OPID,GRNec,I), % do cond after nec successed find_related_goal_cond(OPID,Name,Cond,I1,I), fail. find_related_goal(I1,I). % prev didn't change states,just check if there is any previous state % achieves it achieved_prev([]):-!. achieved_prev([se(Sort,Obj,SEPrev)|Prev]):- goal_related(_,se(Sort,Obj,SE),_,_), state_match(Sort,Obj,SEPrev,SE), achieved_prev(Prev),!. % for nec find_related_goal_nec([],[]):-!. find_related_goal_nec([sc(Sort,Obj,Lhs=>Rhs)|Nec],[[se(Sort,Obj,SE),se(Sort,Obj,Rhs)]|GRNec]):- goal_related(_,se(Sort,Obj,SE),_,_), state_match(Sort,Obj,Lhs,SE), find_related_goal_nec(Nec,GRNec). assert_related_goal_nec(ID,[],I):-!. assert_related_goal_nec(ID,[[se(Sort,Obj,SE),se(Sort,Obj,Rhs)]|GRNec],I):- assert_goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),ID,I), assert_related_goal_nec(ID,GRNec,I),!. find_related_goal_cond(ID,Name,[],I1,I):-!. find_related_goal_cond(ID,Name,[sc(Sort,Obj,LHS=>RHS)|Cond],I1,I):- is_hierarchy(false), goal_related(_,se(Sort,Obj,SE),Ops,_), state_match(Sort,Obj,LHS,SE), filterInvars(LHS,LInVars,LIsOfSorts,LNEs,FLHS), filterInvars(RHS,RInVars,RIsOfSorts,RNEs,FRHS), checkInVars(LInVars), checkInVars(RInVars), checkIsOfSorts(LIsOfSorts), checkIsOfSorts(RIsOfSorts), obeysNEs(LNEs), obeysNEs(RNEs), assert_goal_related(se(Sort,Obj,SE),se(Sort,Obj,FRHS),ID,I), fail. find_related_goal_cond(ID,Name,[sc(Sort1,Obj,LHS=>RHS)|Cond],I1,I):- is_hierarchy(true), goal_related(_,se(Sort,Obj,SE),Ops,_), is_of_sort(Obj,Sort1), is_of_sort(Obj,Sort), %Sort is a primitive sort changed at init state_match(Sort,Obj,LHS,SE), filterInvars(LHS,LInVars,LIsOfSorts,LNEs,FLHS), filterInvars(RHS,RInVars,RIsOfSorts,RNEs,FRHS), checkInVars(LInVars), checkInVars(RInVars), checkIsOfSorts(LIsOfSorts), checkIsOfSorts(RIsOfSorts), obeysNEs(LNEs), obeysNEs(RNEs), assert_goal_related(se(Sort,Obj,SE),se(Sort,Obj,FRHS),ID,I), fail. find_related_goal_cond(ID,Name,[sc(Sort1,Obj,LHS=>RHS)|Cond],I1,I):- find_related_goal_cond(ID,Name,Cond,I1,I). % filter out invars, is_of_sorts and nes from a state list filterInvars([],[],[],[],[]):-!. filterInvars([is_of_sort(A,B)|State],InVars,[is_of_sort(A,B)|IsOfSorts],NEs,FState):- !, filterInvars(State,InVars,IsOfSorts,NEs,FState). filterInvars([ne(A,B)|State],InVars,IsOfSorts,[ne(A,B)|NEs],FState):- !, filterInvars(State,InVars,IsOfSorts,NEs,FState). filterInvars([is_of_primitive_sort(A,B)|State],InVars,[is_of_sort(A,B)|IsOfSorts],NEs,FState):- !, filterInvars(State,InVars,IsOfSorts,NEs,FState). filterInvars([Pred|State],[Pred|InVars],IsOfSorts,NEs,FState):- functor(Pred,FF,NN), functor(Pred1,FF,NN), atomic_invariantsC(Atom), member_cut(Pred1,Atom),!, filterInvars(State,InVars,IsOfSorts,NEs,FState). filterInvars([Pred|State],InVars,IsOfSorts,NEs,[Pred|FState]):- !,filterInvars(State,InVars,IsOfSorts,NEs,FState). % filter out nes from a state list filterNes([],[],[]):-!. filterNes([ne(A,B)|State],[ne(A,B)|NEs],FState):- !, filterNes(State,NEs,FState). filterNes([Pred|State],NEs,[Pred|FState]):- filterNes(State,NEs,FState). /*****************ground can_achieve_g**********************/ % State2 can be achieved by State1 can_achieve_g([],State2,Statics):-!. can_achieve_g(State1,State2,Statics):- can_achieve_g(State1,State2), statics_consist(Statics). can_achieve_g([se(Sort,Obj,ST1)|State1],[se(Sort,Obj,ST2)]):- state_match(Sort,Obj,ST2,ST1). can_achieve_g([Head|State1],State2):- can_achieve_g(State1,State2). /****************end of ground can_achieve_g**********/ % assert:goal_related(Pre,Post,Op,DistanseFromGoal) assert_goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),ID,I):- retract(goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),Ops,I1)), set_append([ID],Ops,Ops1), assert(goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),Ops1,I)),!. assert_goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),ID,I):- assert(goal_related(se(Sort,Obj,SE),se(Sort,Obj,Rhs),[ID],I)),!. get_score(PR,Post,Steps,Score):- tp_goal(Pre,Goal,Statics), max_length(Max), get_distance(Max,Post,Goal,0,Dis),%length from Present to Goal length(Pre,Obj_Num), get_length(PR,1,Len), % Num1 is Obj_Num*Dis,%distanse the smaller the better Num is Obj_Num*Len,%length of the plan the smaller the better % Score is Num1+Num2,!. Score is Dis+Num,!. get_score(PR,Post,Steps,Score):- tp_goal(Pre,Goal,Statics), get_distance(100,Post,Goal,0,Dis),%length from Present to Goal length(Pre,Obj_Num), get_length(PR,1,Len), % Num1 is Obj_Num*Dis,%distanse the smaller the better Num is Obj_Num*Len,%length of the plan the smaller the better % Score is Num1+Num2,!. Score is Dis+Num,!. % get distance from Present to Goal % it is the total of the distance of every objects get_distance(Max,[],Goal,Dis,Dis):-!. get_distance(Max,[se(Sort,Obj,SE)|Post],Goal,Dis1,Dis):- member(se(Sort,Obj,SE0),Goal), post_achieved([se(Sort,Obj,SE0)],[se(Sort,Obj,SE)]),%if it achieved goal get_distance(Max,Post,Goal,Dis1,Dis),!. % the distance is measured by goal_related get_distance(Max,[se(Sort,Obj,SE)|Post],Goal,Dis1,Dis):- goal_related(_,se(Sort,Obj,SE),_,Level), Dis2 is Max-Level, Dis11 is Dis1+Dis2, get_distance(Max,Post,Goal,Dis11,Dis),!. % if it is not found in goal_related, % but it is in initial states, the distance is 0 get_distance(Max,[se(Sort,Obj,SE)|Post],Goal,Dis1,Dis):- member(se(Sort,Obj,SE0),Pre), state_achieved([se(Sort,Obj,SE)],[se(Sort,Obj,SE0)]), get_distance(Max,Post,Goal,Dis1,Dis),!. % if it is not found in goal_related, % and it is not initial states, the distance is infinity, we use 1000 in here get_distance(Max,[se(Sort,Obj,SE)|Post],Goal,Dis1,Dis):- Dis2 is Dis1+1000, get_distance(Max,Post,Goal,Dis2,Dis),!. get_length(init,Len,Len):-!. get_length(TP,Len1,Len):- closed_node(TP,_,_,from(PR),_,_), Len2 is Len1+1, get_length(PR,Len2,Len),!. %------------------------------------------- % remove HP1 from the temp list % if HP1<HP2, then all HP3<HP1 => HP3<HP2 % if HP2<HP1, then all HP1<HP3 => HP2<HP3 remove_temp([],HP1,List,List):-!. remove_temp([before(HP1,HP2)|Temp],HP1,List,Temp1):- remove_temp_before(List,before(HP1,HP2),List2), remove_temp(Temp,HP1,List2,Temp1),!. remove_temp([before(HP2,HP1)|Temp],HP1,List,Temp1):- remove_temp_after(List,before(HP2,HP1),List2), remove_temp(Temp,HP1,List2,Temp1),!. remove_temp([before(HPX,HPY)|Temp],HP1,List,Temp1):- remove_temp(Temp,HP1,List,Temp1),!. % if HP1<HP2, remove HP1<HP2, and change all HP3<HP1 => HP3<HP2 remove_temp_before([],before(HP1,HP2),[]):-!. remove_temp_before([before(HP1,HP2)|T],before(HP1,HP2),T1):- remove_temp_before(T,before(HP1,HP2),T1),!. remove_temp_before([before(HP3,HP1)|T],before(HP1,HP2),[before(HP3,HP2)|T1]):- remove_temp_before(T,before(HP1,HP2),T1),!. remove_temp_before([before(HPX,HPY)|T],before(HP1,HP2),[before(HPX,HPY)|T1]):- remove_temp_before(T,before(HP1,HP2),T1),!. % if HP2<HP1, remove HP2<HP1, and change all HP1<HP3 => HP2<HP3 remove_temp_after([],before(HP1,HP2),[]):-!. remove_temp_after([before(HP2,HP1)|T],before(HP2,HP1),T1):- remove_temp_after(T,before(HP2,HP1),T1),!. remove_temp_after([before(HP1,HP3)|T],before(HP2,HP1),[before(HP2,HP3)|T1]):- remove_temp_after(T,before(HP2,HP1),T1),!. remove_temp_after([before(HPX,HPY)|T],before(HP2,HP1),[before(HPX,HPY)|T1]):- remove_temp_after(T,before(HP2,HP1),T1),!. remove_dec(HPid,[],[]):-!. remove_dec(HPid,[step(HPid,_,_,_,_)|Dec],Dec1):- remove_dec(HPid,Dec,Dec1),!. remove_dec(HPid,[step(A,B,C,D,F)|Dec],[step(A,B,C,D,F)|Dec1]):- remove_dec(HPid,Dec,Dec1),!. /******************************************************/ % State2 is achieved by State1 % first split the states to the substate class of the sort level % then compare them in same sort level state_achieved(undefd,State,Statics):-!. state_achieved([],State2,Statics):-!. state_achieved(State1,State2,Statics):- state_achieved(State1,State2), statics_consist(Statics). state_achieved(undefd,State):-!. state_achieved([],State2). state_achieved(State1,State2):- is_hierarchy(false), state_achievedf(State1,State2). state_achieved(State1,State2):- is_hierarchy(true), state_achievedh(State1,State2). % for flat domain state_achievedf([],State2). state_achievedf([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort,Obj,ST2),State2), state_match(Sort,Obj,ST1,ST2), list_take(State2,[se(Sort,Obj,ST2)],State21), state_achievedf(State1,State21). state_achievedf([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort,Obj,ST2),State2)), state_achievedf(State1,State2). % for hierarchical domain state_achievedh([],State2). state_achievedh([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort2,Obj,ST2),State2), not(not(is_of_sort(Obj,Sort))), not(not(is_of_sort(Obj,Sort2))), state_achieved1([se(Sort2,Obj,ST1)],[se(Sort2,Obj,ST2)]), list_take(State2,[se(Sort2,Obj,ST2)],State21), state_achievedh(State1,State21). state_achievedh([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort2,Obj,ST2),State2)), state_achievedh(State1,State2). % if the ST1 is a subset of ST2 state_achieved1(State1,State2):- split_level(State1,[],SPST1), split_level(State2,[],SPST2), state_achieved2(SPST1,SPST2). % compare the state in there level state_achieved2([],State2). state_achieved2([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort,Obj,ST2),State2), state_match(Sort,Obj,ST1,ST2), state_achieved2(State1,State2). state_achieved2([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort,Obj,ST2),State2)), state_achieved2(State1,State2). /************ states ST1 matchs ST2 ********/ % state_match: ST is achieved by ST1 % ST and ST1 can in same substate classes % in some domain, one substate is another's subset, % so they cann't consider as match each other because they are different state % for example [on_block(a,b)] and [on_block(a,b),clear(a)] state_match(Sort,Obj,ST,ST):-!. state_match(Sort,Obj,ST,ST1):- is_achieved(ST,ST1), not(in_different_states(Sort,Obj,ST,ST1)),!. % in_different_states: check if ST,ST1 in different states in_different_states(Sort,Obj,ST,ST1):- odds_in_subset_substates(Sort,Obj,Odds), diff_items(ST,ST1,Diff), member_cut(Diff,Odds),!. diff_items(ST,ST1,Diff):- list_take(ST,ST1,Diff1), list_take(ST1,ST,Diff2), append(Diff1,Diff2,Diff),!. % split the hier substates to their relavant level % so that we can compare them later at same level split_level([],State,State):-!. split_level([se(Sort,Obj,[])|State],SPST1,SPST):- split_level(State,SPST1,SPST),!. split_level([se(Sort,Obj,ST)|State],SPST1,SPST):- substate_classes(Sort,Obj,Substateclasses), max_member(ST,Substateclasses,MSub, Others), not(isemptylist(MSub)), append(SPST1,[se(Sort,Obj,MSub)],SPST11), split_level([se(Sort,Obj, Others)|State],SPST11,SPST),!. split_level([se(Sort,Obj,ST)|State],SPST1,SPST):- subsortse(Sort,SSorts), uppersortse(Sort,USorts), append(SSorts,USorts,Sametree), split_level1(Sametree,se(Sort,Obj,ST),SPST1,SPST11), split_level(State,SPST11,SPST),!. split_level1([],se(OSort,Obj,_),SPST,SPST):-!.%it should be impossible. split_level1(_,se(OSort,Obj,[]),SPST,SPST):-!. split_level1([Sort|Sortls],se(OSort,Obj,ST),SPST,SPST1):- substate_classes(Sort,Obj,Substateclasses), max_member(ST,Substateclasses,MSub, Others), not(isemptylist(MSub)), split_level1(Sortls,se(OSort,Obj,Others),[se(Sort,Obj,MSub)|SPST],SPST1),!. split_level1([Sort|Sortls],se(OSort,Obj,ST),SPST,SPST1):- split_level1(Sortls,se(OSort,Obj,ST),SPST,SPST1),!. % find out a list which has the max number of predicates in one substates class % and point out the whole substate max_member(State, Stateclass, MSub, Others):- max_member1(State, Stateclass, 0, [],MSub), list_take(State,MSub,Others),!. % find out the biggest same items max_member1(State, [], Num, MSub, MSub):-!. % find it out the biggest set of common items in substateclass and State max_member1(State, [State1|SCls], Num, MSub1, MSub):- same_items(State1,State,MSSt), length(MSSt,Len), Len > Num, max_member1(State, SCls, Len, MSSt, MSub),!. max_member1(State, [State1|SCls], Num, MSub1,MSub):- max_member1(State, SCls, Num, MSub1,MSub),!. % find it out the same items in two list same_items([],List2,[]):-!. same_items([X|List1],List2,[X|Same]):- member(X,List2), same_items(List1,List2,Same),!. same_items([X|List1],List2,Same):- same_items(List1,List2,Same),!. % post achieved: for post (goal) achieved only post_achieved(undefd,State,Statics):-!. post_achieved([],State2,Statics):-!. post_achieved(State1,State2,Statics):- post_achieved(State1,State2), statics_consist(Statics). post_achieved(undefd,State):-!. post_achieved([],State2). post_achieved(State1,State2):- is_hierarchy(false), post_achievedf(State1,State2). post_achieved(State1,State2):- is_hierarchy(true), post_achievedh(State1,State2). % for flat domain post_achievedf([],State2). post_achievedf([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort,Obj,ST2),State2), is_achieved(ST1,ST2), list_take(State2,[se(Sort,Obj,ST2)],State21), post_achievedf(State1,State21). post_achievedf([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort,Obj,ST2),State2)), post_achievedf(State1,State2). % for hierarchical domain post_achievedh([],State2). post_achievedh([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort2,Obj,ST2),State2), not(not(is_of_sort(Obj,Sort))), not(not(is_of_sort(Obj,Sort2))), post_achieved1([se(Sort2,Obj,ST1)],[se(Sort2,Obj,ST2)]), list_take(State2,[se(Sort2,Obj,ST2)],State21), post_achievedh(State1,State21). post_achievedh([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort2,Obj,ST2),State2)), post_achievedh(State1,State2). % if the ST1 is a subset of ST2 post_achieved1(State1,State2):- split_level(State1,[],SPST1), split_level(State2,[],SPST2), post_achieved2(SPST1,SPST2). % compare the state in there level post_achieved2([],State2). post_achieved2([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort,Obj,ST2),State2), is_achieved(ST1,ST2), post_achieved2(State1,State2). post_achieved2([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort,Obj,ST2),State2)), post_achieved2(State1,State2). % all the element in list1 are static or in list2 is_achieved([],_):-!. is_achieved([H|T], State) :- is_statics(H), is_achieved(T,State),!. is_achieved([H|T], State) :- member(H,State), is_achieved(T,State),!. % check if a predicate is statics or not is_statics(ne(A,B)):-!. is_statics(is_of_sort(A,B)):-!. is_statics(is_of_primitive_sort(A,B)):-!. is_statics(Pred):- functor(Pred,FF,NN), functor(Pred1,FF,NN), atomic_invariants(Atom), member(Pred1,Atom),!. /************ state changes by actions ********/ % if an object's state meet the precondition % it change to the postcondition % Pre is the current ground states % Pre0 and Post0 are from an Operator or Method, % so the Sort inse(Sort,Obj,SS0) is also primitive state_change(Pre,[],[],Pre):-!. state_change(Pre,LHS,RHS,Post):- is_hierarchy(false), state_changef(Pre,LHS,RHS,Post). state_change(Pre,LHS,RHS,Post):- is_hierarchy(true), state_changeh(Pre,LHS,RHS,Post). % for flat domain state_changef(Pre,[],[],Pre):-!. state_changef([HPred|Pre],LHS,RHS,[HPost|Post]):- state_changef1(HPred,LHS,RHS,LHS1,RHS1,HPost), state_changef(Pre,LHS1,RHS1,Post). % if no Sort,Obj state exist in action, stay unchanged state_changef1(se(Sort,Obj,SE),[],[],[],[],se(Sort,Obj,SE)):-!. % if there is an Sort,Obj state exist in action, changed to RHS state_changef1(se(Sort,Obj,SE),[se(Sort,Obj,LS)|LHS],[se(Sort,Obj,RS)|RHS],LHS,RHS,se(Sort,Obj,RS)):- state_match(Sort,Obj,LS,SE). state_changef1(se(Sort,Obj,SE),[se(Sort0,Obj0,LS)|LHS],[se(Sort0,Obj0,RS)|RHS],[se(Sort0,Obj0,LS)|LHS1],[se(Sort0,Obj0,RS)|RHS1],Post):- (Sort\==Sort0;Obj\==Obj0), state_changef1(se(Sort,Obj,SE),LHS,RHS,LHS1,RHS1,Post). % for hierarchical domain state_changeh(Pre,[],[],Pre):-!. state_changeh(Pre,[se(Sort,Obj,SE0)|Pre0],[se(Sort,Obj,SS0)|Post0],[STPost|Post]):- member(se(Sort,Obj,SE),Pre), is_of_sort(Obj,Sort), split_level([se(Sort,Obj,SE)],[],SPPre), split_level([se(Sort,Obj,SE0)],[],SPPre0), split_level([se(Sort,Obj,SS0)],[],SPPost0), state_change1(Sort,Obj,SPPre,SPPre0,SPPost0,[],[STPost]), list_take(Pre,[se(Sort,Obj,SE)],Pre11), state_changeh(Pre11,Pre0,Post0,Post). state_changeh(Pre,[se(Sort,Obj,SE0)|Pre0],[se(Sort,Obj,SS0)|Post0],Post):- not(member(se(Sort,Obj,SE),Pre)), state_changeh(Pre,Pre0,Post0,Post),!. state_change1(PSort,Obj,Pre,Pre0,[],State,Post):- merge_level(PSort,Obj,Pre,State,Post),!. state_change1(PSort,Obj,Pre,[],Post0,State,Post):- merge_level(PSort,Obj,Post0,State,Post),!. state_change1(PSort,Obj,[],Pre0,Post0,State,Post):- merge_level(PSort,Obj,Post0,State,Post),!. % if a obj pre achieves action's pre % change the obj's post state with action's post state_change1(PSort,Obj,[se(Sort,Obj,SE)|Pre],Pre0,Post0,State,Post):- member(se(Sort,Obj,SE0),Pre0), % member(se(Sort,Obj,SS0),Post0), state_match(Sort,Obj,SE0,SE), list_take(Pre0,[se(Sort,Obj,SE0)],Pre1), % list_take(Post0,[se(Sort,Obj,SS0)],Post1), append_post([se(Sort,Obj,SE)],[se(Sort,Obj,SE0)],Post0,Post1,State,State1), state_change1(PSort,Obj,Pre,Pre1,Post1,State1,Post),!. % if a obj state not defined in action's pre % move it to its post state_change1(PSort,Obj,[se(Sort,Obj,SE)|Pre],Pre0,Post0,State,Post):- not(member(se(Sort,Obj,SE0),Pre0)), append([se(Sort,Obj,SE)],State,State1), state_change1(PSort,Obj,Pre,Pre0,Post0,State1,Post),!. % append post states append_post([se(Sort,Obj,SE)],[se(Sort,Obj,SE0)],Post0,Post1,State,State1):- member(se(Sort,Obj,SS0),Post0), list_take(SE,SE0,ST0), set_append_e(ST0,SS0,SS1), append([se(Sort,Obj,SS1)],State,State1), list_take(Post0,[se(Sort,Obj,SS0)],Post1),!. append_post([se(Sort,Obj,SE)],[se(Sort,Obj,SE0)],Post0,Post0,State,State):-!. % merge the different level states to a whole state in its primitive sort merge_level(PSort,Obj,[],[],[]):-!. merge_level(PSort,Obj,State1,State2,State):- append(State1,State2,State3), merge_level1(PSort,Obj,State3,State),!. merge_level1(PSort,Obj,[],[]):-!. merge_level1(PSort,Obj,[se(Sort0,Obj,SS0)|List],State):- merge_level2(PSort,Obj, List, [se(PSort,Obj,SS0)],State),!. merge_level2(PSort,Obj,[],State,State):-!. merge_level2(PSort,Obj,[se(Sort0,Obj,SS0)|List],[se(PSort,Obj,SS1)],State):- append(SS0,SS1,SS), merge_level2(PSort,Obj,List,[se(PSort,Obj,SS)],State),!. % rough change the obj's post state with action's post rough_state_change(Pre,[],[],Pre):-!. rough_state_change([],_,_,[]):-!. rough_state_change([se(Sort,Obj,SE)|Pre],Pre0,Post0,[se(Sort,Obj,SS0)|Post]):- member(se(Sort,Obj,SE0),Pre0), member(se(Sort,Obj,SS0),Post0), is_of_sort(Obj,Sort), state_achieved([se(Sort,Obj,SE0)],[se(Sort,Obj,SE)]), list_take(Pre0,[se(Sort,Obj,SE0)],Pre01), list_take(Post0,[se(Sort,Obj,SS0)],Post01), rough_state_change(Pre,Pre01,Post01,Post). rough_state_change([se(Sort,Obj,SE)|Pre],Pre0,Post0,[se(Sort,Obj,SE)|Post]):- rough_state_change(Pre,Pre0,Post0,Post),!. find_lower_sort(Sort,Sort,Sort):-!. find_lower_sort(Sort,Sort1,Sort1):- subsorts(Sort,Sortls), member(Sort1,Sortls),!. find_lower_sort(Sort,Sort1,Sort):- subsorts(Sort1,Sortls), member(Sort,Sortls),!. %------------------------------------------- /************ state changes by necessery changes ********/ % for all the object's state meet the precondition % it change to the postcondition % this is only used in apply grounded operators nec_state_change([],Nec,[]):-!. nec_state_change([se(Sort,Obj,SE)|Pre],Nec,[se(Sort,Obj,Post)|State]):- member(sc(Sort,Obj,Lhs=>Rhs),Nec), state_change([se(Sort,Obj,SE)],[se(Sort,Obj,Lhs)],[se(Sort,Obj,Rhs)],[se(Sort,Obj,Post)]), nec_state_change(Pre,Nec,State),!. nec_state_change([se(Sort,Obj,SE)|Pre],Nec,[se(Sort,Obj,SE)|State]):- not(member(sc(Sort,Obj,Lhs=>Rhs),Nec)), nec_state_change(Pre,Nec,State),!. %------------------------------------------------- /************ state changes by conditions ********/ % for all the object's state meet the precondition % it change to the postcondition cond_state_change([],Cond,[]):-!. cond_state_change(State,[],State):-!. cond_state_change([se(Sort,Obj,SE)|Pre],Cond,[NewSS|State]):- member(sc(Sort1,Obj,SE0=>SS0),Cond), is_of_sort(Obj,Sort1), is_of_sort(Obj,Sort), % state_match(Sort,Obj,SE,SE0), state_change([se(Sort,Obj,SE)],[se(Sort,Obj,SE0)], [se(Sort,Obj,SS0)],[NewSS]), cond_state_change(Pre,Cond,State). cond_state_change([se(Sort,Obj,SE)|Pre],Cond,[se(Sort,Obj,SE)|State]):- cond_state_change(Pre,Cond,State),!. %------------------------------------------- % every states in Pre is achieved by Post all_achieved(undefd,Statics,Post):-!. all_achieved([],Statics,Post):-!. all_achieved(Pre,Statics,Post):- all_achieved(Pre,Post), statics_consist(Statics). all_achieved([],Post). all_achieved([se(Sort,Obj,SL)|Pre],Post):- member(se(Sort,Obj,SR),Post), not(not(is_of_sort(Obj,Sort))), state_achieved1([se(Sort,Obj,SL)],[se(Sort,Obj,SR)]), all_achieved(Pre,Post). %------------------------------------------- % may_achieved: every states in Pre is not conflict with Post may_achieved(undefd,Statics,Post):-!. may_achieved([],Statics,Post):-!. may_achieved(Pre,Statics,Post):- may_achieved(Pre,Post), statics_consist(Statics),!. may_achieved([],Post). may_achieved([se(Sort,Obj,SL)|Pre],Post):- member(se(Sort1,Obj,SR),Post), not(not(is_of_sort(Obj,Sort1))), not(not(is_of_sort(Obj,Sort))), state_may_achieved([se(Sort,Obj,SL)],[se(Sort1,Obj,SR)]), may_achieved(Pre,Post),!. % if the ST1 is a subset of ST2 state_may_achieved(State,State):-!. state_may_achieved(State1,State2):- split_level(State1,[],SPST1), split_level(State2,[],SPST2), state_may_achieved1(SPST1,SPST2),!. % compare the state in there level state_may_achieved1([],State2):-!. state_may_achieved1([se(Sort,Obj,ST1)|State1],State2):- member(se(Sort,Obj,ST2),State2), is_achieved(ST1,ST2), state_may_achieved1(State1,State2),!. state_may_achieved1([se(Sort,Obj,ST1)|State1],State2):- not(member(se(Sort,Obj,ST2),State2)), state_may_achieved1(State1,State2),!. %------------------------------------------- % instantiate a bit % use action's state change include the postcondition post_instant(Post0,Cond,Statics,undefd):-!. post_instant(Post0,Cond,Statics,[]):-!. post_instant(Post0,Cond,Statics,[se(Sort,Obj,SE)|Post]):- member(se(Sort,Obj,SE0),Post0), statics_consist(Statics). post_instant(Post0,Cond,Statics,[se(Sort,Obj,SE)|Post]):- member(sc(Sort,Obj,SE1=>SS),Cond), statics_consist(Statics). post_instant(Post0,Cond,Statics,[se(Sort,Obj,SE)|Post]):- member(sc(Sort0,Obj,SE1=>SS),Cond), not(objectsC(Sort0,_)), subsorts(Sort0,Sortls), not(not(member(Sort,Sortls))), statics_consist(Statics). post_instant(Post0,Cond,Statics,[se(Sort,Obj,SE)|Post]):- post_instant(Post0,Cond,Statics,Post),!. /********* check for statics consist without instanciate them***/ % only instance the variable when there is one choice of from the ground lists statics_consist([]):-!. statics_consist(Statics):- split_fixed(Statics,[],FixST,[],Atom), inv_statics_consist(Atom), fixed_statics_consist(FixST),!. /*********check for statics consist and instanciate them***/ statics_consist_instance([]):-!. statics_consist_instance(Statics) :- split_fixed(Statics,[],FixST,[],Atom), inv_statics_consist_instance(Atom), fixed_statics_consist_instance(FixST). % split out ne,is_of_sort split_fixed([],FixST,FixST,Atom,Atom):-!. split_fixed([ne(A,B)|TStatics],FixST0,FixST,Atom0,Atom):- append_cut(FixST0,[ne(A,B)],FixST1), split_fixed(TStatics,FixST1,FixST,Atom0,Atom),!. split_fixed([is_of_sort(Obj,Sort)|TStatics],FixST0,FixST,Atom0,Atom):- append_cut([is_of_sort(Obj,Sort)],FixST0,FixST1), split_fixed(TStatics,FixST1,FixST,Atom0,Atom),!. split_fixed([is_of_primitive_sort(Obj,Sort)|TStatics],FixST0,FixST,Atom0,Atom):- append_cut([is_of_primitive_sort(Obj,Sort)],FixST0,FixST1), split_fixed(TStatics,FixST1,FixST,Atom0,Atom),!. split_fixed([HST|TStatics],FixST0,FixST,Atom0,Atom):- append_cut(Atom0,[HST],Atom1), split_fixed(TStatics,FixST0,FixST,Atom1,Atom),!. % check invariants without instanciate them % only instance them when there is only one choice of from the ground lists inv_statics_consist([]):-!. inv_statics_consist(Atom):- get_invariants(Invs), inv_statics_consist1(Invs,Atom),!. inv_statics_consist1(Invs,[]):-!. inv_statics_consist1(Invs,[Pred|Atom]):- pred_member(Pred,Invs), inv_statics_consist1(Invs,Atom),!. % check invariants and instanciate them inv_statics_consist_instance([]):-!. inv_statics_consist_instance(Atom):- get_invariants(Invs), inv_statics_consist_instance1(Invs,Atom). inv_statics_consist_instance1(Invs,[]). inv_statics_consist_instance1(Invs,[Pred|Atom]):- member(Pred,Invs), inv_statics_consist_instance1(Invs,Atom). % check invariants without instanciate them fixed_statics_consist([]):-!. fixed_statics_consist([ne(A,B)|TStatics]):- not(A==B), fixed_statics_consist(TStatics),!. fixed_statics_consist([is_of_sort(Obj,Sort)|TStatics]):- is_of_sort0(Obj,Sort), fixed_statics_consist(TStatics),!. fixed_statics_consist([is_of_primitive_sort(Obj,Sort)|TStatics]):- is_of_primitive_sort0(Obj,Sort), fixed_statics_consist(TStatics),!. % check sort info without instanciate them % but instanciate the obj when there is only one obj in the sort is_of_primitive_sort0(X,Y) :- var(X),!. is_of_primitive_sort0(X,Y) :- objectsC(Y,L),obj_member(X,L),!. is_of_sort0(X,Y) :- is_of_primitive_sort0(X,Y). is_of_sort0(X,Y) :- sorts(Y,SL),member(Z,SL),is_of_sort0(X,Z). % check invariants and instanciate them fixed_statics_consist_instance([]). fixed_statics_consist_instance([ne(A,B)|TStatics]):- not(A==B), fixed_statics_consist_instance(TStatics). fixed_statics_consist_instance([is_of_sort(Obj,Sort)|TStatics]):- is_of_sort(Obj,Sort), fixed_statics_consist_instance(TStatics). fixed_statics_consist_instance([is_of_primitive_sort(Obj,Sort)|TStatics]):- is_of_primitive_sort(Obj,Sort), fixed_statics_consist_instance(TStatics). /*********************Initial process *********************/ %node(Name, Precond, Decomps, Temp, Statics) % When inputting new methods etc filter all statics into % static slot make_problem_into_node(I,goal(L,TM,STATS), NN) :- make_problem_up(L, STEPS), make_num_hp(TM,Temp), sort_steps(STEPS,Temp,STEPS1), make_ss_to_se(I,I_Pre), NN = node(root,I_Pre,STEPS1 ,Temp, STATS),!. make_problem_into_node(I,L, NN) :- make_problem_up([achieve(L)], STEPS), make_num_hp(TM,Temp), sort_steps(STEPS,Temp,STEPS1), make_ss_to_se(I,I_Pre), NN = node(root,I_Pre,STEPS1 ,Temp, STATS),!. % make problem to steps make_problem_up([],[]):-!. make_problem_up([achieve(L)|R],[step(HP,achieve(L1),undefd,[L1],unexp)|RS]):- %preconditon here is undefd make_ss_to_se([L],[L1]), gensym(hp,HP), make_problem_up(R, RS),!. make_problem_up([achieve(L)|R],[step(HP,achieve(L1),undefd,L1,unexp)|RS]):- %preconditon here is undefd make_ss_to_se(L,L1), gensym(hp,HP), make_problem_up(R, RS),!. make_problem_up([O|R],[step(HP,O,undefd,undefd,unexp)|RS]):- methodC(O,Pre,Post,Statics1,Temp,ACH,Dec), gensym(hp,HP), make_problem_up(R, RS),!. make_problem_up([O|R], [step(HP,O,undefd,undefd,unexp)|RS]):- operatorC(O,Pre,Post,Cond,Statics1), gensym(hp,HP), make_problem_up(R, RS),!. make_num_hp([],[]):-!. make_num_hp([before(N1,N2)|TM],[before(H1,H2)|Temp]):- gensym_num(hp,N1,H1), gensym_num(hp,N2,H2), make_num_hp(TM,Temp),!. %**************sort steps********************************* % sort steps by temporal constraints. sort_steps(Steps,[],Steps):-!. sort_steps([Steps|[]],[],[Steps]):-!. sort_steps(Steps,Temp,OrderedST):- steps_in_temp(Temp,[],ST), sort_steps1(Temp,ST,OrderedSTID), sort_steps2(Steps,OrderedSTID,[],OrderedST),!. % find out the steps in temporal constraints. steps_in_temp([],ST,ST):-!. steps_in_temp([before(H1,H2)|TT],List,ST):- set_append_e(List,[H1,H2],List1), steps_in_temp(TT,List1,ST),!. % sort the steps_id(hps) by temporal constraints. sort_steps1(Temp,[],[]):-!. sort_steps1(Temp,[HP1|TST],[HPF|OST]):- earliest_step(HP1,HPF,Temp,TST,TST1), sort_steps1(Temp,TST1,OST),!. earliest_step(HPF,HPF,Temp,[],[]):-!. earliest_step(HP1,HPF,Temp,[HP2|TST],[HP1|TST1]):- member(before(HP2,HP1),Temp), earliest_step(HP2,HPF,Temp,TST,TST1),!. earliest_step(HP1,HPF,Temp,[HP2|TST],[HP2|TST1]):- earliest_step(HP1,HPF,Temp,TST,TST1),!. % sort the steps, put the unordered steps in the front sort_steps2(OtherST,[],OrderedST1,OrderedST):- append(OrderedST1,OtherST,OrderedST),!. sort_steps2(Steps,[HP|THPS],List,OrderedST):- member(step(HP,N,Pre,Post,F),Steps), append(List,[step(HP,N,Pre,Post,F)],List1), list_take(Steps,[step(HP,N,Pre,Post,F)],Steps1), sort_steps2(Steps1,THPS,List1,OrderedST),!. sort_steps2(Steps,[HP|THPS],List,OrderedST):- sort_steps2(Steps,THPS,List,OrderedST),!. %******************************************************* % replace ss to se make_ss_to_se([],[]):-!. make_ss_to_se([ss(Sort,Obj,Post)|TPost],[se(Sort,Obj,Post)|TPre]):- make_ss_to_se(TPost,TPre),!. make_ss_to_se([se(Sort,Obj,Post)|TPost],[se(Sort,Obj,Post)|TPre]):- make_ss_to_se(TPost,TPre),!. %******************************************************* % extract_solution(Node,.. % recurvise routine to work down tree and % print out a linearisation of it extract_solution(Node,PHPs,SIZE1,TNList) :- % its the name of a hierarchical op...... getN_decomp(Node, HPs), push_to_primitive(HPs,[],PHPs,[],TNList), pprint(PHPs,1,SIZE), SIZE1 is SIZE -1,!. /************ change_op_representation ***********/ % make pre and post explicit % filter out statics and put in a new slot change_op_representation :- method(A,B,C,Stat,T,Dec), make_ss_to_se(B,B0), make_se_primitive(B0,B1), make_sc_primitive(C,C1), get_preconditions(C1,B1,Pre,Post), rem_statics(Post, PostR,St1), rem_statics(Pre, PreR,St2), append_cut(St1,St2,Statics), append_cut(Stat,Statics,Statics1), remove_unneed(Statics1,[],Statics2), get_achieval(A,Dec,T,Dec1,T1,ACH), % make_se_primitive(ACH1,ACH), assert(methodC(A,PreR,PostR,Statics2,T1,achieve(ACH),Dec1)), fail. change_op_representation :- operator(A,B,C,D), make_ss_to_se(B,B0), make_se_primitive(B0,B1), make_sc_primitive(C,C1), % make_sc_primitive(D,D1), %can't do that because it narrow the conditional change get_preconditions(C1,B1,Pre,Post), rem_statics(Post, PostR,St1), rem_statics(Pre, PreR,St2), append_cut(St1,St2,Statics1), remove_unneed(Statics1,[],Statics), statics_consist(Statics), assert(operatorC(A,PreR,PostR,D,Statics)), fail. change_op_representation:- retractall(current_num(sm,_)),!. get_preconditions([],Prev,Prev,Prev) :-!. get_preconditions([sc(S,X,From =>To)|Rest],Prev,[se(S,X,From1)|Pre],[se(S,X,To1)|Post]):- member_e(se(S,X,PSE),Prev), append(PSE,From,From1), append(PSE,To,To1), list_take(Prev,[se(S,X,PSE)],Prev1), get_preconditions(Rest,Prev1, Pre,Post),!. get_preconditions([sc(S,X,From =>To)|Rest],Prev,[se(S,X,From)|Pre],[se(S,X,To)|Post]):- get_preconditions(Rest,Prev, Pre,Post),!. get_preconditions([],Prev,Prev,Prev) :-!. % get all achieve goals out get_achieval(A,Dec,T,Dec1,T1,Achieval):- retractall(current_num(sm,_)), make_dec(A,Dec,Dec1,T,T1,[],Achieval),!. make_dec(A,[],[],Temp,Temp,Achieval,Achieval):-!. make_dec(A,[HD|TD],TD1,Temp,Temp1,Achieval,Achieval1):- HD=..[achieve|Goal], current_num(sm,Num), replace_achieval_temp(Temp,Temp0,Num), make_ss_to_se(Goal,Goal0), append(Achieval,Goal0,Achieval0), make_dec(A,TD,TD1,Temp0,Temp1,Achieval0,Achieval1),!. make_dec(A,[HD|TD],TD1,Temp,Temp1,Achieval,Achieval1):- HD=..[achieve|Goal], not(current_num(sm,Num)), replace_achieval_temp(Temp,Temp0,1), make_ss_to_se(Goal,Goal0), append(Achieval,Goal0,Achieval0), make_dec(A,TD,TD1,Temp0,Temp1,Achieval0,Achieval1). make_dec(A,[HD|TD],[HD|TD1],Temp,Temp1,Achieval,Achieval1):- HD=..[DecName|Goal], DecName\==achieve, gensym(sm,SM), current_num(sm,Num), make_dec(A,TD,TD1,Temp,Temp1,Achieval,Achieval1),!. % get rid of the achievals in temp orders replace_achieval_temp(Temp,Temp1,Num):- change_all_numbers(Temp,Num,Temp00), tidy_temp(Temp00,Temp1). change_all_numbers([],Num,[]):-!. change_all_numbers([HTemp|TTemp],Num,[HTemp00|TTemp00]):- HTemp=..[before|Nums], change_nums(Nums,Num,Nums1), HTemp00=..[before|Nums1], change_all_numbers(TTemp,Num,TTemp00). change_nums([],Num,[]):-!. change_nums([Num1|TN],Num,[Num1|TN1]):- Num1<Num, change_nums(TN,Num,TN1),!. change_nums([Num1|TN],Num,[Num2|TN1]):- Num1>Num, Num2 is Num1-1, change_nums(TN,Num,TN1),!. change_nums([Num|TN],Num,[0|TN1]):- change_nums(TN,Num,TN1),!. % since assumed achieval only happen at first, so only change the after ones tidy_temp(Temp,Temp1):- member(before(Num,0),Temp), list_take(Temp,[before(Num,0)],Temp0), change_laters(Temp0,Num,Temp01), tidy_temp(Temp01,Temp1). tidy_temp([],[]):-!. tidy_temp([before(0,Num)|Temp],Temp0):- tidy_temp(Temp,Temp0),!. tidy_temp([before(Num1,Num2)|Temp],[before(Num1,Num2)|Temp0]):- tidy_temp(Temp,Temp0),!. change_laters([before(0,Num2)|Temp],Num,[before(Num,Num2)|Temp0]):- change_laters(Temp,Num,Temp0). change_laters([before(Num1,0)|Temp],Num,[before(Num1,0)|Temp0]):- change_laters(Temp,Num,Temp0). change_laters([before(Num1,Num2)|Temp],Num,[before(Num1,Num2)|Temp0]):- change_laters(Temp,Num,Temp0). % change the states to primitive states make_se_primitive([],[]). make_se_primitive([se(Sort,Obj,ST)|SE],[se(Sort,Obj,ST)|SE0]):- objectsC(Sort,Objls),!, make_se_primitive(SE,SE0). make_se_primitive([se(Sort,Obj,ST)|SE],[se(PSort,Obj,ST)|SE0]):- find_prim_sort(Sort,PSorts), member(PSort,PSorts), make_se_primitive(SE,SE0). % change the state changes to primitive states make_sc_primitive([],[]). make_sc_primitive([sc(Sort,Obj,SE1=>SE2)|ST],[sc(Sort,Obj,SE1=>SE2)|ST0]):- objectsC(Sort,Objls),!, make_sc_primitive(ST,ST0). make_sc_primitive([sc(Sort,Obj,SE1=>SE2)|ST],[sc(PSort,Obj,SE1=>SE2)|ST0]):- find_prim_sort(Sort,PSorts), member(PSort,PSorts), make_sc_primitive(ST,ST0). % ------------ end of change operator ---------------------- /********make_tn: save the expansion results*****/ make_tn(TN,Name,Pre,Post,Temp,Dec):- gensym(tn,TN), find_only_changed(Pre,Post,[],Pre1,[],Post1), % tell(user),nl,write(tn(TN,Name,Pre1,Post1,Temp,Dec)),nl,told, assert(tn(TN,Name,Pre1,Post1,Temp,Dec)),!. find_only_changed([],[],Pre,Pre,Post,Post):-!. % just a lazy check if they are in exactly same sequence find_only_changed([se(Sort,Obj,ST)|Pre],[se(Sort,Obj,ST)|Post],Pre0,Pre1,Post0,Post1):- find_only_changed(Pre,Post,Pre0,Pre1,Post0,Post1),!. find_only_changed([se(Sort,Obj,ST)|Pre],Post,Pre0,Pre1,Post0,Post1):- member(se(Sort,Obj,ST1),Post), list_take(Post,[se(Sort,Obj,ST1)],Post2), append_changed(se(Sort,Obj,ST),se(Sort,Obj,ST1),Pre0,Pre3,Post0,Post3), find_only_changed(Pre,Post2,Pre3,Pre1,Post3,Post1),!. find_only_changed([se(Sort,Obj,ST)|Pre],Post,Pre0,Pre1,Post0,Post1):- member(se(SortN,Obj,ST1),Post), list_take(Post,[se(SortN,Obj,ST1)],Post2), append_changed(se(Sort,Obj,ST),se(SortN,Obj,ST1),Pre0,Pre3,Post0,Post3), find_only_changed(Pre,Post2,Pre3,Pre1,Post3,Post1),!. % other fail. % append statics, and check its consistent statics_append([],L,L):- statics_consist_instance(L),!. statics_append(L,[],L):- statics_consist_instance(L),!. statics_append(List1,List2,L):- statics_consist_instance(List1), statics_consist_instance(List2), statics_append1(List1,List2,[],L), statics_consist_instance(L). statics_append1([],List2,L1,L):- append(List2,L1,L),!. statics_append1([H|List1],List2,L,Z) :- statics_append0(H,List2,L,L1), statics_append1(List1,List2,L1,Z). statics_append0(H,[],L,[H|L]). statics_append0(H,[H|Z],L,L). statics_append0(H,[X|Z],L1,L):- statics_append0(H,Z,L1,L). % append only changed states % state_match here means not changed append_changed(se(Sort,Obj,ST),se(Sort1,Obj,ST1),Pre0,Pre0,Post0,Post0):- state_match(Sort,Obj,ST,ST1),!. append_changed(se(Sort,Obj,ST),se(Sort1,Obj,ST1),Pre0,Pre3,Post0,Post3):- append(Pre0,[se(Sort,Obj,ST)],Pre3), append(Post0,[se(Sort,Obj,ST1)],Post3),!. %***********print out solution************************** push_to_primitive([],PHPs,PHPs) :-!. push_to_primitive([step(HPID,_,_,_,exp(TN))|HPs],List,PHPs) :- tn(TN,Name,Pre,Post,Temp,Dec), push_to_primitive(Dec,List,Dec1), push_to_primitive(HPs,Dec1,PHPs),!. push_to_primitive([step(HPID,_,_,_,exp(Name))|HPs],List,PHPs):- append(List,[Name],List1), push_to_primitive(HPs,List1,PHPs),!. push_to_primitive([],PHPs,PHPs,TNLst,TNLst) :-!. push_to_primitive([step(HPID,_,_,_,exp(TN))|HPs],List,PHPs,TNSoFar,TNFinal) :- tn(TN,Name,Pre,Post,Temp,Dec), push_to_primitive(Dec,List,Dec1,[tn(TN,Name,Pre,Post,Temp,Dec)|TNSoFar],TNNext), push_to_primitive(HPs,Dec1,PHPs,TNNext,TNFinal),!. push_to_primitive([step(HPID,_,_,_,exp(Name))|HPs],List,PHPs,TNSoFar,TNFinal):- append(List,[Name],List1), push_to_primitive(HPs,List1,PHPs,TNSoFar,TNFinal),!. /*********** TEMPORAL AND DECLOBBERING ************/ possibly_before(I,J,Temps) :- \+ necessarily_before(J,I,Temps), !. necessarily_before(J,I,Temps) :- member(before(J,I),Temps),!. necessarily_before(J,I,Temps) :- member(before(J,Z),Temps), necessarily_before(Z,I,Temps),!. select_node(node(Name,Pre,Temp,Decomp,Statics)) :- retract(node(Name,Pre,Temp,Decomp,Statics)), % nl,nl,write(Name),write(' RETRACTED'),nl,nl, % tell(user), % nl,nl,write(Name),write(' RETRACTED'),nl,nl, % tell(FF), !. /******************* hierarchy utilities**************************/ % grounding predicates to object level % assert in prolog database as gpredicates(Pred,GPredls) ground_predicates:- predicates(Preds), grounding_preds(Preds), collect_grounded_pred,!. grounding_preds([]). % if it is statics, only choose within atomic_invariants grounding_preds([HPred|TP]):- functor(HPred,FF,NN), functor(APred,FF,NN), atomic_invariants(Atom), member(APred,Atom), ground_all_var_atom(HPred), grounding_preds(TP). % else, combine all the objects grounding_preds([HPred|TP]):- functor(HPred,FF,NN), functor(GPred,FF,NN), ground_all_var(GPred,HPred), grounding_preds(TP). % collect all the grounded predicates together collect_grounded_pred:- gpred(Pred,_), setof(GPred,gpred(Pred,GPred),GPredls), retractall(gpred(Pred,_)), assert(gpredicates(Pred,GPredls)), fail. collect_grounded_pred. ground_all_var_atom(HPred):- functor(HPred,FF,NN), functor(GPred,FF,NN), functor(APred,FF,NN), atomic_invariants(Atom), member(APred,Atom), GPred=..[Name|Vars], APred=..[Name|Sorts], ground_all_var_atom0(Vars,Sorts), assert_gpred(GPred), fail. ground_all_var_atom(HPred). ground_all_var_atom0([],[]). ground_all_var_atom0([HVars|TV],[HSorts|TS]):- subsorts(HSorts,Subsorts), split_prim_noprim(Subsorts,PSorts,NPSorts), member(LS,PSorts), objectsC(LS,Objls), member(HVars,Objls), ground_all_var_atom0(TV,TS). ground_all_var_atom0([HVar|TV],[HASorts|TS]):- objectsC(Sorts,Objls), member(HASorts,Objls), HVar=HASorts, ground_all_var_atom0(TV,TS). ground_all_var(GPred,HPred):- GPred=..[Name|Vars], HPred=..[Name|Sorts], ground_all_var0(Vars,Sorts), not(inconsistent_constraint([GPred])), assert_gpred(GPred), fail. ground_all_var(GPred,HPred). ground_all_var0([],[]). ground_all_var0([HVars|TV],[HSorts|TS]):- objectsC(HSorts,Objls), member(HVars,Objls), ground_all_var0(TV,TS). ground_all_var0([HVars|TV],[HSorts|TS]):- subsorts(HSorts,Subsorts), split_prim_noprim(Subsorts,PSorts,NPSorts), member(LS,PSorts), objectsC(LS,Objls), member(HVars,Objls), ground_all_var0(TV,TS). % assert grounded predicates with related upper level predicates assert_gpred(GPred):- functor(GPred,FF,NN), functor(UPred,FF,NN), assert_gpred0(GPred,UPred),!. assert_gpred0(GPred,UPred):- GPred=..[Name|PSorts], UPred=..[Name|Vars], get_obj_prim_sort(Vars,PSorts), assert(gpred(UPred,GPred)), fail. assert_gpred0(GPred,UPred). get_obj_prim_sort([],[]):-!. get_obj_prim_sort([HSort|TV],[HObj|TS]):- is_of_primitive_sort(HObj,HSort), get_obj_prim_sort(TV,TS),!. /* is_of_primitive_sort(X,Y) :- objectsC(Y,L),member(X,L). is_of_sort(X,Y) :- is_of_primitive_sort(X,Y). is_of_sort(X,Y) :- sorts(Y,SL),member(Z,SL),is_of_sort(X,Z). */ find_all_upper([],[]). find_all_upper([HVars|TV],[HSorts|TS]):- uppersorts(HSorts,Upsorts), member(HVars,Upsorts), find_all_upper(TV,TS). % find out primitive sorts of a sort. find_prim_sort(Sort,PS):- subsorts(Sort,Subsorts), split_prim_noprim(Subsorts,PS,NP),!. % find out the objects of a sort get_sort_objects(Sort,Objs):- find_prim_sort(Sort,PSorts), get_objects1(PSorts,Objls), flatten(Objls,[],Objs),!. get_objects1([],[]):-!. get_objects1([PS1|RS],[Objls1|Objls]):- objectsC(PS1,Objls1), get_objects1(RS,Objls),!. % find subsorts of a sort(exclude). subsortse(Sort,Subsorts):- subsorts(Sort,Subsorts1), list_take(Subsorts1,[Sort],Subsorts),!. % find subsorts of a sort(include). subsorts(Sort,Subsorts):- sort_down([Sort],[],Subsorts),!. sort_down([],Subsorts,Subsorts):-!. sort_down([HOpen|TOpen],List,Subsorts):- objectsC(HOpen,Objls), append(List,[HOpen],List1), sort_down(TOpen,List1,Subsorts),!. sort_down([HOpen|TOpen],List,Sortslist):- sorts(HOpen,Sorts), sort_down(Sorts,List,List2), sort_down(TOpen,[HOpen|List2],Sortslist),!. sort_down([HOpen|TOpen],List,Subsorts):- %if it is not defined as objects or sorts, assume it's primitive append(List,[HOpen],List1), sort_down(TOpen,List1,Subsorts),!. % find uppersorts of a sort(excludes). uppersortse(Sort,Uppersorts):- uppersorts(Sort,Uppersortsf), list_take(Uppersortsf,[Sort],Uppersorts),!. % find uppersorts of a sort or object(include). uppersorts(Sort,Uppersorts):- objectsC(Sort,Objls), sort_up(Sort,[Sort],Uppersorts),!. uppersorts(Sort,Uppersorts):- sorts(Sort,Sortls), sort_up(Sort,[Sort],Uppersorts),!. uppersorts(Obj,Sortls):- objectsC(Sort,Objls), member(Obj, Objls), sort_up(Sort,[Sort],Sortls),!. sort_up(Sort, List,Sortslist):- sorts(NPSort, NPSortls), NPSort \== non_primitive_sorts, NPSort \== primitive_sorts, member(Sort,NPSortls), sort_up(NPSort,[NPSort|List],Sortslist). sort_up(Sort, List,List):-!. % sametree: Sort1 and Sort2 are in same sort tree. sametree(Sort1,Sort2):- Sort1==Sort2,!. sametree(Sort1,Sort2):- var(Sort1),!. sametree(Sort1,Sort2):- var(Sort2),!. sametree(Sort1,Sort2):- uppersorts(Sort2,Sortls), member(Sort1,Sortls),!. sametree(Sort1,Sort2):- uppersorts(Sort1,Sortls), member(Sort2,Sortls),!. % split a sortlist to primitive sorts and non-primitive sorts. split_prim_noprim([],[],[]):-!. split_prim_noprim([HS|TS],[HS|TP],NP):- objectsC(HS,Obj), split_prim_noprim(TS,TP,NP),!. split_prim_noprim([HS|TS],PS,[HS|NP]):- split_prim_noprim(TS,PS,NP),!. /***************** local utils *****************/ /*********** DOMAIN MODEL FUNCTIONS *****************/ get_invariants(Invs) :- atomic_invariants(Invs),!. rem_statics([sc(S,X,Lhs=>Rhs)|ST], [sc(S,X,LhsR=>RhsR)|STR],Rt1) :- split_st_dy(Lhs,[],LR, [],LhsR), split_st_dy(Rhs,[],RR,[],RhsR), append(LR,RR,R), rem_statics(ST, STR,Rt), append(Rt,[is_of_sort(X,S)|R],Rt1),!. rem_statics([ss(S,X,Preds)|Post], [ss(S,X,PredR)|PostR],Rt1) :- split_st_dy(Preds,[],R, [],PredR), rem_statics(Post, PostR,Rt), append(Rt,[is_of_sort(X,S)|R],Rt1),!. rem_statics([se(S,X,Preds)|Post], [se(S,X,PredR)|PostR],Rt1) :- split_st_dy(Preds,[],R, [],PredR), rem_statics(Post, PostR,Rt), append(Rt,[is_of_sort(X,S)|R],Rt1),!. rem_statics([], [],[]) :-!. % ----------------------utilities--------------------- not(X):- \+X. isemptylist([]):-!. member(X,[X|_]). member(X,[_|L]) :- member(X,L). member_cut(X,[X|_]) :- !. member_cut(X,[_|Y]) :- member_cut(X,Y),!. % member_e: X is the exact memeber of List member_e(X,[Y|_]):- X==Y,!. member_e(X,[Y|L]):- var(Y), member_e(X,L),!. member_e(ss(Sort,Obj,SE),[ss(Sort,Obj1,SE)|_]):- Obj==Obj1,!. member_e(se(Sort,Obj,SE),[se(Sort,Obj1,SE)|_]):- Obj==Obj1,!. member_e(sc(Sort,Obj,SE1=>SE2),[sc(Sort,Obj1,SE1=>SE2)|_]):- Obj==Obj1,!. member_e(X,[Y|L]):- member_e(X,L),!. % u_mem in ob_utils is SLOW!?. % this is a fast impl. u_mem_cut(_,[]):-!,fail. u_mem_cut(X,[Y|_]) :- X == Y,!. u_mem_cut(X,[_|L]) :- u_mem_cut(X,L),!. % check if object X is a member of a objects list % 1. if it is not a variable, check if it is in the list % 2. X is a variable, and the list only has one objects, make X as that obj % 3. X is a variable, but the list has more than one objects, leave X unchange obj_member(X,[X|[]]):-!. obj_member(X,List):- obj_member0(X,List),!. obj_member0(X,[Y|_]):- var(X),!.%if X is var, but Y not, the leave X as that variable obj_member0(X,[Y|_]):- X==Y,!. obj_member0(X,[_|Y]) :- obj_member0(X,Y),!. % check if a predicate is a member of a ground predicate list, % just used in binding the predicates to a sort without instantiate it % for efficiency, instantiate the variable if the list only have one atom pred_member(X,List):- setof(X,member(X,List),Refined), pred_member0(X,Refined),!. pred_member0(X,[X|[]]):-!. pred_member0(X,Y):- pred_member1(X,Y),!. pred_member1(X,[Y|_]):- X=..[H|XLs], Y=..[H|YLs], vequal(XLs,YLs),!. pred_member1(X,[_|Y]):- pred_member1(X,Y),!. append([],L,L):-!. append([H|T],L,[H|Z]) :- append(T,L,Z),!. append_cut([],L,L) :- !. append_cut([H|T],L,[H|Z]) :- append_cut(T,L,Z),!. % set_append: list * list -> list (no duplicates) % ----------------------------------------------- set_append([], Z, Z):-! . set_append([A|B], Z, C) :- not(not(member(A, Z))) , set_append(B, Z, C),! . set_append([A|B], Z, [A|C]) :- set_append(B, Z, C) . % append_st: append two statics % remove the constants that no need % instanciate the viables that all ready been bind % ------------------------------------------ append_st(ST1,ST2,ST):- append_cut(ST1,ST2,ST0), remove_unneed(ST0,[],ST),!. % remove the constants that no need % instanciate the variables that all ready been bind remove_unneed([],C,C):-!. remove_unneed([A|B], Z, C):- var(A), member_e(A,Z), remove_unneed(B, Z, C),! . remove_unneed([A|B], Z, C):- var(A), append(Z,[A],D), remove_unneed(B, D, C),!. remove_unneed([A|B], Z, C):- ground(A), remove_unneed(B, Z, C),!. remove_unneed([A|B], Z, C):- A=..[ne|Paras], append(Z,[A],D), remove_unneed(B, D, C),!. remove_unneed([A|B], Z, C):- A=..[Pred|Paras], same_var_member(A,Z), remove_unneed(B, Z, C),!. remove_unneed([A|B], Z, C):- append(Z,[A],D), remove_unneed(B, D, C),!. same_var_member(Pred,[Pred1|List]):- var(Pred1), same_var_member(Pred,List),!. same_var_member(Pred,[Pred1|List]):- Pred==Pred1,!. same_var_member(Pred,[Pred1|List]):- Pred=..[H|T], Pred1=..[H|T1], same_var_member1(T,T1),!. same_var_member(Pred,[Pred1|List]):- same_var_member(Pred,List),!. same_var_member1([],[]):-!. same_var_member1([H1|T],[H2|T]):- var(H1), H1==H2,!. same_var_member1([H|T1],[H|T2]):- var(T1), T1==T2,!. same_var_member1([H1|T1],[H2|T2]):- H1==H2, same_var_member1(T1,T2),!. % set_append_e: list1 + list2 -> list % no duplicate, no instanciation % ------------------------------------------ set_append_e(A,B,C):- append_cut(A,B,D), remove_dup(D,[],C),!. % remove duplicate remove_dup([],C,C):-!. remove_dup([A|B],Z,C) :- member_e(A, Z), remove_dup(B, Z, C),! . remove_dup([A|B], Z, C):- append(Z,[A],D), remove_dup(B, D, C),!. vequal([],[]):-!. vequal([X|XLs],[Y|YLs]):- var(X), vequal(XLs,YLs),!. vequal([X|XLs],[Y|YLs]):- var(Y), vequal(XLs,YLs),!. vequal([X|XLs],[Y|YLs]):- X==Y, vequal(XLs,YLs),!. % subtract(A,B,C): subtract B from A % ------------------------------------- subtract([],_,[]):-!. subtract([A|B],C,D) :- member(A,C), subtract(B,C,D),!. subtract([A|B],C,[A|D]) :- subtract(B,C,D),!. /* arg1 - arg2 = arg3 */ list_take(R,[E|R1],R2):- remove_el(R,E,RR), list_take(RR,R1,R2),!. list_take(R,[_|R1],R2):- list_take(R,R1,R2),!. list_take(A,[],A) :- !. % remove_el: list * el -> list-el % ---------------------------------- remove_el([],_,[]) :- ! . remove_el([A|B],A,B) :- ! . remove_el([A|B],C,[A|D]) :- remove_el(B,C,D) . /* generate symbol predicate (from file futile)*/ gensym(Root,Atom) :- getnum(Root,Num), name(Root,Name1), name(Num,Name2), append(Name1,Name2,Name), name(Atom,Name). getnum(Root,Num) :- retract(current_num(Root,Num1)),!, Num is Num1+1, asserta(current_num(Root,Num)). getnum(Root,1) :- asserta(current_num(Root,1)). gensym_num(Root,Num,Atom):- name(Root,Name), name(Num,Name1), append(Name,Name1,Name2), name(Atom,Name2),!. pprint([],SIZE,SIZE):-!. pprint([HS|TS],Size0,SIZE):- list(HS), pprint(HS,Size0,Size1), pprint(TS,Size1,SIZE),!. pprint([HS|TS],Size0,SIZE):- % write('step '),write(Size0),write(': '), % write(HS),nl, Size1 is Size0+1, pprint(TS,Size1,SIZE),!. /* split static and dynamic from states*/ split_st_dy([],ST,ST,DY,DY):-!. split_st_dy([Pred|TStates],ST0,ST,DY0,DY):- is_statics(Pred), append_cut(ST0,[Pred],ST1), split_st_dy(TStates,ST1,ST,DY0,DY),!. split_st_dy([Pred|TStates],ST0,ST,DY0,DY):- append_cut(DY0,[Pred],DY1), split_st_dy(TStates,ST0,ST,DY1,DY),!. % list of lists -> list flatten([HO|TO], List, O_List):- append(HO, List, List_tmp), flatten(TO, List_tmp, O_List),!. flatten([H|TO], List,O_List):- append([H], List, List_tmp), flatten(TO, List_tmp, O_List). flatten([], [HList|T], O_List):- HList = [], flatten(T, [], O_List). flatten([], [HList|T], O_List):- list(HList), flatten([HList|T],[], O_List),!. flatten([], L,L):-!. % flatten with no duplicate set_flatten([HO|TO], List, O_List):- set_append_e(HO, List, List_tmp), set_flatten(TO, List_tmp, O_List),!. set_flatten([H|TO], List,O_List):- set_append_e([H], List, List_tmp), set_flatten(TO, List_tmp, O_List). set_flatten([], [HList|T], O_List):- HList = [], set_flatten(T, [], O_List). set_flatten([], [HList|T], O_List):- list(HList), set_flatten([HList|T],[], O_List),!. set_flatten([], L,L):-!. % list: [el1,el2, ...] --> bool % ----------------------------- list(A) :- var(A) , ! , fail . list(A) :- functor(A,'.',_). % ***********************for multy tasks***************** :- assert(time_taken(0)). :- assert(soln_size(0)). solve(N,FN):- N < FN, nl,write('task '), write(N),write(': '),nl, solve(N), Ni is N+1, solve(Ni,FN). solve(FN,FN):- nl,write('task '), write(FN),write(': '),nl, solve(FN), retractall(sum(_)), assert(sum(0)), sum_time(CP), retractall(sum(_)), assert(sum(0)), sum_size(SIZE), TIM is CP /1000, retractall(time_taken(_)), retractall(soln_size(_)), nl,write('total time '),write(TIM),write(' seconds'), nl,write('total size '),write(SIZE),nl. solve(FN,FN). sum_time(TIM):- time_taken(CP), retract(sum(N)), N1 is N +CP, assert(sum(N1)), fail. sum_time(TIM):- sum(TIM). sum_size(SIZE):- soln_size(S), retract(sum(N)), N1 is N +S, assert(sum(N1)), fail. sum_size(SIZE):- sum(SIZE). stoppoint. % State1 has relation with State2 % there are objects in action that same with goal state_related(Post,Cond,undefd):-!. state_related(Post,Cond,[]):-!. state_related(Post,Cond,State2):- append_cut(Post,Cond,State1), state_related(State1,State2). state_related([se(Sort1,Obj,SE1)|State1],State2):- member(se(Sort2,Obj,SE2),State2), is_of_sort(Obj,Sort1), is_of_sort(Obj,Sort2). state_related([sc(Sort1,Obj,SE1=>SS1)|State1],State2):- member(se(Sort2,Obj,SE2),State2), is_of_sort(Obj,Sort1), is_of_sort(Obj,Sort2). state_related([se(Sort1,Obj,SE1)|State1],State2):- state_related(State1,State2),!. state_related([sc(Sort1,Obj,SE1=>SS1)|State1],State2):- state_related(State1,State2),!. % change_obj_list: narrow down objects % by just using the objects occure in initial states(world state) change_obj_list:- find_all_dynamic_objects, change_obj_list1, change_atomic_inv,!. change_obj_list(I):- find_dynamic_objects(I), collect_dynamic_obj, change_obj_list1, change_atomic_inv,!. change_obj_list1:- objects(Sort,OBjls), change_obj_list2(Sort), fail. change_obj_list1. % dynamic objects: only keep the dynamic objects that used in tasks change_obj_list2(Sort):- objectsC(Sort,Objls),!. % statics objects: keep change_obj_list2(Sort):- objects(Sort,Objls), assert(objectsC(Sort,Objls)),!. find_all_dynamic_objects:- setof(Init, Id^Goal^htn_task(Id,Goal,Init), All_Init), find_dynamic_obj(All_Init), collect_dynamic_obj. find_all_dynamic_objects:- setof(Init, Id^Goal^planner_task(Id,Goal,Init), All_Init), find_dynamic_obj(All_Init), collect_dynamic_obj. find_dynamic_obj([]):-!. find_dynamic_obj([SE|Rest]):- find_dynamic_obj(SE), find_dynamic_obj(Rest),!. find_dynamic_obj(ss(Sort,Obj,_)):- assert(objectsD(Sort,Obj)),!. collect_dynamic_obj:- objectsD(Sort,_), setof(Obj, objectsD(Sort,Obj), Objls), retractall(objectsD(Sort,_)), assert(objectsC(Sort,Objls)), fail. collect_dynamic_obj. get_preconditions_g([],Prev,Prev,Prev) :-!. get_preconditions_g([sc(S,X,From =>To)|Rest],Prev,[se(S,X,From1)|Pre],[se(S,X,To1)|Post]):- member_cut(se(S,X,PSE),Prev), append_cut(PSE,From,From1), append_cut(PSE,To,To1), list_take(Prev,[se(S,X,PSE)],Prev1), get_preconditions_g(Rest,Prev1, Pre,Post),!. get_preconditions_g([sc(S,X,From =>To)|Rest],Prev,[se(S,X,From)|Pre],[se(S,X,To)|Post]):- get_preconditions_g(Rest,Prev, Pre,Post),!. % only keep the dynamic objects in atomic_invariants change_atomic_inv:- atomic_invariants(Atom), change_atomic_inv1(Atom,Atom1), assert(atomic_invariantsC(Atom1)),!. change_atomic_inv. change_atomic_inv1([],[]). change_atomic_inv1([Pred|Atom],[Pred|Atom1]):- Pred=..[Name|Objs], just_dynamic_objects(Objs), change_atomic_inv1(Atom,Atom1). change_atomic_inv1([Pred|Atom],Atom1):- change_atomic_inv1(Atom,Atom1). just_dynamic_objects([]). just_dynamic_objects([Head|Objs]):- objectsC(Sort,Objls), member(Head,Objls),!, just_dynamic_objects(Objs). find_dynamic_objects([]):-!. find_dynamic_objects([SE|Rest]):- find_dynamic_objects(SE), find_dynamic_objects(Rest),!. find_dynamic_objects(ss(Sort,Obj,_)):- assert(objectsD(Sort,Obj)),!. % ******************************************************************** % ground all operators% enumerateOps ground_op :- assert_sort_objects, enumerateOps, instOps. % opCounter(Top), % write(Top),nl. enumerateOps :- retractall(opCounter), assert(opCounter(1)), enumOps. enumOps :- operator(Name,Prev,Nec,Cond), retract(opCounter(Count)), containsInvars(operator(Name,Prev,Nec,Cond),InVars,IsOfSorts,FPrev,FNec), %Find the atomic_invariants findVarsAndTypes(operator(Name,Prev,Nec,Cond),VT,NEs), assert(opParent(Count,operator(Name,FPrev,FNec,Cond),VT,NEs,InVars,IsOfSorts)), Next is Count + 1, assert(opCounter(Next)), fail. enumOps. % ********************************************************************* % findVarsAndTypes - collect a list of all variables and their % types as they occur in an operator % also collect the list of "ne" constraints % that apply to variables % [<Type>,<Variable>|<Rest>] % % findVarsAndTypes(+Operator,-TypeVarList,-Nes) findVarsAndTypes(operator(_,Pre,Nec,Cond),Vars,NEs) :- vtPrevail(Pre,PreVars,PreNEs), vtEffects(Nec,NecVars,NecNEs), append(PreVars,NecVars,Vars), append(PreNEs,NecNEs,NEs), !. % collect all Vars and types in a changes clause %vtEffects(+EffectsClause,-VarsTypes,-NEClauses). vtEffects([],[],[]). vtEffects([sc(Type,Obj1,Preds)|Rest],VT,NEs) :- vtPreds(Preds,Related,NEs1), append([Type,Obj1],Related,Obj1VT), vtEffects(Rest,RestVT,RestNEs), append(Obj1VT,RestVT,VT), append(NEs1,RestNEs,NEs). % collect all Vars and types in a Prevail clause %vtPrevail(+PrevailClause,-VarsTypes,-NEClauses). vtPrevail([],[],[]). vtPrevail([se(Type,Obj1,Preds)|Rest],VT,NEs) :- vtPLst(Preds,Related,NEs1), append([Type,Obj1],Related,Obj1VT), vtPrevail(Rest,RestVT,RestNEs), append(Obj1VT,RestVT,VT), append(NEs1,RestNEs,NEs). % Deal with the change predicates in a changes clause % vtPreds(+ChangeProps,-VarsTypes,-NEClauses). vtPreds((Pre => Add),Res,NEs) :- vtPLst(Pre,VTPre,NEs1), vtPLst(Add,VTAdd,NEs2), append(VTPre,VTAdd,Res), append(NEs1,NEs2,NEs). % Deal with a list of literals % vtPLst(+Literals,-VarTypes,-NEClauses). vtPLst([],[],[]). vtPLst([ne(X,Y)|Rest],Res,[ne(X,Y)|RestNEs]) :- !, vtPLst(Rest,Res,RestNEs). vtPLst([Pred|Preds],Res,NEs) :- functor(Pred,_,1), !, vtPLst(Preds,Res,NEs). vtPLst([is_of_sort(_,_)|Preds],Res,NEs) :- !, vtPLst(Preds,Res,NEs). % here is the hard bit, Create a dummy literal - instantiate it with % the OCL predicate list to find the types then % match up the type with the original literal variables. vtPLst([Pred|Preds],Res,NEs) :- functor(Pred,Name,Arity), Pred =.. [Name,Obj1|Rest], VNeeded is Arity - 1, createVarList(VNeeded,VN), DummyPred =.. [Name,X|VN], predicates(PList), member(DummyPred,PList), pair(VN,Rest,This), vtPLst(Preds,RestPre,NEs), append(This,RestPre,Res). % Create a list of new uninstantiated variables % createVarList(+NoOfVariablesNeeded, -ListOfvariables). createVarList(1,[X]) :- !. createVarList(N,[X|Rest]) :- Next is N - 1, createVarList(Next,Rest). % merge the list of variables and the list of types % pair(+TypeList,+VarList,-varTypeList). pair([],[],[]). pair([Type|Types],[Var|Vars],[Type,Var|Rest]) :- pair(Types,Vars,Rest). % ********************************************************************** % Top Level Routine to instantiate / ground operators in all legal ways % % instOps instOps :- retractall(opCounter(_)), assert(opCounter(1)), opParent(No,Operator,VT,NEs,InVars,IsOfSorts), checkIsOfSorts(IsOfSorts), checkInVars(InVars), chooseVals(VT,NEs,InVars,Vals), obeysNEs(NEs), retract(opCounter(Count)), operator(Name,Prev,Nec,Cond) = Operator, filterSE(Prev,FPrev), filterSC(Nec,FNec), assert(gOperator(Count,No,operator(Name,FPrev,FNec,Cond))), Next is Count + 1, assert(opCounter(Next)), Next>2000. instOps. checkInVars([]):- !. checkInVars(Preds):- atomic_invariantsC(Invars), doCheckInvars(Preds,Invars). doCheckInvars([],_). doCheckInvars([Pred|Rest],Invars) :- member(Pred,Invars), doCheckInvars(Rest,Invars). checkIsOfSorts([]). checkIsOfSorts([is_of_sort(V,Sort)|Rest]) :- objectsOfSort(Sort,Objs), member(V,Objs), checkIsOfSorts(Rest). % filterSE - remove ne and is_of_sort clauses filterSE([],[]) :- !. filterSE([se(Sort,Id,Preds)|Rest],[se(Sort,Id,FPreds)|FRest]) :- filterPreds(Preds,FPreds),!, filterSE(Rest,FRest). % filterSC - remove ne and is_of_sort clauses filterSC([],[]) :- !. filterSC([sc(Sort,Id,(Pre => Post))|Rest],[sc(Sort,Id,(FPre => FPost))|FRest]) :- filterPreds(Pre,FPre), filterPreds(Post,FPost), !, filterSC(Rest,FRest). % FilterPreds - remove ne and is_of_sort clauses filterPreds([],[]). filterPreds([ne(_,_)|Rest],FRest) :- !, filterPreds(Rest,FRest). filterPreds([is_of_sort(_,_)|Rest],FRest) :- !, filterPreds(Rest,FRest). %filterPreds([Pred|Rest],FRest) :- % atomic_invariantsC(Invars), % member(Pred,Invars), % !, % filterPreds(Rest,FRest). filterPreds([H|T],[H|FT]) :- filterPreds(T,FT). % Collect all possible ways of instantiating the conditional effects collectAllConds(_,_,_,_,[],[]) :- !. collectAllConds(CondVT,NEs,InVars,CondVals,Cond,_) :- retractall(temp(_)), chooseVals(CondVT,NEs,InVars,Vals), assertIndivConds(Cond), fail. collectAllConds(_,_,_,_,_,NewConds) :- setof(Cond,temp(Cond),NewConds). assertIndivConds([]) :- !. assertIndivConds([H|T]) :- assert(temp(H)), assertIndivConds(T). % Find the atomic_invariants in the Operator containsInvars(operator(Name,Prev,Nec,Cond),InVars,IsOfSorts,FPrev,FNec) :- prevInvars(Prev,PInVars,PIsOfSorts,FPrev), necInvars(Nec,NecInVars,NIsOfSorts,FNec), append(NecInVars,PInVars,InVars), append(PIsOfSorts,NIsOfSorts,IsOfSorts), !. prevInvars([],[],[],[]). prevInvars([se(Type,Obj,Props)|Rest],InVars,IsOfSorts,[se(Type,Obj,FProps)|RFPrev]) :- propsInvars(Props,PInvars,PIsOfSorts,FProps), prevInvars(Rest,RInVars,RIsOfSorts,RFPrev), append(PInVars,RInVars,InVars), append([is_of_sort(Obj,Type)|PIsOfSorts],RIsOfSorts,IsOfSorts). necInvars([],[],[],[]). necInvars([sc(Type,Obj,(Props => Adds))|Rest],Invars,IsOfSorts,[sc(Type,Obj,(FProps => FAdds))|RFNec]) :- propsInvars(Props,PInvars,PIsOfSorts,FProps), propsInvars(Adds,AInvars,AIsOfSorts,FAdds), necInvars(Rest,RInvars,RIsOfSorts,RFNec), append(AInvars,PInvars,Temp), append(Temp,RInvars,Invars), append(PIsOfSorts,AIsOfSorts,SortsTemp), append([is_of_sort(Obj,Type)|SortsTemp],RIsOfSorts,IsOfSorts). propsInvars([],[],[],[]). propsInvars([Prop|Props],[Prop|Rest],IsOfSorts,FProps) :- isInvariant(Prop), !, propsInvars(Props,Rest,IsOfSorts,FProps). propsInvars([is_of_sort(X,Y)|Props],InVars,[is_of_sort(X,Y)|IsOfSorts],FProps):- !, propsInvars(Props,InVars,IsOfSorts,FProps). propsInvars([Pred|Props],Rest,IsOfSorts,[Pred|FProps]) :- propsInvars(Props,Rest,IsOfSorts,FProps). isInvariant(Prop) :- atomic_invariantsC(Invars), functor(Prop,Name,Arity), createVarList(Arity,VN), Pred =.. [Name | VN], member(Pred,Invars). % Select values for the variables in the operator % % chooseVals(+TypeVarList,+NEList,+Invariants,-VarValueList) chooseVals([],_,_,[]). chooseVals([Type,Var|TypeVars],NEs,InVars,Vals) :- ground(Var), !, chooseVals(TypeVars,NEs,InVars,Vals). chooseVals([Type,Var|TypeVars],NEs,InVars,[Var|Vals]) :- objectsOfSort(Type,AllVals), member(Var,AllVals), chooseVals(TypeVars,NEs,InVars,Vals). %% For hierarchical domains assert the objects that belong to every sort %% including hierarchical sorts. assert_sort_objects :- objectsC(Type,Objects), assert(objectsOfSort(Type,Objects)), fail. assert_sort_objects :- sorts(Type,SubTypes), Type \== primitive_sorts, Type \== non_primitive_sorts, all_objects(Type,Objs), assert(objectsOfSort(Type,Objs)), fail. assert_sort_objects. all_objects(Type,Objs) :- objectsC(Type,Objs), !. all_objects(Type,Objs) :- sorts(Type,SubSorts), !, collect_subsort_objects(SubSorts,Objs). all_objects(Type,[]) :-!. collect_subsort_objects([],[]). collect_subsort_objects([Sort|Rest],Objs ) :- all_objects(Sort,SortObjs), !, collect_subsort_objects(Rest,RestObjs), append(SortObjs,RestObjs,Objs). obeysNEs([]). obeysNEs([ne(V1,V2)|Rest]) :- V1 \== V2, obeysNEs(Rest). obeysInVars([]). obeysInVars([Prop|Rest]) :- atomic_invariantsC(Invars), member(Prop,Invars), !. % ********************************************************************** % prettyPrinting Routines for ground OCL operators % long and boring % prettyPrintOp(+<Ground Operator>) prettyPrintOp(gOperator(No,Par,Op)) :- write('gOperator('), write(No),write(','), write(Par),write(','),nl, writeOp(4,Op), !. writeOp(TabVal,operator(Name,Prev,Nec,Cond)) :- tab(TabVal), write('operator('),write(Name),write(','),nl, tab(8),write('% Prevail'),nl, tab(8),write('['),nl, writePrevailLists(8,Prev), tab(8),write('],'),nl, tab(8),write('% Necessary'),nl, tab(8),write('['),nl, writeChangeLists(10,Nec), tab(8),write('],'),nl, tab(8),write('% Conditional'),nl, tab(8),write('['),nl, writeChangeLists(10,Cond), tab(8),write('])).'),nl. writePropList(TabVal,[]) :- tab(TabVal), write('[]'). writePropList(TabVal,[ne(_,_)|Props]) :- !, writePropList(Indent,Props). writePropList(TabVal,[Prop|Props]) :- atomic_invariantsC(Invars), member(Prop,Invars), writePropList(TabVal,Props). writePropList(TabVal,[Prop|Props]) :- tab(TabVal), write('['), write(Prop), Indent is TabVal + 1, writePList(Indent,Props). writePList(TabVal,[]) :- nl, tab(TabVal), write(']'). writePList(TabVal,[ne(_,_)]) :- !, nl, tab(TabVal), write(']'). writePList(TabVal,[Prop]) :- atomic_invariantsC(Invars), member(Prop,Invars), !, nl, tab(TabVal), write(']'). writePList(TabVal,[Prop]) :- write(','), nl, tab(TabVal), write(Prop), write(']'). writePList(TabVal,[ne(_,_),P2|Rest]) :- !, writePList(TabVal,[P2|Rest]). writePList(TabVal,[Prop,P2|Rest]) :- atomic_invariantsC(Invars), member(Prop,Invars), !, writePList(TabVal,[P2|Rest]). writePList(TabVal,[P1,P2|Rest]) :- write(','), nl, tab(TabVal), write(P1), writePList(TabVal,[P2|Rest]). writeChangeLists(_,[]). writeChangeLists(TabVal,[sc(Type,Obj,(Req => Add))|Rest]) :- tab(TabVal), write('sc('),write(Type),write(','),write(Obj),write(',('),nl, Indent is TabVal + 12, writePropList(Indent,Req), nl, tab(Indent), write('=>'), nl, writePropList(Indent,Add), write('))'),writeComma(Rest), nl, writeChangeLists(TabVal,Rest). writeComma([]). writeComma(_) :- write(','). writePrevailLists(_,[]). writePrevailLists(TabVal,[se(Type,Obj,Props)|Rest]) :- tab(TabVal), write('se('),write(Type),write(','),write(Obj),write(','),nl, Indent is TabVal + 12, writePropList(Indent,Props), write(')'),writeComma(Rest), nl, writePrevailLists(TabVal,Rest). assert_is_of_sort :- objectsOfSort(Type,Objects), member(Obj,Objects), assert_is_of_sort1(Type,Obj), fail. assert_is_of_sort :- objectsC(Type,Objects), member(Obj,Objects), assert_is_of_primitive_sort(Type,Obj), fail. assert_is_of_sort. assert_is_of_sort1(Type,Obj):- assert(is_of_sort(Obj,Type)),!. assert_is_of_primitive_sort(Type,Obj):- assert(is_of_primitive_sort(Obj,Type)),!. % change substate_class to primary sort level % assert in prolog database as gsubstate_class(Sort,Obj,States) prim_substate_class:- substate_classes(Sort,Obj,Substate), find_prim_sort(Sort,PS), assert_subclass(PS,Obj,Substate), fail. prim_substate_class:- collect_prim_substates. assert_subclass([],Obj,Substate). assert_subclass([HS|TS],Obj,Substate):- assert(gsstates(HS,Obj,Substate)), assert_subclass(TS,Obj,Substate). collect_prim_substates:- gsstates(Sort,Obj,_), setof(SStates,gsstates(Sort,Obj,SStates),GSStates), retractall(gsstates(Sort,Obj,_)), all_combined(GSStates,GSStates0), assert(gsubstate_classes(Sort,Obj,GSStates0)), fail. collect_prim_substates. all_combined(SStates,CSStates):- xprod(SStates,CSStates1), flat_interal(CSStates1,CSStates),!. flat_interal([],[]):-!. flat_interal([HSS1|TSS1],[HSS|TSS]):- flatten(HSS1,[],HSS), flat_interal(TSS1,TSS),!. % xprod: list * list --> (list X list) % ----------------------------------- xprod(A,B,C) :- xprod([A,B],C) . xprod([],[]). xprod(A,E) :- xprod(A,B,C,D) , F =..[^,C,D] , call(setof(B,F,E)) . xprod([X],[A],A,member(A,X)) . xprod([X,Y],[A,B],C,(D,E)) :- C =..[^,A,B] , D =..[member,A,X] , E =..[member,B,Y] . xprod([X|Y],[A|E],D,(F,G)) :- D =..[^,A,C] , F =..[member,A,X] , xprod(Y,E,C,G). % check the domain is hierarchy or not % by check its substate classes is primitive or not check_if_hierarchy:- assert(is_hierarchy(false)), check_if_hierarchy1. check_if_hierarchy1:- substate_classes(Sort,Obj,SS), not(is_of_primitive_sort(Obj,Sort)), retract(is_hierarchy(_)), assert(is_hierarchy(true)). check_if_hierarchy1. % caheck for substates that has one state is other states subset % like [on_block(A,B)] and [on_block(A,B),clear(A)] % which when check state achieve need extra work check_for_substates:- substate_classes(Sort,Obj,SS), check_for_substates1(Sort,Obj,SS), fail. check_for_substates. check_for_substates1(Sort,Obj,[]). check_for_substates1(Sort,Obj,[Head|Tail]):- check_for_substates2(Sort,Obj,Head,Tail), check_for_substates1(Sort,Obj,Tail). check_for_substates2(Sort,Obj,State,[]). check_for_substates2(Sort,Obj,State,[Head|Tail]):- is_achieved(State,Head), subtract(Head,State,Others), filterInvars(Others,_,_,_,Odds), assert_subset_substates(Sort,Obj,Odds), check_for_substates2(Sort,Obj,State,Tail),!. check_for_substates2(Sort,Obj,State,[Head|Tail]):- is_achieved(Head,State), subtract(State,Head,Others), filterInvars(Others,_,_,_,Odds), assert_subset_substates(Sort,Obj,Odds), check_for_substates2(Sort,Obj,State,Tail),!. check_for_substates2(Sort,Obj,State,[Head|Tail]):- check_for_substates2(Sort,Obj,State,Tail),!. assert_subset_substates(Sort,Obj,[]). assert_subset_substates(Sort,Obj,Odds):- retract(odds_in_subset_substates(Sort,Obj,Odds1)), set_append([Odds],Odds1,Odds2), assert(odds_in_subset_substates(Sort,Obj,Odds2)),!. assert_subset_substates(Sort,Obj,Odds):- assert(odds_in_subset_substates(Sort,Obj,[Odds])),!.
TeamSPoon/logicmoo_workspace
packs_sys/logicmoo_ec/prolog/hyhtn_pddl/ptools/hyhtn_code3.pl
Perl
mit
102,209
=head1 NAME Text::NSP::Measures::2D::CHI::tscore - Perl module that implements T-score measure of association for bigrams. =head1 SYNOPSIS =head3 Basic Usage use Text::NSP::Measures::2D::CHI::tscore; my $npp = 60; my $n1p = 20; my $np1 = 20; my $n11 = 10; $tscore_value = calculateStatistic( n11=>$n11, n1p=>$n1p, np1=>$np1, npp=>$npp); if( ($errorCode = getErrorCode())) { print STDERR $errorCode." - ".getErrorMessage()."\n""; } else { print getStatisticName."value for bigram is ".$tscore_value."\n""; } =head1 DESCRIPTION Assume that the frequency count data associated with a bigram <word1><word2> is stored in a 2x2 contingency table: word2 ~word2 word1 n11 n12 | n1p ~word1 n21 n22 | n2p -------------- np1 np2 npp where n11 is the number of times <word1><word2> occur together, and n12 is the number of times <word1> occurs with some word other than word2, and n1p is the number of times in total that word1 occurs as the first word in a bigram. The T-score is defined as a ratio of difference between the observed and the expected mean to the variance of the sample. Note that this is a variant of the standard t-test that was proposed for use in the identification of collocations in large samples of text. Thus, the T-score is defined as follows: m11 = n1p * np1 / npp T-score = (n11 - m11)/sqrt(n11) =over =cut package Text::NSP::Measures::2D::CHI::tscore; use Text::NSP::Measures::2D::CHI; use strict; use Carp; use warnings; no warnings 'redefine'; require Exporter; our ($VERSION, @EXPORT, @ISA); @ISA = qw(Exporter); @EXPORT = qw(initializeStatistic calculateStatistic getErrorCode getErrorMessage getStatisticName); $VERSION = '0.97'; =item calculateStatistic() - method to calculate the tscore Coefficient INPUT PARAMS : $count_values .. Reference of an hash containing the count values computed by the count.pl program. RETURN VALUES : $tscore .. tscore value for this bigram. =cut sub calculateStatistic { my %values = @_; # computes and returns the observed and expected values from # the frequency combination values. returns 0 if there is an # error in the computation or the values are inconsistent. if( !(Text::NSP::Measures::2D::CHI::getValues(\%values)) ) { return; } # Now calculate the tscore my $tscore = (($n11-$m11)/($n11**0.5)); return ( $tscore ); } =item getStatisticName() - Returns the name of this statistic INPUT PARAMS : none RETURN VALUES : $name .. Name of the measure. =cut sub getStatisticName { return "T-score"; } 1; __END__ =back =head1 AUTHOR Ted Pedersen, University of Minnesota Duluth E<lt>tpederse@d.umn.eduE<gt> Satanjeev Banerjee, Carnegie Mellon University E<lt>satanjeev@cmu.eduE<gt> Amruta Purandare, University of Pittsburgh E<lt>amruta@cs.pitt.eduE<gt> Bridget Thomson-McInnes, University of Minnesota Twin Cities E<lt>bthompson@d.umn.eduE<gt> Saiyam Kohli, University of Minnesota Duluth E<lt>kohli003@d.umn.eduE<gt> =head1 HISTORY Last updated: $Id: tscore.pm,v 1.11 2006/06/21 11:10:52 saiyam_kohli Exp $ =head1 BUGS =head1 SEE ALSO @incollection {ChurchGHH91, author={Church, K. and Gale, W. and Hanks, P. and Hindle, D. }, title={Using Statistics in Lexical Analysis}, booktitle={Lexical Acquisition: Exploiting On-Line Resources to Build a Lexicon}, editor={Zernik, U.}, year={1991}, address={Hillsdale, NJ}, publisher={Lawrence Erlbaum Associates} url = L<http://www.patrickhanks.com/papers/usingStats.pdf>} L<http://groups.yahoo.com/group/ngram/> L<http://www.d.umn.edu/~tpederse/nsp.html> =head1 COPYRIGHT Copyright (C) 2000-2006, Ted Pedersen, Satanjeev Banerjee, Amruta Purandare, Bridget Thomson-McInnes and Saiyam Kohli 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Note: a copy of the GNU General Public License is available on the web at L<http://www.gnu.org/licenses/gpl.txt> and is included in this distribution as GPL.txt. =cut
ppapasaikas/SANJUAN
perllib/Text/NSP/Measures/2D/CHI/tscore.pm
Perl
mit
5,211
#!/usr/bin/perl BEGIN { push(@INC, "../../lib/"); } use ConfigCommon; use rccHTML; my %options = ('db_if' => 1, 'db_isis' => 2, 'db_ospf' => 3, 'suffix' => 4, 'preprocess' => 5, 'parse' => 6, 'verify' => 7, 'quit' => 8); my $mysql = "mysql"; my $last_entry; sub print_menu { print <<EOM; Enter option: 1. Create BGP database from scratch. (Database Setup) 2. Create IS-IS database from scratch. (Database Setup) 3. Create OSPF database from scratch. (Database Setup) 4. Add suffixes to files. (confg, jconfg, etc.) 5. Expand peer groups, etc. 6. Parse configs into mysql database. (Generate Intermediate Format) 7. Run verifier, produce reports. 8. Quit EOM print "Option: "; $option = <STDIN>; return $option; } while (1) { my $option = &print_menu(); if ($option == $options{'db_if'}) { # BGP db system("echo 'drop database config_if' | mysql --user=$db_user --password=$db_pass"); system("echo 'create database config_if' | mysql --user=$db_user --password=$db_pass"); system("cat ../../../db-schema/config_if.sql | mysql --user=$db_user --password=$db_pass config_if"); } if ($option == $options{'db_isis'}) { # IGP db system("echo 'drop database config_isis' | mysql --user=$db_user --password=$db_pass"); system("echo 'create database config_isis' | mysql --user=$db_user --password=$db_pass"); system("cat ../../../db-schema/config_isis.sql | mysql --user=$db_user --password=$db_pass config_isis"); } if ($option == $options{'db_ospf'}) { # IGP db system("echo 'drop database config_ospf' | mysql --user=$db_user --password=$db_pass"); system("echo 'create database config_ospf' | mysql --user=$db_user --password=$db_pass"); system("cat ../../../db-schema/config_ospf.sql | mysql --user=$db_user --password=$db_pass config_ospf"); } if ($option == $options{'suffix'}) { printf "Enter config directory: "; my $dir = <STDIN>; system("./rename_files.pl $dir"); } if ($option == $options{'preprocess'}) { printf "Enter config directory: "; my $dir = <STDIN>; system("./riftrans_all.pl $dir"); chomp($dir); printf "Output is in $dir/trans/\n"; } if ($option == $options{'parse'}) { my $def; chomp($last_entry); if (length($last_entry)>1) { $def = " [$last_entry]"; } printf "Enter config directory$def: "; my $dir = <STDIN>; if (length($dir)<2) { $dir = $last_entry; } else { $last_entry = $dir; } system("perl ../config-convert/gen_intermediate.pl --db --configdir=$dir"); } if ($option == $options{'verify'}) { printf "Enter directory for .html summary, or [enter] for STDOUT: "; my $dir = <STDIN>; chomp($dir); my $opt = ""; if (!($dir eq '')) { $opt = "--files=$dir"; # make the rcc index.html page &make_rcc_index($dir); } # BGP tests system("../queries/scripts/test_all.pl $opt"); # IS-IS tests system("../queries/scripts/test_all_isis.pl $opt"); # OSPF tests system("../queries/scripts/test_all_ospf.pl $opt"); # Network graphs system("../queries/scripts/plot_network.pl $opt --format=jpg --bgp"); system("../queries/scripts/plot_network.pl $opt --format=jpg --igp"); system("../queries/scripts/plot_network.pl $opt --format=ps --bgp"); system("../queries/scripts/plot_network.pl $opt --format=ps --igp"); # Generate HTML Summaries if (!($dir eq '')) { system("../queries/scripts/gen_bgp_html.pl --basedir=$dir"); system("../queries/scripts/gen_igp_html.pl --basedir=$dir"); } } if ($option == $options{'quit'}) { exit(0); } }
wenhuizhang/rcc
perl/src/utils/menu.pl
Perl
mit
3,647
########################################################################### # # This file is partially auto-generated by the DateTime::Locale generator # tools (v0.10). This code generator comes with the DateTime::Locale # distribution in the tools/ directory, and is called generate-modules. # # This file was generated from the CLDR JSON locale data. See the LICENSE.cldr # file included in this distribution for license details. # # Do not edit this file directly unless you are sure the part you are editing # is not created by the generator. # ########################################################################### =pod =encoding UTF-8 =head1 NAME DateTime::Locale::pt_GW - Locale data examples for the pt-GW locale. =head1 DESCRIPTION This pod file contains examples of the locale data available for the Portuguese Guinea-Bissau locale. =head2 Days =head3 Wide (format) segunda-feira terça-feira quarta-feira quinta-feira sexta-feira sábado domingo =head3 Abbreviated (format) segunda terça quarta quinta sexta sábado domingo =head3 Narrow (format) S T Q Q S S D =head3 Wide (stand-alone) segunda-feira terça-feira quarta-feira quinta-feira sexta-feira sábado domingo =head3 Abbreviated (stand-alone) segunda terça quarta quinta sexta sábado domingo =head3 Narrow (stand-alone) S T Q Q S S D =head2 Months =head3 Wide (format) janeiro fevereiro março abril maio junho julho agosto setembro outubro novembro dezembro =head3 Abbreviated (format) jan fev mar abr mai jun jul ago set out nov dez =head3 Narrow (format) J F M A M J J A S O N D =head3 Wide (stand-alone) janeiro fevereiro março abril maio junho julho agosto setembro outubro novembro dezembro =head3 Abbreviated (stand-alone) jan fev mar abr mai jun jul ago set out nov dez =head3 Narrow (stand-alone) J F M A M J J A S O N D =head2 Quarters =head3 Wide (format) 1.º trimestre 2.º trimestre 3.º trimestre 4.º trimestre =head3 Abbreviated (format) T1 T2 T3 T4 =head3 Narrow (format) 1 2 3 4 =head3 Wide (stand-alone) 1.º trimestre 2.º trimestre 3.º trimestre 4.º trimestre =head3 Abbreviated (stand-alone) T1 T2 T3 T4 =head3 Narrow (stand-alone) 1 2 3 4 =head2 Eras =head3 Wide (format) antes de Cristo depois de Cristo =head3 Abbreviated (format) a.C. d.C. =head3 Narrow (format) a.C. d.C. =head2 Date Formats =head3 Full 2008-02-05T18:30:30 = terça-feira, 5 de fevereiro de 2008 1995-12-22T09:05:02 = sexta-feira, 22 de dezembro de 1995 -0010-09-15T04:44:23 = sábado, 15 de setembro de -10 =head3 Long 2008-02-05T18:30:30 = 5 de fevereiro de 2008 1995-12-22T09:05:02 = 22 de dezembro de 1995 -0010-09-15T04:44:23 = 15 de setembro de -10 =head3 Medium 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-10 =head3 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 =head2 Time Formats =head3 Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC =head3 Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC =head3 Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 =head3 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 =head2 Datetime Formats =head3 Full 2008-02-05T18:30:30 = terça-feira, 5 de fevereiro de 2008 às 18:30:30 UTC 1995-12-22T09:05:02 = sexta-feira, 22 de dezembro de 1995 às 09:05:02 UTC -0010-09-15T04:44:23 = sábado, 15 de setembro de -10 às 04:44:23 UTC =head3 Long 2008-02-05T18:30:30 = 5 de fevereiro de 2008 às 18:30:30 UTC 1995-12-22T09:05:02 = 22 de dezembro de 1995 às 09:05:02 UTC -0010-09-15T04:44:23 = 15 de setembro de -10 às 04:44:23 UTC =head3 Medium 2008-02-05T18:30:30 = 05/02/2008, 18:30:30 1995-12-22T09:05:02 = 22/12/1995, 09:05:02 -0010-09-15T04:44:23 = 15/09/-10, 04:44:23 =head3 Short 2008-02-05T18:30:30 = 05/02/08, 18:30 1995-12-22T09:05:02 = 22/12/95, 09:05 -0010-09-15T04:44:23 = 15/09/-10, 04:44 =head2 Available Formats =head3 E (ccc) 2008-02-05T18:30:30 = terça 1995-12-22T09:05:02 = sexta -0010-09-15T04:44:23 = sábado =head3 EHm (E, HH:mm) 2008-02-05T18:30:30 = terça, 18:30 1995-12-22T09:05:02 = sexta, 09:05 -0010-09-15T04:44:23 = sábado, 04:44 =head3 EHms (E, HH:mm:ss) 2008-02-05T18:30:30 = terça, 18:30:30 1995-12-22T09:05:02 = sexta, 09:05:02 -0010-09-15T04:44:23 = sábado, 04:44:23 =head3 Ed (E, d) 2008-02-05T18:30:30 = terça, 5 1995-12-22T09:05:02 = sexta, 22 -0010-09-15T04:44:23 = sábado, 15 =head3 Ehm (E, h:mm a) 2008-02-05T18:30:30 = terça, 6:30 p.m. 1995-12-22T09:05:02 = sexta, 9:05 a.m. -0010-09-15T04:44:23 = sábado, 4:44 a.m. =head3 Ehms (E, h:mm:ss a) 2008-02-05T18:30:30 = terça, 6:30:30 p.m. 1995-12-22T09:05:02 = sexta, 9:05:02 a.m. -0010-09-15T04:44:23 = sábado, 4:44:23 a.m. =head3 Gy (y G) 2008-02-05T18:30:30 = 2008 d.C. 1995-12-22T09:05:02 = 1995 d.C. -0010-09-15T04:44:23 = -10 a.C. =head3 GyMMM (MMM 'de' y G) 2008-02-05T18:30:30 = fev de 2008 d.C. 1995-12-22T09:05:02 = dez de 1995 d.C. -0010-09-15T04:44:23 = set de -10 a.C. =head3 GyMMMEd (E, d 'de' MMM 'de' y G) 2008-02-05T18:30:30 = terça, 5 de fev de 2008 d.C. 1995-12-22T09:05:02 = sexta, 22 de dez de 1995 d.C. -0010-09-15T04:44:23 = sábado, 15 de set de -10 a.C. =head3 GyMMMd (d 'de' MMM 'de' y G) 2008-02-05T18:30:30 = 5 de fev de 2008 d.C. 1995-12-22T09:05:02 = 22 de dez de 1995 d.C. -0010-09-15T04:44:23 = 15 de set de -10 a.C. =head3 H (HH) 2008-02-05T18:30:30 = 18 1995-12-22T09:05:02 = 09 -0010-09-15T04:44:23 = 04 =head3 Hm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 =head3 Hms (HH:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 =head3 Hmsv (HH:mm:ss v) 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC =head3 Hmv (HH:mm v) 2008-02-05T18:30:30 = 18:30 UTC 1995-12-22T09:05:02 = 09:05 UTC -0010-09-15T04:44:23 = 04:44 UTC =head3 M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 =head3 MEd (E, dd/MM) 2008-02-05T18:30:30 = terça, 05/02 1995-12-22T09:05:02 = sexta, 22/12 -0010-09-15T04:44:23 = sábado, 15/09 =head3 MMM (LLL) 2008-02-05T18:30:30 = fev 1995-12-22T09:05:02 = dez -0010-09-15T04:44:23 = set =head3 MMMEd (E, d/MM) 2008-02-05T18:30:30 = terça, 5/02 1995-12-22T09:05:02 = sexta, 22/12 -0010-09-15T04:44:23 = sábado, 15/09 =head3 MMMMEd (ccc, d 'de' MMMM) 2008-02-05T18:30:30 = terça, 5 de fevereiro 1995-12-22T09:05:02 = sexta, 22 de dezembro -0010-09-15T04:44:23 = sábado, 15 de setembro =head3 MMMMd (d 'de' MMMM) 2008-02-05T18:30:30 = 5 de fevereiro 1995-12-22T09:05:02 = 22 de dezembro -0010-09-15T04:44:23 = 15 de setembro =head3 MMMd (d/MM) 2008-02-05T18:30:30 = 5/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 =head3 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 =head3 Md (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 =head3 d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 =head3 h (h a) 2008-02-05T18:30:30 = 6 p.m. 1995-12-22T09:05:02 = 9 a.m. -0010-09-15T04:44:23 = 4 a.m. =head3 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 p.m. 1995-12-22T09:05:02 = 9:05 a.m. -0010-09-15T04:44:23 = 4:44 a.m. =head3 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 p.m. 1995-12-22T09:05:02 = 9:05:02 a.m. -0010-09-15T04:44:23 = 4:44:23 a.m. =head3 hmsv (h:mm:ss a v) 2008-02-05T18:30:30 = 6:30:30 p.m. UTC 1995-12-22T09:05:02 = 9:05:02 a.m. UTC -0010-09-15T04:44:23 = 4:44:23 a.m. UTC =head3 hmv (h:mm a v) 2008-02-05T18:30:30 = 6:30 p.m. UTC 1995-12-22T09:05:02 = 9:05 a.m. UTC -0010-09-15T04:44:23 = 4:44 a.m. UTC =head3 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 =head3 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 =head3 yM (MM/y) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-10 =head3 yMEd (E, dd/MM/y) 2008-02-05T18:30:30 = terça, 05/02/2008 1995-12-22T09:05:02 = sexta, 22/12/1995 -0010-09-15T04:44:23 = sábado, 15/09/-10 =head3 yMM (MM/y) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-10 =head3 yMMM (MM/y) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-10 =head3 yMMMEEEEd (EEEE, d/MM/y) 2008-02-05T18:30:30 = terça-feira, 5/02/2008 1995-12-22T09:05:02 = sexta-feira, 22/12/1995 -0010-09-15T04:44:23 = sábado, 15/09/-10 =head3 yMMMEd (E, d/MM/y) 2008-02-05T18:30:30 = terça, 5/02/2008 1995-12-22T09:05:02 = sexta, 22/12/1995 -0010-09-15T04:44:23 = sábado, 15/09/-10 =head3 yMMMM (MMMM 'de' y) 2008-02-05T18:30:30 = fevereiro de 2008 1995-12-22T09:05:02 = dezembro de 1995 -0010-09-15T04:44:23 = setembro de -10 =head3 yMMMMEd (ccc, d 'de' MMMM 'de' y) 2008-02-05T18:30:30 = terça, 5 de fevereiro de 2008 1995-12-22T09:05:02 = sexta, 22 de dezembro de 1995 -0010-09-15T04:44:23 = sábado, 15 de setembro de -10 =head3 yMMMMd (d 'de' MMMM 'de' y) 2008-02-05T18:30:30 = 5 de fevereiro de 2008 1995-12-22T09:05:02 = 22 de dezembro de 1995 -0010-09-15T04:44:23 = 15 de setembro de -10 =head3 yMMMd (d/MM/y) 2008-02-05T18:30:30 = 5/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-10 =head3 yMd (dd/MM/y) 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-10 =head3 yQQQ (QQQQ 'de' y) 2008-02-05T18:30:30 = 1.º trimestre de 2008 1995-12-22T09:05:02 = 4.º trimestre de 1995 -0010-09-15T04:44:23 = 3.º trimestre de -10 =head3 yQQQQ (QQQQ 'de' y) 2008-02-05T18:30:30 = 1.º trimestre de 2008 1995-12-22T09:05:02 = 4.º trimestre de 1995 -0010-09-15T04:44:23 = 3.º trimestre de -10 =head2 Miscellaneous =head3 Prefers 24 hour time? Yes =head3 Local first day of the week 1 (segunda-feira) =head1 SUPPORT See L<DateTime::Locale>. =cut
jkb78/extrajnm
local/lib/perl5/DateTime/Locale/pt_GW.pod
Perl
mit
10,962
package ExtUtils::MM_Win32; use strict; =head1 NAME ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker =head1 SYNOPSIS use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed =head1 DESCRIPTION See ExtUtils::MM_Unix for a documentation of the methods provided there. This package overrides the implementation of these methods, not the semantics. =cut use ExtUtils::MakeMaker::Config; use File::Basename; use File::Spec; use ExtUtils::MakeMaker qw( neatvalue ); require ExtUtils::MM_Any; require ExtUtils::MM_Unix; our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix ); our $VERSION = '7.10_02'; $ENV{EMXSHELL} = 'sh'; # to run `commands` my ( $BORLAND, $GCC, $DLLTOOL ) = _identify_compiler_environment( \%Config ); sub _identify_compiler_environment { my ( $config ) = @_; my $BORLAND = $config->{cc} =~ /^bcc/i ? 1 : 0; my $GCC = $config->{cc} =~ /\bgcc\b/i ? 1 : 0; my $DLLTOOL = $config->{dlltool} || 'dlltool'; return ( $BORLAND, $GCC, $DLLTOOL ); } =head2 Overridden methods =over 4 =item B<dlsyms> =cut sub dlsyms { my($self,%attribs) = @_; my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {}; my(@m); if (not $self->{SKIPHASH}{'dynamic'}) { push(@m," $self->{BASEEXT}.def: Makefile.PL ", q! $(PERLRUN) -MExtUtils::Mksymlists \\ -e "Mksymlists('NAME'=>\"!, $self->{NAME}, q!\", 'DLBASE' => '!,$self->{DLBASE}, # The above two lines quoted differently to work around # a bug in the 4DOS/4NT command line interpreter. The visible # result of the bug was files named q('extension_name',) *with the # single quotes and the comma* in the extension build directories. q!', 'DL_FUNCS' => !,neatvalue($funcs), q!, 'FUNCLIST' => !,neatvalue($funclist), q!, 'IMPORTS' => !,neatvalue($imports), q!, 'DL_VARS' => !, neatvalue($vars), q!);" !); } join('',@m); } =item replace_manpage_separator Changes the path separator with . =cut sub replace_manpage_separator { my($self,$man) = @_; $man =~ s,/+,.,g; $man; } =item B<maybe_command> Since Windows has nothing as simple as an executable bit, we check the file extension. The PATHEXT env variable will be used to get a list of extensions that might indicate a command, otherwise .com, .exe, .bat and .cmd will be used by default. =cut sub maybe_command { my($self,$file) = @_; my @e = exists($ENV{'PATHEXT'}) ? split(/;/, $ENV{PATHEXT}) : qw(.com .exe .bat .cmd); my $e = ''; for (@e) { $e .= "\Q$_\E|" } chop $e; # see if file ends in one of the known extensions if ($file =~ /($e)$/i) { return $file if -e $file; } else { for (@e) { return "$file$_" if -e "$file$_"; } } return; } =item B<init_DIRFILESEP> Using \ for Windows, except for "gmake" where it is /. =cut sub init_DIRFILESEP { my($self) = shift; # The ^ makes sure its not interpreted as an escape in nmake $self->{DIRFILESEP} = $self->is_make_type('nmake') ? '^\\' : $self->is_make_type('dmake') ? '\\\\' : $self->is_make_type('gmake') ? '/' : '\\'; } =item init_tools Override some of the slower, portable commands with Windows specific ones. =cut sub init_tools { my ($self) = @_; $self->{NOOP} ||= 'rem'; $self->{DEV_NULL} ||= '> NUL'; $self->{FIXIN} ||= $self->{PERL_CORE} ? "\$(PERLRUN) $self->{PERL_SRC}\\win32\\bin\\pl2bat.pl" : 'pl2bat.bat'; $self->SUPER::init_tools; # Setting SHELL from $Config{sh} can break dmake. Its ok without it. delete $self->{SHELL}; return; } =item init_others Override the default link and compile tools. LDLOADLIBS's default is changed to $Config{libs}. Adjustments are made for Borland's quirks needing -L to come first. =cut sub init_others { my $self = shift; $self->{LD} ||= 'link'; $self->{AR} ||= 'lib'; $self->SUPER::init_others; $self->{LDLOADLIBS} ||= $Config{libs}; # -Lfoo must come first for Borland, so we put it in LDDLFLAGS if ($BORLAND) { my $libs = $self->{LDLOADLIBS}; my $libpath = ''; while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { $libpath .= ' ' if length $libpath; $libpath .= $1; } $self->{LDLOADLIBS} = $libs; $self->{LDDLFLAGS} ||= $Config{lddlflags}; $self->{LDDLFLAGS} .= " $libpath"; } return; } =item init_platform Add MM_Win32_VERSION. =item platform_constants =cut sub init_platform { my($self) = shift; $self->{MM_Win32_VERSION} = $VERSION; return; } sub platform_constants { my($self) = shift; my $make_frag = ''; foreach my $macro (qw(MM_Win32_VERSION)) { next unless defined $self->{$macro}; $make_frag .= "$macro = $self->{$macro}\n"; } return $make_frag; } =item specify_shell Set SHELL to $ENV{COMSPEC} only if make is type 'gmake'. =cut sub specify_shell { my $self = shift; return '' unless $self->is_make_type('gmake'); "\nSHELL = $ENV{COMSPEC}\n"; } =item constants Add MAXLINELENGTH for dmake before all the constants are output. =cut sub constants { my $self = shift; my $make_text = $self->SUPER::constants; return $make_text unless $self->is_make_type('dmake'); # dmake won't read any single "line" (even those with escaped newlines) # larger than a certain size which can be as small as 8k. PM_TO_BLIB # on large modules like DateTime::TimeZone can create lines over 32k. # So we'll crank it up to a <ironic>WHOPPING</ironic> 64k. # # This has to come here before all the constants and not in # platform_constants which is after constants. my $size = $self->{MAXLINELENGTH} || 800000; my $prefix = qq{ # Get dmake to read long commands like PM_TO_BLIB MAXLINELENGTH = $size }; return $prefix . $make_text; } =item special_targets Add .USESHELL target for dmake. =cut sub special_targets { my($self) = @_; my $make_frag = $self->SUPER::special_targets; $make_frag .= <<'MAKE_FRAG' if $self->is_make_type('dmake'); .USESHELL : MAKE_FRAG return $make_frag; } =item static_lib Changes how to run the linker. The rest is duplicate code from MM_Unix. Should move the linker code to its own method. =cut sub static_lib { my($self) = @_; return '' unless $self->has_link_code; my(@m); push(@m, <<'END'); $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists $(RM_RF) $@ END # If this extension has its own library (eg SDBM_File) # then copy that to $(INST_STATIC) and add $(OBJECT) into it. push @m, <<'MAKE_FRAG' if $self->{MYEXTLIB}; $(CP) $(MYEXTLIB) $@ MAKE_FRAG push @m, q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")' : ($GCC ? '-ru $@ $(OBJECT)' : '-out:$@ $(OBJECT)')).q{ $(CHMOD) $(PERM_RWX) $@ $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld }; # Old mechanism - still available: push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs MAKE_FRAG join('', @m); } =item dynamic_lib Complicated stuff for Win32 that I don't understand. :( =cut sub dynamic_lib { my($self, %attribs) = @_; return '' unless $self->needs_linking(); #might be because of a subdir return '' unless $self->has_link_code; my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': ''); my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; my($ldfrom) = '$(LDFROM)'; my(@m); push(@m,' # This section creates the dynamically loadable $(INST_DYNAMIC) # from $(OBJECT) and possibly $(MYEXTLIB). OTHERLDFLAGS = '.$otherldflags.' INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVEDEP) $(INST_DYNAMIC_DEP) '); if ($GCC) { push(@m, q{ }.$DLLTOOL.q{ --def $(EXPORT_LIST) --output-exp dll.exp $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) dll.exp }.$DLLTOOL.q{ --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) dll.exp }); } elsif ($BORLAND) { push(@m, q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,} .($self->is_make_type('dmake') ? q{"$(PERL_ARCHIVE:s,/,\,)" $(LDLOADLIBS:s,/,\,) } .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)} : q{"$(subst /,\,$(PERL_ARCHIVE))" $(subst /,\,$(LDLOADLIBS)) } .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))}) .q{,$(RESFILES)}); } else { # VC push(@m, q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) } .q{$(MYEXTLIB) "$(PERL_ARCHIVE)" $(LDLOADLIBS) -def:$(EXPORT_LIST)}); # Embed the manifest file if it exists push(@m, q{ if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 if exist $@.manifest del $@.manifest}); } push @m, ' $(CHMOD) $(PERM_RWX) $@ '; join('',@m); } =item extra_clean_files Clean out some extra dll.{base,exp} files which might be generated by gcc. Otherwise, take out all *.pdb files. =cut sub extra_clean_files { my $self = shift; return $GCC ? (qw(dll.base dll.exp)) : ('*.pdb'); } =item init_linker =cut sub init_linker { my $self = shift; $self->{PERL_ARCHIVE} = "\$(PERL_INC)\\$Config{libperl}"; $self->{PERL_ARCHIVEDEP} = "\$(PERL_INCDEP)\\$Config{libperl}"; $self->{PERL_ARCHIVE_AFTER} = ''; $self->{EXPORT_LIST} = '$(BASEEXT).def'; } =item perl_script Checks for the perl program under several common perl extensions. =cut sub perl_script { my($self,$file) = @_; return $file if -r $file && -f _; return "$file.pl" if -r "$file.pl" && -f _; return "$file.plx" if -r "$file.plx" && -f _; return "$file.bat" if -r "$file.bat" && -f _; return; } sub can_dep_space { my $self = shift; 1; # with Win32::GetShortPathName } =item quote_dep =cut sub quote_dep { my ($self, $arg) = @_; if ($arg =~ / / and not $self->is_make_type('gmake')) { require Win32; $arg = Win32::GetShortPathName($arg); die <<EOF if not defined $arg or $arg =~ / /; Tried to use make dependency with space for non-GNU make: '$arg' Fallback to short pathname failed. EOF return $arg; } return $self->SUPER::quote_dep($arg); } =item xs_o This target is stubbed out. Not sure why. =cut sub xs_o { return '' } =item pasthru All we send is -nologo to nmake to prevent it from printing its damned banner. =cut sub pasthru { my($self) = shift; return "PASTHRU = " . ($self->is_make_type('nmake') ? "-nologo" : ""); } =item arch_check (override) Normalize all arguments for consistency of comparison. =cut sub arch_check { my $self = shift; # Win32 is an XS module, minperl won't have it. # arch_check() is not critical, so just fake it. return 1 unless $self->can_load_xs; return $self->SUPER::arch_check( map { $self->_normalize_path_name($_) } @_); } sub _normalize_path_name { my $self = shift; my $file = shift; require Win32; my $short = Win32::GetShortPathName($file); return defined $short ? lc $short : lc $file; } =item oneliner These are based on what command.com does on Win98. They may be wrong for other Windows shells, I don't know. =cut sub oneliner { my($self, $cmd, $switches) = @_; $switches = [] unless defined $switches; # Strip leading and trailing newlines $cmd =~ s{^\n+}{}; $cmd =~ s{\n+$}{}; $cmd = $self->quote_literal($cmd); $cmd = $self->escape_newlines($cmd); $switches = join ' ', @$switches; return qq{\$(ABSPERLRUN) $switches -e $cmd --}; } sub quote_literal { my($self, $text, $opts) = @_; $opts->{allow_variables} = 1 unless defined $opts->{allow_variables}; # See: http://www.autohotkey.net/~deleyd/parameters/parameters.htm#CPP # Apply the Microsoft C/C++ parsing rules $text =~ s{\\\\"}{\\\\\\\\\\"}g; # \\" -> \\\\\" $text =~ s{(?<!\\)\\"}{\\\\\\"}g; # \" -> \\\" $text =~ s{(?<!\\)"}{\\"}g; # " -> \" $text = qq{"$text"} if $text =~ /[ \t]/; # Apply the Command Prompt parsing rules (cmd.exe) my @text = split /("[^"]*")/, $text; # We should also escape parentheses, but it breaks one-liners containing # $(MACRO)s in makefiles. s{([<>|&^@!])}{^$1}g foreach grep { !/^"[^"]*"$/ } @text; $text = join('', @text); # dmake expands {{ to { and }} to }. if( $self->is_make_type('dmake') ) { $text =~ s/{/{{/g; $text =~ s/}/}}/g; } $text = $opts->{allow_variables} ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text); return $text; } sub escape_newlines { my($self, $text) = @_; # Escape newlines $text =~ s{\n}{\\\n}g; return $text; } =item cd dmake can handle Unix style cd'ing but nmake (at least 1.5) cannot. It wants: cd dir1\dir2 command another_command cd ..\.. =cut sub cd { my($self, $dir, @cmds) = @_; return $self->SUPER::cd($dir, @cmds) unless $self->is_make_type('nmake'); my $cmd = join "\n\t", map "$_", @cmds; my $updirs = $self->catdir(map { $self->updir } $self->splitdir($dir)); # No leading tab and no trailing newline makes for easier embedding. my $make_frag = sprintf <<'MAKE_FRAG', $dir, $cmd, $updirs; cd %s %s cd %s MAKE_FRAG chomp $make_frag; return $make_frag; } =item max_exec_len nmake 1.50 limits command length to 2048 characters. =cut sub max_exec_len { my $self = shift; return $self->{_MAX_EXEC_LEN} ||= 2 * 1024; } =item os_flavor Windows is Win32. =cut sub os_flavor { return('Win32'); } =item cflags Defines the PERLDLL symbol if we are configured for static building since all code destined for the perl5xx.dll must be compiled with the PERLDLL symbol defined. =cut sub cflags { my($self,$libperl)=@_; return $self->{CFLAGS} if $self->{CFLAGS}; return '' unless $self->needs_linking(); my $base = $self->SUPER::cflags($libperl); foreach (split /\n/, $base) { /^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2; }; $self->{CCFLAGS} .= " -DPERLDLL" if ($self->{LINKTYPE} eq 'static'); return $self->{CFLAGS} = qq{ CCFLAGS = $self->{CCFLAGS} OPTIMIZE = $self->{OPTIMIZE} PERLTYPE = $self->{PERLTYPE} }; } 1; __END__ =back
operepo/ope
bin/usr/share/perl5/core_perl/ExtUtils/MM_Win32.pm
Perl
mit
14,974
# # Copyright 2017 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package database::mysql::mode::threadsconnected; use base qw(centreon::plugins::mode); use strict; use warnings; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); if (!($self->{sql}->is_version_minimum(version => '5'))) { $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x')."); $self->{output}->option_exit(); } $self->{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Threads_connected'}); my ($dummy, $result) = $self->{sql}->fetchrow_array(); if (!defined($result)) { $self->{output}->add_option_msg(short_msg => "Cannot get number of open connections."); $self->{output}->option_exit(); } my $value = $result; my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("%d client connection threads", $value) ); $self->{output}->perfdata_add(label => 'threads_connected', value => $value, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check number of open connections. =over 8 =item B<--warning> Threshold warning. =item B<--critical> Threshold critical. =back =cut
Shini31/centreon-plugins
database/mysql/mode/threadsconnected.pm
Perl
apache-2.0
3,809
package TestProtocol::echo_bbs2; # similar to TestProtocol::echo_bbs but here re-using one bucket # brigade for input and output, using flatten to slurp all the data in # the bucket brigade, and cleanup to get rid of the old buckets use strict; use warnings FATAL => 'all'; use Apache2::Connection (); use APR::Socket (); use APR::Bucket (); use APR::Brigade (); use APR::Error (); use Apache2::Const -compile => qw(OK MODE_GETLINE); use APR::Const -compile => qw(SUCCESS SO_NONBLOCK); use APR::Status (); sub handler { my $c = shift; # starting from Apache 2.0.49 several platforms require you to set # the socket to a blocking IO mode $c->client_socket->opt_set(APR::Const::SO_NONBLOCK, 0); my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc); my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc); my $last = 0; while (1) { my $rc = $c->input_filters->get_brigade($bb_in, Apache2::Const::MODE_GETLINE); last if APR::Status::is_EOF($rc); die APR::Error::strerror($rc) unless $rc == APR::Const::SUCCESS; next unless $bb_in->flatten(my $data); #warn "read: [$data]\n"; last if $data =~ /^[\r\n]+$/; # transform data here my $bucket = APR::Bucket->new($bb_in->bucket_alloc, uc $data); $bb_out->insert_tail($bucket); $c->output_filters->fflush($bb_out); $bb_in->cleanup; $bb_out->cleanup; } # XXX: add DESTROY and remove explicit calls $bb_in->destroy; $bb_out->destroy; Apache2::Const::OK; } 1;
gitpan/mod_perl
t/protocol/TestProtocol/echo_bbs2.pm
Perl
apache-2.0
1,620
=head1 NAME rawlog-edit - Command-line robotic datasets (rawlogs) manipulation tool =head1 SYNOPSIS rawlog-edit [--rename-externals] [--stereo-rectify <SENSOR_LABEL,0.5>] [--camera-params <SENSOR_LABEL,file.ini>] [--sensors-pose <file.ini>] [--generate-pcd] [--generate-3d-pointclouds] [--cut] [--export-2d-scans-txt] [--export-imu-txt] [--export-gps-txt] [--export-gps-kml] [--keep-label <label[ ,label...]>] [--remove-label <label[,label...]>] [--list-range-bearing] [--remap-timestamps <a;b>] [--list-timestamps] [--list-images] [--info] [--externalize] [-q] [-w] [--to-time <T1>] [--from-time <T0>] [--to-index <N1>] [--from-index <N0>] [--text-file-output <out.txt>] [--image-size <COLSxROWS>] [--image-format <jpg,png,pgm,...>] [--out-dir <.>] [-o <dataset_out.rawlog>] -i <dataset.rawlog> [--] [--version] [-h] =head1 USAGE EXAMPLES B<Quick overview of a dataset file:> rawlog-edit --info -i I<in.rawlog> B<Cut the entries [1000,2000] into another rawlog file:> rawlog-edit --cut --from-index 1000 --to-index 2000 \ -i I<in.rawlog> -o I<out.rawlog> B<Cut the entries from the beginning up to timestamp 1281619819:> rawlog-edit --cut --to-time 1281619819 \ -i I<in.rawlog> -o I<out.rawlog> B<Generate a Google Earth KML file with the GPS data in a dataset:> rawlog-edit --export-gps-kml -i I<in.rawlog> B<Remove all observations named "REAR_LASER":> rawlog-edit --remove-label REAR_LASER -i I<in.rawlog> -o I<out.rawlog> B<Remove all observations not named "REAR_LASER":> rawlog-edit --keep-label REAR_LASER -i I<in.rawlog> -o I<out.rawlog> B<Convert all images to external storage mode:> rawlog-edit --externalize -i I<in.rawlog> -o I<out.rawlog> rawlog-edit --externalize --image-format jpg -i I<in.rawlog> \ -o I<out.rawlog> =head1 DESCRIPTION B<rawlog-edit> is a command-line application to inspect and manipulate robotic dataset files in the "rawlog" standardized format. These are the supported arguments and operations: --rename-externals Op: Renames all the external storage file names within the rawlog (it doesn't change the external files, which may even not exist). --stereo-rectify <SENSOR_LABEL,0.5> Op: creates a new set of external images for all CObservationStereoImages with the given SENSOR_LABEL, using the camera parameters stored in the observations (which must be a valid calibration) and with the given alpha value. Alpha can be -1 for auto, or otherwise be in the range [0,1] (see OpenCV's docs for cvStereoRectify). Requires: -o (or --output) Optional: --image-format to set image format (default=jpg), --image-size to resize output images (example: --image-size 640x480) --camera-params <SENSOR_LABEL,file.ini> Op: change the camera parameters of all CObservationImage's with the given SENSOR_LABEL, with new params loaded from the given file, section '[CAMERA_PARAMS]' for monocular cameras, or '[CAMERA_PARAMS_LEFT]' and '[CAMERA_PARAMS_RIGHT]' for stereo. Requires: -o (or --output) --sensors-pose <file.ini> Op: batch change the poses of sensors from a rawlog-grabber-like configuration file that specifies the pose of sensors by their sensorLabel names. Requires: -o (or --output) --generate-pcd Op: Generate a PointCloud Library (PCL) PCD file with the point cloud for each sensor observation that can be converted into this representation: laser scans, 3D camera images, etc. Optional: --out-dir to change the output directory (default: "./") --generate-3d-pointclouds Op: (re)generate the 3D pointclouds within CObservation3DRangeScan objects that have range data. Requires: -o (or --output) --cut Op: Cut a part of the input rawlog. Requires: -o (or --output) Requires: At least one of --from-index, --from-time, --to-index, --to-time. Use only one of the --from-* and --to-* at once. If only a --from-* is given, the rawlog will be saved up to its end. If only a --to-* is given, the rawlog will be saved from its beginning. --export-2d-scans-txt Op: Export 2D scans to TXT files. Generates two .txt files for each different sensor label of 2D scan observations, one with the timestamps and the other with range data. The generated .txt files will be saved in the same path than the input rawlog, with the same filename + each sensorLabel. --export-imu-txt Op: Export IMU readings to TXT files. Generates one .txt file for each different sensor label of an IMU observation in the dataset. The generated .txt files will be saved in the same path than the input rawlog, with the same filename + each sensorLabel. --export-gps-txt Op: Export GPS readings to TXT files. Generates one .txt file for each different sensor label of GPS observations in the dataset. The generated .txt files will be saved in the same path than the input rawlog, with the same filename + each sensorLabel. --export-gps-kml Op: Export GPS paths to Google Earth KML files. Generates one .kml file with different sections for each different sensor label of GPS observations in the dataset. The generated .kml files will be saved in the same path than the input rawlog, with the same filename + each sensorLabel. --keep-label <label[,label...]> Op: Remove all observations not matching the given sensor label(s).Several labels can be provided separated by commas. Requires: -o (or --output) --remove-label <label[,label...]> Op: Remove all observation matching the given sensor label(s).Several labels can be provided separated by commas. Requires: -o (or --output) --list-range-bearing Op: dump a list of all landmark observations of type range-bearing. Optionally the output text file can be changed with --text-file-output. --remap-timestamps <a;b> Op: Change all timestamps t replacing it with the linear map 'a*t+b'.The parameters 'a' and 'b' must be given separated with a semicolon. Requires: -o (or --output) --list-timestamps Op: generates a list with all the observations' timestamp, sensor label and C++ class name. Optionally the output text file can be changed with --text-file-output. --list-images Op: dump a list of all external image files in the dataset. Optionally the output text file can be changed with --text-file-output. --info Op: parse input file and dump information and statistics. --externalize Op: convert to external storage. Requires: -o (or --output) Optional: --image-format -q, --quiet Terse output -w, --overwrite Force overwrite target file without prompting. --to-time <T1> End time for --cut, as UNIX timestamp, optionally with fractions of seconds. --from-time <T0> Starting time for --cut, as UNIX timestamp, optionally with fractions of seconds. --to-index <N1> End index for --cut --from-index <N0> Starting index for --cut --text-file-output <out.txt> Output for a text file --image-size <COLSxROWS> Resize output images --image-format <jpg,png,pgm,...> External image format --out-dir <.> Output directory (used by some commands only) -o <dataset_out.rawlog>, --output <dataset_out.rawlog> Output dataset (*.rawlog) -i <dataset.rawlog>, --input <dataset.rawlog> (required) Input dataset (required) (*.rawlog) --, --ignore_rest Ignores the rest of the labeled arguments following this flag. --version Displays version information and exits. -h, --help Displays usage information and exits. -- =head1 BUGS Please report bugs at http://www.mrpt.org/project/issues/MRPT =head1 SEE ALSO The GUI program RawLogViewer, and the application wiki pages at http://www.mrpt.org/ =head1 AUTHORS B<rawlog-edit> is part of the Mobile Robot Programming Toolkit (MRPT), and was originally written by the MAPIR laboratory (University of Malaga). This manual page was written by Jose Luis Blanco <joseluisblancoc@gmail.com>. =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of the BSD License. On Debian GNU/Linux systems, the complete text of the BSD License can be found in `/usr/share/common-licenses/BSD'. =cut
samuelpfchoi/mrpt
doc/man-pages/pod/rawlog-edit.pod
Perl
bsd-3-clause
8,783
% Frame number: 0 holdsAt( orientation( id0 )=150, 0 ). holdsAt( appearance( id0 )=appear, 0 ). holdsAt( orientation( id1 )=170, 0 ). holdsAt( appearance( id1 )=appear, 0 ). holdsAt( orientation( id2 )=170, 0 ). holdsAt( appearance( id2 )=appear, 0 ). % Frame number: 1 holdsAt( orientation( id0 )=150, 40 ). holdsAt( appearance( id0 )=visible, 40 ). holdsAt( orientation( id1 )=170, 40 ). holdsAt( appearance( id1 )=visible, 40 ). holdsAt( orientation( id2 )=170, 40 ). holdsAt( appearance( id2 )=visible, 40 ). % Frame number: 2 holdsAt( orientation( id0 )=150, 80 ). holdsAt( appearance( id0 )=visible, 80 ). holdsAt( orientation( id1 )=170, 80 ). holdsAt( appearance( id1 )=visible, 80 ). holdsAt( orientation( id2 )=170, 80 ). holdsAt( appearance( id2 )=visible, 80 ). % Frame number: 3 holdsAt( orientation( id0 )=150, 120 ). holdsAt( appearance( id0 )=visible, 120 ). holdsAt( orientation( id1 )=170, 120 ). holdsAt( appearance( id1 )=visible, 120 ). holdsAt( orientation( id2 )=170, 120 ). holdsAt( appearance( id2 )=visible, 120 ). % Frame number: 4 holdsAt( orientation( id0 )=150, 160 ). holdsAt( appearance( id0 )=visible, 160 ). holdsAt( orientation( id1 )=170, 160 ). holdsAt( appearance( id1 )=visible, 160 ). holdsAt( orientation( id2 )=170, 160 ). holdsAt( appearance( id2 )=visible, 160 ). % Frame number: 5 holdsAt( orientation( id0 )=150, 200 ). holdsAt( appearance( id0 )=visible, 200 ). holdsAt( orientation( id1 )=170, 200 ). holdsAt( appearance( id1 )=visible, 200 ). holdsAt( orientation( id2 )=170, 200 ). holdsAt( appearance( id2 )=visible, 200 ). % Frame number: 6 holdsAt( orientation( id0 )=150, 240 ). holdsAt( appearance( id0 )=visible, 240 ). holdsAt( orientation( id1 )=170, 240 ). holdsAt( appearance( id1 )=visible, 240 ). holdsAt( orientation( id2 )=170, 240 ). holdsAt( appearance( id2 )=visible, 240 ). % Frame number: 7 holdsAt( orientation( id0 )=150, 280 ). holdsAt( appearance( id0 )=visible, 280 ). holdsAt( orientation( id1 )=170, 280 ). holdsAt( appearance( id1 )=visible, 280 ). holdsAt( orientation( id2 )=170, 280 ). holdsAt( appearance( id2 )=visible, 280 ). % Frame number: 8 holdsAt( orientation( id0 )=150, 320 ). holdsAt( appearance( id0 )=visible, 320 ). holdsAt( orientation( id1 )=170, 320 ). holdsAt( appearance( id1 )=visible, 320 ). holdsAt( orientation( id2 )=170, 320 ). holdsAt( appearance( id2 )=visible, 320 ). % Frame number: 9 holdsAt( orientation( id0 )=150, 360 ). holdsAt( appearance( id0 )=visible, 360 ). holdsAt( orientation( id1 )=170, 360 ). holdsAt( appearance( id1 )=visible, 360 ). holdsAt( orientation( id2 )=170, 360 ). holdsAt( appearance( id2 )=visible, 360 ). % Frame number: 10 holdsAt( orientation( id0 )=150, 400 ). holdsAt( appearance( id0 )=visible, 400 ). holdsAt( orientation( id1 )=170, 400 ). holdsAt( appearance( id1 )=visible, 400 ). holdsAt( orientation( id2 )=170, 400 ). holdsAt( appearance( id2 )=visible, 400 ). % Frame number: 11 holdsAt( orientation( id0 )=150, 440 ). holdsAt( appearance( id0 )=visible, 440 ). holdsAt( orientation( id1 )=170, 440 ). holdsAt( appearance( id1 )=visible, 440 ). holdsAt( orientation( id2 )=170, 440 ). holdsAt( appearance( id2 )=visible, 440 ). % Frame number: 12 holdsAt( orientation( id0 )=150, 480 ). holdsAt( appearance( id0 )=visible, 480 ). holdsAt( orientation( id1 )=170, 480 ). holdsAt( appearance( id1 )=visible, 480 ). holdsAt( orientation( id2 )=170, 480 ). holdsAt( appearance( id2 )=visible, 480 ). % Frame number: 13 holdsAt( orientation( id0 )=150, 520 ). holdsAt( appearance( id0 )=visible, 520 ). holdsAt( orientation( id1 )=170, 520 ). holdsAt( appearance( id1 )=visible, 520 ). holdsAt( orientation( id2 )=170, 520 ). holdsAt( appearance( id2 )=visible, 520 ). % Frame number: 14 holdsAt( orientation( id0 )=150, 560 ). holdsAt( appearance( id0 )=visible, 560 ). holdsAt( orientation( id1 )=170, 560 ). holdsAt( appearance( id1 )=visible, 560 ). holdsAt( orientation( id2 )=170, 560 ). holdsAt( appearance( id2 )=visible, 560 ). % Frame number: 15 holdsAt( orientation( id0 )=150, 600 ). holdsAt( appearance( id0 )=visible, 600 ). holdsAt( orientation( id1 )=170, 600 ). holdsAt( appearance( id1 )=visible, 600 ). holdsAt( orientation( id2 )=170, 600 ). holdsAt( appearance( id2 )=visible, 600 ). % Frame number: 16 holdsAt( orientation( id0 )=150, 640 ). holdsAt( appearance( id0 )=visible, 640 ). holdsAt( orientation( id1 )=170, 640 ). holdsAt( appearance( id1 )=visible, 640 ). holdsAt( orientation( id2 )=170, 640 ). holdsAt( appearance( id2 )=visible, 640 ). % Frame number: 17 holdsAt( orientation( id0 )=150, 680 ). holdsAt( appearance( id0 )=visible, 680 ). holdsAt( orientation( id1 )=170, 680 ). holdsAt( appearance( id1 )=visible, 680 ). holdsAt( orientation( id2 )=170, 680 ). holdsAt( appearance( id2 )=visible, 680 ). % Frame number: 18 holdsAt( orientation( id0 )=150, 720 ). holdsAt( appearance( id0 )=visible, 720 ). holdsAt( orientation( id1 )=170, 720 ). holdsAt( appearance( id1 )=visible, 720 ). holdsAt( orientation( id2 )=170, 720 ). holdsAt( appearance( id2 )=visible, 720 ). % Frame number: 19 holdsAt( orientation( id0 )=150, 760 ). holdsAt( appearance( id0 )=visible, 760 ). holdsAt( orientation( id1 )=170, 760 ). holdsAt( appearance( id1 )=visible, 760 ). holdsAt( orientation( id2 )=170, 760 ). holdsAt( appearance( id2 )=visible, 760 ). % Frame number: 20 holdsAt( orientation( id0 )=150, 800 ). holdsAt( appearance( id0 )=visible, 800 ). holdsAt( orientation( id1 )=170, 800 ). holdsAt( appearance( id1 )=visible, 800 ). holdsAt( orientation( id2 )=170, 800 ). holdsAt( appearance( id2 )=visible, 800 ). % Frame number: 21 holdsAt( orientation( id0 )=150, 840 ). holdsAt( appearance( id0 )=visible, 840 ). holdsAt( orientation( id1 )=170, 840 ). holdsAt( appearance( id1 )=visible, 840 ). holdsAt( orientation( id2 )=170, 840 ). holdsAt( appearance( id2 )=visible, 840 ). % Frame number: 22 holdsAt( orientation( id0 )=150, 880 ). holdsAt( appearance( id0 )=visible, 880 ). holdsAt( orientation( id1 )=170, 880 ). holdsAt( appearance( id1 )=visible, 880 ). holdsAt( orientation( id2 )=170, 880 ). holdsAt( appearance( id2 )=visible, 880 ). % Frame number: 23 holdsAt( orientation( id0 )=150, 920 ). holdsAt( appearance( id0 )=visible, 920 ). holdsAt( orientation( id1 )=170, 920 ). holdsAt( appearance( id1 )=visible, 920 ). holdsAt( orientation( id2 )=170, 920 ). holdsAt( appearance( id2 )=visible, 920 ). % Frame number: 24 holdsAt( orientation( id0 )=150, 960 ). holdsAt( appearance( id0 )=visible, 960 ). holdsAt( orientation( id1 )=170, 960 ). holdsAt( appearance( id1 )=visible, 960 ). holdsAt( orientation( id2 )=170, 960 ). holdsAt( appearance( id2 )=visible, 960 ). % Frame number: 25 holdsAt( orientation( id0 )=150, 1000 ). holdsAt( appearance( id0 )=visible, 1000 ). holdsAt( orientation( id1 )=170, 1000 ). holdsAt( appearance( id1 )=visible, 1000 ). holdsAt( orientation( id2 )=170, 1000 ). holdsAt( appearance( id2 )=visible, 1000 ). % Frame number: 26 holdsAt( orientation( id0 )=150, 1040 ). holdsAt( appearance( id0 )=visible, 1040 ). holdsAt( orientation( id1 )=170, 1040 ). holdsAt( appearance( id1 )=visible, 1040 ). holdsAt( orientation( id2 )=170, 1040 ). holdsAt( appearance( id2 )=visible, 1040 ). % Frame number: 27 holdsAt( orientation( id0 )=150, 1080 ). holdsAt( appearance( id0 )=visible, 1080 ). holdsAt( orientation( id1 )=170, 1080 ). holdsAt( appearance( id1 )=visible, 1080 ). holdsAt( orientation( id2 )=170, 1080 ). holdsAt( appearance( id2 )=visible, 1080 ). % Frame number: 28 holdsAt( orientation( id0 )=150, 1120 ). holdsAt( appearance( id0 )=visible, 1120 ). holdsAt( orientation( id1 )=170, 1120 ). holdsAt( appearance( id1 )=visible, 1120 ). holdsAt( orientation( id2 )=170, 1120 ). holdsAt( appearance( id2 )=visible, 1120 ). % Frame number: 29 holdsAt( orientation( id0 )=150, 1160 ). holdsAt( appearance( id0 )=visible, 1160 ). holdsAt( orientation( id1 )=170, 1160 ). holdsAt( appearance( id1 )=visible, 1160 ). holdsAt( orientation( id2 )=170, 1160 ). holdsAt( appearance( id2 )=visible, 1160 ). % Frame number: 30 holdsAt( orientation( id0 )=150, 1200 ). holdsAt( appearance( id0 )=visible, 1200 ). holdsAt( orientation( id1 )=170, 1200 ). holdsAt( appearance( id1 )=visible, 1200 ). holdsAt( orientation( id2 )=170, 1200 ). holdsAt( appearance( id2 )=visible, 1200 ). % Frame number: 31 holdsAt( orientation( id0 )=150, 1240 ). holdsAt( appearance( id0 )=visible, 1240 ). holdsAt( orientation( id1 )=150, 1240 ). holdsAt( appearance( id1 )=visible, 1240 ). holdsAt( orientation( id2 )=170, 1240 ). holdsAt( appearance( id2 )=visible, 1240 ). % Frame number: 32 holdsAt( orientation( id0 )=150, 1280 ). holdsAt( appearance( id0 )=visible, 1280 ). holdsAt( orientation( id1 )=150, 1280 ). holdsAt( appearance( id1 )=visible, 1280 ). holdsAt( orientation( id2 )=170, 1280 ). holdsAt( appearance( id2 )=visible, 1280 ). % Frame number: 33 holdsAt( orientation( id0 )=150, 1320 ). holdsAt( appearance( id0 )=visible, 1320 ). holdsAt( orientation( id1 )=150, 1320 ). holdsAt( appearance( id1 )=visible, 1320 ). holdsAt( orientation( id2 )=170, 1320 ). holdsAt( appearance( id2 )=visible, 1320 ). % Frame number: 34 holdsAt( orientation( id0 )=150, 1360 ). holdsAt( appearance( id0 )=visible, 1360 ). holdsAt( orientation( id1 )=150, 1360 ). holdsAt( appearance( id1 )=visible, 1360 ). holdsAt( orientation( id2 )=170, 1360 ). holdsAt( appearance( id2 )=visible, 1360 ). % Frame number: 35 holdsAt( orientation( id0 )=150, 1400 ). holdsAt( appearance( id0 )=visible, 1400 ). holdsAt( orientation( id1 )=150, 1400 ). holdsAt( appearance( id1 )=visible, 1400 ). holdsAt( orientation( id2 )=170, 1400 ). holdsAt( appearance( id2 )=visible, 1400 ). % Frame number: 36 holdsAt( orientation( id0 )=160, 1440 ). holdsAt( appearance( id0 )=visible, 1440 ). holdsAt( orientation( id1 )=150, 1440 ). holdsAt( appearance( id1 )=visible, 1440 ). holdsAt( orientation( id2 )=170, 1440 ). holdsAt( appearance( id2 )=visible, 1440 ). % Frame number: 37 holdsAt( orientation( id0 )=160, 1480 ). holdsAt( appearance( id0 )=visible, 1480 ). holdsAt( orientation( id1 )=150, 1480 ). holdsAt( appearance( id1 )=visible, 1480 ). holdsAt( orientation( id2 )=170, 1480 ). holdsAt( appearance( id2 )=visible, 1480 ). % Frame number: 38 holdsAt( orientation( id0 )=160, 1520 ). holdsAt( appearance( id0 )=visible, 1520 ). holdsAt( orientation( id1 )=150, 1520 ). holdsAt( appearance( id1 )=visible, 1520 ). holdsAt( orientation( id2 )=170, 1520 ). holdsAt( appearance( id2 )=visible, 1520 ). % Frame number: 39 holdsAt( orientation( id0 )=160, 1560 ). holdsAt( appearance( id0 )=visible, 1560 ). holdsAt( orientation( id1 )=150, 1560 ). holdsAt( appearance( id1 )=visible, 1560 ). holdsAt( orientation( id2 )=170, 1560 ). holdsAt( appearance( id2 )=visible, 1560 ). % Frame number: 40 holdsAt( orientation( id0 )=160, 1600 ). holdsAt( appearance( id0 )=visible, 1600 ). holdsAt( orientation( id1 )=150, 1600 ). holdsAt( appearance( id1 )=visible, 1600 ). holdsAt( orientation( id2 )=170, 1600 ). holdsAt( appearance( id2 )=visible, 1600 ). % Frame number: 41 holdsAt( orientation( id0 )=160, 1640 ). holdsAt( appearance( id0 )=visible, 1640 ). holdsAt( orientation( id1 )=150, 1640 ). holdsAt( appearance( id1 )=visible, 1640 ). holdsAt( orientation( id2 )=170, 1640 ). holdsAt( appearance( id2 )=visible, 1640 ). % Frame number: 42 holdsAt( orientation( id0 )=160, 1680 ). holdsAt( appearance( id0 )=visible, 1680 ). holdsAt( orientation( id1 )=150, 1680 ). holdsAt( appearance( id1 )=visible, 1680 ). holdsAt( orientation( id2 )=170, 1680 ). holdsAt( appearance( id2 )=visible, 1680 ). % Frame number: 43 holdsAt( orientation( id0 )=160, 1720 ). holdsAt( appearance( id0 )=visible, 1720 ). holdsAt( orientation( id1 )=150, 1720 ). holdsAt( appearance( id1 )=visible, 1720 ). holdsAt( orientation( id2 )=170, 1720 ). holdsAt( appearance( id2 )=visible, 1720 ). % Frame number: 44 holdsAt( orientation( id0 )=160, 1760 ). holdsAt( appearance( id0 )=visible, 1760 ). holdsAt( orientation( id1 )=150, 1760 ). holdsAt( appearance( id1 )=visible, 1760 ). holdsAt( orientation( id2 )=170, 1760 ). holdsAt( appearance( id2 )=visible, 1760 ). % Frame number: 45 holdsAt( orientation( id0 )=160, 1800 ). holdsAt( appearance( id0 )=visible, 1800 ). holdsAt( orientation( id1 )=150, 1800 ). holdsAt( appearance( id1 )=visible, 1800 ). holdsAt( orientation( id2 )=170, 1800 ). holdsAt( appearance( id2 )=visible, 1800 ). % Frame number: 46 holdsAt( orientation( id0 )=160, 1840 ). holdsAt( appearance( id0 )=visible, 1840 ). holdsAt( orientation( id1 )=150, 1840 ). holdsAt( appearance( id1 )=visible, 1840 ). holdsAt( orientation( id2 )=170, 1840 ). holdsAt( appearance( id2 )=visible, 1840 ). % Frame number: 47 holdsAt( orientation( id0 )=160, 1880 ). holdsAt( appearance( id0 )=visible, 1880 ). holdsAt( orientation( id1 )=150, 1880 ). holdsAt( appearance( id1 )=visible, 1880 ). holdsAt( orientation( id2 )=170, 1880 ). holdsAt( appearance( id2 )=visible, 1880 ). % Frame number: 48 holdsAt( orientation( id0 )=160, 1920 ). holdsAt( appearance( id0 )=visible, 1920 ). holdsAt( orientation( id1 )=150, 1920 ). holdsAt( appearance( id1 )=visible, 1920 ). holdsAt( orientation( id2 )=170, 1920 ). holdsAt( appearance( id2 )=visible, 1920 ). % Frame number: 49 holdsAt( orientation( id0 )=160, 1960 ). holdsAt( appearance( id0 )=visible, 1960 ). holdsAt( orientation( id1 )=150, 1960 ). holdsAt( appearance( id1 )=visible, 1960 ). holdsAt( orientation( id2 )=170, 1960 ). holdsAt( appearance( id2 )=visible, 1960 ). % Frame number: 50 holdsAt( orientation( id0 )=160, 2000 ). holdsAt( appearance( id0 )=visible, 2000 ). holdsAt( orientation( id1 )=150, 2000 ). holdsAt( appearance( id1 )=visible, 2000 ). holdsAt( orientation( id2 )=170, 2000 ). holdsAt( appearance( id2 )=visible, 2000 ). % Frame number: 51 holdsAt( orientation( id0 )=160, 2040 ). holdsAt( appearance( id0 )=visible, 2040 ). holdsAt( orientation( id1 )=150, 2040 ). holdsAt( appearance( id1 )=visible, 2040 ). holdsAt( orientation( id2 )=170, 2040 ). holdsAt( appearance( id2 )=visible, 2040 ). % Frame number: 52 holdsAt( orientation( id0 )=160, 2080 ). holdsAt( appearance( id0 )=visible, 2080 ). holdsAt( orientation( id1 )=150, 2080 ). holdsAt( appearance( id1 )=visible, 2080 ). holdsAt( orientation( id2 )=170, 2080 ). holdsAt( appearance( id2 )=visible, 2080 ). % Frame number: 53 holdsAt( orientation( id0 )=160, 2120 ). holdsAt( appearance( id0 )=visible, 2120 ). holdsAt( orientation( id1 )=150, 2120 ). holdsAt( appearance( id1 )=visible, 2120 ). holdsAt( orientation( id2 )=170, 2120 ). holdsAt( appearance( id2 )=visible, 2120 ). % Frame number: 54 holdsAt( orientation( id0 )=160, 2160 ). holdsAt( appearance( id0 )=visible, 2160 ). holdsAt( orientation( id1 )=150, 2160 ). holdsAt( appearance( id1 )=visible, 2160 ). holdsAt( orientation( id2 )=170, 2160 ). holdsAt( appearance( id2 )=visible, 2160 ). % Frame number: 55 holdsAt( orientation( id0 )=160, 2200 ). holdsAt( appearance( id0 )=visible, 2200 ). holdsAt( orientation( id1 )=150, 2200 ). holdsAt( appearance( id1 )=visible, 2200 ). holdsAt( orientation( id2 )=170, 2200 ). holdsAt( appearance( id2 )=visible, 2200 ). % Frame number: 56 holdsAt( orientation( id0 )=160, 2240 ). holdsAt( appearance( id0 )=visible, 2240 ). holdsAt( orientation( id1 )=150, 2240 ). holdsAt( appearance( id1 )=visible, 2240 ). holdsAt( orientation( id2 )=170, 2240 ). holdsAt( appearance( id2 )=visible, 2240 ). % Frame number: 57 holdsAt( orientation( id0 )=160, 2280 ). holdsAt( appearance( id0 )=visible, 2280 ). holdsAt( orientation( id1 )=150, 2280 ). holdsAt( appearance( id1 )=visible, 2280 ). holdsAt( orientation( id2 )=170, 2280 ). holdsAt( appearance( id2 )=visible, 2280 ). % Frame number: 58 holdsAt( orientation( id0 )=160, 2320 ). holdsAt( appearance( id0 )=visible, 2320 ). holdsAt( orientation( id1 )=150, 2320 ). holdsAt( appearance( id1 )=visible, 2320 ). holdsAt( orientation( id2 )=170, 2320 ). holdsAt( appearance( id2 )=visible, 2320 ). % Frame number: 59 holdsAt( orientation( id0 )=160, 2360 ). holdsAt( appearance( id0 )=visible, 2360 ). holdsAt( orientation( id1 )=150, 2360 ). holdsAt( appearance( id1 )=visible, 2360 ). holdsAt( orientation( id2 )=170, 2360 ). holdsAt( appearance( id2 )=visible, 2360 ). % Frame number: 60 holdsAt( orientation( id0 )=160, 2400 ). holdsAt( appearance( id0 )=visible, 2400 ). holdsAt( orientation( id1 )=150, 2400 ). holdsAt( appearance( id1 )=visible, 2400 ). holdsAt( orientation( id2 )=170, 2400 ). holdsAt( appearance( id2 )=visible, 2400 ). % Frame number: 61 holdsAt( orientation( id0 )=160, 2440 ). holdsAt( appearance( id0 )=visible, 2440 ). holdsAt( orientation( id1 )=150, 2440 ). holdsAt( appearance( id1 )=visible, 2440 ). holdsAt( orientation( id2 )=170, 2440 ). holdsAt( appearance( id2 )=visible, 2440 ). % Frame number: 62 holdsAt( orientation( id0 )=160, 2480 ). holdsAt( appearance( id0 )=visible, 2480 ). holdsAt( orientation( id1 )=150, 2480 ). holdsAt( appearance( id1 )=visible, 2480 ). holdsAt( orientation( id2 )=170, 2480 ). holdsAt( appearance( id2 )=visible, 2480 ). % Frame number: 63 holdsAt( orientation( id0 )=160, 2520 ). holdsAt( appearance( id0 )=visible, 2520 ). holdsAt( orientation( id1 )=150, 2520 ). holdsAt( appearance( id1 )=visible, 2520 ). holdsAt( orientation( id2 )=170, 2520 ). holdsAt( appearance( id2 )=visible, 2520 ). % Frame number: 64 holdsAt( orientation( id0 )=160, 2560 ). holdsAt( appearance( id0 )=visible, 2560 ). holdsAt( orientation( id1 )=150, 2560 ). holdsAt( appearance( id1 )=visible, 2560 ). holdsAt( orientation( id2 )=170, 2560 ). holdsAt( appearance( id2 )=visible, 2560 ). % Frame number: 65 holdsAt( orientation( id0 )=160, 2600 ). holdsAt( appearance( id0 )=visible, 2600 ). holdsAt( orientation( id1 )=150, 2600 ). holdsAt( appearance( id1 )=visible, 2600 ). holdsAt( orientation( id2 )=25, 2600 ). holdsAt( appearance( id2 )=visible, 2600 ). % Frame number: 66 holdsAt( orientation( id0 )=160, 2640 ). holdsAt( appearance( id0 )=visible, 2640 ). holdsAt( orientation( id1 )=150, 2640 ). holdsAt( appearance( id1 )=visible, 2640 ). holdsAt( orientation( id2 )=25, 2640 ). holdsAt( appearance( id2 )=visible, 2640 ). % Frame number: 67 holdsAt( orientation( id0 )=160, 2680 ). holdsAt( appearance( id0 )=visible, 2680 ). holdsAt( orientation( id1 )=150, 2680 ). holdsAt( appearance( id1 )=visible, 2680 ). holdsAt( orientation( id2 )=25, 2680 ). holdsAt( appearance( id2 )=visible, 2680 ). % Frame number: 68 holdsAt( orientation( id0 )=160, 2720 ). holdsAt( appearance( id0 )=visible, 2720 ). holdsAt( orientation( id1 )=150, 2720 ). holdsAt( appearance( id1 )=visible, 2720 ). holdsAt( orientation( id2 )=25, 2720 ). holdsAt( appearance( id2 )=visible, 2720 ). % Frame number: 69 holdsAt( orientation( id0 )=160, 2760 ). holdsAt( appearance( id0 )=visible, 2760 ). holdsAt( orientation( id1 )=150, 2760 ). holdsAt( appearance( id1 )=visible, 2760 ). holdsAt( orientation( id2 )=25, 2760 ). holdsAt( appearance( id2 )=visible, 2760 ). % Frame number: 70 holdsAt( orientation( id0 )=160, 2800 ). holdsAt( appearance( id0 )=visible, 2800 ). holdsAt( orientation( id1 )=150, 2800 ). holdsAt( appearance( id1 )=visible, 2800 ). holdsAt( orientation( id2 )=25, 2800 ). holdsAt( appearance( id2 )=visible, 2800 ). % Frame number: 71 holdsAt( orientation( id0 )=160, 2840 ). holdsAt( appearance( id0 )=visible, 2840 ). holdsAt( orientation( id1 )=150, 2840 ). holdsAt( appearance( id1 )=visible, 2840 ). holdsAt( orientation( id2 )=25, 2840 ). holdsAt( appearance( id2 )=visible, 2840 ). % Frame number: 72 holdsAt( orientation( id0 )=160, 2880 ). holdsAt( appearance( id0 )=visible, 2880 ). holdsAt( orientation( id1 )=150, 2880 ). holdsAt( appearance( id1 )=visible, 2880 ). holdsAt( orientation( id2 )=25, 2880 ). holdsAt( appearance( id2 )=visible, 2880 ). % Frame number: 73 holdsAt( orientation( id0 )=160, 2920 ). holdsAt( appearance( id0 )=visible, 2920 ). holdsAt( orientation( id1 )=150, 2920 ). holdsAt( appearance( id1 )=visible, 2920 ). holdsAt( orientation( id2 )=25, 2920 ). holdsAt( appearance( id2 )=visible, 2920 ). % Frame number: 74 holdsAt( orientation( id0 )=160, 2960 ). holdsAt( appearance( id0 )=visible, 2960 ). holdsAt( orientation( id1 )=150, 2960 ). holdsAt( appearance( id1 )=visible, 2960 ). holdsAt( orientation( id2 )=25, 2960 ). holdsAt( appearance( id2 )=visible, 2960 ). % Frame number: 75 holdsAt( orientation( id0 )=160, 3000 ). holdsAt( appearance( id0 )=visible, 3000 ). holdsAt( orientation( id1 )=150, 3000 ). holdsAt( appearance( id1 )=visible, 3000 ). holdsAt( orientation( id2 )=25, 3000 ). holdsAt( appearance( id2 )=visible, 3000 ). % Frame number: 76 holdsAt( orientation( id0 )=160, 3040 ). holdsAt( appearance( id0 )=visible, 3040 ). holdsAt( orientation( id1 )=150, 3040 ). holdsAt( appearance( id1 )=visible, 3040 ). holdsAt( orientation( id2 )=25, 3040 ). holdsAt( appearance( id2 )=disappear, 3040 ). % Frame number: 77 holdsAt( orientation( id0 )=160, 3080 ). holdsAt( appearance( id0 )=visible, 3080 ). holdsAt( orientation( id1 )=150, 3080 ). holdsAt( appearance( id1 )=visible, 3080 ). % Frame number: 78 holdsAt( orientation( id0 )=160, 3120 ). holdsAt( appearance( id0 )=visible, 3120 ). holdsAt( orientation( id1 )=150, 3120 ). holdsAt( appearance( id1 )=visible, 3120 ). % Frame number: 79 holdsAt( orientation( id0 )=160, 3160 ). holdsAt( appearance( id0 )=visible, 3160 ). holdsAt( orientation( id1 )=150, 3160 ). holdsAt( appearance( id1 )=visible, 3160 ). % Frame number: 80 holdsAt( orientation( id0 )=160, 3200 ). holdsAt( appearance( id0 )=visible, 3200 ). holdsAt( orientation( id1 )=150, 3200 ). holdsAt( appearance( id1 )=visible, 3200 ). % Frame number: 81 holdsAt( orientation( id0 )=160, 3240 ). holdsAt( appearance( id0 )=visible, 3240 ). holdsAt( orientation( id1 )=150, 3240 ). holdsAt( appearance( id1 )=visible, 3240 ). % Frame number: 82 holdsAt( orientation( id0 )=160, 3280 ). holdsAt( appearance( id0 )=visible, 3280 ). holdsAt( orientation( id1 )=150, 3280 ). holdsAt( appearance( id1 )=visible, 3280 ). % Frame number: 83 holdsAt( orientation( id0 )=160, 3320 ). holdsAt( appearance( id0 )=visible, 3320 ). holdsAt( orientation( id1 )=150, 3320 ). holdsAt( appearance( id1 )=visible, 3320 ). % Frame number: 84 holdsAt( orientation( id0 )=160, 3360 ). holdsAt( appearance( id0 )=visible, 3360 ). holdsAt( orientation( id1 )=150, 3360 ). holdsAt( appearance( id1 )=visible, 3360 ). % Frame number: 85 holdsAt( orientation( id0 )=160, 3400 ). holdsAt( appearance( id0 )=visible, 3400 ). holdsAt( orientation( id1 )=150, 3400 ). holdsAt( appearance( id1 )=visible, 3400 ). % Frame number: 86 holdsAt( orientation( id0 )=160, 3440 ). holdsAt( appearance( id0 )=visible, 3440 ). holdsAt( orientation( id1 )=150, 3440 ). holdsAt( appearance( id1 )=visible, 3440 ). % Frame number: 87 holdsAt( orientation( id0 )=160, 3480 ). holdsAt( appearance( id0 )=visible, 3480 ). holdsAt( orientation( id1 )=150, 3480 ). holdsAt( appearance( id1 )=visible, 3480 ). % Frame number: 88 holdsAt( orientation( id0 )=160, 3520 ). holdsAt( appearance( id0 )=visible, 3520 ). holdsAt( orientation( id1 )=150, 3520 ). holdsAt( appearance( id1 )=visible, 3520 ). % Frame number: 89 holdsAt( orientation( id0 )=160, 3560 ). holdsAt( appearance( id0 )=visible, 3560 ). holdsAt( orientation( id1 )=150, 3560 ). holdsAt( appearance( id1 )=visible, 3560 ). % Frame number: 90 holdsAt( orientation( id0 )=160, 3600 ). holdsAt( appearance( id0 )=visible, 3600 ). holdsAt( orientation( id1 )=150, 3600 ). holdsAt( appearance( id1 )=visible, 3600 ). % Frame number: 91 holdsAt( orientation( id0 )=160, 3640 ). holdsAt( appearance( id0 )=visible, 3640 ). holdsAt( orientation( id1 )=150, 3640 ). holdsAt( appearance( id1 )=visible, 3640 ). % Frame number: 92 holdsAt( orientation( id0 )=160, 3680 ). holdsAt( appearance( id0 )=visible, 3680 ). holdsAt( orientation( id1 )=150, 3680 ). holdsAt( appearance( id1 )=visible, 3680 ). % Frame number: 93 holdsAt( orientation( id0 )=160, 3720 ). holdsAt( appearance( id0 )=visible, 3720 ). holdsAt( orientation( id1 )=150, 3720 ). holdsAt( appearance( id1 )=visible, 3720 ). % Frame number: 94 holdsAt( orientation( id0 )=160, 3760 ). holdsAt( appearance( id0 )=visible, 3760 ). holdsAt( orientation( id1 )=150, 3760 ). holdsAt( appearance( id1 )=visible, 3760 ). % Frame number: 95 holdsAt( orientation( id0 )=160, 3800 ). holdsAt( appearance( id0 )=visible, 3800 ). holdsAt( orientation( id1 )=150, 3800 ). holdsAt( appearance( id1 )=visible, 3800 ). % Frame number: 96 holdsAt( orientation( id0 )=160, 3840 ). holdsAt( appearance( id0 )=visible, 3840 ). holdsAt( orientation( id1 )=150, 3840 ). holdsAt( appearance( id1 )=visible, 3840 ). % Frame number: 97 holdsAt( orientation( id0 )=160, 3880 ). holdsAt( appearance( id0 )=visible, 3880 ). holdsAt( orientation( id1 )=150, 3880 ). holdsAt( appearance( id1 )=visible, 3880 ). % Frame number: 98 holdsAt( orientation( id0 )=160, 3920 ). holdsAt( appearance( id0 )=visible, 3920 ). holdsAt( orientation( id1 )=150, 3920 ). holdsAt( appearance( id1 )=visible, 3920 ). % Frame number: 99 holdsAt( orientation( id0 )=160, 3960 ). holdsAt( appearance( id0 )=visible, 3960 ). holdsAt( orientation( id1 )=150, 3960 ). holdsAt( appearance( id1 )=visible, 3960 ). % Frame number: 100 holdsAt( orientation( id0 )=160, 4000 ). holdsAt( appearance( id0 )=visible, 4000 ). holdsAt( orientation( id1 )=150, 4000 ). holdsAt( appearance( id1 )=visible, 4000 ). % Frame number: 101 holdsAt( orientation( id0 )=160, 4040 ). holdsAt( appearance( id0 )=visible, 4040 ). holdsAt( orientation( id1 )=150, 4040 ). holdsAt( appearance( id1 )=visible, 4040 ). % Frame number: 102 holdsAt( orientation( id0 )=160, 4080 ). holdsAt( appearance( id0 )=visible, 4080 ). holdsAt( orientation( id1 )=150, 4080 ). holdsAt( appearance( id1 )=visible, 4080 ). % Frame number: 103 holdsAt( orientation( id0 )=160, 4120 ). holdsAt( appearance( id0 )=visible, 4120 ). holdsAt( orientation( id1 )=150, 4120 ). holdsAt( appearance( id1 )=visible, 4120 ). % Frame number: 104 holdsAt( orientation( id0 )=160, 4160 ). holdsAt( appearance( id0 )=visible, 4160 ). holdsAt( orientation( id1 )=150, 4160 ). holdsAt( appearance( id1 )=visible, 4160 ). % Frame number: 105 holdsAt( orientation( id0 )=160, 4200 ). holdsAt( appearance( id0 )=visible, 4200 ). holdsAt( orientation( id1 )=150, 4200 ). holdsAt( appearance( id1 )=visible, 4200 ). % Frame number: 106 holdsAt( orientation( id0 )=160, 4240 ). holdsAt( appearance( id0 )=visible, 4240 ). holdsAt( orientation( id1 )=150, 4240 ). holdsAt( appearance( id1 )=visible, 4240 ). % Frame number: 107 holdsAt( orientation( id0 )=160, 4280 ). holdsAt( appearance( id0 )=visible, 4280 ). holdsAt( orientation( id1 )=150, 4280 ). holdsAt( appearance( id1 )=visible, 4280 ). % Frame number: 108 holdsAt( orientation( id0 )=160, 4320 ). holdsAt( appearance( id0 )=visible, 4320 ). holdsAt( orientation( id1 )=150, 4320 ). holdsAt( appearance( id1 )=visible, 4320 ). % Frame number: 109 holdsAt( orientation( id0 )=160, 4360 ). holdsAt( appearance( id0 )=visible, 4360 ). holdsAt( orientation( id1 )=150, 4360 ). holdsAt( appearance( id1 )=visible, 4360 ). % Frame number: 110 holdsAt( orientation( id0 )=160, 4400 ). holdsAt( appearance( id0 )=visible, 4400 ). holdsAt( orientation( id1 )=150, 4400 ). holdsAt( appearance( id1 )=visible, 4400 ). % Frame number: 111 holdsAt( orientation( id0 )=160, 4440 ). holdsAt( appearance( id0 )=visible, 4440 ). holdsAt( orientation( id1 )=150, 4440 ). holdsAt( appearance( id1 )=visible, 4440 ). % Frame number: 112 holdsAt( orientation( id0 )=160, 4480 ). holdsAt( appearance( id0 )=visible, 4480 ). holdsAt( orientation( id1 )=150, 4480 ). holdsAt( appearance( id1 )=visible, 4480 ). % Frame number: 113 holdsAt( orientation( id0 )=160, 4520 ). holdsAt( appearance( id0 )=visible, 4520 ). holdsAt( orientation( id1 )=150, 4520 ). holdsAt( appearance( id1 )=visible, 4520 ). % Frame number: 114 holdsAt( orientation( id0 )=160, 4560 ). holdsAt( appearance( id0 )=visible, 4560 ). holdsAt( orientation( id1 )=150, 4560 ). holdsAt( appearance( id1 )=visible, 4560 ). % Frame number: 115 holdsAt( orientation( id0 )=160, 4600 ). holdsAt( appearance( id0 )=visible, 4600 ). holdsAt( orientation( id1 )=150, 4600 ). holdsAt( appearance( id1 )=visible, 4600 ). % Frame number: 116 holdsAt( orientation( id0 )=160, 4640 ). holdsAt( appearance( id0 )=visible, 4640 ). holdsAt( orientation( id1 )=150, 4640 ). holdsAt( appearance( id1 )=visible, 4640 ). % Frame number: 117 holdsAt( orientation( id0 )=160, 4680 ). holdsAt( appearance( id0 )=visible, 4680 ). holdsAt( orientation( id1 )=150, 4680 ). holdsAt( appearance( id1 )=visible, 4680 ). % Frame number: 118 holdsAt( orientation( id0 )=160, 4720 ). holdsAt( appearance( id0 )=visible, 4720 ). holdsAt( orientation( id1 )=150, 4720 ). holdsAt( appearance( id1 )=visible, 4720 ). % Frame number: 119 holdsAt( orientation( id0 )=160, 4760 ). holdsAt( appearance( id0 )=visible, 4760 ). holdsAt( orientation( id1 )=150, 4760 ). holdsAt( appearance( id1 )=visible, 4760 ). % Frame number: 120 holdsAt( orientation( id0 )=160, 4800 ). holdsAt( appearance( id0 )=visible, 4800 ). holdsAt( orientation( id1 )=150, 4800 ). holdsAt( appearance( id1 )=visible, 4800 ). % Frame number: 121 holdsAt( orientation( id0 )=160, 4840 ). holdsAt( appearance( id0 )=visible, 4840 ). holdsAt( orientation( id1 )=150, 4840 ). holdsAt( appearance( id1 )=visible, 4840 ). % Frame number: 122 holdsAt( orientation( id0 )=160, 4880 ). holdsAt( appearance( id0 )=visible, 4880 ). holdsAt( orientation( id1 )=150, 4880 ). holdsAt( appearance( id1 )=visible, 4880 ). % Frame number: 123 holdsAt( orientation( id0 )=160, 4920 ). holdsAt( appearance( id0 )=visible, 4920 ). holdsAt( orientation( id1 )=150, 4920 ). holdsAt( appearance( id1 )=visible, 4920 ). % Frame number: 124 holdsAt( orientation( id0 )=160, 4960 ). holdsAt( appearance( id0 )=visible, 4960 ). holdsAt( orientation( id1 )=150, 4960 ). holdsAt( appearance( id1 )=visible, 4960 ). % Frame number: 125 holdsAt( orientation( id0 )=160, 5000 ). holdsAt( appearance( id0 )=visible, 5000 ). holdsAt( orientation( id1 )=150, 5000 ). holdsAt( appearance( id1 )=visible, 5000 ). % Frame number: 126 holdsAt( orientation( id0 )=160, 5040 ). holdsAt( appearance( id0 )=visible, 5040 ). holdsAt( orientation( id1 )=150, 5040 ). holdsAt( appearance( id1 )=visible, 5040 ). % Frame number: 127 holdsAt( orientation( id0 )=160, 5080 ). holdsAt( appearance( id0 )=visible, 5080 ). holdsAt( orientation( id1 )=150, 5080 ). holdsAt( appearance( id1 )=visible, 5080 ). % Frame number: 128 holdsAt( orientation( id0 )=160, 5120 ). holdsAt( appearance( id0 )=visible, 5120 ). holdsAt( orientation( id1 )=150, 5120 ). holdsAt( appearance( id1 )=visible, 5120 ). % Frame number: 129 holdsAt( orientation( id0 )=160, 5160 ). holdsAt( appearance( id0 )=visible, 5160 ). holdsAt( orientation( id1 )=150, 5160 ). holdsAt( appearance( id1 )=visible, 5160 ). % Frame number: 130 holdsAt( orientation( id0 )=160, 5200 ). holdsAt( appearance( id0 )=visible, 5200 ). holdsAt( orientation( id1 )=150, 5200 ). holdsAt( appearance( id1 )=visible, 5200 ). % Frame number: 131 holdsAt( orientation( id0 )=160, 5240 ). holdsAt( appearance( id0 )=visible, 5240 ). holdsAt( orientation( id1 )=150, 5240 ). holdsAt( appearance( id1 )=visible, 5240 ). % Frame number: 132 holdsAt( orientation( id0 )=160, 5280 ). holdsAt( appearance( id0 )=visible, 5280 ). holdsAt( orientation( id1 )=150, 5280 ). holdsAt( appearance( id1 )=visible, 5280 ). % Frame number: 133 holdsAt( orientation( id0 )=160, 5320 ). holdsAt( appearance( id0 )=visible, 5320 ). holdsAt( orientation( id1 )=150, 5320 ). holdsAt( appearance( id1 )=visible, 5320 ). % Frame number: 134 holdsAt( orientation( id0 )=160, 5360 ). holdsAt( appearance( id0 )=visible, 5360 ). holdsAt( orientation( id1 )=150, 5360 ). holdsAt( appearance( id1 )=visible, 5360 ). % Frame number: 135 holdsAt( orientation( id0 )=160, 5400 ). holdsAt( appearance( id0 )=visible, 5400 ). holdsAt( orientation( id1 )=150, 5400 ). holdsAt( appearance( id1 )=visible, 5400 ). % Frame number: 136 holdsAt( orientation( id0 )=160, 5440 ). holdsAt( appearance( id0 )=visible, 5440 ). holdsAt( orientation( id1 )=150, 5440 ). holdsAt( appearance( id1 )=visible, 5440 ). % Frame number: 137 holdsAt( orientation( id0 )=160, 5480 ). holdsAt( appearance( id0 )=visible, 5480 ). holdsAt( orientation( id1 )=150, 5480 ). holdsAt( appearance( id1 )=visible, 5480 ). % Frame number: 138 holdsAt( orientation( id0 )=160, 5520 ). holdsAt( appearance( id0 )=visible, 5520 ). holdsAt( orientation( id1 )=150, 5520 ). holdsAt( appearance( id1 )=visible, 5520 ). % Frame number: 139 holdsAt( orientation( id0 )=160, 5560 ). holdsAt( appearance( id0 )=visible, 5560 ). holdsAt( orientation( id1 )=150, 5560 ). holdsAt( appearance( id1 )=visible, 5560 ). % Frame number: 140 holdsAt( orientation( id0 )=160, 5600 ). holdsAt( appearance( id0 )=visible, 5600 ). holdsAt( orientation( id1 )=150, 5600 ). holdsAt( appearance( id1 )=visible, 5600 ). % Frame number: 141 holdsAt( orientation( id0 )=160, 5640 ). holdsAt( appearance( id0 )=visible, 5640 ). holdsAt( orientation( id1 )=150, 5640 ). holdsAt( appearance( id1 )=visible, 5640 ). % Frame number: 142 holdsAt( orientation( id0 )=160, 5680 ). holdsAt( appearance( id0 )=visible, 5680 ). holdsAt( orientation( id1 )=150, 5680 ). holdsAt( appearance( id1 )=visible, 5680 ). % Frame number: 143 holdsAt( orientation( id0 )=160, 5720 ). holdsAt( appearance( id0 )=visible, 5720 ). holdsAt( orientation( id1 )=150, 5720 ). holdsAt( appearance( id1 )=visible, 5720 ). % Frame number: 144 holdsAt( orientation( id0 )=160, 5760 ). holdsAt( appearance( id0 )=visible, 5760 ). holdsAt( orientation( id1 )=150, 5760 ). holdsAt( appearance( id1 )=visible, 5760 ). % Frame number: 145 holdsAt( orientation( id0 )=160, 5800 ). holdsAt( appearance( id0 )=visible, 5800 ). holdsAt( orientation( id1 )=150, 5800 ). holdsAt( appearance( id1 )=visible, 5800 ). % Frame number: 146 holdsAt( orientation( id0 )=160, 5840 ). holdsAt( appearance( id0 )=visible, 5840 ). holdsAt( orientation( id1 )=150, 5840 ). holdsAt( appearance( id1 )=visible, 5840 ). % Frame number: 147 holdsAt( orientation( id0 )=160, 5880 ). holdsAt( appearance( id0 )=visible, 5880 ). holdsAt( orientation( id1 )=150, 5880 ). holdsAt( appearance( id1 )=visible, 5880 ). % Frame number: 148 holdsAt( orientation( id0 )=160, 5920 ). holdsAt( appearance( id0 )=visible, 5920 ). holdsAt( orientation( id1 )=150, 5920 ). holdsAt( appearance( id1 )=visible, 5920 ). % Frame number: 149 holdsAt( orientation( id0 )=160, 5960 ). holdsAt( appearance( id0 )=visible, 5960 ). holdsAt( orientation( id1 )=150, 5960 ). holdsAt( appearance( id1 )=visible, 5960 ). % Frame number: 150 holdsAt( orientation( id0 )=160, 6000 ). holdsAt( appearance( id0 )=visible, 6000 ). holdsAt( orientation( id1 )=150, 6000 ). holdsAt( appearance( id1 )=visible, 6000 ). % Frame number: 151 holdsAt( orientation( id0 )=160, 6040 ). holdsAt( appearance( id0 )=visible, 6040 ). holdsAt( orientation( id1 )=150, 6040 ). holdsAt( appearance( id1 )=visible, 6040 ). % Frame number: 152 holdsAt( orientation( id0 )=160, 6080 ). holdsAt( appearance( id0 )=visible, 6080 ). holdsAt( orientation( id1 )=150, 6080 ). holdsAt( appearance( id1 )=visible, 6080 ). % Frame number: 153 holdsAt( orientation( id0 )=160, 6120 ). holdsAt( appearance( id0 )=visible, 6120 ). holdsAt( orientation( id1 )=150, 6120 ). holdsAt( appearance( id1 )=visible, 6120 ). % Frame number: 154 holdsAt( orientation( id0 )=160, 6160 ). holdsAt( appearance( id0 )=visible, 6160 ). holdsAt( orientation( id1 )=150, 6160 ). holdsAt( appearance( id1 )=visible, 6160 ). % Frame number: 155 holdsAt( orientation( id0 )=160, 6200 ). holdsAt( appearance( id0 )=visible, 6200 ). holdsAt( orientation( id1 )=150, 6200 ). holdsAt( appearance( id1 )=visible, 6200 ). % Frame number: 156 holdsAt( orientation( id0 )=160, 6240 ). holdsAt( appearance( id0 )=visible, 6240 ). holdsAt( orientation( id1 )=150, 6240 ). holdsAt( appearance( id1 )=visible, 6240 ). % Frame number: 157 holdsAt( orientation( id0 )=160, 6280 ). holdsAt( appearance( id0 )=visible, 6280 ). holdsAt( orientation( id1 )=150, 6280 ). holdsAt( appearance( id1 )=visible, 6280 ). % Frame number: 158 holdsAt( orientation( id0 )=160, 6320 ). holdsAt( appearance( id0 )=visible, 6320 ). holdsAt( orientation( id1 )=150, 6320 ). holdsAt( appearance( id1 )=visible, 6320 ). % Frame number: 159 holdsAt( orientation( id0 )=160, 6360 ). holdsAt( appearance( id0 )=visible, 6360 ). holdsAt( orientation( id1 )=150, 6360 ). holdsAt( appearance( id1 )=visible, 6360 ). % Frame number: 160 holdsAt( orientation( id0 )=160, 6400 ). holdsAt( appearance( id0 )=visible, 6400 ). holdsAt( orientation( id1 )=150, 6400 ). holdsAt( appearance( id1 )=visible, 6400 ). % Frame number: 161 holdsAt( orientation( id0 )=160, 6440 ). holdsAt( appearance( id0 )=visible, 6440 ). holdsAt( orientation( id1 )=150, 6440 ). holdsAt( appearance( id1 )=visible, 6440 ). % Frame number: 162 holdsAt( orientation( id0 )=160, 6480 ). holdsAt( appearance( id0 )=visible, 6480 ). holdsAt( orientation( id1 )=150, 6480 ). holdsAt( appearance( id1 )=visible, 6480 ). % Frame number: 163 holdsAt( orientation( id0 )=160, 6520 ). holdsAt( appearance( id0 )=visible, 6520 ). holdsAt( orientation( id1 )=150, 6520 ). holdsAt( appearance( id1 )=visible, 6520 ). % Frame number: 164 holdsAt( orientation( id0 )=160, 6560 ). holdsAt( appearance( id0 )=visible, 6560 ). holdsAt( orientation( id1 )=150, 6560 ). holdsAt( appearance( id1 )=visible, 6560 ). % Frame number: 165 holdsAt( orientation( id0 )=160, 6600 ). holdsAt( appearance( id0 )=visible, 6600 ). holdsAt( orientation( id1 )=150, 6600 ). holdsAt( appearance( id1 )=visible, 6600 ). % Frame number: 166 holdsAt( orientation( id0 )=160, 6640 ). holdsAt( appearance( id0 )=visible, 6640 ). holdsAt( orientation( id1 )=150, 6640 ). holdsAt( appearance( id1 )=visible, 6640 ). % Frame number: 167 holdsAt( orientation( id0 )=160, 6680 ). holdsAt( appearance( id0 )=visible, 6680 ). holdsAt( orientation( id1 )=150, 6680 ). holdsAt( appearance( id1 )=visible, 6680 ). % Frame number: 168 holdsAt( orientation( id0 )=160, 6720 ). holdsAt( appearance( id0 )=visible, 6720 ). holdsAt( orientation( id1 )=150, 6720 ). holdsAt( appearance( id1 )=visible, 6720 ). % Frame number: 169 holdsAt( orientation( id0 )=160, 6760 ). holdsAt( appearance( id0 )=visible, 6760 ). holdsAt( orientation( id1 )=150, 6760 ). holdsAt( appearance( id1 )=visible, 6760 ). % Frame number: 170 holdsAt( orientation( id0 )=160, 6800 ). holdsAt( appearance( id0 )=visible, 6800 ). holdsAt( orientation( id1 )=150, 6800 ). holdsAt( appearance( id1 )=visible, 6800 ). % Frame number: 171 holdsAt( orientation( id0 )=160, 6840 ). holdsAt( appearance( id0 )=visible, 6840 ). holdsAt( orientation( id1 )=150, 6840 ). holdsAt( appearance( id1 )=visible, 6840 ). % Frame number: 172 holdsAt( orientation( id0 )=160, 6880 ). holdsAt( appearance( id0 )=visible, 6880 ). holdsAt( orientation( id1 )=150, 6880 ). holdsAt( appearance( id1 )=visible, 6880 ). % Frame number: 173 holdsAt( orientation( id0 )=160, 6920 ). holdsAt( appearance( id0 )=visible, 6920 ). holdsAt( orientation( id1 )=150, 6920 ). holdsAt( appearance( id1 )=visible, 6920 ). % Frame number: 174 holdsAt( orientation( id0 )=160, 6960 ). holdsAt( appearance( id0 )=visible, 6960 ). holdsAt( orientation( id1 )=150, 6960 ). holdsAt( appearance( id1 )=visible, 6960 ). % Frame number: 175 holdsAt( orientation( id0 )=160, 7000 ). holdsAt( appearance( id0 )=visible, 7000 ). holdsAt( orientation( id1 )=150, 7000 ). holdsAt( appearance( id1 )=visible, 7000 ). % Frame number: 176 holdsAt( orientation( id0 )=160, 7040 ). holdsAt( appearance( id0 )=visible, 7040 ). holdsAt( orientation( id1 )=150, 7040 ). holdsAt( appearance( id1 )=visible, 7040 ). % Frame number: 177 holdsAt( orientation( id0 )=160, 7080 ). holdsAt( appearance( id0 )=visible, 7080 ). holdsAt( orientation( id1 )=150, 7080 ). holdsAt( appearance( id1 )=visible, 7080 ). % Frame number: 178 holdsAt( orientation( id0 )=160, 7120 ). holdsAt( appearance( id0 )=visible, 7120 ). holdsAt( orientation( id1 )=150, 7120 ). holdsAt( appearance( id1 )=visible, 7120 ). % Frame number: 179 holdsAt( orientation( id0 )=160, 7160 ). holdsAt( appearance( id0 )=visible, 7160 ). holdsAt( orientation( id1 )=150, 7160 ). holdsAt( appearance( id1 )=visible, 7160 ). % Frame number: 180 holdsAt( orientation( id0 )=160, 7200 ). holdsAt( appearance( id0 )=visible, 7200 ). holdsAt( orientation( id1 )=150, 7200 ). holdsAt( appearance( id1 )=visible, 7200 ). % Frame number: 181 holdsAt( orientation( id0 )=160, 7240 ). holdsAt( appearance( id0 )=visible, 7240 ). holdsAt( orientation( id1 )=150, 7240 ). holdsAt( appearance( id1 )=visible, 7240 ). % Frame number: 182 holdsAt( orientation( id0 )=160, 7280 ). holdsAt( appearance( id0 )=visible, 7280 ). holdsAt( orientation( id1 )=150, 7280 ). holdsAt( appearance( id1 )=visible, 7280 ). % Frame number: 183 holdsAt( orientation( id0 )=160, 7320 ). holdsAt( appearance( id0 )=visible, 7320 ). holdsAt( orientation( id1 )=150, 7320 ). holdsAt( appearance( id1 )=visible, 7320 ). % Frame number: 184 holdsAt( orientation( id0 )=160, 7360 ). holdsAt( appearance( id0 )=visible, 7360 ). holdsAt( orientation( id1 )=150, 7360 ). holdsAt( appearance( id1 )=visible, 7360 ). % Frame number: 185 holdsAt( orientation( id0 )=160, 7400 ). holdsAt( appearance( id0 )=visible, 7400 ). holdsAt( orientation( id1 )=150, 7400 ). holdsAt( appearance( id1 )=visible, 7400 ). % Frame number: 186 holdsAt( orientation( id0 )=160, 7440 ). holdsAt( appearance( id0 )=visible, 7440 ). holdsAt( orientation( id1 )=150, 7440 ). holdsAt( appearance( id1 )=visible, 7440 ). % Frame number: 187 holdsAt( orientation( id0 )=160, 7480 ). holdsAt( appearance( id0 )=visible, 7480 ). holdsAt( orientation( id1 )=150, 7480 ). holdsAt( appearance( id1 )=visible, 7480 ). % Frame number: 188 holdsAt( orientation( id0 )=160, 7520 ). holdsAt( appearance( id0 )=visible, 7520 ). holdsAt( orientation( id1 )=150, 7520 ). holdsAt( appearance( id1 )=visible, 7520 ). % Frame number: 189 holdsAt( orientation( id0 )=160, 7560 ). holdsAt( appearance( id0 )=visible, 7560 ). holdsAt( orientation( id1 )=150, 7560 ). holdsAt( appearance( id1 )=visible, 7560 ). % Frame number: 190 holdsAt( orientation( id0 )=160, 7600 ). holdsAt( appearance( id0 )=visible, 7600 ). holdsAt( orientation( id1 )=150, 7600 ). holdsAt( appearance( id1 )=visible, 7600 ). % Frame number: 191 holdsAt( orientation( id0 )=160, 7640 ). holdsAt( appearance( id0 )=visible, 7640 ). holdsAt( orientation( id1 )=150, 7640 ). holdsAt( appearance( id1 )=visible, 7640 ). % Frame number: 192 holdsAt( orientation( id0 )=160, 7680 ). holdsAt( appearance( id0 )=visible, 7680 ). holdsAt( orientation( id1 )=150, 7680 ). holdsAt( appearance( id1 )=visible, 7680 ). % Frame number: 193 holdsAt( orientation( id0 )=160, 7720 ). holdsAt( appearance( id0 )=visible, 7720 ). holdsAt( orientation( id1 )=150, 7720 ). holdsAt( appearance( id1 )=visible, 7720 ). % Frame number: 194 holdsAt( orientation( id0 )=160, 7760 ). holdsAt( appearance( id0 )=visible, 7760 ). holdsAt( orientation( id1 )=150, 7760 ). holdsAt( appearance( id1 )=visible, 7760 ). % Frame number: 195 holdsAt( orientation( id0 )=160, 7800 ). holdsAt( appearance( id0 )=visible, 7800 ). holdsAt( orientation( id1 )=150, 7800 ). holdsAt( appearance( id1 )=visible, 7800 ). % Frame number: 196 holdsAt( orientation( id0 )=160, 7840 ). holdsAt( appearance( id0 )=visible, 7840 ). holdsAt( orientation( id1 )=150, 7840 ). holdsAt( appearance( id1 )=visible, 7840 ). % Frame number: 197 holdsAt( orientation( id0 )=160, 7880 ). holdsAt( appearance( id0 )=visible, 7880 ). holdsAt( orientation( id1 )=150, 7880 ). holdsAt( appearance( id1 )=visible, 7880 ). % Frame number: 198 holdsAt( orientation( id0 )=160, 7920 ). holdsAt( appearance( id0 )=visible, 7920 ). holdsAt( orientation( id1 )=170, 7920 ). holdsAt( appearance( id1 )=visible, 7920 ). % Frame number: 199 holdsAt( orientation( id0 )=160, 7960 ). holdsAt( appearance( id0 )=disappear, 7960 ). holdsAt( orientation( id1 )=170, 7960 ). holdsAt( appearance( id1 )=visible, 7960 ). % Frame number: 200 holdsAt( orientation( id1 )=170, 8000 ). holdsAt( appearance( id1 )=visible, 8000 ). % Frame number: 201 holdsAt( orientation( id1 )=170, 8040 ). holdsAt( appearance( id1 )=visible, 8040 ). % Frame number: 202 holdsAt( orientation( id1 )=170, 8080 ). holdsAt( appearance( id1 )=visible, 8080 ). % Frame number: 203 holdsAt( orientation( id1 )=170, 8120 ). holdsAt( appearance( id1 )=visible, 8120 ). % Frame number: 204 holdsAt( orientation( id1 )=170, 8160 ). holdsAt( appearance( id1 )=visible, 8160 ). % Frame number: 205 holdsAt( orientation( id1 )=170, 8200 ). holdsAt( appearance( id1 )=visible, 8200 ). % Frame number: 206 holdsAt( orientation( id1 )=170, 8240 ). holdsAt( appearance( id1 )=visible, 8240 ). % Frame number: 207 holdsAt( orientation( id1 )=170, 8280 ). holdsAt( appearance( id1 )=visible, 8280 ). % Frame number: 208 holdsAt( orientation( id1 )=170, 8320 ). holdsAt( appearance( id1 )=visible, 8320 ). % Frame number: 209 holdsAt( orientation( id1 )=25, 8360 ). holdsAt( appearance( id1 )=visible, 8360 ). % Frame number: 210 holdsAt( orientation( id1 )=25, 8400 ). holdsAt( appearance( id1 )=visible, 8400 ). % Frame number: 211 holdsAt( orientation( id1 )=40, 8440 ). holdsAt( appearance( id1 )=visible, 8440 ). % Frame number: 212 holdsAt( orientation( id1 )=40, 8480 ). holdsAt( appearance( id1 )=visible, 8480 ). % Frame number: 213 holdsAt( orientation( id1 )=40, 8520 ). holdsAt( appearance( id1 )=visible, 8520 ). % Frame number: 214 holdsAt( orientation( id1 )=40, 8560 ). holdsAt( appearance( id1 )=visible, 8560 ). % Frame number: 215 holdsAt( orientation( id1 )=40, 8600 ). holdsAt( appearance( id1 )=visible, 8600 ). % Frame number: 216 holdsAt( orientation( id1 )=40, 8640 ). holdsAt( appearance( id1 )=visible, 8640 ). % Frame number: 217 holdsAt( orientation( id1 )=40, 8680 ). holdsAt( appearance( id1 )=visible, 8680 ). % Frame number: 218 holdsAt( orientation( id1 )=40, 8720 ). holdsAt( appearance( id1 )=visible, 8720 ). % Frame number: 219 holdsAt( orientation( id1 )=40, 8760 ). holdsAt( appearance( id1 )=visible, 8760 ). % Frame number: 220 holdsAt( orientation( id1 )=40, 8800 ). holdsAt( appearance( id1 )=visible, 8800 ). % Frame number: 221 holdsAt( orientation( id1 )=40, 8840 ). holdsAt( appearance( id1 )=visible, 8840 ). % Frame number: 222 holdsAt( orientation( id1 )=40, 8880 ). holdsAt( appearance( id1 )=visible, 8880 ). % Frame number: 223 holdsAt( orientation( id1 )=80, 8920 ). holdsAt( appearance( id1 )=visible, 8920 ). % Frame number: 224 holdsAt( orientation( id1 )=80, 8960 ). holdsAt( appearance( id1 )=visible, 8960 ). % Frame number: 225 holdsAt( orientation( id1 )=80, 9000 ). holdsAt( appearance( id1 )=visible, 9000 ). % Frame number: 226 holdsAt( orientation( id1 )=80, 9040 ). holdsAt( appearance( id1 )=visible, 9040 ). % Frame number: 227 holdsAt( orientation( id1 )=80, 9080 ). holdsAt( appearance( id1 )=visible, 9080 ). % Frame number: 228 holdsAt( orientation( id1 )=80, 9120 ). holdsAt( appearance( id1 )=visible, 9120 ). % Frame number: 229 holdsAt( orientation( id1 )=80, 9160 ). holdsAt( appearance( id1 )=visible, 9160 ). % Frame number: 230 holdsAt( orientation( id1 )=80, 9200 ). holdsAt( appearance( id1 )=visible, 9200 ). % Frame number: 231 holdsAt( orientation( id1 )=80, 9240 ). holdsAt( appearance( id1 )=visible, 9240 ). % Frame number: 232 holdsAt( orientation( id1 )=80, 9280 ). holdsAt( appearance( id1 )=visible, 9280 ). % Frame number: 233 holdsAt( orientation( id1 )=80, 9320 ). holdsAt( appearance( id1 )=visible, 9320 ). % Frame number: 234 holdsAt( orientation( id1 )=80, 9360 ). holdsAt( appearance( id1 )=visible, 9360 ). % Frame number: 235 holdsAt( orientation( id1 )=80, 9400 ). holdsAt( appearance( id1 )=visible, 9400 ). % Frame number: 236 holdsAt( orientation( id1 )=80, 9440 ). holdsAt( appearance( id1 )=visible, 9440 ). % Frame number: 237 holdsAt( orientation( id1 )=80, 9480 ). holdsAt( appearance( id1 )=visible, 9480 ). % Frame number: 238 holdsAt( orientation( id1 )=80, 9520 ). holdsAt( appearance( id1 )=visible, 9520 ). % Frame number: 239 holdsAt( orientation( id1 )=80, 9560 ). holdsAt( appearance( id1 )=visible, 9560 ). % Frame number: 240 holdsAt( orientation( id1 )=80, 9600 ). holdsAt( appearance( id1 )=visible, 9600 ). % Frame number: 241 holdsAt( orientation( id1 )=80, 9640 ). holdsAt( appearance( id1 )=visible, 9640 ). % Frame number: 242 holdsAt( orientation( id1 )=80, 9680 ). holdsAt( appearance( id1 )=visible, 9680 ). % Frame number: 243 holdsAt( orientation( id1 )=80, 9720 ). holdsAt( appearance( id1 )=visible, 9720 ). % Frame number: 244 holdsAt( orientation( id1 )=80, 9760 ). holdsAt( appearance( id1 )=visible, 9760 ). % Frame number: 245 holdsAt( orientation( id1 )=80, 9800 ). holdsAt( appearance( id1 )=visible, 9800 ). % Frame number: 246 holdsAt( orientation( id1 )=80, 9840 ). holdsAt( appearance( id1 )=visible, 9840 ). % Frame number: 247 holdsAt( orientation( id1 )=80, 9880 ). holdsAt( appearance( id1 )=visible, 9880 ). % Frame number: 248 holdsAt( orientation( id1 )=80, 9920 ). holdsAt( appearance( id1 )=visible, 9920 ). % Frame number: 249 holdsAt( orientation( id1 )=80, 9960 ). holdsAt( appearance( id1 )=visible, 9960 ). % Frame number: 250 holdsAt( orientation( id1 )=80, 10000 ). holdsAt( appearance( id1 )=visible, 10000 ). % Frame number: 251 holdsAt( orientation( id1 )=80, 10040 ). holdsAt( appearance( id1 )=visible, 10040 ). % Frame number: 252 holdsAt( orientation( id1 )=80, 10080 ). holdsAt( appearance( id1 )=visible, 10080 ). % Frame number: 253 holdsAt( orientation( id1 )=80, 10120 ). holdsAt( appearance( id1 )=visible, 10120 ). % Frame number: 254 holdsAt( orientation( id1 )=80, 10160 ). holdsAt( appearance( id1 )=visible, 10160 ). % Frame number: 255 holdsAt( orientation( id1 )=80, 10200 ). holdsAt( appearance( id1 )=visible, 10200 ). % Frame number: 256 holdsAt( orientation( id1 )=80, 10240 ). holdsAt( appearance( id1 )=visible, 10240 ). % Frame number: 257 holdsAt( orientation( id1 )=80, 10280 ). holdsAt( appearance( id1 )=visible, 10280 ). % Frame number: 258 holdsAt( orientation( id1 )=80, 10320 ). holdsAt( appearance( id1 )=visible, 10320 ). % Frame number: 259 holdsAt( orientation( id1 )=80, 10360 ). holdsAt( appearance( id1 )=visible, 10360 ). % Frame number: 260 holdsAt( orientation( id1 )=80, 10400 ). holdsAt( appearance( id1 )=visible, 10400 ). % Frame number: 261 holdsAt( orientation( id1 )=80, 10440 ). holdsAt( appearance( id1 )=visible, 10440 ). % Frame number: 262 holdsAt( orientation( id1 )=80, 10480 ). holdsAt( appearance( id1 )=visible, 10480 ). % Frame number: 263 holdsAt( orientation( id1 )=80, 10520 ). holdsAt( appearance( id1 )=visible, 10520 ). % Frame number: 264 holdsAt( orientation( id1 )=80, 10560 ). holdsAt( appearance( id1 )=visible, 10560 ). % Frame number: 265 holdsAt( orientation( id1 )=80, 10600 ). holdsAt( appearance( id1 )=visible, 10600 ). % Frame number: 266 holdsAt( orientation( id1 )=80, 10640 ). holdsAt( appearance( id1 )=visible, 10640 ). % Frame number: 267 holdsAt( orientation( id1 )=80, 10680 ). holdsAt( appearance( id1 )=visible, 10680 ). % Frame number: 268 holdsAt( orientation( id1 )=80, 10720 ). holdsAt( appearance( id1 )=visible, 10720 ). % Frame number: 269 holdsAt( orientation( id1 )=80, 10760 ). holdsAt( appearance( id1 )=visible, 10760 ). % Frame number: 270 holdsAt( orientation( id1 )=80, 10800 ). holdsAt( appearance( id1 )=visible, 10800 ). % Frame number: 271 holdsAt( orientation( id1 )=80, 10840 ). holdsAt( appearance( id1 )=visible, 10840 ). % Frame number: 272 holdsAt( orientation( id1 )=80, 10880 ). holdsAt( appearance( id1 )=visible, 10880 ). % Frame number: 273 holdsAt( orientation( id1 )=80, 10920 ). holdsAt( appearance( id1 )=visible, 10920 ). % Frame number: 274 holdsAt( orientation( id1 )=80, 10960 ). holdsAt( appearance( id1 )=visible, 10960 ). % Frame number: 275 holdsAt( orientation( id1 )=80, 11000 ). holdsAt( appearance( id1 )=visible, 11000 ). % Frame number: 276 holdsAt( orientation( id1 )=80, 11040 ). holdsAt( appearance( id1 )=visible, 11040 ). % Frame number: 277 holdsAt( orientation( id1 )=80, 11080 ). holdsAt( appearance( id1 )=visible, 11080 ). % Frame number: 278 holdsAt( orientation( id1 )=80, 11120 ). holdsAt( appearance( id1 )=visible, 11120 ). % Frame number: 279 holdsAt( orientation( id1 )=80, 11160 ). holdsAt( appearance( id1 )=visible, 11160 ). % Frame number: 280 holdsAt( orientation( id1 )=80, 11200 ). holdsAt( appearance( id1 )=visible, 11200 ). % Frame number: 281 holdsAt( orientation( id1 )=80, 11240 ). holdsAt( appearance( id1 )=visible, 11240 ). % Frame number: 282 holdsAt( orientation( id1 )=80, 11280 ). holdsAt( appearance( id1 )=visible, 11280 ). % Frame number: 283 holdsAt( orientation( id1 )=80, 11320 ). holdsAt( appearance( id1 )=visible, 11320 ). % Frame number: 284 holdsAt( orientation( id1 )=80, 11360 ). holdsAt( appearance( id1 )=visible, 11360 ). holdsAt( orientation( id5 )=170, 11360 ). holdsAt( appearance( id5 )=appear, 11360 ). % Frame number: 285 holdsAt( orientation( id1 )=80, 11400 ). holdsAt( appearance( id1 )=visible, 11400 ). holdsAt( orientation( id5 )=170, 11400 ). holdsAt( appearance( id5 )=visible, 11400 ). % Frame number: 286 holdsAt( orientation( id1 )=80, 11440 ). holdsAt( appearance( id1 )=visible, 11440 ). holdsAt( orientation( id5 )=170, 11440 ). holdsAt( appearance( id5 )=visible, 11440 ). % Frame number: 287 holdsAt( orientation( id1 )=80, 11480 ). holdsAt( appearance( id1 )=visible, 11480 ). holdsAt( orientation( id5 )=170, 11480 ). holdsAt( appearance( id5 )=visible, 11480 ). % Frame number: 288 holdsAt( orientation( id1 )=80, 11520 ). holdsAt( appearance( id1 )=visible, 11520 ). holdsAt( orientation( id5 )=170, 11520 ). holdsAt( appearance( id5 )=visible, 11520 ). % Frame number: 289 holdsAt( orientation( id1 )=80, 11560 ). holdsAt( appearance( id1 )=visible, 11560 ). holdsAt( orientation( id5 )=170, 11560 ). holdsAt( appearance( id5 )=visible, 11560 ). % Frame number: 290 holdsAt( orientation( id1 )=80, 11600 ). holdsAt( appearance( id1 )=visible, 11600 ). holdsAt( orientation( id5 )=170, 11600 ). holdsAt( appearance( id5 )=visible, 11600 ). % Frame number: 291 holdsAt( orientation( id1 )=80, 11640 ). holdsAt( appearance( id1 )=visible, 11640 ). holdsAt( orientation( id5 )=170, 11640 ). holdsAt( appearance( id5 )=visible, 11640 ). % Frame number: 292 holdsAt( orientation( id1 )=80, 11680 ). holdsAt( appearance( id1 )=visible, 11680 ). holdsAt( orientation( id5 )=170, 11680 ). holdsAt( appearance( id5 )=visible, 11680 ). % Frame number: 293 holdsAt( orientation( id1 )=80, 11720 ). holdsAt( appearance( id1 )=visible, 11720 ). holdsAt( orientation( id5 )=170, 11720 ). holdsAt( appearance( id5 )=visible, 11720 ). % Frame number: 294 holdsAt( orientation( id1 )=80, 11760 ). holdsAt( appearance( id1 )=visible, 11760 ). holdsAt( orientation( id5 )=170, 11760 ). holdsAt( appearance( id5 )=visible, 11760 ). % Frame number: 295 holdsAt( orientation( id1 )=80, 11800 ). holdsAt( appearance( id1 )=visible, 11800 ). holdsAt( orientation( id5 )=170, 11800 ). holdsAt( appearance( id5 )=visible, 11800 ). % Frame number: 296 holdsAt( orientation( id1 )=80, 11840 ). holdsAt( appearance( id1 )=visible, 11840 ). holdsAt( orientation( id5 )=170, 11840 ). holdsAt( appearance( id5 )=visible, 11840 ). % Frame number: 297 holdsAt( orientation( id1 )=80, 11880 ). holdsAt( appearance( id1 )=visible, 11880 ). holdsAt( orientation( id5 )=170, 11880 ). holdsAt( appearance( id5 )=visible, 11880 ). % Frame number: 298 holdsAt( orientation( id1 )=80, 11920 ). holdsAt( appearance( id1 )=visible, 11920 ). holdsAt( orientation( id5 )=170, 11920 ). holdsAt( appearance( id5 )=visible, 11920 ). % Frame number: 299 holdsAt( orientation( id1 )=80, 11960 ). holdsAt( appearance( id1 )=visible, 11960 ). holdsAt( orientation( id5 )=170, 11960 ). holdsAt( appearance( id5 )=visible, 11960 ). % Frame number: 300 holdsAt( orientation( id1 )=80, 12000 ). holdsAt( appearance( id1 )=disappear, 12000 ). holdsAt( orientation( id5 )=170, 12000 ). holdsAt( appearance( id5 )=visible, 12000 ). % Frame number: 301 holdsAt( orientation( id5 )=170, 12040 ). holdsAt( appearance( id5 )=visible, 12040 ). % Frame number: 302 holdsAt( orientation( id5 )=170, 12080 ). holdsAt( appearance( id5 )=visible, 12080 ). % Frame number: 303 holdsAt( orientation( id5 )=170, 12120 ). holdsAt( appearance( id5 )=visible, 12120 ). % Frame number: 304 holdsAt( orientation( id5 )=170, 12160 ). holdsAt( appearance( id5 )=visible, 12160 ). % Frame number: 305 holdsAt( orientation( id5 )=170, 12200 ). holdsAt( appearance( id5 )=visible, 12200 ). % Frame number: 306 holdsAt( orientation( id5 )=170, 12240 ). holdsAt( appearance( id5 )=visible, 12240 ). % Frame number: 307 holdsAt( orientation( id5 )=170, 12280 ). holdsAt( appearance( id5 )=visible, 12280 ). % Frame number: 308 holdsAt( orientation( id5 )=170, 12320 ). holdsAt( appearance( id5 )=visible, 12320 ). % Frame number: 309 holdsAt( orientation( id5 )=170, 12360 ). holdsAt( appearance( id5 )=visible, 12360 ). % Frame number: 310 holdsAt( orientation( id5 )=170, 12400 ). holdsAt( appearance( id5 )=visible, 12400 ). % Frame number: 311 holdsAt( orientation( id5 )=170, 12440 ). holdsAt( appearance( id5 )=visible, 12440 ). % Frame number: 312 holdsAt( orientation( id5 )=170, 12480 ). holdsAt( appearance( id5 )=visible, 12480 ). % Frame number: 313 holdsAt( orientation( id5 )=170, 12520 ). holdsAt( appearance( id5 )=visible, 12520 ). % Frame number: 314 holdsAt( orientation( id5 )=170, 12560 ). holdsAt( appearance( id5 )=visible, 12560 ). % Frame number: 315 holdsAt( orientation( id5 )=170, 12600 ). holdsAt( appearance( id5 )=visible, 12600 ). % Frame number: 316 holdsAt( orientation( id5 )=170, 12640 ). holdsAt( appearance( id5 )=visible, 12640 ). % Frame number: 317 holdsAt( orientation( id5 )=170, 12680 ). holdsAt( appearance( id5 )=visible, 12680 ). % Frame number: 318 holdsAt( orientation( id5 )=170, 12720 ). holdsAt( appearance( id5 )=visible, 12720 ). % Frame number: 319 holdsAt( orientation( id5 )=170, 12760 ). holdsAt( appearance( id5 )=visible, 12760 ). % Frame number: 320 holdsAt( orientation( id5 )=170, 12800 ). holdsAt( appearance( id5 )=visible, 12800 ). % Frame number: 321 holdsAt( orientation( id5 )=170, 12840 ). holdsAt( appearance( id5 )=visible, 12840 ). % Frame number: 322 holdsAt( orientation( id5 )=170, 12880 ). holdsAt( appearance( id5 )=visible, 12880 ). % Frame number: 323 holdsAt( orientation( id5 )=170, 12920 ). holdsAt( appearance( id5 )=visible, 12920 ). % Frame number: 324 holdsAt( orientation( id5 )=170, 12960 ). holdsAt( appearance( id5 )=visible, 12960 ). % Frame number: 325 holdsAt( orientation( id5 )=170, 13000 ). holdsAt( appearance( id5 )=visible, 13000 ). % Frame number: 326 holdsAt( orientation( id5 )=170, 13040 ). holdsAt( appearance( id5 )=visible, 13040 ). % Frame number: 327 holdsAt( orientation( id5 )=170, 13080 ). holdsAt( appearance( id5 )=visible, 13080 ). % Frame number: 328 holdsAt( orientation( id5 )=170, 13120 ). holdsAt( appearance( id5 )=visible, 13120 ). % Frame number: 329 holdsAt( orientation( id5 )=170, 13160 ). holdsAt( appearance( id5 )=visible, 13160 ). % Frame number: 330 holdsAt( orientation( id5 )=170, 13200 ). holdsAt( appearance( id5 )=visible, 13200 ). % Frame number: 331 holdsAt( orientation( id5 )=170, 13240 ). holdsAt( appearance( id5 )=visible, 13240 ). % Frame number: 332 holdsAt( orientation( id5 )=170, 13280 ). holdsAt( appearance( id5 )=visible, 13280 ). % Frame number: 333 holdsAt( orientation( id5 )=170, 13320 ). holdsAt( appearance( id5 )=visible, 13320 ). % Frame number: 334 holdsAt( orientation( id5 )=170, 13360 ). holdsAt( appearance( id5 )=visible, 13360 ). % Frame number: 335 holdsAt( orientation( id5 )=170, 13400 ). holdsAt( appearance( id5 )=visible, 13400 ). % Frame number: 336 holdsAt( orientation( id5 )=170, 13440 ). holdsAt( appearance( id5 )=visible, 13440 ). % Frame number: 337 holdsAt( orientation( id5 )=170, 13480 ). holdsAt( appearance( id5 )=visible, 13480 ). % Frame number: 338 holdsAt( orientation( id5 )=170, 13520 ). holdsAt( appearance( id5 )=visible, 13520 ). % Frame number: 339 holdsAt( orientation( id5 )=170, 13560 ). holdsAt( appearance( id5 )=visible, 13560 ). % Frame number: 340 holdsAt( orientation( id5 )=170, 13600 ). holdsAt( appearance( id5 )=visible, 13600 ). % Frame number: 341 holdsAt( orientation( id5 )=170, 13640 ). holdsAt( appearance( id5 )=visible, 13640 ). % Frame number: 342 holdsAt( orientation( id5 )=170, 13680 ). holdsAt( appearance( id5 )=visible, 13680 ). % Frame number: 343 holdsAt( orientation( id5 )=170, 13720 ). holdsAt( appearance( id5 )=visible, 13720 ). % Frame number: 344 holdsAt( orientation( id5 )=170, 13760 ). holdsAt( appearance( id5 )=visible, 13760 ). % Frame number: 345 holdsAt( orientation( id5 )=170, 13800 ). holdsAt( appearance( id5 )=visible, 13800 ). % Frame number: 346 holdsAt( orientation( id5 )=170, 13840 ). holdsAt( appearance( id5 )=visible, 13840 ). % Frame number: 347 holdsAt( orientation( id5 )=170, 13880 ). holdsAt( appearance( id5 )=visible, 13880 ). % Frame number: 348 holdsAt( orientation( id5 )=170, 13920 ). holdsAt( appearance( id5 )=visible, 13920 ). % Frame number: 349 holdsAt( orientation( id5 )=170, 13960 ). holdsAt( appearance( id5 )=visible, 13960 ). % Frame number: 350 holdsAt( orientation( id5 )=170, 14000 ). holdsAt( appearance( id5 )=visible, 14000 ). % Frame number: 351 holdsAt( orientation( id5 )=170, 14040 ). holdsAt( appearance( id5 )=visible, 14040 ). % Frame number: 352 holdsAt( orientation( id5 )=170, 14080 ). holdsAt( appearance( id5 )=visible, 14080 ). % Frame number: 353 holdsAt( orientation( id5 )=170, 14120 ). holdsAt( appearance( id5 )=visible, 14120 ). % Frame number: 354 holdsAt( orientation( id5 )=170, 14160 ). holdsAt( appearance( id5 )=visible, 14160 ). % Frame number: 355 holdsAt( orientation( id5 )=170, 14200 ). holdsAt( appearance( id5 )=visible, 14200 ). % Frame number: 356 holdsAt( orientation( id5 )=170, 14240 ). holdsAt( appearance( id5 )=visible, 14240 ). % Frame number: 357 holdsAt( orientation( id5 )=170, 14280 ). holdsAt( appearance( id5 )=visible, 14280 ). % Frame number: 358 holdsAt( orientation( id5 )=170, 14320 ). holdsAt( appearance( id5 )=visible, 14320 ). % Frame number: 359 holdsAt( orientation( id5 )=170, 14360 ). holdsAt( appearance( id5 )=visible, 14360 ). % Frame number: 360 holdsAt( orientation( id5 )=170, 14400 ). holdsAt( appearance( id5 )=visible, 14400 ). % Frame number: 361 holdsAt( orientation( id5 )=170, 14440 ). holdsAt( appearance( id5 )=visible, 14440 ). % Frame number: 362 holdsAt( orientation( id5 )=170, 14480 ). holdsAt( appearance( id5 )=visible, 14480 ). % Frame number: 363 holdsAt( orientation( id5 )=170, 14520 ). holdsAt( appearance( id5 )=visible, 14520 ). % Frame number: 364 holdsAt( orientation( id5 )=170, 14560 ). holdsAt( appearance( id5 )=visible, 14560 ). % Frame number: 365 holdsAt( orientation( id5 )=170, 14600 ). holdsAt( appearance( id5 )=visible, 14600 ). % Frame number: 366 holdsAt( orientation( id5 )=170, 14640 ). holdsAt( appearance( id5 )=visible, 14640 ). % Frame number: 367 holdsAt( orientation( id5 )=170, 14680 ). holdsAt( appearance( id5 )=visible, 14680 ). % Frame number: 368 holdsAt( orientation( id5 )=170, 14720 ). holdsAt( appearance( id5 )=visible, 14720 ). % Frame number: 369 holdsAt( orientation( id5 )=170, 14760 ). holdsAt( appearance( id5 )=visible, 14760 ). % Frame number: 370 holdsAt( orientation( id5 )=170, 14800 ). holdsAt( appearance( id5 )=visible, 14800 ). % Frame number: 371 holdsAt( orientation( id5 )=170, 14840 ). holdsAt( appearance( id5 )=visible, 14840 ). % Frame number: 372 holdsAt( orientation( id5 )=170, 14880 ). holdsAt( appearance( id5 )=visible, 14880 ). % Frame number: 373 holdsAt( orientation( id5 )=170, 14920 ). holdsAt( appearance( id5 )=visible, 14920 ). % Frame number: 374 holdsAt( orientation( id5 )=170, 14960 ). holdsAt( appearance( id5 )=visible, 14960 ). % Frame number: 375 holdsAt( orientation( id5 )=170, 15000 ). holdsAt( appearance( id5 )=visible, 15000 ). % Frame number: 376 holdsAt( orientation( id5 )=170, 15040 ). holdsAt( appearance( id5 )=visible, 15040 ). % Frame number: 377 holdsAt( orientation( id5 )=170, 15080 ). holdsAt( appearance( id5 )=visible, 15080 ). % Frame number: 378 holdsAt( orientation( id5 )=170, 15120 ). holdsAt( appearance( id5 )=visible, 15120 ). % Frame number: 379 holdsAt( orientation( id5 )=170, 15160 ). holdsAt( appearance( id5 )=visible, 15160 ). % Frame number: 380 holdsAt( orientation( id5 )=170, 15200 ). holdsAt( appearance( id5 )=visible, 15200 ). % Frame number: 381 holdsAt( orientation( id5 )=170, 15240 ). holdsAt( appearance( id5 )=visible, 15240 ). % Frame number: 382 holdsAt( orientation( id5 )=170, 15280 ). holdsAt( appearance( id5 )=visible, 15280 ). % Frame number: 383 holdsAt( orientation( id5 )=170, 15320 ). holdsAt( appearance( id5 )=visible, 15320 ). % Frame number: 384 holdsAt( orientation( id5 )=170, 15360 ). holdsAt( appearance( id5 )=visible, 15360 ). % Frame number: 385 holdsAt( orientation( id5 )=170, 15400 ). holdsAt( appearance( id5 )=visible, 15400 ). % Frame number: 386 holdsAt( orientation( id5 )=170, 15440 ). holdsAt( appearance( id5 )=visible, 15440 ). % Frame number: 387 holdsAt( orientation( id5 )=170, 15480 ). holdsAt( appearance( id5 )=visible, 15480 ). % Frame number: 388 holdsAt( orientation( id5 )=170, 15520 ). holdsAt( appearance( id5 )=visible, 15520 ). % Frame number: 389 holdsAt( orientation( id5 )=170, 15560 ). holdsAt( appearance( id5 )=visible, 15560 ). % Frame number: 390 holdsAt( orientation( id5 )=170, 15600 ). holdsAt( appearance( id5 )=visible, 15600 ). % Frame number: 391 holdsAt( orientation( id5 )=170, 15640 ). holdsAt( appearance( id5 )=visible, 15640 ). % Frame number: 392 holdsAt( orientation( id5 )=170, 15680 ). holdsAt( appearance( id5 )=visible, 15680 ). % Frame number: 393 holdsAt( orientation( id5 )=170, 15720 ). holdsAt( appearance( id5 )=visible, 15720 ). % Frame number: 394 holdsAt( orientation( id5 )=170, 15760 ). holdsAt( appearance( id5 )=visible, 15760 ). % Frame number: 395 holdsAt( orientation( id5 )=170, 15800 ). holdsAt( appearance( id5 )=visible, 15800 ). % Frame number: 396 holdsAt( orientation( id5 )=170, 15840 ). holdsAt( appearance( id5 )=visible, 15840 ). % Frame number: 397 holdsAt( orientation( id5 )=150, 15880 ). holdsAt( appearance( id5 )=visible, 15880 ). % Frame number: 398 holdsAt( orientation( id5 )=150, 15920 ). holdsAt( appearance( id5 )=visible, 15920 ). % Frame number: 399 holdsAt( orientation( id5 )=150, 15960 ). holdsAt( appearance( id5 )=visible, 15960 ). % Frame number: 400 holdsAt( orientation( id5 )=150, 16000 ). holdsAt( appearance( id5 )=visible, 16000 ). % Frame number: 401 holdsAt( orientation( id5 )=150, 16040 ). holdsAt( appearance( id5 )=visible, 16040 ). % Frame number: 402 holdsAt( orientation( id5 )=150, 16080 ). holdsAt( appearance( id5 )=visible, 16080 ). % Frame number: 403 holdsAt( orientation( id5 )=150, 16120 ). holdsAt( appearance( id5 )=visible, 16120 ). % Frame number: 404 holdsAt( orientation( id5 )=150, 16160 ). holdsAt( appearance( id5 )=visible, 16160 ). % Frame number: 405 holdsAt( orientation( id5 )=150, 16200 ). holdsAt( appearance( id5 )=visible, 16200 ). % Frame number: 406 holdsAt( orientation( id5 )=150, 16240 ). holdsAt( appearance( id5 )=visible, 16240 ). % Frame number: 407 holdsAt( orientation( id5 )=150, 16280 ). holdsAt( appearance( id5 )=visible, 16280 ). % Frame number: 408 holdsAt( orientation( id5 )=150, 16320 ). holdsAt( appearance( id5 )=visible, 16320 ). % Frame number: 409 holdsAt( orientation( id5 )=150, 16360 ). holdsAt( appearance( id5 )=visible, 16360 ). % Frame number: 410 holdsAt( orientation( id5 )=150, 16400 ). holdsAt( appearance( id5 )=visible, 16400 ). % Frame number: 411 holdsAt( orientation( id5 )=150, 16440 ). holdsAt( appearance( id5 )=visible, 16440 ). % Frame number: 412 holdsAt( orientation( id5 )=150, 16480 ). holdsAt( appearance( id5 )=visible, 16480 ). % Frame number: 413 holdsAt( orientation( id5 )=150, 16520 ). holdsAt( appearance( id5 )=visible, 16520 ). % Frame number: 414 holdsAt( orientation( id5 )=150, 16560 ). holdsAt( appearance( id5 )=visible, 16560 ). % Frame number: 415 holdsAt( orientation( id5 )=150, 16600 ). holdsAt( appearance( id5 )=visible, 16600 ). % Frame number: 416 holdsAt( orientation( id5 )=150, 16640 ). holdsAt( appearance( id5 )=visible, 16640 ). % Frame number: 417 holdsAt( orientation( id5 )=150, 16680 ). holdsAt( appearance( id5 )=visible, 16680 ). % Frame number: 418 holdsAt( orientation( id5 )=150, 16720 ). holdsAt( appearance( id5 )=visible, 16720 ). % Frame number: 419 holdsAt( orientation( id5 )=150, 16760 ). holdsAt( appearance( id5 )=visible, 16760 ). % Frame number: 420 holdsAt( orientation( id5 )=150, 16800 ). holdsAt( appearance( id5 )=visible, 16800 ). % Frame number: 421 holdsAt( orientation( id5 )=150, 16840 ). holdsAt( appearance( id5 )=visible, 16840 ). % Frame number: 422 holdsAt( orientation( id5 )=150, 16880 ). holdsAt( appearance( id5 )=visible, 16880 ). % Frame number: 423 holdsAt( orientation( id5 )=150, 16920 ). holdsAt( appearance( id5 )=visible, 16920 ). % Frame number: 424 holdsAt( orientation( id5 )=150, 16960 ). holdsAt( appearance( id5 )=visible, 16960 ). % Frame number: 425 holdsAt( orientation( id5 )=150, 17000 ). holdsAt( appearance( id5 )=visible, 17000 ). % Frame number: 426 holdsAt( orientation( id5 )=150, 17040 ). holdsAt( appearance( id5 )=visible, 17040 ). % Frame number: 427 holdsAt( orientation( id5 )=150, 17080 ). holdsAt( appearance( id5 )=visible, 17080 ). % Frame number: 428 holdsAt( orientation( id5 )=150, 17120 ). holdsAt( appearance( id5 )=visible, 17120 ). % Frame number: 429 holdsAt( orientation( id5 )=150, 17160 ). holdsAt( appearance( id5 )=visible, 17160 ). % Frame number: 430 holdsAt( orientation( id5 )=150, 17200 ). holdsAt( appearance( id5 )=visible, 17200 ). % Frame number: 431 holdsAt( orientation( id5 )=150, 17240 ). holdsAt( appearance( id5 )=visible, 17240 ). % Frame number: 432 holdsAt( orientation( id5 )=150, 17280 ). holdsAt( appearance( id5 )=visible, 17280 ). % Frame number: 433 holdsAt( orientation( id5 )=150, 17320 ). holdsAt( appearance( id5 )=visible, 17320 ). % Frame number: 434 holdsAt( orientation( id5 )=150, 17360 ). holdsAt( appearance( id5 )=visible, 17360 ). % Frame number: 435 holdsAt( orientation( id5 )=150, 17400 ). holdsAt( appearance( id5 )=visible, 17400 ). % Frame number: 436 holdsAt( orientation( id5 )=150, 17440 ). holdsAt( appearance( id5 )=visible, 17440 ). % Frame number: 437 holdsAt( orientation( id5 )=150, 17480 ). holdsAt( appearance( id5 )=visible, 17480 ). % Frame number: 438 holdsAt( orientation( id5 )=150, 17520 ). holdsAt( appearance( id5 )=visible, 17520 ). % Frame number: 439 holdsAt( orientation( id5 )=150, 17560 ). holdsAt( appearance( id5 )=visible, 17560 ). % Frame number: 440 holdsAt( orientation( id5 )=150, 17600 ). holdsAt( appearance( id5 )=visible, 17600 ). % Frame number: 441 holdsAt( orientation( id5 )=150, 17640 ). holdsAt( appearance( id5 )=visible, 17640 ). % Frame number: 442 holdsAt( orientation( id5 )=150, 17680 ). holdsAt( appearance( id5 )=visible, 17680 ). % Frame number: 443 holdsAt( orientation( id5 )=150, 17720 ). holdsAt( appearance( id5 )=visible, 17720 ). % Frame number: 444 holdsAt( orientation( id5 )=150, 17760 ). holdsAt( appearance( id5 )=visible, 17760 ). % Frame number: 445 holdsAt( orientation( id5 )=150, 17800 ). holdsAt( appearance( id5 )=visible, 17800 ). % Frame number: 446 holdsAt( orientation( id5 )=150, 17840 ). holdsAt( appearance( id5 )=visible, 17840 ). % Frame number: 447 holdsAt( orientation( id5 )=150, 17880 ). holdsAt( appearance( id5 )=visible, 17880 ). % Frame number: 448 holdsAt( orientation( id5 )=150, 17920 ). holdsAt( appearance( id5 )=visible, 17920 ). % Frame number: 449 holdsAt( orientation( id5 )=150, 17960 ). holdsAt( appearance( id5 )=visible, 17960 ). % Frame number: 450 holdsAt( orientation( id5 )=150, 18000 ). holdsAt( appearance( id5 )=visible, 18000 ). % Frame number: 451 holdsAt( orientation( id5 )=150, 18040 ). holdsAt( appearance( id5 )=visible, 18040 ). % Frame number: 452 holdsAt( orientation( id5 )=150, 18080 ). holdsAt( appearance( id5 )=visible, 18080 ). % Frame number: 453 holdsAt( orientation( id5 )=150, 18120 ). holdsAt( appearance( id5 )=visible, 18120 ). % Frame number: 454 holdsAt( orientation( id5 )=150, 18160 ). holdsAt( appearance( id5 )=visible, 18160 ). % Frame number: 455 holdsAt( orientation( id5 )=150, 18200 ). holdsAt( appearance( id5 )=visible, 18200 ). % Frame number: 456 holdsAt( orientation( id5 )=150, 18240 ). holdsAt( appearance( id5 )=visible, 18240 ). % Frame number: 457 holdsAt( orientation( id5 )=150, 18280 ). holdsAt( appearance( id5 )=visible, 18280 ). % Frame number: 458 holdsAt( orientation( id5 )=150, 18320 ). holdsAt( appearance( id5 )=visible, 18320 ). % Frame number: 459 holdsAt( orientation( id5 )=150, 18360 ). holdsAt( appearance( id5 )=visible, 18360 ). % Frame number: 460 holdsAt( orientation( id5 )=150, 18400 ). holdsAt( appearance( id5 )=visible, 18400 ). % Frame number: 461 holdsAt( orientation( id5 )=150, 18440 ). holdsAt( appearance( id5 )=visible, 18440 ). % Frame number: 462 holdsAt( orientation( id5 )=150, 18480 ). holdsAt( appearance( id5 )=visible, 18480 ). % Frame number: 463 holdsAt( orientation( id5 )=150, 18520 ). holdsAt( appearance( id5 )=visible, 18520 ). % Frame number: 464 holdsAt( orientation( id5 )=150, 18560 ). holdsAt( appearance( id5 )=visible, 18560 ). % Frame number: 465 holdsAt( orientation( id5 )=150, 18600 ). holdsAt( appearance( id5 )=visible, 18600 ). % Frame number: 466 holdsAt( orientation( id5 )=150, 18640 ). holdsAt( appearance( id5 )=visible, 18640 ). % Frame number: 467 holdsAt( orientation( id5 )=150, 18680 ). holdsAt( appearance( id5 )=visible, 18680 ). % Frame number: 468 holdsAt( orientation( id5 )=150, 18720 ). holdsAt( appearance( id5 )=visible, 18720 ). % Frame number: 469 holdsAt( orientation( id5 )=150, 18760 ). holdsAt( appearance( id5 )=visible, 18760 ). % Frame number: 470 holdsAt( orientation( id5 )=150, 18800 ). holdsAt( appearance( id5 )=visible, 18800 ). % Frame number: 471 holdsAt( orientation( id5 )=150, 18840 ). holdsAt( appearance( id5 )=visible, 18840 ). % Frame number: 472 holdsAt( orientation( id5 )=150, 18880 ). holdsAt( appearance( id5 )=visible, 18880 ). % Frame number: 473 holdsAt( orientation( id5 )=150, 18920 ). holdsAt( appearance( id5 )=visible, 18920 ). % Frame number: 474 holdsAt( orientation( id5 )=150, 18960 ). holdsAt( appearance( id5 )=visible, 18960 ). % Frame number: 475 holdsAt( orientation( id5 )=150, 19000 ). holdsAt( appearance( id5 )=visible, 19000 ). % Frame number: 476 holdsAt( orientation( id5 )=150, 19040 ). holdsAt( appearance( id5 )=visible, 19040 ). % Frame number: 477 holdsAt( orientation( id5 )=150, 19080 ). holdsAt( appearance( id5 )=visible, 19080 ). % Frame number: 478 holdsAt( orientation( id5 )=150, 19120 ). holdsAt( appearance( id5 )=visible, 19120 ). % Frame number: 479 holdsAt( orientation( id5 )=150, 19160 ). holdsAt( appearance( id5 )=visible, 19160 ). % Frame number: 480 holdsAt( orientation( id5 )=150, 19200 ). holdsAt( appearance( id5 )=visible, 19200 ). % Frame number: 481 holdsAt( orientation( id5 )=150, 19240 ). holdsAt( appearance( id5 )=visible, 19240 ). % Frame number: 482 holdsAt( orientation( id5 )=150, 19280 ). holdsAt( appearance( id5 )=visible, 19280 ). % Frame number: 483 holdsAt( orientation( id5 )=150, 19320 ). holdsAt( appearance( id5 )=visible, 19320 ). % Frame number: 484 holdsAt( orientation( id5 )=150, 19360 ). holdsAt( appearance( id5 )=visible, 19360 ). % Frame number: 485 holdsAt( orientation( id5 )=150, 19400 ). holdsAt( appearance( id5 )=visible, 19400 ). % Frame number: 486 holdsAt( orientation( id5 )=150, 19440 ). holdsAt( appearance( id5 )=visible, 19440 ). % Frame number: 487 holdsAt( orientation( id5 )=150, 19480 ). holdsAt( appearance( id5 )=visible, 19480 ). % Frame number: 488 holdsAt( orientation( id5 )=150, 19520 ). holdsAt( appearance( id5 )=visible, 19520 ). % Frame number: 489 holdsAt( orientation( id5 )=150, 19560 ). holdsAt( appearance( id5 )=visible, 19560 ). % Frame number: 490 holdsAt( orientation( id5 )=150, 19600 ). holdsAt( appearance( id5 )=visible, 19600 ). % Frame number: 491 holdsAt( orientation( id5 )=150, 19640 ). holdsAt( appearance( id5 )=visible, 19640 ). % Frame number: 492 holdsAt( orientation( id5 )=150, 19680 ). holdsAt( appearance( id5 )=visible, 19680 ). % Frame number: 493 holdsAt( orientation( id5 )=150, 19720 ). holdsAt( appearance( id5 )=visible, 19720 ). % Frame number: 494 holdsAt( orientation( id5 )=150, 19760 ). holdsAt( appearance( id5 )=visible, 19760 ). % Frame number: 495 holdsAt( orientation( id5 )=150, 19800 ). holdsAt( appearance( id5 )=visible, 19800 ). % Frame number: 496 holdsAt( orientation( id5 )=150, 19840 ). holdsAt( appearance( id5 )=visible, 19840 ). % Frame number: 497 holdsAt( orientation( id5 )=150, 19880 ). holdsAt( appearance( id5 )=visible, 19880 ). % Frame number: 498 holdsAt( orientation( id5 )=150, 19920 ). holdsAt( appearance( id5 )=visible, 19920 ). % Frame number: 499 holdsAt( orientation( id5 )=150, 19960 ). holdsAt( appearance( id5 )=visible, 19960 ). % Frame number: 500 holdsAt( orientation( id5 )=150, 20000 ). holdsAt( appearance( id5 )=visible, 20000 ). % Frame number: 501 holdsAt( orientation( id5 )=150, 20040 ). holdsAt( appearance( id5 )=visible, 20040 ). % Frame number: 502 holdsAt( orientation( id5 )=150, 20080 ). holdsAt( appearance( id5 )=visible, 20080 ). % Frame number: 503 holdsAt( orientation( id5 )=150, 20120 ). holdsAt( appearance( id5 )=visible, 20120 ). % Frame number: 504 holdsAt( orientation( id5 )=150, 20160 ). holdsAt( appearance( id5 )=visible, 20160 ). % Frame number: 505 holdsAt( orientation( id5 )=150, 20200 ). holdsAt( appearance( id5 )=visible, 20200 ). % Frame number: 506 holdsAt( orientation( id5 )=150, 20240 ). holdsAt( appearance( id5 )=visible, 20240 ). % Frame number: 507 holdsAt( orientation( id5 )=150, 20280 ). holdsAt( appearance( id5 )=visible, 20280 ). % Frame number: 508 holdsAt( orientation( id5 )=150, 20320 ). holdsAt( appearance( id5 )=visible, 20320 ). % Frame number: 509 holdsAt( orientation( id5 )=150, 20360 ). holdsAt( appearance( id5 )=visible, 20360 ). % Frame number: 510 holdsAt( orientation( id5 )=150, 20400 ). holdsAt( appearance( id5 )=visible, 20400 ). % Frame number: 511 holdsAt( orientation( id5 )=150, 20440 ). holdsAt( appearance( id5 )=visible, 20440 ). % Frame number: 512 holdsAt( orientation( id5 )=150, 20480 ). holdsAt( appearance( id5 )=visible, 20480 ). % Frame number: 513 holdsAt( orientation( id5 )=150, 20520 ). holdsAt( appearance( id5 )=visible, 20520 ). % Frame number: 514 holdsAt( orientation( id5 )=150, 20560 ). holdsAt( appearance( id5 )=visible, 20560 ). % Frame number: 515 holdsAt( orientation( id5 )=140, 20600 ). holdsAt( appearance( id5 )=visible, 20600 ). % Frame number: 516 holdsAt( orientation( id5 )=140, 20640 ). holdsAt( appearance( id5 )=visible, 20640 ). % Frame number: 517 holdsAt( orientation( id5 )=140, 20680 ). holdsAt( appearance( id5 )=visible, 20680 ). % Frame number: 518 holdsAt( orientation( id5 )=140, 20720 ). holdsAt( appearance( id5 )=visible, 20720 ). % Frame number: 519 holdsAt( orientation( id5 )=140, 20760 ). holdsAt( appearance( id5 )=visible, 20760 ). % Frame number: 520 holdsAt( orientation( id5 )=140, 20800 ). holdsAt( appearance( id5 )=visible, 20800 ). % Frame number: 521 holdsAt( orientation( id5 )=140, 20840 ). holdsAt( appearance( id5 )=visible, 20840 ). % Frame number: 522 holdsAt( orientation( id5 )=140, 20880 ). holdsAt( appearance( id5 )=visible, 20880 ). % Frame number: 523 holdsAt( orientation( id5 )=140, 20920 ). holdsAt( appearance( id5 )=visible, 20920 ). % Frame number: 524 holdsAt( orientation( id5 )=140, 20960 ). holdsAt( appearance( id5 )=visible, 20960 ). % Frame number: 525 holdsAt( orientation( id5 )=140, 21000 ). holdsAt( appearance( id5 )=visible, 21000 ). % Frame number: 526 holdsAt( orientation( id5 )=140, 21040 ). holdsAt( appearance( id5 )=visible, 21040 ). % Frame number: 527 holdsAt( orientation( id5 )=140, 21080 ). holdsAt( appearance( id5 )=visible, 21080 ). % Frame number: 528 holdsAt( orientation( id5 )=110, 21120 ). holdsAt( appearance( id5 )=visible, 21120 ). % Frame number: 529 holdsAt( orientation( id5 )=110, 21160 ). holdsAt( appearance( id5 )=visible, 21160 ). % Frame number: 530 holdsAt( orientation( id5 )=110, 21200 ). holdsAt( appearance( id5 )=visible, 21200 ). % Frame number: 531 holdsAt( orientation( id5 )=110, 21240 ). holdsAt( appearance( id5 )=visible, 21240 ). % Frame number: 532 holdsAt( orientation( id5 )=110, 21280 ). holdsAt( appearance( id5 )=visible, 21280 ). % Frame number: 533 holdsAt( orientation( id5 )=110, 21320 ). holdsAt( appearance( id5 )=visible, 21320 ). % Frame number: 534 holdsAt( orientation( id5 )=110, 21360 ). holdsAt( appearance( id5 )=visible, 21360 ). % Frame number: 535 holdsAt( orientation( id5 )=110, 21400 ). holdsAt( appearance( id5 )=visible, 21400 ). % Frame number: 536 holdsAt( orientation( id5 )=110, 21440 ). holdsAt( appearance( id5 )=visible, 21440 ). % Frame number: 537 holdsAt( orientation( id5 )=110, 21480 ). holdsAt( appearance( id5 )=visible, 21480 ). % Frame number: 538 holdsAt( orientation( id5 )=110, 21520 ). holdsAt( appearance( id5 )=visible, 21520 ). % Frame number: 539 holdsAt( orientation( id5 )=110, 21560 ). holdsAt( appearance( id5 )=visible, 21560 ). % Frame number: 540 holdsAt( orientation( id5 )=110, 21600 ). holdsAt( appearance( id5 )=visible, 21600 ). % Frame number: 541 holdsAt( orientation( id5 )=110, 21640 ). holdsAt( appearance( id5 )=visible, 21640 ). % Frame number: 542 holdsAt( orientation( id5 )=110, 21680 ). holdsAt( appearance( id5 )=visible, 21680 ). % Frame number: 543 holdsAt( orientation( id5 )=110, 21720 ). holdsAt( appearance( id5 )=visible, 21720 ). % Frame number: 544 holdsAt( orientation( id5 )=110, 21760 ). holdsAt( appearance( id5 )=visible, 21760 ). % Frame number: 545 holdsAt( orientation( id5 )=110, 21800 ). holdsAt( appearance( id5 )=visible, 21800 ). % Frame number: 546 holdsAt( orientation( id5 )=110, 21840 ). holdsAt( appearance( id5 )=visible, 21840 ). % Frame number: 547 holdsAt( orientation( id5 )=110, 21880 ). holdsAt( appearance( id5 )=visible, 21880 ). % Frame number: 548 holdsAt( orientation( id5 )=110, 21920 ). holdsAt( appearance( id5 )=visible, 21920 ). % Frame number: 549 holdsAt( orientation( id5 )=110, 21960 ). holdsAt( appearance( id5 )=visible, 21960 ). % Frame number: 550 holdsAt( orientation( id5 )=110, 22000 ). holdsAt( appearance( id5 )=visible, 22000 ). % Frame number: 551 holdsAt( orientation( id5 )=110, 22040 ). holdsAt( appearance( id5 )=visible, 22040 ). % Frame number: 552 holdsAt( orientation( id5 )=110, 22080 ). holdsAt( appearance( id5 )=visible, 22080 ). % Frame number: 553 holdsAt( orientation( id5 )=110, 22120 ). holdsAt( appearance( id5 )=visible, 22120 ). % Frame number: 554 holdsAt( orientation( id5 )=110, 22160 ). holdsAt( appearance( id5 )=visible, 22160 ). % Frame number: 555 holdsAt( orientation( id5 )=110, 22200 ). holdsAt( appearance( id5 )=visible, 22200 ). % Frame number: 556 holdsAt( orientation( id5 )=110, 22240 ). holdsAt( appearance( id5 )=visible, 22240 ). % Frame number: 557 holdsAt( orientation( id5 )=110, 22280 ). holdsAt( appearance( id5 )=visible, 22280 ). % Frame number: 558 holdsAt( orientation( id5 )=110, 22320 ). holdsAt( appearance( id5 )=visible, 22320 ). % Frame number: 559 holdsAt( orientation( id5 )=110, 22360 ). holdsAt( appearance( id5 )=visible, 22360 ). % Frame number: 560 holdsAt( orientation( id5 )=110, 22400 ). holdsAt( appearance( id5 )=visible, 22400 ). % Frame number: 561 holdsAt( orientation( id5 )=110, 22440 ). holdsAt( appearance( id5 )=visible, 22440 ). % Frame number: 562 holdsAt( orientation( id5 )=110, 22480 ). holdsAt( appearance( id5 )=visible, 22480 ). % Frame number: 563 holdsAt( orientation( id5 )=110, 22520 ). holdsAt( appearance( id5 )=visible, 22520 ). % Frame number: 564 holdsAt( orientation( id5 )=110, 22560 ). holdsAt( appearance( id5 )=visible, 22560 ). % Frame number: 565 holdsAt( orientation( id5 )=110, 22600 ). holdsAt( appearance( id5 )=visible, 22600 ). % Frame number: 566 holdsAt( orientation( id5 )=110, 22640 ). holdsAt( appearance( id5 )=visible, 22640 ). % Frame number: 567 holdsAt( orientation( id5 )=110, 22680 ). holdsAt( appearance( id5 )=visible, 22680 ). % Frame number: 568 holdsAt( orientation( id5 )=110, 22720 ). holdsAt( appearance( id5 )=visible, 22720 ). % Frame number: 569 holdsAt( orientation( id5 )=100, 22760 ). holdsAt( appearance( id5 )=visible, 22760 ). % Frame number: 570 holdsAt( orientation( id5 )=100, 22800 ). holdsAt( appearance( id5 )=visible, 22800 ). % Frame number: 571 holdsAt( orientation( id5 )=100, 22840 ). holdsAt( appearance( id5 )=visible, 22840 ). % Frame number: 572 holdsAt( orientation( id5 )=100, 22880 ). holdsAt( appearance( id5 )=visible, 22880 ). % Frame number: 573 holdsAt( orientation( id5 )=100, 22920 ). holdsAt( appearance( id5 )=visible, 22920 ). % Frame number: 574 holdsAt( orientation( id5 )=100, 22960 ). holdsAt( appearance( id5 )=visible, 22960 ). % Frame number: 575 holdsAt( orientation( id5 )=100, 23000 ). holdsAt( appearance( id5 )=visible, 23000 ). % Frame number: 576 holdsAt( orientation( id5 )=100, 23040 ). holdsAt( appearance( id5 )=visible, 23040 ). % Frame number: 577 holdsAt( orientation( id5 )=100, 23080 ). holdsAt( appearance( id5 )=visible, 23080 ). % Frame number: 578 holdsAt( orientation( id5 )=100, 23120 ). holdsAt( appearance( id5 )=visible, 23120 ). % Frame number: 579 holdsAt( orientation( id5 )=100, 23160 ). holdsAt( appearance( id5 )=visible, 23160 ). % Frame number: 580 holdsAt( orientation( id5 )=100, 23200 ). holdsAt( appearance( id5 )=visible, 23200 ). % Frame number: 581 holdsAt( orientation( id5 )=100, 23240 ). holdsAt( appearance( id5 )=visible, 23240 ). % Frame number: 582 holdsAt( orientation( id5 )=100, 23280 ). holdsAt( appearance( id5 )=visible, 23280 ). % Frame number: 583 holdsAt( orientation( id5 )=100, 23320 ). holdsAt( appearance( id5 )=visible, 23320 ). % Frame number: 584 holdsAt( orientation( id5 )=100, 23360 ). holdsAt( appearance( id5 )=visible, 23360 ). % Frame number: 585 holdsAt( orientation( id5 )=100, 23400 ). holdsAt( appearance( id5 )=visible, 23400 ). % Frame number: 586 holdsAt( orientation( id5 )=100, 23440 ). holdsAt( appearance( id5 )=visible, 23440 ). % Frame number: 587 holdsAt( orientation( id5 )=100, 23480 ). holdsAt( appearance( id5 )=visible, 23480 ). % Frame number: 588 holdsAt( orientation( id5 )=100, 23520 ). holdsAt( appearance( id5 )=visible, 23520 ). % Frame number: 589 holdsAt( orientation( id5 )=100, 23560 ). holdsAt( appearance( id5 )=visible, 23560 ). % Frame number: 590 holdsAt( orientation( id5 )=100, 23600 ). holdsAt( appearance( id5 )=visible, 23600 ). % Frame number: 591 holdsAt( orientation( id5 )=100, 23640 ). holdsAt( appearance( id5 )=visible, 23640 ). % Frame number: 592 holdsAt( orientation( id5 )=100, 23680 ). holdsAt( appearance( id5 )=visible, 23680 ). % Frame number: 593 holdsAt( orientation( id5 )=100, 23720 ). holdsAt( appearance( id5 )=visible, 23720 ). % Frame number: 594 holdsAt( orientation( id5 )=100, 23760 ). holdsAt( appearance( id5 )=visible, 23760 ). % Frame number: 595 holdsAt( orientation( id5 )=100, 23800 ). holdsAt( appearance( id5 )=visible, 23800 ). % Frame number: 596 holdsAt( orientation( id5 )=100, 23840 ). holdsAt( appearance( id5 )=visible, 23840 ). % Frame number: 597 holdsAt( orientation( id5 )=100, 23880 ). holdsAt( appearance( id5 )=visible, 23880 ). % Frame number: 598 holdsAt( orientation( id5 )=100, 23920 ). holdsAt( appearance( id5 )=visible, 23920 ). % Frame number: 599 holdsAt( orientation( id5 )=100, 23960 ). holdsAt( appearance( id5 )=visible, 23960 ). % Frame number: 600 holdsAt( orientation( id5 )=100, 24000 ). holdsAt( appearance( id5 )=visible, 24000 ). % Frame number: 601 holdsAt( orientation( id5 )=100, 24040 ). holdsAt( appearance( id5 )=visible, 24040 ). % Frame number: 602 holdsAt( orientation( id5 )=100, 24080 ). holdsAt( appearance( id5 )=visible, 24080 ). % Frame number: 603 holdsAt( orientation( id5 )=100, 24120 ). holdsAt( appearance( id5 )=visible, 24120 ). % Frame number: 604 holdsAt( orientation( id5 )=100, 24160 ). holdsAt( appearance( id5 )=visible, 24160 ). % Frame number: 605 holdsAt( orientation( id5 )=100, 24200 ). holdsAt( appearance( id5 )=visible, 24200 ). % Frame number: 606 holdsAt( orientation( id5 )=100, 24240 ). holdsAt( appearance( id5 )=visible, 24240 ). % Frame number: 607 holdsAt( orientation( id5 )=100, 24280 ). holdsAt( appearance( id5 )=visible, 24280 ). % Frame number: 608 holdsAt( orientation( id5 )=100, 24320 ). holdsAt( appearance( id5 )=visible, 24320 ). % Frame number: 609 holdsAt( orientation( id5 )=100, 24360 ). holdsAt( appearance( id5 )=visible, 24360 ). % Frame number: 610 holdsAt( orientation( id5 )=100, 24400 ). holdsAt( appearance( id5 )=visible, 24400 ). % Frame number: 611 holdsAt( orientation( id5 )=100, 24440 ). holdsAt( appearance( id5 )=visible, 24440 ). % Frame number: 612 holdsAt( orientation( id5 )=100, 24480 ). holdsAt( appearance( id5 )=visible, 24480 ). % Frame number: 613 holdsAt( orientation( id5 )=100, 24520 ). holdsAt( appearance( id5 )=visible, 24520 ). % Frame number: 614 holdsAt( orientation( id5 )=100, 24560 ). holdsAt( appearance( id5 )=visible, 24560 ). % Frame number: 615 holdsAt( orientation( id5 )=100, 24600 ). holdsAt( appearance( id5 )=visible, 24600 ). % Frame number: 616 holdsAt( orientation( id5 )=100, 24640 ). holdsAt( appearance( id5 )=visible, 24640 ). % Frame number: 617 holdsAt( orientation( id5 )=100, 24680 ). holdsAt( appearance( id5 )=visible, 24680 ). % Frame number: 618 holdsAt( orientation( id5 )=100, 24720 ). holdsAt( appearance( id5 )=visible, 24720 ). % Frame number: 619 holdsAt( orientation( id5 )=100, 24760 ). holdsAt( appearance( id5 )=visible, 24760 ). % Frame number: 620 holdsAt( orientation( id5 )=100, 24800 ). holdsAt( appearance( id5 )=visible, 24800 ). % Frame number: 621 holdsAt( orientation( id5 )=100, 24840 ). holdsAt( appearance( id5 )=visible, 24840 ). % Frame number: 622 holdsAt( orientation( id5 )=100, 24880 ). holdsAt( appearance( id5 )=visible, 24880 ). % Frame number: 623 holdsAt( orientation( id5 )=100, 24920 ). holdsAt( appearance( id5 )=visible, 24920 ). % Frame number: 624 holdsAt( orientation( id5 )=100, 24960 ). holdsAt( appearance( id5 )=visible, 24960 ). % Frame number: 625 holdsAt( orientation( id5 )=100, 25000 ). holdsAt( appearance( id5 )=visible, 25000 ). % Frame number: 626 holdsAt( orientation( id5 )=100, 25040 ). holdsAt( appearance( id5 )=visible, 25040 ). % Frame number: 627 holdsAt( orientation( id5 )=100, 25080 ). holdsAt( appearance( id5 )=visible, 25080 ). % Frame number: 628 holdsAt( orientation( id5 )=75, 25120 ). holdsAt( appearance( id5 )=visible, 25120 ). % Frame number: 629 holdsAt( orientation( id5 )=75, 25160 ). holdsAt( appearance( id5 )=visible, 25160 ). % Frame number: 630 holdsAt( orientation( id5 )=75, 25200 ). holdsAt( appearance( id5 )=visible, 25200 ). % Frame number: 631 holdsAt( orientation( id5 )=75, 25240 ). holdsAt( appearance( id5 )=visible, 25240 ). % Frame number: 632 holdsAt( orientation( id5 )=75, 25280 ). holdsAt( appearance( id5 )=visible, 25280 ). % Frame number: 633 holdsAt( orientation( id5 )=75, 25320 ). holdsAt( appearance( id5 )=visible, 25320 ). % Frame number: 634 holdsAt( orientation( id5 )=75, 25360 ). holdsAt( appearance( id5 )=visible, 25360 ). % Frame number: 635 holdsAt( orientation( id5 )=75, 25400 ). holdsAt( appearance( id5 )=visible, 25400 ). % Frame number: 636 holdsAt( orientation( id5 )=75, 25440 ). holdsAt( appearance( id5 )=visible, 25440 ). % Frame number: 637 holdsAt( orientation( id5 )=75, 25480 ). holdsAt( appearance( id5 )=visible, 25480 ). % Frame number: 638 holdsAt( orientation( id5 )=75, 25520 ). holdsAt( appearance( id5 )=visible, 25520 ). % Frame number: 639 holdsAt( orientation( id5 )=75, 25560 ). holdsAt( appearance( id5 )=visible, 25560 ). % Frame number: 640 holdsAt( orientation( id5 )=75, 25600 ). holdsAt( appearance( id5 )=visible, 25600 ). % Frame number: 641 holdsAt( orientation( id5 )=75, 25640 ). holdsAt( appearance( id5 )=visible, 25640 ). % Frame number: 642 holdsAt( orientation( id5 )=75, 25680 ). holdsAt( appearance( id5 )=visible, 25680 ). % Frame number: 643 holdsAt( orientation( id5 )=75, 25720 ). holdsAt( appearance( id5 )=visible, 25720 ). % Frame number: 644 holdsAt( orientation( id5 )=75, 25760 ). holdsAt( appearance( id5 )=visible, 25760 ). % Frame number: 645 holdsAt( orientation( id5 )=75, 25800 ). holdsAt( appearance( id5 )=visible, 25800 ). % Frame number: 646 holdsAt( orientation( id5 )=75, 25840 ). holdsAt( appearance( id5 )=visible, 25840 ). % Frame number: 647 holdsAt( orientation( id5 )=75, 25880 ). holdsAt( appearance( id5 )=visible, 25880 ). % Frame number: 648 holdsAt( orientation( id5 )=75, 25920 ). holdsAt( appearance( id5 )=visible, 25920 ). % Frame number: 649 holdsAt( orientation( id5 )=75, 25960 ). holdsAt( appearance( id5 )=visible, 25960 ). % Frame number: 650 holdsAt( orientation( id5 )=75, 26000 ). holdsAt( appearance( id5 )=visible, 26000 ). % Frame number: 651 holdsAt( orientation( id5 )=75, 26040 ). holdsAt( appearance( id5 )=visible, 26040 ). % Frame number: 652 holdsAt( orientation( id5 )=75, 26080 ). holdsAt( appearance( id5 )=visible, 26080 ). % Frame number: 653 holdsAt( orientation( id5 )=75, 26120 ). holdsAt( appearance( id5 )=visible, 26120 ). % Frame number: 654 holdsAt( orientation( id5 )=75, 26160 ). holdsAt( appearance( id5 )=visible, 26160 ). % Frame number: 655 holdsAt( orientation( id5 )=75, 26200 ). holdsAt( appearance( id5 )=visible, 26200 ). % Frame number: 656 holdsAt( orientation( id5 )=75, 26240 ). holdsAt( appearance( id5 )=visible, 26240 ). % Frame number: 657 holdsAt( orientation( id5 )=75, 26280 ). holdsAt( appearance( id5 )=visible, 26280 ). % Frame number: 658 holdsAt( orientation( id5 )=75, 26320 ). holdsAt( appearance( id5 )=visible, 26320 ). % Frame number: 659 holdsAt( orientation( id5 )=75, 26360 ). holdsAt( appearance( id5 )=visible, 26360 ). % Frame number: 660 holdsAt( orientation( id5 )=75, 26400 ). holdsAt( appearance( id5 )=visible, 26400 ). % Frame number: 661 holdsAt( orientation( id5 )=75, 26440 ). holdsAt( appearance( id5 )=visible, 26440 ). % Frame number: 662 holdsAt( orientation( id5 )=75, 26480 ). holdsAt( appearance( id5 )=visible, 26480 ). % Frame number: 663 holdsAt( orientation( id5 )=75, 26520 ). holdsAt( appearance( id5 )=visible, 26520 ). % Frame number: 664 holdsAt( orientation( id5 )=75, 26560 ). holdsAt( appearance( id5 )=visible, 26560 ). % Frame number: 665 holdsAt( orientation( id5 )=75, 26600 ). holdsAt( appearance( id5 )=visible, 26600 ). % Frame number: 666 holdsAt( orientation( id5 )=75, 26640 ). holdsAt( appearance( id5 )=visible, 26640 ). % Frame number: 667 holdsAt( orientation( id5 )=75, 26680 ). holdsAt( appearance( id5 )=visible, 26680 ). % Frame number: 668 holdsAt( orientation( id5 )=45, 26720 ). holdsAt( appearance( id5 )=visible, 26720 ). % Frame number: 669 holdsAt( orientation( id5 )=45, 26760 ). holdsAt( appearance( id5 )=visible, 26760 ). % Frame number: 670 holdsAt( orientation( id5 )=45, 26800 ). holdsAt( appearance( id5 )=visible, 26800 ). % Frame number: 671 holdsAt( orientation( id5 )=45, 26840 ). holdsAt( appearance( id5 )=visible, 26840 ). % Frame number: 672 holdsAt( orientation( id5 )=45, 26880 ). holdsAt( appearance( id5 )=visible, 26880 ). % Frame number: 673 holdsAt( orientation( id5 )=45, 26920 ). holdsAt( appearance( id5 )=visible, 26920 ). % Frame number: 674 holdsAt( orientation( id5 )=45, 26960 ). holdsAt( appearance( id5 )=visible, 26960 ). % Frame number: 675 holdsAt( orientation( id5 )=45, 27000 ). holdsAt( appearance( id5 )=visible, 27000 ). % Frame number: 676 holdsAt( orientation( id5 )=45, 27040 ). holdsAt( appearance( id5 )=visible, 27040 ). % Frame number: 677 holdsAt( orientation( id5 )=45, 27080 ). holdsAt( appearance( id5 )=visible, 27080 ). % Frame number: 678 holdsAt( orientation( id5 )=45, 27120 ). holdsAt( appearance( id5 )=visible, 27120 ). % Frame number: 679 holdsAt( orientation( id5 )=45, 27160 ). holdsAt( appearance( id5 )=visible, 27160 ). % Frame number: 680 holdsAt( orientation( id5 )=45, 27200 ). holdsAt( appearance( id5 )=visible, 27200 ). % Frame number: 681 holdsAt( orientation( id5 )=45, 27240 ). holdsAt( appearance( id5 )=visible, 27240 ). % Frame number: 682 holdsAt( orientation( id5 )=45, 27280 ). holdsAt( appearance( id5 )=visible, 27280 ). % Frame number: 683 holdsAt( orientation( id5 )=45, 27320 ). holdsAt( appearance( id5 )=visible, 27320 ). % Frame number: 684 holdsAt( orientation( id5 )=45, 27360 ). holdsAt( appearance( id5 )=visible, 27360 ). % Frame number: 685 holdsAt( orientation( id5 )=45, 27400 ). holdsAt( appearance( id5 )=visible, 27400 ). % Frame number: 686 holdsAt( orientation( id5 )=45, 27440 ). holdsAt( appearance( id5 )=visible, 27440 ). % Frame number: 687 holdsAt( orientation( id5 )=45, 27480 ). holdsAt( appearance( id5 )=visible, 27480 ). % Frame number: 688 holdsAt( orientation( id5 )=45, 27520 ). holdsAt( appearance( id5 )=visible, 27520 ). % Frame number: 689 holdsAt( orientation( id5 )=45, 27560 ). holdsAt( appearance( id5 )=visible, 27560 ). % Frame number: 690 holdsAt( orientation( id5 )=45, 27600 ). holdsAt( appearance( id5 )=visible, 27600 ). % Frame number: 691 holdsAt( orientation( id5 )=45, 27640 ). holdsAt( appearance( id5 )=visible, 27640 ). % Frame number: 692 holdsAt( orientation( id5 )=45, 27680 ). holdsAt( appearance( id5 )=visible, 27680 ). % Frame number: 693 holdsAt( orientation( id5 )=45, 27720 ). holdsAt( appearance( id5 )=visible, 27720 ). % Frame number: 694 holdsAt( orientation( id5 )=45, 27760 ). holdsAt( appearance( id5 )=visible, 27760 ). % Frame number: 695 holdsAt( orientation( id5 )=45, 27800 ). holdsAt( appearance( id5 )=visible, 27800 ). % Frame number: 696 holdsAt( orientation( id5 )=45, 27840 ). holdsAt( appearance( id5 )=visible, 27840 ). % Frame number: 697 holdsAt( orientation( id5 )=45, 27880 ). holdsAt( appearance( id5 )=visible, 27880 ). % Frame number: 698 holdsAt( orientation( id5 )=45, 27920 ). holdsAt( appearance( id5 )=visible, 27920 ). % Frame number: 699 holdsAt( orientation( id5 )=45, 27960 ). holdsAt( appearance( id5 )=visible, 27960 ). % Frame number: 700 holdsAt( orientation( id5 )=45, 28000 ). holdsAt( appearance( id5 )=visible, 28000 ). % Frame number: 701 holdsAt( orientation( id5 )=45, 28040 ). holdsAt( appearance( id5 )=visible, 28040 ). % Frame number: 702 holdsAt( orientation( id5 )=45, 28080 ). holdsAt( appearance( id5 )=visible, 28080 ). % Frame number: 703 holdsAt( orientation( id5 )=45, 28120 ). holdsAt( appearance( id5 )=visible, 28120 ). % Frame number: 704 holdsAt( orientation( id5 )=45, 28160 ). holdsAt( appearance( id5 )=visible, 28160 ). % Frame number: 705 holdsAt( orientation( id5 )=45, 28200 ). holdsAt( appearance( id5 )=visible, 28200 ). % Frame number: 706 holdsAt( orientation( id5 )=45, 28240 ). holdsAt( appearance( id5 )=visible, 28240 ). % Frame number: 707 holdsAt( orientation( id5 )=45, 28280 ). holdsAt( appearance( id5 )=visible, 28280 ). % Frame number: 708 holdsAt( orientation( id5 )=45, 28320 ). holdsAt( appearance( id5 )=visible, 28320 ). % Frame number: 709 holdsAt( orientation( id5 )=45, 28360 ). holdsAt( appearance( id5 )=visible, 28360 ). % Frame number: 710 holdsAt( orientation( id5 )=45, 28400 ). holdsAt( appearance( id5 )=visible, 28400 ). % Frame number: 711 holdsAt( orientation( id5 )=45, 28440 ). holdsAt( appearance( id5 )=visible, 28440 ). % Frame number: 712 holdsAt( orientation( id5 )=45, 28480 ). holdsAt( appearance( id5 )=visible, 28480 ). % Frame number: 713 holdsAt( orientation( id5 )=45, 28520 ). holdsAt( appearance( id5 )=visible, 28520 ). % Frame number: 714 holdsAt( orientation( id5 )=45, 28560 ). holdsAt( appearance( id5 )=visible, 28560 ). % Frame number: 715 holdsAt( orientation( id5 )=45, 28600 ). holdsAt( appearance( id5 )=visible, 28600 ). % Frame number: 716 holdsAt( orientation( id5 )=45, 28640 ). holdsAt( appearance( id5 )=visible, 28640 ). % Frame number: 717 holdsAt( orientation( id5 )=45, 28680 ). holdsAt( appearance( id5 )=visible, 28680 ). % Frame number: 718 holdsAt( orientation( id5 )=45, 28720 ). holdsAt( appearance( id5 )=visible, 28720 ). % Frame number: 719 holdsAt( orientation( id5 )=45, 28760 ). holdsAt( appearance( id5 )=visible, 28760 ). % Frame number: 720 holdsAt( orientation( id5 )=45, 28800 ). holdsAt( appearance( id5 )=visible, 28800 ). % Frame number: 721 holdsAt( orientation( id5 )=45, 28840 ). holdsAt( appearance( id5 )=visible, 28840 ). % Frame number: 722 holdsAt( orientation( id5 )=45, 28880 ). holdsAt( appearance( id5 )=visible, 28880 ). % Frame number: 723 holdsAt( orientation( id5 )=45, 28920 ). holdsAt( appearance( id5 )=visible, 28920 ). % Frame number: 724 holdsAt( orientation( id5 )=45, 28960 ). holdsAt( appearance( id5 )=visible, 28960 ). % Frame number: 725 holdsAt( orientation( id5 )=45, 29000 ). holdsAt( appearance( id5 )=visible, 29000 ). % Frame number: 726 holdsAt( orientation( id5 )=45, 29040 ). holdsAt( appearance( id5 )=visible, 29040 ). % Frame number: 727 holdsAt( orientation( id5 )=45, 29080 ). holdsAt( appearance( id5 )=visible, 29080 ). % Frame number: 728 holdsAt( orientation( id5 )=45, 29120 ). holdsAt( appearance( id5 )=visible, 29120 ). % Frame number: 729 holdsAt( orientation( id5 )=45, 29160 ). holdsAt( appearance( id5 )=visible, 29160 ). % Frame number: 730 holdsAt( orientation( id5 )=45, 29200 ). holdsAt( appearance( id5 )=visible, 29200 ). % Frame number: 731 holdsAt( orientation( id5 )=45, 29240 ). holdsAt( appearance( id5 )=visible, 29240 ). % Frame number: 732 holdsAt( orientation( id5 )=45, 29280 ). holdsAt( appearance( id5 )=visible, 29280 ). % Frame number: 733 holdsAt( orientation( id5 )=45, 29320 ). holdsAt( appearance( id5 )=visible, 29320 ). % Frame number: 734 holdsAt( orientation( id5 )=45, 29360 ). holdsAt( appearance( id5 )=visible, 29360 ). % Frame number: 735 holdsAt( orientation( id5 )=45, 29400 ). holdsAt( appearance( id5 )=visible, 29400 ). % Frame number: 736 holdsAt( orientation( id5 )=45, 29440 ). holdsAt( appearance( id5 )=visible, 29440 ). % Frame number: 737 holdsAt( orientation( id5 )=45, 29480 ). holdsAt( appearance( id5 )=visible, 29480 ). % Frame number: 738 holdsAt( orientation( id5 )=45, 29520 ). holdsAt( appearance( id5 )=visible, 29520 ). % Frame number: 739 holdsAt( orientation( id5 )=45, 29560 ). holdsAt( appearance( id5 )=visible, 29560 ). % Frame number: 740 holdsAt( orientation( id5 )=45, 29600 ). holdsAt( appearance( id5 )=visible, 29600 ). % Frame number: 741 holdsAt( orientation( id5 )=45, 29640 ). holdsAt( appearance( id5 )=visible, 29640 ). % Frame number: 742 holdsAt( orientation( id5 )=45, 29680 ). holdsAt( appearance( id5 )=visible, 29680 ). % Frame number: 743 holdsAt( orientation( id5 )=45, 29720 ). holdsAt( appearance( id5 )=visible, 29720 ). % Frame number: 744 holdsAt( orientation( id5 )=45, 29760 ). holdsAt( appearance( id5 )=visible, 29760 ). % Frame number: 745 holdsAt( orientation( id5 )=45, 29800 ). holdsAt( appearance( id5 )=visible, 29800 ). % Frame number: 746 holdsAt( orientation( id5 )=45, 29840 ). holdsAt( appearance( id5 )=visible, 29840 ). % Frame number: 747 holdsAt( orientation( id5 )=45, 29880 ). holdsAt( appearance( id5 )=visible, 29880 ). % Frame number: 748 holdsAt( orientation( id5 )=45, 29920 ). holdsAt( appearance( id5 )=visible, 29920 ). % Frame number: 749 holdsAt( orientation( id5 )=45, 29960 ). holdsAt( appearance( id5 )=visible, 29960 ). % Frame number: 750 holdsAt( orientation( id5 )=45, 30000 ). holdsAt( appearance( id5 )=visible, 30000 ). % Frame number: 751 holdsAt( orientation( id5 )=45, 30040 ). holdsAt( appearance( id5 )=visible, 30040 ). % Frame number: 752 holdsAt( orientation( id5 )=45, 30080 ). holdsAt( appearance( id5 )=visible, 30080 ). % Frame number: 753 holdsAt( orientation( id5 )=45, 30120 ). holdsAt( appearance( id5 )=visible, 30120 ). % Frame number: 754 holdsAt( orientation( id5 )=45, 30160 ). holdsAt( appearance( id5 )=visible, 30160 ). % Frame number: 755 holdsAt( orientation( id5 )=45, 30200 ). holdsAt( appearance( id5 )=visible, 30200 ). % Frame number: 756 holdsAt( orientation( id5 )=45, 30240 ). holdsAt( appearance( id5 )=visible, 30240 ). % Frame number: 757 holdsAt( orientation( id5 )=45, 30280 ). holdsAt( appearance( id5 )=visible, 30280 ). % Frame number: 758 holdsAt( orientation( id5 )=45, 30320 ). holdsAt( appearance( id5 )=visible, 30320 ). % Frame number: 759 holdsAt( orientation( id5 )=45, 30360 ). holdsAt( appearance( id5 )=visible, 30360 ). % Frame number: 760 holdsAt( orientation( id5 )=45, 30400 ). holdsAt( appearance( id5 )=visible, 30400 ). % Frame number: 761 holdsAt( orientation( id5 )=45, 30440 ). holdsAt( appearance( id5 )=visible, 30440 ). % Frame number: 762 holdsAt( orientation( id5 )=45, 30480 ). holdsAt( appearance( id5 )=visible, 30480 ). % Frame number: 763 holdsAt( orientation( id5 )=45, 30520 ). holdsAt( appearance( id5 )=visible, 30520 ). % Frame number: 764 holdsAt( orientation( id5 )=45, 30560 ). holdsAt( appearance( id5 )=visible, 30560 ). % Frame number: 765 holdsAt( orientation( id5 )=45, 30600 ). holdsAt( appearance( id5 )=visible, 30600 ). % Frame number: 766 holdsAt( orientation( id5 )=45, 30640 ). holdsAt( appearance( id5 )=visible, 30640 ). % Frame number: 767 holdsAt( orientation( id5 )=45, 30680 ). holdsAt( appearance( id5 )=visible, 30680 ). % Frame number: 768 holdsAt( orientation( id5 )=45, 30720 ). holdsAt( appearance( id5 )=visible, 30720 ). % Frame number: 769 holdsAt( orientation( id5 )=45, 30760 ). holdsAt( appearance( id5 )=visible, 30760 ). % Frame number: 770 holdsAt( orientation( id5 )=45, 30800 ). holdsAt( appearance( id5 )=visible, 30800 ). % Frame number: 771 holdsAt( orientation( id5 )=45, 30840 ). holdsAt( appearance( id5 )=visible, 30840 ). % Frame number: 772 holdsAt( orientation( id5 )=45, 30880 ). holdsAt( appearance( id5 )=visible, 30880 ). % Frame number: 773 holdsAt( orientation( id5 )=45, 30920 ). holdsAt( appearance( id5 )=visible, 30920 ). % Frame number: 774 holdsAt( orientation( id5 )=45, 30960 ). holdsAt( appearance( id5 )=visible, 30960 ). % Frame number: 775 holdsAt( orientation( id5 )=45, 31000 ). holdsAt( appearance( id5 )=visible, 31000 ). % Frame number: 776 holdsAt( orientation( id5 )=45, 31040 ). holdsAt( appearance( id5 )=visible, 31040 ). % Frame number: 777 holdsAt( orientation( id5 )=45, 31080 ). holdsAt( appearance( id5 )=visible, 31080 ). % Frame number: 778 holdsAt( orientation( id5 )=45, 31120 ). holdsAt( appearance( id5 )=visible, 31120 ). % Frame number: 779 holdsAt( orientation( id5 )=45, 31160 ). holdsAt( appearance( id5 )=visible, 31160 ). % Frame number: 780 holdsAt( orientation( id5 )=45, 31200 ). holdsAt( appearance( id5 )=visible, 31200 ). % Frame number: 781 holdsAt( orientation( id5 )=45, 31240 ). holdsAt( appearance( id5 )=visible, 31240 ). % Frame number: 782 holdsAt( orientation( id5 )=45, 31280 ). holdsAt( appearance( id5 )=visible, 31280 ). % Frame number: 783 holdsAt( orientation( id5 )=45, 31320 ). holdsAt( appearance( id5 )=visible, 31320 ). % Frame number: 784 holdsAt( orientation( id5 )=45, 31360 ). holdsAt( appearance( id5 )=visible, 31360 ). % Frame number: 785 holdsAt( orientation( id5 )=45, 31400 ). holdsAt( appearance( id5 )=visible, 31400 ). % Frame number: 786 holdsAt( orientation( id5 )=45, 31440 ). holdsAt( appearance( id5 )=visible, 31440 ). % Frame number: 787 holdsAt( orientation( id5 )=45, 31480 ). holdsAt( appearance( id5 )=visible, 31480 ). % Frame number: 788 holdsAt( orientation( id5 )=45, 31520 ). holdsAt( appearance( id5 )=visible, 31520 ). % Frame number: 789 holdsAt( orientation( id5 )=45, 31560 ). holdsAt( appearance( id5 )=visible, 31560 ). % Frame number: 790 holdsAt( orientation( id5 )=45, 31600 ). holdsAt( appearance( id5 )=visible, 31600 ). % Frame number: 791 holdsAt( orientation( id5 )=45, 31640 ). holdsAt( appearance( id5 )=visible, 31640 ). % Frame number: 792 holdsAt( orientation( id5 )=45, 31680 ). holdsAt( appearance( id5 )=visible, 31680 ). % Frame number: 793 holdsAt( orientation( id5 )=45, 31720 ). holdsAt( appearance( id5 )=visible, 31720 ). % Frame number: 794 holdsAt( orientation( id5 )=45, 31760 ). holdsAt( appearance( id5 )=visible, 31760 ). % Frame number: 795 holdsAt( orientation( id5 )=45, 31800 ). holdsAt( appearance( id5 )=visible, 31800 ). % Frame number: 796 holdsAt( orientation( id5 )=45, 31840 ). holdsAt( appearance( id5 )=visible, 31840 ). % Frame number: 797 holdsAt( orientation( id5 )=45, 31880 ). holdsAt( appearance( id5 )=visible, 31880 ). % Frame number: 798 holdsAt( orientation( id5 )=45, 31920 ). holdsAt( appearance( id5 )=visible, 31920 ). % Frame number: 799 holdsAt( orientation( id5 )=45, 31960 ). holdsAt( appearance( id5 )=visible, 31960 ). % Frame number: 800 holdsAt( orientation( id5 )=45, 32000 ). holdsAt( appearance( id5 )=visible, 32000 ). % Frame number: 801 holdsAt( orientation( id5 )=45, 32040 ). holdsAt( appearance( id5 )=visible, 32040 ). % Frame number: 802 holdsAt( orientation( id5 )=45, 32080 ). holdsAt( appearance( id5 )=visible, 32080 ). % Frame number: 803 holdsAt( orientation( id5 )=45, 32120 ). holdsAt( appearance( id5 )=visible, 32120 ). % Frame number: 804 holdsAt( orientation( id5 )=45, 32160 ). holdsAt( appearance( id5 )=visible, 32160 ). % Frame number: 805 holdsAt( orientation( id5 )=45, 32200 ). holdsAt( appearance( id5 )=visible, 32200 ). % Frame number: 806 holdsAt( orientation( id5 )=45, 32240 ). holdsAt( appearance( id5 )=visible, 32240 ). % Frame number: 807 holdsAt( orientation( id5 )=45, 32280 ). holdsAt( appearance( id5 )=visible, 32280 ). % Frame number: 808 holdsAt( orientation( id5 )=45, 32320 ). holdsAt( appearance( id5 )=visible, 32320 ). % Frame number: 809 holdsAt( orientation( id5 )=45, 32360 ). holdsAt( appearance( id5 )=visible, 32360 ). % Frame number: 810 holdsAt( orientation( id5 )=45, 32400 ). holdsAt( appearance( id5 )=visible, 32400 ). % Frame number: 811 holdsAt( orientation( id5 )=45, 32440 ). holdsAt( appearance( id5 )=visible, 32440 ). % Frame number: 812 holdsAt( orientation( id5 )=45, 32480 ). holdsAt( appearance( id5 )=visible, 32480 ). % Frame number: 813 holdsAt( orientation( id5 )=45, 32520 ). holdsAt( appearance( id5 )=visible, 32520 ). % Frame number: 814 holdsAt( orientation( id5 )=45, 32560 ). holdsAt( appearance( id5 )=visible, 32560 ). % Frame number: 815 holdsAt( orientation( id5 )=60, 32600 ). holdsAt( appearance( id5 )=visible, 32600 ). % Frame number: 816 holdsAt( orientation( id5 )=60, 32640 ). holdsAt( appearance( id5 )=visible, 32640 ). % Frame number: 817 holdsAt( orientation( id5 )=60, 32680 ). holdsAt( appearance( id5 )=visible, 32680 ). % Frame number: 818 holdsAt( orientation( id5 )=60, 32720 ). holdsAt( appearance( id5 )=visible, 32720 ). % Frame number: 819 holdsAt( orientation( id5 )=60, 32760 ). holdsAt( appearance( id5 )=visible, 32760 ). % Frame number: 820 holdsAt( orientation( id5 )=60, 32800 ). holdsAt( appearance( id5 )=visible, 32800 ). % Frame number: 821 holdsAt( orientation( id5 )=60, 32840 ). holdsAt( appearance( id5 )=visible, 32840 ). % Frame number: 822 holdsAt( orientation( id5 )=60, 32880 ). holdsAt( appearance( id5 )=visible, 32880 ). % Frame number: 823 holdsAt( orientation( id5 )=60, 32920 ). holdsAt( appearance( id5 )=visible, 32920 ). % Frame number: 824 holdsAt( orientation( id5 )=60, 32960 ). holdsAt( appearance( id5 )=visible, 32960 ). % Frame number: 825 holdsAt( orientation( id5 )=60, 33000 ). holdsAt( appearance( id5 )=visible, 33000 ). % Frame number: 826 holdsAt( orientation( id5 )=60, 33040 ). holdsAt( appearance( id5 )=visible, 33040 ). % Frame number: 827 holdsAt( orientation( id5 )=60, 33080 ). holdsAt( appearance( id5 )=visible, 33080 ). % Frame number: 828 holdsAt( orientation( id5 )=60, 33120 ). holdsAt( appearance( id5 )=visible, 33120 ). % Frame number: 829 holdsAt( orientation( id5 )=60, 33160 ). holdsAt( appearance( id5 )=visible, 33160 ). % Frame number: 830 holdsAt( orientation( id5 )=60, 33200 ). holdsAt( appearance( id5 )=visible, 33200 ). % Frame number: 831 holdsAt( orientation( id5 )=60, 33240 ). holdsAt( appearance( id5 )=visible, 33240 ). % Frame number: 832 holdsAt( orientation( id5 )=60, 33280 ). holdsAt( appearance( id5 )=visible, 33280 ). % Frame number: 833 holdsAt( orientation( id5 )=60, 33320 ). holdsAt( appearance( id5 )=visible, 33320 ). % Frame number: 834 holdsAt( orientation( id5 )=60, 33360 ). holdsAt( appearance( id5 )=visible, 33360 ). % Frame number: 835 holdsAt( orientation( id5 )=60, 33400 ). holdsAt( appearance( id5 )=visible, 33400 ). % Frame number: 836 holdsAt( orientation( id5 )=60, 33440 ). holdsAt( appearance( id5 )=visible, 33440 ). % Frame number: 837 holdsAt( orientation( id5 )=60, 33480 ). holdsAt( appearance( id5 )=visible, 33480 ). % Frame number: 838 holdsAt( orientation( id5 )=60, 33520 ). holdsAt( appearance( id5 )=visible, 33520 ). % Frame number: 839 holdsAt( orientation( id5 )=60, 33560 ). holdsAt( appearance( id5 )=visible, 33560 ). % Frame number: 840 holdsAt( orientation( id5 )=60, 33600 ). holdsAt( appearance( id5 )=visible, 33600 ). % Frame number: 841 holdsAt( orientation( id5 )=60, 33640 ). holdsAt( appearance( id5 )=visible, 33640 ). % Frame number: 842 holdsAt( orientation( id5 )=60, 33680 ). holdsAt( appearance( id5 )=visible, 33680 ). % Frame number: 843 holdsAt( orientation( id5 )=60, 33720 ). holdsAt( appearance( id5 )=visible, 33720 ). % Frame number: 844 holdsAt( orientation( id5 )=120, 33760 ). holdsAt( appearance( id5 )=visible, 33760 ). % Frame number: 845 holdsAt( orientation( id5 )=120, 33800 ). holdsAt( appearance( id5 )=visible, 33800 ). % Frame number: 846 holdsAt( orientation( id5 )=120, 33840 ). holdsAt( appearance( id5 )=visible, 33840 ). % Frame number: 847 holdsAt( orientation( id5 )=120, 33880 ). holdsAt( appearance( id5 )=visible, 33880 ). % Frame number: 848 holdsAt( orientation( id5 )=140, 33920 ). holdsAt( appearance( id5 )=visible, 33920 ). % Frame number: 849 holdsAt( orientation( id5 )=140, 33960 ). holdsAt( appearance( id5 )=visible, 33960 ). % Frame number: 850 holdsAt( orientation( id5 )=140, 34000 ). holdsAt( appearance( id5 )=visible, 34000 ). % Frame number: 851 holdsAt( orientation( id5 )=140, 34040 ). holdsAt( appearance( id5 )=visible, 34040 ). % Frame number: 852 holdsAt( orientation( id5 )=140, 34080 ). holdsAt( appearance( id5 )=visible, 34080 ). % Frame number: 853 holdsAt( orientation( id5 )=140, 34120 ). holdsAt( appearance( id5 )=visible, 34120 ). % Frame number: 854 holdsAt( orientation( id5 )=140, 34160 ). holdsAt( appearance( id5 )=visible, 34160 ). % Frame number: 855 holdsAt( orientation( id5 )=140, 34200 ). holdsAt( appearance( id5 )=visible, 34200 ). % Frame number: 856 holdsAt( orientation( id5 )=140, 34240 ). holdsAt( appearance( id5 )=visible, 34240 ). % Frame number: 857 holdsAt( orientation( id5 )=140, 34280 ). holdsAt( appearance( id5 )=visible, 34280 ). % Frame number: 858 holdsAt( orientation( id5 )=140, 34320 ). holdsAt( appearance( id5 )=visible, 34320 ). % Frame number: 859 holdsAt( orientation( id5 )=140, 34360 ). holdsAt( appearance( id5 )=visible, 34360 ). % Frame number: 860 holdsAt( orientation( id5 )=140, 34400 ). holdsAt( appearance( id5 )=visible, 34400 ). % Frame number: 861 holdsAt( orientation( id5 )=140, 34440 ). holdsAt( appearance( id5 )=visible, 34440 ). % Frame number: 862 holdsAt( orientation( id5 )=140, 34480 ). holdsAt( appearance( id5 )=visible, 34480 ). % Frame number: 863 holdsAt( orientation( id5 )=140, 34520 ). holdsAt( appearance( id5 )=visible, 34520 ). % Frame number: 864 holdsAt( orientation( id5 )=140, 34560 ). holdsAt( appearance( id5 )=visible, 34560 ). % Frame number: 865 holdsAt( orientation( id5 )=140, 34600 ). holdsAt( appearance( id5 )=visible, 34600 ). % Frame number: 866 holdsAt( orientation( id5 )=140, 34640 ). holdsAt( appearance( id5 )=visible, 34640 ). % Frame number: 867 holdsAt( orientation( id5 )=140, 34680 ). holdsAt( appearance( id5 )=visible, 34680 ). % Frame number: 868 holdsAt( orientation( id5 )=140, 34720 ). holdsAt( appearance( id5 )=visible, 34720 ). % Frame number: 869 holdsAt( orientation( id5 )=140, 34760 ). holdsAt( appearance( id5 )=visible, 34760 ). % Frame number: 870 holdsAt( orientation( id5 )=140, 34800 ). holdsAt( appearance( id5 )=visible, 34800 ). % Frame number: 871 holdsAt( orientation( id5 )=140, 34840 ). holdsAt( appearance( id5 )=visible, 34840 ). % Frame number: 872 holdsAt( orientation( id5 )=140, 34880 ). holdsAt( appearance( id5 )=visible, 34880 ). % Frame number: 873 holdsAt( orientation( id5 )=140, 34920 ). holdsAt( appearance( id5 )=visible, 34920 ). % Frame number: 874 holdsAt( orientation( id5 )=140, 34960 ). holdsAt( appearance( id5 )=visible, 34960 ). % Frame number: 875 holdsAt( orientation( id5 )=140, 35000 ). holdsAt( appearance( id5 )=visible, 35000 ). % Frame number: 876 holdsAt( orientation( id5 )=140, 35040 ). holdsAt( appearance( id5 )=visible, 35040 ). % Frame number: 877 holdsAt( orientation( id5 )=140, 35080 ). holdsAt( appearance( id5 )=visible, 35080 ). % Frame number: 878 holdsAt( orientation( id5 )=140, 35120 ). holdsAt( appearance( id5 )=visible, 35120 ). % Frame number: 879 holdsAt( orientation( id5 )=140, 35160 ). holdsAt( appearance( id5 )=visible, 35160 ). % Frame number: 880 holdsAt( orientation( id5 )=140, 35200 ). holdsAt( appearance( id5 )=visible, 35200 ). % Frame number: 881 holdsAt( orientation( id5 )=140, 35240 ). holdsAt( appearance( id5 )=visible, 35240 ). % Frame number: 882 holdsAt( orientation( id5 )=140, 35280 ). holdsAt( appearance( id5 )=visible, 35280 ). % Frame number: 883 holdsAt( orientation( id5 )=140, 35320 ). holdsAt( appearance( id5 )=visible, 35320 ). % Frame number: 884 holdsAt( orientation( id5 )=140, 35360 ). holdsAt( appearance( id5 )=visible, 35360 ). % Frame number: 885 holdsAt( orientation( id5 )=140, 35400 ). holdsAt( appearance( id5 )=visible, 35400 ). % Frame number: 886 holdsAt( orientation( id5 )=140, 35440 ). holdsAt( appearance( id5 )=visible, 35440 ). % Frame number: 887 holdsAt( orientation( id5 )=140, 35480 ). holdsAt( appearance( id5 )=visible, 35480 ). % Frame number: 888 holdsAt( orientation( id5 )=140, 35520 ). holdsAt( appearance( id5 )=visible, 35520 ). % Frame number: 889 holdsAt( orientation( id5 )=140, 35560 ). holdsAt( appearance( id5 )=visible, 35560 ). % Frame number: 890 holdsAt( orientation( id5 )=140, 35600 ). holdsAt( appearance( id5 )=visible, 35600 ). % Frame number: 891 holdsAt( orientation( id5 )=140, 35640 ). holdsAt( appearance( id5 )=visible, 35640 ). % Frame number: 892 holdsAt( orientation( id5 )=140, 35680 ). holdsAt( appearance( id5 )=visible, 35680 ). % Frame number: 893 holdsAt( orientation( id5 )=140, 35720 ). holdsAt( appearance( id5 )=visible, 35720 ). % Frame number: 894 holdsAt( orientation( id5 )=140, 35760 ). holdsAt( appearance( id5 )=visible, 35760 ). % Frame number: 895 holdsAt( orientation( id5 )=140, 35800 ). holdsAt( appearance( id5 )=visible, 35800 ). % Frame number: 896 holdsAt( orientation( id5 )=140, 35840 ). holdsAt( appearance( id5 )=visible, 35840 ). % Frame number: 897 holdsAt( orientation( id5 )=140, 35880 ). holdsAt( appearance( id5 )=visible, 35880 ). % Frame number: 898 holdsAt( orientation( id5 )=140, 35920 ). holdsAt( appearance( id5 )=visible, 35920 ). % Frame number: 899 holdsAt( orientation( id5 )=140, 35960 ). holdsAt( appearance( id5 )=visible, 35960 ). % Frame number: 900 holdsAt( orientation( id5 )=140, 36000 ). holdsAt( appearance( id5 )=visible, 36000 ). % Frame number: 901 holdsAt( orientation( id5 )=140, 36040 ). holdsAt( appearance( id5 )=visible, 36040 ). % Frame number: 902 holdsAt( orientation( id5 )=140, 36080 ). holdsAt( appearance( id5 )=visible, 36080 ). % Frame number: 903 holdsAt( orientation( id5 )=140, 36120 ). holdsAt( appearance( id5 )=visible, 36120 ). % Frame number: 904 holdsAt( orientation( id5 )=140, 36160 ). holdsAt( appearance( id5 )=visible, 36160 ). % Frame number: 905 holdsAt( orientation( id5 )=140, 36200 ). holdsAt( appearance( id5 )=visible, 36200 ). % Frame number: 906 holdsAt( orientation( id5 )=140, 36240 ). holdsAt( appearance( id5 )=visible, 36240 ). % Frame number: 907 holdsAt( orientation( id5 )=140, 36280 ). holdsAt( appearance( id5 )=visible, 36280 ). % Frame number: 908 holdsAt( orientation( id5 )=140, 36320 ). holdsAt( appearance( id5 )=visible, 36320 ). % Frame number: 909 holdsAt( orientation( id5 )=167, 36360 ). holdsAt( appearance( id5 )=visible, 36360 ). % Frame number: 910 holdsAt( orientation( id5 )=167, 36400 ). holdsAt( appearance( id5 )=disappear, 36400 ).
JasonFil/Prob-EC
dataset/smooth-noise/11-Rest_SlumpOnFloor/rsfgtAppearenceIndv.pl
Perl
bsd-3-clause
124,724
% Tests for ground/1 % % This isn't defined in ISO but many Prologs have it. :- use_module(library(tap)). atom :- ground(here_is_an_atom). integer :- ground(19). float :- ground(7.321). 'compound term' :- ground(hi(one, two, three)). nil :- ground([]). 'complete list' :- ground([a, b, c]). 'bound variable' :- X = something, ground(X). 'unbound variable'(fail) :- ground(_). 'improper list'(fail) :- ground([a,b|_]). 'list pattern'(fail) :- ground([_|_]). 'compound term with variables'(fail) :- ground(a_term(one, X, three, X)).
mndrix/golog
t/ground.pl
Perl
mit
590
package DDG::Goodie::IsAwesome::jee1mr; #ABSTRACT: jee1mr's first Goodie use DDG::Goodie; use strict; zci answer_type => "is_awesome_jee1mr"; zci is_cached => 1; triggers start => "duckduckhack jee1mr"; handle remainder => sub { return if $_; return "jee1mr is awesome and has successfully completed the DuckDuckHack Goodie tutorial!"; }; 1;
aleksandar-todorovic/zeroclickinfo-goodies
lib/DDG/Goodie/IsAwesome/jee1mr.pm
Perl
apache-2.0
357
package DDG::Goodie::DateMath; # ABSTRACT: add/subtract days/weeks/months/years to/from a date use strict; use DDG::Goodie; with 'DDG::GoodieRole::Dates'; use DateTime::Duration; use Lingua::EN::Numericalize; triggers any => qw( plus minus + - date day week month year days weeks months years); zci is_cached => 1; zci answer_type => 'date_math'; my $datestring_regex = datestring_regex(); handle query_lc => sub { my $query = $_; my $relative_regex = qr!(?<number>\d+|[a-z\s-]+)\s+(?<unit>(?:day|week|month|year)s?)!; return unless $query =~ qr!^(?:date\s+)?( (?<date>$datestring_regex)(?:\s+(?<action>plus|\+|\-|minus)\s+$relative_regex)?| $relative_regex\s+(?<action>from)\s+(?<date>$datestring_regex)? )$!x; if (!exists $+{'number'}) { my $out_date = date_output_string(parse_datestring_to_date($+{'date'})); return $out_date, structured_answer => { input => [$+{'date'}], operation => 'Date math', result => $out_date }; } my $input_date = parse_datestring_to_date($+{date}); my $input_number = str2nbr($+{number}); my $unit = $+{unit}; # check/tweak other (non-date) input my %action_map = ( plus => '+', '+' => '+', minus => '-', '-' => '-', from => '+' ); my $action = $action_map{$+{action}} || return; my $number = $action eq '-' ? 0 - $input_number : $input_number; $unit =~ s/s$//g; my ($years, $months, $days, $weeks) = (0, 0, 0, 0); $years = $number if $unit eq "year"; $months = $number if $unit eq "month"; $days = $number if $unit eq "day"; $days = 7 * $number if $unit eq "week"; my $dur = DateTime::Duration->new( years => $years, months => $months, days => $days ); $unit .= 's' if $input_number > 1; # plural? my $out_date = date_output_string($input_date->clone->add_duration($dur)); my $in_date = date_output_string($input_date); my $out_action = "$action $input_number $unit"; return "$in_date $out_action is $out_date", structured_answer => { input => [$in_date . ' ' . $out_action], operation => 'Date math', result => $out_date }; }; 1;
viluon/zeroclickinfo-goodies
lib/DDG/Goodie/DateMath.pm
Perl
apache-2.0
2,343
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by mktables from the Unicode # database, Version 6.1.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. return <<'END'; F0000 FFFFF END
Dokaponteam/ITF_Project
xampp/perl/lib/unicore/lib/Blk/SupPUAA.pl
Perl
mit
423
=head1 NAME perlhack - How to hack at the Perl internals =head1 DESCRIPTION This document attempts to explain how Perl development takes place, and ends with some suggestions for people wanting to become bona fide porters. The perl5-porters mailing list is where the Perl standard distribution is maintained and developed. The list can get anywhere from 10 to 150 messages a day, depending on the heatedness of the debate. Most days there are two or three patches, extensions, features, or bugs being discussed at a time. A searchable archive of the list is at either: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/ or http://archive.develooper.com/perl5-porters@perl.org/ List subscribers (the porters themselves) come in several flavours. Some are quiet curious lurkers, who rarely pitch in and instead watch the ongoing development to ensure they're forewarned of new changes or features in Perl. Some are representatives of vendors, who are there to make sure that Perl continues to compile and work on their platforms. Some patch any reported bug that they know how to fix, some are actively patching their pet area (threads, Win32, the regexp engine), while others seem to do nothing but complain. In other words, it's your usual mix of technical people. Over this group of porters presides Larry Wall. He has the final word in what does and does not change in the Perl language. Various releases of Perl are shepherded by a "pumpking", a porter responsible for gathering patches, deciding on a patch-by-patch, feature-by-feature basis what will and will not go into the release. For instance, Gurusamy Sarathy was the pumpking for the 5.6 release of Perl, and Jarkko Hietaniemi was the pumpking for the 5.8 release, and Rafael Garcia-Suarez holds the pumpking crown for the 5.10 release. In addition, various people are pumpkings for different things. For instance, Andy Dougherty and Jarkko Hietaniemi did a grand job as the I<Configure> pumpkin up till the 5.8 release. For the 5.10 release H.Merijn Brand took over. Larry sees Perl development along the lines of the US government: there's the Legislature (the porters), the Executive branch (the pumpkings), and the Supreme Court (Larry). The legislature can discuss and submit patches to the executive branch all they like, but the executive branch is free to veto them. Rarely, the Supreme Court will side with the executive branch over the legislature, or the legislature over the executive branch. Mostly, however, the legislature and the executive branch are supposed to get along and work out their differences without impeachment or court cases. You might sometimes see reference to Rule 1 and Rule 2. Larry's power as Supreme Court is expressed in The Rules: =over 4 =item 1 Larry is always by definition right about how Perl should behave. This means he has final veto power on the core functionality. =item 2 Larry is allowed to change his mind about any matter at a later date, regardless of whether he previously invoked Rule 1. =back Got that? Larry is always right, even when he was wrong. It's rare to see either Rule exercised, but they are often alluded to. New features and extensions to the language are contentious, because the criteria used by the pumpkings, Larry, and other porters to decide which features should be implemented and incorporated are not codified in a few small design goals as with some other languages. Instead, the heuristics are flexible and often difficult to fathom. Here is one person's list, roughly in decreasing order of importance, of heuristics that new features have to be weighed against: =over 4 =item Does concept match the general goals of Perl? These haven't been written anywhere in stone, but one approximation is: 1. Keep it fast, simple, and useful. 2. Keep features/concepts as orthogonal as possible. 3. No arbitrary limits (platforms, data sizes, cultures). 4. Keep it open and exciting to use/patch/advocate Perl everywhere. 5. Either assimilate new technologies, or build bridges to them. =item Where is the implementation? All the talk in the world is useless without an implementation. In almost every case, the person or people who argue for a new feature will be expected to be the ones who implement it. Porters capable of coding new features have their own agendas, and are not available to implement your (possibly good) idea. =item Backwards compatibility It's a cardinal sin to break existing Perl programs. New warnings are contentious--some say that a program that emits warnings is not broken, while others say it is. Adding keywords has the potential to break programs, changing the meaning of existing token sequences or functions might break programs. =item Could it be a module instead? Perl 5 has extension mechanisms, modules and XS, specifically to avoid the need to keep changing the Perl interpreter. You can write modules that export functions, you can give those functions prototypes so they can be called like built-in functions, you can even write XS code to mess with the runtime data structures of the Perl interpreter if you want to implement really complicated things. If it can be done in a module instead of in the core, it's highly unlikely to be added. =item Is the feature generic enough? Is this something that only the submitter wants added to the language, or would it be broadly useful? Sometimes, instead of adding a feature with a tight focus, the porters might decide to wait until someone implements the more generalized feature. For instance, instead of implementing a "delayed evaluation" feature, the porters are waiting for a macro system that would permit delayed evaluation and much more. =item Does it potentially introduce new bugs? Radical rewrites of large chunks of the Perl interpreter have the potential to introduce new bugs. The smaller and more localized the change, the better. =item Does it preclude other desirable features? A patch is likely to be rejected if it closes off future avenues of development. For instance, a patch that placed a true and final interpretation on prototypes is likely to be rejected because there are still options for the future of prototypes that haven't been addressed. =item Is the implementation robust? Good patches (tight code, complete, correct) stand more chance of going in. Sloppy or incorrect patches might be placed on the back burner until the pumpking has time to fix, or might be discarded altogether without further notice. =item Is the implementation generic enough to be portable? The worst patches make use of a system-specific features. It's highly unlikely that non-portable additions to the Perl language will be accepted. =item Is the implementation tested? Patches which change behaviour (fixing bugs or introducing new features) must include regression tests to verify that everything works as expected. Without tests provided by the original author, how can anyone else changing perl in the future be sure that they haven't unwittingly broken the behaviour the patch implements? And without tests, how can the patch's author be confident that his/her hard work put into the patch won't be accidentally thrown away by someone in the future? =item Is there enough documentation? Patches without documentation are probably ill-thought out or incomplete. Nothing can be added without documentation, so submitting a patch for the appropriate manpages as well as the source code is always a good idea. =item Is there another way to do it? Larry said "Although the Perl Slogan is I<There's More Than One Way to Do It>, I hesitate to make 10 ways to do something". This is a tricky heuristic to navigate, though--one man's essential addition is another man's pointless cruft. =item Does it create too much work? Work for the pumpking, work for Perl programmers, work for module authors, ... Perl is supposed to be easy. =item Patches speak louder than words Working code is always preferred to pie-in-the-sky ideas. A patch to add a feature stands a much higher chance of making it to the language than does a random feature request, no matter how fervently argued the request might be. This ties into "Will it be useful?", as the fact that someone took the time to make the patch demonstrates a strong desire for the feature. =back If you're on the list, you might hear the word "core" bandied around. It refers to the standard distribution. "Hacking on the core" means you're changing the C source code to the Perl interpreter. "A core module" is one that ships with Perl. =head2 Keeping in sync The source code to the Perl interpreter, in its different versions, is kept in a repository managed by the git revision control system. The pumpkings and a few others have write access to the repository to check in changes. How to clone and use the git perl repository is described in L<perlrepository>. You can also choose to use rsync to get a copy of the current source tree for the bleadperl branch and all maintenance branches : $ rsync -avz rsync://perl5.git.perl.org/APC/perl-current . $ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.10.x . $ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.8.x . $ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.6.x . $ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.005xx . (Add the C<--delete> option to remove leftover files) You may also want to subscribe to the perl5-changes mailing list to receive a copy of each patch that gets submitted to the maintenance and development "branches" of the perl repository. See http://lists.perl.org/ for subscription information. If you are a member of the perl5-porters mailing list, it is a good thing to keep in touch with the most recent changes. If not only to verify if what you would have posted as a bug report isn't already solved in the most recent available perl development branch, also known as perl-current, bleading edge perl, bleedperl or bleadperl. Needless to say, the source code in perl-current is usually in a perpetual state of evolution. You should expect it to be very buggy. Do B<not> use it for any purpose other than testing and development. =head2 Perlbug administration There is a single remote administrative interface for modifying bug status, category, open issues etc. using the B<RT> bugtracker system, maintained by Robert Spier. Become an administrator, and close any bugs you can get your sticky mitts on: http://bugs.perl.org/ To email the bug system administrators: "perlbug-admin" <perlbug-admin@perl.org> =head2 Submitting patches Always submit patches to I<perl5-porters@perl.org>. If you're patching a core module and there's an author listed, send the author a copy (see L<Patching a core module>). This lets other porters review your patch, which catches a surprising number of errors in patches. Please patch against the latest B<development> version. (e.g., even if you're fixing a bug in the 5.8 track, patch against the C<blead> branch in the git repository.) If changes are accepted, they are applied to the development branch. Then the maintenance pumpking decides which of those patches is to be backported to the maint branch. Only patches that survive the heat of the development branch get applied to maintenance versions. Your patch should update the documentation and test suite. See L<Writing a test>. If you have added or removed files in the distribution, edit the MANIFEST file accordingly, sort the MANIFEST file using C<make manisort>, and include those changes as part of your patch. Patching documentation also follows the same order: if accepted, a patch is first applied to B<development>, and if relevant then it's backported to B<maintenance>. (With an exception for some patches that document behaviour that only appears in the maintenance branch, but which has changed in the development version.) To report a bug in Perl, use the program I<perlbug> which comes with Perl (if you can't get Perl to work, send mail to the address I<perlbug@perl.org> or I<perlbug@perl.com>). Reporting bugs through I<perlbug> feeds into the automated bug-tracking system, access to which is provided through the web at http://rt.perl.org/rt3/ . It often pays to check the archives of the perl5-porters mailing list to see whether the bug you're reporting has been reported before, and if so whether it was considered a bug. See above for the location of the searchable archives. The CPAN testers ( http://testers.cpan.org/ ) are a group of volunteers who test CPAN modules on a variety of platforms. Perl Smokers ( http://www.nntp.perl.org/group/perl.daily-build and http://www.nntp.perl.org/group/perl.daily-build.reports/ ) automatically test Perl source releases on platforms with various configurations. Both efforts welcome volunteers. In order to get involved in smoke testing of the perl itself visit L<http://search.cpan.org/dist/Test-Smoke>. In order to start smoke testing CPAN modules visit L<http://search.cpan.org/dist/CPAN-YACSmoke/> or L<http://search.cpan.org/dist/POE-Component-CPAN-YACSmoke/> or L<http://search.cpan.org/dist/CPAN-Reporter/>. It's a good idea to read and lurk for a while before chipping in. That way you'll get to see the dynamic of the conversations, learn the personalities of the players, and hopefully be better prepared to make a useful contribution when do you speak up. If after all this you still think you want to join the perl5-porters mailing list, send mail to I<perl5-porters-subscribe@perl.org>. To unsubscribe, send mail to I<perl5-porters-unsubscribe@perl.org>. To hack on the Perl guts, you'll need to read the following things: =over 3 =item L<perlguts> This is of paramount importance, since it's the documentation of what goes where in the Perl source. Read it over a couple of times and it might start to make sense - don't worry if it doesn't yet, because the best way to study it is to read it in conjunction with poking at Perl source, and we'll do that later on. Gisle Aas's illustrated perlguts (also known as I<illguts>) is wonderful, although a little out of date with regard to some size details; the various SV structures have since been reworked for smaller memory footprint. The fundamentals are right however, and the pictures are very helpful. L<http://www.perl.org/tpc/1998/Perl_Language_and_Modules/Perl%20Illustrated/> =item L<perlxstut> and L<perlxs> A working knowledge of XSUB programming is incredibly useful for core hacking; XSUBs use techniques drawn from the PP code, the portion of the guts that actually executes a Perl program. It's a lot gentler to learn those techniques from simple examples and explanation than from the core itself. =item L<perlapi> The documentation for the Perl API explains what some of the internal functions do, as well as the many macros used in the source. =item F<Porting/pumpkin.pod> This is a collection of words of wisdom for a Perl porter; some of it is only useful to the pumpkin holder, but most of it applies to anyone wanting to go about Perl development. =item The perl5-porters FAQ This should be available from http://dev.perl.org/perl5/docs/p5p-faq.html . It contains hints on reading perl5-porters, information on how perl5-porters works and how Perl development in general works. =back =head2 Finding Your Way Around Perl maintenance can be split into a number of areas, and certain people (pumpkins) will have responsibility for each area. These areas sometimes correspond to files or directories in the source kit. Among the areas are: =over 3 =item Core modules Modules shipped as part of the Perl core live in the F<lib/> and F<ext/> subdirectories: F<lib/> is for the pure-Perl modules, and F<ext/> contains the core XS modules. =item Tests There are tests for nearly all the modules, built-ins and major bits of functionality. Test files all have a .t suffix. Module tests live in the F<lib/> and F<ext/> directories next to the module being tested. Others live in F<t/>. See L<Writing a test> =item Documentation Documentation maintenance includes looking after everything in the F<pod/> directory, (as well as contributing new documentation) and the documentation to the modules in core. =item Configure The configure process is the way we make Perl portable across the myriad of operating systems it supports. Responsibility for the configure, build and installation process, as well as the overall portability of the core code rests with the configure pumpkin - others help out with individual operating systems. The files involved are the operating system directories, (F<win32/>, F<os2/>, F<vms/> and so on) the shell scripts which generate F<config.h> and F<Makefile>, as well as the metaconfig files which generate F<Configure>. (metaconfig isn't included in the core distribution.) =item Interpreter And of course, there's the core of the Perl interpreter itself. Let's have a look at that in a little more detail. =back Before we leave looking at the layout, though, don't forget that F<MANIFEST> contains not only the file names in the Perl distribution, but short descriptions of what's in them, too. For an overview of the important files, try this: perl -lne 'print if /^[^\/]+\.[ch]\s+/' MANIFEST =head2 Elements of the interpreter The work of the interpreter has two main stages: compiling the code into the internal representation, or bytecode, and then executing it. L<perlguts/Compiled code> explains exactly how the compilation stage happens. Here is a short breakdown of perl's operation: =over 3 =item Startup The action begins in F<perlmain.c>. (or F<miniperlmain.c> for miniperl) This is very high-level code, enough to fit on a single screen, and it resembles the code found in L<perlembed>; most of the real action takes place in F<perl.c> F<perlmain.c> is generated by L<writemain> from F<miniperlmain.c> at make time, so you should make perl to follow this along. First, F<perlmain.c> allocates some memory and constructs a Perl interpreter, along these lines: 1 PERL_SYS_INIT3(&argc,&argv,&env); 2 3 if (!PL_do_undump) { 4 my_perl = perl_alloc(); 5 if (!my_perl) 6 exit(1); 7 perl_construct(my_perl); 8 PL_perl_destruct_level = 0; 9 } Line 1 is a macro, and its definition is dependent on your operating system. Line 3 references C<PL_do_undump>, a global variable - all global variables in Perl start with C<PL_>. This tells you whether the current running program was created with the C<-u> flag to perl and then F<undump>, which means it's going to be false in any sane context. Line 4 calls a function in F<perl.c> to allocate memory for a Perl interpreter. It's quite a simple function, and the guts of it looks like this: my_perl = (PerlInterpreter*)PerlMem_malloc(sizeof(PerlInterpreter)); Here you see an example of Perl's system abstraction, which we'll see later: C<PerlMem_malloc> is either your system's C<malloc>, or Perl's own C<malloc> as defined in F<malloc.c> if you selected that option at configure time. Next, in line 7, we construct the interpreter using perl_construct, also in F<perl.c>; this sets up all the special variables that Perl needs, the stacks, and so on. Now we pass Perl the command line options, and tell it to go: exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL); if (!exitstatus) perl_run(my_perl); exitstatus = perl_destruct(my_perl); perl_free(my_perl); C<perl_parse> is actually a wrapper around C<S_parse_body>, as defined in F<perl.c>, which processes the command line options, sets up any statically linked XS modules, opens the program and calls C<yyparse> to parse it. =item Parsing The aim of this stage is to take the Perl source, and turn it into an op tree. We'll see what one of those looks like later. Strictly speaking, there's three things going on here. C<yyparse>, the parser, lives in F<perly.c>, although you're better off reading the original YACC input in F<perly.y>. (Yes, Virginia, there B<is> a YACC grammar for Perl!) The job of the parser is to take your code and "understand" it, splitting it into sentences, deciding which operands go with which operators and so on. The parser is nobly assisted by the lexer, which chunks up your input into tokens, and decides what type of thing each token is: a variable name, an operator, a bareword, a subroutine, a core function, and so on. The main point of entry to the lexer is C<yylex>, and that and its associated routines can be found in F<toke.c>. Perl isn't much like other computer languages; it's highly context sensitive at times, it can be tricky to work out what sort of token something is, or where a token ends. As such, there's a lot of interplay between the tokeniser and the parser, which can get pretty frightening if you're not used to it. As the parser understands a Perl program, it builds up a tree of operations for the interpreter to perform during execution. The routines which construct and link together the various operations are to be found in F<op.c>, and will be examined later. =item Optimization Now the parsing stage is complete, and the finished tree represents the operations that the Perl interpreter needs to perform to execute our program. Next, Perl does a dry run over the tree looking for optimisations: constant expressions such as C<3 + 4> will be computed now, and the optimizer will also see if any multiple operations can be replaced with a single one. For instance, to fetch the variable C<$foo>, instead of grabbing the glob C<*foo> and looking at the scalar component, the optimizer fiddles the op tree to use a function which directly looks up the scalar in question. The main optimizer is C<peep> in F<op.c>, and many ops have their own optimizing functions. =item Running Now we're finally ready to go: we have compiled Perl byte code, and all that's left to do is run it. The actual execution is done by the C<runops_standard> function in F<run.c>; more specifically, it's done by these three innocent looking lines: while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))) { PERL_ASYNC_CHECK(); } You may be more comfortable with the Perl version of that: PERL_ASYNC_CHECK() while $Perl::op = &{$Perl::op->{function}}; Well, maybe not. Anyway, each op contains a function pointer, which stipulates the function which will actually carry out the operation. This function will return the next op in the sequence - this allows for things like C<if> which choose the next op dynamically at run time. The C<PERL_ASYNC_CHECK> makes sure that things like signals interrupt execution if required. The actual functions called are known as PP code, and they're spread between four files: F<pp_hot.c> contains the "hot" code, which is most often used and highly optimized, F<pp_sys.c> contains all the system-specific functions, F<pp_ctl.c> contains the functions which implement control structures (C<if>, C<while> and the like) and F<pp.c> contains everything else. These are, if you like, the C code for Perl's built-in functions and operators. Note that each C<pp_> function is expected to return a pointer to the next op. Calls to perl subs (and eval blocks) are handled within the same runops loop, and do not consume extra space on the C stack. For example, C<pp_entersub> and C<pp_entertry> just push a C<CxSUB> or C<CxEVAL> block struct onto the context stack which contain the address of the op following the sub call or eval. They then return the first op of that sub or eval block, and so execution continues of that sub or block. Later, a C<pp_leavesub> or C<pp_leavetry> op pops the C<CxSUB> or C<CxEVAL>, retrieves the return op from it, and returns it. =item Exception handing Perl's exception handing (i.e. C<die> etc.) is built on top of the low-level C<setjmp()>/C<longjmp()> C-library functions. These basically provide a way to capture the current PC and SP registers and later restore them; i.e. a C<longjmp()> continues at the point in code where a previous C<setjmp()> was done, with anything further up on the C stack being lost. This is why code should always save values using C<SAVE_FOO> rather than in auto variables. The perl core wraps C<setjmp()> etc in the macros C<JMPENV_PUSH> and C<JMPENV_JUMP>. The basic rule of perl exceptions is that C<exit>, and C<die> (in the absence of C<eval>) perform a C<JMPENV_JUMP(2)>, while C<die> within C<eval> does a C<JMPENV_JUMP(3)>. At entry points to perl, such as C<perl_parse()>, C<perl_run()> and C<call_sv(cv, G_EVAL)> each does a C<JMPENV_PUSH>, then enter a runops loop or whatever, and handle possible exception returns. For a 2 return, final cleanup is performed, such as popping stacks and calling C<CHECK> or C<END> blocks. Amongst other things, this is how scope cleanup still occurs during an C<exit>. If a C<die> can find a C<CxEVAL> block on the context stack, then the stack is popped to that level and the return op in that block is assigned to C<PL_restartop>; then a C<JMPENV_JUMP(3)> is performed. This normally passes control back to the guard. In the case of C<perl_run> and C<call_sv>, a non-null C<PL_restartop> triggers re-entry to the runops loop. The is the normal way that C<die> or C<croak> is handled within an C<eval>. Sometimes ops are executed within an inner runops loop, such as tie, sort or overload code. In this case, something like sub FETCH { eval { die } } would cause a longjmp right back to the guard in C<perl_run>, popping both runops loops, which is clearly incorrect. One way to avoid this is for the tie code to do a C<JMPENV_PUSH> before executing C<FETCH> in the inner runops loop, but for efficiency reasons, perl in fact just sets a flag, using C<CATCH_SET(TRUE)>. The C<pp_require>, C<pp_entereval> and C<pp_entertry> ops check this flag, and if true, they call C<docatch>, which does a C<JMPENV_PUSH> and starts a new runops level to execute the code, rather than doing it on the current loop. As a further optimisation, on exit from the eval block in the C<FETCH>, execution of the code following the block is still carried on in the inner loop. When an exception is raised, C<docatch> compares the C<JMPENV> level of the C<CxEVAL> with C<PL_top_env> and if they differ, just re-throws the exception. In this way any inner loops get popped. Here's an example. 1: eval { tie @a, 'A' }; 2: sub A::TIEARRAY { 3: eval { die }; 4: die; 5: } To run this code, C<perl_run> is called, which does a C<JMPENV_PUSH> then enters a runops loop. This loop executes the eval and tie ops on line 1, with the eval pushing a C<CxEVAL> onto the context stack. The C<pp_tie> does a C<CATCH_SET(TRUE)>, then starts a second runops loop to execute the body of C<TIEARRAY>. When it executes the entertry op on line 3, C<CATCH_GET> is true, so C<pp_entertry> calls C<docatch> which does a C<JMPENV_PUSH> and starts a third runops loop, which then executes the die op. At this point the C call stack looks like this: Perl_pp_die Perl_runops # third loop S_docatch_body S_docatch Perl_pp_entertry Perl_runops # second loop S_call_body Perl_call_sv Perl_pp_tie Perl_runops # first loop S_run_body perl_run main and the context and data stacks, as shown by C<-Dstv>, look like: STACK 0: MAIN CX 0: BLOCK => CX 1: EVAL => AV() PV("A"\0) retop=leave STACK 1: MAGIC CX 0: SUB => retop=(null) CX 1: EVAL => * retop=nextstate The die pops the first C<CxEVAL> off the context stack, sets C<PL_restartop> from it, does a C<JMPENV_JUMP(3)>, and control returns to the top C<docatch>. This then starts another third-level runops level, which executes the nextstate, pushmark and die ops on line 4. At the point that the second C<pp_die> is called, the C call stack looks exactly like that above, even though we are no longer within an inner eval; this is because of the optimization mentioned earlier. However, the context stack now looks like this, ie with the top CxEVAL popped: STACK 0: MAIN CX 0: BLOCK => CX 1: EVAL => AV() PV("A"\0) retop=leave STACK 1: MAGIC CX 0: SUB => retop=(null) The die on line 4 pops the context stack back down to the CxEVAL, leaving it as: STACK 0: MAIN CX 0: BLOCK => As usual, C<PL_restartop> is extracted from the C<CxEVAL>, and a C<JMPENV_JUMP(3)> done, which pops the C stack back to the docatch: S_docatch Perl_pp_entertry Perl_runops # second loop S_call_body Perl_call_sv Perl_pp_tie Perl_runops # first loop S_run_body perl_run main In this case, because the C<JMPENV> level recorded in the C<CxEVAL> differs from the current one, C<docatch> just does a C<JMPENV_JUMP(3)> and the C stack unwinds to: perl_run main Because C<PL_restartop> is non-null, C<run_body> starts a new runops loop and execution continues. =back =head2 Internal Variable Types You should by now have had a look at L<perlguts>, which tells you about Perl's internal variable types: SVs, HVs, AVs and the rest. If not, do that now. These variables are used not only to represent Perl-space variables, but also any constants in the code, as well as some structures completely internal to Perl. The symbol table, for instance, is an ordinary Perl hash. Your code is represented by an SV as it's read into the parser; any program files you call are opened via ordinary Perl filehandles, and so on. The core L<Devel::Peek|Devel::Peek> module lets us examine SVs from a Perl program. Let's see, for instance, how Perl treats the constant C<"hello">. % perl -MDevel::Peek -e 'Dump("hello")' 1 SV = PV(0xa041450) at 0xa04ecbc 2 REFCNT = 1 3 FLAGS = (POK,READONLY,pPOK) 4 PV = 0xa0484e0 "hello"\0 5 CUR = 5 6 LEN = 6 Reading C<Devel::Peek> output takes a bit of practise, so let's go through it line by line. Line 1 tells us we're looking at an SV which lives at C<0xa04ecbc> in memory. SVs themselves are very simple structures, but they contain a pointer to a more complex structure. In this case, it's a PV, a structure which holds a string value, at location C<0xa041450>. Line 2 is the reference count; there are no other references to this data, so it's 1. Line 3 are the flags for this SV - it's OK to use it as a PV, it's a read-only SV (because it's a constant) and the data is a PV internally. Next we've got the contents of the string, starting at location C<0xa0484e0>. Line 5 gives us the current length of the string - note that this does B<not> include the null terminator. Line 6 is not the length of the string, but the length of the currently allocated buffer; as the string grows, Perl automatically extends the available storage via a routine called C<SvGROW>. You can get at any of these quantities from C very easily; just add C<Sv> to the name of the field shown in the snippet, and you've got a macro which will return the value: C<SvCUR(sv)> returns the current length of the string, C<SvREFCOUNT(sv)> returns the reference count, C<SvPV(sv, len)> returns the string itself with its length, and so on. More macros to manipulate these properties can be found in L<perlguts>. Let's take an example of manipulating a PV, from C<sv_catpvn>, in F<sv.c> 1 void 2 Perl_sv_catpvn(pTHX_ register SV *sv, register const char *ptr, register STRLEN len) 3 { 4 STRLEN tlen; 5 char *junk; 6 junk = SvPV_force(sv, tlen); 7 SvGROW(sv, tlen + len + 1); 8 if (ptr == junk) 9 ptr = SvPVX(sv); 10 Move(ptr,SvPVX(sv)+tlen,len,char); 11 SvCUR(sv) += len; 12 *SvEND(sv) = '\0'; 13 (void)SvPOK_only_UTF8(sv); /* validate pointer */ 14 SvTAINT(sv); 15 } This is a function which adds a string, C<ptr>, of length C<len> onto the end of the PV stored in C<sv>. The first thing we do in line 6 is make sure that the SV B<has> a valid PV, by calling the C<SvPV_force> macro to force a PV. As a side effect, C<tlen> gets set to the current value of the PV, and the PV itself is returned to C<junk>. In line 7, we make sure that the SV will have enough room to accommodate the old string, the new string and the null terminator. If C<LEN> isn't big enough, C<SvGROW> will reallocate space for us. Now, if C<junk> is the same as the string we're trying to add, we can grab the string directly from the SV; C<SvPVX> is the address of the PV in the SV. Line 10 does the actual catenation: the C<Move> macro moves a chunk of memory around: we move the string C<ptr> to the end of the PV - that's the start of the PV plus its current length. We're moving C<len> bytes of type C<char>. After doing so, we need to tell Perl we've extended the string, by altering C<CUR> to reflect the new length. C<SvEND> is a macro which gives us the end of the string, so that needs to be a C<"\0">. Line 13 manipulates the flags; since we've changed the PV, any IV or NV values will no longer be valid: if we have C<$a=10; $a.="6";> we don't want to use the old IV of 10. C<SvPOK_only_utf8> is a special UTF-8-aware version of C<SvPOK_only>, a macro which turns off the IOK and NOK flags and turns on POK. The final C<SvTAINT> is a macro which launders tainted data if taint mode is turned on. AVs and HVs are more complicated, but SVs are by far the most common variable type being thrown around. Having seen something of how we manipulate these, let's go on and look at how the op tree is constructed. =head2 Op Trees First, what is the op tree, anyway? The op tree is the parsed representation of your program, as we saw in our section on parsing, and it's the sequence of operations that Perl goes through to execute your program, as we saw in L</Running>. An op is a fundamental operation that Perl can perform: all the built-in functions and operators are ops, and there are a series of ops which deal with concepts the interpreter needs internally - entering and leaving a block, ending a statement, fetching a variable, and so on. The op tree is connected in two ways: you can imagine that there are two "routes" through it, two orders in which you can traverse the tree. First, parse order reflects how the parser understood the code, and secondly, execution order tells perl what order to perform the operations in. The easiest way to examine the op tree is to stop Perl after it has finished parsing, and get it to dump out the tree. This is exactly what the compiler backends L<B::Terse|B::Terse>, L<B::Concise|B::Concise> and L<B::Debug|B::Debug> do. Let's have a look at how Perl sees C<$a = $b + $c>: % perl -MO=Terse -e '$a=$b+$c' 1 LISTOP (0x8179888) leave 2 OP (0x81798b0) enter 3 COP (0x8179850) nextstate 4 BINOP (0x8179828) sassign 5 BINOP (0x8179800) add [1] 6 UNOP (0x81796e0) null [15] 7 SVOP (0x80fafe0) gvsv GV (0x80fa4cc) *b 8 UNOP (0x81797e0) null [15] 9 SVOP (0x8179700) gvsv GV (0x80efeb0) *c 10 UNOP (0x816b4f0) null [15] 11 SVOP (0x816dcf0) gvsv GV (0x80fa460) *a Let's start in the middle, at line 4. This is a BINOP, a binary operator, which is at location C<0x8179828>. The specific operator in question is C<sassign> - scalar assignment - and you can find the code which implements it in the function C<pp_sassign> in F<pp_hot.c>. As a binary operator, it has two children: the add operator, providing the result of C<$b+$c>, is uppermost on line 5, and the left hand side is on line 10. Line 10 is the null op: this does exactly nothing. What is that doing there? If you see the null op, it's a sign that something has been optimized away after parsing. As we mentioned in L</Optimization>, the optimization stage sometimes converts two operations into one, for example when fetching a scalar variable. When this happens, instead of rewriting the op tree and cleaning up the dangling pointers, it's easier just to replace the redundant operation with the null op. Originally, the tree would have looked like this: 10 SVOP (0x816b4f0) rv2sv [15] 11 SVOP (0x816dcf0) gv GV (0x80fa460) *a That is, fetch the C<a> entry from the main symbol table, and then look at the scalar component of it: C<gvsv> (C<pp_gvsv> into F<pp_hot.c>) happens to do both these things. The right hand side, starting at line 5 is similar to what we've just seen: we have the C<add> op (C<pp_add> also in F<pp_hot.c>) add together two C<gvsv>s. Now, what's this about? 1 LISTOP (0x8179888) leave 2 OP (0x81798b0) enter 3 COP (0x8179850) nextstate C<enter> and C<leave> are scoping ops, and their job is to perform any housekeeping every time you enter and leave a block: lexical variables are tidied up, unreferenced variables are destroyed, and so on. Every program will have those first three lines: C<leave> is a list, and its children are all the statements in the block. Statements are delimited by C<nextstate>, so a block is a collection of C<nextstate> ops, with the ops to be performed for each statement being the children of C<nextstate>. C<enter> is a single op which functions as a marker. That's how Perl parsed the program, from top to bottom: Program | Statement | = / \ / \ $a + / \ $b $c However, it's impossible to B<perform> the operations in this order: you have to find the values of C<$b> and C<$c> before you add them together, for instance. So, the other thread that runs through the op tree is the execution order: each op has a field C<op_next> which points to the next op to be run, so following these pointers tells us how perl executes the code. We can traverse the tree in this order using the C<exec> option to C<B::Terse>: % perl -MO=Terse,exec -e '$a=$b+$c' 1 OP (0x8179928) enter 2 COP (0x81798c8) nextstate 3 SVOP (0x81796c8) gvsv GV (0x80fa4d4) *b 4 SVOP (0x8179798) gvsv GV (0x80efeb0) *c 5 BINOP (0x8179878) add [1] 6 SVOP (0x816dd38) gvsv GV (0x80fa468) *a 7 BINOP (0x81798a0) sassign 8 LISTOP (0x8179900) leave This probably makes more sense for a human: enter a block, start a statement. Get the values of C<$b> and C<$c>, and add them together. Find C<$a>, and assign one to the other. Then leave. The way Perl builds up these op trees in the parsing process can be unravelled by examining F<perly.y>, the YACC grammar. Let's take the piece we need to construct the tree for C<$a = $b + $c> 1 term : term ASSIGNOP term 2 { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); } 3 | term ADDOP term 4 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } If you're not used to reading BNF grammars, this is how it works: You're fed certain things by the tokeniser, which generally end up in upper case. Here, C<ADDOP>, is provided when the tokeniser sees C<+> in your code. C<ASSIGNOP> is provided when C<=> is used for assigning. These are "terminal symbols", because you can't get any simpler than them. The grammar, lines one and three of the snippet above, tells you how to build up more complex forms. These complex forms, "non-terminal symbols" are generally placed in lower case. C<term> here is a non-terminal symbol, representing a single expression. The grammar gives you the following rule: you can make the thing on the left of the colon if you see all the things on the right in sequence. This is called a "reduction", and the aim of parsing is to completely reduce the input. There are several different ways you can perform a reduction, separated by vertical bars: so, C<term> followed by C<=> followed by C<term> makes a C<term>, and C<term> followed by C<+> followed by C<term> can also make a C<term>. So, if you see two terms with an C<=> or C<+>, between them, you can turn them into a single expression. When you do this, you execute the code in the block on the next line: if you see C<=>, you'll do the code in line 2. If you see C<+>, you'll do the code in line 4. It's this code which contributes to the op tree. | term ADDOP term { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } What this does is creates a new binary op, and feeds it a number of variables. The variables refer to the tokens: C<$1> is the first token in the input, C<$2> the second, and so on - think regular expression backreferences. C<$$> is the op returned from this reduction. So, we call C<newBINOP> to create a new binary operator. The first parameter to C<newBINOP>, a function in F<op.c>, is the op type. It's an addition operator, so we want the type to be C<ADDOP>. We could specify this directly, but it's right there as the second token in the input, so we use C<$2>. The second parameter is the op's flags: 0 means "nothing special". Then the things to add: the left and right hand side of our expression, in scalar context. =head2 Stacks When perl executes something like C<addop>, how does it pass on its results to the next op? The answer is, through the use of stacks. Perl has a number of stacks to store things it's currently working on, and we'll look at the three most important ones here. =over 3 =item Argument stack Arguments are passed to PP code and returned from PP code using the argument stack, C<ST>. The typical way to handle arguments is to pop them off the stack, deal with them how you wish, and then push the result back onto the stack. This is how, for instance, the cosine operator works: NV value; value = POPn; value = Perl_cos(value); XPUSHn(value); We'll see a more tricky example of this when we consider Perl's macros below. C<POPn> gives you the NV (floating point value) of the top SV on the stack: the C<$x> in C<cos($x)>. Then we compute the cosine, and push the result back as an NV. The C<X> in C<XPUSHn> means that the stack should be extended if necessary - it can't be necessary here, because we know there's room for one more item on the stack, since we've just removed one! The C<XPUSH*> macros at least guarantee safety. Alternatively, you can fiddle with the stack directly: C<SP> gives you the first element in your portion of the stack, and C<TOP*> gives you the top SV/IV/NV/etc. on the stack. So, for instance, to do unary negation of an integer: SETi(-TOPi); Just set the integer value of the top stack entry to its negation. Argument stack manipulation in the core is exactly the same as it is in XSUBs - see L<perlxstut>, L<perlxs> and L<perlguts> for a longer description of the macros used in stack manipulation. =item Mark stack I say "your portion of the stack" above because PP code doesn't necessarily get the whole stack to itself: if your function calls another function, you'll only want to expose the arguments aimed for the called function, and not (necessarily) let it get at your own data. The way we do this is to have a "virtual" bottom-of-stack, exposed to each function. The mark stack keeps bookmarks to locations in the argument stack usable by each function. For instance, when dealing with a tied variable, (internally, something with "P" magic) Perl has to call methods for accesses to the tied variables. However, we need to separate the arguments exposed to the method to the argument exposed to the original function - the store or fetch or whatever it may be. Here's roughly how the tied C<push> is implemented; see C<av_push> in F<av.c>: 1 PUSHMARK(SP); 2 EXTEND(SP,2); 3 PUSHs(SvTIED_obj((SV*)av, mg)); 4 PUSHs(val); 5 PUTBACK; 6 ENTER; 7 call_method("PUSH", G_SCALAR|G_DISCARD); 8 LEAVE; Let's examine the whole implementation, for practice: 1 PUSHMARK(SP); Push the current state of the stack pointer onto the mark stack. This is so that when we've finished adding items to the argument stack, Perl knows how many things we've added recently. 2 EXTEND(SP,2); 3 PUSHs(SvTIED_obj((SV*)av, mg)); 4 PUSHs(val); We're going to add two more items onto the argument stack: when you have a tied array, the C<PUSH> subroutine receives the object and the value to be pushed, and that's exactly what we have here - the tied object, retrieved with C<SvTIED_obj>, and the value, the SV C<val>. 5 PUTBACK; Next we tell Perl to update the global stack pointer from our internal variable: C<dSP> only gave us a local copy, not a reference to the global. 6 ENTER; 7 call_method("PUSH", G_SCALAR|G_DISCARD); 8 LEAVE; C<ENTER> and C<LEAVE> localise a block of code - they make sure that all variables are tidied up, everything that has been localised gets its previous value returned, and so on. Think of them as the C<{> and C<}> of a Perl block. To actually do the magic method call, we have to call a subroutine in Perl space: C<call_method> takes care of that, and it's described in L<perlcall>. We call the C<PUSH> method in scalar context, and we're going to discard its return value. The call_method() function removes the top element of the mark stack, so there is nothing for the caller to clean up. =item Save stack C doesn't have a concept of local scope, so perl provides one. We've seen that C<ENTER> and C<LEAVE> are used as scoping braces; the save stack implements the C equivalent of, for example: { local $foo = 42; ... } See L<perlguts/Localising Changes> for how to use the save stack. =back =head2 Millions of Macros One thing you'll notice about the Perl source is that it's full of macros. Some have called the pervasive use of macros the hardest thing to understand, others find it adds to clarity. Let's take an example, the code which implements the addition operator: 1 PP(pp_add) 2 { 3 dSP; dATARGET; tryAMAGICbin(add,opASSIGN); 4 { 5 dPOPTOPnnrl_ul; 6 SETn( left + right ); 7 RETURN; 8 } 9 } Every line here (apart from the braces, of course) contains a macro. The first line sets up the function declaration as Perl expects for PP code; line 3 sets up variable declarations for the argument stack and the target, the return value of the operation. Finally, it tries to see if the addition operation is overloaded; if so, the appropriate subroutine is called. Line 5 is another variable declaration - all variable declarations start with C<d> - which pops from the top of the argument stack two NVs (hence C<nn>) and puts them into the variables C<right> and C<left>, hence the C<rl>. These are the two operands to the addition operator. Next, we call C<SETn> to set the NV of the return value to the result of adding the two values. This done, we return - the C<RETURN> macro makes sure that our return value is properly handled, and we pass the next operator to run back to the main run loop. Most of these macros are explained in L<perlapi>, and some of the more important ones are explained in L<perlxs> as well. Pay special attention to L<perlguts/Background and PERL_IMPLICIT_CONTEXT> for information on the C<[pad]THX_?> macros. =head2 The .i Targets You can expand the macros in a F<foo.c> file by saying make foo.i which will expand the macros using cpp. Don't be scared by the results. =head1 SOURCE CODE STATIC ANALYSIS Various tools exist for analysing C source code B<statically>, as opposed to B<dynamically>, that is, without executing the code. It is possible to detect resource leaks, undefined behaviour, type mismatches, portability problems, code paths that would cause illegal memory accesses, and other similar problems by just parsing the C code and looking at the resulting graph, what does it tell about the execution and data flows. As a matter of fact, this is exactly how C compilers know to give warnings about dubious code. =head2 lint, splint The good old C code quality inspector, C<lint>, is available in several platforms, but please be aware that there are several different implementations of it by different vendors, which means that the flags are not identical across different platforms. There is a lint variant called C<splint> (Secure Programming Lint) available from http://www.splint.org/ that should compile on any Unix-like platform. There are C<lint> and <splint> targets in Makefile, but you may have to diddle with the flags (see above). =head2 Coverity Coverity (http://www.coverity.com/) is a product similar to lint and as a testbed for their product they periodically check several open source projects, and they give out accounts to open source developers to the defect databases. =head2 cpd (cut-and-paste detector) The cpd tool detects cut-and-paste coding. If one instance of the cut-and-pasted code changes, all the other spots should probably be changed, too. Therefore such code should probably be turned into a subroutine or a macro. cpd (http://pmd.sourceforge.net/cpd.html) is part of the pmd project (http://pmd.sourceforge.net/). pmd was originally written for static analysis of Java code, but later the cpd part of it was extended to parse also C and C++. Download the pmd-bin-X.Y.zip () from the SourceForge site, extract the pmd-X.Y.jar from it, and then run that on source code thusly: java -cp pmd-X.Y.jar net.sourceforge.pmd.cpd.CPD --minimum-tokens 100 --files /some/where/src --language c > cpd.txt You may run into memory limits, in which case you should use the -Xmx option: java -Xmx512M ... =head2 gcc warnings Though much can be written about the inconsistency and coverage problems of gcc warnings (like C<-Wall> not meaning "all the warnings", or some common portability problems not being covered by C<-Wall>, or C<-ansi> and C<-pedantic> both being a poorly defined collection of warnings, and so forth), gcc is still a useful tool in keeping our coding nose clean. The C<-Wall> is by default on. The C<-ansi> (and its sidekick, C<-pedantic>) would be nice to be on always, but unfortunately they are not safe on all platforms, they can for example cause fatal conflicts with the system headers (Solaris being a prime example). If Configure C<-Dgccansipedantic> is used, the C<cflags> frontend selects C<-ansi -pedantic> for the platforms where they are known to be safe. Starting from Perl 5.9.4 the following extra flags are added: =over 4 =item * C<-Wendif-labels> =item * C<-Wextra> =item * C<-Wdeclaration-after-statement> =back The following flags would be nice to have but they would first need their own Augean stablemaster: =over 4 =item * C<-Wpointer-arith> =item * C<-Wshadow> =item * C<-Wstrict-prototypes> =back The C<-Wtraditional> is another example of the annoying tendency of gcc to bundle a lot of warnings under one switch -- it would be impossible to deploy in practice because it would complain a lot -- but it does contain some warnings that would be beneficial to have available on their own, such as the warning about string constants inside macros containing the macro arguments: this behaved differently pre-ANSI than it does in ANSI, and some C compilers are still in transition, AIX being an example. =head2 Warnings of other C compilers Other C compilers (yes, there B<are> other C compilers than gcc) often have their "strict ANSI" or "strict ANSI with some portability extensions" modes on, like for example the Sun Workshop has its C<-Xa> mode on (though implicitly), or the DEC (these days, HP...) has its C<-std1> mode on. =head2 DEBUGGING You can compile a special debugging version of Perl, which allows you to use the C<-D> option of Perl to tell more about what Perl is doing. But sometimes there is no alternative than to dive in with a debugger, either to see the stack trace of a core dump (very useful in a bug report), or trying to figure out what went wrong before the core dump happened, or how did we end up having wrong or unexpected results. =head2 Poking at Perl To really poke around with Perl, you'll probably want to build Perl for debugging, like this: ./Configure -d -D optimize=-g make C<-g> is a flag to the C compiler to have it produce debugging information which will allow us to step through a running program, and to see in which C function we are at (without the debugging information we might see only the numerical addresses of the functions, which is not very helpful). F<Configure> will also turn on the C<DEBUGGING> compilation symbol which enables all the internal debugging code in Perl. There are a whole bunch of things you can debug with this: L<perlrun> lists them all, and the best way to find out about them is to play about with them. The most useful options are probably l Context (loop) stack processing t Trace execution o Method and overloading resolution c String/numeric conversions Some of the functionality of the debugging code can be achieved using XS modules. -Dr => use re 'debug' -Dx => use O 'Debug' =head2 Using a source-level debugger If the debugging output of C<-D> doesn't help you, it's time to step through perl's execution with a source-level debugger. =over 3 =item * We'll use C<gdb> for our examples here; the principles will apply to any debugger (many vendors call their debugger C<dbx>), but check the manual of the one you're using. =back To fire up the debugger, type gdb ./perl Or if you have a core dump: gdb ./perl core You'll want to do that in your Perl source tree so the debugger can read the source code. You should see the copyright message, followed by the prompt. (gdb) C<help> will get you into the documentation, but here are the most useful commands: =over 3 =item run [args] Run the program with the given arguments. =item break function_name =item break source.c:xxx Tells the debugger that we'll want to pause execution when we reach either the named function (but see L<perlguts/Internal Functions>!) or the given line in the named source file. =item step Steps through the program a line at a time. =item next Steps through the program a line at a time, without descending into functions. =item continue Run until the next breakpoint. =item finish Run until the end of the current function, then stop again. =item 'enter' Just pressing Enter will do the most recent operation again - it's a blessing when stepping through miles of source code. =item print Execute the given C code and print its results. B<WARNING>: Perl makes heavy use of macros, and F<gdb> does not necessarily support macros (see later L</"gdb macro support">). You'll have to substitute them yourself, or to invoke cpp on the source code files (see L</"The .i Targets">) So, for instance, you can't say print SvPV_nolen(sv) but you have to say print Perl_sv_2pv_nolen(sv) =back You may find it helpful to have a "macro dictionary", which you can produce by saying C<cpp -dM perl.c | sort>. Even then, F<cpp> won't recursively apply those macros for you. =head2 gdb macro support Recent versions of F<gdb> have fairly good macro support, but in order to use it you'll need to compile perl with macro definitions included in the debugging information. Using F<gcc> version 3.1, this means configuring with C<-Doptimize=-g3>. Other compilers might use a different switch (if they support debugging macros at all). =head2 Dumping Perl Data Structures One way to get around this macro hell is to use the dumping functions in F<dump.c>; these work a little like an internal L<Devel::Peek|Devel::Peek>, but they also cover OPs and other structures that you can't get at from Perl. Let's take an example. We'll use the C<$a = $b + $c> we used before, but give it a bit of context: C<$b = "6XXXX"; $c = 2.3;>. Where's a good place to stop and poke around? What about C<pp_add>, the function we examined earlier to implement the C<+> operator: (gdb) break Perl_pp_add Breakpoint 1 at 0x46249f: file pp_hot.c, line 309. Notice we use C<Perl_pp_add> and not C<pp_add> - see L<perlguts/Internal Functions>. With the breakpoint in place, we can run our program: (gdb) run -e '$b = "6XXXX"; $c = 2.3; $a = $b + $c' Lots of junk will go past as gdb reads in the relevant source files and libraries, and then: Breakpoint 1, Perl_pp_add () at pp_hot.c:309 309 dSP; dATARGET; tryAMAGICbin(add,opASSIGN); (gdb) step 311 dPOPTOPnnrl_ul; (gdb) We looked at this bit of code before, and we said that C<dPOPTOPnnrl_ul> arranges for two C<NV>s to be placed into C<left> and C<right> - let's slightly expand it: #define dPOPTOPnnrl_ul NV right = POPn; \ SV *leftsv = TOPs; \ NV left = USE_LEFT(leftsv) ? SvNV(leftsv) : 0.0 C<POPn> takes the SV from the top of the stack and obtains its NV either directly (if C<SvNOK> is set) or by calling the C<sv_2nv> function. C<TOPs> takes the next SV from the top of the stack - yes, C<POPn> uses C<TOPs> - but doesn't remove it. We then use C<SvNV> to get the NV from C<leftsv> in the same way as before - yes, C<POPn> uses C<SvNV>. Since we don't have an NV for C<$b>, we'll have to use C<sv_2nv> to convert it. If we step again, we'll find ourselves there: Perl_sv_2nv (sv=0xa0675d0) at sv.c:1669 1669 if (!sv) (gdb) We can now use C<Perl_sv_dump> to investigate the SV: SV = PV(0xa057cc0) at 0xa0675d0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0xa06a510 "6XXXX"\0 CUR = 5 LEN = 6 $1 = void We know we're going to get C<6> from this, so let's finish the subroutine: (gdb) finish Run till exit from #0 Perl_sv_2nv (sv=0xa0675d0) at sv.c:1671 0x462669 in Perl_pp_add () at pp_hot.c:311 311 dPOPTOPnnrl_ul; We can also dump out this op: the current op is always stored in C<PL_op>, and we can dump it with C<Perl_op_dump>. This'll give us similar output to L<B::Debug|B::Debug>. { 13 TYPE = add ===> 14 TARG = 1 FLAGS = (SCALAR,KIDS) { TYPE = null ===> (12) (was rv2sv) FLAGS = (SCALAR,KIDS) { 11 TYPE = gvsv ===> 12 FLAGS = (SCALAR) GV = main::b } } # finish this later # =head2 Patching All right, we've now had a look at how to navigate the Perl sources and some things you'll need to know when fiddling with them. Let's now get on and create a simple patch. Here's something Larry suggested: if a C<U> is the first active format during a C<pack>, (for example, C<pack "U3C8", @stuff>) then the resulting string should be treated as UTF-8 encoded. How do we prepare to fix this up? First we locate the code in question - the C<pack> happens at runtime, so it's going to be in one of the F<pp> files. Sure enough, C<pp_pack> is in F<pp.c>. Since we're going to be altering this file, let's copy it to F<pp.c~>. [Well, it was in F<pp.c> when this tutorial was written. It has now been split off with C<pp_unpack> to its own file, F<pp_pack.c>] Now let's look over C<pp_pack>: we take a pattern into C<pat>, and then loop over the pattern, taking each format character in turn into C<datum_type>. Then for each possible format character, we swallow up the other arguments in the pattern (a field width, an asterisk, and so on) and convert the next chunk input into the specified format, adding it onto the output SV C<cat>. How do we know if the C<U> is the first format in the C<pat>? Well, if we have a pointer to the start of C<pat> then, if we see a C<U> we can test whether we're still at the start of the string. So, here's where C<pat> is set up: STRLEN fromlen; register char *pat = SvPVx(*++MARK, fromlen); register char *patend = pat + fromlen; register I32 len; I32 datumtype; SV *fromstr; We'll have another string pointer in there: STRLEN fromlen; register char *pat = SvPVx(*++MARK, fromlen); register char *patend = pat + fromlen; + char *patcopy; register I32 len; I32 datumtype; SV *fromstr; And just before we start the loop, we'll set C<patcopy> to be the start of C<pat>: items = SP - MARK; MARK++; sv_setpvn(cat, "", 0); + patcopy = pat; while (pat < patend) { Now if we see a C<U> which was at the start of the string, we turn on the C<UTF8> flag for the output SV, C<cat>: + if (datumtype == 'U' && pat==patcopy+1) + SvUTF8_on(cat); if (datumtype == '#') { while (pat < patend && *pat != '\n') pat++; Remember that it has to be C<patcopy+1> because the first character of the string is the C<U> which has been swallowed into C<datumtype!> Oops, we forgot one thing: what if there are spaces at the start of the pattern? C<pack(" U*", @stuff)> will have C<U> as the first active character, even though it's not the first thing in the pattern. In this case, we have to advance C<patcopy> along with C<pat> when we see spaces: if (isSPACE(datumtype)) continue; needs to become if (isSPACE(datumtype)) { patcopy++; continue; } OK. That's the C part done. Now we must do two additional things before this patch is ready to go: we've changed the behaviour of Perl, and so we must document that change. We must also provide some more regression tests to make sure our patch works and doesn't create a bug somewhere else along the line. The regression tests for each operator live in F<t/op/>, and so we make a copy of F<t/op/pack.t> to F<t/op/pack.t~>. Now we can add our tests to the end. First, we'll test that the C<U> does indeed create Unicode strings. t/op/pack.t has a sensible ok() function, but if it didn't we could use the one from t/test.pl. require './test.pl'; plan( tests => 159 ); so instead of this: print 'not ' unless "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000); print "ok $test\n"; $test++; we can write the more sensible (see L<Test::More> for a full explanation of is() and other testing functions). is( "1.20.300.4000", sprintf "%vd", pack("U*",1,20,300,4000), "U* produces Unicode" ); Now we'll test that we got that space-at-the-beginning business right: is( "1.20.300.4000", sprintf "%vd", pack(" U*",1,20,300,4000), " with spaces at the beginning" ); And finally we'll test that we don't make Unicode strings if C<U> is B<not> the first active format: isnt( v1.20.300.4000, sprintf "%vd", pack("C0U*",1,20,300,4000), "U* not first isn't Unicode" ); Mustn't forget to change the number of tests which appears at the top, or else the automated tester will get confused. This will either look like this: print "1..156\n"; or this: plan( tests => 156 ); We now compile up Perl, and run it through the test suite. Our new tests pass, hooray! Finally, the documentation. The job is never done until the paperwork is over, so let's describe the change we've just made. The relevant place is F<pod/perlfunc.pod>; again, we make a copy, and then we'll insert this text in the description of C<pack>: =item * If the pattern begins with a C<U>, the resulting string will be treated as UTF-8-encoded Unicode. You can force UTF-8 encoding on in a string with an initial C<U0>, and the bytes that follow will be interpreted as Unicode characters. If you don't want this to happen, you can begin your pattern with C<C0> (or anything else) to force Perl not to UTF-8 encode your string, and then follow this with a C<U*> somewhere in your pattern. All done. Now let's create the patch. F<Porting/patching.pod> tells us that if we're making major changes, we should copy the entire directory to somewhere safe before we begin fiddling, and then do diff -ruN old new > patch However, we know which files we've changed, and we can simply do this: diff -u pp.c~ pp.c > patch diff -u t/op/pack.t~ t/op/pack.t >> patch diff -u pod/perlfunc.pod~ pod/perlfunc.pod >> patch We end up with a patch looking a little like this: --- pp.c~ Fri Jun 02 04:34:10 2000 +++ pp.c Fri Jun 16 11:37:25 2000 @@ -4375,6 +4375,7 @@ register I32 items; STRLEN fromlen; register char *pat = SvPVx(*++MARK, fromlen); + char *patcopy; register char *patend = pat + fromlen; register I32 len; I32 datumtype; @@ -4405,6 +4406,7 @@ ... And finally, we submit it, with our rationale, to perl5-porters. Job done! =head2 Patching a core module This works just like patching anything else, with an extra consideration. Many core modules also live on CPAN. If this is so, patch the CPAN version instead of the core and send the patch off to the module maintainer (with a copy to p5p). This will help the module maintainer keep the CPAN version in sync with the core version without constantly scanning p5p. The list of maintainers of core modules is usefully documented in F<Porting/Maintainers.pl>. =head2 Adding a new function to the core If, as part of a patch to fix a bug, or just because you have an especially good idea, you decide to add a new function to the core, discuss your ideas on p5p well before you start work. It may be that someone else has already attempted to do what you are considering and can give lots of good advice or even provide you with bits of code that they already started (but never finished). You have to follow all of the advice given above for patching. It is extremely important to test any addition thoroughly and add new tests to explore all boundary conditions that your new function is expected to handle. If your new function is used only by one module (e.g. toke), then it should probably be named S_your_function (for static); on the other hand, if you expect it to accessible from other functions in Perl, you should name it Perl_your_function. See L<perlguts/Internal Functions> for more details. The location of any new code is also an important consideration. Don't just create a new top level .c file and put your code there; you would have to make changes to Configure (so the Makefile is created properly), as well as possibly lots of include files. This is strictly pumpking business. It is better to add your function to one of the existing top level source code files, but your choice is complicated by the nature of the Perl distribution. Only the files that are marked as compiled static are located in the perl executable. Everything else is located in the shared library (or DLL if you are running under WIN32). So, for example, if a function was only used by functions located in toke.c, then your code can go in toke.c. If, however, you want to call the function from universal.c, then you should put your code in another location, for example util.c. In addition to writing your c-code, you will need to create an appropriate entry in embed.pl describing your function, then run 'make regen_headers' to create the entries in the numerous header files that perl needs to compile correctly. See L<perlguts/Internal Functions> for information on the various options that you can set in embed.pl. You will forget to do this a few (or many) times and you will get warnings during the compilation phase. Make sure that you mention this when you post your patch to P5P; the pumpking needs to know this. When you write your new code, please be conscious of existing code conventions used in the perl source files. See L<perlstyle> for details. Although most of the guidelines discussed seem to focus on Perl code, rather than c, they all apply (except when they don't ;). See also I<Porting/patching.pod> file in the Perl source distribution for lots of details about both formatting and submitting patches of your changes. Lastly, TEST TEST TEST TEST TEST any code before posting to p5p. Test on as many platforms as you can find. Test as many perl Configure options as you can (e.g. MULTIPLICITY). If you have profiling or memory tools, see L<EXTERNAL TOOLS FOR DEBUGGING PERL> below for how to use them to further test your code. Remember that most of the people on P5P are doing this on their own time and don't have the time to debug your code. =head2 Writing a test Every module and built-in function has an associated test file (or should...). If you add or change functionality, you have to write a test. If you fix a bug, you have to write a test so that bug never comes back. If you alter the docs, it would be nice to test what the new documentation says. In short, if you submit a patch you probably also have to patch the tests. For modules, the test file is right next to the module itself. F<lib/strict.t> tests F<lib/strict.pm>. This is a recent innovation, so there are some snags (and it would be wonderful for you to brush them out), but it basically works that way. Everything else lives in F<t/>. If you add a new test directory under F<t/>, it is imperative that you add that directory to F<t/HARNESS> and F<t/TEST>. =over 3 =item F<t/base/> Testing of the absolute basic functionality of Perl. Things like C<if>, basic file reads and writes, simple regexes, etc. These are run first in the test suite and if any of them fail, something is I<really> broken. =item F<t/cmd/> These test the basic control structures, C<if/else>, C<while>, subroutines, etc. =item F<t/comp/> Tests basic issues of how Perl parses and compiles itself. =item F<t/io/> Tests for built-in IO functions, including command line arguments. =item F<t/lib/> The old home for the module tests, you shouldn't put anything new in here. There are still some bits and pieces hanging around in here that need to be moved. Perhaps you could move them? Thanks! =item F<t/mro/> Tests for perl's method resolution order implementations (see L<mro>). =item F<t/op/> Tests for perl's built in functions that don't fit into any of the other directories. =item F<t/pod/> Tests for POD directives. There are still some tests for the Pod modules hanging around in here that need to be moved out into F<lib/>. =item F<t/run/> Testing features of how perl actually runs, including exit codes and handling of PERL* environment variables. =item F<t/uni/> Tests for the core support of Unicode. =item F<t/win32/> Windows-specific tests. =item F<t/x2p> A test suite for the s2p converter. =back The core uses the same testing style as the rest of Perl, a simple "ok/not ok" run through Test::Harness, but there are a few special considerations. There are three ways to write a test in the core. Test::More, t/test.pl and ad hoc C<print $test ? "ok 42\n" : "not ok 42\n">. The decision of which to use depends on what part of the test suite you're working on. This is a measure to prevent a high-level failure (such as Config.pm breaking) from causing basic functionality tests to fail. =over 4 =item t/base t/comp Since we don't know if require works, or even subroutines, use ad hoc tests for these two. Step carefully to avoid using the feature being tested. =item t/cmd t/run t/io t/op Now that basic require() and subroutines are tested, you can use the t/test.pl library which emulates the important features of Test::More while using a minimum of core features. You can also conditionally use certain libraries like Config, but be sure to skip the test gracefully if it's not there. =item t/lib ext lib Now that the core of Perl is tested, Test::More can be used. You can also use the full suite of core modules in the tests. =back When you say "make test" Perl uses the F<t/TEST> program to run the test suite (except under Win32 where it uses F<t/harness> instead.) All tests are run from the F<t/> directory, B<not> the directory which contains the test. This causes some problems with the tests in F<lib/>, so here's some opportunity for some patching. You must be triply conscious of cross-platform concerns. This usually boils down to using File::Spec and avoiding things like C<fork()> and C<system()> unless absolutely necessary. =head2 Special Make Test Targets There are various special make targets that can be used to test Perl slightly differently than the standard "test" target. Not all them are expected to give a 100% success rate. Many of them have several aliases, and many of them are not available on certain operating systems. =over 4 =item coretest Run F<perl> on all core tests (F<t/*> and F<lib/[a-z]*> pragma tests). (Not available on Win32) =item test.deparse Run all the tests through B::Deparse. Not all tests will succeed. (Not available on Win32) =item test.taintwarn Run all tests with the B<-t> command-line switch. Not all tests are expected to succeed (until they're specifically fixed, of course). (Not available on Win32) =item minitest Run F<miniperl> on F<t/base>, F<t/comp>, F<t/cmd>, F<t/run>, F<t/io>, F<t/op>, F<t/uni> and F<t/mro> tests. =item test.valgrind check.valgrind utest.valgrind ucheck.valgrind (Only in Linux) Run all the tests using the memory leak + naughty memory access tool "valgrind". The log files will be named F<testname.valgrind>. =item test.third check.third utest.third ucheck.third (Only in Tru64) Run all the tests using the memory leak + naughty memory access tool "Third Degree". The log files will be named F<perl.3log.testname>. =item test.torture torturetest Run all the usual tests and some extra tests. As of Perl 5.8.0 the only extra tests are Abigail's JAPHs, F<t/japh/abigail.t>. You can also run the torture test with F<t/harness> by giving C<-torture> argument to F<t/harness>. =item utest ucheck test.utf8 check.utf8 Run all the tests with -Mutf8. Not all tests will succeed. (Not available on Win32) =item minitest.utf16 test.utf16 Runs the tests with UTF-16 encoded scripts, encoded with different versions of this encoding. C<make utest.utf16> runs the test suite with a combination of C<-utf8> and C<-utf16> arguments to F<t/TEST>. (Not available on Win32) =item test_harness Run the test suite with the F<t/harness> controlling program, instead of F<t/TEST>. F<t/harness> is more sophisticated, and uses the L<Test::Harness> module, thus using this test target supposes that perl mostly works. The main advantage for our purposes is that it prints a detailed summary of failed tests at the end. Also, unlike F<t/TEST>, it doesn't redirect stderr to stdout. Note that under Win32 F<t/harness> is always used instead of F<t/TEST>, so there is no special "test_harness" target. Under Win32's "test" target you may use the TEST_SWITCHES and TEST_FILES environment variables to control the behaviour of F<t/harness>. This means you can say nmake test TEST_FILES="op/*.t" nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t" =item test-notty test_notty Sets PERL_SKIP_TTY_TEST to true before running normal test. =back =head2 Running tests by hand You can run part of the test suite by hand by using one the following commands from the F<t/> directory : ./perl -I../lib TEST list-of-.t-files or ./perl -I../lib harness list-of-.t-files (if you don't specify test scripts, the whole test suite will be run.) =head3 Using t/harness for testing If you use C<harness> for testing you have several command line options available to you. The arguments are as follows, and are in the order that they must appear if used together. harness -v -torture -re=pattern LIST OF FILES TO TEST harness -v -torture -re LIST OF PATTERNS TO MATCH If C<LIST OF FILES TO TEST> is omitted the file list is obtained from the manifest. The file list may include shell wildcards which will be expanded out. =over 4 =item -v Run the tests under verbose mode so you can see what tests were run, and debug output. =item -torture Run the torture tests as well as the normal set. =item -re=PATTERN Filter the file list so that all the test files run match PATTERN. Note that this form is distinct from the B<-re LIST OF PATTERNS> form below in that it allows the file list to be provided as well. =item -re LIST OF PATTERNS Filter the file list so that all the test files run match /(LIST|OF|PATTERNS)/. Note that with this form the patterns are joined by '|' and you cannot supply a list of files, instead the test files are obtained from the MANIFEST. =back You can run an individual test by a command similar to ./perl -I../lib patho/to/foo.t except that the harnesses set up some environment variables that may affect the execution of the test : =over 4 =item PERL_CORE=1 indicates that we're running this test part of the perl core test suite. This is useful for modules that have a dual life on CPAN. =item PERL_DESTRUCT_LEVEL=2 is set to 2 if it isn't set already (see L</PERL_DESTRUCT_LEVEL>) =item PERL (used only by F<t/TEST>) if set, overrides the path to the perl executable that should be used to run the tests (the default being F<./perl>). =item PERL_SKIP_TTY_TEST if set, tells to skip the tests that need a terminal. It's actually set automatically by the Makefile, but can also be forced artificially by running 'make test_notty'. =back =head3 Other environment variables that may influence tests =over 4 =item PERL_TEST_Net_Ping Setting this variable runs all the Net::Ping modules tests, otherwise some tests that interact with the outside world are skipped. See L<perl58delta>. =item PERL_TEST_NOVREXX Setting this variable skips the vrexx.t tests for OS2::REXX. =item PERL_TEST_NUMCONVERTS This sets a variable in op/numconvert.t. =back See also the documentation for the Test and Test::Harness modules, for more environment variables that affect testing. =head2 Common problems when patching Perl source code Perl source plays by ANSI C89 rules: no C99 (or C++) extensions. In some cases we have to take pre-ANSI requirements into consideration. You don't care about some particular platform having broken Perl? I hear there is still a strong demand for J2EE programmers. =head2 Perl environment problems =over 4 =item * Not compiling with threading Compiling with threading (-Duseithreads) completely rewrites the function prototypes of Perl. You better try your changes with that. Related to this is the difference between "Perl_-less" and "Perl_-ly" APIs, for example: Perl_sv_setiv(aTHX_ ...); sv_setiv(...); The first one explicitly passes in the context, which is needed for e.g. threaded builds. The second one does that implicitly; do not get them mixed. If you are not passing in a aTHX_, you will need to do a dTHX (or a dVAR) as the first thing in the function. See L<perlguts/"How multiple interpreters and concurrency are supported"> for further discussion about context. =item * Not compiling with -DDEBUGGING The DEBUGGING define exposes more code to the compiler, therefore more ways for things to go wrong. You should try it. =item * Introducing (non-read-only) globals Do not introduce any modifiable globals, truly global or file static. They are bad form and complicate multithreading and other forms of concurrency. The right way is to introduce them as new interpreter variables, see F<intrpvar.h> (at the very end for binary compatibility). Introducing read-only (const) globals is okay, as long as you verify with e.g. C<nm libperl.a|egrep -v ' [TURtr] '> (if your C<nm> has BSD-style output) that the data you added really is read-only. (If it is, it shouldn't show up in the output of that command.) If you want to have static strings, make them constant: static const char etc[] = "..."; If you want to have arrays of constant strings, note carefully the right combination of C<const>s: static const char * const yippee[] = {"hi", "ho", "silver"}; There is a way to completely hide any modifiable globals (they are all moved to heap), the compilation setting C<-DPERL_GLOBAL_STRUCT_PRIVATE>. It is not normally used, but can be used for testing, read more about it in L<perlguts/"Background and PERL_IMPLICIT_CONTEXT">. =item * Not exporting your new function Some platforms (Win32, AIX, VMS, OS/2, to name a few) require any function that is part of the public API (the shared Perl library) to be explicitly marked as exported. See the discussion about F<embed.pl> in L<perlguts>. =item * Exporting your new function The new shiny result of either genuine new functionality or your arduous refactoring is now ready and correctly exported. So what could possibly go wrong? Maybe simply that your function did not need to be exported in the first place. Perl has a long and not so glorious history of exporting functions that it should not have. If the function is used only inside one source code file, make it static. See the discussion about F<embed.pl> in L<perlguts>. If the function is used across several files, but intended only for Perl's internal use (and this should be the common case), do not export it to the public API. See the discussion about F<embed.pl> in L<perlguts>. =back =head2 Portability problems The following are common causes of compilation and/or execution failures, not common to Perl as such. The C FAQ is good bedtime reading. Please test your changes with as many C compilers and platforms as possible -- we will, anyway, and it's nice to save oneself from public embarrassment. If using gcc, you can add the C<-std=c89> option which will hopefully catch most of these unportabilities. (However it might also catch incompatibilities in your system's header files.) Use the Configure C<-Dgccansipedantic> flag to enable the gcc C<-ansi -pedantic> flags which enforce stricter ANSI rules. If using the C<gcc -Wall> note that not all the possible warnings (like C<-Wunitialized>) are given unless you also compile with C<-O>. Note that if using gcc, starting from Perl 5.9.5 the Perl core source code files (the ones at the top level of the source code distribution, but not e.g. the extensions under ext/) are automatically compiled with as many as possible of the C<-std=c89>, C<-ansi>, C<-pedantic>, and a selection of C<-W> flags (see cflags.SH). Also study L<perlport> carefully to avoid any bad assumptions about the operating system, filesystems, and so forth. You may once in a while try a "make microperl" to see whether we can still compile Perl with just the bare minimum of interfaces. (See README.micro.) Do not assume an operating system indicates a certain compiler. =over 4 =item * Casting pointers to integers or casting integers to pointers void castaway(U8* p) { IV i = p; or void castaway(U8* p) { IV i = (IV)p; Both are bad, and broken, and unportable. Use the PTR2IV() macro that does it right. (Likewise, there are PTR2UV(), PTR2NV(), INT2PTR(), and NUM2PTR().) =item * Casting between data function pointers and data pointers Technically speaking casting between function pointers and data pointers is unportable and undefined, but practically speaking it seems to work, but you should use the FPTR2DPTR() and DPTR2FPTR() macros. Sometimes you can also play games with unions. =item * Assuming sizeof(int) == sizeof(long) There are platforms where longs are 64 bits, and platforms where ints are 64 bits, and while we are out to shock you, even platforms where shorts are 64 bits. This is all legal according to the C standard. (In other words, "long long" is not a portable way to specify 64 bits, and "long long" is not even guaranteed to be any wider than "long".) Instead, use the definitions IV, UV, IVSIZE, I32SIZE, and so forth. Avoid things like I32 because they are B<not> guaranteed to be I<exactly> 32 bits, they are I<at least> 32 bits, nor are they guaranteed to be B<int> or B<long>. If you really explicitly need 64-bit variables, use I64 and U64, but only if guarded by HAS_QUAD. =item * Assuming one can dereference any type of pointer for any type of data char *p = ...; long pony = *p; /* BAD */ Many platforms, quite rightly so, will give you a core dump instead of a pony if the p happens not be correctly aligned. =item * Lvalue casts (int)*p = ...; /* BAD */ Simply not portable. Get your lvalue to be of the right type, or maybe use temporary variables, or dirty tricks with unions. =item * Assume B<anything> about structs (especially the ones you don't control, like the ones coming from the system headers) =over 8 =item * That a certain field exists in a struct =item * That no other fields exist besides the ones you know of =item * That a field is of certain signedness, sizeof, or type =item * That the fields are in a certain order =over 8 =item * While C guarantees the ordering specified in the struct definition, between different platforms the definitions might differ =back =item * That the sizeof(struct) or the alignments are the same everywhere =over 8 =item * There might be padding bytes between the fields to align the fields - the bytes can be anything =item * Structs are required to be aligned to the maximum alignment required by the fields - which for native types is for usually equivalent to sizeof() of the field =back =back =item * Assuming the character set is ASCIIish Perl can compile and run under EBCDIC platforms. See L<perlebcdic>. This is transparent for the most part, but because the character sets differ, you shouldn't use numeric (decimal, octal, nor hex) constants to refer to characters. You can safely say 'A', but not 0x41. You can safely say '\n', but not \012. If a character doesn't have a trivial input form, you can create a #define for it in both C<utfebcdic.h> and C<utf8.h>, so that it resolves to different values depending on the character set being used. (There are three different EBCDIC character sets defined in C<utfebcdic.h>, so it might be best to insert the #define three times in that file.) Also, the range 'A' - 'Z' in ASCII is an unbroken sequence of 26 upper case alphabetic characters. That is not true in EBCDIC. Nor for 'a' to 'z'. But '0' - '9' is an unbroken range in both systems. Don't assume anything about other ranges. Many of the comments in the existing code ignore the possibility of EBCDIC, and may be wrong therefore, even if the code works. This is actually a tribute to the successful transparent insertion of being able to handle EBCDIC without having to change pre-existing code. UTF-8 and UTF-EBCDIC are two different encodings used to represent Unicode code points as sequences of bytes. Macros with the same names (but different definitions) in C<utf8.h> and C<utfebcdic.h> are used to allow the calling code to think that there is only one such encoding. This is almost always referred to as C<utf8>, but it means the EBCDIC version as well. Again, comments in the code may well be wrong even if the code itself is right. For example, the concept of C<invariant characters> differs between ASCII and EBCDIC. On ASCII platforms, only characters that do not have the high-order bit set (i.e. whose ordinals are strict ASCII, 0 - 127) are invariant, and the documentation and comments in the code may assume that, often referring to something like, say, C<hibit>. The situation differs and is not so simple on EBCDIC machines, but as long as the code itself uses the C<NATIVE_IS_INVARIANT()> macro appropriately, it works, even if the comments are wrong. =item * Assuming the character set is just ASCII ASCII is a 7 bit encoding, but bytes have 8 bits in them. The 128 extra characters have different meanings depending on the locale. Absent a locale, currently these extra characters are generally considered to be unassigned, and this has presented some problems. This is scheduled to be changed in 5.12 so that these characters will be considered to be Latin-1 (ISO-8859-1). =item * Mixing #define and #ifdef #define BURGLE(x) ... \ #ifdef BURGLE_OLD_STYLE /* BAD */ ... do it the old way ... \ #else ... do it the new way ... \ #endif You cannot portably "stack" cpp directives. For example in the above you need two separate BURGLE() #defines, one for each #ifdef branch. =item * Adding non-comment stuff after #endif or #else #ifdef SNOSH ... #else !SNOSH /* BAD */ ... #endif SNOSH /* BAD */ The #endif and #else cannot portably have anything non-comment after them. If you want to document what is going (which is a good idea especially if the branches are long), use (C) comments: #ifdef SNOSH ... #else /* !SNOSH */ ... #endif /* SNOSH */ The gcc option C<-Wendif-labels> warns about the bad variant (by default on starting from Perl 5.9.4). =item * Having a comma after the last element of an enum list enum color { CERULEAN, CHARTREUSE, CINNABAR, /* BAD */ }; is not portable. Leave out the last comma. Also note that whether enums are implicitly morphable to ints varies between compilers, you might need to (int). =item * Using //-comments // This function bamfoodles the zorklator. /* BAD */ That is C99 or C++. Perl is C89. Using the //-comments is silently allowed by many C compilers but cranking up the ANSI C89 strictness (which we like to do) causes the compilation to fail. =item * Mixing declarations and code void zorklator() { int n = 3; set_zorkmids(n); /* BAD */ int q = 4; That is C99 or C++. Some C compilers allow that, but you shouldn't. The gcc option C<-Wdeclaration-after-statements> scans for such problems (by default on starting from Perl 5.9.4). =item * Introducing variables inside for() for(int i = ...; ...; ...) { /* BAD */ That is C99 or C++. While it would indeed be awfully nice to have that also in C89, to limit the scope of the loop variable, alas, we cannot. =item * Mixing signed char pointers with unsigned char pointers int foo(char *s) { ... } ... unsigned char *t = ...; /* Or U8* t = ... */ foo(t); /* BAD */ While this is legal practice, it is certainly dubious, and downright fatal in at least one platform: for example VMS cc considers this a fatal error. One cause for people often making this mistake is that a "naked char" and therefore dereferencing a "naked char pointer" have an undefined signedness: it depends on the compiler and the flags of the compiler and the underlying platform whether the result is signed or unsigned. For this very same reason using a 'char' as an array index is bad. =item * Macros that have string constants and their arguments as substrings of the string constants #define FOO(n) printf("number = %d\n", n) /* BAD */ FOO(10); Pre-ANSI semantics for that was equivalent to printf("10umber = %d\10"); which is probably not what you were expecting. Unfortunately at least one reasonably common and modern C compiler does "real backward compatibility" here, in AIX that is what still happens even though the rest of the AIX compiler is very happily C89. =item * Using printf formats for non-basic C types IV i = ...; printf("i = %d\n", i); /* BAD */ While this might by accident work in some platform (where IV happens to be an C<int>), in general it cannot. IV might be something larger. Even worse the situation is with more specific types (defined by Perl's configuration step in F<config.h>): Uid_t who = ...; printf("who = %d\n", who); /* BAD */ The problem here is that Uid_t might be not only not C<int>-wide but it might also be unsigned, in which case large uids would be printed as negative values. There is no simple solution to this because of printf()'s limited intelligence, but for many types the right format is available as with either 'f' or '_f' suffix, for example: IVdf /* IV in decimal */ UVxf /* UV is hexadecimal */ printf("i = %"IVdf"\n", i); /* The IVdf is a string constant. */ Uid_t_f /* Uid_t in decimal */ printf("who = %"Uid_t_f"\n", who); Or you can try casting to a "wide enough" type: printf("i = %"IVdf"\n", (IV)something_very_small_and_signed); Also remember that the C<%p> format really does require a void pointer: U8* p = ...; printf("p = %p\n", (void*)p); The gcc option C<-Wformat> scans for such problems. =item * Blindly using variadic macros gcc has had them for a while with its own syntax, and C99 brought them with a standardized syntax. Don't use the former, and use the latter only if the HAS_C99_VARIADIC_MACROS is defined. =item * Blindly passing va_list Not all platforms support passing va_list to further varargs (stdarg) functions. The right thing to do is to copy the va_list using the Perl_va_copy() if the NEED_VA_COPY is defined. =item * Using gcc statement expressions val = ({...;...;...}); /* BAD */ While a nice extension, it's not portable. The Perl code does admittedly use them if available to gain some extra speed (essentially as a funky form of inlining), but you shouldn't. =item * Binding together several statements in a macro Use the macros STMT_START and STMT_END. STMT_START { ... } STMT_END =item * Testing for operating systems or versions when should be testing for features #ifdef __FOONIX__ /* BAD */ foo = quux(); #endif Unless you know with 100% certainty that quux() is only ever available for the "Foonix" operating system B<and> that is available B<and> correctly working for B<all> past, present, B<and> future versions of "Foonix", the above is very wrong. This is more correct (though still not perfect, because the below is a compile-time check): #ifdef HAS_QUUX foo = quux(); #endif How does the HAS_QUUX become defined where it needs to be? Well, if Foonix happens to be UNIXy enough to be able to run the Configure script, and Configure has been taught about detecting and testing quux(), the HAS_QUUX will be correctly defined. In other platforms, the corresponding configuration step will hopefully do the same. In a pinch, if you cannot wait for Configure to be educated, or if you have a good hunch of where quux() might be available, you can temporarily try the following: #if (defined(__FOONIX__) || defined(__BARNIX__)) # define HAS_QUUX #endif ... #ifdef HAS_QUUX foo = quux(); #endif But in any case, try to keep the features and operating systems separate. =back =head2 Problematic System Interfaces =over 4 =item * malloc(0), realloc(0), calloc(0, 0) are non-portable. To be portable allocate at least one byte. (In general you should rarely need to work at this low level, but instead use the various malloc wrappers.) =item * snprintf() - the return type is unportable. Use my_snprintf() instead. =back =head2 Security problems Last but not least, here are various tips for safer coding. =over 4 =item * Do not use gets() Or we will publicly ridicule you. Seriously. =item * Do not use strcpy() or strcat() or strncpy() or strncat() Use my_strlcpy() and my_strlcat() instead: they either use the native implementation, or Perl's own implementation (borrowed from the public domain implementation of INN). =item * Do not use sprintf() or vsprintf() If you really want just plain byte strings, use my_snprintf() and my_vsnprintf() instead, which will try to use snprintf() and vsnprintf() if those safer APIs are available. If you want something fancier than a plain byte string, use SVs and Perl_sv_catpvf(). =back =head1 EXTERNAL TOOLS FOR DEBUGGING PERL Sometimes it helps to use external tools while debugging and testing Perl. This section tries to guide you through using some common testing and debugging tools with Perl. This is meant as a guide to interfacing these tools with Perl, not as any kind of guide to the use of the tools themselves. B<NOTE 1>: Running under memory debuggers such as Purify, valgrind, or Third Degree greatly slows down the execution: seconds become minutes, minutes become hours. For example as of Perl 5.8.1, the ext/Encode/t/Unicode.t takes extraordinarily long to complete under e.g. Purify, Third Degree, and valgrind. Under valgrind it takes more than six hours, even on a snappy computer-- the said test must be doing something that is quite unfriendly for memory debuggers. If you don't feel like waiting, that you can simply kill away the perl process. B<NOTE 2>: To minimize the number of memory leak false alarms (see L</PERL_DESTRUCT_LEVEL> for more information), you have to have environment variable PERL_DESTRUCT_LEVEL set to 2. The F<TEST> and harness scripts do that automatically. But if you are running some of the tests manually-- for csh-like shells: setenv PERL_DESTRUCT_LEVEL 2 and for Bourne-type shells: PERL_DESTRUCT_LEVEL=2 export PERL_DESTRUCT_LEVEL or in UNIXy environments you can also use the C<env> command: env PERL_DESTRUCT_LEVEL=2 valgrind ./perl -Ilib ... B<NOTE 3>: There are known memory leaks when there are compile-time errors within eval or require, seeing C<S_doeval> in the call stack is a good sign of these. Fixing these leaks is non-trivial, unfortunately, but they must be fixed eventually. B<NOTE 4>: L<DynaLoader> will not clean up after itself completely unless Perl is built with the Configure option C<-Accflags=-DDL_UNLOAD_ALL_AT_EXIT>. =head2 Rational Software's Purify Purify is a commercial tool that is helpful in identifying memory overruns, wild pointers, memory leaks and other such badness. Perl must be compiled in a specific way for optimal testing with Purify. Purify is available under Windows NT, Solaris, HP-UX, SGI, and Siemens Unix. =head2 Purify on Unix On Unix, Purify creates a new Perl binary. To get the most benefit out of Purify, you should create the perl to Purify using: sh Configure -Accflags=-DPURIFY -Doptimize='-g' \ -Uusemymalloc -Dusemultiplicity where these arguments mean: =over 4 =item -Accflags=-DPURIFY Disables Perl's arena memory allocation functions, as well as forcing use of memory allocation functions derived from the system malloc. =item -Doptimize='-g' Adds debugging information so that you see the exact source statements where the problem occurs. Without this flag, all you will see is the source filename of where the error occurred. =item -Uusemymalloc Disable Perl's malloc so that Purify can more closely monitor allocations and leaks. Using Perl's malloc will make Purify report most leaks in the "potential" leaks category. =item -Dusemultiplicity Enabling the multiplicity option allows perl to clean up thoroughly when the interpreter shuts down, which reduces the number of bogus leak reports from Purify. =back Once you've compiled a perl suitable for Purify'ing, then you can just: make pureperl which creates a binary named 'pureperl' that has been Purify'ed. This binary is used in place of the standard 'perl' binary when you want to debug Perl memory problems. As an example, to show any memory leaks produced during the standard Perl testset you would create and run the Purify'ed perl as: make pureperl cd t ../pureperl -I../lib harness which would run Perl on test.pl and report any memory problems. Purify outputs messages in "Viewer" windows by default. If you don't have a windowing environment or if you simply want the Purify output to unobtrusively go to a log file instead of to the interactive window, use these following options to output to the log file "perl.log": setenv PURIFYOPTIONS "-chain-length=25 -windows=no \ -log-file=perl.log -append-logfile=yes" If you plan to use the "Viewer" windows, then you only need this option: setenv PURIFYOPTIONS "-chain-length=25" In Bourne-type shells: PURIFYOPTIONS="..." export PURIFYOPTIONS or if you have the "env" utility: env PURIFYOPTIONS="..." ../pureperl ... =head2 Purify on NT Purify on Windows NT instruments the Perl binary 'perl.exe' on the fly. There are several options in the makefile you should change to get the most use out of Purify: =over 4 =item DEFINES You should add -DPURIFY to the DEFINES line so the DEFINES line looks something like: DEFINES = -DWIN32 -D_CONSOLE -DNO_STRICT $(CRYPT_FLAG) -DPURIFY=1 to disable Perl's arena memory allocation functions, as well as to force use of memory allocation functions derived from the system malloc. =item USE_MULTI = define Enabling the multiplicity option allows perl to clean up thoroughly when the interpreter shuts down, which reduces the number of bogus leak reports from Purify. =item #PERL_MALLOC = define Disable Perl's malloc so that Purify can more closely monitor allocations and leaks. Using Perl's malloc will make Purify report most leaks in the "potential" leaks category. =item CFG = Debug Adds debugging information so that you see the exact source statements where the problem occurs. Without this flag, all you will see is the source filename of where the error occurred. =back As an example, to show any memory leaks produced during the standard Perl testset you would create and run Purify as: cd win32 make cd ../t purify ../perl -I../lib harness which would instrument Perl in memory, run Perl on test.pl, then finally report any memory problems. =head2 valgrind The excellent valgrind tool can be used to find out both memory leaks and illegal memory accesses. As of version 3.3.0, Valgrind only supports Linux on x86, x86-64 and PowerPC. The special "test.valgrind" target can be used to run the tests under valgrind. Found errors and memory leaks are logged in files named F<testfile.valgrind>. Valgrind also provides a cachegrind tool, invoked on perl as: VG_OPTS=--tool=cachegrind make test.valgrind As system libraries (most notably glibc) are also triggering errors, valgrind allows to suppress such errors using suppression files. The default suppression file that comes with valgrind already catches a lot of them. Some additional suppressions are defined in F<t/perl.supp>. To get valgrind and for more information see http://developer.kde.org/~sewardj/ =head2 Compaq's/Digital's/HP's Third Degree Third Degree is a tool for memory leak detection and memory access checks. It is one of the many tools in the ATOM toolkit. The toolkit is only available on Tru64 (formerly known as Digital UNIX formerly known as DEC OSF/1). When building Perl, you must first run Configure with -Doptimize=-g and -Uusemymalloc flags, after that you can use the make targets "perl.third" and "test.third". (What is required is that Perl must be compiled using the C<-g> flag, you may need to re-Configure.) The short story is that with "atom" you can instrument the Perl executable to create a new executable called F<perl.third>. When the instrumented executable is run, it creates a log of dubious memory traffic in file called F<perl.3log>. See the manual pages of atom and third for more information. The most extensive Third Degree documentation is available in the Compaq "Tru64 UNIX Programmer's Guide", chapter "Debugging Programs with Third Degree". The "test.third" leaves a lot of files named F<foo_bar.3log> in the t/ subdirectory. There is a problem with these files: Third Degree is so effective that it finds problems also in the system libraries. Therefore you should used the Porting/thirdclean script to cleanup the F<*.3log> files. There are also leaks that for given certain definition of a leak, aren't. See L</PERL_DESTRUCT_LEVEL> for more information. =head2 PERL_DESTRUCT_LEVEL If you want to run any of the tests yourself manually using e.g. valgrind, or the pureperl or perl.third executables, please note that by default perl B<does not> explicitly cleanup all the memory it has allocated (such as global memory arenas) but instead lets the exit() of the whole program "take care" of such allocations, also known as "global destruction of objects". There is a way to tell perl to do complete cleanup: set the environment variable PERL_DESTRUCT_LEVEL to a non-zero value. The t/TEST wrapper does set this to 2, and this is what you need to do too, if you don't want to see the "global leaks": For example, for "third-degreed" Perl: env PERL_DESTRUCT_LEVEL=2 ./perl.third -Ilib t/foo/bar.t (Note: the mod_perl apache module uses also this environment variable for its own purposes and extended its semantics. Refer to the mod_perl documentation for more information. Also, spawned threads do the equivalent of setting this variable to the value 1.) If, at the end of a run you get the message I<N scalars leaked>, you can recompile with C<-DDEBUG_LEAKING_SCALARS>, which will cause the addresses of all those leaked SVs to be dumped along with details as to where each SV was originally allocated. This information is also displayed by Devel::Peek. Note that the extra details recorded with each SV increases memory usage, so it shouldn't be used in production environments. It also converts C<new_SV()> from a macro into a real function, so you can use your favourite debugger to discover where those pesky SVs were allocated. If you see that you're leaking memory at runtime, but neither valgrind nor C<-DDEBUG_LEAKING_SCALARS> will find anything, you're probably leaking SVs that are still reachable and will be properly cleaned up during destruction of the interpreter. In such cases, using the C<-Dm> switch can point you to the source of the leak. If the executable was built with C<-DDEBUG_LEAKING_SCALARS>, C<-Dm> will output SV allocations in addition to memory allocations. Each SV allocation has a distinct serial number that will be written on creation and destruction of the SV. So if you're executing the leaking code in a loop, you need to look for SVs that are created, but never destroyed between each cycle. If such an SV is found, set a conditional breakpoint within C<new_SV()> and make it break only when C<PL_sv_serial> is equal to the serial number of the leaking SV. Then you will catch the interpreter in exactly the state where the leaking SV is allocated, which is sufficient in many cases to find the source of the leak. As C<-Dm> is using the PerlIO layer for output, it will by itself allocate quite a bunch of SVs, which are hidden to avoid recursion. You can bypass the PerlIO layer if you use the SV logging provided by C<-DPERL_MEM_LOG> instead. =head2 PERL_MEM_LOG If compiled with C<-DPERL_MEM_LOG>, both memory and SV allocations go through logging functions, which is handy for breakpoint setting. Unless C<-DPERL_MEM_LOG_NOIMPL> is also compiled, the logging functions read $ENV{PERL_MEM_LOG} to determine whether to log the event, and if so how: $ENV{PERL_MEM_LOG} =~ /m/ Log all memory ops $ENV{PERL_MEM_LOG} =~ /s/ Log all SV ops $ENV{PERL_MEM_LOG} =~ /t/ include timestamp in Log $ENV{PERL_MEM_LOG} =~ /^(\d+)/ write to FD given (default is 2) Memory logging is somewhat similar to C<-Dm> but is independent of C<-DDEBUGGING>, and at a higher level; all uses of Newx(), Renew(), and Safefree() are logged with the caller's source code file and line number (and C function name, if supported by the C compiler). In contrast, C<-Dm> is directly at the point of C<malloc()>. SV logging is similar. Since the logging doesn't use PerlIO, all SV allocations are logged and no extra SV allocations are introduced by enabling the logging. If compiled with C<-DDEBUG_LEAKING_SCALARS>, the serial number for each SV allocation is also logged. =head2 Profiling Depending on your platform there are various of profiling Perl. There are two commonly used techniques of profiling executables: I<statistical time-sampling> and I<basic-block counting>. The first method takes periodically samples of the CPU program counter, and since the program counter can be correlated with the code generated for functions, we get a statistical view of in which functions the program is spending its time. The caveats are that very small/fast functions have lower probability of showing up in the profile, and that periodically interrupting the program (this is usually done rather frequently, in the scale of milliseconds) imposes an additional overhead that may skew the results. The first problem can be alleviated by running the code for longer (in general this is a good idea for profiling), the second problem is usually kept in guard by the profiling tools themselves. The second method divides up the generated code into I<basic blocks>. Basic blocks are sections of code that are entered only in the beginning and exited only at the end. For example, a conditional jump starts a basic block. Basic block profiling usually works by I<instrumenting> the code by adding I<enter basic block #nnnn> book-keeping code to the generated code. During the execution of the code the basic block counters are then updated appropriately. The caveat is that the added extra code can skew the results: again, the profiling tools usually try to factor their own effects out of the results. =head2 Gprof Profiling gprof is a profiling tool available in many UNIX platforms, it uses F<statistical time-sampling>. You can build a profiled version of perl called "perl.gprof" by invoking the make target "perl.gprof" (What is required is that Perl must be compiled using the C<-pg> flag, you may need to re-Configure). Running the profiled version of Perl will create an output file called F<gmon.out> is created which contains the profiling data collected during the execution. The gprof tool can then display the collected data in various ways. Usually gprof understands the following options: =over 4 =item -a Suppress statically defined functions from the profile. =item -b Suppress the verbose descriptions in the profile. =item -e routine Exclude the given routine and its descendants from the profile. =item -f routine Display only the given routine and its descendants in the profile. =item -s Generate a summary file called F<gmon.sum> which then may be given to subsequent gprof runs to accumulate data over several runs. =item -z Display routines that have zero usage. =back For more detailed explanation of the available commands and output formats, see your own local documentation of gprof. quick hint: $ sh Configure -des -Dusedevel -Doptimize='-g' -Accflags='-pg' -Aldflags='-pg' && make $ ./perl someprog # creates gmon.out in current directory $ gprof perl > out $ view out =head2 GCC gcov Profiling Starting from GCC 3.0 I<basic block profiling> is officially available for the GNU CC. You can build a profiled version of perl called F<perl.gcov> by invoking the make target "perl.gcov" (what is required that Perl must be compiled using gcc with the flags C<-fprofile-arcs -ftest-coverage>, you may need to re-Configure). Running the profiled version of Perl will cause profile output to be generated. For each source file an accompanying ".da" file will be created. To display the results you use the "gcov" utility (which should be installed if you have gcc 3.0 or newer installed). F<gcov> is run on source code files, like this gcov sv.c which will cause F<sv.c.gcov> to be created. The F<.gcov> files contain the source code annotated with relative frequencies of execution indicated by "#" markers. Useful options of F<gcov> include C<-b> which will summarise the basic block, branch, and function call coverage, and C<-c> which instead of relative frequencies will use the actual counts. For more information on the use of F<gcov> and basic block profiling with gcc, see the latest GNU CC manual, as of GCC 3.0 see http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc.html and its section titled "8. gcov: a Test Coverage Program" http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_8.html#SEC132 quick hint: $ sh Configure -des -Doptimize='-g' -Accflags='-fprofile-arcs -ftest-coverage' \ -Aldflags='-fprofile-arcs -ftest-coverage' && make perl.gcov $ rm -f regexec.c.gcov regexec.gcda $ ./perl.gcov $ gcov regexec.c $ view regexec.c.gcov =head2 Pixie Profiling Pixie is a profiling tool available on IRIX and Tru64 (aka Digital UNIX aka DEC OSF/1) platforms. Pixie does its profiling using I<basic-block counting>. You can build a profiled version of perl called F<perl.pixie> by invoking the make target "perl.pixie" (what is required is that Perl must be compiled using the C<-g> flag, you may need to re-Configure). In Tru64 a file called F<perl.Addrs> will also be silently created, this file contains the addresses of the basic blocks. Running the profiled version of Perl will create a new file called "perl.Counts" which contains the counts for the basic block for that particular program execution. To display the results you use the F<prof> utility. The exact incantation depends on your operating system, "prof perl.Counts" in IRIX, and "prof -pixie -all -L. perl" in Tru64. In IRIX the following prof options are available: =over 4 =item -h Reports the most heavily used lines in descending order of use. Useful for finding the hotspot lines. =item -l Groups lines by procedure, with procedures sorted in descending order of use. Within a procedure, lines are listed in source order. Useful for finding the hotspots of procedures. =back In Tru64 the following options are available: =over 4 =item -p[rocedures] Procedures sorted in descending order by the number of cycles executed in each procedure. Useful for finding the hotspot procedures. (This is the default option.) =item -h[eavy] Lines sorted in descending order by the number of cycles executed in each line. Useful for finding the hotspot lines. =item -i[nvocations] The called procedures are sorted in descending order by number of calls made to the procedures. Useful for finding the most used procedures. =item -l[ines] Grouped by procedure, sorted by cycles executed per procedure. Useful for finding the hotspots of procedures. =item -testcoverage The compiler emitted code for these lines, but the code was unexecuted. =item -z[ero] Unexecuted procedures. =back For further information, see your system's manual pages for pixie and prof. =head2 Miscellaneous tricks =over 4 =item * Those debugging perl with the DDD frontend over gdb may find the following useful: You can extend the data conversion shortcuts menu, so for example you can display an SV's IV value with one click, without doing any typing. To do that simply edit ~/.ddd/init file and add after: ! Display shortcuts. Ddd*gdbDisplayShortcuts: \ /t () // Convert to Bin\n\ /d () // Convert to Dec\n\ /x () // Convert to Hex\n\ /o () // Convert to Oct(\n\ the following two lines: ((XPV*) (())->sv_any )->xpv_pv // 2pvx\n\ ((XPVIV*) (())->sv_any )->xiv_iv // 2ivx so now you can do ivx and pvx lookups or you can plug there the sv_peek "conversion": Perl_sv_peek(my_perl, (SV*)()) // sv_peek (The my_perl is for threaded builds.) Just remember that every line, but the last one, should end with \n\ Alternatively edit the init file interactively via: 3rd mouse button -> New Display -> Edit Menu Note: you can define up to 20 conversion shortcuts in the gdb section. =item * If you see in a debugger a memory area mysteriously full of 0xABABABAB or 0xEFEFEFEF, you may be seeing the effect of the Poison() macros, see L<perlclib>. =item * Under ithreads the optree is read only. If you want to enforce this, to check for write accesses from buggy code, compile with C<-DPL_OP_SLAB_ALLOC> to enable the OP slab allocator and C<-DPERL_DEBUG_READONLY_OPS> to enable code that allocates op memory via C<mmap>, and sets it read-only at run time. Any write access to an op results in a C<SIGBUS> and abort. This code is intended for development only, and may not be portable even to all Unix variants. Also, it is an 80% solution, in that it isn't able to make all ops read only. Specifically it =over =item 1 Only sets read-only on all slabs of ops at C<CHECK> time, hence ops allocated later via C<require> or C<eval> will be re-write =item 2 Turns an entire slab of ops read-write if the refcount of any op in the slab needs to be decreased. =item 3 Turns an entire slab of ops read-write if any op from the slab is freed. =back It's not possible to turn the slabs to read-only after an action requiring read-write access, as either can happen during op tree building time, so there may still be legitimate write access. However, as an 80% solution it is still effective, as currently it catches a write access during the generation of F<Config.pm>, which means that we can't yet build F<perl> with this enabled. =back =head1 CONCLUSION We've had a brief look around the Perl source, how to maintain quality of the source code, an overview of the stages F<perl> goes through when it's running your code, how to use debuggers to poke at the Perl guts, and finally how to analyse the execution of Perl. We took a very simple problem and demonstrated how to solve it fully - with documentation, regression tests, and finally a patch for submission to p5p. Finally, we talked about how to use external tools to debug and test Perl. I'd now suggest you read over those references again, and then, as soon as possible, get your hands dirty. The best way to learn is by doing, so: =over 3 =item * Subscribe to perl5-porters, follow the patches and try and understand them; don't be afraid to ask if there's a portion you're not clear on - who knows, you may unearth a bug in the patch... =item * Keep up to date with the bleeding edge Perl distributions and get familiar with the changes. Try and get an idea of what areas people are working on and the changes they're making. =item * Do read the README associated with your operating system, e.g. README.aix on the IBM AIX OS. Don't hesitate to supply patches to that README if you find anything missing or changed over a new OS release. =item * Find an area of Perl that seems interesting to you, and see if you can work out how it works. Scan through the source, and step over it in the debugger. Play, poke, investigate, fiddle! You'll probably get to understand not just your chosen area but a much wider range of F<perl>'s activity as well, and probably sooner than you'd think. =back =over 3 =item I<The Road goes ever on and on, down from the door where it began.> =back If you can do these things, you've started on the long road to Perl porting. Thanks for wanting to help make Perl better - and happy hacking! =head2 Metaphoric Quotations If you recognized the quote about the Road above, you're in luck. Most software projects begin each file with a literal description of each file's purpose. Perl instead begins each with a literary allusion to that file's purpose. Like chapters in many books, all top-level Perl source files (along with a few others here and there) begin with an epigramic inscription that alludes, indirectly and metaphorically, to the material you're about to read. Quotations are taken from writings of J.R.R Tolkien pertaining to his Legendarium, almost always from I<The Lord of the Rings>. Chapters and page numbers are given using the following editions: =over 4 =item * I<The Hobbit>, by J.R.R. Tolkien. The hardcover, 70th-anniversary edition of 2007 was used, published in the UK by Harper Collins Publishers and in the US by the Houghton Mifflin Company. =item * I<The Lord of the Rings>, by J.R.R. Tolkien. The hardcover, 50th-anniversary edition of 2004 was used, published in the UK by Harper Collins Publishers and in the US by the Houghton Mifflin Company. =item * I<The Lays of Beleriand>, by J.R.R. Tolkien and published posthumously by his son and literary executor, C.J.R. Tolkien, being the 3rd of the 12 volumes in Christopher's mammoth I<History of Middle Earth>. Page numbers derive from the hardcover edition, first published in 1983 by George Allen & Unwin; no page numbers changed for the special 3-volume omnibus edition of 2002 or the various trade-paper editions, all again now by Harper Collins or Houghton Mifflin. =back Other JRRT books fair game for quotes would thus include I<The Adventures of Tom Bombadil>, I<The Silmarillion>, I<Unfinished Tales>, and I<The Tale of the Children of Hurin>, all but the first posthumously assembled by CJRT. But I<The Lord of the Rings> itself is perfectly fine and probably best to quote from, provided you can find a suitable quote there. So if you were to supply a new, complete, top-level source file to add to Perl, you should conform to this peculiar practice by yourself selecting an appropriate quotation from Tolkien, retaining the original spelling and punctuation and using the same format the rest of the quotes are in. Indirect and oblique is just fine; remember, it's a metaphor, so being meta is, after all, what it's for. =head1 AUTHOR This document was written by Nathan Torkington, and is maintained by the perl5-porters mailing list. =head1 SEE ALSO L<perlrepository>
Lh4cKg/sl4a
perl/src/pod/perlhack.pod
Perl
apache-2.0
121,410
# snmp-v2tov1.awk # nawk script - pass 1 of translation from SNMP v2 SMI to v1 SMI # mbj@erlang.ericsson.se 971114 # # Translate v2 IMPORTs to their v1 equivalents $[ = 1; # set array base to 1 $, = ' '; # set output field separator $\ = "\n"; # set output record separator line: while (<>) { chomp; # strip record separator @Fld = split(' ', $_, 9999); if (/IMPORT/) { $import = 1; $isave = 0; print $_; next line; } if (($import == 1) && ($Fld[1] eq ';')) { $import = 0; } if (($import == 1) && ($Fld[1] ne 'FROM')) { for ($i = 1; $i <= $#Fld; $i++) { $s = ',', $Fld[$i] =~ s/$s//; $imp{$i + $isave} = $Fld[$i]; } $isave = $isave + ($i - 1); next line; } if (($import == 1) && ($Fld[1] eq 'FROM')) { &print_imp($Fld[2], *imp, $isave); $isave = 0; next line; } # str is 1 if we're inside a string, and 0 otherwise. if (/\"/) { $str = 1; } if ($Fld[$#Fld] =~ /\"$/) { $str = 0; } # Just reprint all comments if (/^--/) { print $_; next line; } # Place comments around MODULE-IDENTITY if (/MODULE-IDENTITY/ && ($str == 0)) { $moduleid = 1; print '--', $_; next line; } if (($moduleid == 1) && ($Fld[1] eq '::=')) { $moduleid = 0; print '--', $_; next line; } if ($moduleid == 1) { print '--', $_; next line; } # Translate TEXTUAL-CONVENTION into an ordinary type assignement. # Place comments around body. if (/TEXTUAL-CONVENTION/ && ($str == 0)) { $textual = 1; print $Fld[1], $Fld[2]; print '--TEXTUAL-CONVENTION'; next line; } if (($textual == 1) && ($Fld[1] eq 'SYNTAX')) { $textual = 0; print "--SYNTAX\n"; for ($i = 2; $i <= $#Fld; $i++) { print $Fld[$i]; } next line; } if ($textual == 1) { $s = '--', s/$s/-- --/; print '--', $_; next line; } # Translate OBJECT-IDENTITY into an OBJECT IDENTIFIER. # Place comments around body. if (/OBJECT-IDENTITY/ && ($str == 0)) { $objid = 1; print $Fld[1], 'OBJECT IDENTIFIER'; print '--OBJECT-IDENTITY'; next line; } if (($objid == 1) && ($Fld[1] eq '::=')) { $objid = 0; print $_; next line; } if ($objid == 1) { $s = '--', s/$s/-- --/; print '--', $_; next line; } # Place comments around MODULE-COMPLIANCE if (/MODULE-COMPLIANCE/ && ($str == 0)) { $modcomp = 1; print '--', $_; next line; } if (($modcomp == 1) && ($Fld[1] eq '::=')) { $modcomp = 0; print '--', $_; next line; } if ($modcomp == 1) { $s = '--', s/$s/-- --/; print '--', $_; next line; } # Place comments around OBJECT-GROUP if (/OBJECT-GROUP/ && ($str == 0)) { $objgr = 1; print '--', $_; next line; } if (($objgr == 1) && ($Fld[1] eq '::=')) { $objgr = 0; print '--', $_; next line; } if ($objgr == 1) { $s = '--', s/$s/-- --/; print '--', $_; next line; } if (/OBJECT-GROUP/) { print 'tjolaopp'; } # Place comments around NOTIFICATION-GROUP if (/NOTIFICATION-GROUP/ && ($str == 0)) { $notgr = 1; print '--', $_; next line; } if (($notgr == 1) && ($Fld[1] eq '::=')) { $notgr = 0; print '--', $_; next line; } if ($notgr == 1) { $s = '--', s/$s/-- --/; print '--', $_; next line; } # Translate NOTIFICATION-TYPE into a TRAP-TYPE. if (/NOTIFICATION-TYPE/ && ($str == 0)) { $trap = 1; print $Fld[1], ' TRAP-TYPE'; printf ' ENTERPRISE '; $tri = 1; next line; } if (($trap == 1) && ($Fld[1] eq 'OBJECTS')) { $tra{$tri++} = $_; next line; } if (($trap == 1) && ($Fld[1] eq 'STATUS')) { next line; } if (($trap == 1) && ($Fld[1] eq '::=')) { print $Fld[3]; &pr_trap(*tra, $tri); printf ' ::= '; print $Fld[4]; $tri = 1; $trap = 0; next line; } if ($trap == 1) { $tra{$tri++} = $_; next line; } if (/UNITS/) { $s = '--', s/$s/-- --/; print '--', $_; next line; } print $_; # Print v1 IMPORT statements # Print a trap } sub print_imp { local($mib, *imp, $isave) = @_; for ($i = 1; $i <= $isave; $i++) { if ($imp{$i} eq 'Counter32') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'Gauge32') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'TimeTicks') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'Opaque') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'IpAddress') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'NetworkAddress') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'enterprises') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'private') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'experimental') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'mgmt') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'internet') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'directory') { print ' ', $imp{$i}; print ' FROM RFC1155-SMI'; } elsif ($imp{$i} eq 'DisplayString') { print ' ', $imp{$i}; print ' FROM RFC1213-MIB'; } elsif ($imp{$i} eq 'mib-2') { print ' ', $imp{$i}; print ' FROM RFC1213-MIB'; } elsif ($imp{$i} eq 'OBJECT-TYPE') { print ' ', $imp{$i}; print ' FROM RFC-1212'; } elsif ($imp{$i} eq 'Integer32') { ; } elsif ($imp{$i} eq 'MODULE-IDENTITY') { ; } elsif ($imp{$i} eq 'TEXTUAL-CONVENTION') { ; } elsif ($imp{$i} eq 'OBJECT-IDENTITY') { ; } elsif ($imp{$i} eq 'OBJECT-GROUP') { ; } elsif ($imp{$i} eq 'MODULE-COMPLIANCE') { ; } elsif ($imp{$i} eq 'NOTIFICATION-GROUP') { ; } elsif ($imp{$i} eq 'NOTIFICATION-TYPE') { print ' TRAP-TYPE'; print ' FROM RFC-1215'; } elsif ($imp{$i} eq 'DateAndTime') { print ' ', $imp{$i}; print ' FROM STANDARD-MIB'; } elsif ($imp{$i} eq 'TruthValue') { print ' ', $imp{$i}; print ' FROM STANDARD-MIB'; } elsif ($imp{$i} eq 'RowStatus') { print ' ', $imp{$i}; print ' FROM STANDARD-MIB'; } else { print ' ', $imp{$i}; print ' FROM', $mib; } } } sub pr_trap { local(*tra, $tri) = @_; for ($i = 1; $i < $tri; $i++) { print $tra{$i}; } }
racker/omnibus
source/otp_src_R14B02/lib/snmp/bin/snmp-v2tov1.pl
Perl
apache-2.0
6,616
package Run::Utax; use 5.010000; use strict; use warnings; our @ISA = qw(); our $VERSION = '0.1'; use File::Which qw(which); use File::Temp qw(tempfile); use Getopt::Long qw(GetOptionsFromArray :config pass_through); use Capture::Tiny ':all'; use Bio::SeqIO; =head2 new() This subroutine creates a new object instance of Run::Utax =cut sub new { my $class = shift @_; $class = ref($class) || $class; my $self = {}; # are there more arguments given? if yes store them in orig_argv if (@_) { $self->{_orig_argv} = \@_; } else { # if not, keep the array empty $self->{_orig_argv} = []; } bless $self, $class; return $self; } =head2 DESTROY =cut sub DESTROY { my $self = shift; $self->_closeAllHandles(); } =head2 usearchpath This setter/getter sets or returns the path for the usearch program. The path must indicate the location of a executable file to be valid. =cut sub usearchpath { my $self = shift; # is a parameter given? if (@_) { # still an argument available so set the path my $utax_path = shift; # before using the command, we want to check if it is executable unless (-x $utax_path) { die "Unable to execute the usearch file on location '$utax_path'\n"; } $self->{_utaxpath} = $utax_path; } # finally return the value return $self->{_utaxpath}; } =head2 database() This setter/getter sets or returns the path for the database file. The path must indicate the location of a existing and accessable file to be valid. =cut sub database { my $self = shift; # is a parameter given? if (@_) { # still an argument available so set the path my $database_path = shift; # check if the file exists and can be accessed unless (-e $database_path) { die "Unable to access the database file on location '$database_path'\n"; } $self->{_database} = $database_path; } # finally return the value return $self->{_database}; } =head2 taxonomy() This setter/getter sets or returns the path for the taxonomy file. The path must indicate the location of a existing and accessable file to be valid. =cut sub taxonomy { my $self = shift; # is a parameter given? if (@_) { # still an argument available so set the path my $taxonomy_path = shift; # check if the file exists and can be accessed unless (-e $taxonomy_path) { die "Unable to access the taxonomy file on location '$taxonomy_path'\n"; } $self->{_taxonomy} = $taxonomy_path; } # finally return the value return $self->{_taxonomy}; } =head2 infile() This setter/getter sets or returns the path for the infile file. The path must indicate the location of a existing and accessable file to be valid. =cut sub infile { my $self = shift; # is a parameter given? if (@_) { # still an argument available so set the path my $infile_path = shift; # check if the file exists and can be accessed unless (-e $infile_path) { die "Unable to access the infile on location '$infile_path'\n"; } $self->{_infile} = $infile_path; } # finally return the value return $self->{_infile}; } =head2 overwrite() This setter/getter sets or returns the status of overwrite flag. Allowed values are 0 for disabled and 1 for enabled overwriting. =cut sub overwrite { my $self = shift; # is a parameter given? if (@_) { # still an argument available so set the path my $overwrite = shift; # convert it into a number $overwrite = $overwrite+0; # check if the value is allowed unless ($overwrite == 0 || $overwrite == 1) { die "Allowed values for overwrite setter are 0 for disabling and 1 for enabling overwriting\n"; } $self->{_overwrite} = $overwrite; } # finally return the value return $self->{_overwrite}; } =head2 outfile() This setter/getter sets or returns the path for the outfile file. It utilizes the private method _check4_outfile to test if the files exists and in this case it dies, if the overwrite flag is not set. The path must indicate the location of a new or an existing and accessable file (if overwrite is set) to be valid. =cut sub outfile { my $self = shift; return $self->_check_4_outfile('outfile', @_); } =head2 fasta() This setter/getter sets or returns the path for the fasta file. It utilizes the private method _check4_outfile to test if the files exists and in this case it dies, if the overwrite flag is not set. The path must indicate the location of a new or an existing and accessable file (if overwrite is set) to be valid. =cut sub fasta { my $self = shift; return $self->_check_4_outfile('fasta', @_); } =head2 tsv() This setter/getter sets or returns the path for the tsv file. It utilizes the private method _check4_outfile to test if the files exists and in this case it dies, if the overwrite flag is not set. The path must indicate the location of a new or an existing and accessable file (if overwrite is set) to be valid. =cut sub tsv { my $self = shift; return $self->_check_4_outfile('tsv', @_); } =head2 run() Runs the usearch command according to the parameter settings. =cut sub run { my $self = shift @_; $self->_parse_and_check_utax(); $self->_parse_arguments(); # I need to create a temporary file for the utax output. The # requested output file is required later my ($fh, $filename) = tempfile(); # construct the run command for usearch $self->{cmd} = [ $self->usearchpath(), '-utax', $self->infile(), '-db', $self->database(), '-tt', $self->taxonomy(), '-utaxout', $filename, '-utax_rawscore', ]; printf STDERR "Command to run: '%s'\n", join(" ", @{$self->{cmd}}); # run the external program my ($stdout, $stderr, $exit) = capture { system( @{$self->{cmd}} ) }; # print status messages printf STDERR "Exit code for command was %d\n==== Captured STDOUT ====\n%s\n==== Captured STDERR ====\n%s", $exit, $stdout, $stderr; # if the exit code was not 0 we need to die # uncoverable branch true unless ($exit == 0) { # uncoverable statement die "The call of usearch8 failed!\n"; } # now we need to parse the output: # - if a tsv is requested, the file will be created # - if a fasta is requested, the file will be created # - the raw utax output is copied into the output file which will be created # open a tsv file, if requested $self->_open4writing('tsv'); $self->_open4writing('fasta'); $self->_open4writing('outfile'); # a handle for the utax output is alread present in $fh # reset the position seek($fh, 0, 0) || die "Unable to reset file position for file '$filename': $!\n"; # utax returns a different order of sequences, therefore we need to track the ID lineage pairs my %id_lineage = (); # if tsv is requested, print a header my $tsvFH = $self->{_FH_tsv}; if ($tsvFH) { print $tsvFH "#", join("\t", qw(ID kingdom phylum class order family genus species)), "\n"; } # get the output file handle my $outFH = $self->{_FH_outfile}; # loop through the original utax output while (<$fh>) { # write the raw output to the outputfile print $outFH $_; chomp($_); my @fields = split(/\t/, $_); # first field contains the id, second field the lineage, third # field a plus sign my $id = $fields[0]; my @lineage = split(/,/, $fields[1]); # workaround a undocumented utax behavior # sometimes it prints two line for an ID, but then the first line contains # * for lineage and plus sign # skip those lines next if ($fields[1] eq "*" && $fields[2] eq "*"); @lineage = map { $_ =~ /([^_]+)_{1,2}(\d+)\(([\d.]+)\)$/; {sciname => $1, taxid => $2, score => $3} } (@lineage); # print sciname and score to the tsv if ($tsvFH) { print $tsvFH join("\t", ($id, map {sprintf "%s (%s)", $_->{sciname}, $_->{score}} (@lineage))), "\n"; } # store the lineage information to the id if not already present if (exists $id_lineage{$id}) { die "utax returned the identical id ($id) twice...\n"; } $id_lineage{$id} = $fields[1]; } # last thing to do is writing the fasta file, if requested if (defined $self->{_FH_fasta}) { # we need to open the input data my $seqin = Bio::SeqIO->new( -file => $self->{_infile} ); # let Bio::SeqIO write our output file if we want it my $seqout = Bio::SeqIO->new( -format => 'fasta', -fh => $self->{_FH_fasta} ); # loop through the sequences and add the lineage infomation to # the description and write it to the output file while (my $inseq = $seqin->next_seq) { my $lin = "n.d."; unless (exists $id_lineage{$inseq->id()}) { warn "No lineage information for id: ", $inseq->id(), "\n"; } else { $lin = $id_lineage{$inseq->id()}; } $inseq->desc($inseq->desc." utax: ".$lin); $seqout->write_seq($inseq); } # done } # close all files $self->_closefile('tsv'); $self->_closefile('fasta'); $self->_closefile('outfile'); } =head1 Private subroutines =head2 _check_4_outfile This method is used by fasta/tsv/outfile. It tests if the file exists and if in that case overwrite is set. =head3 parameters First parameter ist the type of the file. This determines the attribute name. Currently supported are =over 4 =item a) outfile =item b) fasta =item c) tsv =back =cut sub _check_4_outfile { my $self = shift; # next parameter is the type my $type = shift; # the attribute has a leading _ $type = "_".$type; # is another parameter given? if (@_) { # still an argument available so set the path my $file_path = shift; # check if the file exists and can be accessed if (defined $file_path && $file_path ne "-" && -e $file_path && !($self->overwrite)) { die "Overwriting existing files is not allowed. Use option --force|--overwrite to enable that\n"; } $self->{$type} = $file_path; } # finally return the value return $self->{$type}; } =head2 _open4writing This methods checks if a given parameter is defined. If so, it tries to open the file for writing and stores the filehandle in a attribute =head3 parameters The name of the option. So far the following are supported: =over 4 =item a) outfile File for the raw utax output =item b) tsv A file which contains the utax output as tab seperated file =item c) fasta A file which contains the original sequences, but the header of the sequences are supplemented with the utax lineage for that sequence =over =cut sub _open4writing { my $self = shift; # one parameter should be given my $file = shift; # the private attribute owns a leading underscore $file = "_".$file; # the attribute for the file handle has a leading _FH my $filehandle = "_FH".$file; if ($self->{$file}) { # sometimes we want to have the output on stdout, here we can capture that if ($self->{$file} ne "-") { # create a new file my $fh; open($fh, ">", $self->{$file}) || die "Unable to open the file '$self->{$file}' for writing: $!\n"; $self->{$filehandle} = $fh; } else { # we want to write to STDOUT $self->{$filehandle} = \*STDOUT; } } return $self; } =head2 _closefile This methods closes a specified file (given by filename) and set the corresponding filehandle to undef. =cut sub _closefile { my $self = shift; # one parameter should be given my $file = shift; # the private attribute owns a leading underscore $file = "_".$file; # the attribute for the file handle has a leading _FH my $filehandle = "_FH".$file; if (defined $self->{$filehandle} && fileno $self->{$filehandle}) { close($self->{$filehandle}) || die "Unable to close the file '$self->{$file}': $!\n"; } $self->{$filehandle} = undef; return $self; } =head2 _closeAllHandles This methods closes all file handles from the file handle attributed. Should be used as part of the destructor. =cut sub _closeAllHandles { my $self = shift; # find all attributes which represents filehandles my @filehandles = grep {$_ =~ /^_FH_/} (keys %{$self}); # determine the filename attribute from the filehandle attribute and call _closefile foreach my $fh (@filehandles) { # the filename should be stored in a attribute without the leading _FH my $filename = $fh; $filename =~ s/^_FH//; $self->_closefile($filename); } return $self; } =head2 _parse_and_check_utax() This subroutine checks is the utax program is available. Therefore the user can provide the program using three different ways: =over 4 =item 1) Program usearch is available in path =item 2) Environmental variable USEARCHPATH =item 3) Parameter -usearchpath =back =cut sub _parse_and_check_utax { my $self = shift; # check if we have a usearch program available in the PATH my $utax_path = which('usearch8'); # if a environmental variable USEARCHPROGRAM is given, than use that if (exists $ENV{USEARCHPROGRAM}) { $utax_path = $ENV{USEARCHPROGRAM}; } # finally we try to parse the command line options GetOptionsFromArray($self->{_orig_argv}, 'utax|u=s' => \$utax_path ); # did we succeed in finding a usearch file? if ((! defined $utax_path) || ($utax_path eq '')) { die "Unable to find usearch program!\n"; } # now set the progam path $self->usearchpath($utax_path); return $self; } =head2 _parse_arguments() This subroutine checks is the other arguments for validity. =back =cut sub _parse_arguments { my $self = shift; # the command line arguments are stored in _argv_orig # first we want to get the parameter settings my $database = ""; # default empty, as it is required my $taxonomy = ""; # no default, as it is required my $infile = ""; # no default, as it is required my $outfile = "-"; # default is printing to STDOUT my $overwrite = 0; # default no overwriting my $tsv = undef; # default undef my $fasta = undef; # default undef my $ret = GetOptionsFromArray( $self->{_orig_argv}, ( 'database|d=s' => \$database, 'taxonomy|t=s' => \$taxonomy, 'infile|input|i=s' => \$infile, 'outfile|o=s' => \$outfile, 'force|overwrite|f' => \$overwrite, 'tsv=s' => \$tsv, 'fasta=s' => \$fasta, )); # check if required parameters are set if ($database eq "") { die "No database given!"; } if ($taxonomy eq "") { die "No taxonomy file given!"; } if ($infile eq "") { die "No infile file given!"; } # set the values using the setter $self->overwrite($overwrite); # first because it might be required for outfile $self->database($database); $self->taxonomy($taxonomy); $self->infile($infile); $self->outfile($outfile); $self->fasta($fasta); $self->tsv($tsv); } 1; __END__ =head1 NAME Run::Utax - Perl module which is utilized by the run_utax.pl script =head1 SYNOPSIS use Run::Utax; =head1 DESCRIPTION =head1 SEE ALSO =head1 AUTHOR Frank Förster, E<lt>foersterfrank@gmx.de<gt> =head1 COPYRIGHT AND LICENSE The MIT License (MIT) Copyright (c) 2009-2015 Frank Förster 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
greatfireball/Run-Utax
lib/Run/Utax.pm
Perl
mit
16,411
% MODULE g1_ops EXPORTS :- module( g1_ops, [ saturate/2 , % saturate with default depth saturate/3, % saturate with given maximum depth elem_saturate/3, inv_derivate/2, inv_derivate/3, inv_derivate1/2, most_spec_v/3, absorb/3, identify/3, g1_op/3, g1_op/4, apply_g1/2 ]). %IMPORTS :- use_module(home(lgg), [headed_lgg/3,headed_lgg/4]). :- use_module(home(kb), [get_clause/5,store_clause/4,delete_clause/1, get_example/3]). :- use_module(home(var_utils), [skolemize/3,skolemize/4,deskolemize/3]). :- use_module(home(div_utils), [neg/2, buildpar2/3,efface/3]). :- use_module(home(bu_basics), [addtolist/1,getlist/1,clear_mngr/0,assert_body/1, abs_process_proofs/2,abs_build_body/1,assert_clause/1, ident_process_proofs/2,g1_process_proofs/2,g1_build_clause/2, idev_build_clause/2,process_new_literals/2,sat_build_clause/3, assert_absorptions/2,body/3,ident_build_body/1]). :- use_module(home(show_utils), [show_bodies/0]). :- use_module(home(interpreter), [prove3/2,prove4/3]). :- use_module_if_exists(library(basics), [member/2]). % METAPREDICATES % none %*********************************************************************** %* %* module: g1_ops.pl %* %* author: B.Jung, M.Mueller, I.Stahl, B.Tausend date:12/92 %* %* changed: %* %* %* description: - g1-Operator %* Implementation of Ruediger Wirth's G1-operator for inverse %* resolution corresponding to his 1989 PhD thesis. %* - Absorption %* All clauses induced by absorption are labelled "abs" in kb %* - Rouveirol's saturation, with functions allowed as terms. %* *Saturation: Maximum depth: given as input %* default: 100 inverse resolution steps %* *elementary saturation %* - inverse derivate %* Muggleton's inverse linear derivation, i.e. the %* repeated application of the most specific v %* (most specific absorption &most specific identification) %* Induced clauses are marked invd %* - identification %* clauses induced by identification are labelled "idn" in kb %* %* see also: %* %*********************************************************************** %********************************************************************************% %* %* predicate: g1_op/3, g1_op/4 %* %* syntax: g1_op ( +ResolventID, +Parent1ID, -Parent2ID ) %* g1_op ( +ResolventID, +Parent1ID, -Parent2ID, + Label ) %* %* args: ResolventID, Parent1ID, Parent2ID .. clauseIDs %* Label for Parent2ID (default: g11) %* %* description: given a resolvent and one parent clause, the second parent clause %* is constructed %* %* example: %* %* peculiarities: %* %* see also: %* %******************************************************************************** g1_op( Res, Par1, Par2) :- g1_op( Res, Par1, Par2, g11). g1_op( Res, Par1, Par2, Label) :- (var(Label) -> Label = g11;true), get_clause(Res,_,_,Lres,_), get_clause(Par1,_,_,Lpar1,_), % clauses in list representation Res \== Par1, % not a clause with itself clear_mngr, skolemize(Lres,SS,LresSko), % skolemize resolvent assert_clause(LresSko), findall(Uncovered:Proof,prove4(Lpar1,Uncovered,Proof),Proofs), g1_process_proofs(Proofs,Reslit), g1_build_clause(Reslit,Lpar2Sko), % build parent2 deskolemize(Lpar2Sko,SS,Lpar2), % deskolemize store_clause(_,Lpar2,Label,Par2). % and store %********************************************************************************% %* %* predicate: extend_g1/2 %* %* syntax: extend_g1(+Ai_ID,-A_Id) %* %* args: clauseIDs %* %* description: locates suitable V's that are already available in the kb %* %* example: %* %* peculiarities: %* %* see also: %* %********************************************************************************% extend_g1(Ai_id, A_id) :- get_clause(Ai_id,_,_,Ai,_), length(Ai,Li), get_clause(Aj_id,_,_,Aj,g11), Ai_id \== Aj_id, length(Aj,Li), headed_lgg(Ai_id,Aj_id,A_id,g1), get_clause(A_id,_,_,A,_), length(A,L), (L >= Li -> % heuristic delete_clause(Aj_id); delete_clause(A_id), fail). %*********************************************************************** %* %* predicate: apply_g1/2 %* %* syntax: apply_g1( + NewClauseId, - List_of_ResultIds ) %* %* args: %* %* description: One might want to use apply_g1/2 if a new clause of background %* knowledge is added to the kb and the G1-operator is to be applied. %* If there already is a suitable "V", it will be extended and the %* lgg of two A's will be built. %* %* A %* Bi / \ Bj %* \ Ai Aj / %* \ / \ / %* Ci Cj %* %* If a clause A can be built as lgg of Ai and Aj (extend_g1/2), %* Ai and Aj will be deleted. %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** apply_g1(Clause,_) :- % use new clause as parent1 g1_op(_,Clause,Par2), findall(GenPar2, (extend_g1(Par2,GenPar2)), Bag), (Bag == [] -> addtolist(Par2); delete_clause(Par2), addtolist(Bag)), fail, !. apply_g1(Clause,_) :- % use new clause as resolvent g1_op(Clause,_,Par2), findall(GenPar2, (extend_g1(Par2,GenPar2)), Bag), (Bag == [] -> addtolist(Par2); delete_clause(Par2), addtolist(Bag)), fail. apply_g1(_,List) :- getlist(List). %*********************************************************************** %* %* predicate: absorb/3 %* %* syntax: absorb(+ExID, ?Parent1ID, -NewID) %* %* args: ExID: ID of example clause %* Parent1ID: id of known parent clause %* NewID: ID of absorption of example clause %* %* description: apply one absorption step on input clause ExID; %* if Parent1ID is given, it is tried to perform the %* absorption step with it as known parent. %* Otherwise absorption will be performed with the first %* applicable background clause. %* It is made sure that no 2 literals of a parent %* clause abs_match the same literal in the resolvent. %* %* example: %* %* peculiarities: no inverse subsitution yet %* %* see also: %* %*********************************************************************** % parent given absorb(ExID,PID,NewID):- nonvar(PID), clear_mngr, get_clause(ExID,_,_,Ex,_), skolemize(Ex,S,[SHead:p|SBody]), assert_body(SBody), !, abs_match1(PID,success,Proofs), abs_process_proofs(Proofs,PHead), abs_build_body(Body1), append(Body1,[PHead:n],Body), NewClauseS = [ SHead:p | Body ], deskolemize(NewClauseS,S, NewClause), store_clause(_,NewClause,abs,NewID). % parent not given absorb(ExID,PID,NewID):- var(PID), clear_mngr, get_clause(ExID,_,_,Ex,_), skolemize(Ex,S,[SHead:p|SBody]), assert_body(SBody), !, abs_match(ExID,success,Proofs), abs_process_proofs(Proofs,PHead), abs_build_body(Body1), append(Body1,[PHead:n],Body), NewClauseS = [ SHead:p | Body ], deskolemize(NewClauseS,S, NewClause), store_clause(_,NewClause,abs,NewID). %*********************************************************************** %* %* predicate: abs_match/3 %* %* syntax: abs_match(+ExID,-Mark,-Proofs) %* %* args: ExID: Id of the resolvent %* Mark in {success,fail} %* Proofs = [CL,...] where CL is a clause in list notation %* %* description: returns all (instantiated) clauses that can be embedded in the %* skolemized example clause (stored in kb with head/3,body/3) %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** abs_match( ExID, Mark,Proofs):- ( findall(Proof, abs_match0(ExID,Proof), Proofs) -> Mark = success ; Proofs = [], Mark = fail ). abs_match0( ExId, [Goal:p|Proof]):- get_clause(I,_,_,[Goal:p|Body],usr), I \== ExId, prove3(Body,Proof). %*********************************************************************** %* %* predicate: abs_match1/3 %* %* syntax: abs_match1(+PID,-Mark,-Proofs) %* %* args: PID: ID of a parent clause %* %* description: as abs_match, except for the fixed parent clause that %* is embedded in the resolvent %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** abs_match1(PID, Mark, Proofs):- ( findall(Proof, abs_match1a(PID,Proof), Proofs) -> Mark = success ; Proofs = [], Mark = fail ). abs_match1a( PID, [Goal:p|Proof]):- get_clause(PID,_,_,[Goal:p|Body],_), prove3(Body,Proof). %*********************************************************************** %* %* predicate: identify/3 %* %* syntax: identify(+ExID, ?Parent1ID, -NewID) %* %* args: ExID: ID of example clause %* Parent1ID: id of known parent clause %* NewID: ID of identification of example clause %* %* description: apply one identification step on input clause ExID; %* if Parent1ID is given, it is tried to perform the %* identification step with it as known parent. %* Otherwise identification will be performed with the %* first applicable background clause. %* It is made sure that no 2 literals of a parent %* clause ident_match the same literal in the resolvent. %* %* example: %* %* peculiarities: no inverse subsitution yet %* no backtraking %* %* see also: %* %*********************************************************************** % parent given identify(ExID,PID,NewID):- nonvar(PID), clear_mngr, get_clause(ExID,_,_,Ex,_), skolemize(Ex,S,SClause), assert_clause(SClause), !, ident_match1(PID,success,Proofs), ident_process_proofs(Proofs,PHead), ident_build_body(Body1), NewClauseS = [ PHead:p | Body1 ], deskolemize(NewClauseS,S, NewClause), store_clause(_,NewClause,idn,NewID). % parent not given identify(ExID,PID,NewID):- var(PID), get_clause(ExID,_,_,Ex,_), clear_mngr, skolemize(Ex,S,SClause), assert_clause(SClause), % show_bodies, ident_match(ExID,success,Proofs), ident_process_proofs(Proofs,PHead), ident_build_body(Body1), NewClauseS = [ PHead:p | Body1 ], deskolemize(NewClauseS,S, NewClause), store_clause(_,NewClause,idn,NewID). %*********************************************************************** %* %* predicate: ident_match/3 %* %* syntax: ident_match(+ExID,-Mark,-Proofs) %* %* args: ExID: ID of the resolvent %* Mark in {success,fail} %* Proofs = [P1,..,Pm], where Pi=[Uncovered:Proof] and %* Uncovered = Lit/M (M in {new_head,new_body}), Proof = [[Lit,N],...] %* (N in {head,body} %* %* description: matches clauses in kb against skolemized resolvent (stored %* in kb with head/3,body/3), Uncovered is the resolution %* literal that might be positive (new_head) or negative %* (new_body) %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** ident_match( ExID, Mark,Proofs):- ( findall(Proof, ident_match0(ExID,Proof), Proofs) -> Mark = success ; Proofs = [], Mark = fail ). ident_match0( ExId, [Uncovered:Proof]):- get_clause(I,_,_,Clause,usr), I \== ExId, prove4(Clause,Uncovered,Proof). %*********************************************************************** %* %* predicate: ident_match1/3 %* %* syntax: ident_match1(+PID,-Mark,-Proofs) %* %* args: PID ...parentID, Mark,Proofs as for ident_match %* %* description: as ident_match, except for the parent clause to be matched %* against the resolvent is given %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** ident_match1(PID, Mark, Proofs):- ( findall(Proof, ident_match1a(PID,Proof), Proofs) -> Mark = success ; Proofs = [], Mark = fail ). ident_match1a( PID, [Uncovered:Proof]):- get_clause(PID,_,_,Clause,_), prove4(Clause,Uncovered,Proof). %*********************************************************************** %* %* predicates: inv_derivate/2/3 %* %* syntax: inv_derivate(+ExID,-NewID) %* inv_derivate(+ExID,+PrefHead,-NewID) %* %* args: ExID : id of example %* NewID: id of expanded example %* PrefHead: a prolog literal %* %* description: Muggleton's inverse linear derivation %* But: %* while in intermediate stages several head literals %* might appear simultanously, the result will always %* be a Horn clause. As head literal we choose the %* latest one derived in inv_derivate/2. %* inv_derivate/3 takes as additional argument %* a literal, which is interpreted as a preferred %* head. If it is possible, inv_derivate/3 results %* in a Horn clause where the head matches this %* literal. %* The operator is restricted to finding clauses at most %* 100 inverse resolution steps away. %* %* example: inv_derivate(1, member(A,B), ID) %* %* peculiarities: %* %* see also: %* %*********************************************************************** inv_derivate(ExID,NewID):- clear_mngr, ( get_clause(ExID,_,_,CList,_) ; get_example(ExID,Ex,'+'), CList = [Ex:p] ), skolemize(CList,S,CListS), assert_clause(CListS), inv_derivate1(ExID,1), idev_build_clause(_,Clause1), deskolemize(Clause1,S,Clause), store_clause(_,Clause,invd,NewID),!. inv_derivate(ExID,PrefHead,NewID):- clear_mngr, get_clause(ExID,_,_,CList,_), skolemize(CList,S,CListS), assert_clause(CListS), inv_derivate1(ExID,1), idev_build_clause(PrefHead,Clause1), deskolemize(Clause1,S,Clause), store_clause(_,Clause,invd,NewID),!. inv_derivate1(ExID,I):- setof(U:P,ExID^Clause^idev_match0(ExID,Clause,U,P),Proofs), process_new_literals(Proofs,Flag), ( nonvar(Flag), I<100 -> J is I + 1,inv_derivate1(ExID,J) ; true ). %*********************************************************************** %* %* predicate: idev_match0/4 %* %* syntax: idev_match0(+ExID,-Clause,-Uncovered,-Proof) %* %* args: ExID: ID of the resolvent %* Clause: clause in list notation %* Uncovered: Lit/M, where M in {new_head,new_body} %* Proof: [[Lit,N],...] where N in {head,body} %* %* description: matches clause on skolemized resolvent (stored in kb %* with head/3, body/3), and returns the instantiation %* of clause and the resolution literal (Uncovered) %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** idev_match0( ExID,Clause, Uncovered, Proof):- get_clause(ID,_,_,Clause,_), ExID \== ID, prove4(Clause,Uncovered,Proof). %*********************************************************************** %* %* predicate: most_spec_v/3 %* %* syntax: most_spec_v(+ExID, ?PID, -NewID) %* %* args: ExID: id of example (resolvent) %* PID: id of known parent %* NewID: id of new clause %* %* description: %* Apply one most-spec-v operation to example with parent PID; %* If PID is not given, take the first applicable clause %* of bg as parent. %* The most specific v comprises the most specific absorption %* and the most specific identification. %* Since we always want Horn clauses as a result, this operator %* does not implement the most specific identification as %* described by Muggleton: Instead of adding a second head %* literal to the old clause, we replace the original head. %* I.e. our most specific identification operator is destructive. %* The most specific absorption remains nondestructive %* %* example: %* %* peculiarites: %* %* see also: inv_derivate/2 where multiple head literals are %* allowed om intermediate stages. %* %*********************************************************************** most_spec_v(ExID,PID,NewID):- ( get_clause(ExID,_,_,CList,_) ; get_example(ExID,Ex,'+'), CList = [Ex:p] ) , clear_mngr, skolemize(CList,S,CListS), assert_clause(CListS), idev_match1(ExID,_,Uncovered,Proof,PID), % Uncovered \== [], process_new_literals([Uncovered:Proof],Flag), nonvar(Flag), idev_build_clause(_,Clause1), deskolemize(Clause1,S,Clause), store_clause(_,Clause,msv,NewID). %*********************************************************************** %* %* predicate: idev_match1/5 %* %* syntax: idev_match1(+ExID,-Clause,-Uncovered,-Proof,-ID) %* %* args: ExID: ID of the resolvent, ID: ID of matched clause %* Clause: clause in list notation %* Uncovered: Lit/M, where M in {new_head,new_body} %* Proof: [[Lit,N],...] where N in {head,body} %* %* description: is like idev_match0/4, but returns id of absorbed clause %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** idev_match1( ExID,Clause, Uncovered, Proof,ID):- get_clause(ID,_,_,Clause,_), ExID \== ID, prove4(Clause,Uncovered,Proof). %*********************************************************************** %* %* predicate: saturate/2,saturate/3 %* %* syntax: saturate(+ExID, -NewID), saturate(+ExID,-NewID,+Bound) %* %* args: ExID: ID of example clause %* NewID: ID of saturation of example clause %* %* description: apply elementary saturation w.r.t. background %* clauses. %* It is bounded by at most 100 iterations, if bound is not given %* When checking the preconditions for firing one %* absorption step, %* it is made sure that no 2 literals of a parent %* clause subsume the same literal in the resolvent. %* %* example: %* %* peculiarities: %* %* see also: %* %*********************************************************************** saturate(ExID,GenID):- saturate(ExID,GenID,100). saturate(ExID,GenID,Bound):- saturate1(ExID,NewClause,Bound), % Rouveirol's theorem proving alg. % write(NewClause),nl, store_clause(_,NewClause,sat,GenID), !. % no backtracking %*********************************************************************** %* %* predicate: saturate1/3 %* %* syntax: saturate1(+ExID,-NewClause,+Bound) %* %* args: ExID .. ID of example clause, NewClause .. Prolog clause in list notation, %* Bound .. bound for interations %* %* description: saturates example clause w.r.t. background knowledge. %* It is bounded by at most Bound interations. %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** saturate1(ExID,NewClause,Bound):- clear_mngr, get_clause(ExID,H,_B,T,_), skolemize( T,S,[HS:p|U]), assert_body(U), saturate1a(HS,1,Bound,S,S1), bagof(A, M^I^body(A,I,M), NewBody1), sat_build_clause( H, NewBody1, Clause1), % Clause in list notation deskolemize( Clause1,S1,NewClause). %*********************************************************************** %* %* predicate: saturate1a/5 %* %* syntax: saturate1a(+HS,+Count,+Bound,+Subst,-Subst) %* %* args: HS: skolemized head of the example clause, %* Count,Bound: integers %* Subst: skolem subtitutions %* %* description: while Count < Bound, all heads following from the saturated %* clause so far (stored as body(Lit,_,_)) are asserted as %* additional body-literals (via body/3) %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** saturate1a(HS,I,Bound,S1,S2):- sat_match(HS,success,Proofs), !, skolemize(Proofs,S1,S3,Proofs1), assert_absorptions(Proofs1,Flag), ( nonvar(Flag), I < Bound -> J is I +1, saturate1a(HS,J,Bound,S3,S2) ; S2 = S3 ). saturate1a(_,_,_,S,S):- !. %*********************************************************************** %* %* predicate: sat_match/3 %* %* syntax: sat_match(+HS,-M,-Proofs) %* %* args: HS: skolemized head of the example clause %* Proofs = [CL,...] where each CL is a clause in list notation %* %* description: finds all possible proofs for all possible absorptions %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** sat_match(HS,Mark,Proofs):- ( setof(Proof,HS^sat_match0(HS,Proof), Proofs ) -> Mark = success ; Proofs = [], Mark = fail ). sat_match0(HS,[Goal:p|ProofBody]):- get_clause(_I,_,_,[Goal:p|Body],_), prove3(Body,ProofBody), Goal \== HS. %*********************************************************************** %* %* predicate: elem_saturate/3 %* %* syntax: elem_saturate( +ExID, ?PID, -NewID) %* %* args: ExID: id of resolvent %* PID : id of parent in bg %* NewID: id of new parent %* %* description: %* Add head of parent from bg to body of resolvent. %* The Operator is identical to Muggleton's %* most-specific-absorption. %* When checking the preconditions for firing one %* absorption step, %* it is made sure that no 2 literals of a parent %* clause subsume the same literal in the resolvent. %* %* example: %* %* peculiarities: %* %* see also: %* %*********************************************************************** % parent given elem_saturate(ExID,PID,NewID):- nonvar(PID), clear_mngr, get_clause(ExID,_,_,[H:p|B],_), skolemize(B,S,BS), assert_body(BS), get_clause(PID,_,_,[Goal:p|Body],_), prove3(Body,ProofBody), assert_absorptions([ [Goal:p|ProofBody]],Flag), nonvar(Flag), findall( L, body(L,_I,_M) ,NewBody), sat_build_clause(H,NewBody,Clause1), deskolemize(Clause1,S,NewClause), store_clause(_,NewClause,esat,NewID). % parent not given elem_saturate(ExID,PID,NewID):- var(PID), clear_mngr, get_clause(ExID,_,_,[H:p|B],_), skolemize(B,S,BS), assert_body(BS), sat_match1(ExID, [Goal:p|ProofBody],PID), assert_absorptions([ [Goal:p|ProofBody]],Flag), nonvar(Flag), findall( L, body(L,_I,_M) ,NewBody), sat_build_clause(H,NewBody,Clause1), deskolemize(Clause1,S,NewClause), store_clause(_,NewClause,esat,NewID). %*********************************************************************** %* %* predicate: sat_match1/3 %* %* syntax: sat_match1(+ExID,-Proof,-ID) %* %* args: ExID,ID: clauseIDs, Proofs: clause in list notation %* %* description: is like sat_match0/2, but returns id of absorbed clause %* %* example: %* %* peculiarities: none %* %* see also: %* %*********************************************************************** sat_match1(Ex,[Goal:p|ProofBody],I):- get_clause(I,_,_,[Goal:p|Body],_), I \== Ex, prove3(Body,ProofBody).
TeamSPoon/logicmoo_workspace
packs_sys/logicmoo_nars/prolog/miles/g1_ops.pl
Perl
mit
28,140
package WebService::Technorati::ApiQuery; use strict; use utf8; use LWP::UserAgent; use HTTP::Request; use XML::XPath; use WebService::Technorati::Exception; use constant DEFAULT_API_HOST_URL => 'http://api.technorati.com'; BEGIN { use vars qw ($VERSION $DEBUG); $VERSION = 0.04; $DEBUG = 0; } my $api_host_url = ''; =head1 NAME WebService::Technorati::ApiQuery - a base class for web services client queries =head1 SYNOPSIS This class has no constructor, as there's little use instantiating one. The fun is in the derived classes. =head1 DESCRIPTION When adding a new API call client, this class provides a lot scaffolding such as query string building, HTTP protocol stuff, XML::XPath object creation, and other common behaviors. =head1 USAGE This class is mostly utility functions that are inherited by ApiQuery derivations. =head1 BUGS No bugs currently open =head1 SUPPORT Join the Technorati developers mailing list at http://mail.technorati.com/mailman/listinfo/developers =head1 AUTHOR Ian Kallen ikallen _at_ technorati.com http://developers.technorati.com =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of the following Creative Commons License: http://creativecommons.org/licenses/by/2.0 as well as the indemnification provisions of the Apache 2.0 style license, the full text of which can be found in the LICENSE file included with this module. =head1 SEE ALSO perl(1). =cut =head2 apiHostUrl Usage : apiHostUrl('http://developers.technorati.com') Purpose : gets/sets the base URL Returns : a URL string Argument : a base URL, if setting the value; otherwise none Throws : none Comments : Instantiations of an ApiQuery subclass may want to change which api host they connect to (i.e. for beta testing interface changes that aren't yet deployed to the default host, http://api.technorati.com). See Also : WebService::Technorati =cut sub apiHostUrl { my $self = shift; my $change = shift; if ($change) { $api_host_url = $change; } if ($api_host_url) { return $api_host_url; } return DEFAULT_API_HOST_URL; } =head2 fetch_url Usage : fetch_url('http://developers.technorati.com') Purpose : fetches the URL contents Returns : a scalar of the content data Argument : a URL Throws : WebService::Technorati::NetworkException if the URL contents cannot be fetched Comments : the underlying implementation uses LWP::UserAgent See Also : WebService::Technorati =cut sub fetch_url { my $url = shift; my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new('GET', $url); my $response = $ua->request($request); if ($response->is_success) { return $response->content; } else { print $response->code,"\n"; print $response->error_as_HTML; WebService::Technorati::NetworkException->throw("fetching $url failed, stopping"); } } =head2 build_query_string Usage : build_query_string($hashref); Purpose : transforms the keys/values into a query string Returns : the query string Argument : a hash reference Throws : none Comments : multi value keys are not yet accounted for See Also : WebService::Technorati =cut sub build_query_string { my $params = shift; my @pairs = (); while (my($key,$val) = each %{$params}) { push(@pairs, "$key=$val"); } return join('&', @pairs); } =head2 execute Usage : build_query_string($apiurl, $hashref); Purpose : handles the low level execution cycle of an API call Returns : void Argument : a hash reference Throws : none Comments : calls build_query_string, fetch_url, instantiates XML::XPath and calls readResults See Also : WebService::Technorati =cut sub execute { my $self = shift; my $url = shift; my $args = shift; $url .= '?' . build_query_string($args); my $result_xml = fetch_url($url); my $result_xp = XML::XPath->new( xml => $result_xml ); $self->readResults($result_xp); } =head2 readResults Usage : readResults($xpath_data); Purpose : this is an abstract method Returns : void Argument : an XML::XPath representation of an API response Throws : WebService::Technorati::MethodNotImplementedException if not overriden Comments : derived classes must implement this in order to use execute(...) See Also : WebService::Technorati =cut sub readResults { WebService::Technorati::MethodNotImplementedException->throw( "abstract methond 'readResults()' not implemented"); } 1; __END__
carlgao/lenga
images/lenny64-peon/usr/share/perl5/WebService/Technorati/ApiQuery.pm
Perl
mit
4,729
#!/usr/bin/perl # # This is a SAS Component # my $usage = "usage: svr_tab2html [LINK-TEMPLATE] < tab-separated > html The LINK-TEMPATE is a URL in which the 3-character string PEG is mapped to the FIG-ID for any column containing a PEG"; my $border = q(); if (@ARGV && ($ARGV[0] =~ m/^-{1,2}border/)) { $border = q( border=1); shift; } my $url = (@ARGV > 0) ? $ARGV[0] : ""; print "<table$border>\n"; while (defined($_ = <STDIN>)) { chomp; if ($_ =~ m{^//}) { print STDOUT "</table>\n\n"; next; } my $heading_line = ($_ =~ s/^\#//) ? 1 : 0; my @flds = split(/\t/,$_); print "<tr>\n"; foreach $fld (@flds) { if (($fld =~ /(fig\|\d+\.\d+\.peg\.\d+)/) && $url) { my $peg = $1; my $tmp = $url; $tmp =~ s/PEG/$peg/g; $fld = "<a href=$tmp>$fld</a>"; } if ($heading_line) { print STDOUT " <th>$fld</th>\n"; } else { print STDOUT " <td>$fld</td>\n"; } } print STDOUT "</tr>\n"; } print STDOUT "</table>\n";
kbase/kb_seed
service-scripts/svr_tab2html.pl
Perl
mit
1,005
package Muninicious::Munin::RRD::Data; use strict; use warnings; use Mojo::Base -base; use Mojo::JSON; use Muninicious::Munin::RRD::Colours; use Math::BigFloat; use RRDs; use constant { RRD_STARTS => {day => '-2d', week => '-9d', month => '-6w', year => '-15mon'}, RRD_ORDER => ['day', 'week', 'month', 'year'], }; has service => undef; has colours => sub { Muninicious::Munin::RRD::Colours->new() }; has negatives => undef; has cdef_op => undef; has cdef_factor => undef; sub is_negative { my ($self, $field) = @_; if (!defined $self->negatives) { $self->negatives({}); foreach my $field (@{$self->service->fields}) { my $neg_name = $field->metadata('negative'); $self->negatives->{$neg_name} = 1 if (defined $neg_name); } } return $self->negatives->{$field->name} ? 1 : 0; } sub populate_cdef_lookups { my ($self) = @_; return if (defined $self->cdef_op); $self->cdef_op({}); $self->cdef_factor({}); foreach my $field (@{$self->service->fields}) { my $cdef = $field->metadata('cdef'); next if (!defined $cdef); if ($cdef =~ /.*,([\d\.]+),([\/\*])/) { $self->cdef_op->{$field->name} = $2; $self->cdef_factor->{$field->name} = $1; } } } sub apply_cdef { my ($self, $field, $value) = @_; return Math::BigFloat->bnan() if (!defined $value); $self->populate_cdef_lookups(); my $op = $self->cdef_op->{$field->name}; return $value if (!defined $op); my $factor = $self->cdef_factor->{$field->name}; if ($op eq '/') { return $value / $factor; } elsif ($op eq '*') { return $value * $factor; } return $value; } sub apply_negative { my ($self, $field, $value) = @_; if ($self->is_negative($field)) { return $value * -1; } return $value; } sub get_field_data { my ($self, $field, $agg, $start) = @_; my ($start_clock, $steps, $name, $fdata) = RRDs::fetch($field->get_rrd_file, $agg, '-s', $start); my %data; foreach my $i (0...@$fdata) { my $clock = $start_clock + ($steps * $i); my $value = $fdata->[$i]->[0]; $value = $self->apply_cdef($field, $value); $value = $self->apply_negative($field, $value); $data{$clock} = $value; } return \%data; } sub extract_data { my ($self, $field, $type, $agg) = @_; my %data; foreach my $start (reverse @{&RRD_ORDER}) { next if ($type ne 'all' && $type ne $start); my $field_data = $self->get_field_data($field, $agg, &RRD_STARTS->{$start}); foreach my $clock (keys %$field_data) { $data{$clock} = $field_data->{$clock}; } } return \%data; } sub get_data { my ($self, $type) = @_; my $data = { 'name' => $self->service->name, 'title' => $self->service->metadata('title'), 'vlabel' => $self->service->metadata('vlabel'), 'data' => [], }; my $now = time(); foreach my $field (@{$self->service->fields}) { my %values; foreach my $agg (qw/AVERAGE MIN MAX/) { $values{$agg} = $self->extract_data($field, $type, $agg); } my $field_data; $field_data->{'name'} = $field->name; $field_data->{'label'} = $field->metadata('label'); $field_data->{'info'} = $field->metadata('info'); $field_data->{'colour'} = $self->colours->get_field_colour($field); $field_data->{'area'} = ($field->metadata('draw') || '') =~ /AREA/ ? Mojo::JSON->true : Mojo::JSON->false; $field_data->{'stack'} = ($field->metadata('draw') || '') =~ /STACK/ ? Mojo::JSON->true : Mojo::JSON->false; $field_data->{'data'} = []; foreach my $clock (sort keys %{$values{'MIN'}}) { next if ($clock > $now); push(@{$field_data->{'data'}}, [$clock, [$values{'MIN'}->{$clock}, $values{'AVERAGE'}->{$clock}, $values{'AVERAGE'}->{$clock}]]); } push(@{$data->{'data'}}, $field_data); } return $data; } 1;
mattaltus/muninicious
lib/Muninicious/Munin/RRD/Data.pm
Perl
mit
3,833
#!/usr/bin/perl # vim:set tw=78 ts=4 sw=4 ai: use strict; use warnings; use lib '.'; use utf8; use List::Util qw /shuffle/; use ozi; my ($text) = ozi::data; my %stash; my @abc = split '', 'абвгґдеєжзиіїйклмнопрстуфхцчшщьюя-'; $stash{Abc} = \@abc; my @key = shuffle @abc; $stash{EncKey} = \@key; my %enc; for (my $i = 0; $i < @abc; ++$i) { $enc{$abc[$i]} = $key[$i] } $stash{EncMap} = \%enc; my %dec = reverse %enc; $stash{DecMap} = \%dec; $stash{DecKey} = [@dec{@abc}]; $stash{DecText} = $text; $stash{EncText} = join '', (map {$enc{$_}} split '', $text); ozi::run(\%stash);
mvuets/vntu-ozi-testwork
ozi-task1.pl
Perl
mit
617
% dynamoset and powerset are two predicates that calculate the powerset of a set! % The logic is the same in both predicates (using the recursive implementation) % but the recursion is front->last element of the list for the first implementation % and the opposite for the second one. % Run: dynamoset([1,2,3],L). and: powerset([1,2,3],L). and you will understand. dynamoset([],[[]]). dynamoset(L,LL):- makeListNoLast(L,LS), dynamoset(LS,LLS), ! , last(L,LastElement), addLastEverywhere(LastElement,LLS,LLast), append(LLS,LLast,LL). makeListNoLast([_],[]):- !. makeListNoLast([H|T],[H|T2]):- makeListNoLast(T,T2). addLastEverywhere(Element,[H|T],[H2|T2]):- append(H,[Element],H2), addLastEverywhere(Element,T,T2), !. addLastEverywhere(_,[],[]). % another way to implement it: powerset([],[[]]). powerset([H|T],L):- powerset(T,LL), add_map(H,LL,LLL), append(LL,LLL,L). add_map(X,[H|T],L):- adder(X,H,HH), add_map(X,T,LL),!, L=[HH|LL]. add_map(_,[],[]). adder(X,[],[X]). adder(X,[H|T],[X,H|T]).
bblodfon/Prolog
prolog_files/dynamoset.pl
Perl
mit
1,007
# This file is auto-generated by the Perl DateTime Suite time zone # code generator (0.07) This code generator comes with the # DateTime::TimeZone module distribution in the tools/ directory # # Generated from /tmp/Q713JNUf8G/europe. Olson data version 2016a # # Do not edit this file directly. # package DateTime::TimeZone::Europe::Uzhgorod; $DateTime::TimeZone::Europe::Uzhgorod::VERSION = '1.95'; use strict; use Class::Singleton 1.03; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Europe::Uzhgorod::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, # utc_start 59634743448, # utc_end 1890-09-30 22:30:48 (Tue) DateTime::TimeZone::NEG_INFINITY, # local_start 59634748800, # local_end 1890-10-01 00:00:00 (Wed) 5352, 0, 'LMT', ], [ 59634743448, # utc_start 1890-09-30 22:30:48 (Tue) 61188908400, # utc_end 1939-12-31 23:00:00 (Sun) 59634747048, # local_start 1890-09-30 23:30:48 (Tue) 61188912000, # local_end 1940-01-01 00:00:00 (Mon) 3600, 0, 'CET', ], [ 61188908400, # utc_start 1939-12-31 23:00:00 (Sun) 61196778000, # utc_end 1940-04-01 01:00:00 (Mon) 61188912000, # local_start 1940-01-01 00:00:00 (Mon) 61196781600, # local_end 1940-04-01 02:00:00 (Mon) 3600, 0, 'CET', ], [ 61196778000, # utc_start 1940-04-01 01:00:00 (Mon) 61278426000, # utc_end 1942-11-02 01:00:00 (Mon) 61196785200, # local_start 1940-04-01 03:00:00 (Mon) 61278433200, # local_end 1942-11-02 03:00:00 (Mon) 7200, 1, 'CEST', ], [ 61278426000, # utc_start 1942-11-02 01:00:00 (Mon) 61291126800, # utc_end 1943-03-29 01:00:00 (Mon) 61278429600, # local_start 1942-11-02 02:00:00 (Mon) 61291130400, # local_end 1943-03-29 02:00:00 (Mon) 3600, 0, 'CET', ], [ 61291126800, # utc_start 1943-03-29 01:00:00 (Mon) 61307456400, # utc_end 1943-10-04 01:00:00 (Mon) 61291134000, # local_start 1943-03-29 03:00:00 (Mon) 61307463600, # local_end 1943-10-04 03:00:00 (Mon) 7200, 1, 'CEST', ], [ 61307456400, # utc_start 1943-10-04 01:00:00 (Mon) 61323181200, # utc_end 1944-04-03 01:00:00 (Mon) 61307460000, # local_start 1943-10-04 02:00:00 (Mon) 61323184800, # local_end 1944-04-03 02:00:00 (Mon) 3600, 0, 'CET', ], [ 61323181200, # utc_start 1944-04-03 01:00:00 (Mon) 61338808800, # utc_end 1944-09-30 22:00:00 (Sat) 61323188400, # local_start 1944-04-03 03:00:00 (Mon) 61338816000, # local_end 1944-10-01 00:00:00 (Sun) 7200, 1, 'CEST', ], [ 61338808800, # utc_start 1944-09-30 22:00:00 (Sat) 61340968800, # utc_end 1944-10-25 22:00:00 (Wed) 61338816000, # local_start 1944-10-01 00:00:00 (Sun) 61340976000, # local_end 1944-10-26 00:00:00 (Thu) 7200, 1, 'CEST', ], [ 61340968800, # utc_start 1944-10-25 22:00:00 (Wed) 61362226800, # utc_end 1945-06-28 23:00:00 (Thu) 61340972400, # local_start 1944-10-25 23:00:00 (Wed) 61362230400, # local_end 1945-06-29 00:00:00 (Fri) 3600, 0, 'CET', ], [ 61362226800, # utc_start 1945-06-28 23:00:00 (Thu) 62490603600, # utc_end 1981-03-31 21:00:00 (Tue) 61362237600, # local_start 1945-06-29 02:00:00 (Fri) 62490614400, # local_end 1981-04-01 00:00:00 (Wed) 10800, 0, 'MSK', ], [ 62490603600, # utc_start 1981-03-31 21:00:00 (Tue) 62506411200, # utc_end 1981-09-30 20:00:00 (Wed) 62490618000, # local_start 1981-04-01 01:00:00 (Wed) 62506425600, # local_end 1981-10-01 00:00:00 (Thu) 14400, 1, 'MSD', ], [ 62506411200, # utc_start 1981-09-30 20:00:00 (Wed) 62522139600, # utc_end 1982-03-31 21:00:00 (Wed) 62506422000, # local_start 1981-09-30 23:00:00 (Wed) 62522150400, # local_end 1982-04-01 00:00:00 (Thu) 10800, 0, 'MSK', ], [ 62522139600, # utc_start 1982-03-31 21:00:00 (Wed) 62537947200, # utc_end 1982-09-30 20:00:00 (Thu) 62522154000, # local_start 1982-04-01 01:00:00 (Thu) 62537961600, # local_end 1982-10-01 00:00:00 (Fri) 14400, 1, 'MSD', ], [ 62537947200, # utc_start 1982-09-30 20:00:00 (Thu) 62553675600, # utc_end 1983-03-31 21:00:00 (Thu) 62537958000, # local_start 1982-09-30 23:00:00 (Thu) 62553686400, # local_end 1983-04-01 00:00:00 (Fri) 10800, 0, 'MSK', ], [ 62553675600, # utc_start 1983-03-31 21:00:00 (Thu) 62569483200, # utc_end 1983-09-30 20:00:00 (Fri) 62553690000, # local_start 1983-04-01 01:00:00 (Fri) 62569497600, # local_end 1983-10-01 00:00:00 (Sat) 14400, 1, 'MSD', ], [ 62569483200, # utc_start 1983-09-30 20:00:00 (Fri) 62585298000, # utc_end 1984-03-31 21:00:00 (Sat) 62569494000, # local_start 1983-09-30 23:00:00 (Fri) 62585308800, # local_end 1984-04-01 00:00:00 (Sun) 10800, 0, 'MSK', ], [ 62585298000, # utc_start 1984-03-31 21:00:00 (Sat) 62601030000, # utc_end 1984-09-29 23:00:00 (Sat) 62585312400, # local_start 1984-04-01 01:00:00 (Sun) 62601044400, # local_end 1984-09-30 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62601030000, # utc_start 1984-09-29 23:00:00 (Sat) 62616754800, # utc_end 1985-03-30 23:00:00 (Sat) 62601040800, # local_start 1984-09-30 02:00:00 (Sun) 62616765600, # local_end 1985-03-31 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62616754800, # utc_start 1985-03-30 23:00:00 (Sat) 62632479600, # utc_end 1985-09-28 23:00:00 (Sat) 62616769200, # local_start 1985-03-31 03:00:00 (Sun) 62632494000, # local_end 1985-09-29 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62632479600, # utc_start 1985-09-28 23:00:00 (Sat) 62648204400, # utc_end 1986-03-29 23:00:00 (Sat) 62632490400, # local_start 1985-09-29 02:00:00 (Sun) 62648215200, # local_end 1986-03-30 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62648204400, # utc_start 1986-03-29 23:00:00 (Sat) 62663929200, # utc_end 1986-09-27 23:00:00 (Sat) 62648218800, # local_start 1986-03-30 03:00:00 (Sun) 62663943600, # local_end 1986-09-28 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62663929200, # utc_start 1986-09-27 23:00:00 (Sat) 62679654000, # utc_end 1987-03-28 23:00:00 (Sat) 62663940000, # local_start 1986-09-28 02:00:00 (Sun) 62679664800, # local_end 1987-03-29 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62679654000, # utc_start 1987-03-28 23:00:00 (Sat) 62695378800, # utc_end 1987-09-26 23:00:00 (Sat) 62679668400, # local_start 1987-03-29 03:00:00 (Sun) 62695393200, # local_end 1987-09-27 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62695378800, # utc_start 1987-09-26 23:00:00 (Sat) 62711103600, # utc_end 1988-03-26 23:00:00 (Sat) 62695389600, # local_start 1987-09-27 02:00:00 (Sun) 62711114400, # local_end 1988-03-27 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62711103600, # utc_start 1988-03-26 23:00:00 (Sat) 62726828400, # utc_end 1988-09-24 23:00:00 (Sat) 62711118000, # local_start 1988-03-27 03:00:00 (Sun) 62726842800, # local_end 1988-09-25 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62726828400, # utc_start 1988-09-24 23:00:00 (Sat) 62742553200, # utc_end 1989-03-25 23:00:00 (Sat) 62726839200, # local_start 1988-09-25 02:00:00 (Sun) 62742564000, # local_end 1989-03-26 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62742553200, # utc_start 1989-03-25 23:00:00 (Sat) 62758278000, # utc_end 1989-09-23 23:00:00 (Sat) 62742567600, # local_start 1989-03-26 03:00:00 (Sun) 62758292400, # local_end 1989-09-24 03:00:00 (Sun) 14400, 1, 'MSD', ], [ 62758278000, # utc_start 1989-09-23 23:00:00 (Sat) 62766824400, # utc_end 1989-12-31 21:00:00 (Sun) 62758288800, # local_start 1989-09-24 02:00:00 (Sun) 62766835200, # local_end 1990-01-01 00:00:00 (Mon) 10800, 0, 'MSK', ], [ 62766824400, # utc_start 1989-12-31 21:00:00 (Sun) 62782470000, # utc_end 1990-06-30 23:00:00 (Sat) 62766835200, # local_start 1990-01-01 00:00:00 (Mon) 62782480800, # local_end 1990-07-01 02:00:00 (Sun) 10800, 0, 'MSK', ], [ 62782470000, # utc_start 1990-06-30 23:00:00 (Sat) 62806068000, # utc_end 1991-03-31 02:00:00 (Sun) 62782473600, # local_start 1990-07-01 00:00:00 (Sun) 62806071600, # local_end 1991-03-31 03:00:00 (Sun) 3600, 0, 'CET', ], [ 62806068000, # utc_start 1991-03-31 02:00:00 (Sun) 62829900000, # utc_end 1991-12-31 22:00:00 (Tue) 62806075200, # local_start 1991-03-31 04:00:00 (Sun) 62829907200, # local_end 1992-01-01 00:00:00 (Wed) 7200, 0, 'EET', ], [ 62829900000, # utc_start 1991-12-31 22:00:00 (Tue) 62837503200, # utc_end 1992-03-28 22:00:00 (Sat) 62829907200, # local_start 1992-01-01 00:00:00 (Wed) 62837510400, # local_end 1992-03-29 00:00:00 (Sun) 7200, 0, 'EET', ], [ 62837503200, # utc_start 1992-03-28 22:00:00 (Sat) 62853224400, # utc_end 1992-09-26 21:00:00 (Sat) 62837514000, # local_start 1992-03-29 01:00:00 (Sun) 62853235200, # local_end 1992-09-27 00:00:00 (Sun) 10800, 1, 'EEST', ], [ 62853224400, # utc_start 1992-09-26 21:00:00 (Sat) 62868952800, # utc_end 1993-03-27 22:00:00 (Sat) 62853231600, # local_start 1992-09-26 23:00:00 (Sat) 62868960000, # local_end 1993-03-28 00:00:00 (Sun) 7200, 0, 'EET', ], [ 62868952800, # utc_start 1993-03-27 22:00:00 (Sat) 62884674000, # utc_end 1993-09-25 21:00:00 (Sat) 62868963600, # local_start 1993-03-28 01:00:00 (Sun) 62884684800, # local_end 1993-09-26 00:00:00 (Sun) 10800, 1, 'EEST', ], [ 62884674000, # utc_start 1993-09-25 21:00:00 (Sat) 62900402400, # utc_end 1994-03-26 22:00:00 (Sat) 62884681200, # local_start 1993-09-25 23:00:00 (Sat) 62900409600, # local_end 1994-03-27 00:00:00 (Sun) 7200, 0, 'EET', ], [ 62900402400, # utc_start 1994-03-26 22:00:00 (Sat) 62916123600, # utc_end 1994-09-24 21:00:00 (Sat) 62900413200, # local_start 1994-03-27 01:00:00 (Sun) 62916134400, # local_end 1994-09-25 00:00:00 (Sun) 10800, 1, 'EEST', ], [ 62916123600, # utc_start 1994-09-24 21:00:00 (Sat) 62924594400, # utc_end 1994-12-31 22:00:00 (Sat) 62916130800, # local_start 1994-09-24 23:00:00 (Sat) 62924601600, # local_end 1995-01-01 00:00:00 (Sun) 7200, 0, 'EET', ], [ 62924594400, # utc_start 1994-12-31 22:00:00 (Sat) 62931862800, # utc_end 1995-03-26 01:00:00 (Sun) 62924601600, # local_start 1995-01-01 00:00:00 (Sun) 62931870000, # local_end 1995-03-26 03:00:00 (Sun) 7200, 0, 'EET', ], [ 62931862800, # utc_start 1995-03-26 01:00:00 (Sun) 62947587600, # utc_end 1995-09-24 01:00:00 (Sun) 62931873600, # local_start 1995-03-26 04:00:00 (Sun) 62947598400, # local_end 1995-09-24 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 62947587600, # utc_start 1995-09-24 01:00:00 (Sun) 62963917200, # utc_end 1996-03-31 01:00:00 (Sun) 62947594800, # local_start 1995-09-24 03:00:00 (Sun) 62963924400, # local_end 1996-03-31 03:00:00 (Sun) 7200, 0, 'EET', ], [ 62963917200, # utc_start 1996-03-31 01:00:00 (Sun) 62982061200, # utc_end 1996-10-27 01:00:00 (Sun) 62963928000, # local_start 1996-03-31 04:00:00 (Sun) 62982072000, # local_end 1996-10-27 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 62982061200, # utc_start 1996-10-27 01:00:00 (Sun) 62995366800, # utc_end 1997-03-30 01:00:00 (Sun) 62982068400, # local_start 1996-10-27 03:00:00 (Sun) 62995374000, # local_end 1997-03-30 03:00:00 (Sun) 7200, 0, 'EET', ], [ 62995366800, # utc_start 1997-03-30 01:00:00 (Sun) 63013510800, # utc_end 1997-10-26 01:00:00 (Sun) 62995377600, # local_start 1997-03-30 04:00:00 (Sun) 63013521600, # local_end 1997-10-26 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63013510800, # utc_start 1997-10-26 01:00:00 (Sun) 63026816400, # utc_end 1998-03-29 01:00:00 (Sun) 63013518000, # local_start 1997-10-26 03:00:00 (Sun) 63026823600, # local_end 1998-03-29 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63026816400, # utc_start 1998-03-29 01:00:00 (Sun) 63044960400, # utc_end 1998-10-25 01:00:00 (Sun) 63026827200, # local_start 1998-03-29 04:00:00 (Sun) 63044971200, # local_end 1998-10-25 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63044960400, # utc_start 1998-10-25 01:00:00 (Sun) 63058266000, # utc_end 1999-03-28 01:00:00 (Sun) 63044967600, # local_start 1998-10-25 03:00:00 (Sun) 63058273200, # local_end 1999-03-28 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63058266000, # utc_start 1999-03-28 01:00:00 (Sun) 63077014800, # utc_end 1999-10-31 01:00:00 (Sun) 63058276800, # local_start 1999-03-28 04:00:00 (Sun) 63077025600, # local_end 1999-10-31 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63077014800, # utc_start 1999-10-31 01:00:00 (Sun) 63089715600, # utc_end 2000-03-26 01:00:00 (Sun) 63077022000, # local_start 1999-10-31 03:00:00 (Sun) 63089722800, # local_end 2000-03-26 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63089715600, # utc_start 2000-03-26 01:00:00 (Sun) 63108464400, # utc_end 2000-10-29 01:00:00 (Sun) 63089726400, # local_start 2000-03-26 04:00:00 (Sun) 63108475200, # local_end 2000-10-29 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63108464400, # utc_start 2000-10-29 01:00:00 (Sun) 63121165200, # utc_end 2001-03-25 01:00:00 (Sun) 63108471600, # local_start 2000-10-29 03:00:00 (Sun) 63121172400, # local_end 2001-03-25 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63121165200, # utc_start 2001-03-25 01:00:00 (Sun) 63139914000, # utc_end 2001-10-28 01:00:00 (Sun) 63121176000, # local_start 2001-03-25 04:00:00 (Sun) 63139924800, # local_end 2001-10-28 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63139914000, # utc_start 2001-10-28 01:00:00 (Sun) 63153219600, # utc_end 2002-03-31 01:00:00 (Sun) 63139921200, # local_start 2001-10-28 03:00:00 (Sun) 63153226800, # local_end 2002-03-31 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63153219600, # utc_start 2002-03-31 01:00:00 (Sun) 63171363600, # utc_end 2002-10-27 01:00:00 (Sun) 63153230400, # local_start 2002-03-31 04:00:00 (Sun) 63171374400, # local_end 2002-10-27 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63171363600, # utc_start 2002-10-27 01:00:00 (Sun) 63184669200, # utc_end 2003-03-30 01:00:00 (Sun) 63171370800, # local_start 2002-10-27 03:00:00 (Sun) 63184676400, # local_end 2003-03-30 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63184669200, # utc_start 2003-03-30 01:00:00 (Sun) 63202813200, # utc_end 2003-10-26 01:00:00 (Sun) 63184680000, # local_start 2003-03-30 04:00:00 (Sun) 63202824000, # local_end 2003-10-26 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63202813200, # utc_start 2003-10-26 01:00:00 (Sun) 63216118800, # utc_end 2004-03-28 01:00:00 (Sun) 63202820400, # local_start 2003-10-26 03:00:00 (Sun) 63216126000, # local_end 2004-03-28 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63216118800, # utc_start 2004-03-28 01:00:00 (Sun) 63234867600, # utc_end 2004-10-31 01:00:00 (Sun) 63216129600, # local_start 2004-03-28 04:00:00 (Sun) 63234878400, # local_end 2004-10-31 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63234867600, # utc_start 2004-10-31 01:00:00 (Sun) 63247568400, # utc_end 2005-03-27 01:00:00 (Sun) 63234874800, # local_start 2004-10-31 03:00:00 (Sun) 63247575600, # local_end 2005-03-27 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63247568400, # utc_start 2005-03-27 01:00:00 (Sun) 63266317200, # utc_end 2005-10-30 01:00:00 (Sun) 63247579200, # local_start 2005-03-27 04:00:00 (Sun) 63266328000, # local_end 2005-10-30 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63266317200, # utc_start 2005-10-30 01:00:00 (Sun) 63279018000, # utc_end 2006-03-26 01:00:00 (Sun) 63266324400, # local_start 2005-10-30 03:00:00 (Sun) 63279025200, # local_end 2006-03-26 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63279018000, # utc_start 2006-03-26 01:00:00 (Sun) 63297766800, # utc_end 2006-10-29 01:00:00 (Sun) 63279028800, # local_start 2006-03-26 04:00:00 (Sun) 63297777600, # local_end 2006-10-29 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63297766800, # utc_start 2006-10-29 01:00:00 (Sun) 63310467600, # utc_end 2007-03-25 01:00:00 (Sun) 63297774000, # local_start 2006-10-29 03:00:00 (Sun) 63310474800, # local_end 2007-03-25 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63310467600, # utc_start 2007-03-25 01:00:00 (Sun) 63329216400, # utc_end 2007-10-28 01:00:00 (Sun) 63310478400, # local_start 2007-03-25 04:00:00 (Sun) 63329227200, # local_end 2007-10-28 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63329216400, # utc_start 2007-10-28 01:00:00 (Sun) 63342522000, # utc_end 2008-03-30 01:00:00 (Sun) 63329223600, # local_start 2007-10-28 03:00:00 (Sun) 63342529200, # local_end 2008-03-30 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63342522000, # utc_start 2008-03-30 01:00:00 (Sun) 63360666000, # utc_end 2008-10-26 01:00:00 (Sun) 63342532800, # local_start 2008-03-30 04:00:00 (Sun) 63360676800, # local_end 2008-10-26 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63360666000, # utc_start 2008-10-26 01:00:00 (Sun) 63373971600, # utc_end 2009-03-29 01:00:00 (Sun) 63360673200, # local_start 2008-10-26 03:00:00 (Sun) 63373978800, # local_end 2009-03-29 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63373971600, # utc_start 2009-03-29 01:00:00 (Sun) 63392115600, # utc_end 2009-10-25 01:00:00 (Sun) 63373982400, # local_start 2009-03-29 04:00:00 (Sun) 63392126400, # local_end 2009-10-25 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63392115600, # utc_start 2009-10-25 01:00:00 (Sun) 63405421200, # utc_end 2010-03-28 01:00:00 (Sun) 63392122800, # local_start 2009-10-25 03:00:00 (Sun) 63405428400, # local_end 2010-03-28 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63405421200, # utc_start 2010-03-28 01:00:00 (Sun) 63424170000, # utc_end 2010-10-31 01:00:00 (Sun) 63405432000, # local_start 2010-03-28 04:00:00 (Sun) 63424180800, # local_end 2010-10-31 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63424170000, # utc_start 2010-10-31 01:00:00 (Sun) 63436870800, # utc_end 2011-03-27 01:00:00 (Sun) 63424177200, # local_start 2010-10-31 03:00:00 (Sun) 63436878000, # local_end 2011-03-27 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63436870800, # utc_start 2011-03-27 01:00:00 (Sun) 63455619600, # utc_end 2011-10-30 01:00:00 (Sun) 63436881600, # local_start 2011-03-27 04:00:00 (Sun) 63455630400, # local_end 2011-10-30 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63455619600, # utc_start 2011-10-30 01:00:00 (Sun) 63468320400, # utc_end 2012-03-25 01:00:00 (Sun) 63455626800, # local_start 2011-10-30 03:00:00 (Sun) 63468327600, # local_end 2012-03-25 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63468320400, # utc_start 2012-03-25 01:00:00 (Sun) 63487069200, # utc_end 2012-10-28 01:00:00 (Sun) 63468331200, # local_start 2012-03-25 04:00:00 (Sun) 63487080000, # local_end 2012-10-28 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63487069200, # utc_start 2012-10-28 01:00:00 (Sun) 63500374800, # utc_end 2013-03-31 01:00:00 (Sun) 63487076400, # local_start 2012-10-28 03:00:00 (Sun) 63500382000, # local_end 2013-03-31 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63500374800, # utc_start 2013-03-31 01:00:00 (Sun) 63518518800, # utc_end 2013-10-27 01:00:00 (Sun) 63500385600, # local_start 2013-03-31 04:00:00 (Sun) 63518529600, # local_end 2013-10-27 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63518518800, # utc_start 2013-10-27 01:00:00 (Sun) 63531824400, # utc_end 2014-03-30 01:00:00 (Sun) 63518526000, # local_start 2013-10-27 03:00:00 (Sun) 63531831600, # local_end 2014-03-30 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63531824400, # utc_start 2014-03-30 01:00:00 (Sun) 63549968400, # utc_end 2014-10-26 01:00:00 (Sun) 63531835200, # local_start 2014-03-30 04:00:00 (Sun) 63549979200, # local_end 2014-10-26 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63549968400, # utc_start 2014-10-26 01:00:00 (Sun) 63563274000, # utc_end 2015-03-29 01:00:00 (Sun) 63549975600, # local_start 2014-10-26 03:00:00 (Sun) 63563281200, # local_end 2015-03-29 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63563274000, # utc_start 2015-03-29 01:00:00 (Sun) 63581418000, # utc_end 2015-10-25 01:00:00 (Sun) 63563284800, # local_start 2015-03-29 04:00:00 (Sun) 63581428800, # local_end 2015-10-25 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63581418000, # utc_start 2015-10-25 01:00:00 (Sun) 63594723600, # utc_end 2016-03-27 01:00:00 (Sun) 63581425200, # local_start 2015-10-25 03:00:00 (Sun) 63594730800, # local_end 2016-03-27 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63594723600, # utc_start 2016-03-27 01:00:00 (Sun) 63613472400, # utc_end 2016-10-30 01:00:00 (Sun) 63594734400, # local_start 2016-03-27 04:00:00 (Sun) 63613483200, # local_end 2016-10-30 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63613472400, # utc_start 2016-10-30 01:00:00 (Sun) 63626173200, # utc_end 2017-03-26 01:00:00 (Sun) 63613479600, # local_start 2016-10-30 03:00:00 (Sun) 63626180400, # local_end 2017-03-26 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63626173200, # utc_start 2017-03-26 01:00:00 (Sun) 63644922000, # utc_end 2017-10-29 01:00:00 (Sun) 63626184000, # local_start 2017-03-26 04:00:00 (Sun) 63644932800, # local_end 2017-10-29 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63644922000, # utc_start 2017-10-29 01:00:00 (Sun) 63657622800, # utc_end 2018-03-25 01:00:00 (Sun) 63644929200, # local_start 2017-10-29 03:00:00 (Sun) 63657630000, # local_end 2018-03-25 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63657622800, # utc_start 2018-03-25 01:00:00 (Sun) 63676371600, # utc_end 2018-10-28 01:00:00 (Sun) 63657633600, # local_start 2018-03-25 04:00:00 (Sun) 63676382400, # local_end 2018-10-28 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63676371600, # utc_start 2018-10-28 01:00:00 (Sun) 63689677200, # utc_end 2019-03-31 01:00:00 (Sun) 63676378800, # local_start 2018-10-28 03:00:00 (Sun) 63689684400, # local_end 2019-03-31 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63689677200, # utc_start 2019-03-31 01:00:00 (Sun) 63707821200, # utc_end 2019-10-27 01:00:00 (Sun) 63689688000, # local_start 2019-03-31 04:00:00 (Sun) 63707832000, # local_end 2019-10-27 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63707821200, # utc_start 2019-10-27 01:00:00 (Sun) 63721126800, # utc_end 2020-03-29 01:00:00 (Sun) 63707828400, # local_start 2019-10-27 03:00:00 (Sun) 63721134000, # local_end 2020-03-29 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63721126800, # utc_start 2020-03-29 01:00:00 (Sun) 63739270800, # utc_end 2020-10-25 01:00:00 (Sun) 63721137600, # local_start 2020-03-29 04:00:00 (Sun) 63739281600, # local_end 2020-10-25 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63739270800, # utc_start 2020-10-25 01:00:00 (Sun) 63752576400, # utc_end 2021-03-28 01:00:00 (Sun) 63739278000, # local_start 2020-10-25 03:00:00 (Sun) 63752583600, # local_end 2021-03-28 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63752576400, # utc_start 2021-03-28 01:00:00 (Sun) 63771325200, # utc_end 2021-10-31 01:00:00 (Sun) 63752587200, # local_start 2021-03-28 04:00:00 (Sun) 63771336000, # local_end 2021-10-31 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63771325200, # utc_start 2021-10-31 01:00:00 (Sun) 63784026000, # utc_end 2022-03-27 01:00:00 (Sun) 63771332400, # local_start 2021-10-31 03:00:00 (Sun) 63784033200, # local_end 2022-03-27 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63784026000, # utc_start 2022-03-27 01:00:00 (Sun) 63802774800, # utc_end 2022-10-30 01:00:00 (Sun) 63784036800, # local_start 2022-03-27 04:00:00 (Sun) 63802785600, # local_end 2022-10-30 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63802774800, # utc_start 2022-10-30 01:00:00 (Sun) 63815475600, # utc_end 2023-03-26 01:00:00 (Sun) 63802782000, # local_start 2022-10-30 03:00:00 (Sun) 63815482800, # local_end 2023-03-26 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63815475600, # utc_start 2023-03-26 01:00:00 (Sun) 63834224400, # utc_end 2023-10-29 01:00:00 (Sun) 63815486400, # local_start 2023-03-26 04:00:00 (Sun) 63834235200, # local_end 2023-10-29 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63834224400, # utc_start 2023-10-29 01:00:00 (Sun) 63847530000, # utc_end 2024-03-31 01:00:00 (Sun) 63834231600, # local_start 2023-10-29 03:00:00 (Sun) 63847537200, # local_end 2024-03-31 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63847530000, # utc_start 2024-03-31 01:00:00 (Sun) 63865674000, # utc_end 2024-10-27 01:00:00 (Sun) 63847540800, # local_start 2024-03-31 04:00:00 (Sun) 63865684800, # local_end 2024-10-27 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63865674000, # utc_start 2024-10-27 01:00:00 (Sun) 63878979600, # utc_end 2025-03-30 01:00:00 (Sun) 63865681200, # local_start 2024-10-27 03:00:00 (Sun) 63878986800, # local_end 2025-03-30 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63878979600, # utc_start 2025-03-30 01:00:00 (Sun) 63897123600, # utc_end 2025-10-26 01:00:00 (Sun) 63878990400, # local_start 2025-03-30 04:00:00 (Sun) 63897134400, # local_end 2025-10-26 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63897123600, # utc_start 2025-10-26 01:00:00 (Sun) 63910429200, # utc_end 2026-03-29 01:00:00 (Sun) 63897130800, # local_start 2025-10-26 03:00:00 (Sun) 63910436400, # local_end 2026-03-29 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63910429200, # utc_start 2026-03-29 01:00:00 (Sun) 63928573200, # utc_end 2026-10-25 01:00:00 (Sun) 63910440000, # local_start 2026-03-29 04:00:00 (Sun) 63928584000, # local_end 2026-10-25 04:00:00 (Sun) 10800, 1, 'EEST', ], [ 63928573200, # utc_start 2026-10-25 01:00:00 (Sun) 63941878800, # utc_end 2027-03-28 01:00:00 (Sun) 63928580400, # local_start 2026-10-25 03:00:00 (Sun) 63941886000, # local_end 2027-03-28 03:00:00 (Sun) 7200, 0, 'EET', ], [ 63941878800, # utc_start 2027-03-28 01:00:00 (Sun) 63960627600, # utc_end 2027-10-31 01:00:00 (Sun) 63941889600, # local_start 2027-03-28 04:00:00 (Sun) 63960638400, # local_end 2027-10-31 04:00:00 (Sun) 10800, 1, 'EEST', ], ]; sub olson_version {'2016a'} sub has_dst_changes {49} sub _max_year {2026} sub _new_instance { return shift->_init( @_, spans => $spans ); } sub _last_offset { 7200 } my $last_observance = bless( { 'format' => 'EE%sT', 'gmtoff' => '2:00', 'local_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 728294, 'local_rd_secs' => 0, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 728294, 'utc_rd_secs' => 0, 'utc_year' => 1996 }, 'DateTime' ), 'offset_from_std' => 0, 'offset_from_utc' => 7200, 'until' => [], 'utc_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 728293, 'local_rd_secs' => 79200, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 728293, 'utc_rd_secs' => 79200, 'utc_year' => 1995 }, 'DateTime' ) }, 'DateTime::TimeZone::OlsonDB::Observance' ) ; sub _last_observance { $last_observance } my $rules = [ bless( { 'at' => '1:00u', 'from' => '1996', 'in' => 'Oct', 'letter' => '', 'name' => 'EU', 'offset_from_std' => 0, 'on' => 'lastSun', 'save' => '0', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ), bless( { 'at' => '1:00u', 'from' => '1981', 'in' => 'Mar', 'letter' => 'S', 'name' => 'EU', 'offset_from_std' => 3600, 'on' => 'lastSun', 'save' => '1:00', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ) ] ; sub _rules { $rules } 1;
jkb78/extrajnm
local/lib/perl5/DateTime/TimeZone/Europe/Uzhgorod.pm
Perl
mit
28,179
#!/usr/bin/perl # This script runs the manta command read from each line of the input text file # with the specified camera path and creates a gnuplot of the results. # An html page is generated with all of the gnuplot images. # Abe Stephens, October 2005 # Parse args. $input_file = ""; $output_prefix = "manta_path_plot"; $path_file = ""; $path_sync = 1; $path_t = 0; # Use default. $path_time = 0; $path_start = 0; $path_last = 0; $path_warmup = 10; $title = "Manta Camera Path Benchmark"; $plot_x = 2; $plot_y = 5; $plot_columns = 6; $keep = 1; $line = 0; $start_time = time(); @plot_label = ( "Frame number", "Transaction number", "Elapse Frame", "Elapse Seconds", "Average fps" ); ############################################################################### # Variable replacement. sub variable_replace { my @result = (); # Replace in each string. foreach (split(/ /,$_[0])) { my $string = $_; # print "Initial: $string\n"; # Look for a variable to replace. if ($string =~ /\$\{([a-zA-Z\_]+)/) { my $variable = $1; # print "\t[$variable]\n"; # Search for the key. if ($variables{$variable}) { my $value = $variables{$variable}; $string =~ s/\$\{$variable\}/$value/g; } else { print "Line $line: \${$variable} Not found.\n"; exit(1); } # print "Result: $result\n"; } push(@result,$string); } return join(" ",@result); } ############################################################################### # Main program. for ($i=0;$i<@ARGV;++$i) { if ($ARGV[$i] eq "-file") { $input_file = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-prefix") { $output_prefix = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-path") { $path_file = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-sync") { $path_sync = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-delta_t") { $path_t = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-delta_time") { $path_time = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-interval") { $path_start = $ARGV[++$i]; $path_last = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-warmup") { $path_warmup = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-title") { $title = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-plot") { $plot_x = $ARGV[++$i]; $plot_y = $ARGV[++$i]; } elsif ($ARGV[$i] eq "-keep") { $keep = 1; } elsif ($ARGV[$i] eq "-nokeep") { $keep = 0; } elsif ($ARGV[$i] eq "-columns") { $plot_columns = $ARGV[++$i]; } } # Check to see if any defaults should be used. if (($input_file eq "")) { print "Usage: \n"; print "-file <manta commands file>\n"; print "-prefix <output png prefix>\n"; print "-path <camera path file>\n"; print "-sync <camera path sync>\n"; print "-delta_t <camera path delta t>\n"; print "-delta_time <camera path delta time>\n"; print "-interval <m> <n>\n"; print "-warmup <n>\n"; print "-title <title>\n"; print "-plot <x> <y> (default column $plot_x and $plot_y)\n"; print "-columns <n> (number of columns in manta output, default 5)\n"; print " Column info is passed to gnuplot, first column is 1 not 0.\n"; print "-[no]keep (keep temporary files, default on)\n"; print "\n"; print "Each line of the command file is either a manta command or \n"; print "plot: [above args] to change args between runs\n"; exit(1); } # Open the input file. if (!open( INPUT, "<" , $input_file) ) { print "Could not open input file " . $input_file . "\n"; exit(1); } # Output the output html file. $output_html = $output_prefix . ".html"; if (!open( HTML, ">", $output_html )) { print "Could not open output html file " . $output_html . "\n"; exit(1); } print HTML "<head title=\"$title\"></head>\n"; print HTML "<h1>$title</h1>\n"; print HTML "Generated using:<br><font face=\"courier\" size=-1>manta_path_plot.pl " . join(" ",@ARGV) . "</font><p>\n"; # Read in manta commands. $subtitle = 0; while (<INPUT>) { $input_line = $_; # Process the command. process_command( $input_line ); } # Make sure some runs were made. if (@command_array == 0) { exit(0); } ############################################################################### # Create a graph with all results. # Pipe commands to gnuplot. print HTML "<h2>Summary</h2>\n"; print HTML "<pre>\n"; if (!open(GNUPLOT, "|-", "gnuplot")) { print "Could not open gnuplot\n"; exit(1); } $png_file = $output_prefix . "-all.png"; @array = split(/\//,$png_file); $png_file_name = $array[@array-1]; $eps_file = $output_prefix . $line . "-all.eps"; @array = split(/\//,$eps_file); $eps_file_name = $array[@array-1]; @array = split(/\//,$out_file); $txt_file_name = $array[@array-1]; $plot_file = $output_prefix . $line . "-all.gnuplot"; $plot = "plot "; for ($i=0; $i<@out_array; ++$i) { print HTML "$subtitle_array[$i]: $command_array[$i]\n"; $plot = $plot . "\"$out_array[$i]\" using $plot_x_array[$i]:$plot_y_array[$i] title \"$subtitle_array[$i]\" "; if ($i < (@out_array)-1) { $plot = $plot . ", "; } } $plot = $plot . "\n"; print HTML "</pre>\n"; print GNUPLOT "set data style linespoints\n"; # print GNUPLOT "set term png small color\n"; print GNUPLOT "set term png small\n"; print GNUPLOT "set xlabel \"" . $plot_label[$plot_x-1] . "\"\n"; print GNUPLOT "set ylabel \"" . $plot_label[$plot_y-1] . "\"\n"; print GNUPLOT "set title \"$input_file: $title Summary\"\n"; print GNUPLOT "set output \"$png_file\"\n"; print GNUPLOT $plot; print GNUPLOT "set term postscript eps enhanced color\n"; print GNUPLOT "set output \"$eps_file\"\n"; print GNUPLOT $plot; print GNUPLOT "save '$plot_file'\n"; close(GNUPLOT); # Output to html file. print HTML "<img src=\"$png_file_name\" /><br>\n"; print HTML "(<a href=\"$eps_file_name\">eps</a>)"; if ($keep) { print HTML "(<a href=\"$txt_file_name\">txt</a>)"; } print HTML "(<a href=\"$plot_file\">gnuplot</a>)"; print HTML "<hr width=100%><p>\n"; close (HTML); close (INPUT); ############################################################################### # Delete the temporary files. if (!$keep) { for ($i=0; $i<@out_array; ++$i) { if (!unlink($out_array[$i])) { print "Could not delete $out_file\n"; exit(1); } } } print "manta_path_plot.pl Completed successfully in " . ((time()-$start_time)/60) ." minutes.\n\n"; ############################################################################### # Process commands. sub process_command { my $input_line = $_[0]; $_ = $_[0]; ########################################################################### # Check for a plot arg change. if (/^plot:(.*)/) { my $cmd = variable_replace( $1 ); @plot_args = split(/ /,$cmd); my $i; for ($i=0;$i<@plot_args;++$i) { if ($plot_args[$i] eq "-path") { $path_file = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-sync") { $path_sync = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-delta_t") { $path_t = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-delta_time") { $path_time = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-interval") { $path_start = $plot_args[++$i]; $path_last = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-warmup") { $path_warmup = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-plot") { $plot_x = $plot_args[++$i]; $plot_y = $plot_args[++$i]; } elsif ($plot_args[$i] eq "-keep") { $keep = 1; } elsif ($plot_args[$i] eq "-nokeep") { $keep = 0; } elsif ($plot_args[$i] eq "-subtitle") { ++$i; my @strs; while (($i < @plot_args) && !($plot_args[$i] =~ /^-/)) { push(@strs,$plot_args[$i++]); } $subtitle = join(" ",@strs); } } } ########################################################################### # Set command. elsif (/^set:[ \t]*([a-zA-Z\_]+)[ \t]*(.+)/) { my $var = $1; my $value = $2; # Save the variable. $variables{$var} = variable_replace($value); } ########################################################################### # System command. elsif (/^system:[ \t]*(.*)/) { my $command_line = $1; chomp($command_line); print "SYSTEM: $command_line\n"; # Parse command line args. @system_args = split(/[ ]+/,variable_replace($command_line)); # Run the command. if (system(@system_args)!=0) { # Exit on error. print "manta_path_plot.pl:\n"; print "\t$command_line\n"; print "\tTerminated code: $?\n"; exit(1); } } ########################################################################### # Create a Macro. elsif (/^begin_macro:\s*(\w*)\((\w*)\)/) { # Initialize the macro. my $name = $1; my $macro = { "parameter" => $2, "commands" => [] }; # Collect input lines for the macro. my $macro_line; while (!(($macro_line = <INPUT>) =~ /^end_macro:/)) { chomp($macro_line); push( @{$macro{"commands"}}, $macro_line ); } # Add to the macro hash. $macros{$name} = $macro; } # Run a macro elsif (/^macro:\s*(\w*)\(([0-9a-zA-Z_\.-]*)\)/) { my $name = $1; my $value = $2; # Check to see if the macro exists. my $macro = $macros{$name}; if ($macro) { # print "Begin Macro\n"; # Add the global variable. $variables{$$macro{"parameter"}} = $value; # Execute the macro. my $i; for ($i=0;$i<@{$macro{"commands"}};++$i) { $str = ${$macro{"commands"}}[$i]; $cmd = variable_replace( $str ); process_command( $cmd ); } # Remove the parameter. $variables{$$macro{"parameter"}} = 0; # print "End Macro\n"; } else { # Exit on error. print "manta_path_plot.pl:\n"; print "\t$input_line\n"; print "\tMacro not found: $name\n"; exit(1); } } ########################################################################### # Blank lines or comments elsif (/^[ \t]*\#/) { # Quietly skip } elsif (/^$/) { # Quietly skip } elsif (/^echo:\s*(.*)/) { print variable_replace( $1 ) . "\n"; } ########################################################################### # Otherwise process the line as a command. else { $input_line = variable_replace( $input_line ); # Check to see if a camera path file was specified. # If so append the manta camera path directive. if ($path_file ne "") { # Form the camera path command. $path_command = " -ui \"camerapath( -file $path_file -sync $path_sync -behavior exit -warmup $path_warmup "; if ($path_t != 0) { $path_command = $path_command . "-delta_t $path_t "; } if ($path_time != 0) { $path_command = $path_command . "-delta_time $path_time "; } if ($path_start != 0) { $path_command = $path_command . "-interval $path_start $path_last "; } $path_command = $path_command . ")\""; } # Record stat's on the run. $min_fps = 999; $max_fps = 0; $total_fps = 0; $total_samples = 0; $out_file = $output_prefix . $line . ".temp.txt"; chomp($input_line); $command = $input_line . $path_command; # . ">& /dev/null"; # Open a temporary output file. if (!open( TEMP, ">", $out_file )) { print "Could not open temp out file: $out_file\n"; exit(1); } print "RUNNING COMMAND: $command\n"; # Open a pipe to manta. if (!open( MANTA, "-|", $command )) { print "Could not execute line $line: $command\n"; exit(1); } push(@command_array, $command); # Wait for input while (<MANTA>) { # Skip the first sample. if ($total_samples > 0) { chomp; @column = split(/ /); if (@column == $plot_columns) { # print ("Frame: $column[0] fps: $column[4]\n"); print TEMP join(" ", @column) . "\n"; # Keep track of min and max. if ($column[$plot_y-1] < $min_fps) { $min_fps = $column[$plot_y-1]; } if ($column[$plot_y-1] > $max_fps) { $max_fps = $column[$plot_y-1]; } # Keep track of average. $total_fps = $total_fps + $column[$plot_y-1]; } else { $actual = @columns; print "Manta output line $line contained $actual columns $plot_columns expected.\n"; --$total_samples; } } $total_samples++; } # Close the file handles. close(MANTA); close(TEMP); # Pipe commands to gnuplot. if (!open(GNUPLOT, "|-", "gnuplot")) { print "Could not open gnuplot\n"; exit(1); } $png_file = $output_prefix . $line . ".png"; @array = split(/\//,$png_file); $png_file_name = $array[@array-1]; $eps_file = $output_prefix . $line . ".eps"; @array = split(/\//,$eps_file); $eps_file_name = $array[@array-1]; @array = split(/\//,$out_file); $txt_file_name = $array[@array-1]; $plot_file = $output_prefix . $line . ".gnuplot"; # Set the line subtitle. if ($subtitle eq "") { $subtitle = "$input_file:$line"; } print GNUPLOT "set data style linespoints\n"; print GNUPLOT "set xlabel \"" . $plot_label[$plot_x-1] . "\"\n"; print GNUPLOT "set ylabel \"" . $plot_label[$plot_y-1] . "\"\n"; print GNUPLOT "set title \"$input_file command $line\"\n"; # print GNUPLOT "set term png small color\n"; print GNUPLOT "set term png small\n"; print GNUPLOT "set output \"$png_file\"\n"; print GNUPLOT "plot \"$out_file\" using $plot_x:$plot_y title \"$subtitle\"\n"; print GNUPLOT "set term postscript eps enhanced color\n"; print GNUPLOT "set output \"$eps_file\"\n"; print GNUPLOT "plot \"$out_file\" using $plot_x:$plot_y title \"$subtitle\"\n"; print GNUPLOT "save '$plot_file'\n"; close(GNUPLOT); # Output to html file. print HTML "<h2>$subtitle</h2>\n"; print HTML "<font face=\"courier\" size=-1>$command</font><br>\n"; if ($total_samples > 0) { print HTML "<img src=\"$png_file_name\" /><br>\n"; print HTML "<br><pre>\n"; print HTML "Min fps: $min_fps\n"; print HTML "Max fps: $max_fps\n"; print HTML "Median fps: " . (($min_fps+$max_fps)/2) . "\n"; # Subtract one from total samples since we skipped the first one. print HTML "Mean fps: " . ($total_fps / ($total_samples-1)) . "</pre><br>\n"; print HTML "(<a href=\"$eps_file_name\">eps</a>)"; if ($keep) { print HTML "(<a href=\"$txt_file_name\">txt</a>)"; } } else { print HTML "Error: No samples.<p>\n"; } print HTML "<hr width=100%><p>\n"; push(@subtitle_array,$subtitle); push(@out_array,$out_file); push(@plot_x_array,$plot_x); push(@plot_y_array,$plot_y); # Clear the subtitle. $subtitle = ""; ++$line; } }
jeffamstutz/rfManta
StandAlone/manta_path_plot.pl
Perl
mit
17,051
package EnsEMBL::Maize::Component::Rss; use strict; use EnsEMBL::Web::Component; use EnsEMBL::Web::Form; use Readonly; my @chromosomes = map { +{ 'name' => "Chromosome $_", 'value' => $_ } } (1 .. 10); #my @data_types = { "value" =>"bacs", "name"=>"Sequenced BACs", 'checked' => 1 # }; Readonly my $FORM_NAME => 'rss_form'; Readonly my %FORM_ELEMENTS => ( 'chromosome' => { 'type' => 'DropDown', 'required' => 'yes', 'label' => 'Chromosome:', 'name' => 'chromosome', 'values' => \@chromosomes, 'order' => 1, 'select' => 'select', # 'spanning' => 'inline', }, 'start' => { 'type' => 'String', 'required' => 'yes', 'label' => "FPC Start Coordinate (base pairs):", 'name' => 'start', 'order' => 2, }, 'end' => { 'type' => 'String', 'required' => 'yes', 'label' => "FPC End Coordinate (base pairs):", 'name' => 'end', 'order' => 3, }, # 'data' => { # 'type' => 'MultiSelect', # 'name' => 'data', # 'label' => "Data Types for RSS Notification", # 'values' => \@data_types, # 'order' => 4, # }, 'action' => { 'type' => 'Hidden', 'name' => 'action', 'value' => 'submit', 'order' => 5, 'required' => 'no', }, ); sub show_form { my $panel = shift; my ($object) = @_; my $script = $object->script; my $form = EnsEMBL::Web::Form->new($FORM_NAME, "/@{[$object->species]}/$script", 'get'); $form->add_element( 'type' => 'Information', 'value' => '<br></br><p>Note: BAC Notification is provided as RSS (Really Simple Syndication), an XML-based format for information distribution. You can subscribe to any region of the maize genome and receive BAC, gene prediction, and marker updates via your favorite feed reader. The XML generated can also be parsed by RSS enabled browsers such as Firefox 1.0/2.0, Safari 2.0, and Internet Explorer 7.0.</p>' ); my $parameters = _initialize_parameters($object); for my $field ( sort { $parameters->{$a}->{'order'} <=> $parameters->{$b}->{'order'} } keys %$parameters) { my %element_arguments = (); for my $key (keys %{ $parameters->{$field} }) { $element_arguments{$key} = $parameters->{$field}->{$key}; } $form->add_element(%element_arguments); } $form->add_button('submit', 'RSS'); $form->add_button('reset', 'Reset'); $panel->print($form->render); return 1; } sub process { my $panel = shift; my ($object) = @_; $object->rss_xml; return 1; } sub is_required { my ($param) = @_; return 0 unless defined $FORM_ELEMENTS{$param}; return ($FORM_ELEMENTS{$param}->{'required'} eq 'yes'); } sub _initialize_parameters { my ($object) = @_; my %parameters = (); for my $field (keys %FORM_ELEMENTS) { $parameters{$field} = {}; for my $key (keys %{ $FORM_ELEMENTS{$field} }) { $parameters{$field}->{$key} = $FORM_ELEMENTS{$field}->{$key}; } $parameters{$field}->{'value'} ||= $object->param($field); } return \%parameters; } 1;
warelab/gramene-ensembl
maize/modules/EnsEMBL/Maize/Component/Rss.pm
Perl
mit
3,286
=begin comment Swaggy Jenkins Jenkins API clients generated from Swagger / Open API specification The version of the OpenAPI document: 1.1.2-pre.0 Contact: blah@cliffano.com Generated by: https://openapi-generator.tech =end comment =cut # # NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # Do not edit the class manually. # Ref: https://openapi-generator.tech # package WWW::OpenAPIClient::Object::ResponseTimeMonitorData; require 5.6.0; use strict; use warnings; use utf8; use JSON qw(decode_json); use Data::Dumper; use Module::Runtime qw(use_module); use Log::Any qw($log); use Date::Parse; use DateTime; use base ("Class::Accessor", "Class::Data::Inheritable"); # # # # NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. # REF: https://openapi-generator.tech # =begin comment Swaggy Jenkins Jenkins API clients generated from Swagger / Open API specification The version of the OpenAPI document: 1.1.2-pre.0 Contact: blah@cliffano.com Generated by: https://openapi-generator.tech =end comment =cut # # NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # Do not edit the class manually. # Ref: https://openapi-generator.tech # __PACKAGE__->mk_classdata('attribute_map' => {}); __PACKAGE__->mk_classdata('openapi_types' => {}); __PACKAGE__->mk_classdata('method_documentation' => {}); __PACKAGE__->mk_classdata('class_documentation' => {}); # new plain object sub new { my ($class, %args) = @_; my $self = bless {}, $class; $self->init(%args); return $self; } # initialize the object sub init { my ($self, %args) = @_; foreach my $attribute (keys %{$self->attribute_map}) { my $args_key = $self->attribute_map->{$attribute}; $self->$attribute( $args{ $args_key } ); } } # return perl hash sub to_hash { my $self = shift; my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); return $_hash; } # used by JSON for serialization sub TO_JSON { my $self = shift; my $_data = {}; foreach my $_key (keys %{$self->attribute_map}) { if (defined $self->{$_key}) { $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; } } return $_data; } # from Perl hashref sub from_hash { my ($self, $hash) = @_; # loop through attributes and use openapi_types to deserialize the data while ( my ($_key, $_type) = each %{$self->openapi_types} ) { my $_json_attribute = $self->attribute_map->{$_key}; if ($_type =~ /^array\[(.+)\]$/i) { # array my $_subclass = $1; my @_array = (); foreach my $_element (@{$hash->{$_json_attribute}}) { push @_array, $self->_deserialize($_subclass, $_element); } $self->{$_key} = \@_array; } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash my $_subclass = $1; my %_hash = (); while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { $_hash{$_key} = $self->_deserialize($_subclass, $_element); } $self->{$_key} = \%_hash; } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); } else { $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); } } return $self; } # deserialize non-array data sub _deserialize { my ($self, $type, $data) = @_; $log->debugf("deserializing %s with %s",Dumper($data), $type); if ($type eq 'DateTime') { return DateTime->from_epoch(epoch => str2time($data)); } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { return $data; } else { # hash(model) my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; return $_instance->from_hash($data); } } __PACKAGE__->class_documentation({description => '', class => 'ResponseTimeMonitorData', required => [], # TODO } ); __PACKAGE__->method_documentation({ '_class' => { datatype => 'string', base_name => '_class', description => '', format => '', read_only => '', }, 'timestamp' => { datatype => 'int', base_name => 'timestamp', description => '', format => '', read_only => '', }, 'average' => { datatype => 'int', base_name => 'average', description => '', format => '', read_only => '', }, }); __PACKAGE__->openapi_types( { '_class' => 'string', 'timestamp' => 'int', 'average' => 'int' } ); __PACKAGE__->attribute_map( { '_class' => '_class', 'timestamp' => 'timestamp', 'average' => 'average' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); 1;
cliffano/swaggy-jenkins
clients/perl/generated/lib/WWW/OpenAPIClient/Object/ResponseTimeMonitorData.pm
Perl
mit
5,127
package Bootylite::Plugins; use Mojo::Base -base; use Mojo::Util 'camelize'; use Mojo::Loader 'load_class'; has plugins => sub { [] }; sub add { my ($self, $name, $conf) = @_; # try to load $name = camelize $name; my $module = "Bootylite::Plugin::$name"; my $error = load_class $module; die $error->to_string if ref $error; die "plugin $name not found" if $error; # create, configure and add my $plugin = $module->new($conf); push @{$self->plugins}, $plugin; } sub call_startup { $_->startup(@_) for @{shift->plugins} }; sub call_index { $_->index(@_) for @{shift->plugins} }; sub call_paged { $_->paged(@_) for @{shift->plugins} }; sub call_article { $_->article(@_) for @{shift->plugins} }; sub call_archive { $_->archive(@_) for @{shift->plugins} }; sub call_tag { $_->tag(@_) for @{shift->plugins} }; sub call_tags { $_->tags(@_) for @{shift->plugins} }; sub call_page { $_->page(@_) for @{shift->plugins} }; sub call_feed { $_->feed(@_) for @{shift->plugins} }; sub call_tag_feed { $_->tag_feed(@_) for @{shift->plugins} }; sub call_draft { $_->draft(@_) for @{shift->plugins} }; sub call_refresh { $_->refresh(@_) for @{shift->plugins} }; !! 42; __END__
memowe/bootylite
lib/Bootylite/Plugins.pm
Perl
mit
1,319
#!/usr/bin/perl use strict; use warnings; # This class is generated from DBIx.pm. Do not modify. package WWW::Shopify::Model::DBIx::Schema::Result::Model::FulfillmentLineItem; use base qw/DBIx::Class::Core/; __PACKAGE__->table('shopify_fulfillmentsline_items'); __PACKAGE__->add_columns( 'id', { data_type => 'INT', is_nullable => '0', is_auto_increment => 1 }, 'fulfillment_id', { data_type => 'bigint', is_nullable => 0 }, 'line_item_id', { data_type => 'bigint', is_nullable => 0 } ); __PACKAGE__->set_primary_key('id'); __PACKAGE__->belongs_to(fulfillment => 'WWW::Shopify::Model::DBIx::Schema::Result::Model::Order::Fulfillment', 'fulfillment_id'); __PACKAGE__->belongs_to(line_item => 'WWW::Shopify::Model::DBIx::Schema::Result::Model::Order::LineItem', 'line_item_id'); 1;
gitpan/WWW-Shopify
lib/WWW/Shopify/Model/DBIx/Schema/Result/Model/FulfillmentLineItem.pm
Perl
mit
786
# # Main authors: # Christian Schulte <schulte@gecode.org> # # Copyright: # Christian Schulte, 2005 # # Last modified: # $Date: 2012-03-29 00:26:41 +0900 (木, 29 3 2012) $ by $Author: schulte $ # $Revision: 12649 $ # # This file is part of Gecode, the generic constraint # development environment: # http://www.gecode.org # # 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. # # # # Ultra-simplistic makedepend: Just find existing files # Relies on: # - all filenames are relative to root directory, which is the first argument # - #ifdef can be safely ignored # $i=0; $root = $ARGV[$i++]; while ($target = $ARGV[$i++]) { my @todo = (); my %done = (); push @todo, $target; while ($f = pop @todo) { open FILE, "$root/$f" or open FILE, "$f" or die "File missing: $root/$f\n"; while ($l = <FILE>) { if ($l =~ /^\#include <(gecode\/.*)>/ || $l =~ /^\#include "(.*)"/) { $g = $1; $g =~ s|^\./||og; if (!($g =~ /^gecode\/third-party/) && !$done{$g}) { push @todo, $g; if (-e "$root/$g") { $done{$g} = "$root/"; } else { $done{$g} = ""; } } } } close FILE; } $target =~ s|\.cpp?||og; print "$target\$(OBJSUFFIX) $target\$(SBJSUFFIX): "; $l = 3; foreach $g (sort(keys(%done))) { if ($l == 3) { print "\\\n\t"; $l = 0; } print "$done{$g}$g "; $l++; } print "\n"; }
kenhys/gecode
misc/makedepend.perl
Perl
mit
2,427
=head1 NAME SGN::Controller::AJAX::People - a REST controller class to provide the backend for the sgn_people schema =head1 DESCRIPTION REST interface for searching people, getting user data, etc. =head1 AUTHOR Naama Menda <nm249@cornell.edu> =cut package SGN::Controller::AJAX::People; use Moose; use Data::Dumper; use List::MoreUtils qw /any /; use Try::Tiny; use CXGN::People::Schema; use CXGN::People::Roles; BEGIN { extends 'Catalyst::Controller::REST' } __PACKAGE__->config( default => 'application/json', stash_key => 'rest', map => { 'application/json' => 'JSON' }, ); =head2 autocomplete Public Path: /ajax/people/autocomplete Autocomplete a person name. Takes a single GET param, C<person>, responds with a JSON array of completions for that term. =cut sub autocomplete : Local : ActionClass('REST') { } sub autocomplete_GET :Args(1) { my ( $self, $c , $print_id ) = @_; my $person = $c->req->param('term'); # trim and regularize whitespace $person =~ s/(^\s+|\s+)$//g; $person =~ s/\s+/ /g; my $q = "SELECT sp_person_id, first_name, last_name FROM sgn_people.sp_person WHERE lower(first_name) like ? OR lower(last_name) like ? LIMIT 20"; my $sth = $c->dbc->dbh->prepare($q); $sth->execute( lc "$person\%" , lc "$person\%" ); my @results; while (my ($sp_person_id, $first_name, $last_name) = $sth->fetchrow_array ) { $sp_person_id = $print_id ? "," . $sp_person_id : undef; push @results , "$first_name, $last_name $sp_person_id"; } $c->stash->{rest} = \@results; } sub people_and_roles : Path('/ajax/people/people_and_roles') : ActionClass('REST') { } sub people_and_roles_GET : Args(0) { my $self = shift; my $c = shift; my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $person_roles = CXGN::People::Roles->new({ bcs_schema=>$schema }); my $sp_persons = $person_roles->get_sp_persons(); my $sp_roles = $person_roles->get_sp_roles(); my %results = ( sp_persons => $sp_persons, sp_roles => $sp_roles ); $c->stash->{rest} = \%results; } sub add_person_role : Path('/ajax/people/add_person_role') : ActionClass('REST') { } sub add_person_role_GET : Args(0) { my $self = shift; my $c = shift; my $user = $c->user(); if (!$user){ $c->stash->{rest} = {error=>'You must be logged in first!'}; $c->detach; } if (!$user->check_roles("curator")) { $c->stash->{rest} = {error=>'You must be logged in with the correct role!'}; $c->detach; } my $sp_person_id = $c->req->param('sp_person_id'); my $sp_role_id = $c->req->param('sp_role_id'); my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $person_roles = CXGN::People::Roles->new({ bcs_schema=>$schema }); my $add_role = $person_roles->add_sp_person_role($sp_person_id, $sp_role_id); $c->stash->{rest} = {success=>1}; } sub roles :Chained('/') PathPart('ajax/roles') CaptureArgs(0) { my $self = shift; my $c = shift; print STDERR "ajax/roles...\n"; $c->stash->{message} = "processing"; } sub list_roles :Chained('roles') PathPart('list') Args(0) { my $self = shift; my $c = shift; print STDERR "roles list\n"; if (! $c->user()) { $c->stash->{rest} = { error => "You must be logged in to use this function." }; return; } my $schema = $c->dbic_schema("CXGN::People::Schema"); my %roles; my $rs1 = $schema->resultset("SpRole")->search( { } ); while (my $row = $rs1->next()) { $roles{$row->sp_role_id} = $row->name(); } my $rs2 = $schema->resultset("SpPerson")->search( { }, { join => 'sp_person_roles', '+select' => ['sp_person_roles.sp_role_id', 'sp_person_roles.sp_person_role_id' ], '+as' => ['sp_role_id', 'sp_person_role_id' ], order_by => 'sp_role_id' }); my @data; my %hash; my %role_colors = ( curator => 'red', submitter => 'orange', user => 'green' ); my $default_color = "#0275d8"; while (my $row = $rs2->next()) { my $person_name = $row->first_name." ".$row->last_name(); my $delete_link = ""; my $add_user_link = '&nbsp;&nbsp;<a href="#" onclick="javascript:add_user_role('.$row->get_column('sp_person_id').", \'".$person_name."\')\"><span style=\"color:darkgrey;width:8px;height:8px;border:solid;border-width:1px;padding:1px;\"><b>+</b></a></span>"; if ($c->user()->has_role("curator")) { $delete_link = '<a href="javascript:delete_user_role('.$row->get_column('sp_person_role_id').')"><b>X</b></a>'; } else { $delete_link = "X"; } $hash{$row->sp_person_id}->{userlink} = '<a href="/solpeople/personal-info.pl?sp_person_id='.$row->sp_person_id().'">'.$row->first_name()." ".$row->last_name().'</a>'; my $role_name = $roles{$row->get_column('sp_role_id')}; print STDERR "ROLE : $role_name\n"; if (! $c->user()->has_role("curator")) { # only show breeding programs if ($role_name !~ /curator|user|submitter/) { $hash{$row->sp_person_id}->{userroles} .= '<span style="border-radius:16px;color:white;border-style:solid;border:1px;padding:8px;margin:10px;background-color:'.$default_color.'"><b>'.$role_name."</b></span>"; } } else { my $color = $role_colors{$role_name} || $default_color; $hash{$row->sp_person_id}->{userroles} .= '<span style="border-radius:16px;color:white;border-style:solid;border:1px;padding:8px;margin:6px;background-color:'.$color.'"><b>'. $delete_link."&nbsp;&nbsp; ".$role_name."</b></span>"; $hash{$row->sp_person_id}->{add_user_link} = $add_user_link; } } foreach my $k (keys %hash) { $hash{$k}->{userroles} .= $hash{$k}->{add_user_link}; push @data, [ $hash{$k}->{userlink}, $hash{$k}->{userroles} ]; } $c->stash->{rest} = { data => \@data }; } # sub add_user :Chained('roles') PathPart('add/association/user') CaptureArgs(1) { # my $self = shift; # my $c = shift; # my $user_id = shift; # $c->stash->{sp_person_id} = $user_id; # } # sub add_user_role :Chained('add_user') PathPart('role') CaptureArgs(1) { # my $self = shift; # my $c = shift; # my $role_id = shift; # if (! $c->user()) { # $c->stash->{rest} = { error => "You must be logged in to use this function." }; # return; # } # if (! $c->user()->has_role("curator")) { # $c->stash->{rest} = { error => "You don't have the necessary privileges for maintaining user roles." }; # return; # } # } sub delete :Chained('roles') PathPart('delete/association') Args(1) { my $self = shift; my $c = shift; my $sp_person_role_id = shift; if (! $c->user()) { $c->stash->{rest} = { error => "You must be logged in to use this function." }; return; } if (! $c->user()->has_role("curator")) { $c->stash->{rest} = { error => "You don't have the necessary privileges for maintaining user roles." }; return; } my $schema = $c->dbic_schema("CXGN::People::Schema"); my $row = $schema->resultset("SpPersonRole")->find( { sp_person_role_id => $sp_person_role_id } ); if (!$row) { $c->stash->{rest} = { error => 'The relationship does not exist.' }; return; } $row->delete(); $c->stash->{rest} = { message => "Role associated with user deleted." }; } ### 1;
solgenomics/sgn
lib/SGN/Controller/AJAX/People.pm
Perl
mit
7,337
#!/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. =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 <helpdesk.org>. =cut use strict; use warnings; use Getopt::Long; use Bio::EnsEMBL::Utils::Exception qw(warning throw verbose); use Bio::EnsEMBL::Registry; #use Data::Dumper; my $species; my $dump_file; my $dump_dir; my $new_db_version; GetOptions('dump_file=s' => \$dump_file, 'dump_dir=s' => \$dump_dir, 'species=s' => \$species, 'new_db_version=n' => \$new_db_version, ); print "species is $species and new_db_version is $new_db_version and dump_file is $dump_file\n"; usage('You need to enter species,new_db_version as well as the file name where you want to dump the data') if (!defined $dump_file or !$species or !$new_db_version); Bio::EnsEMBL::Registry->load_registry_from_db( -host => 'ens-staging', -db_version => $new_db_version, -user => 'ensro', ); my $queue = 'normal'; my $memory = "'select[mem>4000] rusage[mem=4000]' -M4000000"; $queue = 'long' if ($species eq 'human'); $memory = "'select[mem>5000] rusage[mem=5000]' -M5000000" if ($species eq 'human'); my $dbCore = Bio::EnsEMBL::Registry->get_DBAdaptor($species,'core'); print "dbCore is ",ref($dbCore),"\n"; my $slice_adaptor = $dbCore->get_SliceAdaptor(); my $slices = $slice_adaptor->fetch_all('chromosome'); #find out all possible chromosomes we want to dump and create the different job arrays print "Time starting to dump data: ", scalar(localtime),"\n"; my $call = "bsub -q $queue -R$memory -o $dump_dir/out_dump_strain_$species\_$new_db_version -J dump_strain_$species'[1-" . @{$slices} . "]' ./dump_strain_seq.pl -dump_file \"$dump_dir/$dump_file\" -species $species -new_db_version $new_db_version"; system($call); #print $call,"\n"; #wait for all the process to go to LSF sleep(30); $call = "bsub -o finish_dump.txt -w 'done(dump_strain_" . $species . ")' -J waiting_process gzip $dump_dir/$dump_file*"; #print $call,"\n"; system($call); sub usage{ my $msg = shift; print STDERR <<EOF; usage: perl dump_strain_seq.pl <options> options: -dump_file <filename> file where you want to dump the resequencing data -dump_dir <path> path of the dump_file -species <species> species you want to dump data (default = mouse) -new_db_version <version number> release version number, such as 56 EOF die ("\n$msg\n\n"); }
dbolser/ensembl-variation
scripts/import/dump_strain_wrapper.pl
Perl
apache-2.0
3,272
package Paws::CloudFormation::StackSet; use Moose; has Capabilities => (is => 'ro', isa => 'ArrayRef[Str|Undef]'); has Description => (is => 'ro', isa => 'Str'); has Parameters => (is => 'ro', isa => 'ArrayRef[Paws::CloudFormation::Parameter]'); has StackSetId => (is => 'ro', isa => 'Str'); has StackSetName => (is => 'ro', isa => 'Str'); has Status => (is => 'ro', isa => 'Str'); has Tags => (is => 'ro', isa => 'ArrayRef[Paws::CloudFormation::Tag]'); has TemplateBody => (is => 'ro', isa => 'Str', decode_as => 'JSON', method => 'Template', traits => ['JSONAttribute']); 1; ### main pod documentation begin ### =head1 NAME Paws::CloudFormation::StackSet =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::CloudFormation::StackSet object: $service_obj->Method(Att1 => { Capabilities => $value, ..., TemplateBody => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::CloudFormation::StackSet object: $result = $service_obj->Method(...); $result->Att1->Capabilities =head1 DESCRIPTION A structure that contains information about a stack set. A stack set enables you to provision stacks into AWS accounts and across regions by using a single CloudFormation template. In the stack set, you specify the template to use, as well as any parameters and capabilities that the template requires. =head1 ATTRIBUTES =head2 Capabilities => ArrayRef[Str|Undef] The capabilities that are allowed in the stack set. Some stack set templates might include resources that can affect permissions in your AWS accountE<mdash>for example, by creating new AWS Identity and Access Management (IAM) users. For more information, see Acknowledging IAM Resources in AWS CloudFormation Templates. =head2 Description => Str A description of the stack set that you specify when the stack set is created or updated. =head2 Parameters => ArrayRef[L<Paws::CloudFormation::Parameter>] A list of input parameters for a stack set. =head2 StackSetId => Str The ID of the stack set. =head2 StackSetName => Str The name that's associated with the stack set. =head2 Status => Str The status of the stack set. =head2 Tags => ArrayRef[L<Paws::CloudFormation::Tag>] A list of tags that specify information about the stack set. A maximum number of 50 tags can be specified. =head2 TemplateBody => Str The structure that contains the body of the template that was used to create or update the stack set. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::CloudFormation> =head1 BUGS and CONTRIBUTIONS The source code is located here: https://github.com/pplu/aws-sdk-perl Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues =cut
ioanrogers/aws-sdk-perl
auto-lib/Paws/CloudFormation/StackSet.pm
Perl
apache-2.0
3,084
## OpenXPKI::Server::Authentication::Anonymous.pm ## ## Written 2006 by Michael Bell ## Updated to use new Service::Default semantics 2007 by Alexander Klink ## (C) Copyright 2006 by The OpenXPKI Project use strict; use warnings; package OpenXPKI::Server::Authentication::Anonymous; use OpenXPKI::Debug; use OpenXPKI::Exception; use OpenXPKI::Server::Context qw( CTX ); ## constructor and destructor stuff sub new { my $that = shift; my $class = ref($that) || $that; my $self = {}; bless $self, $class; my $path = shift; ##! 1: "start" $self->{ROLE} = CTX('config')->get("$path.role") || 'Anonymous'; $self->{USER} = CTX('config')->get("$path.user") || 'anonymous'; ##! 2: "role: ".$self->{ROLE} return $self; } sub login_step { ##! 1: 'start' my $self = shift; my $arg_ref = shift; my $name = $arg_ref->{HANDLER}; my $msg = $arg_ref->{MESSAGE}; return ( $self->{USER}, $self->{ROLE}, { SERVICE_MSG => 'SERVICE_READY', }, ); } 1; __END__ =head1 Name OpenXPKI::Server::Authentication::Anonymous =head1 Description This is the class which supports OpenXPKI with an anonymous authentication method. The parameters are passed as a hash reference. You can give a role and a user name in the config, default is role = Anonymous, User = anonymous =head1 Functions =head2 new is the constructor. It requires the config prefix as single argument. =head2 login_step returns the triple (I<user>, I<role>, and the service ready message)
stefanomarty/openxpki
core/server/OpenXPKI/Server/Authentication/Anonymous.pm
Perl
apache-2.0
1,571
# kill processes by db pattern # Author: Monika Komorowska # Date : May 2011 use strict; use DBI; use Getopt::Long; my ( $host, $user, $pass, $port, $dbpattern ); GetOptions( "host|h=s", \$host, "user|u=s", \$user, "pass|p=s", \$pass, "port|P=i", \$port, "dbpattern|pattern=s", \$dbpattern, ); if( !$host || !$user || !$pass || !$dbpattern ) { usage(); } my $dsn = "DBI:mysql:host=$host"; if( $port ) { $dsn .= ";port=$port"; } my $db = DBI->connect( $dsn, $user, $pass ); my $sth=$db->prepare("SHOW FULL PROCESSLIST") || die $DBI::err.": ".$DBI::errstr; $sth->execute || die DBI::err.": ".$DBI::errstr; my $ref; print "Id \t User \t Host \t db \t Command \t Time \t State \t Info\n"; my @proc_ids; while ( $ref = $sth->fetchrow_hashref() ) { if ( $$ref{'db'} =~ /$dbpattern/ ) { push (@proc_ids, $$ref{'Id'}); print "$$ref{'Id'} \t $$ref{'Host'} \t $$ref{'db'} \t $$ref{'Command'} \t $$ref{'Time'} \t $$ref{'State'} \t $$ref{'Info'}\n"; } } my $proc_id_count = @proc_ids; if ($proc_id_count > 0) { print "Are you sure you want to kill process(es) listed above? (y/n)\n"; } else { print "No processes found for db pattern $dbpattern\n"; } my $decision = <>; if ($decision == 'y') { my $killed_count = 0; foreach my $proc_id (@proc_ids) { if ( $db->do("KILL $proc_id") ) { $killed_count ++; } else { print $DBI::errstr; } } print "$killed_count procesess were killed\n"; } sub usage { print STDERR <<EOF Usage: kill_process_by_db options Where options are: -host hostname -user username -pass password -port port_of_server optional -dbpattern regular expression that the database name has to match EOF ; exit; }
adamsardar/perl-libs-custom
EnsemblAPI/ensembl/misc-scripts/db/kill_process_by_db.pl
Perl
apache-2.0
1,796
# # Copyright 2018 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::exchange::2010::local::mode::imapmailbox; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; use centreon::common::powershell::exchange::2010::imapmailbox; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "remote-host:s" => { name => 'remote_host', }, "remote-user:s" => { name => 'remote_user', }, "remote-password:s" => { name => 'remote_password', }, "no-ps" => { name => 'no_ps', }, "timeout:s" => { name => 'timeout', default => 50 }, "command:s" => { name => 'command', default => 'powershell.exe' }, "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, "ps-exec-only" => { name => 'ps_exec_only', }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, "mailbox:s" => { name => 'mailbox', }, "password:s" => { name => 'password', }, }); return $self; } sub change_macros { my ($self, %options) = @_; foreach (('warning', 'critical')) { if (defined($self->{option_results}->{$_})) { $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g; } } } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (!defined($self->{option_results}->{mailbox}) || $self->{option_results}->{mailbox} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify '--mailbox' option."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{password}) || $self->{option_results}->{password} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify '--password' option."); $self->{output}->option_exit(); } $self->change_macros(); } sub run { my ($self, %options) = @_; my $ps = centreon::common::powershell::exchange::2010::imapmailbox::get_powershell( remote_host => $self->{option_results}->{remote_host}, remote_user => $self->{option_results}->{remote_user}, remote_password => $self->{option_results}->{remote_password}, mailbox => $self->{option_results}->{mailbox}, password => $self->{option_results}->{password}, no_ps => $self->{option_results}->{no_ps}, ); $self->{option_results}->{command_options} .= " " . $ps; my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, timeout => $self->{option_results}->{timeout}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}); if (defined($self->{option_results}->{ps_exec_only})) { $self->{output}->output_add(severity => 'OK', short_msg => $stdout); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } centreon::common::powershell::exchange::2010::imapmailbox::check($self, stdout => $stdout, mailbox => $self->{option_results}->{mailbox}); $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check imap to a mailbox. =over 8 =item B<--remote-host> Open a session to the remote-host (fully qualified host name). --remote-user and --remote-password are optional =item B<--remote-user> Open a session to the remote-host with authentication. This also needs --remote-host and --remote-password. =item B<--remote-password> Open a session to the remote-host with authentication. This also needs --remote-user and --remote-host. =item B<--timeout> Set timeout time for command execution (Default: 50 sec) =item B<--no-ps> Don't encode powershell. To be used with --command and 'type' command. =item B<--command> Command to get information (Default: 'powershell.exe'). Can be changed if you have output in a file. To be used with --no-ps option!!! =item B<--command-path> Command path (Default: none). =item B<--command-options> Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). =item B<--ps-exec-only> Print powershell output. =item B<--warning> Set warning threshold. Can used special variables like: %{result}, %{scenario} =item B<--critical> Set critical threshold (Default: '%{result} !~ /Success/i'). Can used special variables like: %{result}, %{scenario} =item B<--mailbox> Set the mailbox to check (Required). =item B<--password> Set the password for the mailbox (Required). =back =cut
wilfriedcomte/centreon-plugins
apps/exchange/2010/local/mode/imapmailbox.pm
Perl
apache-2.0
6,937
=head1 LICENSE Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =head1 NAME Bio::EnsEMBL::Compara::RunnableDB::PairAligner::PairAligner =cut =head1 SYNOPSIS =cut =head1 DESCRIPTION This object is an abstract superclass which must be inherited from. It uses a runnable which takes sequence as input and returns FeaturePair objects as output (like Bio::EnsEMBL::Analysis::Runnable::Blastz) It adds functionality to read and write to a compara databases. It takes as input (via input_id or analysis->parameters) DnaFragChunk or DnaFragChunkSet objects (via dbID reference) and stores GenomicAlignBlock entries. The appropriate Bio::EnsEMBL::Analysis object must be passed for extraction of appropriate parameters. =cut =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut package Bio::EnsEMBL::Compara::RunnableDB::PairAligner::PairAligner; use strict; use Time::HiRes qw(time gettimeofday tv_interval); use File::Basename; use Bio::EnsEMBL::Utils::Exception; use Bio::EnsEMBL::Utils::SqlHelper; use Bio::EnsEMBL::Analysis::RunnableDB; use Bio::EnsEMBL::Compara::GenomicAlign; use Bio::EnsEMBL::Compara::MethodLinkSpeciesSet; use Bio::EnsEMBL::Compara::GenomicAlignBlock; use Bio::EnsEMBL::Compara::Production::DnaFragChunkSet; use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable'); ########################################## # # subclass override methods # ########################################## sub configure_defaults { my $self = shift; return 0; } sub configure_runnable { my $self = shift; throw("subclass must implement configure_runnable method\n"); } ########################################## # # internal RunnableDB methods that should # not be subclassed # ########################################## =head2 fetch_input Title : fetch_input Usage : $self->fetch_input Function: Fetches input data for repeatmasker from the database Returns : none Args : none =cut sub fetch_input { my( $self) = @_; # # run subclass configure_defaults method # $self->configure_defaults(); my $query_DnaFragChunkSet = new Bio::EnsEMBL::Compara::Production::DnaFragChunkSet; if(defined($self->param('qyChunkSetID'))) { my $chunkset = $self->compara_dba->get_DnaFragChunkSetAdaptor->fetch_by_dbID($self->param('qyChunkSetID')); $query_DnaFragChunkSet = $chunkset; } else { throw("Missing qyChunkSetID"); } $self->param('query_DnaFragChunkSet',$query_DnaFragChunkSet); my $db_DnaFragChunkSet = new Bio::EnsEMBL::Compara::Production::DnaFragChunkSet; if(defined($self->param('dbChunkSetID'))) { my $chunkset = $self->compara_dba->get_DnaFragChunkSetAdaptor->fetch_by_dbID($self->param('dbChunkSetID')); $db_DnaFragChunkSet = $chunkset; } else { throw("Missing dbChunkSetID"); } $self->param('db_DnaFragChunkSet',$db_DnaFragChunkSet); #create a Compara::DBAdaptor which shares the same DBI handle #with $self->db (Hive DBAdaptor) $self->compara_dba->dbc->disconnect_when_inactive(0); throw("Missing qyChunkSet") unless($query_DnaFragChunkSet); throw("Missing dbChunkSet") unless($db_DnaFragChunkSet); throw("Missing method_link_type") unless($self->param('method_link_type')); my ($first_qy_chunk) = @{$query_DnaFragChunkSet->get_all_DnaFragChunks}; my ($first_db_chunk) = @{$db_DnaFragChunkSet->get_all_DnaFragChunks}; # # create method_link_species_set # my $method = Bio::EnsEMBL::Compara::Method->new( -type => $self->param('method_link_type'), -class => "GenomicAlignBlock.pairwise_alignment"); my $species_set_obj = Bio::EnsEMBL::Compara::SpeciesSet->new( -genome_dbs => ($first_qy_chunk->dnafrag->genome_db->dbID == $first_db_chunk->dnafrag->genome_db->dbID) ? [$first_qy_chunk->dnafrag->genome_db] : [$first_qy_chunk->dnafrag->genome_db, $first_db_chunk->dnafrag->genome_db] ); my $mlss = Bio::EnsEMBL::Compara::MethodLinkSpeciesSet->new( -method => $method, -species_set_obj => $species_set_obj, ); $self->compara_dba->get_MethodLinkSpeciesSetAdaptor->store($mlss); $self->param('method_link_species_set', $mlss); if (defined $self->param('max_alignments')) { my $sth = $self->compara_dba->dbc->prepare("SELECT count(*) FROM genomic_align_block". " WHERE method_link_species_set_id = ".$mlss->dbID); $sth->execute(); my ($num_alignments) = $sth->fetchrow_array(); $sth->finish(); if ($num_alignments >= $self->max_alignments) { throw("Too many alignments ($num_alignments) have been stored already for MLSS ".$mlss->dbID."\n". " Try changing the parameters or increase the max_alignments option if you think\n". " your system can cope with so many alignments."); } } # # execute subclass configure_runnable method # $self->configure_runnable(); return 1; } sub run { my $self = shift; $self->compara_dba->dbc->disconnect_when_inactive(1); my $starttime = time(); my $work_dir = $self->worker_temp_directory; foreach my $runnable (@{$self->param('runnable')}) { throw("Runnable module not set") unless($runnable); $runnable->run($work_dir); } if($self->debug){printf("%1.3f secs to run %s pairwise\n", (time()-$starttime), $self->param('method_link_type'));} $self->compara_dba->dbc->disconnect_when_inactive(0); return 1; } sub delete_fasta_dumps_but_these { my $self = shift; my $fasta_files_not_to_delete = shift; my $work_dir = $self->worker_temp_directory; open F, "ls $work_dir|"; while (my $file = <F>) { chomp $file; next unless ($file =~ /\.fasta$/); my $delete = 1; foreach my $fasta_file (@{$fasta_files_not_to_delete}) { if ($file eq basename($fasta_file)) { $delete = 0; last; } } unlink "$work_dir/$file" if ($delete); } close F; } sub write_output { my( $self) = @_; my $starttime = time(); #since the Blast runnable takes in analysis parameters rather than an #analysis object, it creates new Analysis objects internally #(a new one for EACH FeaturePair generated) #which are a shadow of the real analysis object ($self->analysis) #The returned FeaturePair objects thus need to be reset to the real analysis object # #Start transaction # if ($self->param('do_transactions')) { my $compara_conn = $self->compara_dba->dbc; my $compara_helper = Bio::EnsEMBL::Utils::SqlHelper->new(-DB_CONNECTION => $compara_conn); $compara_helper->transaction(-CALLBACK => sub { $self->_write_output; }); } else { $self->_write_output; } return 1; } sub _write_output { my ($self) = @_; my $fake_analysis = Bio::EnsEMBL::Analysis->new; #Set use_autoincrement to 1 otherwise the GenomicAlignBlockAdaptor will use #LOCK TABLES which does an implicit commit and prevent any rollback $self->compara_dba->get_GenomicAlignBlockAdaptor->use_autoincrement(1); foreach my $runnable (@{$self->param('runnable')}) { foreach my $fp ( @{ $runnable->output() } ) { if($fp->isa('Bio::EnsEMBL::FeaturePair')) { $fp->analysis($fake_analysis); $self->store_featurePair_as_genomicAlignBlock($fp); } } if($self->debug){printf("%d FeaturePairs found\n", scalar(@{$runnable->output}));} } #print STDERR (time()-$starttime), " secs to write_output\n"; } ########################################## # # internal methods # ########################################## sub dumpChunkSetToWorkdir { my $self = shift; my $chunkSet = shift; my $starttime = time(); my $fastafile = $self->worker_temp_directory. "chunk_set_". $chunkSet->dbID .".fasta"; $fastafile =~ s/\/\//\//g; # converts any // in path to / return $fastafile if(-e $fastafile); open(OUTSEQ, ">$fastafile") or $self->throw("Error opening $fastafile for write"); my $output_seq = Bio::SeqIO->new( -fh =>\*OUTSEQ, -format => 'Fasta'); #Masking options are stored in the dna_collection my $dna_collection = $chunkSet->dna_collection; my $chunk_array = $chunkSet->get_all_DnaFragChunks; if($self->debug){printf("dumpChunkSetToWorkdir : %s : %d chunks\n", $fastafile, $chunkSet->count());} #Load all sequences in a dnafrag_chunk_set and set masking options my $sequence_ids; foreach my $chunk (@$chunk_array) { $chunk->masking_options($dna_collection->masking_options); } my $sequences = $self->compara_dba->get_SequenceAdaptor->fetch_all_by_chunk_set_id($chunkSet->dbID); foreach my $chunk (@$chunk_array) { #only have sequences for chunks with sequence_id > 0 - but this resets the sequence_id to 0. Why? my $this_seq_id = $chunk->sequence_id; #save seq_id $chunk->sequence($sequences->{$this_seq_id}) if ($chunk->sequence_id > 0); #this sets $chunk->sequence_id=0 $chunk->sequence_id($this_seq_id); #reset seq_id #Retrieve sequences with sequence_id=0 (ie too big to store in the sequence table) my $bioseq = $chunk->bioseq; # This may not be necessary now as already have all the sequences in the sequence table if($chunk->sequence_id==0) { my $this_seq_id = $self->compara_dba->get_DnaFragChunkAdaptor->update_sequence($chunk); } $output_seq->write_seq($bioseq); } close OUTSEQ; if($self->debug){printf(" %1.3f secs to dump\n", (time()-$starttime));} return $fastafile } sub dumpChunkToWorkdir { my $self = shift; my $chunk = shift; my $starttime = time(); my $fastafile = $self->worker_temp_directory . "chunk_" . $chunk->dbID . ".fasta"; $fastafile =~ s/\/\//\//g; # converts any // in path to / return $fastafile if(-e $fastafile); if($self->debug){print("dumpChunkToWorkdir : $fastafile\n");} $chunk->cache_sequence; $chunk->dump_to_fasta_file($fastafile); if($self->debug){printf(" %1.3f secs to dump\n", (time()-$starttime));} return $fastafile } sub store_featurePair_as_genomicAlignBlock { my $self = shift; my $fp = shift; my $qyChunk = undef; my $dbChunk = undef; if($fp->seqname =~ /chunkID(\d*):/) { my $chunk_id = $1; #printf("%s => %d\n", $fp->seqname, $chunk_id); $qyChunk = $self->compara_dba->get_DnaFragChunkAdaptor-> fetch_by_dbID($chunk_id); } if($fp->hseqname =~ /chunkID(\d*):/) { my $chunk_id = $1; #printf("%s => %d\n", $fp->hseqname, $chunk_id); $dbChunk = $self->compara_dba->get_DnaFragChunkAdaptor-> fetch_by_dbID($chunk_id); } unless($qyChunk and $dbChunk) { warn("unable to determine DnaFragChunk objects from FeaturePair"); return undef; } if($self->debug > 1) { print("qyChunk : ",$qyChunk->display_id,"\n"); print("dbChunk : ",$dbChunk->display_id,"\n"); print STDOUT $fp->seqname."\t". $fp->start."\t". $fp->end."\t". $fp->strand."\t". $fp->hseqname."\t". $fp->hstart."\t". $fp->hend."\t". $fp->hstrand."\t". $fp->score."\t". $fp->percent_id."\t". $fp->cigar_string."\n"; } $fp->slice($qyChunk->slice); $fp->hslice($dbChunk->slice); # # test if I'm getting the indexes right # if($self->debug > 2) { print_simple_align($fp->get_SimpleAlign, 80); my $testChunk = new Bio::EnsEMBL::Compara::Production::DnaFragChunk(); $testChunk->dnafrag($qyChunk->dnafrag); $testChunk->seq_start($qyChunk->seq_start+$fp->start-1); $testChunk->seq_end($qyChunk->seq_start+$fp->end-1); my $bioseq = $testChunk->bioseq; print($bioseq->seq, "\n"); } my $genomic_align1 = new Bio::EnsEMBL::Compara::GenomicAlign; $genomic_align1->method_link_species_set($self->param('method_link_species_set')); $genomic_align1->dnafrag($qyChunk->dnafrag); $genomic_align1->dnafrag_start($qyChunk->seq_start + $fp->start -1); $genomic_align1->dnafrag_end($qyChunk->seq_start + $fp->end -1); $genomic_align1->dnafrag_strand($fp->strand); $genomic_align1->visible(1); my $cigar1 = $fp->cigar_string; $cigar1 =~ s/I/M/g; $cigar1 = compact_cigar_line($cigar1); $cigar1 =~ s/D/G/g; $genomic_align1->cigar_line($cigar1); my $genomic_align2 = new Bio::EnsEMBL::Compara::GenomicAlign; $genomic_align2->method_link_species_set($self->param('method_link_species_set')); $genomic_align2->dnafrag($dbChunk->dnafrag); $genomic_align2->dnafrag_start($dbChunk->seq_start + $fp->hstart -1); $genomic_align2->dnafrag_end($dbChunk->seq_start + $fp->hend -1); $genomic_align2->dnafrag_strand($fp->hstrand); $genomic_align2->visible(1); my $cigar2 = $fp->cigar_string; $cigar2 =~ s/D/M/g; $cigar2 =~ s/I/D/g; $cigar2 = compact_cigar_line($cigar2); $cigar2 =~ s/D/G/g; $genomic_align2->cigar_line($cigar2); if($self->debug > 1) { print("original cigar_line ",$fp->cigar_string,"\n"); print(" $cigar1\n"); print(" $cigar2\n"); } my $GAB = new Bio::EnsEMBL::Compara::GenomicAlignBlock; $GAB->method_link_species_set($self->param('method_link_species_set')); $GAB->genomic_align_array([$genomic_align1, $genomic_align2]); $GAB->score($fp->score); $GAB->perc_id($fp->percent_id); $GAB->length($fp->alignment_length); $GAB->level_id(1); $self->compara_dba->get_GenomicAlignBlockAdaptor->store($GAB); if($self->debug > 2) { print_simple_align($GAB->get_SimpleAlign, 80);} return $GAB; } sub compact_cigar_line { my $cigar_line = shift; #print("cigar_line '$cigar_line' => "); my @pieces = ( $cigar_line =~ /(\d*[MDI])/g ); my @new_pieces = (); foreach my $piece (@pieces) { $piece =~ s/I/M/; if (! scalar @new_pieces || $piece =~ /D/) { push @new_pieces, $piece; next; } if ($piece =~ /\d*M/ && $new_pieces[-1] =~ /\d*M/) { my ($matches1) = ($piece =~ /(\d*)M/); my ($matches2) = ($new_pieces[-1] =~ /(\d*)M/); if (! defined $matches1 || $matches1 eq "") { $matches1 = 1; } if (! defined $matches2 || $matches2 eq "") { $matches2 = 1; } $new_pieces[-1] = $matches1 + $matches2 . "M"; } else { push @new_pieces, $piece; } } my $new_cigar_line = join("", @new_pieces); #print(" '$new_cigar_line'\n"); return $new_cigar_line; } sub print_simple_align { my $alignment = shift; my $aaPerLine = shift; $aaPerLine=40 unless($aaPerLine and $aaPerLine > 0); my ($seq1, $seq2) = $alignment->each_seq; my $seqStr1 = "|".$seq1->seq().'|'; my $seqStr2 = "|".$seq2->seq().'|'; my $enddiff = length($seqStr1) - length($seqStr2); while($enddiff>0) { $seqStr2 .= " "; $enddiff--; } while($enddiff<0) { $seqStr1 .= " "; $enddiff++; } my $label1 = sprintf("%40s : ", $seq1->id); my $label2 = sprintf("%40s : ", ""); my $label3 = sprintf("%40s : ", $seq2->id); my $line2 = ""; for(my $x=0; $x<length($seqStr1); $x++) { if(substr($seqStr1,$x,1) eq substr($seqStr2, $x,1)) { $line2.='|'; } else { $line2.=' '; } } my $offset=0; my $numLines = (length($seqStr1) / $aaPerLine); while($numLines>0) { printf("$label1 %s\n", substr($seqStr1,$offset,$aaPerLine)); printf("$label2 %s\n", substr($line2,$offset,$aaPerLine)); printf("$label3 %s\n", substr($seqStr2,$offset,$aaPerLine)); print("\n\n"); $offset+=$aaPerLine; $numLines--; } } 1;
dbolser-ebi/ensembl-compara
modules/Bio/EnsEMBL/Compara/RunnableDB/PairAligner/PairAligner.pm
Perl
apache-2.0
16,456
# Copyright 2020, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. package Google::Ads::GoogleAds::V10::Enums::PaymentModeEnum; use strict; use warnings; use Const::Exporter enums => [ UNSPECIFIED => "UNSPECIFIED", UNKNOWN => "UNKNOWN", CLICKS => "CLICKS", CONVERSION_VALUE => "CONVERSION_VALUE", CONVERSIONS => "CONVERSIONS", GUEST_STAY => "GUEST_STAY" ]; 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V10/Enums/PaymentModeEnum.pm
Perl
apache-2.0
919
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2017] 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 =pod =head1 NAME Bio::EnsEMBL::Compara::Production::ProjectionRunnableDB::ProjectOntologyXref =head1 DESCRIPTION This object serves two functions. In the first instance it is a RunnableDB instance to be used in a Hive pipeline and therefore inherits from Hive's Process object. A second set of methods is provided with the suffix C<without_hive> which allows you to use this object outside of a Hive pipeline. The Runnable is here to bring together a ProjectionEngine with the GenomeDB instances it will work with and have it interact with a ProjectionEngine writer (which can be a database or a file). See the C<fetch_input()> method for information on the parameters the module responds and to C<new_without_hive()> for information on how to use the module outside of hive. =head1 AUTHOR Andy Yates (ayatesatebiacuk) =head1 CONTACT This modules is part of the EnsEMBL project (http://www.ensembl.org) Questions can be posted to the dev mailing list: http://lists.ensembl.org/mailman/listinfo/dev =cut package Bio::EnsEMBL::Compara::Production::Projection::RunnableDB::ProjectOntologyXref; use strict; use warnings; use base qw( Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable ); use Bio::EnsEMBL::Utils::Argument qw(rearrange); use Bio::EnsEMBL::Utils::Exception qw(throw); use Bio::EnsEMBL::Utils::Scalar qw(assert_ref check_ref); use File::Spec; use Bio::EnsEMBL::Hive::URLFactory; use Bio::EnsEMBL::Hive::AnalysisJob; use Bio::EnsEMBL::Compara::Production::Projection::RunnableDB::RunnableLogger; use Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedDBEntryWriter; use Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedDisplayXrefWriter; use Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedFileWriter; use Bio::EnsEMBL::Compara::Production::Projection::Writer::MultipleWriter; #--- Non-hive methods =head2 new_without_hive() Arg [PROJECTION_ENGINE] : (ProjectionEngine) The projection engine to use to transfer terms Arg [TARGET_GENOME_DB] : (GenomeDB) GenomeDB to project terms to Arg [WRITE_DBA] : (DBAdaptor) Required if not given -FILE; used to Arg [FILE] : (String) Location of pipeline output; if given a directory it will generate a file name Example : See synopsis Description: Non-hive version of the object construction to be used with scripts Returntype : Bio::EnsEMBL::Compara::Production::Projection::RunnableDB::ProjectOntologyXref Exceptions : if PROJECTION_ENGINE was not given and was not a valid object. Also if we had no GenomeDBs given Caller : general =cut sub new_without_hive { my ($class, @params) = @_; my $self = bless {}, $class; my $job = Bio::EnsEMBL::Hive::AnalysisJob->new(); $self->input_job($job); my ($projection_engine, $target_genome_db, $write_dba, $file, $debug) = rearrange( [qw(projection_engine target_genome_db write_dba file debug)], @params); throw('-PROJECTION_ENGINE was not defined ') unless defined $projection_engine; $self->projection_engine($projection_engine); throw('-TARGET_GENOME_DB was not defined ') unless defined $target_genome_db; $self->target_genome_db($target_genome_db); throw('Need a -FILE or -WRITE_DBA parameter') if ! defined $write_dba && ! defined $file; $self->write_dba($write_dba) if defined $write_dba; $self->file($file) if defined $file; return $self; } =head2 run_without_hive() Performs the run() and write_output() calls in one method. =cut sub run_without_hive { my ($self) = @_; $self->run(); $self->write_output(); return; } =head2 fetch_input() Expect to see the following params: =over 8 =item source_genome_db_id - Required GenomeDB ID =item target_genome_db_id - Required GenomeDB ID =item projection_engine_class - Required String which is the package of the engine to use =item method_link - Optional but should be the method_link class of the types of Homologies to get =item write_to_db - Boolean which if on will start writing results to a core DB =item core_db - String which should be a URL of the core DB to write to B<IF> the one available via the Registry is read-only =item write_to_file - Boolean which if on will start writing results to a file =item file - String indicating a directory to write to (auto generated file name) or a target file name. We do not automatically create directories =item engine_params - Give optional parameters to the engine if required =item source - The source of the DBEntries to use; specify the source_name as used in member =back =cut sub fetch_input { my ($self) = @_; my $compara_dba = $self->get_compara_dba(); my $gdb_a = $compara_dba->get_GenomeDBAdaptor(); throw('No source_genome_db_id given in input') if ! $self->param('source_genome_db_id'); throw('No target_genome_db_id given in input') if ! $self->param('target_genome_db_id'); throw('No projection_engine_class given in input') if ! $self->param('projection_engine_class'); #Building the engine my $source_gdb = $gdb_a->fetch_by_dbID($self->param('source_genome_db_id')); my $log = Bio::EnsEMBL::Compara::Production::Projection::RunnableDB::RunnableLogger->new(-DEBUG => $self->debug()); my $params = { -GENOME_DB => $source_gdb, -DBA => $compara_dba, -LOG => $log }; $params->{-METHOD_LINK} = $self->param('method_link') if $self->param('method_link'); $params->{-SOURCE} = $self->param('source') if $self->param('source'); %{$params} = %{$self->param('engine_params')} if $self->param('engine_params'); my $engine = $self->_build_engine($params); $self->projection_engine($engine); #Working with target GDB my $target_genome_db = $gdb_a->fetch_by_dbID($self->param('target_genome_db_id')); $self->target_genome_db($target_genome_db); #Setting up the outputs if($self->param('write_to_db')) { my $core_db = $self->param('core_db'); my $adaptor = ($core_db) ? Bio::EnsEMBL::Hive::URLFactory->fetch($core_db) : $target_genome_db->db_adaptor(); $self->write_dba($adaptor) } if($self->param('write_to_file')) { my $file = $self->param('file'); throw 'No file param given in input' unless $file; $self->file($file); } return 1; } =head2 run() Gets the engine, runs it & sets the output into projections =cut sub run { my ($self) = @_; my $engine = $self->projection_engine(); my $projections = $engine->project($self->target_genome_db()); $self->projections($projections); return 1; } =head2 write_output() Takes the output pushed into projections and sends them into the specified sources according to the options given. =cut sub write_output { my ($self) = @_; $self->_writer()->write(); return 1; } #### Attributes =head2 projection_engine() The engine used to transfer terms. =cut sub projection_engine { my ($self, $projection_engine) = @_; if(defined $projection_engine) { assert_ref($projection_engine, 'Bio::EnsEMBL::Compara::Production::Projection::ProjectionEngine'); $self->param('projection_engine', $projection_engine); } return $self->param('projection_engine'); } =head2 target_genome_db() The GenomeDB instance used to project terms to =cut sub target_genome_db { my ($self, $target_genome_db) = @_; if(defined $target_genome_db) { assert_ref($target_genome_db, 'Bio::EnsEMBL::Compara::GenomeDB'); $self->{target_genome_db} = $target_genome_db; $self->param('target_genome_db', $target_genome_db); } $self->param('target_genome_db'); } =head2 projections() The projections we have projected; an ArrayRef of Projection objects =cut sub projections { my ($self, $projections) = @_; if(defined $projections && assert_ref($projections, 'ARRAY')) { $self->param('projections', $projections); } $self->param('projections'); } =head2 _writer() Returns the writer instance depending on what was given during construction. =cut sub _writer { my ($self) = @_; if(! defined $self->param('writer')) { my $projections = $self->projections(); my $writers = []; if($self->write_dba()) { if(check_ref($self->projection_engine(), 'Bio::EnsEMBL::Compara::Production::Projection::DisplayXrefProjectionEngine')) { push(@$writers, Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedDisplayXrefWriter->new( -PROJECTIONS => $projections, -DBA => $self->write_dba() )); } else { push(@$writers, Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedDBEntryWriter->new( -PROJECTIONS => $projections, -DBA => $self->write_dba() )); } } if($self->file()) { push(@$writers, Bio::EnsEMBL::Compara::Production::Projection::Writer::ProjectedFileWriter->new( -PROJECTIONS => $projections, -FILE => $self->_target_filename() )); } if(scalar(@{$writers}) > 1) { $self->{writer} = Bio::EnsEMBL::Compara::Production::Projection::Writer::MultipleWriter->new( -WRITERS => $writers, -PROJECTIONS => $projections ); } else { $self->param('writer', shift @{$writers}); } } return $self->param('writer'); } =head2 write_dba() A DBAdaptor instance which can write to a core DBAdaptor; assumed to be the same as the target GenomeDB. =cut sub write_dba { my ($self, $write_dba) = @_; $self->param('write_dba', $write_dba) if defined $write_dba; return $self->param('write_dba'); } =head2 file() The file or directory to write to. =cut sub file { my ($self, $file) = @_; $self->param('file', $file) if defined $file; return $self->param('file'); } =head2 _target_filename() If file is a file name we will return that. If it was a directory we will return a automatically generated name (sourcename_to_targetname.txt) =cut sub _target_filename { my ($self) = @_; my $file = $self->file(); if(-d $file) { my $source_genome_db = $self->projection_engine()->genome_db(); my $target_genome_db = $self->target_genome_db(); my $filename = sprintf('%s_to_%s.txt', $source_genome_db->name(), $target_genome_db->name()); return File::Spec->catfile($file, $filename); } else { return $file; } } sub _build_engine { my ($self, $args) = @_; my $mod = $self->param('projection_engine_class'); eval 'require '.$mod; throw("Cannot bring in the module ${mod}: $@") if $@; my $engine = $mod->new(%{$args}); return $engine; } 1;
danstaines/ensembl-compara
modules/Bio/EnsEMBL/Compara/Production/Projection/RunnableDB/ProjectOntologyXref.pm
Perl
apache-2.0
11,306
package Paws::CloudSearch::DescribeScalingParameters; use Moose; has DomainName => (is => 'ro', isa => 'Str', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'DescribeScalingParameters'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::CloudSearch::DescribeScalingParametersResponse'); class_has _result_key => (isa => 'Str', is => 'ro', default => 'DescribeScalingParametersResult'); 1; ### main pod documentation begin ### =head1 NAME Paws::CloudSearch::DescribeScalingParameters - Arguments for method DescribeScalingParameters on Paws::CloudSearch =head1 DESCRIPTION This class represents the parameters used for calling the method DescribeScalingParameters on the Amazon CloudSearch service. Use the attributes of this class as arguments to method DescribeScalingParameters. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DescribeScalingParameters. As an example: $service_obj->DescribeScalingParameters(Att1 => $value1, Att2 => $value2, ...); 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. =head1 ATTRIBUTES =head2 B<REQUIRED> DomainName => Str =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method DescribeScalingParameters in L<Paws::CloudSearch> =head1 BUGS and CONTRIBUTIONS The source code is located here: https://github.com/pplu/aws-sdk-perl Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues =cut
ioanrogers/aws-sdk-perl
auto-lib/Paws/CloudSearch/DescribeScalingParameters.pm
Perl
apache-2.0
1,739
use 5.008001; use strict; use warnings; package Dancer2::Session::Memcached; # ABSTRACT: Dancer 2 session storage with Cache::Memcached our $VERSION = '0.003'; # VERSION use Carp; use Moo; use Cache::Memcached; use Dancer2::Core::Types; #--------------------------------------------------------------------------# # Public attributes #--------------------------------------------------------------------------# has memcached_servers => ( is => 'ro', isa => Str, required => 1, ); #--------------------------------------------------------------------------# # Private attributes #--------------------------------------------------------------------------# has _memcached => ( is => 'lazy', isa => InstanceOf ['Cache::Memcached'], handles => { _retrieve => 'get', _flush => 'set', _destroy => 'delete', }, ); # Adapted from Dancer::Session::Memcached sub _build__memcached { my ($self) = @_; my $servers = $self->memcached_servers; croak "The setting memcached_servers must be defined" unless defined $servers; $servers = [ split /,\s*/, $servers ]; # make sure the servers look good foreach my $s (@$servers) { if ( $s =~ /^\d+\.\d+\.\d+\.\d+$/ ) { croak "server `$s' is invalid; port is missing, use `server:port'"; } } return Cache::Memcached->new( servers => $servers ); } #--------------------------------------------------------------------------# # Role composition #--------------------------------------------------------------------------# with 'Dancer2::Core::Role::SessionFactory'; # _retrieve, _flush, _destroy handled by _memcached object # memcached doesn't have any easy way to list keys it knows about # so we cheat and return an empty array ref sub _sessions { my ($self) = @_; return []; } 1; # vim: ts=4 sts=4 sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Dancer2::Session::Memcached - Dancer 2 session storage with Cache::Memcached =head1 VERSION version 0.003 =head1 SYNOPSIS # In Dancer 2 config.yml file session: Memcached engines: session: Memcached: memcached_servers: 10.0.1.31:11211,10.0.1.32:11211,/var/sock/memcached =head1 DESCRIPTION This module implements a session factory for Dancer 2 that stores session state within Memcached using L<Cache::Memcached>. =head1 ATTRIBUTES =head2 memcached_servers (required) A comma-separated list of reachable memcached servers (can be either address:port or socket paths). =for Pod::Coverage method_names_here =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at L<https://github.com/dagolden/dancer2-session-memcached/issues>. You will be notified automatically of any progress on your issue. =head2 Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. L<https://github.com/dagolden/dancer2-session-memcached> git clone git://github.com/dagolden/dancer2-session-memcached.git =head1 AUTHOR David Golden <dagolden@cpan.org> =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2013 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 =cut
gitpan/Dancer2-Session-Memcached
lib/Dancer2/Session/Memcached.pm
Perl
apache-2.0
3,468
#!/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; use Bio::EnsEMBL::DBSQL::DBAdaptor; use Bio::EnsEMBL::Pipeline::Tools::TranscriptUtils; use Bio::SeqIO; use Getopt::Long qw(:config no_ignore_case); my $file; my $dbhost = 'ecs2d'; my $dbuser = 'ensro'; my $dbname = 'homo_sapiens_core_9_30'; my $dbpass = undef; my $path; my $genetype; my $protein_id; my $dna_id; GetOptions( 'protein_id:s' => \$protein_id, 'dna_id:s' => \$dna_id, 'host|dbhost|h:s' => \$dbhost, 'dbname|db|D:s' => \$dbname, 'genetype:s' => \$genetype, 'path|cs_version:s' => \$path, ); unless ( $protein_id || $dna_id ){ print STDERR "script to print out all the transcripts with a given id as evidence\n"; print STDERR "Usage: $0 -dbname -dbhost ( -protein_id OR -dna_id ) [ -genetype (optional)]\n"; exit(0); } my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor( '-host' => $dbhost, '-user' => $dbuser, '-dbname' => $dbname, '-pass' => $dbpass, ); print STDERR "connected to $dbname : $dbhost\n"; unless ($path){ $path = $db->assembly_type; } print STDERR "path = $path\n"; if ( $protein_id ){ print "Transcripts based on $protein_id\n"; my @transcripts; TRAN: foreach my $tran ( Bio::EnsEMBL::Pipeline::Tools::TranscriptUtils->find_transcripts_by_protein_evidence($protein_id,$db,$genetype) ){ &show_transcript($db,$tran->dbID); } } if ( $dna_id ){ print "Transcripts based on $dna_id\n"; my @transcripts; TRAN: foreach my $tran ( Bio::EnsEMBL::Pipeline::Tools::TranscriptUtils->find_transcripts_by_dna_evidence($dna_id,$db,$genetype) ){ &show_transcript($db,$tran->dbID); } } ############################################################ sub show_transcript{ my ($db,$t_id) = @_; my $tran = $db->get_TranscriptAdaptor->fetch_by_dbID($t_id); my $tran_id = $tran->stable_id || $tran->dbID; my $transl_id; if ( $tran->translation ){ $transl_id = $tran->translation->stable_id || $tran->translation->dbID; } my $gene_id; if ( $tran->stable_id ){ $gene_id = &get_gene_stable_id($db,$tran->dbID); } else{ $gene_id = &get_gene_id($db,$tran->dbID); } print "Gene:$gene_id\tTranscript:$tran_id\tPeptide:$transl_id\n"; my @exons = @{$tran->get_all_Exons}; print "contig_id\tcontig_name\texon_id\tstart\tend\tphase\tend_phase\tstrand\tlength\n"; foreach my $exon (@exons){ # if exon is sticky print each component if ( $exon->isa('Bio::EnsEMBL::StickyExon') ){ foreach my $exon_c ( @{$exon->get_all_component_Exons} ){ my $length = $exon_c->end - $exon_c->start +1; print $exon_c->contig->dbID."\t".$exon_c->contig->name."\t". $exon_c->dbID."\t".$exon_c->start."\t".$exon_c->end."\t".$exon_c->phase."\t". $exon_c->end_phase."\t".$exon_c->strand."\t".$length."\n"; &print_evidence($exon_c); print "\n"; } } else{ my $length = $exon->end - $exon->start +1; print $exon->contig->dbID."\t".$exon->contig->name."\t". $exon->dbID."\t".$exon->start."\t".$exon->end."\t".$exon->phase."\t". $exon->end_phase."\t".$exon->strand."\t".$length."\n"; &print_evidence($exon); print "\n"; } } } ############################################################ sub print_evidence{ my $exon = shift; my @evidence = @{$exon->get_all_supporting_features}; if ( @evidence ){ foreach my $evi ( @evidence ){ my $length = $evi->end - $evi->start + 1; my $hlength = $evi->hend - $evi->hstart + 1; print "Evidence: ".$evi->dbID."\t".$evi->contig->dbID."\t".$evi->contig->name."\t". $evi->start."-".$evi->end."\t".$evi->phase."\t". $evi->end_phase."\t".$evi->strand."\t".$length."\t". $evi->hstart."-".$evi->hend."\t".$hlength."\t".$evi->hseqname."\n"; } } else{ print "No evidence\n"; } } ############################################################ sub get_gene_stable_id{ my $db = shift; my $t_id = shift; my $q = qq( SELECT gs.stable_id FROM gene_stable_id gs, transcript t, gene g WHERE t.transcript_id = $t_id AND t.gene_id = g.gene_id AND gs.gene_id = g.gene_id ); my $sth = $db->prepare($q) || $db->throw("can't prepare: $q"); my $res = $sth->execute || $db->throw("can't execute: $q"); return $sth->fetchrow_array; } ############################################################ sub get_gene_id{ my $db = shift; my $t_id = shift; my $q = qq( SELECT g.gene_id FROM transcript t, gene g WHERE t.transcript_id = $t_id AND t.gene_id = g.gene_id ); my $sth = $db->prepare($q) || $db->throw("can't prepare: $q"); my $res = $sth->execute || $db->throw("can't execute: $q"); return $sth->fetchrow_array; }
Ensembl/ensembl-pipeline
scripts/post_GeneBuild/get_transcripts_with_this_evidence.pl
Perl
apache-2.0
5,579
# Copyright 2020, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. package Google::Ads::GoogleAds::V9::Enums::LeadFormDesiredIntentEnum; use strict; use warnings; use Const::Exporter enums => [ UNSPECIFIED => "UNSPECIFIED", UNKNOWN => "UNKNOWN", LOW_INTENT => "LOW_INTENT", HIGH_INTENT => "HIGH_INTENT" ]; 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V9/Enums/LeadFormDesiredIntentEnum.pm
Perl
apache-2.0
834
#!/usr/bin/perl -w use strict; use lib "."; use PAsm; use Data::Dumper; my $resolved_bundles = 0; my $resolved_edges = 0; my $total_ambiguous = 0; sub finalize_node { my $nodeid = shift; my $node = shift; return if !defined $nodeid; return if !defined $node; if (defined $node->{$BUNDLE}) { my %paths; foreach my $b (@{$node->{$BUNDLE}}) { if ($b =~ /^#/) { $b =~ s/^#//; my @path = split /:/, $b; my $startnode = $path[0]; my $endnode = $path[scalar @path - 1]; if ($endnode eq $nodeid) { ## Found a complete path to me push @{$paths{$startnode}->{paths}}, $b; } else { ## bundlemsg, skip } } } foreach my $startnode (keys %paths) { if (scalar @{$paths{$startnode}->{paths}} > 1) { # path is ambiguous $total_ambiguous++; next; } ## found a unique consistent path from startnode to nodeid my $path = $paths{$startnode}->{paths}->[0]; my @hops = reverse split /:/, $path; my $curnode = shift @hops; ## nodeid my $curedge = flip_link($hops[0]); my $ut = substr($curedge,0,1); for(my $i = 0; $i < scalar @hops; $i+=2) { $curedge = flip_link($hops[$i]); $curnode = $hops[$i+1]; push @{$node->{$MATETHREAD}}, "$ut:$curedge:$curnode"; $resolved_edges++; } } $resolved_bundles++; } print_node($nodeid, $node); } while (<>) { #print "==> $_"; chomp; my @vals = split /\t/, $_; my $nodeid = shift @vals; my $msgtype = shift @vals; if ($msgtype ne $NODEMSG) { die "Unknown msg: $_\n"; } my $node = {}; parse_node($node, \@vals); finalize_node($nodeid, $node); } hadoop_counter("resolved_bundles", $resolved_bundles); hadoop_counter("resolved_edges", $resolved_edges); hadoop_counter("total_ambiguous", $total_ambiguous);
julianlau/contrail-emr
prototype/matehopfinalize-reduce.pl
Perl
apache-2.0
1,973
:- module(_, [nrev/2], [assertions,functions,regtypes,nativeprops]). :- function(arith(false)). :- entry nrev/2 : {list, ground} * var. :- check pred nrev(A,B) : list(A) => num(B). :- check comp nrev(_,_) + ( not_fails, is_det, sideff(free) ). :- check comp nrev(A,_) + steps_o( length(A) ). nrev( [] ) := []. nrev( [H|L] ) := ~conc( ~nrev(L),[H] ). :- check comp conc(_,_,_) + ( terminates, non_det ). :- check comp conc(A,_,_) + steps_o(length(A)). conc( [], L ) := L. conc( [H|L], K ) := [ H | ~conc(L,K) ].
leuschel/ecce
www/CiaoDE/ciao/library/functions/examples/revf_assrt_bug.pl
Perl
apache-2.0
528
/***************************************************************************** * This file is part of the Prolog Development Tool (PDT) * * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start * Mail: pdt@lists.iai.uni-bonn.de * Copyright (C): 2013, CS Dept. III, University of Bonn * * All rights reserved. This program is made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * ****************************************************************************/ :- module(outline_demo_multifile_contribution, []). % Multifile contribution for entity outline_demo. % % The outline presents this information with the arrow on the module icon. :- multifile(outline_demo:likes/2). outline_demo:likes(jack_torrance, the_overlook_hotel). own_predicate.
TeamSPoon/logicmoo_base
prolog/logicmoo/pdt_server/PDT Tutorial/outline/outline_demo_multifile_contribution.pl
Perl
mit
879
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package XrefParser::SGDParser; use strict; use warnings; use Carp; use POSIX qw(strftime); use File::Basename; use base qw( XrefParser::BaseParser ); # -------------------------------------------------------------------------------- # Parse command line and run if being run directly sub run { my ($self, $ref_arg) = @_; my $source_id = $ref_arg->{source_id}; my $species_id = $ref_arg->{species_id}; my $files = $ref_arg->{files}; my $verbose = $ref_arg->{verbose}; if((!defined $source_id) or (!defined $species_id) or (!defined $files) ){ croak "Need to pass source_id, species_id and files as pairs"; } $verbose |=0; my $file = @{$files}[0]; my $gene_source_id = $self->get_source_id_for_source_name("SGD_GENE"); #my $transcript_source_id = $self->get_source_id_for_source_name("SGD_TRANSCRIPT"); my $translation_source_id = $self->get_source_id_for_source_name("SGD_TRANSLATION"); my $sgd_io = $self->get_filehandle($file); if ( !defined $sgd_io ) { print STDERR "ERROR: Could not open $file\n"; return 1; # 1 is an error } my $xref_count =0; my $syn_count =0; while ( $_ = $sgd_io->getline() ) { chomp; if ($_ =~ /^([^\t]+)\t([^\t]+)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t[^\t]+\t[^\t]*\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]*\t[^\t]+\t[^\t]+\t([^\t]*)$/) { my ($sgd_id, $biotype, $status, $orf_name, $locus_name, $alias_name, $desc) = ($1,$2,$3,$4,$5,$6,$7); # parse the lines corresponding to the gene entries # and filter out lines corresponding to the CDS for example if ($biotype =~ /ORF|.+RNA|transposable_element_gene|pseudogene/) { if ($verbose) { #print STDERR "parsing line for biotype, $biotype\n"; #print STDERR "sgd_id, biotype, status, orf_name, locus_name, alias_name, $sgd_id, $biotype, $status, $orf_name, $locus_name, $alias_name\n"; #print STDERR "desc: $desc\n"; } if (!defined $locus_name || ($locus_name eq "")) { if (!defined $orf_name || ($orf_name eq "")) { print STDERR "can't assign the orf_name as the locus_name!\n"; } else { if ($verbose) { #print STDERR "assigning the orf_name as the locus_name(ie the gene_name)\n"; } $locus_name = $orf_name; } } my (@syn) = split(/\|/,$alias_name); my $gene_xref_id = $self->add_xref({ acc => $sgd_id, label => $locus_name, desc => $desc, source_id => $gene_source_id, species_id => $species_id, info_type => "DIRECT"} ); $self->add_direct_xref($gene_xref_id, $orf_name, "Gene", "DIRECT"); my $translation_xref_id = $self->add_xref({ acc => $sgd_id, label => $locus_name, desc => $desc, source_id => $translation_source_id, species_id => $species_id, info_type => "DIRECT"} ); $self->add_direct_xref($translation_xref_id, $orf_name, "Translation", "DIRECT"); $xref_count++; foreach my $synonym (@syn){ if ($verbose) { # print STDERR "adding synonym, $synonym\n"; } $self->add_to_syn($sgd_id, $gene_source_id, $synonym, $species_id); $syn_count++; } } else { if ($verbose) { #print STDERR "filtering biotype, $biotype\n"; } } } else { if ($verbose) { print STDERR "failed to parse line, $_\n\n"; } } } $sgd_io->close(); print $xref_count." SGD Xrefs added with $syn_count synonyms\n" if($verbose); return 0; #successful } 1;
mjg17/ensembl
misc-scripts/xref_mapping/XrefParser/SGDParser.pm
Perl
apache-2.0
4,176
package Google::Ads::AdWords::v201406::CustomerFeedService::CustomerFeedServiceInterfacePort; use strict; use warnings; use Class::Std::Fast::Storable; use Scalar::Util qw(blessed); use base qw(SOAP::WSDL::Client::Base); # only load if it hasn't been loaded before require Google::Ads::AdWords::v201406::TypeMaps::CustomerFeedService if not Google::Ads::AdWords::v201406::TypeMaps::CustomerFeedService->can('get_class'); sub START { $_[0]->set_proxy('https://adwords.google.com/api/adwords/cm/v201406/CustomerFeedService') if not $_[2]->{proxy}; $_[0]->set_class_resolver('Google::Ads::AdWords::v201406::TypeMaps::CustomerFeedService') if not $_[2]->{class_resolver}; $_[0]->set_prefix($_[2]->{use_prefix}) if exists $_[2]->{use_prefix}; } sub get { my ($self, $body, $header) = @_; die "get must be called as object method (\$self is <$self>)" if not blessed($self); return $self->SUPER::call({ operation => 'get', soap_action => '', style => 'document', body => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::get )], }, header => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::RequestHeader )], }, headerfault => { } }, $body, $header); } sub mutate { my ($self, $body, $header) = @_; die "mutate must be called as object method (\$self is <$self>)" if not blessed($self); return $self->SUPER::call({ operation => 'mutate', soap_action => '', style => 'document', body => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::mutate )], }, header => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::RequestHeader )], }, headerfault => { } }, $body, $header); } sub query { my ($self, $body, $header) = @_; die "query must be called as object method (\$self is <$self>)" if not blessed($self); return $self->SUPER::call({ operation => 'query', soap_action => '', style => 'document', body => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::query )], }, header => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( Google::Ads::AdWords::v201406::CustomerFeedService::RequestHeader )], }, headerfault => { } }, $body, $header); } 1; __END__ =pod =head1 NAME Google::Ads::AdWords::v201406::CustomerFeedService::CustomerFeedServiceInterfacePort - SOAP Interface for the CustomerFeedService Web Service =head1 SYNOPSIS use Google::Ads::AdWords::v201406::CustomerFeedService::CustomerFeedServiceInterfacePort; my $interface = Google::Ads::AdWords::v201406::CustomerFeedService::CustomerFeedServiceInterfacePort->new(); my $response; $response = $interface->get(); $response = $interface->mutate(); $response = $interface->query(); =head1 DESCRIPTION SOAP Interface for the CustomerFeedService web service located at https://adwords.google.com/api/adwords/cm/v201406/CustomerFeedService. =head1 SERVICE CustomerFeedService =head2 Port CustomerFeedServiceInterfacePort =head1 METHODS =head2 General methods =head3 new Constructor. All arguments are forwarded to L<SOAP::WSDL::Client|SOAP::WSDL::Client>. =head2 SOAP Service methods Method synopsis is displayed with hash refs as parameters. The commented class names in the method's parameters denote that objects of the corresponding class can be passed instead of the marked hash ref. You may pass any combination of objects, hash and list refs to these methods, as long as you meet the structure. List items (i.e. multiple occurences) are not displayed in the synopsis. You may generally pass a list ref of hash refs (or objects) instead of a hash ref - this may result in invalid XML if used improperly, though. Note that SOAP::WSDL always expects list references at maximum depth position. XML attributes are not displayed in this synopsis and cannot be set using hash refs. See the respective class' documentation for additional information. =head3 get Returns a list of customer feeds that meet the selector criteria. @param selector Determines which customer feeds to return. If empty, all customer feeds are returned. @return The list of customer feeds. @throws ApiException Indicates a problem with the request. Returns a L<Google::Ads::AdWords::v201406::CustomerFeedService::getResponse|Google::Ads::AdWords::v201406::CustomerFeedService::getResponse> object. $response = $interface->get( { selector => $a_reference_to, # see Google::Ads::AdWords::v201406::Selector },, ); =head3 mutate Adds, sets, or removes customer feeds. @param operations The operations to apply. @return The resulting feeds. @throws ApiException Indicates a problem with the request. Returns a L<Google::Ads::AdWords::v201406::CustomerFeedService::mutateResponse|Google::Ads::AdWords::v201406::CustomerFeedService::mutateResponse> object. $response = $interface->mutate( { operations => $a_reference_to, # see Google::Ads::AdWords::v201406::CustomerFeedOperation },, ); =head3 query Returns the list of customer feeds that match the query. @param query The SQL-like AWQL query string. @return A list of CustomerFeed. @throws ApiException If problems occur while parsing the query or fetching CustomerFeed. Returns a L<Google::Ads::AdWords::v201406::CustomerFeedService::queryResponse|Google::Ads::AdWords::v201406::CustomerFeedService::queryResponse> object. $response = $interface->query( { query => $some_value, # string },, ); =head1 AUTHOR Generated by SOAP::WSDL on Mon Jun 30 09:52:40 2014 =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/CustomerFeedService/CustomerFeedServiceInterfacePort.pm
Perl
apache-2.0
6,741
package # Date::Manip::TZ::etgmtm00; # Copyright (c) 2008-2014 Sullivan Beck. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # This file was automatically generated. Any changes to this file will # be lost the next time 'tzdata' is run. # Generated on: Fri Nov 21 10:41:45 EST 2014 # Data version: tzdata2014j # Code version: tzcode2014j # This module contains data from the zoneinfo time zone database. The original # data was obtained from the URL: # ftp://ftp.iana.org/tz use strict; use warnings; require 5.010000; our (%Dates,%LastRule); END { undef %Dates; undef %LastRule; } our ($VERSION); $VERSION='6.48'; END { undef $VERSION; } %Dates = ( 1 => [ [ [1,1,2,0,0,0],[1,1,1,23,0,0],'-01:00:00',[-1,0,0], 'GMT-1',0,[9999,12,31,0,0,0],[9999,12,30,23,0,0], '0001010200:00:00','0001010123:00:00','9999123100:00:00','9999123023:00:00' ], ], ); %LastRule = ( ); 1;
nriley/Pester
Source/Manip/TZ/etgmtm00.pm
Perl
bsd-2-clause
1,038
package Bio::Phylo::TreeBASE::Result::Treequality; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use strict; use warnings; use base 'DBIx::Class::Core'; =head1 NAME Bio::Phylo::TreeBASE::Result::Treequality =cut __PACKAGE__->table("treequality"); =head1 ACCESSORS =head2 treequality_id data_type: 'bigint' is_auto_increment: 1 is_nullable: 0 sequence: 'treequality_id_sequence' =head2 version data_type: 'integer' is_nullable: 1 =head2 description data_type: 'varchar' is_nullable: 1 size: 255 =cut __PACKAGE__->add_columns( "treequality_id", { data_type => "bigint", is_auto_increment => 1, is_nullable => 0, sequence => "treequality_id_sequence", }, "version", { data_type => "integer", is_nullable => 1 }, "description", { data_type => "varchar", is_nullable => 1, size => 255 }, ); __PACKAGE__->set_primary_key("treequality_id"); =head1 RELATIONS =head2 phylotrees Type: has_many Related object: L<Bio::Phylo::TreeBASE::Result::Phylotree> =cut __PACKAGE__->has_many( "phylotrees", "Bio::Phylo::TreeBASE::Result::Phylotree", { "foreign.treequality_id" => "self.treequality_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); # Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-11-13 19:19:22 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FeFk1Su85OWlQTqw2r3IvA # You can replace this text with custom content, and it will be preserved on regeneration 1;
TreeBASE/treebasetest
treebase-core/src/main/perl/lib/Bio/Phylo/TreeBASE/Result/Treequality.pm
Perl
bsd-3-clause
1,510
package TAP::Parser::Iterator; use strict; use warnings; use base 'TAP::Object'; =head1 NAME TAP::Parser::Iterator - Base class for TAP source iterators =head1 VERSION Version 3.36 =cut our $VERSION = '3.36_01'; =head1 SYNOPSIS # to subclass: use TAP::Parser::Iterator (); use base 'TAP::Parser::Iterator'; sub _initialize { # see TAP::Object... } sub next_raw { ... } sub wait { ... } sub exit { ... } =head1 DESCRIPTION This is a simple iterator base class that defines L<TAP::Parser>'s iterator API. Iterators are typically created from L<TAP::Parser::SourceHandler>s. =head1 METHODS =head2 Class Methods =head3 C<new> Create an iterator. Provided by L<TAP::Object>. =head2 Instance Methods =head3 C<next> while ( my $item = $iter->next ) { ... } Iterate through it, of course. =head3 C<next_raw> B<Note:> this method is abstract and should be overridden. while ( my $item = $iter->next_raw ) { ... } Iterate raw input without applying any fixes for quirky input syntax. =cut sub next { my $self = shift; my $line = $self->next_raw; # vms nit: When encountering 'not ok', vms often has the 'not' on a line # by itself: # not # ok 1 - 'I hate VMS' if ( defined($line) and $line =~ /^\s*not\s*$/ ) { $line .= ( $self->next_raw || '' ); } return $line; } sub next_raw { require Carp; my $msg = Carp::longmess('abstract method called directly!'); $_[0]->_croak($msg); } =head3 C<handle_unicode> If necessary switch the input stream to handle unicode. This only has any effect for I/O handle based streams. The default implementation does nothing. =cut sub handle_unicode { } =head3 C<get_select_handles> Return a list of filehandles that may be used upstream in a select() call to signal that this Iterator is ready. Iterators that are not handle-based should return an empty list. The default implementation does nothing. =cut sub get_select_handles { return; } =head3 C<wait> B<Note:> this method is abstract and should be overridden. my $wait_status = $iter->wait; Return the C<wait> status for this iterator. =head3 C<exit> B<Note:> this method is abstract and should be overridden. my $wait_status = $iter->exit; Return the C<exit> status for this iterator. =cut sub wait { require Carp; my $msg = Carp::longmess('abstract method called directly!'); $_[0]->_croak($msg); } sub exit { require Carp; my $msg = Carp::longmess('abstract method called directly!'); $_[0]->_croak($msg); } 1; =head1 SUBCLASSING Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview. You must override the abstract methods as noted above. =head2 Example L<TAP::Parser::Iterator::Array> is probably the easiest example to follow. There's not much point repeating it here. =head1 SEE ALSO L<TAP::Object>, L<TAP::Parser>, L<TAP::Parser::Iterator::Array>, L<TAP::Parser::Iterator::Stream>, L<TAP::Parser::Iterator::Process>, =cut
operepo/ope
bin/usr/share/perl5/core_perl/TAP/Parser/Iterator.pm
Perl
mit
3,001
#! /usr/local/bin/perl #--------------------------------------- #Writer : Mico Cheng #Version: 2006011701 #Host : db01.aptg.net #use for: get aptg.net users #--------------------------------------- use DBI; $| = 1; die "./delete_user_mail.pl\n" if (scalar(@ARGV)!=0); $dsn=sprintf("DBI:mysql:%s;host=%s", 'mail_db', '210.200.211.3'); $dbh=DBI->connect($dsn, 'rmail', 'xxxxxxx') || die_db($!); ################## Check MailCheck ############################ $sqlstmt=sprintf("select s_mhost,s_mbox from Suspend where s_mhost !='' OR s_mbox !=''"); $sth2=$dbh->prepare($sqlstmt); $sth2->execute(); if ($sth2->rows==0) { print "Nothing found in Suspend!\n"; $dbh->disconnect(); exit 0; } else { $sth2=$dbh->prepare($sqlstmt); $sth2->execute(); while(@Suspend=$sth2->fetchrow_array) { $cnt++; ($s_mhost,$s_mbox) = (@Suspend); print "$cnt : rm -rf /mnt/$s_mhost/$s_mbox\n"; system "rm -rf /mnt/$s_mhost/$s_mbox\n"; } print "Total User: $cnt\n"; }
TonyChengTW/PerlTools
suspend_user_batch/delete_user_mail.pl
Perl
apache-2.0
1,015
# bind8-lib.pl # Common functions for bind8 config files BEGIN { push(@INC, ".."); }; use WebminCore; my $dnssec_tools_minver = 1.13; my $have_dnssec_tools = eval "require Net::DNS::SEC::Tools::dnssectools;"; if ($have_dnssec_tools) { eval "use Net::DNS::SEC::Tools::dnssectools; use Net::DNS::SEC::Tools::rollmgr; use Net::DNS::SEC::Tools::rollrec; use Net::DNS::SEC::Tools::keyrec; use Net::DNS;"; } &init_config(); do 'records-lib.pl'; @extra_forward = split(/\s+/, $config{'extra_forward'}); @extra_reverse = split(/\s+/, $config{'extra_reverse'}); %is_extra = map { $_, 1 } (@extra_forward, @extra_reverse); %access = &get_module_acl(); $zone_names_cache = "$module_config_directory/zone-names"; $zone_names_version = 3; # Where to find root zones file $internic_ftp_host = "rs.internic.net"; $internic_ftp_ip = "199.7.52.73"; $internic_ftp_file = "/domain/named.root"; $internic_ftp_gzip = "/domain/root.zone.gz"; # Get the version number if (open(VERSION, "$module_config_directory/version")) { chop($bind_version = <VERSION>); close(VERSION); } else { $bind_version = &get_bind_version(); } $dnssec_cron_cmd = "$module_config_directory/resign.pl"; # For automatic DLV setup $dnssec_dlv_zone = "dlv.isc.org."; @dnssec_dlv_key = ( 257, 3, 5, '"BEAAAAPHMu/5onzrEE7z1egmhg/WPO0+juoZrW3euWEn4MxDCE1+lLy2brhQv5rN32RKtMzX6Mj70jdzeND4XknW58dnJNPCxn8+jAGl2FZLK8t+1uq4W+nnA3qO2+DL+k6BD4mewMLbIYFwe0PG73Te9fZ2kJb56dhgMde5ymX4BI/oQ+cAK50/xvJv00Frf8kw6ucMTwFlgPe+jnGxPPEmHAte/URkY62ZfkLoBAADLHQ9IrS2tryAe7mbBZVcOwIeU/Rw/mRx/vwwMCTgNboMQKtUdvNXDrYJDSHZws3xiRXF1Rf+al9UmZfSav/4NWLKjHzpT59k/VStTDN0YUuWrBNh"' ); if ($gconfig{'os_type'} =~ /-linux$/ && -r "/dev/urandom" && !$config{'force_random'}) { $rand_flag = "-r /dev/urandom"; } # have_dnssec_tools_support() # Returns 1 if dnssec-tools support is available and we meet minimum version sub have_dnssec_tools_support { if ($have_dnssec_tools && $Net::DNS::SEC::Tools::rollrec::VERSION >= $dnssec_tools_minver) { # check that the location for the following essential # parameters have been defined : # dnssectools_conf # dnssectools_rollrec # dnssectools_keydir # dnssectools_rollmgr_pidfile return undef if (!$config{'dnssectools_conf'} || !$config{'dnssectools_rollrec'} || !$config{'dnssectools_keydir'} || !$config{'dnssectools_rollmgr_pidfile'}); return 1; } return undef; } # get_bind_version() # Returns the BIND verison number, or undef if unknown sub get_bind_version { my $out = `$config{'named_path'} -v 2>&1`; if ($out =~ /(bind|named)\s+([0-9\.]+)/i) { return $2; } return undef; } # get_config() # Returns an array of references to assocs, each containing the details of # one directive sub get_config { if (!@get_config_cache) { @get_config_cache = &read_config_file($config{'named_conf'}); } return \@get_config_cache; } # get_config_parent([file]) # Returns a structure containing the top-level config as members sub get_config_parent { local $file = $_[0] || $config{'named_conf'}; if (!defined($get_config_parent_cache{$file})) { local $conf = &get_config(); if (!defined($lines_count{$file})) { local $lref = &read_file_lines($file); $lines_count{$file} = @$lref; } $get_config_parent_cache{$file} = { 'file' => $file, 'type' => 1, 'line' => -1, 'eline' => $lines_count{$file}, 'members' => $conf }; } return $get_config_parent_cache{$file}; } # read_config_file(file, [expand includes]) # Reads a config file and returns an array of values sub read_config_file { local($lnum, $line, $cmode, @ltok, @lnum, @tok, @rv, $i, $t, $j, $ifile, @inc, $str); $lnum = 0; open(FILE, &make_chroot($_[0])); while($line = <FILE>) { # strip comments $line =~ s/\r|\n//g; $line =~ s/#.*$//g; $line =~ s/\/\*.*\*\///g; $line =~ s/\/\/.*$//g if ($line !~ /".*\/\/.*"/); while(1) { if (!$cmode && $line =~ /\/\*/) { # start of a C-style comment $cmode = 1; $line =~ s/\/\*.*$//g; } elsif ($cmode) { if ($line =~ /\*\//) { # end of comment $cmode = 0; $line =~ s/^.*\*\///g; } else { $line = ""; last; } } else { last; } } # split line into tokens undef(@ltok); while(1) { if ($line =~ /^\s*\"([^"]*)"(.*)$/) { push(@ltok, $1); $line = $2; } elsif ($line =~ /^\s*([{};])(.*)$/) { push(@ltok, $1); $line = $2; } elsif ($line =~ /^\s*([^{}; \t]+)(.*)$/) { push(@ltok, $1); $line = $2; } else { last; } } foreach $t (@ltok) { push(@tok, $t); push(@lnum, $lnum); } $lnum++; } close(FILE); $lines_count{$_[0]} = $lnum; # parse tokens into data structures $i = 0; $j = 0; while($i < @tok) { $str = &parse_struct(\@tok, \@lnum, \$i, $j++, $_[0]); if ($str) { push(@rv, $str); } } if (!@rv) { # Add one dummy directive, so that the file is known push(@rv, { 'name' => 'dummy', 'line' => 0, 'eline' => 0, 'index' => 0, 'file' => $_[0] }); } if (!$_[1]) { # expand include directives while(&recursive_includes(\@rv, &base_directory(\@rv))) { # This is done repeatedly to handle includes within includes } } return @rv; } # recursive_includes(&dirs, base) sub recursive_includes { local ($i, $j); local $any = 0; for($i=0; $i<@{$_[0]}; $i++) { if (lc($_[0]->[$i]->{'name'}) eq "include") { # found one.. replace the include directive with it $ifile = $_[0]->[$i]->{'value'}; if ($ifile !~ /^\//) { $ifile = "$_[1]/$ifile"; } local @inc = &read_config_file($ifile, 1); # update index of included structures local $j; for($j=0; $j<@inc; $j++) { $inc[$j]->{'index'} += $_[0]->[$i]->{'index'}; } # update index of structures after include for($j=$i+1; $j<@{$_[0]}; $j++) { $_[0]->[$j]->{'index'} += scalar(@inc) - 1; } splice(@{$_[0]}, $i--, 1, @inc); $any++; } elsif ($_[0]->[$i]->{'type'} == 1) { # Check sub-structures too $any += &recursive_includes($_[0]->[$i]->{'members'}, $_[1]); } } return $any; } # parse_struct(&tokens, &lines, &line_num, index, file) # A structure can either have one value, or a list of values. # Pos will end up at the start of the next structure sub parse_struct { local (%str, $i, $j, $t, @vals); $i = ${$_[2]}; $str{'line'} = $_[1]->[$i]; if ($_[0]->[$i] ne '{') { # Has a name $str{'name'} = lc($_[0]->[$i]); } else { # No name, so need to move token pointer back one $i--; } $str{'index'} = $_[3]; $str{'file'} = $_[4]; if ($str{'name'} eq 'inet') { # The inet directive doesn't have sub-structures, just multiple # values with { } in them $str{'type'} = 2; $str{'members'} = { }; while(1) { $t = $_[0]->[++$i]; if ($_[0]->[$i+1] eq "{") { # Start of a named sub-structure .. $i += 2; # skip { $j = 0; while($_[0]->[$i] ne "}") { my $substr = &parse_struct( $_[0], $_[1], \$i, $j++, $_[4]); if ($substr) { $substr->{'parent'} = \%str; push(@{$str{'members'}->{$t}}, $substr); } } next; } elsif ($t eq ";") { last; } push(@vals, $t); } $i++; # skip trailing ; $str{'values'} = \@vals; $str{'value'} = $vals[0]; } else { # Normal directive, like foo bar; or foo bar { smeg; }; while(1) { $t = $_[0]->[++$i]; if ($t eq "{" || $t eq ";" || $t eq "}") { last; } elsif (!defined($t)) { ${$_[2]} = $i; return undef; } else { push(@vals, $t); } } $str{'values'} = \@vals; $str{'value'} = $vals[0]; if ($t eq "{") { # contains sub-structures.. parse them local(@mems, $j); $i++; # skip { $str{'type'} = 1; $j = 0; while($_[0]->[$i] ne "}") { if (!defined($_[0]->[$i])) { ${$_[2]} = $i; return undef; } my $substr = &parse_struct( $_[0], $_[1], \$i, $j++, $_[4]); if ($substr) { $substr->{'parent'} = \%str; push(@mems, $substr); } } $str{'members'} = \@mems; $i += 2; # skip trailing } and ; } else { # only a single value.. $str{'type'} = 0; if ($t eq ";") { $i++; # skip trailing ; } } } $str{'eline'} = $_[1]->[$i-1]; # ending line is the line number the trailing # ; is on ${$_[2]} = $i; return \%str; } # find(name, &array) sub find { local($c, @rv); foreach $c (@{$_[1]}) { if ($c->{'name'} eq $_[0]) { push(@rv, $c); } } return @rv ? wantarray ? @rv : $rv[0] : wantarray ? () : undef; } # find_value(name, &array) sub find_value { local(@v); @v = &find($_[0], $_[1]); if (!@v) { return undef; } elsif (wantarray) { return map { $_->{'value'} } @v; } else { return $v[0]->{'value'}; } } # base_directory([&config], [no-cache]) # Returns the base directory for named files sub base_directory { if ($_[1] || !-r $zone_names_cache) { # Actually work out base local ($opts, $dir, $conf); $conf = $_[0] ? $_[0] : &get_config(); if (($opts = &find("options", $conf)) && ($dir = &find("directory", $opts->{'members'}))) { return $dir->{'value'}; } if ($config{'named_conf'} =~ /^(.*)\/[^\/]+$/ && $1) { return $1; } return "/etc"; } else { # Use cache local %znc; &read_file_cached($zone_names_cache, \%znc); return $znc{'base'} || &base_directory($_[0], 1); } } # save_directive(&parent, name|&olds, &values, indent, [structonly]) # Given a structure containing a directive name, type, values and members # add, update or remove that directive in config structure and data files. # Updating of files assumes that there is no overlap between directives - # each line in the config file must contain part or all of only one directive. sub save_directive { local(@oldv, @newv, $pm, $i, $o, $n, $lref, @nl); $pm = $_[0]->{'members'}; @oldv = ref($_[1]) ? @{$_[1]} : &find($_[1], $pm); @newv = @{$_[2]}; for($i=0; $i<@oldv || $i<@newv; $i++) { local $oldeline = $i<@oldv ? $oldv[$i]->{'eline'} : undef; if ($i < @newv) { # Make sure new directive has 'value' set local @v = @{$newv[$i]->{'values'}}; $newv[$i]->{'value'} = @v ? $v[0] : undef; } if ($i >= @oldv && !$_[5]) { # a new directive is being added.. put it at the end of # the parent if (!$_[4]) { local $addfile = $newv[$i]->{'file'} || $_[0]->{'file'}; local $parent = &get_config_parent($addfile); $lref = &read_file_lines(&make_chroot($addfile)); @nl = &directive_lines($newv[$i], $_[3]); splice(@$lref, $_[0]->{'eline'}, 0, @nl); $newv[$i]->{'file'} = $_[0]->{'file'}; $newv[$i]->{'line'} = $_[0]->{'eline'}; $newv[$i]->{'eline'} = $_[0]->{'eline'} + scalar(@nl) - 1; &renumber($parent, $_[0]->{'eline'}-1, $_[0]->{'file'}, scalar(@nl)); } push(@$pm, $newv[$i]); } elsif ($i >= @oldv && $_[5]) { # a new directive is being added.. put it at the start of # the parent if (!$_[4]) { local $parent = &get_config_parent($newv[$i]->{'file'} || $_[0]->{'file'}); $lref = &read_file_lines( &make_chroot($newv[$i]->{'file'} || $_[0]->{'file'})); @nl = &directive_lines($newv[$i], $_[3]); splice(@$lref, $_[0]->{'line'}+1, 0, @nl); $newv[$i]->{'file'} = $_[0]->{'file'}; $newv[$i]->{'line'} = $_[0]->{'line'}+1; $newv[$i]->{'eline'} = $_[0]->{'line'} + scalar(@nl); &renumber($parent, $_[0]->{'line'}, $_[0]->{'file'}, scalar(@nl)); } splice(@$pm, 0, 0, $newv[$i]); } elsif ($i >= @newv) { # a directive was deleted if (!$_[4]) { local $parent = &get_config_parent($oldv[$i]->{'file'}); $lref = &read_file_lines( &make_chroot($oldv[$i]->{'file'})); $ol = $oldv[$i]->{'eline'} - $oldv[$i]->{'line'} + 1; splice(@$lref, $oldv[$i]->{'line'}, $ol); &renumber($parent, $oldeline, $oldv[$i]->{'file'}, -$ol); } splice(@$pm, &indexof($oldv[$i], @$pm), 1); } else { # updating some directive if (!$_[4]) { local $parent = &get_config_parent($oldv[$i]->{'file'}); $lref = &read_file_lines( &make_chroot($oldv[$i]->{'file'})); @nl = &directive_lines($newv[$i], $_[3]); $ol = $oldv[$i]->{'eline'} - $oldv[$i]->{'line'} + 1; splice(@$lref, $oldv[$i]->{'line'}, $ol, @nl); $newv[$i]->{'file'} = $_[0]->{'file'}; $newv[$i]->{'line'} = $oldv[$i]->{'line'}; $newv[$i]->{'eline'} = $oldv[$i]->{'line'} + scalar(@nl) - 1; &renumber($parent, $oldeline, $oldv[$i]->{'file'}, scalar(@nl) - $ol); } $pm->[&indexof($oldv[$i], @$pm)] = $newv[$i]; } } } # directive_lines(&directive, tabs) # Renders some directive into a number of lines of text sub directive_lines { local(@rv, $v, $m, $i); $rv[0] = "\t" x $_[1]; $rv[0] .= "$_[0]->{'name'}"; foreach $v (@{$_[0]->{'values'}}) { if ($need_quote{$_[0]->{'name'}} && !$i) { $rv[0] .= " \"$v\""; } else { $rv[0] .= " $v"; } $i++; } if ($_[0]->{'type'} == 1) { # multiple values.. include them as well $rv[0] .= " {"; foreach $m (@{$_[0]->{'members'}}) { push(@rv, &directive_lines($m, $_[1]+1)); } push(@rv, ("\t" x ($_[1]+1))."}"); } elsif ($_[0]->{'type'} == 2) { # named sub-structures .. include them too foreach my $sn (sort { $a cmp $b } (keys %{$_[0]->{'members'}})) { $rv[0] .= " ".$sn." {"; foreach $m (@{$_[0]->{'members'}->{$sn}}) { $rv[0] .= " ".join(" ", &directive_lines($m, 0)); } $rv[0] .= " }"; } } $rv[$#rv] .= ";"; return @rv; } # renumber(&parent, line, file, count) # Runs through the given array of directives and increases the line numbers # of all those greater than some line by the given count sub renumber { if ($_[0]->{'file'} eq $_[2]) { if ($_[0]->{'line'} > $_[1]) { $_[0]->{'line'} += $_[3]; } if ($_[0]->{'eline'} > $_[1]) { $_[0]->{'eline'} += $_[3]; } } if ($_[0]->{'type'} == 1) { # Do sub-members local $d; foreach $d (@{$_[0]->{'members'}}) { &renumber($d, $_[1], $_[2], $_[3]); } } elsif ($_[0]->{'type'} == 2) { # Do sub-members local ($sm, $d); foreach $sm (keys %{$_[0]->{'members'}}) { foreach $d (@{$_[0]->{'members'}->{$sm}}) { &renumber($d, $_[1], $_[2], $_[3]); } } } } # choice_input(text, name, &config, [display, option]+) # Returns a table row for a multi-value BIND option sub choice_input { my $v = &find_value($_[1], $_[2]); my @opts; for(my $i=3; $i<@_; $i+=2) { push(@opts, [ $_[$i+1], $_[$i] ]); } return &ui_table_row($_[0], &ui_radio($_[1], $v, \@opts)); } # save_choice(name, &parent, indent) # Updates the config from a multi-value option sub save_choice { local($nd); if ($in{$_[0]}) { $nd = { 'name' => $_[0], 'values' => [ $in{$_[0]} ] }; } &save_directive($_[1], $_[0], $nd ? [ $nd ] : [ ], $_[2]); } # addr_match_input(text, name, &config) # A field for editing a list of addresses, ACLs and partial IP addresses sub addr_match_input { my @av; my $v = &find($_[1], $_[2]); if ($v) { foreach my $av (@{$v->{'members'}}) { push(@av, join(" ", $av->{'name'}, @{$av->{'values'}})); } } return &ui_table_row($_[0], &ui_radio("$_[1]_def", $v ? 0 : 1, [ [ 1, $text{'default'} ], [ 0, $text{'listed'} ] ])."<br>". &ui_textarea($_[1], join("\n", @av), 3, 50)); } # save_addr_match(name, &parent, indent) sub save_addr_match { local($addr, @vals, $dir); if ($in{"$_[0]_def"}) { &save_directive($_[1], $_[0], [ ], $_[2]); } else { $in{$_[0]} =~ s/\r//g; foreach $addr (split(/\n+/, $in{$_[0]})) { local ($n, @v) = split(/\s+/, $addr); push(@vals, { 'name' => $n, 'values' => \@v }); } $dir = { 'name' => $_[0], 'type' => 1, 'members' => \@vals }; &save_directive($_[1], $_[0], [ $dir ], $_[2]); } } # address_port_input(addresstext, portlabeltext, portnametext, defaulttext, # addressname, portname, &config, size, type) # Returns table fields for address and a port number sub address_port_input { # Address, using existing function my $rv = &address_input($_[0], $_[4], $_[6], $_[8]); my $v = &find($_[4], $_[6]); my $port; for ($i = 0; $i < @{$v->{'values'}}; $i++) { if ($v->{'values'}->[$i] eq $_[5]) { $port = $v->{'values'}->[$i+1]; last; } } # Port part my $n; ($n = $_[5]) =~ s/[^A-Za-z0-9_]/_/g; $rv .= &ui_table_row($_[1], &ui_opt_textbox($n, $port, $_[7], $_[3], $_[2])); return $rv; } # address_input(text, name, &config, type) sub address_input { local($v, $av, @av); $v = &find($_[1], $_[2]); foreach $av (@{$v->{'members'}}) { push(@av, join(" ", $av->{'name'}, @{$av->{'values'}})); } if ($_[3] == 0) { # text area return &ui_table_row($_[0], &ui_textarea($_[1], join("\n", @av), 3, 50)); } else { # text row return &ui_table_row($_[0], &ui_textbox($_[1], join(' ',@av), 50)); } } # save_port_address(name, portname, &config, indent) sub save_port_address { local($addr, $port, @vals, $dir); foreach $addr (split(/\s+/, $in{$_[0]})) { $addr =~ /^\S+$/ || &error(&text('eipacl', $addr)); push(@vals, { 'name' => $addr }); } $dir = { 'name' => $_[0], 'type' => 1, 'members' => \@vals }; ($n = $_[1]) =~ s/[^A-Za-z0-9_]/_/g; $dir->{'values'} = [ $_[1], $in{$_[1]} ] if (!$in{"${n}_def"}); &save_directive($_[2], $_[0], @vals ? [ $dir ] : [ ], $_[3]); } # save_address(name, &parent, indent, ips-only) sub save_address { local ($addr, @vals, $dir, $i); local @sp = split(/\s+/, $in{$_[0]}); for($i=0; $i<@sp; $i++) { !$_[3] || &check_ipaddress($sp[$i]) || &error(&text('eip', $sp[$i])); if (lc($sp[$i]) eq "key") { push(@vals, { 'name' => $sp[$i], 'values' => [ $sp[++$i] ] }); } else { push(@vals, { 'name' => $sp[$i] }); } } $dir = { 'name' => $_[0], 'type' => 1, 'members' => \@vals }; &save_directive($_[1], $_[0], @vals ? [ $dir ] : [ ], $_[2]); } # forwarders_input(text, name, &config) # Returns a form field containing a table of forwarding IPs and ports sub forwarders_input { my $v = &find($_[1], $_[2]); my (@ips, @prs); foreach my $av (@{$v->{'members'}}) { push(@ips, $av->{'name'}); if ($av->{'values'}->[0] eq 'port') { push(@prs, $av->{'values'}->[1]); } else { push(@prs, undef); } } my @table; for(my $i=0; $i<@ips+3; $i++) { push(@table, [ &ui_textbox("$_[1]_ip_$i", $ips[$i], 20), &ui_opt_textbox("$_[1]_pr_$i", $prs[$i], 5, $text{'default'}), ]); } return &ui_table_row($_[0], &ui_columns_table([ $text{'forwarding_ip'}, $text{'forwarding_port'} ], undef, \@table, undef, 1), 3); } # save_forwarders(name, &parent, indent) sub save_forwarders { local ($i, $ip, $pr, @vals); for($i=0; defined($ip = $in{"$_[0]_ip_$i"}); $i++) { next if (!$ip); &check_ipaddress($ip) || &check_ip6address($ip) || &error(&text('eip', $ip)); $pr = $in{"$_[0]_pr_${i}_def"} ? undef : $in{"$_[0]_pr_$i"}; !$pr || $pr =~ /^\d+$/ || &error(&text('eport', $pr)); push(@vals, { 'name' => $ip, 'values' => $pr ? [ "port", $pr ] : [ ] }); } local $dir = { 'name' => $_[0], 'type' => 1, 'members' => \@vals }; &save_directive($_[1], $_[0], @vals ? [ $dir ] : [ ], $_[2]); } # opt_input(text, name, &config, default, size, units) # Returns a table row with an optional text field sub opt_input { my $v = &find($_[1], $_[2]); my $n; ($n = $_[1]) =~ s/[^A-Za-z0-9_]/_/g; return &ui_table_row($_[0], &ui_opt_textbox($n, $v ? $v->{'value'} : "", $_[4], $_[3])." ".$_[5], $_[4] > 30 ? 3 : 1); } sub save_opt { local($dir, $n); ($n = $_[0]) =~ s/[^A-Za-z0-9_]/_/g; if ($in{"${n}_def"}) { &save_directive($_[2], $_[0], [ ], $_[3]); } elsif ($err = &{$_[1]}($in{$n})) { &error($err); } else { $dir = { 'name' => $_[0], 'values' => [ $in{$n} ] }; &save_directive($_[2], $_[0], [ $dir ], $_[3]); } } # directives that need their value to be quoted @need_quote = ( "file", "zone", "view", "pid-file", "statistics-file", "dump-file", "named-xfer", "secret" ); foreach $need (@need_quote) { $need_quote{$need}++; } 1; # find_reverse(address, [view]) # Returns the zone and record structures for the PTR record for some address sub find_reverse { local($conf, @zl, $rev, $z, $revconf, $revfile, $revrec, @revrecs, $addr, $rr, @octs, $i, @hexs, $ipv6, @zero); # find reverse domain local @zl = grep { $_->{'type'} ne 'view' } &list_zone_names(); if ($_[1] ne '' && $_[1] ne 'any') { @zl = grep { $_->{'view'} && $_->{'viewindex'} == $_[1] } @zl; } else { @zl = grep { !$_->{'view'} } @zl; } $ipv6 = $config{'support_aaaa'} && &check_ip6address($_[0]); if ($ipv6) { @zero = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); $addr = &expandall_ip6($_[0]); $addr =~ s/://g; @hexs = split('', $addr); DOMAIN: for($i=30; $i>=0; $i--) { $addr = join(':',split(/(.{4})/,join('', (@hexs[0..$i],@zero[$i..30])))); $addr =~ s/::/:/g; $addr =~ s/(^:|:$)//g; $rev = &net_to_ip6int($addr, 4*($i+1)); $rev =~ s/\.$//g; foreach $z (@zl) { if (lc($z->{'name'}) eq $rev && $z->{'type'} eq 'master') { # found the reverse master domain $revconf = $z; last DOMAIN; } } } } else { @octs = split(/\./, $_[0]); DOMAIN: for($i=2; $i>=-1; $i--) { $rev = $i<0 ? "in-addr.arpa" : &ip_to_arpa(join('.', @octs[0..$i])); $rev =~ s/\.$//g; foreach $z (@zl) { if ((lc($z->{'name'}) eq $rev || lc($z->{'name'}) eq "$rev.") && $z->{'type'} eq "master") { # found the reverse master domain $revconf = $z; last DOMAIN; } } } } # find reverse record if ($revconf) { $revfile = &absolute_path($revconf->{'file'}); @revrecs = &read_zone_file($revfile, $revconf->{'name'}); if ($ipv6) { $addr = &net_to_ip6int($_[0], 128); } else { $addr = &ip_to_arpa($_[0]); } foreach $rr (@revrecs) { if ($rr->{'type'} eq "PTR" && lc($rr->{'name'}) eq lc($addr)) { # found the reverse record $revrec = $rr; last; } } } return ($revconf, $revfile, $revrec); } # find_forward(address, [view]) # Returns the zone and record structures for the A record for some address sub find_forward { local ($fwdconf, $i, $fwdfile, $fwdrec, $fr, $ipv6); # find forward domain local $host = $_[0]; $host =~ s/\.$//; local @zl = grep { $_->{'type'} ne 'view' } &list_zone_names(); if ($_[1] ne '' && $_[1] ne 'any') { @zl = grep { $_->{'view'} && $_->{'viewindex'} == $_[1] } @zl; } else { @zl = grep { !$_->{'view'} } @zl; } local @parts = split(/\./, $host); DOMAIN: for($i=1; $i<@parts; $i++) { local $fwd = join(".", @parts[$i .. @parts-1]); foreach $z (@zl) { local $typed; if ((lc($z->{'name'}) eq $fwd || lc($z->{'name'}) eq "$fwd.") && $z->{'type'} eq "master") { # Found the forward master! $fwdconf = $z; last DOMAIN; } } } # find forward record if ($fwdconf) { $fwdfile = &absolute_path($fwdconf->{'file'}); local @fwdrecs = &read_zone_file($fwdfile, $fwdconf->{'name'}); foreach $fr (@fwdrecs) { if ($ipv6 ? $fr->{'type'} eq "AAAA" : $fr->{'type'} eq "A" && $fr->{'name'} eq $_[0]) { # found the forward record! $fwdrec = $fr; last; } } } return ($fwdconf, $fwdfile, $fwdrec); } # can_edit_zone(&zone, [&view] | &cachedzone) # Returns 1 if some zone can be edited sub can_edit_zone { local %zcan; local ($zn, $vn, $file); if ($_[0]->{'members'}) { # A full zone structure $zn = $_[0]->{'value'}; $vn = $_[1] ? 'view_'.$_[1]->{'value'} : undef; $file = &find_value("file", $_[0]->{'members'}); } else { # A cached zone object $zn = $_[0]->{'name'}; $vn = $_[0]->{'view'} eq '*' ? undef : $_[0]->{'view'}; $file = $_[0]->{'file'}; } # Check zone name if ($access{'zones'} eq '*') { # Always can } elsif ($access{'zones'} =~ /^\!/) { # List of denied zones foreach (split(/\s+/, $access{'zones'})) { return 0 if ($_ eq $zn || ($vn && $_ eq $vn)); } } else { # List of allowed zones local $ok; foreach my $z (split(/\s+/, $access{'zones'})) { $ok++ if ($z eq $zn || ($vn && $z eq "view_".$vn)); } return 0 if (!$ok); } # Check allowed view if ($access{'inviews'} eq '*') { # All views are OK } else { local $ok; foreach my $v (split(/\s+/, $access{'inviews'})) { $ok++ if ($v eq ($vn || "_")); } return 0 if (!$ok); } if ($access{'dironly'}) { # Check directory access control return 1 if (!$file); $file = &absolute_path($file); return 0 if (!&allowed_zone_file(\%access, $file)); } return 1; } # can_edit_reverse(&zone) sub can_edit_reverse { return $access{'reverse'} || &can_edit_zone($_[0]); } # record_input(zone-name, view, type, file, origin, [num], [record], # [new-name, new-value]) # Display a form for editing or creating a DNS record sub record_input { local(%rec, @recs, $ttl, $ttlunit); local $type = $_[6] ? $_[6]->{'type'} : $_[2]; print &ui_form_start("save_record.cgi"); print &ui_hidden("zone", $_[0]); print &ui_hidden("view", $_[1]); print &ui_hidden("file", $_[3]); print &ui_hidden("origin", $_[4]); print &ui_hidden("sort", $in{'sort'}); if (defined($_[5])) { print &ui_hidden("num", $_[5]); %rec = %{$_[6]}; print &ui_hidden("id", &record_id(\%rec)); } else { print &ui_hidden("new", 1); $rec{'name'} = $_[7] if ($_[7]); $rec{'values'} = [ $_[8] ] if ($_[8]); } print &ui_hidden("type", $type); print &ui_hidden("redirtype", $_[2]); print &ui_table_start(&text(defined($_[5]) ? 'edit_edit' : 'edit_add', $text{"edit_".$type})); # Record name field(s) if ($type eq "PTR") { print &ui_table_row($text{'edit_addr'}, &ui_textbox("name", !%rec && $_[4] =~ /^(\d+)\.(\d+)\.(\d+)\.in-addr/ ? "$3.$2.$1." : &ip6int_to_net(&arpa_to_ip($rec{'name'})), 30)); } elsif ($type eq "NS") { print &ui_table_row($text{'edit_zonename'}, &ui_textbox("name", $rec{'name'}, 30)); } elsif ($type eq "SRV") { local ($serv, $proto, $name) = $rec{'name'} =~ /^([^\.]+)\.([^\.]+)\.(\S+)/ ? ($1, $2, $3) : (undef, undef, undef); $serv =~ s/^_//; $proto =~ s/^_//; print &ui_table_row($text{'edit_name'}, &ui_textbox("name", $name, 30)); print &ui_table_row($text{'edit_proto'}, &ui_select("proto", $proto, [ [ "tcp", "TCP" ], [ "udp", "UDP" ], [ "tls", "TLS" ] ], undef, undef, 1)); print &ui_table_row($text{'edit_serv'}, &ui_textbox("serv", $serv, 20)); } else { print &ui_table_row($text{'edit_name'}, &ui_textbox("name", $rec{'name'}, 30)); } # Show canonical name too, if not auto-converted if ($config{'short_names'} && defined($_[5])) { print &ui_table_row($text{'edit_canon'}, "<tt>$rec{'canon'}</tt>"); } # TTL field if ($rec{'ttl'} =~ /^(\d+)([SMHDW]?)$/i) { $ttl = $1; $ttlunit = $2; } else { $ttl = $rec{'ttl'}; $ttlunit = ""; } print &ui_table_row($text{'edit_ttl'}, &ui_opt_textbox("ttl", $ttl, 8, $text{'default'})." ". &time_unit_choice("ttlunit", $ttlunit)); # Value(s) fields @v = @{$rec{'values'}}; if ($type eq "A" || $type eq "AAAA") { print &ui_table_row($text{'value_A1'}, &ui_textbox("value0", $v[0], 20)." ". (!defined($_[5]) && $type eq "A" ? &free_address_button("value0") : ""), 3); if (defined($_[5])) { print &ui_hidden("oldname", $rec{'name'}); print &ui_hidden("oldvalue0", $v[0]); } } elsif ($type eq "NS") { print &ui_table_row($text{'value_NS1'}, &ui_textbox("value0", $v[0], 30)." ($text{'edit_cnamemsg'})", 3); } elsif ($type eq "CNAME") { print &ui_table_row($text{'value_CNAME1'}, &ui_textbox("value0", $v[0], 30)." ($text{'edit_cnamemsg'})", 3); } elsif ($type eq "MX") { print &ui_table_row($text{'value_MX2'}, &ui_textbox("value1", $v[1], 30)); print &ui_table_row($text{'value_MX1'}, &ui_textbox("value0", $v[0], 8)); } elsif ($type eq "HINFO") { print &ui_table_row($text{'value_HINFO1'}, &ui_textbox("value0", $v[0], 20)); print &ui_table_row($text{'value_HINFO2'}, &ui_textbox("value1", $v[1], 20)); } elsif ($type eq "TXT") { print &ui_table_row($text{'value_TXT1'}, &ui_textarea("value0", join("", @v), 5, 80, "soft"), 3); } elsif ($type eq "WKS") { # Well known server print &ui_table_row($text{'value_WKS1'}, &ui_textbox("value0", $v[0], 15)); print &ui_table_row($text{'value_WKS2'}, &ui_select("value1", lc($v[1]), [ [ "tcp", "TCP" ], [ "udp", "UDP" ] ])); print &ui_table_row($text{'value_WKS3'}, &ui_textarea("value2", join(' ', @v[2..$#v]), 3, 20)); } elsif ($type eq "RP") { # Responsible person print &ui_table_row($text{'value_RP1'}, &ui_textbox("value0", &dotted_to_email($v[0]), 20)); print &ui_table_row($text{'value_RP2'}, &ui_textbox("value1", $v[1], 30)); } elsif ($type eq "PTR") { # Reverse address print &ui_table_row($text{'value_PTR1'}, &ui_textbox("value0", $v[0], 30), 3); if (defined($_[5])) { print &ui_hidden("oldname", $rec{'name'}); print &ui_hidden("oldvalue0", $v[0]); } } elsif ($type eq "SRV") { print &ui_table_row($text{'value_SRV1'}, &ui_textbox("value0", $v[0], 8)); print &ui_table_row($text{'value_SRV2'}, &ui_textbox("value1", $v[1], 8)); print &ui_table_row($text{'value_SRV3'}, &ui_textbox("value2", $v[2], 8)); print &ui_table_row($text{'value_SRV4'}, &ui_textbox("value3", $v[3], 30)); } elsif ($type eq "LOC") { print &ui_table_row($text{'value_LOC1'}, &ui_textbox("value0", join(" ", @v), 40), 3); } elsif ($type eq "KEY") { print &ui_table_row($text{'value_KEY1'}, &ui_textbox("value0", $v[0], 8)); print &ui_table_row($text{'value_KEY2'}, &ui_textbox("value1", $v[1], 8)); print &ui_table_row($text{'value_KEY3'}, &ui_textbox("value2", $v[2], 8)); print &ui_table_row($text{'value_KEY4'}, &ui_textarea("value3", join("\n", &wrap_lines($v[3], 80)), 5, 80), 3); } elsif ($type eq "SPF") { # SPF records are complex, as they have several attributes encoded # in the TXT value local $spf = &parse_spf(@v); print &ui_table_row($text{'value_spfa'}, &ui_yesno_radio("spfa", $spf->{'a'} ? 1 : 0), 3); print &ui_table_row($text{'value_spfmx'}, &ui_yesno_radio("spfmx", $spf->{'mx'} ? 1 : 0), 3); print &ui_table_row($text{'value_spfptr'}, &ui_yesno_radio("spfptr", $spf->{'ptr'} ? 1 : 0), 3); print &ui_table_row($text{'value_spfas'}, &ui_textarea("spfas", join("\n", @{$spf->{'a:'}}), 3, 40), 3); print &ui_table_row($text{'value_spfmxs'}, &ui_textarea("spfmxs", join("\n", @{$spf->{'mx:'}}), 3, 40), 3); print &ui_table_row($text{'value_spfip4s'}, &ui_textarea("spfip4s", join("\n", @{$spf->{'ip4:'}}), 3, 40), 3); if (&supports_ipv6()) { print &ui_table_row($text{'value_spfip6s'}, &ui_textarea("spfip6s", join("\n", @{$spf->{'ip6:'}}), 3, 40), 3); } print &ui_table_row($text{'value_spfincludes'}, &ui_textarea("spfincludes", join("\n", @{$spf->{'include:'}}), 3, 40), 3); print &ui_table_row($text{'value_spfall'}, &ui_select("spfall", int($spf->{'all'}), [ [ 3, $text{'value_spfall3'} ], [ 2, $text{'value_spfall2'} ], [ 1, $text{'value_spfall1'} ], [ 0, $text{'value_spfall0'} ], [ undef, $text{'value_spfalldef'} ] ]), 3); print &ui_table_row($text{'value_spfredirect'}, &ui_opt_textbox("spfredirect", $spf->{'redirect'}, 40, $text{'value_spfnoredirect'}), 3); print &ui_table_row($text{'value_spfexp'}, &ui_opt_textbox("spfexp", $spf->{'exp'}, 40, $text{'value_spfnoexp'}), 3); } elsif ($type eq "DMARC") { # Like SPF, DMARC records have several attributes encoded in the # TXT value local $dmarc = &parse_dmarc(@v); local @popts = ( [ "none", $text{'value_dmarcnone'} ], [ "quarantine", $text{'value_dmarcquar'} ], [ "reject", $text{'value_dmarcreject'} ] ); print &ui_table_row($text{'value_dmarcp'}, &ui_select("dmarcp", $dmarc->{'p'}, \@popts)); print &ui_table_row($text{'value_dmarcpct'}, &ui_textbox("dmarcpct", $dmarc->{'pct'}, 5)."%"); print &ui_table_row($text{'value_dmarcsp'}, &ui_select("dmarcsp", $dmarc->{'sp'}, [ [ "", $text{'value_dmarcnop'} ], @popts ])); print &ui_table_row($text{'value_dmarcaspf'}, &ui_yesno_radio("dmarcaspf", $dmarc->{'aspf'} eq 's')); print &ui_table_row($text{'value_dmarcadkim'}, &ui_yesno_radio("dmarcadkim", $dmarc->{'adkim'} eq 's')); local $rua = $dmarc->{'rua'}; $rua =~ s/^mailto://; print &ui_table_row($text{'value_dmarcrua'}, &ui_opt_textbox("dmarcrua", $rua, 50, $text{'value_dmarcnor'}), 3); local $ruf = $dmarc->{'ruf'}; $ruf =~ s/^mailto://; print &ui_table_row($text{'value_dmarcruf'}, &ui_opt_textbox("dmarcruf", $ruf, 50, $text{'value_dmarcnor'}), 3); } elsif ($type eq "NSEC3PARAM") { # NSEC records have a hash type, flags, number of interations, salt # length and salt print &ui_table_row($text{'value_NSEC3PARAM1'}, &ui_select("value0", $v[0] || 1, [ [ 1, "SHA1" ] ], 1, 0, 1)); print &ui_table_row($text{'value_NSEC3PARAM2'}, &ui_select("value1", $v[1], [ [ 0, $text{'value_delegated'} ], [ 1, $text{'value_notdelegated'} ] ])); print &ui_table_row($text{'value_NSEC3PARAM3'}, &ui_textbox("value2", $v[2], 4)); print &ui_table_row($text{'value_NSEC3PARAM5'}, &ui_textbox("value4", $v[4], 20)); } else { # All other types just have a text box print &ui_table_row($text{'value_other'}, &ui_textarea("values", join("\n", @v), 3, 40), 3); } # Comment field if ($type ne "WKS") { if ($config{'allow_comments'}) { print &ui_table_row($text{'edit_comment'}, &ui_textbox("comment", $rec{'comment'}, 40), 3); } else { print &ui_hidden("comment", $rec{'comment'}); } } # Update reverse/forward option if ($type eq "A" || $type eq "AAAA") { print &ui_table_row($text{'edit_uprev'}, &ui_radio("rev", $config{'rev_def'} == 0 ? 1 : $config{'rev_def'} == 2 ? 2 : 0, [ [ 1, $text{'yes'} ], defined($_[5]) ? ( ) : ( [ 2, $text{'edit_over'} ] ), [ 0, $text{'no'} ] ])); } elsif ($type eq "PTR") { print &ui_table_row($text{'edit_upfwd'}, &ui_radio("fwd", $config{'rev_def'} ? 0 : 1, [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ])); } print &ui_table_end(); # End buttons if (!$access{'ro'}) { if (defined($_[5])) { print &ui_form_end([ [ undef, $text{'save'} ], [ "delete", $text{'delete'} ] ]); } else { print &ui_form_end([ [ undef, $text{'create'} ] ]); } } } # zones_table(&links, &titles, &types, &deletes, &status) # Returns a table of zones, with checkboxes to delete sub zones_table { local($i); local @tds = ( "width=5" ); local $rv; if (&have_dnssec_tools_support()) { $rv .= &ui_columns_start([ "", $text{'index_zone'}, $text{'index_type'}, $text{'index_status'} ], 100, 0, \@tds); } else { $rv .= &ui_columns_start([ "", $text{'index_zone'}, $text{'index_type'} ], 100, 0, \@tds); } for($i=0; $i<@{$_[0]}; $i++) { local @cols; if (&have_dnssec_tools_support()) { @cols = ( &ui_link($_[0]->[$i], $_[1]->[$i]), $_[2]->[$i], $_[4]->[$i] ); } else { @cols = ( &ui_link($_[0]->[$i], $_[1]->[$i]), $_[2]->[$i] ); } if (defined($_[3]->[$i])) { $rv .= &ui_checked_columns_row(\@cols, \@tds, "d", $_[3]->[$i]); } else { $rv .= &ui_columns_row(\@cols, \@tds); } } $rv .= &ui_columns_end(); return $rv; } sub check_net_ip { local($j, $arg = $_[0]); if ($arg !~ /^(\d{1,3}\.){0,3}([0-9\-\/]+)$/) { return 0; } foreach $j (split(/\./, $arg)) { $j =~ /^(\d+)-(\d+)$/ && $1 < 255 && $2 < 255 || $j =~ /^(\d+)\/(\d+)$/ && $1 < 255 && $2 <= 32 || $j <= 255 || return 0; } return 1; } # expand_ip6(ip) # Transform compact (with ::) IPv6 address to the unique expanded form # (without :: and leading zeroes in all parts) sub expand_ip6 { my ($ip) = @_; for(my $n = 6 - ($ip =~ s/([^:]):(?=[^:])/$1:/g); $n > 0; $n--) { $ip =~ s/::/:0::/; } $ip =~ s/::/:/; $ip =~ s/^:/0:/; $ip =~ s/:$/:0/; $ip =~ s/(:|^)0(?=\w)/$1/; $ip =~ tr/[A-Z]/[a-z]/; return $ip; } # expandall_ip6(ip) # Transform IPv6 address to the expanded form containing all internal 0's sub expandall_ip6 { my ($ip) = @_; $ip = &expand_ip6($ip); $ip =~ s/(:|^)(\w{3})(?=:|$)/:0$2/g; $ip =~ s/(:|^)(\w{2})(?=:|$)/:00$2/g; $ip =~ s/(:|^)(\w)(?=:|$)/:000$2/g; return $ip; } # check_ip6address(ip) # Check if some IPv6 address is properly formatted sub check_ip6address { local($ip6); $ip6 = $_[0]; $ip6 = &expand_ip6($ip6); return ($ip6 =~ /^([\da-f]{1,4}:){7}([\da-f]{1,4})$/i); } sub time_unit_choice { local ($name, $value) = @_; return &ui_select($name, $value =~ /^(S?)$/i ? "" : $value =~ /M/i ? "M" : $value =~ /H/i ? "H" : $value =~ /D/i ? "D" : $value =~ /W/i ? "W" : $value, [ [ "", $text{'seconds'} ], [ "M", $text{'minutes'} ], [ "H", $text{'hours'} ], [ "D", $text{'days'} ], [ "W", $text{'weeks'} ] ], 1, 0, 1); } sub extract_time_units { local(@ret); foreach $j (@_) { if ($j =~ /^(\d+)([SMHDW]?)$/is) { push(@ret, $2); $j = $1; } } return @ret; } sub email_to_dotted { local $v = $_[0]; $v =~ s/\.$//; if ($v =~ /^([^.]+)\@(.*)$/) { return "$1.$2."; } elsif ($v =~ /^(.*)\@(.*)$/) { local ($u, $d) = ($1, $2); $u =~ s/\./\\\./g; return "\"$u.$d.\""; } else { return $v; } } sub dotted_to_email { local $v = $_[0]; if ($v ne ".") { $v =~ s/([^\\])\./$1\@/; $v =~ s/\\\./\./g; $v =~ s/\.$//; } return $v; } # set_ownership(file) # Sets the BIND ownership and permissions on some file sub set_ownership { local ($user, $group, $perms); if ($config{'file_owner'}) { # From config ($user, $group) = split(/:/, $config{'file_owner'}); } elsif ($_[0] =~ /^(.*)\/([^\/]+)$/) { # Match parent dir my @st = stat($1); ($user, $group) = ($st[4], $st[5]); } if ($config{'file_perms'}) { $perms = oct($config{'file_perms'}); } &set_ownership_permissions($user, $group, $perms, $_[0]); } if ($bind_version >= 9) { @cat_list = ( 'default', 'general', 'database', 'security', 'config', 'resolver', 'xfer-in', 'xfer-out', 'notify', 'client', 'unmatched', 'network', 'update', 'queries', 'dispatch', 'dnssec', 'lame-servers' ); } else { @cat_list = ( 'default', 'config', 'parser', 'queries', 'lame-servers', 'statistics', 'panic', 'update', 'ncache', 'xfer-in', 'xfer-out', 'db', 'eventlib', 'packet', 'notify', 'cname', 'security', 'os', 'insist', 'maintenance', 'load', 'response-checks'); } @syslog_levels = ( 'kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7' ); @severities = ( 'critical', 'error', 'warning', 'notice', 'info', 'debug', 'dynamic' ); # can_edit_view(&view | &viewcache) # Returns 1 if some view can be edited sub can_edit_view { local %vcan; local $vn = $_[0]->{'members'} ? $_[0]->{'value'} : $_[0]->{'name'}; if ($access{'vlist'} eq '*') { return 1; } elsif ($access{'vlist'} =~ /^\!/) { foreach (split(/\s+/, $access{'vlist'})) { return 0 if ($_ eq $vn); } return 1; } else { foreach (split(/\s+/, $access{'vlist'})) { return 1 if ($_ eq $vn); } return 0; } } # wrap_lines(text, width) # Given a multi-line string, return an array of lines wrapped to # the given width sub wrap_lines { local $rest = $_[0]; local @rv; while(length($rest) > $_[1]) { push(@rv, substr($rest, 0, $_[1])); $rest = substr($rest, $_[1]); } push(@rv, $rest) if ($rest ne ''); return @rv; } # add_zone_access(domain) # Add a new zone to the current user's access list sub add_zone_access { if ($access{'zones'} ne '*' && $access{'zones'} !~ /^\!/) { $access{'zones'} = join(" ", &unique( split(/\s+/, $access{'zones'}), $_[0])); &save_module_acl(\%access); } } # is_config_valid() sub is_config_valid { local $conf = &get_config(); local ($opts, $dir); if (($opts = &find("options", $conf)) && ($dir = &find("directory", $opts->{'members'})) && !(-d &make_chroot($dir->{'value'}))) { return 0; } return 1; } # check_bind_8() # Returns the --help output if non BIND 8/9, or undef if is sub check_bind_8 { local $fflag = $gconfig{'os_type'} eq 'windows' ? '-f' : ''; local $out = `$config{'named_path'} -help $fflag 2>&1`; return $out !~ /\[-f\]/ && $out !~ /\[-f\|/ ? $out : undef; } # get_chroot() # Returns the chroot directory BIND is running under sub get_chroot { if (!defined($get_chroot_cache)) { if ($gconfig{'real_os_type'} eq 'CentOS Linux' && $gconfig{'real_os_version'} >= 6 && $config{'auto_chroot'} =~ /\/etc\/sysconfig\/named/) { # Special case hack - on CentOS 6, chroot path in # /etc/sysconfig/named isn't really used. Instead, files # in the chroot are loopback mounted to the real paths. if (-r $config{'named_conf'} && !-l $config{'named_conf'}) { $config{'auto_chroot'} = undef; } } if ($config{'auto_chroot'}) { local $out = &backquote_command( "$config{'auto_chroot'} 2>/dev/null"); if (!$?) { $out =~ s/\r|\n//g; $get_chroot_cache = $out || ""; } } if (!defined($get_chroot_cache)) { # Use manually set path $get_chroot_cache = $config{'chroot'}; } } return $get_chroot_cache; } # make_chroot(file, [is-pid]) # Given a path that is relative to the chroot directory, return the real path sub make_chroot { local $chroot = &get_chroot(); return $_[0] if (!$chroot); return $_[0] if ($_[0] eq $config{'named_conf'} && $config{'no_chroot'}); return $_[0] if ($_[0] eq $config{'rndc_conf'}); # don't chroot rndc.conf if ($config{'no_pid_chroot'} && $_[1]) { return $_[0]; } return $chroot.$_[0]; } # has_ndc(exclude-mode) # Returns 2 if rndc is installed, 1 if ndc is instaled, or 0 sub has_ndc { if ($config{'rndc_cmd'} =~ /^(\S+)/ && &has_command("$1") && $_[0] != 2) { return 2; } if ($config{'ndc_cmd'} =~ /^(\S+)/ && &has_command("$1") && $_[0] != 1) { return 1; } return 0; } # get_pid_file([no-cache]) # Returns the BIND pid file path, relative to any chroot sub get_pid_file { if ($_[0] || !-r $zone_names_cache) { # Read real config local $conf = &get_config(); local ($opts, $pidopt); if (($opts = &find("options", $conf)) && ($pidopt = &find("pid-file", $opts->{'members'}))) { # read from PID file local $pidfile = $pidopt->{'value'}; if ($pidfile !~ /^\//) { local $dir = &find("directory", $opts->{'members'}); $pidfile = $dir->{'value'}."/".$pidfile; } return $pidfile; } # use default file local $p; foreach $p (split(/\s+/, $config{'pid_file'})) { if (-r &make_chroot($p, 1)) { return $p; } } return "/var/run/named.pid"; } else { # Use cache if possible local %znc; &read_file_cached($zone_names_cache, \%znc); if ($znc{'pidfile'} && -r $znc{'pidfile'}) { return $znc{'pidfile'}; } else { return &get_pid_file(1); } } } # can_edit_type(record-type) sub can_edit_type { return 1 if (!$access{'types'}); local $t; foreach $t (split(/\s+/, $access{'types'})) { return 1 if (lc($t) eq lc($_[0])); } return 0; } # add_to_file() # Returns the filename to which new zones should be added (possibly relative to # a chroot directory) sub add_to_file { if ($config{'zones_file'}) { local $conf = &get_config(); local $f; foreach $f (&get_all_config_files($conf)) { if (&same_file($f, $config{'zones_file'})) { return $config{'zones_file'}; } } } return $config{'named_conf'}; } # get_all_config_files(&conf) # Returns a list of all config files used by named.conf, including includes sub get_all_config_files { local ($conf) = @_; local @rv = ( $config{'named_conf'} ); foreach my $c (@$conf) { push(@rv, $c->{'file'}); if ($c->{'type'} == 1) { push(@rv, &get_all_config_files($c->{'members'})); } } return &unique(@rv); } # free_address_button(name) sub free_address_button { return &popup_window_button("free_chooser.cgi", 200, 500, 1, [ [ "ifield", $_[0] ] ]); } # create_slave_zone(name, master-ip, [view], [file], [&other-ips]) # A convenience function for creating a new slave zone, if it doesn't exist # yet. Mainly useful for Virtualmin, to avoid excessive transfer of BIND # configuration data. # Returns 0 on success, 1 if BIND is not setup, 2 if the zone already exists, # or 3 if the view doesn't exist, or 4 if the slave file couldn't be created sub create_slave_zone { local $parent = &get_config_parent(); local $conf = $parent->{'members'}; local $opts = &find("options", $conf); if (!$opts) { return 1; } # Check if exists in the view if ($_[2]) { local ($v) = grep { $_->{'value'} eq $_[2] } &find("view", $conf); @zones = &find("zone", $v->{'members'}); } else { @zones = &find("zone", $conf); } local ($z) = grep { $_->{'value'} eq $_[0] } @zones; return 2 if ($z); # Create it local @mips = &unique($_[1], @{$_[4]}); local $masters = { 'name' => 'masters', 'type' => 1, 'members' => [ map { { 'name' => $_ } } @mips ] }; local $allow = { 'name' => 'allow-transfer', 'type' => 1, 'members' => [ map { { 'name' => $_ } } @mips ] }; local $dir = { 'name' => 'zone', 'values' => [ $_[0] ], 'type' => 1, 'members' => [ { 'name' => 'type', 'values' => [ 'slave' ] }, $masters, $allow, ] }; local $base = $config{'slave_dir'} || &base_directory(); if ($base !~ /^([a-z]:)?\//) { # Slave dir is relative .. make absolute $base = &base_directory()."/".$base; } local $file; if (!$_[3]) { # File has default name and is under default directory $file = &automatic_filename($_[0], $_[0] =~ /in-addr/i ? 1 : 0, $base, $_[2]); push(@{$dir->{'members'}}, { 'name' => 'file', 'values' => [ $file ] } ); } elsif ($_[3] ne "none") { # File was specified $file = $_[3] =~ /^\// ? $_[3] : $base."/".$_[3]; push(@{$dir->{'members'}}, { 'name' => 'file', 'values' => [ $file ] } ); } # Create the slave file, so that BIND can write to it if ($file) { &open_tempfile(ZONE, ">".&make_chroot($file), 1, 1) || return 4; &close_tempfile(ZONE); &set_ownership(&make_chroot($file)); } # Get and validate view(s) local @views; if ($_[2]) { foreach my $vn (split(/\s+/, $_[2])) { my ($view) = grep { $_->{'value'} eq $vn } &find("view", $conf); push(@views, $view); } return 3 if (!@views); } else { # Top-level only push(@views, undef); } # Create the zone in all views foreach my $view (@views) { &create_zone($dir, $conf, $view ? $view->{'index'} : undef); } return 0; } # create_master_zone(name, &slave-ips, [view], [file], &records) # A convenience function for creating a new master zone, if it doesn't exist # yet. Mainly useful for Virtualmin, to avoid excessive transfer of BIND # configuration data. # Returns 0 on success, 1 if BIND is not setup, 2 if the zone already exists, # or 3 if the view doesn't exist, or 4 if the zone file couldn't be created sub create_master_zone { local ($name, $slaves, $viewname, $file, $records) = @_; local $parent = &get_config_parent(); local $conf = $parent->{'members'}; local $opts = &find("options", $conf); if (!$opts) { return 1; } # Check if exists in the view if ($viewname) { local ($v) = grep { $_->{'value'} eq $viewname } &find("view", $conf); @zones = &find("zone", $v->{'members'}); } else { @zones = &find("zone", $conf); } local ($z) = grep { $_->{'value'} eq $name } @zones; return 2 if ($z); # Create it local $dir = { 'name' => 'zone', 'values' => [ $name ], 'type' => 1, 'members' => [ { 'name' => 'type', 'values' => [ 'master' ] }, ] }; local $base = $config{'master_dir'} || &base_directory(); if ($base !~ /^([a-z]:)?\//) { # Master dir is relative .. make absolute $base = &base_directory()."/".$base; } if (!$file) { # File has default name and is under default directory $file = &automatic_filename($name, $_[0] =~ /in-addr/i ? 1 : 0, $base, $viewname); } push(@{$dir->{'members'}}, { 'name' => 'file', 'values' => [ $file ] } ); # Add slave IPs if (@$slaves) { my $also = { 'name' => 'also-notify', 'type' => 1, 'members' => [ ] }; my $allow = { 'name' => 'allow-transfer', 'type' => 1, 'members' => [ ] }; foreach my $s (@$slaves) { push(@{$also->{'members'}}, { 'name' => $s }); push(@{$allow->{'members'}}, { 'name' => $s }); } push(@{$dir->{'members'}}, $also, $allow); push(@{$dir->{'members'}}, { 'name' => 'notify', 'values' => [ 'yes' ] }); } # Create the zone file, with records &open_tempfile(ZONE, ">".&make_chroot($file), 1, 1) || return 4; &close_tempfile(ZONE); &set_ownership(&make_chroot($file)); foreach my $r (@$records) { if ($r->{'defttl'}) { &create_defttl($file, $r->{'defttl'}); } elsif ($r->{'generate'}) { &create_generator($file, @{$r->{'generate'}}); } elsif ($r->{'type'}) { &create_record($file, $r->{'name'}, $r->{'ttl'}, $r->{'class'}, $r->{'type'}, &join_record_values($r), $r->{'comment'}); } } # Get and validate view(s) local @views; if ($viewname) { foreach my $vn (split(/\s+/, $viewname)) { my ($view) = grep { $_->{'value'} eq $vn } &find("view", $conf); push(@views, $view); } return 3 if (!@views); } else { # Top-level only push(@views, undef); } # Create the zone in all views foreach my $view (@views) { &create_zone($dir, $conf, $view ? $view->{'index'} : undef); } return 0; } # get_master_zone_file(name, [chroot]) # Returns the absolute path to a master zone records file sub get_master_zone_file { local ($name, $chroot) = @_; local $conf = &get_config(); local @zones = &find("zone", $conf); local ($v, $z); foreach $v (&find("view", $conf)) { push(@zones, &find("zone", $v->{'members'})); } local ($z) = grep { lc($_->{'value'}) eq lc($name) } @zones; return undef if (!$z); local $file = &find("file", $z->{'members'}); return undef if (!$file); local $filename = &absolute_path($file->{'values'}->[0]); $filename = &make_chroot($filename) if ($chroot); return $filename; } # get_master_zone_records(name) # Returns a list of all the records in a master zone, each of which is a hashref sub get_master_zone_records { local ($name) = @_; local $filename = &get_master_zone_file($name, 0); return ( ) if (!$filename); return &read_zone_file($filename, $name); } # save_master_zone_records(name, &records) # Update all the records in the master zone, based on a list of hashrefs sub save_master_zone_records { local ($name, $records) = @_; local $filename = &get_master_zone_file($name, 0); return 0 if (!$filename); &open_tempfile(ZONE, ">".&make_chroot($filename), 1, 1) || return 0; &close_tempfile(ZONE); foreach my $r (@$records) { if ($r->{'defttl'}) { &create_defttl($filename, $r->{'defttl'}); } elsif ($r->{'generate'}) { &create_generator($filename, @{$r->{'generate'}}); } elsif ($r->{'type'}) { &create_record($filename, $r->{'name'}, $r->{'ttl'}, $r->{'class'}, $r->{'type'}, &join_record_values($r), $r->{'comment'}); } } return 1; } # delete_zone(name, [view], [file-too]) # Delete one zone from named.conf # Returns 0 on success, 1 if the zone was not found, or 2 if the view was not # found. sub delete_zone { local $parent = &get_config_parent(); local $conf = $parent->{'members'}; local @zones; if ($_[1]) { # Look in one or more views foreach my $vn (split(/\s+/, $_[1])) { local ($v) = grep { $_->{'value'} eq $vn } &find("view", $conf); if ($v) { push(@zones, &find("zone", $v->{'members'})); } } return 2 if (!@zones); $parent = $v; } else { # Look in all views push(@zones, &find("zone", $conf)); foreach my $v (&find("view", $conf)) { push(@zones, &find("zone", $v->{'members'})); } } # Delete all zones in the list local $found = 0; foreach my $z (grep { $_->{'value'} eq $_[0] } @zones) { $found++; # Remove from config file &lock_file($z->{'file'}); &save_directive($z->{'parent'} || $parent, [ $z ], [ ]); &unlock_file($z->{'file'}); &flush_file_lines(); if ($_[2]) { # Remove file local $f = &find("file", $z->{'members'}); if ($f) { &unlink_logged(&make_chroot( &absolute_path($f->{'value'}))); } } } &flush_zone_names(); return $found ? 0 : 1; } # rename_zone(oldname, newname, [view]) # Changes the name of some zone, and perhaps it's file # Returns 0 on success, 1 if the zone was not found, or 2 if the view was # not found. sub rename_zone { local $parent = &get_config_parent(); local $conf = $parent->{'members'}; local @zones; if ($_[2]) { # Look in one view local ($v) = grep { $_->{'value'} eq $_[2] } &find("view", $conf); return 2 if (!$v); @zones = &find("zone", $v->{'members'}); $parent = $v; } else { # Look in all views @zones = &find("zone", $conf); local $v; foreach $v (&find("view", $conf)) { push(@zones, &find("zone", $v->{'members'})); } } local ($z) = grep { $_->{'value'} eq $_[0] } @zones; return 1 if (!$z); $z->{'values'} = [ $_[1] ]; $z->{'value'} = $_[1]; local $file = &find("file", $z->{'members'}); if ($file) { # Update the file too local $newfile = $file->{'values'}->[0]; $newfile =~ s/$_[0]/$_[1]/g; if ($newfile ne $file->{'values'}->[0]) { rename(&make_chroot($file->{'values'}->[0]), &make_chroot($newfile)); $file->{'values'}->[0] = $newfile; $file->{'value'} = $newfile; } } &save_directive($parent, [ $z ], [ $z ]); &flush_file_lines(); &flush_zone_names(); return 0; } # restart_bind() # A convenience function for re-starting BIND. Returns undef on success, or # an error message on failure. sub restart_bind { if ($config{'restart_cmd'} eq 'restart') { # Stop and start again &stop_bind(); sleep(1); # Systemd doesn't like rapid stops and starts return &start_bind(); } elsif ($config{'restart_cmd'}) { # Custom command local $out = &backquote_logged( "$config{'restart_cmd'} 2>&1 </dev/null"); if ($?) { return &text('restart_ecmd', "<pre>$out</pre>"); } } else { # Use signal local $pidfile = &get_pid_file(); local $pid = &check_pid_file(&make_chroot($pidfile, 1)); if (!$pid) { return &text('restart_epidfile', $pidfile); } elsif (!&kill_logged('HUP', $pid)) { return &text('restart_esig', $pid, $!); } } &refresh_nscd(); return undef; } # restart_zone(domain, [view]) # Call ndc or rndc to apply a single zone. Returns undef on success or an error # message on failure. sub restart_zone { local ($dom, $view) = @_; local ($out, $ex); if ($view) { # Reload a zone in a view &try_cmd("freeze ".quotemeta($dom)." IN ".quotemeta($view). " 2>&1 </dev/null"); $out = &try_cmd("reload ".quotemeta($dom)." IN ".quotemeta($view). " 2>&1 </dev/null"); $ex = $?; &try_cmd("thaw ".quotemeta($dom)." IN ".quotemeta($view). " 2>&1 </dev/null"); } else { # Just reload one top-level zone &try_cmd("freeze ".quotemeta($dom)." 2>&1 </dev/null"); $out = &try_cmd("reload ".quotemeta($dom)." 2>&1 </dev/null"); $ex = $?; &try_cmd("thaw ".quotemeta($dom)." 2>&1 </dev/null"); } if ($out =~ /not found/i) { # Zone is not known to BIND yet - do a total reload local $err = &restart_bind(); return $err if ($err); if ($access{'remote'}) { # Restart all slaves too &error_setup(); local @slaveerrs = &restart_on_slaves(); if (@slaveerrs) { return &text('restart_errslave', "<p>".join("<br>", map { "$_->[0]->{'host'} : $_->[1]" } @slaveerrs)); } } } elsif ($ex || $out =~ /failed|not found|error/i) { return &text('restart_endc', "<tt>".&html_escape($out)."</tt>"); } &refresh_nscd(); return undef; } # start_bind() # Attempts to start the BIND DNS server, and returns undef on success or an # error message on failure sub start_bind { local $chroot = &get_chroot(); local $user; local $cmd; if ($config{'named_user'}) { $user = "-u $config{'named_user'}"; if (&get_bind_version() < 9) { # Only version 8 takes the -g flag if ($config{'named_group'}) { $user .= " -g $config{'named_group'}"; } else { local @u = getpwnam($config{'named_user'}); local @g = getgrgid($u[3]); $user .= " -g $g[0]"; } } } if ($config{'start_cmd'}) { $cmd = $config{'start_cmd'}; } elsif (!$chroot) { $cmd = "$config{'named_path'} -c $config{'named_conf'} $user </dev/null 2>&1"; } elsif (`$config{'named_path'} -help 2>&1` =~ /\[-t/) { # use named's chroot option $cmd = "$config{'named_path'} -c $config{'named_conf'} -t $chroot $user </dev/null 2>&1"; } else { # use the chroot command $cmd = "chroot $chroot $config{'named_path'} -c $config{'named_conf'} $user </dev/null 2>&1"; } local $out = &backquote_logged("$cmd 2>&1 </dev/null"); local $rv = $?; if ($rv || $out =~ /chroot.*not available/i) { return &text('start_error', $out ? "<tt>$out</tt>" : "Unknown error"); } return undef; } # stop_bind() # Kills the running DNS server, and returns undef on success or an error message # upon failure sub stop_bind { if ($config{'stop_cmd'}) { # Just use a command local $out = &backquote_logged("($config{'stop_cmd'}) 2>&1"); if ($?) { return "<pre>$out</pre>"; } } else { # Kill the process local $pidfile = &get_pid_file(); local $pid = &check_pid_file(&make_chroot($pidfile, 1)); if (!$pid || !&kill_logged('TERM', $pid)) { return $text{'stop_epid'}; } } return undef; } # is_bind_running() # Returns the PID if BIND is running sub is_bind_running { local $pidfile = &get_pid_file(); local $rv = &check_pid_file(&make_chroot($pidfile, 1)); if (!$rv && $gconfig{'os_type'} eq 'windows') { # Fall back to checking for process $rv = &find_byname("named"); } return $rv; } # version_atleast(v1, v2, v3) sub version_atleast { local @vsp = split(/\./, $bind_version); local $i; for($i=0; $i<@vsp || $i<@_; $i++) { return 0 if ($vsp[$i] < $_[$i]); return 1 if ($vsp[$i] > $_[$i]); } return 1; # same! } # get_zone_index(name, [view]) # Returns the index of some zone in the real on-disk configuration sub get_zone_index { undef(@get_config_cache); local $conf = &get_config(); local $vconf = $_[1] ne '' ? $conf->[$in{'view'}]->{'members'} : $conf; local $c; foreach $c (@$vconf) { if ($c->{'name'} eq 'zone' && $c->{'value'} eq $_[0]) { return $c->{'index'}; } } return undef; } # create_zone(&zone, &conf, [view-idx]) # Convenience function for adding a new zone sub create_zone { local ($dir, $conf, $viewidx) = @_; if ($viewidx ne "") { # Adding inside a view local $view = $conf->[$viewidx]; &lock_file(&make_chroot($view->{'file'})); &save_directive($view, undef, [ $dir ], 1); &flush_file_lines(); &unlock_file(&make_chroot($view->{'file'})); } else { # Adding at top level $dir->{'file'} = &add_to_file(); local $pconf = &get_config_parent($dir->{'file'}); &lock_file(&make_chroot($dir->{'file'})); &save_directive($pconf, undef, [ $dir ], 0); &flush_file_lines(); &unlock_file(&make_chroot($dir->{'file'})); } &flush_zone_names(); } $heiropen_file = "$module_config_directory/heiropen"; # get_heiropen() # Returns an array of open categories sub get_heiropen { open(HEIROPEN, $heiropen_file); local @heiropen = <HEIROPEN>; chop(@heiropen); close(HEIROPEN); return @heiropen; } # save_heiropen(&heir) sub save_heiropen { &open_tempfile(HEIR, ">$heiropen_file"); foreach $h (@{$_[0]}) { &print_tempfile(HEIR, $h,"\n"); } &close_tempfile(HEIR); } # list_zone_names() # Returns a list of zone names, types, files and views based on a cache # built from the primary configuration. sub list_zone_names { local @st = stat($zone_names_cache); local %znc; &read_file_cached($zone_names_cache, \%znc); # Check if any files have changed, or if the master config has changed, or # the PID file. local @files; local ($k, $changed, $filecount, %donefile); foreach $k (keys %znc) { if ($k =~ /^file_(.*)$/) { $filecount++; $donefile{$1}++; local @fst = stat($1); if ($fst[9] > $st[9]) { $changed = 1; } } } if ($changed || !$filecount || $znc{'version'} != $zone_names_version || !$donefile{$config{'named_conf'}} || $config{'no_chroot'} != $znc{'no_chroot_config'} || $config{'pid_file'} ne $znc{'pidfile_config'}) { # Yes .. need to rebuild %znc = ( ); local $conf = &get_config(); local @views = &find("view", $conf); local ($v, $z); local $n = 0; foreach $v (@views) { local @vz = &find("zone", $v->{'members'}); foreach $z (@vz) { local $type = &find_value("type", $z->{'members'}); local $file = &find_value("file", $z->{'members'}); $znc{"zone_".($n++)} = join("\t", $z->{'value'}, $z->{'index'}, $type, $v->{'value'}, $file); $files{$z->{'file'}}++; } $znc{"view_".($n++)} = join("\t", $v->{'value'}, $v->{'index'}); $files{$v->{'file'}}++; } foreach $z (&find("zone", $conf)) { local $type = &find_value("type", $z->{'members'}); local $file = &find_value("file", $z->{'members'}); $znc{"zone_".($n++)} = join("\t", $z->{'value'}, $z->{'index'}, $type, "*", $file); $files{$z->{'file'}}++; } # Store the base directory and PID file $znc{'base'} = &base_directory($conf, 1); $znc{'pidfile'} = &get_pid_file(1); $znc{'pidfile_config'} = $config{'pid_file'}; $znc{'no_chroot_config'} = $config{'no_chroot'}; # Store source files foreach $f (keys %files) { local $realf = &make_chroot(&absolute_path($f)); local @st = stat($realf); $znc{"file_".$realf} = $st[9]; } $znc{'version'} = $zone_names_version; &write_file($zone_names_cache, \%znc); undef(@list_zone_names_cache); } # Use in-memory cache if (scalar(@list_zone_names_cache)) { return @list_zone_names_cache; } # Construct the return value from the hash local (@rv, %viewidx); foreach $k (keys %znc) { if ($k =~ /^zone_(\d+)$/) { local ($name, $index, $type, $view, $file) = split(/\t+/, $znc{$k}, 5); push(@rv, { 'name' => $name, 'type' => $type, 'index' => $index, 'view' => $view eq '*' ? undef : $view, 'file' => $file }); } elsif ($k =~ /^view_(\d+)$/) { local ($name, $index) = split(/\t+/, $znc{$k}, 2); push(@rv, { 'name' => $name, 'index' => $index, 'type' => 'view' }); $viewidx{$name} = $index; } } local $z; foreach $z (@rv) { if ($z->{'type'} ne 'view' && $z->{'view'} ne '*') { $z->{'viewindex'} = $viewidx{$z->{'view'}}; } } @list_zone_names_cache = @rv; return @rv; } # flush_zone_names() # Clears the in-memory and on-disk zone name caches sub flush_zone_names { undef(@list_zone_names_cache); unlink($zone_names_cache); } # get_zone_name(index|name, [viewindex|"any"]) # Returns a zone cache object, looked up by name or index sub get_zone_name { local @zones = &list_zone_names(); local $field = $_[0] =~ /^\d+$/ ? "index" : "name"; local $z; foreach $z (@zones) { if ($z->{$field} eq $_[0] && ($_[1] eq 'any' || $_[1] eq '' && !defined($z->{'viewindex'}) || $_[1] ne '' && $z->{'viewindex'} == $_[1])) { return $z; } } return undef; } # get_zone_name_or_error(index|name, [viewindex|"any"]) # Looks up a zone by name and view, or calls error sub get_zone_name_or_error { local $zone = &get_zone_name(@_); if (!$zone) { my $msg = $_[1] eq 'any' ? 'master_egone' : $_[1] eq '' ? 'master_egone2' : 'master_egone3'; &error(&text($msg, @_)); } return $zone; } # zone_to_config(&zone) # Given a zone name object, return the config file object for the zone. In an # array context, also returns the main config list and parent object sub zone_to_config { my ($zone) = @_; my $parent = &get_config_parent(); my $bconf = &get_config(); my $conf = $bconf; if ($zone->{'viewindex'} ne '') { my $view = $conf->[$zone->{'viewindex'}]; $conf = $view->{'members'}; $parent = $view; } my $z = $conf->[$zone->{'index'}]; return wantarray ? ( $z, $bconf, $parent ) : $z; } # list_slave_servers() # Returns a list of Webmin servers on which slave zones are created / deleted sub list_slave_servers { &foreign_require("servers", "servers-lib.pl"); local %ids = map { $_, 1 } split(/\s+/, $config{'servers'}); local %secids = map { $_, 1 } split(/\s+/, $config{'secservers'}); local @servers = &servers::list_servers(); if (%ids) { local @rv = grep { $ids{$_->{'id'}} } @servers; foreach my $s (@rv) { $s->{'sec'} = $secids{$s->{'id'}}; } return @rv; } elsif ($config{'default_slave'} && !defined($config{'servers'})) { # Migrate old-style setting of single slave local ($serv) = grep { $_->{'host'} eq $config{'default_slave'} } @servers; if ($serv) { &add_slave_server($serv); return ($serv); } } return ( ); } # add_slave_server(&server) sub add_slave_server { &lock_file($module_config); &foreign_require("servers", "servers-lib.pl"); local @sids = split(/\s+/, $config{'servers'}); $config{'servers'} = join(" ", @sids, $_[0]->{'id'}); if ($_[0]->{'sec'}) { local @secsids = split(/\s+/, $config{'secservers'}); $config{'secservers'} = join(" ", @secsids, $_[0]->{'id'}); } &sync_default_slave(); &save_module_config(); &unlock_file($module_config); &servers::save_server($_[0]); } # delete_slave_server(&server) sub delete_slave_server { &lock_file($module_config); local @sids = split(/\s+/, $config{'servers'}); $config{'servers'} = join(" ", grep { $_ != $_[0]->{'id'} } @sids); local @secsids = split(/\s+/, $config{'secservers'}); $config{'secservers'} = join(" ", grep { $_ != $_[0]->{'id'} } @secsids); &sync_default_slave(); &save_module_config(); &unlock_file($module_config); } sub sync_default_slave { local @servers = &list_slave_servers(); if (@servers) { $config{'default_slave'} = $servers[0]->{'host'}; } else { $config{'default_slave'} = ''; } } # server_name(&server) sub server_name { return $_[0]->{'desc'} ? $_[0]->{'desc'} : $_[0]->{'host'}; } # create_master_records(file, zone, master, email, refresh, retry, expiry, min, # add-master-ns, add-slaves-ns, add-template, tmpl-ip, # add-template-reverse) # Creates the records file for a new master zone. Returns undef on success, or # an error message on failure. sub create_master_records { local ($file, $zone, $master, $email, $refresh, $retry, $expiry, $min, $add_master, $add_slaves, $add_tmpl, $ip, $addrev) = @_; # Create the zone file &lock_file(&make_chroot($file)); &open_tempfile(ZONE, ">".&make_chroot($file), 1) || return &text('create_efile3', $file, $!); &print_tempfile(ZONE, "\$ttl $min\n") if ($config{'master_ttl'}); &close_tempfile(ZONE); # create the SOA and NS records local $serial; if ($config{'soa_style'} == 1) { $serial = &date_serial().sprintf("%2.2d", $config{'soa_start'}); } else { # Use Unix time for date and running number serials $serial = time(); } local $vals = "$master $email (\n". "\t\t\t$serial\n". "\t\t\t$refresh\n". "\t\t\t$retry\n". "\t\t\t$expiry\n". "\t\t\t$min )"; &create_record($file, "$zone.", undef, "IN", "SOA", $vals); &create_record($file, "$zone.", undef, "IN", "NS", $master) if ($add_master); if ($add_slaves) { local $slave; foreach $slave (&list_slave_servers()) { local @bn = $slave->{'nsname'} || gethostbyname($slave->{'host'}); local $full = "$bn[0]."; &create_record($file, "$zone.", undef, "IN", "NS", $full); } } if ($add_tmpl) { # Create template records local %bumped; for(my $i=0; $config{"tmpl_$i"}; $i++) { local @c = split(/\s+/, $config{"tmpl_$i"}, 3); local $name = $c[0] eq '.' ? "$zone." : $c[0]; local $fullname = $name =~ /\.$/ ? $name : "$name.$zone."; local $recip = $c[2] || $ip; &create_record($file, $name, undef, "IN", $c[1], $recip); if ($addrev && ($c[1] eq "A" || $c[1] eq "AAAA")) { # Consider adding reverse record local ($revconf, $revfile, $revrec) = &find_reverse( $recip, $view); if ($revconf && &can_edit_reverse($revconf) && !$revrec) { # Yes, add one local $rname = $c[1] eq "A" ? &ip_to_arpa($recip) : &net_to_ip6int($recip); &lock_file(&make_chroot($revfile)); &create_record($revfile, $rname, undef, "IN", "PTR", $fullname); if (!$bumped{$revfile}++) { local @rrecs = &read_zone_file( $revfile, $revconf->{'name'}); &bump_soa_record($revfile, \@rrecs); &sign_dnssec_zone_if_key( $revconf, \@rrecs); } } } } if ($config{'tmpl_include'}) { # Add whatever is in the template file local $tmpl = &read_file_contents($config{'tmpl_include'}); local %hash = ( 'ip' => $ip, 'dom' => $zone ); $tmpl = &substitute_template($tmpl, \%hash); &open_tempfile(FILE, ">>".&make_chroot($file)); &print_tempfile(FILE, $tmpl); &close_tempfile(FILE); } } # If DNSSEC for new zones was requested, sign now local $secerr; if ($config{'tmpl_dnssec'} && &supports_dnssec()) { # Compute the size ($ok, $size) = &compute_dnssec_key_size($config{'tmpl_dnssecalg'}, $config{'tmpl_dnssecsizedef'}, $config{'tmpl_dnssecsize'}); if (!$ok) { # Error computing size?? $secerr = &text('mcreate_ednssecsize', $size); } else { # Create key and sign, saving any error local $fake = { 'file' => $file, 'name' => $zone }; $secerr = &create_dnssec_key($fake, $config{'tmpl_dnssecalg'}, $size); if (!$secerr) { $secerr = &sign_dnssec_zone($fake); } } } &unlock_file(&make_chroot($file)); &set_ownership(&make_chroot($file)); if ($secerr) { return &text('mcreate_ednssec', $secerr); } return undef; } # automatic_filename(domain, is-reverse, base, [viewname]) # Returns a filename for a new zone sub automatic_filename { local ($zone, $rev, $base, $viewname) = @_; local ($subs, $format); if ($rev) { # create filename for reverse zone $subs = &ip6int_to_net(&arpa_to_ip($zone)); $subs =~ s/\//_/; $format = $config{'reversezonefilename_format'}; } else { # create filename for forward zone $format = $config{'forwardzonefilename_format'}; $subs = $zone; } if ($viewname) { $subs .= ".".$viewname; } $format =~ s/ZONE/$subs/g; return $file = $base."/".$format; } # create_on_slaves(zone, master-ip, file, [&hostnames], [local-view]) # Creates the given zone on all configured slave servers, and returns a list # of errors sub create_on_slaves { local ($zone, $master, $file, $hosts, $localview) = @_; local %on = map { $_, 1 } @$hosts; &remote_error_setup(\&slave_error_handler); local $slave; local @slaveerrs; local @slaves = &list_slave_servers(); foreach $slave (@slaves) { # Skip if not on list to add to next if (%on && !$on{$slave->{'host'}} && !$on{$slave->{'nsname'}}); # Connect to server $slave_error = undef; &remote_foreign_require($slave, "bind8", "bind8-lib.pl"); if ($slave_error) { push(@slaveerrs, [ $slave, $slave_error ]); next; } # Work out other slave IPs local @otherslaves; if ($config{'other_slaves'}) { @otherslaves = grep { $_ ne '' } map { &to_ipaddress($_->{'host'}) } grep { $_ ne $slave } @slaves; } push(@otherslaves, split(/\s+/, $config{'extra_slaves'})); # Work out the view my $view; if ($slave->{'bind8_view'} eq '*') { # Same as this system $view = $localview; } elsif ($slave->{'bind8_view'}) { # Named view $view = $slave->{'bind8_view'}; } # Create the zone local $err = &remote_foreign_call($slave, "bind8", "create_slave_zone", $zone, $master, $view, $file, \@otherslaves); if ($err == 1) { push(@slaveerrs, [ $slave, $text{'master_esetup'} ]); } elsif ($err == 2) { push(@slaveerrs, [ $slave, $text{'master_etaken'} ]); } elsif ($err == 3) { push(@slaveerrs, [ $slave, &text('master_eview', $slave->{'bind8_view'}) ]); } } &remote_error_setup(); return @slaveerrs; } # delete_on_slaves(domain, [&slave-hostnames], [local-view]) # Delete some domain or all or listed slave servers sub delete_on_slaves { local ($dom, $slavehosts, $localview) = @_; local %on = map { $_, 1 } @$slavehosts; &remote_error_setup(\&slave_error_handler); local $slave; local @slaveerrs; foreach $slave (&list_slave_servers()) { next if (%on && !$on{$slave->{'host'}} && !$on{$slave->{'nsname'}}); # Connect to server $slave_error = undef; &remote_foreign_require($slave, "bind8", "bind8-lib.pl"); if ($slave_error) { push(@slaveerrs, [ $slave, $slave_error ]); next; } # Work out the view my $view; if ($slave->{'bind8_view'} eq "*") { # Same as on master .. but for now, don't pass in any view # so that it will be found automatically $view = $localview; } elsif ($slave->{'bind8_view'}) { # Named view $view = $slave->{'bind8_view'}; } # Delete the zone $err = &remote_foreign_call($slave, "bind8", "delete_zone", $dom, $view, 1); if ($err == 1) { push(@slaveerrs, [ $slave, $text{'delete_ezone'} ]); } elsif ($err == 2) { push(@slaveerrs, [ $slave, &text('master_eview', $slave->{'bind8_view'}) ]); } } &remote_error_setup(); return @slaveerrs; } # rename_on_slaves(olddomain, newdomain, [&slave-hostnames]) # Changes the name of some domain on all or listed slave servers sub rename_on_slaves { local ($olddom, $newdom, $on) = @_; local %on = map { $_, 1 } @$on; &remote_error_setup(\&slave_error_handler); local $slave; local @slaveerrs; foreach $slave (&list_slave_servers()) { next if (%on && !$on{$slave->{'host'}} && !$on{$slave->{'nsname'}}); # Connect to server $slave_error = undef; &remote_foreign_require($slave, "bind8", "bind8-lib.pl"); if ($slave_error) { push(@slaveerrs, [ $slave, $slave_error ]); next; } # Delete the zone $err = &remote_foreign_call($slave, "bind8", "rename_zone", $olddom, $newdom, $slave->{'bind8_view'}); if ($err == 1) { push(@slaveerrs, [ $slave, $text{'delete_ezone'} ]); } elsif ($err == 2) { push(@slaveerrs, [ $slave, &text('master_eview', $slave->{'bind8_view'}) ]); } } &remote_error_setup(); return @slaveerrs; } # restart_on_slaves([&slave-hostnames]) # Re-starts BIND on all or listed slave servers, and returns a list of errors sub restart_on_slaves { local %on = map { $_, 1 } @{$_[0]}; &remote_error_setup(\&slave_error_handler); local $slave; local @slaveerrs; foreach $slave (&list_slave_servers()) { next if (%on && !$on{$slave->{'host'}}); # Find the PID file $slave_error = undef; &remote_foreign_require($slave, "bind8", "bind8-lib.pl"); if ($slave_error) { push(@slaveerrs, [ $slave, $slave_error ]); next; } local $sver = &remote_foreign_call($slave, "bind8", "get_webmin_version"); local $pidfile; if ($sver >= 1.140) { # Call new function to get PID file from slave $pidfile = &remote_foreign_call( $slave, "bind8", "get_pid_file"); $pidfile = &remote_foreign_call( $slave, "bind8", "make_chroot", $pidfile, 1); } else { push(@slaveerrs, [ $slave, &text('restart_eversion', $slave->{'host'}, 1.140) ]); next; } # Read the PID and restart local $pid = &remote_foreign_call($slave, "bind8", "check_pid_file", $pidfile); if (!$pid) { push(@slaveerrs, [ $slave, &text('restart_erunning2', $slave->{'host'}) ]); next; } $err = &remote_foreign_call($slave, "bind8", "restart_bind"); if ($err) { push(@slaveerrs, [ $slave, &text('restart_esig2', $slave->{'host'}, $err) ]); } } &remote_error_setup(); return @slaveerrs; } sub slave_error_handler { $slave_error = $_[0]; } sub get_forward_record_types { return ("A", "NS", "CNAME", "MX", "HINFO", "TXT", "SPF", "DMARC", "WKS", "RP", "PTR", "LOC", "SRV", "KEY", "NSEC3PARAM", $config{'support_aaaa'} ? ( "AAAA" ) : ( ), @extra_forward); } sub get_reverse_record_types { return ("PTR", "NS", "CNAME", @extra_reverse); } # try_cmd(args, [rndc-args]) # Try calling rndc and ndc with the same args, to see which one works sub try_cmd { local $args = $_[0]; local $rndc_args = $_[1] || $_[0]; local $out; if (&has_ndc() == 2) { # Try with rndc $out = &backquote_logged( $config{'rndc_cmd'}. ($config{'rndc_conf'} ? " -c $config{'rndc_conf'}" : ""). " ".$rndc_args." 2>&1 </dev/null"); } if (&has_ndc() != 2 || $out =~ /connect\s+failed/i) { if (&has_ndc(2)) { # Try with rndc if rndc is not install or failed $out = &backquote_logged("$config{'ndc_cmd'} $args 2>&1 </dev/null"); } } return $out; } # supports_check_zone() # Returns 1 if zone checking is supported, 0 if not sub supports_check_zone { return $config{'checkzone'} && &has_command($config{'checkzone'}); } # check_zone_records(&zone-name|&zone) # Returns a list of errors from checking some zone file, if any sub check_zone_records { local ($zone) = @_; local ($zonename, $zonefile); if ($zone->{'values'}) { # Zone object $zonename = $zone->{'values'}->[0]; local $f = &find("file", $zone->{'members'}); $zonefile = $f->{'values'}->[0]; } else { # Zone name object $zonename = $zone->{'name'}; $zonefile = $zone->{'file'}; } local $out = &backquote_command( $config{'checkzone'}." ".quotemeta($zonename)." ". quotemeta(&make_chroot(&absolute_path($zonefile)))." 2>&1 </dev/null"); return $? ? split(/\r?\n/, $out) : ( ); } # supports_check_conf() # Returns 1 if BIND configuration checking is supported, 0 if not sub supports_check_conf { return $config{'checkconf'} && &has_command($config{'checkconf'}); } # check_bind_config([filename]) # Checks the BIND configuration and returns a list of errors sub check_bind_config { local ($file) = @_; $file ||= &make_chroot($config{'named_conf'}); local $chroot = &get_chroot(); local $out = &backquote_command("$config{'checkconf'} -h 2>&1 </dev/null"); local $zflag = $out =~ /\[-z\]/ ? "-z" : ""; local $out = &backquote_command( $config{'checkconf'}. ($chroot && $chroot ne "/" ? " -t ".quotemeta($chroot) : ""). " $zflag 2>&1 </dev/null"); return $? ? grep { !/loaded\s+serial/ } split(/\r?\n/, $out) : ( ); } # delete_records_file(file) # Given a file (chroot-relative), delete it with locking, and any associated # journal or log files sub delete_records_file { local ($file) = @_; local $zonefile = &make_chroot(&absolute_path($file)); &lock_file($zonefile); unlink($zonefile); local $logfile = $zonefile.".log"; if (-r $logfile) { &lock_file($logfile); unlink($logfile); } local $jnlfile = $zonefile.".jnl"; if (-r $jnlfile) { &lock_file($jnlfile); unlink($jnlfile); } local $signfile = $zonefile.".signed"; if (-r $signfile) { &lock_file($signfile); unlink($signfile); } } # move_zone_button(&config, current-view-index, zone-name) # If possible, returns a button row for moving this zone to another view sub move_zone_button { local ($conf, $view, $zonename) = @_; local @views = grep { &can_edit_view($_) } &find("view", $conf); if ($view eq '' && @views || $view ne '' && @views > 1) { return &ui_buttons_row("move_zone.cgi", $text{'master_move'}, $text{'master_movedesc'}, &ui_hidden("zone", $zonename). &ui_hidden("view", $view), &ui_select("newview", undef, [ map { [ $_->{'index'}, $_->{'value'} ] } grep { $_->{'index'} ne $view } @views ])); } return undef; } # download_root_zone(file) # Download the root zone data to a file (under the chroot), and returns undef # on success or an error message on failure. sub download_root_zone { my ($file) = @_; my $rootfile = &make_chroot($file); my $ftperr; my $temp; # First try by hostname &ftp_download($internic_ftp_host, $internic_ftp_file, $rootfile, \$ftperr); if ($ftperr) { # Try IP address directly $ftperr = undef; &ftp_download($internic_ftp_ip, $internic_ftp_file, $rootfile,\$ftperr); } if ($ftperr) { # Try compressed version $ftperr = undef; $temp = &transname(); &ftp_download($internic_ftp_host, $internic_ftp_gzip, $temp, \$ftperr); } if ($ftperr) { # Try IP address directly for compressed version! $ftperr = undef; &ftp_download($internic_ftp_ip, $internic_ftp_gzip, $temp, \$ftperr); } return $ftperr if ($ftperr); # Got some file .. maybe need to un-compress if ($temp) { &has_command("gzip") || return $text{'boot_egzip'}; my $out = &backquote_command("gzip -d -c ".quotemeta($temp)." 2>&1 >". quotemeta($rootfile)." </dev/null"); return &text('boot_egzip2', "<tt>".&html_escape($out)."</tt>") if ($?); } return undef; } # restart_links([&zone-name]) # Returns HTML for links to restart or start BIND, separated by <br> for use # in ui_print_header sub restart_links { local ($zone) = @_; local @rv; if (!$access{'ro'} && $access{'apply'}) { local $r = $ENV{'REQUEST_METHOD'} eq 'POST' ? 0 : 1; if (&is_bind_running()) { if ($zone && ($access{'apply'} == 1 || $access{'apply'} == 2)) { # Apply this zone my $link = "restart_zone.cgi?return=$r&". "view=$zone->{'viewindex'}&". "zone=$zone->{'name'}"; push(@rv, &ui_link($link, $text{'links_apply'}) ); } # Apply whole config if ($access{'apply'} == 1 || $access{'apply'} == 3) { push(@rv, &ui_link("restart.cgi?return=$r", $text{'links_restart'}) ); } if ($access{'apply'} == 1) { # Stop BIND push(@rv, &ui_link("stop.cgi?return=$r", $text{'links_stop'}) ); } } elsif ($access{'apply'} == 1) { # Start BIND push(@rv, &ui_link("start.cgi?return=$r", $text{'links_start'})); } } return join('<br>', @rv); } # supports_dnssec() # Returns 1 if zone signing is supported sub supports_dnssec { return &has_command($config{'signzone'}) && &has_command($config{'keygen'}); } # supports_dnssec_client() # Returns 2 if this BIND can send and verify DNSSEC requests, 1 if the # dnssec-validation directive is not supported, 0 otherwise sub supports_dnssec_client { return $bind_version >= 9.4 ? 2 : $bind_version >= 9 ? 1 : 0; } # dnssec_size_range(algorithm) # Given an algorithm like DSA or DH, return the max and min allowed key sizes, # and an optional forced divisor. sub dnssec_size_range { local ($alg) = @_; return $alg eq 'RSAMD5' || $alg eq 'RSASHA1' || $alg eq 'RSASHA256' ? ( 512, 2048 ) : $alg eq 'DH' ? ( 128, 4096 ) : $alg eq 'DSA' ? ( 512, 1024, 64 ) : $alg eq 'HMAC-MD5' ? ( 1, 512 ) : $alg eq 'NSEC3RSASHA1' ? ( 512, 4096 ) : $alg eq 'NSEC3DSA' ? ( 512, 1024, 64 ) : ( ); } sub list_dnssec_algorithms { return ("RSASHA1", "RSASHA256", "RSAMD5", "DSA", "DH", "HMAC-MD5", "NSEC3RSASHA1", "NSEC3DSA"); } # get_keys_dir(&zone|&zone-name) # Returns the directory in which to find DNSSEC keys for some zone sub get_keys_dir { local ($z) = @_; if ($config{'keys_dir'}) { return $config{'keys_dir'}; } else { local $fn = &get_zone_file($z, 2); $fn =~ s/\/[^\/]+$//; return $fn; } } # create_dnssec_key(&zone|&zone-name, algorithm, size, single-key) # Creates a new DNSSEC key for some zone, and places it in the same directory # as the zone file. Returns undef on success or an error message on failure. sub create_dnssec_key { local ($z, $alg, $size, $single) = @_; local $fn = &get_keys_dir($z); $fn || return "Could not work keys directory!"; # Remove all keys for the same zone opendir(ZONEDIR, $fn); foreach my $f (readdir(ZONEDIR)) { if ($f =~ /^K\Q$dom\E\.\+(\d+)\+(\d+)\.(key|private)$/) { &unlink_file("$fn/$f"); } } closedir(ZONEDIR); # Fork a background job to do lots of IO, to generate entropy local $pid; if (!$rand_flag) { $pid = fork(); if (!$pid) { exec("find / -type f >/dev/null 2>&1"); exit(1); } } # Work out zone key size local $zonesize; if ($single) { (undef, $zonesize) = &compute_dnssec_key_size($alg, 1); } else { $zonesize = $size; } # Create the zone key local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; local $out = &backquote_logged( "cd ".quotemeta($fn)." && ". "$config{'keygen'} -a ".quotemeta($alg)." -b ".quotemeta($zonesize). " -n ZONE $rand_flag $dom 2>&1"); if ($?) { kill('KILL', $pid) if ($pid); return $out; } # Create the key signing key, if needed if (!$single) { $out = &backquote_logged( "cd ".quotemeta($fn)." && ". "$config{'keygen'} -a ".quotemeta($alg)." -b ".quotemeta($size). " -n ZONE -f KSK $rand_flag $dom 2>&1"); kill('KILL', $pid) if ($pid); if ($?) { return $out; } } else { kill('KILL', $pid) if ($pid); } # Get the new keys local @keys = &get_dnssec_key($z); @keys || return "No new keys found for zone : $out"; foreach my $key (@keys) { ref($key) || return "Failed to get new key for zone : $key"; } if (!$single) { @keys == 2 || return "Expected 2 keys for zone, but found ". scalar(@keys); } # Add the new DNSKEY record(s) to the zone local $chrootfn = &get_zone_file($z); local @recs = &read_zone_file($chrootfn, $dom); for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'DNSKEY') { &delete_record($chrootfn, $recs[$i]); } } foreach my $key (@keys) { &create_record($chrootfn, $dom.".", undef, "IN", "DNSKEY", join(" ", @{$key->{'values'}})); } &bump_soa_record($chrootfn, \@recs); return undef; } # resign_dnssec_key(&zone|&zone-name) # Re-generate the zone key, and re-sign everything. Returns undef on success or # an error message on failure. sub resign_dnssec_key { local ($z) = @_; local $fn = &get_zone_file($z); $fn || return "Could not work out records file!"; local $dir = &get_keys_dir($z); $dir || return "Could not work out keys directory!"; local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; # Get the old zone key record local @recs = &read_zone_file($fn, $dom); local $zonerec; foreach my $r (@recs) { if ($r->{'type'} eq 'DNSKEY' && $r->{'values'}->[0] % 2 == 0) { $zonerec = $r; } } $zonerec || return "Could not find DNSSEC zone key record"; local @keys = &get_dnssec_key($z); @keys == 2 || return "Expected to find 2 keys, but found ".scalar(@keys); local ($zonekey) = grep { !$_->{'ksk'} } @keys; $zonekey || return "Could not find DNSSEC zone key"; # Fork a background job to do lots of IO, to generate entropy local $pid; if (!$rand_flag) { $pid = fork(); if (!$pid) { exec("find / -type f >/dev/null 2>&1"); exit(1); } } # Work out zone key size local $zonesize; local $alg = $zonekey->{'algorithm'}; (undef, $zonesize) = &compute_dnssec_key_size($alg, 1); # Generate a new zone key local $out = &backquote_logged( "cd ".quotemeta($dir)." && ". "$config{'keygen'} -a ".quotemeta($alg)." -b ".quotemeta($zonesize). " -n ZONE $rand_flag $dom 2>&1"); kill('KILL', $pid) if ($pid); if ($?) { return "Failed to generate new zone key : $out"; } # Delete the old key file &unlink_file($zonekey->{'privatefile'}); &unlink_file($zonekey->{'publicfile'}); # Update the zone file with the new key @keys = &get_dnssec_key($z); local ($newzonekey) = grep { !$_->{'ksk'} } @keys; $newzonekey || return "Could not find new DNSSEC zone key"; &modify_record($fn, $zonerec, $dom.".", undef, "IN", "DNSKEY", join(" ", @{$newzonekey->{'values'}})); &bump_soa_record($fn, \@recs); # Re-sign everything local $err = &sign_dnssec_zone($z); return "Re-signing failed : $err" if ($err); return undef; } # delete_dnssec_key(&zone|&zone-name) # Deletes the key for a zone, and all DNSSEC records sub delete_dnssec_key { local ($z) = @_; local $fn = &get_zone_file($z); $fn || return "Could not work out records file!"; local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; # Remove the key local @keys = &get_dnssec_key($z); foreach my $key (@keys) { foreach my $f ('publicfile', 'privatefile') { &unlink_file($key->{$f}) if ($key->{$f}); } } # Remove records local @recs = &read_zone_file($fn, $dom); local $tools = &have_dnssec_tools_support(); for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'NSEC' || $recs[$i]->{'type'} eq 'NSEC3' || $recs[$i]->{'type'} eq 'RRSIG' || $recs[$i]->{'type'} eq 'NSEC3PARAM' && $tools || $recs[$i]->{'type'} eq 'DNSKEY') { &delete_record($fn, $recs[$i]); } } &bump_soa_record($fn, \@recs); } # sign_dnssec_zone(&zone|&zone-name, [bump-soa]) # Replaces a zone's file with one containing signed records. sub sign_dnssec_zone { local ($z, $bump) = @_; local $chrootfn = &get_zone_file($z, 2); $chrootfn || return "Could not work out records file!"; local $dir = &get_keys_dir($z); local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; local $signed = $chrootfn.".webmin-signed"; # Up the serial number, if requested local $fn = &get_zone_file($z, 1); $fn =~ /^(.*)\/([^\/]+$)/; local @recs = &read_zone_file($fn, $dom); if ($bump) { &bump_soa_record($fn, \@recs); } # Get the zone algorithm local @keys = &get_dnssec_key($z); local ($zonekey) = grep { !$_->{'ksk'} } @keys; local $alg = $zonekey ? $zonekey->{'algorithm'} : ""; # Create the signed file. Sometimes this fails with an error like : # task.c:310: REQUIRE(task->references > 0) failed # But re-trying works!?! local $out; local $tries = 0; while($tries++ < 10) { $out = &backquote_logged( "cd ".quotemeta($dir)." && ". "$config{'signzone'} -o ".quotemeta($dom). ($alg =~ /^NSEC3/ ? " -3 -" : ""). " -f ".quotemeta($signed)." ". quotemeta($chrootfn)." 2>&1"); last if (!$?); } return $out if ($tries >= 10); # Merge records back into original file, by deleting all NSEC and RRSIG records # and then copying over for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'NSEC' || $recs[$i]->{'type'} eq 'NSEC3' || $recs[$i]->{'type'} eq 'RRSIG') { &delete_record($fn, $recs[$i]); } } local @signedrecs = &read_zone_file($fn.".webmin-signed", $dom); foreach my $r (@signedrecs) { if ($r->{'type'} eq 'NSEC' || $r->{'type'} eq 'NSEC3' || $r->{'type'} eq 'RRSIG') { &create_record($fn, $r->{'name'}, $r->{'ttl'}, $r->{'class'}, $r->{'type'}, join(" ", @{$r->{'values'}}), $r->{'comment'}); } } &unlink_file($signed); return undef; } # check_if_dnssec_tools_managed(&domain) # Check if the given domain is managed by dnssec-tools # Return 1 if yes, undef if not sub check_if_dnssec_tools_managed { local ($dom) = @_; my $dt_managed; if (&have_dnssec_tools_support()) { my $rrr; &lock_file($config{"dnssectools_rollrec"}); rollrec_lock(); rollrec_read($config{"dnssectools_rollrec"}); $rrr = rollrec_fullrec($dom); if ($rrr) { $dt_managed = 1; } rollrec_close(); rollrec_unlock(); &unlock_file($config{"dnssectools_rollrec"}); } return $dt_managed; } # sign_dnssec_zone_if_key(&zone|&zone-name, &recs, [bump-soa]) # If a zone has a DNSSEC key, sign it. Calls error if signing fails sub sign_dnssec_zone_if_key { local ($z, $recs, $bump) = @_; # Check if zones are managed by dnssec-tools local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; # If zone is managed through dnssec-tools use zonesigner for resigning the zone if (&check_if_dnssec_tools_managed($dom)) { # Do the signing local $zonefile = &get_zone_file($z); local $krfile = "$zonefile".".krf"; local $err; &lock_file(&make_chroot($zonefile)); $err = &dt_resign_zone($dom, $zonefile, $krfile, 0); &unlock_file(&make_chroot($zonefile)); &error($err) if ($err); return undef; } local $keyrec = &get_dnskey_record($z, $recs); if ($keyrec) { local $err = &sign_dnssec_zone($z, $bump); &error(&text('sign_emsg', $err)) if ($err); } } # get_dnssec_key(&zone|&zone-name) # Returns a list of hash containing details of a zone's keys, or an error # message. The KSK is always returned first. sub get_dnssec_key { local ($z) = @_; local $dir = &get_keys_dir($z); local $dom = $z->{'members'} ? $z->{'values'}->[0] : $z->{'name'}; local %keymap; opendir(ZONEDIR, $dir); foreach my $f (readdir(ZONEDIR)) { if ($f =~ /^K\Q$dom\E\.\+(\d+)\+(\d+)\.key$/) { # Found the public key file .. read it $keymap{$2} ||= { }; local $rv = $keymap{$2}; $rv->{'publicfile'} = "$dir/$f"; $rv->{'algorithmid'} = $1; $rv->{'keyid'} = $2; local $config{'short_names'} = 0; # Force canonicalization local ($pub) = &read_zone_file("$dir/$f", $dom, undef, 0, 1); $pub || return "Public key file $dir/$f does not contain ". "any records"; $pub->{'name'} eq $dom."." || return "Public key file $dir/$f is not for zone $dom"; $pub->{'type'} eq "DNSKEY" || return "Public key file $dir/$f does not contain ". "a DNSKEY record"; $rv->{'ksk'} = $pub->{'values'}->[0] % 2 ? 1 : 0; $rv->{'public'} = $pub->{'values'}->[3]; $rv->{'values'} = $pub->{'values'}; $rv->{'publictext'} = &read_file_contents("$dir/$f"); } elsif ($f =~ /^K\Q$dom\E\.\+(\d+)\+(\d+)\.private$/) { # Found the private key file $keymap{$2} ||= { }; local $rv = $keymap{$2}; $rv->{'privatefile'} = "$dir/$f"; local $lref = &read_file_lines("$dir/$f", 1); foreach my $l (@$lref) { if ($l =~ /^(\S+):\s*(.*)/) { local ($n, $v) = ($1, $2); $n =~ s/\(\S+\)$//; $n = lc($n); $rv->{$n} = $v; } } $rv->{'algorithm'} =~ s/^\d+\s+\((\S+)\)$/$1/; $rv->{'privatetext'} = join("\n", @$lref)."\n"; } } closedir(ZONEDIR); # Sort to put KSK first local @rv = values %keymap; @rv = sort { $b->{'ksk'} <=> $a->{'ksk'} } @rv; return wantarray ? @rv : $rv[0]; } # compute_dnssec_key_size(algorithm, def-mode, size) # Given an algorith and size mode (0=entered, 1=average, 2=big), returns either # 0 and an error message or 1 and the corrected size sub compute_dnssec_key_size { local ($alg, $def, $size) = @_; local ($min, $max, $factor) = &dnssec_size_range($alg); local $rv; if ($def == 1) { # Average $rv = int(($max + $min) / 2); if ($factor) { $rv = int($rv / $factor) * $factor; } } elsif ($def == 2) { # Max allowed $rv = $max; } else { $size =~ /^\d+$/ && $size >= $min && $size <= $max || return (0, &text('zonekey_esize', $min, $max)); if ($factor && $size % $factor) { return (0, &text('zonekey_efactor', $factor)); } $rv = $size; } return (1, $rv); } # get_dnssec_cron_job() # Returns the cron job object for re-signing DNSSEC domains sub get_dnssec_cron_job { &foreign_require("cron", "cron-lib.pl"); local ($job) = grep { $_->{'user'} eq 'root' && $_->{'command'} =~ /^\Q$dnssec_cron_cmd\E/ } &cron::list_cron_jobs(); return $job; } # refresh_nscd() # Signal nscd to re-read cached DNS info sub refresh_nscd { if (&find_byname("nscd")) { if (&has_command("nscd")) { # Use nscd -i to reload &system_logged("nscd -i hosts >/dev/null 2>&1 </dev/null"); } else { # Send HUP signal &kill_byname_logged("nscd", "HUP"); } } } # transfer_slave_records(zone, &masters, [file], [source-ip, [source-port]]) # Transfer DNS records from a master into some file. Returns a map from master # IPs to errors. sub transfer_slave_records { my ($dom, $masters, $file, $source, $sourceport) = @_; my $sourcearg; if ($source && $source ne "*") { $sourcearg = "-t ".$source; if ($sourceport) { $sourcearg .= "#".$sourceport; } } my %rv; my $dig = &has_command("dig"); foreach my $ip (@$masters) { if (!$dig) { $rv{$ip} = "Missing dig command"; } else { my $out = &backquote_logged( "$dig IN $sourcearg AXFR ".quotemeta($dom). " \@".quotemeta($ip)." 2>&1"); if ($? || $out =~ /Transfer\s+failed/) { $rv{$ip} = $out; } elsif (!$out) { $rv{$ip} = "No records transferred"; } else { if ($file) { &open_tempfile(XFER, ">$file"); &print_tempfile(XFER, $out); &close_tempfile(XFER); $file = undef; } } } } return \%rv; } sub get_dnssectools_config { &lock_file($config{'dnssectools_conf'}); my $lref = &read_file_lines($config{'dnssectools_conf'}); my @rv; my $lnum = 0; foreach my $line (@$lref) { my ($n, $v) = split(/\s+/, $line, 2); # Do basic sanity checking $v =~ /(\S+)/; $v = $1; if ($n) { push(@rv, { 'name' => $n, 'value' => $v, 'line' => $lnum }); } $lnum++; } &flush_file_lines(); &unlock_file($config{'dnssectools_conf'}); return \@rv; } # save_dnssectools_directive(&config, name, value) # Save new dnssec-tools configuration values to the configuration file sub save_dnssectools_directive { local $conf = $_[0]; local $nv = $_[1]; &lock_file($config{'dnssectools_conf'}); my $lref = &read_file_lines($config{'dnssectools_conf'}); foreach my $n (keys %$nv) { my $old = &find($n, $conf); if ($old) { $lref->[$old->{'line'}] = "$n $$nv{$n}"; } else { push(@$lref, "$n $$nv{$n}"); } } &flush_file_lines(); &unlock_file($config{'dnssectools_conf'}); } # list_dnssec_dne() # return a list containing the two DNSSEC mechanisms used for # proving non-existance sub list_dnssec_dne { return ("NSEC", "NSEC3"); } # list_dnssec_dshash() # return a list containing the different DS record hash types sub list_dnssec_dshash { return ("SHA1", "SHA256"); } # schedule_dnssec_cronjob() # schedule a cron job to handle periodic resign operations sub schedule_dnssec_cronjob { my $job; my $period = $config{'dnssec_period'} || 21; # Create or delete the cron job $job = &get_dnssec_cron_job(); if (!$job) { # Turn on cron job $job = {'user' => 'root', 'active' => 1, 'command' => $dnssec_cron_cmd, 'mins' => int(rand()*60), 'hours' => int(rand()*24), 'days' => '*', 'months' => '*', 'weekdays' => '*' }; &lock_file(&cron::cron_file($job)); &cron::create_cron_job($job); &unlock_file(&cron::cron_file($job)); } &cron::create_wrapper($dnssec_cron_cmd, $module_name, "resign.pl"); &lock_file($module_config_file); $config{'dnssec_period'} = $in{'period'}; &save_module_config(); &unlock_file($module_config_file); } # dt_sign_zone(zone, nsec3) # Replaces a zone's file with one containing signed records. sub dt_sign_zone { local ($zone, $nsec3) = @_; local @recs; local $z = &get_zone_file($zone); local $d = $zone->{'name'}; local $z_chroot = &make_chroot($z); local $k_chroot = $z_chroot.".krf"; local $usz = $z_chroot.".webmin-unsigned"; local $cmd; local $out; if ((($zonesigner=dt_cmdpath('zonesigner')) eq '')) { return $text{'dt_zone_enocmd'}; } if ($nsec3 == 1) { $nsec3param = " -usensec3 -nsec3optout "; } else { $nsec3param = ""; } &lock_file($z_chroot); rollrec_lock(); # Remove DNSSEC records and save the unsigned zone file @recs = &read_zone_file($z, $dom); local $tools = &have_dnssec_tools_support(); for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'NSEC' || $recs[$i]->{'type'} eq 'NSEC3' || $recs[$i]->{'type'} eq 'NSEC3PARAM' && $tools || $recs[$i]->{'type'} eq 'RRSIG' || $recs[$i]->{'type'} eq 'DNSKEY') { &delete_record($z, $recs[$i]); } } &copy_source_dest($z_chroot, $usz); $cmd = "$zonesigner $nsec3param". " -genkeys ". " -kskdirectory ".quotemeta($config{"dnssectools_keydir"}). " -zskdirectory ".quotemeta($config{"dnssectools_keydir"}). " -dsdir ".quotemeta($config{"dnssectools_keydir"}). " -zone ".quotemeta($d). " -krfile ".quotemeta($k_chroot). " ".quotemeta($usz)." ".quotemeta($z_chroot); $out = &backquote_logged("$cmd 2>&1"); if ($?) { rollrec_unlock(); &unlock_file($z_chroot); return $out; } # Create rollrec entry for zone $rrfile = $config{"dnssectools_rollrec"}; &lock_file($rrfile); open(OUT,">> $rrfile") || &error($text{'dt_zone_errfopen'}); print OUT "roll \"$d\"\n"; print OUT " zonename \"$d\"\n"; print OUT " zonefile \"$z_chroot\"\n"; print OUT " keyrec \"$k_chroot\"\n"; print OUT " kskphase \"0\"\n"; print OUT " zskphase \"0\"\n"; print OUT " ksk_rolldate \" \"\n"; print OUT " ksk_rollsecs \"0\"\n"; print OUT " zsk_rolldate \" \"\n"; print OUT " zsk_rollsecs \"0\"\n"; print OUT " maxttl \"0\"\n"; print OUT " phasestart \"new\"\n"; &unlock_file($rrfile); # Setup zone to be auto-resigned every 30 days &schedule_dnssec_cronjob(); rollrec_unlock(); &unlock_file($z_chroot); &dt_rollerd_restart(); &restart_bind(); return undef; } # dt_resign_zone(zone-name, zonefile, krfile, threshold) # Replaces a zone's file with one containing signed records. sub dt_resign_zone { local ($d, $z, $k, $t) = @_; local $zonesigner; local @recs; local $cmd; local $out; local $threshold = ""; local $z_chroot = &make_chroot($z); local $usz = $z_chroot.".webmin-unsigned"; if ((($zonesigner=dt_cmdpath('zonesigner')) eq '')) { return $text{'dt_zone_enocmd'}; } rollrec_lock(); # Remove DNSSEC records and save the unsigned zone file @recs = &read_zone_file($z, $dom); local $tools = &have_dnssec_tools_support(); for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'NSEC' || $recs[$i]->{'type'} eq 'NSEC3' || $recs[$i]->{'type'} eq 'NSEC3PARAM' && $tools || $recs[$i]->{'type'} eq 'RRSIG' || $recs[$i]->{'type'} eq 'DNSKEY') { &delete_record($z, $recs[$i]); } } &copy_source_dest($z_chroot, $usz); if ($t > 0) { $threshold = "-threshold ".quotemeta("-$t"."d"." "); } $cmd = "$zonesigner -verbose -verbose". " -kskdirectory ".quotemeta($config{"dnssectools_keydir"}). " -zskdirectory ".quotemeta($config{"dnssectools_keydir"}). " -dsdir ".quotemeta($config{"dnssectools_keydir"}). " -zone ".quotemeta($d). " -krfile ".quotemeta(&make_chroot($k)). " ".$threshold. " ".quotemeta($usz)." ".quotemeta($z_chroot); $out = &backquote_logged("$cmd 2>&1"); rollrec_unlock(); return $out if ($?); &restart_zone($d); return undef; } # dt_zskroll_zone(zone-name) # Initates a zsk rollover operation for the zone sub dt_zskroll_zone { local ($d) = @_; if (!rollmgr_sendcmd(CHANNEL_WAIT,ROLLCMD_ROLLZSK,$d)) { return $text{'dt_zone_erollctl'}; } return undef; } # dt_kskroll_zone(zone-name) # Initates a ksk rollover operation for the zone sub dt_kskroll_zone { local ($d) = @_; if (!rollmgr_sendcmd(CHANNEL_WAIT,ROLLCMD_ROLLKSK,$d)) { return $text{'dt_zone_erollctl'}; } return undef; } # dt_notify_parentzone(zone-name) # Notifies rollerd that the new DS record has been published in the parent zone sub dt_notify_parentzone { local ($d) = @_; if (!rollmgr_sendcmd(CHANNEL_WAIT,ROLLCMD_DSPUB,$d)) { return $text{'dt_zone_erollctl'}; } return undef; } # dt_rollerd_restart() # Restart the rollerd daemon sub dt_rollerd_restart { local $rollerd; local $r; local $cmd; local $out; if ((($rollerd=dt_cmdpath('rollerd')) eq '')) { return $text{'dt_zone_enocmd'}; } rollmgr_halt(); $r = $config{"dnssectools_rollrec"}; $cmd = "$rollerd -rrfile ".quotemeta($r); &execute_command($cmd); return undef; } # dt_genkrf() # Generate a new krf file for the zone sub dt_genkrf { local ($zone, $z_chroot, $k_chroot) = @_; local $dom = $zone->{'name'}; local @keys = &get_dnssec_key($zone); local $usz = $z_chroot.".webmin-unsigned"; local $zskcur = ""; local $kskcur = ""; local $cmd; local $out; local $oldkeydir = &get_keys_dir($zone); local $keydir = $config{"dnssectools_keydir"}; mkdir($keydir); foreach my $key (@keys) { foreach my $f ('publicfile', 'privatefile') { # Identify if this is a zsk or a ksk $key->{$f} =~ /(K\Q$dom\E\.\+\d+\+\d+)/; if ($key->{'ksk'}) { $kskcur = $1; } else { $zskcur = $1; } &copy_source_dest($key->{$f}, $keydir); &unlink_file($key->{$f}); } } if (($zskcur eq "") || ($kskcur eq "")) { return &text('dt_zone_enokey', $dom); } # Remove the older dsset file if ($oldkeydir) { &unlink_file($oldkeydir."/"."dsset-".$dom."."); } if ((($genkrf=dt_cmdpath('genkrf')) eq '')) { return $text{'dt_zone_enocmd'}; } $cmd = "$genkrf". " -zone ".quotemeta($dom). " -krfile ".quotemeta($k_chroot). " -zskcur=".quotemeta($zskcur). " -kskcur=".quotemeta($kskcur). " -zskdir ".quotemeta($keydir). " -kskdir ".quotemeta($keydir). " ".quotemeta($usz)." ".quotemeta($z_chroot); $out = &backquote_logged("$cmd 2>&1"); return $out if ($?); return undef; } # dt_delete_dnssec_state() # Delete all DNSSEC-Tools meta-data for a given zone sub dt_delete_dnssec_state { local ($zone) = @_; local $z = &get_zone_file($zone); local $dom = $zone->{'members'} ? $zone->{'values'}->[0] : $zone->{'name'}; local $z_chroot = &make_chroot($z); local $k_chroot = $z_chroot.".krf"; local $usz = $z_chroot.".webmin-unsigned"; local @recs; if (&check_if_dnssec_tools_managed($dom)) { rollrec_lock(); #remove entry from rollrec file &lock_file($config{"dnssectools_rollrec"}); rollrec_read($config{"dnssectools_rollrec"}); rollrec_del($dom); rollrec_close(); &unlock_file($config{"dnssectools_rollrec"}); &lock_file($z_chroot); # remove key and krf files keyrec_read($k_chroot); @kskpaths = keyrec_keypaths($dom, "all"); foreach (@kskpaths) { # remove any trailing ".key" s/(.*).key$/\1/; &unlink_file("$_.key"); &unlink_file("$_.private"); } keyrec_close(); &unlink_file($k_chroot); &unlink_file($usz); # Delete dsset &unlink_file($config{"dnssectools_keydir"}."/"."dsset-".$dom."."); # remove DNSSEC records from zonefile @recs = &read_zone_file($z, $dom); local $tools = &have_dnssec_tools_support(); for(my $i=$#recs; $i>=0; $i--) { if ($recs[$i]->{'type'} eq 'NSEC' || $recs[$i]->{'type'} eq 'NSEC3' || $recs[$i]->{'type'} eq 'NSEC3PARAM' && $tools || $recs[$i]->{'type'} eq 'RRSIG' || $recs[$i]->{'type'} eq 'DNSKEY') { &delete_record($z, $recs[$i]); } } &bump_soa_record($z, \@recs); &unlock_file($z_chroot); rollrec_unlock(); &dt_rollerd_restart(); &restart_bind(); } return undef; } # get_ds_record(&zone|&zone-name) # Returns the text of a DS record for this zone sub get_ds_record { my ($zone) = @_; my $zonefile; my $dom; if ($zone->{'values'}) { # Zone object my $f = &find("file", $zone->{'members'}); $zonefile = $f->{'values'}->[0]; $dom = $zone->{'values'}->[0]; } else { # Zone name object $zonefile = $zone->{'file'}; $dom = $zone->{'name'}; } if (&has_command("dnssec-dsfromkey")) { # Generate with a command my $out = &backquote_command("dnssec-dsfromkey -f ".quotemeta(&make_chroot(&absolute_path($zonefile)))." ZONE 2>/dev/null"); return undef if ($?); $out =~ s/\r|\n//g; return $out; } else { # From dsset- file my $keydir = &get_keys_dir($zone); my $out = &read_file_contents($keydir."/dsset-".$dom."."); $out =~ s/\r|\n$//g; return $out; } } 1;
mikaoras/webmin
bind8/bind8-lib.pl
Perl
bsd-3-clause
105,273
package Smolder::Upgrade::V1_37; use strict; use warnings; use base 'Smolder::Upgrade'; sub pre_db_upgrade { } sub post_db_upgrade { } 1;
Smolder/smolder
lib/Smolder/Upgrade/V1_37.pm
Perl
bsd-3-clause
141
# # 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. # use strict; use warnings; use cproton_perl; package qpid::proton; sub check_for_error { my $rc = $_[0]; if($rc < 0) { my $source = $_[1]; die "ERROR[$rc] " . $source->get_error(); } } package qpid::proton::ExceptionHandling; 1;
vadimsu/qpid
proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
Perl
apache-2.0
1,052
#!/usr/bin/perl # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/build/debug/Hostboot/Attr.pm $ # # OpenPOWER HostBoot Project # # COPYRIGHT International Business Machines Corp. 2012,2014 # # 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. # # IBM_PROLOG_END_TAG # # This perl module can be used in a standalone Hostboot environment # (Simics or VBU) or with a L3 dump file to dump a specified target's # attribute(s). # # Authors: CamVan Nguyen # Mark Wenning # use strict; package Hostboot::Attr; use Hostboot::_DebugFrameworkVMM; use Exporter; our @EXPORT_OK = ('main'); use POSIX; use File::Basename; use Data::Dumper; $Data::Dumper::Sortkeys = 1; #------------------------------------------------------------------------------ # Constants #------------------------------------------------------------------------------ use constant PAGESIZE => 4096; # 4KB ## each target object takes up space for: ## uint32_t iv_attrs + void *iv_pAttrNames + void *iv_pAttrValues ## + void* iv_ppAssociations[4] use constant TARGETSIZE => 52; ## Attribute id's are uint32_t enums use constant ATTRID_SIZE => 4; ## pointers to attribute values should be 8 bytes use constant ATTRVALUESPTR_SIZE => 8 ; ## size of the TargetsHdr struct at the beginning of PNOR use constant TARGETS_HDR_SIZE => 0x100; #------------------------------------------------------------------------------ # Globals #------------------------------------------------------------------------------ my %pages = (); my %sections = ( 'PNOR_RO' => { 'vaddr' => 0x100000000, 'physaddr' => 0x0, }, 'PNOR_RW' => { 'vaddr' => 0x108000000, 'physaddr' => 0x0, }, 'HEAP_ZERO_INIT' => { 'vaddr' => 0x110000000, 'physaddr' => 0x0, }, 'HB_HEAP_ZERO_INIT' => { 'vaddr' => 0x118000000, 'physaddr' => 0x0, }, ); my @targets = (); my $attrListRef = {}; #------------------------------------------------------------------------------ # Forward Declarations #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Main #------------------------------------------------------------------------------ sub main { my ($packName,$args) = @_; #-------------------------------------------------------------------------- # Process input arguments #-------------------------------------------------------------------------- my $debug = 0; if (defined $args->{"debug"}) { $debug = $args->{"debug"}; my $debugFileName = ::getImgPath() . "Attr.debug"; open(DEBUG_FILE, "> $debugFileName") or die "Cannot open file $debugFileName"; ::userDisplay "write debug info to $debugFileName\n"; } my $opt_huid = ""; if (defined $args->{"huid"}) { $opt_huid = $args->{"huid"}; chomp $opt_huid; ::userDisplay "huid=$opt_huid option specified. \n"; } my $opt_attrname = ""; if (defined $args->{"attrname"}) { $opt_attrname = $args->{"attrname"}; chomp $opt_attrname; ::userDisplay "attrname=$opt_attrname option specified. \n"; } ## Normally this will not need to be specified, this is the default. my $attrListFile = "targAttrInfo.csv"; ## read --attrfile in case the user wants to override if (defined $args->{"attrfile"}) { $attrListFile = $args->{"attrfile"}; } #-------------------------------------------------------------------------- # Read in the file that associates the attr name, attr id, and size . #-------------------------------------------------------------------------- $attrListFile = ::getImgPath() . $attrListFile; unless (-e $attrListFile) { ::userDisplay "Cannot find attribute list file \"$attrListFile\".\n"; die; } ::userDisplay "Using attribute list file \"$attrListFile\"\n\n"; #-------------------------------------------------------------------------- # Process the attribute list file. Save data to a hash. # # Format of file is: # <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE> # We are not interested in the FAPI-ATTR-ID-STR, parse the rest of # the csv fields. #-------------------------------------------------------------------------- open(FILE, "< $attrListFile") or die "Cannot open file $attrListFile"; my @lines = <FILE>; my $attrIdHex = 0; # Get the attribute data and index by ID foreach my $line (@lines) { chomp($line); my ( $fapi_attr_id_str, $layer_attr_id_str, $attr_id_val, $attr_type ) = split( ',', $line ); ## convert to scalar for a clean index $attrIdHex = hex( $attr_id_val ); $attrListRef->{$attrIdHex}->{'str'} = $layer_attr_id_str ; $attrListRef->{$attrIdHex}->{'type'} = $attr_type ; } close(FILE) or die "Cannot close $attrListFile"; ## $$ debug ## ::userDisplay Dumper( $attrListRef ); #-------------------------------------------------------------------------- # Initialize Global Vars #-------------------------------------------------------------------------- my $cacheData = 0; ## ----------------------------------------------------------------------- ## Initialize Target and Attribute Section info ## ----------------------------------------------------------------------- my $secref = \%sections; $secref->{'PNOR_RO'}->{'physaddr'} = getPhysicalAddr( $secref->{'PNOR_RO'}->{'vaddr'} ); $secref->{'PNOR_RW'}->{'physaddr'} = getPhysicalAddr( $secref->{'PNOR_RW'}->{'vaddr'} ); $secref->{'HEAP_ZERO_INIT'}->{'physaddr'} = getPhysicalAddr( $secref->{'HEAP_ZERO_INIT'}->{'vaddr'} ); $secref->{'HB_HEAP_ZERO_INIT'}->{'physaddr'} = getPhysicalAddr( $secref->{'HB_HEAP_ZERO_INIT'}->{'vaddr'} ); if ( $debug ) { ## Dump Targeting Header ::userDisplay "dump Targeting Header: \n" ; my $data = readData( $secref->{'PNOR_RO'}->{'vaddr'} , 256, $cacheData, $debug ); userDisplayHex( $data ); } ## The first thing in the first section (i.e. after the TargetHeader) ## should be a vaddr pointer to the number of targets, followed by an ## array of all the targets. ## ## Read the pointer to numTargets and the targetArray. ## skip over the 256 byte header to get to the first section my $numTargetsPtr = 0; my $numTargets = 0; $numTargetsPtr = readDataHex( ($secref->{'PNOR_RO'}->{'vaddr'}+TARGETS_HDR_SIZE), 8, $cacheData, $debug ); $numTargets = readDataHex( $numTargetsPtr, 4, $cacheData, $debug ); ## bump the pointer by a uint32_t. We should now be pointing to the ## first target. my $targetsPtr = $numTargetsPtr + 4; if ( $debug ) { ## Sanity check ::userDisplay "ptr to numTargets: ", (sprintf("0x%016x", $numTargetsPtr)), "\n", "ptr to targets: ", (sprintf("0x%016x", $targetsPtr)), "\n", "numTargets: ", (sprintf("0x%08x", $numTargets)), "\n" ; } ::userDisplay "Reading target and attribute data,", " this may take a while...\n"; ## Fill in the @targets array with the target info for ( my $i=0; $i<$numTargets; $i++ ) { my $targInfoRef = {}; my $offset = $i*TARGETSIZE; my $attrSize = 0; ## Read in the number of attributes associated with this target $targInfoRef->{'iv_attr'} = readDataHex( ($targetsPtr + $offset), 4, $cacheData, $debug ); $offset += 4 ; ## bump to iv_AttrNames ptr and store $targInfoRef->{'iv_pAttrNames'} = readDataHex( ($targetsPtr+$offset), 8, $cacheData, $debug ); $offset += 8 ; ## bump to iv_AttrValues ptr and store $targInfoRef->{'iv_pAttrValues'} = readDataHex( ($targetsPtr+$offset), 8, $cacheData, $debug ); ## ## Follow the iv_pAttrNames pointer to read in the attribute id's ## associated with this target ## my @attrIds = getAttrIds( $targInfoRef, $cacheData, $debug ); ## $$ debug ## ::userDisplay join(", ", @attrIds), "\n"; ## follow the iv_AttrValues pointer to read in the value pointers ## associated with each target. ## This should be in 1 to 1 correspondence with the @attrIds array ## above. my @attrValuePtrs = getAttrValuePtrs( $targInfoRef, $cacheData, $debug ); ## $$ debug ## ::userDisplay join(", ", @attrValuePtrs), "\n"; ## ## Fill in the attribute values for each attribute id / name, ## indexed by the name. ## for ( my $j=0; $j<$targInfoRef->{'iv_attr'}; $j++ ) { my $thisAttrId = $attrIds[$j]; my $thisAttrName = $attrListRef->{$thisAttrId}->{'str'} ; if ( $thisAttrName eq "" ) { ## if we can't find the attribute in the attrList file, ## it is probably not an integer or integer array. ## Make up a name. When we print all the attributes at the ## end, these will be skipped unless --debug is turned on. ## @TODO RTC 68517 Handle non-simple non-integer types ## as part of the above RTC to make all attr dump tools ## compatible with cronus. $thisAttrName = "ATTR_TBD_" . (sprintf("0x%x", $thisAttrId)); } ## save the order that they came in. $targInfoRef->{$thisAttrName}->{'index'} = $j; ## store the attribute id $targInfoRef->{$thisAttrName}->{'attrid'} = $thisAttrId; ## read the type and derive the size from the attrList hash. my $attrType = $attrListRef->{$thisAttrId}->{'type'}; $targInfoRef->{$thisAttrName}->{'attrtype'} = $attrType; ## parseType will return a size for simple types, for arrays ## etc it will fill in @parseDesc . my @parseDesc = (); my $readSize = parseType( $attrType, \@parseDesc, $debug ); $targInfoRef->{$thisAttrName}->{'attrsize'} = $readSize; $targInfoRef->{$thisAttrName}->{'attrDesc'} = \@parseDesc; if ( $debug ) { print DEBUG_FILE "process $thisAttrName $attrType ", ", parseDesc= ", scalar(@parseDesc), ", vaddr=", (sprintf("0x%X",$attrValuePtrs[$j])), ", readSize=$readSize", "\n" ; } ## Save the vaddr for debug. $targInfoRef->{$thisAttrName}->{'attrvaddr'} = $attrValuePtrs[$j]; ## fetch the attribute value. Read and store this as a raw ## binary hex string (mixed in with "not present" messages) ## and process it later. my $rawData = 0; $rawData = readData( $attrValuePtrs[$j], $readSize, $cacheData, $debug ); $targInfoRef->{$thisAttrName}->{'attrvalue'} = $rawData; } ## endfor $j (attributes) $targets[$i] = $targInfoRef; } ## endfor $i (targets) if ( $debug ) { print DEBUG_FILE "\n", Dumper( @targets ); } ## -------------------------------------------------------------- ## print out results ## -------------------------------------------------------------- my $foundTarget = 0; ::userDisplay "# number of targets = $numTargets\n" ; foreach my $targetRef ( @targets ) { my $targHuid = binToHex( $targetRef->{'ATTR_HUID'}->{'attrvalue'} ); if ( $opt_huid eq "" ) { displayTargetAttributes( $targetRef, $opt_attrname, $debug ); } else { my $inHuid = hex( $opt_huid ); if ( $debug ) { ::userDisplay "inHuid=", (sprintf("0x%X"),$inHuid), ", targHuid=", (sprintf("0x%X"),$targHuid), "\n"; } if ( $inHuid == $targHuid ) { $foundTarget = 1; displayTargetAttributes( $targetRef, $opt_attrname, $debug ); } } last if ( $foundTarget ); } ## end foreach $targetRef if ( $debug ) { close DEBUG_FILE; } } ## end main ## ## passed a targetref, print all or one of its' attributes in ## more-or-less cronus format ## sub displayTargetAttributes { my ( $targetRef, $attrname, $debug ) = @_; my $foundAttr = 0; ## print HUID and number of attributes (in a comment) first ## as a sanity check. my $huid = binToHex( $targetRef->{'ATTR_HUID'}->{'attrvalue'} ); ::userDisplay "\n# huid = ", (sprintf("0x%X",$huid)), "\n"; ::userDisplay "# number of attributes = ",$targetRef->{'iv_attr'}, "\n"; ::userDisplay "target = ", cronusTargetStr( $huid ), "\n" ; foreach my $attr ( sort keys %$targetRef ) { if ( $attrname ne "" ) { if ( $debug ) { ::userDisplay "attr=$attr, attrname=$attrname \n"; } ## if the attrname option is defined, skip any other attribute next if ( $attr ne $attrname ); } if ( $attr eq $attrname ) { $foundAttr = 1; } ## skip the "iv_" keys. next if ( !($attr =~ m/ATTR_/) ); ## skip the unknown ones, unless debug is on. if ( !$debug ) { next if ( $attr =~ m/ATTR_TBD/ ); } ## make local copies my $attrType = $targetRef->{$attr}->{'attrtype'} ; my @attrDesc = @{$targetRef->{$attr}->{'attrDesc'}}; my $rawAttrValue = $targetRef->{$attr}->{'attrvalue'} ; ## sanity check if (($rawAttrValue eq Hostboot::_DebugFrameworkVMM::NotFound) || ($rawAttrValue eq Hostboot::_DebugFrameworkVMM::NotPresent)) { ::userDisplay $attr ; ::userDisplay " $attrType "; ::userDisplay $rawAttrValue . ": vaddr=" . (sprintf("0x%X",$targetRef->{$attr}->{'attrvaddr'})) ; return; } if ( scalar( @attrDesc ) == 0 ) { ## print attr and type ::userDisplay $attr, " ", $attrType, " " ; ## Print out value(s) my $attrValue = binToHex($rawAttrValue); ::userDisplay (sprintf( "0x%X ", $attrValue )) ; ::userDisplay "\n" ; } else { ## array. userDisplayArray( $targetRef, $attr ); } last if ( $foundAttr ); } ## end foreach $attr } sub userDisplayArray { my ( $targetRef, $attr ) = @_; my $attrType = $targetRef->{$attr}->{'attrtype'}; my $rawAttrValue = $targetRef->{$attr}->{'attrvalue'}; my @attrDesc = @{$targetRef->{$attr}->{'attrDesc'}}; ## assume max dimension of 3 deep, and always a good 1st dimension my $i = 0; my $j_index = -1; my $k_index = -1; my $size = $attrDesc[$i]; $i++; my $i_index = $attrDesc[$i]; $i++; my $enum = $attrDesc[$i]; $i++; if ( $attrDesc[$i] ) { $i++; $j_index = $attrDesc[$i]; $i++; $i++; if ( $attrDesc[$i] ) { $i++; $k_index = $attrDesc[$i]; $i++; if ( $attrDesc[$i] ) { die "array dimensions > 3 are not supported."; } } } if ( $k_index > 0 ) { userDisplay3dArray( $attr, $attrType, $size, $i_index, $j_index, $k_index, $rawAttrValue ); } elsif ($j_index > 0 ) { userDisplay2dArray( $attr, $attrType, $size, $i_index, $j_index, $rawAttrValue ); } else { ## single array my $upsz = $size*2; my @values = unpack("(H$upsz)*", $rawAttrValue ); ## $$ debug ## ::userDisplay scalar(@values), ": ", join( ", ", @values), "\n" ; my $valindex = 0; for ( my $i=0; $i<$i_index; $i++ ) { ##$$debug ::userDisplay (sprintf("%02x ", $valindex) ); ::userDisplay $attr ; ::userDisplay "[$i]" ; ::userDisplay " $attrType "; ::userDisplay $values[$valindex] ; $valindex++; ::userDisplay "\n"; } ## endfor i } ## end else } sub userDisplay2dArray { my ($attr, $attrType, $size, $i_index, $j_index, $rawAttrValue ) = @_; my $upsz = $size*2; my @values = unpack("(H$upsz)*", $rawAttrValue ); ## $$ debug ## ::userDisplay scalar(@values), ": ", join( ", ", @values), "\n" ; my $valindex = 0; for ( my $i=0; $i<$i_index; $i++ ) { for ( my $j=0; $j<$j_index; $j++ ) { ##$$debug ::userDisplay (sprintf("%02x", $valindex) ); ::userDisplay $attr ; ::userDisplay "[$i][$j]" ; ::userDisplay " $attrType "; ::userDisplay $values[$valindex] ; $valindex++; ::userDisplay "\n"; } ## endfor j } ## endfor i } sub userDisplay3dArray { my ($attr, $attrType, $size, $i_index, $j_index, $k_index, $rawAttrValue) = @_; my $upsz = $size*2; my @values = unpack("(H$upsz)*", $rawAttrValue ); ## $$ debug ## ::userDisplay scalar(@values), ": ", join( ", ", @values), "\n" ; my $valindex = 0; for ( my $i=0; $i<$i_index; $i++ ) { for ( my $j=0; $j<$j_index; $j++ ) { for ( my $k=0; $k<$k_index; $k++ ) { ##$$debug ::userDisplay (sprintf("%02x ", $valindex) ); ::userDisplay $attr ; ::userDisplay "[$i][$j][$k]" ; ::userDisplay " $attrType "; ::userDisplay $values[$valindex] ; $valindex++; ::userDisplay "\n"; } ## endfor k } ## endfor j } ## endfor i } sub cronusTargetStr() { my ( $huid ) = @_; my $cronusTargetStr = "TBD"; ## TBD return $cronusTargetStr; } ## ## translate cronus-type type strings to: ## Integer size in bytes ## Number of integers to read ## Enumerated type flag ## Fills in list(s) of these 3 values that describes each field, ## for example: ## u64[5][6][1] ## ( size=8,num=5,enum=0 ), ## dimension 1 ## ( size=8,num=6,enum=0 ), ## dimension 2 ## ( size=8,num=1,enum=0 ), ## dimension 3 ## ( size=0,num=0,enum=0 ), ## endit ## ## if the attr type is a single simpleType, returns the size in bytes. ## If the attr type is more complicated, return the total size in bytes ## and fill in the passed-in parse Description struct. ## sub parseType { my ( $type, $parseDescRef, $debug ) = @_; my $size = 8; ## default my $num = 1; ## default my $enum = 0; ## default my $totalSize = 1; $_ = $type; if ( m/u8/ ) { $size = 1; } if ( m/u16/ ) { $size = 2; } if ( m/u32/ ) { $size = 4; } if ( m/u64/ ) { $size = 8; } ## @TODO RTC 68517 Add code to display non-simple non-integer types $totalSize = $size; ## remove size spec s/[u][0-9]*[e]*//; ## find any arrays my @arrayDims = split /\[([^\]]*)\]/g ; if ( scalar( @arrayDims ) > 0 ) { ## Array. Build the description struct and calculate the right size my $i = 0; foreach ( @arrayDims ) { ## skip empty array entries next if ( ! m/[0-9]+/ ) ; @{$parseDescRef}[$i] = $size; $i++; ## size in bytes @{$parseDescRef}[$i] = $_; $i++; ## number of vars @{$parseDescRef}[$i] = $enum; $i++; ## enum flag $totalSize *= $_ ; } ## add a terminating record @{$parseDescRef}[$i] = 0; $i++; @{$parseDescRef}[$i] = 0; $i++; @{$parseDescRef}[$i] = 0; $i++; } return $totalSize; } ## ## Fetch Attr Ids, passed a pointer to a Target's attrid list. ## return an array of the attr id's sub getAttrIds() { my ( $targInfoRef, $cacheData, $debug ) = @_; my $pAttrIds = $targInfoRef->{'iv_pAttrNames'}; my $numAttrs = $targInfoRef->{'iv_attr'}; my @attrIds = (); my $rawattrids = readData( $pAttrIds, (ATTRID_SIZE*$numAttrs), $cacheData, $debug ); ## split and convert from binary my @unpackattrids = unpack( "(H8)*", $rawattrids ); my $i = 0; foreach ( @unpackattrids ) { @attrIds[$i] = hex($_); $i++; } return @attrIds; } ## ## fetch the array of pointers to attr values ## return an array of the attr values. sub getAttrValuePtrs() { my ( $targInfoRef, $pAttrValues, $numAttrs, $cacheData, $debug ) = @_; my $pAttrValues = $targInfoRef->{'iv_pAttrValues'}; my $numAttrs = $targInfoRef->{'iv_attr'}; my @attrvalueptrs = (); my @attrValues = (); my $rawattrvalueptrs = readData( $pAttrValues, (ATTRVALUESPTR_SIZE*$numAttrs), $cacheData, $debug ); ## split and convert from binary my @unpackattrvalueptrs = unpack( "(H16)*", $rawattrvalueptrs); my $i = 0; foreach ( @unpackattrvalueptrs ) { @attrvalueptrs[$i] = hex($_); $i++; } return @attrvalueptrs; } # # Utility to read a block of data. Caches 4K blocks to save time. # returns "binary" data # sub readData { my ($vaddr, $size, $cache_data, $debug) = @_; my $result = ""; if ($debug == 2) { ::userDisplay sprintf("Reading $size bytes from vaddr 0x%X\n", $vaddr); } while($size) { my $amount = $size; if ((($vaddr % PAGESIZE) + $size) > PAGESIZE) { $amount = PAGESIZE - ($vaddr % PAGESIZE); if ($debug == 2) { ::userDisplay sprintf("Data crossing page boundary for addr " . "0x%X size $size\n", $vaddr); } } if ($cache_data) { # Read the entire page and cache it my $vpageaddr = $vaddr - ($vaddr % PAGESIZE); if (!defined $pages{$vpageaddr}) { my $paddr = getPhysicalAddr($vpageaddr ); if ((Hostboot::_DebugFrameworkVMM::NotFound eq $paddr) || (Hostboot::_DebugFrameworkVMM::NotPresent eq $paddr)) { return $paddr; } else { if ($debug==2) { ::userDisplay sprintf("Caching data for address ". "0x%X = 0x%x\n", $vpageaddr, $paddr); } $pages{$vpageaddr} = ::readData($paddr, PAGESIZE); } } elsif ($debug==2) { ::userDisplay sprintf("Using cached data for address 0x%X\n", $vpageaddr); } $result = $result. substr($pages{$vpageaddr}, $vaddr % PAGESIZE, $amount); } else { my $paddr = getPhysicalAddr($vaddr); if ((Hostboot::_DebugFrameworkVMM::NotFound eq $paddr) || (Hostboot::_DebugFrameworkVMM::NotPresent eq $paddr)) { return $paddr; } else { $result = $result.::readData($paddr, $amount); } } $vaddr = $vaddr + $amount; $size = $size - $amount; } return $result; } ## ## Read $bytes amount of data from $vaddr, using readData above. ## return a valid hex scalar number. ## Print an error message and return 0 if VirtToPhys says "not present" ## sub readDataHex() { my ( $vaddr, $bytes, $cacheData, $debug ) = @_; my $data = readData( $vaddr, $bytes, $cacheData, $debug ); if ((Hostboot::_DebugFrameworkVMM::NotFound eq $data) || (Hostboot::_DebugFrameworkVMM::NotPresent eq $data)) { ::userDisplay "readDataHex ERROR: ", (sprintf("0x%X",$vaddr)), ": $data\n"; return 0; } my $result = binToHex( $data ); return $result; } ## ## read raw binary string and convert it to a hex scalar ## sub binToHex() { my ( $rawData ) = @_; my $result = hex(unpack("H*",$rawData)); return $result; } # Utility to display a block of data sub userDisplayHex { my $data = shift; my $count = 0; # Make it easier to read by displaying as two bytes chunks my @twobytes = unpack("(H4)*", $data); ::userDisplay "\n "; foreach (@twobytes) { ::userDisplay "$_ "; $count++; if (!($count % 8)) { ::userDisplay "\n "; } } ::userDisplay "\n"; } sub helpInfo { my %info = ( name => "Attr", intro => ["Dump the specified target attribute(s)."], options => { "huid=<HUID>" => ["HUID of the target as a hex number.", "If not specified, will output attribute(s) of all ". "targets."], "attrname=<attribute name>" => ["Attribute to dump.", "If not specified, will output all attributes for the ". "specified target."], "attrfile" => ["specify an alternate attribute " . "information file. Normally this will not be needed."], "debug" => ["More debug output."], }, ); } ## modules must return a 1 at the end 1; __END__
alvintpwang/hostboot
src/build/debug/Hostboot/Attr.pm
Perl
apache-2.0
29,132
=head1 This Week on perl5-porters (29 July / 4 August 2002) Now that perl 5.8.0 is out and flies by itself, the 5.9 development track begins. Learn about what may go (or not) in perl 5.9. Plus the usual amount of bugs. =head2 Some directions for perl 5.9 Hugo van der Sanden posted his views on the general directions of perl 5.9 development. Shortly, he listed (with varying degrees of importance or probability) : improving perl's speed ; cleaning the sources ; converging with Perl 6 (with a possible new perl6ish pragma, to use some of the incompatible Perl 6 constructs or deprecations) ; providing multiple Perl distributions containing a various amount of modules. There was also some handwaving (which I initiated) about having some kind of Perl 5 to Perl 6 or Parrot translator. This would probably involve improving the C<B::> backend framework if this is the way to go. http://groups.google.com/groups?threadm=200207301220.g6UCKtr07589%40crypt.compulink.co.uk (I now give the message links to google, so you can navigate the whole thread. I found this more convenient.) Pseudo-hashes and the old 5005 threads will be removed. Michael G Schwern provided a first patch to cut off pseudo-hashes, that doesn't handle the necessary changes to the core modules, esp. fields.pm and base.pm. Hugo also wondered if non-PerlIO perls should be deprecated. This decision should be based on some real-world feedback -- are there platforms that have problems with PerlIO ? http://groups.google.com/groups?selm=200207301220.g6UCKvQ07607%40crypt.compulink.co.uk =head2 Change in the logic of the CPAN indexer As 5.8.0 is out, some problems arise when the CPAN shell is used to install modules that have a dual life (on CPAN and in the core.) Andreas Koenig has updated the CPAN indexer so that I<it indexes perl distribution only for packages that have no separate lives on CPAN.> All packages that have dual lives have been also re-indexed ; this should solve current problems. =head2 PID and threads on Linux One of the specificities of the implementation of threads on Linux is that threads get different PIDs. So Elizabeth Mattijsen asked for a way to get this PID from inside Perl, because C<$$> is always the process number of thread 0. It turned out that C<POSIX::getpid()> simply returns C<$$>, and that C<$$> is is a read-only scalar, set at startup- and at fork-time. But the system call C<getpid()> returns different values for different threads (on Linux). It was agreed that, to be portable (and POSIX-compliant), C<$$> should return the same value across all threads -- the current behavior is thus correct (but undocumented.) However Perl's built-in function C<getppid()> always performs the underlying C call, and return different values from different threads. This should be fixed. http://groups.google.com/groups?threadm=4.2.0.58.20020801191058.02b8a440%40mickey.dijkmat.nl =head2 A couple of core dumps Somebody reported that writing C<%:: = ""> with warnings enabled leads to immediate segfault (bug #15479). Elizabeth, trying to write something like C<our ${""} : foo = 1>, reported another core dump case (this should be a syntax error) (bug #15898). This lead to a small thread about the right place for regression tests for nonsense code like this. The conclusion is that they should go in the test file that seems the more appropriate for it (in those cases, respectively tests for symbol table hashes and for attributes.) =head2 Schwern's Thoughts from TPC Michael G Schwern sent a list of thoughts and ideas that were discussed at TPC : What new modules should be included in 5.10, and based on which criteria ? The simple criterion he proposes is : I<Will this module help users install more modules?> He suggests notably to borgify CPANPLUS, a simplified LWP, Archive::Tar, Archive::Zip, Module::Build (this implies YAML), and Inline. http://groups.google.com/groups?threadm=20020801160521.GB1064%40ool-18b93024.dyn.optonline.net About Inline, and related to the QA effort, Schwern suggests to test the core API and internals with Inline::C. Continuing on Inline, he emits also the idea that XS core modules may be ported to an Inline::C implementation. Brian Ingerson (author of Inline) acknowledges that Inline::C can be used at perl build-time, but he thinks that the only thing that needs to be installed on a user machine is I<enough of Inline.pm to invoke Dynaloader. About 30 lines of code.> He adds that this is the only part of Inline that he would like to see distributed with 5.9. http://groups.google.com/groups?threadm=20020801161356.GD1064%40ool-18b93024.dyn.optonline.net Finally, Schwern suggests to eliminate the changelogs and the old perldelta manpages from the perl distribution (those are pretty huge and can be distributed separately), and to provide an alternate bzip2 tarball of perl. =head2 In brief Philip Hazel reported a couple of bugs about the C<\C> regexp anchor. (Bugs #15763 and #15774). Ilya Zakharevich reported that list assignment with common variables on both sides (e.g. C<($a,$b) = ($b,$a)>) don't work with aliased variables (e.g. C<($a,$b) = ($c,$d)> where $c is an alias to $b and $d an alias to $a.) Bug #15667. Craig Berry noticed that I<extension building against an installed Perl on VMS is broken in 5.8.0>. He provided a patch, and said also that I<in lieu of the patch, folks can either build extensions against an uninstalled Perl or simply copy the missing files manually.> Elizabeth Mattijsen reported a memory leak in threads::shared. Hopefully this problem will only need a patch to threads::shared, that can be released to CPAN. (Bug #15893.) Bleadperl now reports its version as 5.9.0, and Hugo began to apply patches. We're waiting for the first snapshot... =head2 About this summary This summary brought to you by Rafael Garcia-Suarez, from Lyon, France. -- Nota. I'll be on vacation (and off-line) for two weeks in August : approximately from 12th to 25th. So there will be no summary for those weeks. If you find those summaries helpful, and if you want to become a superhero, take over the report for two little weeks! Please drop me a line at rgarciasuarez at free.fr. (If you find those summaries helpful but don't want to take them over, go send money to YAS. Perhaps they'll hire an interim writer.) This report is also available via a mailing list, which subscription address is F<perl5-summary-subscribe@perl.org>.
rjbs/perlweb
docs/dev/perl5/list-summaries/2002/p5p-200207-5.pod
Perl
apache-2.0
6,464
package DDG::Goodie::GenerateMAC; # ABSTRACT: generates a random network MAC address use strict; use DDG::Goodie; triggers startend => "generate mac addr", "generate mac address", "random mac addr", "random mac address", "mac address generator", "mac address random"; zci answer_type => "MAC Address"; zci is_cached => 0; primary_example_queries 'please generate mac address'; description 'generates a MAC address'; name "GenerateMAC"; attribution github => ['https://github.com/UnGround', 'Charlie Belmer'], web => ['http://www.charliebelmer.com', 'Charlie Belmer']; handle remainder => sub { # Ensure rand is seeded for each process srand(); my $address = join(':', map { sprintf '%0.2X', rand(255) } (1 .. 6)); return "Here's a random MAC address: $address", structured_answer => { input => [], operation => 'Random MAC address', result => $address }; }; 1;
kavithaRajagopalan/zeroclickinfo-goodies
lib/DDG/Goodie/GenerateMAC.pm
Perl
apache-2.0
1,050
package # Date::Manip::Offset::off024; # Copyright (c) 2008-2015 Sullivan Beck. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # This file was automatically generated. Any changes to this file will # be lost the next time 'tzdata' is run. # Generated on: Wed Nov 25 11:44:43 EST 2015 # Data version: tzdata2015g # Code version: tzcode2015g # This module contains data from the zoneinfo time zone database. The original # data was obtained from the URL: # ftp://ftp.iana.org/tz use strict; use warnings; require 5.010000; our ($VERSION); $VERSION='6.52'; END { undef $VERSION; } our ($Offset,%Offset); END { undef $Offset; undef %Offset; } $Offset = '+01:05:21'; %Offset = ( 0 => [ 'europe/vienna', ], ); 1;
jkb78/extrajnm
local/lib/perl5/Date/Manip/Offset/off024.pm
Perl
mit
852
#PODNAME: DBD::Oracle::Troubleshooting #ABSTRACT: Tips and Hints to Troubleshoot DBD::Oracle __END__ =pod =head1 NAME DBD::Oracle::Troubleshooting - Tips and Hints to Troubleshoot DBD::Oracle =head1 VERSION version 1.50 =head1 CONNECTING TO ORACLE If you are reading this it is assumed that you have successfully installed DBD::Oracle and you are having some problems connecting to Oracle. First off you will have to tell DBD::Oracle where the binaries reside for the Oracle client it was compiled against. This is the case when you encounter a DBI connect('','system',...) failed: ERROR OCIEnvNlsCreate. error in Linux or in Windows when you get OCI.DLL not found The solution to this problem in the case of Linux is to ensure your 'ORACLE_HOME' (or LD_LIBRARY_PATH for InstantClient) environment variable points to the correct directory. export ORACLE_HOME=/app/oracle/product/xx.x.x For Windows the solution is to add this value to you PATH PATH=c:\app\oracle\product\xx.x.x;%PATH% If you get past this stage and get a ORA-12154: TNS:could not resolve the connect identifier specified error then the most likely cause is DBD::ORACLE cannot find your .ORA (F<TNSNAMES.ORA>, F<LISTENER.ORA>, F<SQLNET.ORA>) files. This can be solved by setting the TNS_ADMIN environment variable to the directory where these files can be found. If you get to this stage and you have either one of the following errors; ORA-12560: TNS:protocol adapter error ORA-12162: TNS:net service name is incorrectly specified usually means that DBD::Oracle can find the listener but the it cannot connect to the DB because the listener cannot find the DB you asked for. =head2 Oracle utilities If you are still having problems connecting then the Oracle adapters utility may offer some help. Run these two commands: $ORACLE_HOME/bin/adapters $ORACLE_HOME/bin/adapters $ORACLE_HOME/bin/sqlplus and check the output. The "Protocol Adapters" should include at least "IPC Protocol Adapter" and "TCP/IP Protocol Adapter". If it generates any errors which look relevant then please talk to your Oracle technical support (and not the dbi-users mailing list). =head2 Connecting using a bequeather If you are using a bequeather to connect to a server on the same host as the client, you might have to add bequeath_detach = yes to your sqlnet.ora file or you won't be able to safely use fork/system functions in Perl. See the discussion at L<http://www.nntp.perl.org/group/perl.dbi.dev/2012/02/msg6837.html> and L<http://www.nntp.perl.org/group/perl.dbi.users/2009/06/msg34023.html> for more gory details. =head1 USING THE LONG TYPES Some examples related to the use of LONG types are available in the C<examples/> directory of the distribution. =head1 Can't find I<libclntsh.so> I<libclntsh.so> is the shared library composed of all the other Oracle libs you used to have to statically link. libclntsh.so should be in I<$ORACLE_HOME/lib>. If it's missing, try running I<$ORACLE_HOME/lib/genclntsh.sh> and it should create it. Never copy I<libclntsh.so> to a different machine or Oracle version. If DBD::Oracle was built on a machine with a different path to I<libclntsh.so> then you'll need to set set an environment variable, typically I<LD_LIBRARY_PATH>, to include the directory containing I<libclntsh.so>. I<LD_LIBRARY_PATH> is typically ignored if the script is running set-uid (which is common in some httpd/CGI configurations). In this case either rebuild with I<LD_RUN_PATH> set to include the path to I<libclntsh> or create a symbolic link so that I<libclntsh> is available via the same path as it was when the module was built. (On Solaris the command "ldd -s Oracle.so" can be used to see how the linker is searching for it.) =head1 Miscellaneous =head2 Crash with an open connection and Module::Runtime in mod_perl2 See RT 72989 (https://rt.cpan.org/Ticket/Display.html?id=72989) Apache2 MPM Prefork with mod_perl2 will crash if Module::Runtime is loaded, and an Oracle connection is opened through PerlRequire (before forking). It looks like this was fixed in 0.012 of Module::Runtime. =head2 bin_param_inout swapping return values See RT 71819 (https://rt.cpan.org/Ticket/Display.html?id=71819) It seems that in some older versions of Oracle Instant Client (certainly 10.2.0.4.0) when output parameters are bound with lengths greater than 3584 the output parameters can be returned in the wrong placeholders. It is reported fixed in Instant Client 11.2.0.2.0. =head1 AUTHORS =over 4 =item * Tim Bunce <timb@cpan.org> =item * John Scoles =item * Yanick Champoux <yanick@cpan.org> =item * Martin J. Evans <mjevans@cpan.org> =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 1994 by Tim Bunce. 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
amidoimidazol/bio_info
Beginning Perl for Bioinformatics/lib/DBD/Oracle/Troubleshooting.pod
Perl
mit
4,915
######################################################################## # Bio::KBase::ObjectAPI::KBaseBiochem::Reaction - This is the moose object corresponding to the Reaction object # Authors: Christopher Henry, Scott Devoid, Paul Frybarger # Contact email: chenry@mcs.anl.gov # Development location: Mathematics and Computer Science Division, Argonne National Lab # Date of module creation: 2012-03-26T23:22:35 ######################################################################## use strict; use Bio::KBase::ObjectAPI::KBaseBiochem::DB::Reaction; package Bio::KBase::ObjectAPI::KBaseBiochem::Reaction; use Bio::KBase::ObjectAPI::utilities; use Moose; use namespace::autoclean; extends 'Bio::KBase::ObjectAPI::KBaseBiochem::DB::Reaction'; #*********************************************************************************************************** # ADDITIONAL ATTRIBUTES: #*********************************************************************************************************** has definition => ( is => 'rw',printOrder => 3, isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_builddefinition' ); has equation => ( is => 'rw',printOrder => 4, isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildequation' ); has equationDir => ( is => 'rw',printOrder => 4, isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildequationdirection' ); has code => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildcode' ); has equationCode => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildequationcode' ); has revEquationCode => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildrevequationcode' ); has equationCompFreeCode => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildcompfreeequationcode' ); has revEquationCompFreeCode => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildrevcompfreeequationcode' ); has equationFormula => ( is => 'rw', isa => 'Str', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildequationformula' ); has balanced => ( is => 'rw', isa => 'Bool',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildbalanced' ); has mapped_uuid => ( is => 'rw', isa => 'ModelSEED::uuid',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildmapped_uuid' ); has compartment => ( is => 'rw', isa => 'Bio::KBase::ObjectAPI::KBaseBiochem::Compartment',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildcompartment' ); has roles => ( is => 'rw', isa => 'ArrayRef',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildroles' ); has isTransport => ( is => 'rw', isa => 'Bool',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildisTransport' ); has unknownStructure => ( is => 'rw', isa => 'Bool',printOrder => '-1', type => 'msdata', metaclass => 'Typed', lazy => 1, builder => '_buildunknownStructure' ); #*********************************************************************************************************** # BUILDERS: #*********************************************************************************************************** sub _builddefinition { my ($self) = @_; return $self->createEquation({format=>"name",hashed=>0}); } sub _buildequation { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>0}); } sub _buildequationdirection { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>0,direction=>1}); } sub _buildequationcode { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>1,protons=>0,direction=>0}); } sub _buildcode { my ($self) = @_; return $self->createEquation({format=>"id"}); } sub _buildrevequationcode { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>1,protons=>0,reverse=>1,direction=>0}); } sub _buildcompfreeequationcode { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>1,compts=>0}); } sub _buildrevcompfreeequationcode { my ($self) = @_; return $self->createEquation({format=>"id",hashed=>1,compts=>0,reverse=>1}); } sub _buildequationformula { my ($self,$args) = @_; return $self->createEquation({format=>"formula",hashed=>0,water=>0}); } sub _buildbalanced { my ($self,$args) = @_; my $result = $self->checkReactionMassChargeBalance({rebalanceProtons => 0}); return $result->{balanced}; } sub _buildmapped_uuid { my ($self) = @_; return "00000000-0000-0000-0000-000000000000"; } sub _buildcompartment { my ($self) = @_; my $comp = $self->parent()->queryObject("compartments",{name => "Cytosol"}); if (!defined($comp)) { Bio::KBase::ObjectAPI::utilities::error("Could not find cytosol compartment in biochemistry!"); } return $comp; } sub _buildroles { my ($self) = @_; my $hash = $self->parent()->reactionRoleHash(); if (defined($hash->{$self->uuid()})) { return [keys(%{$hash->{$self->uuid()}})]; } return []; } sub _buildisTransport { my ($self) = @_; my $rgts = $self->reagents(); if (!defined($rgts->[0])) { return 0; } my $cmp = $rgts->[0]->compartment_ref(); for (my $i=0; $i < @{$rgts}; $i++) { if ($rgts->[$i]->compartment_ref() ne $cmp) { return 1; } } return 0; } sub _buildunknownStructure { my ($self) = @_; my $rgts = $self->reagents(); for (my $i=0; $i < @{$rgts}; $i++) { if (defined($rgts->[$i]->compound()->structure_ref())) { return 1; } } return 0; } #*********************************************************************************************************** # CONSTANTS: #*********************************************************************************************************** #*********************************************************************************************************** # FUNCTIONS: #*********************************************************************************************************** sub getAlias { my ($self,$set) = @_; my $aliases = $self->getAliases($set); return (@$aliases) ? $aliases->[0] : undef; } sub getAliases { my ($self,$setName) = @_; return [] unless(defined($setName)); my $output = []; my $aliases = $self->parent()->reaction_aliases()->{$self->id()}; if (defined($aliases) && defined($aliases->{$setName})) { return $aliases->{$setName}; } return $output; } sub allAliases { my ($self) = @_; my $output = []; my $aliases = $self->parent()->reaction_aliases()->{$self->id()}; if (defined($aliases)) { foreach my $set (keys(%{$aliases})) { push(@{$output},@{$aliases->{$set}}); } } return $output; } sub hasAlias { my ($self,$alias,$setName) = @_; my $aliases = $self->parent()->reaction_aliases()->{$self->id()}; if (defined($aliases) && defined($aliases->{$setName})) { foreach my $searchalias (@{$aliases->{$setName}}) { if ($searchalias eq $alias) { return 1; } } } return 0; } =head3 hasReagent Definition: boolean = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->hasReagent(string(uuid)); Description: Checks to see if a reaction contains a reagent =cut sub hasReagent { my ($self,$cpd) = @_; my $rgts = $self->reagents(); if (!defined($rgts->[0])) { return 0; } for (my $i=0; $i < @{$rgts}; $i++) { if ($rgts->[$i]->compound()->id() eq $cpd) { return 1; } } return 0; } =head3 hasReagentInCompartment Definition: boolean = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->hasReagentInCompartment(string(uuid), string(uuid)); Description: Checks to see if a reaction contains a reagent in a specific oompartment =cut sub hasReagentInCompartment { my ($self,$rgt_uuid,$cmp_uuid) = @_; my $rgts = $self->reagents(); if (!defined($rgts->[0])) { return 0; } for (my $i=0; $i < @{$rgts}; $i++) { if ($rgts->[$i]->compound_ref() eq $rgt_uuid && $rgts->[$i]->compartment_ref() eq $cmp_uuid) { return 1; } } return 0; } =head3 createEquation Definition: string = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->createEquation({ format => string(uuid), hashed => 0/1(0) }); Description: Creates an equation for the core reaction with compounds specified according to the input format =cut sub createEquation { my $self = shift; my $args = Bio::KBase::ObjectAPI::utilities::args([], { format => "id", hashed => 0, water => 1, compts=>1, reverse=>0, direction=>1,protons => 1 }, @_); my $rgt = $self->reagents(); my $rgtHash; my $rxnCompID = $self->compartment()->id(); my $hcpd = $self->parent()->checkForProton(); if (!defined($hcpd) && $args->{hashed}==1) { Bio::KBase::ObjectAPI::utilities::error("Could not find proton in biochemistry!"); } my $wcpd = $self->parent()->checkForWater(); if (!defined($wcpd) && $args->{water}==1) { Bio::KBase::ObjectAPI::utilities::error("Could not find water in biochemistry!"); } for (my $i=0; $i < @{$rgt}; $i++) { my $id = $rgt->[$i]->compound()->id(); next if $args->{protons}==0 && $id eq $hcpd->id() && !$self->isTransport(); next if $args->{water}==0 && $id eq $wcpd->id(); if ($args->{format} eq "name" || $args->{format} eq "id") { my $function = $args->{format}; $id = $rgt->[$i]->compound()->$function(); } elsif ($args->{format} ne "uuid") { if($args->{format} ne "formula"){ $id = $rgt->[$i]->compound()->getAlias($args->{format}); } } if (!defined($rgtHash->{$id}->{$rgt->[$i]->compartment()->id()})) { $rgtHash->{$id}->{$rgt->[$i]->compartment()->id()} = 0; } $rgtHash->{$id}->{$rgt->[$i]->compartment()->id()} += $rgt->[$i]->coefficient(); } #Deliberately commented out for the time being, as protons are being added to the reagents list a priori # if (defined($self->defaultProtons()) && $self->defaultProtons() != 0 && !$args->{hashed}) { # my $id = $hcpd->uuid(); # if ($args->{format} eq "name" || $args->{format} eq "id") { # my $function = $args->{format}; # $id = $hcpd->$function(); # } elsif ($args->{format} ne "uuid") { # $id = $hcpd->getAlias($args->{format}); # } # $rgtHash->{$id}->{$rxnCompID} += $self->defaultProtons(); # } my $reactcode = ""; my $productcode = ""; my $sign = " <=> "; if($args->{direction}==1){ $sign = " => " if $self->direction() eq ">"; $sign = " <= " if $self->direction() eq "<"; } my $sortedCpd = [sort(keys(%{$rgtHash}))]; for (my $i=0; $i < @{$sortedCpd}; $i++) { my $printId=$sortedCpd->[$i]; if($args->{format} eq "formula"){ $printId=$self->parent()->getObject("compounds",$sortedCpd->[$i])->formula(); } my $comps = [sort(keys(%{$rgtHash->{$sortedCpd->[$i]}}))]; for (my $j=0; $j < @{$comps}; $j++) { my $compartment = "[".$comps->[$j]."]"; $compartment="" if !$args->{compts}; if ($rgtHash->{$sortedCpd->[$i]}->{$comps->[$j]} < 0) { my $coef = -1*$rgtHash->{$sortedCpd->[$i]}->{$comps->[$j]}; if (length($reactcode) > 0) { $reactcode .= " + "; } $reactcode .= "(".$coef.") ".$printId.$compartment; } elsif ($rgtHash->{$sortedCpd->[$i]}->{$comps->[$j]} > 0) { if (length($productcode) > 0) { $productcode .= " + "; } $productcode .= "(".$rgtHash->{$sortedCpd->[$i]}->{$comps->[$j]}.") ".$printId.$compartment; } } } my $reaction_string = $reactcode.$sign.$productcode; if($args->{reverse}==1){ $reaction_string = $productcode.$sign.$reactcode; } if ($args->{hashed} == 1) { return Digest::MD5::md5_hex($reaction_string); } return $reaction_string; } =head3 loadFromEquation Definition: Bio::KBase::ObjectAPI::ReactionInstance = Bio::KBase::ObjectAPI::Reaction->loadFromEquation({ equation => REQUIRED:string:stoichiometric equation with reactants and products, aliasType => REQUIRED:string:alias type used in equation }); Description: Parses the input equation, generates the reaction stoichiometry based on the equation, and returns the reaction instance for the equation =cut sub loadFromEquation { my $self = shift; my $args = Bio::KBase::ObjectAPI::utilities::args(["equation","aliasType"], {compartment=>"c",checkDuplicates=>0}, @_); my $bio = $self->parent(); my @TempArray = split(/\s+/, $args->{equation}); my $CurrentlyOnReactants = 1; my $Coefficient = 1; my $parts = []; my $cpdCmpHash; my $compHash; my $compUUIDHash; my $cpdHash; my $cpdCmpCount; for (my $i = 0; $i < @TempArray; $i++) { #some identifiers may include '=' sign, need to skip actual '+' in equation next if $TempArray[$i] eq "+"; if( $TempArray[$i] =~ m/=/ || $TempArray[$i] =~ m/-->/ || $TempArray[$i] =~ m/<--/) { $CurrentlyOnReactants = 0; } elsif ($TempArray[$i] =~ m/^\(([eE\-\.\d]+)\)$/ || $TempArray[$i] =~ m/^([eE\-\.\d]+)$/) { $Coefficient = $1; } elsif ($TempArray[$i] =~ m/(^[\/\\<>\w,&;'#:\{\}\-+\(\)]+)/){ $Coefficient *= -1 if ($CurrentlyOnReactants); my $NewRow = { compound => $1, compartment => $args->{compartment}, coefficient => $Coefficient }; my $Compound=quotemeta($NewRow->{compound}); if ($TempArray[$i] =~ m/^${Compound}\[([a-zA-Z]+)\]/) { $NewRow->{compartment} = lc($1); } my $comp = $compHash->{$NewRow->{compartment}}; unless(defined($comp)) { $comp = $bio->queryObject("compartments", { id => $NewRow->{compartment} }); } unless(defined($comp)) { Bio::KBase::ObjectAPI::utilities::USEWARNING("Unrecognized compartment '".$NewRow->{compartment}."' used in reaction ".$args->{rxnId}); $comp = $bio->add("compartments",{ locked => "0", id => $NewRow->{compartment}, name => $NewRow->{compartment}, hierarchy => 3}); } $compUUIDHash->{$comp->uuid()} = $comp; $compHash->{$comp->id()} = $comp; $NewRow->{compartment} = $comp; my $cpd; if($args->{aliasType} eq "id"){ $cpd = $bio->getObject("compounds",$NewRow->{compound}); }else{ $cpd = $bio->getObjectByAlias("compounds",$NewRow->{compound},$args->{aliasType}); } if(!defined($cpd)) { Bio::KBase::ObjectAPI::utilities::USEWARNING("Unrecognized compound '".$NewRow->{compound}."' used in reaction ".$args->{rxnId}); if(defined($args->{autoadd}) && $args->{autoadd}==1){ Bio::KBase::ObjectAPI::utilities::verbose("Compound '".$NewRow->{compound}."' automatically added to database"); $cpd = $bio->add("compounds",{ locked => "0", name => $NewRow->{compound}, abbreviation => $NewRow->{compound} }); $bio->addAlias({ attribute => "compounds", aliasName => $args->{aliasType}, alias => $NewRow->{compound}, uuid => $cpd->uuid() }); }else{ return 0; } } $NewRow->{compound} = $cpd; if (!defined($cpdCmpHash->{$cpd->uuid()}->{$comp->uuid()})) { $cpdCmpHash->{$cpd->uuid()}->{$comp->uuid()} = 0; } $cpdCmpHash->{$cpd->uuid()}->{$comp->uuid()} += $Coefficient; $cpdHash->{$cpd->uuid()} = $cpd; $cpdCmpCount->{$cpd->uuid()."_".$comp->uuid()}++; push(@$parts, $NewRow); $Coefficient = 1; } } foreach my $cpduuid (keys(%{$cpdCmpHash})) { foreach my $cmpuuid (keys(%{$cpdCmpHash->{$cpduuid}})) { # Do not include reagents with zero coefficients next if $cpdCmpHash->{$cpduuid}->{$cmpuuid} == 0; $self->add("reagents", { compound_ref => $cpduuid, compartment_ref => $cmpuuid, coefficient => $cpdCmpHash->{$cpduuid}->{$cmpuuid}, isCofactor => 0, }); } } #multiple instances of the same reactant in the same compartment is unacceptable. #however, these aren't rejected, (no duplicate reagents are created in the code above #and instead are accounted for in checkReactionMassChargeBalance() if($args->{checkDuplicates}==1 && scalar( grep { $cpdCmpCount->{$_} >1 } keys %$cpdCmpCount)>0){ return 0; }else{ return 1; } } =head3 checkReactionCueBalance Definition: {} = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->checkReactionCueBalance({}); Description: Checks if the cues in the reaction can be balanced =cut sub checkReactionCueBalance { my $self = shift; #Adding up atoms and charge from all reagents my $rgts = $self->reagents(); #balance out reagents in case of 'cpderror' my %reagents=(); foreach my $rgt (@$rgts){ $reagents{$rgt->compound_ref()}+=$rgt->coefficient(); } #balance out cues my %Cues=(); foreach my $rgt ( grep { $reagents{$_->compound_ref()} != 0 } @$rgts ){ my %cues = %{$rgt->compound()->cues()}; foreach my $cue (keys %cues){ $Cues{$cue}+=($cues{$cue}*$rgt->coefficient()); } } %Cues = map { $_ => $Cues{$_} } grep { $Cues{$_} != 0 } keys %Cues; $self->cues(\%Cues); } =head3 calculateEnergyofReaction Definition: {} = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->calculateEnergyofReaction({}); Description: calculates the energy of reaction =cut sub calculateEnergyofReaction{ my $self=shift; my %Cues=%{$self->cues()}; if($self->status() eq "EMPTY" || $self->status() eq "CPDFORMERROR"){ $self->deltaG("10000000"); $self->deltaGErr("10000000"); return; } my $biochem=$self->parent(); my $noDeltaG=0; my %cue_dG=(); my %cue_dGE=(); foreach my $cue( grep { $Cues{$_} !=0 } keys %Cues){ $cue_dG{$cue}=$biochem->getObject("cues",$cue)->deltaG(); $cue_dGE{$cue}=$biochem->getObject("cues",$cue)->deltaGErr(); $noDeltaG=1 if !defined($cue_dG{$cue}) || $cue_dG{$cue} == -10000 || $cue_dG{$cue} == 10000000; } if($noDeltaG){ $self->deltaG("10000000"); $self->deltaGErr("10000000"); return; } my $deltaG=0.0; my $deltaGErr=0.0; foreach my $cue (keys %Cues){ $deltaG+=($cue_dG{$cue}*$Cues{$cue}); $deltaGErr+=(($cue_dGE{$cue}*$Cues{$cue})**2); } $deltaGErr=$deltaGErr**0.5; $deltaGErr=2.0 if !$deltaGErr; $deltaG=sprintf("%.2f",$deltaG); $deltaGErr=sprintf("%.2f",$deltaGErr); $self->deltaG($deltaG); $self->deltaGErr($deltaGErr); } =head3 estimateThermoReversibility Definition: "" = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->estimateThermoReversibility({}); Description: Checks if the cues in the reaction can be balanced =cut sub estimateThermoReversibility{ my $self=shift; my $args = Bio::KBase::ObjectAPI::utilities::args([], { direction=>0 }, @_); Bio::KBase::ObjectAPI::utilities::set_verbose(1); if($self->deltaG() eq "10000000"){ $self->thermoReversibility("?"); return "No deltaG"; } my $biochem = $self->parent(); my $TEMPERATURE=298.15; my $GAS_CONSTANT=0.0019858775; my $RT_CONST=$TEMPERATURE*$GAS_CONSTANT; my $FARADAY = 0.023061; # kcal/vol gram divided by 1000? #Calculate MdeltaG my ($max,$min)=(0.02,0.00001); my ($rct_min,$rct_max)=(0.0,0.0); my ($pdt_min,$pdt_max)=(0.0,0.0); foreach my $rgt (@{$self->reagents()}){ next if $rgt->compound_ref() eq $biochem->checkForProton()->uuid() || $rgt->compound_ref() eq $biochem->checkForWater()->uuid(); my ($tmx,$tmn)=($max,$min); if($rgt->compartment->id() eq "e"){ ($tmx,$tmn)=(1.0,0.0000001); } if($rgt->coefficient()<0){ $rct_min += ($rgt->coefficient()*log($tmn)); $rct_max += ($rgt->coefficient()*log($tmx)); }else{ $pdt_min += ($rgt->coefficient()*log($tmn)); $pdt_max += ($rgt->coefficient()*log($tmx)); } } my $deltaGTransport=0.0; if($self->isTransport()){ # my $deltadpsiG=0.0; # my $deltadconcG=0.0; # my $internalpH=7.0; # my $externalpH=7.5; # my $minpH=7.5; # my $maxpH=7.5; # foreach my $rgt (@{$self->reagents()}){ # if($r->{"DATABASE"}->[0] eq $p->{"DATABASE"}->[0]){ # if($r->{"COMPARTMENT"}->[0] ne $p->{"COMPARTMENT"}){ #Find number of mols transported #And direction of transport # my $tempCoeff = 0; # my $tempComp=""; # if($r->{"COEFFICIENT"}->[0] < $p->{"COEFFICIENT"}->[0]){ # $tempCoeff=$p->{"COEFFICIENT"}->[0]; # $tempComp=$p->{"COMPARTMENT"}->[0]; # }else{ # $tempCoeff=$r->{"COEFFICIENT"}->[0]; # $tempComp=$r->{"COMPARTMENT"}->[0]; # } #find direction of transport based on difference in concentrations # my $conc_diff=0.0; # if($tempComp ne "c"){ # $conc_diff=$internalpH-$externalpH; # }else{ # $conc_diff=$externalpH-$internalpH # } # my $delta_psi = 33.33 * $conc_diff - 143.33; # my $cDB=$self->figmodel()->database()->get_object('compound',{id=>$r->{"DATABASE"}->[0]}); # my $net_charge=0.0; # if(!$cDB || $cDB->charge() eq "" || $cDB->charge() eq "10000000"){ # print STDERR "Transporting ",$r->{"DATABASE"}->[0]," but no charge\n"; # }else{ # $net_charge=$cDB->charge()*$tempCoeff; # } # $deltadpsiG += $net_charge * $FARADAY * $delta_psi; # $deltadconcG += -2.3 * $RT_CONST * $conc_diff * $tempCoeff; # } # } # } #if($r->{"DATABASE"}->[0] eq "cpd00067"){ #$extCoeff -= ($DPSI_COEFF-$RT_CONST*1)*$tempCoeff; #$intCoeff += ($DPSI_COEFF-$RT_CONST*1)*$tempCoeff; #}else{ #$extCoeff -= $DPSI_COEFF*$charge*$tempCoeff; #$intCoeff += $DPSI_COEFF*$charge*$tempCoeff; #} #Then for the whole reactant #if (HinCoeff < 0) { # DeltaGMin += -HinCoeff*IntpH + -HextCoeff*MaxExtpH; # DeltaGMax += -HinCoeff*IntpH + -HextCoeff*MinExtpH; # mMDeltaG += -HinCoeff*IntpH + -HextCoeff*(IntpH+0.5); #} #else { # DeltaGMin += -HinCoeff*IntpH + -HextCoeff*MinExtpH; # DeltaGMax += -HinCoeff*IntpH + -HextCoeff*MaxExtpH; # mMDeltaG += -HinCoeff*IntpH + -HextCoeff*(IntpH+0.5); #} } my $storedmax=$self->deltaG()+$deltaGTransport+($RT_CONST*$pdt_max)+($RT_CONST*$rct_min)+$self->deltaGErr(); my $storedmin=$self->deltaG()+$deltaGTransport+($RT_CONST*$pdt_min)+($RT_CONST*$rct_max)-$self->deltaGErr(); $storedmax=sprintf("%.4f",$storedmax); $storedmin=sprintf("%.4f",$storedmin); if($storedmax<0){ $self->thermoReversibility(">"); $self->direction(">") if $args->{direction}; return "MdeltaG:".$storedmin.">".$storedmax; } if($storedmin>0){ $self->thermoReversibility("<"); $self->direction("<") if $args->{direction}; return "MdeltaG:".$storedmin."<".$storedmax; } #Do heuristics #1: ATP hydrolysis transport #1a: Find Phosphate stuff my %PhoIDs=("ATP" => { "ModelSEED" => "cpd00002", "KEGG" => "C00002", "MetaCyc" => "ATP", "UUID" =>"" }, "ADP" => { "ModelSEED" => "cpd00008", "KEGG" => "C00008", "MetaCyc" => "ADP", "UUID" =>"" }, "AMP" => { "ModelSEED" => "cpd00018", "KEGG" => "C00020", "MetaCyc" => "AMP", "UUID" =>"" }, "Pi" => { "ModelSEED" => "cpd00009", "KEGG" => "C00009", "MetaCyc" => "Pi", "UUID" =>"" }, "Ppi" => { "ModelSEED" => "cpd00012", "KEGG" => "C00013", "MetaCyc" => "PPI", "UUID" =>"" }); my $Source="None"; foreach my $src ("KEGG","MetaCyc","ModelSEED"){ my $cpdObj = $biochem->getObjectByAlias("compounds",$PhoIDs{"Pi"}{$src},$src); if($cpdObj){ $Source=$src; last; } } if($Source eq "None"){ Bio::KBase::ObjectAPI::utilities::verbose("Cannot use heuristics with atypical biochemistry aliases"); return "Error"; } foreach my $cpd (keys %PhoIDs){ my $cpdObj = $biochem->getObjectByAlias("compounds",$PhoIDs{$cpd}{$Source},$Source); if($cpdObj){ $PhoIDs{$cpd}{"UUID"}=$cpdObj->uuid(); }else{ Bio::KBase::ObjectAPI::utilities::verbose("Unable to find phopsphate compound in biochemistry: $cpd"); return "Error"; } } my %PhoHash=(); my %Comps=(); my $Contains_Protons=0; foreach my $rgt (@{$self->reagents()}){ $Comps{$rgt->compartment()->id()}=1; $Contains_Protons=1 if $rgt->compartment()->id() ne "c" && $rgt->compound_ref() eq $biochem->checkForProton()->uuid(); foreach my $cpd (keys %PhoIDs){ $PhoHash{$cpd} += $rgt->coefficient() if $PhoIDs{$cpd}{"UUID"} eq $rgt->compound_ref(); } } #1b: ATP Synthase is reversible if(scalar(keys %Comps)>1 && exists($PhoHash{"ATP"}) && $Contains_Protons){ $self->thermoReversibility("="); $self->direction("=") if $args->{direction}; return "ATPS"; } #1b: Find ABC Transporters (but not ATP Synthase) if(scalar(keys %Comps)>1 && exists($PhoHash{"ATP"}) && !$Contains_Protons){ my $dir="="; if($PhoHash{"ATP"}<0){ $dir=">"; }elsif($PhoHash{"ATP"}>0){ $dir="<"; } $self->thermoReversibility($dir); $self->direction($dir) if $args->{direction}; return "ABCT: ".$dir; } #2: Calculate mMdeltaG my %GasIDs=("CO2"=> { "ModelSEED" => "cpd00011", "KEGG" => "C00011", "MetaCyc" => "CARBON-DIOXIDE", "UUID" =>"" }, "O2" => { "ModelSEED" => "cpd00007", "KEGG" => "C00007", "MetaCyc" => "OXYGEN-MOLECULE", "UUID" =>"" }, "H2" => { "ModelSEED" => "cpd11640", "KEGG" => "C00282", "MetaCyc" => "HYDROGEN-MOLECULE", "UUID" =>"" }); foreach my $cpd (keys %GasIDs){ my $cpdObj = $biochem->getObjectByAlias("compounds",$GasIDs{$cpd}{$Source},$Source); if($cpdObj){ $GasIDs{$cpd}{"UUID"}=$cpdObj->uuid(); }else{ Bio::KBase::ObjectAPI::utilities::verbose("Unable to find gas compound in biochemistry: $cpd"); return "Error"; } } my $conc=0.001; my $rgt_total=0.0; foreach my $rgt (@{$self->reagents()}){ next if $rgt->compound_ref() eq $biochem->checkForProton()->uuid() || $rgt->compound_ref() eq $biochem->checkForWater()->uuid(); my $tconc=$conc; if($rgt->compound_ref() eq $GasIDs{"CO2"}{"UUID"}){ $tconc=0.0001; } if($rgt->compound_ref() eq $GasIDs{"O2"}{"UUID"} || $rgt->compound_ref() eq $GasIDs{"H2"}{"UUID"}){ $tconc=0.000001; } $rgt_total+=($rgt->coefficient()*log($tconc)); } my $mMdeltaG=$self->deltaG()+($RT_CONST*$rgt_total); $mMdeltaG=sprintf("%.4f",$mMdeltaG); if($mMdeltaG >= -2 && $mMdeltaG <= 2) { $self->thermoReversibility("="); $self->direction("=") if $args->{direction}; return "mMdeltaG: $mMdeltaG"; } #3: Calculate low energy points #3a: Find minimum Phosphate stuff my $LowEnergyPoints=0; my $minimum=10000; if(exists($PhoHash{"ATP"}) && exists($PhoHash{"Pi"}) && exists($PhoHash{"ADP"})){ foreach my $key ("ATP", "ADP", "Pi"){ if(exists($PhoHash{$key})){ $minimum=$PhoHash{$key} if $PhoHash{$key}<$minimum; } } $LowEnergyPoints=$minimum if $minimum<10000; }elsif(exists($PhoHash{"ATP"}) && exists($PhoHash{"Ppi"}) && exists($PhoHash{"AMP"})){ foreach my $key ("ATP", "AMP", "Ppi"){ if(exists($PhoHash{$key})){ $minimum=$PhoHash{$key} if $PhoHash{$key}<$minimum; } } $LowEnergyPoints=$minimum if $minimum<10000; } #3b:Find other low energy compounds #taken from software/mfatoolkit/Parameters/Defaults.txt my %LowEIDs=("CO2" => { "ModelSEED" => "cpd00011", "KEGG" => "C00011", "MetaCyc" => "CARBON-DIOXIDE", "UUID" =>"" }, "NH3" => { "ModelSEED" => "cpd00013", "KEGG" => "C00014", "MetaCyc" => "AMMONIA", "UUID" =>"" }, "ACP" => { "ModelSEED" => "cpd11493", "KEGG" => "C00229", "MetaCyc" => "ACP", "UUID" =>"" }, "Pi" => { "ModelSEED" => "cpd00009", "KEGG" => "C00009", "MetaCyc" => "Pi", "UUID" =>"" }, "Ppi" => { "ModelSEED" => "cpd00012", "KEGG" => "C00013", "MetaCyc" => "PPI", "UUID" =>"" }, "CoA" => { "ModelSEED" => "cpd00010", "KEGG" => "C00010", "MetaCyc" => "CO-A", "UUID" =>"" }, "DHL" => { "ModelSEED" => "cpd00449", "KEGG" => "C00579", "MetaCyc" => "DIHYDROLIPOAMIDE", "UUID" =>"" }, "CO3" => { "ModelSEED" => "cpd00242", "KEGG" => "C00288", "MetaCyc" => "HCO3", "UUID" =>"" }); my %LowEUUIDs=(); foreach my $cpd (keys %LowEIDs){ my $cpdObj = $biochem->getObjectByAlias("compounds",$LowEIDs{$cpd}{$Source},$Source); if($cpdObj){ $LowEIDs{$cpd}{"UUID"}=$cpdObj->uuid(); $LowEUUIDs{$cpdObj->uuid()}=1; }else{ Bio::KBase::ObjectAPI::utilities::verbose("Unable to find low energy compound in biochemistry: $cpd"); return "Error"; } } my $LowE_total=0; foreach my $rgt (@{$self->reagents()}){ if(exists($LowEUUIDs{$rgt->compound_ref()})){ $LowE_total += $rgt->coefficient(); } } $LowEnergyPoints-=$LowE_total; #test points if(($LowEnergyPoints*$mMdeltaG) > 2 && $mMdeltaG < 0){ $self->thermoReversibility(">"); $self->direction(">") if $args->{direction}; return "Low Energy Points:$LowEnergyPoints\tmMdeltaG: $mMdeltaG"; }elsif(($LowEnergyPoints*$mMdeltaG) > 2 && $mMdeltaG > 0){ $self->thermoReversibility("<"); $self->direction("<") if $args->{direction}; return "Low Energy Points:$LowEnergyPoints\tmMdeltaG: $mMdeltaG"; } return "Default"; } =head3 checkReactionMassChargeBalance Definition: { balanced => 0/1, error => string, imbalancedAtoms => { C => 1, ... } imbalancedCharge => float } = Bio::KBase::ObjectAPI::KBaseBiochem::Reaction->checkReactionMassChargeBalance({ rebalanceProtons => 0/1(0):boolean flag indicating if protons should be rebalanced if they are the only imbalanced elements in the reaction }); Description: Checks if the reaction is mass and charge balanced, and rebalances protons if called for, but only if protons are the only broken element in the equation =cut sub checkReactionMassChargeBalance { my $self = shift; my $args = Bio::KBase::ObjectAPI::utilities::args([], {rebalanceProtons => 0,rebalanceWater => 0, saveStatus => 0}, @_); my $atomHash; my $netCharge = 0; my $status = "OK"; #Adding up atoms and charge from all reagents my $rgts = $self->reagents(); #Need to remember whether reaction has proton reagent in which compartment my $waterCompHash=(); my $protonCompHash=(); my $compHash=(); my $cpdCmpCount=(); my $hcpd=$self->parent()->checkForProton(); my $wcpd=$self->parent()->checkForWater(); #check for the one reaction which is truly empty if(scalar(@$rgts)==0){ $self->status("EMPTY"); return { balanced => 0, error => "Reactants cancel out completely" }; } #check for reactions with duplicate reagents (same compound in same compartment) #this is rare but arises from use of consolidatebio which doesn't check reactions #after merging compounds. The duplicate reagents need to be removed before balancing #reaction foreach my $rgt (@$rgts){ $cpdCmpCount->{$rgt->compound_ref()."_".$rgt->compartment_ref()}++; } if(scalar( grep { $cpdCmpCount->{$_} > 1 } keys %$cpdCmpCount)>0){ foreach my $cpdcmpt ( grep { $cpdCmpCount->{$_} > 1 } keys %$cpdCmpCount){ my ($cpd,$cmpt)=split(/_/,$cpdcmpt); my $coefficient=0; my $rgtUUIDs=""; foreach my $rgt (@$rgts){ if($rgt->compartment_ref() eq $cmpt && $rgt->compound_ref() eq $cpd){ $coefficient+=$rgt->coefficient(); if(!$rgtUUIDs){ $rgtUUIDs=$cpdcmpt; }else{ $self->remove("reagents",$rgt); } } } $rgts = $self->reagents(); foreach my $rgt (@$rgts){ if($rgt->compound_ref()."_".$rgt->compartment_ref() eq $rgtUUIDs){ $rgt->coefficient($coefficient); } } } } for (my $i=0; $i < @{$rgts};$i++) { my $rgt = $rgts->[$i]; #Check for protons/water $protonCompHash->{$rgt->compartment_ref()}=$rgt->compartment() if $rgt->compound_ref() eq $hcpd->uuid(); $waterCompHash->{$rgt->compartment_ref()}=$rgt->compartment() if $args->{rebalanceWater} && $rgt->compound_ref() eq $wcpd->uuid(); $compHash->{$rgt->compartment_ref()}=$rgt->compartment(); $cpdCmpCount->{$rgt->compound_ref()."_".$rgt->compartment_ref()}++; #Problems are: compounds with noformula, polymers (see next line), and reactions with duplicate compounds in the same compartment #Latest KEGG formulas for polymers contain brackets and 'n', older ones contain '*' my $cpdatoms = $rgt->compound()->calculateAtomsFromFormula(); if (defined($cpdatoms->{error})) { $self->status("CPDFORMERROR"); return { balanced => 0, error => $cpdatoms->{error} }; } $netCharge += $rgt->coefficient()*$rgt->compound()->defaultCharge(); foreach my $atom (keys(%{$cpdatoms})) { if (!defined($atomHash->{$atom})) { $atomHash->{$atom} = 0; } $atomHash->{$atom} += $rgt->coefficient()*$cpdatoms->{$atom}; } } #Adding protons #use of defaultProtons() discontinued for time being #$netCharge += $self->defaultProtons()*1; if (!defined($atomHash->{H})) { $atomHash->{H} = 0; } #$atomHash->{H} += $self->defaultProtons(); #Checking if charge or atoms are unbalanced my $results = { balanced => 1 }; my $imbalancedAtoms = {}; foreach my $atom (keys(%{$atomHash})) { if ($atomHash->{$atom} > 0.00000001 || $atomHash->{$atom} < -0.00000001) { $imbalancedAtoms->{$atom}=$atomHash->{$atom}; } } if($args->{rebalanceWater} && join("",sort keys %$imbalancedAtoms) eq "HO" && ($imbalancedAtoms->{"H"}/$imbalancedAtoms->{"O"}) == 2){ Bio::KBase::ObjectAPI::utilities::verbose("Adjusting ".$self->id()." water by ".$imbalancedAtoms->{"O"}); if(scalar(keys %$waterCompHash)==0){ #must create water reagent #either reaction compartment or, if transporter, defaults to compartment with highest number in hierarchy my $compUuid = (keys %$compHash)[0]; if(scalar(keys %$compHash)>1){ my $hierarchy=1; foreach my $tmpCompUuid (keys %$compHash){ if($compHash->{$tmpCompUuid}->hierarchy()>$hierarchy){ $compUuid=$tmpCompUuid; $hierarchy=$compHash->{$tmpCompUuid}->hierarchy(); } } } $self->add("reagents", {compound_ref => $wcpd->uuid(), compartment_ref => $compUuid, coefficient => -1*$imbalancedAtoms->{"O"}, isCofactor => 0}); }elsif(scalar(keys %$waterCompHash)>0){ #must choose water reagent #defaults to compartment with highest number in hierarchy my $compUuid = (keys %$waterCompHash)[0]; my $hierarchy=1; foreach my $tmpCompUuid ( grep { $_ ne $compUuid } keys %$waterCompHash){ if($waterCompHash->{$tmpCompUuid}->hierarchy()>$hierarchy){ $compUuid=$tmpCompUuid; $hierarchy=$waterCompHash->{$tmpCompUuid}->hierarchy(); } } my $rgts = $self->reagents(); for(my $i=0;$i<scalar(@$rgts);$i++){ if($rgts->[$i]->compound_ref() eq $wcpd->uuid() && $rgts->[$i]->compartment_ref() eq $compUuid){ my $coeff=$rgts->[$i]->coefficient(); $rgts->[$i]->coefficient($coeff+(-1*$imbalancedAtoms->{"O"})); } } $self->reagents($rgts); } foreach my $key ("H","O"){ $atomHash->{$key} = 0; delete($imbalancedAtoms->{$key}) } } if ($args->{rebalanceProtons} && join("",keys %$imbalancedAtoms) eq "H") { Bio::KBase::ObjectAPI::utilities::verbose("Adjusting ".$self->id()." protons by ".$imbalancedAtoms->{"H"}); if(scalar(keys %$protonCompHash)==0){ #must create proton reagent #either reaction compartment or, if transporter, defaults to compartment with highest number in hierarchy my $compUuid = (keys %$compHash)[0]; if(scalar(keys %$compHash)>1){ my $hierarchy=1; foreach my $tmpCompUuid (keys %$compHash){ if($compHash->{$tmpCompUuid}->hierarchy()>$hierarchy){ $compUuid=$tmpCompUuid; $hierarchy=$compHash->{$tmpCompUuid}->hierarchy(); } } } $self->add("reagents", {compound_ref => $hcpd->uuid(), compartment_ref => $compUuid, coefficient => -1*$imbalancedAtoms->{"H"}, isCofactor => 0}); }elsif(scalar(keys %$protonCompHash)>0){ #must choose proton reagent #defaults to compartment with highest number in hierarchy my $compUuid = (keys %$protonCompHash)[0]; my $hierarchy=1; foreach my $tmpCompUuid ( grep { $_ ne $compUuid } keys %$protonCompHash){ if($protonCompHash->{$tmpCompUuid}->hierarchy()>$hierarchy){ $compUuid=$tmpCompUuid; $hierarchy=$protonCompHash->{$tmpCompUuid}->hierarchy(); } } my $rgts = $self->reagents(); for(my $i=0;$i<scalar(@$rgts);$i++){ if($rgts->[$i]->compound_ref() eq $hcpd->uuid() && $rgts->[$i]->compartment_ref() eq $compUuid){ my $coeff=$rgts->[$i]->coefficient(); $rgts->[$i]->coefficient($coeff+(-1*$imbalancedAtoms->{"H"})); } } $self->reagents($rgts); } #my $currentProtons = $self->defaultProtons(); #$currentProtons += -1*$imbalancedAtoms->{"H"}; #$self->defaultProtons($currentProtons); $netCharge += -1*$imbalancedAtoms->{"H"}; $atomHash->{H} = 0; delete($imbalancedAtoms->{H}); $status.="|HB"; } foreach my $atom (keys(%{$imbalancedAtoms})) { if ($status eq "OK") { $status = "MI:"; } else { $status .= "|"; } $results->{balanced} = 0; $results->{imbalancedAtoms}->{$atom} = $atomHash->{$atom}; $status .= $atom.":".$atomHash->{$atom}; } if ($netCharge != 0) { if ($status eq "OK") { $status = "CI:".$netCharge; } else { $status .= "|CI:".$netCharge; } $results->{balanced} = 0; $results->{imbalancedCharge} = $netCharge; } if($args->{saveStatus} == 1){ $self->status($status); } return $results; } sub checkForDuplicateReagents{ my $self=shift; my %cpdCmpCount=(); foreach my $rgt (@{$self->reagents()}){ $cpdCmpCount{$rgt->compound_ref()."_".$rgt->compartment_ref()}++; } if(scalar( grep { $cpdCmpCount{$_} >1 } keys %cpdCmpCount)>0){ return 1; }else{ return 0; } } __PACKAGE__->meta->make_immutable; 1;
mmundy42/KBaseFBAModeling
lib/Bio/KBase/ObjectAPI/KBaseBiochem/Reaction.pm
Perl
mit
37,773
# # Copyright (c) 2019 cPanel, L.L.C. # All rights reserved. # http://cpanel.net/ # # Distributed under the terms of the MIT license. See the LICENSE file for # further details. # package Test::OpenStack::Client::Message; use strict; use warnings; sub new { my ($class, %opts) = @_; $opts{'headers'} ||= {}; $opts{'content'} ||= ''; my %headers = map { lc $_ => $opts{'headers'}->{$_} } keys %{$opts{'headers'}}; $headers{'content-type'} ||= 'application/json'; if (defined $opts{'content'}) { $headers{'content-length'} ||= length $opts{'content'}; } return bless { %opts, 'headers' => \%headers }, $class; } sub header ($$@) { my ($self, $name, $value) = @_; my $key = lc $name; $self->{'headers'}->{$key} = $value if defined $value; return $self->{'headers'}->{$key}; } sub content ($@) { my ($self, $value) = @_; $self->{'content'} = $value if defined $value; return $self->{'content'}; } sub decoded_content ($) { shift->content; } 1;
xantronix/OpenStack-Client
t/lib/Test/OpenStack/Client/Message.pm
Perl
mit
1,060
#!/usr/bin/perl use strict; use warnings; use Getopt::Std; use POSIX qw( ceil floor); use DBI; use Config::Tiny; use HTML::Entities qw(decode_entities); use FindBin qw($Bin); use lib "$Bin/../lib"; use CommonFunctions qw(parseListToArray parseFileList); ######################################################### # Start Variable declarations # ######################################################### my (%opt, @list, $outfile, $species, $confFile, @range, $gff, %sizes, %libs); getopts('l:o:s:c:r:f:h', \%opt); var_check(); # Get configuration settings my $Conf = Config::Tiny->read($confFile); my $conf = $Conf->{$species}; my $sam = $Conf->{'PIPELINE'}->{'sam'}; my $bam = $conf->{'bam'}; # Connect to the SQLite database my $dbh = DBI->connect("dbi:SQLite:dbname=$conf->{'db'}","",""); foreach my $size (@range) { $sizes{$size} = 1; } foreach my $lib (@list) { $libs{$lib} = 1; } ######################################################### # End Variable declarations # ######################################################### ######################################################### # Start Main body of Program # ######################################################### open (OUT, ">$outfile") or die "Cannot open $outfile: $!\n\n"; print OUT "Feature\tSenseReads\tAntiReads\tLength\tAnnotation\n"; my $count = 0; my $sth = $dbh->prepare('SELECT * FROM `reads` WHERE `sid` = ?'); print STDERR " Processing features... $count\r"; open (GFF, $gff) or die " Cannot open $gff: $!\n\n"; while (my $line = <GFF>) { next if (substr($line,0,1) eq '#'); chomp $line; my ($ref, $source, $type, $start, $end, $score, $fstrand, $phase, $attributes) = split /\t/, $line; my $flength = $end - $start + 1; my @attributes = split /;/, $attributes; my %tags; foreach my $item (@attributes) { my ($tag, $value) = split /=/, $item; $tags{$tag} = $value; } my %reads; $reads{'sense'} = 0; $reads{'anti'} = 0; open SAM, "$sam view $bam '$ref:$start-$end' |"; while (my $line = <SAM>) { my @tmp = split /\t/, $line; my $sid = $tmp[0]; my $strand; if ($fstrand eq '+') { $strand = ($tmp[1] == 0) ? 'sense' : 'anti'; } elsif ($fstrand eq '-') { $strand = ($tmp[1] == 16) ? 'sense' : 'anti'; } my $length = length($tmp[9]); next if (!exists($sizes{$length})); $sth->execute($sid); while (my $row = $sth->fetchrow_hashref) { if (exists($libs{$row->{'library_id'}})) { $reads{$strand} += $row->{'reads'}; } } } close SAM; my ($feature, $annotation); if (exists($tags{'ID'})) { $feature = $tags{'ID'}; } elsif (exists($tags{'Name'})) { $feature = $tags{'Name'}; } else { $feature = $attributes; } if (exists($tags{'Note'})) { $annotation = decode_entities($tags{'Note'}); } else { $annotation = 'none'; } print OUT $feature; print OUT "\t".$reads{'sense'}."\t".$reads{'anti'}; print OUT "\t".$flength."\t".$annotation."\n"; $count++; print STDERR " Processing features... $count\r"; } close GFF; print STDERR " Processing features... $count\n"; close OUT; exit; ######################################################### # Start Subroutines # ######################################################### ######################################################### # Start of Varriable Check Subroutine "var_check" # ######################################################### sub var_check { if ($opt{'h'}) { var_error(); } if ($opt{'l'}) { @list = parseListToArray($opt{'l'}); } else { var_error(); } if ($opt{'o'}) { $outfile = $opt{'o'}; } else { var_error(); } if ($opt{'c'}) { $confFile = $opt{'c'}; } else { var_error(); } if ($opt{'s'}) { $species = $opt{'s'}; } else { var_error(); } if ($opt{'r'}) { @range = parseListToArray($opt{'r'}); } else { @range = parseListToArray('18-30'); } if ($opt{'f'}) { $gff = $opt{'f'}; } else { var_error(); } } ######################################################### # End of Varriable Check Subroutine "var_check" # ######################################################### ######################################################### # Start of Varriable error Subroutine "var_error" # ######################################################### sub var_error { print STDERR "\n Description:\n"; print STDERR " This script will generate a distribution of sequencing reads by sequence length for the given features.\n\n"; print STDERR " Usage:\n"; print STDERR " readPerFeature.pl -l <library_ids> -o <output file> -c <conf_file> -s <species> -f <GFF file>\n"; print STDERR "\n\n"; print STDERR " -l The library ID's to use.\n"; print STDERR " example: -l '1-5'\n"; print STDERR " example: -l '1,7,11'\n"; print STDERR " example: -l '1-5,7,9-11'\n"; print STDERR "\n"; print STDERR " -o The output filename.\n"; print STDERR "\n"; print STDERR " -c The configuration file.\n"; print STDERR "\n"; print STDERR " -s The species.\n"; print STDERR "\n"; print STDERR " -f The GFF feature file.\n"; print STDERR "\n"; print STDERR " -r The small RNA size range. Default = 18-30\n"; print STDERR "\n\n\n"; exit 0; } ######################################################### # End of Varriable error Subroutine "var_error" # #########################################################
nfahlgren/srtools
toolkit/readsPerFeature.pl
Perl
mit
5,479
#!/usr/bin/env perl # Script to output HPO terms associated with an OMIM ID use strict; use warnings; use hpo qw/hpo_to_name hpo_to_disease hpo_to_gene/; my $usage = "Usage: $0 <OMIM ID> [OMIM IDs]\n"; if (scalar(@ARGV) == 0){ die $usage; } # download from http://purl.obolibrary.org/obo/hp.obo my $script_path = $0; $script_path =~ s/\w+\.pl$/..\/data\//; my $disease = $script_path . 'phenotype_annotation.tab.gz'; =head1 Columns in annotation file 1 DB required MIM 2 DB_Object_ID required 154700 3 DB_Name required Achondrogenesis, type IB 4 Qualifier optional NOT 5 HPO ID required HP:0002487 6 DB:Reference required OMIM:154700 or PMID:15517394 7 Evidence code required IEA 8 Onset modifier optional HP:0003577 9 Frequency modifier optional "70%" or "12 of 30" or from the vocabulary show in table below 10 With optional 11 Aspect required O 12 Synonym optional ACG1B|Achondrogenesis, Fraccaro type 13 Date required YYYY.MM.DD 14 Assigned by required HPO =cut my %lookup = (); my %name = (); open(IN,'-|',"gunzip -c $disease") || die "Could not open $disease: $!\n"; while(<IN>){ chomp; my ($db, $db_object_id, $db_name, $qualifier, $hpo, $reference, $evidence, $modifier, $frequency, $with, $aspect, $synonym, $date, $assigned) = split(/\t/); # store only OMIM disorders next unless $db eq 'OMIM'; # just keep the numbers OMIM:100300 $db_object_id =~ s/^OMIM://; if (exists $lookup{$db_object_id}){ my $index = scalar(@{$lookup{$db_object_id}}); $lookup{$db_object_id}[$index] = $hpo; } else { $lookup{$db_object_id}[0] = $hpo; $name{$db_object_id} = $db_name; } } close(IN); foreach my $h (@ARGV){ my $phenolyzer_input = ''; $h =~ s/^OMIM://; $h =~ s/(\d+).*$/$1/; if (exists $lookup{$h}){ my %check = (); my $counter = 0; print "OMIM:$h\t$name{$h}\n"; foreach my $n (@{$lookup{$h}}){ next if exists $check{$n}; $check{$n} = 1; $phenolyzer_input .= "$n;"; ++$counter; my $term = hpo_to_name($n); my $disease = hpo_to_disease($n); my $gene = hpo_to_gene($n); print "\t$n\t$term\tno. disease association: $disease\tno. gene association: $gene\n"; } print "$counter HPO terms\n\n"; print "$phenolyzer_input\n\n"; print "---------------------------\n\n"; } else { print "Your input $h was not found\n\n"; print "---------------------------\n\n"; } } __END__
davetang/human_phenotype_ontology
script/omim_to_hpo.pl
Perl
mit
2,709
BEGIN {@INC=("../",@INC)}; use strict; use warnings; use SeriesInfo::NameParser; use Test::More tests => 1; my $s1 = "show.01x02"; subtest "title is optional ($s1)" => sub { plan tests => 5; isnt SeriesInfo::NameParser::parse($s1) , undef , "not undefined"; is SeriesInfo::NameParser::parse($s1)->{show} , "show" , "get show from string"; is SeriesInfo::NameParser::parse($s1)->{season}, 1 , "get season number from string"; is SeriesInfo::NameParser::parse($s1)->{number}, 2 , "get episode number from string"; is SeriesInfo::NameParser::parse($s1)->{title} , "" , "title is undefined"; };
pretorh/seriesinfo-nameparser
tests/title-is-optional.pl
Perl
mit
650
# # Copyright 2018 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 snmp_standard::mode::inodes; use base qw(centreon::plugins::templates::counter); use strict; use warnings; sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All inode partitions are ok' } ]; $self->{maps_counters}->{disk} = [ { label => 'usage', set => { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => 'Used: %s %%', output_error_template => "%s", perfdatas => [ { label => 'used', value => 'usage_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, ]; } sub prefix_disk_output { my ($self, %options) = @_; return "Inode partition '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "name" => { name => 'use_name' }, "diskpath:s" => { name => 'diskpath' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, "filter-device:s" => { name => 'filter_device' }, "display-transform-src:s" => { name => 'display_transform_src' }, "display-transform-dst:s" => { name => 'display_transform_dst' }, }); return $self; } my $mapping = { dskPath => { oid => '.1.3.6.1.4.1.2021.9.1.2' }, dskDevice => { oid => '.1.3.6.1.4.1.2021.9.1.3' }, dskPercentNode => { oid => '.1.3.6.1.4.1.2021.9.1.10' }, }; sub manage_selection { my ($self, %options) = @_; my $results = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{dskPath}->{oid} }, { oid => $mapping->{dskDevice}->{oid} }, { oid => $mapping->{dskPercentNode}->{oid} } ], return_type => 1, nothing_quit => 1); $self->{disk} = {}; foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$results})) { next if ($oid !~ /^$mapping->{dskPath}->{oid}\.(.*)/); my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); $result->{dskPath} = $self->get_display_value(value => $result->{dskPath}); $self->{output}->output_add(long_msg => sprintf("disk path : '%s', device : '%s'", $result->{dskPath}, $result->{dskDevice}), debug => 1); if (!defined($result->{dskPercentNode})) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : no inode usage value", $result->{dskPath}), debug => 1); next; } if (defined($self->{disk}->{$result->{dskPath}})) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : duplicated entry", $result->{dskPath}), debug => 1); next; } if (defined($result->{dskDevice}) && defined($self->{option_results}->{filter_device}) && $self->{option_results}->{filter_device} ne '' && $result->{dskDevice} !~ /$self->{option_results}->{filter_device}/) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk device", $result->{dskPath}), debug => 1); next; } if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) { if ($self->{option_results}->{diskpath} !~ /(^|\s|,)$instance(\s*,|$)/) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter id disk path", $result->{dskPath}), debug => 1); next; } } elsif (defined($self->{option_results}->{diskpath}) && $self->{option_results}->{diskpath} ne '') { if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} !~ /$self->{option_results}->{diskpath}/i) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1); next; } if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} !~ /$self->{option_results}->{diskpath}/) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1); next; } if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} ne $self->{option_results}->{diskpath}) { $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1); next; } } $self->{disk}->{$result->{dskPath}} = { display => $result->{dskPath}, usage => $result->{dskPercentNode} }; } if (scalar(keys %{$self->{disk}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } } sub get_display_value { my ($self, %options) = @_; my $value = $options{value}; if (defined($self->{option_results}->{display_transform_src})) { $self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst})); eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}"; } return $value; } 1; __END__ =head1 MODE Check Inodes space usage on partitions. Need to enable "includeAllDisks 10%" on snmpd.conf. =over 8 =item B<--warning-usage> Threshold warning in percent. =item B<--critical-usage> Threshold critical in percent. =item B<--diskpath> Set the disk path (number expected) ex: 1, 2,... (empty means 'check all disks path'). =item B<--name> Allows to use disk path name with option --diskpath instead of disk path oid index. =item B<--regexp> Allows to use regexp to filter diskpath (with option --name). =item B<--regexp-isensitive> Allows to use regexp non case-sensitive (with --regexp). =item B<--display-transform-src> Regexp src to transform display value. (security risk!!!) =item B<--display-transform-dst> Regexp dst to transform display value. (security risk!!!) =item B<--filter-device> Filter device name (Can be a regexp). =back =cut
wilfriedcomte/centreon-plugins
snmp_standard/mode/inodes.pm
Perl
apache-2.0
8,026
# # 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 network::silverpeak::snmp::mode::uptime; use base qw(centreon::plugins::mode); use strict; use warnings; use POSIX; use centreon::plugins::misc; use centreon::plugins::statefile; use Time::HiRes qw(time); sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "force-oid:s" => { name => 'force_oid' }, "check-overflow" => { name => 'check_overflow' }, }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } $self->{statefile_cache}->check_options(%options); } sub check_overflow { my ($self, %options) = @_; return $options{timeticks} if (!defined($self->{option_results}->{check_overflow})); my $current_time = floor(time() * 100); $self->{new_datas} = { last_time => $current_time, uptime => $options{timeticks}, overflow => 0 }; $self->{statefile_cache}->read(statefile => "cache_" . $self->{snmp}->get_hostname() . '_' . $self->{snmp}->get_port() . '_' . $self->{mode}); my $old_uptime = $self->{statefile_cache}->get(name => 'uptime'); my $last_time = $self->{statefile_cache}->get(name => 'last_time'); my $overflow = $self->{statefile_cache}->get(name => 'overflow'); if (defined($old_uptime) && $old_uptime < $current_time) { my $diff_time = $current_time - $last_time; my $overflow = ($old_uptime + $diff_time) % 4294967296; my $division = ($old_uptime + $diff_time) / 4294967296; if ($division >= 1 && $overflow >= ($options{timeticks} - 5000) && $overflow <= ($options{timeticks} + 5000)) { $overflow++; } $options{timeticks} += ($overflow * 4294967296); } $self->{new_datas}->{overflow} = $overflow if (defined($overflow)); $self->{statefile_cache}->write(data => $self->{new_datas}); return $options{timeticks}; } sub run { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; # spsSystemUptime from SILVERPEAK-MGMT-MIB 8.0 my $oid_hrSystemUptime = '.1.3.6.1.4.1.23867.3.1.1.1.5.0'; my ($result, $value); if (defined($self->{option_results}->{force_oid})) { $result = $self->{snmp}->get_leef(oids => [ $self->{option_results}->{force_oid} ], nothing_quit => 1); $value = $result->{$self->{option_results}->{force_oid}}; } else { $result = $self->{snmp}->get_leef(oids => [ $oid_hrSystemUptime ], nothing_quit => 1); $value = $result->{$oid_hrSystemUptime}; } $value = $self->check_overflow(timeticks => $value); $value = floor($value / 100); my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->perfdata_add(label => 'uptime', unit => 's', value => $value, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("System uptime is: %s", centreon::plugins::misc::change_seconds(value => $value, start => 'd'))); $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check system uptime. =over 8 =item B<--warning> Threshold warning in seconds. =item B<--critical> Threshold critical in seconds. =item B<--force-oid> Can choose your oid (numeric format only). =item B<--check-overflow> Uptime counter limit is 4294967296 and overflow. With that option, we manage the counter going back. But there is a few chance we can miss a reboot. =back =cut
Sims24/centreon-plugins
network/silverpeak/snmp/mode/uptime.pm
Perl
apache-2.0
5,813
# # 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 storage::netapp::snmp::mode::filesys; use base qw(centreon::plugins::templates::counter); use strict; use warnings; sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' }, ]; $self->{maps_counters}->{fs} = [ { label => 'usage', set => { key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), closure_custom_perfdata => $self->can('custom_usage_perfdata'), closure_custom_threshold_check => $self->can('custom_usage_threshold'), } }, { label => 'inodes', set => { key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'display' } ], output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s", perfdatas => [ { label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'compresssaved', set => { key_values => [ { name => 'dfCompressSavedPercent' }, { name => 'display' } ], output_template => 'Compress Saved : %s %%', output_error_template => "Compress Saved : %s", perfdatas => [ { label => 'compresssaved', value => 'dfCompressSavedPercent_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, { label => 'dedupsaved', set => { key_values => [ { name => 'dfDedupeSavedPercent' }, { name => 'display' } ], output_template => 'Dedupe Saved : %s %%', output_error_template => "Dedupe Saved : %s", perfdatas => [ { label => 'dedupsaved', value => 'dfDedupeSavedPercent_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], } }, ]; } sub custom_usage_perfdata { my ($self, %options) = @_; return if ($self->{result_values}->{total} <= 0); my $label = 'used'; my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { $label = 'free'; $value_perf = $self->{result_values}->{free}; } my %total_options = (); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } $self->{output}->perfdata_add( label => $label, unit => 'B', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $value_perf, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), min => 0, max => $self->{result_values}->{total} ); } sub custom_usage_threshold { my ($self, %options) = @_; return 'ok' if ($self->{result_values}->{total} <= 0); my ($exit, $threshold_value); $threshold_value = $self->{result_values}->{used}; $threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free})); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]); return $exit; } sub custom_usage_output { my ($self, %options) = @_; my $msg; if ($self->{result_values}->{total} == 0) { $msg = 'skipping: total size is 0'; } elsif ($self->{result_values}->{total} < 0) { $msg = 'skipping: negative total value (maybe use snmp v2c)'; } else { my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); } return $msg; } sub custom_usage_calc { my ($self, %options) = @_; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; return 0 if ($options{new_datas}->{$self->{instance} . '_total'} == 0); $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; # snapshot can be over 100% if ($self->{result_values}->{free} < 0) { $self->{result_values}->{free} = 0; $self->{result_values}->{prct_free} = 0; } return 0; } sub prefix_fs_output { my ($self, %options) = @_; return "Filesys '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { 'units:s' => { name => 'units', default => '%' }, 'free' => { name => 'free' }, 'filter-name:s' => { name => 'filter_name' }, 'filter-type:s' => { name => 'filter_type' }, 'filter-vserver:s' => { name => 'filter_vserver' }, 'filter-vserver-state:s' => { name => 'filter_vserver_state' }, }); return $self; } my $map_types = { 1 => 'traditionalVolume', 2 => 'flexibleVolume', 3 => 'aggregate', 4 => 'stripedAggregate', 5 => 'stripedVolume' }; my $map_vserver_state = { 0 => 'running', 1 => 'stopped', 2 => 'starting', 3 => 'stopping' }; my $mapping = { dfType => { oid => '.1.3.6.1.4.1.789.1.5.4.1.23', map => $map_types }, }; my $mapping2 = { dfFileSys => { oid => '.1.3.6.1.4.1.789.1.5.4.1.2' }, dfKBytesTotal => { oid => '.1.3.6.1.4.1.789.1.5.4.1.3' }, dfKBytesUsed => { oid => '.1.3.6.1.4.1.789.1.5.4.1.4' }, dfPerCentInodeCapacity => { oid => '.1.3.6.1.4.1.789.1.5.4.1.9' }, df64TotalKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.29' }, df64UsedKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.30' }, dfVserver => { oid => '.1.3.6.1.4.1.789.1.5.4.1.34' }, dfCompressSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.38' }, dfDedupeSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.40' }, }; my $mapping3 = { vserverName => { oid => '.1.3.6.1.4.1.789.1.27.1.1.2' }, vserverState => { oid => '.1.3.6.1.4.1.789.1.27.1.1.16', map => $map_vserver_state }, }; sub get_vserver_state { my ($self, %options) = @_; return if (!defined($self->{option_results}->{filter_vserver_state}) || $self->{option_results}->{filter_vserver} eq ''); my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $mapping3->{vserverName}->{oid} }, { oid => $mapping3->{vserverState}->{oid} } ], return_type => 1, nothing_quit => 1 ); $self->{vserver} = {}; foreach (keys %$snmp_result) { next if (! /^$mapping3->{vserverName}->{oid}\.(.*)/); my $result = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result, instance => $1); $self->{vserver}->{$result->{vserverName}} = $result->{vserverState}; } } sub manage_selection { my ($self, %options) = @_; my @oids = ( $mapping2->{dfKBytesTotal}->{oid}, $mapping2->{dfKBytesUsed}->{oid}, $mapping2->{dfPerCentInodeCapacity}->{oid}, $mapping2->{dfCompressSavedPercent}->{oid}, $mapping2->{dfDedupeSavedPercent}->{oid}, $mapping2->{dfVserver}->{oid}, ); if (!$options{snmp}->is_snmpv1()) { push @oids, $mapping2->{df64TotalKBytes}->{oid}; push @oids, $mapping2->{df64UsedKBytes}->{oid}; } $self->get_vserver_state(%options); my $results; if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '') { $results = $options{snmp}->get_multiple_table( oids => [ { oid => $mapping->{dfType}->{oid} }, { oid => $mapping2->{dfFileSys}->{oid} } ], return_type => 1, nothing_quit => 1 ); } else { $results = $options{snmp}->get_table(oid => $mapping2->{dfFileSys}->{oid}, nothing_quit => 1); } my @fs_selected; foreach my $oid (keys %{$results}) { next if ($oid !~ /^$mapping2->{dfFileSys}->{oid}\.(\d+)/); my $instance = $1; my $name = $results->{$oid}; 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 name.", debug => 1); next; } if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && $map_types->{$results->{$mapping->{dfType}->{oid} . '.' . $instance}} !~ /$self->{option_results}->{filter_type}/) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter type.", debug => 1); next; } push @fs_selected, $instance; } if (scalar(@fs_selected) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } $self->{fs} = {}; $options{snmp}->load(oids => \@oids, instances => \@fs_selected); my $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); foreach my $instance (sort @fs_selected) { my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $instance); if (defined($result2->{dfVserver}) && $result2->{dfVserver} ne '' && defined($self->{option_results}->{filter_vserver_state}) && $self->{option_results}->{filter_vserver_state} ne '' && $self->{vserver}->{$result2->{dfVserver}} !~ /$self->{option_results}->{filter_vserver_state}/) { $self->{output}->output_add(long_msg => "skipping '" . $instance . "': no matching filter vserver state.", debug => 1); next; } if (defined($result2->{dfVserver}) && defined($self->{option_results}->{filter_vserver}) && $self->{option_results}->{filter_vserver} ne '' && $result2->{dfVserver} !~ /$self->{option_results}->{filter_vserver}/) { $self->{output}->output_add(long_msg => "skipping '" . $instance . "': no matching filter vserver.", debug => 1); next; } $self->{fs}->{$instance} = { display => defined($result2->{dfVserver}) && $result2->{dfVserver} ne '' ? $result2->{dfVserver} . ':' . $results->{$mapping2->{dfFileSys}->{oid} . '.' . $instance} : $results->{$mapping2->{dfFileSys}->{oid} . '.' . $instance} }; $self->{fs}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024; $self->{fs}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024; if (defined($result2->{df64TotalKBytes}) && $result2->{df64TotalKBytes} > 0) { $self->{fs}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024; $self->{fs}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024; } $self->{fs}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent}; $self->{fs}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent}; if ($self->{fs}->{$instance}->{total} > 0) { $self->{fs}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity}; } } } 1; __END__ =head1 MODE Check filesystem usage (volumes, snapshots and aggregates also). =over 8 =item B<--warning-*> Threshold warning. Can be: usage, inodes (%), compresssaved (%), dedupsaved (%). =item B<--critical-*> Threshold critical. Can be: usage, inodes (%), compresssaved (%), dedupsaved (%). =item B<--units> Units of thresholds (Default: '%') ('%', 'B'). =item B<--free> Thresholds are on free space left. =item B<--filter-name> Filter by filesystem name (can be a regexp). =item B<--filter-vserver> Filter by vserver name (can be a regexp). =item B<--filter-vserver-state> Filter by vserver state (can be a regexp). =item B<--filter-type> Filter filesystem type (can be a regexp. Example: 'flexibleVolume|aggregate'). =back =cut
Sims24/centreon-plugins
storage/netapp/snmp/mode/filesys.pm
Perl
apache-2.0
15,145
# Copyright 2020, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. package Google::Ads::GoogleAds::V8::Services::GenderViewService; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseService); sub get { my $self = shift; my $request_body = shift; my $http_method = 'GET'; my $request_path = 'v8/{+resourceName}'; my $response_type = 'Google::Ads::GoogleAds::V8::Resources::GenderView'; return $self->SUPER::call($http_method, $request_path, $request_body, $response_type); } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V8/Services/GenderViewService.pm
Perl
apache-2.0
1,035
# 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. =head1 NAME HiveCopyGenes.pm =head1 DESCRIPTION This module copies the genes whose identifiers are listed in a given file from a source database into an output database. =head1 OPTIONS -sourcehost source database host -sourceuser source database read-only user name -sourceport source database port -sourcepass source database read-only user pass -sourcedbname source database name -outhost destination database host -outuser destination database write user name -outpass destination database write user pass -outdbname destination database name -outport destination database port -dnahost dna database host (usually same as source) -dnadbname dna database name () -dnauser dna database read-only user name -dnaport dna database port -file file containing the list of gene ids to be copied from the source to the destination database =head1 EXAMPLE USAGE standaloneJob.pl Bio::EnsEMBL::Analysis::Hive::RunnableDB::HiveCopyGenes -sourcehost HOST -sourceuser READONLY_USER -sourceport PORT -sourcepass READONLY_PASS -sourcedbname SOURCEDB -outhost TARGETHOST -outuser WRITE_USER -outpass WRITE_PASS -outdbname TARGETDB -outport TARGETPORT -dnahost DNAHOST -dnadbname DNADB -dnauser READONLY_USER -dnaport DNAPORT -file gene_ids_to_copy.txt =cut package Bio::EnsEMBL::Analysis::Hive::RunnableDB::HiveCopyGenes; use strict; use warnings; use Bio::EnsEMBL::Analysis::Tools::Utilities qw(run_command); use Bio::EnsEMBL::Utils::Exception qw(warning throw); use parent ('Bio::EnsEMBL::Analysis::Hive::RunnableDB::HiveBaseRunnableDB'); use Net::FTP; use Bio::EnsEMBL::DBSQL::DBAdaptor; use Getopt::Long; use File::Basename; use File::Find; use List::Util qw(sum); sub param_defaults { return { copy_genes_path => '$ENSCODE/ensembl-analysis/scripts/genebuild/', copy_genes_script_name => 'copy_genes.pl', # copy_genes.pl script parameters logic => '', # to set the genes and transcripts analysis (logic names) (optional) sourcehost => undef, sourceuser => undef, sourceport => '3306', sourcepass => undef, sourcedbname => undef, outhost => undef, outuser => undef, outpass => undef, outdbname => undef, outport => '3306', dnahost => undef, dnadbname => undef, dnauser => undef, dnaport => '3306', file => undef } } sub fetch_input { my $self = shift; return 1; } sub run { my $self = shift; $self->param_required('sourcehost'); $self->param_required('sourceuser'); $self->param_required('sourceport'); $self->param_required('sourcepass'); $self->param_required('sourcedbname'); $self->param_required('outhost'); $self->param_required('outuser'); $self->param_required('outpass'); $self->param_required('outdbname'); $self->param_required('outport'); $self->param_required('dnahost'); $self->param_required('dnadbname'); $self->param_required('dnauser'); $self->param_required('dnaport'); $self->param_required('file'); my $command = "perl ".$self->param('copy_genes_path') .$self->param('copy_genes_script_name') ." -sourcehost ".$self->param('sourcehost') ." -sourceport ".$self->param('sourceport') ." -sourcedbname ".$self->param('sourcedbname') ." -outuser ".$self->param('outuser') ." -outpass ".$self->param('outpass') ." -outdbname ".$self->param('outdbname') ." -outport ".$self->param('outport') ." -outhost ".$self->param('outhost') ." -dnahost ".$self->param('dnahost') ." -dnadbname ".$self->param('dnadbname') ." -dnauser ".$self->param('dnauser') ." -dnaport ".$self->param('dnaport') ." -file ".$self->param('file') . " -verbose"; if ($self->param('logic')) { $command .= " -logic ".$self->param('logic'); } print run_command($command,"Copying genes..."); return 1; } sub write_output { my $self = shift; return 1; } 1;
mn1/ensembl-analysis
modules/Bio/EnsEMBL/Analysis/Hive/RunnableDB/HiveCopyGenes.pm
Perl
apache-2.0
4,918
=head1 LICENSE See the NOTICE file distributed with this work for additional information regarding copyright ownership. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =cut =head1 NAME Bio::EnsEMBL::Compara::RunnableDB::GeneTrees::CAFETable =head1 DESCRIPTION This RunnableDB calculates the dynamics of a GeneTree family (based on the tree obtained and the CAFE software) in terms of gains losses per branch tree. It needs a CAFE-compliant species tree. =head1 INHERITANCE TREE Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with an underscore (_) =cut package Bio::EnsEMBL::Compara::RunnableDB::GeneTrees::CAFETable; use strict; use warnings; use Data::Dumper; use Bio::EnsEMBL::Compara::Graph::NewickParser; use base ('Bio::EnsEMBL::Compara::RunnableDB::GeneTrees::GeneGainLossCommon'); sub param_defaults { return { 'tree_fmt' => '%{o}%{":"d}', 'norm_factor' => 0.1, 'norm_factor_step' => 0.1, 'label' => 'cafe', 'no_split_genes' => 0, }; } =head2 fetch_input Title : fetch_input Usage : $self->fetch_input Function : Fetches input data from database Returns : none Args : none =cut sub fetch_input { my ($self) = @_; my $cafe_tree = $self->compara_dba->get_SpeciesTreeAdaptor->fetch_by_method_link_species_set_id_label($self->param_required('mlss_id'), $self->param_required('label'))->root; $self->param('cafe_tree', $cafe_tree); ## Needed for lambda calculation if (! defined $self->param('lambda') && ! defined $self->param('cafe_shell')) { die ('cafe_shell is mandatory if lambda is not provided'); } $self->param('adaptor', $self->compara_dba->get_GeneTreeAdaptor); if ($self->param('perFamTable')) { print STDERR "PER FAMILY CAFE ANALYSIS\n"; $self->warning("Per-family CAFE Analysis"); } else { print STDERR "ONLY ONE CAFE ANALYSIS\n"; $self->warning("One CAFE Analysis for all the families"); } return; } sub run { my ($self) = @_; $self->load_split_genes; if (defined $self->param('lambda') and defined $self->param('perFamTable')) { $self->get_per_family_cafe_table_from_db(); return; } my $table = $self->get_full_cafe_table_from_db(); if (!defined $self->param('lambda')) { $self->param('lambda', $self->get_lambda($table)); } print STDERR "FINAL LAMBDA IS ", $self->param('lambda'), "\n"; if (!defined $self->param('perFamTable') || $self->param('perFamTable') == 0) { my $cafe_tree_string = $self->param('cafe_tree')->newick_format('ryo', $self->param('tree_fmt')); my $sth = $self->compara_dba->dbc->prepare("INSERT INTO CAFE_data (tree, tabledata) VALUES (?,?);"); $sth->execute($cafe_tree_string, $table); $sth->finish(); my $fam_id = $self->compara_dba->dbc->db_handle->last_insert_id(undef, undef, 'CAFE_data', 'fam_id'); $self->param('all_fams', [$fam_id]); } else { $self->get_per_family_cafe_table_from_db(); } } sub write_output { my ($self) = @_; my $all_fams = $self->param('all_fams'); my $lambda = $self->param('lambda'); for my $fam_id (@$all_fams) { print STDERR "FIRING FAM: $fam_id\n" if($self->debug); $self->dataflow_output_id ( { 'fam_id' => $fam_id, 'lambda' => $lambda, }, 2 ); } } ########################################### ## Internal methods ####################### ########################################### sub get_full_cafe_table_from_db { my ($self) = @_; my $cafe_tree = $self->param('cafe_tree'); my $species = [map {$_->node_id} @{$cafe_tree->get_all_leaves()}]; my $table = "FAMILY_DESC\tFAMILY\t" . join("\t", @$species); $table .= "\n"; my $all_trees = $self->get_all_trees($species); ## Returns a closure my $ok_fams = 0; while (my ($name, $id, $vals) = $all_trees->()) { last unless (defined $name); if ($self->has_member_at_root($vals)) { my @vals = map {$vals->{$_}} @$species; $ok_fams++; $table .= join ("\t", ($name, $id, @vals)); $table .= "\n"; } } print STDERR "$ok_fams families in final table\n" if ($self->debug()); print STDERR "$table\n" if ($self->debug()); return $table; } sub get_per_family_cafe_table_from_db { my ($self) = @_; my $fmt = $self->param('tree_fmt'); my $cafe_tree = $self->param('cafe_tree'); my $species = [map {$_->node_id} @{$cafe_tree->get_all_leaves()}]; my $all_trees = $self->get_all_trees($species); ## Returns a closure my $ok_fams = 0; my @all_fams = (); while (my ($name, $id, $vals) = $all_trees->()) { last unless (defined $name); my @species_in_tree = grep {$vals->{$_}} @$species; print STDERR scalar @species_in_tree , " species for this tree\n"; next if (scalar @species_in_tree < 4); #TODO: Should we filter out low-coverage genomes? my $lca = $self->lca($vals); next unless (defined $lca); my $lca_str = $lca->newick_format('ryo', $fmt); print STDERR "TREE FOR THIS FAM: \n$lca_str\n" if ($self->debug()); my $fam_table = "FAMILY_DESC\tFAMILY"; my $all_species_in_tree = $lca->get_all_leaves(); for my $sp_node (@$all_species_in_tree) { my $sp = $sp_node->node_id(); $fam_table .= "\t$sp"; } $fam_table .= "\n"; my @flds = ($name, $id, map {$vals->{$_->node_id}} @$all_species_in_tree); $fam_table .= join("\t", @flds). "\n"; print STDERR "TABLE FOR THIS FAM:\n$fam_table\n" if ($self->debug()); $ok_fams++; my $sth = $self->compara_dba->dbc->prepare("INSERT INTO CAFE_data (tree, tabledata) VALUES (?,?);"); $sth->execute($lca_str, $fam_table); my $fam_id = $self->compara_dba->dbc->db_handle->last_insert_id(undef, undef, 'CAFE_data', 'fam_id'); $sth->finish(); push @all_fams, $fam_id; } print STDERR "$ok_fams families in final table\n" if ($self->debug()); $self->param('all_fams', [@all_fams]); return; } sub lca { my ($self, $sps) = @_; my $cafe_tree = $self->param('cafe_tree'); my $tree_leaves = $cafe_tree->get_all_leaves(); my @leaves = grep {$sps->{$_->node_id}} @$tree_leaves; if (scalar @leaves == 0) { return undef; } return $cafe_tree->find_first_shared_ancestor_from_leaves([@leaves]); } sub has_member_at_root { my ($self, $sps) = @_; my $lca = $self->lca($sps); return ($lca && !$lca->has_parent()); } ######################################## ## Subroutines for lambda calculation ######################################## sub get_lambda { my ($self, $table) = @_; my $cafe_shell = $self->param('cafe_shell'); my $tmp_dir = $self->worker_temp_directory; my $norm_factor = $self->param('norm_factor'); my $norm_factor_step = $self->param('norm_factor_step'); my $lambda = 0; LABEL: while (1) { my $new_table = $self->get_normalized_table($table, $norm_factor); my $table_file = $self->get_table_file($new_table); my $script = $self->get_script($table_file); print STDERR "NORM_FACTOR: $norm_factor\n" if ($self->debug()); print STDERR "Table file is: $table_file\n" if ($self->debug()); print STDERR "Script file is: $script\n" if ($self->debug()); chmod 0755, $script; $self->read_from_command($script, sub { my $cafe_proc = shift; my $inf = 0; my $inf_in_row = 0; while (<$cafe_proc>) { chomp; next unless (/^Lambda\s+:\s+(0\.\d+)\s+&\s+Score\s*:\s+(.+)/); $lambda = $1; my $score = $2; # print STDERR "$_\n"; # print STDERR "++ LAMBDA: $lambda, SCORE: $score\n"; if ($score eq '-inf') { $inf++; $inf_in_row++; print STDERR "-inf score! => INF: $inf, INF_IN_ROW: $inf_in_row\n" if ($self->debug()); } else { $inf_in_row = 0; } if ($inf >= 10 || $inf_in_row >= 4) { $norm_factor+=$norm_factor_step; print STDERR "FAILED LAMBDA CALCULATION -- RETRYING WITH $norm_factor\n" if ($self->debug()); next LABEL; } } } ); last LABEL; } die "lambda cannot be 0 !\n" unless $lambda; return $lambda; } sub get_table_file { my ($self, $table) = @_; my $tmp_dir = $self->worker_temp_directory; my $mlss_id = $self->param('mlss_id'); my $table_file = "${tmp_dir}/cafe_${mlss_id}_lambda.tbl"; $self->_spurt($table_file, $table); return $table_file; } sub get_script { my ($self, $table_file) = @_; my $tmp_dir = $self->worker_temp_directory; my $cafe_shell = $self->param('cafe_shell'); my $mlss_id = $self->param('mlss_id'); my $cafe_tree_string = $self->param('cafe_tree')->newick_format('ryo', $self->param('tree_fmt')); chop($cafe_tree_string); #remove final semicolon $cafe_tree_string =~ s/:\d+$//; # remove last branch length my $script_file = "${tmp_dir}/cafe_${mlss_id}_lambda.sh"; $self->_spurt($script_file, join("\n", "#!$cafe_shell\n", "tree $cafe_tree_string\n", "load -i $table_file -t 1\n", 'lambda -s', )); return $script_file; } sub n_headers { return 2; } 1;
Ensembl/ensembl-compara
modules/Bio/EnsEMBL/Compara/RunnableDB/GeneTrees/CAFETable.pm
Perl
apache-2.0
10,601
# # Copyright 1999, 2000, 2001 Patrik Stridvall # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # package type; use strict; sub new($) { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; bless ($self, $class); return $self; } 1;
howard5888/wine
wine-1.7.7/tools/winapi/type.pm
Perl
apache-2.0
951
package ReseqTrack::ElasticsearchProxy::Model::ChunkedJsonWriter; use namespace::autoclean; use Moose; use Mojo::JSON; use v5.16; has 'num_hits_req' => (is => 'rw', isa => 'Int'); has 'closing_json' => (is => 'rw', isa => 'Str'); has 'is_finished' => (is => 'rw', isa => 'Bool', default => 0); has 'content_length' => (is => 'rw', isa => 'Int', default => 0); has 'scroll_id' => (is => 'rw', isa => 'Maybe[Str]'); has '_num_hits_written' => (is => 'rw', isa => 'Int', default => 0); sub process_json { my ($self, $json_obj, $expected_size) = @_; my $num_hits_written = $self->_num_hits_written; my $num_hits_req = $self->num_hits_req; $self->scroll_id($json_obj->{_scroll_id}); delete $json_obj->{_scroll_id}; my @hits_json; my $hits = $json_obj->{hits}{hits}; my $return_string = ''; if ($num_hits_written) { push(@hits_json, ''); } else { my $breaker = '__CHUNKED_JSON_WRITER_BREAKPOINT__'; $json_obj->{hits}{hits} = [$breaker]; my $json_string = Mojo::JSON::encode_json($json_obj); my ($opening, $closing) = $json_string =~ /^(.*)"$breaker"(.*)$/; $return_string = $opening; $self->closing_json($closing); $self->content_length(length($closing)); } my $new_hits_written = 0; HIT: foreach my $hit (@$hits) { push(@hits_json, Mojo::JSON::encode_json($hit)); $new_hits_written +=1; if ($num_hits_req >= 0 && $num_hits_written == $num_hits_req) { $self->is_finished(1); last HIT; } }; if (!$new_hits_written || ($expected_size && $new_hits_written < $expected_size)) { $self->is_finished(1); } $return_string .= join(',', @hits_json); $self->_num_hits_written($num_hits_written + $new_hits_written); $self->content_length($self->content_length + length($return_string)); return $return_string; } __PACKAGE__->meta->make_immutable; 1;
EMBL-EBI-GCA/gca_elasticsearch
lib/ReseqTrack/ElasticsearchProxy/Model/ChunkedJsonWriter.pm
Perl
apache-2.0
1,936
package Google::Ads::AdWords::v201402::TypeMaps::LocationCriterionService; use strict; use warnings; our $typemap_1 = { 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AdxError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DateError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[DateError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/reach' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]/reason' => 'Google::Ads::AdWords::v201402::NotEmptyError::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'get/selector/dateRange/max/month' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/reason' => 'Google::Ads::AdWords::v201402::RateExceededError::Reason', 'getResponse/rval/location/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]/reason' => 'Google::Ads::AdWords::v201402::AuthorizationError::Reason', 'Fault/detail/ApiExceptionFault/errors[RequestError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QueryError]/message' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'ApiExceptionFault/errors/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/paging/numberResults' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NullError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/dateRange/max/year' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[DateError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]' => 'Google::Ads::AdWords::v201402::OperationAccessDenied', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QueryError]' => 'Google::Ads::AdWords::v201402::QueryError', 'Fault/detail/ApiExceptionFault/errors[DateError]/reason' => 'Google::Ads::AdWords::v201402::DateError::Reason', 'queryResponse/rval/location/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]' => 'Google::Ads::AdWords::v201402::RateExceededError', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DistinctError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'ApiExceptionFault/errors/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RejectedError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/searchTerm' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/ordering/field' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/countryCode' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/reach' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]/reason' => 'Google::Ads::AdWords::v201402::QuotaCheckError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]/reason' => 'Google::Ads::AdWords::v201402::DatabaseError::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[DateError]' => 'Google::Ads::AdWords::v201402::DateError', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]/reason' => 'Google::Ads::AdWords::v201402::ClientTermsError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'get/selector/ordering/sortOrder' => 'Google::Ads::AdWords::v201402::SortOrder', 'Fault/detail/ApiExceptionFault/errors[QueryError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]' => 'Google::Ads::AdWords::v201402::InternalApiError', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/predicates/operator' => 'Google::Ads::AdWords::v201402::Predicate::Operator', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RangeError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse' => 'Google::Ads::AdWords::v201402::LocationCriterionService::getResponse', 'Fault/detail/ApiExceptionFault/errors[IdError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RejectedError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval' => 'Google::Ads::AdWords::v201402::LocationCriterion', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]' => 'Google::Ads::AdWords::v201402::ClientTermsError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]/reason' => 'Google::Ads::AdWords::v201402::LocationCriterionServiceError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RejectedError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ClientTermsError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]/reason' => 'Google::Ads::AdWords::v201402::InternalApiError::Reason', 'Fault/detail/ApiExceptionFault/errors[RejectedError]/reason' => 'Google::Ads::AdWords::v201402::RejectedError::Reason', 'ApiExceptionFault/ApplicationException.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DistinctError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[SelectorError]/reason' => 'Google::Ads::AdWords::v201402::SelectorError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]' => 'Google::Ads::AdWords::v201402::DatabaseError', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]' => 'Google::Ads::AdWords::v201402::AuthorizationError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'get/selector/paging' => 'Google::Ads::AdWords::v201402::Paging', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[RequiredError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DistinctError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'ApiExceptionFault/message' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'query' => 'Google::Ads::AdWords::v201402::LocationCriterionService::query', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]' => 'Google::Ads::AdWords::v201402::SizeLimitError', 'Fault/detail/ApiExceptionFault/errors[RequiredError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/countryCode' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/faultcode' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse' => 'Google::Ads::AdWords::v201402::LocationCriterionService::queryResponse', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[QueryError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AdxError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/locale' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[SelectorError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AdxError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[DateError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail' => 'Google::Ads::AdWords::FaultDetail', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/message' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'ApiExceptionFault' => 'Google::Ads::AdWords::v201402::ApiException', 'get/selector/dateRange' => 'Google::Ads::AdWords::v201402::DateRange', 'queryResponse/rval/location/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[RangeError]/reason' => 'Google::Ads::AdWords::v201402::RangeError::Reason', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]' => 'Google::Ads::AdWords::v201402::ReadOnlyError', 'Fault/detail/ApiExceptionFault/errors[RequestError]' => 'Google::Ads::AdWords::v201402::RequestError', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RequiredError]' => 'Google::Ads::AdWords::v201402::RequiredError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]' => 'Google::Ads::AdWords::v201402::NotEmptyError', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]' => 'Google::Ads::AdWords::v201402::AuthenticationError', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[QueryError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[SelectorError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector' => 'Google::Ads::AdWords::v201402::Selector', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]/reason' => 'Google::Ads::AdWords::v201402::AuthenticationError::Reason', 'Fault/detail/ApiExceptionFault/errors[RangeError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RequestError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/rateScope' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]/reason' => 'Google::Ads::AdWords::v201402::StringLengthError::Reason', 'get/selector/predicates/field' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[AdxError]' => 'Google::Ads::AdWords::v201402::AdxError', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/predicates' => 'Google::Ads::AdWords::v201402::Predicate', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[IdError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[IdError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AdxError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'get/selector/fields' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NullError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get' => 'Google::Ads::AdWords::v201402::LocationCriterionService::get', 'Fault' => 'SOAP::WSDL::SOAP::Typelib::Fault11', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RequestError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]' => 'Google::Ads::AdWords::v201402::QuotaCheckError', 'get/selector/dateRange/min/day' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/searchTerm' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RejectedError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AuthenticationError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'get/selector/dateRange/max' => 'Google::Ads::AdWords::v201402::Date', 'Fault/detail/ApiExceptionFault/errors[RangeError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[SelectorError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/dateRange/min/year' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'get/selector/paging/startIndex' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]' => 'Google::Ads::AdWords::v201402::StringLengthError', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QueryError]/reason' => 'Google::Ads::AdWords::v201402::QueryError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[DistinctError]/reason' => 'Google::Ads::AdWords::v201402::DistinctError::Reason', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NullError]' => 'Google::Ads::AdWords::v201402::NullError', 'get/selector/predicates/values' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'ApiExceptionFault/errors/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval' => 'Google::Ads::AdWords::v201402::LocationCriterion', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'get/selector/dateRange/min/month' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[DistinctError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'ApiExceptionFault/errors/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[LocationCriterionServiceError]' => 'Google::Ads::AdWords::v201402::LocationCriterionServiceError', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/dateRange/min' => 'Google::Ads::AdWords::v201402::Date', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/canonicalName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RangeError]' => 'Google::Ads::AdWords::v201402::RangeError', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/retryAfterSeconds' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'Fault/detail/ApiExceptionFault/errors[InternalApiError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AuthorizationError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[RequiredError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[RequiredError]/reason' => 'Google::Ads::AdWords::v201402::RequiredError::Reason', 'getResponse/rval/location/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[SelectorError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[NullError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'queryResponse/rval/location/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/ApplicationException.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[IdError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[AdxError]/reason' => 'Google::Ads::AdWords::v201402::AdxError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[DatabaseError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]/reason' => 'Google::Ads::AdWords::v201402::ReadOnlyError::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[NullError]/reason' => 'Google::Ads::AdWords::v201402::NullError::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[IdError]/reason' => 'Google::Ads::AdWords::v201402::IdError::Reason', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::token', 'ApiExceptionFault/errors' => 'Google::Ads::AdWords::v201402::ApiError', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QueryError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors' => 'Google::Ads::AdWords::v201402::ApiError', 'Fault/detail/ApiExceptionFault/errors[RequestError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NullError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/locale' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'get/selector/ordering' => 'Google::Ads::AdWords::v201402::OrderBy', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault' => 'Google::Ads::AdWords::v201402::ApiException', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[SizeLimitError]/reason' => 'Google::Ads::AdWords::v201402::SizeLimitError::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[QuotaCheckError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]/fieldPath' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'Fault/detail/ApiExceptionFault/errors[DistinctError]' => 'Google::Ads::AdWords::v201402::DistinctError', 'Fault/detail/ApiExceptionFault/errors[RequestError]/reason' => 'Google::Ads::AdWords::v201402::RequestError::Reason', 'Fault/detail/ApiExceptionFault/errors[ReadOnlyError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RequiredError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[IdError]' => 'Google::Ads::AdWords::v201402::IdError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/targetingStatus' => 'Google::Ads::AdWords::v201402::LocationTargetingStatus', 'Fault/detail/ApiExceptionFault/errors[RangeError]/ApiError.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[StringLengthError]/trigger' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'query/query' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[OperationAccessDenied]/reason' => 'Google::Ads::AdWords::v201402::OperationAccessDenied::Reason', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'Fault/detail/ApiExceptionFault/errors[NotEmptyError]/errorString' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/type' => 'Google::Ads::AdWords::v201402::Criterion::Type', 'Fault/detail/ApiExceptionFault/errors[RejectedError]' => 'Google::Ads::AdWords::v201402::RejectedError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/locationName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/canonicalName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations' => 'Google::Ads::AdWords::v201402::Location', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'get/selector/dateRange/max/day' => 'SOAP::WSDL::XSD::Typelib::Builtin::int', 'queryResponse/rval/location/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'queryResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/Criterion.Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[RateExceededError]/rateName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail/ApiExceptionFault/errors[SelectorError]' => 'Google::Ads::AdWords::v201402::SelectorError', 'getResponse/rval/location/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/parentLocations/displayType' => 'SOAP::WSDL::XSD::Typelib::Builtin::string' }; ; sub get_class { my $name = join '/', @{ $_[1] }; return $typemap_1->{ $name }; } sub get_typemap { return $typemap_1; } 1; __END__ __END__ =pod =head1 NAME Google::Ads::AdWords::v201402::TypeMaps::LocationCriterionService - typemap for LocationCriterionService =head1 DESCRIPTION Typemap created by SOAP::WSDL for map-based SOAP message parsers. =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201402/TypeMaps/LocationCriterionService.pm
Perl
apache-2.0
151,042
package VMOMI::ArrayOfIscsiDependencyEntity; use parent 'VMOMI::ComplexType'; use strict; use warnings; our @class_ancestors = ( ); our @class_members = ( ['IscsiDependencyEntity', 'IscsiDependencyEntity', 1, 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;
stumpr/p5-vmomi
lib/VMOMI/ArrayOfIscsiDependencyEntity.pm
Perl
apache-2.0
441
%%--------------------------------------------------------------------- %% %% MENU BUTTON CLASS %% %%--------------------------------------------------------------------- :- module(menubutton_class_doc,[],[objects,assertions,isomodes,regtypes]). %:- inherit_class(library('tcltk/examples/interface/widget_class')). :- use_module(library(lists),[append/3]). menu('default'). :- export(set_menu/1). %%------------------------------------------------------------------------ :- pred set_menu(+Menu) :: atom # "@var{Menu} posted when menubutton is clicked.". %%------------------------------------------------------------------------ set_menu(Menu) :- atom(Menu), set_fact(menu(Menu)), notify_changes. :- export([get_menu/1]). %%------------------------------------------------------------------------ :- pred get_menu(-Menu) :: atom # "Gets the name of the @var{Menu} asociated to the menubutton.". %%------------------------------------------------------------------------ get_menu(Menu) :- self(ID), owner(OW), append([OW],[ID],PP), % menu(Menu). menu(Menu_name), append(PP,[Menu_name],Menu). %%--------------------------------------------------------------------- %% IMPLEMENTATION %%--------------------------------------------------------------------- :- export([tcl_name/1,creation_options/1]). :- comment(hide,tcl_name/1). %%--------------------------------------------------------------------- :- pred tcl_name(-Widget) :: atom # "Specifies the name of the @var{Widget}. In this case is menubutton.". %%--------------------------------------------------------------------- tcl_name(menubutton). %%--------------------------------------------------------------------- :- pred creation_options(-OptionsList) :: list # "Creates a list with the options supported by the menubutton.". %%--------------------------------------------------------------------- creation_options([' ',min(menu),write(X),write(OW),write(X),write(ID),write(X),C|Other]) :- menu(C), X='.', self(ID), owner(OW), creation_options(Other). %%--------------------------------------------------------------------- %% CONSTRUCTOR %%--------------------------------------------------------------------- :- comment(hide,'class$call'/3). :- comment(hide,'class$used'/2). :- set_prolog_flag(multi_arity_warnings,off). menubutton_class. menubutton_class(Owner) :- menubutton_class(Owner). :- set_prolog_flag(multi_arity_warnings,on).
leuschel/ecce
www/CiaoDE/ciao/library/tcltk_obj/Back/menubutton_class_doc.pl
Perl
apache-2.0
2,565
#!/usr/bin/env perl use strict; use warnings; use FindBin; use lib ("$FindBin::Bin/../PerlLib"); use Gene_obj; use Fasta_reader; use GFF3_utils; use Carp; use Nuc_translator; my $usage = "\n\nusage: $0 gff3_file genome_db [prot|CDS|cDNA|gene,default=prot] [flank=0]\n\n"; my $gff3_file = $ARGV[0] or die $usage; my $fasta_db = $ARGV[1] or die $usage; my $seq_type = $ARGV[2] || "prot"; my $flank = $ARGV[3] || 0; my ($upstream_flank, $downstream_flank) = (0,0); if ($flank) { if ($flank =~ /:/) { ($upstream_flank, $downstream_flank) = split (/:/, $flank); } else { ($upstream_flank, $downstream_flank) = ($flank, $flank); } } if ($upstream_flank < 0 || $downstream_flank < 0) { die $usage; } unless ($seq_type =~ /^(prot|CDS|cDNA|gene)$/) { die "Error, don't understand sequence type [$seq_type]\n\n$usage"; } my $fasta_reader = new Fasta_reader($fasta_db); my %genome = $fasta_reader->retrieve_all_seqs_hash(); my $gene_obj_indexer_href = {}; ## associate gene identifiers with contig id's. my $contig_to_gene_list_href = &GFF3_utils::index_GFF3_gene_objs($gff3_file, $gene_obj_indexer_href); foreach my $asmbl_id (sort keys %$contig_to_gene_list_href) { my $genome_seq = $genome{$asmbl_id} or die "Error, cannot find sequence for $asmbl_id"; #cdbyank_linear($asmbl_id, $fasta_db); my @gene_ids = @{$contig_to_gene_list_href->{$asmbl_id}}; foreach my $gene_id (@gene_ids) { my $gene_obj_ref = $gene_obj_indexer_href->{$gene_id}; my %params; if ($seq_type eq "gene") { $params{unspliced_transcript} = 1; } $gene_obj_ref->create_all_sequence_types(\$genome_seq, %params); my $counter = 0; foreach my $isoform ($gene_obj_ref, $gene_obj_ref->get_additional_isoforms()) { $counter++; my $orientation = $isoform->get_orientation(); my ($model_lend, $model_rend) = sort {$a<=>$b} $isoform->get_model_span(); my ($gene_lend, $gene_rend) = sort {$a<=>$b} $isoform->get_gene_span(); my $isoform_id = $isoform->{Model_feat_name}; my $seq = ""; if ($seq_type eq "prot") { $seq = $isoform->get_protein_sequence(); } elsif ($seq_type eq "CDS") { $seq = $isoform->get_CDS_sequence(); if ($upstream_flank || $downstream_flank) { $seq = &add_flank($seq, $upstream_flank, $downstream_flank, $model_lend, $model_rend, $orientation, \$genome_seq); } } elsif ($seq_type eq "cDNA") { $seq = $isoform->get_cDNA_sequence(); if ($upstream_flank || $downstream_flank) { $seq = &add_flank($seq, $upstream_flank, $downstream_flank, $gene_lend, $gene_rend, $orientation, \$genome_seq); } } elsif ($seq_type eq "gene" && $counter == 1) { $seq = $isoform->get_gene_sequence(); if ($upstream_flank || $downstream_flank) { $seq = &add_flank($seq, $upstream_flank, $downstream_flank, $gene_lend, $gene_rend, $orientation, \$genome_seq); } } unless ($seq) { print STDERR "-warning, no $seq_type sequence for $isoform_id\n"; next; } $seq =~ s/(\S{60})/$1\n/g; # make fasta format chomp $seq; my $com_name = $isoform->{com_name} || ""; if ($com_name eq $isoform_id) { $com_name = ""; } # no sense in repeating it my $locus = $isoform->{pub_locus}; my $model_locus = $isoform->{model_pub_locus}; my $locus_string = ""; if ($model_locus) { $locus_string .= $model_locus; } if ($locus) { $locus_string .= " $locus"; } if ($locus_string) { $locus_string .= " "; # add spacer } print ">$isoform_id $gene_id $locus_string $com_name $asmbl_id:$model_lend-$model_rend($orientation)\n$seq\n"; } } } exit(0); #### sub add_flank { my ($seq, $upstream_flank, $downstream_flank, $lend, $rend, $orientation, $genome_seq_ref) = @_; my $far_left = ($orientation eq '+') ? $lend - $upstream_flank : $lend - $downstream_flank; if ($far_left < 1) { $far_left = 1; } my $flank_right = ($orientation eq '+') ? $downstream_flank : $upstream_flank; my $left_seq = substr($$genome_seq_ref, $far_left - 1, $lend - $far_left); my $right_seq = substr($$genome_seq_ref, $rend, $flank_right); if ($orientation eq '+') { return (lc($left_seq) . uc($seq) . lc($right_seq)); } else { return (lc(&reverse_complement($right_seq)) . uc($seq) . lc(&reverse_complement($left_seq))); } }
EVidenceModeler/EVidenceModeler
EvmUtils/gff3_file_to_proteins.pl
Perl
bsd-3-clause
4,619
#!/usr/bin/perl -w use HTML::Parser; use HTML::Entities; use utf8; sub removewhitespace{ my $s = shift; $s =~ s/^\s+|\s+$//g; return $s }; sub convertstring() { my $string = shift; $string = encode_entities($string, '<>&"'); $string = encode_entities($string); return $string; } 1;
sindycarlo/progetto-tecweb
cgi-bin/funzioni.pl
Perl
bsd-3-clause
295
use strict; use Bio::KBase::HandleService; use Getopt::Long; use JSON; use Pod::Usage; my $man = 0; my $help = 0; my ($in, $out); my ($handle); GetOptions( 'h' => \$help, 'i=s' => \$in, 'o=s' => \$out, 'help' => \$help, 'man' => \$man, 'input=s' => \$in, 'output=s' => \$out, 'handle=s' => \$handle, ) or pod2usage(0); pod2usage(-exitstatus => 0, -output => \*STDOUT, -verbose => 1, -noperldoc => 1, ) if $help; pod2usage(-exitstatus => 0, -output => \*STDOUT, -verbose => 2, -noperldoc => 1, ) if $man; pod2usage(-exitstatus => 0, -output => \*STDOUT, -verbose => 1, -noperldoc => 1, ) if ! $out; # do a little validation on the parameters my ($ih, $oh); if ($handle) { open $ih, "<", $handle or die "Cannot open input handle file $handle: $!"; } else { $ih = \*STDIN; } # main logic # there must be an ih and an out my $obj = Bio::KBase::HandleService->new(); my $h = deserialize_handle($ih); my $rv = $obj->download($h, $out); sub serialize_handle { my $handle = shift or die "handle not passed to serialize_handle"; my $json_text = to_json( $handle, { ascii => 1, pretty => 1 } ); print $oh $json_text; } sub deserialize_handle { my $ih = shift or die "in not passed to deserialize_handle"; my ($json_text, $perl_scalar); $json_text .= $_ while ( <$ih> ); $perl_scalar = from_json( $json_text, { utf8 => 1 } ); } =pod =head1 NAME download =head1 SYNOPSIS download <options> =head1 DESCRIPTION The download command calls the download method of a Bio::KBase::HandleService object. It takes as input a JSON serialized handle either from a file (specified by the --handle option) or STDIN (if the --handle option is not provided) and downloads the data represented by the handle to a file that is specified by the --output option. =head1 OPTIONS =over =item -h, --help Basic usage documentation =item --man More detailed documentation =item --handle The input file containing the handle. If not specified, then defaults to STDIN. =item -o, --output The file to write the downloaded data to (REQUIRED) =back =head1 AUTHORS Thomas Brettin =cut 1;
sjyoo/handle_service
scripts/kbhs-download.pl
Perl
mit
2,251
# # Copyright 2016 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 os::linux::local::mode::uptime; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; use POSIX; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "remote" => { name => 'remote' }, "ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'cat' }, "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => '/proc/uptime 2>&1' }, "warning:s" => { name => 'warning', default => '' }, "critical:s" => { name => 'critical', default => '' }, "seconds" => { name => 'seconds', }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; my $stdout = centreon::plugins::misc::execute(output => $self->{output}, options => $self->{option_results}, sudo => $self->{option_results}->{sudo}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}); my ($uptime, $idletime); if ($stdout =~ /([0-9\.]+)\s+([0-9\.]+)/) { ($uptime, $idletime) = ($1, $2) } if (!defined($uptime) || !defined($idletime)) { $self->{output}->add_option_msg(short_msg => "Some informations missing."); $self->{output}->option_exit(); } my $exit_code = $self->{perfdata}->threshold_check(value => floor($uptime), threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->perfdata_add(label => 'uptime', unit => 's', value => floor($uptime), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("System uptime is: %s", defined($self->{option_results}->{seconds}) ? floor($uptime) . " seconds" : floor($uptime / 86400) . " days" )); $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check system uptime. (need '/proc/uptime' file). =over 8 =item B<--warning> Threshold warning in seconds. =item B<--critical> Threshold critical in seconds. =item B<--seconds> Display uptime in seconds. =item B<--remote> Execute command remotely in 'ssh'. =item B<--hostname> Hostname to query (need --remote). =item B<--ssh-option> Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-path> Specify ssh command path (default: none) =item B<--ssh-command> Specify ssh command (default: 'ssh'). Useful to use 'plink'. =item B<--timeout> Timeout in seconds for the command (Default: 30). =item B<--sudo> Use 'sudo' to execute the command. =item B<--command> Command to get information (Default: 'cat'). Can be changed if you have output in a file. =item B<--command-path> Command path (Default: none). =item B<--command-options> Command options (Default: '/proc/uptime 2>&1'). =back =cut
bcournaud/centreon-plugins
os/linux/local/mode/uptime.pm
Perl
apache-2.0
5,978
package Paws::RDS::RestoreDBClusterFromS3Result; use Moose; has DBCluster => (is => 'ro', isa => 'Paws::RDS::DBCluster'); has _request_id => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::RDS::RestoreDBClusterFromS3Result =head1 ATTRIBUTES =head2 DBCluster => L<Paws::RDS::DBCluster> =head2 _request_id => Str =cut
ioanrogers/aws-sdk-perl
auto-lib/Paws/RDS/RestoreDBClusterFromS3Result.pm
Perl
apache-2.0
375
#!/usr/bin/perl # Author: Tom Laudeman # The Institute for Advanced Technology in the Humanities # Copyright 2014 University of Virginia. Licensed under the Educational Community 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.osedu.org/licenses/ECL-2.0 # http://opensource.org/licenses/ECL-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. # find_empty_elements.pl dir=nysa_cpf > nysa_empty.log 2>&1 & # todo: if redirected, consider capturing the final redirect URL # Find empty elements in all the XML files in a directory tree. This is a QA tool to get a quick survey of # elements that are empty, but maybe shouldn't be empty. # Check for missing /eac-cpf/cpfDescription/relations/resourceRelation # If resourceRelation/@xlink:href then check the URL with wget. Run from a special, empty subdir because # sometimes wget downloads a real file. (Maybe after redirecting.) # > ./find_empty_elements.pl > empty.log # grep empty: empty.log| sort -u | less # > grep empty: empty.log| sort -u # empty: <abstract /> # empty: <description> </description> # empty: <empty /> # empty: <eventDescription /> # empty: <fromDate /> # empty: <origination /> # empty: <relations /> # empty: <toDate /> # # Look for <description> </description> in empty.log # less qa_cpf/Names0/047-001771080.xml # grep 047-001771080 ./british_library/file_target.xml # less ./british_library/Names0/047-001771080.xml # less empty.log # xlf ./british_library/Names0/047-001771080.xml # xlf qa_cpf/Names4/047-002259994.xml use strict; use session_lib qw(:all); use XML::XPath; use CGI; # Handles command line name=value pairs. use Time::HiRes qw(usleep nanosleep); my $delay_microsecs = 2000000; # 100000 is 1/10 second, 250000 is 1/4 second # %re_hash serves two purposes. First, it has the regex that matches error pages for a given repo. Second, it is # used to determine which repos have to do a regex text vs just looking at the https header from wget # --spider. # WorldCat note: the normal regex will not work because the initial file "exists" even # for a missing URL. We must have for a Location: redirect in the http header for the # file to be ok. # Use (?:pattern) for clustering alternatives because it is non-capturing and therefore # faster. # Some repositories don't have consistent URLs, or have a mixture, and some have errors in the host name. As a # result of all that, we need a list of host names that identify a given repository. Since there is no # "correct" text to test against leaving us to check bad text, we must be certain that we're looking for the # bad text in a host name that will return the expected. In other words, we won't find the bad text at the # wrong host name, and having not found the bad text we would (incorrectly) return ok. # 'rave.ohiolink.edu' => 'ohlink', # 'archives.library.illinois.edu', => 'uil', # 'www.amphilsoc.org' => 'aps', # 'amphilsoc.org' => 'aps', # 'hdl.loc.gov' => 'lc', # 'archives.nypl.org' => 'nypl', # 'www.lib.ncsu.edu' => 'ncsu', # 'lib.ncsu.edu' => 'ncsu', # Except for worldcat, these were generated by running a keyboard macro on the output of: # find url_xml/ -type f -exec head -n 3 {} \; | grep "<file" > tmp.txt # Manually delete nwda_missing. Or try this: # find url_xml/ -type f -exec head -n 3 {} \; | grep "<file" | grep -v nwda_missing > tmp.txt # hostname alone is not enough. Both yale and uks are using hdl.handle.net. uks is hdl.handle.net/10407 and # yale is hdl.handle.net/10079. There may be other duplicate hosts as well. my %repo_id = ('www.worldcat.org' => 'worldcat', 'ead.lib.virginia.edu' => 'vah', 'www.lib.utexas.edu' => 'taro', 'oasis.lib.harvard.edu' => 'harvard', 'iarchives.nysed.gov' => 'nysa', 'hdl.handle.net' => 'yale', 'archives.nypl.org' => 'nypl', 'www.aaa.si.edu' => 'aar', 'ead.lib.virginia.edu' => 'vah', 'hdl.handle.net' => 'uks', 'findingaids.library.northwestern.edu' => 'nwu', 'archivespec.unl.edu' => 'unl', 'hdl.loc.gov' => 'lc', 'www.mnhs.org' => 'mhs', 'digital.lib.umd.edu' => 'umd', 'rmoa.unm.edu' => 'rmoa', 'library.duke.edu' => 'duke', 'rmc.library.cornell.edu' => 'crnlu', 'quod.lib.umich.edu' => 'umi', 'www.lib.ncsu.edu' => 'ncsu', 'uda-db.orbiscascade.org' => 'utsu', 'digitool.fcla.edu' => 'afl', 'findingaids.cjh.org' => 'cjh', 'oculus.nlm.nih.gov' => 'nlm', 'special.lib.umn.edu' => 'umn', 'library.syr.edu' => 'syru', 'webapp1.dlib.indiana.edu' => 'inu', 'lib.udel.edu' => 'ude', 'archivesetmanuscrits.bnf.fr' => 'bnf', 'asteria.fivecolleges.edu' => 'fivecol', 'acumen.lib.ua.edu' => 'ual', 'libraries.mit.edu' => 'mit', 'doddcenter.uconn.edu' => 'uct', 'arks.princeton.edu' => 'pu', 'www.lib.uchicago.edu' => 'uchic', 'dlib.nyu.edu' => 'html', 'dla.library.upenn.edu' => 'pacscl', 'nmai.si.edu' => 'nmaia', 'nwda.orbiscascade.org' => 'nwda', 'ccfr.bnf.fr' => 'ccfr', 'rave.ohiolink.edu' => 'ohlink', 'www.azarchivesonline.org' => 'aao', 'archives.library.illinois.edu' => 'uil', 'www.library.ufl.edu' => 'afl-ufl', 'nwda.orbiscascade.org' => 'uut', 'findingaids.cul.columbia.edu' => 'colu', 'archiveshub.ac.uk' => 'ahub', 'findingaid.lib.byu.edu' => 'byu', 'www.oac.cdlib.org' => 'oac', 'archives.utah.gov' => 'utsa', 'library.brown.edu' => 'riamco', 'www2.scc.rutgers.edu' => 'rutu'); # regex hash # Yale and UKS use handle.net which properly returns a 404. # NYPL now returns 200 on good requests, and 302 on bad requests. See multi_ok(). There is improved behavior # for sites that don't use a regex to determine success. Old NYPL: 'nypl' => '<title>.*?servlet # error.*?<\/title>', my %re_hash = ( 'aps' => '<title>.*?Invalid Document.*?<\/title>', 'lc' => '<title>.*?Handle Problem Report.*?<\/title>', 'ncsu' => '<div.*?>Collection not found\.</div>', # <div class="alert-box alert">Collection not found.</div> 'ohlink' => '<title>dynaXML Error: Servlet Error</title>', 'uil', => 'Could not load Collection', 'worldcat' => '^Location:', 'rmoa' => '<description>The document does not exist.<\/description>', 'aar' => 'Location: /collections//more', 'aao' => '<title>dynaXML Error: Servlet Error</title>', 'afl' => '<title>DigiTool Stream Gateway Error</title>', 'afl-ufl' => '<title>Page Not Found</title>', 'fivecol' => 'Length: 0 \[text\/html\]', 'mhs' => '404 Not Found', 'inu' => '<title>dynaXML Error: Invalid Document</title>', 'nlm' => '404 Not Found', 'nmaia' => '<title>Page not Found', 'nysa' => '<title>dynaXML Error: Servlet Error</title>', 'crnlu' => 'Location: http://rmc.library.cornell.edu/404.html', 'crnlu_missing' => 'Location: http://rmc.library.cornell.edu/404.html', 'pu' => '404 Not Found', 'pacscl' => '<title>,\s+</title>', 'uchic' => 'No document with the given EADID.', # '<title></title>' 'riamco' => 'Length: 2328 \(2.3K\) \[text\/html\]', 'uks' => 'HTTP request sent, awaiting response... 404 Not Found', 'umd' => 'Length: 0 \[text\/html\]', 'utsu' => 'HTTP request sent, awaiting response... 404 Not Found', 'uut' => 'HTTP request sent, awaiting response... 404 Not Found', 'uct' => 'HTTP request sent, awaiting response... 404 Not Found', 'cjh' => 'Undefined variable', 'colu' => '\-\->\s+<table', 'ude' => 'Location: http://www.lib.udel.edu \[following\]' ); # For any given run it is fairly easy to forget to add an exception to %re_hash, therefore we need to munge # the first URL and confirm that the munged version fails to resolve. This is the global flag for that once-per-run test. my $missing_confirmed = 0; my $check_missing = 1; my $use_cookie = 0; main(); exit(); my $usage = "Usage $0 dir=somedirectory {url|empty}\nWhere somedirectory is repo_whatever.\n"; sub main { my $do_empty = 0; my $do_url = 0; $| = 1; # unbuffer stdout. # Cache each URL that we have already checked. No reason to re-check them. my %check_url; # Cache each file name with a missing host my %missing_host; # Yes, I know we are a commandline app, but Perl's CGI allows us # to use named args which is kind of nice, and as simple as it gets. my $qq = new CGI; my %ch = $qq->Vars(); if (! exists($ch{dir})) { die "No directory specified.\n$usage\n"; } if (! -e $ch{dir} || ! -d $ch{dir}) { die "Specified does not exist or is not a directory.\n$usage\n"; } # Nov 19 2014 Slightly exciting (?:) non capturing expression in order to the * zero or more occurances of _missing so # that foo and foo_missing are both repositories. # Mar 30 2015 Do not make trailing / required on $ch{dir}. The convention is to not have a trailing slash. my $repo; if ($ch{dir} =~ m/^(.*?(?:_missing)*)_/) { $repo = $1; print "Repository: $repo\n"; } elsif ($ch{dir} =~ m/^\/data\/extract\/(.*?)\/*/) { $repo = $1; print "Repository: $repo\n"; } else { die "Can't determine repository name from dir: $ch{dir}\n$usage\n"; } if (exists($ch{use_cookie})) { $use_cookie = 1; print "Using cookie\n"; # Always write the fe_cookies.txt file so we know it exists in the local directory. wget needs this. open(my $out, ">", "fe_cookies.txt"); print $out "www.worldcat.org FALSE / FALSE 0 owcLocRedirectPersistent _nr.selected\n"; close($out); } else { print "Not using cookie\n"; } if (exists($ch{empty})) { $do_empty = 1; print "Checking empty\n"; } else { print "Not checking empty\n"; } if (exists($ch{url})) { print "Checking url\n"; $do_url = 1; printf("Delay between URL fetch: %d microseconds (%f seconds)\n", $delay_microsecs, ($delay_microsecs / 1000000)); } else { print "Not checking url\n"; } if (! $do_empty && ! $do_url) { die "No check specified. Must check empty or url\n$usage\n" } # Some of the URLs required special algos to create the 'bad' URL. We don't care enough to waste time on # that, so when we have crafted a regex to check for bad URLs, we might not want to bother with the # test. Partly because we did the test manually. Of course, this is disabling QA, but we've wasted too # much time on these bad URLs already. An example URL where we would have to munge the pid param would be # http://example.com/foo?pid=11150&custom_att_2=direct I'm sure we could write a custom URL munger, but we # are not going down that rabbit hole. if (exists($ch{noc})) { $check_missing = 0; $missing_confirmed = 1; print "Disabled testing missing URLs\n"; } # The linux find command will not work on a symlinked dir that doesn't have a trailing / so check and add one. if ($ch{dir} !~ m/\/$/) { $ch{dir} = "$ch{dir}/"; } print "Scanning: $ch{dir}\n"; $XML::XPath::Namespaces = 0; my @files = `find $ch{dir} -type f`; chomp(@files); print "Find done. File count: ". scalar(@files) . "\n"; my $xx = 0; my $first_host = ""; foreach my $file (@files) { print "file: $file\n"; my $xpath = XML::XPath->new(filename => $file); # Checking CPF for missing resourceRelation is not redundant because <relations> won't be empty if # there is a <cpfRelation> which is the case with .c and .r files. When both <cpfRelation> and # <resourceRelation> are empty, we will have an empty <relations> below. my $rrel = $xpath->find('/eac-cpf/cpfDescription/relations/resourceRelation'); if ($do_url) { if (! $rrel) { print "missing rrel:\n"; } else { # Apparently something about using the xpath function causes the &amp; entity to be translated # to a ascii & (decimal 38, \046). If the entity was not translated, the wget call would fail. my $url = $xpath->find('/eac-cpf/cpfDescription/relations/resourceRelation/@xlink:href'); if ($url && $do_url) { # Find the repository identity, and deal with changing and unknown host names. Anything # unexpected is an error. All the expected values should be in %repo_id, and %re_hash. my $host = ""; if ($url =~ m/https*:\/\/(.*?)\//) { $host = $1; } if (! $first_host) { print "Host name: $host\n"; $first_host = $host; } elsif ($first_host ne $host) { my $basef = ''; if ($file =~ m/$repo\_cpf_final\/(.+)\.[cr]\d+\.xml/) { $basef = $1; if (exists($missing_host{$basef})) { print "error: (probably missing-dup:) bad host: $host\n"; } else { print "error: (probably missing:) bad host: $host\n"; $missing_host{$basef} = 1; } } else { print "error: (probably missing:) bad host: $host\n"; } next(); } if (exists($check_url{$url}) and $host) { # If we already checked the URL, just print the result, marked with dup: for easy grep'ing. print "dup: $check_url{$url} $url\n"; } else { # Sleep 100 (or 250) milliseconds in an attempt to be nice to their web server. usleep($delay_microsecs); my $url_ok = 0; if (! $missing_confirmed && $check_missing) { # Use digits to munge the URL. At least one server script likes digits in the id # CGI param and treats non-digits specially. We just want to make a non-resolving # URL, or bad CGI parameter. ("Bad" being broadly defined.) Prior to this test, # confirming that the code would properly classify missing URLs was a time # consuming process. # Nov 5 2014 Some servers that use a url with file.xml will server the correct # page if you send a url file.xml1234, so to test the bad url we have to create file1234.xml. # This is bad: http://www.aaa.si.edu/collections/findingaids/bishisab1234.xml my $new_url = ""; if ($url =~ m/\.[A-Za-z]+$/) { $new_url = $url; $new_url =~ s/(\.[A-Za-z]+)$/1234$1/; } elsif ($url =~ m/(?:\?eadid=)|(?:\?source=)/) { # riamco has params ?eadid, umd has params ?source $new_url = $url; $new_url =~ s/((?:\?eadid=)|(?:\?source=))/$1x1234/; } else { $new_url = $url . '1234'; } my $check_url_ok = url_check($repo, $new_url); if ($check_url_ok) { die "Error: Bad URL returns ok: $new_url\nOriginal URL: $url\n"; } else { print("Missing test confirmed (tested: $new_url)\n"); $missing_confirmed = 1; } } $url_ok = url_check($repo, $url); if ($url_ok) { # We have a hit. The "ok" value in the check_url hash must be unique for grep'ing # the results. Dups have the text "ok-prev:" and are detected way back at the top # of the URL checking code, so they'll never reach this point. print "ok: $url\n"; $check_url{$url} = "ok-prev:"; } else { # The "missing" value in the check_url hash must be unique for grep'ing the results. print "missing: $url\n"; $check_url{$url} = "missing-prev:"; } } } } } if ($do_empty) { # Sep 23 2014 Add test for not ancestor::objectXMLWrap since we only care about empty elements in # the CPF itself. # xpath cpf_qa/howard/Coll._113-ead.c01.xml '//*[not(ancestor::objectXMLWrap)]/attribute::*[.=""]' 2> /dev/null | less # xpath cpf_qa/howard/Coll._113-ead.c01.xml '//*[@*="" and not(ancestor::objectXMLWrap)]' 2> /dev/null | less # xpath cpf_qa/howard/Coll._113-ead.c01.xml 'local-name(//*[@*="" and not(ancestor::objectXMLWrap)])' 2> /dev/null | less # my $empty_nodes = $xpath->find('//*[((not(*) and not(normalize-space())) or not(@*)) and not(ancestor::objectXMLWrap)]'); my $empty_nodes = $xpath->find('//*[(not(normalize-space()) or @*="") and not(ancestor::objectXMLWrap)]'); if ($empty_nodes) { foreach my $node ($empty_nodes->get_nodelist()) { # my $val = $node->toString(); my $val = $node->getName(); print "empty: $val"; my $empty_attr = $xpath->find('attribute::*[.=""]', $node); if ($empty_attr) { foreach my $node ($empty_attr->get_nodelist()) { my $val = $node->getName(); print " attr: $val"; } } print "\n"; } } } $xx++; } } sub url_check { my $host = $_[0]; my $url = $_[1]; # Rather than returning a 404, most sites returns a 200 http header for missing # pages. In other words, even a bad URL returns a 200 web page. Instead of using the # http header result, we have to actually retrieve the entire web page and check it # with a regex. # Good URL examples: # http://iarchives.nysed.gov/xtf/view?docId=14610-88F.xml # http://www.amphilsoc.org/mole/view?docId=ead/Mss.B.W76a-ead.xml # http://archives.library.illinois.edu/archon/?p=collections/controlcard&id=995 my $cookie_suffix = ""; if ($use_cookie) { my $cookie_suffix = " --load-cookies fe_cookies.txt"; } my $cmd = "wget -O - \"$url\" $cookie_suffix"; if ($host eq 'www.worldcat.org' || ! exists($re_hash{$host})) { # Why did url checking on pu create files? Must use -O - even with --spider because some combination # of server responses causes wget to save the file after all. --delete-after without the -O - works # too. It could be the 302 followed by a 500 followed by a 200. Note the "(try: 2)" # wget --delete-after --spider "http://arks.princeton.edu/ark:/88435/0k225b05z" 2>&1 # wget --spider -O - "http://arks.princeton.edu/ark:/88435/0k225b05z" 2>&1 | less # Remember, every command has 2>&1 when executed below. Don't add it twice. $cmd = "wget --spider -O - \"$url\" $cookie_suffix" } my $res = `$cmd 2>&1`; my $url_ok = 0; if (multi_ok('host' => $host, 'text' => "$res")) { $url_ok = 1; } return $url_ok; } sub multi_ok { my %args = @_; my $host = $args{host}; my $text = $args{text}; # Add new repo/regex pairs to this hash. # Worldcat at least uses ^ for start of line in the regex, and to support that we need /sm switches. It # should be fine for all the others which are mid-line matches. # The two cases here with inverse logic is somewhat disturbing. # print "host: $host test: " . substr($text, 0, 40) . "...\n"; # If we have a test regex, then don't worry about doing the normal http 200 test. It will always be true. if (! exists($re_hash{$host})) { # print "No regex: $host\n"; # Nov 1 2014. Which server returned "Remote file exists" but not with a 200 http response? That seems odd/wrong # becase "Remote file exists" is also returned for 302 and other redirects. # if (($text =~ m/^(?:Remote file exists)|(?:awaiting response\.\.\. 200 OK$)/sm)) # Lacking the previous examples, what seems to make sense is to only accept a 200 response as good, # and anything else is bad. I seem to recollect that WorldCat returns a redirect, but the new logic # here is that WorldCat will test the response with a regex, and look for "Location:". Having a regex, # WorldCat won't come into this code branch. my $ret_val = 0; while ($text =~ m/^HTTP request sent, awaiting response\.\.\. (\d+) ([A-Za-z ]+)$/smg) { if ($1 eq 200) { # If this is the only http response code, then the request was successful, and we keep looking # for response codes. $ret_val = 1; } if ($1 ne 200) { # However, any other response code means there was something fishy, at least for the non-regex # hosts. Yes, I know we're returning from inside a loop. # Well behaved servers will return 404, although in at least one case only after trying a redirect. # It seems like a good idea to return a zero (url not ok) if any http response is a 404. return 0; } } return $ret_val; } elsif (exists($re_hash{$host})) { # print "matching host: $host matching: $re_hash{$host}\n"; # print "\n$text\n"; if ($text =~ m/$re_hash{$host}/sm) { return 0; } # This is dangerous. Basically, we assume that since didn't find the error text, the URL must be # ok. That assumption is weak. Much better would be to search for text that only occurs in the good # URLs. We try to make up for this by having an explicit list of host names that will behave as # expected. return 1; } else { die "Error: No matching regex for: $host\n"; } return 0; }
snac-cooperative/snac_eac_cpf_utils
find_empty_elements.pl
Perl
apache-2.0
25,023
package DDG::Goodie::IndependenceDay; # ABSTRACT: Goodie answer for different countries' national independence days use DDG::Goodie; use JSON; use utf8; zci answer_type => "independence_day"; zci is_cached => 1; name "independence day"; description "Gives the date of when a nation assumed independence"; primary_example_queries "what is the independence day of norway", "independence day, papua new guinea"; category "dates"; topics "trivia"; code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IndependenceDay.pm"; attribution github => ["jarmokivekas", "Jarmo Kivekäs"], web => ["http://guttula.com", "Jarmo Kivekäs"], github => ["YouriAckx", "Youri Ackx"], twitter => ["YouriAckx", "Youri Ackx"]; # Triggers triggers any => "independence day", "day of independence"; # uses https://en.wikipedia.org/wiki/List_of_national_independence_days as data source my $data = share('independence_days.json')->slurp; $data = decode_json($data); # define aliases for some countries to improve hit rate my $alias_lookup = share('country_aliases.json')->slurp; $alias_lookup = decode_json($alias_lookup); # Handle statement handle query_clean => sub { # delete noise from query string s/(national|independence of|independence|day of|day|when|what|is the|for|)//g; # delete the whitespace left from query noise (spaces between words) s/^\s*|\s*$//g; # only the name of the country should be left in the string at this point # convert a possible alias into the proper name my $country_key = $alias_lookup->{$_} || $_; # return if the string is not one of the countries return unless $data->{$country_key}; # Format the country name properly for display my $country = $country_key; # Title Case The Country Name $country =~ s/(\w\S*)/\u\L$1/g; # lowercase the words 'of', 'the' and 'and' $country =~ s/\sThe\s/ the /; $country =~ s/\sOf\s/ of /; $country =~ s/\sAnd\s/ and /; # ouput string formatting my $prolog = 'Independence Day of ' . $country; # date and year of independence my $date_str = $data->{$country_key}[0]{'date'} . ', ' . $data->{$country_key}[0]{'year'}; # Some coutries have two dates, add it to the answer if a second one exists. if ($data->{$country_key}[1]){ $date_str .= ' and ' . $data->{$country_key}[1]{'date'} . ', ' . $data->{$country_key}[1]{'year'}; } # html formatted answer my $html = '<div>'; $html .= '<div class="zci__caption">' . $date_str . '</div>'; $html .= '<div class="zci__subheader">' . $prolog . '</div>'; $html .= '</div>'; # plain text answer my $text = $prolog . ' ' . $date_str; return $text, html => $html; }; 1;
Acidburn0zzz/zeroclickinfo-goodies
lib/DDG/Goodie/IndependenceDay.pm
Perl
apache-2.0
2,787
#! /usr/bin/perl -w use strict; use CGI; use CoGeX; use CoGe::Accessory::Web; use CoGe::Core::Genome qw(genomecmp); use HTML::Template; use Sort::Versions; no warnings 'redefine'; use vars qw( $P $PAGE_TITLE $USER $coge $FORM %FUNCTION $LINK ); $PAGE_TITLE = 'Genomes'; $FORM = new CGI; ( $coge, $USER, $P, $LINK ) = CoGe::Accessory::Web->init( cgi => $FORM, page_title => $PAGE_TITLE ); %FUNCTION = ( generate_html => \&generate_html, create_genome => \&create_genome, delete_genome => \&delete_genome, get_genomes_for_user => \&get_genomes_for_user, ); CoGe::Accessory::Web->dispatch( $FORM, \%FUNCTION, \&generate_html ); sub delete_genome { my %opts = @_; my $gid = $opts{gid}; return "Must have valid genome id\n" unless ($gid); print STDERR "delete_genome $gid\n"; # Check permission return 0 unless ( $USER->is_admin or $USER->is_owner( dsg => $gid ) ); # Delete the genome and associated connectors & datasets my $genome = $coge->resultset('Genome')->find($gid); return 0 unless $genome; $genome->deleted(1); $genome->update; CoGe::Accessory::Web::log_history( db => $coge, user_id => $USER->id, page => "$PAGE_TITLE", description => 'delete genome id' . $genome->id ); return 1; } sub get_genomes_for_user { #my %opts = @_; my @genomes; # if ( $USER->is_admin ) { # @genomes = $coge->resultset('Genome')->all(); # } # else { push @genomes, $USER->genomes; # } my @genome_info; foreach my $g (@genomes) { #( sort genomecmp @genomes ) { push @genome_info, { NAME => qq{<span class="link" onclick='window.open("GenomeInfo.pl?gid=} . $g->id . qq{")'>} . $g->info . "</span>", VERSION => $g->version, DATE => $g->get_date, EDIT_BUTTON => "<span class='link ui-icon ui-icon-gear' onclick=\"window.open('GenomeInfo.pl?gid=" . $g->id . "')\"></span>", DELETE_BUTTON => "<span class='link ui-icon ui-icon-trash' onclick=\"dialog_delete_genome({gid: '" . $g->id . "'});\"></span>" }; } my $template = HTML::Template->new( filename => $P->{TMPLDIR} . $PAGE_TITLE . '.tmpl' ); $template->param( DO_GENOME_TABLE => 1 ); $template->param( GENOME_LOOP => \@genome_info ); # $template->param( TYPE_LOOP => get_list_types() ); return $template->output; } sub generate_html { my $template = HTML::Template->new( filename => $P->{TMPLDIR} . 'generic_page.tmpl' ); $template->param( PAGE_TITLE => $PAGE_TITLE, TITLE => 'Genomes', PAGE_LINK => $LINK, HOME => $P->{SERVER}, HELP => 'Genomes', WIKI_URL => $P->{WIKI_URL} || '' ); my $name = $USER->user_name; $name = $USER->first_name if $USER->first_name; $name .= ' ' . $USER->last_name if ( $USER->first_name && $USER->last_name ); $template->param( USER => $name ); $template->param( LOGON => 1 ) unless $USER->user_name eq "public"; my $link = "http://" . $ENV{SERVER_NAME} . $ENV{REQUEST_URI}; $link = CoGe::Accessory::Web::get_tiny_link( url => $link ); $template->param( BODY => generate_body() ); $template->param( ADMIN_ONLY => $USER->is_admin ); $template->param( CAS_URL => $P->{CAS_URL} || '' ); return $template->output; } sub generate_body { my $template = HTML::Template->new( filename => $P->{TMPLDIR} . $PAGE_TITLE . '.tmpl' ); $template->param( MAIN => 1 ); $template->param( PAGE_NAME => $PAGE_TITLE ); $template->param( GENOME_TABLE => get_genomes_for_user() ); return $template->output; }
asherkhb/coge
old/Genomes.pl
Perl
bsd-2-clause
3,926