<commit_before>import inspect
import logging
import os
from os import path
from binstar_client.utils import get_server_api
from binstar_client.errors import BinstarError
from .filer import tempfile_tar
from .filters import filters
from .inspectors import inspectors
from .uploader import ProjectUploader

log = logging.getLogger('binstar.projects.upload')


class CondaProject(object):
    # TODO: This class will be moved into Anaconda-Project
    def __init__(self, project_path, *args, **kwargs):
        self.project_path = project_path
        self._name = None
        self.pfiles = []
        self.metadata = {
            'summary': kwargs.get('summary', None),
            'description': kwargs.get('description', None),
            'version': kwargs.get('version', None)
        }
        self.metadata = dict((k, v) for k, v in self.metadata.iteritems() if v)

    def to_project_creation(self):
        return {
            'name': self.name,
            'access': 'public',
            'profile': {
                'description': self.metadata.get('description', ''),
                'summary': self.metadata.get('summary', ''),
            }
        }

    def to_stage(self):
        return {
            'basename': self.basename
        }

    @property
    def basename(self):
        return "{}.tar".format(self.name)

    @property
    def tar(self):
        return tempfile_tar(self.pfiles)

    @property
    def tar_size(self):
        spos = self.tar.tell()
        self.tar.seek(0, os.SEEK_END)<commit_msg>py3 compatible<commit_after>import inspect
import logging
import os
from os import path
from binstar_client.utils import get_server_api
from binstar_client.errors import BinstarError
from .filer import tempfile_tar
from .filters import filters
from .inspectors import inspectors
from .uploader import ProjectUploader

log = logging.getLogger('binstar.projects.upload')


class CondaProject(object):
    # TODO: This class will be moved into Anaconda-Project
    def __init__(self, project_path, *args, **kwargs):
        self.project_path = project_path
        self._name = None
        self.pfiles = []
        self.metadata = {
            'summary': kwargs.get('summary', None),
            'description': kwargs.get('description', None),
            'version': kwargs.get('version', None)
        }
        self.metadata = dict((k, v) for k, v in self.metadata.items() if v)

    def to_project_creation(self):
        return {
            'name': self.name,
            'access': 'public',
            'profile': {
                'description': self.metadata.get('description', ''),
                'summary': self.metadata.get('summary', ''),
            }
        }

    def to_stage(self):
        return {
            'basename': self.basename
        }

    @property
    def basename(self):
        return "{}.tar".format(self.name)

    @property
    def tar(self):
        return tempfile_tar(self.pfiles)

    @property
    def tar_size(self):
        spos = self.tar.tell()
        self.tar.seek(0, os.SEEK_END)
{'fraction_non_alphanumeric': 0.11507028440666885, 'fraction_numerical': 0.0009807126511932004, 'mean_word_length': 2.3849557522123894, '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': '2353953', 'n_tokens_mistral': 892, 'n_tokens_neox': 886, 'n_words': 220}