• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python posixpath.isdir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中posixpath.isdir函数的典型用法代码示例。如果您正苦于以下问题:Python isdir函数的具体用法?Python isdir怎么用?Python isdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isdir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: HandleEvent

    def HandleEvent(self, event):
        """Unified FAM event handler for DirShadow."""
        action = event.code2str()
        if event.filename[0] == '/':
            return
        epath = "".join([self.data, self.handles[event.requestID],
                         event.filename])
        if posixpath.isdir(epath):
            ident = self.handles[event.requestID] + event.filename
        else:
            ident = self.handles[event.requestID][:-1]

        if action in ['exists', 'created']:
            if posixpath.isdir(epath):
                self.AddDirectoryMonitor(epath[len(self.data):])
            if ident not in self.entries and posixpath.isfile(epath):
                dirpath = "".join([self.data, ident])
                self.entries[ident] = self.es_cls(self.filename_pattern,
                                                  dirpath,
                                                  self.es_child_cls,
                                                  self.encoding)
                self.Entries['Path'][ident] = self.entries[ident].bind_entry
            if not posixpath.isdir(epath):
                # do not pass through directory events
                self.entries[ident].handle_event(event)
        if action == 'changed' and ident in self.entries:
            self.entries[ident].handle_event(event)
        elif action == 'deleted':
            fbase = self.handles[event.requestID] + event.filename
            if fbase in self.entries:
                # a directory was deleted
                del self.entries[fbase]
                del self.Entries['Path'][fbase]
            else:
                self.entries[ident].handle_event(event)
开发者ID:mkdfh,项目名称:bcfg2-dev,代码行数:35,代码来源:Plugin.py


示例2: HandleEvent

    def HandleEvent(self, event=None):
        """
        Updates which files this plugin handles based upon filesystem events.
        Allows configuration items to be added/removed without server restarts.
        """
        action = event.code2str()
        if event.filename[0] == "/":
            return
        epath = "".join([self.data, self.handles[event.requestID], event.filename])
        if posixpath.isdir(epath):
            ident = self.handles[event.requestID] + event.filename
        else:
            ident = self.handles[event.requestID][:-1]

        fname = "".join([ident, "/", event.filename])

        if event.filename.endswith(".xml"):
            if action in ["exists", "created", "changed"]:
                if event.filename.endswith("key.xml"):
                    key_spec = dict(list(lxml.etree.parse(epath).find("Key").items()))
                    self.key_specs[ident] = {"bits": key_spec.get("bits", 2048), "type": key_spec.get("type", "rsa")}
                    self.Entries["Path"][ident] = self.get_key
                elif event.filename.endswith("cert.xml"):
                    cert_spec = dict(list(lxml.etree.parse(epath).find("Cert").items()))
                    ca = cert_spec.get("ca", "default")
                    self.cert_specs[ident] = {
                        "ca": ca,
                        "format": cert_spec.get("format", "pem"),
                        "key": cert_spec.get("key"),
                        "days": cert_spec.get("days", 365),
                        "C": cert_spec.get("c"),
                        "L": cert_spec.get("l"),
                        "ST": cert_spec.get("st"),
                        "OU": cert_spec.get("ou"),
                        "O": cert_spec.get("o"),
                        "emailAddress": cert_spec.get("emailaddress"),
                    }
                    cp = ConfigParser()
                    cp.read(self.core.cfile)
                    self.CAs[ca] = dict(cp.items("sslca_" + ca))
                    self.Entries["Path"][ident] = self.get_cert
            if action == "deleted":
                if ident in self.Entries["Path"]:
                    del self.Entries["Path"][ident]
        else:
            if action in ["exists", "created"]:
                if posixpath.isdir(epath):
                    self.AddDirectoryMonitor(epath[len(self.data) :])
                if ident not in self.entries and posixpath.isfile(epath):
                    self.entries[fname] = self.__child__(epath)
                    self.entries[fname].HandleEvent(event)
            if action == "changed":
                self.entries[fname].HandleEvent(event)
            elif action == "deleted":
                if fname in self.entries:
                    del self.entries[fname]
                else:
                    self.entries[fname].HandleEvent(event)
