Exemple #1
0
    def take_action(self, parsed_args):
        api = memsource_cli.AnalysisApi(self.app.client)
        args = {}

        for k, v in vars(parsed_args).items():
            if v is not None:
                args[k] = v

        _job_ids = []
        for i in parsed_args.jobs:
            _job_ids.append({'uid': i})
        args['jobs'] = _job_ids

        response = api.create_analyse_async(
            token=self.app.client.configuration.token, body=args)

        column_headers = [
            'analyse', 'id', 'created_by', 'date_created', 'action',
            'async_response', 'parent', 'project'
        ]
        data = []

        output = response.to_dict()
        data += [(json.dumps(output['analyse']))]

        content = output['async_request']
        for k, v in content.items():
            if isinstance(v, datetime.datetime):
                v = json.dumps(v, default=str).replace('"', '')
            if isinstance(v, dict):
                v = json.dumps(v)
            data += [(v)]

        return ((column_headers), (data))
Exemple #2
0
    def take_action(self, parsed_args):
        api = memsource_cli.AnalysisApi(self.app.client)
        args = {}

        for k, v in vars(parsed_args).items():
            if v is not None:
                args[k] = v

        _job_ids = []
        for i in parsed_args.jobs:
            _job_ids.append({'uid': i})
        args['jobs'] = _job_ids

        response = api.create_analyses_for_langs(
            token=self.app.client.configuration.token, body=args)

        output = response.to_dict()

        return (('id', 'analyse_id', 'action', 'date_created', 'project_uid',
                 'project_name', 'created_by'),
                ((output['analyses'][i]['async_request']['id'],
                  output['analyses'][i]['analyse']['id'],
                  output['analyses'][i]['async_request']['action'],
                  json.dumps(
                      output['analyses'][i]['async_request']['date_created'],
                      default=str).replace('"', ''),
                  output['analyses'][i]['async_request']['project']['uid'],
                  output['analyses'][i]['async_request']['project']['name'],
                  json.dumps(
                      output['analyses'][i]['async_request']['created_by']))
                 for i in range(0, len(output['analyses']))))
    def take_action(self, parsed_args):
        api = memsource_cli.AnalysisApi(self.app.client)

        response = api.list_by_project_v2(token=self.app.client.configuration.token,
                                          project_uid=parsed_args.project_uid,
                                          page_size=parsed_args.page_size,
                                          page_number=parsed_args.page_number)

        response = response.to_dict()
        return(('id',
                'name',
                'jobs',
                'provider',
                'type',
                'date_created',
                'source_lang',
                'target_lang'
                ), (
            (response['content'][i]['id'],
             response['content'][i]['name'],
             json.dumps(response['content'][i]['analyse_language_parts']
                        [j]['jobs']),
             response['content'][i]['provider'],
             response['content'][i]['type'],
             json.dumps(response['content'][i]['date_created'],
                        default=str).replace('"', ''),
             response['content'][i]['analyse_language_parts']
             [j]['source_lang'],
             response['content'][i]['analyse_language_parts']
             [j]['target_lang']
             )
            for i in range(0, len(response['content']))
            for j in range(0, len(response['content'][i]
                                  ['analyse_language_parts'])))
        )
    def take_action(self, parsed_args):
        api = memsource_cli.AnalysisApi(self.app.client)
        response = api.get_analyse_v2(
            token=self.app.client.configuration.token,
            analyse_id=parsed_args.analyse_id)
        column_headers = [
            'jobs', 'netrate', 'all', 'source_lang', 'target_lang'
        ]
        data = []
        output = response.to_dict()
        content = output['analyse_language_parts']

        for j in range(0, len(content)):
            if content[j]['discounted_data'] is not None:
                discounted_data = content[j]['discounted_data']['all']['words']
            else:
                discounted_data = None
            data += [(content[j]['jobs'], discounted_data,
                      content[j]['data']['all']['words'],
                      content[j]['source_lang'], content[j]['target_lang'])]

        return ((column_headers), (data))
Exemple #5
0
 def take_action(self, parsed_args):
     api = memsource_cli.AnalysisApi(self.app.client)
     api.delete(token=self.app.client.configuration.token,
                analyse_id=parsed_args.analyse_id,
                purge=parsed_args.purge)