code
stringlengths
1
18.2k
params["include_parents"] = include_parents self.logger.debug("GET /api/v1/groups/{group_id}/external_tools with query params: {params} and form data: {data}".format(params=params, data=data, **path)) return self.generic_request("GET", "/api/v1/groups/{group_id}/external_tools".format(**path), data=data, params=params,...
def get_sessionless_launch_url_for_external_tool_courses(self, course_id, assignment_id=None, id=None, launch_type=None, module_item_id=None, url=None): """ Get a sessionless launch url for an external tool. Returns a sessionless launch url for an external tool. NOTE: Either the id or url must be provided unless launch...
# OPTIONAL - module_item_id """The assignment id for a module item launch. Required if launch_type is set to "module_item".""" if module_item_id is not None: params["module_item_id"] = module_item_id # OPTIONAL - launch_type """The type of launch to perform on the external tool. Placement names (eg. "course_navigation"...
def get_single_external_tool_courses(self, course_id, external_tool_id): """ Get a single external tool. Returns the specified external tool. """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # REQUIRED - PATH - external_tool_id """ID""" path["external_tool_id"] = ...
def get_single_external_tool_accounts(self, account_id, external_tool_id): """ Get a single external tool. Returns the specified external tool. """ path = {} data = {} params = {} # REQUIRED - PATH - account_id """ID""" path["account_id"] = account_id # REQUIRED - PATH - external_tool_id """ID""" path["external_tool_id...
def create_external_tool_courses(self, name, course_id, consumer_key, privacy_level, shared_secret, account_navigation_enabled=None, account_navigation_selection_height=None, account_navigation_selection_width=None, account_navigation_text=None, account_navigation_url=None, config_type=None, config_url=None, config_xml...
external tool.""" self._validate_enum(privacy_level, ["anonymous", "name_only", "public"]) data["privacy_level"] = privacy_level # REQUIRED - consumer_key """The consumer key for the external tool""" data["consumer_key"] = consumer_key # REQUIRED - shared_secret """The shared secret with the external tool""" data["shar...
= icon_url # OPTIONAL - text """The default text to show for this tool""" if text is not None: data["text"] = text # OPTIONAL - custom_fields[field_name] """Custom fields that will be sent to the tool consumer; can be used multiple times""" if custom_fields_field_name is not None: data["custom_fields[field_name]"] = cu...
is not None: data["account_navigation[selection_width]"] = account_navigation_selection_width # OPTIONAL - account_navigation[selection_height] """The height of the dialog the tool is launched in""" if account_navigation_selection_height is not None: data["account_navigation[selection_height]"] = account_navigation_sel...
not None: data["course_home_sub_navigation[enabled]"] = course_home_sub_navigation_enabled # OPTIONAL - course_home_sub_navigation[text] """The text that will show on the right-side course home navigation menu""" if course_home_sub_navigation_text is not None: data["course_home_sub_navigation[text]"] = course_home_sub_...
# OPTIONAL - course_navigation[windowTarget] """Determines how the navigation tab will be opened. "_blank" Launches the external tool in a new window or tab. "_self" (Default) Launches the external tool in an iframe inside of Canvas.""" if course_navigation_windowTarget is not None: self._validate_enum(course_navigatio...
WYSIWYG editor""" if editor_button_icon_url is not None: data["editor_button[icon_url]"] = editor_button_icon_url # OPTIONAL - editor_button[selection_width] """The width of the dialog the tool is launched in""" if editor_button_selection_width is not None: data["editor_button[selection_width]"] = editor_button_selecti...
tab""" if homework_submission_text is not None: data["homework_submission[text]"] = homework_submission_text # OPTIONAL - homework_submission[message_type] """Set this to ContentItemSelectionRequest to tell the tool to use content-item; otherwise, omit""" if homework_submission_message_type is not None: data["homework_...
migration_selection_url is not None: data["migration_selection[url]"] = migration_selection_url # OPTIONAL - migration_selection[enabled] """Set this to enable this feature""" if migration_selection_enabled is not None: data["migration_selection[enabled]"] = migration_selection_enabled # OPTIONAL - migration_selection[...
resource_selection_url # OPTIONAL - resource_selection[enabled] """Set this to enable this feature""" if resource_selection_enabled is not None: data["resource_selection[enabled]"] = resource_selection_enabled # OPTIONAL - resource_selection[icon_url] """The url of the icon to show in the module external tool list""" i...
the name parameter overrides the tool name provided in the xml""" if config_type is not None: data["config_type"] = config_type # OPTIONAL - config_xml """XML tool configuration, as specified in the CC xml specification. This is required if "config_type" is set to "by_xml"""" if config_xml is not None: data["config_xml...
set to true LTI query params will not be copied to the post body.""" if oauth_compliant is not None: data["oauth_compliant"] = oauth_compliant self.logger.debug("POST /api/v1/courses/{course_id}/external_tools with query params: {params} and form data: {data}".format(params=params, data=data, **path)) return self.gener...
def insert(self, key, value): """Insert a key-value pair in the list. The pair is inserted at the correct location so that the list remains sorted on *key*. If a pair with the same key is already in the list, then the pair is appended after all other pairs with that key. """ self._find_lte(key) node = self._create_node...
def replace(self, key, value): """Replace the value of the first key-value pair with key *key*. If the key was not found, the pair is inserted. """ self._find_lt(key) node = self._path[0][2] if node is self._tail or key < node[0]: node = self._create_node(key, value) self._insert(node) else: node[1] = value
def clear(self): """Remove all key-value pairs.""" for i in range(self.maxlevel): self._head[2+i] = self._tail self._tail[-1] = 0 self._level = 1
def items(self, start=None, stop=None): """Return an iterator yielding pairs. If *start* is specified, iteration starts at the first pair with a key that is larger than or equal to *start*. If not specified, iteration starts at the first pair in the list. If *stop* is specified, iteration stops at the last pair that is...
def keys(self, start=None, stop=None): """Like :meth:`items` but returns only the keys.""" return (item[0] for item in self.items(start, stop))
def values(self, start=None, stop=None): """Like :meth:`items` but returns only the values.""" return (item[1] for item in self.items(start, stop))
def popitem(self): """Removes the first key-value pair and return it. This method raises a ``KeyError`` if the list is empty. """ node = self._head[2] if node is self._tail: raise KeyError('list is empty') self._find_lt(node[0]) self._remove(node) return (node[0], node[1])
def search(self, key, default=None): """Find the first key-value pair with key *key* and return its value. If the key was not found, return *default*. If no default was provided, return ``None``. This method never raises a ``KeyError``. """ self._find_lt(key) node = self._path[0][2] if node is self._tail or key < node[...
def remove(self, key): """Remove the first key-value pair with key *key*. If the key was not found, a ``KeyError`` is raised. """ self._find_lt(key) node = self._path[0][2] if node is self._tail or key < node[0]: raise KeyError('{!r} is not in list'.format(key)) self._remove(node)
def pop(self, key, default=UNSET): """Remove the first key-value pair with key *key*. If a pair was removed, return its value. Otherwise if *default* was provided, return *default*. Otherwise a ``KeyError`` is raised. """ self._find_lt(key) node = self._path[0][2] if node is self._tail or key < node[0]: if default is s...
def index(self, key, default=UNSET): """Find the first key-value pair with key *key* and return its position. If the key is not found, return *default*. If default was not provided, raise a ``KeyError`` """ self._find_lt(key) node = self._path[0][2] if node is self._tail or key < node[0]: if default is self.UNSET: rais...
def count(self, key): """Return the number of pairs with key *key*.""" count = 0 pos = self.index(key, -1) if pos == -1: return count count += 1 for i in range(pos+1, len(self)): if self[i][0] != key: break count += 1 return count
def update_tab_for_course(self, tab_id, course_id, hidden=None, position=None): """ Update a tab for a course. Home and Settings tabs are not manageable, and can't be hidden or moved Returns a tab object """ path = {} data = {} params = {} # REQUIRED - PATH - course_id """ID""" path["course_id"] = course_id # REQUIRED ...
def select_all(self, table, limit=MAX_ROWS_PER_QUERY, execute=True): """Query all rows and columns from a table.""" # Determine if a row per query limit should be set num_rows = self.count_rows(table) if num_rows > limit: return self._select_batched(table, '*', num_rows, limit, execute=execute) else: return self.select...
def select_distinct(self, table, cols='*', execute=True): """Query distinct values from a table.""" return self.select(table, cols, execute, select_type='SELECT DISTINCT')
def select(self, table, cols, execute=True, select_type='SELECT', return_type=list): """Query every row and only certain columns from a table.""" # Validate query type select_type = select_type.upper() assert select_type in SELECT_QUERY_TYPES # Concatenate statement statement = '{0} {1} FROM {2}'.format(select_type, jo...
def select_join(self, table1, table2, cols, table1_col, table2_col=None, join_type=None): """ Left join all rows and columns from two tables where a common value is shared. :param table1: Name of table #1 :param table2: Name of table #2 :param cols: List of columns or column tuples String or flat list: Assumes column(s...
cols]) # Validate join_type and table2_col join_type = join_type.lower().split(' ', 1)[0].upper() + ' JOIN' if join_type else 'LEFT JOIN' assert join_type in JOIN_QUERY_TYPES table2_col = table2_col if table2_col else table1_col # Concatenate and return statement statement = ''' SELECT {columns} FROM {table1} {join_typ...
def select_limit(self, table, cols='*', offset=0, limit=MAX_ROWS_PER_QUERY): """Run a select query with an offset and limit parameter.""" return self.fetch(self._select_limit_statement(table, cols, offset, limit))
def select_where(self, table, cols, where, return_type=list): """ Query certain rows from a table where a particular value is found. cols parameter can be passed as a iterable (list, set, tuple) or a string if only querying a single column. where parameter can be passed as a two or three part tuple. If only two parts a...
with AND) clauses = [self._where_clause(clause) for clause in where] where_statement = ' AND '.join(clauses) else: where_statement = self._where_clause(where) # Concatenate full statement and execute statement = "SELECT {0} FROM {1} WHERE {2}".format(join_cols(cols), wrap(table), where_statement) values = self.fetch(st...
def select_where_between(self, table, cols, where_col, between): """ Query rows from a table where a columns value is found between two values. :param table: Name of the table :param cols: List, tuple or set of columns or string with single column name :param where_col: Column to check values against :param between: Tu...
def select_where_like(self, table, cols, where_col, start=None, end=None, anywhere=None, index=(None, None), length=None): """ Query rows from a table where a specific pattern is found in a column. MySQL syntax assumptions: (%) The percent sign represents zero, one, or multiple characters. (_) The underscore represents...
# Concatenate full statement and execute statement = "SELECT {0} FROM {1} WHERE {2} LIKE '{3}'".format(join_cols(cols), wrap(table), where_col, pattern) return self.fetch(statement)
def _where_clause(where): """ Unpack a where clause tuple and concatenate a MySQL WHERE statement. :param where: 2 or 3 part tuple containing a where_column and a where_value (optional operator) :return: WHERE clause statement """ assert isinstance(where, tuple) if len(where) == 3: where_col, operator, where_val = wher...
def _return_rows(self, table, cols, values, return_type): """Return fetched rows in the desired type.""" if return_type is dict: # Pack each row into a dictionary cols = self.get_columns(table) if cols is '*' else cols if len(values) > 0 and isinstance(values[0], (set, list, tuple)): return [dict(zip(cols, row)) for ro...
def _select_batched(self, table, cols, num_rows, limit, queries_per_batch=3, execute=True): """Run select queries in small batches and return joined resutls.""" # Execute select queries in small batches to avoid connection timeout commands, offset = [], 0 while num_rows > 0: # Use number of rows as limit if num_rows < ...
def _select_limit_statement(table, cols='*', offset=0, limit=MAX_ROWS_PER_QUERY): """Concatenate a select with offset and limit statement.""" return 'SELECT {0} FROM {1} LIMIT {2}, {3}'.format(join_cols(cols), wrap(table), offset, limit)
def _like_pattern(start, end, anywhere, index, length): """ Create a LIKE pattern to use as a search parameter for a WHERE clause. :param start: Value to be found at the start :param end: Value to be found at the end :param anywhere: Value to be found anywhere :param index: Value to be found at a certain index :param l...
i in [start, anywhere]) and not any(i for i in [end, index, length]): return '{start}%{anywhere}%'.format(start=start, anywhere=anywhere) # End, anywhere elif all(i for i in [end, anywhere]) and not any(i for i in [start, index, length]): return '%{anywhere}%{end}'.format(end=end, anywhere=anywhere) # Start elif start ...
return None
def insert_statement(table, columns, values): """Generate an insert statement string for dumping to text file or MySQL execution.""" if not all(isinstance(r, (list, set, tuple)) for r in values): values = [[r] for r in values] rows = [] for row in values: new_row = [] for col in row: if col is None: new_col = 'NULL' el...
def dump_table(self, table, drop_statement=True): """Export a table structure and data to SQL file for backup or later import.""" create_statement = self.get_table_definition(table) data = self.select_all(table) statements = ['\n', sql_file_comment(''), sql_file_comment('Table structure and data dump for {0}'.format(ta...
def dump_database(self, file_path, database=None, tables=None): """ Export the table structure and data for tables in a database. If not database is specified, it is assumed the currently connected database is the source. If no tables are provided, all tables will be dumped. """ # Change database if needed if database:...
def retry(method): """ Allows to retry method execution few times. """ def inner(self, *args, **kwargs): attempt_number = 1 while attempt_number < self.retries: try: return method(self, *args, **kwargs) except HasOffersException as exc: if 'API usage exceeded rate limit' not in str(exc): raise exc self.logger.debug('Re...
def setup_managers(self): """ Allows to access manager by model name - it is convenient, because HasOffers returns model names in responses. """ self._managers = {} for manager_class in MODEL_MANAGERS: instance = manager_class(self) if not instance.forbid_registration \ and not isinstance(instance, ApplicationManager) ...
def _call(self, target, method, target_class=None, single_result=True, raw=False, files=None, **kwargs): """ Low-level call to HasOffers API. :param target_class: type of resulting object/objects. """ if target_class is None: target_class = target params = prepare_query_params( NetworkToken=self.network_token, NetworkI...
def handle_response(self, content, target=None, single_result=True, raw=False): """ Parses response, checks it. """ response = content['response'] self.check_errors(response) data = response.get('data') if is_empty(data): return data elif is_paginated(data): if 'count' in data and not data['count']: # Response is pagin...
def init_all_objects(self, data, target=None, single_result=True): """ Initializes model instances from given data. Returns single instance if single_result=True. """ if single_result: return self.init_target_object(target, data) return list(self.expand_models(target, data))
def init_target_object(self, target, data): """ Initializes target object and assign extra objects to target as attributes """ target_object = self.init_single_object(target, data.pop(target, data)) for key, item in data.items(): key_alias = MANAGER_ALIASES.get(key, key) if item: # Item is an OrderedDict with 4 possibl...
def expand_models(self, target, data): """ Generates all objects from given data. """ if isinstance(data, dict): data = data.values() for chunk in data: if target in chunk: yield self.init_target_object(target, chunk) else: for key, item in chunk.items(): yield self.init_single_object(key, item)
def merge_roles(dominant_name, deprecated_name): """ Merges a deprecated role into a dominant role. """ dominant_qs = ContributorRole.objects.filter(name=dominant_name) if not dominant_qs.exists() or dominant_qs.count() != 1: return dominant = dominant_qs.first() deprecated_qs = ContributorRole.objects.filter(name=depr...
flat_override.save() for hourly_override in override.override_hourly.all(): hourly_override.profile = dom_override hourly_override.save() for feature_type_override in override.override_feature_type.all(): feature_type_override.profile = dom_override feature_type_override.save()
def quick_search(self, terms): '''Wrapper for search_bugs, for simple string searches''' assert type(terms) is str p = [{'quicksearch': terms}] return self.search_bugs(p)
def search_bugs(self, terms): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/bug.html#search-bugs terms = [{'product': 'Infrastructure & Operations'}, {'status': 'NEW'}]''' params = '' for i in terms: k = i.popitem() params = '{p}&{new}={value}'.format(p=params, new=quote_url(k[0]), value=quote_url(k[1])) ret...
def put_attachment(self, attachmentid, attachment_update): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/attachment.html#update-attachment''' assert type(attachment_update) is DotDict if (not 'ids' in attachment_update): attachment_update.ids = [attachmentid] return self._put('bug/attachment/{attachmentid}'....
def put_bug(self, bugid, bug_update): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/bug.html#update-bug''' assert type(bug_update) is DotDict if (not 'ids' in bug_update): bug_update.ids = [bugid] return self._put('bug/{bugid}'.format(bugid=bugid), json.dumps(bug_update))
def post_attachment(self, bugid, attachment): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/attachment.html#create-attachment''' assert type(attachment) is DotDict assert 'data' in attachment assert 'file_name' in attachment assert 'summary' in attachment if (not 'content_type' in attachment): attachment.con...
def post_bug(self, bug): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/bug.html#create-bug''' assert type(bug) is DotDict assert 'product' in bug assert 'component' in bug assert 'summary' in bug if (not 'version' in bug): bug.version = 'other' if (not 'op_sys' in bug): bug.op_sys = 'All' if (not 'platform' ...
def post_comment(self, bugid, comment): '''http://bugzilla.readthedocs.org/en/latest/api/core/v1/comment.html#create-comments''' data = {'id': bugid, "comment": comment} return self._post('bug/{bugid}/comment'.format(bugid=bugid), json.dumps(data))
def _get(self, q, params=''): '''Generic GET wrapper including the api_key''' if (q[-1] == '/'): q = q[:-1] headers = {'Content-Type': 'application/json'} r = requests.get('{url}{q}?api_key={key}{params}'.format(url=self.url, q=q, key=self.api_key, params=params), headers=headers) ret = DotDict(r.json()) if (not r.ok o...
def _post(self, q, payload='', params=''): '''Generic POST wrapper including the api_key''' if (q[-1] == '/'): q = q[:-1] headers = {'Content-Type': 'application/json'} r = requests.post('{url}{q}?api_key={key}{params}'.format(url=self.url, q=q, key=self.api_key, params=params), headers=headers, data=payload) ret = Dot...
def bind_objects(self, *objects): """Bind one or more objects""" self.control.bind_keys(objects) self.objects += objects
def update(self, time_delta): """Update all sprites in the system. time_delta is the time since the last update (in arbitrary time units). This method can be conveniently scheduled using the Pyglet scheduler method: pyglet.clock.schedule_interval """ self.control.update(self, time_delta) for object in self.objects: obj...
def draw(self): """Draw all the sprites in the system using their renderers. This method is convenient to call from you Pyglet window's on_draw handler to redraw particles when needed. """ glPushAttrib(GL_ALL_ATTRIB_BITS) self.draw_score() for sprite in self: sprite.draw() glPopAttrib()
def reset_ball(self, x, y): """reset ball to set location on the screen""" self.sprite.position.x = x self.sprite.position.y = y
def update(self, td): """Update state of ball""" self.sprite.last_position = self.sprite.position self.sprite.last_velocity = self.sprite.velocity if self.particle_group != None: self.update_particle_group(td)
def generate(self): """Return a random point inside the box""" x, y, z = self.point1 return (x + self.size_x * random(), y + self.size_y * random(), z + self.size_z * random())
def intersect(self, start_point, end_point): """Intersect the line segment with the box return the first intersection point and normal vector pointing into space from the box side intersected. If the line does not intersect, or lies completely in one side of the box return (None, None) """ sx, sy, sz = start_point ex, ...
sz) * t + sz if p1x <= ix <= p2x and p1z <= iz <= p2z: return (ix, iy, iz), (0.0, (sy > p2y) * 2.0 - 1.0, 0.0) if (end_inside and sx < p1x) or (start_inside and ex <= p1x) and (ex != sx): # Test for itersection with left face t = (sx - p1x) / (ex - sx) ix = p1x iy = (ey - sy) * t + sy iz = (ez - sz) * t + sz if p1y <= ...
with top face t = (sy - p1y) / (ey - sy) ix = (ex - sx) * t + sx iy = p1y iz = (ez - sz) * t + sz if p1x <= ix <= p2x and p1z <= iz <= p2z: return (ix, iy, iz), (0.0, (sy > p1y) * 2.0 - 1.0, 0.0) if (end_inside and sx > p2x) or (start_inside and ex >= p2x) and (ex != sx): # Test for itersection with right face t = (sx ...
> p2x) * 2.0 - 1.0, 0.0, 0.0) if (end_inside and sz > p2z) or (start_inside and ez >= p2z) and (ez != sz): # Test for itersection with far face t = (sz - p2z) / (ez - sz) ix = (ex - sx) * t + sx iy = (ey - sy) * t + sy iz = p2z if p1y <= iy <= p2y and p1x <= ix <= p2x: return (ix, iy, iz), (0.0, 0.0, (sz > p2z) * 2.0 -...
= (ey - sy) * t + sy iz = p1z if p1y <= iy <= p2y and p1x <= ix <= p2x: return (ix, iy, iz), (0.0, 0.0, (sz > p1z) * 2.0 - 1.0) return None, None
def custom_search_model(model, query, preview=False, published=False, id_field="id", sort_pinned=True, field_map={}): """Filter a model with the given filter. `field_map` translates incoming field names to the appropriate ES names. """ if preview: func = preview_filter_from_query else: func = filter_from_query f = func...
def preview_filter_from_query(query, id_field="id", field_map={}): """This filter includes the "excluded_ids" so they still show up in the editor.""" f = groups_filter_from_query(query, field_map=field_map) # NOTE: we don't exclude the excluded ids here so they show up in the editor # include these, please included_ids...
def filter_from_query(query, id_field="id", field_map={}): """This returns a filter which actually filters out everything, unlike the preview filter which includes excluded_ids for UI purposes. """ f = groups_filter_from_query(query, field_map=field_map) excluded_ids = query.get("excluded_ids") included_ids = query.get...
def get_condition_filter(condition, field_map={}): """ Return the appropriate filter for a given group condition. # TODO: integrate this into groups_filter_from_query function. """ field_name = condition.get("field") field_name = field_map.get(field_name, field_name) operation = condition["type"] values = condition["va...
) return condition_filter
def groups_filter_from_query(query, field_map={}): """Creates an F object for the groups of a search query.""" f = None # filter groups for group in query.get("groups", []): group_f = MatchAll() for condition in group.get("conditions", []): field_name = condition["field"] field_name = field_map.get(field_name, field_na...
group_f &= ~Terms(**{field_name: values}) date_range = group.get("time") if date_range: group_f &= date_range_filter(date_range) if f: f |= group_f else: f = group_f return f
def date_range_filter(range_name): """Create a filter from a named date range.""" filter_days = list(filter( lambda time: time["label"] == range_name, settings.CUSTOM_SEARCH_TIME_PERIODS)) num_days = filter_days[0]["days"] if len(filter_days) else None if num_days: dt = timedelta(num_days) start_time = timezone.now() -...
def request(self, action, data={}, headers={}, method='GET'): """ Append the REST headers to every request """ headers = { "Authorization": "Bearer " + self.token, "Content-Type": "application/json", "X-Version": "1", "Accept": "application/json" } return Transport.request(self, action, data, headers, method)
def sendMessage(self, to, message, extra={}): """ If the 'to' parameter is a single entry, we will parse it into a list. We will merge default values into the request data and the extra parameters provided by the user. """ to = to if isinstance(to, list) else [to] to = [str(num) for num in to] data = {'to': to, 'text':...
return result
def stopMessage(self, apiMsgId): """ See parent method for documentation """ content = self.parseRest(self.request('rest/message/' + apiMsgId, {}, {}, 'DELETE')) return { 'id': content['apiMessageId'].encode('utf-8'), 'status': content['messageStatus'].encode('utf-8'), 'description': self.getStatus(content['messageStat...
def getMessageCharge(self, apiMsgId): """ See parent method for documentation """ content = self.parseRest(self.request('rest/message/' + apiMsgId)) return { 'id': apiMsgId, 'status': content['messageStatus'].encode('utf-8'), 'description': self.getStatus(content['messageStatus']), 'charge': float(content['charge']) }
def routeCoverage(self, msisdn): """ If the route coverage lookup encounters an error, we will treat it as "not covered". """ content = self.parseRest(self.request('rest/coverage/' + str(msisdn))) return { 'routable': content['routable'], 'destination': content['destination'].encode('utf-8'), 'charge': float(content['m...
def make_account_admin(self, user_id, account_id, role=None, role_id=None, send_confirmation=None): """ Make an account admin. Flag an existing user as an admin within the account. """ path = {} data = {} params = {} # REQUIRED - PATH - account_id """ID""" path["account_id"] = account_id # REQUIRED - user_id """The id ...
the new admin if true. Default is true.""" if send_confirmation is not None: data["send_confirmation"] = send_confirmation self.logger.debug("POST /api/v1/accounts/{account_id}/admins with query params: {params} and form data: {data}".format(params=params, data=data, **path)) return self.generic_request("POST", "/api/v...
def list_account_admins(self, account_id, user_id=None): """ List account admins. List the admins in the account """ path = {} data = {} params = {} # REQUIRED - PATH - account_id """ID""" path["account_id"] = account_id # OPTIONAL - user_id """Scope the results to those with user IDs equal to any of the IDs specified ...
def _hex_to_rgb(hex_code): """ >>> _hex_to_rgb("007fff") (0, 127, 255) """ if len(hex_code) != 6: raise ValueError(hex_code + " is not a string of length 6, cannot convert to rgb.") return tuple(map(ord, hex_code.decode("hex")))
def add_colors_from_file(self, system, f_or_filename): """Add color definition to a given color system. You may pass either a file-like object or a filename string pointing to a color definition csv file. Each line in that input file should look like this:: café au lait,a67b5b i.e. a color name and a sRGB hex code, sep...
if hasattr(f_or_filename, "read"): colors = (row for row in csv.reader(f_or_filename) if row) else: with open(f_or_filename, "rb") as f: colors = [row for row in csv.reader(f) if row] self.add_colors(system, colors)