當前位置: 首頁>>代碼示例>>Python>>正文


Python path.isdir方法代碼示例

本文整理匯總了Python中os.path.isdir方法的典型用法代碼示例。如果您正苦於以下問題:Python path.isdir方法的具體用法?Python path.isdir怎麽用?Python path.isdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在os.path的用法示例。


在下文中一共展示了path.isdir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def list(self):
		dirs = []
		# TODO: error management
		for d in listdir(self.datapath):
			dp = path.join(self.datapath, d)
			if path.isdir(dp):
				dirs.append({
					"name": d,
					"path": dp,
					"mtime": datetime.datetime.fromtimestamp(path.getmtime(dp)).strftime('%d.%m.%Y %H:%M:%S')
					# "size": path.getsize(dp),
					# "hsize": self.human_size(self.get_size(dp))
				})
		
		dirs.sort(key=lambda dir: dir['name'], reverse=True)
		
		return {'status': 'success', 'data': dirs} 
開發者ID:SecPi,項目名稱:SecPi,代碼行數:19,代碼來源:alarmdata.py

示例2: find_package_dirs

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def find_package_dirs(root_path):
    """ Find python package directories in directory `root_path`

    Parameters
    ----------
    root_path : str
        Directory to search for package subdirectories

    Returns
    -------
    package_sdirs : set
        Set of strings where each is a subdirectory of `root_path`, containing
        an ``__init__.py`` file.  Paths prefixed by `root_path`
    """
    package_sdirs = set()
    for entry in os.listdir(root_path):
        fname = entry if root_path == '.' else pjoin(root_path, entry)
        if isdir(fname) and exists(pjoin(fname, '__init__.py')):
            package_sdirs.add(fname)
    return package_sdirs 
開發者ID:matthew-brett,項目名稱:delocate,代碼行數:22,代碼來源:tools.py

示例3: compile_bundle_entry

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def compile_bundle_entry(self, spec, entry):
        """
        Handler for each entry for the bundle method of the compile
        process.  This copies the source file or directory into the
        build directory.
        """

        modname, source, target, modpath = entry
        bundled_modpath = {modname: modpath}
        bundled_target = {modname: target}
        export_module_name = []
        if isfile(source):
            export_module_name.append(modname)
            copy_target = join(spec[BUILD_DIR], target)
            if not exists(dirname(copy_target)):
                makedirs(dirname(copy_target))
            shutil.copy(source, copy_target)
        elif isdir(source):
            copy_target = join(spec[BUILD_DIR], modname)
            shutil.copytree(source, copy_target)

        return bundled_modpath, bundled_target, export_module_name 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:24,代碼來源:toolchain.py

示例4: find_node_modules_basedir

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def find_node_modules_basedir(self):
        """
        Find all node_modules directories configured to be accessible
        through this driver instance.

        This is typically used for adding the direct instance, and does
        not traverse the parent directories like what Node.js does.

        Returns a list of directories that contain a 'node_modules'
        directory.
        """

        paths = []

        # First do the working dir.
        local_node_path = self.join_cwd(NODE_MODULES)
        if isdir(local_node_path):
            paths.append(local_node_path)

        # do the NODE_PATH environment variable last, as Node.js seem to
        # have these resolving just before the global.
        if self.node_path:
            paths.extend(self.node_path.split(pathsep))

        return paths 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:27,代碼來源:base.py

示例5: find_system_jdks

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def find_system_jdks():
    """
    Returns a set of valid JDK directories by searching standard locations.
    """
    bases = [
        '/Library/Java/JavaVirtualMachines',
        '/usr/lib/jvm',
        '/usr/java',
        '/usr/jdk/instances',
        r'C:\Program Files\Java'
    ]
    jdks = set()
    for base in bases:
        if isdir(base):
            for n in os.listdir(base):
                jdk = join(base, n)
                mac_jdk = join(jdk, 'Contents', 'Home')
                if isdir(mac_jdk):
                    jdk = mac_jdk
                if is_valid_jdk(jdk):
                    jdks.add(realpath(jdk))
    return jdks 
開發者ID:graalvm,項目名稱:mx,代碼行數:24,代碼來源:select_jdk.py

