<commit_before># -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from __future__ import division

from tornado.web import authenticated


from qiita_pet.handlers.util import to_int
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_pet.handlers.api_proxy import (
    artifact_graph_get_req, artifact_types_get_req, artifact_post_req,
    artifact_status_put_req, artifact_get_req, artifact_get_prep_req,
    artifact_get_info)
from qiita_core.util import execute_as_transaction
from qiita_core.qiita_settings import qiita_config


class ArtifactGraphAJAX(BaseHandler):
    @authenticated
    def get(self):
        direction = self.get_argument('direction')
        artifact = to_int(self.get_argument('artifact_id'))
        self.write(artifact_graph_get_req(artifact, direction,
                                          self.current_user.id))


class NewArtifactHandler(BaseHandler):
    @authenticated
    def get(self):
        study_id = self.get_argument("study_id")
        prep_id = self.get_argument("prep_template_id")
        artifact_types = [(at, desc) for at, desc, _, _, is_user_uploadable in
                          artifact_types_get_req()['types']
                          if is_user_uploadable]

        self.render("study_ajax/add_artifact.html",
                    study_id=study_id, prep_id=prep_id,
                    artifact_types=artifact_types)

    @authenticated
    @execute_as_transaction
    def post(self):
        artifact_type = self.get_argument('artifact-type')
        name = self.get_argument('name')
        prep_id = self.get_argument('prep-template-id')
        artifact_id = self.get_argument('import-artifact')

        # Request the rest of the arguments, which will be the files
        files = {arg: self.get_argument(arg) for arg in self.request.arguments
                 if arg not in ['name', 'prep-template-id', 'artifact-type',
                                'import-artifact']}
<commit_msg>fix add new artifact []<commit_after># -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from __future__ import division

from tornado.web import authenticated


from qiita_pet.handlers.util import to_int
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_pet.handlers.api_proxy import (
    artifact_graph_get_req, artifact_types_get_req, artifact_post_req,
    artifact_status_put_req, artifact_get_req, artifact_get_prep_req,
    artifact_get_info)
from qiita_core.util import execute_as_transaction
from qiita_core.qiita_settings import qiita_config


class ArtifactGraphAJAX(BaseHandler):
    @authenticated
    def get(self):
        direction = self.get_argument('direction')
        artifact = to_int(self.get_argument('artifact_id'))
        self.write(artifact_graph_get_req(artifact, direction,
                                          self.current_user.id))


class NewArtifactHandler(BaseHandler):
    @authenticated
    def get(self):
        study_id = self.get_argument("study_id")
        prep_id = self.get_argument("prep_template_id")
        artifact_types = [(at, desc) for at, desc, _, _, is_user_uploadable in
                          artifact_types_get_req()['types']
                          if is_user_uploadable]

        self.render("study_ajax/add_artifact.html",
                    study_id=study_id, prep_id=prep_id,
                    artifact_types=artifact_types)

    @authenticated
    @execute_as_transaction
    def post(self):
        artifact_type = self.get_argument('artifact-type')
        name = self.get_argument('name')
        prep_id = self.get_argument('prep-template-id')
        artifact_id = self.get_argument('import-artifact')

        # Request the rest of the arguments, which will be the files
        files = dict()
        for arg in self.request.arguments:
            if arg not in ['name', 'prep-template-id', 'artifact-type',
                           'import-artifact']:
                arg_name = arg
                # removing ending [], in case they exists, necessary for JS
                # array transformation
                if arg_name.endswith('[]'):
                    arg_name = arg_name[:-2]
                files[arg] = self.get_argument(arg)

{'fraction_non_alphanumeric': 0.14256026600166252, 'fraction_numerical': 0.00228595178719867, 'mean_word_length': 2.189529489728297, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6531646', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1268, 'n_words': 296}