<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def output_format_lock(self, packages, **kwargs):
 """ Text to lock file """

        self._output_config['type'] = PLAIN
        text = ''
        tmp_packages = OrderedDict()
        columns = self._config.get_columns()
        widths = {}
        for _pkg in packages.values():
            _pkg_name = _pkg.package_name
            _params = _pkg.get_params(columns, merged=True, raw=False)
            if _pkg_name not in tmp_packages:
                tmp_packages[_pkg_name] = _params
                comment = 1
                for _col in columns:
                    widths[_col] = max(widths.get(_col, len(_col)), len(str(_params.get(_col, '')))) + comment
                    comment = 0
        comment = 1
        for _col in columns:
            text += '{}{} '.format(_col, ' ' * (widths[_col] - len(_col) - comment))
            comment = 0
        text = '#{}\n'.format(text.strip())
        for _pkg_name in sorted(tmp_packages, key=lambda x: str(x).lower()):
            _pkg = tmp_packages[_pkg_name]
            line = ''
            for _col in columns:
                line += '{}{} '.format(_pkg[_col], ' ' * (widths[_col] - len(str(_pkg[_col]))))
            text += '{}\n'.format(line.strip())
        return text