idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
8,200 | def store ( self , secrets , job ) : for j in job : if j in secrets : job [ j ] = self . add ( job [ j ] ) | Sanitize the job object of any of the given secrets . |
8,201 | def has_secret ( self , value ) : if isinstance ( value , string_types ) : for k in self . secrets : if k in value : return True elif isinstance ( value , MutableMapping ) : for this_value in value . values ( ) : if self . has_secret ( this_value ) : return True elif isinstance ( value , MutableSequence ) : for this_va... | Test if the provided document has any of our secrets . |
8,202 | def retrieve ( self , value ) : if isinstance ( value , string_types ) : for key , this_value in self . secrets . items ( ) : value = value . replace ( key , this_value ) elif isinstance ( value , MutableMapping ) : return { k : self . retrieve ( v ) for k , v in value . items ( ) } elif isinstance ( value , MutableSeq... | Replace placeholders with their corresponding secrets . |
8,203 | def _check_mod_11_2 ( numeric_string ) : nums = numeric_string . replace ( "-" , "" ) total = 0 for num in nums [ : - 1 ] : digit = int ( num ) total = ( total + digit ) * 2 remainder = total % 11 result = ( 12 - remainder ) % 11 if result == 10 : checkdigit = "X" else : checkdigit = str ( result ) return nums [ - 1 ] ... | Validate numeric_string for its MOD - 11 - 2 checksum . |
8,204 | def _valid_orcid ( orcid ) : if orcid is None or not orcid : raise ValueError ( u'ORCID cannot be unspecified' ) orcid = orcid . lower ( ) match = re . match ( r"(http://orcid\.org/|https://orcid\.org/|orcid\.org/)?" r"(?P<orcid>(\d{4}-\d{4}-\d{4}-\d{3}[0-9x]))$" , orcid ) help_url = u"https://support.orcid.org/knowled... | Ensure orcid is a valid ORCID identifier . |
8,205 | def checksum_copy ( src_file , dst_file = None , hasher = Hasher , buffersize = 1024 * 1024 ) : checksum = hasher ( ) contents = src_file . read ( buffersize ) if dst_file and hasattr ( dst_file , "name" ) and hasattr ( src_file , "name" ) : temp_location = os . path . join ( os . path . dirname ( dst_file . name ) , s... | Compute checksums while copying a file . |
8,206 | def copy_job_order ( job , job_order_object ) : if not hasattr ( job , "tool" ) : return job_order_object customised_job = { } for each , i in enumerate ( job . tool [ "inputs" ] ) : with SourceLine ( job . tool [ "inputs" ] , each , WorkflowException , _logger . isEnabledFor ( logging . DEBUG ) ) : iid = shortname ( i... | Create copy of job object for provenance . |
8,207 | def evaluate ( self , process , job , job_order_object , research_obj ) : if not hasattr ( process , "steps" ) : self . prospective_prov ( job ) customised_job = copy_job_order ( job , job_order_object ) self . used_artefacts ( customised_job , self . workflow_run_uri ) research_obj . create_job ( customised_job , job ... | Evaluate the nature of job |
8,208 | def start_process ( self , process_name , when , process_run_id = None ) : if process_run_id is None : process_run_id = uuid . uuid4 ( ) . urn prov_label = "Run of workflow/packed.cwl#main/" + process_name self . document . activity ( process_run_id , None , None , { provM . PROV_TYPE : WFPROV [ "ProcessRun" ] , provM ... | Record the start of each Process . |
8,209 | def declare_string ( self , value ) : byte_s = BytesIO ( str ( value ) . encode ( ENCODING ) ) data_file = self . research_object . add_data_file ( byte_s , content_type = TEXT_PLAIN ) checksum = posixpath . basename ( data_file ) data_id = "data:%s" % posixpath . split ( data_file ) [ 1 ] entity = self . document . en... | Save as string in UTF - 8 . |
8,210 | def finalize_prov_profile ( self , name ) : if name is None : filename = "primary.cwlprov" else : wf_name = urllib . parse . quote ( str ( name ) , safe = "" ) . replace ( "%" , "_" ) filename = "%s.%s.cwlprov" % ( wf_name , self . workflow_run_uuid ) basename = posixpath . join ( _posix_path ( PROVENANCE ) , filename ... | Transfer the provenance related files to the RO . |
8,211 | def _initialize_bagit ( self ) : self . self_check ( ) bagit = os . path . join ( self . folder , "bagit.txt" ) with open ( bagit , "w" , encoding = ENCODING , newline = '\n' ) as bag_it_file : bag_it_file . write ( u"BagIt-Version: 0.97\n" ) bag_it_file . write ( u"Tag-File-Character-Encoding: %s\n" % ENCODING ) | Write fixed bagit header . |
8,212 | def user_provenance ( self , document ) : self . self_check ( ) ( username , fullname ) = _whoami ( ) if not self . full_name : self . full_name = fullname document . add_namespace ( UUID ) document . add_namespace ( ORCID ) document . add_namespace ( FOAF ) account = document . agent ( ACCOUNT_UUID , { provM . PROV_TY... | Add the user provenance . |
8,213 | def write_bag_file ( self , path , encoding = ENCODING ) : self . self_check ( ) bag_file = cast ( IO , WritableBagFile ( self , path ) ) if encoding is not None : return cast ( IO , TextIOWrapper ( bag_file , encoding = encoding , newline = "\n" ) ) return bag_file | Write the bag file into our research object . |
8,214 | def add_tagfile ( self , path , timestamp = None ) : self . self_check ( ) checksums = { } if os . path . isdir ( path ) : return with open ( path , "rb" ) as tag_file : checksums [ SHA1 ] = checksum_copy ( tag_file , hasher = hashlib . sha1 ) tag_file . seek ( 0 ) checksums [ SHA256 ] = checksum_copy ( tag_file , hash... | Add tag files to our research object . |
8,215 | def _ro_aggregates ( self ) : def guess_mediatype ( rel_path ) : media_types = { "txt" : TEXT_PLAIN , "ttl" : 'text/turtle; charset="UTF-8"' , "rdf" : 'application/rdf+xml' , "json" : 'application/json' , "jsonld" : 'application/ld+json' , "xml" : 'application/xml' , "cwl" : 'text/x+yaml; charset="UTF-8"' , "provn" : '... | Gather dictionary of files to be added to the manifest . |
8,216 | def packed_workflow ( self , packed ) : self . self_check ( ) rel_path = posixpath . join ( _posix_path ( WORKFLOW ) , "packed.cwl" ) with self . write_bag_file ( rel_path , encoding = None ) as write_pack : write_pack . write ( packed . encode ( ENCODING ) ) _logger . debug ( u"[provenance] Added packed workflow: %s" ... | Pack CWL description to generate re - runnable CWL object in RO . |
8,217 | def has_data_file ( self , sha1hash ) : folder = os . path . join ( self . folder , DATA , sha1hash [ 0 : 2 ] ) hash_path = os . path . join ( folder , sha1hash ) return os . path . isfile ( hash_path ) | Confirms the presence of the given file in the RO . |
8,218 | def add_to_manifest ( self , rel_path , checksums ) : self . self_check ( ) if posixpath . isabs ( rel_path ) : raise ValueError ( "rel_path must be relative: %s" % rel_path ) if posixpath . commonprefix ( [ "data/" , rel_path ] ) == "data/" : manifest = "manifest" else : manifest = "tagmanifest" for ( method , hash_va... | Add files to the research object manifest . |
8,219 | def create_job ( self , builder_job , wf_job = None , is_output = False ) : copied = copy . deepcopy ( builder_job ) relativised_input_objecttemp = { } self . _relativise_files ( copied ) def jdefault ( o ) : return dict ( o ) if is_output : rel_path = posixpath . join ( _posix_path ( WORKFLOW ) , "primary-output.json"... | Generate the new job object with RO specific relative paths . |
8,220 | def _relativise_files ( self , structure ) : _logger . debug ( u"[provenance] Relativising: %s" , structure ) if isinstance ( structure , MutableMapping ) : if structure . get ( "class" ) == "File" : relative_path = None if "checksum" in structure : alg , checksum = structure [ "checksum" ] . split ( "$" ) if alg != SH... | Save any file objects into the RO and update the local paths . |
8,221 | def close ( self , save_to = None ) : if save_to is None : if not self . closed : _logger . debug ( u"[provenance] Deleting temporary %s" , self . folder ) shutil . rmtree ( self . folder , ignore_errors = True ) else : save_to = os . path . abspath ( save_to ) _logger . info ( u"[provenance] Finalizing Research Object... | Close the Research Object optionally saving to specified folder . |
8,222 | def printrdf ( wflow , ctx , style ) : rdf = gather ( wflow , ctx ) . serialize ( format = style , encoding = 'utf-8' ) if not rdf : return u"" return rdf . decode ( 'utf-8' ) | Serialize the CWL document into a string ready for printing . |
8,223 | def create_runtime ( self , env , runtime_context ) : any_path_okay = self . builder . get_requirement ( "DockerRequirement" ) [ 1 ] or False runtime = [ u"singularity" , u"--quiet" , u"exec" , u"--contain" , u"--pid" , u"--ipc" ] if _singularity_supports_userns ( ) : runtime . append ( u"--userns" ) runtime . append (... | Returns the Singularity runtime list of commands and options . |
8,224 | def fetch_document ( argsworkflow , loadingContext = None ) : if loadingContext is None : loadingContext = LoadingContext ( ) loadingContext . loader = default_loader ( ) else : loadingContext = loadingContext . copy ( ) if loadingContext . loader is None : loadingContext . loader = default_loader ( loadingContext . fe... | Retrieve a CWL document . |
8,225 | def make_tool ( uri , loadingContext ) : if loadingContext . loader is None : raise ValueError ( "loadingContext must have a loader" ) resolveduri , metadata = loadingContext . loader . resolve_ref ( uri ) processobj = None if isinstance ( resolveduri , MutableSequence ) : for obj in resolveduri : if obj [ 'id' ] . end... | Make a Python CWL object . |
8,226 | def revmap_file ( builder , outdir , f ) : split = urllib . parse . urlsplit ( outdir ) if not split . scheme : outdir = file_uri ( str ( outdir ) ) if "location" in f and "path" not in f : if f [ "location" ] . startswith ( "file://" ) : f [ "path" ] = convert_pathsep_to_unix ( uri_file_path ( f [ "location" ] ) ) els... | Remap a file from internal path to external path . |
8,227 | def check_adjust ( builder , file_o ) : if not builder . pathmapper : raise ValueError ( "Do not call check_adjust using a builder that doesn't have a pathmapper." ) file_o [ "path" ] = docker_windows_path_adjust ( builder . pathmapper . mapper ( file_o [ "location" ] ) [ 1 ] ) dn , bn = os . path . split ( file_o [ "p... | Map files to assigned path inside a container . |
8,228 | def _flat_crossproduct_scatter ( process , joborder , scatter_keys , callback , startindex , runtimeContext ) : scatter_key = scatter_keys [ 0 ] jobl = len ( joborder [ scatter_key ] ) steps = [ ] put = startindex for index in range ( 0 , jobl ) : sjob = copy . copy ( joborder ) sjob [ scatter_key ] = joborder [ scatte... | Inner loop . |
8,229 | def formatSubclassOf ( fmt , cls , ontology , visited ) : if URIRef ( fmt ) == URIRef ( cls ) : return True if ontology is None : return False if fmt in visited : return False visited . add ( fmt ) uriRefFmt = URIRef ( fmt ) for s , p , o in ontology . triples ( ( uriRefFmt , RDFS . subClassOf , None ) ) : if formatSub... | Determine if fmt is a subclass of cls . |
8,230 | def check_format ( actual_file , input_formats , ontology ) : for afile in aslist ( actual_file ) : if not afile : continue if "format" not in afile : raise validate . ValidationException ( u"File has no 'format' defined: {}" . format ( json_dumps ( afile , indent = 4 ) ) ) for inpf in aslist ( input_formats ) : if afi... | Confirms that the format present is valid for the allowed formats . |
8,231 | def v1_0to1_1_0dev1 ( doc , loader , baseuri ) : doc = copy . deepcopy ( doc ) rewrite = { "http://commonwl.org/cwltool#WorkReuse" : "WorkReuse" , "http://commonwl.org/cwltool#TimeLimit" : "ToolTimeLimit" , "http://commonwl.org/cwltool#NetworkAccess" : "NetworkAccess" , "http://commonwl.org/cwltool#InplaceUpdateRequire... | Public updater for v1 . 0 to v1 . 1 . 0 - dev1 . |
8,232 | def checkversion ( doc , metadata , enable_dev ) : cdoc = None if isinstance ( doc , CommentedSeq ) : if not isinstance ( metadata , CommentedMap ) : raise Exception ( "Expected metadata to be CommentedMap" ) lc = metadata . lc metadata = copy . deepcopy ( metadata ) metadata . lc . data = copy . copy ( lc . data ) met... | Checks the validity of the version of the give CWL document . |
8,233 | def stage_files ( pathmapper , stage_func = None , ignore_writable = False , symlink = True , secret_store = None ) : for key , entry in pathmapper . items ( ) : if not entry . staged : continue if not os . path . exists ( os . path . dirname ( entry . target ) ) : os . makedirs ( os . path . dirname ( entry . target )... | Link or copy files to their targets . Create them as needed . |
8,234 | def avroize_type ( field_type , name_prefix = "" ) : if isinstance ( field_type , MutableSequence ) : for field in field_type : avroize_type ( field , name_prefix ) elif isinstance ( field_type , MutableMapping ) : if field_type [ "type" ] in ( "enum" , "record" ) : if "name" not in field_type : field_type [ "name" ] =... | adds missing information to a type so that CWL types are valid in schema_salad . |
8,235 | def versionstring ( ) : pkg = pkg_resources . require ( "cwltool" ) if pkg : return u"%s %s" % ( sys . argv [ 0 ] , pkg [ 0 ] . version ) return u"%s %s" % ( sys . argv [ 0 ] , "unknown version" ) | version of CWLtool used to execute the workflow . |
8,236 | def docker_windows_path_adjust ( path ) : r if onWindows ( ) : split = path . split ( ':' ) if len ( split ) == 2 : if platform . win32_ver ( ) [ 0 ] in ( '7' , '8' ) : split [ 0 ] = split [ 0 ] . lower ( ) else : split [ 0 ] = split [ 0 ] . capitalize ( ) path = ':' . join ( split ) path = path . replace ( ':' , '' ) ... | r Changes only windows paths so that the can be appropriately passed to the docker run command as as docker treats them as unix paths . |
8,237 | def bytes2str_in_dicts ( inp ) : if isinstance ( inp , MutableMapping ) : for k in inp : inp [ k ] = bytes2str_in_dicts ( inp [ k ] ) return inp if isinstance ( inp , MutableSequence ) : for idx , value in enumerate ( inp ) : inp [ idx ] = bytes2str_in_dicts ( value ) return inp elif isinstance ( inp , bytes ) : return... | Convert any present byte string to unicode string inplace . input is a dict of nested dicts and lists |
8,238 | def visit_class ( rec , cls , op ) : if isinstance ( rec , MutableMapping ) : if "class" in rec and rec . get ( "class" ) in cls : op ( rec ) for d in rec : visit_class ( rec [ d ] , cls , op ) if isinstance ( rec , MutableSequence ) : for d in rec : visit_class ( d , cls , op ) | Apply a function to with class in cls . |
8,239 | def visit_field ( rec , field , op ) : if isinstance ( rec , MutableMapping ) : if field in rec : rec [ field ] = op ( rec [ field ] ) for d in rec : visit_field ( rec [ d ] , field , op ) if isinstance ( rec , MutableSequence ) : for d in rec : visit_field ( d , field , op ) | Apply a function to mapping with field . |
8,240 | def print_num ( num ) : out ( 'hex: 0x{0:08x}' . format ( num ) ) out ( 'dec: {0:d}' . format ( num ) ) out ( 'oct: 0o{0:011o}' . format ( num ) ) out ( 'bin: 0b{0:032b}' . format ( num ) ) | Write a numeric result in various forms |
8,241 | def main ( argv = None ) : parser = get_parser ( ) global args args = parser . parse_args ( argv ) args . func ( ) | Runs the program and handles command line options |
8,242 | def __decode_ext_desc ( self , value_type , value ) : if value_type == 0 : return self . __decode_string ( value ) elif value_type == 1 : return value elif 1 < value_type < 6 : return _bytes_to_int_le ( value ) | decode ASF_EXTENDED_CONTENT_DESCRIPTION_OBJECT values |
8,243 | def fetch ( self , card_id , data = { } , ** kwargs ) : return super ( Card , self ) . fetch ( card_id , data , ** kwargs ) | Fetch Card for given Id |
8,244 | def all ( self , data = { } , ** kwargs ) : return super ( VirtualAccount , self ) . all ( data , ** kwargs ) | Fetch all Virtual Account entities |
8,245 | def fetch ( self , virtual_account_id , data = { } , ** kwargs ) : return super ( VirtualAccount , self ) . fetch ( virtual_account_id , data , ** kwargs ) | Fetch Virtual Account for given Id |
8,246 | def create ( self , data = { } , ** kwargs ) : url = self . base_url return self . post_url ( url , data , ** kwargs ) | Create Virtual Account from given dict |
8,247 | def close ( self , virtual_account_id , data = { } , ** kwargs ) : url = "{}/{}" . format ( self . base_url , virtual_account_id ) data [ 'status' ] = 'closed' return self . patch_url ( url , data , ** kwargs ) | Close Virtual Account from given Id |
8,248 | def payments ( self , virtual_account_id , data = { } , ** kwargs ) : url = "{}/{}/payments" . format ( self . base_url , virtual_account_id ) return self . get_url ( url , data , ** kwargs ) | Fetch Payment for Virtual Account Id |
8,249 | def all ( self , data = { } , ** kwargs ) : return super ( Subscription , self ) . all ( data , ** kwargs ) | Fetch all Subscription entities |
8,250 | def fetch ( self , subscription_id , data = { } , ** kwargs ) : return super ( Subscription , self ) . fetch ( subscription_id , data , ** kwargs ) | Fetch Subscription for given Id |
8,251 | def cancel ( self , subscription_id , data = { } , ** kwargs ) : url = "{}/{}/cancel" . format ( self . base_url , subscription_id ) return self . post_url ( url , data , ** kwargs ) | Cancel subscription given by subscription_id |
8,252 | def all ( self , data = { } , ** kwargs ) : return super ( Order , self ) . all ( data , ** kwargs ) | Fetch all Order entities |
8,253 | def fetch ( self , order_id , data = { } , ** kwargs ) : return super ( Order , self ) . fetch ( order_id , data , ** kwargs ) | Fetch Order for given Id |
8,254 | def fetch ( self , customer_id , data = { } , ** kwargs ) : return super ( Customer , self ) . fetch ( customer_id , data , ** kwargs ) | Fetch Customer for given Id |
8,255 | def edit ( self , customer_id , data = { } , ** kwargs ) : url = '{}/{}' . format ( self . base_url , customer_id ) return self . put_url ( url , data , ** kwargs ) | Edit Customer information from given dict |
8,256 | def fetch ( self , addon_id , data = { } , ** kwargs ) : return super ( Addon , self ) . fetch ( addon_id , data , ** kwargs ) | Fetch addon for given Id |
8,257 | def delete ( self , addon_id , data = { } , ** kwargs ) : return super ( Addon , self ) . delete ( addon_id , data , ** kwargs ) | Delete addon for given id |
8,258 | def all ( self , data = { } , ** kwargs ) : return super ( Refund , self ) . all ( data , ** kwargs ) | Fetch All Refund |
8,259 | def fetch ( self , refund_id , data = { } , ** kwargs ) : return super ( Refund , self ) . fetch ( refund_id , data , ** kwargs ) | Refund object for given paymnet Id |
8,260 | def all ( self , data = { } , ** kwargs ) : return super ( Payment , self ) . all ( data , ** kwargs ) | Fetch all Payment entities |
8,261 | def fetch ( self , payment_id , data = { } , ** kwargs ) : return super ( Payment , self ) . fetch ( payment_id , data , ** kwargs ) | Fetch Payment for given Id |
8,262 | def capture ( self , payment_id , amount , data = { } , ** kwargs ) : url = "{}/{}/capture" . format ( self . base_url , payment_id ) data [ 'amount' ] = amount return self . post_url ( url , data , ** kwargs ) | Capture Payment for given Id |
8,263 | def transfer ( self , payment_id , data = { } , ** kwargs ) : url = "{}/{}/transfers" . format ( self . base_url , payment_id ) return self . post_url ( url , data , ** kwargs ) | Create Transfer for given Payment Id |
8,264 | def transfers ( self , payment_id , data = { } , ** kwargs ) : url = "{}/{}/transfers" . format ( self . base_url , payment_id ) return self . get_url ( url , data , ** kwargs ) | Fetches all transfer for given Payment Id |
8,265 | def fetch ( self , plan_id , data = { } , ** kwargs ) : return super ( Plan , self ) . fetch ( plan_id , data , ** kwargs ) | Fetch Plan for given Id |
8,266 | def all ( self , data = { } , ** kwargs ) : return super ( Plan , self ) . all ( data , ** kwargs ) | Fetch all plan entities |
8,267 | def fetch ( self , customer_id , token_id , data = { } , ** kwargs ) : url = "{}/{}/tokens/{}" . format ( self . base_url , customer_id , token_id ) return self . get_url ( url , data , ** kwargs ) | Fetch Token for given Id and given customer Id |
8,268 | def all ( self , customer_id , data = { } , ** kwargs ) : url = "{}/{}/tokens" . format ( self . base_url , customer_id ) return self . get_url ( url , data , ** kwargs ) | Get all tokens for given customer Id |
8,269 | def delete ( self , customer_id , token_id , data = { } , ** kwargs ) : url = "{}/{}/tokens/{}" . format ( self . base_url , customer_id , token_id ) return self . delete_url ( url , data , ** kwargs ) | Delete Given Token For a Customer |
8,270 | def all ( self , data = { } , ** kwargs ) : return super ( Settlement , self ) . all ( data , ** kwargs ) | Fetch all Settlement entities |
8,271 | def fetch ( self , settlement_id , data = { } , ** kwargs ) : return super ( Settlement , self ) . fetch ( settlement_id , data , ** kwargs ) | Fetch Settlement data for given Id |
8,272 | def compare_string ( self , expected_str , actual_str ) : if len ( expected_str ) != len ( actual_str ) : return False result = 0 for x , y in zip ( expected_str , actual_str ) : result |= ord ( x ) ^ ord ( y ) return result == 0 | Returns True if the two strings are equal False otherwise The time taken is independent of the number of characters that match For the sake of simplicity this function executes in constant time only when the two strings have the same length . It short - circuits when they have different lengths |
8,273 | def all ( self , data = { } , ** kwargs ) : if 'payment_id' in data : url = "/payments/{}/transfers" . format ( data [ 'payment_id' ] ) del data [ 'payment_id' ] return self . get_url ( url , data , ** kwargs ) return super ( Transfer , self ) . all ( data , ** kwargs ) | Fetch all Transfer entities |
8,274 | def fetch ( self , transfer_id , data = { } , ** kwargs ) : return super ( Transfer , self ) . fetch ( transfer_id , data , ** kwargs ) | Fetch Transfer for given Id |
8,275 | def reverse ( self , transfer_id , data = { } , ** kwargs ) : url = "{}/{}/reversals" . format ( self . base_url , transfer_id ) return self . post_url ( url , data , ** kwargs ) | Reverse Transfer from given id |
8,276 | def reversals ( self , transfer_id , data = { } , ** kwargs ) : url = "{}/{}/reversals" . format ( self . base_url , transfer_id ) return self . get_url ( url , data , ** kwargs ) | Get all Reversal Transfer from given id |
8,277 | def request ( self , method , path , ** options ) : options = self . _update_user_agent_header ( options ) url = "{}{}" . format ( self . base_url , path ) response = getattr ( self . session , method ) ( url , auth = self . auth , verify = self . cert_path , ** options ) if ( ( response . status_code >= HTTP_STATUS_CO... | Dispatches a request to the Razorpay HTTP API |
8,278 | def get ( self , path , params , ** options ) : return self . request ( 'get' , path , params = params , ** options ) | Parses GET request options and dispatches a request |
8,279 | def post ( self , path , data , ** options ) : data , options = self . _update_request ( data , options ) return self . request ( 'post' , path , data = data , ** options ) | Parses POST request options and dispatches a request |
8,280 | def patch ( self , path , data , ** options ) : data , options = self . _update_request ( data , options ) return self . request ( 'patch' , path , data = data , ** options ) | Parses PATCH request options and dispatches a request |
8,281 | def delete ( self , path , data , ** options ) : data , options = self . _update_request ( data , options ) return self . request ( 'delete' , path , data = data , ** options ) | Parses DELETE request options and dispatches a request |
8,282 | def put ( self , path , data , ** options ) : data , options = self . _update_request ( data , options ) return self . request ( 'put' , path , data = data , ** options ) | Parses PUT request options and dispatches a request |
8,283 | def _update_request ( self , data , options ) : data = json . dumps ( data ) if 'headers' not in options : options [ 'headers' ] = { } options [ 'headers' ] . update ( { 'Content-type' : 'application/json' } ) return data , options | Updates The resource data and header options |
8,284 | def all ( self , data = { } , ** kwargs ) : return super ( Invoice , self ) . all ( data , ** kwargs ) | Fetch all Invoice entities |
8,285 | def fetch ( self , invoice_id , data = { } , ** kwargs ) : return super ( Invoice , self ) . fetch ( invoice_id , data , ** kwargs ) | Fetch Invoice for given Id |
8,286 | def cancel ( self , invoice_id , ** kwargs ) : url = "{}/{}/cancel" . format ( self . base_url , invoice_id ) return self . post_url ( url , { } , ** kwargs ) | Cancel an unpaid Invoice with given ID via API It can only be called on an invoice that is not in the paid state . |
8,287 | def delete ( self , invoice_id , ** kwargs ) : url = "{}/{}" . format ( self . base_url , invoice_id ) return self . delete_url ( url , { } , ** kwargs ) | Delete an invoice You can delete an invoice which is in the draft state . |
8,288 | def issue ( self , invoice_id , ** kwargs ) : url = "{}/{}/issue" . format ( self . base_url , invoice_id ) return self . post_url ( url , { } , ** kwargs ) | Issues an invoice in draft state |
8,289 | def edit ( self , invoice_id , data = { } , ** kwargs ) : url = "{}/{}" . format ( self . base_url , invoice_id ) return self . patch_url ( url , data , ** kwargs ) | Update an invoice In draft state all the attributes are allowed . |
8,290 | def _pad_added ( self , element , pad ) : name = pad . query_caps ( None ) . to_string ( ) if name . startswith ( 'audio/x-raw' ) : nextpad = self . conv . get_static_pad ( 'sink' ) if not nextpad . is_linked ( ) : self . _got_a_pad = True pad . link ( nextpad ) | The callback for GstElement s pad - added signal . |
8,291 | def _no_more_pads ( self , element ) : if not self . _got_a_pad : self . read_exc = NoStreamError ( ) self . ready_sem . release ( ) | The callback for GstElement s no - more - pads signal . |
8,292 | def _new_sample ( self , sink ) : if self . running : buf = sink . emit ( 'pull-sample' ) . get_buffer ( ) mem = buf . get_all_memory ( ) success , info = mem . map ( Gst . MapFlags . READ ) if success : data = info . data mem . unmap ( info ) self . queue . put ( data ) else : raise GStreamerError ( "Unable to map buf... | The callback for appsink s new - sample signal . |
8,293 | def _unkown_type ( self , uridecodebin , decodebin , caps ) : streaminfo = caps . to_string ( ) if not streaminfo . startswith ( 'audio/' ) : return self . read_exc = UnknownTypeError ( streaminfo ) self . ready_sem . release ( ) | The callback for decodebin s unknown - type signal . |
8,294 | def close ( self , force = False ) : if self . running or force : self . running = False self . finished = True self . pipeline . get_bus ( ) . remove_signal_watch ( ) self . dec . set_property ( "uri" , None ) self . sink . get_static_pad ( "sink" ) . disconnect ( self . caps_handler ) try : self . queue . get_nowait ... | Close the file and clean up associated resources . |
8,295 | def read_data ( self , block_samples = 1024 ) : old_width = self . _file . getsampwidth ( ) while True : data = self . _file . readframes ( block_samples ) if not data : break data = audioop . lin2lin ( data , old_width , TARGET_WIDTH ) if self . _needs_byteswap and self . _file . getcomptype ( ) != 'sowt' : data = byt... | Generates blocks of PCM data found in the file . |
8,296 | def _gst_available ( ) : try : import gi except ImportError : return False try : gi . require_version ( 'Gst' , '1.0' ) except ( ValueError , AttributeError ) : return False try : from gi . repository import Gst except ImportError : return False return True | Determine whether Gstreamer and the Python GObject bindings are installed . |
8,297 | def available_backends ( ) : from . import rawread result = [ rawread . RawAudioFile ] if _ca_available ( ) : from . import macca result . append ( macca . ExtAudioFile ) if _gst_available ( ) : from . import gstdec result . append ( gstdec . GstAudioFile ) if _mad_available ( ) : from . import maddec result . append (... | Returns a list of backends that are available on this system . |
8,298 | def audio_open ( path , backends = None ) : if backends is None : backends = available_backends ( ) for BackendClass in backends : try : return BackendClass ( path ) except DecodeError : pass raise NoBackendError ( ) | Open an audio file using a library that is available on this system . |
8,299 | def popen_multiple ( commands , command_args , * args , ** kwargs ) : for i , command in enumerate ( commands ) : cmd = [ command ] + command_args try : return subprocess . Popen ( cmd , * args , ** kwargs ) except OSError : if i == len ( commands ) - 1 : raise | Like subprocess . Popen but can try multiple commands in case some are not available . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.