code stringlengths 1 18.2k |
|---|
def update_course_settings(self, course_id, allow_student_discussion_editing=None, allow_student_discussion_topics=None, allow_student_forum_attachments=None, allow_student_organized_groups=None, hide_distribution_graphs=None, hide_final_grades=None, home_page_announcement_limit=None, lock_all_announcements=None, restr... |
if hide_final_grades is not None: data["hide_final_grades"] = hide_final_grades # OPTIONAL - hide_distribution_graphs """Hide grade distribution graphs from students""" if hide_distribution_graphs is not None: data["hide_distribution_graphs"] = hide_distribution_graphs # OPTIONAL - lock_all_announcements """Disable com... |
enabled via show_announcements_on_home_page""" if home_page_announcement_limit is not None: data["home_page_announcement_limit"] = home_page_announcement_limit self.logger.debug("PUT /api/v1/courses/{course_id}/settings with query params: {params} and form data: {data}".format(params=params, data=data, **path)) return ... |
def update_course(self, id, course_account_id=None, course_allow_student_forum_attachments=None, course_allow_student_wiki_edits=None, course_allow_wiki_comments=None, course_apply_assignment_group_weights=None, course_course_code=None, course_course_format=None, course_end_at=None, course_event=None, course_grading_st... |
course. If omitted, the course will be named "Unnamed Course." """ if course_name is not None: data["course[name]"] = course_name # OPTIONAL - course[course_code] """The course code for the course.""" if course_course_code is not None: data["course[course_code]"] = course_course_code # OPTIONAL - course[start_at] """Co... |
Attribution No Derivatives) - 'cc_by_sa' (CC Attribution Share Alike) - 'cc_by' (CC Attribution) - 'public_domain' (Public Domain).""" if course_license is not None: data["course[license]"] = course_license # OPTIONAL - course[is_public] """Set to true if course is public to both authenticated and unauthenticated users... |
the course.""" if course_public_description is not None: data["course[public_description]"] = course_public_description # OPTIONAL - course[allow_student_wiki_edits] """If true, students will be able to modify the course wiki.""" if course_allow_student_wiki_edits is not None: data["course[allow_student_wiki_edits]"] =... |
restrict user enrollments to the start and end dates of the course.""" if course_restrict_enrollments_to_course_dates is not None: data["course[restrict_enrollments_to_course_dates]"] = course_restrict_enrollments_to_course_dates # OPTIONAL - course[term_id] """The unique ID of the term to create to course in.""" if co... |
zones}.""" if course_time_zone is not None: data["course[time_zone]"] = course_time_zone # OPTIONAL - course[apply_assignment_group_weights] """Set to true to weight final grade based on assignment groups percentages.""" if course_apply_assignment_group_weights is not None: data["course[apply_assignment_group_weights]"... |
students have received graded submissions. * 'offer' makes a course visible to students. This action is also called "publish" on the web site. * 'conclude' prevents future enrollments and makes a course read-only for all participants. The course still appears in prior-enrollment lists. * 'delete' completely removes the... |
"undelete"]) data["course[event]"] = course_event # OPTIONAL - course[syllabus_body] """The syllabus body for the course""" if course_syllabus_body is not None: data["course[syllabus_body]"] = course_syllabus_body # OPTIONAL - course[grading_standard_id] """The grading standard id to set for the course. If no value is ... |
a request it will fail.""" if course_image_id is not None: data["course[image_id]"] = course_image_id # OPTIONAL - course[image_url] """This is a URL to an image to be used as the course image. This will clear the course's image_id setting if set. If you attempt to provide image_url and image_id in a request it will fa... |
def update_courses(self, event, account_id, course_ids): """ Update courses. Update multiple courses in an account. Operates asynchronously; use the {api:ProgressController#show progress endpoint} to query the status of an operation. The action to take on each course. Must be one of 'offer', 'conclude', 'delete', or 'u... |
conclude rather than delete a course if there is any possibility the course will be used again.) The recovered course will be unpublished. Deleted enrollments will not be recovered. """ path = {} data = {} params = {} # REQUIRED - PATH - account_id """ID""" path["account_id"] = account_id # REQUIRED - course_ids """Lis... |
def reset_course(self, course_id): """ Reset a course. Deletes the current course, and creates a new equivalent course with no content, but all sections and users moved over. """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id self.logger.debug("POST /api/v1/courses/... |
def get_effective_due_dates(self, course_id, assignment_ids=None): """ Get effective due dates. For each assignment in the course, returns each assigned student's ID and their corresponding due date along with some Multiple Grading Periods data. Returns a collection with keys representing assignment IDs and values as a... |
not None: params["assignment_ids"] = assignment_ids self.logger.debug("GET /api/v1/courses/{course_id}/effective_due_dates with query params: {params} and form data: {data}".format(params=params, data=data, **path)) return self.generic_request("GET", "/api/v1/courses/{course_id}/effective_due_dates".format(**path), dat... |
def permissions(self, course_id, permissions=None): """ Permissions. Returns permission information for provided course & current_user """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # OPTIONAL - permissions """List of permissions to check against authenticated u... |
def copy_course_content(self, course_id, exclude=None, only=None, source_course=None): """ Copy course content. DEPRECATED: Please use the {api:ContentMigrationsController#create Content Migrations API} Copies content from one course into another. The default is to copy all course content. You can control specific type... |
None: self._validate_enum(exclude, ["course_settings", "assignments", "external_tools", "files", "topics", "calendar_events", "quizzes", "wiki_pages", "modules", "outcomes"]) data["except"] = exclude # OPTIONAL - only """A list of the course content types to copy, all areas not listed will not be copied.""" if only is ... |
def page(title, description, element_list=None, tab_list=None): """ Returns a dictionary representing a new page to display elements. This can be thought of as a simple container for displaying multiple types of information. The ``section`` method can be used to create separate tabs. Args: title: The title to display d... |
if tab_list is not None: if isinstance(tab_list, list): _page['Data']['Tabs'] = tab_list else: _page['Data']['Tabs'] = [tab_list] return _page |
def tab(tab_name, element_list=None, section_list=None): """ Returns a dictionary representing a new tab to display elements. This can be thought of as a simple container for displaying multiple types of information. Args: tab_name: The title to display element_list: The list of elements to display. If a single element... |
_tab['Elements'].append(element_list) return _tab |
def section(title, element_list): """ Returns a dictionary representing a new section. Sections contain a list of elements that are displayed separately from the global elements on the page. Args: title: The title of the section to be displayed element_list: The list of elements to display within the section Returns: A... |
def image(title, desc, image_name, group=None, height=None): """ Builds an image element. Image elements are primarily created and then wrapped into an image gallery element. This is not required behavior, however and it's independent usage should be allowed depending on the behavior required. The Javascript will searc... |
as an image element """ ie = { 'Type': 'Image', 'Title': title, 'Description': desc, 'Plot File': image_name, } if group: ie['Group'] = group if height: ie['Height'] = height return ie |
def commands(self): """ Fetch individual SQL commands from a SQL commands containing many commands. :return: List of commands """ # Retrieve all commands via split function or splitting on ';' print('\tRetrieving commands from', self.sql_script) print('\tUsing command splitter algorithm {0}'.format(self.split_algo)) wi... |
def execute(self, commands=None, ignored_commands=('DROP', 'UNLOCK', 'LOCK'), execute_fails=True, max_executions=MAX_EXECUTION_ATTEMPTS): """ Sequentially execute a list of SQL commands. Check if commands property has already been fetched, if so use the fetched_commands rather than getting them again. :param commands: ... |
self._execute_commands(commands) # Dump failed commands to text files print('\t' + str(success), 'successful commands') if len(fail) > 1 and self._dump_fails: # Dump failed commands dump_dir = self.dump_commands(fail) # Execute failed commands if execute_fails and self._execute_iters < max_executions: return self._exec... |
def _execute_commands(self, commands, fails=False): """Execute commands and get list of failed commands and count of successful commands""" # Confirm that prepare_statements flag is on if self._prep_statements: prepared_commands = [prepare_sql(c) for c in tqdm(commands, total=len(commands), desc='Prepping SQL Commands'... |
def _execute_commands_from_dir(self, directory): """Re-attempt to split and execute the failed commands""" # Get file paths and contents commands = get_commands_from_dir(directory) # Execute failed commands again print('\tAttempting to execute {0} failed commands'.format(len(commands))) return self.execute(commands, ig... |
def dump_commands(self, commands): """Dump commands wrapper for external access.""" # Get base directory directory = os.path.join(os.path.dirname(self.sql_script), 'fails') # Get file name to be used for folder name fname = os.path.basename(self.sql_script.rsplit('.')[0]) return dump_commands(commands, directory, fname... |
def suppress_output(reverse=False): """ Suppress output """ if reverse: sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ else: sys.stdout = os.devnull sys.stderr = os.devnull |
def get_unresolved_variables(f): """ Gets unresolved vars from file """ reporter = RReporter() checkPath(f, reporter=reporter) return dict(reporter.messages) |
def index_modules(idx=None, path=None): """ Indexes objs from all modules """ suppress_output() modules = defaultdict(list) pkglist = pkgutil.walk_packages(onerror=lambda x: True) print(pkglist) if path: pkglist = pkgutil.walk_packages(path, onerror=lambda x: True) for modl, name, ispkg in pkglist: try: path = os.path.... |
def get_suggestions(idx, unresolved): """ Returns suggestions """ result = {} for u, lines in unresolved.items(): paths = idx.get(u) if paths: result[u] = {'paths': paths, 'lineno': lines} return result |
def includes(self): """ return includes from config """ r = dict([(k, sorted(copy.deepcopy(v).values(), key=lambda x:x.get("order",0))) for k,v in self.get_config("includes").items()]) if self.version is not None: for k,v in r.items(): for j in v: j["path"] = self.versioned_url(j["path"]) return r |
def render(self, tmpl_name, request_env): """ Render the specified template and return the output. Args: tmpl_name (str): file name of the template request_env (dict): request environment Returns: str - the rendered template """ return super(WebApplication, self).render(tmpl_name, request_env) |
def submit_assignment_courses(self, course_id, assignment_id, submission_submission_type, comment_text_comment=None, submission_body=None, submission_file_ids=None, submission_media_comment_id=None, submission_media_comment_type=None, submission_url=None): """ Submit an assignment. Make a submission for an assignment. ... |
= {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # REQUIRED - PATH - assignment_id """ID""" path["assignment_id"] = assignment_id # OPTIONAL - comment[text_comment] """Include a textual comment with the submission.""" if comment_text_comment is not None: data["comment[text... |
an HTML document snippet. Note this HTML snippet will be sanitized using the same ruleset as a submission made from the Canvas web UI. The sanitized HTML will be returned in the response as the submission body. Requires a submission_type of "online_text_entry".""" if submission_body is not None: data["submission[body]"... |
the group's files section, for group assignments). To upload a new file to submit, see the submissions {api:SubmissionsApiController#create_file Upload a file API}. Requires a submission_type of "online_upload".""" if submission_file_ids is not None: data["submission[file_ids]"] = submission_file_ids # OPTIONAL - submi... |
data=data, params=params, no_data=True) |
def list_assignment_submissions_courses(self, course_id, assignment_id, grouped=None, include=None): """ List assignment submissions. Get all existing submissions for an assignment. """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # REQUIRED - PATH - assignment_id... |
def list_assignment_submissions_sections(self, section_id, assignment_id, grouped=None, include=None): """ List assignment submissions. Get all existing submissions for an assignment. """ path = {} data = {} params = {} # REQUIRED - PATH - section_id """ID""" path["section_id"] = section_id # REQUIRED - PATH - assignme... |
def list_submissions_for_multiple_assignments_courses(self, course_id, assignment_ids=None, grading_period_id=None, grouped=None, include=None, order=None, order_direction=None, student_ids=None): """ List submissions for multiple assignments. Get all existing submissions for a given set of students and assignments. ""... |
are returned.""" if assignment_ids is not None: params["assignment_ids"] = assignment_ids # OPTIONAL - grouped """If this argument is present, the response will be grouped by student, rather than a flat array of submissions.""" if grouped is not None: params["grouped"] = grouped # OPTIONAL - grading_period_id """The id... |
mode.""" if order_direction is not None: self._validate_enum(order_direction, ["ascending", "descending"]) params["order_direction"] = order_direction # OPTIONAL - include """Associations to include with the group. `total_scores` requires the `grouped` argument.""" if include is not None: self._validate_enum(include, [... |
def get_single_submission_courses(self, user_id, course_id, assignment_id, include=None): """ Get a single submission. Get a single submission, based on user id. """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # REQUIRED - PATH - assignment_id """ID""" path["assi... |
def get_single_submission_sections(self, user_id, section_id, assignment_id, include=None): """ Get a single submission. Get a single submission, based on user id. """ path = {} data = {} params = {} # REQUIRED - PATH - section_id """ID""" path["section_id"] = section_id # REQUIRED - PATH - assignment_id """ID""" path[... |
def upload_file_sections(self, user_id, section_id, assignment_id): """ Upload a file. Upload a file to a submission. This API endpoint is the first step in uploading a file to a submission as a student. See the {file:file_uploads.html File Upload Documentation} for details on the file upload workflow. The final step o... |
**path)) return self.generic_request("POST", "/api/v1/sections/{section_id}/assignments/{assignment_id}/submissions/{user_id}/files".format(**path), data=data, params=params, no_data=True) |
def grade_or_comment_on_submission_courses(self, user_id, course_id, assignment_id, comment_file_ids=None, comment_group_comment=None, comment_media_comment_id=None, comment_media_comment_type=None, comment_text_comment=None, include_visibility=None, rubric_assessment=None, submission_excuse=None, submission_posted_gra... |
entire group (defaults to false). Ignored if this is not a group assignment or if no text_comment is provided.""" if comment_group_comment is not None: data["comment[group_comment]"] = comment_group_comment # OPTIONAL - comment[media_comment_id] """Add an audio/video comment to the submission. Media comments can be add... |
# OPTIONAL - include[visibility] """Whether this assignment is visible to the owner of the submission""" if include_visibility is not None: data["include[visibility]"] = include_visibility # OPTIONAL - submission[posted_grade] """Assign a score to the submission, updating both the "score" and "grade" fields on the subm... |
following the assignment's defined letter grading scheme. For example, "A-". The resulting score will be the high end of the defined range for the letter grade. For instance, if "B" is defined as 86% to 84%, a letter grade of "B" will be worth 86%. The letter grade will be rejected if the assignment does not have a def... |
format is sent, the grade will only be accepted if the grade equals one of those two values.""" if submission_posted_grade is not None: data["submission[posted_grade]"] = submission_posted_grade # OPTIONAL - submission[excuse] """Sets the "excused" status of an assignment.""" if submission_excuse is not None: data["sub... |
'id': 'crit2', 'points': 5, 'description': 'Criterion 2', 'ratings': [ { 'description': 'Complete', 'points': 5 }, { 'description': 'Incomplete', 'points': 0 } ] } ] Then a possible set of values for rubric_assessment would be: rubric_assessment[crit1][points]=3&rubric_assessment[crit2][points]=5&rubric_assessment[crit... |
def filter(self, collection, data, **kwargs): """Filter given collection.""" ops = self.parse(data) collection = self.apply(collection, ops, **kwargs) return ops, collection |
def parse(self, data): """Parse operator and value from filter's data.""" val = data.get(self.name, missing) if not isinstance(val, dict): return (self.operators['$eq'], self.field.deserialize(val)), return tuple( ( self.operators[op], (self.field.deserialize(val)) if op not in self.list_ops else [ self.field.deseriali... |
def apply(self, collection, ops, **kwargs): """Apply the filter to collection.""" validator = lambda obj: all(op(obj, val) for (op, val) in ops) # noqa return [o for o in collection if validator(o)] |
def convert(self, args, handler=None): """Prepare filters.""" name = args field = attr = None opts = () if isinstance(args, (list, tuple)): name, *opts = args if opts: attr = opts.pop() if opts: field = opts.pop() if not field and handler and handler.Schema: field = handler.Schema._declared_fields.get(attr or name) or ... |
def filter(self, data, collection, **kwargs): """Filter given collection.""" if not data or self.filters is None: return None, collection filters = {} for f in self.filters: if f.name not in data: continue ops, collection = f.filter(collection, data, **kwargs) filters[f.name] = ops return filters, collection |
def forwards(self, orm): "Write your forwards methods here." PERM_CONF = { "publish_content": "Can publish content", "publish_own_content": "Can publish own content", "change_content": "Can change content", "promote_content": "Can promote content" } GROUP_CONF = dict( contributor=(), author=("publish_own_content",), ed... |
def pages(): """Load pages.""" p1 = Page( url='/example1', title='My page with default template', description='my description', content='hello default page', template_name='invenio_pages/default.html', ) p2 = Page( url='/example2', title='My page with my template', description='my description', content='hello my page',... |
def list_poll_choices_in_poll(self, poll_id): """ List poll choices in a poll. Returns the list of PollChoices in this poll. """ path = {} data = {} params = {} # REQUIRED - PATH - poll_id """ID""" path["poll_id"] = poll_id self.logger.debug("GET /api/v1/polls/{poll_id}/poll_choices with query params: {params} and form... |
def create_single_poll_choice(self, poll_id, poll_choices_text, poll_choices_is_correct=None, poll_choices_position=None): """ Create a single poll choice. Create a new poll choice for this poll """ path = {} data = {} params = {} # REQUIRED - PATH - poll_id """ID""" path["poll_id"] = poll_id # REQUIRED - poll_choices[... |
def sso_redirect(request, scopes=list([]), return_to=None): """ Generates a :model:`esi.CallbackRedirect` for the specified request. Redirects to EVE for login. Accepts a view or URL name as a redirect after SSO. """ logger.debug("Initiating redirect of {0} session {1}".format(request.user, request.session.session_key[... |
def receive_callback(request): """ Parses SSO callback, validates, retrieves :model:`esi.Token`, and internally redirects to the target url. """ logger.debug("Received callback for {0} session {1}".format(request.user, request.session.session_key[:5])) # make sure request has required parameters code = request.GET.get(... |
def select_token(request, scopes='', new=False): """ Presents the user with a selection of applicable tokens for the requested view. """ @tokens_required(scopes=scopes, new=new) def _token_list(r, tokens): context = { 'tokens': tokens, 'base_template': app_settings.ESI_BASE_TEMPLATE, } return render(r, 'esi/select_toke... |
def get_primary_key(self, table): """Retrieve the column which is the primary key for a table.""" for column in self.get_schema(table): if len(column) > 3 and 'pri' in column[3].lower(): return column[0] |
def set_primary_key(self, table, column): """Create a Primary Key constraint on a specific column when the table is already created.""" self.execute('ALTER TABLE {0} ADD PRIMARY KEY ({1})'.format(wrap(table), column)) self._printer('\tAdded primary key to {0} on column {1}'.format(wrap(table), column)) |
def set_primary_keys_auto(self, tables=None): """ Create primary keys for every table in the connected database. Checks that each table has a primary key. If a table does not have a key then each column is analyzed to determine if it contains only unique values. If no columns exist containing only unique values then a ... |
def set_primary_key_auto(self, table): """ Analysis a table and set a primary key. Determine primary key by identifying a column with unique values or creating a new column. :param table: Table to alter :return: Primary Key column """ # Confirm no primary key exists pk = self.get_primary_key(table) if not pk: # Determi... |
def drop_primary_key(self, table): """Drop a Primary Key constraint for a specific table.""" if self.get_primary_key(table): self.execute('ALTER TABLE {0} DROP PRIMARY KEY'.format(wrap(table))) |
def set_foreign_key(self, parent_table, parent_column, child_table, child_column): """Create a Foreign Key constraint on a column from a table.""" self.execute('ALTER TABLE {0} ADD FOREIGN KEY ({1}) REFERENCES {2}({3})'.format(parent_table, parent_column, child_table, child_column)) |
def _is_api_key_correct(request): """Return whether the Geckoboard API key on the request is correct.""" api_key = getattr(settings, 'GECKOBOARD_API_KEY', None) if api_key is None: return True auth = request.META.get('HTTP_AUTHORIZATION', '').split() if len(auth) == 2: if auth[0].lower() == b'basic': request_key = base... |
def _encrypt(data): """Equivalent to OpenSSL using 256 bit AES in CBC mode""" BS = AES.block_size def pad(s): n = BS - len(s) % BS char = chr(n).encode('utf8') return s + n * char password = settings.GECKOBOARD_PASSWORD salt = Random.new().read(BS - len('Salted__')) key, iv = _derive_key_and_iv(password, salt, 32, BS) ... |
def _render(request, data, encrypted, format=None): """ Render the data to Geckoboard. If the `format` parameter is passed to the widget it defines the output format. Otherwise the output format is based on the `format` request parameter. A `format` paramater of ``json`` or ``2`` renders JSON output, any other value re... |
def print_report(runner_results): """ Print collated report with output and errors if any """ error_report = collections.defaultdict(list) output_report = collections.defaultdict(list) success_report = list() for runner_info in runner_results: hostname = runner_info['console'] error = runner_info['error'] output = runn... |
def ipmi_method(self, command): """Use ipmitool to run commands with ipmi protocol """ ipmi = ipmitool(self.console, self.password, self.username) if command == "reboot": self.ipmi_method(command="status") if self.output == "Chassis Power is off": command = "on" ipmi.execute(self.ipmi_map[command]) if ipmi.status: self... |
def run(self): """Start thread run here """ try: if self.command == "pxer": self.ipmi_method(command="pxe") if self.status == 0 or self.status == None: self.command = "reboot" else: return self.ipmi_method(self.command) except Exception as e: self.error = str(e) |
def _create(self): """ Create new object on IxNetwork. :return: IXN object reference. """ if 'name' in self._data: obj_ref = self.api.add(self.obj_parent(), self.obj_type(), name=self.obj_name()) else: obj_ref = self.api.add(self.obj_parent(), self.obj_type()) self.api.commit() return self.api.remapIds(obj_ref) |
def merge(self, *args): """ Merge multiple dictionary objects into one. :param variadic args: Multiple dictionary items :return dict """ values = [] for entry in args: values = values + list(entry.items()) return dict(values) |
def parseLegacy(self, response): """ Parse a legacy response and try and catch any errors. If we have multiple responses we wont catch any exceptions, we will return the errors row by row :param dict response: The response string returned from request() :return Returns a dictionary or a list (list for multiple response... |
any failures. if (len(lines) == 1): raise ClickatellError(row['error'], row['code']) finally: result.append(row) return result if len(result) > 1 else result[0] |
def parseRest(self, response): """ Parse a REST response. If the response contains an error field, we will raise it as an exception. """ body = json.loads(response) try: error = body['error']['description'] code = body['error']['code'] except Exception: return body['data'] else: raise ClickatellError(error, code); |
def request(self, action, data={}, headers={}, method='GET'): """ Run the HTTP request against the Clickatell API :param str action: The API action :param dict data: The request parameters :param dict headers: The request headers (if any) :param str method: The HTTP method :return: The request response """ url = ('http... |
def serialize_operations(self, operations): """Serialize a list of operations into JSON.""" serialized_ops = [] for operation in operations: serializer = self.get_serializer_class(operation.__class__) serialized_ops.append(serializer(operation).data) return serialized_ops |
def get(self, request, pzone_pk): """Get all the operations for a given pzone.""" # attempt to get given pzone try: pzone = PZone.objects.get(pk=pzone_pk) except PZone.DoesNotExist: raise Http404("Cannot find given pzone.") # bulid filters filters = {"pzone": pzone} if "from" in request.GET: parsed = dateparse.parse_da... |
def post(self, request, pzone_pk): """Add a new operation to the given pzone, return json of the new operation.""" # attempt to get given content list pzone = None try: pzone = PZone.objects.get(pk=pzone_pk) except PZone.DoesNotExist: raise Http404("Cannot find given pzone.") json_obj = [] http_status = 500 json_op = j... |
time in seconds until the next operation occurs next_ops = PZoneOperation.objects.filter(when__lte=timezone.now()) if len(next_ops) > 0: # we have at least one operation, ordered soonest first next_op = next_ops[0] # cache with expiry number of seconds until op should exec cache.set('pzone-operation-expiry-' + pzone.na... |
def delete(self, request, pzone_pk, operation_pk): """Remove an operation from the given pzone.""" # note : we're not using the pzone_pk here since it's not actually # necessary for getting an operation by pk, but it sure makes the urls # nicer! # attempt to delete operation try: operation = PZoneOperation.objects.get(... |
def perform_update(self, serializer): """creates a record in the `bulbs.promotion.PZoneHistory` :param obj: the instance saved :param created: boolean expressing if the object was newly created (`False` if updated) """ instance = serializer.save() # create history object instance.history.create(data=instance.data) |
def retrieve(self, request, *args, **kwargs): """Retrieve pzone as a preview or applied if no preview is provided.""" when_param = get_query_params(self.request).get("preview", None) pk = self.kwargs["pk"] when = None if when_param: try: when = parse_date(when_param) except ValueError: # invalid format, set back to Non... |
def design(self, max_stimuli=-1, max_inhibitors=-1, max_experiments=10, relax=False, configure=None): """ Finds all optimal experimental designs using up to :attr:`max_experiments` experiments, such that each experiment has up to :attr:`max_stimuli` stimuli and :attr:`max_inhibitors` inhibitors. Each optimal experiment... |
equals True, the number of experiments per design is fixed to :attr:`max_experiments` configure : callable Callable object responsible of setting clingo configuration """ self.designs = [] args = ['-c maxstimuli=%s' % max_stimuli, '-c maxinhibitors=%s' % max_inhibitors, '-Wno-atom-undefined'] clingo = gringo.Control(ar... |
def current(cls): """Get the current event loop singleton object. """ try: return _tls.loop except AttributeError: # create loop only for main thread if threading.current_thread().name == 'MainThread': _tls.loop = cls() return _tls.loop raise RuntimeError('there is no event loop created in the current thread') |
def search_account_domains(self, domain=None, latitude=None, longitude=None, name=None): """ Search account domains. Returns a list of up to 5 matching account domains Partial match on name / domain are supported """ path = {} data = {} params = {} # OPTIONAL - name """campus name""" if name is not None: params["name"]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.