Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.

        :return: ``CTfile`` formatted string.
        :rtype: :py:class:`str`.
326228
def _to_ctfile(self):
        
        output = io.StringIO()

        for entry in self.values():
            output.write(entry['molfile']._to_ctfile())

            for header, values in entry['data'].items():
                output.write('> <{}>\n'.format(header))
                output.write('\n'.join(values))
                output.write('\n')
            output.write('\n$$$$\n')

        return output.getvalue()
218654
def get_docstr(func_or_class):
    
    import utool as ut
    try:
        docstr_ = func_or_class.func_doc
    except AttributeError:
        docstr_ = func_or_class.__doc__
    if docstr_ is None:
        docstr_ = ''
    docstr = ut.unindent(docstr_)
    return docstr
1088351
def to_str(s, encoding=None, errors='strict'):
    
    encoding = encoding or 'utf-8'

    if is_strlike(s):
        if six.PY2:
            return s.encode(encoding, errors) if isinstance(s, unicode) else s
        else:
            return s.decode(encoding, errors) if isinstance(s, bytes) else s
    else:
        return str(s)
1349867
def convert(self):
        
        if not os.path.exists(os.path.dirname(self.file_generator.to_path)):
            dirname = os.path.dirname(self.file_generator.to_path)
            if dirname:
                os.makedirs(dirname)

        if os.path.isdir(self.file_generator.from_path):
            self._many_to_many()
        elif os.path.isfile(self.file_generator.from_path) or fileio.GenericFilePath.is_url(self.file_generator.from_path):
            if self.file_generator.from_path_compression in ("zip", "tar", "tar.gz", "tar.bz2"):
                self._many_to_many()
            elif self.file_generator.from_path_compression in ("gz", "bz2"):
                self._one_to_one()
            elif not self.file_generator.from_path_compression:
                self._one_to_one()
        elif self.file_generator.from_path.isdigit():
            self._one_to_one()
        else:
            raise TypeError('Unknown input file format: "{}"'.format(self.file_generator.from_path))
628312
def to_string(self, buf=None, format_abs_ref_as='string',
                  upper_triangle=True, header=True, index=True, **kwargs):
        
        out = self._sympy_formatter()
        out = out._abs_ref_formatter(format_as=format_abs_ref_as)
        if not upper_triangle:
            out = out._remove_upper_triangle()

        content = out._frame.to_string(buf=buf, header=header, index=index,
                                       **kwargs)
        if not index and not header:
            # NOTE(the following might be removed in the future
            # introduced because of formatting bug in pandas
            # See https://github.com/pandas-dev/pandas/issues/13032)
            space = ' ' * (out.loc[:, 'atom'].str.len().max()
                           - len(out.iloc[0, 0]))
            content = space + content
        return content
494168
def to_string(self, format_, fps=None, **kwargs):
        
        fp = io.StringIO()
        self.to_file(fp, format_, fps=fps, **kwargs)
        return fp.getvalue()
618430
def to_array(self):
        
        array = super(File, self).to_array()
        array['file_id'] = u(self.file_id)  # py2: type unicode, py3: type str

        if self.file_size is not None:
            array['file_size'] = int(self.file_size)  # type int
        if self.file_path is not None:
            array['file_path'] = u(self.file_path)  # py2: type unicode, py3: type str

        return array
1245527
def reformat_filepath(self, config_file, filename):
        
        if not filename.startswith("/"):
            filename = self.config_file_format.format(config_file, filename)
        return filename
125204
def to_str(data):
    
    if isinstance(data, bytes):
        return codecs.decode(data, TEXT_ENCODING)
    return data
1162396
def _to_textfile(self, file_generator):
        
        to_path = file_generator.to_path \
            if file_generator.to_path.endswith(file_generator.file_extension[file_generator.to_format]) \
            else file_generator.to_path + file_generator.file_extension[file_generator.to_format]

        with open(to_path, mode="w") as outfile:
            for f in file_generator:
                outfile.write(f.writestr(file_generator.to_format))
1271368
def from_file(cls, filename):
        
        with open(filename) as f:
            string = f.read()
        return cls.from_string(string)
587205
def toString(self):
        
        output = ""
        for layer in reverse(self.layers):
            output += layer.toString()
        return output
1112227
def to_file_url(filename):
    
    url = 'file://' + os.path.abspath(filename).replace(os.path.sep, '/')
    return url
1298629
def to_file_mode(self):
        
        for message_no in range(len(self.messages)):
            self.__to_file(message_no)
603834
def _to_string(self):
        """"""
        if self.sections:
            start = "/" if self.bound_start else "**/"
            sections = "/**/".join(str(section) for section in self.sections)
            end = "" if self.bound_end else "/**"
        else:
            start = ""
            sections = ""
            end = "" if self.bound_end else "**"
        return "{0}{1}{2}/{3}".format(start, sections, end, str(self.file_pattern))
1147290
def file_to_str(fname):
    
    data = None
    # rU = read with Universal line terminator
    with open(fname, 'rU') as fd:
        data = fd.read()
    return data
617249
def templated_docstring(**docs):
    
    def decorator(f):
        f.__doc__ = format_docstring(f.__name__, f.__doc__, docs)
        return f
    return decorator