开发者ID:jcollie,项目名称:bcfg2,代码行数:58,代码来源:SSLCA.py


示例3: process_dir

def process_dir(source_dir, dest_dir):
    if not posixpath.isdir(dest_dir):
        os.mkdir(dest_dir)
    #print source_dir, dest_dir
    for f in os.listdir(source_dir):
        #print "process", f,
        filename_in=posixpath.join(source_dir, f)
        filename_out=posixpath.join(dest_dir, f)
        #print filename_in, filename_out
        if posixpath.isdir(filename_in):
            #print "dir"
            process_dir(filename_in, filename_out)
        else:
            #print "file"
            process_img(filename_in, filename_out)
开发者ID:pmitros,项目名称:thumbscaler,代码行数:15,代码来源:thumbs.py


示例4: add_entry

 def add_entry(self, event):
     epath = self.event_path(event)
     ident = self.event_id(event)
     if posixpath.isdir(epath):
         self.AddDirectoryMonitor(epath[len(self.data):])
     if ident not in self.entries and posixpath.isfile(epath):
         dirpath = "".join([self.data, ident])
         self.entries[ident] = self.es_cls(self.filename_pattern,
                                           dirpath,
                                           self.es_child_cls,
                                           self.encoding)
         self.Entries['Path'][ident] = self.entries[ident].bind_entry
     if not posixpath.isdir(epath):
         # do not pass through directory events
         self.entries[ident].handle_event(event)
开发者ID:espro,项目名称:bcfg2,代码行数:15,代码来源:Plugin.py


示例5: __setitem__

    def __setitem__(self, key, value):
        if key == "includes":
            if isinstance(value, list):
                value = value[0]
            for path in split(value):
                path = self._parser._interpolate("DEFAULT", None, path, self)
                path = posixpath.expanduser(path)
                if not posixpath.exists(path):
                    raise Exception, "No such configuration file: %s" % path
                if posixpath.isdir(path):
                    logging.info("Parsing config filenames from directory: %s",
                        path)
                    def walk_func(arg, directory, names):
                        for name in names:
                            path = posixpath.join(directory, name)
                            if not posixpath.isdir(path):
                                arg._parser.read(path)

                    posixpath.walk(path, walk_func, self)
                else:
                    logging.info("Parsing config filename: %s", path)
                    self._parser.read(path)

        # Environment has precedence over configuration
        elif not key.startswith("CHECKBOX") or key.upper() not in os.environ:
            super(IncludeDict, self).__setitem__(key, value)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:26,代码来源:config.py


示例6: makedirs

def makedirs(name, mode=0o777, exist_ok=False):
    """makedirs(name [, mode=0o777][, exist_ok=False])

    Super-mkdir; create a leaf directory and all intermediate ones.  Works like
    mkdir, except that any intermediate path segment (not just the rightmost)
    will be created if it does not exist. If the target directory already
    exists, raise an OSError if exist_ok is False. Otherwise no exception is
    raised.  This is recursive.

    """
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, exist_ok=exist_ok)
        except FileExistsError:
            # Defeats race condition when another thread created the path
            pass
        cdir = curdir
        if isinstance(tail, bytes):
            cdir = bytes(curdir, 'ASCII')
        if tail == cdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    try:
        mkdir(name, mode)
    except OSError:
        # Cannot rely on checking for EEXIST, since the operating system
        # could give priority to other errors like EACCES or EROFS
        if not exist_ok or not path.isdir(name):
            raise
开发者ID:Daetalus,项目名称:cpython,代码行数:31,代码来源:os.py


示例7: swap_dir