示例6: all_actions

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def all_actions():
    """
    Returns a list of all available actions from the *.py files in the actions directory
    :return: ist of all available action
    """
    result = []
    directory = os.getcwd()
    while True:
        if any([entry for entry in listdir(directory) if entry == ACTIONS_DIR and isdir(os.path.join(directory, entry))]):
            break
        directory = os.path.abspath(os.path.join(directory, '..'))

    actions_dir = os.path.join(directory, ACTIONS_DIR)
    for f in listdir(actions_dir):
        if isfile(join(actions_dir, f)) and f.endswith("_{}.py".format(ACTION.lower())):
            module_name = ACTION_MODULE_NAME.format(f[0:-len(".py")])
            mod = get_action_module(module_name)
            cls = _get_action_class_from_module(mod)
            if cls is not None:
                action_name = cls[0][0:-len(ACTION)]
                result.append(action_name)
    return result 
開發者ID:awslabs,項目名稱:aws-ops-automator,代碼行數:24,代碼來源:__init__.py

示例7: all_handlers

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def all_handlers():
    global __actions
    if __actions is None:
        __actions = []
        current = abspath(os.getcwd())
        while True:
            if isdir(os.path.join(current, "handlers")):
                break
            parent = dirname(current)
            if parent == current:
                # at top level
                raise Exception("Could not find handlers directory")
            else:
                current = parent

        for f in listdir(os.path.join(current, "handlers")):
            if isfile(join(current, "handlers", f)) and f.endswith("_{}.py".format(HANDLER.lower())):
                module_name = HANDLERS_MODULE_NAME.format(f[0:-len(".py")])
                m = _get_module(module_name)
                cls = _get_handler_class(m)
                if cls is not None:
                    handler_name = cls[0]
                    __actions.append(handler_name)
    return __actions 
開發者ID:awslabs,項目名稱:aws-ops-automator,代碼行數:26,代碼來源:__init__.py

示例8: cache_asset

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def cache_asset(cache_dir, cache_f, path, asset_id):
    r"""
    Caches the info for a given asset id so it can be efficiently
    served in the future.

    Parameters
    ----------
    asset_id : `str`
    The id of the asset that needs to be cached
    """
    asset_cache_dir = p.join(cache_dir, asset_id)
    if not p.isdir(asset_cache_dir):
        os.mkdir(asset_cache_dir)
    cache_f(cache_dir, path, asset_id)


# IMAGE CACHING 
開發者ID:menpo,項目名稱:landmarkerio-server,代碼行數:19,代碼來源:cache.py

示例9: init_pipeline_plugins

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def init_pipeline_plugins(plugin_dir):
    """
    Initialize the pipeline plugins which triggers the auto registering of user
    defined pipeline functions.
    1. Add the plugin_dir into sys.path.
    2. Import the file under plugin_dir that starts with "cce_plugin_" and ends
    with ".py"
    """
    if not op.isdir(plugin_dir):
        logger.warning("%s is not a directory! Pipeline plugin files won't be loaded.",
                       plugin_dir)
        return

    sys.path.append(plugin_dir)
    for file_name in next(walk(plugin_dir))[2]:
        if file_name == "__init__.py" or not file_name.startswith("cce_plugin_"):
            continue
        if file_name.endswith(".py"):
            import_plugin_file(file_name) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:21,代碼來源:plugin.py

示例10: _expand_dirs_to_files

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def _expand_dirs_to_files(files_or_dirs, recursive=False):
    files = []
    files_or_dirs = _ensure_list(files_or_dirs)
    for file_or_dir in files_or_dirs:
        file_or_dir = op.realpath(file_or_dir)
        if op.isdir(file_or_dir):
            # Skip dirnames starting with '.'
            if _to_skip(file_or_dir):
                continue
            # Recursively visit the directories and add the files.
            if recursive:
                files.extend(_expand_dirs_to_files([op.join(file_or_dir, file)
                             for file in os.listdir(file_or_dir)],
                             recursive=recursive))
            else:
                files.extend([op.join(file_or_dir, file)
                              for file in os.listdir(file_or_dir)])
        elif '*' in file_or_dir:
            files.extend(glob.glob(file_or_dir))
        else:
            files.append(file_or_dir)
    return files 
