Lines Matching refs:self
2771 def converter_init(self, *, allow_fd=False, nullable=False):
2774 if self.default not in (unspecified, None):
2777 if self.c_default not in (None, 'Py_None'):
2780 self.nullable = nullable
2781 self.allow_fd = allow_fd
2783 def pre_render(self):
2789 # add self.py_name here when merging with posixmodule conversion
2790 self.c_default = 'PATH_T_INITIALIZE("{}", "{}", {}, {})'.format(
2791 self.function.name,
2792 self.name,
2793 strify(self.nullable),
2794 strify(self.allow_fd),
2797 def cleanup(self):
2798 return "path_cleanup(&" + self.name + ");\n"
2804 def converter_init(self, requires=None):
2805 if self.default in (unspecified, None):
2806 self.c_default = 'DEFAULT_DIR_FD'
2808 self.converter = requires.upper() + '_DIR_FD_CONVERTER'
2810 self.converter = 'dir_fd_converter'
2832 def converter_init(self):
2833 if self.default is not unspecified:
2835 self.c_default = 'NULL'
2837 def cleanup(self):
2838 return "Py_XDECREF(" + self.name + ");\n"
13640 DirEntry_test_mode(PyTypeObject *defining_class, DirEntry *self,
13652 os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class)
13656 return (self->win32_lstat.st_mode & S_IFMT) == S_IFLNK;
13659 if (self->d_type != DT_UNKNOWN)
13660 return self->d_type == DT_LNK;
13662 return DirEntry_test_mode(defining_class, self, 0, S_IFLNK);
13665 return DirEntry_test_mode(defining_class, self, 0, S_IFLNK);
13670 DirEntry_fetch_stat(PyObject *module, DirEntry *self, int follow_symlinks)
13677 if (!PyUnicode_FSDecoder(self->path, &ub))
13689 if (!PyUnicode_FSConverter(self->path, &ub))
13692 if (self->dir_fd != DEFAULT_DIR_FD) {
13696 result = fstatat(self->dir_fd, path, &st,
13727 return path_object_error(self->path);
13733 DirEntry_get_lstat(PyTypeObject *defining_class, DirEntry *self)
13735 if (!self->lstat) {
13738 self->lstat = _pystat_fromstructstat(module, &self->win32_lstat);
13740 self->lstat = DirEntry_fetch_stat(module, self, 0);
13743 Py_XINCREF(self->lstat);
13744 return self->lstat;
13758 os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class,
13763 return DirEntry_get_lstat(defining_class, self);
13766 if (!self->stat) {
13767 int result = os_DirEntry_is_symlink_impl(self, defining_class);
13773 self->stat = DirEntry_fetch_stat(module, self, 1);
13776 self->stat = DirEntry_get_lstat(defining_class, self);
13780 Py_XINCREF(self->stat);
13781 return self->stat;
13786 DirEntry_test_mode(PyTypeObject *defining_class, DirEntry *self,
13802 is_symlink = (self->win32_lstat.st_mode & S_IFMT) == S_IFLNK;
13805 is_symlink = self->d_type == DT_LNK;
13806 need_stat = self->d_type == DT_UNKNOWN || (follow_symlinks && is_symlink);
13812 stat = os_DirEntry_stat_impl(self, defining_class, follow_symlinks);
13842 dir_bits = self->win32_lstat.st_file_attributes & FILE_ATTRIBUTE_DIRECTORY;
13849 result = self->d_type == DT_DIR;
13851 result = self->d_type == DT_REG;
13875 os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class,
13879 return DirEntry_test_mode(defining_class, self, follow_symlinks, S_IFDIR);
13893 os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class,
13897 return DirEntry_test_mode(defining_class, self, follow_symlinks, S_IFREG);
13907 os_DirEntry_inode_impl(DirEntry *self)
13911 if (!self->got_file_index) {
13916 if (!PyUnicode_FSDecoder(self->path, &unicode))
13933 return path_object_error(self->path);
13935 self->win32_file_index = stat.st_ino;
13936 self->got_file_index = 1;
13938 static_assert(sizeof(unsigned long long) >= sizeof(self->win32_file_index),
13940 return PyLong_FromUnsignedLongLong(self->win32_file_index);
13942 static_assert(sizeof(unsigned long long) >= sizeof(self->d_ino),
13944 return PyLong_FromUnsignedLongLong(self->d_ino);
13949 DirEntry_repr(DirEntry *self)
13951 return PyUnicode_FromFormat("<DirEntry %R>", self->name);
13961 os_DirEntry___fspath___impl(DirEntry *self)
13964 Py_INCREF(self->path);
13965 return self->path;
14356 ScandirIterator_close(ScandirIterator *self, PyObject *args)
14358 ScandirIterator_closedir(self);
14363 ScandirIterator_enter(PyObject *self, PyObject *args)
14365 Py_INCREF(self);
14366 return self;
14370 ScandirIterator_exit(ScandirIterator *self, PyObject *args)
14372 ScandirIterator_closedir(self);
14435 // PyType_GetModule(Py_TYPE(self)) doesn't work on a subclass instance.