repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
carymrobbins/py-tryhaskell | tryhaskell/__init__.py | TryHaskell.parse | def parse(cls, j):
"""
:param dict j: JSON response from TryHaskell.
:rtype: TryHaskell.Result
"""
error = j.get('error')
if error:
return cls._bad_result(error)
success = j.get('success')
if success:
try:
return cls... | python | def parse(cls, j):
"""
:param dict j: JSON response from TryHaskell.
:rtype: TryHaskell.Result
"""
error = j.get('error')
if error:
return cls._bad_result(error)
success = j.get('success')
if success:
try:
return cls... | [
"def",
"parse",
"(",
"cls",
",",
"j",
")",
":",
"error",
"=",
"j",
".",
"get",
"(",
"'error'",
")",
"if",
"error",
":",
"return",
"cls",
".",
"_bad_result",
"(",
"error",
")",
"success",
"=",
"j",
".",
"get",
"(",
"'success'",
")",
"if",
"success... | :param dict j: JSON response from TryHaskell.
:rtype: TryHaskell.Result | [
":",
"param",
"dict",
"j",
":",
"JSON",
"response",
"from",
"TryHaskell",
".",
":",
"rtype",
":",
"TryHaskell",
".",
"Result"
] | train | https://github.com/carymrobbins/py-tryhaskell/blob/a178c57bbed13e24946cbe78a6a2444056f1a2b4/tryhaskell/__init__.py#L66-L84 |
carymrobbins/py-tryhaskell | tryhaskell/__init__.py | TryHaskell.show | def show(cls, result):
"""
:param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode
"""
if result.ok:
if result.stdout:
out = '\n'.join(result.stdout)
if result.value and result.value != '()':
... | python | def show(cls, result):
"""
:param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode
"""
if result.ok:
if result.stdout:
out = '\n'.join(result.stdout)
if result.value and result.value != '()':
... | [
"def",
"show",
"(",
"cls",
",",
"result",
")",
":",
"if",
"result",
".",
"ok",
":",
"if",
"result",
".",
"stdout",
":",
"out",
"=",
"'\\n'",
".",
"join",
"(",
"result",
".",
"stdout",
")",
"if",
"result",
".",
"value",
"and",
"result",
".",
"valu... | :param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode | [
":",
"param",
"TryHaskell",
".",
"Result",
"result",
":",
"Parse",
"result",
"of",
"JSON",
"data",
".",
":",
"rtype",
":",
"str|unicode"
] | train | https://github.com/carymrobbins/py-tryhaskell/blob/a178c57bbed13e24946cbe78a6a2444056f1a2b4/tryhaskell/__init__.py#L87-L101 |
carymrobbins/py-tryhaskell | tryhaskell/__init__.py | TryHaskell.show_type | def show_type(cls, result):
"""
:param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode
"""
if result.ok:
return ' :: '.join([result.expr, result.type])
return result.value | python | def show_type(cls, result):
"""
:param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode
"""
if result.ok:
return ' :: '.join([result.expr, result.type])
return result.value | [
"def",
"show_type",
"(",
"cls",
",",
"result",
")",
":",
"if",
"result",
".",
"ok",
":",
"return",
"' :: '",
".",
"join",
"(",
"[",
"result",
".",
"expr",
",",
"result",
".",
"type",
"]",
")",
"return",
"result",
".",
"value"
] | :param TryHaskell.Result result: Parse result of JSON data.
:rtype: str|unicode | [
":",
"param",
"TryHaskell",
".",
"Result",
"result",
":",
"Parse",
"result",
"of",
"JSON",
"data",
".",
":",
"rtype",
":",
"str|unicode"
] | train | https://github.com/carymrobbins/py-tryhaskell/blob/a178c57bbed13e24946cbe78a6a2444056f1a2b4/tryhaskell/__init__.py#L104-L111 |
knagra/farnsworth | managers/views.py | anonymous_login_view | def anonymous_login_view(request):
''' View for an admin to log her/himself out and login the anonymous user. '''
logout(request)
try:
spineless = User.objects.get(username=ANONYMOUS_USERNAME)
except User.DoesNotExist:
random_password = User.objects.make_random_password()
spinele... | python | def anonymous_login_view(request):
''' View for an admin to log her/himself out and login the anonymous user. '''
logout(request)
try:
spineless = User.objects.get(username=ANONYMOUS_USERNAME)
except User.DoesNotExist:
random_password = User.objects.make_random_password()
spinele... | [
"def",
"anonymous_login_view",
"(",
"request",
")",
":",
"logout",
"(",
"request",
")",
"try",
":",
"spineless",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"ANONYMOUS_USERNAME",
")",
"except",
"User",
".",
"DoesNotExist",
":",
"random_pas... | View for an admin to log her/himself out and login the anonymous user. | [
"View",
"for",
"an",
"admin",
"to",
"log",
"her",
"/",
"himself",
"out",
"and",
"login",
"the",
"anonymous",
"user",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L72-L89 |
knagra/farnsworth | managers/views.py | end_anonymous_session_view | def end_anonymous_session_view(request):
''' End the anonymous session if the user is a superuser. '''
request.session['ANONYMOUS_SESSION'] = False
messages.add_message(request, messages.INFO, MESSAGES['ANONYMOUS_SESSION_ENDED'])
return HttpResponseRedirect(reverse('utilities')) | python | def end_anonymous_session_view(request):
''' End the anonymous session if the user is a superuser. '''
request.session['ANONYMOUS_SESSION'] = False
messages.add_message(request, messages.INFO, MESSAGES['ANONYMOUS_SESSION_ENDED'])
return HttpResponseRedirect(reverse('utilities')) | [
"def",
"end_anonymous_session_view",
"(",
"request",
")",
":",
"request",
".",
"session",
"[",
"'ANONYMOUS_SESSION'",
"]",
"=",
"False",
"messages",
".",
"add_message",
"(",
"request",
",",
"messages",
".",
"INFO",
",",
"MESSAGES",
"[",
"'ANONYMOUS_SESSION_ENDED'"... | End the anonymous session if the user is a superuser. | [
"End",
"the",
"anonymous",
"session",
"if",
"the",
"user",
"is",
"a",
"superuser",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L92-L96 |
knagra/farnsworth | managers/views.py | list_managers_view | def list_managers_view(request):
''' Show a list of manager positions with links to view in detail. '''
managerset = Manager.objects.filter(active=True)
return render_to_response('list_managers.html', {
'page_name': "Managers",
'managerset': managerset,
}, context_instance=RequestCon... | python | def list_managers_view(request):
''' Show a list of manager positions with links to view in detail. '''
managerset = Manager.objects.filter(active=True)
return render_to_response('list_managers.html', {
'page_name': "Managers",
'managerset': managerset,
}, context_instance=RequestCon... | [
"def",
"list_managers_view",
"(",
"request",
")",
":",
"managerset",
"=",
"Manager",
".",
"objects",
".",
"filter",
"(",
"active",
"=",
"True",
")",
"return",
"render_to_response",
"(",
"'list_managers.html'",
",",
"{",
"'page_name'",
":",
"\"Managers\"",
",",
... | Show a list of manager positions with links to view in detail. | [
"Show",
"a",
"list",
"of",
"manager",
"positions",
"with",
"links",
"to",
"view",
"in",
"detail",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L99-L105 |
knagra/farnsworth | managers/views.py | manager_view | def manager_view(request, managerTitle):
''' View the details of a manager position.
Parameters:
request is an HTTP request
managerTitle is the URL title of the manager.
'''
targetManager = get_object_or_404(Manager, url_title=managerTitle)
if not targetManager.active:
messa... | python | def manager_view(request, managerTitle):
''' View the details of a manager position.
Parameters:
request is an HTTP request
managerTitle is the URL title of the manager.
'''
targetManager = get_object_or_404(Manager, url_title=managerTitle)
if not targetManager.active:
messa... | [
"def",
"manager_view",
"(",
"request",
",",
"managerTitle",
")",
":",
"targetManager",
"=",
"get_object_or_404",
"(",
"Manager",
",",
"url_title",
"=",
"managerTitle",
")",
"if",
"not",
"targetManager",
".",
"active",
":",
"messages",
".",
"add_message",
"(",
... | View the details of a manager position.
Parameters:
request is an HTTP request
managerTitle is the URL title of the manager. | [
"View",
"the",
"details",
"of",
"a",
"manager",
"position",
".",
"Parameters",
":",
"request",
"is",
"an",
"HTTP",
"request",
"managerTitle",
"is",
"the",
"URL",
"title",
"of",
"the",
"manager",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L108-L123 |
knagra/farnsworth | managers/views.py | meta_manager_view | def meta_manager_view(request):
'''
A manager of managers. Display a list of current managers, with links to modify them.
Also display a link to add a new manager. Restricted to presidents and superadmins.
'''
managers = Manager.objects.all()
return render_to_response('meta_manager.html', {
... | python | def meta_manager_view(request):
'''
A manager of managers. Display a list of current managers, with links to modify them.
Also display a link to add a new manager. Restricted to presidents and superadmins.
'''
managers = Manager.objects.all()
return render_to_response('meta_manager.html', {
... | [
"def",
"meta_manager_view",
"(",
"request",
")",
":",
"managers",
"=",
"Manager",
".",
"objects",
".",
"all",
"(",
")",
"return",
"render_to_response",
"(",
"'meta_manager.html'",
",",
"{",
"'page_name'",
":",
"\"Admin - Meta-Manager\"",
",",
"'managerset'",
":",
... | A manager of managers. Display a list of current managers, with links to modify them.
Also display a link to add a new manager. Restricted to presidents and superadmins. | [
"A",
"manager",
"of",
"managers",
".",
"Display",
"a",
"list",
"of",
"current",
"managers",
"with",
"links",
"to",
"modify",
"them",
".",
"Also",
"display",
"a",
"link",
"to",
"add",
"a",
"new",
"manager",
".",
"Restricted",
"to",
"presidents",
"and",
"s... | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L126-L135 |
knagra/farnsworth | managers/views.py | add_manager_view | def add_manager_view(request):
''' View to add a new manager position. Restricted to superadmins and presidents. '''
form = ManagerForm(request.POST or None)
if form.is_valid():
manager = form.save()
messages.add_message(request, messages.SUCCESS,
MESSAGES['MANAG... | python | def add_manager_view(request):
''' View to add a new manager position. Restricted to superadmins and presidents. '''
form = ManagerForm(request.POST or None)
if form.is_valid():
manager = form.save()
messages.add_message(request, messages.SUCCESS,
MESSAGES['MANAG... | [
"def",
"add_manager_view",
"(",
"request",
")",
":",
"form",
"=",
"ManagerForm",
"(",
"request",
".",
"POST",
"or",
"None",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"manager",
"=",
"form",
".",
"save",
"(",
")",
"messages",
".",
"add_message"... | View to add a new manager position. Restricted to superadmins and presidents. | [
"View",
"to",
"add",
"a",
"new",
"manager",
"position",
".",
"Restricted",
"to",
"superadmins",
"and",
"presidents",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L138-L150 |
knagra/farnsworth | managers/views.py | edit_manager_view | def edit_manager_view(request, managerTitle):
''' View to modify an existing manager.
Parameters:
request is an HTTP request
managerTitle is URL title of the manager.
'''
targetManager = get_object_or_404(Manager, url_title=managerTitle)
form = ManagerForm(
request.POST or No... | python | def edit_manager_view(request, managerTitle):
''' View to modify an existing manager.
Parameters:
request is an HTTP request
managerTitle is URL title of the manager.
'''
targetManager = get_object_or_404(Manager, url_title=managerTitle)
form = ManagerForm(
request.POST or No... | [
"def",
"edit_manager_view",
"(",
"request",
",",
"managerTitle",
")",
":",
"targetManager",
"=",
"get_object_or_404",
"(",
"Manager",
",",
"url_title",
"=",
"managerTitle",
")",
"form",
"=",
"ManagerForm",
"(",
"request",
".",
"POST",
"or",
"None",
",",
"insta... | View to modify an existing manager.
Parameters:
request is an HTTP request
managerTitle is URL title of the manager. | [
"View",
"to",
"modify",
"an",
"existing",
"manager",
".",
"Parameters",
":",
"request",
"is",
"an",
"HTTP",
"request",
"managerTitle",
"is",
"URL",
"title",
"of",
"the",
"manager",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L153-L174 |
knagra/farnsworth | managers/views.py | manage_request_types_view | def manage_request_types_view(request):
''' Manage requests. Display a list of request types with links to edit them.
Also display a link to add a new request type. Restricted to presidents and superadmins.
'''
request_types = RequestType.objects.all()
return render_to_response('manage_request_typ... | python | def manage_request_types_view(request):
''' Manage requests. Display a list of request types with links to edit them.
Also display a link to add a new request type. Restricted to presidents and superadmins.
'''
request_types = RequestType.objects.all()
return render_to_response('manage_request_typ... | [
"def",
"manage_request_types_view",
"(",
"request",
")",
":",
"request_types",
"=",
"RequestType",
".",
"objects",
".",
"all",
"(",
")",
"return",
"render_to_response",
"(",
"'manage_request_types.html'",
",",
"{",
"'page_name'",
":",
"\"Admin - Manage Request Types\"",... | Manage requests. Display a list of request types with links to edit them.
Also display a link to add a new request type. Restricted to presidents and superadmins. | [
"Manage",
"requests",
".",
"Display",
"a",
"list",
"of",
"request",
"types",
"with",
"links",
"to",
"edit",
"them",
".",
"Also",
"display",
"a",
"link",
"to",
"add",
"a",
"new",
"request",
"type",
".",
"Restricted",
"to",
"presidents",
"and",
"superadmins"... | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L177-L185 |
knagra/farnsworth | managers/views.py | add_request_type_view | def add_request_type_view(request):
''' View to add a new request type. Restricted to presidents and superadmins. '''
form = RequestTypeForm(request.POST or None)
if form.is_valid():
rtype = form.save()
messages.add_message(request, messages.SUCCESS,
MESSAGES['R... | python | def add_request_type_view(request):
''' View to add a new request type. Restricted to presidents and superadmins. '''
form = RequestTypeForm(request.POST or None)
if form.is_valid():
rtype = form.save()
messages.add_message(request, messages.SUCCESS,
MESSAGES['R... | [
"def",
"add_request_type_view",
"(",
"request",
")",
":",
"form",
"=",
"RequestTypeForm",
"(",
"request",
".",
"POST",
"or",
"None",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"rtype",
"=",
"form",
".",
"save",
"(",
")",
"messages",
".",
"add_m... | View to add a new request type. Restricted to presidents and superadmins. | [
"View",
"to",
"add",
"a",
"new",
"request",
"type",
".",
"Restricted",
"to",
"presidents",
"and",
"superadmins",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L188-L200 |
knagra/farnsworth | managers/views.py | edit_request_type_view | def edit_request_type_view(request, typeName):
''' View to edit a new request type. Restricted to presidents and superadmins.
Parameters:
request is an HTTP request
typeName is the request type's URL name.
'''
requestType = get_object_or_404(RequestType, url_name=typeName)
form = Re... | python | def edit_request_type_view(request, typeName):
''' View to edit a new request type. Restricted to presidents and superadmins.
Parameters:
request is an HTTP request
typeName is the request type's URL name.
'''
requestType = get_object_or_404(RequestType, url_name=typeName)
form = Re... | [
"def",
"edit_request_type_view",
"(",
"request",
",",
"typeName",
")",
":",
"requestType",
"=",
"get_object_or_404",
"(",
"RequestType",
",",
"url_name",
"=",
"typeName",
")",
"form",
"=",
"RequestTypeForm",
"(",
"request",
".",
"POST",
"or",
"None",
",",
"ins... | View to edit a new request type. Restricted to presidents and superadmins.
Parameters:
request is an HTTP request
typeName is the request type's URL name. | [
"View",
"to",
"edit",
"a",
"new",
"request",
"type",
".",
"Restricted",
"to",
"presidents",
"and",
"superadmins",
".",
"Parameters",
":",
"request",
"is",
"an",
"HTTP",
"request",
"typeName",
"is",
"the",
"request",
"type",
"s",
"URL",
"name",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L203-L224 |
knagra/farnsworth | managers/views.py | requests_view | def requests_view(request, requestType):
'''
Generic request view. Parameters:
request is the HTTP request
requestType is URL name of a RequestType.
e.g. "food", "maintenance", "network", "site"
'''
userProfile = UserProfile.objects.get(user=request.user)
request_type = ... | python | def requests_view(request, requestType):
'''
Generic request view. Parameters:
request is the HTTP request
requestType is URL name of a RequestType.
e.g. "food", "maintenance", "network", "site"
'''
userProfile = UserProfile.objects.get(user=request.user)
request_type = ... | [
"def",
"requests_view",
"(",
"request",
",",
"requestType",
")",
":",
"userProfile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"request",
".",
"user",
")",
"request_type",
"=",
"get_object_or_404",
"(",
"RequestType",
",",
"url_name",
... | Generic request view. Parameters:
request is the HTTP request
requestType is URL name of a RequestType.
e.g. "food", "maintenance", "network", "site" | [
"Generic",
"request",
"view",
".",
"Parameters",
":",
"request",
"is",
"the",
"HTTP",
"request",
"requestType",
"is",
"URL",
"name",
"of",
"a",
"RequestType",
".",
"e",
".",
"g",
".",
"food",
"maintenance",
"network",
"site"
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L227-L302 |
knagra/farnsworth | managers/views.py | my_requests_view | def my_requests_view(request):
'''
Show user his/her requests, sorted by request_type.
'''
page_name = "Your Requests"
userProfile = UserProfile.objects.get(user=request.user)
my_requests = Request.objects.filter(owner=userProfile)
# A pseudo dictionary, actually a list with items of form
... | python | def my_requests_view(request):
'''
Show user his/her requests, sorted by request_type.
'''
page_name = "Your Requests"
userProfile = UserProfile.objects.get(user=request.user)
my_requests = Request.objects.filter(owner=userProfile)
# A pseudo dictionary, actually a list with items of form
... | [
"def",
"my_requests_view",
"(",
"request",
")",
":",
"page_name",
"=",
"\"Your Requests\"",
"userProfile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"request",
".",
"user",
")",
"my_requests",
"=",
"Request",
".",
"objects",
".",
"fil... | Show user his/her requests, sorted by request_type. | [
"Show",
"user",
"his",
"/",
"her",
"requests",
"sorted",
"by",
"request_type",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L305-L374 |
knagra/farnsworth | managers/views.py | list_my_requests_view | def list_my_requests_view(request):
'''
Show user his/her requests in list form.
'''
userProfile = UserProfile.objects.get(user=request.user)
requests = Request.objects.filter(owner=userProfile)
return render_to_response('list_requests.html', {
'page_name': "Your Requests",
'requ... | python | def list_my_requests_view(request):
'''
Show user his/her requests in list form.
'''
userProfile = UserProfile.objects.get(user=request.user)
requests = Request.objects.filter(owner=userProfile)
return render_to_response('list_requests.html', {
'page_name': "Your Requests",
'requ... | [
"def",
"list_my_requests_view",
"(",
"request",
")",
":",
"userProfile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"request",
".",
"user",
")",
"requests",
"=",
"Request",
".",
"objects",
".",
"filter",
"(",
"owner",
"=",
"userProfi... | Show user his/her requests in list form. | [
"Show",
"user",
"his",
"/",
"her",
"requests",
"in",
"list",
"form",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L377-L386 |
knagra/farnsworth | managers/views.py | list_user_requests_view | def list_user_requests_view(request, targetUsername):
'''
Show user his/her requests in list form.
'''
if targetUsername == request.user.username:
return list_my_requests_view(request)
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserPr... | python | def list_user_requests_view(request, targetUsername):
'''
Show user his/her requests in list form.
'''
if targetUsername == request.user.username:
return list_my_requests_view(request)
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserPr... | [
"def",
"list_user_requests_view",
"(",
"request",
",",
"targetUsername",
")",
":",
"if",
"targetUsername",
"==",
"request",
".",
"user",
".",
"username",
":",
"return",
"list_my_requests_view",
"(",
"request",
")",
"targetUser",
"=",
"get_object_or_404",
"(",
"Use... | Show user his/her requests in list form. | [
"Show",
"user",
"his",
"/",
"her",
"requests",
"in",
"list",
"form",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L389-L406 |
knagra/farnsworth | managers/views.py | all_requests_view | def all_requests_view(request):
'''
Show user a list of enabled request types, the number of requests of each
type and a link to see them all.
'''
# Pseudo-dictionary, actually a list with items of form
# (request_type.name.title(), number_of_type_requests, name, enabled,
# glyphicon)
ty... | python | def all_requests_view(request):
'''
Show user a list of enabled request types, the number of requests of each
type and a link to see them all.
'''
# Pseudo-dictionary, actually a list with items of form
# (request_type.name.title(), number_of_type_requests, name, enabled,
# glyphicon)
ty... | [
"def",
"all_requests_view",
"(",
"request",
")",
":",
"# Pseudo-dictionary, actually a list with items of form",
"# (request_type.name.title(), number_of_type_requests, name, enabled,",
"# glyphicon)",
"types_dict",
"=",
"list",
"(",
")",
"for",
"request_type",
"in",
"RequestType",... | Show user a list of enabled request types, the number of requests of each
type and a link to see them all. | [
"Show",
"user",
"a",
"list",
"of",
"enabled",
"request",
"types",
"the",
"number",
"of",
"requests",
"of",
"each",
"type",
"and",
"a",
"link",
"to",
"see",
"them",
"all",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L409-L435 |
knagra/farnsworth | managers/views.py | list_all_requests_view | def list_all_requests_view(request, requestType):
'''
Show all the requests for a given type in list form.
'''
request_type = get_object_or_404(RequestType, url_name=requestType)
requests = Request.objects.filter(request_type=request_type)
# Hide the count for private requests
if not request... | python | def list_all_requests_view(request, requestType):
'''
Show all the requests for a given type in list form.
'''
request_type = get_object_or_404(RequestType, url_name=requestType)
requests = Request.objects.filter(request_type=request_type)
# Hide the count for private requests
if not request... | [
"def",
"list_all_requests_view",
"(",
"request",
",",
"requestType",
")",
":",
"request_type",
"=",
"get_object_or_404",
"(",
"RequestType",
",",
"url_name",
"=",
"requestType",
")",
"requests",
"=",
"Request",
".",
"objects",
".",
"filter",
"(",
"request_type",
... | Show all the requests for a given type in list form. | [
"Show",
"all",
"the",
"requests",
"for",
"a",
"given",
"type",
"in",
"list",
"form",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L438-L455 |
knagra/farnsworth | managers/views.py | request_view | def request_view(request, request_pk):
'''
The view of a single request.
'''
if request.is_ajax():
if not request.user.is_authenticated():
return HttpResponse(json.dumps(dict()),
content_type="application/json")
try:
relevant_reque... | python | def request_view(request, request_pk):
'''
The view of a single request.
'''
if request.is_ajax():
if not request.user.is_authenticated():
return HttpResponse(json.dumps(dict()),
content_type="application/json")
try:
relevant_reque... | [
"def",
"request_view",
"(",
"request",
",",
"request_pk",
")",
":",
"if",
"request",
".",
"is_ajax",
"(",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"HttpResponse",
"(",
"json",
".",
"dumps",
"(",
"... | The view of a single request. | [
"The",
"view",
"of",
"a",
"single",
"request",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L459-L557 |
knagra/farnsworth | managers/views.py | announcement_view | def announcement_view(request, announcement_pk):
''' The view of a single manager announcement. '''
announce = get_object_or_404(Announcement, pk=announcement_pk)
page_name = "View Announcement"
profile = UserProfile.objects.get(user=request.user)
pin_form = PinForm(
request.POST if "pin" in... | python | def announcement_view(request, announcement_pk):
''' The view of a single manager announcement. '''
announce = get_object_or_404(Announcement, pk=announcement_pk)
page_name = "View Announcement"
profile = UserProfile.objects.get(user=request.user)
pin_form = PinForm(
request.POST if "pin" in... | [
"def",
"announcement_view",
"(",
"request",
",",
"announcement_pk",
")",
":",
"announce",
"=",
"get_object_or_404",
"(",
"Announcement",
",",
"pk",
"=",
"announcement_pk",
")",
"page_name",
"=",
"\"View Announcement\"",
"profile",
"=",
"UserProfile",
".",
"objects",... | The view of a single manager announcement. | [
"The",
"view",
"of",
"a",
"single",
"manager",
"announcement",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L560-L580 |
knagra/farnsworth | managers/views.py | edit_announcement_view | def edit_announcement_view(request, announcement_pk):
''' The view of a single manager announcement. '''
announce = get_object_or_404(Announcement, pk=announcement_pk)
profile = UserProfile.objects.get(user=request.user)
if not (announce.incumbent == profile or request.user.is_superuser):
return... | python | def edit_announcement_view(request, announcement_pk):
''' The view of a single manager announcement. '''
announce = get_object_or_404(Announcement, pk=announcement_pk)
profile = UserProfile.objects.get(user=request.user)
if not (announce.incumbent == profile or request.user.is_superuser):
return... | [
"def",
"edit_announcement_view",
"(",
"request",
",",
"announcement_pk",
")",
":",
"announce",
"=",
"get_object_or_404",
"(",
"Announcement",
",",
"pk",
"=",
"announcement_pk",
")",
"profile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"... | The view of a single manager announcement. | [
"The",
"view",
"of",
"a",
"single",
"manager",
"announcement",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L583-L608 |
knagra/farnsworth | managers/views.py | announcements_view | def announcements_view(request):
''' The view of manager announcements. '''
page_name = "Manager Announcements"
userProfile = UserProfile.objects.get(user=request.user)
announcement_form = None
manager_positions = Manager.objects.filter(incumbent=userProfile)
if manager_positions:
announ... | python | def announcements_view(request):
''' The view of manager announcements. '''
page_name = "Manager Announcements"
userProfile = UserProfile.objects.get(user=request.user)
announcement_form = None
manager_positions = Manager.objects.filter(incumbent=userProfile)
if manager_positions:
announ... | [
"def",
"announcements_view",
"(",
"request",
")",
":",
"page_name",
"=",
"\"Manager Announcements\"",
"userProfile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"request",
".",
"user",
")",
"announcement_form",
"=",
"None",
"manager_positions... | The view of manager announcements. | [
"The",
"view",
"of",
"manager",
"announcements",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L611-L655 |
knagra/farnsworth | managers/views.py | all_announcements_view | def all_announcements_view(request):
''' The view of manager announcements. '''
page_name = "Archives - All Announcements"
userProfile = UserProfile.objects.get(user=request.user)
announcement_form = None
manager_positions = Manager.objects.filter(incumbent=userProfile)
if manager_positions:
... | python | def all_announcements_view(request):
''' The view of manager announcements. '''
page_name = "Archives - All Announcements"
userProfile = UserProfile.objects.get(user=request.user)
announcement_form = None
manager_positions = Manager.objects.filter(incumbent=userProfile)
if manager_positions:
... | [
"def",
"all_announcements_view",
"(",
"request",
")",
":",
"page_name",
"=",
"\"Archives - All Announcements\"",
"userProfile",
"=",
"UserProfile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"request",
".",
"user",
")",
"announcement_form",
"=",
"None",
"manage... | The view of manager announcements. | [
"The",
"view",
"of",
"manager",
"announcements",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L658-L692 |
jmgilman/Neolib | neolib/http/browser/ChromeCookies.py | ChromeCookies.installed | def installed():
""" Returns whether or not Google Chrome is installed
Determines the application data path for Google Chrome
and checks if the path exists. If so, returns True, otherwise
it will return False.
Returns
bool - True if Chrome is insta... | python | def installed():
""" Returns whether or not Google Chrome is installed
Determines the application data path for Google Chrome
and checks if the path exists. If so, returns True, otherwise
it will return False.
Returns
bool - True if Chrome is insta... | [
"def",
"installed",
"(",
")",
":",
"try",
":",
"path",
"=",
"ChromeCookies",
".",
"_getPath",
"(",
")",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"pass",
"return",
"True",
"except",
"Exception",
"as",
"e",
":",
"return",
"False"
] | Returns whether or not Google Chrome is installed
Determines the application data path for Google Chrome
and checks if the path exists. If so, returns True, otherwise
it will return False.
Returns
bool - True if Chrome is installed | [
"Returns",
"whether",
"or",
"not",
"Google",
"Chrome",
"is",
"installed",
"Determines",
"the",
"application",
"data",
"path",
"for",
"Google",
"Chrome",
"and",
"checks",
"if",
"the",
"path",
"exists",
".",
"If",
"so",
"returns",
"True",
"otherwise",
"it",
"w... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/http/browser/ChromeCookies.py#L34-L50 |
jmgilman/Neolib | neolib/http/browser/ChromeCookies.py | ChromeCookies.loadCookies | def loadCookies(domain):
""" Loads all Neopets cookie stored by Google Chrome into a CookieJar
Determines the application data path for Google Chrome, finds the cookie database file,
queries it for cookies with domain neopets.com, and proceeds to build a CookieJar with
the assoc... | python | def loadCookies(domain):
""" Loads all Neopets cookie stored by Google Chrome into a CookieJar
Determines the application data path for Google Chrome, finds the cookie database file,
queries it for cookies with domain neopets.com, and proceeds to build a CookieJar with
the assoc... | [
"def",
"loadCookies",
"(",
"domain",
")",
":",
"try",
":",
"cj",
"=",
"requests",
".",
"cookies",
".",
"RequestsCookieJar",
"(",
")",
"path",
"=",
"ChromeCookies",
".",
"_getPath",
"(",
")",
"results",
"=",
"[",
"]",
"with",
"sqlite",
".",
"connect",
"... | Loads all Neopets cookie stored by Google Chrome into a CookieJar
Determines the application data path for Google Chrome, finds the cookie database file,
queries it for cookies with domain neopets.com, and proceeds to build a CookieJar with
the associated data.
Paramete... | [
"Loads",
"all",
"Neopets",
"cookie",
"stored",
"by",
"Google",
"Chrome",
"into",
"a",
"CookieJar",
"Determines",
"the",
"application",
"data",
"path",
"for",
"Google",
"Chrome",
"finds",
"the",
"cookie",
"database",
"file",
"queries",
"it",
"for",
"cookies",
"... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/http/browser/ChromeCookies.py#L53-L92 |
jmgilman/Neolib | neolib/http/browser/ChromeCookies.py | ChromeCookies._getPath | def _getPath():
""" Returns Chrome's cookie database path
Returns
str - Google Chrome's cookie database path
"""
if os.name == "posix":
path = os.getenv("HOME") + "/.config/google-chrome/Default/Cookies"
return path
... | python | def _getPath():
""" Returns Chrome's cookie database path
Returns
str - Google Chrome's cookie database path
"""
if os.name == "posix":
path = os.getenv("HOME") + "/.config/google-chrome/Default/Cookies"
return path
... | [
"def",
"_getPath",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"\"posix\"",
":",
"path",
"=",
"os",
".",
"getenv",
"(",
"\"HOME\"",
")",
"+",
"\"/.config/google-chrome/Default/Cookies\"",
"return",
"path",
"import",
"_winreg",
"key",
"=",
"_winreg",
".",
... | Returns Chrome's cookie database path
Returns
str - Google Chrome's cookie database path | [
"Returns",
"Chrome",
"s",
"cookie",
"database",
"path",
"Returns",
"str",
"-",
"Google",
"Chrome",
"s",
"cookie",
"database",
"path"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/http/browser/ChromeCookies.py#L115-L131 |
aganezov/gos | gos/tmp/scaffolding_with_repeats.py | identify_assembly_points | def identify_assembly_points(graph, bgtree, target_multicolor, exclude=None, verbose=False, verbose_destination=None):
"""
The main granular assembling function, that IDENTIFIES assembly points, but does not perform the assembly on its own
It DOES NOT change the supplied breakpoint graph in any way!!!
"... | python | def identify_assembly_points(graph, bgtree, target_multicolor, exclude=None, verbose=False, verbose_destination=None):
"""
The main granular assembling function, that IDENTIFIES assembly points, but does not perform the assembly on its own
It DOES NOT change the supplied breakpoint graph in any way!!!
"... | [
"def",
"identify_assembly_points",
"(",
"graph",
",",
"bgtree",
",",
"target_multicolor",
",",
"exclude",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"verbose_destination",
"=",
"None",
")",
":",
"if",
"verbose",
":",
"print",
"(",
"\">>Identifying assemblie... | The main granular assembling function, that IDENTIFIES assembly points, but does not perform the assembly on its own
It DOES NOT change the supplied breakpoint graph in any way!!! | [
"The",
"main",
"granular",
"assembling",
"function",
"that",
"IDENTIFIES",
"assembly",
"points",
"but",
"does",
"not",
"perform",
"the",
"assembly",
"on",
"its",
"own",
"It",
"DOES",
"NOT",
"change",
"the",
"supplied",
"breakpoint",
"graph",
"in",
"any",
"way!... | train | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/tmp/scaffolding_with_repeats.py#L217-L277 |
corrni/scenario | scenario/core/webapp/__init__.py | create_app | def create_app(object_name):
"""
An flask application factory, as explained here:
http://flask.pocoo.org/docs/patterns/appfactories/
Arguments:
object_name: the python path of the config object,
e.g. webapp.settings.ProdConfig
env: The name of the current environme... | python | def create_app(object_name):
"""
An flask application factory, as explained here:
http://flask.pocoo.org/docs/patterns/appfactories/
Arguments:
object_name: the python path of the config object,
e.g. webapp.settings.ProdConfig
env: The name of the current environme... | [
"def",
"create_app",
"(",
"object_name",
")",
":",
"app",
"=",
"Flask",
"(",
"__name__",
")",
"app",
".",
"config",
".",
"from_object",
"(",
"object_name",
")",
"# initialize the cache",
"cache",
".",
"init_app",
"(",
"app",
")",
"# initialize the debug tool bar... | An flask application factory, as explained here:
http://flask.pocoo.org/docs/patterns/appfactories/
Arguments:
object_name: the python path of the config object,
e.g. webapp.settings.ProdConfig
env: The name of the current environment, e.g. prod or dev | [
"An",
"flask",
"application",
"factory",
"as",
"explained",
"here",
":",
"http",
":",
"//",
"flask",
".",
"pocoo",
".",
"org",
"/",
"docs",
"/",
"patterns",
"/",
"appfactories",
"/"
] | train | https://github.com/corrni/scenario/blob/42986c5a8ff6f2d70eb81b8c4b642728ec6a4a90/scenario/core/webapp/__init__.py#L11-L35 |
daknuett/py_register_machine2 | engine_tools/conversions.py | int_to_bytes | def int_to_bytes(int_, width = None):
"""
.. _int_to_bytes:
Converts the ``int`` ``int_`` to a ``bytes`` object.
``len(result) == width``.
If ``width`` is None, a number of bytes that is able to hold the
number is choosen, depending on ``int_.bit_length()``.
See also: bytes_to_int_
"""
if(width == None):
... | python | def int_to_bytes(int_, width = None):
"""
.. _int_to_bytes:
Converts the ``int`` ``int_`` to a ``bytes`` object.
``len(result) == width``.
If ``width`` is None, a number of bytes that is able to hold the
number is choosen, depending on ``int_.bit_length()``.
See also: bytes_to_int_
"""
if(width == None):
... | [
"def",
"int_to_bytes",
"(",
"int_",
",",
"width",
"=",
"None",
")",
":",
"if",
"(",
"width",
"==",
"None",
")",
":",
"width",
"=",
"int_",
".",
"bit_length",
"(",
")",
"byts",
"=",
"math",
".",
"ceil",
"(",
"width",
"/",
"8",
")",
"return",
"byte... | .. _int_to_bytes:
Converts the ``int`` ``int_`` to a ``bytes`` object.
``len(result) == width``.
If ``width`` is None, a number of bytes that is able to hold the
number is choosen, depending on ``int_.bit_length()``.
See also: bytes_to_int_ | [
"..",
"_int_to_bytes",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/conversions.py#L10-L25 |
daknuett/py_register_machine2 | engine_tools/conversions.py | bytes_to_int | def bytes_to_int(bytes_, width = None):
"""
.. _bytes_to_int:
Converts the ``bytes`` object ``bytes_`` to an ``int``.
If ``width`` is none, ``width = len(byte_) * 8`` is choosen.
See also: int_to_bytes_
*Example*
>>> from py_register_machine2.engine_tools.conversions import *
>>> i = 4012
>>> int_to_bytes(... | python | def bytes_to_int(bytes_, width = None):
"""
.. _bytes_to_int:
Converts the ``bytes`` object ``bytes_`` to an ``int``.
If ``width`` is none, ``width = len(byte_) * 8`` is choosen.
See also: int_to_bytes_
*Example*
>>> from py_register_machine2.engine_tools.conversions import *
>>> i = 4012
>>> int_to_bytes(... | [
"def",
"bytes_to_int",
"(",
"bytes_",
",",
"width",
"=",
"None",
")",
":",
"if",
"(",
"width",
"==",
"None",
")",
":",
"width",
"=",
"len",
"(",
"bytes_",
")",
"else",
":",
"width",
"=",
"width",
"//",
"8",
"if",
"(",
"width",
">",
"len",
"(",
... | .. _bytes_to_int:
Converts the ``bytes`` object ``bytes_`` to an ``int``.
If ``width`` is none, ``width = len(byte_) * 8`` is choosen.
See also: int_to_bytes_
*Example*
>>> from py_register_machine2.engine_tools.conversions import *
>>> i = 4012
>>> int_to_bytes(i)
b'\xac\x0f'
>>> bytes_to_int(int_to_bytes... | [
"..",
"_bytes_to_int",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/conversions.py#L27-L54 |
daknuett/py_register_machine2 | engine_tools/conversions.py | to_int | def to_int(argument):
"""
Converts the ``str`` argument to an integer:
>>> from py_register_machine2.engine_tools.conversions import *
>>> to_int("0x04")
4
>>> to_int("'a'")
97
"""
if(argument.startswith("0b")):
return int(argument[2:], 2)
elif(argument.startswith("0x")):
return int(argument[2:], 16)
e... | python | def to_int(argument):
"""
Converts the ``str`` argument to an integer:
>>> from py_register_machine2.engine_tools.conversions import *
>>> to_int("0x04")
4
>>> to_int("'a'")
97
"""
if(argument.startswith("0b")):
return int(argument[2:], 2)
elif(argument.startswith("0x")):
return int(argument[2:], 16)
e... | [
"def",
"to_int",
"(",
"argument",
")",
":",
"if",
"(",
"argument",
".",
"startswith",
"(",
"\"0b\"",
")",
")",
":",
"return",
"int",
"(",
"argument",
"[",
"2",
":",
"]",
",",
"2",
")",
"elif",
"(",
"argument",
".",
"startswith",
"(",
"\"0x\"",
")",... | Converts the ``str`` argument to an integer:
>>> from py_register_machine2.engine_tools.conversions import *
>>> to_int("0x04")
4
>>> to_int("'a'")
97 | [
"Converts",
"the",
"str",
"argument",
"to",
"an",
"integer",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/conversions.py#L56-L75 |
daknuett/py_register_machine2 | engine_tools/conversions.py | chunks | def chunks(iterable, size = 8):
"""
from `Stack Overflow <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks>`_
"""
for i in range(0, len(iterable), size):
yield l[i:i + n] | python | def chunks(iterable, size = 8):
"""
from `Stack Overflow <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks>`_
"""
for i in range(0, len(iterable), size):
yield l[i:i + n] | [
"def",
"chunks",
"(",
"iterable",
",",
"size",
"=",
"8",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"iterable",
")",
",",
"size",
")",
":",
"yield",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]"
] | from `Stack Overflow <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks>`_ | [
"from",
"Stack",
"Overflow",
"<http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"312443",
"/",
"how",
"-",
"do",
"-",
"you",
"-",
"split",
"-",
"a",
"-",
"list",
"-",
"into",
"-",
"evenly",
"-",
"sized",
"-",
"chunks",
">",
"_"... | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/conversions.py#L78-L83 |
msfrank/cifparser | cifparser/path.py | make_path | def make_path(*path_or_str_or_segments):
"""
:param path_or_str_or_segments:
:return:
:rtype: cifparser.path.Path
"""
if len(path_or_str_or_segments) == 0:
return ROOT_PATH
elif len(path_or_str_or_segments) == 1:
single_item = path_or_str_or_segments[0]
if isinstance(... | python | def make_path(*path_or_str_or_segments):
"""
:param path_or_str_or_segments:
:return:
:rtype: cifparser.path.Path
"""
if len(path_or_str_or_segments) == 0:
return ROOT_PATH
elif len(path_or_str_or_segments) == 1:
single_item = path_or_str_or_segments[0]
if isinstance(... | [
"def",
"make_path",
"(",
"*",
"path_or_str_or_segments",
")",
":",
"if",
"len",
"(",
"path_or_str_or_segments",
")",
"==",
"0",
":",
"return",
"ROOT_PATH",
"elif",
"len",
"(",
"path_or_str_or_segments",
")",
"==",
"1",
":",
"single_item",
"=",
"path_or_str_or_se... | :param path_or_str_or_segments:
:return:
:rtype: cifparser.path.Path | [
":",
"param",
"path_or_str_or_segments",
":",
":",
"return",
":",
":",
"rtype",
":",
"cifparser",
".",
"path",
".",
"Path"
] | train | https://github.com/msfrank/cifparser/blob/ecd899ba2e7b990e2cec62b115742d830e7e4384/cifparser/path.py#L47-L67 |
ramrod-project/database-brain | schema/brain/decorators.py | deprecated_function | def deprecated_function(func_, replacement="(see docs)",
*args, **kwargs):
"""
decorator to annotate deprecated functions
usage @decorator(replacement="brain.whatever.new_function")
:param func_: <callable>
:param replacement: <str>
:param args: positional arguments
... | python | def deprecated_function(func_, replacement="(see docs)",
*args, **kwargs):
"""
decorator to annotate deprecated functions
usage @decorator(replacement="brain.whatever.new_function")
:param func_: <callable>
:param replacement: <str>
:param args: positional arguments
... | [
"def",
"deprecated_function",
"(",
"func_",
",",
"replacement",
"=",
"\"(see docs)\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"msg",
"=",
"\"{} is deprecated, use {}\\n\"",
".",
"format",
"(",
"func_",
".",
"__name__",
",",
"replacement",
")",
... | decorator to annotate deprecated functions
usage @decorator(replacement="brain.whatever.new_function")
:param func_: <callable>
:param replacement: <str>
:param args: positional arguments
:param kwargs:
:return: <func_'s return value> | [
"decorator",
"to",
"annotate",
"deprecated",
"functions"
] | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/decorators.py#L45-L61 |
lehins/python-wepay | wepay/calls/app.py | App.__modify | def __modify(self, client_id, client_secret, **kwargs):
"""Call documentation: `/app/modify
<https://www.wepay.com/developer/reference/app#modify>`_, plus extra
keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
... | python | def __modify(self, client_id, client_secret, **kwargs):
"""Call documentation: `/app/modify
<https://www.wepay.com/developer/reference/app#modify>`_, plus extra
keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
... | [
"def",
"__modify",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"client_id",
",",
"'client_secret'",
":",
"client_secret",
"}",
"return",
"self",
".",
"make_call",
"(",
"sel... | Call documentation: `/app/modify
<https://www.wepay.com/developer/reference/app#modify>`_, plus extra
keyword parameter:
:keyword bool batch_mode: turn on/off the batch_mode, see
:class:`wepay.api.WePay`
:keyword str batch_reference_id: `reference_id` param for batc... | [
"Call",
"documentation",
":",
"/",
"app",
"/",
"modify",
"<https",
":",
"//",
"www",
".",
"wepay",
".",
"com",
"/",
"developer",
"/",
"reference",
"/",
"app#modify",
">",
"_",
"plus",
"extra",
"keyword",
"parameter",
":",
":",
"keyword",
"bool",
"batch_m... | train | https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/app.py#L31-L50 |
etscrivner/nose-perfdump | perfdump/html.py | HtmlReport.write | def write(cls, html_file):
"""Writes the HTML report to the given file."""
f = open(html_file, 'w')
f.write('<html>')
f.write('<head>')
f.write('</head>')
f.write('<body>')
f.write('<h1>Test times</h1>')
fmt_test = '<tr><td>{:.05f}</td><td>{}</td>... | python | def write(cls, html_file):
"""Writes the HTML report to the given file."""
f = open(html_file, 'w')
f.write('<html>')
f.write('<head>')
f.write('</head>')
f.write('<body>')
f.write('<h1>Test times</h1>')
fmt_test = '<tr><td>{:.05f}</td><td>{}</td>... | [
"def",
"write",
"(",
"cls",
",",
"html_file",
")",
":",
"f",
"=",
"open",
"(",
"html_file",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"'<html>'",
")",
"f",
".",
"write",
"(",
"'<head>'",
")",
"f",
".",
"write",
"(",
"'</head>'",
")",
"f",
".",
"... | Writes the HTML report to the given file. | [
"Writes",
"the",
"HTML",
"report",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/html.py#L36-L81 |
dmckeone/frosty | frosty/includes.py | _import_packages | def _import_packages(packages, optional=None):
"""
Get actual package references from an iterable of package names
:param packages: iterable of package names
:type packages: iter of basestr
:return: set of package references
:rtype: set
"""
if not optional:
optional = []
pac... | python | def _import_packages(packages, optional=None):
"""
Get actual package references from an iterable of package names
:param packages: iterable of package names
:type packages: iter of basestr
:return: set of package references
:rtype: set
"""
if not optional:
optional = []
pac... | [
"def",
"_import_packages",
"(",
"packages",
",",
"optional",
"=",
"None",
")",
":",
"if",
"not",
"optional",
":",
"optional",
"=",
"[",
"]",
"package_references",
"=",
"set",
"(",
")",
"# Check all reqiured packages",
"failures",
"=",
"set",
"(",
")",
"for",... | Get actual package references from an iterable of package names
:param packages: iterable of package names
:type packages: iter of basestr
:return: set of package references
:rtype: set | [
"Get",
"actual",
"package",
"references",
"from",
"an",
"iterable",
"of",
"package",
"names",
":",
"param",
"packages",
":",
"iterable",
"of",
"package",
"names",
":",
"type",
"packages",
":",
"iter",
"of",
"basestr",
":",
"return",
":",
"set",
"of",
"pack... | train | https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/includes.py#L10-L49 |
dmckeone/frosty | frosty/includes.py | build_includes | def build_includes(include_packages, freezer=None, optional=None):
"""
Iterate the list of packages to build a complete list of those packages as well as all subpackages.
:param include_packages: list of package names
:type: include_pacakges: list of basestr
:param freezer: The freezer to use (See ... | python | def build_includes(include_packages, freezer=None, optional=None):
"""
Iterate the list of packages to build a complete list of those packages as well as all subpackages.
:param include_packages: list of package names
:type: include_pacakges: list of basestr
:param freezer: The freezer to use (See ... | [
"def",
"build_includes",
"(",
"include_packages",
",",
"freezer",
"=",
"None",
",",
"optional",
"=",
"None",
")",
":",
"freezer",
"=",
"resolve_freezer",
"(",
"freezer",
")",
"# Import (or get reference to) all listed packages to ensure that they exist.",
"package_reference... | Iterate the list of packages to build a complete list of those packages as well as all subpackages.
:param include_packages: list of package names
:type: include_pacakges: list of basestr
:param freezer: The freezer to use (See FREEZER constants)
:param optional: Optional pacakge names to include (will... | [
"Iterate",
"the",
"list",
"of",
"packages",
"to",
"build",
"a",
"complete",
"list",
"of",
"those",
"packages",
"as",
"well",
"as",
"all",
"subpackages",
"."
] | train | https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/includes.py#L52-L70 |
emencia/emencia_paste_djangocms_3 | emencia_paste_djangocms_3/django_buildout/project/utils/templatetags/i18n_addons.py | locale_title | def locale_title(locale_name):
"""
Giving a locale name return its title, taken from the settings.EXTRA_COUNTRY_LOCALES
If the locale is not in the settings.EXTRA_COUNTRY_LOCALES, return it unchanged
"""
l = dict(settings.EXTRA_COUNTRY_LOCALES)
if locale_name not in l:
return locale... | python | def locale_title(locale_name):
"""
Giving a locale name return its title, taken from the settings.EXTRA_COUNTRY_LOCALES
If the locale is not in the settings.EXTRA_COUNTRY_LOCALES, return it unchanged
"""
l = dict(settings.EXTRA_COUNTRY_LOCALES)
if locale_name not in l:
return locale... | [
"def",
"locale_title",
"(",
"locale_name",
")",
":",
"l",
"=",
"dict",
"(",
"settings",
".",
"EXTRA_COUNTRY_LOCALES",
")",
"if",
"locale_name",
"not",
"in",
"l",
":",
"return",
"locale_name",
"return",
"l",
".",
"get",
"(",
"locale_name",
")"
] | Giving a locale name return its title, taken from the settings.EXTRA_COUNTRY_LOCALES
If the locale is not in the settings.EXTRA_COUNTRY_LOCALES, return it unchanged | [
"Giving",
"a",
"locale",
"name",
"return",
"its",
"title",
"taken",
"from",
"the",
"settings",
".",
"EXTRA_COUNTRY_LOCALES",
"If",
"the",
"locale",
"is",
"not",
"in",
"the",
"settings",
".",
"EXTRA_COUNTRY_LOCALES",
"return",
"it",
"unchanged"
] | train | https://github.com/emencia/emencia_paste_djangocms_3/blob/29eabbcb17e21996a6e1d99592fc719dc8833b59/emencia_paste_djangocms_3/django_buildout/project/utils/templatetags/i18n_addons.py#L17-L26 |
shad7/tvdbapi_client | tvdbapi_client/options.py | _make_opt_list | def _make_opt_list(opts, group):
"""Generate a list of tuple containing group, options
:param opts: option lists associated with a group
:type opts: list
:param group: name of an option group
:type group: str
:return: a list of (group_name, opts) tuples
:rtype: list
"""
import copy
... | python | def _make_opt_list(opts, group):
"""Generate a list of tuple containing group, options
:param opts: option lists associated with a group
:type opts: list
:param group: name of an option group
:type group: str
:return: a list of (group_name, opts) tuples
:rtype: list
"""
import copy
... | [
"def",
"_make_opt_list",
"(",
"opts",
",",
"group",
")",
":",
"import",
"copy",
"import",
"itertools",
"_opts",
"=",
"[",
"(",
"group",
",",
"list",
"(",
"itertools",
".",
"chain",
"(",
"*",
"opts",
")",
")",
")",
"]",
"return",
"[",
"(",
"g",
",",... | Generate a list of tuple containing group, options
:param opts: option lists associated with a group
:type opts: list
:param group: name of an option group
:type group: str
:return: a list of (group_name, opts) tuples
:rtype: list | [
"Generate",
"a",
"list",
"of",
"tuple",
"containing",
"group",
"options"
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/options.py#L32-L46 |
boisei0/pynoramio | pynoramio/__init__.py | Pynoramio._request | def _request(self, lat_min, lon_min, lat_max, lon_max, start, end, picture_size=None, set_=None, map_filter=None):
"""
Internal method to send requests to the Panoramio data API.
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min... | python | def _request(self, lat_min, lon_min, lat_max, lon_max, start, end, picture_size=None, set_=None, map_filter=None):
"""
Internal method to send requests to the Panoramio data API.
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min... | [
"def",
"_request",
"(",
"self",
",",
"lat_min",
",",
"lon_min",
",",
"lat_max",
",",
"lon_max",
",",
"start",
",",
"end",
",",
"picture_size",
"=",
"None",
",",
"set_",
"=",
"None",
",",
"map_filter",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
... | Internal method to send requests to the Panoramio data API.
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min:
Minimum longitude of the bounding box
:type lon_min: float
:param lat_max:
Maximum latitude o... | [
"Internal",
"method",
"to",
"send",
"requests",
"to",
"the",
"Panoramio",
"data",
"API",
"."
] | train | https://github.com/boisei0/pynoramio/blob/d87a1edd691e9bed0527c7b3fe43239687e61546/pynoramio/__init__.py#L18-L95 |
boisei0/pynoramio | pynoramio/__init__.py | Pynoramio.get_from_area | def get_from_area(self, lat_min, lon_min, lat_max, lon_max, picture_size=None, set_=None, map_filter=None):
"""
Get all available photos for a specific bounding box
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min:
... | python | def get_from_area(self, lat_min, lon_min, lat_max, lon_max, picture_size=None, set_=None, map_filter=None):
"""
Get all available photos for a specific bounding box
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min:
... | [
"def",
"get_from_area",
"(",
"self",
",",
"lat_min",
",",
"lon_min",
",",
"lat_max",
",",
"lon_max",
",",
"picture_size",
"=",
"None",
",",
"set_",
"=",
"None",
",",
"map_filter",
"=",
"None",
")",
":",
"page_size",
"=",
"100",
"page",
"=",
"0",
"resul... | Get all available photos for a specific bounding box
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min:
Minimum longitude of the bounding box
:type lon_min: float
:param lat_max:
Maximum latitude of the b... | [
"Get",
"all",
"available",
"photos",
"for",
"a",
"specific",
"bounding",
"box"
] | train | https://github.com/boisei0/pynoramio/blob/d87a1edd691e9bed0527c7b3fe43239687e61546/pynoramio/__init__.py#L97-L146 |
boisei0/pynoramio | pynoramio/__init__.py | Pynoramio.get_all_pictures_cursor | def get_all_pictures_cursor(self, lat_min, lon_min, lat_max, lon_max, picture_size=None, set_=None,
map_filter=None):
"""
Generator to get all available photos for a given bounding box
:param lat_min:
Minimum latitude of the bounding box
:type... | python | def get_all_pictures_cursor(self, lat_min, lon_min, lat_max, lon_max, picture_size=None, set_=None,
map_filter=None):
"""
Generator to get all available photos for a given bounding box
:param lat_min:
Minimum latitude of the bounding box
:type... | [
"def",
"get_all_pictures_cursor",
"(",
"self",
",",
"lat_min",
",",
"lon_min",
",",
"lat_max",
",",
"lon_max",
",",
"picture_size",
"=",
"None",
",",
"set_",
"=",
"None",
",",
"map_filter",
"=",
"None",
")",
":",
"page_size",
"=",
"100",
"page",
"=",
"0"... | Generator to get all available photos for a given bounding box
:param lat_min:
Minimum latitude of the bounding box
:type lat_min: float
:param lon_min:
Minimum longitude of the bounding box
:type lon_min: float
:param lat_max:
Maximum latitud... | [
"Generator",
"to",
"get",
"all",
"available",
"photos",
"for",
"a",
"given",
"bounding",
"box"
] | train | https://github.com/boisei0/pynoramio/blob/d87a1edd691e9bed0527c7b3fe43239687e61546/pynoramio/__init__.py#L148-L203 |
pjuren/pyokit | src/pyokit/datastruct/multipleAlignment.py | MultipleSequenceAlignment.get_column | def get_column(self, position, missing_seqs=MissingSequenceHandler.SKIP):
"""
return a column from an alignment as a dictionary indexed by seq. name.
:param position: the index to extract; these are in alignment
co-ordinates, which are one-based, so the first column
... | python | def get_column(self, position, missing_seqs=MissingSequenceHandler.SKIP):
"""
return a column from an alignment as a dictionary indexed by seq. name.
:param position: the index to extract; these are in alignment
co-ordinates, which are one-based, so the first column
... | [
"def",
"get_column",
"(",
"self",
",",
"position",
",",
"missing_seqs",
"=",
"MissingSequenceHandler",
".",
"SKIP",
")",
":",
"res",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"sequences",
":",
"if",
"isinstance",
"(",
"self",
".",
"sequences",
"[",
... | return a column from an alignment as a dictionary indexed by seq. name.
:param position: the index to extract; these are in alignment
co-ordinates, which are one-based, so the first column
has index 1, and the final column has
index == ... | [
"return",
"a",
"column",
"from",
"an",
"alignment",
"as",
"a",
"dictionary",
"indexed",
"by",
"seq",
".",
"name",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/multipleAlignment.py#L149-L171 |
pjuren/pyokit | src/pyokit/datastruct/multipleAlignment.py | MultipleSequenceAlignment.alignment_to_sequence_coords | def alignment_to_sequence_coords(self, seq_name, start, end, trim=False):
"""
convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
leng... | python | def alignment_to_sequence_coords(self, seq_name, start, end, trim=False):
"""
convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
leng... | [
"def",
"alignment_to_sequence_coords",
"(",
"self",
",",
"seq_name",
",",
"start",
",",
"end",
",",
"trim",
"=",
"False",
")",
":",
"start",
"=",
"1",
"if",
"start",
"<",
"1",
"and",
"trim",
"else",
"start",
"end",
"=",
"self",
".",
"size",
"(",
")",... | convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
length of the alignment (number of columns). Sequence coords follow the
same conventio... | [
"convert",
"an",
"interval",
"in",
"the",
"alignmnet",
"into",
"co",
"-",
"ordinates",
"in",
"one",
"of",
"the",
"sequences",
".",
"Alignment",
"intervals",
"are",
"inclusive",
"of",
"start",
"but",
"not",
"end",
".",
"They",
"are",
"one",
"-",
"based",
... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/multipleAlignment.py#L201-L257 |
pjuren/pyokit | src/pyokit/datastruct/multipleAlignment.py | MultipleSequenceAlignment.sequence_to_alignment_coords | def sequence_to_alignment_coords(self, seq_name, start, end, trim=False):
"""
convert an interval in one of the sequences into an interval in the
alignment. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
lengt... | python | def sequence_to_alignment_coords(self, seq_name, start, end, trim=False):
"""
convert an interval in one of the sequences into an interval in the
alignment. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
lengt... | [
"def",
"sequence_to_alignment_coords",
"(",
"self",
",",
"seq_name",
",",
"start",
",",
"end",
",",
"trim",
"=",
"False",
")",
":",
"# check for valid order of start/end",
"if",
"end",
"<=",
"start",
":",
"raise",
"InvalidSequenceCoordinatesError",
"(",
"\"invalid r... | convert an interval in one of the sequences into an interval in the
alignment. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
length of the alignment (number of columns). Sequence coords follow the
same convention... | [
"convert",
"an",
"interval",
"in",
"one",
"of",
"the",
"sequences",
"into",
"an",
"interval",
"in",
"the",
"alignment",
".",
"Alignment",
"intervals",
"are",
"inclusive",
"of",
"start",
"but",
"not",
"end",
".",
"They",
"are",
"one",
"-",
"based",
".",
"... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/multipleAlignment.py#L259-L336 |
pjuren/pyokit | src/pyokit/datastruct/multipleAlignment.py | MultipleSequenceAlignment.liftover | def liftover(self, origin, dest, o_start, o_end, trim=False):
"""liftover interval in one seq. of this pairwise alignment to the other.
:param origin: name of the origin seq (seq the input coordinates are for)
:param dest: name of the dest. seq (seq the result will be for)
:param o_start: start of ... | python | def liftover(self, origin, dest, o_start, o_end, trim=False):
"""liftover interval in one seq. of this pairwise alignment to the other.
:param origin: name of the origin seq (seq the input coordinates are for)
:param dest: name of the dest. seq (seq the result will be for)
:param o_start: start of ... | [
"def",
"liftover",
"(",
"self",
",",
"origin",
",",
"dest",
",",
"o_start",
",",
"o_end",
",",
"trim",
"=",
"False",
")",
":",
"alig_cols",
"=",
"self",
".",
"sequence_to_alignment_coords",
"(",
"origin",
",",
"o_start",
",",
"o_end",
",",
"trim",
"=",
... | liftover interval in one seq. of this pairwise alignment to the other.
:param origin: name of the origin seq (seq the input coordinates are for)
:param dest: name of the dest. seq (seq the result will be for)
:param o_start: start of the interval (in sequence co-ordinates) to lift.
:param o_end: ... | [
"liftover",
"interval",
"in",
"one",
"seq",
".",
"of",
"this",
"pairwise",
"alignment",
"to",
"the",
"other",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/multipleAlignment.py#L338-L354 |
ourway/marmoolak | marmoolak/__init__.py | Machine._after_event | def _after_event(self, e):
'''
Checks to see if the callback is registered for, after this event is completed.
'''
''' my patch, serialize to redis '''
self.r.set(self.rhname, self.current)
for fnname in ['onafter' + e.event, 'on' + e.event]:
if hasattr(se... | python | def _after_event(self, e):
'''
Checks to see if the callback is registered for, after this event is completed.
'''
''' my patch, serialize to redis '''
self.r.set(self.rhname, self.current)
for fnname in ['onafter' + e.event, 'on' + e.event]:
if hasattr(se... | [
"def",
"_after_event",
"(",
"self",
",",
"e",
")",
":",
"''' my patch, serialize to redis '''",
"self",
".",
"r",
".",
"set",
"(",
"self",
".",
"rhname",
",",
"self",
".",
"current",
")",
"for",
"fnname",
"in",
"[",
"'onafter'",
"+",
"e",
".",
"event",
... | Checks to see if the callback is registered for, after this event is completed. | [
"Checks",
"to",
"see",
"if",
"the",
"callback",
"is",
"registered",
"for",
"after",
"this",
"event",
"is",
"completed",
"."
] | train | https://github.com/ourway/marmoolak/blob/02ce76101ca16d3b1c85d88a92bb7b15dc295ca3/marmoolak/__init__.py#L36-L44 |
EventTeam/beliefs | src/beliefs/cells/strings.py | StringCell.coerce | def coerce(value):
"""
Turns value into a string
"""
if isinstance(value, StringCell):
return value
elif isinstance(value, (str, unicode)):
return StringCell(value)
else:
raise CoercionFailure("Cannot coerce %s to StringCell" % (value)) | python | def coerce(value):
"""
Turns value into a string
"""
if isinstance(value, StringCell):
return value
elif isinstance(value, (str, unicode)):
return StringCell(value)
else:
raise CoercionFailure("Cannot coerce %s to StringCell" % (value)) | [
"def",
"coerce",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"StringCell",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"return",
"StringCell",
"(",
"value",
")",
... | Turns value into a string | [
"Turns",
"value",
"into",
"a",
"string"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/strings.py#L17-L26 |
EventTeam/beliefs | src/beliefs/cells/strings.py | StringCell.is_contradictory | def is_contradictory(self, other):
"""
Can these two strings coexist ?
"""
other = StringCell.coerce(other)
if self.value is None or other.value is None:
# None = empty, and won't contradict anything
return False
def sequence_in(s1, s2):
... | python | def is_contradictory(self, other):
"""
Can these two strings coexist ?
"""
other = StringCell.coerce(other)
if self.value is None or other.value is None:
# None = empty, and won't contradict anything
return False
def sequence_in(s1, s2):
... | [
"def",
"is_contradictory",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"StringCell",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"value",
"is",
"None",
"or",
"other",
".",
"value",
"is",
"None",
":",
"# None = empty, and won't contradict anyt... | Can these two strings coexist ? | [
"Can",
"these",
"two",
"strings",
"coexist",
"?"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/strings.py#L28-L43 |
EventTeam/beliefs | src/beliefs/cells/strings.py | StringCell.is_equal | def is_equal(self, other):
"""
Whether two strings are equal
"""
other = StringCell.coerce(other)
empties = [None,'']
if self.value in empties and other.value in empties:
return True
return self.value == other.value | python | def is_equal(self, other):
"""
Whether two strings are equal
"""
other = StringCell.coerce(other)
empties = [None,'']
if self.value in empties and other.value in empties:
return True
return self.value == other.value | [
"def",
"is_equal",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"StringCell",
".",
"coerce",
"(",
"other",
")",
"empties",
"=",
"[",
"None",
",",
"''",
"]",
"if",
"self",
".",
"value",
"in",
"empties",
"and",
"other",
".",
"value",
"in",
"emp... | Whether two strings are equal | [
"Whether",
"two",
"strings",
"are",
"equal"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/strings.py#L60-L68 |
EventTeam/beliefs | src/beliefs/cells/strings.py | StringCell.merge | def merge(self, other):
"""
Merges two strings
"""
other = StringCell.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
return self
elif self.is_entailed_by(other):
... | python | def merge(self, other):
"""
Merges two strings
"""
other = StringCell.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
return self
elif self.is_entailed_by(other):
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"StringCell",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"is_equal",
"(",
"other",
")",
":",
"# pick among dependencies",
"return",
"self",
"elif",
"other",
".",
"is_entailed_by",... | Merges two strings | [
"Merges",
"two",
"strings"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/strings.py#L70-L87 |
EventTeam/beliefs | src/beliefs/cells/strings.py | StringCell._perform_merge | def _perform_merge(self, other):
"""
Merges the longer string
"""
if len(other.value) > len(self.value):
self.value = other.value[:]
return True | python | def _perform_merge(self, other):
"""
Merges the longer string
"""
if len(other.value) > len(self.value):
self.value = other.value[:]
return True | [
"def",
"_perform_merge",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"other",
".",
"value",
")",
">",
"len",
"(",
"self",
".",
"value",
")",
":",
"self",
".",
"value",
"=",
"other",
".",
"value",
"[",
":",
"]",
"return",
"True"
] | Merges the longer string | [
"Merges",
"the",
"longer",
"string"
] | train | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/strings.py#L89-L95 |
Code4SA/wazimap-mapit | wazimap_mapit/geo.py | GeoData.get_geometry | def get_geometry(self, geo_level, geo_code):
""" Get the geometry description for a geography. This is a dict
with two keys, 'properties' which is a dict of properties,
and 'shape' which is a shapely shape (may be None).
"""
mapit_level = SETTINGS['level_codes'][geo_level]
... | python | def get_geometry(self, geo_level, geo_code):
""" Get the geometry description for a geography. This is a dict
with two keys, 'properties' which is a dict of properties,
and 'shape' which is a shapely shape (may be None).
"""
mapit_level = SETTINGS['level_codes'][geo_level]
... | [
"def",
"get_geometry",
"(",
"self",
",",
"geo_level",
",",
"geo_code",
")",
":",
"mapit_level",
"=",
"SETTINGS",
"[",
"'level_codes'",
"]",
"[",
"geo_level",
"]",
"url",
"=",
"SETTINGS",
"[",
"'url'",
"]",
"+",
"'/area/MDB:%s/feature.geojson?type=%s'",
"%",
"(... | Get the geometry description for a geography. This is a dict
with two keys, 'properties' which is a dict of properties,
and 'shape' which is a shapely shape (may be None). | [
"Get",
"the",
"geometry",
"description",
"for",
"a",
"geography",
".",
"This",
"is",
"a",
"dict",
"with",
"two",
"keys",
"properties",
"which",
"is",
"a",
"dict",
"of",
"properties",
"and",
"shape",
"which",
"is",
"a",
"shapely",
"shape",
"(",
"may",
"be... | train | https://github.com/Code4SA/wazimap-mapit/blob/e72640f760978fa5e63b24a82402d1be1713cee8/wazimap_mapit/geo.py#L30-L53 |
Code4SA/wazimap-mapit | wazimap_mapit/geo.py | GeoData.get_locations_from_coords | def get_locations_from_coords(self, longitude, latitude, levels=None):
"""
Returns a list of geographies containing this point.
"""
resp = requests.get(SETTINGS['url'] + '/point/4326/%s,%s?generation=%s' % (longitude, latitude, SETTINGS['generation']))
resp.raise_for_status()
... | python | def get_locations_from_coords(self, longitude, latitude, levels=None):
"""
Returns a list of geographies containing this point.
"""
resp = requests.get(SETTINGS['url'] + '/point/4326/%s,%s?generation=%s' % (longitude, latitude, SETTINGS['generation']))
resp.raise_for_status()
... | [
"def",
"get_locations_from_coords",
"(",
"self",
",",
"longitude",
",",
"latitude",
",",
"levels",
"=",
"None",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"SETTINGS",
"[",
"'url'",
"]",
"+",
"'/point/4326/%s,%s?generation=%s'",
"%",
"(",
"longitude",
... | Returns a list of geographies containing this point. | [
"Returns",
"a",
"list",
"of",
"geographies",
"containing",
"this",
"point",
"."
] | train | https://github.com/Code4SA/wazimap-mapit/blob/e72640f760978fa5e63b24a82402d1be1713cee8/wazimap_mapit/geo.py#L55-L73 |
openbermuda/ripl | ripl/imagefind.py | ImageFind.add_folder | def add_folder(self, folder):
""" Add a folder scan images there """
if folder in self.folders:
return
self.folders.add(folder)
for subfolder, junk, filenames in os.walk(folder):
for filename in filenames:
name, ext = os.path.splitext(fil... | python | def add_folder(self, folder):
""" Add a folder scan images there """
if folder in self.folders:
return
self.folders.add(folder)
for subfolder, junk, filenames in os.walk(folder):
for filename in filenames:
name, ext = os.path.splitext(fil... | [
"def",
"add_folder",
"(",
"self",
",",
"folder",
")",
":",
"if",
"folder",
"in",
"self",
".",
"folders",
":",
"return",
"self",
".",
"folders",
".",
"add",
"(",
"folder",
")",
"for",
"subfolder",
",",
"junk",
",",
"filenames",
"in",
"os",
".",
"walk"... | Add a folder scan images there | [
"Add",
"a",
"folder",
"scan",
"images",
"there"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/imagefind.py#L28-L40 |
openbermuda/ripl | ripl/imagefind.py | ImageFind.interpret | def interpret(self, msg):
""" Try and find the image file
some magic here would be good.
FIXME move elsewhere and make so everyone can use.
interpreter that finds things?
"""
for gallery in msg.get('galleries', []):
self.add_folder(gallery)
... | python | def interpret(self, msg):
""" Try and find the image file
some magic here would be good.
FIXME move elsewhere and make so everyone can use.
interpreter that finds things?
"""
for gallery in msg.get('galleries', []):
self.add_folder(gallery)
... | [
"def",
"interpret",
"(",
"self",
",",
"msg",
")",
":",
"for",
"gallery",
"in",
"msg",
".",
"get",
"(",
"'galleries'",
",",
"[",
"]",
")",
":",
"self",
".",
"add_folder",
"(",
"gallery",
")",
"image_file",
"=",
"msg",
".",
"get",
"(",
"'image'",
")"... | Try and find the image file
some magic here would be good.
FIXME move elsewhere and make so everyone can use.
interpreter that finds things? | [
"Try",
"and",
"find",
"the",
"image",
"file"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/imagefind.py#L44-L59 |
mfcovington/djangocms-lab-members | cms_lab_members/menu.py | LabMembersMenu.get_nodes | def get_nodes(self, request):
"""
This method is used to build the menu tree.
"""
nodes = []
for scientist in Scientist.objects.filter(current=True, visible=True):
node = NavigationNode(
scientist.full_name,
reverse('lab_members:scienti... | python | def get_nodes(self, request):
"""
This method is used to build the menu tree.
"""
nodes = []
for scientist in Scientist.objects.filter(current=True, visible=True):
node = NavigationNode(
scientist.full_name,
reverse('lab_members:scienti... | [
"def",
"get_nodes",
"(",
"self",
",",
"request",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"scientist",
"in",
"Scientist",
".",
"objects",
".",
"filter",
"(",
"current",
"=",
"True",
",",
"visible",
"=",
"True",
")",
":",
"node",
"=",
"NavigationNode",
... | This method is used to build the menu tree. | [
"This",
"method",
"is",
"used",
"to",
"build",
"the",
"menu",
"tree",
"."
] | train | https://github.com/mfcovington/djangocms-lab-members/blob/c2b0251d985255265b9ba9fbce41a772ea92174c/cms_lab_members/menu.py#L15-L36 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.publisherSocket | def publisherSocket(self,
port,
connect=False,
host='*',
hwm=1):
'''
Create a PUB-style socket for data publishers.
If <connect> is true, connects to a XPUB/XSUB forwarding device.
'''
... | python | def publisherSocket(self,
port,
connect=False,
host='*',
hwm=1):
'''
Create a PUB-style socket for data publishers.
If <connect> is true, connects to a XPUB/XSUB forwarding device.
'''
... | [
"def",
"publisherSocket",
"(",
"self",
",",
"port",
",",
"connect",
"=",
"False",
",",
"host",
"=",
"'*'",
",",
"hwm",
"=",
"1",
")",
":",
"socket",
"=",
"self",
".",
"_context",
".",
"socket",
"(",
"zmq",
".",
"PUB",
")",
"socket",
".",
"setsockop... | Create a PUB-style socket for data publishers.
If <connect> is true, connects to a XPUB/XSUB forwarding device. | [
"Create",
"a",
"PUB",
"-",
"style",
"socket",
"for",
"data",
"publishers",
".",
"If",
"<connect",
">",
"is",
"true",
"connects",
"to",
"a",
"XPUB",
"/",
"XSUB",
"forwarding",
"device",
"."
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L63-L84 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.subscriberSocket | def subscriberSocket(self, host, port, filt=b'', conflate=False):
'''
Create a SUB-style socket for data receivers
'''
socket = self._context.socket(zmq.SUB)
if conflate:
socket.setsockopt(zmq.CONFLATE, 1)
socket.connect(self.tcpAddress(host, port))
s... | python | def subscriberSocket(self, host, port, filt=b'', conflate=False):
'''
Create a SUB-style socket for data receivers
'''
socket = self._context.socket(zmq.SUB)
if conflate:
socket.setsockopt(zmq.CONFLATE, 1)
socket.connect(self.tcpAddress(host, port))
s... | [
"def",
"subscriberSocket",
"(",
"self",
",",
"host",
",",
"port",
",",
"filt",
"=",
"b''",
",",
"conflate",
"=",
"False",
")",
":",
"socket",
"=",
"self",
".",
"_context",
".",
"socket",
"(",
"zmq",
".",
"SUB",
")",
"if",
"conflate",
":",
"socket",
... | Create a SUB-style socket for data receivers | [
"Create",
"a",
"SUB",
"-",
"style",
"socket",
"for",
"data",
"receivers"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L91-L101 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.xpubsubSockets | def xpubsubSockets(self, hostSub, portSub, hostPub, portPub):
'''
Creates frontend and backend for a XPUB/XSUB forwarding device
'''
frontend_addr = self.tcpAddress(hostSub, portSub)
backend_addr = self.tcpAddress(hostPub, portPub)
frontendSocket = self._context.socket(z... | python | def xpubsubSockets(self, hostSub, portSub, hostPub, portPub):
'''
Creates frontend and backend for a XPUB/XSUB forwarding device
'''
frontend_addr = self.tcpAddress(hostSub, portSub)
backend_addr = self.tcpAddress(hostPub, portPub)
frontendSocket = self._context.socket(z... | [
"def",
"xpubsubSockets",
"(",
"self",
",",
"hostSub",
",",
"portSub",
",",
"hostPub",
",",
"portPub",
")",
":",
"frontend_addr",
"=",
"self",
".",
"tcpAddress",
"(",
"hostSub",
",",
"portSub",
")",
"backend_addr",
"=",
"self",
".",
"tcpAddress",
"(",
"host... | Creates frontend and backend for a XPUB/XSUB forwarding device | [
"Creates",
"frontend",
"and",
"backend",
"for",
"a",
"XPUB",
"/",
"XSUB",
"forwarding",
"device"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L104-L118 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.replySocket | def replySocket(self, port, host='*'):
'''
Create a REP-style socket for servers
'''
try:
socket = self._context.socket(zmq.REP)
socket.bind(self.tcpAddress(host, port))
except Exception as e:
newMsg= str("%s %s:%d" % (str(e), host, port))
... | python | def replySocket(self, port, host='*'):
'''
Create a REP-style socket for servers
'''
try:
socket = self._context.socket(zmq.REP)
socket.bind(self.tcpAddress(host, port))
except Exception as e:
newMsg= str("%s %s:%d" % (str(e), host, port))
... | [
"def",
"replySocket",
"(",
"self",
",",
"port",
",",
"host",
"=",
"'*'",
")",
":",
"try",
":",
"socket",
"=",
"self",
".",
"_context",
".",
"socket",
"(",
"zmq",
".",
"REP",
")",
"socket",
".",
"bind",
"(",
"self",
".",
"tcpAddress",
"(",
"host",
... | Create a REP-style socket for servers | [
"Create",
"a",
"REP",
"-",
"style",
"socket",
"for",
"servers"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L122-L132 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.requestSocket | def requestSocket(self, host, port):
'''
Create a REQ-style socket for clients
'''
socket = self._context.socket(zmq.REQ)
socket.connect(self.tcpAddress(host, port))
return socket | python | def requestSocket(self, host, port):
'''
Create a REQ-style socket for clients
'''
socket = self._context.socket(zmq.REQ)
socket.connect(self.tcpAddress(host, port))
return socket | [
"def",
"requestSocket",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"socket",
"=",
"self",
".",
"_context",
".",
"socket",
"(",
"zmq",
".",
"REQ",
")",
"socket",
".",
"connect",
"(",
"self",
".",
"tcpAddress",
"(",
"host",
",",
"port",
")",
")... | Create a REQ-style socket for clients | [
"Create",
"a",
"REQ",
"-",
"style",
"socket",
"for",
"clients"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L136-L142 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.sendRequest | def sendRequest(self, socket, cmd, args=(), timeout=10):
'''
Perform client request/reply
Request is a ZMQ multipart message:
- command string
- pickled argument list
Reply is a pickled object
'''
self._logger.debug("sending request %s %s" % (cmd, args))... | python | def sendRequest(self, socket, cmd, args=(), timeout=10):
'''
Perform client request/reply
Request is a ZMQ multipart message:
- command string
- pickled argument list
Reply is a pickled object
'''
self._logger.debug("sending request %s %s" % (cmd, args))... | [
"def",
"sendRequest",
"(",
"self",
",",
"socket",
",",
"cmd",
",",
"args",
"=",
"(",
")",
",",
"timeout",
"=",
"10",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"sending request %s %s\"",
"%",
"(",
"cmd",
",",
"args",
")",
")",
"t0",
"="... | Perform client request/reply
Request is a ZMQ multipart message:
- command string
- pickled argument list
Reply is a pickled object | [
"Perform",
"client",
"request",
"/",
"reply",
"Request",
"is",
"a",
"ZMQ",
"multipart",
"message",
":",
"-",
"command",
"string",
"-",
"pickled",
"argument",
"list",
"Reply",
"is",
"a",
"pickled",
"object"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L178-L200 |
lbusoni/plico | plico/rpc/zmq_remote_procedure_call.py | ZmqRemoteProcedureCall.handleRequest | def handleRequest(self, obj, socket, multi=False):
'''
Handle one or more requests on a REP socket, with the format
sent by sendRequest()
'''
while 1:
try:
msg = socket.recv_multipart(zmq.NOBLOCK)
method = msg[0].decode()
... | python | def handleRequest(self, obj, socket, multi=False):
'''
Handle one or more requests on a REP socket, with the format
sent by sendRequest()
'''
while 1:
try:
msg = socket.recv_multipart(zmq.NOBLOCK)
method = msg[0].decode()
... | [
"def",
"handleRequest",
"(",
"self",
",",
"obj",
",",
"socket",
",",
"multi",
"=",
"False",
")",
":",
"while",
"1",
":",
"try",
":",
"msg",
"=",
"socket",
".",
"recv_multipart",
"(",
"zmq",
".",
"NOBLOCK",
")",
"method",
"=",
"msg",
"[",
"0",
"]",
... | Handle one or more requests on a REP socket, with the format
sent by sendRequest() | [
"Handle",
"one",
"or",
"more",
"requests",
"on",
"a",
"REP",
"socket",
"with",
"the",
"format",
"sent",
"by",
"sendRequest",
"()"
] | train | https://github.com/lbusoni/plico/blob/08a29da8f06e920470516838878a51ac83bab847/plico/rpc/zmq_remote_procedure_call.py#L215-L244 |
klen/muffin-babel | muffin_babel.py | parse_accept_header | def parse_accept_header(header):
"""Parse accept headers."""
result = []
for match in accept_re.finditer(header):
quality = match.group(2)
if not quality:
quality = 1
else:
quality = max(min(float(quality), 1), 0)
result.append((match.group(1), quality... | python | def parse_accept_header(header):
"""Parse accept headers."""
result = []
for match in accept_re.finditer(header):
quality = match.group(2)
if not quality:
quality = 1
else:
quality = max(min(float(quality), 1), 0)
result.append((match.group(1), quality... | [
"def",
"parse_accept_header",
"(",
"header",
")",
":",
"result",
"=",
"[",
"]",
"for",
"match",
"in",
"accept_re",
".",
"finditer",
"(",
"header",
")",
":",
"quality",
"=",
"match",
".",
"group",
"(",
"2",
")",
"if",
"not",
"quality",
":",
"quality",
... | Parse accept headers. | [
"Parse",
"accept",
"headers",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L44-L54 |
klen/muffin-babel | muffin_babel.py | Plugin.setup | def setup(self, app):
"""Setup the plugin's commands."""
super(Plugin, self).setup(app)
if isinstance(self.cfg['locales_dirs'], str):
self.cfg['locales_dirs'] = [self.cfg['locales_dirs']]
@app.manage.command(init=False)
def extract_messages( # noqa
... | python | def setup(self, app):
"""Setup the plugin's commands."""
super(Plugin, self).setup(app)
if isinstance(self.cfg['locales_dirs'], str):
self.cfg['locales_dirs'] = [self.cfg['locales_dirs']]
@app.manage.command(init=False)
def extract_messages( # noqa
... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"setup",
"(",
"app",
")",
"if",
"isinstance",
"(",
"self",
".",
"cfg",
"[",
"'locales_dirs'",
"]",
",",
"str",
")",
":",
"self",
".",
"cfg",
"[",
... | Setup the plugin's commands. | [
"Setup",
"the",
"plugin",
"s",
"commands",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L81-L156 |
klen/muffin-babel | muffin_babel.py | Plugin.startup | async def startup(self, app):
"""Initialize a local namespace and setup Jinja2."""
self.local = slocal(app.loop)
if self.cfg.configure_jinja2 and 'jinja2' in app.ps:
app.ps.jinja2.env.add_extension('jinja2.ext.i18n')
app.ps.jinja2.env.install_gettext_callables(
... | python | async def startup(self, app):
"""Initialize a local namespace and setup Jinja2."""
self.local = slocal(app.loop)
if self.cfg.configure_jinja2 and 'jinja2' in app.ps:
app.ps.jinja2.env.add_extension('jinja2.ext.i18n')
app.ps.jinja2.env.install_gettext_callables(
... | [
"async",
"def",
"startup",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"local",
"=",
"slocal",
"(",
"app",
".",
"loop",
")",
"if",
"self",
".",
"cfg",
".",
"configure_jinja2",
"and",
"'jinja2'",
"in",
"app",
".",
"ps",
":",
"app",
".",
"ps",
... | Initialize a local namespace and setup Jinja2. | [
"Initialize",
"a",
"local",
"namespace",
"and",
"setup",
"Jinja2",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L158-L170 |
klen/muffin-babel | muffin_babel.py | Plugin.get_translations | def get_translations(self, domain=None, locale=None):
"""Load translations for given or configuration domain.
:param domain: Messages domain (str)
:param locale: Locale object
"""
if locale is None:
if self.locale is None:
return support.NullTranslat... | python | def get_translations(self, domain=None, locale=None):
"""Load translations for given or configuration domain.
:param domain: Messages domain (str)
:param locale: Locale object
"""
if locale is None:
if self.locale is None:
return support.NullTranslat... | [
"def",
"get_translations",
"(",
"self",
",",
"domain",
"=",
"None",
",",
"locale",
"=",
"None",
")",
":",
"if",
"locale",
"is",
"None",
":",
"if",
"self",
".",
"locale",
"is",
"None",
":",
"return",
"support",
".",
"NullTranslations",
"(",
")",
"locale... | Load translations for given or configuration domain.
:param domain: Messages domain (str)
:param locale: Locale object | [
"Load",
"translations",
"for",
"given",
"or",
"configuration",
"domain",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L179-L207 |
klen/muffin-babel | muffin_babel.py | Plugin.locale | def locale(self, value):
"""Set current locale."""
if not isinstance(value, Locale):
value = Locale.parse(value)
self.local.babel_locale = value | python | def locale(self, value):
"""Set current locale."""
if not isinstance(value, Locale):
value = Locale.parse(value)
self.local.babel_locale = value | [
"def",
"locale",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"Locale",
")",
":",
"value",
"=",
"Locale",
".",
"parse",
"(",
"value",
")",
"self",
".",
"local",
".",
"babel_locale",
"=",
"value"
] | Set current locale. | [
"Set",
"current",
"locale",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L219-L223 |
klen/muffin-babel | muffin_babel.py | Plugin.select_locale_by_request | def select_locale_by_request(self, request, locales=()):
"""Choose an user's locales by request."""
default_locale = locales and locales[0] or self.cfg.default_locale
if len(locales) == 1 or 'ACCEPT-LANGUAGE' not in request.headers:
return default_locale
ulocales = [
... | python | def select_locale_by_request(self, request, locales=()):
"""Choose an user's locales by request."""
default_locale = locales and locales[0] or self.cfg.default_locale
if len(locales) == 1 or 'ACCEPT-LANGUAGE' not in request.headers:
return default_locale
ulocales = [
... | [
"def",
"select_locale_by_request",
"(",
"self",
",",
"request",
",",
"locales",
"=",
"(",
")",
")",
":",
"default_locale",
"=",
"locales",
"and",
"locales",
"[",
"0",
"]",
"or",
"self",
".",
"cfg",
".",
"default_locale",
"if",
"len",
"(",
"locales",
")",... | Choose an user's locales by request. | [
"Choose",
"an",
"user",
"s",
"locales",
"by",
"request",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L225-L245 |
klen/muffin-babel | muffin_babel.py | Plugin.gettext | def gettext(self, string, domain=None, **variables):
"""Translate a string with the current locale."""
t = self.get_translations(domain)
return t.ugettext(string) % variables | python | def gettext(self, string, domain=None, **variables):
"""Translate a string with the current locale."""
t = self.get_translations(domain)
return t.ugettext(string) % variables | [
"def",
"gettext",
"(",
"self",
",",
"string",
",",
"domain",
"=",
"None",
",",
"*",
"*",
"variables",
")",
":",
"t",
"=",
"self",
".",
"get_translations",
"(",
"domain",
")",
"return",
"t",
".",
"ugettext",
"(",
"string",
")",
"%",
"variables"
] | Translate a string with the current locale. | [
"Translate",
"a",
"string",
"with",
"the",
"current",
"locale",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L247-L250 |
klen/muffin-babel | muffin_babel.py | Plugin.ngettext | def ngettext(self, singular, plural, num, domain=None, **variables):
"""Translate a string wity the current locale.
The `num` parameter is used to dispatch between singular and various plural forms of the
message.
"""
variables.setdefault('num', num)
t = self.get_transl... | python | def ngettext(self, singular, plural, num, domain=None, **variables):
"""Translate a string wity the current locale.
The `num` parameter is used to dispatch between singular and various plural forms of the
message.
"""
variables.setdefault('num', num)
t = self.get_transl... | [
"def",
"ngettext",
"(",
"self",
",",
"singular",
",",
"plural",
",",
"num",
",",
"domain",
"=",
"None",
",",
"*",
"*",
"variables",
")",
":",
"variables",
".",
"setdefault",
"(",
"'num'",
",",
"num",
")",
"t",
"=",
"self",
".",
"get_translations",
"(... | Translate a string wity the current locale.
The `num` parameter is used to dispatch between singular and various plural forms of the
message. | [
"Translate",
"a",
"string",
"wity",
"the",
"current",
"locale",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L252-L261 |
klen/muffin-babel | muffin_babel.py | Plugin.pgettext | def pgettext(self, context, string, domain=None, **variables):
"""Like :meth:`gettext` but with a context."""
t = self.get_translations(domain)
return t.upgettext(context, string) % variables | python | def pgettext(self, context, string, domain=None, **variables):
"""Like :meth:`gettext` but with a context."""
t = self.get_translations(domain)
return t.upgettext(context, string) % variables | [
"def",
"pgettext",
"(",
"self",
",",
"context",
",",
"string",
",",
"domain",
"=",
"None",
",",
"*",
"*",
"variables",
")",
":",
"t",
"=",
"self",
".",
"get_translations",
"(",
"domain",
")",
"return",
"t",
".",
"upgettext",
"(",
"context",
",",
"str... | Like :meth:`gettext` but with a context. | [
"Like",
":",
"meth",
":",
"gettext",
"but",
"with",
"a",
"context",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L263-L266 |
klen/muffin-babel | muffin_babel.py | Plugin.npgettext | def npgettext(self, context, singular, plural, num, domain=None, **variables):
"""Like :meth:`ngettext` but with a context."""
variables.setdefault('num', num)
t = self.get_translations(domain)
return t.unpgettext(context, singular, plural, num) % variables | python | def npgettext(self, context, singular, plural, num, domain=None, **variables):
"""Like :meth:`ngettext` but with a context."""
variables.setdefault('num', num)
t = self.get_translations(domain)
return t.unpgettext(context, singular, plural, num) % variables | [
"def",
"npgettext",
"(",
"self",
",",
"context",
",",
"singular",
",",
"plural",
",",
"num",
",",
"domain",
"=",
"None",
",",
"*",
"*",
"variables",
")",
":",
"variables",
".",
"setdefault",
"(",
"'num'",
",",
"num",
")",
"t",
"=",
"self",
".",
"ge... | Like :meth:`ngettext` but with a context. | [
"Like",
":",
"meth",
":",
"ngettext",
"but",
"with",
"a",
"context",
"."
] | train | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/muffin_babel.py#L268-L272 |
KnowledgeLinks/rdfframework | rdfframework/datamanager/defmanager.py | DefinitionManager.load | def load(self, file_locations=[], **kwargs):
""" Loads the file_locations into the triplestores
args:
file_locations: list of tuples to load
[('vocabularies', [list of vocabs to load])
('directory', '/directory/path')
('filepath'... | python | def load(self, file_locations=[], **kwargs):
""" Loads the file_locations into the triplestores
args:
file_locations: list of tuples to load
[('vocabularies', [list of vocabs to load])
('directory', '/directory/path')
('filepath'... | [
"def",
"load",
"(",
"self",
",",
"file_locations",
"=",
"[",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"__set_cache_dir__",
"(",
"*",
"*",
"kwargs",
")",
"conn",
"=",
"self",
".",
"__get_conn__",
"(",
"*",
"*",
"kwargs",
")",
"self",
"."... | Loads the file_locations into the triplestores
args:
file_locations: list of tuples to load
[('vocabularies', [list of vocabs to load])
('directory', '/directory/path')
('filepath', '/path/to/a/file')
('package_all',... | [
"Loads",
"the",
"file_locations",
"into",
"the",
"triplestores"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datamanager/defmanager.py#L145-L174 |
KnowledgeLinks/rdfframework | rdfframework/datamanager/defmanager.py | DefinitionManager.load_vocab | def load_vocab(self, vocab_name, **kwargs):
""" loads a vocabulary into the defintion triplestore
args:
vocab_name: the prefix, uri or filename of a vocabulary
"""
log.setLevel(kwargs.get("log_level", self.log_level))
vocab = self.get_vocab(vocab_name , **kwargs)
... | python | def load_vocab(self, vocab_name, **kwargs):
""" loads a vocabulary into the defintion triplestore
args:
vocab_name: the prefix, uri or filename of a vocabulary
"""
log.setLevel(kwargs.get("log_level", self.log_level))
vocab = self.get_vocab(vocab_name , **kwargs)
... | [
"def",
"load_vocab",
"(",
"self",
",",
"vocab_name",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"setLevel",
"(",
"kwargs",
".",
"get",
"(",
"\"log_level\"",
",",
"self",
".",
"log_level",
")",
")",
"vocab",
"=",
"self",
".",
"get_vocab",
"(",
"vo... | loads a vocabulary into the defintion triplestore
args:
vocab_name: the prefix, uri or filename of a vocabulary | [
"loads",
"a",
"vocabulary",
"into",
"the",
"defintion",
"triplestore"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datamanager/defmanager.py#L194-L219 |
KnowledgeLinks/rdfframework | rdfframework/datamanager/defmanager.py | DefinitionManager.get_vocab | def get_vocab(self, vocab_name, **kwargs):
""" Returns data stream of an rdf vocabulary
args:
vocab_name: the name or uri of the vocab to return
"""
vocab_dict = self.__get_vocab_dict__(vocab_name, **kwargs)
filepaths = list(set([os.path.join(self.cache_dir,
... | python | def get_vocab(self, vocab_name, **kwargs):
""" Returns data stream of an rdf vocabulary
args:
vocab_name: the name or uri of the vocab to return
"""
vocab_dict = self.__get_vocab_dict__(vocab_name, **kwargs)
filepaths = list(set([os.path.join(self.cache_dir,
... | [
"def",
"get_vocab",
"(",
"self",
",",
"vocab_name",
",",
"*",
"*",
"kwargs",
")",
":",
"vocab_dict",
"=",
"self",
".",
"__get_vocab_dict__",
"(",
"vocab_name",
",",
"*",
"*",
"kwargs",
")",
"filepaths",
"=",
"list",
"(",
"set",
"(",
"[",
"os",
".",
"... | Returns data stream of an rdf vocabulary
args:
vocab_name: the name or uri of the vocab to return | [
"Returns",
"data",
"stream",
"of",
"an",
"rdf",
"vocabulary"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datamanager/defmanager.py#L236-L265 |
KnowledgeLinks/rdfframework | rdfframework/datamanager/defmanager.py | DefinitionManager.drop_vocab | def drop_vocab(self, vocab_name, **kwargs):
""" Removes the vocab from the definiton triplestore
args:
vocab_name: the name or uri of the vocab to return
"""
vocab_dict = self.__get_vocab_dict__(vocab_name, **kwargs)
return self.drop_file(vocab_dict['filename'], **k... | python | def drop_vocab(self, vocab_name, **kwargs):
""" Removes the vocab from the definiton triplestore
args:
vocab_name: the name or uri of the vocab to return
"""
vocab_dict = self.__get_vocab_dict__(vocab_name, **kwargs)
return self.drop_file(vocab_dict['filename'], **k... | [
"def",
"drop_vocab",
"(",
"self",
",",
"vocab_name",
",",
"*",
"*",
"kwargs",
")",
":",
"vocab_dict",
"=",
"self",
".",
"__get_vocab_dict__",
"(",
"vocab_name",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"drop_file",
"(",
"vocab_dict",
"[",
"'f... | Removes the vocab from the definiton triplestore
args:
vocab_name: the name or uri of the vocab to return | [
"Removes",
"the",
"vocab",
"from",
"the",
"definiton",
"triplestore"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datamanager/defmanager.py#L267-L275 |
djangothon/ab | ab/decorators.py | quick | def quick(config, mysterious=None, only_authenticated=None):
"""
Decides whether this user is allowed to access this view or not.
:param config - Decides if the setting is on globally.
:callable_name - The function which will return the list of users which are
eligible for proceedi... | python | def quick(config, mysterious=None, only_authenticated=None):
"""
Decides whether this user is allowed to access this view or not.
:param config - Decides if the setting is on globally.
:callable_name - The function which will return the list of users which are
eligible for proceedi... | [
"def",
"quick",
"(",
"config",
",",
"mysterious",
"=",
"None",
",",
"only_authenticated",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_quick",
"(",
"request",
",",
"*",
"args",
",",
"*",
... | Decides whether this user is allowed to access this view or not.
:param config - Decides if the setting is on globally.
:callable_name - The function which will return the list of users which are
eligible for proceeding further after this action. | [
"Decides",
"whether",
"this",
"user",
"is",
"allowed",
"to",
"access",
"this",
"view",
"or",
"not",
"."
] | train | https://github.com/djangothon/ab/blob/2075d27805ad94b11535a11439027ce8d0c8ab83/ab/decorators.py#L18-L67 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/ha.py | HA.catch | def catch(cls, catch_exception, config='default'):
"""Decorator class method catching exceptions raised by the wrapped
member function. When exception is caught, the decorator waits
for an amount of time specified in the `ha_config`.
:param catch_exception: Exception class or tuple of e... | python | def catch(cls, catch_exception, config='default'):
"""Decorator class method catching exceptions raised by the wrapped
member function. When exception is caught, the decorator waits
for an amount of time specified in the `ha_config`.
:param catch_exception: Exception class or tuple of e... | [
"def",
"catch",
"(",
"cls",
",",
"catch_exception",
",",
"config",
"=",
"'default'",
")",
":",
"def",
"wrap",
"(",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"wrapped_method",
"(",
"self",
",",
"*",
"args",
",",
"*... | Decorator class method catching exceptions raised by the wrapped
member function. When exception is caught, the decorator waits
for an amount of time specified in the `ha_config`.
:param catch_exception: Exception class or tuple of exception classes. | [
"Decorator",
"class",
"method",
"catching",
"exceptions",
"raised",
"by",
"the",
"wrapped",
"member",
"function",
".",
"When",
"exception",
"is",
"caught",
"the",
"decorator",
"waits",
"for",
"an",
"amount",
"of",
"time",
"specified",
"in",
"the",
"ha_config",
... | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/ha.py#L74-L99 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/ha.py | HA.ha_get_delay_policy | def ha_get_delay_policy(self, config_name):
"""Build generator of delays to wait between each call
:param string config_name: configuration name
"""
config = self.ha_get_config(config_name)
delay_policy_conf = config.delay_config
delay_policy_conf = copy.deepcopy(delay_p... | python | def ha_get_delay_policy(self, config_name):
"""Build generator of delays to wait between each call
:param string config_name: configuration name
"""
config = self.ha_get_config(config_name)
delay_policy_conf = config.delay_config
delay_policy_conf = copy.deepcopy(delay_p... | [
"def",
"ha_get_delay_policy",
"(",
"self",
",",
"config_name",
")",
":",
"config",
"=",
"self",
".",
"ha_get_config",
"(",
"config_name",
")",
"delay_policy_conf",
"=",
"config",
".",
"delay_config",
"delay_policy_conf",
"=",
"copy",
".",
"deepcopy",
"(",
"delay... | Build generator of delays to wait between each call
:param string config_name: configuration name | [
"Build",
"generator",
"of",
"delays",
"to",
"wait",
"between",
"each",
"call"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/ha.py#L104-L116 |
wooyek/django-powerbank | src/django_powerbank/db/models/fields/__init__.py | JSONField.to_python | def to_python(self, value):
"""
Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be converted.
"""
if self.blank and not value:
return {}
value = value or '{}'
if isinstance(value, six... | python | def to_python(self, value):
"""
Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be converted.
"""
if self.blank and not value:
return {}
value = value or '{}'
if isinstance(value, six... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"blank",
"and",
"not",
"value",
":",
"return",
"{",
"}",
"value",
"=",
"value",
"or",
"'{}'",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"binary_type",
")",
":",
"v... | Convert the input JSON value into python structures, raises
django.core.exceptions.ValidationError if the data can't be converted. | [
"Convert",
"the",
"input",
"JSON",
"value",
"into",
"python",
"structures",
"raises",
"django",
".",
"core",
".",
"exceptions",
".",
"ValidationError",
"if",
"the",
"data",
"can",
"t",
"be",
"converted",
"."
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/db/models/fields/__init__.py#L157-L177 |
wooyek/django-powerbank | src/django_powerbank/db/models/fields/__init__.py | JSONField.validate | def validate(self, value, model_instance):
"""Check value is a valid JSON string, raise ValidationError on
error."""
if isinstance(value, six.string_types):
super(JSONField, self).validate(value, model_instance)
try:
json.loads(value)
except Ex... | python | def validate(self, value, model_instance):
"""Check value is a valid JSON string, raise ValidationError on
error."""
if isinstance(value, six.string_types):
super(JSONField, self).validate(value, model_instance)
try:
json.loads(value)
except Ex... | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"model_instance",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"super",
"(",
"JSONField",
",",
"self",
")",
".",
"validate",
"(",
"value",
",",
"model_instance",... | Check value is a valid JSON string, raise ValidationError on
error. | [
"Check",
"value",
"is",
"a",
"valid",
"JSON",
"string",
"raise",
"ValidationError",
"on",
"error",
"."
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/db/models/fields/__init__.py#L179-L187 |
wooyek/django-powerbank | src/django_powerbank/db/models/fields/__init__.py | JSONField.get_prep_value | def get_prep_value(self, value):
"""Convert value to JSON string before save"""
try:
return json.dumps(value)
except Exception as err:
raise ValidationError(str(err)) | python | def get_prep_value(self, value):
"""Convert value to JSON string before save"""
try:
return json.dumps(value)
except Exception as err:
raise ValidationError(str(err)) | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"return",
"json",
".",
"dumps",
"(",
"value",
")",
"except",
"Exception",
"as",
"err",
":",
"raise",
"ValidationError",
"(",
"str",
"(",
"err",
")",
")"
] | Convert value to JSON string before save | [
"Convert",
"value",
"to",
"JSON",
"string",
"before",
"save"
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/db/models/fields/__init__.py#L189-L194 |
wooyek/django-powerbank | src/django_powerbank/db/models/fields/__init__.py | JSONField.value_to_string | def value_to_string(self, obj):
"""Return value from object converted to string properly"""
value = getattr(obj, self.attname)
return self.get_prep_value(value) | python | def value_to_string(self, obj):
"""Return value from object converted to string properly"""
value = getattr(obj, self.attname)
return self.get_prep_value(value) | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"attname",
")",
"return",
"self",
".",
"get_prep_value",
"(",
"value",
")"
] | Return value from object converted to string properly | [
"Return",
"value",
"from",
"object",
"converted",
"to",
"string",
"properly"
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/db/models/fields/__init__.py#L196-L199 |
dcolish/Refugee | refugee/cli.py | RefugeeCmd.do_down | def do_down(self, arg):
"""Run down migration with name or numeric id matching arg"""
print "running down migration"
self.manager.run_one(arg, Direction.DOWN) | python | def do_down(self, arg):
"""Run down migration with name or numeric id matching arg"""
print "running down migration"
self.manager.run_one(arg, Direction.DOWN) | [
"def",
"do_down",
"(",
"self",
",",
"arg",
")",
":",
"print",
"\"running down migration\"",
"self",
".",
"manager",
".",
"run_one",
"(",
"arg",
",",
"Direction",
".",
"DOWN",
")"
] | Run down migration with name or numeric id matching arg | [
"Run",
"down",
"migration",
"with",
"name",
"or",
"numeric",
"id",
"matching",
"arg"
] | train | https://github.com/dcolish/Refugee/blob/b98391cb3127d09b15b59c7c25dab07a968062fa/refugee/cli.py#L36-L39 |
dcolish/Refugee | refugee/cli.py | RefugeeCmd.do_up | def do_up(self, arg):
"""Run up migration with name or numeric id matching arg"""
print "running up migration"
self.manager.run(arg, Direction.UP) | python | def do_up(self, arg):
"""Run up migration with name or numeric id matching arg"""
print "running up migration"
self.manager.run(arg, Direction.UP) | [
"def",
"do_up",
"(",
"self",
",",
"arg",
")",
":",
"print",
"\"running up migration\"",
"self",
".",
"manager",
".",
"run",
"(",
"arg",
",",
"Direction",
".",
"UP",
")"
] | Run up migration with name or numeric id matching arg | [
"Run",
"up",
"migration",
"with",
"name",
"or",
"numeric",
"id",
"matching",
"arg"
] | train | https://github.com/dcolish/Refugee/blob/b98391cb3127d09b15b59c7c25dab07a968062fa/refugee/cli.py#L78-L81 |
dstufft/crust | crust/utils.py | subclass_exception | def subclass_exception(name, parents, module, attached_to=None):
"""
Create exception subclass.
If 'attached_to' is supplied, the exception will be created in a way that
allows it to be pickled, assuming the returned exception class will be added
as an attribute to the 'attached_to' class.
"""
... | python | def subclass_exception(name, parents, module, attached_to=None):
"""
Create exception subclass.
If 'attached_to' is supplied, the exception will be created in a way that
allows it to be pickled, assuming the returned exception class will be added
as an attribute to the 'attached_to' class.
"""
... | [
"def",
"subclass_exception",
"(",
"name",
",",
"parents",
",",
"module",
",",
"attached_to",
"=",
"None",
")",
":",
"class_dict",
"=",
"{",
"'__module__'",
":",
"module",
"}",
"if",
"attached_to",
"is",
"not",
"None",
":",
"def",
"__reduce__",
"(",
"self",... | Create exception subclass.
If 'attached_to' is supplied, the exception will be created in a way that
allows it to be pickled, assuming the returned exception class will be added
as an attribute to the 'attached_to' class. | [
"Create",
"exception",
"subclass",
"."
] | train | https://github.com/dstufft/crust/blob/5d4011ecace12fd3f68a03a17dbefb78390a9fc0/crust/utils.py#L7-L28 |
delfick/gitmit | gitmit/repo.py | Repo.all_files | def all_files(self):
"""Return a set of all the files under git control"""
return set([entry.decode() for entry, _ in self.git.open_index().items()]) | python | def all_files(self):
"""Return a set of all the files under git control"""
return set([entry.decode() for entry, _ in self.git.open_index().items()]) | [
"def",
"all_files",
"(",
"self",
")",
":",
"return",
"set",
"(",
"[",
"entry",
".",
"decode",
"(",
")",
"for",
"entry",
",",
"_",
"in",
"self",
".",
"git",
".",
"open_index",
"(",
")",
".",
"items",
"(",
")",
"]",
")"
] | Return a set of all the files under git control | [
"Return",
"a",
"set",
"of",
"all",
"the",
"files",
"under",
"git",
"control"
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L45-L47 |
delfick/gitmit | gitmit/repo.py | Repo.file_commit_times | def file_commit_times(self, use_files_paths, debug=False):
"""
Traverse the commits in the repository, starting from HEAD until we have
found the commit times for all the files we care about.
Yield each file once, only when it is found to be changed in some commit.
If self.debu... | python | def file_commit_times(self, use_files_paths, debug=False):
"""
Traverse the commits in the repository, starting from HEAD until we have
found the commit times for all the files we care about.
Yield each file once, only when it is found to be changed in some commit.
If self.debu... | [
"def",
"file_commit_times",
"(",
"self",
",",
"use_files_paths",
",",
"debug",
"=",
"False",
")",
":",
"prefixes",
"=",
"PrefixTree",
"(",
")",
"prefixes",
".",
"fill",
"(",
"use_files_paths",
")",
"for",
"entry",
"in",
"self",
".",
"git",
".",
"get_walker... | Traverse the commits in the repository, starting from HEAD until we have
found the commit times for all the files we care about.
Yield each file once, only when it is found to be changed in some commit.
If self.debug is true, also output log.debug for the speed we are going
through com... | [
"Traverse",
"the",
"commits",
"in",
"the",
"repository",
"starting",
"from",
"HEAD",
"until",
"we",
"have",
"found",
"the",
"commit",
"times",
"for",
"all",
"the",
"files",
"we",
"care",
"about",
"."
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L54-L99 |
delfick/gitmit | gitmit/repo.py | Repo.entries_in_tree_oid | def entries_in_tree_oid(self, prefix, tree_oid):
"""Find the tree at this oid and return entries prefixed with ``prefix``"""
try:
tree = self.git.get_object(tree_oid)
except KeyError:
log.warning("Couldn't find object {0}".format(tree_oid))
return empty
... | python | def entries_in_tree_oid(self, prefix, tree_oid):
"""Find the tree at this oid and return entries prefixed with ``prefix``"""
try:
tree = self.git.get_object(tree_oid)
except KeyError:
log.warning("Couldn't find object {0}".format(tree_oid))
return empty
... | [
"def",
"entries_in_tree_oid",
"(",
"self",
",",
"prefix",
",",
"tree_oid",
")",
":",
"try",
":",
"tree",
"=",
"self",
".",
"git",
".",
"get_object",
"(",
"tree_oid",
")",
"except",
"KeyError",
":",
"log",
".",
"warning",
"(",
"\"Couldn't find object {0}\"",
... | Find the tree at this oid and return entries prefixed with ``prefix`` | [
"Find",
"the",
"tree",
"at",
"this",
"oid",
"and",
"return",
"entries",
"prefixed",
"with",
"prefix"
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L101-L109 |
delfick/gitmit | gitmit/repo.py | Repo.entries_in_tree | def entries_in_tree(self, prefix, tree):
"""
Traverse the entries in this tree and yield (prefix, is_tree, oid)
Where prefix is a tuple of the given prefix and the name of the entry.
"""
for entry in tree.items():
if prefix:
new_prefix = prefix + (ent... | python | def entries_in_tree(self, prefix, tree):
"""
Traverse the entries in this tree and yield (prefix, is_tree, oid)
Where prefix is a tuple of the given prefix and the name of the entry.
"""
for entry in tree.items():
if prefix:
new_prefix = prefix + (ent... | [
"def",
"entries_in_tree",
"(",
"self",
",",
"prefix",
",",
"tree",
")",
":",
"for",
"entry",
"in",
"tree",
".",
"items",
"(",
")",
":",
"if",
"prefix",
":",
"new_prefix",
"=",
"prefix",
"+",
"(",
"entry",
".",
"path",
".",
"decode",
"(",
")",
",",
... | Traverse the entries in this tree and yield (prefix, is_tree, oid)
Where prefix is a tuple of the given prefix and the name of the entry. | [
"Traverse",
"the",
"entries",
"in",
"this",
"tree",
"and",
"yield",
"(",
"prefix",
"is_tree",
"oid",
")"
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L111-L123 |
delfick/gitmit | gitmit/repo.py | Repo.tree_structures_for | def tree_structures_for(self, prefix, current_oid, parent_oids, prefixes):
"""
Return the entries for this commit, the entries of the parent commits,
and the difference between the two (current_files - parent_files)
"""
if prefix and prefixes and prefix not in prefixes:
... | python | def tree_structures_for(self, prefix, current_oid, parent_oids, prefixes):
"""
Return the entries for this commit, the entries of the parent commits,
and the difference between the two (current_files - parent_files)
"""
if prefix and prefixes and prefix not in prefixes:
... | [
"def",
"tree_structures_for",
"(",
"self",
",",
"prefix",
",",
"current_oid",
",",
"parent_oids",
",",
"prefixes",
")",
":",
"if",
"prefix",
"and",
"prefixes",
"and",
"prefix",
"not",
"in",
"prefixes",
":",
"return",
"empty",
",",
"empty",
"parent_files",
"=... | Return the entries for this commit, the entries of the parent commits,
and the difference between the two (current_files - parent_files) | [
"Return",
"the",
"entries",
"for",
"this",
"commit",
"the",
"entries",
"of",
"the",
"parent",
"commits",
"and",
"the",
"difference",
"between",
"the",
"two",
"(",
"current_files",
"-",
"parent_files",
")"
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L125-L138 |
delfick/gitmit | gitmit/repo.py | Repo.differences_between | def differences_between(self, current_files, parent_files, changes, prefixes):
"""
yield (thing, changes, is_path)
If is_path is true, changes is None and thing is the path as a tuple.
If is_path is false, thing is the current_files and parent_files for
that changed treeentry a... | python | def differences_between(self, current_files, parent_files, changes, prefixes):
"""
yield (thing, changes, is_path)
If is_path is true, changes is None and thing is the path as a tuple.
If is_path is false, thing is the current_files and parent_files for
that changed treeentry a... | [
"def",
"differences_between",
"(",
"self",
",",
"current_files",
",",
"parent_files",
",",
"changes",
",",
"prefixes",
")",
":",
"parent_oid",
"=",
"None",
"if",
"any",
"(",
"is_tree",
"for",
"_",
",",
"is_tree",
",",
"_",
"in",
"changes",
")",
":",
"if"... | yield (thing, changes, is_path)
If is_path is true, changes is None and thing is the path as a tuple.
If is_path is false, thing is the current_files and parent_files for
that changed treeentry and changes is the difference between current_files
and parent_files.
The code here... | [
"yield",
"(",
"thing",
"changes",
"is_path",
")"
] | train | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/repo.py#L140-L176 |
FujiMakoto/IPS-Vagrant | ips_vagrant/installer/dev_tools/__init__.py | dev_tools_installer | def dev_tools_installer(cv, ctx, site):
"""
Installer factory
@param cv: Current version (The version of Developer Tools we are installing)
@type cv: ips_vagrant.common.version.Version
@return: Installer instance
@rtype: ips_vagrant.installer.dev_tools.latest.DevToolsInstaller
"""
... | python | def dev_tools_installer(cv, ctx, site):
"""
Installer factory
@param cv: Current version (The version of Developer Tools we are installing)
@type cv: ips_vagrant.common.version.Version
@return: Installer instance
@rtype: ips_vagrant.installer.dev_tools.latest.DevToolsInstaller
"""
... | [
"def",
"dev_tools_installer",
"(",
"cv",
",",
"ctx",
",",
"site",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'ipsv.installer.dev_tools'",
")",
"log",
".",
"info",
"(",
"'Loading installer for Dev Tools %s'",
",",
"cv",
")",
"iv",
"=",
"None",
"... | Installer factory
@param cv: Current version (The version of Developer Tools we are installing)
@type cv: ips_vagrant.common.version.Version
@return: Installer instance
@rtype: ips_vagrant.installer.dev_tools.latest.DevToolsInstaller | [
"Installer",
"factory"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/dev_tools/__init__.py#L17-L37 |
delfick/venvstarter | venvstarter.py | Starter.ignite | def ignite(self, args=None):
"""
* Make the virtualenv
* Install dependencies into that virtualenv
* Start the program!
"""
if args is None:
args = sys.argv[1:]
if os.environ.get("MANAGED_VIRTUALENV", None) != "1":
made = self.make_virtual... | python | def ignite(self, args=None):
"""
* Make the virtualenv
* Install dependencies into that virtualenv
* Start the program!
"""
if args is None:
args = sys.argv[1:]
if os.environ.get("MANAGED_VIRTUALENV", None) != "1":
made = self.make_virtual... | [
"def",
"ignite",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"MANAGED_VIRTUALENV\"",
",",
"None",
")",
"!=",... | * Make the virtualenv
* Install dependencies into that virtualenv
* Start the program! | [
"*",
"Make",
"the",
"virtualenv",
"*",
"Install",
"dependencies",
"into",
"that",
"virtualenv",
"*",
"Start",
"the",
"program!"
] | train | https://github.com/delfick/venvstarter/blob/1573da3ad898c146b4ef6449d13ae8f570fdf5e8/venvstarter.py#L286-L301 |
pjuren/pyokit | src/pyokit/scripts/genomicIntJaccard.py | main | def main(args):
"""
main entry point for the GenomicIntJaccard script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
... | python | def main(args):
"""
main entry point for the GenomicIntJaccard script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
... | [
"def",
"main",
"(",
"args",
")",
":",
"# get options and arguments",
"ui",
"=",
"getUI",
"(",
"args",
")",
"if",
"ui",
".",
"optionIsSet",
"(",
"\"test\"",
")",
":",
"# just run unit tests",
"unittest",
".",
"main",
"(",
"argv",
"=",
"[",
"sys",
".",
"ar... | main entry point for the GenomicIntJaccard script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list. | [
"main",
"entry",
"point",
"for",
"the",
"GenomicIntJaccard",
"script",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/genomicIntJaccard.py#L80-L110 |
unbservices/clams | clams/__init__.py | arg | def arg(*args, **kwargs):
"""Annotate a function by adding the args/kwargs to the meta-data.
This appends an Argparse "argument" to the function's
``ARGPARSE_ARGS_LIST`` attribute, creating ``ARGPARSE_ARGS_LIST`` if it
does not already exist. Aside from that, it returns the decorated function
unmo... | python | def arg(*args, **kwargs):
"""Annotate a function by adding the args/kwargs to the meta-data.
This appends an Argparse "argument" to the function's
``ARGPARSE_ARGS_LIST`` attribute, creating ``ARGPARSE_ARGS_LIST`` if it
does not already exist. Aside from that, it returns the decorated function
unmo... | [
"def",
"arg",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"annotate",
"(",
"func",
")",
":",
"# Get the list of argparse args already added to func (if any).",
"argparse_args_list",
"=",
"getattr",
"(",
"func",
",",
"'ARGPARSE_ARGS_LIST'",
",",
"["... | Annotate a function by adding the args/kwargs to the meta-data.
This appends an Argparse "argument" to the function's
``ARGPARSE_ARGS_LIST`` attribute, creating ``ARGPARSE_ARGS_LIST`` if it
does not already exist. Aside from that, it returns the decorated function
unmodified, and unwrapped.
The "... | [
"Annotate",
"a",
"function",
"by",
"adding",
"the",
"args",
"/",
"kwargs",
"to",
"the",
"meta",
"-",
"data",
"."
] | train | https://github.com/unbservices/clams/blob/2ae0a36eb8f82a153d27f74ef37688f976952789/clams/__init__.py#L69-L151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.