code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
method = 'flickr.photos.setTags'
tags = uniq(tags)
_dopost(method, auth=True, photo_id=self.id, tags=tags)
self._load_properties() | def setTags(self, tags) | Set the tags for current photo to list tags.
(flickr.photos.settags) | 8.582623 | 6.662463 | 1.288206 |
method = 'flickr.photos.addTags'
if isinstance(tags, list):
tags = uniq(tags)
_dopost(method, auth=True, photo_id=self.id, tags=tags)
#load properties again
self._load_properties() | def addTags(self, tags) | Adds the list of tags to current tags. (flickr.photos.addtags) | 7.510315 | 6.715475 | 1.118359 |
method = 'flickr.photos.removeTag'
tag_id = ''
try:
tag_id = tag.id
except AttributeError:
raise FlickrError, "Tag object expected"
_dopost(method, auth=True, photo_id=self.id, tag_id=tag_id)
self._load_properties() | def removeTag(self, tag) | Remove the tag from the photo must be a Tag object.
(flickr.photos.removeTag) | 5.189816 | 3.968072 | 1.307894 |
method = 'flickr.photos.setMeta'
if title is None:
title = self.title
if description is None:
description = self.description
_dopost(method, auth=True, title=title, \
description=description, photo_id=self.id)
... | def setMeta(self, title=None, description=None) | Set metadata for photo. (flickr.photos.setMeta) | 3.904954 | 3.496218 | 1.116908 |
method = 'flickr.photos.getSizes'
data = _doget(method, photo_id=self.id)
for psize in data.rsp.sizes.size:
if psize.label == size:
return getattr(psize, urlType)
raise FlickrError, "No URL found" | def getURL(self, size='Medium', urlType='url') | Retrieves a url for the photo. (flickr.photos.getSizes)
urlType - 'url' or 'source'
'url' - flickr page of photo
'source' - image file | 4.69167 | 4.488997 | 1.045149 |
method = 'flickr.photos.getSizes'
data = _doget(method, photo_id=self.id)
ret = []
# The given props are those that we return and the according types, since
# return width and height as string would make "75">"100" be True, which
# is just error prone.
p... | def getSizes(self) | Get all the available sizes of the current image, and all available
data about them.
Returns: A list of dicts with the size data. | 7.954572 | 7.536438 | 1.055482 |
method = 'flickr.photos.geo.getLocation'
try:
data = _doget(method, photo_id=self.id)
except FlickrError: # Some other error might have occured too!?
return None
loc = data.rsp.photo.location
return [loc.latitude, loc.longitude] | def getLocation(self) | Return the latitude+longitutde of the picture.
Returns None if no location given for this pic. | 6.885245 | 6.31147 | 1.09091 |
method = 'flickr.photosets.getPhotos'
data = _doget(method, photoset_id=self.id)
photos = data.rsp.photoset.photo
p = []
for photo in photos:
p.append(Photo(photo.id, title=photo.title, secret=photo.secret, \
server=photo.server))
... | def getPhotos(self) | Returns list of Photos. | 3.872233 | 3.686038 | 1.050514 |
method = 'flickr.photosets.editPhotos'
if primary is None:
primary = self.primary
ids = [photo.id for photo in photos]
if primary.id not in ids:
ids.append(primary.id)
_dopost(method, auth=True, photoset_id=self.id,\
... | def editPhotos(self, photos, primary=None) | Edit the photos in this set.
photos - photos for set
primary - primary photo (if None will used current) | 4.296608 | 4.149636 | 1.035418 |
method = 'flickr.photosets.addPhoto'
_dopost(method, auth=True, photoset_id=self.id, photo_id=photo.id)
self.__count += 1
return True | def addPhoto(self, photo) | Add a photo to this set.
photo - the photo | 6.562124 | 6.936386 | 0.946044 |
method = 'flickr.photosets.editMeta'
if title is None:
title = self.title
if description is None:
description = self.description
_dopost(method, auth=True, title=title, \
description=description, photoset_id=self.id)
... | def editMeta(self, title=None, description=None) | Set metadata for photo. (flickr.photos.setMeta) | 3.856909 | 3.550229 | 1.086383 |
method = 'flickr.photosets.delete'
_dopost(method, auth=True, photoset_id=self.id)
return True | def delete(self) | Deletes the photoset. | 11.222339 | 6.738437 | 1.665422 |
if not isinstance(photo, Photo):
raise TypeError, "Photo expected"
method = 'flickr.photosets.create'
data = _dopost(method, auth=True, title=title,\
description=description,\
primary_photo_id=photo.id)
... | def create(cls, photo, title, description='') | Create a new photoset.
photo - primary photo | 5.985481 | 6.418674 | 0.93251 |
if getattr(self, "_%s__%s" % (self.__class__.__name__, var)) is None \
and not self.__loaded:
self._load_properties()
return getattr(self, "_%s__%s" % (self.__class__.__name__, var)) | def _general_getattr(self, var) | Generic get attribute function. | 2.902087 | 2.908028 | 0.997957 |
method = 'flickr.people.getInfo'
data = _doget(method, user_id=self.__id)
self.__loaded = True
person = data.rsp.person
self.__isadmin = person.isadmin
self.__ispro = person.ispro
self.__icon_server = person.iconserver
if int(person.ico... | def _load_properties(self) | Load User properties from Flickr. | 3.150967 | 2.870981 | 1.097523 |
method = 'flickr.photosets.getList'
data = _doget(method, user_id=self.id)
sets = []
if isinstance(data.rsp.photosets.photoset, list):
for photoset in data.rsp.photosets.photoset:
sets.append(Photoset(photoset.id, photoset.title.text,\
... | def getPhotosets(self) | Returns a list of Photosets. | 2.274778 | 2.239398 | 1.015799 |
method = 'flickr.groups.getInfo'
data = _doget(method, group_id=self.id)
self.__loaded = True
group = data.rsp.group
self.__name = photo.name.text
self.__members = photo.members.text
self.__online = photo.online.text
self.__privacy = ph... | def _load_properties(self) | Loads the properties from Flickr. | 6.337938 | 5.504717 | 1.151365 |
method = 'flickr.groups.pools.getPhotos'
data = _doget(method, group_id=self.id, tags=tags,\
per_page=per_page, page=page)
photos = []
for photo in data.rsp.photos.photo:
photos.append(_parse_photo(photo))
return photos | def getPhotos(self, tags='', per_page='', page='') | Get a list of photo objects for this group | 3.744687 | 3.790076 | 0.988024 |
method = 'flickr.groups.pools.add'
_dopost(method, auth=True, photo_id=photo.id, group_id=self.id)
return True | def add(self, photo) | Adds a Photo to the group | 7.66983 | 6.600772 | 1.161959 |
key = Key(self.name, self.contained_key)
return SimpleResultSet([key]) | def get_all_keys(self, headers=None, **params) | This method returns the single key around which this anonymous Bucket
was instantiated.
:rtype: SimpleResultSet
:return: The result from file system listing the keys requested | 31.414385 | 18.309261 | 1.715765 |
if key_name == '-':
return Key(self.name, '-', key_type=Key.KEY_STREAM_READABLE)
else:
fp = open(key_name, 'rb')
return Key(self.name, key_name, fp) | def get_key(self, key_name, headers=None, version_id=None,
key_type=Key.KEY_REGULAR_FILE) | Check to see if a particular key exists within the bucket.
Returns: An instance of a Key object or None
:type key_name: string
:param key_name: The name of the key to retrieve
:type version_id: string
:param version_id: Unused in this subclass.
:type stream_type: integ... | 4.953533 | 4.562681 | 1.085663 |
if key_name == '-':
return Key(self.name, '-', key_type=Key.KEY_STREAM_WRITABLE)
else:
dir_name = os.path.dirname(key_name)
if dir_name and not os.path.exists(dir_name):
os.makedirs(dir_name)
fp = open(key_name, 'wb')
r... | def new_key(self, key_name=None, key_type=Key.KEY_REGULAR_FILE) | Creates a new key
:type key_name: string
:param key_name: The name of the key to create
:rtype: :class:`boto.file.key.Key`
:returns: An instance of the newly created key object | 2.962018 | 3.276983 | 0.903886 |
params = {'QueueName': queue_name}
if visibility_timeout:
params['DefaultVisibilityTimeout'] = '%d' % (visibility_timeout,)
return self.get_object('CreateQueue', params, botornado.sqs.queue.AsyncQueue, callback=callback) | def create_queue(self, queue_name, visibility_timeout=None, callback=None) | Create an SQS Queue.
:type queue_name: str or unicode
:param queue_name: The name of the new queue. Names are scoped to
an account and need to be unique within that
account. Calling this method on an existing
queue name ... | 4.544725 | 5.253564 | 0.865075 |
return self.get_status('DeleteQueue', None, queue.id, callback=callback) | def delete_queue(self, queue, force_deletion=False, callback=None) | Delete an SQS Queue.
:type queue: A Queue object
:param queue: The SQS queue to be deleted
:type force_deletion: Boolean
:param force_deletion: Normally, SQS will not delete a queue that
contains messages. However, if the
... | 11.325149 | 10.162313 | 1.114426 |
params = {'AttributeName' : attribute}
return self.get_object('GetQueueAttributes', params,
Attributes, queue.id, callback=callback) | def get_queue_attributes(self, queue, attribute='All', callback=None) | Gets one or all attributes of a Queue
:type queue: A Queue object
:param queue: The SQS queue to be deleted
:type attribute: str
:type attribute: The specific attribute requested. If not supplied,
the default is to return all attributes.
... | 5.383253 | 4.651787 | 1.157244 |
params = {'MaxNumberOfMessages' : number_messages}
if visibility_timeout:
params['VisibilityTimeout'] = visibility_timeout
if attributes:
self.build_list_params(params, attributes, 'AttributeName')
return self.get_list('ReceiveMessage', params,
... | def receive_message(self, queue, number_messages=1,
visibility_timeout=None, attributes=None, callback=None) | Read messages from an SQS Queue.
:type queue: A Queue object
:param queue: The Queue from which messages are read.
:type number_messages: int
:param number_messages: The maximum number of messages to read
(default=1)
:type visibi... | 3.308647 | 3.368664 | 0.982184 |
params = {'ReceiptHandle' : receipt_handle,
'VisibilityTimeout' : visibility_timeout}
return self.get_status('ChangeMessageVisibility', params, queue.id, callback=callback) | def change_message_visibility(self, queue, receipt_handle,
visibility_timeout, callback=None) | Extends the read lock timeout for the specified message from
the specified queue to the specified value.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param queue: The receipt handle ... | 3.255504 | 4.439848 | 0.733247 |
params = {'Label': label,
'AWSAccountId' : aws_account_id,
'ActionName' : action_name}
return self.get_status('AddPermission', params, queue.id, callback=callback) | def add_permission(self, queue, label, aws_account_id, action_name, callback=None) | Add a permission to a queue.
:type queue: :class:`boto.sqs.queue.Queue`
:param queue: The queue object
:type label: str or unicode
:param label: A unique identification of the permission you are setting.
Maximum of 80 characters ``[0-9a-zA-Z_-]``
... | 3.030576 | 3.226993 | 0.939133 |
return [RDSRegionInfo(name='us-east-1',
endpoint='rds.us-east-1.amazonaws.com'),
RDSRegionInfo(name='eu-west-1',
endpoint='rds.eu-west-1.amazonaws.com'),
RDSRegionInfo(name='us-west-1',
endpoint='rds.us-west-1... | def regions() | Get all available regions for the RDS service.
:rtype: list
:return: A list of :class:`boto.rds.regioninfo.RDSRegionInfo` | 1.439433 | 1.356468 | 1.061162 |
params = {}
if instance_id:
params['DBInstanceIdentifier'] = instance_id
if max_records:
params['MaxRecords'] = max_records
if marker:
params['Marker'] = marker
return self.get_list('DescribeDBInstances', params,
... | def get_all_dbinstances(self, instance_id=None, max_records=None,
marker=None) | Retrieve all the DBInstances in your account.
:type instance_id: str
:param instance_id: DB Instance identifier. If supplied, only
information this instance will be returned.
Otherwise, info about all DB Instances will
... | 1.600413 | 2.012257 | 0.795332 |
params = {'DBInstanceIdentifier' : id,
'SourceDBInstanceIdentifier' : source_id}
if instance_class:
params['DBInstanceClass'] = instance_class
if port:
params['Port'] = port
if availability_zone:
params['AvailabilityZone'] = ... | def create_dbinstance_read_replica(self, id, source_id,
instance_class=None,
port=3306,
availability_zone=None,
auto_minor_version_upgrade=None) | Create a new DBInstance Read Replica.
:type id: str
:param id: Unique identifier for the new instance.
Must contain 1-63 alphanumeric characters.
First character must be a letter.
May not end with a hyphen or contain two consecutive hyphens
... | 1.515194 | 1.633913 | 0.927341 |
params = {'DBInstanceIdentifier' : id}
if param_group:
params['DBParameterGroupName'] = param_group
if security_groups:
l = []
for group in security_groups:
if isinstance(group, DBSecurityGroup):
l.append(group.name... | def modify_dbinstance(self, id, param_group=None, security_groups=None,
preferred_maintenance_window=None,
master_password=None, allocated_storage=None,
instance_class=None,
backup_retention_period=None,
... | Modify an existing DBInstance.
:type id: str
:param id: Unique identifier for the new instance.
:type security_groups: list of str or list of DBSecurityGroup objects
:param security_groups: List of names of DBSecurityGroup to authorize on
this DBInstance... | 1.423041 | 1.467155 | 0.969933 |
params = {'DBInstanceIdentifier' : id}
if skip_final_snapshot:
params['SkipFinalSnapshot'] = 'true'
else:
params['SkipFinalSnapshot'] = 'false'
params['FinalDBSnapshotIdentifier'] = final_snapshot_id
return self.get_object('DeleteDBInstance', ... | def delete_dbinstance(self, id, skip_final_snapshot=False,
final_snapshot_id='') | Delete an existing DBInstance.
:type id: str
:param id: Unique identifier for the new instance.
:type skip_final_snapshot: bool
:param skip_final_snapshot: This parameter determines whether a final
db snapshot is created before the instance
... | 1.906891 | 2.142369 | 0.890085 |
params = {}
if groupname:
params['DBParameterGroupName'] = groupname
if max_records:
params['MaxRecords'] = max_records
if marker:
params['Marker'] = marker
return self.get_list('DescribeDBParameterGroups', params,
... | def get_all_dbparameter_groups(self, groupname=None, max_records=None,
marker=None) | Get all parameter groups associated with your account in a region.
:type groupname: str
:param groupname: The name of the DBParameter group to retrieve.
If not provided, all DBParameter groups will be returned.
:type max_records: int
:param max_records: The ma... | 1.67623 | 2.001146 | 0.837635 |
params = {'DBParameterGroupName' : groupname}
if source:
params['Source'] = source
if max_records:
params['MaxRecords'] = max_records
if marker:
params['Marker'] = marker
pg = self.get_object('DescribeDBParameters', params, ParameterGr... | def get_all_dbparameters(self, groupname, source=None,
max_records=None, marker=None) | Get all parameters associated with a ParameterGroup
:type groupname: str
:param groupname: The name of the DBParameter group to retrieve.
:type source: str
:param source: Specifies which parameters to return.
If not specified, all parameters will be returned.
... | 2.342146 | 2.412302 | 0.970917 |
params = {'DBParameterGroupName': name,
'DBParameterGroupFamily': engine,
'Description' : description}
return self.get_object('CreateDBParameterGroup', params, ParameterGroup) | def create_parameter_group(self, name, engine='MySQL5.1', description='') | Create a new dbparameter group for your account.
:type name: string
:param name: The name of the new dbparameter group
:type engine: str
:param engine: Name of database engine.
:type description: string
:param description: The description of the new security group
... | 3.547736 | 4.129508 | 0.859118 |
params = {'DBParameterGroupName': name}
for i in range(0, len(parameters)):
parameter = parameters[i]
parameter.merge(params, i+1)
return self.get_list('ModifyDBParameterGroup', params,
ParameterGroup, verb='POST') | def modify_parameter_group(self, name, parameters=None) | Modify a parameter group for your account.
:type name: string
:param name: The name of the new parameter group
:type parameters: list of :class:`boto.rds.parametergroup.Parameter`
:param parameters: The new parameters
:rtype: :class:`boto.rds.parametergroup.ParameterGroup`
... | 5.514972 | 5.710662 | 0.965732 |
params = {'DBParameterGroupName':name}
if reset_all_params:
params['ResetAllParameters'] = 'true'
else:
params['ResetAllParameters'] = 'false'
for i in range(0, len(parameters)):
parameter = parameters[i]
parameter.merg... | def reset_parameter_group(self, name, reset_all_params=False,
parameters=None) | Resets some or all of the parameters of a ParameterGroup to the
default value
:type key_name: string
:param key_name: The name of the ParameterGroup to reset
:type parameters: list of :class:`boto.rds.parametergroup.Parameter`
:param parameters: The parameters to reset. If not... | 3.551344 | 3.682907 | 0.964277 |
params = {}
if groupname:
params['DBSecurityGroupName'] = groupname
if max_records:
params['MaxRecords'] = max_records
if marker:
params['Marker'] = marker
return self.get_list('DescribeDBSecurityGroups', params,
... | def get_all_dbsecurity_groups(self, groupname=None, max_records=None,
marker=None) | Get all security groups associated with your account in a region.
:type groupnames: list
:param groupnames: A list of the names of security groups to retrieve.
If not provided, all security groups will
be returned.
:type max_records: int
... | 1.785788 | 2.148201 | 0.831295 |
params = {'DBSecurityGroupName':name}
if description:
params['DBSecurityGroupDescription'] = description
group = self.get_object('CreateDBSecurityGroup', params,
DBSecurityGroup)
group.name = name
group.description = descriptio... | def create_dbsecurity_group(self, name, description=None) | Create a new security group for your account.
This will create the security group within the region you
are currently connected to.
:type name: string
:param name: The name of the new security group
:type description: string
:param description: The description of the ne... | 2.806544 | 3.127648 | 0.897333 |
params = {'DBSecurityGroupName':group_name}
if ec2_security_group_name:
params['EC2SecurityGroupName'] = ec2_security_group_name
if ec2_security_group_owner_id:
params['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id
if cidr_ip:
params... | def authorize_dbsecurity_group(self, group_name, cidr_ip=None,
ec2_security_group_name=None,
ec2_security_group_owner_id=None) | Add a new rule to an existing security group.
You need to pass in either src_security_group_name and
src_security_group_owner_id OR a CIDR block but not both.
:type group_name: string
:param group_name: The name of the security group you are adding
the rule to... | 1.687208 | 2.093896 | 0.805774 |
params = {'DBSecurityGroupName':group_name}
if ec2_security_group_name:
params['EC2SecurityGroupName'] = ec2_security_group_name
if ec2_security_group_owner_id:
params['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id
if cidr_ip:
params... | def revoke_dbsecurity_group(self, group_name, ec2_security_group_name=None,
ec2_security_group_owner_id=None, cidr_ip=None) | Remove an existing rule from an existing security group.
You need to pass in either ec2_security_group_name and
ec2_security_group_owner_id OR a CIDR block.
:type group_name: string
:param group_name: The name of the security group you are removing
the rule fr... | 1.466739 | 1.898417 | 0.772612 |
params = {}
if snapshot_id:
params['DBSnapshotIdentifier'] = snapshot_id
if instance_id:
params['DBInstanceIdentifier'] = instance_id
if max_records:
params['MaxRecords'] = max_records
if marker:
params['Marker'] = marker
... | def get_all_dbsnapshots(self, snapshot_id=None, instance_id=None,
max_records=None, marker=None) | Get information about DB Snapshots.
:type snapshot_id: str
:param snapshot_id: The unique identifier of an RDS snapshot.
If not provided, all RDS snapshots will be returned.
:type instance_id: str
:param instance_id: The identifier of a DBInstance. If provi... | 1.485391 | 1.748412 | 0.849566 |
params = {'DBSnapshotIdentifier' : snapshot_id,
'DBInstanceIdentifier' : dbinstance_id}
return self.get_object('CreateDBSnapshot', params, DBSnapshot) | def create_dbsnapshot(self, snapshot_id, dbinstance_id) | Create a new DB snapshot.
:type snapshot_id: string
:param snapshot_id: The identifier for the DBSnapshot
:type dbinstance_id: string
:param dbinstance_id: The source identifier for the RDS instance from
which the snapshot is created.
:rtype: :cla... | 2.349721 | 3.105212 | 0.756702 |
params = {'DBSnapshotIdentifier' : identifier,
'DBInstanceIdentifier' : instance_id,
'DBInstanceClass' : instance_class}
if port:
params['Port'] = port
if availability_zone:
params['AvailabilityZone'] = availability_zone
... | def restore_dbinstance_from_dbsnapshot(self, identifier, instance_id,
instance_class, port=None,
availability_zone=None) | Create a new DBInstance from a DB snapshot.
:type identifier: string
:param identifier: The identifier for the DBSnapshot
:type instance_id: string
:param instance_id: The source identifier for the RDS instance from
which the snapshot is created.
... | 1.776792 | 2.00163 | 0.887673 |
params = {'SourceDBInstanceIdentifier' : source_instance_id,
'TargetDBInstanceIdentifier' : target_instance_id}
if use_latest:
params['UseLatestRestorableTime'] = 'true'
elif restore_time:
params['RestoreTime'] = restore_time.isoformat()
... | def restore_dbinstance_from_point_in_time(self, source_instance_id,
target_instance_id,
use_latest=False,
restore_time=None,
dbinstance_... | Create a new DBInstance from a point in time.
:type source_instance_id: string
:param source_instance_id: The identifier for the source DBInstance.
:type target_instance_id: string
:param target_instance_id: The identifier of the new DBInstance.
:type use_latest: bool
... | 1.5217 | 1.644681 | 0.925226 |
params = {}
if source_identifier and source_type:
params['SourceIdentifier'] = source_identifier
params['SourceType'] = source_type
if start_time:
params['StartTime'] = start_time.isoformat()
if end_time:
params['EndTime'] = end_ti... | def get_all_events(self, source_identifier=None, source_type=None,
start_time=None, end_time=None,
max_records=None, marker=None) | Get information about events related to your DBInstances,
DBSecurityGroups and DBParameterGroups.
:type source_identifier: str
:param source_identifier: If supplied, the events returned will be
limited to those that apply to the identified
... | 1.548721 | 1.675903 | 0.924111 |
with fileutil.opened(filename, "rb") as file:
if offset is None:
file.seek(-128, 2)
else:
file.seek(offset)
data = file.read(128)
return cls.decode(data, encoding=encoding) | def read(cls, filename, offset=None, encoding="iso-8859-1") | Read an ID3v1 tag from a file. | 2.779591 | 2.803532 | 0.99146 |
with fileutil.opened(filename, "rb+") as file:
if offset is None:
file.seek(-128, 2)
else:
file.seek(offset)
offset = file.tell()
data = file.read(128)
if data[:3] == b"TAG":
fileutil.replace_chu... | def delete(cls, filename, offset=None) | Delete ID3v1 tag from a file (if present). | 3.313858 | 3.052444 | 1.085641 |
if isinstance(acl_or_str, Policy):
raise InvalidAclError('Attempt to set S3 Policy on GS ACL')
elif isinstance(acl_or_str, ACL):
self.set_xml_acl(acl_or_str.to_xml(), key_name, headers=headers)
else:
self.set_canned_acl(acl_or_str, key_name, headers=... | def set_acl(self, acl_or_str, key_name='', headers=None, version_id=None) | sets or changes a bucket's acl. We include a version_id argument
to support a polymorphic interface for callers, however,
version_id is not relevant for Google Cloud Storage buckets
and is therefore ignored here. | 3.286113 | 3.067464 | 1.07128 |
if isinstance(acl_or_str, Policy):
raise InvalidAclError('Attempt to set S3 Policy on GS ACL')
elif isinstance(acl_or_str, ACL):
self.set_def_xml_acl(acl_or_str.to_xml(), key_name, headers=headers)
else:
self.set_def_canned_acl(acl_or_str, key_name, h... | def set_def_acl(self, acl_or_str, key_name='', headers=None) | sets or changes a bucket's default object acl | 3.451366 | 3.408018 | 1.012719 |
response = self.connection.make_request('GET', self.name, key_name,
query_args=query_args,
headers=headers)
body = response.read()
if response.status == 200:
acl = ACL(self)
... | def get_acl_helper(self, key_name, headers, query_args) | provides common functionality for get_acl() and get_def_acl() | 2.159262 | 2.188288 | 0.986736 |
return self.get_acl_helper(key_name, headers, STANDARD_ACL) | def get_acl(self, key_name='', headers=None, version_id=None) | returns a bucket's acl. We include a version_id argument
to support a polymorphic interface for callers, however,
version_id is not relevant for Google Cloud Storage buckets
and is therefore ignored here. | 7.7998 | 7.430971 | 1.049634 |
return self.set_canned_acl_helper(acl_str, key_name, headers,
STANDARD_ACL) | def set_canned_acl(self, acl_str, key_name='', headers=None,
version_id=None) | sets or changes a bucket's acl to a predefined (canned) value.
We include a version_id argument to support a polymorphic
interface for callers, however, version_id is not relevant for
Google Cloud Storage buckets and is therefore ignored here. | 4.377146 | 4.707659 | 0.929792 |
return self.set_canned_acl_helper(acl_str, key_name, headers,
query_args=DEF_OBJ_ACL) | def set_def_canned_acl(self, acl_str, key_name='', headers=None) | sets or changes a bucket's default object acl to a predefined
(canned) value | 5.49711 | 5.619385 | 0.978241 |
return self.set_xml_acl(acl_str, key_name, headers,
query_args=DEF_OBJ_ACL) | def set_def_xml_acl(self, acl_str, key_name='', headers=None) | sets or changes a bucket's default object | 6.039604 | 6.818204 | 0.885806 |
if permission not in GSPermissions:
raise self.connection.provider.storage_permissions_error(
'Unknown Permission: %s' % permission)
acl = self.get_acl(headers=headers)
acl.add_user_grant(permission, user_id)
self.set_acl(acl, headers=headers)
... | def add_user_grant(self, permission, user_id, recursive=False, headers=None) | Convenience method that provides a quick way to add a canonical user grant to a bucket.
This method retrieves the current ACL, creates a new grant based on the parameters
passed in, adds that grant to the ACL and then PUTs the new ACL back to GS.
:type permission: string
:param ... | 3.483739 | 3.393409 | 1.026619 |
ec2 = self.get_ec2_connection()
rs = ec2.get_all_snapshots()
all_vols = [self.volume_id] + self.past_volume_ids
snaps = []
for snapshot in rs:
if snapshot.volume_id in all_vols:
if snapshot.progress == '100%':
snapshot.date... | def get_snapshots(self) | Returns a list of all completed snapshots for this volume ID. | 3.108661 | 2.934814 | 1.059236 |
snaps = self.get_snapshots()
# Always keep the oldest and the newest
if len(snaps) <= 2:
return snaps
snaps = snaps[1:-1]
now = datetime.datetime.now(snaps[0].date.tzinfo)
midnight = datetime.datetime(year=now.year, month=now.month,
... | def trim_snapshots(self, delete=False) | Trim the number of snapshots for this volume. This method always
keeps the oldest snapshot. It then uses the parameters passed in
to determine how many others should be kept.
The algorithm is to keep all snapshots from the current day. Then
it will keep the first snapshot of the day ... | 2.699227 | 2.55418 | 1.056788 |
headers = {}
token = self.encode_token(token)
if self.config["header"]:
headers[self.config["header"]] = token
if self.config["cookie"]:
headers["Set-Cookie"] = dump_cookie(
self.config["cookie"], token, httponly=True,
max_... | def generate_headers(self, token) | Generate auth headers | 3.423964 | 3.199787 | 1.07006 |
if not token:
return None
now = datetime.utcnow()
time_to_live = self.config["expiration"]
if "exp" not in token:
return now + timedelta(seconds=time_to_live)
elif self.config["refresh"]:
exp = datetime.utcfromtimestamp(token["exp"])
... | def calculate_expiration(self, token) | Calculate token expiration
return expiration if the token need to set expiration or refresh,
otherwise return None.
Args:
token (dict): a decoded token | 3.350526 | 3.21826 | 1.041099 |
key = current_app.secret_key
if key is None:
if current_app.debug:
current_app.logger.debug("app.secret_key not set")
return None
try:
return jwt.decode(
token, key,
algorithms=[self.config["algorithm"]]... | def decode_token(self, token) | Decode Authorization token, return None if token invalid | 3.017147 | 2.928143 | 1.030396 |
key = current_app.secret_key
if key is None:
raise RuntimeError(
"please set app.secret_key before generate token")
return jwt.encode(token, key, algorithm=self.config["algorithm"]) | def encode_token(self, token) | Encode Authorization token, return bytes token | 4.606834 | 4.543157 | 1.014016 |
if 'AWS_CREDENTIAL_FILE' in os.environ:
path = os.environ['AWS_CREDENTIAL_FILE']
path = os.path.expanduser(path)
path = os.path.expandvars(path)
if os.path.isfile(path):
fp = open(path)
lines = fp.readlines()
... | def check_for_credential_file(self) | Checks for the existance of an AWS credential file.
If the environment variable AWS_CREDENTIAL_FILE is
set and points to a file, that file will be read and
will be searched credentials.
Note that if credentials have been explicitelypassed
into the class constructor, those values ... | 1.786251 | 1.704863 | 1.047739 |
url = self.args.get('url', None)
if url:
del self.args['url']
if not url and self.EnvURL in os.environ:
url = os.environ[self.EnvURL]
if url:
rslt = urlparse.urlparse(url)
if 'is_secure' not in self.args:
if rslt.sc... | def check_for_env_url(self) | First checks to see if a url argument was explicitly passed
in. If so, that will be used. If not, it checks for the
existence of the environment variable specified in ENV_URL.
If this is set, it should contain a fully qualified URL to the
service you want to use.
Note that any ... | 2.04554 | 1.921564 | 1.064518 |
"instance of :class:`eulfedora.api.ResourceIndex`, with the same root url and credentials"
if self._risearch is None:
self._risearch = ResourceIndex(self.fedora_root, self.username, self.password)
return self._risearch | def risearch(self) | instance of :class:`eulfedora.api.ResourceIndex`, with the same root url and credentials | 5.726108 | 2.452357 | 2.33494 |
# this method should no longer be needed - default pid logic moved to DigitalObject
warnings.warn(,
DeprecationWarning)
kwargs = {}
if namespace:
kwargs['namespace'] = namespace
elif self.default_pidspace:
kwargs['namespace']... | def get_next_pid(self, namespace=None, count=None) | Request next available pid or pids from Fedora, optionally in a specified
namespace. Calls :meth:`ApiFacade.getNextPID`.
.. deprecated :: 0.14
Mint pids for new objects with
:func:`eulfedora.models.DigitalObject.get_default_pid`
instead, or call :meth:`ApiFacade.getNextPI... | 5.548142 | 4.443454 | 1.24861 |
kwargs = {'text': text}
if log_message:
kwargs['logMessage'] = log_message
response = self.api.ingest(**kwargs)
return response.content | def ingest(self, text, log_message=None) | Ingest a new object into Fedora. Returns the pid of the new object on
success. Calls :meth:`ApiFacade.ingest`.
:param text: full text content of the object to be ingested
:param log_message: optional log message
:rtype: string | 3.657353 | 3.924757 | 0.931867 |
kwargs = {'pid': pid}
if log_message:
kwargs['logMessage'] = log_message
response = self.api.purgeObject(**kwargs)
return response.status_code == requests.codes.ok | def purge_object(self, pid, log_message=None) | Purge an object from Fedora. Calls :meth:`ApiFacade.purgeObject`.
:param pid: pid of the object to be purged
:param log_message: optional log message
:rtype: boolean | 3.199887 | 3.017217 | 1.060542 |
uris = self.risearch.get_subjects(modelns.hasModel, cmodel_uri)
return [self.get_object(uri, type) for uri in uris] | def get_objects_with_cmodel(self, cmodel_uri, type=None) | Find objects in Fedora with the specified content model.
:param cmodel_uri: content model URI (should be full URI in info:fedora/pid:### format)
:param type: type of object to return (e.g., class:`DigitalObject`)
:rtype: list of objects | 6.208541 | 7.15466 | 0.867762 |
objtype = type or self.default_object_type
if pid is None:
if create is None:
create = True
else:
if create is None:
create = False
return objtype(self.api, pid, create,
default_pidspace=self.defaul... | def get_object(self, pid=None, type=None, create=None) | Initialize a single object from Fedora, or create a new one, with the
same Fedora configuration and credentials.
:param pid: pid of the object to request, or a function that can be
called to get one. if not specified, :meth:`get_next_pid`
will be called if a pid ... | 4.066242 | 4.532972 | 0.897037 |
obj = DigitalObject(api, pid, create, default_pidspace)
if create:
return obj
if not obj.exists:
return obj
match_type = self.best_subtype_for_object(obj)
return match_type(api, pid) | def infer_object_subtype(self, api, pid=None, create=False, default_pidspace=None) | Construct a DigitalObject or appropriate subclass, inferring the
appropriate subtype using :meth:`best_subtype_for_object`. Note that
this method signature has been selected to match the
:class:`~eulfedora.models.DigitalObject` constructor so that this
method might be passed directly to ... | 5.479901 | 4.860327 | 1.127476 |
if content_models is None:
obj_models = set(str(m) for m in obj.get_models())
else:
obj_models = content_models
# go through registered DigitalObject subtypes looking for what type
# this object might be. use the first longest match: that is, look
... | def best_subtype_for_object(self, obj, content_models=None) | Given a :class:`~eulfedora.models.DigitalObject`, examine the
object to select the most appropriate subclass to instantiate. This
generic implementation examines the object's content models and
compares them against the defined subclasses of
:class:`~eulfedora.models.DigitalObject` to pi... | 4.936162 | 4.907205 | 1.005901 |
type = type or self.default_object_type
find_opts = {'chunksize' : chunksize}
search_operators = {
'exact': '=',
'gt': '>',
'gte': '>=',
'lt': '<',
'lte': '<=',
'contains': '~'
}
if terms is not ... | def find_objects(self, terms=None, type=None, chunksize=None, **kwargs) | Find objects in Fedora. Find query should be generated via keyword
args, based on the fields in Fedora documentation. By default, the
query uses a contains (~) search for all search terms. Calls
:meth:`ApiFacade.findObjects`. Results seem to return consistently
in ascending PID order.... | 3.073253 | 2.956755 | 1.039401 |
if not self._sync and not hasattr(self, '_buffer'):
self._buffer = {}
if not os.path.exists(self.cache_dir):
os.makedirs(self.cache_dir) | def create(self) | Create the write buffer and cache directory. | 4.470454 | 3.13166 | 1.427503 |
if not self._sync:
del self._buffer
shutil.rmtree(self.cache_dir) | def delete(self) | Delete the write buffer and cache directory. | 13.754566 | 7.304618 | 1.882996 |
self.sync()
self.sync = self.create = self.delete = self._closed
self._write_to_file = self._read_to_file = self._closed
self._key_to_filename = self._filename_to_key = self._closed
self.__getitem__ = self.__setitem__ = self.__delitem__ = self._closed
self.__iter... | def close(self) | Sync the write buffer, then close the cache.
If a closed :class:`FileCache` object's methods are called, a
:exc:`ValueError` will be raised. | 4.018593 | 3.702599 | 1.085344 |
if self._sync:
return # opened in sync mode, so skip the manual sync
self._sync = True
for ekey in self._buffer:
filename = self._key_to_filename(ekey)
self._write_to_file(filename, self._buffer[ekey])
self._buffer.clear()
self._sync ... | def sync(self) | Sync the write buffer with the cache files and clear the buffer.
If the :class:`FileCache` object was opened with the optional ``'s'``
*flag* argument, then calling :meth:`sync` will do nothing. | 4.945642 | 4.632648 | 1.067563 |
if isinstance(key, str) or isinstance(key, unicode):
key = key.encode(self._keyencoding)
elif not isinstance(key, bytes):
raise TypeError("key must be bytes or str")
return codecs.encode(key, 'hex_codec').decode(self._keyencoding) | def _encode_key(self, key) | Encode key using *hex_codec* for constructing a cache filename.
Keys are implicitly converted to :class:`bytes` if passed as
:class:`str`. | 2.781613 | 2.860726 | 0.972345 |
bkey = codecs.decode(key.encode(self._keyencoding), 'hex_codec')
return bkey.decode(self._keyencoding) if self._serialize else bkey | def _decode_key(self, key) | Decode key using hex_codec to retrieve the original key.
Keys are returned as :class:`str` if serialization is enabled.
Keys are returned as :class:`bytes` if serialization is disabled. | 5.97657 | 4.333398 | 1.379188 |
try:
return [os.path.join(self.cache_dir, filename) for filename in
os.listdir(self.cache_dir)]
except (FileNotFoundError, OSError):
return [] | def _all_filenames(self) | Return a list of absolute cache filenames | 2.958151 | 2.348053 | 1.259832 |
file_keys = [self._filename_to_key(fn) for fn in self._all_filenames()]
if self._sync:
return set(file_keys)
else:
return set(file_keys + list(self._buffer)) | def _all_keys(self) | Return a list of all encoded key names. | 4.678326 | 4.657878 | 1.00439 |
fh, tmp = tempfile.mkstemp()
with os.fdopen(fh, self._flag) as f:
f.write(self._dumps(bytesvalue))
rename(tmp, filename)
os.chmod(filename, self._mode) | def _write_to_file(self, filename, bytesvalue) | Write bytesvalue to filename. | 3.973968 | 3.82732 | 1.038316 |
try:
with open(filename, 'rb') as f:
return self._loads(f.read())
except (IOError, OSError):
logger.warning('Error opening file: {}'.format(filename))
return None | def _read_from_file(self, filename) | Read data from filename. | 3.104888 | 3.046502 | 1.019165 |
if query is not None and terms is not None:
raise Exception("Cannot findObject with both query ('%s') and terms ('%s')" % (query, terms))
http_args = {'resultFormat': 'xml'}
if query is not None:
http_args['query'] = query
if terms is not None:
... | def findObjects(self, query=None, terms=None, pid=True, chunksize=None, session_token=None) | Wrapper function for `Fedora REST API findObjects <http://fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-findObjects>`_
and `Fedora REST API resumeFindObjects <http://fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-resumeFindObjects>`_
One and only one of query or terms must ... | 2.275458 | 2.424651 | 0.938469 |
# /objects/{pid}/datastreams/{dsID}/content ? [asOfDateTime] [download]
http_args = {}
if rqst_headers is None:
rqst_headers = {}
if asOfDateTime:
http_args['asOfDateTime'] = datetime_to_fedoratime(asOfDateTime)
url = 'objects/%(pid)s/datastreams/... | def getDatastreamDissemination(self, pid, dsID, asOfDateTime=None, stream=False,
head=False, rqst_headers=None) | Get a single datastream on a Fedora object; optionally, get the version
as of a particular date time.
:param pid: object pid
:param dsID: datastream id
:param asOfDateTime: optional datetime; ``must`` be a non-naive datetime
so it can be converted to a date-time format Fedor... | 2.929627 | 2.907352 | 1.007662 |
'''Get a service dissemination.
.. NOTE:
This method not available in REST API until Fedora 3.3
:param pid: object pid
:param sDefPid: service definition pid
:param method: service method name
:param method_params: method parameters
:rtype: :class:`... | def getDissemination(self, pid, sdefPid, method, method_params=None) | Get a service dissemination.
.. NOTE:
This method not available in REST API until Fedora 3.3
:param pid: object pid
:param sDefPid: service definition pid
:param method: service method name
:param method_params: method parameters
:rtype: :class:`requests.mo... | 3.468409 | 1.957643 | 1.771727 |
# /objects/{pid} ? [format] [asOfDateTime]
http_args = {}
if asOfDateTime:
http_args['asOfDateTime'] = datetime_to_fedoratime(asOfDateTime)
http_args.update(self.format_xml)
url = 'objects/%(pid)s' % {'pid': pid}
return self.get(url, params=http_args) | def getObjectProfile(self, pid, asOfDateTime=None) | Get top-level information aboug a single Fedora object; optionally,
retrieve information as of a particular date-time.
:param pid: object pid
:param asOfDateTime: optional datetime; ``must`` be a non-naive datetime
so it can be converted to a date-time format Fedora can understand
... | 4.399087 | 4.196497 | 1.048276 |
'''List available service methods.
:param pid: object pid
:param sDefPid: service definition pid
:rtype: :class:`requests.models.Response`
'''
# /objects/{pid}/methods ? [format, datetime]
# /objects/{pid}/methods/{sdefpid} ? [format, datetime]
## NOTE: ... | def listMethods(self, pid, sdefpid=None) | List available service methods.
:param pid: object pid
:param sDefPid: service definition pid
:rtype: :class:`requests.models.Response` | 5.962694 | 4.439312 | 1.343157 |
http_args = {'subject': subject, 'predicate': predicate,
'object': object, 'isLiteral': isLiteral}
if datatype is not None:
http_args['datatype'] = datatype
url = 'objects/%(pid)s/relationships/new' % {'pid': pid}
response = self.post(url, para... | def addRelationship(self, pid, subject, predicate, object, isLiteral=False,
datatype=None) | Wrapper function for `Fedora REST API addRelationship <https://wiki.duraspace.org/display/FEDORA34/REST+API#RESTAPI-addRelationship>`_
:param pid: persistent id for the object to add the new relationship to
:param subject: subject of the relationship; object or datastream URI
:param predicate: ... | 2.716446 | 2.639114 | 1.029302 |
def compareDatastreamChecksum(self, pid, dsID, asOfDateTime=None): # date time
'''Compare (validate) datastream checksum. This is a special case of
:meth:`getDatastream`, with validate checksum set to True. Fedora
will recalculate the checksum and compare it to the stored value.
Respons... | Compare (validate) datastream checksum. This is a special case of
:meth:`getDatastream`, with validate checksum set to True. Fedora
will recalculate the checksum and compare it to the stored value.
Response is the same content returned by :meth:`getDatastream`,
with validation result in... | null | null | null | |
'''Export an object to be migrated or archived.
:param pid: object pid
:param context: export context, one of: public, migrate, archive
(default: public)
:param format: export format (Fedora default is foxml 1.1)
:param encoding: encoding (Fedora default is UTF-8)
... | def export(self, pid, context=None, format=None, encoding=None,
stream=False) | Export an object to be migrated or archived.
:param pid: object pid
:param context: export context, one of: public, migrate, archive
(default: public)
:param format: export format (Fedora default is foxml 1.1)
:param encoding: encoding (Fedora default is UTF-8)
:para... | 3.832927 | 1.556934 | 2.461842 |
# /objects/{pid}/datastreams/{dsID} ? [asOfDateTime] [format] [validateChecksum]
http_args = {}
if validateChecksum:
# fedora only responds to lower-case validateChecksum option
http_args['validateChecksum'] = str(validateChecksum).lower()
if asOfDateTime... | def getDatastream(self, pid, dsID, asOfDateTime=None, validateChecksum=False) | Get information about a single datastream on a Fedora object; optionally,
get information for the version of the datastream as of a particular date time.
:param pid: object pid
:param dsID: datastream id
:param asOfDateTime: optional datetime; ``must`` be a non-naive datetime
... | 3.743791 | 3.622689 | 1.033429 |
'''Get history information for a datastream.
:param pid: object pid
:param dsid: datastream id
:param format: format
:rtype: :class:`requests.models.Response`
'''
http_args = {}
if format is not None:
http_args['format'] = format
# Fed... | def getDatastreamHistory(self, pid, dsid, format=None) | Get history information for a datastream.
:param pid: object pid
:param dsid: datastream id
:param format: format
:rtype: :class:`requests.models.Response` | 3.606614 | 3.036969 | 1.18757 |
http_args = {'format': 'xml'}
if numPIDs:
http_args['numPIDs'] = numPIDs
if namespace:
http_args['namespace'] = namespace
rel_url = 'objects/nextPID'
return self.post(rel_url, params=http_args) | def getNextPID(self, numPIDs=None, namespace=None) | Wrapper function for `Fedora REST API getNextPid <http://fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-getNextPID>`_
:param numPIDs: (optional) get the specified number of pids;
by default, returns 1
:param namespace: (optional) get the next pid in the specified
p... | 3.303418 | 3.261332 | 1.012905 |
'''Get information about relationships on an object.
Wrapper function for
`Fedora REST API getRelationships <https://wiki.duraspace.org/display/FEDORA34/REST+API#RESTAPI-getRelationships>`_
:param pid: object pid
:param subject: subject (optional)
:param predicate: pre... | def getRelationships(self, pid, subject=None, predicate=None, format=None) | Get information about relationships on an object.
Wrapper function for
`Fedora REST API getRelationships <https://wiki.duraspace.org/display/FEDORA34/REST+API#RESTAPI-getRelationships>`_
:param pid: object pid
:param subject: subject (optional)
:param predicate: predicate (opt... | 2.512701 | 1.489196 | 1.687287 |
# NOTE: ingest method supports additional options for
# label/format/namespace/ownerId, etc - but we generally set
# those in the foxml that is passed in
http_args = {}
if logMessage:
http_args['logMessage'] = logMessage
headers = {'Content-Type': '... | def ingest(self, text, logMessage=None) | Ingest a new object into Fedora. Returns the pid of the new object on success.
Return response should have a status of 201 Created on success, and
the content of the response will be the newly created pid.
Wrapper function for `Fedora REST API ingest <http://fedora-commons.org/confluence/displa... | 7.853246 | 7.399899 | 1.061264 |
'''Modify object properties. Returned response should have
a status of 200 on succuss.
:param pid: object pid
:param label: object label
:param ownerId: object owner
:param state: object state
:param logMessage: optional log message
:rtype: :class:`requ... | def modifyObject(self, pid, label, ownerId, state, logMessage=None) | Modify object properties. Returned response should have
a status of 200 on succuss.
:param pid: object pid
:param label: object label
:param ownerId: object owner
:param state: object state
:param logMessage: optional log message
:rtype: :class:`requests.models... | 3.082251 | 1.992806 | 1.546689 |
# /objects/{pid}/datastreams/{dsID} ? [startDT] [endDT] [logMessage] [force]
http_args = {}
if logMessage:
http_args['logMessage'] = logMessage
if startDT:
http_args['startDT'] = startDT
if endDT:
http_args['endDT'] = endDT
if ... | def purgeDatastream(self, pid, dsID, startDT=None, endDT=None, logMessage=None,
force=False) | Purge a datastream, or specific versions of a dastream, from
a Fedora object. On success, response content will include
a list of timestamps for the purged datastream versions; on failure,
response content may contain an error message.
:param pid: object pid
:param dsID: datast... | 2.080599 | 2.368226 | 0.878548 |
http_args = {}
if logMessage:
http_args['logMessage'] = logMessage
url = 'objects/%(pid)s' % {'pid': pid}
return self.delete(url, params=http_args) | def purgeObject(self, pid, logMessage=None) | Purge an object from Fedora.
Returned response shoudl have a status of 200 on success; response
content is a timestamp.
Wrapper function for
`REST API purgeObject <http://fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-purgeObject>`_
:param pid: pid of the object t... | 3.566082 | 4.131635 | 0.863116 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.