Look for files in subdirectory of MEDIA_ROOT using the tenant's
        domain_url value as the specifier.
967391
def path(self, name):
        
        if name is None:
            name = ''
        try:
            location = safe_join(self.location, connection.tenant.domain_url)
        except AttributeError:
            location = self.location
        try:
            path = safe_join(location, name)
        except ValueError:
            raise SuspiciousOperation(
                "Attempted access to '%s' denied." % name)
        return os.path.normpath(path)
1112970
def get_subdomains_count(db_path=None, zonefiles_dir=None):
    
    opts = get_blockstack_opts()
    if not is_subdomains_enabled(opts):
        log.warn("Subdomain support is disabled")
        return None

    if db_path is None:
        db_path = opts['subdomaindb_path']

    if zonefiles_dir is None:
        zonefiles_dir = opts['zonefiles']

    db = SubdomainDB(db_path, zonefiles_dir)
    return db.get_subdomains_count()
148286
private static Collection<? extends URL> doFindPathMatchingJarResources(final URL rootDirResource, final String subPattern) {

        final Set<URL> result = new LinkedHashSet<URL>();

        JarFile jarFile = null;
        String jarFileUrl;
        String rootEntryPath = null;
        URLConnection con;
        boolean newJarFile = false;

        try {
            con = rootDirResource.openConnection();

            if (con instanceof JarURLConnection) {
                final JarURLConnection jarCon = (JarURLConnection) con;

                jarCon.setUseCaches(false);
                jarFile = jarCon.getJarFile();
                jarFileUrl = jarCon.getJarFileURL().toExternalForm();
                final JarEntry jarEntry = jarCon.getJarEntry();

                rootEntryPath = jarEntry != null ? jarEntry.getName() : "";
            } else {
                // No JarURLConnection -> need to resort to URL file parsing.
                // We'll assume URLs of the format "jar:path!/entry", with the
                // protocol
                // being arbitrary as long as following the entry format.
                // We'll also handle paths with and without leading "file:"
                // prefix.
                final String urlFile = rootDirResource.getFile();
                final int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);

                if (separatorIndex != -1) {
                    jarFileUrl = urlFile.substring(0, separatorIndex);
                    rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length());
                    jarFile = getJarFile(jarFileUrl);
                } else {
                    jarFile = new JarFile(urlFile);
                    jarFileUrl = urlFile;
                    rootEntryPath = "";
                }
                newJarFile = true;

            }

        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "reslove jar File error", e);
            return result;
        }
        try {
            if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
                // Root entry path must end with slash to allow for proper
                // matching.
                // The Sun JRE does not return a slash here, but BEA JRockit
                // does.
                rootEntryPath = rootEntryPath + "/";
            }
            for (final Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
                final JarEntry entry = (JarEntry) entries.nextElement();
                final String entryPath = entry.getName();

                String relativePath = null;

                if (entryPath.startsWith(rootEntryPath)) {
                    relativePath = entryPath.substring(rootEntryPath.length());

                    if (AntPathMatcher.match(subPattern, relativePath)) {
                        if (relativePath.startsWith("/")) {
                            relativePath = relativePath.substring(1);
                        }
                        result.add(new URL(rootDirResource, relativePath));
                    }
                }
            }
            return result;
        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "parse the JarFile error", e);
        } finally {
            // Close jar file, but only if freshly obtained -
            // not from JarURLConnection, which might cache the file reference.
            if (newJarFile) {
                try {
                    jarFile.close();
                } catch (final IOException e) {
                    LOGGER.log(Level.WARN, " occur error when closing jarFile", e);
                }
            }
        }
        return result;
    }
1227348
def dir_attribs(location, mode=None, owner=None,
                group=None, recursive=False, use_sudo=False):
    
    args = ''
    if recursive:
        args = args + ' -R '

    if mode:
        if use_sudo:
            sudo('chmod %s %s %s' % (args, mode,  location))
        else:
            run('chmod %s %s %s' % (args, mode,  location))
    if owner:
        if use_sudo:
            sudo('chown %s %s %s' % (args, owner, location))
        else:
            run('chown %s %s %s' % (args, owner, location))
    if group:
        if use_sudo:
            sudo('chgrp %s %s %s' % (args, group, location))
        else:
            run('chgrp %s %s %s' % (args, group, location))
    return True
9425
def find(dir_path, opts = {})
      regex = opts.key?(:regex) ? opts[:regex] : nil

      # We should always be doing GET because switching between methods is used
      # within this function.
      opts.delete(:head)

      begin
        exists = list_directory(dir_path, head: true).first
      rescue
        exists = false
      end

      return [] unless exists

      response = list_directory(dir_path, opts)
      listing = response.first

      listing.inject([]) do |memo, obj|
        if obj['type'] == 'directory'
          sub_dir = "#{dir_path}/#{obj['name']}"
          sub_search = find(sub_dir, regex: regex)
          memo.push(*sub_search)
        end

        if obj['type'] == 'object'
          file = "#{dir_path}/#{obj['name']}"

          if !regex || obj['name'].match(regex)
            memo.push file
          end
        end

        memo
      end
    end
427601
def __find_source_files(self):
        
        for dir_path, _, files in os.walk(self._source_directory):
            for name in files:
                if name.lower().endswith(self._source_file_extension):
                    basename = os.path.splitext(os.path.basename(name))[0]
                    relative_path = os.path.relpath(os.path.join(dir_path, name))

                    if basename in self._source_file_names:
                        self._io.error("Files '{0}' and '{1}' have the same basename.".
                                       format(self._source_file_names[basename], relative_path))
                        self.error_file_names.add(relative_path)
                    else:
                        self._source_file_names[basename] = relative_path
