partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | InvoiceController.update_status | Updates the status of this invoice based upon the total
payments. | registrasion/controllers/invoice.py | def update_status(self):
''' Updates the status of this invoice based upon the total
payments.'''
old_status = self.invoice.status
total_paid = self.invoice.total_payments()
num_payments = commerce.PaymentBase.objects.filter(
invoice=self.invoice,
).count()
... | def update_status(self):
''' Updates the status of this invoice based upon the total
payments.'''
old_status = self.invoice.status
total_paid = self.invoice.total_payments()
num_payments = commerce.PaymentBase.objects.filter(
invoice=self.invoice,
).count()
... | [
"Updates",
"the",
"status",
"of",
"this",
"invoice",
"based",
"upon",
"the",
"total",
"payments",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L271-L318 | [
"def",
"update_status",
"(",
"self",
")",
":",
"old_status",
"=",
"self",
".",
"invoice",
".",
"status",
"total_paid",
"=",
"self",
".",
"invoice",
".",
"total_payments",
"(",
")",
"num_payments",
"=",
"commerce",
".",
"PaymentBase",
".",
"objects",
".",
"... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController._mark_paid | Marks the invoice as paid, and updates the attached cart if
necessary. | registrasion/controllers/invoice.py | def _mark_paid(self):
''' Marks the invoice as paid, and updates the attached cart if
necessary. '''
cart = self.invoice.cart
if cart:
cart.status = commerce.Cart.STATUS_PAID
cart.save()
self.invoice.status = commerce.Invoice.STATUS_PAID
self.invoi... | def _mark_paid(self):
''' Marks the invoice as paid, and updates the attached cart if
necessary. '''
cart = self.invoice.cart
if cart:
cart.status = commerce.Cart.STATUS_PAID
cart.save()
self.invoice.status = commerce.Invoice.STATUS_PAID
self.invoi... | [
"Marks",
"the",
"invoice",
"as",
"paid",
"and",
"updates",
"the",
"attached",
"cart",
"if",
"necessary",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L320-L328 | [
"def",
"_mark_paid",
"(",
"self",
")",
":",
"cart",
"=",
"self",
".",
"invoice",
".",
"cart",
"if",
"cart",
":",
"cart",
".",
"status",
"=",
"commerce",
".",
"Cart",
".",
"STATUS_PAID",
"cart",
".",
"save",
"(",
")",
"self",
".",
"invoice",
".",
"s... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController._mark_refunded | Marks the invoice as refunded, and updates the attached cart if
necessary. | registrasion/controllers/invoice.py | def _mark_refunded(self):
''' Marks the invoice as refunded, and updates the attached cart if
necessary. '''
self._release_cart()
self.invoice.status = commerce.Invoice.STATUS_REFUNDED
self.invoice.save() | def _mark_refunded(self):
''' Marks the invoice as refunded, and updates the attached cart if
necessary. '''
self._release_cart()
self.invoice.status = commerce.Invoice.STATUS_REFUNDED
self.invoice.save() | [
"Marks",
"the",
"invoice",
"as",
"refunded",
"and",
"updates",
"the",
"attached",
"cart",
"if",
"necessary",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L330-L335 | [
"def",
"_mark_refunded",
"(",
"self",
")",
":",
"self",
".",
"_release_cart",
"(",
")",
"self",
".",
"invoice",
".",
"status",
"=",
"commerce",
".",
"Invoice",
".",
"STATUS_REFUNDED",
"self",
".",
"invoice",
".",
"save",
"(",
")"
] | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController._mark_void | Marks the invoice as refunded, and updates the attached cart if
necessary. | registrasion/controllers/invoice.py | def _mark_void(self):
''' Marks the invoice as refunded, and updates the attached cart if
necessary. '''
self.invoice.status = commerce.Invoice.STATUS_VOID
self.invoice.save() | def _mark_void(self):
''' Marks the invoice as refunded, and updates the attached cart if
necessary. '''
self.invoice.status = commerce.Invoice.STATUS_VOID
self.invoice.save() | [
"Marks",
"the",
"invoice",
"as",
"refunded",
"and",
"updates",
"the",
"attached",
"cart",
"if",
"necessary",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L337-L341 | [
"def",
"_mark_void",
"(",
"self",
")",
":",
"self",
".",
"invoice",
".",
"status",
"=",
"commerce",
".",
"Invoice",
".",
"STATUS_VOID",
"self",
".",
"invoice",
".",
"save",
"(",
")"
] | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController._invoice_matches_cart | Returns true if there is no cart, or if the revision of this
invoice matches the current revision of the cart. | registrasion/controllers/invoice.py | def _invoice_matches_cart(self):
''' Returns true if there is no cart, or if the revision of this
invoice matches the current revision of the cart. '''
self._refresh()
cart = self.invoice.cart
if not cart:
return True
return cart.revision == self.invoice.ca... | def _invoice_matches_cart(self):
''' Returns true if there is no cart, or if the revision of this
invoice matches the current revision of the cart. '''
self._refresh()
cart = self.invoice.cart
if not cart:
return True
return cart.revision == self.invoice.ca... | [
"Returns",
"true",
"if",
"there",
"is",
"no",
"cart",
"or",
"if",
"the",
"revision",
"of",
"this",
"invoice",
"matches",
"the",
"current",
"revision",
"of",
"the",
"cart",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L343-L353 | [
"def",
"_invoice_matches_cart",
"(",
"self",
")",
":",
"self",
".",
"_refresh",
"(",
")",
"cart",
"=",
"self",
".",
"invoice",
".",
"cart",
"if",
"not",
"cart",
":",
"return",
"True",
"return",
"cart",
".",
"revision",
"==",
"self",
".",
"invoice",
"."... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController.update_validity | Voids this invoice if the attached cart is no longer valid because
the cart revision has changed, or the reservations have expired. | registrasion/controllers/invoice.py | def update_validity(self):
''' Voids this invoice if the attached cart is no longer valid because
the cart revision has changed, or the reservations have expired. '''
is_valid = self._invoice_matches_cart()
cart = self.invoice.cart
if self.invoice.is_unpaid and is_valid and cart... | def update_validity(self):
''' Voids this invoice if the attached cart is no longer valid because
the cart revision has changed, or the reservations have expired. '''
is_valid = self._invoice_matches_cart()
cart = self.invoice.cart
if self.invoice.is_unpaid and is_valid and cart... | [
"Voids",
"this",
"invoice",
"if",
"the",
"attached",
"cart",
"is",
"no",
"longer",
"valid",
"because",
"the",
"cart",
"revision",
"has",
"changed",
"or",
"the",
"reservations",
"have",
"expired",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L361-L378 | [
"def",
"update_validity",
"(",
"self",
")",
":",
"is_valid",
"=",
"self",
".",
"_invoice_matches_cart",
"(",
")",
"cart",
"=",
"self",
".",
"invoice",
".",
"cart",
"if",
"self",
".",
"invoice",
".",
"is_unpaid",
"and",
"is_valid",
"and",
"cart",
":",
"tr... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController.void | Voids the invoice if it is valid to do so. | registrasion/controllers/invoice.py | def void(self):
''' Voids the invoice if it is valid to do so. '''
if self.invoice.total_payments() > 0:
raise ValidationError("Invoices with payments must be refunded.")
elif self.invoice.is_refunded:
raise ValidationError("Refunded invoices may not be voided.")
... | def void(self):
''' Voids the invoice if it is valid to do so. '''
if self.invoice.total_payments() > 0:
raise ValidationError("Invoices with payments must be refunded.")
elif self.invoice.is_refunded:
raise ValidationError("Refunded invoices may not be voided.")
... | [
"Voids",
"the",
"invoice",
"if",
"it",
"is",
"valid",
"to",
"do",
"so",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L380-L389 | [
"def",
"void",
"(",
"self",
")",
":",
"if",
"self",
".",
"invoice",
".",
"total_payments",
"(",
")",
">",
"0",
":",
"raise",
"ValidationError",
"(",
"\"Invoices with payments must be refunded.\"",
")",
"elif",
"self",
".",
"invoice",
".",
"is_refunded",
":",
... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController.refund | Refunds the invoice by generating a CreditNote for the value of
all of the payments against the cart.
The invoice is marked as refunded, and the underlying cart is marked
as released. | registrasion/controllers/invoice.py | def refund(self):
''' Refunds the invoice by generating a CreditNote for the value of
all of the payments against the cart.
The invoice is marked as refunded, and the underlying cart is marked
as released.
'''
if self.invoice.is_void:
raise ValidationError(... | def refund(self):
''' Refunds the invoice by generating a CreditNote for the value of
all of the payments against the cart.
The invoice is marked as refunded, and the underlying cart is marked
as released.
'''
if self.invoice.is_void:
raise ValidationError(... | [
"Refunds",
"the",
"invoice",
"by",
"generating",
"a",
"CreditNote",
"for",
"the",
"value",
"of",
"all",
"of",
"the",
"payments",
"against",
"the",
"cart",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L392-L412 | [
"def",
"refund",
"(",
"self",
")",
":",
"if",
"self",
".",
"invoice",
".",
"is_void",
":",
"raise",
"ValidationError",
"(",
"\"Void invoices cannot be refunded\"",
")",
"# Raises a credit note fot the value of the invoice.",
"amount",
"=",
"self",
".",
"invoice",
".",... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController.email | Sends out an e-mail notifying the user about something to do
with that invoice. | registrasion/controllers/invoice.py | def email(cls, invoice, kind):
''' Sends out an e-mail notifying the user about something to do
with that invoice. '''
context = {
"invoice": invoice,
}
send_email([invoice.user.email], kind, context=context) | def email(cls, invoice, kind):
''' Sends out an e-mail notifying the user about something to do
with that invoice. '''
context = {
"invoice": invoice,
}
send_email([invoice.user.email], kind, context=context) | [
"Sends",
"out",
"an",
"e",
"-",
"mail",
"notifying",
"the",
"user",
"about",
"something",
"to",
"do",
"with",
"that",
"invoice",
"."
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L415-L423 | [
"def",
"email",
"(",
"cls",
",",
"invoice",
",",
"kind",
")",
":",
"context",
"=",
"{",
"\"invoice\"",
":",
"invoice",
",",
"}",
"send_email",
"(",
"[",
"invoice",
".",
"user",
".",
"email",
"]",
",",
"kind",
",",
"context",
"=",
"context",
")"
] | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | InvoiceController.email_on_invoice_change | Sends out all of the necessary notifications that the status of the
invoice has changed to:
- Invoice is now paid
- Invoice is now refunded | registrasion/controllers/invoice.py | def email_on_invoice_change(cls, invoice, old_status, new_status):
''' Sends out all of the necessary notifications that the status of the
invoice has changed to:
- Invoice is now paid
- Invoice is now refunded
'''
# The statuses that we don't care about.
silen... | def email_on_invoice_change(cls, invoice, old_status, new_status):
''' Sends out all of the necessary notifications that the status of the
invoice has changed to:
- Invoice is now paid
- Invoice is now refunded
'''
# The statuses that we don't care about.
silen... | [
"Sends",
"out",
"all",
"of",
"the",
"necessary",
"notifications",
"that",
"the",
"status",
"of",
"the",
"invoice",
"has",
"changed",
"to",
":"
] | chrisjrn/registrasion | python | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L433-L453 | [
"def",
"email_on_invoice_change",
"(",
"cls",
",",
"invoice",
",",
"old_status",
",",
"new_status",
")",
":",
"# The statuses that we don't care about.",
"silent_status",
"=",
"[",
"commerce",
".",
"Invoice",
".",
"STATUS_VOID",
",",
"commerce",
".",
"Invoice",
".",... | 461d5846c6f9f3b7099322a94f5d9911564448e4 |
test | GenData.update | Update the object with new data. | genesis/data.py | def update(self, data):
"""Update the object with new data."""
fields = [
'id',
'status',
'type',
'persistence',
'date_start',
'date_finish',
'date_created',
'date_modified',
'checksum',
... | def update(self, data):
"""Update the object with new data."""
fields = [
'id',
'status',
'type',
'persistence',
'date_start',
'date_finish',
'date_created',
'date_modified',
'checksum',
... | [
"Update",
"the",
"object",
"with",
"new",
"data",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/data.py#L15-L47 | [
"def",
"update",
"(",
"self",
",",
"data",
")",
":",
"fields",
"=",
"[",
"'id'",
",",
"'status'",
",",
"'type'",
",",
"'persistence'",
",",
"'date_start'",
",",
"'date_finish'",
",",
"'date_created'",
",",
"'date_modified'",
",",
"'checksum'",
",",
"'process... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | GenData._flatten_field | Reduce dicts of dicts to dot separated keys. | genesis/data.py | def _flatten_field(self, field, schema, path):
"""Reduce dicts of dicts to dot separated keys."""
flat = {}
for field_schema, fields, path in iterate_schema(field, schema, path):
name = field_schema['name']
typ = field_schema['type']
label = field_schema['labe... | def _flatten_field(self, field, schema, path):
"""Reduce dicts of dicts to dot separated keys."""
flat = {}
for field_schema, fields, path in iterate_schema(field, schema, path):
name = field_schema['name']
typ = field_schema['type']
label = field_schema['labe... | [
"Reduce",
"dicts",
"of",
"dicts",
"to",
"dot",
"separated",
"keys",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/data.py#L49-L59 | [
"def",
"_flatten_field",
"(",
"self",
",",
"field",
",",
"schema",
",",
"path",
")",
":",
"flat",
"=",
"{",
"}",
"for",
"field_schema",
",",
"fields",
",",
"path",
"in",
"iterate_schema",
"(",
"field",
",",
"schema",
",",
"path",
")",
":",
"name",
"=... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | GenData.print_annotation | Print annotation "key: value" pairs to standard output. | genesis/data.py | def print_annotation(self):
"""Print annotation "key: value" pairs to standard output."""
for path, ann in self.annotation.items():
print("{}: {}".format(path, ann['value'])) | def print_annotation(self):
"""Print annotation "key: value" pairs to standard output."""
for path, ann in self.annotation.items():
print("{}: {}".format(path, ann['value'])) | [
"Print",
"annotation",
"key",
":",
"value",
"pairs",
"to",
"standard",
"output",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/data.py#L61-L64 | [
"def",
"print_annotation",
"(",
"self",
")",
":",
"for",
"path",
",",
"ann",
"in",
"self",
".",
"annotation",
".",
"items",
"(",
")",
":",
"print",
"(",
"\"{}: {}\"",
".",
"format",
"(",
"path",
",",
"ann",
"[",
"'value'",
"]",
")",
")"
] | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | GenData.print_downloads | Print file fields to standard output. | genesis/data.py | def print_downloads(self):
"""Print file fields to standard output."""
for path, ann in self.annotation.items():
if path.startswith('output') and ann['type'] == 'basic:file:':
print("{}: {}".format(path, ann['value']['file'])) | def print_downloads(self):
"""Print file fields to standard output."""
for path, ann in self.annotation.items():
if path.startswith('output') and ann['type'] == 'basic:file:':
print("{}: {}".format(path, ann['value']['file'])) | [
"Print",
"file",
"fields",
"to",
"standard",
"output",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/data.py#L66-L70 | [
"def",
"print_downloads",
"(",
"self",
")",
":",
"for",
"path",
",",
"ann",
"in",
"self",
".",
"annotation",
".",
"items",
"(",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'output'",
")",
"and",
"ann",
"[",
"'type'",
"]",
"==",
"'basic:file:'",
... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | GenData.download | Download a file.
:param field: file field to download
:type field: string
:rtype: a file handle | genesis/data.py | def download(self, field):
"""Download a file.
:param field: file field to download
:type field: string
:rtype: a file handle
"""
if not field.startswith('output'):
raise ValueError("Only processor results (output.* fields) can be downloaded")
if fi... | def download(self, field):
"""Download a file.
:param field: file field to download
:type field: string
:rtype: a file handle
"""
if not field.startswith('output'):
raise ValueError("Only processor results (output.* fields) can be downloaded")
if fi... | [
"Download",
"a",
"file",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/data.py#L72-L90 | [
"def",
"download",
"(",
"self",
",",
"field",
")",
":",
"if",
"not",
"field",
".",
"startswith",
"(",
"'output'",
")",
":",
"raise",
"ValueError",
"(",
"\"Only processor results (output.* fields) can be downloaded\"",
")",
"if",
"field",
"not",
"in",
"self",
"."... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Issue.add_arguments | Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args. | asana_hub/actions/issue.py | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-t... | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-t... | [
"Add",
"arguments",
"to",
"the",
"parser",
"for",
"collection",
"in",
"app",
".",
"args",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/actions/issue.py#L19-L47 | [
"def",
"add_arguments",
"(",
"cls",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'-t'",
",",
"'--title'",
",",
"action",
"=",
"'store'",
",",
"nargs",
"=",
"'?'",
",",
"const",
"=",
"''",
",",
"dest",
"=",
"'title'",
",",
"help",
"="... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | Genesis.projects | Return a list :obj:`GenProject` projects.
:rtype: list of :obj:`GenProject` projects | genesis/genesis.py | def projects(self):
"""Return a list :obj:`GenProject` projects.
:rtype: list of :obj:`GenProject` projects
"""
if not ('projects' in self.cache and self.cache['projects']):
self.cache['projects'] = {c['id']: GenProject(c, self) for c in self.api.case.get()['objects']}
... | def projects(self):
"""Return a list :obj:`GenProject` projects.
:rtype: list of :obj:`GenProject` projects
"""
if not ('projects' in self.cache and self.cache['projects']):
self.cache['projects'] = {c['id']: GenProject(c, self) for c in self.api.case.get()['objects']}
... | [
"Return",
"a",
"list",
":",
"obj",
":",
"GenProject",
"projects",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L40-L49 | [
"def",
"projects",
"(",
"self",
")",
":",
"if",
"not",
"(",
"'projects'",
"in",
"self",
".",
"cache",
"and",
"self",
".",
"cache",
"[",
"'projects'",
"]",
")",
":",
"self",
".",
"cache",
"[",
"'projects'",
"]",
"=",
"{",
"c",
"[",
"'id'",
"]",
":... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.project_data | Return a list of Data objects for given project.
:param project: ObjectId or slug of Genesis project
:type project: string
:rtype: list of Data objects | genesis/genesis.py | def project_data(self, project):
"""Return a list of Data objects for given project.
:param project: ObjectId or slug of Genesis project
:type project: string
:rtype: list of Data objects
"""
projobjects = self.cache['project_objects']
objects = self.cache['obje... | def project_data(self, project):
"""Return a list of Data objects for given project.
:param project: ObjectId or slug of Genesis project
:type project: string
:rtype: list of Data objects
"""
projobjects = self.cache['project_objects']
objects = self.cache['obje... | [
"Return",
"a",
"list",
"of",
"Data",
"objects",
"for",
"given",
"project",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L51-L106 | [
"def",
"project_data",
"(",
"self",
",",
"project",
")",
":",
"projobjects",
"=",
"self",
".",
"cache",
"[",
"'project_objects'",
"]",
"objects",
"=",
"self",
".",
"cache",
"[",
"'objects'",
"]",
"project_id",
"=",
"str",
"(",
"project",
")",
"if",
"not"... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.data | Query for Data object annotation. | genesis/genesis.py | def data(self, **query):
"""Query for Data object annotation."""
objects = self.cache['objects']
data = self.api.data.get(**query)['objects']
data_objects = []
for d in data:
_id = d['id']
if _id in objects:
# Update existing object
... | def data(self, **query):
"""Query for Data object annotation."""
objects = self.cache['objects']
data = self.api.data.get(**query)['objects']
data_objects = []
for d in data:
_id = d['id']
if _id in objects:
# Update existing object
... | [
"Query",
"for",
"Data",
"object",
"annotation",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L108-L157 | [
"def",
"data",
"(",
"self",
",",
"*",
"*",
"query",
")",
":",
"objects",
"=",
"self",
".",
"cache",
"[",
"'objects'",
"]",
"data",
"=",
"self",
".",
"api",
".",
"data",
".",
"get",
"(",
"*",
"*",
"query",
")",
"[",
"'objects'",
"]",
"data_objects... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.processors | Return a list of Processor objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:rtype: list of Processor objects | genesis/genesis.py | def processors(self, processor_name=None):
"""Return a list of Processor objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:rtype: list of Processor objects
"""
if processor_name:
return self.api.processor.get(name=processor_na... | def processors(self, processor_name=None):
"""Return a list of Processor objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:rtype: list of Processor objects
"""
if processor_name:
return self.api.processor.get(name=processor_na... | [
"Return",
"a",
"list",
"of",
"Processor",
"objects",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L159-L170 | [
"def",
"processors",
"(",
"self",
",",
"processor_name",
"=",
"None",
")",
":",
"if",
"processor_name",
":",
"return",
"self",
".",
"api",
".",
"processor",
".",
"get",
"(",
"name",
"=",
"processor_name",
")",
"[",
"'objects'",
"]",
"else",
":",
"return"... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.print_processor_inputs | Print processor input fields and types.
:param processor_name: Processor object name
:type processor_name: string | genesis/genesis.py | def print_processor_inputs(self, processor_name):
"""Print processor input fields and types.
:param processor_name: Processor object name
:type processor_name: string
"""
p = self.processors(processor_name=processor_name)
if len(p) == 1:
p = p[0]
el... | def print_processor_inputs(self, processor_name):
"""Print processor input fields and types.
:param processor_name: Processor object name
:type processor_name: string
"""
p = self.processors(processor_name=processor_name)
if len(p) == 1:
p = p[0]
el... | [
"Print",
"processor",
"input",
"fields",
"and",
"types",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L178-L196 | [
"def",
"print_processor_inputs",
"(",
"self",
",",
"processor_name",
")",
":",
"p",
"=",
"self",
".",
"processors",
"(",
"processor_name",
"=",
"processor_name",
")",
"if",
"len",
"(",
"p",
")",
"==",
"1",
":",
"p",
"=",
"p",
"[",
"0",
"]",
"else",
"... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.rundata | POST JSON data object to server | genesis/genesis.py | def rundata(self, strjson):
"""POST JSON data object to server"""
d = json.loads(strjson)
return self.api.data.post(d) | def rundata(self, strjson):
"""POST JSON data object to server"""
d = json.loads(strjson)
return self.api.data.post(d) | [
"POST",
"JSON",
"data",
"object",
"to",
"server"
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L198-L202 | [
"def",
"rundata",
"(",
"self",
",",
"strjson",
")",
":",
"d",
"=",
"json",
".",
"loads",
"(",
"strjson",
")",
"return",
"self",
".",
"api",
".",
"data",
".",
"post",
"(",
"d",
")"
] | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.create | Create an object of resource:
* data
* project
* processor
* trigger
* template
:param data: Object values
:type data: dict
:param resource: Resource name
:type resource: string | genesis/genesis.py | def create(self, data, resource='data'):
"""Create an object of resource:
* data
* project
* processor
* trigger
* template
:param data: Object values
:type data: dict
:param resource: Resource name
:type resource: string
"""
... | def create(self, data, resource='data'):
"""Create an object of resource:
* data
* project
* processor
* trigger
* template
:param data: Object values
:type data: dict
:param resource: Resource name
:type resource: string
"""
... | [
"Create",
"an",
"object",
"of",
"resource",
":"
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L204-L241 | [
"def",
"create",
"(",
"self",
",",
"data",
",",
"resource",
"=",
"'data'",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"if",
"not",
"isinstance",
"(",
"data",
",",
"str",
... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.upload | Upload files and data objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:param processor_name: Processor object name
:type processor_name: string
:param fields: Processor field-value pairs
:type fields: args
:rtype: HTTP Response ob... | genesis/genesis.py | def upload(self, project_id, processor_name, **fields):
"""Upload files and data objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:param processor_name: Processor object name
:type processor_name: string
:param fields: Processor field-valu... | def upload(self, project_id, processor_name, **fields):
"""Upload files and data objects.
:param project_id: ObjectId of Genesis project
:type project_id: string
:param processor_name: Processor object name
:type processor_name: string
:param fields: Processor field-valu... | [
"Upload",
"files",
"and",
"data",
"objects",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L243-L294 | [
"def",
"upload",
"(",
"self",
",",
"project_id",
",",
"processor_name",
",",
"*",
"*",
"fields",
")",
":",
"p",
"=",
"self",
".",
"processors",
"(",
"processor_name",
"=",
"processor_name",
")",
"if",
"len",
"(",
"p",
")",
"==",
"1",
":",
"p",
"=",
... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis._upload_file | Upload a single file on the platform.
File is uploaded in chunks of 1,024 bytes.
:param fn: File path
:type fn: string | genesis/genesis.py | def _upload_file(self, fn):
"""Upload a single file on the platform.
File is uploaded in chunks of 1,024 bytes.
:param fn: File path
:type fn: string
"""
size = os.path.getsize(fn)
counter = 0
base_name = os.path.basename(fn)
session_id = str(uu... | def _upload_file(self, fn):
"""Upload a single file on the platform.
File is uploaded in chunks of 1,024 bytes.
:param fn: File path
:type fn: string
"""
size = os.path.getsize(fn)
counter = 0
base_name = os.path.basename(fn)
session_id = str(uu... | [
"Upload",
"a",
"single",
"file",
"on",
"the",
"platform",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L296-L345 | [
"def",
"_upload_file",
"(",
"self",
",",
"fn",
")",
":",
"size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"fn",
")",
"counter",
"=",
"0",
"base_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fn",
")",
"session_id",
"=",
"str",
"(",
"uu... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | Genesis.download | Download files of data objects.
:param data_objects: Data object ids
:type data_objects: list of UUID strings
:param field: Download field name
:type field: string
:rtype: generator of requests.Response objects | genesis/genesis.py | def download(self, data_objects, field):
"""Download files of data objects.
:param data_objects: Data object ids
:type data_objects: list of UUID strings
:param field: Download field name
:type field: string
:rtype: generator of requests.Response objects
"""
... | def download(self, data_objects, field):
"""Download files of data objects.
:param data_objects: Data object ids
:type data_objects: list of UUID strings
:param field: Download field name
:type field: string
:rtype: generator of requests.Response objects
"""
... | [
"Download",
"files",
"of",
"data",
"objects",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/genesis.py#L347-L378 | [
"def",
"download",
"(",
"self",
",",
"data_objects",
",",
"field",
")",
":",
"if",
"not",
"field",
".",
"startswith",
"(",
"'output'",
")",
":",
"raise",
"ValueError",
"(",
"\"Only processor results (output.* fields) can be downloaded\"",
")",
"for",
"o",
"in",
... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | get_subclasses | Gets the subclasses of a class. | asana_hub/action.py | def get_subclasses(c):
"""Gets the subclasses of a class."""
subclasses = c.__subclasses__()
for d in list(subclasses):
subclasses.extend(get_subclasses(d))
return subclasses | def get_subclasses(c):
"""Gets the subclasses of a class."""
subclasses = c.__subclasses__()
for d in list(subclasses):
subclasses.extend(get_subclasses(d))
return subclasses | [
"Gets",
"the",
"subclasses",
"of",
"a",
"class",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/action.py#L5-L10 | [
"def",
"get_subclasses",
"(",
"c",
")",
":",
"subclasses",
"=",
"c",
".",
"__subclasses__",
"(",
")",
"for",
"d",
"in",
"list",
"(",
"subclasses",
")",
":",
"subclasses",
".",
"extend",
"(",
"get_subclasses",
"(",
"d",
")",
")",
"return",
"subclasses"
] | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | Action.add_arguments | Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args. | asana_hub/action.py | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-a... | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-a... | [
"Add",
"arguments",
"to",
"the",
"parser",
"for",
"collection",
"in",
"app",
".",
"args",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/action.py#L27-L62 | [
"def",
"add_arguments",
"(",
"cls",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'-as-api'",
",",
"'--asana-api'",
",",
"action",
"=",
"'store'",
",",
"nargs",
"=",
"'?'",
",",
"const",
"=",
"''",
",",
"dest",
"=",
"'asana_api'",
",",
... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | Action.get_repo_and_project | Returns repository and project. | asana_hub/action.py | def get_repo_and_project(self):
"""Returns repository and project."""
app = self.app
# Get repo
repo = app.data.apply('github-repo', app.args.github_repo,
app.prompt_repo,
on_load=app.github.get_repo,
on_save=lambda r: r.id
)
asse... | def get_repo_and_project(self):
"""Returns repository and project."""
app = self.app
# Get repo
repo = app.data.apply('github-repo', app.args.github_repo,
app.prompt_repo,
on_load=app.github.get_repo,
on_save=lambda r: r.id
)
asse... | [
"Returns",
"repository",
"and",
"project",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/action.py#L64-L96 | [
"def",
"get_repo_and_project",
"(",
"self",
")",
":",
"app",
"=",
"self",
".",
"app",
"# Get repo",
"repo",
"=",
"app",
".",
"data",
".",
"apply",
"(",
"'github-repo'",
",",
"app",
".",
"args",
".",
"github_repo",
",",
"app",
".",
"prompt_repo",
",",
"... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | get_variant_phenotypes_with_suggested_changes | for each variant, yields evidence and associated phenotypes, both current and suggested | civicpy/recipes.py | def get_variant_phenotypes_with_suggested_changes(variant_id_list):
'''for each variant, yields evidence and associated phenotypes, both current and suggested'''
variants = civic.get_variants_by_ids(variant_id_list)
evidence = list()
for variant in variants:
evidence.extend(variant.evidence)
... | def get_variant_phenotypes_with_suggested_changes(variant_id_list):
'''for each variant, yields evidence and associated phenotypes, both current and suggested'''
variants = civic.get_variants_by_ids(variant_id_list)
evidence = list()
for variant in variants:
evidence.extend(variant.evidence)
... | [
"for",
"each",
"variant",
"yields",
"evidence",
"and",
"associated",
"phenotypes",
"both",
"current",
"and",
"suggested"
] | griffithlab/civicpy | python | https://github.com/griffithlab/civicpy/blob/feac435483bac46ea650f46d1b4f15eb3395a2b8/civicpy/recipes.py#L5-L25 | [
"def",
"get_variant_phenotypes_with_suggested_changes",
"(",
"variant_id_list",
")",
":",
"variants",
"=",
"civic",
".",
"get_variants_by_ids",
"(",
"variant_id_list",
")",
"evidence",
"=",
"list",
"(",
")",
"for",
"variant",
"in",
"variants",
":",
"evidence",
".",
... | feac435483bac46ea650f46d1b4f15eb3395a2b8 |
test | get_variant_phenotypes_with_suggested_changes_merged | for each variant, yields evidence and merged phenotype from applying suggested changes to current | civicpy/recipes.py | def get_variant_phenotypes_with_suggested_changes_merged(variant_id_list):
'''for each variant, yields evidence and merged phenotype from applying suggested changes to current'''
for evidence, phenotype_status in get_variant_phenotypes_with_suggested_changes(variant_id_list):
final = phenotype_status['c... | def get_variant_phenotypes_with_suggested_changes_merged(variant_id_list):
'''for each variant, yields evidence and merged phenotype from applying suggested changes to current'''
for evidence, phenotype_status in get_variant_phenotypes_with_suggested_changes(variant_id_list):
final = phenotype_status['c... | [
"for",
"each",
"variant",
"yields",
"evidence",
"and",
"merged",
"phenotype",
"from",
"applying",
"suggested",
"changes",
"to",
"current"
] | griffithlab/civicpy | python | https://github.com/griffithlab/civicpy/blob/feac435483bac46ea650f46d1b4f15eb3395a2b8/civicpy/recipes.py#L28-L37 | [
"def",
"get_variant_phenotypes_with_suggested_changes_merged",
"(",
"variant_id_list",
")",
":",
"for",
"evidence",
",",
"phenotype_status",
"in",
"get_variant_phenotypes_with_suggested_changes",
"(",
"variant_id_list",
")",
":",
"final",
"=",
"phenotype_status",
"[",
"'curre... | feac435483bac46ea650f46d1b4f15eb3395a2b8 |
test | search_variants_by_coordinates | Search the cache for variants matching provided coordinates using the corresponding search mode.
:param coordinate_query: A civic CoordinateQuery object
start: the genomic start coordinate of the query
stop: the genomic end coordinate of the query
... | civicpy/civic.py | def search_variants_by_coordinates(coordinate_query, search_mode='any'):
"""
Search the cache for variants matching provided coordinates using the corresponding search mode.
:param coordinate_query: A civic CoordinateQuery object
start: the genomic start coordinate of the query
... | def search_variants_by_coordinates(coordinate_query, search_mode='any'):
"""
Search the cache for variants matching provided coordinates using the corresponding search mode.
:param coordinate_query: A civic CoordinateQuery object
start: the genomic start coordinate of the query
... | [
"Search",
"the",
"cache",
"for",
"variants",
"matching",
"provided",
"coordinates",
"using",
"the",
"corresponding",
"search",
"mode",
"."
] | griffithlab/civicpy | python | https://github.com/griffithlab/civicpy/blob/feac435483bac46ea650f46d1b4f15eb3395a2b8/civicpy/civic.py#L559-L611 | [
"def",
"search_variants_by_coordinates",
"(",
"coordinate_query",
",",
"search_mode",
"=",
"'any'",
")",
":",
"get_all_variants",
"(",
")",
"ct",
"=",
"COORDINATE_TABLE",
"start_idx",
"=",
"COORDINATE_TABLE_START",
"stop_idx",
"=",
"COORDINATE_TABLE_STOP",
"chr_idx",
"=... | feac435483bac46ea650f46d1b4f15eb3395a2b8 |
test | bulk_search_variants_by_coordinates | An interator to search the cache for variants matching the set of sorted coordinates and yield
matches corresponding to the search mode.
:param sorted_queries: A list of civic CoordinateQuery objects, sorted by coordinate.
start: the genomic start coordinate of the query
... | civicpy/civic.py | def bulk_search_variants_by_coordinates(sorted_queries, search_mode='any'):
"""
An interator to search the cache for variants matching the set of sorted coordinates and yield
matches corresponding to the search mode.
:param sorted_queries: A list of civic CoordinateQuery objects, sorted by coordinate.... | def bulk_search_variants_by_coordinates(sorted_queries, search_mode='any'):
"""
An interator to search the cache for variants matching the set of sorted coordinates and yield
matches corresponding to the search mode.
:param sorted_queries: A list of civic CoordinateQuery objects, sorted by coordinate.... | [
"An",
"interator",
"to",
"search",
"the",
"cache",
"for",
"variants",
"matching",
"the",
"set",
"of",
"sorted",
"coordinates",
"and",
"yield",
"matches",
"corresponding",
"to",
"the",
"search",
"mode",
"."
] | griffithlab/civicpy | python | https://github.com/griffithlab/civicpy/blob/feac435483bac46ea650f46d1b4f15eb3395a2b8/civicpy/civic.py#L615-L699 | [
"def",
"bulk_search_variants_by_coordinates",
"(",
"sorted_queries",
",",
"search_mode",
"=",
"'any'",
")",
":",
"def",
"is_sorted",
"(",
"prev_q",
",",
"current_q",
")",
":",
"if",
"prev_q",
"[",
"'chr'",
"]",
"<",
"current_q",
"[",
"'chr'",
"]",
":",
"retu... | feac435483bac46ea650f46d1b4f15eb3395a2b8 |
test | CivicRecord.update | Updates record and returns True if record is complete after update, else False. | civicpy/civic.py | def update(self, allow_partial=True, force=False, **kwargs):
"""Updates record and returns True if record is complete after update, else False."""
if kwargs:
self.__init__(partial=allow_partial, force=force, **kwargs)
return not self._partial
if not force and CACHE.get(h... | def update(self, allow_partial=True, force=False, **kwargs):
"""Updates record and returns True if record is complete after update, else False."""
if kwargs:
self.__init__(partial=allow_partial, force=force, **kwargs)
return not self._partial
if not force and CACHE.get(h... | [
"Updates",
"record",
"and",
"returns",
"True",
"if",
"record",
"is",
"complete",
"after",
"update",
"else",
"False",
"."
] | griffithlab/civicpy | python | https://github.com/griffithlab/civicpy/blob/feac435483bac46ea650f46d1b4f15eb3395a2b8/civicpy/civic.py#L176-L192 | [
"def",
"update",
"(",
"self",
",",
"allow_partial",
"=",
"True",
",",
"force",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"self",
".",
"__init__",
"(",
"partial",
"=",
"allow_partial",
",",
"force",
"=",
"force",
",",
"*",
... | feac435483bac46ea650f46d1b4f15eb3395a2b8 |
test | ToolApp.uniqify | Returns a unique list of seq | asana_hub/tool.py | def uniqify(cls, seq):
"""Returns a unique list of seq"""
seen = set()
seen_add = seen.add
return [ x for x in seq if x not in seen and not seen_add(x)] | def uniqify(cls, seq):
"""Returns a unique list of seq"""
seen = set()
seen_add = seen.add
return [ x for x in seq if x not in seen and not seen_add(x)] | [
"Returns",
"a",
"unique",
"list",
"of",
"seq"
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L54-L58 | [
"def",
"uniqify",
"(",
"cls",
",",
"seq",
")",
":",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"return",
"[",
"x",
"for",
"x",
"in",
"seq",
"if",
"x",
"not",
"in",
"seen",
"and",
"not",
"seen_add",
"(",
"x",
")",
"]"
] | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.authenticate | Connects to Github and Asana and authenticates via OAuth. | asana_hub/tool.py | def authenticate(self):
"""Connects to Github and Asana and authenticates via OAuth."""
if self.oauth:
return False
# Save asana.
self.settings.apply('api-asana', self.args.asana_api,
"enter asana api key")
# Save github.com
self.settings.apply('... | def authenticate(self):
"""Connects to Github and Asana and authenticates via OAuth."""
if self.oauth:
return False
# Save asana.
self.settings.apply('api-asana', self.args.asana_api,
"enter asana api key")
# Save github.com
self.settings.apply('... | [
"Connects",
"to",
"Github",
"and",
"Asana",
"and",
"authenticates",
"via",
"OAuth",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L60-L81 | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"self",
".",
"oauth",
":",
"return",
"False",
"# Save asana.",
"self",
".",
"settings",
".",
"apply",
"(",
"'api-asana'",
",",
"self",
".",
"args",
".",
"asana_api",
",",
"\"enter asana api key\"",
")",
"... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp._list_select | Given a list of values and names, accepts the index value or name. | asana_hub/tool.py | def _list_select(cls, lst, prompt, offset=0):
"""Given a list of values and names, accepts the index value or name."""
inp = raw_input("select %s: " % prompt)
assert inp, "value required."
try:
return lst[int(inp)+offset]
except ValueError:
return inp
... | def _list_select(cls, lst, prompt, offset=0):
"""Given a list of values and names, accepts the index value or name."""
inp = raw_input("select %s: " % prompt)
assert inp, "value required."
try:
return lst[int(inp)+offset]
except ValueError:
return inp
... | [
"Given",
"a",
"list",
"of",
"values",
"and",
"names",
"accepts",
"the",
"index",
"value",
"or",
"name",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L84-L95 | [
"def",
"_list_select",
"(",
"cls",
",",
"lst",
",",
"prompt",
",",
"offset",
"=",
"0",
")",
":",
"inp",
"=",
"raw_input",
"(",
"\"select %s: \"",
"%",
"prompt",
")",
"assert",
"inp",
",",
"\"value required.\"",
"try",
":",
"return",
"lst",
"[",
"int",
... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.save_issue_data_task | Saves a issue data (tasks, etc.) to local data.
Args:
issue:
`int`. Github issue number.
task:
`int`. Asana task ID.
namespace:
`str`. Namespace for storing this issue. | asana_hub/tool.py | def save_issue_data_task(self, issue, task_id, namespace='open'):
"""Saves a issue data (tasks, etc.) to local data.
Args:
issue:
`int`. Github issue number.
task:
`int`. Asana task ID.
namespace:
`str`. Namespace for s... | def save_issue_data_task(self, issue, task_id, namespace='open'):
"""Saves a issue data (tasks, etc.) to local data.
Args:
issue:
`int`. Github issue number.
task:
`int`. Asana task ID.
namespace:
`str`. Namespace for s... | [
"Saves",
"a",
"issue",
"data",
"(",
"tasks",
"etc",
".",
")",
"to",
"local",
"data",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L157-L174 | [
"def",
"save_issue_data_task",
"(",
"self",
",",
"issue",
",",
"task_id",
",",
"namespace",
"=",
"'open'",
")",
":",
"issue_data",
"=",
"self",
".",
"get_saved_issue_data",
"(",
"issue",
",",
"namespace",
")",
"if",
"not",
"issue_data",
".",
"has_key",
"(",
... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.get_saved_issue_data | Returns issue data from local data.
Args:
issue:
`int`. Github issue number.
namespace:
`str`. Namespace for storing this issue. | asana_hub/tool.py | def get_saved_issue_data(self, issue, namespace='open'):
"""Returns issue data from local data.
Args:
issue:
`int`. Github issue number.
namespace:
`str`. Namespace for storing this issue.
"""
if isinstance(issue, int):
... | def get_saved_issue_data(self, issue, namespace='open'):
"""Returns issue data from local data.
Args:
issue:
`int`. Github issue number.
namespace:
`str`. Namespace for storing this issue.
"""
if isinstance(issue, int):
... | [
"Returns",
"issue",
"data",
"from",
"local",
"data",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L190-L213 | [
"def",
"get_saved_issue_data",
"(",
"self",
",",
"issue",
",",
"namespace",
"=",
"'open'",
")",
":",
"if",
"isinstance",
"(",
"issue",
",",
"int",
")",
":",
"issue_number",
"=",
"str",
"(",
"issue",
")",
"elif",
"isinstance",
"(",
"issue",
",",
"basestri... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.move_saved_issue_data | Moves an issue_data from one namespace to another. | asana_hub/tool.py | def move_saved_issue_data(self, issue, ns, other_ns):
"""Moves an issue_data from one namespace to another."""
if isinstance(issue, int):
issue_number = str(issue)
elif isinstance(issue, basestring):
issue_number = issue
else:
issue_number = issue.num... | def move_saved_issue_data(self, issue, ns, other_ns):
"""Moves an issue_data from one namespace to another."""
if isinstance(issue, int):
issue_number = str(issue)
elif isinstance(issue, basestring):
issue_number = issue
else:
issue_number = issue.num... | [
"Moves",
"an",
"issue_data",
"from",
"one",
"namespace",
"to",
"another",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L215-L237 | [
"def",
"move_saved_issue_data",
"(",
"self",
",",
"issue",
",",
"ns",
",",
"other_ns",
")",
":",
"if",
"isinstance",
"(",
"issue",
",",
"int",
")",
":",
"issue_number",
"=",
"str",
"(",
"issue",
")",
"elif",
"isinstance",
"(",
"issue",
",",
"basestring",... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.get_saved_task_data | Returns task data from local data.
Args:
task:
`int`. Asana task number. | asana_hub/tool.py | def get_saved_task_data(self, task):
"""Returns task data from local data.
Args:
task:
`int`. Asana task number.
"""
if isinstance(task, int):
task_number = str(task)
elif isinstance(task, basestring):
task_number = task
... | def get_saved_task_data(self, task):
"""Returns task data from local data.
Args:
task:
`int`. Asana task number.
"""
if isinstance(task, int):
task_number = str(task)
elif isinstance(task, basestring):
task_number = task
... | [
"Returns",
"task",
"data",
"from",
"local",
"data",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L262-L282 | [
"def",
"get_saved_task_data",
"(",
"self",
",",
"task",
")",
":",
"if",
"isinstance",
"(",
"task",
",",
"int",
")",
":",
"task_number",
"=",
"str",
"(",
"task",
")",
"elif",
"isinstance",
"(",
"task",
",",
"basestring",
")",
":",
"task_number",
"=",
"t... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | ToolApp.get_asana_task | Retrieves a task from asana. | asana_hub/tool.py | def get_asana_task(self, asana_task_id):
"""Retrieves a task from asana."""
try:
return self.asana.tasks.find_by_id(asana_task_id)
except asana_errors.NotFoundError:
return None
except asana_errors.ForbiddenError:
return None | def get_asana_task(self, asana_task_id):
"""Retrieves a task from asana."""
try:
return self.asana.tasks.find_by_id(asana_task_id)
except asana_errors.NotFoundError:
return None
except asana_errors.ForbiddenError:
return None | [
"Retrieves",
"a",
"task",
"from",
"asana",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/tool.py#L288-L296 | [
"def",
"get_asana_task",
"(",
"self",
",",
"asana_task_id",
")",
":",
"try",
":",
"return",
"self",
".",
"asana",
".",
"tasks",
".",
"find_by_id",
"(",
"asana_task_id",
")",
"except",
"asana_errors",
".",
"NotFoundError",
":",
"return",
"None",
"except",
"as... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | JSONData.save | Save data. | asana_hub/json_data.py | def save(self):
"""Save data."""
with open(self.filename, 'wb') as file:
self.prune()
self.data['version'] = self.version
json.dump(self.data,
file,
sort_keys=True, indent=2) | def save(self):
"""Save data."""
with open(self.filename, 'wb') as file:
self.prune()
self.data['version'] = self.version
json.dump(self.data,
file,
sort_keys=True, indent=2) | [
"Save",
"data",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/json_data.py#L38-L46 | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filename",
",",
"'wb'",
")",
"as",
"file",
":",
"self",
".",
"prune",
"(",
")",
"self",
".",
"data",
"[",
"'version'",
"]",
"=",
"self",
".",
"version",
"json",
".",
"dump",... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | JSONData.apply | Applies a setting value to a key, if the value is not `None`.
Returns without prompting if either of the following:
* `value` is not `None`
* already present in the dictionary
Args:
prompt:
May either be a string to prompt via `raw_input` or a
... | asana_hub/json_data.py | def apply(self, key, value, prompt=None,
on_load=lambda a: a, on_save=lambda a: a):
"""Applies a setting value to a key, if the value is not `None`.
Returns without prompting if either of the following:
* `value` is not `None`
* already present in the dictionary
... | def apply(self, key, value, prompt=None,
on_load=lambda a: a, on_save=lambda a: a):
"""Applies a setting value to a key, if the value is not `None`.
Returns without prompting if either of the following:
* `value` is not `None`
* already present in the dictionary
... | [
"Applies",
"a",
"setting",
"value",
"to",
"a",
"key",
"if",
"the",
"value",
"is",
"not",
"None",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/json_data.py#L68-L112 | [
"def",
"apply",
"(",
"self",
",",
"key",
",",
"value",
",",
"prompt",
"=",
"None",
",",
"on_load",
"=",
"lambda",
"a",
":",
"a",
",",
"on_save",
"=",
"lambda",
"a",
":",
"a",
")",
":",
"# Reset value if flag exists without value",
"if",
"value",
"==",
... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | PullRequest.add_arguments | Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args. | asana_hub/actions/pull_request.py | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-i... | def add_arguments(cls, parser):
"""Add arguments to the parser for collection in app.args.
Args:
parser:
`argparse.ArgumentParser`. Parser.
Arguments added here are server on
self.args.
"""
parser.add_argument(
'-i... | [
"Add",
"arguments",
"to",
"the",
"parser",
"for",
"collection",
"in",
"app",
".",
"args",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/actions/pull_request.py#L19-L55 | [
"def",
"add_arguments",
"(",
"cls",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'-i'",
",",
"'--issue'",
",",
"action",
"=",
"'store'",
",",
"nargs",
"=",
"'?'",
",",
"const",
"=",
"''",
",",
"dest",
"=",
"'issue'",
",",
"help",
"="... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | transport_task | Decorator for retrying tasks with special cases. | asana_hub/transport.py | def transport_task(func):
"""Decorator for retrying tasks with special cases."""
def wrapped_func(*args, **kwargs):
tries = 0
while True:
try:
try:
return func(*args, **kwargs)
except (asana_errors.InvalidRequestError,
... | def transport_task(func):
"""Decorator for retrying tasks with special cases."""
def wrapped_func(*args, **kwargs):
tries = 0
while True:
try:
try:
return func(*args, **kwargs)
except (asana_errors.InvalidRequestError,
... | [
"Decorator",
"for",
"retrying",
"tasks",
"with",
"special",
"cases",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L42-L73 | [
"def",
"transport_task",
"(",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tries",
"=",
"0",
"while",
"True",
":",
"try",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwarg... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | flush | Waits until queue is empty. | asana_hub/transport.py | def flush(callback=None):
"""Waits until queue is empty."""
while True:
if shutdown_event.is_set():
return
if callable(callback):
callback()
try:
item = queue.get(timeout=1)
queue.put(item) # put it back, we're just peeking.
exc... | def flush(callback=None):
"""Waits until queue is empty."""
while True:
if shutdown_event.is_set():
return
if callable(callback):
callback()
try:
item = queue.get(timeout=1)
queue.put(item) # put it back, we're just peeking.
exc... | [
"Waits",
"until",
"queue",
"is",
"empty",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L254-L268 | [
"def",
"flush",
"(",
"callback",
"=",
"None",
")",
":",
"while",
"True",
":",
"if",
"shutdown_event",
".",
"is_set",
"(",
")",
":",
"return",
"if",
"callable",
"(",
"callback",
")",
":",
"callback",
"(",
")",
"try",
":",
"item",
"=",
"queue",
".",
... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | task_create | Creates a task | asana_hub/transport.py | def task_create(asana_workspace_id, name, notes, assignee, projects,
completed, **kwargs):
"""Creates a task"""
put("task_create",
asana_workspace_id=asana_workspace_id,
name=name,
notes=notes,
assignee=assignee,
projects=projects,
completed=comple... | def task_create(asana_workspace_id, name, notes, assignee, projects,
completed, **kwargs):
"""Creates a task"""
put("task_create",
asana_workspace_id=asana_workspace_id,
name=name,
notes=notes,
assignee=assignee,
projects=projects,
completed=comple... | [
"Creates",
"a",
"task"
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L276-L286 | [
"def",
"task_create",
"(",
"asana_workspace_id",
",",
"name",
",",
"notes",
",",
"assignee",
",",
"projects",
",",
"completed",
",",
"*",
"*",
"kwargs",
")",
":",
"put",
"(",
"\"task_create\"",
",",
"asana_workspace_id",
"=",
"asana_workspace_id",
",",
"name",... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | format_task_numbers_with_links | Returns formatting for the tasks section of asana. | asana_hub/transport.py | def format_task_numbers_with_links(tasks):
"""Returns formatting for the tasks section of asana."""
project_id = data.get('asana-project', None)
def _task_format(task_id):
if project_id:
asana_url = tool.ToolApp.make_asana_url(project_id, task_id)
return "[#%d](%s)" % (task... | def format_task_numbers_with_links(tasks):
"""Returns formatting for the tasks section of asana."""
project_id = data.get('asana-project', None)
def _task_format(task_id):
if project_id:
asana_url = tool.ToolApp.make_asana_url(project_id, task_id)
return "[#%d](%s)" % (task... | [
"Returns",
"formatting",
"for",
"the",
"tasks",
"section",
"of",
"asana",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L320-L332 | [
"def",
"format_task_numbers_with_links",
"(",
"tasks",
")",
":",
"project_id",
"=",
"data",
".",
"get",
"(",
"'asana-project'",
",",
"None",
")",
"def",
"_task_format",
"(",
"task_id",
")",
":",
"if",
"project_id",
":",
"asana_url",
"=",
"tool",
".",
"ToolAp... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | TransportWorker.create_missing_task | Creates a missing task. | asana_hub/transport.py | def create_missing_task(self,
asana_workspace_id,
name,
assignee,
projects,
completed,
issue_number,
issue_html_url,
... | def create_missing_task(self,
asana_workspace_id,
name,
assignee,
projects,
completed,
issue_number,
issue_html_url,
... | [
"Creates",
"a",
"missing",
"task",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L112-L168 | [
"def",
"create_missing_task",
"(",
"self",
",",
"asana_workspace_id",
",",
"name",
",",
"assignee",
",",
"projects",
",",
"completed",
",",
"issue_number",
",",
"issue_html_url",
",",
"issue_state",
",",
"issue_body",
",",
"tasks",
",",
"labels",
",",
"label_tag... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | TransportWorker.apply_tasks_to_issue | Applies task numbers to an issue. | asana_hub/transport.py | def apply_tasks_to_issue(self, tasks, issue_number, issue_body):
"""Applies task numbers to an issue."""
issue_body = issue_body
task_numbers = format_task_numbers_with_links(tasks)
if task_numbers:
new_body = ASANA_SECTION_RE.sub('', issue_body)
new_body = new_bo... | def apply_tasks_to_issue(self, tasks, issue_number, issue_body):
"""Applies task numbers to an issue."""
issue_body = issue_body
task_numbers = format_task_numbers_with_links(tasks)
if task_numbers:
new_body = ASANA_SECTION_RE.sub('', issue_body)
new_body = new_bo... | [
"Applies",
"task",
"numbers",
"to",
"an",
"issue",
"."
] | Loudr/asana-hub | python | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/transport.py#L219-L231 | [
"def",
"apply_tasks_to_issue",
"(",
"self",
",",
"tasks",
",",
"issue_number",
",",
"issue_body",
")",
":",
"issue_body",
"=",
"issue_body",
"task_numbers",
"=",
"format_task_numbers_with_links",
"(",
"tasks",
")",
"if",
"task_numbers",
":",
"new_body",
"=",
"ASAN... | af996ce890ed23d8ede5bf68dcd318e3438829cb |
test | GenProject.data_types | Return a list of data types. | genesis/project.py | def data_types(self):
"""Return a list of data types."""
data = self.gencloud.project_data(self.id)
return sorted(set(d.type for d in data)) | def data_types(self):
"""Return a list of data types."""
data = self.gencloud.project_data(self.id)
return sorted(set(d.type for d in data)) | [
"Return",
"a",
"list",
"of",
"data",
"types",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/project.py#L17-L20 | [
"def",
"data_types",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"gencloud",
".",
"project_data",
"(",
"self",
".",
"id",
")",
"return",
"sorted",
"(",
"set",
"(",
"d",
".",
"type",
"for",
"d",
"in",
"data",
")",
")"
] | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | GenProject.data | Query for Data object annotation. | genesis/project.py | def data(self, **query):
"""Query for Data object annotation."""
data = self.gencloud.project_data(self.id)
query['case_ids__contains'] = self.id
ids = set(d['id'] for d in self.gencloud.api.dataid.get(**query)['objects'])
return [d for d in data if d.id in ids] | def data(self, **query):
"""Query for Data object annotation."""
data = self.gencloud.project_data(self.id)
query['case_ids__contains'] = self.id
ids = set(d['id'] for d in self.gencloud.api.dataid.get(**query)['objects'])
return [d for d in data if d.id in ids] | [
"Query",
"for",
"Data",
"object",
"annotation",
"."
] | genialis/genesis-pyapi | python | https://github.com/genialis/genesis-pyapi/blob/dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a/genesis/project.py#L22-L27 | [
"def",
"data",
"(",
"self",
",",
"*",
"*",
"query",
")",
":",
"data",
"=",
"self",
".",
"gencloud",
".",
"project_data",
"(",
"self",
".",
"id",
")",
"query",
"[",
"'case_ids__contains'",
"]",
"=",
"self",
".",
"id",
"ids",
"=",
"set",
"(",
"d",
... | dfe9bcc8b332a8b9873db4ab9994b0cc10eb209a |
test | ekm_log | Send string to module level log
Args:
logstr (str): string to print.
priority (int): priority, supports 3 (default) and 4 (special). | ekmmeters.py | def ekm_log(logstr, priority=3):
""" Send string to module level log
Args:
logstr (str): string to print.
priority (int): priority, supports 3 (default) and 4 (special).
"""
if priority <= ekmmeters_log_level:
dt = datetime.datetime
stamp = datetime.datetime.now().strfti... | def ekm_log(logstr, priority=3):
""" Send string to module level log
Args:
logstr (str): string to print.
priority (int): priority, supports 3 (default) and 4 (special).
"""
if priority <= ekmmeters_log_level:
dt = datetime.datetime
stamp = datetime.datetime.now().strfti... | [
"Send",
"string",
"to",
"module",
"level",
"log"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L67-L78 | [
"def",
"ekm_log",
"(",
"logstr",
",",
"priority",
"=",
"3",
")",
":",
"if",
"priority",
"<=",
"ekmmeters_log_level",
":",
"dt",
"=",
"datetime",
".",
"datetime",
"stamp",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SerialPort.initPort | Required initialization call, wraps pyserial constructor. | ekmmeters.py | def initPort(self):
""" Required initialization call, wraps pyserial constructor. """
try:
self.m_ser = serial.Serial(port=self.m_ttyport,
baudrate=self.m_baudrate,
timeout=0,
... | def initPort(self):
""" Required initialization call, wraps pyserial constructor. """
try:
self.m_ser = serial.Serial(port=self.m_ttyport,
baudrate=self.m_baudrate,
timeout=0,
... | [
"Required",
"initialization",
"call",
"wraps",
"pyserial",
"constructor",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L964-L982 | [
"def",
"initPort",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"m_ser",
"=",
"serial",
".",
"Serial",
"(",
"port",
"=",
"self",
".",
"m_ttyport",
",",
"baudrate",
"=",
"self",
".",
"m_baudrate",
",",
"timeout",
"=",
"0",
",",
"parity",
"=",
"se... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SerialPort.write | Passthrough for pyserial Serial.write().
Args:
output (str): Block to write to port | ekmmeters.py | def write(self, output):
"""Passthrough for pyserial Serial.write().
Args:
output (str): Block to write to port
"""
view_str = output.encode('ascii', 'ignore')
if (len(view_str) > 0):
self.m_ser.write(view_str)
self.m_ser.flush()
s... | def write(self, output):
"""Passthrough for pyserial Serial.write().
Args:
output (str): Block to write to port
"""
view_str = output.encode('ascii', 'ignore')
if (len(view_str) > 0):
self.m_ser.write(view_str)
self.m_ser.flush()
s... | [
"Passthrough",
"for",
"pyserial",
"Serial",
".",
"write",
"()",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L997-L1009 | [
"def",
"write",
"(",
"self",
",",
"output",
")",
":",
"view_str",
"=",
"output",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
"if",
"(",
"len",
"(",
"view_str",
")",
">",
"0",
")",
":",
"self",
".",
"m_ser",
".",
"write",
"(",
"view_str",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SerialPort.setPollingValues | Optional polling loop control
Args:
max_waits (int): waits
wait_sleep (int): ms per wait | ekmmeters.py | def setPollingValues(self, max_waits, wait_sleep):
""" Optional polling loop control
Args:
max_waits (int): waits
wait_sleep (int): ms per wait
"""
self.m_max_waits = max_waits
self.m_wait_sleep = wait_sleep | def setPollingValues(self, max_waits, wait_sleep):
""" Optional polling loop control
Args:
max_waits (int): waits
wait_sleep (int): ms per wait
"""
self.m_max_waits = max_waits
self.m_wait_sleep = wait_sleep | [
"Optional",
"polling",
"loop",
"control"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1011-L1019 | [
"def",
"setPollingValues",
"(",
"self",
",",
"max_waits",
",",
"wait_sleep",
")",
":",
"self",
".",
"m_max_waits",
"=",
"max_waits",
"self",
".",
"m_wait_sleep",
"=",
"wait_sleep"
] | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SerialPort.getResponse | Poll for finished block or first byte ACK.
Args:
context (str): internal serial call context.
Returns:
string: Response, implict cast from byte array. | ekmmeters.py | def getResponse(self, context=""):
""" Poll for finished block or first byte ACK.
Args:
context (str): internal serial call context.
Returns:
string: Response, implict cast from byte array.
"""
waits = 0 # allowed interval counter
response_str = ... | def getResponse(self, context=""):
""" Poll for finished block or first byte ACK.
Args:
context (str): internal serial call context.
Returns:
string: Response, implict cast from byte array.
"""
waits = 0 # allowed interval counter
response_str = ... | [
"Poll",
"for",
"finished",
"block",
"or",
"first",
"byte",
"ACK",
".",
"Args",
":",
"context",
"(",
"str",
")",
":",
"internal",
"serial",
"call",
"context",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1021-L1052 | [
"def",
"getResponse",
"(",
"self",
",",
"context",
"=",
"\"\"",
")",
":",
"waits",
"=",
"0",
"# allowed interval counter",
"response_str",
"=",
"\"\"",
"# returned bytes in string default",
"try",
":",
"waits",
"=",
"0",
"# allowed interval counter",
"while",
"(",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.combineAB | Use the serial block definitions in V3 and V4 to create one field list. | ekmmeters.py | def combineAB(self):
""" Use the serial block definitions in V3 and V4 to create one field list. """
v4definition_meter = V4Meter()
v4definition_meter.makeAB()
defv4 = v4definition_meter.getReadBuffer()
v3definition_meter = V3Meter()
v3definition_meter.makeReturnFormat()... | def combineAB(self):
""" Use the serial block definitions in V3 and V4 to create one field list. """
v4definition_meter = V4Meter()
v4definition_meter.makeAB()
defv4 = v4definition_meter.getReadBuffer()
v3definition_meter = V3Meter()
v3definition_meter.makeReturnFormat()... | [
"Use",
"the",
"serial",
"block",
"definitions",
"in",
"V3",
"and",
"V4",
"to",
"create",
"one",
"field",
"list",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1076-L1097 | [
"def",
"combineAB",
"(",
"self",
")",
":",
"v4definition_meter",
"=",
"V4Meter",
"(",
")",
"v4definition_meter",
".",
"makeAB",
"(",
")",
"defv4",
"=",
"v4definition_meter",
".",
"getReadBuffer",
"(",
")",
"v3definition_meter",
"=",
"V3Meter",
"(",
")",
"v3def... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.mapTypeToSql | Translate FieldType to portable SQL Type. Override if needful.
Args:
fld_type (int): :class:`~ekmmeters.FieldType` in serial block.
fld_len (int): Binary length in serial block
Returns:
string: Portable SQL type and length where appropriate. | ekmmeters.py | def mapTypeToSql(fld_type=FieldType.NoType, fld_len=0):
""" Translate FieldType to portable SQL Type. Override if needful.
Args:
fld_type (int): :class:`~ekmmeters.FieldType` in serial block.
fld_len (int): Binary length in serial block
Returns:
string: Port... | def mapTypeToSql(fld_type=FieldType.NoType, fld_len=0):
""" Translate FieldType to portable SQL Type. Override if needful.
Args:
fld_type (int): :class:`~ekmmeters.FieldType` in serial block.
fld_len (int): Binary length in serial block
Returns:
string: Port... | [
"Translate",
"FieldType",
"to",
"portable",
"SQL",
"Type",
".",
"Override",
"if",
"needful",
".",
"Args",
":",
"fld_type",
"(",
"int",
")",
":",
":",
"class",
":",
"~ekmmeters",
".",
"FieldType",
"in",
"serial",
"block",
".",
"fld_len",
"(",
"int",
")",
... | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1100-L1121 | [
"def",
"mapTypeToSql",
"(",
"fld_type",
"=",
"FieldType",
".",
"NoType",
",",
"fld_len",
"=",
"0",
")",
":",
"if",
"fld_type",
"==",
"FieldType",
".",
"Float",
":",
"return",
"\"FLOAT\"",
"elif",
"fld_type",
"==",
"FieldType",
".",
"String",
":",
"return",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.fillCreate | Return query portion below CREATE.
Args:
qry_str (str): String as built.
Returns:
string: Passed string with fields appended. | ekmmeters.py | def fillCreate(self, qry_str):
""" Return query portion below CREATE.
Args:
qry_str (str): String as built.
Returns:
string: Passed string with fields appended.
"""
count = 0
for fld in self.m_all_fields:
fld_type = self.m_all_fields[f... | def fillCreate(self, qry_str):
""" Return query portion below CREATE.
Args:
qry_str (str): String as built.
Returns:
string: Passed string with fields appended.
"""
count = 0
for fld in self.m_all_fields:
fld_type = self.m_all_fields[f... | [
"Return",
"query",
"portion",
"below",
"CREATE",
".",
"Args",
":",
"qry_str",
"(",
"str",
")",
":",
"String",
"as",
"built",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1123-L1145 | [
"def",
"fillCreate",
"(",
"self",
",",
"qry_str",
")",
":",
"count",
"=",
"0",
"for",
"fld",
"in",
"self",
".",
"m_all_fields",
":",
"fld_type",
"=",
"self",
".",
"m_all_fields",
"[",
"fld",
"]",
"[",
"MeterData",
".",
"TypeValue",
"]",
"fld_len",
"=",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.sqlCreate | Reasonably portable SQL CREATE for defined fields.
Returns:
string: Portable as possible SQL Create for all-reads table. | ekmmeters.py | def sqlCreate(self):
""" Reasonably portable SQL CREATE for defined fields.
Returns:
string: Portable as possible SQL Create for all-reads table.
"""
count = 0
qry_str = "CREATE TABLE Meter_Reads ( \n\r"
qry_str = self.fillCreate(qry_str)
ekm_log(qry_s... | def sqlCreate(self):
""" Reasonably portable SQL CREATE for defined fields.
Returns:
string: Portable as possible SQL Create for all-reads table.
"""
count = 0
qry_str = "CREATE TABLE Meter_Reads ( \n\r"
qry_str = self.fillCreate(qry_str)
ekm_log(qry_s... | [
"Reasonably",
"portable",
"SQL",
"CREATE",
"for",
"defined",
"fields",
".",
"Returns",
":",
"string",
":",
"Portable",
"as",
"possible",
"SQL",
"Create",
"for",
"all",
"-",
"reads",
"table",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1147-L1156 | [
"def",
"sqlCreate",
"(",
"self",
")",
":",
"count",
"=",
"0",
"qry_str",
"=",
"\"CREATE TABLE Meter_Reads ( \\n\\r\"",
"qry_str",
"=",
"self",
".",
"fillCreate",
"(",
"qry_str",
")",
"ekm_log",
"(",
"qry_str",
",",
"4",
")",
"return",
"qry_str"
] | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.sqlInsert | Reasonably portable SQL INSERT for from combined read buffer.
Args:
def_buf (SerialBlock): Database only serial block of all fields.
raw_a (str): Raw A read as hex string.
raw_b (str): Raw B read (if exists, otherwise empty) as hex string.
Returns:
str: S... | ekmmeters.py | def sqlInsert(def_buf, raw_a, raw_b):
""" Reasonably portable SQL INSERT for from combined read buffer.
Args:
def_buf (SerialBlock): Database only serial block of all fields.
raw_a (str): Raw A read as hex string.
raw_b (str): Raw B read (if exists, otherwise empty) a... | def sqlInsert(def_buf, raw_a, raw_b):
""" Reasonably portable SQL INSERT for from combined read buffer.
Args:
def_buf (SerialBlock): Database only serial block of all fields.
raw_a (str): Raw A read as hex string.
raw_b (str): Raw B read (if exists, otherwise empty) a... | [
"Reasonably",
"portable",
"SQL",
"INSERT",
"for",
"from",
"combined",
"read",
"buffer",
".",
"Args",
":",
"def_buf",
"(",
"SerialBlock",
")",
":",
"Database",
"only",
"serial",
"block",
"of",
"all",
"fields",
".",
"raw_a",
"(",
"str",
")",
":",
"Raw",
"A... | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1159-L1198 | [
"def",
"sqlInsert",
"(",
"def_buf",
",",
"raw_a",
",",
"raw_b",
")",
":",
"count",
"=",
"0",
"qry_str",
"=",
"\"INSERT INTO Meter_Reads ( \\n\\t\"",
"for",
"fld",
"in",
"def_buf",
":",
"if",
"count",
">",
"0",
":",
"qry_str",
"+=",
"\", \\n\\t\"",
"qry_str"... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | MeterDB.dbInsert | Call overridden dbExec() with built insert statement.
Args:
def_buf (SerialBlock): Block of read buffer fields to write.
raw_a (str): Hex string of raw A read.
raw_b (str): Hex string of raw B read or empty. | ekmmeters.py | def dbInsert(self, def_buf, raw_a, raw_b):
""" Call overridden dbExec() with built insert statement.
Args:
def_buf (SerialBlock): Block of read buffer fields to write.
raw_a (str): Hex string of raw A read.
raw_b (str): Hex string of raw B read or empty.
"""
... | def dbInsert(self, def_buf, raw_a, raw_b):
""" Call overridden dbExec() with built insert statement.
Args:
def_buf (SerialBlock): Block of read buffer fields to write.
raw_a (str): Hex string of raw A read.
raw_b (str): Hex string of raw B read or empty.
"""
... | [
"Call",
"overridden",
"dbExec",
"()",
"with",
"built",
"insert",
"statement",
".",
"Args",
":",
"def_buf",
"(",
"SerialBlock",
")",
":",
"Block",
"of",
"read",
"buffer",
"fields",
"to",
"write",
".",
"raw_a",
"(",
"str",
")",
":",
"Hex",
"string",
"of",
... | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1228-L1235 | [
"def",
"dbInsert",
"(",
"self",
",",
"def_buf",
",",
"raw_a",
",",
"raw_b",
")",
":",
"self",
".",
"dbExec",
"(",
"self",
".",
"sqlInsert",
"(",
"def_buf",
",",
"raw_a",
",",
"raw_b",
")",
")"
] | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SqliteMeterDB.dbExec | Required override of dbExec() from MeterDB(), run query.
Args:
query_str (str): query to run | ekmmeters.py | def dbExec(self, query_str):
""" Required override of dbExec() from MeterDB(), run query.
Args:
query_str (str): query to run
"""
try:
connection = sqlite3.connect(self.m_connection_string)
cursor = connection.cursor()
cursor.execute(query_... | def dbExec(self, query_str):
""" Required override of dbExec() from MeterDB(), run query.
Args:
query_str (str): query to run
"""
try:
connection = sqlite3.connect(self.m_connection_string)
cursor = connection.cursor()
cursor.execute(query_... | [
"Required",
"override",
"of",
"dbExec",
"()",
"from",
"MeterDB",
"()",
"run",
"query",
".",
"Args",
":",
"query_str",
"(",
"str",
")",
":",
"query",
"to",
"run"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1263-L1279 | [
"def",
"dbExec",
"(",
"self",
",",
"query_str",
")",
":",
"try",
":",
"connection",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"m_connection_string",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"query_... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SqliteMeterDB.dict_factory | Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
Returns:
dict: modified row. | ekmmeters.py | def dict_factory(self, cursor, row):
""" Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
Returns:
dict: mod... | def dict_factory(self, cursor, row):
""" Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
Returns:
dict: mod... | [
"Sqlite",
"callback",
"accepting",
"the",
"cursor",
"and",
"the",
"original",
"row",
"as",
"a",
"tuple",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1281-L1306 | [
"def",
"dict_factory",
"(",
"self",
",",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"val",
"=",
"row",
"[",
"idx",
"]",
"name",
"=",
"col",
"[",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SqliteMeterDB.raw_dict_factory | Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types, including raw read hex strings.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
Returns:
dict: modified row. | ekmmeters.py | def raw_dict_factory(cursor, row):
""" Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types, including raw read hex strings.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
... | def raw_dict_factory(cursor, row):
""" Sqlite callback accepting the cursor and the original row as a tuple.
Simple return of JSON safe types, including raw read hex strings.
Args:
cursor (sqlite cursor): Original cursory
row (sqlite row tuple): Original row.
... | [
"Sqlite",
"callback",
"accepting",
"the",
"cursor",
"and",
"the",
"original",
"row",
"as",
"a",
"tuple",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1309-L1331 | [
"def",
"raw_dict_factory",
"(",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"val",
"=",
"row",
"[",
"idx",
"]",
"name",
"=",
"col",
"[",
"0",
"]",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | SqliteMeterDB.renderJsonReadsSince | Simple since Time_Stamp query returned as JSON records.
Args:
timestamp (int): Epoch time in seconds.
meter (str): 12 character meter address to query
Returns:
str: JSON rendered read records. | ekmmeters.py | def renderJsonReadsSince(self, timestamp, meter):
""" Simple since Time_Stamp query returned as JSON records.
Args:
timestamp (int): Epoch time in seconds.
meter (str): 12 character meter address to query
Returns:
str: JSON rendered read records.
""... | def renderJsonReadsSince(self, timestamp, meter):
""" Simple since Time_Stamp query returned as JSON records.
Args:
timestamp (int): Epoch time in seconds.
meter (str): 12 character meter address to query
Returns:
str: JSON rendered read records.
""... | [
"Simple",
"since",
"Time_Stamp",
"query",
"returned",
"as",
"JSON",
"records",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1333-L1357 | [
"def",
"renderJsonReadsSince",
"(",
"self",
",",
"timestamp",
",",
"meter",
")",
":",
"result",
"=",
"\"\"",
"try",
":",
"connection",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"m_connection_string",
")",
"connection",
".",
"row_factory",
"=",
"self"... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setContext | Set context string for serial command. Private setter.
Args:
context_str (str): Command specific string. | ekmmeters.py | def setContext(self, context_str):
""" Set context string for serial command. Private setter.
Args:
context_str (str): Command specific string.
"""
if (len(self.m_context) == 0) and (len(context_str) >= 7):
if context_str[0:7] != "request":
ekm_l... | def setContext(self, context_str):
""" Set context string for serial command. Private setter.
Args:
context_str (str): Command specific string.
"""
if (len(self.m_context) == 0) and (len(context_str) >= 7):
if context_str[0:7] != "request":
ekm_l... | [
"Set",
"context",
"string",
"for",
"serial",
"command",
".",
"Private",
"setter",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1482-L1491 | [
"def",
"setContext",
"(",
"self",
",",
"context_str",
")",
":",
"if",
"(",
"len",
"(",
"self",
".",
"m_context",
")",
"==",
"0",
")",
"and",
"(",
"len",
"(",
"context_str",
")",
">=",
"7",
")",
":",
"if",
"context_str",
"[",
"0",
":",
"7",
"]",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.calc_crc16 | Drop in pure python replacement for ekmcrc.c extension.
Args:
buf (bytes): String or byte array (implicit Python 2.7 cast)
Returns:
str: 16 bit CRC per EKM Omnimeters formatted as hex string. | ekmmeters.py | def calc_crc16(buf):
""" Drop in pure python replacement for ekmcrc.c extension.
Args:
buf (bytes): String or byte array (implicit Python 2.7 cast)
Returns:
str: 16 bit CRC per EKM Omnimeters formatted as hex string.
"""
crc_table = [0x0000, 0xc0c1, 0xc1... | def calc_crc16(buf):
""" Drop in pure python replacement for ekmcrc.c extension.
Args:
buf (bytes): String or byte array (implicit Python 2.7 cast)
Returns:
str: 16 bit CRC per EKM Omnimeters formatted as hex string.
"""
crc_table = [0x0000, 0xc0c1, 0xc1... | [
"Drop",
"in",
"pure",
"python",
"replacement",
"for",
"ekmcrc",
".",
"c",
"extension",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1502-L1552 | [
"def",
"calc_crc16",
"(",
"buf",
")",
":",
"crc_table",
"=",
"[",
"0x0000",
",",
"0xc0c1",
",",
"0xc181",
",",
"0x0140",
",",
"0xc301",
",",
"0x03c0",
",",
"0x0280",
",",
"0xc241",
",",
"0xc601",
",",
"0x06c0",
",",
"0x0780",
",",
"0xc741",
",",
"0x0... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.calcPF | Simple wrap to calc legacy PF value
Args:
pf: meter power factor reading
Returns:
int: legacy push pf | ekmmeters.py | def calcPF(pf):
""" Simple wrap to calc legacy PF value
Args:
pf: meter power factor reading
Returns:
int: legacy push pf
"""
pf_y = pf[:1]
pf_x = pf[1:]
result = 100
if pf_y == CosTheta.CapacitiveLead:
result = 200 - ... | def calcPF(pf):
""" Simple wrap to calc legacy PF value
Args:
pf: meter power factor reading
Returns:
int: legacy push pf
"""
pf_y = pf[:1]
pf_x = pf[1:]
result = 100
if pf_y == CosTheta.CapacitiveLead:
result = 200 - ... | [
"Simple",
"wrap",
"to",
"calc",
"legacy",
"PF",
"value"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1555-L1572 | [
"def",
"calcPF",
"(",
"pf",
")",
":",
"pf_y",
"=",
"pf",
"[",
":",
"1",
"]",
"pf_x",
"=",
"pf",
"[",
"1",
":",
"]",
"result",
"=",
"100",
"if",
"pf_y",
"==",
"CosTheta",
".",
"CapacitiveLead",
":",
"result",
"=",
"200",
"-",
"int",
"(",
"pf_x",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setMaxDemandPeriod | Serial call to set max demand period.
Args:
period (int): : as int.
password (str): Optional password.
Returns:
bool: True on completion with ACK. | ekmmeters.py | def setMaxDemandPeriod(self, period, password="00000000"):
""" Serial call to set max demand period.
Args:
period (int): : as int.
password (str): Optional password.
Returns:
bool: True on completion with ACK.
"""
result = False
self.... | def setMaxDemandPeriod(self, period, password="00000000"):
""" Serial call to set max demand period.
Args:
period (int): : as int.
password (str): Optional password.
Returns:
bool: True on completion with ACK.
"""
result = False
self.... | [
"Serial",
"call",
"to",
"set",
"max",
"demand",
"period",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1574-L1609 | [
"def",
"setMaxDemandPeriod",
"(",
"self",
",",
"period",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setMaxDemandPeriod\"",
")",
"try",
":",
"if",
"period",
"<",
"1",
"or",
"period",
">",
"3",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setMeterPassword | Serial Call to set meter password. USE WITH CAUTION.
Args:
new_pwd (str): 8 digit numeric password to set
pwd (str): Old 8 digit numeric password.
Returns:
bool: True on completion with ACK. | ekmmeters.py | def setMeterPassword(self, new_pwd, pwd="00000000"):
""" Serial Call to set meter password. USE WITH CAUTION.
Args:
new_pwd (str): 8 digit numeric password to set
pwd (str): Old 8 digit numeric password.
Returns:
bool: True on completion with ACK.
"... | def setMeterPassword(self, new_pwd, pwd="00000000"):
""" Serial Call to set meter password. USE WITH CAUTION.
Args:
new_pwd (str): 8 digit numeric password to set
pwd (str): Old 8 digit numeric password.
Returns:
bool: True on completion with ACK.
"... | [
"Serial",
"Call",
"to",
"set",
"meter",
"password",
".",
"USE",
"WITH",
"CAUTION",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1648-L1684 | [
"def",
"setMeterPassword",
"(",
"self",
",",
"new_pwd",
",",
"pwd",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setMeterPassword\"",
")",
"try",
":",
"if",
"len",
"(",
"new_pwd",
")",
"!=",
"8",
"or",
"len",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.unpackStruct | Wrapper for struct.unpack with SerialBlock buffer definitionns.
Args:
data (str): Implicit cast bytes to str, serial port return.
def_buf (SerialBlock): Block object holding field lengths.
Returns:
tuple: parsed result of struct.unpack() with field definitions. | ekmmeters.py | def unpackStruct(self, data, def_buf):
""" Wrapper for struct.unpack with SerialBlock buffer definitionns.
Args:
data (str): Implicit cast bytes to str, serial port return.
def_buf (SerialBlock): Block object holding field lengths.
Returns:
tuple: parsed res... | def unpackStruct(self, data, def_buf):
""" Wrapper for struct.unpack with SerialBlock buffer definitionns.
Args:
data (str): Implicit cast bytes to str, serial port return.
def_buf (SerialBlock): Block object holding field lengths.
Returns:
tuple: parsed res... | [
"Wrapper",
"for",
"struct",
".",
"unpack",
"with",
"SerialBlock",
"buffer",
"definitionns",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1686-L1705 | [
"def",
"unpackStruct",
"(",
"self",
",",
"data",
",",
"def_buf",
")",
":",
"struct_str",
"=",
"\"=\"",
"for",
"fld",
"in",
"def_buf",
":",
"if",
"not",
"def_buf",
"[",
"fld",
"]",
"[",
"MeterData",
".",
"CalculatedFlag",
"]",
":",
"struct_str",
"=",
"s... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.convertData | Move data from raw tuple into scaled and conveted values.
Args:
contents (tuple): Breakout of passed block from unpackStruct().
def_buf (): Read buffer destination.
kwh_scale (int): :class:`~ekmmeters.ScaleKWH` as int, from Field.kWhScale`
Returns:
bool... | ekmmeters.py | def convertData(self, contents, def_buf, kwh_scale=ScaleKWH.EmptyScale):
""" Move data from raw tuple into scaled and conveted values.
Args:
contents (tuple): Breakout of passed block from unpackStruct().
def_buf (): Read buffer destination.
kwh_scale (int): :class:... | def convertData(self, contents, def_buf, kwh_scale=ScaleKWH.EmptyScale):
""" Move data from raw tuple into scaled and conveted values.
Args:
contents (tuple): Breakout of passed block from unpackStruct().
def_buf (): Read buffer destination.
kwh_scale (int): :class:... | [
"Move",
"data",
"from",
"raw",
"tuple",
"into",
"scaled",
"and",
"conveted",
"values",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1709-L1801 | [
"def",
"convertData",
"(",
"self",
",",
"contents",
",",
"def_buf",
",",
"kwh_scale",
"=",
"ScaleKWH",
".",
"EmptyScale",
")",
":",
"log_str",
"=",
"\"\"",
"count",
"=",
"0",
"# getting scale does not require a full read. It does require that the",
"# reads have the sc... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.jsonRender | Translate the passed serial block into string only JSON.
Args:
def_buf (SerialBlock): Any :class:`~ekmmeters.SerialBlock` object.
Returns:
str: JSON rendering of meter record. | ekmmeters.py | def jsonRender(self, def_buf):
""" Translate the passed serial block into string only JSON.
Args:
def_buf (SerialBlock): Any :class:`~ekmmeters.SerialBlock` object.
Returns:
str: JSON rendering of meter record.
"""
try:
ret_dict = SerialBlock... | def jsonRender(self, def_buf):
""" Translate the passed serial block into string only JSON.
Args:
def_buf (SerialBlock): Any :class:`~ekmmeters.SerialBlock` object.
Returns:
str: JSON rendering of meter record.
"""
try:
ret_dict = SerialBlock... | [
"Translate",
"the",
"passed",
"serial",
"block",
"into",
"string",
"only",
"JSON",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1803-L1822 | [
"def",
"jsonRender",
"(",
"self",
",",
"def_buf",
")",
":",
"try",
":",
"ret_dict",
"=",
"SerialBlock",
"(",
")",
"ret_dict",
"[",
"Field",
".",
"Meter_Address",
"]",
"=",
"self",
".",
"getMeterAddress",
"(",
")",
"for",
"fld",
"in",
"def_buf",
":",
"c... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.crcMeterRead | Internal read CRC wrapper.
Args:
raw_read (str): Bytes with implicit string cast from serial read
def_buf (SerialBlock): Populated read buffer.
Returns:
bool: True if passed CRC equals calculated CRC. | ekmmeters.py | def crcMeterRead(self, raw_read, def_buf):
""" Internal read CRC wrapper.
Args:
raw_read (str): Bytes with implicit string cast from serial read
def_buf (SerialBlock): Populated read buffer.
Returns:
bool: True if passed CRC equals calculated CRC.
"... | def crcMeterRead(self, raw_read, def_buf):
""" Internal read CRC wrapper.
Args:
raw_read (str): Bytes with implicit string cast from serial read
def_buf (SerialBlock): Populated read buffer.
Returns:
bool: True if passed CRC equals calculated CRC.
"... | [
"Internal",
"read",
"CRC",
"wrapper",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1824-L1872 | [
"def",
"crcMeterRead",
"(",
"self",
",",
"raw_read",
",",
"def_buf",
")",
":",
"try",
":",
"if",
"len",
"(",
"raw_read",
")",
"==",
"0",
":",
"ekm_log",
"(",
"\"(\"",
"+",
"self",
".",
"m_context",
"+",
"\") Empty return read.\"",
")",
"return",
"False",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.splitEkmDate | Break out a date from Omnimeter read.
Note a corrupt date will raise an exception when you
convert it to int to hand to this method.
Args:
dateint (int): Omnimeter datetime as int.
Returns:
tuple: Named tuple which breaks out as followws:
========... | ekmmeters.py | def splitEkmDate(dateint):
"""Break out a date from Omnimeter read.
Note a corrupt date will raise an exception when you
convert it to int to hand to this method.
Args:
dateint (int): Omnimeter datetime as int.
Returns:
tuple: Named tuple which breaks ... | def splitEkmDate(dateint):
"""Break out a date from Omnimeter read.
Note a corrupt date will raise an exception when you
convert it to int to hand to this method.
Args:
dateint (int): Omnimeter datetime as int.
Returns:
tuple: Named tuple which breaks ... | [
"Break",
"out",
"a",
"date",
"from",
"Omnimeter",
"read",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1875-L1912 | [
"def",
"splitEkmDate",
"(",
"dateint",
")",
":",
"date_str",
"=",
"str",
"(",
"dateint",
")",
"dt",
"=",
"namedtuple",
"(",
"'EkmDate'",
",",
"[",
"'yy'",
",",
"'mm'",
",",
"'dd'",
",",
"'weekday'",
",",
"'hh'",
",",
"'minutes'",
",",
"'ss'",
"]",
")... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.unregisterObserver | Remove an observer from the meter update() chain.
Args:
observer (MeterObserver): Subclassed MeterObserver. | ekmmeters.py | def unregisterObserver(self, observer):
""" Remove an observer from the meter update() chain.
Args:
observer (MeterObserver): Subclassed MeterObserver.
"""
if observer in self.m_observers:
self.m_observers.remove(observer)
pass | def unregisterObserver(self, observer):
""" Remove an observer from the meter update() chain.
Args:
observer (MeterObserver): Subclassed MeterObserver.
"""
if observer in self.m_observers:
self.m_observers.remove(observer)
pass | [
"Remove",
"an",
"observer",
"from",
"the",
"meter",
"update",
"()",
"chain",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1931-L1939 | [
"def",
"unregisterObserver",
"(",
"self",
",",
"observer",
")",
":",
"if",
"observer",
"in",
"self",
".",
"m_observers",
":",
"self",
".",
"m_observers",
".",
"remove",
"(",
"observer",
")",
"pass"
] | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.initSchd_1_to_4 | Initialize first tariff schedule :class:`~ekmmeters.SerialBlock`. | ekmmeters.py | def initSchd_1_to_4(self):
""" Initialize first tariff schedule :class:`~ekmmeters.SerialBlock`. """
self.m_schd_1_to_4["reserved_40"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_schd_1_to_4["Schedule_1_Period_1_Hour"] = [2, FieldType.Int, ScaleType.No, "", 0, False, True]
... | def initSchd_1_to_4(self):
""" Initialize first tariff schedule :class:`~ekmmeters.SerialBlock`. """
self.m_schd_1_to_4["reserved_40"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_schd_1_to_4["Schedule_1_Period_1_Hour"] = [2, FieldType.Int, ScaleType.No, "", 0, False, True]
... | [
"Initialize",
"first",
"tariff",
"schedule",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1941-L1997 | [
"def",
"initSchd_1_to_4",
"(",
"self",
")",
":",
"self",
".",
"m_schd_1_to_4",
"[",
"\"reserved_40\"",
"]",
"=",
"[",
"6",
",",
"FieldType",
".",
"Hex",
",",
"ScaleType",
".",
"No",
",",
"\"\"",
",",
"0",
",",
"False",
",",
"False",
"]",
"self",
".",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.initSchd_5_to_6 | Initialize second(and last) tariff schedule :class:`~ekmmeters.SerialBlock`. | ekmmeters.py | def initSchd_5_to_6(self):
""" Initialize second(and last) tariff schedule :class:`~ekmmeters.SerialBlock`. """
self.m_schd_5_to_6["reserved_30"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_schd_5_to_6["Schedule_5_Period_1_Hour"] = [2, FieldType.Int, ScaleType.No, "", 0, False... | def initSchd_5_to_6(self):
""" Initialize second(and last) tariff schedule :class:`~ekmmeters.SerialBlock`. """
self.m_schd_5_to_6["reserved_30"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_schd_5_to_6["Schedule_5_Period_1_Hour"] = [2, FieldType.Int, ScaleType.No, "", 0, False... | [
"Initialize",
"second",
"(",
"and",
"last",
")",
"tariff",
"schedule",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1999-L2033 | [
"def",
"initSchd_5_to_6",
"(",
"self",
")",
":",
"self",
".",
"m_schd_5_to_6",
"[",
"\"reserved_30\"",
"]",
"=",
"[",
"6",
",",
"FieldType",
".",
"Hex",
",",
"ScaleType",
".",
"No",
",",
"\"\"",
",",
"0",
",",
"False",
",",
"False",
"]",
"self",
".",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.getSchedulesBuffer | Return the requested tariff schedule :class:`~ekmmeters.SerialBlock` for meter.
Args:
period_group (int): A :class:`~ekmmeters.ReadSchedules` value.
Returns:
SerialBlock: The requested tariff schedules for meter. | ekmmeters.py | def getSchedulesBuffer(self, period_group):
""" Return the requested tariff schedule :class:`~ekmmeters.SerialBlock` for meter.
Args:
period_group (int): A :class:`~ekmmeters.ReadSchedules` value.
Returns:
SerialBlock: The requested tariff schedules for meter.
... | def getSchedulesBuffer(self, period_group):
""" Return the requested tariff schedule :class:`~ekmmeters.SerialBlock` for meter.
Args:
period_group (int): A :class:`~ekmmeters.ReadSchedules` value.
Returns:
SerialBlock: The requested tariff schedules for meter.
... | [
"Return",
"the",
"requested",
"tariff",
"schedule",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock",
"for",
"meter",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2035-L2050 | [
"def",
"getSchedulesBuffer",
"(",
"self",
",",
"period_group",
")",
":",
"empty_return",
"=",
"SerialBlock",
"(",
")",
"if",
"period_group",
"==",
"ReadSchedules",
".",
"Schedules_1_To_4",
":",
"return",
"self",
".",
"m_schd_1_to_4",
"elif",
"period_group",
"==",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.initHldyDates | Initialize holidays :class:`~ekmmeters.SerialBlock` | ekmmeters.py | def initHldyDates(self):
""" Initialize holidays :class:`~ekmmeters.SerialBlock` """
self.m_hldy["reserved_20"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_hldy["Holiday_1_Mon"] = [2, FieldType.Int, ScaleType.No, "", 0, False, True]
self.m_hldy["Holiday_1_Day"] = [2, F... | def initHldyDates(self):
""" Initialize holidays :class:`~ekmmeters.SerialBlock` """
self.m_hldy["reserved_20"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_hldy["Holiday_1_Mon"] = [2, FieldType.Int, ScaleType.No, "", 0, False, True]
self.m_hldy["Holiday_1_Day"] = [2, F... | [
"Initialize",
"holidays",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2052-L2099 | [
"def",
"initHldyDates",
"(",
"self",
")",
":",
"self",
".",
"m_hldy",
"[",
"\"reserved_20\"",
"]",
"=",
"[",
"6",
",",
"FieldType",
".",
"Hex",
",",
"ScaleType",
".",
"No",
",",
"\"\"",
",",
"0",
",",
"False",
",",
"False",
"]",
"self",
".",
"m_hld... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.initMons | Initialize first month tariff :class:`~ekmmeters.SerialBlock` for meter | ekmmeters.py | def initMons(self):
""" Initialize first month tariff :class:`~ekmmeters.SerialBlock` for meter """
self.m_mons["reserved_echo_cmd"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_mons["Month_1_Tot"] = [8, FieldType.Float, ScaleType.KWH, "", 0, False, False]
self.m_mons["... | def initMons(self):
""" Initialize first month tariff :class:`~ekmmeters.SerialBlock` for meter """
self.m_mons["reserved_echo_cmd"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_mons["Month_1_Tot"] = [8, FieldType.Float, ScaleType.KWH, "", 0, False, False]
self.m_mons["... | [
"Initialize",
"first",
"month",
"tariff",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock",
"for",
"meter"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2105-L2140 | [
"def",
"initMons",
"(",
"self",
")",
":",
"self",
".",
"m_mons",
"[",
"\"reserved_echo_cmd\"",
"]",
"=",
"[",
"6",
",",
"FieldType",
".",
"Hex",
",",
"ScaleType",
".",
"No",
",",
"\"\"",
",",
"0",
",",
"False",
",",
"False",
"]",
"self",
".",
"m_mo... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.initRevMons | Initialize second (and last) month tarifff :class:`~ekmmeters.SerialBlock` for meter. | ekmmeters.py | def initRevMons(self):
""" Initialize second (and last) month tarifff :class:`~ekmmeters.SerialBlock` for meter. """
self.m_rev_mons["reserved_echo_cmd"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_rev_mons["Month_1_Tot"] = [8, FieldType.Float, ScaleType.KWH, "", 0, False, Fal... | def initRevMons(self):
""" Initialize second (and last) month tarifff :class:`~ekmmeters.SerialBlock` for meter. """
self.m_rev_mons["reserved_echo_cmd"] = [6, FieldType.Hex, ScaleType.No, "", 0, False, False]
self.m_rev_mons["Month_1_Tot"] = [8, FieldType.Float, ScaleType.KWH, "", 0, False, Fal... | [
"Initialize",
"second",
"(",
"and",
"last",
")",
"month",
"tarifff",
":",
"class",
":",
"~ekmmeters",
".",
"SerialBlock",
"for",
"meter",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2142-L2177 | [
"def",
"initRevMons",
"(",
"self",
")",
":",
"self",
".",
"m_rev_mons",
"[",
"\"reserved_echo_cmd\"",
"]",
"=",
"[",
"6",
",",
"FieldType",
".",
"Hex",
",",
"ScaleType",
".",
"No",
",",
"\"\"",
",",
"0",
",",
"False",
",",
"False",
"]",
"self",
".",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.getMonthsBuffer | Get the months tariff SerialBlock for meter.
Args:
direction (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
SerialBlock: Requested months tariffs buffer. | ekmmeters.py | def getMonthsBuffer(self, direction):
""" Get the months tariff SerialBlock for meter.
Args:
direction (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
SerialBlock: Requested months tariffs buffer.
"""
if direction == ReadMonths.kWhReverse:
... | def getMonthsBuffer(self, direction):
""" Get the months tariff SerialBlock for meter.
Args:
direction (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
SerialBlock: Requested months tariffs buffer.
"""
if direction == ReadMonths.kWhReverse:
... | [
"Get",
"the",
"months",
"tariff",
"SerialBlock",
"for",
"meter",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2179-L2193 | [
"def",
"getMonthsBuffer",
"(",
"self",
",",
"direction",
")",
":",
"if",
"direction",
"==",
"ReadMonths",
".",
"kWhReverse",
":",
"return",
"self",
".",
"m_rev_mons",
"# default direction == ReadMonths.kWh",
"return",
"self",
".",
"m_mons"
] | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setTime | Serial set time with day of week calculation.
Args:
yy (int): Last two digits of year.
mm (int): Month 1-12.
dd (int): Day 1-31
hh (int): Hour 0 to 23.
minutes (int): Minutes 0 to 59.
ss (int): Seconds 0 to 59.
password (str): ... | ekmmeters.py | def setTime(self, yy, mm, dd, hh, minutes, ss, password="00000000"):
""" Serial set time with day of week calculation.
Args:
yy (int): Last two digits of year.
mm (int): Month 1-12.
dd (int): Day 1-31
hh (int): Hour 0 to 23.
minutes (int): Min... | def setTime(self, yy, mm, dd, hh, minutes, ss, password="00000000"):
""" Serial set time with day of week calculation.
Args:
yy (int): Last two digits of year.
mm (int): Month 1-12.
dd (int): Day 1-31
hh (int): Hour 0 to 23.
minutes (int): Min... | [
"Serial",
"set",
"time",
"with",
"day",
"of",
"week",
"calculation",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2231-L2309 | [
"def",
"setTime",
"(",
"self",
",",
"yy",
",",
"mm",
",",
"dd",
",",
"hh",
",",
"minutes",
",",
"ss",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setTime\"",
")",
"try",
":",
"if",
"mm"... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setCTRatio | Serial call to set CT ratio for attached inductive pickup.
Args:
new_ct (int): A :class:`~ekmmeters.CTRatio` value, a legal amperage setting.
password (str): Optional password.
Returns:
bool: True on completion with ACK. | ekmmeters.py | def setCTRatio(self, new_ct, password="00000000"):
""" Serial call to set CT ratio for attached inductive pickup.
Args:
new_ct (int): A :class:`~ekmmeters.CTRatio` value, a legal amperage setting.
password (str): Optional password.
Returns:
bool: True on com... | def setCTRatio(self, new_ct, password="00000000"):
""" Serial call to set CT ratio for attached inductive pickup.
Args:
new_ct (int): A :class:`~ekmmeters.CTRatio` value, a legal amperage setting.
password (str): Optional password.
Returns:
bool: True on com... | [
"Serial",
"call",
"to",
"set",
"CT",
"ratio",
"for",
"attached",
"inductive",
"pickup",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2311-L2359 | [
"def",
"setCTRatio",
"(",
"self",
",",
"new_ct",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"ret",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setCTRatio\"",
")",
"try",
":",
"self",
".",
"clearCmdMsg",
"(",
")",
"if",
"(",
"(",
"new_ct",
"!=... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.assignSchedule | Assign one schedule tariff period to meter bufffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extents.Schedules).
tariff (int): :class:`~ekmmeters.Tariffs` value or in range(Extents.Tariffs).
hour (int): Hour from 0-23.
minute (int):... | ekmmeters.py | def assignSchedule(self, schedule, period, hour, minute, tariff):
""" Assign one schedule tariff period to meter bufffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extents.Schedules).
tariff (int): :class:`~ekmmeters.Tariffs` value or in range(Exten... | def assignSchedule(self, schedule, period, hour, minute, tariff):
""" Assign one schedule tariff period to meter bufffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extents.Schedules).
tariff (int): :class:`~ekmmeters.Tariffs` value or in range(Exten... | [
"Assign",
"one",
"schedule",
"tariff",
"period",
"to",
"meter",
"bufffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2361-L2399 | [
"def",
"assignSchedule",
"(",
"self",
",",
"schedule",
",",
"period",
",",
"hour",
",",
"minute",
",",
"tariff",
")",
":",
"if",
"(",
"(",
"schedule",
"not",
"in",
"range",
"(",
"Extents",
".",
"Schedules",
")",
")",
"or",
"(",
"period",
"not",
"in",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.assignSeasonSchedule | Define a single season and assign a schedule
Args:
season (int): A :class:`~ekmmeters.Seasons` value or in range(Extent.Seasons).
month (int): Month 1-12.
day (int): Day 1-31.
schedule (int): A :class:`~ekmmeters.LCDItems` value or in range(Extent.Schedules).
... | ekmmeters.py | def assignSeasonSchedule(self, season, month, day, schedule):
""" Define a single season and assign a schedule
Args:
season (int): A :class:`~ekmmeters.Seasons` value or in range(Extent.Seasons).
month (int): Month 1-12.
day (int): Day 1-31.
schedule (in... | def assignSeasonSchedule(self, season, month, day, schedule):
""" Define a single season and assign a schedule
Args:
season (int): A :class:`~ekmmeters.Seasons` value or in range(Extent.Seasons).
month (int): Month 1-12.
day (int): Day 1-31.
schedule (in... | [
"Define",
"a",
"single",
"season",
"and",
"assign",
"a",
"schedule"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2455-L2492 | [
"def",
"assignSeasonSchedule",
"(",
"self",
",",
"season",
",",
"month",
",",
"day",
",",
"schedule",
")",
":",
"season",
"+=",
"1",
"schedule",
"+=",
"1",
"if",
"(",
"(",
"season",
"<",
"1",
")",
"or",
"(",
"season",
">",
"Extents",
".",
"Seasons",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setSeasonSchedules | Serial command to set seasons table.
If no dictionary is passed, the meter object buffer is used.
Args:
cmd_dict (dict): Optional dictionary of season schedules.
password (str): Optional password
Returns:
bool: True on completion and ACK. | ekmmeters.py | def setSeasonSchedules(self, cmd_dict=None, password="00000000"):
""" Serial command to set seasons table.
If no dictionary is passed, the meter object buffer is used.
Args:
cmd_dict (dict): Optional dictionary of season schedules.
password (str): Optional password
... | def setSeasonSchedules(self, cmd_dict=None, password="00000000"):
""" Serial command to set seasons table.
If no dictionary is passed, the meter object buffer is used.
Args:
cmd_dict (dict): Optional dictionary of season schedules.
password (str): Optional password
... | [
"Serial",
"command",
"to",
"set",
"seasons",
"table",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2494-L2544 | [
"def",
"setSeasonSchedules",
"(",
"self",
",",
"cmd_dict",
"=",
"None",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setSeasonSchedules\"",
")",
"if",
"not",
"cmd_dict",
":",
"cmd_dict",
"=",
"sel... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.assignHolidayDate | Set a singe holiday day and month in object buffer.
There is no class style enum for holidays.
Args:
holiday (int): 0-19 or range(Extents.Holidays).
month (int): Month 1-12.
day (int): Day 1-31
Returns:
bool: True on completion. | ekmmeters.py | def assignHolidayDate(self, holiday, month, day):
""" Set a singe holiday day and month in object buffer.
There is no class style enum for holidays.
Args:
holiday (int): 0-19 or range(Extents.Holidays).
month (int): Month 1-12.
day (int): Day 1-31
R... | def assignHolidayDate(self, holiday, month, day):
""" Set a singe holiday day and month in object buffer.
There is no class style enum for holidays.
Args:
holiday (int): 0-19 or range(Extents.Holidays).
month (int): Month 1-12.
day (int): Day 1-31
R... | [
"Set",
"a",
"singe",
"holiday",
"day",
"and",
"month",
"in",
"object",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2546-L2574 | [
"def",
"assignHolidayDate",
"(",
"self",
",",
"holiday",
",",
"month",
",",
"day",
")",
":",
"holiday",
"+=",
"1",
"if",
"(",
"month",
">",
"12",
")",
"or",
"(",
"month",
"<",
"0",
")",
"or",
"(",
"day",
">",
"31",
")",
"or",
"(",
"day",
"<",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setHolidayDates | Serial call to set holiday list.
If a buffer dictionary is not supplied, the method will use
the class object buffer populated with assignHolidayDate.
Args:
cmd_dict (dict): Optional dictionary of holidays.
password (str): Optional password.
Returns:
... | ekmmeters.py | def setHolidayDates(self, cmd_dict=None, password="00000000"):
""" Serial call to set holiday list.
If a buffer dictionary is not supplied, the method will use
the class object buffer populated with assignHolidayDate.
Args:
cmd_dict (dict): Optional dictionary of holidays.
... | def setHolidayDates(self, cmd_dict=None, password="00000000"):
""" Serial call to set holiday list.
If a buffer dictionary is not supplied, the method will use
the class object buffer populated with assignHolidayDate.
Args:
cmd_dict (dict): Optional dictionary of holidays.
... | [
"Serial",
"call",
"to",
"set",
"holiday",
"list",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2576-L2653 | [
"def",
"setHolidayDates",
"(",
"self",
",",
"cmd_dict",
"=",
"None",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setHolidayDates\"",
")",
"if",
"not",
"cmd_dict",
":",
"cmd_dict",
"=",
"self",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.setWeekendHolidaySchedules | Serial call to set weekend and holiday :class:`~ekmmeters.Schedules`.
Args:
new_wknd (int): :class:`~ekmmeters.Schedules` value to assign.
new_hldy (int): :class:`~ekmmeters.Schedules` value to assign.
password (str): Optional password..
Returns:
bool: T... | ekmmeters.py | def setWeekendHolidaySchedules(self, new_wknd, new_hldy, password="00000000"):
""" Serial call to set weekend and holiday :class:`~ekmmeters.Schedules`.
Args:
new_wknd (int): :class:`~ekmmeters.Schedules` value to assign.
new_hldy (int): :class:`~ekmmeters.Schedules` value to as... | def setWeekendHolidaySchedules(self, new_wknd, new_hldy, password="00000000"):
""" Serial call to set weekend and holiday :class:`~ekmmeters.Schedules`.
Args:
new_wknd (int): :class:`~ekmmeters.Schedules` value to assign.
new_hldy (int): :class:`~ekmmeters.Schedules` value to as... | [
"Serial",
"call",
"to",
"set",
"weekend",
"and",
"holiday",
":",
"class",
":",
"~ekmmeters",
".",
"Schedules",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2655-L2688 | [
"def",
"setWeekendHolidaySchedules",
"(",
"self",
",",
"new_wknd",
",",
"new_hldy",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setWeekendHolidaySchedules\"",
")",
"try",
":",
"if",
"not",
"self",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.readSchedules | Serial call to read schedule tariffs buffer
Args:
tableset (int): :class:`~ekmmeters.ReadSchedules` buffer to return.
Returns:
bool: True on completion and ACK. | ekmmeters.py | def readSchedules(self, tableset):
""" Serial call to read schedule tariffs buffer
Args:
tableset (int): :class:`~ekmmeters.ReadSchedules` buffer to return.
Returns:
bool: True on completion and ACK.
"""
self.setContext("readSchedules")
try:
... | def readSchedules(self, tableset):
""" Serial call to read schedule tariffs buffer
Args:
tableset (int): :class:`~ekmmeters.ReadSchedules` buffer to return.
Returns:
bool: True on completion and ACK.
"""
self.setContext("readSchedules")
try:
... | [
"Serial",
"call",
"to",
"read",
"schedule",
"tariffs",
"buffer"
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2690-L2731 | [
"def",
"readSchedules",
"(",
"self",
",",
"tableset",
")",
":",
"self",
".",
"setContext",
"(",
"\"readSchedules\"",
")",
"try",
":",
"req_table",
"=",
"binascii",
".",
"hexlify",
"(",
"str",
"(",
"tableset",
")",
".",
"zfill",
"(",
"1",
")",
")",
"req... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.extractSchedule | Read a single schedule tariff from meter object buffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extent.Schedules).
tariff (int): A :class:`~ekmmeters.Tariffs` value or in range(Extent.Tariffs).
Returns:
bool: True on completion. | ekmmeters.py | def extractSchedule(self, schedule, period):
""" Read a single schedule tariff from meter object buffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extent.Schedules).
tariff (int): A :class:`~ekmmeters.Tariffs` value or in range(Extent.Tariffs).
... | def extractSchedule(self, schedule, period):
""" Read a single schedule tariff from meter object buffer.
Args:
schedule (int): A :class:`~ekmmeters.Schedules` value or in range(Extent.Schedules).
tariff (int): A :class:`~ekmmeters.Tariffs` value or in range(Extent.Tariffs).
... | [
"Read",
"a",
"single",
"schedule",
"tariff",
"from",
"meter",
"object",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2733-L2778 | [
"def",
"extractSchedule",
"(",
"self",
",",
"schedule",
",",
"period",
")",
":",
"ret",
"=",
"namedtuple",
"(",
"\"ret\"",
",",
"[",
"\"Hour\"",
",",
"\"Min\"",
",",
"\"Tariff\"",
",",
"\"Period\"",
",",
"\"Schedule\"",
"]",
")",
"work_table",
"=",
"self",... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.readMonthTariffs | Serial call to read month tariffs block into meter object buffer.
Args:
months_type (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
bool: True on completion. | ekmmeters.py | def readMonthTariffs(self, months_type):
""" Serial call to read month tariffs block into meter object buffer.
Args:
months_type (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
bool: True on completion.
"""
self.setContext("readMonthTariffs")
... | def readMonthTariffs(self, months_type):
""" Serial call to read month tariffs block into meter object buffer.
Args:
months_type (int): A :class:`~ekmmeters.ReadMonths` value.
Returns:
bool: True on completion.
"""
self.setContext("readMonthTariffs")
... | [
"Serial",
"call",
"to",
"read",
"month",
"tariffs",
"block",
"into",
"meter",
"object",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2780-L2815 | [
"def",
"readMonthTariffs",
"(",
"self",
",",
"months_type",
")",
":",
"self",
".",
"setContext",
"(",
"\"readMonthTariffs\"",
")",
"try",
":",
"req_type",
"=",
"binascii",
".",
"hexlify",
"(",
"str",
"(",
"months_type",
")",
".",
"zfill",
"(",
"1",
")",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.extractMonthTariff | Extract the tariff for a single month from the meter object buffer.
Args:
month (int): A :class:`~ekmmeters.Months` value or range(Extents.Months).
Returns:
tuple: The eight tariff period totals for month. The return tuple breaks out as follows:
================= ... | ekmmeters.py | def extractMonthTariff(self, month):
""" Extract the tariff for a single month from the meter object buffer.
Args:
month (int): A :class:`~ekmmeters.Months` value or range(Extents.Months).
Returns:
tuple: The eight tariff period totals for month. The return tuple break... | def extractMonthTariff(self, month):
""" Extract the tariff for a single month from the meter object buffer.
Args:
month (int): A :class:`~ekmmeters.Months` value or range(Extents.Months).
Returns:
tuple: The eight tariff period totals for month. The return tuple break... | [
"Extract",
"the",
"tariff",
"for",
"a",
"single",
"month",
"from",
"the",
"meter",
"object",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2817-L2864 | [
"def",
"extractMonthTariff",
"(",
"self",
",",
"month",
")",
":",
"ret",
"=",
"namedtuple",
"(",
"\"ret\"",
",",
"[",
"\"Month\"",
",",
"Field",
".",
"kWh_Tariff_1",
",",
"Field",
".",
"kWh_Tariff_2",
",",
"Field",
".",
"kWh_Tariff_3",
",",
"Field",
".",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.readHolidayDates | Serial call to read holiday dates into meter object buffer.
Returns:
bool: True on completion. | ekmmeters.py | def readHolidayDates(self):
""" Serial call to read holiday dates into meter object buffer.
Returns:
bool: True on completion.
"""
self.setContext("readHolidayDates")
try:
req_str = "0152310230304230282903"
self.request(False)
req_... | def readHolidayDates(self):
""" Serial call to read holiday dates into meter object buffer.
Returns:
bool: True on completion.
"""
self.setContext("readHolidayDates")
try:
req_str = "0152310230304230282903"
self.request(False)
req_... | [
"Serial",
"call",
"to",
"read",
"holiday",
"dates",
"into",
"meter",
"object",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2866-L2892 | [
"def",
"readHolidayDates",
"(",
"self",
")",
":",
"self",
".",
"setContext",
"(",
"\"readHolidayDates\"",
")",
"try",
":",
"req_str",
"=",
"\"0152310230304230282903\"",
"self",
".",
"request",
"(",
"False",
")",
"req_crc",
"=",
"self",
".",
"calc_crc16",
"(",
... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
test | Meter.extractHolidayDate | Read a single holiday date from meter buffer.
Args:
setting_holiday (int): Holiday from 0-19 or in range(Extents.Holidays)
Returns:
tuple: Holiday tuple, elements are strings.
=============== ======================
Holiday Holiday 0-19 as strin... | ekmmeters.py | def extractHolidayDate(self, setting_holiday):
""" Read a single holiday date from meter buffer.
Args:
setting_holiday (int): Holiday from 0-19 or in range(Extents.Holidays)
Returns:
tuple: Holiday tuple, elements are strings.
=============== =============... | def extractHolidayDate(self, setting_holiday):
""" Read a single holiday date from meter buffer.
Args:
setting_holiday (int): Holiday from 0-19 or in range(Extents.Holidays)
Returns:
tuple: Holiday tuple, elements are strings.
=============== =============... | [
"Read",
"a",
"single",
"holiday",
"date",
"from",
"meter",
"buffer",
"."
] | ekmmetering/ekmmeters | python | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L2894-L2929 | [
"def",
"extractHolidayDate",
"(",
"self",
",",
"setting_holiday",
")",
":",
"ret",
"=",
"namedtuple",
"(",
"\"result\"",
",",
"[",
"\"Holiday\"",
",",
"\"Month\"",
",",
"\"Day\"",
"]",
")",
"setting_holiday",
"+=",
"1",
"ret",
".",
"Holiday",
"=",
"str",
"... | b3748bdf30263bfa46ea40157bdf8df2522e1904 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.