| 1 | package PMLTQ::Command::query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $PMLTQ::Command::query::VERSION = '2.0.3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: WIP: Executes query on treebank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use PMLTQ::Base 'PMLTQ::Command'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use PMLTQ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Treex::PML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Treex::PML::Instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Treex::PML::Schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use PMLTQ::Common ':tredmacro'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use HTTP::Request::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Pod::Usage 'pod2usage'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $extension_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | GetOptionsFromArray(\@args, \%opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'debug|D', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'server|s=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 'command|c=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 'ntred|N', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 'jtred|J', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'btred|B', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 'sql|S', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'shared-dir|d=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 'keep-tmp-files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 'filelist|l=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'username=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'password=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'auth-id=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'pmltq-extension-dir|X=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'stdin', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'query|Q=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'query-id|i=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'query-file|f=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'query-pml-file|p=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'filters|F=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'no-filters', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'old-api', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'output-json', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'netgraph-query|G=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'print-servers|P', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'config-file|c=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 'node-types|n', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 'relations|r', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'limit|L=i', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'timeout|t=i', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'history|H', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'quiet|q', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'help|h=s@', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'usage|u', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'version|V', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'man' ) || die "invalid options"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | Treex::PML::AddResourcePath( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | PMLTQ->resources_dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | File::Spec->catfile(${FindBin::RealBin},'config'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $ENV{HOME}.'/.tred.d' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | Treex::PML::AddBackends(qw(Storable PMLBackend PMLTransformBackend)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($opts{stdin}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $opts{query} = <STDIN>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $opts{$1}=1 if defined($opts{server}) and $opts{server}=~s{^[nbj]tred://}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts{"server"} and $opts{"server"} =~ s[^[nbj]tred://][]
MC/DC0%0/2
defined $opts{"server"} and $opts{"server"} =~ s[^[nbj]tred://][]
defined $opts{"server"}
$opts{"server"} =~ s[^[nbj]tred://][]
Truth table0%0/3
A and B
A= defined $opts{"server"}B= $opts{"server"} =~ s[^[nbj]tred://][]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $extension_dir = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $opts{'pmltq-extension-dir'} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | File::Spec->catfile($ENV{HOME},'.tred.d','extensions', 'pmltq'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'pmltq-extension-dir'} || 'File::Spec'->catfile($ENV{'HOME'}, '.tred.d', 'extensions', 'pmltq')
MC/DC0%0/2
$opts{'pmltq-extension-dir'} || 'File::Spec'->catfile($ENV{'HOME'}, '.tred.d', 'extensions', 'pmltq')
$opts{'pmltq-extension-dir'}
'File::Spec'->catfile($ENV{'HOME'}, '.tred.d', 'extensions', 'pmltq')
Truth table0%0/3
A || B
A= $opts{'pmltq-extension-dir'}B= 'File::Spec'->catfile($ENV{'HOME'}, '.tred.d', 'extensions', 'pmltq')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | Treex::PML::AddResourcePath(File::Spec->catfile($extension_dir,'resources')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($opts{ntred}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ntred_search(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } elsif ($opts{jtred}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | jtred_search(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } elsif ($opts{btred}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | btred_search(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->pmltq_http_search(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | my %auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub pmltq_http_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pmltq_http_search: not called CC=51 SCAR=78.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($opts{query} and !@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$opts{"query"} and not @args
MC/DC0%0/2
$opts{"query"} and not @args
$opts{"query"}
not @args
Truth table0%0/3
A and not(B)
A= $opts{"query"}B= not @args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $query = $opts{query}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ▶ | } elsif (!$query and @args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $query and @args
MC/DC0%0/2
not $query and @args
not $query
@args
Truth table0%0/3
not(A) and B
A= not $queryB= @args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $query=join ' ',@args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif ($opts{'query-pml-file'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $query_file = Treex::PML::Factory->createDocumentFromFile($opts{'query-pml-file'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | die "Failed to open PML query file $opts{'query-pml-file'}: $Treex::PML::FSError\n" if $Treex::PML::FSError or !$query_file or !$query_file->trees; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$Treex::PML::FSError or not $query_file or not $query_file->trees
$Treex::PML::FSError or not $query_file
MC/DC0%0/3
$Treex::PML::FSError or not $query_file or not $query_file->trees
$Treex::PML::FSError
not $query_file
not $query_file->trees
Truth table0%0/4
A or not(B) or not(C)
A= $Treex::PML::FSErrorB= not $query_fileC= not $query_file->trees
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $query = first { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | !$opts{'query-id'} or $_->{id} and $_->{id} eq $opts{'query-id'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
!$opts{'query-id'} || $_->{'id'} && $_->{'id'} eq $opts{'query-id'}
$_->{"id"} and $_->{"id"} eq $opts{"query-id"}
MC/DC0%0/3
!$opts{'query-id'} || $_->{'id'} && $_->{'id'} eq $opts{'query-id'}
!$opts{'query-id'}
$_->{"id"}
$_->{"id"} eq $opts{"query-id"}
Truth table0%0/4
not(A) || B and C
A= !$opts{'query-id'}B= $_->{"id"}C= $_->{"id"} eq $opts{"query-id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | } $query_file->trees; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | die "Didn't find query $opts{'query-id'} in query file $opts{'query-pml-file'}!" unless $query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $query = encode('UTF-8',PMLTQ::Common::as_text($query)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } elsif ($opts{'query-file'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | open my $fh, $opts{'query-file'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | or die "Cannot open query file '$opts{'query-file'}': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $query = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ($opts{'query-id'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $query=~s/#\s*==\s*query:\s*\Q$opts{'query-id'}\E\s* ==(.*?)(?:#\s*==\s*query:\s*\w+\s*==.*|$)/$1/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ▶ | } elsif (!$opts{'node-types'} and !$opts{'relations'} and !$opts{'print-servers'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$opts{'node-types'} || $opts{'relations'} || $opts{'print-servers'}
$opts{"node-types"} or $opts{"relations"}
MC/DC0%0/3
$opts{'node-types'} || $opts{'relations'} || $opts{'print-servers'}
$opts{"node-types"}
$opts{"relations"}
$opts{'print-servers'}
Truth table0%0/4
A or B || C
A= $opts{"node-types"}B= $opts{"relations"}C= $opts{'print-servers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | pod2usage(-msg => 'pmltq'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (!$opts{'query-pml-file'} and $opts{'netgraph-query'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $opts{"query-pml-file"} and $opts{"netgraph-query"}
MC/DC0%0/2
not $opts{"query-pml-file"} and $opts{"netgraph-query"}
not $opts{"query-pml-file"}
$opts{"netgraph-query"}
Truth table0%0/3
not(A) and B
A= not $opts{"query-pml-file"}B= $opts{"netgraph-query"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | require PMLTQ::NG2PMLTQ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $query = PMLTQ::NG2PMLTQ::ng2pmltq($query,{type=>$opts{'netgraph-query'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if (!$opts{'node-types'} and !$opts{'relations'} and !$opts{'print-servers'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opts{"node-types"} or $opts{"relations"} or $opts{"print-servers"}
$opts{"node-types"} or $opts{"relations"}
MC/DC0%0/3
$opts{"node-types"} or $opts{"relations"} or $opts{"print-servers"}
$opts{"node-types"}
$opts{"relations"}
$opts{"print-servers"}
Truth table0%0/4
A or B or C
A= $opts{"node-types"}B= $opts{"relations"}C= $opts{"print-servers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | die "Query is empty!" unless $query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $filters = $opts{'filters'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($filters and $filters=~/\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$filters and $filters =~ /\S/
MC/DC0%0/2
$filters and $filters =~ /\S/
$filters
$filters =~ /\S/
Truth table0%0/3
A and B
A= $filtersB= $filters =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $filters='>> '.$filters unless $filters =~ /^\s*>>/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $query .= $filters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $opts{'config-file'} ||= Treex::PML::FindInResources('treebase.conf'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"config-file"} ||= Treex::PML::FindInResources("treebase.conf")
MC/DC0%0/2
$opts{"config-file"} ||= Treex::PML::FindInResources("treebase.conf")
$opts{"config-file"}
Treex::PML::FindInResources("treebase.conf")
Truth table0%0/3
A ||= B
A= $opts{"config-file"}B= Treex::PML::FindInResources("treebase.conf")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($opts{debug}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | print STDERR "Reading configuration from $opts{'config-file'}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | my $configs = (-f $opts{'config-file'}) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | Treex::PML::Factory->createPMLInstance({ filename=>$opts{'config-file'} })->get_root->{configurations} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $id = $opts{'server'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $id ||= 'default' unless $opts{'print-servers'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$id ||= "default"
MC/DC0%0/1
$id ||= "default"
$id
Truth table0%0/2
A
A= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my ($conf,$type) = $id ? get_server_conf($configs,$id, $opts{'old-api'}) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | %auth = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | username => $opts{username}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | password => $opts{password}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($opts{'auth-id'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my ($auth) = get_server_conf($configs,$opts{'auth-id'}, $opts{'old-api'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $auth{$_} ||= $auth->{$_} for qw(username password); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$auth{$_} ||= $auth->{$_}
MC/DC0%0/2
$auth{$_} ||= $auth->{$_}
$auth{$_}
$auth->{$_}
Truth table0%0/3
A ||= B
A= $auth{$_}B= $auth->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | die "Didn't find auth-id configuration: $opts{'auth-id'}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ($conf) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $auth{$_} ||= $conf->{$_} for qw(username password baseurl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$auth{$_} ||= $conf->{$_}
MC/DC0%0/2
$auth{$_} ||= $conf->{$_}
$auth{$_}
$conf->{$_}
Truth table0%0/3
A ||= B
A= $auth{$_}B= $conf->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($opts{'print-servers'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($opts{'server'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | unless ($type eq 'http') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | die "Cannot query available services on a $type server"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $result=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $self->http_search($conf->{url},$query,{ other=>1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | callback => sub { $result.=$_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | debug=>$opts{debug}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | %auth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 'baseurl' => $conf->{baseurl} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my @services = split /\n/,$result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | for my $srv (@services) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my %srv = map { split(':',$_,2) } split /\t/, $srv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | print $srv{id},"\t",$srv{service},"\t",$srv{title},"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my @types = qw(dbi http); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my %columns = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | dbi => [qw(driver host port database username sources)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | http => [qw(url username cached_description/title)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my %configs = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | map { my $type = $_; ($_ =>[map $_->value, grep { $_->name eq $type } SeqV($configs)]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | @types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | for my $type (@types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $confs = $configs{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (@$confs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | print uc($type)." configurations:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | print (("-"x60)."\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | for my $c (@$confs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | print $c->{id}.": ".(join(", ", map "$_->[0]=$_->[1]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | grep length($_->[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | map [m{/(.*)} ? $1 : $_,Treex::PML::Instance::get_data($c,$_)], @{$columns{$type}})."\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | print STDERR $query,"\n" if $opts{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ($type eq 'http') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | #if($opts{'old-api'}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $self->http_search($conf->{url},$query,{ 'node-types'=>$opts{'node-types'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 'relations'=>$opts{'relations'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | debug=>$opts{debug}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | %auth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 'old-api'=>$opts{'old-api'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 'output-json'=>$opts{'output-json'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 'baseurl' => $conf->{baseurl} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | #} else { ## NEW API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # print STDERR "TODO NEW API\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | require PMLTQ::SQLEvaluator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | my $evaluator = PMLTQ::SQLEvaluator->new(undef,{connect => $conf, debug=>$opts{debug}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | %auth | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $evaluator->connect(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($opts{'node-types'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | print join "\n", @{$evaluator->get_node_types}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } elsif ($opts{'relations'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | print join "\n", @{$evaluator->get_specific_relations}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | search($evaluator,$query); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $evaluator->{dbi}->disconnect() if $evaluator->{dbi}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub get_server_conf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_server_conf: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($configs,$id, $oldapi)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my ($conf,$type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ($id =~ /^https?:/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $type = 'http'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $conf = {url => $id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | unless($oldapi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $conf->{baseurl} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $conf->{baseurl} =~ s@api/treebanks.*?$@@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $conf_el = first { $_->value->{id} eq $id } SeqV($configs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | die "Didn't find server configuration named '$id'!\nUse $0 --print-servers and then $0 --server <config-id|URL>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | unless $conf_el; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $conf = $conf_el->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | unless($oldapi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $conf->{baseurl} = $conf->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $conf->{url} = URI::WithBase->new('/',$conf->{url}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $conf->{url}->path_segments('api', 'treebanks', $conf->{treebank}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $conf->{url} = $conf->{url}->abs->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $type = $conf_el->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return ($conf,$type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub http_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_search: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my ($self,$url,$query,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $opts||={}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts ||= {}
MC/DC0%0/1
$opts ||= {}
$opts
Truth table0%0/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $tmp = File::Temp->new( TEMPLATE => 'pmltq_XXXXX', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | TMPDIR => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | UNLINK => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | SUFFIX => '.txt' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if($opts->{'old-api'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | $ua->credentials(URI->new($url)->host_port,'PMLTQ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | $auth{username}, $auth{password}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if $opts->{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $ua = $self->ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $ua->agent("PMLTQ/1.0 "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | $self->login($ua,\%auth) if $opts->{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | $url.='/' unless $url=~m{^https?://.+/$}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $METHOD = \&POST; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ($opts->{'node-types'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $url = $opts->{'old-api'} ? qq{${url}nodetypes} : qq{${url}node-types}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $METHOD = \&GET unless $opts->{'old-api'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $query = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } elsif ($opts->{'relations'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $url = qq{${url}relations}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $METHOD = \&GET unless $opts->{'old-api'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $query = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } elsif ($opts->{'other'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $url = qq{${url}other}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | die "Unknown option --other in new api\n" unless $opts->{'old-api'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $query = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $url = qq{${url}query}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | $ua->timeout($opts{timeout}+2) if $opts{timeout}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $q = $query; Encode::_utf8_off($q); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | binmode STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my $sub = $opts->{callback} || sub { print $opts{'output-json'} ? ($_[0]) : (map {join("\t",@$_)."\n"} @{JSON::from_json($_[0])->{results}}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
Condition0%0/3
$opts->{'callback'} || sub {
print $opts{'output-json'} ? $_[0] : map({join("\t", @$_) . "\n";} @{&JSON::from_json($_[0])->{'results'};});
}
MC/DC0%0/2
$opts->{'callback'} || sub {
print $opts{'output-json'} ? $_[0] : map({join("\t", @$_) . "\n";} @{&JSON::from_json($_[0])->{'results'};});
}
$opts->{'callback'}
sub {
print $opts{'output-json'} ? $_[0] : map({join("\t", @$_) . "\n";} @{&JSON::from_json($_[0])->{'results'};});
}
Truth table0%0/3
A || B
A= $opts->{'callback'}B= sub {
print $opts{'output-json'} ? $_[0] : map({join("\t", @$_) . "\n";} @{&JSON::from_json($_[0])->{'results'};});
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | my $res = $ua->request($METHOD->($url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $opts->{'old-api'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | ([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | query => $q, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | format => 'text', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | limit => $opts{limit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | row_limit => $opts{limit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | timeout => $opts{timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Content_Type => 'application/json;charset=UTF-8', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | User_Agent => 'PML-TQ CLI', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | Content => JSON->new->utf8->encode({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | query => $q, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | limit => $opts{limit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # row_limit => $opts{limit}, #TODO: currently not working | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | timeout => $opts{timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | nohistory => !!$opts{history} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ),$sub ,1024*8 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | unless ($res->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | die $res->status_line."\n".$res->content."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my ($evaluator,$query)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $evaluator->prepare_query($query); # count=>1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | $results = $evaluator->run({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | node_limit => $opts{limit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | row_limit => $opts{limit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | timeout => $opts{timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | timeout_callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | print STDERR "Evaluation of query timed out\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | exit 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | if ($results) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | for my $r (@$results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | print join("\t",@$r)."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | print STDERR $#$results+1," result(s)\n" unless $opts{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub quote_cmdline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_cmdline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $quoted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | join ' ', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $arg = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $arg =~ s{'}{'\\''}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | qq{'$arg'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub ntred_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ntred_search: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my ($host,$port)= $opts{server} ? split(/:/,$opts{server}) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | my $command = $opts{command} || 'ntred'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'command'} || 'ntred'
MC/DC0%0/1
$opts{'command'} || 'ntred'
$opts{'command'}
Truth table0%0/2
A
A= $opts{'command'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | my $shared_dir=File::Spec->rel2abs($opts{'shared-dir'} || '.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'shared-dir'} || '.'
MC/DC0%0/1
$opts{'shared-dir'} || '.'
$opts{'shared-dir'}
Truth table0%0/2
A
A= $opts{'shared-dir'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $filter_file="$shared_dir/pmltq_ntred_filter.$$.pl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my @script_flags=('--filter-code-out', $filter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | foreach (qw(query query-id query-file query-pml-file filters netgraph-query)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | push @script_flags, '--'.$_, (/file/ ? File::Spec->rel2abs($opts{$_}) : $opts{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if defined($opts{$_}) and length($opts{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $opts{$_} and length $opts{$_}
MC/DC0%0/2
defined $opts{$_} and length $opts{$_}
defined $opts{$_}
length $opts{$_}
Truth table0%0/3
A and B
A= defined $opts{$_}B= length $opts{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | $command .= ' '.quote_cmdline( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ((defined($host) and length($host)) ? ('--hub',$host) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ((defined($port) and length($port)) ? ('--port',$port) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | '-q', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | '-I', File::Spec->catfile($extension_dir,qw(contrib pmltq pmltq.ntred)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | ($opts{filelist} ? ('-l', File::Spec->rel2abs($opts{filelist})) : (@args ? ('-L', '--', @args) : ())), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
defined $host and length $host
defined $port and length $port
MC/DC0%0/2
defined $host and length $host
defined $host
length $host
MC/DC0%0/2
defined $port and length $port
defined $port
length $port
Truth table0%0/3
A and B
A= defined $hostB= length $host
Truth table0%0/3
A and B
A= defined $portB= length $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | '--', @script_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | open(my $pipe, $command.' | ') || die "Failed to start ntred client: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | apply_filter($pipe, $filter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | close($pipe); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | unlink $filter_file if -f $filter_file and !$opts{'keep-tmp-files'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $filter_file and not $opts{"keep-tmp-files"}
MC/DC0%0/2
-f $filter_file and not $opts{"keep-tmp-files"}
-f $filter_file
not $opts{"keep-tmp-files"}
Truth table0%0/3
A and not(B)
A= -f $filter_fileB= not $opts{"keep-tmp-files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub jtred_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jtred_search: not called CC=24 SCAR=64.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $command = $opts{command} || 'jtred'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'command'} || 'jtred'
MC/DC0%0/1
$opts{'command'} || 'jtred'
$opts{'command'}
Truth table0%0/2
A
A= $opts{'command'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $jobname="pmltq_jtred_$$"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if ($opts{server}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $jobname.="-".$ENV{HOSTNAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | my $shared_dir=File::Spec->rel2abs($opts{'shared-dir'} || '.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'shared-dir'} || '.'
MC/DC0%0/1
$opts{'shared-dir'} || '.'
$opts{'shared-dir'}
Truth table0%0/2
A
A= $opts{'shared-dir'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my $filter_file="$shared_dir/$jobname.pl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $filelist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ($opts{filelist}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my ($vol,$dir) = File::Spec->splitpath($opts{filelist}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my $base = File::Spec->catpath($vol,$dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | open my $fh, '<', $opts{filelist} or die "Cannot open filelist $opts{filelist}: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $filelist = "$shared_dir/$jobname.fl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | open my $out_fh, '>', $filelist or die "Cannot create temporary filelist $filelist: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | print STDERR "Resolving filelist files to $base...\n" unless $opts{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | while(<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | print $out_fh File::Spec->rel2abs($_,$base),"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | print STDERR "done.\n" unless $opts{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | close $out_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my @script_flags=('--filter-code-out', $filter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | foreach (qw(query query-id query-file query-pml-file filters netgraph-query)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | push @script_flags, '--'.$_, (/file/ ? File::Spec->rel2abs($opts{$_}) : $opts{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if defined($opts{$_}) and length($opts{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $opts{$_} and length $opts{$_}
MC/DC0%0/2
defined $opts{$_} and length $opts{$_}
defined $opts{$_}
length $opts{$_}
Truth table0%0/3
A and B
A= defined $opts{$_}B= length $opts{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | my @command = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | $command, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ($opts{'shared-dir'} ? ('-jw', $shared_dir) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | '-jn', $jobname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | ($opts{quiet} ? '-jq' : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ($filelist ? ('-l', $filelist) : @args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | '-jb', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | '-q', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | '-I', File::Spec->catfile($extension_dir,qw(contrib pmltq pmltq.ntred)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | '-o', @script_flags, '--' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $pipe; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if ($opts{server}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my $cwd = quote_cmdline(getcwd()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | open($pipe, '-|', 'ssh', $opts{server}, <<"SCRIPT".quote_cmdline(@command)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | if [ -f ~/.bash_profile ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | . ~/.bash_profile 2>/dev/null 1>&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | elif [ -f ~/.profile ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | . ~/.profile 2>/dev/null 1>&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | cd $cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | SCRIPT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | || die "Failed to start jtred on host $opts{server} over ssh: $!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | open($pipe, '-|',@command) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | || die "Failed to start jtred: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | apply_filter($pipe, $filter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | close($pipe); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | unlink $filter_file if -f $filter_file and !$opts{'keep-tmp-files'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $filter_file and not $opts{"keep-tmp-files"}
MC/DC0%0/2
-f $filter_file and not $opts{"keep-tmp-files"}
-f $filter_file
not $opts{"keep-tmp-files"}
Truth table0%0/3
A and not(B)
A= -f $filter_fileB= not $opts{"keep-tmp-files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | unlink $filelist if $filelist and !$opts{'keep-tmp-files'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$filelist and not $opts{"keep-tmp-files"}
MC/DC0%0/2
$filelist and not $opts{"keep-tmp-files"}
$filelist
not $opts{"keep-tmp-files"}
Truth table0%0/3
A and not(B)
A= $filelistB= not $opts{"keep-tmp-files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub btred_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
btred_search: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my $command = $opts{command} || 'btred'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'command'} || 'btred'
MC/DC0%0/1
$opts{'command'} || 'btred'
$opts{'command'}
Truth table0%0/2
A
A= $opts{'command'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $jobname="pmltq_btred_$$"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ($opts{server}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $jobname.="-".$ENV{HOSTNAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | my $shared_dir=File::Spec->rel2abs($opts{'shared-dir'} || '.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'shared-dir'} || '.'
MC/DC0%0/1
$opts{'shared-dir'} || '.'
$opts{'shared-dir'}
Truth table0%0/2
A
A= $opts{'shared-dir'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $filter_file="$shared_dir/$jobname.pl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my @script_flags=('--filter-code-out', $filter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | foreach (qw(query query-id query-file query-pml-file filters netgraph-query)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | push @script_flags, '--'.$_, (/file/ ? File::Spec->rel2abs($opts{$_}) : $opts{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if defined($opts{$_}) and length($opts{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $opts{$_} and length $opts{$_}
MC/DC0%0/2
defined $opts{$_} and length $opts{$_}
defined $opts{$_}
length $opts{$_}
Truth table0%0/3
A and B
A= defined $opts{$_}B= length $opts{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | for (qw(node-types relations)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if ($opts{$_}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | push @script_flags, '--info', $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | $command .= ' '.quote_cmdline( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | ($opts{quiet} ? '-Q' : '-q'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | '-I', File::Spec->catfile($extension_dir,qw(contrib pmltq pmltq.ntred)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | '-o', '--apply-filters', @script_flags, '--', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | ($opts{filelist} ? ('-l', $opts{filelist}) : @args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($opts{server}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $cwd = quote_cmdline(getcwd()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | system('ssh', $opts{server}, <<"SCRIPT"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | if [ -f ~/.bash_profile ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | . ~/.bash_profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | elif [ -f ~/.profile ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | . ~/.profile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | cd $cwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | $command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | SCRIPT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | print STDERR "$command\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | system($command); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | unlink $filter_file if -f $filter_file and !$opts{'keep-tmp-files'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $filter_file and not $opts{"keep-tmp-files"}
MC/DC0%0/2
-f $filter_file and not $opts{"keep-tmp-files"}
-f $filter_file
not $opts{"keep-tmp-files"}
Truth table0%0/3
A and not(B)
A= -f $filter_fileB= not $opts{"keep-tmp-files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | sub round { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my ($value, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my $rounding = ($value >= 0 ? 0.5 : -0.5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $decimalscale = 10**int($precision || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$precision || 0
MC/DC0%0/1
$precision || 0
$precision
Truth table0%0/2
A
A= $precision
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $scaledvalue = int($value * $decimalscale + $rounding); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return $scaledvalue / $decimalscale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub trunc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trunc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my ($self, $num, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $digits = int $digits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $decimalscale = 10**abs($digits); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if ($digits >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | return int($num * $decimalscale) / $decimalscale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | return int($num / $decimalscale) * $decimalscale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | sub apply_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_filter: not called CC=15 SCAR=53.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my ($input, $filter_file)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $filters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | my $filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | use POSIX qw(ceil floor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | if ($opts{'no-filters'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | print while (<$input>); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | my $output_filter = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | init => sub { }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | process_row => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my ($self,$row)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | print(join("\t",@$row)."\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | finish => sub { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | while (<$input>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | unless ($filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if (-f $filter_file and -s $filter_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $filter_file and -s $filter_file
MC/DC0%0/2
-f $filter_file and -s $filter_file
-f $filter_file
-s $filter_file
Truth table0%0/3
A and B
A= -f $filter_fileB= -s $filter_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | open my $fh, "<", $filter_file or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | die "Cannot open $filter_file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $filter_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $filter_code = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | eval "use utf8;\n".$filter_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | print STDERR $filter_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | die "Running filter $filter_file failed!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | my @filters = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my @local_filters = map eval, @{$_->{local_filters_code}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $sub = eval($_->{code}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $sub | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } @$filters; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # connect filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | for my $filter (@filters) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | $prev->{output}=$filter if $prev; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $prev = $filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | if ($prev) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $prev->{output} = $output_filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | $filter = $filters[0] || die "First filter is empty!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$filters[0] || die('First filter is empty!')
MC/DC0%0/1
$filters[0] || die('First filter is empty!')
$filters[0]
Truth table0%0/2
A
A= $filters[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $filter->{init}->($filter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $filter = $output_filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $filter->{process_row}->($filter,[split /\t/,$_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | $filter->{finish}->($filter) if $filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | pmltq query [--server <URL_or_server_ID> ] [ <options> ] [ --stdin | --query-file <filename> | --query <query> | <query> ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | pmltq query --btred [ <options> ] [ --stdin | --query-file <filename> | --query <query> ] [ -l <filelist> | <file(s)> ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | pmltq query --ntred [ <options> ] [ --stdin | --query-file <filename> | --query <query> ] [ -l <filelist> | <file(s)> ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | pmltq query --jtred [ <options> ] [ --stdin | --query-file <filename> | --query <query> ] [ -l <filelist> | <file(s)> ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | pmltq query [options] [ --print-servers|-P | --node-types | --relations ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | Run the query. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | =over 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | =item B<--sql|-S> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | Use SQL-based query engine (default). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | =item B<--btred|-B> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | Query given files or filelist using btred. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | =item B<--ntred|-N> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | Query given files or filelist using ntred (ntred servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | must be already up and running). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | =item B<--jtred|-J> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | Run query query over given files/filelist using jtred (multiple btred | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | instances distributed over an SGE cluster). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | =item B<--server|-s> URL_or_ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | If used with SQL-based engine, this option can be used to specify a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | URL (http://hostname/APIpath/treebanks/treebankID) to a pmltq http server, or an ID of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | pre-configured SQL or HTTP server (use B<--print-servers> to get a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | list). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | If used with btred or jtred, it can be used to specify a server to run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | btred/jtred on using SSH. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | If used with ntred, it can be used to specify a hostname and port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | (hostname:port) for the ntred hub. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | =item B<--stdin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | Read query from the standard input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | =item B<--query|-Q> string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | Specify PML-TQ query on the command-line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | =item B<--query-file> filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | Read PML-TQ query from a given (utf-8 encoded text) file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | =item B<--query-pml-file> filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | Read PML-TQ query from a given PML file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | =item B<--query-id> ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | Use query with a given ID. If the input is a text file, it can contain more than one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | query. In that case, each query must start with a line of the following form: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # == query: ID == | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | where ID is a unique identifier of the query. This option can be used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | to select a single query from the input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | If the input is a PML file, then the ID is just the id of the query tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | =item B<--filelist|-l> filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | This flag can be used with B<--btred>, B<--ntred>, or B<--jtred> to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | spedify a file containing a list of files to search, each on a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | separate line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | Note that for B<--ntred>, the files must be already loaded on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | B<ntred> servers and this flag simply allows you to specify a subcorpus. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | =item B<--auth-id> URL_or_ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | Use username/password stored in the configuration for a given service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | (spcified by URL or config-file ID) on the serice specified using --server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =item B<--username> username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | Username for a HTTP or SQL PML-TQ service. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | =item B<--password> password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | Password for a HTTP or SQL PML-TQ service. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | =item B<--limit|-L> number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | Only applicable to SQL-based engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | Specify maximum number of results (i.e. rows printed by pmltq). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | =item B<--history|-H> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | Sets whether should be query logged to users query history on server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | =item B<--timeout|-t> seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | Only applicable to SQL-based engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | Specify a timeout for the query. If the query evaluation takes longer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | than a given number of B<seconds>, pmltq terminates the connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | with the server and returns with a message "Evaluation of query timed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | out" and exit code 2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | =item B<--config-file|-c> filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | Specify a configuration file. The configuration file is a XML file (in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | fact, a PML instance conforming to the treebase_conf_schema.xml) that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | lists available SQL engine configurations. If this option is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | provided, B<pmltq> attempts to find a file named treebase.conf in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | resource paths (namely in ~/.tred.d). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | =item B<--node-types> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | List available node types and exit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | =item B<--netgraph-query|-N> type_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | Assume the query is in NetGraph syntax and translate it to PMLTQ, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | using a given node type as the default type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | =item B<--debug|-D> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | Print some extended information (e.g. evaluation benchmarks). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||