1289648
def _find_files(dl_paths, publisher, url_dict):
  """"""
  if publisher == 'cnn':
    top_dir = os.path.join(dl_paths['cnn_stories'], 'cnn', 'stories')
  elif publisher == 'dm':
    top_dir = os.path.join(dl_paths['dm_stories'], 'dailymail', 'stories')
  else:
    logging.fatal('Unsupported publisher: %s', publisher)
  files = tf.io.gfile.listdir(top_dir)

  ret_files = []
  for p in files:
    basename = os.path.basename(p)
    if basename[0:basename.find('.story')] in url_dict:
      ret_files.append(os.path.join(top_dir, p))
  return ret_files
572070
def findFile(input):
    """"""

    # If no input name is provided, default to returning 'no'(FALSE)
    if not input:
        return no

    # We use 'osfn' here to insure that any IRAF variables are
    # expanded out before splitting out the path...
    _fdir, _fname = os.path.split(osfn(input))

    if _fdir == '':
        _fdir = os.curdir

    try:
        flist = os.listdir(_fdir)
    except OSError:
        # handle when requested file in on a disconnect network store
        return no

    _root, _extn = parseFilename(_fname)

    found = no
    for name in flist:
        if name == _root:
            # Check to see if given extension, if any, exists
            if _extn is None:
                found = yes
                continue
            else:
                _split = _extn.split(',')
                _extnum = None
                _extver = None
                if  _split[0].isdigit():
                    _extname = None
                    _extnum = int(_split[0])
                else:
                    _extname = _split[0]
                    if len(_split) > 1:
                        _extver = int(_split[1])
                    else:
                        _extver = 1
                f = openImage(_root)
                f.close()
                if _extnum is not None:
                    if _extnum < len(f):
                        found = yes
                        del f
                        continue
                    else:
                        del f
                else:
                    _fext = findExtname(f, _extname, extver=_extver)
                    if _fext is not None:
                        found = yes
                        del f
                        continue
    return found
664784
function getDomainsByPath(path) {
  var domain = fis.media().get('project.domain', {}),
    value = [];
  if (typeof domain === 'string') {
    value = domain.split(/\s*,\s*/);
  } else if (fis.util.is(domain, 'Array')) {
    value = domain;
  } else {
    fis.util.map(domain, function(pattern, domain) {
      if ((pattern === 'image' && fis.util.isImageFile(path)) || fis.util.glob(pattern, path)) {
        if (typeof domain === 'string') {
          value = domain.split(/\s*,\s*/);
        } else if (fis.util.is(domain, 'Array')) {
          value = domain;
        } else {
          fis.log.warning('invalid domain [' + domain + '] of [project.domain.' + pattern + ']');
        }
        return true;
      }
    });
  }
  return value;
}
792117
def getMedia(self, uri):
        """"""

        r = self.doQuery('media/' + uri)

        if r.status_code == 200:
            content_type = 'application/octet-stream'

            if 'content-type' in r.headers:
                content_type = r.headers['content-type']

            cache_control = None

            if 'cache-control' in r.headers:
                cache_control = r.headers['cache-control']

            return (r.content, content_type, cache_control)
        else:
            return (None, None, None)
958363
def subdomain?(*jids)
      !jids.flatten.index do |jid|
        !component?(jid) && !pubsub?(jid)
      end
    end
631417
def find_files(directory, pattern):
    
    for root, __, files in os.walk(directory):
        for basename in files:
            if fnmatch.fnmatch(basename, pattern):
                filename = os.path.join(root, basename)
                yield filename
766004
def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
    """"""
    file_list = []
    for root, dirs, files in walk(path.join(base_path, sub_path)):
        if trim_base_path:
            root = path.relpath(root, base_path)
        file_list.extend([path.join(root, file_name)
                          for file_name in files
                          if file_name.endswith(ext)])
    return sorted(file_list)
547780
def get_all_media(exclude=None):
    

    if not exclude:
        exclude = []

    media = set()

    for root, dirs, files in os.walk(six.text_type(settings.MEDIA_ROOT)):
        for name in files:
            path = os.path.abspath(os.path.join(root, name))
            relpath = os.path.relpath(path, settings.MEDIA_ROOT)
            for e in exclude:
                if re.match(r'^%s$' % re.escape(e).replace('\\*', '.*'), relpath):
                    break
            else:
                media.add(path)

    return media
955705
def get_admin_url(self, query_params=None, use_path=False):
        """"""

        if not query_params:
            query_params = {}

        url = ''
        if self.is_top_node():
            url = reverse('admin:media_tree_filenode_changelist');
        elif use_path and (self.is_folder() or self.pk):
            url = reverse('admin:media_tree_filenode_open_path', args=(self.get_path(),));
        elif self.is_folder():
            url = reverse('admin:media_tree_filenode_changelist');
            query_params['folder_id'] = self.pk
        elif self.pk:
            return reverse('admin:media_tree_filenode_change', args=(self.pk,));

        if len(query_params):
            params = ['%s=%s' % (key, value) for key, value in query_params.items()]
            url = '%s?%s' % (url, "&".join(params))

        return url
495715
def _get_sub_dirs(parent):
    """"""
    return [child for child in os.listdir(parent) if os.path.isdir(os.path.join(parent, child))]
600248
function findRelative( url ){

    var dirName =       path.dirname( url );
    var baseName =      path.basename( url );
    var entries;

    if ( !fs.existsSync( dirName )){
        entries =       [];
    } else {
        entries =       fs.readdirSync( dirName ).filter( matches );
    }

    return entries.map( fsUtils.getFullPath( dirName ));

    /// Return true if entry === baseName.extension
    function matches( entry ){

        var len =       baseName.length;
        return entry[len] === "." && !entry.indexOf( baseName ) && entry.slice( len + 1 ).indexOf( "." ) === -1;
    }///
}