<commit_before>from mint.django_rest.rbuilder.manager.basemanager import exposed
from mint.django_rest.rbuilder.packageworkspaces import models

class BaseManager(object):
    def __init__(self, mgr):
        # mgr is a weakref to avoid circular references. Access its fields
        # through properties
        self.mgr = mgr

    @property
    def cfg(self):
        return self.mgr.cfg

    @property
    def rest_db(self):
        return self.mgr.rest_db

    @property
    def user(self):
        return self.mgr.user
        

class PackageWorkspaceManager(BaseManager):
    """docstring for PackageWorkspaceManager"""
    
    @exposed
    def getPackageWorkspaces(self):
        """docstring for getWorkspace"""
        PackageWorkspaces = models.PackageWorkspaces()
        PackageWorkspaces.package_workspace = list(models.PackageWorkspace.objects.all())
        return PackageWorkspaces
    
    @exposed
    def getPackageWorkspace(self, workspace_id):
        """docstring for PackageWorkspace"""
        package_workspace = models.PackageWorkspace.objects.get(pk=workspace_id)
        return package_workspace
        
    @exposed
    def addPackageWorkspace(self, workspace):
        """docstring for addWorkspace"""
        workspace.save()
        return workspace
        
    @exposed
    def updatePackageWorkspace(self, workspace_id, workspace):
        """docstring for updateWorkspace"""
        if not workspace:
            return
        w = models.PackageWorkspace.objects.get(pk=workspace_id)
        field_names = w.get_field_dict().keys()
        for name in field_names:
            attr = getattr(workspace, name, None)
            if not attr:
                continue
            setattr(w, name, attr)
        w.save()
        return w
    
    # @exposed
    # def updatePackageWorkspace(self, workspace):
    #     """docstring for updateWorkspace"""
    #     if not workspace:
    #         return
    #     workspace.save()
    #     return workspace
    
    @exposed
    def deletePackageWorkspace(self, workspace_id):
        """docstring for deletePackageWorkspace"""
        workspace = models.PackageWorkspace.objects.get(pk=workspace_id)
        workspace.delete()
        
        <commit_msg>trying to fix pepflakes errors<commit_after>from mint.django_rest.rbuilder.manager.basemanager import exposed
from mint.django_rest.rbuilder.packageworkspaces import models

class BaseManager(object):
    def __init__(self, mgr):
        # mgr is a weakref to avoid circular references. Access its fields
        # through properties
        self.mgr = mgr

    @property
    def cfg(self):
        return self.mgr.cfg

    @property
    def rest_db(self):
        return self.mgr.rest_db

    @property
    def user(self):
        return self.mgr.user
        

class PackageWorkspaceManager(BaseManager):
    """docstring for PackageWorkspaceManager"""
    
    @exposed
    def getPackageWorkspaces(self):
        """docstring for getWorkspace"""
        PackageWorkspaces = models.PackageWorkspaces()
        PackageWorkspaces.package_workspace = list(models.PackageWorkspace.objects.all())
        return PackageWorkspaces
    
    @exposed
    def getPackageWorkspace(self, workspace_id):
        """docstring for PackageWorkspace"""
        package_workspace = models.PackageWorkspace.objects.get(pk=workspace_id)
        return package_workspace
        
    @exposed
    def addPackageWorkspace(self, workspace):
        """docstring for addWorkspace"""
        workspace.save()
        return workspace
        
    @exposed
    def updatePackageWorkspace(self, workspace_id, workspace):
        """docstring for updateWorkspace"""
        if not workspace:
            return
        w = models.PackageWorkspace.objects.get(pk=workspace_id)
        field_names = w.get_field_dict().keys()
        for name in field_names:
            attr = getattr(workspace, name, None)
            if not attr:
                continue
            setattr(w, name, attr)
        w.save()
        return w
    
    # @exposed
    # def updatePackageWorkspace(self, workspace):
    #     """docstring for updateWorkspace"""
    #     if not workspace:
    #         return
    #     workspace.save()
    #     return workspace
    
    @exposed
    def deletePackageWorkspace(self, workspace_id):
        """docstring for deletePackageWorkspace"""
        workspace = models.PackageWorkspace.objects.get(pk=workspace_id)
        workspace.delete()
{'fraction_non_alphanumeric': 0.083835005574136, 'fraction_numerical': 0.0, 'mean_word_length': 2.45342571208622, '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': '7483257', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1206, 'n_words': 282}