Minify CSS

    Args:
        src: css string or path-to-file with text to beautify (mandatory)
        dest: path-to-file to save beautified css string; if file doesn't exist
              it is created automatically; (optional)
              if this arg is skept function returns string
        preserve_comments: if set False, all comments are removed from minified text
                           default is True (comments are preserved)

    Returns: 1) minified CSS string if dest is not provided
             2) length of saved file if dest is provided

    Example:
            css.min('path/to/file.css')
            css.min('path/to/file.css', 'path/to/save/result.css')
            css.min('path/to/file.css', False)
            css.min('path/to/file.css', 'path/to/save/result.css', False)

def _css_min(src, dest='', preserve_comments=True):
    """Minify CSS

    Args:
        src: css string or path-to-file with text to beautify (mandatory)
        dest: path-to-file to save beautified css string; if file doesn't exist
              it is created automatically; (optional)
              if this arg is skept function returns string
        preserve_comments: if set False, all comments are removed from minified text
                           default is True (comments are preserved)

    Returns: 1) minified CSS string if dest is not provided
             2) length of saved file if dest is provided

    Example:
            css.min('path/to/file.css')
            css.min('path/to/file.css', 'path/to/save/result.css')
            css.min('path/to/file.css', False)
            css.min('path/to/file.css', 'path/to/save/result.css', False)
    """

    if dest == '': # all default
        return _css_min_exec(_text(src))
    else:
        if type(dest) is bool:  #dest is skept, custom pattern provided at dist place
            return _css_min_exec(_text(src), dest)
        else:
            with open(dest, 'w') as f2:
                return f2.write(_css_min_exec(_text(src), preserve_comments))