idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
46,300 | def convert2wkt ( self , set3D = True ) : features = self . getfeatures ( ) for feature in features : try : feature . geometry ( ) . Set3D ( set3D ) except AttributeError : dim = 3 if set3D else 2 feature . geometry ( ) . SetCoordinateDimension ( dim ) return [ feature . geometry ( ) . ExportToWkt ( ) for feature in fe... | export the geometry of each feature as a wkt string |
46,301 | def getFeatureByAttribute ( self , fieldname , attribute ) : attr = attribute . strip ( ) if isinstance ( attribute , str ) else attribute if fieldname not in self . fieldnames : raise KeyError ( 'invalid field name' ) out = [ ] self . layer . ResetReading ( ) for feature in self . layer : field = feature . GetField ( ... | get features by field attribute |
46,302 | def init_layer ( self ) : self . layer = self . vector . GetLayer ( ) self . __features = [ None ] * self . nfeatures | initialize a layer object |
46,303 | def load ( self ) : self . layer . ResetReading ( ) for i in range ( self . nfeatures ) : if self . __features [ i ] is None : self . __features [ i ] = self . layer [ i ] | load all feature into memory |
46,304 | def reproject ( self , projection ) : srs_out = crsConvert ( projection , 'osr' ) if self . srs . IsSame ( srs_out ) == 0 : coordTrans = osr . CoordinateTransformation ( self . srs , srs_out ) layername = self . layername geomType = self . geomType features = self . getfeatures ( ) feat_def = features [ 0 ] . GetDefnRe... | in - memory reprojection |
46,305 | def write ( self , outfile , format = 'ESRI Shapefile' , overwrite = True ) : ( outfilepath , outfilename ) = os . path . split ( outfile ) basename = os . path . splitext ( outfilename ) [ 0 ] driver = ogr . GetDriverByName ( format ) if os . path . exists ( outfile ) : if overwrite : driver . DeleteDataSource ( outfi... | write the Vector object to a file |
46,306 | def _init_zmq ( self , port_publish , port_subscribe ) : log . debug ( 'kernel {} publishing on port {}' '' . format ( self . analysis . id_ , port_publish ) ) self . zmq_publish = zmq . Context ( ) . socket ( zmq . PUB ) self . zmq_publish . connect ( 'tcp://127.0.0.1:{}' . format ( port_publish ) ) log . debug ( 'ker... | Initialize zmq messaging . |
46,307 | def emit ( self , signal , message , analysis_id ) : log . debug ( 'kernel {} zmq send ({}): {}' '' . format ( analysis_id , signal , message ) ) self . zmq_publish . send ( json . dumps ( { 'analysis_id' : analysis_id , 'frame' : { 'signal' : signal , 'load' : message } , } , default = json_encoder_default ) . encode ... | Emit signal to main . |
46,308 | def set_ports ( self , port0 = 0x00 , port1 = 0x00 ) : 'Writes specified value to the pins defined as output by method. Writing to input pins has no effect.' self . bus . write_byte_data ( self . address , self . CONTROL_PORT0 , port0 ) self . bus . write_byte_data ( self . address , self . CONTROL_PORT0 , port1 ) retu... | Writes specified value to the pins defined as output by method . Writing to input pins has no effect . |
46,309 | def get_gtf_db ( gtf , in_memory = False ) : db_file = gtf + '.db' if gtf . endswith ( '.gz' ) : db_file = gtf [ : - 3 ] + '.db' if file_exists ( db_file ) : return gffutils . FeatureDB ( db_file ) db_file = ':memory:' if in_memory else db_file if in_memory or not file_exists ( db_file ) : debug ( 'GTF database does no... | create a gffutils DB |
46,310 | def gtf_to_bed ( gtf , alt_out_dir = None ) : out_file = os . path . splitext ( gtf ) [ 0 ] + '.bed' if file_exists ( out_file ) : return out_file if not os . access ( os . path . dirname ( out_file ) , os . W_OK | os . X_OK ) : if not alt_out_dir : raise IOError ( 'Cannot write transcript BED output file %s' % out_fil... | create a BED file of transcript - level features with attached gene name or gene ids |
46,311 | def tx2genefile ( gtf , out_file = None ) : installed_tx2gene = os . path . join ( os . path . dirname ( gtf ) , "tx2gene.csv" ) if file_exists ( installed_tx2gene ) : return installed_tx2gene if file_exists ( out_file ) : return out_file with file_transaction ( out_file ) as tx_out_file : with open ( tx_out_file , "w"... | write out a file of transcript - > gene mappings . use the installed tx2gene . csv if it exists else write a new one out |
46,312 | def transcript_to_gene ( gtf ) : gene_lookup = { } for feature in complete_features ( get_gtf_db ( gtf ) ) : gene_id = feature . attributes . get ( 'gene_id' , [ None ] ) [ 0 ] transcript_id = feature . attributes . get ( 'transcript_id' , [ None ] ) [ 0 ] gene_lookup [ transcript_id ] = gene_id return gene_lookup | return a dictionary keyed by transcript_id of the associated gene_id |
46,313 | def set_freq ( self , fout , freq ) : hsdiv_tuple = ( 4 , 5 , 6 , 7 , 9 , 11 ) n1div_tuple = ( 1 , ) + tuple ( range ( 2 , 129 , 2 ) ) fdco_min = 5670.0 hsdiv = self . get_hs_div ( ) n1div = self . get_n1_div ( ) if abs ( ( freq - fout ) * 1e6 / fout ) > 3500 : fdco = fout * hsdiv * n1div fxtal = fdco / self . get_rfre... | Sets new output frequency required parameters are real current frequency at output and new required frequency . |
46,314 | def check_folders ( name ) : if os . getcwd ( ) . endswith ( 'analyses' ) : correct = input ( 'You are in an analyses folder. This will create ' 'another analyses folder inside this one. Do ' 'you want to continue? (y/N)' ) if correct != 'y' : return False if not os . path . exists ( os . path . join ( os . getcwd ( ) ... | Only checks and asks questions . Nothing is written to disk . |
46,315 | def create_analyses ( name , kernel = None ) : if not os . path . exists ( os . path . join ( os . getcwd ( ) , 'analyses' ) ) : os . system ( "mkdir analyses" ) init_path = os . path . join ( os . getcwd ( ) , 'analyses' , '__init__.py' ) if not os . path . exists ( init_path ) : with open ( init_path , 'w' ) as f : p... | Create an analysis with given name and suffix . |
46,316 | def create_analysis ( name , kernel , src_dir , scaffold_name ) : folder = os . path . join ( os . getcwd ( ) , 'analyses' , name ) if not os . path . exists ( folder ) : os . makedirs ( folder ) else : log . warning ( 'Analysis folder {} already exists.' . format ( folder ) ) for f in os . listdir ( src_dir ) : if f i... | Create analysis files . |
46,317 | def crsConvert ( crsIn , crsOut ) : if isinstance ( crsIn , osr . SpatialReference ) : srs = crsIn . Clone ( ) else : srs = osr . SpatialReference ( ) if isinstance ( crsIn , int ) : crsIn = 'EPSG:{}' . format ( crsIn ) if isinstance ( crsIn , str ) : try : srs . SetFromUserInput ( crsIn ) except RuntimeError : raise T... | convert between different types of spatial references |
46,318 | def haversine ( lat1 , lon1 , lat2 , lon2 ) : radius = 6371000 lat1 , lon1 , lat2 , lon2 = map ( math . radians , [ lat1 , lon1 , lat2 , lon2 ] ) a = math . sin ( ( lat2 - lat1 ) / 2 ) ** 2 + math . cos ( lat1 ) * math . cos ( lat2 ) * math . sin ( ( lon2 - lon1 ) / 2 ) ** 2 c = 2 * math . asin ( math . sqrt ( a ) ) re... | compute the distance in meters between two points in latlon |
46,319 | def gdal_rasterize ( src , dst , options ) : out = gdal . Rasterize ( dst , src , options = gdal . RasterizeOptions ( ** options ) ) out = None | a simple wrapper for gdal . Rasterize |
46,320 | def set_up_dirs ( proc_name , output_dir = None , work_dir = None , log_dir = None ) : output_dir = safe_mkdir ( adjust_path ( output_dir or join ( os . getcwd ( ) , proc_name ) ) , 'output_dir' ) debug ( 'Saving results into ' + output_dir ) work_dir = safe_mkdir ( work_dir or join ( output_dir , 'work' ) , 'working d... | Creates output_dir work_dir and sets up log |
46,321 | def _iter_content_generator ( response , decode_unicode ) : for chunk in response . iter_content ( 100 * 1024 , decode_unicode = decode_unicode ) : if decode_unicode : chunk = chunk . replace ( '\r\n' , '\n' ) chunk = chunk . rstrip ( '\r' ) yield chunk | Generator used to yield 100 KiB chunks for a given response . |
46,322 | def generic_request ( self , class_ , iter_lines = False , iter_content = False , controller = None , parse_types = False , ** kwargs ) : r if iter_lines and iter_content : raise ValueError ( 'iter_lines and iter_content cannot both be True' ) if 'format' in kwargs and parse_types : raise ValueError ( 'parse_types can ... | r Generic Space - Track query . |
46,323 | def _ratelimited_get ( self , * args , ** kwargs ) : with self . _ratelimiter : resp = self . session . get ( * args , ** kwargs ) if resp . status_code == 500 : if 'violated your query rate limit' in resp . text : until = time . time ( ) + self . _ratelimiter . period t = threading . Thread ( target = self . _ratelimi... | Perform get request handling rate limiting . |
46,324 | def _find_controller ( self , class_ ) : for controller , classes in self . request_controllers . items ( ) : if class_ in classes : return controller else : raise ValueError ( 'Unknown request class {!r}' . format ( class_ ) ) | Find first controller that matches given request class . |
46,325 | def get_predicates ( self , class_ , controller = None ) : if class_ not in self . _predicates : if controller is None : controller = self . _find_controller ( class_ ) else : classes = self . request_controllers . get ( controller , None ) if classes is None : raise ValueError ( 'Unknown request controller {!r}' . for... | Get full predicate information for given request class and cache for subsequent calls . |
46,326 | def get_predicates ( self , class_ ) : return self . client . get_predicates ( class_ = class_ , controller = self . controller ) | Proxy get_predicates to client with stored request controller . |
46,327 | def on_install ( self , editor ) : super ( FoldingPanel , self ) . on_install ( editor ) self . context_menu = QtWidgets . QMenu ( _ ( 'Folding' ) , self . editor ) action = self . action_collapse = QtWidgets . QAction ( _ ( 'Collapse' ) , self . context_menu ) action . setShortcut ( 'Shift+-' ) action . triggered . co... | Add the folding menu to the editor on install . |
46,328 | def _draw_rect ( self , rect , painter ) : c = self . _custom_color if self . _native : c = self . get_system_bck_color ( ) grad = QtGui . QLinearGradient ( rect . topLeft ( ) , rect . topRight ( ) ) if sys . platform == 'darwin' : grad . setColorAt ( 0 , c . lighter ( 100 ) ) grad . setColorAt ( 1 , c . lighter ( 110 ... | Draw the background rectangle using the current style primitive color or foldIndicatorBackground if nativeFoldingIndicator is true . |
46,329 | def get_system_bck_color ( ) : def merged_colors ( colorA , colorB , factor ) : maxFactor = 100 colorA = QtGui . QColor ( colorA ) colorB = QtGui . QColor ( colorB ) tmp = colorA tmp . setRed ( ( tmp . red ( ) * factor ) / maxFactor + ( colorB . red ( ) * ( maxFactor - factor ) ) / maxFactor ) tmp . setGreen ( ( tmp . ... | Gets a system color for drawing the fold scope background . |
46,330 | def _add_scope_decorations ( self , block , start , end ) : try : parent = FoldScope ( block ) . parent ( ) except ValueError : parent = None if TextBlockHelper . is_fold_trigger ( block ) : base_color = self . _get_scope_highlight_color ( ) factor_step = 5 if base_color . lightness ( ) < 128 : factor_step = 10 factor ... | Show a scope decoration on the editor widget |
46,331 | def _highlight_surrounding_scopes ( self , block ) : scope = FoldScope ( block ) if ( self . _current_scope is None or self . _current_scope . get_range ( ) != scope . get_range ( ) ) : self . _current_scope = scope self . _clear_scope_decos ( ) start , end = scope . get_range ( ) if not TextBlockHelper . is_collapsed ... | Highlights the scopes surrounding the current fold scope . |
46,332 | def leaveEvent ( self , event ) : super ( FoldingPanel , self ) . leaveEvent ( event ) QtWidgets . QApplication . restoreOverrideCursor ( ) self . _highlight_runner . cancel_requests ( ) if not self . highlight_caret_scope : self . _clear_scope_decos ( ) self . _mouse_over_line = None self . _current_scope = None else ... | Removes scope decorations and background from the editor and the panel if highlight_caret_scope else simply update the scope decorations to match the caret scope . |
46,333 | def verify_signature ( self , payload , headers ) : github_signature = headers . get ( "x-hub-signature" ) if not github_signature : json_abort ( 401 , "X-Hub-Signature header missing." ) gh_webhook_secret = current_app . config [ "GITHUB_WEBHOOK_SECRET" ] signature = "sha1={}" . format ( hmac . new ( gh_webhook_secret... | Verify that the payload was sent from our GitHub instance . |
46,334 | def get_options ( self ) : ( options , args ) = self . parser . parse_args ( ) visdkrc_opts = self . read_visdkrc ( ) for opt in self . config_vars : if not getattr ( options , opt ) : if visdkrc_opts : if opt in visdkrc_opts : setattr ( options , opt , visdkrc_opts [ opt ] ) for opt in self . required_opts : if opt no... | Get the options that have been set . |
46,335 | def parse_job_files ( self ) : repo_jobs = [ ] for rel_job_file_path , job_info in self . job_files . items ( ) : LOGGER . debug ( "Checking for job definitions in %s" , rel_job_file_path ) jobs = self . parse_job_definitions ( rel_job_file_path , job_info ) LOGGER . debug ( "Found %d job definitions in %s" , len ( job... | Check for job definitions in known zuul files . |
46,336 | def change_directory ( self , directory ) : self . _process . write ( ( 'cd %s\n' % directory ) . encode ( ) ) if sys . platform == 'win32' : self . _process . write ( ( os . path . splitdrive ( directory ) [ 0 ] + '\r\n' ) . encode ( ) ) self . clear ( ) else : self . _process . write ( b'\x0C' ) | Changes the current directory . |
46,337 | def icon ( self ) : if isinstance ( self . _icon , str ) : if QtGui . QIcon . hasThemeIcon ( self . _icon ) : return QtGui . QIcon . fromTheme ( self . _icon ) else : return QtGui . QIcon ( self . _icon ) elif isinstance ( self . _icon , tuple ) : return QtGui . QIcon . fromTheme ( self . _icon [ 0 ] , QtGui . QIcon ( ... | Gets the icon file name . Read - only . |
46,338 | def add_marker ( self , marker ) : self . _markers . append ( marker ) doc = self . editor . document ( ) assert isinstance ( doc , QtGui . QTextDocument ) block = doc . findBlockByLineNumber ( marker . _position ) marker . block = block d = TextDecoration ( block ) d . set_full_width ( ) if self . _background : d . se... | Adds the marker to the panel . |
46,339 | def remove_marker ( self , marker ) : self . _markers . remove ( marker ) self . _to_remove . append ( marker ) if hasattr ( marker , 'decoration' ) : self . editor . decorations . remove ( marker . decoration ) self . repaint ( ) | Removes a marker from the panel |
46,340 | def _display_tooltip ( self , tooltip , top ) : QtWidgets . QToolTip . showText ( self . mapToGlobal ( QtCore . QPoint ( self . sizeHint ( ) . width ( ) , top ) ) , tooltip , self ) | Display tooltip at the specified top position . |
46,341 | def finditer_noregex ( string , sub , whole_word ) : start = 0 while True : start = string . find ( sub , start ) if start == - 1 : return if whole_word : if start : pchar = string [ start - 1 ] else : pchar = ' ' try : nchar = string [ start + len ( sub ) ] except IndexError : nchar = ' ' if nchar in DocumentWordsProv... | Search occurrences using str . find instead of regular expressions . |
46,342 | def complete ( self , code , * args ) : completions = [ ] for word in self . split ( code , self . separators ) : completions . append ( { 'name' : word } ) return completions | Provides completions based on the document words . |
46,343 | def status_to_string ( cls , status ) : strings = { CheckerMessages . INFO : "Info" , CheckerMessages . WARNING : "Warning" , CheckerMessages . ERROR : "Error" } return strings [ status ] | Converts a message status to a string . |
46,344 | def add_messages ( self , messages ) : if len ( messages ) > self . limit : messages = messages [ : self . limit ] _logger ( self . __class__ ) . log ( 5 , 'adding %s messages' % len ( messages ) ) self . _finished = False self . _new_messages = messages self . _to_check = list ( self . _messages ) self . _pending_msg ... | Adds a message or a list of message . |
46,345 | def remove_message ( self , message ) : import time _logger ( self . __class__ ) . log ( 5 , 'removing message %s' % message ) t = time . time ( ) usd = message . block . userData ( ) if usd : try : usd . messages . remove ( message ) except ( AttributeError , ValueError ) : pass if message . decoration : self . editor... | Removes a message . |
46,346 | def clear_messages ( self ) : while len ( self . _messages ) : msg = self . _messages . pop ( 0 ) usd = msg . block . userData ( ) if usd and hasattr ( usd , 'messages' ) : usd . messages [ : ] = [ ] if msg . decoration : self . editor . decorations . remove ( msg . decoration ) | Clears all messages . |
46,347 | def _on_work_finished ( self , results ) : messages = [ ] for msg in results : msg = CheckerMessage ( * msg ) if msg . line >= self . editor . blockCount ( ) : msg . line = self . editor . blockCount ( ) - 1 block = self . editor . document ( ) . findBlockByNumber ( msg . line ) msg . block = block messages . append ( ... | Display results . |
46,348 | def request_analysis ( self ) : if self . _finished : _logger ( self . __class__ ) . log ( 5 , 'running analysis' ) self . _job_runner . request_job ( self . _request ) elif self . editor : _logger ( self . __class__ ) . log ( 5 , 'delaying analysis (previous analysis not finished)' ) QtCore . QTimer . singleShot ( 500... | Requests an analysis . |
46,349 | def _request ( self ) : try : self . editor . toPlainText ( ) except ( TypeError , RuntimeError ) : return try : max_line_length = self . editor . modes . get ( 'RightMarginMode' ) . position except KeyError : max_line_length = 79 request_data = { 'code' : self . editor . toPlainText ( ) , 'path' : self . editor . file... | Requests a checking of the editor content . |
46,350 | def _writen ( fd , data ) : while data : n = os . write ( fd , data ) data = data [ n : ] | Write all the data to a descriptor . |
46,351 | def flush_cache ( self , properties = None ) : if hasattr ( self , '_cache' ) : if properties is None : del ( self . _cache ) else : for prop in properties : if prop in self . _cache : del ( self . _cache [ prop ] ) | Flushes the cache being held for this instance . |
46,352 | def update ( self , properties = None ) : if properties is None : try : self . update_view_data ( properties = list ( self . _cache . keys ( ) ) ) except AttributeError : pass else : self . update_view_data ( properties = properties ) | Updates the properties being held for this instance . |
46,353 | def preload ( self , name , properties = None ) : if properties is None : raise ValueError ( "You must specify some properties to preload. To" " preload all properties use the string \"all\"." ) if not getattr ( self , name ) : return mo_refs = [ ] for item in getattr ( self , name ) : if isinstance ( item , ManagedObj... | Pre - loads the requested properties for each object in the name attribute . |
46,354 | def _set_view_data ( self , object_content ) : logger . info ( "Setting view data for a %s" , self . __class__ ) self . _object_content = object_content for dynprop in object_content . propSet : if dynprop . name not in self . _valid_attrs : logger . error ( "Server returned a property '%s' but the object" " hasn't def... | Update the local object from the passed in object_content . |
46,355 | def _initialize_repo_cache ( ) : LOGGER . info ( "Initializing repository cache" ) repo_cache = { } for hit in GitRepo . search ( ) . query ( "match_all" ) . scan ( ) : repo_cache [ hit . repo_name ] = hit . to_dict ( skip_empty = False ) return repo_cache | Initialize the repository cache used for scraping . |
46,356 | def main ( options ) : client = Client ( server = options . server , username = options . username , password = options . password ) print ( 'Successfully connected to %s' % client . server ) lm_info = client . sc . licenseManager . QuerySupportedFeatures ( ) for feature in lm_info : print ( '%s: %s' % ( feature . feat... | Obtains supported features from the license manager |
46,357 | def append ( self , mode ) : _logger ( ) . log ( 5 , 'adding mode %r' , mode . name ) self . _modes [ mode . name ] = mode mode . on_install ( self . editor ) return mode | Adds a mode to the editor . |
46,358 | def remove ( self , name_or_klass ) : _logger ( ) . log ( 5 , 'removing mode %r' , name_or_klass ) mode = self . get ( name_or_klass ) mode . on_uninstall ( ) self . _modes . pop ( mode . name ) return mode | Removes a mode from the editor . |
46,359 | def append ( self , decoration ) : if decoration not in self . _decorations : self . _decorations . append ( decoration ) self . _decorations = sorted ( self . _decorations , key = lambda sel : sel . draw_order ) self . editor . setExtraSelections ( self . _decorations ) return True return False | Adds a text decoration on a CodeEdit instance |
46,360 | def clear ( self ) : self . _decorations [ : ] = [ ] try : self . editor . setExtraSelections ( self . _decorations ) except RuntimeError : pass | Removes all text decoration from the editor . |
46,361 | def _on_key_pressed ( self , event ) : if ( int ( event . modifiers ( ) ) & QtCore . Qt . ControlModifier > 0 and not int ( event . modifiers ( ) ) & QtCore . Qt . ShiftModifier ) : if event . key ( ) == QtCore . Qt . Key_0 : self . editor . reset_zoom ( ) event . accept ( ) if event . key ( ) == QtCore . Qt . Key_Plus... | Resets editor font size to the default font size |
46,362 | def _on_wheel_event ( self , event ) : try : delta = event . angleDelta ( ) . y ( ) except AttributeError : delta = event . delta ( ) if int ( event . modifiers ( ) ) & QtCore . Qt . ControlModifier > 0 : if delta < self . prev_delta : self . editor . zoom_out ( ) event . accept ( ) else : self . editor . zoom_in ( ) e... | Increments or decrements editor fonts settings on mouse wheel event if ctrl modifier is on . |
46,363 | def set_writer ( self , writer ) : if self . _writer != writer and self . _writer : self . _writer = None if writer : self . _writer = writer | Changes the writer function to handle writing to the text edit . |
46,364 | def start_process ( self , process , args = None , cwd = None , env = None ) : self . setReadOnly ( False ) if env is None : env = { } if args is None : args = [ ] if not self . _running : self . process = QProcess ( ) self . process . finished . connect ( self . _on_process_finished ) self . process . started . connec... | Starts a process interactively . |
46,365 | def write ( text_edit , text , color ) : try : text_edit . moveCursor ( QTextCursor . End ) text_edit . setTextColor ( color ) text_edit . insertPlainText ( text ) text_edit . moveCursor ( QTextCursor . End ) except RuntimeError : pass | Default write function . Move the cursor to the end and insert text with the specified color . |
46,366 | def apply_color_scheme ( self , color_scheme ) : self . stdout_color = color_scheme . formats [ 'normal' ] . foreground ( ) . color ( ) self . stdin_color = color_scheme . formats [ 'number' ] . foreground ( ) . color ( ) self . app_msg_color = color_scheme . formats [ 'string' ] . foreground ( ) . color ( ) self . bac... | Apply a pygments color scheme to the console . |
46,367 | def process_block ( self , current_block , previous_block , text ) : prev_fold_level = TextBlockHelper . get_fold_lvl ( previous_block ) if text . strip ( ) == '' : fold_level = prev_fold_level else : fold_level = self . detect_fold_level ( previous_block , current_block ) if fold_level > self . limit : fold_level = se... | Processes a block and setup its folding info . |
46,368 | def read_config ( contents ) : file_obj = io . StringIO ( contents ) config = six . moves . configparser . ConfigParser ( ) config . readfp ( file_obj ) return config | Reads pylintrc config into native ConfigParser object . |
46,369 | def load_local_config ( filename ) : if not filename : return imp . new_module ( 'local_pylint_config' ) module = imp . load_source ( 'local_pylint_config' , filename ) return module | Loads the pylint . config . py file . |
46,370 | def determine_final_config ( config_module ) : config = Config ( DEFAULT_LIBRARY_RC_ADDITIONS , DEFAULT_LIBRARY_RC_REPLACEMENTS , DEFAULT_TEST_RC_ADDITIONS , DEFAULT_TEST_RC_REPLACEMENTS ) for field in config . _fields : if hasattr ( config_module , field ) : config = config . _replace ( ** { field : getattr ( config_m... | Determines the final additions and replacements . |
46,371 | def lint_fileset ( * dirnames , ** kwargs ) : try : rc_filename = kwargs [ 'rc_filename' ] description = kwargs [ 'description' ] if len ( kwargs ) != 2 : raise KeyError except KeyError : raise KeyError ( _LINT_FILESET_MSG ) pylint_shell_command = [ 'pylint' , '--rcfile' , rc_filename ] pylint_shell_command . extend ( ... | Lints a group of files using a given rcfile . |
46,372 | def make_rc ( base_cfg , target_filename , additions = None , replacements = None ) : if additions is None : additions = { } if replacements is None : replacements = { } new_cfg = six . moves . configparser . ConfigParser ( ) new_cfg . _sections = copy . deepcopy ( base_cfg . _sections ) new_sections = new_cfg . _secti... | Combines a base rc and additions into single file . |
46,373 | def run_command ( args ) : library_rc = 'pylintrc' test_rc = 'pylintrc.test' if os . path . exists ( library_rc ) : os . remove ( library_rc ) if os . path . exists ( test_rc ) : os . remove ( test_rc ) default_config = read_config ( get_default_config ( ) ) user_config = load_local_config ( args . config ) configurati... | Script entry point . Lints both sets of files . |
46,374 | def login ( self , username = None , password = None ) : if username is None : username = self . username if password is None : password = self . password logger . debug ( "Logging into server" ) self . sc . sessionManager . Login ( userName = username , password = password ) self . _logged_in = True | Login to a vSphere server . |
46,375 | def logout ( self ) : if self . _logged_in is True : self . si . flush_cache ( ) self . sc . sessionManager . Logout ( ) self . _logged_in = False | Logout of a vSphere server . |
46,376 | def invoke ( self , method , _this , ** kwargs ) : if ( self . _logged_in is False and method not in [ "Login" , "RetrieveServiceContent" ] ) : logger . critical ( "Cannot exec %s unless logged in" , method ) raise NotLoggedInError ( "Cannot exec %s unless logged in" % method ) for kwarg in kwargs : kwargs [ kwarg ] = ... | Invoke a method on the server . |
46,377 | def _mor_to_pobject ( self , mo_ref ) : kls = classmapper ( mo_ref . _type ) new_object = kls ( mo_ref , self ) return new_object | Converts a MOR to a psphere object . |
46,378 | def _marshal ( self , obj ) : logger . debug ( "Checking if %s needs to be marshalled" , obj ) if isinstance ( obj , ManagedObject ) : logger . debug ( "obj is a psphere object, converting to MOR" ) return obj . _mo_ref if isinstance ( obj , list ) : logger . debug ( "obj is a list, recursing it" ) new_list = [ ] for i... | Walks an object and marshals any psphere object into MORs . |
46,379 | def _unmarshal ( self , obj ) : if isinstance ( obj , suds . sudsobject . Object ) is False : logger . debug ( "%s is not a suds instance, skipping" , obj ) return obj logger . debug ( "Processing:" ) logger . debug ( obj ) logger . debug ( "...with keylist:" ) logger . debug ( obj . __keylist__ ) if "_type" in obj . _... | Walks an object and unmarshals any MORs into psphere objects . |
46,380 | def create ( self , type_ , ** kwargs ) : obj = self . factory . create ( "ns0:%s" % type_ ) for key , value in kwargs . items ( ) : setattr ( obj , key , value ) return obj | Create a SOAP object of the requested type . |
46,381 | def get_views ( self , mo_refs , properties = None ) : property_specs = [ ] for mo_ref in mo_refs : property_spec = self . create ( 'PropertySpec' ) property_spec . type = str ( mo_ref . _type ) if properties is None : properties = [ ] else : if properties == "all" : property_spec . all = True else : property_spec . al... | Get a list of local view s for multiple managed objects . |
46,382 | def get_search_filter_spec ( self , begin_entity , property_spec ) : ss_strings = [ 'resource_pool_traversal_spec' , 'resource_pool_vm_traversal_spec' , 'folder_traversal_spec' , 'datacenter_host_traversal_spec' , 'datacenter_vm_traversal_spec' , 'compute_resource_rp_traversal_spec' , 'compute_resource_host_traversal_s... | Build a PropertyFilterSpec capable of full inventory traversal . By specifying all valid traversal specs we are creating a PFS that can recursively select any object under the given entity . |
46,383 | def find_entity_views ( self , view_type , begin_entity = None , properties = None ) : if properties is None : properties = [ ] if not begin_entity : begin_entity = self . sc . rootFolder . _mo_ref property_spec = self . create ( 'PropertySpec' ) property_spec . type = view_type property_spec . all = False property_spe... | Find all ManagedEntity s of the requested type . |
46,384 | def find_entity_view ( self , view_type , begin_entity = None , filter = { } , properties = None ) : if properties is None : properties = [ ] kls = classmapper ( view_type ) if not begin_entity : begin_entity = self . sc . rootFolder . _mo_ref logger . debug ( "Using %s" , self . sc . rootFolder . _mo_ref ) property_sp... | Find a ManagedEntity of the requested type . |
46,385 | def load_template ( name = None ) : if name is None : name = "default" logger . info ( "Loading template with name %s" , name ) try : template_file = open ( "%s/%s.yaml" % ( template_path , name ) ) except IOError : raise TemplateNotFoundError template = yaml . safe_load ( template_file ) template_file . close ( ) if "... | Loads a template of the specified name . |
46,386 | def list_templates ( ) : templates = [ f for f in glob . glob ( os . path . join ( template_path , '*.yaml' ) ) ] return templates | Returns a list of all templates . |
46,387 | def create_nic ( client , target , nic ) : for network in target . network : if network . name == nic [ "network_name" ] : net = network break else : return None backing = client . create ( "VirtualEthernetCardNetworkBackingInfo" ) backing . deviceName = nic [ "network_name" ] backing . network = net connect_info = cli... | Return a NIC spec |
46,388 | def main ( name , options ) : server = config . _config_value ( "general" , "server" , options . server ) if server is None : raise ValueError ( "server must be supplied on command line" " or in configuration file." ) username = config . _config_value ( "general" , "username" , options . username ) if username is None ... | The main method for this script . |
46,389 | def add_ignore_patterns ( self , * patterns ) : for ptrn in patterns : if isinstance ( ptrn , list ) : for p in ptrn : self . _ignored_patterns . append ( p ) else : self . _ignored_patterns . append ( ptrn ) | Adds an ignore pattern to the list for ignore patterns . |
46,390 | def set_context_menu ( self , context_menu ) : self . context_menu = context_menu self . context_menu . tree_view = self self . context_menu . init_actions ( ) for action in self . context_menu . actions ( ) : self . addAction ( action ) | Sets the context menu of the tree view . |
46,391 | def filePath ( self , index ) : return self . _fs_model_source . filePath ( self . _fs_model_proxy . mapToSource ( index ) ) | Gets the file path of the item at the specified index . |
46,392 | def fileInfo ( self , index ) : return self . _fs_model_source . fileInfo ( self . _fs_model_proxy . mapToSource ( index ) ) | Gets the file info of the item at the specified index . |
46,393 | def paste_from_clipboard ( self ) : to = self . get_current_path ( ) if os . path . isfile ( to ) : to = os . path . abspath ( os . path . join ( to , os . pardir ) ) mime = QtWidgets . QApplication . clipboard ( ) . mimeData ( ) paste_operation = None if mime . hasFormat ( self . _UrlListMimeData . format ( copy = Tru... | Pastes files from clipboard . |
46,394 | def _paste ( self , sources , destination , copy ) : for src in sources : debug ( '%s <%s> to <%s>' % ( 'copying' if copy else 'cutting' , src , destination ) ) perform_copy = True ext = os . path . splitext ( src ) [ 1 ] original = os . path . splitext ( os . path . split ( src ) [ 1 ] ) [ 0 ] filename , status = QtWi... | Copies the files listed in sources to destination . Source are removed if copy is set to False . |
46,395 | def delete ( self ) : urls = self . selected_urls ( ) rep = QtWidgets . QMessageBox . question ( self . tree_view , _ ( 'Confirm delete' ) , _ ( 'Are you sure about deleting the selected files/directories?' ) , QtWidgets . QMessageBox . Yes | QtWidgets . QMessageBox . No , QtWidgets . QMessageBox . Yes ) if rep == QtWi... | Deletes the selected items . |
46,396 | def get_current_path ( self ) : path = self . tree_view . fileInfo ( self . tree_view . currentIndex ( ) ) . filePath ( ) if not path : path = self . tree_view . root_path return path | Gets the path of the currently selected item . |
46,397 | def copy_path_to_clipboard ( self ) : path = self . get_current_path ( ) QtWidgets . QApplication . clipboard ( ) . setText ( path ) debug ( 'path copied: %s' % path ) | Copies the file path to the clipboard |
46,398 | def rename ( self ) : src = self . get_current_path ( ) pardir , name = os . path . split ( src ) new_name , status = QtWidgets . QInputDialog . getText ( self . tree_view , _ ( 'Rename ' ) , _ ( 'New name:' ) , QtWidgets . QLineEdit . Normal , name ) if status : dest = os . path . join ( pardir , new_name ) old_files ... | Renames the selected item in the tree view |
46,399 | def create_file ( self ) : src = self . get_current_path ( ) name , status = QtWidgets . QInputDialog . getText ( self . tree_view , _ ( 'Create new file' ) , _ ( 'File name:' ) , QtWidgets . QLineEdit . Normal , '' ) if status : fatal_names = [ '.' , '..' , os . sep ] for i in fatal_names : if i == name : QtWidgets . ... | Creates a file under the current directory . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.