repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
DinoTools/python-overpy
overpy/__init__.py
Result.append
def append(self, element): """ Append a new element to the result. :param element: The element to append :type element: overpy.Element """ if is_valid_type(element, Element): self._class_collection_map[element.__class__].setdefault(element.id, element)
python
def append(self, element): """ Append a new element to the result. :param element: The element to append :type element: overpy.Element """ if is_valid_type(element, Element): self._class_collection_map[element.__class__].setdefault(element.id, element)
[ "def", "append", "(", "self", ",", "element", ")", ":", "if", "is_valid_type", "(", "element", ",", "Element", ")", ":", "self", ".", "_class_collection_map", "[", "element", ".", "__class__", "]", ".", "setdefault", "(", "element", ".", "id", ",", "elem...
Append a new element to the result. :param element: The element to append :type element: overpy.Element
[ "Append", "a", "new", "element", "to", "the", "result", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L289-L297
DinoTools/python-overpy
overpy/__init__.py
Result.get_elements
def get_elements(self, filter_cls, elem_id=None): """ Get a list of elements from the result and filter the element type by a class. :param filter_cls: :param elem_id: ID of the object :type elem_id: Integer :return: List of available elements :rtype: List ...
python
def get_elements(self, filter_cls, elem_id=None): """ Get a list of elements from the result and filter the element type by a class. :param filter_cls: :param elem_id: ID of the object :type elem_id: Integer :return: List of available elements :rtype: List ...
[ "def", "get_elements", "(", "self", ",", "filter_cls", ",", "elem_id", "=", "None", ")", ":", "result", "=", "[", "]", "if", "elem_id", "is", "not", "None", ":", "try", ":", "result", "=", "[", "self", ".", "_class_collection_map", "[", "filter_cls", "...
Get a list of elements from the result and filter the element type by a class. :param filter_cls: :param elem_id: ID of the object :type elem_id: Integer :return: List of available elements :rtype: List
[ "Get", "a", "list", "of", "elements", "from", "the", "result", "and", "filter", "the", "element", "type", "by", "a", "class", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L299-L318
DinoTools/python-overpy
overpy/__init__.py
Result.from_json
def from_json(cls, data, api=None): """ Create a new instance and load data from json object. :param data: JSON data returned by the Overpass API :type data: Dict :param api: :type api: overpy.Overpass :return: New instance of Result object :rtype: overpy...
python
def from_json(cls, data, api=None): """ Create a new instance and load data from json object. :param data: JSON data returned by the Overpass API :type data: Dict :param api: :type api: overpy.Overpass :return: New instance of Result object :rtype: overpy...
[ "def", "from_json", "(", "cls", ",", "data", ",", "api", "=", "None", ")", ":", "result", "=", "cls", "(", "api", "=", "api", ")", "for", "elem_cls", "in", "[", "Node", ",", "Way", ",", "Relation", ",", "Area", "]", ":", "for", "element", "in", ...
Create a new instance and load data from json object. :param data: JSON data returned by the Overpass API :type data: Dict :param api: :type api: overpy.Overpass :return: New instance of Result object :rtype: overpy.Result
[ "Create", "a", "new", "instance", "and", "load", "data", "from", "json", "object", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L341-L359
DinoTools/python-overpy
overpy/__init__.py
Result.from_xml
def from_xml(cls, data, api=None, parser=None): """ Create a new instance and load data from xml data or object. .. note:: If parser is set to None, the functions tries to find the best parse. By default the SAX parser is chosen if a string is provided as data. ...
python
def from_xml(cls, data, api=None, parser=None): """ Create a new instance and load data from xml data or object. .. note:: If parser is set to None, the functions tries to find the best parse. By default the SAX parser is chosen if a string is provided as data. ...
[ "def", "from_xml", "(", "cls", ",", "data", ",", "api", "=", "None", ",", "parser", "=", "None", ")", ":", "if", "parser", "is", "None", ":", "if", "isinstance", "(", "data", ",", "str", ")", ":", "parser", "=", "XML_PARSER_SAX", "else", ":", "pars...
Create a new instance and load data from xml data or object. .. note:: If parser is set to None, the functions tries to find the best parse. By default the SAX parser is chosen if a string is provided as data. The parser is set to DOM if an xml.etree.ElementTree.Elem...
[ "Create", "a", "new", "instance", "and", "load", "data", "from", "xml", "data", "or", "object", ".", "..", "note", "::", "If", "parser", "is", "set", "to", "None", "the", "functions", "tries", "to", "find", "the", "best", "parse", ".", "By", "default",...
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L362-L414
DinoTools/python-overpy
overpy/__init__.py
Result.get_area
def get_area(self, area_id, resolve_missing=False): """ Get an area by its ID. :param area_id: The area ID :type area_id: Integer :param resolve_missing: Query the Overpass API if the area is missing in the result set. :return: The area :rtype: overpy.Area ...
python
def get_area(self, area_id, resolve_missing=False): """ Get an area by its ID. :param area_id: The area ID :type area_id: Integer :param resolve_missing: Query the Overpass API if the area is missing in the result set. :return: The area :rtype: overpy.Area ...
[ "def", "get_area", "(", "self", ",", "area_id", ",", "resolve_missing", "=", "False", ")", ":", "areas", "=", "self", ".", "get_areas", "(", "area_id", "=", "area_id", ")", "if", "len", "(", "areas", ")", "==", "0", ":", "if", "resolve_missing", "is", ...
Get an area by its ID. :param area_id: The area ID :type area_id: Integer :param resolve_missing: Query the Overpass API if the area is missing in the result set. :return: The area :rtype: overpy.Area :raises overpy.exception.DataIncomplete: The requested way is not avai...
[ "Get", "an", "area", "by", "its", "ID", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L416-L449
DinoTools/python-overpy
overpy/__init__.py
Result.get_areas
def get_areas(self, area_id=None, **kwargs): """ Alias for get_elements() but filter the result by Area :param area_id: The Id of the area :type area_id: Integer :return: List of elements """ return self.get_elements(Area, elem_id=area_id, **kwargs)
python
def get_areas(self, area_id=None, **kwargs): """ Alias for get_elements() but filter the result by Area :param area_id: The Id of the area :type area_id: Integer :return: List of elements """ return self.get_elements(Area, elem_id=area_id, **kwargs)
[ "def", "get_areas", "(", "self", ",", "area_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_elements", "(", "Area", ",", "elem_id", "=", "area_id", ",", "*", "*", "kwargs", ")" ]
Alias for get_elements() but filter the result by Area :param area_id: The Id of the area :type area_id: Integer :return: List of elements
[ "Alias", "for", "get_elements", "()", "but", "filter", "the", "result", "by", "Area" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L451-L459
DinoTools/python-overpy
overpy/__init__.py
Result.get_node
def get_node(self, node_id, resolve_missing=False): """ Get a node by its ID. :param node_id: The node ID :type node_id: Integer :param resolve_missing: Query the Overpass API if the node is missing in the result set. :return: The node :rtype: overpy.Node ...
python
def get_node(self, node_id, resolve_missing=False): """ Get a node by its ID. :param node_id: The node ID :type node_id: Integer :param resolve_missing: Query the Overpass API if the node is missing in the result set. :return: The node :rtype: overpy.Node ...
[ "def", "get_node", "(", "self", ",", "node_id", ",", "resolve_missing", "=", "False", ")", ":", "nodes", "=", "self", ".", "get_nodes", "(", "node_id", "=", "node_id", ")", "if", "len", "(", "nodes", ")", "==", "0", ":", "if", "not", "resolve_missing",...
Get a node by its ID. :param node_id: The node ID :type node_id: Integer :param resolve_missing: Query the Overpass API if the node is missing in the result set. :return: The node :rtype: overpy.Node :raises overpy.exception.DataIncomplete: At least one referenced node i...
[ "Get", "a", "node", "by", "its", "ID", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L461-L494
DinoTools/python-overpy
overpy/__init__.py
Result.get_nodes
def get_nodes(self, node_id=None, **kwargs): """ Alias for get_elements() but filter the result by Node() :param node_id: The Id of the node :type node_id: Integer :return: List of elements """ return self.get_elements(Node, elem_id=node_id, **kwargs)
python
def get_nodes(self, node_id=None, **kwargs): """ Alias for get_elements() but filter the result by Node() :param node_id: The Id of the node :type node_id: Integer :return: List of elements """ return self.get_elements(Node, elem_id=node_id, **kwargs)
[ "def", "get_nodes", "(", "self", ",", "node_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_elements", "(", "Node", ",", "elem_id", "=", "node_id", ",", "*", "*", "kwargs", ")" ]
Alias for get_elements() but filter the result by Node() :param node_id: The Id of the node :type node_id: Integer :return: List of elements
[ "Alias", "for", "get_elements", "()", "but", "filter", "the", "result", "by", "Node", "()" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L496-L504
DinoTools/python-overpy
overpy/__init__.py
Result.get_relation
def get_relation(self, rel_id, resolve_missing=False): """ Get a relation by its ID. :param rel_id: The relation ID :type rel_id: Integer :param resolve_missing: Query the Overpass API if the relation is missing in the result set. :return: The relation :rtype: ov...
python
def get_relation(self, rel_id, resolve_missing=False): """ Get a relation by its ID. :param rel_id: The relation ID :type rel_id: Integer :param resolve_missing: Query the Overpass API if the relation is missing in the result set. :return: The relation :rtype: ov...
[ "def", "get_relation", "(", "self", ",", "rel_id", ",", "resolve_missing", "=", "False", ")", ":", "relations", "=", "self", ".", "get_relations", "(", "rel_id", "=", "rel_id", ")", "if", "len", "(", "relations", ")", "==", "0", ":", "if", "resolve_missi...
Get a relation by its ID. :param rel_id: The relation ID :type rel_id: Integer :param resolve_missing: Query the Overpass API if the relation is missing in the result set. :return: The relation :rtype: overpy.Relation :raises overpy.exception.DataIncomplete: The requeste...
[ "Get", "a", "relation", "by", "its", "ID", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L506-L539
DinoTools/python-overpy
overpy/__init__.py
Result.get_relations
def get_relations(self, rel_id=None, **kwargs): """ Alias for get_elements() but filter the result by Relation :param rel_id: Id of the relation :type rel_id: Integer :return: List of elements """ return self.get_elements(Relation, elem_id=rel_id, **kwargs)
python
def get_relations(self, rel_id=None, **kwargs): """ Alias for get_elements() but filter the result by Relation :param rel_id: Id of the relation :type rel_id: Integer :return: List of elements """ return self.get_elements(Relation, elem_id=rel_id, **kwargs)
[ "def", "get_relations", "(", "self", ",", "rel_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_elements", "(", "Relation", ",", "elem_id", "=", "rel_id", ",", "*", "*", "kwargs", ")" ]
Alias for get_elements() but filter the result by Relation :param rel_id: Id of the relation :type rel_id: Integer :return: List of elements
[ "Alias", "for", "get_elements", "()", "but", "filter", "the", "result", "by", "Relation" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L541-L549
DinoTools/python-overpy
overpy/__init__.py
Result.get_way
def get_way(self, way_id, resolve_missing=False): """ Get a way by its ID. :param way_id: The way ID :type way_id: Integer :param resolve_missing: Query the Overpass API if the way is missing in the result set. :return: The way :rtype: overpy.Way :raises ...
python
def get_way(self, way_id, resolve_missing=False): """ Get a way by its ID. :param way_id: The way ID :type way_id: Integer :param resolve_missing: Query the Overpass API if the way is missing in the result set. :return: The way :rtype: overpy.Way :raises ...
[ "def", "get_way", "(", "self", ",", "way_id", ",", "resolve_missing", "=", "False", ")", ":", "ways", "=", "self", ".", "get_ways", "(", "way_id", "=", "way_id", ")", "if", "len", "(", "ways", ")", "==", "0", ":", "if", "resolve_missing", "is", "Fals...
Get a way by its ID. :param way_id: The way ID :type way_id: Integer :param resolve_missing: Query the Overpass API if the way is missing in the result set. :return: The way :rtype: overpy.Way :raises overpy.exception.DataIncomplete: The requested way is not available in...
[ "Get", "a", "way", "by", "its", "ID", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L551-L584
DinoTools/python-overpy
overpy/__init__.py
Result.get_ways
def get_ways(self, way_id=None, **kwargs): """ Alias for get_elements() but filter the result by Way :param way_id: The Id of the way :type way_id: Integer :return: List of elements """ return self.get_elements(Way, elem_id=way_id, **kwargs)
python
def get_ways(self, way_id=None, **kwargs): """ Alias for get_elements() but filter the result by Way :param way_id: The Id of the way :type way_id: Integer :return: List of elements """ return self.get_elements(Way, elem_id=way_id, **kwargs)
[ "def", "get_ways", "(", "self", ",", "way_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_elements", "(", "Way", ",", "elem_id", "=", "way_id", ",", "*", "*", "kwargs", ")" ]
Alias for get_elements() but filter the result by Way :param way_id: The Id of the way :type way_id: Integer :return: List of elements
[ "Alias", "for", "get_elements", "()", "but", "filter", "the", "result", "by", "Way" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L586-L594
DinoTools/python-overpy
overpy/__init__.py
Element.get_center_from_json
def get_center_from_json(cls, data): """ Get center information from json data :param data: json data :return: tuple with two elements: lat and lon :rtype: tuple """ center_lat = None center_lon = None center = data.get("center") if isinst...
python
def get_center_from_json(cls, data): """ Get center information from json data :param data: json data :return: tuple with two elements: lat and lon :rtype: tuple """ center_lat = None center_lon = None center = data.get("center") if isinst...
[ "def", "get_center_from_json", "(", "cls", ",", "data", ")", ":", "center_lat", "=", "None", "center_lon", "=", "None", "center", "=", "data", ".", "get", "(", "\"center\"", ")", "if", "isinstance", "(", "center", ",", "dict", ")", ":", "center_lat", "="...
Get center information from json data :param data: json data :return: tuple with two elements: lat and lon :rtype: tuple
[ "Get", "center", "information", "from", "json", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L631-L649
DinoTools/python-overpy
overpy/__init__.py
Area.from_xml
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
python
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "tag", ".", "lower", "(", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "c...
Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject :rtype: overpy.Way :raises overpy.exception.Eleme...
[ "Create", "new", "way", "element", "from", "XML", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L717-L758
DinoTools/python-overpy
overpy/__init__.py
Node.from_json
def from_json(cls, data, result=None): """ Create new Node element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Node :rtype: over...
python
def from_json(cls, data, result=None): """ Create new Node element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Node :rtype: over...
[ "def", "from_json", "(", "cls", ",", "data", ",", "result", "=", "None", ")", ":", "if", "data", ".", "get", "(", "\"type\"", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "cls", ...
Create new Node element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Node :rtype: overpy.Node :raises overpy.exception.ElementDataWrongTy...
[ "Create", "new", "Node", "element", "from", "JSON", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L788-L819
DinoTools/python-overpy
overpy/__init__.py
Node.from_xml
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
python
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "tag", ".", "lower", "(", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "c...
Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject :rtype: overpy.Node :raises overpy.exception.Elem...
[ "Create", "new", "way", "element", "from", "XML", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L822-L868
DinoTools/python-overpy
overpy/__init__.py
Way.get_nodes
def get_nodes(self, resolve_missing=False): """ Get the nodes defining the geometry of the way :param resolve_missing: Try to resolve missing nodes. :type resolve_missing: Boolean :return: List of nodes :rtype: List of overpy.Node :raises overpy.exception.DataInc...
python
def get_nodes(self, resolve_missing=False): """ Get the nodes defining the geometry of the way :param resolve_missing: Try to resolve missing nodes. :type resolve_missing: Boolean :return: List of nodes :rtype: List of overpy.Node :raises overpy.exception.DataInc...
[ "def", "get_nodes", "(", "self", ",", "resolve_missing", "=", "False", ")", ":", "result", "=", "[", "]", "resolved", "=", "False", "for", "node_id", "in", "self", ".", "_node_ids", ":", "try", ":", "node", "=", "self", ".", "_result", ".", "get_node",...
Get the nodes defining the geometry of the way :param resolve_missing: Try to resolve missing nodes. :type resolve_missing: Boolean :return: List of nodes :rtype: List of overpy.Node :raises overpy.exception.DataIncomplete: At least one referenced node is not available in the re...
[ "Get", "the", "nodes", "defining", "the", "geometry", "of", "the", "way" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L909-L963
DinoTools/python-overpy
overpy/__init__.py
Way.from_json
def from_json(cls, data, result=None): """ Create new Way element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Way :rtype: overpy...
python
def from_json(cls, data, result=None): """ Create new Way element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Way :rtype: overpy...
[ "def", "from_json", "(", "cls", ",", "data", ",", "result", "=", "None", ")", ":", "if", "data", ".", "get", "(", "\"type\"", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "cls", ...
Create new Way element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Way :rtype: overpy.Way :raises overpy.exception.ElementDataWrongType:...
[ "Create", "new", "Way", "element", "from", "JSON", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L966-L1005
DinoTools/python-overpy
overpy/__init__.py
Way.from_xml
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
python
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "tag", ".", "lower", "(", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "c...
Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject :rtype: overpy.Way :raises overpy.exception.Eleme...
[ "Create", "new", "way", "element", "from", "XML", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1008-L1061
DinoTools/python-overpy
overpy/__init__.py
Relation.from_json
def from_json(cls, data, result=None): """ Create new Relation element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Relation :rty...
python
def from_json(cls, data, result=None): """ Create new Relation element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Relation :rty...
[ "def", "from_json", "(", "cls", ",", "data", ",", "result", "=", "None", ")", ":", "if", "data", ".", "get", "(", "\"type\"", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "cls", ...
Create new Relation element from JSON data :param data: Element data from JSON :type data: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of Relation :rtype: overpy.Relation :raises overpy.exception.Elemen...
[ "Create", "new", "Relation", "element", "from", "JSON", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1092-L1144
DinoTools/python-overpy
overpy/__init__.py
Relation.from_xml
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
python
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "tag", ".", "lower", "(", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "c...
Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject :rtype: overpy.Relation :raises overpy.exception....
[ "Create", "new", "way", "element", "from", "XML", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1147-L1211
DinoTools/python-overpy
overpy/__init__.py
RelationMember.from_json
def from_json(cls, data, result=None): """ Create new RelationMember element from JSON data :param child: Element data from JSON :type child: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of RelationMembe...
python
def from_json(cls, data, result=None): """ Create new RelationMember element from JSON data :param child: Element data from JSON :type child: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of RelationMembe...
[ "def", "from_json", "(", "cls", ",", "data", ",", "result", "=", "None", ")", ":", "if", "data", ".", "get", "(", "\"type\"", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "cls", ...
Create new RelationMember element from JSON data :param child: Element data from JSON :type child: Dict :param result: The result this element belongs to :type result: overpy.Result :return: New instance of RelationMember :rtype: overpy.RelationMember :raises ove...
[ "Create", "new", "RelationMember", "element", "from", "JSON", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1234-L1282
DinoTools/python-overpy
overpy/__init__.py
RelationMember.from_xml
def from_xml(cls, child, result=None): """ Create new RelationMember from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this element belongs to :type result: overpy.Result :return: New relation m...
python
def from_xml(cls, child, result=None): """ Create new RelationMember from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this element belongs to :type result: overpy.Result :return: New relation m...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "attrib", ".", "get", "(", "\"type\"", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expecte...
Create new RelationMember from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this element belongs to :type result: overpy.Result :return: New relation member oject :rtype: overpy.RelationMember :...
[ "Create", "new", "RelationMember", "from", "XML", "data" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1285-L1333
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler.startElement
def startElement(self, name, attrs): """ Handle opening elements. :param name: Name of the element :type name: String :param attrs: Attributes of the element :type attrs: Dict """ if name in self.ignore_start: return try: h...
python
def startElement(self, name, attrs): """ Handle opening elements. :param name: Name of the element :type name: String :param attrs: Attributes of the element :type attrs: Dict """ if name in self.ignore_start: return try: h...
[ "def", "startElement", "(", "self", ",", "name", ",", "attrs", ")", ":", "if", "name", "in", "self", ".", "ignore_start", ":", "return", "try", ":", "handler", "=", "getattr", "(", "self", ",", "'_handle_start_%s'", "%", "name", ")", "except", "Attribute...
Handle opening elements. :param name: Name of the element :type name: String :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "elements", "." ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1405-L1420
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler.endElement
def endElement(self, name): """ Handle closing elements :param name: Name of the element :type name: String """ if name in self.ignore_end: return try: handler = getattr(self, '_handle_end_%s' % name) except AttributeError: ...
python
def endElement(self, name): """ Handle closing elements :param name: Name of the element :type name: String """ if name in self.ignore_end: return try: handler = getattr(self, '_handle_end_%s' % name) except AttributeError: ...
[ "def", "endElement", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "ignore_end", ":", "return", "try", ":", "handler", "=", "getattr", "(", "self", ",", "'_handle_end_%s'", "%", "name", ")", "except", "AttributeError", ":", "raise"...
Handle closing elements :param name: Name of the element :type name: String
[ "Handle", "closing", "elements" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1422-L1435
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_center
def _handle_start_center(self, attrs): """ Handle opening center element :param attrs: Attributes of the element :type attrs: Dict """ center_lat = attrs.get("lat") center_lon = attrs.get("lon") if center_lat is None or center_lon is None: rai...
python
def _handle_start_center(self, attrs): """ Handle opening center element :param attrs: Attributes of the element :type attrs: Dict """ center_lat = attrs.get("lat") center_lon = attrs.get("lon") if center_lat is None or center_lon is None: rai...
[ "def", "_handle_start_center", "(", "self", ",", "attrs", ")", ":", "center_lat", "=", "attrs", ".", "get", "(", "\"lat\"", ")", "center_lon", "=", "attrs", ".", "get", "(", "\"lon\"", ")", "if", "center_lat", "is", "None", "or", "center_lon", "is", "Non...
Handle opening center element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "center", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1437-L1449
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_tag
def _handle_start_tag(self, attrs): """ Handle opening tag element :param attrs: Attributes of the element :type attrs: Dict """ try: tag_key = attrs['k'] except KeyError: raise ValueError("Tag without name/key.") self._curr['tags'...
python
def _handle_start_tag(self, attrs): """ Handle opening tag element :param attrs: Attributes of the element :type attrs: Dict """ try: tag_key = attrs['k'] except KeyError: raise ValueError("Tag without name/key.") self._curr['tags'...
[ "def", "_handle_start_tag", "(", "self", ",", "attrs", ")", ":", "try", ":", "tag_key", "=", "attrs", "[", "'k'", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "\"Tag without name/key.\"", ")", "self", ".", "_curr", "[", "'tags'", "]", "[", ...
Handle opening tag element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "tag", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1451-L1462
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_node
def _handle_start_node(self, attrs): """ Handle opening node element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'lat': None, 'lon': None, 'node_id': None, ...
python
def _handle_start_node(self, attrs): """ Handle opening node element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'lat': None, 'lon': None, 'node_id': None, ...
[ "def", "_handle_start_node", "(", "self", ",", "attrs", ")", ":", "self", ".", "_curr", "=", "{", "'attributes'", ":", "dict", "(", "attrs", ")", ",", "'lat'", ":", "None", ",", "'lon'", ":", "None", ",", "'node_id'", ":", "None", ",", "'tags'", ":",...
Handle opening node element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "node", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1464-L1486
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_end_node
def _handle_end_node(self): """ Handle closing node element """ self._result.append(Node(result=self._result, **self._curr)) self._curr = {}
python
def _handle_end_node(self): """ Handle closing node element """ self._result.append(Node(result=self._result, **self._curr)) self._curr = {}
[ "def", "_handle_end_node", "(", "self", ")", ":", "self", ".", "_result", ".", "append", "(", "Node", "(", "result", "=", "self", ".", "_result", ",", "*", "*", "self", ".", "_curr", ")", ")", "self", ".", "_curr", "=", "{", "}" ]
Handle closing node element
[ "Handle", "closing", "node", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1488-L1493
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_way
def _handle_start_way(self, attrs): """ Handle opening way element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'center_lat': None, 'center_lon': None, 'attributes': dict(attrs), 'node_ids': ...
python
def _handle_start_way(self, attrs): """ Handle opening way element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'center_lat': None, 'center_lon': None, 'attributes': dict(attrs), 'node_ids': ...
[ "def", "_handle_start_way", "(", "self", ",", "attrs", ")", ":", "self", ".", "_curr", "=", "{", "'center_lat'", ":", "None", ",", "'center_lon'", ":", "None", ",", "'attributes'", ":", "dict", "(", "attrs", ")", ",", "'node_ids'", ":", "[", "]", ",", ...
Handle opening way element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "way", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1495-L1512
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_end_way
def _handle_end_way(self): """ Handle closing way element """ self._result.append(Way(result=self._result, **self._curr)) self._curr = {}
python
def _handle_end_way(self): """ Handle closing way element """ self._result.append(Way(result=self._result, **self._curr)) self._curr = {}
[ "def", "_handle_end_way", "(", "self", ")", ":", "self", ".", "_result", ".", "append", "(", "Way", "(", "result", "=", "self", ".", "_result", ",", "*", "*", "self", ".", "_curr", ")", ")", "self", ".", "_curr", "=", "{", "}" ]
Handle closing way element
[ "Handle", "closing", "way", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1514-L1519
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_area
def _handle_start_area(self, attrs): """ Handle opening area element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'tags': {}, 'area_id': None } if attrs.get('id...
python
def _handle_start_area(self, attrs): """ Handle opening area element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'tags': {}, 'area_id': None } if attrs.get('id...
[ "def", "_handle_start_area", "(", "self", ",", "attrs", ")", ":", "self", ".", "_curr", "=", "{", "'attributes'", ":", "dict", "(", "attrs", ")", ",", "'tags'", ":", "{", "}", ",", "'area_id'", ":", "None", "}", "if", "attrs", ".", "get", "(", "'id...
Handle opening area element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "area", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1521-L1535
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_end_area
def _handle_end_area(self): """ Handle closing area element """ self._result.append(Area(result=self._result, **self._curr)) self._curr = {}
python
def _handle_end_area(self): """ Handle closing area element """ self._result.append(Area(result=self._result, **self._curr)) self._curr = {}
[ "def", "_handle_end_area", "(", "self", ")", ":", "self", ".", "_result", ".", "append", "(", "Area", "(", "result", "=", "self", ".", "_result", ",", "*", "*", "self", ".", "_curr", ")", ")", "self", ".", "_curr", "=", "{", "}" ]
Handle closing area element
[ "Handle", "closing", "area", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1537-L1542
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_nd
def _handle_start_nd(self, attrs): """ Handle opening nd element :param attrs: Attributes of the element :type attrs: Dict """ if isinstance(self.cur_relation_member, RelationWay): if self.cur_relation_member.geometry is None: self.cur_relatio...
python
def _handle_start_nd(self, attrs): """ Handle opening nd element :param attrs: Attributes of the element :type attrs: Dict """ if isinstance(self.cur_relation_member, RelationWay): if self.cur_relation_member.geometry is None: self.cur_relatio...
[ "def", "_handle_start_nd", "(", "self", ",", "attrs", ")", ":", "if", "isinstance", "(", "self", ".", "cur_relation_member", ",", "RelationWay", ")", ":", "if", "self", ".", "cur_relation_member", ".", "geometry", "is", "None", ":", "self", ".", "cur_relatio...
Handle opening nd element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "nd", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1544-L1565
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_relation
def _handle_start_relation(self, attrs): """ Handle opening relation element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'members': [], 'rel_id': None, 'tags': {} ...
python
def _handle_start_relation(self, attrs): """ Handle opening relation element :param attrs: Attributes of the element :type attrs: Dict """ self._curr = { 'attributes': dict(attrs), 'members': [], 'rel_id': None, 'tags': {} ...
[ "def", "_handle_start_relation", "(", "self", ",", "attrs", ")", ":", "self", ".", "_curr", "=", "{", "'attributes'", ":", "dict", "(", "attrs", ")", ",", "'members'", ":", "[", "]", ",", "'rel_id'", ":", "None", ",", "'tags'", ":", "{", "}", "}", ...
Handle opening relation element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "relation", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1567-L1582
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_end_relation
def _handle_end_relation(self): """ Handle closing relation element """ self._result.append(Relation(result=self._result, **self._curr)) self._curr = {}
python
def _handle_end_relation(self): """ Handle closing relation element """ self._result.append(Relation(result=self._result, **self._curr)) self._curr = {}
[ "def", "_handle_end_relation", "(", "self", ")", ":", "self", ".", "_result", ".", "append", "(", "Relation", "(", "result", "=", "self", ".", "_result", ",", "*", "*", "self", ".", "_curr", ")", ")", "self", ".", "_curr", "=", "{", "}" ]
Handle closing relation element
[ "Handle", "closing", "relation", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1584-L1589
DinoTools/python-overpy
overpy/__init__.py
OSMSAXHandler._handle_start_member
def _handle_start_member(self, attrs): """ Handle opening member element :param attrs: Attributes of the element :type attrs: Dict """ params = { # ToDo: Parse attributes 'attributes': {}, 'ref': None, 'result': self._resu...
python
def _handle_start_member(self, attrs): """ Handle opening member element :param attrs: Attributes of the element :type attrs: Dict """ params = { # ToDo: Parse attributes 'attributes': {}, 'ref': None, 'result': self._resu...
[ "def", "_handle_start_member", "(", "self", ",", "attrs", ")", ":", "params", "=", "{", "# ToDo: Parse attributes", "'attributes'", ":", "{", "}", ",", "'ref'", ":", "None", ",", "'result'", ":", "self", ".", "_result", ",", "'role'", ":", "None", "}", "...
Handle opening member element :param attrs: Attributes of the element :type attrs: Dict
[ "Handle", "opening", "member", "element" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1591-L1622
DinoTools/python-overpy
overpy/helper.py
get_street
def get_street(street, areacode, api=None): """ Retrieve streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street: Name of street :param String areacode: The OSM id of the bounding area :return: Parsed result :raises overpy.exception.Ove...
python
def get_street(street, areacode, api=None): """ Retrieve streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street: Name of street :param String areacode: The OSM id of the bounding area :return: Parsed result :raises overpy.exception.Ove...
[ "def", "get_street", "(", "street", ",", "areacode", ",", "api", "=", "None", ")", ":", "if", "api", "is", "None", ":", "api", "=", "overpy", ".", "Overpass", "(", ")", "query", "=", "\"\"\"\n area(%s)->.location;\n (\n way[highway][name=\...
Retrieve streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street: Name of street :param String areacode: The OSM id of the bounding area :return: Parsed result :raises overpy.exception.OverPyException: If something bad happens.
[ "Retrieve", "streets", "in", "a", "given", "bounding", "area" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/helper.py#L6-L35
DinoTools/python-overpy
overpy/helper.py
get_intersection
def get_intersection(street1, street2, areacode, api=None): """ Retrieve intersection of two streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street1: Name of first street of intersection :param String street2: Name of second street of intersec...
python
def get_intersection(street1, street2, areacode, api=None): """ Retrieve intersection of two streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street1: Name of first street of intersection :param String street2: Name of second street of intersec...
[ "def", "get_intersection", "(", "street1", ",", "street2", ",", "areacode", ",", "api", "=", "None", ")", ":", "if", "api", "is", "None", ":", "api", "=", "overpy", ".", "Overpass", "(", ")", "query", "=", "\"\"\"\n area(%s)->.location;\n (\n ...
Retrieve intersection of two streets in a given bounding area :param overpy.Overpass api: First street of intersection :param String street1: Name of first street of intersection :param String street2: Name of second street of intersection :param String areacode: The OSM id of the bounding area :re...
[ "Retrieve", "intersection", "of", "two", "streets", "in", "a", "given", "bounding", "area" ]
train
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/helper.py#L38-L64
clemtoy/pptree
pptree/pptree.py
print_tree
def print_tree(current_node, childattr='children', nameattr='name', indent='', last='updown'): if hasattr(current_node, nameattr): name = lambda node: getattr(node, nameattr) else: name = lambda node: str(node) children = lambda node: getattr(node, childattr) nb_children = lamb...
python
def print_tree(current_node, childattr='children', nameattr='name', indent='', last='updown'): if hasattr(current_node, nameattr): name = lambda node: getattr(node, nameattr) else: name = lambda node: str(node) children = lambda node: getattr(node, childattr) nb_children = lamb...
[ "def", "print_tree", "(", "current_node", ",", "childattr", "=", "'children'", ",", "nameattr", "=", "'name'", ",", "indent", "=", "''", ",", "last", "=", "'updown'", ")", ":", "if", "hasattr", "(", "current_node", ",", "nameattr", ")", ":", "name", "=",...
Creation of balanced lists for "up" branch and "down" branch.
[ "Creation", "of", "balanced", "lists", "for", "up", "branch", "and", "down", "branch", "." ]
train
https://github.com/clemtoy/pptree/blob/16099da42b1da6d03b3a0ed0e27d0b6e90947a54/pptree/pptree.py#L16-L55
architv/chcli
challenges/cli.py
check_platforms
def check_platforms(platforms): """Checks if the platforms have a valid platform code""" if len(platforms) > 0: return all(platform in PLATFORM_IDS for platform in platforms) return True
python
def check_platforms(platforms): """Checks if the platforms have a valid platform code""" if len(platforms) > 0: return all(platform in PLATFORM_IDS for platform in platforms) return True
[ "def", "check_platforms", "(", "platforms", ")", ":", "if", "len", "(", "platforms", ")", ">", "0", ":", "return", "all", "(", "platform", "in", "PLATFORM_IDS", "for", "platform", "in", "platforms", ")", "return", "True" ]
Checks if the platforms have a valid platform code
[ "Checks", "if", "the", "platforms", "have", "a", "valid", "platform", "code" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/cli.py#L17-L21
architv/chcli
challenges/cli.py
main
def main(active, upcoming, hiring, short, goto, platforms, time): """A CLI for active and upcoming programming challenges from various platforms""" if not check_platforms(platforms): raise IncorrectParametersException('Invlaid code for platform. Please check the platform ids') try: if active: acti...
python
def main(active, upcoming, hiring, short, goto, platforms, time): """A CLI for active and upcoming programming challenges from various platforms""" if not check_platforms(platforms): raise IncorrectParametersException('Invlaid code for platform. Please check the platform ids') try: if active: acti...
[ "def", "main", "(", "active", ",", "upcoming", ",", "hiring", ",", "short", ",", "goto", ",", "platforms", ",", "time", ")", ":", "if", "not", "check_platforms", "(", "platforms", ")", ":", "raise", "IncorrectParametersException", "(", "'Invlaid code for platf...
A CLI for active and upcoming programming challenges from various platforms
[ "A", "CLI", "for", "active", "and", "upcoming", "programming", "challenges", "from", "various", "platforms" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/cli.py#L117-L164
architv/chcli
challenges/writers.py
colors
def colors(): """Creates an enum for colors""" enums = dict( TIME_LEFT="red", CONTEST_NAME="yellow", HOST="green", MISC="blue", TIME_TO_START="green", ) return type('Enum', (), enums)
python
def colors(): """Creates an enum for colors""" enums = dict( TIME_LEFT="red", CONTEST_NAME="yellow", HOST="green", MISC="blue", TIME_TO_START="green", ) return type('Enum', (), enums)
[ "def", "colors", "(", ")", ":", "enums", "=", "dict", "(", "TIME_LEFT", "=", "\"red\"", ",", "CONTEST_NAME", "=", "\"yellow\"", ",", "HOST", "=", "\"green\"", ",", "MISC", "=", "\"blue\"", ",", "TIME_TO_START", "=", "\"green\"", ",", ")", "return", "type...
Creates an enum for colors
[ "Creates", "an", "enum", "for", "colors" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/writers.py#L7-L17
architv/chcli
challenges/writers.py
challenge
def challenge(): """Creates an enum for contest type""" enums = dict( ACTIVE="active", UPCOMING="upcoming", HIRING="hiring", ALL="all", SHORT="short", ) return type('Enum', (), enums)
python
def challenge(): """Creates an enum for contest type""" enums = dict( ACTIVE="active", UPCOMING="upcoming", HIRING="hiring", ALL="all", SHORT="short", ) return type('Enum', (), enums)
[ "def", "challenge", "(", ")", ":", "enums", "=", "dict", "(", "ACTIVE", "=", "\"active\"", ",", "UPCOMING", "=", "\"upcoming\"", ",", "HIRING", "=", "\"hiring\"", ",", "ALL", "=", "\"all\"", ",", "SHORT", "=", "\"short\"", ",", ")", "return", "type", "...
Creates an enum for contest type
[ "Creates", "an", "enum", "for", "contest", "type" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/writers.py#L20-L30
architv/chcli
challenges/writers.py
get_time_string
def get_time_string(contest, contest_type): """Return a string with time for the contest to begin/end""" if contest_type == challenge().ACTIVE: time_diff = time_difference(contest["end"]) elif contest_type == challenge().UPCOMING: time_diff = time_difference(contest["start"]) elif contest_type in [chal...
python
def get_time_string(contest, contest_type): """Return a string with time for the contest to begin/end""" if contest_type == challenge().ACTIVE: time_diff = time_difference(contest["end"]) elif contest_type == challenge().UPCOMING: time_diff = time_difference(contest["start"]) elif contest_type in [chal...
[ "def", "get_time_string", "(", "contest", ",", "contest_type", ")", ":", "if", "contest_type", "==", "challenge", "(", ")", ".", "ACTIVE", ":", "time_diff", "=", "time_difference", "(", "contest", "[", "\"end\"", "]", ")", "elif", "contest_type", "==", "chal...
Return a string with time for the contest to begin/end
[ "Return", "a", "string", "with", "time", "for", "the", "contest", "to", "begin", "/", "end" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/writers.py#L52-L72
architv/chcli
challenges/utilities.py
time_difference
def time_difference(target_time): """Calculate the difference between the current time and the given time""" TimeDiff = namedtuple("TimeDiff", ["days", "hours", "minutes", "seconds"]) time_diff = format_date(target_time) - datetime.utcnow() hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds =...
python
def time_difference(target_time): """Calculate the difference between the current time and the given time""" TimeDiff = namedtuple("TimeDiff", ["days", "hours", "minutes", "seconds"]) time_diff = format_date(target_time) - datetime.utcnow() hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds =...
[ "def", "time_difference", "(", "target_time", ")", ":", "TimeDiff", "=", "namedtuple", "(", "\"TimeDiff\"", ",", "[", "\"days\"", ",", "\"hours\"", ",", "\"minutes\"", ",", "\"seconds\"", "]", ")", "time_diff", "=", "format_date", "(", "target_time", ")", "-",...
Calculate the difference between the current time and the given time
[ "Calculate", "the", "difference", "between", "the", "current", "time", "and", "the", "given", "time" ]
train
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/utilities.py#L12-L18
manjitkumar/drf-url-filters
filters/validations.py
IntegerLike
def IntegerLike(msg=None): ''' Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of digits ''' def fn(value): if not any([ isinstance(value, numbers.Integral), (isinstance(v...
python
def IntegerLike(msg=None): ''' Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of digits ''' def fn(value): if not any([ isinstance(value, numbers.Integral), (isinstance(v...
[ "def", "IntegerLike", "(", "msg", "=", "None", ")", ":", "def", "fn", "(", "value", ")", ":", "if", "not", "any", "(", "[", "isinstance", "(", "value", ",", "numbers", ".", "Integral", ")", ",", "(", "isinstance", "(", "value", ",", "float", ")", ...
Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of digits
[ "Checks", "whether", "a", "value", "is", ":", "-", "int", "or", "-", "long", "or", "-", "float", "without", "a", "fractional", "part", "or", "-", "str", "or", "unicode", "composed", "only", "of", "digits" ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/filters/validations.py#L13-L32
manjitkumar/drf-url-filters
filters/validations.py
Alphanumeric
def Alphanumeric(msg=None): ''' Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of alphanumeric characters ''' def fn(value): if not any([ isinstance(value, numbers.Integral), ...
python
def Alphanumeric(msg=None): ''' Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of alphanumeric characters ''' def fn(value): if not any([ isinstance(value, numbers.Integral), ...
[ "def", "Alphanumeric", "(", "msg", "=", "None", ")", ":", "def", "fn", "(", "value", ")", ":", "if", "not", "any", "(", "[", "isinstance", "(", "value", ",", "numbers", ".", "Integral", ")", ",", "(", "isinstance", "(", "value", ",", "float", ")", ...
Checks whether a value is: - int, or - long, or - float without a fractional part, or - str or unicode composed only of alphanumeric characters
[ "Checks", "whether", "a", "value", "is", ":", "-", "int", "or", "-", "long", "or", "-", "float", "without", "a", "fractional", "part", "or", "-", "str", "or", "unicode", "composed", "only", "of", "alphanumeric", "characters" ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/filters/validations.py#L35-L54
manjitkumar/drf-url-filters
filters/validations.py
StrictlyAlphanumeric
def StrictlyAlphanumeric(msg=None): ''' Checks whether a value is: - str or unicode, and - composed of both alphabets and digits ''' def fn(value): if not ( isinstance(value, basestring) and value.isalnum() and not value.isdigit() and not ...
python
def StrictlyAlphanumeric(msg=None): ''' Checks whether a value is: - str or unicode, and - composed of both alphabets and digits ''' def fn(value): if not ( isinstance(value, basestring) and value.isalnum() and not value.isdigit() and not ...
[ "def", "StrictlyAlphanumeric", "(", "msg", "=", "None", ")", ":", "def", "fn", "(", "value", ")", ":", "if", "not", "(", "isinstance", "(", "value", ",", "basestring", ")", "and", "value", ".", "isalnum", "(", ")", "and", "not", "value", ".", "isdigi...
Checks whether a value is: - str or unicode, and - composed of both alphabets and digits
[ "Checks", "whether", "a", "value", "is", ":", "-", "str", "or", "unicode", "and", "-", "composed", "of", "both", "alphabets", "and", "digits" ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/filters/validations.py#L57-L75
manjitkumar/drf-url-filters
filters/validations.py
DatetimeWithTZ
def DatetimeWithTZ(msg=None): ''' Checks whether a value is : - a valid castable datetime object with timezone. ''' def fn(value): try: date = parse_datetime(value) or parse_date(value) if date is not None: return date else: ...
python
def DatetimeWithTZ(msg=None): ''' Checks whether a value is : - a valid castable datetime object with timezone. ''' def fn(value): try: date = parse_datetime(value) or parse_date(value) if date is not None: return date else: ...
[ "def", "DatetimeWithTZ", "(", "msg", "=", "None", ")", ":", "def", "fn", "(", "value", ")", ":", "try", ":", "date", "=", "parse_datetime", "(", "value", ")", "or", "parse_date", "(", "value", ")", "if", "date", "is", "not", "None", ":", "return", ...
Checks whether a value is : - a valid castable datetime object with timezone.
[ "Checks", "whether", "a", "value", "is", ":", "-", "a", "valid", "castable", "datetime", "object", "with", "timezone", "." ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/filters/validations.py#L78-L92
manjitkumar/drf-url-filters
filters/validations.py
CSVofIntegers
def CSVofIntegers(msg=None): ''' Checks whether a value is list of integers. Returns list of integers or just one integer in list if there is only one element in given CSV string. ''' def fn(value): try: if isinstance(value, basestring): if ',' in value: ...
python
def CSVofIntegers(msg=None): ''' Checks whether a value is list of integers. Returns list of integers or just one integer in list if there is only one element in given CSV string. ''' def fn(value): try: if isinstance(value, basestring): if ',' in value: ...
[ "def", "CSVofIntegers", "(", "msg", "=", "None", ")", ":", "def", "fn", "(", "value", ")", ":", "try", ":", "if", "isinstance", "(", "value", ",", "basestring", ")", ":", "if", "','", "in", "value", ":", "value", "=", "list", "(", "map", "(", "in...
Checks whether a value is list of integers. Returns list of integers or just one integer in list if there is only one element in given CSV string.
[ "Checks", "whether", "a", "value", "is", "list", "of", "integers", ".", "Returns", "list", "of", "integers", "or", "just", "one", "integer", "in", "list", "if", "there", "is", "only", "one", "element", "in", "given", "CSV", "string", "." ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/filters/validations.py#L95-L121
manjitkumar/drf-url-filters
example_app/views.py
TeamsViewSet.get_queryset
def get_queryset(self): """ Optionally restricts the queryset by filtering against query parameters in the URL. """ query_params = self.request.query_params url_params = self.kwargs # get queryset_filters from FilterMixin queryset_filters = self.get_db_f...
python
def get_queryset(self): """ Optionally restricts the queryset by filtering against query parameters in the URL. """ query_params = self.request.query_params url_params = self.kwargs # get queryset_filters from FilterMixin queryset_filters = self.get_db_f...
[ "def", "get_queryset", "(", "self", ")", ":", "query_params", "=", "self", ".", "request", ".", "query_params", "url_params", "=", "self", ".", "kwargs", "# get queryset_filters from FilterMixin", "queryset_filters", "=", "self", ".", "get_db_filters", "(", "url_par...
Optionally restricts the queryset by filtering against query parameters in the URL.
[ "Optionally", "restricts", "the", "queryset", "by", "filtering", "against", "query", "parameters", "in", "the", "URL", "." ]
train
https://github.com/manjitkumar/drf-url-filters/blob/ebac358729bcd9aa70537247b2ccd6005f5678c1/example_app/views.py#L90-L112
nimbis/cmsplugin-newsplus
cmsplugin_newsplus/settings.py
get_setting
def get_setting(name, default): """ A little helper for fetching global settings with a common prefix. """ parent_name = "CMSPLUGIN_NEWS_{0}".format(name) return getattr(django_settings, parent_name, default)
python
def get_setting(name, default): """ A little helper for fetching global settings with a common prefix. """ parent_name = "CMSPLUGIN_NEWS_{0}".format(name) return getattr(django_settings, parent_name, default)
[ "def", "get_setting", "(", "name", ",", "default", ")", ":", "parent_name", "=", "\"CMSPLUGIN_NEWS_{0}\"", ".", "format", "(", "name", ")", "return", "getattr", "(", "django_settings", ",", "parent_name", ",", "default", ")" ]
A little helper for fetching global settings with a common prefix.
[ "A", "little", "helper", "for", "fetching", "global", "settings", "with", "a", "common", "prefix", "." ]
train
https://github.com/nimbis/cmsplugin-newsplus/blob/1787fb674faa7800845f18ce782154e290f6be27/cmsplugin_newsplus/settings.py#L5-L10
nimbis/cmsplugin-newsplus
cmsplugin_newsplus/admin.py
NewsAdmin.make_published
def make_published(self, request, queryset): """ Marks selected news items as published """ rows_updated = queryset.update(is_published=True) self.message_user(request, ungettext('%(count)d newsitem was published', ...
python
def make_published(self, request, queryset): """ Marks selected news items as published """ rows_updated = queryset.update(is_published=True) self.message_user(request, ungettext('%(count)d newsitem was published', ...
[ "def", "make_published", "(", "self", ",", "request", ",", "queryset", ")", ":", "rows_updated", "=", "queryset", ".", "update", "(", "is_published", "=", "True", ")", "self", ".", "message_user", "(", "request", ",", "ungettext", "(", "'%(count)d newsitem was...
Marks selected news items as published
[ "Marks", "selected", "news", "items", "as", "published" ]
train
https://github.com/nimbis/cmsplugin-newsplus/blob/1787fb674faa7800845f18ce782154e290f6be27/cmsplugin_newsplus/admin.py#L38-L46
nimbis/cmsplugin-newsplus
cmsplugin_newsplus/admin.py
NewsAdmin.make_unpublished
def make_unpublished(self, request, queryset): """ Marks selected news items as unpublished """ rows_updated = queryset.update(is_published=False) self.message_user(request, ungettext('%(count)d newsitem was unpublished', ...
python
def make_unpublished(self, request, queryset): """ Marks selected news items as unpublished """ rows_updated = queryset.update(is_published=False) self.message_user(request, ungettext('%(count)d newsitem was unpublished', ...
[ "def", "make_unpublished", "(", "self", ",", "request", ",", "queryset", ")", ":", "rows_updated", "=", "queryset", ".", "update", "(", "is_published", "=", "False", ")", "self", ".", "message_user", "(", "request", ",", "ungettext", "(", "'%(count)d newsitem ...
Marks selected news items as unpublished
[ "Marks", "selected", "news", "items", "as", "unpublished" ]
train
https://github.com/nimbis/cmsplugin-newsplus/blob/1787fb674faa7800845f18ce782154e290f6be27/cmsplugin_newsplus/admin.py#L49-L57
nimbis/cmsplugin-newsplus
cmsplugin_newsplus/widgets/tinymce_widget.py
TinyMCEEditor.render
def render(self, name, value, attrs=None): if value is None: value = '' value = smart_unicode(value) final_attrs = self.build_attrs(attrs) final_attrs['name'] = name assert 'id' in final_attrs, \ "TinyMCE widget attributes must contain 'id'" mce_co...
python
def render(self, name, value, attrs=None): if value is None: value = '' value = smart_unicode(value) final_attrs = self.build_attrs(attrs) final_attrs['name'] = name assert 'id' in final_attrs, \ "TinyMCE widget attributes must contain 'id'" mce_co...
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "if", "value", "is", "None", ":", "value", "=", "''", "value", "=", "smart_unicode", "(", "value", ")", "final_attrs", "=", "self", ".", "build_attrs", "(",...
plugins = mce_config.get("plugins", "") if len(plugins): plugins += "," plugins += "-cmsplugins" mce_config['plugins'] = plugins adv2 = mce_config.get('theme_advanced_buttons1', "") if len(adv2): adv2 = "," + adv2 adv2 = "cmsplugins,cmspluginsedit"...
[ "plugins", "=", "mce_config", ".", "get", "(", "plugins", ")", "if", "len", "(", "plugins", ")", ":", "plugins", "+", "=", "plugins", "+", "=", "-", "cmsplugins", "mce_config", "[", "plugins", "]", "=", "plugins", "adv2", "=", "mce_config", ".", "get",...
train
https://github.com/nimbis/cmsplugin-newsplus/blob/1787fb674faa7800845f18ce782154e290f6be27/cmsplugin_newsplus/widgets/tinymce_widget.py#L48-L100
tutorcruncher/pydf
pydf/wkhtmltopdf.py
_execute_wk
def _execute_wk(*args, input=None): """ Generate path for the wkhtmltopdf binary and execute command. :param args: args to pass straight to subprocess.Popen :return: stdout, stderr """ wk_args = (WK_PATH,) + args return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=sub...
python
def _execute_wk(*args, input=None): """ Generate path for the wkhtmltopdf binary and execute command. :param args: args to pass straight to subprocess.Popen :return: stdout, stderr """ wk_args = (WK_PATH,) + args return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=sub...
[ "def", "_execute_wk", "(", "*", "args", ",", "input", "=", "None", ")", ":", "wk_args", "=", "(", "WK_PATH", ",", ")", "+", "args", "return", "subprocess", ".", "run", "(", "wk_args", ",", "input", "=", "input", ",", "stdout", "=", "subprocess", ".",...
Generate path for the wkhtmltopdf binary and execute command. :param args: args to pass straight to subprocess.Popen :return: stdout, stderr
[ "Generate", "path", "for", "the", "wkhtmltopdf", "binary", "and", "execute", "command", "." ]
train
https://github.com/tutorcruncher/pydf/blob/53dd030f02f112593ed6e2655160a40b892a23c0/pydf/wkhtmltopdf.py#L22-L30
tutorcruncher/pydf
pydf/wkhtmltopdf.py
generate_pdf
def generate_pdf(html, *, cache_dir: Path=DFT_CACHE_DIR, grayscale: bool=False, lowquality: bool=False, margin_bottom: str=None, margin_left: str=None, margin_right: str=None, margin_top: str=None, ...
python
def generate_pdf(html, *, cache_dir: Path=DFT_CACHE_DIR, grayscale: bool=False, lowquality: bool=False, margin_bottom: str=None, margin_left: str=None, margin_right: str=None, margin_top: str=None, ...
[ "def", "generate_pdf", "(", "html", ",", "*", ",", "cache_dir", ":", "Path", "=", "DFT_CACHE_DIR", ",", "grayscale", ":", "bool", "=", "False", ",", "lowquality", ":", "bool", "=", "False", ",", "margin_bottom", ":", "str", "=", "None", ",", "margin_left...
Generate a pdf from either a url or a html string. After the html and url arguments all other arguments are passed straight to wkhtmltopdf For details on extra arguments see the output of get_help() and get_extended_help() All arguments whether specified or caught with extra_kwargs are converted ...
[ "Generate", "a", "pdf", "from", "either", "a", "url", "or", "a", "html", "string", "." ]
train
https://github.com/tutorcruncher/pydf/blob/53dd030f02f112593ed6e2655160a40b892a23c0/pydf/wkhtmltopdf.py#L78-L153
tutorcruncher/pydf
pydf/wkhtmltopdf.py
get_version
def get_version(): """ Get version of pydf and wkhtmltopdf binary :return: version string """ try: wk_version = _string_execute('-V') except Exception as e: # we catch all errors here to make sure we get a version no matter what wk_version = '%s: %s' % (e.__class__.__nam...
python
def get_version(): """ Get version of pydf and wkhtmltopdf binary :return: version string """ try: wk_version = _string_execute('-V') except Exception as e: # we catch all errors here to make sure we get a version no matter what wk_version = '%s: %s' % (e.__class__.__nam...
[ "def", "get_version", "(", ")", ":", "try", ":", "wk_version", "=", "_string_execute", "(", "'-V'", ")", "except", "Exception", "as", "e", ":", "# we catch all errors here to make sure we get a version no matter what", "wk_version", "=", "'%s: %s'", "%", "(", "e", "...
Get version of pydf and wkhtmltopdf binary :return: version string
[ "Get", "version", "of", "pydf", "and", "wkhtmltopdf", "binary" ]
train
https://github.com/tutorcruncher/pydf/blob/53dd030f02f112593ed6e2655160a40b892a23c0/pydf/wkhtmltopdf.py#L160-L171
PiotrDabkowski/pyjsparser
pyjsparser/parser.py
PyJsParser._interpret_regexp
def _interpret_regexp(self, string, flags): '''Perform sctring escape - for regexp literals''' self.index = 0 self.length = len(string) self.source = string self.lineNumber = 0 self.lineStart = 0 octal = False st = '' inside_square = 0 whil...
python
def _interpret_regexp(self, string, flags): '''Perform sctring escape - for regexp literals''' self.index = 0 self.length = len(string) self.source = string self.lineNumber = 0 self.lineStart = 0 octal = False st = '' inside_square = 0 whil...
[ "def", "_interpret_regexp", "(", "self", ",", "string", ",", "flags", ")", ":", "self", ".", "index", "=", "0", "self", ".", "length", "=", "len", "(", "string", ")", "self", ".", "source", "=", "string", "self", ".", "lineNumber", "=", "0", "self", ...
Perform sctring escape - for regexp literals
[ "Perform", "sctring", "escape", "-", "for", "regexp", "literals" ]
train
https://github.com/PiotrDabkowski/pyjsparser/blob/5465d037b30e334cb0997f2315ec1e451b8ad4c1/pyjsparser/parser.py#L518-L608
sckott/habanero
habanero/crossref/crossref.py
Crossref.works
def works(self, ids = None, query = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref works :param ids: [Array] DOIs ...
python
def works(self, ids = None, query = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref works :param ids: [Array] DOIs ...
[ "def", "works", "(", "self", ",", "ids", "=", "None", ",", "query", "=", "None", ",", "filter", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "sample", "=", "None", ",", "sort", "=", "None", ",", "order", "=", "None", ...
Search Crossref works :param ids: [Array] DOIs (digital object identifier) or other identifiers :param query: [String] A query string :param filter: [Hash] Filter options. See examples for usage. Accepts a dict, with filter names and their values. For repeating filter names ...
[ "Search", "Crossref", "works" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L171-L296
sckott/habanero
habanero/crossref/crossref.py
Crossref.prefixes
def prefixes(self, ids = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, works = False, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref prefixes :param ids: [Array...
python
def prefixes(self, ids = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, works = False, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref prefixes :param ids: [Array...
[ "def", "prefixes", "(", "self", ",", "ids", "=", "None", ",", "filter", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "sample", "=", "None", ",", "sort", "=", "None", ",", "order", "=", "None", ",", "facet", "=", "None"...
Search Crossref prefixes :param ids: [Array] DOIs (digital object identifier) or other identifiers :param filter: [Hash] Filter options. See examples for usage. Accepts a dict, with filter names and their values. For repeating filter names pass in a list of the values to that fi...
[ "Search", "Crossref", "prefixes" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L361-L430
sckott/habanero
habanero/crossref/crossref.py
Crossref.types
def types(self, ids = None, query = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, works = False, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref types :param ids...
python
def types(self, ids = None, query = None, filter = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, works = False, select = None, cursor = None, cursor_max = 5000, **kwargs): ''' Search Crossref types :param ids...
[ "def", "types", "(", "self", ",", "ids", "=", "None", ",", "query", "=", "None", ",", "filter", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "sample", "=", "None", ",", "sort", "=", "None", ",", "order", "=", "None", ...
Search Crossref types :param ids: [Array] Type identifier, e.g., journal :param query: [String] A query string :param filter: [Hash] Filter options. See examples for usage. Accepts a dict, with filter names and their values. For repeating filter names pass in a list of t...
[ "Search", "Crossref", "types" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L573-L625
sckott/habanero
habanero/crossref/crossref.py
Crossref.licenses
def licenses(self, query = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, **kwargs): ''' Search Crossref licenses :param query: [String] A query string :param offset: [Fixnum] Number of record to start at, from 1 to...
python
def licenses(self, query = None, offset = None, limit = None, sample = None, sort = None, order = None, facet = None, **kwargs): ''' Search Crossref licenses :param query: [String] A query string :param offset: [Fixnum] Number of record to start at, from 1 to...
[ "def", "licenses", "(", "self", ",", "query", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "sample", "=", "None", ",", "sort", "=", "None", ",", "order", "=", "None", ",", "facet", "=", "None", ",", "*", "*", "kwargs",...
Search Crossref licenses :param query: [String] A query string :param offset: [Fixnum] Number of record to start at, from 1 to 10000 :param limit: [Fixnum] Number of results to return. Not relevant when searching with specific dois. Default: 20. Max: 1000 :param sort: [String] Field to ...
[ "Search", "Crossref", "licenses" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L627-L659
sckott/habanero
habanero/crossref/crossref.py
Crossref.registration_agency
def registration_agency(self, ids, **kwargs): ''' Determine registration agency for DOIs :param ids: [Array] DOIs (digital object identifier) or other identifiers :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) ...
python
def registration_agency(self, ids, **kwargs): ''' Determine registration agency for DOIs :param ids: [Array] DOIs (digital object identifier) or other identifiers :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) ...
[ "def", "registration_agency", "(", "self", ",", "ids", ",", "*", "*", "kwargs", ")", ":", "check_kwargs", "(", "[", "\"query\"", ",", "\"filter\"", ",", "\"offset\"", ",", "\"limit\"", ",", "\"sample\"", ",", "\"sort\"", ",", "\"order\"", ",", "\"facet\"", ...
Determine registration agency for DOIs :param ids: [Array] DOIs (digital object identifier) or other identifiers :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) :return: list of DOI minting agencies Usage:: ...
[ "Determine", "registration", "agency", "for", "DOIs" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L661-L688
sckott/habanero
habanero/crossref/crossref.py
Crossref.random_dois
def random_dois(self, sample = 10, **kwargs): ''' Get a random set of DOIs :param sample: [Fixnum] Number of random DOIs to return. Default: 10. Max: 100 :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) :retur...
python
def random_dois(self, sample = 10, **kwargs): ''' Get a random set of DOIs :param sample: [Fixnum] Number of random DOIs to return. Default: 10. Max: 100 :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) :retur...
[ "def", "random_dois", "(", "self", ",", "sample", "=", "10", ",", "*", "*", "kwargs", ")", ":", "res", "=", "request", "(", "self", ".", "mailto", ",", "self", ".", "base_url", ",", "\"/works/\"", ",", "None", ",", "None", ",", "None", ",", "None",...
Get a random set of DOIs :param sample: [Fixnum] Number of random DOIs to return. Default: 10. Max: 100 :param kwargs: additional named arguments passed on to `requests.get`, e.g., field queries (see examples) :return: [Array] of DOIs Usage:: from habanero imp...
[ "Get", "a", "random", "set", "of", "DOIs" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/crossref/crossref.py#L690-L712
sckott/habanero
habanero/cn/styles.py
csl_styles
def csl_styles(**kwargs): ''' Get list of styles from https://github.com/citation-style-language/styles :param kwargs: any additional arguments will be passed on to `requests.get` :return: list, of CSL styles Usage:: from habanero import cn cn.csl_styles() ''' base = "https://api.github.co...
python
def csl_styles(**kwargs): ''' Get list of styles from https://github.com/citation-style-language/styles :param kwargs: any additional arguments will be passed on to `requests.get` :return: list, of CSL styles Usage:: from habanero import cn cn.csl_styles() ''' base = "https://api.github.co...
[ "def", "csl_styles", "(", "*", "*", "kwargs", ")", ":", "base", "=", "\"https://api.github.com/repos/citation-style-language/styles\"", "tt", "=", "requests", ".", "get", "(", "base", "+", "'/commits?per_page=1'", ",", "*", "*", "kwargs", ")", "tt", ".", "raise_...
Get list of styles from https://github.com/citation-style-language/styles :param kwargs: any additional arguments will be passed on to `requests.get` :return: list, of CSL styles Usage:: from habanero import cn cn.csl_styles()
[ "Get", "list", "of", "styles", "from", "https", ":", "//", "github", ".", "com", "/", "citation", "-", "style", "-", "language", "/", "styles" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/cn/styles.py#L7-L33
sckott/habanero
habanero/cn/cn.py
content_negotiation
def content_negotiation(ids = None, format = "bibtex", style = 'apa', locale = "en-US", url = None, **kwargs): ''' Get citations in various formats from CrossRef :param ids: [str] Search by a single DOI or many DOIs, each a string. If many passed in, do so in a list :param format: [str] Nam...
python
def content_negotiation(ids = None, format = "bibtex", style = 'apa', locale = "en-US", url = None, **kwargs): ''' Get citations in various formats from CrossRef :param ids: [str] Search by a single DOI or many DOIs, each a string. If many passed in, do so in a list :param format: [str] Nam...
[ "def", "content_negotiation", "(", "ids", "=", "None", ",", "format", "=", "\"bibtex\"", ",", "style", "=", "'apa'", ",", "locale", "=", "\"en-US\"", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "url", "is", "None", ":", "url", ...
Get citations in various formats from CrossRef :param ids: [str] Search by a single DOI or many DOIs, each a string. If many passed in, do so in a list :param format: [str] Name of the format. One of "rdf-xml", "turtle", "citeproc-json", "citeproc-json-ish", "text", "ris", "bibtex" (Default), "...
[ "Get", "citations", "in", "various", "formats", "from", "CrossRef" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/cn/cn.py#L4-L76
sckott/habanero
habanero/counts/counts.py
citation_count
def citation_count(doi, url = "http://www.crossref.org/openurl/", key = "cboettig@ropensci.org", **kwargs): ''' Get a citation count with a DOI :param doi: [String] DOI, digital object identifier :param url: [String] the API url for the function (should be left to default) :param keyc: [String]...
python
def citation_count(doi, url = "http://www.crossref.org/openurl/", key = "cboettig@ropensci.org", **kwargs): ''' Get a citation count with a DOI :param doi: [String] DOI, digital object identifier :param url: [String] the API url for the function (should be left to default) :param keyc: [String]...
[ "def", "citation_count", "(", "doi", ",", "url", "=", "\"http://www.crossref.org/openurl/\"", ",", "key", "=", "\"cboettig@ropensci.org\"", ",", "*", "*", "kwargs", ")", ":", "args", "=", "{", "\"id\"", ":", "\"doi:\"", "+", "doi", ",", "\"pid\"", ":", "key"...
Get a citation count with a DOI :param doi: [String] DOI, digital object identifier :param url: [String] the API url for the function (should be left to default) :param keyc: [String] your API key See http://labs.crossref.org/openurl/ for more info on this Crossref API service. Usage:: f...
[ "Get", "a", "citation", "count", "with", "a", "DOI" ]
train
https://github.com/sckott/habanero/blob/a17d87070378786bbb138e1c9712ecad9aacf38e/habanero/counts/counts.py#L5-L30
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.findHierarchy
def findHierarchy(self, max_subs=10): """Find hierarchy for the LaTeX source. >>> TOC.fromLatex(r'\subsection{yo}\section{hello}').findHierarchy() ('section', 'subsection') >>> TOC.fromLatex( ... r'\subsubsubsection{huh}\subsubsection{hah}').findHierarchy() ('subsubsecti...
python
def findHierarchy(self, max_subs=10): """Find hierarchy for the LaTeX source. >>> TOC.fromLatex(r'\subsection{yo}\section{hello}').findHierarchy() ('section', 'subsection') >>> TOC.fromLatex( ... r'\subsubsubsection{huh}\subsubsection{hah}').findHierarchy() ('subsubsecti...
[ "def", "findHierarchy", "(", "self", ",", "max_subs", "=", "10", ")", ":", "hierarchy", "=", "[", "]", "defaults", "=", "TOC", ".", "default_hierarchy", "+", "tuple", "(", "'%ssection'", "%", "(", "'sub'", "*", "i", ")", "for", "i", "in", "range", "(...
Find hierarchy for the LaTeX source. >>> TOC.fromLatex(r'\subsection{yo}\section{hello}').findHierarchy() ('section', 'subsection') >>> TOC.fromLatex( ... r'\subsubsubsection{huh}\subsubsection{hah}').findHierarchy() ('subsubsection', 'subsubsubsection') >>> TOC.fromLate...
[ "Find", "hierarchy", "for", "the", "LaTeX", "source", "." ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L69-L87
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.getHeadingLevel
def getHeadingLevel(ts, hierarchy=default_hierarchy): """Extract heading level for a particular Tex element, given a specified hierarchy. >>> ts = TexSoup(r'\section{Hello}').section >>> TOC.getHeadingLevel(ts) 2 >>> ts2 = TexSoup(r'\chapter{hello again}').chapter ...
python
def getHeadingLevel(ts, hierarchy=default_hierarchy): """Extract heading level for a particular Tex element, given a specified hierarchy. >>> ts = TexSoup(r'\section{Hello}').section >>> TOC.getHeadingLevel(ts) 2 >>> ts2 = TexSoup(r'\chapter{hello again}').chapter ...
[ "def", "getHeadingLevel", "(", "ts", ",", "hierarchy", "=", "default_hierarchy", ")", ":", "try", ":", "return", "hierarchy", ".", "index", "(", "ts", ".", "name", ")", "+", "1", "except", "ValueError", ":", "if", "ts", ".", "name", ".", "endswith", "(...
Extract heading level for a particular Tex element, given a specified hierarchy. >>> ts = TexSoup(r'\section{Hello}').section >>> TOC.getHeadingLevel(ts) 2 >>> ts2 = TexSoup(r'\chapter{hello again}').chapter >>> TOC.getHeadingLevel(ts2) 1 >>> ts3 = TexSou...
[ "Extract", "heading", "level", "for", "a", "particular", "Tex", "element", "given", "a", "specified", "hierarchy", "." ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L90-L115
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.parseTopDepth
def parseTopDepth(self, descendants=()): """Parse tex for highest tag in hierarchy >>> TOC.fromLatex('\\section{Hah}\\subsection{No}').parseTopDepth() 1 >>> s = '\\subsubsubsection{Yo}\\subsubsection{Hah}' >>> TOC.fromLatex(s).parseTopDepth() 1 >>> h = ('section'...
python
def parseTopDepth(self, descendants=()): """Parse tex for highest tag in hierarchy >>> TOC.fromLatex('\\section{Hah}\\subsection{No}').parseTopDepth() 1 >>> s = '\\subsubsubsection{Yo}\\subsubsection{Hah}' >>> TOC.fromLatex(s).parseTopDepth() 1 >>> h = ('section'...
[ "def", "parseTopDepth", "(", "self", ",", "descendants", "=", "(", ")", ")", ":", "descendants", "=", "list", "(", "descendants", ")", "or", "list", "(", "getattr", "(", "self", ".", "source", ",", "'descendants'", ",", "descendants", ")", ")", "if", "...
Parse tex for highest tag in hierarchy >>> TOC.fromLatex('\\section{Hah}\\subsection{No}').parseTopDepth() 1 >>> s = '\\subsubsubsection{Yo}\\subsubsection{Hah}' >>> TOC.fromLatex(s).parseTopDepth() 1 >>> h = ('section', 'subsubsection', 'subsubsubsection') >>> T...
[ "Parse", "tex", "for", "highest", "tag", "in", "hierarchy" ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L117-L133
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.parseBranches
def parseBranches(self, descendants): """ Parse top level of latex :param list elements: list of source objects :return: list of filtered TreeOfContents objects >>> toc = TOC.fromLatex(r'\section{h1}\subsection{subh1}\section{h2}\ ... \subsection{subh2}') >>> toc...
python
def parseBranches(self, descendants): """ Parse top level of latex :param list elements: list of source objects :return: list of filtered TreeOfContents objects >>> toc = TOC.fromLatex(r'\section{h1}\subsection{subh1}\section{h2}\ ... \subsection{subh2}') >>> toc...
[ "def", "parseBranches", "(", "self", ",", "descendants", ")", ":", "i", ",", "branches", "=", "self", ".", "parseTopDepth", "(", "descendants", ")", ",", "[", "]", "for", "descendant", "in", "descendants", ":", "if", "self", ".", "getHeadingLevel", "(", ...
Parse top level of latex :param list elements: list of source objects :return: list of filtered TreeOfContents objects >>> toc = TOC.fromLatex(r'\section{h1}\subsection{subh1}\section{h2}\ ... \subsection{subh2}') >>> toc.parseTopDepth(toc.descendants) 1 >>> toc....
[ "Parse", "top", "level", "of", "latex", ":", "param", "list", "elements", ":", "list", "of", "source", "objects", ":", "return", ":", "list", "of", "filtered", "TreeOfContents", "objects" ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L152-L177
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.fromFile
def fromFile(path_or_buffer): """Creates abstraction using path to file :param str path_or_buffer: path to tex file or buffer :return: TreeOfContents object """ return TOC.fromLatex(open(path_or_buffer).read() if isinstance(path_or_buffer, str) ...
python
def fromFile(path_or_buffer): """Creates abstraction using path to file :param str path_or_buffer: path to tex file or buffer :return: TreeOfContents object """ return TOC.fromLatex(open(path_or_buffer).read() if isinstance(path_or_buffer, str) ...
[ "def", "fromFile", "(", "path_or_buffer", ")", ":", "return", "TOC", ".", "fromLatex", "(", "open", "(", "path_or_buffer", ")", ".", "read", "(", ")", "if", "isinstance", "(", "path_or_buffer", ",", "str", ")", "else", "path_or_buffer", ")" ]
Creates abstraction using path to file :param str path_or_buffer: path to tex file or buffer :return: TreeOfContents object
[ "Creates", "abstraction", "using", "path", "to", "file" ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L213-L221
alvinwan/tex2py
tex2py/tex2py.py
TreeOfContents.fromLatex
def fromLatex(tex, *args, **kwargs): """Creates abstraction using Latex :param str tex: Latex :return: TreeOfContents object """ source = TexSoup(tex) return TOC('[document]', source=source, descendants=list(source.descendants), *args, **kwargs)
python
def fromLatex(tex, *args, **kwargs): """Creates abstraction using Latex :param str tex: Latex :return: TreeOfContents object """ source = TexSoup(tex) return TOC('[document]', source=source, descendants=list(source.descendants), *args, **kwargs)
[ "def", "fromLatex", "(", "tex", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "source", "=", "TexSoup", "(", "tex", ")", "return", "TOC", "(", "'[document]'", ",", "source", "=", "source", ",", "descendants", "=", "list", "(", "source", ".", ...
Creates abstraction using Latex :param str tex: Latex :return: TreeOfContents object
[ "Creates", "abstraction", "using", "Latex" ]
train
https://github.com/alvinwan/tex2py/blob/85ce4a23ad8dbeb49a360171877dd14d099b3e9a/tex2py/tex2py.py#L224-L232
mar10/pyftpsync
ftpsync/synchronizers.py
process_options
def process_options(opts): """Check and prepare options dict.""" # Convert match and exclude args into pattern lists match = opts.get("match") if match and type(match) is str: opts["match"] = [pat.strip() for pat in match.split(",")] elif match: assert type(match) is list else: ...
python
def process_options(opts): """Check and prepare options dict.""" # Convert match and exclude args into pattern lists match = opts.get("match") if match and type(match) is str: opts["match"] = [pat.strip() for pat in match.split(",")] elif match: assert type(match) is list else: ...
[ "def", "process_options", "(", "opts", ")", ":", "# Convert match and exclude args into pattern lists", "match", "=", "opts", ".", "get", "(", "\"match\"", ")", "if", "match", "and", "type", "(", "match", ")", "is", "str", ":", "opts", "[", "\"match\"", "]", ...
Check and prepare options dict.
[ "Check", "and", "prepare", "options", "dict", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L41-L59
mar10/pyftpsync
ftpsync/synchronizers.py
match_path
def match_path(entry, opts): """Return True if `path` matches `match` and `exclude` options.""" if entry.name in ALWAYS_OMIT: return False # TODO: currently we use fnmatch syntax and match against names. # We also might allow glob syntax and match against the whole relative path instead # pa...
python
def match_path(entry, opts): """Return True if `path` matches `match` and `exclude` options.""" if entry.name in ALWAYS_OMIT: return False # TODO: currently we use fnmatch syntax and match against names. # We also might allow glob syntax and match against the whole relative path instead # pa...
[ "def", "match_path", "(", "entry", ",", "opts", ")", ":", "if", "entry", ".", "name", "in", "ALWAYS_OMIT", ":", "return", "False", "# TODO: currently we use fnmatch syntax and match against names.", "# We also might allow glob syntax and match against the whole relative path inst...
Return True if `path` matches `match` and `exclude` options.
[ "Return", "True", "if", "path", "matches", "match", "and", "exclude", "options", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L63-L88
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer._compare_file
def _compare_file(self, local, remote): """Byte compare two files (early out on first difference).""" assert isinstance(local, FileEntry) and isinstance(remote, FileEntry) if not local or not remote: write(" Files cannot be compared ({} != {}).".format(local, remote)) ...
python
def _compare_file(self, local, remote): """Byte compare two files (early out on first difference).""" assert isinstance(local, FileEntry) and isinstance(remote, FileEntry) if not local or not remote: write(" Files cannot be compared ({} != {}).".format(local, remote)) ...
[ "def", "_compare_file", "(", "self", ",", "local", ",", "remote", ")", ":", "assert", "isinstance", "(", "local", ",", "FileEntry", ")", "and", "isinstance", "(", "remote", ",", "FileEntry", ")", "if", "not", "local", "or", "not", "remote", ":", "write",...
Byte compare two files (early out on first difference).
[ "Byte", "compare", "two", "files", "(", "early", "out", "on", "first", "difference", ")", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L231-L255
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer._tick
def _tick(self): """Write progress info and move cursor to beginning of line.""" if (self.verbose >= 3 and not IS_REDIRECTED) or self.options.get("progress"): stats = self.get_stats() prefix = DRY_RUN_PREFIX if self.dry_run else "" sys.stdout.write( "{...
python
def _tick(self): """Write progress info and move cursor to beginning of line.""" if (self.verbose >= 3 and not IS_REDIRECTED) or self.options.get("progress"): stats = self.get_stats() prefix = DRY_RUN_PREFIX if self.dry_run else "" sys.stdout.write( "{...
[ "def", "_tick", "(", "self", ")", ":", "if", "(", "self", ".", "verbose", ">=", "3", "and", "not", "IS_REDIRECTED", ")", "or", "self", ".", "options", ".", "get", "(", "\"progress\"", ")", ":", "stats", "=", "self", ".", "get_stats", "(", ")", "pre...
Write progress info and move cursor to beginning of line.
[ "Write", "progress", "info", "and", "move", "cursor", "to", "beginning", "of", "line", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L437-L451
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer._sync_dir
def _sync_dir(self): """Traverse the local folder structure and remote peers. This is the core algorithm that generates calls to self.sync_XXX() handler methods. _sync_dir() is called by self.run(). """ local_entries = self.local.get_dir() # Convert into a dict {...
python
def _sync_dir(self): """Traverse the local folder structure and remote peers. This is the core algorithm that generates calls to self.sync_XXX() handler methods. _sync_dir() is called by self.run(). """ local_entries = self.local.get_dir() # Convert into a dict {...
[ "def", "_sync_dir", "(", "self", ")", ":", "local_entries", "=", "self", ".", "local", ".", "get_dir", "(", ")", "# Convert into a dict {name: FileEntry, ...}", "local_entry_map", "=", "dict", "(", "map", "(", "lambda", "e", ":", "(", "e", ".", "name", ",", ...
Traverse the local folder structure and remote peers. This is the core algorithm that generates calls to self.sync_XXX() handler methods. _sync_dir() is called by self.run().
[ "Traverse", "the", "local", "folder", "structure", "and", "remote", "peers", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L474-L596
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer.on_error
def on_error(self, e, pair): """Called for pairs that don't match `match` and `exclude` filters.""" RED = ansi_code("Fore.LIGHTRED_EX") R = ansi_code("Style.RESET_ALL") # any_entry = pair.any_entry write((RED + "ERROR: {}\n {}" + R).format(e, pair)) # Return True to ig...
python
def on_error(self, e, pair): """Called for pairs that don't match `match` and `exclude` filters.""" RED = ansi_code("Fore.LIGHTRED_EX") R = ansi_code("Style.RESET_ALL") # any_entry = pair.any_entry write((RED + "ERROR: {}\n {}" + R).format(e, pair)) # Return True to ig...
[ "def", "on_error", "(", "self", ",", "e", ",", "pair", ")", ":", "RED", "=", "ansi_code", "(", "\"Fore.LIGHTRED_EX\"", ")", "R", "=", "ansi_code", "(", "\"Style.RESET_ALL\"", ")", "# any_entry = pair.any_entry", "write", "(", "(", "RED", "+", "\"ERROR: {}\\n ...
Called for pairs that don't match `match` and `exclude` filters.
[ "Called", "for", "pairs", "that", "don", "t", "match", "match", "and", "exclude", "filters", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L606-L616
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer.on_copy_local
def on_copy_local(self, pair): """Called when the local resource should be copied to remote.""" status = pair.remote_classification self._log_action("copy", status, ">", pair.local)
python
def on_copy_local(self, pair): """Called when the local resource should be copied to remote.""" status = pair.remote_classification self._log_action("copy", status, ">", pair.local)
[ "def", "on_copy_local", "(", "self", ",", "pair", ")", ":", "status", "=", "pair", ".", "remote_classification", "self", ".", "_log_action", "(", "\"copy\"", ",", "status", ",", "\">\"", ",", "pair", ".", "local", ")" ]
Called when the local resource should be copied to remote.
[ "Called", "when", "the", "local", "resource", "should", "be", "copied", "to", "remote", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L626-L629
mar10/pyftpsync
ftpsync/synchronizers.py
BaseSynchronizer.on_copy_remote
def on_copy_remote(self, pair): """Called when the remote resource should be copied to local.""" status = pair.local_classification self._log_action("copy", status, "<", pair.remote)
python
def on_copy_remote(self, pair): """Called when the remote resource should be copied to local.""" status = pair.local_classification self._log_action("copy", status, "<", pair.remote)
[ "def", "on_copy_remote", "(", "self", ",", "pair", ")", ":", "status", "=", "pair", ".", "local_classification", "self", ".", "_log_action", "(", "\"copy\"", ",", "status", ",", "\"<\"", ",", "pair", ".", "remote", ")" ]
Called when the remote resource should be copied to local.
[ "Called", "when", "the", "remote", "resource", "should", "be", "copied", "to", "local", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L631-L634
mar10/pyftpsync
ftpsync/synchronizers.py
BiDirSynchronizer.on_need_compare
def on_need_compare(self, pair): """Re-classify pair based on file attributes and options.""" # print("on_need_compare", pair) # If no metadata is available, we could only classify file entries as # 'existing'. # Now we use peer information to improve this classification. ...
python
def on_need_compare(self, pair): """Re-classify pair based on file attributes and options.""" # print("on_need_compare", pair) # If no metadata is available, we could only classify file entries as # 'existing'. # Now we use peer information to improve this classification. ...
[ "def", "on_need_compare", "(", "self", ",", "pair", ")", ":", "# print(\"on_need_compare\", pair)", "# If no metadata is available, we could only classify file entries as", "# 'existing'.", "# Now we use peer information to improve this classification.", "c_pair", "=", "(", "pair", "...
Re-classify pair based on file attributes and options.
[ "Re", "-", "classify", "pair", "based", "on", "file", "attributes", "and", "options", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L871-L934
mar10/pyftpsync
ftpsync/synchronizers.py
BiDirSynchronizer.on_conflict
def on_conflict(self, pair): """Return False to prevent visiting of children.""" # self._log_action("skip", "conflict", "!", pair.local, min_level=2) # print("on_conflict", pair) any_entry = pair.any_entry if not self._test_match_or_print(any_entry): return r...
python
def on_conflict(self, pair): """Return False to prevent visiting of children.""" # self._log_action("skip", "conflict", "!", pair.local, min_level=2) # print("on_conflict", pair) any_entry = pair.any_entry if not self._test_match_or_print(any_entry): return r...
[ "def", "on_conflict", "(", "self", ",", "pair", ")", ":", "# self._log_action(\"skip\", \"conflict\", \"!\", pair.local, min_level=2)", "# print(\"on_conflict\", pair)", "any_entry", "=", "pair", ".", "any_entry", "if", "not", "self", ".", "_test_match_or_print", "(", "any_...
Return False to prevent visiting of children.
[ "Return", "False", "to", "prevent", "visiting", "of", "children", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L936-L990
mar10/pyftpsync
ftpsync/synchronizers.py
UploadSynchronizer.on_mismatch
def on_mismatch(self, pair): """Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource. """ remote_entry = pair.remote if self.options.get("delete_unmatched") and remote_entry: self._log_action("delete...
python
def on_mismatch(self, pair): """Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource. """ remote_entry = pair.remote if self.options.get("delete_unmatched") and remote_entry: self._log_action("delete...
[ "def", "on_mismatch", "(", "self", ",", "pair", ")", ":", "remote_entry", "=", "pair", ".", "remote", "if", "self", ".", "options", ".", "get", "(", "\"delete_unmatched\"", ")", "and", "remote_entry", ":", "self", ".", "_log_action", "(", "\"delete\"", ","...
Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource.
[ "Called", "for", "pairs", "that", "don", "t", "match", "match", "and", "exclude", "filters", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L1109-L1122
mar10/pyftpsync
ftpsync/synchronizers.py
DownloadSynchronizer._interactive_resolve
def _interactive_resolve(self, pair): """Return 'local', 'remote', or 'skip' to use local, remote resource or skip.""" if self.resolve_all: if self.verbose >= 5: self._print_pair_diff(pair) return self.resolve_all resolve = self.options.get("resolve", "sk...
python
def _interactive_resolve(self, pair): """Return 'local', 'remote', or 'skip' to use local, remote resource or skip.""" if self.resolve_all: if self.verbose >= 5: self._print_pair_diff(pair) return self.resolve_all resolve = self.options.get("resolve", "sk...
[ "def", "_interactive_resolve", "(", "self", ",", "pair", ")", ":", "if", "self", ".", "resolve_all", ":", "if", "self", ".", "verbose", ">=", "5", ":", "self", ".", "_print_pair_diff", "(", "pair", ")", "return", "self", ".", "resolve_all", "resolve", "=...
Return 'local', 'remote', or 'skip' to use local, remote resource or skip.
[ "Return", "local", "remote", "or", "skip", "to", "use", "local", "remote", "resource", "or", "skip", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L1194-L1263
mar10/pyftpsync
ftpsync/synchronizers.py
DownloadSynchronizer.on_mismatch
def on_mismatch(self, pair): """Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource. """ local_entry = pair.local if self.options.get("delete_unmatched") and local_entry: self._log_action("delete", ...
python
def on_mismatch(self, pair): """Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource. """ local_entry = pair.local if self.options.get("delete_unmatched") and local_entry: self._log_action("delete", ...
[ "def", "on_mismatch", "(", "self", ",", "pair", ")", ":", "local_entry", "=", "pair", ".", "local", "if", "self", ".", "options", ".", "get", "(", "\"delete_unmatched\"", ")", "and", "local_entry", ":", "self", ".", "_log_action", "(", "\"delete\"", ",", ...
Called for pairs that don't match `match` and `exclude` filters. If --delete-unmatched is on, remove the remote resource.
[ "Called", "for", "pairs", "that", "don", "t", "match", "match", "and", "exclude", "filters", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/synchronizers.py#L1271-L1284
mar10/pyftpsync
ftpsync/run_command.py
handle_run_command
def handle_run_command(parser, args): """Implement `run` sub-command.""" MAX_LEVELS = 15 # --- Look for `pyftpsync.yaml` in current folder and parents --- cur_level = 0 cur_folder = os.getcwd() config_path = None while cur_level < MAX_LEVELS: path = os.path.join(cur_folder, CONFIG_...
python
def handle_run_command(parser, args): """Implement `run` sub-command.""" MAX_LEVELS = 15 # --- Look for `pyftpsync.yaml` in current folder and parents --- cur_level = 0 cur_folder = os.getcwd() config_path = None while cur_level < MAX_LEVELS: path = os.path.join(cur_folder, CONFIG_...
[ "def", "handle_run_command", "(", "parser", ",", "args", ")", ":", "MAX_LEVELS", "=", "15", "# --- Look for `pyftpsync.yaml` in current folder and parents ---", "cur_level", "=", "0", "cur_folder", "=", "os", ".", "getcwd", "(", ")", "config_path", "=", "None", "whi...
Implement `run` sub-command.
[ "Implement", "run", "sub", "-", "command", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/run_command.py#L90-L216
mar10/pyftpsync
ftpsync/util.py
set_pyftpsync_logger
def set_pyftpsync_logger(logger=True): """Define target for common output. Args: logger (bool | None | logging.Logger): Pass None to use `print()` to stdout instead of logging. Pass True to create a simple standard logger. """ global _logger prev_logger = _logger ...
python
def set_pyftpsync_logger(logger=True): """Define target for common output. Args: logger (bool | None | logging.Logger): Pass None to use `print()` to stdout instead of logging. Pass True to create a simple standard logger. """ global _logger prev_logger = _logger ...
[ "def", "set_pyftpsync_logger", "(", "logger", "=", "True", ")", ":", "global", "_logger", "prev_logger", "=", "_logger", "if", "logger", "is", "True", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ")", "_logger", "=", "logg...
Define target for common output. Args: logger (bool | None | logging.Logger): Pass None to use `print()` to stdout instead of logging. Pass True to create a simple standard logger.
[ "Define", "target", "for", "common", "output", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L31-L47
mar10/pyftpsync
ftpsync/util.py
write
def write(*args, **kwargs): """Redirectable wrapper for print statements.""" debug = kwargs.pop("debug", None) warning = kwargs.pop("warning", None) if _logger: kwargs.pop("end", None) kwargs.pop("file", None) if debug: _logger.debug(*args, **kwargs) elif warn...
python
def write(*args, **kwargs): """Redirectable wrapper for print statements.""" debug = kwargs.pop("debug", None) warning = kwargs.pop("warning", None) if _logger: kwargs.pop("end", None) kwargs.pop("file", None) if debug: _logger.debug(*args, **kwargs) elif warn...
[ "def", "write", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "debug", "=", "kwargs", ".", "pop", "(", "\"debug\"", ",", "None", ")", "warning", "=", "kwargs", ".", "pop", "(", "\"warning\"", ",", "None", ")", "if", "_logger", ":", "kwargs",...
Redirectable wrapper for print statements.
[ "Redirectable", "wrapper", "for", "print", "statements", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L54-L68
mar10/pyftpsync
ftpsync/util.py
write_error
def write_error(*args, **kwargs): """Redirectable wrapper for print sys.stderr statements.""" if _logger: kwargs.pop("end", None) kwargs.pop("file", None) _logger.error(*args, **kwargs) else: print(*args, file=sys.stderr, **kwargs)
python
def write_error(*args, **kwargs): """Redirectable wrapper for print sys.stderr statements.""" if _logger: kwargs.pop("end", None) kwargs.pop("file", None) _logger.error(*args, **kwargs) else: print(*args, file=sys.stderr, **kwargs)
[ "def", "write_error", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "_logger", ":", "kwargs", ".", "pop", "(", "\"end\"", ",", "None", ")", "kwargs", ".", "pop", "(", "\"file\"", ",", "None", ")", "_logger", ".", "error", "(", "*", "...
Redirectable wrapper for print sys.stderr statements.
[ "Redirectable", "wrapper", "for", "print", "sys", ".", "stderr", "statements", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L71-L78
mar10/pyftpsync
ftpsync/util.py
namespace_to_dict
def namespace_to_dict(o): """Convert an argparse namespace object to a dictionary.""" d = {} for k, v in o.__dict__.items(): if not callable(v): d[k] = v return d
python
def namespace_to_dict(o): """Convert an argparse namespace object to a dictionary.""" d = {} for k, v in o.__dict__.items(): if not callable(v): d[k] = v return d
[ "def", "namespace_to_dict", "(", "o", ")", ":", "d", "=", "{", "}", "for", "k", ",", "v", "in", "o", ".", "__dict__", ".", "items", "(", ")", ":", "if", "not", "callable", "(", "v", ")", ":", "d", "[", "k", "]", "=", "v", "return", "d" ]
Convert an argparse namespace object to a dictionary.
[ "Convert", "an", "argparse", "namespace", "object", "to", "a", "dictionary", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L109-L115
mar10/pyftpsync
ftpsync/util.py
eps_compare
def eps_compare(f1, f2, eps): """Return true if |f1-f2| <= eps.""" res = f1 - f2 if abs(res) <= eps: # '<=',so eps == 0 works as expected return 0 elif res < 0: return -1 return 1
python
def eps_compare(f1, f2, eps): """Return true if |f1-f2| <= eps.""" res = f1 - f2 if abs(res) <= eps: # '<=',so eps == 0 works as expected return 0 elif res < 0: return -1 return 1
[ "def", "eps_compare", "(", "f1", ",", "f2", ",", "eps", ")", ":", "res", "=", "f1", "-", "f2", "if", "abs", "(", "res", ")", "<=", "eps", ":", "# '<=',so eps == 0 works as expected", "return", "0", "elif", "res", "<", "0", ":", "return", "-", "1", ...
Return true if |f1-f2| <= eps.
[ "Return", "true", "if", "|f1", "-", "f2|", "<", "=", "eps", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L118-L125
mar10/pyftpsync
ftpsync/util.py
get_option
def get_option(env_name, section, opt_name, default=None): """Return a configuration setting from environment var or .pyftpsyncrc""" val = os.environ.get(env_name) if val is None: try: val = _pyftpsyncrc_parser.get(section, opt_name) except (compat.configparser.NoSectionError, co...
python
def get_option(env_name, section, opt_name, default=None): """Return a configuration setting from environment var or .pyftpsyncrc""" val = os.environ.get(env_name) if val is None: try: val = _pyftpsyncrc_parser.get(section, opt_name) except (compat.configparser.NoSectionError, co...
[ "def", "get_option", "(", "env_name", ",", "section", ",", "opt_name", ",", "default", "=", "None", ")", ":", "val", "=", "os", ".", "environ", ".", "get", "(", "env_name", ")", "if", "val", "is", "None", ":", "try", ":", "val", "=", "_pyftpsyncrc_pa...
Return a configuration setting from environment var or .pyftpsyncrc
[ "Return", "a", "configuration", "setting", "from", "environment", "var", "or", ".", "pyftpsyncrc" ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L139-L149
mar10/pyftpsync
ftpsync/util.py
check_cli_verbose
def check_cli_verbose(default=3): """Check for presence of `--verbose`/`--quiet` or `-v`/`-q` without using argparse.""" args = sys.argv[1:] verbose = default + args.count("--verbose") - args.count("--quiet") for arg in args: if arg.startswith("-") and not arg.startswith("--"): verb...
python
def check_cli_verbose(default=3): """Check for presence of `--verbose`/`--quiet` or `-v`/`-q` without using argparse.""" args = sys.argv[1:] verbose = default + args.count("--verbose") - args.count("--quiet") for arg in args: if arg.startswith("-") and not arg.startswith("--"): verb...
[ "def", "check_cli_verbose", "(", "default", "=", "3", ")", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "verbose", "=", "default", "+", "args", ".", "count", "(", "\"--verbose\"", ")", "-", "args", ".", "count", "(", "\"--quiet\"", ")", ...
Check for presence of `--verbose`/`--quiet` or `-v`/`-q` without using argparse.
[ "Check", "for", "presence", "of", "--", "verbose", "/", "--", "quiet", "or", "-", "v", "/", "-", "q", "without", "using", "argparse", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L152-L161
mar10/pyftpsync
ftpsync/util.py
prompt_for_password
def prompt_for_password(url, user=None, default_user=None): """Prompt for username and password. If a user name is passed, only prompt for a password. Args: url (str): hostname user (str, optional): Pass a valid name to skip prompting for a user name default_user (str, o...
python
def prompt_for_password(url, user=None, default_user=None): """Prompt for username and password. If a user name is passed, only prompt for a password. Args: url (str): hostname user (str, optional): Pass a valid name to skip prompting for a user name default_user (str, o...
[ "def", "prompt_for_password", "(", "url", ",", "user", "=", "None", ",", "default_user", "=", "None", ")", ":", "if", "user", "is", "None", ":", "default_user", "=", "default_user", "or", "getpass", ".", "getuser", "(", ")", "while", "user", "is", "None"...
Prompt for username and password. If a user name is passed, only prompt for a password. Args: url (str): hostname user (str, optional): Pass a valid name to skip prompting for a user name default_user (str, optional): Pass a valid name that is used as default whe...
[ "Prompt", "for", "username", "and", "password", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L169-L199
mar10/pyftpsync
ftpsync/util.py
get_credentials_for_url
def get_credentials_for_url(url, opts, force_user=None): """Lookup credentials for a given target in keyring and .netrc. Optionally prompts for credentials if not found. Returns: 2-tuple (username, password) or None """ creds = None verbose = int(opts.get("verbose")) force_prompt =...
python
def get_credentials_for_url(url, opts, force_user=None): """Lookup credentials for a given target in keyring and .netrc. Optionally prompts for credentials if not found. Returns: 2-tuple (username, password) or None """ creds = None verbose = int(opts.get("verbose")) force_prompt =...
[ "def", "get_credentials_for_url", "(", "url", ",", "opts", ",", "force_user", "=", "None", ")", ":", "creds", "=", "None", "verbose", "=", "int", "(", "opts", ".", "get", "(", "\"verbose\"", ")", ")", "force_prompt", "=", "opts", ".", "get", "(", "\"pr...
Lookup credentials for a given target in keyring and .netrc. Optionally prompts for credentials if not found. Returns: 2-tuple (username, password) or None
[ "Lookup", "credentials", "for", "a", "given", "target", "in", "keyring", "and", ".", "netrc", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L202-L285
mar10/pyftpsync
ftpsync/util.py
save_password
def save_password(url, username, password): """Store credentials in keyring.""" if keyring: if ":" in username: raise RuntimeError( "Unable to store credentials if username contains a ':' ({}).".format( username ) ) try...
python
def save_password(url, username, password): """Store credentials in keyring.""" if keyring: if ":" in username: raise RuntimeError( "Unable to store credentials if username contains a ':' ({}).".format( username ) ) try...
[ "def", "save_password", "(", "url", ",", "username", ",", "password", ")", ":", "if", "keyring", ":", "if", "\":\"", "in", "username", ":", "raise", "RuntimeError", "(", "\"Unable to store credentials if username contains a ':' ({}).\"", ".", "format", "(", "usernam...
Store credentials in keyring.
[ "Store", "credentials", "in", "keyring", "." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L288-L316
mar10/pyftpsync
ftpsync/util.py
str_to_bool
def str_to_bool(val): """Return a boolean for '0', 'false', 'on', ...""" val = str(val).lower().strip() if val in ("1", "true", "on", "yes"): return True elif val in ("0", "false", "off", "no"): return False raise ValueError( "Invalid value '{}'" "(expected '1', '0', ...
python
def str_to_bool(val): """Return a boolean for '0', 'false', 'on', ...""" val = str(val).lower().strip() if val in ("1", "true", "on", "yes"): return True elif val in ("0", "false", "off", "no"): return False raise ValueError( "Invalid value '{}'" "(expected '1', '0', ...
[ "def", "str_to_bool", "(", "val", ")", ":", "val", "=", "str", "(", "val", ")", ".", "lower", "(", ")", ".", "strip", "(", ")", "if", "val", "in", "(", "\"1\"", ",", "\"true\"", ",", "\"on\"", ",", "\"yes\"", ")", ":", "return", "True", "elif", ...
Return a boolean for '0', 'false', 'on', ...
[ "Return", "a", "boolean", "for", "0", "false", "on", "..." ]
train
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/util.py#L319-L329