query stringlengths 5 1.23k | positive stringlengths 53 15.2k | id_ int64 0 252k | task_name stringlengths 87 242 | negative listlengths 20 553 |
|---|---|---|---|---|
Write out all of the metrics in each of the databases returning a future that will indicate all metrics have been written when that future is done . | def _write_measurements ( ) : global _timeout , _writing future = concurrent . Future ( ) if _writing : LOGGER . warning ( 'Currently writing measurements, skipping write' ) future . set_result ( False ) elif not _pending_measurements ( ) : future . set_result ( True ) elif not _sample_batch ( ) : LOGGER . debug ( 'Skipping batch submission due to sampling' ) future . set_result ( True ) # Exit early if there's an error condition if future . done ( ) : return future if not _http_client or _dirty : _create_http_client ( ) # Keep track of the futures for each batch submission futures = [ ] # Submit a batch for each database for database in _measurements : url = '{}?db={}&precision=ms' . format ( _base_url , database ) # Get the measurements to submit measurements = _measurements [ database ] [ : _max_batch_size ] # Pop them off the stack of pending measurements _measurements [ database ] = _measurements [ database ] [ _max_batch_size : ] # Create the request future LOGGER . debug ( 'Submitting %r measurements to %r' , len ( measurements ) , url ) request = _http_client . fetch ( url , method = 'POST' , body = '\n' . join ( measurements ) . encode ( 'utf-8' ) ) # Keep track of each request in our future stack futures . append ( ( request , str ( uuid . uuid4 ( ) ) , database , measurements ) ) # Start the wait cycle for all the requests to complete _writing = True _futures_wait ( future , futures ) return future | 11,300 | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L670-L724 | [
"def",
"del_restriction",
"(",
"self",
",",
"command",
",",
"user",
",",
"event_types",
")",
":",
"if",
"user",
".",
"lower",
"(",
")",
"in",
"self",
".",
"commands_rights",
"[",
"command",
"]",
":",
"for",
"event_type",
"in",
"event_types",
":",
"try",
":",
"self",
".",
"commands_rights",
"[",
"command",
"]",
"[",
"user",
".",
"lower",
"(",
")",
"]",
".",
"remove",
"(",
"event_type",
")",
"except",
"ValueError",
":",
"pass",
"if",
"not",
"self",
".",
"commands_rights",
"[",
"command",
"]",
"[",
"user",
".",
"lower",
"(",
")",
"]",
":",
"self",
".",
"commands_rights",
"[",
"command",
"]",
".",
"pop",
"(",
"user",
".",
"lower",
"(",
")",
")"
] |
Record the time it takes to run an arbitrary code block . | def duration ( self , name ) : start = time . time ( ) try : yield finally : self . set_field ( name , max ( time . time ( ) , start ) - start ) | 11,301 | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L842-L856 | [
"def",
"delete_classifier",
"(",
"self",
",",
"classifier_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"classifier_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'classifier_id must be provided'",
")",
"headers",
"=",
"{",
"}",
"if",
"'headers'",
"in",
"kwargs",
":",
"headers",
".",
"update",
"(",
"kwargs",
".",
"get",
"(",
"'headers'",
")",
")",
"sdk_headers",
"=",
"get_sdk_headers",
"(",
"'watson_vision_combined'",
",",
"'V3'",
",",
"'delete_classifier'",
")",
"headers",
".",
"update",
"(",
"sdk_headers",
")",
"params",
"=",
"{",
"'version'",
":",
"self",
".",
"version",
"}",
"url",
"=",
"'/v3/classifiers/{0}'",
".",
"format",
"(",
"*",
"self",
".",
"_encode_path_vars",
"(",
"classifier_id",
")",
")",
"response",
"=",
"self",
".",
"request",
"(",
"method",
"=",
"'DELETE'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"headers",
",",
"params",
"=",
"params",
",",
"accept_json",
"=",
"True",
")",
"return",
"response"
] |
Return the measurement in the line protocol format . | def marshall ( self ) : return '{},{} {} {}' . format ( self . _escape ( self . name ) , ',' . join ( [ '{}={}' . format ( self . _escape ( k ) , self . _escape ( v ) ) for k , v in self . tags . items ( ) ] ) , self . _marshall_fields ( ) , int ( self . timestamp * 1000 ) ) | 11,302 | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L858-L869 | [
"def",
"_subst_libs",
"(",
"env",
",",
"libs",
")",
":",
"if",
"SCons",
".",
"Util",
".",
"is_String",
"(",
"libs",
")",
":",
"libs",
"=",
"env",
".",
"subst",
"(",
"libs",
")",
"if",
"SCons",
".",
"Util",
".",
"is_String",
"(",
"libs",
")",
":",
"libs",
"=",
"libs",
".",
"split",
"(",
")",
"elif",
"SCons",
".",
"Util",
".",
"is_Sequence",
"(",
"libs",
")",
":",
"_libs",
"=",
"[",
"]",
"for",
"l",
"in",
"libs",
":",
"_libs",
"+=",
"_subst_libs",
"(",
"env",
",",
"l",
")",
"libs",
"=",
"_libs",
"else",
":",
"# libs is an object (Node, for example)",
"libs",
"=",
"[",
"libs",
"]",
"return",
"libs"
] |
Set the value of a field in the measurement . | def set_field ( self , name , value ) : if not any ( [ isinstance ( value , t ) for t in { int , float , bool , str } ] ) : LOGGER . debug ( 'Invalid field value: %r' , value ) raise ValueError ( 'Value must be a str, bool, integer, or float' ) self . fields [ name ] = value | 11,303 | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L871-L882 | [
"def",
"reboot_node",
"(",
"node_id",
",",
"profile",
",",
"*",
"*",
"libcloud_kwargs",
")",
":",
"conn",
"=",
"_get_driver",
"(",
"profile",
"=",
"profile",
")",
"node",
"=",
"_get_by_id",
"(",
"conn",
".",
"list_nodes",
"(",
"*",
"*",
"libcloud_kwargs",
")",
",",
"node_id",
")",
"return",
"conn",
".",
"reboot_node",
"(",
"node",
",",
"*",
"*",
"libcloud_kwargs",
")"
] |
Set multiple tags for the measurement . | def set_tags ( self , tags ) : for key , value in tags . items ( ) : self . set_tag ( key , value ) | 11,304 | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L896-L906 | [
"def",
"_compress_json",
"(",
"self",
",",
"j",
")",
":",
"compressed_json",
"=",
"copy",
".",
"copy",
"(",
"j",
")",
"compressed_json",
".",
"pop",
"(",
"'users'",
",",
"None",
")",
"compressed_data",
"=",
"zlib",
".",
"compress",
"(",
"json",
".",
"dumps",
"(",
"j",
"[",
"'users'",
"]",
")",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"self",
".",
"zlib_compression_strength",
")",
"b64_data",
"=",
"base64",
".",
"b64encode",
"(",
"compressed_data",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"compressed_json",
"[",
"'blob'",
"]",
"=",
"b64_data",
"return",
"compressed_json"
] |
Replys a text message | def reply ( self , text ) : data = { 'text' : text , 'vchannel_id' : self [ 'vchannel_id' ] } if self . is_p2p ( ) : data [ 'type' ] = RTMMessageType . P2PMessage data [ 'to_uid' ] = self [ 'uid' ] else : data [ 'type' ] = RTMMessageType . ChannelMessage data [ 'channel_id' ] = self [ 'channel_id' ] return RTMMessage ( data ) | 11,305 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_message.py#L53-L69 | [
"def",
"assignment",
"(",
"self",
",",
"index",
")",
":",
"index",
"=",
"np",
".",
"array",
"(",
"index",
")",
"max_possible_index",
"=",
"np",
".",
"prod",
"(",
"self",
".",
"cardinality",
")",
"-",
"1",
"if",
"not",
"all",
"(",
"i",
"<=",
"max_possible_index",
"for",
"i",
"in",
"index",
")",
":",
"raise",
"IndexError",
"(",
"\"Index greater than max possible index\"",
")",
"assignments",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"index",
")",
",",
"len",
"(",
"self",
".",
"scope",
"(",
")",
")",
")",
",",
"dtype",
"=",
"np",
".",
"int",
")",
"rev_card",
"=",
"self",
".",
"cardinality",
"[",
":",
":",
"-",
"1",
"]",
"for",
"i",
",",
"card",
"in",
"enumerate",
"(",
"rev_card",
")",
":",
"assignments",
"[",
":",
",",
"i",
"]",
"=",
"index",
"%",
"card",
"index",
"=",
"index",
"//",
"card",
"assignments",
"=",
"assignments",
"[",
":",
",",
":",
":",
"-",
"1",
"]",
"return",
"[",
"[",
"(",
"key",
",",
"val",
")",
"for",
"key",
",",
"val",
"in",
"zip",
"(",
"self",
".",
"variables",
",",
"values",
")",
"]",
"for",
"values",
"in",
"assignments",
"]"
] |
Refers current message and replys a new message | def refer ( self , text ) : data = self . reply ( text ) data [ 'refer_key' ] = self [ 'key' ] return data | 11,306 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_message.py#L71-L82 | [
"def",
"_log10_Inorm_extern_atmx",
"(",
"self",
",",
"Teff",
",",
"logg",
",",
"abun",
")",
":",
"log10_Inorm",
"=",
"libphoebe",
".",
"wd_atmint",
"(",
"Teff",
",",
"logg",
",",
"abun",
",",
"self",
".",
"extern_wd_idx",
",",
"self",
".",
"wd_data",
"[",
"\"planck_table\"",
"]",
",",
"self",
".",
"wd_data",
"[",
"\"atm_table\"",
"]",
")",
"return",
"log10_Inorm"
] |
Increments the delta information and refreshes the interface . | def increment ( self ) : if self . _starttime is not None : self . _delta = datetime . datetime . now ( ) - self . _starttime else : self . _delta = datetime . timedelta ( ) self . refresh ( ) self . ticked . emit ( ) | 11,307 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtimerlabel.py#L87-L97 | [
"def",
"_parse_directory",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parser",
".",
"has_option",
"(",
"'storage'",
",",
"'directory'",
")",
":",
"directory",
"=",
"self",
".",
"_parser",
".",
"get",
"(",
"'storage'",
",",
"'directory'",
")",
"# Don't allow CUSTOM_APPS_DIR as a storage directory",
"if",
"directory",
"==",
"CUSTOM_APPS_DIR",
":",
"raise",
"ConfigError",
"(",
"\"{} cannot be used as a storage directory.\"",
".",
"format",
"(",
"CUSTOM_APPS_DIR",
")",
")",
"else",
":",
"directory",
"=",
"MACKUP_BACKUP_PATH",
"return",
"str",
"(",
"directory",
")"
] |
Updates the label display with the current timer information . | def refresh ( self ) : delta = self . elapsed ( ) seconds = delta . seconds limit = self . limit ( ) options = { } options [ 'hours' ] = self . hours ( ) options [ 'minutes' ] = self . minutes ( ) options [ 'seconds' ] = self . seconds ( ) try : text = self . format ( ) % options except ValueError : text = '#ERROR' self . setText ( text ) if limit and limit <= seconds : self . stop ( ) self . timeout . emit ( ) | 11,308 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtimerlabel.py#L132-L154 | [
"def",
"unsubscribe",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"self",
".",
"object",
".",
"subscribers",
".",
"remove",
"(",
"request",
".",
"user",
")",
"messages",
".",
"success",
"(",
"self",
".",
"request",
",",
"self",
".",
"success_message",
")",
"return",
"HttpResponseRedirect",
"(",
"self",
".",
"get_success_url",
"(",
")",
")"
] |
Stops the timer and resets its values to 0 . | def reset ( self ) : self . _elapsed = datetime . timedelta ( ) self . _delta = datetime . timedelta ( ) self . _starttime = datetime . datetime . now ( ) self . refresh ( ) | 11,309 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtimerlabel.py#L157-L165 | [
"def",
"find_structure",
"(",
"self",
",",
"filename_or_structure",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"filename_or_structure",
",",
"str",
")",
":",
"s",
"=",
"Structure",
".",
"from_file",
"(",
"filename_or_structure",
")",
"elif",
"isinstance",
"(",
"filename_or_structure",
",",
"Structure",
")",
":",
"s",
"=",
"filename_or_structure",
"else",
":",
"raise",
"MPRestError",
"(",
"\"Provide filename or Structure object.\"",
")",
"payload",
"=",
"{",
"'structure'",
":",
"json",
".",
"dumps",
"(",
"s",
".",
"as_dict",
"(",
")",
",",
"cls",
"=",
"MontyEncoder",
")",
"}",
"response",
"=",
"self",
".",
"session",
".",
"post",
"(",
"'{}/find_structure'",
".",
"format",
"(",
"self",
".",
"preamble",
")",
",",
"data",
"=",
"payload",
")",
"if",
"response",
".",
"status_code",
"in",
"[",
"200",
",",
"400",
"]",
":",
"resp",
"=",
"json",
".",
"loads",
"(",
"response",
".",
"text",
",",
"cls",
"=",
"MontyDecoder",
")",
"if",
"resp",
"[",
"'valid_response'",
"]",
":",
"return",
"resp",
"[",
"'response'",
"]",
"else",
":",
"raise",
"MPRestError",
"(",
"resp",
"[",
"\"error\"",
"]",
")",
"raise",
"MPRestError",
"(",
"\"REST error with status code {} and error {}\"",
".",
"format",
"(",
"response",
".",
"status_code",
",",
"response",
".",
"text",
")",
")",
"except",
"Exception",
"as",
"ex",
":",
"raise",
"MPRestError",
"(",
"str",
"(",
"ex",
")",
")"
] |
Stops the timer . If the timer is not currently running then this method will do nothing . | def stop ( self ) : if not self . _timer . isActive ( ) : return self . _elapsed += self . _delta self . _timer . stop ( ) | 11,310 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtimerlabel.py#L237-L246 | [
"def",
"set_key_value",
"(",
"self",
",",
"value",
",",
"store_type",
"=",
"PUBLIC_KEY_STORE_TYPE_BASE64",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"if",
"PUBLIC_KEY_STORE_TYPE_HEX",
"in",
"value",
":",
"self",
".",
"set_key_value",
"(",
"value",
"[",
"PUBLIC_KEY_STORE_TYPE_HEX",
"]",
",",
"PUBLIC_KEY_STORE_TYPE_HEX",
")",
"elif",
"PUBLIC_KEY_STORE_TYPE_BASE64",
"in",
"value",
":",
"self",
".",
"set_key_value",
"(",
"value",
"[",
"PUBLIC_KEY_STORE_TYPE_BASE64",
"]",
",",
"PUBLIC_KEY_STORE_TYPE_BASE64",
")",
"elif",
"PUBLIC_KEY_STORE_TYPE_BASE85",
"in",
"value",
":",
"self",
".",
"set_key_value",
"(",
"value",
"[",
"PUBLIC_KEY_STORE_TYPE_BASE85",
"]",
",",
"PUBLIC_KEY_STORE_TYPE_BASE85",
")",
"elif",
"PUBLIC_KEY_STORE_TYPE_JWK",
"in",
"value",
":",
"self",
".",
"set_key_value",
"(",
"value",
"[",
"PUBLIC_KEY_STORE_TYPE_JWK",
"]",
",",
"PUBLIC_KEY_STORE_TYPE_JWK",
")",
"elif",
"PUBLIC_KEY_STORE_TYPE_PEM",
"in",
"value",
":",
"self",
".",
"set_key_value",
"(",
"value",
"[",
"PUBLIC_KEY_STORE_TYPE_PEM",
"]",
",",
"PUBLIC_KEY_STORE_TYPE_PEM",
")",
"else",
":",
"self",
".",
"_value",
"=",
"value",
"self",
".",
"_store_type",
"=",
"store_type"
] |
Starts the thread in its own event loop if the local and global thread options are true otherwise runs the thread logic in the main event loop . | def start ( self ) : if ( self . localThreadingEnabled ( ) and self . globalThreadingEnabled ( ) ) : super ( XThread , self ) . start ( ) else : self . run ( ) self . finished . emit ( ) | 11,311 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xthread.py#L57-L67 | [
"def",
"get_components",
"(",
"self",
",",
"which",
")",
":",
"mappings",
"=",
"self",
".",
"representation_mappings",
".",
"get",
"(",
"getattr",
"(",
"self",
",",
"which",
")",
".",
"__class__",
",",
"[",
"]",
")",
"old_to_new",
"=",
"dict",
"(",
")",
"for",
"name",
"in",
"getattr",
"(",
"self",
",",
"which",
")",
".",
"components",
":",
"for",
"m",
"in",
"mappings",
":",
"if",
"isinstance",
"(",
"m",
",",
"RegexRepresentationMapping",
")",
":",
"pattr",
"=",
"re",
".",
"match",
"(",
"m",
".",
"repr_name",
",",
"name",
")",
"old_to_new",
"[",
"name",
"]",
"=",
"m",
".",
"new_name",
".",
"format",
"(",
"*",
"pattr",
".",
"groups",
"(",
")",
")",
"elif",
"m",
".",
"repr_name",
"==",
"name",
":",
"old_to_new",
"[",
"name",
"]",
"=",
"m",
".",
"new_name",
"mapping",
"=",
"OrderedDict",
"(",
")",
"for",
"name",
"in",
"getattr",
"(",
"self",
",",
"which",
")",
".",
"components",
":",
"mapping",
"[",
"old_to_new",
".",
"get",
"(",
"name",
",",
"name",
")",
"]",
"=",
"name",
"return",
"mapping"
] |
Starts loading this item for the batch . | def startLoading ( self ) : if super ( XBatchItem , self ) . startLoading ( ) : tree = self . treeWidget ( ) if not isinstance ( tree , XOrbTreeWidget ) : self . takeFromTree ( ) return next_batch = self . batch ( ) tree . _loadBatch ( self , next_batch ) | 11,312 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L307-L318 | [
"def",
"init",
"(",
"cls",
",",
"conn_string",
"=",
"None",
")",
":",
"if",
"conn_string",
":",
"_update_meta",
"(",
"conn_string",
")",
"# We initialize the engine within the models module because models'",
"# schema can depend on which data types are supported by the engine",
"Meta",
".",
"Session",
"=",
"new_sessionmaker",
"(",
")",
"Meta",
".",
"engine",
"=",
"Meta",
".",
"Session",
".",
"kw",
"[",
"\"bind\"",
"]",
"logger",
".",
"info",
"(",
"f\"Connecting user:{Meta.DBUSER} \"",
"f\"to {Meta.DBHOST}:{Meta.DBPORT}/{Meta.DBNAME}\"",
")",
"Meta",
".",
"_init_db",
"(",
")",
"if",
"not",
"Meta",
".",
"log_path",
":",
"init_logging",
"(",
")",
"return",
"cls"
] |
Assigns the order names for this tree based on the name of the columns . | def assignOrderNames ( self ) : try : schema = self . tableType ( ) . schema ( ) except AttributeError : return for colname in self . columns ( ) : column = schema . column ( colname ) if column : self . setColumnOrderName ( colname , column . name ( ) ) | 11,313 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L601-L614 | [
"def",
"clean_all",
"(",
"self",
",",
"config_file",
",",
"region",
"=",
"None",
",",
"profile_name",
"=",
"None",
")",
":",
"logging",
".",
"info",
"(",
"'[begin] Cleaning all provisioned artifacts'",
")",
"config",
"=",
"GroupConfigFile",
"(",
"config_file",
"=",
"config_file",
")",
"if",
"config",
".",
"is_fresh",
"(",
")",
"is",
"True",
":",
"raise",
"ValueError",
"(",
"\"Config is already clean.\"",
")",
"if",
"region",
"is",
"None",
":",
"region",
"=",
"self",
".",
"_region",
"self",
".",
"_delete_group",
"(",
"config_file",
",",
"region",
"=",
"region",
",",
"profile_name",
"=",
"profile_name",
")",
"self",
".",
"clean_core",
"(",
"config_file",
",",
"region",
"=",
"region",
")",
"self",
".",
"clean_devices",
"(",
"config_file",
",",
"region",
"=",
"region",
")",
"self",
".",
"clean_file",
"(",
"config_file",
")",
"logging",
".",
"info",
"(",
"'[end] Cleaned all provisioned artifacts'",
")"
] |
Clears the tree and record information . | def clearAll ( self ) : # clear the tree information
self . clear ( ) # clear table information
self . _tableTypeName = '' self . _tableType = None # clear the records information
self . _recordSet = None self . _currentRecordSet = None # clear lookup information
self . _query = None self . _order = None self . _groupBy = None # clear paging information
if not self . signalsBlocked ( ) : self . recordsChanged . emit ( ) | 11,314 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L634-L657 | [
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"self",
".",
"websock_url",
"=",
"self",
".",
"chrome",
".",
"start",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"websock",
"=",
"websocket",
".",
"WebSocketApp",
"(",
"self",
".",
"websock_url",
")",
"self",
".",
"websock_thread",
"=",
"WebsockReceiverThread",
"(",
"self",
".",
"websock",
",",
"name",
"=",
"'WebsockThread:%s'",
"%",
"self",
".",
"chrome",
".",
"port",
")",
"self",
".",
"websock_thread",
".",
"start",
"(",
")",
"self",
".",
"_wait_for",
"(",
"lambda",
":",
"self",
".",
"websock_thread",
".",
"is_open",
",",
"timeout",
"=",
"30",
")",
"# tell browser to send us messages we're interested in",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Page.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Console.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Runtime.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.setForceUpdateOnPageLoad'",
")",
"# disable google analytics",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.setBlockedURLs'",
",",
"params",
"=",
"{",
"'urls'",
":",
"[",
"'*google-analytics.com/analytics.js'",
",",
"'*google-analytics.com/ga.js'",
"]",
"}",
")"
] |
Assigns the grouping to the current header index . | def groupByHeaderIndex ( self ) : index = self . headerMenuColumn ( ) columnTitle = self . columnOf ( index ) tableType = self . tableType ( ) if not tableType : return column = tableType . schema ( ) . column ( columnTitle ) if not column : return self . setGroupBy ( column . name ( ) ) self . setGroupingActive ( True ) | 11,315 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1012-L1028 | [
"def",
"ValidateEndConfig",
"(",
"self",
",",
"config_obj",
",",
"errors_fatal",
"=",
"True",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"not",
"config",
".",
"CONFIG",
"[",
"\"Client.fleetspeak_enabled\"",
"]",
":",
"location",
"=",
"config_obj",
".",
"Get",
"(",
"\"Client.server_urls\"",
",",
"context",
"=",
"self",
".",
"context",
")",
"if",
"not",
"location",
":",
"errors",
".",
"append",
"(",
"\"Empty Client.server_urls\"",
")",
"for",
"url",
"in",
"location",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Bad Client.server_urls specified %s\"",
"%",
"url",
")",
"key_data",
"=",
"config_obj",
".",
"GetRaw",
"(",
"\"Client.executable_signing_public_key\"",
",",
"default",
"=",
"None",
",",
"context",
"=",
"self",
".",
"context",
")",
"if",
"key_data",
"is",
"None",
":",
"errors",
".",
"append",
"(",
"\"Missing Client.executable_signing_public_key.\"",
")",
"elif",
"not",
"key_data",
".",
"startswith",
"(",
"\"-----BEGIN PUBLIC\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Invalid Client.executable_signing_public_key: %s\"",
"%",
"key_data",
")",
"else",
":",
"rsa_key",
"=",
"rdf_crypto",
".",
"RSAPublicKey",
"(",
")",
"rsa_key",
".",
"ParseFromHumanReadable",
"(",
"key_data",
")",
"if",
"not",
"config",
".",
"CONFIG",
"[",
"\"Client.fleetspeak_enabled\"",
"]",
":",
"certificate",
"=",
"config_obj",
".",
"GetRaw",
"(",
"\"CA.certificate\"",
",",
"default",
"=",
"None",
",",
"context",
"=",
"self",
".",
"context",
")",
"if",
"certificate",
"is",
"None",
"or",
"not",
"certificate",
".",
"startswith",
"(",
"\"-----BEGIN CERTIF\"",
")",
":",
"errors",
".",
"append",
"(",
"\"CA certificate missing from config.\"",
")",
"for",
"bad_opt",
"in",
"[",
"\"Client.private_key\"",
"]",
":",
"if",
"config_obj",
".",
"Get",
"(",
"bad_opt",
",",
"context",
"=",
"self",
".",
"context",
",",
"default",
"=",
"\"\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Client cert in conf, this should be empty at deployment\"",
"\" %s\"",
"%",
"bad_opt",
")",
"if",
"errors_fatal",
"and",
"errors",
":",
"for",
"error",
"in",
"errors",
":",
"logging",
".",
"error",
"(",
"\"Build Config Error: %s\"",
",",
"error",
")",
"raise",
"RuntimeError",
"(",
"\"Bad configuration generated. Terminating.\"",
")",
"else",
":",
"return",
"errors"
] |
Initializes the columns that will be used for this tree widget based \ on the table type linked to it . | def initializeColumns ( self ) : tableType = self . tableType ( ) if not tableType : return elif self . _columnsInitialized or self . columnOf ( 0 ) != '1' : self . assignOrderNames ( ) return # set the table header information
tschema = tableType . schema ( ) columns = tschema . columns ( ) names = [ col . displayName ( ) for col in columns if not col . isPrivate ( ) ] self . setColumns ( sorted ( names ) ) self . assignOrderNames ( ) self . resizeToContents ( ) | 11,316 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1213-L1232 | [
"def",
"get_enroll",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"DeviceRegistration",
".",
"wrap",
"(",
"device",
")",
"for",
"device",
"in",
"self",
".",
"__get_u2f_devices",
"(",
")",
"]",
"enroll",
"=",
"start_register",
"(",
"self",
".",
"__appid",
",",
"devices",
")",
"enroll",
"[",
"'status'",
"]",
"=",
"'ok'",
"session",
"[",
"'_u2f_enroll_'",
"]",
"=",
"enroll",
".",
"json",
"return",
"enroll"
] |
Refreshes the record list for the tree . | def refresh ( self , reloadData = False , force = False ) : if not ( self . isVisible ( ) or force ) : self . _refreshTimer . start ( ) return if self . isLoading ( ) : return if reloadData : self . refreshQueryRecords ( ) # cancel current work
self . _refreshTimer . stop ( ) self . worker ( ) . cancel ( ) if self . _popup : self . _popup . close ( ) # grab the record set
currset = self . currentRecordSet ( ) self . worker ( ) . setBatched ( self . isPaged ( ) ) self . worker ( ) . setBatchSize ( self . pageSize ( ) ) # group the information
if self . _searchTerms : currset . setGroupBy ( None ) pageSize = 0 # work with groups
elif self . groupBy ( ) and self . isGroupingActive ( ) : currset . setGroupBy ( self . groupBy ( ) ) # work with batching
else : currset . setGroupBy ( None ) # order the information
if self . order ( ) : currset . setOrdered ( True ) currset . setOrder ( self . order ( ) ) # for larger queries, run it through the thread
if self . useLoader ( ) : loader = XLoaderWidget . start ( self ) # specify the columns to load
if self . specifiedColumnsOnly ( ) : currset . setColumns ( map ( lambda x : x . name ( ) , self . specifiedColumns ( ) ) ) self . _loadedColumns = set ( self . visibleColumns ( ) ) if self . isThreadEnabled ( ) and currset . isThreadEnabled ( ) : self . worker ( ) . setPreloadColumns ( self . _preloadColumns ) self . loadRequested . emit ( currset ) else : QApplication . setOverrideCursor ( Qt . WaitCursor ) self . worker ( ) . loadRecords ( currset ) QApplication . restoreOverrideCursor ( ) | 11,317 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1577-L1639 | [
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"self",
".",
"websock_url",
"=",
"self",
".",
"chrome",
".",
"start",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"websock",
"=",
"websocket",
".",
"WebSocketApp",
"(",
"self",
".",
"websock_url",
")",
"self",
".",
"websock_thread",
"=",
"WebsockReceiverThread",
"(",
"self",
".",
"websock",
",",
"name",
"=",
"'WebsockThread:%s'",
"%",
"self",
".",
"chrome",
".",
"port",
")",
"self",
".",
"websock_thread",
".",
"start",
"(",
")",
"self",
".",
"_wait_for",
"(",
"lambda",
":",
"self",
".",
"websock_thread",
".",
"is_open",
",",
"timeout",
"=",
"30",
")",
"# tell browser to send us messages we're interested in",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Page.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Console.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Runtime.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.setForceUpdateOnPageLoad'",
")",
"# disable google analytics",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.setBlockedURLs'",
",",
"params",
"=",
"{",
"'urls'",
":",
"[",
"'*google-analytics.com/analytics.js'",
",",
"'*google-analytics.com/ga.js'",
"]",
"}",
")"
] |
Refreshes the query results based on the tree s query . | def refreshQueryRecords ( self ) : if self . _recordSet is not None : records = RecordSet ( self . _recordSet ) elif self . tableType ( ) : records = self . tableType ( ) . select ( ) else : return records . setDatabase ( self . database ( ) ) # replace the base query with this widget
if self . queryAction ( ) == XOrbTreeWidget . QueryAction . Replace : if self . query ( ) : records . setQuery ( self . query ( ) ) else : records . setQuery ( None ) # join together the query for this widget
elif self . queryAction ( ) == XOrbTreeWidget . QueryAction . Join : if records . query ( ) : records . setQuery ( self . query ( ) & self . query ( ) ) elif self . query ( ) : records . setQuery ( self . query ( ) ) else : records . setQuery ( None ) self . _recordSet = records if not self . signalsBlocked ( ) : self . queryChanged . emit ( ) self . recordsChanged . emit ( ) | 11,318 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1641-L1674 | [
"def",
"_is_user_directory",
"(",
"self",
",",
"pathname",
")",
":",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"userdata_location",
"(",
")",
",",
"pathname",
")",
"# SteamOS puts a directory named 'anonymous' in the userdata directory",
"# by default. Since we assume that pathname is a userID, ignore any name",
"# that can't be converted to a number",
"return",
"os",
".",
"path",
".",
"isdir",
"(",
"fullpath",
")",
"and",
"pathname",
".",
"isdigit",
"(",
")"
] |
Updates the icon for this lock button based on its check state . | def updateState ( self ) : if self . isChecked ( ) : self . setIcon ( self . lockIcon ( ) ) self . setToolTip ( 'Click to unlock' ) else : self . setIcon ( self . unlockIcon ( ) ) self . setToolTip ( 'Click to lock' ) | 11,319 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlockbutton.py#L78-L87 | [
"def",
"read_legacy",
"(",
"filename",
")",
":",
"reader",
"=",
"vtk",
".",
"vtkDataSetReader",
"(",
")",
"reader",
".",
"SetFileName",
"(",
"filename",
")",
"# Ensure all data is fetched with poorly formated legacy files",
"reader",
".",
"ReadAllScalarsOn",
"(",
")",
"reader",
".",
"ReadAllColorScalarsOn",
"(",
")",
"reader",
".",
"ReadAllNormalsOn",
"(",
")",
"reader",
".",
"ReadAllTCoordsOn",
"(",
")",
"reader",
".",
"ReadAllVectorsOn",
"(",
")",
"# Perform the read",
"reader",
".",
"Update",
"(",
")",
"output",
"=",
"reader",
".",
"GetOutputDataObject",
"(",
"0",
")",
"if",
"output",
"is",
"None",
":",
"raise",
"AssertionError",
"(",
"'No output when using VTKs legacy reader'",
")",
"return",
"vtki",
".",
"wrap",
"(",
"output",
")"
] |
Wrapper for ModelAdmin . render_change_form . Replaces standard static AdminForm with an EAV - friendly one . The point is that our form generates fields dynamically and fieldsets must be inferred from a prepared and validated form instance not just the form class . Django does not seem to provide hooks for this purpose so we simply wrap the view and substitute some data . | def render_change_form ( self , request , context , * * kwargs ) : form = context [ 'adminform' ] . form # infer correct data from the form fieldsets = [ ( None , { 'fields' : form . fields . keys ( ) } ) ] adminform = helpers . AdminForm ( form , fieldsets , self . prepopulated_fields ) media = mark_safe ( self . media + adminform . media ) context . update ( adminform = adminform , media = media ) super_meth = super ( BaseEntityAdmin , self ) . render_change_form return super_meth ( request , context , * * kwargs ) | 11,320 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/admin.py#L35-L55 | [
"def",
"max_pv_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_max_pv",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] |
Run your app in gevent . wsgi . WSGIServer | def gevent_run ( app , port = 5000 , log = None , error_log = None , address = '' , monkey_patch = True , start = True , * * kwargs ) : # pragma: no cover if log is None : log = app . logger if error_log is None : error_log = app . logger if monkey_patch : from gevent import monkey monkey . patch_all ( ) from gevent . wsgi import WSGIServer http_server = WSGIServer ( ( address , port ) , app , log = log , error_log = error_log , * * kwargs ) if start : http_server . serve_forever ( ) return http_server | 11,321 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/http/runners.py#L12-L40 | [
"def",
"normalize_volume",
"(",
"volume",
")",
":",
"res",
"=",
"dict",
"(",
")",
"res",
"[",
"'type'",
"]",
"=",
"'volume'",
"res",
"[",
"'id'",
"]",
"=",
"volume",
"[",
"'_id'",
"]",
"if",
"'_score'",
"in",
"volume",
":",
"res",
"[",
"'score'",
"]",
"=",
"volume",
"[",
"'_score'",
"]",
"source",
"=",
"volume",
"[",
"'_source'",
"]",
"attachments",
"=",
"source",
"[",
"'_attachments'",
"]",
"del",
"(",
"source",
"[",
"'_attachments'",
"]",
")",
"del",
"(",
"source",
"[",
"'_text_'",
"+",
"source",
"[",
"'_language'",
"]",
"]",
")",
"res",
"[",
"'metadata'",
"]",
"=",
"source",
"atts",
"=",
"list",
"(",
")",
"for",
"attachment",
"in",
"attachments",
":",
"atts",
".",
"append",
"(",
"Archivant",
".",
"normalize_attachment",
"(",
"attachment",
")",
")",
"res",
"[",
"'attachments'",
"]",
"=",
"atts",
"return",
"res"
] |
Run your app in one tornado event loop process | def tornado_run ( app , port = 5000 , address = "" , use_gevent = False , start = True , monkey_patch = None , Container = None , Server = None , threadpool = None ) : # pragma: no cover if Container is None : from tornado . wsgi import WSGIContainer Container = WSGIContainer if Server is None : from tornado . httpserver import HTTPServer Server = HTTPServer if monkey_patch is None : monkey_patch = use_gevent CustomWSGIContainer = Container if use_gevent : if monkey_patch : from gevent import monkey monkey . patch_all ( ) import gevent class GeventWSGIContainer ( Container ) : def __call__ ( self , * args , * * kwargs ) : def async_task ( ) : super ( GeventWSGIContainer , self ) . __call__ ( * args , * * kwargs ) gevent . spawn ( async_task ) CustomWSGIContainer = GeventWSGIContainer if threadpool is not None : from multiprocessing . pool import ThreadPool if not isinstance ( threadpool , ThreadPool ) : threadpool = ThreadPool ( threadpool ) class ThreadPoolWSGIContainer ( Container ) : def __call__ ( self , * args , * * kwargs ) : def async_task ( ) : super ( ThreadPoolWSGIContainer , self ) . __call__ ( * args , * * kwargs ) threadpool . apply_async ( async_task ) CustomWSGIContainer = ThreadPoolWSGIContainer http_server = Server ( CustomWSGIContainer ( app ) ) http_server . listen ( port , address ) if start : tornado_start ( ) return http_server | 11,322 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/http/runners.py#L58-L121 | [
"def",
"validate_instance_dbname",
"(",
"self",
",",
"dbname",
")",
":",
"# 1-64 alphanumeric characters, cannot be a reserved MySQL word",
"if",
"re",
".",
"match",
"(",
"'[\\w-]+$'",
",",
"dbname",
")",
"is",
"not",
"None",
":",
"if",
"len",
"(",
"dbname",
")",
"<=",
"41",
"and",
"len",
"(",
"dbname",
")",
">=",
"1",
":",
"if",
"dbname",
".",
"lower",
"(",
")",
"not",
"in",
"MYSQL_RESERVED_WORDS",
":",
"return",
"True",
"return",
"'*** Error: Database names must be 1-64 alphanumeric characters,\\\n cannot be a reserved MySQL word.'"
] |
Combine servers in one tornado event loop process | def tornado_combiner ( configs , use_gevent = False , start = True , monkey_patch = None , Container = None , Server = None , threadpool = None ) : # pragma: no cover servers = [ ] if monkey_patch is None : monkey_patch = use_gevent if use_gevent : if monkey_patch : from gevent import monkey monkey . patch_all ( ) if threadpool is not None : from multiprocessing . pool import ThreadPool if not isinstance ( threadpool , ThreadPool ) : threadpool = ThreadPool ( threadpool ) for config in configs : app = config [ 'app' ] port = config . get ( 'port' , 5000 ) address = config . get ( 'address' , '' ) server = tornado_run ( app , use_gevent = use_gevent , port = port , monkey_patch = False , address = address , start = False , Container = Container , Server = Server , threadpool = threadpool ) servers . append ( server ) if start : tornado_start ( ) return servers | 11,323 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/http/runners.py#L124-L169 | [
"def",
"validate_instance_dbname",
"(",
"self",
",",
"dbname",
")",
":",
"# 1-64 alphanumeric characters, cannot be a reserved MySQL word",
"if",
"re",
".",
"match",
"(",
"'[\\w-]+$'",
",",
"dbname",
")",
"is",
"not",
"None",
":",
"if",
"len",
"(",
"dbname",
")",
"<=",
"41",
"and",
"len",
"(",
"dbname",
")",
">=",
"1",
":",
"if",
"dbname",
".",
"lower",
"(",
")",
"not",
"in",
"MYSQL_RESERVED_WORDS",
":",
"return",
"True",
"return",
"'*** Error: Database names must be 1-64 alphanumeric characters,\\\n cannot be a reserved MySQL word.'"
] |
Parse a dictionary file . Reads a RADIUS dictionary file and merges its contents into the class instance . | def ReadDictionary ( self , file ) : fil = dictfile . DictFile ( file ) state = { } state [ 'vendor' ] = '' self . defer_parse = [ ] for line in fil : state [ 'file' ] = fil . File ( ) state [ 'line' ] = fil . Line ( ) line = line . split ( '#' , 1 ) [ 0 ] . strip ( ) tokens = line . split ( ) if not tokens : continue key = tokens [ 0 ] . upper ( ) if key == 'ATTRIBUTE' : self . __ParseAttribute ( state , tokens ) elif key == 'VALUE' : self . __ParseValue ( state , tokens , True ) elif key == 'VENDOR' : self . __ParseVendor ( state , tokens ) elif key == 'BEGIN-VENDOR' : self . __ParseBeginVendor ( state , tokens ) elif key == 'END-VENDOR' : self . __ParseEndVendor ( state , tokens ) for state , tokens in self . defer_parse : key = tokens [ 0 ] . upper ( ) if key == 'VALUE' : self . __ParseValue ( state , tokens , False ) self . defer_parse = [ ] | 11,324 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/radius/dictionary.py#L303-L343 | [
"def",
"deletecols",
"(",
"X",
",",
"cols",
")",
":",
"if",
"isinstance",
"(",
"cols",
",",
"str",
")",
":",
"cols",
"=",
"cols",
".",
"split",
"(",
"','",
")",
"retain",
"=",
"[",
"n",
"for",
"n",
"in",
"X",
".",
"dtype",
".",
"names",
"if",
"n",
"not",
"in",
"cols",
"]",
"if",
"len",
"(",
"retain",
")",
">",
"0",
":",
"return",
"X",
"[",
"retain",
"]",
"else",
":",
"return",
"None"
] |
Draws the axis for this system . | def drawAxis ( self , painter ) : # draw the axis lines
pen = QPen ( self . axisColor ( ) ) pen . setWidth ( 4 ) painter . setPen ( pen ) painter . drawLines ( self . _buildData [ 'axis_lines' ] ) # draw the notches
for rect , text in self . _buildData [ 'grid_h_notches' ] : painter . drawText ( rect , Qt . AlignTop | Qt . AlignRight , text ) for rect , text in self . _buildData [ 'grid_v_notches' ] : painter . drawText ( rect , Qt . AlignCenter , text ) | 11,325 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartscene.py#L223-L238 | [
"def",
"cudnnSetPooling2dDescriptor",
"(",
"poolingDesc",
",",
"mode",
",",
"windowHeight",
",",
"windowWidth",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalStride",
",",
"horizontalStride",
")",
":",
"status",
"=",
"_libcudnn",
".",
"cudnnSetPooling2dDescriptor",
"(",
"poolingDesc",
",",
"mode",
",",
"windowHeight",
",",
"windowWidth",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalStride",
",",
"horizontalStride",
")",
"cudnnCheckStatus",
"(",
"status",
")"
] |
Rebuilds the data for this scene to draw with . | def rebuild ( self ) : global XChartWidgetItem if ( XChartWidgetItem is None ) : from projexui . widgets . xchartwidget . xchartwidgetitem import XChartWidgetItem self . _buildData = { } # build the grid location
x = 8 y = 8 w = self . sceneRect ( ) . width ( ) h = self . sceneRect ( ) . height ( ) hpad = self . horizontalPadding ( ) vpad = self . verticalPadding ( ) hmax = self . horizontalRuler ( ) . maxNotchSize ( Qt . Horizontal ) left_offset = hpad + self . verticalRuler ( ) . maxNotchSize ( Qt . Vertical ) right_offset = left_offset + hpad top_offset = vpad bottom_offset = top_offset + vpad + hmax left = x + left_offset right = w - right_offset top = y + top_offset bottom = h - bottom_offset rect = QRectF ( ) rect . setLeft ( left ) rect . setRight ( right ) rect . setBottom ( bottom ) rect . setTop ( top ) self . _buildData [ 'grid_rect' ] = rect # rebuild the ruler data
self . rebuildGrid ( ) self . _dirty = False # rebuild all the items
padding = self . horizontalPadding ( ) + self . verticalPadding ( ) grid = self . sceneRect ( ) filt = lambda x : isinstance ( x , XChartWidgetItem ) items = filter ( filt , self . items ( ) ) height = float ( grid . height ( ) ) if height == 0 : ratio = 1 else : ratio = grid . width ( ) / height count = len ( items ) if ( not count ) : return if ( ratio >= 1 ) : radius = ( grid . height ( ) - padding * 2 ) / 2.0 x = rect . center ( ) . x ( ) y = rect . center ( ) . y ( ) dx = radius * 2.5 dy = 0 else : radius = ( grid . width ( ) - padding * 2 ) / 2.0 x = rect . center ( ) . x ( ) y = rect . center ( ) . y ( ) dx = 0 dy = radius * 2.5 for item in items : item . setPieCenter ( QPointF ( x , y ) ) item . setRadius ( radius ) item . rebuild ( ) x += dx y += dy if ( self . _trackerItem and self . _trackerItem ( ) ) : self . _trackerItem ( ) . rebuild ( self . _buildData [ 'grid_rect' ] ) | 11,326 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartscene.py#L407-L486 | [
"def",
"filterNonJournals",
"(",
"citesLst",
",",
"invert",
"=",
"False",
")",
":",
"retCites",
"=",
"[",
"]",
"for",
"c",
"in",
"citesLst",
":",
"if",
"c",
".",
"isJournal",
"(",
")",
":",
"if",
"not",
"invert",
":",
"retCites",
".",
"append",
"(",
"c",
")",
"elif",
"invert",
":",
"retCites",
".",
"append",
"(",
"c",
")",
"return",
"retCites"
] |
Overloads the set scene rect to handle rebuild information . | def setSceneRect ( self , * args ) : super ( XChartScene , self ) . setSceneRect ( * args ) self . _dirty = True | 11,327 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartscene.py#L676-L681 | [
"def",
"is_citeable",
"(",
"publication_info",
")",
":",
"def",
"_item_has_pub_info",
"(",
"item",
")",
":",
"return",
"all",
"(",
"key",
"in",
"item",
"for",
"key",
"in",
"(",
"'journal_title'",
",",
"'journal_volume'",
")",
")",
"def",
"_item_has_page_or_artid",
"(",
"item",
")",
":",
"return",
"any",
"(",
"key",
"in",
"item",
"for",
"key",
"in",
"(",
"'page_start'",
",",
"'artid'",
")",
")",
"has_pub_info",
"=",
"any",
"(",
"_item_has_pub_info",
"(",
"item",
")",
"for",
"item",
"in",
"publication_info",
")",
"has_page_or_artid",
"=",
"any",
"(",
"_item_has_page_or_artid",
"(",
"item",
")",
"for",
"item",
"in",
"publication_info",
")",
"return",
"has_pub_info",
"and",
"has_page_or_artid"
] |
Updates the tracker item information . | def updateTrackerItem ( self , point = None ) : item = self . trackerItem ( ) if not item : return gridRect = self . _buildData . get ( 'grid_rect' ) if ( not ( gridRect and gridRect . isValid ( ) ) ) : item . setVisible ( False ) return if ( point is not None ) : item . setPos ( point . x ( ) , gridRect . top ( ) ) if ( not gridRect . contains ( item . pos ( ) ) ) : item . setVisible ( False ) return if ( self . chartType ( ) != self . Type . Line ) : item . setVisible ( False ) return if ( not self . isTrackingEnabled ( ) ) : item . setVisible ( False ) return item . rebuild ( gridRect ) | 11,328 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartscene.py#L774-L803 | [
"def",
"union",
"(",
"self",
",",
"*",
"dstreams",
")",
":",
"if",
"not",
"dstreams",
":",
"raise",
"ValueError",
"(",
"\"should have at least one DStream to union\"",
")",
"if",
"len",
"(",
"dstreams",
")",
"==",
"1",
":",
"return",
"dstreams",
"[",
"0",
"]",
"if",
"len",
"(",
"set",
"(",
"s",
".",
"_jrdd_deserializer",
"for",
"s",
"in",
"dstreams",
")",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"All DStreams should have same serializer\"",
")",
"if",
"len",
"(",
"set",
"(",
"s",
".",
"_slideDuration",
"for",
"s",
"in",
"dstreams",
")",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"All DStreams should have same slide duration\"",
")",
"cls",
"=",
"SparkContext",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"streaming",
".",
"api",
".",
"java",
".",
"JavaDStream",
"jdstreams",
"=",
"SparkContext",
".",
"_gateway",
".",
"new_array",
"(",
"cls",
",",
"len",
"(",
"dstreams",
")",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"dstreams",
")",
")",
":",
"jdstreams",
"[",
"i",
"]",
"=",
"dstreams",
"[",
"i",
"]",
".",
"_jdstream",
"return",
"DStream",
"(",
"self",
".",
"_jssc",
".",
"union",
"(",
"jdstreams",
")",
",",
"self",
",",
"dstreams",
"[",
"0",
"]",
".",
"_jrdd_deserializer",
")"
] |
Accepts the current text and rebuilds the parts widget . | def acceptEdit ( self ) : if ( self . _partsWidget . isVisible ( ) ) : return False use_completion = self . completer ( ) . popup ( ) . isVisible ( ) completion = self . completer ( ) . currentCompletion ( ) self . _completerTree . hide ( ) self . completer ( ) . popup ( ) . hide ( ) if ( use_completion ) : self . setText ( completion ) else : self . rebuild ( ) return True | 11,329 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnavigationedit.py#L298-L317 | [
"def",
"multivariate_neg_logposterior",
"(",
"self",
",",
"beta",
")",
":",
"post",
"=",
"self",
".",
"neg_loglik",
"(",
"beta",
")",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"self",
".",
"z_no",
")",
":",
"if",
"self",
".",
"latent_variables",
".",
"z_list",
"[",
"k",
"]",
".",
"prior",
".",
"covariance_prior",
"is",
"True",
":",
"post",
"+=",
"-",
"self",
".",
"latent_variables",
".",
"z_list",
"[",
"k",
"]",
".",
"prior",
".",
"logpdf",
"(",
"self",
".",
"custom_covariance",
"(",
"beta",
")",
")",
"break",
"else",
":",
"post",
"+=",
"-",
"self",
".",
"latent_variables",
".",
"z_list",
"[",
"k",
"]",
".",
"prior",
".",
"logpdf",
"(",
"beta",
"[",
"k",
"]",
")",
"return",
"post"
] |
Rejects the current edit and shows the parts widget . | def cancelEdit ( self ) : if ( self . _partsWidget . isVisible ( ) ) : return False self . _completerTree . hide ( ) self . completer ( ) . popup ( ) . hide ( ) self . setText ( self . _originalText ) return True | 11,330 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnavigationedit.py#L319-L331 | [
"def",
"get_rmsd",
"(",
"self",
",",
"mol1",
",",
"mol2",
")",
":",
"label1",
",",
"label2",
"=",
"self",
".",
"_mapper",
".",
"uniform_labels",
"(",
"mol1",
",",
"mol2",
")",
"if",
"label1",
"is",
"None",
"or",
"label2",
"is",
"None",
":",
"return",
"float",
"(",
"\"Inf\"",
")",
"return",
"self",
".",
"_calc_rms",
"(",
"mol1",
",",
"mol2",
",",
"label1",
",",
"label2",
")"
] |
Rebuilds the pathing based on the parts . | def startEdit ( self ) : self . _originalText = self . text ( ) self . scrollWidget ( ) . hide ( ) self . setFocus ( ) self . selectAll ( ) | 11,331 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnavigationedit.py#L515-L522 | [
"def",
"make_random_models_table",
"(",
"n_sources",
",",
"param_ranges",
",",
"random_state",
"=",
"None",
")",
":",
"prng",
"=",
"check_random_state",
"(",
"random_state",
")",
"sources",
"=",
"Table",
"(",
")",
"for",
"param_name",
",",
"(",
"lower",
",",
"upper",
")",
"in",
"param_ranges",
".",
"items",
"(",
")",
":",
"# Generate a column for every item in param_ranges, even if it",
"# is not in the model (e.g. flux). However, such columns will",
"# be ignored when rendering the image.",
"sources",
"[",
"param_name",
"]",
"=",
"prng",
".",
"uniform",
"(",
"lower",
",",
"upper",
",",
"n_sources",
")",
"return",
"sources"
] |
Rebuilds the parts widget with the latest text . | def rebuild ( self ) : navitem = self . currentItem ( ) if ( navitem ) : navitem . initialize ( ) self . setUpdatesEnabled ( False ) self . scrollWidget ( ) . show ( ) self . _originalText = '' partsw = self . partsWidget ( ) for button in self . _buttonGroup . buttons ( ) : self . _buttonGroup . removeButton ( button ) button . close ( ) button . setParent ( None ) button . deleteLater ( ) # create the root button layout = partsw . layout ( ) parts = self . parts ( ) button = QToolButton ( partsw ) button . setAutoRaise ( True ) button . setMaximumWidth ( 12 ) button . setArrowType ( Qt . RightArrow ) button . setProperty ( 'path' , wrapVariant ( '' ) ) button . setProperty ( 'is_completer' , wrapVariant ( True ) ) last_button = button self . _buttonGroup . addButton ( button ) layout . insertWidget ( 0 , button ) # check to see if we have a navigation model setup if ( self . _navigationModel ) : last_item = self . _navigationModel . itemByPath ( self . text ( ) ) show_last = last_item and last_item . rowCount ( ) > 0 else : show_last = False # load the navigation system count = len ( parts ) for i , part in enumerate ( parts ) : path = self . separator ( ) . join ( parts [ : i + 1 ] ) button = QToolButton ( partsw ) button . setAutoRaise ( True ) button . setText ( part ) if ( self . _navigationModel ) : item = self . _navigationModel . itemByPath ( path ) if ( item ) : button . setIcon ( item . icon ( ) ) button . setToolButtonStyle ( Qt . ToolButtonTextBesideIcon ) button . setProperty ( 'path' , wrapVariant ( path ) ) button . setProperty ( 'is_completer' , wrapVariant ( False ) ) self . _buttonGroup . addButton ( button ) layout . insertWidget ( ( i * 2 ) + 1 , button ) # determine if we should show the final button if ( show_last or i < ( count - 1 ) ) : button = QToolButton ( partsw ) button . setAutoRaise ( True ) button . setMaximumWidth ( 12 ) button . setArrowType ( Qt . RightArrow ) button . setProperty ( 'path' , wrapVariant ( path ) ) button . setProperty ( 'is_completer' , wrapVariant ( True ) ) self . _buttonGroup . addButton ( button ) layout . insertWidget ( ( i * 2 ) + 2 , button ) last_button = button if ( self . scrollWidget ( ) . width ( ) < partsw . width ( ) ) : self . scrollParts ( partsw . width ( ) - self . scrollWidget ( ) . width ( ) ) self . setUpdatesEnabled ( True ) self . navigationChanged . emit ( ) | 11,332 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnavigationedit.py#L524-L606 | [
"def",
"_IOC",
"(",
"cls",
",",
"dir",
",",
"op",
",",
"structure",
"=",
"None",
")",
":",
"control",
"=",
"cls",
"(",
"dir",
",",
"op",
",",
"structure",
")",
"def",
"do",
"(",
"dev",
",",
"*",
"*",
"args",
")",
":",
"return",
"control",
"(",
"dev",
",",
"*",
"*",
"args",
")",
"return",
"do"
] |
Return a new instance of query_cls . | def query ( self ) : if not hasattr ( self , '_decoded_query' ) : self . _decoded_query = list ( urls . _url_decode_impl ( self . querystr . split ( '&' ) , 'utf-8' , False , True , 'strict' ) ) return self . query_cls ( self . _decoded_query ) | 11,333 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/core.py#L110-L116 | [
"def",
"get_conf_file",
"(",
"self",
")",
":",
"for",
"conf_file",
"in",
"[",
"self",
".",
"collection_rules_file",
",",
"self",
".",
"fallback_file",
"]",
":",
"logger",
".",
"debug",
"(",
"\"trying to read conf from: \"",
"+",
"conf_file",
")",
"conf",
"=",
"self",
".",
"try_disk",
"(",
"conf_file",
",",
"self",
".",
"gpg",
")",
"if",
"not",
"conf",
":",
"continue",
"version",
"=",
"conf",
".",
"get",
"(",
"'version'",
",",
"None",
")",
"if",
"version",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"ERROR: Could not find version in json\"",
")",
"conf",
"[",
"'file'",
"]",
"=",
"conf_file",
"logger",
".",
"debug",
"(",
"\"Success reading config\"",
")",
"logger",
".",
"debug",
"(",
"json",
".",
"dumps",
"(",
"conf",
")",
")",
"return",
"conf",
"raise",
"ValueError",
"(",
"\"ERROR: Unable to download conf or read it from disk!\"",
")"
] |
Load the plugin information to the interface . | def refreshUi ( self ) : dataSet = self . dataSet ( ) if not dataSet : return False # lookup widgets based on the data set information for widget in self . findChildren ( QWidget ) : prop = unwrapVariant ( widget . property ( 'dataName' ) ) if prop is None : continue # update the data for the widget prop_name = nativestring ( prop ) if prop_name in dataSet : value = dataSet . value ( prop_name ) projexui . setWidgetValue ( widget , value ) return True | 11,334 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xconfigdialog/xconfigwidget.py#L57-L77 | [
"def",
"list_blobs",
"(",
"call",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"# pylint: disable=unused-argument",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"if",
"'container'",
"not",
"in",
"kwargs",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'A container must be specified'",
")",
"storageservice",
"=",
"_get_block_blob_service",
"(",
"kwargs",
")",
"ret",
"=",
"{",
"}",
"try",
":",
"for",
"blob",
"in",
"storageservice",
".",
"list_blobs",
"(",
"kwargs",
"[",
"'container'",
"]",
")",
".",
"items",
":",
"ret",
"[",
"blob",
".",
"name",
"]",
"=",
"{",
"'blob_type'",
":",
"blob",
".",
"properties",
".",
"blob_type",
",",
"'last_modified'",
":",
"blob",
".",
"properties",
".",
"last_modified",
".",
"isoformat",
"(",
")",
",",
"'server_encrypted'",
":",
"blob",
".",
"properties",
".",
"server_encrypted",
",",
"}",
"except",
"Exception",
"as",
"exc",
":",
"log",
".",
"warning",
"(",
"six",
".",
"text_type",
"(",
"exc",
")",
")",
"return",
"ret"
] |
Resets the ui information to the default data for the widget . | def reset ( self ) : if not self . plugin ( ) : return False self . plugin ( ) . reset ( ) self . refreshUi ( ) return True | 11,335 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xconfigdialog/xconfigwidget.py#L79-L89 | [
"def",
"update_domain_name",
"(",
"self",
",",
"domain_name",
",",
"certificate_name",
"=",
"None",
",",
"certificate_body",
"=",
"None",
",",
"certificate_private_key",
"=",
"None",
",",
"certificate_chain",
"=",
"None",
",",
"certificate_arn",
"=",
"None",
",",
"lambda_name",
"=",
"None",
",",
"stage",
"=",
"None",
",",
"route53",
"=",
"True",
",",
"base_path",
"=",
"None",
")",
":",
"print",
"(",
"\"Updating domain name!\"",
")",
"certificate_name",
"=",
"certificate_name",
"+",
"str",
"(",
"time",
".",
"time",
"(",
")",
")",
"api_gateway_domain",
"=",
"self",
".",
"apigateway_client",
".",
"get_domain_name",
"(",
"domainName",
"=",
"domain_name",
")",
"if",
"not",
"certificate_arn",
"and",
"certificate_body",
"and",
"certificate_private_key",
"and",
"certificate_chain",
":",
"acm_certificate",
"=",
"self",
".",
"acm_client",
".",
"import_certificate",
"(",
"Certificate",
"=",
"certificate_body",
",",
"PrivateKey",
"=",
"certificate_private_key",
",",
"CertificateChain",
"=",
"certificate_chain",
")",
"certificate_arn",
"=",
"acm_certificate",
"[",
"'CertificateArn'",
"]",
"self",
".",
"update_domain_base_path_mapping",
"(",
"domain_name",
",",
"lambda_name",
",",
"stage",
",",
"base_path",
")",
"return",
"self",
".",
"apigateway_client",
".",
"update_domain_name",
"(",
"domainName",
"=",
"domain_name",
",",
"patchOperations",
"=",
"[",
"{",
"\"op\"",
":",
"\"replace\"",
",",
"\"path\"",
":",
"\"/certificateName\"",
",",
"\"value\"",
":",
"certificate_name",
"}",
",",
"{",
"\"op\"",
":",
"\"replace\"",
",",
"\"path\"",
":",
"\"/certificateArn\"",
",",
"\"value\"",
":",
"certificate_arn",
"}",
"]",
")"
] |
network to host long | def n2l ( c , l ) : l = U32 ( c [ 0 ] << 24 ) l = l | ( U32 ( c [ 1 ] ) << 16 ) l = l | ( U32 ( c [ 2 ] ) << 8 ) l = l | ( U32 ( c [ 3 ] ) ) return l | 11,336 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/mschap/des_c.py#L75-L81 | [
"def",
"allocate_stack",
"(",
"size",
"=",
"DEFAULT_STACK_SIZE",
")",
":",
"# Allocate memory with appropriate flags for a stack as in https://blog.fefe.de/?ts=a85c8ba7",
"base",
"=",
"libc",
".",
"mmap",
"(",
"None",
",",
"size",
"+",
"GUARD_PAGE_SIZE",
",",
"libc",
".",
"PROT_READ",
"|",
"libc",
".",
"PROT_WRITE",
",",
"libc",
".",
"MAP_PRIVATE",
"|",
"libc",
".",
"MAP_ANONYMOUS",
"|",
"libc",
".",
"MAP_GROWSDOWN",
"|",
"libc",
".",
"MAP_STACK",
",",
"-",
"1",
",",
"0",
")",
"try",
":",
"# create a guard page that crashes the application when it is written to (on stack overflow)",
"libc",
".",
"mprotect",
"(",
"base",
",",
"GUARD_PAGE_SIZE",
",",
"libc",
".",
"PROT_NONE",
")",
"yield",
"ctypes",
".",
"c_void_p",
"(",
"base",
"+",
"size",
"+",
"GUARD_PAGE_SIZE",
")",
"finally",
":",
"libc",
".",
"munmap",
"(",
"base",
",",
"size",
"+",
"GUARD_PAGE_SIZE",
")"
] |
host to network long | def l2n ( l , c ) : c = [ ] c . append ( int ( ( l >> 24 ) & U32 ( 0xFF ) ) ) c . append ( int ( ( l >> 16 ) & U32 ( 0xFF ) ) ) c . append ( int ( ( l >> 8 ) & U32 ( 0xFF ) ) ) c . append ( int ( ( l ) & U32 ( 0xFF ) ) ) return c | 11,337 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/mschap/des_c.py#L83-L90 | [
"def",
"_unscramble_regressor_columns",
"(",
"parent_data",
",",
"data",
")",
":",
"matches",
"=",
"[",
"'_power[0-9]+'",
",",
"'_derivative[0-9]+'",
"]",
"var",
"=",
"OrderedDict",
"(",
"(",
"c",
",",
"deque",
"(",
")",
")",
"for",
"c",
"in",
"parent_data",
".",
"columns",
")",
"for",
"c",
"in",
"data",
".",
"columns",
":",
"col",
"=",
"c",
"for",
"m",
"in",
"matches",
":",
"col",
"=",
"re",
".",
"sub",
"(",
"m",
",",
"''",
",",
"col",
")",
"if",
"col",
"==",
"c",
":",
"var",
"[",
"col",
"]",
".",
"appendleft",
"(",
"c",
")",
"else",
":",
"var",
"[",
"col",
"]",
".",
"append",
"(",
"c",
")",
"unscrambled",
"=",
"reduce",
"(",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"+",
"y",
")",
",",
"var",
".",
"values",
"(",
")",
")",
"return",
"data",
"[",
"[",
"*",
"unscrambled",
"]",
"]"
] |
Gets the rtm ws_host and user information | def start ( self ) : resp = self . post ( 'start' ) if resp . is_fail ( ) : return None if 'result' not in resp . data : return None result = resp . data [ 'result' ] return { 'user' : result [ 'user' ] , 'ws_host' : result [ 'ws_host' ] , } | 11,338 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_client.py#L52-L70 | [
"def",
"get_job_list",
"(",
"logger",
",",
"match",
",",
"library_mapping",
",",
"token",
",",
"host",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"host",
"+",
"'/api/2.0/jobs/list'",
",",
"auth",
"=",
"(",
"'token'",
",",
"token",
")",
",",
")",
"if",
"res",
".",
"status_code",
"==",
"200",
":",
"job_list",
"=",
"[",
"]",
"if",
"len",
"(",
"res",
".",
"json",
"(",
")",
"[",
"'jobs'",
"]",
")",
"==",
"0",
":",
"return",
"[",
"]",
"for",
"job",
"in",
"res",
".",
"json",
"(",
")",
"[",
"'jobs'",
"]",
":",
"logger",
".",
"debug",
"(",
"'job: {}'",
".",
"format",
"(",
"job",
"[",
"'settings'",
"]",
"[",
"'name'",
"]",
")",
")",
"if",
"'libraries'",
"in",
"job",
"[",
"'settings'",
"]",
".",
"keys",
"(",
")",
":",
"for",
"library",
"in",
"job",
"[",
"'settings'",
"]",
"[",
"'libraries'",
"]",
":",
"if",
"match",
".",
"suffix",
"in",
"library",
".",
"keys",
"(",
")",
":",
"try",
":",
"# if in prod_folder, mapping turns uri into name",
"job_library_uri",
"=",
"basename",
"(",
"library",
"[",
"match",
".",
"suffix",
"]",
")",
"job_match",
"=",
"library_mapping",
"[",
"job_library_uri",
"]",
"except",
"KeyError",
":",
"logger",
".",
"debug",
"(",
"'not in library map: {}'",
".",
"format",
"(",
"job_library_uri",
")",
")",
"pass",
"else",
":",
"if",
"match",
".",
"replace_version",
"(",
"job_match",
",",
"logger",
")",
":",
"job_list",
".",
"append",
"(",
"{",
"'job_id'",
":",
"job",
"[",
"'job_id'",
"]",
",",
"'job_name'",
":",
"job",
"[",
"'settings'",
"]",
"[",
"'name'",
"]",
",",
"'library_path'",
":",
"library",
"[",
"match",
".",
"suffix",
"]",
",",
"}",
")",
"else",
":",
"logger",
".",
"debug",
"(",
"'not replacable: {}'",
".",
"format",
"(",
"job_match",
".",
"filename",
")",
")",
"else",
":",
"logger",
".",
"debug",
"(",
"'no matching suffix: looking for {}, found {}'",
".",
"format",
"(",
"match",
".",
"suffix",
",",
"str",
"(",
"library",
".",
"keys",
"(",
")",
")",
")",
")",
"return",
"job_list",
"else",
":",
"raise",
"APIError",
"(",
"res",
")"
] |
Does the request job | def do ( self , resource , method , params = None , data = None , json = None , headers = None ) : uri = "{0}/{1}" . format ( self . _api_base , resource ) if not params : params = { } params . update ( { 'token' : self . _token } ) req = Request ( method = method , url = uri , params = params , headers = headers , data = data , json = json ) s = Session ( ) prepped = s . prepare_request ( req ) resp = s . send ( prepped ) return RTMResponse ( resp ) | 11,339 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_client.py#L72-L108 | [
"def",
"start_wrap_console",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_wrap_console",
"or",
"self",
".",
"_console_type",
"!=",
"\"telnet\"",
":",
"return",
"remaining_trial",
"=",
"60",
"while",
"True",
":",
"try",
":",
"(",
"reader",
",",
"writer",
")",
"=",
"yield",
"from",
"asyncio",
".",
"open_connection",
"(",
"host",
"=",
"\"127.0.0.1\"",
",",
"port",
"=",
"self",
".",
"_internal_console_port",
")",
"break",
"except",
"(",
"OSError",
",",
"ConnectionRefusedError",
")",
"as",
"e",
":",
"if",
"remaining_trial",
"<=",
"0",
":",
"raise",
"e",
"yield",
"from",
"asyncio",
".",
"sleep",
"(",
"0.1",
")",
"remaining_trial",
"-=",
"1",
"yield",
"from",
"AsyncioTelnetServer",
".",
"write_client_intro",
"(",
"writer",
",",
"echo",
"=",
"True",
")",
"server",
"=",
"AsyncioTelnetServer",
"(",
"reader",
"=",
"reader",
",",
"writer",
"=",
"writer",
",",
"binary",
"=",
"True",
",",
"echo",
"=",
"True",
")",
"self",
".",
"_wrapper_telnet_server",
"=",
"yield",
"from",
"asyncio",
".",
"start_server",
"(",
"server",
".",
"run",
",",
"self",
".",
"_manager",
".",
"port_manager",
".",
"console_host",
",",
"self",
".",
"console",
")"
] |
Sends a GET request | def get ( self , resource , params = None , headers = None ) : return self . do ( resource , 'GET' , params = params , headers = headers ) | 11,340 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_client.py#L110-L116 | [
"def",
"GetAttachmentIdFromMediaId",
"(",
"media_id",
")",
":",
"altchars",
"=",
"'+-'",
"if",
"not",
"six",
".",
"PY2",
":",
"altchars",
"=",
"altchars",
".",
"encode",
"(",
"'utf-8'",
")",
"# altchars for '+' and '/'. We keep '+' but replace '/' with '-'",
"buffer",
"=",
"base64",
".",
"b64decode",
"(",
"str",
"(",
"media_id",
")",
",",
"altchars",
")",
"resoure_id_length",
"=",
"20",
"attachment_id",
"=",
"''",
"if",
"len",
"(",
"buffer",
")",
">",
"resoure_id_length",
":",
"# We are cutting off the storage index.",
"attachment_id",
"=",
"base64",
".",
"b64encode",
"(",
"buffer",
"[",
"0",
":",
"resoure_id_length",
"]",
",",
"altchars",
")",
"if",
"not",
"six",
".",
"PY2",
":",
"attachment_id",
"=",
"attachment_id",
".",
"decode",
"(",
"'utf-8'",
")",
"else",
":",
"attachment_id",
"=",
"media_id",
"return",
"attachment_id"
] |
Sends a POST request | def post ( self , resource , data = None , json = None ) : return self . do ( resource , 'POST' , data = data , json = json ) | 11,341 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/rtm_client.py#L118-L124 | [
"def",
"filename_metadata",
"(",
"filename",
")",
":",
"from",
".",
".",
"segments",
"import",
"Segment",
"name",
"=",
"Path",
"(",
"filename",
")",
".",
"name",
"try",
":",
"obs",
",",
"desc",
",",
"start",
",",
"dur",
"=",
"name",
".",
"split",
"(",
"'-'",
")",
"except",
"ValueError",
"as",
"exc",
":",
"exc",
".",
"args",
"=",
"(",
"'Failed to parse {!r} as LIGO-T050017-compatible '",
"'filename'",
".",
"format",
"(",
"name",
")",
",",
")",
"raise",
"start",
"=",
"float",
"(",
"start",
")",
"dur",
"=",
"dur",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"while",
"True",
":",
"# recursively remove extension components",
"try",
":",
"dur",
"=",
"float",
"(",
"dur",
")",
"except",
"ValueError",
":",
"if",
"'.'",
"not",
"in",
"dur",
":",
"raise",
"dur",
"=",
"dur",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"else",
":",
"break",
"return",
"obs",
",",
"desc",
",",
"Segment",
"(",
"start",
",",
"start",
"+",
"dur",
")"
] |
Dispatches the request to the plugins collect method | def CollectMetrics ( self , request , context ) : LOG . debug ( "CollectMetrics called" ) try : metrics_to_collect = [ ] for metric in request . metrics : metrics_to_collect . append ( Metric ( pb = metric ) ) metrics_collected = self . plugin . collect ( metrics_to_collect ) return MetricsReply ( metrics = [ m . pb for m in metrics_collected ] ) except Exception as err : msg = "message: {}\n\nstack trace: {}" . format ( err , traceback . format_exc ( ) ) return MetricsReply ( metrics = [ ] , error = msg ) | 11,342 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/collector_proxy.py#L36-L48 | [
"def",
"_init_rabit",
"(",
")",
":",
"if",
"_LIB",
"is",
"not",
"None",
":",
"_LIB",
".",
"RabitGetRank",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"_LIB",
".",
"RabitGetWorldSize",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"_LIB",
".",
"RabitIsDistributed",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"_LIB",
".",
"RabitVersionNumber",
".",
"restype",
"=",
"ctypes",
".",
"c_int"
] |
Dispatches the request to the plugins get_config_policy method | def GetConfigPolicy ( self , request , context ) : try : policy = self . plugin . get_config_policy ( ) return policy . _pb except Exception as err : msg = "message: {}\n\nstack trace: {}" . format ( err . message , traceback . format_exc ( ) ) return GetConfigPolicyReply ( error = msg ) | 11,343 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/plugin_proxy.py#L43-L51 | [
"def",
"PrependUOffsetTRelative",
"(",
"self",
",",
"off",
")",
":",
"# Ensure alignment is already done:",
"self",
".",
"Prep",
"(",
"N",
".",
"UOffsetTFlags",
".",
"bytewidth",
",",
"0",
")",
"if",
"not",
"(",
"off",
"<=",
"self",
".",
"Offset",
"(",
")",
")",
":",
"msg",
"=",
"\"flatbuffers: Offset arithmetic error.\"",
"raise",
"OffsetArithmeticError",
"(",
"msg",
")",
"off2",
"=",
"self",
".",
"Offset",
"(",
")",
"-",
"off",
"+",
"N",
".",
"UOffsetTFlags",
".",
"bytewidth",
"self",
".",
"PlaceUOffsetT",
"(",
"off2",
")"
] |
Use this method to send text messages . On success the sent Message is returned . | def send_message ( self , text , chat_id , reply_to_message_id = None , disable_web_page_preview = False , reply_markup = None ) : self . logger . info ( 'sending message "%s"' , format ( text . replace ( '\n' , '\\n' ) ) ) payload = dict ( text = text , chat_id = chat_id , reply_to_message_id = reply_to_message_id , disable_web_page_preview = disable_web_page_preview , reply_markup = reply_markup ) return Message . from_api ( self , * * self . _get ( 'sendMessage' , payload ) ) | 11,344 | https://github.com/wrboyce/telegrambot/blob/c35ce19886df4c306a2a19851cc1f63e3066d70d/telegrambot/api/__init__.py#L63-L73 | [
"def",
"lookup_basis_by_role",
"(",
"primary_basis",
",",
"role",
",",
"data_dir",
"=",
"None",
")",
":",
"data_dir",
"=",
"fix_data_dir",
"(",
"data_dir",
")",
"role",
"=",
"role",
".",
"lower",
"(",
")",
"if",
"not",
"role",
"in",
"get_roles",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Role {} is not a valid role\"",
".",
"format",
"(",
"role",
")",
")",
"bs_data",
"=",
"_get_basis_metadata",
"(",
"primary_basis",
",",
"data_dir",
")",
"auxdata",
"=",
"bs_data",
"[",
"'auxiliaries'",
"]",
"if",
"not",
"role",
"in",
"auxdata",
":",
"raise",
"RuntimeError",
"(",
"\"Role {} doesn't exist for {}\"",
".",
"format",
"(",
"role",
",",
"primary_basis",
")",
")",
"return",
"auxdata",
"[",
"role",
"]"
] |
Use this method to send audio files if you want Telegram clients to display them in the music player . Your audio must be in the . mp3 format . On success the sent Message is returned . Bots can currently send audio files of up to 50 MB in size this limit may be changed in the future . | def send_audio ( self , chat_id , audio , duration = None , performer = None , title = None , reply_to_message_id = None , reply_markup = None ) : self . logger . info ( 'sending audio payload %s' , audio ) payload = dict ( chat_id = chat_id , duration = duration , performer = performer , title = title , reply_to_message_id = reply_to_message_id , reply_markup = reply_markup ) files = dict ( audio = open ( audio , 'rb' ) ) return Message . from_api ( self , * * self . _post ( 'sendAudio' , payload , files ) ) | 11,345 | https://github.com/wrboyce/telegrambot/blob/c35ce19886df4c306a2a19851cc1f63e3066d70d/telegrambot/api/__init__.py#L97-L118 | [
"def",
"_unbind_topics",
"(",
"self",
",",
"topics",
")",
":",
"self",
".",
"client",
".",
"unsubscribe",
"(",
"topics",
".",
"status",
")",
"self",
".",
"client",
".",
"unsubscribe",
"(",
"topics",
".",
"tracing",
")",
"self",
".",
"client",
".",
"unsubscribe",
"(",
"topics",
".",
"streaming",
")",
"self",
".",
"client",
".",
"unsubscribe",
"(",
"topics",
".",
"response",
")"
] |
Use this method to send general files . On success the sent Message is returned . Bots can currently send files of any type of up to 50 MB in size this limit may be changed in the future . | def send_document ( self , chat_id = None , document = None , reply_to_message_id = None , reply_markup = None ) : payload = dict ( chat_id = chat_id , reply_to_message_id = reply_to_message_id , reply_markup = reply_markup ) files = dict ( video = open ( document , 'rb' ) ) return Message . from_api ( api , * * self . _post ( 'sendDocument' , payload , files ) ) | 11,346 | https://github.com/wrboyce/telegrambot/blob/c35ce19886df4c306a2a19851cc1f63e3066d70d/telegrambot/api/__init__.py#L120-L129 | [
"def",
"close",
"(",
"self",
")",
":",
"windll",
".",
"kernel32",
".",
"CloseHandle",
"(",
"self",
".",
"conout_pipe",
")",
"windll",
".",
"kernel32",
".",
"CloseHandle",
"(",
"self",
".",
"conin_pipe",
")"
] |
Use this method to send . webp stickers . On success the sent Message is returned . | def send_sticker ( self , chat_id = None , sticker = None , reply_to_message_id = None , reply_markup = None ) : payload = dict ( chat_id = chat_id , reply_to_message_id = reply_to_message_id , reply_markup = reply_markup ) files = dict ( sticker = open ( sticker , 'rb' ) ) return Message . from_api ( api , * * self . _post ( 'sendSticker' , payload , files ) ) | 11,347 | https://github.com/wrboyce/telegrambot/blob/c35ce19886df4c306a2a19851cc1f63e3066d70d/telegrambot/api/__init__.py#L131-L139 | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"update_ttl",
"(",
"other",
".",
"ttl",
")",
"super",
"(",
"Rdataset",
",",
"self",
")",
".",
"update",
"(",
"other",
")"
] |
Removes this item from the view scene . | def removeFromScene ( self ) : gantt = self . ganttWidget ( ) if not gantt : return scene = gantt . viewWidget ( ) . scene ( ) scene . removeItem ( self . viewItem ( ) ) for target , viewItem in self . _dependencies . items ( ) : target . _reverseDependencies . pop ( self ) scene . removeItem ( viewItem ) | 11,348 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L331-L344 | [
"def",
"create_alarm_subscription",
"(",
"self",
",",
"on_data",
"=",
"None",
",",
"timeout",
"=",
"60",
")",
":",
"manager",
"=",
"WebSocketSubscriptionManager",
"(",
"self",
".",
"_client",
",",
"resource",
"=",
"'alarms'",
")",
"# Represent subscription as a future",
"subscription",
"=",
"AlarmSubscription",
"(",
"manager",
")",
"wrapped_callback",
"=",
"functools",
".",
"partial",
"(",
"_wrap_callback_parse_alarm_data",
",",
"subscription",
",",
"on_data",
")",
"manager",
".",
"open",
"(",
"wrapped_callback",
",",
"instance",
"=",
"self",
".",
"_instance",
",",
"processor",
"=",
"self",
".",
"_processor",
")",
"# Wait until a reply or exception is received",
"subscription",
".",
"reply",
"(",
"timeout",
"=",
"timeout",
")",
"return",
"subscription"
] |
Syncs the information from this item to the tree and view . | def sync ( self , recursive = False ) : self . syncTree ( recursive = recursive ) self . syncView ( recursive = recursive ) | 11,349 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L503-L508 | [
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"self",
".",
"websock_url",
"=",
"self",
".",
"chrome",
".",
"start",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"websock",
"=",
"websocket",
".",
"WebSocketApp",
"(",
"self",
".",
"websock_url",
")",
"self",
".",
"websock_thread",
"=",
"WebsockReceiverThread",
"(",
"self",
".",
"websock",
",",
"name",
"=",
"'WebsockThread:%s'",
"%",
"self",
".",
"chrome",
".",
"port",
")",
"self",
".",
"websock_thread",
".",
"start",
"(",
")",
"self",
".",
"_wait_for",
"(",
"lambda",
":",
"self",
".",
"websock_thread",
".",
"is_open",
",",
"timeout",
"=",
"30",
")",
"# tell browser to send us messages we're interested in",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Page.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Console.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Runtime.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.setForceUpdateOnPageLoad'",
")",
"# disable google analytics",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.setBlockedURLs'",
",",
"params",
"=",
"{",
"'urls'",
":",
"[",
"'*google-analytics.com/analytics.js'",
",",
"'*google-analytics.com/ga.js'",
"]",
"}",
")"
] |
Syncs the information from this item to the tree . | def syncTree ( self , recursive = False , blockSignals = True ) : tree = self . treeWidget ( ) # sync the tree information
if not tree : return items = [ self ] if recursive : items += list ( self . children ( recursive = True ) ) if blockSignals and not tree . signalsBlocked ( ) : blocked = True tree . blockSignals ( True ) else : blocked = False date_format = self . ganttWidget ( ) . dateFormat ( ) for item in items : for c , col in enumerate ( tree . columns ( ) ) : value = item . property ( col , '' ) item . setData ( c , Qt . EditRole , wrapVariant ( value ) ) if blocked : tree . blockSignals ( False ) | 11,350 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L535-L563 | [
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"self",
".",
"websock_url",
"=",
"self",
".",
"chrome",
".",
"start",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"websock",
"=",
"websocket",
".",
"WebSocketApp",
"(",
"self",
".",
"websock_url",
")",
"self",
".",
"websock_thread",
"=",
"WebsockReceiverThread",
"(",
"self",
".",
"websock",
",",
"name",
"=",
"'WebsockThread:%s'",
"%",
"self",
".",
"chrome",
".",
"port",
")",
"self",
".",
"websock_thread",
".",
"start",
"(",
")",
"self",
".",
"_wait_for",
"(",
"lambda",
":",
"self",
".",
"websock_thread",
".",
"is_open",
",",
"timeout",
"=",
"30",
")",
"# tell browser to send us messages we're interested in",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Page.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Console.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Runtime.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.enable'",
")",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'ServiceWorker.setForceUpdateOnPageLoad'",
")",
"# disable google analytics",
"self",
".",
"send_to_chrome",
"(",
"method",
"=",
"'Network.setBlockedURLs'",
",",
"params",
"=",
"{",
"'urls'",
":",
"[",
"'*google-analytics.com/analytics.js'",
",",
"'*google-analytics.com/ga.js'",
"]",
"}",
")"
] |
Syncs the information from this item to the view . | def syncView ( self , recursive = False ) : # update the view widget
gantt = self . ganttWidget ( ) tree = self . treeWidget ( ) if not gantt : return vwidget = gantt . viewWidget ( ) scene = vwidget . scene ( ) cell_w = gantt . cellWidth ( ) tree_offset_y = tree . header ( ) . height ( ) + 1 tree_offset_y += tree . verticalScrollBar ( ) . value ( ) # collect the items to work on
items = [ self ] if recursive : items += list ( self . children ( recursive = True ) ) for item in items : # grab the view item from the gantt item
vitem = item . viewItem ( ) if not vitem . scene ( ) : scene . addItem ( vitem ) # make sure the item should be visible
if item . isHidden ( ) or not tree : vitem . hide ( ) continue vitem . show ( ) tree_rect = tree . visualItemRect ( item ) tree_y = tree_rect . y ( ) + tree_offset_y tree_h = tree_rect . height ( ) # check to see if this item is hidden
if tree_rect . height ( ) == 0 : vitem . hide ( ) continue if gantt . timescale ( ) in ( gantt . Timescale . Minute , gantt . Timescale . Hour , gantt . Timescale . Day ) : dstart = item . dateTimeStart ( ) dend = item . dateTimeEnd ( ) view_x = scene . datetimeXPos ( dstart ) view_r = scene . datetimeXPos ( dend ) view_w = view_r - view_x else : view_x = scene . dateXPos ( item . dateStart ( ) ) view_w = item . duration ( ) * cell_w # determine the % off from the length based on this items time
if not item . isAllDay ( ) : full_day = 24 * 60 * 60 # full days worth of seconds
# determine the start offset
start = item . timeStart ( ) start_day = ( start . hour ( ) * 60 * 60 ) start_day += ( start . minute ( ) * 60 ) start_day += ( start . second ( ) ) offset_start = ( start_day / float ( full_day ) ) * cell_w # determine the end offset
end = item . timeEnd ( ) end_day = ( end . hour ( ) * 60 * 60 ) end_day += ( start . minute ( ) * 60 ) end_day += ( start . second ( ) + 1 ) # forces at least 1 sec
offset_end = ( ( full_day - end_day ) / float ( full_day ) ) offset_end *= cell_w # update the xpos and widths
view_x += offset_start view_w -= ( offset_start + offset_end ) view_w = max ( view_w , 5 ) vitem . setSyncing ( True ) vitem . setPos ( view_x , tree_y ) vitem . setRect ( 0 , 0 , view_w , tree_h ) vitem . setSyncing ( False ) # setup standard properties
flags = vitem . ItemIsSelectable flags |= vitem . ItemIsFocusable if item . flags ( ) & Qt . ItemIsEditable : flags |= vitem . ItemIsMovable vitem . setFlags ( flags ) item . syncDependencies ( ) | 11,351 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L565-L662 | [
"def",
"_init_publisher_ws",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"Initializing new web socket connection.\"",
")",
"url",
"=",
"(",
"'wss://%s/v1/stream/messages/'",
"%",
"self",
".",
"eventhub_client",
".",
"host",
")",
"headers",
"=",
"self",
".",
"_generate_publish_headers",
"(",
")",
"logging",
".",
"debug",
"(",
"\"URL=\"",
"+",
"str",
"(",
"url",
")",
")",
"logging",
".",
"debug",
"(",
"\"HEADERS=\"",
"+",
"str",
"(",
"headers",
")",
")",
"websocket",
".",
"enableTrace",
"(",
"False",
")",
"self",
".",
"_ws",
"=",
"websocket",
".",
"WebSocketApp",
"(",
"url",
",",
"header",
"=",
"headers",
",",
"on_message",
"=",
"self",
".",
"_on_ws_message",
",",
"on_open",
"=",
"self",
".",
"_on_ws_open",
",",
"on_close",
"=",
"self",
".",
"_on_ws_close",
")",
"self",
".",
"_ws_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_ws",
".",
"run_forever",
",",
"kwargs",
"=",
"{",
"'ping_interval'",
":",
"30",
"}",
")",
"self",
".",
"_ws_thread",
".",
"daemon",
"=",
"True",
"self",
".",
"_ws_thread",
".",
"start",
"(",
")",
"time",
".",
"sleep",
"(",
"1",
")"
] |
Match package with the requirement . | def match ( self , package ) : if isinstance ( package , basestring ) : from . packages import Package package = Package . parse ( package ) if self . name != package . name : return False if self . version_constraints and package . version not in self . version_constraints : return False if self . build_options : if package . build_options : if self . build_options - package . build_options : return False else : return True else : return False else : return True | 11,352 | https://github.com/pmuller/versions/blob/951bc3fd99b6a675190f11ee0752af1d7ff5b440/versions/requirements.py#L117-L146 | [
"def",
"_cached_results",
"(",
"self",
",",
"start_time",
",",
"end_time",
")",
":",
"cached_buckets",
"=",
"self",
".",
"_bucket_events",
"(",
"self",
".",
"_client",
".",
"get",
"(",
"self",
".",
"_scratch_stream",
",",
"start_time",
",",
"end_time",
",",
"namespace",
"=",
"self",
".",
"_scratch_namespace",
")",
")",
"for",
"bucket_events",
"in",
"cached_buckets",
":",
"# If we have multiple cache entries for the same bucket, pretend",
"# we have no results for that bucket.",
"if",
"len",
"(",
"bucket_events",
")",
"==",
"1",
":",
"first_result",
"=",
"bucket_events",
"[",
"0",
"]",
"yield",
"(",
"kronos_time_to_epoch_time",
"(",
"first_result",
"[",
"TIMESTAMP_FIELD",
"]",
")",
",",
"first_result",
"[",
"QueryCache",
".",
"CACHE_KEY",
"]",
")"
] |
Returns the current Raft leader | async def leader ( self ) : response = await self . _api . get ( "/v1/status/leader" ) if response . status == 200 : return response . body | 11,353 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/status_endpoint.py#L11-L19 | [
"def",
"get_listing",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'listing'",
")",
":",
"allEvents",
"=",
"self",
".",
"get_allEvents",
"(",
")",
"openEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
"closedEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
"publicEvents",
"=",
"allEvents",
".",
"instance_of",
"(",
"PublicEvent",
")",
"allSeries",
"=",
"allEvents",
".",
"instance_of",
"(",
"Series",
")",
"self",
".",
"listing",
"=",
"{",
"'allEvents'",
":",
"allEvents",
",",
"'openEvents'",
":",
"openEvents",
",",
"'closedEvents'",
":",
"closedEvents",
",",
"'publicEvents'",
":",
"publicEvents",
",",
"'allSeries'",
":",
"allSeries",
",",
"'regOpenEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'publicevent__category'",
")",
",",
"'regOpenSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateSeries'",
":",
"allSeries",
".",
"filter",
"(",
"series__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'series__category'",
")",
",",
"}",
"return",
"self",
".",
"listing"
] |
Returns the current Raft peer set | async def peers ( self ) : response = await self . _api . get ( "/v1/status/peers" ) if response . status == 200 : return set ( response . body ) | 11,354 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/status_endpoint.py#L21-L41 | [
"def",
"_index_audio_cmu",
"(",
"self",
",",
"basename",
"=",
"None",
",",
"replace_already_indexed",
"=",
"False",
")",
":",
"self",
".",
"_prepare_audio",
"(",
"basename",
"=",
"basename",
",",
"replace_already_indexed",
"=",
"replace_already_indexed",
")",
"for",
"staging_audio_basename",
"in",
"self",
".",
"_list_audio_files",
"(",
"sub_dir",
"=",
"\"staging\"",
")",
":",
"original_audio_name",
"=",
"''",
".",
"join",
"(",
"staging_audio_basename",
".",
"split",
"(",
"'.'",
")",
"[",
":",
"-",
"1",
"]",
")",
"[",
":",
"-",
"3",
"]",
"pocketsphinx_command",
"=",
"''",
".",
"join",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
")",
"try",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Now indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
",",
"universal_newlines",
"=",
"True",
")",
".",
"split",
"(",
"'\\n'",
")",
"str_timestamps_with_sil_conf",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"split",
"(",
"\" \"",
")",
",",
"filter",
"(",
"None",
",",
"output",
"[",
"1",
":",
"]",
")",
")",
")",
"# Timestamps are putted in a list of a single element. To match",
"# Watson's output.",
"self",
".",
"__timestamps_unregulated",
"[",
"original_audio_name",
"+",
"\".wav\"",
"]",
"=",
"[",
"(",
"self",
".",
"_timestamp_extractor_cmu",
"(",
"staging_audio_basename",
",",
"str_timestamps_with_sil_conf",
")",
")",
"]",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Done indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"e",
",",
"\"The command was: {}\"",
".",
"format",
"(",
"pocketsphinx_command",
")",
")",
"self",
".",
"__errors",
"[",
"(",
"time",
"(",
")",
",",
"staging_audio_basename",
")",
"]",
"=",
"e",
"self",
".",
"_timestamp_regulator",
"(",
")",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Finished indexing procedure\"",
")"
] |
Unmarks this splitter as being in a collapsed state clearing any \ collapsed information . | def unmarkCollapsed ( self ) : if ( not self . isCollapsed ( ) ) : return self . _collapsed = False self . _storedSizes = None if ( self . orientation ( ) == Qt . Vertical ) : self . _collapseBefore . setArrowType ( Qt . UpArrow ) self . _collapseAfter . setArrowType ( Qt . DownArrow ) else : self . _collapseBefore . setArrowType ( Qt . LeftArrow ) self . _collapseAfter . setArrowType ( Qt . RightArrow ) | 11,355 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsplitter.py#L269-L285 | [
"def",
"fetcher",
"(",
"date",
"=",
"datetime",
".",
"today",
"(",
")",
",",
"url_pattern",
"=",
"URL_PATTERN",
")",
":",
"api_url",
"=",
"url_pattern",
"%",
"date",
".",
"strftime",
"(",
"'%Y-%m-%d'",
")",
"headers",
"=",
"{",
"'Referer'",
":",
"'http://n.pl/program-tv'",
"}",
"raw_result",
"=",
"requests",
".",
"get",
"(",
"api_url",
",",
"headers",
"=",
"headers",
")",
".",
"json",
"(",
")",
"return",
"raw_result"
] |
Collapses the splitter after this handle . | def toggleCollapseAfter ( self ) : if ( self . isCollapsed ( ) ) : self . uncollapse ( ) else : self . collapse ( XSplitterHandle . CollapseDirection . After ) | 11,356 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsplitter.py#L287-L294 | [
"def",
"configure_materials_manager",
"(",
"graph",
",",
"key_provider",
")",
":",
"if",
"graph",
".",
"config",
".",
"materials_manager",
".",
"enable_cache",
":",
"return",
"CachingCryptoMaterialsManager",
"(",
"cache",
"=",
"LocalCryptoMaterialsCache",
"(",
"graph",
".",
"config",
".",
"materials_manager",
".",
"cache_capacity",
")",
",",
"master_key_provider",
"=",
"key_provider",
",",
"max_age",
"=",
"graph",
".",
"config",
".",
"materials_manager",
".",
"cache_max_age",
",",
"max_messages_encrypted",
"=",
"graph",
".",
"config",
".",
"materials_manager",
".",
"cache_max_messages_encrypted",
",",
")",
"return",
"DefaultCryptoMaterialsManager",
"(",
"master_key_provider",
"=",
"key_provider",
")"
] |
Collapses the splitter before this handle . | def toggleCollapseBefore ( self ) : if ( self . isCollapsed ( ) ) : self . uncollapse ( ) else : self . collapse ( XSplitterHandle . CollapseDirection . Before ) | 11,357 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsplitter.py#L296-L303 | [
"def",
"_get_http_crl_distribution_points",
"(",
"self",
",",
"crl_distribution_points",
")",
":",
"output",
"=",
"[",
"]",
"if",
"crl_distribution_points",
"is",
"None",
":",
"return",
"[",
"]",
"for",
"distribution_point",
"in",
"crl_distribution_points",
":",
"distribution_point_name",
"=",
"distribution_point",
"[",
"'distribution_point'",
"]",
"if",
"distribution_point_name",
"is",
"VOID",
":",
"continue",
"# RFC 5280 indicates conforming CA should not use the relative form",
"if",
"distribution_point_name",
".",
"name",
"==",
"'name_relative_to_crl_issuer'",
":",
"continue",
"# This library is currently only concerned with HTTP-based CRLs",
"for",
"general_name",
"in",
"distribution_point_name",
".",
"chosen",
":",
"if",
"general_name",
".",
"name",
"==",
"'uniform_resource_identifier'",
":",
"output",
".",
"append",
"(",
"distribution_point",
")",
"return",
"output"
] |
Resets the colors to the default settings . | def reset ( self ) : dataSet = self . dataSet ( ) if ( not dataSet ) : dataSet = XScheme ( ) dataSet . reset ( ) | 11,358 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/configs/xschemeconfig.py#L113-L121 | [
"def",
"unregisterDataItem",
"(",
"self",
",",
"path",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/unregisterItem\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"itempath\"",
":",
"path",
",",
"\"force\"",
":",
"\"true\"",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Ensures that this layer is visible by turning on all parent layers \ that it needs to based on its inheritance value . | def ensureVisible ( self ) : # make sure all parents are visible if self . _parent and self . _inheritVisibility : self . _parent . ensureVisible ( ) self . _visible = True self . sync ( ) | 11,359 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnodelayer.py#L97-L107 | [
"def",
"set_error_handler",
"(",
"codec",
",",
"handler",
",",
"data",
"=",
"None",
")",
":",
"OPENJP2",
".",
"opj_set_error_handler",
".",
"argtypes",
"=",
"[",
"CODEC_TYPE",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_void_p",
"]",
"OPENJP2",
".",
"opj_set_error_handler",
".",
"restype",
"=",
"check_error",
"OPENJP2",
".",
"opj_set_error_handler",
"(",
"codec",
",",
"handler",
",",
"data",
")"
] |
Syncs the items on this layer with the current layer settings . | def sync ( self ) : layerData = self . layerData ( ) for item in self . scene ( ) . items ( ) : try : if item . _layer == self : item . syncLayerData ( layerData ) except AttributeError : continue | 11,360 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnodelayer.py#L391-L401 | [
"def",
"parse_journal",
"(",
"journal",
")",
":",
"events",
"=",
"[",
"e",
"for",
"e",
"in",
"journal",
"if",
"not",
"isinstance",
"(",
"e",
",",
"CorruptedUsnRecord",
")",
"]",
"keyfunc",
"=",
"lambda",
"e",
":",
"str",
"(",
"e",
".",
"file_reference_number",
")",
"+",
"e",
".",
"file_name",
"+",
"e",
".",
"timestamp",
"event_groups",
"=",
"(",
"tuple",
"(",
"g",
")",
"for",
"k",
",",
"g",
"in",
"groupby",
"(",
"events",
",",
"key",
"=",
"keyfunc",
")",
")",
"if",
"len",
"(",
"events",
")",
"<",
"len",
"(",
"list",
"(",
"journal",
")",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Corrupted records in UsnJrnl, some events might be missing.\"",
")",
"return",
"[",
"journal_event",
"(",
"g",
")",
"for",
"g",
"in",
"event_groups",
"]"
] |
the urlparse . urlsplit cache breaks if it contains unicode and we cannot control that . So we force type cast that thing back to what we think it is . | def _safe_urlsplit ( s ) : rv = urlparse . urlsplit ( s ) # we have to check rv[2] here and not rv[1] as rv[1] will be # an empty bytestring in case no domain was given. if type ( rv [ 2 ] ) is not type ( s ) : assert hasattr ( urlparse , 'clear_cache' ) urlparse . clear_cache ( ) rv = urlparse . urlsplit ( s ) assert type ( rv [ 2 ] ) is type ( s ) return rv | 11,361 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L58-L71 | [
"async",
"def",
"open_session",
"(",
"self",
",",
"request",
":",
"BaseRequestWebsocket",
")",
"->",
"Session",
":",
"return",
"await",
"ensure_coroutine",
"(",
"self",
".",
"session_interface",
".",
"open_session",
")",
"(",
"self",
",",
"request",
")"
] |
Splits up an URI or IRI . | def _uri_split ( uri ) : scheme , netloc , path , query , fragment = _safe_urlsplit ( uri ) auth = None port = None if '@' in netloc : auth , netloc = netloc . split ( '@' , 1 ) if netloc . startswith ( '[' ) : host , port_part = netloc [ 1 : ] . split ( ']' , 1 ) if port_part . startswith ( ':' ) : port = port_part [ 1 : ] elif ':' in netloc : host , port = netloc . split ( ':' , 1 ) else : host = netloc return scheme , auth , host , port , path , query , fragment | 11,362 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L95-L113 | [
"def",
"write_result_stream",
"(",
"result_stream",
",",
"filename_prefix",
"=",
"None",
",",
"results_per_file",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"result_stream",
",",
"types",
".",
"GeneratorType",
")",
":",
"stream",
"=",
"result_stream",
"else",
":",
"stream",
"=",
"result_stream",
".",
"stream",
"(",
")",
"file_time_formatter",
"=",
"\"%Y-%m-%dT%H_%M_%S\"",
"if",
"filename_prefix",
"is",
"None",
":",
"filename_prefix",
"=",
"\"twitter_search_results\"",
"if",
"results_per_file",
":",
"logger",
".",
"info",
"(",
"\"chunking result stream to files with {} tweets per file\"",
".",
"format",
"(",
"results_per_file",
")",
")",
"chunked_stream",
"=",
"partition",
"(",
"stream",
",",
"results_per_file",
",",
"pad_none",
"=",
"True",
")",
"for",
"chunk",
"in",
"chunked_stream",
":",
"chunk",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
",",
"chunk",
")",
"curr_datetime",
"=",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"file_time_formatter",
")",
")",
"_filename",
"=",
"\"{}_{}.json\"",
".",
"format",
"(",
"filename_prefix",
",",
"curr_datetime",
")",
"yield",
"from",
"write_ndjson",
"(",
"_filename",
",",
"chunk",
")",
"else",
":",
"curr_datetime",
"=",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"file_time_formatter",
")",
")",
"_filename",
"=",
"\"{}.json\"",
".",
"format",
"(",
"filename_prefix",
")",
"yield",
"from",
"write_ndjson",
"(",
"_filename",
",",
"stream",
")"
] |
URL decode a single string with a given decoding . | def url_unquote ( s , charset = 'utf-8' , errors = 'replace' ) : if isinstance ( s , unicode ) : s = s . encode ( charset ) return _decode_unicode ( _unquote ( s ) , charset , errors ) | 11,363 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L412-L425 | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"expire_in",
"=",
"None",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_keystore",
":",
"self",
".",
"_keystore",
"[",
"key",
"]",
"=",
"InMemoryItemValue",
"(",
"expire_in",
"=",
"expire_in",
")",
"k",
"=",
"self",
".",
"_keystore",
"[",
"key",
"]",
"\"\"\":type k InMemoryItemValue\"\"\"",
"k",
".",
"update_expire_time",
"(",
"expire_in",
")",
"k",
".",
"value",
"=",
"value"
] |
URL decode a single string with the given decoding and decode a + to whitespace . | def url_unquote_plus ( s , charset = 'utf-8' , errors = 'replace' ) : if isinstance ( s , unicode ) : s = s . encode ( charset ) return _decode_unicode ( _unquote_plus ( s ) , charset , errors ) | 11,364 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L428-L442 | [
"def",
"get_parcel",
"(",
"resource_root",
",",
"product",
",",
"version",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"_get_parcel",
"(",
"resource_root",
",",
"PARCEL_PATH",
"%",
"(",
"cluster_name",
",",
"product",
",",
"version",
")",
")"
] |
Setups a new internal logging handler . For fastlog loggers handlers are kept track of in the self . _handlers list | def addHandler ( self , handler ) : self . _handlers . append ( handler ) self . inner . addHandler ( handler ) | 11,365 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L38-L44 | [
"def",
"get_description",
"(",
"self",
",",
"lang",
":",
"str",
"=",
"None",
")",
"->",
"Literal",
":",
"return",
"self",
".",
"metadata",
".",
"get_single",
"(",
"key",
"=",
"DC",
".",
"description",
",",
"lang",
"=",
"lang",
")"
] |
Adjusts the output format of messages based on the style name provided | def setStyle ( self , stylename ) : self . style = importlib . import_module ( stylename ) newHandler = Handler ( ) newHandler . setFormatter ( Formatter ( self . style ) ) self . addHandler ( newHandler ) | 11,366 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L46-L59 | [
"def",
"is_registration_possible",
"(",
"self",
",",
"user_info",
")",
":",
"return",
"self",
".",
"get_accessibility",
"(",
")",
".",
"is_open",
"(",
")",
"and",
"self",
".",
"_registration",
".",
"is_open",
"(",
")",
"and",
"self",
".",
"is_user_accepted_by_access_control",
"(",
"user_info",
")"
] |
Internal method to filter into the formatter before being passed to the main Python logger | def _log ( self , lvl , msg , type , args , kwargs ) : extra = kwargs . get ( 'extra' , { } ) extra . setdefault ( "fastlog-type" , type ) extra . setdefault ( "fastlog-indent" , self . _indent ) kwargs [ 'extra' ] = extra self . _lastlevel = lvl self . inner . log ( lvl , msg , * args , * * kwargs ) | 11,367 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L67-L78 | [
"def",
"createAltHistoryPlot",
"(",
"self",
")",
":",
"self",
".",
"altHistRect",
"=",
"patches",
".",
"Rectangle",
"(",
"(",
"self",
".",
"leftPos",
"+",
"(",
"self",
".",
"vertSize",
"/",
"10.0",
")",
",",
"-",
"0.25",
")",
",",
"0.5",
",",
"0.5",
",",
"facecolor",
"=",
"'grey'",
",",
"edgecolor",
"=",
"'none'",
",",
"alpha",
"=",
"0.4",
",",
"zorder",
"=",
"4",
")",
"self",
".",
"axes",
".",
"add_patch",
"(",
"self",
".",
"altHistRect",
")",
"self",
".",
"altPlot",
",",
"=",
"self",
".",
"axes",
".",
"plot",
"(",
"[",
"self",
".",
"leftPos",
"+",
"(",
"self",
".",
"vertSize",
"/",
"10.0",
")",
",",
"self",
".",
"leftPos",
"+",
"(",
"self",
".",
"vertSize",
"/",
"10.0",
")",
"+",
"0.5",
"]",
",",
"[",
"0.0",
",",
"0.0",
"]",
",",
"color",
"=",
"'k'",
",",
"marker",
"=",
"None",
",",
"zorder",
"=",
"4",
")",
"self",
".",
"altMarker",
",",
"=",
"self",
".",
"axes",
".",
"plot",
"(",
"self",
".",
"leftPos",
"+",
"(",
"self",
".",
"vertSize",
"/",
"10.0",
")",
"+",
"0.5",
",",
"0.0",
",",
"marker",
"=",
"'o'",
",",
"color",
"=",
"'k'",
",",
"zorder",
"=",
"4",
")",
"self",
".",
"altText2",
"=",
"self",
".",
"axes",
".",
"text",
"(",
"self",
".",
"leftPos",
"+",
"(",
"4",
"*",
"self",
".",
"vertSize",
"/",
"10.0",
")",
"+",
"0.5",
",",
"0.0",
",",
"'%.f m'",
"%",
"self",
".",
"relAlt",
",",
"color",
"=",
"'k'",
",",
"size",
"=",
"self",
".",
"fontSize",
",",
"ha",
"=",
"'left'",
",",
"va",
"=",
"'center'",
",",
"zorder",
"=",
"4",
")"
] |
Prints a separator to the log . This can be used to separate blocks of log messages . | def separator ( self , * args , * * kwargs ) : levelOverride = kwargs . get ( 'level' ) or self . _lastlevel self . _log ( levelOverride , '' , 'separator' , args , kwargs ) | 11,368 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L106-L117 | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"super",
"(",
"HyperparameterTuningJobAnalytics",
",",
"self",
")",
".",
"clear_cache",
"(",
")",
"self",
".",
"_tuning_job_describe_result",
"=",
"None",
"self",
".",
"_training_job_summaries",
"=",
"None"
] |
Begins an indented block . Must be used in a with code block . All calls to the logger inside of the block will be indented . | def indent ( self ) : blk = IndentBlock ( self , self . _indent ) self . _indent += 1 return blk | 11,369 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L119-L126 | [
"def",
"setAltInterface",
"(",
"self",
",",
"alternate",
")",
":",
"if",
"isinstance",
"(",
"alternate",
",",
"Interface",
")",
":",
"alternate",
"=",
"alternate",
".",
"alternateSetting",
"self",
".",
"dev",
".",
"set_interface_altsetting",
"(",
"self",
".",
"__claimed_interface",
",",
"alternate",
")"
] |
Prints an empty line to the log . Uses the level of the last message printed unless specified otherwise with the level = kwarg . | def newline ( self , * args , * * kwargs ) : levelOverride = kwargs . get ( 'level' ) or self . _lastlevel self . _log ( levelOverride , '' , 'newline' , args , kwargs ) | 11,370 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L135-L141 | [
"def",
"copy_meta_from",
"(",
"self",
",",
"ido",
")",
":",
"self",
".",
"_active_scalar_info",
"=",
"ido",
".",
"active_scalar_info",
"self",
".",
"_active_vectors_info",
"=",
"ido",
".",
"active_vectors_info",
"if",
"hasattr",
"(",
"ido",
",",
"'_textures'",
")",
":",
"self",
".",
"_textures",
"=",
"ido",
".",
"_textures"
] |
Outputs a colorful hexdump of the first argument . | def hexdump ( self , s , * args , * * kwargs ) : levelOverride = kwargs . get ( 'level' ) or self . _lastlevel hexdmp = hexdump . hexdump ( self , s , * * kwargs ) self . _log ( levelOverride , hexdmp , 'indented' , args , kwargs ) | 11,371 | https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/log.py#L143-L163 | [
"def",
"filterNonJournals",
"(",
"citesLst",
",",
"invert",
"=",
"False",
")",
":",
"retCites",
"=",
"[",
"]",
"for",
"c",
"in",
"citesLst",
":",
"if",
"c",
".",
"isJournal",
"(",
")",
":",
"if",
"not",
"invert",
":",
"retCites",
".",
"append",
"(",
"c",
")",
"elif",
"invert",
":",
"retCites",
".",
"append",
"(",
"c",
")",
"return",
"retCites"
] |
Returns the current text for this combobox including the hint option \ if no text is set . | def currentText ( self ) : lineEdit = self . lineEdit ( ) if lineEdit : return lineEdit . currentText ( ) text = nativestring ( super ( XComboBox , self ) . currentText ( ) ) if not text : return self . _hint return text | 11,372 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L142-L153 | [
"def",
"_createConnection",
"(",
"self",
",",
"connections",
")",
":",
"for",
"c",
"in",
"connections",
":",
"# Create GSSHAPY Connection object",
"connection",
"=",
"Connection",
"(",
"slinkNumber",
"=",
"c",
"[",
"'slinkNumber'",
"]",
",",
"upSjuncNumber",
"=",
"c",
"[",
"'upSjunc'",
"]",
",",
"downSjuncNumber",
"=",
"c",
"[",
"'downSjunc'",
"]",
")",
"# Associate Connection with StormPipeNetworkFile",
"connection",
".",
"stormPipeNetworkFile",
"=",
"self"
] |
Displays a custom popup widget for this system if a checkable state \ is setup . | def showPopup ( self ) : if not self . isCheckable ( ) : return super ( XComboBox , self ) . showPopup ( ) if not self . isVisible ( ) : return # update the checkable widget popup point = self . mapToGlobal ( QPoint ( 0 , self . height ( ) - 1 ) ) popup = self . checkablePopup ( ) popup . setModel ( self . model ( ) ) popup . move ( point ) popup . setFixedWidth ( self . width ( ) ) height = ( self . count ( ) * 19 ) + 2 if height > 400 : height = 400 popup . setVerticalScrollBarPolicy ( Qt . ScrollBarAlwaysOn ) else : popup . setVerticalScrollBarPolicy ( Qt . ScrollBarAlwaysOff ) popup . setFixedHeight ( height ) popup . show ( ) popup . raise_ ( ) | 11,373 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L500-L527 | [
"def",
"replace_insight",
"(",
"self",
",",
"project_key",
",",
"insight_id",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"self",
".",
"__build_insight_obj",
"(",
"lambda",
":",
"_swagger",
".",
"InsightPutRequest",
"(",
"title",
"=",
"kwargs",
".",
"get",
"(",
"'title'",
")",
",",
"body",
"=",
"_swagger",
".",
"InsightBody",
"(",
"image_url",
"=",
"kwargs",
".",
"get",
"(",
"'image_url'",
")",
",",
"embed_url",
"=",
"kwargs",
".",
"get",
"(",
"'embed_url'",
")",
",",
"markdown_body",
"=",
"kwargs",
".",
"get",
"(",
"'markdown_body'",
")",
")",
")",
",",
"kwargs",
")",
"project_owner",
",",
"project_id",
"=",
"parse_dataset_key",
"(",
"project_key",
")",
"try",
":",
"self",
".",
"_insights_api",
".",
"replace_insight",
"(",
"project_owner",
",",
"project_id",
",",
"insight_id",
",",
"body",
"=",
"request",
")",
"except",
"_swagger",
".",
"rest",
".",
"ApiException",
"as",
"e",
":",
"raise",
"RestApiError",
"(",
"cause",
"=",
"e",
")"
] |
Updates the items to reflect the current check state system . | def updateCheckState ( self ) : checkable = self . isCheckable ( ) model = self . model ( ) flags = Qt . ItemIsSelectable | Qt . ItemIsEnabled for i in range ( self . count ( ) ) : item = model . item ( i ) if not ( checkable and item . text ( ) ) : item . setCheckable ( False ) item . setFlags ( flags ) # only allow checking for items with text else : item . setCheckable ( True ) item . setFlags ( flags | Qt . ItemIsUserCheckable ) | 11,374 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L529-L547 | [
"def",
"get",
"(",
"self",
",",
"file_lines",
",",
"index",
")",
":",
"line",
"=",
"file_lines",
"[",
"index",
"]",
"start_index",
"=",
"line",
".",
"find",
"(",
"'# '",
")",
"+",
"2",
"# Start index for header text",
"start_tag",
"=",
"line",
".",
"rfind",
"(",
"self",
".",
"_open",
")",
"# Start index of AnchorHub tag",
"end_tag",
"=",
"line",
".",
"rfind",
"(",
"self",
".",
"_close",
")",
"# End index of AnchorHub tag",
"# The magic '+1' below knocks out the hash '#' character from extraction",
"tag",
"=",
"line",
"[",
"start_tag",
"+",
"len",
"(",
"self",
".",
"_open",
")",
"+",
"1",
":",
"end_tag",
"]",
"string",
"=",
"line",
"[",
"start_index",
":",
"start_tag",
"]",
"return",
"[",
"tag",
",",
"string",
"]"
] |
Updates the text in the editor to reflect the latest state . | def updateCheckedText ( self ) : if not self . isCheckable ( ) : return indexes = self . checkedIndexes ( ) items = self . checkedItems ( ) if len ( items ) < 2 or self . separator ( ) : self . lineEdit ( ) . setText ( self . separator ( ) . join ( items ) ) else : self . lineEdit ( ) . setText ( '{0} items selected' . format ( len ( items ) ) ) if not self . signalsBlocked ( ) : self . checkedItemsChanged . emit ( items ) self . checkedIndexesChanged . emit ( indexes ) | 11,375 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L549-L566 | [
"def",
"relay_info",
"(",
"self",
",",
"relay",
",",
"attribute",
"=",
"None",
")",
":",
"# Check if the relay number is valid.",
"if",
"(",
"relay",
"<",
"0",
")",
"or",
"(",
"relay",
">",
"(",
"self",
".",
"num_relays",
"-",
"1",
")",
")",
":",
"# Invalid relay index specified.",
"return",
"None",
"else",
":",
"if",
"attribute",
"is",
"None",
":",
"# Return all the relay attributes.",
"return",
"self",
".",
"relays",
"[",
"relay",
"]",
"else",
":",
"try",
":",
"return",
"self",
".",
"relays",
"[",
"relay",
"]",
"[",
"attribute",
"]",
"except",
"KeyError",
":",
"# Invalid key specified.",
"return",
"None"
] |
Processes metrics . | def process ( self , metrics , config ) : LOG . debug ( "Process called" ) for metric in metrics : metric . tags [ "instance-id" ] = config [ "instance-id" ] return metrics | 11,376 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/examples/processor/tag.py#L34-L55 | [
"def",
"_add_dependency",
"(",
"self",
",",
"dependency",
",",
"var_name",
"=",
"None",
")",
":",
"if",
"var_name",
"is",
"None",
":",
"var_name",
"=",
"next",
"(",
"self",
".",
"temp_var_names",
")",
"# Don't add duplicate dependencies",
"if",
"(",
"dependency",
",",
"var_name",
")",
"not",
"in",
"self",
".",
"dependencies",
":",
"self",
".",
"dependencies",
".",
"append",
"(",
"(",
"dependency",
",",
"var_name",
")",
")",
"return",
"var_name"
] |
Cleanup references to the movie when this button is destroyed . | def cleanup ( self ) : if self . _movie is not None : self . _movie . frameChanged . disconnect ( self . _updateFrame ) self . _movie = None | 11,377 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbutton.py#L121-L127 | [
"def",
"get_lat_lon_time_from_nmea",
"(",
"nmea_file",
",",
"local_time",
"=",
"True",
")",
":",
"with",
"open",
"(",
"nmea_file",
",",
"\"r\"",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"lines",
"=",
"[",
"l",
".",
"rstrip",
"(",
"\"\\n\\r\"",
")",
"for",
"l",
"in",
"lines",
"]",
"# Get initial date",
"for",
"l",
"in",
"lines",
":",
"if",
"\"GPRMC\"",
"in",
"l",
":",
"data",
"=",
"pynmea2",
".",
"parse",
"(",
"l",
")",
"date",
"=",
"data",
".",
"datetime",
".",
"date",
"(",
")",
"break",
"# Parse GPS trace",
"points",
"=",
"[",
"]",
"for",
"l",
"in",
"lines",
":",
"if",
"\"GPRMC\"",
"in",
"l",
":",
"data",
"=",
"pynmea2",
".",
"parse",
"(",
"l",
")",
"date",
"=",
"data",
".",
"datetime",
".",
"date",
"(",
")",
"if",
"\"$GPGGA\"",
"in",
"l",
":",
"data",
"=",
"pynmea2",
".",
"parse",
"(",
"l",
")",
"timestamp",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"date",
",",
"data",
".",
"timestamp",
")",
"lat",
",",
"lon",
",",
"alt",
"=",
"data",
".",
"latitude",
",",
"data",
".",
"longitude",
",",
"data",
".",
"altitude",
"points",
".",
"append",
"(",
"(",
"timestamp",
",",
"lat",
",",
"lon",
",",
"alt",
")",
")",
"points",
".",
"sort",
"(",
")",
"return",
"points"
] |
Overloads the paint even to render this button . | def paintEvent ( self , event ) : if self . isHoverable ( ) and self . icon ( ) . isNull ( ) : return # initialize the painter
painter = QtGui . QStylePainter ( ) painter . begin ( self ) try : option = QtGui . QStyleOptionToolButton ( ) self . initStyleOption ( option ) # generate the scaling and rotating factors
x_scale = 1 y_scale = 1 if self . flipHorizontal ( ) : x_scale = - 1 if self . flipVertical ( ) : y_scale = - 1 center = self . rect ( ) . center ( ) painter . translate ( center . x ( ) , center . y ( ) ) painter . rotate ( self . angle ( ) ) painter . scale ( x_scale , y_scale ) painter . translate ( - center . x ( ) , - center . y ( ) ) painter . drawComplexControl ( QtGui . QStyle . CC_ToolButton , option ) finally : painter . end ( ) | 11,378 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbutton.py#L206-L237 | [
"def",
"metamodel_from_str",
"(",
"lang_desc",
",",
"metamodel",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"metamodel",
":",
"metamodel",
"=",
"TextXMetaModel",
"(",
"*",
"*",
"kwargs",
")",
"language_from_str",
"(",
"lang_desc",
",",
"metamodel",
")",
"return",
"metamodel"
] |
The cli tool as a built - in function . | def converter ( input_string , block_size = 2 ) : sentences = textprocessing . getSentences ( input_string ) blocks = textprocessing . getBlocks ( sentences , block_size ) parse . makeIdentifiers ( blocks ) | 11,379 | https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/__init__.py#L82-L94 | [
"def",
"unbind",
"(",
"self",
",",
"devices_to_unbind",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"url",
"=",
"self",
".",
"base_url",
"+",
"\"api/0.1.0/subscribe/unbind\"",
"headers",
"=",
"{",
"\"apikey\"",
":",
"self",
".",
"entity_api_key",
"}",
"data",
"=",
"{",
"\"exchange\"",
":",
"\"amq.topic\"",
",",
"\"keys\"",
":",
"devices_to_unbind",
",",
"\"queue\"",
":",
"self",
".",
"entity_id",
"}",
"with",
"self",
".",
"no_ssl_verification",
"(",
")",
":",
"r",
"=",
"requests",
".",
"delete",
"(",
"url",
",",
"json",
"=",
"data",
",",
"headers",
"=",
"headers",
")",
"print",
"(",
"r",
")",
"response",
"=",
"dict",
"(",
")",
"if",
"\"No API key\"",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"json",
".",
"loads",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"[",
"'message'",
"]",
"elif",
"'unbind'",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"success\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"else",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"response",
"[",
"\"response\"",
"]",
"=",
"str",
"(",
"r",
")",
"return",
"response"
] |
Copies the selected items to the clipboard . | def copy ( self ) : text = [ ] for item in self . selectedItems ( ) : text . append ( nativestring ( item . text ( ) ) ) QApplication . clipboard ( ) . setText ( ',' . join ( text ) ) | 11,380 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmultitagedit.py#L254-L262 | [
"def",
"ValidateEndConfig",
"(",
"self",
",",
"config_obj",
",",
"errors_fatal",
"=",
"True",
")",
":",
"errors",
"=",
"super",
"(",
"WindowsClientRepacker",
",",
"self",
")",
".",
"ValidateEndConfig",
"(",
"config_obj",
",",
"errors_fatal",
"=",
"errors_fatal",
")",
"install_dir",
"=",
"config_obj",
"[",
"\"Client.install_path\"",
"]",
"for",
"path",
"in",
"config_obj",
"[",
"\"Client.tempdir_roots\"",
"]",
":",
"if",
"path",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Client.tempdir_root %s starts with /, probably has Unix path.\"",
"%",
"path",
")",
"if",
"not",
"path",
".",
"startswith",
"(",
"install_dir",
")",
":",
"errors",
".",
"append",
"(",
"\"Client.tempdir_root %s is not inside the install_dir %s, this is \"",
"\"a security risk\"",
"%",
"(",
"(",
"path",
",",
"install_dir",
")",
")",
")",
"if",
"config_obj",
".",
"Get",
"(",
"\"Logging.path\"",
")",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Logging.path starts with /, probably has Unix path. %s\"",
"%",
"config_obj",
"[",
"\"Logging.path\"",
"]",
")",
"if",
"\"Windows\\\\\"",
"in",
"config_obj",
".",
"GetRaw",
"(",
"\"Logging.path\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Windows in Logging.path, you probably want \"",
"\"%(WINDIR|env) instead\"",
")",
"if",
"not",
"config_obj",
"[",
"\"Client.binary_name\"",
"]",
".",
"endswith",
"(",
"\".exe\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Missing .exe extension on binary_name %s\"",
"%",
"config_obj",
"[",
"\"Client.binary_name\"",
"]",
")",
"if",
"not",
"config_obj",
"[",
"\"Nanny.binary\"",
"]",
".",
"endswith",
"(",
"\".exe\"",
")",
":",
"errors",
".",
"append",
"(",
"\"Missing .exe extension on nanny_binary\"",
")",
"if",
"errors_fatal",
"and",
"errors",
":",
"for",
"error",
"in",
"errors",
":",
"logging",
".",
"error",
"(",
"\"Build Config Error: %s\"",
",",
"error",
")",
"raise",
"RuntimeError",
"(",
"\"Bad configuration generated. Terminating.\"",
")",
"else",
":",
"return",
"errors"
] |
Finishes editing the current item . | def finishEditing ( self , tag ) : curr_item = self . currentItem ( ) create_item = self . createItem ( ) self . closePersistentEditor ( curr_item ) if curr_item == create_item : self . addTag ( tag ) elif self . isTagValid ( tag ) : curr_item . setText ( tag ) | 11,381 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmultitagedit.py#L381-L393 | [
"def",
"get_heat_kernel",
"(",
"network_id",
")",
":",
"url",
"=",
"ndex_relevance",
"+",
"'/%s/generate_ndex_heat_kernel'",
"%",
"network_id",
"res",
"=",
"ndex_client",
".",
"send_request",
"(",
"url",
",",
"{",
"}",
",",
"is_json",
"=",
"True",
",",
"use_get",
"=",
"True",
")",
"if",
"res",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"'Could not get heat kernel for network %s.'",
"%",
"network_id",
")",
"return",
"None",
"kernel_id",
"=",
"res",
".",
"get",
"(",
"'kernel_id'",
")",
"if",
"kernel_id",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"'Could not get heat kernel for network %s.'",
"%",
"network_id",
")",
"return",
"None",
"return",
"kernel_id"
] |
Pastes text from the clipboard . | def paste ( self ) : text = nativestring ( QApplication . clipboard ( ) . text ( ) ) for tag in text . split ( ',' ) : tag = tag . strip ( ) if ( self . isTagValid ( tag ) ) : self . addTag ( tag ) | 11,382 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmultitagedit.py#L585-L593 | [
"def",
"get_owned_subscriptions",
"(",
"self",
",",
"server_id",
")",
":",
"# Validate server_id",
"self",
".",
"_get_server",
"(",
"server_id",
")",
"return",
"list",
"(",
"self",
".",
"_owned_subscriptions",
"[",
"server_id",
"]",
")"
] |
Overloads the resize event to control if we are still editing . If we are resizing then we are no longer editing . | def resizeEvent ( self , event ) : curr_item = self . currentItem ( ) self . closePersistentEditor ( curr_item ) super ( XMultiTagEdit , self ) . resizeEvent ( event ) | 11,383 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmultitagedit.py#L595-L604 | [
"def",
"instance_for_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"model_instance",
"=",
"ModelInstance",
"(",
")",
"for",
"prior_model_tuple",
"in",
"self",
".",
"prior_model_tuples",
":",
"setattr",
"(",
"model_instance",
",",
"prior_model_tuple",
".",
"name",
",",
"prior_model_tuple",
".",
"prior_model",
".",
"instance_for_arguments",
"(",
"arguments",
")",
")",
"return",
"model_instance"
] |
Dispatches the request to the plugins publish method | def Publish ( self , request , context ) : LOG . debug ( "Publish called" ) try : self . plugin . publish ( [ Metric ( pb = m ) for m in request . Metrics ] , ConfigMap ( pb = request . Config ) ) return ErrReply ( ) except Exception as err : msg = "message: {}\n\nstack trace: {}" . format ( err , traceback . format_exc ( ) ) return ErrReply ( error = msg ) | 11,384 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/publisher_proxy.py#L35-L47 | [
"def",
"dump_dict",
"(",
"self",
")",
":",
"dump_dict",
"=",
"dict",
"(",
")",
"dump_dict",
"[",
"'Structure'",
"]",
"=",
"self",
".",
"name",
"# Refer to the __set_format__ method for an explanation",
"# of the following construct.",
"for",
"keys",
"in",
"self",
".",
"__keys__",
":",
"for",
"key",
"in",
"keys",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"key",
")",
"if",
"isinstance",
"(",
"val",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"if",
"key",
"==",
"'TimeDateStamp'",
"or",
"key",
"==",
"'dwTimeStamp'",
":",
"try",
":",
"val",
"=",
"'0x%-8X [%s UTC]'",
"%",
"(",
"val",
",",
"time",
".",
"asctime",
"(",
"time",
".",
"gmtime",
"(",
"val",
")",
")",
")",
"except",
"ValueError",
"as",
"e",
":",
"val",
"=",
"'0x%-8X [INVALID TIME]'",
"%",
"val",
"else",
":",
"val",
"=",
"''",
".",
"join",
"(",
"chr",
"(",
"d",
")",
"if",
"chr",
"(",
"d",
")",
"in",
"string",
".",
"printable",
"else",
"\"\\\\x%02x\"",
"%",
"d",
"for",
"d",
"in",
"[",
"ord",
"(",
"c",
")",
"if",
"not",
"isinstance",
"(",
"c",
",",
"int",
")",
"else",
"c",
"for",
"c",
"in",
"val",
"]",
")",
"dump_dict",
"[",
"key",
"]",
"=",
"{",
"'FileOffset'",
":",
"self",
".",
"__field_offsets__",
"[",
"key",
"]",
"+",
"self",
".",
"__file_offset__",
",",
"'Offset'",
":",
"self",
".",
"__field_offsets__",
"[",
"key",
"]",
",",
"'Value'",
":",
"val",
"}",
"return",
"dump_dict"
] |
Entry point for remove_template . | def main ( ) : # Wrap sys stdout for python 2, so print can understand unicode. if sys . version_info [ 0 ] < 3 : sys . stdout = codecs . getwriter ( "utf-8" ) ( sys . stdout ) options = docopt . docopt ( __doc__ , help = True , version = 'template_remover v%s' % __VERSION__ ) print ( template_remover . clean ( io . open ( options [ 'FILENAME' ] ) . read ( ) ) ) return 0 | 11,385 | https://github.com/deezer/template-remover/blob/de963f221612f57d4982fbc779acd21302c7b817/scripts/remove_template.py#L49-L62 | [
"def",
"store_vector",
"(",
"self",
",",
"v",
",",
"data",
"=",
"None",
")",
":",
"# We will store the normalized vector (used during retrieval)",
"nv",
"=",
"unitvec",
"(",
"v",
")",
"# Store vector in each bucket of all hashes",
"for",
"lshash",
"in",
"self",
".",
"lshashes",
":",
"for",
"bucket_key",
"in",
"lshash",
".",
"hash_vector",
"(",
"v",
")",
":",
"#print 'Storying in bucket %s one vector' % bucket_key",
"self",
".",
"storage",
".",
"store_vector",
"(",
"lshash",
".",
"hash_name",
",",
"bucket_key",
",",
"nv",
",",
"data",
")"
] |
Validates given value against Schema . TYPE_RANGE data type . Raises TypeError or ValueError if something is wrong . Returns None if everything is OK . | def validate_range_value ( value ) : if value == ( None , None ) : return if not hasattr ( value , '__iter__' ) : raise TypeError ( 'Range value must be an iterable, got "%s".' % value ) if not 2 == len ( value ) : raise ValueError ( 'Range value must consist of two elements, got %d.' % len ( value ) ) if not all ( isinstance ( x , ( int , float ) ) for x in value ) : raise TypeError ( 'Range value must consist of two numbers, got "%s" ' 'and "%s" instead.' % value ) if not value [ 0 ] <= value [ 1 ] : raise ValueError ( 'Range must consist of min and max values (min <= ' 'max) but got "%s" and "%s" instead.' % value ) return | 11,386 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/models.py#L357-L377 | [
"def",
"files_comments_add",
"(",
"self",
",",
"*",
",",
"comment",
":",
"str",
",",
"file",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"SlackResponse",
":",
"kwargs",
".",
"update",
"(",
"{",
"\"comment\"",
":",
"comment",
",",
"\"file\"",
":",
"file",
"}",
")",
"return",
"self",
".",
"api_call",
"(",
"\"files.comments.add\"",
",",
"json",
"=",
"kwargs",
")"
] |
Saves given EAV attribute with given value for given entity . | def save_attr ( self , entity , value ) : if self . datatype == self . TYPE_MANY : self . _save_m2m_attr ( entity , value ) else : self . _save_single_attr ( entity , value ) | 11,387 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/models.py#L111-L132 | [
"def",
"from_string",
"(",
"contents",
")",
":",
"if",
"contents",
"[",
"-",
"1",
"]",
"!=",
"\"\\n\"",
":",
"contents",
"+=",
"\"\\n\"",
"white_space",
"=",
"r\"[ \\t\\r\\f\\v]\"",
"natoms_line",
"=",
"white_space",
"+",
"r\"*\\d+\"",
"+",
"white_space",
"+",
"r\"*\\n\"",
"comment_line",
"=",
"r\"[^\\n]*\\n\"",
"coord_lines",
"=",
"r\"(\\s*\\w+\\s+[0-9\\-\\+\\.eEdD]+\\s+[0-9\\-\\+\\.eEdD]+\\s+[0-9\\-\\+\\.eEdD]+\\s*\\n)+\"",
"frame_pattern_text",
"=",
"natoms_line",
"+",
"comment_line",
"+",
"coord_lines",
"pat",
"=",
"re",
".",
"compile",
"(",
"frame_pattern_text",
",",
"re",
".",
"MULTILINE",
")",
"mols",
"=",
"[",
"]",
"for",
"xyz_match",
"in",
"pat",
".",
"finditer",
"(",
"contents",
")",
":",
"xyz_text",
"=",
"xyz_match",
".",
"group",
"(",
"0",
")",
"mols",
".",
"append",
"(",
"XYZ",
".",
"_from_frame_string",
"(",
"xyz_text",
")",
")",
"return",
"XYZ",
"(",
"mols",
")"
] |
Creates or updates an EAV attribute for given entity with given value . | def _save_single_attr ( self , entity , value = None , schema = None , create_nulls = False , extra = { } ) : # If schema is not many-to-one, the value is saved to the corresponding # Attr instance (which is created or updated). schema = schema or self lookups = dict ( get_entity_lookups ( entity ) , schema = schema , * * extra ) try : attr = self . attrs . get ( * * lookups ) except self . attrs . model . DoesNotExist : attr = self . attrs . model ( * * lookups ) if create_nulls or value != attr . value : attr . value = value for k , v in extra . items ( ) : setattr ( attr , k , v ) attr . save ( ) | 11,388 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/models.py#L134-L157 | [
"def",
"read_stream",
"(",
"self",
",",
"file",
":",
"IO",
",",
"data_stream",
":",
"DataStream",
")",
"->",
"Reply",
":",
"yield",
"from",
"data_stream",
".",
"read_file",
"(",
"file",
"=",
"file",
")",
"reply",
"=",
"yield",
"from",
"self",
".",
"_control_stream",
".",
"read_reply",
"(",
")",
"self",
".",
"raise_if_not_match",
"(",
"'End stream'",
",",
"ReplyCodes",
".",
"closing_data_connection",
",",
"reply",
")",
"data_stream",
".",
"close",
"(",
")",
"return",
"reply"
] |
Prompts the user to select a color for this button . | def pickColor ( self ) : color = QColorDialog . getColor ( self . color ( ) , self ) if ( color . isValid ( ) ) : self . setColor ( color ) | 11,389 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcolorbutton.py#L49-L56 | [
"def",
"isNonNegative",
"(",
"matrix",
")",
":",
"try",
":",
"if",
"(",
"matrix",
">=",
"0",
")",
".",
"all",
"(",
")",
":",
"return",
"True",
"except",
"(",
"NotImplementedError",
",",
"AttributeError",
",",
"TypeError",
")",
":",
"try",
":",
"if",
"(",
"matrix",
".",
"data",
">=",
"0",
")",
".",
"all",
"(",
")",
":",
"return",
"True",
"except",
"AttributeError",
":",
"matrix",
"=",
"_np",
".",
"array",
"(",
"matrix",
")",
"if",
"(",
"matrix",
".",
"data",
">=",
"0",
")",
".",
"all",
"(",
")",
":",
"return",
"True",
"return",
"False"
] |
get adapter data by its id . | def by_id ( self , id ) : path = partial ( _path , self . adapter ) path = path ( id ) return self . _get ( path ) | 11,390 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L19-L23 | [
"def",
"reset",
"(",
"self",
")",
":",
"# Reset Union Temporal Pooler fields",
"self",
".",
"_poolingActivation",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
"self",
".",
"_unionSDR",
"=",
"numpy",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"UINT_DTYPE",
")",
"self",
".",
"_poolingTimer",
"=",
"numpy",
".",
"ones",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
"*",
"1000",
"self",
".",
"_poolingActivationInitLevel",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
"self",
".",
"_preActiveInput",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumInputs",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
"self",
".",
"_prePredictedActiveInput",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"self",
".",
"getNumInputs",
"(",
")",
",",
"self",
".",
"_historyLength",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
"# Reset Spatial Pooler fields",
"self",
".",
"setOverlapDutyCycles",
"(",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
")",
"self",
".",
"setActiveDutyCycles",
"(",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
")",
"self",
".",
"setMinOverlapDutyCycles",
"(",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
")",
"self",
".",
"setBoostFactors",
"(",
"numpy",
".",
"ones",
"(",
"self",
".",
"getNumColumns",
"(",
")",
",",
"dtype",
"=",
"REAL_DTYPE",
")",
")"
] |
get adapter data by name . | def by_name ( self , name , archived = False , limit = None , page = None ) : if not archived : path = _path ( self . adapter ) else : path = _path ( self . adapter , 'archived' ) return self . _get ( path , name = name , limit = limit , page = page ) | 11,391 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L25-L31 | [
"def",
"_get_initial_request",
"(",
"self",
")",
":",
"# Any ack IDs that are under lease management need to have their",
"# deadline extended immediately.",
"if",
"self",
".",
"_leaser",
"is",
"not",
"None",
":",
"# Explicitly copy the list, as it could be modified by another",
"# thread.",
"lease_ids",
"=",
"list",
"(",
"self",
".",
"_leaser",
".",
"ack_ids",
")",
"else",
":",
"lease_ids",
"=",
"[",
"]",
"# Put the request together.",
"request",
"=",
"types",
".",
"StreamingPullRequest",
"(",
"modify_deadline_ack_ids",
"=",
"list",
"(",
"lease_ids",
")",
",",
"modify_deadline_seconds",
"=",
"[",
"self",
".",
"ack_deadline",
"]",
"*",
"len",
"(",
"lease_ids",
")",
",",
"stream_ack_deadline_seconds",
"=",
"self",
".",
"ack_histogram",
".",
"percentile",
"(",
"99",
")",
",",
"subscription",
"=",
"self",
".",
"_subscription",
",",
")",
"# Return the initial request.",
"return",
"request"
] |
get all adapter data . | def all ( self , archived = False , limit = None , page = None ) : path = partial ( _path , self . adapter ) if not archived : path = _path ( self . adapter ) else : path = _path ( self . adapter , 'archived' ) return self . _get ( path , limit = limit , page = page ) | 11,392 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L33-L40 | [
"def",
"create",
"(",
"url",
",",
"filename",
",",
"properties",
")",
":",
"# Ensure that the file has valid suffix",
"if",
"not",
"has_tar_suffix",
"(",
"filename",
")",
":",
"raise",
"ValueError",
"(",
"'invalid file suffix: '",
"+",
"filename",
")",
"# Upload file to create subject. If response is not 201 the uploaded",
"# file is not a valid FreeSurfer archive",
"files",
"=",
"{",
"'file'",
":",
"open",
"(",
"filename",
",",
"'rb'",
")",
"}",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"files",
"=",
"files",
")",
"if",
"response",
".",
"status_code",
"!=",
"201",
":",
"raise",
"ValueError",
"(",
"'invalid file: '",
"+",
"filename",
")",
"# Get image group HATEOAS references from successful response",
"links",
"=",
"references_to_dict",
"(",
"response",
".",
"json",
"(",
")",
"[",
"'links'",
"]",
")",
"resource_url",
"=",
"links",
"[",
"REF_SELF",
"]",
"# Update subject properties if given",
"if",
"not",
"properties",
"is",
"None",
":",
"obj_props",
"=",
"[",
"]",
"# Catch TypeErrors if properties is not a list.",
"try",
":",
"for",
"key",
"in",
"properties",
":",
"obj_props",
".",
"append",
"(",
"{",
"'key'",
":",
"key",
",",
"'value'",
":",
"properties",
"[",
"key",
"]",
"}",
")",
"except",
"TypeError",
"as",
"ex",
":",
"raise",
"ValueError",
"(",
"'invalid property set'",
")",
"try",
":",
"req",
"=",
"urllib2",
".",
"Request",
"(",
"links",
"[",
"REF_UPSERT_PROPERTIES",
"]",
")",
"req",
".",
"add_header",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
"response",
"=",
"urllib2",
".",
"urlopen",
"(",
"req",
",",
"json",
".",
"dumps",
"(",
"{",
"'properties'",
":",
"obj_props",
"}",
")",
")",
"except",
"urllib2",
".",
"URLError",
"as",
"ex",
":",
"raise",
"ValueError",
"(",
"str",
"(",
"ex",
")",
")",
"return",
"resource_url"
] |
return a project by it s name . this only works with the exact name of the project . | def by_name ( self , name , archived = False , limit = None , page = None ) : # this only works with the exact name return super ( Projects , self ) . by_name ( name , archived = archived , limit = limit , page = page ) | 11,393 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L56-L62 | [
"def",
"_start_update_server",
"(",
"auth_token",
")",
":",
"server",
"=",
"AccumulatorServer",
"(",
"(",
"\"localhost\"",
",",
"0",
")",
",",
"_UpdateRequestHandler",
",",
"auth_token",
")",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"server",
".",
"serve_forever",
")",
"thread",
".",
"daemon",
"=",
"True",
"thread",
".",
"start",
"(",
")",
"return",
"server"
] |
delete a time entry . | def delete ( self , id ) : path = partial ( _path , self . adapter ) path = path ( id ) return self . _delete ( path ) | 11,394 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L212-L216 | [
"def",
"delete",
"(",
"self",
",",
"msg",
",",
"claim_id",
"=",
"None",
")",
":",
"msg_id",
"=",
"utils",
".",
"get_id",
"(",
"msg",
")",
"if",
"claim_id",
":",
"uri",
"=",
"\"/%s/%s?claim_id=%s\"",
"%",
"(",
"self",
".",
"uri_base",
",",
"msg_id",
",",
"claim_id",
")",
"else",
":",
"uri",
"=",
"\"/%s/%s\"",
"%",
"(",
"self",
".",
"uri_base",
",",
"msg_id",
")",
"return",
"self",
".",
"_delete",
"(",
"uri",
")"
] |
time entries by year month and day . | def at ( self , year , month , day ) : path = partial ( _path , self . adapter ) path = partial ( path , int ( year ) ) path = partial ( path , int ( month ) ) path = path ( int ( day ) ) return self . _get ( path ) | 11,395 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L226-L232 | [
"def",
"server_close",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Closing the socket server connection.\"",
")",
"TCPServer",
".",
"server_close",
"(",
"self",
")",
"self",
".",
"queue_manager",
".",
"close",
"(",
")",
"self",
".",
"topic_manager",
".",
"close",
"(",
")",
"if",
"hasattr",
"(",
"self",
".",
"authenticator",
",",
"'close'",
")",
":",
"self",
".",
"authenticator",
".",
"close",
"(",
")",
"self",
".",
"shutdown",
"(",
")"
] |
start a specific tracker . | def start ( self , id ) : path = partial ( _path , self . adapter ) path = path ( id ) return self . _put ( path ) | 11,396 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L254-L258 | [
"def",
"compose",
"(",
"list_of_files",
",",
"destination_file",
",",
"files_metadata",
"=",
"None",
",",
"content_type",
"=",
"None",
",",
"retry_params",
"=",
"None",
",",
"_account_id",
"=",
"None",
")",
":",
"api",
"=",
"storage_api",
".",
"_get_storage_api",
"(",
"retry_params",
"=",
"retry_params",
",",
"account_id",
"=",
"_account_id",
")",
"if",
"os",
".",
"getenv",
"(",
"'SERVER_SOFTWARE'",
")",
".",
"startswith",
"(",
"'Dev'",
")",
":",
"def",
"_temp_func",
"(",
"file_list",
",",
"destination_file",
",",
"content_type",
")",
":",
"bucket",
"=",
"'/'",
"+",
"destination_file",
".",
"split",
"(",
"'/'",
")",
"[",
"1",
"]",
"+",
"'/'",
"with",
"open",
"(",
"destination_file",
",",
"'w'",
",",
"content_type",
"=",
"content_type",
")",
"as",
"gcs_merge",
":",
"for",
"source_file",
"in",
"file_list",
":",
"with",
"open",
"(",
"bucket",
"+",
"source_file",
"[",
"'Name'",
"]",
",",
"'r'",
")",
"as",
"gcs_source",
":",
"gcs_merge",
".",
"write",
"(",
"gcs_source",
".",
"read",
"(",
")",
")",
"compose_object",
"=",
"_temp_func",
"else",
":",
"compose_object",
"=",
"api",
".",
"compose_object",
"file_list",
",",
"_",
"=",
"_validate_compose_list",
"(",
"destination_file",
",",
"list_of_files",
",",
"files_metadata",
",",
"32",
")",
"compose_object",
"(",
"file_list",
",",
"destination_file",
",",
"content_type",
")"
] |
stop the tracker . | def stop ( self , id ) : path = partial ( _path , self . adapter ) path = path ( id ) return self . _delete ( path ) | 11,397 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L261-L265 | [
"def",
"thaw",
"(",
"vault_client",
",",
"src_file",
",",
"opt",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"src_file",
")",
":",
"raise",
"aomi",
".",
"exceptions",
".",
"AomiFile",
"(",
"\"%s does not exist\"",
"%",
"src_file",
")",
"tmp_dir",
"=",
"ensure_tmpdir",
"(",
")",
"zip_file",
"=",
"thaw_decrypt",
"(",
"vault_client",
",",
"src_file",
",",
"tmp_dir",
",",
"opt",
")",
"archive",
"=",
"zipfile",
".",
"ZipFile",
"(",
"zip_file",
",",
"'r'",
")",
"for",
"archive_file",
"in",
"archive",
".",
"namelist",
"(",
")",
":",
"archive",
".",
"extract",
"(",
"archive_file",
",",
"tmp_dir",
")",
"os",
".",
"chmod",
"(",
"\"%s/%s\"",
"%",
"(",
"tmp_dir",
",",
"archive_file",
")",
",",
"0o640",
")",
"LOG",
".",
"debug",
"(",
"\"Extracted %s from archive\"",
",",
"archive_file",
")",
"LOG",
".",
"info",
"(",
"\"Thawing secrets into %s\"",
",",
"opt",
".",
"secrets",
")",
"config",
"=",
"get_secretfile",
"(",
"opt",
")",
"Context",
".",
"load",
"(",
"config",
",",
"opt",
")",
".",
"thaw",
"(",
"tmp_dir",
")"
] |
Clears out all of the rollout items from the widget . | def clear ( self ) : self . blockSignals ( True ) self . setUpdatesEnabled ( False ) for child in self . findChildren ( XRolloutItem ) : child . setParent ( None ) child . deleteLater ( ) self . setUpdatesEnabled ( True ) self . blockSignals ( False ) | 11,398 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xrolloutwidget.py#L229-L239 | [
"def",
"_init_libcrypto",
"(",
")",
":",
"libcrypto",
"=",
"_load_libcrypto",
"(",
")",
"try",
":",
"libcrypto",
".",
"OPENSSL_init_crypto",
"(",
")",
"except",
"AttributeError",
":",
"# Support for OpenSSL < 1.1 (OPENSSL_API_COMPAT < 0x10100000L)",
"libcrypto",
".",
"OPENSSL_no_config",
"(",
")",
"libcrypto",
".",
"OPENSSL_add_all_algorithms_noconf",
"(",
")",
"libcrypto",
".",
"RSA_new",
".",
"argtypes",
"=",
"(",
")",
"libcrypto",
".",
"RSA_new",
".",
"restype",
"=",
"c_void_p",
"libcrypto",
".",
"RSA_free",
".",
"argtypes",
"=",
"(",
"c_void_p",
",",
")",
"libcrypto",
".",
"RSA_size",
".",
"argtype",
"=",
"(",
"c_void_p",
")",
"libcrypto",
".",
"BIO_new_mem_buf",
".",
"argtypes",
"=",
"(",
"c_char_p",
",",
"c_int",
")",
"libcrypto",
".",
"BIO_new_mem_buf",
".",
"restype",
"=",
"c_void_p",
"libcrypto",
".",
"BIO_free",
".",
"argtypes",
"=",
"(",
"c_void_p",
",",
")",
"libcrypto",
".",
"PEM_read_bio_RSAPrivateKey",
".",
"argtypes",
"=",
"(",
"c_void_p",
",",
"c_void_p",
",",
"c_void_p",
",",
"c_void_p",
")",
"libcrypto",
".",
"PEM_read_bio_RSAPrivateKey",
".",
"restype",
"=",
"c_void_p",
"libcrypto",
".",
"PEM_read_bio_RSA_PUBKEY",
".",
"argtypes",
"=",
"(",
"c_void_p",
",",
"c_void_p",
",",
"c_void_p",
",",
"c_void_p",
")",
"libcrypto",
".",
"PEM_read_bio_RSA_PUBKEY",
".",
"restype",
"=",
"c_void_p",
"libcrypto",
".",
"RSA_private_encrypt",
".",
"argtypes",
"=",
"(",
"c_int",
",",
"c_char_p",
",",
"c_char_p",
",",
"c_void_p",
",",
"c_int",
")",
"libcrypto",
".",
"RSA_public_decrypt",
".",
"argtypes",
"=",
"(",
"c_int",
",",
"c_char_p",
",",
"c_char_p",
",",
"c_void_p",
",",
"c_int",
")",
"return",
"libcrypto"
] |
Returns the minimum height that will be required based on this font size and labels list . | def minimumLabelHeight ( self ) : metrics = QFontMetrics ( self . labelFont ( ) ) return max ( self . _minimumLabelHeight , metrics . height ( ) + self . verticalLabelPadding ( ) ) | 11,399 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartaxis.py#L191-L198 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_timer",
".",
"isActive",
"(",
")",
":",
"return",
"self",
".",
"_elapsed",
"+=",
"self",
".",
"_delta",
"self",
".",
"_timer",
".",
"stop",
"(",
")"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.