Esempio n. 1
0
 def list(self, ignore_patterns):
     """
     List all files in all app storages.
     """
     for path, storage in AppDirectoriesFinder.list(self, ignore_patterns):
         if self.is_dependency(path, storage):
             yield path, storage
Esempio n. 2
0
def _can_symlink_static_files():
    from django.conf import settings

    finder = AppDirectoriesFinder()
    for path, storage in finder.list([]):
        # Get the first static file and use that as our source
        source_path = storage.path(path)
        break

    # Check that we can make a symlink between this file, and the static root
    # directory we are using.
    return symlink_capability_check(source_path, settings.STATIC_ROOT)
Esempio n. 3
0
def walk_finders(path):
    """Find all qunit related files given the path component that comes
  after '/qunit/'

  Works similarly to 'os.walk' but returns just files and directories
  by surfing over all possible files.
  """
    # Get a file system path from url path
    path_comps = [c for c in path.split('/') if c != u'']
    tmp = os.sep.join(path_comps)
    file_path = os.path.join(settings.QUNIT_TEST_PATH, tmp)
    finder_files = []

    # Get list of files from app directories from app file finder
    adf = AppDirectoriesFinder()
    for fpath, filestorageobj in adf.list(''):
        if settings.QUNIT_TEST_PATH in fpath:
            finder_files.append((fpath, filestorageobj))

    # Get list of files from app directories from file system file finder
    # By adding this second, files in the project base override app specific files
    fsf = FileSystemFinder()
    for fpath, filestorageobj in fsf.list(''):
        if settings.QUNIT_TEST_PATH in fpath:
            finder_files.append((fpath, filestorageobj))

    # Form arrays of files in this directory and sub directories
    matchfiles = []
    subdirectories = []
    for ffile_path, fso in finder_files:
        split = ffile_path.split(file_path)
        if len(split) > 1:
            # Check to see if sub-directories exist
            path_split = split[1].split(os.sep)
            if len(path_split) > 1 and path_split[0] != u'':
                # this file indicates a sub directory
                subdirectories.append(path_split[0])
            else:
                # this is a file in this directory
                matchfiles.append((ffile_path, fso))

    # Get rid of duplicates
    subdirectories = list(set(subdirectories))  # array of strings
    matchfiles = list(set(matchfiles))  # array of tuples

    return (subdirectories, matchfiles)