def swap_dir(rootpath, path):
    """Swap a symlink with its target directory.

    Args:
        rootpath: Rootpath for tag conversions.
        path: Path of target symlink.

    """
    target = path
    if posixpath.islink(target) and posixpath.isdir(target):
        here = target
        there = pathlib.readlink(target)
        # here is the symlink
        # there is the dir
        here_tag = tagnames.path2tag(rootpath, here)
        there_tag = tagnames.path2tag(rootpath, there)
        dtags.remove_tag(here, here_tag)
        dtags.add_tag(here, there_tag)
        os.unlink(here)
        # here is now nothing
        # there is now the dir
        os.rename(there, here)
        # here is now the dir
        # there is now nothing
        os.symlink(here, there)
    else:
        raise ValueError('{} is not a symlink to a directory'.format(target))
开发者ID:darkfeline,项目名称:dantalian,代码行数:27,代码来源:base.py


示例8: 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


示例9: UpdateListBoxes

	def UpdateListBoxes(self):
		from os import listdir
		from posixpath import isfile, isdir, join, basename
		from commands import getoutput
		from string import splitfields

		cwd = self.cwd
		self.fileLb.delete(0, self.fileLb.size())
		filter = self.filterEntry.get()
		# '*' will list recurively, we don't want that.
		if filter == '*':
			filter = ''
		cmd = "/bin/ls " + join(cwd, filter)
		cmdOutput = getoutput(cmd)
		files = splitfields(cmdOutput, "\n")
		files.sort()
		for i in range(len(files)):
			if isfile(join(cwd, files[i])):
				self.fileLb.insert('end', basename(files[i]))
		self.dirLb.delete(0, self.dirLb.size())
		files = listdir(cwd)
		files.sort()
		for i in range(len(files)):
			if isdir(join(cwd, files[i])):
				self.dirLb.insert('end', files[i])
		self.dirLabel['text'] = "Directory:" + self.cwd_print()
开发者ID:asottile,项目名称:ancient-pythons,代码行数:26,代码来源:filedlg.py


示例10: test_isdir

    def test_isdir(self):
        self.assertIs(posixpath.isdir(test_support.TESTFN), False)
        f = open(test_support.TESTFN, "wb")
        try:
            f.write("foo")
            f.close()
            self.assertIs(posixpath.isdir(test_support.TESTFN), False)
            os.remove(test_support.TESTFN)
            os.mkdir(test_support.TESTFN)
            self.assertIs(posixpath.isdir(test_support.TESTFN), True)
            os.rmdir(test_support.TESTFN)
        finally:
            if not f.close():
                f.close()

        self.assertRaises(TypeError, posixpath.isdir)
开发者ID:CaoYouXin,项目名称:myfirstapicloudapp,代码行数:16,代码来源:test_posixpath.py


示例11: makedirs

def makedirs(name, mode=0o777, exist_ok=False):
    """makedirs(path [, mode=0o777][, exist_ok=False])

    Super-mkdir; create a leaf directory and all intermediate ones.
    Works like mkdir, except that any intermediate path segment (not
    just the rightmost) will be created if it does not exist. If the
    target directory with the same mode as we specified already exists,
    raises an OSError if exist_ok is False, otherwise no exception is
    raised.  This is recursive.

    """
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, mode, exist_ok)
        except OSError as e:
            # be happy if someone already created the path
            if e.errno != errno.EEXIST:
                raise
        if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    try:
        mkdir(name, mode)
    except OSError as e:
        import stat as st
        if not (e.errno == errno.EEXIST and exist_ok and path.isdir(name) and
                st.S_IMODE(lstat(name).st_mode) == _get_masked_mode(mode)):
            raise
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:30,代码来源:os.py


示例12: delete

def delete(Home):
	for files in os.listdir(Home):
		if posixpath.isdir(Home+files+"/"):
			delete(Home+files+"/")
			os.rmdir(Home+files)
		else:
			os.remove(Home+files)
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:7,代码来源:remove.py


