Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def validiate_webhook_signature(self, webhook, signature): digester = hmac.new(self.session.oauth2credential.client_secret, webhook, hashlib.sha256 ) return (signatur...
[ "Validates a webhook signature from a webhook body + client secret\n\n Parameters\n webhook (string)\n The request body of the webhook.\n signature (string)\n The webhook signature specified in X-Uber-Signature header.\n " ]
Please provide a description of the function:def adapt_meta(self, meta): surge = meta.get('surge_confirmation') href = surge.get('href') surge_id = surge.get('surge_confirmation_id') return href, surge_id
[ "Convert meta from error response to href and surge_id attributes." ]
Please provide a description of the function:def connect(): # Exchange authorization code for acceess token and create session session = auth_flow.get_session(request.url) client = UberRidesClient(session) # Fetch profile for rider profile = client.get_rider_profile().json # Fetch all tr...
[ "Connect controller to handle token exchange and query Uber API." ]
Please provide a description of the function:def estimate_ride(api_client): try: estimate = api_client.estimate_ride( product_id=SURGE_PRODUCT_ID, start_latitude=START_LAT, start_longitude=START_LNG, end_latitude=END_LAT, end_longitude=END_LNG...
[ "Use an UberRidesClient to fetch a ride estimate and print the results.\n\n Parameters\n api_client (UberRidesClient)\n An authorized UberRidesClient with 'request' scope.\n " ]
Please provide a description of the function:def update_surge(api_client, surge_multiplier): try: update_surge = api_client.update_sandbox_product( SURGE_PRODUCT_ID, surge_multiplier=surge_multiplier, ) except (ClientError, ServerError) as error: fail_print(...
[ "Use an UberRidesClient to update surge and print the results.\n\n Parameters\n api_client (UberRidesClient)\n An authorized UberRidesClient with 'request' scope.\n surge_mutliplier (float)\n The surge multiple for a sandbox product. A multiplier greater than\n or e...
Please provide a description of the function:def update_ride(api_client, ride_status, ride_id): try: update_product = api_client.update_sandbox_ride(ride_id, ride_status) except (ClientError, ServerError) as error: fail_print(error) else: message = '{} New status: {}' ...
[ "Use an UberRidesClient to update ride status and print the results.\n\n Parameters\n api_client (UberRidesClient)\n An authorized UberRidesClient with 'request' scope.\n ride_status (str)\n New ride status to update to.\n ride_id (str)\n Unique identifier fo...
Please provide a description of the function:def request_ufp_ride(api_client): try: estimate = api_client.estimate_ride( product_id=UFP_PRODUCT_ID, start_latitude=START_LAT, start_longitude=START_LNG, end_latitude=END_LAT, end_longitude=END_L...
[ "Use an UberRidesClient to request a ride and print the results.\n\n Parameters\n api_client (UberRidesClient)\n An authorized UberRidesClient with 'request' scope.\n\n Returns\n The unique ID of the requested ride.\n " ]
Please provide a description of the function:def request_surge_ride(api_client, surge_confirmation_id=None): try: request = api_client.request_ride( product_id=SURGE_PRODUCT_ID, start_latitude=START_LAT, start_longitude=START_LNG, end_latitude=END_LAT, ...
[ "Use an UberRidesClient to request a ride and print the results.\n\n If the product has a surge_multiple greater than or equal to 2.0,\n a SurgeError is raised. Confirm surge by visiting the\n surge_confirmation_url and automatically try the request again.\n\n Parameters\n api_client (UberRidesCl...
Please provide a description of the function:def get_ride_details(api_client, ride_id): try: ride_details = api_client.get_ride_details(ride_id) except (ClientError, ServerError) as error: fail_print(error) else: success_print(ride_details.json)
[ "Use an UberRidesClient to get ride details and print the results.\n\n Parameters\n api_client (UberRidesClient)\n An authorized UberRidesClient with 'request' scope.\n ride_id (str)\n Unique ride identifier.\n " ]
Please provide a description of the function:def generate_data(method, args): data = {} params = {} if method in http.BODY_METHODS: data = dumps(args) else: params = args return data, params
[ "Assign arguments to body or URL of an HTTP request.\n\n Parameters\n method (str)\n HTTP Method. (e.g. 'POST')\n args (dict)\n Dictionary of data to attach to each Request.\n e.g. {'latitude': 37.561, 'longitude': -122.742}\n\n Returns\n (str or dict)\n ...
Please provide a description of the function:def generate_prepared_request(method, url, headers, data, params, handlers): request = Request( method=method, url=url, headers=headers, data=data, params=params, ) handlers.append(error_handler) for handler in h...
[ "Add handlers and prepare a Request.\n\n Parameters\n method (str)\n HTTP Method. (e.g. 'POST')\n headers (dict)\n Headers to send.\n data (JSON-formatted str)\n Body to attach to the request.\n params (dict)\n Dictionary of URL parameters t...
Please provide a description of the function:def build_url(host, path, params=None): path = quote(path) params = params or {} if params: path = '/{}?{}'.format(path, urlencode(params)) else: path = '/{}'.format(path) if not host.startswith(http.URL_SCHEME): host = '{}{...
[ "Build a URL.\n\n This method encodes the parameters and adds them\n to the end of the base URL, then adds scheme and hostname.\n\n Parameters\n host (str)\n Base URL of the Uber Server that handles API calls.\n path (str)\n Target path to add to the host (e.g. 'v1.2/pro...
Please provide a description of the function:def hello_user(api_client): try: response = api_client.get_user_profile() except (ClientError, ServerError) as error: fail_print(error) return else: profile = response.json first_name = profile.get('first_name') ...
[ "Use an authorized client to fetch and print profile information.\n\n Parameters\n api_client (UberRidesClient)\n An UberRidesClient with OAuth 2.0 credentials.\n " ]
Please provide a description of the function:def error_handler(response, **kwargs): try: body = response.json() except ValueError: body = {} status_code = response.status_code message = body.get('message', '') fields = body.get('fields', '') error_message = str(status_code) ...
[ "Error Handler to surface 4XX and 5XX errors.\n\n Attached as a callback hook on the Request object.\n\n Parameters\n response (requests.Response)\n The HTTP response from an API request.\n **kwargs\n Arbitrary keyword arguments.\n\n Raises\n ClientError (ApiError...
Please provide a description of the function:def make_from_response( cls, response, grant_type, client_id, client_secret=None, redirect_url=None, ): if response.status_code != codes.ok: message = 'Error with Access Token Request: {}' ...
[ "Alternate constructor for OAuth2Credential().\n\n Create an OAuth2Credential from an HTTP Response.\n\n Parameters\n response (Response)\n HTTP Response containing OAuth 2.0 credentials.\n grant_type (str)\n Type of OAuth 2.0 Grant used to obtain ac...
Please provide a description of the function:def import_app_credentials(filename=CREDENTIALS_FILENAME): with open(filename, 'r') as config_file: config = safe_load(config_file) client_id = config['client_id'] client_secret = config['client_secret'] redirect_url = config['redirect_url'] ...
[ "Import app credentials from configuration file.\n\n Parameters\n filename (str)\n Name of configuration file.\n\n Returns\n credentials (dict)\n All your app credentials and information\n imported from the configuration file.\n " ]
Please provide a description of the function:def create_uber_client(credentials): oauth2credential = OAuth2Credential( client_id=credentials.get('client_id'), access_token=credentials.get('access_token'), expires_in_seconds=credentials.get('expires_in_seconds'), scopes=credentia...
[ "Create an UberRidesClient from OAuth 2.0 credentials.\n\n Parameters\n credentials (dict)\n Dictionary of OAuth 2.0 credentials.\n\n Returns\n (UberRidesClient)\n An authorized UberRidesClient to access API resources.\n " ]
Please provide a description of the function:def encrypt(receiver_pubhex: str, msg: bytes) -> bytes: disposable_key = generate_key() receiver_pubkey = hex2pub(receiver_pubhex) aes_key = derive(disposable_key, receiver_pubkey) cipher_text = aes_encrypt(aes_key, msg) return disposable_key.public_...
[ "\n Encrypt with eth public key\n\n Parameters\n ----------\n receiver_pubhex: str\n Receiver's ethereum public key hex string\n msg: bytes\n Data to encrypt\n\n Returns\n -------\n bytes\n Encrypted data\n " ]
Please provide a description of the function:def decrypt(receiver_prvhex: str, msg: bytes) -> bytes: pubkey = msg[0:65] # pubkey's length is 65 bytes encrypted = msg[65:] sender_public_key = hex2pub(pubkey.hex()) private_key = hex2prv(receiver_prvhex) aes_key = derive(private_key, sender_publi...
[ "\n Decrypt with eth private key\n\n Parameters\n ----------\n receiver_pubhex: str\n Receiver's ethereum private key hex string\n msg: bytes\n Data to decrypt\n\n Returns\n -------\n bytes\n Plain text\n " ]
Please provide a description of the function:def hex2pub(pub_hex: str) -> PublicKey: uncompressed = decode_hex(pub_hex) if len(uncompressed) == 64: uncompressed = b"\x04" + uncompressed return PublicKey(uncompressed)
[ "\n Convert ethereum hex to EllipticCurvePublicKey\n The hex should be 65 bytes, but ethereum public key only has 64 bytes\n So have to add \\x04\n\n Parameters\n ----------\n pub_hex: str\n Ethereum public key hex string\n\n Returns\n -------\n coincurve.PublicKey\n A secp2...
Please provide a description of the function:def derive(private_key: PrivateKey, peer_public_key: PublicKey) -> bytes: return private_key.ecdh(peer_public_key.format())
[ "\n Key exchange between private key and peer's public key,\n `derive(k1, k2.public_key)` should be equal to `derive(k2, k1.public_key)`.\n\n Parameters\n ----------\n private_key: coincurve.PrivateKey\n A secp256k1 private key\n peer_public_key: coincurve.PublicKey\n Peer's public k...
Please provide a description of the function:def aes_encrypt(key: bytes, plain_text: bytes) -> bytes: aes_cipher = AES.new(key, AES_CIPHER_MODE) encrypted, tag = aes_cipher.encrypt_and_digest(plain_text) cipher_text = bytearray() cipher_text.extend(aes_cipher.nonce) cipher_text.extend(tag) ...
[ "\n AES-GCM encryption\n\n Parameters\n ----------\n key: bytes\n AES session key, which derived from two secp256k1 keys\n plain_text: bytes\n Plain text to encrypt\n\n Returns\n -------\n bytes\n nonce(16 bytes) + tag(16 bytes) + encrypted data\n " ]
Please provide a description of the function:def aes_decrypt(key: bytes, cipher_text: bytes) -> bytes: nonce = cipher_text[:16] tag = cipher_text[16:32] ciphered_data = cipher_text[32:] aes_cipher = AES.new(key, AES_CIPHER_MODE, nonce=nonce) return aes_cipher.decrypt_and_verify(ciphered_data, ...
[ "\n AES-GCM decryption\n\n Parameters\n ----------\n key: bytes\n AES session key, which derived from two secp256k1 keys\n cipher_text: bytes\n Encrypted text:\n nonce(16 bytes) + tag(16 bytes) + encrypted data\n\n Returns\n -------\n bytes\n Plain text\n\n ...
Please provide a description of the function:def apply_scaling(self, copy=True): if copy: return self.multiplier * self.data + self.base if self.multiplier != 1: self.data *= self.multiplier if self.base != 0: self.data += self.base return ...
[ "Scale pixel values to there true DN.\n\n :param copy: whether to apply the scalling to a copy of the pixel data\n and leave the orginial unaffected\n\n :returns: a scalled version of the pixel data\n " ]
Please provide a description of the function:def specials_mask(self): mask = self.data >= self.specials['Min'] mask &= self.data <= self.specials['Max'] return mask
[ "Create a pixel map for special pixels.\n\n :returns: an array where the value is `False` if the pixel is special\n and `True` otherwise\n " ]
Please provide a description of the function:def get_image_array(self): specials_mask = self.specials_mask() data = self.data.copy() data[specials_mask] -= data[specials_mask].min() data[specials_mask] *= 255 / data[specials_mask].max() data[data == self.specials['His'...
[ "Create an array for use in making an image.\n\n Creates a linear stretch of the image and scales it to between `0` and\n `255`. `Null`, `Lis` and `Lrs` pixels are set to `0`. `His` and `Hrs`\n pixels are set to `255`.\n\n Usage::\n\n from pysis import CubeFile\n fr...
Please provide a description of the function:def dtype(self): pixels_group = self.label['IsisCube']['Core']['Pixels'] byte_order = self.BYTE_ORDERS[pixels_group['ByteOrder']] pixel_type = self.PIXEL_TYPES[pixels_group['Type']] return pixel_type.newbyteorder(byte_order)
[ "Pixel data type." ]
Please provide a description of the function:def get_bin_index(self, value): if value == self.max_value: return self.num_bins - 1 return int(self.C * log(value / self.min_value))
[ "Used to get the index of the bin to place a particular value." ]
Please provide a description of the function:def get_bounds(self, bin_num): min_value = pow(2.0, float(bin_num) / 2.0) * self.min_value max_value = pow(2.0, float(bin_num + 1.0) / 2.0) * self.min_value return self.Bounds(min_value, max_value)
[ "Get the bonds of a bin, given its index `bin_num`.\n\n :returns: a `Bounds` namedtuple with properties min and max\n respectively.\n " ]
Please provide a description of the function:def check_isis_version(major, minor=0, patch=0): if ISIS_VERSION and (major, minor, patch) <= ISIS_VERISON_TUPLE: return msg = 'Version %s.%s.%s of isis required (%s found).' raise VersionError(msg % (major, minor, patch, ISIS_VERSION))
[ "Checks that the current isis version is equal to or above the suplied\n version." ]
Please provide a description of the function:def require_isis_version(major, minor=0, patch=0): def decorator(fn): @wraps(fn) def wrapper(*args, **kwargs): check_isis_version(major, minor, patch) return fn(*args, **kwargs) return wrapper return decorator
[ "Decorator that ensures a function is called with a minimum isis version.\n " ]
Please provide a description of the function:def write_file_list(filename, file_list=[], glob=None): if glob: file_list = iglob(glob) with open(filename, 'w') as f: for line in file_list: f.write(line + '\n')
[ "Write a list of files to a file.\n\n :param filename: the name of the file to write the list to\n\n :param file_list: a list of filenames to write to a file\n\n :param glob: if glob is specified, it will ignore file_list and instead\n create a list of files based on the pattern provide by glob (ex....
Please provide a description of the function:def file_variations(filename, extensions): (label, ext) = splitext(filename) return [label + extention for extention in extensions]
[ "Create a variation of file names.\n\n Generate a list of variations on a filename by replacing the extension with\n a the provided list.\n\n :param filename: The original file name to use as a base.\n\n :param extensions: A list of file extensions to generate new filenames.\n " ]
Please provide a description of the function:def get_bin_index(self, value): if value == self.max_value: return self.num_bins - 1 return int((value - self.min_value) / self.bin_size)
[ "Used to get the index of the bin to place a particular value." ]
Please provide a description of the function:def get_bounds(self, bin_num): min_bound = (self.bin_size * bin_num) + self.min_value max_bound = min_bound + self.bin_size return self.Bounds(min_bound, max_bound)
[ "Get the bonds of a bin, given its index `bin_num`.\n\n :returns: a `Bounds` namedtuple with properties min and max\n respectively.\n " ]
Please provide a description of the function:def insert(self, key, value, data={}): if value < self.min_value or value > self.max_value: raise BoundsError('item value out of bounds') item = self.Item(key, value, data) index = self.get_bin_index(value) self.bins[ind...
[ "Insert the `key` into a bin based on the given `value`.\n\n Optionally, `data` dictionary may be provided to attach arbitrary data\n to the key.\n " ]
Please provide a description of the function:def iterkeys(self): def _iterkeys(bin): for item in bin: yield item.key for bin in self.bins: yield _iterkeys(bin)
[ "An iterator over the keys of each bin." ]
Please provide a description of the function:def file_request(self): response = requests.get( self.__base_url, headers=self.__headers, stream=True) return response.raw.read(), response.headers
[ "\n Request that retrieve a binary file\n " ]
Please provide a description of the function:def get_signatures(self, limit=100, offset=0, conditions={}): url = self.SIGNS_URL + "?limit=%s&offset=%s" % (limit, offset) for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url ...
[ "\n Get all signatures\n " ]
Please provide a description of the function:def get_signature(self, signature_id): connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_ID_URL % signature_id) return connection.get_request()
[ "\n Get a concrete Signature\n @return Signature data\n " ]
Please provide a description of the function:def count_signatures(self, conditions={}): url = self.SIGNS_COUNT_URL + '?' for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url += '&%s=%s' % (key, value) connection = ...
[ "\n Count all signatures\n " ]
Please provide a description of the function:def download_audit_trail(self, signature_id, document_id): connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_DOCUMENTS_AUDIT_URL % (signature_id, document_id)) response, headers = connection.file_request() ...
[ "\n Get the audit trail of concrete document\n @signature_id: Id of signature\n @document_id: Id of document\n " ]
Please provide a description of the function:def download_signed_document(self, signature_id, document_id): connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_DOCUMENTS_SIGNED_URL % (signature_id, document_id)) response, headers = connection.file_reques...
[ "\n Get the audit trail of concrete document\n @signature_id: Id of signature\n @document_id: Id of document\n " ]
Please provide a description of the function:def cancel_signature(self, signature_id): connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_CANCEL_URL % signature_id) return connection.patch_request()
[ "\n Cancel a concrete Signature\n @signature_id: Id of signature\n @return Signature data\n " ]
Please provide a description of the function:def send_signature_reminder(self, signature_id): connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_SEND_REMINDER_URL % signature_id) return connection.post_request()
[ "\n Send a reminder email\n @signature_id: Id of signature\n @document_id: Id of document\n " ]
Please provide a description of the function:def get_branding(self, branding_id): connection = Connection(self.token) connection.set_url(self.production, self.BRANDINGS_ID_URL % branding_id) return connection.get_request()
[ "\n Get a concrete branding\n @branding_id: Id of the branding to fetch\n @return Branding\n " ]
Please provide a description of the function:def get_brandings(self): connection = Connection(self.token) connection.set_url(self.production, self.BRANDINGS_URL) return connection.get_request()
[ "\n Get all account brandings\n @return List of brandings\n " ]
Please provide a description of the function:def create_branding(self, params): connection = Connection(self.token) connection.add_header('Content-Type', 'application/json') connection.set_url(self.production, self.BRANDINGS_URL) connection.add_params(params, json_format=True) ...
[ "\n Create a new branding\n @params: An array of params (all params are optional)\n - layout: Default color for all application widgets (hex code)\n - text: Default text color for all application widgets (hex code)\n - application_texts: A dict with the new text values...
Please provide a description of the function:def update_branding(self, branding_id, params): connection = Connection(self.token) connection.add_header('Content-Type', 'application/json') connection.set_url(self.production, self.BRANDINGS_ID_URL % branding_id) connection.add_par...
[ "\n Update a existing branding\n @branding_id: Id of the branding to update\n @params: Same params as method create_branding, see above\n @return: A dict with updated branding data\n " ]
Please provide a description of the function:def get_templates(self, limit=100, offset=0): url = self.TEMPLATES_URL + "?limit=%s&offset=%s" % (limit, offset) connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get all account templates\n " ]
Please provide a description of the function:def get_emails(self, limit=100, offset=0, conditions={}): url = self.EMAILS_URL + "?limit=%s&offset=%s" % (limit, offset) for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url += ...
[ "\n Get all certified emails\n " ]
Please provide a description of the function:def count_emails(self, conditions={}): url = self.EMAILS_COUNT_URL + "?" for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url += '&%s=%s' % (key, value) connection = Con...
[ "\n Count all certified emails\n " ]
Please provide a description of the function:def get_email(self, email_id): connection = Connection(self.token) connection.set_url(self.production, self.EMAILS_ID_URL % email_id) return connection.get_request()
[ "\n Get a specific email\n " ]
Please provide a description of the function:def count_SMS(self, conditions={}): url = self.SMS_COUNT_URL + "?" for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url += '&%s=%s' % (key, value) connection = Connectio...
[ "\n Count all certified sms\n " ]
Please provide a description of the function:def get_SMS(self, limit=100, offset=0, conditions={}): url = self.SMS_URL + "?limit=%s&offset=%s" % (limit, offset) for key, value in conditions.items(): if key is 'ids': value = ",".join(value) url += '&%s=%...
[ "\n Get all certified sms\n " ]
Please provide a description of the function:def get_single_SMS(self, sms_id): connection = Connection(self.token) connection.set_url(self.production, self.SMS_ID_URL % sms_id) return connection.get_request()
[ "\n Get a specific sms\n " ]
Please provide a description of the function:def create_SMS(self, files, recipients, body, params={}): parameters = {} parser = Parser() documents = {} parser.fill_array(documents, files, 'files') recipients = recipients if isinstance(recipients, list) else [recipien...
[ "\n Create a new certified sms\n\n @files\n Files to send\n ex: ['/documents/internet_contract.pdf', ... ]\n @recipients\n A dictionary with the phone and name of the person you want to sign. Phone must be always with prefix\n If you wanna send o...
Please provide a description of the function:def get_users(self, limit=100, offset=0): url = self.TEAM_USERS_URL + "?limit=%s&offset=%s" % (limit, offset) connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get all users from your current team\n " ]
Please provide a description of the function:def get_seats(self, limit=100, offset=0): url = self.TEAM_SEATS_URL + "?limit=%s&offset=%s" % (limit, offset) connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get all seats from your current team\n " ]
Please provide a description of the function:def get_user(self, user_id): url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get a single user\n " ]
Please provide a description of the function:def invite_user(self, email, role): parameters = { 'email': email, 'role': role } connection = Connection(self.token) connection.set_url(self.production, self.TEAM_USERS_URL) connection.add_params(para...
[ "\n Send an invitation to email with a link to join your team\n :param email: Email to add to your team\n :param role: Can be admin or member\n " ]
Please provide a description of the function:def change_user_role(self, user_id, role): parameters = { 'role': role } url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) connection.add_...
[ "\n Change role of current user\n :param user_id: Id of user\n :param role: Can be admin or member\n " ]
Please provide a description of the function:def remove_user(self, user_id): url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Remove a user from your team\n :param user_id: Id of user\n " ]
Please provide a description of the function:def remove_seat(self, seat_id): url = self.TEAM_SEATS_ID_URL % seat_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Remove a seat from your team\n :param seat_id: Id of user\n " ]
Please provide a description of the function:def get_groups(self, limit=100, offset=0): url = self.TEAM_GROUPS_URL + "?limit=%s&offset=%s" % (limit, offset) connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get all groups from your current team\n " ]
Please provide a description of the function:def get_group(self, group_id): url = self.TEAM_GROUPS_ID_URL % group_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get a single group\n " ]
Please provide a description of the function:def create_group(self, name): parameters = { 'name': name } url = self.TEAM_GROUPS_URL connection = Connection(self.token) connection.set_url(self.production, url) connection.add_params(parameters) ...
[ "\n Create group\n :param name: Group name\n " ]
Please provide a description of the function:def update_group(self, group_id, name): parameters = { 'name': name } url = self.TEAM_GROUPS_ID_URL % group_id connection = Connection(self.token) connection.set_url(self.production, url) connection.add_h...
[ "\n Change group name\n :param group_id: Id of group\n :param name: Group name\n " ]
Please provide a description of the function:def delete_group(self, group_id): url = self.TEAM_GROUPS_ID_URL % group_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Remove a group from your team\n :param group_id: Id of group\n " ]
Please provide a description of the function:def add_member_to_group(self, group_id, user_id): url = self.TEAM_MEMBERS_URL % (group_id, user_id) connection = Connection(self.token) connection.set_url(self.production, url) return connection.post_request()
[ "\n Add a user to a group as a member\n :param group_id:\n :param user_id:\n " ]
Please provide a description of the function:def remove_member_from_group(self, group_id, user_id): url = self.TEAM_MEMBERS_URL % (group_id, user_id) connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Add a user to a group as a member\n :param group_id:\n :param user_id:\n " ]
Please provide a description of the function:def add_manager_to_group(self, group_id, user_id): url = self.TEAM_MANAGERS_URL % (group_id, user_id) connection = Connection(self.token) connection.set_url(self.production, url) return connection.post_request()
[ "\n Add a user to a group as a member\n :param group_id:\n :param user_id:\n " ]
Please provide a description of the function:def remove_manager_from_group(self, group_id, user_id): url = self.TEAM_MANAGERS_URL % (group_id, user_id) connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Add a user to a group as a member\n :param group_id:\n :param user_id:\n " ]
Please provide a description of the function:def get_subscriptions(self, limit=100, offset=0, params={}): url = self.SUBSCRIPTIONS_URL + "?limit=%s&offset=%s" % (limit, offset) for key, value in params.items(): if key is 'ids': value = ",".join(value) u...
[ "\n Get all subscriptions\n " ]
Please provide a description of the function:def count_subscriptions(self, params={}): url = self.SUBSCRIPTIONS_COUNT_URL + '?' for key, value in params.items(): if key is 'ids': value = ",".join(value) url += '&%s=%s' % (key, value) connection...
[ "\n Count all subscriptions\n " ]
Please provide a description of the function:def get_subscription(self, subscription_id): url = self.SUBSCRIPTIONS_ID_URL % subscription_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get single subscription\n " ]
Please provide a description of the function:def create_subscription(self, url, events): params = { 'url': url, 'events': events } url = self.SUBSCRIPTIONS_URL connection = Connection(self.token) connection.set_url(self.production, url) ...
[ "\n Create subscription\n :param events: Events to subscribe\n :param url: Url to send events\n " ]
Please provide a description of the function:def update_subscription(self, subscription_id, url=None, events=None): params = {} if url is not None: params['url'] = url if events is not None: params['events'] = events url = self.SUBSCRIPTIONS_ID_URL % s...
[ "\n Create subscription\n :param subscription_id: Subscription to update\n :param events: Events to subscribe\n :param url: Url to send events\n " ]
Please provide a description of the function:def delete_subscription(self, subscription_id): url = self.SUBSCRIPTIONS_ID_URL % subscription_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Delete single subscription\n " ]
Please provide a description of the function:def get_contacts(self, limit=100, offset=0, params={}): url = self.CONTACTS_URL + "?limit=%s&offset=%s" % (limit, offset) for key, value in params.items(): if key is 'ids': value = ",".join(value) url += '&%s...
[ "\n Get all account contacts\n " ]
Please provide a description of the function:def get_contact(self, contact_id): url = self.CONTACTS_ID_URL % contact_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.get_request()
[ "\n Get single contact\n " ]
Please provide a description of the function:def create_contact(self, email, name): params = {'email': email, 'name': name} url = self.CONTACTS_URL connection = Connection(self.token) connection.set_url(self.production, url) connection.add_header('Content-Type', 'appli...
[ "\n Create a new contact\n :param email: user email\n :param name: user name\n " ]
Please provide a description of the function:def update_contact(self, contact_id, email=None, name=None): params = {} if email is not None: params['email'] = email if name is not None: params['name'] = name url = self.CONTACTS_ID_URL % contact_id ...
[ "\n Update a current contact\n :param contact_id: contact id\n :param email: user email\n :param name: user name\n " ]
Please provide a description of the function:def delete_contact(self, contact_id): url = self.CONTACTS_ID_URL % contact_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "\n Delete single contact\n " ]
Please provide a description of the function:def sleep_walk(secs): ''' Pass the time by adding numbers until the specified number of seconds has elapsed. Intended as a replacement for ``time.sleep`` that doesn't leave the CPU idle (which will make the job seem like it's stalled). ''' start_time ...
[]
Please provide a description of the function:def computeFactorial(n): sleep_walk(10) ret = 1 for i in range(n): ret = ret * (i + 1) return ret
[ "\n computes factorial of n\n " ]
Please provide a description of the function:def main(): logging.captureWarnings(True) logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' + '%(message)s'), level=logging.INFO) args = [3, 5, 10, 20] # The default queue used by grid_map is all.q...
[ "\n execute map example\n " ]
Please provide a description of the function:def compute_factorial(n): sleep_walk(10) ret = 1 for i in range(n): ret = ret * (i + 1) return ret
[ "\n computes factorial of n\n " ]
Please provide a description of the function:def make_jobs(): # set up list of arguments inputvec = [[3], [5], [10], [20]] # create empty job vector jobs = [] # create job objects for arg in inputvec: # The default queue used by the Job class is all.q. You must specify # ...
[ "\n creates a list of Job objects,\n which carry all information needed\n for a function to be executed on SGE:\n - function object\n - arguments\n - settings\n " ]
Please provide a description of the function:def main(): logging.captureWarnings(True) logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' + '%(message)s'), level=logging.INFO) print("=====================================") print("======== Sub...
[ "\n run a set of jobs on cluster\n " ]
Please provide a description of the function:def execute_cmd(cmd, **kwargs): yield '$ {}\n'.format(' '.join(cmd)) kwargs['stdout'] = subprocess.PIPE kwargs['stderr'] = subprocess.STDOUT proc = subprocess.Popen(cmd, **kwargs) # Capture output for logging. # Each line will be yielded as tex...
[ "\n Call given command, yielding output line by line\n " ]
Please provide a description of the function:def main(): logging.basicConfig( format='[%(asctime)s] %(levelname)s -- %(message)s', level=logging.DEBUG) parser = argparse.ArgumentParser(description='Synchronizes a github repository with a local repository.') parser.add_argument('git_url...
[ "\n Synchronizes a github repository with a local repository.\n " ]
Please provide a description of the function:def pull(self): if not os.path.exists(self.repo_dir): yield from self.initialize_repo() else: yield from self.update()
[ "\n Pull selected repo from a remote git repository,\n while preserving user changes\n " ]
Please provide a description of the function:def initialize_repo(self): logging.info('Repo {} doesn\'t exist. Cloning...'.format(self.repo_dir)) clone_args = ['git', 'clone'] if self.depth and self.depth > 0: clone_args.extend(['--depth', str(self.depth)]) clone_arg...
[ "\n Clones repository & sets up usernames.\n " ]
Please provide a description of the function:def reset_deleted_files(self): yield from self.ensure_lock() deleted_files = subprocess.check_output([ 'git', 'ls-files', '--deleted' ], cwd=self.repo_dir).decode().strip().split('\n') for filename in deleted_files: ...
[ "\n Runs the equivalent of git checkout -- <file> for each file that was\n deleted. This allows us to delete a file, hit an interact link, then get a\n clean version of the file again.\n " ]
Please provide a description of the function:def repo_is_dirty(self): try: subprocess.check_call(['git', 'diff-files', '--quiet'], cwd=self.repo_dir) # Return code is 0 return False except subprocess.CalledProcessError: return True
[ "\n Return true if repo is dirty\n " ]
Please provide a description of the function:def find_upstream_changed(self, kind): output = subprocess.check_output([ 'git', 'log', '{}..origin/{}'.format(self.branch_name, self.branch_name), '--oneline', '--name-status' ], cwd=self.repo_dir).decode() files = []...
[ "\n Return list of files that have been changed upstream belonging to a particular kind of change\n " ]
Please provide a description of the function:def ensure_lock(self): try: lockpath = os.path.join(self.repo_dir, '.git', 'index.lock') mtime = os.path.getmtime(lockpath) # A lock file does exist # If it's older than 10 minutes, we just assume it is stale a...
[ "\n Make sure we have the .git/lock required to do modifications on the repo\n\n This must be called before any git commands that modify state. This isn't guaranteed\n to be atomic, due to the nature of using files for locking. But it's the best we\n can do right now.\n " ]
Please provide a description of the function:def rename_local_untracked(self): # Find what files have been added! new_upstream_files = self.find_upstream_changed('A') for f in new_upstream_files: if os.path.exists(f): # If there's a file extension, put the ti...
[ "\n Rename local untracked files that would require pulls\n " ]
Please provide a description of the function:def update(self): # Fetch remotes, so we know we're dealing with latest remote yield from self.update_remotes() # Rename local untracked files that might be overwritten by pull yield from self.rename_local_untracked() # Rese...
[ "\n Do the pulling if necessary\n " ]