<commit_before>package util

import (
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"github.com/APTrust/exchange/constants"
	"path"
	"regexp"
	"strings"
)

var reManifest *regexp.Regexp = regexp.MustCompile("^manifest-[A-Za-z0-9]+\\.txt$")
var reTagManifest *regexp.Regexp = regexp.MustCompile("^tagmanifest-[A-Za-z0-9]+\\.txt$")
var reLegal *regexp.Regexp = regexp.MustCompile("^[A-Za-z0-9\\-_\\.]+$")

// OwnerOf returns the domain name of the institution that owns the
// specified bucket. For example, if bucketName is 'aptrust.receiving.unc.edu'
// the return value will be 'unc.edu'.
func OwnerOf(bucketName string) (institution string) {
	if strings.HasPrefix(bucketName, constants.ReceiveTestBucketPrefix) {
		institution = strings.Replace(bucketName, constants.ReceiveTestBucketPrefix, "", 1)
	} else if strings.HasPrefix(bucketName, constants.ReceiveBucketPrefix) {
		institution = strings.Replace(bucketName, constants.ReceiveBucketPrefix, "", 1)
	} else if strings.HasPrefix(bucketName, constants.RestoreBucketPrefix) {
		institution = strings.Replace(bucketName, constants.RestoreBucketPrefix, "", 1)
	} else if bucketName == "aptrust.test.receiving" || bucketName == "aptrust.integration.test" {
		// Special case for integration tests
		institution = "test.edu"
	}
	return institution
}

// RestorationBucketFor returns the name of the specified institution's
// restoration bucket. E.g. institution 'unc.edu' returns bucketName
// 'aptrust.restore.unc.edu'. The second param, restoreToTestBuckets,
// is set the in the config json file and accessible through
// Config.RestoreToTestBuckets. It should be true everywhere
// except in the production environment. If true, this will return
// 'aptrust.restore.test.unc.edu'.
func RestorationBucketFor(institution string, restoreToTestBuckets bool) (bucketName string) {<commit_msg>Fixed https://trello.com/c/1IoROBMT: Ingest test.edu bags into production<commit_after>package util

import (
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"github.com/APTrust/exchange/constants"
	"path"
	"regexp"
	"strings"
)

var reManifest *regexp.Regexp = regexp.MustCompile("^manifest-[A-Za-z0-9]+\\.txt$")
var reTagManifest *regexp.Regexp = regexp.MustCompile("^tagmanifest-[A-Za-z0-9]+\\.txt$")
var reLegal *regexp.Regexp = regexp.MustCompile("^[A-Za-z0-9\\-_\\.]+$")

// OwnerOf returns the domain name of the institution that owns the
// specified bucket. For example, if bucketName is 'aptrust.receiving.unc.edu'
// the return value will be 'unc.edu'.
func OwnerOf(bucketName string) (institution string) {
	if bucketName == constants.ReceiveTestBucketPrefix {
		// Actual test.edu receiving bucket for production.
		// Didn't anticipate this case back in 2014. Oops.
		institution = "test.edu"
	} else if strings.HasPrefix(bucketName, constants.ReceiveTestBucketPrefix) {
		institution = strings.Replace(bucketName, constants.ReceiveTestBucketPrefix, "", 1)
	} else if strings.HasPrefix(bucketName, constants.ReceiveBucketPrefix) {
		institution = strings.Replace(bucketName, constants.ReceiveBucketPrefix, "", 1)
	} else if strings.HasPrefix(bucketName, constants.RestoreBucketPrefix) {
		institution = strings.Replace(bucketName, constants.RestoreBucketPrefix, "", 1)
	} else if bucketName == "aptrust.test.receiving" || bucketName == "aptrust.integration.test" {
		// Special case for integration tests
		institution = "test.edu"
	}
	return institution
}

// RestorationBucketFor returns the name of the specified institution's
// restoration bucket. E.g. institution 'unc.edu' returns bucketName
// 'aptrust.restore.unc.edu'. The second param, restoreToTestBuckets,
// is set the in the config json file and accessible through
// Config.RestoreToTestBuckets. It should be true everywhere
// except in the production environment. If true, this will return
// 'aptrust.restore.test.unc.edu'.
func RestorationBucketFor(institution string, restoreToTestBuckets bool) (bucketName string) {
{'fraction_non_alphanumeric': 0.12293624587249175, 'fraction_numerical': 0.006858013716027432, 'mean_word_length': 4.930722891566265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '5746547', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1188, 'n_words': 316}