partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | DomainRecords.rename | Change the name of this domain record
Parameters
----------
id: int
domain record id
name: str
new name of record | poseidon/api.py | def rename(self, id, name):
"""
Change the name of this domain record
Parameters
----------
id: int
domain record id
name: str
new name of record
"""
return super(DomainRecords, self).update(id, name=name)[self.singular] | def rename(self, id, name):
"""
Change the name of this domain record
Parameters
----------
id: int
domain record id
name: str
new name of record
"""
return super(DomainRecords, self).update(id, name=name)[self.singular] | [
"Change",
"the",
"name",
"of",
"this",
"domain",
"record"
] | changhiskhan/poseidon | python | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/api.py#L402-L413 | [
"def",
"rename",
"(",
"self",
",",
"id",
",",
"name",
")",
":",
"return",
"super",
"(",
"DomainRecords",
",",
"self",
")",
".",
"update",
"(",
"id",
",",
"name",
"=",
"name",
")",
"[",
"self",
".",
"singular",
"]"
] | 6d1cecbe02f1e510dd185fe23f88f7af35eb737f |
valid | DomainRecords.create | Parameters
----------
type: str
{A, AAAA, CNAME, MX, TXT, SRV, NS}
name: str
Name of the record
data: object, type-dependent
type == 'A' : IPv4 address
type == 'AAAA' : IPv6 address
type == 'CNAME' : destination host name
... | poseidon/api.py | def create(self, type, name=None, data=None, priority=None,
port=None, weight=None):
"""
Parameters
----------
type: str
{A, AAAA, CNAME, MX, TXT, SRV, NS}
name: str
Name of the record
data: object, type-dependent
type ==... | def create(self, type, name=None, data=None, priority=None,
port=None, weight=None):
"""
Parameters
----------
type: str
{A, AAAA, CNAME, MX, TXT, SRV, NS}
name: str
Name of the record
data: object, type-dependent
type ==... | [
"Parameters",
"----------",
"type",
":",
"str",
"{",
"A",
"AAAA",
"CNAME",
"MX",
"TXT",
"SRV",
"NS",
"}",
"name",
":",
"str",
"Name",
"of",
"the",
"record",
"data",
":",
"object",
"type",
"-",
"dependent",
"type",
"==",
"A",
":",
"IPv4",
"address",
"... | changhiskhan/poseidon | python | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/api.py#L415-L439 | [
"def",
"create",
"(",
"self",
",",
"type",
",",
"name",
"=",
"None",
",",
"data",
"=",
"None",
",",
"priority",
"=",
"None",
",",
"port",
"=",
"None",
",",
"weight",
"=",
"None",
")",
":",
"if",
"type",
"==",
"'A'",
"and",
"name",
"is",
"None",
... | 6d1cecbe02f1e510dd185fe23f88f7af35eb737f |
valid | DomainRecords.get | Retrieve a single domain record given the id | poseidon/api.py | def get(self, id, **kwargs):
"""
Retrieve a single domain record given the id
"""
return super(DomainRecords, self).get(id, **kwargs) | def get(self, id, **kwargs):
"""
Retrieve a single domain record given the id
"""
return super(DomainRecords, self).get(id, **kwargs) | [
"Retrieve",
"a",
"single",
"domain",
"record",
"given",
"the",
"id"
] | changhiskhan/poseidon | python | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/api.py#L441-L445 | [
"def",
"get",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"DomainRecords",
",",
"self",
")",
".",
"get",
"(",
"id",
",",
"*",
"*",
"kwargs",
")"
] | 6d1cecbe02f1e510dd185fe23f88f7af35eb737f |
valid | FogBugz.logon | Logs the user on to FogBugz.
Returns None for a successful login. | fogbugz.py | def logon(self, username, password):
"""
Logs the user on to FogBugz.
Returns None for a successful login.
"""
if self._token:
self.logoff()
try:
response = self.__makerequest(
'logon', email=username, password=password)
ex... | def logon(self, username, password):
"""
Logs the user on to FogBugz.
Returns None for a successful login.
"""
if self._token:
self.logoff()
try:
response = self.__makerequest(
'logon', email=username, password=password)
ex... | [
"Logs",
"the",
"user",
"on",
"to",
"FogBugz",
"."
] | yougov/FogBugzPy | python | https://github.com/yougov/FogBugzPy/blob/593aba31dff69b5d42f864e544f8a9c1872e3a16/fogbugz.py#L93-L110 | [
"def",
"logon",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"self",
".",
"_token",
":",
"self",
".",
"logoff",
"(",
")",
"try",
":",
"response",
"=",
"self",
".",
"__makerequest",
"(",
"'logon'",
",",
"email",
"=",
"username",
",",... | 593aba31dff69b5d42f864e544f8a9c1872e3a16 |
valid | FogBugz.__encode_multipart_formdata | fields is a sequence of (key, value) elements for regular form fields.
files is a sequence of (filename, filehandle) files to be uploaded
returns (content_type, body) | fogbugz.py | def __encode_multipart_formdata(self, fields, files):
"""
fields is a sequence of (key, value) elements for regular form fields.
files is a sequence of (filename, filehandle) files to be uploaded
returns (content_type, body)
"""
BOUNDARY = _make_boundary()
if len... | def __encode_multipart_formdata(self, fields, files):
"""
fields is a sequence of (key, value) elements for regular form fields.
files is a sequence of (filename, filehandle) files to be uploaded
returns (content_type, body)
"""
BOUNDARY = _make_boundary()
if len... | [
"fields",
"is",
"a",
"sequence",
"of",
"(",
"key",
"value",
")",
"elements",
"for",
"regular",
"form",
"fields",
".",
"files",
"is",
"a",
"sequence",
"of",
"(",
"filename",
"filehandle",
")",
"files",
"to",
"be",
"uploaded",
"returns",
"(",
"content_type",... | yougov/FogBugzPy | python | https://github.com/yougov/FogBugzPy/blob/593aba31dff69b5d42f864e544f8a9c1872e3a16/fogbugz.py#L125-L172 | [
"def",
"__encode_multipart_formdata",
"(",
"self",
",",
"fields",
",",
"files",
")",
":",
"BOUNDARY",
"=",
"_make_boundary",
"(",
")",
"if",
"len",
"(",
"files",
")",
">",
"0",
":",
"fields",
"[",
"'nFileCount'",
"]",
"=",
"str",
"(",
"len",
"(",
"file... | 593aba31dff69b5d42f864e544f8a9c1872e3a16 |
valid | chop | Chop list_ into n chunks. Returns a list. | leicaexperiment/utils.py | def chop(list_, n):
"Chop list_ into n chunks. Returns a list."
# could look into itertools also, might be implemented there
size = len(list_)
each = size // n
if each == 0:
return [list_]
chopped = []
for i in range(n):
start = i * each
end = (i+1) * each
if ... | def chop(list_, n):
"Chop list_ into n chunks. Returns a list."
# could look into itertools also, might be implemented there
size = len(list_)
each = size // n
if each == 0:
return [list_]
chopped = []
for i in range(n):
start = i * each
end = (i+1) * each
if ... | [
"Chop",
"list_",
"into",
"n",
"chunks",
".",
"Returns",
"a",
"list",
"."
] | arve0/leicaexperiment | python | https://github.com/arve0/leicaexperiment/blob/c0393c4d51984a506f813319efb66e54c4f2a426/leicaexperiment/utils.py#L9-L24 | [
"def",
"chop",
"(",
"list_",
",",
"n",
")",
":",
"# could look into itertools also, might be implemented there",
"size",
"=",
"len",
"(",
"list_",
")",
"each",
"=",
"size",
"//",
"n",
"if",
"each",
"==",
"0",
":",
"return",
"[",
"list_",
"]",
"chopped",
"=... | c0393c4d51984a506f813319efb66e54c4f2a426 |
valid | get_first | return first droplet | scripts/snapshot.py | def get_first():
"""
return first droplet
"""
client = po.connect() # this depends on the DIGITALOCEAN_API_KEY envvar
all_droplets = client.droplets.list()
id = all_droplets[0]['id'] # I'm cheating because I only have one droplet
return client.droplets.get(id) | def get_first():
"""
return first droplet
"""
client = po.connect() # this depends on the DIGITALOCEAN_API_KEY envvar
all_droplets = client.droplets.list()
id = all_droplets[0]['id'] # I'm cheating because I only have one droplet
return client.droplets.get(id) | [
"return",
"first",
"droplet"
] | changhiskhan/poseidon | python | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/scripts/snapshot.py#L10-L17 | [
"def",
"get_first",
"(",
")",
":",
"client",
"=",
"po",
".",
"connect",
"(",
")",
"# this depends on the DIGITALOCEAN_API_KEY envvar",
"all_droplets",
"=",
"client",
".",
"droplets",
".",
"list",
"(",
")",
"id",
"=",
"all_droplets",
"[",
"0",
"]",
"[",
"'id'... | 6d1cecbe02f1e510dd185fe23f88f7af35eb737f |
valid | take_snapshot | Take a snapshot of a droplet
Parameters
----------
name: str
name for snapshot | scripts/snapshot.py | def take_snapshot(droplet, name):
"""
Take a snapshot of a droplet
Parameters
----------
name: str
name for snapshot
"""
print "powering off"
droplet.power_off()
droplet.wait() # wait for pending actions to complete
print "taking snapshot"
droplet.take_snapshot(name)... | def take_snapshot(droplet, name):
"""
Take a snapshot of a droplet
Parameters
----------
name: str
name for snapshot
"""
print "powering off"
droplet.power_off()
droplet.wait() # wait for pending actions to complete
print "taking snapshot"
droplet.take_snapshot(name)... | [
"Take",
"a",
"snapshot",
"of",
"a",
"droplet"
] | changhiskhan/poseidon | python | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/scripts/snapshot.py#L20-L37 | [
"def",
"take_snapshot",
"(",
"droplet",
",",
"name",
")",
":",
"print",
"\"powering off\"",
"droplet",
".",
"power_off",
"(",
")",
"droplet",
".",
"wait",
"(",
")",
"# wait for pending actions to complete",
"print",
"\"taking snapshot\"",
"droplet",
".",
"take_snaps... | 6d1cecbe02f1e510dd185fe23f88f7af35eb737f |
valid | ManagedResource.allowed_operations | Retrieves the allowed operations for this request. | armet/resources/managed/base.py | def allowed_operations(self):
"""Retrieves the allowed operations for this request."""
if self.slug is not None:
return self.meta.detail_allowed_operations
return self.meta.list_allowed_operations | def allowed_operations(self):
"""Retrieves the allowed operations for this request."""
if self.slug is not None:
return self.meta.detail_allowed_operations
return self.meta.list_allowed_operations | [
"Retrieves",
"the",
"allowed",
"operations",
"for",
"this",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L80-L85 | [
"def",
"allowed_operations",
"(",
"self",
")",
":",
"if",
"self",
".",
"slug",
"is",
"not",
"None",
":",
"return",
"self",
".",
"meta",
".",
"detail_allowed_operations",
"return",
"self",
".",
"meta",
".",
"list_allowed_operations"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.assert_operations | Assets if the requested operations are allowed in this context. | armet/resources/managed/base.py | def assert_operations(self, *args):
"""Assets if the requested operations are allowed in this context."""
if not set(args).issubset(self.allowed_operations):
raise http.exceptions.Forbidden() | def assert_operations(self, *args):
"""Assets if the requested operations are allowed in this context."""
if not set(args).issubset(self.allowed_operations):
raise http.exceptions.Forbidden() | [
"Assets",
"if",
"the",
"requested",
"operations",
"are",
"allowed",
"in",
"this",
"context",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L87-L90 | [
"def",
"assert_operations",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"set",
"(",
"args",
")",
".",
"issubset",
"(",
"self",
".",
"allowed_operations",
")",
":",
"raise",
"http",
".",
"exceptions",
".",
"Forbidden",
"(",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.make_response | Fills the response object from the passed data. | armet/resources/managed/base.py | def make_response(self, data=None):
"""Fills the response object from the passed data."""
if data is not None:
# Prepare the data for transmission.
data = self.prepare(data)
# Encode the data using a desired encoder.
self.response.write(data, serialize=Tr... | def make_response(self, data=None):
"""Fills the response object from the passed data."""
if data is not None:
# Prepare the data for transmission.
data = self.prepare(data)
# Encode the data using a desired encoder.
self.response.write(data, serialize=Tr... | [
"Fills",
"the",
"response",
"object",
"from",
"the",
"passed",
"data",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L92-L99 | [
"def",
"make_response",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"# Prepare the data for transmission.",
"data",
"=",
"self",
".",
"prepare",
"(",
"data",
")",
"# Encode the data using a desired encoder.",
"self",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.get | Processes a `GET` request. | armet/resources/managed/base.py | def get(self, request, response):
"""Processes a `GET` request."""
# Ensure we're allowed to read the resource.
self.assert_operations('read')
# Delegate to `read` to retrieve the items.
items = self.read()
# if self.slug is not None and not items:
# # Reque... | def get(self, request, response):
"""Processes a `GET` request."""
# Ensure we're allowed to read the resource.
self.assert_operations('read')
# Delegate to `read` to retrieve the items.
items = self.read()
# if self.slug is not None and not items:
# # Reque... | [
"Processes",
"a",
"GET",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L328-L358 | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# Ensure we're allowed to read the resource.",
"self",
".",
"assert_operations",
"(",
"'read'",
")",
"# Delegate to `read` to retrieve the items.",
"items",
"=",
"self",
".",
"read",
"(",
")",
"#... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.post | Processes a `POST` request. | armet/resources/managed/base.py | def post(self, request, response):
"""Processes a `POST` request."""
if self.slug is not None:
# Don't know what to do an item access.
raise http.exceptions.NotImplemented()
# Ensure we're allowed to create a resource.
self.assert_operations('create')
# ... | def post(self, request, response):
"""Processes a `POST` request."""
if self.slug is not None:
# Don't know what to do an item access.
raise http.exceptions.NotImplemented()
# Ensure we're allowed to create a resource.
self.assert_operations('create')
# ... | [
"Processes",
"a",
"POST",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L360-L377 | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"self",
".",
"slug",
"is",
"not",
"None",
":",
"# Don't know what to do an item access.",
"raise",
"http",
".",
"exceptions",
".",
"NotImplemented",
"(",
")",
"# Ensure we're allowed to... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.put | Processes a `PUT` request. | armet/resources/managed/base.py | def put(self, request, response):
"""Processes a `PUT` request."""
if self.slug is None:
# Mass-PUT is not implemented.
raise http.exceptions.NotImplemented()
# Check if the resource exists.
target = self.read()
# Deserialize and clean the incoming objec... | def put(self, request, response):
"""Processes a `PUT` request."""
if self.slug is None:
# Mass-PUT is not implemented.
raise http.exceptions.NotImplemented()
# Check if the resource exists.
target = self.read()
# Deserialize and clean the incoming objec... | [
"Processes",
"a",
"PUT",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L379-L415 | [
"def",
"put",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"self",
".",
"slug",
"is",
"None",
":",
"# Mass-PUT is not implemented.",
"raise",
"http",
".",
"exceptions",
".",
"NotImplemented",
"(",
")",
"# Check if the resource exists.",
"target"... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.delete | Processes a `DELETE` request. | armet/resources/managed/base.py | def delete(self, request, response):
"""Processes a `DELETE` request."""
if self.slug is None:
# Mass-DELETE is not implemented.
raise http.exceptions.NotImplemented()
# Ensure we're allowed to destroy a resource.
self.assert_operations('destroy')
# Dele... | def delete(self, request, response):
"""Processes a `DELETE` request."""
if self.slug is None:
# Mass-DELETE is not implemented.
raise http.exceptions.NotImplemented()
# Ensure we're allowed to destroy a resource.
self.assert_operations('destroy')
# Dele... | [
"Processes",
"a",
"DELETE",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L417-L431 | [
"def",
"delete",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"self",
".",
"slug",
"is",
"None",
":",
"# Mass-DELETE is not implemented.",
"raise",
"http",
".",
"exceptions",
".",
"NotImplemented",
"(",
")",
"# Ensure we're allowed to destroy a re... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | ManagedResource.link | Processes a `LINK` request.
A `LINK` request is asking to create a relation from the currently
represented URI to all of the `Link` request headers. | armet/resources/managed/base.py | def link(self, request, response):
"""Processes a `LINK` request.
A `LINK` request is asking to create a relation from the currently
represented URI to all of the `Link` request headers.
"""
from armet.resources.managed.request import read
if self.slug is None:
... | def link(self, request, response):
"""Processes a `LINK` request.
A `LINK` request is asking to create a relation from the currently
represented URI to all of the `Link` request headers.
"""
from armet.resources.managed.request import read
if self.slug is None:
... | [
"Processes",
"a",
"LINK",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/managed/base.py#L446-L471 | [
"def",
"link",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"from",
"armet",
".",
"resources",
".",
"managed",
".",
"request",
"import",
"read",
"if",
"self",
".",
"slug",
"is",
"None",
":",
"# Mass-LINK is not implemented.",
"raise",
"http",
".... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | DjangoCreator.create_project | Creates a base Django project | ignition/django.py | def create_project(self):
'''
Creates a base Django project
'''
if os.path.exists(self._py):
prj_dir = os.path.join(self._app_dir, self._project_name)
if os.path.exists(prj_dir):
if self._force:
logging.warn('Removing existing p... | def create_project(self):
'''
Creates a base Django project
'''
if os.path.exists(self._py):
prj_dir = os.path.join(self._app_dir, self._project_name)
if os.path.exists(prj_dir):
if self._force:
logging.warn('Removing existing p... | [
"Creates",
"a",
"base",
"Django",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/django.py#L39-L59 | [
"def",
"create_project",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_py",
")",
":",
"prj_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_app_dir",
",",
"self",
".",
"_project_name",
")",
"if",
... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ilike_helper | Helper function that performs an `ilike` query if a string value
is passed, otherwise the normal default operation. | armet/connectors/sqlalchemy/resources.py | def ilike_helper(default):
"""Helper function that performs an `ilike` query if a string value
is passed, otherwise the normal default operation."""
@functools.wraps(default)
def wrapped(x, y):
# String values should use ILIKE queries.
if isinstance(y, six.string_types) and not isinstanc... | def ilike_helper(default):
"""Helper function that performs an `ilike` query if a string value
is passed, otherwise the normal default operation."""
@functools.wraps(default)
def wrapped(x, y):
# String values should use ILIKE queries.
if isinstance(y, six.string_types) and not isinstanc... | [
"Helper",
"function",
"that",
"performs",
"an",
"ilike",
"query",
"if",
"a",
"string",
"value",
"is",
"passed",
"otherwise",
"the",
"normal",
"default",
"operation",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/connectors/sqlalchemy/resources.py#L28-L38 | [
"def",
"ilike_helper",
"(",
"default",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"default",
")",
"def",
"wrapped",
"(",
"x",
",",
"y",
")",
":",
"# String values should use ILIKE queries.",
"if",
"isinstance",
"(",
"y",
",",
"six",
".",
"string_types",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | parse | Parse the querystring into a normalized form. | armet/query/parser.py | def parse(text, encoding='utf8'):
"""Parse the querystring into a normalized form."""
# Decode the text if we got bytes.
if isinstance(text, six.binary_type):
text = text.decode(encoding)
return Query(text, split_segments(text)) | def parse(text, encoding='utf8'):
"""Parse the querystring into a normalized form."""
# Decode the text if we got bytes.
if isinstance(text, six.binary_type):
text = text.decode(encoding)
return Query(text, split_segments(text)) | [
"Parse",
"the",
"querystring",
"into",
"a",
"normalized",
"form",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/query/parser.py#L153-L160 | [
"def",
"parse",
"(",
"text",
",",
"encoding",
"=",
"'utf8'",
")",
":",
"# Decode the text if we got bytes.",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"binary_type",
")",
":",
"text",
"=",
"text",
".",
"decode",
"(",
"encoding",
")",
"return",
"Que... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | split_segments | Return objects representing segments. | armet/query/parser.py | def split_segments(text, closing_paren=False):
"""Return objects representing segments."""
buf = StringIO()
# The segments we're building, and the combinators used to combine them.
# Note that after this is complete, this should be true:
# len(segments) == len(combinators) + 1
# Thus we can und... | def split_segments(text, closing_paren=False):
"""Return objects representing segments."""
buf = StringIO()
# The segments we're building, and the combinators used to combine them.
# Note that after this is complete, this should be true:
# len(segments) == len(combinators) + 1
# Thus we can und... | [
"Return",
"objects",
"representing",
"segments",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/query/parser.py#L169-L271 | [
"def",
"split_segments",
"(",
"text",
",",
"closing_paren",
"=",
"False",
")",
":",
"buf",
"=",
"StringIO",
"(",
")",
"# The segments we're building, and the combinators used to combine them.",
"# Note that after this is complete, this should be true:",
"# len(segments) == len(comb... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | parse_directive | Takes a key of type (foo:bar) and returns either the key and the
directive, or the key and None (for no directive.) | armet/query/parser.py | def parse_directive(key):
"""
Takes a key of type (foo:bar) and returns either the key and the
directive, or the key and None (for no directive.)
"""
if constants.DIRECTIVE in key:
return key.split(constants.DIRECTIVE, 1)
else:
return key, None | def parse_directive(key):
"""
Takes a key of type (foo:bar) and returns either the key and the
directive, or the key and None (for no directive.)
"""
if constants.DIRECTIVE in key:
return key.split(constants.DIRECTIVE, 1)
else:
return key, None | [
"Takes",
"a",
"key",
"of",
"type",
"(",
"foo",
":",
"bar",
")",
"and",
"returns",
"either",
"the",
"key",
"and",
"the",
"directive",
"or",
"the",
"key",
"and",
"None",
"(",
"for",
"no",
"directive",
".",
")"
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/query/parser.py#L284-L292 | [
"def",
"parse_directive",
"(",
"key",
")",
":",
"if",
"constants",
".",
"DIRECTIVE",
"in",
"key",
":",
"return",
"key",
".",
"split",
"(",
"constants",
".",
"DIRECTIVE",
",",
"1",
")",
"else",
":",
"return",
"key",
",",
"None"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | parse_segment | we expect foo=bar | armet/query/parser.py | def parse_segment(text):
"we expect foo=bar"
if not len(text):
return NoopQuerySegment()
q = QuerySegment()
# First we need to split the segment into key/value pairs. This is done
# by attempting to split the sequence for each equality comparison. Then
# discard any that did not spl... | def parse_segment(text):
"we expect foo=bar"
if not len(text):
return NoopQuerySegment()
q = QuerySegment()
# First we need to split the segment into key/value pairs. This is done
# by attempting to split the sequence for each equality comparison. Then
# discard any that did not spl... | [
"we",
"expect",
"foo",
"=",
"bar"
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/query/parser.py#L295-L366 | [
"def",
"parse_segment",
"(",
"text",
")",
":",
"if",
"not",
"len",
"(",
"text",
")",
":",
"return",
"NoopQuerySegment",
"(",
")",
"q",
"=",
"QuerySegment",
"(",
")",
"# First we need to split the segment into key/value pairs. This is done",
"# by attempting to split th... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Attribute.set | Set the value of this attribute for the passed object. | armet/attributes/attribute.py | def set(self, target, value):
"""Set the value of this attribute for the passed object.
"""
if not self._set:
return
if self.path is None:
# There is no path defined on this resource.
# We can do no magic to set the value.
self.set = lamb... | def set(self, target, value):
"""Set the value of this attribute for the passed object.
"""
if not self._set:
return
if self.path is None:
# There is no path defined on this resource.
# We can do no magic to set the value.
self.set = lamb... | [
"Set",
"the",
"value",
"of",
"this",
"attribute",
"for",
"the",
"passed",
"object",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/attributes/attribute.py#L123-L159 | [
"def",
"set",
"(",
"self",
",",
"target",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_set",
":",
"return",
"if",
"self",
".",
"path",
"is",
"None",
":",
"# There is no path defined on this resource.",
"# We can do no magic to set the value.",
"self",
"."... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | parse | Consumes set specifiers as text and forms a generator to retrieve
the requested ranges.
@param[in] specifiers
Expected syntax is from the byte-range-specifier ABNF found in the
[RFC 2616]; eg. 15-17,151,-16,26-278,15
@returns
Consecutive tuples that describe the requested range; eg... | armet/pagination.py | def parse(specifiers):
"""
Consumes set specifiers as text and forms a generator to retrieve
the requested ranges.
@param[in] specifiers
Expected syntax is from the byte-range-specifier ABNF found in the
[RFC 2616]; eg. 15-17,151,-16,26-278,15
@returns
Consecutive tuples th... | def parse(specifiers):
"""
Consumes set specifiers as text and forms a generator to retrieve
the requested ranges.
@param[in] specifiers
Expected syntax is from the byte-range-specifier ABNF found in the
[RFC 2616]; eg. 15-17,151,-16,26-278,15
@returns
Consecutive tuples th... | [
"Consumes",
"set",
"specifiers",
"as",
"text",
"and",
"forms",
"a",
"generator",
"to",
"retrieve",
"the",
"requested",
"ranges",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/pagination.py#L12-L56 | [
"def",
"parse",
"(",
"specifiers",
")",
":",
"specifiers",
"=",
"\"\"",
".",
"join",
"(",
"specifiers",
".",
"split",
"(",
")",
")",
"for",
"specifier",
"in",
"specifiers",
".",
"split",
"(",
"','",
")",
":",
"if",
"len",
"(",
"specifier",
")",
"==",... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | paginate | Paginate an iterable during a request.
Magically splicling an iterable in our supported ORMs allows LIMIT and
OFFSET queries. We should probably delegate this to the ORM or something
in the future. | armet/pagination.py | def paginate(request, response, items):
"""Paginate an iterable during a request.
Magically splicling an iterable in our supported ORMs allows LIMIT and
OFFSET queries. We should probably delegate this to the ORM or something
in the future.
"""
# TODO: support dynamic rangewords and page length... | def paginate(request, response, items):
"""Paginate an iterable during a request.
Magically splicling an iterable in our supported ORMs allows LIMIT and
OFFSET queries. We should probably delegate this to the ORM or something
in the future.
"""
# TODO: support dynamic rangewords and page length... | [
"Paginate",
"an",
"iterable",
"during",
"a",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/pagination.py#L59-L100 | [
"def",
"paginate",
"(",
"request",
",",
"response",
",",
"items",
")",
":",
"# TODO: support dynamic rangewords and page lengths",
"# TODO: support multi-part range requests",
"# Get the header",
"header",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"'Range'",
")",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | indexesOptional | Decorate test methods with this if you don't require strict index checking | nose2gae/__init__.py | def indexesOptional(f):
"""Decorate test methods with this if you don't require strict index checking"""
stack = inspect.stack()
_NO_INDEX_CHECK_NEEDED.add('%s.%s.%s' % (f.__module__, stack[1][3], f.__name__))
del stack
return f | def indexesOptional(f):
"""Decorate test methods with this if you don't require strict index checking"""
stack = inspect.stack()
_NO_INDEX_CHECK_NEEDED.add('%s.%s.%s' % (f.__module__, stack[1][3], f.__name__))
del stack
return f | [
"Decorate",
"test",
"methods",
"with",
"this",
"if",
"you",
"don",
"t",
"require",
"strict",
"index",
"checking"
] | udacity/nose2-gae | python | https://github.com/udacity/nose2-gae/blob/4fcc1acd5cc983295b20402de8d159b688942398/nose2gae/__init__.py#L24-L29 | [
"def",
"indexesOptional",
"(",
"f",
")",
":",
"stack",
"=",
"inspect",
".",
"stack",
"(",
")",
"_NO_INDEX_CHECK_NEEDED",
".",
"add",
"(",
"'%s.%s.%s'",
"%",
"(",
"f",
".",
"__module__",
",",
"stack",
"[",
"1",
"]",
"[",
"3",
"]",
",",
"f",
".",
"__... | 4fcc1acd5cc983295b20402de8d159b688942398 |
valid | Request.read | Read and return the request data.
@param[in] deserialize
True to deserialize the resultant text using a determiend format
or the passed format.
@param[in] format
A specific format to deserialize in; if provided, no detection is
done. If not provided, the... | armet/http/request.py | def read(self, deserialize=False, format=None):
"""Read and return the request data.
@param[in] deserialize
True to deserialize the resultant text using a determiend format
or the passed format.
@param[in] format
A specific format to deserialize in; if provi... | def read(self, deserialize=False, format=None):
"""Read and return the request data.
@param[in] deserialize
True to deserialize the resultant text using a determiend format
or the passed format.
@param[in] format
A specific format to deserialize in; if provi... | [
"Read",
"and",
"return",
"the",
"request",
"data",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/request.py#L192-L217 | [
"def",
"read",
"(",
"self",
",",
"deserialize",
"=",
"False",
",",
"format",
"=",
"None",
")",
":",
"if",
"deserialize",
":",
"data",
",",
"_",
"=",
"self",
".",
"deserialize",
"(",
"format",
"=",
"format",
")",
"return",
"data",
"content",
"=",
"sel... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | use | Updates the active resource configuration to the passed
keyword arguments.
Invoking this method without passing arguments will just return the
active resource configuration.
@returns
The previous configuration. | armet/helpers.py | def use(**kwargs):
"""
Updates the active resource configuration to the passed
keyword arguments.
Invoking this method without passing arguments will just return the
active resource configuration.
@returns
The previous configuration.
"""
config = dict(use.config)
use.config... | def use(**kwargs):
"""
Updates the active resource configuration to the passed
keyword arguments.
Invoking this method without passing arguments will just return the
active resource configuration.
@returns
The previous configuration.
"""
config = dict(use.config)
use.config... | [
"Updates",
"the",
"active",
"resource",
"configuration",
"to",
"the",
"passed",
"keyword",
"arguments",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/helpers.py#L5-L18 | [
"def",
"use",
"(",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"dict",
"(",
"use",
".",
"config",
")",
"use",
".",
"config",
".",
"update",
"(",
"kwargs",
")",
"return",
"config"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | try_delegation | This decorator wraps descriptor methods with a new method that tries
to delegate to a function of the same name defined on the owner instance
for convenience for dispatcher clients. | nmmd/base.py | def try_delegation(method):
'''This decorator wraps descriptor methods with a new method that tries
to delegate to a function of the same name defined on the owner instance
for convenience for dispatcher clients.
'''
@functools.wraps(method)
def delegator(self, *args, **kwargs):
if self.... | def try_delegation(method):
'''This decorator wraps descriptor methods with a new method that tries
to delegate to a function of the same name defined on the owner instance
for convenience for dispatcher clients.
'''
@functools.wraps(method)
def delegator(self, *args, **kwargs):
if self.... | [
"This",
"decorator",
"wraps",
"descriptor",
"methods",
"with",
"a",
"new",
"method",
"that",
"tries",
"to",
"delegate",
"to",
"a",
"function",
"of",
"the",
"same",
"name",
"defined",
"on",
"the",
"owner",
"instance",
"for",
"convenience",
"for",
"dispatcher",
... | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L66-L85 | [
"def",
"try_delegation",
"(",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"delegator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"try_delegation",
":",
"# Try to dispatch to th... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | Dispatcher.register | Given a single decorated handler function,
prepare, append desired data to self.registry. | nmmd/base.py | def register(self, method, args, kwargs):
'''Given a single decorated handler function,
prepare, append desired data to self.registry.
'''
invoc = self.dump_invoc(*args, **kwargs)
self.registry.append((invoc, method.__name__)) | def register(self, method, args, kwargs):
'''Given a single decorated handler function,
prepare, append desired data to self.registry.
'''
invoc = self.dump_invoc(*args, **kwargs)
self.registry.append((invoc, method.__name__)) | [
"Given",
"a",
"single",
"decorated",
"handler",
"function",
"prepare",
"append",
"desired",
"data",
"to",
"self",
".",
"registry",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L159-L164 | [
"def",
"register",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"invoc",
"=",
"self",
".",
"dump_invoc",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"registry",
".",
"append",
"(",
"(",
"invoc",
",",
"method",
... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | Dispatcher.gen_methods | Find all method names this input dispatches to. This method
can accept *args, **kwargs, but it's the gen_dispatch method's
job of passing specific args to handler methods. | nmmd/base.py | def gen_methods(self, *args, **kwargs):
'''Find all method names this input dispatches to. This method
can accept *args, **kwargs, but it's the gen_dispatch method's
job of passing specific args to handler methods.
'''
dispatched = False
for invoc, methodname in self.regi... | def gen_methods(self, *args, **kwargs):
'''Find all method names this input dispatches to. This method
can accept *args, **kwargs, but it's the gen_dispatch method's
job of passing specific args to handler methods.
'''
dispatched = False
for invoc, methodname in self.regi... | [
"Find",
"all",
"method",
"names",
"this",
"input",
"dispatches",
"to",
".",
"This",
"method",
"can",
"accept",
"*",
"args",
"**",
"kwargs",
"but",
"it",
"s",
"the",
"gen_dispatch",
"method",
"s",
"job",
"of",
"passing",
"specific",
"args",
"to",
"handler",... | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L178-L199 | [
"def",
"gen_methods",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dispatched",
"=",
"False",
"for",
"invoc",
",",
"methodname",
"in",
"self",
".",
"registry",
":",
"args",
",",
"kwargs",
"=",
"self",
".",
"loads",
"(",
"invoc",... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | Dispatcher.get_method | Find the first method this input dispatches to. | nmmd/base.py | def get_method(self, *args, **kwargs):
'''Find the first method this input dispatches to.
'''
for method in self.gen_methods(*args, **kwargs):
return method
msg = 'No method was found for %r on %r.'
raise self.DispatchError(msg % ((args, kwargs), self.inst)) | def get_method(self, *args, **kwargs):
'''Find the first method this input dispatches to.
'''
for method in self.gen_methods(*args, **kwargs):
return method
msg = 'No method was found for %r on %r.'
raise self.DispatchError(msg % ((args, kwargs), self.inst)) | [
"Find",
"the",
"first",
"method",
"this",
"input",
"dispatches",
"to",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L202-L208 | [
"def",
"get_method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"method",
"in",
"self",
".",
"gen_methods",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"method",
"msg",
"=",
"'No method was found for %r ... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | Dispatcher.dispatch | Find and evaluate/return the first method this input dispatches to. | nmmd/base.py | def dispatch(self, *args, **kwargs):
'''Find and evaluate/return the first method this input dispatches to.
'''
for result in self.gen_dispatch(*args, **kwargs):
return result | def dispatch(self, *args, **kwargs):
'''Find and evaluate/return the first method this input dispatches to.
'''
for result in self.gen_dispatch(*args, **kwargs):
return result | [
"Find",
"and",
"evaluate",
"/",
"return",
"the",
"first",
"method",
"this",
"input",
"dispatches",
"to",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L211-L215 | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"result",
"in",
"self",
".",
"gen_dispatch",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"result"
] | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | Dispatcher.gen_dispatch | Find and evaluate/yield every method this input dispatches to. | nmmd/base.py | def gen_dispatch(self, *args, **kwargs):
'''Find and evaluate/yield every method this input dispatches to.
'''
dispatched = False
for method_data in self.gen_methods(*args, **kwargs):
dispatched = True
result = self.apply_handler(method_data, *args, **kwargs)
... | def gen_dispatch(self, *args, **kwargs):
'''Find and evaluate/yield every method this input dispatches to.
'''
dispatched = False
for method_data in self.gen_methods(*args, **kwargs):
dispatched = True
result = self.apply_handler(method_data, *args, **kwargs)
... | [
"Find",
"and",
"evaluate",
"/",
"yield",
"every",
"method",
"this",
"input",
"dispatches",
"to",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L218-L231 | [
"def",
"gen_dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dispatched",
"=",
"False",
"for",
"method_data",
"in",
"self",
".",
"gen_methods",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dispatched",
"=",
"True... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | TypeDispatcher.gen_method_keys | Given a node, return the string to use in computing the
matching visitor methodname. Can also be a generator of strings. | nmmd/base.py | def gen_method_keys(self, *args, **kwargs):
'''Given a node, return the string to use in computing the
matching visitor methodname. Can also be a generator of strings.
'''
token = args[0]
for mro_type in type(token).__mro__[:-1]:
name = mro_type.__name__
y... | def gen_method_keys(self, *args, **kwargs):
'''Given a node, return the string to use in computing the
matching visitor methodname. Can also be a generator of strings.
'''
token = args[0]
for mro_type in type(token).__mro__[:-1]:
name = mro_type.__name__
y... | [
"Given",
"a",
"node",
"return",
"the",
"string",
"to",
"use",
"in",
"computing",
"the",
"matching",
"visitor",
"methodname",
".",
"Can",
"also",
"be",
"a",
"generator",
"of",
"strings",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L334-L341 | [
"def",
"gen_method_keys",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"token",
"=",
"args",
"[",
"0",
"]",
"for",
"mro_type",
"in",
"type",
"(",
"token",
")",
".",
"__mro__",
"[",
":",
"-",
"1",
"]",
":",
"name",
"=",
"mro... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | TypeDispatcher.gen_methods | Find all method names this input dispatches to. | nmmd/base.py | def gen_methods(self, *args, **kwargs):
'''Find all method names this input dispatches to.
'''
token = args[0]
inst = self.inst
prefix = self._method_prefix
for method_key in self.gen_method_keys(*args, **kwargs):
method = getattr(inst, prefix + method_key, No... | def gen_methods(self, *args, **kwargs):
'''Find all method names this input dispatches to.
'''
token = args[0]
inst = self.inst
prefix = self._method_prefix
for method_key in self.gen_method_keys(*args, **kwargs):
method = getattr(inst, prefix + method_key, No... | [
"Find",
"all",
"method",
"names",
"this",
"input",
"dispatches",
"to",
"."
] | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/base.py#L345-L370 | [
"def",
"gen_methods",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"token",
"=",
"args",
"[",
"0",
"]",
"inst",
"=",
"self",
".",
"inst",
"prefix",
"=",
"self",
".",
"_method_prefix",
"for",
"method_key",
"in",
"self",
".",
"ge... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | RegexDispatcher.apply_handler | Call the dispatched function, optionally with other data
stored/created during .register and .prepare. Assume the arguments
passed in by the dispathcer are the only ones required. | nmmd/ext/regex.py | def apply_handler(self, method_data, *args, **kwargs):
'''Call the dispatched function, optionally with other data
stored/created during .register and .prepare. Assume the arguments
passed in by the dispathcer are the only ones required.
'''
if isinstance(method_data, tuple):
... | def apply_handler(self, method_data, *args, **kwargs):
'''Call the dispatched function, optionally with other data
stored/created during .register and .prepare. Assume the arguments
passed in by the dispathcer are the only ones required.
'''
if isinstance(method_data, tuple):
... | [
"Call",
"the",
"dispatched",
"function",
"optionally",
"with",
"other",
"data",
"stored",
"/",
"created",
"during",
".",
"register",
"and",
".",
"prepare",
".",
"Assume",
"the",
"arguments",
"passed",
"in",
"by",
"the",
"dispathcer",
"are",
"the",
"only",
"o... | twneale/nmmd | python | https://github.com/twneale/nmmd/blob/ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f/nmmd/ext/regex.py#L39-L53 | [
"def",
"apply_handler",
"(",
"self",
",",
"method_data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"method_data",
",",
"tuple",
")",
":",
"len_method",
"=",
"len",
"(",
"method_data",
")",
"method",
"=",
"method_data",... | ab3b3f1290c85b8d05bbf59b54c7f22da8972b6f |
valid | BumpRequirement.parse | Parse string to create an instance
:param str s: String with requirement to parse
:param bool required: Is this requirement required to be fulfilled? If not, then it is a filter. | bumper/cars.py | def parse(cls, s, required=False):
"""
Parse string to create an instance
:param str s: String with requirement to parse
:param bool required: Is this requirement required to be fulfilled? If not, then it is a filter.
"""
req = pkg_resources.Requirement.parse(s)
... | def parse(cls, s, required=False):
"""
Parse string to create an instance
:param str s: String with requirement to parse
:param bool required: Is this requirement required to be fulfilled? If not, then it is a filter.
"""
req = pkg_resources.Requirement.parse(s)
... | [
"Parse",
"string",
"to",
"create",
"an",
"instance"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L33-L41 | [
"def",
"parse",
"(",
"cls",
",",
"s",
",",
"required",
"=",
"False",
")",
":",
"req",
"=",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"s",
")",
"return",
"cls",
"(",
"req",
",",
"required",
"=",
"required",
")"
] | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | RequirementsManager.add | Add requirements to be managed
:param list/Requirement requirements: List of :class:`BumpRequirement` or :class:`pkg_resources.Requirement`
:param bool required: Set required flag for each requirement if provided. | bumper/cars.py | def add(self, requirements, required=None):
"""
Add requirements to be managed
:param list/Requirement requirements: List of :class:`BumpRequirement` or :class:`pkg_resources.Requirement`
:param bool required: Set required flag for each requirement if provided.
"""
if is... | def add(self, requirements, required=None):
"""
Add requirements to be managed
:param list/Requirement requirements: List of :class:`BumpRequirement` or :class:`pkg_resources.Requirement`
:param bool required: Set required flag for each requirement if provided.
"""
if is... | [
"Add",
"requirements",
"to",
"be",
"managed"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L91-L145 | [
"def",
"add",
"(",
"self",
",",
"requirements",
",",
"required",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"requirements",
",",
"RequirementsManager",
")",
":",
"requirements",
"=",
"list",
"(",
"requirements",
")",
"elif",
"not",
"isinstance",
"(",
... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | RequirementsManager.check | Check off requirements that are met by name/version.
:param str|Bump|Requirement context: Either package name, requirement string, :class:`Bump`,
:class:`BumpRequirement`, or
:class:`pkg_resources.Requirement instance
... | bumper/cars.py | def check(self, context, version=None):
"""
Check off requirements that are met by name/version.
:param str|Bump|Requirement context: Either package name, requirement string, :class:`Bump`,
:class:`BumpRequirement`, or
... | def check(self, context, version=None):
"""
Check off requirements that are met by name/version.
:param str|Bump|Requirement context: Either package name, requirement string, :class:`Bump`,
:class:`BumpRequirement`, or
... | [
"Check",
"off",
"requirements",
"that",
"are",
"met",
"by",
"name",
"/",
"version",
"."
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L150-L191 | [
"def",
"check",
"(",
"self",
",",
"context",
",",
"version",
"=",
"None",
")",
":",
"req_str",
"=",
"None",
"self",
".",
"checked",
".",
"append",
"(",
"(",
"context",
",",
"version",
")",
")",
"if",
"isinstance",
"(",
"context",
",",
"str",
")",
"... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | RequirementsManager.satisfied_by_checked | Check if requirement is already satisfied by what was previously checked
:param Requirement req: Requirement to check | bumper/cars.py | def satisfied_by_checked(self, req):
"""
Check if requirement is already satisfied by what was previously checked
:param Requirement req: Requirement to check
"""
req_man = RequirementsManager([req])
return any(req_man.check(*checked) for checked in self.checked) | def satisfied_by_checked(self, req):
"""
Check if requirement is already satisfied by what was previously checked
:param Requirement req: Requirement to check
"""
req_man = RequirementsManager([req])
return any(req_man.check(*checked) for checked in self.checked) | [
"Check",
"if",
"requirement",
"is",
"already",
"satisfied",
"by",
"what",
"was",
"previously",
"checked"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L193-L201 | [
"def",
"satisfied_by_checked",
"(",
"self",
",",
"req",
")",
":",
"req_man",
"=",
"RequirementsManager",
"(",
"[",
"req",
"]",
")",
"return",
"any",
"(",
"req_man",
".",
"check",
"(",
"*",
"checked",
")",
"for",
"checked",
"in",
"self",
".",
"checked",
... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | Bump.from_requirement | Create an instance from :class:`pkg_resources.Requirement` instance | bumper/cars.py | def from_requirement(cls, req, changes=None):
""" Create an instance from :class:`pkg_resources.Requirement` instance """
return cls(req.project_name, req.specs and ''.join(req.specs[0]) or '', changes=changes) | def from_requirement(cls, req, changes=None):
""" Create an instance from :class:`pkg_resources.Requirement` instance """
return cls(req.project_name, req.specs and ''.join(req.specs[0]) or '', changes=changes) | [
"Create",
"an",
"instance",
"from",
":",
"class",
":",
"pkg_resources",
".",
"Requirement",
"instance"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L248-L250 | [
"def",
"from_requirement",
"(",
"cls",
",",
"req",
",",
"changes",
"=",
"None",
")",
":",
"return",
"cls",
"(",
"req",
".",
"project_name",
",",
"req",
".",
"specs",
"and",
"''",
".",
"join",
"(",
"req",
".",
"specs",
"[",
"0",
"]",
")",
"or",
"'... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | Bump.as_requirement | Convert back to a :class:`pkg_resources.Requirement` instance | bumper/cars.py | def as_requirement(self):
""" Convert back to a :class:`pkg_resources.Requirement` instance """
if self.new_version:
return pkg_resources.Requirement.parse(self.name + ''.join(self.new_version))
else:
return pkg_resources.Requirement.parse(self.name) | def as_requirement(self):
""" Convert back to a :class:`pkg_resources.Requirement` instance """
if self.new_version:
return pkg_resources.Requirement.parse(self.name + ''.join(self.new_version))
else:
return pkg_resources.Requirement.parse(self.name) | [
"Convert",
"back",
"to",
"a",
":",
"class",
":",
"pkg_resources",
".",
"Requirement",
"instance"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L252-L257 | [
"def",
"as_requirement",
"(",
"self",
")",
":",
"if",
"self",
".",
"new_version",
":",
"return",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"self",
".",
"name",
"+",
"''",
".",
"join",
"(",
"self",
".",
"new_version",
")",
")",
"else",
":"... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | Bump.require | Add new requirements that must be fulfilled for this bump to occur | bumper/cars.py | def require(self, req):
""" Add new requirements that must be fulfilled for this bump to occur """
reqs = req if isinstance(req, list) else [req]
for req in reqs:
if not isinstance(req, BumpRequirement):
req = BumpRequirement(req)
req.required = True
... | def require(self, req):
""" Add new requirements that must be fulfilled for this bump to occur """
reqs = req if isinstance(req, list) else [req]
for req in reqs:
if not isinstance(req, BumpRequirement):
req = BumpRequirement(req)
req.required = True
... | [
"Add",
"new",
"requirements",
"that",
"must",
"be",
"fulfilled",
"for",
"this",
"bump",
"to",
"occur"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L259-L268 | [
"def",
"require",
"(",
"self",
",",
"req",
")",
":",
"reqs",
"=",
"req",
"if",
"isinstance",
"(",
"req",
",",
"list",
")",
"else",
"[",
"req",
"]",
"for",
"req",
"in",
"reqs",
":",
"if",
"not",
"isinstance",
"(",
"req",
",",
"BumpRequirement",
")",... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | AbstractBumper.requirements_for_changes | Parse changes for requirements
:param list changes: | bumper/cars.py | def requirements_for_changes(self, changes):
"""
Parse changes for requirements
:param list changes:
"""
requirements = []
reqs_set = set()
if isinstance(changes, str):
changes = changes.split('\n')
if not changes or changes[0].startswith('-... | def requirements_for_changes(self, changes):
"""
Parse changes for requirements
:param list changes:
"""
requirements = []
reqs_set = set()
if isinstance(changes, str):
changes = changes.split('\n')
if not changes or changes[0].startswith('-... | [
"Parse",
"changes",
"for",
"requirements"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L287-L324 | [
"def",
"requirements_for_changes",
"(",
"self",
",",
"changes",
")",
":",
"requirements",
"=",
"[",
"]",
"reqs_set",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"changes",
",",
"str",
")",
":",
"changes",
"=",
"changes",
".",
"split",
"(",
"'\\n'",
... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | AbstractBumper.package_changes | List of changes for package name from current_version to new_version, in descending order.
If current version is higher than new version (downgrade), then a minus sign will be prefixed to each change. | bumper/cars.py | def package_changes(self, name, current_version, new_version):
"""
List of changes for package name from current_version to new_version, in descending order.
If current version is higher than new version (downgrade), then a minus sign will be prefixed to each change.
"""
if p... | def package_changes(self, name, current_version, new_version):
"""
List of changes for package name from current_version to new_version, in descending order.
If current version is higher than new version (downgrade), then a minus sign will be prefixed to each change.
"""
if p... | [
"List",
"of",
"changes",
"for",
"package",
"name",
"from",
"current_version",
"to",
"new_version",
"in",
"descending",
"order",
".",
"If",
"current",
"version",
"is",
"higher",
"than",
"new",
"version",
"(",
"downgrade",
")",
"then",
"a",
"minus",
"sign",
"w... | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L382-L398 | [
"def",
"package_changes",
"(",
"self",
",",
"name",
",",
"current_version",
",",
"new_version",
")",
":",
"if",
"pkg_resources",
".",
"parse_version",
"(",
"current_version",
")",
">",
"pkg_resources",
".",
"parse_version",
"(",
"new_version",
")",
":",
"downgra... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | AbstractBumper._bump | Bump an existing requirement to the desired requirement if any.
Subclass can override this `_bump` method to change how each requirement is bumped.
BR = Bump to Requested Version
BL = Bump to Latest Version
BLR = Bump to Latest Version per Requested Requirement
BROL = ... | bumper/cars.py | def _bump(self, existing_req=None, bump_reqs=None):
"""
Bump an existing requirement to the desired requirement if any.
Subclass can override this `_bump` method to change how each requirement is bumped.
BR = Bump to Requested Version
BL = Bump to Latest Version
... | def _bump(self, existing_req=None, bump_reqs=None):
"""
Bump an existing requirement to the desired requirement if any.
Subclass can override this `_bump` method to change how each requirement is bumped.
BR = Bump to Requested Version
BL = Bump to Latest Version
... | [
"Bump",
"an",
"existing",
"requirement",
"to",
"the",
"desired",
"requirement",
"if",
"any",
".",
"Subclass",
"can",
"override",
"this",
"_bump",
"method",
"to",
"change",
"how",
"each",
"requirement",
"is",
"bumped",
"."
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L414-L536 | [
"def",
"_bump",
"(",
"self",
",",
"existing_req",
"=",
"None",
",",
"bump_reqs",
"=",
"None",
")",
":",
"if",
"existing_req",
"or",
"bump_reqs",
"and",
"any",
"(",
"r",
".",
"required",
"for",
"r",
"in",
"bump_reqs",
")",
":",
"name",
"=",
"existing_re... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | AbstractBumper.bump | Bump dependencies using given requirements.
:param RequirementsManager bump_reqs: Bump requirements manager
:param dict kwargs: Additional args from argparse. Some bumpers accept user options, and some not.
:return: List of :class:`Bump` changes made. | bumper/cars.py | def bump(self, bump_reqs=None, **kwargs):
"""
Bump dependencies using given requirements.
:param RequirementsManager bump_reqs: Bump requirements manager
:param dict kwargs: Additional args from argparse. Some bumpers accept user options, and some not.
:return: List of :... | def bump(self, bump_reqs=None, **kwargs):
"""
Bump dependencies using given requirements.
:param RequirementsManager bump_reqs: Bump requirements manager
:param dict kwargs: Additional args from argparse. Some bumpers accept user options, and some not.
:return: List of :... | [
"Bump",
"dependencies",
"using",
"given",
"requirements",
"."
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L538-L587 | [
"def",
"bump",
"(",
"self",
",",
"bump_reqs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"bumps",
"=",
"{",
"}",
"for",
"existing_req",
"in",
"sorted",
"(",
"self",
".",
"requirements",
"(",
")",
",",
"key",
"=",
"lambda",
"r",
":",
"r",
"."... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | AbstractBumper.reverse | Restore content in target file to be before any changes | bumper/cars.py | def reverse(self):
""" Restore content in target file to be before any changes """
if self._original_target_content:
with open(self.target, 'w') as fp:
fp.write(self._original_target_content) | def reverse(self):
""" Restore content in target file to be before any changes """
if self._original_target_content:
with open(self.target, 'w') as fp:
fp.write(self._original_target_content) | [
"Restore",
"content",
"in",
"target",
"file",
"to",
"be",
"before",
"any",
"changes"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L589-L593 | [
"def",
"reverse",
"(",
"self",
")",
":",
"if",
"self",
".",
"_original_target_content",
":",
"with",
"open",
"(",
"self",
".",
"target",
",",
"'w'",
")",
"as",
"fp",
":",
"fp",
".",
"write",
"(",
"self",
".",
"_original_target_content",
")"
] | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | Serializer.serialize | Transforms the object into an acceptable format for transmission.
@throws ValueError
To indicate this serializer does not support the encoding of the
specified object. | armet/serializers/base.py | def serialize(self, data=None):
"""
Transforms the object into an acceptable format for transmission.
@throws ValueError
To indicate this serializer does not support the encoding of the
specified object.
"""
if data is not None and self.response is not No... | def serialize(self, data=None):
"""
Transforms the object into an acceptable format for transmission.
@throws ValueError
To indicate this serializer does not support the encoding of the
specified object.
"""
if data is not None and self.response is not No... | [
"Transforms",
"the",
"object",
"into",
"an",
"acceptable",
"format",
"for",
"transmission",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/serializers/base.py#L28-L45 | [
"def",
"serialize",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"not",
"None",
"and",
"self",
".",
"response",
"is",
"not",
"None",
":",
"# Set the content type.",
"self",
".",
"response",
"[",
"'Content-Type'",
"]",
"=",
"self",... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | cons | Extends a collection with a value. | armet/utils/functional.py | def cons(collection, value):
"""Extends a collection with a value."""
if isinstance(value, collections.Mapping):
if collection is None:
collection = {}
collection.update(**value)
elif isinstance(value, six.string_types):
if collection is None:
collection = []... | def cons(collection, value):
"""Extends a collection with a value."""
if isinstance(value, collections.Mapping):
if collection is None:
collection = {}
collection.update(**value)
elif isinstance(value, six.string_types):
if collection is None:
collection = []... | [
"Extends",
"a",
"collection",
"with",
"a",
"value",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/utils/functional.py#L7-L29 | [
"def",
"cons",
"(",
"collection",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"collections",
".",
"Mapping",
")",
":",
"if",
"collection",
"is",
"None",
":",
"collection",
"=",
"{",
"}",
"collection",
".",
"update",
"(",
"*",
"*",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | _merge | Merges a named option collection. | armet/resources/resource/options.py | def _merge(options, name, bases, default=None):
"""Merges a named option collection."""
result = None
for base in bases:
if base is None:
continue
value = getattr(base, name, None)
if value is None:
continue
result = utils.cons(result, value)
va... | def _merge(options, name, bases, default=None):
"""Merges a named option collection."""
result = None
for base in bases:
if base is None:
continue
value = getattr(base, name, None)
if value is None:
continue
result = utils.cons(result, value)
va... | [
"Merges",
"a",
"named",
"option",
"collection",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/options.py#L11-L28 | [
"def",
"_merge",
"(",
"options",
",",
"name",
",",
"bases",
",",
"default",
"=",
"None",
")",
":",
"result",
"=",
"None",
"for",
"base",
"in",
"bases",
":",
"if",
"base",
"is",
"None",
":",
"continue",
"value",
"=",
"getattr",
"(",
"base",
",",
"na... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | parse_requirements | Parse string requirements into list of :class:`pkg_resources.Requirement` instances
:param str requirements: Requirements text to parse
:param str in_file: File the requirements came from
:return: List of requirements
:raises ValueError: if failed to parse | bumper/utils.py | def parse_requirements(requirements, in_file=None):
"""
Parse string requirements into list of :class:`pkg_resources.Requirement` instances
:param str requirements: Requirements text to parse
:param str in_file: File the requirements came from
:return: List of requirements
:raises Val... | def parse_requirements(requirements, in_file=None):
"""
Parse string requirements into list of :class:`pkg_resources.Requirement` instances
:param str requirements: Requirements text to parse
:param str in_file: File the requirements came from
:return: List of requirements
:raises Val... | [
"Parse",
"string",
"requirements",
"into",
"list",
"of",
":",
"class",
":",
"pkg_resources",
".",
"Requirement",
"instances"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/utils.py#L12-L25 | [
"def",
"parse_requirements",
"(",
"requirements",
",",
"in_file",
"=",
"None",
")",
":",
"try",
":",
"return",
"list",
"(",
"pkg_resources",
".",
"parse_requirements",
"(",
"requirements",
")",
")",
"except",
"Exception",
"as",
"e",
":",
"in_file",
"=",
"' i... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | PyPI.package_info | All package info for given package | bumper/utils.py | def package_info(cls, package):
""" All package info for given package """
if package not in cls.package_info_cache:
package_json_url = 'https://pypi.python.org/pypi/%s/json' % package
try:
logging.getLogger('requests').setLevel(logging.WARN)
res... | def package_info(cls, package):
""" All package info for given package """
if package not in cls.package_info_cache:
package_json_url = 'https://pypi.python.org/pypi/%s/json' % package
try:
logging.getLogger('requests').setLevel(logging.WARN)
res... | [
"All",
"package",
"info",
"for",
"given",
"package"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/utils.py#L34-L51 | [
"def",
"package_info",
"(",
"cls",
",",
"package",
")",
":",
"if",
"package",
"not",
"in",
"cls",
".",
"package_info_cache",
":",
"package_json_url",
"=",
"'https://pypi.python.org/pypi/%s/json'",
"%",
"package",
"try",
":",
"logging",
".",
"getLogger",
"(",
"'r... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | PyPI.all_package_versions | All versions for package | bumper/utils.py | def all_package_versions(package):
""" All versions for package """
info = PyPI.package_info(package)
return info and sorted(info['releases'].keys(), key=lambda x: x.split(), reverse=True) or [] | def all_package_versions(package):
""" All versions for package """
info = PyPI.package_info(package)
return info and sorted(info['releases'].keys(), key=lambda x: x.split(), reverse=True) or [] | [
"All",
"versions",
"for",
"package"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/utils.py#L60-L63 | [
"def",
"all_package_versions",
"(",
"package",
")",
":",
"info",
"=",
"PyPI",
".",
"package_info",
"(",
"package",
")",
"return",
"info",
"and",
"sorted",
"(",
"info",
"[",
"'releases'",
"]",
".",
"keys",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | Headers.insert | Insert a value at the passed index in the named header. | armet/http/response.py | def insert(self, name, index, value):
"""Insert a value at the passed index in the named header."""
return self._sequence[name].insert(index, value) | def insert(self, name, index, value):
"""Insert a value at the passed index in the named header."""
return self._sequence[name].insert(index, value) | [
"Insert",
"a",
"value",
"at",
"the",
"passed",
"index",
"in",
"the",
"named",
"header",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L104-L106 | [
"def",
"insert",
"(",
"self",
",",
"name",
",",
"index",
",",
"value",
")",
":",
"return",
"self",
".",
"_sequence",
"[",
"name",
"]",
".",
"insert",
"(",
"index",
",",
"value",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.close | Flush and close the stream.
This is called automatically by the base resource on resources
unless the resource is operating asynchronously; in that case,
this method MUST be called in order to signal the end of the request.
If not the request will simply hang as it is waiting for some
... | armet/http/response.py | def close(self):
"""Flush and close the stream.
This is called automatically by the base resource on resources
unless the resource is operating asynchronously; in that case,
this method MUST be called in order to signal the end of the request.
If not the request will simply hang... | def close(self):
"""Flush and close the stream.
This is called automatically by the base resource on resources
unless the resource is operating asynchronously; in that case,
this method MUST be called in order to signal the end of the request.
If not the request will simply hang... | [
"Flush",
"and",
"close",
"the",
"stream",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L241-L265 | [
"def",
"close",
"(",
"self",
")",
":",
"# Ensure we're not closed.",
"self",
".",
"require_not_closed",
"(",
")",
"if",
"not",
"self",
".",
"streaming",
"or",
"self",
".",
"asynchronous",
":",
"# We're not streaming, auto-write content-length if not",
"# already set.",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.write | Writes the given chunk to the output buffer.
@param[in] chunk
Either a byte array, a unicode string, or a generator. If `chunk`
is a generator then calling `self.write(<generator>)` is
equivalent to:
@code
for x in <generator>:
... | armet/http/response.py | def write(self, chunk, serialize=False, format=None):
"""Writes the given chunk to the output buffer.
@param[in] chunk
Either a byte array, a unicode string, or a generator. If `chunk`
is a generator then calling `self.write(<generator>)` is
equivalent to:
... | def write(self, chunk, serialize=False, format=None):
"""Writes the given chunk to the output buffer.
@param[in] chunk
Either a byte array, a unicode string, or a generator. If `chunk`
is a generator then calling `self.write(<generator>)` is
equivalent to:
... | [
"Writes",
"the",
"given",
"chunk",
"to",
"the",
"output",
"buffer",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L276-L345 | [
"def",
"write",
"(",
"self",
",",
"chunk",
",",
"serialize",
"=",
"False",
",",
"format",
"=",
"None",
")",
":",
"# Ensure we're not closed.",
"self",
".",
"require_not_closed",
"(",
")",
"if",
"chunk",
"is",
"None",
":",
"# There is nothing here.",
"return",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.serialize | Serializes the data into this response using a serializer.
@param[in] data
The data to be serialized.
@param[in] format
A specific format to serialize in; if provided, no detection is
done. If not provided, the accept header (as well as the URL
extension... | armet/http/response.py | def serialize(self, data, format=None):
"""Serializes the data into this response using a serializer.
@param[in] data
The data to be serialized.
@param[in] format
A specific format to serialize in; if provided, no detection is
done. If not provided, the acce... | def serialize(self, data, format=None):
"""Serializes the data into this response using a serializer.
@param[in] data
The data to be serialized.
@param[in] format
A specific format to serialize in; if provided, no detection is
done. If not provided, the acce... | [
"Serializes",
"the",
"data",
"into",
"this",
"response",
"using",
"a",
"serializer",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L347-L362 | [
"def",
"serialize",
"(",
"self",
",",
"data",
",",
"format",
"=",
"None",
")",
":",
"return",
"self",
".",
"_resource",
".",
"serialize",
"(",
"data",
",",
"response",
"=",
"self",
",",
"format",
"=",
"format",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.flush | Flush the write buffers of the stream.
This results in writing the current contents of the write buffer to
the transport layer, initiating the HTTP/1.1 response. This initiates
a streaming response. If the `Content-Length` header is not given
then the chunked `Transfer-Encoding` is appl... | armet/http/response.py | def flush(self):
"""Flush the write buffers of the stream.
This results in writing the current contents of the write buffer to
the transport layer, initiating the HTTP/1.1 response. This initiates
a streaming response. If the `Content-Length` header is not given
then the chunked... | def flush(self):
"""Flush the write buffers of the stream.
This results in writing the current contents of the write buffer to
the transport layer, initiating the HTTP/1.1 response. This initiates
a streaming response. If the `Content-Length` header is not given
then the chunked... | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L364-L386 | [
"def",
"flush",
"(",
"self",
")",
":",
"# Ensure we're not closed.",
"self",
".",
"require_not_closed",
"(",
")",
"# Pull out the accumulated chunk.",
"chunk",
"=",
"self",
".",
"_stream",
".",
"getvalue",
"(",
")",
"self",
".",
"_stream",
".",
"truncate",
"(",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.send | Writes the passed chunk and flushes it to the client. | armet/http/response.py | def send(self, *args, **kwargs):
"""Writes the passed chunk and flushes it to the client."""
self.write(*args, **kwargs)
self.flush() | def send(self, *args, **kwargs):
"""Writes the passed chunk and flushes it to the client."""
self.write(*args, **kwargs)
self.flush() | [
"Writes",
"the",
"passed",
"chunk",
"and",
"flushes",
"it",
"to",
"the",
"client",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L388-L391 | [
"def",
"send",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"write",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"flush",
"(",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.end | Writes the passed chunk, flushes it to the client,
and terminates the connection. | armet/http/response.py | def end(self, *args, **kwargs):
"""
Writes the passed chunk, flushes it to the client,
and terminates the connection.
"""
self.send(*args, **kwargs)
self.close() | def end(self, *args, **kwargs):
"""
Writes the passed chunk, flushes it to the client,
and terminates the connection.
"""
self.send(*args, **kwargs)
self.close() | [
"Writes",
"the",
"passed",
"chunk",
"flushes",
"it",
"to",
"the",
"client",
"and",
"terminates",
"the",
"connection",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L393-L399 | [
"def",
"end",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"send",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"close",
"(",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Response.insert | Insert a value at the passed index in the named header. | armet/http/response.py | def insert(self, name, index, value):
"""Insert a value at the passed index in the named header."""
return self.headers.insert(index, value) | def insert(self, name, index, value):
"""Insert a value at the passed index in the named header."""
return self.headers.insert(index, value) | [
"Insert",
"a",
"value",
"at",
"the",
"passed",
"index",
"in",
"the",
"named",
"header",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L437-L439 | [
"def",
"insert",
"(",
"self",
",",
"name",
",",
"index",
",",
"value",
")",
":",
"return",
"self",
".",
"headers",
".",
"insert",
"(",
"index",
",",
"value",
")"
] | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | FlaskCreator.create_project | Creates a base Flask project | ignition/flask.py | def create_project(self):
"""
Creates a base Flask project
"""
if os.path.exists(self._py):
prj_dir = os.path.join(self._app_dir, self._project_name)
if os.path.exists(prj_dir):
if self._force:
logging.warn('Removing existing p... | def create_project(self):
"""
Creates a base Flask project
"""
if os.path.exists(self._py):
prj_dir = os.path.join(self._app_dir, self._project_name)
if os.path.exists(prj_dir):
if self._force:
logging.warn('Removing existing p... | [
"Creates",
"a",
"base",
"Flask",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/flask.py#L44-L73 | [
"def",
"create_project",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_py",
")",
":",
"prj_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_app_dir",
",",
"self",
".",
"_project_name",
")",
"if",
... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | replaced_directory | This ``Context Manager`` is used to move the contents of a directory
elsewhere temporarily and put them back upon exit. This allows testing
code to use the same file directories as normal code without fear of
damage.
The name of the temporary directory which contains your files is yielded.
:param... | waelstow.py | def replaced_directory(dirname):
"""This ``Context Manager`` is used to move the contents of a directory
elsewhere temporarily and put them back upon exit. This allows testing
code to use the same file directories as normal code without fear of
damage.
The name of the temporary directory which con... | def replaced_directory(dirname):
"""This ``Context Manager`` is used to move the contents of a directory
elsewhere temporarily and put them back upon exit. This allows testing
code to use the same file directories as normal code without fear of
damage.
The name of the temporary directory which con... | [
"This",
"Context",
"Manager",
"is",
"used",
"to",
"move",
"the",
"contents",
"of",
"a",
"directory",
"elsewhere",
"temporarily",
"and",
"put",
"them",
"back",
"upon",
"exit",
".",
"This",
"allows",
"testing",
"code",
"to",
"use",
"the",
"same",
"file",
"di... | cltrudeau/waelstow | python | https://github.com/cltrudeau/waelstow/blob/f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837/waelstow.py#L123-L171 | [
"def",
"replaced_directory",
"(",
"dirname",
")",
":",
"if",
"dirname",
"[",
"-",
"1",
"]",
"==",
"'/'",
":",
"dirname",
"=",
"dirname",
"[",
":",
"-",
"1",
"]",
"full_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dirname",
")",
"if",
"not",... | f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837 |
valid | capture_stdout | This ``Context Manager`` redirects STDOUT to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDOUT is restored.
Example:
.. code-block:: python
with capture_stdout() as capture:
print('foo')
# got here? => capture.getvalue() will now have "foo\\n" | waelstow.py | def capture_stdout():
"""This ``Context Manager`` redirects STDOUT to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDOUT is restored.
Example:
.. code-block:: python
with capture_stdout() as capture:
print('foo')
# got here? => capture.getvalue... | def capture_stdout():
"""This ``Context Manager`` redirects STDOUT to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDOUT is restored.
Example:
.. code-block:: python
with capture_stdout() as capture:
print('foo')
# got here? => capture.getvalue... | [
"This",
"Context",
"Manager",
"redirects",
"STDOUT",
"to",
"a",
"StringIO",
"objects",
"which",
"is",
"returned",
"from",
"the",
"Context",
".",
"On",
"exit",
"STDOUT",
"is",
"restored",
"."
] | cltrudeau/waelstow | python | https://github.com/cltrudeau/waelstow/blob/f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837/waelstow.py#L175-L194 | [
"def",
"capture_stdout",
"(",
")",
":",
"stdout",
"=",
"sys",
".",
"stdout",
"try",
":",
"capture_out",
"=",
"StringIO",
"(",
")",
"sys",
".",
"stdout",
"=",
"capture_out",
"yield",
"capture_out",
"finally",
":",
"sys",
".",
"stdout",
"=",
"stdout"
] | f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837 |
valid | capture_stderr | This ``Context Manager`` redirects STDERR to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDERR is restored.
Example:
.. code-block:: python
with capture_stderr() as capture:
print('foo')
# got here? => capture.getvalue() will now have "foo\\n" | waelstow.py | def capture_stderr():
"""This ``Context Manager`` redirects STDERR to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDERR is restored.
Example:
.. code-block:: python
with capture_stderr() as capture:
print('foo')
# got here? => capture.getvalue... | def capture_stderr():
"""This ``Context Manager`` redirects STDERR to a ``StringIO`` objects
which is returned from the ``Context``. On exit STDERR is restored.
Example:
.. code-block:: python
with capture_stderr() as capture:
print('foo')
# got here? => capture.getvalue... | [
"This",
"Context",
"Manager",
"redirects",
"STDERR",
"to",
"a",
"StringIO",
"objects",
"which",
"is",
"returned",
"from",
"the",
"Context",
".",
"On",
"exit",
"STDERR",
"is",
"restored",
"."
] | cltrudeau/waelstow | python | https://github.com/cltrudeau/waelstow/blob/f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837/waelstow.py#L198-L217 | [
"def",
"capture_stderr",
"(",
")",
":",
"stderr",
"=",
"sys",
".",
"stderr",
"try",
":",
"capture_out",
"=",
"StringIO",
"(",
")",
"sys",
".",
"stderr",
"=",
"capture_out",
"yield",
"capture_out",
"finally",
":",
"sys",
".",
"stderr",
"=",
"stderr"
] | f67ad5e86f1ef447d6c6ae3e6845bdae83f2d837 |
valid | PyOptions.create | .. _createoptions:
Create an option object used to start the manager
:param a: The path of the config directory
:type a: str
:param b: The path of the user directory
:type b: str
:param c: The "command line" options of the openzwave library
:type c: str
... | libopenzwave/_global.py | def create(self, a, b, c):
"""
.. _createoptions:
Create an option object used to start the manager
:param a: The path of the config directory
:type a: str
:param b: The path of the user directory
:type b: str
:param c: The "command line" options of the ... | def create(self, a, b, c):
"""
.. _createoptions:
Create an option object used to start the manager
:param a: The path of the config directory
:type a: str
:param b: The path of the user directory
:type b: str
:param c: The "command line" options of the ... | [
"..",
"_createoptions",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L63-L81 | [
"def",
"create",
"(",
"self",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"self",
".",
"options",
"=",
"CreateOptions",
"(",
"str_to_cppstr",
"(",
"a",
")",
",",
"str_to_cppstr",
"(",
"b",
")",
",",
"str_to_cppstr",
"(",
"c",
")",
")",
"return",
"True"... | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | PyOptions.addOptionBool | .. _addOptionBool:
Add a boolean option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionInt_, addOptionString... | libopenzwave/_global.py | def addOptionBool(self, name, value):
"""
.. _addOptionBool:
Add a boolean option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool... | def addOptionBool(self, name, value):
"""
.. _addOptionBool:
Add a boolean option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool... | [
"..",
"_addOptionBool",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L128-L144 | [
"def",
"addOptionBool",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"self",
".",
"options",
".",
"AddOptionBool",
"(",
"str_to_cppstr",
"(",
"name",
")",
",",
"value",
")"
] | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | PyOptions.addOptionInt | .. _addOptionInt:
Add an integer option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionBool_, addOptionStrin... | libopenzwave/_global.py | def addOptionInt(self, name, value):
"""
.. _addOptionInt:
Add an integer option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
... | def addOptionInt(self, name, value):
"""
.. _addOptionInt:
Add an integer option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
... | [
"..",
"_addOptionInt",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L146-L162 | [
"def",
"addOptionInt",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"self",
".",
"options",
".",
"AddOptionInt",
"(",
"str_to_cppstr",
"(",
"name",
")",
",",
"value",
")"
] | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | PyOptions.addOptionString | .. _addOptionString:
Add a string option.
:param name: The name of the option. Option names are case insensitive and must be unique.
:type name: str
:param value: The value of the option.
:type value: str
:param append: Setting append to true will cause values read fro... | libopenzwave/_global.py | def addOptionString(self, name, value, append=False):
"""
.. _addOptionString:
Add a string option.
:param name: The name of the option. Option names are case insensitive and must be unique.
:type name: str
:param value: The value of the option.
:type value: st... | def addOptionString(self, name, value, append=False):
"""
.. _addOptionString:
Add a string option.
:param name: The name of the option. Option names are case insensitive and must be unique.
:type name: str
:param value: The value of the option.
:type value: st... | [
"..",
"_addOptionString",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L164-L185 | [
"def",
"addOptionString",
"(",
"self",
",",
"name",
",",
"value",
",",
"append",
"=",
"False",
")",
":",
"return",
"self",
".",
"options",
".",
"AddOptionString",
"(",
"str_to_cppstr",
"(",
"name",
")",
",",
"str_to_cppstr",
"(",
"value",
")",
",",
"appe... | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | PyOptions.addOption | .. _addOption:
Add an option.
:param name: The name of the option.
:type name: string
:param value: The value of the option.
:type value: boolean, integer, string
:return: The result of the operation.
:rtype: bool
:see: addOptionBool_, addOptionInt_, ad... | libopenzwave/_global.py | def addOption(self, name, value):
"""
.. _addOption:
Add an option.
:param name: The name of the option.
:type name: string
:param value: The value of the option.
:type value: boolean, integer, string
:return: The result of the operation.
:rtype:... | def addOption(self, name, value):
"""
.. _addOption:
Add an option.
:param name: The name of the option.
:type name: string
:param value: The value of the option.
:type value: boolean, integer, string
:return: The result of the operation.
:rtype:... | [
"..",
"_addOption",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L187-L211 | [
"def",
"addOption",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"name",
"not",
"in",
"PyOptionList",
":",
"return",
"False",
"if",
"PyOptionList",
"[",
"name",
"]",
"[",
"'type'",
"]",
"==",
"\"String\"",
":",
"return",
"self",
".",
"addOpt... | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | PyOptions.getOption | .. _getOption:
Retrieve option of a value.
:param name: The name of the option.
:type name: string
:return: The value
:rtype: boolean, integer, string or None
:see: getOptionAsBool_, getOptionAsInt_, getOptionAsString_ | libopenzwave/_global.py | def getOption(self, name):
"""
.. _getOption:
Retrieve option of a value.
:param name: The name of the option.
:type name: string
:return: The value
:rtype: boolean, integer, string or None
:see: getOptionAsBool_, getOptionAsInt_, getOptionAsString_
... | def getOption(self, name):
"""
.. _getOption:
Retrieve option of a value.
:param name: The name of the option.
:type name: string
:return: The value
:rtype: boolean, integer, string or None
:see: getOptionAsBool_, getOptionAsInt_, getOptionAsString_
... | [
"..",
"_getOption",
":"
] | Julian/libopenzwave-cffi | python | https://github.com/Julian/libopenzwave-cffi/blob/7683e5e4e08270dd7d780ab6a0ccd048343b08e1/libopenzwave/_global.py#L213-L235 | [
"def",
"getOption",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"PyOptionList",
":",
"return",
"None",
"if",
"PyOptionList",
"[",
"name",
"]",
"[",
"'type'",
"]",
"==",
"\"String\"",
":",
"return",
"self",
".",
"getOptionAsString",
"("... | 7683e5e4e08270dd7d780ab6a0ccd048343b08e1 |
valid | Resource.urls | Builds the URL configuration for this resource. | armet/connectors/django/resources.py | def urls(cls):
"""Builds the URL configuration for this resource."""
return urls.patterns('', urls.url(
r'^{}(?:$|(?P<path>[/:(.].*))'.format(cls.meta.name),
cls.view,
name='armet-api-{}'.format(cls.meta.name),
kwargs={'resource': cls.meta.name})) | def urls(cls):
"""Builds the URL configuration for this resource."""
return urls.patterns('', urls.url(
r'^{}(?:$|(?P<path>[/:(.].*))'.format(cls.meta.name),
cls.view,
name='armet-api-{}'.format(cls.meta.name),
kwargs={'resource': cls.meta.name})) | [
"Builds",
"the",
"URL",
"configuration",
"for",
"this",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/connectors/django/resources.py#L43-L49 | [
"def",
"urls",
"(",
"cls",
")",
":",
"return",
"urls",
".",
"patterns",
"(",
"''",
",",
"urls",
".",
"url",
"(",
"r'^{}(?:$|(?P<path>[/:(.].*))'",
".",
"format",
"(",
"cls",
".",
"meta",
".",
"name",
")",
",",
"cls",
".",
"view",
",",
"name",
"=",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | dump | Dump an object in req format to the fp given.
:param Mapping obj: The object to serialize. Must have a keys method.
:param fp: A writable that can accept all the types given.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separato... | req.py | def dump(obj, fp, startindex=1, separator=DEFAULT, index_separator=DEFAULT):
'''Dump an object in req format to the fp given.
:param Mapping obj: The object to serialize. Must have a keys method.
:param fp: A writable that can accept all the types given.
:param separator: The separator between key and... | def dump(obj, fp, startindex=1, separator=DEFAULT, index_separator=DEFAULT):
'''Dump an object in req format to the fp given.
:param Mapping obj: The object to serialize. Must have a keys method.
:param fp: A writable that can accept all the types given.
:param separator: The separator between key and... | [
"Dump",
"an",
"object",
"in",
"req",
"format",
"to",
"the",
"fp",
"given",
"."
] | absperf/python-req | python | https://github.com/absperf/python-req/blob/de878f08f4fb28fa140c80d5cbdb04518ef5e968/req.py#L10-L54 | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"startindex",
"=",
"1",
",",
"separator",
"=",
"DEFAULT",
",",
"index_separator",
"=",
"DEFAULT",
")",
":",
"if",
"startindex",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'startindex must be non-negative, but was {}'... | de878f08f4fb28fa140c80d5cbdb04518ef5e968 |
valid | dumps | Dump an object in req format to a string.
:param Mapping obj: The object to serialize. Must have a keys method.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: The separator between key and index. Defaults to u'_' or b'_', ... | req.py | def dumps(obj, startindex=1, separator=DEFAULT, index_separator=DEFAULT):
'''Dump an object in req format to a string.
:param Mapping obj: The object to serialize. Must have a keys method.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param ... | def dumps(obj, startindex=1, separator=DEFAULT, index_separator=DEFAULT):
'''Dump an object in req format to a string.
:param Mapping obj: The object to serialize. Must have a keys method.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param ... | [
"Dump",
"an",
"object",
"in",
"req",
"format",
"to",
"a",
"string",
"."
] | absperf/python-req | python | https://github.com/absperf/python-req/blob/de878f08f4fb28fa140c80d5cbdb04518ef5e968/req.py#L56-L81 | [
"def",
"dumps",
"(",
"obj",
",",
"startindex",
"=",
"1",
",",
"separator",
"=",
"DEFAULT",
",",
"index_separator",
"=",
"DEFAULT",
")",
":",
"try",
":",
"firstkey",
"=",
"next",
"(",
"iter",
"(",
"obj",
".",
"keys",
"(",
")",
")",
")",
"except",
"S... | de878f08f4fb28fa140c80d5cbdb04518ef5e968 |
valid | load | Load an object from the file pointer.
:param fp: A readable filehandle.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: The separator between key and index. Defaults to u'_' or b'_', depending on the types.
:param cls: A... | req.py | def load(fp, separator=DEFAULT, index_separator=DEFAULT, cls=dict, list_cls=list):
'''Load an object from the file pointer.
:param fp: A readable filehandle.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: The separator b... | def load(fp, separator=DEFAULT, index_separator=DEFAULT, cls=dict, list_cls=list):
'''Load an object from the file pointer.
:param fp: A readable filehandle.
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: The separator b... | [
"Load",
"an",
"object",
"from",
"the",
"file",
"pointer",
"."
] | absperf/python-req | python | https://github.com/absperf/python-req/blob/de878f08f4fb28fa140c80d5cbdb04518ef5e968/req.py#L83-L150 | [
"def",
"load",
"(",
"fp",
",",
"separator",
"=",
"DEFAULT",
",",
"index_separator",
"=",
"DEFAULT",
",",
"cls",
"=",
"dict",
",",
"list_cls",
"=",
"list",
")",
":",
"converter",
"=",
"None",
"output",
"=",
"cls",
"(",
")",
"arraykeys",
"=",
"set",
"(... | de878f08f4fb28fa140c80d5cbdb04518ef5e968 |
valid | loads | Loads an object from a string.
:param s: An object to parse
:type s: bytes or str
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: The separator between key and index. Defaults to u'_' or b'_', depending on the types.
... | req.py | def loads(s, separator=DEFAULT, index_separator=DEFAULT, cls=dict, list_cls=list):
'''Loads an object from a string.
:param s: An object to parse
:type s: bytes or str
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: T... | def loads(s, separator=DEFAULT, index_separator=DEFAULT, cls=dict, list_cls=list):
'''Loads an object from a string.
:param s: An object to parse
:type s: bytes or str
:param separator: The separator between key and value. Defaults to u'|' or b'|', depending on the types.
:param index_separator: T... | [
"Loads",
"an",
"object",
"from",
"a",
"string",
"."
] | absperf/python-req | python | https://github.com/absperf/python-req/blob/de878f08f4fb28fa140c80d5cbdb04518ef5e968/req.py#L152-L174 | [
"def",
"loads",
"(",
"s",
",",
"separator",
"=",
"DEFAULT",
",",
"index_separator",
"=",
"DEFAULT",
",",
"cls",
"=",
"dict",
",",
"list_cls",
"=",
"list",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"io",
"=",
"S... | de878f08f4fb28fa140c80d5cbdb04518ef5e968 |
valid | bump | CLI entry point to bump requirements in requirements.txt or pinned.txt | bumper/__init__.py | def bump():
""" CLI entry point to bump requirements in requirements.txt or pinned.txt """
parser = argparse.ArgumentParser(description=bump.__doc__)
parser.add_argument('names', nargs='*', help="""
Only bump dependencies that match the name.
Name can be a product group name defined in workspac... | def bump():
""" CLI entry point to bump requirements in requirements.txt or pinned.txt """
parser = argparse.ArgumentParser(description=bump.__doc__)
parser.add_argument('names', nargs='*', help="""
Only bump dependencies that match the name.
Name can be a product group name defined in workspac... | [
"CLI",
"entry",
"point",
"to",
"bump",
"requirements",
"in",
"requirements",
".",
"txt",
"or",
"pinned",
".",
"txt"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/__init__.py#L12-L46 | [
"def",
"bump",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"bump",
".",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'names'",
",",
"nargs",
"=",
"'*'",
",",
"help",
"=",
"\"\"\"\n Only bump dependen... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | BumperDriver.bump | Bump dependency requirements using filter.
:param list filter_requirements: List of dependency filter requirements.
:param bool required: Require the filter_requirements to be met (by adding if possible).
:param bool show_summary: Show summary for each bump made.
:param bool show_detail... | bumper/__init__.py | def bump(self, filter_requirements, required=False, show_summary=True, show_detail=False, **kwargs):
"""
Bump dependency requirements using filter.
:param list filter_requirements: List of dependency filter requirements.
:param bool required: Require the filter_requirements to be met (b... | def bump(self, filter_requirements, required=False, show_summary=True, show_detail=False, **kwargs):
"""
Bump dependency requirements using filter.
:param list filter_requirements: List of dependency filter requirements.
:param bool required: Require the filter_requirements to be met (b... | [
"Bump",
"dependency",
"requirements",
"using",
"filter",
"."
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/__init__.py#L71-L197 | [
"def",
"bump",
"(",
"self",
",",
"filter_requirements",
",",
"required",
"=",
"False",
",",
"show_summary",
"=",
"True",
",",
"show_detail",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"found_targets",
"=",
"[",
"target",
"for",
"target",
"in",
"sel... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | BumperDriver.reverse | Reverse all bumpers | bumper/__init__.py | def reverse(self):
""" Reverse all bumpers """
if not self.test_drive and self.bumps:
map(lambda b: b.reverse(), self.bumpers) | def reverse(self):
""" Reverse all bumpers """
if not self.test_drive and self.bumps:
map(lambda b: b.reverse(), self.bumpers) | [
"Reverse",
"all",
"bumpers"
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/__init__.py#L199-L202 | [
"def",
"reverse",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"test_drive",
"and",
"self",
".",
"bumps",
":",
"map",
"(",
"lambda",
"b",
":",
"b",
".",
"reverse",
"(",
")",
",",
"self",
".",
"bumpers",
")"
] | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | BumperDriver._expand_targets | Expand targets by looking for '-r' in targets. | bumper/__init__.py | def _expand_targets(self, targets, base_dir=None):
""" Expand targets by looking for '-r' in targets. """
all_targets = []
for target in targets:
target_dirs = [p for p in [base_dir, os.path.dirname(target)] if p]
target_dir = target_dirs and os.path.join(*target_dirs) o... | def _expand_targets(self, targets, base_dir=None):
""" Expand targets by looking for '-r' in targets. """
all_targets = []
for target in targets:
target_dirs = [p for p in [base_dir, os.path.dirname(target)] if p]
target_dir = target_dirs and os.path.join(*target_dirs) o... | [
"Expand",
"targets",
"by",
"looking",
"for",
"-",
"r",
"in",
"targets",
"."
] | maxzheng/bumper-lib | python | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/__init__.py#L204-L223 | [
"def",
"_expand_targets",
"(",
"self",
",",
"targets",
",",
"base_dir",
"=",
"None",
")",
":",
"all_targets",
"=",
"[",
"]",
"for",
"target",
"in",
"targets",
":",
"target_dirs",
"=",
"[",
"p",
"for",
"p",
"in",
"[",
"base_dir",
",",
"os",
".",
"path... | 32a9dec5448673825bb2d7d92fa68882b597f794 |
valid | ProjectCreator.get_nginx_config | Gets the Nginx config for the project | ignition/__init__.py | def get_nginx_config(self):
"""
Gets the Nginx config for the project
"""
if os.path.exists(self._nginx_config):
return open(self._nginx_config, 'r').read()
else:
return None | def get_nginx_config(self):
"""
Gets the Nginx config for the project
"""
if os.path.exists(self._nginx_config):
return open(self._nginx_config, 'r').read()
else:
return None | [
"Gets",
"the",
"Nginx",
"config",
"for",
"the",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L88-L96 | [
"def",
"get_nginx_config",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_nginx_config",
")",
":",
"return",
"open",
"(",
"self",
".",
"_nginx_config",
",",
"'r'",
")",
".",
"read",
"(",
")",
"else",
":",
"return",... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ProjectCreator.check_directories | Creates base directories for app, virtualenv, and nginx | ignition/__init__.py | def check_directories(self):
"""
Creates base directories for app, virtualenv, and nginx
"""
self.log.debug('Checking directories')
if not os.path.exists(self._ve_dir):
os.makedirs(self._ve_dir)
if not os.path.exists(self._app_dir):
os.makedirs(se... | def check_directories(self):
"""
Creates base directories for app, virtualenv, and nginx
"""
self.log.debug('Checking directories')
if not os.path.exists(self._ve_dir):
os.makedirs(self._ve_dir)
if not os.path.exists(self._app_dir):
os.makedirs(se... | [
"Creates",
"base",
"directories",
"for",
"app",
"virtualenv",
"and",
"nginx"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L115-L147 | [
"def",
"check_directories",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Checking directories'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_ve_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"_... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ProjectCreator.create_virtualenv | Creates the virtualenv for the project | ignition/__init__.py | def create_virtualenv(self):
"""
Creates the virtualenv for the project
"""
if check_command('virtualenv'):
ve_dir = os.path.join(self._ve_dir, self._project_name)
if os.path.exists(ve_dir):
if self._force:
logging.warn... | def create_virtualenv(self):
"""
Creates the virtualenv for the project
"""
if check_command('virtualenv'):
ve_dir = os.path.join(self._ve_dir, self._project_name)
if os.path.exists(ve_dir):
if self._force:
logging.warn... | [
"Creates",
"the",
"virtualenv",
"for",
"the",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L149-L171 | [
"def",
"create_virtualenv",
"(",
"self",
")",
":",
"if",
"check_command",
"(",
"'virtualenv'",
")",
":",
"ve_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_ve_dir",
",",
"self",
".",
"_project_name",
")",
"if",
"os",
".",
"path",
".",
... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ProjectCreator.create_nginx_config | Creates the Nginx configuration for the project | ignition/__init__.py | def create_nginx_config(self):
"""
Creates the Nginx configuration for the project
"""
cfg = '# nginx config for {0}\n'.format(self._project_name)
if not self._shared_hosting:
# user
if self._user:
cfg += 'user {0};\n'.format(self._user)
... | def create_nginx_config(self):
"""
Creates the Nginx configuration for the project
"""
cfg = '# nginx config for {0}\n'.format(self._project_name)
if not self._shared_hosting:
# user
if self._user:
cfg += 'user {0};\n'.format(self._user)
... | [
"Creates",
"the",
"Nginx",
"configuration",
"for",
"the",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L179-L233 | [
"def",
"create_nginx_config",
"(",
"self",
")",
":",
"cfg",
"=",
"'# nginx config for {0}\\n'",
".",
"format",
"(",
"self",
".",
"_project_name",
")",
"if",
"not",
"self",
".",
"_shared_hosting",
":",
"# user",
"if",
"self",
".",
"_user",
":",
"cfg",
"+=",
... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ProjectCreator.create_manage_scripts | Creates scripts to start and stop the application | ignition/__init__.py | def create_manage_scripts(self):
"""
Creates scripts to start and stop the application
"""
# create start script
start = '# start script for {0}\n\n'.format(self._project_name)
# start uwsgi
start += 'echo \'Starting uWSGI...\'\n'
start += 'sh {0}.uwsgi\n... | def create_manage_scripts(self):
"""
Creates scripts to start and stop the application
"""
# create start script
start = '# start script for {0}\n\n'.format(self._project_name)
# start uwsgi
start += 'echo \'Starting uWSGI...\'\n'
start += 'sh {0}.uwsgi\n... | [
"Creates",
"scripts",
"to",
"start",
"and",
"stop",
"the",
"application"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L235-L271 | [
"def",
"create_manage_scripts",
"(",
"self",
")",
":",
"# create start script",
"start",
"=",
"'# start script for {0}\\n\\n'",
".",
"format",
"(",
"self",
".",
"_project_name",
")",
"# start uwsgi",
"start",
"+=",
"'echo \\'Starting uWSGI...\\'\\n'",
"start",
"+=",
"'s... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | ProjectCreator.create | Creates the full project | ignition/__init__.py | def create(self):
"""
Creates the full project
"""
# create virtualenv
self.create_virtualenv()
# create project
self.create_project()
# generate uwsgi script
self.create_uwsgi_script()
# generate nginx config
self.create_nginx_con... | def create(self):
"""
Creates the full project
"""
# create virtualenv
self.create_virtualenv()
# create project
self.create_project()
# generate uwsgi script
self.create_uwsgi_script()
# generate nginx config
self.create_nginx_con... | [
"Creates",
"the",
"full",
"project"
] | ehazlett/ignition | python | https://github.com/ehazlett/ignition/blob/618776fccd199c4613e105ee55955b40e52d3e68/ignition/__init__.py#L273-L288 | [
"def",
"create",
"(",
"self",
")",
":",
"# create virtualenv",
"self",
".",
"create_virtualenv",
"(",
")",
"# create project",
"self",
".",
"create_project",
"(",
")",
"# generate uwsgi script",
"self",
".",
"create_uwsgi_script",
"(",
")",
"# generate nginx config",
... | 618776fccd199c4613e105ee55955b40e52d3e68 |
valid | dasherize | Dasherizes the passed value. | armet/utils/string.py | def dasherize(value):
"""Dasherizes the passed value."""
value = value.strip()
value = re.sub(r'([A-Z])', r'-\1', value)
value = re.sub(r'[-_\s]+', r'-', value)
value = re.sub(r'^-', r'', value)
value = value.lower()
return value | def dasherize(value):
"""Dasherizes the passed value."""
value = value.strip()
value = re.sub(r'([A-Z])', r'-\1', value)
value = re.sub(r'[-_\s]+', r'-', value)
value = re.sub(r'^-', r'', value)
value = value.lower()
return value | [
"Dasherizes",
"the",
"passed",
"value",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/utils/string.py#L6-L13 | [
"def",
"dasherize",
"(",
"value",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"value",
"=",
"re",
".",
"sub",
"(",
"r'([A-Z])'",
",",
"r'-\\1'",
",",
"value",
")",
"value",
"=",
"re",
".",
"sub",
"(",
"r'[-_\\s]+'",
",",
"r'-'",
",",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.redirect | Redirect to the canonical URI for this resource. | armet/resources/resource/base.py | def redirect(cls, request, response):
"""Redirect to the canonical URI for this resource."""
if cls.meta.legacy_redirect:
if request.method in ('GET', 'HEAD',):
# A SAFE request is allowed to redirect using a 301
response.status = http.client.MOVED_PERMANENTLY... | def redirect(cls, request, response):
"""Redirect to the canonical URI for this resource."""
if cls.meta.legacy_redirect:
if request.method in ('GET', 'HEAD',):
# A SAFE request is allowed to redirect using a 301
response.status = http.client.MOVED_PERMANENTLY... | [
"Redirect",
"to",
"the",
"canonical",
"URI",
"for",
"this",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L50-L68 | [
"def",
"redirect",
"(",
"cls",
",",
"request",
",",
"response",
")",
":",
"if",
"cls",
".",
"meta",
".",
"legacy_redirect",
":",
"if",
"request",
".",
"method",
"in",
"(",
"'GET'",
",",
"'HEAD'",
",",
")",
":",
"# A SAFE request is allowed to redirect using ... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.view | Entry-point of the request / response cycle; Handles resource creation
and delegation.
@param[in] requset
The HTTP request object; containing accessors for information
about the request.
@param[in] response
The HTTP response object; contains accessors for mo... | armet/resources/resource/base.py | def view(cls, request, response):
"""
Entry-point of the request / response cycle; Handles resource creation
and delegation.
@param[in] requset
The HTTP request object; containing accessors for information
about the request.
@param[in] response
... | def view(cls, request, response):
"""
Entry-point of the request / response cycle; Handles resource creation
and delegation.
@param[in] requset
The HTTP request object; containing accessors for information
about the request.
@param[in] response
... | [
"Entry",
"-",
"point",
"of",
"the",
"request",
"/",
"response",
"cycle",
";",
"Handles",
"resource",
"creation",
"and",
"delegation",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L71-L157 | [
"def",
"view",
"(",
"cls",
",",
"request",
",",
"response",
")",
":",
"# Determine if we need to redirect.",
"test",
"=",
"cls",
".",
"meta",
".",
"trailing_slash",
"if",
"test",
"^",
"request",
".",
"path",
".",
"endswith",
"(",
"'/'",
")",
":",
"# Constr... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.parse | Parses out parameters and separates them out of the path.
This uses one of the many defined patterns on the options class. But,
it defaults to a no-op if there are no defined patterns. | armet/resources/resource/base.py | def parse(cls, path):
"""Parses out parameters and separates them out of the path.
This uses one of the many defined patterns on the options class. But,
it defaults to a no-op if there are no defined patterns.
"""
# Iterate through the available patterns.
for resource, p... | def parse(cls, path):
"""Parses out parameters and separates them out of the path.
This uses one of the many defined patterns on the options class. But,
it defaults to a no-op if there are no defined patterns.
"""
# Iterate through the available patterns.
for resource, p... | [
"Parses",
"out",
"parameters",
"and",
"separates",
"them",
"out",
"of",
"the",
"path",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L160-L175 | [
"def",
"parse",
"(",
"cls",
",",
"path",
")",
":",
"# Iterate through the available patterns.",
"for",
"resource",
",",
"pattern",
"in",
"cls",
".",
"meta",
".",
"patterns",
":",
"# Attempt to match the path.",
"match",
"=",
"re",
".",
"match",
"(",
"pattern",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.traverse | Traverses down the path and determines the accessed resource.
This makes use of the patterns array to implement simple traversal.
This defaults to a no-op if there are no defined patterns. | armet/resources/resource/base.py | def traverse(cls, request, params=None):
"""Traverses down the path and determines the accessed resource.
This makes use of the patterns array to implement simple traversal.
This defaults to a no-op if there are no defined patterns.
"""
# Attempt to parse the path using a patter... | def traverse(cls, request, params=None):
"""Traverses down the path and determines the accessed resource.
This makes use of the patterns array to implement simple traversal.
This defaults to a no-op if there are no defined patterns.
"""
# Attempt to parse the path using a patter... | [
"Traverses",
"down",
"the",
"path",
"and",
"determines",
"the",
"accessed",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L178-L214 | [
"def",
"traverse",
"(",
"cls",
",",
"request",
",",
"params",
"=",
"None",
")",
":",
"# Attempt to parse the path using a pattern.",
"result",
"=",
"cls",
".",
"parse",
"(",
"request",
".",
"path",
")",
"if",
"result",
"is",
"None",
":",
"# No parsing was requ... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.stream | Helper method used in conjunction with the view handler to
stream responses to the client. | armet/resources/resource/base.py | def stream(cls, response, sequence):
"""
Helper method used in conjunction with the view handler to
stream responses to the client.
"""
# Construct the iterator and run the sequence once in order
# to capture any headers and status codes set.
iterator = iter(seque... | def stream(cls, response, sequence):
"""
Helper method used in conjunction with the view handler to
stream responses to the client.
"""
# Construct the iterator and run the sequence once in order
# to capture any headers and status codes set.
iterator = iter(seque... | [
"Helper",
"method",
"used",
"in",
"conjunction",
"with",
"the",
"view",
"handler",
"to",
"stream",
"responses",
"to",
"the",
"client",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L217-L258 | [
"def",
"stream",
"(",
"cls",
",",
"response",
",",
"sequence",
")",
":",
"# Construct the iterator and run the sequence once in order",
"# to capture any headers and status codes set.",
"iterator",
"=",
"iter",
"(",
"sequence",
")",
"data",
"=",
"{",
"'chunk'",
":",
"ne... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.deserialize | Deserializes the text using a determined deserializer.
@param[in] request
The request object to pull information from; normally used to
determine the deserialization format (when `format` is
not provided).
@param[in] text
The text to be deserialized. Can... | armet/resources/resource/base.py | def deserialize(self, request=None, text=None, format=None):
"""Deserializes the text using a determined deserializer.
@param[in] request
The request object to pull information from; normally used to
determine the deserialization format (when `format` is
not provided... | def deserialize(self, request=None, text=None, format=None):
"""Deserializes the text using a determined deserializer.
@param[in] request
The request object to pull information from; normally used to
determine the deserialization format (when `format` is
not provided... | [
"Deserializes",
"the",
"text",
"using",
"a",
"determined",
"deserializer",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L261-L326 | [
"def",
"deserialize",
"(",
"self",
",",
"request",
"=",
"None",
",",
"text",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"Resource",
")",
":",
"if",
"not",
"request",
":",
"# Ensure we have a response object.",
... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.serialize | Serializes the data using a determined serializer.
@param[in] data
The data to be serialized.
@param[in] response
The response object to serialize the data to.
If this method is invoked as an instance method, the response
object can be omitted and it wil... | armet/resources/resource/base.py | def serialize(self, data, response=None, request=None, format=None):
"""Serializes the data using a determined serializer.
@param[in] data
The data to be serialized.
@param[in] response
The response object to serialize the data to.
If this method is invoked ... | def serialize(self, data, response=None, request=None, format=None):
"""Serializes the data using a determined serializer.
@param[in] data
The data to be serialized.
@param[in] response
The response object to serialize the data to.
If this method is invoked ... | [
"Serializes",
"the",
"data",
"using",
"a",
"determined",
"serializer",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L329-L411 | [
"def",
"serialize",
"(",
"self",
",",
"data",
",",
"response",
"=",
"None",
",",
"request",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"Resource",
")",
":",
"if",
"not",
"request",
":",
"# Ensure we have a ... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource._process_cross_domain_request | Facilitate Cross-Origin Requests (CORs). | armet/resources/resource/base.py | def _process_cross_domain_request(cls, request, response):
"""Facilitate Cross-Origin Requests (CORs).
"""
# Step 1
# Check for Origin header.
origin = request.get('Origin')
if not origin:
return
# Step 2
# Check if the origin is in the list ... | def _process_cross_domain_request(cls, request, response):
"""Facilitate Cross-Origin Requests (CORs).
"""
# Step 1
# Check for Origin header.
origin = request.get('Origin')
if not origin:
return
# Step 2
# Check if the origin is in the list ... | [
"Facilitate",
"Cross",
"-",
"Origin",
"Requests",
"(",
"CORs",
")",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L414-L473 | [
"def",
"_process_cross_domain_request",
"(",
"cls",
",",
"request",
",",
"response",
")",
":",
"# Step 1",
"# Check for Origin header.",
"origin",
"=",
"request",
".",
"get",
"(",
"'Origin'",
")",
"if",
"not",
"origin",
":",
"return",
"# Step 2",
"# Check if the o... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.dispatch | Entry-point of the dispatch cycle for this resource.
Performs common work such as authentication, decoding, etc. before
handing complete control of the result to a function with the
same name as the request method. | armet/resources/resource/base.py | def dispatch(self, request, response):
"""Entry-point of the dispatch cycle for this resource.
Performs common work such as authentication, decoding, etc. before
handing complete control of the result to a function with the
same name as the request method.
"""
# Assert a... | def dispatch(self, request, response):
"""Entry-point of the dispatch cycle for this resource.
Performs common work such as authentication, decoding, etc. before
handing complete control of the result to a function with the
same name as the request method.
"""
# Assert a... | [
"Entry",
"-",
"point",
"of",
"the",
"dispatch",
"cycle",
"for",
"this",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L480-L499 | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# Assert authentication and attempt to get a valid user object.",
"self",
".",
"require_authentication",
"(",
"request",
")",
"# Assert accessibiltiy of the resource in question.",
"self",
".",
"requi... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.require_authentication | Ensure we are authenticated. | armet/resources/resource/base.py | def require_authentication(self, request):
"""Ensure we are authenticated."""
request.user = user = None
if request.method == 'OPTIONS':
# Authentication should not be checked on an OPTIONS request.
return
for auth in self.meta.authentication:
user =... | def require_authentication(self, request):
"""Ensure we are authenticated."""
request.user = user = None
if request.method == 'OPTIONS':
# Authentication should not be checked on an OPTIONS request.
return
for auth in self.meta.authentication:
user =... | [
"Ensure",
"we",
"are",
"authenticated",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L501-L529 | [
"def",
"require_authentication",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"user",
"=",
"user",
"=",
"None",
"if",
"request",
".",
"method",
"==",
"'OPTIONS'",
":",
"# Authentication should not be checked on an OPTIONS request.",
"return",
"for",
"auth"... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.require_accessibility | Ensure we are allowed to access this resource. | armet/resources/resource/base.py | def require_accessibility(self, user, method):
"""Ensure we are allowed to access this resource."""
if method == 'OPTIONS':
# Authorization should not be checked on an OPTIONS request.
return
authz = self.meta.authorization
if not authz.is_accessible(user, method... | def require_accessibility(self, user, method):
"""Ensure we are allowed to access this resource."""
if method == 'OPTIONS':
# Authorization should not be checked on an OPTIONS request.
return
authz = self.meta.authorization
if not authz.is_accessible(user, method... | [
"Ensure",
"we",
"are",
"allowed",
"to",
"access",
"this",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L531-L540 | [
"def",
"require_accessibility",
"(",
"self",
",",
"user",
",",
"method",
")",
":",
"if",
"method",
"==",
"'OPTIONS'",
":",
"# Authorization should not be checked on an OPTIONS request.",
"return",
"authz",
"=",
"self",
".",
"meta",
".",
"authorization",
"if",
"not",... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.