示例13: getAttributes

    def getAttributes(self, path):
        attributes = {}
        sys_path = "/sys%s" % path
        try:
            names = os.listdir(sys_path)
        except OSError:
            return attributes

        for name in names:
            name_path = posixpath.join(sys_path, name)
            if name[0] == "." \
               or name in ["dev", "uevent"] \
               or posixpath.isdir(name_path) \
               or posixpath.islink(name_path):
                continue

            try:
                value = open(name_path, "r").read().strip()
            except IOError:
                continue

            value = value.split("\n")[0]
            if [c for c in value if not isprint(c)]:
                continue

            attributes[name] = value

        return attributes
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:28,代码来源:udev.py


示例14: makedirs

def makedirs(name, mode=0o777, exist_ok=False):
    """makedirs(name [, mode=0o777][, exist_ok=False])

    Super-mkdir; create a leaf directory and all intermediate ones.  Works like
    mkdir, except that any intermediate path segment (not just the rightmost)
    will be created if it does not exist. If the target directory already
    exists, raise an OSError if exist_ok is False. Otherwise no exception is
    raised.  This is recursive.

    """
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, mode, exist_ok)
        except FileExistsError:
            # be happy if someone already created the path
            pass
        cdir = curdir
        if isinstance(tail, bytes):
            cdir = bytes(curdir, 'ASCII')
        if tail == cdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    try:
        mkdir(name, mode)
    except OSError as e:
        if not exist_ok or e.errno != errno.EEXIST or not path.isdir(name):
            raise
开发者ID:ztane,项目名称:jython3,代码行数:29,代码来源:os.py


示例15: Separate

 def Separate(head, List, ext):
     for files in List:
         if use.isdir(use.join(head, files)):
             Folders.append(use.join(head, files))
         else:
             if use.splitext(files) == ext:
                 Files.append(use.join(head, files))
     return Folders, Files
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:8,代码来源:opp2.py


示例16: __init__

 def __init__(self, persist, directory, directory_size=1000):
     self._directory = directory
     self._directory_size = directory_size
     self._original_persist = persist
     self._persist = persist.root_at("message-store")
     message_dir = self._message_dir()
     if not posixpath.isdir(message_dir):
         os.makedirs(message_dir)
开发者ID:bladernr,项目名称:checkbox,代码行数:8,代码来源:message.py


示例17: getallmandirs

def getallmandirs(dirs):
      mandirs = []
      for filename in dirs:
            path,name = posixpath.split(filename)
            if name == 'RCS' or name == 'sec' or name == "concepts" or name  == "SCCS" : continue
            if posixpath.isdir(filename):
                  mandirs.append(filename)
      return mandirs
开发者ID:fengyuqi,项目名称:petsc,代码行数:8,代码来源:wwwindex.py


示例18: test_swap_dir

 def test_swap_dir(self):
     with patch('dantalian.dtags.add_tag', autospec=True) as mock_add, \
          patch('dantalian.dtags.remove_tag', autospec=True) as mock_rm:
         base.swap_dir(self.root, 'bag/apple')
         self.assertTrue(posixpath.islink('apple'))
         self.assertTrue(posixpath.isdir('bag/apple'))
         mock_rm.assert_called_with('bag/apple', '//bag/apple')
         mock_add.assert_called_with('bag/apple', '//apple')
开发者ID:darkfeline,项目名称:dantalian,代码行数:8,代码来源:base_test.py


示例19: Separate

def Separate(path,List):
	Files,Folders=[],[]
	for files in List:
		if use.isdir(use.join(path,files)):
			 Folders.append(use.join(path,files))
	for files in List:
		if files not in Folders and use.splitext(files)[1]=='.jar':
			Files.append(use.join(path,files))
	return Folders,Files
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:9,代码来源:AutoGen.py


示例20: magic_list

def magic_list(args):
    rootpath = _tag_convert(args, 'path')
    path = args.path
    if posixpath.isdir(path) and args.tags:
        results = dtags.list_tags(path)
    else:
        results = base.list_links(rootpath, path)
    for item in results:
        print(item)
开发者ID:darkfeline,项目名称:dantalian,代码行数:9,代码来源:commands.py



注:本文中的posixpath.isdir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python posixpath.islink函数代码示例发布时间:2022-05-25
下一篇:
Python posixpath.isabs函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap