_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q257500 | GTFS.get_trip_counts_per_day | validation | def get_trip_counts_per_day(self):
"""
Get trip counts per day between the start and end day of the feed.
Returns
-------
trip_counts : pandas.DataFrame
Has columns "date_str" (dtype str) "trip_counts" (dtype int)
"""
query = "SELECT date, count(*) AS... | python | {
"resource": ""
} |
q257501 | GTFS.get_spreading_trips | validation | def get_spreading_trips(self, start_time_ut, lat, lon,
max_duration_ut=4 * 3600,
min_transfer_time=30,
use_shapes=False):
"""
Starting from a specific point and time, get complete single source
shortest path spre... | python | {
"resource": ""
} |
q257502 | GTFS.get_closest_stop | validation | def get_closest_stop(self, lat, lon):
"""
Get closest stop to a given location.
Parameters
----------
lat: float
latitude coordinate of the location
lon: float
longitude coordinate of the location
Returns
-------
stop_I: i... | python | {
"resource": ""
} |
q257503 | GTFS.tripI_takes_place_on_dsut | validation | def tripI_takes_place_on_dsut(self, trip_I, day_start_ut):
"""
Check that a trip takes place during a day
Parameters
----------
trip_I : int
index of the trip in the gtfs data base
day_start_ut : int
the starting time of the day in unix time (seco... | python | {
"resource": ""
} |
q257504 | GTFS.day_start_ut | validation | def day_start_ut(self, ut):
"""
Convert unixtime to unixtime on GTFS start-of-day.
GTFS defines the start of a day as "noon minus 12 hours" to solve
most DST-related problems. This means that on DST-changing days,
the day start isn't midnight. This function isn't idempotent.
... | python | {
"resource": ""
} |
q257505 | GTFS.increment_day_start_ut | validation | def increment_day_start_ut(self, day_start_ut, n_days=1):
"""Increment the GTFS-definition of "day start".
Parameters
----------
day_start_ut : int
unixtime of the previous start of day. If this time is between
12:00 or greater, there *will* be bugs. To solve t... | python | {
"resource": ""
} |
q257506 | GTFS._get_possible_day_starts | validation | def _get_possible_day_starts(self, start_ut, end_ut, max_time_overnight=None):
"""
Get all possible day start times between start_ut and end_ut
Currently this function is used only by get_tripIs_within_range_by_dsut
Parameters
----------
start_ut : list<int>
... | python | {
"resource": ""
} |
q257507 | GTFS.stop | validation | def stop(self, stop_I):
"""
Get all stop data as a pandas DataFrame for all stops, or an individual stop'
Parameters
----------
stop_I : int
stop index
Returns
-------
stop: pandas.DataFrame
"""
return pd.read_sql_query("SELEC... | python | {
"resource": ""
} |
q257508 | GTFS.get_transit_events | validation | def get_transit_events(self, start_time_ut=None, end_time_ut=None, route_type=None):
"""
Obtain a list of events that take place during a time interval.
Each event needs to be only partially overlap the given time interval.
Does not include walking events.
Parameters
---... | python | {
"resource": ""
} |
q257509 | GTFS.get_day_start_ut_span | validation | def get_day_start_ut_span(self):
"""
Return the first and last day_start_ut
Returns
-------
first_day_start_ut: int
last_day_start_ut: int
"""
cur = self.conn.cursor()
first_day_start_ut, last_day_start_ut = \
cur.execute("SELECT min(d... | python | {
"resource": ""
} |
q257510 | TravelImpedanceDataStore.read_data_as_dataframe | validation | def read_data_as_dataframe(self,
travel_impedance_measure,
from_stop_I=None,
to_stop_I=None,
statistic=None):
"""
Recover pre-computed travel_impedance between od-pairs from the da... | python | {
"resource": ""
} |
q257511 | NodeProfileMultiObjective._check_dep_time_is_valid | validation | def _check_dep_time_is_valid(self, dep_time):
"""
A simple checker, that connections are coming in descending order of departure time
and that no departure time has been "skipped".
Parameters
----------
dep_time
Returns
-------
None
"""
... | python | {
"resource": ""
} |
q257512 | NodeProfileMultiObjective.update | validation | def update(self, new_labels, departure_time_backup=None):
"""
Update the profile with the new labels.
Each new label should have the same departure_time.
Parameters
----------
new_labels: list[LabelTime]
Returns
-------
added: bool
wh... | python | {
"resource": ""
} |
q257513 | NodeProfileMultiObjective.evaluate | validation | def evaluate(self, dep_time, first_leg_can_be_walk=True, connection_arrival_time=None):
"""
Get the pareto_optimal set of Labels, given a departure time.
Parameters
----------
dep_time : float, int
time in unix seconds
first_leg_can_be_walk : bool, optional
... | python | {
"resource": ""
} |
q257514 | TableLoader.create_table | validation | def create_table(self, conn):
"""Make table definitions"""
# Make cursor
cur = conn.cursor()
# Drop table if it already exists, to be recreated. This
# could in the future abort if table already exists, and not
# recreate it from scratch.
#cur.execute('''DROP TAB... | python | {
"resource": ""
} |
q257515 | TableLoader.import_ | validation | def import_(self, conn):
"""Do the actual import. Copy data and store in connection object.
This function:
- Creates the tables
- Imports data (using self.gen_rows)
- Run any post_import hooks.
- Creates any indexs
- Does *not* run self.make_views - those must be... | python | {
"resource": ""
} |
q257516 | TableLoader.copy | validation | def copy(cls, conn, **where):
"""Copy data from one table to another while filtering data at the same time
Parameters
----------
conn: sqlite3 DB connection. It must have a second database
attached as "other".
**where : keyword arguments
specifying (star... | python | {
"resource": ""
} |
q257517 | get_median_lat_lon_of_stops | validation | def get_median_lat_lon_of_stops(gtfs):
"""
Get median latitude AND longitude of stops
Parameters
----------
gtfs: GTFS
Returns
-------
median_lat : float
median_lon : float
"""
stops = gtfs.get_table("stops")
median_lat = numpy.percentile(stops['lat'].values, 50)
me... | python | {
"resource": ""
} |
q257518 | get_centroid_of_stops | validation | def get_centroid_of_stops(gtfs):
"""
Get mean latitude AND longitude of stops
Parameters
----------
gtfs: GTFS
Returns
-------
mean_lat : float
mean_lon : float
"""
stops = gtfs.get_table("stops")
mean_lat = numpy.mean(stops['lat'].values)
mean_lon = numpy.mean(stop... | python | {
"resource": ""
} |
q257519 | write_stats_as_csv | validation | def write_stats_as_csv(gtfs, path_to_csv, re_write=False):
"""
Writes data from get_stats to csv file
Parameters
----------
gtfs: GTFS
path_to_csv: str
filepath to the csv file to be generated
re_write:
insted of appending, create a new one.
"""
stats_dict = get_stat... | python | {
"resource": ""
} |
q257520 | _distribution | validation | def _distribution(gtfs, table, column):
"""Count occurrences of values AND return it as a string.
Example return value: '1:5 2:15'"""
cur = gtfs.conn.cursor()
cur.execute('SELECT {column}, count(*) '
'FROM {table} GROUP BY {column} '
'ORDER BY {column}'.format(column=c... | python | {
"resource": ""
} |
q257521 | _feed_calendar_span | validation | def _feed_calendar_span(gtfs, stats):
"""
Computes the temporal coverage of each source feed
Parameters
----------
gtfs: gtfspy.GTFS object
stats: dict
where to append the stats
Returns
-------
stats: dict
"""
n_feeds = _n_gtfs_sources(gtfs)[0]
max_start = None
... | python | {
"resource": ""
} |
q257522 | route_frequencies | validation | def route_frequencies(gtfs, results_by_mode=False):
"""
Return the frequency of all types of routes per day.
Parameters
-----------
gtfs: GTFS
Returns
-------
pandas.DataFrame with columns
route_I, type, frequency
"""
day = gtfs.get_suitable_date_for_daily_extract()
... | python | {
"resource": ""
} |
q257523 | get_vehicle_hours_by_type | validation | def get_vehicle_hours_by_type(gtfs, route_type):
"""
Return the sum of vehicle hours in a particular day by route type.
"""
day = gtfs.get_suitable_date_for_daily_extract()
query = (" SELECT * , SUM(end_time_ds - start_time_ds)/3600 as vehicle_hours_type"
" FROM"
" (SELECT... | python | {
"resource": ""
} |
q257524 | ConnectionScan._scan_footpaths | validation | def _scan_footpaths(self, stop_id, walk_departure_time):
"""
Scan the footpaths originating from stop_id
Parameters
----------
stop_id: int
"""
for _, neighbor, data in self._walk_network.edges_iter(nbunch=[stop_id], data=True):
d_walk = data["d_walk"... | python | {
"resource": ""
} |
q257525 | timeit | validation | def timeit(method):
"""
A Python decorator for printing out the execution time for a function.
Adapted from:
www.andreas-jung.com/contents/a-python-decorator-for-measuring-the-execution-time-of-methods
"""
def timed(*args, **kw):
time_start = time.time()
result = method(*args, *... | python | {
"resource": ""
} |
q257526 | AuthForm.clean | validation | def clean(self):
"""When receiving the filled out form, check for valid access."""
cleaned_data = super(AuthForm, self).clean()
user = self.get_user()
if self.staff_only and (not user or not user.is_staff):
raise forms.ValidationError('Sorry, only staff are allowed.')
... | python | {
"resource": ""
} |
q257527 | get_lockdown_form | validation | def get_lockdown_form(form_path):
"""Return a form class for a given string pointing to a lockdown form."""
if not form_path:
raise ImproperlyConfigured('No LOCKDOWN_FORM specified.')
form_path_list = form_path.split(".")
new_module = ".".join(form_path_list[:-1])
attr = form_path_list[-1]
... | python | {
"resource": ""
} |
q257528 | LockdownMiddleware.process_request | validation | def process_request(self, request):
"""Check if each request is allowed to access the current resource."""
try:
session = request.session
except AttributeError:
raise ImproperlyConfigured('django-lockdown requires the Django '
'sessi... | python | {
"resource": ""
} |
q257529 | LockdownMiddleware.redirect | validation | def redirect(self, request):
"""Handle redirects properly."""
url = request.path
querystring = request.GET.copy()
if self.logout_key and self.logout_key in request.GET:
del querystring[self.logout_key]
if querystring:
url = '%s?%s' % (url, querystring.urle... | python | {
"resource": ""
} |
q257530 | Registry.get | validation | def get(self, profile_id):
'''Returns the profile with the received ID as a dict
If a local copy of the profile exists, it'll be returned. If not, it'll
be downloaded from the web. The results are cached, so any subsequent
calls won't hit the filesystem or the web.
Args:
... | python | {
"resource": ""
} |
q257531 | get_descriptor_base_path | validation | def get_descriptor_base_path(descriptor):
"""Get descriptor base path if string or return None.
"""
# Infer from path/url
if isinstance(descriptor, six.string_types):
if os.path.exists(descriptor):
base_path = os.path.dirname(os.path.abspath(descriptor))
else:
# ... | python | {
"resource": ""
} |
q257532 | retrieve_descriptor | validation | def retrieve_descriptor(descriptor):
"""Retrieve descriptor.
"""
the_descriptor = descriptor
if the_descriptor is None:
the_descriptor = {}
if isinstance(the_descriptor, six.string_types):
try:
if os.path.isfile(the_descriptor):
with open(the_descriptor,... | python | {
"resource": ""
} |
q257533 | is_safe_path | validation | def is_safe_path(path):
"""Check if path is safe and allowed.
"""
contains_windows_var = lambda val: re.match(r'%.+%', val)
contains_posix_var = lambda val: re.match(r'\$.+', val)
unsafeness_conditions = [
os.path.isabs(path),
('..%s' % os.path.sep) in path,
path.startswith(... | python | {
"resource": ""
} |
q257534 | _validate_zip | validation | def _validate_zip(the_zip):
"""Validate zipped data package
"""
datapackage_jsons = [f for f in the_zip.namelist() if f.endswith('datapackage.json')]
if len(datapackage_jsons) != 1:
msg = 'DataPackage must have only one "datapackage.json" (had {n})'
raise exceptions.DataPackageException(... | python | {
"resource": ""
} |
q257535 | _slugify_foreign_key | validation | def _slugify_foreign_key(schema):
"""Slugify foreign key
"""
for foreign_key in schema.get('foreignKeys', []):
foreign_key['reference']['resource'] = _slugify_resource_name(
foreign_key['reference'].get('resource', ''))
return schema | python | {
"resource": ""
} |
q257536 | Package.validate | validation | def validate(self):
""""Validate this Data Package.
"""
# Deprecate
warnings.warn(
'Property "package.validate" is deprecated.',
UserWarning)
descriptor = self.to_dict()
self.profile.validate(descriptor) | python | {
"resource": ""
} |
q257537 | push_datapackage | validation | def push_datapackage(descriptor, backend, **backend_options):
"""Push Data Package to storage.
All parameters should be used as keyword arguments.
Args:
descriptor (str): path to descriptor
backend (str): backend name like `sql` or `bigquery`
backend_options (dict): backend options... | python | {
"resource": ""
} |
q257538 | pull_datapackage | validation | def pull_datapackage(descriptor, name, backend, **backend_options):
"""Pull Data Package from storage.
All parameters should be used as keyword arguments.
Args:
descriptor (str): path where to store descriptor
name (str): name of the pulled datapackage
backend (str): backend name l... | python | {
"resource": ""
} |
q257539 | _convert_path | validation | def _convert_path(path, name):
"""Convert resource's path and name to storage's table name.
Args:
path (str): resource path
name (str): resource name
Returns:
str: table name
"""
table = os.path.splitext(path)[0]
table = table.replace(os.path.sep, '__')
if name is ... | python | {
"resource": ""
} |
q257540 | _restore_path | validation | def _restore_path(table):
"""Restore resource's path and name from storage's table.
Args:
table (str): table name
Returns:
(str, str): resource path and name
"""
name = None
splited = table.split('___')
path = splited[0]
if len(splited) == 2:
name = splited[1]
... | python | {
"resource": ""
} |
q257541 | _convert_schemas | validation | def _convert_schemas(mapping, schemas):
"""Convert schemas to be compatible with storage schemas.
Foreign keys related operations.
Args:
mapping (dict): mapping between resource name and table name
schemas (list): schemas
Raises:
ValueError: if there is no resource
... | python | {
"resource": ""
} |
q257542 | _restore_resources | validation | def _restore_resources(resources):
"""Restore schemas from being compatible with storage schemas.
Foreign keys related operations.
Args:
list: resources from storage
Returns:
list: restored resources
"""
resources = deepcopy(resources)
for resource in resources:
s... | python | {
"resource": ""
} |
q257543 | _buffer_incomplete_responses | validation | def _buffer_incomplete_responses(raw_output, buf):
"""It is possible for some of gdb's output to be read before it completely finished its response.
In that case, a partial mi response was read, which cannot be parsed into structured data.
We want to ALWAYS parse complete mi records. To do this, we store a ... | python | {
"resource": ""
} |
q257544 | GdbController.verify_valid_gdb_subprocess | validation | def verify_valid_gdb_subprocess(self):
"""Verify there is a process object, and that it is still running.
Raise NoGdbProcessError if either of the above are not true."""
if not self.gdb_process:
raise NoGdbProcessError("gdb process is not attached")
elif self.gdb_process.pol... | python | {
"resource": ""
} |
q257545 | GdbController.write | validation | def write(
self,
mi_cmd_to_write,
timeout_sec=DEFAULT_GDB_TIMEOUT_SEC,
raise_error_on_timeout=True,
read_response=True,
):
"""Write to gdb process. Block while parsing responses from gdb for a maximum of timeout_sec.
Args:
mi_cmd_to_write (str or ... | python | {
"resource": ""
} |
q257546 | GdbController.get_gdb_response | validation | def get_gdb_response(
self, timeout_sec=DEFAULT_GDB_TIMEOUT_SEC, raise_error_on_timeout=True
):
"""Get response from GDB, and block while doing so. If GDB does not have any response ready to be read
by timeout_sec, an exception is raised.
Args:
timeout_sec (float): Maxim... | python | {
"resource": ""
} |
q257547 | GdbController._get_responses_windows | validation | def _get_responses_windows(self, timeout_sec):
"""Get responses on windows. Assume no support for select and use a while loop."""
timeout_time_sec = time.time() + timeout_sec
responses = []
while True:
try:
self.gdb_process.stdout.flush()
if PY... | python | {
"resource": ""
} |
q257548 | GdbController._get_responses_unix | validation | def _get_responses_unix(self, timeout_sec):
"""Get responses on unix-like system. Use select to wait for output."""
timeout_time_sec = time.time() + timeout_sec
responses = []
while True:
select_timeout = timeout_time_sec - time.time()
# I prefer to not pass a neg... | python | {
"resource": ""
} |
q257549 | main | validation | def main(verbose=True):
"""Build and debug an application programatically
For a list of GDB MI commands, see https://www.sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html
"""
# Build C program
find_executable(MAKE_CMD)
if not find_executable(MAKE_CMD):
print(
'Could not fin... | python | {
"resource": ""
} |
q257550 | StringStream.read | validation | def read(self, count):
"""Read count characters starting at self.index,
and return those characters as a string
"""
new_index = self.index + count
if new_index > self.len:
buf = self.raw_text[self.index :] # return to the end, don't fail
else:
buf... | python | {
"resource": ""
} |
q257551 | StringStream.advance_past_string_with_gdb_escapes | validation | def advance_past_string_with_gdb_escapes(self, chars_to_remove_gdb_escape=None):
"""characters that gdb escapes that should not be
escaped by this parser
"""
if chars_to_remove_gdb_escape is None:
chars_to_remove_gdb_escape = ['"']
buf = ""
while True:
... | python | {
"resource": ""
} |
q257552 | parse_response | validation | def parse_response(gdb_mi_text):
"""Parse gdb mi text and turn it into a dictionary.
See https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Stream-Records.html#GDB_002fMI-Stream-Records
for details on types of gdb mi output.
Args:
gdb_mi_text (str): String output from gdb
Returns:
... | python | {
"resource": ""
} |
q257553 | _get_notify_msg_and_payload | validation | def _get_notify_msg_and_payload(result, stream):
"""Get notify message and payload dict"""
token = stream.advance_past_chars(["=", "*"])
token = int(token) if token != "" else None
logger.debug("%s", fmt_green("parsing message"))
message = stream.advance_past_chars([","])
logger.debug("parsed m... | python | {
"resource": ""
} |
q257554 | _get_result_msg_and_payload | validation | def _get_result_msg_and_payload(result, stream):
"""Get result message and payload dict"""
groups = _GDB_MI_RESULT_RE.match(result).groups()
token = int(groups[0]) if groups[0] != "" else None
message = groups[1]
if groups[2] is None:
payload = None
else:
stream.advance_past_ch... | python | {
"resource": ""
} |
q257555 | BroadcastQueue._get_or_create_subscription | validation | def _get_or_create_subscription(self):
"""In a broadcast queue, workers have a unique subscription ensuring
that every worker recieves a copy of every task."""
topic_path = self._get_topic_path()
subscription_name = '{}-{}-{}-worker'.format(
queue.PUBSUB_OBJECT_PREFIX, self.n... | python | {
"resource": ""
} |
q257556 | BroadcastQueue.cleanup | validation | def cleanup(self):
"""Deletes this worker's subscription."""
if self.subscription:
logger.info("Deleting worker subscription...")
self.subscriber_client.delete_subscription(self.subscription) | python | {
"resource": ""
} |
q257557 | Queue._get_or_create_subscription | validation | def _get_or_create_subscription(self):
"""Workers all share the same subscription so that tasks are
distributed across all workers."""
topic_path = self._get_topic_path()
subscription_name = '{}-{}-shared'.format(
PUBSUB_OBJECT_PREFIX, self.name)
subscription_path = s... | python | {
"resource": ""
} |
q257558 | Queue.enqueue | validation | def enqueue(self, f, *args, **kwargs):
"""Enqueues a function for the task queue to execute."""
task = Task(uuid4().hex, f, args, kwargs)
self.storage.put_task(task)
return self.enqueue_task(task) | python | {
"resource": ""
} |
q257559 | Queue.enqueue_task | validation | def enqueue_task(self, task):
"""Enqueues a task directly. This is used when a task is retried or if
a task was manually created.
Note that this does not store the task.
"""
data = dumps(task)
if self._async:
self.publisher_client.publish(self.topic_path, da... | python | {
"resource": ""
} |
q257560 | main | validation | def main(path, pid, queue):
"""
Standalone PSQ worker.
The queue argument must be the full importable path to a psq.Queue
instance.
Example usage:
psqworker config.q
psqworker --path /opt/app queues.fast
"""
setup_logging()
if pid:
with open(os.path.expandus... | python | {
"resource": ""
} |
q257561 | TaskResult.result | validation | def result(self, timeout=None):
"""Gets the result of the task.
Arguments:
timeout: Maximum seconds to wait for a result before raising a
TimeoutError. If set to None, this will wait forever. If the
queue doesn't store results and timeout is None, this call w... | python | {
"resource": ""
} |
q257562 | service_start | validation | def service_start(service=None, param=None):
"""
Launch a Process, return his pid
"""
if service is not None:
to_run = ["python", service]
if param is not None:
to_run += param
return subprocess.Popen(to_run)
return False | python | {
"resource": ""
} |
q257563 | update_running_pids | validation | def update_running_pids(old_procs):
"""
Update the list of the running process and return the list
"""
new_procs = []
for proc in old_procs:
if proc.poll() is None and check_pid(proc.pid):
publisher.debug(str(proc.pid) + ' is alive')
new_procs.append(proc)
... | python | {
"resource": ""
} |
q257564 | run_splitted_processing | validation | def run_splitted_processing(max_simultaneous_processes, process_name,
filenames):
"""
Run processes which push the routing dump of the RIPE in a redis
database.
The dump has been splitted in multiple files and each process run
on one of this files.
"""... | python | {
"resource": ""
} |
q257565 | fsplit | validation | def fsplit(file_to_split):
"""
Split the file and return the list of filenames.
"""
dirname = file_to_split + '_splitted'
if not os.path.exists(dirname):
os.mkdir(dirname)
part_file_size = os.path.getsize(file_to_split) / number_of_files + 1
splitted_files = []
with open(file... | python | {
"resource": ""
} |
q257566 | IPASN.asn | validation | def asn(self, ip, announce_date=None):
"""
Give an IP, maybe a date, get the ASN.
This is the fastest command.
:param ip: IP address to search for
:param announce_date: Date of the announcement
:rtype: String, ASN.
"""
assignations, ... | python | {
"resource": ""
} |
q257567 | IPASN.date_asn_block | validation | def date_asn_block(self, ip, announce_date=None):
"""
Get the ASN and the IP Block announcing the IP at a specific date.
:param ip: IP address to search for
:param announce_date: Date of the announcement
:rtype: tuple
.. code-block:: python
... | python | {
"resource": ""
} |
q257568 | IPASN.history | validation | def history(self, ip, days_limit=None):
"""
Get the full history of an IP. It takes time.
:param ip: IP address to search for
:param days_limit: Max amount of days to query. (None means no limit)
:rtype: list. For each day in the database: day, asn, block
... | python | {
"resource": ""
} |
q257569 | IPASN.aggregate_history | validation | def aggregate_history(self, ip, days_limit=None):
"""
Get the full history of an IP, aggregate the result instead of
returning one line per day.
:param ip: IP address to search for
:param days_limit: Max amount of days to query. (None means no limit)
... | python | {
"resource": ""
} |
q257570 | downloadURL | validation | def downloadURL(url, filename):
"""
Inconditianilly download the URL in a temporary directory.
When finished, the file is moved in the real directory.
Like this an other process will not attempt to extract an inclomplete file.
"""
path_temp_bviewfile = os.path.join(c.raw_data, c.bvie... | python | {
"resource": ""
} |
q257571 | already_downloaded | validation | def already_downloaded(filename):
"""
Verify that the file has not already been downloaded.
"""
cur_file = os.path.join(c.bview_dir, filename)
old_file = os.path.join(c.bview_dir, 'old', filename)
if not os.path.exists(cur_file) and not os.path.exists(old_file):
return False
retu... | python | {
"resource": ""
} |
q257572 | strToBool | validation | def strToBool(val):
"""
Helper function to turn a string representation of "true" into
boolean True.
"""
if isinstance(val, str):
val = val.lower()
return val in ['true', 'on', 'yes', True] | python | {
"resource": ""
} |
q257573 | get_page_url | validation | def get_page_url(page_num, current_app, url_view_name, url_extra_args, url_extra_kwargs, url_param_name, url_get_params, url_anchor):
"""
Helper function to return a valid URL string given the template tag parameters
"""
if url_view_name is not None:
# Add page param to the kwargs list. Override... | python | {
"resource": ""
} |
q257574 | bootstrap_paginate | validation | def bootstrap_paginate(parser, token):
"""
Renders a Page object as a Twitter Bootstrap styled pagination bar.
Compatible with Bootstrap 3.x and 4.x only.
Example::
{% bootstrap_paginate page_obj range=10 %}
Named Parameters::
range - The size of the pagination bar (ie, if set t... | python | {
"resource": ""
} |
q257575 | get_regressions | validation | def get_regressions(
package_descriptors, targets,
building_repo_data, testing_repo_data, main_repo_data):
"""
For each package and target check if it is a regression.
This is the case if the main repo contains a package version which is
higher then in any of the other repos or if any o... | python | {
"resource": ""
} |
q257576 | _strip_version_suffix | validation | def _strip_version_suffix(version):
"""
Remove trailing junk from the version number.
>>> strip_version_suffix('')
''
>>> strip_version_suffix('None')
'None'
>>> strip_version_suffix('1.2.3-4trusty-20140131-1359-+0000')
'1.2.3-4'
>>> strip_version_suffix('1.2.3-foo')
'1.2.3'
... | python | {
"resource": ""
} |
q257577 | get_homogeneous | validation | def get_homogeneous(package_descriptors, targets, repos_data):
"""
For each package check if the version in one repo is equal for all targets.
The version could be different in different repos though.
:return: a dict indexed by package names containing a boolean flag
"""
homogeneous = {}
f... | python | {
"resource": ""
} |
q257578 | get_package_counts | validation | def get_package_counts(package_descriptors, targets, repos_data):
"""
Get the number of packages per target and repository.
:return: a dict indexed by targets containing
a list of integer values (one for each repo)
"""
counts = {}
for target in targets:
counts[target] = [0] * len(... | python | {
"resource": ""
} |
q257579 | get_jenkins_job_urls | validation | def get_jenkins_job_urls(
rosdistro_name, jenkins_url, release_build_name, targets):
"""
Get the Jenkins job urls for each target.
The placeholder {pkg} needs to be replaced with the ROS package name.
:return: a dict indexed by targets containing a string
"""
urls = {}
for target i... | python | {
"resource": ""
} |
q257580 | configure_ci_jobs | validation | def configure_ci_jobs(
config_url, rosdistro_name, ci_build_name,
groovy_script=None, dry_run=False):
"""Configure all Jenkins CI jobs."""
config = get_config_index(config_url)
build_files = get_ci_build_files(config, rosdistro_name)
build_file = build_files[ci_build_name]
index = g... | python | {
"resource": ""
} |
q257581 | configure_ci_job | validation | def configure_ci_job(
config_url, rosdistro_name, ci_build_name,
os_name, os_code_name, arch,
config=None, build_file=None,
index=None, dist_file=None,
jenkins=None, views=None,
is_disabled=False,
groovy_script=None,
build_targets=None,
dry_run=Fal... | python | {
"resource": ""
} |
q257582 | write_groovy_script_and_configs | validation | def write_groovy_script_and_configs(
filename, content, job_configs, view_configs=None):
"""Write out the groovy script and configs to file.
This writes the reconfigure script to the file location
and places the expanded configs in subdirectories 'view_configs' /
'job_configs' that the script c... | python | {
"resource": ""
} |
q257583 | topological_order_packages | validation | def topological_order_packages(packages):
"""
Order packages topologically.
First returning packages which have message generators and then
the rest based on all direct depends and indirect recursive run_depends.
:param packages: A dict mapping relative paths to ``Package`` objects ``dict``
:r... | python | {
"resource": ""
} |
q257584 | _unarmor_pem | validation | def _unarmor_pem(data, password=None):
"""
Removes PEM-encoding from a public key, private key or certificate. If the
private key is encrypted, the password will be used to decrypt it.
:param data:
A byte string of the PEM-encoded data
:param password:
A byte string of the encrypti... | python | {
"resource": ""
} |
q257585 | _decrypt_encrypted_data | validation | def _decrypt_encrypted_data(encryption_algorithm_info, encrypted_content, password):
"""
Decrypts encrypted ASN.1 data
:param encryption_algorithm_info:
An instance of asn1crypto.pkcs5.Pkcs5EncryptionAlgorithm
:param encrypted_content:
A byte string of the encrypted content
:param... | python | {
"resource": ""
} |
q257586 | _setup_evp_encrypt_decrypt | validation | def _setup_evp_encrypt_decrypt(cipher, data):
"""
Creates an EVP_CIPHER pointer object and determines the buffer size
necessary for the parameter specified.
:param evp_cipher_ctx:
An EVP_CIPHER_CTX pointer
:param cipher:
A unicode string of "aes128", "aes192", "aes256", "des",
... | python | {
"resource": ""
} |
q257587 | _advapi32_interpret_rsa_key_blob | validation | def _advapi32_interpret_rsa_key_blob(bit_size, blob_struct, blob):
"""
Takes a CryptoAPI RSA private key blob and converts it into the ASN.1
structures for the public and private keys
:param bit_size:
The integer bit size of the key
:param blob_struct:
An instance of the advapi32.R... | python | {
"resource": ""
} |
q257588 | _advapi32_interpret_dsa_key_blob | validation | def _advapi32_interpret_dsa_key_blob(bit_size, public_blob, private_blob):
"""
Takes a CryptoAPI DSS private key blob and converts it into the ASN.1
structures for the public and private keys
:param bit_size:
The integer bit size of the key
:param public_blob:
A byte string of the ... | python | {
"resource": ""
} |
q257589 | _advapi32_load_key | validation | def _advapi32_load_key(key_object, key_info, container):
"""
Loads a certificate, public key or private key into a Certificate,
PublicKey or PrivateKey object via CryptoAPI
:param key_object:
An asn1crypto.x509.Certificate, asn1crypto.keys.PublicKeyInfo or
asn1crypto.keys.PrivateKeyInfo... | python | {
"resource": ""
} |
q257590 | rsa_pkcs1v15_verify | validation | def rsa_pkcs1v15_verify(certificate_or_public_key, signature, data, hash_algorithm):
"""
Verifies an RSASSA-PKCS-v1.5 signature.
When the hash_algorithm is "raw", the operation is identical to RSA
public key decryption. That is: the data is not hashed and no ASN.1
structure with an algorithm identi... | python | {
"resource": ""
} |
q257591 | _advapi32_verify | validation | def _advapi32_verify(certificate_or_public_key, signature, data, hash_algorithm, rsa_pss_padding=False):
"""
Verifies an RSA, DSA or ECDSA signature via CryptoAPI
:param certificate_or_public_key:
A Certificate or PublicKey instance to verify the signature with
:param signature:
A byte... | python | {
"resource": ""
} |
q257592 | _bcrypt_verify | validation | def _bcrypt_verify(certificate_or_public_key, signature, data, hash_algorithm, rsa_pss_padding=False):
"""
Verifies an RSA, DSA or ECDSA signature via CNG
:param certificate_or_public_key:
A Certificate or PublicKey instance to verify the signature with
:param signature:
A byte string ... | python | {
"resource": ""
} |
q257593 | dsa_sign | validation | def dsa_sign(private_key, data, hash_algorithm):
"""
Generates a DSA signature
:param private_key:
The PrivateKey to generate the signature with
:param data:
A byte string of the data the signature is for
:param hash_algorithm:
A unicode string of "md5", "sha1", "sha256", ... | python | {
"resource": ""
} |
q257594 | ecdsa_sign | validation | def ecdsa_sign(private_key, data, hash_algorithm):
"""
Generates an ECDSA signature
:param private_key:
The PrivateKey to generate the signature with
:param data:
A byte string of the data the signature is for
:param hash_algorithm:
A unicode string of "md5", "sha1", "sha2... | python | {
"resource": ""
} |
q257595 | _advapi32_sign | validation | def _advapi32_sign(private_key, data, hash_algorithm, rsa_pss_padding=False):
"""
Generates an RSA, DSA or ECDSA signature via CryptoAPI
:param private_key:
The PrivateKey to generate the signature with
:param data:
A byte string of the data the signature is for
:param hash_algori... | python | {
"resource": ""
} |
q257596 | _bcrypt_sign | validation | def _bcrypt_sign(private_key, data, hash_algorithm, rsa_pss_padding=False):
"""
Generates an RSA, DSA or ECDSA signature via CNG
:param private_key:
The PrivateKey to generate the signature with
:param data:
A byte string of the data the signature is for
:param hash_algorithm:
... | python | {
"resource": ""
} |
q257597 | _advapi32_encrypt | validation | def _advapi32_encrypt(certificate_or_public_key, data, rsa_oaep_padding=False):
"""
Encrypts a value using an RSA public key via CryptoAPI
:param certificate_or_public_key:
A Certificate or PublicKey instance to encrypt with
:param data:
A byte string of the data to encrypt
:param... | python | {
"resource": ""
} |
q257598 | _bcrypt_encrypt | validation | def _bcrypt_encrypt(certificate_or_public_key, data, rsa_oaep_padding=False):
"""
Encrypts a value using an RSA public key via CNG
:param certificate_or_public_key:
A Certificate or PublicKey instance to encrypt with
:param data:
A byte string of the data to encrypt
:param rsa_oae... | python | {
"resource": ""
} |
q257599 | _advapi32_decrypt | validation | def _advapi32_decrypt(private_key, ciphertext, rsa_oaep_padding=False):
"""
Encrypts a value using an RSA private key via CryptoAPI
:param private_key:
A PrivateKey instance to decrypt with
:param ciphertext:
A byte string of the data to decrypt
:param rsa_oaep_padding:
If... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.