query stringlengths 5 1.23k | positive stringlengths 53 15.2k | id_ int64 0 252k | task_name stringlengths 87 242 | negative listlengths 20 553 |
|---|---|---|---|---|
Refreshes the button for this toolbar . | def refreshButton ( self ) : collapsed = self . isCollapsed ( ) btn = self . _collapseButton if not btn : return btn . setMaximumSize ( MAX_SIZE , MAX_SIZE ) # set up a vertical scrollbar if self . orientation ( ) == Qt . Vertical : btn . setMaximumHeight ( 12 ) else : btn . setMaximumWidth ( 12 ) icon = '' # collapse/expand a vertical toolbar if self . orientation ( ) == Qt . Vertical : if collapsed : self . setFixedWidth ( self . _collapsedSize ) btn . setMaximumHeight ( MAX_SIZE ) btn . setArrowType ( Qt . RightArrow ) else : self . setMaximumWidth ( MAX_SIZE ) self . _precollapseSize = None btn . setMaximumHeight ( 12 ) btn . setArrowType ( Qt . LeftArrow ) else : if collapsed : self . setFixedHeight ( self . _collapsedSize ) btn . setMaximumWidth ( MAX_SIZE ) btn . setArrowType ( Qt . DownArrow ) else : self . setMaximumHeight ( 1000 ) self . _precollapseSize = None btn . setMaximumWidth ( 12 ) btn . setArrowType ( Qt . UpArrow ) for index in range ( 1 , self . layout ( ) . count ( ) ) : item = self . layout ( ) . itemAt ( index ) if not item . widget ( ) : continue if collapsed : item . widget ( ) . setMaximumSize ( 0 , 0 ) else : item . widget ( ) . setMaximumSize ( MAX_SIZE , MAX_SIZE ) if not self . isCollapsable ( ) : btn . hide ( ) else : btn . show ( ) | 10,900 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtoolbar.py#L138-L194 | [
"def",
"remove_stale_javascripts",
"(",
"portal",
")",
":",
"logger",
".",
"info",
"(",
"\"Removing stale javascripts ...\"",
")",
"for",
"js",
"in",
"JAVASCRIPTS_TO_REMOVE",
":",
"logger",
".",
"info",
"(",
"\"Unregistering JS %s\"",
"%",
"js",
")",
"portal",
".",
"portal_javascripts",
".",
"unregisterResource",
"(",
"js",
")"
] |
Return a list of all active Messages which match the given URL . | def match ( self , url ) : return list ( { message for message in self . active ( ) if message . is_global or message . match ( url ) } ) | 10,901 | https://github.com/ubernostrum/django-soapbox/blob/f9189e1ddf47175f2392b92c7a0a902817ee1e93/soapbox/models.py#L36-L45 | [
"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"
] |
Draws this item with the inputed painter . This will call the scene s renderer to draw this item . | def paint ( self , painter , option , widget ) : scene = self . scene ( ) if not scene : return scene . chart ( ) . renderer ( ) . drawItem ( self , painter , option ) | 10,902 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartdatasetitem.py#L78-L87 | [
"def",
"Process",
"(",
"self",
",",
"parser_mediator",
",",
"registry_key",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"registry_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Windows Registry key is not set.'",
")",
"# This will raise if unhandled keyword arguments are passed.",
"super",
"(",
"WindowsRegistryPlugin",
",",
"self",
")",
".",
"Process",
"(",
"parser_mediator",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"ExtractEvents",
"(",
"parser_mediator",
",",
"registry_key",
",",
"*",
"*",
"kwargs",
")"
] |
Some queries have different syntax depending what version of postgres we are querying against . | def is_pg_at_least_nine_two ( self ) : if self . _is_pg_at_least_nine_two is None : results = self . version ( ) regex = re . compile ( "PostgreSQL (\d+\.\d+\.\d+) on" ) matches = regex . match ( results [ 0 ] . version ) version = matches . groups ( ) [ 0 ] if version > '9.2.0' : self . _is_pg_at_least_nine_two = True else : self . _is_pg_at_least_nine_two = False return self . _is_pg_at_least_nine_two | 10,903 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L104-L123 | [
"def",
"loadSharedResource",
"(",
"self",
",",
"pchResourceName",
",",
"pchBuffer",
",",
"unBufferLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"loadSharedResource",
"result",
"=",
"fn",
"(",
"pchResourceName",
",",
"pchBuffer",
",",
"unBufferLen",
")",
"return",
"result"
] |
Execute the given sql statement . | def execute ( self , statement ) : # Make the sql statement easier to read in case some of the queries we # run end up in the output sql = statement . replace ( '\n' , '' ) sql = ' ' . join ( sql . split ( ) ) self . cursor . execute ( sql ) return self . cursor . fetchall ( ) | 10,904 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L132-L146 | [
"def",
"pivot_wavelength",
"(",
"self",
")",
":",
"wl",
"=",
"self",
".",
"registry",
".",
"_pivot_wavelengths",
".",
"get",
"(",
"(",
"self",
".",
"telescope",
",",
"self",
".",
"band",
")",
")",
"if",
"wl",
"is",
"not",
"None",
":",
"return",
"wl",
"wl",
"=",
"self",
".",
"calc_pivot_wavelength",
"(",
")",
"self",
".",
"registry",
".",
"register_pivot_wavelength",
"(",
"self",
".",
"telescope",
",",
"self",
".",
"band",
",",
"wl",
")",
"return",
"wl"
] |
Show 10 most frequently called queries . Requires the pg_stat_statements Postgres module to be installed . | def calls ( self , truncate = False ) : if self . pg_stat_statement ( ) : if truncate : select = """
SELECT CASE
WHEN length(query) < 40
THEN query
ELSE substr(query, 0, 38) || '..'
END AS qry,
""" else : select = 'SELECT query,' return self . execute ( sql . CALLS . format ( select = select ) ) else : return [ self . get_missing_pg_stat_statement_error ( ) ] | 10,905 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L177-L208 | [
"def",
"reset",
"(",
"self",
",",
"relation_name",
"=",
"None",
")",
":",
"if",
"relation_name",
"is",
"not",
"None",
":",
"self",
".",
"data_access",
".",
"delete",
"(",
"\"relations\"",
",",
"dict",
"(",
"name",
"=",
"relation_name",
")",
")",
"else",
":",
"self",
".",
"data_access",
".",
"delete",
"(",
"\"relations\"",
",",
"\"1=1\"",
")",
"return",
"self"
] |
Display queries holding locks other queries are waiting to be released . | def blocking ( self ) : return self . execute ( sql . BLOCKING . format ( query_column = self . query_column , pid_column = self . pid_column ) ) | 10,906 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L210-L231 | [
"def",
"generate_config_index",
"(",
"defaults",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
",",
"base_dir",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Path",
"]",
":",
"base",
"=",
"Path",
"(",
"base_dir",
")",
"if",
"base_dir",
"else",
"infer_config_base_dir",
"(",
")",
"def",
"parse_or_default",
"(",
"ce",
":",
"ConfigElement",
",",
"val",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Path",
":",
"if",
"not",
"val",
":",
"return",
"base",
"/",
"Path",
"(",
"ce",
".",
"default",
")",
"else",
":",
"return",
"Path",
"(",
"val",
")",
"return",
"{",
"ce",
".",
"name",
":",
"parse_or_default",
"(",
"ce",
",",
"defaults",
".",
"get",
"(",
"ce",
".",
"name",
")",
")",
"for",
"ce",
"in",
"CONFIG_ELEMENTS",
"}"
] |
Show 10 queries that have longest execution time in aggregate . Requires the pg_stat_statments Postgres module to be installed . | def outliers ( self , truncate = False ) : if self . pg_stat_statement ( ) : if truncate : query = """
CASE WHEN length(query) < 40
THEN query
ELSE substr(query, 0, 38) || '..'
END
""" else : query = 'query' return self . execute ( sql . OUTLIERS . format ( query = query ) ) else : return [ self . get_missing_pg_stat_statement_error ( ) ] | 10,907 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L233-L263 | [
"def",
"unshare",
"(",
"flags",
")",
":",
"res",
"=",
"lib",
".",
"unshare",
"(",
"flags",
")",
"if",
"res",
"!=",
"0",
":",
"_check_error",
"(",
"ffi",
".",
"errno",
")"
] |
Show all queries longer than five minutes by descending duration . | def long_running_queries ( self ) : if self . is_pg_at_least_nine_two ( ) : idle = "AND state <> 'idle'" else : idle = "AND current_query <> '<IDLE>'" return self . execute ( sql . LONG_RUNNING_QUERIES . format ( pid_column = self . pid_column , query_column = self . query_column , idle = idle ) ) | 10,908 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L303-L327 | [
"def",
"load_version",
"(",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"\"cpt\"",
",",
"\"__init__.py\"",
")",
")",
"with",
"open",
"(",
"filename",
",",
"\"rt\"",
")",
"as",
"version_file",
":",
"conan_init",
"=",
"version_file",
".",
"read",
"(",
")",
"version",
"=",
"re",
".",
"search",
"(",
"\"__version__ = '([0-9a-z.-]+)'\"",
",",
"conan_init",
")",
".",
"group",
"(",
"1",
")",
"return",
"version"
] |
Display queries with active locks . | def locks ( self ) : return self . execute ( sql . LOCKS . format ( pid_column = self . pid_column , query_column = self . query_column ) ) | 10,909 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L422-L443 | [
"def",
"from_csv",
"(",
"col",
",",
"schema",
",",
"options",
"=",
"{",
"}",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"schema",
",",
"basestring",
")",
":",
"schema",
"=",
"_create_column_from_literal",
"(",
"schema",
")",
"elif",
"isinstance",
"(",
"schema",
",",
"Column",
")",
":",
"schema",
"=",
"_to_java_column",
"(",
"schema",
")",
"else",
":",
"raise",
"TypeError",
"(",
"\"schema argument should be a column or string\"",
")",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"from_csv",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"schema",
",",
"options",
")",
"return",
"Column",
"(",
"jc",
")"
] |
View active queries with execution time . | def ps ( self ) : if self . is_pg_at_least_nine_two ( ) : idle = "AND state <> 'idle'" else : idle = "AND current_query <> '<IDLE>'" return self . execute ( sql . PS . format ( pid_column = self . pid_column , query_column = self . query_column , idle = idle ) ) | 10,910 | https://github.com/scottwoodall/python-pgextras/blob/d3aa83081d41b14b7c1f003cd837c812a2b5fff5/pgextras/__init__.py#L460-L486 | [
"def",
"pin_update",
"(",
"self",
",",
"from_path",
",",
"to_path",
",",
"*",
"*",
"kwargs",
")",
":",
"#PY2: No support for kw-only parameters after glob parameters",
"if",
"\"unpin\"",
"in",
"kwargs",
":",
"kwargs",
".",
"setdefault",
"(",
"\"opts\"",
",",
"{",
"\"unpin\"",
":",
"kwargs",
"[",
"\"unpin\"",
"]",
"}",
")",
"del",
"kwargs",
"[",
"\"unpin\"",
"]",
"args",
"=",
"(",
"from_path",
",",
"to_path",
")",
"return",
"self",
".",
"_client",
".",
"request",
"(",
"'/pin/update'",
",",
"args",
",",
"decoder",
"=",
"'json'",
",",
"*",
"*",
"kwargs",
")"
] |
Publishes metrics to a file in JSON format . | def publish ( self , metrics , config ) : if len ( metrics ) > 0 : with open ( config [ "file" ] , 'a' ) as outfile : for metric in metrics : outfile . write ( json_format . MessageToJson ( metric . _pb , including_default_value_fields = True ) ) | 10,911 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/examples/publisher/file.py#L37-L59 | [
"def",
"old",
"(",
"self",
")",
":",
"ori",
"=",
"self",
".",
"original",
".",
"action",
"if",
"isinstance",
"(",
"ori",
",",
"(",
"types",
".",
"ChannelAdminLogEventActionChangeAbout",
",",
"types",
".",
"ChannelAdminLogEventActionChangeTitle",
",",
"types",
".",
"ChannelAdminLogEventActionChangeUsername",
")",
")",
":",
"return",
"ori",
".",
"prev_value",
"elif",
"isinstance",
"(",
"ori",
",",
"types",
".",
"ChannelAdminLogEventActionChangePhoto",
")",
":",
"return",
"ori",
".",
"prev_photo",
"elif",
"isinstance",
"(",
"ori",
",",
"types",
".",
"ChannelAdminLogEventActionChangeStickerSet",
")",
":",
"return",
"ori",
".",
"prev_stickerset",
"elif",
"isinstance",
"(",
"ori",
",",
"types",
".",
"ChannelAdminLogEventActionEditMessage",
")",
":",
"return",
"ori",
".",
"prev_message",
"elif",
"isinstance",
"(",
"ori",
",",
"(",
"types",
".",
"ChannelAdminLogEventActionParticipantToggleAdmin",
",",
"types",
".",
"ChannelAdminLogEventActionParticipantToggleBan",
")",
")",
":",
"return",
"ori",
".",
"prev_participant",
"elif",
"isinstance",
"(",
"ori",
",",
"(",
"types",
".",
"ChannelAdminLogEventActionToggleInvites",
",",
"types",
".",
"ChannelAdminLogEventActionTogglePreHistoryHidden",
",",
"types",
".",
"ChannelAdminLogEventActionToggleSignatures",
")",
")",
":",
"return",
"not",
"ori",
".",
"new_value",
"elif",
"isinstance",
"(",
"ori",
",",
"types",
".",
"ChannelAdminLogEventActionDeleteMessage",
")",
":",
"return",
"ori",
".",
"message",
"elif",
"isinstance",
"(",
"ori",
",",
"types",
".",
"ChannelAdminLogEventActionDefaultBannedRights",
")",
":",
"return",
"ori",
".",
"prev_banned_rights"
] |
Avoid name clashes between static and dynamic attributes . | def clean_name ( self ) : name = self . cleaned_data [ 'name' ] reserved_names = self . _meta . model . _meta . get_all_field_names ( ) if name not in reserved_names : return name raise ValidationError ( _ ( 'Attribute name must not clash with reserved names' ' ("%s")' ) % '", "' . join ( reserved_names ) ) | 10,912 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/forms.py#L40-L47 | [
"def",
"_add_supplemental_bams",
"(",
"data",
")",
":",
"file_key",
"=",
"\"work_bam\"",
"if",
"data",
".",
"get",
"(",
"file_key",
")",
":",
"for",
"supext",
"in",
"[",
"\"disc\"",
",",
"\"sr\"",
"]",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"data",
"[",
"file_key",
"]",
")",
"test_file",
"=",
"\"%s-%s%s\"",
"%",
"(",
"base",
",",
"supext",
",",
"ext",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"test_file",
")",
":",
"sup_key",
"=",
"file_key",
"+",
"\"_plus\"",
"if",
"sup_key",
"not",
"in",
"data",
":",
"data",
"[",
"sup_key",
"]",
"=",
"{",
"}",
"data",
"[",
"sup_key",
"]",
"[",
"supext",
"]",
"=",
"test_file",
"return",
"data"
] |
Saves this form s cleaned_data into model instance self . instance and related EAV attributes . | def save ( self , commit = True ) : if self . errors : raise ValueError ( "The %s could not be saved because the data didn't" " validate." % self . instance . _meta . object_name ) # create entity instance, don't save yet instance = super ( BaseDynamicEntityForm , self ) . save ( commit = False ) # assign attributes for name in instance . get_schema_names ( ) : value = self . cleaned_data . get ( name ) setattr ( instance , name , value ) # save entity and its attributes if commit : instance . save ( ) return instance | 10,913 | https://github.com/neithere/eav-django/blob/7f2e9fe17bbe740622cfb38f6ce0e8413b7da3d7/eav/forms.py#L122-L146 | [
"def",
"click_download",
"(",
"self",
",",
"event",
")",
":",
"args",
"[",
"'parallel'",
"]",
"=",
"self",
".",
"p",
".",
"get",
"(",
")",
"args",
"[",
"'file_type'",
"]",
"=",
"self",
".",
"optionmenu",
".",
"get",
"(",
")",
"args",
"[",
"'no_redirects'",
"]",
"=",
"self",
".",
"t",
".",
"get",
"(",
")",
"args",
"[",
"'query'",
"]",
"=",
"self",
".",
"entry_query",
".",
"get",
"(",
")",
"args",
"[",
"'min_file_size'",
"]",
"=",
"int",
"(",
"self",
".",
"entry_min",
".",
"get",
"(",
")",
")",
"args",
"[",
"'max_file_size'",
"]",
"=",
"int",
"(",
"self",
".",
"entry_max",
".",
"get",
"(",
")",
")",
"args",
"[",
"'limit'",
"]",
"=",
"int",
"(",
"self",
".",
"entry_limit",
".",
"get",
"(",
")",
")",
"args",
"[",
"'website'",
"]",
"=",
"self",
".",
"entry_website",
".",
"get",
"(",
")",
"args",
"[",
"'option'",
"]",
"=",
"self",
".",
"engine",
".",
"get",
"(",
")",
"print",
"(",
"args",
")",
"self",
".",
"check_threat",
"(",
")",
"download_content_gui",
"(",
"*",
"*",
"args",
")"
] |
Refreshes the contents of the completer based on the current text . | def refresh ( self ) : table = self . tableType ( ) search = nativestring ( self . _pywidget . text ( ) ) if search == self . _lastSearch : return self . _lastSearch = search if not search : return if search in self . _cache : records = self . _cache [ search ] else : records = table . select ( where = self . baseQuery ( ) , order = self . order ( ) ) records = list ( records . search ( search , limit = self . limit ( ) ) ) self . _cache [ search ] = records self . _records = records self . model ( ) . setStringList ( map ( str , self . _records ) ) self . complete ( ) | 10,914 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/completers/xorbsearchcompleter.py#L130-L153 | [
"def",
"require_session",
"(",
"handler",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"handler",
")",
"async",
"def",
"decorated",
"(",
"request",
":",
"web",
".",
"Request",
")",
"->",
"web",
".",
"Response",
":",
"request_session_token",
"=",
"request",
".",
"match_info",
"[",
"'session'",
"]",
"session",
"=",
"session_from_request",
"(",
"request",
")",
"if",
"not",
"session",
"or",
"request_session_token",
"!=",
"session",
".",
"token",
":",
"LOG",
".",
"warning",
"(",
"f\"request for invalid session {request_session_token}\"",
")",
"return",
"web",
".",
"json_response",
"(",
"data",
"=",
"{",
"'error'",
":",
"'bad-token'",
",",
"'message'",
":",
"f'No such session {request_session_token}'",
"}",
",",
"status",
"=",
"404",
")",
"return",
"await",
"handler",
"(",
"request",
",",
"session",
")",
"return",
"decorated"
] |
Initializes the view if it is visible or being loaded . | def initialize ( self , force = False ) : if force or ( self . isVisible ( ) and not self . isInitialized ( ) and not self . signalsBlocked ( ) ) : self . _initialized = True self . initialized . emit ( ) | 10,915 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xview.py#L321-L330 | [
"def",
"_get_params",
"(",
"self",
",",
"validator_parameter",
",",
"name_prefix",
")",
":",
"params_validator",
"=",
"self",
".",
"request",
".",
"get",
"(",
"validator_parameter",
")",
"user_params",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"request",
".",
"arguments",
"(",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"name_prefix",
")",
":",
"values",
"=",
"self",
".",
"request",
".",
"get_all",
"(",
"key",
")",
"adjusted_key",
"=",
"key",
"[",
"len",
"(",
"name_prefix",
")",
":",
"]",
"if",
"len",
"(",
"values",
")",
"==",
"1",
":",
"user_params",
"[",
"adjusted_key",
"]",
"=",
"values",
"[",
"0",
"]",
"else",
":",
"user_params",
"[",
"adjusted_key",
"]",
"=",
"values",
"if",
"params_validator",
":",
"resolved_validator",
"=",
"util",
".",
"for_name",
"(",
"params_validator",
")",
"resolved_validator",
"(",
"user_params",
")",
"return",
"user_params"
] |
Destroys the singleton instance of this class if one exists . | def destroySingleton ( cls ) : singleton_key = '_{0}__singleton' . format ( cls . __name__ ) singleton = getattr ( cls , singleton_key , None ) if singleton is not None : setattr ( cls , singleton_key , None ) singleton . close ( ) singleton . deleteLater ( ) | 10,916 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xview.py#L739-L750 | [
"def",
"set_descriptor",
"(",
"dev",
",",
"desc",
",",
"desc_type",
",",
"desc_index",
",",
"wIndex",
"=",
"None",
")",
":",
"wValue",
"=",
"desc_index",
"|",
"(",
"desc_type",
"<<",
"8",
")",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",
"util",
".",
"CTRL_OUT",
",",
"util",
".",
"CTRL_TYPE_STANDARD",
",",
"util",
".",
"CTRL_RECIPIENT_DEVICE",
")",
"dev",
".",
"ctrl_transfer",
"(",
"bmRequestType",
"=",
"bmRequestType",
",",
"bRequest",
"=",
"0x07",
",",
"wValue",
"=",
"wValue",
",",
"wIndex",
"=",
"wIndex",
",",
"data_or_wLength",
"=",
"desc",
")"
] |
Adjusts the size of this widget as the parent resizes . | def adjustSize ( self ) : # adjust the close button align = self . closeAlignment ( ) if align & QtCore . Qt . AlignTop : y = 6 else : y = self . height ( ) - 38 if align & QtCore . Qt . AlignLeft : x = 6 else : x = self . width ( ) - 38 self . _closeButton . move ( x , y ) # adjust the central widget widget = self . centralWidget ( ) if widget is not None : center = self . rect ( ) . center ( ) widget . move ( center . x ( ) - widget . width ( ) / 2 , center . y ( ) - widget . height ( ) / 2 ) | 10,917 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L48-L70 | [
"def",
"render_unregistered",
"(",
"error",
"=",
"None",
")",
":",
"return",
"template",
"(",
"read_index_template",
"(",
")",
",",
"registered",
"=",
"False",
",",
"error",
"=",
"error",
",",
"seeder_data",
"=",
"None",
",",
"url_id",
"=",
"None",
",",
")"
] |
Exits the modal window on an escape press . | def keyPressEvent ( self , event ) : if event . key ( ) == QtCore . Qt . Key_Escape : self . reject ( ) super ( XOverlayWidget , self ) . keyPressEvent ( event ) | 10,918 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L97-L106 | [
"def",
"sample_prior",
"(",
"batch_size",
")",
":",
"cat",
",",
"_",
"=",
"get_distributions",
"(",
"DIST_PRIOR_PARAM",
"[",
":",
"NUM_CLASS",
"]",
",",
"DIST_PRIOR_PARAM",
"[",
"NUM_CLASS",
":",
"]",
")",
"sample_cat",
"=",
"tf",
".",
"one_hot",
"(",
"cat",
".",
"sample",
"(",
"batch_size",
")",
",",
"NUM_CLASS",
")",
"sample_uni",
"=",
"tf",
".",
"random_uniform",
"(",
"[",
"batch_size",
",",
"NUM_UNIFORM",
"]",
",",
"-",
"1",
",",
"1",
")",
"samples",
"=",
"tf",
".",
"concat",
"(",
"[",
"sample_cat",
",",
"sample_uni",
"]",
",",
"axis",
"=",
"1",
")",
"return",
"samples"
] |
Resizes this overlay as the widget resizes . | def eventFilter ( self , object , event ) : if object == self . parent ( ) and event . type ( ) == QtCore . QEvent . Resize : self . resize ( event . size ( ) ) elif event . type ( ) == QtCore . QEvent . Close : self . setResult ( 0 ) return False | 10,919 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L108-L121 | [
"def",
"remove_users_from_organization",
"(",
"self",
",",
"organization_id",
",",
"users_list",
")",
":",
"log",
".",
"warning",
"(",
"'Removing users...'",
")",
"url",
"=",
"'rest/servicedeskapi/organization/{}/user'",
".",
"format",
"(",
"organization_id",
")",
"data",
"=",
"{",
"'usernames'",
":",
"users_list",
"}",
"return",
"self",
".",
"delete",
"(",
"url",
",",
"headers",
"=",
"self",
".",
"experimental_headers",
",",
"data",
"=",
"data",
")"
] |
Handles a resize event for this overlay centering the central widget if one is found . | def resizeEvent ( self , event ) : super ( XOverlayWidget , self ) . resizeEvent ( event ) self . adjustSize ( ) | 10,920 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L153-L161 | [
"def",
"show_company",
"(",
"domain",
")",
":",
"data",
"=",
"__utils__",
"[",
"'http.query'",
"]",
"(",
"'{0}/companies/domain/{1}'",
".",
"format",
"(",
"_base_url",
"(",
")",
",",
"domain",
")",
",",
"status",
"=",
"True",
",",
"decode",
"=",
"True",
",",
"decode_type",
"=",
"'json'",
",",
"header_dict",
"=",
"{",
"'tppl-api-key'",
":",
"_api_key",
"(",
")",
",",
"}",
",",
")",
"status",
"=",
"data",
"[",
"'status'",
"]",
"if",
"six",
".",
"text_type",
"(",
"status",
")",
".",
"startswith",
"(",
"'4'",
")",
"or",
"six",
".",
"text_type",
"(",
"status",
")",
".",
"startswith",
"(",
"'5'",
")",
":",
"raise",
"CommandExecutionError",
"(",
"'There was an API error: {0}'",
".",
"format",
"(",
"data",
"[",
"'error'",
"]",
")",
")",
"return",
"data",
".",
"get",
"(",
"'dict'",
",",
"{",
"}",
")"
] |
Sets the central widget for this overlay to the inputed widget . | def setCentralWidget ( self , widget ) : self . _centralWidget = widget if widget is not None : widget . setParent ( self ) widget . installEventFilter ( self ) # create the drop shadow effect effect = QtGui . QGraphicsDropShadowEffect ( self ) effect . setColor ( QtGui . QColor ( 'black' ) ) effect . setBlurRadius ( 80 ) effect . setOffset ( 0 , 0 ) widget . setGraphicsEffect ( effect ) | 10,921 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L163-L181 | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"REG_VALIDATION_STR",
"not",
"in",
"request",
".",
"session",
":",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'registration'",
")",
")",
"try",
":",
"self",
".",
"temporaryRegistration",
"=",
"TemporaryRegistration",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"self",
".",
"request",
".",
"session",
"[",
"REG_VALIDATION_STR",
"]",
".",
"get",
"(",
"'temporaryRegistrationId'",
")",
")",
"except",
"ObjectDoesNotExist",
":",
"messages",
".",
"error",
"(",
"request",
",",
"_",
"(",
"'Invalid registration identifier passed to sign-up form.'",
")",
")",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'registration'",
")",
")",
"expiry",
"=",
"parse_datetime",
"(",
"self",
".",
"request",
".",
"session",
"[",
"REG_VALIDATION_STR",
"]",
".",
"get",
"(",
"'temporaryRegistrationExpiry'",
",",
"''",
")",
",",
")",
"if",
"not",
"expiry",
"or",
"expiry",
"<",
"timezone",
".",
"now",
"(",
")",
":",
"messages",
".",
"info",
"(",
"request",
",",
"_",
"(",
"'Your registration session has expired. Please try again.'",
")",
")",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'registration'",
")",
")",
"return",
"super",
"(",
"StudentInfoView",
",",
"self",
")",
".",
"dispatch",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
Sets whether or not the user should be able to close this overlay widget . | def setClosable ( self , state ) : self . _closable = state if state : self . _closeButton . show ( ) else : self . _closeButton . hide ( ) | 10,922 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L183-L193 | [
"def",
"job_details",
"(",
"job_id",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"data",
"=",
"connection",
".",
"hgetall",
"(",
"job_key",
"(",
"job_id",
")",
")",
"job_data",
"=",
"{",
"'id'",
":",
"job_id",
",",
"'schedule_at'",
":",
"int",
"(",
"connection",
".",
"zscore",
"(",
"REDIS_KEY",
",",
"job_id",
")",
")",
"}",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"try",
":",
"decoded",
"=",
"value",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"decoded",
"=",
"value",
"if",
"decoded",
".",
"isdigit",
"(",
")",
":",
"decoded",
"=",
"int",
"(",
"decoded",
")",
"job_data",
"[",
"key",
".",
"decode",
"(",
"'utf-8'",
")",
"]",
"=",
"decoded",
"return",
"job_data"
] |
Closes this widget and kills the result . | def setVisible ( self , state ) : super ( XOverlayWidget , self ) . setVisible ( state ) if not state : self . setResult ( 0 ) | 10,923 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L211-L218 | [
"def",
"editProtocol",
"(",
"self",
",",
"clusterProtocolObj",
")",
":",
"if",
"isinstance",
"(",
"clusterProtocolObj",
",",
"ClusterProtocol",
")",
":",
"pass",
"else",
":",
"raise",
"AttributeError",
"(",
"\"Invalid Input, must be a ClusterProtocal Object\"",
")",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/editProtocol\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"tcpClusterPort\"",
":",
"str",
"(",
"clusterProtocolObj",
".",
"value",
"[",
"'tcpClusterPort'",
"]",
")",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Ensures this widget is the top - most widget for its parent . | def showEvent ( self , event ) : super ( XOverlayWidget , self ) . showEvent ( event ) # raise to the top self . raise_ ( ) self . _closeButton . setVisible ( self . isClosable ( ) ) widget = self . centralWidget ( ) if widget : center = self . rect ( ) . center ( ) start_x = end_x = center . x ( ) - widget . width ( ) / 2 start_y = - widget . height ( ) end_y = center . y ( ) - widget . height ( ) / 2 start = QtCore . QPoint ( start_x , start_y ) end = QtCore . QPoint ( end_x , end_y ) # create the movement animation anim = QtCore . QPropertyAnimation ( self ) anim . setPropertyName ( 'pos' ) anim . setTargetObject ( widget ) anim . setStartValue ( start ) anim . setEndValue ( end ) anim . setDuration ( 500 ) anim . setEasingCurve ( QtCore . QEasingCurve . InOutQuad ) anim . finished . connect ( anim . deleteLater ) anim . start ( ) | 10,924 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L220-L251 | [
"def",
"set",
"(",
"self",
",",
"subscribed",
",",
"ignored",
")",
":",
"sub",
"=",
"{",
"'subscribed'",
":",
"subscribed",
",",
"'ignored'",
":",
"ignored",
"}",
"json",
"=",
"self",
".",
"_json",
"(",
"self",
".",
"_put",
"(",
"self",
".",
"_api",
",",
"data",
"=",
"dumps",
"(",
"sub",
")",
")",
",",
"200",
")",
"self",
".",
"__init__",
"(",
"json",
",",
"self",
".",
"_session",
")"
] |
Creates a modal dialog for this overlay with the inputed widget . If the user accepts the widget then 1 will be returned otherwise 0 will be returned . | def modal ( widget , parent = None , align = QtCore . Qt . AlignTop | QtCore . Qt . AlignRight , blurred = True ) : if parent is None : parent = QtGui . QApplication . instance ( ) . activeWindow ( ) overlay = XOverlayWidget ( parent ) overlay . setAttribute ( QtCore . Qt . WA_DeleteOnClose ) overlay . setCentralWidget ( widget ) overlay . setCloseAlignment ( align ) overlay . show ( ) return overlay | 10,925 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xoverlaywidget.py#L254-L269 | [
"def",
"save_matpower",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
"import",
"MATPOWERWriter",
"MATPOWERWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] |
Applies the current line of code as an interactive python command . | def applyCommand ( self ) : # generate the command information
cursor = self . textCursor ( ) cursor . movePosition ( cursor . EndOfLine ) line = projex . text . nativestring ( cursor . block ( ) . text ( ) ) at_end = cursor . atEnd ( ) modifiers = QApplication . instance ( ) . keyboardModifiers ( ) mod_mode = at_end or modifiers == Qt . ShiftModifier # test the line for information
if mod_mode and line . endswith ( ':' ) : cursor . movePosition ( cursor . EndOfLine ) line = re . sub ( '^>>> ' , '' , line ) line = re . sub ( '^\.\.\. ' , '' , line ) count = len ( line ) - len ( line . lstrip ( ) ) + 4 self . insertPlainText ( '\n... ' + count * ' ' ) return False elif mod_mode and line . startswith ( '...' ) and ( line . strip ( ) != '...' or not at_end ) : cursor . movePosition ( cursor . EndOfLine ) line = re . sub ( '^\.\.\. ' , '' , line ) count = len ( line ) - len ( line . lstrip ( ) ) self . insertPlainText ( '\n... ' + count * ' ' ) return False # if we're not at the end of the console, then add it to the end
elif line . startswith ( '>>>' ) or line . startswith ( '...' ) : # move to the top of the command structure
line = projex . text . nativestring ( cursor . block ( ) . text ( ) ) while line . startswith ( '...' ) : cursor . movePosition ( cursor . PreviousBlock ) line = projex . text . nativestring ( cursor . block ( ) . text ( ) ) # calculate the command
cursor . movePosition ( cursor . EndOfLine ) line = projex . text . nativestring ( cursor . block ( ) . text ( ) ) ended = False lines = [ ] while True : # add the new block
lines . append ( line ) if cursor . atEnd ( ) : ended = True break # move to the next line
cursor . movePosition ( cursor . NextBlock ) cursor . movePosition ( cursor . EndOfLine ) line = projex . text . nativestring ( cursor . block ( ) . text ( ) ) # check for a new command or the end of the command
if not line . startswith ( '...' ) : break command = '\n' . join ( lines ) # if we did not end up at the end of the command block, then
# copy it for modification
if not ( ended and command ) : self . waitForInput ( ) self . insertPlainText ( command . replace ( '>>> ' , '' ) ) cursor . movePosition ( cursor . End ) return False else : self . waitForInput ( ) return False self . executeCommand ( command ) return True | 10,926 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xconsoleedit.py#L198-L277 | [
"def",
"update_counts",
"(",
"self",
",",
"prior_counts",
",",
"subtype_counts",
")",
":",
"for",
"source",
",",
"(",
"pos",
",",
"neg",
")",
"in",
"prior_counts",
".",
"items",
"(",
")",
":",
"if",
"source",
"not",
"in",
"self",
".",
"prior_counts",
":",
"self",
".",
"prior_counts",
"[",
"source",
"]",
"=",
"[",
"0",
",",
"0",
"]",
"self",
".",
"prior_counts",
"[",
"source",
"]",
"[",
"0",
"]",
"+=",
"pos",
"self",
".",
"prior_counts",
"[",
"source",
"]",
"[",
"1",
"]",
"+=",
"neg",
"for",
"source",
",",
"subtype_dict",
"in",
"subtype_counts",
".",
"items",
"(",
")",
":",
"if",
"source",
"not",
"in",
"self",
".",
"subtype_counts",
":",
"self",
".",
"subtype_counts",
"[",
"source",
"]",
"=",
"{",
"}",
"for",
"subtype",
",",
"(",
"pos",
",",
"neg",
")",
"in",
"subtype_dict",
".",
"items",
"(",
")",
":",
"if",
"subtype",
"not",
"in",
"self",
".",
"subtype_counts",
"[",
"source",
"]",
":",
"self",
".",
"subtype_counts",
"[",
"source",
"]",
"[",
"subtype",
"]",
"=",
"[",
"0",
",",
"0",
"]",
"self",
".",
"subtype_counts",
"[",
"source",
"]",
"[",
"subtype",
"]",
"[",
"0",
"]",
"+=",
"pos",
"self",
".",
"subtype_counts",
"[",
"source",
"]",
"[",
"subtype",
"]",
"[",
"1",
"]",
"+=",
"neg",
"self",
".",
"update_probs",
"(",
")"
] |
Navigates to the home position for the edit . | def gotoHome ( self ) : mode = QTextCursor . MoveAnchor # select the home
if QApplication . instance ( ) . keyboardModifiers ( ) == Qt . ShiftModifier : mode = QTextCursor . KeepAnchor cursor = self . textCursor ( ) block = projex . text . nativestring ( cursor . block ( ) . text ( ) ) cursor . movePosition ( QTextCursor . StartOfBlock , mode ) if block . startswith ( '>>> ' ) : cursor . movePosition ( QTextCursor . Right , mode , 4 ) elif block . startswith ( '... ' ) : match = re . match ( '...\s*' , block ) cursor . movePosition ( QTextCursor . Right , mode , match . end ( ) ) self . setTextCursor ( cursor ) | 10,927 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xconsoleedit.py#L452-L472 | [
"def",
"remove_stale_javascripts",
"(",
"portal",
")",
":",
"logger",
".",
"info",
"(",
"\"Removing stale javascripts ...\"",
")",
"for",
"js",
"in",
"JAVASCRIPTS_TO_REMOVE",
":",
"logger",
".",
"info",
"(",
"\"Unregistering JS %s\"",
"%",
"js",
")",
"portal",
".",
"portal_javascripts",
".",
"unregisterResource",
"(",
"js",
")"
] |
Inserts a new input command into the console editor . | def waitForInput ( self ) : self . _waitingForInput = False try : if self . isDestroyed ( ) or self . isReadOnly ( ) : return except RuntimeError : return self . moveCursor ( QTextCursor . End ) if self . textCursor ( ) . block ( ) . text ( ) == '>>> ' : return # if there is already text on the line, then start a new line
newln = '>>> ' if projex . text . nativestring ( self . textCursor ( ) . block ( ) . text ( ) ) : newln = '\n' + newln # insert the text
self . setCurrentMode ( 'standard' ) self . insertPlainText ( newln ) self . scrollToEnd ( ) self . _blankCache = '' | 10,928 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xconsoleedit.py#L771-L797 | [
"def",
"del_reference",
"(",
"self",
",",
"source",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"rc",
"=",
"api",
".",
"get_tool",
"(",
"\"reference_catalog\"",
")",
"uid",
"=",
"api",
".",
"get_uid",
"(",
"target",
")",
"rc",
".",
"deleteReference",
"(",
"source",
",",
"uid",
",",
"self",
".",
"relationship",
")",
"# unlink the version of the reference",
"self",
".",
"link_version",
"(",
"source",
",",
"target",
")"
] |
Saves all the current widgets and closes down . | def accept ( self ) : for i in range ( self . uiConfigSTACK . count ( ) ) : widget = self . uiConfigSTACK . widget ( i ) if ( not widget ) : continue if ( not widget . save ( ) ) : self . uiConfigSTACK . setCurrentWidget ( widget ) return False # close all the widgets in the stack for i in range ( self . uiConfigSTACK . count ( ) ) : widget = self . uiConfigSTACK . widget ( i ) if ( not widget ) : continue widget . close ( ) if ( self == XConfigDialog . _instance ) : XConfigDialog . _instance = None super ( XConfigDialog , self ) . accept ( ) | 10,929 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xconfigdialog/xconfigdialog.py#L71-L95 | [
"def",
"generate_boto3_response",
"(",
"operation",
")",
":",
"def",
"_boto3_request",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rendered",
"=",
"method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"'json'",
"in",
"self",
".",
"headers",
".",
"get",
"(",
"'Content-Type'",
",",
"[",
"]",
")",
":",
"self",
".",
"response_headers",
".",
"update",
"(",
"{",
"'x-amzn-requestid'",
":",
"'2690d7eb-ed86-11dd-9877-6fad448a8419'",
",",
"'date'",
":",
"datetime",
".",
"now",
"(",
"pytz",
".",
"utc",
")",
".",
"strftime",
"(",
"'%a, %d %b %Y %H:%M:%S %Z'",
")",
",",
"'content-type'",
":",
"'application/x-amz-json-1.1'",
"}",
")",
"resp",
"=",
"xml_to_json_response",
"(",
"self",
".",
"aws_service_spec",
",",
"operation",
",",
"rendered",
")",
"return",
"''",
"if",
"resp",
"is",
"None",
"else",
"json",
".",
"dumps",
"(",
"resp",
")",
"return",
"rendered",
"return",
"f",
"return",
"_boto3_request"
] |
Overloads the reject method to clear up the instance variable . | def reject ( self ) : if ( self == XConfigDialog . _instance ) : XConfigDialog . _instance = None super ( XConfigDialog , self ) . reject ( ) | 10,930 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xconfigdialog/xconfigdialog.py#L127-L134 | [
"def",
"import_file",
"(",
"filename",
")",
":",
"#file_path = os.path.relpath(filename)",
"file_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"log",
"(",
"DEBUG",
",",
"\"Loading prices from %s\"",
",",
"file_path",
")",
"prices",
"=",
"__read_prices_from_file",
"(",
"file_path",
")",
"with",
"BookAggregate",
"(",
"for_writing",
"=",
"True",
")",
"as",
"svc",
":",
"svc",
".",
"prices",
".",
"import_prices",
"(",
"prices",
")",
"print",
"(",
"\"Saving book...\"",
")",
"svc",
".",
"book",
".",
"save",
"(",
")"
] |
Show the config widget for the currently selected plugin . | def showConfig ( self ) : item = self . uiPluginTREE . currentItem ( ) if not isinstance ( item , PluginItem ) : return plugin = item . plugin ( ) widget = self . findChild ( QWidget , plugin . uniqueName ( ) ) if ( not widget ) : widget = plugin . createWidget ( self ) widget . setObjectName ( plugin . uniqueName ( ) ) self . uiConfigSTACK . addWidget ( widget ) self . uiConfigSTACK . setCurrentWidget ( widget ) | 10,931 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xconfigdialog/xconfigdialog.py#L209-L225 | [
"def",
"rtt_read",
"(",
"self",
",",
"buffer_index",
",",
"num_bytes",
")",
":",
"buf",
"=",
"(",
"ctypes",
".",
"c_ubyte",
"*",
"num_bytes",
")",
"(",
")",
"bytes_read",
"=",
"self",
".",
"_dll",
".",
"JLINK_RTTERMINAL_Read",
"(",
"buffer_index",
",",
"buf",
",",
"num_bytes",
")",
"if",
"bytes_read",
"<",
"0",
":",
"raise",
"errors",
".",
"JLinkRTTException",
"(",
"bytes_read",
")",
"return",
"list",
"(",
"buf",
")",
"[",
":",
"bytes_read",
"]"
] |
OpenVPN client_kill method | def cli ( server , port , client ) : tn = telnetlib . Telnet ( host = server , port = port ) tn . write ( 'kill %s\n' % client . encode ( 'utf-8' ) ) tn . write ( 'exit\n' ) os . _exit ( 0 ) | 10,932 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/openvpn/client_kill.py#L11-L17 | [
"def",
"from_pint",
"(",
"cls",
",",
"arr",
",",
"unit_registry",
"=",
"None",
")",
":",
"p_units",
"=",
"[",
"]",
"for",
"base",
",",
"exponent",
"in",
"arr",
".",
"_units",
".",
"items",
"(",
")",
":",
"bs",
"=",
"convert_pint_units",
"(",
"base",
")",
"p_units",
".",
"append",
"(",
"\"%s**(%s)\"",
"%",
"(",
"bs",
",",
"Rational",
"(",
"exponent",
")",
")",
")",
"p_units",
"=",
"\"*\"",
".",
"join",
"(",
"p_units",
")",
"if",
"isinstance",
"(",
"arr",
".",
"magnitude",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"unyt_array",
"(",
"arr",
".",
"magnitude",
",",
"p_units",
",",
"registry",
"=",
"unit_registry",
")",
"else",
":",
"return",
"unyt_quantity",
"(",
"arr",
".",
"magnitude",
",",
"p_units",
",",
"registry",
"=",
"unit_registry",
")"
] |
Updates the position of the buttons based on the current geometry . | def adjustButtons ( self ) : tabbar = self . tabBar ( ) tabbar . adjustSize ( ) w = self . width ( ) - self . _optionsButton . width ( ) - 2 self . _optionsButton . move ( w , 0 ) if self . count ( ) : need_update = self . _addButton . property ( 'alone' ) != False if need_update : self . _addButton . setProperty ( 'alone' , False ) self . _addButton . move ( tabbar . width ( ) , 1 ) self . _addButton . setFixedHeight ( tabbar . height ( ) ) else : need_update = self . _addButton . property ( 'alone' ) != True if need_update : self . _addButton . setProperty ( 'alone' , True ) self . _addButton . move ( tabbar . width ( ) + 2 , 1 ) self . _addButton . stackUnder ( self . currentWidget ( ) ) # force refresh on the stylesheet (Qt limitation for updates)
if need_update : app = QApplication . instance ( ) app . setStyleSheet ( app . styleSheet ( ) ) | 10,933 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtabwidget.py#L101-L131 | [
"def",
"create_calcs",
"(",
"self",
")",
":",
"specs",
"=",
"self",
".",
"_combine_core_aux_specs",
"(",
")",
"for",
"spec",
"in",
"specs",
":",
"spec",
"[",
"'dtype_out_time'",
"]",
"=",
"_prune_invalid_time_reductions",
"(",
"spec",
")",
"return",
"[",
"Calc",
"(",
"*",
"*",
"sp",
")",
"for",
"sp",
"in",
"specs",
"]"
] |
Publish message to exchange | def publish ( self , message , routing_key = None ) : if routing_key is None : routing_key = self . routing_key return self . client . publish_to_exchange ( self . name , message = message , routing_key = routing_key ) | 10,934 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/queues/client.py#L32-L42 | [
"def",
"initialize_schema",
"(",
"connection",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"PRAGMA application_id={}\"",
".",
"format",
"(",
"_TENSORBOARD_APPLICATION_ID",
")",
")",
"cursor",
".",
"execute",
"(",
"\"PRAGMA user_version={}\"",
".",
"format",
"(",
"_TENSORBOARD_USER_VERSION",
")",
")",
"with",
"connection",
":",
"for",
"statement",
"in",
"_SCHEMA_STATEMENTS",
":",
"lines",
"=",
"statement",
".",
"strip",
"(",
"'\\n'",
")",
".",
"split",
"(",
"'\\n'",
")",
"message",
"=",
"lines",
"[",
"0",
"]",
"+",
"(",
"'...'",
"if",
"len",
"(",
"lines",
")",
">",
"1",
"else",
"''",
")",
"logger",
".",
"debug",
"(",
"'Running DB init statement: %s'",
",",
"message",
")",
"cursor",
".",
"execute",
"(",
"statement",
")"
] |
Publish message to queue | def publish ( self , message ) : return self . client . publish_to_queue ( self . name , message = message ) | 10,935 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/queues/client.py#L63-L70 | [
"def",
"namer",
"(",
"cls",
",",
"imageUrl",
",",
"pageUrl",
")",
":",
"start",
"=",
"''",
"tsmatch",
"=",
"compile",
"(",
"r'/(\\d+)-'",
")",
".",
"search",
"(",
"imageUrl",
")",
"if",
"tsmatch",
":",
"start",
"=",
"datetime",
".",
"utcfromtimestamp",
"(",
"int",
"(",
"tsmatch",
".",
"group",
"(",
"1",
")",
")",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")",
"else",
":",
"# There were only chapter 1, page 4 and 5 not matching when writing",
"# this...",
"start",
"=",
"'2015-04-11x'",
"return",
"start",
"+",
"\"-\"",
"+",
"pageUrl",
".",
"rsplit",
"(",
"'/'",
",",
"1",
")",
"[",
"-",
"1",
"]"
] |
Adjusts the contents for this widget based on the anchor and \ mode . | def adjustContentsMargins ( self ) : anchor = self . anchor ( ) mode = self . currentMode ( ) # margins for a dialog
if ( mode == XPopupWidget . Mode . Dialog ) : self . setContentsMargins ( 0 , 0 , 0 , 0 ) # margins for a top anchor point
elif ( anchor & ( XPopupWidget . Anchor . TopLeft | XPopupWidget . Anchor . TopCenter | XPopupWidget . Anchor . TopRight ) ) : self . setContentsMargins ( 0 , self . popupPadding ( ) + 5 , 0 , 0 ) # margins for a bottom anchor point
elif ( anchor & ( XPopupWidget . Anchor . BottomLeft | XPopupWidget . Anchor . BottomCenter | XPopupWidget . Anchor . BottomRight ) ) : self . setContentsMargins ( 0 , 0 , 0 , self . popupPadding ( ) ) # margins for a left anchor point
elif ( anchor & ( XPopupWidget . Anchor . LeftTop | XPopupWidget . Anchor . LeftCenter | XPopupWidget . Anchor . LeftBottom ) ) : self . setContentsMargins ( self . popupPadding ( ) , 0 , 0 , 0 ) # margins for a right anchor point
else : self . setContentsMargins ( 0 , 0 , self . popupPadding ( ) , 0 ) self . adjustMask ( ) | 10,936 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L188-L222 | [
"def",
"validate_event_and_assign_id",
"(",
"event",
")",
":",
"event_time",
"=",
"event",
".",
"get",
"(",
"TIMESTAMP_FIELD",
")",
"if",
"event_time",
"is",
"None",
":",
"event",
"[",
"TIMESTAMP_FIELD",
"]",
"=",
"event_time",
"=",
"epoch_time_to_kronos_time",
"(",
"time",
".",
"time",
"(",
")",
")",
"elif",
"type",
"(",
"event_time",
")",
"not",
"in",
"(",
"int",
",",
"long",
")",
":",
"raise",
"InvalidEventTime",
"(",
"event_time",
")",
"# Generate a uuid1-like sequence from the event time with the non-time bytes",
"# set to random values.",
"_id",
"=",
"uuid_from_kronos_time",
"(",
"event_time",
")",
"event",
"[",
"ID_FIELD",
"]",
"=",
"str",
"(",
"_id",
")",
"return",
"_id",
",",
"event"
] |
Updates the alpha mask for this popup widget . | def adjustMask ( self ) : if self . currentMode ( ) == XPopupWidget . Mode . Dialog : self . clearMask ( ) return path = self . borderPath ( ) bitmap = QBitmap ( self . width ( ) , self . height ( ) ) bitmap . fill ( QColor ( 'white' ) ) with XPainter ( bitmap ) as painter : painter . setRenderHint ( XPainter . Antialiasing ) pen = QPen ( QColor ( 'black' ) ) pen . setWidthF ( 0.75 ) painter . setPen ( pen ) painter . setBrush ( QColor ( 'black' ) ) painter . drawPath ( path ) self . setMask ( bitmap ) | 10,937 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L224-L244 | [
"def",
"device",
"(",
"self",
",",
"idx",
")",
":",
"class",
"GpuDevice",
"(",
"Structure",
")",
":",
"pass",
"c_nvmlDevice_t",
"=",
"POINTER",
"(",
"GpuDevice",
")",
"c_index",
"=",
"c_uint",
"(",
"idx",
")",
"device",
"=",
"c_nvmlDevice_t",
"(",
")",
"_check_return",
"(",
"_NVML",
".",
"get_function",
"(",
"\"nvmlDeviceGetHandleByIndex_v2\"",
")",
"(",
"c_index",
",",
"byref",
"(",
"device",
")",
")",
")",
"return",
"NvidiaDevice",
"(",
"device",
")"
] |
Adjusts the size of this popup to best fit the new widget size . | def adjustSize ( self ) : widget = self . centralWidget ( ) if widget is None : super ( XPopupWidget , self ) . adjustSize ( ) return widget . adjustSize ( ) hint = widget . minimumSizeHint ( ) size = widget . minimumSize ( ) width = max ( size . width ( ) , hint . width ( ) ) height = max ( size . height ( ) , hint . height ( ) ) width += 20 height += 20 if self . _buttonBoxVisible : height += self . buttonBox ( ) . height ( ) + 10 if self . _titleBarVisible : height += max ( self . _dialogButton . height ( ) , self . _closeButton . height ( ) ) + 10 curr_w = self . width ( ) curr_h = self . height ( ) # determine if we need to move based on our anchor
anchor = self . anchor ( ) if anchor & ( self . Anchor . LeftBottom | self . Anchor . RightBottom | self . Anchor . BottomLeft | self . Anchor . BottomCenter | self . Anchor . BottomRight ) : delta_y = height - curr_h elif anchor & ( self . Anchor . LeftCenter | self . Anchor . RightCenter ) : delta_y = ( height - curr_h ) / 2 else : delta_y = 0 if anchor & ( self . Anchor . RightTop | self . Anchor . RightCenter | self . Anchor . RightTop | self . Anchor . TopRight ) : delta_x = width - curr_w elif anchor & ( self . Anchor . TopCenter | self . Anchor . BottomCenter ) : delta_x = ( width - curr_w ) / 2 else : delta_x = 0 self . setMinimumSize ( width , height ) self . resize ( width , height ) pos = self . pos ( ) pos . setX ( pos . x ( ) - delta_x ) pos . setY ( pos . y ( ) - delta_y ) self . move ( pos ) | 10,938 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L246-L305 | [
"def",
"render_unregistered",
"(",
"error",
"=",
"None",
")",
":",
"return",
"template",
"(",
"read_index_template",
"(",
")",
",",
"registered",
"=",
"False",
",",
"error",
"=",
"error",
",",
"seeder_data",
"=",
"None",
",",
"url_id",
"=",
"None",
",",
")"
] |
Closes the popup widget and central widget . | def close ( self ) : widget = self . centralWidget ( ) if widget and not widget . close ( ) : return super ( XPopupWidget , self ) . close ( ) | 10,939 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L530-L538 | [
"def",
"download",
"(",
"self",
",",
"bundle_uuid",
",",
"replica",
",",
"version",
"=",
"\"\"",
",",
"download_dir",
"=",
"\"\"",
",",
"metadata_files",
"=",
"(",
"'*'",
",",
")",
",",
"data_files",
"=",
"(",
"'*'",
",",
")",
",",
"num_retries",
"=",
"10",
",",
"min_delay_seconds",
"=",
"0.25",
")",
":",
"errors",
"=",
"0",
"with",
"concurrent",
".",
"futures",
".",
"ThreadPoolExecutor",
"(",
"self",
".",
"threads",
")",
"as",
"executor",
":",
"futures_to_dss_file",
"=",
"{",
"executor",
".",
"submit",
"(",
"task",
")",
":",
"dss_file",
"for",
"dss_file",
",",
"task",
"in",
"self",
".",
"_download_tasks",
"(",
"bundle_uuid",
",",
"replica",
",",
"version",
",",
"download_dir",
",",
"metadata_files",
",",
"data_files",
",",
"num_retries",
",",
"min_delay_seconds",
")",
"}",
"for",
"future",
"in",
"concurrent",
".",
"futures",
".",
"as_completed",
"(",
"futures_to_dss_file",
")",
":",
"dss_file",
"=",
"futures_to_dss_file",
"[",
"future",
"]",
"try",
":",
"future",
".",
"result",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"errors",
"+=",
"1",
"logger",
".",
"warning",
"(",
"'Failed to download file %s version %s from replica %s'",
",",
"dss_file",
".",
"uuid",
",",
"dss_file",
".",
"version",
",",
"dss_file",
".",
"replica",
",",
"exc_info",
"=",
"e",
")",
"if",
"errors",
":",
"raise",
"RuntimeError",
"(",
"'{} file(s) failed to download'",
".",
"format",
"(",
"errors",
")",
")"
] |
Refreshes the labels to display the proper title and count information . | def refreshLabels ( self ) : itemCount = self . itemCount ( ) title = self . itemsTitle ( ) if ( not itemCount ) : self . _itemsLabel . setText ( ' %s per page' % title ) else : msg = ' %s per page, %i %s total' % ( title , itemCount , title ) self . _itemsLabel . setText ( msg ) | 10,940 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpageswidget.py#L207-L218 | [
"def",
"finish",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Session disconnected.\"",
")",
"try",
":",
"self",
".",
"sock",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"except",
":",
"pass",
"self",
".",
"session_end",
"(",
")"
] |
Import modules from package and append into sys . modules | def import_modules_from_package ( package ) : path = [ os . path . dirname ( __file__ ) , '..' ] + package . split ( '.' ) path = os . path . join ( * path ) for root , dirs , files in os . walk ( path ) : for filename in files : if filename . startswith ( '__' ) or not filename . endswith ( '.py' ) : continue new_package = "." . join ( root . split ( os . sep ) ) . split ( "...." ) [ 1 ] module_name = '%s.%s' % ( new_package , filename [ : - 3 ] ) if module_name not in sys . modules : __import__ ( module_name ) | 10,941 | https://github.com/mikhaildubov/AST-text-analysis/blob/055ad8d2492c100bbbaa25309ec1074bdf1dfaa5/east/utils.py#L119-L133 | [
"def",
"compare",
"(",
"self",
",",
"control_result",
",",
"experimental_result",
")",
":",
"_compare",
"=",
"getattr",
"(",
"self",
",",
"'_compare'",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"==",
"y",
")",
"return",
"(",
"# Mismatch if only one of the results returned an error, or if",
"# different types of errors were returned.",
"type",
"(",
"control_result",
".",
"error",
")",
"is",
"type",
"(",
"experimental_result",
".",
"error",
")",
"and",
"_compare",
"(",
"control_result",
".",
"value",
",",
"experimental_result",
".",
"value",
")",
")"
] |
Perform a request . | def request ( self , request_method , api_method , * args , * * kwargs ) : url = self . _build_url ( api_method ) resp = requests . request ( request_method , url , * args , * * kwargs ) try : rv = resp . json ( ) except ValueError : raise RequestFailedError ( resp , 'not a json body' ) if not resp . ok : raise RequestFailedError ( resp , rv . get ( 'error' ) ) return rv | 10,942 | https://github.com/bearyinnovative/bearychat.py/blob/6c7af2d215c2ff7135bb5af66ca333d0ea1089fd/bearychat/openapi/client.py#L82-L109 | [
"def",
"get_urls",
"(",
"self",
")",
":",
"not_clone_url",
"=",
"[",
"url",
"(",
"r'^(.+)/will_not_clone/$'",
",",
"admin",
".",
"site",
".",
"admin_view",
"(",
"self",
".",
"will_not_clone",
")",
")",
"]",
"restore_url",
"=",
"[",
"url",
"(",
"r'^(.+)/restore/$'",
",",
"admin",
".",
"site",
".",
"admin_view",
"(",
"self",
".",
"restore",
")",
")",
"]",
"return",
"not_clone_url",
"+",
"restore_url",
"+",
"super",
"(",
"VersionedAdmin",
",",
"self",
")",
".",
"get_urls",
"(",
")"
] |
Disables snapping during the current value update to ensure a smooth transition for node animations . Since this can only be called via code we don t need to worry about snapping to the grid for a user . | def updateCurrentValue ( self , value ) : xsnap = None ysnap = None if value != self . endValue ( ) : xsnap = self . targetObject ( ) . isXSnappedToGrid ( ) ysnap = self . targetObject ( ) . isYSnappedToGrid ( ) self . targetObject ( ) . setXSnapToGrid ( False ) self . targetObject ( ) . setYSnapToGrid ( False ) super ( XNodeAnimation , self ) . updateCurrentValue ( value ) if value != self . endValue ( ) : self . targetObject ( ) . setXSnapToGrid ( xsnap ) self . targetObject ( ) . setYSnapToGrid ( ysnap ) | 10,943 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L69-L89 | [
"def",
"roleDeleted",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ref",
"=",
"{",
"'exchange'",
":",
"'role-deleted'",
",",
"'name'",
":",
"'roleDeleted'",
",",
"'routingKey'",
":",
"[",
"{",
"'multipleWords'",
":",
"True",
",",
"'name'",
":",
"'reserved'",
",",
"}",
",",
"]",
",",
"'schema'",
":",
"'v1/role-message.json#'",
",",
"}",
"return",
"self",
".",
"_makeTopicExchange",
"(",
"ref",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
Adjusts the font used for the title based on the current with and \ display name . | def adjustTitleFont ( self ) : left , top , right , bottom = self . contentsMargins ( ) r = self . roundingRadius ( ) # include text padding left += 5 + r / 2 top += 5 + r / 2 right += 5 + r / 2 bottom += 5 + r / 2 r = self . rect ( ) rect_l = r . left ( ) + left rect_r = r . right ( ) - right rect_t = r . top ( ) + top rect_b = r . bottom ( ) - bottom # ensure we have a valid rect rect = QRect ( rect_l , rect_t , rect_r - rect_l , rect_b - rect_t ) if rect . width ( ) < 10 : return font = XFont ( QApplication . font ( ) ) font . adaptSize ( self . displayName ( ) , rect , wordWrap = self . wordWrap ( ) ) self . _titleFont = font | 10,944 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L196-L224 | [
"def",
"disconnect",
"(",
"self",
",",
"code",
")",
":",
"Subscriber",
".",
"objects",
".",
"filter",
"(",
"session_id",
"=",
"self",
".",
"session_id",
")",
".",
"delete",
"(",
")"
] |
Adjusts the size of this node to support the length of its contents . | def adjustSize ( self ) : cell = self . scene ( ) . cellWidth ( ) * 2 minheight = cell minwidth = 2 * cell # fit to the grid size metrics = QFontMetrics ( QApplication . font ( ) ) width = metrics . width ( self . displayName ( ) ) + 20 width = ( ( width / cell ) * cell ) + ( cell % width ) height = self . rect ( ) . height ( ) # adjust for the icon icon = self . icon ( ) if icon and not icon . isNull ( ) : width += self . iconSize ( ) . width ( ) + 2 height = max ( height , self . iconSize ( ) . height ( ) + 2 ) w = max ( width , minwidth ) h = max ( height , minheight ) max_w = self . maximumWidth ( ) max_h = self . maximumHeight ( ) if max_w is not None : w = min ( w , max_w ) if max_h is not None : h = min ( h , max_h ) self . setMinimumWidth ( w ) self . setMinimumHeight ( h ) self . rebuild ( ) | 10,945 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L226-L261 | [
"def",
"handle_input",
"(",
"self",
",",
"input_hdr",
")",
":",
"input_slice",
"=",
"input_hdr",
"[",
"'NAXIS'",
"]",
"*",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"input_hdr",
"[",
"'NAXIS'",
"]",
")",
":",
"if",
"input_hdr",
"[",
"'CTYPE%d'",
"%",
"(",
"i",
"+",
"1",
")",
"]",
".",
"startswith",
"(",
"\"RA\"",
")",
":",
"input_slice",
"[",
"-",
"1",
"]",
"=",
"slice",
"(",
"None",
")",
"if",
"input_hdr",
"[",
"'CTYPE%d'",
"%",
"(",
"i",
"+",
"1",
")",
"]",
".",
"startswith",
"(",
"\"DEC\"",
")",
":",
"input_slice",
"[",
"-",
"2",
"]",
"=",
"slice",
"(",
"None",
")",
"return",
"input_slice"
] |
Returns whether or not this node is enabled . | def isEnabled ( self ) : if ( self . _disableWithLayer and self . _layer ) : lenabled = self . _layer . isEnabled ( ) else : lenabled = True return self . _enabled and lenabled | 10,946 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L1052-L1061 | [
"def",
"read_zmat",
"(",
"cls",
",",
"inputfile",
",",
"implicit_index",
"=",
"True",
")",
":",
"cols",
"=",
"[",
"'atom'",
",",
"'b'",
",",
"'bond'",
",",
"'a'",
",",
"'angle'",
",",
"'d'",
",",
"'dihedral'",
"]",
"if",
"implicit_index",
":",
"zmat_frame",
"=",
"pd",
".",
"read_table",
"(",
"inputfile",
",",
"comment",
"=",
"'#'",
",",
"delim_whitespace",
"=",
"True",
",",
"names",
"=",
"cols",
")",
"zmat_frame",
".",
"index",
"=",
"range",
"(",
"1",
",",
"len",
"(",
"zmat_frame",
")",
"+",
"1",
")",
"else",
":",
"zmat_frame",
"=",
"pd",
".",
"read_table",
"(",
"inputfile",
",",
"comment",
"=",
"'#'",
",",
"delim_whitespace",
"=",
"True",
",",
"names",
"=",
"[",
"'temp_index'",
"]",
"+",
"cols",
")",
"zmat_frame",
".",
"set_index",
"(",
"'temp_index'",
",",
"drop",
"=",
"True",
",",
"inplace",
"=",
"True",
")",
"zmat_frame",
".",
"index",
".",
"name",
"=",
"None",
"if",
"pd",
".",
"isnull",
"(",
"zmat_frame",
".",
"iloc",
"[",
"0",
",",
"1",
"]",
")",
":",
"zmat_values",
"=",
"[",
"1.27",
",",
"127.",
",",
"127.",
"]",
"zmat_refs",
"=",
"[",
"constants",
".",
"int_label",
"[",
"x",
"]",
"for",
"x",
"in",
"[",
"'origin'",
",",
"'e_z'",
",",
"'e_x'",
"]",
"]",
"for",
"row",
",",
"i",
"in",
"enumerate",
"(",
"zmat_frame",
".",
"index",
"[",
":",
"3",
"]",
")",
":",
"cols",
"=",
"[",
"'b'",
",",
"'a'",
",",
"'d'",
"]",
"zmat_frame",
".",
"loc",
"[",
":",
",",
"cols",
"]",
"=",
"zmat_frame",
".",
"loc",
"[",
":",
",",
"cols",
"]",
".",
"astype",
"(",
"'O'",
")",
"if",
"row",
"<",
"2",
":",
"zmat_frame",
".",
"loc",
"[",
"i",
",",
"cols",
"[",
"row",
":",
"]",
"]",
"=",
"zmat_refs",
"[",
"row",
":",
"]",
"zmat_frame",
".",
"loc",
"[",
"i",
",",
"[",
"'bond'",
",",
"'angle'",
",",
"'dihedral'",
"]",
"[",
"row",
":",
"]",
"]",
"=",
"zmat_values",
"[",
"row",
":",
"]",
"else",
":",
"zmat_frame",
".",
"loc",
"[",
"i",
",",
"'d'",
"]",
"=",
"zmat_refs",
"[",
"2",
"]",
"zmat_frame",
".",
"loc",
"[",
"i",
",",
"'dihedral'",
"]",
"=",
"zmat_values",
"[",
"2",
"]",
"elif",
"zmat_frame",
".",
"iloc",
"[",
"0",
",",
"1",
"]",
"in",
"constants",
".",
"int_label",
".",
"keys",
"(",
")",
":",
"zmat_frame",
"=",
"zmat_frame",
".",
"replace",
"(",
"{",
"col",
":",
"constants",
".",
"int_label",
"for",
"col",
"in",
"[",
"'b'",
",",
"'a'",
",",
"'d'",
"]",
"}",
")",
"zmat_frame",
"=",
"cls",
".",
"_cast_correct_types",
"(",
"zmat_frame",
")",
"try",
":",
"Zmat",
"=",
"cls",
"(",
"zmat_frame",
")",
"except",
"InvalidReference",
":",
"raise",
"UndefinedCoordinateSystem",
"(",
"'Your zmatrix cannot be transformed to cartesian coordinates'",
")",
"return",
"Zmat"
] |
Pop an item from the dict . | def popitem ( self ) : try : item = dict . popitem ( self ) return ( item [ 0 ] , item [ 1 ] [ 0 ] ) except KeyError , e : raise BadRequestKeyError ( str ( e ) ) | 10,947 | https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_datastructures.py#L333-L339 | [
"def",
"_start_vibration_win",
"(",
"self",
",",
"left_motor",
",",
"right_motor",
")",
":",
"xinput_set_state",
"=",
"self",
".",
"manager",
".",
"xinput",
".",
"XInputSetState",
"xinput_set_state",
".",
"argtypes",
"=",
"[",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"POINTER",
"(",
"XinputVibration",
")",
"]",
"xinput_set_state",
".",
"restype",
"=",
"ctypes",
".",
"c_uint",
"vibration",
"=",
"XinputVibration",
"(",
"int",
"(",
"left_motor",
"*",
"65535",
")",
",",
"int",
"(",
"right_motor",
"*",
"65535",
")",
")",
"xinput_set_state",
"(",
"self",
".",
"__device_number",
",",
"ctypes",
".",
"byref",
"(",
"vibration",
")",
")"
] |
Emits the current record changed signal for this combobox provided \ the signals aren t blocked . | def emitCurrentRecordChanged ( self ) : record = unwrapVariant ( self . itemData ( self . currentIndex ( ) , Qt . UserRole ) ) if not Table . recordcheck ( record ) : record = None self . _currentRecord = record if not self . signalsBlocked ( ) : self . _changedRecord = record self . currentRecordChanged . emit ( record ) | 10,948 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L358-L370 | [
"def",
"save_volume_files",
"(",
"note",
",",
"error",
",",
"registrations",
",",
"subject",
",",
"no_vol_export",
",",
"volume_format",
",",
"volume_path",
",",
"angle_tag",
",",
"eccen_tag",
",",
"label_tag",
",",
"radius_tag",
")",
":",
"if",
"no_vol_export",
":",
"return",
"{",
"'volume_files'",
":",
"(",
")",
"}",
"volume_format",
"=",
"volume_format",
".",
"lower",
"(",
")",
"# make an exporter for properties:",
"if",
"volume_format",
"in",
"[",
"'mgh'",
",",
"'mgz'",
",",
"'auto'",
",",
"'automatic'",
",",
"'default'",
"]",
":",
"volume_format",
"=",
"'mgh'",
"if",
"volume_format",
"==",
"'mgh'",
"else",
"'mgz'",
"def",
"export",
"(",
"flnm",
",",
"d",
")",
":",
"flnm",
"=",
"flnm",
"+",
"'.'",
"+",
"volume_format",
"dt",
"=",
"np",
".",
"int32",
"if",
"np",
".",
"issubdtype",
"(",
"d",
".",
"dtype",
",",
"np",
".",
"dtype",
"(",
"int",
")",
".",
"type",
")",
"else",
"np",
".",
"float32",
"img",
"=",
"fsmgh",
".",
"MGHImage",
"(",
"np",
".",
"asarray",
"(",
"d",
",",
"dtype",
"=",
"dt",
")",
",",
"subject",
".",
"voxel_to_native_matrix",
")",
"img",
".",
"to_filename",
"(",
"flnm",
")",
"return",
"flnm",
"elif",
"volume_format",
"in",
"[",
"'nifti'",
",",
"'nii'",
",",
"'niigz'",
",",
"'nii.gz'",
"]",
":",
"volume_format",
"=",
"'nii'",
"if",
"volume_format",
"==",
"'nii'",
"else",
"'nii.gz'",
"def",
"export",
"(",
"flnm",
",",
"p",
")",
":",
"flnm",
"=",
"flnm",
"+",
"'.'",
"+",
"volume_format",
"dt",
"=",
"np",
".",
"int32",
"if",
"np",
".",
"issubdtype",
"(",
"p",
".",
"dtype",
",",
"np",
".",
"dtype",
"(",
"int",
")",
".",
"type",
")",
"else",
"np",
".",
"float32",
"img",
"=",
"nib",
".",
"Nifti1Image",
"(",
"np",
".",
"asarray",
"(",
"p",
",",
"dtype",
"=",
"dt",
")",
",",
"subject",
".",
"voxel_to_native_matrix",
")",
"img",
".",
"to_filename",
"(",
"flnm",
")",
"return",
"flnm",
"else",
":",
"error",
"(",
"'Could not understand volume file-format %s'",
"%",
"volume_format",
")",
"path",
"=",
"volume_path",
"if",
"volume_path",
"else",
"os",
".",
"path",
".",
"join",
"(",
"subject",
".",
"path",
",",
"'mri'",
")",
"files",
"=",
"[",
"]",
"note",
"(",
"'Extracting predicted meshes for volume export...'",
")",
"hemis",
"=",
"[",
"registrations",
"[",
"h",
"]",
"[",
"'predicted_mesh'",
"]",
"if",
"h",
"in",
"registrations",
"else",
"None",
"for",
"h",
"in",
"[",
"'lh'",
",",
"'rh'",
"]",
"]",
"for",
"(",
"pname",
",",
"tag",
")",
"in",
"zip",
"(",
"[",
"'polar_angle'",
",",
"'eccentricity'",
",",
"'visual_area'",
",",
"'radius'",
"]",
",",
"[",
"angle_tag",
",",
"eccen_tag",
",",
"label_tag",
",",
"radius_tag",
"]",
")",
":",
"# we have to make the volume first...",
"dat",
"=",
"tuple",
"(",
"[",
"None",
"if",
"h",
"is",
"None",
"else",
"h",
".",
"prop",
"(",
"pname",
")",
"for",
"h",
"in",
"hemis",
"]",
")",
"(",
"mtd",
",",
"dt",
")",
"=",
"(",
"'nearest'",
",",
"np",
".",
"int32",
")",
"if",
"pname",
"==",
"'visual_area'",
"else",
"(",
"'linear'",
",",
"np",
".",
"float32",
")",
"note",
"(",
"'Constructing %s image...'",
"%",
"pname",
")",
"img",
"=",
"subject",
".",
"cortex_to_image",
"(",
"dat",
",",
"method",
"=",
"mtd",
",",
"dtype",
"=",
"dt",
")",
"flnm",
"=",
"export",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"tag",
")",
",",
"img",
")",
"files",
".",
"append",
"(",
"flnm",
")",
"return",
"{",
"'volume_files'",
":",
"tuple",
"(",
"files",
")",
"}"
] |
Emits the current record edited signal for this combobox provided the signals aren t blocked and the record has changed since the last time . | def emitCurrentRecordEdited ( self ) : if self . _changedRecord == - 1 : return if self . signalsBlocked ( ) : return record = self . _changedRecord self . _changedRecord = - 1 self . currentRecordEdited . emit ( record ) | 10,949 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L372-L385 | [
"def",
"getUtilities",
"(",
"self",
",",
"decision",
",",
"orderVector",
")",
":",
"scoringVector",
"=",
"self",
".",
"getScoringVector",
"(",
"orderVector",
")",
"utilities",
"=",
"[",
"]",
"for",
"alt",
"in",
"decision",
":",
"altPosition",
"=",
"orderVector",
".",
"index",
"(",
"alt",
")",
"utility",
"=",
"float",
"(",
"scoringVector",
"[",
"altPosition",
"]",
")",
"if",
"self",
".",
"isLoss",
"==",
"True",
":",
"utility",
"=",
"-",
"1",
"*",
"utility",
"utilities",
".",
"append",
"(",
"utility",
")",
"return",
"utilities"
] |
When this widget loses focus try to emit the record changed event signal . | def focusInEvent ( self , event ) : self . _changedRecord = - 1 super ( XOrbRecordBox , self ) . focusInEvent ( event ) | 10,950 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L480-L486 | [
"def",
"extract_bus_routine",
"(",
"page",
")",
":",
"if",
"not",
"isinstance",
"(",
"page",
",",
"pq",
")",
":",
"page",
"=",
"pq",
"(",
"page",
")",
"stations",
"=",
"extract_stations",
"(",
"page",
")",
"return",
"{",
"# Routine name.",
"'name'",
":",
"extract_routine_name",
"(",
"page",
")",
",",
"# Bus stations.",
"'stations'",
":",
"stations",
",",
"# Current routine.",
"'current'",
":",
"extract_current_routine",
"(",
"page",
",",
"stations",
")",
"}"
] |
Overloads the hide popup method to handle when the user hides the popup widget . | def hidePopup ( self ) : if self . _treePopupWidget and self . showTreePopup ( ) : self . _treePopupWidget . close ( ) super ( XOrbRecordBox , self ) . hidePopup ( ) | 10,951 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L499-L507 | [
"def",
"etag",
"(",
"self",
",",
"etag",
")",
":",
"if",
"etag",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `etag`, must not be `None`\"",
")",
"if",
"etag",
"is",
"not",
"None",
"and",
"not",
"re",
".",
"search",
"(",
"'[A-Za-z0-9]{0,256}'",
",",
"etag",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `etag`, must be a follow pattern or equal to `/[A-Za-z0-9]{0,256}/`\"",
")",
"self",
".",
"_etag",
"=",
"etag"
] |
Marks this widget as loading records . | def markLoadingStarted ( self ) : if self . isThreadEnabled ( ) : XLoaderWidget . start ( self ) if self . showTreePopup ( ) : tree = self . treePopupWidget ( ) tree . setCursor ( Qt . WaitCursor ) tree . clear ( ) tree . setUpdatesEnabled ( False ) tree . blockSignals ( True ) self . _baseHints = ( self . hint ( ) , tree . hint ( ) ) tree . setHint ( 'Loading records...' ) self . setHint ( 'Loading records...' ) else : self . _baseHints = ( self . hint ( ) , '' ) self . setHint ( 'Loading records...' ) self . setCursor ( Qt . WaitCursor ) self . blockSignals ( True ) self . setUpdatesEnabled ( False ) # prepare to load
self . clear ( ) use_dummy = not self . isRequired ( ) or self . isCheckable ( ) if use_dummy : self . addItem ( '' ) self . loadingStarted . emit ( ) | 10,952 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L573-L604 | [
"def",
"Modify",
"(",
"self",
",",
"client_limit",
"=",
"None",
",",
"client_rate",
"=",
"None",
",",
"duration",
"=",
"None",
")",
":",
"args",
"=",
"hunt_pb2",
".",
"ApiModifyHuntArgs",
"(",
"hunt_id",
"=",
"self",
".",
"hunt_id",
")",
"if",
"client_limit",
"is",
"not",
"None",
":",
"args",
".",
"client_limit",
"=",
"client_limit",
"if",
"client_rate",
"is",
"not",
"None",
":",
"args",
".",
"client_rate",
"=",
"client_rate",
"if",
"duration",
"is",
"not",
"None",
":",
"args",
".",
"duration",
"=",
"duration",
"data",
"=",
"self",
".",
"_context",
".",
"SendRequest",
"(",
"\"ModifyHunt\"",
",",
"args",
")",
"return",
"Hunt",
"(",
"data",
"=",
"data",
",",
"context",
"=",
"self",
".",
"_context",
")"
] |
Marks this widget as finished loading records . | def markLoadingFinished ( self ) : XLoaderWidget . stop ( self , force = True ) hint , tree_hint = self . _baseHints self . setHint ( hint ) # set the tree widget
if self . showTreePopup ( ) : tree = self . treePopupWidget ( ) tree . setHint ( tree_hint ) tree . unsetCursor ( ) tree . setUpdatesEnabled ( True ) tree . blockSignals ( False ) self . unsetCursor ( ) self . blockSignals ( False ) self . setUpdatesEnabled ( True ) self . loadingFinished . emit ( ) | 10,953 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordbox.py#L606-L626 | [
"def",
"download_encrypted_file",
"(",
"job",
",",
"input_args",
",",
"name",
")",
":",
"work_dir",
"=",
"job",
".",
"fileStore",
".",
"getLocalTempDir",
"(",
")",
"key_path",
"=",
"input_args",
"[",
"'ssec'",
"]",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"name",
")",
"url",
"=",
"input_args",
"[",
"name",
"]",
"with",
"open",
"(",
"key_path",
",",
"'r'",
")",
"as",
"f",
":",
"key",
"=",
"f",
".",
"read",
"(",
")",
"if",
"len",
"(",
"key",
")",
"!=",
"32",
":",
"raise",
"RuntimeError",
"(",
"'Invalid Key! Must be 32 bytes: {}'",
".",
"format",
"(",
"key",
")",
")",
"key",
"=",
"generate_unique_key",
"(",
"key_path",
",",
"url",
")",
"encoded_key",
"=",
"base64",
".",
"b64encode",
"(",
"key",
")",
"encoded_key_md5",
"=",
"base64",
".",
"b64encode",
"(",
"hashlib",
".",
"md5",
"(",
"key",
")",
".",
"digest",
"(",
")",
")",
"h1",
"=",
"'x-amz-server-side-encryption-customer-algorithm:AES256'",
"h2",
"=",
"'x-amz-server-side-encryption-customer-key:{}'",
".",
"format",
"(",
"encoded_key",
")",
"h3",
"=",
"'x-amz-server-side-encryption-customer-key-md5:{}'",
".",
"format",
"(",
"encoded_key_md5",
")",
"try",
":",
"subprocess",
".",
"check_call",
"(",
"[",
"'curl'",
",",
"'-fs'",
",",
"'--retry'",
",",
"'5'",
",",
"'-H'",
",",
"h1",
",",
"'-H'",
",",
"h2",
",",
"'-H'",
",",
"h3",
",",
"url",
",",
"'-o'",
",",
"file_path",
"]",
")",
"except",
"OSError",
":",
"raise",
"RuntimeError",
"(",
"'Failed to find \"curl\". Install via \"apt-get install curl\"'",
")",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
"return",
"job",
".",
"fileStore",
".",
"writeGlobalFile",
"(",
"file_path",
")"
] |
Destroyes this item by disconnecting any signals that may exist . This is called when the tree clears itself or is deleted . If you are manually removing an item you should call the destroy method yourself . This is required since Python allows for non - QObject connections and since QTreeWidgetItem s are not QObjects they do not properly handle being destroyed with connections on them . | def destroy ( self ) : try : tree = self . treeWidget ( ) tree . destroyed . disconnect ( self . destroy ) except StandardError : pass for movie in set ( self . _movies . values ( ) ) : try : movie . frameChanged . disconnect ( self . _updateFrame ) except StandardError : pass | 10,954 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L125-L144 | [
"def",
"convert_context_to_csv",
"(",
"self",
",",
"context",
")",
":",
"content",
"=",
"[",
"]",
"date_headers",
"=",
"context",
"[",
"'date_headers'",
"]",
"headers",
"=",
"[",
"'Name'",
"]",
"headers",
".",
"extend",
"(",
"[",
"date",
".",
"strftime",
"(",
"'%m/%d/%Y'",
")",
"for",
"date",
"in",
"date_headers",
"]",
")",
"headers",
".",
"append",
"(",
"'Total'",
")",
"content",
".",
"append",
"(",
"headers",
")",
"summaries",
"=",
"context",
"[",
"'summaries'",
"]",
"summary",
"=",
"summaries",
".",
"get",
"(",
"self",
".",
"export",
",",
"[",
"]",
")",
"for",
"rows",
",",
"totals",
"in",
"summary",
":",
"for",
"name",
",",
"user_id",
",",
"hours",
"in",
"rows",
":",
"data",
"=",
"[",
"name",
"]",
"data",
".",
"extend",
"(",
"hours",
")",
"content",
".",
"append",
"(",
"data",
")",
"total",
"=",
"[",
"'Totals'",
"]",
"total",
".",
"extend",
"(",
"totals",
")",
"content",
".",
"append",
"(",
"total",
")",
"return",
"content"
] |
Expands all the parents of this item to ensure that it is visible to the user . | def ensureVisible ( self ) : parent = self . parent ( ) while parent : parent . setExpanded ( True ) parent = parent . parent ( ) | 10,955 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L173-L181 | [
"def",
"delete_pb_devices",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Register PB devices.'",
")",
"parser",
".",
"add_argument",
"(",
"'num_pb'",
",",
"type",
"=",
"int",
",",
"help",
"=",
"'Number of PBs devices to register.'",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'sip.tango_control.subarray'",
")",
"tango_db",
"=",
"Database",
"(",
")",
"log",
".",
"info",
"(",
"\"Deleting PB devices:\"",
")",
"for",
"index",
"in",
"range",
"(",
"args",
".",
"num_pb",
")",
":",
"name",
"=",
"'sip_sdp/pb/{:05d}'",
".",
"format",
"(",
"index",
")",
"log",
".",
"info",
"(",
"\"\\t%s\"",
",",
"name",
")",
"tango_db",
".",
"delete_device",
"(",
"name",
")"
] |
Initialzes this item with a grouping style option . | def initGroupStyle ( self , useIcons = True , columnCount = None ) : flags = self . flags ( ) if flags & QtCore . Qt . ItemIsSelectable : flags ^= QtCore . Qt . ItemIsSelectable self . setFlags ( flags ) if useIcons : ico = QtGui . QIcon ( resources . find ( 'img/treeview/triangle_right.png' ) ) expand_ico = QtGui . QIcon ( resources . find ( 'img/treeview/triangle_down.png' ) ) self . setIcon ( 0 , ico ) self . setExpandedIcon ( 0 , expand_ico ) palette = QtGui . QApplication . palette ( ) line_clr = palette . color ( palette . Mid ) base_clr = palette . color ( palette . Button ) text_clr = palette . color ( palette . ButtonText ) gradient = QtGui . QLinearGradient ( ) gradient . setColorAt ( 0.00 , line_clr ) gradient . setColorAt ( 0.03 , line_clr ) gradient . setColorAt ( 0.04 , base_clr . lighter ( 105 ) ) gradient . setColorAt ( 0.25 , base_clr ) gradient . setColorAt ( 0.96 , base_clr . darker ( 105 ) ) gradient . setColorAt ( 0.97 , line_clr ) gradient . setColorAt ( 1.00 , line_clr ) h = self . _fixedHeight if not h : h = self . sizeHint ( 0 ) . height ( ) if not h : h = 18 gradient . setStart ( 0.0 , 0.0 ) gradient . setFinalStop ( 0.0 , h ) brush = QtGui . QBrush ( gradient ) tree = self . treeWidget ( ) columnCount = columnCount or ( tree . columnCount ( ) if tree else self . columnCount ( ) ) for i in range ( columnCount ) : self . setForeground ( i , text_clr ) self . setBackground ( i , brush ) | 10,956 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L242-L290 | [
"def",
"transcribe",
"(",
"decoder",
",",
"audio_file",
",",
"libdir",
"=",
"None",
")",
":",
"decoder",
"=",
"get_decoder",
"(",
")",
"decoder",
".",
"start_utt",
"(",
")",
"stream",
"=",
"open",
"(",
"audio_file",
",",
"'rb'",
")",
"while",
"True",
":",
"buf",
"=",
"stream",
".",
"read",
"(",
"1024",
")",
"if",
"buf",
":",
"decoder",
".",
"process_raw",
"(",
"buf",
",",
"False",
",",
"False",
")",
"else",
":",
"break",
"decoder",
".",
"end_utt",
"(",
")",
"return",
"evaluate_results",
"(",
"decoder",
")"
] |
Takes this item from the tree . | def takeFromTree ( self ) : tree = self . treeWidget ( ) parent = self . parent ( ) if parent : parent . takeChild ( parent . indexOfChild ( self ) ) else : tree . takeTopLevelItem ( tree . indexOfTopLevelItem ( self ) ) | 10,957 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L548-L558 | [
"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'",
"]",
"}",
")"
] |
Run the pymongo find command against the default database and collection and paginate the output to the screen . | def find ( self , * args , * * kwargs ) : # print(f"database.collection: '{self.database.name}.{self.collection.name}'") self . print_cursor ( self . collection . find ( * args , * * kwargs ) ) | 10,958 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L247-L253 | [
"def",
"UpdateManifestResourcesFromXML",
"(",
"dstpath",
",",
"xmlstr",
",",
"names",
"=",
"None",
",",
"languages",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Updating manifest in %s\"",
",",
"dstpath",
")",
"if",
"dstpath",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"\".exe\"",
")",
":",
"name",
"=",
"1",
"else",
":",
"name",
"=",
"2",
"winresource",
".",
"UpdateResources",
"(",
"dstpath",
",",
"xmlstr",
",",
"RT_MANIFEST",
",",
"names",
"or",
"[",
"name",
"]",
",",
"languages",
"or",
"[",
"0",
",",
"\"*\"",
"]",
")"
] |
Run the pymongo find_one command against the default database and collection and paginate the output to the screen . | def find_one ( self , * args , * * kwargs ) : # print(f"database.collection: '{self.database.name}.{self.collection.name}'") self . print_doc ( self . collection . find_one ( * args , * * kwargs ) ) | 10,959 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L255-L261 | [
"def",
"_run_lint_on_file_stamped",
"(",
"*",
"args",
")",
":",
"# We pass an empty dictionary as keyword arguments here to work",
"# around a bug in frosted, which crashes when no keyword arguments",
"# are passed",
"#",
"# suppress(E204)",
"stamp_args",
",",
"stamp_kwargs",
"=",
"_run_lint_on_file_stamped_args",
"(",
"*",
"args",
",",
"*",
"*",
"{",
"}",
")",
"return",
"jobstamp",
".",
"run",
"(",
"_run_lint_on_file_exceptions",
",",
"*",
"stamp_args",
",",
"*",
"*",
"stamp_kwargs",
")"
] |
Run the pymongo insert_one command against the default database and collection and returne the inserted ID . | def insert_one ( self , * args , * * kwargs ) : # print(f"database.collection: '{self.database.name}.{self.collection.name}'") result = self . collection . insert_one ( * args , * * kwargs ) return result . inserted_id | 10,960 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L263-L270 | [
"def",
"rmdir",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"self",
".",
"_raise_closed",
"(",
")",
"self",
".",
"_accessor",
".",
"rmdir",
"(",
"self",
")"
] |
Run the pymongo insert_many command against the default database and collection and return the list of inserted IDs . | def insert_many ( self , * args , * * kwargs ) : # print(f"database.collection: '{self.database.name}.{self.collection.name}'") result = self . collection . insert_many ( * args , * * kwargs ) return result . inserted_ids | 10,961 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L272-L279 | [
"def",
"rmdir",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"self",
".",
"_raise_closed",
"(",
")",
"self",
".",
"_accessor",
".",
"rmdir",
"(",
"self",
")"
] |
Run the pymongo delete_one command against the default database and collection and return the deleted IDs . | def delete_one ( self , * args , * * kwargs ) : result = self . collection . delete_one ( * args , * * kwargs ) return result . raw_result | 10,962 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L281-L287 | [
"def",
"diffuse_advanced",
"(",
"self",
",",
"heatColumnName",
"=",
"None",
",",
"time",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"PARAMS",
"=",
"set_param",
"(",
"[",
"\"heatColumnName\"",
",",
"\"time\"",
"]",
",",
"[",
"heatColumnName",
",",
"time",
"]",
")",
"response",
"=",
"api",
"(",
"url",
"=",
"self",
".",
"__url",
"+",
"\"/diffuse_advanced\"",
",",
"PARAMS",
"=",
"PARAMS",
",",
"method",
"=",
"\"POST\"",
",",
"verbose",
"=",
"verbose",
")",
"return",
"response"
] |
Run the pymongo delete_many command against the default database and collection and return the deleted IDs . | def delete_many ( self , * args , * * kwargs ) : result = self . collection . delete_many ( * args , * * kwargs ) return result . raw_result | 10,963 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L289-L295 | [
"def",
"diffuse_advanced",
"(",
"self",
",",
"heatColumnName",
"=",
"None",
",",
"time",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"PARAMS",
"=",
"set_param",
"(",
"[",
"\"heatColumnName\"",
",",
"\"time\"",
"]",
",",
"[",
"heatColumnName",
",",
"time",
"]",
")",
"response",
"=",
"api",
"(",
"url",
"=",
"self",
".",
"__url",
"+",
"\"/diffuse_advanced\"",
",",
"PARAMS",
"=",
"PARAMS",
",",
"method",
"=",
"\"POST\"",
",",
"verbose",
"=",
"verbose",
")",
"return",
"response"
] |
Count all the documents in a collection accurately | def count_documents ( self , filter = { } , * args , * * kwargs ) : result = self . collection . count_documents ( filter , * args , * * kwargs ) return result | 10,964 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L297-L302 | [
"def",
"detect_data_file",
"(",
"input",
",",
"file_name",
"=",
"\"\"",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name",
")",
"if",
"ext",
"==",
"\".m\"",
":",
"line",
"=",
"input",
".",
"readline",
"(",
")",
"# first line",
"if",
"line",
".",
"startswith",
"(",
"\"function\"",
")",
":",
"type",
"=",
"\"matpower\"",
"logger",
".",
"info",
"(",
"\"Recognised MATPOWER data file.\"",
")",
"elif",
"line",
".",
"startswith",
"(",
"\"Bus.con\"",
"or",
"line",
".",
"startswith",
"(",
"\"%\"",
")",
")",
":",
"type",
"=",
"\"psat\"",
"logger",
".",
"info",
"(",
"\"Recognised PSAT data file.\"",
")",
"else",
":",
"type",
"=",
"\"unrecognised\"",
"input",
".",
"seek",
"(",
"0",
")",
"# reset buffer for parsing",
"elif",
"(",
"ext",
"==",
"\".raw\"",
")",
"or",
"(",
"ext",
"==",
"\".psse\"",
")",
":",
"type",
"=",
"\"psse\"",
"logger",
".",
"info",
"(",
"\"Recognised PSS/E data file.\"",
")",
"elif",
"(",
"ext",
"==",
"\".pkl\"",
")",
"or",
"(",
"ext",
"==",
"\".pickle\"",
")",
":",
"type",
"=",
"\"pickle\"",
"logger",
".",
"info",
"(",
"\"Recognised pickled case.\"",
")",
"else",
":",
"type",
"=",
"None",
"return",
"type"
] |
Internal function to return all the collections for every database . include a list of db_names to filter the list of collections . | def _get_collections ( self , db_names = None ) : if db_names : db_list = db_names else : db_list = self . client . list_database_names ( ) for db_name in db_list : db = self . client . get_database ( db_name ) for col_name in db . list_collection_names ( ) : size = db [ col_name ] . g yield f"{db_name}.{col_name}" | 10,965 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L337-L351 | [
"def",
"naturaltime",
"(",
"val",
")",
":",
"val",
"=",
"val",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"if",
"isinstance",
"(",
"val",
",",
"datetime",
")",
"else",
"parse",
"(",
"val",
")",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"return",
"humanize",
".",
"naturaltime",
"(",
"now",
"-",
"val",
")"
] |
Outputs lines to a terminal . It uses shutil . get_terminal_size to determine the height of the terminal . It expects an iterator that returns a line at a time and those lines should be terminated by a valid newline sequence . | def pager ( self , lines ) : try : line_count = 0 if self . _output_filename : print ( f"Output is also going to '{self.output_file}'" ) self . _output_file = open ( self . _output_filename , "a+" ) terminal_columns , terminal_lines = shutil . get_terminal_size ( fallback = ( 80 , 24 ) ) lines_left = terminal_lines for i , l in enumerate ( lines , 1 ) : line_residue = 0 if self . line_numbers : output_line = f"{i:<4} {l}" else : output_line = l line_overflow = int ( len ( output_line ) / terminal_columns ) if line_overflow : line_residue = len ( output_line ) % terminal_columns if line_overflow >= 1 : lines_left = lines_left - line_overflow else : lines_left = lines_left - 1 if line_residue > 1 : lines_left = lines_left - 1 # line_count = line_count + 1 print ( output_line ) if self . _output_file : self . _output_file . write ( f"{l}\n" ) self . _output_file . flush ( ) #print(lines_left) if ( lines_left - self . overlap - 1 ) <= 0 : # -1 to leave room for prompt if self . paginate : print ( "Hit Return to continue (q or quit to exit)" , end = "" ) user_input = input ( ) if user_input . lower ( ) . strip ( ) in [ "q" , "quit" , "exit" ] : break terminal_columns , terminal_lines = shutil . get_terminal_size ( fallback = ( 80 , 24 ) ) lines_left = terminal_lines # end for if self . _output_file : self . _output_file . close ( ) except KeyboardInterrupt : print ( "ctrl-C..." ) if self . _output_file : self . _output_file . close ( ) | 10,966 | https://github.com/jdrumgoole/mongodbshell/blob/7e194247ea2adc1f124532935507cdffafa2c1f6/mongodbshell/__init__.py#L454-L536 | [
"def",
"update_bundle",
"(",
"data_bundle_path",
",",
"locale",
")",
":",
"import",
"rqalpha",
".",
"utils",
".",
"bundle_helper",
"rqalpha",
".",
"utils",
".",
"bundle_helper",
".",
"update_bundle",
"(",
"data_bundle_path",
",",
"locale",
")"
] |
Groups the selected items together into a sub query | def groupQuery ( self ) : items = self . uiQueryTREE . selectedItems ( ) if ( not len ( items ) > 2 ) : return if ( isinstance ( items [ - 1 ] , XJoinItem ) ) : items = items [ : - 1 ] tree = self . uiQueryTREE parent = items [ 0 ] . parent ( ) if ( not parent ) : parent = tree preceeding = items [ - 1 ] tree . blockSignals ( True ) tree . setUpdatesEnabled ( False ) grp_item = XQueryItem ( parent , Q ( ) , preceeding = preceeding ) for item in items : parent = item . parent ( ) if ( not parent ) : tree . takeTopLevelItem ( tree . indexOfTopLevelItem ( item ) ) else : parent . takeChild ( parent . indexOfChild ( item ) ) grp_item . addChild ( item ) grp_item . update ( ) tree . blockSignals ( False ) tree . setUpdatesEnabled ( True ) | 10,967 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbquerywidget.py#L575-L607 | [
"def",
"ParseFileObject",
"(",
"self",
",",
"parser_mediator",
",",
"file_object",
")",
":",
"file_offset",
"=",
"0",
"try",
":",
"timestamp",
",",
"event_data",
"=",
"self",
".",
"_ReadEntry",
"(",
"parser_mediator",
",",
"file_object",
",",
"file_offset",
")",
"except",
"errors",
".",
"ParseError",
"as",
"exception",
":",
"raise",
"errors",
".",
"UnableToParseFile",
"(",
"'Unable to parse first utmp entry with error: {0!s}'",
".",
"format",
"(",
"exception",
")",
")",
"if",
"not",
"event_data",
".",
"username",
":",
"raise",
"errors",
".",
"UnableToParseFile",
"(",
"'Unable to parse first utmp entry with error: missing username'",
")",
"if",
"not",
"timestamp",
":",
"raise",
"errors",
".",
"UnableToParseFile",
"(",
"'Unable to parse first utmp entry with error: missing timestamp'",
")",
"date_time",
"=",
"dfdatetime_posix_time",
".",
"PosixTimeInMicroseconds",
"(",
"timestamp",
"=",
"timestamp",
")",
"event",
"=",
"time_events",
".",
"DateTimeValuesEvent",
"(",
"date_time",
",",
"definitions",
".",
"TIME_DESCRIPTION_START",
")",
"parser_mediator",
".",
"ProduceEventWithEventData",
"(",
"event",
",",
"event_data",
")",
"file_offset",
"=",
"file_object",
".",
"tell",
"(",
")",
"file_size",
"=",
"file_object",
".",
"get_size",
"(",
")",
"while",
"file_offset",
"<",
"file_size",
":",
"if",
"parser_mediator",
".",
"abort",
":",
"break",
"try",
":",
"timestamp",
",",
"event_data",
"=",
"self",
".",
"_ReadEntry",
"(",
"parser_mediator",
",",
"file_object",
",",
"file_offset",
")",
"except",
"errors",
".",
"ParseError",
":",
"# Note that the utmp file can contain trailing data.",
"break",
"date_time",
"=",
"dfdatetime_posix_time",
".",
"PosixTimeInMicroseconds",
"(",
"timestamp",
"=",
"timestamp",
")",
"event",
"=",
"time_events",
".",
"DateTimeValuesEvent",
"(",
"date_time",
",",
"definitions",
".",
"TIME_DESCRIPTION_START",
")",
"parser_mediator",
".",
"ProduceEventWithEventData",
"(",
"event",
",",
"event_data",
")",
"file_offset",
"=",
"file_object",
".",
"tell",
"(",
")"
] |
Removes the currently selected query . | def removeQuery ( self ) : items = self . uiQueryTREE . selectedItems ( ) tree = self . uiQueryTREE for item in items : parent = item . parent ( ) if ( parent ) : parent . takeChild ( parent . indexOfChild ( item ) ) else : tree . takeTopLevelItem ( tree . indexOfTopLevelItem ( item ) ) self . setQuery ( self . query ( ) ) | 10,968 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbquerywidget.py#L631-L644 | [
"def",
"_read_header_lines",
"(",
"base_record_name",
",",
"dir_name",
",",
"pb_dir",
")",
":",
"file_name",
"=",
"base_record_name",
"+",
"'.hea'",
"# Read local file",
"if",
"pb_dir",
"is",
"None",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dir_name",
",",
"file_name",
")",
",",
"'r'",
")",
"as",
"fp",
":",
"# Record line followed by signal/segment lines if any",
"header_lines",
"=",
"[",
"]",
"# Comment lines",
"comment_lines",
"=",
"[",
"]",
"for",
"line",
"in",
"fp",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"# Comment line",
"if",
"line",
".",
"startswith",
"(",
"'#'",
")",
":",
"comment_lines",
".",
"append",
"(",
"line",
")",
"# Non-empty non-comment line = header line.",
"elif",
"line",
":",
"# Look for a comment in the line",
"ci",
"=",
"line",
".",
"find",
"(",
"'#'",
")",
"if",
"ci",
">",
"0",
":",
"header_lines",
".",
"append",
"(",
"line",
"[",
":",
"ci",
"]",
")",
"# comment on same line as header line",
"comment_lines",
".",
"append",
"(",
"line",
"[",
"ci",
":",
"]",
")",
"else",
":",
"header_lines",
".",
"append",
"(",
"line",
")",
"# Read online header file",
"else",
":",
"header_lines",
",",
"comment_lines",
"=",
"download",
".",
"_stream_header",
"(",
"file_name",
",",
"pb_dir",
")",
"return",
"header_lines",
",",
"comment_lines"
] |
Runs the current wizard . | def runWizard ( self ) : plugin = self . currentPlugin ( ) if ( plugin and plugin . runWizard ( self ) ) : self . accept ( ) | 10,969 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xwizardbrowserdialog/xwizardbrowserdialog.py#L133-L139 | [
"async",
"def",
"close",
"(",
"self",
")",
":",
"# Remove the core NATS Streaming subscriptions.",
"await",
"self",
".",
"_close",
"(",
")",
"req",
"=",
"protocol",
".",
"CloseRequest",
"(",
")",
"req",
".",
"clientID",
"=",
"self",
".",
"_client_id",
"msg",
"=",
"await",
"self",
".",
"_nc",
".",
"request",
"(",
"self",
".",
"_close_req_subject",
",",
"req",
".",
"SerializeToString",
"(",
")",
",",
"self",
".",
"_connect_timeout",
",",
")",
"resp",
"=",
"protocol",
".",
"CloseResponse",
"(",
")",
"resp",
".",
"ParseFromString",
"(",
"msg",
".",
"data",
")",
"if",
"resp",
".",
"error",
"!=",
"\"\"",
":",
"raise",
"StanError",
"(",
"resp",
".",
"error",
")"
] |
Shows the description for the current plugin in the interface . | def showDescription ( self ) : plugin = self . currentPlugin ( ) if ( not plugin ) : self . uiDescriptionTXT . setText ( '' ) else : self . uiDescriptionTXT . setText ( plugin . description ( ) ) | 10,970 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xwizardbrowserdialog/xwizardbrowserdialog.py#L208-L216 | [
"def",
"chainCerts",
"(",
"data",
")",
":",
"matches",
"=",
"re",
".",
"findall",
"(",
"r'(-----BEGIN CERTIFICATE-----\\n.+?\\n-----END CERTIFICATE-----)'",
",",
"data",
",",
"flags",
"=",
"re",
".",
"DOTALL",
")",
"chainCertificates",
"=",
"[",
"Certificate",
".",
"loadPEM",
"(",
"chainCertPEM",
")",
".",
"original",
"for",
"chainCertPEM",
"in",
"matches",
"]",
"return",
"chainCertificates",
"[",
"1",
":",
"]"
] |
Show the wizards widget for the currently selected plugin . | def showWizards ( self ) : self . uiWizardTABLE . clear ( ) item = self . uiPluginTREE . currentItem ( ) if ( not ( item and item . parent ( ) ) ) : plugins = [ ] else : wlang = nativestring ( item . parent ( ) . text ( 0 ) ) wgrp = nativestring ( item . text ( 0 ) ) plugins = self . plugins ( wlang , wgrp ) if ( not plugins ) : self . uiWizardTABLE . setEnabled ( False ) self . uiDescriptionTXT . setEnabled ( False ) return self . uiWizardTABLE . setEnabled ( True ) self . uiDescriptionTXT . setEnabled ( True ) # determine the number of columns
colcount = len ( plugins ) / 2 if ( len ( plugins ) % 2 ) : colcount += 1 self . uiWizardTABLE . setRowCount ( 2 ) self . uiWizardTABLE . setColumnCount ( colcount ) header = self . uiWizardTABLE . verticalHeader ( ) header . setResizeMode ( 0 , header . Stretch ) header . setResizeMode ( 1 , header . Stretch ) header . setMinimumSectionSize ( 64 ) header . hide ( ) header = self . uiWizardTABLE . horizontalHeader ( ) header . setMinimumSectionSize ( 64 ) header . hide ( ) col = - 1 row = 1 for plugin in plugins : if ( row ) : col += 1 row = int ( not row ) widget = PluginWidget ( self , plugin ) self . uiWizardTABLE . setItem ( row , col , QTableWidgetItem ( ) ) self . uiWizardTABLE . setCellWidget ( row , col , widget ) | 10,971 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xwizardbrowserdialog/xwizardbrowserdialog.py#L218-L268 | [
"def",
"_set_max_value",
"(",
"self",
",",
"max_value",
")",
":",
"self",
".",
"_external_max_value",
"=",
"max_value",
"# Check that the current value of the parameter is still within the boundaries. If not, issue a warning",
"if",
"self",
".",
"_external_max_value",
"is",
"not",
"None",
"and",
"self",
".",
"value",
">",
"self",
".",
"_external_max_value",
":",
"warnings",
".",
"warn",
"(",
"\"The current value of the parameter %s (%s) \"",
"\"was above the new maximum %s.\"",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"value",
",",
"self",
".",
"_external_max_value",
")",
",",
"exceptions",
".",
"RuntimeWarning",
")",
"self",
".",
"value",
"=",
"self",
".",
"_external_max_value"
] |
Registers this class as a valid datatype for saving and loading via the datatype system . | def registerToDataTypes ( cls ) : from projexui . xdatatype import registerDataType registerDataType ( cls . __name__ , lambda pyvalue : pyvalue . toString ( ) , lambda qvariant : cls . fromString ( unwrapVariant ( qvariant ) ) ) | 10,972 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xcolorset.py#L184-L192 | [
"def",
"_AlignDecryptedDataOffset",
"(",
"self",
",",
"decrypted_data_offset",
")",
":",
"self",
".",
"_file_object",
".",
"seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"self",
".",
"_decrypter",
"=",
"self",
".",
"_GetDecrypter",
"(",
")",
"self",
".",
"_decrypted_data",
"=",
"b''",
"encrypted_data_offset",
"=",
"0",
"encrypted_data_size",
"=",
"self",
".",
"_file_object",
".",
"get_size",
"(",
")",
"while",
"encrypted_data_offset",
"<",
"encrypted_data_size",
":",
"read_count",
"=",
"self",
".",
"_ReadEncryptedData",
"(",
"self",
".",
"_ENCRYPTED_DATA_BUFFER_SIZE",
")",
"if",
"read_count",
"==",
"0",
":",
"break",
"encrypted_data_offset",
"+=",
"read_count",
"if",
"decrypted_data_offset",
"<",
"self",
".",
"_decrypted_data_size",
":",
"self",
".",
"_decrypted_data_offset",
"=",
"decrypted_data_offset",
"break",
"decrypted_data_offset",
"-=",
"self",
".",
"_decrypted_data_size"
] |
Mark the hovered state as being true . | def enterEvent ( self , event ) : super ( XViewPanelItem , self ) . enterEvent ( event ) # store the hover state and mark for a repaint self . _hovered = True self . update ( ) | 10,973 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L134-L144 | [
"def",
"_run_sbgenomics",
"(",
"args",
")",
":",
"assert",
"not",
"args",
".",
"no_container",
",",
"\"Seven Bridges runs require containers\"",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"flags",
"=",
"[",
"]",
"cmd",
"=",
"[",
"\"sbg-cwl-runner\"",
"]",
"+",
"flags",
"+",
"args",
".",
"toolargs",
"+",
"[",
"main_file",
",",
"json_file",
"]",
"_run_tool",
"(",
"cmd",
")"
] |
Mark the hovered state as being false . | def leaveEvent ( self , event ) : super ( XViewPanelItem , self ) . leaveEvent ( event ) # store the hover state and mark for a repaint self . _hovered = False self . update ( ) | 10,974 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L146-L156 | [
"def",
"_mmUpdateDutyCycles",
"(",
"self",
")",
":",
"period",
"=",
"self",
".",
"getDutyCyclePeriod",
"(",
")",
"unionSDRArray",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"getNumColumns",
"(",
")",
")",
"unionSDRArray",
"[",
"list",
"(",
"self",
".",
"_mmTraces",
"[",
"\"unionSDR\"",
"]",
".",
"data",
"[",
"-",
"1",
"]",
")",
"]",
"=",
"1",
"self",
".",
"_mmData",
"[",
"\"unionSDRDutyCycle\"",
"]",
"=",
"UnionTemporalPoolerMonitorMixin",
".",
"_mmUpdateDutyCyclesHelper",
"(",
"self",
".",
"_mmData",
"[",
"\"unionSDRDutyCycle\"",
"]",
",",
"unionSDRArray",
",",
"period",
")",
"self",
".",
"_mmData",
"[",
"\"persistenceDutyCycle\"",
"]",
"=",
"UnionTemporalPoolerMonitorMixin",
".",
"_mmUpdateDutyCyclesHelper",
"(",
"self",
".",
"_mmData",
"[",
"\"persistenceDutyCycle\"",
"]",
",",
"self",
".",
"_poolingActivation",
",",
"period",
")"
] |
Creates the mouse event for dragging or activating this tab . | def mousePressEvent ( self , event ) : self . _moveItemStarted = False rect = QtCore . QRect ( 0 , 0 , 12 , self . height ( ) ) # drag the tab off if not self . _locked and rect . contains ( event . pos ( ) ) : tabbar = self . parent ( ) panel = tabbar . parent ( ) index = tabbar . indexOf ( self ) view = panel . widget ( index ) pixmap = QtGui . QPixmap . grabWidget ( view ) drag = QtGui . QDrag ( panel ) data = QtCore . QMimeData ( ) data . setData ( 'x-application/xview/tabbed_view' , QtCore . QByteArray ( str ( index ) ) ) drag . setMimeData ( data ) drag . setPixmap ( pixmap ) if not drag . exec_ ( ) : cursor = QtGui . QCursor . pos ( ) geom = self . window ( ) . geometry ( ) if not geom . contains ( cursor ) : view . popout ( ) # allow moving indexes around elif not self . _locked and self . isActive ( ) : self . _moveItemStarted = self . parent ( ) . count ( ) > 1 else : self . activate ( ) super ( XViewPanelItem , self ) . mousePressEvent ( event ) | 10,975 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L214-L251 | [
"def",
"get",
"(",
"self",
",",
"segids",
")",
":",
"list_return",
"=",
"True",
"if",
"type",
"(",
"segids",
")",
"in",
"(",
"int",
",",
"float",
")",
":",
"list_return",
"=",
"False",
"segids",
"=",
"[",
"int",
"(",
"segids",
")",
"]",
"paths",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"str",
"(",
"segid",
")",
")",
"for",
"segid",
"in",
"segids",
"]",
"StorageClass",
"=",
"Storage",
"if",
"len",
"(",
"segids",
")",
">",
"1",
"else",
"SimpleStorage",
"with",
"StorageClass",
"(",
"self",
".",
"vol",
".",
"layer_cloudpath",
",",
"progress",
"=",
"self",
".",
"vol",
".",
"progress",
")",
"as",
"stor",
":",
"results",
"=",
"stor",
".",
"get_files",
"(",
"paths",
")",
"for",
"res",
"in",
"results",
":",
"if",
"res",
"[",
"'error'",
"]",
"is",
"not",
"None",
":",
"raise",
"res",
"[",
"'error'",
"]",
"missing",
"=",
"[",
"res",
"[",
"'filename'",
"]",
"for",
"res",
"in",
"results",
"if",
"res",
"[",
"'content'",
"]",
"is",
"None",
"]",
"if",
"len",
"(",
"missing",
")",
":",
"raise",
"SkeletonDecodeError",
"(",
"\"File(s) do not exist: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"missing",
")",
")",
")",
"skeletons",
"=",
"[",
"]",
"for",
"res",
"in",
"results",
":",
"segid",
"=",
"int",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"res",
"[",
"'filename'",
"]",
")",
")",
"try",
":",
"skel",
"=",
"PrecomputedSkeleton",
".",
"decode",
"(",
"res",
"[",
"'content'",
"]",
",",
"segid",
"=",
"segid",
")",
"except",
"Exception",
"as",
"err",
":",
"raise",
"SkeletonDecodeError",
"(",
"\"segid \"",
"+",
"str",
"(",
"segid",
")",
"+",
"\": \"",
"+",
"err",
".",
"message",
")",
"skeletons",
".",
"append",
"(",
"skel",
")",
"if",
"list_return",
":",
"return",
"skeletons",
"return",
"skeletons",
"[",
"0",
"]"
] |
Sets the fixed height for this item to the inputed height amount . | def setFixedHeight ( self , height ) : super ( XViewPanelItem , self ) . setFixedHeight ( height ) self . _dragLabel . setFixedHeight ( height ) self . _titleLabel . setFixedHeight ( height ) self . _searchButton . setFixedHeight ( height ) self . _closeButton . setFixedHeight ( height ) | 10,976 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L274-L285 | [
"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"
] |
Clears out all the items from this tab bar . | def clear ( self ) : self . blockSignals ( True ) items = list ( self . items ( ) ) for item in items : item . close ( ) self . blockSignals ( False ) self . _currentIndex = - 1 self . currentIndexChanged . emit ( self . _currentIndex ) | 10,977 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L407-L418 | [
"def",
"MakeRequest",
"(",
"self",
",",
"data",
")",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"grr_client_sent_bytes\"",
",",
"len",
"(",
"data",
")",
")",
"# Verify the response is as it should be from the control endpoint.",
"response",
"=",
"self",
".",
"http_manager",
".",
"OpenServerEndpoint",
"(",
"path",
"=",
"\"control?api=%s\"",
"%",
"config",
".",
"CONFIG",
"[",
"\"Network.api\"",
"]",
",",
"verify_cb",
"=",
"self",
".",
"VerifyServerControlResponse",
",",
"data",
"=",
"data",
",",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"binary/octet-stream\"",
"}",
")",
"if",
"response",
".",
"code",
"==",
"406",
":",
"self",
".",
"InitiateEnrolment",
"(",
")",
"return",
"response",
"if",
"response",
".",
"code",
"==",
"200",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"grr_client_received_bytes\"",
",",
"len",
"(",
"response",
".",
"data",
")",
")",
"return",
"response",
"# An unspecified error occured.",
"return",
"response"
] |
Requests a close for the inputed tab item . | def closeTab ( self , item ) : index = self . indexOf ( item ) if index != - 1 : self . tabCloseRequested . emit ( index ) | 10,978 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L420-L428 | [
"def",
"parse_fields_http",
"(",
"self",
",",
"response",
",",
"extra_org_map",
"=",
"None",
")",
":",
"# Set the org_map. Map the orgRef handle to an RIR.",
"org_map",
"=",
"self",
".",
"org_map",
".",
"copy",
"(",
")",
"try",
":",
"org_map",
".",
"update",
"(",
"extra_org_map",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
",",
"IndexError",
",",
"KeyError",
")",
":",
"pass",
"try",
":",
"asn_data",
"=",
"{",
"'asn_registry'",
":",
"None",
",",
"'asn'",
":",
"None",
",",
"'asn_cidr'",
":",
"None",
",",
"'asn_country_code'",
":",
"None",
",",
"'asn_date'",
":",
"None",
",",
"'asn_description'",
":",
"None",
"}",
"try",
":",
"net_list",
"=",
"response",
"[",
"'nets'",
"]",
"[",
"'net'",
"]",
"if",
"not",
"isinstance",
"(",
"net_list",
",",
"list",
")",
":",
"net_list",
"=",
"[",
"net_list",
"]",
"except",
"(",
"KeyError",
",",
"TypeError",
")",
":",
"log",
".",
"debug",
"(",
"'No networks found'",
")",
"net_list",
"=",
"[",
"]",
"for",
"n",
"in",
"reversed",
"(",
"net_list",
")",
":",
"try",
":",
"asn_data",
"[",
"'asn_registry'",
"]",
"=",
"(",
"org_map",
"[",
"n",
"[",
"'orgRef'",
"]",
"[",
"'@handle'",
"]",
".",
"upper",
"(",
")",
"]",
")",
"except",
"KeyError",
"as",
"e",
":",
"log",
".",
"debug",
"(",
"'Could not parse ASN registry via HTTP: '",
"'{0}'",
".",
"format",
"(",
"str",
"(",
"e",
")",
")",
")",
"continue",
"break",
"if",
"not",
"asn_data",
"[",
"'asn_registry'",
"]",
":",
"log",
".",
"debug",
"(",
"'Could not parse ASN registry via HTTP'",
")",
"raise",
"ASNRegistryError",
"(",
"'ASN registry lookup failed.'",
")",
"except",
"ASNRegistryError",
":",
"raise",
"except",
"Exception",
"as",
"e",
":",
"# pragma: no cover",
"raise",
"ASNParseError",
"(",
"'Parsing failed for \"{0}\" with exception: {1}.'",
"''",
".",
"format",
"(",
"response",
",",
"e",
")",
"[",
":",
"100",
"]",
")",
"return",
"asn_data"
] |
Returns a list of all the items associated with this panel . | def items ( self ) : output = [ ] for i in xrange ( self . layout ( ) . count ( ) ) : item = self . layout ( ) . itemAt ( i ) try : widget = item . widget ( ) except AttributeError : break if isinstance ( widget , XViewPanelItem ) : output . append ( widget ) else : break return output | 10,979 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L488-L506 | [
"def",
"show_message",
"(",
"device",
",",
"msg",
",",
"y_offset",
"=",
"0",
",",
"fill",
"=",
"None",
",",
"font",
"=",
"None",
",",
"scroll_delay",
"=",
"0.03",
")",
":",
"fps",
"=",
"0",
"if",
"scroll_delay",
"==",
"0",
"else",
"1.0",
"/",
"scroll_delay",
"regulator",
"=",
"framerate_regulator",
"(",
"fps",
")",
"font",
"=",
"font",
"or",
"DEFAULT_FONT",
"with",
"canvas",
"(",
"device",
")",
"as",
"draw",
":",
"w",
",",
"h",
"=",
"textsize",
"(",
"msg",
",",
"font",
")",
"x",
"=",
"device",
".",
"width",
"virtual",
"=",
"viewport",
"(",
"device",
",",
"width",
"=",
"w",
"+",
"x",
"+",
"x",
",",
"height",
"=",
"device",
".",
"height",
")",
"with",
"canvas",
"(",
"virtual",
")",
"as",
"draw",
":",
"text",
"(",
"draw",
",",
"(",
"x",
",",
"y_offset",
")",
",",
"msg",
",",
"font",
"=",
"font",
",",
"fill",
"=",
"fill",
")",
"i",
"=",
"0",
"while",
"i",
"<=",
"w",
"+",
"x",
":",
"with",
"regulator",
":",
"virtual",
".",
"set_position",
"(",
"(",
"i",
",",
"0",
")",
")",
"i",
"+=",
"1"
] |
Moves the tab from the inputed index to the given index . | def moveTab ( self , fromIndex , toIndex ) : try : item = self . layout ( ) . itemAt ( fromIndex ) self . layout ( ) . insertItem ( toIndex , item . widget ( ) ) except StandardError : pass | 10,980 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L508-L519 | [
"def",
"_import_parsers",
"(",
")",
":",
"global",
"ARCGIS_NODES",
"global",
"ARCGIS_ROOTS",
"global",
"ArcGISParser",
"global",
"FGDC_ROOT",
"global",
"FgdcParser",
"global",
"ISO_ROOTS",
"global",
"IsoParser",
"global",
"VALID_ROOTS",
"if",
"ARCGIS_NODES",
"is",
"None",
"or",
"ARCGIS_ROOTS",
"is",
"None",
"or",
"ArcGISParser",
"is",
"None",
":",
"from",
"gis_metadata",
".",
"arcgis_metadata_parser",
"import",
"ARCGIS_NODES",
"from",
"gis_metadata",
".",
"arcgis_metadata_parser",
"import",
"ARCGIS_ROOTS",
"from",
"gis_metadata",
".",
"arcgis_metadata_parser",
"import",
"ArcGISParser",
"if",
"FGDC_ROOT",
"is",
"None",
"or",
"FgdcParser",
"is",
"None",
":",
"from",
"gis_metadata",
".",
"fgdc_metadata_parser",
"import",
"FGDC_ROOT",
"from",
"gis_metadata",
".",
"fgdc_metadata_parser",
"import",
"FgdcParser",
"if",
"ISO_ROOTS",
"is",
"None",
"or",
"IsoParser",
"is",
"None",
":",
"from",
"gis_metadata",
".",
"iso_metadata_parser",
"import",
"ISO_ROOTS",
"from",
"gis_metadata",
".",
"iso_metadata_parser",
"import",
"IsoParser",
"if",
"VALID_ROOTS",
"is",
"None",
":",
"VALID_ROOTS",
"=",
"{",
"FGDC_ROOT",
"}",
".",
"union",
"(",
"ARCGIS_ROOTS",
"+",
"ISO_ROOTS",
")"
] |
Removes the tab at the inputed index . | def removeTab ( self , index ) : curr_index = self . currentIndex ( ) items = list ( self . items ( ) ) item = items [ index ] item . close ( ) if index <= curr_index : self . _currentIndex -= 1 | 10,981 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L546-L558 | [
"def",
"ClientInit",
"(",
")",
":",
"metric_metadata",
"=",
"client_metrics",
".",
"GetMetadata",
"(",
")",
"metric_metadata",
".",
"extend",
"(",
"communicator",
".",
"GetMetricMetadata",
"(",
")",
")",
"stats_collector_instance",
".",
"Set",
"(",
"default_stats_collector",
".",
"DefaultStatsCollector",
"(",
"metric_metadata",
")",
")",
"config_lib",
".",
"SetPlatformArchContext",
"(",
")",
"config_lib",
".",
"ParseConfigCommandLine",
"(",
")",
"client_logging",
".",
"LogInit",
"(",
")",
"all_parsers",
".",
"Register",
"(",
")",
"registry",
".",
"Init",
"(",
")",
"if",
"not",
"config",
".",
"CONFIG",
".",
"ContextApplied",
"(",
"contexts",
".",
"CLIENT_BUILD_CONTEXT",
")",
":",
"config",
".",
"CONFIG",
".",
"Persist",
"(",
"\"Client.labels\"",
")",
"config",
".",
"CONFIG",
".",
"Persist",
"(",
"\"Client.proxy_servers\"",
")",
"config",
".",
"CONFIG",
".",
"Persist",
"(",
"\"Client.tempdir_roots\"",
")"
] |
Emits the add requested signal . | def requestAddMenu ( self ) : point = QtCore . QPoint ( self . _addButton . width ( ) , 0 ) point = self . _addButton . mapToGlobal ( point ) self . addRequested . emit ( point ) | 10,982 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L560-L566 | [
"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",
")"
] |
Emits the options request signal . | def requestOptionsMenu ( self ) : point = QtCore . QPoint ( 0 , self . _optionsButton . height ( ) ) point = self . _optionsButton . mapToGlobal ( point ) self . optionsRequested . emit ( point ) | 10,983 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L568-L574 | [
"def",
"build_caching_info_message",
"(",
"job_spec",
",",
"job_id",
",",
"workflow_workspace",
",",
"workflow_json",
",",
"result_path",
")",
":",
"caching_info_message",
"=",
"{",
"\"job_spec\"",
":",
"job_spec",
",",
"\"job_id\"",
":",
"job_id",
",",
"\"workflow_workspace\"",
":",
"workflow_workspace",
",",
"\"workflow_json\"",
":",
"workflow_json",
",",
"\"result_path\"",
":",
"result_path",
"}",
"return",
"caching_info_message"
] |
Sets the current item to the item at the inputed index . | def setCurrentIndex ( self , index ) : if self . _currentIndex == index : return self . _currentIndex = index self . currentIndexChanged . emit ( index ) for i , item in enumerate ( self . items ( ) ) : item . setMenuEnabled ( i == index ) self . repaint ( ) | 10,984 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L576-L590 | [
"def",
"run",
"(",
")",
":",
"print",
"(",
"\"Environment\"",
",",
"os",
".",
"environ",
")",
"try",
":",
"os",
".",
"environ",
"[",
"\"SELENIUM\"",
"]",
"except",
"KeyError",
":",
"print",
"(",
"\"Please set the environment variable SELENIUM to Selenium URL\"",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"driver",
"=",
"WhatsAPIDriver",
"(",
"client",
"=",
"'remote'",
",",
"command_executor",
"=",
"os",
".",
"environ",
"[",
"\"SELENIUM\"",
"]",
")",
"print",
"(",
"\"Waiting for QR\"",
")",
"driver",
".",
"wait_for_login",
"(",
")",
"print",
"(",
"\"Bot started\"",
")",
"driver",
".",
"subscribe_new_messages",
"(",
"NewMessageObserver",
"(",
")",
")",
"print",
"(",
"\"Waiting for new messages...\"",
")",
"while",
"True",
":",
"time",
".",
"sleep",
"(",
"60",
")"
] |
Sets the fixed height for this bar to the inputed height . | def setFixedHeight ( self , height ) : super ( XViewPanelBar , self ) . setFixedHeight ( height ) # update the layout if self . layout ( ) : for i in xrange ( self . layout ( ) . count ( ) ) : try : self . layout ( ) . itemAt ( i ) . widget ( ) . setFixedHeight ( height ) except StandardError : continue | 10,985 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L610-L624 | [
"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\"",
")"
] |
Returns the text for the tab at the inputed index . | def setTabText ( self , index , text ) : try : self . items ( ) [ index ] . setText ( text ) except IndexError : pass | 10,986 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L626-L637 | [
"def",
"detach_session",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"not",
"None",
":",
"self",
".",
"_session",
".",
"unsubscribe",
"(",
"self",
")",
"self",
".",
"_session",
"=",
"None"
] |
Closes a full view panel . | def closePanel ( self ) : # make sure we can close all the widgets in the view first for i in range ( self . count ( ) ) : if not self . widget ( i ) . canClose ( ) : return False container = self . parentWidget ( ) viewWidget = self . viewWidget ( ) # close all the child views for i in xrange ( self . count ( ) - 1 , - 1 , - 1 ) : self . widget ( i ) . close ( ) self . tabBar ( ) . clear ( ) if isinstance ( container , XSplitter ) : parent_container = container . parentWidget ( ) if container . count ( ) == 2 : if isinstance ( parent_container , XSplitter ) : sizes = parent_container . sizes ( ) widget = container . widget ( int ( not container . indexOf ( self ) ) ) index = parent_container . indexOf ( container ) parent_container . insertWidget ( index , widget ) container . setParent ( None ) container . close ( ) container . deleteLater ( ) parent_container . setSizes ( sizes ) elif parent_container . parentWidget ( ) == viewWidget : widget = container . widget ( int ( not container . indexOf ( self ) ) ) widget . setParent ( viewWidget ) if projexui . QT_WRAPPER == 'PySide' : _ = viewWidget . takeWidget ( ) else : old_widget = viewWidget . widget ( ) old_widget . setParent ( None ) old_widget . close ( ) old_widget . deleteLater ( ) QtGui . QApplication . instance ( ) . processEvents ( ) viewWidget . setWidget ( widget ) else : container . setParent ( None ) container . close ( ) container . deleteLater ( ) else : self . setFocus ( ) self . _hintLabel . setText ( self . hint ( ) ) self . _hintLabel . show ( ) return True | 10,987 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L935-L993 | [
"def",
"conn_aws",
"(",
"cred",
",",
"crid",
")",
":",
"driver",
"=",
"get_driver",
"(",
"Provider",
".",
"EC2",
")",
"try",
":",
"aws_obj",
"=",
"driver",
"(",
"cred",
"[",
"'aws_access_key_id'",
"]",
",",
"cred",
"[",
"'aws_secret_access_key'",
"]",
",",
"region",
"=",
"cred",
"[",
"'aws_default_region'",
"]",
")",
"except",
"SSLError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r SSL Error with AWS: {}\"",
".",
"format",
"(",
"e",
")",
")",
"except",
"InvalidCredsError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r Error with AWS Credentials: {}\"",
".",
"format",
"(",
"e",
")",
")",
"return",
"{",
"crid",
":",
"aws_obj",
"}"
] |
Find and switch to the first tab of the specified view type . If the type does not exist add it . | def ensureVisible ( self , viewType ) : # make sure we're not trying to switch to the same type view = self . currentView ( ) if type ( view ) == viewType : return view self . blockSignals ( True ) self . setUpdatesEnabled ( False ) for i in xrange ( self . count ( ) ) : widget = self . widget ( i ) if type ( widget ) == viewType : self . setCurrentIndex ( i ) view = widget break else : view = self . addView ( viewType ) self . blockSignals ( False ) self . setUpdatesEnabled ( True ) return view | 10,988 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1121-L1150 | [
"def",
"merged",
"(",
"self",
")",
":",
"stats",
"=",
"{",
"}",
"for",
"topic",
"in",
"self",
".",
"client",
".",
"topics",
"(",
")",
"[",
"'topics'",
"]",
":",
"for",
"producer",
"in",
"self",
".",
"client",
".",
"lookup",
"(",
"topic",
")",
"[",
"'producers'",
"]",
":",
"hostname",
"=",
"producer",
"[",
"'broadcast_address'",
"]",
"port",
"=",
"producer",
"[",
"'http_port'",
"]",
"host",
"=",
"'%s_%s'",
"%",
"(",
"hostname",
",",
"port",
")",
"stats",
"[",
"host",
"]",
"=",
"nsqd",
".",
"Client",
"(",
"'http://%s:%s/'",
"%",
"(",
"hostname",
",",
"port",
")",
")",
".",
"clean_stats",
"(",
")",
"return",
"stats"
] |
Inserts a new tab for this widget . | def insertTab ( self , index , widget , title ) : self . insertWidget ( index , widget ) tab = self . tabBar ( ) . insertTab ( index , title ) tab . titleChanged . connect ( widget . setWindowTitle ) | 10,989 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1225-L1235 | [
"def",
"_get_certificate",
"(",
"cert_url",
")",
":",
"global",
"_cache",
"if",
"cert_url",
"in",
"_cache",
":",
"cert",
"=",
"_cache",
"[",
"cert_url",
"]",
"if",
"cert",
".",
"has_expired",
"(",
")",
":",
"_cache",
"=",
"{",
"}",
"else",
":",
"return",
"cert",
"url",
"=",
"urlparse",
"(",
"cert_url",
")",
"host",
"=",
"url",
".",
"netloc",
".",
"lower",
"(",
")",
"path",
"=",
"posixpath",
".",
"normpath",
"(",
"url",
".",
"path",
")",
"# Sanity check location so we don't get some random person's cert.",
"if",
"url",
".",
"scheme",
"!=",
"'https'",
"or",
"host",
"not",
"in",
"[",
"'s3.amazonaws.com'",
",",
"'s3.amazonaws.com:443'",
"]",
"or",
"not",
"path",
".",
"startswith",
"(",
"'/echo.api/'",
")",
":",
"log",
".",
"error",
"(",
"'invalid cert location %s'",
",",
"cert_url",
")",
"return",
"resp",
"=",
"urlopen",
"(",
"cert_url",
")",
"if",
"resp",
".",
"getcode",
"(",
")",
"!=",
"200",
":",
"log",
".",
"error",
"(",
"'failed to download certificate'",
")",
"return",
"cert",
"=",
"crypto",
".",
"load_certificate",
"(",
"crypto",
".",
"FILETYPE_PEM",
",",
"resp",
".",
"read",
"(",
")",
")",
"if",
"cert",
".",
"has_expired",
"(",
")",
"or",
"cert",
".",
"get_subject",
"(",
")",
".",
"CN",
"!=",
"'echo-api.amazon.com'",
":",
"log",
".",
"error",
"(",
"'certificate expired or invalid'",
")",
"return",
"_cache",
"[",
"cert_url",
"]",
"=",
"cert",
"return",
"cert"
] |
Marks that the current widget has changed . | def markCurrentChanged ( self ) : view = self . currentView ( ) if view : view . setCurrent ( ) self . setFocus ( ) view . setFocus ( ) self . _hintLabel . hide ( ) else : self . _hintLabel . show ( ) self . _hintLabel . setText ( self . hint ( ) ) if not self . count ( ) : self . tabBar ( ) . clear ( ) self . adjustSizeConstraint ( ) | 10,990 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1254-L1271 | [
"def",
"mol_supplier",
"(",
"lines",
",",
"no_halt",
",",
"assign_descriptors",
")",
":",
"def",
"sdf_block",
"(",
"lns",
")",
":",
"mol",
"=",
"[",
"]",
"opt",
"=",
"[",
"]",
"is_mol",
"=",
"True",
"for",
"line",
"in",
"lns",
":",
"if",
"line",
".",
"startswith",
"(",
"\"$$$$\"",
")",
":",
"yield",
"mol",
"[",
":",
"]",
",",
"opt",
"[",
":",
"]",
"is_mol",
"=",
"True",
"mol",
".",
"clear",
"(",
")",
"opt",
".",
"clear",
"(",
")",
"elif",
"line",
".",
"startswith",
"(",
"\"M END\"",
")",
":",
"is_mol",
"=",
"False",
"elif",
"is_mol",
":",
"mol",
".",
"append",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"else",
":",
"opt",
".",
"append",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"if",
"mol",
":",
"yield",
"mol",
",",
"opt",
"for",
"i",
",",
"(",
"mol",
",",
"opt",
")",
"in",
"enumerate",
"(",
"sdf_block",
"(",
"lines",
")",
")",
":",
"try",
":",
"c",
"=",
"molecule",
"(",
"mol",
")",
"if",
"assign_descriptors",
":",
"molutil",
".",
"assign_descriptors",
"(",
"c",
")",
"except",
"ValueError",
"as",
"err",
":",
"if",
"no_halt",
":",
"print",
"(",
"\"Unsupported symbol: {} (#{} in v2000reader)\"",
".",
"format",
"(",
"err",
",",
"i",
"+",
"1",
")",
")",
"c",
"=",
"molutil",
".",
"null_molecule",
"(",
"assign_descriptors",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Unsupported symbol: {}\"",
".",
"format",
"(",
"err",
")",
")",
"except",
"RuntimeError",
"as",
"err",
":",
"if",
"no_halt",
":",
"print",
"(",
"\"Failed to minimize ring: {} (#{} in v2000reader)\"",
".",
"format",
"(",
"err",
",",
"i",
"+",
"1",
")",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"Failed to minimize ring: {}\"",
".",
"format",
"(",
"err",
")",
")",
"except",
":",
"if",
"no_halt",
":",
"print",
"(",
"\"Unexpected error (#{} in v2000reader)\"",
".",
"format",
"(",
"i",
"+",
"1",
")",
")",
"c",
"=",
"molutil",
".",
"null_molecule",
"(",
"assign_descriptors",
")",
"c",
".",
"data",
"=",
"optional_data",
"(",
"opt",
")",
"yield",
"c",
"continue",
"else",
":",
"print",
"(",
"traceback",
".",
"format_exc",
"(",
")",
")",
"raise",
"Exception",
"(",
"\"Unsupported Error\"",
")",
"c",
".",
"data",
"=",
"optional_data",
"(",
"opt",
")",
"yield",
"c"
] |
Refreshes the titles for each view within this tab panel . | def refreshTitles ( self ) : for index in range ( self . count ( ) ) : widget = self . widget ( index ) self . setTabText ( index , widget . windowTitle ( ) ) | 10,991 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1301-L1307 | [
"def",
"verify_certificate_chain",
"(",
"cert_str",
",",
"trusted_certs",
",",
"ignore_self_signed",
"=",
"True",
")",
":",
"# Load the certificate",
"certificate",
"=",
"crypto",
".",
"load_certificate",
"(",
"crypto",
".",
"FILETYPE_ASN1",
",",
"cert_str",
")",
"# Create a certificate store and add your trusted certs",
"try",
":",
"store",
"=",
"crypto",
".",
"X509Store",
"(",
")",
"if",
"ignore_self_signed",
":",
"store",
".",
"add_cert",
"(",
"certificate",
")",
"# Assuming the certificates are in PEM format in a trusted_certs list",
"for",
"_cert",
"in",
"trusted_certs",
":",
"store",
".",
"add_cert",
"(",
"crypto",
".",
"load_certificate",
"(",
"crypto",
".",
"FILETYPE_ASN1",
",",
"_cert",
")",
")",
"# Create a certificate context using the store and the certificate",
"store_ctx",
"=",
"crypto",
".",
"X509StoreContext",
"(",
"store",
",",
"certificate",
")",
"# Verify the certificate, returns None if certificate is not valid",
"store_ctx",
".",
"verify_certificate",
"(",
")",
"return",
"True",
"except",
"crypto",
".",
"X509StoreContextError",
"as",
"e",
":",
"raise",
"AS2Exception",
"(",
"'Partner Certificate Invalid: %s'",
"%",
"e",
".",
"args",
"[",
"-",
"1",
"]",
"[",
"-",
"1",
"]",
")"
] |
Sets the current index on self and on the tab bar to keep the two insync . | def setCurrentIndex ( self , index ) : super ( XViewPanel , self ) . setCurrentIndex ( index ) self . tabBar ( ) . setCurrentIndex ( index ) | 10,992 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1452-L1459 | [
"def",
"extract_response",
"(",
"raw_response",
")",
":",
"data",
"=",
"urlread",
"(",
"raw_response",
")",
"if",
"is_success_response",
"(",
"raw_response",
")",
":",
"return",
"data",
"elif",
"is_failure_response",
"(",
"raw_response",
")",
":",
"raise",
"RemoteExecuteError",
"(",
"data",
")",
"elif",
"is_invalid_response",
"(",
"raw_response",
")",
":",
"raise",
"InvalidResponseError",
"(",
"data",
")",
"else",
":",
"raise",
"UnknownStatusError",
"(",
"data",
")"
] |
Swaps the current tab view for the inputed action s type . | def switchCurrentView ( self , viewType ) : if not self . count ( ) : return self . addView ( viewType ) # make sure we're not trying to switch to the same type view = self . currentView ( ) if type ( view ) == viewType : return view # create a new view and close the old one self . blockSignals ( True ) self . setUpdatesEnabled ( False ) # create the new view index = self . indexOf ( view ) if not view . close ( ) : return None #else: # self.tabBar().removeTab(index) index = self . currentIndex ( ) new_view = viewType . createInstance ( self . viewWidget ( ) , self . viewWidget ( ) ) # add the new view self . insertTab ( index , new_view , new_view . windowTitle ( ) ) self . blockSignals ( False ) self . setUpdatesEnabled ( True ) self . setCurrentIndex ( index ) return new_view | 10,993 | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1503-L1540 | [
"def",
"poissonVectorRDD",
"(",
"sc",
",",
"mean",
",",
"numRows",
",",
"numCols",
",",
"numPartitions",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"poissonVectorRDD\"",
",",
"sc",
".",
"_jsc",
",",
"float",
"(",
"mean",
")",
",",
"numRows",
",",
"numCols",
",",
"numPartitions",
",",
"seed",
")"
] |
Returns a list of the keys under the given prefix | async def keys ( self , prefix , * , dc = None , separator = None , watch = None , consistency = None ) : response = await self . _read ( prefix , dc = dc , separator = separator , keys = True , watch = watch , consistency = consistency ) return consul ( response ) | 10,994 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L39-L68 | [
"def",
"tfidf_weight",
"(",
"X",
")",
":",
"X",
"=",
"coo_matrix",
"(",
"X",
")",
"# calculate IDF",
"N",
"=",
"float",
"(",
"X",
".",
"shape",
"[",
"0",
"]",
")",
"idf",
"=",
"log",
"(",
"N",
")",
"-",
"log1p",
"(",
"bincount",
"(",
"X",
".",
"col",
")",
")",
"# apply TF-IDF adjustment",
"X",
".",
"data",
"=",
"sqrt",
"(",
"X",
".",
"data",
")",
"*",
"idf",
"[",
"X",
".",
"col",
"]",
"return",
"X"
] |
Gets all keys with a prefix of Key during the transaction . | async def get_tree ( self , prefix , * , dc = None , separator = None , watch = None , consistency = None ) : response = await self . _read ( prefix , dc = dc , recurse = True , separator = separator , watch = watch , consistency = consistency ) result = response . body for data in result : data [ "Value" ] = decode_value ( data [ "Value" ] , data [ "Flags" ] ) return consul ( result , meta = extract_meta ( response . headers ) ) | 10,995 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L141-L168 | [
"def",
"handler404",
"(",
"request",
",",
"template_name",
"=",
"'404.html'",
")",
":",
"t",
"=",
"loader",
".",
"get_template",
"(",
"template_name",
")",
"# You need to create a 404.html template.",
"return",
"http",
".",
"HttpResponseNotFound",
"(",
"t",
".",
"render",
"(",
"Context",
"(",
"{",
"'MEDIA_URL'",
":",
"settings",
".",
"MEDIA_URL",
",",
"'STATIC_URL'",
":",
"settings",
".",
"STATIC_URL",
"}",
")",
")",
")"
] |
Sets the key to the given value with check - and - set semantics . | async def cas ( self , key , value , * , flags = None , index ) : value = encode_value ( value , flags ) index = extract_attr ( index , keys = [ "ModifyIndex" , "Index" ] ) response = await self . _write ( key , value , flags = flags , cas = index ) return response . body is True | 10,996 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L187-L208 | [
"def",
"getBriefModuleInfoFromFile",
"(",
"fileName",
")",
":",
"modInfo",
"=",
"BriefModuleInfo",
"(",
")",
"_cdmpyparser",
".",
"getBriefModuleInfoFromFile",
"(",
"modInfo",
",",
"fileName",
")",
"modInfo",
".",
"flush",
"(",
")",
"return",
"modInfo"
] |
Locks the Key with the given Session . | async def lock ( self , key , value , * , flags = None , session ) : value = encode_value ( value , flags ) session_id = extract_attr ( session , keys = [ "ID" ] ) response = await self . _write ( key , value , flags = flags , acquire = session_id ) return response . body is True | 10,997 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L210-L229 | [
"def",
"make_diet_var_getter",
"(",
"params",
")",
":",
"def",
"diet_var_initializer",
"(",
"shape",
",",
"dtype",
",",
"partition_info",
"=",
"None",
")",
":",
"\"\"\"Initializer for a diet variable.\"\"\"",
"del",
"dtype",
"del",
"partition_info",
"with",
"common_layers",
".",
"fn_device_dependency",
"(",
"\"diet_init\"",
")",
"as",
"out_deps",
":",
"float_range",
"=",
"math",
".",
"sqrt",
"(",
"3",
")",
"ret",
"=",
"tf",
".",
"random_uniform",
"(",
"shape",
",",
"-",
"float_range",
",",
"float_range",
")",
"if",
"params",
".",
"quantize",
":",
"ret",
"=",
"_quantize",
"(",
"ret",
",",
"params",
",",
"randomize",
"=",
"False",
")",
"out_deps",
".",
"append",
"(",
"ret",
")",
"return",
"ret",
"def",
"diet_var_getter",
"(",
"getter",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Get diet variable and return it dequantized.\"\"\"",
"if",
"params",
".",
"quantize",
":",
"kwargs",
"[",
"\"dtype\"",
"]",
"=",
"tf",
".",
"float16",
"kwargs",
"[",
"\"initializer\"",
"]",
"=",
"diet_var_initializer",
"kwargs",
"[",
"\"trainable\"",
"]",
"=",
"False",
"base_var",
"=",
"getter",
"(",
"*",
"*",
"kwargs",
")",
"dequantized",
"=",
"_dequantize",
"(",
"base_var",
",",
"params",
")",
"if",
"not",
"hasattr",
"(",
"params",
",",
"\"dequantized\"",
")",
":",
"params",
".",
"dequantized",
"=",
"defaultdict",
"(",
"list",
")",
"params",
".",
"dequantized",
"[",
"base_var",
".",
"name",
"]",
".",
"append",
"(",
"dequantized",
")",
"return",
"dequantized",
"return",
"diet_var_getter"
] |
Unlocks the Key with the given Session . | async def unlock ( self , key , value , * , flags = None , session ) : value = encode_value ( value , flags ) session_id = extract_attr ( session , keys = [ "ID" ] ) response = await self . _write ( key , value , flags = flags , release = session_id ) return response . body is True | 10,998 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L231-L250 | [
"def",
"_read_body_by_chunk",
"(",
"self",
",",
"response",
",",
"file",
",",
"raw",
"=",
"False",
")",
":",
"reader",
"=",
"ChunkedTransferReader",
"(",
"self",
".",
"_connection",
")",
"file_is_async",
"=",
"hasattr",
"(",
"file",
",",
"'drain'",
")",
"while",
"True",
":",
"chunk_size",
",",
"data",
"=",
"yield",
"from",
"reader",
".",
"read_chunk_header",
"(",
")",
"self",
".",
"_data_event_dispatcher",
".",
"notify_read",
"(",
"data",
")",
"if",
"raw",
":",
"file",
".",
"write",
"(",
"data",
")",
"if",
"not",
"chunk_size",
":",
"break",
"while",
"True",
":",
"content",
",",
"data",
"=",
"yield",
"from",
"reader",
".",
"read_chunk_body",
"(",
")",
"self",
".",
"_data_event_dispatcher",
".",
"notify_read",
"(",
"data",
")",
"if",
"not",
"content",
":",
"if",
"raw",
":",
"file",
".",
"write",
"(",
"data",
")",
"break",
"content",
"=",
"self",
".",
"_decompress_data",
"(",
"content",
")",
"if",
"file",
":",
"file",
".",
"write",
"(",
"content",
")",
"if",
"file_is_async",
":",
"yield",
"from",
"file",
".",
"drain",
"(",
")",
"content",
"=",
"self",
".",
"_flush_decompressor",
"(",
")",
"if",
"file",
":",
"file",
".",
"write",
"(",
"content",
")",
"if",
"file_is_async",
":",
"yield",
"from",
"file",
".",
"drain",
"(",
")",
"trailer_data",
"=",
"yield",
"from",
"reader",
".",
"read_trailer",
"(",
")",
"self",
".",
"_data_event_dispatcher",
".",
"notify_read",
"(",
"trailer_data",
")",
"if",
"file",
"and",
"raw",
":",
"file",
".",
"write",
"(",
"trailer_data",
")",
"if",
"file_is_async",
":",
"yield",
"from",
"file",
".",
"drain",
"(",
")",
"response",
".",
"fields",
".",
"parse",
"(",
"trailer_data",
")"
] |
Deletes all keys with a prefix of Key . | async def delete_tree ( self , prefix , * , separator = None ) : response = await self . _discard ( prefix , recurse = True , separator = separator ) return response . body is True | 10,999 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L288-L300 | [
"def",
"oauth_error_handler",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# OAuthErrors should not happen, so they are not caught here. Hence",
"# they will result in a 500 Internal Server Error which is what we",
"# are interested in.",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"OAuthClientError",
"as",
"e",
":",
"current_app",
".",
"logger",
".",
"warning",
"(",
"e",
".",
"message",
",",
"exc_info",
"=",
"True",
")",
"return",
"oauth2_handle_error",
"(",
"e",
".",
"remote",
",",
"e",
".",
"response",
",",
"e",
".",
"code",
",",
"e",
".",
"uri",
",",
"e",
".",
"description",
")",
"except",
"OAuthCERNRejectedAccountError",
"as",
"e",
":",
"current_app",
".",
"logger",
".",
"warning",
"(",
"e",
".",
"message",
",",
"exc_info",
"=",
"True",
")",
"flash",
"(",
"_",
"(",
"'CERN account not allowed.'",
")",
",",
"category",
"=",
"'danger'",
")",
"return",
"redirect",
"(",
"'/'",
")",
"except",
"OAuthRejectedRequestError",
":",
"flash",
"(",
"_",
"(",
"'You rejected the authentication request.'",
")",
",",
"category",
"=",
"'info'",
")",
"return",
"redirect",
"(",
"'/'",
")",
"except",
"AlreadyLinkedError",
":",
"flash",
"(",
"_",
"(",
"'External service is already linked to another account.'",
")",
",",
"category",
"=",
"'danger'",
")",
"return",
"redirect",
"(",
"url_for",
"(",
"'invenio_oauthclient_settings.index'",
")",
")",
"return",
"inner"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.