<commit_before>#!/usr/bin/perl
###############################################################################
# Copyright (c) 2000-2016 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#   <NAME>
#   <NAME>
#
###############################################################################
###############################################################################
# This script is intended to archive the project hierarchy from a TPD file structure
###############################################################################
use 5.010;
use strict;
use warnings;
use Cwd;
use File::Copy;

my $ttcn3_dir = $ENV{'TTCN3_DIR'};
my $bindir = $ttcn3_dir . "/bin"; 
my $home = cwd();
my @list = readFile();
my $tpd = getTPDFileName(\@list);
chomp ($tpd);
if (-l $tpd)  #get the path if it is a symlink
{
  $tpd = `readlink $tpd`;
  chomp ($tpd);
}
my $root = getPathToRootDir(\@list); # get the workspace directory of the OS
chomp ($root);
chdir ($root) or die "cannot change: $!\n";
my $cutstring = cwd; # this is string generated from the the absolut path to the workspace
my $archiveDir = getArchiveDir(\@list); #directory to place the archive
$archiveDir = $home . "/" .  $archiveDir;
chomp ($archiveDir);
my $createDir = "mkdir -p " .  $archiveDir;
my $res = system($createDir);
my $backupFileName = createBackupFileName();
my $backupfile = $archiveDir . "/" . $backupFileName;
if ($res != 0) { die (" creating directory " . $archiveDir ." failed\n"); }
my $archive = $bindir . "/" . "ttcn3_makefilegen" ." -V -P " . $cutstring .  " -t " .  $tpd . " | xargs tar cfz ". $archiveDir . "/" .  $backupFileName . " 2> /dev/null";
system($archive);  #running it
if (-e $backupfile) { print ("archiving succeeded\n"); }
else                { print ("archiving failed\n"); }
chdir ($home) or die "cannot change: $!\n";
############################################################
sub readFile
{
  my $makefile = "Makefile";
  open ( FILE,  "<", $makefile ) or die ( "failed to open file: $home\/$makefile\n" );
  my @lines = <FILE>;
  close FILE;
  return  @lines;   
}
############################################################
sub getPathToRootDir #get the relative path to OS workspace 
{
  my @list = @{$_[0]};
  my $search = qr/^ROOT_DIR =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $dot = '.';
             $offset = index($list[$i], $dot);
             last;
          }
    }
  if ($offset  == 0) { die ( "no ROOT_DIR variable was found in the Makefile\n" ); }
  my $path = substr $line,  $offset;
  return $path;
}
############################################################
sub getTPDFileName # TPD filename what the Makefile is created from
{
  my @list = @{$_[0]};
  my $search = qr/^TPD =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no TPD variable was found in the Makefile\n" ); }
  my $file = substr $line,  $offset + 1;
  $file =~ s/^\s+|\s+$//;  # remove heading and traling whitespaces 
  return $file;
}
############################################################
sub getArchiveDir # the name of the archive directory
{
  my @list = @{$_[0]};
  my $search = qr/^ARCHIVE_DIR =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no ARCHIVE_DIR variable was found in the Makefile\n" ); }
  my $dir = substr $line,  $offset + 1;
  $dir =~ s/^\s+|\s+$//;  # remove heading and trailing whitespaces 
  return $dir;
}
############################################################
sub getExecutableName # the name of the target executable
{
  my @list = @{$_[0]};
  my $search = qr/^EXECUTABLE =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no EXCUTABLE variable was found in the Makefile\n" ); }
  my $exec = substr $line,  $offset + 1;
  $exec =~ s/^\s+|\s+$//;  # remove heading and trailing whitespaces 
  return $exec;
}
############################################################
sub createBackupFileName
{
  my $backupFile = getExecutableName(\@list);
  my $dot = '.';
  my $result = index($backupFile, $dot);
  if ($result > -1)
  {
     $backupFile = substr $backupFile,  0, $result;
  }
  chomp ($backupFile);
  my $date =  `date '+%y%m%d-%H%M'`;
  chomp ($date);
  my $baseName = $backupFile . "-" . $date . ".tgz";
  chomp ($baseName);
  return $baseName;
}
<commit_msg>Corrected typo in ttcn3_archive.pl<commit_after>#!/usr/bin/perl
###############################################################################
# Copyright (c) 2000-2016 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#   <NAME>
#   <NAME>
#
###############################################################################
###############################################################################
# This script is intended to archive the project hierarchy from a TPD file structure
###############################################################################
use 5.010;
use strict;
use warnings;
use Cwd;
use File::Copy;

