idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
7,100 | def cli ( code , cif , parameters , daemon ) : from aiida import orm from aiida . plugins import factories from aiida_codtools . common . cli import CliParameters , CliRunner from aiida_codtools . common . resources import get_default_options process = factories . CalculationFactory ( code . get_attribute ( 'input_plug... | Run any cod - tools calculation for the given CifData node . | 186 | 14 |
7,101 | def make ( parser ) : s = parser . add_subparsers ( title = 'commands' , metavar = 'COMMAND' , help = 'description' , ) def gen_pass_f ( args ) : gen_pass ( ) gen_pass_parser = s . add_parser ( 'gen-pass' , help = 'generate the password' ) gen_pass_parser . set_defaults ( func = gen_pass_f ) def cmd_f ( args ) : cmd ( ... | DEPRECATED prepare OpenStack basic environment | 222 | 8 |
7,102 | def pw_converter ( handler , flt ) : import peewee as pw if isinstance ( flt , Filter ) : return flt model = handler . model field = getattr ( model , flt ) if isinstance ( field , pw . BooleanField ) : return PWBoolFilter ( flt ) if field . choices : choices = [ ( Filter . default , '---' ) ] + list ( field . choices ... | Convert column name to filter . | 115 | 7 |
7,103 | def process ( self , * args , * * kwargs ) : super ( RawIDField , self ) . process ( * args , * * kwargs ) if self . object_data : self . description = self . description or str ( self . object_data ) | Get a description . | 58 | 4 |
7,104 | def _value ( self ) : if self . data is not None : value = self . data . _data . get ( self . field . to_field . name ) return str ( value ) return '' | Get field value . | 43 | 4 |
7,105 | def sort ( self , request , reverse = False ) : field = self . model . _meta . fields . get ( self . columns_sort ) if not field : return self . collection if reverse : field = field . desc ( ) return self . collection . order_by ( field ) | Sort current collection . | 60 | 4 |
7,106 | def value ( self , data ) : value = data . get ( self . name ) if value : return int ( value ) return self . default | Get value from data . | 30 | 5 |
7,107 | def get_fields ( node , fields_tag = "field_list" ) : fields_nodes = [ c for c in node . children if c . tagname == fields_tag ] if len ( fields_nodes ) == 0 : return { } assert len ( fields_nodes ) == 1 , "multiple nodes with tag " + fields_tag fields_node = fields_nodes [ 0 ] fields = [ { f . tagname : f . rawsource ... | Get the field names and their values from a node . | 153 | 11 |
7,108 | def extract_signature ( docstring ) : root = publish_doctree ( docstring , settings_overrides = { "report_level" : 5 } ) fields = get_fields ( root ) return fields . get ( SIG_FIELD ) | Extract the signature from a docstring . | 54 | 9 |
7,109 | def split_parameter_types ( parameters ) : if parameters == "" : return [ ] # only consider the top level commas, ignore the ones in [] commas = [ ] bracket_depth = 0 for i , char in enumerate ( parameters ) : if ( char == "," ) and ( bracket_depth == 0 ) : commas . append ( i ) elif char == "[" : bracket_depth += 1 el... | Split a parameter types declaration into individual types . | 160 | 9 |
7,110 | def parse_signature ( signature ) : if " -> " not in signature : # signature comment: no parameters, treat variable type as return type param_types , return_type = None , signature . strip ( ) else : lhs , return_type = [ s . strip ( ) for s in signature . split ( " -> " ) ] csv = lhs [ 1 : - 1 ] . strip ( ) # remove t... | Parse a signature into its input and return parameter types . | 141 | 12 |
7,111 | def get_aliases ( lines ) : aliases = { } for line in lines : line = line . strip ( ) if len ( line ) > 0 and line . startswith ( SIG_ALIAS ) : _ , content = line . split ( SIG_ALIAS ) alias , signature = [ t . strip ( ) for t in content . split ( "=" ) ] aliases [ alias ] = signature return aliases | Get the type aliases in the source . | 87 | 8 |
7,112 | def get_stub ( source , generic = False ) : generator = StubGenerator ( source , generic = generic ) stub = generator . generate_stub ( ) return stub | Get the stub code for a source code . | 37 | 9 |
7,113 | def get_mod_paths ( mod_name , out_dir ) : paths = [ ] try : mod = get_loader ( mod_name ) source = Path ( mod . path ) if source . name . endswith ( ".py" ) : source_rel = Path ( * mod_name . split ( "." ) ) if source . name == "__init__.py" : source_rel = source_rel . joinpath ( "__init__.py" ) destination = Path ( o... | Get source and stub paths for a module . | 174 | 9 |
7,114 | def get_pkg_paths ( pkg_name , out_dir ) : paths = [ ] try : pkg = import_module ( pkg_name ) if not hasattr ( pkg , "__path__" ) : return get_mod_paths ( pkg_name , out_dir ) for mod_info in walk_packages ( pkg . __path__ , pkg . __name__ + "." ) : mod_paths = get_mod_paths ( mod_info . name , out_dir ) paths . extend... | Recursively get all source and stub paths for a package . | 164 | 13 |
7,115 | def process_docstring ( app , what , name , obj , options , lines ) : aliases = getattr ( app , "_sigaliases" , None ) if aliases is None : if what == "module" : aliases = get_aliases ( inspect . getsource ( obj ) . splitlines ( ) ) app . _sigaliases = aliases sig_marker = ":" + SIG_FIELD + ":" is_class = what in ( "cl... | Modify the docstring before generating documentation . | 711 | 9 |
7,116 | def main ( argv = None ) : parser = ArgumentParser ( prog = "pygenstub" ) parser . add_argument ( "--version" , action = "version" , version = "%(prog)s " + __version__ ) parser . add_argument ( "files" , nargs = "*" , help = "generate stubs for given files" ) parser . add_argument ( "-m" , "--module" , action = "appen... | Start the command line interface . | 674 | 6 |
7,117 | def add_variable ( self , node ) : if node . name not in self . variable_names : self . variables . append ( node ) self . variable_names . add ( node . name ) node . parent = self | Add a variable node to this node . | 47 | 8 |
7,118 | def get_code ( self ) : stub = [ ] for child in self . variables : stub . extend ( child . get_code ( ) ) if ( ( len ( self . variables ) > 0 ) and ( len ( self . children ) > 0 ) and ( not isinstance ( self , ClassNode ) ) ) : stub . append ( "" ) for child in self . children : stub . extend ( child . get_code ( ) ) r... | Get the stub code for this node . | 95 | 8 |
7,119 | def get_code ( self ) : stub = [ ] for deco in self . decorators : if ( deco in DECORATORS ) or deco . endswith ( ".setter" ) : stub . append ( "@" + deco ) parameters = [ ] for name , type_ , has_default in self . parameters : decl = "%(n)s%(t)s%(d)s" % { "n" : name , "t" : ": " + type_ if type_ else "" , "d" : " = ..... | Get the stub code for this function . | 368 | 8 |
7,120 | def get_code ( self ) : stub = [ ] bases = ( "(" + ", " . join ( self . bases ) + ")" ) if len ( self . bases ) > 0 else "" slots = { "n" : self . name , "b" : bases } if ( len ( self . children ) == 0 ) and ( len ( self . variables ) == 0 ) : stub . append ( "class %(n)s%(b)s: ..." % slots ) else : stub . append ( "cl... | Get the stub code for this class . | 170 | 8 |
7,121 | def collect_aliases ( self ) : self . aliases = get_aliases ( self . _code_lines ) for alias , signature in self . aliases . items ( ) : _ , _ , requires = parse_signature ( signature ) self . required_types |= requires self . defined_types |= { alias } | Collect the type aliases in the source . | 69 | 8 |
7,122 | def visit_Import ( self , node ) : line = self . _code_lines [ node . lineno - 1 ] module_name = line . split ( "import" ) [ 0 ] . strip ( ) for name in node . names : imported_name = name . name if name . asname : imported_name = name . asname + "::" + imported_name self . imported_namespaces [ imported_name ] = modul... | Visit an import node . | 96 | 5 |
7,123 | def visit_ImportFrom ( self , node ) : line = self . _code_lines [ node . lineno - 1 ] module_name = line . split ( "from" ) [ 1 ] . split ( "import" ) [ 0 ] . strip ( ) for name in node . names : imported_name = name . name if name . asname : imported_name = name . asname + "::" + imported_name self . imported_names [... | Visit an from - import node . | 106 | 7 |
7,124 | def visit_Assign ( self , node ) : line = self . _code_lines [ node . lineno - 1 ] if SIG_COMMENT in line : line = _RE_COMMENT_IN_STRING . sub ( "" , line ) if ( SIG_COMMENT not in line ) and ( not self . generic ) : return if SIG_COMMENT in line : _ , signature = line . split ( SIG_COMMENT ) _ , return_type , requires... | Visit an assignment node . | 267 | 5 |
7,125 | def visit_FunctionDef ( self , node ) : node = self . get_function_node ( node ) if node is not None : node . _async = False | Visit a function node . | 36 | 5 |
7,126 | def visit_AsyncFunctionDef ( self , node ) : node = self . get_function_node ( node ) if node is not None : node . _async = True | Visit an async function node . | 37 | 6 |
7,127 | def visit_ClassDef ( self , node ) : self . defined_types . add ( node . name ) bases = [ ] for n in node . bases : base_parts = [ ] while True : if not isinstance ( n , ast . Attribute ) : base_parts . append ( n . id ) break else : base_parts . append ( n . attr ) n = n . value bases . append ( "." . join ( base_part... | Visit a class node . | 190 | 5 |
7,128 | def generate_import_from ( module_ , names ) : regular_names = [ n for n in names if "::" not in n ] as_names = [ n for n in names if "::" in n ] line = "" if len ( regular_names ) > 0 : slots = { "m" : module_ , "n" : ", " . join ( sorted ( regular_names ) ) } line = "from %(m)s import %(n)s" % slots if len ( line ) >... | Generate an import line . | 259 | 6 |
7,129 | def has_csv_permission ( self , request , obj = None ) : if getattr ( settings , 'DJANGO_EXPORTS_REQUIRE_PERM' , None ) : opts = self . opts codename = '%s_%s' % ( 'csv' , opts . object_name . lower ( ) ) return request . user . has_perm ( "%s.%s" % ( opts . app_label , codename ) ) return True | Returns True if the given request has permission to add an object . Can be overridden by the user in subclasses . By default we assume all staff users can use this action unless DJANGO_EXPORTS_REQUIRE_PERM is set to True in your django settings . | 105 | 58 |
7,130 | def assoc ( self , key , value ) : copydict = ImmutableDict ( ) copydict . tree = self . tree . assoc ( hash ( key ) , ( key , value ) ) copydict . _length = self . _length + 1 return copydict | Returns a new ImmutableDict instance with value associated with key . The implicit parameter is not modified . | 58 | 21 |
7,131 | def update ( self , other = None , * * kwargs ) : copydict = ImmutableDict ( ) if other : vallist = [ ( hash ( key ) , ( key , other [ key ] ) ) for key in other ] else : vallist = [ ] if kwargs : vallist += [ ( hash ( key ) , ( key , kwargs [ key ] ) ) for key in kwargs ] copydict . tree = self . tree . multi_assoc ( ... | Takes the same arguments as the update method in the builtin dict class . However this version returns a new ImmutableDict instead of modifying in - place . | 131 | 33 |
7,132 | def remove ( self , key ) : copydict = ImmutableDict ( ) copydict . tree = self . tree . remove ( hash ( key ) ) copydict . _length = self . _length - 1 return copydict | Returns a new ImmutableDict with the given key removed . | 48 | 13 |
7,133 | def _load_config ( self ) : config = SafeConfigParser ( ) config_file = os . path . join ( self . config_path , 'settings.ini' ) config . read ( config_file ) for option , type in list ( AVAILABLE_OPTIONS . items ( ) ) : if config . has_option ( 'DEFAULT' , option ) : if type == 'int' : value = config . getint ( 'DEFAU... | Load and parse config file pass options to livestreamer | 179 | 10 |
7,134 | def urn ( self , value : Union [ URN , str ] ) : if isinstance ( value , str ) : value = URN ( value ) elif not isinstance ( value , URN ) : raise TypeError ( "New urn must be string or {} instead of {}" . format ( type ( URN ) , type ( value ) ) ) self . _urn = value | Set the urn | 83 | 4 |
7,135 | def get_cts_metadata ( self , key : str , lang : str = None ) -> Literal : return self . metadata . get_single ( RDF_NAMESPACES . CTS . term ( key ) , lang ) | Get easily a metadata from the CTS namespace | 51 | 9 |
7,136 | def set_metadata_from_collection ( self , text_metadata : CtsTextMetadata ) : edition , work , textgroup = tuple ( ( [ text_metadata ] + text_metadata . parents ) [ : 3 ] ) for node in textgroup . metadata . get ( RDF_NAMESPACES . CTS . groupname ) : lang = node . language self . metadata . add ( RDF_NAMESPACES . CTS .... | Set the object metadata using its collections recursively | 365 | 10 |
7,137 | def create_datapoint ( value , timestamp = None , * * tags ) : if timestamp is None : timestamp = time_millis ( ) if type ( timestamp ) is datetime : timestamp = datetime_to_time_millis ( timestamp ) item = { 'timestamp' : timestamp , 'value' : value } if tags is not None : item [ 'tags' ] = tags return item | Creates a single datapoint dict with a value timestamp and tags . | 86 | 15 |
7,138 | def create_metric ( metric_type , metric_id , data ) : if not isinstance ( data , list ) : data = [ data ] return { 'type' : metric_type , 'id' : metric_id , 'data' : data } | Create Hawkular - Metrics submittable structure . | 56 | 11 |
7,139 | def put ( self , data ) : if not isinstance ( data , list ) : data = [ data ] r = collections . defaultdict ( list ) for d in data : metric_type = d . pop ( 'type' , None ) if metric_type is None : raise HawkularError ( 'Undefined MetricType' ) r [ metric_type ] . append ( d ) # This isn't transactional, but .. ouh wel... | Send multiple different metric_ids to the server in a single batch . Metrics can be a mixture of types . | 146 | 23 |
7,140 | def push ( self , metric_type , metric_id , value , timestamp = None ) : if type ( timestamp ) is datetime : timestamp = datetime_to_time_millis ( timestamp ) item = create_metric ( metric_type , metric_id , create_datapoint ( value , timestamp ) ) self . put ( item ) | Pushes a single metric_id datapoint combination to the server . | 75 | 15 |
7,141 | def query_metric ( self , metric_type , metric_id , start = None , end = None , * * query_options ) : if start is not None : if type ( start ) is datetime : query_options [ 'start' ] = datetime_to_time_millis ( start ) else : query_options [ 'start' ] = start if end is not None : if type ( end ) is datetime : query_opt... | Query for metrics datapoints from the server . | 173 | 11 |
7,142 | def query_metric_stats ( self , metric_type , metric_id = None , start = None , end = None , bucketDuration = None , * * query_options ) : if start is not None : if type ( start ) is datetime : query_options [ 'start' ] = datetime_to_time_millis ( start ) else : query_options [ 'start' ] = start if end is not None : if... | Query for metric aggregates from the server . This is called buckets in the Hawkular - Metrics documentation . | 302 | 22 |
7,143 | def query_metric_definition ( self , metric_type , metric_id ) : return self . _get ( self . _get_metrics_single_url ( metric_type , metric_id ) ) | Query definition of a single metric id . | 46 | 8 |
7,144 | def query_metric_definitions ( self , metric_type = None , id_filter = None , * * tags ) : params = { } if id_filter is not None : params [ 'id' ] = id_filter if metric_type is not None : params [ 'type' ] = MetricType . short ( metric_type ) if len ( tags ) > 0 : params [ 'tags' ] = self . _transform_tags ( * * tags )... | Query available metric definitions . | 120 | 5 |
7,145 | def query_tag_values ( self , metric_type = None , * * tags ) : tagql = self . _transform_tags ( * * tags ) return self . _get ( self . _get_metrics_tags_url ( self . _get_url ( metric_type ) ) + '/{}' . format ( tagql ) ) | Query for possible tag values . | 76 | 6 |
7,146 | def query_metric_tags ( self , metric_type , metric_id ) : definition = self . _get ( self . _get_metrics_tags_url ( self . _get_metrics_single_url ( metric_type , metric_id ) ) ) return definition | Returns a list of tags in the metric definition . | 62 | 10 |
7,147 | def delete_metric_tags ( self , metric_type , metric_id , * * deleted_tags ) : tags = self . _transform_tags ( * * deleted_tags ) tags_url = self . _get_metrics_tags_url ( self . _get_metrics_single_url ( metric_type , metric_id ) ) + '/{0}' . format ( tags ) self . _delete ( tags_url ) | Delete one or more tags from the metric definition . | 97 | 10 |
7,148 | def create_tenant ( self , tenant_id , retentions = None ) : item = { 'id' : tenant_id } if retentions is not None : item [ 'retentions' ] = retentions self . _post ( self . _get_tenants_url ( ) , json . dumps ( item , indent = 2 ) ) | Create a tenant . Currently nothing can be set ( to be fixed after the master version of Hawkular - Metrics has fixed implementation . | 78 | 27 |
7,149 | def get_default_options ( num_machines = 1 , max_wallclock_seconds = 1800 , withmpi = False ) : return { 'resources' : { 'num_machines' : int ( num_machines ) } , 'max_wallclock_seconds' : int ( max_wallclock_seconds ) , 'withmpi' : withmpi , } | Return an instance of the options dictionary with the minimally required parameters for a JobCalculation and set to default values unless overriden | 86 | 27 |
7,150 | def take_screenshot ( self ) : if not self . failed : return browser = getattr ( world , 'browser' , None ) if not browser : return try : scenario_name = self . scenario . name scenario_index = self . scenario . feature . scenarios . index ( self . scenario ) + 1 except AttributeError : scenario_name = self . backgroun... | Take a screenshot after a failed step . | 301 | 8 |
7,151 | def kunc_p ( v , v0 , k0 , k0p , order = 5 ) : return cal_p_kunc ( v , [ v0 , k0 , k0p ] , order = order , uncertainties = isuncertainties ( [ v , v0 , k0 , k0p ] ) ) | calculate Kunc EOS see Dorogokupets 2015 for detail | 71 | 16 |
7,152 | def cal_p_kunc ( v , k , order = 5 , uncertainties = True ) : v0 = k [ 0 ] k0 = k [ 1 ] k0p = k [ 2 ] x = np . power ( v / v0 , 1. / 3. ) f1 = ( 1. - x ) / ( np . power ( x , order ) ) if uncertainties : f2 = unp . exp ( ( 1.5 * k0p - order + 0.5 ) * ( 1. - x ) ) else : f2 = np . exp ( ( 1.5 * k0p - order + 0.5 ) * ( 1... | calculate Kunc EOS see Dorogokupets2015 for functional form | 160 | 17 |
7,153 | def find_files ( path = '' , ext = '' , level = None , typ = list , dirs = False , files = True , verbosity = 0 ) : gen = generate_files ( path , ext = ext , level = level , dirs = dirs , files = files , verbosity = verbosity ) if isinstance ( typ ( ) , collections . Mapping ) : return typ ( ( ff [ 'path' ] , ff ) for ... | Recursively find all files in the indicated directory | 116 | 10 |
7,154 | def serialize ( self ) : if type ( self . value ) == int : return "i{:X}s" . format ( self . value ) . encode ( 'ascii' ) if type ( self . value ) == str : value = self . value . encode ( 'utf-8' ) return "{:X}:" . format ( len ( value ) ) . encode ( 'ascii' ) + value if type ( self . value ) == bytes : value = base64 ... | Serialize the token and return it as bytes . | 289 | 10 |
7,155 | def write ( self , file_or_path , append = False , timeout = 10 ) : if isinstance ( file_or_path , six . string_types ) : if self . coverage : file_or_path = get_smother_filename ( file_or_path , self . coverage . config . parallel ) outfile = Lock ( file_or_path , mode = 'a+' , timeout = timeout , fail_when_locked = F... | Write Smother results to a file . | 193 | 8 |
7,156 | def query_context ( self , regions , file_factory = PythonFile ) : result = set ( ) for region in regions : try : pf = file_factory ( region . filename ) except InvalidPythonFile : continue # region and/or coverage report may use paths # relative to this directory. Ensure we find a match # if they use different convent... | Return which set of test contexts intersect a set of code regions . | 167 | 13 |
7,157 | def add_child ( self , child ) : if isinstance ( child , BaseCitation ) : self . _children . append ( child ) | Adds a child to the CitationSet | 30 | 7 |
7,158 | def depth ( self ) -> int : if len ( self . children ) : return 1 + max ( [ child . depth for child in self . children ] ) else : return 1 | Depth of the citation scheme | 37 | 5 |
7,159 | def set_link ( self , prop , value ) : # https://rdflib.readthedocs.io/en/stable/ # URIRef == identifiers (urn, http, URI in general) # Literal == String or Number (can have a language) # BNode == Anonymous nodes (So no specific identifier) # eg. BNode : Edition(MartialEpigrams:URIRef) ---has_metadata--> Metadata(BNode... | Set given link in CTS Namespace | 130 | 8 |
7,160 | def editions ( self ) : return [ item for urn , item in self . parent . children . items ( ) if isinstance ( item , CtsEditionMetadata ) ] | Get all editions of the texts | 38 | 6 |
7,161 | def get_description ( self , lang = None ) : return self . metadata . get_single ( key = RDF_NAMESPACES . CTS . description , lang = lang ) | Get the DC description of the object | 40 | 7 |
7,162 | def lang ( self ) : return str ( self . graph . value ( self . asNode ( ) , DC . language ) ) | Languages this text is in | 27 | 6 |
7,163 | def lang ( self , lang ) : self . graph . set ( ( self . asNode ( ) , DC . language , Literal ( lang ) ) ) | Language this text is available in | 33 | 6 |
7,164 | def update ( self , other ) : if not isinstance ( other , CtsWorkMetadata ) : raise TypeError ( "Cannot add %s to CtsWorkMetadata" % type ( other ) ) elif self . urn != other . urn : raise InvalidURN ( "Cannot add CtsWorkMetadata %s to CtsWorkMetadata %s " % ( self . urn , other . urn ) ) for urn , text in other . chil... | Merge two XmlCtsWorkMetadata Objects . | 141 | 12 |
7,165 | def get_translation_in ( self , key = None ) : if key is not None : return [ item for item in self . texts . values ( ) if isinstance ( item , CtsTranslationMetadata ) and item . lang == key ] else : return [ item for item in self . texts . values ( ) if isinstance ( item , CtsTranslationMetadata ) ] | Find a translation with given language | 80 | 6 |
7,166 | def update ( self , other ) : if not isinstance ( other , CtsTextgroupMetadata ) : raise TypeError ( "Cannot add %s to CtsTextgroupMetadata" % type ( other ) ) elif str ( self . urn ) != str ( other . urn ) : raise InvalidURN ( "Cannot add CtsTextgroupMetadata %s to CtsTextgroupMetadata %s " % ( self . urn , other . ur... | Merge two Textgroup Objects . | 181 | 7 |
7,167 | def get ( self , tags = [ ] , trigger_ids = [ ] ) : params = { } if len ( tags ) > 0 : params [ 'tags' ] = ',' . join ( tags ) if len ( trigger_ids ) > 0 : params [ 'triggerIds' ] = ',' . join ( trigger_ids ) url = self . _service_url ( 'triggers' , params = params ) triggers_dict = self . _get ( url ) return Trigger .... | Get triggers with optional filtering . Querying without parameters returns all the trigger definitions . | 117 | 17 |
7,168 | def create ( self , trigger ) : data = self . _serialize_object ( trigger ) if isinstance ( trigger , FullTrigger ) : returned_dict = self . _post ( self . _service_url ( [ 'triggers' , 'trigger' ] ) , data ) return FullTrigger ( returned_dict ) else : returned_dict = self . _post ( self . _service_url ( 'triggers' ) ,... | Create a new trigger . | 103 | 5 |
7,169 | def update ( self , trigger_id , full_trigger ) : data = self . _serialize_object ( full_trigger ) rdict = self . _put ( self . _service_url ( [ 'triggers' , 'trigger' , trigger_id ] ) , data ) return FullTrigger ( rdict ) | Update an existing full trigger . | 69 | 6 |
7,170 | def create_group ( self , trigger ) : data = self . _serialize_object ( trigger ) return Trigger ( self . _post ( self . _service_url ( [ 'triggers' , 'groups' ] ) , data ) ) | Create a new group trigger . | 53 | 6 |
7,171 | def group_members ( self , group_id , include_orphans = False ) : params = { 'includeOrphans' : str ( include_orphans ) . lower ( ) } url = self . _service_url ( [ 'triggers' , 'groups' , group_id , 'members' ] , params = params ) return Trigger . list_to_object_list ( self . _get ( url ) ) | Find all group member trigger definitions | 92 | 6 |
7,172 | def update_group ( self , group_id , trigger ) : data = self . _serialize_object ( trigger ) self . _put ( self . _service_url ( [ 'triggers' , 'groups' , group_id ] ) , data , parse_json = False ) | Update an existing group trigger definition and its member definitions . | 63 | 11 |
7,173 | def delete_group ( self , group_id , keep_non_orphans = False , keep_orphans = False ) : params = { 'keepNonOrphans' : str ( keep_non_orphans ) . lower ( ) , 'keepOrphans' : str ( keep_orphans ) . lower ( ) } self . _delete ( self . _service_url ( [ 'triggers' , 'groups' , group_id ] , params = params ) ) | Delete a group trigger | 103 | 4 |
7,174 | def create_group_member ( self , member ) : data = self . _serialize_object ( member ) return Trigger ( self . _post ( self . _service_url ( [ 'triggers' , 'groups' , 'members' ] ) , data ) ) | Create a new member trigger for a parent trigger . | 59 | 10 |
7,175 | def set_group_conditions ( self , group_id , conditions , trigger_mode = None ) : data = self . _serialize_object ( conditions ) if trigger_mode is not None : url = self . _service_url ( [ 'triggers' , 'groups' , group_id , 'conditions' , trigger_mode ] ) else : url = self . _service_url ( [ 'triggers' , 'groups' , gro... | Set the group conditions . | 133 | 5 |
7,176 | def set_conditions ( self , trigger_id , conditions , trigger_mode = None ) : data = self . _serialize_object ( conditions ) if trigger_mode is not None : url = self . _service_url ( [ 'triggers' , trigger_id , 'conditions' , trigger_mode ] ) else : url = self . _service_url ( [ 'triggers' , trigger_id , 'conditions' ]... | Set the conditions for the trigger . | 123 | 7 |
7,177 | def conditions ( self , trigger_id ) : response = self . _get ( self . _service_url ( [ 'triggers' , trigger_id , 'conditions' ] ) ) return Condition . list_to_object_list ( response ) | Get all conditions for a specific trigger . | 55 | 8 |
7,178 | def create_dampening ( self , trigger_id , dampening ) : data = self . _serialize_object ( dampening ) url = self . _service_url ( [ 'triggers' , trigger_id , 'dampenings' ] ) return Dampening ( self . _post ( url , data ) ) | Create a new dampening . | 73 | 6 |
7,179 | def delete_dampening ( self , trigger_id , dampening_id ) : self . _delete ( self . _service_url ( [ 'triggers' , trigger_id , 'dampenings' , dampening_id ] ) ) | Delete an existing dampening definition . | 56 | 7 |
7,180 | def update_dampening ( self , trigger_id , dampening_id ) : data = self . _serialize_object ( dampening ) url = self . _service_url ( [ 'triggers' , trigger_id , 'dampenings' , dampening_id ] ) return Dampening ( self . _put ( url , data ) ) | Update an existing dampening definition . | 80 | 7 |
7,181 | def create_group_dampening ( self , group_id , dampening ) : data = self . _serialize_object ( dampening ) url = self . _service_url ( [ 'triggers' , 'groups' , group_id , 'dampenings' ] ) return Dampening ( self . _post ( url , data ) ) | Create a new group dampening | 79 | 6 |
7,182 | def update_group_dampening ( self , group_id , dampening_id , dampening ) : data = self . _serialize_object ( dampening ) url = self . _service_url ( [ 'triggers' , 'groups' , group_id , 'dampenings' , dampening_id ] ) return Dampening ( self . _put ( url , data ) ) | Update an existing group dampening | 89 | 6 |
7,183 | def delete_group_dampening ( self , group_id , dampening_id ) : self . _delete ( self . _service_url ( [ 'triggers' , 'groups' , group_id , 'dampenings' , dampening_id ] ) ) | Delete an existing group dampening | 62 | 6 |
7,184 | def set_group_member_orphan ( self , member_id ) : self . _put ( self . _service_url ( [ 'triggers' , 'groups' , 'members' , member_id , 'orphan' ] ) , data = None , parse_json = False ) | Make a non - orphan member trigger into an orphan . | 65 | 11 |
7,185 | def set_group_member_unorphan ( self , member_id , unorphan_info ) : data = self . _serialize_object ( unorphan_info ) data = self . _service_url ( [ 'triggers' , 'groups' , 'members' , member_id , 'unorphan' ] ) return Trigger ( self . _put ( url , data ) ) | Make an orphan member trigger into an group trigger . | 88 | 10 |
7,186 | def enable ( self , trigger_ids = [ ] ) : trigger_ids = ',' . join ( trigger_ids ) url = self . _service_url ( [ 'triggers' , 'enabled' ] , params = { 'triggerIds' : trigger_ids , 'enabled' : 'true' } ) self . _put ( url , data = None , parse_json = False ) | Enable triggers . | 86 | 3 |
7,187 | def get_twitter ( app_key = None , app_secret = None , search = 'python' , location = '' , * * kwargs ) : if not app_key : from settings_secret import TWITTER_API_KEY as app_key if not app_secret : from settings_secret import TWITTER_API_SECRET as app_secret twitter = Twython ( app_key , app_secret , oauth_version = 2 ... | Location may be specified with a string name or latitude longitude radius | 121 | 13 |
7,188 | def limitted_dump ( cursor = None , twitter = None , path = 'tweets.json' , limit = 450 , rate = TWITTER_SEARCH_RATE_LIMIT , indent = - 1 ) : if not twitter : twitter = get_twitter ( ) cursor = cursor or 'python' if isinstance ( cursor , basestring ) : cursor = get_cursor ( twitter , search = cursor ) newline = '\n' if... | Dump a limitted number of json . dump - able objects to the indicated file | 268 | 17 |
7,189 | def altshuler_grun ( v , v0 , gamma0 , gamma_inf , beta ) : x = v / v0 return gamma_inf + ( gamma0 - gamma_inf ) * np . power ( x , beta ) | calculate Gruneisen parameter for Altshuler equation | 52 | 13 |
7,190 | def altshuler_debyetemp ( v , v0 , gamma0 , gamma_inf , beta , theta0 ) : x = v / v0 if isuncertainties ( [ v , v0 , gamma0 , gamma_inf , beta , theta0 ] ) : theta = theta0 * np . power ( x , - 1. * gamma_inf ) * unp . exp ( ( gamma0 - gamma_inf ) / beta * ( 1. - np . power ( x , beta ) ) ) else : theta = theta0 * np .... | calculate Debye temperature for Altshuler equation | 170 | 12 |
7,191 | def dorogokupets2007_pth ( v , temp , v0 , gamma0 , gamma_inf , beta , theta0 , n , z , three_r = 3. * constants . R , t_ref = 300. ) : v_mol = vol_uc2mol ( v , z ) # x = v_mol / v0_mol gamma = altshuler_grun ( v , v0 , gamma0 , gamma_inf , beta ) theta = altshuler_debyetemp ( v , v0 , gamma0 , gamma_inf , beta , theta... | calculate thermal pressure for Dorogokupets 2007 EOS | 197 | 14 |
7,192 | def bind ( cls , app , * paths , methods = None , name = None , view = None ) : # Register self in admin if view is None : app . ps . admin . register ( cls ) if not paths : paths = ( '%s/%s' % ( app . ps . admin . cfg . prefix , name or cls . name ) , ) cls . url = paths [ 0 ] return super ( AdminHandler , cls ) . bin... | Connect to admin interface and application . | 119 | 7 |
7,193 | def action ( cls , view ) : name = "%s:%s" % ( cls . name , view . __name__ ) path = "%s/%s" % ( cls . url , view . __name__ ) cls . actions . append ( ( view . __doc__ , path ) ) return cls . register ( path , name = name ) ( view ) | Register admin view action . | 83 | 5 |
7,194 | async def dispatch ( self , request , * * kwargs ) : # Authorize request self . auth = await self . authorize ( request ) # Load collection self . collection = await self . load_many ( request ) # Load resource self . resource = await self . load_one ( request ) if request . method == 'GET' and self . resource is None ... | Dispatch a request . | 255 | 4 |
7,195 | async def sort ( self , request , reverse = False ) : return sorted ( self . collection , key = lambda o : getattr ( o , self . columns_sort , 0 ) , reverse = reverse ) | Sort collection . | 44 | 3 |
7,196 | async def get_form ( self , request ) : if not self . form : return None formdata = await request . post ( ) return self . form ( formdata , obj = self . resource ) | Base point load resource . | 43 | 5 |
7,197 | async def get ( self , request ) : form = await self . get_form ( request ) ctx = dict ( active = self , form = form , request = request ) if self . resource : return self . app . ps . jinja2 . render ( self . template_item , * * ctx ) return self . app . ps . jinja2 . render ( self . template_list , * * ctx ) | Get collection of resources . | 93 | 5 |
7,198 | def columns_formatter ( cls , colname ) : def wrapper ( func ) : cls . columns_formatters [ colname ] = func return func return wrapper | Decorator to mark a function as columns formatter . | 36 | 12 |
7,199 | def render_value ( self , data , column ) : renderer = self . columns_formatters . get ( column , format_value ) return renderer ( self , data , column ) | Render value . | 40 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.