
import os
import sys
import orig_clevercss

def clevercss(app):
    @app.before_request
    def _render_clever_css():
        static_dir = app.root_path + app.static_path

        clever_paths = []
        for path, subdirs, filenames in os.walk(static_dir):
            clever_paths.extend([
                os.path.join(path, f)
                for f in filenames if os.path.splitext(f)[1] == '.ccss'
            ])
        for clever_path in clever_paths:
            css_path = os.path.splitext(clever_path)[0] + '.css'
            if not os.path.isfile(css_path):
                css_mtime = -1
            else:
                css_mtime = os.path.getmtime(css_path)
            clever_mtime = os.path.getmtime(clever_path)
            if clever_mtime >= css_mtime:
                sys.argv[1:] = [clever_path]
                orig_clevercss.main()


import os
import sys
import orig_clevercss

def clevercss(app):
    @app.before_request
    def _render_clever_css():
        static_dir = os.path.join(app.root_path, app._static_folder)

        clever_paths = []
        for path, subdirs, filenames in os.walk(static_dir):
            clever_paths.extend([
                os.path.join(path, f)
                for f in filenames if os.path.splitext(f)[1] == '.ccss'
            ])
        for clever_path in clever_paths:
            css_path = os.path.splitext(clever_path)[0] + '.css'
            if not os.path.isfile(css_path):
                css_mtime = -1
            else:
                css_mtime = os.path.getmtime(css_path)
            clever_mtime = os.path.getmtime(clever_path)
            if clever_mtime >= css_mtime:
                sys.argv[1:] = [clever_path]
                orig_clevercss.main()

Fix for specifying the static directory in later versions of flask
Fix for specifying the static directory in later versions of flask
  
  import os
  import sys
  import orig_clevercss
  
  def clevercss(app):
      @app.before_request
      def _render_clever_css():
-         static_dir = app.root_path + app.static_path
+         static_dir = os.path.join(app.root_path, app._static_folder)
  
          clever_paths = []
          for path, subdirs, filenames in os.walk(static_dir):
              clever_paths.extend([
                  os.path.join(path, f)
                  for f in filenames if os.path.splitext(f)[1] == '.ccss'
              ])
          for clever_path in clever_paths:
              css_path = os.path.splitext(clever_path)[0] + '.css'
              if not os.path.isfile(css_path):
                  css_mtime = -1
              else:
                  css_mtime = os.path.getmtime(css_path)
              clever_mtime = os.path.getmtime(clever_path)
              if clever_mtime >= css_mtime:
                  sys.argv[1:] = [clever_path]
                  orig_clevercss.main()
  
Fix for specifying the static directory in later versions of flask
## Code Before:

import os
import sys
import orig_clevercss

def clevercss(app):
    @app.before_request
    def _render_clever_css():
        static_dir = app.root_path + app.static_path

        clever_paths = []
        for path, subdirs, filenames in os.walk(static_dir):
            clever_paths.extend([
                os.path.join(path, f)
                for f in filenames if os.path.splitext(f)[1] == '.ccss'
            ])
        for clever_path in clever_paths:
            css_path = os.path.splitext(clever_path)[0] + '.css'
            if not os.path.isfile(css_path):
                css_mtime = -1
            else:
                css_mtime = os.path.getmtime(css_path)
            clever_mtime = os.path.getmtime(clever_path)
            if clever_mtime >= css_mtime:
                sys.argv[1:] = [clever_path]
                orig_clevercss.main()

## Instruction:
Fix for specifying the static directory in later versions of flask
## Code After:

import os
import sys
import orig_clevercss

def clevercss(app):
    @app.before_request
    def _render_clever_css():
        static_dir = os.path.join(app.root_path, app._static_folder)

        clever_paths = []
        for path, subdirs, filenames in os.walk(static_dir):
            clever_paths.extend([
                os.path.join(path, f)
                for f in filenames if os.path.splitext(f)[1] == '.ccss'
            ])
        for clever_path in clever_paths:
            css_path = os.path.splitext(clever_path)[0] + '.css'
            if not os.path.isfile(css_path):
                css_mtime = -1
            else:
                css_mtime = os.path.getmtime(css_path)
            clever_mtime = os.path.getmtime(clever_path)
            if clever_mtime >= css_mtime:
                sys.argv[1:] = [clever_path]
                orig_clevercss.main()