my $ttcn3_dir = $ENV{'TTCN3_DIR'};
my $bindir = $ttcn3_dir . "/bin"; 
my $home = cwd();
my @list = readFile();
my $tpd = getTPDFileName(\@list);
chomp ($tpd);
if (-l $tpd)  #get the path if it is a symlink
{
  $tpd = `readlink $tpd`;
  chomp ($tpd);
}
my $root = getPathToRootDir(\@list); # get the workspace directory of the OS
chomp ($root);
chdir ($root) or die "cannot change: $!\n";
my $cutstring = cwd; # this is string generated from the the absolute path to the workspace
my $archiveDir = getArchiveDir(\@list); #directory to place the archive
$archiveDir = $home . "/" .  $archiveDir;
chomp ($archiveDir);
my $createDir = "mkdir -p " .  $archiveDir;
my $res = system($createDir);
my $backupFileName = createBackupFileName();
my $backupfile = $archiveDir . "/" . $backupFileName;
if ($res != 0) { die (" creating directory " . $archiveDir ." failed\n"); }
my $archive = $bindir . "/" . "ttcn3_makefilegen" ." -V -P " . $cutstring .  " -t " .  $tpd . " | xargs tar cfz ". $archiveDir . "/" .  $backupFileName . " 2> /dev/null";
system($archive);  #running it
if (-e $backupfile) { print ("archiving succeeded\n"); }
else                { print ("archiving failed\n"); }
chdir ($home) or die "cannot change: $!\n";
############################################################
sub readFile
{
  my $makefile = "Makefile";
  open ( FILE,  "<", $makefile ) or die ( "failed to open file: $home\/$makefile\n" );
  my @lines = <FILE>;
  close FILE;
  return  @lines;   
}
############################################################
sub getPathToRootDir #get the relative path to OS workspace 
{
  my @list = @{$_[0]};
  my $search = qr/^ROOT_DIR =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $dot = '.';
             $offset = index($list[$i], $dot);
             last;
          }
    }
  if ($offset  == 0) { die ( "no ROOT_DIR variable was found in the Makefile\n" ); }
  my $path = substr $line,  $offset;
  return $path;
}
############################################################
sub getTPDFileName # TPD filename what the Makefile is created from
{
  my @list = @{$_[0]};
  my $search = qr/^TPD =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no TPD variable was found in the Makefile\n" ); }
  my $file = substr $line,  $offset + 1;
  $file =~ s/^\s+|\s+$//;  # remove heading and traling whitespaces 
  return $file;
}
############################################################
sub getArchiveDir # the name of the archive directory
{
  my @list = @{$_[0]};
  my $search = qr/^ARCHIVE_DIR =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no ARCHIVE_DIR variable was found in the Makefile\n" ); }
  my $dir = substr $line,  $offset + 1;
  $dir =~ s/^\s+|\s+$//;  # remove heading and trailing whitespaces 
  return $dir;
}
############################################################
sub getExecutableName # the name of the target executable
{
  my @list = @{$_[0]};
  my $search = qr/^EXECUTABLE =/s;
  my $offset = 0;
  my $line;
  for  my $i ( 0 .. $#list )
    {
        if ( $list[$i] =~ $search ) 
          {
             $line = $list[$i];
             my $assign = '=';
             $offset = index($list[$i], $assign);
             last;
          }
    }
  if ($offset  == 0) { die ( "no EXCUTABLE variable was found in the Makefile\n" ); }
  my $exec = substr $line,  $offset + 1;
  $exec =~ s/^\s+|\s+$//;  # remove heading and trailing whitespaces 
  return $exec;
}
############################################################
sub createBackupFileName
{
  my $backupFile = getExecutableName(\@list);
  my $dot = '.';
  my $result = index($backupFile, $dot);
  if ($result > -1)
  {
     $backupFile = substr $backupFile,  0, $result;
  }
  chomp ($backupFile);
  my $date =  `date '+%y%m%d-%H%M'`;
  chomp ($date);
  my $baseName = $backupFile . "-" . $date . ".tgz";
  chomp ($baseName);
  return $baseName;
}

{'fraction_non_alphanumeric': 0.27682605421686746, 'fraction_numerical': 0.008189006024096385, 'mean_word_length': 2.925009235315848, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5296842', 'n_tokens_mistral': 3538, 'n_tokens_neox': 3416, 'n_words': 1025}