repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | parse_intf_section | def parse_intf_section(interface):
"""Parse a single entry from show interfaces output.
Different cases:
mgmt0 is up
admin state is up
Ethernet2/1 is up
admin state is up, Dedicated Interface
Vlan1 is down (Administratively down), line protocol is down, autostate enabled
Ethernet154/... | python | def parse_intf_section(interface):
"""Parse a single entry from show interfaces output.
Different cases:
mgmt0 is up
admin state is up
Ethernet2/1 is up
admin state is up, Dedicated Interface
Vlan1 is down (Administratively down), line protocol is down, autostate enabled
Ethernet154/... | [
"def",
"parse_intf_section",
"(",
"interface",
")",
":",
"interface",
"=",
"interface",
".",
"strip",
"(",
")",
"re_protocol",
"=",
"r\"^(?P<intf_name>\\S+?)\\s+is\\s+(?P<status>.+?)\"",
"r\",\\s+line\\s+protocol\\s+is\\s+(?P<protocol>\\S+).*$\"",
"re_intf_name_state",
"=",
"r\... | Parse a single entry from show interfaces output.
Different cases:
mgmt0 is up
admin state is up
Ethernet2/1 is up
admin state is up, Dedicated Interface
Vlan1 is down (Administratively down), line protocol is down, autostate enabled
Ethernet154/1/48 is up (with no 'admin state') | [
"Parse",
"a",
"single",
"entry",
"from",
"show",
"interfaces",
"output",
"."
] | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L74-L169 | train |
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | NXOSSSHDriver._get_diff | def _get_diff(self):
"""Get a diff between running config and a proposed file."""
diff = []
self._create_sot_file()
command = ('show diff rollback-patch file {0} file {1}'.format(
'sot_file', self.replace_file.split('/')[-1]))
diff_out = self.device.send_comman... | python | def _get_diff(self):
"""Get a diff between running config and a proposed file."""
diff = []
self._create_sot_file()
command = ('show diff rollback-patch file {0} file {1}'.format(
'sot_file', self.replace_file.split('/')[-1]))
diff_out = self.device.send_comman... | [
"def",
"_get_diff",
"(",
"self",
")",
":",
"diff",
"=",
"[",
"]",
"self",
".",
"_create_sot_file",
"(",
")",
"command",
"=",
"(",
"'show diff rollback-patch file {0} file {1}'",
".",
"format",
"(",
"'sot_file'",
",",
"self",
".",
"replace_file",
".",
"split",
... | Get a diff between running config and a proposed file. | [
"Get",
"a",
"diff",
"between",
"running",
"config",
"and",
"a",
"proposed",
"file",
"."
] | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L595-L613 | train |
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | NXOSSSHDriver._save_to_checkpoint | def _save_to_checkpoint(self, filename):
"""Save the current running config to the given file."""
command = 'checkpoint file {}'.format(filename)
self.device.send_command(command) | python | def _save_to_checkpoint(self, filename):
"""Save the current running config to the given file."""
command = 'checkpoint file {}'.format(filename)
self.device.send_command(command) | [
"def",
"_save_to_checkpoint",
"(",
"self",
",",
"filename",
")",
":",
"command",
"=",
"'checkpoint file {}'",
".",
"format",
"(",
"filename",
")",
"self",
".",
"device",
".",
"send_command",
"(",
"command",
")"
] | Save the current running config to the given file. | [
"Save",
"the",
"current",
"running",
"config",
"to",
"the",
"given",
"file",
"."
] | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L657-L660 | train |
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | NXOSSSHDriver.get_facts | def get_facts(self):
"""Return a set of facts from the devices."""
# default values.
vendor = u'Cisco'
uptime = -1
serial_number, fqdn, os_version, hostname, domain_name = ('',) * 5
# obtain output from device
show_ver = self.device.send_command('show version')
... | python | def get_facts(self):
"""Return a set of facts from the devices."""
# default values.
vendor = u'Cisco'
uptime = -1
serial_number, fqdn, os_version, hostname, domain_name = ('',) * 5
# obtain output from device
show_ver = self.device.send_command('show version')
... | [
"def",
"get_facts",
"(",
"self",
")",
":",
"# default values.",
"vendor",
"=",
"u'Cisco'",
"uptime",
"=",
"-",
"1",
"serial_number",
",",
"fqdn",
",",
"os_version",
",",
"hostname",
",",
"domain_name",
"=",
"(",
"''",
",",
")",
"*",
"5",
"# obtain output f... | Return a set of facts from the devices. | [
"Return",
"a",
"set",
"of",
"facts",
"from",
"the",
"devices",
"."
] | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L736-L799 | train |
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | NXOSSSHDriver.get_arp_table | def get_arp_table(self):
"""
Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
... | python | def get_arp_table(self):
"""
Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
... | [
"def",
"get_arp_table",
"(",
"self",
")",
":",
"arp_table",
"=",
"[",
"]",
"command",
"=",
"'show ip arp vrf default | exc INCOMPLETE'",
"output",
"=",
"self",
".",
"device",
".",
"send_command",
"(",
"command",
")",
"separator",
"=",
"r\"^Address\\s+Age.*Interface.... | Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
'interface' : 'MgmtEth0/RSP0/CPU0... | [
"Get",
"arp",
"table",
"information",
"."
] | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L1037-L1105 | train |
napalm-automation/napalm-nxos | napalm_nxos_ssh/nxos_ssh.py | NXOSSSHDriver.get_mac_address_table | def get_mac_address_table(self):
"""
Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address
Table, having the following keys
* mac (string)
* interface (string)
* vlan (int)
* active (boolean)
* static (... | python | def get_mac_address_table(self):
"""
Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address
Table, having the following keys
* mac (string)
* interface (string)
* vlan (int)
* active (boolean)
* static (... | [
"def",
"get_mac_address_table",
"(",
"self",
")",
":",
"# The '*' is stripped out later",
"RE_MACTABLE_FORMAT1",
"=",
"r\"^\\s+{}\\s+{}\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\"",
".",
"format",
"(",
"VLAN_REGEX",
",",
"MAC_REGEX",
")",
"RE_MACTABLE_FORMAT2",
"=",
"r\"^\\s+{}\... | Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address
Table, having the following keys
* mac (string)
* interface (string)
* vlan (int)
* active (boolean)
* static (boolean)
* moves (int)
* last... | [
"Returns",
"a",
"lists",
"of",
"dictionaries",
".",
"Each",
"dictionary",
"represents",
"an",
"entry",
"in",
"the",
"MAC",
"Address",
"Table",
"having",
"the",
"following",
"keys",
"*",
"mac",
"(",
"string",
")",
"*",
"interface",
"(",
"string",
")",
"*",
... | 936d641c99e068817abf247e0e5571fc31b3a92a | https://github.com/napalm-automation/napalm-nxos/blob/936d641c99e068817abf247e0e5571fc31b3a92a/napalm_nxos_ssh/nxos_ssh.py#L1220-L1320 | train |
celiao/django-rest-authemail | authemail/views.py | Logout.get | def get(self, request, format=None):
"""
Remove all auth tokens owned by request.user.
"""
tokens = Token.objects.filter(user=request.user)
for token in tokens:
token.delete()
content = {'success': _('User logged out.')}
return Response(content, status... | python | def get(self, request, format=None):
"""
Remove all auth tokens owned by request.user.
"""
tokens = Token.objects.filter(user=request.user)
for token in tokens:
token.delete()
content = {'success': _('User logged out.')}
return Response(content, status... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"format",
"=",
"None",
")",
":",
"tokens",
"=",
"Token",
".",
"objects",
".",
"filter",
"(",
"user",
"=",
"request",
".",
"user",
")",
"for",
"token",
"in",
"tokens",
":",
"token",
".",
"delete",
"(",... | Remove all auth tokens owned by request.user. | [
"Remove",
"all",
"auth",
"tokens",
"owned",
"by",
"request",
".",
"user",
"."
] | 7295a4061a46b058595dae19b14c612f0eb0393a | https://github.com/celiao/django-rest-authemail/blob/7295a4061a46b058595dae19b14c612f0eb0393a/authemail/views.py#L130-L138 | train |
celiao/django-rest-authemail | authemail/wrapper.py | API._set_attrs_to_values | def _set_attrs_to_values(self, response={}):
"""
Set attributes to dictionary values so can access via dot notation.
"""
for key in response.keys():
setattr(self, key, response[key]) | python | def _set_attrs_to_values(self, response={}):
"""
Set attributes to dictionary values so can access via dot notation.
"""
for key in response.keys():
setattr(self, key, response[key]) | [
"def",
"_set_attrs_to_values",
"(",
"self",
",",
"response",
"=",
"{",
"}",
")",
":",
"for",
"key",
"in",
"response",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"response",
"[",
"key",
"]",
")"
] | Set attributes to dictionary values so can access via dot notation. | [
"Set",
"attributes",
"to",
"dictionary",
"values",
"so",
"can",
"access",
"via",
"dot",
"notation",
"."
] | 7295a4061a46b058595dae19b14c612f0eb0393a | https://github.com/celiao/django-rest-authemail/blob/7295a4061a46b058595dae19b14c612f0eb0393a/authemail/wrapper.py#L47-L52 | train |
acoomans/flask-autodoc | flask_autodoc/autodoc.py | Autodoc.add_custom_nl2br_filters | def add_custom_nl2br_filters(self, app):
"""Add a custom filter nl2br to jinja2
Replaces all newline to <BR>
"""
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){3,}')
@app.template_filter()
@evalcontextfilter
def nl2br(eval_ctx, value):
result = '\n\n'.j... | python | def add_custom_nl2br_filters(self, app):
"""Add a custom filter nl2br to jinja2
Replaces all newline to <BR>
"""
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){3,}')
@app.template_filter()
@evalcontextfilter
def nl2br(eval_ctx, value):
result = '\n\n'.j... | [
"def",
"add_custom_nl2br_filters",
"(",
"self",
",",
"app",
")",
":",
"_paragraph_re",
"=",
"re",
".",
"compile",
"(",
"r'(?:\\r\\n|\\r|\\n){3,}'",
")",
"@",
"app",
".",
"template_filter",
"(",
")",
"@",
"evalcontextfilter",
"def",
"nl2br",
"(",
"eval_ctx",
",... | Add a custom filter nl2br to jinja2
Replaces all newline to <BR> | [
"Add",
"a",
"custom",
"filter",
"nl2br",
"to",
"jinja2",
"Replaces",
"all",
"newline",
"to",
"<BR",
">"
] | 6c77c8935b71fbf3243b5e589c5c255d0299d853 | https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/flask_autodoc/autodoc.py#L51-L62 | train |
acoomans/flask-autodoc | flask_autodoc/autodoc.py | Autodoc.doc | def doc(self, groups=None, set_location=True, **properties):
"""Add flask route to autodoc for automatic documentation
Any route decorated with this method will be added to the list of
routes to be documented by the generate() or html() methods.
By default, the route is added to the 'a... | python | def doc(self, groups=None, set_location=True, **properties):
"""Add flask route to autodoc for automatic documentation
Any route decorated with this method will be added to the list of
routes to be documented by the generate() or html() methods.
By default, the route is added to the 'a... | [
"def",
"doc",
"(",
"self",
",",
"groups",
"=",
"None",
",",
"set_location",
"=",
"True",
",",
"*",
"*",
"properties",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"# Get previous group list (if any)",
"if",
"f",
"in",
"self",
".",
"func_groups",
":"... | Add flask route to autodoc for automatic documentation
Any route decorated with this method will be added to the list of
routes to be documented by the generate() or html() methods.
By default, the route is added to the 'all' group.
By specifying group or groups argument, the route can... | [
"Add",
"flask",
"route",
"to",
"autodoc",
"for",
"automatic",
"documentation"
] | 6c77c8935b71fbf3243b5e589c5c255d0299d853 | https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/flask_autodoc/autodoc.py#L64-L111 | train |
acoomans/flask-autodoc | flask_autodoc/autodoc.py | Autodoc.generate | def generate(self, groups='all', sort=None):
"""Return a list of dict describing the routes specified by the
doc() method
Each dict contains:
- methods: the set of allowed methods (ie ['GET', 'POST'])
- rule: relative url (ie '/user/<int:id>')
- endpoint: function nam... | python | def generate(self, groups='all', sort=None):
"""Return a list of dict describing the routes specified by the
doc() method
Each dict contains:
- methods: the set of allowed methods (ie ['GET', 'POST'])
- rule: relative url (ie '/user/<int:id>')
- endpoint: function nam... | [
"def",
"generate",
"(",
"self",
",",
"groups",
"=",
"'all'",
",",
"sort",
"=",
"None",
")",
":",
"groups_to_generate",
"=",
"list",
"(",
")",
"if",
"type",
"(",
"groups",
")",
"is",
"list",
":",
"groups_to_generate",
"=",
"groups",
"elif",
"type",
"(",... | Return a list of dict describing the routes specified by the
doc() method
Each dict contains:
- methods: the set of allowed methods (ie ['GET', 'POST'])
- rule: relative url (ie '/user/<int:id>')
- endpoint: function name (ie 'show_user')
- doc: docstring of the func... | [
"Return",
"a",
"list",
"of",
"dict",
"describing",
"the",
"routes",
"specified",
"by",
"the",
"doc",
"()",
"method"
] | 6c77c8935b71fbf3243b5e589c5c255d0299d853 | https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/flask_autodoc/autodoc.py#L113-L166 | train |
acoomans/flask-autodoc | flask_autodoc/autodoc.py | Autodoc.html | def html(self, groups='all', template=None, **context):
"""Return an html string of the routes specified by the doc() method
A template can be specified. A list of routes is available under the
'autodoc' value (refer to the documentation for the generate() for a
description of available... | python | def html(self, groups='all', template=None, **context):
"""Return an html string of the routes specified by the doc() method
A template can be specified. A list of routes is available under the
'autodoc' value (refer to the documentation for the generate() for a
description of available... | [
"def",
"html",
"(",
"self",
",",
"groups",
"=",
"'all'",
",",
"template",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"context",
"[",
"'autodoc'",
"]",
"=",
"context",
"[",
"'autodoc'",
"]",
"if",
"'autodoc'",
"in",
"context",
"else",
"self",
".... | Return an html string of the routes specified by the doc() method
A template can be specified. A list of routes is available under the
'autodoc' value (refer to the documentation for the generate() for a
description of available values). If no template is specified, a
default template i... | [
"Return",
"an",
"html",
"string",
"of",
"the",
"routes",
"specified",
"by",
"the",
"doc",
"()",
"method"
] | 6c77c8935b71fbf3243b5e589c5c255d0299d853 | https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/flask_autodoc/autodoc.py#L168-L194 | train |
jim-easterbrook/Photini | src/photini/imagelist.py | ImageList.unsaved_files_dialog | def unsaved_files_dialog(
self, all_files=False, with_cancel=True, with_discard=True):
"""Return true if OK to continue with close or quit or whatever"""
for image in self.images:
if image.metadata.changed() and (all_files or image.selected):
break
else:
... | python | def unsaved_files_dialog(
self, all_files=False, with_cancel=True, with_discard=True):
"""Return true if OK to continue with close or quit or whatever"""
for image in self.images:
if image.metadata.changed() and (all_files or image.selected):
break
else:
... | [
"def",
"unsaved_files_dialog",
"(",
"self",
",",
"all_files",
"=",
"False",
",",
"with_cancel",
"=",
"True",
",",
"with_discard",
"=",
"True",
")",
":",
"for",
"image",
"in",
"self",
".",
"images",
":",
"if",
"image",
".",
"metadata",
".",
"changed",
"("... | Return true if OK to continue with close or quit or whatever | [
"Return",
"true",
"if",
"OK",
"to",
"continue",
"with",
"close",
"or",
"quit",
"or",
"whatever"
] | 06f1b1988db23a5cad98bbc6c16406a64a6c556d | https://github.com/jim-easterbrook/Photini/blob/06f1b1988db23a5cad98bbc6c16406a64a6c556d/src/photini/imagelist.py#L748-L772 | train |
jim-easterbrook/Photini | src/photini/metadata.py | DateTime.from_ISO_8601 | def from_ISO_8601(cls, date_string, time_string, tz_string):
"""Sufficiently general ISO 8601 parser.
Inputs must be in "basic" format, i.e. no '-' or ':' separators.
See https://en.wikipedia.org/wiki/ISO_8601
"""
# parse tz_string
if tz_string:
tz_offset = ... | python | def from_ISO_8601(cls, date_string, time_string, tz_string):
"""Sufficiently general ISO 8601 parser.
Inputs must be in "basic" format, i.e. no '-' or ':' separators.
See https://en.wikipedia.org/wiki/ISO_8601
"""
# parse tz_string
if tz_string:
tz_offset = ... | [
"def",
"from_ISO_8601",
"(",
"cls",
",",
"date_string",
",",
"time_string",
",",
"tz_string",
")",
":",
"# parse tz_string",
"if",
"tz_string",
":",
"tz_offset",
"=",
"(",
"int",
"(",
"tz_string",
"[",
"1",
":",
"3",
"]",
")",
"*",
"60",
")",
"+",
"int... | Sufficiently general ISO 8601 parser.
Inputs must be in "basic" format, i.e. no '-' or ':' separators.
See https://en.wikipedia.org/wiki/ISO_8601 | [
"Sufficiently",
"general",
"ISO",
"8601",
"parser",
"."
] | 06f1b1988db23a5cad98bbc6c16406a64a6c556d | https://github.com/jim-easterbrook/Photini/blob/06f1b1988db23a5cad98bbc6c16406a64a6c556d/src/photini/metadata.py#L412-L436 | train |
acoomans/flask-autodoc | examples/factory/blog/frontend.py | post_post | def post_post():
"""Create a new post.
Form Data: title, content, authorid.
"""
authorid = request.form.get('authorid', None)
Post(request.form['title'],
request.form['content'],
users[authorid])
return redirect("/posts") | python | def post_post():
"""Create a new post.
Form Data: title, content, authorid.
"""
authorid = request.form.get('authorid', None)
Post(request.form['title'],
request.form['content'],
users[authorid])
return redirect("/posts") | [
"def",
"post_post",
"(",
")",
":",
"authorid",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'authorid'",
",",
"None",
")",
"Post",
"(",
"request",
".",
"form",
"[",
"'title'",
"]",
",",
"request",
".",
"form",
"[",
"'content'",
"]",
",",
"users",
... | Create a new post.
Form Data: title, content, authorid. | [
"Create",
"a",
"new",
"post",
".",
"Form",
"Data",
":",
"title",
"content",
"authorid",
"."
] | 6c77c8935b71fbf3243b5e589c5c255d0299d853 | https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/examples/factory/blog/frontend.py#L59-L67 | train |
niklasb/webkit-server | webkit_server.py | SelectionMixin.xpath | def xpath(self, xpath):
""" Finds another node by XPath originating at the current node. """
return [self.get_node_factory().create(node_id)
for node_id in self._get_xpath_ids(xpath).split(",")
if node_id] | python | def xpath(self, xpath):
""" Finds another node by XPath originating at the current node. """
return [self.get_node_factory().create(node_id)
for node_id in self._get_xpath_ids(xpath).split(",")
if node_id] | [
"def",
"xpath",
"(",
"self",
",",
"xpath",
")",
":",
"return",
"[",
"self",
".",
"get_node_factory",
"(",
")",
".",
"create",
"(",
"node_id",
")",
"for",
"node_id",
"in",
"self",
".",
"_get_xpath_ids",
"(",
"xpath",
")",
".",
"split",
"(",
"\",\"",
"... | Finds another node by XPath originating at the current node. | [
"Finds",
"another",
"node",
"by",
"XPath",
"originating",
"at",
"the",
"current",
"node",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L21-L25 | train |
niklasb/webkit-server | webkit_server.py | SelectionMixin.css | def css(self, css):
""" Finds another node by a CSS selector relative to the current node. """
return [self.get_node_factory().create(node_id)
for node_id in self._get_css_ids(css).split(",")
if node_id] | python | def css(self, css):
""" Finds another node by a CSS selector relative to the current node. """
return [self.get_node_factory().create(node_id)
for node_id in self._get_css_ids(css).split(",")
if node_id] | [
"def",
"css",
"(",
"self",
",",
"css",
")",
":",
"return",
"[",
"self",
".",
"get_node_factory",
"(",
")",
".",
"create",
"(",
"node_id",
")",
"for",
"node_id",
"in",
"self",
".",
"_get_css_ids",
"(",
"css",
")",
".",
"split",
"(",
"\",\"",
")",
"i... | Finds another node by a CSS selector relative to the current node. | [
"Finds",
"another",
"node",
"by",
"a",
"CSS",
"selector",
"relative",
"to",
"the",
"current",
"node",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L27-L31 | train |
niklasb/webkit-server | webkit_server.py | Node.get_bool_attr | def get_bool_attr(self, name):
""" Returns the value of a boolean HTML attribute like `checked` or `disabled`
"""
val = self.get_attr(name)
return val is not None and val.lower() in ("true", name) | python | def get_bool_attr(self, name):
""" Returns the value of a boolean HTML attribute like `checked` or `disabled`
"""
val = self.get_attr(name)
return val is not None and val.lower() in ("true", name) | [
"def",
"get_bool_attr",
"(",
"self",
",",
"name",
")",
":",
"val",
"=",
"self",
".",
"get_attr",
"(",
"name",
")",
"return",
"val",
"is",
"not",
"None",
"and",
"val",
".",
"lower",
"(",
")",
"in",
"(",
"\"true\"",
",",
"name",
")"
] | Returns the value of a boolean HTML attribute like `checked` or `disabled` | [
"Returns",
"the",
"value",
"of",
"a",
"boolean",
"HTML",
"attribute",
"like",
"checked",
"or",
"disabled"
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L68-L72 | train |
niklasb/webkit-server | webkit_server.py | Node.set_attr | def set_attr(self, name, value):
""" Sets the value of an attribute. """
self.exec_script("node.setAttribute(%s, %s)" % (repr(name), repr(value))) | python | def set_attr(self, name, value):
""" Sets the value of an attribute. """
self.exec_script("node.setAttribute(%s, %s)" % (repr(name), repr(value))) | [
"def",
"set_attr",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"exec_script",
"(",
"\"node.setAttribute(%s, %s)\"",
"%",
"(",
"repr",
"(",
"name",
")",
",",
"repr",
"(",
"value",
")",
")",
")"
] | Sets the value of an attribute. | [
"Sets",
"the",
"value",
"of",
"an",
"attribute",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L78-L80 | train |
niklasb/webkit-server | webkit_server.py | Node.value | def value(self):
""" Returns the node's value. """
if self.is_multi_select():
return [opt.value()
for opt in self.xpath(".//option")
if opt["selected"]]
else:
return self._invoke("value") | python | def value(self):
""" Returns the node's value. """
if self.is_multi_select():
return [opt.value()
for opt in self.xpath(".//option")
if opt["selected"]]
else:
return self._invoke("value") | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_multi_select",
"(",
")",
":",
"return",
"[",
"opt",
".",
"value",
"(",
")",
"for",
"opt",
"in",
"self",
".",
"xpath",
"(",
"\".//option\"",
")",
"if",
"opt",
"[",
"\"selected\"",
"]",
"]... | Returns the node's value. | [
"Returns",
"the",
"node",
"s",
"value",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L82-L89 | train |
niklasb/webkit-server | webkit_server.py | Client.set_header | def set_header(self, key, value):
""" Sets a HTTP header for future requests. """
self.conn.issue_command("Header", _normalize_header(key), value) | python | def set_header(self, key, value):
""" Sets a HTTP header for future requests. """
self.conn.issue_command("Header", _normalize_header(key), value) | [
"def",
"set_header",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"Header\"",
",",
"_normalize_header",
"(",
"key",
")",
",",
"value",
")"
] | Sets a HTTP header for future requests. | [
"Sets",
"a",
"HTTP",
"header",
"for",
"future",
"requests",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L250-L252 | train |
niklasb/webkit-server | webkit_server.py | Client.headers | def headers(self):
""" Returns a list of the last HTTP response headers.
Header keys are normalized to capitalized form, as in `User-Agent`.
"""
headers = self.conn.issue_command("Headers")
res = []
for header in headers.split("\r"):
key, value = header.split(": ", 1)
for line in val... | python | def headers(self):
""" Returns a list of the last HTTP response headers.
Header keys are normalized to capitalized form, as in `User-Agent`.
"""
headers = self.conn.issue_command("Headers")
res = []
for header in headers.split("\r"):
key, value = header.split(": ", 1)
for line in val... | [
"def",
"headers",
"(",
"self",
")",
":",
"headers",
"=",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"Headers\"",
")",
"res",
"=",
"[",
"]",
"for",
"header",
"in",
"headers",
".",
"split",
"(",
"\"\\r\"",
")",
":",
"key",
",",
"value",
"=",
"... | Returns a list of the last HTTP response headers.
Header keys are normalized to capitalized form, as in `User-Agent`. | [
"Returns",
"a",
"list",
"of",
"the",
"last",
"HTTP",
"response",
"headers",
".",
"Header",
"keys",
"are",
"normalized",
"to",
"capitalized",
"form",
"as",
"in",
"User",
"-",
"Agent",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L262-L272 | train |
niklasb/webkit-server | webkit_server.py | Client.eval_script | def eval_script(self, expr):
""" Evaluates a piece of Javascript in the context of the current page and
returns its value. """
ret = self.conn.issue_command("Evaluate", expr)
return json.loads("[%s]" % ret)[0] | python | def eval_script(self, expr):
""" Evaluates a piece of Javascript in the context of the current page and
returns its value. """
ret = self.conn.issue_command("Evaluate", expr)
return json.loads("[%s]" % ret)[0] | [
"def",
"eval_script",
"(",
"self",
",",
"expr",
")",
":",
"ret",
"=",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"Evaluate\"",
",",
"expr",
")",
"return",
"json",
".",
"loads",
"(",
"\"[%s]\"",
"%",
"ret",
")",
"[",
"0",
"]"
] | Evaluates a piece of Javascript in the context of the current page and
returns its value. | [
"Evaluates",
"a",
"piece",
"of",
"Javascript",
"in",
"the",
"context",
"of",
"the",
"current",
"page",
"and",
"returns",
"its",
"value",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L274-L278 | train |
niklasb/webkit-server | webkit_server.py | Client.render | def render(self, path, width = 1024, height = 1024):
""" Renders the current page to a PNG file (viewport size in pixels). """
self.conn.issue_command("Render", path, width, height) | python | def render(self, path, width = 1024, height = 1024):
""" Renders the current page to a PNG file (viewport size in pixels). """
self.conn.issue_command("Render", path, width, height) | [
"def",
"render",
"(",
"self",
",",
"path",
",",
"width",
"=",
"1024",
",",
"height",
"=",
"1024",
")",
":",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"Render\"",
",",
"path",
",",
"width",
",",
"height",
")"
] | Renders the current page to a PNG file (viewport size in pixels). | [
"Renders",
"the",
"current",
"page",
"to",
"a",
"PNG",
"file",
"(",
"viewport",
"size",
"in",
"pixels",
")",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L284-L286 | train |
niklasb/webkit-server | webkit_server.py | Client.cookies | def cookies(self):
""" Returns a list of all cookies in cookie string format. """
return [line.strip()
for line in self.conn.issue_command("GetCookies").split("\n")
if line.strip()] | python | def cookies(self):
""" Returns a list of all cookies in cookie string format. """
return [line.strip()
for line in self.conn.issue_command("GetCookies").split("\n")
if line.strip()] | [
"def",
"cookies",
"(",
"self",
")",
":",
"return",
"[",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"GetCookies\"",
")",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"line",
".",
"strip",
"(",
... | Returns a list of all cookies in cookie string format. | [
"Returns",
"a",
"list",
"of",
"all",
"cookies",
"in",
"cookie",
"string",
"format",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L301-L305 | train |
niklasb/webkit-server | webkit_server.py | Client.set_attribute | def set_attribute(self, attr, value = True):
""" Sets a custom attribute for our Webkit instance. Possible attributes are:
* ``auto_load_images``
* ``dns_prefetch_enabled``
* ``plugins_enabled``
* ``private_browsing_enabled``
* ``javascript_can_open_windows``
* ``javascript_can_... | python | def set_attribute(self, attr, value = True):
""" Sets a custom attribute for our Webkit instance. Possible attributes are:
* ``auto_load_images``
* ``dns_prefetch_enabled``
* ``plugins_enabled``
* ``private_browsing_enabled``
* ``javascript_can_open_windows``
* ``javascript_can_... | [
"def",
"set_attribute",
"(",
"self",
",",
"attr",
",",
"value",
"=",
"True",
")",
":",
"value",
"=",
"\"true\"",
"if",
"value",
"else",
"\"false\"",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"SetAttribute\"",
",",
"self",
".",
"_normalize_attr",
"(... | Sets a custom attribute for our Webkit instance. Possible attributes are:
* ``auto_load_images``
* ``dns_prefetch_enabled``
* ``plugins_enabled``
* ``private_browsing_enabled``
* ``javascript_can_open_windows``
* ``javascript_can_access_clipboard``
* ``offline_storage_database... | [
"Sets",
"a",
"custom",
"attribute",
"for",
"our",
"Webkit",
"instance",
".",
"Possible",
"attributes",
"are",
":"
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L314-L339 | train |
niklasb/webkit-server | webkit_server.py | Client.set_html | def set_html(self, html, url = None):
""" Sets custom HTML in our Webkit session and allows to specify a fake URL.
Scripts and CSS is dynamically fetched as if the HTML had been loaded from
the given URL. """
if url:
self.conn.issue_command('SetHtml', html, url)
else:
self.conn.issue_com... | python | def set_html(self, html, url = None):
""" Sets custom HTML in our Webkit session and allows to specify a fake URL.
Scripts and CSS is dynamically fetched as if the HTML had been loaded from
the given URL. """
if url:
self.conn.issue_command('SetHtml', html, url)
else:
self.conn.issue_com... | [
"def",
"set_html",
"(",
"self",
",",
"html",
",",
"url",
"=",
"None",
")",
":",
"if",
"url",
":",
"self",
".",
"conn",
".",
"issue_command",
"(",
"'SetHtml'",
",",
"html",
",",
"url",
")",
"else",
":",
"self",
".",
"conn",
".",
"issue_command",
"("... | Sets custom HTML in our Webkit session and allows to specify a fake URL.
Scripts and CSS is dynamically fetched as if the HTML had been loaded from
the given URL. | [
"Sets",
"custom",
"HTML",
"in",
"our",
"Webkit",
"session",
"and",
"allows",
"to",
"specify",
"a",
"fake",
"URL",
".",
"Scripts",
"and",
"CSS",
"is",
"dynamically",
"fetched",
"as",
"if",
"the",
"HTML",
"had",
"been",
"loaded",
"from",
"the",
"given",
"U... | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L347-L354 | train |
niklasb/webkit-server | webkit_server.py | Client.set_proxy | def set_proxy(self, host = "localhost",
port = 0,
user = "",
password = ""):
""" Sets a custom HTTP proxy to use for future requests. """
self.conn.issue_command("SetProxy", host, port, user, password) | python | def set_proxy(self, host = "localhost",
port = 0,
user = "",
password = ""):
""" Sets a custom HTTP proxy to use for future requests. """
self.conn.issue_command("SetProxy", host, port, user, password) | [
"def",
"set_proxy",
"(",
"self",
",",
"host",
"=",
"\"localhost\"",
",",
"port",
"=",
"0",
",",
"user",
"=",
"\"\"",
",",
"password",
"=",
"\"\"",
")",
":",
"self",
".",
"conn",
".",
"issue_command",
"(",
"\"SetProxy\"",
",",
"host",
",",
"port",
","... | Sets a custom HTTP proxy to use for future requests. | [
"Sets",
"a",
"custom",
"HTTP",
"proxy",
"to",
"use",
"for",
"future",
"requests",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L356-L361 | train |
niklasb/webkit-server | webkit_server.py | Server.connect | def connect(self):
""" Returns a new socket connection to this server. """
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", self._port))
return sock | python | def connect(self):
""" Returns a new socket connection to this server. """
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", self._port))
return sock | [
"def",
"connect",
"(",
"self",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"sock",
".",
"connect",
"(",
"(",
"\"127.0.0.1\"",
",",
"self",
".",
"_port",
")",
")",
"return",
"s... | Returns a new socket connection to this server. | [
"Returns",
"a",
"new",
"socket",
"connection",
"to",
"this",
"server",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L437-L441 | train |
niklasb/webkit-server | webkit_server.py | SocketBuffer.read_line | def read_line(self):
""" Consume one line from the stream. """
while True:
newline_idx = self.buf.find(b"\n")
if newline_idx >= 0:
res = self.buf[:newline_idx]
self.buf = self.buf[newline_idx + 1:]
return res
chunk = self.f.recv(4096)
if not chunk:
raise E... | python | def read_line(self):
""" Consume one line from the stream. """
while True:
newline_idx = self.buf.find(b"\n")
if newline_idx >= 0:
res = self.buf[:newline_idx]
self.buf = self.buf[newline_idx + 1:]
return res
chunk = self.f.recv(4096)
if not chunk:
raise E... | [
"def",
"read_line",
"(",
"self",
")",
":",
"while",
"True",
":",
"newline_idx",
"=",
"self",
".",
"buf",
".",
"find",
"(",
"b\"\\n\"",
")",
"if",
"newline_idx",
">=",
"0",
":",
"res",
"=",
"self",
".",
"buf",
"[",
":",
"newline_idx",
"]",
"self",
"... | Consume one line from the stream. | [
"Consume",
"one",
"line",
"from",
"the",
"stream",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L475-L486 | train |
niklasb/webkit-server | webkit_server.py | SocketBuffer.read | def read(self, n):
""" Consume `n` characters from the stream. """
while len(self.buf) < n:
chunk = self.f.recv(4096)
if not chunk:
raise EndOfStreamError()
self.buf += chunk
res, self.buf = self.buf[:n], self.buf[n:]
return res | python | def read(self, n):
""" Consume `n` characters from the stream. """
while len(self.buf) < n:
chunk = self.f.recv(4096)
if not chunk:
raise EndOfStreamError()
self.buf += chunk
res, self.buf = self.buf[:n], self.buf[n:]
return res | [
"def",
"read",
"(",
"self",
",",
"n",
")",
":",
"while",
"len",
"(",
"self",
".",
"buf",
")",
"<",
"n",
":",
"chunk",
"=",
"self",
".",
"f",
".",
"recv",
"(",
"4096",
")",
"if",
"not",
"chunk",
":",
"raise",
"EndOfStreamError",
"(",
")",
"self"... | Consume `n` characters from the stream. | [
"Consume",
"n",
"characters",
"from",
"the",
"stream",
"."
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L488-L496 | train |
niklasb/webkit-server | webkit_server.py | ServerConnection.issue_command | def issue_command(self, cmd, *args):
""" Sends and receives a message to/from the server """
self._writeline(cmd)
self._writeline(str(len(args)))
for arg in args:
arg = str(arg)
self._writeline(str(len(arg)))
self._sock.sendall(arg.encode("utf-8"))
return self._read_response() | python | def issue_command(self, cmd, *args):
""" Sends and receives a message to/from the server """
self._writeline(cmd)
self._writeline(str(len(args)))
for arg in args:
arg = str(arg)
self._writeline(str(len(arg)))
self._sock.sendall(arg.encode("utf-8"))
return self._read_response() | [
"def",
"issue_command",
"(",
"self",
",",
"cmd",
",",
"*",
"args",
")",
":",
"self",
".",
"_writeline",
"(",
"cmd",
")",
"self",
".",
"_writeline",
"(",
"str",
"(",
"len",
"(",
"args",
")",
")",
")",
"for",
"arg",
"in",
"args",
":",
"arg",
"=",
... | Sends and receives a message to/from the server | [
"Sends",
"and",
"receives",
"a",
"message",
"to",
"/",
"from",
"the",
"server"
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L511-L520 | train |
niklasb/webkit-server | webkit_server.py | ServerConnection._read_response | def _read_response(self):
""" Reads a complete response packet from the server """
result = self.buf.read_line().decode("utf-8")
if not result:
raise NoResponseError("No response received from server.")
msg = self._read_message()
if result != "ok":
raise InvalidResponseError(msg)
r... | python | def _read_response(self):
""" Reads a complete response packet from the server """
result = self.buf.read_line().decode("utf-8")
if not result:
raise NoResponseError("No response received from server.")
msg = self._read_message()
if result != "ok":
raise InvalidResponseError(msg)
r... | [
"def",
"_read_response",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"buf",
".",
"read_line",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
"if",
"not",
"result",
":",
"raise",
"NoResponseError",
"(",
"\"No response received from server.\"",
")",
"m... | Reads a complete response packet from the server | [
"Reads",
"a",
"complete",
"response",
"packet",
"from",
"the",
"server"
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L522-L532 | train |
niklasb/webkit-server | webkit_server.py | ServerConnection._read_message | def _read_message(self):
""" Reads a single size-annotated message from the server """
size = int(self.buf.read_line().decode("utf-8"))
return self.buf.read(size).decode("utf-8") | python | def _read_message(self):
""" Reads a single size-annotated message from the server """
size = int(self.buf.read_line().decode("utf-8"))
return self.buf.read(size).decode("utf-8") | [
"def",
"_read_message",
"(",
"self",
")",
":",
"size",
"=",
"int",
"(",
"self",
".",
"buf",
".",
"read_line",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"return",
"self",
".",
"buf",
".",
"read",
"(",
"size",
")",
".",
"decode",
"(",
"\... | Reads a single size-annotated message from the server | [
"Reads",
"a",
"single",
"size",
"-",
"annotated",
"message",
"from",
"the",
"server"
] | c9e3a8394b8c51000c35f8a56fb770580562b544 | https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L534-L537 | train |
hanneshapke/pyzillow | pyzillow/pyzillow.py | ZillowWrapper.get_deep_search_results | def get_deep_search_results(self, address, zipcode):
"""
GetDeepSearchResults API
"""
url = 'http://www.zillow.com/webservice/GetDeepSearchResults.htm'
params = {
'address': address,
'citystatezip': zipcode,
'zws-id': self.api_key
}
... | python | def get_deep_search_results(self, address, zipcode):
"""
GetDeepSearchResults API
"""
url = 'http://www.zillow.com/webservice/GetDeepSearchResults.htm'
params = {
'address': address,
'citystatezip': zipcode,
'zws-id': self.api_key
}
... | [
"def",
"get_deep_search_results",
"(",
"self",
",",
"address",
",",
"zipcode",
")",
":",
"url",
"=",
"'http://www.zillow.com/webservice/GetDeepSearchResults.htm'",
"params",
"=",
"{",
"'address'",
":",
"address",
",",
"'citystatezip'",
":",
"zipcode",
",",
"'zws-id'",... | GetDeepSearchResults API | [
"GetDeepSearchResults",
"API"
] | 1de937669da4ec1eb779b4615f903d3e5bd0eca6 | https://github.com/hanneshapke/pyzillow/blob/1de937669da4ec1eb779b4615f903d3e5bd0eca6/pyzillow/pyzillow.py#L20-L31 | train |
hanneshapke/pyzillow | pyzillow/pyzillow.py | ZillowWrapper.get_updated_property_details | def get_updated_property_details(self, zpid):
"""
GetUpdatedPropertyDetails API
"""
url = 'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm'
params = {
'zpid': zpid,
'zws-id': self.api_key
}
return self.get_data(url, params) | python | def get_updated_property_details(self, zpid):
"""
GetUpdatedPropertyDetails API
"""
url = 'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm'
params = {
'zpid': zpid,
'zws-id': self.api_key
}
return self.get_data(url, params) | [
"def",
"get_updated_property_details",
"(",
"self",
",",
"zpid",
")",
":",
"url",
"=",
"'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm'",
"params",
"=",
"{",
"'zpid'",
":",
"zpid",
",",
"'zws-id'",
":",
"self",
".",
"api_key",
"}",
"return",
"self",... | GetUpdatedPropertyDetails API | [
"GetUpdatedPropertyDetails",
"API"
] | 1de937669da4ec1eb779b4615f903d3e5bd0eca6 | https://github.com/hanneshapke/pyzillow/blob/1de937669da4ec1eb779b4615f903d3e5bd0eca6/pyzillow/pyzillow.py#L33-L43 | train |
kylefox/python-image-orientation-patch | img_rotate/__init__.py | fix_orientation | def fix_orientation(img, save_over=False):
"""
`img` can be an Image instance or a path to an image file.
`save_over` indicates if the original image file should be replaced by the new image.
* Note: `save_over` is only valid if `img` is a file path.
"""
path = None
if not isinstance(img, Im... | python | def fix_orientation(img, save_over=False):
"""
`img` can be an Image instance or a path to an image file.
`save_over` indicates if the original image file should be replaced by the new image.
* Note: `save_over` is only valid if `img` is a file path.
"""
path = None
if not isinstance(img, Im... | [
"def",
"fix_orientation",
"(",
"img",
",",
"save_over",
"=",
"False",
")",
":",
"path",
"=",
"None",
"if",
"not",
"isinstance",
"(",
"img",
",",
"Image",
".",
"Image",
")",
":",
"path",
"=",
"img",
"img",
"=",
"Image",
".",
"open",
"(",
"path",
")"... | `img` can be an Image instance or a path to an image file.
`save_over` indicates if the original image file should be replaced by the new image.
* Note: `save_over` is only valid if `img` is a file path. | [
"img",
"can",
"be",
"an",
"Image",
"instance",
"or",
"a",
"path",
"to",
"an",
"image",
"file",
".",
"save_over",
"indicates",
"if",
"the",
"original",
"image",
"file",
"should",
"be",
"replaced",
"by",
"the",
"new",
"image",
".",
"*",
"Note",
":",
"sav... | 7941763d732a3bec0497991479be3c57aedd3415 | https://github.com/kylefox/python-image-orientation-patch/blob/7941763d732a3bec0497991479be3c57aedd3415/img_rotate/__init__.py#L25-L54 | train |
anfema/integrate | integrate/check.py | Check.log_error | def log_error(self, error, message, detail=None, strip=4):
"Add an error message and optional user message to the error list"
if message:
msg = message + ": " + error
else:
msg = error
tb = traceback.format_stack()
if sys.version_info >= (3, 0):
... | python | def log_error(self, error, message, detail=None, strip=4):
"Add an error message and optional user message to the error list"
if message:
msg = message + ": " + error
else:
msg = error
tb = traceback.format_stack()
if sys.version_info >= (3, 0):
... | [
"def",
"log_error",
"(",
"self",
",",
"error",
",",
"message",
",",
"detail",
"=",
"None",
",",
"strip",
"=",
"4",
")",
":",
"if",
"message",
":",
"msg",
"=",
"message",
"+",
"\": \"",
"+",
"error",
"else",
":",
"msg",
"=",
"error",
"tb",
"=",
"t... | Add an error message and optional user message to the error list | [
"Add",
"an",
"error",
"message",
"and",
"optional",
"user",
"message",
"to",
"the",
"error",
"list"
] | e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7 | https://github.com/anfema/integrate/blob/e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7/integrate/check.py#L12-L29 | train |
anfema/integrate | integrate/check.py | Check.equal | def equal(self, a, b, message=None):
"Check if two values are equal"
if a != b:
self.log_error("{} != {}".format(str(a), str(b)), message)
return False
return True | python | def equal(self, a, b, message=None):
"Check if two values are equal"
if a != b:
self.log_error("{} != {}".format(str(a), str(b)), message)
return False
return True | [
"def",
"equal",
"(",
"self",
",",
"a",
",",
"b",
",",
"message",
"=",
"None",
")",
":",
"if",
"a",
"!=",
"b",
":",
"self",
".",
"log_error",
"(",
"\"{} != {}\"",
".",
"format",
"(",
"str",
"(",
"a",
")",
",",
"str",
"(",
"b",
")",
")",
",",
... | Check if two values are equal | [
"Check",
"if",
"two",
"values",
"are",
"equal"
] | e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7 | https://github.com/anfema/integrate/blob/e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7/integrate/check.py#L35-L40 | train |
anfema/integrate | integrate/check.py | Check.is_not_none | def is_not_none(self, a, message=None):
"Check if a value is not None"
if a is None:
self.log_error("{} is None".format(str(a)), message)
return False
return True | python | def is_not_none(self, a, message=None):
"Check if a value is not None"
if a is None:
self.log_error("{} is None".format(str(a)), message)
return False
return True | [
"def",
"is_not_none",
"(",
"self",
",",
"a",
",",
"message",
"=",
"None",
")",
":",
"if",
"a",
"is",
"None",
":",
"self",
".",
"log_error",
"(",
"\"{} is None\"",
".",
"format",
"(",
"str",
"(",
"a",
")",
")",
",",
"message",
")",
"return",
"False"... | Check if a value is not None | [
"Check",
"if",
"a",
"value",
"is",
"not",
"None"
] | e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7 | https://github.com/anfema/integrate/blob/e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7/integrate/check.py#L56-L61 | train |
anfema/integrate | integrate/check.py | Check.raises | def raises(self, exception_type, function, *args, **kwargs):
"""
Check if a function raises a specified exception type,
*args and **kwargs are forwarded to the function
"""
try:
result = function(*args, **kwargs)
self.log_error("{} did not throw ex... | python | def raises(self, exception_type, function, *args, **kwargs):
"""
Check if a function raises a specified exception type,
*args and **kwargs are forwarded to the function
"""
try:
result = function(*args, **kwargs)
self.log_error("{} did not throw ex... | [
"def",
"raises",
"(",
"self",
",",
"exception_type",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"result",
"=",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"log_error",
"(",
"\"{} d... | Check if a function raises a specified exception type,
*args and **kwargs are forwarded to the function | [
"Check",
"if",
"a",
"function",
"raises",
"a",
"specified",
"exception",
"type",
"*",
"args",
"and",
"**",
"kwargs",
"are",
"forwarded",
"to",
"the",
"function"
] | e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7 | https://github.com/anfema/integrate/blob/e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7/integrate/check.py#L82-L99 | train |
anfema/integrate | integrate/check.py | Check.does_not_raise | def does_not_raise(self, function, *args, **kwargs):
"""
Check if a function does not raise an exception,
*args and **kwargs are forwarded to the function
"""
try:
return function(*args, **kwargs)
except Exception as e:
self.log_error("{} d... | python | def does_not_raise(self, function, *args, **kwargs):
"""
Check if a function does not raise an exception,
*args and **kwargs are forwarded to the function
"""
try:
return function(*args, **kwargs)
except Exception as e:
self.log_error("{} d... | [
"def",
"does_not_raise",
"(",
"self",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"log_e... | Check if a function does not raise an exception,
*args and **kwargs are forwarded to the function | [
"Check",
"if",
"a",
"function",
"does",
"not",
"raise",
"an",
"exception",
"*",
"args",
"and",
"**",
"kwargs",
"are",
"forwarded",
"to",
"the",
"function"
] | e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7 | https://github.com/anfema/integrate/blob/e9d3bb8f0613e82184735ee67a42ea01b1a9b1b7/integrate/check.py#L101-L112 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | calculate_color_temperature | def calculate_color_temperature(r, g, b):
"""Converts the raw R/G/B values to color temperature in degrees Kelvin."""
# 1. Map RGB values to their XYZ counterparts.
# Based on 6500K fluorescent, 3000K fluorescent
# and 60W incandescent values for a wide range.
# Note: Y = Illuminance or lux
X = ... | python | def calculate_color_temperature(r, g, b):
"""Converts the raw R/G/B values to color temperature in degrees Kelvin."""
# 1. Map RGB values to their XYZ counterparts.
# Based on 6500K fluorescent, 3000K fluorescent
# and 60W incandescent values for a wide range.
# Note: Y = Illuminance or lux
X = ... | [
"def",
"calculate_color_temperature",
"(",
"r",
",",
"g",
",",
"b",
")",
":",
"# 1. Map RGB values to their XYZ counterparts.",
"# Based on 6500K fluorescent, 3000K fluorescent",
"# and 60W incandescent values for a wide range.",
"# Note: Y = Illuminance or lux",
"X",
"=",
"(",
"-"... | Converts the raw R/G/B values to color temperature in degrees Kelvin. | [
"Converts",
"the",
"raw",
"R",
"/",
"G",
"/",
"B",
"values",
"to",
"color",
"temperature",
"in",
"degrees",
"Kelvin",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L102-L124 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | calculate_lux | def calculate_lux(r, g, b):
"""Converts the raw R/G/B values to luminosity in lux."""
illuminance = (-0.32466 * r) + (1.57837 * g) + (-0.73191 * b)
return int(illuminance) | python | def calculate_lux(r, g, b):
"""Converts the raw R/G/B values to luminosity in lux."""
illuminance = (-0.32466 * r) + (1.57837 * g) + (-0.73191 * b)
return int(illuminance) | [
"def",
"calculate_lux",
"(",
"r",
",",
"g",
",",
"b",
")",
":",
"illuminance",
"=",
"(",
"-",
"0.32466",
"*",
"r",
")",
"+",
"(",
"1.57837",
"*",
"g",
")",
"+",
"(",
"-",
"0.73191",
"*",
"b",
")",
"return",
"int",
"(",
"illuminance",
")"
] | Converts the raw R/G/B values to luminosity in lux. | [
"Converts",
"the",
"raw",
"R",
"/",
"G",
"/",
"B",
"values",
"to",
"luminosity",
"in",
"lux",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L126-L129 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725._write8 | def _write8(self, reg, value):
"""Write a 8-bit value to a register."""
self._device.write8(TCS34725_COMMAND_BIT | reg, value) | python | def _write8(self, reg, value):
"""Write a 8-bit value to a register."""
self._device.write8(TCS34725_COMMAND_BIT | reg, value) | [
"def",
"_write8",
"(",
"self",
",",
"reg",
",",
"value",
")",
":",
"self",
".",
"_device",
".",
"write8",
"(",
"TCS34725_COMMAND_BIT",
"|",
"reg",
",",
"value",
")"
] | Write a 8-bit value to a register. | [
"Write",
"a",
"8",
"-",
"bit",
"value",
"to",
"a",
"register",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L161-L163 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.enable | def enable(self):
"""Enable the chip."""
# Flip on the power and enable bits.
self._write8(TCS34725_ENABLE, TCS34725_ENABLE_PON)
time.sleep(0.01)
self._write8(TCS34725_ENABLE, (TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN)) | python | def enable(self):
"""Enable the chip."""
# Flip on the power and enable bits.
self._write8(TCS34725_ENABLE, TCS34725_ENABLE_PON)
time.sleep(0.01)
self._write8(TCS34725_ENABLE, (TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN)) | [
"def",
"enable",
"(",
"self",
")",
":",
"# Flip on the power and enable bits.",
"self",
".",
"_write8",
"(",
"TCS34725_ENABLE",
",",
"TCS34725_ENABLE_PON",
")",
"time",
".",
"sleep",
"(",
"0.01",
")",
"self",
".",
"_write8",
"(",
"TCS34725_ENABLE",
",",
"(",
"... | Enable the chip. | [
"Enable",
"the",
"chip",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L165-L170 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.disable | def disable(self):
"""Disable the chip (power down)."""
# Flip off the power on and enable bits.
reg = self._readU8(TCS34725_ENABLE)
reg &= ~(TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN)
self._write8(TCS34725_ENABLE, reg) | python | def disable(self):
"""Disable the chip (power down)."""
# Flip off the power on and enable bits.
reg = self._readU8(TCS34725_ENABLE)
reg &= ~(TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN)
self._write8(TCS34725_ENABLE, reg) | [
"def",
"disable",
"(",
"self",
")",
":",
"# Flip off the power on and enable bits.",
"reg",
"=",
"self",
".",
"_readU8",
"(",
"TCS34725_ENABLE",
")",
"reg",
"&=",
"~",
"(",
"TCS34725_ENABLE_PON",
"|",
"TCS34725_ENABLE_AEN",
")",
"self",
".",
"_write8",
"(",
"TCS... | Disable the chip (power down). | [
"Disable",
"the",
"chip",
"(",
"power",
"down",
")",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L172-L177 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.set_integration_time | def set_integration_time(self, integration_time):
"""Sets the integration time for the TC34725. Provide one of these
constants:
- TCS34725_INTEGRATIONTIME_2_4MS = 2.4ms - 1 cycle - Max Count: 1024
- TCS34725_INTEGRATIONTIME_24MS = 24ms - 10 cycles - Max Count: 10240
-... | python | def set_integration_time(self, integration_time):
"""Sets the integration time for the TC34725. Provide one of these
constants:
- TCS34725_INTEGRATIONTIME_2_4MS = 2.4ms - 1 cycle - Max Count: 1024
- TCS34725_INTEGRATIONTIME_24MS = 24ms - 10 cycles - Max Count: 10240
-... | [
"def",
"set_integration_time",
"(",
"self",
",",
"integration_time",
")",
":",
"self",
".",
"_integration_time",
"=",
"integration_time",
"self",
".",
"_write8",
"(",
"TCS34725_ATIME",
",",
"integration_time",
")"
] | Sets the integration time for the TC34725. Provide one of these
constants:
- TCS34725_INTEGRATIONTIME_2_4MS = 2.4ms - 1 cycle - Max Count: 1024
- TCS34725_INTEGRATIONTIME_24MS = 24ms - 10 cycles - Max Count: 10240
- TCS34725_INTEGRATIONTIME_50MS = 50ms - 20 cycles - Max C... | [
"Sets",
"the",
"integration",
"time",
"for",
"the",
"TC34725",
".",
"Provide",
"one",
"of",
"these",
"constants",
":",
"-",
"TCS34725_INTEGRATIONTIME_2_4MS",
"=",
"2",
".",
"4ms",
"-",
"1",
"cycle",
"-",
"Max",
"Count",
":",
"1024",
"-",
"TCS34725_INTEGRATIO... | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L179-L190 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.get_raw_data | def get_raw_data(self):
"""Reads the raw red, green, blue and clear channel values. Will return
a 4-tuple with the red, green, blue, clear color values (unsigned 16-bit
numbers).
"""
# Read each color register.
r = self._readU16LE(TCS34725_RDATAL)
g = self._readU1... | python | def get_raw_data(self):
"""Reads the raw red, green, blue and clear channel values. Will return
a 4-tuple with the red, green, blue, clear color values (unsigned 16-bit
numbers).
"""
# Read each color register.
r = self._readU16LE(TCS34725_RDATAL)
g = self._readU1... | [
"def",
"get_raw_data",
"(",
"self",
")",
":",
"# Read each color register.",
"r",
"=",
"self",
".",
"_readU16LE",
"(",
"TCS34725_RDATAL",
")",
"g",
"=",
"self",
".",
"_readU16LE",
"(",
"TCS34725_GDATAL",
")",
"b",
"=",
"self",
".",
"_readU16LE",
"(",
"TCS347... | Reads the raw red, green, blue and clear channel values. Will return
a 4-tuple with the red, green, blue, clear color values (unsigned 16-bit
numbers). | [
"Reads",
"the",
"raw",
"red",
"green",
"blue",
"and",
"clear",
"channel",
"values",
".",
"Will",
"return",
"a",
"4",
"-",
"tuple",
"with",
"the",
"red",
"green",
"blue",
"clear",
"color",
"values",
"(",
"unsigned",
"16",
"-",
"bit",
"numbers",
")",
"."... | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L214-L226 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.set_interrupt | def set_interrupt(self, enabled):
"""Enable or disable interrupts by setting enabled to True or False."""
enable_reg = self._readU8(TCS34725_ENABLE)
if enabled:
enable_reg |= TCS34725_ENABLE_AIEN
else:
enable_reg &= ~TCS34725_ENABLE_AIEN
self._write8(TCS34... | python | def set_interrupt(self, enabled):
"""Enable or disable interrupts by setting enabled to True or False."""
enable_reg = self._readU8(TCS34725_ENABLE)
if enabled:
enable_reg |= TCS34725_ENABLE_AIEN
else:
enable_reg &= ~TCS34725_ENABLE_AIEN
self._write8(TCS34... | [
"def",
"set_interrupt",
"(",
"self",
",",
"enabled",
")",
":",
"enable_reg",
"=",
"self",
".",
"_readU8",
"(",
"TCS34725_ENABLE",
")",
"if",
"enabled",
":",
"enable_reg",
"|=",
"TCS34725_ENABLE_AIEN",
"else",
":",
"enable_reg",
"&=",
"~",
"TCS34725_ENABLE_AIEN",... | Enable or disable interrupts by setting enabled to True or False. | [
"Enable",
"or",
"disable",
"interrupts",
"by",
"setting",
"enabled",
"to",
"True",
"or",
"False",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L228-L236 | train |
adafruit/Adafruit_Python_TCS34725 | Adafruit_TCS34725/TCS34725.py | TCS34725.set_interrupt_limits | def set_interrupt_limits(self, low, high):
"""Set the interrupt limits to provied unsigned 16-bit threshold values.
"""
self._device.write8(0x04, low & 0xFF)
self._device.write8(0x05, low >> 8)
self._device.write8(0x06, high & 0xFF)
self._device.write8(0x07, high >> 8) | python | def set_interrupt_limits(self, low, high):
"""Set the interrupt limits to provied unsigned 16-bit threshold values.
"""
self._device.write8(0x04, low & 0xFF)
self._device.write8(0x05, low >> 8)
self._device.write8(0x06, high & 0xFF)
self._device.write8(0x07, high >> 8) | [
"def",
"set_interrupt_limits",
"(",
"self",
",",
"low",
",",
"high",
")",
":",
"self",
".",
"_device",
".",
"write8",
"(",
"0x04",
",",
"low",
"&",
"0xFF",
")",
"self",
".",
"_device",
".",
"write8",
"(",
"0x05",
",",
"low",
">>",
"8",
")",
"self",... | Set the interrupt limits to provied unsigned 16-bit threshold values. | [
"Set",
"the",
"interrupt",
"limits",
"to",
"provied",
"unsigned",
"16",
"-",
"bit",
"threshold",
"values",
"."
] | 996396cd095522d788b7b15d20fd44e566c8464e | https://github.com/adafruit/Adafruit_Python_TCS34725/blob/996396cd095522d788b7b15d20fd44e566c8464e/Adafruit_TCS34725/TCS34725.py#L242-L248 | train |
latture/json2table | json2table/json2table.py | convert | def convert(json_input, build_direction="LEFT_TO_RIGHT", table_attributes=None):
"""
Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
build_direction : {"TOP_TO_BOTTOM", "LEFT_TO_RIGHT"}
String denoting the build direc... | python | def convert(json_input, build_direction="LEFT_TO_RIGHT", table_attributes=None):
"""
Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
build_direction : {"TOP_TO_BOTTOM", "LEFT_TO_RIGHT"}
String denoting the build direc... | [
"def",
"convert",
"(",
"json_input",
",",
"build_direction",
"=",
"\"LEFT_TO_RIGHT\"",
",",
"table_attributes",
"=",
"None",
")",
":",
"json_converter",
"=",
"JsonConverter",
"(",
"build_direction",
"=",
"build_direction",
",",
"table_attributes",
"=",
"table_attribut... | Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
build_direction : {"TOP_TO_BOTTOM", "LEFT_TO_RIGHT"}
String denoting the build direction of the table. If ``"TOP_TO_BOTTOM"`` child
objects will be appended below parent... | [
"Converts",
"JSON",
"to",
"HTML",
"Table",
"format",
"."
] | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L12-L48 | train |
latture/json2table | json2table/json2table.py | JsonConverter.convert | def convert(self, json_input):
"""
Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
Returns
-------
str
String of converted HTML.
"""
html_output = self.... | python | def convert(self, json_input):
"""
Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
Returns
-------
str
String of converted HTML.
"""
html_output = self.... | [
"def",
"convert",
"(",
"self",
",",
"json_input",
")",
":",
"html_output",
"=",
"self",
".",
"_table_opening_tag",
"if",
"self",
".",
"_build_top_to_bottom",
":",
"html_output",
"+=",
"self",
".",
"_markup_header_row",
"(",
"json_input",
".",
"keys",
"(",
")",... | Converts JSON to HTML Table format.
Parameters
----------
json_input : dict
JSON object to convert into HTML.
Returns
-------
str
String of converted HTML. | [
"Converts",
"JSON",
"to",
"HTML",
"Table",
"format",
"."
] | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L73-L109 | train |
latture/json2table | json2table/json2table.py | JsonConverter._dict_to_html_attributes | def _dict_to_html_attributes(d):
"""
Converts a dictionary to a string of ``key=\"value\"`` pairs.
If ``None`` is provided as the dictionary an empty string is returned,
i.e. no html attributes are generated.
Parameters
----------
d : dict
Dictionary ... | python | def _dict_to_html_attributes(d):
"""
Converts a dictionary to a string of ``key=\"value\"`` pairs.
If ``None`` is provided as the dictionary an empty string is returned,
i.e. no html attributes are generated.
Parameters
----------
d : dict
Dictionary ... | [
"def",
"_dict_to_html_attributes",
"(",
"d",
")",
":",
"if",
"d",
"is",
"None",
":",
"return",
"\"\"",
"return",
"\"\"",
".",
"join",
"(",
"\" {}=\\\"{}\\\"\"",
".",
"format",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"iter",
"("... | Converts a dictionary to a string of ``key=\"value\"`` pairs.
If ``None`` is provided as the dictionary an empty string is returned,
i.e. no html attributes are generated.
Parameters
----------
d : dict
Dictionary to convert to html attributes.
Returns
... | [
"Converts",
"a",
"dictionary",
"to",
"a",
"string",
"of",
"key",
"=",
"\\",
"value",
"\\",
"pairs",
".",
"If",
"None",
"is",
"provided",
"as",
"the",
"dictionary",
"an",
"empty",
"string",
"is",
"returned",
"i",
".",
"e",
".",
"no",
"html",
"attributes... | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L144-L164 | train |
latture/json2table | json2table/json2table.py | JsonConverter._list_of_dicts_to_column_headers | def _list_of_dicts_to_column_headers(list_of_dicts):
"""
Detects if all entries in an list of ``dict``'s have identical keys.
Returns the keys if all keys are the same and ``None`` otherwise.
Parameters
----------
list_of_dicts : list
List of dictionaries to ... | python | def _list_of_dicts_to_column_headers(list_of_dicts):
"""
Detects if all entries in an list of ``dict``'s have identical keys.
Returns the keys if all keys are the same and ``None`` otherwise.
Parameters
----------
list_of_dicts : list
List of dictionaries to ... | [
"def",
"_list_of_dicts_to_column_headers",
"(",
"list_of_dicts",
")",
":",
"if",
"len",
"(",
"list_of_dicts",
")",
"<",
"2",
"or",
"not",
"all",
"(",
"isinstance",
"(",
"item",
",",
"dict",
")",
"for",
"item",
"in",
"list_of_dicts",
")",
":",
"return",
"No... | Detects if all entries in an list of ``dict``'s have identical keys.
Returns the keys if all keys are the same and ``None`` otherwise.
Parameters
----------
list_of_dicts : list
List of dictionaries to test for identical keys.
Returns
-------
list or... | [
"Detects",
"if",
"all",
"entries",
"in",
"an",
"list",
"of",
"dict",
"s",
"have",
"identical",
"keys",
".",
"Returns",
"the",
"keys",
"if",
"all",
"keys",
"are",
"the",
"same",
"and",
"None",
"otherwise",
"."
] | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L167-L190 | train |
latture/json2table | json2table/json2table.py | JsonConverter._markup | def _markup(self, entry):
"""
Recursively generates HTML for the current entry.
Parameters
----------
entry : object
Object to convert to HTML. Maybe be a single entity or contain multiple and/or nested objects.
Returns
-------
str
... | python | def _markup(self, entry):
"""
Recursively generates HTML for the current entry.
Parameters
----------
entry : object
Object to convert to HTML. Maybe be a single entity or contain multiple and/or nested objects.
Returns
-------
str
... | [
"def",
"_markup",
"(",
"self",
",",
"entry",
")",
":",
"if",
"entry",
"is",
"None",
":",
"return",
"\"\"",
"if",
"isinstance",
"(",
"entry",
",",
"list",
")",
":",
"list_markup",
"=",
"\"<ul>\"",
"for",
"item",
"in",
"entry",
":",
"list_markup",
"+=",
... | Recursively generates HTML for the current entry.
Parameters
----------
entry : object
Object to convert to HTML. Maybe be a single entity or contain multiple and/or nested objects.
Returns
-------
str
String of HTML formatted json. | [
"Recursively",
"generates",
"HTML",
"for",
"the",
"current",
"entry",
"."
] | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L192-L218 | train |
latture/json2table | json2table/json2table.py | JsonConverter._maybe_club | def _maybe_club(self, list_of_dicts):
"""
If all keys in a list of dicts are identical, values from each ``dict``
are clubbed, i.e. inserted under a common column heading. If the keys
are not identical ``None`` is returned, and the list should be converted
to HTML per the normal... | python | def _maybe_club(self, list_of_dicts):
"""
If all keys in a list of dicts are identical, values from each ``dict``
are clubbed, i.e. inserted under a common column heading. If the keys
are not identical ``None`` is returned, and the list should be converted
to HTML per the normal... | [
"def",
"_maybe_club",
"(",
"self",
",",
"list_of_dicts",
")",
":",
"column_headers",
"=",
"JsonConverter",
".",
"_list_of_dicts_to_column_headers",
"(",
"list_of_dicts",
")",
"if",
"column_headers",
"is",
"None",
":",
"# common headers not found, return normal markup",
"h... | If all keys in a list of dicts are identical, values from each ``dict``
are clubbed, i.e. inserted under a common column heading. If the keys
are not identical ``None`` is returned, and the list should be converted
to HTML per the normal ``convert`` function.
Parameters
-------... | [
"If",
"all",
"keys",
"in",
"a",
"list",
"of",
"dicts",
"are",
"identical",
"values",
"from",
"each",
"dict",
"are",
"clubbed",
"i",
".",
"e",
".",
"inserted",
"under",
"a",
"common",
"column",
"heading",
".",
"If",
"the",
"keys",
"are",
"not",
"identic... | 8bd1363f54ee4fd608ffb7677761526184a9da83 | https://github.com/latture/json2table/blob/8bd1363f54ee4fd608ffb7677761526184a9da83/json2table/json2table.py#L220-L272 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/tpl.py | TplApi.update_voice_notify | def update_voice_notify(self, param, must=[APIKEY, TPL_ID, TPL_CONTENT]):
'''修改语音通知模版
注意:模板成功修改之后需要重新审核才能使用!同时提醒您如果修改了变量,务必重新测试,以免替换出错!
参数:
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
tpl_id Long 是 模板... | python | def update_voice_notify(self, param, must=[APIKEY, TPL_ID, TPL_CONTENT]):
'''修改语音通知模版
注意:模板成功修改之后需要重新审核才能使用!同时提醒您如果修改了变量,务必重新测试,以免替换出错!
参数:
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
tpl_id Long 是 模板... | [
"def",
"update_voice_notify",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"TPL_ID",
",",
"TPL_CONTENT",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
... | 修改语音通知模版
注意:模板成功修改之后需要重新审核才能使用!同时提醒您如果修改了变量,务必重新测试,以免替换出错!
参数:
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
tpl_id Long 是 模板id,64位长整形。指定id时返回id对应的模板。未指定时返回所有模板 9527
tpl_content String 是 模板i... | [
"修改语音通知模版",
"注意:模板成功修改之后需要重新审核才能使用!同时提醒您如果修改了变量,务必重新测试,以免替换出错!",
"参数:",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"tpl_id",
"Long",
"是",
"模板id,64位长整形。指定id时返回id对应的模板。未指定时返回所有模板",
"9527",
"tpl_content",
"String",
"是"... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/tpl.py#L144-L163 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/model/result.py | Result.code | def code(self, code=None, ret_r=False):
'''
Args:
code: (Optional) set code
ret_r: (Optional) force to return Result. Default value is False
returns:
response code(0-success, others-failure) or self
'''
if code or ret_r:
self._code ... | python | def code(self, code=None, ret_r=False):
'''
Args:
code: (Optional) set code
ret_r: (Optional) force to return Result. Default value is False
returns:
response code(0-success, others-failure) or self
'''
if code or ret_r:
self._code ... | [
"def",
"code",
"(",
"self",
",",
"code",
"=",
"None",
",",
"ret_r",
"=",
"False",
")",
":",
"if",
"code",
"or",
"ret_r",
":",
"self",
".",
"_code",
"=",
"code",
"return",
"self",
"return",
"self",
".",
"_code"
] | Args:
code: (Optional) set code
ret_r: (Optional) force to return Result. Default value is False
returns:
response code(0-success, others-failure) or self | [
"Args",
":",
"code",
":",
"(",
"Optional",
")",
"set",
"code",
"ret_r",
":",
"(",
"Optional",
")",
"force",
"to",
"return",
"Result",
".",
"Default",
"value",
"is",
"False",
"returns",
":",
"response",
"code",
"(",
"0",
"-",
"success",
"others",
"-",
... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/model/result.py#L33-L44 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/model/result.py | Result.msg | def msg(self, msg=None, ret_r=False):
'''code's message'''
if msg or ret_r:
self._msg = msg
return self
return self._msg | python | def msg(self, msg=None, ret_r=False):
'''code's message'''
if msg or ret_r:
self._msg = msg
return self
return self._msg | [
"def",
"msg",
"(",
"self",
",",
"msg",
"=",
"None",
",",
"ret_r",
"=",
"False",
")",
":",
"if",
"msg",
"or",
"ret_r",
":",
"self",
".",
"_msg",
"=",
"msg",
"return",
"self",
"return",
"self",
".",
"_msg"
] | code's message | [
"code",
"s",
"message"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/model/result.py#L46-L51 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/model/result.py | Result.detail | def detail(self, detail=None, ret_r=False):
'''code's detail'''
if detail or ret_r:
self._detail = detail
return self
return self._detail | python | def detail(self, detail=None, ret_r=False):
'''code's detail'''
if detail or ret_r:
self._detail = detail
return self
return self._detail | [
"def",
"detail",
"(",
"self",
",",
"detail",
"=",
"None",
",",
"ret_r",
"=",
"False",
")",
":",
"if",
"detail",
"or",
"ret_r",
":",
"self",
".",
"_detail",
"=",
"detail",
"return",
"self",
"return",
"self",
".",
"_detail"
] | code's detail | [
"code",
"s",
"detail"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/model/result.py#L53-L58 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/model/result.py | Result.data | def data(self, data=None, ret_r=False):
'''response data'''
if data or ret_r:
self._data = data
return self
return self._data | python | def data(self, data=None, ret_r=False):
'''response data'''
if data or ret_r:
self._data = data
return self
return self._data | [
"def",
"data",
"(",
"self",
",",
"data",
"=",
"None",
",",
"ret_r",
"=",
"False",
")",
":",
"if",
"data",
"or",
"ret_r",
":",
"self",
".",
"_data",
"=",
"data",
"return",
"self",
"return",
"self",
".",
"_data"
] | response data | [
"response",
"data"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/model/result.py#L60-L65 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/user.py | UserApi.get | def get(self, param=None, must=[APIKEY]):
'''查账户信息
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
Args:
param: (Optional)
Results:
Result
'''
param = {} if param is None else param
r = s... | python | def get(self, param=None, must=[APIKEY]):
'''查账户信息
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
Args:
param: (Optional)
Results:
Result
'''
param = {} if param is None else param
r = s... | [
"def",
"get",
"(",
"self",
",",
"param",
"=",
"None",
",",
"must",
"=",
"[",
"APIKEY",
"]",
")",
":",
"param",
"=",
"{",
"}",
"if",
"param",
"is",
"None",
"else",
"param",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"... | 查账户信息
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
Args:
param: (Optional)
Results:
Result | [
"查账户信息",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"Args",
":",
"param",
":",
"(",
"Optional",
")",
"Results",
":",
"Result"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/user.py#L19-L35 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/ypapi.py | YunpianApi._init | def _init(self, clnt):
'''initialize api by YunpianClient'''
assert clnt, "clnt is None"
self._clnt = clnt
self._apikey = clnt.apikey()
self._version = clnt.conf(YP_VERSION, defval=VERSION_V2)
self._charset = clnt.conf(HTTP_CHARSET, defval=CHARSET_UTF8)
self._name... | python | def _init(self, clnt):
'''initialize api by YunpianClient'''
assert clnt, "clnt is None"
self._clnt = clnt
self._apikey = clnt.apikey()
self._version = clnt.conf(YP_VERSION, defval=VERSION_V2)
self._charset = clnt.conf(HTTP_CHARSET, defval=CHARSET_UTF8)
self._name... | [
"def",
"_init",
"(",
"self",
",",
"clnt",
")",
":",
"assert",
"clnt",
",",
"\"clnt is None\"",
"self",
".",
"_clnt",
"=",
"clnt",
"self",
".",
"_apikey",
"=",
"clnt",
".",
"apikey",
"(",
")",
"self",
".",
"_version",
"=",
"clnt",
".",
"conf",
"(",
... | initialize api by YunpianClient | [
"initialize",
"api",
"by",
"YunpianClient"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/ypapi.py#L94-L101 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/ypapi.py | YunpianApi.name | def name(self, name=None):
'''api name, default is module.__name__'''
if name:
self._name = name
return self
return self._name | python | def name(self, name=None):
'''api name, default is module.__name__'''
if name:
self._name = name
return self
return self._name | [
"def",
"name",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"self",
".",
"_name",
"=",
"name",
"return",
"self",
"return",
"self",
".",
"_name"
] | api name, default is module.__name__ | [
"api",
"name",
"default",
"is",
"module",
".",
"__name__"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/ypapi.py#L139-L144 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/ypapi.py | YunpianApi.post | def post(self, param, h, r):
'''
Args:
param: request parameters
h: ResultHandler
r: YunpianApiResult
'''
try:
rsp = self.client().post(self.uri(), param)
# print(rsp)
return self.result(rsp, h, r)
except Val... | python | def post(self, param, h, r):
'''
Args:
param: request parameters
h: ResultHandler
r: YunpianApiResult
'''
try:
rsp = self.client().post(self.uri(), param)
# print(rsp)
return self.result(rsp, h, r)
except Val... | [
"def",
"post",
"(",
"self",
",",
"param",
",",
"h",
",",
"r",
")",
":",
"try",
":",
"rsp",
"=",
"self",
".",
"client",
"(",
")",
".",
"post",
"(",
"self",
".",
"uri",
"(",
")",
",",
"param",
")",
"# print(rsp)",
"return",
"self",
".",
"result",... | Args:
param: request parameters
h: ResultHandler
r: YunpianApiResult | [
"Args",
":",
"param",
":",
"request",
"parameters",
"h",
":",
"ResultHandler",
"r",
":",
"YunpianApiResult"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/ypapi.py#L150-L162 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/ypapi.py | YunpianApi.verify_param | def verify_param(self, param, must=[], r=None):
'''return Code.ARGUMENT_MISSING if every key in must not found in param'''
if APIKEY not in param:
param[APIKEY] = self.apikey()
r = Result() if r is None else r
for p in must:
if p not in param:
r.c... | python | def verify_param(self, param, must=[], r=None):
'''return Code.ARGUMENT_MISSING if every key in must not found in param'''
if APIKEY not in param:
param[APIKEY] = self.apikey()
r = Result() if r is None else r
for p in must:
if p not in param:
r.c... | [
"def",
"verify_param",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"]",
",",
"r",
"=",
"None",
")",
":",
"if",
"APIKEY",
"not",
"in",
"param",
":",
"param",
"[",
"APIKEY",
"]",
"=",
"self",
".",
"apikey",
"(",
")",
"r",
"=",
"Result",
"("... | return Code.ARGUMENT_MISSING if every key in must not found in param | [
"return",
"Code",
".",
"ARGUMENT_MISSING",
"if",
"every",
"key",
"in",
"must",
"not",
"found",
"in",
"param"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/ypapi.py#L180-L191 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | _YunpianConf.custom_conf | def custom_conf(self, conf):
'''custom apikey and http parameters'''
if conf:
for (key, val) in conf.items():
self.__conf[key] = val
return self | python | def custom_conf(self, conf):
'''custom apikey and http parameters'''
if conf:
for (key, val) in conf.items():
self.__conf[key] = val
return self | [
"def",
"custom_conf",
"(",
"self",
",",
"conf",
")",
":",
"if",
"conf",
":",
"for",
"(",
"key",
",",
"val",
")",
"in",
"conf",
".",
"items",
"(",
")",
":",
"self",
".",
"__conf",
"[",
"key",
"]",
"=",
"val",
"return",
"self"
] | custom apikey and http parameters | [
"custom",
"apikey",
"and",
"http",
"parameters"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L59-L64 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | _YunpianConf.conf | def conf(self, key):
'''get config'''
return self.__conf[key] if key in self.__conf else _YunpianConf.YP_CONF.get(key) | python | def conf(self, key):
'''get config'''
return self.__conf[key] if key in self.__conf else _YunpianConf.YP_CONF.get(key) | [
"def",
"conf",
"(",
"self",
",",
"key",
")",
":",
"return",
"self",
".",
"__conf",
"[",
"key",
"]",
"if",
"key",
"in",
"self",
".",
"__conf",
"else",
"_YunpianConf",
".",
"YP_CONF",
".",
"get",
"(",
"key",
")"
] | get config | [
"get",
"config"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L73-L75 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | _ApiFactory.api | def api(self, name):
'''return special API by package's name'''
assert name, 'name is none'
if flow.__name__ == name:
api = flow.FlowApi()
elif sign.__name__ == name:
api = sign.SignApi()
elif sms.__name__ == name:
api = sms.SmsApi()
e... | python | def api(self, name):
'''return special API by package's name'''
assert name, 'name is none'
if flow.__name__ == name:
api = flow.FlowApi()
elif sign.__name__ == name:
api = sign.SignApi()
elif sms.__name__ == name:
api = sms.SmsApi()
e... | [
"def",
"api",
"(",
"self",
",",
"name",
")",
":",
"assert",
"name",
",",
"'name is none'",
"if",
"flow",
".",
"__name__",
"==",
"name",
":",
"api",
"=",
"flow",
".",
"FlowApi",
"(",
")",
"elif",
"sign",
".",
"__name__",
"==",
"name",
":",
"api",
"=... | return special API by package's name | [
"return",
"special",
"API",
"by",
"package",
"s",
"name"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L85-L105 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | YunpianClient.conf | def conf(self, key=None, defval=None):
'''return YunpianConf if key=None, else return value in YunpianConf'''
if key is None:
return self._ypconf
val = self._ypconf.conf(key)
return defval if val is None else val | python | def conf(self, key=None, defval=None):
'''return YunpianConf if key=None, else return value in YunpianConf'''
if key is None:
return self._ypconf
val = self._ypconf.conf(key)
return defval if val is None else val | [
"def",
"conf",
"(",
"self",
",",
"key",
"=",
"None",
",",
"defval",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"self",
".",
"_ypconf",
"val",
"=",
"self",
".",
"_ypconf",
".",
"conf",
"(",
"key",
")",
"return",
"defval",
"if... | return YunpianConf if key=None, else return value in YunpianConf | [
"return",
"YunpianConf",
"if",
"key",
"=",
"None",
"else",
"return",
"value",
"in",
"YunpianConf"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L175-L180 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | YunpianClient.post | def post(self, url, data, charset=CHARSET_UTF8, headers={}):
'''response json text'''
if 'Api-Lang' not in headers:
headers['Api-Lang'] = 'python'
if 'Content-Type' not in headers:
headers['Content-Type'] = "application/x-www-form-urlencoded;charset=" + charset
rs... | python | def post(self, url, data, charset=CHARSET_UTF8, headers={}):
'''response json text'''
if 'Api-Lang' not in headers:
headers['Api-Lang'] = 'python'
if 'Content-Type' not in headers:
headers['Content-Type'] = "application/x-www-form-urlencoded;charset=" + charset
rs... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
",",
"charset",
"=",
"CHARSET_UTF8",
",",
"headers",
"=",
"{",
"}",
")",
":",
"if",
"'Api-Lang'",
"not",
"in",
"headers",
":",
"headers",
"[",
"'Api-Lang'",
"]",
"=",
"'python'",
"if",
"'Content-Type... | response json text | [
"response",
"json",
"text"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L185-L193 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | YunpianClient.urlEncodeAndJoin | def urlEncodeAndJoin(self, seq, sepr=','):
'''sepr.join(urlencode(seq))
Args:
seq: string list to be urlencoded
sepr: join seq with sepr
Returns:
str
'''
try:
from urllib.parse import quote_plus as encode
return sepr.joi... | python | def urlEncodeAndJoin(self, seq, sepr=','):
'''sepr.join(urlencode(seq))
Args:
seq: string list to be urlencoded
sepr: join seq with sepr
Returns:
str
'''
try:
from urllib.parse import quote_plus as encode
return sepr.joi... | [
"def",
"urlEncodeAndJoin",
"(",
"self",
",",
"seq",
",",
"sepr",
"=",
"','",
")",
":",
"try",
":",
"from",
"urllib",
".",
"parse",
"import",
"quote_plus",
"as",
"encode",
"return",
"sepr",
".",
"join",
"(",
"[",
"encode",
"(",
"x",
",",
"encoding",
"... | sepr.join(urlencode(seq))
Args:
seq: string list to be urlencoded
sepr: join seq with sepr
Returns:
str | [
"sepr",
".",
"join",
"(",
"urlencode",
"(",
"seq",
"))",
"Args",
":",
"seq",
":",
"string",
"list",
"to",
"be",
"urlencoded",
"sepr",
":",
"join",
"seq",
"with",
"sepr",
"Returns",
":",
"str"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L195-L208 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/voice.py | VoiceApi.send | def send(self, param, must=[APIKEY, MOBILE, CODE]):
'''发语音验证码
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号、固话(需加区号) 15205201314 01088880000
code String 是 验证码,支持4~6位阿拉伯数字 1234
encrypt String 否 加密方式 使用加密 tea (不再使用)
... | python | def send(self, param, must=[APIKEY, MOBILE, CODE]):
'''发语音验证码
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号、固话(需加区号) 15205201314 01088880000
code String 是 验证码,支持4~6位阿拉伯数字 1234
encrypt String 否 加密方式 使用加密 tea (不再使用)
... | [
"def",
"send",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"MOBILE",
",",
"CODE",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
")",
":",
"retur... | 发语音验证码
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号、固话(需加区号) 15205201314 01088880000
code String 是 验证码,支持4~6位阿拉伯数字 1234
encrypt String 否 加密方式 使用加密 tea (不再使用)
_sign String 否 签名字段 参考使用加密 393d079e0a00912335adfe46f4a2e10f (... | [
"发语音验证码"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/voice.py#L20-L42 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.single_send | def single_send(self, param, must=[APIKEY, MOBILE, TEXT]):
'''单条发送
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号;仅支持单号码发送;国际号码需包含国际地区前缀号码,格式必须是"+"号开头("+"号需要urlencode处理,否则会出现格式错误),国际号码不以"+"开头将被认为是中国地区的号码
(针对国际短信,m... | python | def single_send(self, param, must=[APIKEY, MOBILE, TEXT]):
'''单条发送
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号;仅支持单号码发送;国际号码需包含国际地区前缀号码,格式必须是"+"号开头("+"号需要urlencode处理,否则会出现格式错误),国际号码不以"+"开头将被认为是中国地区的号码
(针对国际短信,m... | [
"def",
"single_send",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"MOBILE",
",",
"TEXT",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
")",
":",
... | 单条发送
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号;仅支持单号码发送;国际号码需包含国际地区前缀号码,格式必须是"+"号开头("+"号需要urlencode处理,否则会出现格式错误),国际号码不以"+"开头将被认为是中国地区的号码
(针对国际短信,mobile参数会自动格式化到E.164格式,可能会造成传入mobile参数跟后续的状态报告中的号码不一致。E.164格式说明,参见:
... | [
"单条发送",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"mobile",
"String",
"是",
"接收的手机号;仅支持单号码发送;国际号码需包含国际地区前缀号码,格式必须是",
"+",
"号开头",
"(",
"+",
"号需要urlencode处理,否则会出现格式错误",
")",
",国际号码不以",
"+",
"开头将被认为是中国地区的号码",
"... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L50-L77 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.pull_reply | def pull_reply(self, param=None, must=[APIKEY]):
'''获取回复短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size Integer 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result
'''
param =... | python | def pull_reply(self, param=None, must=[APIKEY]):
'''获取回复短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size Integer 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result
'''
param =... | [
"def",
"pull_reply",
"(",
"self",
",",
"param",
"=",
"None",
",",
"must",
"=",
"[",
"APIKEY",
"]",
")",
":",
"param",
"=",
"{",
"}",
"if",
"param",
"is",
"None",
"else",
"param",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
"... | 获取回复短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size Integer 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result | [
"获取回复短信",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"page_size",
"Integer",
"否",
"每页个数,最大100个,默认20个",
"20",
"Args",
":",
"param",
":",
"Results",
":",
"Result"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L157-L174 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.get_reply | def get_reply(self, param, must=[APIKEY, START_TIME, END_TIME, PAGE_NUM, PAGE_SIZE]):
'''查回复的短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信回复开始时间 2013-08-11 00:00:00
end_time String 是 短信回复结束时间 2013-08-12 00:00:00
... | python | def get_reply(self, param, must=[APIKEY, START_TIME, END_TIME, PAGE_NUM, PAGE_SIZE]):
'''查回复的短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信回复开始时间 2013-08-11 00:00:00
end_time String 是 短信回复结束时间 2013-08-12 00:00:00
... | [
"def",
"get_reply",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"START_TIME",
",",
"END_TIME",
",",
"PAGE_NUM",
",",
"PAGE_SIZE",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
... | 查回复的短信
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信回复开始时间 2013-08-11 00:00:00
end_time String 是 短信回复结束时间 2013-08-12 00:00:00
page_num Integer 是 页码,默认值为1 1
page_size Integer 是 每页个数,最大100个 20
mobile String... | [
"查回复的短信",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"start_time",
"String",
"是",
"短信回复开始时间",
"2013",
"-",
"08",
"-",
"11",
"00",
":",
"00",
":",
"00",
"end_time",
"String",
"是",
"短信回复结束时间",
"2013"... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L177-L199 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.get_record | def get_record(self, param, must=[APIKEY, START_TIME, END_TIME]):
'''查短信发送记录
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 否 需要查询的手机号 15205201314
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间... | python | def get_record(self, param, must=[APIKEY, START_TIME, END_TIME]):
'''查短信发送记录
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 否 需要查询的手机号 15205201314
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间... | [
"def",
"get_record",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"START_TIME",
",",
"END_TIME",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
")",
... | 查短信发送记录
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 否 需要查询的手机号 15205201314
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间 2013-08-12 00:00:00
page_num Integer 否 页码,默认值为1 1
page_size ... | [
"查短信发送记录",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"mobile",
"String",
"否",
"需要查询的手机号",
"15205201314",
"start_time",
"String",
"是",
"短信发送开始时间",
"2013",
"-",
"08",
"-",
"11",
"00",
":",
"00",
":",
... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L220-L240 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.count | def count(self, param, must=[APIKEY, START_TIME, END_TIME]):
'''统计短信条数
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间 2013-08-12 00:00:00
mobile String 否 需要查询的手... | python | def count(self, param, must=[APIKEY, START_TIME, END_TIME]):
'''统计短信条数
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间 2013-08-12 00:00:00
mobile String 否 需要查询的手... | [
"def",
"count",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"START_TIME",
",",
"END_TIME",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
")",
":",... | 统计短信条数
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
start_time String 是 短信发送开始时间 2013-08-11 00:00:00
end_time String 是 短信发送结束时间 2013-08-12 00:00:00
mobile String 否 需要查询的手机号 15205201314
page_num Integer 否 页码,默认值为1 1
page_size I... | [
"统计短信条数",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"start_time",
"String",
"是",
"短信发送开始时间",
"2013",
"-",
"08",
"-",
"11",
"00",
":",
"00",
":",
"00",
"end_time",
"String",
"是",
"短信发送结束时间",
"2013"... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L242-L262 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.tpl_send | def tpl_send(self, param, must=[APIKEY, MOBILE, TPL_ID, TPL_VALUE]):
'''指定模板发送 only v1 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号 15205201314
tpl_id Long 是 模板id 1
tpl_value String 是 变量名和变量值对。请先对您的变量... | python | def tpl_send(self, param, must=[APIKEY, MOBILE, TPL_ID, TPL_VALUE]):
'''指定模板发送 only v1 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号 15205201314
tpl_id Long 是 模板id 1
tpl_value String 是 变量名和变量值对。请先对您的变量... | [
"def",
"tpl_send",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"MOBILE",
",",
"TPL_ID",
",",
"TPL_VALUE",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
... | 指定模板发送 only v1 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号 15205201314
tpl_id Long 是 模板id 1
tpl_value String 是 变量名和变量值对。请先对您的变量名和变量值分别进行urlencode再传递。使用参考:代码示例。
注:变量名和变量值都不能为空 模板: 【#company#】您的验证码是#co... | [
"指定模板发送",
"only",
"v1",
"deprecated",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"mobile",
"String",
"是",
"接收的手机号",
"15205201314",
"tpl_id",
"Long",
"是",
"模板id",
"1",
"tpl_value",
"String",
"是",
"变量名和变... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L264-L289 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/sms.py | SmsApi.tpl_single_send | def tpl_single_send(self, param, must=[APIKEY, MOBILE, TPL_ID, TPL_VALUE]):
'''指定模板单发 only v2 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号(针对国际短信,mobile参数会自动格式化到E.164格式,可能会造成传入mobile参数跟后续的状态报告中的号码不一致。E.164格式说明,参见:
... | python | def tpl_single_send(self, param, must=[APIKEY, MOBILE, TPL_ID, TPL_VALUE]):
'''指定模板单发 only v2 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号(针对国际短信,mobile参数会自动格式化到E.164格式,可能会造成传入mobile参数跟后续的状态报告中的号码不一致。E.164格式说明,参见:
... | [
"def",
"tpl_single_send",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"MOBILE",
",",
"TPL_ID",
",",
"TPL_VALUE",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_s... | 指定模板单发 only v2 deprecated
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是
接收的手机号(针对国际短信,mobile参数会自动格式化到E.164格式,可能会造成传入mobile参数跟后续的状态报告中的号码不一致。E.164格式说明,参见:
https://en.wikipedia.org/wiki/E.164) 15205201314
tpl_id Long 是 模板id 1
... | [
"指定模板单发",
"only",
"v2",
"deprecated"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/sms.py#L291-L318 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/flow.py | FlowApi.get_package | def get_package(self, param=None, must=[APIKEY]):
'''查询流量包
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
carrier String 否 运营商ID 传入该参数则获取指定运营商的流量包, 否则获取所有运营商的流量包 移动:10086 联通:10010 电信:10000
Args:
param:
Results:
... | python | def get_package(self, param=None, must=[APIKEY]):
'''查询流量包
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
carrier String 否 运营商ID 传入该参数则获取指定运营商的流量包, 否则获取所有运营商的流量包 移动:10086 联通:10010 电信:10000
Args:
param:
Results:
... | [
"def",
"get_package",
"(",
"self",
",",
"param",
"=",
"None",
",",
"must",
"=",
"[",
"APIKEY",
"]",
")",
":",
"param",
"=",
"{",
"}",
"if",
"param",
"is",
"None",
"else",
"param",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
... | 查询流量包
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
carrier String 否 运营商ID 传入该参数则获取指定运营商的流量包, 否则获取所有运营商的流量包 移动:10086 联通:10010 电信:10000
Args:
param:
Results:
Result | [
"查询流量包",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"carrier",
"String",
"否",
"运营商ID",
"传入该参数则获取指定运营商的流量包,",
"否则获取所有运营商的流量包",
"移动:10086",
"联通:10010",
"电信:10000",
"Args",
":",
"param",
":",
"Results",
":",
... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/flow.py#L19-L36 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/flow.py | FlowApi.recharge | def recharge(self, param, must=[APIKEY, MOBILE, SN]):
'''充值流量
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号(仅支持大陆号码) 15205201314
sn String 是 流量包的唯一ID 点击查看 1008601
callback_url String 否 本条流量充值的状态报告推送地址 http://your... | python | def recharge(self, param, must=[APIKEY, MOBILE, SN]):
'''充值流量
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号(仅支持大陆号码) 15205201314
sn String 是 流量包的唯一ID 点击查看 1008601
callback_url String 否 本条流量充值的状态报告推送地址 http://your... | [
"def",
"recharge",
"(",
"self",
",",
"param",
",",
"must",
"=",
"[",
"APIKEY",
",",
"MOBILE",
",",
"SN",
"]",
")",
":",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
")",
"if",
"not",
"r",
".",
"is_succ",
"(",
")",
":",
"ret... | 充值流量
参数名 类型 是否必须 描述 示例
apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
mobile String 是 接收的手机号(仅支持大陆号码) 15205201314
sn String 是 流量包的唯一ID 点击查看 1008601
callback_url String 否 本条流量充值的状态报告推送地址 http://your_receive_url_address
encrypt String 否 加密方式 使用加密 tea (不再使用... | [
"充值流量",
"参数名",
"类型",
"是否必须",
"描述",
"示例",
"apikey",
"String",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"mobile",
"String",
"是",
"接收的手机号(仅支持大陆号码)",
"15205201314",
"sn",
"String",
"是",
"流量包的唯一ID",
"点击查看",
"1008601",
"callback_url",
"String",
"否",
"本条流量充值的状态报告... | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/flow.py#L38-L58 | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/api/flow.py | FlowApi.pull_status | def pull_status(self, param=None, must=[APIKEY]):
'''获取状态报告
参数名 是否必须 描述 示例
apikey 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result
'''
param = {} if param is N... | python | def pull_status(self, param=None, must=[APIKEY]):
'''获取状态报告
参数名 是否必须 描述 示例
apikey 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result
'''
param = {} if param is N... | [
"def",
"pull_status",
"(",
"self",
",",
"param",
"=",
"None",
",",
"must",
"=",
"[",
"APIKEY",
"]",
")",
":",
"param",
"=",
"{",
"}",
"if",
"param",
"is",
"None",
"else",
"param",
"r",
"=",
"self",
".",
"verify_param",
"(",
"param",
",",
"must",
... | 获取状态报告
参数名 是否必须 描述 示例
apikey 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
page_size 否 每页个数,最大100个,默认20个 20
Args:
param:
Results:
Result | [
"获取状态报告",
"参数名",
"是否必须",
"描述",
"示例",
"apikey",
"是",
"用户唯一标识",
"9b11127a9701975c734b8aee81ee3526",
"page_size",
"否",
"每页个数,最大100个,默认20个",
"20",
"Args",
":",
"param",
":",
"Results",
":",
"Result"
] | 405a1196ec83fdf29ff454f74ef036974be11970 | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/api/flow.py#L60-L77 | train |
doconix/django-mako-plus | django_mako_plus/command.py | run_command | def run_command(*args, raise_exception=True, cwd=None):
'''
Runs a command, piping all output to the DMP log.
The args should be separate arguments so paths and subcommands can have spaces in them:
ret = run_command('ls', '-l', '/Users/me/My Documents')
print(ret.code)
print(ret.std... | python | def run_command(*args, raise_exception=True, cwd=None):
'''
Runs a command, piping all output to the DMP log.
The args should be separate arguments so paths and subcommands can have spaces in them:
ret = run_command('ls', '-l', '/Users/me/My Documents')
print(ret.code)
print(ret.std... | [
"def",
"run_command",
"(",
"*",
"args",
",",
"raise_exception",
"=",
"True",
",",
"cwd",
"=",
"None",
")",
":",
"args",
"=",
"[",
"str",
"(",
"a",
")",
"for",
"a",
"in",
"args",
"]",
"log",
".",
"info",
"(",
"'running %s'",
",",
"' '",
".",
"join... | Runs a command, piping all output to the DMP log.
The args should be separate arguments so paths and subcommands can have spaces in them:
ret = run_command('ls', '-l', '/Users/me/My Documents')
print(ret.code)
print(ret.stdout)
print(ret.stderr)
On Windows, the PATH is not foll... | [
"Runs",
"a",
"command",
"piping",
"all",
"output",
"to",
"the",
"DMP",
"log",
".",
"The",
"args",
"should",
"be",
"separate",
"arguments",
"so",
"paths",
"and",
"subcommands",
"can",
"have",
"spaces",
"in",
"them",
":"
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/command.py#L13-L37 | train |
doconix/django-mako-plus | django_mako_plus/template/loader.py | MakoTemplateLoader.get_template | def get_template(self, template, def_name=None):
'''Retrieve a *Django* API template object for the given template name, using the app_path and template_subdir
settings in this object. This method still uses the corresponding Mako template and engine, but it
gives a Django API wrapper aro... | python | def get_template(self, template, def_name=None):
'''Retrieve a *Django* API template object for the given template name, using the app_path and template_subdir
settings in this object. This method still uses the corresponding Mako template and engine, but it
gives a Django API wrapper aro... | [
"def",
"get_template",
"(",
"self",
",",
"template",
",",
"def_name",
"=",
"None",
")",
":",
"try",
":",
"# wrap the mako template in an adapter that gives the Django template API",
"return",
"MakoTemplateAdapter",
"(",
"self",
".",
"get_mako_template",
"(",
"template",
... | Retrieve a *Django* API template object for the given template name, using the app_path and template_subdir
settings in this object. This method still uses the corresponding Mako template and engine, but it
gives a Django API wrapper around it so you can use it the same as any Django template.
... | [
"Retrieve",
"a",
"*",
"Django",
"*",
"API",
"template",
"object",
"for",
"the",
"given",
"template",
"name",
"using",
"the",
"app_path",
"and",
"template_subdir",
"settings",
"in",
"this",
"object",
".",
"This",
"method",
"still",
"uses",
"the",
"corresponding... | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/loader.py#L71-L95 | train |
doconix/django-mako-plus | django_mako_plus/template/loader.py | MakoTemplateLoader.get_mako_template | def get_mako_template(self, template, force=False):
'''Retrieve the real *Mako* template object for the given template name without any wrapper,
using the app_path and template_subdir settings in this object.
This method is an alternative to get_template(). Use it when you need the actua... | python | def get_mako_template(self, template, force=False):
'''Retrieve the real *Mako* template object for the given template name without any wrapper,
using the app_path and template_subdir settings in this object.
This method is an alternative to get_template(). Use it when you need the actua... | [
"def",
"get_mako_template",
"(",
"self",
",",
"template",
",",
"force",
"=",
"False",
")",
":",
"if",
"template",
"is",
"None",
":",
"raise",
"TemplateLookupException",
"(",
"'Template \"%s\" not found in search path: %s.'",
"%",
"(",
"template",
",",
"self",
".",... | Retrieve the real *Mako* template object for the given template name without any wrapper,
using the app_path and template_subdir settings in this object.
This method is an alternative to get_template(). Use it when you need the actual Mako template object.
This method raises a Mako ex... | [
"Retrieve",
"the",
"real",
"*",
"Mako",
"*",
"template",
"object",
"for",
"the",
"given",
"template",
"name",
"without",
"any",
"wrapper",
"using",
"the",
"app_path",
"and",
"template_subdir",
"settings",
"in",
"this",
"object",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/loader.py#L98-L119 | train |
doconix/django-mako-plus | django_mako_plus/router/resolver.py | app_resolver | def app_resolver(app_name=None, pattern_kwargs=None, name=None):
'''
Registers the given app_name with DMP and adds convention-based
url patterns for it.
This function is meant to be called in a project's urls.py.
'''
urlconf = URLConf(app_name, pattern_kwargs)
resolver = re_path(
'... | python | def app_resolver(app_name=None, pattern_kwargs=None, name=None):
'''
Registers the given app_name with DMP and adds convention-based
url patterns for it.
This function is meant to be called in a project's urls.py.
'''
urlconf = URLConf(app_name, pattern_kwargs)
resolver = re_path(
'... | [
"def",
"app_resolver",
"(",
"app_name",
"=",
"None",
",",
"pattern_kwargs",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"urlconf",
"=",
"URLConf",
"(",
"app_name",
",",
"pattern_kwargs",
")",
"resolver",
"=",
"re_path",
"(",
"'^{}/?'",
".",
"format",
... | Registers the given app_name with DMP and adds convention-based
url patterns for it.
This function is meant to be called in a project's urls.py. | [
"Registers",
"the",
"given",
"app_name",
"with",
"DMP",
"and",
"adds",
"convention",
"-",
"based",
"url",
"patterns",
"for",
"it",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/resolver.py#L30-L46 | train |
doconix/django-mako-plus | django_mako_plus/router/resolver.py | dmp_paths_for_app | def dmp_paths_for_app(app_name, pattern_kwargs=None, pretty_app_name=None):
'''Utility function that creates the default patterns for an app'''
dmp = apps.get_app_config('django_mako_plus')
# Because these patterns are subpatterns within the app's resolver,
# we don't include the /app/ in the pattern --... | python | def dmp_paths_for_app(app_name, pattern_kwargs=None, pretty_app_name=None):
'''Utility function that creates the default patterns for an app'''
dmp = apps.get_app_config('django_mako_plus')
# Because these patterns are subpatterns within the app's resolver,
# we don't include the /app/ in the pattern --... | [
"def",
"dmp_paths_for_app",
"(",
"app_name",
",",
"pattern_kwargs",
"=",
"None",
",",
"pretty_app_name",
"=",
"None",
")",
":",
"dmp",
"=",
"apps",
".",
"get_app_config",
"(",
"'django_mako_plus'",
")",
"# Because these patterns are subpatterns within the app's resolver,"... | Utility function that creates the default patterns for an app | [
"Utility",
"function",
"that",
"creates",
"the",
"default",
"patterns",
"for",
"an",
"app"
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/resolver.py#L65-L131 | train |
doconix/django-mako-plus | django_mako_plus/router/resolver.py | dmp_path | def dmp_path(regex, kwargs=None, name=None, app_name=None):
'''
Creates a DMP-style, convention-based pattern that resolves
to various view functions based on the 'dmp_page' value.
The following should exist as 1) regex named groups or
2) items in the kwargs dict:
dmp_app Should res... | python | def dmp_path(regex, kwargs=None, name=None, app_name=None):
'''
Creates a DMP-style, convention-based pattern that resolves
to various view functions based on the 'dmp_page' value.
The following should exist as 1) regex named groups or
2) items in the kwargs dict:
dmp_app Should res... | [
"def",
"dmp_path",
"(",
"regex",
",",
"kwargs",
"=",
"None",
",",
"name",
"=",
"None",
",",
"app_name",
"=",
"None",
")",
":",
"return",
"PagePattern",
"(",
"regex",
",",
"kwargs",
",",
"name",
",",
"app_name",
")"
] | Creates a DMP-style, convention-based pattern that resolves
to various view functions based on the 'dmp_page' value.
The following should exist as 1) regex named groups or
2) items in the kwargs dict:
dmp_app Should resolve to a name in INSTALLED_APPS.
If missing, de... | [
"Creates",
"a",
"DMP",
"-",
"style",
"convention",
"-",
"based",
"pattern",
"that",
"resolves",
"to",
"various",
"view",
"functions",
"based",
"on",
"the",
"dmp_page",
"value",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/resolver.py#L140-L160 | train |
doconix/django-mako-plus | django_mako_plus/router/resolver.py | PagePattern.resolve | def resolve(self, path):
'''
Different from Django, this method matches by /app/page/ convention
using its pattern. The pattern should create keyword arguments for
dmp_app, dmp_page.
'''
match = super().resolve(path)
if match:
try:
rou... | python | def resolve(self, path):
'''
Different from Django, this method matches by /app/page/ convention
using its pattern. The pattern should create keyword arguments for
dmp_app, dmp_page.
'''
match = super().resolve(path)
if match:
try:
rou... | [
"def",
"resolve",
"(",
"self",
",",
"path",
")",
":",
"match",
"=",
"super",
"(",
")",
".",
"resolve",
"(",
"path",
")",
"if",
"match",
":",
"try",
":",
"routing_data",
"=",
"RoutingData",
"(",
"match",
".",
"kwargs",
".",
"pop",
"(",
"'dmp_app'",
... | Different from Django, this method matches by /app/page/ convention
using its pattern. The pattern should create keyword arguments for
dmp_app, dmp_page. | [
"Different",
"from",
"Django",
"this",
"method",
"matches",
"by",
"/",
"app",
"/",
"page",
"/",
"convention",
"using",
"its",
"pattern",
".",
"The",
"pattern",
"should",
"create",
"keyword",
"arguments",
"for",
"dmp_app",
"dmp_page",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/resolver.py#L183-L227 | train |
doconix/django-mako-plus | django_mako_plus/filters.py | alternate_syntax | def alternate_syntax(local, using, **kwargs):
'''
A Mako filter that renders a block of text using a different template engine
than Mako. The named template engine must be listed in settings.TEMPLATES.
The template context variables are available in the embedded template.
Specify kwargs to add add... | python | def alternate_syntax(local, using, **kwargs):
'''
A Mako filter that renders a block of text using a different template engine
than Mako. The named template engine must be listed in settings.TEMPLATES.
The template context variables are available in the embedded template.
Specify kwargs to add add... | [
"def",
"alternate_syntax",
"(",
"local",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"# get the request (the MakoTemplateAdapter above places this in the context)",
"request",
"=",
"local",
".",
"context",
"[",
"'request'",
"]",
"if",
"isinstance",
"(",
"local",
... | A Mako filter that renders a block of text using a different template engine
than Mako. The named template engine must be listed in settings.TEMPLATES.
The template context variables are available in the embedded template.
Specify kwargs to add additional variables created within the template.
This i... | [
"A",
"Mako",
"filter",
"that",
"renders",
"a",
"block",
"of",
"text",
"using",
"a",
"different",
"template",
"engine",
"than",
"Mako",
".",
"The",
"named",
"template",
"engine",
"must",
"be",
"listed",
"in",
"settings",
".",
"TEMPLATES",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/filters.py#L64-L124 | train |
doconix/django-mako-plus | django_mako_plus/router/discover.py | get_view_function | def get_view_function(module_name, function_name, fallback_app=None, fallback_template=None, verify_decorator=True):
'''
Retrieves a view function from the cache, finding it if the first time.
Raises ViewDoesNotExist if not found. This is called by resolver.py.
'''
# first check the cache (without ... | python | def get_view_function(module_name, function_name, fallback_app=None, fallback_template=None, verify_decorator=True):
'''
Retrieves a view function from the cache, finding it if the first time.
Raises ViewDoesNotExist if not found. This is called by resolver.py.
'''
# first check the cache (without ... | [
"def",
"get_view_function",
"(",
"module_name",
",",
"function_name",
",",
"fallback_app",
"=",
"None",
",",
"fallback_template",
"=",
"None",
",",
"verify_decorator",
"=",
"True",
")",
":",
"# first check the cache (without doing locks)",
"key",
"=",
"(",
"module_nam... | Retrieves a view function from the cache, finding it if the first time.
Raises ViewDoesNotExist if not found. This is called by resolver.py. | [
"Retrieves",
"a",
"view",
"function",
"from",
"the",
"cache",
"finding",
"it",
"if",
"the",
"first",
"time",
".",
"Raises",
"ViewDoesNotExist",
"if",
"not",
"found",
".",
"This",
"is",
"called",
"by",
"resolver",
".",
"py",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/discover.py#L24-L47 | train |
doconix/django-mako-plus | django_mako_plus/router/discover.py | find_view_function | def find_view_function(module_name, function_name, fallback_app=None, fallback_template=None, verify_decorator=True):
'''
Finds a view function, class-based view, or template view.
Raises ViewDoesNotExist if not found.
'''
dmp = apps.get_app_config('django_mako_plus')
# I'm first calling find_s... | python | def find_view_function(module_name, function_name, fallback_app=None, fallback_template=None, verify_decorator=True):
'''
Finds a view function, class-based view, or template view.
Raises ViewDoesNotExist if not found.
'''
dmp = apps.get_app_config('django_mako_plus')
# I'm first calling find_s... | [
"def",
"find_view_function",
"(",
"module_name",
",",
"function_name",
",",
"fallback_app",
"=",
"None",
",",
"fallback_template",
"=",
"None",
",",
"verify_decorator",
"=",
"True",
")",
":",
"dmp",
"=",
"apps",
".",
"get_app_config",
"(",
"'django_mako_plus'",
... | Finds a view function, class-based view, or template view.
Raises ViewDoesNotExist if not found. | [
"Finds",
"a",
"view",
"function",
"class",
"-",
"based",
"view",
"or",
"template",
"view",
".",
"Raises",
"ViewDoesNotExist",
"if",
"not",
"found",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/discover.py#L50-L99 | train |
doconix/django-mako-plus | django_mako_plus/router/discover.py | create_view_for_template | def create_view_for_template(app_name, template_name):
'''
Creates a view function for templates (used whe a view.py file doesn't exist but the .html does)
Raises TemplateDoesNotExist if the template doesn't exist.
'''
# ensure the template exists
apps.get_app_config('django_mako_plus').engine.g... | python | def create_view_for_template(app_name, template_name):
'''
Creates a view function for templates (used whe a view.py file doesn't exist but the .html does)
Raises TemplateDoesNotExist if the template doesn't exist.
'''
# ensure the template exists
apps.get_app_config('django_mako_plus').engine.g... | [
"def",
"create_view_for_template",
"(",
"app_name",
",",
"template_name",
")",
":",
"# ensure the template exists",
"apps",
".",
"get_app_config",
"(",
"'django_mako_plus'",
")",
".",
"engine",
".",
"get_template_loader",
"(",
"app_name",
")",
".",
"get_template",
"("... | Creates a view function for templates (used whe a view.py file doesn't exist but the .html does)
Raises TemplateDoesNotExist if the template doesn't exist. | [
"Creates",
"a",
"view",
"function",
"for",
"templates",
"(",
"used",
"whe",
"a",
"view",
".",
"py",
"file",
"doesn",
"t",
"exist",
"but",
"the",
".",
"html",
"does",
")",
"Raises",
"TemplateDoesNotExist",
"if",
"the",
"template",
"doesn",
"t",
"exist",
"... | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/discover.py#L102-L116 | train |
doconix/django-mako-plus | django_mako_plus/provider/base.py | BaseProvider.iter_related | def iter_related(self):
'''
Generator function that iterates this object's related providers,
which includes this provider.
'''
for tpl in self.provider_run.templates:
yield tpl.providers[self.index] | python | def iter_related(self):
'''
Generator function that iterates this object's related providers,
which includes this provider.
'''
for tpl in self.provider_run.templates:
yield tpl.providers[self.index] | [
"def",
"iter_related",
"(",
"self",
")",
":",
"for",
"tpl",
"in",
"self",
".",
"provider_run",
".",
"templates",
":",
"yield",
"tpl",
".",
"providers",
"[",
"self",
".",
"index",
"]"
] | Generator function that iterates this object's related providers,
which includes this provider. | [
"Generator",
"function",
"that",
"iterates",
"this",
"object",
"s",
"related",
"providers",
"which",
"includes",
"this",
"provider",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/base.py#L94-L100 | train |
doconix/django-mako-plus | django_mako_plus/provider/base.py | BaseProvider.get_cache_item | def get_cache_item(self):
'''Gets the cached item. Raises AttributeError if it hasn't been set.'''
if settings.DEBUG:
raise AttributeError('Caching disabled in DEBUG mode')
return getattr(self.template, self.options['template_cache_key']) | python | def get_cache_item(self):
'''Gets the cached item. Raises AttributeError if it hasn't been set.'''
if settings.DEBUG:
raise AttributeError('Caching disabled in DEBUG mode')
return getattr(self.template, self.options['template_cache_key']) | [
"def",
"get_cache_item",
"(",
"self",
")",
":",
"if",
"settings",
".",
"DEBUG",
":",
"raise",
"AttributeError",
"(",
"'Caching disabled in DEBUG mode'",
")",
"return",
"getattr",
"(",
"self",
".",
"template",
",",
"self",
".",
"options",
"[",
"'template_cache_ke... | Gets the cached item. Raises AttributeError if it hasn't been set. | [
"Gets",
"the",
"cached",
"item",
".",
"Raises",
"AttributeError",
"if",
"it",
"hasn",
"t",
"been",
"set",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/base.py#L149-L153 | train |
doconix/django-mako-plus | django_mako_plus/util/datastruct.py | flatten | def flatten(*args):
'''Generator that recursively flattens embedded lists, tuples, etc.'''
for arg in args:
if isinstance(arg, collections.Iterable) and not isinstance(arg, (str, bytes)):
yield from flatten(*arg)
else:
yield arg | python | def flatten(*args):
'''Generator that recursively flattens embedded lists, tuples, etc.'''
for arg in args:
if isinstance(arg, collections.Iterable) and not isinstance(arg, (str, bytes)):
yield from flatten(*arg)
else:
yield arg | [
"def",
"flatten",
"(",
"*",
"args",
")",
":",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"collections",
".",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"arg",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"yield",
... | Generator that recursively flattens embedded lists, tuples, etc. | [
"Generator",
"that",
"recursively",
"flattens",
"embedded",
"lists",
"tuples",
"etc",
"."
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/util/datastruct.py#L18-L24 | train |
doconix/django-mako-plus | django_mako_plus/util/datastruct.py | crc32 | def crc32(filename):
'''
Calculates the CRC checksum for a file.
Using CRC32 because security isn't the issue and don't need perfect noncollisions.
We just need to know if a file has changed.
On my machine, crc32 was 20 times faster than any hashlib algorithm,
including blake and md5 algorithms... | python | def crc32(filename):
'''
Calculates the CRC checksum for a file.
Using CRC32 because security isn't the issue and don't need perfect noncollisions.
We just need to know if a file has changed.
On my machine, crc32 was 20 times faster than any hashlib algorithm,
including blake and md5 algorithms... | [
"def",
"crc32",
"(",
"filename",
")",
":",
"result",
"=",
"0",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fin",
":",
"while",
"True",
":",
"chunk",
"=",
"fin",
".",
"read",
"(",
"48",
")",
"if",
"len",
"(",
"chunk",
")",
"==",
"0... | Calculates the CRC checksum for a file.
Using CRC32 because security isn't the issue and don't need perfect noncollisions.
We just need to know if a file has changed.
On my machine, crc32 was 20 times faster than any hashlib algorithm,
including blake and md5 algorithms. | [
"Calculates",
"the",
"CRC",
"checksum",
"for",
"a",
"file",
".",
"Using",
"CRC32",
"because",
"security",
"isn",
"t",
"the",
"issue",
"and",
"don",
"t",
"need",
"perfect",
"noncollisions",
".",
"We",
"just",
"need",
"to",
"know",
"if",
"a",
"file",
"has"... | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/util/datastruct.py#L28-L44 | train |
doconix/django-mako-plus | django_mako_plus/management/commands/dmp_makemessages.py | Command.compile_mako_files | def compile_mako_files(self, app_config):
'''Compiles the Mako templates within the apps of this system'''
# go through the files in the templates, scripts, and styles directories
for subdir_name in self.SEARCH_DIRS:
subdir = subdir_name.format(
app_path=app_config.pa... | python | def compile_mako_files(self, app_config):
'''Compiles the Mako templates within the apps of this system'''
# go through the files in the templates, scripts, and styles directories
for subdir_name in self.SEARCH_DIRS:
subdir = subdir_name.format(
app_path=app_config.pa... | [
"def",
"compile_mako_files",
"(",
"self",
",",
"app_config",
")",
":",
"# go through the files in the templates, scripts, and styles directories",
"for",
"subdir_name",
"in",
"self",
".",
"SEARCH_DIRS",
":",
"subdir",
"=",
"subdir_name",
".",
"format",
"(",
"app_path",
... | Compiles the Mako templates within the apps of this system | [
"Compiles",
"the",
"Mako",
"templates",
"within",
"the",
"apps",
"of",
"this",
"system"
] | a90f9b4af19e5fa9f83452989cdcaed21569a181 | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_makemessages.py#L70-L100 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.