開發者ID:rossant,項目名稱:ipymd,代碼行數:24,代碼來源:scripts.py

示例11: run

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def run(self, edit, new_view=False):
        path = self.path
        filenames = self.get_selected()

        # If reuse view is turned on and the only item is a directory, refresh the existing view.
        if not new_view and reuse_view():
            if len(filenames) == 1 and isdir(join(path, filenames[0])):
                fqn = join(path, filenames[0])
                show(self.view.window(), fqn, view_id=self.view.id())
                return

        for filename in filenames:
            fqn = join(path, filename)
            if isdir(fqn):
                show(self.view.window(), fqn, ignore_existing=new_view)
            else:
                self.view.window().open_file(fqn) 
開發者ID:kublaios,項目名稱:dired,代碼行數:19,代碼來源:dired.py

示例12: _move

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def _move(self, path):
        if path == self.path:
            return

        files = self.get_marked() or self.get_selected()

        if not isabs(path):
            path = join(self.path, path)
        if not isdir(path):
            sublime.error_message('Not a valid directory: {}'.format(path))
            return

        # Move all items into the target directory.  If the target directory was also selected,
        # ignore it.
        files = self.get_marked() or self.get_selected()
        path = normpath(path)
        for filename in files:
            fqn = normpath(join(self.path, filename))
            if fqn != path:
                shutil.move(fqn, path)
        self.view.run_command('dired_refresh') 
開發者ID:kublaios,項目名稱:dired,代碼行數:23,代碼來源:dired.py

示例13: _parse_split

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def _parse_split(self, path):
        """
        Split the path into the directory to search and the prefix to match in that directory.

        If the path is completely invalid, (None, None) is returned.
        """
        prefix = ''

        if not path.endswith(os.sep):
            prefix = basename(path)
            path   = dirname(path)

        if not isdir(path):
            return (None, None)

        return (path, prefix) 
開發者ID:kublaios,項目名稱:dired,代碼行數:18,代碼來源:prompt.py

示例14: register_plugins

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def register_plugins(linter, directory):
    """load all module and package in the given directory, looking for a
    'register' function in each one, used to register pylint checkers
    """
    imported = {}
    for filename in os.listdir(directory):
        base, extension = splitext(filename)
        if base in imported or base == '__pycache__':
            continue
        if extension in PY_EXTS and base != '__init__' or (
                not extension and isdir(join(directory, base))):
            try:
                module = modutils.load_module_from_file(join(directory, filename))
            except ValueError:
                # empty module name (usually emacs auto-save files)
                continue
            except ImportError as exc:
                print("Problem importing module %s: %s" % (filename, exc),
                      file=sys.stderr)
            else:
                if hasattr(module, 'register'):
                    module.register(linter)
                    imported[base] = 1 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:25,代碼來源:utils.py

示例15: scan_diveces_airodump

# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import isdir [as 別名]
def scan_diveces_airodump(self):
        dirpath = "Settings/Dump"
        if not path.isdir(dirpath):
            makedirs(dirpath)
        self.data = {'Bssid':[], 'Essid':[], 'Channel':[]}
        exit_air = airdump_start(self.interface)
        self.fix = False
        if exit_air == None:
            self.cap = get_network_scan()
            if self.cap != None:
                for i in self.cap:
                    i = i.split("||")
                    if Refactor.check_is_mac(i[2]):
                        Headers = []
                        self.data['Channel'].append(i[0])
                        self.data['Essid'].append(i[1])
                        self.data['Bssid'].append(i[2])
                        for n, key in enumerate(self.data.keys()):
                            Headers.append(key)
                            for m, item in enumerate(self.data[key]):
                                item = QTableWidgetItem(item)
                                item.setTextAlignment(Qt.AlignVCenter | Qt.AlignCenter)
                                self.tables.setItem(m, n, item)
                    self.cap =[] 
開發者ID:wi-fi-analyzer,項目名稱:3vilTwinAttacker,代碼行數:26,代碼來源:ModuleDeauth.py


注:本文中的os.path.isdir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。