

def finalize(self, ctx, shard_state):
    'Finalize writer shard-level state.\n\n    Args:\n      ctx: an instance of context.Context.\n      shard_state: shard state.\n    '
    mapreduce_spec = ctx.mapreduce_spec
    output_sharding = self.__class__._get_output_sharding(mapper_spec=mapreduce_spec.mapper)
    if (output_sharding == self.OUTPUT_SHARDING_INPUT_SHARDS):
        filesystem = output_sharding._get_filesystem(mapreduce_spec.mapper)
        state = self._State.from_json(shard_state.writer_state)
        writable_filename = state.filenames[0]
        files.finalize(writable_filename)
        finalized_filenames = [self._get_finalized_filename(filesystem, state.filenames[0], state.request_filenames[0])]
        state.filenames = finalized_filenames
        state.request_filenames = []
        shard_state.writer_state = state.to_json()
        if (filesystem == 'blobstore'):
            logging.info('Shard %s-%s finalized blobstore file %s.', mapreduce_spec.mapreduce_id, shard_state.shard_number, writable_filename)
            logging.info('Finalized name is %s.', finalized_filenames[0])

dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/mapreduce/output_writers.py FileOutputWriterBase.finalize/VarMisuse@50/129 `self`->`output_sharding`