Python os.pathconf() Examples

The following are code examples for showing how to use os.pathconf(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: click-configfile   Author: click-contrib   File: path.py    (license) View Source Project 5 votes vote down vote up
def pathconf(self, name):
            """ .. seealso:: :func:`os.pathconf` """
            return os.pathconf(self, name)

    #
    # --- Modifying operations on files and directories 
Example 2
Project: web_ctp   Author: molebot   File: test_os.py    (license) View Source Project 5 votes vote down vote up
def test_fpathconf(self):
        if hasattr(os, "fpathconf"):
            self.check(os.pathconf, "PC_NAME_MAX")
            self.check(os.fpathconf, "PC_NAME_MAX") 
Example 3
Project: click-configfile   Author: jenisys   File: path.py    (license) View Source Project 5 votes vote down vote up
def pathconf(self, name):
            """ .. seealso:: :func:`os.pathconf` """
            return os.pathconf(self, name)

    #
    # --- Modifying operations on files and directories 
Example 4
Project: ouroboros   Author: pybee   File: test_os.py    (license) View Source Project 5 votes vote down vote up
def test_fpathconf(self):
        self.check(os.pathconf, "PC_NAME_MAX")
        self.check(os.fpathconf, "PC_NAME_MAX") 
Example 5
Project: tissuelab   Author: VirtualPlants   File: path.py    (license) View Source Project 5 votes vote down vote up
def pathconf(self, name):
            return os.pathconf(self, name)


    # --- Modifying operations on files and directories 
Example 6
Project: kbe_server   Author: xiaohaoppy   File: test_os.py    (license) View Source Project 5 votes vote down vote up
def test_fpathconf(self):
        self.check(os.pathconf, "PC_NAME_MAX")
        self.check(os.fpathconf, "PC_NAME_MAX") 
Example 7
Project: python-flask-security   Author: weinbergdavid   File: downloads.py    (license) View Source Project 5 votes vote down vote up
def get_filename_max_length(directory):
    max_len = 255
    try:
        pathconf = os.pathconf
    except AttributeError:
        pass  # non-posix
    else:
        try:
            max_len = pathconf(directory, 'PC_NAME_MAX')
        except OSError as e:
            if e.errno != errno.EINVAL:
                raise
    return max_len 
Example 8
Project: pyfilesystem2   Author: PyFilesystem   File: osfs.py    (license) View Source Project 4 votes vote down vote up
def __init__(self,
                 root_path,
                 create=False,
                 create_mode=0o777):
        """Create an OSFS instance.
        """
        super(OSFS, self).__init__()
        root_path = fsdecode(fspath(root_path))
        _root_path = os.path.expanduser(os.path.expandvars(root_path))
        _root_path = os.path.normpath(os.path.abspath(_root_path))
        self.root_path = _root_path

        if create:
            try:
                if not os.path.isdir(_root_path):
                    os.makedirs(_root_path, mode=create_mode)
            except OSError as error:
                raise errors.CreateFailed(
                    'unable to create {} ({})'.format(root_path, error)
                )
        else:
            if not os.path.isdir(_root_path):
                raise errors.CreateFailed(
                    'root path does not exist'
                )

        _meta = self._meta = {
            'case_insensitive': os.path.normcase('Aa') != 'aa',
            'network': False,
            'read_only': False,
            'supports_rename': True,
            'thread_safe': True,
            'unicode_paths': os.path.supports_unicode_filenames,
            'virtual': False,
        }

        if _WINDOWS_PLATFORM:  # pragma: nocover
            _meta["invalid_path_chars"] =\
                ''.join(six.unichr(n) for n in range(31)) + '\\:*?"<>|'
        else:
            _meta["invalid_path_chars"] = '\0'

            if 'PC_PATH_MAX' in os.pathconf_names:
                _meta['max_sys_path_length'] = (
                    os.pathconf(
                        fsencode(_root_path),
                        os.pathconf_names['PC_PATH_MAX']
                    )
                )