Create M3U playlist with contents of `section_dir`/*.mp4. The playlist
    will be created in that directory.

    @param section_dir: Path where to scan for *.mp4 files.
    @type section_dir: str
168834
def create_m3u_playlist(section_dir):
    
    path_to_return = os.getcwd()

    for (_path, subdirs, files) in os.walk(section_dir):
        os.chdir(_path)
        globbed_videos = sorted(glob.glob("*.mp4"))
        m3u_name = os.path.split(_path)[1] + ".m3u"

        if len(globbed_videos):
            with open(m3u_name, "w") as m3u:
                for video in globbed_videos:
                    m3u.write(video + "\n")
            os.chdir(path_to_return)
    os.chdir(path_to_return)
1064015
def addWatchedDirectory(self, dirname, watching=Purr.WATCHED, save_config=True):
        """"""
        # see if we're alredy watching this exact set of directories -- do nothing if so
        dirname = Purr.canonizePath(dirname)
        # do nothing if already watching
        if dirname in self.watched_dirs:
            dprint(1, "addWatchDirectory(): already watching %s\n", dirname)
            # watching=None means do not change the watch-state
            if watching is None:
                return
        else:
            if watching is None:
                watching = Purr.WATCHED
            # make watcher object
            wdir = Purrer.WatchedDir(dirname, mtime=self.timestamp,
                                     watch_patterns=self._watch_patterns, ignore_patterns=self._ignore_patterns)
            # fileset=None indicates error reading directory, so ignore it
            if wdir.fileset is None:
                print("There was an error reading the directory %s, will stop watching it." % dirname)
                self.setWatchingState(dirname, Purr.REMOVED, save_config=True)
                return
            self.watchers[dirname] = wdir
            self.watched_dirs.append(dirname)
            dprintf(2, "watching directory %s, mtime %s, %d files\n",
                    dirname, time.strftime("%x %X", time.localtime(wdir.mtime)), len(wdir.fileset))
            # find files in this directory matching the watch_patterns, and watch them for changes
            watchset = set()
            for patt in self._watch_patterns:
                watchset.update(fnmatch.filter(wdir.fileset, patt))
            for fname in watchset:
                quiet = matches_patterns(fname, self._quiet_patterns)
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if fullname not in self.watchers:
                    wfile = Purrer.WatchedFile(fullname, quiet=quiet, mtime=self.timestamp)
                    self.watchers[fullname] = wfile
                    dprintf(3, "watching file %s, timestamp %s, quiet %d\n",
                            fullname, time.strftime("%x %X", time.localtime(wfile.mtime)), quiet)
            # find subdirectories  matching the subdir_patterns, and watch them for changes
            for fname in wdir.fileset:
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if os.path.isdir(fullname):
                    for desc, dir_patts, canary_patts in self._subdir_patterns:
                        if matches_patterns(fname, dir_patts):
                            quiet = matches_patterns(fname, self._quiet_patterns)
                            wdir = Purrer.WatchedSubdir(fullname, canary_patterns=canary_patts, quiet=quiet,
                                                        mtime=self.timestamp)
                            self.watchers[fullname] = wdir
                            dprintf(3, "watching subdirectory %s/{%s}, timestamp %s, quiet %d\n",
                                    fullname, ",".join(canary_patts),
                                    time.strftime("%x %X", time.localtime(wdir.mtime)), quiet)
                            break
        # set state and save config
        self.setWatchingState(dirname, watching, save_config=save_config)
734701
def add_directory(dir_path)
      full_path = File.join(@path, dir_path)
      FileUtils.mkdir_p(full_path) unless File.directory?(full_path)

      self.class.new(full_path)
    end
152255
public void addDirectory(File dir) {
    File[] ndirs = new File[directories.length + 1];
    System.arraycopy(directories, 0, ndirs, 0, directories.length);
    ndirs[ndirs.length - 1] = dir;
    directories = ndirs;
  }
1000172
protected void createInternalDataStructre(List<Section> sectionList) {
        try {
            lock.lock();

            for (Section sec : sectionList) {
                if ("robots".equals(sec.getName())) {
                    Map<String, RobotEntry> robotsMapTmp = new HashMap<String, RobotEntry>();
                    for (Entry en : sec.getEntries()) {
                        RobotEntry re = new RobotEntry(en.getData());
                        robotsMapTmp.put(re.getUserAgentString(), re);
                    }
                    robotsMap = robotsMapTmp;
                } else if ("os".equals(sec.getName())) {
                    Map<Long, OsEntry> osMapTmp = new HashMap<Long, OsEntry>();
                    for (Entry en : sec.getEntries()) {
                        OsEntry oe = new OsEntry(en.getData());
                        osMapTmp.put(Long.parseLong(en.getKey()), oe);
                    }
                    osMap = osMapTmp;
                } else if ("browser".equals(sec.getName())) {
                    Map<Long, BrowserEntry> browserMapTmp = new HashMap<Long, BrowserEntry>();
                    for (Entry en : sec.getEntries()) {
                        BrowserEntry be = new BrowserEntry(en.getData());
                        browserMapTmp.put(Long.parseLong(en.getKey()), be);
                    }
                    browserMap = browserMapTmp;
                } else if ("browser_type".equals(sec.getName())) {
                    Map<Long, String> browserTypeMapTmp = new HashMap<Long, String>();
                    for (Entry en : sec.getEntries()) {
                        browserTypeMapTmp.put(Long.parseLong(en.getKey()), en.getData().iterator().next());
                    }
                    browserTypeMap = browserTypeMapTmp;
                } else if ("browser_reg".equals(sec.getName())) {
                    Map<String, Long> browserRegMapTmp = new LinkedHashMap<String, Long>();
                    for (Entry en : sec.getEntries()) {
                        Iterator<String> it = en.getData().iterator();
                        browserRegMapTmp.put(convertPerlToJavaRegex(it.next()), Long.parseLong(it.next()));
                    }
                    browserRegMap = browserRegMapTmp;
                } else if ("browser_os".equals(sec.getName())) {
                    Map<Long, Long> browserOsMapTmp = new HashMap<Long, Long>();
                    for (Entry en : sec.getEntries()) {
                        browserOsMapTmp.put(Long.parseLong(en.getKey()), Long.parseLong(en.getData().iterator().next()));
                    }
                    browserOsMap = browserOsMapTmp;
                } else if ("os_reg".equals(sec.getName())) {
                    Map<Pattern, Long> osRegMapTmp = new LinkedHashMap<Pattern, Long>();
                    for (Entry en : sec.getEntries()) {
                        Iterator<String> it = en.getData().iterator();
                        Pattern pattern = Pattern.compile(convertPerlToJavaRegex(it.next()), Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
                        osRegMapTmp.put(pattern, Long.parseLong(it.next()));
                    }
                    osRegMap = osRegMapTmp;
                }
            }
        } finally {
            lock.unlock();
        }
    }
328541
def mkdir(self, target_folder):
        
        self.printv("Making directory: %s" % target_folder)
        self.k.key = re.sub(r"^/|/$", "", target_folder) + "/"
        self.k.set_contents_from_string('')
        self.k.close()
1098216
def respond_list_directory(self, dir_path, query=None):
		
		del query
		try:
			dir_contents = os.listdir(dir_path)
		except os.error:
			self.respond_not_found()
			return
		if os.path.normpath(dir_path) != self.__config['serve_files_root']:
			dir_contents.append('..')
		dir_contents.sort(key=lambda a: a.lower())
		displaypath = html.escape(urllib.parse.unquote(self.path), quote=True)

		f = io.BytesIO()
		encoding = sys.getfilesystemencoding()
		f.write(b'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n')
		f.write(b'<html>\n<title>Directory listing for ' + displaypath.encode(encoding) + b'</title>\n')
		f.write(b'<body>\n<h2>Directory listing for ' + displaypath.encode(encoding) + b'</h2>\n')
		f.write(b'<hr>\n<ul>\n')
		for name in dir_contents:
			fullname = os.path.join(dir_path, name)
			displayname = linkname = name
			# Append / for directories or @ for symbolic links
			if os.path.isdir(fullname):
				displayname = name + "/"
				linkname = name + "/"
			if os.path.islink(fullname):
				displayname = name + "@"
				# Note: a link to a directory displays with @ and links with /
			f.write(('<li><a href="' + urllib.parse.quote(linkname) + '">' + html.escape(displayname, quote=True) + '</a>\n').encode(encoding))
		f.write(b'</ul>\n<hr>\n</body>\n</html>\n')
		length = f.tell()
		f.seek(0)

		self.send_response(200)
		self.send_header('Content-Type', 'text/html; charset=' + encoding)
		self.send_header('Content-Length', length)
		self.end_headers()
		shutil.copyfileobj(f, self.wfile)
		f.close()
		return
711038
def add_videos_to_playlist(self, access_token, playlist_id, video_ids):
        
        url = 'https://openapi.youku.com/v2/playlists/video/add.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'playlist_id': playlist_id,
            'video_ids': video_ids
        }
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
637941
def section(self, resources):
        

        section = [p for p in self.parents(resources) if p.rtype == 'section']
        if section:
            return section[0]
        return None
262291
def add_section(self, section):
        
        if section.lower() == "default":
            raise ValueError('Invalid section name: %s' % section)

        if section in self._sections:
            raise DuplicateSectionError(section)
        self._sections[section] = self._dict()
1301007
def _get_sections(request):
    
    sections = []
    for section_url in SECTIONS:
        crumb = find_crumb(request, section_url)
        if crumb:
            if section_url == '/':
                if request.path == section_url:
                    crumb.is_current = True
            else:
                if request.path.startswith(section_url):
                    crumb.is_current = True
            sections.append(crumb)

    return sections
126814
def playlist_category(self):
        
        url = 'https://openapi.youku.com/v2/schemas/playlist/category.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
996133
def __set_folder_list(self, section):
        
        for l in range(1, self.__folder_list_max_size + 1):
            value = {}
            key = 'folder_' + str(l) + '_'

            # Path is mandatory
            value['indice'] = str(l)
            value['path'] = self.config.get_value(section, key + 'path')
            if value['path'] is None:
                continue
            else:
                value['path'] = nativestr(value['path'])

            # Optional conf keys
            for i in ['careful', 'warning', 'critical']:
                # Read threshold
                value[i] = self.config.get_value(section, key + i)
                if value[i] is not None:
                    logger.debug("{} threshold for folder {} is {}".format(i, value["path"], value[i]))
                # Read action
                action = self.config.get_value(section, key + i + '_action')
                if action is not None:
                    value[i + '_action'] = action
                    logger.debug("{} action for folder {} is {}".format(i, value["path"], value[i + '_action']))

            # Add the item to the list
            self.__folder_list.append(value)
913103
def dir_freq(directory):
    ''''''
    content = dir_list(directory)
    i = 0
    freqdict = {}
    for filename in content:
        filewords = eliminate_repeats(read_file(directory + '/' + filename))
        for word in filewords:
            if freqdict.has_key(word):
                freqdict[word] += 1
            else:
                freqdict[word] = 1
    tupleize = []
    for key in freqdict.keys():
        wordtuple = (key,freqdict[key])
        tupleize.append(wordtuple)
    return tupleize
1144817
public void addWatchDirectory(File dir, List<String> fileExtensions) {
    	List<String> fileExtensionsWithoutDot = new ArrayList<String>(fileExtensions.size());
    	for(String fileExtension : fileExtensions){
    		fileExtensionsWithoutDot.add(removeStartingDotIfPresent(fileExtension));
    	}
    	directoryWatcherDelegate.addWatchDirectory(dir, fileExtensions);
    }
318758
private void addFilesFromDir(File dir) {
    File[] files = dir.listFiles();
    for (int i = 0; i < files.length; i++) {
      if (!files[i].isDirectory()) {
        mFiles.add(files[i]);
      } else if (mRecursive) {
        addFilesFromDir(files[i]);
      }
    }
  }
305823
private static Set<File> findAllFiles(File dir) {
        Set<File> foundFiles = new HashSet<>();
        if (dir == null) {
            return foundFiles;
        }
        recurse(dir, foundFiles);
        return foundFiles;
    }