���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/ukubnwwtacc0unt/chapelbellstudios.com/uploads/cover/gi.tar
���ѧ٧ѧ�
_propertyhelper.py 0000644 00000035302 15204206113 0010336 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # pygobject - Python bindings for the GObject library # Copyright (C) 2007 Johan Dahlin # # gi/_propertyhelper.py: GObject property wrapper/helper # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, see <http://www.gnu.org/licenses/>. import sys import traceback from . import _gi from ._constants import \ TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \ TYPE_BOOLEAN, TYPE_INT, TYPE_UINT, TYPE_LONG, \ TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_ENUM, TYPE_FLAGS, \ TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \ TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, \ TYPE_PYOBJECT, TYPE_GTYPE, TYPE_STRV, TYPE_VARIANT G_MAXFLOAT = _gi.G_MAXFLOAT G_MAXDOUBLE = _gi.G_MAXDOUBLE G_MININT = _gi.G_MININT G_MAXINT = _gi.G_MAXINT G_MAXUINT = _gi.G_MAXUINT G_MINLONG = _gi.G_MINLONG G_MAXLONG = _gi.G_MAXLONG G_MAXULONG = _gi.G_MAXULONG if sys.version_info >= (3, 0): _basestring = str _long = int else: _basestring = basestring _long = long class Property(object): """Creates a new Property which when used in conjunction with GObject subclass will create a Python property accessor for the GObject ParamSpec. :param callable getter: getter to get the value of the property :param callable setter: setter to set the value of the property :param type type: type of property :param default: default value, must match the property type. :param str nick: short description :param str blurb: long description :param GObject.ParamFlags flags: parameter flags :keyword minimum: minimum allowed value (int, float, long only) :keyword maximum: maximum allowed value (int, float, long only) .. code-block:: python class MyObject(GObject.Object): prop = GObject.Property(type=str) obj = MyObject() obj.prop = 'value' obj.prop # now is 'value' The API is similar to the builtin :py:func:`property`: .. code-block:: python class AnotherObject(GObject.Object): value = 0 @GObject.Property def prop(self): 'Read only property.' return 1 @GObject.Property(type=int) def propInt(self): 'Read-write integer property.' return self.value @propInt.setter def propInt(self, value): self.value = value """ _type_from_pytype_lookup = { # Put long_ first in case long_ and int are the same so int clobbers long_ _long: TYPE_LONG, int: TYPE_INT, bool: TYPE_BOOLEAN, float: TYPE_DOUBLE, str: TYPE_STRING, object: TYPE_PYOBJECT, } _min_value_lookup = { TYPE_UINT: 0, TYPE_ULONG: 0, TYPE_UINT64: 0, # Remember that G_MINFLOAT and G_MINDOUBLE are something different. TYPE_FLOAT: -G_MAXFLOAT, TYPE_DOUBLE: -G_MAXDOUBLE, TYPE_INT: G_MININT, TYPE_LONG: G_MINLONG, TYPE_INT64: -2 ** 63, } _max_value_lookup = { TYPE_UINT: G_MAXUINT, TYPE_ULONG: G_MAXULONG, TYPE_INT64: 2 ** 63 - 1, TYPE_UINT64: 2 ** 64 - 1, TYPE_FLOAT: G_MAXFLOAT, TYPE_DOUBLE: G_MAXDOUBLE, TYPE_INT: G_MAXINT, TYPE_LONG: G_MAXLONG, } _default_lookup = { TYPE_INT: 0, TYPE_UINT: 0, TYPE_LONG: 0, TYPE_ULONG: 0, TYPE_INT64: 0, TYPE_UINT64: 0, TYPE_STRING: '', TYPE_FLOAT: 0.0, TYPE_DOUBLE: 0.0, } class __metaclass__(type): def __repr__(self): return "<class 'GObject.Property'>" def __init__(self, getter=None, setter=None, type=None, default=None, nick='', blurb='', flags=_gi.PARAM_READWRITE, minimum=None, maximum=None): self.name = None if type is None: type = object self.type = self._type_from_python(type) self.default = self._get_default(default) self._check_default() if not isinstance(nick, _basestring): raise TypeError("nick must be a string") self.nick = nick if not isinstance(blurb, _basestring): raise TypeError("blurb must be a string") self.blurb = blurb # Always clobber __doc__ with blurb even if blurb is empty because # we don't want the lengthy Property class documentation showing up # on instances. self.__doc__ = blurb self.flags = flags # Call after setting blurb for potential __doc__ usage. if getter and not setter: setter = self._readonly_setter elif setter and not getter: getter = self._writeonly_getter elif not setter and not getter: getter = self._default_getter setter = self._default_setter self.getter(getter) # do not call self.setter() here, as this defines the property name # already self.fset = setter if minimum is not None: if minimum < self._get_minimum(): raise TypeError( "Minimum for type %s cannot be lower than %d" % (self.type, self._get_minimum())) else: minimum = self._get_minimum() self.minimum = minimum if maximum is not None: if maximum > self._get_maximum(): raise TypeError( "Maximum for type %s cannot be higher than %d" % (self.type, self._get_maximum())) else: maximum = self._get_maximum() self.maximum = maximum self._exc = None def __repr__(self): return '<GObject Property %s (%s)>' % ( self.name or '(uninitialized)', _gi.type_name(self.type)) def __get__(self, instance, klass): if instance is None: return self self._exc = None # Simply return the result of fget directly, no need to go through GObject. # See: https://bugzilla.gnome.org/show_bug.cgi?id=723872 # We catch and print any exception occurring within the fget for compatibility # prior to the fast path addition from bug 723872, this should eventually # be removed and exceptions raised directly to the caller as in: # https://bugzilla.gnome.org/show_bug.cgi?id=575652 try: value = self.fget(instance) except Exception: traceback.print_exc() value = None if self._exc: exc = self._exc self._exc = None raise exc return value def __set__(self, instance, value): if instance is None: raise TypeError self._exc = None instance.set_property(self.name, value) if self._exc: exc = self._exc self._exc = None raise exc def __call__(self, fget): """Allows application of the getter along with init arguments.""" return self.getter(fget) def getter(self, fget): """Set the getter function to fget. For use as a decorator.""" if fget.__doc__: # Always clobber docstring and blurb with the getter docstring. self.blurb = fget.__doc__ self.__doc__ = fget.__doc__ self.fget = fget return self def setter(self, fset): """Set the setter function to fset. For use as a decorator.""" self.fset = fset # with a setter decorator, we must ignore the name of the method in # install_properties, as this does not need to be a valid property name # and does not define the property name. So set the name here. if not self.name: self.name = self.fget.__name__ return self def _type_from_python(self, type_): if type_ in self._type_from_pytype_lookup: return self._type_from_pytype_lookup[type_] elif (isinstance(type_, type) and issubclass(type_, (_gi.GObject, _gi.GEnum, _gi.GFlags, _gi.GBoxed, _gi.GInterface))): return type_.__gtype__ elif type_ in (TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, TYPE_INT, TYPE_UINT, TYPE_BOOLEAN, TYPE_LONG, TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_FLOAT, TYPE_DOUBLE, TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, TYPE_STRING, TYPE_PYOBJECT, TYPE_GTYPE, TYPE_STRV, TYPE_VARIANT): return type_ else: raise TypeError("Unsupported type: %r" % (type_,)) def _get_default(self, default): if default is not None: return default return self._default_lookup.get(self.type, None) def _check_default(self): ptype = self.type default = self.default if (ptype == TYPE_BOOLEAN and (default not in (True, False))): raise TypeError( "default must be True or False, not %r" % (default,)) elif ptype == TYPE_PYOBJECT: if default is not None: raise TypeError("object types does not have default values") elif ptype == TYPE_GTYPE: if default is not None: raise TypeError("GType types does not have default values") elif _gi.type_is_a(ptype, TYPE_ENUM): if default is None: raise TypeError("enum properties needs a default value") elif not _gi.type_is_a(default, ptype): raise TypeError("enum value %s must be an instance of %r" % (default, ptype)) elif _gi.type_is_a(ptype, TYPE_FLAGS): if not _gi.type_is_a(default, ptype): raise TypeError("flags value %s must be an instance of %r" % (default, ptype)) elif _gi.type_is_a(ptype, TYPE_STRV) and default is not None: if not isinstance(default, list): raise TypeError("Strv value %s must be a list" % repr(default)) for val in default: if type(val) not in (str, bytes): raise TypeError("Strv value %s must contain only strings" % str(default)) elif _gi.type_is_a(ptype, TYPE_VARIANT) and default is not None: if not hasattr(default, '__gtype__') or not _gi.type_is_a(default, TYPE_VARIANT): raise TypeError("variant value %s must be an instance of %r" % (default, ptype)) def _get_minimum(self): return self._min_value_lookup.get(self.type, None) def _get_maximum(self): return self._max_value_lookup.get(self.type, None) # # Getter and Setter # def _default_setter(self, instance, value): setattr(instance, '_property_helper_' + self.name, value) def _default_getter(self, instance): return getattr(instance, '_property_helper_' + self.name, self.default) def _readonly_setter(self, instance, value): self._exc = TypeError("%s property of %s is read-only" % ( self.name, type(instance).__name__)) def _writeonly_getter(self, instance): self._exc = TypeError("%s property of %s is write-only" % ( self.name, type(instance).__name__)) # # Public API # def get_pspec_args(self): ptype = self.type if ptype in (TYPE_INT, TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_FLOAT, TYPE_DOUBLE): args = self.minimum, self.maximum, self.default elif (ptype == TYPE_STRING or ptype == TYPE_BOOLEAN or ptype.is_a(TYPE_ENUM) or ptype.is_a(TYPE_FLAGS) or ptype.is_a(TYPE_VARIANT)): args = (self.default,) elif ptype in (TYPE_PYOBJECT, TYPE_GTYPE): args = () elif ptype.is_a(TYPE_OBJECT) or ptype.is_a(TYPE_BOXED): args = () else: raise NotImplementedError(ptype) return (self.type, self.nick, self.blurb) + args + (self.flags,) def install_properties(cls): """ Scans the given class for instances of Property and merges them into the classes __gproperties__ dict if it exists or adds it if not. """ gproperties = cls.__dict__.get('__gproperties__', {}) props = [] for name, prop in cls.__dict__.items(): if isinstance(prop, Property): # not same as the built-in # if a property was defined with a decorator, it may already have # a name; if it was defined with an assignment (prop = Property(...)) # we set the property's name to the member name if not prop.name: prop.name = name # we will encounter the same property multiple times in case of # custom setter methods if prop.name in gproperties: if gproperties[prop.name] == prop.get_pspec_args(): continue raise ValueError('Property %s was already found in __gproperties__' % prop.name) gproperties[prop.name] = prop.get_pspec_args() props.append(prop) if not props: return cls.__gproperties__ = gproperties if 'do_get_property' in cls.__dict__ or 'do_set_property' in cls.__dict__: for prop in props: if prop.fget != prop._default_getter or prop.fset != prop._default_setter: raise TypeError( "GObject subclass %r defines do_get/set_property" " and it also uses a property with a custom setter" " or getter. This is not allowed" % (cls.__name__,)) def obj_get_property(self, pspec): name = pspec.name.replace('-', '_') return getattr(self, name, None) cls.do_get_property = obj_get_property def obj_set_property(self, pspec, value): name = pspec.name.replace('-', '_') prop = getattr(cls, name, None) if prop: prop.fset(self, value) cls.do_set_property = obj_set_property docstring.py 0000644 00000015040 15204206113 0007104 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2013 Simon Feltman <sfeltman@gnome.org> # # docstring.py: documentation string generator for gi. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from ._gi import \ VFuncInfo, \ FunctionInfo, \ CallableInfo, \ ObjectInfo, \ StructInfo, \ Direction, \ TypeTag #: Module storage for currently registered doc string generator function. _generate_doc_string_func = None def set_doc_string_generator(func): """Set doc string generator function :param callable func: Callable which takes a GIInfoStruct and returns documentation for it. """ global _generate_doc_string_func _generate_doc_string_func = func def get_doc_string_generator(): """Returns the currently registered doc string generator.""" return _generate_doc_string_func def generate_doc_string(info): """Generate a doc string given a GIInfoStruct. :param gi.types.BaseInfo info: GI info instance to generate documentation for. :returns: Generated documentation as a string. :rtype: str This passes the info struct to the currently registered doc string generator and returns the result. """ return _generate_doc_string_func(info) _type_tag_to_py_type = {TypeTag.BOOLEAN: bool, TypeTag.INT8: int, TypeTag.UINT8: int, TypeTag.INT16: int, TypeTag.UINT16: int, TypeTag.INT32: int, TypeTag.UINT32: int, TypeTag.INT64: int, TypeTag.UINT64: int, TypeTag.FLOAT: float, TypeTag.DOUBLE: float, TypeTag.GLIST: list, TypeTag.GSLIST: list, TypeTag.ARRAY: list, TypeTag.GHASH: dict, TypeTag.UTF8: str, TypeTag.FILENAME: str, TypeTag.UNICHAR: str, TypeTag.INTERFACE: None, TypeTag.GTYPE: None, TypeTag.ERROR: None, TypeTag.VOID: None, } def _get_pytype_hint(gi_type): type_tag = gi_type.get_tag() py_type = _type_tag_to_py_type.get(type_tag, None) if py_type and hasattr(py_type, '__name__'): return py_type.__name__ elif type_tag == TypeTag.INTERFACE: iface = gi_type.get_interface() info_name = iface.get_name() if not info_name: return gi_type.get_tag_as_string() return '%s.%s' % (iface.get_namespace(), info_name) return gi_type.get_tag_as_string() def _generate_callable_info_doc(info): in_args_strs = [] if isinstance(info, VFuncInfo): in_args_strs = ['self'] elif isinstance(info, FunctionInfo): if info.is_method(): in_args_strs = ['self'] args = info.get_arguments() hint_blacklist = ('void',) # Build lists of indices prior to adding the docs because it is possible # the index retrieved comes before input arguments being used. ignore_indices = set() user_data_indices = set() for arg in args: ignore_indices.add(arg.get_destroy()) ignore_indices.add(arg.get_type().get_array_length()) user_data_indices.add(arg.get_closure()) # Build input argument strings for i, arg in enumerate(args): if arg.get_direction() == Direction.OUT: continue # skip exclusively output args if i in ignore_indices: continue argstr = arg.get_name() hint = _get_pytype_hint(arg.get_type()) if hint not in hint_blacklist: argstr += ':' + hint if arg.may_be_null() or i in user_data_indices: # allow-none or user_data from a closure argstr += '=None' elif arg.is_optional(): argstr += '=<optional>' in_args_strs.append(argstr) in_args_str = ', '.join(in_args_strs) # Build return + output argument strings out_args_strs = [] return_hint = _get_pytype_hint(info.get_return_type()) if not info.skip_return() and return_hint and return_hint not in hint_blacklist: argstr = return_hint if info.may_return_null(): argstr += ' or None' out_args_strs.append(argstr) for i, arg in enumerate(args): if arg.get_direction() == Direction.IN: continue # skip exclusively input args if i in ignore_indices: continue argstr = arg.get_name() hint = _get_pytype_hint(arg.get_type()) if hint not in hint_blacklist: argstr += ':' + hint out_args_strs.append(argstr) if out_args_strs: return '%s(%s) -> %s' % (info.__name__, in_args_str, ', '.join(out_args_strs)) else: return '%s(%s)' % (info.__name__, in_args_str) def _generate_class_info_doc(info): header = '\n:Constructors:\n\n::\n\n' # start with \n to avoid auto indent of other lines doc = '' if isinstance(info, StructInfo): # Don't show default constructor for disguised (0 length) structs if info.get_size() > 0: doc += ' ' + info.get_name() + '()\n' else: doc += ' ' + info.get_name() + '(**properties)\n' for method_info in info.get_methods(): if method_info.is_constructor(): doc += ' ' + _generate_callable_info_doc(method_info) + '\n' if doc: return header + doc else: return '' def _generate_doc_dispatch(info): if isinstance(info, (ObjectInfo, StructInfo)): return _generate_class_info_doc(info) elif isinstance(info, CallableInfo): return _generate_callable_info_doc(info) return '' set_doc_string_generator(_generate_doc_dispatch) _error.py 0000644 00000004040 15204206113 0006376 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2014 Simon Feltman <sfeltman@gnome.org> # # _error.py: GError Python implementation # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA # NOTE: This file should not have any dependencies on introspection libs # like gi.repository.GLib because it would cause a circular dependency. # Developers wanting to use the GError class in their applications should # use gi.repository.GLib.GError class GError(RuntimeError): def __init__(self, message='unknown error', domain='pygi-error', code=0): super(GError, self).__init__(message) self.message = message self.domain = domain self.code = code def __str__(self): return "%s: %s (%d)" % (self.domain, self.message, self.code) def __repr__(self): return "%s.%s('%s', '%s', %d)" % (GError.__module__, GError.__name__, self.message, self.domain, self.code) def copy(self): return GError(self.message, self.domain, self.code) def matches(self, domain, code): """Placeholder that will be monkey patched in GLib overrides.""" raise NotImplementedError @staticmethod def new_literal(domain, message, code): """Placeholder that will be monkey patched in GLib overrides.""" raise NotImplementedError repository/__init__.py 0000644 00000002022 15204206113 0011062 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2009 Johan Dahlin <johan@gnome.org> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from __future__ import absolute_import import sys from ..importer import DynamicImporter sys.meta_path.append(DynamicImporter('gi.repository')) del DynamicImporter del sys repository/__pycache__/__init__.cpython-36.pyc 0000644 00000000445 15204206113 0015355 0 ustar 00 3 ��<_ � @ s8 d dl mZ d dlZddlmZ ejjed�� [[dS )� )�absolute_importN� )�DynamicImporterz gi.repository)Z __future__r �sysZimporterr � meta_path�append� r r � /usr/lib64/python3.6/__init__.py�<module> s repository/__pycache__/__init__.cpython-36.opt-1.pyc 0000644 00000000445 15204206113 0016314 0 ustar 00 3 ��<_ � @ s8 d dl mZ d dlZddlmZ ejjed�� [[dS )� )�absolute_importN� )�DynamicImporterz gi.repository)Z __future__r �sysZimporterr � meta_path�append� r r � /usr/lib64/python3.6/__init__.py�<module> s pygtkcompat.py 0000644 00000001376 15204206113 0007461 0 ustar 00 from __future__ import absolute_import import warnings from gi import PyGIDeprecationWarning warnings.warn('gi.pygtkcompat is being deprecated in favor of using "pygtkcompat" directly.', PyGIDeprecationWarning) # pyflakes.ignore from pygtkcompat import (enable, enable_gtk, enable_vte, enable_poppler, enable_webkit, enable_gudev, enable_gst, enable_goocanvas) __all__ = ['enable', 'enable_gtk', 'enable_vte', 'enable_poppler', 'enable_webkit', 'enable_gudev', 'enable_gst', 'enable_goocanvas'] __init__.py 0000644 00000013556 15204206113 0006661 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2005-2009 Johan Dahlin <johan@gnome.org> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from __future__ import absolute_import # support overrides in different directories than our gi module from pkgutil import extend_path __path__ = extend_path(__path__, __name__) import sys import os import importlib import types _static_binding_error = ('When using gi.repository you must not import static ' 'modules like "gobject". Please change all occurrences ' 'of "import gobject" to "from gi.repository import GObject". ' 'See: https://bugzilla.gnome.org/show_bug.cgi?id=709183') # we can't have pygobject 2 loaded at the same time we load the internal _gobject if 'gobject' in sys.modules: raise ImportError(_static_binding_error) from . import _gi from ._gi import _API from ._gi import Repository from ._gi import PyGIDeprecationWarning from ._gi import PyGIWarning _API = _API # pyflakes PyGIDeprecationWarning = PyGIDeprecationWarning PyGIWarning = PyGIWarning _versions = {} _overridesdir = os.path.join(os.path.dirname(__file__), 'overrides') # Needed for compatibility with "pygobject.h"/pygobject_init() _gobject = types.ModuleType("gi._gobject") sys.modules[_gobject.__name__] = _gobject _gobject._PyGObject_API = _gi._PyGObject_API _gobject.pygobject_version = _gi.pygobject_version version_info = _gi.pygobject_version[:] __version__ = "{0}.{1}.{2}".format(*version_info) class _DummyStaticModule(types.ModuleType): __path__ = None def __getattr__(self, name): raise AttributeError(_static_binding_error) sys.modules['glib'] = _DummyStaticModule('glib', _static_binding_error) sys.modules['gobject'] = _DummyStaticModule('gobject', _static_binding_error) sys.modules['gio'] = _DummyStaticModule('gio', _static_binding_error) sys.modules['gtk'] = _DummyStaticModule('gtk', _static_binding_error) sys.modules['gtk.gdk'] = _DummyStaticModule('gtk.gdk', _static_binding_error) def check_version(version): if isinstance(version, str): version_list = tuple(map(int, version.split("."))) else: version_list = version if version_list > version_info: raise ValueError(( "pygobject's version %s required, and available version " "%s is not recent enough") % (version, __version__) ) def require_version(namespace, version): """ Ensures the correct versions are loaded when importing `gi` modules. :param namespace: The name of module to require. :type namespace: str :param version: The version of module to require. :type version: str :raises ValueError: If module/version is already loaded, already required, or unavailable. :Example: .. code-block:: python import gi gi.require_version('Gtk', '3.0') """ repository = Repository.get_default() if sys.version_info[0] <= 2: if not isinstance(version, basestring): raise ValueError('Namespace version needs to be a string.') else: if not isinstance(version, str): raise ValueError('Namespace version needs to be a string.') if namespace in repository.get_loaded_namespaces(): loaded_version = repository.get_version(namespace) if loaded_version != version: raise ValueError('Namespace %s is already loaded with version %s' % (namespace, loaded_version)) if namespace in _versions and _versions[namespace] != version: raise ValueError('Namespace %s already requires version %s' % (namespace, _versions[namespace])) available_versions = repository.enumerate_versions(namespace) if not available_versions: raise ValueError('Namespace %s not available' % namespace) if version not in available_versions: raise ValueError('Namespace %s not available for version %s' % (namespace, version)) _versions[namespace] = version def require_versions(requires): """ Utility function for consolidating multiple `gi.require_version()` calls. :param requires: The names and versions of modules to require. :type requires: dict :Example: .. code-block:: python import gi gi.require_versions({'Gtk': '3.0', 'GLib': '2.0', 'Gio': '2.0'}) """ for module_name, module_version in requires.items(): require_version(module_name, module_version) def get_required_version(namespace): return _versions.get(namespace, None) def require_foreign(namespace, symbol=None): """Ensure the given foreign marshaling module is available and loaded. :param str namespace: Introspection namespace of the foreign module (e.g. "cairo") :param symbol: Optional symbol typename to ensure a converter exists. :type symbol: str or None :raises: ImportError :Example: .. code-block:: python import gi import cairo gi.require_foreign('cairo') """ try: _gi.require_foreign(namespace, symbol) except Exception as e: raise ImportError(str(e)) importlib.import_module('gi.repository', namespace) types.py 0000644 00000034242 15204206113 0006261 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2005-2009 Johan Dahlin <johan@gnome.org> # # types.py: base types for introspected items. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from __future__ import absolute_import import sys import warnings import re from ._constants import TYPE_INVALID from .docstring import generate_doc_string from ._gi import \ InterfaceInfo, \ ObjectInfo, \ StructInfo, \ VFuncInfo, \ register_interface_info, \ hook_up_vfunc_implementation, \ GInterface from . import _gi StructInfo, GInterface # pyflakes from . import _propertyhelper as propertyhelper from . import _signalhelper as signalhelper if (3, 0) <= sys.version_info < (3, 3): # callable not available for python 3.0 thru 3.2 def callable(obj): return hasattr(obj, '__call__') def snake_case(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() class MetaClassHelper(object): def _setup_methods(cls): for method_info in cls.__info__.get_methods(): setattr(cls, method_info.__name__, method_info) def _setup_class_methods(cls): info = cls.__info__ class_struct = info.get_class_struct() if class_struct is None: return for method_info in class_struct.get_methods(): name = method_info.__name__ # Don't mask regular methods or base class methods with TypeClass methods. if not hasattr(cls, name): setattr(cls, name, classmethod(method_info)) def _setup_fields(cls): for field_info in cls.__info__.get_fields(): name = field_info.get_name().replace('-', '_') setattr(cls, name, property(field_info.get_value, field_info.set_value)) def _setup_constants(cls): for constant_info in cls.__info__.get_constants(): name = constant_info.get_name() value = constant_info.get_value() setattr(cls, name, value) def _setup_vfuncs(cls): for vfunc_name, py_vfunc in cls.__dict__.items(): if not vfunc_name.startswith("do_") or not callable(py_vfunc): continue skip_ambiguity_check = False # If a method name starts with "do_" assume it is a vfunc, and search # in the base classes for a method with the same name to override. # Recursion is necessary as overriden methods in most immediate parent # classes may shadow vfuncs from classes higher in the hierarchy. vfunc_info = None for base in cls.__mro__: method = getattr(base, vfunc_name, None) if method is not None and isinstance(method, VFuncInfo): vfunc_info = method break if not hasattr(base, '__info__') or not hasattr(base.__info__, 'get_vfuncs'): continue base_name = snake_case(base.__info__.get_type_name()) for v in base.__info__.get_vfuncs(): if vfunc_name == 'do_%s_%s' % (base_name, v.get_name()): vfunc_info = v skip_ambiguity_check = True break if vfunc_info: break # If we did not find a matching method name in the bases, we might # be overriding an interface virtual method. Since interfaces do not # provide implementations, there will be no method attribute installed # on the object. Instead we have to search through # InterfaceInfo.get_vfuncs(). Note that the infos returned by # get_vfuncs() use the C vfunc name (ie. there is no "do_" prefix). if vfunc_info is None: vfunc_info = find_vfunc_info_in_interface(cls.__bases__, vfunc_name[len("do_"):]) if vfunc_info is not None: # Check to see if there are vfuncs with the same name in the bases. # We have no way of specifying which one we are supposed to override. if not skip_ambiguity_check: ambiguous_base = find_vfunc_conflict_in_bases(vfunc_info, cls.__bases__) if ambiguous_base is not None: base_info = vfunc_info.get_container() raise TypeError('Method %s() on class %s.%s is ambiguous ' 'with methods in base classes %s.%s and %s.%s' % (vfunc_name, cls.__info__.get_namespace(), cls.__info__.get_name(), base_info.get_namespace(), base_info.get_name(), ambiguous_base.__info__.get_namespace(), ambiguous_base.__info__.get_name() )) hook_up_vfunc_implementation(vfunc_info, cls.__gtype__, py_vfunc) def _setup_native_vfuncs(cls): # Only InterfaceInfo and ObjectInfo have the get_vfuncs() method. # We skip InterfaceInfo because interfaces have no implementations for vfuncs. # Also check if __info__ in __dict__, not hasattr('__info__', ...) # because we do not want to accidentally retrieve __info__ from a base class. class_info = cls.__dict__.get('__info__') if class_info is None or not isinstance(class_info, ObjectInfo): return # Special case skipping of vfuncs for GObject.Object because they will break # the static bindings which will try to use them. if cls.__module__ == 'gi.repository.GObject' and cls.__name__ == 'Object': return for vfunc_info in class_info.get_vfuncs(): name = 'do_%s' % vfunc_info.__name__ setattr(cls, name, vfunc_info) def find_vfunc_info_in_interface(bases, vfunc_name): for base in bases: # All wrapped interfaces inherit from GInterface. # This can be seen in IntrospectionModule.__getattr__() in module.py. # We do not need to search regular classes here, only wrapped interfaces. # We also skip GInterface, because it is not wrapped and has no __info__ attr. # Skip bases without __info__ (static _gi.GObject) if base is GInterface or\ not issubclass(base, GInterface) or\ not hasattr(base, '__info__'): continue # Only look at this classes vfuncs if it is an interface. if isinstance(base.__info__, InterfaceInfo): for vfunc in base.__info__.get_vfuncs(): if vfunc.get_name() == vfunc_name: return vfunc # Recurse into the parent classes vfunc = find_vfunc_info_in_interface(base.__bases__, vfunc_name) if vfunc is not None: return vfunc return None def find_vfunc_conflict_in_bases(vfunc, bases): for klass in bases: if not hasattr(klass, '__info__') or \ not hasattr(klass.__info__, 'get_vfuncs'): continue vfuncs = klass.__info__.get_vfuncs() vfunc_name = vfunc.get_name() for v in vfuncs: if v.get_name() == vfunc_name and v != vfunc: return klass aklass = find_vfunc_conflict_in_bases(vfunc, klass.__bases__) if aklass is not None: return aklass return None class _GObjectMetaBase(type): """Metaclass for automatically registering GObject classes.""" def __init__(cls, name, bases, dict_): type.__init__(cls, name, bases, dict_) propertyhelper.install_properties(cls) signalhelper.install_signals(cls) cls._type_register(cls.__dict__) def _type_register(cls, namespace): # don't register the class if already registered if '__gtype__' in namespace: return # Do not register a new GType for the overrides, as this would sort of # defeat the purpose of overrides... if cls.__module__.startswith('gi.overrides.'): return _gi.type_register(cls, namespace.get('__gtype_name__')) _gi._install_metaclass(_GObjectMetaBase) class GObjectMeta(_GObjectMetaBase, MetaClassHelper): """Meta class used for GI GObject based types.""" def __init__(cls, name, bases, dict_): super(GObjectMeta, cls).__init__(name, bases, dict_) is_gi_defined = False if cls.__module__ == 'gi.repository.' + cls.__info__.get_namespace(): is_gi_defined = True is_python_defined = False if not is_gi_defined and cls.__module__ != GObjectMeta.__module__: is_python_defined = True if is_python_defined: cls._setup_vfuncs() elif is_gi_defined: if isinstance(cls.__info__, ObjectInfo): cls._setup_class_methods() cls._setup_methods() cls._setup_constants() cls._setup_native_vfuncs() if isinstance(cls.__info__, ObjectInfo): cls._setup_fields() elif isinstance(cls.__info__, InterfaceInfo): register_interface_info(cls.__info__.get_g_type()) def mro(cls): return mro(cls) @property def __doc__(cls): """Meta class property which shows up on any class using this meta-class.""" if cls == GObjectMeta: return '' doc = cls.__dict__.get('__doc__', None) if doc is not None: return doc # For repository classes, dynamically generate a doc string if it wasn't overridden. if cls.__module__.startswith(('gi.repository.', 'gi.overrides')): return generate_doc_string(cls.__info__) return None def mro(C): """Compute the class precedence list (mro) according to C3, with GObject interface considerations. We override Python's MRO calculation to account for the fact that GObject classes are not affected by the diamond problem: http://en.wikipedia.org/wiki/Diamond_problem Based on http://www.python.org/download/releases/2.3/mro/ """ # TODO: If this turns out being too slow, consider using generators bases = [] bases_of_subclasses = [[C]] if C.__bases__: for base in C.__bases__: # Python causes MRO's to be calculated starting with the lowest # base class and working towards the descendant, storing the result # in __mro__ at each point. Therefore at this point we know that # we already have our base class MRO's available to us, there is # no need for us to (re)calculate them. if hasattr(base, '__mro__'): bases_of_subclasses += [list(base.__mro__)] else: warnings.warn('Mixin class %s is an old style class, please ' 'update this to derive from "object".' % base, RuntimeWarning) # For old-style classes (Python2 only), the MRO is not # easily accessible. As we do need it here, we calculate # it via recursion, according to the C3 algorithm. Using C3 # for old style classes deviates from Python's own behaviour, # but visible effects here would be a corner case triggered by # questionable design. bases_of_subclasses += [mro(base)] bases_of_subclasses += [list(C.__bases__)] while bases_of_subclasses: for subclass_bases in bases_of_subclasses: candidate = subclass_bases[0] not_head = [s for s in bases_of_subclasses if candidate in s[1:]] if not_head and GInterface not in candidate.__bases__: candidate = None # conflict, reject candidate else: break if candidate is None: raise TypeError('Cannot create a consistent method resolution ' 'order (MRO)') bases.append(candidate) for subclass_bases in bases_of_subclasses[:]: # remove candidate if subclass_bases and subclass_bases[0] == candidate: del subclass_bases[0] if not subclass_bases: bases_of_subclasses.remove(subclass_bases) return bases def nothing(*args, **kwargs): pass class StructMeta(type, MetaClassHelper): """Meta class used for GI Struct based types.""" def __init__(cls, name, bases, dict_): super(StructMeta, cls).__init__(name, bases, dict_) # Avoid touching anything else than the base class. g_type = cls.__info__.get_g_type() if g_type != TYPE_INVALID and g_type.pytype is not None: return cls._setup_fields() cls._setup_methods() for method_info in cls.__info__.get_methods(): if method_info.is_constructor() and \ method_info.__name__ == 'new' and \ (not method_info.get_arguments() or cls.__info__.get_size() == 0): cls.__new__ = staticmethod(method_info) # Boxed will raise an exception # if arguments are given to __init__ cls.__init__ = nothing break @property def __doc__(cls): if cls == StructMeta: return '' return generate_doc_string(cls.__info__) module.py 0000644 00000024121 15204206113 0006375 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab # # Copyright (C) 2007-2009 Johan Dahlin <johan@gnome.org> # # module.py: dynamic module for introspected libraries. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from __future__ import absolute_import import sys import importlib from threading import Lock _have_py3 = (sys.version_info[0] >= 3) try: maketrans = ''.maketrans except AttributeError: # fallback for Python 2 from string import maketrans import gi from ._gi import \ Repository, \ FunctionInfo, \ RegisteredTypeInfo, \ EnumInfo, \ ObjectInfo, \ InterfaceInfo, \ ConstantInfo, \ StructInfo, \ UnionInfo, \ CallbackInfo, \ Struct, \ Boxed, \ CCallback, \ enum_add, \ enum_register_new_gtype_and_add, \ flags_add, \ flags_register_new_gtype_and_add, \ GInterface from .types import \ GObjectMeta, \ StructMeta from ._constants import \ TYPE_NONE, \ TYPE_BOXED, \ TYPE_POINTER, \ TYPE_ENUM, \ TYPE_FLAGS repository = Repository.get_default() # Cache of IntrospectionModules that have been loaded. _introspection_modules = {} def get_parent_for_object(object_info): parent_object_info = object_info.get_parent() if not parent_object_info: # If we reach the end of the introspection info class hierarchy, look # for an existing wrapper on the GType and use it as a base for the # new introspection wrapper. This allows static C wrappers already # registered with the GType to be used as the introspection base # (_gi.GObject for example) gtype = object_info.get_g_type() if gtype and gtype.pytype: return gtype.pytype # Otherwise use builtins.object as the base return object namespace = parent_object_info.get_namespace() name = parent_object_info.get_name() module = importlib.import_module('gi.repository.' + namespace) return getattr(module, name) def get_interfaces_for_object(object_info): interfaces = [] for interface_info in object_info.get_interfaces(): namespace = interface_info.get_namespace() name = interface_info.get_name() module = importlib.import_module('gi.repository.' + namespace) interfaces.append(getattr(module, name)) return interfaces class IntrospectionModule(object): """An object which wraps an introspection typelib. This wrapping creates a python module like representation of the typelib using gi repository as a foundation. Accessing attributes of the module will dynamically pull them in and create wrappers for the members. These members are then cached on this introspection module. """ def __init__(self, namespace, version=None): """Might raise gi._gi.RepositoryError""" repository.require(namespace, version) self._namespace = namespace self._version = version self.__name__ = 'gi.repository.' + namespace path = repository.get_typelib_path(self._namespace) self.__path__ = [path] if _have_py3: # get_typelib_path() delivers bytes, not a string self.__path__ = [path.decode('UTF-8')] if self._version is None: self._version = repository.get_version(self._namespace) self._lock = Lock() def __getattr__(self, name): info = repository.find_by_name(self._namespace, name) if not info: raise AttributeError("%r object has no attribute %r" % ( self.__name__, name)) if isinstance(info, EnumInfo): g_type = info.get_g_type() with self._lock: wrapper = g_type.pytype if wrapper is None: if info.is_flags(): if g_type.is_a(TYPE_FLAGS): wrapper = flags_add(g_type) else: assert g_type == TYPE_NONE wrapper = flags_register_new_gtype_and_add(info) else: if g_type.is_a(TYPE_ENUM): wrapper = enum_add(g_type) else: assert g_type == TYPE_NONE wrapper = enum_register_new_gtype_and_add(info) wrapper.__info__ = info wrapper.__module__ = 'gi.repository.' + info.get_namespace() # Don't use upper() here to avoid locale specific # identifier conversion (e. g. in Turkish 'i'.upper() == 'i') # see https://bugzilla.gnome.org/show_bug.cgi?id=649165 ascii_upper_trans = maketrans( 'abcdefgjhijklmnopqrstuvwxyz', 'ABCDEFGJHIJKLMNOPQRSTUVWXYZ') for value_info in info.get_values(): value_name = value_info.get_name_unescaped().translate(ascii_upper_trans) setattr(wrapper, value_name, wrapper(value_info.get_value())) for method_info in info.get_methods(): setattr(wrapper, method_info.__name__, method_info) if g_type != TYPE_NONE: g_type.pytype = wrapper elif isinstance(info, RegisteredTypeInfo): g_type = info.get_g_type() # Create a wrapper. if isinstance(info, ObjectInfo): parent = get_parent_for_object(info) interfaces = tuple(interface for interface in get_interfaces_for_object(info) if not issubclass(parent, interface)) bases = (parent,) + interfaces metaclass = GObjectMeta elif isinstance(info, CallbackInfo): bases = (CCallback,) metaclass = GObjectMeta elif isinstance(info, InterfaceInfo): bases = (GInterface,) metaclass = GObjectMeta elif isinstance(info, (StructInfo, UnionInfo)): if g_type.is_a(TYPE_BOXED): bases = (Boxed,) elif (g_type.is_a(TYPE_POINTER) or g_type == TYPE_NONE or g_type.fundamental == g_type): bases = (Struct,) else: raise TypeError("unable to create a wrapper for %s.%s" % (info.get_namespace(), info.get_name())) metaclass = StructMeta else: raise NotImplementedError(info) with self._lock: # Check if there is already a Python wrapper that is not a parent class # of the wrapper being created. If it is a parent, it is ok to clobber # g_type.pytype with a new child class wrapper of the existing parent. # Note that the return here never occurs under normal circumstances due # to caching on the __dict__ itself. if g_type != TYPE_NONE: type_ = g_type.pytype if type_ is not None and type_ not in bases: self.__dict__[name] = type_ return type_ dict_ = { '__info__': info, '__module__': 'gi.repository.' + self._namespace, '__gtype__': g_type } wrapper = metaclass(name, bases, dict_) # Register the new Python wrapper. if g_type != TYPE_NONE: g_type.pytype = wrapper elif isinstance(info, FunctionInfo): wrapper = info elif isinstance(info, ConstantInfo): wrapper = info.get_value() else: raise NotImplementedError(info) # Cache the newly created wrapper which will then be # available directly on this introspection module instead of being # lazily constructed through the __getattr__ we are currently in. self.__dict__[name] = wrapper return wrapper def __repr__(self): path = repository.get_typelib_path(self._namespace) if _have_py3: # get_typelib_path() delivers bytes, not a string path = path.decode('UTF-8') return "<IntrospectionModule %r from %r>" % (self._namespace, path) def __dir__(self): # Python's default dir() is just dir(self.__class__) + self.__dict__.keys() result = set(dir(self.__class__)) result.update(self.__dict__.keys()) # update *set* because some repository attributes have already been # wrapped by __getattr__() and included in self.__dict__; but skip # Callback types, as these are not real objects which we can actually # get namespace_infos = repository.get_infos(self._namespace) result.update(info.get_name() for info in namespace_infos if not isinstance(info, CallbackInfo)) return list(result) def get_introspection_module(namespace): """ :Returns: An object directly wrapping the gi module without overrides. Might raise gi._gi.RepositoryError """ if namespace in _introspection_modules: return _introspection_modules[namespace] version = gi.get_required_version(namespace) module = IntrospectionModule(namespace, version) _introspection_modules[namespace] = module return module _constants.py 0000644 00000003631 15204206113 0007266 0 ustar 00 # -*- Mode: Python; py-indent-offset: 4 -*- # pygobject - Python bindings for the GObject library # Copyright (C) 2006-2007 Johan Dahlin # # gi/_constants.py: GObject type constants # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, see <http://www.gnu.org/licenses/>. from . import _gi TYPE_INVALID = _gi.TYPE_INVALID TYPE_NONE = _gi.type_from_name('void') TYPE_INTERFACE = _gi.type_from_name('GInterface') TYPE_CHAR = _gi.type_from_name('gchar') TYPE_UCHAR = _gi.type_from_name('guchar') TYPE_BOOLEAN = _gi.type_from_name('gboolean') TYPE_INT = _gi.type_from_name('gint') TYPE_UINT = _gi.type_from_name('guint') TYPE_LONG = _gi.type_from_name('glong') TYPE_ULONG = _gi.type_from_name('gulong') TYPE_INT64 = _gi.type_from_name('gint64') TYPE_UINT64 = _gi.type_from_name('guint64') TYPE_ENUM = _gi.type_from_name('GEnum') TYPE_FLAGS = _gi.type_from_name('GFlags') TYPE_FLOAT = _gi.type_from_name('gfloat') TYPE_DOUBLE = _gi.type_from_name('gdouble') TYPE_STRING = _gi.type_from_name('gchararray') TYPE_POINTER = _gi.type_from_name('gpointer') TYPE_BOXED = _gi.type_from_name('GBoxed') TYPE_PARAM = _gi.type_from_name('GParam') TYPE_OBJECT = _gi.type_from_name('GObject') TYPE_PYOBJECT = _gi.type_from_name('PyObject') TYPE_GTYPE = _gi.type_from_name('GType') TYPE_STRV = _gi.type_from_name('GStrv') TYPE_VARIANT = _gi.type_from_name('GVariant') TYPE_UNICHAR = TYPE_UINT __pycache__/_ossighelper.cpython-36.pyc 0000644 00000012276 15204206113 0014067 0 ustar 00 3 ��<_�! � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z m Z dd� Zdae dd� �Z d d � Ze� ZejZeje_ejge_ejej�ejkr�eej�ZndZdd � Ze dd� �Zdd� Zg adae dd� �ZdS )� )�print_functionN)�closing�contextmanagerc C sp t | d�r| jd� nVyddl}W n tk r> td��Y n.X | j� }|j||j�}|j||j||jB � dS )z�Ensures that the socket is not inherited by child processes Raises: EnvironmentError NotImplementedError: With Python <3.4 on Windows �set_inheritableFr Nz+Not implemented for older Python on Windows) �hasattrr �fcntl�ImportError�NotImplementedError�filenoZF_GETFDZF_SETFDZ FD_CLOEXEC)�sockr �fd�flags� r �$/usr/lib64/python3.6/_ossighelper.py�ensure_socket_not_inheritable s r Fc '