<commit_before>	#!/usr/bin/perl
package perunServicesInit;

use Exporter 'import';
@EXPORT_OK = qw(init);
@EXPORT= qw(getDirectory getDestinationDirectory getHierarchicalData getDataWithGroups);

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Perun::Agent;
use File::Path;
use File::Temp qw/ tempdir /;
use File::Temp qw/ :mktemp  /;
use File::Copy;
use Data::Dumper;
use IO::Compress::Gzip qw(gzip $GzipError) ;

#die at the very end of skript when any warning occured during executing
our $DIE_AT_END=0;
$SIG{__WARN__} = sub { $DIE_AT_END=1; warn @_; };
END { if($DIE_AT_END) { die "Died because of warning(s) occured during procesing.\n"; } };

my ($agent, $service, $facility, $servicesAgent, $directory, $tmp_directory, $tmp_directory_destination, $getData_directory);

# Prepare direactory for file which will be generated
# Create VERSION file in this directory. This file contains protocol version
# 
# This method REQUIRE acess to $::SERVICE_NAME and $::PROTOCOL_VERSION
# this can be achieved by folowing lines in your main script: (for example)
#     local $::SERVICE_NAME = "passwd";
#     local $::PROTOCOL_VERSION = "3.0.0";
sub init {

	unless(defined $::SERVICE_NAME) { die; }
	unless(defined $::PROTOCOL_VERSION) {die;}
	
	my $facilityId;
	GetOptions ("facilityId|f=i" => \$facilityId) || die;

	unless(defined $facilityId) { die "ERROR: facilityId required"; }

	$agent = Perun::Agent->new();
	$servicesAgent = $agent->getServicesAgent;
	my $facilitiesAgent = $agent->getFacilitiesAgent;
	$service = $servicesAgent->getServiceByName( name => $::SERVICE_NAME);
	$facility = $facilitiesAgent->getFacilityById( id => $facilityId);

	$directory = "spool/" . $facility->getName . "-" . $facility->getType . "/" . $service->getName."/";
	$tmp_directory = "spool/tmp/" . $facility->getName . "-" . $facility->getType . "/" . $service->getName."/";
	$tmp_directory_destination = $tmp_directory . "/_destination/";
	$getData_directory = "spool/tmp/getData/" . $facility->getName . "-" . $facility->getType . "/" . $service->getName."/";

	my $err;
	rmtree($tmp_directory,  { error => \$err } );
	if(@$err) { die "Can't rmtree( $tmp_directory  )" };
	mkpath($tmp_directory, { error => \$err } );
	if(@$err) { die "Can't mkpath( $tmp_directory  )" };
	mkpath($tmp_directory_destination, { error => \$err } );
	if(@$err) { die "Can't mkpath( $tmp_directory_destination  )" };
	createVersionFile();
	createServicesFile();
	createFacilityNameFile($facility->getName . "-" . $facility->getType);

	rmtree($getData_directory);
	if(@$err) { die "Can't rmtree( $getData_directory  )" };
	mkpath($getData_directory);
	if(@$err) { die "Can't mkpath( $getData_directory  )" };
}

sub finalize {
	unless($DIE_AT_END) {
		my $err;
		rmtree($directory, { error => \$err } );
		if(@$err) { die "Can't rmtree( $directory  )" };
<commit_msg>Get rid of facility type from perunServicesInit<commit_after>	#!/usr/bin/perl
package perunServicesInit;

use Exporter 'import';
@EXPORT_OK = qw(init);
@EXPORT= qw(getDirectory getDestinationDirectory getHierarchicalData getDataWithGroups);

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Perun::Agent;
use File::Path;
use File::Temp qw/ tempdir /;
use File::Temp qw/ :mktemp  /;
use File::Copy;
use Data::Dumper;
use IO::Compress::Gzip qw(gzip $GzipError) ;

#die at the very end of skript when any warning occured during executing
our $DIE_AT_END=0;
$SIG{__WARN__} = sub { $DIE_AT_END=1; warn @_; };
END { if($DIE_AT_END) { die "Died because of warning(s) occured during procesing.\n"; } };

my ($agent, $service, $facility, $servicesAgent, $directory, $tmp_directory, $tmp_directory_destination, $getData_directory);

# Prepare direactory for file which will be generated
# Create VERSION file in this directory. This file contains protocol version
# 
# This method REQUIRE acess to $::SERVICE_NAME and $::PROTOCOL_VERSION
# this can be achieved by folowing lines in your main script: (for example)
#     local $::SERVICE_NAME = "passwd";
#     local $::PROTOCOL_VERSION = "3.0.0";
sub init {

	unless(defined $::SERVICE_NAME) { die; }
	unless(defined $::PROTOCOL_VERSION) {die;}
	
	my $facilityId;
	GetOptions ("facilityId|f=i" => \$facilityId) || die;

	unless(defined $facilityId) { die "ERROR: facilityId required"; }

	$agent = Perun::Agent->new();
	$servicesAgent = $agent->getServicesAgent;
	my $facilitiesAgent = $agent->getFacilitiesAgent;
	$service = $servicesAgent->getServiceByName( name => $::SERVICE_NAME);
	$facility = $facilitiesAgent->getFacilityById( id => $facilityId);

	$directory = "spool/" . $facility->getName . "/" . $service->getName."/";
	$tmp_directory = "spool/tmp/" . $facility->getName . "/" . $service->getName."/";
	$tmp_directory_destination = $tmp_directory . "/_destination/";
	$getData_directory = "spool/tmp/getData/" . $facility->getName . "/" . $service->getName."/";

	my $err;
	rmtree($tmp_directory,  { error => \$err } );
	if(@$err) { die "Can't rmtree( $tmp_directory  )" };
	mkpath($tmp_directory, { error => \$err } );
	if(@$err) { die "Can't mkpath( $tmp_directory  )" };
	mkpath($tmp_directory_destination, { error => \$err } );
	if(@$err) { die "Can't mkpath( $tmp_directory_destination  )" };
	createVersionFile();
	createServicesFile();
	createFacilityNameFile($facility->getName);

	rmtree($getData_directory);
	if(@$err) { die "Can't rmtree( $getData_directory  )" };
	mkpath($getData_directory);
	if(@$err) { die "Can't mkpath( $getData_directory  )" };
}

sub finalize {
	unless($DIE_AT_END) {
		my $err;
		rmtree($directory, { error => \$err } );
		if(@$err) { die "Can't rmtree( $directory  )" };

{'fraction_non_alphanumeric': 0.16826071555083244, 'fraction_numerical': 0.001771165426850868, 'mean_word_length': 5.131378935939196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3505626', 'n_tokens_mistral': 2010, 'n_tokens_neox': 1969, 'n_words': 470}