All Samples(4374) | Call(4302) | Derive(0) | Import(72)
Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath (excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).
If optional arg 'topdown' is true or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
(directories are generated top down). If topdown is false, the triple
for a directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).
When topdown is true, the caller can modify the dirnames list in-place
(e.g., via del or slice assignment), and walk will only recurse into the
subdirectories whose names remain in dirnames; this can be used to prune
the search, or to impose a specific order of visiting. Modifying
dirnames when topdown is false is ineffective, since the directories in
dirnames have already been generated by the time dirnames itself is
generated.
By default errors from the os.listdir() call are ignored. If
optional arg 'onerror' is specified, it should be a function; it
will be called with one argument, an os.error instance. It can
report the error to continue with the walk, or raise the exception
to abort the walk. Note that the filename is available as the
filename attribute of the exception object.
By default, os.walk does not follow symbolic links to subdirectories on
systems that support them. In order to get this functionality, set the
optional argument 'followlinks' to true.
Caution: if you pass a relative pathname for top, don't change the
current working directory between resumptions of walk. walk never
changes the current directory, and assumes that the client doesn't
either.
Example:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print root, "consumes",
print sum([getsize(join(root, name)) for name in files]),
print "bytes in", len(files), "non-directory files"
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
def walk(top, topdown=True, onerror=None, followlinks=False):
"""Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath (excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).
If optional arg 'topdown' is true or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
(directories are generated top down). If topdown is false, the triple
for a directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).
When topdown is true, the caller can modify the dirnames list in-place
(e.g., via del or slice assignment), and walk will only recurse into the
subdirectories whose names remain in dirnames; this can be used to prune
the search, or to impose a specific order of visiting. Modifying
dirnames when topdown is false is ineffective, since the directories in
dirnames have already been generated by the time dirnames itself is
generated.
By default errors from the os.listdir() call are ignored. If
optional arg 'onerror' is specified, it should be a function; it
will be called with one argument, an os.error instance. It can
report the error to continue with the walk, or raise the exception
to abort the walk. Note that the filename is available as the
filename attribute of the exception object.
By default, os.walk does not follow symbolic links to subdirectories on
systems that support them. In order to get this functionality, set the
optional argument 'followlinks' to true.
Caution: if you pass a relative pathname for top, don't change the
current working directory between resumptions of walk. walk never
changes the current directory, and assumes that the client doesn't
either.
Example:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print root, "consumes",
print sum([getsize(join(root, name)) for name in files]),
print "bytes in", len(files), "non-directory files"
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
"""
islink, join, isdir = path.islink, path.join, path.isdir
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.path.walk
# always suppressed the exception then, rather than blow up for a
# minor reason when (say) a thousand readable directories are still
# left to visit. That logic is copied here.
try:
# Note that listdir and error are globals in this module due
# to earlier import-*.
names = listdir(top)
except error, err:
if onerror is not None:
onerror(err)
return
dirs, nondirs = [], []
for name in names:
if isdir(join(top, name)):
dirs.append(name)
else:
nondirs.append(name)
if topdown:
yield top, dirs, nondirs
for name in dirs:
new_path = join(top, name)
if followlinks or not islink(new_path):
for x in walk(new_path, topdown, onerror, followlinks):
yield x
if not topdown:
yield top, dirs, nondirs
from django.utils.encoding import smart_str, smart_unicode
from django.contrib.auth.decorators import login_required
from wtsite.mediapool.models import *
from os import access, stat, path, walk, F_OK, R_OK
from os.path import join, getsize
from stat import ST_MTIME
import tagpy, datetime, logging
def build_file_list(dir):
logging.info('Start of build_file_list(%s)' % dir)
if not (access(dir, (F_OK or R_OK))):
return
list = walk(dir,topdown=True)
#empty all songs from current database. This should be fast!!!
d = Song.objects.all()
d.delete()
list = walk(dir,topdown=True)
for root, dirs, files in list:
for f in files:
ext = path.splitext(f)[1]
for s in songs:
found = False
db_filename = smart_str(s.filename)
list = walk(dir,topdown=True)
for root, dirs, files in list:
if(found):
continue
src/i/t/itools-HEAD/fs/lfs.py itools(Download)
# Import from the Standard Library from datetime import datetime from os import listdir, makedirs, remove as os_remove, walk from os import access, R_OK, W_OK from os.path import exists, getatime, getctime, getmtime ,getsize from os.path import isfile, isdir, join, basename, dirname
def traverse(self, path='.'):
path = self._resolve_path(path)
yield path
if isdir(path):
for root, folders, files in walk(path, topdown=True):
for name in folders:
yield join(root, name)
src/v/e/velocikit-HEAD/trunk/src/velocikit/tools/proxify.py velocikit(Download)
from os.path import split, splitext, join, exists, abspath import codecs import inspect from os import chdir, getcwd, walk, stat, remove import tempfile from zipfile import PyZipFile import logging
# compare modification times of source and destination files
skip = True
srcmtime = None
for root, dirs, files in walk('.'):
for filename in files:
if filename.endswith(".py"):
pyfile = join(root,filename)
src/v/e/velocikit-HEAD/src/velocikit/tools/proxify.py velocikit(Download)
from os.path import split, splitext, join, exists, abspath import codecs import inspect from os import chdir, getcwd, walk, stat, remove import tempfile from zipfile import PyZipFile import logging
# compare modification times of source and destination files
skip = True
srcmtime = None
for root, dirs, files in walk('.'):
for filename in files:
if filename.endswith(".py"):
pyfile = join(root,filename)
src/s/k/skink-HEAD/skink/lib/ion/fs.py skink(Download)
import os from os.path import join, dirname, abspath, exists, isfile from os import walk, remove import fnmatch import shutil
def locate(*args, **kw):
root = 'root' in kw and kw['root'] or os.curdir
root_path = abspath(root)
patterns = args
return_files = []
for path, dirs, files in walk(root_path):
src/w/3/w3af-HEAD/extras/misc/convertTabs.py w3af(Download)
import os
from os.path import join
from os import walk, system
for root, dirs, files in walk('.'):
filenames = [join(root, name) for name in files if '.svn' not in root and name.endswith('.py') and name != 'convertTabs.py' and 'extlib' not in root ]
for filename in filenames:
src/c/a/cargo-HEAD/src/python/cargo/io.py cargo(Download)
"""
# walk the directory tree
from os import walk
from os.path import (
join,
isfile,
)
if isfile(path):
walked = [path]
else:
def walk_path():
for (p, _, f) in walk(path):
src/p/y/pyClanSphere-HEAD/pyClanSphere/application.py pyClanSphere(Download)
:license: BSD, see LICENSE for more details.
"""
import sys
from os import path, remove, makedirs, walk, environ
from time import time
from urlparse import urlparse
from collections import deque
def list_templates(self):
"""Return a sorted list of all templates."""
templates = set()
for p in self.get_searchpath():
for dirpath, dirnames, filenames in walk(p):
dirpath = dirpath[len(p) + 1:]
if dirpath.startswith('.'):
src/m/y/mypy-0.255/mypy/project_template/myfile/merge.py mypy(Download)
from os import makedirs from os.path import exists from hashlib import md5 from os import walk from glob import glob from struct import unpack from zlib import crc32
def walk_filter(basedir, dirfilter=None, filefilter=None):
for dirpath, dirnames, filenames in walk(basedir):
if dirfilter and not dirfilter(dirpath):
continue
prefix = dirpath[len(basedir)+1:]
for filename in filenames:
if filefilter and not filefilter(filename):
src/p/y/pyClanSphere-HEAD/pyClanSphere/pluginsystem.py pyClanSphere(Download)
import re import sys import inspect from os import path, listdir, walk, makedirs from types import ModuleType from shutil import rmtree from time import localtime, time
# write all files into a "pdata/" folder
offset = len(self.path) + 1
for dirpath, dirnames, filenames in walk(self.path):
# don't recurse into hidden dirs
for i in range(len(dirnames)-1, -1, -1):
if dirnames[i].startswith('.'):
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 Next