repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
camptocamp/Studio | studio/controllers/datastores.py | DatastoresController.index | def index(self, format='html'):
"""GET /datastores: All items in the collection."""
# url('datastores')
results = meta.Session.query(DataStore)
serialized_datastores = [{'id': ds.id, 'text': ds.name, 'href': h.url_for(controller="datastores", action="show", id=ds.id), 'type': ds.type} fo... | python | def index(self, format='html'):
"""GET /datastores: All items in the collection."""
# url('datastores')
results = meta.Session.query(DataStore)
serialized_datastores = [{'id': ds.id, 'text': ds.name, 'href': h.url_for(controller="datastores", action="show", id=ds.id), 'type': ds.type} fo... | [
"def",
"index",
"(",
"self",
",",
"format",
"=",
"'html'",
")",
":",
"# url('datastores')",
"results",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"DataStore",
")",
"serialized_datastores",
"=",
"[",
"{",
"'id'",
":",
"ds",
".",
"id",
",",
"'text'",
... | GET /datastores: All items in the collection. | [
"GET",
"/",
"datastores",
":",
"All",
"items",
"in",
"the",
"collection",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datastores.py#L44-L50 | train | GET / datastores : All items in the collection. |
camptocamp/Studio | studio/controllers/datastores.py | DatastoresController.create | def create(self):
"""POST /datastores: Create a new item."""
# url('datastores')
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
new = DataStore(content['name'],
... | python | def create(self):
"""POST /datastores: Create a new item."""
# url('datastores')
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
new = DataStore(content['name'],
... | [
"def",
"create",
"(",
"self",
")",
":",
"# url('datastores')",
"content",
"=",
"request",
".",
"environ",
"[",
"'wsgi.input'",
"]",
".",
"read",
"(",
"int",
"(",
"request",
".",
"environ",
"[",
"'CONTENT_LENGTH'",
"]",
")",
")",
"content",
"=",
"content",
... | POST /datastores: Create a new item. | [
"POST",
"/",
"datastores",
":",
"Create",
"a",
"new",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datastores.py#L53-L64 | train | POST / datastores : Create a new item. |
camptocamp/Studio | studio/controllers/datastores.py | DatastoresController.update | def update(self, id):
"""PUT /datastores/id: Update an existing item."""
# url('DataStores', id=ID)
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
result = m... | python | def update(self, id):
"""PUT /datastores/id: Update an existing item."""
# url('DataStores', id=ID)
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
result = m... | [
"def",
"update",
"(",
"self",
",",
"id",
")",
":",
"# url('DataStores', id=ID)",
"content",
"=",
"request",
".",
"environ",
"[",
"'wsgi.input'",
"]",
".",
"read",
"(",
"int",
"(",
"request",
".",
"environ",
"[",
"'CONTENT_LENGTH'",
"]",
")",
")",
"content"... | PUT /datastores/id: Update an existing item. | [
"PUT",
"/",
"datastores",
"/",
"id",
":",
"Update",
"an",
"existing",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datastores.py#L67-L78 | train | PUT / datastores / id : Update an existing item. |
camptocamp/Studio | studio/controllers/datastores.py | DatastoresController.delete | def delete(self, id):
"""DELETE /datastores/id: Delete an existing item."""
# url('DataStores', id=ID)
result = meta.Session.query(DataStore).get(id)
meta.Session.delete(result)
meta.Session.commit()
response.status = 204
# remove content-type from response heade... | python | def delete(self, id):
"""DELETE /datastores/id: Delete an existing item."""
# url('DataStores', id=ID)
result = meta.Session.query(DataStore).get(id)
meta.Session.delete(result)
meta.Session.commit()
response.status = 204
# remove content-type from response heade... | [
"def",
"delete",
"(",
"self",
",",
"id",
")",
":",
"# url('DataStores', id=ID)",
"result",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"DataStore",
")",
".",
"get",
"(",
"id",
")",
"meta",
".",
"Session",
".",
"delete",
"(",
"result",
")",
"meta",
... | DELETE /datastores/id: Delete an existing item. | [
"DELETE",
"/",
"datastores",
"/",
"id",
":",
"Delete",
"an",
"existing",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datastores.py#L81-L91 | train | DELETE / datastores / id : Delete an existing item. |
camptocamp/Studio | studio/controllers/datastores.py | DatastoresController.show | def show(self, id):
"""GET /datastores/id: Show a specific item."""
# url('DataStores', id=ID)
datastore = meta.Session.query(DataStore).get(id)
# do not raise RuntimeError from discover_datasources
# if in "test" mode
try:
datasources = discover_datasources(... | python | def show(self, id):
"""GET /datastores/id: Show a specific item."""
# url('DataStores', id=ID)
datastore = meta.Session.query(DataStore).get(id)
# do not raise RuntimeError from discover_datasources
# if in "test" mode
try:
datasources = discover_datasources(... | [
"def",
"show",
"(",
"self",
",",
"id",
")",
":",
"# url('DataStores', id=ID)",
"datastore",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"DataStore",
")",
".",
"get",
"(",
"id",
")",
"# do not raise RuntimeError from discover_datasources",
"# if in \"test\" mode"... | GET /datastores/id: Show a specific item. | [
"GET",
"/",
"datastores",
"/",
"id",
":",
"Show",
"a",
"specific",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datastores.py#L95-L112 | train | GET / datastores / id : Show a specific item. |
Utagai/spice | spice_api/spice.py | init_auth | def init_auth(username, password):
"""Initializes the auth settings for accessing MyAnimeList
through its official API from a given username and password.
:param username Your MyAnimeList account username.
:param password Your MyAnimeList account password.
:return A tuple containing your credentials... | python | def init_auth(username, password):
"""Initializes the auth settings for accessing MyAnimeList
through its official API from a given username and password.
:param username Your MyAnimeList account username.
:param password Your MyAnimeList account password.
:return A tuple containing your credentials... | [
"def",
"init_auth",
"(",
"username",
",",
"password",
")",
":",
"username",
"=",
"username",
".",
"strip",
"(",
")",
"password",
"=",
"password",
".",
"strip",
"(",
")",
"credentials",
"=",
"(",
"username",
",",
"password",
")",
"if",
"helpers",
".",
"... | Initializes the auth settings for accessing MyAnimeList
through its official API from a given username and password.
:param username Your MyAnimeList account username.
:param password Your MyAnimeList account password.
:return A tuple containing your credentials. | [
"Initializes",
"the",
"auth",
"settings",
"for",
"accessing",
"MyAnimeList",
"through",
"its",
"official",
"API",
"from",
"a",
"given",
"username",
"and",
"password",
".",
":",
"param",
"username",
"Your",
"MyAnimeList",
"account",
"username",
".",
":",
"param",... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L100-L113 | train | Initializes the auth settings for accessing MyAnimeList
through its official API from a given username and password. |
Utagai/spice | spice_api/spice.py | load_auth_from_file | def load_auth_from_file(filename):
"""Initializes the auth settings for accessing MyAnimelist through its
official API from a given filename.
:param filename The name of the file containing your MyAnimeList
credentials
REQUIREMENTS: The file must...
... | python | def load_auth_from_file(filename):
"""Initializes the auth settings for accessing MyAnimelist through its
official API from a given filename.
:param filename The name of the file containing your MyAnimeList
credentials
REQUIREMENTS: The file must...
... | [
"def",
"load_auth_from_file",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"auth_file",
":",
"lines",
"=",
"auth_file",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
")",
"... | Initializes the auth settings for accessing MyAnimelist through its
official API from a given filename.
:param filename The name of the file containing your MyAnimeList
credentials
REQUIREMENTS: The file must...
...username for your MAL account.
... | [
"Initializes",
"the",
"auth",
"settings",
"for",
"accessing",
"MyAnimelist",
"through",
"its",
"official",
"API",
"from",
"a",
"given",
"filename",
".",
":",
"param",
"filename",
"The",
"name",
"of",
"the",
"file",
"containing",
"your",
"MyAnimeList",
"credentia... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L115-L141 | train | Initializes the auth settings for accessing MyAnimelist through its
official API from a given file. |
Utagai/spice | spice_api/spice.py | search | def search(query, medium, credentials):
"""Searches MyAnimeList for a [medium] matching the keyword(s) given by query.
:param query The keyword(s) to search with.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return A list of all items that are of type [medium] and match t... | python | def search(query, medium, credentials):
"""Searches MyAnimeList for a [medium] matching the keyword(s) given by query.
:param query The keyword(s) to search with.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return A list of all items that are of type [medium] and match t... | [
"def",
"search",
"(",
"query",
",",
"medium",
",",
"credentials",
")",
":",
"helpers",
".",
"check_creds",
"(",
"credentials",
",",
"header",
")",
"if",
"len",
"(",
"query",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"constants",
".",
"INVALID_EMPT... | Searches MyAnimeList for a [medium] matching the keyword(s) given by query.
:param query The keyword(s) to search with.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return A list of all items that are of type [medium] and match the
given keywords, or, an empty li... | [
"Searches",
"MyAnimeList",
"for",
"a",
"[",
"medium",
"]",
"matching",
"the",
"keyword",
"(",
"s",
")",
"given",
"by",
"query",
".",
":",
"param",
"query",
"The",
"keyword",
"(",
"s",
")",
"to",
"search",
"with",
".",
":",
"param",
"medium",
"Anime",
... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L143-L173 | train | Searches MyAnimeList for a given keyword and returns a list of all items that match the given keywords. |
Utagai/spice | spice_api/spice.py | search_id | def search_id(id, medium, credentials):
"""Grabs the [medium] with the given id from MyAnimeList as a [medium]
object.
:param id The id of the [medium].
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return The [medium] object with id requested, or None if no such [m... | python | def search_id(id, medium, credentials):
"""Grabs the [medium] with the given id from MyAnimeList as a [medium]
object.
:param id The id of the [medium].
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return The [medium] object with id requested, or None if no such [m... | [
"def",
"search_id",
"(",
"id",
",",
"medium",
",",
"credentials",
")",
":",
"helpers",
".",
"check_creds",
"(",
"credentials",
",",
"header",
")",
"if",
"id",
"<=",
"0",
"or",
"not",
"float",
"(",
"id",
")",
".",
"is_integer",
"(",
")",
":",
"raise",... | Grabs the [medium] with the given id from MyAnimeList as a [medium]
object.
:param id The id of the [medium].
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:return The [medium] object with id requested, or None if no such [medium]
exists.
:raise ValueErro... | [
"Grabs",
"the",
"[",
"medium",
"]",
"with",
"the",
"given",
"id",
"from",
"MyAnimeList",
"as",
"a",
"[",
"medium",
"]",
"object",
".",
":",
"param",
"id",
"The",
"id",
"of",
"the",
"[",
"medium",
"]",
".",
":",
"param",
"medium",
"Anime",
"or",
"ma... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L175-L203 | train | Searches MyAnimeList for an anime with the given id. |
Utagai/spice | spice_api/spice.py | add | def add(data, id, medium, credentials):
"""Adds the [medium] with the given id and data to the user's [medium]List.
:param data The data for the [medium] to add.
:param id The id of the data to add.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError Fo... | python | def add(data, id, medium, credentials):
"""Adds the [medium] with the given id and data to the user's [medium]List.
:param data The data for the [medium] to add.
:param id The id of the data to add.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError Fo... | [
"def",
"add",
"(",
"data",
",",
"id",
",",
"medium",
",",
"credentials",
")",
":",
"_op",
"(",
"data",
",",
"id",
",",
"medium",
",",
"tokens",
".",
"Operations",
".",
"ADD",
",",
"credentials",
")"
] | Adds the [medium] with the given id and data to the user's [medium]List.
:param data The data for the [medium] to add.
:param id The id of the data to add.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError For bad arguments. | [
"Adds",
"the",
"[",
"medium",
"]",
"with",
"the",
"given",
"id",
"and",
"data",
"to",
"the",
"user",
"s",
"[",
"medium",
"]",
"List",
".",
":",
"param",
"data",
"The",
"data",
"for",
"the",
"[",
"medium",
"]",
"to",
"add",
".",
":",
"param",
"id"... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L205-L212 | train | Adds the data for the given id and data to the user s [ mediumList ]. |
Utagai/spice | spice_api/spice.py | update | def update(data, id, medium, credentials):
"""Updates the [medium] with the given id and data on the user's [medium]List.
:param data The data for the [medium] to update.
:param id The id of the data to update.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise V... | python | def update(data, id, medium, credentials):
"""Updates the [medium] with the given id and data on the user's [medium]List.
:param data The data for the [medium] to update.
:param id The id of the data to update.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise V... | [
"def",
"update",
"(",
"data",
",",
"id",
",",
"medium",
",",
"credentials",
")",
":",
"_op",
"(",
"data",
",",
"id",
",",
"medium",
",",
"tokens",
".",
"Operations",
".",
"UPDATE",
",",
"credentials",
")"
] | Updates the [medium] with the given id and data on the user's [medium]List.
:param data The data for the [medium] to update.
:param id The id of the data to update.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError For bad arguments. | [
"Updates",
"the",
"[",
"medium",
"]",
"with",
"the",
"given",
"id",
"and",
"data",
"on",
"the",
"user",
"s",
"[",
"medium",
"]",
"List",
".",
":",
"param",
"data",
"The",
"data",
"for",
"the",
"[",
"medium",
"]",
"to",
"update",
".",
":",
"param",
... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L214-L221 | train | Updates the data for the given id and data on the user s [ mediumList ]. |
Utagai/spice | spice_api/spice.py | delete | def delete(data, id, medium, credentials):
"""Deletes the [medium] with the given id and data from the user's [medium]List.
:param data The data for the [medium] to delete.
:param id The id of the data to delete.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise... | python | def delete(data, id, medium, credentials):
"""Deletes the [medium] with the given id and data from the user's [medium]List.
:param data The data for the [medium] to delete.
:param id The id of the data to delete.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise... | [
"def",
"delete",
"(",
"data",
",",
"id",
",",
"medium",
",",
"credentials",
")",
":",
"_op",
"(",
"data",
",",
"id",
",",
"medium",
",",
"tokens",
".",
"Operations",
".",
"DElETE",
",",
"credentials",
")"
] | Deletes the [medium] with the given id and data from the user's [medium]List.
:param data The data for the [medium] to delete.
:param id The id of the data to delete.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError For bad arguments. | [
"Deletes",
"the",
"[",
"medium",
"]",
"with",
"the",
"given",
"id",
"and",
"data",
"from",
"the",
"user",
"s",
"[",
"medium",
"]",
"List",
".",
":",
"param",
"data",
"The",
"data",
"for",
"the",
"[",
"medium",
"]",
"to",
"delete",
".",
":",
"param"... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L223-L230 | train | Delete the data for the given id and data from the user s [ mediumList ]. |
Utagai/spice | spice_api/spice.py | get_blank | def get_blank(medium):
"""Returns a [medium]Data object for filling before calling spice.add(),
spice.update() or spice.delete().
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:returns A [medium]Data object.
"""
if medium == tokens.Medium.ANIME:
return object... | python | def get_blank(medium):
"""Returns a [medium]Data object for filling before calling spice.add(),
spice.update() or spice.delete().
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:returns A [medium]Data object.
"""
if medium == tokens.Medium.ANIME:
return object... | [
"def",
"get_blank",
"(",
"medium",
")",
":",
"if",
"medium",
"==",
"tokens",
".",
"Medium",
".",
"ANIME",
":",
"return",
"objects",
".",
"AnimeData",
"(",
")",
"elif",
"medium",
"==",
"tokens",
".",
"Medium",
".",
"MANGA",
":",
"return",
"objects",
"."... | Returns a [medium]Data object for filling before calling spice.add(),
spice.update() or spice.delete().
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:returns A [medium]Data object. | [
"Returns",
"a",
"[",
"medium",
"]",
"Data",
"object",
"for",
"filling",
"before",
"calling",
"spice",
".",
"add",
"()",
"spice",
".",
"update",
"()",
"or",
"spice",
".",
"delete",
"()",
".",
":",
"param",
"medium",
"Anime",
"or",
"manga",
"(",
"tokens"... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L249-L260 | train | Returns a [ medium ]Data object for filling before calling spice. add or spice. update or spice. delete. |
Utagai/spice | spice_api/spice.py | get_list | def get_list(medium, user, credentials):
"""Returns a MediumList (Anime or Manga depends on [medium]) of user.
If user is not given, the username is taken from the initialized auth
credentials.
:param medium Anime or manga (tokens.Medium.Anime or tokens.Medium.Manga)
:param user The user whose lis... | python | def get_list(medium, user, credentials):
"""Returns a MediumList (Anime or Manga depends on [medium]) of user.
If user is not given, the username is taken from the initialized auth
credentials.
:param medium Anime or manga (tokens.Medium.Anime or tokens.Medium.Manga)
:param user The user whose lis... | [
"def",
"get_list",
"(",
"medium",
",",
"user",
",",
"credentials",
")",
":",
"helpers",
".",
"check_creds",
"(",
"credentials",
",",
"header",
")",
"list_url",
"=",
"helpers",
".",
"get_list_url",
"(",
"medium",
",",
"user",
")",
"#for some reason, we don't ne... | Returns a MediumList (Anime or Manga depends on [medium]) of user.
If user is not given, the username is taken from the initialized auth
credentials.
:param medium Anime or manga (tokens.Medium.Anime or tokens.Medium.Manga)
:param user The user whose list should be grabbed. May use credentials[0]. | [
"Returns",
"a",
"MediumList",
"(",
"Anime",
"or",
"Manga",
"depends",
"on",
"[",
"medium",
"]",
")",
"of",
"user",
".",
"If",
"user",
"is",
"not",
"given",
"the",
"username",
"is",
"taken",
"from",
"the",
"initialized",
"auth",
"credentials",
".",
":",
... | 00b2c9e80ef338f4daef7643d99e8c7a0750b57c | https://github.com/Utagai/spice/blob/00b2c9e80ef338f4daef7643d99e8c7a0750b57c/spice_api/spice.py#L262-L278 | train | Returns a MediumList object for the given user. |
camptocamp/Studio | studio/controllers/error.py | ErrorController.document | def document(self):
"""Render the error document"""
resp = request.environ.get('pylons.original_response')
content = literal(resp.body) or cgi.escape(request.GET.get('message'))
page = error_document_template % \
dict(prefix=request.environ.get('SCRIPT_NAME', ''),
... | python | def document(self):
"""Render the error document"""
resp = request.environ.get('pylons.original_response')
content = literal(resp.body) or cgi.escape(request.GET.get('message'))
page = error_document_template % \
dict(prefix=request.environ.get('SCRIPT_NAME', ''),
... | [
"def",
"document",
"(",
"self",
")",
":",
"resp",
"=",
"request",
".",
"environ",
".",
"get",
"(",
"'pylons.original_response'",
")",
"content",
"=",
"literal",
"(",
"resp",
".",
"body",
")",
"or",
"cgi",
".",
"escape",
"(",
"request",
".",
"GET",
".",... | Render the error document | [
"Render",
"the",
"error",
"document"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/error.py#L41-L49 | train | Render the error document |
camptocamp/Studio | studio/controllers/error.py | ErrorController._serve_file | def _serve_file(self, path):
"""Call Paste's FileApp (a WSGI application) to serve the file
at the specified path
"""
static = PkgResourcesParser('pylons', 'pylons')
request.environ['PATH_INFO'] = '/%s' % path
return static(request.environ, self.start_response) | python | def _serve_file(self, path):
"""Call Paste's FileApp (a WSGI application) to serve the file
at the specified path
"""
static = PkgResourcesParser('pylons', 'pylons')
request.environ['PATH_INFO'] = '/%s' % path
return static(request.environ, self.start_response) | [
"def",
"_serve_file",
"(",
"self",
",",
"path",
")",
":",
"static",
"=",
"PkgResourcesParser",
"(",
"'pylons'",
",",
"'pylons'",
")",
"request",
".",
"environ",
"[",
"'PATH_INFO'",
"]",
"=",
"'/%s'",
"%",
"path",
"return",
"static",
"(",
"request",
".",
... | Call Paste's FileApp (a WSGI application) to serve the file
at the specified path | [
"Call",
"Paste",
"s",
"FileApp",
"(",
"a",
"WSGI",
"application",
")",
"to",
"serve",
"the",
"file",
"at",
"the",
"specified",
"path"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/error.py#L59-L65 | train | Serve the file at the specified path |
camptocamp/Studio | studio/lib/helpers.py | gen_mapname | def gen_mapname():
""" Generate a uniq mapfile pathname. """
filepath = None
while (filepath is None) or (os.path.exists(os.path.join(config['mapfiles_dir'], filepath))):
filepath = '%s.map' % _gen_string()
return filepath | python | def gen_mapname():
""" Generate a uniq mapfile pathname. """
filepath = None
while (filepath is None) or (os.path.exists(os.path.join(config['mapfiles_dir'], filepath))):
filepath = '%s.map' % _gen_string()
return filepath | [
"def",
"gen_mapname",
"(",
")",
":",
"filepath",
"=",
"None",
"while",
"(",
"filepath",
"is",
"None",
")",
"or",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"config",
"[",
"'mapfiles_dir'",
"]",
",",
"filepath",
... | Generate a uniq mapfile pathname. | [
"Generate",
"a",
"uniq",
"mapfile",
"pathname",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/helpers.py#L39-L44 | train | Generate a uniq mapfile pathname. |
camptocamp/Studio | studio/config/installer.py | StudioInstaller.config_content | def config_content(self, command, vars):
"""
Called by ``self.write_config``, this returns the text content
for the config file, given the provided variables.
"""
settable_vars = [
var('db_url', 'Database url for sqlite, postgres or mysql',
de... | python | def config_content(self, command, vars):
"""
Called by ``self.write_config``, this returns the text content
for the config file, given the provided variables.
"""
settable_vars = [
var('db_url', 'Database url for sqlite, postgres or mysql',
de... | [
"def",
"config_content",
"(",
"self",
",",
"command",
",",
"vars",
")",
":",
"settable_vars",
"=",
"[",
"var",
"(",
"'db_url'",
",",
"'Database url for sqlite, postgres or mysql'",
",",
"default",
"=",
"'sqlite:///%(here)s/studio.db'",
")",
",",
"var",
"(",
"'ms_u... | Called by ``self.write_config``, this returns the text content
for the config file, given the provided variables. | [
"Called",
"by",
"self",
".",
"write_config",
"this",
"returns",
"the",
"text",
"content",
"for",
"the",
"config",
"file",
"given",
"the",
"provided",
"variables",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/config/installer.py#L29-L55 | train | Called by self. write_config this returns the text content for the config file given the variables. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField._resolve_definitions | def _resolve_definitions(self, schema, definitions):
"""Interpolates definitions from the top-level definitions key into the
schema. This is performed in a cut-down way similar to JSON schema.
"""
if not definitions:
return schema
if not isinstance(schema, dict):
... | python | def _resolve_definitions(self, schema, definitions):
"""Interpolates definitions from the top-level definitions key into the
schema. This is performed in a cut-down way similar to JSON schema.
"""
if not definitions:
return schema
if not isinstance(schema, dict):
... | [
"def",
"_resolve_definitions",
"(",
"self",
",",
"schema",
",",
"definitions",
")",
":",
"if",
"not",
"definitions",
":",
"return",
"schema",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"return",
"schema",
"ref",
"=",
"schema",
".",
... | Interpolates definitions from the top-level definitions key into the
schema. This is performed in a cut-down way similar to JSON schema. | [
"Interpolates",
"definitions",
"from",
"the",
"top",
"-",
"level",
"definitions",
"key",
"into",
"the",
"schema",
".",
"This",
"is",
"performed",
"in",
"a",
"cut",
"-",
"down",
"way",
"similar",
"to",
"JSON",
"schema",
"."
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L181-L207 | train | Interpolates definitions from the top - level definitions key into the top - level schema key. This is performed in a cut - down way similar to JSON schema. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField._get_serializer | def _get_serializer(self, _type):
"""Gets a serializer for a particular type. For primitives, returns the
serializer from the module-level serializers.
For arrays and objects, uses the special _get_T_serializer methods to
build the encoders and decoders.
"""
if _type in _... | python | def _get_serializer(self, _type):
"""Gets a serializer for a particular type. For primitives, returns the
serializer from the module-level serializers.
For arrays and objects, uses the special _get_T_serializer methods to
build the encoders and decoders.
"""
if _type in _... | [
"def",
"_get_serializer",
"(",
"self",
",",
"_type",
")",
":",
"if",
"_type",
"in",
"_serializers",
":",
"# _serializers is module level",
"return",
"_serializers",
"[",
"_type",
"]",
"# array and object are special types",
"elif",
"_type",
"==",
"'array'",
":",
"re... | Gets a serializer for a particular type. For primitives, returns the
serializer from the module-level serializers.
For arrays and objects, uses the special _get_T_serializer methods to
build the encoders and decoders. | [
"Gets",
"a",
"serializer",
"for",
"a",
"particular",
"type",
".",
"For",
"primitives",
"returns",
"the",
"serializer",
"from",
"the",
"module",
"-",
"level",
"serializers",
".",
"For",
"arrays",
"and",
"objects",
"uses",
"the",
"special",
"_get_T_serializer",
... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L209-L223 | train | Gets a serializer for a particular type. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField._get_array_serializer | def _get_array_serializer(self):
"""Gets the encoder and decoder for an array. Uses the 'items' key to
build the encoders and decoders for the specified type.
"""
if not self._items:
raise ValueError('Must specify \'items\' for \'array\' type')
field = SchemaField(se... | python | def _get_array_serializer(self):
"""Gets the encoder and decoder for an array. Uses the 'items' key to
build the encoders and decoders for the specified type.
"""
if not self._items:
raise ValueError('Must specify \'items\' for \'array\' type')
field = SchemaField(se... | [
"def",
"_get_array_serializer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_items",
":",
"raise",
"ValueError",
"(",
"'Must specify \\'items\\' for \\'array\\' type'",
")",
"field",
"=",
"SchemaField",
"(",
"self",
".",
"_items",
")",
"def",
"encode",
"("... | Gets the encoder and decoder for an array. Uses the 'items' key to
build the encoders and decoders for the specified type. | [
"Gets",
"the",
"encoder",
"and",
"decoder",
"for",
"an",
"array",
".",
"Uses",
"the",
"items",
"key",
"to",
"build",
"the",
"encoders",
"and",
"decoders",
"for",
"the",
"specified",
"type",
"."
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L225-L243 | train | Gets the encoder and decoder functions for an array. Uses the items key to
build the encoders and decoders for the specified type. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField._get_object_serializer | def _get_object_serializer(self):
"""Gets the encoder and decoder for an object. Uses the 'properties'
key to build the encoders and decoders for the specified types,
mapping them to their specified names and parameters. These include:
* default (Default: None)
* require... | python | def _get_object_serializer(self):
"""Gets the encoder and decoder for an object. Uses the 'properties'
key to build the encoders and decoders for the specified types,
mapping them to their specified names and parameters. These include:
* default (Default: None)
* require... | [
"def",
"_get_object_serializer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_properties",
":",
"raise",
"ValueError",
"(",
"'Must specify \\'properties\\' for \\'object\\' type'",
")",
"fields",
"=",
"{",
"}",
"for",
"(",
"name",
",",
"definition",
")",
"... | Gets the encoder and decoder for an object. Uses the 'properties'
key to build the encoders and decoders for the specified types,
mapping them to their specified names and parameters. These include:
* default (Default: None)
* required (Default: true)
* readonly (Def... | [
"Gets",
"the",
"encoder",
"and",
"decoder",
"for",
"an",
"object",
".",
"Uses",
"the",
"properties",
"key",
"to",
"build",
"the",
"encoders",
"and",
"decoders",
"for",
"the",
"specified",
"types",
"mapping",
"them",
"to",
"their",
"specified",
"names",
"and"... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L245-L358 | train | Gets the encoder and decoder for an object. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField.encode | def encode(self, value):
"""The encoder for this schema.
Tries each encoder in order of the types specified for this schema.
"""
if value is None and self._default is not None:
value = self._default
for encoder in self._encoders:
try:
retu... | python | def encode(self, value):
"""The encoder for this schema.
Tries each encoder in order of the types specified for this schema.
"""
if value is None and self._default is not None:
value = self._default
for encoder in self._encoders:
try:
retu... | [
"def",
"encode",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
"and",
"self",
".",
"_default",
"is",
"not",
"None",
":",
"value",
"=",
"self",
".",
"_default",
"for",
"encoder",
"in",
"self",
".",
"_encoders",
":",
"try",
":",
"... | The encoder for this schema.
Tries each encoder in order of the types specified for this schema. | [
"The",
"encoder",
"for",
"this",
"schema",
".",
"Tries",
"each",
"encoder",
"in",
"order",
"of",
"the",
"types",
"specified",
"for",
"this",
"schema",
"."
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L360-L374 | train | Encodes the value into a value in the appropriate encoder for this schema. |
jpgxs/pyopsview | pyopsview/schema.py | SchemaField.decode | def decode(self, value):
"""The decoder for this schema.
Tries each decoder in order of the types specified for this schema.
"""
# Use the default value unless the field accepts None types
has_null_encoder = bool(encode_decode_null in self._decoders)
if value is None and... | python | def decode(self, value):
"""The decoder for this schema.
Tries each decoder in order of the types specified for this schema.
"""
# Use the default value unless the field accepts None types
has_null_encoder = bool(encode_decode_null in self._decoders)
if value is None and... | [
"def",
"decode",
"(",
"self",
",",
"value",
")",
":",
"# Use the default value unless the field accepts None types",
"has_null_encoder",
"=",
"bool",
"(",
"encode_decode_null",
"in",
"self",
".",
"_decoders",
")",
"if",
"value",
"is",
"None",
"and",
"self",
".",
"... | The decoder for this schema.
Tries each decoder in order of the types specified for this schema. | [
"The",
"decoder",
"for",
"this",
"schema",
".",
"Tries",
"each",
"decoder",
"in",
"order",
"of",
"the",
"types",
"specified",
"for",
"this",
"schema",
"."
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/schema.py#L376-L393 | train | The decoder for this schema. |
pjamesjoyce/lcopt | lcopt/bw2_import.py | hierarchy_pos | def hierarchy_pos(links, root, width=1., vert_gap=0.2, vert_loc=0, xcenter=0.5, pos=None, parent=None, min_dx=0.03):
'''If there is a cycle that is reachable from root, then this will see infinite recursion.
G: the graph
root: the root node of current branch
width: horizontal space allocated fo... | python | def hierarchy_pos(links, root, width=1., vert_gap=0.2, vert_loc=0, xcenter=0.5, pos=None, parent=None, min_dx=0.03):
'''If there is a cycle that is reachable from root, then this will see infinite recursion.
G: the graph
root: the root node of current branch
width: horizontal space allocated fo... | [
"def",
"hierarchy_pos",
"(",
"links",
",",
"root",
",",
"width",
"=",
"1.",
",",
"vert_gap",
"=",
"0.2",
",",
"vert_loc",
"=",
"0",
",",
"xcenter",
"=",
"0.5",
",",
"pos",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"min_dx",
"=",
"0.03",
")",
... | If there is a cycle that is reachable from root, then this will see infinite recursion.
G: the graph
root: the root node of current branch
width: horizontal space allocated for this branch - avoids overlap with other branches
vert_gap: gap between levels of hierarchy
vert_loc: vertica... | [
"If",
"there",
"is",
"a",
"cycle",
"that",
"is",
"reachable",
"from",
"root",
"then",
"this",
"will",
"see",
"infinite",
"recursion",
".",
"G",
":",
"the",
"graph",
"root",
":",
"the",
"root",
"node",
"of",
"current",
"branch",
"width",
":",
"horizontal"... | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/bw2_import.py#L60-L87 | train | Returns a dict that represents the position of the root node in the hierarchy. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | _fail_early | def _fail_early(message, **kwds):
"""The module arguments are dynamically generated based on the Opsview
version. This means that fail_json isn't available until after the module
has been properly initialized and the schemas have been loaded.
"""
import json
output = dict(kwds)
output.updat... | python | def _fail_early(message, **kwds):
"""The module arguments are dynamically generated based on the Opsview
version. This means that fail_json isn't available until after the module
has been properly initialized and the schemas have been loaded.
"""
import json
output = dict(kwds)
output.updat... | [
"def",
"_fail_early",
"(",
"message",
",",
"*",
"*",
"kwds",
")",
":",
"import",
"json",
"output",
"=",
"dict",
"(",
"kwds",
")",
"output",
".",
"update",
"(",
"{",
"'msg'",
":",
"message",
",",
"'failed'",
":",
"True",
",",
"}",
")",
"print",
"(",... | The module arguments are dynamically generated based on the Opsview
version. This means that fail_json isn't available until after the module
has been properly initialized and the schemas have been loaded. | [
"The",
"module",
"arguments",
"are",
"dynamically",
"generated",
"based",
"on",
"the",
"Opsview",
"version",
".",
"This",
"means",
"that",
"fail_json",
"isn",
"t",
"available",
"until",
"after",
"the",
"module",
"has",
"been",
"properly",
"initialized",
"and",
... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L14-L27 | train | This function is used to fail the Opsview
module. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | _compare_recursive | def _compare_recursive(old, new):
"""Deep comparison between objects; assumes that `new` contains
user defined parameters so only keys which exist in `new` will be
compared. Returns `True` if they differ. Else, `False`.
"""
if isinstance(new, dict):
for key in six.iterkeys(new):
... | python | def _compare_recursive(old, new):
"""Deep comparison between objects; assumes that `new` contains
user defined parameters so only keys which exist in `new` will be
compared. Returns `True` if they differ. Else, `False`.
"""
if isinstance(new, dict):
for key in six.iterkeys(new):
... | [
"def",
"_compare_recursive",
"(",
"old",
",",
"new",
")",
":",
"if",
"isinstance",
"(",
"new",
",",
"dict",
")",
":",
"for",
"key",
"in",
"six",
".",
"iterkeys",
"(",
"new",
")",
":",
"try",
":",
"if",
"_compare_recursive",
"(",
"old",
"[",
"key",
... | Deep comparison between objects; assumes that `new` contains
user defined parameters so only keys which exist in `new` will be
compared. Returns `True` if they differ. Else, `False`. | [
"Deep",
"comparison",
"between",
"objects",
";",
"assumes",
"that",
"new",
"contains",
"user",
"defined",
"parameters",
"so",
"only",
"keys",
"which",
"exist",
"in",
"new",
"will",
"be",
"compared",
".",
"Returns",
"True",
"if",
"they",
"differ",
".",
"Else"... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L30-L53 | train | Deep comparison between objects ; assumes that new contains
user defined parameters so only keys which exist in old will be compared. Returns True if they differ otherwise False. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | OpsviewAnsibleModuleAdvanced._pre_init | def _pre_init(self, object_type):
"""To know the arguments, they must be loaded from the schema. This is
only possible once the client has been initialized (otherwise the
opsview version is not known). This function gathers the connection
arguments before the module is initialized so tha... | python | def _pre_init(self, object_type):
"""To know the arguments, they must be loaded from the schema. This is
only possible once the client has been initialized (otherwise the
opsview version is not known). This function gathers the connection
arguments before the module is initialized so tha... | [
"def",
"_pre_init",
"(",
"self",
",",
"object_type",
")",
":",
"# Internal Ansible function to load the arguments",
"pre_params",
"=",
"_load_params",
"(",
")",
"login_params",
"=",
"{",
"}",
"for",
"key",
"in",
"six",
".",
"iterkeys",
"(",
"self",
".",
"login_a... | To know the arguments, they must be loaded from the schema. This is
only possible once the client has been initialized (otherwise the
opsview version is not known). This function gathers the connection
arguments before the module is initialized so that the argument spec
can be set.
... | [
"To",
"know",
"the",
"arguments",
"they",
"must",
"be",
"loaded",
"from",
"the",
"schema",
".",
"This",
"is",
"only",
"possible",
"once",
"the",
"client",
"has",
"been",
"initialized",
"(",
"otherwise",
"the",
"opsview",
"version",
"is",
"not",
"known",
")... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L112-L143 | train | Internal method that loads the connection parameters and creates the manager and the argument spec. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | OpsviewAnsibleModuleAdvanced._build_argspec | def _build_argspec(self):
"""Builds the ansible argument spec using the fields from the schema
definition. It's the caller's responsibility to add any arguments which
are not defined in the schema (e.g. login parameters)
"""
fields = self.manager._schema.fields
argspec = ... | python | def _build_argspec(self):
"""Builds the ansible argument spec using the fields from the schema
definition. It's the caller's responsibility to add any arguments which
are not defined in the schema (e.g. login parameters)
"""
fields = self.manager._schema.fields
argspec = ... | [
"def",
"_build_argspec",
"(",
"self",
")",
":",
"fields",
"=",
"self",
".",
"manager",
".",
"_schema",
".",
"fields",
"argspec",
"=",
"{",
"}",
"for",
"(",
"field_name",
",",
"field",
")",
"in",
"six",
".",
"iteritems",
"(",
"fields",
")",
":",
"# Re... | Builds the ansible argument spec using the fields from the schema
definition. It's the caller's responsibility to add any arguments which
are not defined in the schema (e.g. login parameters) | [
"Builds",
"the",
"ansible",
"argument",
"spec",
"using",
"the",
"fields",
"from",
"the",
"schema",
"definition",
".",
"It",
"s",
"the",
"caller",
"s",
"responsibility",
"to",
"add",
"any",
"arguments",
"which",
"are",
"not",
"defined",
"in",
"the",
"schema",... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L172-L196 | train | Builds the ansible argument spec using the fields from the schema that are defined in the API. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | OpsviewAnsibleModuleAdvanced.get_object_params | def get_object_params(self):
"""Returns all of the parameters which should be used to create/update
an object.
* Omits any parameters not defined in the schema
* Omits any null parameters if they were not explicitly specified
"""
return {name: value for (name, value) in s... | python | def get_object_params(self):
"""Returns all of the parameters which should be used to create/update
an object.
* Omits any parameters not defined in the schema
* Omits any null parameters if they were not explicitly specified
"""
return {name: value for (name, value) in s... | [
"def",
"get_object_params",
"(",
"self",
")",
":",
"return",
"{",
"name",
":",
"value",
"for",
"(",
"name",
",",
"value",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"params",
")",
"if",
"(",
"name",
"not",
"in",
"self",
".",
"additional_ar... | Returns all of the parameters which should be used to create/update
an object.
* Omits any parameters not defined in the schema
* Omits any null parameters if they were not explicitly specified | [
"Returns",
"all",
"of",
"the",
"parameters",
"which",
"should",
"be",
"used",
"to",
"create",
"/",
"update",
"an",
"object",
".",
"*",
"Omits",
"any",
"parameters",
"not",
"defined",
"in",
"the",
"schema",
"*",
"Omits",
"any",
"null",
"parameters",
"if",
... | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L198-L207 | train | Returns all of the parameters that should be used to create or update a resource. |
jpgxs/pyopsview | pyopsview/ansible/module_utils/opsview.py | OpsviewAnsibleModuleAdvanced._requires_update | def _requires_update(self, old_object, new_object):
"""Checks whether the old object and new object differ; only checks
keys which exist in the new object
"""
old_encoded = self.manager._encode(old_object)
new_encoded = self.manager._encode(new_object)
return _compare_rec... | python | def _requires_update(self, old_object, new_object):
"""Checks whether the old object and new object differ; only checks
keys which exist in the new object
"""
old_encoded = self.manager._encode(old_object)
new_encoded = self.manager._encode(new_object)
return _compare_rec... | [
"def",
"_requires_update",
"(",
"self",
",",
"old_object",
",",
"new_object",
")",
":",
"old_encoded",
"=",
"self",
".",
"manager",
".",
"_encode",
"(",
"old_object",
")",
"new_encoded",
"=",
"self",
".",
"manager",
".",
"_encode",
"(",
"new_object",
")",
... | Checks whether the old object and new object differ; only checks
keys which exist in the new object | [
"Checks",
"whether",
"the",
"old",
"object",
"and",
"new",
"object",
"differ",
";",
"only",
"checks",
"keys",
"which",
"exist",
"in",
"the",
"new",
"object"
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/ansible/module_utils/opsview.py#L215-L221 | train | Checks whether the old object and new object are the same. |
cnschema/cdata | cdata/web.py | url2domain | def url2domain(url):
""" extract domain from url
"""
parsed_uri = urlparse.urlparse(url)
domain = '{uri.netloc}'.format(uri=parsed_uri)
domain = re.sub("^.+@", "", domain)
domain = re.sub(":.+$", "", domain)
return domain | python | def url2domain(url):
""" extract domain from url
"""
parsed_uri = urlparse.urlparse(url)
domain = '{uri.netloc}'.format(uri=parsed_uri)
domain = re.sub("^.+@", "", domain)
domain = re.sub(":.+$", "", domain)
return domain | [
"def",
"url2domain",
"(",
"url",
")",
":",
"parsed_uri",
"=",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
"domain",
"=",
"'{uri.netloc}'",
".",
"format",
"(",
"uri",
"=",
"parsed_uri",
")",
"domain",
"=",
"re",
".",
"sub",
"(",
"\"^.+@\"",
",",
"\"\"... | extract domain from url | [
"extract",
"domain",
"from",
"url"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/web.py#L20-L27 | train | extract domain from url |
camptocamp/Studio | studio/model/__init__.py | init_model | def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
if meta.Session is None:
sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine)
meta.engine = engine
meta.Session = orm.scoped_session(sm) | python | def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
if meta.Session is None:
sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine)
meta.engine = engine
meta.Session = orm.scoped_session(sm) | [
"def",
"init_model",
"(",
"engine",
")",
":",
"if",
"meta",
".",
"Session",
"is",
"None",
":",
"sm",
"=",
"orm",
".",
"sessionmaker",
"(",
"autoflush",
"=",
"True",
",",
"autocommit",
"=",
"False",
",",
"bind",
"=",
"engine",
")",
"meta",
".",
"engin... | Call me before using any of the tables or classes in the model | [
"Call",
"me",
"before",
"using",
"any",
"of",
"the",
"tables",
"or",
"classes",
"in",
"the",
"model"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/model/__init__.py#L32-L38 | train | Call me before using any of the tables or classes in the model |
unbit/davvy | davvy/__init__.py | register_prop | def register_prop(name, handler_get, handler_set):
"""
register a property handler
"""
global props_get, props_set
if handler_get:
props_get[name] = handler_get
if handler_set:
props_set[name] = handler_set | python | def register_prop(name, handler_get, handler_set):
"""
register a property handler
"""
global props_get, props_set
if handler_get:
props_get[name] = handler_get
if handler_set:
props_set[name] = handler_set | [
"def",
"register_prop",
"(",
"name",
",",
"handler_get",
",",
"handler_set",
")",
":",
"global",
"props_get",
",",
"props_set",
"if",
"handler_get",
":",
"props_get",
"[",
"name",
"]",
"=",
"handler_get",
"if",
"handler_set",
":",
"props_set",
"[",
"name",
"... | register a property handler | [
"register",
"a",
"property",
"handler"
] | d9cd95fba25dbc76d80955bbbe5ff9d7cf52268a | https://github.com/unbit/davvy/blob/d9cd95fba25dbc76d80955bbbe5ff9d7cf52268a/davvy/__init__.py#L9-L17 | train | register a property handler
|
unbit/davvy | davvy/__init__.py | retrieve_prop | def retrieve_prop(name):
"""
retrieve a property handler
"""
handler_get, handler_set = None, None
if name in props_get:
handler_get = props_get[name]
if name in props_set:
handler_set = props_set[name]
return (name, handler_get, handler_set) | python | def retrieve_prop(name):
"""
retrieve a property handler
"""
handler_get, handler_set = None, None
if name in props_get:
handler_get = props_get[name]
if name in props_set:
handler_set = props_set[name]
return (name, handler_get, handler_set) | [
"def",
"retrieve_prop",
"(",
"name",
")",
":",
"handler_get",
",",
"handler_set",
"=",
"None",
",",
"None",
"if",
"name",
"in",
"props_get",
":",
"handler_get",
"=",
"props_get",
"[",
"name",
"]",
"if",
"name",
"in",
"props_set",
":",
"handler_set",
"=",
... | retrieve a property handler | [
"retrieve",
"a",
"property",
"handler"
] | d9cd95fba25dbc76d80955bbbe5ff9d7cf52268a | https://github.com/unbit/davvy/blob/d9cd95fba25dbc76d80955bbbe5ff9d7cf52268a/davvy/__init__.py#L20-L31 | train | retrieve a property handler
|
Radi85/Comment | comment/api/views.py | CommentList.get_queryset | def get_queryset(self):
'''
Parameters are already validated in the QuerySetPermission
'''
model_type = self.request.GET.get("type")
pk = self.request.GET.get("id")
content_type_model = ContentType.objects.get(model=model_type.lower())
Model = content_type_model.m... | python | def get_queryset(self):
'''
Parameters are already validated in the QuerySetPermission
'''
model_type = self.request.GET.get("type")
pk = self.request.GET.get("id")
content_type_model = ContentType.objects.get(model=model_type.lower())
Model = content_type_model.m... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"model_type",
"=",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"\"type\"",
")",
"pk",
"=",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"\"id\"",
")",
"content_type_model",
"=",
"ContentTyp... | Parameters are already validated in the QuerySetPermission | [
"Parameters",
"are",
"already",
"validated",
"in",
"the",
"QuerySetPermission"
] | c3c46afe51228cd7ee4e04f5e6164fff1be3a5bc | https://github.com/Radi85/Comment/blob/c3c46afe51228cd7ee4e04f5e6164fff1be3a5bc/comment/api/views.py#L34-L43 | train | Returns a QuerySet of Comment objects for the current resource. |
camptocamp/Studio | studio/lib/archivefile.py | extractall | def extractall(archive, filename, dstdir):
""" extract zip or tar content to dstdir"""
if zipfile.is_zipfile(archive):
z = zipfile.ZipFile(archive)
for name in z.namelist():
targetname = name
# directories ends with '/' (on Windows as well)
if targetname.... | python | def extractall(archive, filename, dstdir):
""" extract zip or tar content to dstdir"""
if zipfile.is_zipfile(archive):
z = zipfile.ZipFile(archive)
for name in z.namelist():
targetname = name
# directories ends with '/' (on Windows as well)
if targetname.... | [
"def",
"extractall",
"(",
"archive",
",",
"filename",
",",
"dstdir",
")",
":",
"if",
"zipfile",
".",
"is_zipfile",
"(",
"archive",
")",
":",
"z",
"=",
"zipfile",
".",
"ZipFile",
"(",
"archive",
")",
"for",
"name",
"in",
"z",
".",
"namelist",
"(",
")"... | extract zip or tar content to dstdir | [
"extract",
"zip",
"or",
"tar",
"content",
"to",
"dstdir"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/archivefile.py#L22-L55 | train | extracts a zip or tar file to dstdir |
camptocamp/Studio | studio/websetup.py | setup_app | def setup_app(command, conf, vars):
"""Place any commands to setup studio here"""
load_environment(conf.global_conf, conf.local_conf)
# Merge and minify JavaScript code
input_file = config['js_tmpl']
public_dir = config['pylons.paths']['static_files']
output_file = os.path.join(public_dir, 'js'... | python | def setup_app(command, conf, vars):
"""Place any commands to setup studio here"""
load_environment(conf.global_conf, conf.local_conf)
# Merge and minify JavaScript code
input_file = config['js_tmpl']
public_dir = config['pylons.paths']['static_files']
output_file = os.path.join(public_dir, 'js'... | [
"def",
"setup_app",
"(",
"command",
",",
"conf",
",",
"vars",
")",
":",
"load_environment",
"(",
"conf",
".",
"global_conf",
",",
"conf",
".",
"local_conf",
")",
"# Merge and minify JavaScript code",
"input_file",
"=",
"config",
"[",
"'js_tmpl'",
"]",
"public_di... | Place any commands to setup studio here | [
"Place",
"any",
"commands",
"to",
"setup",
"studio",
"here"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/websetup.py#L34-L197 | train | Setup the application |
camptocamp/Studio | studio/websetup.py | _merge_js | def _merge_js(input_file, input_dir, output_file):
""" Call into the merge_js module to merge the js files
and minify the code. """
from studio.lib.buildjs import merge_js
merge_js.main(input_file, input_dir, output_file) | python | def _merge_js(input_file, input_dir, output_file):
""" Call into the merge_js module to merge the js files
and minify the code. """
from studio.lib.buildjs import merge_js
merge_js.main(input_file, input_dir, output_file) | [
"def",
"_merge_js",
"(",
"input_file",
",",
"input_dir",
",",
"output_file",
")",
":",
"from",
"studio",
".",
"lib",
".",
"buildjs",
"import",
"merge_js",
"merge_js",
".",
"main",
"(",
"input_file",
",",
"input_dir",
",",
"output_file",
")"
] | Call into the merge_js module to merge the js files
and minify the code. | [
"Call",
"into",
"the",
"merge_js",
"module",
"to",
"merge",
"the",
"js",
"files",
"and",
"minify",
"the",
"code",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/websetup.py#L208-L212 | train | Merge the js files
and minify the code. |
pjamesjoyce/lcopt | lcopt/utils.py | lcopt_bw2_setup | def lcopt_bw2_setup(ecospold_path, overwrite=False, db_name=None): # pragma: no cover
"""
Utility function to set up brightway2 to work correctly with lcopt.
It requires the path to the ecospold files containing the Ecoinvent 3.3 cutoff database.
If you don't have these files, log into `ecoinvent.or... | python | def lcopt_bw2_setup(ecospold_path, overwrite=False, db_name=None): # pragma: no cover
"""
Utility function to set up brightway2 to work correctly with lcopt.
It requires the path to the ecospold files containing the Ecoinvent 3.3 cutoff database.
If you don't have these files, log into `ecoinvent.or... | [
"def",
"lcopt_bw2_setup",
"(",
"ecospold_path",
",",
"overwrite",
"=",
"False",
",",
"db_name",
"=",
"None",
")",
":",
"# pragma: no cover",
"default_ei_name",
"=",
"\"Ecoinvent3_3_cutoff\"",
"if",
"db_name",
"is",
"None",
":",
"db_name",
"=",
"DEFAULT_PROJECT_STEM"... | Utility function to set up brightway2 to work correctly with lcopt.
It requires the path to the ecospold files containing the Ecoinvent 3.3 cutoff database.
If you don't have these files, log into `ecoinvent.org <http://www.ecoinvent.org/login-databases.html>`_ and go to the Files tab
Download the file ... | [
"Utility",
"function",
"to",
"set",
"up",
"brightway2",
"to",
"work",
"correctly",
"with",
"lcopt",
"."
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/utils.py#L38-L77 | train | This function sets up brightway2 to work correctly with lcopt. |
pjamesjoyce/lcopt | lcopt/utils.py | lcopt_bw2_autosetup | def lcopt_bw2_autosetup(ei_username=None, ei_password=None, write_config=None, ecoinvent_version='3.3', ecoinvent_system_model = "cutoff", overwrite=False):
"""
Utility function to automatically set up brightway2 to work correctly with lcopt.
It requires a valid username and password to login to the eco... | python | def lcopt_bw2_autosetup(ei_username=None, ei_password=None, write_config=None, ecoinvent_version='3.3', ecoinvent_system_model = "cutoff", overwrite=False):
"""
Utility function to automatically set up brightway2 to work correctly with lcopt.
It requires a valid username and password to login to the eco... | [
"def",
"lcopt_bw2_autosetup",
"(",
"ei_username",
"=",
"None",
",",
"ei_password",
"=",
"None",
",",
"write_config",
"=",
"None",
",",
"ecoinvent_version",
"=",
"'3.3'",
",",
"ecoinvent_system_model",
"=",
"\"cutoff\"",
",",
"overwrite",
"=",
"False",
")",
":",
... | Utility function to automatically set up brightway2 to work correctly with lcopt.
It requires a valid username and password to login to the ecoinvent website.
These can be entered directly into the function using the keyword arguments `ei_username` and `ei_password` or entered interactively by using no argume... | [
"Utility",
"function",
"to",
"automatically",
"set",
"up",
"brightway2",
"to",
"work",
"correctly",
"with",
"lcopt",
"."
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/utils.py#L123-L228 | train | Auto - set up brightway2 for a given ecoinvent database. |
pjamesjoyce/lcopt | lcopt/utils.py | forwast_autodownload | def forwast_autodownload(FORWAST_URL):
"""
Autodownloader for forwast database package for brightway. Used by `lcopt_bw2_forwast_setup` to get the database data. Not designed to be used on its own
"""
dirpath = tempfile.mkdtemp()
r = requests.get(FORWAST_URL)
z = zipfile.ZipFile(io.BytesI... | python | def forwast_autodownload(FORWAST_URL):
"""
Autodownloader for forwast database package for brightway. Used by `lcopt_bw2_forwast_setup` to get the database data. Not designed to be used on its own
"""
dirpath = tempfile.mkdtemp()
r = requests.get(FORWAST_URL)
z = zipfile.ZipFile(io.BytesI... | [
"def",
"forwast_autodownload",
"(",
"FORWAST_URL",
")",
":",
"dirpath",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"r",
"=",
"requests",
".",
"get",
"(",
"FORWAST_URL",
")",
"z",
"=",
"zipfile",
".",
"ZipFile",
"(",
"io",
".",
"BytesIO",
"(",
"r",
".",... | Autodownloader for forwast database package for brightway. Used by `lcopt_bw2_forwast_setup` to get the database data. Not designed to be used on its own | [
"Autodownloader",
"for",
"forwast",
"database",
"package",
"for",
"brightway",
".",
"Used",
"by",
"lcopt_bw2_forwast_setup",
"to",
"get",
"the",
"database",
"data",
".",
"Not",
"designed",
"to",
"be",
"used",
"on",
"its",
"own"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/utils.py#L288-L297 | train | Autodownloader for forwast database package for brightway. |
pjamesjoyce/lcopt | lcopt/utils.py | lcopt_bw2_forwast_setup | def lcopt_bw2_forwast_setup(use_autodownload=True, forwast_path=None, db_name=FORWAST_PROJECT_NAME, overwrite=False):
"""
Utility function to set up brightway2 to work correctly with lcopt using the FORWAST database instead of ecoinvent
By default it'll try and download the forwast database as a .... | python | def lcopt_bw2_forwast_setup(use_autodownload=True, forwast_path=None, db_name=FORWAST_PROJECT_NAME, overwrite=False):
"""
Utility function to set up brightway2 to work correctly with lcopt using the FORWAST database instead of ecoinvent
By default it'll try and download the forwast database as a .... | [
"def",
"lcopt_bw2_forwast_setup",
"(",
"use_autodownload",
"=",
"True",
",",
"forwast_path",
"=",
"None",
",",
"db_name",
"=",
"FORWAST_PROJECT_NAME",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"use_autodownload",
":",
"forwast_filepath",
"=",
"forwast_autodown... | Utility function to set up brightway2 to work correctly with lcopt using the FORWAST database instead of ecoinvent
By default it'll try and download the forwast database as a .bw2package file from lca-net
If you've downloaded the forwast .bw2package file already you can set use_autodownload=False and forwast_... | [
"Utility",
"function",
"to",
"set",
"up",
"brightway2",
"to",
"work",
"correctly",
"with",
"lcopt",
"using",
"the",
"FORWAST",
"database",
"instead",
"of",
"ecoinvent"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/utils.py#L300-L350 | train | Utility function to set up brightway2 forwast database |
MoseleyBioinformaticsLab/mwtab | mwtab/validator.py | _validate_samples_factors | def _validate_samples_factors(mwtabfile, validate_samples=True, validate_factors=True):
"""Validate ``Samples`` and ``Factors`` identifiers across the file.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
:return: None
:rtype: :py:obj:... | python | def _validate_samples_factors(mwtabfile, validate_samples=True, validate_factors=True):
"""Validate ``Samples`` and ``Factors`` identifiers across the file.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
:return: None
:rtype: :py:obj:... | [
"def",
"_validate_samples_factors",
"(",
"mwtabfile",
",",
"validate_samples",
"=",
"True",
",",
"validate_factors",
"=",
"True",
")",
":",
"from_subject_samples",
"=",
"{",
"i",
"[",
"\"local_sample_id\"",
"]",
"for",
"i",
"in",
"mwtabfile",
"[",
"\"SUBJECT_SAMPL... | Validate ``Samples`` and ``Factors`` identifiers across the file.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
:return: None
:rtype: :py:obj:`None` | [
"Validate",
"Samples",
"and",
"Factors",
"identifiers",
"across",
"the",
"file",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/validator.py#L19-L44 | train | Validate the Samples and Factor identifiers across the file. |
MoseleyBioinformaticsLab/mwtab | mwtab/validator.py | validate_file | def validate_file(mwtabfile, section_schema_mapping=section_schema_mapping, validate_samples=True, validate_factors=True):
"""Validate entire ``mwTab`` formatted file one section at a time.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
... | python | def validate_file(mwtabfile, section_schema_mapping=section_schema_mapping, validate_samples=True, validate_factors=True):
"""Validate entire ``mwTab`` formatted file one section at a time.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
... | [
"def",
"validate_file",
"(",
"mwtabfile",
",",
"section_schema_mapping",
"=",
"section_schema_mapping",
",",
"validate_samples",
"=",
"True",
",",
"validate_factors",
"=",
"True",
")",
":",
"validated_mwtabfile",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"_validate_... | Validate entire ``mwTab`` formatted file one section at a time.
:param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`.
:type mwtabfile: :class:`~mwtab.mwtab.MWTabFile`
:param dict section_schema_mapping: Dictionary that provides mapping between section name and schema definition.
:param val... | [
"Validate",
"entire",
"mwTab",
"formatted",
"file",
"one",
"section",
"at",
"a",
"time",
".",
":",
"param",
"mwtabfile",
":",
"Instance",
"of",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
".",
":",
"type",
"mwtabfile",
":",
":",
"class",... | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/validator.py#L58-L86 | train | Validate entire MWTab formatted file. |
cocaine/cocaine-tools | cocaine/proxy/__init__.py | Daemon.daemonize | def daemonize(self):
"""Double-fork magic"""
if self.userid:
uid = pwd.getpwnam(self.userid).pw_uid
os.seteuid(uid)
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError as err:
sys.stderr.write("First fork... | python | def daemonize(self):
"""Double-fork magic"""
if self.userid:
uid = pwd.getpwnam(self.userid).pw_uid
os.seteuid(uid)
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError as err:
sys.stderr.write("First fork... | [
"def",
"daemonize",
"(",
"self",
")",
":",
"if",
"self",
".",
"userid",
":",
"uid",
"=",
"pwd",
".",
"getpwnam",
"(",
"self",
".",
"userid",
")",
".",
"pw_uid",
"os",
".",
"seteuid",
"(",
"uid",
")",
"try",
":",
"pid",
"=",
"os",
".",
"fork",
"... | Double-fork magic | [
"Double",
"-",
"fork",
"magic"
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/proxy/__init__.py#L38-L77 | train | Double - fork magic |
cocaine/cocaine-tools | cocaine/proxy/__init__.py | Daemon.start | def start(self, *args):
"""
Start the daemon
"""
if os.path.exists(self.pidfile):
msg = "pidfile exists. Exit.\n"
sys.stderr.write(msg % self.pidfile)
sys.exit(1)
self.daemonize()
self.run(*args) | python | def start(self, *args):
"""
Start the daemon
"""
if os.path.exists(self.pidfile):
msg = "pidfile exists. Exit.\n"
sys.stderr.write(msg % self.pidfile)
sys.exit(1)
self.daemonize()
self.run(*args) | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"pidfile",
")",
":",
"msg",
"=",
"\"pidfile exists. Exit.\\n\"",
"sys",
".",
"stderr",
".",
"write",
"(",
"msg",
"%",
"self",
".",
"p... | Start the daemon | [
"Start",
"the",
"daemon"
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/proxy/__init__.py#L85-L96 | train | Start the daemon. |
camptocamp/Studio | studio/controllers/datasources.py | DatasourcesController.index | def index(self, datastore_id=None):
""" GET /datastores/{datastore_id}/datasources: Get all
datasources within a given datastore."""
datastore = self._get_datastore_by_id(datastore_id)
if datastore is None:
abort(404)
discovery_result = discover_datasources(datast... | python | def index(self, datastore_id=None):
""" GET /datastores/{datastore_id}/datasources: Get all
datasources within a given datastore."""
datastore = self._get_datastore_by_id(datastore_id)
if datastore is None:
abort(404)
discovery_result = discover_datasources(datast... | [
"def",
"index",
"(",
"self",
",",
"datastore_id",
"=",
"None",
")",
":",
"datastore",
"=",
"self",
".",
"_get_datastore_by_id",
"(",
"datastore_id",
")",
"if",
"datastore",
"is",
"None",
":",
"abort",
"(",
"404",
")",
"discovery_result",
"=",
"discover_datas... | GET /datastores/{datastore_id}/datasources: Get all
datasources within a given datastore. | [
"GET",
"/",
"datastores",
"/",
"{",
"datastore_id",
"}",
"/",
"datasources",
":",
"Get",
"all",
"datasources",
"within",
"a",
"given",
"datastore",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datasources.py#L49-L59 | train | GET / datastores/{datastore_id}/datasources : Get all
datasources within a given datastore. |
camptocamp/Studio | studio/controllers/datasources.py | DatasourcesController.create | def create(self, datastore_id=None):
"""POST /datastores/{datastore_id}/datasources: Create a new
datasource by file upload."""
datastore = self._get_ogrdatastore_by_id(datastore_id)
if not datastore:
abort(404)
# only "directory" datastores are supported at this po... | python | def create(self, datastore_id=None):
"""POST /datastores/{datastore_id}/datasources: Create a new
datasource by file upload."""
datastore = self._get_ogrdatastore_by_id(datastore_id)
if not datastore:
abort(404)
# only "directory" datastores are supported at this po... | [
"def",
"create",
"(",
"self",
",",
"datastore_id",
"=",
"None",
")",
":",
"datastore",
"=",
"self",
".",
"_get_ogrdatastore_by_id",
"(",
"datastore_id",
")",
"if",
"not",
"datastore",
":",
"abort",
"(",
"404",
")",
"# only \"directory\" datastores are supported at... | POST /datastores/{datastore_id}/datasources: Create a new
datasource by file upload. | [
"POST",
"/",
"datastores",
"/",
"{",
"datastore_id",
"}",
"/",
"datasources",
":",
"Create",
"a",
"new",
"datasource",
"by",
"file",
"upload",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datasources.py#L62-L95 | train | POST a new entry in the datastores folder. |
camptocamp/Studio | studio/controllers/datasources.py | DatasourcesController.showcolumns | def showcolumns(self, datastore_id=None, datasource_id=None):
""" GET /datastores/{datastore_id}/datasources/{datasource_id}/columns: Get a
specific datasource's columns within a given datastore. """
datastore = self._get_datastore_by_id(datastore_id)
if datastore is None:
... | python | def showcolumns(self, datastore_id=None, datasource_id=None):
""" GET /datastores/{datastore_id}/datasources/{datasource_id}/columns: Get a
specific datasource's columns within a given datastore. """
datastore = self._get_datastore_by_id(datastore_id)
if datastore is None:
... | [
"def",
"showcolumns",
"(",
"self",
",",
"datastore_id",
"=",
"None",
",",
"datasource_id",
"=",
"None",
")",
":",
"datastore",
"=",
"self",
".",
"_get_datastore_by_id",
"(",
"datastore_id",
")",
"if",
"datastore",
"is",
"None",
":",
"abort",
"(",
"404",
")... | GET /datastores/{datastore_id}/datasources/{datasource_id}/columns: Get a
specific datasource's columns within a given datastore. | [
"GET",
"/",
"datastores",
"/",
"{",
"datastore_id",
"}",
"/",
"datasources",
"/",
"{",
"datasource_id",
"}",
"/",
"columns",
":",
"Get",
"a",
"specific",
"datasource",
"s",
"columns",
"within",
"a",
"given",
"datastore",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datasources.py#L98-L108 | train | GET / datastores/{datastore_id}/datasources/{datasource_id}/columns |
camptocamp/Studio | studio/controllers/datasources.py | DatasourcesController.showmapfile | def showmapfile(self,datastore_id=None, datasource_id=None):
""" GET /datastores/{datastore_id}/datasources/{datasource_id}/mapfile: Get
the JSON representation of a specific datasource's default MapFile LAYER
block. """
datastore = self._get_datastore_by_id(datastore_id)
... | python | def showmapfile(self,datastore_id=None, datasource_id=None):
""" GET /datastores/{datastore_id}/datasources/{datasource_id}/mapfile: Get
the JSON representation of a specific datasource's default MapFile LAYER
block. """
datastore = self._get_datastore_by_id(datastore_id)
... | [
"def",
"showmapfile",
"(",
"self",
",",
"datastore_id",
"=",
"None",
",",
"datasource_id",
"=",
"None",
")",
":",
"datastore",
"=",
"self",
".",
"_get_datastore_by_id",
"(",
"datastore_id",
")",
"if",
"datastore",
"is",
"None",
":",
"abort",
"(",
"404",
")... | GET /datastores/{datastore_id}/datasources/{datasource_id}/mapfile: Get
the JSON representation of a specific datasource's default MapFile LAYER
block. | [
"GET",
"/",
"datastores",
"/",
"{",
"datastore_id",
"}",
"/",
"datasources",
"/",
"{",
"datasource_id",
"}",
"/",
"mapfile",
":",
"Get",
"the",
"JSON",
"representation",
"of",
"a",
"specific",
"datasource",
"s",
"default",
"MapFile",
"LAYER",
"block",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datasources.py#L111-L153 | train | Get a specific MapFile LAYER
. |
tropo/tropo-webapi-python | build/lib/tropo.py | Result.getInterpretation | def getInterpretation(self):
"""
Get the value of the previously POSTed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[0]
else:
dict = actions
return dict['interpretation'] | python | def getInterpretation(self):
"""
Get the value of the previously POSTed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[0]
else:
dict = actions
return dict['interpretation'] | [
"def",
"getInterpretation",
"(",
"self",
")",
":",
"actions",
"=",
"self",
".",
"_actions",
"if",
"(",
"type",
"(",
"actions",
")",
"is",
"list",
")",
":",
"dict",
"=",
"actions",
"[",
"0",
"]",
"else",
":",
"dict",
"=",
"actions",
"return",
"dict",
... | Get the value of the previously POSTed Tropo action. | [
"Get",
"the",
"value",
"of",
"the",
"previously",
"POSTed",
"Tropo",
"action",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L654-L664 | train | Get the interpretation of the previously POSTed Tropo action. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.ask | def ask(self, choices, **options):
"""
Sends a prompt to the user and optionally waits for a response.
Arguments: "choices" is a Choices object
See https://www.tropo.com/docs/webapi/ask
"""
# # **Sun May 15 21:21:29 2011** -- egilchri
# Settng the voice in this method ca... | python | def ask(self, choices, **options):
"""
Sends a prompt to the user and optionally waits for a response.
Arguments: "choices" is a Choices object
See https://www.tropo.com/docs/webapi/ask
"""
# # **Sun May 15 21:21:29 2011** -- egilchri
# Settng the voice in this method ca... | [
"def",
"ask",
"(",
"self",
",",
"choices",
",",
"*",
"*",
"options",
")",
":",
"# # **Sun May 15 21:21:29 2011** -- egilchri",
"# Settng the voice in this method call has priority.",
"# Otherwise, we can pick up the voice from the Tropo object,",
"# if it is set there.",
"if",
"has... | Sends a prompt to the user and optionally waits for a response.
Arguments: "choices" is a Choices object
See https://www.tropo.com/docs/webapi/ask | [
"Sends",
"a",
"prompt",
"to",
"the",
"user",
"and",
"optionally",
"waits",
"for",
"a",
"response",
".",
"Arguments",
":",
"choices",
"is",
"a",
"Choices",
"object",
"See",
"https",
":",
"//",
"www",
".",
"tropo",
".",
"com",
"/",
"docs",
"/",
"webapi",... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L710-L727 | train | Sends a prompt to the user and optionally waits for a response. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.call | def call (self, to, **options):
"""
Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
Arguments: to is a String.
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/d... | python | def call (self, to, **options):
"""
Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
Arguments: to is a String.
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/d... | [
"def",
"call",
"(",
"self",
",",
"to",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Call",
"(",
"to",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
Arguments: to is a String.
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/call | [
"Places",
"a",
"call",
"or",
"sends",
"an",
"an",
"IM",
"Twitter",
"or",
"SMS",
"message",
".",
"To",
"start",
"a",
"call",
"use",
"the",
"Session",
"API",
"to",
"tell",
"Tropo",
"to",
"launch",
"your",
"code",
".",
"Arguments",
":",
"to",
"is",
"a",... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L730-L737 | train | Adds a call to the list of steps that can be performed on a specific Tropo site. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.conference | def conference(self, id, **options):
"""
This object allows multiple lines in separate sessions to be conferenced together so that the parties on each line can talk to each other simultaneously.
This is a voice channel only feature.
Argument: "id" is a String
Argument: **options ... | python | def conference(self, id, **options):
"""
This object allows multiple lines in separate sessions to be conferenced together so that the parties on each line can talk to each other simultaneously.
This is a voice channel only feature.
Argument: "id" is a String
Argument: **options ... | [
"def",
"conference",
"(",
"self",
",",
"id",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Conference",
"(",
"id",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | This object allows multiple lines in separate sessions to be conferenced together so that the parties on each line can talk to each other simultaneously.
This is a voice channel only feature.
Argument: "id" is a String
Argument: **options is a set of optional keyword arguments.
See https... | [
"This",
"object",
"allows",
"multiple",
"lines",
"in",
"separate",
"sessions",
"to",
"be",
"conferenced",
"together",
"so",
"that",
"the",
"parties",
"on",
"each",
"line",
"can",
"talk",
"to",
"each",
"other",
"simultaneously",
".",
"This",
"is",
"a",
"voice... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L739-L747 | train | Add a conference to the list of conferences that can be used to talk to a specific line. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.message | def message (self, say_obj, to, **options):
"""
A shortcut method to create a session, say something, and hang up, all in one step. This is particularly useful for sending out a quick SMS or IM.
Argument: "say_obj" is a Say object
Argument: "to" is a String
Argument: **options is... | python | def message (self, say_obj, to, **options):
"""
A shortcut method to create a session, say something, and hang up, all in one step. This is particularly useful for sending out a quick SMS or IM.
Argument: "say_obj" is a Say object
Argument: "to" is a String
Argument: **options is... | [
"def",
"message",
"(",
"self",
",",
"say_obj",
",",
"to",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"say_obj",
",",
"basestring",
")",
":",
"say",
"=",
"Say",
"(",
"say_obj",
")",
".",
"obj",
"else",
":",
"say",
"=",
"say_obj",
... | A shortcut method to create a session, say something, and hang up, all in one step. This is particularly useful for sending out a quick SMS or IM.
Argument: "say_obj" is a Say object
Argument: "to" is a String
Argument: **options is a set of optional keyword arguments.
See https://www.tr... | [
"A",
"shortcut",
"method",
"to",
"create",
"a",
"session",
"say",
"something",
"and",
"hang",
"up",
"all",
"in",
"one",
"step",
".",
"This",
"is",
"particularly",
"useful",
"for",
"sending",
"out",
"a",
"quick",
"SMS",
"or",
"IM",
".",
"Argument",
":",
... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L756-L768 | train | Shortcut method to create a session say something and hang up all in one step. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.on | def on(self, event, **options):
"""
Adds an event callback so that your application may be notified when a particular event occurs.
Possible events are: "continue", "error", "incomplete" and "hangup".
Argument: event is an event
Argument: **options is a set of optional keyword ar... | python | def on(self, event, **options):
"""
Adds an event callback so that your application may be notified when a particular event occurs.
Possible events are: "continue", "error", "incomplete" and "hangup".
Argument: event is an event
Argument: **options is a set of optional keyword ar... | [
"def",
"on",
"(",
"self",
",",
"event",
",",
"*",
"*",
"options",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'voice'",
")",
":",
"if",
"(",
"not",
"'voice'",
"in",
"options",
")",
":",
"options",
"[",
"'voice'",
"]",
"=",
"self",
".",
"voice",... | Adds an event callback so that your application may be notified when a particular event occurs.
Possible events are: "continue", "error", "incomplete" and "hangup".
Argument: event is an event
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/weba... | [
"Adds",
"an",
"event",
"callback",
"so",
"that",
"your",
"application",
"may",
"be",
"notified",
"when",
"a",
"particular",
"event",
"occurs",
".",
"Possible",
"events",
"are",
":",
"continue",
"error",
"incomplete",
"and",
"hangup",
".",
"Argument",
":",
"e... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L770-L783 | train | Adds an event callback so that your application may be notified when a particular event occurs. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.say | def say(self, message, **options):
"""
When the current session is a voice channel this key will either play a message or an audio file from a URL.
In the case of an text channel it will send the text back to the user via i nstant messaging or SMS.
Argument: message is a string
A... | python | def say(self, message, **options):
"""
When the current session is a voice channel this key will either play a message or an audio file from a URL.
In the case of an text channel it will send the text back to the user via i nstant messaging or SMS.
Argument: message is a string
A... | [
"def",
"say",
"(",
"self",
",",
"message",
",",
"*",
"*",
"options",
")",
":",
"#voice = self.voice",
"# # **Sun May 15 21:21:29 2011** -- egilchri",
"# Settng the voice in this method call has priority.",
"# Otherwise, we can pick up the voice from the Tropo object,",
"# if it is se... | When the current session is a voice channel this key will either play a message or an audio file from a URL.
In the case of an text channel it will send the text back to the user via i nstant messaging or SMS.
Argument: message is a string
Argument: **options is a set of optional keyword argumen... | [
"When",
"the",
"current",
"session",
"is",
"a",
"voice",
"channel",
"this",
"key",
"will",
"either",
"play",
"a",
"message",
"or",
"an",
"audio",
"file",
"from",
"a",
"URL",
".",
"In",
"the",
"case",
"of",
"an",
"text",
"channel",
"it",
"will",
"send",... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L809-L828 | train | This method will send a message to the user. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.startRecording | def startRecording(self, url, **options):
"""
Allows Tropo applications to begin recording the current session.
Argument: url is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/startrecording
"""
self._ste... | python | def startRecording(self, url, **options):
"""
Allows Tropo applications to begin recording the current session.
Argument: url is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/startrecording
"""
self._ste... | [
"def",
"startRecording",
"(",
"self",
",",
"url",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"StartRecording",
"(",
"url",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Allows Tropo applications to begin recording the current session.
Argument: url is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/startrecording | [
"Allows",
"Tropo",
"applications",
"to",
"begin",
"recording",
"the",
"current",
"session",
".",
"Argument",
":",
"url",
"is",
"a",
"string",
"Argument",
":",
"**",
"options",
"is",
"a",
"set",
"of",
"optional",
"keyword",
"arguments",
".",
"See",
"https",
... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L830-L837 | train | Starts recording the current session. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.transfer | def transfer(self, to, **options):
"""
Transfers an already answered call to another destination / phone number.
Argument: to is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/transfer
"""
self._steps.app... | python | def transfer(self, to, **options):
"""
Transfers an already answered call to another destination / phone number.
Argument: to is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/transfer
"""
self._steps.app... | [
"def",
"transfer",
"(",
"self",
",",
"to",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Transfer",
"(",
"to",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Transfers an already answered call to another destination / phone number.
Argument: to is a string
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/transfer | [
"Transfers",
"an",
"already",
"answered",
"call",
"to",
"another",
"destination",
"/",
"phone",
"number",
".",
"Argument",
":",
"to",
"is",
"a",
"string",
"Argument",
":",
"**",
"options",
"is",
"a",
"set",
"of",
"optional",
"keyword",
"arguments",
".",
"S... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L846-L853 | train | Transfers an already answered call to another destination phone number. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.wait | def wait(self, milliseconds, **options):
"""
Allows the thread to sleep for a given amount of time in milliseconds
Argument: milliseconds is an Integer
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/wait
"""
self._steps.append(... | python | def wait(self, milliseconds, **options):
"""
Allows the thread to sleep for a given amount of time in milliseconds
Argument: milliseconds is an Integer
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/wait
"""
self._steps.append(... | [
"def",
"wait",
"(",
"self",
",",
"milliseconds",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Wait",
"(",
"milliseconds",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Allows the thread to sleep for a given amount of time in milliseconds
Argument: milliseconds is an Integer
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/wait | [
"Allows",
"the",
"thread",
"to",
"sleep",
"for",
"a",
"given",
"amount",
"of",
"time",
"in",
"milliseconds",
"Argument",
":",
"milliseconds",
"is",
"an",
"Integer",
"Argument",
":",
"**",
"options",
"is",
"a",
"set",
"of",
"optional",
"keyword",
"arguments",... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L855-L862 | train | Wait for a given amount of time in milliseconds. |
tropo/tropo-webapi-python | build/lib/tropo.py | Tropo.RenderJson | def RenderJson(self, pretty=False):
"""
Render a Tropo object into a Json string.
"""
steps = self._steps
topdict = {}
topdict['tropo'] = steps
if pretty:
try:
json = jsonlib.dumps(topdict, indent=4, sort_keys=False)
except ... | python | def RenderJson(self, pretty=False):
"""
Render a Tropo object into a Json string.
"""
steps = self._steps
topdict = {}
topdict['tropo'] = steps
if pretty:
try:
json = jsonlib.dumps(topdict, indent=4, sort_keys=False)
except ... | [
"def",
"RenderJson",
"(",
"self",
",",
"pretty",
"=",
"False",
")",
":",
"steps",
"=",
"self",
".",
"_steps",
"topdict",
"=",
"{",
"}",
"topdict",
"[",
"'tropo'",
"]",
"=",
"steps",
"if",
"pretty",
":",
"try",
":",
"json",
"=",
"jsonlib",
".",
"dum... | Render a Tropo object into a Json string. | [
"Render",
"a",
"Tropo",
"object",
"into",
"a",
"Json",
"string",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L864-L878 | train | Render a Tropo object into a Json string. |
vkiryukhin/vkbeautify-python | vkbeautify.py | xml | def xml(src, dest=False, shift=4):
"""Beautify XML
Args:
src: xml string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function re... | python | def xml(src, dest=False, shift=4):
"""Beautify XML
Args:
src: xml string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function re... | [
"def",
"xml",
"(",
"src",
",",
"dest",
"=",
"False",
",",
"shift",
"=",
"4",
")",
":",
"if",
"not",
"dest",
":",
"return",
"_xml",
"(",
"_text",
"(",
"src",
")",
")",
"# returns string",
"else",
":",
"if",
"type",
"(",
"dest",
")",
"is",
"int",
... | Beautify XML
Args:
src: xml string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function returns string
shift: can be either ... | [
"Beautify",
"XML"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L19-L54 | train | Beautify XML string or path - to - file with text to beautified. |
vkiryukhin/vkbeautify-python | vkbeautify.py | json | def json(src, dest=False, shift=4):
"""Beautify JSON
Args:
src: JSON string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified json string; (optional)
if file doesn't exist it is created automatically;
if this arg is skept functio... | python | def json(src, dest=False, shift=4):
"""Beautify JSON
Args:
src: JSON string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified json string; (optional)
if file doesn't exist it is created automatically;
if this arg is skept functio... | [
"def",
"json",
"(",
"src",
",",
"dest",
"=",
"False",
",",
"shift",
"=",
"4",
")",
":",
"if",
"not",
"dest",
":",
"return",
"_json",
"(",
"_text",
"(",
"src",
")",
")",
"# returns string",
"else",
":",
"if",
"type",
"(",
"dest",
")",
"is",
"int",... | Beautify JSON
Args:
src: JSON string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified json string; (optional)
if file doesn't exist it is created automatically;
if this arg is skept function returns string
shift: can be eith... | [
"Beautify",
"JSON"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L57-L92 | train | Beautify JSON string src or path - to - file with text to beautified dest |
vkiryukhin/vkbeautify-python | vkbeautify.py | css | def css(src, dest=False, shift=4):
"""Beautify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function re... | python | def css(src, dest=False, shift=4):
"""Beautify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function re... | [
"def",
"css",
"(",
"src",
",",
"dest",
"=",
"False",
",",
"shift",
"=",
"4",
")",
":",
"if",
"not",
"dest",
":",
"# all default",
"return",
"_css",
"(",
"_text",
"(",
"src",
")",
")",
"else",
":",
"if",
"type",
"(",
"dest",
")",
"is",
"int",
":... | Beautify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function returns string
shift: can be either ... | [
"Beautify",
"CSS"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L95-L130 | train | Beautify CSS string or path - to - file with text to beautified |
vkiryukhin/vkbeautify-python | vkbeautify.py | _xml_min | def _xml_min(src, dest='', preserve_comments=True):
"""Minify XML
Args:
src: xml string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept ... | python | def _xml_min(src, dest='', preserve_comments=True):
"""Minify XML
Args:
src: xml string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept ... | [
"def",
"_xml_min",
"(",
"src",
",",
"dest",
"=",
"''",
",",
"preserve_comments",
"=",
"True",
")",
":",
"if",
"dest",
"==",
"''",
":",
"return",
"_xml_min_exec",
"(",
"_text",
"(",
"src",
")",
")",
"# returns string",
"else",
":",
"if",
"type",
"(",
... | Minify XML
Args:
src: xml string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function returns string
preserve_comments: if set F... | [
"Minify",
"XML"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L133-L161 | train | Minify XML string src to dest. |
vkiryukhin/vkbeautify-python | vkbeautify.py | _json_min | def _json_min(src, dest=''):
"""Minify JSON
Args:
src: json string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; (optional)
- if file doesn't exist it is created automatically;
- if this arg is skept function returns ... | python | def _json_min(src, dest=''):
"""Minify JSON
Args:
src: json string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; (optional)
- if file doesn't exist it is created automatically;
- if this arg is skept function returns ... | [
"def",
"_json_min",
"(",
"src",
",",
"dest",
"=",
"''",
")",
":",
"if",
"dest",
"==",
"''",
":",
"return",
"_json_min_exec",
"(",
"_text",
"(",
"src",
")",
")",
"# returns string",
"else",
":",
"if",
"type",
"(",
"dest",
")",
"is",
"bool",
":",
"# ... | Minify JSON
Args:
src: json string or path-to-file with text to minify (mandatory)
dest: path-to-file to save minified xml string; (optional)
- if file doesn't exist it is created automatically;
- if this arg is skept function returns string
Returns: 1) minified JSO... | [
"Minify",
"JSON"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L165-L189 | train | Minify JSON string src to dest. |
vkiryukhin/vkbeautify-python | vkbeautify.py | _css_min | def _css_min(src, dest='', preserve_comments=True):
"""Minify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is sk... | python | def _css_min(src, dest='', preserve_comments=True):
"""Minify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is sk... | [
"def",
"_css_min",
"(",
"src",
",",
"dest",
"=",
"''",
",",
"preserve_comments",
"=",
"True",
")",
":",
"if",
"dest",
"==",
"''",
":",
"# all default",
"return",
"_css_min_exec",
"(",
"_text",
"(",
"src",
")",
")",
"else",
":",
"if",
"type",
"(",
"de... | Minify CSS
Args:
src: css string or path-to-file with text to beautify (mandatory)
dest: path-to-file to save beautified css string; if file doesn't exist
it is created automatically; (optional)
if this arg is skept function returns string
preserve_comments: if s... | [
"Minify",
"CSS"
] | bd26dbc8e37e519392fa303f34999c82b86c413f | https://github.com/vkiryukhin/vkbeautify-python/blob/bd26dbc8e37e519392fa303f34999c82b86c413f/vkbeautify.py#L193-L221 | train | Minify CSS string src to dest. |
tropo/tropo-webapi-python | samples/ReceiveSMS.py | index | def index(request):
session = Session(request.body)
print 'request.body begin'
print request.body
print 'request.body end'
t = Tropo()
smsContent = session.initialText
#t.call(to=session.parameters['callToNumber'], network='SIP')
#t.say(session.parameters['message'])
"""
t = Trop... | python | def index(request):
session = Session(request.body)
print 'request.body begin'
print request.body
print 'request.body end'
t = Tropo()
smsContent = session.initialText
#t.call(to=session.parameters['callToNumber'], network='SIP')
#t.say(session.parameters['message'])
"""
t = Trop... | [
"def",
"index",
"(",
"request",
")",
":",
"session",
"=",
"Session",
"(",
"request",
".",
"body",
")",
"print",
"'request.body begin'",
"print",
"request",
".",
"body",
"print",
"'request.body end'",
"t",
"=",
"Tropo",
"(",
")",
"smsContent",
"=",
"session",... | t = Tropo()
t.call(to="xiangjun_yu@192.168.26.1:5678")
t.say("wo shi yi ke xiao xiao cao") | [
"t",
"=",
"Tropo",
"()",
"t",
".",
"call",
"(",
"to",
"=",
"xiangjun_yu"
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/ReceiveSMS.py#L11-L42 | train | This function is used to index the SMS. |
tropo/tropo-webapi-python | tropo.py | Result.getValue | def getValue(self):
"""
Get the value of the previously POSTed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[0]
else:
dict = actions
return dict.get('value', 'NoValue') | python | def getValue(self):
"""
Get the value of the previously POSTed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[0]
else:
dict = actions
return dict.get('value', 'NoValue') | [
"def",
"getValue",
"(",
"self",
")",
":",
"actions",
"=",
"self",
".",
"_actions",
"if",
"(",
"type",
"(",
"actions",
")",
"is",
"list",
")",
":",
"dict",
"=",
"actions",
"[",
"0",
"]",
"else",
":",
"dict",
"=",
"actions",
"return",
"dict",
".",
... | Get the value of the previously POSTed Tropo action. | [
"Get",
"the",
"value",
"of",
"the",
"previously",
"POSTed",
"Tropo",
"action",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L712-L722 | train | Get the value of the previously POSTed Tropo action. |
tropo/tropo-webapi-python | tropo.py | Result.getIndexedValue | def getIndexedValue(self, index):
"""
Get the value of the indexed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[index]
else:
dict = actions
return dict.get('value', 'NoValue') | python | def getIndexedValue(self, index):
"""
Get the value of the indexed Tropo action.
"""
actions = self._actions
if (type (actions) is list):
dict = actions[index]
else:
dict = actions
return dict.get('value', 'NoValue') | [
"def",
"getIndexedValue",
"(",
"self",
",",
"index",
")",
":",
"actions",
"=",
"self",
".",
"_actions",
"if",
"(",
"type",
"(",
"actions",
")",
"is",
"list",
")",
":",
"dict",
"=",
"actions",
"[",
"index",
"]",
"else",
":",
"dict",
"=",
"actions",
... | Get the value of the indexed Tropo action. | [
"Get",
"the",
"value",
"of",
"the",
"indexed",
"Tropo",
"action",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L724-L734 | train | Get the value of the indexed Tropo action. |
tropo/tropo-webapi-python | tropo.py | Result.getNamedActionValue | def getNamedActionValue(self, name):
"""
Get the value of the named Tropo action.
"""
actions = self._actions
if (type (actions) is list):
for a in actions:
if a.get('name', 'NoValue') == name:
dict =a
else:
dic... | python | def getNamedActionValue(self, name):
"""
Get the value of the named Tropo action.
"""
actions = self._actions
if (type (actions) is list):
for a in actions:
if a.get('name', 'NoValue') == name:
dict =a
else:
dic... | [
"def",
"getNamedActionValue",
"(",
"self",
",",
"name",
")",
":",
"actions",
"=",
"self",
".",
"_actions",
"if",
"(",
"type",
"(",
"actions",
")",
"is",
"list",
")",
":",
"for",
"a",
"in",
"actions",
":",
"if",
"a",
".",
"get",
"(",
"'name'",
",",
... | Get the value of the named Tropo action. | [
"Get",
"the",
"value",
"of",
"the",
"named",
"Tropo",
"action",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L736-L748 | train | Get the value of the named Tropo action. |
tropo/tropo-webapi-python | tropo.py | Tropo.answer | def answer (self, headers, **options):
"""
Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API headers tell Tropo headers launch your code.
Arguments: headers is a String.
Argument: **options is a set of optional keyword arguments.
See h... | python | def answer (self, headers, **options):
"""
Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API headers tell Tropo headers launch your code.
Arguments: headers is a String.
Argument: **options is a set of optional keyword arguments.
See h... | [
"def",
"answer",
"(",
"self",
",",
"headers",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Answer",
"(",
"headers",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API headers tell Tropo headers launch your code.
Arguments: headers is a String.
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/answer | [
"Places",
"a",
"call",
"or",
"sends",
"an",
"an",
"IM",
"Twitter",
"or",
"SMS",
"message",
".",
"To",
"start",
"a",
"call",
"use",
"the",
"Session",
"API",
"headers",
"tell",
"Tropo",
"headers",
"launch",
"your",
"code",
".",
"Arguments",
":",
"headers",... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L862-L869 | train | Adds an answer to the list of steps that will be executed when the Tropo API is started. |
tropo/tropo-webapi-python | tropo.py | Tropo.redirect | def redirect(self, id, name, **options):
"""
Forwards an incoming call to another destination / phone number before answering it.
Argument: id is a String
Argument: name is a String
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs... | python | def redirect(self, id, name, **options):
"""
Forwards an incoming call to another destination / phone number before answering it.
Argument: id is a String
Argument: name is a String
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs... | [
"def",
"redirect",
"(",
"self",
",",
"id",
",",
"name",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"Redirect",
"(",
"id",
",",
"name",
",",
"*",
"*",
"options",
")",
".",
"obj",
")"
] | Forwards an incoming call to another destination / phone number before answering it.
Argument: id is a String
Argument: name is a String
Argument: **options is a set of optional keyword arguments.
See https://www.tropo.com/docs/webapi/redirect | [
"Forwards",
"an",
"incoming",
"call",
"to",
"another",
"destination",
"/",
"phone",
"number",
"before",
"answering",
"it",
".",
"Argument",
":",
"id",
"is",
"a",
"String",
"Argument",
":",
"name",
"is",
"a",
"String",
"Argument",
":",
"**",
"options",
"is"... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L934-L942 | train | Forwards an incoming call to another destination phone number before answering it. |
tropo/tropo-webapi-python | tropo.py | Tropo.generalLogSecurity | def generalLogSecurity(self, state, **options):
"""
Turn on/off all logging on the Tropo platform
Argument: state is a String
See https://www.tropo.com/docs/webapi/generallogsecurity
"""
self._steps.append(GeneralLogSecurity(state).obj) | python | def generalLogSecurity(self, state, **options):
"""
Turn on/off all logging on the Tropo platform
Argument: state is a String
See https://www.tropo.com/docs/webapi/generallogsecurity
"""
self._steps.append(GeneralLogSecurity(state).obj) | [
"def",
"generalLogSecurity",
"(",
"self",
",",
"state",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_steps",
".",
"append",
"(",
"GeneralLogSecurity",
"(",
"state",
")",
".",
"obj",
")"
] | Turn on/off all logging on the Tropo platform
Argument: state is a String
See https://www.tropo.com/docs/webapi/generallogsecurity | [
"Turn",
"on",
"/",
"off",
"all",
"logging",
"on",
"the",
"Tropo",
"platform",
"Argument",
":",
"state",
"is",
"a",
"String",
"See",
"https",
":",
"//",
"www",
".",
"tropo",
".",
"com",
"/",
"docs",
"/",
"webapi",
"/",
"generallogsecurity"
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/tropo.py#L1006-L1012 | train | This method is called by the general log security step. |
camptocamp/Studio | studio/lib/os_utils.py | stop_subprocess | def stop_subprocess(pid):
"""Stop subprocess whose process id is pid."""
if hasattr(os, "kill"):
import signal
os.kill(pid, signal.SIGTERM)
else:
import win32api
pid = win32api.OpenProcess(1, 0, pid)
win32api.TerminateProcess(pid, 0)
os.waitpid(pid, 0) | python | def stop_subprocess(pid):
"""Stop subprocess whose process id is pid."""
if hasattr(os, "kill"):
import signal
os.kill(pid, signal.SIGTERM)
else:
import win32api
pid = win32api.OpenProcess(1, 0, pid)
win32api.TerminateProcess(pid, 0)
os.waitpid(pid, 0) | [
"def",
"stop_subprocess",
"(",
"pid",
")",
":",
"if",
"hasattr",
"(",
"os",
",",
"\"kill\"",
")",
":",
"import",
"signal",
"os",
".",
"kill",
"(",
"pid",
",",
"signal",
".",
"SIGTERM",
")",
"else",
":",
"import",
"win32api",
"pid",
"=",
"win32api",
"... | Stop subprocess whose process id is pid. | [
"Stop",
"subprocess",
"whose",
"process",
"id",
"is",
"pid",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/os_utils.py#L23-L32 | train | Stop a subprocess whose process id is pid. |
cocaine/cocaine-tools | cocaine/tools/actions/mql/__init__.py | Parser.expr | def expr(self):
"""
expr ::= term ((AND | OR) term)*
term ::= factor ((EQ | NE) factor)*
factor ::= func | const | LPAREN expr RPAREN
func ::= lit LPAREN expr (,expr)* RPAREN
lit ::= alphanum
"""
node = self.term()
while True:
... | python | def expr(self):
"""
expr ::= term ((AND | OR) term)*
term ::= factor ((EQ | NE) factor)*
factor ::= func | const | LPAREN expr RPAREN
func ::= lit LPAREN expr (,expr)* RPAREN
lit ::= alphanum
"""
node = self.term()
while True:
... | [
"def",
"expr",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"term",
"(",
")",
"while",
"True",
":",
"token",
"=",
"self",
".",
"current_token",
"if",
"token",
".",
"type",
"==",
"AND",
":",
"self",
".",
"eat",
"(",
"AND",
")",
"elif",
"token"... | expr ::= term ((AND | OR) term)*
term ::= factor ((EQ | NE) factor)*
factor ::= func | const | LPAREN expr RPAREN
func ::= lit LPAREN expr (,expr)* RPAREN
lit ::= alphanum | [
"expr",
"::",
"=",
"term",
"((",
"AND",
"|",
"OR",
")",
"term",
")",
"*",
"term",
"::",
"=",
"factor",
"((",
"EQ",
"|",
"NE",
")",
"factor",
")",
"*",
"factor",
"::",
"=",
"func",
"|",
"const",
"|",
"LPAREN",
"expr",
"RPAREN",
"func",
"::",
"="... | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/actions/mql/__init__.py#L186-L205 | train | A term - level expression that returns a term - level expression. |
cnschema/cdata | cdata/core.py | file2abspath | def file2abspath(filename, this_file=__file__):
"""
generate absolute path for the given file and base dir
"""
return os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(this_file)), filename)) | python | def file2abspath(filename, this_file=__file__):
"""
generate absolute path for the given file and base dir
"""
return os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(this_file)), filename)) | [
"def",
"file2abspath",
"(",
"filename",
",",
"this_file",
"=",
"__file__",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"... | generate absolute path for the given file and base dir | [
"generate",
"absolute",
"path",
"for",
"the",
"given",
"file",
"and",
"base",
"dir"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L28-L33 | train | generate absolute path for the given file and base dir |
cnschema/cdata | cdata/core.py | file2json | def file2json(filename, encoding='utf-8'):
"""
save a line
"""
with codecs.open(filename, "r", encoding=encoding) as f:
return json.load(f) | python | def file2json(filename, encoding='utf-8'):
"""
save a line
"""
with codecs.open(filename, "r", encoding=encoding) as f:
return json.load(f) | [
"def",
"file2json",
"(",
"filename",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"\"r\"",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
")"
] | save a line | [
"save",
"a",
"line"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L39-L44 | train | save a line
|
cnschema/cdata | cdata/core.py | file2iter | def file2iter(filename, encoding='utf-8', comment_prefix="#",
skip_empty_line=True):
"""
json stream parsing or line parsing
"""
ret = list()
visited = set()
with codecs.open(filename, encoding=encoding) as f:
for line in f:
line = line.strip()
#... | python | def file2iter(filename, encoding='utf-8', comment_prefix="#",
skip_empty_line=True):
"""
json stream parsing or line parsing
"""
ret = list()
visited = set()
with codecs.open(filename, encoding=encoding) as f:
for line in f:
line = line.strip()
#... | [
"def",
"file2iter",
"(",
"filename",
",",
"encoding",
"=",
"'utf-8'",
",",
"comment_prefix",
"=",
"\"#\"",
",",
"skip_empty_line",
"=",
"True",
")",
":",
"ret",
"=",
"list",
"(",
")",
"visited",
"=",
"set",
"(",
")",
"with",
"codecs",
".",
"open",
"(",... | json stream parsing or line parsing | [
"json",
"stream",
"parsing",
"or",
"line",
"parsing"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L47-L65 | train | yields all the lines in a file |
cnschema/cdata | cdata/core.py | json2file | def json2file(data, filename, encoding='utf-8'):
"""
write json in canonical json format
"""
with codecs.open(filename, "w", encoding=encoding) as f:
json.dump(data, f, ensure_ascii=False, indent=4, sort_keys=True) | python | def json2file(data, filename, encoding='utf-8'):
"""
write json in canonical json format
"""
with codecs.open(filename, "w", encoding=encoding) as f:
json.dump(data, f, ensure_ascii=False, indent=4, sort_keys=True) | [
"def",
"json2file",
"(",
"data",
",",
"filename",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"\"w\"",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"data",
",",
... | write json in canonical json format | [
"write",
"json",
"in",
"canonical",
"json",
"format"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L71-L76 | train | write json in canonical json format |
cnschema/cdata | cdata/core.py | lines2file | def lines2file(lines, filename, encoding='utf-8'):
"""
write json stream, write lines too
"""
with codecs.open(filename, "w", encoding=encoding) as f:
for line in lines:
f.write(line)
f.write("\n") | python | def lines2file(lines, filename, encoding='utf-8'):
"""
write json stream, write lines too
"""
with codecs.open(filename, "w", encoding=encoding) as f:
for line in lines:
f.write(line)
f.write("\n") | [
"def",
"lines2file",
"(",
"lines",
",",
"filename",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"\"w\"",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"for",
"line",
"in",
"lines",
":",
"f"... | write json stream, write lines too | [
"write",
"json",
"stream",
"write",
"lines",
"too"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L79-L86 | train | write lines to json stream |
cnschema/cdata | cdata/core.py | items2file | def items2file(items, filename, encoding='utf-8', modifier='w'):
"""
json array to file, canonical json format
"""
with codecs.open(filename, modifier, encoding=encoding) as f:
for item in items:
f.write(u"{}\n".format(json.dumps(
item, ensure_ascii=False, sort_ke... | python | def items2file(items, filename, encoding='utf-8', modifier='w'):
"""
json array to file, canonical json format
"""
with codecs.open(filename, modifier, encoding=encoding) as f:
for item in items:
f.write(u"{}\n".format(json.dumps(
item, ensure_ascii=False, sort_ke... | [
"def",
"items2file",
"(",
"items",
",",
"filename",
",",
"encoding",
"=",
"'utf-8'",
",",
"modifier",
"=",
"'w'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"modifier",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"for",
... | json array to file, canonical json format | [
"json",
"array",
"to",
"file",
"canonical",
"json",
"format"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L89-L96 | train | write a list of items to a file |
cnschema/cdata | cdata/core.py | json_get | def json_get(json_object, property_path, default=None):
"""
get value of property_path from a json object, e.g. person.father.name
* invalid path return None
* valid path (the -1 on path is an object), use default
"""
temp = json_object
for field in property_path[:-1]:
if... | python | def json_get(json_object, property_path, default=None):
"""
get value of property_path from a json object, e.g. person.father.name
* invalid path return None
* valid path (the -1 on path is an object), use default
"""
temp = json_object
for field in property_path[:-1]:
if... | [
"def",
"json_get",
"(",
"json_object",
",",
"property_path",
",",
"default",
"=",
"None",
")",
":",
"temp",
"=",
"json_object",
"for",
"field",
"in",
"property_path",
"[",
":",
"-",
"1",
"]",
":",
"if",
"not",
"isinstance",
"(",
"temp",
",",
"dict",
")... | get value of property_path from a json object, e.g. person.father.name
* invalid path return None
* valid path (the -1 on path is an object), use default | [
"get",
"value",
"of",
"property_path",
"from",
"a",
"json",
"object",
"e",
".",
"g",
".",
"person",
".",
"father",
".",
"name",
"*",
"invalid",
"path",
"return",
"None",
"*",
"valid",
"path",
"(",
"the",
"-",
"1",
"on",
"path",
"is",
"an",
"object",
... | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L102-L115 | train | Get value of property_path from a json object |
cnschema/cdata | cdata/core.py | json_dict_copy | def json_dict_copy(json_object, property_list, defaultValue=None):
"""
property_list = [
{ "name":"name", "alternateName": ["name","title"]},
{ "name":"birthDate", "alternateName": ["dob","dateOfBirth"] },
{ "name":"description" }
]
"""
ret = {}
for pr... | python | def json_dict_copy(json_object, property_list, defaultValue=None):
"""
property_list = [
{ "name":"name", "alternateName": ["name","title"]},
{ "name":"birthDate", "alternateName": ["dob","dateOfBirth"] },
{ "name":"description" }
]
"""
ret = {}
for pr... | [
"def",
"json_dict_copy",
"(",
"json_object",
",",
"property_list",
",",
"defaultValue",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"prop",
"in",
"property_list",
":",
"p_name",
"=",
"prop",
"[",
"\"name\"",
"]",
"for",
"alias",
"in",
"prop",
"."... | property_list = [
{ "name":"name", "alternateName": ["name","title"]},
{ "name":"birthDate", "alternateName": ["dob","dateOfBirth"] },
{ "name":"description" }
] | [
"property_list",
"=",
"[",
"{",
"name",
":",
"name",
"alternateName",
":",
"[",
"name",
"title",
"]",
"}",
"{",
"name",
":",
"birthDate",
"alternateName",
":",
"[",
"dob",
"dateOfBirth",
"]",
"}",
"{",
"name",
":",
"description",
"}",
"]"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L138-L159 | train | Returns a copy of the given json_object with the given list of properties. |
cnschema/cdata | cdata/core.py | any2utf8 | def any2utf8(data):
"""
rewrite json object values (unicode) into utf-8 encoded string
"""
if isinstance(data, dict):
ret = {}
for k, v in data.items():
k = any2utf8(k)
ret[k] = any2utf8(v)
return ret
elif isinstance(data, list):
return [an... | python | def any2utf8(data):
"""
rewrite json object values (unicode) into utf-8 encoded string
"""
if isinstance(data, dict):
ret = {}
for k, v in data.items():
k = any2utf8(k)
ret[k] = any2utf8(v)
return ret
elif isinstance(data, list):
return [an... | [
"def",
"any2utf8",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"data",
".",
"items",
"(",
")",
":",
"k",
"=",
"any2utf8",
"(",
"k",
")",
"ret",
"[",
"k",
"... | rewrite json object values (unicode) into utf-8 encoded string | [
"rewrite",
"json",
"object",
"values",
"(",
"unicode",
")",
"into",
"utf",
"-",
"8",
"encoded",
"string"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L175-L195 | train | rewrite json object values ( unicode ) into utf - 8 encoded string
|
cnschema/cdata | cdata/core.py | stat_jsonld | def stat_jsonld(data, key=None, counter=None):
"""
provide statistics for jsonld, right now only count triples
see also https://json-ld.org/playground/
note: attributes @id @context do not contribute any triple
"""
if counter is None:
counter = collections.Counter()
if... | python | def stat_jsonld(data, key=None, counter=None):
"""
provide statistics for jsonld, right now only count triples
see also https://json-ld.org/playground/
note: attributes @id @context do not contribute any triple
"""
if counter is None:
counter = collections.Counter()
if... | [
"def",
"stat_jsonld",
"(",
"data",
",",
"key",
"=",
"None",
",",
"counter",
"=",
"None",
")",
":",
"if",
"counter",
"is",
"None",
":",
"counter",
"=",
"collections",
".",
"Counter",
"(",
")",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
... | provide statistics for jsonld, right now only count triples
see also https://json-ld.org/playground/
note: attributes @id @context do not contribute any triple | [
"provide",
"statistics",
"for",
"jsonld",
"right",
"now",
"only",
"count",
"triples",
"see",
"also",
"https",
":",
"//",
"json",
"-",
"ld",
".",
"org",
"/",
"playground",
"/",
"note",
":",
"attributes"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/core.py#L269-L300 | train | provide statistics for jsonld |
cocaine/cocaine-tools | cocaine/proxy/proxy.py | CocaineProxy.resolve_group_to_version | def resolve_group_to_version(self, name, value=None):
""" Pick a version from a routing group using a random or provided value
A routing group looks like (weight, version):
{"APP": [[29431330, 'A'], [82426238, 'B'], [101760716, 'C'], [118725487, 'D'], [122951927, 'E']]}
"""
... | python | def resolve_group_to_version(self, name, value=None):
""" Pick a version from a routing group using a random or provided value
A routing group looks like (weight, version):
{"APP": [[29431330, 'A'], [82426238, 'B'], [101760716, 'C'], [118725487, 'D'], [122951927, 'E']]}
"""
... | [
"def",
"resolve_group_to_version",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"current_rg",
":",
"return",
"name",
"routing_group",
"=",
"self",
".",
"current_rg",
"[",
"name",
"]",
"if",
"len",... | Pick a version from a routing group using a random or provided value
A routing group looks like (weight, version):
{"APP": [[29431330, 'A'], [82426238, 'B'], [101760716, 'C'], [118725487, 'D'], [122951927, 'E']]} | [
"Pick",
"a",
"version",
"from",
"a",
"routing",
"group",
"using",
"a",
"random",
"or",
"provided",
"value",
"A",
"routing",
"group",
"looks",
"like",
"(",
"weight",
"version",
")",
":",
"{",
"APP",
":",
"[[",
"29431330",
"A",
"]",
"[",
"82426238",
"B",... | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/proxy/proxy.py#L572-L587 | train | Pick a version from a routing group using a random value |
balloob/voluptuous-serialize | voluptuous_serialize/__init__.py | convert | def convert(schema):
"""Convert a voluptuous schema to a dictionary."""
# pylint: disable=too-many-return-statements,too-many-branches
if isinstance(schema, vol.Schema):
schema = schema.schema
if isinstance(schema, Mapping):
val = []
for key, value in schema.items():
... | python | def convert(schema):
"""Convert a voluptuous schema to a dictionary."""
# pylint: disable=too-many-return-statements,too-many-branches
if isinstance(schema, vol.Schema):
schema = schema.schema
if isinstance(schema, Mapping):
val = []
for key, value in schema.items():
... | [
"def",
"convert",
"(",
"schema",
")",
":",
"# pylint: disable=too-many-return-statements,too-many-branches",
"if",
"isinstance",
"(",
"schema",
",",
"vol",
".",
"Schema",
")",
":",
"schema",
"=",
"schema",
".",
"schema",
"if",
"isinstance",
"(",
"schema",
",",
"... | Convert a voluptuous schema to a dictionary. | [
"Convert",
"a",
"voluptuous",
"schema",
"to",
"a",
"dictionary",
"."
] | 02992eb3128063d065048cdcbfb907efe0a53b99 | https://github.com/balloob/voluptuous-serialize/blob/02992eb3128063d065048cdcbfb907efe0a53b99/voluptuous_serialize/__init__.py#L15-L97 | train | Convert a voluptuous schema to a dictionary. |
jpgxs/pyopsview | pyopsview/utils.py | version_cmp | def version_cmp(version_a, version_b):
"""Compares two versions"""
a = normalize_version(version_a)
b = normalize_version(version_b)
i_a = a[0] * 100 + a[1] * 10 + a[0] * 1
i_b = b[0] * 100 + b[1] * 10 + b[0] * 1
return i_a - i_b | python | def version_cmp(version_a, version_b):
"""Compares two versions"""
a = normalize_version(version_a)
b = normalize_version(version_b)
i_a = a[0] * 100 + a[1] * 10 + a[0] * 1
i_b = b[0] * 100 + b[1] * 10 + b[0] * 1
return i_a - i_b | [
"def",
"version_cmp",
"(",
"version_a",
",",
"version_b",
")",
":",
"a",
"=",
"normalize_version",
"(",
"version_a",
")",
"b",
"=",
"normalize_version",
"(",
"version_b",
")",
"i_a",
"=",
"a",
"[",
"0",
"]",
"*",
"100",
"+",
"a",
"[",
"1",
"]",
"*",
... | Compares two versions | [
"Compares",
"two",
"versions"
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/utils.py#L52-L60 | train | Compares two versions |
uw-it-aca/uw-restclients-core | restclients_core/models/__init__.py | MockHTTP.getheader | def getheader(self, field, default=''):
"""
Returns the HTTP response header field, case insensitively
"""
if self.headers:
for header in self.headers:
if field.lower() == header.lower():
return self.headers[header]
return default | python | def getheader(self, field, default=''):
"""
Returns the HTTP response header field, case insensitively
"""
if self.headers:
for header in self.headers:
if field.lower() == header.lower():
return self.headers[header]
return default | [
"def",
"getheader",
"(",
"self",
",",
"field",
",",
"default",
"=",
"''",
")",
":",
"if",
"self",
".",
"headers",
":",
"for",
"header",
"in",
"self",
".",
"headers",
":",
"if",
"field",
".",
"lower",
"(",
")",
"==",
"header",
".",
"lower",
"(",
"... | Returns the HTTP response header field, case insensitively | [
"Returns",
"the",
"HTTP",
"response",
"header",
"field",
"case",
"insensitively"
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/models/__init__.py#L30-L39 | train | Returns the HTTP response header field case insensitively |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | isAlphanum | def isAlphanum(c):
"""return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character.
"""
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126)); | python | def isAlphanum(c):
"""return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character.
"""
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126)); | [
"def",
"isAlphanum",
"(",
"c",
")",
":",
"return",
"(",
"(",
"c",
">=",
"'a'",
"and",
"c",
"<=",
"'z'",
")",
"or",
"(",
"c",
">=",
"'0'",
"and",
"c",
"<=",
"'9'",
")",
"or",
"(",
"c",
">=",
"'A'",
"and",
"c",
"<=",
"'Z'",
")",
"or",
"c",
... | return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character. | [
"return",
"true",
"if",
"the",
"character",
"is",
"a",
"letter",
"digit",
"underscore",
"dollar",
"sign",
"or",
"non",
"-",
"ASCII",
"character",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L63-L68 | train | Return True if the character is a letter digit underscore dollar sign or non - ASCII character. |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | JavascriptMinify._get | def _get(self):
"""return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed.
"""
c = self.theLookahead
self.theLookahead = None
if c == None:
c = self.instream.rea... | python | def _get(self):
"""return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed.
"""
c = self.theLookahead
self.theLookahead = None
if c == None:
c = self.instream.rea... | [
"def",
"_get",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"theLookahead",
"self",
".",
"theLookahead",
"=",
"None",
"if",
"c",
"==",
"None",
":",
"c",
"=",
"self",
".",
"instream",
".",
"read",
"(",
"1",
")",
"if",
"c",
">=",
"' '",
"or",
"c... | return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed. | [
"return",
"the",
"next",
"character",
"from",
"stdin",
".",
"Watch",
"out",
"for",
"lookahead",
".",
"If",
"the",
"character",
"is",
"a",
"control",
"character",
"translate",
"it",
"to",
"a",
"space",
"or",
"linefeed",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L86-L101 | train | return the next character from stdin |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | JavascriptMinify._next | def _next(self):
"""get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
... | python | def _next(self):
"""get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
... | [
"def",
"_next",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_get",
"(",
")",
"if",
"c",
"==",
"'/'",
":",
"p",
"=",
"self",
".",
"_peek",
"(",
")",
"if",
"p",
"==",
"'/'",
":",
"c",
"=",
"self",
".",
"_get",
"(",
")",
"while",
"c",
">"... | get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'. | [
"get",
"the",
"next",
"character",
"excluding",
"comments",
".",
"peek",
"()",
"is",
"used",
"to",
"see",
"if",
"a",
"/",
"is",
"followed",
"by",
"a",
"/",
"or",
"*",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L107-L130 | train | get the next character excluding comments. peek is used to see
. |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | JavascriptMinify._action | def _action(self, action):
"""do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
... | python | def _action(self, action):
"""do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
... | [
"def",
"_action",
"(",
"self",
",",
"action",
")",
":",
"if",
"action",
"<=",
"1",
":",
"self",
".",
"_outA",
"(",
")",
"if",
"action",
"<=",
"2",
":",
"self",
".",
"theA",
"=",
"self",
".",
"theB",
"if",
"self",
".",
"theA",
"==",
"\"'\"",
"or... | do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
action recognizes a regular expressio... | [
"do",
"something!",
"What",
"you",
"do",
"is",
"determined",
"by",
"the",
"argument",
":",
"1",
"Output",
"A",
".",
"Copy",
"B",
"to",
"A",
".",
"Get",
"the",
"next",
"B",
".",
"2",
"Copy",
"B",
"to",
"A",
".",
"Get",
"the",
"next",
"B",
".",
"... | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L132-L177 | train | This method is called by the action method in the A. It is called by the action method in A. It is called by the action method in A. It is called by the action method in A. It is called by the action method in A. The action is defined by the action parameter. |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | JavascriptMinify._jsmin | def _jsmin(self):
"""Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed.
"""... | python | def _jsmin(self):
"""Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed.
"""... | [
"def",
"_jsmin",
"(",
"self",
")",
":",
"self",
".",
"theA",
"=",
"'\\n'",
"self",
".",
"_action",
"(",
"3",
")",
"while",
"self",
".",
"theA",
"!=",
"'\\000'",
":",
"if",
"self",
".",
"theA",
"==",
"' '",
":",
"if",
"isAlphanum",
"(",
"self",
".... | Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed. | [
"Copy",
"the",
"input",
"to",
"the",
"output",
"deleting",
"the",
"characters",
"which",
"are",
"insignificant",
"to",
"JavaScript",
".",
"Comments",
"will",
"be",
"removed",
".",
"Tabs",
"will",
"be",
"replaced",
"with",
"spaces",
".",
"Carriage",
"returns",
... | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L180-L220 | train | Copy the input to the output deleting the characters which are not insignificant to JavaScript. |
camptocamp/Studio | studio/controllers/layertemplates.py | LayertemplatesController.index | def index(self, format='html'):
"""GET /layertemplates: All items in the collection."""
# url('layertemplates')
lts = meta.Session.query(LayerTemplate)
# use following query for getting layertemplates owned by current user
#lts = self._get_lts_from_user(c.user)
serialized... | python | def index(self, format='html'):
"""GET /layertemplates: All items in the collection."""
# url('layertemplates')
lts = meta.Session.query(LayerTemplate)
# use following query for getting layertemplates owned by current user
#lts = self._get_lts_from_user(c.user)
serialized... | [
"def",
"index",
"(",
"self",
",",
"format",
"=",
"'html'",
")",
":",
"# url('layertemplates')",
"lts",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"LayerTemplate",
")",
"# use following query for getting layertemplates owned by current user",
"#lts = self._get_lts_fro... | GET /layertemplates: All items in the collection. | [
"GET",
"/",
"layertemplates",
":",
"All",
"items",
"in",
"the",
"collection",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/layertemplates.py#L47-L62 | train | GET / layertemplates : All items in the collection. |
camptocamp/Studio | studio/controllers/layertemplates.py | LayertemplatesController.create | def create(self):
"""POST /layertemplates: Create a new item."""
# url('layertemplates')
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
lt = self._new_lt_from_user(c... | python | def create(self):
"""POST /layertemplates: Create a new item."""
# url('layertemplates')
content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
content = content.decode('utf8')
content = simplejson.loads(content)
lt = self._new_lt_from_user(c... | [
"def",
"create",
"(",
"self",
")",
":",
"# url('layertemplates')",
"content",
"=",
"request",
".",
"environ",
"[",
"'wsgi.input'",
"]",
".",
"read",
"(",
"int",
"(",
"request",
".",
"environ",
"[",
"'CONTENT_LENGTH'",
"]",
")",
")",
"content",
"=",
"conten... | POST /layertemplates: Create a new item. | [
"POST",
"/",
"layertemplates",
":",
"Create",
"a",
"new",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/layertemplates.py#L66-L75 | train | POST / layertemplates : Create a new item. |
camptocamp/Studio | studio/controllers/layertemplates.py | LayertemplatesController.update | def update(self, id):
"""PUT /layertemplates/id: Update an existing item."""
# url('LayerTemplates', id=ID)
lt = meta.Session.query(LayerTemplate).get(id)
# use following query for getting a layertemplate owned by current user
#lt = self._get_lt_from_user_by_id(c.user, id)
... | python | def update(self, id):
"""PUT /layertemplates/id: Update an existing item."""
# url('LayerTemplates', id=ID)
lt = meta.Session.query(LayerTemplate).get(id)
# use following query for getting a layertemplate owned by current user
#lt = self._get_lt_from_user_by_id(c.user, id)
... | [
"def",
"update",
"(",
"self",
",",
"id",
")",
":",
"# url('LayerTemplates', id=ID)",
"lt",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"LayerTemplate",
")",
".",
"get",
"(",
"id",
")",
"# use following query for getting a layertemplate owned by current user",
"#... | PUT /layertemplates/id: Update an existing item. | [
"PUT",
"/",
"layertemplates",
"/",
"id",
":",
"Update",
"an",
"existing",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/layertemplates.py#L79-L94 | train | PUT / layertemplates / id : Update an existing item. |
camptocamp/Studio | studio/controllers/layertemplates.py | LayertemplatesController.delete | def delete(self, id):
"""DELETE /layertemplates/id: Delete an existing item."""
# url('LayerTemplates', id=ID)
lt = meta.Session.query(LayerTemplate).get(id)
# use following query for getting a layertemplate owned by current user
#lt = self._get_lt_from_user_by_id(c.user, id)
... | python | def delete(self, id):
"""DELETE /layertemplates/id: Delete an existing item."""
# url('LayerTemplates', id=ID)
lt = meta.Session.query(LayerTemplate).get(id)
# use following query for getting a layertemplate owned by current user
#lt = self._get_lt_from_user_by_id(c.user, id)
... | [
"def",
"delete",
"(",
"self",
",",
"id",
")",
":",
"# url('LayerTemplates', id=ID)",
"lt",
"=",
"meta",
".",
"Session",
".",
"query",
"(",
"LayerTemplate",
")",
".",
"get",
"(",
"id",
")",
"# use following query for getting a layertemplate owned by current user",
"#... | DELETE /layertemplates/id: Delete an existing item. | [
"DELETE",
"/",
"layertemplates",
"/",
"id",
":",
"Delete",
"an",
"existing",
"item",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/layertemplates.py#L97-L106 | train | DELETE / layertemplates / id : Delete an existing item. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.