How to use the pathlib.PosixPath function in pathlib

To help you get started, we’ve selected a few pathlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / buck / third-party / py / pathlib / test_pathlib.py View on Github external
def test_unsupported_flavour(self):
        if os.name == 'nt':
            self.assertRaises(NotImplementedError, pathlib.PosixPath)
        else:
            self.assertRaises(NotImplementedError, pathlib.WindowsPath)
github emilkarlen / exactly / test / exactly_lib_test / type_system / data / path_description.py View on Github external
def _expected_str(self, directory_name: str, path_suffix: PathPartDdv) -> str:
        return str(pathlib.PosixPath(directory_name, path_suffix.value()))
github oddjobz / pynndb / pynndb_shell / __init__.py View on Github external
def __init__(self):
        super().__init__()
        path = PosixPath('~/.pynndb').expanduser()
        Path.mkdir(path, exist_ok=True)
        if not path.is_dir():
            self.pfeedback('error: unable to open configuration folder')
            exit(1)
        self._data = path / 'local_data'
        self._base = path / 'registered'
        self._line = path / '.readline_history'
        Path.mkdir(self._data, exist_ok=True)
        Path.mkdir(self._base, exist_ok=True)
        if not self._data.is_dir() or not self._base.is_dir():
            self.pfeedback('error: unable to open configuration folder')
            exit(1)

        self.settable.update({'limit': 'The maximum number of records to return'})
        self.prompt = self._default_prompt
github steemit / sbds / sbds / storages / fs / __init__.py View on Github external
def __dirs(self):
        prefix_permutations = it.permutations(CHARS, 4)
        for perm in prefix_permutations:
            yield pathlib.PosixPath(self.base_path, f'{perm[0]}{perm[1]}/{perm[2]}{perm[3]}')
github steemit / sbds / sbds / storages / fs / cli.py View on Github external
def key(block_num, name, base_path):
    block_num_sha = hashlib.sha1(bytes(block_num)).hexdigest()
    return pathlib.PosixPath(os.path.join(
        base_path, block_num_sha[:2], block_num_sha[2:4], block_num_sha[4:6], str(block_num), f'{name}'))
github Abjad / abjad / abjad / segments / Path.py View on Github external
from abjad.system.LilyPondFormatManager import LilyPondFormatManager
from abjad.system.Tag import Tag
from abjad.top.activate import activate
from abjad.top.attach import attach
from abjad.top.deactivate import deactivate
from abjad.top.iterate import iterate
from abjad.utilities.CyclicTuple import CyclicTuple
from abjad.utilities.OrderedDict import OrderedDict
from abjad.utilities.String import String

from .Line import Line
from .Part import Part
from .PartManifest import PartManifest


class Path(pathlib.PosixPath):
    """
    Path in an Abjad score package.

    ..  container:: example

        >>> path = abjad.Path(
        ...     '/path/to/scores/my_score/my_score',
        ...     scores='/path/to/scores',
        ...     )

        >>> path.materials
        Path*('/path/to/scores/my_score/my_score/materials')

        >>> instruments = path.materials / 'instruments'
        >>> instruments
        Path*('/path/to/scores/my_score/my_score/materials/instruments')
github roscisz / TensorHive / tensorhive / app / web / AppServer.py View on Github external
def _inject_api_endpoint_to_app():
    '''
    Allows for changing API URL that web app is sending requests to.
    Web app expects API URL to be specified in `config.json`.
    The file must not exist, it will be created automatically if needed.
    '''
    try:
        web_app_json_config_path = PosixPath(__file__).parent / 'dist/static/config.json'
        data = {
            'apiPath': 'http://{}:{}/{}'.format(
                API_SERVER.HOST,
                API_SERVER.PORT,
                API.URL_PREFIX),
            'version': tensorhive.__version__,
            'apiVersion': API.VERSION
        }
        # Overwrite current file content/create file if it does not exist
        with open(str(web_app_json_config_path), 'w') as json_file:
            json.dump(data, json_file)
    except IOError as e:
        log.error('Could inject API endpoint URL, reason: ' + str(e))
    except Exception as e:
        log.critical('Unknown error: ' + str(e))
    else:
github facebookexperimental / eden / eden / integration / lib / linux.py View on Github external
def sys_fs_cgroup_path(self) -> pathlib.PosixPath:
        return pathlib.PosixPath(os.fsdecode(bytes(_cgroup_mount) + self.__name))