repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.overview
def overview(self, tag=None, fromdate=None, todate=None): """ Gets a brief overview of statistics for all of your outbound email. """ return self.call("GET", "/stats/outbound", tag=tag, fromdate=fromdate, todate=todate)
python
def overview(self, tag=None, fromdate=None, todate=None): """ Gets a brief overview of statistics for all of your outbound email. """ return self.call("GET", "/stats/outbound", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "overview", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound\"", ",", "tag", "=", "tag", ",", "fromdate", "=", "fro...
Gets a brief overview of statistics for all of your outbound email.
[ "Gets", "a", "brief", "overview", "of", "statistics", "for", "all", "of", "your", "outbound", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L8-L12
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.sends
def sends(self, tag=None, fromdate=None, todate=None): """ Gets a total count of emails you’ve sent out. """ return self.call("GET", "/stats/outbound/sends", tag=tag, fromdate=fromdate, todate=todate)
python
def sends(self, tag=None, fromdate=None, todate=None): """ Gets a total count of emails you’ve sent out. """ return self.call("GET", "/stats/outbound/sends", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "sends", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/sends\"", ",", "tag", "=", "tag", ",", "fromdate", "=", "...
Gets a total count of emails you’ve sent out.
[ "Gets", "a", "total", "count", "of", "emails", "you’ve", "sent", "out", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L14-L18
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.bounces
def bounces(self, tag=None, fromdate=None, todate=None): """ Gets total counts of emails you’ve sent out that have been returned as bounced. """ return self.call("GET", "/stats/outbound/bounces", tag=tag, fromdate=fromdate, todate=todate)
python
def bounces(self, tag=None, fromdate=None, todate=None): """ Gets total counts of emails you’ve sent out that have been returned as bounced. """ return self.call("GET", "/stats/outbound/bounces", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "bounces", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/bounces\"", ",", "tag", "=", "tag", ",", "fromdate", "=",...
Gets total counts of emails you’ve sent out that have been returned as bounced.
[ "Gets", "total", "counts", "of", "emails", "you’ve", "sent", "out", "that", "have", "been", "returned", "as", "bounced", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L20-L24
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.spam
def spam(self, tag=None, fromdate=None, todate=None): """ Gets a total count of recipients who have marked your email as spam. """ return self.call("GET", "/stats/outbound/spam", tag=tag, fromdate=fromdate, todate=todate)
python
def spam(self, tag=None, fromdate=None, todate=None): """ Gets a total count of recipients who have marked your email as spam. """ return self.call("GET", "/stats/outbound/spam", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "spam", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/spam\"", ",", "tag", "=", "tag", ",", "fromdate", "=", "fr...
Gets a total count of recipients who have marked your email as spam.
[ "Gets", "a", "total", "count", "of", "recipients", "who", "have", "marked", "your", "email", "as", "spam", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L26-L30
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.tracked
def tracked(self, tag=None, fromdate=None, todate=None): """ Gets a total count of emails you’ve sent with open tracking or link tracking enabled. """ return self.call("GET", "/stats/outbound/tracked", tag=tag, fromdate=fromdate, todate=todate)
python
def tracked(self, tag=None, fromdate=None, todate=None): """ Gets a total count of emails you’ve sent with open tracking or link tracking enabled. """ return self.call("GET", "/stats/outbound/tracked", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "tracked", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/tracked\"", ",", "tag", "=", "tag", ",", "fromdate", "=",...
Gets a total count of emails you’ve sent with open tracking or link tracking enabled.
[ "Gets", "a", "total", "count", "of", "emails", "you’ve", "sent", "with", "open", "tracking", "or", "link", "tracking", "enabled", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L32-L36
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.opens
def opens(self, tag=None, fromdate=None, todate=None): """ Gets total counts of recipients who opened your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens", tag=tag, fromdate=fromdate, todate=todate)
python
def opens(self, tag=None, fromdate=None, todate=None): """ Gets total counts of recipients who opened your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "opens", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/opens\"", ",", "tag", "=", "tag", ",", "fromdate", "=", "...
Gets total counts of recipients who opened your emails. This is only recorded when open tracking is enabled for that email.
[ "Gets", "total", "counts", "of", "recipients", "who", "opened", "your", "emails", ".", "This", "is", "only", "recorded", "when", "open", "tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L38-L43
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.opens_platforms
def opens_platforms(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the platforms used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/platforms", tag=tag, fromdate=fr...
python
def opens_platforms(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the platforms used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/platforms", tag=tag, fromdate=fr...
[ "def", "opens_platforms", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/opens/platforms\"", ",", "tag", "=", "tag", ",", "f...
Gets an overview of the platforms used to open your emails. This is only recorded when open tracking is enabled for that email.
[ "Gets", "an", "overview", "of", "the", "platforms", "used", "to", "open", "your", "emails", ".", "This", "is", "only", "recorded", "when", "open", "tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L45-L50
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.emailclients
def emailclients(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/emailclients", tag=tag, fromdat...
python
def emailclients(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/emailclients", tag=tag, fromdat...
[ "def", "emailclients", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/opens/emailclients\"", ",", "tag", "=", "tag", ",", "f...
Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email.
[ "Gets", "an", "overview", "of", "the", "email", "clients", "used", "to", "open", "your", "emails", ".", "This", "is", "only", "recorded", "when", "open", "tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L52-L57
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.readtimes
def readtimes(self, tag=None, fromdate=None, todate=None): """ Gets the length of time that recipients read emails along with counts for each time. This is only recorded when open tracking is enabled for that email. Read time tracking stops at 20 seconds, so any read times above that wil...
python
def readtimes(self, tag=None, fromdate=None, todate=None): """ Gets the length of time that recipients read emails along with counts for each time. This is only recorded when open tracking is enabled for that email. Read time tracking stops at 20 seconds, so any read times above that wil...
[ "def", "readtimes", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/opens/readtimes\"", ",", "tag", "=", "tag", ",", "fromdat...
Gets the length of time that recipients read emails along with counts for each time. This is only recorded when open tracking is enabled for that email. Read time tracking stops at 20 seconds, so any read times above that will appear in the 20s+ field.
[ "Gets", "the", "length", "of", "time", "that", "recipients", "read", "emails", "along", "with", "counts", "for", "each", "time", ".", "This", "is", "only", "recorded", "when", "open", "tracking", "is", "enabled", "for", "that", "email", ".", "Read", "time"...
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L59-L65
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.clicks
def clicks(self, tag=None, fromdate=None, todate=None): """ Gets total counts of unique links that were clicked. """ return self.call("GET", "/stats/outbound/clicks", tag=tag, fromdate=fromdate, todate=todate)
python
def clicks(self, tag=None, fromdate=None, todate=None): """ Gets total counts of unique links that were clicked. """ return self.call("GET", "/stats/outbound/clicks", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "clicks", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/clicks\"", ",", "tag", "=", "tag", ",", "fromdate", "=", ...
Gets total counts of unique links that were clicked.
[ "Gets", "total", "counts", "of", "unique", "links", "that", "were", "clicked", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L67-L71
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.browserfamilies
def browserfamilies(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the browsers used to open links in your emails. This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/browserfamilies", tag=t...
python
def browserfamilies(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the browsers used to open links in your emails. This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/browserfamilies", tag=t...
[ "def", "browserfamilies", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/clicks/browserfamilies\"", ",", "tag", "=", "tag", ",...
Gets an overview of the browsers used to open links in your emails. This is only recorded when Link Tracking is enabled for that email.
[ "Gets", "an", "overview", "of", "the", "browsers", "used", "to", "open", "links", "in", "your", "emails", ".", "This", "is", "only", "recorded", "when", "Link", "Tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L73-L78
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.clicks_platforms
def clicks_platforms(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the browser platforms used to open your emails. This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/platforms", tag=tag, f...
python
def clicks_platforms(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the browser platforms used to open your emails. This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/platforms", tag=tag, f...
[ "def", "clicks_platforms", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/clicks/platforms\"", ",", "tag", "=", "tag", ",", ...
Gets an overview of the browser platforms used to open your emails. This is only recorded when Link Tracking is enabled for that email.
[ "Gets", "an", "overview", "of", "the", "browser", "platforms", "used", "to", "open", "your", "emails", ".", "This", "is", "only", "recorded", "when", "Link", "Tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L80-L85
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.location
def location(self, tag=None, fromdate=None, todate=None): """ Gets an overview of which part of the email links were clicked from (HTML or Text). This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/location", tag...
python
def location(self, tag=None, fromdate=None, todate=None): """ Gets an overview of which part of the email links were clicked from (HTML or Text). This is only recorded when Link Tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/clicks/location", tag...
[ "def", "location", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound/clicks/location\"", ",", "tag", "=", "tag", ",", "fromdate...
Gets an overview of which part of the email links were clicked from (HTML or Text). This is only recorded when Link Tracking is enabled for that email.
[ "Gets", "an", "overview", "of", "which", "part", "of", "the", "email", "links", "were", "clicked", "from", "(", "HTML", "or", "Text", ")", ".", "This", "is", "only", "recorded", "when", "Link", "Tracking", "is", "enabled", "for", "that", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L87-L92
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.line_rate
def line_rate(self, filename=None): """ Return the global line rate of the coverage report. If the `filename` file is given, return the line rate of the file. """ if filename is None: el = self.xml else: el = self._get_class_element_by_filename(fil...
python
def line_rate(self, filename=None): """ Return the global line rate of the coverage report. If the `filename` file is given, return the line rate of the file. """ if filename is None: el = self.xml else: el = self._get_class_element_by_filename(fil...
[ "def", "line_rate", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "el", "=", "self", ".", "xml", "else", ":", "el", "=", "self", ".", "_get_class_element_by_filename", "(", "filename", ")", "return", "float", ...
Return the global line rate of the coverage report. If the `filename` file is given, return the line rate of the file.
[ "Return", "the", "global", "line", "rate", "of", "the", "coverage", "report", ".", "If", "the", "filename", "file", "is", "given", "return", "the", "line", "rate", "of", "the", "file", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L93-L103
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.branch_rate
def branch_rate(self, filename=None): """ Return the global branch rate of the coverage report. If the `filename` file is given, return the branch rate of the file. """ if filename is None: el = self.xml else: el = self._get_class_element_by_filena...
python
def branch_rate(self, filename=None): """ Return the global branch rate of the coverage report. If the `filename` file is given, return the branch rate of the file. """ if filename is None: el = self.xml else: el = self._get_class_element_by_filena...
[ "def", "branch_rate", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "el", "=", "self", ".", "xml", "else", ":", "el", "=", "self", ".", "_get_class_element_by_filename", "(", "filename", ")", "return", "float",...
Return the global branch rate of the coverage report. If the `filename` file is given, return the branch rate of the file.
[ "Return", "the", "global", "branch", "rate", "of", "the", "coverage", "report", ".", "If", "the", "filename", "file", "is", "given", "return", "the", "branch", "rate", "of", "the", "file", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L105-L115
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.missed_statements
def missed_statements(self, filename): """ Return a list of uncovered line numbers for each of the missed statements found for the file `filename`. """ el = self._get_class_element_by_filename(filename) lines = el.xpath('./lines/line[@hits=0]') return [int(l.attri...
python
def missed_statements(self, filename): """ Return a list of uncovered line numbers for each of the missed statements found for the file `filename`. """ el = self._get_class_element_by_filename(filename) lines = el.xpath('./lines/line[@hits=0]') return [int(l.attri...
[ "def", "missed_statements", "(", "self", ",", "filename", ")", ":", "el", "=", "self", ".", "_get_class_element_by_filename", "(", "filename", ")", "lines", "=", "el", ".", "xpath", "(", "'./lines/line[@hits=0]'", ")", "return", "[", "int", "(", "l", ".", ...
Return a list of uncovered line numbers for each of the missed statements found for the file `filename`.
[ "Return", "a", "list", "of", "uncovered", "line", "numbers", "for", "each", "of", "the", "missed", "statements", "found", "for", "the", "file", "filename", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L118-L125
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.line_statuses
def line_statuses(self, filename): """ Return a list of tuples `(lineno, status)` of all the lines found in the Cobertura report for the given file `filename` where `lineno` is the line number and `status` is coverage status of the line which can be either `True` (line hit) or `F...
python
def line_statuses(self, filename): """ Return a list of tuples `(lineno, status)` of all the lines found in the Cobertura report for the given file `filename` where `lineno` is the line number and `status` is coverage status of the line which can be either `True` (line hit) or `F...
[ "def", "line_statuses", "(", "self", ",", "filename", ")", ":", "line_elements", "=", "self", ".", "_get_lines_by_filename", "(", "filename", ")", "lines_w_status", "=", "[", "]", "for", "line", "in", "line_elements", ":", "lineno", "=", "int", "(", "line", ...
Return a list of tuples `(lineno, status)` of all the lines found in the Cobertura report for the given file `filename` where `lineno` is the line number and `status` is coverage status of the line which can be either `True` (line hit) or `False` (line miss).
[ "Return", "a", "list", "of", "tuples", "(", "lineno", "status", ")", "of", "all", "the", "lines", "found", "in", "the", "Cobertura", "report", "for", "the", "given", "file", "filename", "where", "lineno", "is", "the", "line", "number", "and", "status", "...
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L137-L152
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.missed_lines
def missed_lines(self, filename): """ Return a list of extrapolated uncovered line numbers for the file `filename` according to `Cobertura.line_statuses`. """ statuses = self.line_statuses(filename) statuses = extrapolate_coverage(statuses) return [lno for lno, st...
python
def missed_lines(self, filename): """ Return a list of extrapolated uncovered line numbers for the file `filename` according to `Cobertura.line_statuses`. """ statuses = self.line_statuses(filename) statuses = extrapolate_coverage(statuses) return [lno for lno, st...
[ "def", "missed_lines", "(", "self", ",", "filename", ")", ":", "statuses", "=", "self", ".", "line_statuses", "(", "filename", ")", "statuses", "=", "extrapolate_coverage", "(", "statuses", ")", "return", "[", "lno", "for", "lno", ",", "status", "in", "sta...
Return a list of extrapolated uncovered line numbers for the file `filename` according to `Cobertura.line_statuses`.
[ "Return", "a", "list", "of", "extrapolated", "uncovered", "line", "numbers", "for", "the", "file", "filename", "according", "to", "Cobertura", ".", "line_statuses", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L154-L161
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.file_source
def file_source(self, filename): """ Return a list of namedtuple `Line` for each line of code found in the source file with the given `filename`. """ lines = [] try: with self.filesystem.open(filename) as f: line_statuses = dict(self.line_statu...
python
def file_source(self, filename): """ Return a list of namedtuple `Line` for each line of code found in the source file with the given `filename`. """ lines = [] try: with self.filesystem.open(filename) as f: line_statuses = dict(self.line_statu...
[ "def", "file_source", "(", "self", ",", "filename", ")", ":", "lines", "=", "[", "]", "try", ":", "with", "self", ".", "filesystem", ".", "open", "(", "filename", ")", "as", "f", ":", "line_statuses", "=", "dict", "(", "self", ".", "line_statuses", "...
Return a list of namedtuple `Line` for each line of code found in the source file with the given `filename`.
[ "Return", "a", "list", "of", "namedtuple", "Line", "for", "each", "line", "of", "code", "found", "in", "the", "source", "file", "with", "the", "given", "filename", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L164-L183
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.total_misses
def total_misses(self, filename=None): """ Return the total number of uncovered statements for the file `filename`. If `filename` is not given, return the total number of uncovered statements for all files. """ if filename is not None: return len(self.missed_s...
python
def total_misses(self, filename=None): """ Return the total number of uncovered statements for the file `filename`. If `filename` is not given, return the total number of uncovered statements for all files. """ if filename is not None: return len(self.missed_s...
[ "def", "total_misses", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "not", "None", ":", "return", "len", "(", "self", ".", "missed_statements", "(", "filename", ")", ")", "total", "=", "0", "for", "filename", "in", "self...
Return the total number of uncovered statements for the file `filename`. If `filename` is not given, return the total number of uncovered statements for all files.
[ "Return", "the", "total", "number", "of", "uncovered", "statements", "for", "the", "file", "filename", ".", "If", "filename", "is", "not", "given", "return", "the", "total", "number", "of", "uncovered", "statements", "for", "all", "files", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L185-L198
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.total_hits
def total_hits(self, filename=None): """ Return the total number of covered statements for the file `filename`. If `filename` is not given, return the total number of covered statements for all files. """ if filename is not None: return len(self.hit_statements...
python
def total_hits(self, filename=None): """ Return the total number of covered statements for the file `filename`. If `filename` is not given, return the total number of covered statements for all files. """ if filename is not None: return len(self.hit_statements...
[ "def", "total_hits", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "not", "None", ":", "return", "len", "(", "self", ".", "hit_statements", "(", "filename", ")", ")", "total", "=", "0", "for", "filename", "in", "self", ...
Return the total number of covered statements for the file `filename`. If `filename` is not given, return the total number of covered statements for all files.
[ "Return", "the", "total", "number", "of", "covered", "statements", "for", "the", "file", "filename", ".", "If", "filename", "is", "not", "given", "return", "the", "total", "number", "of", "covered", "statements", "for", "all", "files", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L200-L213
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.total_statements
def total_statements(self, filename=None): """ Return the total number of statements for the file `filename`. If `filename` is not given, return the total number of statements for all files. """ if filename is not None: statements = self._get_lines_by_filename...
python
def total_statements(self, filename=None): """ Return the total number of statements for the file `filename`. If `filename` is not given, return the total number of statements for all files. """ if filename is not None: statements = self._get_lines_by_filename...
[ "def", "total_statements", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "not", "None", ":", "statements", "=", "self", ".", "_get_lines_by_filename", "(", "filename", ")", "return", "len", "(", "statements", ")", "total", "=...
Return the total number of statements for the file `filename`. If `filename` is not given, return the total number of statements for all files.
[ "Return", "the", "total", "number", "of", "statements", "for", "the", "file", "filename", ".", "If", "filename", "is", "not", "given", "return", "the", "total", "number", "of", "statements", "for", "all", "files", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L215-L230
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.files
def files(self): """ Return the list of available files in the coverage report. """ # maybe replace with a trie at some point? see has_file FIXME already_seen = set() filenames = [] for el in self.xml.xpath("//class"): filename = el.attrib['filename']...
python
def files(self): """ Return the list of available files in the coverage report. """ # maybe replace with a trie at some point? see has_file FIXME already_seen = set() filenames = [] for el in self.xml.xpath("//class"): filename = el.attrib['filename']...
[ "def", "files", "(", "self", ")", ":", "# maybe replace with a trie at some point? see has_file FIXME", "already_seen", "=", "set", "(", ")", "filenames", "=", "[", "]", "for", "el", "in", "self", ".", "xml", ".", "xpath", "(", "\"//class\"", ")", ":", "filena...
Return the list of available files in the coverage report.
[ "Return", "the", "list", "of", "available", "files", "in", "the", "coverage", "report", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L233-L248
aconrad/pycobertura
pycobertura/cobertura.py
Cobertura.source_lines
def source_lines(self, filename): """ Return a list for source lines of file `filename`. """ with self.filesystem.open(filename) as f: return f.readlines()
python
def source_lines(self, filename): """ Return a list for source lines of file `filename`. """ with self.filesystem.open(filename) as f: return f.readlines()
[ "def", "source_lines", "(", "self", ",", "filename", ")", ":", "with", "self", ".", "filesystem", ".", "open", "(", "filename", ")", "as", "f", ":", "return", "f", ".", "readlines", "(", ")" ]
Return a list for source lines of file `filename`.
[ "Return", "a", "list", "for", "source", "lines", "of", "file", "filename", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L259-L264
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff.has_better_coverage
def has_better_coverage(self): """ Return `True` if coverage of has improved, `False` otherwise. This does not ensure that all changes have been covered. If this is what you want, use `CoberturaDiff.has_all_changes_covered()` instead. """ for filename in self.files(): ...
python
def has_better_coverage(self): """ Return `True` if coverage of has improved, `False` otherwise. This does not ensure that all changes have been covered. If this is what you want, use `CoberturaDiff.has_all_changes_covered()` instead. """ for filename in self.files(): ...
[ "def", "has_better_coverage", "(", "self", ")", ":", "for", "filename", "in", "self", ".", "files", "(", ")", ":", "if", "self", ".", "diff_total_misses", "(", "filename", ")", ">", "0", ":", "return", "False", "return", "True" ]
Return `True` if coverage of has improved, `False` otherwise. This does not ensure that all changes have been covered. If this is what you want, use `CoberturaDiff.has_all_changes_covered()` instead.
[ "Return", "True", "if", "coverage", "of", "has", "improved", "False", "otherwise", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L282-L292
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff.has_all_changes_covered
def has_all_changes_covered(self): """ Return `True` if all changes have been covered, `False` otherwise. """ for filename in self.files(): for hunk in self.file_source_hunks(filename): for line in hunk: if line.reason is None: ...
python
def has_all_changes_covered(self): """ Return `True` if all changes have been covered, `False` otherwise. """ for filename in self.files(): for hunk in self.file_source_hunks(filename): for line in hunk: if line.reason is None: ...
[ "def", "has_all_changes_covered", "(", "self", ")", ":", "for", "filename", "in", "self", ".", "files", "(", ")", ":", "for", "hunk", "in", "self", ".", "file_source_hunks", "(", "filename", ")", ":", "for", "line", "in", "hunk", ":", "if", "line", "."...
Return `True` if all changes have been covered, `False` otherwise.
[ "Return", "True", "if", "all", "changes", "have", "been", "covered", "False", "otherwise", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L294-L305
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff._diff_attr
def _diff_attr(self, attr_name, filename): """ Return the difference between `self.cobertura2.<attr_name>(filename)` and `self.cobertura1.<attr_name>(filename)`. This generic method is meant to diff the count of methods that return counts for a given file `filename`, e.g...
python
def _diff_attr(self, attr_name, filename): """ Return the difference between `self.cobertura2.<attr_name>(filename)` and `self.cobertura1.<attr_name>(filename)`. This generic method is meant to diff the count of methods that return counts for a given file `filename`, e.g...
[ "def", "_diff_attr", "(", "self", ",", "attr_name", ",", "filename", ")", ":", "if", "filename", "is", "not", "None", ":", "files", "=", "[", "filename", "]", "else", ":", "files", "=", "self", ".", "files", "(", ")", "total_count", "=", "0.0", "for"...
Return the difference between `self.cobertura2.<attr_name>(filename)` and `self.cobertura1.<attr_name>(filename)`. This generic method is meant to diff the count of methods that return counts for a given file `filename`, e.g. `Cobertura.total_statements`, `Cobertura.total_misses...
[ "Return", "the", "difference", "between", "self", ".", "cobertura2", ".", "<attr_name", ">", "(", "filename", ")", "and", "self", ".", "cobertura1", ".", "<attr_name", ">", "(", "filename", ")", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L307-L335
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff.diff_missed_lines
def diff_missed_lines(self, filename): """ Return a list of 2-element tuples `(lineno, is_new)` for the given file `filename` where `lineno` is a missed line number and `is_new` indicates whether the missed line was introduced (True) or removed (False). """ line_c...
python
def diff_missed_lines(self, filename): """ Return a list of 2-element tuples `(lineno, is_new)` for the given file `filename` where `lineno` is a missed line number and `is_new` indicates whether the missed line was introduced (True) or removed (False). """ line_c...
[ "def", "diff_missed_lines", "(", "self", ",", "filename", ")", ":", "line_changed", "=", "[", "]", "for", "line", "in", "self", ".", "file_source", "(", "filename", ")", ":", "if", "line", ".", "status", "is", "not", "None", ":", "is_new", "=", "not", ...
Return a list of 2-element tuples `(lineno, is_new)` for the given file `filename` where `lineno` is a missed line number and `is_new` indicates whether the missed line was introduced (True) or removed (False).
[ "Return", "a", "list", "of", "2", "-", "element", "tuples", "(", "lineno", "is_new", ")", "for", "the", "given", "file", "filename", "where", "lineno", "is", "a", "missed", "line", "number", "and", "is_new", "indicates", "whether", "the", "missed", "line",...
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L351-L363
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff.file_source
def file_source(self, filename): """ Return a list of namedtuple `Line` for each line of code found in the given file `filename`. """ if self.cobertura1.has_file(filename) and \ self.cobertura1.filesystem.has_file(filename): lines1 = self.cobertura1.s...
python
def file_source(self, filename): """ Return a list of namedtuple `Line` for each line of code found in the given file `filename`. """ if self.cobertura1.has_file(filename) and \ self.cobertura1.filesystem.has_file(filename): lines1 = self.cobertura1.s...
[ "def", "file_source", "(", "self", ",", "filename", ")", ":", "if", "self", ".", "cobertura1", ".", "has_file", "(", "filename", ")", "and", "self", ".", "cobertura1", ".", "filesystem", ".", "has_file", "(", "filename", ")", ":", "lines1", "=", "self", ...
Return a list of namedtuple `Line` for each line of code found in the given file `filename`.
[ "Return", "a", "list", "of", "namedtuple", "Line", "for", "each", "line", "of", "code", "found", "in", "the", "given", "file", "filename", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L371-L418
aconrad/pycobertura
pycobertura/cobertura.py
CoberturaDiff.file_source_hunks
def file_source_hunks(self, filename): """ Like `CoberturaDiff.file_source`, but returns a list of line hunks of the lines that have changed for the given file `filename`. An empty list means that the file has no lines that have a change in coverage status. """ li...
python
def file_source_hunks(self, filename): """ Like `CoberturaDiff.file_source`, but returns a list of line hunks of the lines that have changed for the given file `filename`. An empty list means that the file has no lines that have a change in coverage status. """ li...
[ "def", "file_source_hunks", "(", "self", ",", "filename", ")", ":", "lines", "=", "self", ".", "file_source", "(", "filename", ")", "hunks", "=", "hunkify_lines", "(", "lines", ")", "return", "hunks" ]
Like `CoberturaDiff.file_source`, but returns a list of line hunks of the lines that have changed for the given file `filename`. An empty list means that the file has no lines that have a change in coverage status.
[ "Like", "CoberturaDiff", ".", "file_source", "but", "returns", "a", "list", "of", "line", "hunks", "of", "the", "lines", "that", "have", "changed", "for", "the", "given", "file", "filename", ".", "An", "empty", "list", "means", "that", "the", "file", "has"...
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L420-L429
bufferapp/kiner
kiner/producer.py
KinesisProducer.monitor
def monitor(self): """Flushes the queue periodically.""" while self.monitor_running.is_set(): if time.time() - self.last_flush > self.batch_time: if not self.queue.empty(): logger.info("Queue Flush: time without flush exceeded") self.fl...
python
def monitor(self): """Flushes the queue periodically.""" while self.monitor_running.is_set(): if time.time() - self.last_flush > self.batch_time: if not self.queue.empty(): logger.info("Queue Flush: time without flush exceeded") self.fl...
[ "def", "monitor", "(", "self", ")", ":", "while", "self", ".", "monitor_running", ".", "is_set", "(", ")", ":", "if", "time", ".", "time", "(", ")", "-", "self", ".", "last_flush", ">", "self", ".", "batch_time", ":", "if", "not", "self", ".", "que...
Flushes the queue periodically.
[ "Flushes", "the", "queue", "periodically", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L63-L70
bufferapp/kiner
kiner/producer.py
KinesisProducer.put_records
def put_records(self, records, partition_key=None): """Add a list of data records to the record queue in the proper format. Convinience method that calls self.put_record for each element. Parameters ---------- records : list Lists of records to send. partitio...
python
def put_records(self, records, partition_key=None): """Add a list of data records to the record queue in the proper format. Convinience method that calls self.put_record for each element. Parameters ---------- records : list Lists of records to send. partitio...
[ "def", "put_records", "(", "self", ",", "records", ",", "partition_key", "=", "None", ")", ":", "for", "record", "in", "records", ":", "self", ".", "put_record", "(", "record", ",", "partition_key", ")" ]
Add a list of data records to the record queue in the proper format. Convinience method that calls self.put_record for each element. Parameters ---------- records : list Lists of records to send. partition_key: str Hash that determines which shard a given...
[ "Add", "a", "list", "of", "data", "records", "to", "the", "record", "queue", "in", "the", "proper", "format", ".", "Convinience", "method", "that", "calls", "self", ".", "put_record", "for", "each", "element", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L72-L85
bufferapp/kiner
kiner/producer.py
KinesisProducer.put_record
def put_record(self, data, partition_key=None): """Add data to the record queue in the proper format. Parameters ---------- data : str Data to send. partition_key: str Hash that determines which shard a given data record belongs to. """ #...
python
def put_record(self, data, partition_key=None): """Add data to the record queue in the proper format. Parameters ---------- data : str Data to send. partition_key: str Hash that determines which shard a given data record belongs to. """ #...
[ "def", "put_record", "(", "self", ",", "data", ",", "partition_key", "=", "None", ")", ":", "# Byte encode the data", "data", "=", "encode_data", "(", "data", ")", "# Create a random partition key if not provided", "if", "not", "partition_key", ":", "partition_key", ...
Add data to the record queue in the proper format. Parameters ---------- data : str Data to send. partition_key: str Hash that determines which shard a given data record belongs to.
[ "Add", "data", "to", "the", "record", "queue", "in", "the", "proper", "format", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L87-L118
bufferapp/kiner
kiner/producer.py
KinesisProducer.close
def close(self): """Flushes the queue and waits for the executor to finish.""" logger.info('Closing producer') self.flush_queue() self.monitor_running.clear() self.pool.shutdown() logger.info('Producer closed')
python
def close(self): """Flushes the queue and waits for the executor to finish.""" logger.info('Closing producer') self.flush_queue() self.monitor_running.clear() self.pool.shutdown() logger.info('Producer closed')
[ "def", "close", "(", "self", ")", ":", "logger", ".", "info", "(", "'Closing producer'", ")", "self", ".", "flush_queue", "(", ")", "self", ".", "monitor_running", ".", "clear", "(", ")", "self", ".", "pool", ".", "shutdown", "(", ")", "logger", ".", ...
Flushes the queue and waits for the executor to finish.
[ "Flushes", "the", "queue", "and", "waits", "for", "the", "executor", "to", "finish", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L120-L126
bufferapp/kiner
kiner/producer.py
KinesisProducer.flush_queue
def flush_queue(self): """Grab all the current records in the queue and send them.""" records = [] while not self.queue.empty() and len(records) < self.batch_size: records.append(self.queue.get()) if records: self.send_records(records) self.last_flus...
python
def flush_queue(self): """Grab all the current records in the queue and send them.""" records = [] while not self.queue.empty() and len(records) < self.batch_size: records.append(self.queue.get()) if records: self.send_records(records) self.last_flus...
[ "def", "flush_queue", "(", "self", ")", ":", "records", "=", "[", "]", "while", "not", "self", ".", "queue", ".", "empty", "(", ")", "and", "len", "(", "records", ")", "<", "self", ".", "batch_size", ":", "records", ".", "append", "(", "self", ".",...
Grab all the current records in the queue and send them.
[ "Grab", "all", "the", "current", "records", "in", "the", "queue", "and", "send", "them", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L128-L137
bufferapp/kiner
kiner/producer.py
KinesisProducer.send_records
def send_records(self, records, attempt=0): """Send records to the Kinesis stream. Falied records are sent again with an exponential backoff decay. Parameters ---------- records : array Array of formated records to send. attempt: int Number of ti...
python
def send_records(self, records, attempt=0): """Send records to the Kinesis stream. Falied records are sent again with an exponential backoff decay. Parameters ---------- records : array Array of formated records to send. attempt: int Number of ti...
[ "def", "send_records", "(", "self", ",", "records", ",", "attempt", "=", "0", ")", ":", "# If we already tried more times than we wanted, save to a file", "if", "attempt", ">", "self", ".", "max_retries", ":", "logger", ".", "warning", "(", "'Writing {} records to fil...
Send records to the Kinesis stream. Falied records are sent again with an exponential backoff decay. Parameters ---------- records : array Array of formated records to send. attempt: int Number of times the records have been sent without success.
[ "Send", "records", "to", "the", "Kinesis", "stream", "." ]
train
https://github.com/bufferapp/kiner/blob/c4c6e7ef24e5600864d0bdc4c8b967b339245238/kiner/producer.py#L139-L178
aconrad/pycobertura
pycobertura/utils.py
rangify
def rangify(number_list): """Assumes the list is sorted.""" if not number_list: return number_list ranges = [] range_start = prev_num = number_list[0] for num in number_list[1:]: if num != (prev_num + 1): ranges.append((range_start, prev_num)) range_start = ...
python
def rangify(number_list): """Assumes the list is sorted.""" if not number_list: return number_list ranges = [] range_start = prev_num = number_list[0] for num in number_list[1:]: if num != (prev_num + 1): ranges.append((range_start, prev_num)) range_start = ...
[ "def", "rangify", "(", "number_list", ")", ":", "if", "not", "number_list", ":", "return", "number_list", "ranges", "=", "[", "]", "range_start", "=", "prev_num", "=", "number_list", "[", "0", "]", "for", "num", "in", "number_list", "[", "1", ":", "]", ...
Assumes the list is sorted.
[ "Assumes", "the", "list", "is", "sorted", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/utils.py#L61-L76
aconrad/pycobertura
pycobertura/utils.py
extrapolate_coverage
def extrapolate_coverage(lines_w_status): """ Given the following input: >>> lines_w_status = [ (1, True), (4, True), (7, False), (9, False), ] Return expanded lines with their extrapolated line status. >>> extrapolate_coverage(lines_w_status) == [ (1, ...
python
def extrapolate_coverage(lines_w_status): """ Given the following input: >>> lines_w_status = [ (1, True), (4, True), (7, False), (9, False), ] Return expanded lines with their extrapolated line status. >>> extrapolate_coverage(lines_w_status) == [ (1, ...
[ "def", "extrapolate_coverage", "(", "lines_w_status", ")", ":", "lines", "=", "[", "]", "prev_lineno", "=", "0", "prev_status", "=", "True", "for", "lineno", ",", "status", "in", "lines_w_status", ":", "while", "(", "lineno", "-", "prev_lineno", ")", ">", ...
Given the following input: >>> lines_w_status = [ (1, True), (4, True), (7, False), (9, False), ] Return expanded lines with their extrapolated line status. >>> extrapolate_coverage(lines_w_status) == [ (1, True), (2, True), (3, True), (...
[ "Given", "the", "following", "input", ":" ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/utils.py#L79-L120
aconrad/pycobertura
pycobertura/utils.py
reconcile_lines
def reconcile_lines(lines1, lines2): """ Return a dict `{lineno1: lineno2}` which reconciles line numbers `lineno1` of list `lines1` to line numbers `lineno2` of list `lines2`. Only lines that are common in both sets are present in the dict, lines unique to one of the sets are omitted. """ d...
python
def reconcile_lines(lines1, lines2): """ Return a dict `{lineno1: lineno2}` which reconciles line numbers `lineno1` of list `lines1` to line numbers `lineno2` of list `lines2`. Only lines that are common in both sets are present in the dict, lines unique to one of the sets are omitted. """ d...
[ "def", "reconcile_lines", "(", "lines1", ",", "lines2", ")", ":", "differ", "=", "difflib", ".", "Differ", "(", ")", "diff", "=", "differ", ".", "compare", "(", "lines1", ",", "lines2", ")", "SAME", "=", "' '", "ADDED", "=", "'+ '", "REMOVED", "=", ...
Return a dict `{lineno1: lineno2}` which reconciles line numbers `lineno1` of list `lines1` to line numbers `lineno2` of list `lines2`. Only lines that are common in both sets are present in the dict, lines unique to one of the sets are omitted.
[ "Return", "a", "dict", "{", "lineno1", ":", "lineno2", "}", "which", "reconciles", "line", "numbers", "lineno1", "of", "list", "lines1", "to", "line", "numbers", "lineno2", "of", "list", "lines2", ".", "Only", "lines", "that", "are", "common", "in", "both"...
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/utils.py#L123-L159
aconrad/pycobertura
pycobertura/utils.py
hunkify_lines
def hunkify_lines(lines, context=3): """ Return a list of line hunks given a list of lines `lines`. The number of context lines can be control with `context` which will return line hunks surrounded with `context` lines before and after the code change. """ # Find contiguous line changes rang...
python
def hunkify_lines(lines, context=3): """ Return a list of line hunks given a list of lines `lines`. The number of context lines can be control with `context` which will return line hunks surrounded with `context` lines before and after the code change. """ # Find contiguous line changes rang...
[ "def", "hunkify_lines", "(", "lines", ",", "context", "=", "3", ")", ":", "# Find contiguous line changes", "ranges", "=", "[", "]", "range_start", "=", "None", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "line", ".", "statu...
Return a list of line hunks given a list of lines `lines`. The number of context lines can be control with `context` which will return line hunks surrounded with `context` lines before and after the code change.
[ "Return", "a", "list", "of", "line", "hunks", "given", "a", "list", "of", "lines", "lines", ".", "The", "number", "of", "context", "lines", "can", "be", "control", "with", "context", "which", "will", "return", "line", "hunks", "surrounded", "with", "contex...
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/utils.py#L162-L210
aconrad/pycobertura
pycobertura/cli.py
show
def show(cobertura_file, format, output, source, source_prefix): """show coverage summary of a Cobertura report""" cobertura = Cobertura(cobertura_file, source=source) Reporter = reporters[format] reporter = Reporter(cobertura) report = reporter.generate() if not isinstance(report, bytes): ...
python
def show(cobertura_file, format, output, source, source_prefix): """show coverage summary of a Cobertura report""" cobertura = Cobertura(cobertura_file, source=source) Reporter = reporters[format] reporter = Reporter(cobertura) report = reporter.generate() if not isinstance(report, bytes): ...
[ "def", "show", "(", "cobertura_file", ",", "format", ",", "output", ",", "source", ",", "source_prefix", ")", ":", "cobertura", "=", "Cobertura", "(", "cobertura_file", ",", "source", "=", "source", ")", "Reporter", "=", "reporters", "[", "format", "]", "r...
show coverage summary of a Cobertura report
[ "show", "coverage", "summary", "of", "a", "Cobertura", "report" ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cli.py#L65-L76
aconrad/pycobertura
pycobertura/cli.py
diff
def diff( cobertura_file1, cobertura_file2, color, format, output, source1, source2, source_prefix1, source_prefix2, source): """compare coverage of two Cobertura reports""" cobertura1 = Cobertura( cobertura_file1, source=source1, source_prefix=source_prefix1 ...
python
def diff( cobertura_file1, cobertura_file2, color, format, output, source1, source2, source_prefix1, source_prefix2, source): """compare coverage of two Cobertura reports""" cobertura1 = Cobertura( cobertura_file1, source=source1, source_prefix=source_prefix1 ...
[ "def", "diff", "(", "cobertura_file1", ",", "cobertura_file2", ",", "color", ",", "format", ",", "output", ",", "source1", ",", "source2", ",", "source_prefix1", ",", "source_prefix2", ",", "source", ")", ":", "cobertura1", "=", "Cobertura", "(", "cobertura_fi...
compare coverage of two Cobertura reports
[ "compare", "coverage", "of", "two", "Cobertura", "reports" ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cli.py#L141-L176
aconrad/pycobertura
pycobertura/filesystem.py
DirectoryFileSystem.open
def open(self, filename): """ Yield a file-like object for file `filename`. This function is a context manager. """ filename = self.real_filename(filename) if not os.path.exists(filename): raise self.FileNotFound(filename) with codecs.open(filename,...
python
def open(self, filename): """ Yield a file-like object for file `filename`. This function is a context manager. """ filename = self.real_filename(filename) if not os.path.exists(filename): raise self.FileNotFound(filename) with codecs.open(filename,...
[ "def", "open", "(", "self", ",", "filename", ")", ":", "filename", "=", "self", ".", "real_filename", "(", "filename", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "self", ".", "FileNotFound", "(", "filename",...
Yield a file-like object for file `filename`. This function is a context manager.
[ "Yield", "a", "file", "-", "like", "object", "for", "file", "filename", "." ]
train
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/filesystem.py#L31-L43
pyros-dev/pyros
pyros/client/client.py
PyrosClient.topic_inject
def topic_inject(self, topic_name, _msg_content=None, **kwargs): """ Injecting message into topic. if _msg_content, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _msg_content: optional message content :param kwargs: each extra ...
python
def topic_inject(self, topic_name, _msg_content=None, **kwargs): """ Injecting message into topic. if _msg_content, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _msg_content: optional message content :param kwargs: each extra ...
[ "def", "topic_inject", "(", "self", ",", "topic_name", ",", "_msg_content", "=", "None", ",", "*", "*", "kwargs", ")", ":", "#changing unicode to string ( testing stability of multiprocess debugging )", "if", "isinstance", "(", "topic_name", ",", "unicode", ")", ":", ...
Injecting message into topic. if _msg_content, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _msg_content: optional message content :param kwargs: each extra kwarg will be put int he message is structure matches :return:
[ "Injecting", "message", "into", "topic", ".", "if", "_msg_content", "we", "inject", "it", "directly", ".", "if", "not", "we", "use", "all", "extra", "kwargs", ":", "param", "topic_name", ":", "name", "of", "the", "topic", ":", "param", "_msg_content", ":",...
train
https://github.com/pyros-dev/pyros/blob/59f6c8848a66481a4039cbf28b7673428181842e/pyros/client/client.py#L111-L130
pyros-dev/pyros
pyros/client/client.py
PyrosClient.param_set
def param_set(self, param_name, _value=None, **kwargs): """ Setting parameter. if _value, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _value: optional value :param kwargs: each extra kwarg will be put in the value if structur...
python
def param_set(self, param_name, _value=None, **kwargs): """ Setting parameter. if _value, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _value: optional value :param kwargs: each extra kwarg will be put in the value if structur...
[ "def", "param_set", "(", "self", ",", "param_name", ",", "_value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "#changing unicode to string ( testing stability of multiprocess debugging )", "if", "isinstance", "(", "param_name", ",", "unicode", ")", ":", "param_...
Setting parameter. if _value, we inject it directly. if not, we use all extra kwargs :param topic_name: name of the topic :param _value: optional value :param kwargs: each extra kwarg will be put in the value if structure matches :return:
[ "Setting", "parameter", ".", "if", "_value", "we", "inject", "it", "directly", ".", "if", "not", "we", "use", "all", "extra", "kwargs", ":", "param", "topic_name", ":", "name", "of", "the", "topic", ":", "param", "_value", ":", "optional", "value", ":", ...
train
https://github.com/pyros-dev/pyros/blob/59f6c8848a66481a4039cbf28b7673428181842e/pyros/client/client.py#L165-L187
pyros-dev/pyros
setup.py
PrepareReleaseCommand.run
def run(self): """runner""" # change version in code and changelog before running this subprocess.check_call("git commit CHANGELOG.rst pyros/_version.py CHANGELOG.rst -m 'v{0}'".format(__version__), shell=True) subprocess.check_call("git push", shell=True) print("You should ver...
python
def run(self): """runner""" # change version in code and changelog before running this subprocess.check_call("git commit CHANGELOG.rst pyros/_version.py CHANGELOG.rst -m 'v{0}'".format(__version__), shell=True) subprocess.check_call("git push", shell=True) print("You should ver...
[ "def", "run", "(", "self", ")", ":", "# change version in code and changelog before running this", "subprocess", ".", "check_call", "(", "\"git commit CHANGELOG.rst pyros/_version.py CHANGELOG.rst -m 'v{0}'\"", ".", "format", "(", "__version__", ")", ",", "shell", "=", "True"...
runner
[ "runner" ]
train
https://github.com/pyros-dev/pyros/blob/59f6c8848a66481a4039cbf28b7673428181842e/setup.py#L40-L49
pyros-dev/pyros
pyros/__main__.py
run
def run(interface, config, logfile, ros_args): """ Start a pyros node. :param interface: the interface implementation (ROS, Mock, ZMP, etc.) :param config: the config file path, absolute, or relative to working directory :param logfile: the logfile path, absolute, or relative to working directory ...
python
def run(interface, config, logfile, ros_args): """ Start a pyros node. :param interface: the interface implementation (ROS, Mock, ZMP, etc.) :param config: the config file path, absolute, or relative to working directory :param logfile: the logfile path, absolute, or relative to working directory ...
[ "def", "run", "(", "interface", ",", "config", ",", "logfile", ",", "ros_args", ")", ":", "logging", ".", "info", "(", "'pyros started with : interface {interface} config {config} logfile {logfile} ros_args {ros_args}'", ".", "format", "(", "interface", "=", "interface", ...
Start a pyros node. :param interface: the interface implementation (ROS, Mock, ZMP, etc.) :param config: the config file path, absolute, or relative to working directory :param logfile: the logfile path, absolute, or relative to working directory :param ros_args: the ros arguments (useful to absorb addi...
[ "Start", "a", "pyros", "node", ".", ":", "param", "interface", ":", "the", "interface", "implementation", "(", "ROS", "Mock", "ZMP", "etc", ".", ")", ":", "param", "config", ":", "the", "config", "file", "path", "absolute", "or", "relative", "to", "worki...
train
https://github.com/pyros-dev/pyros/blob/59f6c8848a66481a4039cbf28b7673428181842e/pyros/__main__.py#L207-L225
numberoverzero/bottom
bottom/unpack.py
nickmask
def nickmask(prefix: str, kwargs: Dict[str, Any]) -> None: """ store nick, user, host in kwargs if prefix is correct format """ if "!" in prefix and "@" in prefix: # From a user kwargs["nick"], remainder = prefix.split("!", 1) kwargs["user"], kwargs["host"] = remainder.split("@", 1) ...
python
def nickmask(prefix: str, kwargs: Dict[str, Any]) -> None: """ store nick, user, host in kwargs if prefix is correct format """ if "!" in prefix and "@" in prefix: # From a user kwargs["nick"], remainder = prefix.split("!", 1) kwargs["user"], kwargs["host"] = remainder.split("@", 1) ...
[ "def", "nickmask", "(", "prefix", ":", "str", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "if", "\"!\"", "in", "prefix", "and", "\"@\"", "in", "prefix", ":", "# From a user", "kwargs", "[", "\"nick\"", "]", ",", ...
store nick, user, host in kwargs if prefix is correct format
[ "store", "nick", "user", "host", "in", "kwargs", "if", "prefix", "is", "correct", "format" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/unpack.py#L175-L183
numberoverzero/bottom
bottom/unpack.py
split_line
def split_line(msg: str) -> Tuple[str, str, List[str]]: """ Parse message according to rfc 2812 for routing """ match = RE_IRCLINE.match(msg) if not match: raise ValueError("Invalid line") prefix = match.group("prefix") or "" command = match.group("command") params = (match.group("param...
python
def split_line(msg: str) -> Tuple[str, str, List[str]]: """ Parse message according to rfc 2812 for routing """ match = RE_IRCLINE.match(msg) if not match: raise ValueError("Invalid line") prefix = match.group("prefix") or "" command = match.group("command") params = (match.group("param...
[ "def", "split_line", "(", "msg", ":", "str", ")", "->", "Tuple", "[", "str", ",", "str", ",", "List", "[", "str", "]", "]", ":", "match", "=", "RE_IRCLINE", ".", "match", "(", "msg", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "\"...
Parse message according to rfc 2812 for routing
[ "Parse", "message", "according", "to", "rfc", "2812", "for", "routing" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/unpack.py#L190-L204
numberoverzero/bottom
bottom/pack.py
b
def b(field: str, kwargs: Dict[str, Any], present: Optional[Any] = None, missing: Any = '') -> str: """ Return `present` value (default to `field`) if `field` in `kwargs` and Truthy, otherwise return `missing` value """ if kwargs.get(field): return field if present is None else str(pre...
python
def b(field: str, kwargs: Dict[str, Any], present: Optional[Any] = None, missing: Any = '') -> str: """ Return `present` value (default to `field`) if `field` in `kwargs` and Truthy, otherwise return `missing` value """ if kwargs.get(field): return field if present is None else str(pre...
[ "def", "b", "(", "field", ":", "str", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ",", "present", ":", "Optional", "[", "Any", "]", "=", "None", ",", "missing", ":", "Any", "=", "''", ")", "->", "str", ":", "if", "kwargs", ".", "...
Return `present` value (default to `field`) if `field` in `kwargs` and Truthy, otherwise return `missing` value
[ "Return", "present", "value", "(", "default", "to", "field", ")", "if", "field", "in", "kwargs", "and", "Truthy", "otherwise", "return", "missing", "value" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/pack.py#L7-L15
numberoverzero/bottom
bottom/pack.py
f
def f(field: str, kwargs: Dict[str, Any], default: Optional[Any] = None) -> str: """ Alias for more readable command construction """ if default is not None: return str(kwargs.get(field, default)) return str(kwargs[field])
python
def f(field: str, kwargs: Dict[str, Any], default: Optional[Any] = None) -> str: """ Alias for more readable command construction """ if default is not None: return str(kwargs.get(field, default)) return str(kwargs[field])
[ "def", "f", "(", "field", ":", "str", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ")", "->", "str", ":", "if", "default", "is", "not", "None", ":", "return", "str", "("...
Alias for more readable command construction
[ "Alias", "for", "more", "readable", "command", "construction" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/pack.py#L18-L23
numberoverzero/bottom
bottom/pack.py
pack
def pack(field: str, kwargs: Dict[str, Any], default: Optional[Any] = None, sep: str=',') -> str: """ Util for joining multiple fields with commas """ if default is not None: value = kwargs.get(field, default) else: value = kwargs[field] if isinstance(value, str): return...
python
def pack(field: str, kwargs: Dict[str, Any], default: Optional[Any] = None, sep: str=',') -> str: """ Util for joining multiple fields with commas """ if default is not None: value = kwargs.get(field, default) else: value = kwargs[field] if isinstance(value, str): return...
[ "def", "pack", "(", "field", ":", "str", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ",", "sep", ":", "str", "=", "','", ")", "->", "str", ":", "if", "default", "is", ...
Util for joining multiple fields with commas
[ "Util", "for", "joining", "multiple", "fields", "with", "commas" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/pack.py#L26-L38
numberoverzero/bottom
bottom/pack.py
pack_command
def pack_command(command: str, **kwargs: Any) -> str: """ Pack a command to send to an IRC server """ if not command: raise ValueError("Must provide a command") if not isinstance(command, str): raise ValueError("Command must be a string") command = command.upper() # ================...
python
def pack_command(command: str, **kwargs: Any) -> str: """ Pack a command to send to an IRC server """ if not command: raise ValueError("Must provide a command") if not isinstance(command, str): raise ValueError("Command must be a string") command = command.upper() # ================...
[ "def", "pack_command", "(", "command", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "str", ":", "if", "not", "command", ":", "raise", "ValueError", "(", "\"Must provide a command\"", ")", "if", "not", "isinstance", "(", "command", ",", "st...
Pack a command to send to an IRC server
[ "Pack", "a", "command", "to", "send", "to", "an", "IRC", "server" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/pack.py#L41-L547
numberoverzero/bottom
bottom/client.py
RawClient.connect
async def connect(self) -> None: """Open a connection to the defined server.""" def protocol_factory() -> Protocol: return Protocol(client=self) _, protocol = await self.loop.create_connection( protocol_factory, host=self.host, port=self.port, ...
python
async def connect(self) -> None: """Open a connection to the defined server.""" def protocol_factory() -> Protocol: return Protocol(client=self) _, protocol = await self.loop.create_connection( protocol_factory, host=self.host, port=self.port, ...
[ "async", "def", "connect", "(", "self", ")", "->", "None", ":", "def", "protocol_factory", "(", ")", "->", "Protocol", ":", "return", "Protocol", "(", "client", "=", "self", ")", "_", ",", "protocol", "=", "await", "self", ".", "loop", ".", "create_con...
Open a connection to the defined server.
[ "Open", "a", "connection", "to", "the", "defined", "server", "." ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/client.py#L69-L87
numberoverzero/bottom
bottom/client.py
RawClient.trigger
def trigger(self, event: str, **kwargs: Any) -> None: """Trigger all handlers for an event to (asynchronously) execute""" event = event.upper() for func in self._event_handlers[event]: self.loop.create_task(func(**kwargs)) # This will unblock anyone that is awaiting on the ne...
python
def trigger(self, event: str, **kwargs: Any) -> None: """Trigger all handlers for an event to (asynchronously) execute""" event = event.upper() for func in self._event_handlers[event]: self.loop.create_task(func(**kwargs)) # This will unblock anyone that is awaiting on the ne...
[ "def", "trigger", "(", "self", ",", "event", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "event", "=", "event", ".", "upper", "(", ")", "for", "func", "in", "self", ".", "_event_handlers", "[", "event", "]", ":", "sel...
Trigger all handlers for an event to (asynchronously) execute
[ "Trigger", "all", "handlers", "for", "an", "event", "to", "(", "asynchronously", ")", "execute" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/client.py#L94-L104
numberoverzero/bottom
bottom/client.py
RawClient.on
def on(self, event: str, func: Optional[Callable] = None) -> Callable: """ Decorate a function to be invoked when the given event occurs. The function may be a coroutine. Your function should accept **kwargs in case an event is triggered with unexpected kwargs. Example ...
python
def on(self, event: str, func: Optional[Callable] = None) -> Callable: """ Decorate a function to be invoked when the given event occurs. The function may be a coroutine. Your function should accept **kwargs in case an event is triggered with unexpected kwargs. Example ...
[ "def", "on", "(", "self", ",", "event", ":", "str", ",", "func", ":", "Optional", "[", "Callable", "]", "=", "None", ")", "->", "Callable", ":", "if", "func", "is", "None", ":", "return", "functools", ".", "partial", "(", "self", ".", "on", ",", ...
Decorate a function to be invoked when the given event occurs. The function may be a coroutine. Your function should accept **kwargs in case an event is triggered with unexpected kwargs. Example ------- import asyncio import bottom client = bottom.Client(...) ...
[ "Decorate", "a", "function", "to", "be", "invoked", "when", "the", "given", "event", "occurs", "." ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/client.py#L110-L142
numberoverzero/bottom
bottom/client.py
Client.send
def send(self, command: str, **kwargs: Any) -> None: """ Send a message to the server. .. code-block:: python client.send("nick", nick="weatherbot") client.send("privmsg", target="#python", message="Hello, World!") """ packed_command = pack_command(comm...
python
def send(self, command: str, **kwargs: Any) -> None: """ Send a message to the server. .. code-block:: python client.send("nick", nick="weatherbot") client.send("privmsg", target="#python", message="Hello, World!") """ packed_command = pack_command(comm...
[ "def", "send", "(", "self", ",", "command", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "packed_command", "=", "pack_command", "(", "command", ",", "*", "*", "kwargs", ")", ".", "strip", "(", ")", "self", ".", "send_raw...
Send a message to the server. .. code-block:: python client.send("nick", nick="weatherbot") client.send("privmsg", target="#python", message="Hello, World!")
[ "Send", "a", "message", "to", "the", "server", "." ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/bottom/client.py#L170-L181
numberoverzero/bottom
examples/regex.py
Router._handle
def _handle(self, nick, target, message, **kwargs): """ client callback entrance """ for regex, (func, pattern) in self.routes.items(): match = regex.match(message) if match: self.client.loop.create_task( func(nick, target, message, match, **kw...
python
def _handle(self, nick, target, message, **kwargs): """ client callback entrance """ for regex, (func, pattern) in self.routes.items(): match = regex.match(message) if match: self.client.loop.create_task( func(nick, target, message, match, **kw...
[ "def", "_handle", "(", "self", ",", "nick", ",", "target", ",", "message", ",", "*", "*", "kwargs", ")", ":", "for", "regex", ",", "(", "func", ",", "pattern", ")", "in", "self", ".", "routes", ".", "items", "(", ")", ":", "match", "=", "regex", ...
client callback entrance
[ "client", "callback", "entrance" ]
train
https://github.com/numberoverzero/bottom/blob/9ba5f8e22d4990071e3606256e9bc1f64ec989fe/examples/regex.py#L12-L18
miccoli/pyownet
examples/owget.py
main
def main(): """parse commandline arguments and print result""" fcodes = collections.OrderedDict(( ('f.i', protocol.FLG_FORMAT_FDI), ('fi', protocol.FLG_FORMAT_FI), ('f.i.c', protocol.FLG_FORMAT_FDIDC), ('f.ic', protocol.FLG_FORMAT_FDIC), ('fi.c', protocol.FLG_FORMAT_FIDC...
python
def main(): """parse commandline arguments and print result""" fcodes = collections.OrderedDict(( ('f.i', protocol.FLG_FORMAT_FDI), ('fi', protocol.FLG_FORMAT_FI), ('f.i.c', protocol.FLG_FORMAT_FDIDC), ('f.ic', protocol.FLG_FORMAT_FDIC), ('fi.c', protocol.FLG_FORMAT_FIDC...
[ "def", "main", "(", ")", ":", "fcodes", "=", "collections", ".", "OrderedDict", "(", "(", "(", "'f.i'", ",", "protocol", ".", "FLG_FORMAT_FDI", ")", ",", "(", "'fi'", ",", "protocol", ".", "FLG_FORMAT_FI", ")", ",", "(", "'f.i.c'", ",", "protocol", "."...
parse commandline arguments and print result
[ "parse", "commandline", "arguments", "and", "print", "result" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/examples/owget.py#L38-L170
miccoli/pyownet
diags/stress_t.py
main
def main(): """parse commandline arguments and print result""" # # setup command line parsing a la argpase # parser = argparse.ArgumentParser() # positional args parser.add_argument('uri', metavar='URI', nargs='?', default='/', help='[owserver:]//hostname:port/path'...
python
def main(): """parse commandline arguments and print result""" # # setup command line parsing a la argpase # parser = argparse.ArgumentParser() # positional args parser.add_argument('uri', metavar='URI', nargs='?', default='/', help='[owserver:]//hostname:port/path'...
[ "def", "main", "(", ")", ":", "#", "# setup command line parsing a la argpase", "#", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# positional args", "parser", ".", "add_argument", "(", "'uri'", ",", "metavar", "=", "'URI'", ",", "nargs", "=", ...
parse commandline arguments and print result
[ "parse", "commandline", "arguments", "and", "print", "result" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/diags/stress_t.py#L64-L112
SeanOC/sharpy
sharpy/client.py
Client.build_url
def build_url(self, path, params=None): ''' Constructs the url for a cheddar API resource ''' url = u'%s/%s/productCode/%s' % ( self.endpoint, path, self.product_code, ) if params: for key, value in params.items(): ...
python
def build_url(self, path, params=None): ''' Constructs the url for a cheddar API resource ''' url = u'%s/%s/productCode/%s' % ( self.endpoint, path, self.product_code, ) if params: for key, value in params.items(): ...
[ "def", "build_url", "(", "self", ",", "path", ",", "params", "=", "None", ")", ":", "url", "=", "u'%s/%s/productCode/%s'", "%", "(", "self", ".", "endpoint", ",", "path", ",", "self", ".", "product_code", ",", ")", "if", "params", ":", "for", "key", ...
Constructs the url for a cheddar API resource
[ "Constructs", "the", "url", "for", "a", "cheddar", "API", "resource" ]
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/client.py#L33-L46
SeanOC/sharpy
sharpy/client.py
Client.make_request
def make_request(self, path, params=None, data=None, method=None): ''' Makes a request to the cheddar api using the authentication and configuration settings available. ''' # Setup values url = self.build_url(path, params) client_log.debug('Requesting: %s' % url)...
python
def make_request(self, path, params=None, data=None, method=None): ''' Makes a request to the cheddar api using the authentication and configuration settings available. ''' # Setup values url = self.build_url(path, params) client_log.debug('Requesting: %s' % url)...
[ "def", "make_request", "(", "self", ",", "path", ",", "params", "=", "None", ",", "data", "=", "None", ",", "method", "=", "None", ")", ":", "# Setup values", "url", "=", "self", ".", "build_url", "(", "path", ",", "params", ")", "client_log", ".", "...
Makes a request to the cheddar api using the authentication and configuration settings available.
[ "Makes", "a", "request", "to", "the", "cheddar", "api", "using", "the", "authentication", "and", "configuration", "settings", "available", "." ]
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/client.py#L70-L125
miccoli/pyownet
examples/walk.py
main
def main(): """parse commandline arguments and print result""" # # setup command line parsing a la argpase # parser = argparse.ArgumentParser() # positional args parser.add_argument('uri', metavar='URI', nargs='?', default='/', help='[owserver:]//server:port/entity'...
python
def main(): """parse commandline arguments and print result""" # # setup command line parsing a la argpase # parser = argparse.ArgumentParser() # positional args parser.add_argument('uri', metavar='URI', nargs='?', default='/', help='[owserver:]//server:port/entity'...
[ "def", "main", "(", ")", ":", "#", "# setup command line parsing a la argpase", "#", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# positional args", "parser", ".", "add_argument", "(", "'uri'", ",", "metavar", "=", "'URI'", ",", "nargs", "=", ...
parse commandline arguments and print result
[ "parse", "commandline", "arguments", "and", "print", "result" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/examples/walk.py#L38-L124
miccoli/pyownet
src/pyownet/protocol.py
proxy
def proxy(host='localhost', port=4304, flags=0, persistent=False, verbose=False, ): """factory function that returns a proxy object for an owserver at host, port. """ # resolve host name/port try: gai = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, ...
python
def proxy(host='localhost', port=4304, flags=0, persistent=False, verbose=False, ): """factory function that returns a proxy object for an owserver at host, port. """ # resolve host name/port try: gai = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, ...
[ "def", "proxy", "(", "host", "=", "'localhost'", ",", "port", "=", "4304", ",", "flags", "=", "0", ",", "persistent", "=", "False", ",", "verbose", "=", "False", ",", ")", ":", "# resolve host name/port", "try", ":", "gai", "=", "socket", ".", "getaddr...
factory function that returns a proxy object for an owserver at host, port.
[ "factory", "function", "that", "returns", "a", "proxy", "object", "for", "an", "owserver", "at", "host", "port", "." ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L708-L750
miccoli/pyownet
src/pyownet/protocol.py
clone
def clone(proxy, persistent=True): """factory function for cloning a proxy object""" if not isinstance(proxy, _Proxy): raise TypeError('argument is not a Proxy object') if persistent: pclass = _PersistentProxy else: pclass = _Proxy return pclass(proxy._family, proxy._socka...
python
def clone(proxy, persistent=True): """factory function for cloning a proxy object""" if not isinstance(proxy, _Proxy): raise TypeError('argument is not a Proxy object') if persistent: pclass = _PersistentProxy else: pclass = _Proxy return pclass(proxy._family, proxy._socka...
[ "def", "clone", "(", "proxy", ",", "persistent", "=", "True", ")", ":", "if", "not", "isinstance", "(", "proxy", ",", "_Proxy", ")", ":", "raise", "TypeError", "(", "'argument is not a Proxy object'", ")", "if", "persistent", ":", "pclass", "=", "_Persistent...
factory function for cloning a proxy object
[ "factory", "function", "for", "cloning", "a", "proxy", "object" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L753-L765
miccoli/pyownet
src/pyownet/protocol.py
_OwnetConnection.shutdown
def shutdown(self): """shutdown connection""" if self.verbose: print(self.socket.getsockname(), 'xx', self.peername) try: self.socket.shutdown(socket.SHUT_RDWR) except IOError as err: assert err.errno is _ENOTCONN, "unexpected IOError: %s" % err ...
python
def shutdown(self): """shutdown connection""" if self.verbose: print(self.socket.getsockname(), 'xx', self.peername) try: self.socket.shutdown(socket.SHUT_RDWR) except IOError as err: assert err.errno is _ENOTCONN, "unexpected IOError: %s" % err ...
[ "def", "shutdown", "(", "self", ")", ":", "if", "self", ".", "verbose", ":", "print", "(", "self", ".", "socket", ".", "getsockname", "(", ")", ",", "'xx'", ",", "self", ".", "peername", ")", "try", ":", "self", ".", "socket", ".", "shutdown", "(",...
shutdown connection
[ "shutdown", "connection" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L391-L403
miccoli/pyownet
src/pyownet/protocol.py
_OwnetConnection.req
def req(self, msgtype, payload, flags, size=0, offset=0, timeout=0): """send message to server and return response""" if timeout < 0: raise ValueError("timeout cannot be negative!") tohead = _ToServerHeader(payload=len(payload), type=msgtype, flags=...
python
def req(self, msgtype, payload, flags, size=0, offset=0, timeout=0): """send message to server and return response""" if timeout < 0: raise ValueError("timeout cannot be negative!") tohead = _ToServerHeader(payload=len(payload), type=msgtype, flags=...
[ "def", "req", "(", "self", ",", "msgtype", ",", "payload", ",", "flags", ",", "size", "=", "0", ",", "offset", "=", "0", ",", "timeout", "=", "0", ")", ":", "if", "timeout", "<", "0", ":", "raise", "ValueError", "(", "\"timeout cannot be negative!\"", ...
send message to server and return response
[ "send", "message", "to", "server", "and", "return", "response" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L408-L436
miccoli/pyownet
src/pyownet/protocol.py
_OwnetConnection._send_msg
def _send_msg(self, header, payload): """send message to server""" if self.verbose: print('->', repr(header)) print('..', repr(payload)) assert header.payload == len(payload) try: sent = self.socket.send(header + payload) except IOError as err...
python
def _send_msg(self, header, payload): """send message to server""" if self.verbose: print('->', repr(header)) print('..', repr(payload)) assert header.payload == len(payload) try: sent = self.socket.send(header + payload) except IOError as err...
[ "def", "_send_msg", "(", "self", ",", "header", ",", "payload", ")", ":", "if", "self", ".", "verbose", ":", "print", "(", "'->'", ",", "repr", "(", "header", ")", ")", "print", "(", "'..'", ",", "repr", "(", "payload", ")", ")", "assert", "header"...
send message to server
[ "send", "message", "to", "server" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L438-L456
miccoli/pyownet
src/pyownet/protocol.py
_OwnetConnection._read_msg
def _read_msg(self): """read message from server""" # # NOTE: # '_recv_socket(nbytes)' was implemented as # 'socket.recv(nbytes, socket.MSG_WAITALL)' # but socket.MSG_WAITALL proved not reliable # def _recv_socket(nbytes): """read nbytes byte...
python
def _read_msg(self): """read message from server""" # # NOTE: # '_recv_socket(nbytes)' was implemented as # 'socket.recv(nbytes, socket.MSG_WAITALL)' # but socket.MSG_WAITALL proved not reliable # def _recv_socket(nbytes): """read nbytes byte...
[ "def", "_read_msg", "(", "self", ")", ":", "#", "# NOTE:", "# '_recv_socket(nbytes)' was implemented as", "# 'socket.recv(nbytes, socket.MSG_WAITALL)'", "# but socket.MSG_WAITALL proved not reliable", "#", "def", "_recv_socket", "(", "nbytes", ")", ":", "\"\"\"read nbytes bytes f...
read message from server
[ "read", "message", "from", "server" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L458-L519
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.sendmess
def sendmess(self, msgtype, payload, flags=0, size=0, offset=0, timeout=0): """ retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data """ flags |= self.flags assert not (flags & FLG_PERSISTENCE) with self._new_connection() as conn: ...
python
def sendmess(self, msgtype, payload, flags=0, size=0, offset=0, timeout=0): """ retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data """ flags |= self.flags assert not (flags & FLG_PERSISTENCE) with self._new_connection() as conn: ...
[ "def", "sendmess", "(", "self", ",", "msgtype", ",", "payload", ",", "flags", "=", "0", ",", "size", "=", "0", ",", "offset", "=", "0", ",", "timeout", "=", "0", ")", ":", "flags", "|=", "self", ".", "flags", "assert", "not", "(", "flags", "&", ...
retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data
[ "retcode", "data", "=", "sendmess", "(", "msgtype", "payload", ")", "send", "generic", "message", "and", "returns", "retcode", "data" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L563-L575
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.ping
def ping(self): """sends a NOP packet and waits response; returns None""" ret, data = self.sendmess(MSG_NOP, bytes()) if data or ret > 0: raise ProtocolError('invalid reply to ping message') if ret < 0: raise OwnetError(-ret, self.errmess[-ret])
python
def ping(self): """sends a NOP packet and waits response; returns None""" ret, data = self.sendmess(MSG_NOP, bytes()) if data or ret > 0: raise ProtocolError('invalid reply to ping message') if ret < 0: raise OwnetError(-ret, self.errmess[-ret])
[ "def", "ping", "(", "self", ")", ":", "ret", ",", "data", "=", "self", ".", "sendmess", "(", "MSG_NOP", ",", "bytes", "(", ")", ")", "if", "data", "or", "ret", ">", "0", ":", "raise", "ProtocolError", "(", "'invalid reply to ping message'", ")", "if", ...
sends a NOP packet and waits response; returns None
[ "sends", "a", "NOP", "packet", "and", "waits", "response", ";", "returns", "None" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L577-L584
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.present
def present(self, path, timeout=0): """returns True if there is an entity at path""" ret, data = self.sendmess(MSG_PRESENCE, str2bytez(path), timeout=timeout) assert ret <= 0 and not data, (ret, data) if ret < 0: return False else: ...
python
def present(self, path, timeout=0): """returns True if there is an entity at path""" ret, data = self.sendmess(MSG_PRESENCE, str2bytez(path), timeout=timeout) assert ret <= 0 and not data, (ret, data) if ret < 0: return False else: ...
[ "def", "present", "(", "self", ",", "path", ",", "timeout", "=", "0", ")", ":", "ret", ",", "data", "=", "self", ".", "sendmess", "(", "MSG_PRESENCE", ",", "str2bytez", "(", "path", ")", ",", "timeout", "=", "timeout", ")", "assert", "ret", "<=", "...
returns True if there is an entity at path
[ "returns", "True", "if", "there", "is", "an", "entity", "at", "path" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L586-L595
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.dir
def dir(self, path='/', slash=True, bus=False, timeout=0): """list entities at path""" if slash: msg = MSG_DIRALLSLASH else: msg = MSG_DIRALL if bus: flags = self.flags | FLG_BUS_RET else: flags = self.flags & ~FLG_BUS_RET ...
python
def dir(self, path='/', slash=True, bus=False, timeout=0): """list entities at path""" if slash: msg = MSG_DIRALLSLASH else: msg = MSG_DIRALL if bus: flags = self.flags | FLG_BUS_RET else: flags = self.flags & ~FLG_BUS_RET ...
[ "def", "dir", "(", "self", ",", "path", "=", "'/'", ",", "slash", "=", "True", ",", "bus", "=", "False", ",", "timeout", "=", "0", ")", ":", "if", "slash", ":", "msg", "=", "MSG_DIRALLSLASH", "else", ":", "msg", "=", "MSG_DIRALL", "if", "bus", ":...
list entities at path
[ "list", "entities", "at", "path" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L597-L615
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.read
def read(self, path, size=MAX_PAYLOAD, offset=0, timeout=0): """read data at path""" if size > MAX_PAYLOAD: raise ValueError("size cannot exceed %d" % MAX_PAYLOAD) ret, data = self.sendmess(MSG_READ, str2bytez(path), size=size, offset=offset, timeo...
python
def read(self, path, size=MAX_PAYLOAD, offset=0, timeout=0): """read data at path""" if size > MAX_PAYLOAD: raise ValueError("size cannot exceed %d" % MAX_PAYLOAD) ret, data = self.sendmess(MSG_READ, str2bytez(path), size=size, offset=offset, timeo...
[ "def", "read", "(", "self", ",", "path", ",", "size", "=", "MAX_PAYLOAD", ",", "offset", "=", "0", ",", "timeout", "=", "0", ")", ":", "if", "size", ">", "MAX_PAYLOAD", ":", "raise", "ValueError", "(", "\"size cannot exceed %d\"", "%", "MAX_PAYLOAD", ")"...
read data at path
[ "read", "data", "at", "path" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L617-L627
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.write
def write(self, path, data, offset=0, timeout=0): """write data at path path is a string, data binary; it is responsability of the caller ensure proper encoding. """ # fixme: check of path type delayed to str2bytez if not isinstance(data, (bytes, bytearray, )): ...
python
def write(self, path, data, offset=0, timeout=0): """write data at path path is a string, data binary; it is responsability of the caller ensure proper encoding. """ # fixme: check of path type delayed to str2bytez if not isinstance(data, (bytes, bytearray, )): ...
[ "def", "write", "(", "self", ",", "path", ",", "data", ",", "offset", "=", "0", ",", "timeout", "=", "0", ")", ":", "# fixme: check of path type delayed to str2bytez", "if", "not", "isinstance", "(", "data", ",", "(", "bytes", ",", "bytearray", ",", ")", ...
write data at path path is a string, data binary; it is responsability of the caller ensure proper encoding.
[ "write", "data", "at", "path" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L629-L645
miccoli/pyownet
src/pyownet/protocol.py
_PersistentProxy.sendmess
def sendmess(self, msgtype, payload, flags=0, size=0, offset=0, timeout=0): """ retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data """ # reuse last valid connection or create new conn = self.conn or self._new_connection() # ...
python
def sendmess(self, msgtype, payload, flags=0, size=0, offset=0, timeout=0): """ retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data """ # reuse last valid connection or create new conn = self.conn or self._new_connection() # ...
[ "def", "sendmess", "(", "self", ",", "msgtype", ",", "payload", ",", "flags", "=", "0", ",", "size", "=", "0", ",", "offset", "=", "0", ",", "timeout", "=", "0", ")", ":", "# reuse last valid connection or create new", "conn", "=", "self", ".", "conn", ...
retcode, data = sendmess(msgtype, payload) send generic message and returns retcode, data
[ "retcode", "data", "=", "sendmess", "(", "msgtype", "payload", ")", "send", "generic", "message", "and", "returns", "retcode", "data" ]
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L679-L701
SeanOC/sharpy
sharpy/product.py
CheddarProduct.get_customers
def get_customers(self, filter_data=None): ''' Returns all customers. Sometimes they are too much and cause internal server errors on CG. API call permits post parameters for filtering which tends to fix this https://cheddargetter.com/developers#all-customers filter_da...
python
def get_customers(self, filter_data=None): ''' Returns all customers. Sometimes they are too much and cause internal server errors on CG. API call permits post parameters for filtering which tends to fix this https://cheddargetter.com/developers#all-customers filter_da...
[ "def", "get_customers", "(", "self", ",", "filter_data", "=", "None", ")", ":", "customers", "=", "[", "]", "try", ":", "response", "=", "self", ".", "client", ".", "make_request", "(", "path", "=", "'customers/get'", ",", "data", "=", "filter_data", ")"...
Returns all customers. Sometimes they are too much and cause internal server errors on CG. API call permits post parameters for filtering which tends to fix this https://cheddargetter.com/developers#all-customers filter_data Will be processed by urlencode and can be used f...
[ "Returns", "all", "customers", ".", "Sometimes", "they", "are", "too", "much", "and", "cause", "internal", "server", "errors", "on", "CG", ".", "API", "call", "permits", "post", "parameters", "for", "filtering", "which", "tends", "to", "fix", "this", "https"...
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L214-L241
SeanOC/sharpy
sharpy/product.py
CheddarProduct.delete_all_customers
def delete_all_customers(self): ''' This method does exactly what you think it does. Calling this method deletes all customer data in your cheddar product and the configured gateway. This action cannot be undone. DO NOT RUN THIS UNLESS YOU REALLY, REALLY, REALLY MEAN T...
python
def delete_all_customers(self): ''' This method does exactly what you think it does. Calling this method deletes all customer data in your cheddar product and the configured gateway. This action cannot be undone. DO NOT RUN THIS UNLESS YOU REALLY, REALLY, REALLY MEAN T...
[ "def", "delete_all_customers", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "make_request", "(", "path", "=", "'customers/delete-all/confirm/%d'", "%", "int", "(", "time", "(", ")", ")", ",", "method", "=", "'POST'", ")" ]
This method does exactly what you think it does. Calling this method deletes all customer data in your cheddar product and the configured gateway. This action cannot be undone. DO NOT RUN THIS UNLESS YOU REALLY, REALLY, REALLY MEAN TO!
[ "This", "method", "does", "exactly", "what", "you", "think", "it", "does", ".", "Calling", "this", "method", "deletes", "all", "customer", "data", "in", "your", "cheddar", "product", "and", "the", "configured", "gateway", ".", "This", "action", "cannot", "be...
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L254-L265
SeanOC/sharpy
sharpy/product.py
PricingPlan.initial_bill_date
def initial_bill_date(self): ''' An estimated initial bill date for an account created today, based on available plan info. ''' time_to_start = None if self.initial_bill_count_unit == 'months': time_to_start = relativedelta(months=self.initial_bill_co...
python
def initial_bill_date(self): ''' An estimated initial bill date for an account created today, based on available plan info. ''' time_to_start = None if self.initial_bill_count_unit == 'months': time_to_start = relativedelta(months=self.initial_bill_co...
[ "def", "initial_bill_date", "(", "self", ")", ":", "time_to_start", "=", "None", "if", "self", ".", "initial_bill_count_unit", "==", "'months'", ":", "time_to_start", "=", "relativedelta", "(", "months", "=", "self", ".", "initial_bill_count", ")", "else", ":", ...
An estimated initial bill date for an account created today, based on available plan info.
[ "An", "estimated", "initial", "bill", "date", "for", "an", "account", "created", "today", "based", "on", "available", "plan", "info", "." ]
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L331-L345
SeanOC/sharpy
sharpy/product.py
Customer.charge
def charge(self, code, each_amount, quantity=1, description=None): ''' Add an arbitrary charge or credit to a customer's account. A positive number will create a charge. A negative number will create a credit. each_amount is normalized to a Decimal with a precision of 2 as tha...
python
def charge(self, code, each_amount, quantity=1, description=None): ''' Add an arbitrary charge or credit to a customer's account. A positive number will create a charge. A negative number will create a credit. each_amount is normalized to a Decimal with a precision of 2 as tha...
[ "def", "charge", "(", "self", ",", "code", ",", "each_amount", ",", "quantity", "=", "1", ",", "description", "=", "None", ")", ":", "each_amount", "=", "Decimal", "(", "each_amount", ")", "each_amount", "=", "each_amount", ".", "quantize", "(", "Decimal",...
Add an arbitrary charge or credit to a customer's account. A positive number will create a charge. A negative number will create a credit. each_amount is normalized to a Decimal with a precision of 2 as that is the level of precision which the cheddar API supports.
[ "Add", "an", "arbitrary", "charge", "or", "credit", "to", "a", "customer", "s", "account", ".", "A", "positive", "number", "will", "create", "a", "charge", ".", "A", "negative", "number", "will", "create", "a", "credit", ".", "each_amount", "is", "normaliz...
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L482-L505
SeanOC/sharpy
sharpy/product.py
Customer.create_one_time_invoice
def create_one_time_invoice(self, charges): ''' Charges should be a list of charges to execute immediately. Each value in the charges diectionary should be a dictionary with the following keys: code Your code for this charge. This code will be displayed in the ...
python
def create_one_time_invoice(self, charges): ''' Charges should be a list of charges to execute immediately. Each value in the charges diectionary should be a dictionary with the following keys: code Your code for this charge. This code will be displayed in the ...
[ "def", "create_one_time_invoice", "(", "self", ",", "charges", ")", ":", "data", "=", "{", "}", "for", "n", ",", "charge", "in", "enumerate", "(", "charges", ")", ":", "each_amount", "=", "Decimal", "(", "charge", "[", "'each_amount'", "]", ")", "each_am...
Charges should be a list of charges to execute immediately. Each value in the charges diectionary should be a dictionary with the following keys: code Your code for this charge. This code will be displayed in the user's invoice and is limited to 36 characters. ...
[ "Charges", "should", "be", "a", "list", "of", "charges", "to", "execute", "immediately", ".", "Each", "value", "in", "the", "charges", "diectionary", "should", "be", "a", "dictionary", "with", "the", "following", "keys", ":" ]
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L507-L542
SeanOC/sharpy
sharpy/product.py
Item.set
def set(self, quantity): ''' Set the item's quantity to the passed in amount. If nothing is passed in, a quantity of 1 is assumed. If a decimal value is passsed in, it is rounded to the 4th decimal place as that is the level of precision which the Cheddar API accepts. ...
python
def set(self, quantity): ''' Set the item's quantity to the passed in amount. If nothing is passed in, a quantity of 1 is assumed. If a decimal value is passsed in, it is rounded to the 4th decimal place as that is the level of precision which the Cheddar API accepts. ...
[ "def", "set", "(", "self", ",", "quantity", ")", ":", "data", "=", "{", "}", "data", "[", "'quantity'", "]", "=", "self", ".", "_normalize_quantity", "(", "quantity", ")", "response", "=", "self", ".", "subscription", ".", "customer", ".", "product", "...
Set the item's quantity to the passed in amount. If nothing is passed in, a quantity of 1 is assumed. If a decimal value is passsed in, it is rounded to the 4th decimal place as that is the level of precision which the Cheddar API accepts.
[ "Set", "the", "item", "s", "quantity", "to", "the", "passed", "in", "amount", ".", "If", "nothing", "is", "passed", "in", "a", "quantity", "of", "1", "is", "assumed", ".", "If", "a", "decimal", "value", "is", "passsed", "in", "it", "is", "rounded", "...
train
https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L746-L766
rliebz/whoswho
whoswho/model.py
Name.deep_compare
def deep_compare(self, other, settings): """ Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return bool: whether the two names are compatible """ ...
python
def deep_compare(self, other, settings): """ Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return bool: whether the two names are compatible """ ...
[ "def", "deep_compare", "(", "self", ",", "other", ",", "settings", ")", ":", "if", "not", "self", ".", "_is_compatible_with", "(", "other", ")", ":", "return", "False", "first", ",", "middle", ",", "last", "=", "self", ".", "_compare_components", "(", "o...
Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return bool: whether the two names are compatible
[ "Compares", "each", "field", "of", "the", "name", "one", "at", "a", "time", "to", "see", "if", "they", "match", ".", "Each", "name", "field", "has", "context", "-", "specific", "comparison", "logic", "." ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L25-L39
rliebz/whoswho
whoswho/model.py
Name.ratio_deep_compare
def ratio_deep_compare(self, other, settings): """ Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return int: sequence ratio match (out of 100) """ ...
python
def ratio_deep_compare(self, other, settings): """ Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return int: sequence ratio match (out of 100) """ ...
[ "def", "ratio_deep_compare", "(", "self", ",", "other", ",", "settings", ")", ":", "if", "not", "self", ".", "_is_compatible_with", "(", "other", ")", ":", "return", "0", "first", ",", "middle", ",", "last", "=", "self", ".", "_compare_components", "(", ...
Compares each field of the name one at a time to see if they match. Each name field has context-specific comparison logic. :param Name other: other Name for comparison :return int: sequence ratio match (out of 100)
[ "Compares", "each", "field", "of", "the", "name", "one", "at", "a", "time", "to", "see", "if", "they", "match", ".", "Each", "name", "field", "has", "context", "-", "specific", "comparison", "logic", "." ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L41-L63
rliebz/whoswho
whoswho/model.py
Name._is_compatible_with
def _is_compatible_with(self, other): """ Return True if names are not incompatible. This checks that the gender of titles and compatibility of suffixes """ title = self._compare_title(other) suffix = self._compare_suffix(other) return title and suffix
python
def _is_compatible_with(self, other): """ Return True if names are not incompatible. This checks that the gender of titles and compatibility of suffixes """ title = self._compare_title(other) suffix = self._compare_suffix(other) return title and suffix
[ "def", "_is_compatible_with", "(", "self", ",", "other", ")", ":", "title", "=", "self", ".", "_compare_title", "(", "other", ")", "suffix", "=", "self", ".", "_compare_suffix", "(", "other", ")", "return", "title", "and", "suffix" ]
Return True if names are not incompatible. This checks that the gender of titles and compatibility of suffixes
[ "Return", "True", "if", "names", "are", "not", "incompatible", "." ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L65-L75
rliebz/whoswho
whoswho/model.py
Name._compare_title
def _compare_title(self, other): """Return False if titles have different gender associations""" # If title is omitted, assume a match if not self.title or not other.title: return True titles = set(self.title_list + other.title_list) return not (titles & MALE_TITLE...
python
def _compare_title(self, other): """Return False if titles have different gender associations""" # If title is omitted, assume a match if not self.title or not other.title: return True titles = set(self.title_list + other.title_list) return not (titles & MALE_TITLE...
[ "def", "_compare_title", "(", "self", ",", "other", ")", ":", "# If title is omitted, assume a match", "if", "not", "self", ".", "title", "or", "not", "other", ".", "title", ":", "return", "True", "titles", "=", "set", "(", "self", ".", "title_list", "+", ...
Return False if titles have different gender associations
[ "Return", "False", "if", "titles", "have", "different", "gender", "associations" ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L77-L86
rliebz/whoswho
whoswho/model.py
Name._compare_suffix
def _compare_suffix(self, other): """Return false if suffixes are mutually exclusive""" # If suffix is omitted, assume a match if not self.suffix or not other.suffix: return True # Check if more than one unique suffix suffix_set = set(self.suffix_list + other.suffix...
python
def _compare_suffix(self, other): """Return false if suffixes are mutually exclusive""" # If suffix is omitted, assume a match if not self.suffix or not other.suffix: return True # Check if more than one unique suffix suffix_set = set(self.suffix_list + other.suffix...
[ "def", "_compare_suffix", "(", "self", ",", "other", ")", ":", "# If suffix is omitted, assume a match", "if", "not", "self", ".", "suffix", "or", "not", "other", ".", "suffix", ":", "return", "True", "# Check if more than one unique suffix", "suffix_set", "=", "set...
Return false if suffixes are mutually exclusive
[ "Return", "false", "if", "suffixes", "are", "mutually", "exclusive" ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L88-L103
rliebz/whoswho
whoswho/model.py
Name._compare_components
def _compare_components(self, other, settings, ratio=False): """Return comparison of first, middle, and last components""" first = compare_name_component( self.first_list, other.first_list, settings['first'], ratio, ) if settings['check_n...
python
def _compare_components(self, other, settings, ratio=False): """Return comparison of first, middle, and last components""" first = compare_name_component( self.first_list, other.first_list, settings['first'], ratio, ) if settings['check_n...
[ "def", "_compare_components", "(", "self", ",", "other", ",", "settings", ",", "ratio", "=", "False", ")", ":", "first", "=", "compare_name_component", "(", "self", ".", "first_list", ",", "other", ".", "first_list", ",", "settings", "[", "'first'", "]", "...
Return comparison of first, middle, and last components
[ "Return", "comparison", "of", "first", "middle", "and", "last", "components" ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L105-L159
rliebz/whoswho
whoswho/model.py
Name._determine_weights
def _determine_weights(self, other, settings): """ Return weights of name components based on whether or not they were omitted """ # TODO: Reduce weight for matches by prefix or initials first_is_used = settings['first']['required'] or \ self.first and other...
python
def _determine_weights(self, other, settings): """ Return weights of name components based on whether or not they were omitted """ # TODO: Reduce weight for matches by prefix or initials first_is_used = settings['first']['required'] or \ self.first and other...
[ "def", "_determine_weights", "(", "self", ",", "other", ",", "settings", ")", ":", "# TODO: Reduce weight for matches by prefix or initials", "first_is_used", "=", "settings", "[", "'first'", "]", "[", "'required'", "]", "or", "self", ".", "first", "and", "other", ...
Return weights of name components based on whether or not they were omitted
[ "Return", "weights", "of", "name", "components", "based", "on", "whether", "or", "not", "they", "were", "omitted" ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/model.py#L161-L181
bohea/sanic-limiter
sanic_limiter/extension.py
Limiter.init_app
def init_app(self, app): """ :param app: :class:`sanic.Sanic` instance to rate limit. """ self.enabled = app.config.setdefault(C.ENABLED, True) self._swallow_errors = app.config.setdefault( C.SWALLOW_ERRORS, self._swallow_errors ) self._storage_options...
python
def init_app(self, app): """ :param app: :class:`sanic.Sanic` instance to rate limit. """ self.enabled = app.config.setdefault(C.ENABLED, True) self._swallow_errors = app.config.setdefault( C.SWALLOW_ERRORS, self._swallow_errors ) self._storage_options...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "self", ".", "enabled", "=", "app", ".", "config", ".", "setdefault", "(", "C", ".", "ENABLED", ",", "True", ")", "self", ".", "_swallow_errors", "=", "app", ".", "config", ".", "setdefault", "(",...
:param app: :class:`sanic.Sanic` instance to rate limit.
[ ":", "param", "app", ":", ":", "class", ":", "sanic", ".", "Sanic", "instance", "to", "rate", "limit", "." ]
train
https://github.com/bohea/sanic-limiter/blob/54c9fc4a3a3f1a9bb69367262637d07701ae5694/sanic_limiter/extension.py#L116-L147
bohea/sanic-limiter
sanic_limiter/extension.py
Limiter.limit
def limit(self, limit_value, key_func=None, per_method=False, methods=None, error_message=None, exempt_when=None): """ decorator to be used for rate limiting individual routes. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-stri...
python
def limit(self, limit_value, key_func=None, per_method=False, methods=None, error_message=None, exempt_when=None): """ decorator to be used for rate limiting individual routes. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-stri...
[ "def", "limit", "(", "self", ",", "limit_value", ",", "key_func", "=", "None", ",", "per_method", "=", "False", ",", "methods", "=", "None", ",", "error_message", "=", "None", ",", "exempt_when", "=", "None", ")", ":", "return", "self", ".", "__limit_dec...
decorator to be used for rate limiting individual routes. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-string` for more details. :param function key_func: function/lambda to extract the unique identifier for the rate limit. defaults to rem...
[ "decorator", "to", "be", "used", "for", "rate", "limiting", "individual", "routes", "." ]
train
https://github.com/bohea/sanic-limiter/blob/54c9fc4a3a3f1a9bb69367262637d07701ae5694/sanic_limiter/extension.py#L297-L316
bohea/sanic-limiter
sanic_limiter/extension.py
Limiter.shared_limit
def shared_limit(self, limit_value, scope, key_func=None, error_message=None, exempt_when=None): """ decorator to be applied to multiple routes sharing the same rate limit. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-s...
python
def shared_limit(self, limit_value, scope, key_func=None, error_message=None, exempt_when=None): """ decorator to be applied to multiple routes sharing the same rate limit. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-s...
[ "def", "shared_limit", "(", "self", ",", "limit_value", ",", "scope", ",", "key_func", "=", "None", ",", "error_message", "=", "None", ",", "exempt_when", "=", "None", ")", ":", "return", "self", ".", "__limit_decorator", "(", "limit_value", ",", "key_func",...
decorator to be applied to multiple routes sharing the same rate limit. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-string` for more details. :param scope: a string or callable that returns a string for defining the rate limiting scope. ...
[ "decorator", "to", "be", "applied", "to", "multiple", "routes", "sharing", "the", "same", "rate", "limit", "." ]
train
https://github.com/bohea/sanic-limiter/blob/54c9fc4a3a3f1a9bb69367262637d07701ae5694/sanic_limiter/extension.py#L318-L335
bohea/sanic-limiter
sanic_limiter/extension.py
Limiter.reset
def reset(self): """ resets the storage if it supports being reset """ try: self._storage.reset() self.logger.info("Storage has been reset and all limits cleared") except NotImplementedError: self.logger.warning("This storage type does not supp...
python
def reset(self): """ resets the storage if it supports being reset """ try: self._storage.reset() self.logger.info("Storage has been reset and all limits cleared") except NotImplementedError: self.logger.warning("This storage type does not supp...
[ "def", "reset", "(", "self", ")", ":", "try", ":", "self", ".", "_storage", ".", "reset", "(", ")", "self", ".", "logger", ".", "info", "(", "\"Storage has been reset and all limits cleared\"", ")", "except", "NotImplementedError", ":", "self", ".", "logger", ...
resets the storage if it supports being reset
[ "resets", "the", "storage", "if", "it", "supports", "being", "reset" ]
train
https://github.com/bohea/sanic-limiter/blob/54c9fc4a3a3f1a9bb69367262637d07701ae5694/sanic_limiter/extension.py#L358-L366
karan/HackerNewsAPI
hn/utils.py
get_soup
def get_soup(page=''): """ Returns a bs4 object of the page requested """ content = requests.get('%s/%s' % (BASE_URL, page)).text return BeautifulSoup(content)
python
def get_soup(page=''): """ Returns a bs4 object of the page requested """ content = requests.get('%s/%s' % (BASE_URL, page)).text return BeautifulSoup(content)
[ "def", "get_soup", "(", "page", "=", "''", ")", ":", "content", "=", "requests", ".", "get", "(", "'%s/%s'", "%", "(", "BASE_URL", ",", "page", ")", ")", ".", "text", "return", "BeautifulSoup", "(", "content", ")" ]
Returns a bs4 object of the page requested
[ "Returns", "a", "bs4", "object", "of", "the", "page", "requested" ]
train
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/utils.py#L9-L14
rliebz/whoswho
whoswho/who.py
match
def match(fullname1, fullname2, strictness='default', options=None): """ Takes two names and returns true if they describe the same person. :param string fullname1: first human name :param string fullname2: second human name :param string strictness: strictness settings to use :param dict optio...
python
def match(fullname1, fullname2, strictness='default', options=None): """ Takes two names and returns true if they describe the same person. :param string fullname1: first human name :param string fullname2: second human name :param string strictness: strictness settings to use :param dict optio...
[ "def", "match", "(", "fullname1", ",", "fullname2", ",", "strictness", "=", "'default'", ",", "options", "=", "None", ")", ":", "if", "options", "is", "not", "None", ":", "settings", "=", "deepcopy", "(", "SETTINGS", "[", "strictness", "]", ")", "deep_up...
Takes two names and returns true if they describe the same person. :param string fullname1: first human name :param string fullname2: second human name :param string strictness: strictness settings to use :param dict options: custom strictness settings updates :return bool: the names match
[ "Takes", "two", "names", "and", "returns", "true", "if", "they", "describe", "the", "same", "person", "." ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/who.py#L8-L28
rliebz/whoswho
whoswho/who.py
ratio
def ratio(fullname1, fullname2, strictness='default', options=None): """ Takes two names and returns true if they describe the same person. Uses difflib's sequence matching on a per-field basis for names :param string fullname1: first human name :param string fullname2: second human name :param...
python
def ratio(fullname1, fullname2, strictness='default', options=None): """ Takes two names and returns true if they describe the same person. Uses difflib's sequence matching on a per-field basis for names :param string fullname1: first human name :param string fullname2: second human name :param...
[ "def", "ratio", "(", "fullname1", ",", "fullname2", ",", "strictness", "=", "'default'", ",", "options", "=", "None", ")", ":", "if", "options", "is", "not", "None", ":", "settings", "=", "deepcopy", "(", "SETTINGS", "[", "strictness", "]", ")", "deep_up...
Takes two names and returns true if they describe the same person. Uses difflib's sequence matching on a per-field basis for names :param string fullname1: first human name :param string fullname2: second human name :param string strictness: strictness settings to use :param dict options: custom st...
[ "Takes", "two", "names", "and", "returns", "true", "if", "they", "describe", "the", "same", "person", ".", "Uses", "difflib", "s", "sequence", "matching", "on", "a", "per", "-", "field", "basis", "for", "names" ]
train
https://github.com/rliebz/whoswho/blob/0c411e418c240fcec6ea0a23d15bd003056c65d0/whoswho/who.py#L31-L52
karan/HackerNewsAPI
hn/hn.py
HN._get_zipped_rows
def _get_zipped_rows(self, soup): """ Returns all 'tr' tag rows as a list of tuples. Each tuple is for a single story. """ # the table with all submissions table = soup.findChildren('table')[2] # get all rows but last 2 rows = table.findChildren(['...
python
def _get_zipped_rows(self, soup): """ Returns all 'tr' tag rows as a list of tuples. Each tuple is for a single story. """ # the table with all submissions table = soup.findChildren('table')[2] # get all rows but last 2 rows = table.findChildren(['...
[ "def", "_get_zipped_rows", "(", "self", ",", "soup", ")", ":", "# the table with all submissions\r", "table", "=", "soup", ".", "findChildren", "(", "'table'", ")", "[", "2", "]", "# get all rows but last 2\r", "rows", "=", "table", ".", "findChildren", "(", "["...
Returns all 'tr' tag rows as a list of tuples. Each tuple is for a single story.
[ "Returns", "all", "tr", "tag", "rows", "as", "a", "list", "of", "tuples", ".", "Each", "tuple", "is", "for", "a", "single", "story", "." ]
train
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/hn.py#L36-L55
karan/HackerNewsAPI
hn/hn.py
HN._build_story
def _build_story(self, all_rows): """ Builds and returns a list of stories (dicts) from the passed source. """ # list to hold all stories all_stories = [] for (info, detail) in all_rows: #-- Get the into about a story --# # split in 3 c...
python
def _build_story(self, all_rows): """ Builds and returns a list of stories (dicts) from the passed source. """ # list to hold all stories all_stories = [] for (info, detail) in all_rows: #-- Get the into about a story --# # split in 3 c...
[ "def", "_build_story", "(", "self", ",", "all_rows", ")", ":", "# list to hold all stories\r", "all_stories", "=", "[", "]", "for", "(", "info", ",", "detail", ")", "in", "all_rows", ":", "#-- Get the into about a story --#\r", "# split in 3 cells\r", "info_cells", ...
Builds and returns a list of stories (dicts) from the passed source.
[ "Builds", "and", "returns", "a", "list", "of", "stories", "(", "dicts", ")", "from", "the", "passed", "source", "." ]
train
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/hn.py#L57-L138
karan/HackerNewsAPI
hn/hn.py
HN.get_stories
def get_stories(self, story_type='', limit=30): """ Yields a list of stories from the passed page of HN. 'story_type' can be: \t'' = top stories (homepage) (default) \t'news2' = page 2 of top stories \t'newest' = most recent stories \t'best' = best...
python
def get_stories(self, story_type='', limit=30): """ Yields a list of stories from the passed page of HN. 'story_type' can be: \t'' = top stories (homepage) (default) \t'news2' = page 2 of top stories \t'newest' = most recent stories \t'best' = best...
[ "def", "get_stories", "(", "self", ",", "story_type", "=", "''", ",", "limit", "=", "30", ")", ":", "if", "limit", "is", "None", "or", "limit", "<", "1", "or", "limit", ">", "30", ":", "# we need at least 30 items\r", "limit", "=", "30", "stories_found",...
Yields a list of stories from the passed page of HN. 'story_type' can be: \t'' = top stories (homepage) (default) \t'news2' = page 2 of top stories \t'newest' = most recent stories \t'best' = best stories 'limit' is the number of stories required from the...
[ "Yields", "a", "list", "of", "stories", "from", "the", "passed", "page", "of", "HN", ".", "story_type", "can", "be", ":", "\\", "t", "=", "top", "stories", "(", "homepage", ")", "(", "default", ")", "\\", "t", "news2", "=", "page", "2", "of", "top"...
train
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/hn.py#L140-L175
karan/HackerNewsAPI
hn/hn.py
HN.get_leaders
def get_leaders(self, limit=10): """ Return the leaders of Hacker News """ if limit is None: limit = 10 soup = get_soup('leaders') table = soup.find('table') leaders_table = table.find_all('table')[1] listleaders = leaders_table.find_all('tr')[2:] ...
python
def get_leaders(self, limit=10): """ Return the leaders of Hacker News """ if limit is None: limit = 10 soup = get_soup('leaders') table = soup.find('table') leaders_table = table.find_all('table')[1] listleaders = leaders_table.find_all('tr')[2:] ...
[ "def", "get_leaders", "(", "self", ",", "limit", "=", "10", ")", ":", "if", "limit", "is", "None", ":", "limit", "=", "10", "soup", "=", "get_soup", "(", "'leaders'", ")", "table", "=", "soup", ".", "find", "(", "'table'", ")", "leaders_table", "=", ...
Return the leaders of Hacker News
[ "Return", "the", "leaders", "of", "Hacker", "News" ]
train
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/hn.py#L177-L191