idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
11,100 | def bin ( self , n_bins = 1 , pixels_per_bin = None , wave_min = None , wave_max = None ) : if wave_min is not None : self . wave_min = wave_min if wave_max is not None : self . wave_max = wave_max raw_wave = self . raw [ 0 ] whr = np . logical_and ( raw_wave * q . AA >= self . wave_min , raw_wave * q . AA <= self . wave_max ) self . wave = ( raw_wave [ whr ] * q . AA ) . to ( self . wave_units ) self . throughput = self . raw [ 1 ] [ whr ] print ( 'Bandpass trimmed to' , '{} - {}' . format ( self . wave_min , self . wave_max ) ) pts = len ( self . wave ) if isinstance ( pixels_per_bin , int ) : self . pixels_per_bin = pixels_per_bin self . n_bins = int ( pts / self . pixels_per_bin ) elif isinstance ( n_bins , int ) : self . n_bins = n_bins self . pixels_per_bin = int ( pts / self . n_bins ) else : raise ValueError ( "Please specify 'n_bins' OR 'pixels_per_bin' as integers." ) print ( '{} bins of {} pixels each.' . format ( self . n_bins , self . pixels_per_bin ) ) new_len = self . n_bins * self . pixels_per_bin start = ( pts - new_len ) // 2 self . wave = self . wave [ start : new_len + start ] . reshape ( self . n_bins , self . pixels_per_bin ) self . throughput = self . throughput [ start : new_len + start ] . reshape ( self . n_bins , self . pixels_per_bin ) | Break the filter up into bins and apply a throughput to each bin useful for G141 G102 and other grisms |
11,101 | def centers ( self ) : w_cen = np . nanmean ( self . wave . value , axis = 1 ) f_cen = np . nanmean ( self . throughput , axis = 1 ) return np . asarray ( [ w_cen , f_cen ] ) | A getter for the wavelength bin centers and average fluxes |
11,102 | def flux_units ( self , units ) : dtypes = ( q . core . PrefixUnit , q . quantity . Quantity , q . core . CompositeUnit ) if not isinstance ( units , dtypes ) : raise ValueError ( units , "units not understood." ) if units != self . flux_units : sfd = q . spectral_density ( self . wave_eff ) self . zp = self . zp . to ( units , equivalencies = sfd ) self . _flux_units = units | A setter for the flux units |
11,103 | def info ( self , fetch = False ) : tp = ( int , bytes , bool , str , float , tuple , list , np . ndarray ) info = [ [ k , str ( v ) ] for k , v in vars ( self ) . items ( ) if isinstance ( v , tp ) and k not in [ 'rsr' , 'raw' , 'centers' ] and not k . startswith ( '_' ) ] table = at . Table ( np . asarray ( info ) . reshape ( len ( info ) , 2 ) , names = [ 'Attributes' , 'Values' ] ) table . sort ( 'Attributes' ) if fetch : return table else : table . pprint ( max_width = - 1 , max_lines = - 1 , align = [ '>' , '<' ] ) | Print a table of info about the current filter |
11,104 | def load_TopHat ( self , wave_min , wave_max , pixels_per_bin = 100 ) : self . pixels_per_bin = pixels_per_bin self . n_bins = 1 self . _wave_units = q . AA wave_min = wave_min . to ( self . wave_units ) wave_max = wave_max . to ( self . wave_units ) self . _wave = np . linspace ( wave_min , wave_max , pixels_per_bin ) self . _throughput = np . ones_like ( self . wave ) self . raw = np . array ( [ self . wave . value , self . throughput ] ) wave_eff = ( ( wave_min + wave_max ) / 2. ) . value width = ( wave_max - wave_min ) . value self . path = '' self . refs = '' self . Band = 'Top Hat' self . CalibrationReference = '' self . FWHM = width self . Facility = '-' self . FilterProfileService = '-' self . MagSys = '-' self . PhotCalID = '' self . PhotSystem = '' self . ProfileReference = '' self . WavelengthMin = wave_min . value self . WavelengthMax = wave_max . value self . WavelengthCen = wave_eff self . WavelengthEff = wave_eff self . WavelengthMean = wave_eff self . WavelengthPeak = wave_eff self . WavelengthPhot = wave_eff self . WavelengthPivot = wave_eff self . WavelengthUCD = '' self . WidthEff = width self . ZeroPoint = 0 self . ZeroPointType = '' self . ZeroPointUnit = 'Jy' self . filterID = 'Top Hat' | Loads a top hat filter given wavelength min and max values |
11,105 | def overlap ( self , spectrum ) : swave = self . wave [ np . where ( self . throughput != 0 ) ] s1 , s2 = swave . min ( ) , swave . max ( ) owave = spectrum [ 0 ] o1 , o2 = owave . min ( ) , owave . max ( ) if ( s1 >= o1 and s2 <= o2 ) : ans = 'full' elif ( s2 < o1 ) or ( o2 < s1 ) : ans = 'none' else : ans = 'partial' return ans | Tests for overlap of this filter with a spectrum |
11,106 | def plot ( self , fig = None , draw = True ) : COLORS = color_gen ( 'Category10' ) if fig is None : xlab = 'Wavelength [{}]' . format ( self . wave_units ) ylab = 'Throughput' title = self . filterID fig = figure ( title = title , x_axis_label = xlab , y_axis_label = ylab ) fig . line ( ( self . raw [ 0 ] * q . AA ) . to ( self . wave_units ) , self . raw [ 1 ] , alpha = 0.1 , line_width = 8 , color = 'black' ) for x , y in self . rsr : fig . line ( x , y , color = next ( COLORS ) , line_width = 2 ) fig . circle ( * self . centers , size = 8 , color = 'black' ) if draw : show ( fig ) else : return fig | Plot the filter |
11,107 | def throughput ( self , points ) : if not points . shape == self . wave . shape : raise ValueError ( "Throughput and wavelength must be same shape." ) self . _throughput = points | A setter for the throughput |
11,108 | def wave ( self , wavelength ) : if not isinstance ( wavelength , q . quantity . Quantity ) : raise ValueError ( "Wavelength must be in length units." ) self . _wave = wavelength self . wave_units = wavelength . unit | A setter for the wavelength |
11,109 | def wave_units ( self , units ) : if not units . is_equivalent ( q . m ) : raise ValueError ( units , ": New wavelength units must be a length." ) self . _wave_units = units self . _wave = self . wave . to ( self . wave_units ) . round ( 5 ) self . wave_min = self . wave_min . to ( self . wave_units ) . round ( 5 ) self . wave_max = self . wave_max . to ( self . wave_units ) . round ( 5 ) self . wave_eff = self . wave_eff . to ( self . wave_units ) . round ( 5 ) self . wave_center = self . wave_center . to ( self . wave_units ) . round ( 5 ) self . wave_mean = self . wave_mean . to ( self . wave_units ) . round ( 5 ) self . wave_peak = self . wave_peak . to ( self . wave_units ) . round ( 5 ) self . wave_phot = self . wave_phot . to ( self . wave_units ) . round ( 5 ) self . wave_pivot = self . wave_pivot . to ( self . wave_units ) . round ( 5 ) self . width_eff = self . width_eff . to ( self . wave_units ) . round ( 5 ) self . fwhm = self . fwhm . to ( self . wave_units ) . round ( 5 ) | A setter for the wavelength units |
11,110 | def clear ( self ) : for act in self . actions ( ) : act . setParent ( None ) act . deleteLater ( ) for lbl in self . actionLabels ( ) : lbl . close ( ) lbl . deleteLater ( ) | Clears out all the actions and items from this toolbar . |
11,111 | def resizeToMinimum ( self ) : offset = self . padding ( ) min_size = self . minimumPixmapSize ( ) if self . position ( ) in ( XDockToolbar . Position . East , XDockToolbar . Position . West ) : self . resize ( min_size . width ( ) + offset , self . height ( ) ) elif self . position ( ) in ( XDockToolbar . Position . North , XDockToolbar . Position . South ) : self . resize ( self . width ( ) , min_size . height ( ) + offset ) | Resizes the dock toolbar to the minimum sizes . |
11,112 | def unholdAction ( self ) : self . _actionHeld = False point = self . mapFromGlobal ( QCursor . pos ( ) ) self . setCurrentAction ( self . actionAt ( point ) ) | Unholds the action from being blocked on the leave event . |
11,113 | def apply ( self ) : font = self . value ( 'font' ) try : font . setPointSize ( self . value ( 'fontSize' ) ) except TypeError : pass palette = self . value ( 'colorSet' ) . palette ( ) if ( unwrapVariant ( QApplication . instance ( ) . property ( 'useScheme' ) ) ) : QApplication . instance ( ) . setFont ( font ) QApplication . instance ( ) . setPalette ( palette ) for widget in QApplication . topLevelWidgets ( ) : for area in widget . findChildren ( QMdiArea ) : area . setPalette ( palette ) else : logger . debug ( 'The application doesnt have the useScheme property.' ) | Applies the scheme to the current application . |
11,114 | def reset ( self ) : self . setValue ( 'colorSet' , XPaletteColorSet ( ) ) self . setValue ( 'font' , QApplication . font ( ) ) self . setValue ( 'fontSize' , QApplication . font ( ) . pointSize ( ) ) | Resets the values to the current application information . |
11,115 | def pickAttachment ( self ) : filename = QFileDialog . getOpenFileName ( self . window ( ) , 'Select Attachment' , '' , 'All Files (*.*)' ) if type ( filename ) == tuple : filename = nativestring ( filename [ 0 ] ) filename = nativestring ( filename ) if filename : self . addAttachment ( os . path . basename ( filename ) , filename ) | Prompts the user to select an attachment to add to this edit . |
11,116 | def resizeToContents ( self ) : if self . _toolbar . isVisible ( ) : doc = self . document ( ) h = doc . documentLayout ( ) . documentSize ( ) . height ( ) offset = 34 edit = self . _attachmentsEdit if self . _attachments : edit . move ( 2 , self . height ( ) - edit . height ( ) - 31 ) edit . setTags ( sorted ( self . _attachments . keys ( ) ) ) edit . show ( ) offset = 34 + edit . height ( ) else : edit . hide ( ) offset = 34 self . setFixedHeight ( h + offset ) self . _toolbar . move ( 2 , self . height ( ) - 32 ) else : super ( XCommentEdit , self ) . resizeToContents ( ) | Resizes this toolbar based on the contents of its text . |
11,117 | async def configuration ( self , * , dc = None , consistency = None ) : response = await self . _api . get ( "/v1/operator/raft/configuration" , params = { "dc" : dc } , consistency = consistency ) return response . body | Inspects the Raft configuration |
11,118 | async def peer_delete ( self , * , dc = None , address ) : address = extract_attr ( address , keys = [ "Address" ] ) params = { "dc" : dc , "address" : address } response = await self . _api . delete ( "/v1/operator/raft/peer" , params = params ) return response . status < 400 | Remove the server with given address from the Raft configuration |
11,119 | def autoLayout ( self ) : try : direction = self . currentSlide ( ) . scene ( ) . direction ( ) except AttributeError : direction = QtGui . QBoxLayout . TopToBottom size = self . size ( ) self . _slideshow . resize ( size ) prev = self . _previousButton next = self . _nextButton if direction == QtGui . QBoxLayout . BottomToTop : y = 9 else : y = size . height ( ) - prev . height ( ) - 9 prev . move ( 9 , y ) next . move ( size . width ( ) - next . width ( ) - 9 , y ) for i in range ( self . _slideshow . count ( ) ) : widget = self . _slideshow . widget ( i ) widget . scene ( ) . autoLayout ( size ) | Automatically lays out the contents for this widget . |
11,120 | def goForward ( self ) : if self . _slideshow . currentIndex ( ) == self . _slideshow . count ( ) - 1 : self . finished . emit ( ) else : self . _slideshow . slideInNext ( ) | Moves to the next slide or finishes the walkthrough . |
11,121 | def updateUi ( self ) : index = self . _slideshow . currentIndex ( ) count = self . _slideshow . count ( ) self . _previousButton . setVisible ( index != 0 ) self . _nextButton . setText ( 'Finish' if index == count - 1 else 'Next' ) self . autoLayout ( ) | Updates the interface to show the selection buttons . |
11,122 | def parse_unit ( prop , dictionary , dt = None ) : try : dt = timezone . parse_datetime ( dictionary . get ( 'date_time' ) ) except TypeError : dt = None matches = [ k for k in dictionary . keys ( ) if prop in k ] try : value = dictionary [ matches [ 0 ] ] unit = re . search ( r' \(([^)]+)\)' , matches [ 0 ] ) except IndexError : return None if ';' in value : values = [ val for val in value . split ( ';' ) if val != '' ] if unit : return [ Observation ( v , unit . group ( 1 ) , dt ) for v in values ] else : return values if not value or not unit : return value or None return Observation ( value , unit . group ( 1 ) , dt ) | Do a fuzzy match for prop in the dictionary taking into account unit suffix . |
11,123 | def clear ( self ) : for i in range ( self . count ( ) ) : widget = self . widget ( i ) if widget is not None : widget . close ( ) widget . setParent ( None ) widget . deleteLater ( ) | Clears all the container for this query widget . |
11,124 | def cleanupContainers ( self ) : for i in range ( self . count ( ) - 1 , self . currentIndex ( ) , - 1 ) : widget = self . widget ( i ) widget . close ( ) widget . setParent ( None ) widget . deleteLater ( ) | Cleans up all containers to the right of the current one . |
11,125 | def exitContainer ( self ) : try : entry = self . _compoundStack . pop ( ) except IndexError : return container = self . currentContainer ( ) entry . setQuery ( container . query ( ) ) self . slideInPrev ( ) | Removes the current query container . |
11,126 | def rebuild ( self ) : self . setUpdatesEnabled ( False ) self . blockSignals ( True ) for child in self . findChildren ( QObject ) : child . setParent ( None ) child . deleteLater ( ) schema = self . schema ( ) if ( schema ) : self . setEnabled ( True ) uifile = self . uiFile ( ) if ( uifile ) : projexui . loadUi ( '' , self , uifile ) for widget in self . findChildren ( XOrbColumnEdit ) : columnName = widget . columnName ( ) column = schema . column ( columnName ) if ( column ) : widget . setColumn ( column ) else : logger . debug ( '%s is not a valid column of %s' % ( columnName , schema . name ( ) ) ) else : layout = QFormLayout ( ) layout . setContentsMargins ( 0 , 0 , 0 , 0 ) columns = schema . columns ( ) columns . sort ( key = lambda x : x . displayName ( ) ) record = self . record ( ) for column in columns : if ( column . name ( ) . startswith ( '_' ) ) : continue label = column . displayName ( ) coltype = column . columnType ( ) name = column . name ( ) widget = XOrbColumnEdit ( self ) widget . setObjectName ( 'ui_' + name ) widget . setColumnName ( name ) widget . setColumnType ( coltype ) widget . setColumn ( column ) layout . addRow ( QLabel ( label , self ) , widget ) self . setLayout ( layout ) self . adjustSize ( ) self . setWindowTitle ( 'Edit %s' % schema . name ( ) ) else : self . setEnabled ( False ) self . setUpdatesEnabled ( True ) self . blockSignals ( False ) | Rebuilds the interface for this widget based on the current model . |
11,127 | def save ( self ) : schema = self . schema ( ) if ( not schema ) : self . saved . emit ( ) return record = self . record ( ) if not record : record = self . _model ( ) save_data = [ ] column_edits = self . findChildren ( XOrbColumnEdit ) for widget in column_edits : columnName = widget . columnName ( ) column = schema . column ( columnName ) if ( not column ) : logger . warning ( '%s is not a valid column of %s.' % ( columnName , schema . name ( ) ) ) continue value = widget . value ( ) if ( value == IGNORED ) : continue if ( column . required ( ) and not value ) : name = column . displayName ( ) QMessageBox . information ( self , 'Missing Required Field' , '%s is a required field.' % name ) return elif ( column . unique ( ) ) : query = Q ( column . name ( ) ) == value if ( record . isRecord ( ) ) : query &= Q ( self . _model ) != record columns = self . _model . schema ( ) . primaryColumns ( ) result = self . _model . select ( columns = columns , where = query ) if ( result . total ( ) ) : QMessageBox . information ( self , 'Duplicate Entry' , '%s already exists.' % value ) return save_data . append ( ( column , value ) ) for column , value in save_data : record . setRecordValue ( column . name ( ) , value ) self . _record = record self . saved . emit ( ) | Saves the values from the editor to the system . |
11,128 | def acceptText ( self ) : if not self . signalsBlocked ( ) : self . textEntered . emit ( self . toPlainText ( ) ) self . htmlEntered . emit ( self . toHtml ( ) ) self . returnPressed . emit ( ) | Emits the editing finished signals for this widget . |
11,129 | def clear ( self ) : super ( XTextEdit , self ) . clear ( ) self . textEntered . emit ( '' ) self . htmlEntered . emit ( '' ) if self . autoResizeToContents ( ) : self . resizeToContents ( ) | Clears the text for this edit and resizes the toolbar information . |
11,130 | def paste ( self ) : html = QApplication . clipboard ( ) . text ( ) if not self . isRichTextEditEnabled ( ) : self . insertPlainText ( projex . text . toAscii ( html ) ) else : super ( XTextEdit , self ) . paste ( ) | Pastes text from the clipboard into this edit . |
11,131 | def resizeToContents ( self ) : doc = self . document ( ) h = doc . documentLayout ( ) . documentSize ( ) . height ( ) self . setFixedHeight ( h + 4 ) | Resizes this widget to fit the contents of its text . |
11,132 | def matchCollapsedState ( self ) : collapsed = not self . isChecked ( ) if self . _inverted : collapsed = not collapsed if ( not self . isCollapsible ( ) or not collapsed ) : for child in self . children ( ) : if ( not isinstance ( child , QWidget ) ) : continue child . show ( ) self . setMaximumHeight ( MAX_INT ) self . adjustSize ( ) if ( self . parent ( ) ) : self . parent ( ) . adjustSize ( ) else : self . setMaximumHeight ( self . collapsedHeight ( ) ) for child in self . children ( ) : if ( not isinstance ( child , QWidget ) ) : continue child . hide ( ) | Matches the collapsed state for this groupbox . |
11,133 | def import_qt ( glbls ) : if 'QtCore' in glbls : return from projexui . qt import QtCore , QtGui , wrapVariant , uic from projexui . widgets . xloggersplashscreen import XLoggerSplashScreen glbls [ 'QtCore' ] = QtCore glbls [ 'QtGui' ] = QtGui glbls [ 'wrapVariant' ] = wrapVariant glbls [ 'uic' ] = uic glbls [ 'XLoggerSplashScreen' ] = XLoggerSplashScreen | Delayed qt loader . |
11,134 | def encode_value ( value , flags = None , base64 = False ) : if flags : logger . debug ( "Flag %s encoding not implemented yet" % flags ) if not isinstance ( value , bytes ) : raise ValueError ( "value must be bytes" ) return b64encode ( value ) if base64 else value | Mostly used by payloads |
11,135 | def _finishAnimation ( self ) : self . setCurrentIndex ( self . _nextIndex ) self . widget ( self . _lastIndex ) . hide ( ) self . widget ( self . _lastIndex ) . move ( self . _lastPoint ) self . _active = False if not self . signalsBlocked ( ) : self . animationFinished . emit ( ) | Cleans up post - animation . |
11,136 | def clear ( self ) : for i in range ( self . count ( ) - 1 , - 1 , - 1 ) : w = self . widget ( i ) if w : self . removeWidget ( w ) w . close ( ) w . deleteLater ( ) | Clears out the widgets from this stack . |
11,137 | def list ( conf ) : try : config = init_config ( conf ) conn = get_conn ( config . get ( 'DEFAULT' , 'statusdb' ) ) cur = conn . cursor ( ) sqlstr = cur . execute ( sqlstr ) result = cur . fetchall ( ) conn . commit ( ) conn . close ( ) for r in result : print r except Exception , e : traceback . print_exc ( ) | OpenVPN status list method |
11,138 | def cli ( conf ) : try : config = init_config ( conf ) debug = config . getboolean ( 'DEFAULT' , 'debug' ) conn = get_conn ( config . get ( 'DEFAULT' , 'statusdb' ) ) cur = conn . cursor ( ) sqlstr = try : cur . execute ( 'drop table client_status' ) except : pass cur . execute ( sqlstr ) print 'flush client status database' conn . commit ( ) conn . close ( ) except : traceback . print_exc ( ) | OpenVPN status initdb method |
11,139 | async def register ( self , service ) : response = await self . _api . put ( "/v1/agent/service/register" , data = service ) return response . status == 200 | Registers a new local service . |
11,140 | async def deregister ( self , service ) : service_id = extract_attr ( service , keys = [ "ServiceID" , "ID" ] ) response = await self . _api . get ( "/v1/agent/service/deregister" , service_id ) return response . status == 200 | Deregisters a local service |
11,141 | async def disable ( self , service , * , reason = None ) : return await self . maintenance ( service , False , reason = reason ) | Enters maintenance mode for service |
11,142 | async def enable ( self , service , * , reason = None ) : return await self . maintenance ( service , False , reason = reason ) | Resumes normal operation for service |
11,143 | def mppe_chap2_gen_keys ( password , nt_response ) : password_hash = mschap . nt_password_hash ( password ) password_hash_hash = mschap . hash_nt_password_hash ( password_hash ) master_key = get_master_key ( password_hash_hash , nt_response ) master_send_key = get_asymetric_start_key ( master_key , 16 , True , True ) master_recv_key = get_asymetric_start_key ( master_key , 16 , False , True ) return master_send_key , master_recv_key | 3 . 3 . Generating 128 - bit Session Keys |
11,144 | def query ( self , sql , args = None , many = None , as_dict = False ) : con = self . pool . pop ( ) c = None try : c = con . cursor ( as_dict ) LOGGER . debug ( "Query sql: " + sql + " args:" + str ( args ) ) c . execute ( sql , args ) if many and many > 0 : return self . _yield ( con , c , many ) else : return c . fetchall ( ) except Exception as e : LOGGER . error ( "Error Qeury on %s" , str ( e ) ) raise DBError ( e . args [ 0 ] , e . args [ 1 ] ) finally : many or ( c and c . close ( ) ) many or ( con and self . pool . push ( con ) ) | The connection raw sql query when select table show table to fetch records it is compatible the dbi execute method . |
11,145 | def connection_class ( self , adapter ) : if self . adapters . get ( adapter ) : return self . adapters [ adapter ] try : class_prefix = getattr ( __import__ ( 'db.' + adapter , globals ( ) , locals ( ) , [ '__class_prefix__' ] ) , '__class_prefix__' ) driver = self . _import_class ( 'db.' + adapter + '.connection.' + class_prefix + 'Connection' ) except ImportError : raise DBError ( "Must install adapter `%s` or doesn't support" % ( adapter ) ) self . adapters [ adapter ] = driver return driver | Get connection class by adapter |
11,146 | def dialect_class ( self , adapter ) : if self . dialects . get ( adapter ) : return self . dialects [ adapter ] try : class_prefix = getattr ( __import__ ( 'db.' + adapter , globals ( ) , locals ( ) , [ '__class_prefix__' ] ) , '__class_prefix__' ) driver = self . _import_class ( 'db.' + adapter + '.dialect.' + class_prefix + 'Dialect' ) except ImportError : raise DBError ( "Must install adapter `%s` or doesn't support" % ( adapter ) ) self . dialects [ adapter ] = driver return driver | Get dialect sql class by adapter |
11,147 | def _import_class ( self , module2cls ) : d = module2cls . rfind ( "." ) classname = module2cls [ d + 1 : len ( module2cls ) ] m = __import__ ( module2cls [ 0 : d ] , globals ( ) , locals ( ) , [ classname ] ) return getattr ( m , classname ) | Import class by module dot split string |
11,148 | def rebuild ( self , gridRect ) : scene = self . scene ( ) if ( not scene ) : return self . setVisible ( gridRect . contains ( self . pos ( ) ) ) self . setZValue ( 100 ) path = QPainterPath ( ) path . moveTo ( 0 , 0 ) path . lineTo ( 0 , gridRect . height ( ) ) tip = '' tip_point = None self . _ellipses = [ ] items = scene . collidingItems ( self ) self . _basePath = QPainterPath ( path ) for item in items : item_path = item . path ( ) found = None for y in range ( int ( gridRect . top ( ) ) , int ( gridRect . bottom ( ) ) ) : point = QPointF ( self . pos ( ) . x ( ) , y ) if ( item_path . contains ( point ) ) : found = QPointF ( 0 , y - self . pos ( ) . y ( ) ) break if ( found ) : path . addEllipse ( found , 6 , 6 ) self . _ellipses . append ( found ) value = scene . valueAt ( self . mapToScene ( found ) ) tip_point = self . mapToScene ( found ) hruler = scene . horizontalRuler ( ) vruler = scene . verticalRuler ( ) x_value = hruler . formatValue ( value [ 0 ] ) y_value = vruler . formatValue ( value [ 1 ] ) tip = '<b>x:</b> %s<br/><b>y:</b> %s' % ( x_value , y_value ) self . setPath ( path ) self . setVisible ( True ) if ( tip ) : anchor = XPopupWidget . Anchor . RightCenter widget = self . scene ( ) . chartWidget ( ) tip_point = widget . mapToGlobal ( widget . mapFromScene ( tip_point ) ) XPopupWidget . showToolTip ( tip , anchor = anchor , parent = widget , point = tip_point , foreground = QColor ( 'blue' ) , background = QColor ( 148 , 148 , 255 ) ) | Rebuilds the tracker item . |
11,149 | def get_access_token ( self ) : if self . token_info and not self . is_token_expired ( self . token_info ) : return self . token_info [ 'access_token' ] token_info = self . _request_access_token ( ) token_info = self . _add_custom_values_to_token_info ( token_info ) self . token_info = token_info return self . token_info [ 'access_token' ] | If a valid access token is in memory returns it Else feches a new token and returns it |
11,150 | def _request_access_token ( self ) : payload = { 'grant_type' : 'authorization_code' , 'code' : code , 'redirect_uri' : self . redirect_uri } headers = _make_authorization_headers ( self . client_id , self . client_secret ) response = requests . post ( self . OAUTH_TOKEN_URL , data = payload , headers = headers , verify = LOGIN_VERIFY_SSL_CERT ) if response . status_code is not 200 : raise MercedesMeAuthError ( response . reason ) token_info = response . json ( ) return token_info | Gets client credentials access token |
11,151 | def get_cached_token ( self ) : token_info = None if self . cache_path : try : f = open ( self . cache_path ) token_info_string = f . read ( ) f . close ( ) token_info = json . loads ( token_info_string ) if self . is_token_expired ( token_info ) : token_info = self . refresh_access_token ( token_info [ 'refresh_token' ] ) except IOError : pass return token_info | Gets a cached auth token |
11,152 | def get_authorize_url ( self , state = None ) : payload = { 'client_id' : self . client_id , 'response_type' : 'code' , 'redirect_uri' : self . redirect_uri , 'scope' : self . scope } urlparams = urllib . parse . urlencode ( payload ) return "%s?%s" % ( self . OAUTH_AUTHORIZE_URL , urlparams ) | Gets the URL to use to authorize this app |
11,153 | def get_access_token ( self , code ) : payload = { 'redirect_uri' : self . redirect_uri , 'code' : code , 'grant_type' : 'authorization_code' } headers = self . _make_authorization_headers ( ) response = requests . post ( self . OAUTH_TOKEN_URL , data = payload , headers = headers , verify = LOGIN_VERIFY_SSL_CERT ) if response . status_code is not 200 : raise MercedesMeAuthError ( response . reason ) token_info = response . json ( ) token_info = self . _add_custom_values_to_token_info ( token_info ) self . _save_token_info ( token_info ) return token_info | Gets the access token for the app given the code |
11,154 | def _add_custom_values_to_token_info ( self , token_info ) : token_info [ 'expires_at' ] = int ( time . time ( ) ) + token_info [ 'expires_in' ] token_info [ 'scope' ] = self . scope return token_info | Store some values that aren t directly provided by a Web API response . |
11,155 | def clear ( self , autoBuild = True ) : for action in self . _actionGroup . actions ( ) : self . _actionGroup . removeAction ( action ) action = QAction ( '' , self ) action . setObjectName ( 'place_holder' ) self . _actionGroup . addAction ( action ) if autoBuild : self . rebuild ( ) | Clears the actions for this widget . |
11,156 | def copyFilepath ( self ) : clipboard = QApplication . instance ( ) . clipboard ( ) clipboard . setText ( self . filepath ( ) ) clipboard . setText ( self . filepath ( ) , clipboard . Selection ) | Copies the current filepath contents to the current clipboard . |
11,157 | def pickFilepath ( self ) : mode = self . filepathMode ( ) filepath = '' filepaths = [ ] curr_dir = nativestring ( self . _filepathEdit . text ( ) ) if ( not curr_dir ) : curr_dir = QDir . currentPath ( ) if mode == XFilepathEdit . Mode . SaveFile : filepath = QFileDialog . getSaveFileName ( self , self . windowTitle ( ) , curr_dir , self . filepathTypes ( ) ) elif mode == XFilepathEdit . Mode . OpenFile : filepath = QFileDialog . getOpenFileName ( self , self . windowTitle ( ) , curr_dir , self . filepathTypes ( ) ) elif mode == XFilepathEdit . Mode . OpenFiles : filepaths = QFileDialog . getOpenFileNames ( self , self . windowTitle ( ) , curr_dir , self . filepathTypes ( ) ) else : filepath = QFileDialog . getExistingDirectory ( self , self . windowTitle ( ) , curr_dir ) if filepath : if type ( filepath ) == tuple : filepath = filepath [ 0 ] self . setFilepath ( nativestring ( filepath ) ) elif filepaths : self . setFilepaths ( map ( str , filepaths ) ) | Prompts the user to select a filepath from the system based on the \ current filepath mode . |
11,158 | def showMenu ( self , pos ) : menu = QMenu ( self ) menu . setAttribute ( Qt . WA_DeleteOnClose ) menu . addAction ( 'Clear' ) . triggered . connect ( self . clearFilepath ) menu . addSeparator ( ) menu . addAction ( 'Copy Filepath' ) . triggered . connect ( self . copyFilepath ) menu . exec_ ( self . mapToGlobal ( pos ) ) | Popups a menu for this widget . |
11,159 | def validateFilepath ( self ) : if ( not self . isValidated ( ) ) : return valid = self . isValid ( ) if ( not valid ) : fg = self . invalidForeground ( ) bg = self . invalidBackground ( ) else : fg = self . validForeground ( ) bg = self . validBackground ( ) palette = self . palette ( ) palette . setColor ( palette . Base , bg ) palette . setColor ( palette . Text , fg ) self . _filepathEdit . setPalette ( palette ) | Alters the color scheme based on the validation settings . |
11,160 | def clear ( self ) : self . uiQueryTXT . setText ( '' ) self . uiQueryTREE . clear ( ) self . uiGroupingTXT . setText ( '' ) self . uiSortingTXT . setText ( '' ) | Clears the information for this edit . |
11,161 | def save ( self ) : record = self . record ( ) if not record : logger . warning ( 'No record has been defined for %s.' % self ) return False if not self . signalsBlocked ( ) : self . aboutToSaveRecord . emit ( record ) self . aboutToSave . emit ( ) values = self . saveValues ( ) check = values . copy ( ) for column_name , value in check . items ( ) : try : equals = value == record . recordValue ( column_name ) except UnicodeWarning : equals = False if equals : check . pop ( column_name ) if not check and record . isRecord ( ) : if not self . signalsBlocked ( ) : self . recordSaved . emit ( record ) self . saved . emit ( ) self . _saveSignalBlocked = False else : self . _saveSignalBlocked = True if self . autoCommitOnSave ( ) : status , result = record . commit ( ) if status == 'errored' : if 'db_error' in result : msg = nativestring ( result [ 'db_error' ] ) else : msg = 'An unknown database error has occurred.' QMessageBox . information ( self , 'Commit Error' , msg ) return False return True success , msg = record . validateValues ( check ) if ( not success ) : QMessageBox . information ( None , 'Could Not Save' , msg ) return False record . setRecordValues ( ** values ) success , msg = record . validateRecord ( ) if not success : QMessageBox . information ( None , 'Could Not Save' , msg ) return False if ( self . autoCommitOnSave ( ) ) : result = record . commit ( ) if 'errored' in result : QMessageBox . information ( None , 'Could Not Save' , msg ) return False if ( not self . signalsBlocked ( ) ) : self . recordSaved . emit ( record ) self . saved . emit ( ) self . _saveSignalBlocked = False else : self . _saveSignalBlocked = True return True | Saves the changes from the ui to this widgets record instance . |
11,162 | def add_dynamic_element ( self , name , description ) : self . _pb . add ( Name = name , Description = description , Value = "*" ) return self | Adds a dynamic namespace element to the end of the Namespace . |
11,163 | def Chrome ( headless = False , user_agent = None , profile_path = None ) : chromedriver = drivers . ChromeDriver ( headless , user_agent , profile_path ) return chromedriver . driver | Starts and returns a Selenium webdriver object for Chrome . |
11,164 | def Firefox ( headless = False , user_agent = None , profile_path = None ) : firefoxdriver = drivers . FirefoxDriver ( headless , user_agent , profile_path ) return firefoxdriver . driver | Starts and returns a Selenium webdriver object for Firefox . |
11,165 | def cancel ( self ) : if self . _running : self . interrupt ( ) self . _running = False self . _cancelled = True self . loadingFinished . emit ( ) | Cancels the current lookup . |
11,166 | def loadBatch ( self , records ) : try : curr_batch = records [ : self . batchSize ( ) ] next_batch = records [ self . batchSize ( ) : ] curr_records = list ( curr_batch ) if self . _preloadColumns : for record in curr_records : record . recordValues ( self . _preloadColumns ) if len ( curr_records ) == self . batchSize ( ) : self . loadedRecords [ object , object ] . emit ( curr_records , next_batch ) else : self . loadedRecords [ object ] . emit ( curr_records ) except ConnectionLostError : self . connectionLost . emit ( ) except Interruption : pass | Loads the records for this instance in a batched mode . |
11,167 | def names ( self ) : if getattr ( self , 'key' , None ) is None : result = [ ] else : result = [ self . key ] if hasattr ( self , 'aliases' ) : result . extend ( self . aliases ) return result | Names by which the instance can be retrieved . |
11,168 | def autoLayout ( self , size = None ) : if size is None : size = self . _view . size ( ) self . setSceneRect ( 0 , 0 , size . width ( ) , size . height ( ) ) for item in self . items ( ) : if isinstance ( item , XWalkthroughGraphic ) : item . autoLayout ( size ) | Updates the layout for the graphics within this scene . |
11,169 | def prepare ( self ) : for item in self . items ( ) : if isinstance ( item , XWalkthroughGraphic ) : item . prepare ( ) | Prepares the items for display . |
11,170 | def autoLayout ( self , size ) : direction = self . property ( 'direction' , QtGui . QBoxLayout . TopToBottom ) x = 0 y = 0 base_off_x = 0 base_off_y = 0 for i , child in enumerate ( self . childItems ( ) ) : off_x = 6 + child . boundingRect ( ) . width ( ) off_y = 6 + child . boundingRect ( ) . height ( ) if direction == QtGui . QBoxLayout . TopToBottom : child . setPos ( x , y ) y += off_y elif direction == QtGui . QBoxLayout . BottomToTop : y -= off_y child . setPos ( x , y ) if not base_off_y : base_off_y = off_y elif direction == QtGui . QBoxLayout . LeftToRight : child . setPos ( x , y ) x += off_x else : x -= off_x child . setPos ( x , y ) if not base_off_x : base_off_x = off_x pos = self . property ( 'pos' ) align = self . property ( 'align' ) offset = self . property ( 'offset' ) rect = self . boundingRect ( ) if pos : x = pos . x ( ) y = pos . y ( ) elif align == QtCore . Qt . AlignCenter : x = ( size . width ( ) - rect . width ( ) ) / 2.0 y = ( size . height ( ) - rect . height ( ) ) / 2.0 else : if align & QtCore . Qt . AlignLeft : x = 0 elif align & QtCore . Qt . AlignRight : x = ( size . width ( ) - rect . width ( ) ) else : x = ( size . width ( ) - rect . width ( ) ) / 2.0 if align & QtCore . Qt . AlignTop : y = 0 elif align & QtCore . Qt . AlignBottom : y = ( size . height ( ) - rect . height ( ) ) else : y = ( size . height ( ) - rect . height ( ) ) / 2.0 if offset : x += offset . x ( ) y += offset . y ( ) x += base_off_x y += base_off_y self . setPos ( x , y ) | Lays out this widget within the graphics scene . |
11,171 | def prepare ( self ) : text = self . property ( 'caption' ) if text : capw = int ( self . property ( 'caption_width' , 0 ) ) item = self . addText ( text , capw ) | Prepares this graphic item to be displayed . |
11,172 | def prepare ( self ) : pixmap = self . property ( 'pixmap' ) if pixmap is not None : return super ( XWalkthroughSnapshot , self ) . prepare ( ) widget = self . property ( 'widget' ) if type ( widget ) in ( unicode , str ) : widget = self . findReference ( widget ) if not widget : return super ( XWalkthroughSnapshot , self ) . prepare ( ) if self . property ( 'overlay' ) and widget . parent ( ) : ref = self . referenceWidget ( ) if ref == widget : pos = QtCore . QPoint ( 0 , 0 ) else : glbl_pos = widget . mapToGlobal ( QtCore . QPoint ( 0 , 0 ) ) pos = ref . mapFromGlobal ( glbl_pos ) self . setProperty ( 'pos' , pos ) crop = self . property ( 'crop' , QtCore . QRect ( 0 , 0 , 0 , 0 ) ) if crop : rect = widget . rect ( ) if crop . width ( ) : rect . setWidth ( crop . width ( ) ) if crop . height ( ) : rect . setHeight ( crop . height ( ) ) if crop . x ( ) : rect . setX ( rect . width ( ) - crop . x ( ) ) if crop . y ( ) : rect . setY ( rect . height ( ) - crop . y ( ) ) pixmap = QtGui . QPixmap . grabWidget ( widget , rect ) else : pixmap = QtGui . QPixmap . grabWidget ( widget ) scaled = self . property ( 'scaled' ) if scaled : pixmap = pixmap . scaled ( pixmap . width ( ) * scaled , pixmap . height ( ) * scaled , QtCore . Qt . KeepAspectRatio , QtCore . Qt . SmoothTransformation ) kwds = { } kwds [ 'whatsThis' ] = widget . whatsThis ( ) kwds [ 'toolTip' ] = widget . toolTip ( ) kwds [ 'windowTitle' ] = widget . windowTitle ( ) kwds [ 'objectName' ] = widget . objectName ( ) self . setProperty ( 'caption' , self . property ( 'caption' , '' ) . format ( ** kwds ) ) self . setProperty ( 'pixmap' , pixmap ) self . addPixmap ( pixmap ) return super ( XWalkthroughSnapshot , self ) . prepare ( ) | Prepares the information for this graphic . |
11,173 | def get_real_layer_path ( self , path ) : filename = path . split ( '/' ) [ - 1 ] local_path = path filetype = os . path . splitext ( filename ) [ 1 ] if re . match ( r'^[a-zA-Z]+://' , path ) : local_path = os . path . join ( DATA_DIRECTORY , filename ) if not os . path . exists ( local_path ) : sys . stdout . write ( '* Downloading %s...\n' % filename ) self . download_file ( path , local_path ) elif self . args . redownload : os . remove ( local_path ) sys . stdout . write ( '* Redownloading %s...\n' % filename ) self . download_file ( path , local_path ) elif not os . path . exists ( local_path ) : raise Exception ( '%s does not exist' % local_path ) real_path = path if filetype == '.zip' : slug = os . path . splitext ( filename ) [ 0 ] real_path = os . path . join ( DATA_DIRECTORY , slug ) if not os . path . exists ( real_path ) : sys . stdout . write ( '* Unzipping...\n' ) self . unzip_file ( local_path , real_path ) return real_path | Get the path the actual layer file . |
11,174 | def download_file ( self , url , local_path ) : response = requests . get ( url , stream = True ) with open ( local_path , 'wb' ) as f : for chunk in tqdm ( response . iter_content ( chunk_size = 1024 ) , unit = 'KB' ) : if chunk : f . write ( chunk ) f . flush ( ) | Download a file from a remote host . |
11,175 | def unzip_file ( self , zip_path , output_path ) : with zipfile . ZipFile ( zip_path , 'r' ) as z : z . extractall ( output_path ) | Unzip a local file into a specified directory . |
11,176 | def process_ogr2ogr ( self , name , layer , input_path ) : output_path = os . path . join ( TEMP_DIRECTORY , '%s.json' % name ) if os . path . exists ( output_path ) : os . remove ( output_path ) ogr2ogr_cmd = [ 'ogr2ogr' , '-f' , 'GeoJSON' , '-clipsrc' , self . config [ 'bbox' ] ] if 'where' in layer : ogr2ogr_cmd . extend ( [ '-where' , '"%s"' % layer [ 'where' ] ] ) ogr2ogr_cmd . extend ( [ output_path , input_path ] ) sys . stdout . write ( '* Running ogr2ogr\n' ) if self . args . verbose : sys . stdout . write ( ' %s\n' % ' ' . join ( ogr2ogr_cmd ) ) r = envoy . run ( ' ' . join ( ogr2ogr_cmd ) ) if r . status_code != 0 : sys . stderr . write ( r . std_err ) return output_path | Process a layer using ogr2ogr . |
11,177 | def process_topojson ( self , name , layer , input_path ) : output_path = os . path . join ( TEMP_DIRECTORY , '%s.topojson' % name ) topojson_binary = 'node_modules/bin/topojson' if not os . path . exists ( topojson_binary ) : topojson_binary = 'topojson' topo_cmd = [ topojson_binary , '-o' , output_path ] if 'id-property' in layer : topo_cmd . extend ( [ '--id-property' , layer [ 'id-property' ] ] ) if layer . get ( 'all-properties' , False ) : topo_cmd . append ( '-p' ) elif 'properties' in layer : topo_cmd . extend ( [ '-p' , ',' . join ( layer [ 'properties' ] ) ] ) topo_cmd . extend ( [ '--' , input_path ] ) sys . stdout . write ( '* Running TopoJSON\n' ) if self . args . verbose : sys . stdout . write ( ' %s\n' % ' ' . join ( topo_cmd ) ) r = envoy . run ( ' ' . join ( topo_cmd ) ) if r . status_code != 0 : sys . stderr . write ( r . std_err ) return output_path | Process layer using topojson . |
11,178 | def merge ( self , paths ) : topojson_binary = 'node_modules/bin/topojson' if not os . path . exists ( topojson_binary ) : topojson_binary = 'topojson' merge_cmd = '%(binary)s -o %(output_path)s --bbox -p -- %(paths)s' % { 'output_path' : self . args . output_path , 'paths' : ' ' . join ( paths ) , 'binary' : topojson_binary } sys . stdout . write ( 'Merging layers\n' ) if self . args . verbose : sys . stdout . write ( ' %s\n' % merge_cmd ) r = envoy . run ( merge_cmd ) if r . status_code != 0 : sys . stderr . write ( r . std_err ) | Merge data layers into a single topojson file . |
11,179 | def createMenu ( self ) : name , accepted = QInputDialog . getText ( self , 'Create Menu' , 'Name: ' ) if ( accepted ) : self . addMenuItem ( self . createMenuItem ( name ) , self . uiMenuTREE . currentItem ( ) ) | Creates a new menu with the given name . |
11,180 | def removeItem ( self ) : item = self . uiMenuTREE . currentItem ( ) if ( not item ) : return opts = QMessageBox . Yes | QMessageBox . No answer = QMessageBox . question ( self , 'Remove Item' , 'Are you sure you want to remove this ' ' item?' , opts ) if ( answer == QMessageBox . Yes ) : parent = item . parent ( ) if ( parent ) : parent . takeChild ( parent . indexOfChild ( item ) ) else : tree = self . uiMenuTREE tree . takeTopLevelItem ( tree . indexOfTopLevelItem ( item ) ) | Removes the item from the menu . |
11,181 | def renameMenu ( self ) : item = self . uiMenuTREE . currentItem ( ) name , accepted = QInputDialog . getText ( self , 'Rename Menu' , 'Name:' , QLineEdit . Normal , item . text ( 0 ) ) if ( accepted ) : item . setText ( 0 , name ) | Prompts the user to supply a new name for the menu . |
11,182 | def showMenu ( self ) : item = self . uiMenuTREE . currentItem ( ) menu = QMenu ( self ) act = menu . addAction ( 'Add Menu...' ) act . setIcon ( QIcon ( projexui . resources . find ( 'img/folder.png' ) ) ) act . triggered . connect ( self . createMenu ) if ( item and item . data ( 0 , Qt . UserRole ) == 'menu' ) : act = menu . addAction ( 'Rename Menu...' ) ico = QIcon ( projexui . resources . find ( 'img/edit.png' ) ) act . setIcon ( ico ) act . triggered . connect ( self . renameMenu ) act = menu . addAction ( 'Add Separator' ) act . setIcon ( QIcon ( projexui . resources . find ( 'img/ui/splitter.png' ) ) ) act . triggered . connect ( self . createSeparator ) menu . addSeparator ( ) act = menu . addAction ( 'Remove Item' ) act . setIcon ( QIcon ( projexui . resources . find ( 'img/remove.png' ) ) ) act . triggered . connect ( self . removeItem ) act . setEnabled ( item is not None ) menu . exec_ ( QCursor . pos ( ) ) | Creates a menu to display for the editing of template information . |
11,183 | def init_app ( self , app ) : host = app . config . get ( 'STATS_HOSTNAME' , 'localhost' ) port = app . config . get ( 'STATS_PORT' , 8125 ) base_key = app . config . get ( 'STATS_BASE_KEY' , app . name ) client = _StatsClient ( host = host , port = port , prefix = base_key , ) app . before_request ( client . flask_time_start ) app . after_request ( client . flask_time_end ) if not hasattr ( app , 'extensions' ) : app . extensions = { } app . extensions . setdefault ( 'stats' , { } ) app . extensions [ 'stats' ] [ self ] = client return client | Inititialise the extension with the app object . |
11,184 | def depends ( func = None , after = None , before = None , priority = None ) : if not ( func is None or inspect . ismethod ( func ) or inspect . isfunction ( func ) ) : raise ValueError ( "depends decorator can only be used on functions or methods" ) if not ( after or before or priority ) : raise ValueError ( "depends decorator needs at least one argument" ) if func is None : return partial ( depends , after = after , before = before , priority = priority ) def self_check ( a , b ) : if a == b : raise ValueError ( "Test '{}' cannot depend on itself" . format ( a ) ) def handle_dep ( conditions , _before = True ) : if conditions : if type ( conditions ) is not list : conditions = [ conditions ] for cond in conditions : if hasattr ( cond , '__call__' ) : cond = cond . __name__ self_check ( func . __name__ , cond ) if _before : soft_dependencies [ cond ] . add ( func . __name__ ) else : dependencies [ func . __name__ ] . add ( cond ) handle_dep ( before ) handle_dep ( after , False ) if priority : priorities [ func . __name__ ] = priority @ wraps ( func ) def inner ( * args , ** kwargs ) : return func ( * args , ** kwargs ) return inner | Decorator to specify test dependencies |
11,185 | def split_on_condition ( seq , condition ) : l1 , l2 = tee ( ( condition ( item ) , item ) for item in seq ) return ( i for p , i in l1 if p ) , ( i for p , i in l2 if not p ) | Split a sequence into two iterables without looping twice |
11,186 | def prepare_suite ( self , suite ) : all_tests = { } for s in suite : m = re . match ( r'(\w+)\s+\(.+\)' , str ( s ) ) if m : name = m . group ( 1 ) else : name = str ( s ) . split ( '.' ) [ - 1 ] all_tests [ name ] = s return self . orderTests ( all_tests , suite ) | Prepare suite and determine test ordering |
11,187 | def dependency_ran ( self , test ) : for d in ( self . test_name ( i ) for i in dependencies [ test ] ) : if d not in self . ok_results : return "Required test '{}' did not run (does it exist?)" . format ( d ) return None | Returns an error string if any of the dependencies did not run |
11,188 | def class_path ( cls ) : if cls . __module__ == '__main__' : path = None else : path = os . path . dirname ( inspect . getfile ( cls ) ) if not path : path = os . getcwd ( ) return os . path . realpath ( path ) | Return the path to the source file of the given class . |
11,189 | def caller_path ( steps = 1 ) : frame = sys . _getframe ( steps + 1 ) try : path = os . path . dirname ( frame . f_code . co_filename ) finally : del frame if not path : path = os . getcwd ( ) return os . path . realpath ( path ) | Return the path to the source file of the current frames caller . |
11,190 | def resource ( self , * resources ) : resources = tuple ( self . resources ) + resources return Resource ( self . client , resources ) | Resource builder with resources url |
11,191 | def match ( self , version ) : if isinstance ( version , basestring ) : version = Version . parse ( version ) return self . operator ( version , self . version ) | Match version with the constraint . |
11,192 | def warnings ( filename , board = 'pro' , hwpack = 'arduino' , mcu = '' , f_cpu = '' , extra_lib = '' , ver = '' , backend = 'arscons' , ) : cc = Arduino ( board = board , hwpack = hwpack , mcu = mcu , f_cpu = f_cpu , extra_lib = extra_lib , ver = ver , backend = backend , ) cc . build ( filename ) print 'backend:' , cc . backend print 'MCU:' , cc . mcu_compiler ( ) print print ( '=============================================' ) print ( 'SIZE' ) print ( '=============================================' ) print 'program:' , cc . size ( ) . program_bytes print 'data:' , cc . size ( ) . data_bytes core_warnings = [ x for x in cc . warnings if 'gcc' in x ] + [ x for x in cc . warnings if 'core' in x ] lib_warnings = [ x for x in cc . warnings if 'lib_' in x ] notsketch_warnings = core_warnings + lib_warnings sketch_warnings = [ x for x in cc . warnings if x not in notsketch_warnings ] print print ( '=============================================' ) print ( 'WARNINGS' ) print ( '=============================================' ) print print ( 'core' ) print ( '-------------------' ) print ( '\n' . join ( core_warnings ) ) print print ( 'lib' ) print ( '-------------------' ) print ( '\n' . join ( lib_warnings ) ) print print ( 'sketch' ) print ( '-------------------' ) print ( '\n' . join ( sketch_warnings ) ) | build Arduino sketch and display results |
11,193 | def accept ( self ) : if ( not self . save ( ) ) : return for i in range ( self . uiActionTREE . topLevelItemCount ( ) ) : item = self . uiActionTREE . topLevelItem ( i ) action = item . action ( ) action . setShortcut ( QKeySequence ( item . text ( 1 ) ) ) super ( XShortcutDialog , self ) . accept ( ) | Saves the current settings for the actions in the list and exits the dialog . |
11,194 | def clear ( self ) : item = self . uiActionTREE . currentItem ( ) if ( not item ) : return self . uiShortcutTXT . setText ( '' ) item . setText ( 1 , '' ) | Clears the current settings for the current action . |
11,195 | def updateAction ( self ) : item = self . uiActionTREE . currentItem ( ) if ( item ) : action = item . action ( ) else : action = QAction ( ) self . uiShortcutTXT . setText ( action . shortcut ( ) . toString ( ) ) | Updates the action to edit based on the current item . |
11,196 | def declassify ( to_remove , * args , ** kwargs ) : def argdecorate ( fn ) : @ wraps ( fn ) def declassed ( * args , ** kwargs ) : ret = fn ( * args , ** kwargs ) try : if type ( ret ) is list : return [ r [ to_remove ] for r in ret ] return ret [ to_remove ] except KeyError : return ret return declassed return argdecorate | flatten the return values of the mite api . |
11,197 | def clean_dict ( d ) : ktd = list ( ) for k , v in d . items ( ) : if not v : ktd . append ( k ) elif type ( v ) is dict : d [ k ] = clean_dict ( v ) for k in ktd : d . pop ( k ) return d | remove the keys with None values . |
11,198 | def load ( self ) : if self . _loaded : return self . setChildIndicatorPolicy ( self . DontShowIndicatorWhenChildless ) self . _loaded = True column = self . schemaColumn ( ) if not column . isReference ( ) : return ref = column . referenceModel ( ) if not ref : return columns = sorted ( ref . schema ( ) . columns ( ) , key = lambda x : x . name ( ) . strip ( '_' ) ) for column in columns : XOrbColumnItem ( self , column ) | Loads the children for this item . |
11,199 | def refresh ( self ) : self . setUpdatesEnabled ( False ) self . blockSignals ( True ) self . clear ( ) tableType = self . tableType ( ) if not tableType : self . setUpdatesEnabled ( True ) self . blockSignals ( False ) return schema = tableType . schema ( ) columns = list ( sorted ( schema . columns ( ) , key = lambda x : x . name ( ) . strip ( '_' ) ) ) for column in columns : XOrbColumnItem ( self , column ) self . setUpdatesEnabled ( True ) self . blockSignals ( False ) | Resets the data for this navigator . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.