Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
BaseRichTextEditHandlerTestCase._clear_edit_handler_cache
(self)
These tests generate new EditHandlers with different settings. The cached edit handlers should be cleared before and after each test run to ensure that no changes leak through to other tests.
These tests generate new EditHandlers with different settings. The cached edit handlers should be cleared before and after each test run to ensure that no changes leak through to other tests.
def _clear_edit_handler_cache(self): """ These tests generate new EditHandlers with different settings. The cached edit handlers should be cleared before and after each test run to ensure that no changes leak through to other tests. """ from wagtail.tests.testapp.models i...
[ "def", "_clear_edit_handler_cache", "(", "self", ")", ":", "from", "wagtail", ".", "tests", ".", "testapp", ".", "models", "import", "DefaultRichBlockFieldPage", "rich_text_block", "=", "(", "DefaultRichBlockFieldPage", ".", "get_edit_handler", "(", ")", ".", "get_f...
[ 23, 4 ]
[ 38, 53 ]
python
en
['en', 'error', 'th']
False
AsyncApp.app_func
(self)
This will run both methods asynchronously and then block until they are finished
This will run both methods asynchronously and then block until they are finished
def app_func(self): '''This will run both methods asynchronously and then block until they are finished ''' self.other_task = asyncio.ensure_future(self.waste_time_freely()) async def run_wrapper(): # we don't actually need to set asyncio as the lib because it is ...
[ "def", "app_func", "(", "self", ")", ":", "self", ".", "other_task", "=", "asyncio", ".", "ensure_future", "(", "self", ".", "waste_time_freely", "(", ")", ")", "async", "def", "run_wrapper", "(", ")", ":", "# we don't actually need to set asyncio as the lib becau...
[ 45, 4 ]
[ 58, 61 ]
python
en
['en', 'en', 'en']
True
AsyncApp.waste_time_freely
(self)
This method is also run by the asyncio loop and periodically prints something.
This method is also run by the asyncio loop and periodically prints something.
async def waste_time_freely(self): '''This method is also run by the asyncio loop and periodically prints something. ''' try: i = 0 while True: if self.root is not None: status = self.root.ids.label.status pr...
[ "async", "def", "waste_time_freely", "(", "self", ")", ":", "try", ":", "i", "=", "0", "while", "True", ":", "if", "self", ".", "root", "is", "not", "None", ":", "status", "=", "self", ".", "root", ".", "ids", ".", "label", ".", "status", "print", ...
[ 60, 4 ]
[ 83, 38 ]
python
en
['en', 'en', 'en']
True
CoinStore.new_block
(self, block: FullBlock, tx_additions: List[Coin], tx_removals: List[bytes32])
Only called for blocks which are blocks (and thus have rewards and transactions)
Only called for blocks which are blocks (and thus have rewards and transactions)
async def new_block(self, block: FullBlock, tx_additions: List[Coin], tx_removals: List[bytes32]): """ Only called for blocks which are blocks (and thus have rewards and transactions) """ if block.is_transaction_block() is False: return None assert block.foliage_trans...
[ "async", "def", "new_block", "(", "self", ",", "block", ":", "FullBlock", ",", "tx_additions", ":", "List", "[", "Coin", "]", ",", "tx_removals", ":", "List", "[", "bytes32", "]", ")", ":", "if", "block", ".", "is_transaction_block", "(", ")", "is", "F...
[ 63, 4 ]
[ 104, 74 ]
python
en
['en', 'error', 'th']
False
CoinStore.rollback_to_block
(self, block_index: int)
Note that block_index can be negative, in which case everything is rolled back
Note that block_index can be negative, in which case everything is rolled back
async def rollback_to_block(self, block_index: int): """ Note that block_index can be negative, in which case everything is rolled back """ # Update memory cache delete_queue: bytes32 = [] for coin_name, coin_record in list(self.coin_record_cache.cache.items()): ...
[ "async", "def", "rollback_to_block", "(", "self", ",", "block_index", ":", "int", ")", ":", "# Update memory cache", "delete_queue", ":", "bytes32", "=", "[", "]", "for", "coin_name", ",", "coin_record", "in", "list", "(", "self", ".", "coin_record_cache", "."...
[ 194, 4 ]
[ 224, 24 ]
python
en
['en', 'error', 'th']
False
Paginator.validate_number
(self, number)
Validates the given 1-based page number.
Validates the given 1-based page number.
def validate_number(self, number): """ Validates the given 1-based page number. """ try: number = int(number) except (TypeError, ValueError): raise PageNotAnInteger(_('That page number is not an integer')) if number < 1: raise EmptyPage...
[ "def", "validate_number", "(", "self", ",", "number", ")", ":", "try", ":", "number", "=", "int", "(", "number", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "raise", "PageNotAnInteger", "(", "_", "(", "'That page number is not an integer'", ...
[ 35, 4 ]
[ 50, 21 ]
python
en
['en', 'error', 'th']
False
Paginator.page
(self, number)
Returns a Page object for the given 1-based page number.
Returns a Page object for the given 1-based page number.
def page(self, number): """ Returns a Page object for the given 1-based page number. """ number = self.validate_number(number) bottom = (number - 1) * self.per_page top = bottom + self.per_page if top + self.orphans >= self.count: top = self.count ...
[ "def", "page", "(", "self", ",", "number", ")", ":", "number", "=", "self", ".", "validate_number", "(", "number", ")", "bottom", "=", "(", "number", "-", "1", ")", "*", "self", ".", "per_page", "top", "=", "bottom", "+", "self", ".", "per_page", "...
[ 52, 4 ]
[ 61, 73 ]
python
en
['en', 'error', 'th']
False
Paginator._get_page
(self, *args, **kwargs)
Returns an instance of a single page. This hook can be used by subclasses to use an alternative to the standard :cls:`Page` object.
Returns an instance of a single page.
def _get_page(self, *args, **kwargs): """ Returns an instance of a single page. This hook can be used by subclasses to use an alternative to the standard :cls:`Page` object. """ return Page(*args, **kwargs)
[ "def", "_get_page", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Page", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 63, 4 ]
[ 70, 36 ]
python
en
['en', 'error', 'th']
False
Paginator.count
(self)
Returns the total number of objects, across all pages.
Returns the total number of objects, across all pages.
def count(self): """ Returns the total number of objects, across all pages. """ try: return self.object_list.count() except (AttributeError, TypeError): # AttributeError if object_list has no count() method. # TypeError if object_list.count() r...
[ "def", "count", "(", "self", ")", ":", "try", ":", "return", "self", ".", "object_list", ".", "count", "(", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "# AttributeError if object_list has no count() method.", "# TypeError if object_list.count() ...
[ 73, 4 ]
[ 83, 40 ]
python
en
['en', 'error', 'th']
False
Paginator.num_pages
(self)
Returns the total number of pages.
Returns the total number of pages.
def num_pages(self): """ Returns the total number of pages. """ if self.count == 0 and not self.allow_empty_first_page: return 0 hits = max(1, self.count - self.orphans) return int(ceil(hits / float(self.per_page)))
[ "def", "num_pages", "(", "self", ")", ":", "if", "self", ".", "count", "==", "0", "and", "not", "self", ".", "allow_empty_first_page", ":", "return", "0", "hits", "=", "max", "(", "1", ",", "self", ".", "count", "-", "self", ".", "orphans", ")", "r...
[ 86, 4 ]
[ 93, 53 ]
python
en
['en', 'error', 'th']
False
Paginator.page_range
(self)
Returns a 1-based range of pages for iterating through within a template for loop.
Returns a 1-based range of pages for iterating through within a template for loop.
def page_range(self): """ Returns a 1-based range of pages for iterating through within a template for loop. """ return six.moves.range(1, self.num_pages + 1)
[ "def", "page_range", "(", "self", ")", ":", "return", "six", ".", "moves", ".", "range", "(", "1", ",", "self", ".", "num_pages", "+", "1", ")" ]
[ 96, 4 ]
[ 101, 53 ]
python
en
['en', 'error', 'th']
False
Paginator._check_object_list_is_ordered
(self)
Warn if self.object_list is unordered (typically a QuerySet).
Warn if self.object_list is unordered (typically a QuerySet).
def _check_object_list_is_ordered(self): """ Warn if self.object_list is unordered (typically a QuerySet). """ if hasattr(self.object_list, 'ordered') and not self.object_list.ordered: warnings.warn( 'Pagination may yield inconsistent results with an unordered...
[ "def", "_check_object_list_is_ordered", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "object_list", ",", "'ordered'", ")", "and", "not", "self", ".", "object_list", ".", "ordered", ":", "warnings", ".", "warn", "(", "'Pagination may yield inconsiste...
[ 103, 4 ]
[ 112, 13 ]
python
en
['en', 'error', 'th']
False
Page.start_index
(self)
Returns the 1-based index of the first object on this page, relative to total objects in the paginator.
Returns the 1-based index of the first object on this page, relative to total objects in the paginator.
def start_index(self): """ Returns the 1-based index of the first object on this page, relative to total objects in the paginator. """ # Special case, return zero if no items. if self.paginator.count == 0: return 0 return (self.paginator.per_page * (se...
[ "def", "start_index", "(", "self", ")", ":", "# Special case, return zero if no items.", "if", "self", ".", "paginator", ".", "count", "==", "0", ":", "return", "0", "return", "(", "self", ".", "paginator", ".", "per_page", "*", "(", "self", ".", "number", ...
[ 155, 4 ]
[ 163, 64 ]
python
en
['en', 'error', 'th']
False
Page.end_index
(self)
Returns the 1-based index of the last object on this page, relative to total objects found (hits).
Returns the 1-based index of the last object on this page, relative to total objects found (hits).
def end_index(self): """ Returns the 1-based index of the last object on this page, relative to total objects found (hits). """ # Special case for the last page because there can be orphans. if self.number == self.paginator.num_pages: return self.paginator.cou...
[ "def", "end_index", "(", "self", ")", ":", "# Special case for the last page because there can be orphans.", "if", "self", ".", "number", "==", "self", ".", "paginator", ".", "num_pages", ":", "return", "self", ".", "paginator", ".", "count", "return", "self", "."...
[ 165, 4 ]
[ 173, 52 ]
python
en
['en', 'error', 'th']
False
CustomUserManager._create_user
(self, username, email, password, is_staff, is_superuser, is_active=True, **extra_fields)
Creates and saves a User with the given username, email and password.
Creates and saves a User with the given username, email and password.
def _create_user(self, username, email, password, is_staff, is_superuser, is_active=True, **extra_fields): """ Creates and saves a User with the given username, email and password. """ if not username: raise ValueError('The given username must be set') ...
[ "def", "_create_user", "(", "self", ",", "username", ",", "email", ",", "password", ",", "is_staff", ",", "is_superuser", ",", "is_active", "=", "True", ",", "*", "*", "extra_fields", ")", ":", "if", "not", "username", ":", "raise", "ValueError", "(", "'...
[ 13, 4 ]
[ 26, 19 ]
python
en
['en', 'error', 'th']
False
generate_training_data
(h5_file, batch_size=128, steps_per_epoch=25, random_frac=0.0625, test_split=0.1, validation_split=0.1, val_steps_per_epoch=5)
Creates a training generator, a validation generator, and a test set from a HDF5 file containing pos_signals, neg_signals and neg_internal_signals. Data is augmented by addition of random noise and random duplicat
Creates a training generator, a validation generator, and a test set from a HDF5 file containing pos_signals, neg_signals and neg_internal_signals. Data is augmented by addition of random noise and random duplicat
def generate_training_data(h5_file, batch_size=128, steps_per_epoch=25, random_frac=0.0625, test_split=0.1, validation_split=0.1, val_steps_per_epoch=5): ...
[ "def", "generate_training_data", "(", "h5_file", ",", "batch_size", "=", "128", ",", "steps_per_epoch", "=", "25", ",", "random_frac", "=", "0.0625", ",", "test_split", "=", "0.1", ",", "validation_split", "=", "0.1", ",", "val_steps_per_epoch", "=", "5", ")",...
[ 81, 0 ]
[ 126, 71 ]
python
en
['en', 'error', 'th']
False
Point.__init__
(self, x=None, y=None, z=None, srid=None)
The Point object may be initialized with either a tuple, or individual parameters. For Example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individual parameters
The Point object may be initialized with either a tuple, or individual parameters.
def __init__(self, x=None, y=None, z=None, srid=None): """ The Point object may be initialized with either a tuple, or individual parameters. For Example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individua...
[ "def", "__init__", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "z", "=", "None", ",", "srid", "=", "None", ")", ":", "if", "x", "is", "None", ":", "coords", "=", "[", "]", "elif", "isinstance", "(", "x", ",", "(", "tuple",...
[ 17, 4 ]
[ 44, 53 ]
python
en
['en', 'error', 'th']
False
Point._create_point
(cls, ndim, coords)
Create a coordinate sequence, set X, Y, [Z], and create point
Create a coordinate sequence, set X, Y, [Z], and create point
def _create_point(cls, ndim, coords): """ Create a coordinate sequence, set X, Y, [Z], and create point """ if not ndim: return capi.create_point(None) if ndim < 2 or ndim > 3: raise TypeError('Invalid point dimension: %s' % str(ndim)) cs = capi....
[ "def", "_create_point", "(", "cls", ",", "ndim", ",", "coords", ")", ":", "if", "not", "ndim", ":", "return", "capi", ".", "create_point", "(", "None", ")", "if", "ndim", "<", "2", "or", "ndim", ">", "3", ":", "raise", "TypeError", "(", "'Invalid poi...
[ 54, 4 ]
[ 71, 36 ]
python
en
['en', 'error', 'th']
False
Point.__iter__
(self)
Allows iteration over coordinates of this Point.
Allows iteration over coordinates of this Point.
def __iter__(self): "Allows iteration over coordinates of this Point." for i in range(len(self)): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "yield", "self", "[", "i", "]" ]
[ 86, 4 ]
[ 89, 25 ]
python
en
['en', 'en', 'en']
True
Point.__len__
(self)
Returns the number of dimensions for this Point (either 0, 2 or 3).
Returns the number of dimensions for this Point (either 0, 2 or 3).
def __len__(self): "Returns the number of dimensions for this Point (either 0, 2 or 3)." if self.empty: return 0 if self.hasz: return 3 else: return 2
[ "def", "__len__", "(", "self", ")", ":", "if", "self", ".", "empty", ":", "return", "0", "if", "self", ".", "hasz", ":", "return", "3", "else", ":", "return", "2" ]
[ 91, 4 ]
[ 98, 20 ]
python
en
['en', 'en', 'en']
True
Point.x
(self)
Returns the X component of the Point.
Returns the X component of the Point.
def x(self): "Returns the X component of the Point." return self._cs.getOrdinate(0, 0)
[ "def", "x", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "0", ",", "0", ")" ]
[ 111, 4 ]
[ 113, 41 ]
python
en
['en', 'en', 'en']
True
Point.x
(self, value)
Sets the X component of the Point.
Sets the X component of the Point.
def x(self, value): "Sets the X component of the Point." self._cs.setOrdinate(0, 0, value)
[ "def", "x", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "0", ",", "0", ",", "value", ")" ]
[ 116, 4 ]
[ 118, 41 ]
python
en
['en', 'en', 'en']
True
Point.y
(self)
Returns the Y component of the Point.
Returns the Y component of the Point.
def y(self): "Returns the Y component of the Point." return self._cs.getOrdinate(1, 0)
[ "def", "y", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "1", ",", "0", ")" ]
[ 121, 4 ]
[ 123, 41 ]
python
en
['en', 'en', 'en']
True
Point.y
(self, value)
Sets the Y component of the Point.
Sets the Y component of the Point.
def y(self, value): "Sets the Y component of the Point." self._cs.setOrdinate(1, 0, value)
[ "def", "y", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "1", ",", "0", ",", "value", ")" ]
[ 126, 4 ]
[ 128, 41 ]
python
en
['en', 'en', 'en']
True
Point.z
(self)
Returns the Z component of the Point.
Returns the Z component of the Point.
def z(self): "Returns the Z component of the Point." return self._cs.getOrdinate(2, 0) if self.hasz else None
[ "def", "z", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "2", ",", "0", ")", "if", "self", ".", "hasz", "else", "None" ]
[ 131, 4 ]
[ 133, 64 ]
python
en
['en', 'en', 'en']
True
Point.z
(self, value)
Sets the Z component of the Point.
Sets the Z component of the Point.
def z(self, value): "Sets the Z component of the Point." if not self.hasz: raise GEOSException('Cannot set Z on 2D Point.') self._cs.setOrdinate(2, 0, value)
[ "def", "z", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "hasz", ":", "raise", "GEOSException", "(", "'Cannot set Z on 2D Point.'", ")", "self", ".", "_cs", ".", "setOrdinate", "(", "2", ",", "0", ",", "value", ")" ]
[ 136, 4 ]
[ 140, 41 ]
python
en
['en', 'en', 'en']
True
Point.tuple
(self)
Returns a tuple of the point.
Returns a tuple of the point.
def tuple(self): "Returns a tuple of the point." return self._cs.tuple
[ "def", "tuple", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "tuple" ]
[ 186, 4 ]
[ 188, 29 ]
python
en
['en', 'en', 'en']
True
Point.tuple
(self, tup)
Sets the coordinates of the point with the given tuple.
Sets the coordinates of the point with the given tuple.
def tuple(self, tup): "Sets the coordinates of the point with the given tuple." self._cs[0] = tup
[ "def", "tuple", "(", "self", ",", "tup", ")", ":", "self", ".", "_cs", "[", "0", "]", "=", "tup" ]
[ 191, 4 ]
[ 193, 25 ]
python
en
['en', 'en', 'en']
True
LastState.just_infused_sub_epoch_summary
(self)
Returns true if state is an end of sub-slot, and that end of sub-slot infused a sub epoch summary
Returns true if state is an end of sub-slot, and that end of sub-slot infused a sub epoch summary
def just_infused_sub_epoch_summary(self) -> bool: """ Returns true if state is an end of sub-slot, and that end of sub-slot infused a sub epoch summary """ return self.state_type == StateType.END_OF_SUB_SLOT and self.infused_ses
[ "def", "just_infused_sub_epoch_summary", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "state_type", "==", "StateType", ".", "END_OF_SUB_SLOT", "and", "self", ".", "infused_ses" ]
[ 149, 4 ]
[ 153, 80 ]
python
en
['en', 'error', 'th']
False
URLRegistry.url_pattern
(self, pattern_str)
Converts some regex-friendly url pattern (Resources().resource string) to a compiled pattern.
Converts some regex-friendly url pattern (Resources().resource string) to a compiled pattern.
def url_pattern(self, pattern_str): """Converts some regex-friendly url pattern (Resources().resource string) to a compiled pattern. """ # should account for any relative endpoint w/ query parameters pattern = r'^' + pattern_str + r'(\?.*)*$' return re.compile(pattern)
[ "def", "url_pattern", "(", "self", ",", "pattern_str", ")", ":", "# should account for any relative endpoint w/ query parameters", "pattern", "=", "r'^'", "+", "pattern_str", "+", "r'(\\?.*)*$'", "return", "re", ".", "compile", "(", "pattern", ")" ]
[ 14, 4 ]
[ 20, 34 ]
python
en
['en', 'de', 'en']
True
URLRegistry.register
(self, *args)
Registers a single resource (generic python type or object) to either 1. a single url string (internally coverted via URLRegistry.url_pattern) and optional method or method iterable 2. a list or tuple of url string and optional method or method iterables for retrieval via get(). reg.reg...
Registers a single resource (generic python type or object) to either 1. a single url string (internally coverted via URLRegistry.url_pattern) and optional method or method iterable 2. a list or tuple of url string and optional method or method iterables for retrieval via get().
def register(self, *args): """Registers a single resource (generic python type or object) to either 1. a single url string (internally coverted via URLRegistry.url_pattern) and optional method or method iterable 2. a list or tuple of url string and optional method or method iterables for...
[ "def", "register", "(", "self", ",", "*", "args", ")", ":", "if", "not", "args", "or", "len", "(", "args", ")", "==", "1", ":", "raise", "TypeError", "(", "'register needs at least a url and Resource.'", ")", "elif", "len", "(", "args", ")", "not", "in",...
[ 38, 4 ]
[ 84, 62 ]
python
en
['en', 'en', 'en']
True
URLRegistry.setdefault
(self, *args)
Establishes a default return value for get() by optional method (iterable). reg.setdefault(ResourceOne) reg.get('/some/unregistered/path') -> ResourceOne reg.setdefault('method', ResourceTwo) reg.get('/some/registered/methodless/path/', 'method') -> ResourceTwo r...
Establishes a default return value for get() by optional method (iterable).
def setdefault(self, *args): """Establishes a default return value for get() by optional method (iterable). reg.setdefault(ResourceOne) reg.get('/some/unregistered/path') -> ResourceOne reg.setdefault('method', ResourceTwo) reg.get('/some/registered/methodless/path/', 'm...
[ "def", "setdefault", "(", "self", ",", "*", "args", ")", ":", "if", "not", "args", ":", "raise", "TypeError", "(", "'setdefault needs at least a Resource.'", ")", "if", "len", "(", "args", ")", "==", "1", ":", "# all methods", "self", ".", "default", "[", ...
[ 86, 4 ]
[ 115, 97 ]
python
en
['en', 'da', 'en']
True
URLRegistry.get
(self, url, method=not_provided)
Returns a single resource by previously registered path and optional method where 1. If a registration was methodless and a method is provided to get() the return value will be None or, if applicable, a registry default (see setdefault()). 2. If a registration included a method (excluding ...
Returns a single resource by previously registered path and optional method where 1. If a registration was methodless and a method is provided to get() the return value will be None or, if applicable, a registry default (see setdefault()). 2. If a registration included a method (excluding ...
def get(self, url, method=not_provided): """Returns a single resource by previously registered path and optional method where 1. If a registration was methodless and a method is provided to get() the return value will be None or, if applicable, a registry default (see setdefault()). ...
[ "def", "get", "(", "self", ",", "url", ",", "method", "=", "not_provided", ")", ":", "registered_type", "=", "None", "default_methods", "=", "list", "(", "self", ".", "default", ")", "# Make sure dot character evaluated last", "default_methods", ".", "sort", "("...
[ 117, 4 ]
[ 158, 30 ]
python
en
['en', 'en', 'en']
True
migrate_survey_passwords
(apps, schema_editor)
Take the output of the Job Template password list for all that have a survey enabled, and then save it into the job model.
Take the output of the Job Template password list for all that have a survey enabled, and then save it into the job model.
def migrate_survey_passwords(apps, schema_editor): """Take the output of the Job Template password list for all that have a survey enabled, and then save it into the job model. """ Job = apps.get_model('main', 'Job') for job in Job.objects.iterator(): if not job.job_template: con...
[ "def", "migrate_survey_passwords", "(", "apps", ",", "schema_editor", ")", ":", "Job", "=", "apps", ".", "get_model", "(", "'main'", ",", "'Job'", ")", "for", "job", "in", "Job", ".", "objects", ".", "iterator", "(", ")", ":", "if", "not", "job", ".", ...
[ 11, 0 ]
[ 26, 22 ]
python
en
['en', 'en', 'en']
True
chunks
(l, n)
Yield successive n-sized chunks from l.
Yield successive n-sized chunks from l.
def chunks(l, n): """Yield successive n-sized chunks from l.""" for i in range(0, len(l), n): yield l[i:i + n]
[ "def", "chunks", "(", "l", ",", "n", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "l", ")", ",", "n", ")", ":", "yield", "l", "[", "i", ":", "i", "+", "n", "]" ]
[ 644, 0 ]
[ 647, 20 ]
python
en
['en', 'en', 'en']
True
BlockStore.get_block_records_by_hash
(self, header_hashes: List[bytes32])
Returns a list of Block Records, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present
Returns a list of Block Records, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present
async def get_block_records_by_hash(self, header_hashes: List[bytes32]): """ Returns a list of Block Records, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present """ if len(header_hashes) == 0: return [] ...
[ "async", "def", "get_block_records_by_hash", "(", "self", ",", "header_hashes", ":", "List", "[", "bytes32", "]", ")", ":", "if", "len", "(", "header_hashes", ")", "==", "0", ":", "return", "[", "]", "header_hashes_db", "=", "tuple", "(", "[", "hh", ".",...
[ 170, 4 ]
[ 192, 18 ]
python
en
['en', 'error', 'th']
False
BlockStore.get_blocks_by_hash
(self, header_hashes: List[bytes32])
Returns a list of Full Blocks blocks, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present
Returns a list of Full Blocks blocks, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present
async def get_blocks_by_hash(self, header_hashes: List[bytes32]) -> List[FullBlock]: """ Returns a list of Full Blocks blocks, ordered by the same order in which header_hashes are passed in. Throws an exception if the blocks are not present """ if len(header_hashes) == 0: ...
[ "async", "def", "get_blocks_by_hash", "(", "self", ",", "header_hashes", ":", "List", "[", "bytes32", "]", ")", "->", "List", "[", "FullBlock", "]", ":", "if", "len", "(", "header_hashes", ")", "==", "0", ":", "return", "[", "]", "header_hashes_db", "=",...
[ 194, 4 ]
[ 221, 18 ]
python
en
['en', 'error', 'th']
False
BlockStore.get_block_records
( self, )
Returns a dictionary with all blocks, as well as the header hash of the peak, if present.
Returns a dictionary with all blocks, as well as the header hash of the peak, if present.
async def get_block_records( self, ) -> Tuple[Dict[bytes32, BlockRecord], Optional[bytes32]]: """ Returns a dictionary with all blocks, as well as the header hash of the peak, if present. """ cursor = await self.db.execute("SELECT * from block_records") rows =...
[ "async", "def", "get_block_records", "(", "self", ",", ")", "->", "Tuple", "[", "Dict", "[", "bytes32", ",", "BlockRecord", "]", ",", "Optional", "[", "bytes32", "]", "]", ":", "cursor", "=", "await", "self", ".", "db", ".", "execute", "(", "\"SELECT *...
[ 234, 4 ]
[ 252, 24 ]
python
en
['en', 'error', 'th']
False
BlockStore.get_block_records_in_range
( self, start: int, stop: int, )
Returns a dictionary with all blocks in range between start and stop if present.
Returns a dictionary with all blocks in range between start and stop if present.
async def get_block_records_in_range( self, start: int, stop: int, ) -> Dict[bytes32, BlockRecord]: """ Returns a dictionary with all blocks in range between start and stop if present. """ formatted_str = f"SELECT header_hash, block from block_records...
[ "async", "def", "get_block_records_in_range", "(", "self", ",", "start", ":", "int", ",", "stop", ":", "int", ",", ")", "->", "Dict", "[", "bytes32", ",", "BlockRecord", "]", ":", "formatted_str", "=", "f\"SELECT header_hash, block from block_records WHERE height >=...
[ 254, 4 ]
[ 274, 18 ]
python
en
['en', 'error', 'th']
False
BlockStore.get_block_records_close_to_peak
( self, blocks_n: int )
Returns a dictionary with all blocks that have height >= peak height - blocks_n, as well as the peak header hash.
Returns a dictionary with all blocks that have height >= peak height - blocks_n, as well as the peak header hash.
async def get_block_records_close_to_peak( self, blocks_n: int ) -> Tuple[Dict[bytes32, BlockRecord], Optional[bytes32]]: """ Returns a dictionary with all blocks that have height >= peak height - blocks_n, as well as the peak header hash. """ res = await self.db.exe...
[ "async", "def", "get_block_records_close_to_peak", "(", "self", ",", "blocks_n", ":", "int", ")", "->", "Tuple", "[", "Dict", "[", "bytes32", ",", "BlockRecord", "]", ",", "Optional", "[", "bytes32", "]", "]", ":", "res", "=", "await", "self", ".", "db",...
[ 276, 4 ]
[ 298, 46 ]
python
en
['en', 'error', 'th']
False
BlockStore.get_peak_height_dicts
(self)
Returns a dictionary with all blocks, as well as the header hash of the peak, if present.
Returns a dictionary with all blocks, as well as the header hash of the peak, if present.
async def get_peak_height_dicts(self) -> Tuple[Dict[uint32, bytes32], Dict[uint32, SubEpochSummary]]: """ Returns a dictionary with all blocks, as well as the header hash of the peak, if present. """ res = await self.db.execute("SELECT * from block_records WHERE is_peak = 1") ...
[ "async", "def", "get_peak_height_dicts", "(", "self", ")", "->", "Tuple", "[", "Dict", "[", "uint32", ",", "bytes32", "]", ",", "Dict", "[", "uint32", ",", "SubEpochSummary", "]", "]", ":", "res", "=", "await", "self", ".", "db", ".", "execute", "(", ...
[ 300, 4 ]
[ 339, 50 ]
python
en
['en', 'error', 'th']
False
clear_duplicate_counts
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
This is a preparatory migration for our Analytics tables. The backstory is that Django's unique_together indexes do not properly handle the subgroup=None corner case (allowing duplicate rows that have a subgroup of None), which meant that in race conditions, rather than updating an existing row for the...
This is a preparatory migration for our Analytics tables.
def clear_duplicate_counts(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """This is a preparatory migration for our Analytics tables. The backstory is that Django's unique_together indexes do not properly handle the subgroup=None corner case (allowing duplicate rows that have a subgrou...
[ "def", "clear_duplicate_counts", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "count_tables", "=", "dict", "(", "realm", "=", "apps", ".", "get_model", "(", "\"analytics\"", ",", "\"RealmCount\"", ")",...
[ 6, 0 ]
[ 53, 40 ]
python
en
['en', 'en', 'en']
True
short_sync_batch
(self, peer: ws.WSKaleConnection, start_height: uint32, target_height: uint32)
Tries to sync to a chain which is not too far in the future, by downloading batches of blocks. If the first block that we download is not connected to our chain, we return False and do an expensive long sync instead. Long sync is not preferred because it requires downloading and validating a we...
Tries to sync to a chain which is not too far in the future, by downloading batches of blocks. If the first block that we download is not connected to our chain, we return False and do an expensive long sync instead. Long sync is not preferred because it requires downloading and validating a we...
async def short_sync_batch(self, peer: ws.WSKaleConnection, start_height: uint32, target_height: uint32) -> bool: """ Tries to sync to a chain which is not too far in the future, by downloading batches of blocks. If the first block that we download is not connected to our chain, we return False ...
[ "async", "def", "short_sync_batch", "(", "self", ",", "peer", ":", "ws", ".", "WSKaleConnection", ",", "start_height", ":", "uint32", ",", "target_height", ":", "uint32", ")", "->", "bool", ":", "# Don't trigger multiple batch syncs to the same peer", "if", "(", "...
[ 205, 4 ]
[ 272, 19 ]
python
en
['en', 'error', 'th']
False
short_sync_backtrack
( self, peer: ws.WSKaleConnection, peak_height: uint32, target_height: uint32, target_unf_hash: bytes32 )
Performs a backtrack sync, where blocks are downloaded one at a time from newest to oldest. If we do not find the fork point 5 deeper than our peak, we return False and do a long sync instead. Args: peer: peer to sync from peak_height: height of our peak tar...
Performs a backtrack sync, where blocks are downloaded one at a time from newest to oldest. If we do not find the fork point 5 deeper than our peak, we return False and do a long sync instead.
async def short_sync_backtrack( self, peer: ws.WSKaleConnection, peak_height: uint32, target_height: uint32, target_unf_hash: bytes32 ): """ Performs a backtrack sync, where blocks are downloaded one at a time from newest to oldest. If we do not find the fork point 5 deeper than our ...
[ "async", "def", "short_sync_backtrack", "(", "self", ",", "peer", ":", "ws", ".", "WSKaleConnection", ",", "peak_height", ":", "uint32", ",", "target_height", ":", "uint32", ",", "target_unf_hash", ":", "bytes32", ")", ":", "try", ":", "if", "peer", ".", "...
[ 274, 4 ]
[ 324, 31 ]
python
en
['en', 'error', 'th']
False
new_peak
(self, request: full_node_protocol.NewPeak, peer: ws.WSKaleConnection)
We have received a notification of a new peak from a peer. This happens either when we have just connected, or when the peer has updated their peak. Args: request: information about the new peak peer: peer that sent the message
We have received a notification of a new peak from a peer. This happens either when we have just connected, or when the peer has updated their peak.
async def new_peak(self, request: full_node_protocol.NewPeak, peer: ws.WSKaleConnection): """ We have received a notification of a new peak from a peer. This happens either when we have just connected, or when the peer has updated their peak. Args: request: information about...
[ "async", "def", "new_peak", "(", "self", ",", "request", ":", "full_node_protocol", ".", "NewPeak", ",", "peer", ":", "ws", ".", "WSKaleConnection", ")", ":", "# Store this peak/peer combination in case we want to sync to it, and to keep track of peers", "self", ".", "syn...
[ 326, 4 ]
[ 390, 63 ]
python
en
['en', 'error', 'th']
False
send_peak_to_timelords
( self, peak_block: Optional[FullBlock] = None, peer: Optional[ws.WSKaleConnection] = None )
Sends current peak to timelords
Sends current peak to timelords
async def send_peak_to_timelords( self, peak_block: Optional[FullBlock] = None, peer: Optional[ws.WSKaleConnection] = None ): """ Sends current peak to timelords """ if peak_block is None: peak_block = await self.blockchain.get_full_peak() if peak_block is...
[ "async", "def", "send_peak_to_timelords", "(", "self", ",", "peak_block", ":", "Optional", "[", "FullBlock", "]", "=", "None", ",", "peer", ":", "Optional", "[", "ws", ".", "WSKaleConnection", "]", "=", "None", ")", ":", "if", "peak_block", "is", "None", ...
[ 392, 4 ]
[ 445, 76 ]
python
en
['en', 'error', 'th']
False
on_connect
(self, connection: ws.WSKaleConnection)
Whenever we connect to another node / wallet, send them our current heads. Also send heads to farmers and challenges to timelords.
Whenever we connect to another node / wallet, send them our current heads. Also send heads to farmers and challenges to timelords.
async def on_connect(self, connection: ws.WSKaleConnection): """ Whenever we connect to another node / wallet, send them our current heads. Also send heads to farmers and challenges to timelords. """ self._state_changed("add_connection") self._state_changed("sync_mode") ...
[ "async", "def", "on_connect", "(", "self", ",", "connection", ":", "ws", ".", "WSKaleConnection", ")", ":", "self", ".", "_state_changed", "(", "\"add_connection\"", ")", "self", ".", "_state_changed", "(", "\"sync_mode\"", ")", "if", "self", ".", "full_node_p...
[ 466, 4 ]
[ 516, 51 ]
python
en
['en', 'error', 'th']
False
_sync
(self)
Performs a full sync of the blockchain up to the peak. - Wait a few seconds for peers to send us their peaks - Select the heaviest peak, and request a weight proof from a peer with that peak - Validate the weight proof, and disconnect from the peer if invalid - F...
Performs a full sync of the blockchain up to the peak. - Wait a few seconds for peers to send us their peaks - Select the heaviest peak, and request a weight proof from a peer with that peak - Validate the weight proof, and disconnect from the peer if invalid - F...
async def _sync(self): """ Performs a full sync of the blockchain up to the peak. - Wait a few seconds for peers to send us their peaks - Select the heaviest peak, and request a weight proof from a peer with that peak - Validate the weight proof, and disconnect from t...
[ "async", "def", "_sync", "(", "self", ")", ":", "if", "self", ".", "weight_proof_handler", "is", "None", ":", "return", "None", "# Ensure we are only syncing once and not double calling this method", "if", "self", ".", "sync_store", ".", "get_sync_mode", "(", ")", "...
[ 548, 4 ]
[ 679, 37 ]
python
en
['en', 'error', 'th']
False
_finish_sync
(self)
Finalize sync by setting sync mode to False, clearing all sync information, and adding any final blocks that we have finalized recently.
Finalize sync by setting sync mode to False, clearing all sync information, and adding any final blocks that we have finalized recently.
async def _finish_sync(self): """ Finalize sync by setting sync mode to False, clearing all sync information, and adding any final blocks that we have finalized recently. """ self.log.info("long sync done") self.sync_store.set_long_sync(False) self.sync_store.set_...
[ "async", "def", "_finish_sync", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"long sync done\"", ")", "self", ".", "sync_store", ".", "set_long_sync", "(", "False", ")", "self", ".", "sync_store", ".", "set_sync_mode", "(", "False", ")", ...
[ 834, 4 ]
[ 856, 40 ]
python
en
['en', 'error', 'th']
False
peak_post_processing
( self, block: FullBlock, record: BlockRecord, fork_height: uint32, peer: Optional[ws.WSKaleConnection] )
Must be called under self.blockchain.lock. This updates the internal state of the full node with the latest peak information. It also notifies peers about the new peak.
Must be called under self.blockchain.lock. This updates the internal state of the full node with the latest peak information. It also notifies peers about the new peak.
async def peak_post_processing( self, block: FullBlock, record: BlockRecord, fork_height: uint32, peer: Optional[ws.WSKaleConnection] ): """ Must be called under self.blockchain.lock. This updates the internal state of the full node with the latest peak information. It also notifies ...
[ "async", "def", "peak_post_processing", "(", "self", ",", "block", ":", "FullBlock", ",", "record", ":", "BlockRecord", ",", "fork_height", ":", "uint32", ",", "peer", ":", "Optional", "[", "ws", ".", "WSKaleConnection", "]", ")", ":", "difficulty", "=", "...
[ 929, 4 ]
[ 1074, 39 ]
python
en
['en', 'error', 'th']
False
respond_block
( self, respond_block: full_node_protocol.RespondBlock, peer: Optional[ws.WSKaleConnection] = None, )
Receive a full block from a peer full node (or ourselves).
Receive a full block from a peer full node (or ourselves).
async def respond_block( self, respond_block: full_node_protocol.RespondBlock, peer: Optional[ws.WSKaleConnection] = None, ) -> Optional[Message]: """ Receive a full block from a peer full node (or ourselves). """ block: FullBlock = respond_block.block ...
[ "async", "def", "respond_block", "(", "self", ",", "respond_block", ":", "full_node_protocol", ".", "RespondBlock", ",", "peer", ":", "Optional", "[", "ws", ".", "WSKaleConnection", "]", "=", "None", ",", ")", "->", "Optional", "[", "Message", "]", ":", "b...
[ 1076, 4 ]
[ 1235, 19 ]
python
en
['en', 'error', 'th']
False
respond_unfinished_block
( self, respond_unfinished_block: full_node_protocol.RespondUnfinishedBlock, peer: Optional[ws.WSKaleConnection], farmed_block: bool = False, )
We have received an unfinished block, either created by us, or from another peer. We can validate it and if it's a good block, propagate it to other peers and timelords.
We have received an unfinished block, either created by us, or from another peer. We can validate it and if it's a good block, propagate it to other peers and timelords.
async def respond_unfinished_block( self, respond_unfinished_block: full_node_protocol.RespondUnfinishedBlock, peer: Optional[ws.WSKaleConnection], farmed_block: bool = False, ): """ We have received an unfinished block, either created by us, or from another peer. ...
[ "async", "def", "respond_unfinished_block", "(", "self", ",", "respond_unfinished_block", ":", "full_node_protocol", ".", "RespondUnfinishedBlock", ",", "peer", ":", "Optional", "[", "ws", ".", "WSKaleConnection", "]", ",", "farmed_block", ":", "bool", "=", "False",...
[ 1237, 4 ]
[ 1394, 47 ]
python
en
['en', 'error', 'th']
False
_can_accept_compact_proof
( self, vdf_info: VDFInfo, vdf_proof: VDFProof, height: uint32, header_hash: bytes32, field_vdf: CompressibleVDFField, )
- Checks if the provided proof is indeed compact. - Checks if proof verifies given the vdf_info from the start of sub-slot. - Checks if the provided vdf_info is correct, assuming it refers to the start of sub-slot. - Checks if the existing proof was non-compact. Ignore this proof if we ...
- Checks if the provided proof is indeed compact. - Checks if proof verifies given the vdf_info from the start of sub-slot. - Checks if the provided vdf_info is correct, assuming it refers to the start of sub-slot. - Checks if the existing proof was non-compact. Ignore this proof if we ...
async def _can_accept_compact_proof( self, vdf_info: VDFInfo, vdf_proof: VDFProof, height: uint32, header_hash: bytes32, field_vdf: CompressibleVDFField, ) -> bool: """ - Checks if the provided proof is indeed compact. - Checks if proof verifie...
[ "async", "def", "_can_accept_compact_proof", "(", "self", ",", "vdf_info", ":", "VDFInfo", ",", "vdf_proof", ":", "VDFProof", ",", "height", ":", "uint32", ",", "header_hash", ":", "bytes32", ",", "field_vdf", ":", "CompressibleVDFField", ",", ")", "->", "bool...
[ 1695, 4 ]
[ 1726, 27 ]
python
en
['en', 'error', 'th']
False
modeladmin_register
(modeladmin_class)
Method for registering ModelAdmin or ModelAdminGroup classes with Wagtail.
Method for registering ModelAdmin or ModelAdminGroup classes with Wagtail.
def modeladmin_register(modeladmin_class): """ Method for registering ModelAdmin or ModelAdminGroup classes with Wagtail. """ instance = modeladmin_class() instance.register_with_wagtail() return modeladmin_class
[ "def", "modeladmin_register", "(", "modeladmin_class", ")", ":", "instance", "=", "modeladmin_class", "(", ")", "instance", ".", "register_with_wagtail", "(", ")", "return", "modeladmin_class" ]
[ 678, 0 ]
[ 684, 27 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.__init__
(self, parent=None)
Don't allow initialisation unless self.model is set to a valid model
Don't allow initialisation unless self.model is set to a valid model
def __init__(self, parent=None): """ Don't allow initialisation unless self.model is set to a valid model """ if not self.model or not issubclass(self.model, Model): raise ImproperlyConfigured( u"The model attribute on your '%s' class must be set, and " ...
[ "def", "__init__", "(", "self", ",", "parent", "=", "None", ")", ":", "if", "not", "self", ".", "model", "or", "not", "issubclass", "(", "self", ".", "model", ",", "Model", ")", ":", "raise", "ImproperlyConfigured", "(", "u\"The model attribute on your '%s' ...
[ 113, 4 ]
[ 130, 51 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_permission_helper_class
(self)
Returns a permission_helper class to help with permission-based logic for the given model.
Returns a permission_helper class to help with permission-based logic for the given model.
def get_permission_helper_class(self): """ Returns a permission_helper class to help with permission-based logic for the given model. """ if self.permission_helper_class: return self.permission_helper_class if self.is_pagemodel: return PagePermissi...
[ "def", "get_permission_helper_class", "(", "self", ")", ":", "if", "self", ".", "permission_helper_class", ":", "return", "self", ".", "permission_helper_class", "if", "self", ".", "is_pagemodel", ":", "return", "PagePermissionHelper", "return", "PermissionHelper" ]
[ 132, 4 ]
[ 141, 31 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_button_helper_class
(self)
Returns a ButtonHelper class to help generate buttons for the given model.
Returns a ButtonHelper class to help generate buttons for the given model.
def get_button_helper_class(self): """ Returns a ButtonHelper class to help generate buttons for the given model. """ if self.button_helper_class: return self.button_helper_class if self.is_pagemodel: return PageButtonHelper return ButtonHe...
[ "def", "get_button_helper_class", "(", "self", ")", ":", "if", "self", ".", "button_helper_class", ":", "return", "self", ".", "button_helper_class", "if", "self", ".", "is_pagemodel", ":", "return", "PageButtonHelper", "return", "ButtonHelper" ]
[ 150, 4 ]
[ 159, 27 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_menu_label
(self)
Returns the label text to be used for the menu item.
Returns the label text to be used for the menu item.
def get_menu_label(self): """ Returns the label text to be used for the menu item. """ return self.menu_label or self.opts.verbose_name_plural.title()
[ "def", "get_menu_label", "(", "self", ")", ":", "return", "self", ".", "menu_label", "or", "self", ".", "opts", ".", "verbose_name_plural", ".", "title", "(", ")" ]
[ 161, 4 ]
[ 165, 71 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_menu_icon
(self)
Returns the icon to be used for the menu item. The value is prepended with 'icon-' to create the full icon class name. For design consistency, the same icon is also applied to the main heading for views called by this class.
Returns the icon to be used for the menu item. The value is prepended with 'icon-' to create the full icon class name. For design consistency, the same icon is also applied to the main heading for views called by this class.
def get_menu_icon(self): """ Returns the icon to be used for the menu item. The value is prepended with 'icon-' to create the full icon class name. For design consistency, the same icon is also applied to the main heading for views called by this class. """ if sel...
[ "def", "get_menu_icon", "(", "self", ")", ":", "if", "self", ".", "menu_icon", ":", "return", "self", ".", "menu_icon", "if", "self", ".", "is_pagemodel", ":", "return", "'doc-full-inverse'", "return", "'snippet'" ]
[ 167, 4 ]
[ 178, 24 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_menu_order
(self)
Returns the 'order' to be applied to the menu item. 000 being first place. Where ModelAdminGroup is used, the menu_order value should be applied to that, and any ModelAdmin classes added to 'items' attribute will be ordered automatically, based on their order in that sequence. ...
Returns the 'order' to be applied to the menu item. 000 being first place. Where ModelAdminGroup is used, the menu_order value should be applied to that, and any ModelAdmin classes added to 'items' attribute will be ordered automatically, based on their order in that sequence. ...
def get_menu_order(self): """ Returns the 'order' to be applied to the menu item. 000 being first place. Where ModelAdminGroup is used, the menu_order value should be applied to that, and any ModelAdmin classes added to 'items' attribute will be ordered automatically, based on th...
[ "def", "get_menu_order", "(", "self", ")", ":", "return", "self", ".", "menu_order", "or", "999" ]
[ 180, 4 ]
[ 188, 37 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_list_display
(self, request)
Return a sequence containing the fields/method output to be displayed in the list view.
Return a sequence containing the fields/method output to be displayed in the list view.
def get_list_display(self, request): """ Return a sequence containing the fields/method output to be displayed in the list view. """ return self.list_display
[ "def", "get_list_display", "(", "self", ",", "request", ")", ":", "return", "self", ".", "list_display" ]
[ 190, 4 ]
[ 195, 32 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_list_display_add_buttons
(self, request)
Return the name of the field/method from list_display where action buttons should be added. Defaults to the first item from get_list_display()
Return the name of the field/method from list_display where action buttons should be added. Defaults to the first item from get_list_display()
def get_list_display_add_buttons(self, request): """ Return the name of the field/method from list_display where action buttons should be added. Defaults to the first item from get_list_display() """ return self.list_display_add_buttons or self.get_list_display( ...
[ "def", "get_list_display_add_buttons", "(", "self", ",", "request", ")", ":", "return", "self", ".", "list_display_add_buttons", "or", "self", ".", "get_list_display", "(", "request", ")", "[", "0", "]" ]
[ 197, 4 ]
[ 204, 23 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_list_export
(self, request)
Return a sequence containing the fields/method output to be displayed in spreadsheet exports.
Return a sequence containing the fields/method output to be displayed in spreadsheet exports.
def get_list_export(self, request): """ Return a sequence containing the fields/method output to be displayed in spreadsheet exports. """ return self.list_export
[ "def", "get_list_export", "(", "self", ",", "request", ")", ":", "return", "self", ".", "list_export" ]
[ 206, 4 ]
[ 211, 31 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_empty_value_display
(self, field_name=None)
Return the empty_value_display value defined on ModelAdmin
Return the empty_value_display value defined on ModelAdmin
def get_empty_value_display(self, field_name=None): """ Return the empty_value_display value defined on ModelAdmin """ return mark_safe(self.empty_value_display)
[ "def", "get_empty_value_display", "(", "self", ",", "field_name", "=", "None", ")", ":", "return", "mark_safe", "(", "self", ".", "empty_value_display", ")" ]
[ 213, 4 ]
[ 217, 50 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_list_filter
(self, request)
Returns a sequence containing the fields to be displayed as filters in the right sidebar in the list view.
Returns a sequence containing the fields to be displayed as filters in the right sidebar in the list view.
def get_list_filter(self, request): """ Returns a sequence containing the fields to be displayed as filters in the right sidebar in the list view. """ return self.list_filter
[ "def", "get_list_filter", "(", "self", ",", "request", ")", ":", "return", "self", ".", "list_filter" ]
[ 219, 4 ]
[ 224, 31 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_ordering
(self, request)
Returns a sequence defining the default ordering for results in the list view.
Returns a sequence defining the default ordering for results in the list view.
def get_ordering(self, request): """ Returns a sequence defining the default ordering for results in the list view. """ return self.ordering or ()
[ "def", "get_ordering", "(", "self", ",", "request", ")", ":", "return", "self", ".", "ordering", "or", "(", ")" ]
[ 226, 4 ]
[ 231, 34 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_queryset
(self, request)
Returns a QuerySet of all model instances that can be edited by the admin site.
Returns a QuerySet of all model instances that can be edited by the admin site.
def get_queryset(self, request): """ Returns a QuerySet of all model instances that can be edited by the admin site. """ qs = self.model._default_manager.get_queryset() ordering = self.get_ordering(request) if ordering: qs = qs.order_by(*ordering) ...
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "self", ".", "model", ".", "_default_manager", ".", "get_queryset", "(", ")", "ordering", "=", "self", ".", "get_ordering", "(", "request", ")", "if", "ordering", ":", "qs", "=", ...
[ 233, 4 ]
[ 245, 17 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_search_fields
(self, request)
Returns a sequence defining which fields on a model should be searched when a search is initiated from the list view.
Returns a sequence defining which fields on a model should be searched when a search is initiated from the list view.
def get_search_fields(self, request): """ Returns a sequence defining which fields on a model should be searched when a search is initiated from the list view. """ return self.search_fields or ()
[ "def", "get_search_fields", "(", "self", ",", "request", ")", ":", "return", "self", ".", "search_fields", "or", "(", ")" ]
[ 247, 4 ]
[ 252, 39 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_search_handler
(self, request, search_fields=None)
Returns an instance of ``self.search_handler_class`` that can be used by ``IndexView``.
Returns an instance of ``self.search_handler_class`` that can be used by ``IndexView``.
def get_search_handler(self, request, search_fields=None): """ Returns an instance of ``self.search_handler_class`` that can be used by ``IndexView``. """ return self.search_handler_class( search_fields or self.get_search_fields(request) )
[ "def", "get_search_handler", "(", "self", ",", "request", ",", "search_fields", "=", "None", ")", ":", "return", "self", ".", "search_handler_class", "(", "search_fields", "or", "self", ".", "get_search_fields", "(", "request", ")", ")" ]
[ 254, 4 ]
[ 261, 9 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_extra_search_kwargs
(self, request, search_term)
Returns a dictionary of additional kwargs to be sent to ``SearchHandler.search_queryset()``.
Returns a dictionary of additional kwargs to be sent to ``SearchHandler.search_queryset()``.
def get_extra_search_kwargs(self, request, search_term): """ Returns a dictionary of additional kwargs to be sent to ``SearchHandler.search_queryset()``. """ return self.extra_search_kwargs
[ "def", "get_extra_search_kwargs", "(", "self", ",", "request", ",", "search_term", ")", ":", "return", "self", ".", "extra_search_kwargs" ]
[ 263, 4 ]
[ 268, 39 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_extra_attrs_for_row
(self, obj, context)
Return a dictionary of HTML attributes to be added to the `<tr>` element for the suppled `obj` when rendering the results table in `index_view`. `data-object-pk` is already added by default.
Return a dictionary of HTML attributes to be added to the `<tr>` element for the suppled `obj` when rendering the results table in `index_view`. `data-object-pk` is already added by default.
def get_extra_attrs_for_row(self, obj, context): """ Return a dictionary of HTML attributes to be added to the `<tr>` element for the suppled `obj` when rendering the results table in `index_view`. `data-object-pk` is already added by default. """ return {}
[ "def", "get_extra_attrs_for_row", "(", "self", ",", "obj", ",", "context", ")", ":", "return", "{", "}" ]
[ 270, 4 ]
[ 276, 17 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_extra_class_names_for_field_col
(self, obj, field_name)
Return a list of additional CSS class names to be added to the table cell's `class` attribute when rendering the output of `field_name` for `obj` in `index_view`. Must always return a list.
Return a list of additional CSS class names to be added to the table cell's `class` attribute when rendering the output of `field_name` for `obj` in `index_view`.
def get_extra_class_names_for_field_col(self, obj, field_name): """ Return a list of additional CSS class names to be added to the table cell's `class` attribute when rendering the output of `field_name` for `obj` in `index_view`. Must always return a list. """ r...
[ "def", "get_extra_class_names_for_field_col", "(", "self", ",", "obj", ",", "field_name", ")", ":", "return", "[", "]" ]
[ 278, 4 ]
[ 286, 17 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_extra_attrs_for_field_col
(self, obj, field_name)
Return a dictionary of additional HTML attributes to be added to a table cell when rendering the output of `field_name` for `obj` in `index_view`. Must always return a dictionary.
Return a dictionary of additional HTML attributes to be added to a table cell when rendering the output of `field_name` for `obj` in `index_view`.
def get_extra_attrs_for_field_col(self, obj, field_name): """ Return a dictionary of additional HTML attributes to be added to a table cell when rendering the output of `field_name` for `obj` in `index_view`. Must always return a dictionary. """ return {}
[ "def", "get_extra_attrs_for_field_col", "(", "self", ",", "obj", ",", "field_name", ")", ":", "return", "{", "}" ]
[ 288, 4 ]
[ 296, 17 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_prepopulated_fields
(self, request)
Returns a sequence specifying custom prepopulated fields slugs on Create/Edit pages.
Returns a sequence specifying custom prepopulated fields slugs on Create/Edit pages.
def get_prepopulated_fields(self, request): """ Returns a sequence specifying custom prepopulated fields slugs on Create/Edit pages. """ return self.prepopulated_fields or {}
[ "def", "get_prepopulated_fields", "(", "self", ",", "request", ")", ":", "return", "self", ".", "prepopulated_fields", "or", "{", "}" ]
[ 298, 4 ]
[ 302, 45 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_form_fields_exclude
(self, request)
Returns a list or tuple of fields names to be excluded from Create/Edit pages.
Returns a list or tuple of fields names to be excluded from Create/Edit pages.
def get_form_fields_exclude(self, request): """ Returns a list or tuple of fields names to be excluded from Create/Edit pages. """ return self.form_fields_exclude
[ "def", "get_form_fields_exclude", "(", "self", ",", "request", ")", ":", "return", "self", ".", "form_fields_exclude" ]
[ 304, 4 ]
[ 308, 39 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_inspect_view_fields
(self)
Return a list of field names, indicating the model fields that should be displayed in the 'inspect' view. Returns the value of the 'inspect_view_fields' attribute if populated, otherwise a sensible list of fields is generated automatically, with any field named in 'inspect_view_...
Return a list of field names, indicating the model fields that should be displayed in the 'inspect' view. Returns the value of the 'inspect_view_fields' attribute if populated, otherwise a sensible list of fields is generated automatically, with any field named in 'inspect_view_...
def get_inspect_view_fields(self): """ Return a list of field names, indicating the model fields that should be displayed in the 'inspect' view. Returns the value of the 'inspect_view_fields' attribute if populated, otherwise a sensible list of fields is generated automatically, ...
[ "def", "get_inspect_view_fields", "(", "self", ")", ":", "if", "not", "self", ".", "inspect_view_fields", ":", "found_fields", "=", "[", "]", "for", "f", "in", "self", ".", "model", ".", "_meta", ".", "get_fields", "(", ")", ":", "if", "f", ".", "name"...
[ 330, 4 ]
[ 348, 39 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.index_view
(self, request)
Instantiates a class-based view to provide listing functionality for the assigned model. The view class used can be overridden by changing the 'index_view_class' attribute.
Instantiates a class-based view to provide listing functionality for the assigned model. The view class used can be overridden by changing the 'index_view_class' attribute.
def index_view(self, request): """ Instantiates a class-based view to provide listing functionality for the assigned model. The view class used can be overridden by changing the 'index_view_class' attribute. """ kwargs = {'model_admin': self} view_class = self.ind...
[ "def", "index_view", "(", "self", ",", "request", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", "}", "view_class", "=", "self", ".", "index_view_class", "return", "view_class", ".", "as_view", "(", "*", "*", "kwargs", ")", "(", "request", "...
[ 350, 4 ]
[ 358, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.create_view
(self, request)
Instantiates a class-based view to provide 'creation' functionality for the assigned model, or redirect to Wagtail's create view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'create_view_class' attribute.
Instantiates a class-based view to provide 'creation' functionality for the assigned model, or redirect to Wagtail's create view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'create_view_class' attribute.
def create_view(self, request): """ Instantiates a class-based view to provide 'creation' functionality for the assigned model, or redirect to Wagtail's create view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'create_view_class' att...
[ "def", "create_view", "(", "self", ",", "request", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", "}", "view_class", "=", "self", ".", "create_view_class", "return", "view_class", ".", "as_view", "(", "*", "*", "kwargs", ")", "(", "request", ...
[ 360, 4 ]
[ 369, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.choose_parent_view
(self, request)
Instantiates a class-based view to allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view class used can be overridden by changing the 'choose_parent_view_...
Instantiates a class-based view to allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view class used can be overridden by changing the 'choose_parent_view_...
def choose_parent_view(self, request): """ Instantiates a class-based view to allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view class used can be overr...
[ "def", "choose_parent_view", "(", "self", ",", "request", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", "}", "view_class", "=", "self", ".", "choose_parent_view_class", "return", "view_class", ".", "as_view", "(", "*", "*", "kwargs", ")", "(", ...
[ 371, 4 ]
[ 381, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.inspect_view
(self, request, instance_pk)
Instantiates a class-based view to provide 'inspect' functionality for the assigned model. The view class used can be overridden by changing the 'inspect_view_class' attribute.
Instantiates a class-based view to provide 'inspect' functionality for the assigned model. The view class used can be overridden by changing the 'inspect_view_class' attribute.
def inspect_view(self, request, instance_pk): """ Instantiates a class-based view to provide 'inspect' functionality for the assigned model. The view class used can be overridden by changing the 'inspect_view_class' attribute. """ kwargs = {'model_admin': self, 'instance_...
[ "def", "inspect_view", "(", "self", ",", "request", ",", "instance_pk", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'instance_pk'", ":", "instance_pk", "}", "view_class", "=", "self", ".", "inspect_view_class", "return", "view_class", "."...
[ 383, 4 ]
[ 391, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.edit_view
(self, request, instance_pk)
Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class' attribute.
Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class' attribute.
def edit_view(self, request, instance_pk): """ Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class'...
[ "def", "edit_view", "(", "self", ",", "request", ",", "instance_pk", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'instance_pk'", ":", "instance_pk", "}", "view_class", "=", "self", ".", "edit_view_class", "return", "view_class", ".", "a...
[ 393, 4 ]
[ 402, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.delete_view
(self, request, instance_pk)
Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'delete_view_class' attribute. ...
Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'delete_view_class' attribute. ...
def delete_view(self, request, instance_pk): """ Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overridden by...
[ "def", "delete_view", "(", "self", ",", "request", ",", "instance_pk", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'instance_pk'", ":", "instance_pk", "}", "view_class", "=", "self", ".", "delete_view_class", "return", "view_class", ".", ...
[ 404, 4 ]
[ 414, 52 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_edit_handler
(self, instance, request)
Returns the appropriate edit_handler for this modeladmin class. edit_handlers can be defined either on the model itself or on the modeladmin (as property edit_handler or panels). Falls back to extracting panel / edit handler definitions from the model class.
Returns the appropriate edit_handler for this modeladmin class. edit_handlers can be defined either on the model itself or on the modeladmin (as property edit_handler or panels). Falls back to extracting panel / edit handler definitions from the model class.
def get_edit_handler(self, instance, request): """ Returns the appropriate edit_handler for this modeladmin class. edit_handlers can be defined either on the model itself or on the modeladmin (as property edit_handler or panels). Falls back to extracting panel / edit handler defi...
[ "def", "get_edit_handler", "(", "self", ",", "instance", ",", "request", ")", ":", "if", "hasattr", "(", "self", ",", "'edit_handler'", ")", ":", "edit_handler", "=", "self", ".", "edit_handler", "elif", "hasattr", "(", "self", ",", "'panels'", ")", ":", ...
[ 416, 4 ]
[ 437, 27 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_templates
(self, action='index')
Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class.
Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class.
def get_templates(self, action='index'): """ Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class. """ app_label = self.opts.app_label.lower() model_name = sel...
[ "def", "get_templates", "(", "self", ",", "action", "=", "'index'", ")", ":", "app_label", "=", "self", ".", "opts", ".", "app_label", ".", "lower", "(", ")", "model_name", "=", "self", ".", "opts", ".", "model_name", ".", "lower", "(", ")", "return", ...
[ 439, 4 ]
[ 451, 9 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_index_template
(self)
Returns a template to be used when rendering 'index_view'. If a template is specified by the 'index_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'index_view'. If a template is specified by the 'index_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_index_template(self): """ Returns a template to be used when rendering 'index_view'. If a template is specified by the 'index_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ return self.index_template_na...
[ "def", "get_index_template", "(", "self", ")", ":", "return", "self", ".", "index_template_name", "or", "self", ".", "get_templates", "(", "'index'", ")" ]
[ 453, 4 ]
[ 459, 70 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_choose_parent_template
(self)
Returns a template to be used when rendering 'choose_parent_view'. If a template is specified by the 'choose_parent_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'choose_parent_view'. If a template is specified by the 'choose_parent_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_choose_parent_template(self): """ Returns a template to be used when rendering 'choose_parent_view'. If a template is specified by the 'choose_parent_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ ...
[ "def", "get_choose_parent_template", "(", "self", ")", ":", "return", "self", ".", "choose_parent_template_name", "or", "self", ".", "get_templates", "(", "'choose_parent'", ")" ]
[ 461, 4 ]
[ 469, 28 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_inspect_template
(self)
Returns a template to be used when rendering 'inspect_view'. If a template is specified by the 'inspect_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'inspect_view'. If a template is specified by the 'inspect_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_inspect_template(self): """ Returns a template to be used when rendering 'inspect_view'. If a template is specified by the 'inspect_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ return self.ins...
[ "def", "get_inspect_template", "(", "self", ")", ":", "return", "self", ".", "inspect_template_name", "or", "self", ".", "get_templates", "(", "'inspect'", ")" ]
[ 471, 4 ]
[ 478, 74 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_create_template
(self)
Returns a template to be used when rendering 'create_view'. If a template is specified by the 'create_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'create_view'. If a template is specified by the 'create_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_create_template(self): """ Returns a template to be used when rendering 'create_view'. If a template is specified by the 'create_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ return self.create...
[ "def", "get_create_template", "(", "self", ")", ":", "return", "self", ".", "create_template_name", "or", "self", ".", "get_templates", "(", "'create'", ")" ]
[ 480, 4 ]
[ 487, 72 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_edit_template
(self)
Returns a template to be used when rendering 'edit_view'. If a template is specified by the 'edit_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'edit_view'. If a template is specified by the 'edit_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_edit_template(self): """ Returns a template to be used when rendering 'edit_view'. If a template is specified by the 'edit_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ return self.edit_template_name o...
[ "def", "get_edit_template", "(", "self", ")", ":", "return", "self", ".", "edit_template_name", "or", "self", ".", "get_templates", "(", "'edit'", ")" ]
[ 489, 4 ]
[ 495, 68 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_delete_template
(self)
Returns a template to be used when rendering 'delete_view'. If a template is specified by the 'delete_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
Returns a template to be used when rendering 'delete_view'. If a template is specified by the 'delete_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned.
def get_delete_template(self): """ Returns a template to be used when rendering 'delete_view'. If a template is specified by the 'delete_template_name' attribute, that will be used. Otherwise, a list of preferred template names are returned. """ return self.delete...
[ "def", "get_delete_template", "(", "self", ")", ":", "return", "self", ".", "delete_template_name", "or", "self", ".", "get_templates", "(", "'delete'", ")" ]
[ 497, 4 ]
[ 504, 72 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_menu_item
(self, order=None)
Utilised by Wagtail's 'register_menu_item' hook to create a menu item to access the listing view, or can be called by ModelAdminGroup to create a SubMenu
Utilised by Wagtail's 'register_menu_item' hook to create a menu item to access the listing view, or can be called by ModelAdminGroup to create a SubMenu
def get_menu_item(self, order=None): """ Utilised by Wagtail's 'register_menu_item' hook to create a menu item to access the listing view, or can be called by ModelAdminGroup to create a SubMenu """ return ModelAdminMenuItem(self, order or self.get_menu_order())
[ "def", "get_menu_item", "(", "self", ",", "order", "=", "None", ")", ":", "return", "ModelAdminMenuItem", "(", "self", ",", "order", "or", "self", ".", "get_menu_order", "(", ")", ")" ]
[ 506, 4 ]
[ 512, 71 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_permissions_for_registration
(self)
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet """ from wagta...
[ "def", "get_permissions_for_registration", "(", "self", ")", ":", "from", "wagtail", ".", "snippets", ".", "models", "import", "SNIPPET_MODELS", "if", "not", "self", ".", "is_pagemodel", "and", "self", ".", "model", "not", "in", "SNIPPET_MODELS", ":", "return", ...
[ 514, 4 ]
[ 523, 40 ]
python
en
['en', 'error', 'th']
False
ModelAdmin.get_admin_urls_for_registration
(self)
Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers.
Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers.
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers. """ urls = ( re_path( self.url_helper.get_action_url_pattern('index'), self.index_view...
[ "def", "get_admin_urls_for_registration", "(", "self", ")", ":", "urls", "=", "(", "re_path", "(", "self", ".", "url_helper", ".", "get_action_url_pattern", "(", "'index'", ")", ",", "self", ".", "index_view", ",", "name", "=", "self", ".", "url_helper", "."...
[ 525, 4 ]
[ 562, 19 ]
python
en
['en', 'error', 'th']
False
ModelAdminGroup.__init__
(self)
When initialising, instantiate the classes within 'items', and assign the instances to a 'modeladmin_instances' attribute for convenient access later
When initialising, instantiate the classes within 'items', and assign the instances to a 'modeladmin_instances' attribute for convenient access later
def __init__(self): """ When initialising, instantiate the classes within 'items', and assign the instances to a 'modeladmin_instances' attribute for convenient access later """ self.modeladmin_instances = [] for ModelAdminClass in self.items: self.mod...
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "modeladmin_instances", "=", "[", "]", "for", "ModelAdminClass", "in", "self", ".", "items", ":", "self", ".", "modeladmin_instances", ".", "append", "(", "ModelAdminClass", "(", "parent", "=", "self", ...
[ 592, 4 ]
[ 600, 74 ]
python
en
['en', 'error', 'th']
False
ModelAdminGroup.get_menu_item
(self)
Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances
Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances
def get_menu_item(self): """ Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances """ if self.modeladmin_instances: submenu = SubMenu(self.get_submenu_it...
[ "def", "get_menu_item", "(", "self", ")", ":", "if", "self", ".", "modeladmin_instances", ":", "submenu", "=", "SubMenu", "(", "self", ".", "get_submenu_items", "(", ")", ")", "return", "GroupMenuItem", "(", "self", ",", "self", ".", "get_menu_order", "(", ...
[ 616, 4 ]
[ 624, 70 ]
python
en
['en', 'error', 'th']
False
ModelAdminGroup.get_permissions_for_registration
(self)
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings.
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings.
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings. """ qs = Permission.objects.none() for instance in self.modeladmin_i...
[ "def", "get_permissions_for_registration", "(", "self", ")", ":", "qs", "=", "Permission", ".", "objects", ".", "none", "(", ")", "for", "instance", "in", "self", ".", "modeladmin_instances", ":", "qs", "=", "qs", "|", "instance", ".", "get_permissions_for_reg...
[ 634, 4 ]
[ 643, 17 ]
python
en
['en', 'error', 'th']
False
ModelAdminGroup.get_admin_urls_for_registration
(self)
Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances
Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances """ urls = tuple() for instance in self.modeladmin_instances: urls += instance.get_admin_urls_for_r...
[ "def", "get_admin_urls_for_registration", "(", "self", ")", ":", "urls", "=", "tuple", "(", ")", "for", "instance", "in", "self", ".", "modeladmin_instances", ":", "urls", "+=", "instance", ".", "get_admin_urls_for_registration", "(", ")", "return", "urls" ]
[ 645, 4 ]
[ 653, 19 ]
python
en
['en', 'error', 'th']
False
run
()
\ The ``gunicorn`` command line runner for launching Gunicorn with generic WSGI applications.
\ The ``gunicorn`` command line runner for launching Gunicorn with generic WSGI applications.
def run(): """\ The ``gunicorn`` command line runner for launching Gunicorn with generic WSGI applications. """ from gunicorn.app.wsgiapp import WSGIApplication WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
[ "def", "run", "(", ")", ":", "from", "gunicorn", ".", "app", ".", "wsgiapp", "import", "WSGIApplication", "WSGIApplication", "(", "\"%(prog)s [OPTIONS] [APP_MODULE]\"", ")", ".", "run", "(", ")" ]
[ 51, 0 ]
[ 57, 60 ]
python
en
['en', 'ja', 'hi']
False
ProjectOptions.resolve_execution_environment
(self)
Project updates, themselves, will use the control plane execution environment. Jobs using the project can use the default_environment, but the project updates are not flexible enough to allow customizing the image they use.
Project updates, themselves, will use the control plane execution environment. Jobs using the project can use the default_environment, but the project updates are not flexible enough to allow customizing the image they use.
def resolve_execution_environment(self): """ Project updates, themselves, will use the control plane execution environment. Jobs using the project can use the default_environment, but the project updates are not flexible enough to allow customizing the image they use. """ ...
[ "def", "resolve_execution_environment", "(", "self", ")", ":", "return", "get_control_plane_execution_environment", "(", ")" ]
[ 185, 4 ]
[ 191, 56 ]
python
en
['en', 'error', 'th']
False
ProjectOptions.get_lock_file
(self)
We want the project path in name only, we don't care if it exists or not. This method will just append .lock onto the full directory path.
We want the project path in name only, we don't care if it exists or not. This method will just append .lock onto the full directory path.
def get_lock_file(self): """ We want the project path in name only, we don't care if it exists or not. This method will just append .lock onto the full directory path. """ proj_path = self.get_project_path(check_if_exists=False) if not proj_path: return None ...
[ "def", "get_lock_file", "(", "self", ")", ":", "proj_path", "=", "self", ".", "get_project_path", "(", "check_if_exists", "=", "False", ")", "if", "not", "proj_path", ":", "return", "None", "return", "proj_path", "+", "'.lock'" ]
[ 239, 4 ]
[ 247, 34 ]
python
en
['en', 'error', 'th']
False