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
RequirementCommand.trace_basic_info
(finder)
Trace basic information about the provided objects.
Trace basic information about the provided objects.
def trace_basic_info(finder): # type: (PackageFinder) -> None """ Trace basic information about the provided objects. """ # Display where finder is looking for packages search_scope = finder.search_scope locations = search_scope.get_formatted_locations() i...
[ "def", "trace_basic_info", "(", "finder", ")", ":", "# type: (PackageFinder) -> None", "# Display where finder is looking for packages", "search_scope", "=", "finder", ".", "search_scope", "locations", "=", "search_scope", ".", "get_formatted_locations", "(", ")", "if", "lo...
[ 369, 4 ]
[ 378, 34 ]
python
en
['en', 'error', 'th']
False
RequirementCommand._build_package_finder
( self, options, # type: Values session, # type: PipSession target_python=None, # type: Optional[TargetPython] ignore_requires_python=None, # type: Optional[bool] )
Create a package finder appropriate to this requirement command. :param ignore_requires_python: Whether to ignore incompatible "Requires-Python" values in links. Defaults to False.
Create a package finder appropriate to this requirement command.
def _build_package_finder( self, options, # type: Values session, # type: PipSession target_python=None, # type: Optional[TargetPython] ignore_requires_python=None, # type: Optional[bool] ): # type: (...) -> PackageFinder """ ...
[ "def", "_build_package_finder", "(", "self", ",", "options", ",", "# type: Values", "session", ",", "# type: PipSession", "target_python", "=", "None", ",", "# type: Optional[TargetPython]", "ignore_requires_python", "=", "None", ",", "# type: Optional[bool]", ")", ":", ...
[ 380, 4 ]
[ 407, 9 ]
python
en
['en', 'error', 'th']
False
bagnet33
(pretrained=False, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-33 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-33 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet33(pretrained=False, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-33 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet( Bottleneck, [ 3, 4, 6, 3], strides=strides, kernel3=[ 1, 1, 1, 1], **kwar...
[ "def", "bagnet33", "(", "pretrained", "=", "False", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "Bottleneck", ",", "[", "3", ",", "4", ",", "6", ",", "3", ...
[ 210, 0 ]
[ 221, 16 ]
python
en
['en', 'en', 'en']
True
bagnet17
(pretrained=False, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-17 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-17 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet17(pretrained=False, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-17 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet( Bottleneck, [ 3, 4, 6, 3], strides=strides, kernel3=[ 1, 1, 1, 0], **kwar...
[ "def", "bagnet17", "(", "pretrained", "=", "False", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "Bottleneck", ",", "[", "3", ",", "4", ",", "6", ",", "3", ...
[ 224, 0 ]
[ 235, 16 ]
python
en
['en', 'en', 'en']
True
bagnet9
(pretrained=False, strides=[2, 2, 2, 1], **kwargs)
Constructs a Bagnet-9 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
Constructs a Bagnet-9 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
def bagnet9(pretrained=False, strides=[2, 2, 2, 1], **kwargs): """Constructs a Bagnet-9 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = BagNet( Bottleneck, [ 3, 4, 6, 3], strides=strides, kernel3=[ 1, 1, 0, 0], **kwargs...
[ "def", "bagnet9", "(", "pretrained", "=", "False", ",", "strides", "=", "[", "2", ",", "2", ",", "2", ",", "1", "]", ",", "*", "*", "kwargs", ")", ":", "model", "=", "BagNet", "(", "Bottleneck", ",", "[", "3", ",", "4", ",", "6", ",", "3", ...
[ 238, 0 ]
[ 249, 16 ]
python
en
['en', 'en', 'en']
True
mnist_tutorial
( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, train_dir=TRAIN_DIR, filename=FILENAME, load_model=LOAD_MODEL, testing=False, label_smoothing=0.1, )
MNIST CleverHans tutorial :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :param nb_epochs: number of epochs to train model :param ...
MNIST CleverHans tutorial :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :param nb_epochs: number of epochs to train model :param ...
def mnist_tutorial( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, train_dir=TRAIN_DIR, filename=FILENAME, load_model=LOAD_MODEL, testing=False, label_smoothing=0.1, ): """ MNI...
[ "def", "mnist_tutorial", "(", "train_start", "=", "0", ",", "train_end", "=", "60000", ",", "test_start", "=", "0", ",", "test_end", "=", "10000", ",", "nb_epochs", "=", "NB_EPOCHS", ",", "batch_size", "=", "BATCH_SIZE", ",", "learning_rate", "=", "LEARNING_...
[ 40, 0 ]
[ 227, 17 ]
python
en
['en', 'error', 'th']
False
DateField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1140, 4 ]
[ 1181, 17 ]
python
en
['en', 'error', 'th']
False
DateTimeField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1287, 4 ]
[ 1331, 17 ]
python
en
['en', 'error', 'th']
False
DecimalField.format_number
(self, value)
Formats a number into a string with the requisite number of digits and decimal places.
Formats a number into a string with the requisite number of digits and decimal places.
def format_number(self, value): """ Formats a number into a string with the requisite number of digits and decimal places. """ # Method moved to django.db.backends.utils. # # It is preserved because it is used by the oracle backend # (django.db.backends.or...
[ "def", "format_number", "(", "self", ",", "value", ")", ":", "# Method moved to django.db.backends.utils.", "#", "# It is preserved because it is used by the oracle backend", "# (django.db.backends.oracle.query), and also for", "# backwards-compatibility with any external code which may have...
[ 1544, 4 ]
[ 1556, 79 ]
python
en
['en', 'error', 'th']
False
TimeField._check_fix_default_value
(self)
Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905
Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up.
def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 2040, 4 ]
[ 2084, 17 ]
python
en
['en', 'error', 'th']
False
BinaryField.value_to_string
(self, obj)
Binary data is serialized as base64
Binary data is serialized as base64
def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(force_bytes(self._get_val_from_obj(obj))).decode('ascii')
[ "def", "value_to_string", "(", "self", ",", "obj", ")", ":", "return", "b64encode", "(", "force_bytes", "(", "self", ".", "_get_val_from_obj", "(", "obj", ")", ")", ")", ".", "decode", "(", "'ascii'", ")" ]
[ 2212, 4 ]
[ 2214, 82 ]
python
en
['en', 'en', 'en']
True
AdminSite.check
(self, app_configs)
Run the system checks on all ModelAdmins, except if they aren't customized at all.
Run the system checks on all ModelAdmins, except if they aren't customized at all.
def check(self, app_configs): """ Run the system checks on all ModelAdmins, except if they aren't customized at all. """ if app_configs is None: app_configs = apps.get_app_configs() app_configs = set(app_configs) # Speed up lookups below errors = [] ...
[ "def", "check", "(", "self", ",", "app_configs", ")", ":", "if", "app_configs", "is", "None", ":", "app_configs", "=", "apps", ".", "get_app_configs", "(", ")", "app_configs", "=", "set", "(", "app_configs", ")", "# Speed up lookups below", "errors", "=", "[...
[ 69, 4 ]
[ 83, 21 ]
python
en
['en', 'error', 'th']
False
AdminSite.register
(self, model_or_iterable, admin_class=None, **options)
Register the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, use ModelAdmin (the default admin options). If keyword arguments are given -- e.g., list_display -- apply them as options to the admin cl...
Register the given model(s) with the given admin class.
def register(self, model_or_iterable, admin_class=None, **options): """ Register the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, use ModelAdmin (the default admin options). If keyword arguments a...
[ "def", "register", "(", "self", ",", "model_or_iterable", ",", "admin_class", "=", "None", ",", "*", "*", "options", ")", ":", "admin_class", "=", "admin_class", "or", "ModelAdmin", "if", "isinstance", "(", "model_or_iterable", ",", "ModelBase", ")", ":", "m...
[ 85, 4 ]
[ 131, 64 ]
python
en
['en', 'error', 'th']
False
AdminSite.unregister
(self, model_or_iterable)
Unregister the given model(s). If a model isn't already registered, raise NotRegistered.
Unregister the given model(s).
def unregister(self, model_or_iterable): """ Unregister the given model(s). If a model isn't already registered, raise NotRegistered. """ if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] for model in model_or_iterable: ...
[ "def", "unregister", "(", "self", ",", "model_or_iterable", ")", ":", "if", "isinstance", "(", "model_or_iterable", ",", "ModelBase", ")", ":", "model_or_iterable", "=", "[", "model_or_iterable", "]", "for", "model", "in", "model_or_iterable", ":", "if", "model"...
[ 133, 4 ]
[ 144, 37 ]
python
en
['en', 'error', 'th']
False
AdminSite.is_registered
(self, model)
Check if a model class is registered with this `AdminSite`.
Check if a model class is registered with this `AdminSite`.
def is_registered(self, model): """ Check if a model class is registered with this `AdminSite`. """ return model in self._registry
[ "def", "is_registered", "(", "self", ",", "model", ")", ":", "return", "model", "in", "self", ".", "_registry" ]
[ 146, 4 ]
[ 150, 38 ]
python
en
['en', 'error', 'th']
False
AdminSite.add_action
(self, action, name=None)
Register an action to be available globally.
Register an action to be available globally.
def add_action(self, action, name=None): """ Register an action to be available globally. """ name = name or action.__name__ self._actions[name] = action self._global_actions[name] = action
[ "def", "add_action", "(", "self", ",", "action", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "action", ".", "__name__", "self", ".", "_actions", "[", "name", "]", "=", "action", "self", ".", "_global_actions", "[", "name", "]", "="...
[ 152, 4 ]
[ 158, 43 ]
python
en
['en', 'error', 'th']
False
AdminSite.disable_action
(self, name)
Disable a globally-registered action. Raise KeyError for invalid names.
Disable a globally-registered action. Raise KeyError for invalid names.
def disable_action(self, name): """ Disable a globally-registered action. Raise KeyError for invalid names. """ del self._actions[name]
[ "def", "disable_action", "(", "self", ",", "name", ")", ":", "del", "self", ".", "_actions", "[", "name", "]" ]
[ 160, 4 ]
[ 164, 31 ]
python
en
['en', 'error', 'th']
False
AdminSite.get_action
(self, name)
Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names.
Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names.
def get_action(self, name): """ Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names. """ return self._global_actions[name]
[ "def", "get_action", "(", "self", ",", "name", ")", ":", "return", "self", ".", "_global_actions", "[", "name", "]" ]
[ 166, 4 ]
[ 171, 41 ]
python
en
['en', 'error', 'th']
False
AdminSite.actions
(self)
Get all the enabled actions as an iterable of (name, func).
Get all the enabled actions as an iterable of (name, func).
def actions(self): """ Get all the enabled actions as an iterable of (name, func). """ return self._actions.items()
[ "def", "actions", "(", "self", ")", ":", "return", "self", ".", "_actions", ".", "items", "(", ")" ]
[ 174, 4 ]
[ 178, 36 ]
python
en
['en', 'error', 'th']
False
AdminSite.has_permission
(self, request)
Return True if the given HttpRequest has permission to view *at least one* page in the admin site.
Return True if the given HttpRequest has permission to view *at least one* page in the admin site.
def has_permission(self, request): """ Return True if the given HttpRequest has permission to view *at least one* page in the admin site. """ return request.user.is_active and request.user.is_staff
[ "def", "has_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff" ]
[ 188, 4 ]
[ 193, 63 ]
python
en
['en', 'error', 'th']
False
AdminSite.admin_view
(self, view, cacheable=False)
Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``. You'll want to use this from within ``AdminSite.get_urls()``: class MyAdminSite(AdminSite): def get_u...
Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``.
def admin_view(self, view, cacheable=False): """ Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``. You'll want to use this from within ``AdminSite.get_urls()``: ...
[ "def", "admin_view", "(", "self", ",", "view", ",", "cacheable", "=", "False", ")", ":", "def", "inner", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_permission", "(", "request", ")", ":", "if"...
[ 195, 4 ]
[ 237, 42 ]
python
en
['en', 'error', 'th']
False
AdminSite.each_context
(self, request)
Return a dictionary of variables to put in the template context for *every* page in the admin site. For sites running on a subpath, use the SCRIPT_NAME value if site_url hasn't been customized.
Return a dictionary of variables to put in the template context for *every* page in the admin site.
def each_context(self, request): """ Return a dictionary of variables to put in the template context for *every* page in the admin site. For sites running on a subpath, use the SCRIPT_NAME value if site_url hasn't been customized. """ script_name = request.META['...
[ "def", "each_context", "(", "self", ",", "request", ")", ":", "script_name", "=", "request", ".", "META", "[", "'SCRIPT_NAME'", "]", "site_url", "=", "script_name", "if", "self", ".", "site_url", "==", "'/'", "and", "script_name", "else", "self", ".", "sit...
[ 294, 4 ]
[ 311, 9 ]
python
en
['en', 'error', 'th']
False
AdminSite.password_change
(self, request, extra_context=None)
Handle the "change password" task -- both form display and validation.
Handle the "change password" task -- both form display and validation.
def password_change(self, request, extra_context=None): """ Handle the "change password" task -- both form display and validation. """ from django.contrib.admin.forms import AdminPasswordChangeForm from django.contrib.auth.views import PasswordChangeView url = reverse('ad...
[ "def", "password_change", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "forms", "import", "AdminPasswordChangeForm", "from", "django", ".", "contrib", ".", "auth", ".", "views"...
[ 313, 4 ]
[ 328, 62 ]
python
en
['en', 'error', 'th']
False
AdminSite.password_change_done
(self, request, extra_context=None)
Display the "success" page after a password change.
Display the "success" page after a password change.
def password_change_done(self, request, extra_context=None): """ Display the "success" page after a password change. """ from django.contrib.auth.views import PasswordChangeDoneView defaults = { 'extra_context': {**self.each_context(request), **(extra_context or {})},...
[ "def", "password_change_done", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "PasswordChangeDoneView", "defaults", "=", "{", "'extra_context'", ":", "{", "*", ...
[ 330, 4 ]
[ 341, 66 ]
python
en
['en', 'error', 'th']
False
AdminSite.i18n_javascript
(self, request, extra_context=None)
Display the i18n JavaScript that the Django admin requires. `extra_context` is unused but present for consistency with the other admin views.
Display the i18n JavaScript that the Django admin requires.
def i18n_javascript(self, request, extra_context=None): """ Display the i18n JavaScript that the Django admin requires. `extra_context` is unused but present for consistency with the other admin views. """ return JavaScriptCatalog.as_view(packages=['django.contrib.admin'...
[ "def", "i18n_javascript", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "return", "JavaScriptCatalog", ".", "as_view", "(", "packages", "=", "[", "'django.contrib.admin'", "]", ")", "(", "request", ")" ]
[ 343, 4 ]
[ 350, 84 ]
python
en
['en', 'error', 'th']
False
AdminSite.logout
(self, request, extra_context=None)
Log out the user for the given HttpRequest. This should *not* assume the user is already logged in.
Log out the user for the given HttpRequest.
def logout(self, request, extra_context=None): """ Log out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ from django.contrib.auth.views import LogoutView defaults = { 'extra_context': { **self....
[ "def", "logout", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "LogoutView", "defaults", "=", "{", "'extra_context'", ":", "{", "*", "*", "self", ".", "e...
[ 353, 4 ]
[ 372, 54 ]
python
en
['en', 'error', 'th']
False
AdminSite.login
(self, request, extra_context=None)
Display the login form for the given HttpRequest.
Display the login form for the given HttpRequest.
def login(self, request, extra_context=None): """ Display the login form for the given HttpRequest. """ if request.method == 'GET' and self.has_permission(request): # Already logged-in, redirect to admin index index_path = reverse('admin:index', current_app=self.n...
[ "def", "login", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "if", "request", ".", "method", "==", "'GET'", "and", "self", ".", "has_permission", "(", "request", ")", ":", "# Already logged-in, redirect to admin index", "index_path",...
[ 375, 4 ]
[ 406, 53 ]
python
en
['en', 'error', 'th']
False
AdminSite._build_app_dict
(self, request, label=None)
Build the app dictionary. The optional `label` parameter filters models of a specific app.
Build the app dictionary. The optional `label` parameter filters models of a specific app.
def _build_app_dict(self, request, label=None): """ Build the app dictionary. The optional `label` parameter filters models of a specific app. """ app_dict = {} if label: models = { m: m_a for m, m_a in self._registry.items() i...
[ "def", "_build_app_dict", "(", "self", ",", "request", ",", "label", "=", "None", ")", ":", "app_dict", "=", "{", "}", "if", "label", ":", "models", "=", "{", "m", ":", "m_a", "for", "m", ",", "m_a", "in", "self", ".", "_registry", ".", "items", ...
[ 408, 4 ]
[ 474, 23 ]
python
en
['en', 'error', 'th']
False
AdminSite.get_app_list
(self, request)
Return a sorted list of all the installed apps that have been registered in this site.
Return a sorted list of all the installed apps that have been registered in this site.
def get_app_list(self, request): """ Return a sorted list of all the installed apps that have been registered in this site. """ app_dict = self._build_app_dict(request) # Sort the apps alphabetically. app_list = sorted(app_dict.values(), key=lambda x: x['name'].l...
[ "def", "get_app_list", "(", "self", ",", "request", ")", ":", "app_dict", "=", "self", ".", "_build_app_dict", "(", "request", ")", "# Sort the apps alphabetically.", "app_list", "=", "sorted", "(", "app_dict", ".", "values", "(", ")", ",", "key", "=", "lamb...
[ 476, 4 ]
[ 490, 23 ]
python
en
['en', 'error', 'th']
False
AdminSite.index
(self, request, extra_context=None)
Display the main admin index page, which lists all of the installed apps that have been registered in this site.
Display the main admin index page, which lists all of the installed apps that have been registered in this site.
def index(self, request, extra_context=None): """ Display the main admin index page, which lists all of the installed apps that have been registered in this site. """ app_list = self.get_app_list(request) context = { **self.each_context(request), ...
[ "def", "index", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "app_list", "=", "self", ".", "get_app_list", "(", "request", ")", "context", "=", "{", "*", "*", "self", ".", "each_context", "(", "request", ")", ",", "'title'"...
[ 493, 4 ]
[ 509, 92 ]
python
en
['en', 'error', 'th']
False
TransferFamily.manage_subfleet
(self)
Manage start/stop actions for subfleet TransferFamily servers
Manage start/stop actions for subfleet TransferFamily servers
def manage_subfleet(self): """Manage start/stop actions for subfleet TransferFamily servers """ if "transfer" not in self.context["o_state"].get_resource_services(): return states = defaultdict(int) for server in self.servers: arn = server["Arn"] ...
[ "def", "manage_subfleet", "(", "self", ")", ":", "if", "\"transfer\"", "not", "in", "self", ".", "context", "[", "\"o_state\"", "]", ".", "get_resource_services", "(", ")", ":", "return", "states", "=", "defaultdict", "(", "int", ")", "for", "server", "in"...
[ 93, 4 ]
[ 147, 73 ]
python
en
['en', 'en', 'en']
True
list_files
(suffix="")
Returns a list of all files in CleverHans with the given suffix. Parameters ---------- suffix : str Returns ------- file_list : list A list of all files in CleverHans whose filepath ends with `suffix`.
Returns a list of all files in CleverHans with the given suffix.
def list_files(suffix=""): """ Returns a list of all files in CleverHans with the given suffix. Parameters ---------- suffix : str Returns ------- file_list : list A list of all files in CleverHans whose filepath ends with `suffix`. """ cleverhans_path = os.path.abspa...
[ "def", "list_files", "(", "suffix", "=", "\"\"", ")", ":", "cleverhans_path", "=", "os", ".", "path", ".", "abspath", "(", "cleverhans", ".", "__path__", "[", "0", "]", ")", "# In some environments cleverhans_path does not point to a real directory.", "# In such case ...
[ 5, 0 ]
[ 43, 20 ]
python
en
['en', 'error', 'th']
False
_list_files
(path, suffix="")
Returns a list of all files ending in `suffix` contained within `path`. Parameters ---------- path : str a filepath suffix : str Returns ------- l : list A list of all files ending in `suffix` contained within `path`. (If `path` is a file rather than a director...
Returns a list of all files ending in `suffix` contained within `path`.
def _list_files(path, suffix=""): """ Returns a list of all files ending in `suffix` contained within `path`. Parameters ---------- path : str a filepath suffix : str Returns ------- l : list A list of all files ending in `suffix` contained within `path`. (I...
[ "def", "_list_files", "(", "path", ",", "suffix", "=", "\"\"", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "incomplete", "=", "os", ".", "listdir", "(", "path", ")", "complete", "=", "[", "os", ".", "path", ".", "join"...
[ 46, 0 ]
[ 76, 17 ]
python
en
['en', 'error', 'th']
False
BaseHandler.load_middleware
(self)
Populate middleware lists from settings.MIDDLEWARE_CLASSES. Must be called after the environment is fixed (see __call__ in subclasses).
Populate middleware lists from settings.MIDDLEWARE_CLASSES.
def load_middleware(self): """ Populate middleware lists from settings.MIDDLEWARE_CLASSES. Must be called after the environment is fixed (see __call__ in subclasses). """ self._view_middleware = [] self._template_response_middleware = [] self._response_middleware...
[ "def", "load_middleware", "(", "self", ")", ":", "self", ".", "_view_middleware", "=", "[", "]", "self", ".", "_template_response_middleware", "=", "[", "]", "self", ".", "_response_middleware", "=", "[", "]", "self", ".", "_exception_middleware", "=", "[", ...
[ 34, 4 ]
[ 66, 53 ]
python
en
['en', 'error', 'th']
False
BaseHandler.get_response
(self, request)
Returns an HttpResponse object for the given HttpRequest
Returns an HttpResponse object for the given HttpRequest
def get_response(self, request): "Returns an HttpResponse object for the given HttpRequest" # Setup default url resolver for this thread, this code is outside # the try/except so we don't get a spurious "unbound local # variable" exception in the event an exception is raised before ...
[ "def", "get_response", "(", "self", ",", "request", ")", ":", "# Setup default url resolver for this thread, this code is outside", "# the try/except so we don't get a spurious \"unbound local", "# variable\" exception in the event an exception is raised before", "# resolver is set", "urlcon...
[ 86, 4 ]
[ 220, 23 ]
python
en
['en', 'en', 'en']
True
BaseHandler.handle_uncaught_exception
(self, request, resolver, exc_info)
Processing for any otherwise uncaught exceptions (those that will generate HTTP 500 responses). Can be overridden by subclasses who want customised 500 handling. Be *very* careful when overriding this because the error could be caused by anything, so assuming something like the...
Processing for any otherwise uncaught exceptions (those that will generate HTTP 500 responses). Can be overridden by subclasses who want customised 500 handling.
def handle_uncaught_exception(self, request, resolver, exc_info): """ Processing for any otherwise uncaught exceptions (those that will generate HTTP 500 responses). Can be overridden by subclasses who want customised 500 handling. Be *very* careful when overriding this because ...
[ "def", "handle_uncaught_exception", "(", "self", ",", "request", ",", "resolver", ",", "exc_info", ")", ":", "if", "settings", ".", "DEBUG_PROPAGATE_EXCEPTIONS", ":", "raise", "logger", ".", "error", "(", "'Internal Server Error: %s'", ",", "request", ".", "path",...
[ 222, 4 ]
[ 251, 46 ]
python
en
['en', 'error', 'th']
False
BaseHandler.apply_response_fixes
(self, request, response)
Applies each of the functions in self.response_fixes to the request and response, modifying the response in the process. Returns the new response.
Applies each of the functions in self.response_fixes to the request and response, modifying the response in the process. Returns the new response.
def apply_response_fixes(self, request, response): """ Applies each of the functions in self.response_fixes to the request and response, modifying the response in the process. Returns the new response. """ for func in self.response_fixes: response = func(reque...
[ "def", "apply_response_fixes", "(", "self", ",", "request", ",", "response", ")", ":", "for", "func", "in", "self", ".", "response_fixes", ":", "response", "=", "func", "(", "request", ",", "response", ")", "return", "response" ]
[ 253, 4 ]
[ 261, 23 ]
python
en
['en', 'error', 'th']
False
EditMessageTest.check_message
(self, msg_id: int, topic_name: str, content: str)
We assume our caller just edited a message. Next, we will make sure we properly cached the messages. We still have to do a query to hydrate recipient info, but we won't need to hit the zerver_message table.
We assume our caller just edited a message.
def check_message(self, msg_id: int, topic_name: str, content: str) -> None: # Make sure we saved the message correctly to the DB. msg = Message.objects.get(id=msg_id) self.assertEqual(msg.topic_name(), topic_name) self.assertEqual(msg.content, content) """ We assume our...
[ "def", "check_message", "(", "self", ",", "msg_id", ":", "int", ",", "topic_name", ":", "str", ",", "content", ":", "str", ")", "->", "None", ":", "# Make sure we saved the message correctly to the DB.", "msg", "=", "Message", ".", "objects", ".", "get", "(", ...
[ 27, 4 ]
[ 72, 13 ]
python
en
['en', 'error', 'th']
False
EditMessageTest.test_save_message
(self)
This is also tested by a client test, but here we can verify the cache against the database
This is also tested by a client test, but here we can verify the cache against the database
def test_save_message(self) -> None: """This is also tested by a client test, but here we can verify the cache against the database""" self.login("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topic_name="editing", content="before edit" ...
[ "def", "test_save_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "\"Scotland\"", ",", "topic_name"...
[ 109, 4 ]
[ 134, 53 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_edit_cases
(self)
This test verifies the accuracy of construction of Zulip's edit history data structures.
This test verifies the accuracy of construction of Zulip's edit history data structures.
def test_edit_cases(self) -> None: """This test verifies the accuracy of construction of Zulip's edit history data structures.""" self.login("hamlet") hamlet = self.example_user("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topi...
[ "def", "test_edit_cases", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_u...
[ 451, 4 ]
[ 591, 64 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_inaccessible_msg_after_stream_change
(self)
Simulates the case where message is moved to a stream where user is not a subscribed
Simulates the case where message is moved to a stream where user is not a subscribed
def test_inaccessible_msg_after_stream_change(self) -> None: """Simulates the case where message is moved to a stream where user is not a subscribed""" (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics( "iago", "test move stream", "new stream", "test" ...
[ "def", "test_inaccessible_msg_after_stream_change", "(", "self", ")", "->", "None", ":", "(", "user_profile", ",", "old_stream", ",", "new_stream", ",", "msg_id", ",", "msg_id_lt", ")", "=", "self", ".", "prepare_move_topics", "(", "\"iago\"", ",", "\"test move st...
[ 1191, 4 ]
[ 1246, 9 ]
python
en
['en', 'en', 'en']
True
get_opening_hours
(begin, end, resources=None)
:type begin:datetime.date :type end:datetime.date :type resources: Resource | None :rtype: dict[datetime, dict[Resource, list[OpenHours]]] Find opening hours for all resources on a given time period. If resources is None, finds opening hours for all resources. This version goes through a...
:type begin:datetime.date :type end:datetime.date :type resources: Resource | None :rtype: dict[datetime, dict[Resource, list[OpenHours]]]
def get_opening_hours(begin, end, resources=None): """ :type begin:datetime.date :type end:datetime.date :type resources: Resource | None :rtype: dict[datetime, dict[Resource, list[OpenHours]]] Find opening hours for all resources on a given time period. If resources is None, finds opening...
[ "def", "get_opening_hours", "(", "begin", ",", "end", ",", "resources", "=", "None", ")", ":", "if", "not", "resources", ":", "resources", "=", "Resource", ".", "objects", ".", "all", "(", ")", "if", "not", "begin", "<", "end", ":", "end", "=", "begi...
[ 220, 0 ]
[ 289, 16 ]
python
en
['en', 'error', 'th']
False
get_availability
(begin, end, resources=None, duration=None)
Availability is opening hours and free time between reservations This function calculates both for given time range Given a queryset of resources (even if just one) can calculate applicable opening hours and free time slots between begin and end of day and reservations for days that have rese...
Availability is opening hours and free time between reservations
def get_availability(begin, end, resources=None, duration=None): """ Availability is opening hours and free time between reservations This function calculates both for given time range Given a queryset of resources (even if just one) can calculate applicable opening hours and free time slots betwe...
[ "def", "get_availability", "(", "begin", ",", "end", ",", "resources", "=", "None", ",", "duration", "=", "None", ")", ":", "if", "not", "resources", ":", "resources", "=", "Resource", ".", "objects", ".", "all", "(", ")", "dt_range", "=", "DateTimeTZRan...
[ 292, 0 ]
[ 362, 38 ]
python
en
['en', 'error', 'th']
False
calculate_availability
(resource, opening_hours, duration=None)
Goes through reservations for given resource Calculates available time for days with reservations based on reservation duration and opening hours Availability is dictionary of dates and a list of FreeTime objects with begin and end DateTime fields If duration is given and longer than free ti...
Goes through reservations for given resource
def calculate_availability(resource, opening_hours, duration=None): """ Goes through reservations for given resource Calculates available time for days with reservations based on reservation duration and opening hours Availability is dictionary of dates and a list of FreeTime objects with begi...
[ "def", "calculate_availability", "(", "resource", ",", "opening_hours", ",", "duration", "=", "None", ")", ":", "reservations_by_day", "=", "groupby", "(", "resource", ".", "overlapping_reservations", ",", "key", "=", "lambda", "rsv", ":", "rsv", ".", "begin", ...
[ 365, 0 ]
[ 442, 23 ]
python
en
['en', 'error', 'th']
False
periods_to_opening_hours
(resource, begin_dt, end_dt)
Goes through resource's unit's periods and its own periods Creates opening hours for each day First unit's regular days are processed, then their exceptions Then same order for resource itself Resulting date dict is union of all periodical information or false if given day is closed ...
Goes through resource's unit's periods and its own periods
def periods_to_opening_hours(resource, begin_dt, end_dt): """ Goes through resource's unit's periods and its own periods Creates opening hours for each day First unit's regular days are processed, then their exceptions Then same order for resource itself Resulting date dict is union of al...
[ "def", "periods_to_opening_hours", "(", "resource", ",", "begin_dt", ",", "end_dt", ")", ":", "#begin_dt = datetime.datetime.combine(begin, datetime.time(0, 0))", "#end_dt = datetime.datetime.combine(end, datetime.time(0, 0))", "begin_d", "=", "begin_dt", ".", "date", "(", ")", ...
[ 445, 0 ]
[ 532, 16 ]
python
en
['en', 'error', 'th']
False
TimeWarp.__init__
(self, dt=None, day=None, end_dt=None, end_day=None, original_timezone=None)
Converts given dt or day into UTC date time object and saves this and the original time zone object into object's fields NOTE: At the moment Arror generated DateTime's will fail time zone conversion since Arrow does zone handling differently than Pytz, use Pytz zone localized ...
Converts given dt or day into UTC date time object and saves this and the original time zone object into object's fields
def __init__(self, dt=None, day=None, end_dt=None, end_day=None, original_timezone=None): """ Converts given dt or day into UTC date time object and saves this and the original time zone object into object's fields NOTE: At the moment Arror generated DateTime's will fail time zo...
[ "def", "__init__", "(", "self", ",", "dt", "=", "None", ",", "day", "=", "None", ",", "end_dt", "=", "None", ",", "end_day", "=", "None", ",", "original_timezone", "=", "None", ")", ":", "if", "dt", "and", "not", "hasattr", "(", "dt", ",", "\"tzinf...
[ 36, 4 ]
[ 87, 31 ]
python
en
['en', 'error', 'th']
False
TimeWarp.find_timezone
(self, dt, original_timezone=None)
Gets the pytz time zone object from given original time zone, or uses datetime objects own or finally returns Django's current time zone :type dt: datetime.datetime :type original_timezone: string :rtype: pytz.timezone
Gets the pytz time zone object from given original time zone, or uses datetime objects own or finally returns Django's current time zone
def find_timezone(self, dt, original_timezone=None): """ Gets the pytz time zone object from given original time zone, or uses datetime objects own or finally returns Django's current time zone :type dt: datetime.datetime :type original_timezone: string :rtype: p...
[ "def", "find_timezone", "(", "self", ",", "dt", ",", "original_timezone", "=", "None", ")", ":", "if", "original_timezone", ":", "return", "pytz", ".", "timezone", "(", "original_timezone", ")", "elif", "dt", ".", "tzinfo", "and", "dt", ".", "tzinfo", ".",...
[ 99, 4 ]
[ 114, 50 ]
python
en
['en', 'error', 'th']
False
TimeWarp.dt_as_utc
(self, dt, zone=None)
Normalizes given datetime to UTC DateTime with time zone cast to UTC Naive DateTime is in given time zone and is casted to UTC When no zone is given and DateTime is naive, localize it to UTC as is :param dt: datetime to normalize :type dt: datetime.datetime :pa...
Normalizes given datetime to UTC
def dt_as_utc(self, dt, zone=None): """ Normalizes given datetime to UTC DateTime with time zone cast to UTC Naive DateTime is in given time zone and is casted to UTC When no zone is given and DateTime is naive, localize it to UTC as is :param dt: datetime to normalize ...
[ "def", "dt_as_utc", "(", "self", ",", "dt", ",", "zone", "=", "None", ")", ":", "if", "dt", ".", "tzinfo", ":", "return", "dt", ".", "astimezone", "(", "pytz", ".", "utc", ")", "elif", "zone", ":", "return", "zone", ".", "localize", "(", "dt", ")...
[ 116, 4 ]
[ 136, 40 ]
python
en
['en', 'error', 'th']
False
TimeWarp.get_delta
(self, delta, operator, zone=None)
:param delta: :type delta: datetime.timedelta :param operator: operator function to apply :type operator: func :param zone: :type zone: pytz.timezone :return: :rtype: TimeWarp
def get_delta(self, delta, operator, zone=None): """ :param delta: :type delta: datetime.timedelta :param operator: operator function to apply :type operator: func :param zone: :type zone: pytz.timezone :return: :rtype: TimeWarp """ ...
[ "def", "get_delta", "(", "self", ",", "delta", ",", "operator", ",", "zone", "=", "None", ")", ":", "if", "zone", ":", "return", "TimeWarp", "(", "operator", "(", "self", ".", "dt", ".", "astimezone", "(", "zone", ")", ",", "delta", ")", ")", "else...
[ 138, 4 ]
[ 154, 44 ]
python
en
['en', 'error', 'th']
False
TimeWarp.serialize
(self, dt_format=None, zone=None)
Serializes datetimes using given format or default format if None, in given or original time zone Returns formatted strings as dict for both datetime fields if present TimeWarp class now has built in time formats Serializer can use given format or you can choose from built in f...
Serializes datetimes using given format or default format if None, in given or original time zone Returns formatted strings as dict for both datetime fields if present
def serialize(self, dt_format=None, zone=None): """ Serializes datetimes using given format or default format if None, in given or original time zone Returns formatted strings as dict for both datetime fields if present TimeWarp class now has built in time formats Serial...
[ "def", "serialize", "(", "self", ",", "dt_format", "=", "None", ",", "zone", "=", "None", ")", ":", "if", "not", "zone", ":", "zone", "=", "self", ".", "original_timezone", "else", ":", "zone", "=", "pytz", ".", "timezone", "(", "zone", ")", "resp", ...
[ 184, 4 ]
[ 217, 19 ]
python
en
['en', 'error', 'th']
False
std_call
(func)
Return the correct STDCALL function for certain OSR routines on Win32 platforms.
Return the correct STDCALL function for certain OSR routines on Win32 platforms.
def std_call(func): """ Return the correct STDCALL function for certain OSR routines on Win32 platforms. """ if os.name == 'nt': return lwingdal[func] else: return lgdal[func]
[ "def", "std_call", "(", "func", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "return", "lwingdal", "[", "func", "]", "else", ":", "return", "lgdal", "[", "func", "]" ]
[ 56, 0 ]
[ 64, 26 ]
python
en
['en', 'error', 'th']
False
gdal_version
()
Return only the GDAL version number information.
Return only the GDAL version number information.
def gdal_version(): "Return only the GDAL version number information." return _version_info(b'RELEASE_NAME')
[ "def", "gdal_version", "(", ")", ":", "return", "_version_info", "(", "b'RELEASE_NAME'", ")" ]
[ 75, 0 ]
[ 77, 41 ]
python
en
['en', 'da', 'en']
True
gdal_full_version
()
Return the full GDAL version information.
Return the full GDAL version information.
def gdal_full_version(): "Return the full GDAL version information." return _version_info('')
[ "def", "gdal_full_version", "(", ")", ":", "return", "_version_info", "(", "''", ")" ]
[ 80, 0 ]
[ 82, 28 ]
python
en
['en', 'no', 'en']
True
get_current_site
(request)
Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request.
Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request.
def get_current_site(request): """ Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request. """ # Imports are inside the function because its point is to avoid importing # the Site models when django.contrib.sites isn't...
[ "def", "get_current_site", "(", "request", ")", ":", "# Imports are inside the function because its point is to avoid importing", "# the Site models when django.contrib.sites isn't installed.", "if", "apps", ".", "is_installed", "(", "'django.contrib.sites'", ")", ":", "from", ".",...
[ 5, 0 ]
[ 17, 35 ]
python
en
['en', 'error', 'th']
False
check_realm_emoji_update
(var_name: str, event: Dict[str, object])
The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make a Map as needed.
The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make a Map as needed.
def check_realm_emoji_update(var_name: str, event: Dict[str, object]) -> None: """ The way we send realm emojis is kinda clumsy--we send a dict mapping the emoji id to a sub_dict with the fields (including the id). Ideally we can streamline this and just send a list of dicts. The clients can make ...
[ "def", "check_realm_emoji_update", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ")", "->", "None", ":", "_check_realm_emoji_update", "(", "var_name", ",", "event", ")", "assert", "isinstance", "(", "event", "[", "...
[ 720, 0 ]
[ 732, 27 ]
python
en
['en', 'error', 'th']
False
check_realm_update
( var_name: str, event: Dict[str, object], prop: str, )
Realm updates have these two fields: property value We check not only the basic schema, but also that the value people actually matches the type from Realm.property_types that we have configured for the property.
Realm updates have these two fields:
def check_realm_update( var_name: str, event: Dict[str, object], prop: str, ) -> None: """ Realm updates have these two fields: property value We check not only the basic schema, but also that the value people actually matches the type from Realm.property_types that we ...
[ "def", "check_realm_update", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", "prop", ":", "str", ",", ")", "->", "None", ":", "_check_realm_update", "(", "var_name", ",", "event", ")", "assert", "prop", "=="...
[ 832, 0 ]
[ 873, 73 ]
python
en
['en', 'error', 'th']
False
check_update_display_settings
( var_name: str, event: Dict[str, object], )
Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary.
Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary.
def check_update_display_settings( var_name: str, event: Dict[str, object], ) -> None: """ Display setting events have a "setting" field that is more specifically typed according to the UserProfile.property_types dictionary. """ _check_update_display_settings(var_name, event) setting...
[ "def", "check_update_display_settings", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", ")", "->", "None", ":", "_check_update_display_settings", "(", "var_name", ",", "event", ")", "setting_name", "=", "event", "...
[ 1335, 0 ]
[ 1355, 50 ]
python
en
['en', 'error', 'th']
False
check_update_global_notifications
( var_name: str, event: Dict[str, object], desired_val: Union[bool, int, str], )
See UserProfile.notification_setting_types for more details.
See UserProfile.notification_setting_types for more details.
def check_update_global_notifications( var_name: str, event: Dict[str, object], desired_val: Union[bool, int, str], ) -> None: """ See UserProfile.notification_setting_types for more details. """ _check_update_global_notifications(var_name, event) setting_name = event["notification_n...
[ "def", "check_update_global_notifications", "(", "var_name", ":", "str", ",", "event", ":", "Dict", "[", "str", ",", "object", "]", ",", "desired_val", ":", "Union", "[", "bool", ",", "int", ",", "str", "]", ",", ")", "->", "None", ":", "_check_update_gl...
[ 1369, 0 ]
[ 1385, 44 ]
python
en
['en', 'error', 'th']
False
build_wheel_pep517
( name, # type: str backend, # type: Pep517HookCaller metadata_directory, # type: str build_options, # type: List[str] tempd, # type: str )
Build one InstallRequirement using the PEP 517 build process. Returns path to wheel if successfully built. Otherwise, returns None.
Build one InstallRequirement using the PEP 517 build process.
def build_wheel_pep517( name, # type: str backend, # type: Pep517HookCaller metadata_directory, # type: str build_options, # type: List[str] tempd, # type: str ): # type: (...) -> Optional[str] """Build one InstallRequirement using the PEP 517 build process. Returns path to wheel i...
[ "def", "build_wheel_pep517", "(", "name", ",", "# type: str", "backend", ",", "# type: Pep517HookCaller", "metadata_directory", ",", "# type: str", "build_options", ",", "# type: List[str]", "tempd", ",", "# type: str", ")", ":", "# type: (...) -> Optional[str]", "assert", ...
[ 13, 0 ]
[ 45, 42 ]
python
en
['en', 'en', 'en']
True
Dropout.fprop
(self, x, dropout=False, dropout_dict=None, **kwargs)
Forward propagation as either no-op or dropping random units. :param x: The input to the layer :param dropout: bool specifying whether to drop units :param dropout_dict: dict This dictionary is usually not needed. In rare cases, generally for research purposes, t...
Forward propagation as either no-op or dropping random units. :param x: The input to the layer :param dropout: bool specifying whether to drop units :param dropout_dict: dict This dictionary is usually not needed. In rare cases, generally for research purposes, t...
def fprop(self, x, dropout=False, dropout_dict=None, **kwargs): """ Forward propagation as either no-op or dropping random units. :param x: The input to the layer :param dropout: bool specifying whether to drop units :param dropout_dict: dict This dictionary is usuall...
[ "def", "fprop", "(", "self", ",", "x", ",", "dropout", "=", "False", ",", "dropout_dict", "=", "None", ",", "*", "*", "kwargs", ")", ":", "include_prob", "=", "self", ".", "include_prob", "if", "dropout_dict", "is", "not", "None", ":", "assert", "dropo...
[ 617, 4 ]
[ 640, 16 ]
python
en
['en', 'error', 'th']
False
get_all_distribution_names
(url=None)
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
def get_all_distribution_names(url=None): """ Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. """ if url is None: url = DEFAULT_INDEX client = ServerProxy(url, timeout=3.0) try: return cli...
[ "def", "get_all_distribution_names", "(", "url", "=", "None", ")", ":", "if", "url", "is", "None", ":", "url", "=", "DEFAULT_INDEX", "client", "=", "ServerProxy", "(", "url", ",", "timeout", "=", "3.0", ")", "try", ":", "return", "client", ".", "list_pac...
[ 40, 0 ]
[ 52, 25 ]
python
en
['en', 'error', 'th']
False
Locator.__init__
(self, scheme='default')
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
def __init__(self, scheme='default'): """ Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` ...
[ "def", "__init__", "(", "self", ",", "scheme", "=", "'default'", ")", ":", "self", ".", "_cache", "=", "{", "}", "self", ".", "scheme", "=", "scheme", "# Because of bugs in some of the handlers on some of the platforms,", "# we use our own opener rather than just using ur...
[ 101, 4 ]
[ 118, 35 ]
python
en
['en', 'error', 'th']
False
Locator.get_errors
(self)
Return any errors which have occurred.
Return any errors which have occurred.
def get_errors(self): """ Return any errors which have occurred. """ result = [] while not self.errors.empty(): # pragma: no cover try: e = self.errors.get(False) result.append(e) except self.errors.Empty: c...
[ "def", "get_errors", "(", "self", ")", ":", "result", "=", "[", "]", "while", "not", "self", ".", "errors", ".", "empty", "(", ")", ":", "# pragma: no cover", "try", ":", "e", "=", "self", ".", "errors", ".", "get", "(", "False", ")", "result", "."...
[ 120, 4 ]
[ 132, 21 ]
python
en
['en', 'error', 'th']
False
Locator.clear_errors
(self)
Clear any errors which may have been logged.
Clear any errors which may have been logged.
def clear_errors(self): """ Clear any errors which may have been logged. """ # Just get the errors and throw them away self.get_errors()
[ "def", "clear_errors", "(", "self", ")", ":", "# Just get the errors and throw them away", "self", ".", "get_errors", "(", ")" ]
[ 134, 4 ]
[ 139, 25 ]
python
en
['en', 'error', 'th']
False
Locator._get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisfy, otherwise it will be None.
For a given project, get a dictionary mapping available versions to Distribution instances.
def _get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisf...
[ "def", "_get_project", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 152, 4 ]
[ 162, 69 ]
python
en
['en', 'error', 'th']
False
Locator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Please implement in the subclass')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 164, 4 ]
[ 168, 69 ]
python
en
['en', 'error', 'th']
False
Locator.get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top.
For a given project, get a dictionary mapping available versions to Distribution instances.
def get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top. """ if self._cache is None: # pragma: no cover ...
[ "def", "get_project", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_cache", "is", "None", ":", "# pragma: no cover", "result", "=", "self", ".", "_get_project", "(", "name", ")", "elif", "name", "in", "self", ".", "_cache", ":", "result", "=...
[ 170, 4 ]
[ 185, 21 ]
python
en
['en', 'error', 'th']
False
Locator.score_url
(self, url)
Give an url a score which can be used to choose preferred URLs for a given project release.
Give an url a score which can be used to choose preferred URLs for a given project release.
def score_url(self, url): """ Give an url a score which can be used to choose preferred URLs for a given project release. """ t = urlparse(url) basename = posixpath.basename(t.path) compatible = True is_wheel = basename.endswith('.whl') is_download...
[ "def", "score_url", "(", "self", ",", "url", ")", ":", "t", "=", "urlparse", "(", "url", ")", "basename", "=", "posixpath", ".", "basename", "(", "t", ".", "path", ")", "compatible", "=", "True", "is_wheel", "=", "basename", ".", "endswith", "(", "'....
[ 187, 4 ]
[ 200, 64 ]
python
en
['en', 'error', 'th']
False
Locator.prefer_url
(self, url1, url2)
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over those from other locations, wheel compatibili...
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip).
def prefer_url(self, url1, url2): """ Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over ...
[ "def", "prefer_url", "(", "self", ",", "url1", ",", "url2", ")", ":", "result", "=", "url2", "if", "url1", ":", "s1", "=", "self", ".", "score_url", "(", "url1", ")", "s2", "=", "self", ".", "score_url", "(", "url2", ")", "if", "s1", ">", "s2", ...
[ 202, 4 ]
[ 222, 21 ]
python
en
['en', 'error', 'th']
False
Locator.split_filename
(self, filename, project_name)
Attempt to split a filename in project name, version and Python version.
Attempt to split a filename in project name, version and Python version.
def split_filename(self, filename, project_name): """ Attempt to split a filename in project name, version and Python version. """ return split_filename(filename, project_name)
[ "def", "split_filename", "(", "self", ",", "filename", ",", "project_name", ")", ":", "return", "split_filename", "(", "filename", ",", "project_name", ")" ]
[ 224, 4 ]
[ 228, 53 ]
python
en
['en', 'error', 'th']
False
Locator.convert_url_to_download_info
(self, url, project_name)
See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, None is returned.
See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page).
def convert_url_to_download_info(self, url, project_name): """ See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, No...
[ "def", "convert_url_to_download_info", "(", "self", ",", "url", ",", "project_name", ")", ":", "def", "same_project", "(", "name1", ",", "name2", ")", ":", "return", "normalize_name", "(", "name1", ")", "==", "normalize_name", "(", "name2", ")", "result", "=...
[ 230, 4 ]
[ 302, 21 ]
python
en
['en', 'error', 'th']
False
Locator._get_digest
(self, info)
Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5.
Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'.
def _get_digest(self, info): """ Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5. """ result = None if '...
[ "def", "_get_digest", "(", "self", ",", "info", ")", ":", "result", "=", "None", "if", "'digests'", "in", "info", ":", "digests", "=", "info", "[", "'digests'", "]", "for", "algo", "in", "(", "'sha256'", ",", "'md5'", ")", ":", "if", "algo", "in", ...
[ 304, 4 ]
[ 325, 21 ]
python
en
['en', 'error', 'th']
False
Locator._update_version_data
(self, result, info)
Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution.
Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution.
def _update_version_data(self, result, info): """ Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution. """ name = inf...
[ "def", "_update_version_data", "(", "self", ",", "result", ",", "info", ")", ":", "name", "=", "info", ".", "pop", "(", "'name'", ")", "version", "=", "info", ".", "pop", "(", "'version'", ")", "if", "version", "in", "result", ":", "dist", "=", "resu...
[ 327, 4 ]
[ 348, 30 ]
python
en
['en', 'error', 'th']
False
Locator.locate
(self, requirement, prereleases=False)
Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``True``, allow pre-release versions ...
Find the most recent distribution which matches the given requirement.
def locate(self, requirement, prereleases=False): """ Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``Tr...
[ "def", "locate", "(", "self", ",", "requirement", ",", "prereleases", "=", "False", ")", ":", "result", "=", "None", "r", "=", "parse_requirement", "(", "requirement", ")", "if", "r", "is", "None", ":", "# pragma: no cover", "raise", "DistlibException", "(",...
[ 350, 4 ]
[ 407, 21 ]
python
en
['en', 'error', 'th']
False
PyPIRPCLocator.__init__
(self, url, **kwargs)
Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor.
Initialise an instance.
def __init__(self, url, **kwargs): """ Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. """ super(PyPIRPCLocator, self).__init__(**kwargs) self.base_url = url self.client = ServerProxy(ur...
[ "def", "__init__", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "super", "(", "PyPIRPCLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self", ".", "base_url", "=", "url", "self", ".", "client", "=", "Server...
[ 415, 4 ]
[ 424, 51 ]
python
en
['en', 'error', 'th']
False
PyPIRPCLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ return set(self.client.list_packages())
[ "def", "get_distribution_names", "(", "self", ")", ":", "return", "set", "(", "self", ".", "client", ".", "list_packages", "(", ")", ")" ]
[ 426, 4 ]
[ 430, 47 ]
python
en
['en', 'error', 'th']
False
PyPIJSONLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Not available from this locator')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Not available from this locator'", ")" ]
[ 467, 4 ]
[ 471, 68 ]
python
en
['en', 'error', 'th']
False
Page.__init__
(self, data, url)
Initialise an instance with the Unicode page contents and the URL they came from.
Initialise an instance with the Unicode page contents and the URL they came from.
def __init__(self, data, url): """ Initialise an instance with the Unicode page contents and the URL they came from. """ self.data = data self.base_url = self.url = url m = self._base.search(self.data) if m: self.base_url = m.group(1)
[ "def", "__init__", "(", "self", ",", "data", ",", "url", ")", ":", "self", ".", "data", "=", "data", "self", ".", "base_url", "=", "self", ".", "url", "=", "url", "m", "=", "self", ".", "_base", ".", "search", "(", "self", ".", "data", ")", "if...
[ 543, 4 ]
[ 552, 38 ]
python
en
['en', 'error', 'th']
False
Page.links
(self)
Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping.
Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping.
def links(self): """ Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping. """ def clean(url): "Tidy up an URL." ...
[ "def", "links", "(", "self", ")", ":", "def", "clean", "(", "url", ")", ":", "\"Tidy up an URL.\"", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "frag", "=", "urlparse", "(", "url", ")", "return", "urlunparse", "(", "(", "s...
[ 557, 4 ]
[ 582, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.__init__
(self, url, timeout=None, num_workers=10, **kwargs)
Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, ...
Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, ...
def __init__(self, url, timeout=None, num_workers=10, **kwargs): """ Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). ...
[ "def", "__init__", "(", "self", ",", "url", ",", "timeout", "=", "None", ",", "num_workers", "=", "10", ",", "*", "*", "kwargs", ")", ":", "super", "(", "SimpleScrapingLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self",...
[ 599, 4 ]
[ 624, 35 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._prepare_threads
(self)
Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages).
Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages).
def _prepare_threads(self): """ Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages). """ self._threads = [] for i in range(self.num_workers): t = th...
[ "def", "_prepare_threads", "(", "self", ")", ":", "self", ".", "_threads", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "num_workers", ")", ":", "t", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_fetch", ")", "t...
[ 626, 4 ]
[ 637, 35 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._wait_threads
(self)
Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so.
Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so.
def _wait_threads(self): """ Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so. """ # Note that you need two loops, since you can't say which # thread will get each sentinel for t in self._threads: self._to_fetc...
[ "def", "_wait_threads", "(", "self", ")", ":", "# Note that you need two loops, since you can't say which", "# thread will get each sentinel", "for", "t", "in", "self", ".", "_threads", ":", "self", ".", "_to_fetch", ".", "put", "(", "None", ")", "# sentinel", "for", ...
[ 639, 4 ]
[ 650, 26 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._is_platform_dependent
(self, url)
Does an URL refer to a platform-specific download?
Does an URL refer to a platform-specific download?
def _is_platform_dependent(self, url): """ Does an URL refer to a platform-specific download? """ return self.platform_dependent.search(url)
[ "def", "_is_platform_dependent", "(", "self", ",", "url", ")", ":", "return", "self", ".", "platform_dependent", ".", "search", "(", "url", ")" ]
[ 673, 4 ]
[ 677, 50 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._process_download
(self, url)
See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean value.
See if an URL is a suitable download for a project.
def _process_download(self, url): """ See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean ...
[ "def", "_process_download", "(", "self", ",", "url", ")", ":", "if", "self", ".", "platform_check", "and", "self", ".", "_is_platform_dependent", "(", "url", ")", ":", "info", "=", "None", "else", ":", "info", "=", "self", ".", "convert_url_to_download_info"...
[ 679, 4 ]
[ 697, 19 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._should_queue
(self, link, referrer, rel)
Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping.
Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping.
def _should_queue(self, link, referrer, rel): """ Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping. """ scheme, netloc, path, _, _, _ = urlparse(link) if path.endswith(self.source_extensions + self.bina...
[ "def", "_should_queue", "(", "self", ",", "link", ",", "referrer", ",", "rel", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "_", ",", "_", ",", "_", "=", "urlparse", "(", "link", ")", "if", "path", ".", "endswith", "(", "self", ".", "sour...
[ 699, 4 ]
[ 726, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator._fetch
(self)
Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread.
Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping.
def _fetch(self): """ Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread. """ while True: url = self._to_fetch.get() t...
[ "def", "_fetch", "(", "self", ")", ":", "while", "True", ":", "url", "=", "self", ".", "_to_fetch", ".", "get", "(", ")", "try", ":", "if", "url", ":", "page", "=", "self", ".", "get_page", "(", "url", ")", "if", "page", "is", "None", ":", "# e...
[ 728, 4 ]
[ 759, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.get_page
(self, url)
Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator).
Get the HTML for an URL, possibly from an in-memory cache.
def get_page(self, url): """ Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator). ...
[ "def", "get_page", "(", "self", ",", "url", ")", ":", "# http://peak.telecommunity.com/DevCenter/EasyInstall#package-index-api", "scheme", ",", "netloc", ",", "path", ",", "_", ",", "_", ",", "_", "=", "urlparse", "(", "url", ")", "if", "scheme", "==", "'file'...
[ 761, 4 ]
[ 818, 21 ]
python
en
['en', 'error', 'th']
False
SimpleScrapingLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() page = self.get_page(self.base_url) if not page: raise DistlibException('Unable to get %s' % self.base_url) for match in self._distname_re...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "page", "=", "self", ".", "get_page", "(", "self", ".", "base_url", ")", "if", "not", "page", ":", "raise", "DistlibException", "(", "'Unable to get %s'", "%", "self", ...
[ 822, 4 ]
[ 832, 21 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.__init__
(self, path, **kwargs)
Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are recursed into. If False,...
Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are recursed into. If False,...
def __init__(self, path, **kwargs): """ Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are ...
[ "def", "__init__", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "self", ".", "recursive", "=", "kwargs", ".", "pop", "(", "'recursive'", ",", "True", ")", "super", "(", "DirectoryLocator", ",", "self", ")", ".", "__init__", "(", "*", ...
[ 839, 4 ]
[ 854, 28 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.should_include
(self, filename, parent)
Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation.
Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation.
def should_include(self, filename, parent): """ Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation. """ return filename.endswith(sel...
[ "def", "should_include", "(", "self", ",", "filename", ",", "parent", ")", ":", "return", "filename", ".", "endswith", "(", "self", ".", "downloadable_extensions", ")" ]
[ 856, 4 ]
[ 862, 62 ]
python
en
['en', 'error', 'th']
False
DirectoryLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() for root, dirs, files in os.walk(self.base_dir): for fn in files: if self.should_include(fn, root): fn = os.path.join(...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "base_dir", ")", ":", "for", "fn", "in", "files", ":", "if", "self", ".", ...
[ 880, 4 ]
[ 897, 21 ]
python
en
['en', 'error', 'th']
False
JSONLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Not available from this locator')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Not available from this locator'", ")" ]
[ 906, 4 ]
[ 910, 68 ]
python
en
['en', 'error', 'th']
False
DistPathLocator.__init__
(self, distpath, **kwargs)
Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search.
Initialise an instance.
def __init__(self, distpath, **kwargs): """ Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search. """ super(DistPathLocator, self).__init__(**kwargs) assert isinstance(distpath, DistributionPath) self.distpath = distpath
[ "def", "__init__", "(", "self", ",", "distpath", ",", "*", "*", "kwargs", ")", ":", "super", "(", "DistPathLocator", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "assert", "isinstance", "(", "distpath", ",", "DistributionPath", ")", ...
[ 942, 4 ]
[ 950, 32 ]
python
en
['en', 'error', 'th']
False
AggregatingLocator.__init__
(self, *locators, **kwargs)
Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful search from any of the locator...
Initialise an instance.
def __init__(self, *locators, **kwargs): """ Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful ...
[ "def", "__init__", "(", "self", ",", "*", "locators", ",", "*", "*", "kwargs", ")", ":", "self", ".", "merge", "=", "kwargs", ".", "pop", "(", "'merge'", ",", "False", ")", "self", ".", "locators", "=", "locators", "super", "(", "AggregatingLocator", ...
[ 969, 4 ]
[ 983, 58 ]
python
en
['en', 'error', 'th']
False
AggregatingLocator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ result = set() for locator in self.locators: try: result |= locator.get_distribution_names() except NotImplementedError: pass...
[ "def", "get_distribution_names", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "locator", "in", "self", ".", "locators", ":", "try", ":", "result", "|=", "locator", ".", "get_distribution_names", "(", ")", "except", "NotImplementedError", ":"...
[ 1041, 4 ]
[ 1051, 21 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.__init__
(self, locator=None)
Initialise an instance, using the specified locator to locate distributions.
Initialise an instance, using the specified locator to locate distributions.
def __init__(self, locator=None): """ Initialise an instance, using the specified locator to locate distributions. """ self.locator = locator or default_locator self.scheme = get_scheme(self.locator.scheme)
[ "def", "__init__", "(", "self", ",", "locator", "=", "None", ")", ":", "self", ".", "locator", "=", "locator", "or", "default_locator", "self", ".", "scheme", "=", "get_scheme", "(", "self", ".", "locator", ".", "scheme", ")" ]
[ 1072, 4 ]
[ 1078, 53 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.add_distribution
(self, dist)
Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add.
Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add.
def add_distribution(self, dist): """ Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add. """ logger.debug('adding distribution %s', dist) name = dist.key self.dists_by_name...
[ "def", "add_distribution", "(", "self", ",", "dist", ")", ":", "logger", ".", "debug", "(", "'adding distribution %s'", ",", "dist", ")", "name", "=", "dist", ".", "key", "self", ".", "dists_by_name", "[", "name", "]", "=", "dist", "self", ".", "dists", ...
[ 1080, 4 ]
[ 1093, 70 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.remove_distribution
(self, dist)
Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove.
Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove.
def remove_distribution(self, dist): """ Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove. """ logger.debug('removing distribution %s', dist) name = dist.key del s...
[ "def", "remove_distribution", "(", "self", ",", "dist", ")", ":", "logger", ".", "debug", "(", "'removing distribution %s'", ",", "dist", ")", "name", "=", "dist", ".", "key", "del", "self", ".", "dists_by_name", "[", "name", "]", "del", "self", ".", "di...
[ 1095, 4 ]
[ 1111, 39 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.get_matcher
(self, reqt)
Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`).
Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`).
def get_matcher(self, reqt): """ Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`). """ try: matcher = self.scheme.matcher...
[ "def", "get_matcher", "(", "self", ",", "reqt", ")", ":", "try", ":", "matcher", "=", "self", ".", "scheme", ".", "matcher", "(", "reqt", ")", "except", "UnsupportedVersionError", ":", "# pragma: no cover", "# XXX compat-mode if cannot read the version", "name", "...
[ 1113, 4 ]
[ 1127, 22 ]
python
en
['en', 'error', 'th']
False
DependencyFinder.find_providers
(self, reqt)
Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement.
Find the distributions which can fulfill a requirement.
def find_providers(self, reqt): """ Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement. """ matcher = self.get_matcher(reqt) name = matche...
[ "def", "find_providers", "(", "self", ",", "reqt", ")", ":", "matcher", "=", "self", ".", "get_matcher", "(", "reqt", ")", "name", "=", "matcher", ".", "key", "# case-insensitive", "result", "=", "set", "(", ")", "provided", "=", "self", ".", "provided",...
[ 1129, 4 ]
[ 1151, 21 ]
python
en
['en', 'error', 'th']
False