_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q275900
missing_categories
test
def missing_categories(context): ''' Adds the categories that the user does not currently have. ''' user = user_for_context(context) categories_available = set(CategoryController.available_categories(user)) items = ItemController(user).items_pending_or_purchased() categories_held = set() for p...
python
{ "resource": "" }
q275901
available_credit
test
def available_credit(context): ''' Calculates the sum of unclaimed credit from this user's credit notes. Returns: Decimal: the sum of the values of unclaimed credit notes for the current user. ''' notes = commerce.CreditNote.unclaimed().filter( invoice__user=user_for_conte...
python
{ "resource": "" }
q275902
sold_out_and_unregistered
test
def sold_out_and_unregistered(context): ''' If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a ...
python
{ "resource": "" }
q275903
guided_registration
test
def guided_registration(request, page_number=None): ''' Goes through the registration process in order, making sure user sees all valid categories. The user must be logged in to see this view. Parameter: page_number: 1) Profile form (and e-mail address?) 2) Ticket type ...
python
{ "resource": "" }
q275904
edit_profile
test
def edit_profile(request): ''' View for editing an attendee's profile The user must be logged in to edit their profile. Returns: redirect or render: In the case of a ``POST`` request, it'll redirect to ``dashboard``, or otherwise, it will render ``registrasion/profile_form....
python
{ "resource": "" }
q275905
_handle_profile
test
def _handle_profile(request, prefix): ''' Returns a profile form instance, and a boolean which is true if the form was handled. ''' attendee = people.Attendee.get_instance(request.user) try: profile = attendee.attendeeprofilebase profile = people.AttendeeProfileBase.objects.get_subclass...
python
{ "resource": "" }
q275906
product_category
test
def product_category(request, category_id): ''' Form for selecting products from an individual product category. Arguments: category_id (castable to int): The id of the category to display. Returns: redirect or render: If the form has been sucessfully submitted, redirect to ...
python
{ "resource": "" }
q275907
_handle_products
test
def _handle_products(request, category, products, prefix): ''' Handles a products list form in the given request. Returns the form instance, the discounts applicable to this form, and whether the contents were handled. ''' current_cart = CartController.for_user(request.user) ProductsForm = forms.P...
python
{ "resource": "" }
q275908
_handle_voucher
test
def _handle_voucher(request, prefix): ''' Handles a voucher form in the given request. Returns the voucher form instance, and whether the voucher code was handled. ''' voucher_form = forms.VoucherForm(request.POST or None, prefix=prefix) current_cart = CartController.for_user(request.user) if (vou...
python
{ "resource": "" }
q275909
checkout
test
def checkout(request, user_id=None): ''' Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailabl...
python
{ "resource": "" }
q275910
invoice_access
test
def invoice_access(request, access_code): ''' Redirects to an invoice for the attendee that matches the given access code, if any. If the attendee has multiple invoices, we use the following tie-break: - If there's an unpaid invoice, show that, otherwise - If there's a paid invoice, show the most ...
python
{ "resource": "" }
q275911
invoice
test
def invoice(request, invoice_id, access_code=None): ''' Displays an invoice. This view is not authenticated, but it will only allow access to either: the user the invoice belongs to; staff; or a request made with the correct access code. Arguments: invoice_id (castable to int): The invoic...
python
{ "resource": "" }
q275912
manual_payment
test
def manual_payment(request, invoice_id): ''' Allows staff to make manual payments or refunds on an invoice. This form requires a login, and the logged in user needs to be staff. Arguments: invoice_id (castable to int): The invoice ID to be paid Returns: render: Renders ``r...
python
{ "resource": "" }
q275913
refund
test
def refund(request, invoice_id): ''' Marks an invoice as refunded and requests a credit note for the full amount paid against the invoice. This view requires a login, and the logged in user must be staff. Arguments: invoice_id (castable to int): The ID of the invoice to refund. Returns: ...
python
{ "resource": "" }
q275914
credit_note
test
def credit_note(request, note_id, access_code=None): ''' Displays a credit note. If ``request`` is a ``POST`` request, forms for applying or refunding a credit note will be processed. This view requires a login, and the logged in user must be staff. Arguments: note_id (castable to int): T...
python
{ "resource": "" }
q275915
amend_registration
test
def amend_registration(request, user_id): ''' Allows staff to amend a user's current registration cart, and etc etc. ''' user = User.objects.get(id=int(user_id)) current_cart = CartController.for_user(user) items = commerce.ProductItem.objects.filter( cart=current_cart.cart, ).select_r...
python
{ "resource": "" }
q275916
extend_reservation
test
def extend_reservation(request, user_id, days=7): ''' Allows staff to extend the reservation on a given user's cart. ''' user = User.objects.get(id=int(user_id)) cart = CartController.for_user(user) cart.extend_reservation(datetime.timedelta(days=days)) return redirect(request.META["HTTP_REFER...
python
{ "resource": "" }
q275917
invoice_mailout
test
def invoice_mailout(request): ''' Allows staff to send emails to users based on their invoice status. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.InvoiceEmailForm( request.POST or None, ...
python
{ "resource": "" }
q275918
badges
test
def badges(request): ''' Either displays a form containing a list of users with badges to render, or returns a .zip file containing their badges. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.Invo...
python
{ "resource": "" }
q275919
render_badge
test
def render_badge(user): ''' Renders a single user's badge. ''' data = { "user": user, } t = loader.get_template('registrasion/badge.svg') return t.render(data)
python
{ "resource": "" }
q275920
DiscountController.available_discounts
test
def available_discounts(cls, user, categories, products): ''' Returns all discounts available to this user for the given categories and products. The discounts also list the available quantity for this user, not including products that are pending purchase. ''' filtered_clauses = cls._f...
python
{ "resource": "" }
q275921
DiscountController._annotate_with_past_uses
test
def _annotate_with_past_uses(cls, queryset, user): ''' Annotates the queryset with a usage count for that discount claus by the given user. ''' if queryset.model == conditions.DiscountForCategory: matches = ( Q(category=F('discount__discountitem__product__category'))...
python
{ "resource": "" }
q275922
ProductController.available_products
test
def available_products(cls, user, category=None, products=None): ''' Returns a list of all of the products that are available per flag conditions from the given categories. ''' if category is None and products is None: raise ValueError("You must provide products or a category") ...
python
{ "resource": "" }
q275923
CreditNoteController.apply_to_invoice
test
def apply_to_invoice(self, invoice): ''' Applies the total value of this credit note to the specified invoice. If this credit note overpays the invoice, a new credit note containing the residual value will be created. Raises ValidationError if the given invoice is not allowed to be ...
python
{ "resource": "" }
q275924
CreditNoteController.cancellation_fee
test
def cancellation_fee(self, percentage): ''' Generates an invoice with a cancellation fee, and applies credit to the invoice. percentage (Decimal): The percentage of the credit note to turn into a cancellation fee. Must be 0 <= percentage <= 100. ''' # Local import to fi...
python
{ "resource": "" }
q275925
generate_access_code
test
def generate_access_code(): ''' Generates an access code for users' payments as well as their fulfilment code for check-in. The access code will 4 characters long, which allows for 1,500,625 unique codes, which really should be enough for anyone. ''' length = 6 # all upper-case letters + digits...
python
{ "resource": "" }
q275926
lazy
test
def lazy(function, *args, **kwargs): ''' Produces a callable so that functions can be lazily evaluated in templates. Arguments: function (callable): The function to call at evaluation time. args: Positional arguments, passed directly to ``function``. kwargs: Keyword arguments, pa...
python
{ "resource": "" }
q275927
get_object_from_name
test
def get_object_from_name(name): ''' Returns the named object. Arguments: name (str): A string of form `package.subpackage.etc.module.property`. This function will import `package.subpackage.etc.module` and return `property` from that module. ''' dot = name.rindex(".") ...
python
{ "resource": "" }
q275928
InvoiceController.for_cart
test
def for_cart(cls, cart): ''' Returns an invoice object for a given cart at its current revision. If such an invoice does not exist, the cart is validated, and if valid, an invoice is generated.''' cart.refresh_from_db() try: invoice = commerce.Invoice.objects.exclude...
python
{ "resource": "" }
q275929
InvoiceController.manual_invoice
test
def manual_invoice(cls, user, due_delta, description_price_pairs): ''' Generates an invoice for arbitrary items, not held in a user's cart. Arguments: user (User): The user the invoice is being generated for. due_delta (datetime.timedelta): The length until the invoice i...
python
{ "resource": "" }
q275930
InvoiceController._generate_from_cart
test
def _generate_from_cart(cls, cart): ''' Generates an invoice for the given cart. ''' cart.refresh_from_db() # Generate the line items from the cart. product_items = commerce.ProductItem.objects.filter(cart=cart) product_items = product_items.select_related( "produc...
python
{ "resource": "" }
q275931
InvoiceController._apply_credit_notes
test
def _apply_credit_notes(cls, invoice): ''' Applies the user's credit notes to the given invoice on creation. ''' # We only automatically apply credit notes if this is the *only* # unpaid invoice for this user. invoices = commerce.Invoice.objects.filter( user=invoice....
python
{ "resource": "" }
q275932
InvoiceController.can_view
test
def can_view(self, user=None, access_code=None): ''' Returns true if the accessing user is allowed to view this invoice, or if the given access code matches this invoice's user's access code. ''' if user == self.invoice.user: return True if user.is_staff: ...
python
{ "resource": "" }
q275933
InvoiceController._refresh
test
def _refresh(self): ''' Refreshes the underlying invoice and cart objects. ''' self.invoice.refresh_from_db() if self.invoice.cart: self.invoice.cart.refresh_from_db()
python
{ "resource": "" }
q275934
InvoiceController.validate_allowed_to_pay
test
def validate_allowed_to_pay(self): ''' Passes cleanly if we're allowed to pay, otherwise raise a ValidationError. ''' self._refresh() if not self.invoice.is_unpaid: raise ValidationError("You can only pay for unpaid invoices.") if not self.invoice.cart: ...
python
{ "resource": "" }
q275935
InvoiceController.update_status
test
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() ...
python
{ "resource": "" }
q275936
InvoiceController._mark_paid
test
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...
python
{ "resource": "" }
q275937
InvoiceController._invoice_matches_cart
test
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...
python
{ "resource": "" }
q275938
InvoiceController.update_validity
test
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...
python
{ "resource": "" }
q275939
InvoiceController.void
test
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.") ...
python
{ "resource": "" }
q275940
InvoiceController.refund
test
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(...
python
{ "resource": "" }
q275941
InvoiceController.email
test
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)
python
{ "resource": "" }
q275942
GenData.update
test
def update(self, data): """Update the object with new data.""" fields = [ 'id', 'status', 'type', 'persistence', 'date_start', 'date_finish', 'date_created', 'date_modified', 'checksum', ...
python
{ "resource": "" }
q275943
GenData._flatten_field
test
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...
python
{ "resource": "" }
q275944
GenData.print_downloads
test
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']))
python
{ "resource": "" }
q275945
GenData.download
test
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...
python
{ "resource": "" }
q275946
Genesis.project_data
test
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...
python
{ "resource": "" }
q275947
Genesis.processors
test
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...
python
{ "resource": "" }
q275948
Genesis.print_processor_inputs
test
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...
python
{ "resource": "" }
q275949
Genesis.rundata
test
def rundata(self, strjson): """POST JSON data object to server""" d = json.loads(strjson) return self.api.data.post(d)
python
{ "resource": "" }
q275950
Genesis.upload
test
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...
python
{ "resource": "" }
q275951
Genesis._upload_file
test
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...
python
{ "resource": "" }
q275952
Genesis.download
test
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 """ ...
python
{ "resource": "" }
q275953
get_subclasses
test
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
python
{ "resource": "" }
q275954
Action.get_repo_and_project
test
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...
python
{ "resource": "" }
q275955
get_variant_phenotypes_with_suggested_changes
test
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) ...
python
{ "resource": "" }
q275956
get_variant_phenotypes_with_suggested_changes_merged
test
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...
python
{ "resource": "" }
q275957
search_variants_by_coordinates
test
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 ...
python
{ "resource": "" }
q275958
bulk_search_variants_by_coordinates
test
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....
python
{ "resource": "" }
q275959
CivicRecord.update
test
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...
python
{ "resource": "" }
q275960
ToolApp.uniqify
test
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)]
python
{ "resource": "" }
q275961
ToolApp.authenticate
test
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('...
python
{ "resource": "" }
q275962
ToolApp._list_select
test
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 ...
python
{ "resource": "" }
q275963
ToolApp.get_saved_issue_data
test
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): ...
python
{ "resource": "" }
q275964
ToolApp.move_saved_issue_data
test
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...
python
{ "resource": "" }
q275965
ToolApp.get_saved_task_data
test
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 ...
python
{ "resource": "" }
q275966
ToolApp.get_asana_task
test
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
python
{ "resource": "" }
q275967
JSONData.save
test
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)
python
{ "resource": "" }
q275968
JSONData.apply
test
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 ...
python
{ "resource": "" }
q275969
transport_task
test
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, ...
python
{ "resource": "" }
q275970
flush
test
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...
python
{ "resource": "" }
q275971
task_create
test
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...
python
{ "resource": "" }
q275972
format_task_numbers_with_links
test
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...
python
{ "resource": "" }
q275973
TransportWorker.create_missing_task
test
def create_missing_task(self, asana_workspace_id, name, assignee, projects, completed, issue_number, issue_html_url, ...
python
{ "resource": "" }
q275974
GenProject.data_types
test
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))
python
{ "resource": "" }
q275975
ekm_log
test
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...
python
{ "resource": "" }
q275976
SerialPort.initPort
test
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, ...
python
{ "resource": "" }
q275977
SerialPort.setPollingValues
test
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
python
{ "resource": "" }
q275978
MeterDB.combineAB
test
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()...
python
{ "resource": "" }
q275979
SqliteMeterDB.renderJsonReadsSince
test
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. ""...
python
{ "resource": "" }
q275980
Meter.setContext
test
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...
python
{ "resource": "" }
q275981
Meter.calcPF
test
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 - ...
python
{ "resource": "" }
q275982
Meter.setMaxDemandPeriod
test
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....
python
{ "resource": "" }
q275983
Meter.setMeterPassword
test
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. "...
python
{ "resource": "" }
q275984
Meter.unpackStruct
test
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...
python
{ "resource": "" }
q275985
Meter.convertData
test
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:...
python
{ "resource": "" }
q275986
Meter.jsonRender
test
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...
python
{ "resource": "" }
q275987
Meter.crcMeterRead
test
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. "...
python
{ "resource": "" }
q275988
Meter.splitEkmDate
test
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 ...
python
{ "resource": "" }
q275989
Meter.getMonthsBuffer
test
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: ...
python
{ "resource": "" }
q275990
Meter.setCTRatio
test
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...
python
{ "resource": "" }
q275991
Meter.assignSchedule
test
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...
python
{ "resource": "" }
q275992
Meter.assignSeasonSchedule
test
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...
python
{ "resource": "" }
q275993
Meter.setSeasonSchedules
test
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 ...
python
{ "resource": "" }
q275994
Meter.assignHolidayDate
test
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...
python
{ "resource": "" }
q275995
Meter.readSchedules
test
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: ...
python
{ "resource": "" }
q275996
Meter.extractSchedule
test
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). ...
python
{ "resource": "" }
q275997
Meter.readMonthTariffs
test
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") ...
python
{ "resource": "" }
q275998
Meter.extractMonthTariff
test
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...
python
{ "resource": "" }
q275999
Meter.readHolidayDates
test
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_...
python
{ "resource": "" }