_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q246400
ConfigOptions.add_option
train
def add_option(self, key, default=NO_VALUE, alternate_keys=NO_VALUE, doc='', parser=str, **meta): """Add an option to the group. :arg key: the key to look up :arg default: the default value (if any); must be a string that is parseable by the specified parser ...
python
{ "resource": "" }
q246401
ConfigOptions.update
train
def update(self, new_options): """Update this ConfigOptions using data from another.""" for option in new_options: if option.key in
python
{ "resource": "" }
q246402
RequiredConfigMixin.get_required_config
train
def get_required_config(cls): """Roll up configuration options for this class and parent classes. This handles subclasses overriding options in parent classes. :returns: final ``ConfigOptions`` representing all configuration for this class """
python
{ "resource": "" }
q246403
RequiredConfigMixin.get_runtime_config
train
def get_runtime_config(self, namespace=None): """Roll up the runtime config for this class and all children. Implement this to call ``.get_runtime_config()`` on child components or to adjust how it works. For example, if you created a component that has a child component, you c...
python
{ "resource": "" }
q246404
ConfigIniEnv.parse_ini_file
train
def parse_ini_file(self, path): """Parse ini file at ``path`` and return dict.""" cfgobj = ConfigObj(path, list_values=False) def extract_section(namespace, d): cfg = {} for key, val in d.items(): if isinstance(d[key], dict):
python
{ "resource": "" }
q246405
TBA.team
train
def team(self, team, simple=False): """ Get data on a single specified team. :param team: Team to get data for.
python
{ "resource": "" }
q246406
TBA.team_events
train
def team_events(self, team, year=None, simple=False, keys=False): """ Get team events a team has participated in. :param team: Team to get events for. :param year: Year to get events from. :param simple: Get only vital data. :param keys: Get just the keys of the events. ...
python
{ "resource": "" }
q246407
TBA.team_awards
train
def team_awards(self, team, year=None, event=None): """ Get list of awards team has recieved. :param team: Team to get awards of. :param year: Year to get awards from. :param event: Event to get awards from. :return: List of Award objects """ if event: ...
python
{ "resource": "" }
q246408
TBA.team_matches
train
def team_matches(self, team, event=None, year=None, simple=False, keys=False): """ Get list of matches team has participated in. :param team: Team to get matches of. :param year: Year to get matches from. :param event: Event to get matches from. :param simple: Get only v...
python
{ "resource": "" }
q246409
TBA.team_media
train
def team_media(self, team, year=None, tag=None): """ Get media for a given team. :param team: Team to get media of. :param year: Year to get media from. :param tag: Get only media with a given tag. :return: List of Media objects.
python
{ "resource": "" }
q246410
TBA.team_robots
train
def team_robots(self, team): """ Get data about a team's robots. :param team: Key for team whose robots
python
{ "resource": "" }
q246411
TBA.team_districts
train
def team_districts(self, team): """ Get districts a team has competed in. :param team: Team to get
python
{ "resource": "" }
q246412
TBA.team_profiles
train
def team_profiles(self, team): """ Get team's social media profiles linked on their TBA page. :param team: Team
python
{ "resource": "" }
q246413
TBA.team_status
train
def team_status(self, team, event): """ Get status of a team at an event. :param team: Team whose status to get.
python
{ "resource": "" }
q246414
TBA.events
train
def events(self, year, simple=False, keys=False): """ Get a list of events in a given year. :param year: Year to get events from. :param keys: Get only keys of the events rather than full data.
python
{ "resource": "" }
q246415
TBA.event
train
def event(self, event, simple=False): """ Get basic information about an event. More specific data (typically obtained with the detail_type URL parameter) can be obtained with event_alliances(), event_district_points(), event_insights(), event_oprs(),
python
{ "resource": "" }
q246416
TBA.event_teams
train
def event_teams(self, event, simple=False, keys=False): """ Get list of teams at an event. :param event: Event key to get data on. :param simple: Get only vital data. :param keys: Return list of team keys only rather than full data on every team. :return: List of string ...
python
{ "resource": "" }
q246417
TBA.event_matches
train
def event_matches(self, event, simple=False, keys=False): """ Get list of matches played at an event. :param event: Event key to get data on. :param keys: Return list of match keys only rather than full data on every
python
{ "resource": "" }
q246418
TBA.match
train
def match(self, key=None, year=None, event=None, type='qm', number=None, round=None, simple=False): """ Get data on a match. You may either pass the match's key directly, or pass `year`, `event`, `type`, `match` (the match number), and `round` if applicable (playoffs only). The event year may b...
python
{ "resource": "" }
q246419
TBA.district_events
train
def district_events(self, district, simple=False, keys=False): """ Return list of events in a given district. :param district: Key of district whose events you want. :param simple: Get only vital data. :param keys: Return list of event keys only rather than full data on every ev...
python
{ "resource": "" }
q246420
TBA.district_teams
train
def district_teams(self, district, simple=False, keys=False): """ Get list of teams in the given district. :param district: Key for the district to get teams in. :param simple: Get only vital data. :param keys: Return list of team keys only rather than full data on every team. ...
python
{ "resource": "" }
q246421
TBA.update_trusted
train
def update_trusted(self, auth_id, auth_secret, event_key): """ Set Trusted API ID and Secret and the event key they are assigned to. :param auth_id: Your event authorization ID, obtainable at https://www.thebluealliance.com/request/apiwrite
python
{ "resource": "" }
q246422
TBA.delete_event_matches
train
def delete_event_matches(self, data=None): """ Delete an event's matches on The Blue Alliance. :param data: List of match keys to delete, can be ommited if you would like to delete all matches.
python
{ "resource": "" }
q246423
ConstraintExpression.from_where
train
def from_where(cls, where): """ Factory method for creating the top-level expression """ if where.conjunction:
python
{ "resource": "" }
q246424
Conjunction._factory
train
def _factory(cls, constraints, op): """ Factory for joining constraints with a single conjunction """ pieces = []
python
{ "resource": "" }
q246425
Conjunction.remove_index
train
def remove_index(self, index): """ This one takes some explanation. When we do a query with a WHERE statement, it may end up being a scan and it may end up being a query. If it is a query, we need to remove the hash and range key constraints from the expression and return that as...
python
{ "resource": "" }
q246426
default
train
def default(value): """ Default encoder for JSON """ if isinstance(value, Decimal): primative = float(value) if int(primative) == primative: return int(primative) else: return primative elif isinstance(value, set):
python
{ "resource": "" }
q246427
add_query_kwargs
train
def add_query_kwargs(kwargs, visitor, constraints, index): """ Construct KeyConditionExpression and FilterExpression """ (query_const, filter_const) = constraints.remove_index(index)
python
{ "resource": "" }
q246428
iter_insert_items
train
def iter_insert_items(tree): """ Iterate over the items to insert from an INSERT statement """ if tree.list_values: keys = tree.attrs for values in tree.list_values: if len(keys) != len(values): raise SyntaxError( "Values '%s' do not match attribut...
python
{ "resource": "" }
q246429
Engine.connect
train
def connect(self, *args, **kwargs): """ Proxy to DynamoDBConnection.connect. """ self.connection = DynamoDBConnection.connect(*args, **kwargs)
python
{ "resource": "" }
q246430
Engine.connection
train
def connection(self, connection): """ Change the dynamo connection """ if connection is not None: connection.subscribe("capacity", self._on_capacity_data) connection.default_return_capacity = True if self._connection is not None:
python
{ "resource": "" }
q246431
Engine.cloudwatch_connection
train
def cloudwatch_connection(self): """ Lazy create a connection to cloudwatch """ if self._cloudwatch_connection is
python
{ "resource": "" }
q246432
Engine._format_explain
train
def _format_explain(self): """ Format the results of an EXPLAIN """ lines = [] for (command, kwargs) in self._call_list:
python
{ "resource": "" }
q246433
Engine._pretty_format
train
def _pretty_format(self, statement, result): """ Format the return value of a query for humans """ if result is None: return "Success" ret = result if statement.action in ("SELECT", "SCAN"): if statement.save_file: filename = statement.save_file[0]...
python
{ "resource": "" }
q246434
Engine.describe_all
train
def describe_all(self, refresh=True): """ Describe all tables in the connected region """ tables = self.connection.list_tables() descs = []
python
{ "resource": "" }
q246435
Engine.execute
train
def execute(self, commands, pretty_format=False): """ Parse and run a DQL string Parameters ---------- commands : str The DQL command string pretty_format : bool Pretty-format the return value. (e.g. 4 -> 'Updated 4 items') """ tr...
python
{ "resource": "" }
q246436
Engine._run
train
def _run(self, tree): """ Run a query from a parse tree """ if tree.throttle: limiter = self._parse_throttle(tree.table, tree.throttle) self._query_rate_limit = limiter del tree["throttle"] return self._run(tree) if tree.action == "SELECT": ...
python
{ "resource": "" }
q246437
Engine._parse_throttle
train
def _parse_throttle(self, tablename, throttle): """ Parse a 'throttle' statement and return a RateLimit """ amount = [] desc = self.describe(tablename) throughputs = [desc.read_throughput, desc.write_throughput] for value, throughput in zip(throttle[1:], throughputs):
python
{ "resource": "" }
q246438
Engine._on_capacity_data
train
def _on_capacity_data(self, conn, command, kwargs, response, capacity): """ Log the received consumed capacity data """ if self._analyzing: self.consumed_capacities.append((command, capacity)) if self._query_rate_limit is not None: self._query_rate_limit.on_capacity( ...
python
{ "resource": "" }
q246439
Engine._on_throttle
train
def _on_throttle(self, conn, command, kwargs, response, capacity, seconds): """ Print out a message when the query is throttled """ LOG.info(
python
{ "resource": "" }
q246440
Engine._explain
train
def _explain(self, tree): """ Set up the engine to do a dry run of a query """ self._explaining = True self._call_list = [] old_call = self.connection.call def fake_call(command, **kwargs): """ Replacement for connection.call that logs args """ if command...
python
{ "resource": "" }
q246441
Engine._iter_where_in
train
def _iter_where_in(self, tree): """ Iterate over the KEYS IN and generate primary keys """ desc = self.describe(tree.table, require=True)
python
{ "resource": "" }
q246442
Engine._query_and_op
train
def _query_and_op(self, tree, table, method_name, method_kwargs): """ Query the table and perform an operation on each item """ result = [] if tree.keys_in: if tree.using: raise SyntaxError("Cannot use USING with KEYS IN") keys = self._iter_where_in(tree) ...
python
{ "resource": "" }
q246443
Engine._delete
train
def _delete(self, tree): """ Run a DELETE statement """ tablename = tree.table table = self.describe(tablename, require=True) kwargs = {} visitor = Visitor(self.reserved_words) if tree.where: constraints = ConstraintExpression.from_where(tree.where) ...
python
{ "resource": "" }
q246444
Engine._update
train
def _update(self, tree): """ Run an UPDATE statement """ tablename = tree.table table = self.describe(tablename, require=True) kwargs = {} if tree.returns: kwargs["returns"] = "_".join(tree.returns) else: kwargs["returns"] = "NONE" visito...
python
{ "resource": "" }
q246445
Engine._parse_global_index
train
def _parse_global_index(self, clause, attrs): """ Parse a global index clause and return a GlobalIndex """ index_type, name = clause[:2] name = resolve(name) def get_key(field, data_type=None): """ Get or set the DynamoKey from the field name """ if field in attr...
python
{ "resource": "" }
q246446
Engine._insert
train
def _insert(self, tree): """ Run an INSERT statement """ tablename = tree.table count = 0 kwargs = {}
python
{ "resource": "" }
q246447
Engine._drop
train
def _drop(self, tree): """ Run a DROP statement """ tablename = tree.table kwargs = {} try: ret = self.connection.delete_table(tablename, **kwargs) except DynamoDBError as e:
python
{ "resource": "" }
q246448
Engine._update_throughput
train
def _update_throughput(self, tablename, read, write, index): """ Update the throughput on a table or index """ def get_desc(): """ Get the table or global index description """ desc = self.describe(tablename, refresh=True, require=True) if index is not None: ...
python
{ "resource": "" }
q246449
Engine._alter
train
def _alter(self, tree): """ Run an ALTER statement """ if tree.throughput: [read, write] = tree.throughput index = None if tree.index: index = tree.index self._update_throughput(tree.table, read, write, index) elif tree.drop_index: ...
python
{ "resource": "" }
q246450
Engine._dump
train
def _dump(self, tree): """ Run a DUMP statement """ schema = [] if tree.tables: for table in tree.tables: desc = self.describe(table, refresh=True, require=True) schema.append(desc.schema) else:
python
{ "resource": "" }
q246451
Engine._load
train
def _load(self, tree): """ Run a LOAD statement """ filename = tree.load_file[0] if filename[0] in ['"', "'"]: filename = unwrap(filename) if not os.path.exists(filename): raise Exception("No such file %r" % filename) batch = self.connection.batch_write(tr...
python
{ "resource": "" }
q246452
FragmentEngine.execute
train
def execute(self, fragment, pretty_format=True): """ Run or aggregate a query fragment Concat the fragment to any stored fragments. If they form a complete query, run it and return the result. If not, store them and return None. """ self.fragments = (self.fragme...
python
{ "resource": "" }
q246453
FragmentEngine.pformat_exc
train
def pformat_exc(self, exc): """ Format an exception message for the last query's parse error """ lines = [] try: pre_nl = self.last_query.rindex("\n", 0, exc.loc) + 1 except ValueError:
python
{ "resource": "" }
q246454
UpdateExpression.from_update
train
def from_update(cls, update): """ Factory for creating an Update expression """ expressions = [] if update.set_expr: expressions.append(UpdateSetMany.from_clause(update.set_expr)) if update.remove_expr: expressions.append(UpdateRemove.from_clause(update.remove_exp...
python
{ "resource": "" }
q246455
TableField.to_index
train
def to_index(self, index_type, index_name, includes=None): """ Create an index
python
{ "resource": "" }
q246456
GlobalIndex.from_description
train
def from_description(cls, description, attrs): """ Create an object from a dynamo3 response """ hash_key = None range_key = None index_type = description["Projection"]["ProjectionType"] includes = description["Projection"].get("NonKeyAttributes") for data in description["...
python
{ "resource": "" }
q246457
GlobalIndex.pformat
train
def pformat(self, consumed_capacity=None): """ Pretty format for insertion into table pformat """ consumed_capacity = consumed_capacity or {} lines = [] parts = ["GLOBAL", self.index_type, "INDEX", self.name] if self.status != "ACTIVE": parts.insert(0, "[%s]" % self.s...
python
{ "resource": "" }
q246458
GlobalIndex.schema
train
def schema(self): """ The DQL fragment for constructing this index """ if self.status == "DELETING": return "" parts = ["GLOBAL", self.index_type, "INDEX"] parts.append("('%s', %s," % (self.name, self.hash_key.name)) if self.range_key: parts.append("%s," %...
python
{ "resource": "" }
q246459
TableMeta.get_matching_indexes
train
def get_matching_indexes(self, possible_hash, possible_range): """ Get all indexes that could be queried on using a set of keys. If any indexes match both hash AND range keys, indexes that only match the hash key will be excluded from the result. Parameters ---------- ...
python
{ "resource": "" }
q246460
TableMeta.get_indexes
train
def get_indexes(self): """ Get a dict of index names to index """ ret = {} for index in
python
{ "resource": "" }
q246461
TableMeta.from_description
train
def from_description(cls, table): """ Factory method that uses the dynamo3 'describe' return value """ throughput = table.provisioned_throughput attrs = {} for data in getattr(table, "attribute_definitions", []): field = TableField(data["AttributeName"], TYPES_REV[data["Attri...
python
{ "resource": "" }
q246462
TableMeta.primary_key_attributes
train
def primary_key_attributes(self): """ Get the names of the primary key attributes as a tuple """ if self.range_key is None:
python
{ "resource": "" }
q246463
TableMeta.primary_key_tuple
train
def primary_key_tuple(self, item): """ Get the primary key tuple from an item """ if self.range_key is None: return (item[self.hash_key.name],)
python
{ "resource": "" }
q246464
TableMeta.primary_key
train
def primary_key(self, hkey, rkey=None): """ Construct a primary key dictionary You can either pass in a (hash_key[, range_key]) as the arguments, or you may pass in an Item itself """ if isinstance(hkey, dict): def decode(val): """ Convert D...
python
{ "resource": "" }
q246465
TableMeta.total_read_throughput
train
def total_read_throughput(self): """ Combined read throughput of table and global indexes """ total = self.read_throughput
python
{ "resource": "" }
q246466
TableMeta.total_write_throughput
train
def total_write_throughput(self): """ Combined write throughput of table and global indexes """ total = self.write_throughput
python
{ "resource": "" }
q246467
TableMeta.schema
train
def schema(self): """ The DQL query that will construct this table's schema """ attrs = self.attrs.copy() parts = ["CREATE", "TABLE", self.name, "(%s," % self.hash_key.schema] del attrs[self.hash_key.name] if self.range_key: parts.append(self.range_key.schema + ",")
python
{ "resource": "" }
q246468
TableMeta.pformat
train
def pformat(self): """ Pretty string format """ lines = [] lines.append(("%s (%s)" % (self.name, self.status)).center(50, "-")) lines.append("items: {0:,} ({1:,} bytes)".format(self.item_count, self.size)) cap = self.consumed_capacity.get("__table__", {}) read = "Read: " ...
python
{ "resource": "" }
q246469
resolve
train
def resolve(val): """ Convert a pyparsing value to the python type """ name = val.getName() if name == "number": try: return int(val.number) except ValueError: return Decimal(val.number) elif name == "str": return unwrap(val.str) elif name == "null": ...
python
{ "resource": "" }
q246470
dt_to_ts
train
def dt_to_ts(value): """ If value is a datetime, convert to timestamp """ if not isinstance(value,
python
{ "resource": "" }
q246471
eval_function
train
def eval_function(value): """ Evaluate a timestamp function """ name, args = value[0], value[1:] if name == "NOW": return datetime.utcnow().replace(tzinfo=tzutc()) elif name in ["TIMESTAMP", "TS"]: return parse(unwrap(args[0])).replace(tzinfo=tzlocal()) elif name in
python
{ "resource": "" }
q246472
eval_interval
train
def eval_interval(interval): """ Evaluate an interval expression """ kwargs = { "years": 0, "months": 0, "weeks": 0, "days": 0, "hours": 0, "minutes": 0, "seconds": 0, "microseconds": 0, } for section in interval[1:]: name = section...
python
{ "resource": "" }
q246473
eval_expression
train
def eval_expression(value): """ Evaluate a full time expression """ start = eval_function(value.ts_expression[0]) interval = eval_interval(value.ts_expression[2])
python
{ "resource": "" }
q246474
linkcode_resolve
train
def linkcode_resolve(domain, info): """ Link source code to github """ if domain != 'py' or not info['module']: return None filename = info['module'].replace('.', '/') mod = importlib.import_module(info['module']) basename = os.path.splitext(mod.__file__)[0] if
python
{ "resource": "" }
q246475
Monitor.run
train
def run(self, stdscr): """ Initialize curses and refresh in a loop """ self.win = stdscr curses.curs_set(0) stdscr.timeout(0) curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
python
{ "resource": "" }
q246476
Monitor._calc_min_width
train
def _calc_min_width(self, table): """ Calculate the minimum allowable width for a table """ width = len(table.name) cap = table.consumed_capacity["__table__"] width = max(width, 4 + len("%.1f/%d" % (cap["read"], table.read_throughput))) width = max(width, 4 + len("%.1f/%d" % (cap...
python
{ "resource": "" }
q246477
Monitor._add_throughput
train
def _add_throughput(self, y, x, width, op, title, available, used): """ Write a single throughput measure to a row """ percent = float(used) / available self.win.addstr(y, x, "[") # Because we have disabled scrolling, writing the lower right corner # character in a terminal can t...
python
{ "resource": "" }
q246478
Monitor.refresh
train
def refresh(self, fetch_data): """ Redraw the display """ self.win.erase() height, width = getmaxyx() if curses.is_term_resized(height, width): self.win.clear() curses.resizeterm(height, width) y = 1 # Starts at 1 because of date string x = 0 ...
python
{ "resource": "" }
q246479
add
train
def add(a, b): """ Add two values, ignoring None """ if a is None: if b is None: return None else:
python
{ "resource": "" }
q246480
sub
train
def sub(a, b): """ Subtract two values, ignoring None """ if a is None: if b is None: return None else:
python
{ "resource": "" }
q246481
mul
train
def mul(a, b): """ Multiply two values, ignoring None """ if a is None: if b is None: return None else:
python
{ "resource": "" }
q246482
div
train
def div(a, b): """ Divide two values, ignoring None """ if a is None: if b is None: return None else:
python
{ "resource": "" }
q246483
parse_expression
train
def parse_expression(clause): """ For a clause that could be a field, value, or expression """ if isinstance(clause, Expression): return clause elif hasattr(clause, "getName") and clause.getName() != "field": if clause.getName() == "nested": return AttributeSelection.from_stateme...
python
{ "resource": "" }
q246484
SelectFunction.from_statement
train
def from_statement(cls, statement): """ Create a selection function from a statement """ if statement[0] in ["TS", "TIMESTAMP", "UTCTIMESTAMP", "UTCTS"]: return TimestampFunction.from_statement(statement) elif statement[0] in ["NOW", "UTCNOW"]:
python
{ "resource": "" }
q246485
select_functions
train
def select_functions(expr): """ Create the function expressions for selection """ body = Group(expr) return Group( function("timestamp", body, caseless=True)
python
{ "resource": "" }
q246486
create_selection
train
def create_selection(): """ Create a selection expression """ operation = Forward() nested = Group(Suppress("(") + operation + Suppress(")")).setResultsName("nested") select_expr = Forward() functions = select_functions(select_expr) maybe_nested = functions | nested | Group(var_val) operatio...
python
{ "resource": "" }
q246487
create_query_constraint
train
def create_query_constraint(): """ Create a constraint for a query WHERE clause """ op = oneOf("= < > >= <= != <>", caseless=True).setName("operator") basic_constraint = (var + op + var_val).setResultsName("operator") between = ( var + Suppress(upkey("between")) + value + Suppress(and_) + value ...
python
{ "resource": "" }
q246488
create_where
train
def create_where(): """ Create a grammar for the 'where' clause used by 'select' """ conjunction = Forward().setResultsName("conjunction") nested = Group(Suppress("(") + conjunction + Suppress(")")).setResultsName( "conjunction" ) maybe_nested = nested | constraint inverted = Group(not_...
python
{ "resource": "" }
q246489
create_keys_in
train
def create_keys_in(): """ Create a grammer for the 'KEYS IN' clause used for queries """ keys = Group( Optional(Suppress("(")) + value + Optional(Suppress(",") + value) + Optional(Suppress(")"))
python
{ "resource": "" }
q246490
Field.evaluate
train
def evaluate(self, item): """ Pull the field off the item """ try: for match in PATH_PATTERN.finditer(self.field): path = match.group(0) if path[0] == "[": # If we're selecting an item at a specific index of an # array, ...
python
{ "resource": "" }
q246491
main
train
def main(): """ Build a standalone dql executable """ venv_dir = tempfile.mkdtemp() try: make_virtualenv(venv_dir) print("Downloading dependencies") pip = os.path.join(venv_dir, "bin", "pip") subprocess.check_call([pip, "install", "pex"]) print("Building executable"...
python
{ "resource": "" }
q246492
Visitor._maybe_replace_path
train
def _maybe_replace_path(self, match): """ Regex replacement method that will sub paths when needed """ path = match.group(0)
python
{ "resource": "" }
q246493
Visitor._should_replace
train
def _should_replace(self, path): """ True if should replace the path """ return ( self._reserved_words is None
python
{ "resource": "" }
q246494
Visitor._replace_path
train
def _replace_path(self, path): """ Get the replacement value for a path """ if path in self._field_to_key: return self._field_to_key[path] next_key = "#f%d" % self._next_field
python
{ "resource": "" }
q246495
wrap
train
def wrap(string, length, indent): """ Wrap a string at a line length """ newline = "\n" + " " * indent
python
{ "resource": "" }
q246496
format_json
train
def format_json(json_object, indent): """ Pretty-format json data """ indent_str = "\n" + " " * indent
python
{ "resource": "" }
q246497
delta_to_str
train
def delta_to_str(rd): """ Convert a relativedelta to a human-readable string """ parts = [] if rd.days > 0: parts.append("%d day%s" % (rd.days, plural(rd.days))) clock_parts = [] if rd.hours > 0: clock_parts.append("%02d" % rd.hours) if rd.minutes > 0 or rd.hours > 0: clo...
python
{ "resource": "" }
q246498
less_display
train
def less_display(): """ Use smoke and mirrors to acquire 'less' for pretty paging """ # here's some magic. We want the nice paging from 'less', so we write # the output to a file and use subprocess to run 'less' on the file. # But the file might have sensitive data, so open it in 0600 mode. _, filen...
python
{ "resource": "" }
q246499
stdout_display
train
def stdout_display(): """ Print results straight to stdout """ if sys.version_info[0] == 2:
python
{ "resource": "" }