partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
BaseApi.path_helper
Works like a apispec plugin May return a path as string and mutate operations dict. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#ope...
flask_appbuilder/api/__init__.py
def path_helper(self, path=None, operations=None, **kwargs): """ Works like a apispec plugin May return a path as string and mutate operations dict. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See ...
def path_helper(self, path=None, operations=None, **kwargs): """ Works like a apispec plugin May return a path as string and mutate operations dict. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See ...
[ "Works", "like", "a", "apispec", "plugin", "May", "return", "a", "path", "as", "string", "and", "mutate", "operations", "dict", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L398-L412
[ "def", "path_helper", "(", "self", ",", "path", "=", "None", ",", "operations", "=", "None", ",", "*", "*", "kwargs", ")", ":", "RE_URL", "=", "re", ".", "compile", "(", "r\"<(?:[^:<>]+:)?([^<>]+)>\"", ")", "path", "=", "RE_URL", ".", "sub", "(", "r\"{...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseApi.operation_helper
May mutate operations. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See :param list methods: A list of methods registered for this path
flask_appbuilder/api/__init__.py
def operation_helper( self, path=None, operations=None, methods=None, func=None, **kwargs ): """May mutate operations. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See :param list methods: A list of methods r...
def operation_helper( self, path=None, operations=None, methods=None, func=None, **kwargs ): """May mutate operations. :param str path: Path to the resource :param dict operations: A `dict` mapping HTTP methods to operation object. See :param list methods: A list of methods r...
[ "May", "mutate", "operations", ".", ":", "param", "str", "path", ":", "Path", "to", "the", "resource", ":", "param", "dict", "operations", ":", "A", "dict", "mapping", "HTTP", "methods", "to", "operation", "object", ".", "See", ":", "param", "list", "met...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L414-L432
[ "def", "operation_helper", "(", "self", ",", "path", "=", "None", ",", "operations", "=", "None", ",", "methods", "=", "None", ",", "func", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "method", "in", "methods", ":", "yaml_doc_string", "=", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseApi.response
Generic HTTP JSON response method :param code: HTTP code (int) :param kwargs: Data structure for response (dict) :return: HTTP Json response
flask_appbuilder/api/__init__.py
def response(code, **kwargs): """ Generic HTTP JSON response method :param code: HTTP code (int) :param kwargs: Data structure for response (dict) :return: HTTP Json response """ _ret_json = jsonify(kwargs) resp = make_response(_ret_json, code) ...
def response(code, **kwargs): """ Generic HTTP JSON response method :param code: HTTP code (int) :param kwargs: Data structure for response (dict) :return: HTTP Json response """ _ret_json = jsonify(kwargs) resp = make_response(_ret_json, code) ...
[ "Generic", "HTTP", "JSON", "response", "method" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L489-L500
[ "def", "response", "(", "code", ",", "*", "*", "kwargs", ")", ":", "_ret_json", "=", "jsonify", "(", "kwargs", ")", "resp", "=", "make_response", "(", "_ret_json", ",", "code", ")", "resp", ".", "headers", "[", "\"Content-Type\"", "]", "=", "\"applicatio...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseModelApi._gen_labels_columns
Auto generates pretty label_columns from list of columns
flask_appbuilder/api/__init__.py
def _gen_labels_columns(self, list_columns): """ Auto generates pretty label_columns from list of columns """ for col in list_columns: if not self.label_columns.get(col): self.label_columns[col] = self._prettify_column(col)
def _gen_labels_columns(self, list_columns): """ Auto generates pretty label_columns from list of columns """ for col in list_columns: if not self.label_columns.get(col): self.label_columns[col] = self._prettify_column(col)
[ "Auto", "generates", "pretty", "label_columns", "from", "list", "of", "columns" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L632-L638
[ "def", "_gen_labels_columns", "(", "self", ",", "list_columns", ")", ":", "for", "col", "in", "list_columns", ":", "if", "not", "self", ".", "label_columns", ".", "get", "(", "col", ")", ":", "self", ".", "label_columns", "[", "col", "]", "=", "self", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseModelApi._label_columns_json
Prepares dict with labels to be JSON serializable
flask_appbuilder/api/__init__.py
def _label_columns_json(self, cols=None): """ Prepares dict with labels to be JSON serializable """ ret = {} cols = cols or [] d = {k: v for (k, v) in self.label_columns.items() if k in cols} for key, value in d.items(): ret[key] = as_unicode(_(val...
def _label_columns_json(self, cols=None): """ Prepares dict with labels to be JSON serializable """ ret = {} cols = cols or [] d = {k: v for (k, v) in self.label_columns.items() if k in cols} for key, value in d.items(): ret[key] = as_unicode(_(val...
[ "Prepares", "dict", "with", "labels", "to", "be", "JSON", "serializable" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L640-L649
[ "def", "_label_columns_json", "(", "self", ",", "cols", "=", "None", ")", ":", "ret", "=", "{", "}", "cols", "=", "cols", "or", "[", "]", "d", "=", "{", "k", ":", "v", "for", "(", "k", ",", "v", ")", "in", "self", ".", "label_columns", ".", "...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._init_titles
Init Titles if not defined
flask_appbuilder/api/__init__.py
def _init_titles(self): """ Init Titles if not defined """ super(ModelRestApi, self)._init_titles() class_name = self.datamodel.model_name if not self.list_title: self.list_title = "List " + self._prettify_name(class_name) if not self.add_title: ...
def _init_titles(self): """ Init Titles if not defined """ super(ModelRestApi, self)._init_titles() class_name = self.datamodel.model_name if not self.list_title: self.list_title = "List " + self._prettify_name(class_name) if not self.add_title: ...
[ "Init", "Titles", "if", "not", "defined" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L873-L887
[ "def", "_init_titles", "(", "self", ")", ":", "super", "(", "ModelRestApi", ",", "self", ")", ".", "_init_titles", "(", ")", "class_name", "=", "self", ".", "datamodel", ".", "model_name", "if", "not", "self", ".", "list_title", ":", "self", ".", "list_t...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._init_properties
Init Properties
flask_appbuilder/api/__init__.py
def _init_properties(self): """ Init Properties """ super(ModelRestApi, self)._init_properties() # Reset init props self.description_columns = self.description_columns or {} self.list_exclude_columns = self.list_exclude_columns or [] self.show_exclude_...
def _init_properties(self): """ Init Properties """ super(ModelRestApi, self)._init_properties() # Reset init props self.description_columns = self.description_columns or {} self.list_exclude_columns = self.list_exclude_columns or [] self.show_exclude_...
[ "Init", "Properties" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L889-L932
[ "def", "_init_properties", "(", "self", ")", ":", "super", "(", "ModelRestApi", ",", "self", ")", ".", "_init_properties", "(", ")", "# Reset init props", "self", ".", "description_columns", "=", "self", ".", "description_columns", "or", "{", "}", "self", ".",...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.info
Endpoint that renders a response for CRUD REST meta data --- get: parameters: - $ref: '#/components/parameters/get_info_schema' responses: 200: description: Item from Model content: application/json: ...
flask_appbuilder/api/__init__.py
def info(self, **kwargs): """ Endpoint that renders a response for CRUD REST meta data --- get: parameters: - $ref: '#/components/parameters/get_info_schema' responses: 200: description: Item from Model content: ...
def info(self, **kwargs): """ Endpoint that renders a response for CRUD REST meta data --- get: parameters: - $ref: '#/components/parameters/get_info_schema' responses: 200: description: Item from Model content: ...
[ "Endpoint", "that", "renders", "a", "response", "for", "CRUD", "REST", "meta", "data", "---", "get", ":", "parameters", ":", "-", "$ref", ":", "#", "/", "components", "/", "parameters", "/", "get_info_schema", "responses", ":", "200", ":", "description", "...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1032-L1068
[ "def", "info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_response", "=", "dict", "(", ")", "_args", "=", "kwargs", ".", "get", "(", "\"rison\"", ",", "{", "}", ")", "self", ".", "set_response_key_mappings", "(", "_response", ",", "self", ".",...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.get
Get item from Model --- get: parameters: - in: path schema: type: integer name: pk - $ref: '#/components/parameters/get_item_schema' responses: 200: description: Item from Model content:...
flask_appbuilder/api/__init__.py
def get(self, pk, **kwargs): """Get item from Model --- get: parameters: - in: path schema: type: integer name: pk - $ref: '#/components/parameters/get_item_schema' responses: 200: description...
def get(self, pk, **kwargs): """Get item from Model --- get: parameters: - in: path schema: type: integer name: pk - $ref: '#/components/parameters/get_item_schema' responses: 200: description...
[ "Get", "item", "from", "Model", "---", "get", ":", "parameters", ":", "-", "in", ":", "path", "schema", ":", "type", ":", "integer", "name", ":", "pk", "-", "$ref", ":", "#", "/", "components", "/", "parameters", "/", "get_item_schema", "responses", ":...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1079-L1144
[ "def", "get", "(", "self", ",", "pk", ",", "*", "*", "kwargs", ")", ":", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", "self", ".", "_base_filters", ")", "if", "not", "item", ":", "return", "self", ".", "response_404", "(", "...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.get_list
Get list of items from Model --- get: parameters: - $ref: '#/components/parameters/get_list_schema' responses: 200: description: Items from Model content: application/json: schema: ...
flask_appbuilder/api/__init__.py
def get_list(self, **kwargs): """Get list of items from Model --- get: parameters: - $ref: '#/components/parameters/get_list_schema' responses: 200: description: Items from Model content: application/json: ...
def get_list(self, **kwargs): """Get list of items from Model --- get: parameters: - $ref: '#/components/parameters/get_list_schema' responses: 200: description: Items from Model content: application/json: ...
[ "Get", "list", "of", "items", "from", "Model", "---", "get", ":", "parameters", ":", "-", "$ref", ":", "#", "/", "components", "/", "parameters", "/", "get_list_schema", "responses", ":", "200", ":", "description", ":", "Items", "from", "Model", "content",...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1156-L1238
[ "def", "get_list", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_response", "=", "dict", "(", ")", "_args", "=", "kwargs", ".", "get", "(", "\"rison\"", ",", "{", "}", ")", "# handle select columns", "select_cols", "=", "_args", ".", "get", "(", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.post
POST item to Model --- post: requestBody: description: Model schema required: true content: application/json: schema: $ref: '#/components/schemas/{{self.__class__.__name__}}.post' responses: ...
flask_appbuilder/api/__init__.py
def post(self): """POST item to Model --- post: requestBody: description: Model schema required: true content: application/json: schema: $ref: '#/components/schemas/{{self.__class__.__name__}}.post' ...
def post(self): """POST item to Model --- post: requestBody: description: Model schema required: true content: application/json: schema: $ref: '#/components/schemas/{{self.__class__.__name__}}.post' ...
[ "POST", "item", "to", "Model", "---", "post", ":", "requestBody", ":", "description", ":", "Model", "schema", "required", ":", "true", "content", ":", "application", "/", "json", ":", "schema", ":", "$ref", ":", "#", "/", "components", "/", "schemas", "/...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1244-L1299
[ "def", "post", "(", "self", ")", ":", "if", "not", "request", ".", "is_json", ":", "return", "self", ".", "response_400", "(", "message", "=", "\"Request is not JSON\"", ")", "try", ":", "item", "=", "self", ".", "add_model_schema", ".", "load", "(", "re...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.put
POST item to Model --- put: parameters: - in: path schema: type: integer name: pk requestBody: description: Model schema required: true content: application/json: schema:...
flask_appbuilder/api/__init__.py
def put(self, pk): """POST item to Model --- put: parameters: - in: path schema: type: integer name: pk requestBody: description: Model schema required: true content: application...
def put(self, pk): """POST item to Model --- put: parameters: - in: path schema: type: integer name: pk requestBody: description: Model schema required: true content: application...
[ "POST", "item", "to", "Model", "---", "put", ":", "parameters", ":", "-", "in", ":", "path", "schema", ":", "type", ":", "integer", "name", ":", "pk", "requestBody", ":", "description", ":", "Model", "schema", "required", ":", "true", "content", ":", "...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1305-L1368
[ "def", "put", "(", "self", ",", "pk", ")", ":", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", "self", ".", "_base_filters", ")", "if", "not", "request", ".", "is_json", ":", "return", "self", ".", "response", "(", "400", ",", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi.delete
Delete item from Model --- delete: parameters: - in: path schema: type: integer name: pk responses: 200: description: Item deleted content: application/json: sche...
flask_appbuilder/api/__init__.py
def delete(self, pk): """Delete item from Model --- delete: parameters: - in: path schema: type: integer name: pk responses: 200: description: Item deleted content: applica...
def delete(self, pk): """Delete item from Model --- delete: parameters: - in: path schema: type: integer name: pk responses: 200: description: Item deleted content: applica...
[ "Delete", "item", "from", "Model", "---", "delete", ":", "parameters", ":", "-", "in", ":", "path", "schema", ":", "type", ":", "integer", "name", ":", "pk", "responses", ":", "200", ":", "description", ":", "Item", "deleted", "content", ":", "applicatio...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1374-L1409
[ "def", "delete", "(", "self", ",", "pk", ")", ":", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", "self", ".", "_base_filters", ")", "if", "not", "item", ":", "return", "self", ".", "response_404", "(", ")", "self", ".", "pre_de...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._handle_page_args
Helper function to handle rison page arguments, sets defaults and impose FAB_API_MAX_PAGE_SIZE :param rison_args: :return: (tuple) page, page_size
flask_appbuilder/api/__init__.py
def _handle_page_args(self, rison_args): """ Helper function to handle rison page arguments, sets defaults and impose FAB_API_MAX_PAGE_SIZE :param rison_args: :return: (tuple) page, page_size """ page = rison_args.get(API_PAGE_INDEX_RIS_KEY, 0...
def _handle_page_args(self, rison_args): """ Helper function to handle rison page arguments, sets defaults and impose FAB_API_MAX_PAGE_SIZE :param rison_args: :return: (tuple) page, page_size """ page = rison_args.get(API_PAGE_INDEX_RIS_KEY, 0...
[ "Helper", "function", "to", "handle", "rison", "page", "arguments", "sets", "defaults", "and", "impose", "FAB_API_MAX_PAGE_SIZE" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1417-L1428
[ "def", "_handle_page_args", "(", "self", ",", "rison_args", ")", ":", "page", "=", "rison_args", ".", "get", "(", "API_PAGE_INDEX_RIS_KEY", ",", "0", ")", "page_size", "=", "rison_args", ".", "get", "(", "API_PAGE_SIZE_RIS_KEY", ",", "self", ".", "page_size", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._handle_order_args
Help function to handle rison order arguments :param rison_args: :return:
flask_appbuilder/api/__init__.py
def _handle_order_args(self, rison_args): """ Help function to handle rison order arguments :param rison_args: :return: """ order_column = rison_args.get(API_ORDER_COLUMN_RIS_KEY, "") order_direction = rison_args.get(API_ORDER_DIRECTION_RIS_KEY, "...
def _handle_order_args(self, rison_args): """ Help function to handle rison order arguments :param rison_args: :return: """ order_column = rison_args.get(API_ORDER_COLUMN_RIS_KEY, "") order_direction = rison_args.get(API_ORDER_DIRECTION_RIS_KEY, "...
[ "Help", "function", "to", "handle", "rison", "order", "arguments" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1438-L1452
[ "def", "_handle_order_args", "(", "self", ",", "rison_args", ")", ":", "order_column", "=", "rison_args", ".", "get", "(", "API_ORDER_COLUMN_RIS_KEY", ",", "\"\"", ")", "order_direction", "=", "rison_args", ".", "get", "(", "API_ORDER_DIRECTION_RIS_KEY", ",", "\"\...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._description_columns_json
Prepares dict with col descriptions to be JSON serializable
flask_appbuilder/api/__init__.py
def _description_columns_json(self, cols=None): """ Prepares dict with col descriptions to be JSON serializable """ ret = {} cols = cols or [] d = {k: v for (k, v) in self.description_columns.items() if k in cols} for key, value in d.items(): ret[k...
def _description_columns_json(self, cols=None): """ Prepares dict with col descriptions to be JSON serializable """ ret = {} cols = cols or [] d = {k: v for (k, v) in self.description_columns.items() if k in cols} for key, value in d.items(): ret[k...
[ "Prepares", "dict", "with", "col", "descriptions", "to", "be", "JSON", "serializable" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1459-L1468
[ "def", "_description_columns_json", "(", "self", ",", "cols", "=", "None", ")", ":", "ret", "=", "{", "}", "cols", "=", "cols", "or", "[", "]", "d", "=", "{", "k", ":", "v", "for", "(", "k", ",", "v", ")", "in", "self", ".", "description_columns"...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._get_field_info
Return a dict with field details ready to serve as a response :param field: marshmallow field :return: dict with field details
flask_appbuilder/api/__init__.py
def _get_field_info(self, field, filter_rel_field, page=None, page_size=None): """ Return a dict with field details ready to serve as a response :param field: marshmallow field :return: dict with field details """ ret = dict() ret["name"] = field....
def _get_field_info(self, field, filter_rel_field, page=None, page_size=None): """ Return a dict with field details ready to serve as a response :param field: marshmallow field :return: dict with field details """ ret = dict() ret["name"] = field....
[ "Return", "a", "dict", "with", "field", "details", "ready", "to", "serve", "as", "a", "response" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1470-L1494
[ "def", "_get_field_info", "(", "self", ",", "field", ",", "filter_rel_field", ",", "page", "=", "None", ",", "page_size", "=", "None", ")", ":", "ret", "=", "dict", "(", ")", "ret", "[", "\"name\"", "]", "=", "field", ".", "name", "ret", "[", "\"labe...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._get_fields_info
Returns a dict with fields detail from a marshmallow schema :param cols: list of columns to show info for :param model_schema: Marshmallow model schema :param filter_rel_fields: expects add_query_rel_fields or edit_query_rel_fields :param ...
flask_appbuilder/api/__init__.py
def _get_fields_info(self, cols, model_schema, filter_rel_fields, **kwargs): """ Returns a dict with fields detail from a marshmallow schema :param cols: list of columns to show info for :param model_schema: Marshmallow model schema :param filter_rel_fields: expe...
def _get_fields_info(self, cols, model_schema, filter_rel_fields, **kwargs): """ Returns a dict with fields detail from a marshmallow schema :param cols: list of columns to show info for :param model_schema: Marshmallow model schema :param filter_rel_fields: expe...
[ "Returns", "a", "dict", "with", "fields", "detail", "from", "a", "marshmallow", "schema" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1496-L1523
[ "def", "_get_fields_info", "(", "self", ",", "cols", ",", "model_schema", ",", "filter_rel_fields", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "list", "(", ")", "for", "col", "in", "cols", ":", "page", "=", "page_size", "=", "None", "col_args", "="...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._get_list_related_field
Return a list of values for a related field :param field: Marshmallow field :param filter_rel_field: Filters for the related field :param page: The page index :param page_size: The page size :return: (int, list) total record count and list of dict with id and value
flask_appbuilder/api/__init__.py
def _get_list_related_field( self, field, filter_rel_field, page=None, page_size=None ): """ Return a list of values for a related field :param field: Marshmallow field :param filter_rel_field: Filters for the related field :param page: The page index :pa...
def _get_list_related_field( self, field, filter_rel_field, page=None, page_size=None ): """ Return a list of values for a related field :param field: Marshmallow field :param filter_rel_field: Filters for the related field :param page: The page index :pa...
[ "Return", "a", "list", "of", "values", "for", "a", "related", "field" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1525-L1554
[ "def", "_get_list_related_field", "(", "self", ",", "field", ",", "filter_rel_field", ",", "page", "=", "None", ",", "page_size", "=", "None", ")", ":", "ret", "=", "list", "(", ")", "if", "isinstance", "(", "field", ",", "Related", ")", "or", "isinstanc...
c293734c1b86e176a3ba57ee2deab6676d125576
train
ModelRestApi._merge_update_item
Merge a model with a python data structure This is useful to turn PUT method into a PATCH also :param model_item: SQLA Model :param data: python data structure :return: python data structure
flask_appbuilder/api/__init__.py
def _merge_update_item(self, model_item, data): """ Merge a model with a python data structure This is useful to turn PUT method into a PATCH also :param model_item: SQLA Model :param data: python data structure :return: python data structure """ d...
def _merge_update_item(self, model_item, data): """ Merge a model with a python data structure This is useful to turn PUT method into a PATCH also :param model_item: SQLA Model :param data: python data structure :return: python data structure """ d...
[ "Merge", "a", "model", "with", "a", "python", "data", "structure", "This", "is", "useful", "to", "turn", "PUT", "method", "into", "a", "PATCH", "also", ":", "param", "model_item", ":", "SQLA", "Model", ":", "param", "data", ":", "python", "data", "struct...
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/__init__.py#L1556-L1568
[ "def", "_merge_update_item", "(", "self", ",", "model_item", ",", "data", ")", ":", "data_item", "=", "self", ".", "edit_model_schema", ".", "dump", "(", "model_item", ",", "many", "=", "False", ")", ".", "data", "for", "_col", "in", "self", ".", "edit_c...
c293734c1b86e176a3ba57ee2deab6676d125576
train
GeneralModelConverter._convert_many_to_one
Creates a WTForm field for many to one related fields, will use a Select box based on a query. Will only work with SQLAlchemy interface.
flask_appbuilder/forms.py
def _convert_many_to_one(self, col_name, label, description, lst_validators, filter_rel_fields, form_props): """ Creates a WTForm field for many to one related fields, will use a Select box based on a query. Will only ...
def _convert_many_to_one(self, col_name, label, description, lst_validators, filter_rel_fields, form_props): """ Creates a WTForm field for many to one related fields, will use a Select box based on a query. Will only ...
[ "Creates", "a", "WTForm", "field", "for", "many", "to", "one", "related", "fields", "will", "use", "a", "Select", "box", "based", "on", "a", "query", ".", "Will", "only", "work", "with", "SQLAlchemy", "interface", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/forms.py#L136-L161
[ "def", "_convert_many_to_one", "(", "self", ",", "col_name", ",", "label", ",", "description", ",", "lst_validators", ",", "filter_rel_fields", ",", "form_props", ")", ":", "query_func", "=", "self", ".", "_get_related_query_func", "(", "col_name", ",", "filter_re...
c293734c1b86e176a3ba57ee2deab6676d125576
train
GeneralModelConverter.create_form
Converts a model to a form given :param label_columns: A dictionary with the column's labels. :param inc_columns: A list with the columns to include :param description_columns: A dictionary with a description for cols. :par...
flask_appbuilder/forms.py
def create_form(self, label_columns=None, inc_columns=None, description_columns=None, validators_columns=None, extra_fields=None, filter_rel_fields=None): """ Converts a model to a form given :param label_columns: A dictionary with...
def create_form(self, label_columns=None, inc_columns=None, description_columns=None, validators_columns=None, extra_fields=None, filter_rel_fields=None): """ Converts a model to a form given :param label_columns: A dictionary with...
[ "Converts", "a", "model", "to", "a", "form", "given" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/forms.py#L236-L277
[ "def", "create_form", "(", "self", ",", "label_columns", "=", "None", ",", "inc_columns", "=", "None", ",", "description_columns", "=", "None", ",", "validators_columns", "=", "None", ",", "extra_fields", "=", "None", ",", "filter_rel_fields", "=", "None", ")"...
c293734c1b86e176a3ba57ee2deab6676d125576
train
GenericSession.get
Returns the object for the key Override it for efficiency.
flask_appbuilder/models/generic/__init__.py
def get(self, pk): """ Returns the object for the key Override it for efficiency. """ for item in self.store.get(self.query_class): # coverts pk value to correct type pk = item.properties[item.pk].col_type(pk) if getattr(item, item.pk) ...
def get(self, pk): """ Returns the object for the key Override it for efficiency. """ for item in self.store.get(self.query_class): # coverts pk value to correct type pk = item.properties[item.pk].col_type(pk) if getattr(item, item.pk) ...
[ "Returns", "the", "object", "for", "the", "key", "Override", "it", "for", "efficiency", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/generic/__init__.py#L144-L153
[ "def", "get", "(", "self", ",", "pk", ")", ":", "for", "item", "in", "self", ".", "store", ".", "get", "(", "self", ".", "query_class", ")", ":", "# coverts pk value to correct type", "pk", "=", "item", ".", "properties", "[", "item", ".", "pk", "]", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
GenericSession.query
SQLAlchemy query like method
flask_appbuilder/models/generic/__init__.py
def query(self, model_cls): """ SQLAlchemy query like method """ self._filters_cmd = list() self.query_filters = list() self._order_by_cmd = None self._offset = 0 self._limit = 0 self.query_class = model_cls._name return self
def query(self, model_cls): """ SQLAlchemy query like method """ self._filters_cmd = list() self.query_filters = list() self._order_by_cmd = None self._offset = 0 self._limit = 0 self.query_class = model_cls._name return self
[ "SQLAlchemy", "query", "like", "method" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/generic/__init__.py#L155-L165
[ "def", "query", "(", "self", ",", "model_cls", ")", ":", "self", ".", "_filters_cmd", "=", "list", "(", ")", "self", ".", "query_filters", "=", "list", "(", ")", "self", ".", "_order_by_cmd", "=", "None", "self", ".", "_offset", "=", "0", "self", "."...
c293734c1b86e176a3ba57ee2deab6676d125576
train
GenericSession.all
SQLA like 'all' method, will populate all rows and apply all filters and orders to it.
flask_appbuilder/models/generic/__init__.py
def all(self): """ SQLA like 'all' method, will populate all rows and apply all filters and orders to it. """ items = list() if not self._filters_cmd: items = self.store.get(self.query_class) else: for item in self.store.get(self.qu...
def all(self): """ SQLA like 'all' method, will populate all rows and apply all filters and orders to it. """ items = list() if not self._filters_cmd: items = self.store.get(self.query_class) else: for item in self.store.get(self.qu...
[ "SQLA", "like", "all", "method", "will", "populate", "all", "rows", "and", "apply", "all", "filters", "and", "orders", "to", "it", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/generic/__init__.py#L351-L373
[ "def", "all", "(", "self", ")", ":", "items", "=", "list", "(", ")", "if", "not", "self", ".", "_filters_cmd", ":", "items", "=", "self", ".", "store", ".", "get", "(", "self", ".", "query_class", ")", "else", ":", "for", "item", "in", "self", "....
c293734c1b86e176a3ba57ee2deab6676d125576
train
TemplateFilters.link_order_filter
Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc'
flask_appbuilder/filters.py
def link_order_filter(self, column, modelview_name): """ Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc' """ new_args = request.view_args.copy() args = request.args.copy() if ("_oc_" + modelview_name) in args: ...
def link_order_filter(self, column, modelview_name): """ Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc' """ new_args = request.view_args.copy() args = request.args.copy() if ("_oc_" + modelview_name) in args: ...
[ "Arguments", "are", "passed", "like", ":", "_oc_<VIEW_NAME", ">", "=", "<COL_NAME", ">", "&_od_<VIEW_NAME", ">", "=", "asc", "|", "desc" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/filters.py#L44-L63
[ "def", "link_order_filter", "(", "self", ",", "column", ",", "modelview_name", ")", ":", "new_args", "=", "request", ".", "view_args", ".", "copy", "(", ")", "args", "=", "request", ".", "args", ".", "copy", "(", ")", "if", "(", "\"_oc_\"", "+", "model...
c293734c1b86e176a3ba57ee2deab6676d125576
train
TemplateFilters.link_page_filter
Arguments are passed like: page_<VIEW_NAME>=<PAGE_NUMBER>
flask_appbuilder/filters.py
def link_page_filter(self, page, modelview_name): """ Arguments are passed like: page_<VIEW_NAME>=<PAGE_NUMBER> """ new_args = request.view_args.copy() args = request.args.copy() args["page_" + modelview_name] = page return url_for( request.endpoin...
def link_page_filter(self, page, modelview_name): """ Arguments are passed like: page_<VIEW_NAME>=<PAGE_NUMBER> """ new_args = request.view_args.copy() args = request.args.copy() args["page_" + modelview_name] = page return url_for( request.endpoin...
[ "Arguments", "are", "passed", "like", ":", "page_<VIEW_NAME", ">", "=", "<PAGE_NUMBER", ">" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/filters.py#L66-L76
[ "def", "link_page_filter", "(", "self", ",", "page", ",", "modelview_name", ")", ":", "new_args", "=", "request", ".", "view_args", ".", "copy", "(", ")", "args", "=", "request", ".", "args", ".", "copy", "(", ")", "args", "[", "\"page_\"", "+", "model...
c293734c1b86e176a3ba57ee2deab6676d125576
train
TemplateFilters.link_page_size_filter
Arguments are passed like: psize_<VIEW_NAME>=<PAGE_NUMBER>
flask_appbuilder/filters.py
def link_page_size_filter(self, page_size, modelview_name): """ Arguments are passed like: psize_<VIEW_NAME>=<PAGE_NUMBER> """ new_args = request.view_args.copy() args = request.args.copy() args["psize_" + modelview_name] = page_size return url_for( re...
def link_page_size_filter(self, page_size, modelview_name): """ Arguments are passed like: psize_<VIEW_NAME>=<PAGE_NUMBER> """ new_args = request.view_args.copy() args = request.args.copy() args["psize_" + modelview_name] = page_size return url_for( re...
[ "Arguments", "are", "passed", "like", ":", "psize_<VIEW_NAME", ">", "=", "<PAGE_NUMBER", ">" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/filters.py#L79-L89
[ "def", "link_page_size_filter", "(", "self", ",", "page_size", ",", "modelview_name", ")", ":", "new_args", "=", "request", ".", "view_args", ".", "copy", "(", ")", "args", "=", "request", ".", "args", ".", "copy", "(", ")", "args", "[", "\"psize_\"", "+...
c293734c1b86e176a3ba57ee2deab6676d125576
train
reset_password
Resets a user's password
flask_appbuilder/console.py
def reset_password(app, appbuilder, username, password): """ Resets a user's password """ _appbuilder = import_application(app, appbuilder) user = _appbuilder.sm.find_user(username=username) if not user: click.echo("User {0} not found.".format(username)) else: _appbuilder...
def reset_password(app, appbuilder, username, password): """ Resets a user's password """ _appbuilder = import_application(app, appbuilder) user = _appbuilder.sm.find_user(username=username) if not user: click.echo("User {0} not found.".format(username)) else: _appbuilder...
[ "Resets", "a", "user", "s", "password" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L96-L106
[ "def", "reset_password", "(", "app", ",", "appbuilder", ",", "username", ",", "password", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "user", "=", "_appbuilder", ".", "sm", ".", "find_user", "(", "username", "=", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
create_admin
Creates an admin user
flask_appbuilder/console.py
def create_admin(app, appbuilder, username, firstname, lastname, email, password): """ Creates an admin user """ auth_type = { c.AUTH_DB: "Database Authentications", c.AUTH_OID: "OpenID Authentication", c.AUTH_LDAP: "LDAP Authentication", c.AUTH_REMOTE_USER: "WebServe...
def create_admin(app, appbuilder, username, firstname, lastname, email, password): """ Creates an admin user """ auth_type = { c.AUTH_DB: "Database Authentications", c.AUTH_OID: "OpenID Authentication", c.AUTH_LDAP: "LDAP Authentication", c.AUTH_REMOTE_USER: "WebServe...
[ "Creates", "an", "admin", "user" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L117-L144
[ "def", "create_admin", "(", "app", ",", "appbuilder", ",", "username", ",", "firstname", ",", "lastname", ",", "email", ",", "password", ")", ":", "auth_type", "=", "{", "c", ".", "AUTH_DB", ":", "\"Database Authentications\"", ",", "c", ".", "AUTH_OID", "...
c293734c1b86e176a3ba57ee2deab6676d125576
train
create_user
Create a user
flask_appbuilder/console.py
def create_user(app, appbuilder, role, username, firstname, lastname, email, password): """ Create a user """ _appbuilder = import_application(app, appbuilder) role_object = _appbuilder.sm.find_role(role) user = _appbuilder.sm.add_user( username, firstname, lastname, email, role_obje...
def create_user(app, appbuilder, role, username, firstname, lastname, email, password): """ Create a user """ _appbuilder = import_application(app, appbuilder) role_object = _appbuilder.sm.find_role(role) user = _appbuilder.sm.add_user( username, firstname, lastname, email, role_obje...
[ "Create", "a", "user" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L156-L168
[ "def", "create_user", "(", "app", ",", "appbuilder", ",", "role", ",", "username", ",", "firstname", ",", "lastname", ",", "email", ",", "password", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "role_object", "=", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
run
Runs Flask dev web server.
flask_appbuilder/console.py
def run(app, appbuilder, host, port, debug): """ Runs Flask dev web server. """ _appbuilder = import_application(app, appbuilder) _appbuilder.get_app.run(host=host, port=port, debug=debug)
def run(app, appbuilder, host, port, debug): """ Runs Flask dev web server. """ _appbuilder = import_application(app, appbuilder) _appbuilder.get_app.run(host=host, port=port, debug=debug)
[ "Runs", "Flask", "dev", "web", "server", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L177-L182
[ "def", "run", "(", "app", ",", "appbuilder", ",", "host", ",", "port", ",", "debug", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "_appbuilder", ".", "get_app", ".", "run", "(", "host", "=", "host", ",", "port...
c293734c1b86e176a3ba57ee2deab6676d125576
train
create_db
Create all your database objects (SQLAlchemy specific).
flask_appbuilder/console.py
def create_db(app, appbuilder): """ Create all your database objects (SQLAlchemy specific). """ from flask_appbuilder.models.sqla import Base _appbuilder = import_application(app, appbuilder) engine = _appbuilder.get_session.get_bind(mapper=None, clause=None) Base.metadata.create_all(en...
def create_db(app, appbuilder): """ Create all your database objects (SQLAlchemy specific). """ from flask_appbuilder.models.sqla import Base _appbuilder = import_application(app, appbuilder) engine = _appbuilder.get_session.get_bind(mapper=None, clause=None) Base.metadata.create_all(en...
[ "Create", "all", "your", "database", "objects", "(", "SQLAlchemy", "specific", ")", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L188-L197
[ "def", "create_db", "(", "app", ",", "appbuilder", ")", ":", "from", "flask_appbuilder", ".", "models", ".", "sqla", "import", "Base", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "engine", "=", "_appbuilder", ".", "get_session...
c293734c1b86e176a3ba57ee2deab6676d125576
train
version
Flask-AppBuilder package version
flask_appbuilder/console.py
def version(app, appbuilder): """ Flask-AppBuilder package version """ _appbuilder = import_application(app, appbuilder) click.echo( click.style( "F.A.B Version: {0}.".format(_appbuilder.version), bg="blue", fg="white" ) )
def version(app, appbuilder): """ Flask-AppBuilder package version """ _appbuilder = import_application(app, appbuilder) click.echo( click.style( "F.A.B Version: {0}.".format(_appbuilder.version), bg="blue", fg="white" ) )
[ "Flask", "-", "AppBuilder", "package", "version" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L203-L212
[ "def", "version", "(", "app", ",", "appbuilder", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "click", ".", "echo", "(", "click", ".", "style", "(", "\"F.A.B Version: {0}.\"", ".", "format", "(", "_appbuilder", ".",...
c293734c1b86e176a3ba57ee2deab6676d125576
train
security_cleanup
Cleanup unused permissions from views and roles.
flask_appbuilder/console.py
def security_cleanup(app, appbuilder): """ Cleanup unused permissions from views and roles. """ _appbuilder = import_application(app, appbuilder) _appbuilder.security_cleanup() click.echo(click.style("Finished security cleanup", fg="green"))
def security_cleanup(app, appbuilder): """ Cleanup unused permissions from views and roles. """ _appbuilder = import_application(app, appbuilder) _appbuilder.security_cleanup() click.echo(click.style("Finished security cleanup", fg="green"))
[ "Cleanup", "unused", "permissions", "from", "views", "and", "roles", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L218-L224
[ "def", "security_cleanup", "(", "app", ",", "appbuilder", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "_appbuilder", ".", "security_cleanup", "(", ")", "click", ".", "echo", "(", "click", ".", "style", "(", "\"Fini...
c293734c1b86e176a3ba57ee2deab6676d125576
train
list_views
List all registered views
flask_appbuilder/console.py
def list_views(app, appbuilder): """ List all registered views """ _appbuilder = import_application(app, appbuilder) echo_header("List of registered views") for view in _appbuilder.baseviews: click.echo( "View:{0} | Route:{1} | Perms:{2}".format( view.__cl...
def list_views(app, appbuilder): """ List all registered views """ _appbuilder = import_application(app, appbuilder) echo_header("List of registered views") for view in _appbuilder.baseviews: click.echo( "View:{0} | Route:{1} | Perms:{2}".format( view.__cl...
[ "List", "all", "registered", "views" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L230-L241
[ "def", "list_views", "(", "app", ",", "appbuilder", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "echo_header", "(", "\"List of registered views\"", ")", "for", "view", "in", "_appbuilder", ".", "baseviews", ":", "click...
c293734c1b86e176a3ba57ee2deab6676d125576
train
list_users
List all users on the database
flask_appbuilder/console.py
def list_users(app, appbuilder): """ List all users on the database """ _appbuilder = import_application(app, appbuilder) echo_header("List of users") for user in _appbuilder.sm.get_all_users(): click.echo( "username:{0} | email:{1} | role:{2}".format( use...
def list_users(app, appbuilder): """ List all users on the database """ _appbuilder = import_application(app, appbuilder) echo_header("List of users") for user in _appbuilder.sm.get_all_users(): click.echo( "username:{0} | email:{1} | role:{2}".format( use...
[ "List", "all", "users", "on", "the", "database" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L247-L258
[ "def", "list_users", "(", "app", ",", "appbuilder", ")", ":", "_appbuilder", "=", "import_application", "(", "app", ",", "appbuilder", ")", "echo_header", "(", "\"List of users\"", ")", "for", "user", "in", "_appbuilder", ".", "sm", ".", "get_all_users", "(", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
collect_static
Copies flask-appbuilder static files to your projects static folder
flask_appbuilder/console.py
def collect_static(static_folder): """ Copies flask-appbuilder static files to your projects static folder """ appbuilder_static_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "static/appbuilder" ) app_static_path = os.path.join(os.getcwd(), static_folder) if no...
def collect_static(static_folder): """ Copies flask-appbuilder static files to your projects static folder """ appbuilder_static_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "static/appbuilder" ) app_static_path = os.path.join(os.getcwd(), static_folder) if no...
[ "Copies", "flask", "-", "appbuilder", "static", "files", "to", "your", "projects", "static", "folder" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/console.py#L388-L413
[ "def", "collect_static", "(", "static_folder", ")", ":", "appbuilder_static_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "\"static/appbuilder\"",...
c293734c1b86e176a3ba57ee2deab6676d125576
train
aggregate_avg
Function to use on Group by Charts. accepts a list and returns the average of the list's items
flask_appbuilder/models/group.py
def aggregate_avg(items, col): """ Function to use on Group by Charts. accepts a list and returns the average of the list's items """ try: return aggregate_sum(items, col) / aggregate_count(items, col) except Exception: log.warning(c.LOGMSG_WAR_DBI_AVG_ZERODIV) re...
def aggregate_avg(items, col): """ Function to use on Group by Charts. accepts a list and returns the average of the list's items """ try: return aggregate_sum(items, col) / aggregate_count(items, col) except Exception: log.warning(c.LOGMSG_WAR_DBI_AVG_ZERODIV) re...
[ "Function", "to", "use", "on", "Group", "by", "Charts", ".", "accepts", "a", "list", "and", "returns", "the", "average", "of", "the", "list", "s", "items" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/group.py#L51-L60
[ "def", "aggregate_avg", "(", "items", ",", "col", ")", ":", "try", ":", "return", "aggregate_sum", "(", "items", ",", "col", ")", "/", "aggregate_count", "(", "items", ",", "col", ")", "except", "Exception", ":", "log", ".", "warning", "(", "c", ".", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseProcessData.to_json
Will return a dict with Google JSON structure for charts The Google structure:: { cols: [{id:<COL_NAME>, label:<LABEL FOR COL>, type: <COL TYPE>}, ...] rows: [{c: [{v: <COL VALUE}, ...], ... ] } :param data: :...
flask_appbuilder/models/group.py
def to_json(self, data, labels=None): """ Will return a dict with Google JSON structure for charts The Google structure:: { cols: [{id:<COL_NAME>, label:<LABEL FOR COL>, type: <COL TYPE>}, ...] rows: [{c: [{v: <COL VALUE}, ...], ....
def to_json(self, data, labels=None): """ Will return a dict with Google JSON structure for charts The Google structure:: { cols: [{id:<COL_NAME>, label:<LABEL FOR COL>, type: <COL TYPE>}, ...] rows: [{c: [{v: <COL VALUE}, ...], ....
[ "Will", "return", "a", "dict", "with", "Google", "JSON", "structure", "for", "charts" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/group.py#L267-L315
[ "def", "to_json", "(", "self", ",", "data", ",", "labels", "=", "None", ")", ":", "labels", "=", "labels", "or", "dict", "(", ")", "json_data", "=", "dict", "(", ")", "json_data", "[", "\"cols\"", "]", "=", "[", "]", "# Create Structure to identify the g...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseView.create_blueprint
Create Flask blueprint. You will generally not use it :param appbuilder: the AppBuilder object :param endpoint: endpoint override for this blueprint, will assume class name if not provided :param static_folder: the relative...
flask_appbuilder/baseviews.py
def create_blueprint(self, appbuilder, endpoint=None, static_folder=None): """ Create Flask blueprint. You will generally not use it :param appbuilder: the AppBuilder object :param endpoint: endpoint override for this blueprint, w...
def create_blueprint(self, appbuilder, endpoint=None, static_folder=None): """ Create Flask blueprint. You will generally not use it :param appbuilder: the AppBuilder object :param endpoint: endpoint override for this blueprint, w...
[ "Create", "Flask", "blueprint", ".", "You", "will", "generally", "not", "use", "it" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L120-L160
[ "def", "create_blueprint", "(", "self", ",", "appbuilder", ",", "endpoint", "=", "None", ",", "static_folder", "=", "None", ")", ":", "# Store appbuilder instance", "self", ".", "appbuilder", "=", "appbuilder", "# If endpoint name is not provided, get it from the class na...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseView.render_template
Use this method on your own endpoints, will pass the extra_args to the templates. :param template: The template relative path :param kwargs: arguments to be passed to the template
flask_appbuilder/baseviews.py
def render_template(self, template, **kwargs): """ Use this method on your own endpoints, will pass the extra_args to the templates. :param template: The template relative path :param kwargs: arguments to be passed to the template """ kwargs["base...
def render_template(self, template, **kwargs): """ Use this method on your own endpoints, will pass the extra_args to the templates. :param template: The template relative path :param kwargs: arguments to be passed to the template """ kwargs["base...
[ "Use", "this", "method", "on", "your", "own", "endpoints", "will", "pass", "the", "extra_args", "to", "the", "templates", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L172-L184
[ "def", "render_template", "(", "self", ",", "template", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"base_template\"", "]", "=", "self", ".", "appbuilder", ".", "base_template", "kwargs", "[", "\"appbuilder\"", "]", "=", "self", ".", "appbuilder", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseView.update_redirect
Call it on your own endpoint's to update the back history navigation. If you bypass it, the next submit or back will go over it.
flask_appbuilder/baseviews.py
def update_redirect(self): """ Call it on your own endpoint's to update the back history navigation. If you bypass it, the next submit or back will go over it. """ page_history = Stack(session.get("page_history", [])) page_history.push(request.url) session...
def update_redirect(self): """ Call it on your own endpoint's to update the back history navigation. If you bypass it, the next submit or back will go over it. """ page_history = Stack(session.get("page_history", [])) page_history.push(request.url) session...
[ "Call", "it", "on", "your", "own", "endpoint", "s", "to", "update", "the", "back", "history", "navigation", ".", "If", "you", "bypass", "it", "the", "next", "submit", "or", "back", "will", "go", "over", "it", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L208-L215
[ "def", "update_redirect", "(", "self", ")", ":", "page_history", "=", "Stack", "(", "session", ".", "get", "(", "\"page_history\"", ",", "[", "]", ")", ")", "page_history", ".", "push", "(", "request", ".", "url", ")", "session", "[", "\"page_history\"", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseView.get_redirect
Returns the previous url.
flask_appbuilder/baseviews.py
def get_redirect(self): """ Returns the previous url. """ index_url = self.appbuilder.get_url_for_index page_history = Stack(session.get("page_history", [])) if page_history.pop() is None: return index_url session["page_history"] = page_history.to...
def get_redirect(self): """ Returns the previous url. """ index_url = self.appbuilder.get_url_for_index page_history = Stack(session.get("page_history", [])) if page_history.pop() is None: return index_url session["page_history"] = page_history.to...
[ "Returns", "the", "previous", "url", "." ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L217-L228
[ "def", "get_redirect", "(", "self", ")", ":", "index_url", "=", "self", ".", "appbuilder", ".", "get_url_for_index", "page_history", "=", "Stack", "(", "session", ".", "get", "(", "\"page_history\"", ",", "[", "]", ")", ")", "if", "page_history", ".", "pop...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseModelView._label_columns_json
Prepares dict with labels to be JSON serializable
flask_appbuilder/baseviews.py
def _label_columns_json(self): """ Prepares dict with labels to be JSON serializable """ ret = {} for key, value in list(self.label_columns.items()): ret[key] = as_unicode(value.encode("UTF-8")) return ret
def _label_columns_json(self): """ Prepares dict with labels to be JSON serializable """ ret = {} for key, value in list(self.label_columns.items()): ret[key] = as_unicode(value.encode("UTF-8")) return ret
[ "Prepares", "dict", "with", "labels", "to", "be", "JSON", "serializable" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L487-L494
[ "def", "_label_columns_json", "(", "self", ")", ":", "ret", "=", "{", "}", "for", "key", ",", "value", "in", "list", "(", "self", ".", "label_columns", ".", "items", "(", ")", ")", ":", "ret", "[", "key", "]", "=", "as_unicode", "(", "value", ".", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._init_forms
Init forms for Add and Edit
flask_appbuilder/baseviews.py
def _init_forms(self): """ Init forms for Add and Edit """ super(BaseCRUDView, self)._init_forms() conv = GeneralModelConverter(self.datamodel) if not self.add_form: self.add_form = conv.create_form( self.label_columns, self...
def _init_forms(self): """ Init forms for Add and Edit """ super(BaseCRUDView, self)._init_forms() conv = GeneralModelConverter(self.datamodel) if not self.add_form: self.add_form = conv.create_form( self.label_columns, self...
[ "Init", "forms", "for", "Add", "and", "Edit" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L705-L728
[ "def", "_init_forms", "(", "self", ")", ":", "super", "(", "BaseCRUDView", ",", "self", ")", ".", "_init_forms", "(", ")", "conv", "=", "GeneralModelConverter", "(", "self", ".", "datamodel", ")", "if", "not", "self", ".", "add_form", ":", "self", ".", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._init_properties
Init Properties
flask_appbuilder/baseviews.py
def _init_properties(self): """ Init Properties """ super(BaseCRUDView, self)._init_properties() # Reset init props self.related_views = self.related_views or [] self._related_views = self._related_views or [] self.description_columns = self.descriptio...
def _init_properties(self): """ Init Properties """ super(BaseCRUDView, self)._init_properties() # Reset init props self.related_views = self.related_views or [] self._related_views = self._related_views or [] self.description_columns = self.descriptio...
[ "Init", "Properties" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L746-L802
[ "def", "_init_properties", "(", "self", ")", ":", "super", "(", "BaseCRUDView", ",", "self", ")", ".", "_init_properties", "(", ")", "# Reset init props", "self", ".", "related_views", "=", "self", ".", "related_views", "or", "[", "]", "self", ".", "_related...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._get_related_views_widgets
:return: Returns a dict with 'related_views' key with a list of Model View widgets
flask_appbuilder/baseviews.py
def _get_related_views_widgets( self, item, orders=None, pages=None, page_sizes=None, widgets=None, **args ): """ :return: Returns a dict with 'related_views' key with a list of Model View widgets """ widgets = widgets or {} widgets...
def _get_related_views_widgets( self, item, orders=None, pages=None, page_sizes=None, widgets=None, **args ): """ :return: Returns a dict with 'related_views' key with a list of Model View widgets """ widgets = widgets or {} widgets...
[ ":", "return", ":", "Returns", "a", "dict", "with", "related_views", "key", "with", "a", "list", "of", "Model", "View", "widgets" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L851-L876
[ "def", "_get_related_views_widgets", "(", "self", ",", "item", ",", "orders", "=", "None", ",", "pages", "=", "None", ",", "page_sizes", "=", "None", ",", "widgets", "=", "None", ",", "*", "*", "args", ")", ":", "widgets", "=", "widgets", "or", "{", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._get_list_widget
get joined base filter and current active filter for query
flask_appbuilder/baseviews.py
def _get_list_widget( self, filters, actions=None, order_column="", order_direction="", page=None, page_size=None, widgets=None, **args ): """ get joined base filter and current active filter for query """ widgets = widgets or ...
def _get_list_widget( self, filters, actions=None, order_column="", order_direction="", page=None, page_size=None, widgets=None, **args ): """ get joined base filter and current active filter for query """ widgets = widgets or ...
[ "get", "joined", "base", "filter", "and", "current", "active", "filter", "for", "query" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L885-L930
[ "def", "_get_list_widget", "(", "self", ",", "filters", ",", "actions", "=", "None", ",", "order_column", "=", "\"\"", ",", "order_direction", "=", "\"\"", ",", "page", "=", "None", ",", "page_size", "=", "None", ",", "widgets", "=", "None", ",", "*", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._list
list function logic, override to implement different logic returns list and search widget
flask_appbuilder/baseviews.py
def _list(self): """ list function logic, override to implement different logic returns list and search widget """ if get_order_args().get(self.__class__.__name__): order_column, order_direction = get_order_args().get( self.__class__.__name__ ...
def _list(self): """ list function logic, override to implement different logic returns list and search widget """ if get_order_args().get(self.__class__.__name__): order_column, order_direction = get_order_args().get( self.__class__.__name__ ...
[ "list", "function", "logic", "override", "to", "implement", "different", "logic", "returns", "list", "and", "search", "widget" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L991-L1014
[ "def", "_list", "(", "self", ")", ":", "if", "get_order_args", "(", ")", ".", "get", "(", "self", ".", "__class__", ".", "__name__", ")", ":", "order_column", ",", "order_direction", "=", "get_order_args", "(", ")", ".", "get", "(", "self", ".", "__cla...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._show
show function logic, override to implement different logic returns show and related list widget
flask_appbuilder/baseviews.py
def _show(self, pk): """ show function logic, override to implement different logic returns show and related list widget """ pages = get_page_args() page_sizes = get_page_size_args() orders = get_order_args() item = self.datamodel.get(pk, self._ba...
def _show(self, pk): """ show function logic, override to implement different logic returns show and related list widget """ pages = get_page_args() page_sizes = get_page_size_args() orders = get_order_args() item = self.datamodel.get(pk, self._ba...
[ "show", "function", "logic", "override", "to", "implement", "different", "logic", "returns", "show", "and", "related", "list", "widget" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L1016-L1032
[ "def", "_show", "(", "self", ",", "pk", ")", ":", "pages", "=", "get_page_args", "(", ")", "page_sizes", "=", "get_page_size_args", "(", ")", "orders", "=", "get_order_args", "(", ")", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", ...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._add
Add function logic, override to implement different logic returns add widget or None
flask_appbuilder/baseviews.py
def _add(self): """ Add function logic, override to implement different logic returns add widget or None """ is_valid_form = True get_filter_args(self._filters) exclude_cols = self._filters.get_relation_cols() form = self.add_form.refresh() ...
def _add(self): """ Add function logic, override to implement different logic returns add widget or None """ is_valid_form = True get_filter_args(self._filters) exclude_cols = self._filters.get_relation_cols() form = self.add_form.refresh() ...
[ "Add", "function", "logic", "override", "to", "implement", "different", "logic", "returns", "add", "widget", "or", "None" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L1034-L1065
[ "def", "_add", "(", "self", ")", ":", "is_valid_form", "=", "True", "get_filter_args", "(", "self", ".", "_filters", ")", "exclude_cols", "=", "self", ".", "_filters", ".", "get_relation_cols", "(", ")", "form", "=", "self", ".", "add_form", ".", "refresh"...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._edit
Edit function logic, override to implement different logic returns Edit widget and related list or None
flask_appbuilder/baseviews.py
def _edit(self, pk): """ Edit function logic, override to implement different logic returns Edit widget and related list or None """ is_valid_form = True pages = get_page_args() page_sizes = get_page_size_args() orders = get_order_args() ge...
def _edit(self, pk): """ Edit function logic, override to implement different logic returns Edit widget and related list or None """ is_valid_form = True pages = get_page_args() page_sizes = get_page_size_args() orders = get_order_args() ge...
[ "Edit", "function", "logic", "override", "to", "implement", "different", "logic", "returns", "Edit", "widget", "and", "related", "list", "or", "None" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L1067-L1123
[ "def", "_edit", "(", "self", ",", "pk", ")", ":", "is_valid_form", "=", "True", "pages", "=", "get_page_args", "(", ")", "page_sizes", "=", "get_page_size_args", "(", ")", "orders", "=", "get_order_args", "(", ")", "get_filter_args", "(", "self", ".", "_fi...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._delete
Delete function logic, override to implement different logic deletes the record with primary_key = pk :param pk: record primary key to delete
flask_appbuilder/baseviews.py
def _delete(self, pk): """ Delete function logic, override to implement different logic deletes the record with primary_key = pk :param pk: record primary key to delete """ item = self.datamodel.get(pk, self._base_filters) if not item:...
def _delete(self, pk): """ Delete function logic, override to implement different logic deletes the record with primary_key = pk :param pk: record primary key to delete """ item = self.datamodel.get(pk, self._base_filters) if not item:...
[ "Delete", "function", "logic", "override", "to", "implement", "different", "logic", "deletes", "the", "record", "with", "primary_key", "=", "pk" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L1125-L1144
[ "def", "_delete", "(", "self", ",", "pk", ")", ":", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", "self", ".", "_base_filters", ")", "if", "not", "item", ":", "abort", "(", "404", ")", "try", ":", "self", ".", "pre_delete", "...
c293734c1b86e176a3ba57ee2deab6676d125576
train
BaseCRUDView._fill_form_exclude_cols
fill the form with the suppressed cols, generated from exclude_cols
flask_appbuilder/baseviews.py
def _fill_form_exclude_cols(self, exclude_cols, form): """ fill the form with the suppressed cols, generated from exclude_cols """ for filter_key in exclude_cols: filter_value = self._filters.get_filter_value(filter_key) rel_obj = self.datamodel.get_related_ob...
def _fill_form_exclude_cols(self, exclude_cols, form): """ fill the form with the suppressed cols, generated from exclude_cols """ for filter_key in exclude_cols: filter_value = self._filters.get_filter_value(filter_key) rel_obj = self.datamodel.get_related_ob...
[ "fill", "the", "form", "with", "the", "suppressed", "cols", "generated", "from", "exclude_cols" ]
dpgaspar/Flask-AppBuilder
python
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L1186-L1195
[ "def", "_fill_form_exclude_cols", "(", "self", ",", "exclude_cols", ",", "form", ")", ":", "for", "filter_key", "in", "exclude_cols", ":", "filter_value", "=", "self", ".", "_filters", ".", "get_filter_value", "(", "filter_key", ")", "rel_obj", "=", "self", "....
c293734c1b86e176a3ba57ee2deab6676d125576
train
Transfer.get
Download a file from the current connection to the local filesystem. :param str remote: Remote file to download. May be absolute, or relative to the remote working directory. .. note:: Most SFTP servers set the remote working directory to the ...
fabric/transfer.py
def get(self, remote, local=None, preserve_mode=True): """ Download a file from the current connection to the local filesystem. :param str remote: Remote file to download. May be absolute, or relative to the remote working directory. .. note:: ...
def get(self, remote, local=None, preserve_mode=True): """ Download a file from the current connection to the local filesystem. :param str remote: Remote file to download. May be absolute, or relative to the remote working directory. .. note:: ...
[ "Download", "a", "file", "from", "the", "current", "connection", "to", "the", "local", "filesystem", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/transfer.py#L41-L145
[ "def", "get", "(", "self", ",", "remote", ",", "local", "=", "None", ",", "preserve_mode", "=", "True", ")", ":", "# TODO: how does this API change if we want to implement", "# remote-to-remote file transfer? (Is that even realistic?)", "# TODO: handle v1's string interpolation b...
e9939d68b734935f0c98d98817912ad7c698238f
train
Transfer.put
Upload a file from the local filesystem to the current connection. :param local: Local path of file to upload, or a file-like object. **If a string is given**, it should be a path to a local (regular) file (not a directory). .. note:: When deali...
fabric/transfer.py
def put(self, local, remote=None, preserve_mode=True): """ Upload a file from the local filesystem to the current connection. :param local: Local path of file to upload, or a file-like object. **If a string is given**, it should be a path to a local (regular) ...
def put(self, local, remote=None, preserve_mode=True): """ Upload a file from the local filesystem to the current connection. :param local: Local path of file to upload, or a file-like object. **If a string is given**, it should be a path to a local (regular) ...
[ "Upload", "a", "file", "from", "the", "local", "filesystem", "to", "the", "current", "connection", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/transfer.py#L147-L283
[ "def", "put", "(", "self", ",", "local", ",", "remote", "=", "None", ",", "preserve_mode", "=", "True", ")", ":", "if", "not", "local", ":", "raise", "ValueError", "(", "\"Local path must not be empty!\"", ")", "is_file_like", "=", "hasattr", "(", "local", ...
e9939d68b734935f0c98d98817912ad7c698238f
train
Config.load_ssh_config
Load SSH config file(s) from disk. Also (beforehand) ensures that Invoke-level config re: runtime SSH config file paths, is accounted for. .. versionadded:: 2.0
fabric/config.py
def load_ssh_config(self): """ Load SSH config file(s) from disk. Also (beforehand) ensures that Invoke-level config re: runtime SSH config file paths, is accounted for. .. versionadded:: 2.0 """ # Update the runtime SSH config path (assumes enough regular confi...
def load_ssh_config(self): """ Load SSH config file(s) from disk. Also (beforehand) ensures that Invoke-level config re: runtime SSH config file paths, is accounted for. .. versionadded:: 2.0 """ # Update the runtime SSH config path (assumes enough regular confi...
[ "Load", "SSH", "config", "file", "(", "s", ")", "from", "disk", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/config.py#L110-L127
[ "def", "load_ssh_config", "(", "self", ")", ":", "# Update the runtime SSH config path (assumes enough regular config", "# levels have been loaded that anyone wanting to transmit this info", "# from a 'vanilla' Invoke config, has gotten it set.)", "if", "self", ".", "ssh_config_path", ":",...
e9939d68b734935f0c98d98817912ad7c698238f
train
Config._load_ssh_files
Trigger loading of configured SSH config file paths. Expects that ``base_ssh_config`` has already been set to an `~paramiko.config.SSHConfig` object. :returns: ``None``.
fabric/config.py
def _load_ssh_files(self): """ Trigger loading of configured SSH config file paths. Expects that ``base_ssh_config`` has already been set to an `~paramiko.config.SSHConfig` object. :returns: ``None``. """ # TODO: does this want to more closely ape the behavior o...
def _load_ssh_files(self): """ Trigger loading of configured SSH config file paths. Expects that ``base_ssh_config`` has already been set to an `~paramiko.config.SSHConfig` object. :returns: ``None``. """ # TODO: does this want to more closely ape the behavior o...
[ "Trigger", "loading", "of", "configured", "SSH", "config", "file", "paths", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/config.py#L168-L189
[ "def", "_load_ssh_files", "(", "self", ")", ":", "# TODO: does this want to more closely ape the behavior of", "# InvokeConfig.load_files? re: having a _found attribute for each that", "# determines whether to load or skip", "if", "self", ".", "_runtime_ssh_path", "is", "not", "None", ...
e9939d68b734935f0c98d98817912ad7c698238f
train
Config._load_ssh_file
Attempt to open and parse an SSH config file at ``path``. Does nothing if ``path`` is not a path to a valid file. :returns: ``None``.
fabric/config.py
def _load_ssh_file(self, path): """ Attempt to open and parse an SSH config file at ``path``. Does nothing if ``path`` is not a path to a valid file. :returns: ``None``. """ if os.path.isfile(path): old_rules = len(self.base_ssh_config._config) w...
def _load_ssh_file(self, path): """ Attempt to open and parse an SSH config file at ``path``. Does nothing if ``path`` is not a path to a valid file. :returns: ``None``. """ if os.path.isfile(path): old_rules = len(self.base_ssh_config._config) w...
[ "Attempt", "to", "open", "and", "parse", "an", "SSH", "config", "file", "at", "path", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/config.py#L191-L207
[ "def", "_load_ssh_file", "(", "self", ",", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "old_rules", "=", "len", "(", "self", ".", "base_ssh_config", ".", "_config", ")", "with", "open", "(", "path", ")", "as", "...
e9939d68b734935f0c98d98817912ad7c698238f
train
Config.global_defaults
Default configuration values and behavior toggles. Fabric only extends this method in order to make minor adjustments and additions to Invoke's `~invoke.config.Config.global_defaults`; see its documentation for the base values, such as the config subtrees controlling behavior of ``run``...
fabric/config.py
def global_defaults(): """ Default configuration values and behavior toggles. Fabric only extends this method in order to make minor adjustments and additions to Invoke's `~invoke.config.Config.global_defaults`; see its documentation for the base values, such as the config subtr...
def global_defaults(): """ Default configuration values and behavior toggles. Fabric only extends this method in order to make minor adjustments and additions to Invoke's `~invoke.config.Config.global_defaults`; see its documentation for the base values, such as the config subtr...
[ "Default", "configuration", "values", "and", "behavior", "toggles", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/config.py#L210-L253
[ "def", "global_defaults", "(", ")", ":", "# TODO: hrm should the run-related things actually be derived from the", "# runner_class? E.g. Local defines local stuff, Remote defines remote", "# stuff? Doesn't help with the final config tree tho...", "# TODO: as to that, this is a core problem, Fabric w...
e9939d68b734935f0c98d98817912ad7c698238f
train
Tunnel.read_and_write
Read ``chunk_size`` from ``reader``, writing result to ``writer``. Returns ``None`` if successful, or ``True`` if the read was empty. .. versionadded:: 2.0
fabric/tunnels.py
def read_and_write(self, reader, writer, chunk_size): """ Read ``chunk_size`` from ``reader``, writing result to ``writer``. Returns ``None`` if successful, or ``True`` if the read was empty. .. versionadded:: 2.0 """ data = reader.recv(chunk_size) if len(data) ...
def read_and_write(self, reader, writer, chunk_size): """ Read ``chunk_size`` from ``reader``, writing result to ``writer``. Returns ``None`` if successful, or ``True`` if the read was empty. .. versionadded:: 2.0 """ data = reader.recv(chunk_size) if len(data) ...
[ "Read", "chunk_size", "from", "reader", "writing", "result", "to", "writer", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/tunnels.py#L146-L157
[ "def", "read_and_write", "(", "self", ",", "reader", ",", "writer", ",", "chunk_size", ")", ":", "data", "=", "reader", ".", "recv", "(", "chunk_size", ")", "if", "len", "(", "data", ")", "==", "0", ":", "return", "True", "writer", ".", "sendall", "(...
e9939d68b734935f0c98d98817912ad7c698238f
train
get_local_user
Return the local executing username, or ``None`` if one can't be found. .. versionadded:: 2.0
fabric/util.py
def get_local_user(): """ Return the local executing username, or ``None`` if one can't be found. .. versionadded:: 2.0 """ # TODO: I don't understand why these lines were added outside the # try/except, since presumably it means the attempt at catching ImportError # wouldn't work. However,...
def get_local_user(): """ Return the local executing username, or ``None`` if one can't be found. .. versionadded:: 2.0 """ # TODO: I don't understand why these lines were added outside the # try/except, since presumably it means the attempt at catching ImportError # wouldn't work. However,...
[ "Return", "the", "local", "executing", "username", "or", "None", "if", "one", "can", "t", "be", "found", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/util.py#L16-L45
[ "def", "get_local_user", "(", ")", ":", "# TODO: I don't understand why these lines were added outside the", "# try/except, since presumably it means the attempt at catching ImportError", "# wouldn't work. However, that's how the contributing user committed it.", "# Need an older Windows box to test...
e9939d68b734935f0c98d98817912ad7c698238f
train
FabExecutor.parameterize
Parameterize a Call with its Context set to a per-host Config.
fabric/executor.py
def parameterize(self, call, host): """ Parameterize a Call with its Context set to a per-host Config. """ debug("Parameterizing {!r} for host {!r}".format(call, host)) # Generate a custom ConnectionCall that knows how to yield a Connection # in its make_context(), specif...
def parameterize(self, call, host): """ Parameterize a Call with its Context set to a per-host Config. """ debug("Parameterizing {!r} for host {!r}".format(call, host)) # Generate a custom ConnectionCall that knows how to yield a Connection # in its make_context(), specif...
[ "Parameterize", "a", "Call", "with", "its", "Context", "set", "to", "a", "per", "-", "host", "Config", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/executor.py#L58-L68
[ "def", "parameterize", "(", "self", ",", "call", ",", "host", ")", ":", "debug", "(", "\"Parameterizing {!r} for host {!r}\"", ".", "format", "(", "call", ",", "host", ")", ")", "# Generate a custom ConnectionCall that knows how to yield a Connection", "# in its make_cont...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection_.mixed_use_of_local_and_run
Run command truly locally, and over SSH via localhost
integration/connection.py
def mixed_use_of_local_and_run(self): """ Run command truly locally, and over SSH via localhost """ cxn = Connection("localhost") result = cxn.local("echo foo", hide=True) assert result.stdout == "foo\n" assert not cxn.is_connected # meh way of proving it didn't ...
def mixed_use_of_local_and_run(self): """ Run command truly locally, and over SSH via localhost """ cxn = Connection("localhost") result = cxn.local("echo foo", hide=True) assert result.stdout == "foo\n" assert not cxn.is_connected # meh way of proving it didn't ...
[ "Run", "command", "truly", "locally", "and", "over", "SSH", "via", "localhost" ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/integration/connection.py#L67-L77
[ "def", "mixed_use_of_local_and_run", "(", "self", ")", ":", "cxn", "=", "Connection", "(", "\"localhost\"", ")", "result", "=", "cxn", ".", "local", "(", "\"echo foo\"", ",", "hide", "=", "True", ")", "assert", "result", ".", "stdout", "==", "\"foo\\n\"", ...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.open
Initiate an SSH connection to the host/port this object is bound to. This may include activating the configured gateway connection, if one is set. Also saves a handle to the now-set Transport object for easier access. Various connect-time settings (and/or their corresponding :ref:`SSH...
fabric/connection.py
def open(self): """ Initiate an SSH connection to the host/port this object is bound to. This may include activating the configured gateway connection, if one is set. Also saves a handle to the now-set Transport object for easier access. Various connect-time settings (...
def open(self): """ Initiate an SSH connection to the host/port this object is bound to. This may include activating the configured gateway connection, if one is set. Also saves a handle to the now-set Transport object for easier access. Various connect-time settings (...
[ "Initiate", "an", "SSH", "connection", "to", "the", "host", "/", "port", "this", "object", "is", "bound", "to", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L475-L525
[ "def", "open", "(", "self", ")", ":", "# Short-circuit", "if", "self", ".", "is_connected", ":", "return", "err", "=", "\"Refusing to be ambiguous: connect() kwarg '{}' was given both via regular arg and via connect_kwargs!\"", "# noqa", "# These may not be given, period", "for",...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.open_gateway
Obtain a socket-like object from `gateway`. :returns: A ``direct-tcpip`` `paramiko.channel.Channel`, if `gateway` was a `.Connection`; or a `~paramiko.proxy.ProxyCommand`, if `gateway` was a string. .. versionadded:: 2.0
fabric/connection.py
def open_gateway(self): """ Obtain a socket-like object from `gateway`. :returns: A ``direct-tcpip`` `paramiko.channel.Channel`, if `gateway` was a `.Connection`; or a `~paramiko.proxy.ProxyCommand`, if `gateway` was a string. .. versionadded:: 2.0 ...
def open_gateway(self): """ Obtain a socket-like object from `gateway`. :returns: A ``direct-tcpip`` `paramiko.channel.Channel`, if `gateway` was a `.Connection`; or a `~paramiko.proxy.ProxyCommand`, if `gateway` was a string. .. versionadded:: 2.0 ...
[ "Obtain", "a", "socket", "-", "like", "object", "from", "gateway", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L527-L565
[ "def", "open_gateway", "(", "self", ")", ":", "# ProxyCommand is faster to set up, so do it first.", "if", "isinstance", "(", "self", ".", "gateway", ",", "string_types", ")", ":", "# Leverage a dummy SSHConfig to ensure %h/%p/etc are parsed.", "# TODO: use real SSH config once l...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.close
Terminate the network connection to the remote end, if open. If no connection is open, this method does nothing. .. versionadded:: 2.0
fabric/connection.py
def close(self): """ Terminate the network connection to the remote end, if open. If no connection is open, this method does nothing. .. versionadded:: 2.0 """ if self.is_connected: self.client.close() if self.forward_agent and self._agent_handle...
def close(self): """ Terminate the network connection to the remote end, if open. If no connection is open, this method does nothing. .. versionadded:: 2.0 """ if self.is_connected: self.client.close() if self.forward_agent and self._agent_handle...
[ "Terminate", "the", "network", "connection", "to", "the", "remote", "end", "if", "open", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L567-L578
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "is_connected", ":", "self", ".", "client", ".", "close", "(", ")", "if", "self", ".", "forward_agent", "and", "self", ".", "_agent_handler", "is", "not", "None", ":", "self", ".", "_agent_handl...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.run
Execute a shell command on the remote end of this connection. This method wraps an SSH-capable implementation of `invoke.runners.Runner.run`; see its documentation for details. .. warning:: There are a few spots where Fabric departs from Invoke's default settings/behavi...
fabric/connection.py
def run(self, command, **kwargs): """ Execute a shell command on the remote end of this connection. This method wraps an SSH-capable implementation of `invoke.runners.Runner.run`; see its documentation for details. .. warning:: There are a few spots where Fabric dep...
def run(self, command, **kwargs): """ Execute a shell command on the remote end of this connection. This method wraps an SSH-capable implementation of `invoke.runners.Runner.run`; see its documentation for details. .. warning:: There are a few spots where Fabric dep...
[ "Execute", "a", "shell", "command", "on", "the", "remote", "end", "of", "this", "connection", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L594-L609
[ "def", "run", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "runner", "=", "self", ".", "config", ".", "runners", ".", "remote", "(", "self", ")", "return", "self", ".", "_run", "(", "runner", ",", "command", ",", "*", "*", "kwa...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.sudo
Execute a shell command, via ``sudo``, on the remote end. This method is identical to `invoke.context.Context.sudo` in every way, except in that -- like `run` -- it honors per-host/per-connection configuration overrides in addition to the generic/global ones. Thus, for example, per-host...
fabric/connection.py
def sudo(self, command, **kwargs): """ Execute a shell command, via ``sudo``, on the remote end. This method is identical to `invoke.context.Context.sudo` in every way, except in that -- like `run` -- it honors per-host/per-connection configuration overrides in addition to the g...
def sudo(self, command, **kwargs): """ Execute a shell command, via ``sudo``, on the remote end. This method is identical to `invoke.context.Context.sudo` in every way, except in that -- like `run` -- it honors per-host/per-connection configuration overrides in addition to the g...
[ "Execute", "a", "shell", "command", "via", "sudo", "on", "the", "remote", "end", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L612-L624
[ "def", "sudo", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "runner", "=", "self", ".", "config", ".", "runners", ".", "remote", "(", "self", ")", "return", "self", ".", "_sudo", "(", "runner", ",", "command", ",", "*", "*", "k...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.local
Execute a shell command on the local system. This method is effectively a wrapper of `invoke.run`; see its docs for details and call signature. .. versionadded:: 2.0
fabric/connection.py
def local(self, *args, **kwargs): """ Execute a shell command on the local system. This method is effectively a wrapper of `invoke.run`; see its docs for details and call signature. .. versionadded:: 2.0 """ # Superclass run() uses runners.local, so we can liter...
def local(self, *args, **kwargs): """ Execute a shell command on the local system. This method is effectively a wrapper of `invoke.run`; see its docs for details and call signature. .. versionadded:: 2.0 """ # Superclass run() uses runners.local, so we can liter...
[ "Execute", "a", "shell", "command", "on", "the", "local", "system", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L626-L637
[ "def", "local", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Superclass run() uses runners.local, so we can literally just call it", "# straight.", "return", "super", "(", "Connection", ",", "self", ")", ".", "run", "(", "*", "args", ",",...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.sftp
Return a `~paramiko.sftp_client.SFTPClient` object. If called more than one time, memoizes the first result; thus, any given `.Connection` instance will only ever have a single SFTP client, and state (such as that managed by `~paramiko.sftp_client.SFTPClient.chdir`) will be preserved. ...
fabric/connection.py
def sftp(self): """ Return a `~paramiko.sftp_client.SFTPClient` object. If called more than one time, memoizes the first result; thus, any given `.Connection` instance will only ever have a single SFTP client, and state (such as that managed by `~paramiko.sftp_client.SFT...
def sftp(self): """ Return a `~paramiko.sftp_client.SFTPClient` object. If called more than one time, memoizes the first result; thus, any given `.Connection` instance will only ever have a single SFTP client, and state (such as that managed by `~paramiko.sftp_client.SFT...
[ "Return", "a", "~paramiko", ".", "sftp_client", ".", "SFTPClient", "object", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L640-L653
[ "def", "sftp", "(", "self", ")", ":", "if", "self", ".", "_sftp", "is", "None", ":", "self", ".", "_sftp", "=", "self", ".", "client", ".", "open_sftp", "(", ")", "return", "self", ".", "_sftp" ]
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.forward_local
Open a tunnel connecting ``local_port`` to the server's environment. For example, say you want to connect to a remote PostgreSQL database which is locked down and only accessible via the system it's running on. You have SSH access to this server, so you can temporarily make port 5432 on...
fabric/connection.py
def forward_local( self, local_port, remote_port=None, remote_host="localhost", local_host="localhost", ): """ Open a tunnel connecting ``local_port`` to the server's environment. For example, say you want to connect to a remote PostgreSQL database ...
def forward_local( self, local_port, remote_port=None, remote_host="localhost", local_host="localhost", ): """ Open a tunnel connecting ``local_port`` to the server's environment. For example, say you want to connect to a remote PostgreSQL database ...
[ "Open", "a", "tunnel", "connecting", "local_port", "to", "the", "server", "s", "environment", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L682-L772
[ "def", "forward_local", "(", "self", ",", "local_port", ",", "remote_port", "=", "None", ",", "remote_host", "=", "\"localhost\"", ",", "local_host", "=", "\"localhost\"", ",", ")", ":", "if", "not", "remote_port", ":", "remote_port", "=", "local_port", "# Tun...
e9939d68b734935f0c98d98817912ad7c698238f
train
Connection.forward_remote
Open a tunnel connecting ``remote_port`` to the local environment. For example, say you're running a daemon in development mode on your workstation at port 8080, and want to funnel traffic to it from a production or staging environment. In most situations this isn't possible as your of...
fabric/connection.py
def forward_remote( self, remote_port, local_port=None, remote_host="127.0.0.1", local_host="localhost", ): """ Open a tunnel connecting ``remote_port`` to the local environment. For example, say you're running a daemon in development mode on your ...
def forward_remote( self, remote_port, local_port=None, remote_host="127.0.0.1", local_host="localhost", ): """ Open a tunnel connecting ``remote_port`` to the local environment. For example, say you're running a daemon in development mode on your ...
[ "Open", "a", "tunnel", "connecting", "remote_port", "to", "the", "local", "environment", "." ]
fabric/fabric
python
https://github.com/fabric/fabric/blob/e9939d68b734935f0c98d98817912ad7c698238f/fabric/connection.py#L781-L882
[ "def", "forward_remote", "(", "self", ",", "remote_port", ",", "local_port", "=", "None", ",", "remote_host", "=", "\"127.0.0.1\"", ",", "local_host", "=", "\"localhost\"", ",", ")", ":", "if", "not", "local_port", ":", "local_port", "=", "remote_port", "# Cal...
e9939d68b734935f0c98d98817912ad7c698238f
train
dedup_list
Given a list (l) will removing duplicates from the list, preserving the original order of the list. Assumes that the list entrie are hashable.
lark/utils.py
def dedup_list(l): """Given a list (l) will removing duplicates from the list, preserving the original order of the list. Assumes that the list entrie are hashable.""" dedup = set() return [ x for x in l if not (x in dedup or dedup.add(x))]
def dedup_list(l): """Given a list (l) will removing duplicates from the list, preserving the original order of the list. Assumes that the list entrie are hashable.""" dedup = set() return [ x for x in l if not (x in dedup or dedup.add(x))]
[ "Given", "a", "list", "(", "l", ")", "will", "removing", "duplicates", "from", "the", "list", "preserving", "the", "original", "order", "of", "the", "list", ".", "Assumes", "that", "the", "list", "entrie", "are", "hashable", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/utils.py#L182-L187
[ "def", "dedup_list", "(", "l", ")", ":", "dedup", "=", "set", "(", ")", "return", "[", "x", "for", "x", "in", "l", "if", "not", "(", "x", "in", "dedup", "or", "dedup", ".", "add", "(", "x", ")", ")", "]" ]
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_parse
Parses sentence 's' using CNF grammar 'g'.
lark/parsers/cyk.py
def _parse(s, g): """Parses sentence 's' using CNF grammar 'g'.""" # The CYK table. Indexed with a 2-tuple: (start pos, end pos) table = defaultdict(set) # Top-level structure is similar to the CYK table. Each cell is a dict from # rule name to the best (lightest) tree for that rule. trees = def...
def _parse(s, g): """Parses sentence 's' using CNF grammar 'g'.""" # The CYK table. Indexed with a 2-tuple: (start pos, end pos) table = defaultdict(set) # Top-level structure is similar to the CYK table. Each cell is a dict from # rule name to the best (lightest) tree for that rule. trees = def...
[ "Parses", "sentence", "s", "using", "CNF", "grammar", "g", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L136-L170
[ "def", "_parse", "(", "s", ",", "g", ")", ":", "# The CYK table. Indexed with a 2-tuple: (start pos, end pos)", "table", "=", "defaultdict", "(", "set", ")", "# Top-level structure is similar to the CYK table. Each cell is a dict from", "# rule name to the best (lightest) tree for th...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
get_any_nt_unit_rule
Returns a non-terminal unit rule from 'g', or None if there is none.
lark/parsers/cyk.py
def get_any_nt_unit_rule(g): """Returns a non-terminal unit rule from 'g', or None if there is none.""" for rule in g.rules: if len(rule.rhs) == 1 and isinstance(rule.rhs[0], NT): return rule return None
def get_any_nt_unit_rule(g): """Returns a non-terminal unit rule from 'g', or None if there is none.""" for rule in g.rules: if len(rule.rhs) == 1 and isinstance(rule.rhs[0], NT): return rule return None
[ "Returns", "a", "non", "-", "terminal", "unit", "rule", "from", "g", "or", "None", "if", "there", "is", "none", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L242-L247
[ "def", "get_any_nt_unit_rule", "(", "g", ")", ":", "for", "rule", "in", "g", ".", "rules", ":", "if", "len", "(", "rule", ".", "rhs", ")", "==", "1", "and", "isinstance", "(", "rule", ".", "rhs", "[", "0", "]", ",", "NT", ")", ":", "return", "r...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_remove_unit_rule
Removes 'rule' from 'g' without changing the langugage produced by 'g'.
lark/parsers/cyk.py
def _remove_unit_rule(g, rule): """Removes 'rule' from 'g' without changing the langugage produced by 'g'.""" new_rules = [x for x in g.rules if x != rule] refs = [x for x in g.rules if x.lhs == rule.rhs[0]] new_rules += [build_unit_skiprule(rule, ref) for ref in refs] return Grammar(new_rules)
def _remove_unit_rule(g, rule): """Removes 'rule' from 'g' without changing the langugage produced by 'g'.""" new_rules = [x for x in g.rules if x != rule] refs = [x for x in g.rules if x.lhs == rule.rhs[0]] new_rules += [build_unit_skiprule(rule, ref) for ref in refs] return Grammar(new_rules)
[ "Removes", "rule", "from", "g", "without", "changing", "the", "langugage", "produced", "by", "g", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L250-L255
[ "def", "_remove_unit_rule", "(", "g", ",", "rule", ")", ":", "new_rules", "=", "[", "x", "for", "x", "in", "g", ".", "rules", "if", "x", "!=", "rule", "]", "refs", "=", "[", "x", "for", "x", "in", "g", ".", "rules", "if", "x", ".", "lhs", "==...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_split
Splits a rule whose len(rhs) > 2 into shorter rules.
lark/parsers/cyk.py
def _split(rule): """Splits a rule whose len(rhs) > 2 into shorter rules.""" rule_str = str(rule.lhs) + '__' + '_'.join(str(x) for x in rule.rhs) rule_name = '__SP_%s' % (rule_str) + '_%d' yield Rule(rule.lhs, [rule.rhs[0], NT(rule_name % 1)], weight=rule.weight, alias=rule.alias) for i in xrange(1,...
def _split(rule): """Splits a rule whose len(rhs) > 2 into shorter rules.""" rule_str = str(rule.lhs) + '__' + '_'.join(str(x) for x in rule.rhs) rule_name = '__SP_%s' % (rule_str) + '_%d' yield Rule(rule.lhs, [rule.rhs[0], NT(rule_name % 1)], weight=rule.weight, alias=rule.alias) for i in xrange(1,...
[ "Splits", "a", "rule", "whose", "len", "(", "rhs", ")", ">", "2", "into", "shorter", "rules", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L258-L265
[ "def", "_split", "(", "rule", ")", ":", "rule_str", "=", "str", "(", "rule", ".", "lhs", ")", "+", "'__'", "+", "'_'", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "rule", ".", "rhs", ")", "rule_name", "=", "'__SP_%s'", "%", "(", ...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_term
Applies the TERM rule on 'g' (see top comment).
lark/parsers/cyk.py
def _term(g): """Applies the TERM rule on 'g' (see top comment).""" all_t = {x for rule in g.rules for x in rule.rhs if isinstance(x, T)} t_rules = {t: Rule(NT('__T_%s' % str(t)), [t], weight=0, alias='Term') for t in all_t} new_rules = [] for rule in g.rules: if len(rule.rhs) > 1 and any(is...
def _term(g): """Applies the TERM rule on 'g' (see top comment).""" all_t = {x for rule in g.rules for x in rule.rhs if isinstance(x, T)} t_rules = {t: Rule(NT('__T_%s' % str(t)), [t], weight=0, alias='Term') for t in all_t} new_rules = [] for rule in g.rules: if len(rule.rhs) > 1 and any(is...
[ "Applies", "the", "TERM", "rule", "on", "g", "(", "see", "top", "comment", ")", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L268-L280
[ "def", "_term", "(", "g", ")", ":", "all_t", "=", "{", "x", "for", "rule", "in", "g", ".", "rules", "for", "x", "in", "rule", ".", "rhs", "if", "isinstance", "(", "x", ",", "T", ")", "}", "t_rules", "=", "{", "t", ":", "Rule", "(", "NT", "(...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_bin
Applies the BIN rule to 'g' (see top comment).
lark/parsers/cyk.py
def _bin(g): """Applies the BIN rule to 'g' (see top comment).""" new_rules = [] for rule in g.rules: if len(rule.rhs) > 2: new_rules += _split(rule) else: new_rules.append(rule) return Grammar(new_rules)
def _bin(g): """Applies the BIN rule to 'g' (see top comment).""" new_rules = [] for rule in g.rules: if len(rule.rhs) > 2: new_rules += _split(rule) else: new_rules.append(rule) return Grammar(new_rules)
[ "Applies", "the", "BIN", "rule", "to", "g", "(", "see", "top", "comment", ")", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L283-L291
[ "def", "_bin", "(", "g", ")", ":", "new_rules", "=", "[", "]", "for", "rule", "in", "g", ".", "rules", ":", "if", "len", "(", "rule", ".", "rhs", ")", ">", "2", ":", "new_rules", "+=", "_split", "(", "rule", ")", "else", ":", "new_rules", ".", ...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
_unit
Applies the UNIT rule to 'g' (see top comment).
lark/parsers/cyk.py
def _unit(g): """Applies the UNIT rule to 'g' (see top comment).""" nt_unit_rule = get_any_nt_unit_rule(g) while nt_unit_rule: g = _remove_unit_rule(g, nt_unit_rule) nt_unit_rule = get_any_nt_unit_rule(g) return g
def _unit(g): """Applies the UNIT rule to 'g' (see top comment).""" nt_unit_rule = get_any_nt_unit_rule(g) while nt_unit_rule: g = _remove_unit_rule(g, nt_unit_rule) nt_unit_rule = get_any_nt_unit_rule(g) return g
[ "Applies", "the", "UNIT", "rule", "to", "g", "(", "see", "top", "comment", ")", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L294-L300
[ "def", "_unit", "(", "g", ")", ":", "nt_unit_rule", "=", "get_any_nt_unit_rule", "(", "g", ")", "while", "nt_unit_rule", ":", "g", "=", "_remove_unit_rule", "(", "g", ",", "nt_unit_rule", ")", "nt_unit_rule", "=", "get_any_nt_unit_rule", "(", "g", ")", "retu...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
revert_cnf
Reverts a parse tree (RuleNode) to its original non-CNF form (Node).
lark/parsers/cyk.py
def revert_cnf(node): """Reverts a parse tree (RuleNode) to its original non-CNF form (Node).""" if isinstance(node, T): return node # Reverts TERM rule. if node.rule.lhs.name.startswith('__T_'): return node.children[0] else: children = [] for child in map(revert_cnf,...
def revert_cnf(node): """Reverts a parse tree (RuleNode) to its original non-CNF form (Node).""" if isinstance(node, T): return node # Reverts TERM rule. if node.rule.lhs.name.startswith('__T_'): return node.children[0] else: children = [] for child in map(revert_cnf,...
[ "Reverts", "a", "parse", "tree", "(", "RuleNode", ")", "to", "its", "original", "non", "-", "CNF", "form", "(", "Node", ")", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L322-L343
[ "def", "revert_cnf", "(", "node", ")", ":", "if", "isinstance", "(", "node", ",", "T", ")", ":", "return", "node", "# Reverts TERM rule.", "if", "node", ".", "rule", ".", "lhs", ".", "name", ".", "startswith", "(", "'__T_'", ")", ":", "return", "node",...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Parser._to_rule
Converts a lark rule, (lhs, rhs, callback, options), to a Rule.
lark/parsers/cyk.py
def _to_rule(self, lark_rule): """Converts a lark rule, (lhs, rhs, callback, options), to a Rule.""" assert isinstance(lark_rule.origin, NT) assert all(isinstance(x, Symbol) for x in lark_rule.expansion) return Rule( lark_rule.origin, lark_rule.expansion, weight=l...
def _to_rule(self, lark_rule): """Converts a lark rule, (lhs, rhs, callback, options), to a Rule.""" assert isinstance(lark_rule.origin, NT) assert all(isinstance(x, Symbol) for x in lark_rule.expansion) return Rule( lark_rule.origin, lark_rule.expansion, weight=l...
[ "Converts", "a", "lark", "rule", "(", "lhs", "rhs", "callback", "options", ")", "to", "a", "Rule", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L94-L101
[ "def", "_to_rule", "(", "self", ",", "lark_rule", ")", ":", "assert", "isinstance", "(", "lark_rule", ".", "origin", ",", "NT", ")", "assert", "all", "(", "isinstance", "(", "x", ",", "Symbol", ")", "for", "x", "in", "lark_rule", ".", "expansion", ")",...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Parser.parse
Parses input, which is a list of tokens.
lark/parsers/cyk.py
def parse(self, tokenized): # pylint: disable=invalid-name """Parses input, which is a list of tokens.""" table, trees = _parse(tokenized, self.grammar) # Check if the parse succeeded. if all(r.lhs != self.start for r in table[(0, len(tokenized) - 1)]): raise ParseError('Par...
def parse(self, tokenized): # pylint: disable=invalid-name """Parses input, which is a list of tokens.""" table, trees = _parse(tokenized, self.grammar) # Check if the parse succeeded. if all(r.lhs != self.start for r in table[(0, len(tokenized) - 1)]): raise ParseError('Par...
[ "Parses", "input", "which", "is", "a", "list", "of", "tokens", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L103-L110
[ "def", "parse", "(", "self", ",", "tokenized", ")", ":", "# pylint: disable=invalid-name", "table", ",", "trees", "=", "_parse", "(", "tokenized", ",", "self", ".", "grammar", ")", "# Check if the parse succeeded.", "if", "all", "(", "r", ".", "lhs", "!=", "...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Parser._to_tree
Converts a RuleNode parse tree to a lark Tree.
lark/parsers/cyk.py
def _to_tree(self, rule_node): """Converts a RuleNode parse tree to a lark Tree.""" orig_rule = self.orig_rules[rule_node.rule.alias] children = [] for child in rule_node.children: if isinstance(child, RuleNode): children.append(self._to_tree(child)) ...
def _to_tree(self, rule_node): """Converts a RuleNode parse tree to a lark Tree.""" orig_rule = self.orig_rules[rule_node.rule.alias] children = [] for child in rule_node.children: if isinstance(child, RuleNode): children.append(self._to_tree(child)) ...
[ "Converts", "a", "RuleNode", "parse", "tree", "to", "a", "lark", "Tree", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/cyk.py#L112-L124
[ "def", "_to_tree", "(", "self", ",", "rule_node", ")", ":", "orig_rule", "=", "self", ".", "orig_rules", "[", "rule_node", ".", "rule", ".", "alias", "]", "children", "=", "[", "]", "for", "child", "in", "rule_node", ".", "children", ":", "if", "isinst...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
pydot__tree_to_png
Creates a colorful image that represents the tree (data+children, without meta) Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to directed graphs drawn from top to bottom, from left to right, from bottom to top, and from right to left, respectively. See: https://www.graphviz.or...
lark/tree.py
def pydot__tree_to_png(tree, filename, rankdir="LR"): """Creates a colorful image that represents the tree (data+children, without meta) Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to directed graphs drawn from top to bottom, from left to right, from bottom to top, and from ...
def pydot__tree_to_png(tree, filename, rankdir="LR"): """Creates a colorful image that represents the tree (data+children, without meta) Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to directed graphs drawn from top to bottom, from left to right, from bottom to top, and from ...
[ "Creates", "a", "colorful", "image", "that", "represents", "the", "tree", "(", "data", "+", "children", "without", "meta", ")" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/tree.py#L144-L180
[ "def", "pydot__tree_to_png", "(", "tree", ",", "filename", ",", "rankdir", "=", "\"LR\"", ")", ":", "import", "pydot", "graph", "=", "pydot", ".", "Dot", "(", "graph_type", "=", "'digraph'", ",", "rankdir", "=", "rankdir", ")", "i", "=", "[", "0", "]",...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Tree.expand_kids_by_index
Expand (inline) children at the given indices
lark/tree.py
def expand_kids_by_index(self, *indices): "Expand (inline) children at the given indices" for i in sorted(indices, reverse=True): # reverse so that changing tail won't affect indices kid = self.children[i] self.children[i:i+1] = kid.children
def expand_kids_by_index(self, *indices): "Expand (inline) children at the given indices" for i in sorted(indices, reverse=True): # reverse so that changing tail won't affect indices kid = self.children[i] self.children[i:i+1] = kid.children
[ "Expand", "(", "inline", ")", "children", "at", "the", "given", "indices" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/tree.py#L61-L65
[ "def", "expand_kids_by_index", "(", "self", ",", "*", "indices", ")", ":", "for", "i", "in", "sorted", "(", "indices", ",", "reverse", "=", "True", ")", ":", "# reverse so that changing tail won't affect indices", "kid", "=", "self", ".", "children", "[", "i",...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
visit_children_decor
See Interpreter
examples/standalone/json_parser.py
def visit_children_decor(func): "See Interpreter" @wraps(func) def inner(cls, tree): values = cls.visit_children(tree) return func(cls, values) return inner
def visit_children_decor(func): "See Interpreter" @wraps(func) def inner(cls, tree): values = cls.visit_children(tree) return func(cls, values) return inner
[ "See", "Interpreter" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L453-L459
[ "def", "visit_children_decor", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "cls", ",", "tree", ")", ":", "values", "=", "cls", ".", "visit_children", "(", "tree", ")", "return", "func", "(", "cls", ",", "values", ")", ...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
v_args
A convenience decorator factory, for modifying the behavior of user-supplied visitor methods
examples/standalone/json_parser.py
def v_args(inline=False, meta=False, tree=False): "A convenience decorator factory, for modifying the behavior of user-supplied visitor methods" if [tree, meta, inline].count(True) > 1: raise ValueError("Visitor functions can either accept tree, or meta, or be inlined. These cannot be combined.") de...
def v_args(inline=False, meta=False, tree=False): "A convenience decorator factory, for modifying the behavior of user-supplied visitor methods" if [tree, meta, inline].count(True) > 1: raise ValueError("Visitor functions can either accept tree, or meta, or be inlined. These cannot be combined.") de...
[ "A", "convenience", "decorator", "factory", "for", "modifying", "the", "behavior", "of", "user", "-", "supplied", "visitor", "methods" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L539-L545
[ "def", "v_args", "(", "inline", "=", "False", ",", "meta", "=", "False", ",", "tree", "=", "False", ")", ":", "if", "[", "tree", ",", "meta", ",", "inline", "]", ".", "count", "(", "True", ")", ">", "1", ":", "raise", "ValueError", "(", "\"Visito...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
UnexpectedInput.match_examples
Given a parser instance and a dictionary mapping some label with some malformed syntax examples, it'll return the label for the example that bests matches the current error.
examples/standalone/json_parser.py
def match_examples(self, parse_fn, examples): """ Given a parser instance and a dictionary mapping some label with some malformed syntax examples, it'll return the label for the example that bests matches the current error. """ assert self.state is not None, "Not supporte...
def match_examples(self, parse_fn, examples): """ Given a parser instance and a dictionary mapping some label with some malformed syntax examples, it'll return the label for the example that bests matches the current error. """ assert self.state is not None, "Not supporte...
[ "Given", "a", "parser", "instance", "and", "a", "dictionary", "mapping", "some", "label", "with", "some", "malformed", "syntax", "examples", "it", "ll", "return", "the", "label", "for", "the", "example", "that", "bests", "matches", "the", "current", "error", ...
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L61-L85
[ "def", "match_examples", "(", "self", ",", "parse_fn", ",", "examples", ")", ":", "assert", "self", ".", "state", "is", "not", "None", ",", "\"Not supported for this exception\"", "candidate", "=", "None", "for", "label", ",", "example", "in", "examples", ".",...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
LineCounter.feed
Consume a token and calculate the new line & column. As an optional optimization, set test_newline=False is token doesn't contain a newline.
examples/standalone/json_parser.py
def feed(self, token, test_newline=True): """Consume a token and calculate the new line & column. As an optional optimization, set test_newline=False is token doesn't contain a newline. """ if test_newline: newlines = token.count(self.newline_char) if newlines: ...
def feed(self, token, test_newline=True): """Consume a token and calculate the new line & column. As an optional optimization, set test_newline=False is token doesn't contain a newline. """ if test_newline: newlines = token.count(self.newline_char) if newlines: ...
[ "Consume", "a", "token", "and", "calculate", "the", "new", "line", "&", "column", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L825-L837
[ "def", "feed", "(", "self", ",", "token", ",", "test_newline", "=", "True", ")", ":", "if", "test_newline", ":", "newlines", "=", "token", ".", "count", "(", "self", ".", "newline_char", ")", "if", "newlines", ":", "self", ".", "line", "+=", "newlines"...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Lark.open
Create an instance of Lark with the grammar given by its filename If rel_to is provided, the function will find the grammar filename in relation to it. Example: >>> Lark.open("grammar_file.lark", rel_to=__file__, parser="lalr") Lark(...)
examples/standalone/json_parser.py
def open(cls, grammar_filename, rel_to=None, **options): """Create an instance of Lark with the grammar given by its filename If rel_to is provided, the function will find the grammar filename in relation to it. Example: >>> Lark.open("grammar_file.lark", rel_to=__file__, parser="...
def open(cls, grammar_filename, rel_to=None, **options): """Create an instance of Lark with the grammar given by its filename If rel_to is provided, the function will find the grammar filename in relation to it. Example: >>> Lark.open("grammar_file.lark", rel_to=__file__, parser="...
[ "Create", "an", "instance", "of", "Lark", "with", "the", "grammar", "given", "by", "its", "filename" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L1793-L1808
[ "def", "open", "(", "cls", ",", "grammar_filename", ",", "rel_to", "=", "None", ",", "*", "*", "options", ")", ":", "if", "rel_to", ":", "basepath", "=", "os", ".", "path", ".", "dirname", "(", "rel_to", ")", "grammar_filename", "=", "os", ".", "path...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Lark.lex
Only lex (and postlex) the text, without parsing it. Only relevant when lexer='standard
examples/standalone/json_parser.py
def lex(self, text): "Only lex (and postlex) the text, without parsing it. Only relevant when lexer='standard'" if not hasattr(self, 'lexer'): self.lexer = self._build_lexer() stream = self.lexer.lex(text) if self.options.postlex: return self.options.postlex.proce...
def lex(self, text): "Only lex (and postlex) the text, without parsing it. Only relevant when lexer='standard'" if not hasattr(self, 'lexer'): self.lexer = self._build_lexer() stream = self.lexer.lex(text) if self.options.postlex: return self.options.postlex.proce...
[ "Only", "lex", "(", "and", "postlex", ")", "the", "text", "without", "parsing", "it", ".", "Only", "relevant", "when", "lexer", "=", "standard" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L1814-L1821
[ "def", "lex", "(", "self", ",", "text", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'lexer'", ")", ":", "self", ".", "lexer", "=", "self", ".", "_build_lexer", "(", ")", "stream", "=", "self", ".", "lexer", ".", "lex", "(", "text", ")", ...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
calculate_sets
Calculate FOLLOW sets. Adapted from: http://lara.epfl.ch/w/cc09:algorithm_for_first_and_follow_sets
lark/parsers/grammar_analysis.py
def calculate_sets(rules): """Calculate FOLLOW sets. Adapted from: http://lara.epfl.ch/w/cc09:algorithm_for_first_and_follow_sets""" symbols = {sym for rule in rules for sym in rule.expansion} | {rule.origin for rule in rules} # foreach grammar rule X ::= Y(1) ... Y(k) # if k=0 or {Y(1),...,Y(k)} ...
def calculate_sets(rules): """Calculate FOLLOW sets. Adapted from: http://lara.epfl.ch/w/cc09:algorithm_for_first_and_follow_sets""" symbols = {sym for rule in rules for sym in rule.expansion} | {rule.origin for rule in rules} # foreach grammar rule X ::= Y(1) ... Y(k) # if k=0 or {Y(1),...,Y(k)} ...
[ "Calculate", "FOLLOW", "sets", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/grammar_analysis.py#L48-L105
[ "def", "calculate_sets", "(", "rules", ")", ":", "symbols", "=", "{", "sym", "for", "rule", "in", "rules", "for", "sym", "in", "rule", ".", "expansion", "}", "|", "{", "rule", ".", "origin", "for", "rule", "in", "rules", "}", "# foreach grammar rule X ::...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
GrammarAnalyzer.expand_rule
Returns all init_ptrs accessible by rule (recursive)
lark/parsers/grammar_analysis.py
def expand_rule(self, rule): "Returns all init_ptrs accessible by rule (recursive)" init_ptrs = set() def _expand_rule(rule): assert not rule.is_term, rule for r in self.rules_by_origin[rule]: init_ptr = RulePtr(r, 0) init_ptrs.add(init_pt...
def expand_rule(self, rule): "Returns all init_ptrs accessible by rule (recursive)" init_ptrs = set() def _expand_rule(rule): assert not rule.is_term, rule for r in self.rules_by_origin[rule]: init_ptr = RulePtr(r, 0) init_ptrs.add(init_pt...
[ "Returns", "all", "init_ptrs", "accessible", "by", "rule", "(", "recursive", ")" ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/grammar_analysis.py#L128-L146
[ "def", "expand_rule", "(", "self", ",", "rule", ")", ":", "init_ptrs", "=", "set", "(", ")", "def", "_expand_rule", "(", "rule", ")", ":", "assert", "not", "rule", ".", "is_term", ",", "rule", "for", "r", "in", "self", ".", "rules_by_origin", "[", "r...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
import_from_grammar_into_namespace
Returns all rules and terminals of grammar, prepended with a 'namespace' prefix, except for those which are aliased.
lark/load_grammar.py
def import_from_grammar_into_namespace(grammar, namespace, aliases): """Returns all rules and terminals of grammar, prepended with a 'namespace' prefix, except for those which are aliased. """ imported_terms = dict(grammar.term_defs) imported_rules = {n:(n,deepcopy(t),o) for n,t,o in grammar.rule_d...
def import_from_grammar_into_namespace(grammar, namespace, aliases): """Returns all rules and terminals of grammar, prepended with a 'namespace' prefix, except for those which are aliased. """ imported_terms = dict(grammar.term_defs) imported_rules = {n:(n,deepcopy(t),o) for n,t,o in grammar.rule_d...
[ "Returns", "all", "rules", "and", "terminals", "of", "grammar", "prepended", "with", "a", "namespace", "prefix", "except", "for", "those", "which", "are", "aliased", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/load_grammar.py#L577-L618
[ "def", "import_from_grammar_into_namespace", "(", "grammar", ",", "namespace", ",", "aliases", ")", ":", "imported_terms", "=", "dict", "(", "grammar", ".", "term_defs", ")", "imported_rules", "=", "{", "n", ":", "(", "n", ",", "deepcopy", "(", "t", ")", "...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
GrammarLoader.load_grammar
Parse grammar_text, verify, and create Grammar object. Display nice messages on error.
lark/load_grammar.py
def load_grammar(self, grammar_text, grammar_name='<?>'): "Parse grammar_text, verify, and create Grammar object. Display nice messages on error." try: tree = self.canonize_tree.transform( self.parser.parse(grammar_text+'\n') ) except UnexpectedCharacters as e: context =...
def load_grammar(self, grammar_text, grammar_name='<?>'): "Parse grammar_text, verify, and create Grammar object. Display nice messages on error." try: tree = self.canonize_tree.transform( self.parser.parse(grammar_text+'\n') ) except UnexpectedCharacters as e: context =...
[ "Parse", "grammar_text", "verify", "and", "create", "Grammar", "object", ".", "Display", "nice", "messages", "on", "error", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/load_grammar.py#L686-L843
[ "def", "load_grammar", "(", "self", ",", "grammar_text", ",", "grammar_name", "=", "'<?>'", ")", ":", "try", ":", "tree", "=", "self", ".", "canonize_tree", ".", "transform", "(", "self", ".", "parser", ".", "parse", "(", "grammar_text", "+", "'\\n'", ")...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
Parser.predict_and_complete
The core Earley Predictor and Completer. At each stage of the input, we handling any completed items (things that matched on the last cycle) and use those to predict what should come next in the input stream. The completions and any predicted non-terminals are recursively processed unti...
lark/parsers/earley.py
def predict_and_complete(self, i, to_scan, columns, transitives): """The core Earley Predictor and Completer. At each stage of the input, we handling any completed items (things that matched on the last cycle) and use those to predict what should come next in the input stream. The compl...
def predict_and_complete(self, i, to_scan, columns, transitives): """The core Earley Predictor and Completer. At each stage of the input, we handling any completed items (things that matched on the last cycle) and use those to predict what should come next in the input stream. The compl...
[ "The", "core", "Earley", "Predictor", "and", "Completer", "." ]
lark-parser/lark
python
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/lark/parsers/earley.py#L56-L147
[ "def", "predict_and_complete", "(", "self", ",", "i", ",", "to_scan", ",", "columns", ",", "transitives", ")", ":", "# Held Completions (H in E.Scotts paper).", "node_cache", "=", "{", "}", "held_completions", "=", "{", "}", "column", "=", "columns", "[", "i", ...
a798dec77907e74520dd7e90c7b6a4acc680633a
train
RadioGroup.applyStyleRules
Conditionally disabled/enables form fields based on the current section in the radio group
gooey/gui/components/widgets/radio_group.py
def applyStyleRules(self): """ Conditionally disabled/enables form fields based on the current section in the radio group """ for button, widget in zip(self.radioButtons, self.widgets): if isinstance(widget, CheckBox): widget.hideInput() ...
def applyStyleRules(self): """ Conditionally disabled/enables form fields based on the current section in the radio group """ for button, widget in zip(self.radioButtons, self.widgets): if isinstance(widget, CheckBox): widget.hideInput() ...
[ "Conditionally", "disabled", "/", "enables", "form", "fields", "based", "on", "the", "current", "section", "in", "the", "radio", "group" ]
chriskiehl/Gooey
python
https://github.com/chriskiehl/Gooey/blob/e598573c6519b953e0ccfc1f3663f827f8cd7e22/gooey/gui/components/widgets/radio_group.py#L95-L106
[ "def", "applyStyleRules", "(", "self", ")", ":", "for", "button", ",", "widget", "in", "zip", "(", "self", ".", "radioButtons", ",", "self", ".", "widgets", ")", ":", "if", "isinstance", "(", "widget", ",", "CheckBox", ")", ":", "widget", ".", "hideInp...
e598573c6519b953e0ccfc1f3663f827f8cd7e22