repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
mapbox/mapbox-sdk-py
mapbox/services/base.py
Session
def Session(access_token=None, env=None): """Create an HTTP session. Parameters ---------- access_token : str Mapbox access token string (optional). env : dict, optional A dict that subsitutes for os.environ. Returns ------- requests.Session """ if env is None: ...
python
def Session(access_token=None, env=None): """Create an HTTP session. Parameters ---------- access_token : str Mapbox access token string (optional). env : dict, optional A dict that subsitutes for os.environ. Returns ------- requests.Session """ if env is None: ...
[ "def", "Session", "(", "access_token", "=", "None", ",", "env", "=", "None", ")", ":", "if", "env", "is", "None", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "access_token", "=", "(", "access_token", "or", "env", ".", "get", "(", ...
Create an HTTP session. Parameters ---------- access_token : str Mapbox access token string (optional). env : dict, optional A dict that subsitutes for os.environ. Returns ------- requests.Session
[ "Create", "an", "HTTP", "session", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L14-L39
train
mapbox/mapbox-sdk-py
mapbox/services/base.py
Service.username
def username(self): """The username in the service's access token Returns ------- str """ token = self.session.params.get('access_token') if not token: raise errors.TokenError( "session does not have a valid access_token param") ...
python
def username(self): """The username in the service's access token Returns ------- str """ token = self.session.params.get('access_token') if not token: raise errors.TokenError( "session does not have a valid access_token param") ...
[ "def", "username", "(", "self", ")", ":", "token", "=", "self", ".", "session", ".", "params", ".", "get", "(", "'access_token'", ")", "if", "not", "token", ":", "raise", "errors", ".", "TokenError", "(", "\"session does not have a valid access_token param\"", ...
The username in the service's access token Returns ------- str
[ "The", "username", "in", "the", "service", "s", "access", "token" ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L101-L120
train
mapbox/mapbox-sdk-py
mapbox/services/base.py
Service.handle_http_error
def handle_http_error(self, response, custom_messages=None, raise_for_status=False): """Converts service errors to Python exceptions Parameters ---------- response : requests.Response A service response. custom_messages : dict, optional ...
python
def handle_http_error(self, response, custom_messages=None, raise_for_status=False): """Converts service errors to Python exceptions Parameters ---------- response : requests.Response A service response. custom_messages : dict, optional ...
[ "def", "handle_http_error", "(", "self", ",", "response", ",", "custom_messages", "=", "None", ",", "raise_for_status", "=", "False", ")", ":", "if", "not", "custom_messages", ":", "custom_messages", "=", "{", "}", "if", "response", ".", "status_code", "in", ...
Converts service errors to Python exceptions Parameters ---------- response : requests.Response A service response. custom_messages : dict, optional A mapping of custom exception messages to HTTP status codes. raise_for_status : bool, optional ...
[ "Converts", "service", "errors", "to", "Python", "exceptions" ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L122-L144
train
mapbox/mapbox-sdk-py
mapbox/services/mapmatching.py
MapMatcher.match
def match(self, feature, gps_precision=None, profile='mapbox.driving'): """Match features to OpenStreetMap data.""" profile = self._validate_profile(profile) feature = self._validate_feature(feature) geojson_line_feature = json.dumps(feature) uri = URITemplate(self.baseuri + '/...
python
def match(self, feature, gps_precision=None, profile='mapbox.driving'): """Match features to OpenStreetMap data.""" profile = self._validate_profile(profile) feature = self._validate_feature(feature) geojson_line_feature = json.dumps(feature) uri = URITemplate(self.baseuri + '/...
[ "def", "match", "(", "self", ",", "feature", ",", "gps_precision", "=", "None", ",", "profile", "=", "'mapbox.driving'", ")", ":", "profile", "=", "self", ".", "_validate_profile", "(", "profile", ")", "feature", "=", "self", ".", "_validate_feature", "(", ...
Match features to OpenStreetMap data.
[ "Match", "features", "to", "OpenStreetMap", "data", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/mapmatching.py#L33-L55
train
mapbox/mapbox-sdk-py
mapbox/services/tilequery.py
Tilequery._validate_geometry
def _validate_geometry(self, geometry): """Validates geometry, raising error if invalid.""" if geometry is not None and geometry not in self.valid_geometries: raise InvalidParameterError("{} is not a valid geometry".format(geometry)) return geometry
python
def _validate_geometry(self, geometry): """Validates geometry, raising error if invalid.""" if geometry is not None and geometry not in self.valid_geometries: raise InvalidParameterError("{} is not a valid geometry".format(geometry)) return geometry
[ "def", "_validate_geometry", "(", "self", ",", "geometry", ")", ":", "if", "geometry", "is", "not", "None", "and", "geometry", "not", "in", "self", ".", "valid_geometries", ":", "raise", "InvalidParameterError", "(", "\"{} is not a valid geometry\"", ".", "format"...
Validates geometry, raising error if invalid.
[ "Validates", "geometry", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/tilequery.py#L72-L78
train
mapbox/mapbox-sdk-py
mapbox/services/tilequery.py
Tilequery.tilequery
def tilequery( self, map_id, lon=None, lat=None, radius=None, limit=None, dedupe=None, geometry=None, layers=None, ): """Returns data about specific features from a vector tileset. Parameters ---------- ...
python
def tilequery( self, map_id, lon=None, lat=None, radius=None, limit=None, dedupe=None, geometry=None, layers=None, ): """Returns data about specific features from a vector tileset. Parameters ---------- ...
[ "def", "tilequery", "(", "self", ",", "map_id", ",", "lon", "=", "None", ",", "lat", "=", "None", ",", "radius", "=", "None", ",", "limit", "=", "None", ",", "dedupe", "=", "None", ",", "geometry", "=", "None", ",", "layers", "=", "None", ",", ")...
Returns data about specific features from a vector tileset. Parameters ---------- map_id : str or list The tileset's unique identifier in the format username.id. map_id may be either a str with one value or a list with multiple values. ...
[ "Returns", "data", "about", "specific", "features", "from", "a", "vector", "tileset", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/tilequery.py#L80-L209
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps._validate_file_format
def _validate_file_format(self, file_format): """Validates file format, raising error if invalid.""" if file_format not in self.valid_file_formats: raise InvalidFileFormatError( "{} is not a valid file format".format(file_format) ) return file_format
python
def _validate_file_format(self, file_format): """Validates file format, raising error if invalid.""" if file_format not in self.valid_file_formats: raise InvalidFileFormatError( "{} is not a valid file format".format(file_format) ) return file_format
[ "def", "_validate_file_format", "(", "self", ",", "file_format", ")", ":", "if", "file_format", "not", "in", "self", ".", "valid_file_formats", ":", "raise", "InvalidFileFormatError", "(", "\"{} is not a valid file format\"", ".", "format", "(", "file_format", ")", ...
Validates file format, raising error if invalid.
[ "Validates", "file", "format", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L122-L130
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps._validate_feature_format
def _validate_feature_format(self, feature_format): """Validates feature format, raising error if invalid.""" if feature_format not in self.valid_feature_formats: raise InvalidFeatureFormatError( "{} is not a valid feature format".format(feature_format) ) ...
python
def _validate_feature_format(self, feature_format): """Validates feature format, raising error if invalid.""" if feature_format not in self.valid_feature_formats: raise InvalidFeatureFormatError( "{} is not a valid feature format".format(feature_format) ) ...
[ "def", "_validate_feature_format", "(", "self", ",", "feature_format", ")", ":", "if", "feature_format", "not", "in", "self", ".", "valid_feature_formats", ":", "raise", "InvalidFeatureFormatError", "(", "\"{} is not a valid feature format\"", ".", "format", "(", "featu...
Validates feature format, raising error if invalid.
[ "Validates", "feature", "format", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L144-L152
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps._validate_marker_name
def _validate_marker_name(self, marker_name): """Validates marker name, raising error if invalid.""" if marker_name not in self.valid_marker_names: raise InvalidMarkerNameError( "{} is not a valid marker name".format(marker_name) ) return marker_name
python
def _validate_marker_name(self, marker_name): """Validates marker name, raising error if invalid.""" if marker_name not in self.valid_marker_names: raise InvalidMarkerNameError( "{} is not a valid marker name".format(marker_name) ) return marker_name
[ "def", "_validate_marker_name", "(", "self", ",", "marker_name", ")", ":", "if", "marker_name", "not", "in", "self", ".", "valid_marker_names", ":", "raise", "InvalidMarkerNameError", "(", "\"{} is not a valid marker name\"", ".", "format", "(", "marker_name", ")", ...
Validates marker name, raising error if invalid.
[ "Validates", "marker", "name", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L154-L162
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps._validate_label
def _validate_label(self, label): """Validates label, raising error if invalid.""" letter_pattern = compile("^[a-z]{1}$") number_pattern = compile("^[0]{1}$|^[1-9]{1,2}$") icon_pattern = compile("^[a-zA-Z ]{1,}$") if not match(letter_pattern, label)\ and not match(n...
python
def _validate_label(self, label): """Validates label, raising error if invalid.""" letter_pattern = compile("^[a-z]{1}$") number_pattern = compile("^[0]{1}$|^[1-9]{1,2}$") icon_pattern = compile("^[a-zA-Z ]{1,}$") if not match(letter_pattern, label)\ and not match(n...
[ "def", "_validate_label", "(", "self", ",", "label", ")", ":", "letter_pattern", "=", "compile", "(", "\"^[a-z]{1}$\"", ")", "number_pattern", "=", "compile", "(", "\"^[0]{1}$|^[1-9]{1,2}$\"", ")", "icon_pattern", "=", "compile", "(", "\"^[a-zA-Z ]{1,}$\"", ")", "...
Validates label, raising error if invalid.
[ "Validates", "label", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L164-L178
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps._validate_color
def _validate_color(self, color): """Validates color, raising error if invalid.""" three_digit_pattern = compile("^[a-f0-9]{3}$") six_digit_pattern = compile("^[a-f0-9]{6}$") if not match(three_digit_pattern, color)\ and not match(six_digit_pattern, color): ...
python
def _validate_color(self, color): """Validates color, raising error if invalid.""" three_digit_pattern = compile("^[a-f0-9]{3}$") six_digit_pattern = compile("^[a-f0-9]{6}$") if not match(three_digit_pattern, color)\ and not match(six_digit_pattern, color): ...
[ "def", "_validate_color", "(", "self", ",", "color", ")", ":", "three_digit_pattern", "=", "compile", "(", "\"^[a-f0-9]{3}$\"", ")", "six_digit_pattern", "=", "compile", "(", "\"^[a-f0-9]{6}$\"", ")", "if", "not", "match", "(", "three_digit_pattern", ",", "color",...
Validates color, raising error if invalid.
[ "Validates", "color", "raising", "error", "if", "invalid", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L180-L192
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps.tile
def tile(self, map_id, x, y, z, retina=False, file_format="png", style_id=None, timestamp=None): """Returns an image tile, vector tile, or UTFGrid in the specified file format. Parameters ---------- map_id : str The tile's unique identifier in the form...
python
def tile(self, map_id, x, y, z, retina=False, file_format="png", style_id=None, timestamp=None): """Returns an image tile, vector tile, or UTFGrid in the specified file format. Parameters ---------- map_id : str The tile's unique identifier in the form...
[ "def", "tile", "(", "self", ",", "map_id", ",", "x", ",", "y", ",", "z", ",", "retina", "=", "False", ",", "file_format", "=", "\"png\"", ",", "style_id", "=", "None", ",", "timestamp", "=", "None", ")", ":", "# Check x, y, and z.", "if", "x", "is", ...
Returns an image tile, vector tile, or UTFGrid in the specified file format. Parameters ---------- map_id : str The tile's unique identifier in the format username.id. x : int The tile's column, where 0 is the minimum value and ((2**z) - 1) i...
[ "Returns", "an", "image", "tile", "vector", "tile", "or", "UTFGrid", "in", "the", "specified", "file", "format", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L194-L295
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps.features
def features(self, map_id, feature_format="json"): """Returns vector features from Mapbox Editor projects as GeoJSON or KML. Parameters ---------- map_id : str The map's unique identifier in the format username.id. feature_format : str, optional ...
python
def features(self, map_id, feature_format="json"): """Returns vector features from Mapbox Editor projects as GeoJSON or KML. Parameters ---------- map_id : str The map's unique identifier in the format username.id. feature_format : str, optional ...
[ "def", "features", "(", "self", ",", "map_id", ",", "feature_format", "=", "\"json\"", ")", ":", "# Validate feature_format.", "feature_format", "=", "self", ".", "_validate_feature_format", "(", "feature_format", ")", "# Create dict to assist in building URI resource path....
Returns vector features from Mapbox Editor projects as GeoJSON or KML. Parameters ---------- map_id : str The map's unique identifier in the format username.id. feature_format : str, optional The vector's feature format. The default value is...
[ "Returns", "vector", "features", "from", "Mapbox", "Editor", "projects", "as", "GeoJSON", "or", "KML", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L297-L338
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps.metadata
def metadata(self, map_id, secure=False): """Returns TileJSON metadata for a tileset. Parameters ---------- map_id : str The map's unique identifier in the format username.id. secure : bool, optional The representation of the requested resources, ...
python
def metadata(self, map_id, secure=False): """Returns TileJSON metadata for a tileset. Parameters ---------- map_id : str The map's unique identifier in the format username.id. secure : bool, optional The representation of the requested resources, ...
[ "def", "metadata", "(", "self", ",", "map_id", ",", "secure", "=", "False", ")", ":", "# Create dict to assist in building URI resource path.", "path_values", "=", "dict", "(", "map_id", "=", "map_id", ")", "# Build URI resource path.", "path_part", "=", "\"/{map_id}....
Returns TileJSON metadata for a tileset. Parameters ---------- map_id : str The map's unique identifier in the format username.id. secure : bool, optional The representation of the requested resources, where True indicates representation as HTTPS en...
[ "Returns", "TileJSON", "metadata", "for", "a", "tileset", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L340-L384
train
mapbox/mapbox-sdk-py
mapbox/services/maps.py
Maps.marker
def marker(self, marker_name=None, label=None, color=None, retina=False): """Returns a single marker image without any background map. Parameters ---------- marker_name : str The marker's shape and size. label : str, optional T...
python
def marker(self, marker_name=None, label=None, color=None, retina=False): """Returns a single marker image without any background map. Parameters ---------- marker_name : str The marker's shape and size. label : str, optional T...
[ "def", "marker", "(", "self", ",", "marker_name", "=", "None", ",", "label", "=", "None", ",", "color", "=", "None", ",", "retina", "=", "False", ")", ":", "# Check for marker_name.", "if", "marker_name", "is", "None", ":", "raise", "ValidationError", "(",...
Returns a single marker image without any background map. Parameters ---------- marker_name : str The marker's shape and size. label : str, optional The marker's alphanumeric label. Options are a through z, 0 through 99, or the ...
[ "Returns", "a", "single", "marker", "image", "without", "any", "background", "map", "." ]
72d19dbcf2d254a6ea08129a726471fd21f13023
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L386-L468
train
django-extensions/django-extensions
django_extensions/management/commands/runserver_plus.py
set_werkzeug_log_color
def set_werkzeug_log_color(): """Try to set color to the werkzeug log.""" from django.core.management.color import color_style from werkzeug.serving import WSGIRequestHandler from werkzeug._internal import _log _style = color_style() _orig_log = WSGIRequestHandler.log def werk_log(self, ty...
python
def set_werkzeug_log_color(): """Try to set color to the werkzeug log.""" from django.core.management.color import color_style from werkzeug.serving import WSGIRequestHandler from werkzeug._internal import _log _style = color_style() _orig_log = WSGIRequestHandler.log def werk_log(self, ty...
[ "def", "set_werkzeug_log_color", "(", ")", ":", "from", "django", ".", "core", ".", "management", ".", "color", "import", "color_style", "from", "werkzeug", ".", "serving", "import", "WSGIRequestHandler", "from", "werkzeug", ".", "_internal", "import", "_log", "...
Try to set color to the werkzeug log.
[ "Try", "to", "set", "color", "to", "the", "werkzeug", "log", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/runserver_plus.py#L423-L463
train
django-extensions/django-extensions
django_extensions/db/fields/__init__.py
AutoSlugField._slug_strip
def _slug_strip(self, value): """ Clean up a slug by removing slug separator characters that occur at the beginning or end of a slug. If an alternate separator is used, it will also replace any instances of the default '-' separator with the new separator. """ re...
python
def _slug_strip(self, value): """ Clean up a slug by removing slug separator characters that occur at the beginning or end of a slug. If an alternate separator is used, it will also replace any instances of the default '-' separator with the new separator. """ re...
[ "def", "_slug_strip", "(", "self", ",", "value", ")", ":", "re_sep", "=", "'(?:-|%s)'", "%", "re", ".", "escape", "(", "self", ".", "separator", ")", "value", "=", "re", ".", "sub", "(", "'%s+'", "%", "re_sep", ",", "self", ".", "separator", ",", "...
Clean up a slug by removing slug separator characters that occur at the beginning or end of a slug. If an alternate separator is used, it will also replace any instances of the default '-' separator with the new separator.
[ "Clean", "up", "a", "slug", "by", "removing", "slug", "separator", "characters", "that", "occur", "at", "the", "beginning", "or", "end", "of", "a", "slug", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/db/fields/__init__.py#L134-L144
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
full_name
def full_name(first_name, last_name, username, **extra): """Return full name or username.""" name = " ".join(n for n in [first_name, last_name] if n) if not name: return username return name
python
def full_name(first_name, last_name, username, **extra): """Return full name or username.""" name = " ".join(n for n in [first_name, last_name] if n) if not name: return username return name
[ "def", "full_name", "(", "first_name", ",", "last_name", ",", "username", ",", "*", "*", "extra", ")", ":", "name", "=", "\" \"", ".", "join", "(", "n", "for", "n", "in", "[", "first_name", ",", "last_name", "]", "if", "n", ")", "if", "not", "name"...
Return full name or username.
[ "Return", "full", "name", "or", "username", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L23-L28
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
Command.google
def google(self, qs): """CSV format suitable for importing into google GMail""" csvf = writer(sys.stdout) csvf.writerow(['Name', 'Email']) for ent in qs: csvf.writerow([full_name(**ent), ent['email']])
python
def google(self, qs): """CSV format suitable for importing into google GMail""" csvf = writer(sys.stdout) csvf.writerow(['Name', 'Email']) for ent in qs: csvf.writerow([full_name(**ent), ent['email']])
[ "def", "google", "(", "self", ",", "qs", ")", ":", "csvf", "=", "writer", "(", "sys", ".", "stdout", ")", "csvf", ".", "writerow", "(", "[", "'Name'", ",", "'Email'", "]", ")", "for", "ent", "in", "qs", ":", "csvf", ".", "writerow", "(", "[", "...
CSV format suitable for importing into google GMail
[ "CSV", "format", "suitable", "for", "importing", "into", "google", "GMail" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L88-L93
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
Command.linkedin
def linkedin(self, qs): """ CSV format suitable for importing into linkedin Groups. perfect for pre-approving members of a linkedin group. """ csvf = writer(sys.stdout) csvf.writerow(['First Name', 'Last Name', 'Email']) for ent in qs: csvf.writerow([e...
python
def linkedin(self, qs): """ CSV format suitable for importing into linkedin Groups. perfect for pre-approving members of a linkedin group. """ csvf = writer(sys.stdout) csvf.writerow(['First Name', 'Last Name', 'Email']) for ent in qs: csvf.writerow([e...
[ "def", "linkedin", "(", "self", ",", "qs", ")", ":", "csvf", "=", "writer", "(", "sys", ".", "stdout", ")", "csvf", ".", "writerow", "(", "[", "'First Name'", ",", "'Last Name'", ",", "'Email'", "]", ")", "for", "ent", "in", "qs", ":", "csvf", ".",...
CSV format suitable for importing into linkedin Groups. perfect for pre-approving members of a linkedin group.
[ "CSV", "format", "suitable", "for", "importing", "into", "linkedin", "Groups", ".", "perfect", "for", "pre", "-", "approving", "members", "of", "a", "linkedin", "group", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L95-L103
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
Command.outlook
def outlook(self, qs): """CSV format suitable for importing into outlook""" csvf = writer(sys.stdout) columns = ['Name', 'E-mail Address', 'Notes', 'E-mail 2 Address', 'E-mail 3 Address', 'Mobile Phone', 'Pager', 'Company', 'Job Title', 'Home Phone', 'Home Phone 2', ...
python
def outlook(self, qs): """CSV format suitable for importing into outlook""" csvf = writer(sys.stdout) columns = ['Name', 'E-mail Address', 'Notes', 'E-mail 2 Address', 'E-mail 3 Address', 'Mobile Phone', 'Pager', 'Company', 'Job Title', 'Home Phone', 'Home Phone 2', ...
[ "def", "outlook", "(", "self", ",", "qs", ")", ":", "csvf", "=", "writer", "(", "sys", ".", "stdout", ")", "columns", "=", "[", "'Name'", ",", "'E-mail Address'", ",", "'Notes'", ",", "'E-mail 2 Address'", ",", "'E-mail 3 Address'", ",", "'Mobile Phone'", ...
CSV format suitable for importing into outlook
[ "CSV", "format", "suitable", "for", "importing", "into", "outlook" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L105-L115
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
Command.vcard
def vcard(self, qs): """VCARD format.""" try: import vobject except ImportError: print(self.style.ERROR("Please install vobject to use the vcard export format.")) sys.exit(1) out = sys.stdout for ent in qs: card = vobject.vCard() ...
python
def vcard(self, qs): """VCARD format.""" try: import vobject except ImportError: print(self.style.ERROR("Please install vobject to use the vcard export format.")) sys.exit(1) out = sys.stdout for ent in qs: card = vobject.vCard() ...
[ "def", "vcard", "(", "self", ",", "qs", ")", ":", "try", ":", "import", "vobject", "except", "ImportError", ":", "print", "(", "self", ".", "style", ".", "ERROR", "(", "\"Please install vobject to use the vcard export format.\"", ")", ")", "sys", ".", "exit", ...
VCARD format.
[ "VCARD", "format", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L117-L138
train
django-extensions/django-extensions
django_extensions/management/mysql.py
parse_mysql_cnf
def parse_mysql_cnf(dbinfo): """ Attempt to parse mysql database config file for connection settings. Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs so we have to emulate the behaviour Settings that are missing will return '' returns (u...
python
def parse_mysql_cnf(dbinfo): """ Attempt to parse mysql database config file for connection settings. Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs so we have to emulate the behaviour Settings that are missing will return '' returns (u...
[ "def", "parse_mysql_cnf", "(", "dbinfo", ")", ":", "read_default_file", "=", "dbinfo", ".", "get", "(", "'OPTIONS'", ",", "{", "}", ")", ".", "get", "(", "'read_default_file'", ")", "if", "read_default_file", ":", "config", "=", "configparser", ".", "RawConf...
Attempt to parse mysql database config file for connection settings. Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs so we have to emulate the behaviour Settings that are missing will return '' returns (user, password, database_name, database_ho...
[ "Attempt", "to", "parse", "mysql", "database", "config", "file", "for", "connection", "settings", ".", "Ideally", "we", "would", "hook", "into", "django", "s", "code", "to", "do", "this", "but", "read_default_file", "is", "handled", "by", "the", "mysql", "C"...
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/mysql.py#L5-L43
train
django-extensions/django-extensions
django_extensions/management/jobs.py
get_jobs
def get_jobs(when=None, only_scheduled=False): """ Return a dictionary mapping of job names together with their respective application class. """ # FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py try: cpath = os.path.dirname(os.path.realpath(sys.argv[0]...
python
def get_jobs(when=None, only_scheduled=False): """ Return a dictionary mapping of job names together with their respective application class. """ # FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py try: cpath = os.path.dirname(os.path.realpath(sys.argv[0]...
[ "def", "get_jobs", "(", "when", "=", "None", ",", "only_scheduled", "=", "False", ")", ":", "# FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py", "try", ":", "cpath", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ...
Return a dictionary mapping of job names together with their respective application class.
[ "Return", "a", "dictionary", "mapping", "of", "job", "names", "together", "with", "their", "respective", "application", "class", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/jobs.py#L102-L139
train
django-extensions/django-extensions
django_extensions/management/commands/runjobs.py
Command.runjobs_by_signals
def runjobs_by_signals(self, when, options): """ Run jobs from the signals """ # Thanks for Ian Holsman for the idea and code from django_extensions.management import signals from django.conf import settings verbosity = options["verbosity"] for app_name in settings.INSTA...
python
def runjobs_by_signals(self, when, options): """ Run jobs from the signals """ # Thanks for Ian Holsman for the idea and code from django_extensions.management import signals from django.conf import settings verbosity = options["verbosity"] for app_name in settings.INSTA...
[ "def", "runjobs_by_signals", "(", "self", ",", "when", ",", "options", ")", ":", "# Thanks for Ian Holsman for the idea and code", "from", "django_extensions", ".", "management", "import", "signals", "from", "django", ".", "conf", "import", "settings", "verbosity", "=...
Run jobs from the signals
[ "Run", "jobs", "from", "the", "signals" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/runjobs.py#L44-L74
train
django-extensions/django-extensions
django_extensions/__init__.py
get_version
def get_version(version): """Dynamically calculate the version based on VERSION tuple.""" if len(version) > 2 and version[2] is not None: if isinstance(version[2], int): str_version = "%s.%s.%s" % version[:3] else: str_version = "%s.%s_%s" % version[:3] else: ...
python
def get_version(version): """Dynamically calculate the version based on VERSION tuple.""" if len(version) > 2 and version[2] is not None: if isinstance(version[2], int): str_version = "%s.%s.%s" % version[:3] else: str_version = "%s.%s_%s" % version[:3] else: ...
[ "def", "get_version", "(", "version", ")", ":", "if", "len", "(", "version", ")", ">", "2", "and", "version", "[", "2", "]", "is", "not", "None", ":", "if", "isinstance", "(", "version", "[", "2", "]", ",", "int", ")", ":", "str_version", "=", "\...
Dynamically calculate the version based on VERSION tuple.
[ "Dynamically", "calculate", "the", "version", "based", "on", "VERSION", "tuple", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/__init__.py#L5-L15
train
django-extensions/django-extensions
django_extensions/templatetags/indent_text.py
indentby
def indentby(parser, token): """ Add indentation to text between the tags by the given indentation level. {% indentby <indent_level> [if <statement>] %} ... {% endindentby %} Arguments: indent_level - Number of spaces to indent text with. statement - Only apply indent_level if the ...
python
def indentby(parser, token): """ Add indentation to text between the tags by the given indentation level. {% indentby <indent_level> [if <statement>] %} ... {% endindentby %} Arguments: indent_level - Number of spaces to indent text with. statement - Only apply indent_level if the ...
[ "def", "indentby", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "largs", "=", "len", "(", "args", ")", "if", "largs", "not", "in", "(", "2", ",", "4", ")", ":", "raise", "template", ".", "TemplateSyn...
Add indentation to text between the tags by the given indentation level. {% indentby <indent_level> [if <statement>] %} ... {% endindentby %} Arguments: indent_level - Number of spaces to indent text with. statement - Only apply indent_level if the boolean statement evalutates to True.
[ "Add", "indentation", "to", "text", "between", "the", "tags", "by", "the", "given", "indentation", "level", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/templatetags/indent_text.py#L33-L55
train
django-extensions/django-extensions
django_extensions/management/commands/pipchecker.py
Command._urlopen_as_json
def _urlopen_as_json(self, url, headers=None): """Shorcut for return contents as json""" req = Request(url, headers=headers) return json.loads(urlopen(req).read())
python
def _urlopen_as_json(self, url, headers=None): """Shorcut for return contents as json""" req = Request(url, headers=headers) return json.loads(urlopen(req).read())
[ "def", "_urlopen_as_json", "(", "self", ",", "url", ",", "headers", "=", "None", ")", ":", "req", "=", "Request", "(", "url", ",", "headers", "=", "headers", ")", "return", "json", ".", "loads", "(", "urlopen", "(", "req", ")", ".", "read", "(", ")...
Shorcut for return contents as json
[ "Shorcut", "for", "return", "contents", "as", "json" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L116-L119
train
django-extensions/django-extensions
django_extensions/management/commands/pipchecker.py
Command.check_pypi
def check_pypi(self): """If the requirement is frozen to pypi, check for a new version.""" for dist in get_installed_distributions(): name = dist.project_name if name in self.reqs.keys(): self.reqs[name]["dist"] = dist pypi = ServerProxy("https://pypi.pyt...
python
def check_pypi(self): """If the requirement is frozen to pypi, check for a new version.""" for dist in get_installed_distributions(): name = dist.project_name if name in self.reqs.keys(): self.reqs[name]["dist"] = dist pypi = ServerProxy("https://pypi.pyt...
[ "def", "check_pypi", "(", "self", ")", ":", "for", "dist", "in", "get_installed_distributions", "(", ")", ":", "name", "=", "dist", ".", "project_name", "if", "name", "in", "self", ".", "reqs", ".", "keys", "(", ")", ":", "self", ".", "reqs", "[", "n...
If the requirement is frozen to pypi, check for a new version.
[ "If", "the", "requirement", "is", "frozen", "to", "pypi", "check", "for", "a", "new", "version", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L132-L164
train
django-extensions/django-extensions
django_extensions/management/commands/pipchecker.py
Command.check_other
def check_other(self): """ If the requirement is frozen somewhere other than pypi or github, skip. If you have a private pypi or use --extra-index-url, consider contributing support here. """ if self.reqs: self.stdout.write(self.style.ERROR("\nOnly pypi and g...
python
def check_other(self): """ If the requirement is frozen somewhere other than pypi or github, skip. If you have a private pypi or use --extra-index-url, consider contributing support here. """ if self.reqs: self.stdout.write(self.style.ERROR("\nOnly pypi and g...
[ "def", "check_other", "(", "self", ")", ":", "if", "self", ".", "reqs", ":", "self", ".", "stdout", ".", "write", "(", "self", ".", "style", ".", "ERROR", "(", "\"\\nOnly pypi and github based requirements are supported:\"", ")", ")", "for", "name", ",", "re...
If the requirement is frozen somewhere other than pypi or github, skip. If you have a private pypi or use --extra-index-url, consider contributing support here.
[ "If", "the", "requirement", "is", "frozen", "somewhere", "other", "than", "pypi", "or", "github", "skip", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L297-L313
train
django-extensions/django-extensions
django_extensions/db/fields/encrypted.py
BaseEncryptedField.get_crypt_class
def get_crypt_class(self): """ Get the Keyczar class to use. The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default, this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption. This is necessary if you are only providing public keys to ...
python
def get_crypt_class(self): """ Get the Keyczar class to use. The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default, this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption. This is necessary if you are only providing public keys to ...
[ "def", "get_crypt_class", "(", "self", ")", ":", "crypt_type", "=", "getattr", "(", "settings", ",", "'ENCRYPTED_FIELD_MODE'", ",", "'DECRYPT_AND_ENCRYPT'", ")", "if", "crypt_type", "==", "'ENCRYPT'", ":", "crypt_class_name", "=", "'Encrypter'", "elif", "crypt_type"...
Get the Keyczar class to use. The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default, this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption. This is necessary if you are only providing public keys to Keyczar. Returns: keyczar....
[ "Get", "the", "Keyczar", "class", "to", "use", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/db/fields/encrypted.py#L46-L69
train
django-extensions/django-extensions
django_extensions/management/commands/sqldsn.py
Command._postgresql
def _postgresql(self, dbhost, dbport, dbname, dbuser, dbpass, dsn_style=None): # noqa """PostgreSQL psycopg2 driver accepts two syntaxes Plus a string for .pgpass file """ dsn = [] if dsn_style is None or dsn_style == 'all' or dsn_style == 'keyvalue': dsnstr = "ho...
python
def _postgresql(self, dbhost, dbport, dbname, dbuser, dbpass, dsn_style=None): # noqa """PostgreSQL psycopg2 driver accepts two syntaxes Plus a string for .pgpass file """ dsn = [] if dsn_style is None or dsn_style == 'all' or dsn_style == 'keyvalue': dsnstr = "ho...
[ "def", "_postgresql", "(", "self", ",", "dbhost", ",", "dbport", ",", "dbname", ",", "dbuser", ",", "dbpass", ",", "dsn_style", "=", "None", ")", ":", "# noqa", "dsn", "=", "[", "]", "if", "dsn_style", "is", "None", "or", "dsn_style", "==", "'all'", ...
PostgreSQL psycopg2 driver accepts two syntaxes Plus a string for .pgpass file
[ "PostgreSQL", "psycopg2", "driver", "accepts", "two", "syntaxes" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldsn.py#L100-L141
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
check_dependencies
def check_dependencies(model, model_queue, avaliable_models): """ Check that all the depenedencies for this model are already in the queue. """ # A list of allowed links: existing fields, itself and the special case ContentType allowed_links = [m.model.__name__ for m in model_queue] + [model.__name__, 'Cont...
python
def check_dependencies(model, model_queue, avaliable_models): """ Check that all the depenedencies for this model are already in the queue. """ # A list of allowed links: existing fields, itself and the special case ContentType allowed_links = [m.model.__name__ for m in model_queue] + [model.__name__, 'Cont...
[ "def", "check_dependencies", "(", "model", ",", "model_queue", ",", "avaliable_models", ")", ":", "# A list of allowed links: existing fields, itself and the special case ContentType", "allowed_links", "=", "[", "m", ".", "model", ".", "__name__", "for", "m", "in", "model...
Check that all the depenedencies for this model are already in the queue.
[ "Check", "that", "all", "the", "depenedencies", "for", "this", "model", "are", "already", "in", "the", "queue", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L712-L733
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
Code.get_import_lines
def get_import_lines(self): """ Take the stored imports and converts them to lines """ if self.imports: return ["from %s import %s" % (value, key) for key, value in self.imports.items()] else: return []
python
def get_import_lines(self): """ Take the stored imports and converts them to lines """ if self.imports: return ["from %s import %s" % (value, key) for key, value in self.imports.items()] else: return []
[ "def", "get_import_lines", "(", "self", ")", ":", "if", "self", ".", "imports", ":", "return", "[", "\"from %s import %s\"", "%", "(", "value", ",", "key", ")", "for", "key", ",", "value", "in", "self", ".", "imports", ".", "items", "(", ")", "]", "e...
Take the stored imports and converts them to lines
[ "Take", "the", "stored", "imports", "and", "converts", "them", "to", "lines" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L178-L183
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
InstanceCode.skip
def skip(self): """ Determine whether or not this object should be skipped. If this model instance is a parent of a single subclassed instance, skip it. The subclassed instance will create this parent instance for us. TODO: Allow the user to force its creation? "...
python
def skip(self): """ Determine whether or not this object should be skipped. If this model instance is a parent of a single subclassed instance, skip it. The subclassed instance will create this parent instance for us. TODO: Allow the user to force its creation? "...
[ "def", "skip", "(", "self", ")", ":", "if", "self", ".", "skip_me", "is", "not", "None", ":", "return", "self", ".", "skip_me", "cls", "=", "self", ".", "instance", ".", "__class__", "using", "=", "router", ".", "db_for_write", "(", "cls", ",", "inst...
Determine whether or not this object should be skipped. If this model instance is a parent of a single subclassed instance, skip it. The subclassed instance will create this parent instance for us. TODO: Allow the user to force its creation?
[ "Determine", "whether", "or", "not", "this", "object", "should", "be", "skipped", ".", "If", "this", "model", "instance", "is", "a", "parent", "of", "a", "single", "subclassed", "instance", "skip", "it", ".", "The", "subclassed", "instance", "will", "create"...
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L299-L327
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
InstanceCode.instantiate
def instantiate(self): """ Write lines for instantiation """ # e.g. model_name_35 = Model() code_lines = [] if not self.instantiated: code_lines.append("%s = %s()" % (self.variable_name, self.model.__name__)) self.instantiated = True # Store our vari...
python
def instantiate(self): """ Write lines for instantiation """ # e.g. model_name_35 = Model() code_lines = [] if not self.instantiated: code_lines.append("%s = %s()" % (self.variable_name, self.model.__name__)) self.instantiated = True # Store our vari...
[ "def", "instantiate", "(", "self", ")", ":", "# e.g. model_name_35 = Model()", "code_lines", "=", "[", "]", "if", "not", "self", ".", "instantiated", ":", "code_lines", ".", "append", "(", "\"%s = %s()\"", "%", "(", "self", ".", "variable_name", ",", "self", ...
Write lines for instantiation
[ "Write", "lines", "for", "instantiation" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L329-L343
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
InstanceCode.get_waiting_list
def get_waiting_list(self, force=False): """ Add lines for any waiting fields that can be completed now. """ code_lines = [] skip_autofield = self.options['skip_autofield'] # Process normal fields for field in list(self.waiting_list): try: # Find the...
python
def get_waiting_list(self, force=False): """ Add lines for any waiting fields that can be completed now. """ code_lines = [] skip_autofield = self.options['skip_autofield'] # Process normal fields for field in list(self.waiting_list): try: # Find the...
[ "def", "get_waiting_list", "(", "self", ",", "force", "=", "False", ")", ":", "code_lines", "=", "[", "]", "skip_autofield", "=", "self", ".", "options", "[", "'skip_autofield'", "]", "# Process normal fields", "for", "field", "in", "list", "(", "self", ".",...
Add lines for any waiting fields that can be completed now.
[ "Add", "lines", "for", "any", "waiting", "fields", "that", "can", "be", "completed", "now", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L345-L366
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
InstanceCode.get_many_to_many_lines
def get_many_to_many_lines(self, force=False): """ Generate lines that define many to many relations for this instance. """ lines = [] for field, rel_items in self.many_to_many_waiting_list.items(): for rel_item in list(rel_items): try: pk_name =...
python
def get_many_to_many_lines(self, force=False): """ Generate lines that define many to many relations for this instance. """ lines = [] for field, rel_items in self.many_to_many_waiting_list.items(): for rel_item in list(rel_items): try: pk_name =...
[ "def", "get_many_to_many_lines", "(", "self", ",", "force", "=", "False", ")", ":", "lines", "=", "[", "]", "for", "field", ",", "rel_items", "in", "self", ".", "many_to_many_waiting_list", ".", "items", "(", ")", ":", "for", "rel_item", "in", "list", "(...
Generate lines that define many to many relations for this instance.
[ "Generate", "lines", "that", "define", "many", "to", "many", "relations", "for", "this", "instance", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L368-L391
train
django-extensions/django-extensions
django_extensions/management/commands/dumpscript.py
Script._queue_models
def _queue_models(self, models, context): """ Work an an appropriate ordering for the models. This isn't essential, but makes the script look nicer because more instances can be defined on their first try. """ model_queue = [] number_remaining_models = len(models)...
python
def _queue_models(self, models, context): """ Work an an appropriate ordering for the models. This isn't essential, but makes the script look nicer because more instances can be defined on their first try. """ model_queue = [] number_remaining_models = len(models)...
[ "def", "_queue_models", "(", "self", ",", "models", ",", "context", ")", ":", "model_queue", "=", "[", "]", "number_remaining_models", "=", "len", "(", "models", ")", "# Max number of cycles allowed before we call it an infinite loop.", "MAX_CYCLES", "=", "number_remain...
Work an an appropriate ordering for the models. This isn't essential, but makes the script look nicer because more instances can be defined on their first try.
[ "Work", "an", "an", "appropriate", "ordering", "for", "the", "models", ".", "This", "isn", "t", "essential", "but", "makes", "the", "script", "look", "nicer", "because", "more", "instances", "can", "be", "defined", "on", "their", "first", "try", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L411-L454
train
django-extensions/django-extensions
django_extensions/management/commands/sqldiff.py
SQLDiff.sql_to_dict
def sql_to_dict(self, query, param): """ Execute query and return a dict sql_to_dict(query, param) -> list of dicts code from snippet at http://www.djangosnippets.org/snippets/1383/ """ cursor = connection.cursor() cursor.execute(query, param) fieldnames...
python
def sql_to_dict(self, query, param): """ Execute query and return a dict sql_to_dict(query, param) -> list of dicts code from snippet at http://www.djangosnippets.org/snippets/1383/ """ cursor = connection.cursor() cursor.execute(query, param) fieldnames...
[ "def", "sql_to_dict", "(", "self", ",", "query", ",", "param", ")", ":", "cursor", "=", "connection", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "query", ",", "param", ")", "fieldnames", "=", "[", "name", "[", "0", "]", "for", "name", ...
Execute query and return a dict sql_to_dict(query, param) -> list of dicts code from snippet at http://www.djangosnippets.org/snippets/1383/
[ "Execute", "query", "and", "return", "a", "dict" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldiff.py#L257-L274
train
django-extensions/django-extensions
django_extensions/management/commands/sqldiff.py
SQLDiff.print_diff
def print_diff(self, style=no_style()): """ Print differences to stdout """ if self.options['sql']: self.print_diff_sql(style) else: self.print_diff_text(style)
python
def print_diff(self, style=no_style()): """ Print differences to stdout """ if self.options['sql']: self.print_diff_sql(style) else: self.print_diff_text(style)
[ "def", "print_diff", "(", "self", ",", "style", "=", "no_style", "(", ")", ")", ":", "if", "self", ".", "options", "[", "'sql'", "]", ":", "self", ".", "print_diff_sql", "(", "style", ")", "else", ":", "self", ".", "print_diff_text", "(", "style", ")...
Print differences to stdout
[ "Print", "differences", "to", "stdout" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldiff.py#L676-L681
train
django-extensions/django-extensions
django_extensions/templatetags/syntax_color.py
pygments_required
def pygments_required(func): """Raise ImportError if pygments is not installed.""" def wrapper(*args, **kwargs): if not HAS_PYGMENTS: # pragma: no cover raise ImportError( "Please install 'pygments' library to use syntax_color.") rv = func(*args, **kwargs) re...
python
def pygments_required(func): """Raise ImportError if pygments is not installed.""" def wrapper(*args, **kwargs): if not HAS_PYGMENTS: # pragma: no cover raise ImportError( "Please install 'pygments' library to use syntax_color.") rv = func(*args, **kwargs) re...
[ "def", "pygments_required", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_PYGMENTS", ":", "# pragma: no cover", "raise", "ImportError", "(", "\"Please install 'pygments' library to use syntax_color.\"...
Raise ImportError if pygments is not installed.
[ "Raise", "ImportError", "if", "pygments", "is", "not", "installed", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/templatetags/syntax_color.py#L54-L62
train
django-extensions/django-extensions
django_extensions/utils/dia2django.py
addparentstofks
def addparentstofks(rels, fks): """ Get a list of relations, between parents and sons and a dict of clases named in dia, and modifies the fks to add the parent as fk to get order on the output of classes and replaces the base class of the son, to put the class parent name. """ for j in rels:...
python
def addparentstofks(rels, fks): """ Get a list of relations, between parents and sons and a dict of clases named in dia, and modifies the fks to add the parent as fk to get order on the output of classes and replaces the base class of the son, to put the class parent name. """ for j in rels:...
[ "def", "addparentstofks", "(", "rels", ",", "fks", ")", ":", "for", "j", "in", "rels", ":", "son", "=", "index", "(", "fks", ",", "j", "[", "1", "]", ")", "parent", "=", "index", "(", "fks", ",", "j", "[", "0", "]", ")", "fks", "[", "son", ...
Get a list of relations, between parents and sons and a dict of clases named in dia, and modifies the fks to add the parent as fk to get order on the output of classes and replaces the base class of the son, to put the class parent name.
[ "Get", "a", "list", "of", "relations", "between", "parents", "and", "sons", "and", "a", "dict", "of", "clases", "named", "in", "dia", "and", "modifies", "the", "fks", "to", "add", "the", "parent", "as", "fk", "to", "get", "order", "on", "the", "output"...
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/utils/dia2django.py#L57-L69
train
django-extensions/django-extensions
django_extensions/management/shells.py
get_app_name
def get_app_name(mod_name): """ Retrieve application name from models.py module path >>> get_app_name('testapp.models.foo') 'testapp' 'testapp' instead of 'some.testapp' for compatibility: >>> get_app_name('some.testapp.models.foo') 'testapp' >>> get_app_name('some.models.testapp.model...
python
def get_app_name(mod_name): """ Retrieve application name from models.py module path >>> get_app_name('testapp.models.foo') 'testapp' 'testapp' instead of 'some.testapp' for compatibility: >>> get_app_name('some.testapp.models.foo') 'testapp' >>> get_app_name('some.models.testapp.model...
[ "def", "get_app_name", "(", "mod_name", ")", ":", "rparts", "=", "list", "(", "reversed", "(", "mod_name", ".", "split", "(", "'.'", ")", ")", ")", "try", ":", "try", ":", "return", "rparts", "[", "rparts", ".", "index", "(", "MODELS_MODULE_NAME", ")",...
Retrieve application name from models.py module path >>> get_app_name('testapp.models.foo') 'testapp' 'testapp' instead of 'some.testapp' for compatibility: >>> get_app_name('some.testapp.models.foo') 'testapp' >>> get_app_name('some.models.testapp.models.foo') 'testapp' >>> get_app_na...
[ "Retrieve", "application", "name", "from", "models", ".", "py", "module", "path" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/shells.py#L46-L72
train
django-extensions/django-extensions
django_extensions/management/commands/merge_model_instances.py
get_generic_fields
def get_generic_fields(): """Return a list of all GenericForeignKeys in all models.""" generic_fields = [] for model in apps.get_models(): for field_name, field in model.__dict__.items(): if isinstance(field, GenericForeignKey): generic_fields.append(field) return gen...
python
def get_generic_fields(): """Return a list of all GenericForeignKeys in all models.""" generic_fields = [] for model in apps.get_models(): for field_name, field in model.__dict__.items(): if isinstance(field, GenericForeignKey): generic_fields.append(field) return gen...
[ "def", "get_generic_fields", "(", ")", ":", "generic_fields", "=", "[", "]", "for", "model", "in", "apps", ".", "get_models", "(", ")", ":", "for", "field_name", ",", "field", "in", "model", ".", "__dict__", ".", "items", "(", ")", ":", "if", "isinstan...
Return a list of all GenericForeignKeys in all models.
[ "Return", "a", "list", "of", "all", "GenericForeignKeys", "in", "all", "models", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/merge_model_instances.py#L78-L85
train
django-extensions/django-extensions
django_extensions/management/commands/merge_model_instances.py
Command.merge_model_instances
def merge_model_instances(self, primary_object, alias_objects): """ Merge several model instances into one, the `primary_object`. Use this function to merge model objects and migrate all of the related fields from the alias objects the primary object. """ generic_fields =...
python
def merge_model_instances(self, primary_object, alias_objects): """ Merge several model instances into one, the `primary_object`. Use this function to merge model objects and migrate all of the related fields from the alias objects the primary object. """ generic_fields =...
[ "def", "merge_model_instances", "(", "self", ",", "primary_object", ",", "alias_objects", ")", ":", "generic_fields", "=", "get_generic_fields", "(", ")", "# get related fields", "related_fields", "=", "list", "(", "filter", "(", "lambda", "x", ":", "x", ".", "i...
Merge several model instances into one, the `primary_object`. Use this function to merge model objects and migrate all of the related fields from the alias objects the primary object.
[ "Merge", "several", "model", "instances", "into", "one", "the", "primary_object", ".", "Use", "this", "function", "to", "merge", "model", "objects", "and", "migrate", "all", "of", "the", "related", "fields", "from", "the", "alias", "objects", "the", "primary",...
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/merge_model_instances.py#L132-L222
train
django-extensions/django-extensions
django_extensions/management/commands/graph_models.py
Command.add_arguments
def add_arguments(self, parser): """Unpack self.arguments for parser.add_arguments.""" parser.add_argument('app_label', nargs='*') for argument in self.arguments: parser.add_argument(*argument.split(' '), **self.arguments[argument])
python
def add_arguments(self, parser): """Unpack self.arguments for parser.add_arguments.""" parser.add_argument('app_label', nargs='*') for argument in self.arguments: parser.add_argument(*argument.split(' '), **self.arguments[argument])
[ "def", "add_arguments", "(", "self", ",", "parser", ")", ":", "parser", ".", "add_argument", "(", "'app_label'", ",", "nargs", "=", "'*'", ")", "for", "argument", "in", "self", ".", "arguments", ":", "parser", ".", "add_argument", "(", "*", "argument", "...
Unpack self.arguments for parser.add_arguments.
[ "Unpack", "self", ".", "arguments", "for", "parser", ".", "add_arguments", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L169-L173
train
django-extensions/django-extensions
django_extensions/management/commands/graph_models.py
Command.render_output_json
def render_output_json(self, graph_data, output_file=None): """Write model data to file or stdout in JSON format.""" if output_file: with open(output_file, 'wt') as json_output_f: json.dump(graph_data, json_output_f) else: self.stdout.write(json.dumps(grap...
python
def render_output_json(self, graph_data, output_file=None): """Write model data to file or stdout in JSON format.""" if output_file: with open(output_file, 'wt') as json_output_f: json.dump(graph_data, json_output_f) else: self.stdout.write(json.dumps(grap...
[ "def", "render_output_json", "(", "self", ",", "graph_data", ",", "output_file", "=", "None", ")", ":", "if", "output_file", ":", "with", "open", "(", "output_file", ",", "'wt'", ")", "as", "json_output_f", ":", "json", ".", "dump", "(", "graph_data", ",",...
Write model data to file or stdout in JSON format.
[ "Write", "model", "data", "to", "file", "or", "stdout", "in", "JSON", "format", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L246-L252
train
django-extensions/django-extensions
django_extensions/management/commands/graph_models.py
Command.render_output_pygraphviz
def render_output_pygraphviz(self, dotdata, **kwargs): """Render model data as image using pygraphviz""" if not HAS_PYGRAPHVIZ: raise CommandError("You need to install pygraphviz python module") version = pygraphviz.__version__.rstrip("-svn") try: if tuple(int(v)...
python
def render_output_pygraphviz(self, dotdata, **kwargs): """Render model data as image using pygraphviz""" if not HAS_PYGRAPHVIZ: raise CommandError("You need to install pygraphviz python module") version = pygraphviz.__version__.rstrip("-svn") try: if tuple(int(v)...
[ "def", "render_output_pygraphviz", "(", "self", ",", "dotdata", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_PYGRAPHVIZ", ":", "raise", "CommandError", "(", "\"You need to install pygraphviz python module\"", ")", "version", "=", "pygraphviz", ".", "__versio...
Render model data as image using pygraphviz
[ "Render", "model", "data", "as", "image", "using", "pygraphviz" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L254-L272
train
django-extensions/django-extensions
django_extensions/management/commands/graph_models.py
Command.render_output_pydot
def render_output_pydot(self, dotdata, **kwargs): """Render model data as image using pydot""" if not HAS_PYDOT: raise CommandError("You need to install pydot python module") graph = pydot.graph_from_dot_data(dotdata) if not graph: raise CommandError("pydot retur...
python
def render_output_pydot(self, dotdata, **kwargs): """Render model data as image using pydot""" if not HAS_PYDOT: raise CommandError("You need to install pydot python module") graph = pydot.graph_from_dot_data(dotdata) if not graph: raise CommandError("pydot retur...
[ "def", "render_output_pydot", "(", "self", ",", "dotdata", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_PYDOT", ":", "raise", "CommandError", "(", "\"You need to install pydot python module\"", ")", "graph", "=", "pydot", ".", "graph_from_dot_data", "(", ...
Render model data as image using pydot
[ "Render", "model", "data", "as", "image", "using", "pydot" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L274-L297
train
django-extensions/django-extensions
django_extensions/management/commands/show_urls.py
Command.extract_views_from_urlpatterns
def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None): """ Return a list of views from a list of urlpatterns. Each object in the returned list is a three-tuple: (view_func, regex, name) """ views = [] for p in urlpatterns: if isinstan...
python
def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None): """ Return a list of views from a list of urlpatterns. Each object in the returned list is a three-tuple: (view_func, regex, name) """ views = [] for p in urlpatterns: if isinstan...
[ "def", "extract_views_from_urlpatterns", "(", "self", ",", "urlpatterns", ",", "base", "=", "''", ",", "namespace", "=", "None", ")", ":", "views", "=", "[", "]", "for", "p", "in", "urlpatterns", ":", "if", "isinstance", "(", "p", ",", "(", "URLPattern",...
Return a list of views from a list of urlpatterns. Each object in the returned list is a three-tuple: (view_func, regex, name)
[ "Return", "a", "list", "of", "views", "from", "a", "list", "of", "urlpatterns", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/show_urls.py#L196-L245
train
django-extensions/django-extensions
django_extensions/admin/__init__.py
ForeignKeyAutocompleteAdminMixin.foreignkey_autocomplete
def foreignkey_autocomplete(self, request): """ Search in the fields of the given related model and returns the result as a simple string to be used by the jQuery Autocomplete plugin """ query = request.GET.get('q', None) app_label = request.GET.get('app_label', None) ...
python
def foreignkey_autocomplete(self, request): """ Search in the fields of the given related model and returns the result as a simple string to be used by the jQuery Autocomplete plugin """ query = request.GET.get('q', None) app_label = request.GET.get('app_label', None) ...
[ "def", "foreignkey_autocomplete", "(", "self", ",", "request", ")", ":", "query", "=", "request", ".", "GET", ".", "get", "(", "'q'", ",", "None", ")", "app_label", "=", "request", ".", "GET", ".", "get", "(", "'app_label'", ",", "None", ")", "model_na...
Search in the fields of the given related model and returns the result as a simple string to be used by the jQuery Autocomplete plugin
[ "Search", "in", "the", "fields", "of", "the", "given", "related", "model", "and", "returns", "the", "result", "as", "a", "simple", "string", "to", "be", "used", "by", "the", "jQuery", "Autocomplete", "plugin" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/admin/__init__.py#L67-L126
train
django-extensions/django-extensions
django_extensions/admin/__init__.py
ForeignKeyAutocompleteAdminMixin.formfield_for_dbfield
def formfield_for_dbfield(self, db_field, **kwargs): """ Override the default widget for Foreignkey fields if they are specified in the related_search_fields class attribute. """ if isinstance(db_field, models.ForeignKey) and db_field.name in self.related_search_fields: ...
python
def formfield_for_dbfield(self, db_field, **kwargs): """ Override the default widget for Foreignkey fields if they are specified in the related_search_fields class attribute. """ if isinstance(db_field, models.ForeignKey) and db_field.name in self.related_search_fields: ...
[ "def", "formfield_for_dbfield", "(", "self", ",", "db_field", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "db_field", ",", "models", ".", "ForeignKey", ")", "and", "db_field", ".", "name", "in", "self", ".", "related_search_fields", ":", "h...
Override the default widget for Foreignkey fields if they are specified in the related_search_fields class attribute.
[ "Override", "the", "default", "widget", "for", "Foreignkey", "fields", "if", "they", "are", "specified", "in", "the", "related_search_fields", "class", "attribute", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/admin/__init__.py#L147-L158
train
django-extensions/django-extensions
django_extensions/management/technical_response.py
null_technical_500_response
def null_technical_500_response(request, exc_type, exc_value, tb, status_code=500): """ Alternative function for django.views.debug.technical_500_response. Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid leaking exceptions. If an uncaught exception is rai...
python
def null_technical_500_response(request, exc_type, exc_value, tb, status_code=500): """ Alternative function for django.views.debug.technical_500_response. Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid leaking exceptions. If an uncaught exception is rai...
[ "def", "null_technical_500_response", "(", "request", ",", "exc_type", ",", "exc_value", ",", "tb", ",", "status_code", "=", "500", ")", ":", "try", ":", "# Store the most recent tb for WSGI requests. The class can be found in the second frame of the tb", "if", "isinstance", ...
Alternative function for django.views.debug.technical_500_response. Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid leaking exceptions. If an uncaught exception is raised, the wrapper calls technical_500_response() to create a response for django's debug view...
[ "Alternative", "function", "for", "django", ".", "views", ".", "debug", ".", "technical_500_response", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/technical_response.py#L11-L37
train
django-extensions/django-extensions
django_extensions/management/commands/sync_s3.py
Command.invalidate_objects_cf
def invalidate_objects_cf(self): """Split the invalidation request in groups of 1000 objects""" if not self.AWS_CLOUDFRONT_DISTRIBUTION: raise CommandError( 'An object invalidation was requested but the variable ' 'AWS_CLOUDFRONT_DISTRIBUTION is not present in...
python
def invalidate_objects_cf(self): """Split the invalidation request in groups of 1000 objects""" if not self.AWS_CLOUDFRONT_DISTRIBUTION: raise CommandError( 'An object invalidation was requested but the variable ' 'AWS_CLOUDFRONT_DISTRIBUTION is not present in...
[ "def", "invalidate_objects_cf", "(", "self", ")", ":", "if", "not", "self", ".", "AWS_CLOUDFRONT_DISTRIBUTION", ":", "raise", "CommandError", "(", "'An object invalidation was requested but the variable '", "'AWS_CLOUDFRONT_DISTRIBUTION is not present in your settings.'", ")", "#...
Split the invalidation request in groups of 1000 objects
[ "Split", "the", "invalidation", "request", "in", "groups", "of", "1000", "objects" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sync_s3.py#L253-L274
train
django-extensions/django-extensions
django_extensions/management/commands/sync_s3.py
Command.open_s3
def open_s3(self): """Open connection to S3 returning bucket and key""" conn = boto.connect_s3( self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, **self.get_s3connection_kwargs()) try: bucket = conn.get_bucket(self.AWS_BUCKET_NAME) except...
python
def open_s3(self): """Open connection to S3 returning bucket and key""" conn = boto.connect_s3( self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, **self.get_s3connection_kwargs()) try: bucket = conn.get_bucket(self.AWS_BUCKET_NAME) except...
[ "def", "open_s3", "(", "self", ")", ":", "conn", "=", "boto", ".", "connect_s3", "(", "self", ".", "AWS_ACCESS_KEY_ID", ",", "self", ".", "AWS_SECRET_ACCESS_KEY", ",", "*", "*", "self", ".", "get_s3connection_kwargs", "(", ")", ")", "try", ":", "bucket", ...
Open connection to S3 returning bucket and key
[ "Open", "connection", "to", "S3", "returning", "bucket", "and", "key" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sync_s3.py#L298-L308
train
django-extensions/django-extensions
django_extensions/management/commands/shell_plus.py
Command.set_application_name
def set_application_name(self, options): """ Set the application_name on PostgreSQL connection Use the fallback_application_name to let the user override it with PGAPPNAME env variable http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS # noqa ...
python
def set_application_name(self, options): """ Set the application_name on PostgreSQL connection Use the fallback_application_name to let the user override it with PGAPPNAME env variable http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS # noqa ...
[ "def", "set_application_name", "(", "self", ",", "options", ")", ":", "supported_backends", "=", "[", "'django.db.backends.postgresql'", ",", "'django.db.backends.postgresql_psycopg2'", "]", "opt_name", "=", "'fallback_application_name'", "default_app_name", "=", "'django_she...
Set the application_name on PostgreSQL connection Use the fallback_application_name to let the user override it with PGAPPNAME env variable http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS # noqa
[ "Set", "the", "application_name", "on", "PostgreSQL", "connection" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/shell_plus.py#L394-L425
train
django-extensions/django-extensions
django_extensions/management/commands/mail_debug.py
ExtensionDebuggingServer.process_message
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs): """Output will be sent to the module logger at INFO level.""" inheaders = 1 lines = data.split('\n') logger.info('---------- MESSAGE FOLLOWS ----------') for line in lines: # headers first ...
python
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs): """Output will be sent to the module logger at INFO level.""" inheaders = 1 lines = data.split('\n') logger.info('---------- MESSAGE FOLLOWS ----------') for line in lines: # headers first ...
[ "def", "process_message", "(", "self", ",", "peer", ",", "mailfrom", ",", "rcpttos", ",", "data", ",", "*", "*", "kwargs", ")", ":", "inheaders", "=", "1", "lines", "=", "data", ".", "split", "(", "'\\n'", ")", "logger", ".", "info", "(", "'---------...
Output will be sent to the module logger at INFO level.
[ "Output", "will", "be", "sent", "to", "the", "module", "logger", "at", "INFO", "level", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/mail_debug.py#L20-L31
train
django-extensions/django-extensions
django_extensions/management/email_notifications.py
EmailNotificationCommand.run_from_argv
def run_from_argv(self, argv): """Overriden in order to access the command line arguments.""" self.argv_string = ' '.join(argv) super(EmailNotificationCommand, self).run_from_argv(argv)
python
def run_from_argv(self, argv): """Overriden in order to access the command line arguments.""" self.argv_string = ' '.join(argv) super(EmailNotificationCommand, self).run_from_argv(argv)
[ "def", "run_from_argv", "(", "self", ",", "argv", ")", ":", "self", ".", "argv_string", "=", "' '", ".", "join", "(", "argv", ")", "super", "(", "EmailNotificationCommand", ",", "self", ")", ".", "run_from_argv", "(", "argv", ")" ]
Overriden in order to access the command line arguments.
[ "Overriden", "in", "order", "to", "access", "the", "command", "line", "arguments", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/email_notifications.py#L62-L65
train
django-extensions/django-extensions
django_extensions/management/email_notifications.py
EmailNotificationCommand.execute
def execute(self, *args, **options): """ Overriden in order to send emails on unhandled exception. If an unhandled exception in ``def handle(self, *args, **options)`` occurs and `--email-exception` is set or `self.email_exception` is set to True send an email to ADMINS with the ...
python
def execute(self, *args, **options): """ Overriden in order to send emails on unhandled exception. If an unhandled exception in ``def handle(self, *args, **options)`` occurs and `--email-exception` is set or `self.email_exception` is set to True send an email to ADMINS with the ...
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "try", ":", "super", "(", "EmailNotificationCommand", ",", "self", ")", ".", "execute", "(", "*", "args", ",", "*", "*", "options", ")", "except", "Exception", ":", ...
Overriden in order to send emails on unhandled exception. If an unhandled exception in ``def handle(self, *args, **options)`` occurs and `--email-exception` is set or `self.email_exception` is set to True send an email to ADMINS with the traceback and then reraise the exception.
[ "Overriden", "in", "order", "to", "send", "emails", "on", "unhandled", "exception", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/email_notifications.py#L67-L81
train
django-extensions/django-extensions
django_extensions/management/email_notifications.py
EmailNotificationCommand.send_email_notification
def send_email_notification(self, notification_id=None, include_traceback=False, verbosity=1): """ Send email notifications. Reads settings from settings.EMAIL_NOTIFICATIONS dict, if available, using ``notification_id`` as a key or else provides reasonable defaults. """ ...
python
def send_email_notification(self, notification_id=None, include_traceback=False, verbosity=1): """ Send email notifications. Reads settings from settings.EMAIL_NOTIFICATIONS dict, if available, using ``notification_id`` as a key or else provides reasonable defaults. """ ...
[ "def", "send_email_notification", "(", "self", ",", "notification_id", "=", "None", ",", "include_traceback", "=", "False", ",", "verbosity", "=", "1", ")", ":", "# Load email notification settings if available", "if", "notification_id", "is", "not", "None", ":", "t...
Send email notifications. Reads settings from settings.EMAIL_NOTIFICATIONS dict, if available, using ``notification_id`` as a key or else provides reasonable defaults.
[ "Send", "email", "notifications", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/email_notifications.py#L83-L140
train
django-extensions/django-extensions
django_extensions/compat.py
load_tag_library
def load_tag_library(libname): """ Load a templatetag library on multiple Django versions. Returns None if the library isn't loaded. """ from django.template.backends.django import get_installed_libraries from django.template.library import InvalidTemplateLibrary try: lib = get_inst...
python
def load_tag_library(libname): """ Load a templatetag library on multiple Django versions. Returns None if the library isn't loaded. """ from django.template.backends.django import get_installed_libraries from django.template.library import InvalidTemplateLibrary try: lib = get_inst...
[ "def", "load_tag_library", "(", "libname", ")", ":", "from", "django", ".", "template", ".", "backends", ".", "django", "import", "get_installed_libraries", "from", "django", ".", "template", ".", "library", "import", "InvalidTemplateLibrary", "try", ":", "lib", ...
Load a templatetag library on multiple Django versions. Returns None if the library isn't loaded.
[ "Load", "a", "templatetag", "library", "on", "multiple", "Django", "versions", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/compat.py#L17-L30
train
django-extensions/django-extensions
django_extensions/compat.py
get_template_setting
def get_template_setting(template_key, default=None): """ Read template settings """ templates_var = getattr(settings, 'TEMPLATES', None) if templates_var: for tdict in templates_var: if template_key in tdict: return tdict[template_key] return default
python
def get_template_setting(template_key, default=None): """ Read template settings """ templates_var = getattr(settings, 'TEMPLATES', None) if templates_var: for tdict in templates_var: if template_key in tdict: return tdict[template_key] return default
[ "def", "get_template_setting", "(", "template_key", ",", "default", "=", "None", ")", ":", "templates_var", "=", "getattr", "(", "settings", ",", "'TEMPLATES'", ",", "None", ")", "if", "templates_var", ":", "for", "tdict", "in", "templates_var", ":", "if", "...
Read template settings
[ "Read", "template", "settings" ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/compat.py#L33-L40
train
django-extensions/django-extensions
django_extensions/management/modelviz.py
ModelGraph.use_model
def use_model(self, model_name): """ Decide whether to use a model, based on the model name and the lists of models to exclude and include. """ # Check against exclude list. if self.exclude_models: for model_pattern in self.exclude_models: mode...
python
def use_model(self, model_name): """ Decide whether to use a model, based on the model name and the lists of models to exclude and include. """ # Check against exclude list. if self.exclude_models: for model_pattern in self.exclude_models: mode...
[ "def", "use_model", "(", "self", ",", "model_name", ")", ":", "# Check against exclude list.", "if", "self", ".", "exclude_models", ":", "for", "model_pattern", "in", "self", ".", "exclude_models", ":", "model_pattern", "=", "'^%s$'", "%", "model_pattern", ".", ...
Decide whether to use a model, based on the model name and the lists of models to exclude and include.
[ "Decide", "whether", "to", "use", "a", "model", "based", "on", "the", "model", "name", "and", "the", "lists", "of", "models", "to", "exclude", "and", "include", "." ]
7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/modelviz.py#L359-L377
train
google/transitfeed
transitfeed/shapelib.py
GetClosestPoint
def GetClosestPoint(x, a, b): """ Returns the point on the great circle segment ab closest to x. """ assert(x.IsUnitLength()) assert(a.IsUnitLength()) assert(b.IsUnitLength()) a_cross_b = a.RobustCrossProd(b) # project to the great circle going through a and b p = x.Minus( a_cross_b.Times( ...
python
def GetClosestPoint(x, a, b): """ Returns the point on the great circle segment ab closest to x. """ assert(x.IsUnitLength()) assert(a.IsUnitLength()) assert(b.IsUnitLength()) a_cross_b = a.RobustCrossProd(b) # project to the great circle going through a and b p = x.Minus( a_cross_b.Times( ...
[ "def", "GetClosestPoint", "(", "x", ",", "a", ",", "b", ")", ":", "assert", "(", "x", ".", "IsUnitLength", "(", ")", ")", "assert", "(", "a", ".", "IsUnitLength", "(", ")", ")", "assert", "(", "b", ".", "IsUnitLength", "(", ")", ")", "a_cross_b", ...
Returns the point on the great circle segment ab closest to x.
[ "Returns", "the", "point", "on", "the", "great", "circle", "segment", "ab", "closest", "to", "x", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L221-L243
train
google/transitfeed
transitfeed/shapelib.py
Point.Plus
def Plus(self, other): """ Returns a new point which is the pointwise sum of self and other. """ return Point(self.x + other.x, self.y + other.y, self.z + other.z)
python
def Plus(self, other): """ Returns a new point which is the pointwise sum of self and other. """ return Point(self.x + other.x, self.y + other.y, self.z + other.z)
[ "def", "Plus", "(", "self", ",", "other", ")", ":", "return", "Point", "(", "self", ".", "x", "+", "other", ".", "x", ",", "self", ".", "y", "+", "other", ".", "y", ",", "self", ".", "z", "+", "other", ".", "z", ")" ]
Returns a new point which is the pointwise sum of self and other.
[ "Returns", "a", "new", "point", "which", "is", "the", "pointwise", "sum", "of", "self", "and", "other", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L79-L85
train
google/transitfeed
transitfeed/shapelib.py
Point.Minus
def Minus(self, other): """ Returns a new point which is the pointwise subtraction of other from self. """ return Point(self.x - other.x, self.y - other.y, self.z - other.z)
python
def Minus(self, other): """ Returns a new point which is the pointwise subtraction of other from self. """ return Point(self.x - other.x, self.y - other.y, self.z - other.z)
[ "def", "Minus", "(", "self", ",", "other", ")", ":", "return", "Point", "(", "self", ".", "x", "-", "other", ".", "x", ",", "self", ".", "y", "-", "other", ".", "y", ",", "self", ".", "z", "-", "other", ".", "z", ")" ]
Returns a new point which is the pointwise subtraction of other from self.
[ "Returns", "a", "new", "point", "which", "is", "the", "pointwise", "subtraction", "of", "other", "from", "self", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L87-L94
train
google/transitfeed
transitfeed/shapelib.py
Point.Times
def Times(self, val): """ Returns a new point which is pointwise multiplied by val. """ return Point(self.x * val, self.y * val, self.z * val)
python
def Times(self, val): """ Returns a new point which is pointwise multiplied by val. """ return Point(self.x * val, self.y * val, self.z * val)
[ "def", "Times", "(", "self", ",", "val", ")", ":", "return", "Point", "(", "self", ".", "x", "*", "val", ",", "self", ".", "y", "*", "val", ",", "self", ".", "z", "*", "val", ")" ]
Returns a new point which is pointwise multiplied by val.
[ "Returns", "a", "new", "point", "which", "is", "pointwise", "multiplied", "by", "val", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L102-L106
train
google/transitfeed
transitfeed/shapelib.py
Point.Ortho
def Ortho(self): """Returns a unit-length point orthogonal to this point""" (index, val) = self.LargestComponent() index = index - 1 if index < 0: index = 2 temp = Point(0.012, 0.053, 0.00457) if index == 0: temp.x = 1 elif index == 1: temp.y = 1 elif index == 2: ...
python
def Ortho(self): """Returns a unit-length point orthogonal to this point""" (index, val) = self.LargestComponent() index = index - 1 if index < 0: index = 2 temp = Point(0.012, 0.053, 0.00457) if index == 0: temp.x = 1 elif index == 1: temp.y = 1 elif index == 2: ...
[ "def", "Ortho", "(", "self", ")", ":", "(", "index", ",", "val", ")", "=", "self", ".", "LargestComponent", "(", ")", "index", "=", "index", "-", "1", "if", "index", "<", "0", ":", "index", "=", "2", "temp", "=", "Point", "(", "0.012", ",", "0....
Returns a unit-length point orthogonal to this point
[ "Returns", "a", "unit", "-", "length", "point", "orthogonal", "to", "this", "point" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L145-L158
train
google/transitfeed
transitfeed/shapelib.py
Point.CrossProd
def CrossProd(self, other): """ Returns the cross product of self and other. """ return Point( self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
python
def CrossProd(self, other): """ Returns the cross product of self and other. """ return Point( self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
[ "def", "CrossProd", "(", "self", ",", "other", ")", ":", "return", "Point", "(", "self", ".", "y", "*", "other", ".", "z", "-", "self", ".", "z", "*", "other", ".", "y", ",", "self", ".", "z", "*", "other", ".", "x", "-", "self", ".", "x", ...
Returns the cross product of self and other.
[ "Returns", "the", "cross", "product", "of", "self", "and", "other", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L160-L167
train
google/transitfeed
transitfeed/shapelib.py
Point.Equals
def Equals(self, other): """ Returns true of self and other are approximately equal. """ return (self._approxEq(self.x, other.x) and self._approxEq(self.y, other.y) and self._approxEq(self.z, other.z))
python
def Equals(self, other): """ Returns true of self and other are approximately equal. """ return (self._approxEq(self.x, other.x) and self._approxEq(self.y, other.y) and self._approxEq(self.z, other.z))
[ "def", "Equals", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "_approxEq", "(", "self", ".", "x", ",", "other", ".", "x", ")", "and", "self", ".", "_approxEq", "(", "self", ".", "y", ",", "other", ".", "y", ")", "and", "self...
Returns true of self and other are approximately equal.
[ "Returns", "true", "of", "self", "and", "other", "are", "approximately", "equal", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L173-L179
train
google/transitfeed
transitfeed/shapelib.py
Point.Angle
def Angle(self, other): """ Returns the angle in radians between self and other. """ return math.atan2(self.CrossProd(other).Norm2(), self.DotProd(other))
python
def Angle(self, other): """ Returns the angle in radians between self and other. """ return math.atan2(self.CrossProd(other).Norm2(), self.DotProd(other))
[ "def", "Angle", "(", "self", ",", "other", ")", ":", "return", "math", ".", "atan2", "(", "self", ".", "CrossProd", "(", "other", ")", ".", "Norm2", "(", ")", ",", "self", ".", "DotProd", "(", "other", ")", ")" ]
Returns the angle in radians between self and other.
[ "Returns", "the", "angle", "in", "radians", "between", "self", "and", "other", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L181-L186
train
google/transitfeed
transitfeed/shapelib.py
Point.ToLatLng
def ToLatLng(self): """ Returns that latitude and longitude that this point represents under a spherical Earth model. """ rad_lat = math.atan2(self.z, math.sqrt(self.x * self.x + self.y * self.y)) rad_lng = math.atan2(self.y, self.x) return (rad_lat * 180.0 / math.pi, rad_lng * 180.0 / math....
python
def ToLatLng(self): """ Returns that latitude and longitude that this point represents under a spherical Earth model. """ rad_lat = math.atan2(self.z, math.sqrt(self.x * self.x + self.y * self.y)) rad_lng = math.atan2(self.y, self.x) return (rad_lat * 180.0 / math.pi, rad_lng * 180.0 / math....
[ "def", "ToLatLng", "(", "self", ")", ":", "rad_lat", "=", "math", ".", "atan2", "(", "self", ".", "z", ",", "math", ".", "sqrt", "(", "self", ".", "x", "*", "self", ".", "x", "+", "self", ".", "y", "*", "self", ".", "y", ")", ")", "rad_lng", ...
Returns that latitude and longitude that this point represents under a spherical Earth model.
[ "Returns", "that", "latitude", "and", "longitude", "that", "this", "point", "represents", "under", "a", "spherical", "Earth", "model", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L188-L195
train
google/transitfeed
transitfeed/shapelib.py
Point.FromLatLng
def FromLatLng(lat, lng): """ Returns a new point representing this latitude and longitude under a spherical Earth model. """ phi = lat * (math.pi / 180.0) theta = lng * (math.pi / 180.0) cosphi = math.cos(phi) return Point(math.cos(theta) * cosphi, math.sin(theta) * cos...
python
def FromLatLng(lat, lng): """ Returns a new point representing this latitude and longitude under a spherical Earth model. """ phi = lat * (math.pi / 180.0) theta = lng * (math.pi / 180.0) cosphi = math.cos(phi) return Point(math.cos(theta) * cosphi, math.sin(theta) * cos...
[ "def", "FromLatLng", "(", "lat", ",", "lng", ")", ":", "phi", "=", "lat", "*", "(", "math", ".", "pi", "/", "180.0", ")", "theta", "=", "lng", "*", "(", "math", ".", "pi", "/", "180.0", ")", "cosphi", "=", "math", ".", "cos", "(", "phi", ")",...
Returns a new point representing this latitude and longitude under a spherical Earth model.
[ "Returns", "a", "new", "point", "representing", "this", "latitude", "and", "longitude", "under", "a", "spherical", "Earth", "model", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L198-L208
train
google/transitfeed
transitfeed/shapelib.py
Poly.LengthMeters
def LengthMeters(self): """Return length of this polyline in meters.""" assert(len(self._points) > 0) length = 0 for i in range(0, len(self._points) - 1): length += self._points[i].GetDistanceMeters(self._points[i+1]) return length
python
def LengthMeters(self): """Return length of this polyline in meters.""" assert(len(self._points) > 0) length = 0 for i in range(0, len(self._points) - 1): length += self._points[i].GetDistanceMeters(self._points[i+1]) return length
[ "def", "LengthMeters", "(", "self", ")", ":", "assert", "(", "len", "(", "self", ".", "_points", ")", ">", "0", ")", "length", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "_points", ")", "-", "1", ")", ":", "l...
Return length of this polyline in meters.
[ "Return", "length", "of", "this", "polyline", "in", "meters", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L299-L305
train
google/transitfeed
transitfeed/shapelib.py
Poly.CutAtClosestPoint
def CutAtClosestPoint(self, p): """ Let x be the point on the polyline closest to p. Then CutAtClosestPoint returns two new polylines, one representing the polyline from the beginning up to x, and one representing x onwards to the end of the polyline. x is the first point returned in the secon...
python
def CutAtClosestPoint(self, p): """ Let x be the point on the polyline closest to p. Then CutAtClosestPoint returns two new polylines, one representing the polyline from the beginning up to x, and one representing x onwards to the end of the polyline. x is the first point returned in the secon...
[ "def", "CutAtClosestPoint", "(", "self", ",", "p", ")", ":", "(", "closest", ",", "i", ")", "=", "self", ".", "GetClosestPoint", "(", "p", ")", "tmp", "=", "[", "closest", "]", "tmp", ".", "extend", "(", "self", ".", "_points", "[", "i", "+", "1"...
Let x be the point on the polyline closest to p. Then CutAtClosestPoint returns two new polylines, one representing the polyline from the beginning up to x, and one representing x onwards to the end of the polyline. x is the first point returned in the second polyline.
[ "Let", "x", "be", "the", "point", "on", "the", "polyline", "closest", "to", "p", ".", "Then", "CutAtClosestPoint", "returns", "two", "new", "polylines", "one", "representing", "the", "polyline", "from", "the", "beginning", "up", "to", "x", "and", "one", "r...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L311-L324
train
google/transitfeed
transitfeed/shapelib.py
Poly.GreedyPolyMatchDist
def GreedyPolyMatchDist(self, shape): """ Tries a greedy matching algorithm to match self to the given shape. Returns the maximum distance in meters of any point in self to its matched point in shape under the algorithm. Args: shape, a Poly object. """ tmp_shape = Poly(shape.GetPoints(...
python
def GreedyPolyMatchDist(self, shape): """ Tries a greedy matching algorithm to match self to the given shape. Returns the maximum distance in meters of any point in self to its matched point in shape under the algorithm. Args: shape, a Poly object. """ tmp_shape = Poly(shape.GetPoints(...
[ "def", "GreedyPolyMatchDist", "(", "self", ",", "shape", ")", ":", "tmp_shape", "=", "Poly", "(", "shape", ".", "GetPoints", "(", ")", ")", "max_radius", "=", "0", "for", "(", "i", ",", "point", ")", "in", "enumerate", "(", "self", ".", "_points", ")...
Tries a greedy matching algorithm to match self to the given shape. Returns the maximum distance in meters of any point in self to its matched point in shape under the algorithm. Args: shape, a Poly object.
[ "Tries", "a", "greedy", "matching", "algorithm", "to", "match", "self", "to", "the", "given", "shape", ".", "Returns", "the", "maximum", "distance", "in", "meters", "of", "any", "point", "in", "self", "to", "its", "matched", "point", "in", "shape", "under"...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L326-L341
train
google/transitfeed
transitfeed/shapelib.py
PolyCollection.AddPoly
def AddPoly(self, poly, smart_duplicate_handling=True): """ Adds a new polyline to the collection. """ inserted_name = poly.GetName() if poly.GetName() in self._name_to_shape: if not smart_duplicate_handling: raise ShapeError("Duplicate shape found: " + poly.GetName()) print ("W...
python
def AddPoly(self, poly, smart_duplicate_handling=True): """ Adds a new polyline to the collection. """ inserted_name = poly.GetName() if poly.GetName() in self._name_to_shape: if not smart_duplicate_handling: raise ShapeError("Duplicate shape found: " + poly.GetName()) print ("W...
[ "def", "AddPoly", "(", "self", ",", "poly", ",", "smart_duplicate_handling", "=", "True", ")", ":", "inserted_name", "=", "poly", ".", "GetName", "(", ")", "if", "poly", ".", "GetName", "(", ")", "in", "self", ".", "_name_to_shape", ":", "if", "not", "...
Adds a new polyline to the collection.
[ "Adds", "a", "new", "polyline", "to", "the", "collection", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L392-L408
train
google/transitfeed
transitfeed/shapelib.py
PolyCollection.FindMatchingPolys
def FindMatchingPolys(self, start_point, end_point, max_radius=150): """ Returns a list of polylines in the collection that have endpoints within max_radius of the given start and end points. """ matches = [] for shape in self._name_to_shape.itervalues(): if start_point.GetDistanceMeters(s...
python
def FindMatchingPolys(self, start_point, end_point, max_radius=150): """ Returns a list of polylines in the collection that have endpoints within max_radius of the given start and end points. """ matches = [] for shape in self._name_to_shape.itervalues(): if start_point.GetDistanceMeters(s...
[ "def", "FindMatchingPolys", "(", "self", ",", "start_point", ",", "end_point", ",", "max_radius", "=", "150", ")", ":", "matches", "=", "[", "]", "for", "shape", "in", "self", ".", "_name_to_shape", ".", "itervalues", "(", ")", ":", "if", "start_point", ...
Returns a list of polylines in the collection that have endpoints within max_radius of the given start and end points.
[ "Returns", "a", "list", "of", "polylines", "in", "the", "collection", "that", "have", "endpoints", "within", "max_radius", "of", "the", "given", "start", "and", "end", "points", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L413-L423
train
google/transitfeed
transitfeed/shapelib.py
PolyGraph._ReconstructPath
def _ReconstructPath(self, came_from, current_node): """ Helper method for ShortestPath, to reconstruct path. Arguments: came_from: a dictionary mapping Point to (Point, Poly) tuples. This dictionary keeps track of the previous neighbor to a node, and the edge used to get from the...
python
def _ReconstructPath(self, came_from, current_node): """ Helper method for ShortestPath, to reconstruct path. Arguments: came_from: a dictionary mapping Point to (Point, Poly) tuples. This dictionary keeps track of the previous neighbor to a node, and the edge used to get from the...
[ "def", "_ReconstructPath", "(", "self", ",", "came_from", ",", "current_node", ")", ":", "if", "current_node", "in", "came_from", ":", "(", "previous_node", ",", "previous_edge", ")", "=", "came_from", "[", "current_node", "]", "if", "previous_edge", ".", "Get...
Helper method for ShortestPath, to reconstruct path. Arguments: came_from: a dictionary mapping Point to (Point, Poly) tuples. This dictionary keeps track of the previous neighbor to a node, and the edge used to get from the previous neighbor to the node. current_node: the current P...
[ "Helper", "method", "for", "ShortestPath", "to", "reconstruct", "path", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L505-L526
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddTableColumn
def AddTableColumn(self, table, column): """Add column to table if it is not already there.""" if column not in self._table_columns[table]: self._table_columns[table].append(column)
python
def AddTableColumn(self, table, column): """Add column to table if it is not already there.""" if column not in self._table_columns[table]: self._table_columns[table].append(column)
[ "def", "AddTableColumn", "(", "self", ",", "table", ",", "column", ")", ":", "if", "column", "not", "in", "self", ".", "_table_columns", "[", "table", "]", ":", "self", ".", "_table_columns", "[", "table", "]", ".", "append", "(", "column", ")" ]
Add column to table if it is not already there.
[ "Add", "column", "to", "table", "if", "it", "is", "not", "already", "there", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L87-L90
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddTableColumns
def AddTableColumns(self, table, columns): """Add columns to table if they are not already there. Args: table: table name as a string columns: an iterable of column names""" table_columns = self._table_columns.setdefault(table, []) for attr in columns: if attr not in table_columns: ...
python
def AddTableColumns(self, table, columns): """Add columns to table if they are not already there. Args: table: table name as a string columns: an iterable of column names""" table_columns = self._table_columns.setdefault(table, []) for attr in columns: if attr not in table_columns: ...
[ "def", "AddTableColumns", "(", "self", ",", "table", ",", "columns", ")", ":", "table_columns", "=", "self", ".", "_table_columns", ".", "setdefault", "(", "table", ",", "[", "]", ")", "for", "attr", "in", "columns", ":", "if", "attr", "not", "in", "ta...
Add columns to table if they are not already there. Args: table: table name as a string columns: an iterable of column names
[ "Add", "columns", "to", "table", "if", "they", "are", "not", "already", "there", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L92-L101
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddAgency
def AddAgency(self, name, url, timezone, agency_id=None): """Adds an agency to this schedule.""" agency = self._gtfs_factory.Agency(name, url, timezone, agency_id) self.AddAgencyObject(agency) return agency
python
def AddAgency(self, name, url, timezone, agency_id=None): """Adds an agency to this schedule.""" agency = self._gtfs_factory.Agency(name, url, timezone, agency_id) self.AddAgencyObject(agency) return agency
[ "def", "AddAgency", "(", "self", ",", "name", ",", "url", ",", "timezone", ",", "agency_id", "=", "None", ")", ":", "agency", "=", "self", ".", "_gtfs_factory", ".", "Agency", "(", "name", ",", "url", ",", "timezone", ",", "agency_id", ")", "self", "...
Adds an agency to this schedule.
[ "Adds", "an", "agency", "to", "this", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L157-L161
train
google/transitfeed
transitfeed/schedule.py
Schedule.GetDefaultAgency
def GetDefaultAgency(self): """Return the default Agency. If no default Agency has been set select the default depending on how many Agency objects are in the Schedule. If there are 0 make a new Agency the default, if there is 1 it becomes the default, if there is more than 1 then return None. """ ...
python
def GetDefaultAgency(self): """Return the default Agency. If no default Agency has been set select the default depending on how many Agency objects are in the Schedule. If there are 0 make a new Agency the default, if there is 1 it becomes the default, if there is more than 1 then return None. """ ...
[ "def", "GetDefaultAgency", "(", "self", ")", ":", "if", "not", "self", ".", "_default_agency", ":", "if", "len", "(", "self", ".", "_agencies", ")", "==", "0", ":", "self", ".", "NewDefaultAgency", "(", ")", "elif", "len", "(", "self", ".", "_agencies"...
Return the default Agency. If no default Agency has been set select the default depending on how many Agency objects are in the Schedule. If there are 0 make a new Agency the default, if there is 1 it becomes the default, if there is more than 1 then return None.
[ "Return", "the", "default", "Agency", ".", "If", "no", "default", "Agency", "has", "been", "set", "select", "the", "default", "depending", "on", "how", "many", "Agency", "objects", "are", "in", "the", "Schedule", ".", "If", "there", "are", "0", "make", "...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L184-L195
train
google/transitfeed
transitfeed/schedule.py
Schedule.NewDefaultAgency
def NewDefaultAgency(self, **kwargs): """Create a new Agency object and make it the default agency for this Schedule""" agency = self._gtfs_factory.Agency(**kwargs) if not agency.agency_id: agency.agency_id = util.FindUniqueId(self._agencies) self._default_agency = agency self.SetDefaultAgency...
python
def NewDefaultAgency(self, **kwargs): """Create a new Agency object and make it the default agency for this Schedule""" agency = self._gtfs_factory.Agency(**kwargs) if not agency.agency_id: agency.agency_id = util.FindUniqueId(self._agencies) self._default_agency = agency self.SetDefaultAgency...
[ "def", "NewDefaultAgency", "(", "self", ",", "*", "*", "kwargs", ")", ":", "agency", "=", "self", ".", "_gtfs_factory", ".", "Agency", "(", "*", "*", "kwargs", ")", "if", "not", "agency", ".", "agency_id", ":", "agency", ".", "agency_id", "=", "util", ...
Create a new Agency object and make it the default agency for this Schedule
[ "Create", "a", "new", "Agency", "object", "and", "make", "it", "the", "default", "agency", "for", "this", "Schedule" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L197-L204
train
google/transitfeed
transitfeed/schedule.py
Schedule.SetDefaultAgency
def SetDefaultAgency(self, agency, validate=True): """Make agency the default and add it to the schedule if not already added""" assert isinstance(agency, self._gtfs_factory.Agency) self._default_agency = agency if agency.agency_id not in self._agencies: self.AddAgencyObject(agency, validate=valid...
python
def SetDefaultAgency(self, agency, validate=True): """Make agency the default and add it to the schedule if not already added""" assert isinstance(agency, self._gtfs_factory.Agency) self._default_agency = agency if agency.agency_id not in self._agencies: self.AddAgencyObject(agency, validate=valid...
[ "def", "SetDefaultAgency", "(", "self", ",", "agency", ",", "validate", "=", "True", ")", ":", "assert", "isinstance", "(", "agency", ",", "self", ".", "_gtfs_factory", ".", "Agency", ")", "self", ".", "_default_agency", "=", "agency", "if", "agency", ".",...
Make agency the default and add it to the schedule if not already added
[ "Make", "agency", "the", "default", "and", "add", "it", "to", "the", "schedule", "if", "not", "already", "added" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L206-L211
train
google/transitfeed
transitfeed/schedule.py
Schedule.GetDefaultServicePeriod
def GetDefaultServicePeriod(self): """Return the default ServicePeriod. If no default ServicePeriod has been set select the default depending on how many ServicePeriod objects are in the Schedule. If there are 0 make a new ServicePeriod the default, if there is 1 it becomes the default, if there is more...
python
def GetDefaultServicePeriod(self): """Return the default ServicePeriod. If no default ServicePeriod has been set select the default depending on how many ServicePeriod objects are in the Schedule. If there are 0 make a new ServicePeriod the default, if there is 1 it becomes the default, if there is more...
[ "def", "GetDefaultServicePeriod", "(", "self", ")", ":", "if", "not", "self", ".", "_default_service_period", ":", "if", "len", "(", "self", ".", "service_periods", ")", "==", "0", ":", "self", ".", "NewDefaultServicePeriod", "(", ")", "elif", "len", "(", ...
Return the default ServicePeriod. If no default ServicePeriod has been set select the default depending on how many ServicePeriod objects are in the Schedule. If there are 0 make a new ServicePeriod the default, if there is 1 it becomes the default, if there is more than 1 then return None.
[ "Return", "the", "default", "ServicePeriod", ".", "If", "no", "default", "ServicePeriod", "has", "been", "set", "select", "the", "default", "depending", "on", "how", "many", "ServicePeriod", "objects", "are", "in", "the", "Schedule", ".", "If", "there", "are",...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L221-L232
train
google/transitfeed
transitfeed/schedule.py
Schedule.NewDefaultServicePeriod
def NewDefaultServicePeriod(self): """Create a new ServicePeriod object, make it the default service period and return it. The default service period is used when you create a trip without providing an explict service period. """ service_period = self._gtfs_factory.ServicePeriod() service_period.ser...
python
def NewDefaultServicePeriod(self): """Create a new ServicePeriod object, make it the default service period and return it. The default service period is used when you create a trip without providing an explict service period. """ service_period = self._gtfs_factory.ServicePeriod() service_period.ser...
[ "def", "NewDefaultServicePeriod", "(", "self", ")", ":", "service_period", "=", "self", ".", "_gtfs_factory", ".", "ServicePeriod", "(", ")", "service_period", ".", "service_id", "=", "util", ".", "FindUniqueId", "(", "self", ".", "service_periods", ")", "# blan...
Create a new ServicePeriod object, make it the default service period and return it. The default service period is used when you create a trip without providing an explict service period.
[ "Create", "a", "new", "ServicePeriod", "object", "make", "it", "the", "default", "service", "period", "and", "return", "it", ".", "The", "default", "service", "period", "is", "used", "when", "you", "create", "a", "trip", "without", "providing", "an", "explic...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L234-L242
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddStop
def AddStop(self, lat, lng, name, stop_id=None): """Add a stop to this schedule. Args: lat: Latitude of the stop as a float or string lng: Longitude of the stop as a float or string name: Name of the stop, which will appear in the feed stop_id: stop_id of the stop or None, in which case...
python
def AddStop(self, lat, lng, name, stop_id=None): """Add a stop to this schedule. Args: lat: Latitude of the stop as a float or string lng: Longitude of the stop as a float or string name: Name of the stop, which will appear in the feed stop_id: stop_id of the stop or None, in which case...
[ "def", "AddStop", "(", "self", ",", "lat", ",", "lng", ",", "name", ",", "stop_id", "=", "None", ")", ":", "if", "stop_id", "is", "None", ":", "stop_id", "=", "util", ".", "FindUniqueId", "(", "self", ".", "stops", ")", "stop", "=", "self", ".", ...
Add a stop to this schedule. Args: lat: Latitude of the stop as a float or string lng: Longitude of the stop as a float or string name: Name of the stop, which will appear in the feed stop_id: stop_id of the stop or None, in which case a unique id is picked Returns: A new Stop ob...
[ "Add", "a", "stop", "to", "this", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L340-L356
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddStopObject
def AddStopObject(self, stop, problem_reporter=None): """Add Stop object to this schedule if stop_id is non-blank.""" assert stop._schedule is None if not problem_reporter: problem_reporter = self.problem_reporter if not stop.stop_id: return if stop.stop_id in self.stops: problem...
python
def AddStopObject(self, stop, problem_reporter=None): """Add Stop object to this schedule if stop_id is non-blank.""" assert stop._schedule is None if not problem_reporter: problem_reporter = self.problem_reporter if not stop.stop_id: return if stop.stop_id in self.stops: problem...
[ "def", "AddStopObject", "(", "self", ",", "stop", ",", "problem_reporter", "=", "None", ")", ":", "assert", "stop", ".", "_schedule", "is", "None", "if", "not", "problem_reporter", ":", "problem_reporter", "=", "self", ".", "problem_reporter", "if", "not", "...
Add Stop object to this schedule if stop_id is non-blank.
[ "Add", "Stop", "object", "to", "this", "schedule", "if", "stop_id", "is", "non", "-", "blank", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L358-L375
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddRoute
def AddRoute(self, short_name, long_name, route_type, route_id=None): """Add a route to this schedule. Args: short_name: Short name of the route, such as "71L" long_name: Full name of the route, such as "NW 21st Ave/St Helens Rd" route_type: A type such as "Tram", "Subway" or "Bus" rout...
python
def AddRoute(self, short_name, long_name, route_type, route_id=None): """Add a route to this schedule. Args: short_name: Short name of the route, such as "71L" long_name: Full name of the route, such as "NW 21st Ave/St Helens Rd" route_type: A type such as "Tram", "Subway" or "Bus" rout...
[ "def", "AddRoute", "(", "self", ",", "short_name", ",", "long_name", ",", "route_type", ",", "route_id", "=", "None", ")", ":", "if", "route_id", "is", "None", ":", "route_id", "=", "util", ".", "FindUniqueId", "(", "self", ".", "routes", ")", "route", ...
Add a route to this schedule. Args: short_name: Short name of the route, such as "71L" long_name: Full name of the route, such as "NW 21st Ave/St Helens Rd" route_type: A type such as "Tram", "Subway" or "Bus" route_id: id of the route or None, in which case a unique id is picked Return...
[ "Add", "a", "route", "to", "this", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L380-L397
train
google/transitfeed
transitfeed/schedule.py
Schedule.AddFareObject
def AddFareObject(self, fare, problem_reporter=None): """Deprecated. Please use AddFareAttributeObject.""" warnings.warn("No longer supported. The Fare class was renamed to " "FareAttribute, and all related functions were renamed " "accordingly.", DeprecationWarning) self...
python
def AddFareObject(self, fare, problem_reporter=None): """Deprecated. Please use AddFareAttributeObject.""" warnings.warn("No longer supported. The Fare class was renamed to " "FareAttribute, and all related functions were renamed " "accordingly.", DeprecationWarning) self...
[ "def", "AddFareObject", "(", "self", ",", "fare", ",", "problem_reporter", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"No longer supported. The Fare class was renamed to \"", "\"FareAttribute, and all related functions were renamed \"", "\"accordingly.\"", ",", "D...
Deprecated. Please use AddFareAttributeObject.
[ "Deprecated", ".", "Please", "use", "AddFareAttributeObject", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L475-L480
train
google/transitfeed
transitfeed/schedule.py
Schedule.GetNearestStops
def GetNearestStops(self, lat, lon, n=1): """Return the n nearest stops to lat,lon""" dist_stop_list = [] for s in self.stops.values(): # TODO: Use util.ApproximateDistanceBetweenStops? dist = (s.stop_lat - lat)**2 + (s.stop_lon - lon)**2 if len(dist_stop_list) < n: bisect.insort(d...
python
def GetNearestStops(self, lat, lon, n=1): """Return the n nearest stops to lat,lon""" dist_stop_list = [] for s in self.stops.values(): # TODO: Use util.ApproximateDistanceBetweenStops? dist = (s.stop_lat - lat)**2 + (s.stop_lon - lon)**2 if len(dist_stop_list) < n: bisect.insort(d...
[ "def", "GetNearestStops", "(", "self", ",", "lat", ",", "lon", ",", "n", "=", "1", ")", ":", "dist_stop_list", "=", "[", "]", "for", "s", "in", "self", ".", "stops", ".", "values", "(", ")", ":", "# TODO: Use util.ApproximateDistanceBetweenStops?", "dist",...
Return the n nearest stops to lat,lon
[ "Return", "the", "n", "nearest", "stops", "to", "lat", "lon" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L584-L595
train
google/transitfeed
transitfeed/schedule.py
Schedule.GetStopsInBoundingBox
def GetStopsInBoundingBox(self, north, east, south, west, n): """Return a sample of up to n stops in a bounding box""" stop_list = [] for s in self.stops.values(): if (s.stop_lat <= north and s.stop_lat >= south and s.stop_lon <= east and s.stop_lon >= west): stop_list.append(s) ...
python
def GetStopsInBoundingBox(self, north, east, south, west, n): """Return a sample of up to n stops in a bounding box""" stop_list = [] for s in self.stops.values(): if (s.stop_lat <= north and s.stop_lat >= south and s.stop_lon <= east and s.stop_lon >= west): stop_list.append(s) ...
[ "def", "GetStopsInBoundingBox", "(", "self", ",", "north", ",", "east", ",", "south", ",", "west", ",", "n", ")", ":", "stop_list", "=", "[", "]", "for", "s", "in", "self", ".", "stops", ".", "values", "(", ")", ":", "if", "(", "s", ".", "stop_la...
Return a sample of up to n stops in a bounding box
[ "Return", "a", "sample", "of", "up", "to", "n", "stops", "in", "a", "bounding", "box" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L597-L606
train
google/transitfeed
transitfeed/schedule.py
Schedule.ValidateFeedStartAndExpirationDates
def ValidateFeedStartAndExpirationDates(self, problems, first_date, last_date, first_date_origin, last_date_origin, today): """Validate the start and expiration dates of the feed. Issue a warning if it only starts in the futu...
python
def ValidateFeedStartAndExpirationDates(self, problems, first_date, last_date, first_date_origin, last_date_origin, today): """Validate the start and expiration dates of the feed. Issue a warning if it only starts in the futu...
[ "def", "ValidateFeedStartAndExpirationDates", "(", "self", ",", "problems", ",", "first_date", ",", "last_date", ",", "first_date_origin", ",", "last_date_origin", ",", "today", ")", ":", "warning_cutoff", "=", "today", "+", "datetime", ".", "timedelta", "(", "day...
Validate the start and expiration dates of the feed. Issue a warning if it only starts in the future, or if it expires within 60 days. Args: problems: The problem reporter object first_date: A date object representing the first day the feed is active last_date: A date object represe...
[ "Validate", "the", "start", "and", "expiration", "dates", "of", "the", "feed", ".", "Issue", "a", "warning", "if", "it", "only", "starts", "in", "the", "future", "or", "if", "it", "expires", "within", "60", "days", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L829-L852
train
google/transitfeed
transitfeed/schedule.py
Schedule.ValidateServiceGaps
def ValidateServiceGaps(self, problems, validation_start_date, validation_end_date, service_gap_interval): """Validate consecutive dates without service in the feed. Issue a warning if it finds service gap...
python
def ValidateServiceGaps(self, problems, validation_start_date, validation_end_date, service_gap_interval): """Validate consecutive dates without service in the feed. Issue a warning if it finds service gap...
[ "def", "ValidateServiceGaps", "(", "self", ",", "problems", ",", "validation_start_date", ",", "validation_end_date", ",", "service_gap_interval", ")", ":", "if", "service_gap_interval", "is", "None", ":", "return", "departures", "=", "self", ".", "GenerateDateTripsDe...
Validate consecutive dates without service in the feed. Issue a warning if it finds service gaps of at least "service_gap_interval" consecutive days in the date range [validation_start_date, last_service_date) Args: problems: The problem reporter object validation_start_date: A dat...
[ "Validate", "consecutive", "dates", "without", "service", "in", "the", "feed", ".", "Issue", "a", "warning", "if", "it", "finds", "service", "gaps", "of", "at", "least", "service_gap_interval", "consecutive", "days", "in", "the", "date", "range", "[", "validat...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L854-L907
train
google/transitfeed
transitfeed/schedule.py
Schedule.ValidateStopTimesForTrip
def ValidateStopTimesForTrip(self, problems, trip, stop_times): """Checks for the stop times of a trip. Ensure that a trip does not have too many consecutive stop times with the same departure/arrival time.""" prev_departure_secs = -1 consecutive_stop_times_with_potentially_same_time = 0 consec...
python
def ValidateStopTimesForTrip(self, problems, trip, stop_times): """Checks for the stop times of a trip. Ensure that a trip does not have too many consecutive stop times with the same departure/arrival time.""" prev_departure_secs = -1 consecutive_stop_times_with_potentially_same_time = 0 consec...
[ "def", "ValidateStopTimesForTrip", "(", "self", ",", "problems", ",", "trip", ",", "stop_times", ")", ":", "prev_departure_secs", "=", "-", "1", "consecutive_stop_times_with_potentially_same_time", "=", "0", "consecutive_stop_times_with_fully_specified_same_time", "=", "0",...
Checks for the stop times of a trip. Ensure that a trip does not have too many consecutive stop times with the same departure/arrival time.
[ "Checks", "for", "the", "stop", "times", "of", "a", "trip", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L1169-L1203
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph.Draw
def Draw(self, stoplist=None, triplist=None, height=520): """Main interface for drawing the marey graph. If called without arguments, the data generated in the previous call will be used. New decorators can be added between calls. Args: # Class Stop is defined in transitfeed.py stoplist: [...
python
def Draw(self, stoplist=None, triplist=None, height=520): """Main interface for drawing the marey graph. If called without arguments, the data generated in the previous call will be used. New decorators can be added between calls. Args: # Class Stop is defined in transitfeed.py stoplist: [...
[ "def", "Draw", "(", "self", ",", "stoplist", "=", "None", ",", "triplist", "=", "None", ",", "height", "=", "520", ")", ":", "output", "=", "str", "(", ")", "if", "not", "triplist", ":", "triplist", "=", "[", "]", "if", "not", "stoplist", ":", "s...
Main interface for drawing the marey graph. If called without arguments, the data generated in the previous call will be used. New decorators can be added between calls. Args: # Class Stop is defined in transitfeed.py stoplist: [Stop, Stop, ...] # Class Trip is defined in transitfeed.py ...
[ "Main", "interface", "for", "drawing", "the", "marey", "graph", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L73-L112
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._BuildStations
def _BuildStations(self, stoplist): """Dispatches the best algorithm for calculating station line position. Args: # Class Stop is defined in transitfeed.py stoplist: [Stop, Stop, ...] # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] Returns: # One integer...
python
def _BuildStations(self, stoplist): """Dispatches the best algorithm for calculating station line position. Args: # Class Stop is defined in transitfeed.py stoplist: [Stop, Stop, ...] # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] Returns: # One integer...
[ "def", "_BuildStations", "(", "self", ",", "stoplist", ")", ":", "stations", "=", "[", "]", "dists", "=", "self", ".", "_EuclidianDistances", "(", "stoplist", ")", "stations", "=", "self", ".", "_CalculateYLines", "(", "dists", ")", "return", "stations" ]
Dispatches the best algorithm for calculating station line position. Args: # Class Stop is defined in transitfeed.py stoplist: [Stop, Stop, ...] # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] Returns: # One integer y-coordinate for each station normalized b...
[ "Dispatches", "the", "best", "algorithm", "for", "calculating", "station", "line", "position", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L196-L213
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._EuclidianDistances
def _EuclidianDistances(self,slist): """Calculate euclidian distances between stops. Uses the stoplists long/lats to approximate distances between stations and build a list with y-coordinates for the horizontal lines in the graph. Args: # Class Stop is defined in transitfeed.py stoplis...
python
def _EuclidianDistances(self,slist): """Calculate euclidian distances between stops. Uses the stoplists long/lats to approximate distances between stations and build a list with y-coordinates for the horizontal lines in the graph. Args: # Class Stop is defined in transitfeed.py stoplis...
[ "def", "_EuclidianDistances", "(", "self", ",", "slist", ")", ":", "e_dists2", "=", "[", "transitfeed", ".", "ApproximateDistanceBetweenStops", "(", "stop", ",", "tail", ")", "for", "(", "stop", ",", "tail", ")", "in", "itertools", ".", "izip", "(", "slist...
Calculate euclidian distances between stops. Uses the stoplists long/lats to approximate distances between stations and build a list with y-coordinates for the horizontal lines in the graph. Args: # Class Stop is defined in transitfeed.py stoplist: [Stop, Stop, ...] Returns: # O...
[ "Calculate", "euclidian", "distances", "between", "stops", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L215-L234
train