repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
philgyford/django-spectator
spectator/events/templatetags/spectator_events.py
most_seen_creators_by_works_card
def most_seen_creators_by_works_card(work_kind=None, role_name=None, num=10): """ Displays a card showing the Creators that are associated with the most Works. e.g.: {% most_seen_creators_by_works_card work_kind='movie' role_name='Director' num=5 %} """ object_list = most_seen_creators_by_wo...
python
def most_seen_creators_by_works_card(work_kind=None, role_name=None, num=10): """ Displays a card showing the Creators that are associated with the most Works. e.g.: {% most_seen_creators_by_works_card work_kind='movie' role_name='Director' num=5 %} """ object_list = most_seen_creators_by_wo...
[ "def", "most_seen_creators_by_works_card", "(", "work_kind", "=", "None", ",", "role_name", "=", "None", ",", "num", "=", "10", ")", ":", "object_list", "=", "most_seen_creators_by_works", "(", "work_kind", "=", "work_kind", ",", "role_name", "=", "role_name", "...
Displays a card showing the Creators that are associated with the most Works. e.g.: {% most_seen_creators_by_works_card work_kind='movie' role_name='Director' num=5 %}
[ "Displays", "a", "card", "showing", "the", "Creators", "that", "are", "associated", "with", "the", "most", "Works", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/templatetags/spectator_events.py#L203-L235
train
philgyford/django-spectator
spectator/events/templatetags/spectator_events.py
most_seen_works_card
def most_seen_works_card(kind=None, num=10): """ Displays a card showing the Works that are associated with the most Events. """ object_list = most_seen_works(kind=kind, num=num) object_list = chartify(object_list, 'num_views', cutoff=1) if kind: card_title = 'Most seen {}'.format( ...
python
def most_seen_works_card(kind=None, num=10): """ Displays a card showing the Works that are associated with the most Events. """ object_list = most_seen_works(kind=kind, num=num) object_list = chartify(object_list, 'num_views', cutoff=1) if kind: card_title = 'Most seen {}'.format( ...
[ "def", "most_seen_works_card", "(", "kind", "=", "None", ",", "num", "=", "10", ")", ":", "object_list", "=", "most_seen_works", "(", "kind", "=", "kind", ",", "num", "=", "num", ")", "object_list", "=", "chartify", "(", "object_list", ",", "'num_views'", ...
Displays a card showing the Works that are associated with the most Events.
[ "Displays", "a", "card", "showing", "the", "Works", "that", "are", "associated", "with", "the", "most", "Events", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/templatetags/spectator_events.py#L247-L267
train
philgyford/django-spectator
spectator/core/models.py
SluggedModelMixin._generate_slug
def _generate_slug(self, value): """ Generates a slug using a Hashid of `value`. """ alphabet = app_settings.SLUG_ALPHABET salt = app_settings.SLUG_SALT hashids = Hashids(alphabet=alphabet, salt=salt, min_length=5) return hashids.encode(value)
python
def _generate_slug(self, value): """ Generates a slug using a Hashid of `value`. """ alphabet = app_settings.SLUG_ALPHABET salt = app_settings.SLUG_SALT hashids = Hashids(alphabet=alphabet, salt=salt, min_length=5) return hashids.encode(value)
[ "def", "_generate_slug", "(", "self", ",", "value", ")", ":", "alphabet", "=", "app_settings", ".", "SLUG_ALPHABET", "salt", "=", "app_settings", ".", "SLUG_SALT", "hashids", "=", "Hashids", "(", "alphabet", "=", "alphabet", ",", "salt", "=", "salt", ",", ...
Generates a slug using a Hashid of `value`.
[ "Generates", "a", "slug", "using", "a", "Hashid", "of", "value", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/models.py#L46-L55
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/storage.py
Storage.create
def create(self, bucket, descriptor, force=False): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Make lists buckets = bucket if isinstance(bucket, six.string_types): buckets = [bucket] descriptors = descriptor if isinstanc...
python
def create(self, bucket, descriptor, force=False): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Make lists buckets = bucket if isinstance(bucket, six.string_types): buckets = [bucket] descriptors = descriptor if isinstanc...
[ "def", "create", "(", "self", ",", "bucket", ",", "descriptor", ",", "force", "=", "False", ")", ":", "# Make lists", "buckets", "=", "bucket", "if", "isinstance", "(", "bucket", ",", "six", ".", "string_types", ")", ":", "buckets", "=", "[", "bucket", ...
https://github.com/frictionlessdata/tableschema-pandas-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "pandas", "-", "py#storage" ]
ef941dbc12f5d346e9612f8fec1b4b356b8493ca
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/storage.py#L47-L71
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/storage.py
Storage.delete
def delete(self, bucket=None, ignore=False): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Make lists buckets = bucket if isinstance(bucket, six.string_types): buckets = [bucket] elif bucket is None: buckets = reversed...
python
def delete(self, bucket=None, ignore=False): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Make lists buckets = bucket if isinstance(bucket, six.string_types): buckets = [bucket] elif bucket is None: buckets = reversed...
[ "def", "delete", "(", "self", ",", "bucket", "=", "None", ",", "ignore", "=", "False", ")", ":", "# Make lists", "buckets", "=", "bucket", "if", "isinstance", "(", "bucket", ",", "six", ".", "string_types", ")", ":", "buckets", "=", "[", "bucket", "]",...
https://github.com/frictionlessdata/tableschema-pandas-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "pandas", "-", "py#storage" ]
ef941dbc12f5d346e9612f8fec1b4b356b8493ca
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/storage.py#L73-L100
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/storage.py
Storage.describe
def describe(self, bucket, descriptor=None): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Set descriptor if descriptor is not None: self.__descriptors[bucket] = descriptor # Get descriptor else: descriptor = self.__d...
python
def describe(self, bucket, descriptor=None): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Set descriptor if descriptor is not None: self.__descriptors[bucket] = descriptor # Get descriptor else: descriptor = self.__d...
[ "def", "describe", "(", "self", ",", "bucket", ",", "descriptor", "=", "None", ")", ":", "# Set descriptor", "if", "descriptor", "is", "not", "None", ":", "self", ".", "__descriptors", "[", "bucket", "]", "=", "descriptor", "# Get descriptor", "else", ":", ...
https://github.com/frictionlessdata/tableschema-pandas-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "pandas", "-", "py#storage" ]
ef941dbc12f5d346e9612f8fec1b4b356b8493ca
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/storage.py#L102-L117
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/storage.py
Storage.iter
def iter(self, bucket): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Check existense if bucket not in self.buckets: message = 'Bucket "%s" doesn\'t exist.' % bucket raise tableschema.exceptions.StorageError(message) # Prepar...
python
def iter(self, bucket): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Check existense if bucket not in self.buckets: message = 'Bucket "%s" doesn\'t exist.' % bucket raise tableschema.exceptions.StorageError(message) # Prepar...
[ "def", "iter", "(", "self", ",", "bucket", ")", ":", "# Check existense", "if", "bucket", "not", "in", "self", ".", "buckets", ":", "message", "=", "'Bucket \"%s\" doesn\\'t exist.'", "%", "bucket", "raise", "tableschema", ".", "exceptions", ".", "StorageError",...
https://github.com/frictionlessdata/tableschema-pandas-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "pandas", "-", "py#storage" ]
ef941dbc12f5d346e9612f8fec1b4b356b8493ca
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/storage.py#L119-L135
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/storage.py
Storage.write
def write(self, bucket, rows): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Prepare descriptor = self.describe(bucket) new_data_frame = self.__mapper.convert_descriptor_and_rows(descriptor, rows) # Just set new DataFrame if current is empty...
python
def write(self, bucket, rows): """https://github.com/frictionlessdata/tableschema-pandas-py#storage """ # Prepare descriptor = self.describe(bucket) new_data_frame = self.__mapper.convert_descriptor_and_rows(descriptor, rows) # Just set new DataFrame if current is empty...
[ "def", "write", "(", "self", ",", "bucket", ",", "rows", ")", ":", "# Prepare", "descriptor", "=", "self", ".", "describe", "(", "bucket", ")", "new_data_frame", "=", "self", ".", "__mapper", ".", "convert_descriptor_and_rows", "(", "descriptor", ",", "rows"...
https://github.com/frictionlessdata/tableschema-pandas-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "pandas", "-", "py#storage" ]
ef941dbc12f5d346e9612f8fec1b4b356b8493ca
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/storage.py#L143-L161
train
philgyford/django-spectator
spectator/events/migrations/0030_movies_to_works.py
forwards
def forwards(apps, schema_editor): """ Change all Movie objects into Work objects, and their associated data into WorkRole and WorkSelection models, then delete the Movie. """ Movie = apps.get_model('spectator_events', 'Movie') Work = apps.get_model('spectator_events', 'Work') WorkRole = app...
python
def forwards(apps, schema_editor): """ Change all Movie objects into Work objects, and their associated data into WorkRole and WorkSelection models, then delete the Movie. """ Movie = apps.get_model('spectator_events', 'Movie') Work = apps.get_model('spectator_events', 'Work') WorkRole = app...
[ "def", "forwards", "(", "apps", ",", "schema_editor", ")", ":", "Movie", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Movie'", ")", "Work", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Work'", ")", "WorkRole", "=", "...
Change all Movie objects into Work objects, and their associated data into WorkRole and WorkSelection models, then delete the Movie.
[ "Change", "all", "Movie", "objects", "into", "Work", "objects", "and", "their", "associated", "data", "into", "WorkRole", "and", "WorkSelection", "models", "then", "delete", "the", "Movie", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0030_movies_to_works.py#L6-L41
train
philgyford/django-spectator
spectator/core/views.py
PaginatedListView.paginate_queryset
def paginate_queryset(self, queryset, page_size): """ Paginate the queryset, if needed. This is EXACTLY the same as the standard ListView.paginate_queryset() except for this line: page = paginator.page(page_number, softlimit=True) Because we want to use the DiggPagin...
python
def paginate_queryset(self, queryset, page_size): """ Paginate the queryset, if needed. This is EXACTLY the same as the standard ListView.paginate_queryset() except for this line: page = paginator.page(page_number, softlimit=True) Because we want to use the DiggPagin...
[ "def", "paginate_queryset", "(", "self", ",", "queryset", ",", "page_size", ")", ":", "paginator", "=", "self", ".", "get_paginator", "(", "queryset", ",", "page_size", ",", "orphans", "=", "self", ".", "get_paginate_orphans", "(", ")", ",", "allow_empty_first...
Paginate the queryset, if needed. This is EXACTLY the same as the standard ListView.paginate_queryset() except for this line: page = paginator.page(page_number, softlimit=True) Because we want to use the DiggPaginator's softlimit option. So that if you're viewing a page of, ...
[ "Paginate", "the", "queryset", "if", "needed", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/views.py#L33-L73
train
philgyford/django-spectator
spectator/reading/templatetags/spectator_reading.py
annual_reading_counts_card
def annual_reading_counts_card(kind='all', current_year=None): """ Displays years and the number of books/periodicals read per year. kind is one of 'book', 'periodical', 'all' (default). current_year is an optional date object representing the year we're already showing information about. "...
python
def annual_reading_counts_card(kind='all', current_year=None): """ Displays years and the number of books/periodicals read per year. kind is one of 'book', 'periodical', 'all' (default). current_year is an optional date object representing the year we're already showing information about. "...
[ "def", "annual_reading_counts_card", "(", "kind", "=", "'all'", ",", "current_year", "=", "None", ")", ":", "if", "kind", "==", "'book'", ":", "card_title", "=", "'Books per year'", "elif", "kind", "==", "'periodical'", ":", "card_title", "=", "'Periodicals per ...
Displays years and the number of books/periodicals read per year. kind is one of 'book', 'periodical', 'all' (default). current_year is an optional date object representing the year we're already showing information about.
[ "Displays", "years", "and", "the", "number", "of", "books", "/", "periodicals", "read", "per", "year", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/reading/templatetags/spectator_reading.py#L33-L53
train
philgyford/django-spectator
spectator/reading/templatetags/spectator_reading.py
day_publications
def day_publications(date): """ Returns a QuerySet of Publications that were being read on `date`. `date` is a date tobject. """ readings = Reading.objects \ .filter(start_date__lte=date) \ .filter( Q(end_date__gte=date) ...
python
def day_publications(date): """ Returns a QuerySet of Publications that were being read on `date`. `date` is a date tobject. """ readings = Reading.objects \ .filter(start_date__lte=date) \ .filter( Q(end_date__gte=date) ...
[ "def", "day_publications", "(", "date", ")", ":", "readings", "=", "Reading", ".", "objects", ".", "filter", "(", "start_date__lte", "=", "date", ")", ".", "filter", "(", "Q", "(", "end_date__gte", "=", "date", ")", "|", "Q", "(", "end_date__isnull", "="...
Returns a QuerySet of Publications that were being read on `date`. `date` is a date tobject.
[ "Returns", "a", "QuerySet", "of", "Publications", "that", "were", "being", "read", "on", "date", ".", "date", "is", "a", "date", "tobject", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/reading/templatetags/spectator_reading.py#L78-L96
train
philgyford/django-spectator
spectator/reading/templatetags/spectator_reading.py
day_publications_card
def day_publications_card(date): """ Displays Publications that were being read on `date`. `date` is a date tobject. """ d = date.strftime(app_settings.DATE_FORMAT) card_title = 'Reading on {}'.format(d) return { 'card_title': card_title, 'publication_list': day_publi...
python
def day_publications_card(date): """ Displays Publications that were being read on `date`. `date` is a date tobject. """ d = date.strftime(app_settings.DATE_FORMAT) card_title = 'Reading on {}'.format(d) return { 'card_title': card_title, 'publication_list': day_publi...
[ "def", "day_publications_card", "(", "date", ")", ":", "d", "=", "date", ".", "strftime", "(", "app_settings", ".", "DATE_FORMAT", ")", "card_title", "=", "'Reading on {}'", ".", "format", "(", "d", ")", "return", "{", "'card_title'", ":", "card_title", ",",...
Displays Publications that were being read on `date`. `date` is a date tobject.
[ "Displays", "Publications", "that", "were", "being", "read", "on", "date", ".", "date", "is", "a", "date", "tobject", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/reading/templatetags/spectator_reading.py#L100-L110
train
philgyford/django-spectator
spectator/reading/templatetags/spectator_reading.py
reading_dates
def reading_dates(reading): """ Given a Reading, with start and end dates and granularities[1] it returns an HTML string representing that period. eg: * '1–6 Feb 2017' * '1 Feb to 3 Mar 2017' * 'Feb 2017 to Mar 2018' * '2017–2018' etc. [1] https://www.flickr.com/ser...
python
def reading_dates(reading): """ Given a Reading, with start and end dates and granularities[1] it returns an HTML string representing that period. eg: * '1–6 Feb 2017' * '1 Feb to 3 Mar 2017' * 'Feb 2017 to Mar 2018' * '2017–2018' etc. [1] https://www.flickr.com/ser...
[ "def", "reading_dates", "(", "reading", ")", ":", "# 3 September 2017", "full_format", "=", "'<time datetime=\"%Y-%m-%d\">{}</time>'", ".", "format", "(", "'%-d %B %Y'", ")", "# September 2017", "month_year_format", "=", "'<time datetime=\"%Y-%m\">{}</time>'", ".", "format", ...
Given a Reading, with start and end dates and granularities[1] it returns an HTML string representing that period. eg: * '1–6 Feb 2017' * '1 Feb to 3 Mar 2017' * 'Feb 2017 to Mar 2018' * '2017–2018' etc. [1] https://www.flickr.com/services/api/misc.dates.html
[ "Given", "a", "Reading", "with", "start", "and", "end", "dates", "and", "granularities", "[", "1", "]", "it", "returns", "an", "HTML", "string", "representing", "that", "period", ".", "eg", ":" ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/reading/templatetags/spectator_reading.py#L136-L288
train
philgyford/django-spectator
spectator/events/migrations/0035_change_event_kinds.py
forwards
def forwards(apps, schema_editor): """ Change Events with kind 'movie' to 'cinema' and Events with kind 'play' to 'theatre'. Purely for more consistency. """ Event = apps.get_model('spectator_events', 'Event') for ev in Event.objects.filter(kind='movie'): ev.kind = 'cinema' ...
python
def forwards(apps, schema_editor): """ Change Events with kind 'movie' to 'cinema' and Events with kind 'play' to 'theatre'. Purely for more consistency. """ Event = apps.get_model('spectator_events', 'Event') for ev in Event.objects.filter(kind='movie'): ev.kind = 'cinema' ...
[ "def", "forwards", "(", "apps", ",", "schema_editor", ")", ":", "Event", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Event'", ")", "for", "ev", "in", "Event", ".", "objects", ".", "filter", "(", "kind", "=", "'movie'", ")", ":", "e...
Change Events with kind 'movie' to 'cinema' and Events with kind 'play' to 'theatre'. Purely for more consistency.
[ "Change", "Events", "with", "kind", "movie", "to", "cinema", "and", "Events", "with", "kind", "play", "to", "theatre", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0035_change_event_kinds.py#L6-L21
train
philgyford/django-spectator
devproject/devproject/settings.py
get_env_variable
def get_env_variable(var_name, default=None): """Get the environment variable or return exception.""" try: return os.environ[var_name] except KeyError: if default is None: error_msg = "Set the %s environment variable" % var_name raise ImproperlyConfigured(error_msg) ...
python
def get_env_variable(var_name, default=None): """Get the environment variable or return exception.""" try: return os.environ[var_name] except KeyError: if default is None: error_msg = "Set the %s environment variable" % var_name raise ImproperlyConfigured(error_msg) ...
[ "def", "get_env_variable", "(", "var_name", ",", "default", "=", "None", ")", ":", "try", ":", "return", "os", ".", "environ", "[", "var_name", "]", "except", "KeyError", ":", "if", "default", "is", "None", ":", "error_msg", "=", "\"Set the %s environment va...
Get the environment variable or return exception.
[ "Get", "the", "environment", "variable", "or", "return", "exception", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/devproject/devproject/settings.py#L21-L30
train
philgyford/django-spectator
spectator/events/migrations/0039_populate_exhibitions.py
generate_slug
def generate_slug(value): """ Generates a slug using a Hashid of `value`. COPIED from spectator.core.models.SluggedModelMixin() because migrations don't make this happen automatically and perhaps the least bad thing is to copy the method here, ugh. """ alphabet = app_settings.SLUG_ALPHABET ...
python
def generate_slug(value): """ Generates a slug using a Hashid of `value`. COPIED from spectator.core.models.SluggedModelMixin() because migrations don't make this happen automatically and perhaps the least bad thing is to copy the method here, ugh. """ alphabet = app_settings.SLUG_ALPHABET ...
[ "def", "generate_slug", "(", "value", ")", ":", "alphabet", "=", "app_settings", ".", "SLUG_ALPHABET", "salt", "=", "app_settings", ".", "SLUG_SALT", "hashids", "=", "Hashids", "(", "alphabet", "=", "alphabet", ",", "salt", "=", "salt", ",", "min_length", "=...
Generates a slug using a Hashid of `value`. COPIED from spectator.core.models.SluggedModelMixin() because migrations don't make this happen automatically and perhaps the least bad thing is to copy the method here, ugh.
[ "Generates", "a", "slug", "using", "a", "Hashid", "of", "value", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0039_populate_exhibitions.py#L11-L24
train
philgyford/django-spectator
spectator/events/migrations/0039_populate_exhibitions.py
forwards
def forwards(apps, schema_editor): """ Having added the new 'exhibition' Work type, we're going to assume that every Event of type 'museum' should actually have one Exhibition attached. So, we'll add one, with the same title as the Event. And we'll move all Creators from the Event to the Exhibition...
python
def forwards(apps, schema_editor): """ Having added the new 'exhibition' Work type, we're going to assume that every Event of type 'museum' should actually have one Exhibition attached. So, we'll add one, with the same title as the Event. And we'll move all Creators from the Event to the Exhibition...
[ "def", "forwards", "(", "apps", ",", "schema_editor", ")", ":", "Event", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Event'", ")", "Work", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Work'", ")", "WorkRole", "=", "...
Having added the new 'exhibition' Work type, we're going to assume that every Event of type 'museum' should actually have one Exhibition attached. So, we'll add one, with the same title as the Event. And we'll move all Creators from the Event to the Exhibition.
[ "Having", "added", "the", "new", "exhibition", "Work", "type", "we", "re", "going", "to", "assume", "that", "every", "Event", "of", "type", "museum", "should", "actually", "have", "one", "Exhibition", "attached", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0039_populate_exhibitions.py#L27-L70
train
philgyford/django-spectator
spectator/core/managers.py
CreatorManager.by_publications
def by_publications(self): """ The Creators who have been most-read, ordered by number of read publications (ignoring if any of those publicatinos have been read multiple times.) Each Creator will have a `num_publications` attribute. """ if not spectator_apps.is_...
python
def by_publications(self): """ The Creators who have been most-read, ordered by number of read publications (ignoring if any of those publicatinos have been read multiple times.) Each Creator will have a `num_publications` attribute. """ if not spectator_apps.is_...
[ "def", "by_publications", "(", "self", ")", ":", "if", "not", "spectator_apps", ".", "is_enabled", "(", "'reading'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"To use the CreatorManager.by_publications() method, 'spectator.reading' must by in INSTALLED_APPS.\"", ")", ...
The Creators who have been most-read, ordered by number of read publications (ignoring if any of those publicatinos have been read multiple times.) Each Creator will have a `num_publications` attribute.
[ "The", "Creators", "who", "have", "been", "most", "-", "read", "ordered", "by", "number", "of", "read", "publications", "(", "ignoring", "if", "any", "of", "those", "publicatinos", "have", "been", "read", "multiple", "times", ".", ")" ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/managers.py#L10-L27
train
philgyford/django-spectator
spectator/core/managers.py
CreatorManager.by_readings
def by_readings(self, role_names=['', 'Author']): """ The Creators who have been most-read, ordered by number of readings. By default it will only include Creators whose role was left empty, or is 'Author'. Each Creator will have a `num_readings` attribute. """ ...
python
def by_readings(self, role_names=['', 'Author']): """ The Creators who have been most-read, ordered by number of readings. By default it will only include Creators whose role was left empty, or is 'Author'. Each Creator will have a `num_readings` attribute. """ ...
[ "def", "by_readings", "(", "self", ",", "role_names", "=", "[", "''", ",", "'Author'", "]", ")", ":", "if", "not", "spectator_apps", ".", "is_enabled", "(", "'reading'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"To use the CreatorManager.by_readings() met...
The Creators who have been most-read, ordered by number of readings. By default it will only include Creators whose role was left empty, or is 'Author'. Each Creator will have a `num_readings` attribute.
[ "The", "Creators", "who", "have", "been", "most", "-", "read", "ordered", "by", "number", "of", "readings", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/managers.py#L29-L48
train
philgyford/django-spectator
spectator/core/managers.py
CreatorManager.by_events
def by_events(self, kind=None): """ Get the Creators involved in the most Events. This only counts Creators directly involved in an Event. i.e. if a Creator is the director of a movie Work, and an Event was a viewing of that movie, that Event wouldn't count. Unless they were ...
python
def by_events(self, kind=None): """ Get the Creators involved in the most Events. This only counts Creators directly involved in an Event. i.e. if a Creator is the director of a movie Work, and an Event was a viewing of that movie, that Event wouldn't count. Unless they were ...
[ "def", "by_events", "(", "self", ",", "kind", "=", "None", ")", ":", "if", "not", "spectator_apps", ".", "is_enabled", "(", "'events'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"To use the CreatorManager.by_events() method, 'spectator.events' must by in INSTALLED...
Get the Creators involved in the most Events. This only counts Creators directly involved in an Event. i.e. if a Creator is the director of a movie Work, and an Event was a viewing of that movie, that Event wouldn't count. Unless they were also directly involved in the Event (e.g. speak...
[ "Get", "the", "Creators", "involved", "in", "the", "most", "Events", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/managers.py#L50-L72
train
philgyford/django-spectator
spectator/core/managers.py
CreatorManager.by_works
def by_works(self, kind=None, role_name=None): """ Get the Creators involved in the most Works. kind - If supplied, only Works with that `kind` value will be counted. role_name - If supplied, only Works on which the role is that will be counted. e.g. To get all 'movie' Works on...
python
def by_works(self, kind=None, role_name=None): """ Get the Creators involved in the most Works. kind - If supplied, only Works with that `kind` value will be counted. role_name - If supplied, only Works on which the role is that will be counted. e.g. To get all 'movie' Works on...
[ "def", "by_works", "(", "self", ",", "kind", "=", "None", ",", "role_name", "=", "None", ")", ":", "if", "not", "spectator_apps", ".", "is_enabled", "(", "'events'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"To use the CreatorManager.by_works() method, 's...
Get the Creators involved in the most Works. kind - If supplied, only Works with that `kind` value will be counted. role_name - If supplied, only Works on which the role is that will be counted. e.g. To get all 'movie' Works on which the Creators had the role 'Director': Creator.o...
[ "Get", "the", "Creators", "involved", "in", "the", "most", "Works", "." ]
f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/managers.py#L74-L104
train
inveniosoftware/invenio-search
examples/app.py
index
def index(): """Query Elasticsearch using Invenio query syntax.""" page = request.values.get('page', 1, type=int) size = request.values.get('size', 2, type=int) search = ExampleSearch()[(page - 1) * size:page * size] if 'q' in request.values: search = search.query(QueryString(query=request.v...
python
def index(): """Query Elasticsearch using Invenio query syntax.""" page = request.values.get('page', 1, type=int) size = request.values.get('size', 2, type=int) search = ExampleSearch()[(page - 1) * size:page * size] if 'q' in request.values: search = search.query(QueryString(query=request.v...
[ "def", "index", "(", ")", ":", "page", "=", "request", ".", "values", ".", "get", "(", "'page'", ",", "1", ",", "type", "=", "int", ")", "size", "=", "request", ".", "values", ".", "get", "(", "'size'", ",", "2", ",", "type", "=", "int", ")", ...
Query Elasticsearch using Invenio query syntax.
[ "Query", "Elasticsearch", "using", "Invenio", "query", "syntax", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/examples/app.py#L106-L119
train
krbcontext/python-krbcontext
krbcontext/context.py
krbContext.clean_options
def clean_options(self, using_keytab=False, principal=None, keytab_file=None, ccache_file=None, password=None): """Clean argument to related object :param bool using_keytab: refer to ``krbContext.__init__``. :param str principal:...
python
def clean_options(self, using_keytab=False, principal=None, keytab_file=None, ccache_file=None, password=None): """Clean argument to related object :param bool using_keytab: refer to ``krbContext.__init__``. :param str principal:...
[ "def", "clean_options", "(", "self", ",", "using_keytab", "=", "False", ",", "principal", "=", "None", ",", "keytab_file", "=", "None", ",", "ccache_file", "=", "None", ",", "password", "=", "None", ")", ":", "cleaned", "=", "{", "}", "if", "using_keytab...
Clean argument to related object :param bool using_keytab: refer to ``krbContext.__init__``. :param str principal: refer to ``krbContext.__init__``. :param str keytab_file: refer to ``krbContext.__init__``. :param str ccache_file: refer to ``krbContext.__init__``. :param str pas...
[ "Clean", "argument", "to", "related", "object" ]
9dc93765a4723fa04c2ca57125294d422a6356cd
https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L104-L148
train
krbcontext/python-krbcontext
krbcontext/context.py
krbContext.init_with_keytab
def init_with_keytab(self): """Initialize credential cache with keytab""" creds_opts = { 'usage': 'initiate', 'name': self._cleaned_options['principal'], } store = {} if self._cleaned_options['keytab'] != DEFAULT_KEYTAB: store['client_keytab']...
python
def init_with_keytab(self): """Initialize credential cache with keytab""" creds_opts = { 'usage': 'initiate', 'name': self._cleaned_options['principal'], } store = {} if self._cleaned_options['keytab'] != DEFAULT_KEYTAB: store['client_keytab']...
[ "def", "init_with_keytab", "(", "self", ")", ":", "creds_opts", "=", "{", "'usage'", ":", "'initiate'", ",", "'name'", ":", "self", ".", "_cleaned_options", "[", "'principal'", "]", ",", "}", "store", "=", "{", "}", "if", "self", ".", "_cleaned_options", ...
Initialize credential cache with keytab
[ "Initialize", "credential", "cache", "with", "keytab" ]
9dc93765a4723fa04c2ca57125294d422a6356cd
https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L150-L183
train
krbcontext/python-krbcontext
krbcontext/context.py
krbContext.init_with_password
def init_with_password(self): """Initialize credential cache with password **Causion:** once you enter password from command line, or pass it to API directly, the given password is not encrypted always. Although getting credential with password works, from security point of view, it ...
python
def init_with_password(self): """Initialize credential cache with password **Causion:** once you enter password from command line, or pass it to API directly, the given password is not encrypted always. Although getting credential with password works, from security point of view, it ...
[ "def", "init_with_password", "(", "self", ")", ":", "creds_opts", "=", "{", "'usage'", ":", "'initiate'", ",", "'name'", ":", "self", ".", "_cleaned_options", "[", "'principal'", "]", ",", "}", "if", "self", ".", "_cleaned_options", "[", "'ccache'", "]", "...
Initialize credential cache with password **Causion:** once you enter password from command line, or pass it to API directly, the given password is not encrypted always. Although getting credential with password works, from security point of view, it is strongly recommended **NOT** use ...
[ "Initialize", "credential", "cache", "with", "password" ]
9dc93765a4723fa04c2ca57125294d422a6356cd
https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L185-L240
train
krbcontext/python-krbcontext
krbcontext/context.py
krbContext._prepare_context
def _prepare_context(self): """Prepare context Initialize credential cache with keytab or password according to ``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so that Kerberos library called in current context is able to get credential from correct cache. ...
python
def _prepare_context(self): """Prepare context Initialize credential cache with keytab or password according to ``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so that Kerberos library called in current context is able to get credential from correct cache. ...
[ "def", "_prepare_context", "(", "self", ")", ":", "ccache", "=", "self", ".", "_cleaned_options", "[", "'ccache'", "]", "# Whatever there is KRB5CCNAME was set in current process,", "# original_krb5ccname will contain current value even if None if", "# that variable wasn't set, and w...
Prepare context Initialize credential cache with keytab or password according to ``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so that Kerberos library called in current context is able to get credential from correct cache. Internal use only.
[ "Prepare", "context" ]
9dc93765a4723fa04c2ca57125294d422a6356cd
https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L242-L273
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.templates
def templates(self): """Generate a dictionary with template names and file paths.""" templates = {} result = [] if self.entry_point_group_templates: result = self.load_entry_point_group_templates( self.entry_point_group_templates) or [] for template i...
python
def templates(self): """Generate a dictionary with template names and file paths.""" templates = {} result = [] if self.entry_point_group_templates: result = self.load_entry_point_group_templates( self.entry_point_group_templates) or [] for template i...
[ "def", "templates", "(", "self", ")", ":", "templates", "=", "{", "}", "result", "=", "[", "]", "if", "self", ".", "entry_point_group_templates", ":", "result", "=", "self", ".", "load_entry_point_group_templates", "(", "self", ".", "entry_point_group_templates"...
Generate a dictionary with template names and file paths.
[ "Generate", "a", "dictionary", "with", "template", "names", "and", "file", "paths", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L71-L83
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.register_mappings
def register_mappings(self, alias, package_name): """Register mappings from a package under given alias. :param alias: The alias. :param package_name: The package name. """ # For backwards compatibility, we also allow for ES2 mappings to be # placed at the root level of ...
python
def register_mappings(self, alias, package_name): """Register mappings from a package under given alias. :param alias: The alias. :param package_name: The package name. """ # For backwards compatibility, we also allow for ES2 mappings to be # placed at the root level of ...
[ "def", "register_mappings", "(", "self", ",", "alias", ",", "package_name", ")", ":", "# For backwards compatibility, we also allow for ES2 mappings to be", "# placed at the root level of the specified package path, and not in", "# the `<package-path>/v2` directory.", "if", "ES_VERSION",...
Register mappings from a package under given alias. :param alias: The alias. :param package_name: The package name.
[ "Register", "mappings", "from", "a", "package", "under", "given", "alias", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L85-L145
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.register_templates
def register_templates(self, directory): """Register templates from the provided directory. :param directory: The templates directory. """ try: resource_listdir(directory, 'v{}'.format(ES_VERSION[0])) directory = '{}/v{}'.format(directory, ES_VERSION[0]) ...
python
def register_templates(self, directory): """Register templates from the provided directory. :param directory: The templates directory. """ try: resource_listdir(directory, 'v{}'.format(ES_VERSION[0])) directory = '{}/v{}'.format(directory, ES_VERSION[0]) ...
[ "def", "register_templates", "(", "self", ",", "directory", ")", ":", "try", ":", "resource_listdir", "(", "directory", ",", "'v{}'", ".", "format", "(", "ES_VERSION", "[", "0", "]", ")", ")", "directory", "=", "'{}/v{}'", ".", "format", "(", "directory", ...
Register templates from the provided directory. :param directory: The templates directory.
[ "Register", "templates", "from", "the", "provided", "directory", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L147-L190
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.load_entry_point_group_mappings
def load_entry_point_group_mappings(self, entry_point_group_mappings): """Load actions from an entry point group.""" for ep in iter_entry_points(group=entry_point_group_mappings): self.register_mappings(ep.name, ep.module_name)
python
def load_entry_point_group_mappings(self, entry_point_group_mappings): """Load actions from an entry point group.""" for ep in iter_entry_points(group=entry_point_group_mappings): self.register_mappings(ep.name, ep.module_name)
[ "def", "load_entry_point_group_mappings", "(", "self", ",", "entry_point_group_mappings", ")", ":", "for", "ep", "in", "iter_entry_points", "(", "group", "=", "entry_point_group_mappings", ")", ":", "self", ".", "register_mappings", "(", "ep", ".", "name", ",", "e...
Load actions from an entry point group.
[ "Load", "actions", "from", "an", "entry", "point", "group", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L192-L195
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.load_entry_point_group_templates
def load_entry_point_group_templates(self, entry_point_group_templates): """Load actions from an entry point group.""" result = [] for ep in iter_entry_points(group=entry_point_group_templates): with self.app.app_context(): for template_dir in ep.load()(): ...
python
def load_entry_point_group_templates(self, entry_point_group_templates): """Load actions from an entry point group.""" result = [] for ep in iter_entry_points(group=entry_point_group_templates): with self.app.app_context(): for template_dir in ep.load()(): ...
[ "def", "load_entry_point_group_templates", "(", "self", ",", "entry_point_group_templates", ")", ":", "result", "=", "[", "]", "for", "ep", "in", "iter_entry_points", "(", "group", "=", "entry_point_group_templates", ")", ":", "with", "self", ".", "app", ".", "a...
Load actions from an entry point group.
[ "Load", "actions", "from", "an", "entry", "point", "group", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L197-L204
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState._client_builder
def _client_builder(self): """Build Elasticsearch client.""" client_config = self.app.config.get('SEARCH_CLIENT_CONFIG') or {} client_config.setdefault( 'hosts', self.app.config.get('SEARCH_ELASTIC_HOSTS')) client_config.setdefault('connection_class', RequestsHttpConnection) ...
python
def _client_builder(self): """Build Elasticsearch client.""" client_config = self.app.config.get('SEARCH_CLIENT_CONFIG') or {} client_config.setdefault( 'hosts', self.app.config.get('SEARCH_ELASTIC_HOSTS')) client_config.setdefault('connection_class', RequestsHttpConnection) ...
[ "def", "_client_builder", "(", "self", ")", ":", "client_config", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'SEARCH_CLIENT_CONFIG'", ")", "or", "{", "}", "client_config", ".", "setdefault", "(", "'hosts'", ",", "self", ".", "app", ".", "c...
Build Elasticsearch client.
[ "Build", "Elasticsearch", "client", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L206-L212
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.client
def client(self): """Return client for current application.""" if self._client is None: self._client = self._client_builder() return self._client
python
def client(self): """Return client for current application.""" if self._client is None: self._client = self._client_builder() return self._client
[ "def", "client", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "None", ":", "self", ".", "_client", "=", "self", ".", "_client_builder", "(", ")", "return", "self", ".", "_client" ]
Return client for current application.
[ "Return", "client", "for", "current", "application", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L215-L219
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.flush_and_refresh
def flush_and_refresh(self, index): """Flush and refresh one or more indices. .. warning:: Do not call this method unless you know what you are doing. This method is only intended to be called during tests. """ self.client.indices.flush(wait_if_ongoing=True, index...
python
def flush_and_refresh(self, index): """Flush and refresh one or more indices. .. warning:: Do not call this method unless you know what you are doing. This method is only intended to be called during tests. """ self.client.indices.flush(wait_if_ongoing=True, index...
[ "def", "flush_and_refresh", "(", "self", ",", "index", ")", ":", "self", ".", "client", ".", "indices", ".", "flush", "(", "wait_if_ongoing", "=", "True", ",", "index", "=", "index", ")", "self", ".", "client", ".", "indices", ".", "refresh", "(", "ind...
Flush and refresh one or more indices. .. warning:: Do not call this method unless you know what you are doing. This method is only intended to be called during tests.
[ "Flush", "and", "refresh", "one", "or", "more", "indices", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L221-L233
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.cluster_version
def cluster_version(self): """Get version of Elasticsearch running on the cluster.""" versionstr = self.client.info()['version']['number'] return [int(x) for x in versionstr.split('.')]
python
def cluster_version(self): """Get version of Elasticsearch running on the cluster.""" versionstr = self.client.info()['version']['number'] return [int(x) for x in versionstr.split('.')]
[ "def", "cluster_version", "(", "self", ")", ":", "versionstr", "=", "self", ".", "client", ".", "info", "(", ")", "[", "'version'", "]", "[", "'number'", "]", "return", "[", "int", "(", "x", ")", "for", "x", "in", "versionstr", ".", "split", "(", "...
Get version of Elasticsearch running on the cluster.
[ "Get", "version", "of", "Elasticsearch", "running", "on", "the", "cluster", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L236-L239
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.active_aliases
def active_aliases(self): """Get a filtered list of aliases based on configuration. Returns aliases and their mappings that are defined in the `SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to `None` (the default), all aliases are included. """ whitel...
python
def active_aliases(self): """Get a filtered list of aliases based on configuration. Returns aliases and their mappings that are defined in the `SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to `None` (the default), all aliases are included. """ whitel...
[ "def", "active_aliases", "(", "self", ")", ":", "whitelisted_aliases", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'SEARCH_MAPPINGS'", ")", "if", "whitelisted_aliases", "is", "None", ":", "return", "self", ".", "aliases", "else", ":", "return",...
Get a filtered list of aliases based on configuration. Returns aliases and their mappings that are defined in the `SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to `None` (the default), all aliases are included.
[ "Get", "a", "filtered", "list", "of", "aliases", "based", "on", "configuration", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L242-L254
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.create
def create(self, ignore=None): """Yield tuple with created index name and responses from a client.""" ignore = ignore or [] def _create(tree_or_filename, alias=None): """Create indices and aliases by walking DFS.""" # Iterate over aliases: for name, value in ...
python
def create(self, ignore=None): """Yield tuple with created index name and responses from a client.""" ignore = ignore or [] def _create(tree_or_filename, alias=None): """Create indices and aliases by walking DFS.""" # Iterate over aliases: for name, value in ...
[ "def", "create", "(", "self", ",", "ignore", "=", "None", ")", ":", "ignore", "=", "ignore", "or", "[", "]", "def", "_create", "(", "tree_or_filename", ",", "alias", "=", "None", ")", ":", "\"\"\"Create indices and aliases by walking DFS.\"\"\"", "# Iterate over...
Yield tuple with created index name and responses from a client.
[ "Yield", "tuple", "with", "created", "index", "name", "and", "responses", "from", "a", "client", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L256-L283
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.put_templates
def put_templates(self, ignore=None): """Yield tuple with registered template and response from client.""" ignore = ignore or [] def _replace_prefix(template_path, body): """Replace index prefix in template request body.""" pattern = '__SEARCH_INDEX_PREFIX__' ...
python
def put_templates(self, ignore=None): """Yield tuple with registered template and response from client.""" ignore = ignore or [] def _replace_prefix(template_path, body): """Replace index prefix in template request body.""" pattern = '__SEARCH_INDEX_PREFIX__' ...
[ "def", "put_templates", "(", "self", ",", "ignore", "=", "None", ")", ":", "ignore", "=", "ignore", "or", "[", "]", "def", "_replace_prefix", "(", "template_path", ",", "body", ")", ":", "\"\"\"Replace index prefix in template request body.\"\"\"", "pattern", "=",...
Yield tuple with registered template and response from client.
[ "Yield", "tuple", "with", "registered", "template", "and", "response", "from", "client", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L285-L314
train
inveniosoftware/invenio-search
invenio_search/ext.py
_SearchState.delete
def delete(self, ignore=None): """Yield tuple with deleted index name and responses from a client.""" ignore = ignore or [] def _delete(tree_or_filename, alias=None): """Delete indexes and aliases by walking DFS.""" if alias: yield alias, self.client.indi...
python
def delete(self, ignore=None): """Yield tuple with deleted index name and responses from a client.""" ignore = ignore or [] def _delete(tree_or_filename, alias=None): """Delete indexes and aliases by walking DFS.""" if alias: yield alias, self.client.indi...
[ "def", "delete", "(", "self", ",", "ignore", "=", "None", ")", ":", "ignore", "=", "ignore", "or", "[", "]", "def", "_delete", "(", "tree_or_filename", ",", "alias", "=", "None", ")", ":", "\"\"\"Delete indexes and aliases by walking DFS.\"\"\"", "if", "alias"...
Yield tuple with deleted index name and responses from a client.
[ "Yield", "tuple", "with", "deleted", "index", "name", "and", "responses", "from", "a", "client", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L316-L341
train
inveniosoftware/invenio-search
invenio_search/ext.py
InvenioSearch.init_app
def init_app(self, app, entry_point_group_mappings='invenio_search.mappings', entry_point_group_templates='invenio_search.templates', **kwargs): """Flask application initialization. :param app: An instance of :class:`~flask.app.Flask`. """ ...
python
def init_app(self, app, entry_point_group_mappings='invenio_search.mappings', entry_point_group_templates='invenio_search.templates', **kwargs): """Flask application initialization. :param app: An instance of :class:`~flask.app.Flask`. """ ...
[ "def", "init_app", "(", "self", ",", "app", ",", "entry_point_group_mappings", "=", "'invenio_search.mappings'", ",", "entry_point_group_templates", "=", "'invenio_search.templates'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "init_config", "(", "app", ")", ...
Flask application initialization. :param app: An instance of :class:`~flask.app.Flask`.
[ "Flask", "application", "initialization", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L357-L375
train
ybrs/pydisque
example/poor_consumer.py
main
def main(): """Start the poor_consumer.""" try: opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "nack=", "servers=", "queues="]) except getopt.GetoptError as err: print str(err) usage() sys.exit() # defaults nack = 0.0 ...
python
def main(): """Start the poor_consumer.""" try: opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "nack=", "servers=", "queues="]) except getopt.GetoptError as err: print str(err) usage() sys.exit() # defaults nack = 0.0 ...
[ "def", "main", "(", ")", ":", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "sys", ".", "argv", "[", "1", ":", "]", ",", "\"h:v\"", ",", "[", "\"help\"", ",", "\"nack=\"", ",", "\"servers=\"", ",", "\"queues=\"", "]", ")", "...
Start the poor_consumer.
[ "Start", "the", "poor_consumer", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/example/poor_consumer.py#L27-L78
train
ybrs/pydisque
pydisque/client.py
Client.connect
def connect(self): """ Connect to one of the Disque nodes. You can get current connection with connected_node property :returns: nothing """ self.connected_node = None for i, node in self.nodes.items(): host, port = i.split(':') port = i...
python
def connect(self): """ Connect to one of the Disque nodes. You can get current connection with connected_node property :returns: nothing """ self.connected_node = None for i, node in self.nodes.items(): host, port = i.split(':') port = i...
[ "def", "connect", "(", "self", ")", ":", "self", ".", "connected_node", "=", "None", "for", "i", ",", "node", "in", "self", ".", "nodes", ".", "items", "(", ")", ":", "host", ",", "port", "=", "i", ".", "split", "(", "':'", ")", "port", "=", "i...
Connect to one of the Disque nodes. You can get current connection with connected_node property :returns: nothing
[ "Connect", "to", "one", "of", "the", "Disque", "nodes", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L117-L143
train
ybrs/pydisque
pydisque/client.py
Client.execute_command
def execute_command(self, *args, **kwargs): """Execute a command on the connected server.""" try: return self.get_connection().execute_command(*args, **kwargs) except ConnectionError as e: logger.warn('trying to reconnect') self.connect() logger.wa...
python
def execute_command(self, *args, **kwargs): """Execute a command on the connected server.""" try: return self.get_connection().execute_command(*args, **kwargs) except ConnectionError as e: logger.warn('trying to reconnect') self.connect() logger.wa...
[ "def", "execute_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "get_connection", "(", ")", ".", "execute_command", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "ConnectionErro...
Execute a command on the connected server.
[ "Execute", "a", "command", "on", "the", "connected", "server", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L157-L165
train
ybrs/pydisque
pydisque/client.py
Client.add_job
def add_job(self, queue_name, job, timeout=200, replicate=None, delay=None, retry=None, ttl=None, maxlen=None, asynchronous=None): """ Add a job to a queue. ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>...
python
def add_job(self, queue_name, job, timeout=200, replicate=None, delay=None, retry=None, ttl=None, maxlen=None, asynchronous=None): """ Add a job to a queue. ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>...
[ "def", "add_job", "(", "self", ",", "queue_name", ",", "job", ",", "timeout", "=", "200", ",", "replicate", "=", "None", ",", "delay", "=", "None", ",", "retry", "=", "None", ",", "ttl", "=", "None", ",", "maxlen", "=", "None", ",", "asynchronous", ...
Add a job to a queue. ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>] [RETRY <sec>] [TTL <sec>] [MAXLEN <count>] [ASYNC] :param queue_name: is the name of the queue, any string, basically. :param job: is a string representing the job. :param timeout: is...
[ "Add", "a", "job", "to", "a", "queue", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L182-L235
train
ybrs/pydisque
pydisque/client.py
Client.get_job
def get_job(self, queues, timeout=None, count=None, nohang=False, withcounters=False): """ Return some number of jobs from specified queues. GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM queue1 queue2 ... queueN :param queues: name of queues ...
python
def get_job(self, queues, timeout=None, count=None, nohang=False, withcounters=False): """ Return some number of jobs from specified queues. GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM queue1 queue2 ... queueN :param queues: name of queues ...
[ "def", "get_job", "(", "self", ",", "queues", ",", "timeout", "=", "None", ",", "count", "=", "None", ",", "nohang", "=", "False", ",", "withcounters", "=", "False", ")", ":", "assert", "queues", "command", "=", "[", "'GETJOB'", "]", "if", "nohang", ...
Return some number of jobs from specified queues. GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM queue1 queue2 ... queueN :param queues: name of queues :returns: list of tuple(job_id, queue_name, job), tuple(job_id, queue_name, job, nacks, additional_de...
[ "Return", "some", "number", "of", "jobs", "from", "specified", "queues", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L237-L271
train
ybrs/pydisque
pydisque/client.py
Client.qstat
def qstat(self, queue_name, return_dict=False): """ Return the status of the queue (currently unimplemented). Future support / testing of QSTAT support in Disque QSTAT <qname> Return produced ... consumed ... idle ... sources [...] ctime ... """ rtn = self.exec...
python
def qstat(self, queue_name, return_dict=False): """ Return the status of the queue (currently unimplemented). Future support / testing of QSTAT support in Disque QSTAT <qname> Return produced ... consumed ... idle ... sources [...] ctime ... """ rtn = self.exec...
[ "def", "qstat", "(", "self", ",", "queue_name", ",", "return_dict", "=", "False", ")", ":", "rtn", "=", "self", ".", "execute_command", "(", "'QSTAT'", ",", "queue_name", ")", "if", "return_dict", ":", "grouped", "=", "self", ".", "_grouper", "(", "rtn",...
Return the status of the queue (currently unimplemented). Future support / testing of QSTAT support in Disque QSTAT <qname> Return produced ... consumed ... idle ... sources [...] ctime ...
[ "Return", "the", "status", "of", "the", "queue", "(", "currently", "unimplemented", ")", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L333-L349
train
ybrs/pydisque
pydisque/client.py
Client.show
def show(self, job_id, return_dict=False): """ Describe the job. :param job_id: """ rtn = self.execute_command('SHOW', job_id) if return_dict: grouped = self._grouper(rtn, 2) rtn = dict((a, b) for a, b in grouped) return rtn
python
def show(self, job_id, return_dict=False): """ Describe the job. :param job_id: """ rtn = self.execute_command('SHOW', job_id) if return_dict: grouped = self._grouper(rtn, 2) rtn = dict((a, b) for a, b in grouped) return rtn
[ "def", "show", "(", "self", ",", "job_id", ",", "return_dict", "=", "False", ")", ":", "rtn", "=", "self", ".", "execute_command", "(", "'SHOW'", ",", "job_id", ")", "if", "return_dict", ":", "grouped", "=", "self", ".", "_grouper", "(", "rtn", ",", ...
Describe the job. :param job_id:
[ "Describe", "the", "job", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L402-L415
train
ybrs/pydisque
pydisque/client.py
Client.pause
def pause(self, queue_name, kw_in=None, kw_out=None, kw_all=None, kw_none=None, kw_state=None, kw_bcast=None): """ Pause a queue. Unfortunately, the PAUSE keywords are mostly reserved words in Python, so I've been a little creative in the function variable names. Open ...
python
def pause(self, queue_name, kw_in=None, kw_out=None, kw_all=None, kw_none=None, kw_state=None, kw_bcast=None): """ Pause a queue. Unfortunately, the PAUSE keywords are mostly reserved words in Python, so I've been a little creative in the function variable names. Open ...
[ "def", "pause", "(", "self", ",", "queue_name", ",", "kw_in", "=", "None", ",", "kw_out", "=", "None", ",", "kw_all", "=", "None", ",", "kw_none", "=", "None", ",", "kw_state", "=", "None", ",", "kw_bcast", "=", "None", ")", ":", "command", "=", "[...
Pause a queue. Unfortunately, the PAUSE keywords are mostly reserved words in Python, so I've been a little creative in the function variable names. Open to suggestions to change it (canardleteer) :param queue_name: The job queue we are modifying. :param kw_in: pause the queue ...
[ "Pause", "a", "queue", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L417-L451
train
ybrs/pydisque
pydisque/client.py
Client.qscan
def qscan(self, cursor=0, count=None, busyloop=None, minlen=None, maxlen=None, importrate=None): """ Iterate all the existing queues in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a bu...
python
def qscan(self, cursor=0, count=None, busyloop=None, minlen=None, maxlen=None, importrate=None): """ Iterate all the existing queues in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a bu...
[ "def", "qscan", "(", "self", ",", "cursor", "=", "0", ",", "count", "=", "None", ",", "busyloop", "=", "None", ",", "minlen", "=", "None", ",", "maxlen", "=", "None", ",", "importrate", "=", "None", ")", ":", "command", "=", "[", "\"QSCAN\"", ",", ...
Iterate all the existing queues in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a busy loop. :param minlen: Don't return elements with less than count jobs queued. :param maxlen: Don't return element...
[ "Iterate", "all", "the", "existing", "queues", "in", "the", "local", "node", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L453-L477
train
ybrs/pydisque
pydisque/client.py
Client.jscan
def jscan(self, cursor=0, count=None, busyloop=None, queue=None, state=None, reply=None): """Iterate all the existing jobs in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a busy loop. :...
python
def jscan(self, cursor=0, count=None, busyloop=None, queue=None, state=None, reply=None): """Iterate all the existing jobs in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a busy loop. :...
[ "def", "jscan", "(", "self", ",", "cursor", "=", "0", ",", "count", "=", "None", ",", "busyloop", "=", "None", ",", "queue", "=", "None", ",", "state", "=", "None", ",", "reply", "=", "None", ")", ":", "command", "=", "[", "\"JSCAN\"", ",", "curs...
Iterate all the existing jobs in the local node. :param count: An hint about how much work to do per iteration. :param busyloop: Block and return all the elements in a busy loop. :param queue: Return only jobs in the specified queue. :param state: Must be a list - Return jobs in the spe...
[ "Iterate", "all", "the", "existing", "jobs", "in", "the", "local", "node", "." ]
ea5ce1576b66398c1cce32cad0f15709b1ea8df8
https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L479-L505
train
inveniosoftware/invenio-search
invenio_search/utils.py
build_index_name
def build_index_name(app, *parts): """Build an index name from parts. :param parts: Parts that should be combined to make an index name. """ base_index = os.path.splitext( '-'.join([part for part in parts if part]) )[0] return prefix_index(app=app, index=base_index)
python
def build_index_name(app, *parts): """Build an index name from parts. :param parts: Parts that should be combined to make an index name. """ base_index = os.path.splitext( '-'.join([part for part in parts if part]) )[0] return prefix_index(app=app, index=base_index)
[ "def", "build_index_name", "(", "app", ",", "*", "parts", ")", ":", "base_index", "=", "os", ".", "path", ".", "splitext", "(", "'-'", ".", "join", "(", "[", "part", "for", "part", "in", "parts", "if", "part", "]", ")", ")", "[", "0", "]", "retur...
Build an index name from parts. :param parts: Parts that should be combined to make an index name.
[ "Build", "an", "index", "name", "from", "parts", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/utils.py#L27-L36
train
inveniosoftware/invenio-search
invenio_search/utils.py
schema_to_index
def schema_to_index(schema, index_names=None): """Get index/doc_type given a schema URL. :param schema: The schema name :param index_names: A list of index name. :returns: A tuple containing (index, doc_type). """ parts = schema.split('/') doc_type = os.path.splitext(parts[-1]) if doc_...
python
def schema_to_index(schema, index_names=None): """Get index/doc_type given a schema URL. :param schema: The schema name :param index_names: A list of index name. :returns: A tuple containing (index, doc_type). """ parts = schema.split('/') doc_type = os.path.splitext(parts[-1]) if doc_...
[ "def", "schema_to_index", "(", "schema", ",", "index_names", "=", "None", ")", ":", "parts", "=", "schema", ".", "split", "(", "'/'", ")", "doc_type", "=", "os", ".", "path", ".", "splitext", "(", "parts", "[", "-", "1", "]", ")", "if", "doc_type", ...
Get index/doc_type given a schema URL. :param schema: The schema name :param index_names: A list of index name. :returns: A tuple containing (index, doc_type).
[ "Get", "index", "/", "doc_type", "given", "a", "schema", "URL", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/utils.py#L39-L60
train
inveniosoftware/invenio-search
invenio_search/cli.py
es_version_check
def es_version_check(f): """Decorator to check Elasticsearch version.""" @wraps(f) def inner(*args, **kwargs): cluster_ver = current_search.cluster_version[0] client_ver = ES_VERSION[0] if cluster_ver != client_ver: raise click.ClickException( 'Elasticsear...
python
def es_version_check(f): """Decorator to check Elasticsearch version.""" @wraps(f) def inner(*args, **kwargs): cluster_ver = current_search.cluster_version[0] client_ver = ES_VERSION[0] if cluster_ver != client_ver: raise click.ClickException( 'Elasticsear...
[ "def", "es_version_check", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cluster_ver", "=", "current_search", ".", "cluster_version", "[", "0", "]", "client_ver", "=", "ES_VERSION...
Decorator to check Elasticsearch version.
[ "Decorator", "to", "check", "Elasticsearch", "version", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L30-L45
train
inveniosoftware/invenio-search
invenio_search/cli.py
init
def init(force): """Initialize registered aliases and mappings.""" click.secho('Creating indexes...', fg='green', bold=True, file=sys.stderr) with click.progressbar( current_search.create(ignore=[400] if force else None), length=current_search.number_of_indexes) as bar: for n...
python
def init(force): """Initialize registered aliases and mappings.""" click.secho('Creating indexes...', fg='green', bold=True, file=sys.stderr) with click.progressbar( current_search.create(ignore=[400] if force else None), length=current_search.number_of_indexes) as bar: for n...
[ "def", "init", "(", "force", ")", ":", "click", ".", "secho", "(", "'Creating indexes...'", ",", "fg", "=", "'green'", ",", "bold", "=", "True", ",", "file", "=", "sys", ".", "stderr", ")", "with", "click", ".", "progressbar", "(", "current_search", "....
Initialize registered aliases and mappings.
[ "Initialize", "registered", "aliases", "and", "mappings", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L68-L81
train
inveniosoftware/invenio-search
invenio_search/cli.py
destroy
def destroy(force): """Destroy all indexes.""" click.secho('Destroying indexes...', fg='red', bold=True, file=sys.stderr) with click.progressbar( current_search.delete(ignore=[400, 404] if force else None), length=current_search.number_of_indexes) as bar: for name, response i...
python
def destroy(force): """Destroy all indexes.""" click.secho('Destroying indexes...', fg='red', bold=True, file=sys.stderr) with click.progressbar( current_search.delete(ignore=[400, 404] if force else None), length=current_search.number_of_indexes) as bar: for name, response i...
[ "def", "destroy", "(", "force", ")", ":", "click", ".", "secho", "(", "'Destroying indexes...'", ",", "fg", "=", "'red'", ",", "bold", "=", "True", ",", "file", "=", "sys", ".", "stderr", ")", "with", "click", ".", "progressbar", "(", "current_search", ...
Destroy all indexes.
[ "Destroy", "all", "indexes", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L91-L98
train
inveniosoftware/invenio-search
invenio_search/cli.py
create
def create(index_name, body, force, verbose): """Create a new index.""" result = current_search_client.indices.create( index=index_name, body=json.load(body), ignore=[400] if force else None, ) if verbose: click.echo(json.dumps(result))
python
def create(index_name, body, force, verbose): """Create a new index.""" result = current_search_client.indices.create( index=index_name, body=json.load(body), ignore=[400] if force else None, ) if verbose: click.echo(json.dumps(result))
[ "def", "create", "(", "index_name", ",", "body", ",", "force", ",", "verbose", ")", ":", "result", "=", "current_search_client", ".", "indices", ".", "create", "(", "index", "=", "index_name", ",", "body", "=", "json", ".", "load", "(", "body", ")", ",...
Create a new index.
[ "Create", "a", "new", "index", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L108-L116
train
inveniosoftware/invenio-search
invenio_search/cli.py
list_cmd
def list_cmd(only_active, only_aliases, verbose): """List indices.""" def _tree_print(d, rec_list=None, verbose=False, indent=2): # Note that on every recursion rec_list is copied, # which might not be very effective for very deep dictionaries. rec_list = rec_list or [] for idx, ...
python
def list_cmd(only_active, only_aliases, verbose): """List indices.""" def _tree_print(d, rec_list=None, verbose=False, indent=2): # Note that on every recursion rec_list is copied, # which might not be very effective for very deep dictionaries. rec_list = rec_list or [] for idx, ...
[ "def", "list_cmd", "(", "only_active", ",", "only_aliases", ",", "verbose", ")", ":", "def", "_tree_print", "(", "d", ",", "rec_list", "=", "None", ",", "verbose", "=", "False", ",", "indent", "=", "2", ")", ":", "# Note that on every recursion rec_list is cop...
List indices.
[ "List", "indices", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L124-L153
train
inveniosoftware/invenio-search
invenio_search/cli.py
delete
def delete(index_name, force, verbose): """Delete index by its name.""" result = current_search_client.indices.delete( index=index_name, ignore=[400, 404] if force else None, ) if verbose: click.echo(json.dumps(result))
python
def delete(index_name, force, verbose): """Delete index by its name.""" result = current_search_client.indices.delete( index=index_name, ignore=[400, 404] if force else None, ) if verbose: click.echo(json.dumps(result))
[ "def", "delete", "(", "index_name", ",", "force", ",", "verbose", ")", ":", "result", "=", "current_search_client", ".", "indices", ".", "delete", "(", "index", "=", "index_name", ",", "ignore", "=", "[", "400", ",", "404", "]", "if", "force", "else", ...
Delete index by its name.
[ "Delete", "index", "by", "its", "name", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L165-L172
train
inveniosoftware/invenio-search
invenio_search/cli.py
put
def put(index_name, doc_type, identifier, body, force, verbose): """Index input data.""" result = current_search_client.index( index=index_name, doc_type=doc_type or index_name, id=identifier, body=json.load(body), op_type='index' if force or identifier is None else 'crea...
python
def put(index_name, doc_type, identifier, body, force, verbose): """Index input data.""" result = current_search_client.index( index=index_name, doc_type=doc_type or index_name, id=identifier, body=json.load(body), op_type='index' if force or identifier is None else 'crea...
[ "def", "put", "(", "index_name", ",", "doc_type", ",", "identifier", ",", "body", ",", "force", ",", "verbose", ")", ":", "result", "=", "current_search_client", ".", "index", "(", "index", "=", "index_name", ",", "doc_type", "=", "doc_type", "or", "index_...
Index input data.
[ "Index", "input", "data", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L184-L194
train
inveniosoftware/invenio-search
invenio_search/api.py
RecordsSearch.get_records
def get_records(self, ids): """Return records by their identifiers. :param ids: A list of record identifier. :returns: A list of records. """ return self.query(Ids(values=[str(id_) for id_ in ids]))
python
def get_records(self, ids): """Return records by their identifiers. :param ids: A list of record identifier. :returns: A list of records. """ return self.query(Ids(values=[str(id_) for id_ in ids]))
[ "def", "get_records", "(", "self", ",", "ids", ")", ":", "return", "self", ".", "query", "(", "Ids", "(", "values", "=", "[", "str", "(", "id_", ")", "for", "id_", "in", "ids", "]", ")", ")" ]
Return records by their identifiers. :param ids: A list of record identifier. :returns: A list of records.
[ "Return", "records", "by", "their", "identifiers", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L120-L126
train
inveniosoftware/invenio-search
invenio_search/api.py
RecordsSearch.faceted_search
def faceted_search(cls, query=None, filters=None, search=None): """Return faceted search instance with defaults set. :param query: Elastic DSL query object (``Q``). :param filters: Dictionary with selected facet values. :param search: An instance of ``Search`` class. (default: ``cls()``...
python
def faceted_search(cls, query=None, filters=None, search=None): """Return faceted search instance with defaults set. :param query: Elastic DSL query object (``Q``). :param filters: Dictionary with selected facet values. :param search: An instance of ``Search`` class. (default: ``cls()``...
[ "def", "faceted_search", "(", "cls", ",", "query", "=", "None", ",", "filters", "=", "None", ",", "search", "=", "None", ")", ":", "search_", "=", "search", "or", "cls", "(", ")", "class", "RecordsFacetedSearch", "(", "FacetedSearch", ")", ":", "\"\"\"Pa...
Return faceted search instance with defaults set. :param query: Elastic DSL query object (``Q``). :param filters: Dictionary with selected facet values. :param search: An instance of ``Search`` class. (default: ``cls()``).
[ "Return", "faceted", "search", "instance", "with", "defaults", "set", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L129-L155
train
inveniosoftware/invenio-search
invenio_search/api.py
RecordsSearch.with_preference_param
def with_preference_param(self): """Add the preference param to the ES request and return a new Search. The preference param avoids the bouncing effect with multiple replicas, documented on ES documentation. See: https://www.elastic.co/guide/en/elasticsearch/guide/current /_sear...
python
def with_preference_param(self): """Add the preference param to the ES request and return a new Search. The preference param avoids the bouncing effect with multiple replicas, documented on ES documentation. See: https://www.elastic.co/guide/en/elasticsearch/guide/current /_sear...
[ "def", "with_preference_param", "(", "self", ")", ":", "user_hash", "=", "self", ".", "_get_user_hash", "(", ")", "if", "user_hash", ":", "return", "self", ".", "params", "(", "preference", "=", "user_hash", ")", "return", "self" ]
Add the preference param to the ES request and return a new Search. The preference param avoids the bouncing effect with multiple replicas, documented on ES documentation. See: https://www.elastic.co/guide/en/elasticsearch/guide/current /_search_options.html#_preference for more informa...
[ "Add", "the", "preference", "param", "to", "the", "ES", "request", "and", "return", "a", "new", "Search", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L157-L168
train
inveniosoftware/invenio-search
invenio_search/api.py
RecordsSearch._get_user_agent
def _get_user_agent(self): """Retrieve the request's User-Agent, if available. Taken from Flask Login utils.py. """ user_agent = request.headers.get('User-Agent') if user_agent: user_agent = user_agent.encode('utf-8') return user_agent or ''
python
def _get_user_agent(self): """Retrieve the request's User-Agent, if available. Taken from Flask Login utils.py. """ user_agent = request.headers.get('User-Agent') if user_agent: user_agent = user_agent.encode('utf-8') return user_agent or ''
[ "def", "_get_user_agent", "(", "self", ")", ":", "user_agent", "=", "request", ".", "headers", ".", "get", "(", "'User-Agent'", ")", "if", "user_agent", ":", "user_agent", "=", "user_agent", ".", "encode", "(", "'utf-8'", ")", "return", "user_agent", "or", ...
Retrieve the request's User-Agent, if available. Taken from Flask Login utils.py.
[ "Retrieve", "the", "request", "s", "User", "-", "Agent", "if", "available", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L170-L178
train
inveniosoftware/invenio-search
invenio_search/api.py
RecordsSearch._get_user_hash
def _get_user_hash(self): """Calculate a digest based on request's User-Agent and IP address.""" if request: user_hash = '{ip}-{ua}'.format(ip=request.remote_addr, ua=self._get_user_agent()) alg = hashlib.md5() alg.update(use...
python
def _get_user_hash(self): """Calculate a digest based on request's User-Agent and IP address.""" if request: user_hash = '{ip}-{ua}'.format(ip=request.remote_addr, ua=self._get_user_agent()) alg = hashlib.md5() alg.update(use...
[ "def", "_get_user_hash", "(", "self", ")", ":", "if", "request", ":", "user_hash", "=", "'{ip}-{ua}'", ".", "format", "(", "ip", "=", "request", ".", "remote_addr", ",", "ua", "=", "self", ".", "_get_user_agent", "(", ")", ")", "alg", "=", "hashlib", "...
Calculate a digest based on request's User-Agent and IP address.
[ "Calculate", "a", "digest", "based", "on", "request", "s", "User", "-", "Agent", "and", "IP", "address", "." ]
19c073d608d4c811f1c5aecb6622402d39715228
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L180-L188
train
chaoss/grimoirelab-sigils
src/migration/utils.py
beautify
def beautify(filename=None, json_str=None): """Beautify JSON string or file. Keyword arguments: :param filename: use its contents as json string instead of json_str param. :param json_str: json string to be beautified. """ if filename is not None: with open(filename) as json_file: ...
python
def beautify(filename=None, json_str=None): """Beautify JSON string or file. Keyword arguments: :param filename: use its contents as json string instead of json_str param. :param json_str: json string to be beautified. """ if filename is not None: with open(filename) as json_file: ...
[ "def", "beautify", "(", "filename", "=", "None", ",", "json_str", "=", "None", ")", ":", "if", "filename", "is", "not", "None", ":", "with", "open", "(", "filename", ")", "as", "json_file", ":", "json_str", "=", "json", ".", "load", "(", "json_file", ...
Beautify JSON string or file. Keyword arguments: :param filename: use its contents as json string instead of json_str param. :param json_str: json string to be beautified.
[ "Beautify", "JSON", "string", "or", "file", "." ]
33d395195acb316287143a535a2c6e4009bf0528
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/utils.py#L26-L38
train
chaoss/grimoirelab-sigils
src/migration/utils.py
replace
def replace(pretty, old_str, new_str): """ Replace strings giving some info on where the replacement was done """ out_str = '' line_number = 1 changes = 0 for line in pretty.splitlines(keepends=True): new_line = line.replace(old_str, new_str) if line.find(old_str) != -1: ...
python
def replace(pretty, old_str, new_str): """ Replace strings giving some info on where the replacement was done """ out_str = '' line_number = 1 changes = 0 for line in pretty.splitlines(keepends=True): new_line = line.replace(old_str, new_str) if line.find(old_str) != -1: ...
[ "def", "replace", "(", "pretty", ",", "old_str", ",", "new_str", ")", ":", "out_str", "=", "''", "line_number", "=", "1", "changes", "=", "0", "for", "line", "in", "pretty", ".", "splitlines", "(", "keepends", "=", "True", ")", ":", "new_line", "=", ...
Replace strings giving some info on where the replacement was done
[ "Replace", "strings", "giving", "some", "info", "on", "where", "the", "replacement", "was", "done" ]
33d395195acb316287143a535a2c6e4009bf0528
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/utils.py#L40-L58
train
praw-dev/prawcore
examples/obtain_refresh_token.py
receive_connection
def receive_connection(): """Wait for and then return a connected socket.. Opens a TCP connection on port 8080, and waits for a single client. """ server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.bind(("localhost", 8...
python
def receive_connection(): """Wait for and then return a connected socket.. Opens a TCP connection on port 8080, and waits for a single client. """ server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.bind(("localhost", 8...
[ "def", "receive_connection", "(", ")", ":", "server", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "server", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_REUSEADDR", ",...
Wait for and then return a connected socket.. Opens a TCP connection on port 8080, and waits for a single client.
[ "Wait", "for", "and", "then", "return", "a", "connected", "socket", ".." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L19-L31
train
praw-dev/prawcore
examples/obtain_refresh_token.py
send_message
def send_message(client, message): """Send message to client and close the connection.""" print(message) client.send("HTTP/1.1 200 OK\r\n\r\n{}".format(message).encode("utf-8")) client.close()
python
def send_message(client, message): """Send message to client and close the connection.""" print(message) client.send("HTTP/1.1 200 OK\r\n\r\n{}".format(message).encode("utf-8")) client.close()
[ "def", "send_message", "(", "client", ",", "message", ")", ":", "print", "(", "message", ")", "client", ".", "send", "(", "\"HTTP/1.1 200 OK\\r\\n\\r\\n{}\"", ".", "format", "(", "message", ")", ".", "encode", "(", "\"utf-8\"", ")", ")", "client", ".", "cl...
Send message to client and close the connection.
[ "Send", "message", "to", "client", "and", "close", "the", "connection", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L34-L38
train
praw-dev/prawcore
examples/obtain_refresh_token.py
main
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) < 2: print("Usage: {} SCOPE...".format(sys.argv[0])) return 1 authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_refresh_token_example"), os.environ["PRAWCOR...
python
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) < 2: print("Usage: {} SCOPE...".format(sys.argv[0])) return 1 authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_refresh_token_example"), os.environ["PRAWCOR...
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "<", "2", ":", "print", "(", "\"Usage: {} SCOPE...\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "return", "1", "authenticator", "=", "prawcore", ".", ...
Provide the program's entry point when directly executed.
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L41-L82
train
neo4j-drivers/neobolt
neobolt/diagnostics.py
watch
def watch(logger_name, level=DEBUG, out=stdout): """ Quick wrapper for using the Watcher. :param logger_name: name of logger to watch :param level: minimum log level to show (default INFO) :param out: where to send output (default stdout) :return: Watcher instance """ watcher = Watcher(logg...
python
def watch(logger_name, level=DEBUG, out=stdout): """ Quick wrapper for using the Watcher. :param logger_name: name of logger to watch :param level: minimum log level to show (default INFO) :param out: where to send output (default stdout) :return: Watcher instance """ watcher = Watcher(logg...
[ "def", "watch", "(", "logger_name", ",", "level", "=", "DEBUG", ",", "out", "=", "stdout", ")", ":", "watcher", "=", "Watcher", "(", "logger_name", ")", "watcher", ".", "watch", "(", "level", ",", "out", ")", "return", "watcher" ]
Quick wrapper for using the Watcher. :param logger_name: name of logger to watch :param level: minimum log level to show (default INFO) :param out: where to send output (default stdout) :return: Watcher instance
[ "Quick", "wrapper", "for", "using", "the", "Watcher", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/diagnostics.py#L80-L90
train
neo4j-drivers/neobolt
neobolt/meta.py
get_user_agent
def get_user_agent(): """ Obtain the default user agent string sent to the server after a successful handshake. """ from sys import platform, version_info template = "neobolt/{} Python/{}.{}.{}-{}-{} ({})" fields = (version,) + tuple(version_info) + (platform,) return template.format(*fields...
python
def get_user_agent(): """ Obtain the default user agent string sent to the server after a successful handshake. """ from sys import platform, version_info template = "neobolt/{} Python/{}.{}.{}-{}-{} ({})" fields = (version,) + tuple(version_info) + (platform,) return template.format(*fields...
[ "def", "get_user_agent", "(", ")", ":", "from", "sys", "import", "platform", ",", "version_info", "template", "=", "\"neobolt/{} Python/{}.{}.{}-{}-{} ({})\"", "fields", "=", "(", "version", ",", ")", "+", "tuple", "(", "version_info", ")", "+", "(", "platform",...
Obtain the default user agent string sent to the server after a successful handshake.
[ "Obtain", "the", "default", "user", "agent", "string", "sent", "to", "the", "server", "after", "a", "successful", "handshake", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/meta.py#L26-L33
train
neo4j-drivers/neobolt
neobolt/meta.py
import_best
def import_best(c_module, py_module): """ Import the best available module, with C preferred to pure Python. """ from importlib import import_module from os import getenv pure_python = getenv("PURE_PYTHON", "") if pure_python: return import_module(py_module) else: try: ...
python
def import_best(c_module, py_module): """ Import the best available module, with C preferred to pure Python. """ from importlib import import_module from os import getenv pure_python = getenv("PURE_PYTHON", "") if pure_python: return import_module(py_module) else: try: ...
[ "def", "import_best", "(", "c_module", ",", "py_module", ")", ":", "from", "importlib", "import", "import_module", "from", "os", "import", "getenv", "pure_python", "=", "getenv", "(", "\"PURE_PYTHON\"", ",", "\"\"", ")", "if", "pure_python", ":", "return", "im...
Import the best available module, with C preferred to pure Python.
[ "Import", "the", "best", "available", "module", "with", "C", "preferred", "to", "pure", "Python", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/meta.py#L58-L71
train
neo4j-drivers/neobolt
neobolt/types/__init__.py
PackStreamHydrator.hydrate
def hydrate(self, values): """ Convert PackStream values into native values. """ def hydrate_(obj): if isinstance(obj, Structure): try: f = self.hydration_functions[obj.tag] except KeyError: # If we don't recogn...
python
def hydrate(self, values): """ Convert PackStream values into native values. """ def hydrate_(obj): if isinstance(obj, Structure): try: f = self.hydration_functions[obj.tag] except KeyError: # If we don't recogn...
[ "def", "hydrate", "(", "self", ",", "values", ")", ":", "def", "hydrate_", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "Structure", ")", ":", "try", ":", "f", "=", "self", ".", "hydration_functions", "[", "obj", ".", "tag", "]", "exc...
Convert PackStream values into native values.
[ "Convert", "PackStream", "values", "into", "native", "values", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/types/__init__.py#L97-L117
train
praw-dev/prawcore
prawcore/auth.py
BaseAuthenticator.authorize_url
def authorize_url(self, duration, scopes, state, implicit=False): """Return the URL used out-of-band to grant access to your application. :param duration: Either ``permanent`` or ``temporary``. ``temporary`` authorizations generate access tokens that last only 1 hour. ``permanen...
python
def authorize_url(self, duration, scopes, state, implicit=False): """Return the URL used out-of-band to grant access to your application. :param duration: Either ``permanent`` or ``temporary``. ``temporary`` authorizations generate access tokens that last only 1 hour. ``permanen...
[ "def", "authorize_url", "(", "self", ",", "duration", ",", "scopes", ",", "state", ",", "implicit", "=", "False", ")", ":", "if", "self", ".", "redirect_uri", "is", "None", ":", "raise", "InvalidInvocation", "(", "\"redirect URI not provided\"", ")", "if", "...
Return the URL used out-of-band to grant access to your application. :param duration: Either ``permanent`` or ``temporary``. ``temporary`` authorizations generate access tokens that last only 1 hour. ``permanent`` authorizations additionally generate a refresh token that can...
[ "Return", "the", "URL", "used", "out", "-", "of", "-", "band", "to", "grant", "access", "to", "your", "application", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L35-L75
train
praw-dev/prawcore
prawcore/auth.py
BaseAuthenticator.revoke_token
def revoke_token(self, token, token_type=None): """Ask Reddit to revoke the provided token. :param token: The access or refresh token to revoke. :param token_type: (Optional) When provided, hint to Reddit what the token type is for a possible efficiency gain. The value can be ...
python
def revoke_token(self, token, token_type=None): """Ask Reddit to revoke the provided token. :param token: The access or refresh token to revoke. :param token_type: (Optional) When provided, hint to Reddit what the token type is for a possible efficiency gain. The value can be ...
[ "def", "revoke_token", "(", "self", ",", "token", ",", "token_type", "=", "None", ")", ":", "data", "=", "{", "\"token\"", ":", "token", "}", "if", "token_type", "is", "not", "None", ":", "data", "[", "\"token_type_hint\"", "]", "=", "token_type", "url",...
Ask Reddit to revoke the provided token. :param token: The access or refresh token to revoke. :param token_type: (Optional) When provided, hint to Reddit what the token type is for a possible efficiency gain. The value can be either ``access_token`` or ``refresh_token``.
[ "Ask", "Reddit", "to", "revoke", "the", "provided", "token", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L77-L90
train
praw-dev/prawcore
prawcore/auth.py
BaseAuthorizer.revoke
def revoke(self): """Revoke the current Authorization.""" if self.access_token is None: raise InvalidInvocation("no token available to revoke") self._authenticator.revoke_token(self.access_token, "access_token") self._clear_access_token()
python
def revoke(self): """Revoke the current Authorization.""" if self.access_token is None: raise InvalidInvocation("no token available to revoke") self._authenticator.revoke_token(self.access_token, "access_token") self._clear_access_token()
[ "def", "revoke", "(", "self", ")", ":", "if", "self", ".", "access_token", "is", "None", ":", "raise", "InvalidInvocation", "(", "\"no token available to revoke\"", ")", "self", ".", "_authenticator", ".", "revoke_token", "(", "self", ".", "access_token", ",", ...
Revoke the current Authorization.
[ "Revoke", "the", "current", "Authorization", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L184-L190
train
praw-dev/prawcore
prawcore/auth.py
Authorizer.authorize
def authorize(self, code): """Obtain and set authorization tokens based on ``code``. :param code: The code obtained by an out-of-band authorization request to Reddit. """ if self._authenticator.redirect_uri is None: raise InvalidInvocation("redirect URI not prov...
python
def authorize(self, code): """Obtain and set authorization tokens based on ``code``. :param code: The code obtained by an out-of-band authorization request to Reddit. """ if self._authenticator.redirect_uri is None: raise InvalidInvocation("redirect URI not prov...
[ "def", "authorize", "(", "self", ",", "code", ")", ":", "if", "self", ".", "_authenticator", ".", "redirect_uri", "is", "None", ":", "raise", "InvalidInvocation", "(", "\"redirect URI not provided\"", ")", "self", ".", "_request_token", "(", "code", "=", "code...
Obtain and set authorization tokens based on ``code``. :param code: The code obtained by an out-of-band authorization request to Reddit.
[ "Obtain", "and", "set", "authorization", "tokens", "based", "on", "code", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L210-L223
train
praw-dev/prawcore
prawcore/auth.py
Authorizer.refresh
def refresh(self): """Obtain a new access token from the refresh_token.""" if self.refresh_token is None: raise InvalidInvocation("refresh token not provided") self._request_token( grant_type="refresh_token", refresh_token=self.refresh_token )
python
def refresh(self): """Obtain a new access token from the refresh_token.""" if self.refresh_token is None: raise InvalidInvocation("refresh token not provided") self._request_token( grant_type="refresh_token", refresh_token=self.refresh_token )
[ "def", "refresh", "(", "self", ")", ":", "if", "self", ".", "refresh_token", "is", "None", ":", "raise", "InvalidInvocation", "(", "\"refresh token not provided\"", ")", "self", ".", "_request_token", "(", "grant_type", "=", "\"refresh_token\"", ",", "refresh_toke...
Obtain a new access token from the refresh_token.
[ "Obtain", "a", "new", "access", "token", "from", "the", "refresh_token", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L225-L231
train
praw-dev/prawcore
prawcore/auth.py
Authorizer.revoke
def revoke(self, only_access=False): """Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorizat...
python
def revoke(self, only_access=False): """Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorizat...
[ "def", "revoke", "(", "self", ",", "only_access", "=", "False", ")", ":", "if", "only_access", "or", "self", ".", "refresh_token", "is", "None", ":", "super", "(", "Authorizer", ",", "self", ")", ".", "revoke", "(", ")", "else", ":", "self", ".", "_a...
Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorization.
[ "Revoke", "the", "current", "Authorization", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L233-L250
train
praw-dev/prawcore
prawcore/auth.py
DeviceIDAuthorizer.refresh
def refresh(self): """Obtain a new access token.""" grant_type = "https://oauth.reddit.com/grants/installed_client" self._request_token(grant_type=grant_type, device_id=self._device_id)
python
def refresh(self): """Obtain a new access token.""" grant_type = "https://oauth.reddit.com/grants/installed_client" self._request_token(grant_type=grant_type, device_id=self._device_id)
[ "def", "refresh", "(", "self", ")", ":", "grant_type", "=", "\"https://oauth.reddit.com/grants/installed_client\"", "self", ".", "_request_token", "(", "grant_type", "=", "grant_type", ",", "device_id", "=", "self", ".", "_device_id", ")" ]
Obtain a new access token.
[ "Obtain", "a", "new", "access", "token", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L275-L278
train
praw-dev/prawcore
prawcore/auth.py
ScriptAuthorizer.refresh
def refresh(self): """Obtain a new personal-use script type access token.""" self._request_token( grant_type="password", username=self._username, password=self._password, )
python
def refresh(self): """Obtain a new personal-use script type access token.""" self._request_token( grant_type="password", username=self._username, password=self._password, )
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_request_token", "(", "grant_type", "=", "\"password\"", ",", "username", "=", "self", ".", "_username", ",", "password", "=", "self", ".", "_password", ",", ")" ]
Obtain a new personal-use script type access token.
[ "Obtain", "a", "new", "personal", "-", "use", "script", "type", "access", "token", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L347-L353
train
praw-dev/prawcore
prawcore/requestor.py
Requestor.request
def request(self, *args, **kwargs): """Issue the HTTP request capturing any errors that may occur.""" try: return self._http.request(*args, timeout=TIMEOUT, **kwargs) except Exception as exc: raise RequestException(exc, args, kwargs)
python
def request(self, *args, **kwargs): """Issue the HTTP request capturing any errors that may occur.""" try: return self._http.request(*args, timeout=TIMEOUT, **kwargs) except Exception as exc: raise RequestException(exc, args, kwargs)
[ "def", "request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_http", ".", "request", "(", "*", "args", ",", "timeout", "=", "TIMEOUT", ",", "*", "*", "kwargs", ")", "except", "Exception", ...
Issue the HTTP request capturing any errors that may occur.
[ "Issue", "the", "HTTP", "request", "capturing", "any", "errors", "that", "may", "occur", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/requestor.py#L50-L55
train
JDongian/python-jamo
jamo/jamo.py
_hangul_char_to_jamo
def _hangul_char_to_jamo(syllable): """Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back. """ if is_hangul_char(syllable): rem = ord(syllable) - _JAMO_OFFSET tail = rem % 28 vowel = 1 + ((rem - tail) % 588) // 28 lead =...
python
def _hangul_char_to_jamo(syllable): """Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back. """ if is_hangul_char(syllable): rem = ord(syllable) - _JAMO_OFFSET tail = rem % 28 vowel = 1 + ((rem - tail) % 588) // 28 lead =...
[ "def", "_hangul_char_to_jamo", "(", "syllable", ")", ":", "if", "is_hangul_char", "(", "syllable", ")", ":", "rem", "=", "ord", "(", "syllable", ")", "-", "_JAMO_OFFSET", "tail", "=", "rem", "%", "28", "vowel", "=", "1", "+", "(", "(", "rem", "-", "t...
Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back.
[ "Return", "a", "3", "-", "tuple", "of", "lead", "vowel", "and", "tail", "jamo", "characters", ".", "Note", ":", "Non", "-", "Hangul", "characters", "are", "echoed", "back", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L54-L71
train
JDongian/python-jamo
jamo/jamo.py
_jamo_to_hangul_char
def _jamo_to_hangul_char(lead, vowel, tail=0): """Return the Hangul character for the given jamo characters. """ lead = ord(lead) - _JAMO_LEAD_OFFSET vowel = ord(vowel) - _JAMO_VOWEL_OFFSET tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0 return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ...
python
def _jamo_to_hangul_char(lead, vowel, tail=0): """Return the Hangul character for the given jamo characters. """ lead = ord(lead) - _JAMO_LEAD_OFFSET vowel = ord(vowel) - _JAMO_VOWEL_OFFSET tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0 return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ...
[ "def", "_jamo_to_hangul_char", "(", "lead", ",", "vowel", ",", "tail", "=", "0", ")", ":", "lead", "=", "ord", "(", "lead", ")", "-", "_JAMO_LEAD_OFFSET", "vowel", "=", "ord", "(", "vowel", ")", "-", "_JAMO_VOWEL_OFFSET", "tail", "=", "ord", "(", "tail...
Return the Hangul character for the given jamo characters.
[ "Return", "the", "Hangul", "character", "for", "the", "given", "jamo", "characters", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L74-L80
train
JDongian/python-jamo
jamo/jamo.py
_get_unicode_name
def _get_unicode_name(char): """Fetch the unicode name for jamo characters. """ if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys(): raise InvalidJamoError("Not jamo or nameless jamo character", char) else: if is_hcj(char): return _HCJ_TO_NAME[char] ...
python
def _get_unicode_name(char): """Fetch the unicode name for jamo characters. """ if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys(): raise InvalidJamoError("Not jamo or nameless jamo character", char) else: if is_hcj(char): return _HCJ_TO_NAME[char] ...
[ "def", "_get_unicode_name", "(", "char", ")", ":", "if", "char", "not", "in", "_JAMO_TO_NAME", ".", "keys", "(", ")", "and", "char", "not", "in", "_HCJ_TO_NAME", ".", "keys", "(", ")", ":", "raise", "InvalidJamoError", "(", "\"Not jamo or nameless jamo charact...
Fetch the unicode name for jamo characters.
[ "Fetch", "the", "unicode", "name", "for", "jamo", "characters", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L93-L101
train
JDongian/python-jamo
jamo/jamo.py
is_jamo
def is_jamo(character): """Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid. """ code = ord(character) return 0x1100 <= code <= 0x11FF or\ 0xA960 <= code <= 0xA97C or\ 0xD7B0 ...
python
def is_jamo(character): """Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid. """ code = ord(character) return 0x1100 <= code <= 0x11FF or\ 0xA960 <= code <= 0xA97C or\ 0xD7B0 ...
[ "def", "is_jamo", "(", "character", ")", ":", "code", "=", "ord", "(", "character", ")", "return", "0x1100", "<=", "code", "<=", "0x11FF", "or", "0xA960", "<=", "code", "<=", "0xA97C", "or", "0xD7B0", "<=", "code", "<=", "0xD7C6", "or", "0xD7CB", "<=",...
Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid.
[ "Test", "if", "a", "single", "character", "is", "a", "jamo", "character", ".", "Valid", "jamo", "includes", "all", "modern", "and", "archaic", "jamo", "as", "well", "as", "all", "HCJ", ".", "Non", "-", "assigned", "code", "points", "are", "invalid", "." ...
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L104-L113
train
JDongian/python-jamo
jamo/jamo.py
is_jamo_modern
def is_jamo_modern(character): """Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicod...
python
def is_jamo_modern(character): """Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicod...
[ "def", "is_jamo_modern", "(", "character", ")", ":", "code", "=", "ord", "(", "character", ")", "return", "0x1100", "<=", "code", "<=", "0x1112", "or", "0x1161", "<=", "code", "<=", "0x1175", "or", "0x11A8", "<=", "code", "<=", "0x11C2", "or", "is_hcj_mo...
Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicode 7.0 spec.
[ "Test", "if", "a", "single", "character", "is", "a", "modern", "jamo", "character", ".", "Modern", "jamo", "includes", "all", "U", "+", "11xx", "jamo", "in", "addition", "to", "HCJ", "in", "modern", "usage", "as", "defined", "in", "Unicode", "7", ".", ...
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L116-L127
train
JDongian/python-jamo
jamo/jamo.py
is_jamo_compound
def is_jamo_compound(character): """Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong. """ if len(character) != 1: return False # Consider instead: # raise TypeError('is_jamo_compound() expected a single character') if is_jamo(...
python
def is_jamo_compound(character): """Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong. """ if len(character) != 1: return False # Consider instead: # raise TypeError('is_jamo_compound() expected a single character') if is_jamo(...
[ "def", "is_jamo_compound", "(", "character", ")", ":", "if", "len", "(", "character", ")", "!=", "1", ":", "return", "False", "# Consider instead:", "# raise TypeError('is_jamo_compound() expected a single character')", "if", "is_jamo", "(", "character", ")", ":", "re...
Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong.
[ "Test", "if", "a", "single", "character", "is", "a", "compound", "i", ".", "e", ".", "a", "consonant", "cluster", "double", "consonant", "or", "dipthong", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L155-L165
train
JDongian/python-jamo
jamo/jamo.py
get_jamo_class
def get_jamo_class(jamo): """Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class dire...
python
def get_jamo_class(jamo): """Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class dire...
[ "def", "get_jamo_class", "(", "jamo", ")", ":", "# TODO: Perhaps raise a separate error for U+3xxx jamo.", "if", "jamo", "in", "JAMO_LEADS", "or", "jamo", "==", "chr", "(", "0x115F", ")", ":", "return", "\"lead\"", "if", "jamo", "in", "JAMO_VOWELS", "or", "jamo", ...
Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class directly corresponds to the Unicode 7...
[ "Determine", "if", "a", "jamo", "character", "is", "a", "lead", "vowel", "or", "tail", ".", "Integers", "and", "U", "+", "11xx", "characters", "are", "valid", "arguments", ".", "HCJ", "consonants", "are", "not", "valid", "here", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L168-L188
train
JDongian/python-jamo
jamo/jamo.py
hcj_to_jamo
def hcj_to_jamo(hcj_char, position="vowel"): """Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError. """ if position == "lead": jamo_class = "CHOSEONG" eli...
python
def hcj_to_jamo(hcj_char, position="vowel"): """Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError. """ if position == "lead": jamo_class = "CHOSEONG" eli...
[ "def", "hcj_to_jamo", "(", "hcj_char", ",", "position", "=", "\"vowel\"", ")", ":", "if", "position", "==", "\"lead\"", ":", "jamo_class", "=", "\"CHOSEONG\"", "elif", "position", "==", "\"vowel\"", ":", "jamo_class", "=", "\"JUNGSEONG\"", "elif", "position", ...
Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError.
[ "Convert", "a", "HCJ", "character", "to", "a", "jamo", "character", ".", "Arguments", "may", "be", "single", "characters", "along", "with", "the", "desired", "jamo", "class", "(", "lead", "vowel", "tail", ")", ".", "Non", "-", "mappable", "input", "will", ...
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L216-L235
train
JDongian/python-jamo
jamo/jamo.py
hangul_to_jamo
def hangul_to_jamo(hangul_string): """Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of...
python
def hangul_to_jamo(hangul_string): """Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of...
[ "def", "hangul_to_jamo", "(", "hangul_string", ")", ":", "return", "(", "_", "for", "_", "in", "chain", ".", "from_iterable", "(", "_hangul_char_to_jamo", "(", "_", ")", "for", "_", "in", "hangul_string", ")", ")" ]
Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of h2j, the string version.
[ "Convert", "a", "string", "of", "Hangul", "to", "jamo", ".", "Arguments", "may", "be", "iterables", "of", "characters", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L245-L256
train
JDongian/python-jamo
jamo/jamo.py
jamo_to_hangul
def jamo_to_hangul(lead, vowel, tail=''): """Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h. """ # Internally, ...
python
def jamo_to_hangul(lead, vowel, tail=''): """Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h. """ # Internally, ...
[ "def", "jamo_to_hangul", "(", "lead", ",", "vowel", ",", "tail", "=", "''", ")", ":", "# Internally, we convert everything to a jamo char,", "# then pass it to _jamo_to_hangul_char", "lead", "=", "hcj_to_jamo", "(", "lead", ",", "\"lead\"", ")", "vowel", "=", "hcj_to_...
Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h.
[ "Return", "the", "Hangul", "character", "for", "the", "given", "jamo", "input", ".", "Integers", "corresponding", "to", "U", "+", "11xx", "jamo", "codepoints", "U", "+", "11xx", "jamo", "characters", "or", "HCJ", "are", "valid", "inputs", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L271-L295
train
JDongian/python-jamo
jamo/jamo.py
decompose_jamo
def decompose_jamo(compound): """Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError. """ if len(compound) != 1: raise TypeError("decompose_jamo() expects a single characte...
python
def decompose_jamo(compound): """Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError. """ if len(compound) != 1: raise TypeError("decompose_jamo() expects a single characte...
[ "def", "decompose_jamo", "(", "compound", ")", ":", "if", "len", "(", "compound", ")", "!=", "1", ":", "raise", "TypeError", "(", "\"decompose_jamo() expects a single character,\"", ",", "\"but received\"", ",", "type", "(", "compound", ")", ",", "\"length\"", "...
Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError.
[ "Return", "a", "tuple", "of", "jamo", "character", "constituents", "of", "a", "compound", ".", "Note", ":", "Non", "-", "compound", "characters", "are", "echoed", "back", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L310-L325
train
JDongian/python-jamo
jamo/jamo.py
compose_jamo
def compose_jamo(*parts): """Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string. """ # Internally, we convert everything to a jamo char, # then pass it to _...
python
def compose_jamo(*parts): """Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string. """ # Internally, we convert everything to a jamo char, # then pass it to _...
[ "def", "compose_jamo", "(", "*", "parts", ")", ":", "# Internally, we convert everything to a jamo char,", "# then pass it to _jamo_to_hangul_char", "# NOTE: Relies on hcj_to_jamo not strictly requiring \"position\" arg.", "for", "p", "in", "parts", ":", "if", "not", "(", "type",...
Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string.
[ "Return", "the", "compound", "jamo", "for", "the", "given", "jamo", "input", ".", "Integers", "corresponding", "to", "U", "+", "11xx", "jamo", "codepoints", "U", "+", "11xx", "jamo", "characters", "or", "HCJ", "are", "valid", "inputs", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L328-L350
train
JDongian/python-jamo
jamo/jamo.py
synth_hangul
def synth_hangul(string): """Convert jamo characters in a string into hcj as much as possible.""" raise NotImplementedError return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)])
python
def synth_hangul(string): """Convert jamo characters in a string into hcj as much as possible.""" raise NotImplementedError return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)])
[ "def", "synth_hangul", "(", "string", ")", ":", "raise", "NotImplementedError", "return", "''", ".", "join", "(", "[", "''", ".", "join", "(", "''", ".", "join", "(", "jamo_to_hcj", "(", "_", ")", ")", "for", "_", "in", "string", ")", "]", ")" ]
Convert jamo characters in a string into hcj as much as possible.
[ "Convert", "jamo", "characters", "in", "a", "string", "into", "hcj", "as", "much", "as", "possible", "." ]
d087a9f5f52f066fb933ad1da8e9915703374c9a
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L353-L356
train
praw-dev/prawcore
prawcore/util.py
authorization_error_class
def authorization_error_class(response): """Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error. """ message = response.headers.get("www-authenticate") if message: error = message.replace('"', "").rsplit("=", 1)[...
python
def authorization_error_class(response): """Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error. """ message = response.headers.get("www-authenticate") if message: error = message.replace('"', "").rsplit("=", 1)[...
[ "def", "authorization_error_class", "(", "response", ")", ":", "message", "=", "response", ".", "headers", ".", "get", "(", "\"www-authenticate\"", ")", "if", "message", ":", "error", "=", "message", ".", "replace", "(", "'\"'", ",", "\"\"", ")", ".", "rsp...
Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error.
[ "Return", "an", "exception", "instance", "that", "maps", "to", "the", "OAuth", "Error", "." ]
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/util.py#L12-L23
train
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
_last_bookmark
def _last_bookmark(b0, b1): """ Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string. """ n = [None, None] _, _, n[0] = b0.rpartition(":") _, _, n[1] = b1.rpartition(":") for i in range(2): try: n[i] =...
python
def _last_bookmark(b0, b1): """ Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string. """ n = [None, None] _, _, n[0] = b0.rpartition(":") _, _, n[1] = b1.rpartition(":") for i in range(2): try: n[i] =...
[ "def", "_last_bookmark", "(", "b0", ",", "b1", ")", ":", "n", "=", "[", "None", ",", "None", "]", "_", ",", "_", ",", "n", "[", "0", "]", "=", "b0", ".", "rpartition", "(", "\":\"", ")", "_", ",", "_", ",", "n", "[", "1", "]", "=", "b1", ...
Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string.
[ "Return", "the", "latest", "of", "two", "bookmarks", "by", "looking", "for", "the", "maximum", "integer", "value", "following", "the", "last", "colon", "in", "the", "bookmark", "string", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L705-L717
train
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
last_bookmark
def last_bookmark(bookmarks): """ The bookmark returned by the last :class:`.Transaction`. """ last = None for bookmark in bookmarks: if last is None: last = bookmark else: last = _last_bookmark(last, bookmark) return last
python
def last_bookmark(bookmarks): """ The bookmark returned by the last :class:`.Transaction`. """ last = None for bookmark in bookmarks: if last is None: last = bookmark else: last = _last_bookmark(last, bookmark) return last
[ "def", "last_bookmark", "(", "bookmarks", ")", ":", "last", "=", "None", "for", "bookmark", "in", "bookmarks", ":", "if", "last", "is", "None", ":", "last", "=", "bookmark", "else", ":", "last", "=", "_last_bookmark", "(", "last", ",", "bookmark", ")", ...
The bookmark returned by the last :class:`.Transaction`.
[ "The", "bookmark", "returned", "by", "the", "last", ":", "class", ":", ".", "Transaction", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L721-L730
train
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
connect
def connect(address, **config): """ Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed. """ ssl_context = make_ssl_context(**config) last_error = None # Establish a connection to the host and port specified # Catches refused connec...
python
def connect(address, **config): """ Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed. """ ssl_context = make_ssl_context(**config) last_error = None # Establish a connection to the host and port specified # Catches refused connec...
[ "def", "connect", "(", "address", ",", "*", "*", "config", ")", ":", "ssl_context", "=", "make_ssl_context", "(", "*", "*", "config", ")", "last_error", "=", "None", "# Establish a connection to the host and port specified", "# Catches refused connections see:", "# http...
Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed.
[ "Connect", "and", "perform", "a", "handshake", "and", "return", "a", "valid", "Connection", "object", "assuming", "a", "protocol", "version", "can", "be", "agreed", "." ]
724569d76e85777c4f5e30e8d0a18116bda4d8cd
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L858-L884
train