uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c4b052617fbacb74f6d499c5 | train | class | class AssetJsonView(View):
def get(self,request,*args,**kwargs):
# 数据库中获取数据
table_config = [
{
'q': None,
'title': "选项",
'display': True,
'text': {'content': "<input type='checkbox' />","kwargs": {}},
'attrs'... | class AssetJsonView(View):
| def get(self,request,*args,**kwargs):
# 数据库中获取数据
table_config = [
{
'q': None,
'title': "选项",
'display': True,
'text': {'content': "<input type='checkbox' />","kwargs": {}},
'attrs': {}
},
... | from django.shortcuts import render,HttpResponse
from django.views import View
import json
class AssetView(View):
def get(self,request,*args,**kwargs):
# 数据库中获取数据
return render(request,'asset.html')
class AssetJsonView(View):
| 56 | 256 | 855 | 6 | 50 | shuigedeng/taotao-cloud-paren | taotao-cloud-python/taotao-cloud-oldboy/day77-cmdb/day75/web/views.py | Python | AssetJsonView | AssetJsonView | 11 | 112 | 11 | 11 | d58731eb6f741dd3b8efbb294773eeae35329d25 | bigcode/the-stack | train |
383f7065db65d0ccb25b8e65 | train | class | class AssetView(View):
def get(self,request,*args,**kwargs):
# 数据库中获取数据
return render(request,'asset.html')
| class AssetView(View):
| def get(self,request,*args,**kwargs):
# 数据库中获取数据
return render(request,'asset.html')
| from django.shortcuts import render,HttpResponse
from django.views import View
import json
class AssetView(View):
| 22 | 64 | 33 | 5 | 16 | shuigedeng/taotao-cloud-paren | taotao-cloud-python/taotao-cloud-oldboy/day77-cmdb/day75/web/views.py | Python | AssetView | AssetView | 5 | 9 | 5 | 6 | 81f60da85f91464da060319b0351d3b289624605 | bigcode/the-stack | train |
db721fc52dd86068dc5b6e42 | train | class | class BuinessUnitJsonView(View):
def get(self,request,*args,**kwargs):
# 数据库中获取数据
table_config = [
{
'q': None,
'title': "选项",
'display': True,
'text': {'content': "<input type='checkbox' />","kwargs": {}},
'... | class BuinessUnitJsonView(View):
| def get(self,request,*args,**kwargs):
# 数据库中获取数据
table_config = [
{
'q': None,
'title': "选项",
'display': True,
'text': {'content': "<input type='checkbox' />","kwargs": {}},
'attrs': {}
},
... | _choices': models.Asset.device_status_choices,
'idc_choices': list(models.IDC.objects.values_list('id','name'))
},
# 分页组件生成页码信息
'pager': """<li><a>1</a></li><li><a>2</a></li><li><a>3</a></li><li><a>4</a></li><li><a>5</a></li>"""
}
return HttpResponse(... | 205 | 205 | 685 | 8 | 197 | shuigedeng/taotao-cloud-paren | taotao-cloud-python/taotao-cloud-oldboy/day77-cmdb/day75/web/views.py | Python | BuinessUnitJsonView | BuinessUnitJsonView | 120 | 207 | 120 | 120 | 13edb8907a46923a65f49f1bd1572c9ce6bdf0e3 | bigcode/the-stack | train |
6a6de2771319cb42f5e2552e | train | class | class BuinessUnitView(View):
def get(self,request,*args,**kwargs):
# 数据库中获取数据
return render(request,'business_unit.html')
| class BuinessUnitView(View):
| def get(self,request,*args,**kwargs):
# 数据库中获取数据
return render(request,'business_unit.html')
| ))
def put(self,request,*args,**kwargs):
content = request.body
v = json.loads(str(content,encoding='utf-8'))
print(v)
ret = {
'status':True
}
return HttpResponse(json.dumps(ret))
class BuinessUnitView(View):
| 64 | 64 | 36 | 7 | 57 | shuigedeng/taotao-cloud-paren | taotao-cloud-python/taotao-cloud-oldboy/day77-cmdb/day75/web/views.py | Python | BuinessUnitView | BuinessUnitView | 114 | 118 | 114 | 115 | a501b6e797502508906f1446501ff72bf87a327f | bigcode/the-stack | train |
7c07ee24bf58c469e36b9e68 | train | function | def _get_next_position(context):
"""Get the next menu entry position for the event."""
contribution_id = context.current_parameters['contribution_id']
res = (db.session.query(db.func.max(SubContribution.position))
.filter(SubContribution.contribution_id == contribution_id)
.one())
... | def _get_next_position(context):
| """Get the next menu entry position for the event."""
contribution_id = context.current_parameters['contribution_id']
res = (db.session.query(db.func.max(SubContribution.position))
.filter(SubContribution.contribution_id == contribution_id)
.one())
return (res[0] or 0) + 1
| ."""
from indico.modules.events.contributions.models.contributions import Contribution
contribution_id = context.current_parameters['contribution_id']
assert contribution_id is not None
return increment_and_get(Contribution._last_friendly_subcontribution_id, Contribution.id == contribution_id)
def _get_... | 64 | 64 | 76 | 7 | 57 | sms77io/indico | indico/modules/events/contributions/models/subcontributions.py | Python | _get_next_position | _get_next_position | 29 | 35 | 29 | 29 | 409269d90e8b6559553de090ae0ce0e763333997 | bigcode/the-stack | train |
741df9a7ffbab9bd653128b4 | train | class | class SubContribution(SearchableTitleMixin, SearchableDescriptionMixin, AttachedItemsMixin, AttachedNotesMixin,
db.Model):
__tablename__ = 'subcontributions'
__auto_table_args = (db.Index(None, 'friendly_id', 'contribution_id', unique=True),
db.CheckConstraint("dat... | class SubContribution(SearchableTitleMixin, SearchableDescriptionMixin, AttachedItemsMixin, AttachedNotesMixin,
db.Model):
| __tablename__ = 'subcontributions'
__auto_table_args = (db.Index(None, 'friendly_id', 'contribution_id', unique=True),
db.CheckConstraint("date_trunc('minute', duration) = duration", 'duration_no_seconds'),
{'schema': 'events'})
PRELOAD_EVENT_ATTACHED_ITEMS... | ico.core.db.sqlalchemy.notes import AttachedNotesMixin
from indico.core.db.sqlalchemy.searchable import SearchableTitleMixin
from indico.core.db.sqlalchemy.util.models import auto_table_args
from indico.core.db.sqlalchemy.util.queries import increment_and_get
from indico.util.locators import locator_property
from indic... | 256 | 256 | 999 | 25 | 230 | sms77io/indico | indico/modules/events/contributions/models/subcontributions.py | Python | SubContribution | SubContribution | 38 | 191 | 38 | 39 | 068cf62b9c4a888e7891486afdf03103b6408795 | bigcode/the-stack | train |
bb501c01fcc2976a7996c881 | train | function | def _get_next_friendly_id(context):
"""Get the next friendly id for a sub-contribution."""
from indico.modules.events.contributions.models.contributions import Contribution
contribution_id = context.current_parameters['contribution_id']
assert contribution_id is not None
return increment_and_get(Con... | def _get_next_friendly_id(context):
| """Get the next friendly id for a sub-contribution."""
from indico.modules.events.contributions.models.contributions import Contribution
contribution_id = context.current_parameters['contribution_id']
assert contribution_id is not None
return increment_and_get(Contribution._last_friendly_subcontribu... | ableTitleMixin
from indico.core.db.sqlalchemy.util.models import auto_table_args
from indico.core.db.sqlalchemy.util.queries import increment_and_get
from indico.util.locators import locator_property
from indico.util.string import format_repr, slugify
def _get_next_friendly_id(context):
| 64 | 64 | 78 | 9 | 54 | sms77io/indico | indico/modules/events/contributions/models/subcontributions.py | Python | _get_next_friendly_id | _get_next_friendly_id | 21 | 26 | 21 | 21 | 0cb0ffa32d09fd78c66789b3b93f636c84f283b0 | bigcode/the-stack | train |
36cac00ff21144f3be6cc1d4 | train | class | class LinkPropDlg(QtGui.QDialog, Ui_LinkPropDialog):
"""
Link properties dialog.
By loading UI files at runtime we can:
- create user interfaces at runtime (without using pyuic)
- use multiple inheritance, MyParentClass(BaseClass, FormClass)
This class displays a simple dialo... | class LinkPropDlg(QtGui.QDialog, Ui_LinkPropDialog):
| """
Link properties dialog.
By loading UI files at runtime we can:
- create user interfaces at runtime (without using pyuic)
- use multiple inheritance, MyParentClass(BaseClass, FormClass)
This class displays a simple dialog that shows some properties of
the selected link... | ables.utils
translate = QtGui.QApplication.translate
# This method of the PyQt4.uic module allows for dinamically loading user
# interfaces created by QtDesigner. See the PyQt4 Reference Guide for more
# info.
Ui_LinkPropDialog = \
loadUiType(os.path.join(os.path.dirname(__file__),'link_prop_dlg.ui'))[0]
cl... | 92 | 93 | 312 | 14 | 78 | lefevre-fraser/openmeta-mms | bin/Python27/Lib/site-packages/vitables/nodeprops/linkpropdlg.py | Python | LinkPropDlg | LinkPropDlg | 46 | 90 | 46 | 46 | d0dd210222b688af09ac4b2857781bc650689100 | bigcode/the-stack | train |
3b7f51565b5d33a63a067e17 | train | class | @pulumi.output_type
class PrivateEndpointResponse(dict):
"""
The Private Endpoint resource.
"""
def __init__(__self__, *,
id: str):
"""
The Private Endpoint resource.
:param str id: The ARM identifier for Private Endpoint
"""
pulumi.set(__self__, ... | @pulumi.output_type
class PrivateEndpointResponse(dict):
| """
The Private Endpoint resource.
"""
def __init__(__self__, *,
id: str):
"""
The Private Endpoint resource.
:param str id: The ARM identifier for Private Endpoint
"""
pulumi.set(__self__, "id", id)
@property
@pulumi.getter
def id(se... | @property
@pulumi.getter(name="privateEndpoint")
def private_endpoint(self) -> Optional['outputs.PrivateEndpointResponse']:
"""
The resource of private end point.
"""
return pulumi.get(self, "private_endpoint")
@pulumi.output_type
class PrivateEndpointResponse(dict):
| 64 | 64 | 112 | 12 | 52 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | PrivateEndpointResponse | PrivateEndpointResponse | 534 | 553 | 534 | 535 | 55d86a2831355da67146e26b06ba980740f4695d | bigcode/the-stack | train |
7ccadbe55dacd10609cd2562 | train | class | @pulumi.output_type
class DicomServiceAuthenticationConfigurationResponse(dict):
"""
Authentication configuration information
"""
def __init__(__self__, *,
audiences: Sequence[str],
authority: str):
"""
Authentication configuration information
:p... | @pulumi.output_type
class DicomServiceAuthenticationConfigurationResponse(dict):
| """
Authentication configuration information
"""
def __init__(__self__, *,
audiences: Sequence[str],
authority: str):
"""
Authentication configuration information
:param Sequence[str] audiences: The audiences for the service
:param str au... | CosmosDbConfigurationInfoResponse',
'ServiceExportConfigurationInfoResponse',
'ServiceManagedIdentityResponseIdentity',
'ServicesPropertiesResponse',
'ServicesResourceResponseIdentity',
'SystemDataResponse',
'WorkspaceResponseProperties',
]
@pulumi.output_type
class DicomServiceAuthenticationCon... | 64 | 64 | 188 | 15 | 49 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | DicomServiceAuthenticationConfigurationResponse | DicomServiceAuthenticationConfigurationResponse | 38 | 68 | 38 | 39 | c0f14ccdbdd7ecaba92e741238181ddb8de1eb9f | bigcode/the-stack | train |
c97c2f0bbcc873cb414dc3f0 | train | class | @pulumi.output_type
class PrivateEndpointConnectionResponse(dict):
"""
The Private Endpoint Connection resource.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "privateLinkServiceConnectionState":
suggest = "private_link_service_connection_state"
... | @pulumi.output_type
class PrivateEndpointConnectionResponse(dict):
| """
The Private Endpoint Connection resource.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "privateLinkServiceConnectionState":
suggest = "private_link_service_connection_state"
elif key == "provisioningState":
suggest = "pro... | pulumi.get(self, "consumer_group")
@property
@pulumi.getter(name="eventHubName")
def event_hub_name(self) -> Optional[str]:
"""
Event Hub name to connect to.
"""
return pulumi.get(self, "event_hub_name")
@property
@pulumi.getter(name="fullyQualifiedEventHubNamespac... | 256 | 256 | 858 | 13 | 243 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | PrivateEndpointConnectionResponse | PrivateEndpointConnectionResponse | 435 | 531 | 435 | 436 | 558f4c5e032fcbc0742c004de8488cdba0b5d141 | bigcode/the-stack | train |
dc42ea4bf03301ae419c6f42 | train | class | @pulumi.output_type
class FhirServiceCorsConfigurationResponse(dict):
"""
The settings for the CORS configuration of the service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "allowCredentials":
suggest = "allow_credentials"
eli... | @pulumi.output_type
class FhirServiceCorsConfigurationResponse(dict):
| """
The settings for the CORS configuration of the service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "allowCredentials":
suggest = "allow_credentials"
elif key == "maxAge":
suggest = "max_age"
if suggest... | self__, "audience", audience)
if authority is not None:
pulumi.set(__self__, "authority", authority)
if smart_proxy_enabled is not None:
pulumi.set(__self__, "smart_proxy_enabled", smart_proxy_enabled)
@property
@pulumi.getter
def audience(self) -> Optional[str]:
... | 207 | 207 | 693 | 15 | 192 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | FhirServiceCorsConfigurationResponse | FhirServiceCorsConfigurationResponse | 214 | 301 | 214 | 215 | 39fba212fcb95ab342f55077e4c85f61dec7bfa1 | bigcode/the-stack | train |
1c0c5e2c9ebf7cb99c69b98a | train | class | @pulumi.output_type
class FhirServiceExportConfigurationResponse(dict):
"""
Export operation configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "storageAccountName":
suggest = "storage_account_name"
if suggest:
... | @pulumi.output_type
class FhirServiceExportConfigurationResponse(dict):
| """
Export operation configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "storageAccountName":
suggest = "storage_account_name"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in FhirServiceExportConfi... | ]]:
"""
The methods to be allowed via CORS.
"""
return pulumi.get(self, "methods")
@property
@pulumi.getter
def origins(self) -> Optional[Sequence[str]]:
"""
The origins to be allowed via CORS.
"""
return pulumi.get(self, "origins")
@pulumi.ou... | 87 | 87 | 293 | 15 | 72 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | FhirServiceExportConfigurationResponse | FhirServiceExportConfigurationResponse | 304 | 341 | 304 | 305 | a894cc115ee10b684df2535881fa828b49e47563 | bigcode/the-stack | train |
851095f69ddb3b03ade1be30 | train | class | @pulumi.output_type
class ServiceExportConfigurationInfoResponse(dict):
"""
Export operation configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "storageAccountName":
suggest = "storage_account_name"
if suggest:
... | @pulumi.output_type
class ServiceExportConfigurationInfoResponse(dict):
| """
Export operation configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "storageAccountName":
suggest = "storage_account_name"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in ServiceExportConfigura... | .
"""
return pulumi.get(self, "key_vault_key_uri")
@property
@pulumi.getter(name="offerThroughput")
def offer_throughput(self) -> Optional[int]:
"""
The provisioned throughput for the backing database.
"""
return pulumi.get(self, "offer_throughput")
@pulumi.o... | 86 | 86 | 289 | 14 | 72 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceExportConfigurationInfoResponse | ServiceExportConfigurationInfoResponse | 907 | 944 | 907 | 908 | e3c5990e76f9d681997f4f570764d4b38c76ae9d | bigcode/the-stack | train |
6a5338181db0f64bfbffa7ca | train | class | @pulumi.output_type
class ServiceCosmosDbConfigurationInfoResponse(dict):
"""
The settings for the Cosmos DB database backing the service.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "keyVaultKeyUri":
suggest = "key_vault_key_uri"
elif ... | @pulumi.output_type
class ServiceCosmosDbConfigurationInfoResponse(dict):
| """
The settings for the Cosmos DB database backing the service.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "keyVaultKeyUri":
suggest = "key_vault_key_uri"
elif key == "offerThroughput":
suggest = "offer_throughput"
... | -> Optional[int]:
"""
The max age to be allowed via CORS.
"""
return pulumi.get(self, "max_age")
@property
@pulumi.getter
def methods(self) -> Optional[Sequence[str]]:
"""
The methods to be allowed via CORS.
"""
return pulumi.get(self, "metho... | 139 | 139 | 464 | 16 | 123 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceCosmosDbConfigurationInfoResponse | ServiceCosmosDbConfigurationInfoResponse | 853 | 904 | 853 | 854 | 4f21abc5271f2549cadbba866771034dce87487b | bigcode/the-stack | train |
5ee79cf1e861483ca9c40a44 | train | class | @pulumi.output_type
class ServiceAcrConfigurationInfoResponse(dict):
"""
Azure container registry configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "loginServers":
suggest = "login_servers"
if suggest:
p... | @pulumi.output_type
class ServiceAcrConfigurationInfoResponse(dict):
| """
Azure container registry configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "loginServers":
suggest = "login_servers"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in ServiceAcrConfigurationInfo... | umi.set(__self__, "object_id", object_id)
@property
@pulumi.getter(name="objectId")
def object_id(self) -> str:
"""
An Azure AD object ID (User or Apps) that is allowed access to the FHIR service.
"""
return pulumi.get(self, "object_id")
@pulumi.output_type
class ServiceAcrC... | 87 | 87 | 291 | 15 | 72 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceAcrConfigurationInfoResponse | ServiceAcrConfigurationInfoResponse | 659 | 696 | 659 | 660 | 54ccadf2d28a2538b99a0aa5a4f5694315e02519 | bigcode/the-stack | train |
1584c993cd1746e3d75255be | train | class | @pulumi.output_type
class FhirServiceAuthenticationConfigurationResponse(dict):
"""
Authentication configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "smartProxyEnabled":
suggest = "smart_proxy_enabled"
if suggest:
... | @pulumi.output_type
class FhirServiceAuthenticationConfigurationResponse(dict):
| """
Authentication configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "smartProxyEnabled":
suggest = "smart_proxy_enabled"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in FhirServiceAuthenticationC... | init__(__self__, *,
login_servers: Optional[Sequence[str]] = None):
"""
Azure container registry configuration information
:param Sequence[str] login_servers: The list of the Azure container registry login servers.
"""
if login_servers is not None:
pu... | 138 | 138 | 463 | 15 | 123 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | FhirServiceAuthenticationConfigurationResponse | FhirServiceAuthenticationConfigurationResponse | 150 | 211 | 150 | 151 | dccee36898068ae1a7a850c985e9d19da228d823 | bigcode/the-stack | train |
9e71ef7d42da6887d6033090 | train | class | @pulumi.output_type
class ServiceCorsConfigurationInfoResponse(dict):
"""
The settings for the CORS configuration of the service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "allowCredentials":
suggest = "allow_credentials"
eli... | @pulumi.output_type
class ServiceCorsConfigurationInfoResponse(dict):
| """
The settings for the CORS configuration of the service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "allowCredentials":
suggest = "allow_credentials"
elif key == "maxAge":
suggest = "max_age"
if suggest... | self__, "audience", audience)
if authority is not None:
pulumi.set(__self__, "authority", authority)
if smart_proxy_enabled is not None:
pulumi.set(__self__, "smart_proxy_enabled", smart_proxy_enabled)
@property
@pulumi.getter
def audience(self) -> Optional[str]:
... | 206 | 206 | 689 | 14 | 192 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceCorsConfigurationInfoResponse | ServiceCorsConfigurationInfoResponse | 763 | 850 | 763 | 764 | 20d5c4291cbb1661a6b7b5cfa514b18e68ee39d8 | bigcode/the-stack | train |
bf85a648bc9141b90e0d9f2e | train | class | @pulumi.output_type
class SystemDataResponse(dict):
"""
Metadata pertaining to creation and last modification of the resource.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "createdAt":
suggest = "created_at"
elif key == "createdBy":
... | @pulumi.output_type
class SystemDataResponse(dict):
| """
Metadata pertaining to creation and last modification of the resource.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "createdAt":
suggest = "created_at"
elif key == "createdBy":
suggest = "created_by"
elif key == "... | it.
:param str principal_id: The principal ID of the resource identity.
:param str tenant_id: The tenant ID of the resource.
:param str type: Type of identity being specified, currently SystemAssigned and None are allowed.
"""
pulumi.set(__self__, "principal_id", principal_id)
... | 256 | 256 | 892 | 12 | 244 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | SystemDataResponse | SystemDataResponse | 1,185 | 1,292 | 1,185 | 1,186 | 56522dc172ddf528bd2123ced2197ab7b502478d | bigcode/the-stack | train |
b48e505d4de226991a67821d | train | class | @pulumi.output_type
class FhirServiceAcrConfigurationResponse(dict):
"""
Azure container registry configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "loginServers":
suggest = "login_servers"
if suggest:
p... | @pulumi.output_type
class FhirServiceAcrConfigurationResponse(dict):
| """
Azure container registry configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "loginServers":
suggest = "login_servers"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in FhirServiceAcrConfiguration... | pulumi.set(__self__, "object_id", object_id)
@property
@pulumi.getter(name="objectId")
def object_id(self) -> str:
"""
An Azure AD object ID (User or Apps) that is allowed access to the FHIR service.
"""
return pulumi.get(self, "object_id")
@pulumi.output_type
class FhirSer... | 89 | 89 | 297 | 16 | 73 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | FhirServiceAcrConfigurationResponse | FhirServiceAcrConfigurationResponse | 110 | 147 | 110 | 111 | 5f25b7b5f6c6fea702069f28b87dc34f088a2a4f | bigcode/the-stack | train |
960bd83fbc2f856e0c040ff2 | train | class | @pulumi.output_type
class ServicesResourceResponseIdentity(dict):
"""
Setting indicating whether the service has a managed identity associated with it.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "principalId":
suggest = "principal_id"
... | @pulumi.output_type
class ServicesResourceResponseIdentity(dict):
| """
Setting indicating whether the service has a managed identity associated with it.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "principalId":
suggest = "principal_id"
elif key == "tenantId":
suggest = "tenant_id"
... | ")
@property
@pulumi.getter(name="privateEndpointConnections")
def private_endpoint_connections(self) -> Optional[Sequence['outputs.PrivateEndpointConnectionResponse']]:
"""
The list of private endpoint connections that are set up for this resource.
"""
return pulumi.get(sel... | 140 | 140 | 469 | 13 | 127 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServicesResourceResponseIdentity | ServicesResourceResponseIdentity | 1,121 | 1,182 | 1,121 | 1,122 | c5724d23b8d80898850cc18d17b92a028344ed25 | bigcode/the-stack | train |
226a1e0f161f3d9430e22963 | train | class | @pulumi.output_type
class ServicesPropertiesResponse(dict):
"""
The properties of a service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "provisioningState":
suggest = "provisioning_state"
elif key == "accessPolicies":
... | @pulumi.output_type
class ServicesPropertiesResponse(dict):
| """
The properties of a service instance.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "provisioningState":
suggest = "provisioning_state"
elif key == "accessPolicies":
suggest = "access_policies"
elif key == "acrConf... | name of the default export storage account.
"""
if storage_account_name is not None:
pulumi.set(__self__, "storage_account_name", storage_account_name)
@property
@pulumi.getter(name="storageAccountName")
def storage_account_name(self) -> Optional[str]:
"""
The n... | 256 | 256 | 1,399 | 12 | 244 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServicesPropertiesResponse | ServicesPropertiesResponse | 970 | 1,118 | 970 | 971 | ce0233021a92ae4b317e53ff5a27554e21521e71 | bigcode/the-stack | train |
68515b384f2ef4b2fa7ded66 | train | class | @pulumi.output_type
class ServiceManagedIdentityResponseIdentity(dict):
"""
Setting indicating whether the service has a managed identity associated with it.
"""
def __init__(__self__, *,
type: Optional[str] = None):
"""
Setting indicating whether the service has a manag... | @pulumi.output_type
class ServiceManagedIdentityResponseIdentity(dict):
| """
Setting indicating whether the service has a managed identity associated with it.
"""
def __init__(__self__, *,
type: Optional[str] = None):
"""
Setting indicating whether the service has a managed identity associated with it.
:param str type: Type of identit... |
@pulumi.getter(name="storageAccountName")
def storage_account_name(self) -> Optional[str]:
"""
The name of the default export storage account.
"""
return pulumi.get(self, "storage_account_name")
@pulumi.output_type
class ServiceManagedIdentityResponseIdentity(dict):
| 64 | 64 | 156 | 14 | 50 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceManagedIdentityResponseIdentity | ServiceManagedIdentityResponseIdentity | 947 | 967 | 947 | 948 | 9f5838e15a416c650555318afddf5a734e1432f0 | bigcode/the-stack | train |
0a0d4ca777d17a644ca735bf | train | class | @pulumi.output_type
class IotMappingPropertiesResponse(dict):
"""
The mapping content.
"""
def __init__(__self__, *,
content: Optional[Any] = None):
"""
The mapping content.
:param Any content: The mapping.
"""
if content is not None:
... | @pulumi.output_type
class IotMappingPropertiesResponse(dict):
| """
The mapping content.
"""
def __init__(__self__, *,
content: Optional[Any] = None):
"""
The mapping content.
:param Any content: The mapping.
"""
if content is not None:
pulumi.set(__self__, "content", content)
@property
@p... | HubNamespace")
def fully_qualified_event_hub_namespace(self) -> Optional[str]:
"""
Fully qualified namespace of the Event Hub to connect to.
"""
return pulumi.get(self, "fully_qualified_event_hub_namespace")
@pulumi.output_type
class IotMappingPropertiesResponse(dict):
| 64 | 64 | 116 | 14 | 50 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | IotMappingPropertiesResponse | IotMappingPropertiesResponse | 412 | 432 | 412 | 413 | b2f2e7c9013cafbe053f37e286c60b12f434571e | bigcode/the-stack | train |
6d48042cfaf7ecee64738e64 | train | class | @pulumi.output_type
class ServiceAuthenticationConfigurationInfoResponse(dict):
"""
Authentication configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "smartProxyEnabled":
suggest = "smart_proxy_enabled"
if suggest:
... | @pulumi.output_type
class ServiceAuthenticationConfigurationInfoResponse(dict):
| """
Authentication configuration information
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "smartProxyEnabled":
suggest = "smart_proxy_enabled"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in ServiceAuthenticationConfi... | def __init__(__self__, *,
login_servers: Optional[Sequence[str]] = None):
"""
Azure container registry configuration information
:param Sequence[str] login_servers: The list of the ACR login servers.
"""
if login_servers is not None:
pulumi.set(__sel... | 137 | 137 | 459 | 14 | 123 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceAuthenticationConfigurationInfoResponse | ServiceAuthenticationConfigurationInfoResponse | 699 | 760 | 699 | 700 | cc0ed48f2fc546e7889a4939296d49a3cdf2ca82 | bigcode/the-stack | train |
75c566925a8c04f464c18b5a | train | class | @pulumi.output_type
class IotEventHubIngestionEndpointConfigurationResponse(dict):
"""
Event Hub ingestion endpoint configuration
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "consumerGroup":
suggest = "consumer_group"
elif key == "event... | @pulumi.output_type
class IotEventHubIngestionEndpointConfigurationResponse(dict):
| """
Event Hub ingestion endpoint configuration
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "consumerGroup":
suggest = "consumer_group"
elif key == "eventHubName":
suggest = "event_hub_name"
elif key == "fullyQualifie... | , key: str, default = None) -> Any:
FhirServiceExportConfigurationResponse.__key_warning(key)
return super().get(key, default)
def __init__(__self__, *,
storage_account_name: Optional[str] = None):
"""
Export operation configuration information
:param str st... | 176 | 176 | 589 | 18 | 158 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | IotEventHubIngestionEndpointConfigurationResponse | IotEventHubIngestionEndpointConfigurationResponse | 344 | 409 | 344 | 345 | 245a64f50923d51091ecd07d2ed38563b6bdc1d3 | bigcode/the-stack | train |
8b7b3c003deb91fe8fbac539 | train | class | @pulumi.output_type
class ServiceAccessPolicyEntryResponse(dict):
"""
An access policy entry.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "objectId":
suggest = "object_id"
if suggest:
pulumi.log.warn(f"Key '{key}' not found... | @pulumi.output_type
class ServiceAccessPolicyEntryResponse(dict):
| """
An access policy entry.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "objectId":
suggest = "object_id"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in ServiceAccessPolicyEntryResponse. Access the value via the '{s... | approval/rejection of the connection.
"""
return pulumi.get(self, "description")
@property
@pulumi.getter
def status(self) -> Optional[str]:
"""
Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.
"""
return pulum... | 86 | 86 | 288 | 14 | 72 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | ServiceAccessPolicyEntryResponse | ServiceAccessPolicyEntryResponse | 620 | 656 | 620 | 621 | ef0d4add61426ca8b69ad14e379716d4cf569cd3 | bigcode/the-stack | train |
7ec37cada86e94affcb66f89 | train | class | @pulumi.output_type
class FhirServiceAccessPolicyEntryResponse(dict):
"""
An access policy entry.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "objectId":
suggest = "object_id"
if suggest:
pulumi.log.warn(f"Key '{key}' not f... | @pulumi.output_type
class FhirServiceAccessPolicyEntryResponse(dict):
| """
An access policy entry.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "objectId":
suggest = "object_id"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in FhirServiceAccessPolicyEntryResponse. Access the value via the... | def audiences(self) -> Sequence[str]:
"""
The audiences for the service
"""
return pulumi.get(self, "audiences")
@property
@pulumi.getter
def authority(self) -> str:
"""
The authority url for the service
"""
return pulumi.get(self, "author... | 88 | 88 | 296 | 16 | 72 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | FhirServiceAccessPolicyEntryResponse | FhirServiceAccessPolicyEntryResponse | 71 | 107 | 71 | 72 | 34e4bf8f8c4c3717ef42fa46e9163ba0943ef9fa | bigcode/the-stack | train |
b66e0f8a9f73194c7430f3b0 | train | class | @pulumi.output_type
class PrivateLinkServiceConnectionStateResponse(dict):
"""
A collection of information about the state of the connection between service consumer and provider.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "actionsRequired":
s... | @pulumi.output_type
class PrivateLinkServiceConnectionStateResponse(dict):
| """
A collection of information about the state of the connection between service consumer and provider.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "actionsRequired":
suggest = "actions_required"
if suggest:
pulumi.log.war... | EndpointResponse']:
"""
The resource of private end point.
"""
return pulumi.get(self, "private_endpoint")
@pulumi.output_type
class PrivateEndpointResponse(dict):
"""
The Private Endpoint resource.
"""
def __init__(__self__, *,
id: str):
"""
... | 153 | 153 | 513 | 15 | 138 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | PrivateLinkServiceConnectionStateResponse | PrivateLinkServiceConnectionStateResponse | 556 | 617 | 556 | 557 | d439b60a93f2e5bf8af28ae76dcf63f2ba6608b8 | bigcode/the-stack | train |
2581aabfaec939e573f31c6a | train | class | @pulumi.output_type
class WorkspaceResponseProperties(dict):
"""
Workspaces resource specific properties.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "provisioningState":
suggest = "provisioning_state"
if suggest:
pulumi.lo... | @pulumi.output_type
class WorkspaceResponseProperties(dict):
| """
Workspaces resource specific properties.
"""
@staticmethod
def __key_warning(key: str):
suggest = None
if key == "provisioningState":
suggest = "provisioning_state"
if suggest:
pulumi.log.warn(f"Key '{key}' not found in WorkspaceResponseProperties... | umi.get(self, "last_modified_by")
@property
@pulumi.getter(name="lastModifiedByType")
def last_modified_by_type(self) -> Optional[str]:
"""
The type of identity that last modified the resource.
"""
return pulumi.get(self, "last_modified_by_type")
@pulumi.output_type
class Wo... | 78 | 78 | 260 | 12 | 66 | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/healthcareapis/v20210601preview/outputs.py | Python | WorkspaceResponseProperties | WorkspaceResponseProperties | 1,295 | 1,331 | 1,295 | 1,296 | 1f488850deea192350fa310d94ffe23693413244 | bigcode/the-stack | train |
4b59d6dda7420b395983b242 | train | function | def main():
# create the application window
win = GraphWin('Dice Roller')
win.setCoords(0, 0, 10, 10)
win.setBackground('green2')
# draw the interface widgets
die1 = DieView(win, Point(3, 7), 2)
die2 = DieView(win, Point(7, 7), 2)
roll_button = Button(win, Point(5, 4.5), 6, 1, 'Roll Dic... | def main():
# create the application window
| win = GraphWin('Dice Roller')
win.setCoords(0, 0, 10, 10)
win.setBackground('green2')
# draw the interface widgets
die1 = DieView(win, Point(3, 7), 2)
die2 = DieView(win, Point(7, 7), 2)
roll_button = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
roll_button.activate()
quit_button =... | ip2.setFill(self.foreground)
self.pip3.setFill(self.foreground)
self.pip5.setFill(self.foreground)
self.pip6.setFill(self.foreground)
self.pip7.setFill(self.foreground)
def set_color(self, color):
self.foreground = color
self.set_value(self.value)
def... | 84 | 85 | 285 | 10 | 74 | alirkaya/programming-textbook-solutions | john_zelle_python3/roller_color_dice.py | Python | main | main | 142 | 172 | 142 | 143 | f3614d0288499c6d6ecdb924744ad8da7d2ec452 | bigcode/the-stack | train |
2ff595ddaa73990b546bfea2 | train | class | class DieView:
""" DieView is a widget that displays a graphical representation of a standard six-sided die. """
def __init__(self, win, center, size):
""" Create a view of a die, e.g."
d1 = DieView(my_win, Point(40, 50), 20)
creates a die centered at (40, 50) having sides
of le... | class DieView:
| """ DieView is a widget that displays a graphical representation of a standard six-sided die. """
def __init__(self, win, center, size):
""" Create a view of a die, e.g."
d1 = DieView(my_win, Point(40, 50), 20)
creates a die centered at (40, 50) having sides
of length 20. """
... | _max, self.x_min = x + w, x - w
self.y_max, self.y_min = y + h, y - h
p1 = Point(self.x_min, self.y_min)
p2 = Point(self.x_max, self.y_max)
self.rect = Rectangle(p1, p2)
self.rect.setFill('lightgray')
self.rect.draw(win)
self.label = Text(center, label)
se... | 256 | 256 | 911 | 4 | 251 | alirkaya/programming-textbook-solutions | john_zelle_python3/roller_color_dice.py | Python | DieView | DieView | 49 | 139 | 49 | 49 | 58173883a75fdbec3cf27859b6c10e7ec86d639e | bigcode/the-stack | train |
17f9b0b651cc1c8810656250 | train | class | class Button:
"""A button is a labeled rectangle in a window .
It is activated or deactivated with the activate()
and deactivate() methods. The clicked (p) method
returns true if the button is active and p is inside it."""
def __init__(self, win, center, width, height, label):
""" Creates a... | class Button:
| """A button is a labeled rectangle in a window .
It is activated or deactivated with the activate()
and deactivate() methods. The clicked (p) method
returns true if the button is active and p is inside it."""
def __init__(self, win, center, width, height, label):
""" Creates a rectangular b... | from random import randrange, randint
from graphics import *
class Button:
| 15 | 115 | 384 | 3 | 12 | alirkaya/programming-textbook-solutions | john_zelle_python3/roller_color_dice.py | Python | Button | Button | 5 | 46 | 5 | 5 | 373cd20bc309443da3d3293a6384bb67f6e46f62 | bigcode/the-stack | train |
353fc01ffa8d33b85dda50d9 | train | class | class GenericFormTemplate(GatewayForm):
# When updating the form, remember to make the corresponding changes to the workflow pages
workflow_name = 'delete_text_record_example'
workflow_permission = 'delete_text_record_example_page'
configuration = Configuration(
workflow_name=workflow_name,
... | class GenericFormTemplate(GatewayForm):
# When updating the form, remember to make the corresponding changes to the workflow pages
| workflow_name = 'delete_text_record_example'
workflow_permission = 'delete_text_record_example_page'
configuration = Configuration(
workflow_name=workflow_name,
permissions=workflow_permission,
label='Configuration',
required=True,
coerce=int,
validators=[],
... | # Copyright 2017 BlueCat Networks. All rights reserved.
from wtforms import SubmitField
from bluecat.wtform_fields import Configuration, View, Zone, CustomStringField, CustomSearchButtonField, \
FilteredSelectField, PlainHTML
from bluecat.wtform_extensions import GatewayForm
from bluecat.server_endpoints import ge... | 102 | 137 | 458 | 26 | 75 | glennmcallister/gateway-workflows | Examples/Text Record/delete_text_record_example/delete_text_record_example_form.py | Python | GenericFormTemplate | GenericFormTemplate | 10 | 87 | 10 | 11 | 177715429d95ec482e0493e980f81eb6f8f5c21b | bigcode/the-stack | train |
97d8dd7380bd7c2ed795b60d | train | function | def get_tokens_at_position(node: HasTokens, position: Position) -> List[Token]:
return [t for t in node.tokens if position.is_in_range(range := range_from_token(t)) or range.end == position]
| def get_tokens_at_position(node: HasTokens, position: Position) -> List[Token]:
| return [t for t in node.tokens if position.is_in_range(range := range_from_token(t)) or range.end == position]
| ) -> str:
s = str(token.value)
result = ""
for c in s:
if c in [" ", "\t"]:
result += c
else:
break
return result
def get_tokens_at_position(node: HasTokens, position: Position) -> List[Token]:
| 64 | 64 | 46 | 19 | 44 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | get_tokens_at_position | get_tokens_at_position | 173 | 174 | 173 | 173 | a61ea0bd72a3785af1604ff806d7b5bf33aa91f1 | bigcode/the-stack | train |
ca5c741cf5e96fd18b607df3 | train | function | def iter_nodes(node: ast.AST) -> Generator[ast.AST, None, None]:
for _field, value in ast.iter_fields(node):
if isinstance(value, list):
for item in value:
if isinstance(item, ast.AST):
yield item
yield from iter_nodes(item)
elif i... | def iter_nodes(node: ast.AST) -> Generator[ast.AST, None, None]:
| for _field, value in ast.iter_fields(node):
if isinstance(value, list):
for item in value:
if isinstance(item, ast.AST):
yield item
yield from iter_nodes(item)
elif isinstance(value, ast.AST):
yield value
y... | AsyncIterator,
Generator,
Iterator,
List,
Optional,
Protocol,
Tuple,
runtime_checkable,
)
from ...common.types import Position, Range
from .async_ast import walk
def iter_nodes(node: ast.AST) -> Generator[ast.AST, None, None]:
| 64 | 64 | 85 | 20 | 43 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | iter_nodes | iter_nodes | 20 | 31 | 20 | 20 | 7d5f11765f42405688bf8314ed2f09f86814b20f | bigcode/the-stack | train |
e125f1dbf4c993af154443e9 | train | class | @runtime_checkable
class Statement(Protocol):
def get_token(self, type: str) -> Token:
...
def get_tokens(self, *types: str) -> Tuple[Token, ...]:
...
def get_value(self, type: str, default: Any = None) -> Any:
...
def get_values(self, *types: str) -> Tuple[Any, ...]:
... | @runtime_checkable
class Statement(Protocol):
| def get_token(self, type: str) -> Token:
...
def get_tokens(self, *types: str) -> Tuple[Token, ...]:
...
def get_value(self, type: str, default: Any = None) -> Any:
...
def get_values(self, *types: str) -> Tuple[Any, ...]:
...
@property
def lineno(self) -> int... | _checkable
class HasTokens(Protocol):
tokens: Tuple[Token, ...]
@runtime_checkable
class HasError(Protocol):
error: Optional[str]
@runtime_checkable
class HasErrors(Protocol):
errors: Optional[List[str]]
@runtime_checkable
class Statement(Protocol):
| 63 | 64 | 146 | 10 | 53 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | Statement | Statement | 75 | 103 | 75 | 76 | 98aa237c5dc93ecf17394f3821e13e2d584c8e9b | bigcode/the-stack | train |
7f1fc19db8b15805b8b935e0 | train | function | def iter_nodes_at_position(node: ast.AST, position: Position) -> AsyncIterator[ast.AST]:
return (n async for n in walk(node) if position.is_in_range(range := range_from_node(n)) or range.end == position)
| def iter_nodes_at_position(node: ast.AST, position: Position) -> AsyncIterator[ast.AST]:
| return (n async for n in walk(node) if position.is_in_range(range := range_from_node(n)) or range.end == position)
| (node: HasTokens, position: Position) -> List[Token]:
return [t for t in node.tokens if position.is_in_range(range := range_from_token(t)) or range.end == position]
def iter_nodes_at_position(node: ast.AST, position: Position) -> AsyncIterator[ast.AST]:
| 64 | 64 | 52 | 23 | 41 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | iter_nodes_at_position | iter_nodes_at_position | 177 | 178 | 177 | 177 | 12c7bcc2e48de85a678a5933cb207ef79313d718 | bigcode/the-stack | train |
003e55785ea836f91563674e | train | function | def whitespace_at_begin_of_token(token: Token) -> int:
s = str(token.value)
result = 0
for c in s:
if c == " ":
result += 1
elif c == "\t":
result += 2
else:
break
return result
| def whitespace_at_begin_of_token(token: Token) -> int:
| s = str(token.value)
result = 0
for c in s:
if c == " ":
result += 1
elif c == "\t":
result += 2
else:
break
return result
| from robot.errors import VariableError
try:
r = list(token.tokenize_variables())
if len(r) == 1 and r[0] == token:
return True
except VariableError:
pass
return False
def whitespace_at_begin_of_token(token: Token) -> int:
| 64 | 64 | 68 | 13 | 50 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | whitespace_at_begin_of_token | whitespace_at_begin_of_token | 146 | 157 | 146 | 146 | bb594d670178f77838c9cb51707556aa1da3c750 | bigcode/the-stack | train |
f52b53123b9c2f6dda605016 | train | function | def _tokenize_no_variables(token: Token) -> Generator[Token, None, None]:
yield token
| def _tokenize_no_variables(token: Token) -> Generator[Token, None, None]:
| yield token
| ast.AST, position: Position) -> Optional[ast.AST]:
result_nodes = await get_nodes_at_position(node, position)
if not result_nodes:
return None
return result_nodes[-1]
def _tokenize_no_variables(token: Token) -> Generator[Token, None, None]:
| 64 | 64 | 23 | 19 | 45 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | _tokenize_no_variables | _tokenize_no_variables | 193 | 194 | 193 | 193 | 7c21dfef9c851c595011937bd7194afc8944148d | bigcode/the-stack | train |
64d40abd64a39edb669cf444 | train | function | def is_non_variable_token(token: Token) -> bool:
from robot.errors import VariableError
try:
r = list(token.tokenize_variables())
if len(r) == 1 and r[0] == token:
return True
except VariableError:
pass
return False
| def is_non_variable_token(token: Token) -> bool:
| from robot.errors import VariableError
try:
r = list(token.tokenize_variables())
if len(r) == 1 and r[0] == token:
return True
except VariableError:
pass
return False
| _from_token_or_node(node: ast.AST, token: Optional[Token]) -> Range:
if token is not None:
return range_from_token(token)
if node is not None:
return range_from_node(node)
return Range.zero()
def is_non_variable_token(token: Token) -> bool:
| 64 | 64 | 64 | 12 | 52 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | is_non_variable_token | is_non_variable_token | 134 | 143 | 134 | 134 | a9b9b2bb8d1e02ee612e9febc103f24958a62371 | bigcode/the-stack | train |
9bad93ea435e15107877e768 | train | class | @runtime_checkable
class HasError(Protocol):
error: Optional[str]
| @runtime_checkable
class HasError(Protocol):
| error: Optional[str]
| : Optional[str]
@property
def end_col_offset(self) -> int:
...
def tokenize_variables(self) -> Iterator[Token]:
...
@runtime_checkable
class HasTokens(Protocol):
tokens: Tuple[Token, ...]
@runtime_checkable
class HasError(Protocol):
| 64 | 64 | 17 | 11 | 53 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | HasError | HasError | 65 | 67 | 65 | 66 | 14b55aadafa3646ac7dd15229b0c922ba0e4d2aa | bigcode/the-stack | train |
f6af2edfa2ab6464a5e46199 | train | function | def whitespace_from_begin_of_token(token: Token) -> str:
s = str(token.value)
result = ""
for c in s:
if c in [" ", "\t"]:
result += c
else:
break
return result
| def whitespace_from_begin_of_token(token: Token) -> str:
| s = str(token.value)
result = ""
for c in s:
if c in [" ", "\t"]:
result += c
else:
break
return result
| (token.value)
result = 0
for c in s:
if c == " ":
result += 1
elif c == "\t":
result += 2
else:
break
return result
def whitespace_from_begin_of_token(token: Token) -> str:
| 64 | 64 | 54 | 13 | 50 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | whitespace_from_begin_of_token | whitespace_from_begin_of_token | 160 | 170 | 160 | 160 | 134e2488649e1594cd2a1419bcbb26395f201a4e | bigcode/the-stack | train |
9e3e9a8eb5e90fa017a73e62 | train | class | @runtime_checkable
class HasTokens(Protocol):
tokens: Tuple[Token, ...]
| @runtime_checkable
class HasTokens(Protocol):
| tokens: Tuple[Token, ...]
| ]
value: str
lineno: int
col_offset: int
error: Optional[str]
@property
def end_col_offset(self) -> int:
...
def tokenize_variables(self) -> Iterator[Token]:
...
@runtime_checkable
class HasTokens(Protocol):
| 64 | 64 | 20 | 11 | 53 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | HasTokens | HasTokens | 60 | 62 | 60 | 61 | 5d79aceda396fd3c1d9d2628d7a3b873d0d85fb6 | bigcode/the-stack | train |
94deac0a8642d386227aa79e | train | class | @runtime_checkable
class Token(Protocol):
type: Optional[str]
value: str
lineno: int
col_offset: int
error: Optional[str]
@property
def end_col_offset(self) -> int:
...
def tokenize_variables(self) -> Iterator[Token]:
...
| @runtime_checkable
class Token(Protocol):
| type: Optional[str]
value: str
lineno: int
col_offset: int
error: Optional[str]
@property
def end_col_offset(self) -> int:
...
def tokenize_variables(self) -> Iterator[Token]:
...
| 1, character=node.col_offset),
end=Position(
line=node.end_lineno - 1 if node.end_lineno is not None else -1,
character=node.end_col_offset if node.end_col_offset is not None else -1,
),
)
@runtime_checkable
class Token(Protocol):
| 64 | 64 | 68 | 10 | 54 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | Token | Token | 44 | 57 | 44 | 45 | 005e60faada57cbcd1e82e729b731f1146777b54 | bigcode/the-stack | train |
681bb345f8e5e9fca8df7500 | train | function | def node_in_range(node: ast.AST, range: Range) -> bool:
node_range = range_from_node(node)
return node_range.start.is_in_range(range) or node_range.end.is_in_range(range)
| def node_in_range(node: ast.AST, range: Range) -> bool:
| node_range = range_from_node(node)
return node_range.start.is_in_range(range) or node_range.end.is_in_range(range)
| ),
)
def token_in_range(token: Token, range: Range) -> bool:
token_range = range_from_token(token)
return token_range.start.is_in_range(range) or token_range.end.is_in_range(range)
def node_in_range(node: ast.AST, range: Range) -> bool:
| 64 | 64 | 45 | 17 | 47 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | node_in_range | node_in_range | 121 | 123 | 121 | 121 | 2aa1385cf3a3c793f8d7ba6481dbb500cc6538e6 | bigcode/the-stack | train |
38eb037fce319c9bd873bab7 | train | function | async def get_node_at_position(node: ast.AST, position: Position) -> Optional[ast.AST]:
result_nodes = await get_nodes_at_position(node, position)
if not result_nodes:
return None
return result_nodes[-1]
| async def get_node_at_position(node: ast.AST, position: Position) -> Optional[ast.AST]:
| result_nodes = await get_nodes_at_position(node, position)
if not result_nodes:
return None
return result_nodes[-1]
| )
async def get_nodes_at_position(node: ast.AST, position: Position) -> List[ast.AST]:
return [n async for n in iter_nodes_at_position(node, position)]
async def get_node_at_position(node: ast.AST, position: Position) -> Optional[ast.AST]:
| 63 | 64 | 53 | 23 | 40 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | get_node_at_position | get_node_at_position | 185 | 190 | 185 | 185 | d2a48b34ccea22464aecc734bf3158bd069e888c | bigcode/the-stack | train |
46f9b3803e91a8d02d028161 | train | function | def range_from_node(node: ast.AST) -> Range:
return Range(
start=Position(line=node.lineno - 1, character=node.col_offset),
end=Position(
line=node.end_lineno - 1 if node.end_lineno is not None else -1,
character=node.end_col_offset if node.end_col_offset is not None else -1,... | def range_from_node(node: ast.AST) -> Range:
| return Range(
start=Position(line=node.lineno - 1, character=node.col_offset),
end=Position(
line=node.end_lineno - 1 if node.end_lineno is not None else -1,
character=node.end_col_offset if node.end_col_offset is not None else -1,
),
)
| isinstance(value, list):
for item in value:
if isinstance(item, ast.AST):
yield item
yield from iter_nodes(item)
elif isinstance(value, ast.AST):
yield value
yield from iter_nodes(value)
def range_from_node(node: ast.... | 64 | 64 | 80 | 13 | 51 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | range_from_node | range_from_node | 34 | 41 | 34 | 34 | 7c5a4bc060dfcd742a558f55bb54dce59b7bc6c2 | bigcode/the-stack | train |
870199dcb2ee4f9b0a9766d5 | train | class | @runtime_checkable
class HasErrors(Protocol):
errors: Optional[List[str]]
| @runtime_checkable
class HasErrors(Protocol):
| errors: Optional[List[str]]
| :
...
def tokenize_variables(self) -> Iterator[Token]:
...
@runtime_checkable
class HasTokens(Protocol):
tokens: Tuple[Token, ...]
@runtime_checkable
class HasError(Protocol):
error: Optional[str]
@runtime_checkable
class HasErrors(Protocol):
| 64 | 64 | 18 | 11 | 53 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | HasErrors | HasErrors | 70 | 72 | 70 | 71 | f41e3f94f39436559d68bfd1eff1dc43abc4ef97 | bigcode/the-stack | train |
00753bb975375bf30ac58782 | train | function | def range_from_token_or_node(node: ast.AST, token: Optional[Token]) -> Range:
if token is not None:
return range_from_token(token)
if node is not None:
return range_from_node(node)
return Range.zero()
| def range_from_token_or_node(node: ast.AST, token: Optional[Token]) -> Range:
| if token is not None:
return range_from_token(token)
if node is not None:
return range_from_node(node)
return Range.zero()
| _in_range(node: ast.AST, range: Range) -> bool:
node_range = range_from_node(node)
return node_range.start.is_in_range(range) or node_range.end.is_in_range(range)
def range_from_token_or_node(node: ast.AST, token: Optional[Token]) -> Range:
| 64 | 64 | 54 | 21 | 43 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | range_from_token_or_node | range_from_token_or_node | 126 | 131 | 126 | 126 | 187bc623259077dce758f2bd46b7ea3e2ee22a7d | bigcode/the-stack | train |
56444bbe7ef5d505fc6b936d | train | function | def range_from_token(token: Token) -> Range:
return Range(
start=Position(line=token.lineno - 1, character=token.col_offset),
end=Position(
line=token.lineno - 1,
character=token.end_col_offset,
),
)
| def range_from_token(token: Token) -> Range:
| return Range(
start=Position(line=token.lineno - 1, character=token.col_offset),
end=Position(
line=token.lineno - 1,
character=token.end_col_offset,
),
)
| (self) -> int:
...
@property
def col_offset(self) -> int:
...
@property
def end_lineno(self) -> int:
...
@property
def end_col_offset(self) -> int:
...
def range_from_token(token: Token) -> Range:
| 64 | 64 | 61 | 11 | 53 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | range_from_token | range_from_token | 106 | 113 | 106 | 106 | 18d8f298486615eac591c25892b8a8a8e456b3e0 | bigcode/the-stack | train |
15d4b24eafbcbb4eb3113297 | train | function | def token_in_range(token: Token, range: Range) -> bool:
token_range = range_from_token(token)
return token_range.start.is_in_range(range) or token_range.end.is_in_range(range)
| def token_in_range(token: Token, range: Range) -> bool:
| token_range = range_from_token(token)
return token_range.start.is_in_range(range) or token_range.end.is_in_range(range)
| return Range(
start=Position(line=token.lineno - 1, character=token.col_offset),
end=Position(
line=token.lineno - 1,
character=token.end_col_offset,
),
)
def token_in_range(token: Token, range: Range) -> bool:
| 64 | 64 | 43 | 15 | 49 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | token_in_range | token_in_range | 116 | 118 | 116 | 116 | 9b7f5f8a2dc2403c3b18b22119696605db59bc66 | bigcode/the-stack | train |
0e5fa35ef90a5f8d6c4197c0 | train | function | def tokenize_variables(
token: Token, identifiers: str = "$@&%", ignore_errors: bool = False
) -> Generator[Token, Any, Any]:
from robot.api.parsing import Token as RobotToken
from robot.variables import VariableIterator
if token.type not in {*RobotToken.ALLOW_VARIABLES, RobotToken.KEYWORD, RobotToken.... | def tokenize_variables(
token: Token, identifiers: str = "$@&%", ignore_errors: bool = False
) -> Generator[Token, Any, Any]:
| from robot.api.parsing import Token as RobotToken
from robot.variables import VariableIterator
if token.type not in {*RobotToken.ALLOW_VARIABLES, RobotToken.KEYWORD, RobotToken.ASSIGN}:
return _tokenize_no_variables(token)
variables = VariableIterator(token.value, identifiers=identifiers, ignor... | return result_nodes[-1]
def _tokenize_no_variables(token: Token) -> Generator[Token, None, None]:
yield token
def tokenize_variables(
token: Token, identifiers: str = "$@&%", ignore_errors: bool = False
) -> Generator[Token, Any, Any]:
| 64 | 64 | 132 | 34 | 29 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | tokenize_variables | tokenize_variables | 197 | 208 | 197 | 199 | 2b256a13010cf942d32154490e729535a94f68f8 | bigcode/the-stack | train |
8b0489b097470af45d065c95 | train | function | async def get_nodes_at_position(node: ast.AST, position: Position) -> List[ast.AST]:
return [n async for n in iter_nodes_at_position(node, position)]
| async def get_nodes_at_position(node: ast.AST, position: Position) -> List[ast.AST]:
| return [n async for n in iter_nodes_at_position(node, position)]
| position: Position) -> AsyncIterator[ast.AST]:
return (n async for n in walk(node) if position.is_in_range(range := range_from_node(n)) or range.end == position)
async def get_nodes_at_position(node: ast.AST, position: Position) -> List[ast.AST]:
| 64 | 64 | 39 | 23 | 41 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | get_nodes_at_position | get_nodes_at_position | 181 | 182 | 181 | 181 | 4cceb75077ca1cccda85694117779de1b9c20626 | bigcode/the-stack | train |
6abd06bd4664827214492002 | train | function | def _tokenize_variables(token: Token, variables: Any) -> Generator[Token, Any, Any]:
from robot.api.parsing import Token as RobotToken
lineno = token.lineno
col_offset = token.col_offset
remaining = ""
for before, variable, remaining in variables:
if before:
yield RobotToken(tok... | def _tokenize_variables(token: Token, variables: Any) -> Generator[Token, Any, Any]:
| from robot.api.parsing import Token as RobotToken
lineno = token.lineno
col_offset = token.col_offset
remaining = ""
for before, variable, remaining in variables:
if before:
yield RobotToken(token.type, before, lineno, col_offset)
col_offset += len(before)
yi... | variables = VariableIterator(token.value, identifiers=identifiers, ignore_errors=ignore_errors)
if not variables:
return _tokenize_no_variables(token)
return _tokenize_variables(token, variables)
def _tokenize_variables(token: Token, variables: Any) -> Generator[Token, Any, Any]:
| 64 | 64 | 135 | 22 | 42 | d-biehl/robotcode | robotcode/language_server/robotframework/utils/ast.py | Python | _tokenize_variables | _tokenize_variables | 211 | 224 | 211 | 211 | 4c236d06ced91b3e9c76f21af61926ada2e40b17 | bigcode/the-stack | train |
4a06cb272d99c6d2e385a0b4 | train | class | class Product(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
| class Product(models.Model):
| name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
| from django.db import models
class Product(models.Model):
| 11 | 64 | 28 | 5 | 5 | FrancesMaffyValor/DownGit | A/B/C/D/E/F/G/H/3/product/models.py | Python | Product | Product | 3 | 7 | 3 | 3 | 67ef04f00a410b6cd275ecb472985b41051b26f8 | bigcode/the-stack | train |
022cc68cb6a2e70739b7c9ba | train | function | def main():
num_events = 40
line_length = 200
attributes_count = 3
add_events_request = generate_add_events_request(
num_events=num_events,
line_length=line_length,
attributes_count=attributes_count,
base_body=BASE_BODY,
)
add_events_data = add_events_request.get... | def main():
| num_events = 40
line_length = 200
attributes_count = 3
add_events_request = generate_add_events_request(
num_events=num_events,
line_length=line_length,
attributes_count=attributes_count,
base_body=BASE_BODY,
)
add_events_data = add_events_request.get_payload()
... | SCALYR_URL is not None
if not SCALYR_URL.endswith("/addEvents"):
SCALYR_URL += "/addEvents"
BASE_HEADERS = {
"Content-Type": "application/json",
}
BASE_BODY = {"token": SCALYR_TOKEN, "session": "session", "threads": []}
def main():
| 68 | 68 | 227 | 3 | 65 | zkanda/scalyr-agent-2 | scripts/test_send_compressed_data.py | Python | main | main | 49 | 79 | 49 | 49 | 03e7182bb88e3bebc1a21aeaf43bfca7bdf5ed38 | bigcode/the-stack | train |
35dd9774ead5af5d31073efd | train | function | @callback
def setup_cors(app, origins):
"""Set up CORS."""
# This import should remain here. That way the HTTP integration can always
# be imported by other integrations without it's requirements being installed.
import aiohttp_cors
cors = aiohttp_cors.setup(
app,
defaults={
... | @callback
def setup_cors(app, origins):
| """Set up CORS."""
# This import should remain here. That way the HTTP integration can always
# be imported by other integrations without it's requirements being installed.
import aiohttp_cors
cors = aiohttp_cors.setup(
app,
defaults={
host: aiohttp_cors.ResourceOptions(... | AUTHORIZATION
from homeassistant.const import HTTP_HEADER_X_REQUESTED_WITH
from homeassistant.core import callback
# mypy: allow-untyped-defs, no-check-untyped-defs
ALLOWED_CORS_HEADERS = [
ORIGIN,
ACCEPT,
HTTP_HEADER_X_REQUESTED_WITH,
CONTENT_TYPE,
AUTHORIZATION,
]
VALID_CORS_TYPES = (Resource... | 95 | 95 | 318 | 11 | 84 | tecknicaltom/home-assistant | homeassistant/components/http/cors.py | Python | setup_cors | setup_cors | 21 | 78 | 21 | 22 | 42611a346a42ed57837581ed866e2b2be0a7952c | bigcode/the-stack | train |
3b85aaf782753a086edb49a6 | train | function | def clear_task_instances(tis,
session,
activate_dag_runs=True,
dag=None,
):
"""
Clears a set of task instances, but makes sure the running ones
get killed.
:param tis: a list of task instances
:param... | def clear_task_instances(tis,
session,
activate_dag_runs=True,
dag=None,
):
| """
Clears a set of task instances, but makes sure the running ones
get killed.
:param tis: a list of task instances
:param session: current session
:param activate_dag_runs: flag to check for active dag run
:param dag: DAG object
"""
job_ids = []
for ti in tis:
if ti.st... | import Sentry
from airflow.stats import Stats
from airflow.ti_deps.dep_context import DepContext
from airflow.ti_deps.dependencies import REQUEUEABLE_DEPS, RUNNING_DEPS
from airflow.utils import timezone
from airflow.utils.email import send_email
from airflow.utils.helpers import is_container
from airflow.utils.log.lo... | 150 | 150 | 501 | 23 | 126 | IGIT-CN/airflow | airflow/models/taskinstance.py | Python | clear_task_instances | clear_task_instances | 66 | 123 | 66 | 70 | ebb327b0e6f0c30120319df95a427f77f97ccded | bigcode/the-stack | train |
b5055ab94cb8332d602c8958 | train | class | class TaskInstance(Base, LoggingMixin):
"""
Task instances store the state of a task instance. This table is the
authority and single source of truth around what tasks have run and the
state they are in.
The SqlAlchemy model doesn't have a SqlAlchemy foreign key to the task or
dag model deliber... | class TaskInstance(Base, LoggingMixin):
| """
Task instances store the state of a task instance. This table is the
authority and single source of truth around what tasks have run and the
state they are in.
The SqlAlchemy model doesn't have a SqlAlchemy foreign key to the task or
dag model deliberately to have more control over transact... | all reschedules related to the ti to clear
TR = TaskReschedule
session.query(TR).filter(
TR.dag_id == ti.dag_id,
TR.task_id == ti.task_id,
TR.execution_date == ti.execution_date,
TR.try_number == ti.try_number
).delete()
if job_ids:
f... | 256 | 256 | 11,973 | 8 | 248 | IGIT-CN/airflow | airflow/models/taskinstance.py | Python | TaskInstance | TaskInstance | 131 | 1,555 | 131 | 131 | 2cd3fc410dd116237dcd9b903155c7ea72bbf665 | bigcode/the-stack | train |
e1a4dd4b13ef1f6656fdbc7b | train | class | class SimpleTaskInstance:
"""
Simplified Task Instance.
Used to send data between processes via Queues.
"""
def __init__(self, ti: TaskInstance):
self._dag_id: str = ti.dag_id
self._task_id: str = ti.task_id
self._execution_date: datetime = ti.execution_date
self._st... | class SimpleTaskInstance:
| """
Simplified Task Instance.
Used to send data between processes via Queues.
"""
def __init__(self, ti: TaskInstance):
self._dag_id: str = ti.dag_id
self._task_id: str = ti.task_id
self._execution_date: datetime = ti.execution_date
self._start_date: datetime = ti.st... | and_(TI.dag_id == dag_id,
TI.task_id == task_id,
TI.execution_date == execution_date)
for dag_id, task_id, execution_date, _ in tis])
return or_(*filter_for_tis)
if all(isinstance(t, TaskInstance) ... | 197 | 197 | 659 | 5 | 192 | IGIT-CN/airflow | airflow/models/taskinstance.py | Python | SimpleTaskInstance | SimpleTaskInstance | 1,563 | 1,660 | 1,563 | 1,563 | d35eb2f17864d1189b142a6e2540392c8e44d009 | bigcode/the-stack | train |
b6ce03fbe639ab4c349b0e72 | train | function | def main():
png_images = []
for p in Path("s3://elevation-tiles-prod/normal/10/963").iterdir():
if p.suffix != ".png":
continue
png_images.append(p)
if 3 < len(png_images):
break
for input_path in png_images:
if OUTPUT_BUCKET != "":
outpu... | def main():
| png_images = []
for p in Path("s3://elevation-tiles-prod/normal/10/963").iterdir():
if p.suffix != ".png":
continue
png_images.append(p)
if 3 < len(png_images):
break
for input_path in png_images:
if OUTPUT_BUCKET != "":
output_path = Pat... | from paaaaath import Path
OUTPUT_BUCKET = "" # fill output bucket name
def main():
| 21 | 64 | 132 | 3 | 17 | ar90n/paaaaath | examples/s3.py | Python | main | main | 6 | 22 | 6 | 6 | da0ce8778b11c8b6118ec1a58f8c1993cf2b5a59 | bigcode/the-stack | train |
5ed57573a41c27d135b69d43 | train | function | @keep_lazy_text
def urlquote_plus(url, safe=''):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
"""
return quote_plus(url, safe)
| @keep_lazy_text
def urlquote_plus(url, safe=''):
| """
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
"""
return quote_plus(url, safe)
| @keep_lazy_text
def urlquote(url, safe='/'):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
"""
return quote(url, safe)
@keep_lazy_text
def urlquote_plus(url, safe=''):
| 64 | 64 | 53 | 14 | 50 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlquote_plus | urlquote_plus | 56 | 62 | 56 | 57 | 8915e3f534744943e860b2d7619f180af4e8ef78 | bigcode/the-stack | train |
be81500211d0b3c8a72e3203 | train | function | def _is_safe_url(url, allowed_hosts, require_https=False):
# Chrome considers any URL with more than two slashes to be absolute, but
# urlparse is not so flexible. Treat any url with three slashes as unsafe.
if url.startswith('///'):
return False
try:
url_info = _urlparse(url)
except... | def _is_safe_url(url, allowed_hosts, require_https=False):
# Chrome considers any URL with more than two slashes to be absolute, but
# urlparse is not so flexible. Treat any url with three slashes as unsafe.
| if url.startswith('///'):
return False
try:
url_info = _urlparse(url)
except ValueError: # e.g. invalid IPv6 addresses
return False
# Forbid URLs like http:///example.com - with a scheme, but without a hostname.
# In that URL, example.com is not the hostname but, a path comp... | ('#', 1)
if '?' in url:
url, query = url.split('?', 1)
v = SplitResult(scheme, netloc, url, query, fragment)
return _coerce_result(v)
def _is_safe_url(url, allowed_hosts, require_https=False):
# Chrome considers any URL with more than two slashes to be absolute, but
# urlparse is not so flex... | 99 | 99 | 332 | 51 | 48 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | _is_safe_url | _is_safe_url | 368 | 394 | 368 | 370 | 9943446a7dca461bdf8395e23e32ea187b1c73d9 | bigcode/the-stack | train |
450cb9c199de8224d69cecd0 | train | function | def is_safe_url(url, allowed_hosts, require_https=False):
"""
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to
a different host and uses a safe scheme).
Always return ``False`` on an empty url.
If ``require_https`` is ``True``, only 'https' will be considered a valid
... | def is_safe_url(url, allowed_hosts, require_https=False):
| """
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to
a different host and uses a safe scheme).
Always return ``False`` on an empty url.
If ``require_https`` is ``True``, only 'https' will be considered a valid
scheme, as opposed to 'http' and 'https' with the default,... | string match.
"""
if not pattern:
return False
pattern = pattern.lower()
return (
pattern[0] == '.' and (host.endswith(pattern) or host == pattern[1:]) or
pattern == host
)
def is_safe_url(url, allowed_hosts, require_https=False):
| 66 | 66 | 222 | 13 | 53 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | is_safe_url | is_safe_url | 295 | 316 | 295 | 295 | 6032be78648c32550cf6a9047363f7d1f7f682ab | bigcode/the-stack | train |
713e8d37745e4b50f6b55eb6 | train | function | @keep_lazy_text
def urlquote(url, safe='/'):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
"""
return quote(url, safe)
| @keep_lazy_text
def urlquote(url, safe='/'):
| """
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
"""
return quote(url, safe)
| M, __D2, __T, __Y))
RFC3986_GENDELIMS = ":/?#[]@"
RFC3986_SUBDELIMS = "!$&'()*+,;="
FIELDS_MATCH = re.compile('[&;]')
@keep_lazy_text
def urlquote(url, safe='/'):
| 63 | 64 | 50 | 13 | 51 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlquote | urlquote | 47 | 53 | 47 | 48 | e520c1c28428adddea68bc06588282624506fd9c | bigcode/the-stack | train |
36b1c13bea76efea76efd32e | train | function | def parse_etags(etag_str):
"""
Parse a string of ETags given in an If-None-Match or If-Match header as
defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags
should be matched.
"""
if etag_str.strip() == '*':
return ['*']
else:
# Parse each ETag individuall... | def parse_etags(etag_str):
| """
Parse a string of ETags given in an If-None-Match or If-Match header as
defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags
should be matched.
"""
if etag_str.strip() == '*':
return ['*']
else:
# Parse each ETag individually, and return any that are ... | """
s = s.encode()
try:
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
except (LookupError, BinasciiError) as e:
raise ValueError(e)
def parse_etags(etag_str):
| 64 | 64 | 138 | 8 | 56 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | parse_etags | parse_etags | 251 | 262 | 251 | 251 | ba7ac8fc2d61cb14005846575c0568873e8338b1 | bigcode/the-stack | train |
49634634f985404c45c18169 | train | function | def _urlparse(url, scheme='', allow_fragments=True):
"""Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string)... | def _urlparse(url, scheme='', allow_fragments=True):
| """Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes."""
url, scheme, _... | is_safe_url(url, allowed_hosts, require_https=require_https) and
_is_safe_url(url.replace('\\', '/'), allowed_hosts, require_https=require_https))
# Copied from urllib.parse.urlparse() but uses fixed urlsplit() function.
def _urlparse(url, scheme='', allow_fragments=True):
| 64 | 64 | 201 | 13 | 51 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | _urlparse | _urlparse | 320 | 334 | 320 | 320 | c1b4712ba07c41684482ff99f8b8c62518630963 | bigcode/the-stack | train |
dc701bcc95131701f06d069c | train | function | def urlsafe_base64_encode(s):
"""
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
"""
return base64.urlsafe_b64encode(s).rstrip(b'\n=').decode('ascii')
| def urlsafe_base64_encode(s):
| """
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
"""
return base64.urlsafe_b64encode(s).rstrip(b'\n=').decode('ascii')
| input.")
if i < 36:
return char_set[i]
b36 = ''
while i != 0:
i, n = divmod(i, 36)
b36 = char_set[n] + b36
return b36
def urlsafe_base64_encode(s):
| 64 | 64 | 56 | 8 | 55 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlsafe_base64_encode | urlsafe_base64_encode | 231 | 236 | 231 | 231 | 06384efe1322b8f9338f34a90d638580ee34a4b8 | bigcode/the-stack | train |
104767ed7222480dd9e8561b | train | function | def parse_http_date(date):
"""
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Return an integer expressed in seconds since the epoch, in UTC.
"""
# email.utils.parse... | def parse_http_date(date):
| """
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Return an integer expressed in seconds since the epoch, in UTC.
"""
# email.utils.parsedate() does the job for RFC... | 1 section 7.1.1.1.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to the current time.
Output a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'.
"""
return formatdate(epoch_second... | 96 | 96 | 322 | 6 | 90 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | parse_http_date | parse_http_date | 156 | 189 | 156 | 156 | 8ea2a4cb4e45c897fb3883435422b833080dfb5b | bigcode/the-stack | train |
72f97ded3e3532ba82e4b4a4 | train | function | def urlencode(query, doseq=False):
"""
A version of Python's urllib.parse.urlencode() function that can operate on
MultiValueDict and non-string values.
"""
if isinstance(query, MultiValueDict):
query = query.lists()
elif hasattr(query, 'items'):
query = query.items()
query_p... | def urlencode(query, doseq=False):
| """
A version of Python's urllib.parse.urlencode() function that can operate on
MultiValueDict and non-string values.
"""
if isinstance(query, MultiValueDict):
query = query.lists()
elif hasattr(query, 'items'):
query = query.items()
query_params = []
for key, value in qu... | (was used for unicode handling on Python 2)
"""
return unquote(quoted_url)
@keep_lazy_text
def urlunquote_plus(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
"""
return unquote_plus(quoted_ur... | 85 | 85 | 285 | 8 | 77 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlencode | urlencode | 83 | 120 | 83 | 83 | 534c4f2bb4791d359334b6b6b38872393b4183ca | bigcode/the-stack | train |
41bb883bf2554a6ecb33d3fb | train | function | def base36_to_int(s):
"""
Convert a base 36 string to an int. Raise ValueError if the input won't fit
into an int.
"""
# To prevent overconsumption of server resources, reject any
# base36 string that is longer than 13 base36 digits (13 digits
# is sufficient to base36-encode any 64-bit inte... | def base36_to_int(s):
| """
Convert a base 36 string to an int. Raise ValueError if the input won't fit
into an int.
"""
# To prevent overconsumption of server resources, reject any
# base36 string that is longer than 13 base36 digits (13 digits
# is sufficient to base36-encode any 64-bit integer)
if len(s) > 1... |
def parse_http_date_safe(date):
"""
Same as parse_http_date, but return None if the input is invalid.
"""
try:
return parse_http_date(date)
except Exception:
pass
# Base 36 functions: useful for generating compact URLs
def base36_to_int(s):
| 64 | 64 | 111 | 7 | 56 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | base36_to_int | base36_to_int | 204 | 214 | 204 | 204 | 6124d7d5eed356434f84fcab4a118a4e5ed943d1 | bigcode/the-stack | train |
e31cb3d5c6258e44c836b60d | train | function | def escape_leading_slashes(url):
"""
If redirecting to an absolute path (two leading slashes), a slash must be
escaped to prevent browsers from handling the path as schemaless and
redirecting to another host.
"""
if url.startswith('//'):
url = '/%2F{}'.format(url[2:])
return url
| def escape_leading_slashes(url):
| """
If redirecting to an absolute path (two leading slashes), a slash must be
escaped to prevent browsers from handling the path as schemaless and
redirecting to another host.
"""
if url.startswith('//'):
url = '/%2F{}'.format(url[2:])
return url
| ' ')
name = unquote(name, encoding=encoding, errors=errors)
value = nv[1].replace('+', ' ')
value = unquote(value, encoding=encoding, errors=errors)
r.append((name, value))
return r
def escape_leading_slashes(url):
| 64 | 64 | 76 | 8 | 55 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | escape_leading_slashes | escape_leading_slashes | 450 | 458 | 450 | 450 | 528ed78f31a21fe0165fb2da5d437dc5f0acbb43 | bigcode/the-stack | train |
6f41c8770c3dc795ed08be78 | train | function | def cookie_date(epoch_seconds=None):
"""
Format the time to ensure compatibility with Netscape's cookie standard.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to the current time.
Ou... | def cookie_date(epoch_seconds=None):
| """
Format the time to ensure compatibility with Netscape's cookie standard.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to the current time.
Output a string in the format 'Wdy, DD-... | 'mean to pass an empty string or omit the value?'
)
elif not isinstance(item, bytes):
item = str(item)
query_val.append(item)
query_params.append((key, query_val))
return original_urlencode(qu... | 64 | 64 | 181 | 7 | 57 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | cookie_date | cookie_date | 123 | 139 | 123 | 123 | 80b361df8b4c378c126f3c859807673b0489dff1 | bigcode/the-stack | train |
f02b5bb64c9a6b3b381137de | train | function | def quote_etag(etag_str):
"""
If the provided string is already a quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
"""
if ETAG_MATCH.match(etag_str):
return etag_str
else:
return '"%s"' % etag_str
| def quote_etag(etag_str):
| """
If the provided string is already a quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
"""
if ETAG_MATCH.match(etag_str):
return etag_str
else:
return '"%s"' % etag_str
| # Parse each ETag individually, and return any that are valid.
etag_matches = (ETAG_MATCH.match(etag.strip()) for etag in etag_str.split(','))
return [match.group(1) for match in etag_matches if match]
def quote_etag(etag_str):
| 64 | 64 | 74 | 8 | 56 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | quote_etag | quote_etag | 265 | 273 | 265 | 265 | 90b95cba0652742ae5cd311a72deee04c7ac07fd | bigcode/the-stack | train |
ed0b91005f233a01bbe7b8ae | train | function | def is_same_domain(host, pattern):
"""
Return ``True`` if the host is either an exact match or a match
to the wildcard pattern.
Any pattern beginning with a period matches a domain and all of its
subdomains. (e.g. ``.example.com`` matches ``example.com`` and
``foo.example.com``). Anything else ... | def is_same_domain(host, pattern):
| """
Return ``True`` if the host is either an exact match or a match
to the wildcard pattern.
Any pattern beginning with a period matches a domain and all of its
subdomains. (e.g. ``.example.com`` matches ``example.com`` and
``foo.example.com``). Anything else is an exact string match.
"""
... | quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
"""
if ETAG_MATCH.match(etag_str):
return etag_str
else:
return '"%s"' % etag_str
def is_same_domain(host, pattern):
| 64 | 64 | 133 | 8 | 55 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | is_same_domain | is_same_domain | 276 | 292 | 276 | 276 | 8405fea85e0e81bad38527ea4bfafd013bdbc75b | bigcode/the-stack | train |
24c9e6adab52a19243cabff8 | train | function | def _urlsplit(url, scheme='', allow_fragments=True):
"""Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't exp... | def _urlsplit(url, scheme='', allow_fragments=True):
| """Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes."""
url, scheme, _coerce_result = _... | uses_params and ';' in url:
url, params = _splitparams(url)
else:
params = ''
result = ParseResult(scheme, netloc, url, params, query, fragment)
return _coerce_result(result)
# Copied from urllib.parse.urlsplit() with
# https://github.com/python/cpython/pull/661 applied.
def _urlsplit(url... | 90 | 90 | 303 | 13 | 77 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | _urlsplit | _urlsplit | 339 | 365 | 339 | 339 | 7ac7aeb1640d3c0f6a5784515c9208c0b59fcf3c | bigcode/the-stack | train |
b2edab6c6c12b4dda15caa14 | train | function | @keep_lazy_text
def urlunquote_plus(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
"""
return unquote_plus(quoted_url)
| @keep_lazy_text
def urlunquote_plus(quoted_url):
| """
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
"""
return unquote_plus(quoted_url)
| _lazy_text
def urlunquote(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
"""
return unquote(quoted_url)
@keep_lazy_text
def urlunquote_plus(quoted_url):
| 64 | 64 | 55 | 14 | 50 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlunquote_plus | urlunquote_plus | 74 | 80 | 74 | 75 | 4d4e2d8911242469b7247b7df4a3f21d15df22b2 | bigcode/the-stack | train |
16f81a57af860a814bbd45aa | train | function | def parse_http_date_safe(date):
"""
Same as parse_http_date, but return None if the input is invalid.
"""
try:
return parse_http_date(date)
except Exception:
pass
| def parse_http_date_safe(date):
| """
Same as parse_http_date, but return None if the input is invalid.
"""
try:
return parse_http_date(date)
except Exception:
pass
| (m.group('sec'))
result = datetime.datetime(year, month, day, hour, min, sec)
return calendar.timegm(result.utctimetuple())
except Exception as exc:
raise ValueError("%r is not a valid date" % date) from exc
def parse_http_date_safe(date):
| 64 | 64 | 44 | 7 | 56 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | parse_http_date_safe | parse_http_date_safe | 192 | 199 | 192 | 192 | b3d340bec2504ac89cab9234c64cfdb69655d57e | bigcode/the-stack | train |
43490ca2cfea012cf9afad84 | train | function | def int_to_base36(i):
"""Convert an integer to a base36 string."""
char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
if i < 0:
raise ValueError("Negative base36 conversion input.")
if i < 36:
return char_set[i]
b36 = ''
while i != 0:
i, n = divmod(i, 36)
b36 = cha... | def int_to_base36(i):
| """Convert an integer to a base36 string."""
char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
if i < 0:
raise ValueError("Negative base36 conversion input.")
if i < 36:
return char_set[i]
b36 = ''
while i != 0:
i, n = divmod(i, 36)
b36 = char_set[n] + b36
ret... | string that is longer than 13 base36 digits (13 digits
# is sufficient to base36-encode any 64-bit integer)
if len(s) > 13:
raise ValueError("Base36 input too large")
return int(s, 36)
def int_to_base36(i):
| 64 | 64 | 101 | 7 | 57 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | int_to_base36 | int_to_base36 | 217 | 228 | 217 | 217 | 6712844c7004c78d18798a8e5bc241ddfe266042 | bigcode/the-stack | train |
7a10d60244f825fd60e7ef40 | train | function | def http_date(epoch_seconds=None):
"""
Format the time to match the RFC1123 date format as specified by HTTP
RFC7231 section 7.1.1.1.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to t... | def http_date(epoch_seconds=None):
| """
Format the time to match the RFC1123 date format as specified by HTTP
RFC7231 section 7.1.1.1.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to the current time.
Output a stri... | InDjango30Warning, stacklevel=2,
)
rfcdate = formatdate(epoch_seconds)
return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25])
def http_date(epoch_seconds=None):
| 64 | 64 | 119 | 7 | 57 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | http_date | http_date | 142 | 153 | 142 | 142 | 4cbe1ee4525f9f651ec9ad1c292fdc10135dfc7a | bigcode/the-stack | train |
acd5ec0e43d00af74ee0f63c | train | function | @keep_lazy_text
def urlunquote(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
"""
return unquote(quoted_url)
| @keep_lazy_text
def urlunquote(quoted_url):
| """
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
"""
return unquote(quoted_url)
| _lazy_text
def urlquote_plus(url, safe=''):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
"""
return quote_plus(url, safe)
@keep_lazy_text
def urlunquote(quoted_url):
| 64 | 64 | 52 | 13 | 51 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlunquote | urlunquote | 65 | 71 | 65 | 66 | 8f36fe6b1a9aba147122ef0abfefb57245b130d8 | bigcode/the-stack | train |
fafa70e5d255c4c446e4b2aa | train | function | def urlsafe_base64_decode(s):
"""
Decode a base64 encoded string. Add back any trailing equal signs that
might have been stripped.
"""
s = s.encode()
try:
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
except (LookupError, BinasciiError) as e:
raise Value... | def urlsafe_base64_decode(s):
| """
Decode a base64 encoded string. Add back any trailing equal signs that
might have been stripped.
"""
s = s.encode()
try:
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
except (LookupError, BinasciiError) as e:
raise ValueError(e)
| def urlsafe_base64_encode(s):
"""
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
"""
return base64.urlsafe_b64encode(s).rstrip(b'\n=').decode('ascii')
def urlsafe_base64_decode(s):
| 64 | 64 | 89 | 8 | 56 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | urlsafe_base64_decode | urlsafe_base64_decode | 239 | 248 | 239 | 239 | 61bbe32e356daae8b7769aca816fb4e5ac4d6f98 | bigcode/the-stack | train |
2df943cf1d4a2d21d277d5a0 | train | function | def limited_parse_qsl(qs, keep_blank_values=False, encoding='utf-8',
errors='replace', fields_limit=None):
"""
Return a list of key/value tuples parsed from query string.
Copied from urlparse with an additional "fields_limit" argument.
Copyright (C) 2013 Python Software Foundation... | def limited_parse_qsl(qs, keep_blank_values=False, encoding='utf-8',
errors='replace', fields_limit=None):
| """
Return a list of key/value tuples parsed from query string.
Copied from urlparse with an additional "fields_limit" argument.
Copyright (C) 2013 Python Software Foundation (see LICENSE.python).
Arguments:
qs: percent-encoded query string to be parsed
keep_blank_values: flag indicating... | ':
return False
scheme = url_info.scheme
# Consider URLs without a scheme (e.g. //example.com/p) to be http.
if not url_info.scheme and url_info.netloc:
scheme = 'http'
valid_schemes = ['https'] if require_https else ['http', 'https']
return ((not url_info.netloc or url_info.netloc i... | 128 | 128 | 427 | 28 | 100 | Boring-Mind/DjangoGirls1 | lib/python3.7/site-packages/django/utils/http.py | Python | limited_parse_qsl | limited_parse_qsl | 397 | 447 | 397 | 398 | eecbf13bdb9c995a93eea542e329dbcd6b25875a | bigcode/the-stack | train |
f5fb0012e3d4270cb2d3a998 | train | class | class DirectoryService(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_m... | class DirectoryService(object):
| """
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute ... | # coding: utf-8
"""
Pure Storage FlashBlade REST 1.10 Python SDK
Pure Storage FlashBlade REST 1.10 Python SDK, developed by [Pure Storage, Inc](http://www.purestorage.com/). Documentations can be found at [purity-fb.readthedocs.io](http://purity-fb.readthedocs.io/).
OpenAPI spec version: 1.10
Contact... | 137 | 256 | 2,571 | 5 | 131 | mabdelhafez/purity_fb_python_client | purity_fb/purity_fb_1dot10/models/directory_service.py | Python | DirectoryService | DirectoryService | 19 | 455 | 19 | 19 | 96fa237cafbc450ef64cb752145df56832e38e46 | bigcode/the-stack | train |
26d3363bae72351772ffc3a2 | train | class | class FdFind(Package):
"""A simple, fast and user-friendly alternative to 'find'."""
homepage = "https://github.com/sharkdp/fd"
url = "https://github.com/sharkdp/fd/archive/v7.3.0.tar.gz"
version('7.4.0', sha256='33570ba65e7f8b438746cb92bb9bc4a6030b482a0d50db37c830c4e315877537')
depends_on('... | class FdFind(Package):
| """A simple, fast and user-friendly alternative to 'find'."""
homepage = "https://github.com/sharkdp/fd"
url = "https://github.com/sharkdp/fd/archive/v7.3.0.tar.gz"
version('7.4.0', sha256='33570ba65e7f8b438746cb92bb9bc4a6030b482a0d50db37c830c4e315877537')
depends_on('rust')
def install... | # Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class FdFind(Package):
| 61 | 64 | 146 | 7 | 54 | player1537-forks/spack | var/spack/repos/builtin/packages/fd-find/package.py | Python | FdFind | FdFind | 9 | 21 | 9 | 9 | d36eff9bc4f11dd2872d633e98a73494c8ef0cb9 | bigcode/the-stack | train |
ecd35afd5316054afb5c050b | train | class | class TimeoutConfig:
"""
Timeout values.
"""
def __init__(
self,
timeout: TimeoutTypes = None,
*,
connect_timeout: float = None,
read_timeout: float = None,
write_timeout: float = None,
):
if timeout is None:
self.connect_timeout =... | class TimeoutConfig:
| """
Timeout values.
"""
def __init__(
self,
timeout: TimeoutTypes = None,
*,
connect_timeout: float = None,
read_timeout: float = None,
write_timeout: float = None,
):
if timeout is None:
self.connect_timeout = connect_timeout
... | _SSLv3
context.options |= ssl.OP_NO_TLSv1
context.options |= ssl.OP_NO_TLSv1_1
context.options |= ssl.OP_NO_COMPRESSION
context.set_ciphers(DEFAULT_CIPHERS)
if ssl.HAS_ALPN:
context.set_alpn_protocols(["h2", "http/1.1"])
if ssl.HAS_NPN:
context.se... | 108 | 108 | 362 | 4 | 103 | Rikardo69/httpx | httpx/config.py | Python | TimeoutConfig | TimeoutConfig | 163 | 213 | 163 | 163 | b6db5c16cb234dc4eee5c988bf256aff1ab2c0f9 | bigcode/the-stack | train |
86c1a15d06fd5b7eb72c14e7 | train | class | class PoolLimits:
"""
Limits on the number of connections in a connection pool.
"""
def __init__(
self,
*,
soft_limit: int = None,
hard_limit: int = None,
pool_timeout: float = None,
):
self.soft_limit = soft_limit
self.hard_limit = hard_limit... | class PoolLimits:
| """
Limits on the number of connections in a connection pool.
"""
def __init__(
self,
*,
soft_limit: int = None,
hard_limit: int = None,
pool_timeout: float = None,
):
self.soft_limit = soft_limit
self.hard_limit = hard_limit
self.pool... | , self.write_timeout}) == 1:
return f"{class_name}(timeout={self.connect_timeout})"
return (
f"{class_name}(connect_timeout={self.connect_timeout}, "
f"read_timeout={self.read_timeout}, write_timeout={self.write_timeout})"
)
class PoolLimits:
| 64 | 64 | 199 | 4 | 60 | Rikardo69/httpx | httpx/config.py | Python | PoolLimits | PoolLimits | 216 | 245 | 216 | 216 | 195bd79701e7fdb7a2fa1ed8398987ed6602b0d1 | bigcode/the-stack | train |
71f94856a596b3d8034d453f | train | class | class SSLConfig:
"""
SSL Configuration.
"""
def __init__(self, *, cert: CertTypes = None, verify: VerifyTypes = True):
self.cert = cert
self.verify = verify
self.ssl_context: typing.Optional[ssl.SSLContext] = None
def __eq__(self, other: typing.Any) -> bool:
return... | class SSLConfig:
| """
SSL Configuration.
"""
def __init__(self, *, cert: CertTypes = None, verify: VerifyTypes = True):
self.cert = cert
self.verify = verify
self.ssl_context: typing.Optional[ssl.SSLContext] = None
def __eq__(self, other: typing.Any) -> bool:
return (
is... | import asyncio
import os
import ssl
import typing
import certifi
from .__version__ import __version__
CertTypes = typing.Union[str, typing.Tuple[str, str], typing.Tuple[str, str, str]]
VerifyTypes = typing.Union[str, bool]
TimeoutTypes = typing.Union[float, typing.Tuple[float, float, float], "TimeoutConfig"]
USER_... | 213 | 256 | 974 | 4 | 209 | Rikardo69/httpx | httpx/config.py | Python | SSLConfig | SSLConfig | 37 | 160 | 37 | 37 | 5ce4548af814842d5692fe6fc7ed74f92bd606f2 | bigcode/the-stack | train |
ca4a1d0bef4b69dc40dde532 | train | function | def _nanrankdata_1d(a):
y = np.empty(a.shape, dtype=np.float64)
y.fill(np.nan)
idx = ~np.isnan(a)
y[idx] = scipy_rankdata(a[idx])
return y
| def _nanrankdata_1d(a):
| y = np.empty(a.shape, dtype=np.float64)
y.fill(np.nan)
idx = ~np.isnan(a)
y[idx] = scipy_rankdata(a[idx])
return y
| :
y = a.astype(np.float64, copy=True)
else:
y = np.apply_along_axis(func1d, axis, a)
if a.dtype != np.float64:
y = y.astype(np.float64)
return y
def _nanrankdata_1d(a):
| 64 | 64 | 52 | 10 | 53 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | _nanrankdata_1d | _nanrankdata_1d | 31 | 36 | 31 | 31 | 5d2f027ab97ef04f17c75364ae149b16317edc5b | bigcode/the-stack | train |
6b42d92fac025468c0c37ffc | train | function | def rankdata(a, axis=None):
"Slow rankdata function used for unaccelerated dtypes."
return _rank(scipy_rankdata, a, axis)
| def rankdata(a, axis=None):
| "Slow rankdata function used for unaccelerated dtypes."
return _rank(scipy_rankdata, a, axis)
| import numpy as np
from numpy import partition, argpartition
__all__ = ['rankdata', 'nanrankdata', 'partition', 'argpartition', 'push']
def rankdata(a, axis=None):
| 44 | 64 | 36 | 8 | 36 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | rankdata | rankdata | 7 | 9 | 7 | 7 | 8126cc1b560bcdaa8cb34efd81a7227fc46a7bec | bigcode/the-stack | train |
42b7549236818ddaa65669e6 | train | function | def scipy_rankdata(a, method='average'):
"""
rankdata(a, method='average')
Assign ranks to data, dealing with ties appropriately.
Ranks begin at 1. The `method` argument controls how ranks are assigned
to equal values. See [1]_ for further discussion of ranking methods.
Parameters
--------... | def scipy_rankdata(a, method='average'):
| """
rankdata(a, method='average')
Assign ranks to data, dealing with ties appropriately.
Ranks begin at 1. The `method` argument controls how ranks are assigned
to equal values. See [1]_ for further discussion of ranking methods.
Parameters
----------
a : array_like
The array o... | = ~np.isnan(y)
recent = np.empty(y.shape[:-1])
count = np.empty(y.shape[:-1])
recent.fill(np.nan)
count.fill(np.nan)
with np.errstate(invalid='ignore'):
for i in range(y.shape[-1]):
idx = (i - count) > n
recent[idx] = np.nan
idx = ~fidx[..., i]
... | 243 | 243 | 811 | 10 | 233 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | scipy_rankdata | scipy_rankdata | 83 | 165 | 83 | 83 | 30d6a57c3187e30e24ddfe94ffdb51f67259f9d0 | bigcode/the-stack | train |
14907e3923ffa4ef5da94e45 | train | function | def nanrankdata(a, axis=None):
"Slow nanrankdata function used for unaccelerated dtypes."
return _rank(_nanrankdata_1d, a, axis)
| def nanrankdata(a, axis=None):
| "Slow nanrankdata function used for unaccelerated dtypes."
return _rank(_nanrankdata_1d, a, axis)
| ['rankdata', 'nanrankdata', 'partition', 'argpartition', 'push']
def rankdata(a, axis=None):
"Slow rankdata function used for unaccelerated dtypes."
return _rank(scipy_rankdata, a, axis)
def nanrankdata(a, axis=None):
| 64 | 64 | 40 | 9 | 55 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | nanrankdata | nanrankdata | 12 | 14 | 12 | 12 | 3be68832b5869f8be8c61f5b9b2e306597237e74 | bigcode/the-stack | train |
b5428af1232e7cafe57d40f7 | train | function | def push(a, n=np.inf, axis=-1):
"Slow push used for unaccelerated dtypes."
if axis is None:
raise ValueError("`axis` cannot be None")
y = np.array(a)
ndim = y.ndim
if axis != -1 or axis != ndim - 1:
y = np.rollaxis(y, axis, ndim)
if ndim == 1:
y = y[None, :]
elif ndim... | def push(a, n=np.inf, axis=-1):
| "Slow push used for unaccelerated dtypes."
if axis is None:
raise ValueError("`axis` cannot be None")
y = np.array(a)
ndim = y.ndim
if axis != -1 or axis != ndim - 1:
y = np.rollaxis(y, axis, ndim)
if ndim == 1:
y = y[None, :]
elif ndim == 0:
return y
fidx... | .dtype != np.float64:
y = y.astype(np.float64)
return y
def _nanrankdata_1d(a):
y = np.empty(a.shape, dtype=np.float64)
y.fill(np.nan)
idx = ~np.isnan(a)
y[idx] = scipy_rankdata(a[idx])
return y
def push(a, n=np.inf, axis=-1):
| 83 | 83 | 278 | 12 | 70 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | push | push | 39 | 69 | 39 | 39 | 8693f2693cd70ffb086da2d2ffbdf9a5529158fc | bigcode/the-stack | train |
0109127679970e887ec69a74 | train | function | def _rank(func1d, a, axis):
a = np.array(a, copy=False)
if axis is None:
a = a.ravel()
axis = 0
if a.size == 0:
y = a.astype(np.float64, copy=True)
else:
y = np.apply_along_axis(func1d, axis, a)
if a.dtype != np.float64:
y = y.astype(np.float64)
re... | def _rank(func1d, a, axis):
| a = np.array(a, copy=False)
if axis is None:
a = a.ravel()
axis = 0
if a.size == 0:
y = a.astype(np.float64, copy=True)
else:
y = np.apply_along_axis(func1d, axis, a)
if a.dtype != np.float64:
y = y.astype(np.float64)
return y
| return _rank(scipy_rankdata, a, axis)
def nanrankdata(a, axis=None):
"Slow nanrankdata function used for unaccelerated dtypes."
return _rank(_nanrankdata_1d, a, axis)
def _rank(func1d, a, axis):
| 64 | 64 | 101 | 11 | 53 | shoyer/bottleneck | bottleneck/slow/nonreduce_axis.py | Python | _rank | _rank | 17 | 28 | 17 | 17 | 014bf0f1a985b4d8c59d46d9d0b568e41e504dd0 | bigcode/the-stack | train |
94719807c4d60290554c265d | train | function | def import_error(msg):
print()
print('## IMPORT ERROR:' + msg)
print()
| def import_error(msg):
| print()
print('## IMPORT ERROR:' + msg)
print()
| # nost test suite copied initially from ECOS project
from __future__ import print_function
import platform
def import_error(msg):
| 27 | 64 | 21 | 5 | 21 | alexfrolov/scs-python | test/test_scs_basic.py | Python | import_error | import_error | 6 | 9 | 6 | 6 | 933a3cd7fc82c6c5f6089652aa8d1cdcd30998c5 | bigcode/the-stack | train |
c5366784326762b4cb9f81e7 | train | function | def test_problems():
sol = scs.solve(data, cone, use_indirect=False)
yield check_solution, sol['x'][0], 1
new_cone = {'q': [2], 'l': 0}
sol = scs.solve(data, new_cone, use_indirect=False)
yield check_solution, sol['x'][0], 0.5
sol = scs.solve(data, cone, use_indirect=True)
yield check_solution, sol['x']... | def test_problems():
| sol = scs.solve(data, cone, use_indirect=False)
yield check_solution, sol['x'][0], 1
new_cone = {'q': [2], 'l': 0}
sol = scs.solve(data, new_cone, use_indirect=False)
yield check_solution, sol['x'][0], 0.5
sol = scs.solve(data, cone, use_indirect=True)
yield check_solution, sol['x'][0], 1
sol = scs.s... | {'q': [], 'l': 2}
FAIL = 'Failure' # scs code for failure
def check_solution(solution, expected):
assert_almost_equals(solution, expected, places=2)
def check_failure(sol):
assert sol['info']['status'] == FAIL
def test_problems():
| 64 | 64 | 146 | 5 | 58 | alexfrolov/scs-python | test/test_scs_basic.py | Python | test_problems | test_problems | 54 | 66 | 54 | 54 | ab7eff152c15db1ad40e6b89ac73fac282b16243 | bigcode/the-stack | train |
216bce6273148735aa4b093c | train | function | def check_failure(sol):
assert sol['info']['status'] == FAIL
| def check_failure(sol):
| assert sol['info']['status'] == FAIL
| A': A, 'b': b, 'c': c}
cone = {'q': [], 'l': 2}
FAIL = 'Failure' # scs code for failure
def check_solution(solution, expected):
assert_almost_equals(solution, expected, places=2)
def check_failure(sol):
| 64 | 64 | 16 | 5 | 59 | alexfrolov/scs-python | test/test_scs_basic.py | Python | check_failure | check_failure | 50 | 51 | 50 | 50 | 6c5e99e30710ad30be5d45300dd2ef0bc8ee4a10 | bigcode/the-stack | train |
d3e180bfc36f0259f0c9915a | train | function | def check_solution(solution, expected):
assert_almost_equals(solution, expected, places=2)
| def check_solution(solution, expected):
| assert_almost_equals(solution, expected, places=2)
| .csc_matrix([1., -1.]).T.tocsc()
data = {'A': A, 'b': b, 'c': c}
cone = {'q': [], 'l': 2}
FAIL = 'Failure' # scs code for failure
def check_solution(solution, expected):
| 64 | 64 | 20 | 7 | 56 | alexfrolov/scs-python | test/test_scs_basic.py | Python | check_solution | check_solution | 46 | 47 | 46 | 46 | 32381d57333787dda36271a7acce1fc1caae9065 | bigcode/the-stack | train |
f1e908b0173b7c6f882f6b3d | train | function | def test_failures():
yield assert_raises, TypeError, scs.solve
yield assert_raises, ValueError, scs.solve, data, {'q': [4], 'l': -2}
# disable this until win64 types figured out
# yield check_keyword, ValueError, 'max_iters', -1
# python 2.6 and before just cast float to int
if platform.python_version_tuple... | def test_failures():
| yield assert_raises, TypeError, scs.solve
yield assert_raises, ValueError, scs.solve, data, {'q': [4], 'l': -2}
# disable this until win64 types figured out
# yield check_keyword, ValueError, 'max_iters', -1
# python 2.6 and before just cast float to int
if platform.python_version_tuple() >= ('2', '7', '0')... | .solve(data, new_cone, use_indirect=True)
yield check_solution, sol['x'][0], 0.5
def check_keyword(error_type, keyword, value):
assert_raises(error_type, scs.solve, data, cone, **{keyword: value})
def test_failures():
| 64 | 64 | 143 | 5 | 59 | alexfrolov/scs-python | test/test_scs_basic.py | Python | test_failures | test_failures | 89 | 98 | 89 | 89 | ebef5d6286df56ae4462c5b793f9ba2a3f2ed797 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.