<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reader(self, fp, encoding):
 """ Simple `open` wrapper for several file types. This supports ``.gz`` and ``.json``. :param fp: opened file :type fp: file pointer :param encoding: encoding of opened file :type encoding: string :rtype: file pointer """

        _, suffix = os.path.splitext(fp.name)
        if suffix == '.gz':
            fp.close()
            return gzip.open(fp.name)
        elif suffix == '.json':
            return json.load(fp)
        elif suffix == '.csv' or self.delimiter:
            return csvreader(fp, encoding, delimiter=self.delimiter or ',')
        elif suffix == '.tsv':
            return csvreader(fp, encoding, delimiter='\t')
        return fp