<commit_before>import re
from sfa.util.xrn import Xrn
from sfa.util.config import Config

def hrn_to_os_slicename(hrn):
    return OSXrn(xrn=hrn, type='slice').get_slicename()

def cleanup_name(name):
    return name.replace(".", "_").replace("+", "_")                

class OSXrn(Xrn):

    def __init__(self, name=None, auth=None, **kwds):
        
        config = Config()
        if name is not None:
            if 'type' in kwds:
                self.type = kwds['type']
            if auth is not None:
                self.hrn='.'.join([auth, cleanup_name(name)]) 
            else:
                self.hrn = config.SFA_INTERFACE_HRN + "." + cleanup_name(name)
            self.hrn_to_urn()
        else:
            Xrn.__init__(self, **kwds)   
         
        self.name = self.get_name() 
    
    def get_name(self):
        self._normalize()
        leaf = self.leaf
        sliver_id_parts = leaf.split(':')
        name = sliver_id_parts[0]
        name = re.sub('[^a-zA-Z0-9_]', '', name)
        return name


    def get_slicename(self):
        self._normalize()
        slicename = self.hrn
        slicename = slicename.split(':')[0]
        slicename = re.sub('[\.]', '_', slicename)
        return slicename
        
            <commit_msg>added hrn_to_os_tenant_name()<commit_after>import re
from sfa.util.xrn import Xrn
from sfa.util.config import Config

def hrn_to_os_slicename(hrn):
    return OSXrn(xrn=hrn, type='slice').get_slicename()


def hrn_to_os_tenant_name(hrn):
    return OSXrn(xrn=hrn, type='slice').get_tenant_name()

def cleanup_name(name):
    return name.replace(".", "_").replace("+", "_")                

class OSXrn(Xrn):

    def __init__(self, name=None, auth=None, **kwds):
        
        config = Config()
        if name is not None:
            if 'type' in kwds:
                self.type = kwds['type']
            if auth is not None:
                self.hrn='.'.join([auth, cleanup_name(name)]) 
            else:
                self.hrn = config.SFA_INTERFACE_HRN + "." + cleanup_name(name)
            self.hrn_to_urn()
        else:
            Xrn.__init__(self, **kwds)   
         
        self.name = self.get_name() 
    
    def get_name(self):
        self._normalize()
        leaf = self.leaf
        sliver_id_parts = leaf.split(':')
        name = sliver_id_parts[0]
        name = re.sub('[^a-zA-Z0-9_]', '', name)
        return name


    def get_slicename(self):
        self._normalize()
        slicename = self.hrn
        slicename = slicename.split(':')[0]
        slicename = re.sub('[\.]', '_', slicename)
        return slicename

    def get_tenant_name(self):
        self._normalize()
        tenant_name = self.hrn
        tenant_name = ".".join(tenant_name.split('.')[1:])
        return tenant_name
        
        
            
{'fraction_non_alphanumeric': 0.1353356890459364, 'fraction_numerical': 0.0031802120141342758, 'mean_word_length': 1.8858307849133538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5593679', 'n_tokens_mistral': 962, 'n_tokens_neox': 949, 'n_words': 181}