Best Python code snippet using fMBT_python
sparsetools.py
Source:sparsetools.py  
1# -*- coding: utf-8 -*-2"""3ORIGINAL PROGRAM SOURCE CODE:41: '''52: sparsetools is not a public module in scipy.sparse, but this file is63: for backward compatibility if someone happens to use it.74: '''85: from numpy import deprecate96: 107: # This file shouldn't be imported by scipy --- Scipy code should use118: # internally scipy.sparse._sparsetools129: 1310: 1411: @deprecate(old_name="scipy.sparse.sparsetools",1512:            message=("scipy.sparse.sparsetools is a private module for scipy.sparse, "1613:                     "and should not be used."))1714: def _deprecated():1815:     pass1916: 2017: del deprecate2118: 2219: try:2320:     _deprecated()2421: except DeprecationWarning as e:2522:     # don't fail import if DeprecationWarnings raise error -- works around2623:     # the situation with Numpy's test framework2724:     pass2825: 2926: from ._sparsetools import *3027: 31"""32# Import the stypy library necessary elements33from stypy.type_inference_programs.type_inference_programs_imports import *34# Create the module type store35module_type_store = Context(None, __file__)36# ################# Begin of the type inference program ##################37str_379375 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 4, (-1)), 'str', '\nsparsetools is not a public module in scipy.sparse, but this file is\nfor backward compatibility if someone happens to use it.\n')38stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 5, 0))39# 'from numpy import deprecate' statement (line 5)40update_path_to_current_file_folder('C:/Python27/lib/site-packages/scipy/sparse/')41import_379376 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'numpy')42if (type(import_379376) is not StypyTypeError):43    if (import_379376 != 'pyd_module'):44        __import__(import_379376)45        sys_modules_379377 = sys.modules[import_379376]46        import_from_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'numpy', sys_modules_379377.module_type_store, module_type_store, ['deprecate'])47        nest_module(stypy.reporting.localization.Localization(__file__, 5, 0), __file__, sys_modules_379377, sys_modules_379377.module_type_store, module_type_store)48    else:49        from numpy import deprecate50        import_from_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'numpy', None, module_type_store, ['deprecate'], [deprecate])51else:52    # Assigning a type to the variable 'numpy' (line 5)53    module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 5, 0), 'numpy', import_379376)54remove_current_file_folder_from_path('C:/Python27/lib/site-packages/scipy/sparse/')55@norecursion56def _deprecated(localization, *varargs, **kwargs):57    global module_type_store58    # Assign values to the parameters with defaults59    defaults = []60    # Create a new context for function '_deprecated'61    module_type_store = module_type_store.open_function_context('_deprecated', 11, 0, False)62    63    # Passed parameters checking function64    _deprecated.stypy_localization = localization65    _deprecated.stypy_type_of_self = None66    _deprecated.stypy_type_store = module_type_store67    _deprecated.stypy_function_name = '_deprecated'68    _deprecated.stypy_param_names_list = []69    _deprecated.stypy_varargs_param_name = None70    _deprecated.stypy_kwargs_param_name = None71    _deprecated.stypy_call_defaults = defaults72    _deprecated.stypy_call_varargs = varargs73    _deprecated.stypy_call_kwargs = kwargs74    arguments = process_argument_values(localization, None, module_type_store, '_deprecated', [], None, None, defaults, varargs, kwargs)75    if is_error_type(arguments):76        # Destroy the current context77        module_type_store = module_type_store.close_function_context()78        return arguments79    # Initialize method data80    init_call_information(module_type_store, '_deprecated', localization, [], arguments)81    82    # Default return type storage variable (SSA)83    # Assigning a type to the variable 'stypy_return_type'84    module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)85    86    87    # ################# Begin of '_deprecated(...)' code ##################88    pass89    90    # ################# End of '_deprecated(...)' code ##################91    # Teardown call information92    teardown_call_information(localization, arguments)93    94    # Storing the return type of function '_deprecated' in the type store95    # Getting the type of 'stypy_return_type' (line 11)96    stypy_return_type_379378 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 11, 0), 'stypy_return_type')97    module_type_store.store_return_type_of_current_context(stypy_return_type_379378)98    99    # Destroy the current context100    module_type_store = module_type_store.close_function_context()101    102    # Return type of the function '_deprecated'103    return stypy_return_type_379378104# Assigning a type to the variable '_deprecated' (line 11)105module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 11, 0), '_deprecated', _deprecated)106# Deleting a member107module_type_store.del_member(stypy.reporting.localization.Localization(__file__, 17, 0), module_type_store, 'deprecate')108# SSA begins for try-except statement (line 19)109module_type_store = SSAContext.create_ssa_context(module_type_store, 'try-except')110# Call to _deprecated(...): (line 20)111# Processing the call keyword arguments (line 20)112kwargs_379380 = {}113# Getting the type of '_deprecated' (line 20)114_deprecated_379379 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 20, 4), '_deprecated', False)115# Calling _deprecated(args, kwargs) (line 20)116_deprecated_call_result_379381 = invoke(stypy.reporting.localization.Localization(__file__, 20, 4), _deprecated_379379, *[], **kwargs_379380)117# SSA branch for the except part of a try statement (line 19)118# SSA branch for the except 'DeprecationWarning' branch of a try statement (line 19)119# Storing handler type120module_type_store.open_ssa_branch('except')121# Getting the type of 'DeprecationWarning' (line 21)122DeprecationWarning_379382 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 21, 7), 'DeprecationWarning')123# Assigning a type to the variable 'e' (line 21)124module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 21, 0), 'e', DeprecationWarning_379382)125pass126# SSA join for try-except statement (line 19)127module_type_store = module_type_store.join_ssa_context()128stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 26, 0))129# 'from scipy.sparse._sparsetools import ' statement (line 26)130update_path_to_current_file_folder('C:/Python27/lib/site-packages/scipy/sparse/')131import_379383 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 26, 0), 'scipy.sparse._sparsetools')132if (type(import_379383) is not StypyTypeError):133    if (import_379383 != 'pyd_module'):134        __import__(import_379383)135        sys_modules_379384 = sys.modules[import_379383]136        import_from_module(stypy.reporting.localization.Localization(__file__, 26, 0), 'scipy.sparse._sparsetools', sys_modules_379384.module_type_store, module_type_store, ['*'])137        nest_module(stypy.reporting.localization.Localization(__file__, 26, 0), __file__, sys_modules_379384, sys_modules_379384.module_type_store, module_type_store)138    else:139        from scipy.sparse._sparsetools import *140        import_from_module(stypy.reporting.localization.Localization(__file__, 26, 0), 'scipy.sparse._sparsetools', None, module_type_store, ['*'], None)141else:142    # Assigning a type to the variable 'scipy.sparse._sparsetools' (line 26)143    module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 26, 0), 'scipy.sparse._sparsetools', import_379383)144remove_current_file_folder_from_path('C:/Python27/lib/site-packages/scipy/sparse/')145# ################# End of the type inference program ##################146module_errors = stypy.errors.type_error.StypyTypeError.get_error_msgs()...__init__.py
Source:__init__.py  
1# -*- Mode: Python; py-indent-offset: 4 -*-2# pygtk - Python bindings for the GTK toolkit.3# Copyright (C) 1998-2003  James Henstridge4#               2004-2006  Johan Dahlin5#6#   gtk/__init__.py: initialisation file for gtk package.7#8# This library is free software; you can redistribute it and/or9# modify it under the terms of the GNU Lesser General Public10# License as published by the Free Software Foundation; either11# version 2.1 of the License, or (at your option) any later version.12#13# This library is distributed in the hope that it will be useful,14# but WITHOUT ANY WARRANTY; without even the implied warranty of15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU16# Lesser General Public License for more details.17#18# You should have received a copy of the GNU Lesser General Public19# License along with this library; if not, write to the Free Software20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130121# USA22import sys23# For broken embedded programs which forgot to call Sys_SetArgv24if not hasattr(sys, 'argv'):25    sys.argv = []26# load the required modules:27import gobject as _gobject28ver = getattr(_gobject, 'pygobject_version', ())29if ver < (2, 11, 1):30    raise ImportError(31        "PyGTK requires PyGObject 2.11.1 or higher, but %s was found" % (ver,))32if 'gtk._gtk' in sys.modules:33    _gtk = sys.modules['gtk._gtk']34else:35    from gtk import _gtk36import gdk37from gtk._lazyutils import LazyNamespace, LazyModule38from gtk.deprecation import _Deprecated, _DeprecatedConstant39def _init():40    import sys41    try:42        sys_path = sys.path[:]43        try:44            _gtk.init_check()45        except RuntimeError, e:46            import warnings47            warnings.warn(str(e), _gtk.Warning)48    finally:49        # init_check calls PySys_SetArgv which calls sys.path.insert(0, ''),50        # which causes problems for pychecker, restore it if modified.51        if sys.path != sys_path:52            sys.path[:] = sys_path53    # install the default log handlers54    _gtk.add_log_handlers()55keysyms = LazyModule('keysyms', locals())56_init()57# CAPI58_PyGtk_API = _gtk._PyGtk_API59gdk.INPUT_READ      = _gobject.IO_IN | _gobject.IO_HUP | _gobject.IO_ERR60gdk.INPUT_WRITE     = _gobject.IO_OUT | _gobject.IO_HUP61gdk.INPUT_EXCEPTION = _gobject.IO_PRI62# Python 2.5+ context manager, usable through 'with' keyword.63class _Lock(object):64    __enter__ = gdk.threads_enter65    def __exit__(*ignored):66        gdk.threads_leave()67gdk.lock = _Lock()68# old names compatibility ...69idle_add       = _Deprecated(_gobject, 'idle_add', 'idle_add', 'gobject')70idle_remove    = _Deprecated(_gobject, 'source_remove', 'idle_remove', 'gobject')71timeout_add    = _Deprecated(_gobject, 'timeout_add', 'timeout_add', 'gobject')72timeout_remove = _Deprecated(_gobject, 'source_remove', 'timeout_remove',73                             'gobject')74input_add      = _Deprecated(_gobject, 'io_add_watch', 'input_add', 'gobject')75input_add_full = _Deprecated(_gobject, 'io_add_watch', 'input_add_full',76                             'gobject')77input_remove   = _Deprecated(_gobject, 'source_remove', 'input_remove', 'gobject')78mainloop                 = _Deprecated('gtk', 'main', 'mainloop')79mainquit                 = _Deprecated('gtk', 'main_quit', 'mainquit')80mainiteration            = _Deprecated('gtk', 'main_iteration',81                                       'mainiteration')82load_font                = _Deprecated(gdk, 'Font', 'load_font', 'gtk.gdk')83load_fontset             = _Deprecated(gdk, 'fontset_load', 'load_fontset',84                                       'gtk.gdk')85create_pixmap            = _Deprecated(gdk, 'Pixmap', 'create_pixmap', 'gtk.gdk')86create_pixmap_from_xpm   = _Deprecated(gdk, 'pixmap_create_from_xpm',87                                       'pixmap_create_from_xpm', 'gtk.gdk')88create_pixmap_from_xpm_d = _Deprecated(gdk, 'pixmap_create_from_xpm_d',89                                       'pixmap_create_from_xpm_d', 'gtk.gdk')90threads_init = _Deprecated(gdk, 'threads_init', 'threads_init', 'gtk.gdk')91threads_enter = _Deprecated(gdk, 'threads_enter', 'threads_enter', 'gtk.gdk')92threads_leave = _Deprecated(gdk, 'threads_leave', 'threads_leave', 'gtk.gdk')93TRUE = _DeprecatedConstant(True, 'gtk.TRUE', 'True')94FALSE = _DeprecatedConstant(False, 'gtk.FALSE', 'False')95# Can't figure out how to deprecate gdk.Warning96gdk.Warning = Warning97# We don't want to export this98del _Deprecated, _DeprecatedConstant, _gobject, _init, _Lock99# Do this as late as possible, so programs like pyflakes can check100# everything above101from gtk._gtk import *102# Make PyGTK interactive103set_interactive(1)104# # For testing, so you can just turn off dynamicnamespace in gtk.override105# if hasattr(_gtk, '_get_symbol_names'):106#     import gtk107#     ns = LazyNamespace(_gtk, locals())108#     ns.add_submodule('glade', '_glade')109#     ns.add_submodule('_gtk', 'gtk._gtk')110#     sys.modules['gtk'] = ns...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
