partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
EventHeap.add_event
Add an event to the heap/priority queue Parameters ---------- event : Event
gtfspy/spreading/heap.py
def add_event(self, event): """ Add an event to the heap/priority queue Parameters ---------- event : Event """ assert event.dep_time_ut <= event.arr_time_ut heappush(self.heap, event)
def add_event(self, event): """ Add an event to the heap/priority queue Parameters ---------- event : Event """ assert event.dep_time_ut <= event.arr_time_ut heappush(self.heap, event)
[ "Add", "an", "event", "to", "the", "heap", "/", "priority", "queue" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/spreading/heap.py#L38-L47
[ "def", "add_event", "(", "self", ",", "event", ")", ":", "assert", "event", ".", "dep_time_ut", "<=", "event", ".", "arr_time_ut", "heappush", "(", "self", ".", "heap", ",", "event", ")" ]
bddba4b74faae6c1b91202f19184811e326547e5
valid
EventHeap.add_walk_events_to_heap
Parameters ---------- transfer_distances: e : Event start_time_ut : int walk_speed : float uninfected_stops : list max_duration_ut : int
gtfspy/spreading/heap.py
def add_walk_events_to_heap(self, transfer_distances, e, start_time_ut, walk_speed, uninfected_stops, max_duration_ut): """ Parameters ---------- transfer_distances: e : Event start_time_ut : int walk_speed : float uninfected_stops : list max_durat...
def add_walk_events_to_heap(self, transfer_distances, e, start_time_ut, walk_speed, uninfected_stops, max_duration_ut): """ Parameters ---------- transfer_distances: e : Event start_time_ut : int walk_speed : float uninfected_stops : list max_durat...
[ "Parameters", "----------", "transfer_distances", ":", "e", ":", "Event", "start_time_ut", ":", "int", "walk_speed", ":", "float", "uninfected_stops", ":", "list", "max_duration_ut", ":", "int" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/spreading/heap.py#L58-L81
[ "def", "add_walk_events_to_heap", "(", "self", ",", "transfer_distances", ",", "e", ",", "start_time_ut", ",", "walk_speed", ",", "uninfected_stops", ",", "max_duration_ut", ")", ":", "n", "=", "len", "(", "transfer_distances", ")", "dists_values", "=", "transfer_...
bddba4b74faae6c1b91202f19184811e326547e5
valid
NodeProfileMultiObjective._check_dep_time_is_valid
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
gtfspy/routing/node_profile_multiobjective.py
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 """ ...
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 """ ...
[ "A", "simple", "checker", "that", "connections", "are", "coming", "in", "descending", "order", "of", "departure", "time", "and", "that", "no", "departure", "time", "has", "been", "skipped", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_multiobjective.py#L58-L79
[ "def", "_check_dep_time_is_valid", "(", "self", ",", "dep_time", ")", ":", "assert", "dep_time", "<=", "self", ".", "_min_dep_time", ",", "\"Labels should be entered in decreasing order of departure time.\"", "dep_time_index", "=", "self", ".", "dep_times_to_index", "[", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
NodeProfileMultiObjective.update
Update the profile with the new labels. Each new label should have the same departure_time. Parameters ---------- new_labels: list[LabelTime] Returns ------- added: bool whether new_pareto_tuple was added to the set of pareto-optimal tuples
gtfspy/routing/node_profile_multiobjective.py
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...
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...
[ "Update", "the", "profile", "with", "the", "new", "labels", ".", "Each", "new", "label", "should", "have", "the", "same", "departure_time", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_multiobjective.py#L91-L131
[ "def", "update", "(", "self", ",", "new_labels", ",", "departure_time_backup", "=", "None", ")", ":", "if", "self", ".", "_closed", ":", "raise", "RuntimeError", "(", "\"Profile is closed, no updates can be made\"", ")", "try", ":", "departure_time", "=", "next", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
NodeProfileMultiObjective.evaluate
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 whether to allow walking to target to be included into the profile (I.e. whether this...
gtfspy/routing/node_profile_multiobjective.py
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 ...
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 ...
[ "Get", "the", "pareto_optimal", "set", "of", "Labels", "given", "a", "departure", "time", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_multiobjective.py#L133-L175
[ "def", "evaluate", "(", "self", ",", "dep_time", ",", "first_leg_can_be_walk", "=", "True", ",", "connection_arrival_time", "=", "None", ")", ":", "walk_labels", "=", "list", "(", ")", "# walk label towards target", "if", "first_leg_can_be_walk", "and", "self", "....
bddba4b74faae6c1b91202f19184811e326547e5
valid
NodeProfileMultiObjective.finalize
Parameters ---------- neighbor_label_bags: list each list element is a list of labels corresponding to a neighboring node (note: only labels with first connection being a departure should be included) walk_durations: list departure_arrival_stop_pairs: list of tup...
gtfspy/routing/node_profile_multiobjective.py
def finalize(self, neighbor_label_bags=None, walk_durations=None, departure_arrival_stop_pairs=None): """ Parameters ---------- neighbor_label_bags: list each list element is a list of labels corresponding to a neighboring node (note: only labels with first conne...
def finalize(self, neighbor_label_bags=None, walk_durations=None, departure_arrival_stop_pairs=None): """ Parameters ---------- neighbor_label_bags: list each list element is a list of labels corresponding to a neighboring node (note: only labels with first conne...
[ "Parameters", "----------", "neighbor_label_bags", ":", "list", "each", "list", "element", "is", "a", "list", "of", "labels", "corresponding", "to", "a", "neighboring", "node", "(", "note", ":", "only", "labels", "with", "first", "connection", "being", "a", "d...
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_multiobjective.py#L234-L258
[ "def", "finalize", "(", "self", ",", "neighbor_label_bags", "=", "None", ",", "walk_durations", "=", "None", ",", "departure_arrival_stop_pairs", "=", "None", ")", ":", "assert", "(", "not", "self", ".", "_finalized", ")", "if", "self", ".", "_final_pareto_opt...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TableLoader.exists_by_source
Does this GTFS contain this file? (file specified by the class)
gtfspy/import_loaders/table_loader.py
def exists_by_source(self): """Does this GTFS contain this file? (file specified by the class)""" exists_list = [] for source in self.gtfs_sources: if isinstance(source, dict): # source can now be either a dict or a zipfile if self.fname in source: ...
def exists_by_source(self): """Does this GTFS contain this file? (file specified by the class)""" exists_list = [] for source in self.gtfs_sources: if isinstance(source, dict): # source can now be either a dict or a zipfile if self.fname in source: ...
[ "Does", "this", "GTFS", "contain", "this", "file?", "(", "file", "specified", "by", "the", "class", ")" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_loaders/table_loader.py#L112-L141
[ "def", "exists_by_source", "(", "self", ")", ":", "exists_list", "=", "[", "]", "for", "source", "in", "self", ".", "gtfs_sources", ":", "if", "isinstance", "(", "source", ",", "dict", ")", ":", "# source can now be either a dict or a zipfile", "if", "self", "...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TableLoader.create_table
Make table definitions
gtfspy/import_loaders/table_loader.py
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...
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...
[ "Make", "table", "definitions" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_loaders/table_loader.py#L239-L259
[ "def", "create_table", "(", "self", ",", "conn", ")", ":", "# 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.", "...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TableLoader.insert_data
Load data from GTFS file into database
gtfspy/import_loaders/table_loader.py
def insert_data(self, conn): """Load data from GTFS file into database""" cur = conn.cursor() # This is a bit hackish. It is annoying to have to write the # INSERT statement yourself and keep it up to date with the # table rows. This gets the first row, figures out the field ...
def insert_data(self, conn): """Load data from GTFS file into database""" cur = conn.cursor() # This is a bit hackish. It is annoying to have to write the # INSERT statement yourself and keep it up to date with the # table rows. This gets the first row, figures out the field ...
[ "Load", "data", "from", "GTFS", "file", "into", "database" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_loaders/table_loader.py#L261-L298
[ "def", "insert_data", "(", "self", ",", "conn", ")", ":", "cur", "=", "conn", ".", "cursor", "(", ")", "# This is a bit hackish. It is annoying to have to write the", "# INSERT statement yourself and keep it up to date with the", "# table rows. This gets the first row, figures ou...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TableLoader.import_
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 done after all tables are...
gtfspy/import_loaders/table_loader.py
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...
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...
[ "Do", "the", "actual", "import", ".", "Copy", "data", "and", "store", "in", "connection", "object", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_loaders/table_loader.py#L338-L365
[ "def", "import_", "(", "self", ",", "conn", ")", ":", "if", "self", ".", "print_progress", ":", "print", "(", "'Beginning'", ",", "self", ".", "__class__", ".", "__name__", ")", "# what is this mystical self._conn ?", "self", ".", "_conn", "=", "conn", "self...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TableLoader.copy
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 (start_ut and end_ut for filtering, see the co...
gtfspy/import_loaders/table_loader.py
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...
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...
[ "Copy", "data", "from", "one", "table", "to", "another", "while", "filtering", "data", "at", "the", "same", "time" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_loaders/table_loader.py#L375-L392
[ "def", "copy", "(", "cls", ",", "conn", ",", "*", "*", "where", ")", ":", "cur", "=", "conn", ".", "cursor", "(", ")", "if", "where", "and", "cls", ".", "copy_where", ":", "copy_where", "=", "cls", ".", "copy_where", ".", "format", "(", "*", "*",...
bddba4b74faae6c1b91202f19184811e326547e5
valid
JourneyDataAnalyzer.get_journey_legs_to_target
Returns a dataframe of aggregated sections from source nodes to target. The returned sections are either transfer point to transfer point or stop to stop. In a before after setting, the results can be filtered based on values in a difference db. :param target: :param fastest_path: ...
gtfspy/routing/journey_data_analyzer.py
def get_journey_legs_to_target(self, target, fastest_path=True, min_boardings=False, all_leg_sections=True, ignore_walk=False, diff_threshold=None, diff_path=None): """ Returns a dataframe of aggregated sections from source nodes to target. The returned...
def get_journey_legs_to_target(self, target, fastest_path=True, min_boardings=False, all_leg_sections=True, ignore_walk=False, diff_threshold=None, diff_path=None): """ Returns a dataframe of aggregated sections from source nodes to target. The returned...
[ "Returns", "a", "dataframe", "of", "aggregated", "sections", "from", "source", "nodes", "to", "target", ".", "The", "returned", "sections", "are", "either", "transfer", "point", "to", "transfer", "point", "or", "stop", "to", "stop", ".", "In", "a", "before",...
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/journey_data_analyzer.py#L26-L73
[ "def", "get_journey_legs_to_target", "(", "self", ",", "target", ",", "fastest_path", "=", "True", ",", "min_boardings", "=", "False", ",", "all_leg_sections", "=", "True", ",", "ignore_walk", "=", "False", ",", "diff_threshold", "=", "None", ",", "diff_path", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
JourneyDataAnalyzer.get_upstream_stops_ratio
Selects the stops for which the ratio or higher proportion of trips to the target passes trough a set of trough stops :param target: target of trips :param trough_stops: stops where the selected trips are passing trough :param ratio: threshold for inclusion :return:
gtfspy/routing/journey_data_analyzer.py
def get_upstream_stops_ratio(self, target, trough_stops, ratio): """ Selects the stops for which the ratio or higher proportion of trips to the target passes trough a set of trough stops :param target: target of trips :param trough_stops: stops where the selected trips are passing trough...
def get_upstream_stops_ratio(self, target, trough_stops, ratio): """ Selects the stops for which the ratio or higher proportion of trips to the target passes trough a set of trough stops :param target: target of trips :param trough_stops: stops where the selected trips are passing trough...
[ "Selects", "the", "stops", "for", "which", "the", "ratio", "or", "higher", "proportion", "of", "trips", "to", "the", "target", "passes", "trough", "a", "set", "of", "trough", "stops", ":", "param", "target", ":", "target", "of", "trips", ":", "param", "t...
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/journey_data_analyzer.py#L222-L243
[ "def", "get_upstream_stops_ratio", "(", "self", ",", "target", ",", "trough_stops", ",", "ratio", ")", ":", "if", "isinstance", "(", "trough_stops", ",", "list", ")", ":", "trough_stops", "=", "\",\"", ".", "join", "(", "trough_stops", ")", "query", "=", "...
bddba4b74faae6c1b91202f19184811e326547e5
valid
get_spatial_bounds
Parameters ---------- gtfs Returns ------- min_lon: float max_lon: float min_lat: float max_lat: float
gtfspy/stats.py
def get_spatial_bounds(gtfs, as_dict=False): """ Parameters ---------- gtfs Returns ------- min_lon: float max_lon: float min_lat: float max_lat: float """ stats = get_stats(gtfs) lon_min = stats['lon_min'] lon_max = stats['lon_max'] lat_min = stats['lat_min'...
def get_spatial_bounds(gtfs, as_dict=False): """ Parameters ---------- gtfs Returns ------- min_lon: float max_lon: float min_lat: float max_lat: float """ stats = get_stats(gtfs) lon_min = stats['lon_min'] lon_max = stats['lon_max'] lat_min = stats['lat_min'...
[ "Parameters", "----------", "gtfs" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L14-L35
[ "def", "get_spatial_bounds", "(", "gtfs", ",", "as_dict", "=", "False", ")", ":", "stats", "=", "get_stats", "(", "gtfs", ")", "lon_min", "=", "stats", "[", "'lon_min'", "]", "lon_max", "=", "stats", "[", "'lon_max'", "]", "lat_min", "=", "stats", "[", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
get_median_lat_lon_of_stops
Get median latitude AND longitude of stops Parameters ---------- gtfs: GTFS Returns ------- median_lat : float median_lon : float
gtfspy/stats.py
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...
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...
[ "Get", "median", "latitude", "AND", "longitude", "of", "stops" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L48-L64
[ "def", "get_median_lat_lon_of_stops", "(", "gtfs", ")", ":", "stops", "=", "gtfs", ".", "get_table", "(", "\"stops\"", ")", "median_lat", "=", "numpy", ".", "percentile", "(", "stops", "[", "'lat'", "]", ".", "values", ",", "50", ")", "median_lon", "=", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
get_centroid_of_stops
Get mean latitude AND longitude of stops Parameters ---------- gtfs: GTFS Returns ------- mean_lat : float mean_lon : float
gtfspy/stats.py
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...
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...
[ "Get", "mean", "latitude", "AND", "longitude", "of", "stops" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L66-L82
[ "def", "get_centroid_of_stops", "(", "gtfs", ")", ":", "stops", "=", "gtfs", ".", "get_table", "(", "\"stops\"", ")", "mean_lat", "=", "numpy", ".", "mean", "(", "stops", "[", "'lat'", "]", ".", "values", ")", "mean_lon", "=", "numpy", ".", "mean", "("...
bddba4b74faae6c1b91202f19184811e326547e5
valid
write_stats_as_csv
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.
gtfspy/stats.py
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...
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...
[ "Writes", "data", "from", "get_stats", "to", "csv", "file" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L85-L130
[ "def", "write_stats_as_csv", "(", "gtfs", ",", "path_to_csv", ",", "re_write", "=", "False", ")", ":", "stats_dict", "=", "get_stats", "(", "gtfs", ")", "# check if file exist", "if", "re_write", ":", "os", ".", "remove", "(", "path_to_csv", ")", "#if not os.p...
bddba4b74faae6c1b91202f19184811e326547e5
valid
get_stats
Get basic statistics of the GTFS data. Parameters ---------- gtfs: GTFS Returns ------- stats: dict A dictionary of various statistics. Keys should be strings, values should be inputtable to a database (int, date, str, ...) (but not a list)
gtfspy/stats.py
def get_stats(gtfs): """ Get basic statistics of the GTFS data. Parameters ---------- gtfs: GTFS Returns ------- stats: dict A dictionary of various statistics. Keys should be strings, values should be inputtable to a database (int, date, str, ...) (but not a li...
def get_stats(gtfs): """ Get basic statistics of the GTFS data. Parameters ---------- gtfs: GTFS Returns ------- stats: dict A dictionary of various statistics. Keys should be strings, values should be inputtable to a database (int, date, str, ...) (but not a li...
[ "Get", "basic", "statistics", "of", "the", "GTFS", "data", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L133-L245
[ "def", "get_stats", "(", "gtfs", ")", ":", "stats", "=", "{", "}", "# Basic table counts", "for", "table", "in", "[", "'agencies'", ",", "'routes'", ",", "'stops'", ",", "'stop_times'", ",", "'trips'", ",", "'calendar'", ",", "'shapes'", ",", "'calendar_date...
bddba4b74faae6c1b91202f19184811e326547e5
valid
_distribution
Count occurrences of values AND return it as a string. Example return value: '1:5 2:15
gtfspy/stats.py
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...
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...
[ "Count", "occurrences", "of", "values", "AND", "return", "it", "as", "a", "string", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L248-L256
[ "def", "_distribution", "(", "gtfs", ",", "table", ",", "column", ")", ":", "cur", "=", "gtfs", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT {column}, count(*) '", "'FROM {table} GROUP BY {column} '", "'ORDER BY {column}'", ".", "fo...
bddba4b74faae6c1b91202f19184811e326547e5
valid
_fleet_size_estimate
Calculates fleet size estimates by two separate formula: 1. Considering all routes separately with no interlining and doing a deficit calculation at every terminal 2. By looking at the maximum number of vehicles in simultaneous movement Parameters ---------- gtfs: GTFS hour: int date: ? ...
gtfspy/stats.py
def _fleet_size_estimate(gtfs, hour, date): """ Calculates fleet size estimates by two separate formula: 1. Considering all routes separately with no interlining and doing a deficit calculation at every terminal 2. By looking at the maximum number of vehicles in simultaneous movement Parameters ...
def _fleet_size_estimate(gtfs, hour, date): """ Calculates fleet size estimates by two separate formula: 1. Considering all routes separately with no interlining and doing a deficit calculation at every terminal 2. By looking at the maximum number of vehicles in simultaneous movement Parameters ...
[ "Calculates", "fleet", "size", "estimates", "by", "two", "separate", "formula", ":", "1", ".", "Considering", "all", "routes", "separately", "with", "no", "interlining", "and", "doing", "a", "deficit", "calculation", "at", "every", "terminal", "2", ".", "By", ...
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L259-L346
[ "def", "_fleet_size_estimate", "(", "gtfs", ",", "hour", ",", "date", ")", ":", "results", "=", "{", "}", "fleet_size_list", "=", "[", "]", "cur", "=", "gtfs", ".", "conn", ".", "cursor", "(", ")", "rows", "=", "cur", ".", "execute", "(", "'SELECT ty...
bddba4b74faae6c1b91202f19184811e326547e5
valid
_feed_calendar_span
Computes the temporal coverage of each source feed Parameters ---------- gtfs: gtfspy.GTFS object stats: dict where to append the stats Returns ------- stats: dict
gtfspy/stats.py
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 ...
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 ...
[ "Computes", "the", "temporal", "coverage", "of", "each", "source", "feed" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L357-L399
[ "def", "_feed_calendar_span", "(", "gtfs", ",", "stats", ")", ":", "n_feeds", "=", "_n_gtfs_sources", "(", "gtfs", ")", "[", "0", "]", "max_start", "=", "None", "min_end", "=", "None", "if", "n_feeds", ">", "1", ":", "for", "i", "in", "range", "(", "...
bddba4b74faae6c1b91202f19184811e326547e5
valid
route_frequencies
Return the frequency of all types of routes per day. Parameters ----------- gtfs: GTFS Returns ------- pandas.DataFrame with columns route_I, type, frequency
gtfspy/stats.py
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() ...
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() ...
[ "Return", "the", "frequency", "of", "all", "types", "of", "routes", "per", "day", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L506-L533
[ "def", "route_frequencies", "(", "gtfs", ",", "results_by_mode", "=", "False", ")", ":", "day", "=", "gtfs", ".", "get_suitable_date_for_daily_extract", "(", ")", "query", "=", "(", "\" SELECT f.route_I, type, frequency FROM routes as r\"", "\" JOIN\"", "\" (SELECT route_...
bddba4b74faae6c1b91202f19184811e326547e5
valid
hourly_frequencies
Return all the number of vehicles (i.e. busses,trams,etc) that pass hourly through a stop in a time frame. Parameters ---------- gtfs: GTFS st : int start time of the time framein unix time et : int end time of the time frame in unix time route_type: int Returns -------...
gtfspy/stats.py
def hourly_frequencies(gtfs, st, et, route_type): """ Return all the number of vehicles (i.e. busses,trams,etc) that pass hourly through a stop in a time frame. Parameters ---------- gtfs: GTFS st : int start time of the time framein unix time et : int end time of the time f...
def hourly_frequencies(gtfs, st, et, route_type): """ Return all the number of vehicles (i.e. busses,trams,etc) that pass hourly through a stop in a time frame. Parameters ---------- gtfs: GTFS st : int start time of the time framein unix time et : int end time of the time f...
[ "Return", "all", "the", "number", "of", "vehicles", "(", "i", ".", "e", ".", "busses", "trams", "etc", ")", "that", "pass", "hourly", "through", "a", "stop", "in", "a", "time", "frame", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L536-L574
[ "def", "hourly_frequencies", "(", "gtfs", ",", "st", ",", "et", ",", "route_type", ")", ":", "timeframe", "=", "et", "-", "st", "hours", "=", "timeframe", "/", "3600", "day", "=", "gtfs", ".", "get_suitable_date_for_daily_extract", "(", ")", "stops", "=", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
get_vehicle_hours_by_type
Return the sum of vehicle hours in a particular day by route type.
gtfspy/stats.py
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...
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...
[ "Return", "the", "sum", "of", "vehicle", "hours", "in", "a", "particular", "day", "by", "route", "type", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L607-L622
[ "def", "get_vehicle_hours_by_type", "(", "gtfs", ",", "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 *...
bddba4b74faae6c1b91202f19184811e326547e5
valid
ConnectionScan._scan_footpaths
Scan the footpaths originating from stop_id Parameters ---------- stop_id: int
gtfspy/routing/connection_scan.py
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"...
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"...
[ "Scan", "the", "footpaths", "originating", "from", "stop_id" ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/connection_scan.py#L92-L103
[ "def", "_scan_footpaths", "(", "self", ",", "stop_id", ",", "walk_departure_time", ")", ":", "for", "_", ",", "neighbor", ",", "data", "in", "self", ".", "_walk_network", ".", "edges_iter", "(", "nbunch", "=", "[", "stop_id", "]", ",", "data", "=", "True...
bddba4b74faae6c1b91202f19184811e326547e5
valid
timeit
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
gtfspy/routing/util.py
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, *...
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, *...
[ "A", "Python", "decorator", "for", "printing", "out", "the", "execution", "time", "for", "a", "function", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/util.py#L3-L17
[ "def", "timeit", "(", "method", ")", ":", "def", "timed", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "time_start", "=", "time", ".", "time", "(", ")", "result", "=", "method", "(", "*", "args", ",", "*", "*", "kw", ")", "time_end", "=", ...
bddba4b74faae6c1b91202f19184811e326547e5
valid
TimetableValidator.validate_and_get_warnings
Validates/checks a given GTFS feed with respect to a number of different issues. The set of warnings that are checked for, can be found in the gtfs_validator.ALL_WARNINGS Returns ------- warnings: WarningsContainer
gtfspy/timetable_validator.py
def validate_and_get_warnings(self): """ Validates/checks a given GTFS feed with respect to a number of different issues. The set of warnings that are checked for, can be found in the gtfs_validator.ALL_WARNINGS Returns ------- warnings: WarningsContainer """ ...
def validate_and_get_warnings(self): """ Validates/checks a given GTFS feed with respect to a number of different issues. The set of warnings that are checked for, can be found in the gtfs_validator.ALL_WARNINGS Returns ------- warnings: WarningsContainer """ ...
[ "Validates", "/", "checks", "a", "given", "GTFS", "feed", "with", "respect", "to", "a", "number", "of", "different", "issues", "." ]
CxAalto/gtfspy
python
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/timetable_validator.py#L70-L86
[ "def", "validate_and_get_warnings", "(", "self", ")", ":", "self", ".", "warnings_container", ".", "clear", "(", ")", "self", ".", "_validate_stops_with_same_stop_time", "(", ")", "self", ".", "_validate_speeds_and_trip_times", "(", ")", "self", ".", "_validate_stop...
bddba4b74faae6c1b91202f19184811e326547e5
valid
LockdownForm.clean_password
Check that the password is valid.
lockdown/forms.py
def clean_password(self): """Check that the password is valid.""" value = self.cleaned_data.get('password') if value not in self.valid_passwords: raise forms.ValidationError('Incorrect password.') return value
def clean_password(self): """Check that the password is valid.""" value = self.cleaned_data.get('password') if value not in self.valid_passwords: raise forms.ValidationError('Incorrect password.') return value
[ "Check", "that", "the", "password", "is", "valid", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/forms.py#L22-L27
[ "def", "clean_password", "(", "self", ")", ":", "value", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password'", ")", "if", "value", "not", "in", "self", ".", "valid_passwords", ":", "raise", "forms", ".", "ValidationError", "(", "'Incorrect passwor...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
AuthForm.clean
When receiving the filled out form, check for valid access.
lockdown/forms.py
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.') ...
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.') ...
[ "When", "receiving", "the", "filled", "out", "form", "check", "for", "valid", "access", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/forms.py#L72-L80
[ "def", "clean", "(", "self", ")", ":", "cleaned_data", "=", "super", "(", "AuthForm", ",", "self", ")", ".", "clean", "(", ")", "user", "=", "self", ".", "get_user", "(", ")", "if", "self", ".", "staff_only", "and", "(", "not", "user", "or", "not",...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
AuthForm.authenticate
Check that the password is valid. This allows for revoking of a user's preview rights by changing the valid passwords.
lockdown/forms.py
def authenticate(self, token_value): """Check that the password is valid. This allows for revoking of a user's preview rights by changing the valid passwords. """ try: backend_path, user_id = token_value.split(':', 1) except (ValueError, AttributeError): ...
def authenticate(self, token_value): """Check that the password is valid. This allows for revoking of a user's preview rights by changing the valid passwords. """ try: backend_path, user_id = token_value.split(':', 1) except (ValueError, AttributeError): ...
[ "Check", "that", "the", "password", "is", "valid", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/forms.py#L91-L102
[ "def", "authenticate", "(", "self", ",", "token_value", ")", ":", "try", ":", "backend_path", ",", "user_id", "=", "token_value", ".", "split", "(", "':'", ",", "1", ")", "except", "(", "ValueError", ",", "AttributeError", ")", ":", "return", "False", "b...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
get_lockdown_form
Return a form class for a given string pointing to a lockdown form.
lockdown/middleware.py
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] ...
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] ...
[ "Return", "a", "form", "class", "for", "a", "given", "string", "pointing", "to", "a", "lockdown", "form", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/middleware.py#L21-L40
[ "def", "get_lockdown_form", "(", "form_path", ")", ":", "if", "not", "form_path", ":", "raise", "ImproperlyConfigured", "(", "'No LOCKDOWN_FORM specified.'", ")", "form_path_list", "=", "form_path", ".", "split", "(", "\".\"", ")", "new_module", "=", "\".\"", ".",...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
LockdownMiddleware.process_request
Check if each request is allowed to access the current resource.
lockdown/middleware.py
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...
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...
[ "Check", "if", "each", "request", "is", "allowed", "to", "access", "the", "current", "resource", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/middleware.py#L81-L194
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "try", ":", "session", "=", "request", ".", "session", "except", "AttributeError", ":", "raise", "ImproperlyConfigured", "(", "'django-lockdown requires the Django '", "'sessions framework'", ")", "# Don...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
LockdownMiddleware.redirect
Handle redirects properly.
lockdown/middleware.py
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...
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...
[ "Handle", "redirects", "properly", "." ]
Dunedan/django-lockdown
python
https://github.com/Dunedan/django-lockdown/blob/f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec/lockdown/middleware.py#L196-L204
[ "def", "redirect", "(", "self", ",", "request", ")", ":", "url", "=", "request", ".", "path", "querystring", "=", "request", ".", "GET", ".", "copy", "(", ")", "if", "self", ".", "logout_key", "and", "self", ".", "logout_key", "in", "request", ".", "...
f2f3fee174e14e2da32c6d4f8528ba6b8c2106ec
valid
infer
https://github.com/frictionlessdata/datapackage-py#infer
datapackage/infer.py
def infer(pattern, base_path=None): """https://github.com/frictionlessdata/datapackage-py#infer """ package = Package({}, base_path=base_path) descriptor = package.infer(pattern) return descriptor
def infer(pattern, base_path=None): """https://github.com/frictionlessdata/datapackage-py#infer """ package = Package({}, base_path=base_path) descriptor = package.infer(pattern) return descriptor
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#infer" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/infer.py#L13-L18
[ "def", "infer", "(", "pattern", ",", "base_path", "=", "None", ")", ":", "package", "=", "Package", "(", "{", "}", ",", "base_path", "=", "base_path", ")", "descriptor", "=", "package", ".", "infer", "(", "pattern", ")", "return", "descriptor" ]
aca085ea54541b087140b58a81332f8728baeeb2
valid
Registry.get
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: profile_id (str): The ID of the ...
datapackage/registry.py
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: ...
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: ...
[ "Returns", "the", "profile", "with", "the", "received", "ID", "as", "a", "dict" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/registry.py#L61-L81
[ "def", "get", "(", "self", ",", "profile_id", ")", ":", "if", "profile_id", "not", "in", "self", ".", "_profiles", ":", "try", ":", "self", ".", "_profiles", "[", "profile_id", "]", "=", "self", ".", "_get_profile", "(", "profile_id", ")", "except", "(...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Registry._get_profile
dict: Return the profile with the received ID as a dict (None if it doesn't exist).
datapackage/registry.py
def _get_profile(self, profile_id): '''dict: Return the profile with the received ID as a dict (None if it doesn't exist).''' profile_metadata = self._registry.get(profile_id) if not profile_metadata: return path = self._get_absolute_path(profile_metadata.get('schema...
def _get_profile(self, profile_id): '''dict: Return the profile with the received ID as a dict (None if it doesn't exist).''' profile_metadata = self._registry.get(profile_id) if not profile_metadata: return path = self._get_absolute_path(profile_metadata.get('schema...
[ "dict", ":", "Return", "the", "profile", "with", "the", "received", "ID", "as", "a", "dict", "(", "None", "if", "it", "doesn", "t", "exist", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/registry.py#L85-L110
[ "def", "_get_profile", "(", "self", ",", "profile_id", ")", ":", "profile_metadata", "=", "self", ".", "_registry", ".", "get", "(", "profile_id", ")", "if", "not", "profile_metadata", ":", "return", "path", "=", "self", ".", "_get_absolute_path", "(", "prof...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Registry._get_registry
dict: Return the registry as dict with profiles keyed by id.
datapackage/registry.py
def _get_registry(self, registry_path_or_url): '''dict: Return the registry as dict with profiles keyed by id.''' if registry_path_or_url.startswith('http'): profiles = self._load_json_url(registry_path_or_url) else: profiles = self._load_json_file(registry_path_or_url) ...
def _get_registry(self, registry_path_or_url): '''dict: Return the registry as dict with profiles keyed by id.''' if registry_path_or_url.startswith('http'): profiles = self._load_json_url(registry_path_or_url) else: profiles = self._load_json_file(registry_path_or_url) ...
[ "dict", ":", "Return", "the", "registry", "as", "dict", "with", "profiles", "keyed", "by", "id", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/registry.py#L112-L127
[ "def", "_get_registry", "(", "self", ",", "registry_path_or_url", ")", ":", "if", "registry_path_or_url", ".", "startswith", "(", "'http'", ")", ":", "profiles", "=", "self", ".", "_load_json_url", "(", "registry_path_or_url", ")", "else", ":", "profiles", "=", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Registry._get_absolute_path
str: Return the received relative_path joined with the base path (None if there were some error).
datapackage/registry.py
def _get_absolute_path(self, relative_path): '''str: Return the received relative_path joined with the base path (None if there were some error).''' try: return os.path.join(self.base_path, relative_path) except (AttributeError, TypeError): pass
def _get_absolute_path(self, relative_path): '''str: Return the received relative_path joined with the base path (None if there were some error).''' try: return os.path.join(self.base_path, relative_path) except (AttributeError, TypeError): pass
[ "str", ":", "Return", "the", "received", "relative_path", "joined", "with", "the", "base", "path", "(", "None", "if", "there", "were", "some", "error", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/registry.py#L129-L135
[ "def", "_get_absolute_path", "(", "self", ",", "relative_path", ")", ":", "try", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "base_path", ",", "relative_path", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "pass" ]
aca085ea54541b087140b58a81332f8728baeeb2
valid
Registry._load_json_url
dict: Return the JSON at the local path or URL as a dict.
datapackage/registry.py
def _load_json_url(self, url): '''dict: Return the JSON at the local path or URL as a dict.''' res = requests.get(url) res.raise_for_status() return res.json()
def _load_json_url(self, url): '''dict: Return the JSON at the local path or URL as a dict.''' res = requests.get(url) res.raise_for_status() return res.json()
[ "dict", ":", "Return", "the", "JSON", "at", "the", "local", "path", "or", "URL", "as", "a", "dict", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/registry.py#L141-L146
[ "def", "_load_json_url", "(", "self", ",", "url", ")", ":", "res", "=", "requests", ".", "get", "(", "url", ")", "res", ".", "raise_for_status", "(", ")", "return", "res", ".", "json", "(", ")" ]
aca085ea54541b087140b58a81332f8728baeeb2
valid
get_descriptor_base_path
Get descriptor base path if string or return None.
datapackage/helpers.py
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: # ...
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: # ...
[ "Get", "descriptor", "base", "path", "if", "string", "or", "return", "None", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L20-L36
[ "def", "get_descriptor_base_path", "(", "descriptor", ")", ":", "# Infer from path/url", "if", "isinstance", "(", "descriptor", ",", "six", ".", "string_types", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "descriptor", ")", ":", "base_path", "=", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
retrieve_descriptor
Retrieve descriptor.
datapackage/helpers.py
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,...
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,...
[ "Retrieve", "descriptor", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L41-L78
[ "def", "retrieve_descriptor", "(", "descriptor", ")", ":", "the_descriptor", "=", "descriptor", "if", "the_descriptor", "is", "None", ":", "the_descriptor", "=", "{", "}", "if", "isinstance", "(", "the_descriptor", ",", "six", ".", "string_types", ")", ":", "t...
aca085ea54541b087140b58a81332f8728baeeb2
valid
dereference_package_descriptor
Dereference data package descriptor (IN-PLACE FOR NOW).
datapackage/helpers.py
def dereference_package_descriptor(descriptor, base_path): """Dereference data package descriptor (IN-PLACE FOR NOW). """ for resource in descriptor.get('resources', []): dereference_resource_descriptor(resource, base_path, descriptor) return descriptor
def dereference_package_descriptor(descriptor, base_path): """Dereference data package descriptor (IN-PLACE FOR NOW). """ for resource in descriptor.get('resources', []): dereference_resource_descriptor(resource, base_path, descriptor) return descriptor
[ "Dereference", "data", "package", "descriptor", "(", "IN", "-", "PLACE", "FOR", "NOW", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L83-L88
[ "def", "dereference_package_descriptor", "(", "descriptor", ",", "base_path", ")", ":", "for", "resource", "in", "descriptor", ".", "get", "(", "'resources'", ",", "[", "]", ")", ":", "dereference_resource_descriptor", "(", "resource", ",", "base_path", ",", "de...
aca085ea54541b087140b58a81332f8728baeeb2
valid
dereference_resource_descriptor
Dereference resource descriptor (IN-PLACE FOR NOW).
datapackage/helpers.py
def dereference_resource_descriptor(descriptor, base_path, base_descriptor=None): """Dereference resource descriptor (IN-PLACE FOR NOW). """ PROPERTIES = ['schema', 'dialect'] if base_descriptor is None: base_descriptor = descriptor for property in PROPERTIES: value = descriptor.get(...
def dereference_resource_descriptor(descriptor, base_path, base_descriptor=None): """Dereference resource descriptor (IN-PLACE FOR NOW). """ PROPERTIES = ['schema', 'dialect'] if base_descriptor is None: base_descriptor = descriptor for property in PROPERTIES: value = descriptor.get(...
[ "Dereference", "resource", "descriptor", "(", "IN", "-", "PLACE", "FOR", "NOW", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L91-L150
[ "def", "dereference_resource_descriptor", "(", "descriptor", ",", "base_path", ",", "base_descriptor", "=", "None", ")", ":", "PROPERTIES", "=", "[", "'schema'", ",", "'dialect'", "]", "if", "base_descriptor", "is", "None", ":", "base_descriptor", "=", "descriptor...
aca085ea54541b087140b58a81332f8728baeeb2
valid
expand_package_descriptor
Apply defaults to data package descriptor (IN-PLACE FOR NOW).
datapackage/helpers.py
def expand_package_descriptor(descriptor): """Apply defaults to data package descriptor (IN-PLACE FOR NOW). """ descriptor.setdefault('profile', config.DEFAULT_DATA_PACKAGE_PROFILE) for resource in descriptor.get('resources', []): expand_resource_descriptor(resource) return descriptor
def expand_package_descriptor(descriptor): """Apply defaults to data package descriptor (IN-PLACE FOR NOW). """ descriptor.setdefault('profile', config.DEFAULT_DATA_PACKAGE_PROFILE) for resource in descriptor.get('resources', []): expand_resource_descriptor(resource) return descriptor
[ "Apply", "defaults", "to", "data", "package", "descriptor", "(", "IN", "-", "PLACE", "FOR", "NOW", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L155-L161
[ "def", "expand_package_descriptor", "(", "descriptor", ")", ":", "descriptor", ".", "setdefault", "(", "'profile'", ",", "config", ".", "DEFAULT_DATA_PACKAGE_PROFILE", ")", "for", "resource", "in", "descriptor", ".", "get", "(", "'resources'", ",", "[", "]", ")"...
aca085ea54541b087140b58a81332f8728baeeb2
valid
expand_resource_descriptor
Apply defaults to resource descriptor (IN-PLACE FOR NOW).
datapackage/helpers.py
def expand_resource_descriptor(descriptor): """Apply defaults to resource descriptor (IN-PLACE FOR NOW). """ descriptor.setdefault('profile', config.DEFAULT_RESOURCE_PROFILE) if descriptor['profile'] == 'tabular-data-resource': # Schema schema = descriptor.get('schema') if schem...
def expand_resource_descriptor(descriptor): """Apply defaults to resource descriptor (IN-PLACE FOR NOW). """ descriptor.setdefault('profile', config.DEFAULT_RESOURCE_PROFILE) if descriptor['profile'] == 'tabular-data-resource': # Schema schema = descriptor.get('schema') if schem...
[ "Apply", "defaults", "to", "resource", "descriptor", "(", "IN", "-", "PLACE", "FOR", "NOW", ")", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L164-L184
[ "def", "expand_resource_descriptor", "(", "descriptor", ")", ":", "descriptor", ".", "setdefault", "(", "'profile'", ",", "config", ".", "DEFAULT_RESOURCE_PROFILE", ")", "if", "descriptor", "[", "'profile'", "]", "==", "'tabular-data-resource'", ":", "# Schema", "sc...
aca085ea54541b087140b58a81332f8728baeeb2
valid
is_safe_path
Check if path is safe and allowed.
datapackage/helpers.py
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(...
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(...
[ "Check", "if", "path", "is", "safe", "and", "allowed", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/helpers.py#L197-L212
[ "def", "is_safe_path", "(", "path", ")", ":", "contains_windows_var", "=", "lambda", "val", ":", "re", ".", "match", "(", "r'%.+%'", ",", "val", ")", "contains_posix_var", "=", "lambda", "val", ":", "re", ".", "match", "(", "r'\\$.+'", ",", "val", ")", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_extract_zip_if_possible
If descriptor is a path to zip file extract and return (tempdir, descriptor)
datapackage/package.py
def _extract_zip_if_possible(descriptor): """If descriptor is a path to zip file extract and return (tempdir, descriptor) """ tempdir = None result = descriptor try: if isinstance(descriptor, six.string_types): res = requests.get(descriptor) res.raise_for_status() ...
def _extract_zip_if_possible(descriptor): """If descriptor is a path to zip file extract and return (tempdir, descriptor) """ tempdir = None result = descriptor try: if isinstance(descriptor, six.string_types): res = requests.get(descriptor) res.raise_for_status() ...
[ "If", "descriptor", "is", "a", "path", "to", "zip", "file", "extract", "and", "return", "(", "tempdir", "descriptor", ")" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L432-L471
[ "def", "_extract_zip_if_possible", "(", "descriptor", ")", ":", "tempdir", "=", "None", "result", "=", "descriptor", "try", ":", "if", "isinstance", "(", "descriptor", ",", "six", ".", "string_types", ")", ":", "res", "=", "requests", ".", "get", "(", "des...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_validate_zip
Validate zipped data package
datapackage/package.py
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(...
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(...
[ "Validate", "zipped", "data", "package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L474-L480
[ "def", "_validate_zip", "(", "the_zip", ")", ":", "datapackage_jsons", "=", "[", "f", "for", "f", "in", "the_zip", ".", "namelist", "(", ")", "if", "f", ".", "endswith", "(", "'datapackage.json'", ")", "]", "if", "len", "(", "datapackage_jsons", ")", "!=...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_slugify_foreign_key
Slugify foreign key
datapackage/package.py
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
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
[ "Slugify", "foreign", "key" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L489-L495
[ "def", "_slugify_foreign_key", "(", "schema", ")", ":", "for", "foreign_key", "in", "schema", ".", "get", "(", "'foreignKeys'", ",", "[", "]", ")", ":", "foreign_key", "[", "'reference'", "]", "[", "'resource'", "]", "=", "_slugify_resource_name", "(", "fore...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.get_resource
https://github.com/frictionlessdata/datapackage-py#package
datapackage/package.py
def get_resource(self, name): """https://github.com/frictionlessdata/datapackage-py#package """ for resource in self.resources: if resource.name == name: return resource return None
def get_resource(self, name): """https://github.com/frictionlessdata/datapackage-py#package """ for resource in self.resources: if resource.name == name: return resource return None
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L156-L162
[ "def", "get_resource", "(", "self", ",", "name", ")", ":", "for", "resource", "in", "self", ".", "resources", ":", "if", "resource", ".", "name", "==", "name", ":", "return", "resource", "return", "None" ]
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.add_resource
https://github.com/frictionlessdata/datapackage-py#package
datapackage/package.py
def add_resource(self, descriptor): """https://github.com/frictionlessdata/datapackage-py#package """ self.__current_descriptor.setdefault('resources', []) self.__current_descriptor['resources'].append(descriptor) self.__build() return self.__resources[-1]
def add_resource(self, descriptor): """https://github.com/frictionlessdata/datapackage-py#package """ self.__current_descriptor.setdefault('resources', []) self.__current_descriptor['resources'].append(descriptor) self.__build() return self.__resources[-1]
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L164-L170
[ "def", "add_resource", "(", "self", ",", "descriptor", ")", ":", "self", ".", "__current_descriptor", ".", "setdefault", "(", "'resources'", ",", "[", "]", ")", "self", ".", "__current_descriptor", "[", "'resources'", "]", ".", "append", "(", "descriptor", "...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.remove_resource
https://github.com/frictionlessdata/datapackage-py#package
datapackage/package.py
def remove_resource(self, name): """https://github.com/frictionlessdata/datapackage-py#package """ resource = self.get_resource(name) if resource: predicat = lambda resource: resource.get('name') != name self.__current_descriptor['resources'] = list(filter( ...
def remove_resource(self, name): """https://github.com/frictionlessdata/datapackage-py#package """ resource = self.get_resource(name) if resource: predicat = lambda resource: resource.get('name') != name self.__current_descriptor['resources'] = list(filter( ...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L172-L181
[ "def", "remove_resource", "(", "self", ",", "name", ")", ":", "resource", "=", "self", ".", "get_resource", "(", "name", ")", "if", "resource", ":", "predicat", "=", "lambda", "resource", ":", "resource", ".", "get", "(", "'name'", ")", "!=", "name", "...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.infer
https://github.com/frictionlessdata/datapackage-py#package
datapackage/package.py
def infer(self, pattern=False): """https://github.com/frictionlessdata/datapackage-py#package """ # Files if pattern: # No base path if not self.__base_path: message = 'Base path is required for pattern infer' raise exceptions.Dat...
def infer(self, pattern=False): """https://github.com/frictionlessdata/datapackage-py#package """ # Files if pattern: # No base path if not self.__base_path: message = 'Base path is required for pattern infer' raise exceptions.Dat...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L183-L212
[ "def", "infer", "(", "self", ",", "pattern", "=", "False", ")", ":", "# Files", "if", "pattern", ":", "# No base path", "if", "not", "self", ".", "__base_path", ":", "message", "=", "'Base path is required for pattern infer'", "raise", "exceptions", ".", "DataPa...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.save
https://github.com/frictionlessdata/datapackage-py#package
datapackage/package.py
def save(self, target=None, storage=None, **options): """https://github.com/frictionlessdata/datapackage-py#package """ # Save package to storage if storage is not None: if not isinstance(storage, Storage): storage = Storage.connect(storage, **options) ...
def save(self, target=None, storage=None, **options): """https://github.com/frictionlessdata/datapackage-py#package """ # Save package to storage if storage is not None: if not isinstance(storage, Storage): storage = Storage.connect(storage, **options) ...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#package" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L225-L279
[ "def", "save", "(", "self", ",", "target", "=", "None", ",", "storage", "=", "None", ",", "*", "*", "options", ")", ":", "# Save package to storage", "if", "storage", "is", "not", "None", ":", "if", "not", "isinstance", "(", "storage", ",", "Storage", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.attributes
tuple: Attributes defined in the schema and the data package.
datapackage/package.py
def attributes(self): """tuple: Attributes defined in the schema and the data package. """ # Deprecate warnings.warn( 'Property "package.attributes" is deprecated.', UserWarning) # Get attributes attributes = set(self.to_dict().keys()) tr...
def attributes(self): """tuple: Attributes defined in the schema and the data package. """ # Deprecate warnings.warn( 'Property "package.attributes" is deprecated.', UserWarning) # Get attributes attributes = set(self.to_dict().keys()) tr...
[ "tuple", ":", "Attributes", "defined", "in", "the", "schema", "and", "the", "data", "package", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L346-L362
[ "def", "attributes", "(", "self", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"package.attributes\" is deprecated.'", ",", "UserWarning", ")", "# Get attributes", "attributes", "=", "set", "(", "self", ".", "to_dict", "(", ")", ".", "keys", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.required_attributes
tuple: The schema's required attributed.
datapackage/package.py
def required_attributes(self): """tuple: The schema's required attributed. """ # Deprecate warnings.warn( 'Property "package.required_attributes" is deprecated.', UserWarning) required = () # Get required try: if self.profile....
def required_attributes(self): """tuple: The schema's required attributed. """ # Deprecate warnings.warn( 'Property "package.required_attributes" is deprecated.', UserWarning) required = () # Get required try: if self.profile....
[ "tuple", ":", "The", "schema", "s", "required", "attributed", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L365-L382
[ "def", "required_attributes", "(", "self", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"package.required_attributes\" is deprecated.'", ",", "UserWarning", ")", "required", "=", "(", ")", "# Get required", "try", ":", "if", "self", ".", "profi...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.validate
Validate this Data Package.
datapackage/package.py
def validate(self): """"Validate this Data Package. """ # Deprecate warnings.warn( 'Property "package.validate" is deprecated.', UserWarning) descriptor = self.to_dict() self.profile.validate(descriptor)
def validate(self): """"Validate this Data Package. """ # Deprecate warnings.warn( 'Property "package.validate" is deprecated.', UserWarning) descriptor = self.to_dict() self.profile.validate(descriptor)
[ "Validate", "this", "Data", "Package", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L384-L394
[ "def", "validate", "(", "self", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"package.validate\" is deprecated.'", ",", "UserWarning", ")", "descriptor", "=", "self", ".", "to_dict", "(", ")", "self", ".", "profile", ".", "validate", "(", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Package.iter_errors
Lazily yields each ValidationError for the received data dict.
datapackage/package.py
def iter_errors(self): """"Lazily yields each ValidationError for the received data dict. """ # Deprecate warnings.warn( 'Property "package.iter_errors" is deprecated.', UserWarning) return self.profile.iter_errors(self.to_dict())
def iter_errors(self): """"Lazily yields each ValidationError for the received data dict. """ # Deprecate warnings.warn( 'Property "package.iter_errors" is deprecated.', UserWarning) return self.profile.iter_errors(self.to_dict())
[ "Lazily", "yields", "each", "ValidationError", "for", "the", "received", "data", "dict", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L396-L405
[ "def", "iter_errors", "(", "self", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"package.iter_errors\" is deprecated.'", ",", "UserWarning", ")", "return", "self", ".", "profile", ".", "iter_errors", "(", "self", ".", "to_dict", "(", ")", "...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Profile.validate
https://github.com/frictionlessdata/datapackage-py#schema
datapackage/profile.py
def validate(self, descriptor): """https://github.com/frictionlessdata/datapackage-py#schema """ # Collect errors errors = [] for error in self._validator.iter_errors(descriptor): if isinstance(error, jsonschema.exceptions.ValidationError): message = ...
def validate(self, descriptor): """https://github.com/frictionlessdata/datapackage-py#schema """ # Collect errors errors = [] for error in self._validator.iter_errors(descriptor): if isinstance(error, jsonschema.exceptions.ValidationError): message = ...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#schema" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/profile.py#L44-L69
[ "def", "validate", "(", "self", ",", "descriptor", ")", ":", "# Collect errors", "errors", "=", "[", "]", "for", "error", "in", "self", ".", "_validator", ".", "iter_errors", "(", "descriptor", ")", ":", "if", "isinstance", "(", "error", ",", "jsonschema",...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Profile.iter_errors
Lazily yields each ValidationError for the received data dict.
datapackage/profile.py
def iter_errors(self, data): """Lazily yields each ValidationError for the received data dict. """ # Deprecate warnings.warn( 'Property "profile.iter_errors" is deprecated.', UserWarning) for error in self._validator.iter_errors(data): yield ...
def iter_errors(self, data): """Lazily yields each ValidationError for the received data dict. """ # Deprecate warnings.warn( 'Property "profile.iter_errors" is deprecated.', UserWarning) for error in self._validator.iter_errors(data): yield ...
[ "Lazily", "yields", "each", "ValidationError", "for", "the", "received", "data", "dict", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/profile.py#L135-L145
[ "def", "iter_errors", "(", "self", ",", "data", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"profile.iter_errors\" is deprecated.'", ",", "UserWarning", ")", "for", "error", "in", "self", ".", "_validator", ".", "iter_errors", "(", "data", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.tabular
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def tabular(self): """https://github.com/frictionlessdata/datapackage-py#resource """ if self.__current_descriptor.get('profile') == 'tabular-data-resource': return True if not self.__strict: if self.__current_descriptor.get('format') in config.TABULAR_FORMATS: ...
def tabular(self): """https://github.com/frictionlessdata/datapackage-py#resource """ if self.__current_descriptor.get('profile') == 'tabular-data-resource': return True if not self.__strict: if self.__current_descriptor.get('format') in config.TABULAR_FORMATS: ...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L127-L137
[ "def", "tabular", "(", "self", ")", ":", "if", "self", ".", "__current_descriptor", ".", "get", "(", "'profile'", ")", "==", "'tabular-data-resource'", ":", "return", "True", "if", "not", "self", ".", "__strict", ":", "if", "self", ".", "__current_descriptor...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.iter
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def iter(self, relations=False, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ # Error for non tabular if not self.tabular: message = 'Methods iter/read are not supported for non tabular data' raise exceptions.DataPackageException(...
def iter(self, relations=False, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ # Error for non tabular if not self.tabular: message = 'Methods iter/read are not supported for non tabular data' raise exceptions.DataPackageException(...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L161-L174
[ "def", "iter", "(", "self", ",", "relations", "=", "False", ",", "*", "*", "options", ")", ":", "# Error for non tabular", "if", "not", "self", ".", "tabular", ":", "message", "=", "'Methods iter/read are not supported for non tabular data'", "raise", "exceptions", ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.raw_iter
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def raw_iter(self, stream=False): """https://github.com/frictionlessdata/datapackage-py#resource """ # Error for inline if self.inline: message = 'Methods raw_iter/raw_read are not supported for inline data' raise exceptions.DataPackageException(message) ...
def raw_iter(self, stream=False): """https://github.com/frictionlessdata/datapackage-py#resource """ # Error for inline if self.inline: message = 'Methods raw_iter/raw_read are not supported for inline data' raise exceptions.DataPackageException(message) ...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L197-L220
[ "def", "raw_iter", "(", "self", ",", "stream", "=", "False", ")", ":", "# Error for inline", "if", "self", ".", "inline", ":", "message", "=", "'Methods raw_iter/raw_read are not supported for inline data'", "raise", "exceptions", ".", "DataPackageException", "(", "me...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.raw_read
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def raw_read(self): """https://github.com/frictionlessdata/datapackage-py#resource """ contents = b'' with self.raw_iter() as filelike: for chunk in filelike: contents += chunk return contents
def raw_read(self): """https://github.com/frictionlessdata/datapackage-py#resource """ contents = b'' with self.raw_iter() as filelike: for chunk in filelike: contents += chunk return contents
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L222-L229
[ "def", "raw_read", "(", "self", ")", ":", "contents", "=", "b''", "with", "self", ".", "raw_iter", "(", ")", "as", "filelike", ":", "for", "chunk", "in", "filelike", ":", "contents", "+=", "chunk", "return", "contents" ]
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.infer
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def infer(self, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ descriptor = deepcopy(self.__current_descriptor) # Blank -> Stop if self.__source_inspection.get('blank'): return descriptor # Name if not descriptor.get('...
def infer(self, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ descriptor = deepcopy(self.__current_descriptor) # Blank -> Stop if self.__source_inspection.get('blank'): return descriptor # Name if not descriptor.get('...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L231-L281
[ "def", "infer", "(", "self", ",", "*", "*", "options", ")", ":", "descriptor", "=", "deepcopy", "(", "self", ".", "__current_descriptor", ")", "# Blank -> Stop", "if", "self", ".", "__source_inspection", ".", "get", "(", "'blank'", ")", ":", "return", "des...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.commit
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def commit(self, strict=None): """https://github.com/frictionlessdata/datapackage-py#resource """ if strict is not None: self.__strict = strict elif self.__current_descriptor == self.__next_descriptor: return False self.__current_descriptor = deepcopy(self...
def commit(self, strict=None): """https://github.com/frictionlessdata/datapackage-py#resource """ if strict is not None: self.__strict = strict elif self.__current_descriptor == self.__next_descriptor: return False self.__current_descriptor = deepcopy(self...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L283-L293
[ "def", "commit", "(", "self", ",", "strict", "=", "None", ")", ":", "if", "strict", "is", "not", "None", ":", "self", ".", "__strict", "=", "strict", "elif", "self", ".", "__current_descriptor", "==", "self", ".", "__next_descriptor", ":", "return", "Fal...
aca085ea54541b087140b58a81332f8728baeeb2
valid
Resource.save
https://github.com/frictionlessdata/datapackage-py#resource
datapackage/resource.py
def save(self, target, storage=None, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ # Save resource to storage if storage is not None: if self.tabular: self.infer() storage.create(target, self.schema.descriptor,...
def save(self, target, storage=None, **options): """https://github.com/frictionlessdata/datapackage-py#resource """ # Save resource to storage if storage is not None: if self.tabular: self.infer() storage.create(target, self.schema.descriptor,...
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "datapackage", "-", "py#resource" ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/resource.py#L295-L315
[ "def", "save", "(", "self", ",", "target", ",", "storage", "=", "None", ",", "*", "*", "options", ")", ":", "# Save resource to storage", "if", "storage", "is", "not", "None", ":", "if", "self", ".", "tabular", ":", "self", ".", "infer", "(", ")", "s...
aca085ea54541b087140b58a81332f8728baeeb2
valid
push_datapackage
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 mentioned in backend docs
datapackage/pushpull.py
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...
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...
[ "Push", "Data", "Package", "to", "storage", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L23-L86
[ "def", "push_datapackage", "(", "descriptor", ",", "backend", ",", "*", "*", "backend_options", ")", ":", "# Deprecated", "warnings", ".", "warn", "(", "'Functions \"push/pull_datapackage\" are deprecated. '", "'Please use \"Package\" class'", ",", "UserWarning", ")", "# ...
aca085ea54541b087140b58a81332f8728baeeb2
valid
pull_datapackage
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 like `sql` or `bigquery` backend_options (dict): backend options men...
datapackage/pushpull.py
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...
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...
[ "Pull", "Data", "Package", "from", "storage", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L89-L157
[ "def", "pull_datapackage", "(", "descriptor", ",", "name", ",", "backend", ",", "*", "*", "backend_options", ")", ":", "# Deprecated", "warnings", ".", "warn", "(", "'Functions \"push/pull_datapackage\" are deprecated. '", "'Please use \"Package\" class'", ",", "UserWarni...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_convert_path
Convert resource's path and name to storage's table name. Args: path (str): resource path name (str): resource name Returns: str: table name
datapackage/pushpull.py
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 ...
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 ...
[ "Convert", "resource", "s", "path", "and", "name", "to", "storage", "s", "table", "name", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L162-L179
[ "def", "_convert_path", "(", "path", ",", "name", ")", ":", "table", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "[", "0", "]", "table", "=", "table", ".", "replace", "(", "os", ".", "path", ".", "sep", ",", "'__'", ")", "if", "n...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_restore_path
Restore resource's path and name from storage's table. Args: table (str): table name Returns: (str, str): resource path and name
datapackage/pushpull.py
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] ...
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] ...
[ "Restore", "resource", "s", "path", "and", "name", "from", "storage", "s", "table", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L182-L199
[ "def", "_restore_path", "(", "table", ")", ":", "name", "=", "None", "splited", "=", "table", ".", "split", "(", "'___'", ")", "path", "=", "splited", "[", "0", "]", "if", "len", "(", "splited", ")", "==", "2", ":", "name", "=", "splited", "[", "...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_convert_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 for some foreign key in given mapping Ret...
datapackage/pushpull.py
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 ...
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 ...
[ "Convert", "schemas", "to", "be", "compatible", "with", "storage", "schemas", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L202-L229
[ "def", "_convert_schemas", "(", "mapping", ",", "schemas", ")", ":", "schemas", "=", "deepcopy", "(", "schemas", ")", "for", "schema", "in", "schemas", ":", "for", "fk", "in", "schema", ".", "get", "(", "'foreignKeys'", ",", "[", "]", ")", ":", "resour...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_restore_resources
Restore schemas from being compatible with storage schemas. Foreign keys related operations. Args: list: resources from storage Returns: list: restored resources
datapackage/pushpull.py
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...
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...
[ "Restore", "schemas", "from", "being", "compatible", "with", "storage", "schemas", "." ]
frictionlessdata/datapackage-py
python
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L232-L250
[ "def", "_restore_resources", "(", "resources", ")", ":", "resources", "=", "deepcopy", "(", "resources", ")", "for", "resource", "in", "resources", ":", "schema", "=", "resource", "[", "'schema'", "]", "for", "fk", "in", "schema", ".", "get", "(", "'foreig...
aca085ea54541b087140b58a81332f8728baeeb2
valid
_buffer_incomplete_responses
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 buffer of gdb's output if the output did not end in a ...
pygdbmi/gdbcontroller.py
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 ...
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 ...
[ "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", "pars...
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L444-L477
[ "def", "_buffer_incomplete_responses", "(", "raw_output", ",", "buf", ")", ":", "if", "raw_output", ":", "if", "buf", ":", "# concatenate buffer and new output", "raw_output", "=", "b\"\"", ".", "join", "(", "[", "buf", ",", "raw_output", "]", ")", "buf", "=",...
709c781794d3c3b903891f83da011d2d995895d1
valid
_make_non_blocking
make file object non-blocking Windows doesn't have the fcntl module, but someone on stack overflow supplied this code as an answer, and it works http://stackoverflow.com/a/34504971/2893090
pygdbmi/gdbcontroller.py
def _make_non_blocking(file_obj): """make file object non-blocking Windows doesn't have the fcntl module, but someone on stack overflow supplied this code as an answer, and it works http://stackoverflow.com/a/34504971/2893090""" if USING_WINDOWS: LPDWORD = POINTER(DWORD) PIPE_NOWAIT...
def _make_non_blocking(file_obj): """make file object non-blocking Windows doesn't have the fcntl module, but someone on stack overflow supplied this code as an answer, and it works http://stackoverflow.com/a/34504971/2893090""" if USING_WINDOWS: LPDWORD = POINTER(DWORD) PIPE_NOWAIT...
[ "make", "file", "object", "non", "-", "blocking", "Windows", "doesn", "t", "have", "the", "fcntl", "module", "but", "someone", "on", "stack", "overflow", "supplied", "this", "code", "as", "an", "answer", "and", "it", "works", "http", ":", "//", "stackoverf...
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L480-L504
[ "def", "_make_non_blocking", "(", "file_obj", ")", ":", "if", "USING_WINDOWS", ":", "LPDWORD", "=", "POINTER", "(", "DWORD", ")", "PIPE_NOWAIT", "=", "wintypes", ".", "DWORD", "(", "0x00000001", ")", "SetNamedPipeHandleState", "=", "windll", ".", "kernel32", "...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.spawn_new_gdb_subprocess
Spawn a new gdb subprocess with the arguments supplied to the object during initialization. If gdb subprocess already exists, terminate it before spanwing a new one. Return int: gdb process id
pygdbmi/gdbcontroller.py
def spawn_new_gdb_subprocess(self): """Spawn a new gdb subprocess with the arguments supplied to the object during initialization. If gdb subprocess already exists, terminate it before spanwing a new one. Return int: gdb process id """ if self.gdb_process: sel...
def spawn_new_gdb_subprocess(self): """Spawn a new gdb subprocess with the arguments supplied to the object during initialization. If gdb subprocess already exists, terminate it before spanwing a new one. Return int: gdb process id """ if self.gdb_process: sel...
[ "Spawn", "a", "new", "gdb", "subprocess", "with", "the", "arguments", "supplied", "to", "the", "object", "during", "initialization", ".", "If", "gdb", "subprocess", "already", "exists", "terminate", "it", "before", "spanwing", "a", "new", "one", ".", "Return",...
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L129-L166
[ "def", "spawn_new_gdb_subprocess", "(", "self", ")", ":", "if", "self", ".", "gdb_process", ":", "self", ".", "logger", ".", "debug", "(", "\"Killing current gdb subprocess (pid %d)\"", "%", "self", ".", "gdb_process", ".", "pid", ")", "self", ".", "exit", "("...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.verify_valid_gdb_subprocess
Verify there is a process object, and that it is still running. Raise NoGdbProcessError if either of the above are not true.
pygdbmi/gdbcontroller.py
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...
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...
[ "Verify", "there", "is", "a", "process", "object", "and", "that", "it", "is", "still", "running", ".", "Raise", "NoGdbProcessError", "if", "either", "of", "the", "above", "are", "not", "true", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L168-L178
[ "def", "verify_valid_gdb_subprocess", "(", "self", ")", ":", "if", "not", "self", ".", "gdb_process", ":", "raise", "NoGdbProcessError", "(", "\"gdb process is not attached\"", ")", "elif", "self", ".", "gdb_process", ".", "poll", "(", ")", "is", "not", "None", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.write
Write to gdb process. Block while parsing responses from gdb for a maximum of timeout_sec. Args: mi_cmd_to_write (str or list): String to write to gdb. If list, it is joined by newlines. timeout_sec (float): Maximum number of seconds to wait for response before exiting. Must be >= 0. ...
pygdbmi/gdbcontroller.py
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 ...
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 ...
[ "Write", "to", "gdb", "process", ".", "Block", "while", "parsing", "responses", "from", "gdb", "for", "a", "maximum", "of", "timeout_sec", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L180-L246
[ "def", "write", "(", "self", ",", "mi_cmd_to_write", ",", "timeout_sec", "=", "DEFAULT_GDB_TIMEOUT_SEC", ",", "raise_error_on_timeout", "=", "True", ",", "read_response", "=", "True", ",", ")", ":", "self", ".", "verify_valid_gdb_subprocess", "(", ")", "if", "ti...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.get_gdb_response
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): Maximum time to wait for reponse. Must be >= 0. Will return after raise_error_on_timeout (bool): Whether an exce...
pygdbmi/gdbcontroller.py
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...
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...
[ "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", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L248-L285
[ "def", "get_gdb_response", "(", "self", ",", "timeout_sec", "=", "DEFAULT_GDB_TIMEOUT_SEC", ",", "raise_error_on_timeout", "=", "True", ")", ":", "self", ".", "verify_valid_gdb_subprocess", "(", ")", "if", "timeout_sec", "<", "0", ":", "self", ".", "logger", "."...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController._get_responses_windows
Get responses on windows. Assume no support for select and use a while loop.
pygdbmi/gdbcontroller.py
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...
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...
[ "Get", "responses", "on", "windows", ".", "Assume", "no", "support", "for", "select", "and", "use", "a", "while", "loop", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L287-L319
[ "def", "_get_responses_windows", "(", "self", ",", "timeout_sec", ")", ":", "timeout_time_sec", "=", "time", ".", "time", "(", ")", "+", "timeout_sec", "responses", "=", "[", "]", "while", "True", ":", "try", ":", "self", ".", "gdb_process", ".", "stdout",...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController._get_responses_unix
Get responses on unix-like system. Use select to wait for output.
pygdbmi/gdbcontroller.py
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...
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...
[ "Get", "responses", "on", "unix", "-", "like", "system", ".", "Use", "select", "to", "wait", "for", "output", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L321-L369
[ "def", "_get_responses_unix", "(", "self", ",", "timeout_sec", ")", ":", "timeout_time_sec", "=", "time", ".", "time", "(", ")", "+", "timeout_sec", "responses", "=", "[", "]", "while", "True", ":", "select_timeout", "=", "timeout_time_sec", "-", "time", "."...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController._get_responses_list
Get parsed response list from string output Args: raw_output (unicode): gdb output to parse stream (str): either stdout or stderr
pygdbmi/gdbcontroller.py
def _get_responses_list(self, raw_output, stream): """Get parsed response list from string output Args: raw_output (unicode): gdb output to parse stream (str): either stdout or stderr """ responses = [] raw_output, self._incomplete_output[stream] = _buffe...
def _get_responses_list(self, raw_output, stream): """Get parsed response list from string output Args: raw_output (unicode): gdb output to parse stream (str): either stdout or stderr """ responses = [] raw_output, self._incomplete_output[stream] = _buffe...
[ "Get", "parsed", "response", "list", "from", "string", "output", "Args", ":", "raw_output", "(", "unicode", ")", ":", "gdb", "output", "to", "parse", "stream", "(", "str", ")", ":", "either", "stdout", "or", "stderr" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L371-L402
[ "def", "_get_responses_list", "(", "self", ",", "raw_output", ",", "stream", ")", ":", "responses", "=", "[", "]", "raw_output", ",", "self", ".", "_incomplete_output", "[", "stream", "]", "=", "_buffer_incomplete_responses", "(", "raw_output", ",", "self", "....
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.send_signal_to_gdb
Send signal name (case insensitive) or number to gdb subprocess gdbmi.send_signal_to_gdb(2) # valid gdbmi.send_signal_to_gdb('sigint') # also valid gdbmi.send_signal_to_gdb('SIGINT') # also valid raises ValueError if signal_input is invalie raises NoGdbProcessError if there i...
pygdbmi/gdbcontroller.py
def send_signal_to_gdb(self, signal_input): """Send signal name (case insensitive) or number to gdb subprocess gdbmi.send_signal_to_gdb(2) # valid gdbmi.send_signal_to_gdb('sigint') # also valid gdbmi.send_signal_to_gdb('SIGINT') # also valid raises ValueError if signal_input...
def send_signal_to_gdb(self, signal_input): """Send signal name (case insensitive) or number to gdb subprocess gdbmi.send_signal_to_gdb(2) # valid gdbmi.send_signal_to_gdb('sigint') # also valid gdbmi.send_signal_to_gdb('SIGINT') # also valid raises ValueError if signal_input...
[ "Send", "signal", "name", "(", "case", "insensitive", ")", "or", "number", "to", "gdb", "subprocess", "gdbmi", ".", "send_signal_to_gdb", "(", "2", ")", "#", "valid", "gdbmi", ".", "send_signal_to_gdb", "(", "sigint", ")", "#", "also", "valid", "gdbmi", "....
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L404-L428
[ "def", "send_signal_to_gdb", "(", "self", ",", "signal_input", ")", ":", "try", ":", "signal", "=", "int", "(", "signal_input", ")", "except", "Exception", ":", "signal", "=", "SIGNAL_NAME_TO_NUM", ".", "get", "(", "signal_input", ".", "upper", "(", ")", "...
709c781794d3c3b903891f83da011d2d995895d1
valid
GdbController.exit
Terminate gdb process Returns: None
pygdbmi/gdbcontroller.py
def exit(self): """Terminate gdb process Returns: None""" if self.gdb_process: self.gdb_process.terminate() self.gdb_process.communicate() self.gdb_process = None return None
def exit(self): """Terminate gdb process Returns: None""" if self.gdb_process: self.gdb_process.terminate() self.gdb_process.communicate() self.gdb_process = None return None
[ "Terminate", "gdb", "process", "Returns", ":", "None" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L434-L441
[ "def", "exit", "(", "self", ")", ":", "if", "self", ".", "gdb_process", ":", "self", ".", "gdb_process", ".", "terminate", "(", ")", "self", ".", "gdb_process", ".", "communicate", "(", ")", "self", ".", "gdb_process", "=", "None", "return", "None" ]
709c781794d3c3b903891f83da011d2d995895d1
valid
main
Build and debug an application programatically For a list of GDB MI commands, see https://www.sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html
example.py
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...
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...
[ "Build", "and", "debug", "an", "application", "programatically" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/example.py#L26-L64
[ "def", "main", "(", "verbose", "=", "True", ")", ":", "# Build C program", "find_executable", "(", "MAKE_CMD", ")", "if", "not", "find_executable", "(", "MAKE_CMD", ")", ":", "print", "(", "'Could not find executable \"%s\". Ensure it is installed and on your $PATH.'", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
StringStream.read
Read count characters starting at self.index, and return those characters as a string
pygdbmi/StringStream.py
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...
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...
[ "Read", "count", "characters", "starting", "at", "self", ".", "index", "and", "return", "those", "characters", "as", "a", "string" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/StringStream.py#L25-L36
[ "def", "read", "(", "self", ",", "count", ")", ":", "new_index", "=", "self", ".", "index", "+", "count", "if", "new_index", ">", "self", ".", "len", ":", "buf", "=", "self", ".", "raw_text", "[", "self", ".", "index", ":", "]", "# return to the end,...
709c781794d3c3b903891f83da011d2d995895d1
valid
StringStream.advance_past_chars
Advance the index past specific chars Args chars (list): list of characters to advance past Return substring that was advanced past
pygdbmi/StringStream.py
def advance_past_chars(self, chars): """Advance the index past specific chars Args chars (list): list of characters to advance past Return substring that was advanced past """ start_index = self.index while True: current_char = self.raw_text[self.index] ...
def advance_past_chars(self, chars): """Advance the index past specific chars Args chars (list): list of characters to advance past Return substring that was advanced past """ start_index = self.index while True: current_char = self.raw_text[self.index] ...
[ "Advance", "the", "index", "past", "specific", "chars", "Args", "chars", "(", "list", ")", ":", "list", "of", "characters", "to", "advance", "past" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/StringStream.py#L42-L58
[ "def", "advance_past_chars", "(", "self", ",", "chars", ")", ":", "start_index", "=", "self", ".", "index", "while", "True", ":", "current_char", "=", "self", ".", "raw_text", "[", "self", ".", "index", "]", "self", ".", "index", "+=", "1", "if", "curr...
709c781794d3c3b903891f83da011d2d995895d1
valid
StringStream.advance_past_string_with_gdb_escapes
characters that gdb escapes that should not be escaped by this parser
pygdbmi/StringStream.py
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: ...
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: ...
[ "characters", "that", "gdb", "escapes", "that", "should", "not", "be", "escaped", "by", "this", "parser" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/StringStream.py#L60-L92
[ "def", "advance_past_string_with_gdb_escapes", "(", "self", ",", "chars_to_remove_gdb_escape", "=", "None", ")", ":", "if", "chars_to_remove_gdb_escape", "is", "None", ":", "chars_to_remove_gdb_escape", "=", "[", "'\"'", "]", "buf", "=", "\"\"", "while", "True", ":"...
709c781794d3c3b903891f83da011d2d995895d1
valid
parse_response
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: dict with the following keys: ...
pygdbmi/gdbmiparser.py
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: ...
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: ...
[ "Parse", "gdb", "mi", "text", "and", "turn", "it", "into", "a", "dictionary", "." ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L40-L102
[ "def", "parse_response", "(", "gdb_mi_text", ")", ":", "stream", "=", "StringStream", "(", "gdb_mi_text", ",", "debug", "=", "_DEBUG", ")", "if", "_GDB_MI_NOTIFY_RE", ".", "match", "(", "gdb_mi_text", ")", ":", "token", ",", "message", ",", "payload", "=", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
assert_match
If values don't match, print them and raise a ValueError, otherwise, continue Raises: ValueError if argumetns do not match
pygdbmi/gdbmiparser.py
def assert_match(actual_char_or_str, expected_char_or_str): """If values don't match, print them and raise a ValueError, otherwise, continue Raises: ValueError if argumetns do not match""" if expected_char_or_str != actual_char_or_str: print("Expected") pprint(expected_char_or_str) ...
def assert_match(actual_char_or_str, expected_char_or_str): """If values don't match, print them and raise a ValueError, otherwise, continue Raises: ValueError if argumetns do not match""" if expected_char_or_str != actual_char_or_str: print("Expected") pprint(expected_char_or_str) ...
[ "If", "values", "don", "t", "match", "print", "them", "and", "raise", "a", "ValueError", "otherwise", "continue", "Raises", ":", "ValueError", "if", "argumetns", "do", "not", "match" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L115-L125
[ "def", "assert_match", "(", "actual_char_or_str", ",", "expected_char_or_str", ")", ":", "if", "expected_char_or_str", "!=", "actual_char_or_str", ":", "print", "(", "\"Expected\"", ")", "pprint", "(", "expected_char_or_str", ")", "print", "(", "\"\"", ")", "print",...
709c781794d3c3b903891f83da011d2d995895d1
valid
_get_notify_msg_and_payload
Get notify message and payload dict
pygdbmi/gdbmiparser.py
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...
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...
[ "Get", "notify", "message", "and", "payload", "dict" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L182-L193
[ "def", "_get_notify_msg_and_payload", "(", "result", ",", "stream", ")", ":", "token", "=", "stream", ".", "advance_past_chars", "(", "[", "\"=\"", ",", "\"*\"", "]", ")", "token", "=", "int", "(", "token", ")", "if", "token", "!=", "\"\"", "else", "None...
709c781794d3c3b903891f83da011d2d995895d1
valid
_get_result_msg_and_payload
Get result message and payload dict
pygdbmi/gdbmiparser.py
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...
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...
[ "Get", "result", "message", "and", "payload", "dict" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L196-L209
[ "def", "_get_result_msg_and_payload", "(", "result", ",", "stream", ")", ":", "groups", "=", "_GDB_MI_RESULT_RE", ".", "match", "(", "result", ")", ".", "groups", "(", ")", "token", "=", "int", "(", "groups", "[", "0", "]", ")", "if", "groups", "[", "0...
709c781794d3c3b903891f83da011d2d995895d1
valid
_parse_dict
Parse dictionary, with optional starting character '{' return (tuple): Number of characters parsed from to_parse Parsed dictionary
pygdbmi/gdbmiparser.py
def _parse_dict(stream): """Parse dictionary, with optional starting character '{' return (tuple): Number of characters parsed from to_parse Parsed dictionary """ obj = {} logger.debug("%s", fmt_green("parsing dict")) while True: c = stream.read(1) if c in _WHIT...
def _parse_dict(stream): """Parse dictionary, with optional starting character '{' return (tuple): Number of characters parsed from to_parse Parsed dictionary """ obj = {} logger.debug("%s", fmt_green("parsing dict")) while True: c = stream.read(1) if c in _WHIT...
[ "Parse", "dictionary", "with", "optional", "starting", "character", "{", "return", "(", "tuple", ")", ":", "Number", "of", "characters", "parsed", "from", "to_parse", "Parsed", "dictionary" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L212-L267
[ "def", "_parse_dict", "(", "stream", ")", ":", "obj", "=", "{", "}", "logger", ".", "debug", "(", "\"%s\"", ",", "fmt_green", "(", "\"parsing dict\"", ")", ")", "while", "True", ":", "c", "=", "stream", ".", "read", "(", "1", ")", "if", "c", "in", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
_parse_key_val
Parse key, value combination return (tuple): Parsed key (string) Parsed value (either a string, array, or dict)
pygdbmi/gdbmiparser.py
def _parse_key_val(stream): """Parse key, value combination return (tuple): Parsed key (string) Parsed value (either a string, array, or dict) """ logger.debug("parsing key/val") key = _parse_key(stream) val = _parse_val(stream) logger.debug("parsed key/val") logger.deb...
def _parse_key_val(stream): """Parse key, value combination return (tuple): Parsed key (string) Parsed value (either a string, array, or dict) """ logger.debug("parsing key/val") key = _parse_key(stream) val = _parse_val(stream) logger.debug("parsed key/val") logger.deb...
[ "Parse", "key", "value", "combination", "return", "(", "tuple", ")", ":", "Parsed", "key", "(", "string", ")", "Parsed", "value", "(", "either", "a", "string", "array", "or", "dict", ")" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L270-L285
[ "def", "_parse_key_val", "(", "stream", ")", ":", "logger", ".", "debug", "(", "\"parsing key/val\"", ")", "key", "=", "_parse_key", "(", "stream", ")", "val", "=", "_parse_val", "(", "stream", ")", "logger", ".", "debug", "(", "\"parsed key/val\"", ")", "...
709c781794d3c3b903891f83da011d2d995895d1
valid
_parse_key
Parse key, value combination returns : Parsed key (string)
pygdbmi/gdbmiparser.py
def _parse_key(stream): """Parse key, value combination returns : Parsed key (string) """ logger.debug("parsing key") key = stream.advance_past_chars(["="]) logger.debug("parsed key:") logger.debug("%s", fmt_green(key)) return key
def _parse_key(stream): """Parse key, value combination returns : Parsed key (string) """ logger.debug("parsing key") key = stream.advance_past_chars(["="]) logger.debug("parsed key:") logger.debug("%s", fmt_green(key)) return key
[ "Parse", "key", "value", "combination", "returns", ":", "Parsed", "key", "(", "string", ")" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L288-L299
[ "def", "_parse_key", "(", "stream", ")", ":", "logger", ".", "debug", "(", "\"parsing key\"", ")", "key", "=", "stream", ".", "advance_past_chars", "(", "[", "\"=\"", "]", ")", "logger", ".", "debug", "(", "\"parsed key:\"", ")", "logger", ".", "debug", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
_parse_val
Parse value from string returns: Parsed value (either a string, array, or dict)
pygdbmi/gdbmiparser.py
def _parse_val(stream): """Parse value from string returns: Parsed value (either a string, array, or dict) """ logger.debug("parsing value") while True: c = stream.read(1) if c == "{": # Start object val = _parse_dict(stream) break ...
def _parse_val(stream): """Parse value from string returns: Parsed value (either a string, array, or dict) """ logger.debug("parsing value") while True: c = stream.read(1) if c == "{": # Start object val = _parse_dict(stream) break ...
[ "Parse", "value", "from", "string", "returns", ":", "Parsed", "value", "(", "either", "a", "string", "array", "or", "dict", ")" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L302-L341
[ "def", "_parse_val", "(", "stream", ")", ":", "logger", ".", "debug", "(", "\"parsing value\"", ")", "while", "True", ":", "c", "=", "stream", ".", "read", "(", "1", ")", "if", "c", "==", "\"{\"", ":", "# Start object", "val", "=", "_parse_dict", "(", ...
709c781794d3c3b903891f83da011d2d995895d1
valid
_parse_array
Parse an array, stream should be passed the initial [ returns: Parsed array
pygdbmi/gdbmiparser.py
def _parse_array(stream): """Parse an array, stream should be passed the initial [ returns: Parsed array """ logger.debug("parsing array") arr = [] while True: c = stream.read(1) if c in _GDB_MI_VALUE_START_CHARS: stream.seek(-1) val = _parse_val...
def _parse_array(stream): """Parse an array, stream should be passed the initial [ returns: Parsed array """ logger.debug("parsing array") arr = [] while True: c = stream.read(1) if c in _GDB_MI_VALUE_START_CHARS: stream.seek(-1) val = _parse_val...
[ "Parse", "an", "array", "stream", "should", "be", "passed", "the", "initial", "[", "returns", ":", "Parsed", "array" ]
cs01/pygdbmi
python
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L344-L370
[ "def", "_parse_array", "(", "stream", ")", ":", "logger", ".", "debug", "(", "\"parsing array\"", ")", "arr", "=", "[", "]", "while", "True", ":", "c", "=", "stream", ".", "read", "(", "1", ")", "if", "c", "in", "_GDB_MI_VALUE_START_CHARS", ":", "strea...
709c781794d3c3b903891f83da011d2d995895d1
valid
JsDumper.as_parameters
Dump python list as the parameter of javascript function :param parameters: :param variables: :return:
django_echarts/utils/interfaces.py
def as_parameters(*parameters, variables=None): """ Dump python list as the parameter of javascript function :param parameters: :param variables: :return: """ s = json.dumps(parameters) s = s[1:-1] if variables: for v in variables: ...
def as_parameters(*parameters, variables=None): """ Dump python list as the parameter of javascript function :param parameters: :param variables: :return: """ s = json.dumps(parameters) s = s[1:-1] if variables: for v in variables: ...
[ "Dump", "python", "list", "as", "the", "parameter", "of", "javascript", "function", ":", "param", "parameters", ":", ":", "param", "variables", ":", ":", "return", ":" ]
kinegratii/django-echarts
python
https://github.com/kinegratii/django-echarts/blob/50f9ebb60ccd5e96aeb88176b6e8c789a66b7677/django_echarts/utils/interfaces.py#L81-L94
[ "def", "as_parameters", "(", "*", "parameters", ",", "variables", "=", "None", ")", ":", "s", "=", "json", ".", "dumps", "(", "parameters", ")", "s", "=", "s", "[", "1", ":", "-", "1", "]", "if", "variables", ":", "for", "v", "in", "variables", "...
50f9ebb60ccd5e96aeb88176b6e8c789a66b7677
valid
SettingsStore.generate_local_url
Generate the local url for a js file. :param js_name: :return:
django_echarts/plugins/store.py
def generate_local_url(self, js_name): """ Generate the local url for a js file. :param js_name: :return: """ host = self._settings['local_host'].format(**self._host_context).rstrip('/') return '{}/{}.js'.format(host, js_name)
def generate_local_url(self, js_name): """ Generate the local url for a js file. :param js_name: :return: """ host = self._settings['local_host'].format(**self._host_context).rstrip('/') return '{}/{}.js'.format(host, js_name)
[ "Generate", "the", "local", "url", "for", "a", "js", "file", ".", ":", "param", "js_name", ":", ":", "return", ":" ]
kinegratii/django-echarts
python
https://github.com/kinegratii/django-echarts/blob/50f9ebb60ccd5e96aeb88176b6e8c789a66b7677/django_echarts/plugins/store.py#L74-L81
[ "def", "generate_local_url", "(", "self", ",", "js_name", ")", ":", "host", "=", "self", ".", "_settings", "[", "'local_host'", "]", ".", "format", "(", "*", "*", "self", ".", "_host_context", ")", ".", "rstrip", "(", "'/'", ")", "return", "'{}/{}.js'", ...
50f9ebb60ccd5e96aeb88176b6e8c789a66b7677
valid
ifetch_single
getter() g(item, key):pass
django_echarts/datasets/fetch.py
def ifetch_single(iterable, key, default=EMPTY, getter=None): """ getter() g(item, key):pass """ def _getter(item): if getter: custom_getter = partial(getter, key=key) return custom_getter(item) else: try: attrgetter = operator.attrget...
def ifetch_single(iterable, key, default=EMPTY, getter=None): """ getter() g(item, key):pass """ def _getter(item): if getter: custom_getter = partial(getter, key=key) return custom_getter(item) else: try: attrgetter = operator.attrget...
[ "getter", "()", "g", "(", "item", "key", ")", ":", "pass" ]
kinegratii/django-echarts
python
https://github.com/kinegratii/django-echarts/blob/50f9ebb60ccd5e96aeb88176b6e8c789a66b7677/django_echarts/datasets/fetch.py#L19-L46
[ "def", "ifetch_single", "(", "iterable", ",", "key", ",", "default", "=", "EMPTY", ",", "getter", "=", "None", ")", ":", "def", "_getter", "(", "item", ")", ":", "if", "getter", ":", "custom_getter", "=", "partial", "(", "getter", ",", "key", "=", "k...
50f9ebb60ccd5e96aeb88176b6e8c789a66b7677