idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
28,800 | def convert_sbcs_model ( old_model , alphabet ) : char_to_order = { i : order for i , order in enumerate ( old_model [ 'char_to_order_map' ] ) } pos_ratio = old_model [ 'typical_positive_ratio' ] keep_ascii_letters = old_model [ 'keep_english_letter' ] curr_model = SingleByteCharSetModel ( charset_name = old_model [ 'c... | Create a SingleByteCharSetModel object representing the charset . |
28,801 | def get_py_impl ( ) : if hasattr ( sys , 'pypy_version_info' ) : pyimpl = 'PyPy' elif sys . platform . startswith ( 'java' ) : pyimpl = 'Jython' elif sys . platform == 'cli' : pyimpl = 'IronPython' else : pyimpl = 'CPython' return pyimpl | Return what kind of Python this is |
28,802 | def detect_all ( byte_str ) : if not isinstance ( byte_str , bytearray ) : if not isinstance ( byte_str , bytes ) : raise TypeError ( 'Expected object of type bytes or bytearray, got: ' '{0}' . format ( type ( byte_str ) ) ) else : byte_str = bytearray ( byte_str ) detector = UniversalDetector ( ) detector . feed ( byt... | Detect all the possible encodings of the given byte string . |
28,803 | def geojson_to_wkt ( geojson_obj , feature_number = 0 , decimals = 4 ) : if 'coordinates' in geojson_obj : geometry = geojson_obj elif 'geometry' in geojson_obj : geometry = geojson_obj [ 'geometry' ] else : geometry = geojson_obj [ 'features' ] [ feature_number ] [ 'geometry' ] def ensure_2d ( geometry ) : if isinstan... | Convert a GeoJSON object to Well - Known Text . Intended for use with OpenSearch queries . |
28,804 | def _check_scihub_response ( response , test_json = True ) : response . encoding = 'utf-8' try : response . raise_for_status ( ) if test_json : response . json ( ) except ( requests . HTTPError , ValueError ) : msg = "Invalid API response." try : msg = response . headers [ 'cause-message' ] except : try : msg = respons... | Check that the response from server has status code 2xx and that the response is valid JSON . |
28,805 | def _parse_odata_timestamp ( in_date ) : timestamp = int ( in_date . replace ( '/Date(' , '' ) . replace ( ')/' , '' ) ) seconds = timestamp // 1000 ms = timestamp % 1000 return datetime . utcfromtimestamp ( seconds ) + timedelta ( milliseconds = ms ) | Convert the timestamp received from OData JSON API to a datetime object . |
28,806 | def _parse_opensearch_response ( products ) : converters = { 'date' : _parse_iso_date , 'int' : int , 'long' : int , 'float' : float , 'double' : float } default_converter = lambda x : x output = OrderedDict ( ) for prod in products : product_dict = { } prod_id = prod [ 'id' ] output [ prod_id ] = product_dict for key ... | Convert a query response to a dictionary . |
28,807 | def query ( self , area = None , date = None , raw = None , area_relation = 'Intersects' , order_by = None , limit = None , offset = 0 , ** keywords ) : query = self . format_query ( area , date , raw , area_relation , ** keywords ) self . logger . debug ( "Running query: order_by=%s, limit=%s, offset=%s, query=%s" , o... | Query the OpenSearch API with the coordinates of an area a date interval and any other search keywords accepted by the API . |
28,808 | def format_query ( area = None , date = None , raw = None , area_relation = 'Intersects' , ** keywords ) : if area_relation . lower ( ) not in { "intersects" , "contains" , "iswithin" } : raise ValueError ( "Incorrect AOI relation provided ({})" . format ( area_relation ) ) kw_lower = set ( x . lower ( ) for x in keywo... | Create a OpenSearch API query string . |
28,809 | def count ( self , area = None , date = None , raw = None , area_relation = 'Intersects' , ** keywords ) : for kw in [ 'order_by' , 'limit' , 'offset' ] : if kw in keywords : del keywords [ kw ] query = self . format_query ( area , date , raw , area_relation , ** keywords ) _ , total_count = self . _load_query ( query ... | Get the number of products matching a query . |
28,810 | def to_geojson ( products ) : feature_list = [ ] for i , ( product_id , props ) in enumerate ( products . items ( ) ) : props = props . copy ( ) props [ 'id' ] = product_id poly = geomet . wkt . loads ( props [ 'footprint' ] ) del props [ 'footprint' ] del props [ 'gmlfootprint' ] for k , v in props . items ( ) : if is... | Return the products from a query response as a GeoJSON with the values in their appropriate Python types . |
28,811 | def to_dataframe ( products ) : try : import pandas as pd except ImportError : raise ImportError ( "to_dataframe requires the optional dependency Pandas." ) return pd . DataFrame . from_dict ( products , orient = 'index' ) | Return the products from a query response as a Pandas DataFrame with the values in their appropriate Python types . |
28,812 | def to_geodataframe ( products ) : try : import geopandas as gpd import shapely . wkt except ImportError : raise ImportError ( "to_geodataframe requires the optional dependencies GeoPandas and Shapely." ) crs = { 'init' : 'epsg:4326' } if len ( products ) == 0 : return gpd . GeoDataFrame ( crs = crs ) df = SentinelAPI ... | Return the products from a query response as a GeoPandas GeoDataFrame with the values in their appropriate Python types . |
28,813 | def get_product_odata ( self , id , full = False ) : url = urljoin ( self . api_url , u"odata/v1/Products('{}')?$format=json" . format ( id ) ) if full : url += '&$expand=Attributes' response = self . session . get ( url , auth = self . session . auth , timeout = self . timeout ) _check_scihub_response ( response ) val... | Access OData API to get info about a product . |
28,814 | def _trigger_offline_retrieval ( self , url ) : with self . session . get ( url , auth = self . session . auth , timeout = self . timeout ) as r : if r . status_code == 202 : self . logger . info ( "Accepted for retrieval" ) elif r . status_code == 503 : self . logger . error ( "Request not accepted" ) raise SentinelAP... | Triggers retrieval of an offline product |
28,815 | def download ( self , id , directory_path = '.' , checksum = True ) : product_info = self . get_product_odata ( id ) path = join ( directory_path , product_info [ 'title' ] + '.zip' ) product_info [ 'path' ] = path product_info [ 'downloaded_bytes' ] = 0 self . logger . info ( 'Downloading %s to %s' , id , path ) if ex... | Download a product . |
28,816 | def download_all ( self , products , directory_path = '.' , max_attempts = 10 , checksum = True ) : product_ids = list ( products ) self . logger . info ( "Will download %d products" , len ( product_ids ) ) return_values = OrderedDict ( ) last_exception = None for i , product_id in enumerate ( products ) : for attempt_... | Download a list of products . |
28,817 | def get_products_size ( products ) : size_total = 0 for title , props in products . items ( ) : size_product = props [ "size" ] size_value = float ( size_product . split ( " " ) [ 0 ] ) size_unit = str ( size_product . split ( " " ) [ 1 ] ) if size_unit == "MB" : size_value /= 1024. if size_unit == "KB" : size_value /=... | Return the total file size in GB of all products in the OpenSearch response . |
28,818 | def check_files ( self , paths = None , ids = None , directory = None , delete = False ) : if not ids and not paths : raise ValueError ( "Must provide either file paths or product IDs and a directory" ) if ids and not directory : raise ValueError ( "Directory value missing" ) paths = paths or [ ] ids = ids or [ ] def n... | Verify the integrity of product files on disk . |
28,819 | def _md5_compare ( self , file_path , checksum , block_size = 2 ** 13 ) : with closing ( self . _tqdm ( desc = "MD5 checksumming" , total = getsize ( file_path ) , unit = "B" , unit_scale = True ) ) as progress : md5 = hashlib . md5 ( ) with open ( file_path , "rb" ) as f : while True : block_data = f . read ( block_si... | Compare a given MD5 checksum with one calculated from a file . |
28,820 | def transaction_retry ( max_retries = 1 ) : def _outer ( fun ) : @ wraps ( fun ) def _inner ( * args , ** kwargs ) : _max_retries = kwargs . pop ( 'exception_retry_count' , max_retries ) for retries in count ( 0 ) : try : return fun ( * args , ** kwargs ) except Exception : if retries >= _max_retries : raise try : roll... | Decorator for methods doing database operations . |
28,821 | def delete_expired ( self , expires ) : meta = self . model . _meta with commit_on_success ( ) : self . get_all_expired ( expires ) . update ( hidden = True ) cursor = self . connection_for_write ( ) . cursor ( ) cursor . execute ( 'DELETE FROM {0.db_table} WHERE hidden=%s' . format ( meta ) , ( True , ) , ) | Delete all expired taskset results . |
28,822 | def get_task ( self , task_id ) : try : return self . get ( task_id = task_id ) except self . model . DoesNotExist : if self . _last_id == task_id : self . warn_if_repeatable_read ( ) self . _last_id = task_id return self . model ( task_id = task_id ) | Get task meta for task by task_id . |
28,823 | def store_result ( self , task_id , result , status , traceback = None , children = None ) : return self . update_or_create ( task_id = task_id , defaults = { 'status' : status , 'result' : result , 'traceback' : traceback , 'meta' : { 'children' : children } } ) | Store the result and status of a task . |
28,824 | def restore_taskset ( self , taskset_id ) : try : return self . get ( taskset_id = taskset_id ) except self . model . DoesNotExist : pass | Get the async result instance by taskset id . |
28,825 | def delete_taskset ( self , taskset_id ) : s = self . restore_taskset ( taskset_id ) if s : s . delete ( ) | Delete a saved taskset result . |
28,826 | def store_result ( self , taskset_id , result ) : return self . update_or_create ( taskset_id = taskset_id , defaults = { 'result' : result } ) | Store the async result instance of a taskset . |
28,827 | def _store_result ( self , task_id , result , status , traceback = None , request = None ) : self . TaskModel . _default_manager . store_result ( task_id , result , status , traceback = traceback , children = self . current_task_children ( request ) , ) return result | Store return value and status of an executed task . |
28,828 | def _save_group ( self , group_id , result ) : self . TaskSetModel . _default_manager . store_result ( group_id , result ) return result | Store the result of an executed group . |
28,829 | def _restore_group ( self , group_id ) : meta = self . TaskSetModel . _default_manager . restore_taskset ( group_id ) if meta : return meta . to_dict ( ) | Get group metadata for a group by id . |
28,830 | def cleanup ( self ) : expires = maybe_timedelta ( self . expires ) for model in self . TaskModel , self . TaskSetModel : model . _default_manager . delete_expired ( expires ) | Delete expired metadata . |
28,831 | def handle_task ( self , uuid_task , worker = None ) : uuid , task = uuid_task if task . worker and task . worker . hostname : worker = self . handle_worker ( ( task . worker . hostname , task . worker ) , ) defaults = { 'name' : task . name , 'args' : task . args , 'kwargs' : task . kwargs , 'eta' : correct_awareness ... | Handle snapshotted event . |
28,832 | def respect_language ( language ) : if language : prev = translation . get_language ( ) translation . activate ( language ) try : yield finally : translation . activate ( prev ) else : yield | Context manager that changes the current translation language for all code inside the following block . |
28,833 | def autodiscover ( ) : global _RACE_PROTECTION if _RACE_PROTECTION : return _RACE_PROTECTION = True try : return filter ( None , [ find_related_module ( app , 'tasks' ) for app in settings . INSTALLED_APPS ] ) finally : _RACE_PROTECTION = False | Include tasks for all applications in INSTALLED_APPS . |
28,834 | def find_related_module ( app , related_name ) : try : app_path = importlib . import_module ( app ) . __path__ except ImportError as exc : warn ( 'Autodiscover: Error importing %s.%s: %r' % ( app , related_name , exc , ) ) return except AttributeError : return try : f , _ , _ = imp . find_module ( related_name , app_pa... | Given an application name and a module name tries to find that module in the application . |
28,835 | def read_configuration ( self ) : self . configured = True backend = ( getattr ( settings , 'CELERY_RESULT_BACKEND' , None ) or getattr ( settings , 'CELERY_BACKEND' , None ) ) if not backend : settings . CELERY_RESULT_BACKEND = 'database' return DictAttribute ( settings ) | Load configuration from Django settings . |
28,836 | def on_task_init ( self , task_id , task ) : try : is_eager = task . request . is_eager except AttributeError : is_eager = False if not is_eager : self . close_database ( ) | Called before every task . |
28,837 | def naturaldate ( date , include_seconds = False ) : if not date : return '' right_now = now ( ) today = datetime ( right_now . year , right_now . month , right_now . day , tzinfo = right_now . tzinfo ) delta = right_now - date delta_midnight = today - date days = delta . days hours = delta . seconds // 3600 minutes = ... | Convert datetime into a human natural date string . |
28,838 | def apply ( request , task_name ) : try : task = tasks [ task_name ] except KeyError : raise Http404 ( 'apply: no such task' ) return task_view ( task ) ( request ) | View applying a task . |
28,839 | def task_status ( request , task_id ) : result = AsyncResult ( task_id ) state , retval = result . state , result . result response_data = { 'id' : task_id , 'status' : state , 'result' : retval } if state in states . EXCEPTION_STATES : traceback = result . traceback response_data . update ( { 'result' : safe_repr ( re... | Returns task status and result in JSON format . |
28,840 | def task_webhook ( fun ) : @ wraps ( fun ) def _inner ( * args , ** kwargs ) : try : retval = fun ( * args , ** kwargs ) except Exception as exc : response = { 'status' : 'failure' , 'reason' : safe_repr ( exc ) } else : response = { 'status' : 'success' , 'retval' : retval } return JsonResponse ( response ) return _in... | Decorator turning a function into a task webhook . |
28,841 | def mk_tab_context_menu ( callback_object ) : callback_object . context_menu = Gtk . Menu ( ) menu = callback_object . context_menu mi1 = Gtk . MenuItem ( _ ( "New Tab" ) ) mi1 . connect ( "activate" , callback_object . on_new_tab ) menu . add ( mi1 ) mi2 = Gtk . MenuItem ( _ ( "Rename" ) ) mi2 . connect ( "activate" ,... | Create the context menu for a notebook tab |
28,842 | def mk_notebook_context_menu ( callback_object ) : callback_object . context_menu = Gtk . Menu ( ) menu = callback_object . context_menu mi = Gtk . MenuItem ( _ ( "New Tab" ) ) mi . connect ( "activate" , callback_object . on_new_tab ) menu . add ( mi ) menu . add ( Gtk . SeparatorMenuItem ( ) ) mi = Gtk . MenuItem ( _... | Create the context menu for the notebook |
28,843 | def ontop_toggled ( self , settings , key , user_data ) : self . guake . window . set_keep_above ( settings . get_boolean ( key ) ) | If the gconf var window_ontop be changed this method will be called and will set the keep_above attribute in guake s main window . |
28,844 | def alignment_changed ( self , settings , key , user_data ) : RectCalculator . set_final_window_rect ( self . settings , self . guake . window ) self . guake . set_tab_position ( ) self . guake . force_move_if_shown ( ) | If the gconf var window_halignment be changed this method will be called and will call the move function in guake . |
28,845 | def size_changed ( self , settings , key , user_data ) : RectCalculator . set_final_window_rect ( self . settings , self . guake . window ) | If the gconf var window_height or window_width are changed this method will be called and will call the resize function in guake . |
28,846 | def cursor_blink_mode_changed ( self , settings , key , user_data ) : for term in self . guake . notebook_manager . iter_terminals ( ) : term . set_property ( "cursor-blink-mode" , settings . get_int ( key ) ) | Called when cursor blink mode settings has been changed |
28,847 | def history_size_changed ( self , settings , key , user_data ) : lines = settings . get_int ( key ) for i in self . guake . notebook_manager . iter_terminals ( ) : i . set_scrollback_lines ( lines ) | If the gconf var history_size be changed this method will be called and will set the scrollback_lines property of all terminals open . |
28,848 | def keystroke_output ( self , settings , key , user_data ) : for i in self . guake . notebook_manager . iter_terminals ( ) : i . set_scroll_on_output ( settings . get_boolean ( key ) ) | If the gconf var scroll_output be changed this method will be called and will set the scroll_on_output in all terminals open . |
28,849 | def keystroke_toggled ( self , settings , key , user_data ) : for i in self . guake . notebook_manager . iter_terminals ( ) : i . set_scroll_on_keystroke ( settings . get_boolean ( key ) ) | If the gconf var scroll_keystroke be changed this method will be called and will set the scroll_on_keystroke in all terminals open . |
28,850 | def allow_bold_toggled ( self , settings , key , user_data ) : for term in self . guake . notebook_manager . iter_terminals ( ) : term . set_allow_bold ( settings . get_boolean ( key ) ) | If the gconf var allow_bold is changed this method will be called and will change the VTE terminal o . displaying characters in bold font . |
28,851 | def bold_is_bright_toggled ( self , settings , key , user_data ) : try : for term in self . guake . notebook_manager . iter_terminals ( ) : term . set_bold_is_bright ( settings . get_boolean ( key ) ) except : log . error ( "set_bold_is_bright not supported by your version of VTE" ) | If the dconf var bold_is_bright is changed this method will be called and will change the VTE terminal to toggle auto - brightened bold text . |
28,852 | def palette_font_and_background_color_toggled ( self , settings , key , user_data ) : self . settings . styleFont . triggerOnChangedValue ( self . settings . styleFont , 'palette' ) | If the gconf var use_palette_font_and_background_color be changed this method will be called and will change the font color and the background color to the color defined in the palette . |
28,853 | def backspace_changed ( self , settings , key , user_data ) : for i in self . guake . notebook_manager . iter_terminals ( ) : i . set_backspace_binding ( self . getEraseBinding ( settings . get_string ( key ) ) ) | If the gconf var compat_backspace be changed this method will be called and will change the binding configuration in all terminals open . |
28,854 | def delete_changed ( self , settings , key , user_data ) : for i in self . guake . notebook_manager . iter_terminals ( ) : i . set_delete_binding ( self . getEraseBinding ( settings . get_string ( key ) ) ) | If the gconf var compat_delete be changed this method will be called and will change the binding configuration in all terminals open . |
28,855 | def max_tab_name_length_changed ( self , settings , key , user_data ) : if self . guake . notebook_manager . get_current_notebook ( ) . get_current_terminal ( ) is None : return if self . guake . notebook_manager . get_current_notebook ( ) . get_current_terminal ( ) . get_window_title ( ) is None : return self . guake ... | If the gconf var max_tab_name_length be changed this method will be called and will set the tab name length limit . |
28,856 | def abbreviate_tab_names_changed ( self , settings , key , user_data ) : abbreviate_tab_names = settings . get_boolean ( 'abbreviate-tab-names' ) self . guake . abbreviate = abbreviate_tab_names self . guake . recompute_tabs_titles ( ) | If the gconf var abbreviate_tab_names be changed this method will be called and will update tab names . |
28,857 | def reload_accelerators ( self , * args ) : if self . accel_group : self . guake . window . remove_accel_group ( self . accel_group ) self . accel_group = Gtk . AccelGroup ( ) self . guake . window . add_accel_group ( self . accel_group ) self . load_accelerators ( ) | Reassign an accel_group to guake main window and guake context menu and calls the load_accelerators method . |
28,858 | def bindtextdomain ( app_name , locale_dir = None ) : import locale from locale import gettext as _ log . info ( "Local binding for app '%s', local dir: %s" , app_name , locale_dir ) locale . bindtextdomain ( app_name , locale_dir ) locale . textdomain ( app_name ) | Bind the domain represented by app_name to the locale directory locale_dir . It has the effect of loading translations enabling applications for different languages . |
28,859 | def setup_standalone_signals ( instance ) : window = instance . get_widget ( 'config-window' ) window . connect ( 'delete-event' , Gtk . main_quit ) button = instance . get_widget ( 'button1' ) button . handler_block_by_func ( instance . gtk_widget_destroy ) button . connect ( 'clicked' , Gtk . main_quit ) return insta... | Called when prefs dialog is running in standalone mode . It makes the delete event of dialog and click on close button finish the application . |
28,860 | def on_default_shell_changed ( self , combo ) : citer = combo . get_active_iter ( ) if not citer : return shell = combo . get_model ( ) . get_value ( citer , 0 ) if shell == USER_SHELL_VALUE : self . settings . general . reset ( 'default-shell' ) else : self . settings . general . set_string ( 'default-shell' , shell ) | Changes the activity of default_shell in dconf |
28,861 | def on_gtk_theme_name_changed ( self , combo ) : citer = combo . get_active_iter ( ) if not citer : return theme_name = combo . get_model ( ) . get_value ( citer , 0 ) self . settings . general . set_string ( 'gtk-theme-name' , theme_name ) select_gtk_theme ( self . settings ) | Set the gtk_theme_name property in dconf |
28,862 | def on_gtk_prefer_dark_theme_toggled ( self , chk ) : self . settings . general . set_boolean ( 'gtk-prefer-dark-theme' , chk . get_active ( ) ) select_gtk_theme ( self . settings ) | Set the gtk_prefer_dark_theme property in dconf |
28,863 | def on_start_at_login_toggled ( self , chk ) : self . settings . general . set_boolean ( 'start-at-login' , chk . get_active ( ) ) refresh_user_start ( self . settings ) | Changes the activity of start_at_login in dconf |
28,864 | def on_max_tab_name_length_changed ( self , spin ) : val = int ( spin . get_value ( ) ) self . settings . general . set_int ( 'max-tab-name-length' , val ) self . prefDlg . update_vte_subwidgets_states ( ) | Changes the value of max_tab_name_length in dconf |
28,865 | def on_right_align_toggled ( self , chk ) : v = chk . get_active ( ) self . settings . general . set_int ( 'window-halignment' , 1 if v else 0 ) | set the horizontal alignment setting . |
28,866 | def on_bottom_align_toggled ( self , chk ) : v = chk . get_active ( ) self . settings . general . set_int ( 'window-valignment' , ALIGN_BOTTOM if v else ALIGN_TOP ) | set the vertical alignment setting . |
28,867 | def on_display_n_changed ( self , combo ) : i = combo . get_active_iter ( ) if not i : return model = combo . get_model ( ) first_item_path = model . get_path ( model . get_iter_first ( ) ) if model . get_path ( i ) == first_item_path : val_int = ALWAYS_ON_PRIMARY else : val = model . get_value ( i , 0 ) val_int = int ... | Set the destination display in dconf . |
28,868 | def on_window_height_value_changed ( self , hscale ) : val = hscale . get_value ( ) self . settings . general . set_int ( 'window-height' , int ( val ) ) | Changes the value of window_height in dconf |
28,869 | def on_window_width_value_changed ( self , wscale ) : val = wscale . get_value ( ) self . settings . general . set_int ( 'window-width' , int ( val ) ) | Changes the value of window_width in dconf |
28,870 | def on_window_halign_value_changed ( self , halign_button ) : which_align = { 'radiobutton_align_left' : ALIGN_LEFT , 'radiobutton_align_right' : ALIGN_RIGHT , 'radiobutton_align_center' : ALIGN_CENTER } if halign_button . get_active ( ) : self . settings . general . set_int ( 'window-halignment' , which_align [ halign... | Changes the value of window_halignment in dconf |
28,871 | def on_history_size_value_changed ( self , spin ) : val = int ( spin . get_value ( ) ) self . settings . general . set_int ( 'history-size' , val ) self . _update_history_widgets ( ) | Changes the value of history_size in dconf |
28,872 | def on_transparency_value_changed ( self , hscale ) : value = hscale . get_value ( ) self . prefDlg . set_colors_from_settings ( ) self . settings . styleBackground . set_int ( 'transparency' , MAX_TRANSPARENCY - int ( value ) ) | Changes the value of background_transparency in dconf |
28,873 | def on_backspace_binding_changed ( self , combo ) : val = combo . get_active_text ( ) self . settings . general . set_string ( 'compat-backspace' , ERASE_BINDINGS [ val ] ) | Changes the value of compat_backspace in dconf |
28,874 | def on_window_vertical_displacement_value_changed ( self , spin ) : self . settings . general . set_int ( 'window-vertical-displacement' , int ( spin . get_value ( ) ) ) | Changes the value of window - vertical - displacement |
28,875 | def on_window_horizontal_displacement_value_changed ( self , spin ) : self . settings . general . set_int ( 'window-horizontal-displacement' , int ( spin . get_value ( ) ) ) | Changes the value of window - horizontal - displacement |
28,876 | def toggle_use_font_background_sensitivity ( self , chk ) : self . get_widget ( 'palette_16' ) . set_sensitive ( chk . get_active ( ) ) self . get_widget ( 'palette_17' ) . set_sensitive ( chk . get_active ( ) ) | If the user chooses to use the gnome default font configuration it means that he will not be able to use the font selector . |
28,877 | def toggle_quick_open_command_line_sensitivity ( self , chk ) : self . get_widget ( 'quick_open_command_line' ) . set_sensitive ( chk . get_active ( ) ) self . get_widget ( 'quick_open_in_current_terminal' ) . set_sensitive ( chk . get_active ( ) ) | When the user unchecks enable quick open the command line should be disabled |
28,878 | def on_cursor_shape_changed ( self , combo ) : index = combo . get_active ( ) self . settings . style . set_int ( 'cursor-shape' , index ) | Changes the value of cursor_shape in dconf |
28,879 | def set_palette_name ( self , palette_name ) : combo = self . get_widget ( 'palette_name' ) found = False log . debug ( "wanting palette: %r" , palette_name ) for i in combo . get_model ( ) : if i [ 0 ] == palette_name : combo . set_active_iter ( i . iter ) found = True break if not found : combo . set_active ( self . ... | If the given palette matches an existing one shows it in the combobox |
28,880 | def set_palette_colors ( self , palette ) : palette = palette . split ( ':' ) for i , pal in enumerate ( palette ) : x , color = Gdk . Color . parse ( pal ) self . get_widget ( 'palette_%d' % i ) . set_color ( color ) | Updates the color buttons with the given palette |
28,881 | def _load_hooks_settings ( self ) : log . debug ( "executing _load_hooks_settings" ) hook_show_widget = self . get_widget ( "hook_show" ) hook_show_setting = self . settings . hooks . get_string ( "show" ) if hook_show_widget is not None : if hook_show_setting is not None : hook_show_widget . set_text ( hook_show_setti... | load hooks settings |
28,882 | def _load_screen_settings ( self ) : combo = self . get_widget ( 'display_n' ) dest_screen = self . settings . general . get_int ( 'display-n' ) screen = self . get_widget ( 'config-window' ) . get_screen ( ) n_screens = screen . get_n_monitors ( ) if dest_screen > n_screens - 1 : self . settings . general . set_boolea... | Load screen settings |
28,883 | def populate_keys_tree ( self ) : for group in HOTKEYS : parent = self . store . append ( None , [ None , group [ 'label' ] , None , None ] ) for item in group [ 'keys' ] : if item [ 'key' ] == "show-hide" or item [ 'key' ] == "show-focus" : accel = self . settings . keybindingsGlobal . get_string ( item [ 'key' ] ) el... | Reads the HOTKEYS global variable and insert all data in the TreeStore used by the preferences window treeview . |
28,884 | def populate_display_n ( self ) : cb = self . get_widget ( 'display_n' ) screen = self . get_widget ( 'config-window' ) . get_screen ( ) cb . append_text ( "always on primary" ) for m in range ( 0 , int ( screen . get_n_monitors ( ) ) ) : if m == int ( screen . get_primary_monitor ( ) ) : cb . append_text ( str ( m ) +... | Get the number of displays and populate this drop - down box with them all . Prepend the always on primary option . |
28,885 | def on_accel_cleared ( self , cellrendereraccel , path ) : dconf_path = self . store [ path ] [ HOTKET_MODEL_INDEX_DCONF ] if dconf_path == "show-hide" : log . warn ( "Cannot disable 'show-hide' hotkey" ) self . settings . keybindingsGlobal . set_string ( dconf_path , old_accel ) else : self . store [ path ] [ HOTKET_M... | If the user tries to clear a keybinding with the backspace key this callback will be called and it just fill the model with an empty key and set the disabled string in dconf path . |
28,886 | def start_editing ( self , treeview , event ) : x , y = int ( event . x ) , int ( event . y ) ret = treeview . get_path_at_pos ( x , y ) if not ret : return False path , column , cellx , celly = ret treeview . row_activated ( path , Gtk . TreeViewColumn ( None ) ) treeview . set_cursor ( path ) return False | Make the treeview grab the focus and start editing the cell that the user has clicked to avoid confusion with two or three clicks before editing a keybinding . |
28,887 | def save_tabs_when_changed ( func ) : def wrapper ( * args , ** kwargs ) : func ( * args , ** kwargs ) log . debug ( "mom, I've been called: %s %s" , func . __name__ , func ) clsname = args [ 0 ] . __class__ . __name__ g = None if clsname == 'Guake' : g = args [ 0 ] elif getattr ( args [ 0 ] , 'get_guake' , None ) : g ... | Decorator for save - tabs - when - changed |
28,888 | def get_final_window_monitor ( cls , settings , window ) : screen = window . get_screen ( ) use_mouse = settings . general . get_boolean ( 'mouse-display' ) dest_screen = settings . general . get_int ( 'display-n' ) if use_mouse : win , x , y , _ = screen . get_root_window ( ) . get_pointer ( ) dest_screen = screen . g... | Gets the final screen number for the main window of guake . |
28,889 | def quit ( self ) : response = self . run ( ) == Gtk . ResponseType . YES self . destroy ( ) return response | Run the are you sure dialog for quitting Guake |
28,890 | def set_terminal ( self , terminal ) : if self . terminal is not None : raise RuntimeError ( "TerminalBox: terminal already set" ) self . terminal = terminal self . terminal . connect ( "grab-focus" , self . on_terminal_focus ) self . terminal . connect ( "button-press-event" , self . on_button_press , None ) self . te... | Packs the terminal widget . |
28,891 | def add_scroll_bar ( self ) : adj = self . terminal . get_vadjustment ( ) scroll = Gtk . VScrollbar ( adj ) scroll . show ( ) self . pack_start ( scroll , False , False , 0 ) | Packs the scrollbar . |
28,892 | def execute_command ( self , command , tab = None ) : if not self . get_notebook ( ) . has_page ( ) : self . add_tab ( ) if command [ - 1 ] != '\n' : command += '\n' terminal = self . get_notebook ( ) . get_current_terminal ( ) terminal . feed_child ( command ) | Execute the command in the tab . If tab is None the command will be executed in the currently selected tab . Command should end with \ n otherwise it will be appended to the string . |
28,893 | def execute_command_by_uuid ( self , tab_uuid , command ) : if command [ - 1 ] != '\n' : command += '\n' try : tab_uuid = uuid . UUID ( tab_uuid ) page_index , = ( index for index , t in enumerate ( self . get_notebook ( ) . iter_terminals ( ) ) if t . get_uuid ( ) == tab_uuid ) except ValueError : pass else : terminal... | Execute the command in the tab whose terminal has the tab_uuid uuid |
28,894 | def on_window_losefocus ( self , window , event ) : if not HidePrevention ( self . window ) . may_hide ( ) : return value = self . settings . general . get_boolean ( 'window-losefocus' ) visible = window . get_property ( 'visible' ) self . losefocus_time = get_server_time ( self . window ) if visible and value : log . ... | Hides terminal main window when it loses the focus and if the window_losefocus gconf variable is True . |
28,895 | def show_menu ( self , status_icon , button , activate_time ) : menu = self . get_widget ( 'tray-menu' ) menu . popup ( None , None , None , Gtk . StatusIcon . position_menu , button , activate_time ) | Show the tray icon menu . |
28,896 | def show_hide ( self , * args ) : log . debug ( "Show_hide called" ) if self . forceHide : self . forceHide = False return if not HidePrevention ( self . window ) . may_hide ( ) : return if not self . win_prepare ( ) : return if not self . window . get_property ( 'visible' ) : log . info ( "Showing the terminal" ) self... | Toggles the main window visibility |
28,897 | def show ( self ) : self . hidden = False window_rect = RectCalculator . set_final_window_rect ( self . settings , self . window ) self . window . stick ( ) if not self . get_notebook ( ) . has_page ( ) : self . add_tab ( ) self . window . set_keep_below ( False ) self . window . show_all ( ) self . settings . general ... | Shows the main window and grabs the focus on it . |
28,898 | def hide ( self ) : if not HidePrevention ( self . window ) . may_hide ( ) : return self . hidden = True self . get_widget ( 'window-root' ) . unstick ( ) self . window . hide ( ) | Hides the main window of the terminal and sets the visible flag to False . |
28,899 | def load_config ( self ) : self . settings . general . triggerOnChangedValue ( self . settings . general , 'use-trayicon' ) self . settings . general . triggerOnChangedValue ( self . settings . general , 'prompt-on-quit' ) self . settings . general . triggerOnChangedValue ( self . settings . general , 'prompt-on-close-... | Just a proxy for all the configuration stuff . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.