本文整理汇总了Python中posix.listdir函数的典型用法代码示例。如果您正苦于以下问题:Python listdir函数的具体用法?Python listdir怎么用?Python listdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listdir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Main
def Main():
localfile = open('/home/www/pals/html/dowser/html/cdf.txt','w')
comp = localfile.read()
files = posix.listdir('/home/www/pals/html/dowser/')
os.chdir('/home/www/pals/html/dowser/')
dirs = []
paths = []
for i in range(len(files)):
file = files[i]
if posixpath.isdir(file):
os.chdir('/home/www/pals/html/dowser/'+file+'/')
hello = posix.getcwd()
refs = posix.listdir(hello)
for it in range(len(refs)):
ref = refs[it]
paths.append(hello+"/"+ref)
os.chdir('/home/www/pals/html/dowser/')
print comp
for i in range(len(paths)):
path = paths[i]
localfile.write(path+"\n")
localfile.close()
print "Files in dowser updated"
开发者ID:akrherz,项目名称:pals,代码行数:25,代码来源:cdf.py
示例2: join
def _訓練恬音模型(cls):
訓練目錄 = join(cls.專案目錄, '訓練音檔')
題目 = []
答案 = []
for 類型 in sorted(listdir(訓練目錄)):
類型目錄 = join(訓練目錄, 類型)
for 音檔 in sorted(listdir(類型目錄)):
音檔所在 = join(類型目錄, 音檔)
音檔 = 聲音檔.對檔案讀(音檔所在)
for 音框 in 音檔.全部音框():
特徵 = 恬音判斷.算特徵參數(音框)
題目.append(cls._特徵轉陣列(特徵))
答案.append(類型)
cls.恬音模型 = svm.SVC()
cls.恬音模型.fit(題目, 答案)
开发者ID:Taiwanese-Corpus,项目名称:kaxabu-muwalak-misa-a-ahan-bizu,代码行数:15,代码来源:切錄音檔.py
示例3: _listdir
def _listdir(dir, cache={}):
# since this function is only used by caseOk, it's fine to cache the
# results and avoid reading the whole contents of a directory each time
# we just want to check the case of a filename.
if not dir in cache:
cache[dir] = listdir(dir)
return cache[dir]
开发者ID:Jeffliu,项目名称:hadoopy,代码行数:7,代码来源:iu.py
示例4: process_dir
def process_dir(data_dir_path, output_file_path):
# get the list of files in the directory
onlyfiles = [ f for f in listdir(data_dir_path) if isfile(join(data_dir_path,f))]
# crate a new workbook and sheet
wb_new = Workbook()
sheet_names = wb_new.get_sheet_names()
ws_new = wb_new.get_sheet_by_name(sheet_names[0])
# keep track of number of files processed
global file_count
file_count = 0
# keep track of the row number in the new merged file
global row_count
row_count = 1
# save daily sales
global daily_sales
daily_sales = {}
# process each file in given path
for f in onlyfiles:
process_file(data_dir_path + f, ws_new, file_count)
file_count += 1
# finally save daily sales json
with open(output_file_path + 'daily_sale_figures.json', 'w', encoding = 'utf-8') as fp:
json.dump(daily_sales, fp)
# finally save the new excel file
wb_new.save(output_file_path + 'daily_product_sales.xlsx')
开发者ID:jayBana,项目名称:InventoryMan,代码行数:32,代码来源:02_process_daily_sales.py
示例5: _listdir
def _listdir(dir, cache=None):
# The cache is not used. It was found to cause problems
# with programs that dynamically add python modules to be
# reimported by that same program (i.e., plugins), because
# the cache is only built once at the beginning, and never
# updated. So, we must really list the directory again.
return listdir(dir)
开发者ID:3xp10it,项目名称:evlal_win,代码行数:7,代码来源:iu.py
示例6: get_exe_locations
def get_exe_locations(target_dir):
"""Generate possible locations from which to chainload in the target dir."""
# TODO: let this be a generator when not compiling with PyPy, so we can
# avoid a few stat() calls in the common case.
locs = []
appdir = appdir_from_executable(sys.executable)
# If we're in an appdir, first try to launch from within "<appname>.app"
# directory. We must also try the default scheme for backwards compat.
if sys.platform == "darwin":
if basename(dirname(sys.executable)) == "MacOS":
if __esky_name__:
locs.append(pathjoin(target_dir,
__esky_name__+".app",
sys.executable[len(appdir)+1:]))
else:
for nm in listdir(target_dir):
if nm.endswith(".app"):
locs.append(pathjoin(target_dir,
nm,
sys.executable[len(appdir)+1:]))
# This is the default scheme: the same path as the exe in the appdir.
locs.append(target_dir + sys.executable[len(appdir):])
# If sys.executable was a backup file, try using original filename.
orig_exe = get_original_filename(sys.executable)
if orig_exe is not None:
locs.append(target_dir + orig_exe[len(appdir):])
return locs
开发者ID:AndrewIsaac,项目名称:mastr-ms,代码行数:27,代码来源:bootstrap.py
示例7: makedirs
def 接檔案(原本音檔, 目錄音檔):
makedirs(目錄音檔, exist_ok=True)
for 資料夾 in sorted(listdir(原本音檔)):
所在 = join(原本音檔, 資料夾)
if isdir(所在):
全部音檔合起來 = None
for 第幾個 in range(4):
for 檔案 in sorted(listdir(所在))[第幾個::4]:
這個音檔 = 聲音檔.對檔案讀(join(所在, 檔案))
try:
全部音檔合起來 = 全部音檔合起來.接(這個音檔)
except:
全部音檔合起來 = 這個音檔
結果檔案 = join(目錄音檔, "{}-{}.wav".format(資料夾, 第幾個))
with open(結果檔案, "wb") as 檔案:
檔案.write(全部音檔合起來.wav格式資料())
开发者ID:Taiwanese-Corpus,项目名称:kaxabu-muwalak-misa-a-ahan-bizu,代码行数:16,代码来源:敆音檔.py
示例8: load_files
def load_files(self, directory="dummy_files"):
dir_path = join(dirname(__file__), "..", directory)
if not isdir(dir_path):
print "Skipping non-existing dir", directory
return
file_names = listdir(dir_path)
for fn in file_names:
if fn.startswith("."):
continue
path = join(dir_path, fn)
name = unicode(fn, errors="replace")
data = open(path).read()
mime_type = mimetypes.guess_type(fn)[0]
f = File(name, data, mime_type)
f.creator_id = choice(self.users).uid
f.owner_id = choice(self.users).uid
n_tags = random.randint(0, len(TAGS))
tags = random.sample(TAGS, n_tags)
f.tags = u",".join(tags)
self.db.session.add(f)
开发者ID:sfermigier,项目名称:yaka,代码行数:26,代码来源:util.py
示例9: openlistwindow
def openlistwindow(dirname):
list = posix.listdir(dirname)
list.sort()
i = 0
while i < len(list):
if list[i] == '.' or list[i] == '..':
del list[i]
else:
i = i+1
for i in range(len(list)):
name = list[i]
if path.isdir(path.join(dirname, name)):
list[i] = list[i] + '/'
width = maxwidth(list)
width = width + stdwin.textwidth(' ') # XXX X11 stdwin bug workaround
height = len(list) * stdwin.lineheight()
stdwin.setdefwinsize(width, min(height, 500))
w = stdwin.open(dirname)
stdwin.setdefwinsize(0, 0)
w.setdocsize(width, height)
w.drawproc = drawlistwindow
w.mouse = mouselistwindow
w.close = closelistwindow
w.dirname = dirname
w.list = list
w.selected = -1
return w
开发者ID:asottile,项目名称:ancient-pythons,代码行数:27,代码来源:jukebox.py
示例10: process_dir
def process_dir(data_dir_path, output_file_path):
# crate a new workbook and sheets
wb_new = Workbook()
ws_deliveries = wb_new.get_active_sheet()
ws_deliveries.title = 'Deliveries'
ws_returns = wb_new.create_sheet(1)
ws_returns.title = 'Returns'
ws_wastage = wb_new.create_sheet(2)
ws_wastage.title = 'Wastage'
ws_staff_meals = wb_new.create_sheet(3)
ws_staff_meals.title = 'Staff Meals'
ws_transfers_in = wb_new.create_sheet(4)
ws_transfers_in.title = 'Transfers In'
ws_transfers_out = wb_new.create_sheet(5)
ws_transfers_out.title = 'Transfers Out'
# get the list of files in the directory
onlyfiles = [ f for f in listdir(data_dir_path) if isfile(join(data_dir_path,f))]
# process each file
for f in onlyfiles:
process_file(data_dir_path + f, wb_new)
# save the new workbook
wb_new.save(output_file_path)
开发者ID:jayBana,项目名称:InventoryMan,代码行数:26,代码来源:01_process_transactions.py
示例11: listdir
def _資料夾的短恬量(self, 資料夾):
self.檢查資料夾有辨識出來的檔案(資料夾)
短恬數量 = 0
for 檔名 in listdir(資料夾):
for 一逝 in 程式腳本._讀檔案(join(資料夾, 檔名)):
if 一逝.endswith('sp'):
短恬數量 += 1
return 短恬數量
开发者ID:sih4sing5hong5,项目名称:tai5-uan5_gian5-gi2_kang1-ku7,代码行数:8,代码来源:TestHTK辨識整合試驗.py
示例12: which_days
def which_days():
print '<H3>on this day <spacer type="horizontal" size="50">'
print '<select name="day">'
files = posix.listdir('/home/httpd/html/archivewx/data_days')
files.sort()
for file in files:
print '<option value="'+file+'">'+file+'\n'
print '</select></H3>'
开发者ID:akrherz,项目名称:pals,代码行数:8,代码来源:hourly.py
示例13: openlistwindow
def openlistwindow(dirname):
list = posix.listdir(dirname)
list.sort()
i = 0
while i < len(list):
if list[i] = '.' or list[i] = '..':
del list[i]
else:
i = i+1
开发者ID:asottile,项目名称:ancient-pythons,代码行数:9,代码来源:jukebox.py
示例14: listdir
def listdir(path, fil=None, rec=False):
names = [posixpath.join(path, name) for name in posix.listdir(path)]
for name in names:
if posixpath.isdir(name):
for name in listdir(name, fil, rec):
yield name
if (fil is not None and fnmatch(name, fil)) or fil is None:
yield name
开发者ID:prologic,项目名称:mio,代码行数:9,代码来源:path.py
示例15: avail
def avail(day):
files = posix.listdir('/home/www/pals/html/archivewx/data/'+day)
files.sort()
print '<H3>Available files to link in:</H3>'
print '<form name="two">'
print '<SELECT>'
for file in files:
print '<OPTION>'+file
print '</SELECT></Form><HR>'
开发者ID:akrherz,项目名称:pals,代码行数:9,代码来源:edit_hourly.py
示例16: glob1
def glob1(dirname, pattern):
if not dirname: dirname = '.'
try:
names = posix.listdir(dirname)
except posix.error:
return []
result = []
for name in names:
if name[0] <> '.' or pattern[0] = '.':
if fnmatch.fnmatch(name, pattern): result.append(name)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:10,代码来源:glob.py
示例17: load_objects
def load_objects(self):
for filename in listdir(dirname(__file__)):
name, ext = splitext(filename)
if ext == ".py" and name != "__init__":
module = __import__(
"mio.traits.{0:s}".format(name), fromlist=["mio.traits"])
predicate = lambda x: isclass(x) and issubclass(
x, Object) and getmodule(x) is module and x is not Traits
for name, object in getmembers(module, predicate):
yield name, object
开发者ID:prologic,项目名称:mio,代码行数:10,代码来源:__init__.py
示例18: selector
def selector():
print '<form method="post" action="/cgi-bin/archivewx/page_gen.py">'
print '<select name="date">'
dates = posix.listdir(dir)
dates.sort()
for date in dates:
if date == "index.html":
blah = "1"
else:
print '<option value="'+date+'">'+date
print '</select><HR><H2>And get started:</H2>'
print '<input type="submit" value="Start exercise"></form>'
开发者ID:akrherz,项目名称:pals,代码行数:12,代码来源:index.py
示例19: sorted
def 轉規个資料夾(來源):
for 檔名 in sorted(listdir(來源), key=lambda 檔名: 檔名[2:]):
來源檔案 = join(來源, 檔名)
if 檔名.endswith('doc'):
print(檔名)
try:
for 一逝 in 轉換doc(
來源檔案
).doc轉html().html轉array().提array():
yield 一逝
except Exception as 錯誤:
print(來源檔案, 錯誤)
开发者ID:Taiwanese-Corpus,项目名称:Carstairs-Douglas_1873_chinese-english-dictionary,代码行数:12,代码来源:轉換doc.py
示例20: walk
def walk(top, func, arg):
try:
names = posix.listdir(top)
except posix.error:
return
func(arg, top, names)
exceptions = ('.', '..')
for name in names:
if name not in exceptions:
name = join(top, name)
if isdir(name) and not islink(name):
walk(name, func, arg)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:12,代码来源:posixpath.py
注:本文中的posix.listdir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论