_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q34900
ConfigParser.next
train
def next(self): """ Return the next token. Keep track of our current position in the config for nice errors. """ if self.current_token == len(self.tokens): return None token = self.tokens[self.current_token] if token["type"] == "newline": ...
python
{ "resource": "" }
q34901
ConfigParser.remove_quotes
train
def remove_quotes(self, value): """ Remove any surrounding quotes from a value and unescape any contained quotes of that type. """ # beware the empty string if not value: return value if value[0] == value[-1] == '"': return value[1:-1].rep...
python
{ "resource": "" }
q34902
ConfigParser.make_value
train
def make_value(self, value): """ Converts to actual value, or remains as string. """ # ensure any escape sequences are converted to unicode value = self.unicode_escape_sequence_fix(value) if value and value[0] in ['"', "'"]: return self.remove_quotes(value) ...
python
{ "resource": "" }
q34903
ConfigParser.config_function
train
def config_function(self, token): """ Process a config function from a token """ match = token["match"] function = match.group(2).lower() param = match.group(3) or "" value_type = match.group(6) or "auto" # fix any escaped closing parenthesis para...
python
{ "resource": "" }
q34904
ConfigParser.value_convert
train
def value_convert(self, value, value_type): """ convert string into type used by `config functions` """ CONVERSION_OPTIONS = { "str": str, "int": int, "float": float, # Treat booleans specially "bool": (lambda val: val.lower() i...
python
{ "resource": "" }
q34905
ConfigParser.make_value_from_env
train
def make_value_from_env(self, param, value_type, function): """ get environment variable """ value = os.getenv(param) if value is None: self.notify_user("Environment variable `%s` undefined" % param) return self.value_convert(value, value_type)
python
{ "resource": "" }
q34906
ConfigParser.make_value_from_shell
train
def make_value_from_shell(self, param, value_type, function): """ run command in the shell """ try: value = check_output(param, shell=True).rstrip() except CalledProcessError: # for value_type of 'bool' we return False on error code if value_ty...
python
{ "resource": "" }
q34907
ConfigParser.make_function_value_private
train
def make_function_value_private(self, value, value_type, function): """ Wraps converted value so that it is hidden in logs etc. Note this is not secure just reduces leaking info Allows base 64 encode stuff using base64() or plain hide() in the config """ # remove...
python
{ "resource": "" }
q34908
ConfigParser.separator
train
def separator(self, separator=",", end_token=None): """ Read through tokens till the required separator is found. We ignore newlines. If an end token is supplied raise a ParseEnd exception if it is found. """ while True: token = self.next() t_val...
python
{ "resource": "" }
q34909
ConfigParser.make_list
train
def make_list(self, end_token="]"): """ We are in a list so get values until the end token. This can also used to get tuples. """ out = [] while True: try: value = self.value_assign(end_token=end_token) out.append(value) ...
python
{ "resource": "" }
q34910
ConfigParser.dict_key
train
def dict_key(self): """ Find the next key in a dict. We skip any newlines and check for if the dict has ended. """ while True: token = self.next() t_value = token["value"] if t_value == "\n": continue if t_value == ...
python
{ "resource": "" }
q34911
ConfigParser.make_dict
train
def make_dict(self): """ We are in a dict so get key value pairs until the end token. """ out = {} while True: try: key = self.dict_key() self.separator(separator=":") value = self.value_assign(end_token="]") ...
python
{ "resource": "" }
q34912
ConfigParser.module_def
train
def module_def(self): """ This is a module definition so parse content till end. """ if self.module_level == MAX_NESTING_LEVELS: self.error("Module nested too deep") self.module_level += 1 module = ModuleDefinition() self.parse(module, end_token="}") ...
python
{ "resource": "" }
q34913
ConfigParser.process_value
train
def process_value(self, name, value, module_name): """ This method allow any encodings to be dealt with. Currently only base64 is supported. Note: If other encodings are added then this should be split so that there is a method for each encoding. """ # if we have...
python
{ "resource": "" }
q34914
ConfigParser.parse
train
def parse(self, dictionary=None, end_token=None): """ Parse through the tokens. Finding names and values. This is called at the start of parsing the config but is also called to parse module definitions. """ self.level += 1 name = [] if dictionary is None:...
python
{ "resource": "" }
q34915
Py3status.on_click
train
def on_click(self, event): """ Control moc with mouse clicks. """ button = event["button"] if button == self.button_pause: if self.state == "STOP": self.py3.command_run("mocp --play") else: self.py3.command_run("mocp --toggl...
python
{ "resource": "" }
q34916
Py3._thresholds_init
train
def _thresholds_init(self): """ Initiate and check any thresholds set """ thresholds = getattr(self._py3status_module, "thresholds", []) self._thresholds = {} if isinstance(thresholds, list): try: thresholds.sort() except TypeError:...
python
{ "resource": "" }
q34917
Py3._report_exception
train
def _report_exception(self, msg, frame_skip=2): """ THIS IS PRIVATE AND UNSUPPORTED. logs an exception that occurs inside of a Py3 method. We only log the exception once to prevent spamming the logs and we do not notify the user. frame_skip is used to change the place i...
python
{ "resource": "" }
q34918
Py3.flatten_dict
train
def flatten_dict(self, d, delimiter="-", intermediates=False, parent_key=None): """ Flatten a dictionary. Values that are dictionaries are flattened using delimiter in between (eg. parent-child) Values that are lists are flattened using delimiter followed by the index (...
python
{ "resource": "" }
q34919
Py3.is_my_event
train
def is_my_event(self, event): """ Checks if an event triggered belongs to the module receiving it. This is mainly for containers who will also receive events from any children they have. Returns True if the event name and instance match that of the module checking. ...
python
{ "resource": "" }
q34920
Py3.log
train
def log(self, message, level=LOG_INFO): """ Log the message. The level must be one of LOG_ERROR, LOG_INFO or LOG_WARNING """ assert level in [ self.LOG_ERROR, self.LOG_INFO, self.LOG_WARNING, ], "level must be LOG_ERROR, LOG_INFO or LOG...
python
{ "resource": "" }
q34921
Py3.update
train
def update(self, module_name=None): """ Update a module. If module_name is supplied the module of that name is updated. Otherwise the module calling is updated. """ if not module_name: return self._module.force_update() else: module_info = self._...
python
{ "resource": "" }
q34922
Py3.get_output
train
def get_output(self, module_name): """ Return the output of the named module. This will be a list. """ output = [] module_info = self._get_module_info(module_name) if module_info: output = module_info["module"].get_latest() # we do a deep copy so that...
python
{ "resource": "" }
q34923
Py3.trigger_event
train
def trigger_event(self, module_name, event): """ Trigger an event on a named module. """ if module_name: self._py3_wrapper.events_thread.process_event(module_name, event)
python
{ "resource": "" }
q34924
Py3.notify_user
train
def notify_user(self, msg, level="info", rate_limit=5, title=None, icon=None): """ Send a notification to the user. level must be 'info', 'error' or 'warning'. rate_limit is the time period in seconds during which this message should not be repeated. icon must be an icon ...
python
{ "resource": "" }
q34925
Py3.register_function
train
def register_function(self, function_name, function): """ Register a function for the module. The following functions can be registered .. py:function:: content_function() Called to discover what modules a container is displaying. This is used to determi...
python
{ "resource": "" }
q34926
Py3.time_in
train
def time_in(self, seconds=None, sync_to=None, offset=0): """ Returns the time a given number of seconds into the future. Helpful for creating the ``cached_until`` value for the module output. .. note:: from version 3.1 modules no longer need to explicitly set a ...
python
{ "resource": "" }
q34927
Py3.format_contains
train
def format_contains(self, format_string, names): """ Determines if ``format_string`` contains a placeholder string ``names`` or a list of placeholders ``names``. ``names`` is tested against placeholders using fnmatch so the following patterns can be used: .. code-block:...
python
{ "resource": "" }
q34928
Py3.get_color_names_list
train
def get_color_names_list(self, format_strings): """ Returns a list of color names in ``format_string``. :param format_strings: Accepts a format string or a list of format strings. """ if not format_strings: return [] if not getattr(self._py3status_module, "th...
python
{ "resource": "" }
q34929
Py3.get_placeholders_list
train
def get_placeholders_list(self, format_string, matches=None): """ Returns a list of placeholders in ``format_string``. If ``matches`` is provided then it is used to filter the result using fnmatch so the following patterns can be used: .. code-block:: none * ...
python
{ "resource": "" }
q34930
Py3.safe_format
train
def safe_format( self, format_string, param_dict=None, force_composite=False, attr_getter=None ): r""" Parser for advanced formatting. Unknown placeholders will be shown in the output eg ``{foo}``. Square brackets ``[]`` can be used. The content of them will be removed ...
python
{ "resource": "" }
q34931
Py3.check_commands
train
def check_commands(self, cmd_list): """ Checks to see if commands in list are available using ``which``. returns the first available command. If a string is passed then that command will be checked for. """ # if a string is passed then convert it to a list. This preven...
python
{ "resource": "" }
q34932
Py3.command_run
train
def command_run(self, command): """ Runs a command and returns the exit code. The command can either be supplied as a sequence or string. An Exception is raised if an error occurs """ # convert the command to sequence if a string if isinstance(command, basestring...
python
{ "resource": "" }
q34933
Py3.command_output
train
def command_output( self, command, shell=False, capture_stderr=False, localized=False ): """ Run a command and return its output as unicode. The command can either be supplied as a sequence or string. :param command: command to run can be a str or list :param shell: ...
python
{ "resource": "" }
q34934
Py3._storage_init
train
def _storage_init(self): """ Ensure that storage is initialized. """ if not self._storage.initialized: self._storage.init(self._module._py3_wrapper, self._is_python_2)
python
{ "resource": "" }
q34935
Py3.storage_set
train
def storage_set(self, key, value): """ Store a value for the module. """ if not self._module: return self._storage_init() module_name = self._module.module_full_name return self._storage.storage_set(module_name, key, value)
python
{ "resource": "" }
q34936
Py3.storage_get
train
def storage_get(self, key): """ Retrieve a value for the module. """ if not self._module: return self._storage_init() module_name = self._module.module_full_name return self._storage.storage_get(module_name, key)
python
{ "resource": "" }
q34937
Py3.storage_del
train
def storage_del(self, key=None): """ Remove the value stored with the key from storage. If key is not supplied then all values for the module are removed. """ if not self._module: return self._storage_init() module_name = self._module.module_full_name ...
python
{ "resource": "" }
q34938
Py3.storage_keys
train
def storage_keys(self): """ Return a list of the keys for values stored for the module. Keys will contain the following metadata entries: - '_ctime': storage creation timestamp - '_mtime': storage last modification timestamp """ if not self._module: r...
python
{ "resource": "" }
q34939
Py3.storage_items
train
def storage_items(self): """ Return key, value pairs of the stored data for the module. Keys will contain the following metadata entries: - '_ctime': storage creation timestamp - '_mtime': storage last modification timestamp """ if not self._module: r...
python
{ "resource": "" }
q34940
Py3.play_sound
train
def play_sound(self, sound_file): """ Plays sound_file if possible. """ self.stop_sound() if sound_file: cmd = self.check_commands(["ffplay", "paplay", "play"]) if cmd: if cmd == "ffplay": cmd = "ffplay -autoexit -nodisp...
python
{ "resource": "" }
q34941
Py3.threshold_get_color
train
def threshold_get_color(self, value, name=None): """ Obtain color for a value using thresholds. The value will be checked against any defined thresholds. These should have been set in the i3status configuration. If more than one threshold is needed for a module then the name c...
python
{ "resource": "" }
q34942
Py3.request
train
def request( self, url, params=None, data=None, headers=None, timeout=None, auth=None, cookiejar=None, ): """ Make a request to a url and retrieve the results. If the headers parameter does not provide an 'User-Agent' key, one ...
python
{ "resource": "" }
q34943
Py3status._get_ip
train
def _get_ip(self, interface): """ Returns the interface's IPv4 address if device exists and has a valid ip address. Otherwise, returns an empty string """ if interface in ni.interfaces(): addresses = ni.ifaddresses(interface) if ni.AF_INET in addresses: ...
python
{ "resource": "" }
q34944
Py3status.on_click
train
def on_click(self, event): """ Display a notification following the specified format """ if not self.notification: return if self.charging: format = self.format_notify_charging else: format = self.format_notify_discharging mes...
python
{ "resource": "" }
q34945
Py3status._extract_battery_info_from_acpi
train
def _extract_battery_info_from_acpi(self): """ Get the battery info from acpi # Example acpi -bi raw output (Discharging): Battery 0: Discharging, 94%, 09:23:28 remaining Battery 0: design capacity 5703 mAh, last full capacity 5283 mAh = 92% Battery 1: Unknown, 98% ...
python
{ "resource": "" }
q34946
Py3status.example_method
train
def example_method(self, i3s_output_list, i3s_config): """ This method will return an empty text message so it will NOT be displayed on your i3bar. If you want something displayed you should write something in the 'full_text' key of your response. See the i3bar protocol...
python
{ "resource": "" }
q34947
Py3status.on_click
train
def on_click(self, event): """ Toggle between display modes 'ip' and 'status' """ button = event["button"] if button == self.button_toggle: self.toggled = True if self.mode == "ip": self.mode = "status" else: sel...
python
{ "resource": "" }
q34948
Py3status._get_layout
train
def _get_layout(self): """ Get the outputs layout from xrandr and try to detect the currently active layout as best as we can on start. """ connected = list() active_layout = list() disconnected = list() layout = OrderedDict( {"connected": Orde...
python
{ "resource": "" }
q34949
Py3status._set_available_combinations
train
def _set_available_combinations(self): """ Generate all connected outputs combinations and set the max display width while iterating. """ available = set() combinations_map = {} whitelist = None if self.output_combinations: whitelist = self.ou...
python
{ "resource": "" }
q34950
Py3status._get_string_and_set_width
train
def _get_string_and_set_width(self, combination, mode): """ Construct the string to be displayed and record the max width. """ show = "{}".format(self._separator(mode)).join(combination) show = show.rstrip("{}".format(self._separator(mode))) self.max_width = max([self.max...
python
{ "resource": "" }
q34951
Py3status._choose_what_to_display
train
def _choose_what_to_display(self, force_refresh=False): """ Choose what combination to display on the bar. By default we try to display the active layout on the first run, else we display the last selected combination. """ for _ in range(len(self.available_combinations))...
python
{ "resource": "" }
q34952
Py3status._apply_workspaces
train
def _apply_workspaces(self, combination, mode): """ Allows user to force move a comma separated list of workspaces to the given output when it's activated. Example: - DP1_workspaces = "1,2,3" """ if len(combination) > 1 and mode == "extend": sleep...
python
{ "resource": "" }
q34953
Py3status._fallback_to_available_output
train
def _fallback_to_available_output(self): """ Fallback to the first available output when the active layout was composed of only one output. This allows us to avoid cases where you get stuck with a black sreen on your laptop by switching back to the integrated screen auto...
python
{ "resource": "" }
q34954
Py3status._force_force_on_start
train
def _force_force_on_start(self): """ Force the user configured mode on start. """ if self.force_on_start in self.available_combinations: self.displayed = self.force_on_start self._choose_what_to_display(force_refresh=True) self._apply(force=True) ...
python
{ "resource": "" }
q34955
Py3status._force_on_change
train
def _force_on_change(self): """ Handle force_on_change feature. """ for layout in self.force_on_change: if layout in self.available_combinations: if self.active_layout != layout: self.displayed = layout self._apply(force...
python
{ "resource": "" }
q34956
Py3status.xrandr
train
def xrandr(self): """ This is the main py3status method, it will orchestrate what's being displayed on the bar. """ self.layout = self._get_layout() self._set_available_combinations() self._choose_what_to_display() if len(self.available_combinations) < 2 ...
python
{ "resource": "" }
q34957
Py3status._set_optimal_area
train
def _set_optimal_area(self, data): """ Reduce the zone to reduce the size of fetched data on refresh """ lats = [station["latitude"] for station in data.values()] longs = [station["longitude"] for station in data.values()] self.gps.update( { "g...
python
{ "resource": "" }
q34958
Py3status._get_text
train
def _get_text(self): """ Get the current metadata """ if self._data.get("state") == PLAYING: color = self.py3.COLOR_PLAYING or self.py3.COLOR_GOOD state_symbol = self.state_play elif self._data.get("state") == PAUSED: color = self.py3.COLOR_PAU...
python
{ "resource": "" }
q34959
Py3status._set_player
train
def _set_player(self): """ Sort the current players into priority order and set self._player Players are ordered by working state then prefernce supplied by user and finally by instance if a player has more than one running. """ players = [] for name, p in self._m...
python
{ "resource": "" }
q34960
Py3status._add_player
train
def _add_player(self, player_id): """ Add player to mpris_players """ if not player_id.startswith(SERVICE_BUS): return False player = self._dbus.get(player_id, SERVICE_BUS_URL) if player.Identity not in self._mpris_names: self._mpris_names[player...
python
{ "resource": "" }
q34961
Py3status._remove_player
train
def _remove_player(self, player_id): """ Remove player from mpris_players """ player = self._mpris_players.get(player_id) if player: if player.get("subscription"): player["subscription"].disconnect() del self._mpris_players[player_id]
python
{ "resource": "" }
q34962
Py3status.mpris
train
def mpris(self): """ Get the current output format and return it. """ if self._kill: raise KeyboardInterrupt current_player_id = self._player_details.get("id") cached_until = self.py3.CACHE_FOREVER if self._player is None: text = self.form...
python
{ "resource": "" }
q34963
Py3status.on_click
train
def on_click(self, event): """ Handles click events """ index = event["index"] button = event["button"] if index not in self._control_states.keys(): if button == self.button_toggle: index = "toggle" elif button == self.button_stop:...
python
{ "resource": "" }
q34964
Py3status._get_timezone
train
def _get_timezone(self, tz): """ Find and return the time zone if possible """ # special Local timezone if tz == "Local": try: return tzlocal.get_localzone() except pytz.UnknownTimeZoneError: return "?" # we can use...
python
{ "resource": "" }
q34965
setup
train
def setup(sphinx): """ This will be called by sphinx. """ create_auto_documentation() # add the py3status lexer (for code blocks) from sphinx.highlighting import lexers lexers['py3status'] = Py3statusLexer() # enable screenshot directive for dynamic screenshots sphinx.add_directive...
python
{ "resource": "" }
q34966
Py3status._compile_re
train
def _compile_re(self, expression): """ Compile given regular expression for current sanitize words """ meta_words = "|".join(self.sanitize_words) expression = expression.replace("META_WORDS_HERE", meta_words) return re.compile(expression, re.IGNORECASE)
python
{ "resource": "" }
q34967
Py3status._sanitize_title
train
def _sanitize_title(self, title): """ Remove redunant meta data from title and return it """ title = re.sub(self.inside_brackets, "", title) title = re.sub(self.after_delimiter, "", title) return title.strip()
python
{ "resource": "" }
q34968
Py3status.spotify
train
def spotify(self): """ Get the current "artist - title" and return it. """ (text, color) = self._get_text() response = { "cached_until": self.py3.time_in(self.cache_timeout), "color": color, "full_text": text, } return response
python
{ "resource": "" }
q34969
Storage.get_legacy_storage_path
train
def get_legacy_storage_path(self): """ Detect and return existing legacy storage path. """ config_dir = os.path.dirname( self.py3_wrapper.config.get("i3status_config_path", "/tmp") ) storage_path = os.path.join(config_dir, "py3status.data") if os.path....
python
{ "resource": "" }
q34970
Storage.save
train
def save(self): """ Save our data to disk. We want to always have a valid file. """ with NamedTemporaryFile( dir=os.path.dirname(self.storage_path), delete=False ) as f: # we use protocol=2 for python 2/3 compatibility dump(self.data, f, protoc...
python
{ "resource": "" }
q34971
Py3status.secs_to_dhms
train
def secs_to_dhms(time_in_secs): """Convert seconds to days, hours, minutes, seconds. Using days as the largest unit of time. Blindly using the days in `time.gmtime()` will fail if it's more than one month (days > 31). """ days = int(time_in_secs / SECS_IN_DAY) remaining...
python
{ "resource": "" }
q34972
Py3status._setup_bar
train
def _setup_bar(self): """ Setup the process bar. """ bar = u"" items_cnt = len(PROGRESS_BAR_ITEMS) bar_val = float(self._time_left) / self._section_time * self.num_progress_bars while bar_val > 0: selector = int(bar_val * items_cnt) selecto...
python
{ "resource": "" }
q34973
Py3status.pomodoro
train
def pomodoro(self): """ Pomodoro response handling and countdown """ if not self._initialized: self._init() cached_until = self.py3.time_in(0) if self._running: self._time_left = ceil(self._end_time - time()) time_left = ceil(self._tim...
python
{ "resource": "" }
q34974
UdevMonitor._setup_pyudev_monitoring
train
def _setup_pyudev_monitoring(self): """ Setup the udev monitor. """ context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) self.udev_observer = pyudev.MonitorObserver(monitor, self._udev_event) self.udev_observer.start() self.py3_wrapper...
python
{ "resource": "" }
q34975
UdevMonitor.subscribe
train
def subscribe(self, py3_module, trigger_action, subsystem): """ Subscribe the given module to the given udev subsystem. Here we will lazy load the monitor if necessary and return success or failure based on the availability of pyudev. """ if self.pyudev_available: ...
python
{ "resource": "" }
q34976
UdevMonitor.trigger_actions
train
def trigger_actions(self, subsystem): """ Refresh all modules which subscribed to the given subsystem. """ for py3_module, trigger_action in self.udev_consumers[subsystem]: if trigger_action in ON_TRIGGER_ACTIONS: self.py3_wrapper.log( "%s ...
python
{ "resource": "" }
q34977
I3statusModule.run
train
def run(self): """ updates the modules output. Currently only time and tztime need to do this """ if self.update_time_value(): self.i3status.py3_wrapper.notify_update(self.module_name) due_time = self.py3.time_in(sync_to=self.time_delta) self.i3status...
python
{ "resource": "" }
q34978
I3statusModule.update_from_item
train
def update_from_item(self, item): """ Update from i3status output. returns if item has changed. """ if not self.is_time_module: # correct the output # Restore the name/instance. item["name"] = self.name item["instance"] = self.instance ...
python
{ "resource": "" }
q34979
I3statusModule.set_time_zone
train
def set_time_zone(self, item): """ Work out the time zone and create a shim tzinfo. We return True if all is good or False if there was an issue and we need to re check the time zone. see issue #1375 """ # parse i3status date i3s_time = item["full_text"].encode(...
python
{ "resource": "" }
q34980
I3status.setup
train
def setup(self): """ Do any setup work needed to run i3status modules """ for conf_name in self.py3_config["i3s_modules"]: module = I3statusModule(conf_name, self) self.i3modules[conf_name] = module if module.is_time_module: self.time_m...
python
{ "resource": "" }
q34981
I3status.valid_config_param
train
def valid_config_param(self, param_name, cleanup=False): """ Check if a given section name is a valid parameter for i3status. """ if cleanup: valid_config_params = [ _ for _ in self.i3status_module_names if _ not in ["cpu_usage"...
python
{ "resource": "" }
q34982
I3status.set_responses
train
def set_responses(self, json_list): """ Set the given i3status responses on their respective configuration. """ self.update_json_list() updates = [] for index, item in enumerate(self.json_list): conf_name = self.py3_config["i3s_modules"][index] mo...
python
{ "resource": "" }
q34983
I3status.write_in_tmpfile
train
def write_in_tmpfile(text, tmpfile): """ Write the given text in the given tmpfile in python2 and python3. """ try: tmpfile.write(text) except TypeError: tmpfile.write(str.encode(text)) except UnicodeEncodeError: tmpfile.write(text.enco...
python
{ "resource": "" }
q34984
I3status.write_tmp_i3status_config
train
def write_tmp_i3status_config(self, tmpfile): """ Given a temporary file descriptor, write a valid i3status config file based on the parsed one from 'i3status_config_path'. """ # order += ... for module in self.py3_config["i3s_modules"]: self.write_in_tmpfile(...
python
{ "resource": "" }
q34985
I3status.spawn_i3status
train
def spawn_i3status(self): """ Spawn i3status using a self generated config file and poll its output. """ try: with NamedTemporaryFile(prefix="py3status_") as tmpfile: self.write_tmp_i3status_config(tmpfile) i3status_pipe = Popen( ...
python
{ "resource": "" }
q34986
catch_factory
train
def catch_factory(attr): """ Factory returning a catch function """ def _catch(s, *args, **kw): """ This is used to catch and process all calls. """ def process(value): """ return the actual value after processing """ if a...
python
{ "resource": "" }
q34987
Py3status._github_count
train
def _github_count(self, url): """ Get counts for requests that return 'total_count' in the json response. """ url = self.url_api + url + "&per_page=1" # if we have authentication details use them as we get better # rate-limiting. if self.username and self.auth_tok...
python
{ "resource": "" }
q34988
Py3status._notifications
train
def _notifications(self): """ Get the number of unread notifications. """ if not self.username or not self.auth_token: if not self.notification_warning: self.py3.notify_user( "Github module needs username and " "auth_tok...
python
{ "resource": "" }
q34989
Common.get_config_attribute
train
def get_config_attribute(self, name, attribute): """ Look for the attribute in the config. Start with the named module and then walk up through any containing group and then try the general section of the config. """ # A user can set a param to None in the config to pre...
python
{ "resource": "" }
q34990
Py3statusWrapper.timeout_queue_add
train
def timeout_queue_add(self, item, cache_time=0): """ Add a item to be run at a future time. This must be a Module, I3statusModule or a Task """ # add the info to the add queue. We do this so that actually adding # the module is done in the core thread. self.timeo...
python
{ "resource": "" }
q34991
Py3statusWrapper.timeout_process_add_queue
train
def timeout_process_add_queue(self, module, cache_time): """ Add a module to the timeout_queue if it is scheduled in the future or if it is due for an update immediately just trigger that. the timeout_queue is a dict with the scheduled time as the key and the value is a list of ...
python
{ "resource": "" }
q34992
Py3statusWrapper.timeout_queue_process
train
def timeout_queue_process(self): """ Check the timeout_queue and set any due modules to update. """ # process any items that need adding to the queue while self.timeout_add_queue: self.timeout_process_add_queue(*self.timeout_add_queue.popleft()) now = time.tim...
python
{ "resource": "" }
q34993
Py3statusWrapper.gevent_monkey_patch_report
train
def gevent_monkey_patch_report(self): """ Report effective gevent monkey patching on the logs. """ try: import gevent.socket import socket if gevent.socket.socket is socket.socket: self.log("gevent monkey patching is active") ...
python
{ "resource": "" }
q34994
Py3statusWrapper.get_user_modules
train
def get_user_modules(self): """ Search configured include directories for user provided modules. user_modules: { 'weather_yahoo': ('~/i3/py3status/', 'weather_yahoo.py') } """ user_modules = {} for include_path in self.config["include_paths"]: ...
python
{ "resource": "" }
q34995
Py3statusWrapper.get_user_configured_modules
train
def get_user_configured_modules(self): """ Get a dict of all available and configured py3status modules in the user's i3status.conf. """ user_modules = {} if not self.py3_modules: return user_modules for module_name, module_info in self.get_user_module...
python
{ "resource": "" }
q34996
Py3statusWrapper.notify_user
train
def notify_user( self, msg, level="error", rate_limit=None, module_name="", icon=None, title="py3status", ): """ Display notification to user via i3-nagbar or send-notify We also make sure to log anything to keep trace of it. N...
python
{ "resource": "" }
q34997
Py3statusWrapper.stop
train
def stop(self): """ Set the Event lock, this will break all threads' loops. """ self.running = False # stop the command server try: self.commands_thread.kill() except: # noqa e722 pass try: self.lock.set() ...
python
{ "resource": "" }
q34998
Py3statusWrapper.refresh_modules
train
def refresh_modules(self, module_string=None, exact=True): """ Update modules. if module_string is None all modules are refreshed if module_string then modules with the exact name or those starting with the given string depending on exact parameter will be refreshed. If a...
python
{ "resource": "" }
q34999
Py3statusWrapper.notify_update
train
def notify_update(self, update, urgent=False): """ Name or list of names of modules that have updated. """ if not isinstance(update, list): update = [update] self.update_queue.extend(update) # find containers that use the modules that updated containe...
python
{ "resource": "" }