repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ph4r05/monero-serialize | monero_serialize/xmrrpc.py | Modeler.dump_variant | async def dump_variant(self, elem, elem_type=None, params=None, obj=None):
"""
Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
fvalue = None
... | python | async def dump_variant(self, elem, elem_type=None, params=None, obj=None):
"""
Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
fvalue = None
... | [
"async",
"def",
"dump_variant",
"(",
"self",
",",
"elem",
",",
"elem_type",
"=",
"None",
",",
"params",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"fvalue",
"=",
"None",
"if",
"isinstance",
"(",
"elem",
",",
"x",
".",
"VariantType",
")",
"or",
... | Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | [
"Dumps",
"variant",
"type",
"to",
"the",
"writer",
".",
"Supports",
"both",
"wrapped",
"and",
"raw",
"variant",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L1209-L1244 | train | Dumps a single variant to the writer. |
ph4r05/monero-serialize | monero_serialize/xmrrpc.py | Modeler.load_variant | async def load_variant(self, elem_type, params=None, elem=None, wrapped=None, obj=None):
"""
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:retu... | python | async def load_variant(self, elem_type, params=None, elem=None, wrapped=None, obj=None):
"""
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:retu... | [
"async",
"def",
"load_variant",
"(",
"self",
",",
"elem_type",
",",
"params",
"=",
"None",
",",
"elem",
"=",
"None",
",",
"wrapped",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"is_wrapped",
"=",
"elem_type",
".",
"WRAPS_VALUE",
"if",
"wrapped",
"i... | Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:return: | [
"Loads",
"variant",
"type",
"from",
"the",
"reader",
".",
"Supports",
"both",
"wrapped",
"and",
"raw",
"variant",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L1246-L1280 | train | Loads a single variant from the reader. |
ph4r05/monero-serialize | monero_serialize/xmrrpc.py | Modeler.message | async def message(self, msg, msg_type=None, obj=None):
"""
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return:
"""
elem_type = msg_type if msg_type is not None else msg.__class__
obj = collections.OrderedDict() if not x.has_elem(o... | python | async def message(self, msg, msg_type=None, obj=None):
"""
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return:
"""
elem_type = msg_type if msg_type is not None else msg.__class__
obj = collections.OrderedDict() if not x.has_elem(o... | [
"async",
"def",
"message",
"(",
"self",
",",
"msg",
",",
"msg_type",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"elem_type",
"=",
"msg_type",
"if",
"msg_type",
"is",
"not",
"None",
"else",
"msg",
".",
"__class__",
"obj",
"=",
"collections",
".",
... | Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return: | [
"Loads",
"/",
"dumps",
"message",
":",
"param",
"msg",
":",
":",
"param",
"msg_type",
":",
":",
"param",
"obj",
":",
":",
"return",
":"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L1282-L1301 | train | Load and dumps a message. |
ph4r05/monero-serialize | monero_serialize/xmrrpc.py | Modeler.field | async def field(self, elem=None, elem_type=None, params=None, obj=None):
"""
Archive field
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
fvalue = None
... | python | async def field(self, elem=None, elem_type=None, params=None, obj=None):
"""
Archive field
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
fvalue = None
... | [
"async",
"def",
"field",
"(",
"self",
",",
"elem",
"=",
"None",
",",
"elem_type",
"=",
"None",
",",
"params",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"elem_type",
"=",
"elem_type",
"if",
"elem_type",
"else",
"elem",
".",
"__class__",
"fvalue",
... | Archive field
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | [
"Archive",
"field",
":",
"param",
"elem",
":",
":",
"param",
"elem_type",
":",
":",
"param",
"params",
":",
":",
"param",
"obj",
":",
":",
"return",
":"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L1343-L1393 | train | Get the archive field. |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.is_valid_volsize | def is_valid_volsize(self,volsize):
"""
Convenience method that round input to valid ScaleIO Volume size (8GB increments)
:param volsize: Size in MB
:rtype int: Valid ScaleIO Volume size rounded to nearest 8GB increment above or equal to volsize
"""
if type(volsi... | python | def is_valid_volsize(self,volsize):
"""
Convenience method that round input to valid ScaleIO Volume size (8GB increments)
:param volsize: Size in MB
:rtype int: Valid ScaleIO Volume size rounded to nearest 8GB increment above or equal to volsize
"""
if type(volsi... | [
"def",
"is_valid_volsize",
"(",
"self",
",",
"volsize",
")",
":",
"if",
"type",
"(",
"volsize",
")",
"is",
"int",
":",
"size_temp",
"=",
"divmod",
"(",
"volsize",
",",
"8192",
")",
"if",
"size_temp",
"[",
"1",
"]",
">",
"0",
":",
"# If not on 8GB bound... | Convenience method that round input to valid ScaleIO Volume size (8GB increments)
:param volsize: Size in MB
:rtype int: Valid ScaleIO Volume size rounded to nearest 8GB increment above or equal to volsize | [
"Convenience",
"method",
"that",
"round",
"input",
"to",
"valid",
"ScaleIO",
"Volume",
"size",
"(",
"8GB",
"increments",
")",
":",
"param",
"volsize",
":",
"Size",
"in",
"MB",
":",
"rtype",
"int",
":",
"Valid",
"ScaleIO",
"Volume",
"size",
"rounded",
"to",... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L49-L61 | train | Checks if the given size is a valid ScaleIO Volume size. |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.delete_volume | def delete_volume(self, volObj, removeMode='ONLY_ME', **kwargs):
"""
removeMode = 'ONLY_ME' | 'INCLUDING_DESCENDANTS' | 'DESCENDANTS_ONLY' | 'WHOLE_VTREE'
Using kwargs it will be possible to tell delete_volume() to unmap all SDCs before delting. Not working yet
"""
if kwargs:
... | python | def delete_volume(self, volObj, removeMode='ONLY_ME', **kwargs):
"""
removeMode = 'ONLY_ME' | 'INCLUDING_DESCENDANTS' | 'DESCENDANTS_ONLY' | 'WHOLE_VTREE'
Using kwargs it will be possible to tell delete_volume() to unmap all SDCs before delting. Not working yet
"""
if kwargs:
... | [
"def",
"delete_volume",
"(",
"self",
",",
"volObj",
",",
"removeMode",
"=",
"'ONLY_ME'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"iteritems",
"(",
")",
":",
"if",
"key",
"==",
"'autoUnm... | removeMode = 'ONLY_ME' | 'INCLUDING_DESCENDANTS' | 'DESCENDANTS_ONLY' | 'WHOLE_VTREE'
Using kwargs it will be possible to tell delete_volume() to unmap all SDCs before delting. Not working yet | [
"removeMode",
"=",
"ONLY_ME",
"|",
"INCLUDING_DESCENDANTS",
"|",
"DESCENDANTS_ONLY",
"|",
"WHOLE_VTREE",
"Using",
"kwargs",
"it",
"will",
"be",
"possible",
"to",
"tell",
"delete_volume",
"()",
"to",
"unmap",
"all",
"SDCs",
"before",
"delting",
".",
"Not",
"worki... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L63-L92 | train | Delete a volume from the API. |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.map_volume_to_sdc | def map_volume_to_sdc(self, volumeObj, sdcObj=None, allowMultipleMappings=False, **kwargs):
"""
Map a Volume to SDC
:param volumeObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param allowMultipleMappings: True to allow more than one SDC to be mapped to volume
... | python | def map_volume_to_sdc(self, volumeObj, sdcObj=None, allowMultipleMappings=False, **kwargs):
"""
Map a Volume to SDC
:param volumeObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param allowMultipleMappings: True to allow more than one SDC to be mapped to volume
... | [
"def",
"map_volume_to_sdc",
"(",
"self",
",",
"volumeObj",
",",
"sdcObj",
"=",
"None",
",",
"allowMultipleMappings",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"if",
"kwargs",
"... | Map a Volume to SDC
:param volumeObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param allowMultipleMappings: True to allow more than one SDC to be mapped to volume
:return: POST request response
:rtype: Requests POST response object | [
"Map",
"a",
"Volume",
"to",
"SDC",
":",
"param",
"volumeObj",
":",
"ScaleIO",
"Volume",
"object",
":",
"param",
"sdcObj",
":",
"ScaleIO",
"SDC",
"object",
":",
"param",
"allowMultipleMappings",
":",
"True",
"to",
"allow",
"more",
"than",
"one",
"SDC",
"to"... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L95-L113 | train | Map a Volume to a ScaleIO SDC |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.unmap_volume_from_sdc | def unmap_volume_from_sdc(self, volObj, sdcObj=None, **kwargs):
"""
Unmap a Volume from SDC or all SDCs
:param volObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param \**kwargs:
:Keyword Arguments:
*disableMapAllSdcs* (``bool``) -- True to disable a... | python | def unmap_volume_from_sdc(self, volObj, sdcObj=None, **kwargs):
"""
Unmap a Volume from SDC or all SDCs
:param volObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param \**kwargs:
:Keyword Arguments:
*disableMapAllSdcs* (``bool``) -- True to disable a... | [
"def",
"unmap_volume_from_sdc",
"(",
"self",
",",
"volObj",
",",
"sdcObj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO:",
"# Check if object parameters are the correct ones, otherwise throw error",
"# ADD logic for ALL SDC UNMAP",
"# For all SDC unmapVolumeFromDict ... | Unmap a Volume from SDC or all SDCs
:param volObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param \**kwargs:
:Keyword Arguments:
*disableMapAllSdcs* (``bool``) -- True to disable all SDCs mapping
:return: POST request response
:rtype: Requests POST... | [
"Unmap",
"a",
"Volume",
"from",
"SDC",
"or",
"all",
"SDCs",
":",
"param",
"volObj",
":",
"ScaleIO",
"Volume",
"object",
":",
"param",
"sdcObj",
":",
"ScaleIO",
"SDC",
"object",
":",
"param",
"\\",
"**",
"kwargs",
":",
":",
"Keyword",
"Arguments",
":",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L120-L148 | train | Unmap a Volume from a ScaleIO SDC or all SDCs |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.get_volumes_for_sdc | def get_volumes_for_sdc(self, sdcObj):
"""
:param sdcObj: SDC object
:return: list of Volumes attached to SDC
:rtyoe: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = self.conn.connection._do_get("{}/{}{}/{}".format... | python | def get_volumes_for_sdc(self, sdcObj):
"""
:param sdcObj: SDC object
:return: list of Volumes attached to SDC
:rtyoe: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = self.conn.connection._do_get("{}/{}{}/{}".format... | [
"def",
"get_volumes_for_sdc",
"(",
"self",
",",
"sdcObj",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"all_volumes",
"=",
"[",
"]",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_get",
"(",
"\"{}/{... | :param sdcObj: SDC object
:return: list of Volumes attached to SDC
:rtyoe: ScaleIO Volume object | [
":",
"param",
"sdcObj",
":",
"SDC",
"object",
":",
"return",
":",
"list",
"of",
"Volumes",
"attached",
"to",
"SDC",
":",
"rtyoe",
":",
"ScaleIO",
"Volume",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L151-L164 | train | get_volumes_for_sdc - Returns a list of Volumes attached to the SDC object |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.get_volume_by_id | def get_volume_by_id(self, id):
"""
Get ScaleIO Volume object by its ID
:param name: ID of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified ID found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... | python | def get_volume_by_id(self, id):
"""
Get ScaleIO Volume object by its ID
:param name: ID of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified ID found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... | [
"def",
"get_volume_by_id",
"(",
"self",
",",
"id",
")",
":",
"for",
"vol",
"in",
"self",
".",
"conn",
".",
"volumes",
":",
"if",
"vol",
".",
"id",
"==",
"id",
":",
"return",
"vol",
"raise",
"KeyError",
"(",
"\"Volume with ID \"",
"+",
"id",
"+",
"\" ... | Get ScaleIO Volume object by its ID
:param name: ID of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified ID found
:rtype: ScaleIO Volume object | [
"Get",
"ScaleIO",
"Volume",
"object",
"by",
"its",
"ID",
":",
"param",
"name",
":",
"ID",
"of",
"volume",
":",
"return",
":",
"ScaleIO",
"Volume",
"object",
":",
"raise",
"KeyError",
":",
"No",
"Volume",
"with",
"specified",
"ID",
"found",
":",
"rtype",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L166-L177 | train | Get ScaleIO Volume object by its ID |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.get_volumes_for_vtree | def get_volumes_for_vtree(self, vtreeObj):
"""
:param vtreeObj: VTree object
Protection Domain Object
:return: list of Volumes attached to VTree
:rtype: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = s... | python | def get_volumes_for_vtree(self, vtreeObj):
"""
:param vtreeObj: VTree object
Protection Domain Object
:return: list of Volumes attached to VTree
:rtype: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = s... | [
"def",
"get_volumes_for_vtree",
"(",
"self",
",",
"vtreeObj",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"all_volumes",
"=",
"[",
"]",
"response",
"=",
"self",
".",
"_do_get",
"(",
"\"{}/{}{}/{}\"",
".",
"format",
"(",... | :param vtreeObj: VTree object
Protection Domain Object
:return: list of Volumes attached to VTree
:rtype: ScaleIO Volume object | [
":",
"param",
"vtreeObj",
":",
"VTree",
"object",
"Protection",
"Domain",
"Object",
":",
"return",
":",
"list",
"of",
"Volumes",
"attached",
"to",
"VTree",
":",
"rtype",
":",
"ScaleIO",
"Volume",
"object"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L179-L193 | train | Returns a list of ScaleIO Volume objects attached to a VTree. |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.get_volume_by_name | def get_volume_by_name(self, name):
"""
Get ScaleIO Volume object by its Name
:param name: Name of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified name found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... | python | def get_volume_by_name(self, name):
"""
Get ScaleIO Volume object by its Name
:param name: Name of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified name found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... | [
"def",
"get_volume_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"vol",
"in",
"self",
".",
"conn",
".",
"volumes",
":",
"if",
"vol",
".",
"name",
"==",
"name",
":",
"return",
"vol",
"raise",
"KeyError",
"(",
"\"Volume with NAME \"",
"+",
"name",
... | Get ScaleIO Volume object by its Name
:param name: Name of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified name found
:rtype: ScaleIO Volume object | [
"Get",
"ScaleIO",
"Volume",
"object",
"by",
"its",
"Name",
":",
"param",
"name",
":",
"Name",
"of",
"volume",
":",
"return",
":",
"ScaleIO",
"Volume",
"object",
":",
"raise",
"KeyError",
":",
"No",
"Volume",
"with",
"specified",
"name",
"found",
":",
"rt... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L195-L206 | train | Get ScaleIO Volume object by its Name |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.resize_volume | def resize_volume(self, volumeObj, sizeInGb, bsize=1000):
"""
Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request r... | python | def resize_volume(self, volumeObj, sizeInGb, bsize=1000):
"""
Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request r... | [
"def",
"resize_volume",
"(",
"self",
",",
"volumeObj",
",",
"sizeInGb",
",",
"bsize",
"=",
"1000",
")",
":",
"current_vol",
"=",
"self",
".",
"get_volume_by_id",
"(",
"volumeObj",
".",
"id",
")",
"if",
"current_vol",
".",
"size_kb",
">",
"(",
"sizeInGb",
... | Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request response
:rtype: Requests POST response object | [
"Resize",
"a",
"volume",
"to",
"new",
"GB",
"size",
"must",
"be",
"larger",
"than",
"original",
".",
":",
"param",
"volumeObj",
":",
"ScaleIO",
"Volume",
"Object",
":",
"param",
"sizeInGb",
":",
"New",
"size",
"in",
"GB",
"(",
"have",
"to",
"be",
"larg... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L209-L226 | train | This method resizes a ScaleIO Volume object to new size in GB. |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.create_snapshot | def create_snapshot(self, systemId, snapshotSpecificationObject):
"""
Create snapshot for list of volumes
:param systemID: Cluster ID
:param snapshotSpecificationObject: Of class SnapshotSpecification
:rtype: SnapshotGroupId
"""
self.conn.connection._check_login(... | python | def create_snapshot(self, systemId, snapshotSpecificationObject):
"""
Create snapshot for list of volumes
:param systemID: Cluster ID
:param snapshotSpecificationObject: Of class SnapshotSpecification
:rtype: SnapshotGroupId
"""
self.conn.connection._check_login(... | [
"def",
"create_snapshot",
"(",
"self",
",",
"systemId",
",",
"snapshotSpecificationObject",
")",
":",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"#try:",
"response",
"=",
"self",
".",
"conn",
".",
"connection",
".",
"_do_post",
"(... | Create snapshot for list of volumes
:param systemID: Cluster ID
:param snapshotSpecificationObject: Of class SnapshotSpecification
:rtype: SnapshotGroupId | [
"Create",
"snapshot",
"for",
"list",
"of",
"volumes",
":",
"param",
"systemID",
":",
"Cluster",
"ID",
":",
"param",
"snapshotSpecificationObject",
":",
"Of",
"class",
"SnapshotSpecification",
":",
"rtype",
":",
"SnapshotGroupId"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L228-L240 | train | Create snapshot for list of volumes |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.delete_snapshot | def delete_snapshot(self, systemId, snapshotGroupId):
"""
:param systemId: ID of Cluster
:param snapshotGroupId: ID of snapshot group ID to be removed
/api/instances/System::{id}/action/removeConsistencyGroupSnapshots
type: POST
Required:
sna... | python | def delete_snapshot(self, systemId, snapshotGroupId):
"""
:param systemId: ID of Cluster
:param snapshotGroupId: ID of snapshot group ID to be removed
/api/instances/System::{id}/action/removeConsistencyGroupSnapshots
type: POST
Required:
sna... | [
"def",
"delete_snapshot",
"(",
"self",
",",
"systemId",
",",
"snapshotGroupId",
")",
":",
"#try:",
"consistencyGroupIdDict",
"=",
"{",
"'snapGroupId'",
":",
"snapshotGroupId",
"}",
"self",
".",
"conn",
".",
"connection",
".",
"_check_login",
"(",
")",
"response"... | :param systemId: ID of Cluster
:param snapshotGroupId: ID of snapshot group ID to be removed
/api/instances/System::{id}/action/removeConsistencyGroupSnapshots
type: POST
Required:
snapGroupId
Return:
numberOfVolumes - number of volumes t... | [
":",
"param",
"systemId",
":",
"ID",
"of",
"Cluster",
":",
"param",
"snapshotGroupId",
":",
"ID",
"of",
"snapshot",
"group",
"ID",
"to",
"be",
"removed",
"/",
"api",
"/",
"instances",
"/",
"System",
"::",
"{",
"id",
"}",
"/",
"action",
"/",
"removeCons... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L242-L262 | train | This method deletes a snapshot from a cluster |
swevm/scaleio-py | scaleiopy/api/scaleio/provisioning/volume.py | Volume.get_sdc_for_volume | def get_sdc_for_volume(self, volObj):
"""
Get list of SDC mapped to a specific volume
:param volObj: ScaleIO volume object
:return: List of ScaleIO SDC objects (empty list if no mapping exist)
:rtype: SDC object
"""
sdcList = []
if volObj.mapped_sdcs is no... | python | def get_sdc_for_volume(self, volObj):
"""
Get list of SDC mapped to a specific volume
:param volObj: ScaleIO volume object
:return: List of ScaleIO SDC objects (empty list if no mapping exist)
:rtype: SDC object
"""
sdcList = []
if volObj.mapped_sdcs is no... | [
"def",
"get_sdc_for_volume",
"(",
"self",
",",
"volObj",
")",
":",
"sdcList",
"=",
"[",
"]",
"if",
"volObj",
".",
"mapped_sdcs",
"is",
"not",
"None",
":",
"for",
"sdc",
"in",
"volObj",
".",
"mapped_sdcs",
":",
"sdcList",
".",
"append",
"(",
"sdc",
")",... | Get list of SDC mapped to a specific volume
:param volObj: ScaleIO volume object
:return: List of ScaleIO SDC objects (empty list if no mapping exist)
:rtype: SDC object | [
"Get",
"list",
"of",
"SDC",
"mapped",
"to",
"a",
"specific",
"volume",
":",
"param",
"volObj",
":",
"ScaleIO",
"volume",
"object",
":",
"return",
":",
"List",
"of",
"ScaleIO",
"SDC",
"objects",
"(",
"empty",
"list",
"if",
"no",
"mapping",
"exist",
")",
... | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L291-L307 | train | Get list of SDC objects mapped to a specific volume |
jenisys/parse_type | bin/make_localpi.py | make_index_for | def make_index_for(package, index_dir, verbose=True):
"""
Create an 'index.html' for one package.
:param package: Package object to use.
:param index_dir: Where 'index.html' should be created.
"""
index_template = """\
<html>
<head><title>{title}</title></head>
<body>
<h1>{title}</h1>
<ul>
{p... | python | def make_index_for(package, index_dir, verbose=True):
"""
Create an 'index.html' for one package.
:param package: Package object to use.
:param index_dir: Where 'index.html' should be created.
"""
index_template = """\
<html>
<head><title>{title}</title></head>
<body>
<h1>{title}</h1>
<ul>
{p... | [
"def",
"make_index_for",
"(",
"package",
",",
"index_dir",
",",
"verbose",
"=",
"True",
")",
":",
"index_template",
"=",
"\"\"\"\\\n<html>\n<head><title>{title}</title></head>\n<body>\n<h1>{title}</h1>\n<ul>\n{packages}\n</ul>\n</body>\n</html>\n\"\"\"",
"item_template",
"=",
"'<li... | Create an 'index.html' for one package.
:param package: Package object to use.
:param index_dir: Where 'index.html' should be created. | [
"Create",
"an",
"index",
".",
"html",
"for",
"one",
"package",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/make_localpi.py#L118-L170 | train | Create an index. html file for one package. |
jenisys/parse_type | bin/make_localpi.py | make_package_index | def make_package_index(download_dir):
"""
Create a pypi server like file structure below download directory.
:param download_dir: Download directory with packages.
EXAMPLE BEFORE:
+-- downloads/
+-- alice-1.0.zip
+-- alice-1.0.tar.gz
+-- bob-1.3.0.tar.gz
... | python | def make_package_index(download_dir):
"""
Create a pypi server like file structure below download directory.
:param download_dir: Download directory with packages.
EXAMPLE BEFORE:
+-- downloads/
+-- alice-1.0.zip
+-- alice-1.0.tar.gz
+-- bob-1.3.0.tar.gz
... | [
"def",
"make_package_index",
"(",
"download_dir",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"download_dir",
")",
":",
"raise",
"ValueError",
"(",
"\"No such directory: %r\"",
"%",
"download_dir",
")",
"pkg_rootdir",
"=",
"os",
".",
"path",
... | Create a pypi server like file structure below download directory.
:param download_dir: Download directory with packages.
EXAMPLE BEFORE:
+-- downloads/
+-- alice-1.0.zip
+-- alice-1.0.tar.gz
+-- bob-1.3.0.tar.gz
+-- bob-1.4.2.tar.gz
+-- charly-1... | [
"Create",
"a",
"pypi",
"server",
"like",
"file",
"structure",
"below",
"download",
"directory",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/make_localpi.py#L173-L233 | train | Create a pypi server like file structure below download directory. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser._convert_to_list | def _convert_to_list(self, value, delimiters):
"""
Return a list value translating from other types if necessary.
:param str value: The value to convert.
"""
if not value:
return []
if delimiters:
return [l.strip() for l in value.split(delimiters... | python | def _convert_to_list(self, value, delimiters):
"""
Return a list value translating from other types if necessary.
:param str value: The value to convert.
"""
if not value:
return []
if delimiters:
return [l.strip() for l in value.split(delimiters... | [
"def",
"_convert_to_list",
"(",
"self",
",",
"value",
",",
"delimiters",
")",
":",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"if",
"delimiters",
":",
"return",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"value",
".",
"split",
"(",
"de... | Return a list value translating from other types if necessary.
:param str value: The value to convert. | [
"Return",
"a",
"list",
"value",
"translating",
"from",
"other",
"types",
"if",
"necessary",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L30-L40 | train | Converts a value from other types if necessary. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.getlist | def getlist(self, section, option, raw=False, vars=None, fallback=[], delimiters=','):
"""
A convenience method which coerces the option in the specified section to a list of strings.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
return self._convert_to... | python | def getlist(self, section, option, raw=False, vars=None, fallback=[], delimiters=','):
"""
A convenience method which coerces the option in the specified section to a list of strings.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
return self._convert_to... | [
"def",
"getlist",
"(",
"self",
",",
"section",
",",
"option",
",",
"raw",
"=",
"False",
",",
"vars",
"=",
"None",
",",
"fallback",
"=",
"[",
"]",
",",
"delimiters",
"=",
"','",
")",
":",
"v",
"=",
"self",
".",
"get",
"(",
"section",
",",
"option"... | A convenience method which coerces the option in the specified section to a list of strings. | [
"A",
"convenience",
"method",
"which",
"coerces",
"the",
"option",
"in",
"the",
"specified",
"section",
"to",
"a",
"list",
"of",
"strings",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L50-L55 | train | A convenience method which coerces the option in the specified section to a list of strings. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.getfile | def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a file.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... | python | def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a file.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... | [
"def",
"getfile",
"(",
"self",
",",
"section",
",",
"option",
",",
"raw",
"=",
"False",
",",
"vars",
"=",
"None",
",",
"fallback",
"=",
"\"\"",
",",
"validate",
"=",
"False",
")",
":",
"v",
"=",
"self",
".",
"get",
"(",
"section",
",",
"option",
... | A convenience method which coerces the option in the specified section to a file. | [
"A",
"convenience",
"method",
"which",
"coerces",
"the",
"option",
"in",
"the",
"specified",
"section",
"to",
"a",
"file",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L57-L63 | train | A convenience method which coerces the option in the specified section to a file. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.getdir | def getdir(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a directory.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... | python | def getdir(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a directory.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... | [
"def",
"getdir",
"(",
"self",
",",
"section",
",",
"option",
",",
"raw",
"=",
"False",
",",
"vars",
"=",
"None",
",",
"fallback",
"=",
"\"\"",
",",
"validate",
"=",
"False",
")",
":",
"v",
"=",
"self",
".",
"get",
"(",
"section",
",",
"option",
"... | A convenience method which coerces the option in the specified section to a directory. | [
"A",
"convenience",
"method",
"which",
"coerces",
"the",
"option",
"in",
"the",
"specified",
"section",
"to",
"a",
"directory",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L65-L71 | train | A convenience method which coerces the option in the specified section to a directory. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.getdirs | def getdirs(self, section, option, raw=False, vars=None, fallback=[]):
"""
A convenience method which coerces the option in the specified section to a list of directories.
"""
globs = self.getlist(section, option, fallback=[])
return [f for g in globs for f in glob.glob(g) if os.... | python | def getdirs(self, section, option, raw=False, vars=None, fallback=[]):
"""
A convenience method which coerces the option in the specified section to a list of directories.
"""
globs = self.getlist(section, option, fallback=[])
return [f for g in globs for f in glob.glob(g) if os.... | [
"def",
"getdirs",
"(",
"self",
",",
"section",
",",
"option",
",",
"raw",
"=",
"False",
",",
"vars",
"=",
"None",
",",
"fallback",
"=",
"[",
"]",
")",
":",
"globs",
"=",
"self",
".",
"getlist",
"(",
"section",
",",
"option",
",",
"fallback",
"=",
... | A convenience method which coerces the option in the specified section to a list of directories. | [
"A",
"convenience",
"method",
"which",
"coerces",
"the",
"option",
"in",
"the",
"specified",
"section",
"to",
"a",
"list",
"of",
"directories",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L73-L78 | train | A convenience method which coerces the option in the specified section to a list of directories. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.set | def set(self, section, option, value=None):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
if isinstance(section, bytes):
section = section.decode('utf8')
if isinstance(option, bytes):
option =... | python | def set(self, section, option, value=None):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
if isinstance(section, bytes):
section = section.decode('utf8')
if isinstance(option, bytes):
option =... | [
"def",
"set",
"(",
"self",
",",
"section",
",",
"option",
",",
"value",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"section",
",",
"bytes",
")",
":",
"section",
"=",
"section",
".",
"decode",
"(",
"'utf8'",
")",
"if",
"isinstance",
"(",
"option"... | Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings. | [
"Extends",
":",
"meth",
":",
"~configparser",
".",
"ConfigParser",
".",
"set",
"by",
"auto",
"formatting",
"byte",
"strings",
"into",
"unicode",
"strings",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L80-L93 | train | Overrides ~configparser. ConfigParser. set by auto formatting byte strings into unicode strings. |
dbarsam/python-vsgen | vsgen/util/config.py | VSGConfigParser.update | def update(self, **kwargs):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
# Override the template values with the override values.
for s in config.sections():
for o in config.options(s):
ov... | python | def update(self, **kwargs):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
# Override the template values with the override values.
for s in config.sections():
for o in config.options(s):
ov... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Override the template values with the override values.",
"for",
"s",
"in",
"config",
".",
"sections",
"(",
")",
":",
"for",
"o",
"in",
"config",
".",
"options",
"(",
"s",
")",
":",
"overri... | Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings. | [
"Extends",
":",
"meth",
":",
"~configparser",
".",
"ConfigParser",
".",
"set",
"by",
"auto",
"formatting",
"byte",
"strings",
"into",
"unicode",
"strings",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L95-L104 | train | Updates the configuration with the values from the given kwargs. |
useblocks/groundwork | groundwork/patterns/gw_documents_pattern.py | DocumentsListPlugin.register | def register(self, name, content, description=None):
"""
Register a new document.
:param content: Content of this document. Jinja and rst are supported.
:type content: str
:param name: Unique name of the document for documentation purposes.
:param description: Short desc... | python | def register(self, name, content, description=None):
"""
Register a new document.
:param content: Content of this document. Jinja and rst are supported.
:type content: str
:param name: Unique name of the document for documentation purposes.
:param description: Short desc... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"content",
",",
"description",
"=",
"None",
")",
":",
"return",
"self",
".",
"__app",
".",
"documents",
".",
"register",
"(",
"name",
",",
"content",
",",
"self",
".",
"_plugin",
",",
"description",
")"... | Register a new document.
:param content: Content of this document. Jinja and rst are supported.
:type content: str
:param name: Unique name of the document for documentation purposes.
:param description: Short description of this document | [
"Register",
"a",
"new",
"document",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L66-L75 | train | Register a new document. |
useblocks/groundwork | groundwork/patterns/gw_documents_pattern.py | DocumentsListApplication.register | def register(self, name, content, plugin, description=None):
"""
Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param content: Conten... | python | def register(self, name, content, plugin, description=None):
"""
Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param content: Conten... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"content",
",",
"plugin",
",",
"description",
"=",
"None",
")",
":",
"if",
"name",
"in",
"self",
".",
"documents",
".",
"keys",
"(",
")",
":",
"raise",
"DocumentExistsException",
"(",
"\"Document %s was alr... | Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param content: Content of the document
:type content: str
:param name: Unique name of ... | [
"Registers",
"a",
"new",
"document",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L95-L114 | train | Registers a new document. |
useblocks/groundwork | groundwork/patterns/gw_documents_pattern.py | DocumentsListApplication.unregister | def unregister(self, document):
"""
Unregisters an existing document, so that this document is no longer available.
This function is mainly used during plugin deactivation.
:param document: Name of the document
"""
if document not in self.documents.keys():
s... | python | def unregister(self, document):
"""
Unregisters an existing document, so that this document is no longer available.
This function is mainly used during plugin deactivation.
:param document: Name of the document
"""
if document not in self.documents.keys():
s... | [
"def",
"unregister",
"(",
"self",
",",
"document",
")",
":",
"if",
"document",
"not",
"in",
"self",
".",
"documents",
".",
"keys",
"(",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Can not unregister document %s\"",
"%",
"document",
")",
"else",
... | Unregisters an existing document, so that this document is no longer available.
This function is mainly used during plugin deactivation.
:param document: Name of the document | [
"Unregisters",
"an",
"existing",
"document",
"so",
"that",
"this",
"document",
"is",
"no",
"longer",
"available",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L116-L128 | train | Unregisters an existing document so that it is no longer available. |
useblocks/groundwork | groundwork/patterns/gw_documents_pattern.py | DocumentsListApplication.get | def get(self, document=None, plugin=None):
"""
Get one or more documents.
:param document: Name of the document
:type document: str
:param plugin: Plugin object, under which the document was registered
:type plugin: GwBasePattern
"""
if plugin is not None... | python | def get(self, document=None, plugin=None):
"""
Get one or more documents.
:param document: Name of the document
:type document: str
:param plugin: Plugin object, under which the document was registered
:type plugin: GwBasePattern
"""
if plugin is not None... | [
"def",
"get",
"(",
"self",
",",
"document",
"=",
"None",
",",
"plugin",
"=",
"None",
")",
":",
"if",
"plugin",
"is",
"not",
"None",
":",
"if",
"document",
"is",
"None",
":",
"documents_list",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"documen... | Get one or more documents.
:param document: Name of the document
:type document: str
:param plugin: Plugin object, under which the document was registered
:type plugin: GwBasePattern | [
"Get",
"one",
"or",
"more",
"documents",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L130-L161 | train | Get one or more documents. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginManager.initialise_by_names | def initialise_by_names(self, plugins=None):
"""
Initialises given plugins, but does not activate them.
This is needed to import and configure libraries, which are imported by used patterns, like GwFlask.
After this action, all needed python modules are imported and configured.
... | python | def initialise_by_names(self, plugins=None):
"""
Initialises given plugins, but does not activate them.
This is needed to import and configure libraries, which are imported by used patterns, like GwFlask.
After this action, all needed python modules are imported and configured.
... | [
"def",
"initialise_by_names",
"(",
"self",
",",
"plugins",
"=",
"None",
")",
":",
"if",
"plugins",
"is",
"None",
":",
"plugins",
"=",
"[",
"]",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Plugins Initialisation started\"",
")",
"if",
"not",
"isinstance",
"(... | Initialises given plugins, but does not activate them.
This is needed to import and configure libraries, which are imported by used patterns, like GwFlask.
After this action, all needed python modules are imported and configured.
Also the groundwork application object is ready and contains fun... | [
"Initialises",
"given",
"plugins",
"but",
"does",
"not",
"activate",
"them",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L46-L79 | train | Initialises given plugins but does not activate them. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginManager.activate | def activate(self, plugins=[]):
"""
Activates given plugins.
This calls mainly plugin.activate() and plugins register needed resources like commands, signals or
documents.
If given plugins have not been initialised, this is also done via :func:`_load`.
:param plugins: ... | python | def activate(self, plugins=[]):
"""
Activates given plugins.
This calls mainly plugin.activate() and plugins register needed resources like commands, signals or
documents.
If given plugins have not been initialised, this is also done via :func:`_load`.
:param plugins: ... | [
"def",
"activate",
"(",
"self",
",",
"plugins",
"=",
"[",
"]",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Plugins Activation started\"",
")",
"if",
"not",
"isinstance",
"(",
"plugins",
",",
"list",
")",
":",
"raise",
"AttributeError",
"(",
"\"p... | Activates given plugins.
This calls mainly plugin.activate() and plugins register needed resources like commands, signals or
documents.
If given plugins have not been initialised, this is also done via :func:`_load`.
:param plugins: List of plugin names
:type plugins: list of ... | [
"Activates",
"given",
"plugins",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L129-L183 | train | Activates given plugins. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginManager.deactivate | def deactivate(self, plugins=[]):
"""
Deactivates given plugins.
A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired,
no deactivate functions are called.)
A deactivated plugin is still loaded and initialised and can be react... | python | def deactivate(self, plugins=[]):
"""
Deactivates given plugins.
A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired,
no deactivate functions are called.)
A deactivated plugin is still loaded and initialised and can be react... | [
"def",
"deactivate",
"(",
"self",
",",
"plugins",
"=",
"[",
"]",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Plugins Deactivation started\"",
")",
"if",
"not",
"isinstance",
"(",
"plugins",
",",
"list",
")",
":",
"raise",
"AttributeError",
"(",
... | Deactivates given plugins.
A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired,
no deactivate functions are called.)
A deactivated plugin is still loaded and initialised and can be reactivated by calling :func:`activate` again.
It i... | [
"Deactivates",
"given",
"plugins",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L185-L227 | train | Deactivates given plugins. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginManager.get | def get(self, name=None):
"""
Returns the plugin object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... | python | def get(self, name=None):
"""
Returns the plugin object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"_plugins",
"else",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_plugins",
".",
"keys",
"(",
")",
":",
"return",
"None",
"els... | Returns the plugin object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins | [
"Returns",
"the",
"plugin",
"object",
"with",
"the",
"given",
"name",
".",
"Or",
"if",
"a",
"name",
"is",
"not",
"given",
"the",
"complete",
"plugin",
"dictionary",
"is",
"returned",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L229-L243 | train | Returns the single or dictionary of plugins with the given name. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginManager.is_active | def is_active(self, name):
"""
Returns True if plugin exists and is active.
If plugin does not exist, it returns None
:param name: plugin name
:return: boolean or None
"""
if name in self._plugins.keys():
return self._plugins["name"].active
re... | python | def is_active(self, name):
"""
Returns True if plugin exists and is active.
If plugin does not exist, it returns None
:param name: plugin name
:return: boolean or None
"""
if name in self._plugins.keys():
return self._plugins["name"].active
re... | [
"def",
"is_active",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_plugins",
".",
"keys",
"(",
")",
":",
"return",
"self",
".",
"_plugins",
"[",
"\"name\"",
"]",
".",
"active",
"return",
"None"
] | Returns True if plugin exists and is active.
If plugin does not exist, it returns None
:param name: plugin name
:return: boolean or None | [
"Returns",
"True",
"if",
"plugin",
"exists",
"and",
"is",
"active",
".",
"If",
"plugin",
"does",
"not",
"exist",
"it",
"returns",
"None"
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L255-L265 | train | Returns True if plugin exists and is active. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginClassManager._get_plugins_by_entry_points | def _get_plugins_by_entry_points(self):
"""
Registers plugin classes, which are in sys.path and have an entry_point called 'groundwork.plugin'.
:return: dict of plugin classes
"""
# Let's find and register every plugin, which is in sys.path and has defined a entry_point 'groundwo... | python | def _get_plugins_by_entry_points(self):
"""
Registers plugin classes, which are in sys.path and have an entry_point called 'groundwork.plugin'.
:return: dict of plugin classes
"""
# Let's find and register every plugin, which is in sys.path and has defined a entry_point 'groundwo... | [
"def",
"_get_plugins_by_entry_points",
"(",
"self",
")",
":",
"# Let's find and register every plugin, which is in sys.path and has defined a entry_point 'groundwork.plugin'",
"# in it's setup.py",
"entry_points",
"=",
"[",
"]",
"classes",
"=",
"{",
"}",
"for",
"entry_point",
"in... | Registers plugin classes, which are in sys.path and have an entry_point called 'groundwork.plugin'.
:return: dict of plugin classes | [
"Registers",
"plugin",
"classes",
"which",
"are",
"in",
"sys",
".",
"path",
"and",
"have",
"an",
"entry_point",
"called",
"groundwork",
".",
"plugin",
".",
":",
"return",
":",
"dict",
"of",
"plugin",
"classes"
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L282-L329 | train | Get all the plugins from entry_points. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginClassManager.register | def register(self, classes=[]):
"""
Registers new plugins.
The registration only creates a new entry for a plugin inside the _classes dictionary.
It does not activate or even initialise the plugin.
A plugin must be a class, which inherits directly or indirectly from GwBasePatte... | python | def register(self, classes=[]):
"""
Registers new plugins.
The registration only creates a new entry for a plugin inside the _classes dictionary.
It does not activate or even initialise the plugin.
A plugin must be a class, which inherits directly or indirectly from GwBasePatte... | [
"def",
"register",
"(",
"self",
",",
"classes",
"=",
"[",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"classes",
",",
"list",
")",
":",
"raise",
"AttributeError",
"(",
"\"plugins must be a list, not %s.\"",
"%",
"type",
"(",
"classes",
")",
")",
"plugin... | Registers new plugins.
The registration only creates a new entry for a plugin inside the _classes dictionary.
It does not activate or even initialise the plugin.
A plugin must be a class, which inherits directly or indirectly from GwBasePattern.
:param classes: List of plugin classes
... | [
"Registers",
"new",
"plugins",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L331-L354 | train | Registers new plugins. |
useblocks/groundwork | groundwork/pluginmanager.py | PluginClassManager.get | def get(self, name=None):
"""
Returns the plugin class object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... | python | def get(self, name=None):
"""
Returns the plugin class object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"_classes",
"else",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_classes",
".",
"keys",
"(",
")",
":",
"return",
"None",
"els... | Returns the plugin class object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins | [
"Returns",
"the",
"plugin",
"class",
"object",
"with",
"the",
"given",
"name",
".",
"Or",
"if",
"a",
"name",
"is",
"not",
"given",
"the",
"complete",
"plugin",
"dictionary",
"is",
"returned",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L390-L404 | train | Returns the plugin class object with the given name or the complete plugin dictionary if no name is given. |
lexich/yandex-disk-webdav | yandexwebdav.py | _ | def _(path):
"""
Normalize path to unicode
:param path: path
:return: normalize path
>>> _(None)
u''
>>> _(u("test1"))
u'test1'
>>> _("test2")
u'test2'
"""
if path is None:
return u("")
if not PY3:
if type(path) == unicode:
return path
... | python | def _(path):
"""
Normalize path to unicode
:param path: path
:return: normalize path
>>> _(None)
u''
>>> _(u("test1"))
u'test1'
>>> _("test2")
u'test2'
"""
if path is None:
return u("")
if not PY3:
if type(path) == unicode:
return path
... | [
"def",
"_",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"u",
"(",
"\"\"",
")",
"if",
"not",
"PY3",
":",
"if",
"type",
"(",
"path",
")",
"==",
"unicode",
":",
"return",
"path",
"try",
":",
"return",
"_decode_utf8",
"(",
"path... | Normalize path to unicode
:param path: path
:return: normalize path
>>> _(None)
u''
>>> _(u("test1"))
u'test1'
>>> _("test2")
u'test2' | [
"Normalize",
"path",
"to",
"unicode",
":",
"param",
"path",
":",
"path",
":",
"return",
":",
"normalize",
"path"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L39-L61 | train | Normalize path to unicode
|
lexich/yandex-disk-webdav | yandexwebdav.py | remote | def remote(href):
"""
Normalize remote href
:param href: remote path
:return: normalize href
>>> remote("/test/hello.txt")
u'/test/hello.txt'
>>> remote("test/hello.txt")
u'/test/hello.txt'
>>> remote("test\hello.txt")
u'/test/hello.txt'
>>> remote(None)
u'/'
"""
... | python | def remote(href):
"""
Normalize remote href
:param href: remote path
:return: normalize href
>>> remote("/test/hello.txt")
u'/test/hello.txt'
>>> remote("test/hello.txt")
u'/test/hello.txt'
>>> remote("test\hello.txt")
u'/test/hello.txt'
>>> remote(None)
u'/'
"""
... | [
"def",
"remote",
"(",
"href",
")",
":",
"href",
"=",
"_",
"(",
"href",
")",
"href",
"=",
"os",
".",
"path",
".",
"join",
"(",
"u",
"(",
"\"/\"",
")",
",",
"href",
")",
"if",
"os",
".",
"sep",
"==",
"\"\\\\\"",
":",
"href",
"=",
"href",
".",
... | Normalize remote href
:param href: remote path
:return: normalize href
>>> remote("/test/hello.txt")
u'/test/hello.txt'
>>> remote("test/hello.txt")
u'/test/hello.txt'
>>> remote("test\hello.txt")
u'/test/hello.txt'
>>> remote(None)
u'/' | [
"Normalize",
"remote",
"href",
":",
"param",
"href",
":",
"remote",
"path",
":",
"return",
":",
"normalize",
"href"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L64-L83 | train | normalize remote href
|
lexich/yandex-disk-webdav | yandexwebdav.py | Config.getHeaders | def getHeaders(self):
"""
Get common headers
:return:
"""
basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip()
return {
"Depth": "1",
"Authorization": 'Basic ' + _decode_utf8(basicauth),
"Accept": "*/*"
} | python | def getHeaders(self):
"""
Get common headers
:return:
"""
basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip()
return {
"Depth": "1",
"Authorization": 'Basic ' + _decode_utf8(basicauth),
"Accept": "*/*"
} | [
"def",
"getHeaders",
"(",
"self",
")",
":",
"basicauth",
"=",
"base64",
".",
"encodestring",
"(",
"b",
"(",
"self",
".",
"user",
"+",
"':'",
"+",
"self",
".",
"password",
")",
")",
".",
"strip",
"(",
")",
"return",
"{",
"\"Depth\"",
":",
"\"1\"",
"... | Get common headers
:return: | [
"Get",
"common",
"headers",
":",
"return",
":"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L192-L202 | train | Get common headers for the current user and password |
lexich/yandex-disk-webdav | yandexwebdav.py | Config.list | def list(self, href):
"""
list of files and directories at remote server
:param href: remote folder
:return: list(folders, files) and list(None,None) if folder doesn't exist
"""
for iTry in range(TRYINGS):
logger.info(u("list(%s): %s") % (iTry, href))
... | python | def list(self, href):
"""
list of files and directories at remote server
:param href: remote folder
:return: list(folders, files) and list(None,None) if folder doesn't exist
"""
for iTry in range(TRYINGS):
logger.info(u("list(%s): %s") % (iTry, href))
... | [
"def",
"list",
"(",
"self",
",",
"href",
")",
":",
"for",
"iTry",
"in",
"range",
"(",
"TRYINGS",
")",
":",
"logger",
".",
"info",
"(",
"u",
"(",
"\"list(%s): %s\"",
")",
"%",
"(",
"iTry",
",",
"href",
")",
")",
"folders",
"=",
"None",
"files",
"=... | list of files and directories at remote server
:param href: remote folder
:return: list(folders, files) and list(None,None) if folder doesn't exist | [
"list",
"of",
"files",
"and",
"directories",
"at",
"remote",
"server",
":",
"param",
"href",
":",
"remote",
"folder",
":",
"return",
":",
"list",
"(",
"folders",
"files",
")",
"and",
"list",
"(",
"None",
"None",
")",
"if",
"folder",
"doesn",
"t",
"exis... | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L211-L254 | train | list of files and directories at remote server |
lexich/yandex-disk-webdav | yandexwebdav.py | Config.sync | def sync(self, localpath, href, exclude=None, block=True):
"""
Sync local and remote folders
:param localpath: local folder
:param href: remote folder
:param exclude: filter folder which need to exlude
:return: respose
"""
logger.info(u("sync: %s %s") % (l... | python | def sync(self, localpath, href, exclude=None, block=True):
"""
Sync local and remote folders
:param localpath: local folder
:param href: remote folder
:param exclude: filter folder which need to exlude
:return: respose
"""
logger.info(u("sync: %s %s") % (l... | [
"def",
"sync",
"(",
"self",
",",
"localpath",
",",
"href",
",",
"exclude",
"=",
"None",
",",
"block",
"=",
"True",
")",
":",
"logger",
".",
"info",
"(",
"u",
"(",
"\"sync: %s %s\"",
")",
"%",
"(",
"localpath",
",",
"href",
")",
")",
"try",
":",
"... | Sync local and remote folders
:param localpath: local folder
:param href: remote folder
:param exclude: filter folder which need to exlude
:return: respose | [
"Sync",
"local",
"and",
"remote",
"folders",
":",
"param",
"localpath",
":",
"local",
"folder",
":",
"param",
"href",
":",
"remote",
"folder",
":",
"param",
"exclude",
":",
"filter",
"folder",
"which",
"need",
"to",
"exlude",
":",
"return",
":",
"respose"
... | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L256-L314 | train | Sync local and remote folders |
lexich/yandex-disk-webdav | yandexwebdav.py | Config.mkdir | def mkdir(self, href):
"""
create remote folder
:param href: remote path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("mkdir(%s): %s") % (iTry, href))
try:
href = remote(href)
con = self.getConnect... | python | def mkdir(self, href):
"""
create remote folder
:param href: remote path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("mkdir(%s): %s") % (iTry, href))
try:
href = remote(href)
con = self.getConnect... | [
"def",
"mkdir",
"(",
"self",
",",
"href",
")",
":",
"for",
"iTry",
"in",
"range",
"(",
"TRYINGS",
")",
":",
"logger",
".",
"info",
"(",
"u",
"(",
"\"mkdir(%s): %s\"",
")",
"%",
"(",
"iTry",
",",
"href",
")",
")",
"try",
":",
"href",
"=",
"remote"... | create remote folder
:param href: remote path
:return: response | [
"create",
"remote",
"folder",
":",
"param",
"href",
":",
"remote",
"path",
":",
"return",
":",
"response"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L316-L335 | train | create remote folder
|
lexich/yandex-disk-webdav | yandexwebdav.py | Config.downloadTo | def downloadTo(self, href, localpath):
"""
Download file to localstorage
:param href: remote path
:param localpath: local path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("downloadTo(%s): %s %s") % (iTry, href, localpath))
... | python | def downloadTo(self, href, localpath):
"""
Download file to localstorage
:param href: remote path
:param localpath: local path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("downloadTo(%s): %s %s") % (iTry, href, localpath))
... | [
"def",
"downloadTo",
"(",
"self",
",",
"href",
",",
"localpath",
")",
":",
"for",
"iTry",
"in",
"range",
"(",
"TRYINGS",
")",
":",
"logger",
".",
"info",
"(",
"u",
"(",
"\"downloadTo(%s): %s %s\"",
")",
"%",
"(",
"iTry",
",",
"href",
",",
"localpath",
... | Download file to localstorage
:param href: remote path
:param localpath: local path
:return: response | [
"Download",
"file",
"to",
"localstorage",
":",
"param",
"href",
":",
"remote",
"path",
":",
"param",
"localpath",
":",
"local",
"path",
":",
"return",
":",
"response"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L362-L398 | train | Download file to localstorage |
lexich/yandex-disk-webdav | yandexwebdav.py | Config.upload | def upload(self, localpath, href):
"""
Upload file from localpath to remote server
:param localpath: local path
:param href: remote path
:return: response
"""
localpath = _(localpath)
href = remote(href)
if not os.path.exists(localpath):
... | python | def upload(self, localpath, href):
"""
Upload file from localpath to remote server
:param localpath: local path
:param href: remote path
:return: response
"""
localpath = _(localpath)
href = remote(href)
if not os.path.exists(localpath):
... | [
"def",
"upload",
"(",
"self",
",",
"localpath",
",",
"href",
")",
":",
"localpath",
"=",
"_",
"(",
"localpath",
")",
"href",
"=",
"remote",
"(",
"href",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"localpath",
")",
":",
"logger",
".",
... | Upload file from localpath to remote server
:param localpath: local path
:param href: remote path
:return: response | [
"Upload",
"file",
"from",
"localpath",
"to",
"remote",
"server",
":",
"param",
"localpath",
":",
"local",
"path",
":",
"param",
"href",
":",
"remote",
"path",
":",
"return",
":",
"response"
] | 669f51f999ed14e137454b90e7d035e2ca171c75 | https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L447-L477 | train | Uploads a file from localpath to remote server and returns the ID of the file that was uploaded. |
dbarsam/python-vsgen | vsgen/solution.py | VSGSolution._import | def _import(self, datadict):
"""
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values.
"""
self.GUID = datadict.get("GUID", uuid.uuid1())
self.FileName = datadict.get("FileName", "")
... | python | def _import(self, datadict):
"""
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values.
"""
self.GUID = datadict.get("GUID", uuid.uuid1())
self.FileName = datadict.get("FileName", "")
... | [
"def",
"_import",
"(",
"self",
",",
"datadict",
")",
":",
"self",
".",
"GUID",
"=",
"datadict",
".",
"get",
"(",
"\"GUID\"",
",",
"uuid",
".",
"uuid1",
"(",
")",
")",
"self",
".",
"FileName",
"=",
"datadict",
".",
"get",
"(",
"\"FileName\"",
",",
"... | Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values. | [
"Internal",
"method",
"to",
"import",
"instance",
"variables",
"data",
"from",
"a",
"dictionary"
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/solution.py#L37-L47 | train | Internal method to import instance variables data from a dictionary containing variables values. |
dbarsam/python-vsgen | vsgen/solution.py | VSGSolution.write | def write(self):
"""
Writes the ``.sln`` file to disk.
"""
filters = {
'MSGUID': lambda x: ('{%s}' % x).upper(),
'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName))
}
context = {
'sln': self
}
retu... | python | def write(self):
"""
Writes the ``.sln`` file to disk.
"""
filters = {
'MSGUID': lambda x: ('{%s}' % x).upper(),
'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName))
}
context = {
'sln': self
}
retu... | [
"def",
"write",
"(",
"self",
")",
":",
"filters",
"=",
"{",
"'MSGUID'",
":",
"lambda",
"x",
":",
"(",
"'{%s}'",
"%",
"x",
")",
".",
"upper",
"(",
")",
",",
"'relslnfile'",
":",
"lambda",
"x",
":",
"os",
".",
"path",
".",
"relpath",
"(",
"x",
",... | Writes the ``.sln`` file to disk. | [
"Writes",
"the",
".",
"sln",
"file",
"to",
"disk",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/solution.py#L49-L60 | train | Writes the. sln file to disk. |
atarashansky/self-assembling-manifold | SAM.py | SAM.preprocess_data | def preprocess_data(self, div=1, downsample=0, sum_norm=None,
include_genes=None, exclude_genes=None,
include_cells=None, exclude_cells=None,
norm='log', min_expression=1, thresh=0.01,
filter_genes=True):
"""Log-norm... | python | def preprocess_data(self, div=1, downsample=0, sum_norm=None,
include_genes=None, exclude_genes=None,
include_cells=None, exclude_cells=None,
norm='log', min_expression=1, thresh=0.01,
filter_genes=True):
"""Log-norm... | [
"def",
"preprocess_data",
"(",
"self",
",",
"div",
"=",
"1",
",",
"downsample",
"=",
"0",
",",
"sum_norm",
"=",
"None",
",",
"include_genes",
"=",
"None",
",",
"exclude_genes",
"=",
"None",
",",
"include_cells",
"=",
"None",
",",
"exclude_cells",
"=",
"N... | Log-normalizes and filters the expression data.
Parameters
----------
div : float, optional, default 1
The factor by which the gene expression will be divided prior to
log normalization.
downsample : float, optional, default 0
The factor by which to... | [
"Log",
"-",
"normalizes",
"and",
"filters",
"the",
"expression",
"data",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L143-L346 | train | Preprocess the data for the UMI - related data. |
atarashansky/self-assembling-manifold | SAM.py | SAM.load_data | def load_data(self, filename, transpose=True,
save_sparse_file='h5ad', sep=',', **kwargs):
"""Loads the specified data file. The file can be a table of
read counts (i.e. '.csv' or '.txt'), with genes as rows and cells
as columns by default. The file can also be a pickle file (o... | python | def load_data(self, filename, transpose=True,
save_sparse_file='h5ad', sep=',', **kwargs):
"""Loads the specified data file. The file can be a table of
read counts (i.e. '.csv' or '.txt'), with genes as rows and cells
as columns by default. The file can also be a pickle file (o... | [
"def",
"load_data",
"(",
"self",
",",
"filename",
",",
"transpose",
"=",
"True",
",",
"save_sparse_file",
"=",
"'h5ad'",
",",
"sep",
"=",
"','",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"filename",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",... | Loads the specified data file. The file can be a table of
read counts (i.e. '.csv' or '.txt'), with genes as rows and cells
as columns by default. The file can also be a pickle file (output from
'save_sparse_data') or an h5ad file (output from 'save_anndata').
This function that loads t... | [
"Loads",
"the",
"specified",
"data",
"file",
".",
"The",
"file",
"can",
"be",
"a",
"table",
"of",
"read",
"counts",
"(",
"i",
".",
"e",
".",
".",
"csv",
"or",
".",
"txt",
")",
"with",
"genes",
"as",
"rows",
"and",
"cells",
"as",
"columns",
"by",
... | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L348-L427 | train | Loads the specified data file into the internal data structures. |
atarashansky/self-assembling-manifold | SAM.py | SAM.save_sparse_data | def save_sparse_data(self, fname):
"""Saves the tuple (raw_data,all_cell_names,all_gene_names) in a
Pickle file.
Parameters
----------
fname - string
The filename of the output file.
"""
data = self.adata_raw.X.T
if data.getformat()=='csr':
... | python | def save_sparse_data(self, fname):
"""Saves the tuple (raw_data,all_cell_names,all_gene_names) in a
Pickle file.
Parameters
----------
fname - string
The filename of the output file.
"""
data = self.adata_raw.X.T
if data.getformat()=='csr':
... | [
"def",
"save_sparse_data",
"(",
"self",
",",
"fname",
")",
":",
"data",
"=",
"self",
".",
"adata_raw",
".",
"X",
".",
"T",
"if",
"data",
".",
"getformat",
"(",
")",
"==",
"'csr'",
":",
"data",
"=",
"data",
".",
"tocsc",
"(",
")",
"cell_names",
"=",... | Saves the tuple (raw_data,all_cell_names,all_gene_names) in a
Pickle file.
Parameters
----------
fname - string
The filename of the output file. | [
"Saves",
"the",
"tuple",
"(",
"raw_data",
"all_cell_names",
"all_gene_names",
")",
"in",
"a",
"Pickle",
"file",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L429-L446 | train | Saves the raw data in a pickle file. |
atarashansky/self-assembling-manifold | SAM.py | SAM.save_anndata | def save_anndata(self, fname, data = 'adata_raw', **kwargs):
"""Saves `adata_raw` to a .h5ad file (AnnData's native file format).
Parameters
----------
fname - string
The filename of the output file.
"""
x = self.__dict__[data]
x.write_h5ad(fname, **... | python | def save_anndata(self, fname, data = 'adata_raw', **kwargs):
"""Saves `adata_raw` to a .h5ad file (AnnData's native file format).
Parameters
----------
fname - string
The filename of the output file.
"""
x = self.__dict__[data]
x.write_h5ad(fname, **... | [
"def",
"save_anndata",
"(",
"self",
",",
"fname",
",",
"data",
"=",
"'adata_raw'",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"self",
".",
"__dict__",
"[",
"data",
"]",
"x",
".",
"write_h5ad",
"(",
"fname",
",",
"*",
"*",
"kwargs",
")"
] | Saves `adata_raw` to a .h5ad file (AnnData's native file format).
Parameters
----------
fname - string
The filename of the output file. | [
"Saves",
"adata_raw",
"to",
"a",
".",
"h5ad",
"file",
"(",
"AnnData",
"s",
"native",
"file",
"format",
")",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L448-L458 | train | Saves an anndata to a. h5ad file. |
atarashansky/self-assembling-manifold | SAM.py | SAM.load_annotations | def load_annotations(self, aname, sep=','):
"""Loads cell annotations.
Loads the cell annoations specified by the 'aname' path.
Parameters
----------
aname - string
The path to the annotations file. First column should be cell IDs
and second column shoul... | python | def load_annotations(self, aname, sep=','):
"""Loads cell annotations.
Loads the cell annoations specified by the 'aname' path.
Parameters
----------
aname - string
The path to the annotations file. First column should be cell IDs
and second column shoul... | [
"def",
"load_annotations",
"(",
"self",
",",
"aname",
",",
"sep",
"=",
"','",
")",
":",
"ann",
"=",
"pd",
".",
"read_csv",
"(",
"aname",
")",
"cell_names",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"adata",
".",
"obs_names",
")",
")",... | Loads cell annotations.
Loads the cell annoations specified by the 'aname' path.
Parameters
----------
aname - string
The path to the annotations file. First column should be cell IDs
and second column should be the desired annotations. | [
"Loads",
"cell",
"annotations",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L460-L489 | train | Loads the cell annoations specified by the aname path. |
atarashansky/self-assembling-manifold | SAM.py | SAM.dispersion_ranking_NN | def dispersion_ranking_NN(self, nnm, num_norm_avg=50):
"""Computes the spatial dispersion factors for each gene.
Parameters
----------
nnm - scipy.sparse, float
Square cell-to-cell nearest-neighbor matrix.
num_norm_avg - int, optional, default 50
The top... | python | def dispersion_ranking_NN(self, nnm, num_norm_avg=50):
"""Computes the spatial dispersion factors for each gene.
Parameters
----------
nnm - scipy.sparse, float
Square cell-to-cell nearest-neighbor matrix.
num_norm_avg - int, optional, default 50
The top... | [
"def",
"dispersion_ranking_NN",
"(",
"self",
",",
"nnm",
",",
"num_norm_avg",
"=",
"50",
")",
":",
"self",
".",
"knn_avg",
"(",
"nnm",
")",
"D_avg",
"=",
"self",
".",
"adata",
".",
"layers",
"[",
"'X_knn_avg'",
"]",
"mu",
",",
"var",
"=",
"sf",
".",
... | Computes the spatial dispersion factors for each gene.
Parameters
----------
nnm - scipy.sparse, float
Square cell-to-cell nearest-neighbor matrix.
num_norm_avg - int, optional, default 50
The top 'num_norm_avg' dispersions are averaged to determine the
... | [
"Computes",
"the",
"spatial",
"dispersion",
"factors",
"for",
"each",
"gene",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L491-L532 | train | Computes the spatial dispersion factors for each gene in the set of outlier genes. |
atarashansky/self-assembling-manifold | SAM.py | SAM.calculate_regression_PCs | def calculate_regression_PCs(self, genes=None, npcs=None, plot=False):
"""Computes the contribution of the gene IDs in 'genes' to each
principal component (PC) of the filtered expression data as the mean of
the absolute value of the corresponding gene loadings. High values
correspond to ... | python | def calculate_regression_PCs(self, genes=None, npcs=None, plot=False):
"""Computes the contribution of the gene IDs in 'genes' to each
principal component (PC) of the filtered expression data as the mean of
the absolute value of the corresponding gene loadings. High values
correspond to ... | [
"def",
"calculate_regression_PCs",
"(",
"self",
",",
"genes",
"=",
"None",
",",
"npcs",
"=",
"None",
",",
"plot",
"=",
"False",
")",
":",
"from",
"sklearn",
".",
"decomposition",
"import",
"PCA",
"if",
"npcs",
"is",
"None",
":",
"npcs",
"=",
"self",
".... | Computes the contribution of the gene IDs in 'genes' to each
principal component (PC) of the filtered expression data as the mean of
the absolute value of the corresponding gene loadings. High values
correspond to PCs that are highly correlated with the features in
'genes'. These PCs can... | [
"Computes",
"the",
"contribution",
"of",
"the",
"gene",
"IDs",
"in",
"genes",
"to",
"each",
"principal",
"component",
"(",
"PC",
")",
"of",
"the",
"filtered",
"expression",
"data",
"as",
"the",
"mean",
"of",
"the",
"absolute",
"value",
"of",
"the",
"corres... | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L534-L586 | train | Calculates the regression of the gene IDs in genes to each other. |
atarashansky/self-assembling-manifold | SAM.py | SAM.regress_genes | def regress_genes(self, PCs):
"""Regress out the principal components in 'PCs' from the filtered
expression data ('SAM.D'). Assumes 'calculate_regression_PCs' has
been previously called.
Parameters
----------
PCs - int, numpy.array, list
The principal compone... | python | def regress_genes(self, PCs):
"""Regress out the principal components in 'PCs' from the filtered
expression data ('SAM.D'). Assumes 'calculate_regression_PCs' has
been previously called.
Parameters
----------
PCs - int, numpy.array, list
The principal compone... | [
"def",
"regress_genes",
"(",
"self",
",",
"PCs",
")",
":",
"ind",
"=",
"[",
"PCs",
"]",
"ind",
"=",
"np",
".",
"array",
"(",
"ind",
")",
".",
"flatten",
"(",
")",
"try",
":",
"y",
"=",
"self",
".",
"adata",
".",
"X",
".",
"toarray",
"(",
")",... | Regress out the principal components in 'PCs' from the filtered
expression data ('SAM.D'). Assumes 'calculate_regression_PCs' has
been previously called.
Parameters
----------
PCs - int, numpy.array, list
The principal components to regress out of the expression data... | [
"Regress",
"out",
"the",
"principal",
"components",
"in",
"PCs",
"from",
"the",
"filtered",
"expression",
"data",
"(",
"SAM",
".",
"D",
")",
".",
"Assumes",
"calculate_regression_PCs",
"has",
"been",
"previously",
"called",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L588-L610 | train | Regress out the principal components in PCs from the filtered sequence data. |
atarashansky/self-assembling-manifold | SAM.py | SAM.run | def run(self,
max_iter=10,
verbose=True,
projection='umap',
stopping_condition=5e-3,
num_norm_avg=50,
k=20,
distance='correlation',
preprocessing='Normalizer',
proj_kwargs={}):
"""Runs the Self-Assembling... | python | def run(self,
max_iter=10,
verbose=True,
projection='umap',
stopping_condition=5e-3,
num_norm_avg=50,
k=20,
distance='correlation',
preprocessing='Normalizer',
proj_kwargs={}):
"""Runs the Self-Assembling... | [
"def",
"run",
"(",
"self",
",",
"max_iter",
"=",
"10",
",",
"verbose",
"=",
"True",
",",
"projection",
"=",
"'umap'",
",",
"stopping_condition",
"=",
"5e-3",
",",
"num_norm_avg",
"=",
"50",
",",
"k",
"=",
"20",
",",
"distance",
"=",
"'correlation'",
",... | Runs the Self-Assembling Manifold algorithm.
Parameters
----------
k - int, optional, default 20
The number of nearest neighbors to identify for each cell.
distance : string, optional, default 'correlation'
The distance metric to use when constructing cell dista... | [
"Runs",
"the",
"Self",
"-",
"Assembling",
"Manifold",
"algorithm",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L612-L779 | train | This method runs the Self - Assembling Manifold algorithm. |
atarashansky/self-assembling-manifold | SAM.py | SAM.plot_correlated_groups | def plot_correlated_groups(self, group=None, n_genes=5, **kwargs):
"""Plots orthogonal expression patterns.
In the default mode, plots orthogonal gene expression patterns. A
specific correlated group of genes can be specified to plot gene
expression patterns within that group.
... | python | def plot_correlated_groups(self, group=None, n_genes=5, **kwargs):
"""Plots orthogonal expression patterns.
In the default mode, plots orthogonal gene expression patterns. A
specific correlated group of genes can be specified to plot gene
expression patterns within that group.
... | [
"def",
"plot_correlated_groups",
"(",
"self",
",",
"group",
"=",
"None",
",",
"n_genes",
"=",
"5",
",",
"*",
"*",
"kwargs",
")",
":",
"geneID_groups",
"=",
"self",
".",
"adata",
".",
"uns",
"[",
"'gene_groups'",
"]",
"if",
"(",
"group",
"is",
"None",
... | Plots orthogonal expression patterns.
In the default mode, plots orthogonal gene expression patterns. A
specific correlated group of genes can be specified to plot gene
expression patterns within that group.
Parameters
----------
group - int, optional, default None
... | [
"Plots",
"orthogonal",
"expression",
"patterns",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L857-L885 | train | Plots orthogonal expression patterns within a specific correlated group of genes. |
atarashansky/self-assembling-manifold | SAM.py | SAM.plot_correlated_genes | def plot_correlated_genes(
self,
name,
n_genes=5,
number_of_features=1000,
**kwargs):
"""Plots gene expression patterns correlated with the input gene.
Parameters
----------
name - string
The name of the gene with r... | python | def plot_correlated_genes(
self,
name,
n_genes=5,
number_of_features=1000,
**kwargs):
"""Plots gene expression patterns correlated with the input gene.
Parameters
----------
name - string
The name of the gene with r... | [
"def",
"plot_correlated_genes",
"(",
"self",
",",
"name",
",",
"n_genes",
"=",
"5",
",",
"number_of_features",
"=",
"1000",
",",
"*",
"*",
"kwargs",
")",
":",
"all_gene_names",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"adata",
".",
"var_... | Plots gene expression patterns correlated with the input gene.
Parameters
----------
name - string
The name of the gene with respect to which correlated gene
expression patterns will be displayed.
n_genes - int, optional, default 5
The number of top ... | [
"Plots",
"gene",
"expression",
"patterns",
"correlated",
"with",
"the",
"input",
"gene",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L887-L924 | train | Plots the top ranked expression patterns of the given gene. |
atarashansky/self-assembling-manifold | SAM.py | SAM.corr_bin_genes | def corr_bin_genes(self, number_of_features=None, input_gene=None):
"""A (hacky) method for binning groups of genes correlated along the
SAM manifold.
Parameters
----------
number_of_features - int, optional, default None
The number of genes to bin. Capped at 5000 du... | python | def corr_bin_genes(self, number_of_features=None, input_gene=None):
"""A (hacky) method for binning groups of genes correlated along the
SAM manifold.
Parameters
----------
number_of_features - int, optional, default None
The number of genes to bin. Capped at 5000 du... | [
"def",
"corr_bin_genes",
"(",
"self",
",",
"number_of_features",
"=",
"None",
",",
"input_gene",
"=",
"None",
")",
":",
"weights",
"=",
"self",
".",
"adata",
".",
"var",
"[",
"'spatial_dispersions'",
"]",
".",
"values",
"all_gene_names",
"=",
"np",
".",
"a... | A (hacky) method for binning groups of genes correlated along the
SAM manifold.
Parameters
----------
number_of_features - int, optional, default None
The number of genes to bin. Capped at 5000 due to memory
considerations.
input_gene - str, optional, de... | [
"A",
"(",
"hacky",
")",
"method",
"for",
"binning",
"groups",
"of",
"genes",
"correlated",
"along",
"the",
"SAM",
"manifold",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L926-L1009 | train | This method is used to bin the genes in the SAM manifold. |
atarashansky/self-assembling-manifold | SAM.py | SAM.run_tsne | def run_tsne(self, X=None, metric='correlation', **kwargs):
"""Wrapper for sklearn's t-SNE implementation.
See sklearn for the t-SNE documentation. All arguments are the same
with the exception that 'metric' is set to 'precomputed' by default,
implying that this function expects a dista... | python | def run_tsne(self, X=None, metric='correlation', **kwargs):
"""Wrapper for sklearn's t-SNE implementation.
See sklearn for the t-SNE documentation. All arguments are the same
with the exception that 'metric' is set to 'precomputed' by default,
implying that this function expects a dista... | [
"def",
"run_tsne",
"(",
"self",
",",
"X",
"=",
"None",
",",
"metric",
"=",
"'correlation'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"X",
"is",
"not",
"None",
")",
":",
"dt",
"=",
"man",
".",
"TSNE",
"(",
"metric",
"=",
"metric",
",",
"*",... | Wrapper for sklearn's t-SNE implementation.
See sklearn for the t-SNE documentation. All arguments are the same
with the exception that 'metric' is set to 'precomputed' by default,
implying that this function expects a distance matrix by default. | [
"Wrapper",
"for",
"sklearn",
"s",
"t",
"-",
"SNE",
"implementation",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1011-L1026 | train | Wrapper for sklearn s t - SNE implementation. |
atarashansky/self-assembling-manifold | SAM.py | SAM.run_umap | def run_umap(self, X=None, metric=None, **kwargs):
"""Wrapper for umap-learn.
See https://github.com/lmcinnes/umap sklearn for the documentation
and source code.
"""
import umap as umap
if metric is None:
metric = self.distance
if(X is not None):
... | python | def run_umap(self, X=None, metric=None, **kwargs):
"""Wrapper for umap-learn.
See https://github.com/lmcinnes/umap sklearn for the documentation
and source code.
"""
import umap as umap
if metric is None:
metric = self.distance
if(X is not None):
... | [
"def",
"run_umap",
"(",
"self",
",",
"X",
"=",
"None",
",",
"metric",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"umap",
"as",
"umap",
"if",
"metric",
"is",
"None",
":",
"metric",
"=",
"self",
".",
"distance",
"if",
"(",
"X",
"is",... | Wrapper for umap-learn.
See https://github.com/lmcinnes/umap sklearn for the documentation
and source code. | [
"Wrapper",
"for",
"umap",
"-",
"learn",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1028-L1048 | train | Wrapper for umap - learn.
|
atarashansky/self-assembling-manifold | SAM.py | SAM.run_diff_umap | def run_diff_umap(self,use_rep='X_pca', metric='euclidean', n_comps=15,
method='gauss', **kwargs):
"""
Experimental -- running UMAP on the diffusion components
"""
import scanpy.api as sc
sc.pp.neighbors(self.adata,use_rep=use_rep,n_neig... | python | def run_diff_umap(self,use_rep='X_pca', metric='euclidean', n_comps=15,
method='gauss', **kwargs):
"""
Experimental -- running UMAP on the diffusion components
"""
import scanpy.api as sc
sc.pp.neighbors(self.adata,use_rep=use_rep,n_neig... | [
"def",
"run_diff_umap",
"(",
"self",
",",
"use_rep",
"=",
"'X_pca'",
",",
"metric",
"=",
"'euclidean'",
",",
"n_comps",
"=",
"15",
",",
"method",
"=",
"'gauss'",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"scanpy",
".",
"api",
"as",
"sc",
"sc",
"."... | Experimental -- running UMAP on the diffusion components | [
"Experimental",
"--",
"running",
"UMAP",
"on",
"the",
"diffusion",
"components"
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1050-L1066 | train | Run UMAP on the diffusion components of the current object |
atarashansky/self-assembling-manifold | SAM.py | SAM.scatter | def scatter(self, projection=None, c=None, cmap='rainbow', linewidth=0.0,
edgecolor='k', axes=None, colorbar=True, s=10, **kwargs):
"""Display a scatter plot.
Displays a scatter plot using the SAM projection or another input
projection with or without annotations.
Param... | python | def scatter(self, projection=None, c=None, cmap='rainbow', linewidth=0.0,
edgecolor='k', axes=None, colorbar=True, s=10, **kwargs):
"""Display a scatter plot.
Displays a scatter plot using the SAM projection or another input
projection with or without annotations.
Param... | [
"def",
"scatter",
"(",
"self",
",",
"projection",
"=",
"None",
",",
"c",
"=",
"None",
",",
"cmap",
"=",
"'rainbow'",
",",
"linewidth",
"=",
"0.0",
",",
"edgecolor",
"=",
"'k'",
",",
"axes",
"=",
"None",
",",
"colorbar",
"=",
"True",
",",
"s",
"=",
... | Display a scatter plot.
Displays a scatter plot using the SAM projection or another input
projection with or without annotations.
Parameters
----------
projection - ndarray of floats, optional, default None
An N x 2 matrix, where N is the number of data points. If ... | [
"Display",
"a",
"scatter",
"plot",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1077-L1175 | train | Display a scatter plot of the current state of the key - value entry in the current state of the object. |
atarashansky/self-assembling-manifold | SAM.py | SAM.show_gene_expression | def show_gene_expression(self, gene, avg=True, axes=None, **kwargs):
"""Display a gene's expressions.
Displays a scatter plot using the SAM projection or another input
projection with a particular gene's expressions overlaid.
Parameters
----------
gene - string
... | python | def show_gene_expression(self, gene, avg=True, axes=None, **kwargs):
"""Display a gene's expressions.
Displays a scatter plot using the SAM projection or another input
projection with a particular gene's expressions overlaid.
Parameters
----------
gene - string
... | [
"def",
"show_gene_expression",
"(",
"self",
",",
"gene",
",",
"avg",
"=",
"True",
",",
"axes",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"all_gene_names",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"adata",
".",
"var_names",
")",
... | Display a gene's expressions.
Displays a scatter plot using the SAM projection or another input
projection with a particular gene's expressions overlaid.
Parameters
----------
gene - string
a case-sensitive string indicating the gene expression pattern
t... | [
"Display",
"a",
"gene",
"s",
"expressions",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1177-L1231 | train | Displays a scatter plot of a particular gene s expression pattern. |
atarashansky/self-assembling-manifold | SAM.py | SAM.louvain_clustering | def louvain_clustering(self, X=None, res=1, method='modularity'):
"""Runs Louvain clustering using the vtraag implementation. Assumes
that 'louvain' optional dependency is installed.
Parameters
----------
res - float, optional, default 1
The resolution parameter whic... | python | def louvain_clustering(self, X=None, res=1, method='modularity'):
"""Runs Louvain clustering using the vtraag implementation. Assumes
that 'louvain' optional dependency is installed.
Parameters
----------
res - float, optional, default 1
The resolution parameter whic... | [
"def",
"louvain_clustering",
"(",
"self",
",",
"X",
"=",
"None",
",",
"res",
"=",
"1",
",",
"method",
"=",
"'modularity'",
")",
":",
"if",
"X",
"is",
"None",
":",
"X",
"=",
"self",
".",
"adata",
".",
"uns",
"[",
"'neighbors'",
"]",
"[",
"'connectiv... | Runs Louvain clustering using the vtraag implementation. Assumes
that 'louvain' optional dependency is installed.
Parameters
----------
res - float, optional, default 1
The resolution parameter which tunes the number of clusters Louvain
finds.
method - s... | [
"Runs",
"Louvain",
"clustering",
"using",
"the",
"vtraag",
"implementation",
".",
"Assumes",
"that",
"louvain",
"optional",
"dependency",
"is",
"installed",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1265-L1316 | train | Runs Louvain clustering on the vtraag X. |
atarashansky/self-assembling-manifold | SAM.py | SAM.kmeans_clustering | def kmeans_clustering(self, numc, X=None, npcs=15):
"""Performs k-means clustering.
Parameters
----------
numc - int
Number of clusters
npcs - int, optional, default 15
Number of principal components to use as inpute for k-means
clustering.
... | python | def kmeans_clustering(self, numc, X=None, npcs=15):
"""Performs k-means clustering.
Parameters
----------
numc - int
Number of clusters
npcs - int, optional, default 15
Number of principal components to use as inpute for k-means
clustering.
... | [
"def",
"kmeans_clustering",
"(",
"self",
",",
"numc",
",",
"X",
"=",
"None",
",",
"npcs",
"=",
"15",
")",
":",
"from",
"sklearn",
".",
"cluster",
"import",
"KMeans",
"if",
"X",
"is",
"None",
":",
"D_sub",
"=",
"self",
".",
"adata",
".",
"uns",
"[",... | Performs k-means clustering.
Parameters
----------
numc - int
Number of clusters
npcs - int, optional, default 15
Number of principal components to use as inpute for k-means
clustering. | [
"Performs",
"k",
"-",
"means",
"clustering",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1318-L1350 | train | Performs k - means clustering on the clusteres of the specified number of clusters. |
atarashansky/self-assembling-manifold | SAM.py | SAM.identify_marker_genes_rf | def identify_marker_genes_rf(self, labels=None, clusters=None,
n_genes=4000):
"""
Ranks marker genes for each cluster using a random forest
classification approach.
Parameters
----------
labels - numpy.array or str, optional, default Non... | python | def identify_marker_genes_rf(self, labels=None, clusters=None,
n_genes=4000):
"""
Ranks marker genes for each cluster using a random forest
classification approach.
Parameters
----------
labels - numpy.array or str, optional, default Non... | [
"def",
"identify_marker_genes_rf",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"clusters",
"=",
"None",
",",
"n_genes",
"=",
"4000",
")",
":",
"if",
"(",
"labels",
"is",
"None",
")",
":",
"try",
":",
"keys",
"=",
"np",
".",
"array",
"(",
"list",
... | Ranks marker genes for each cluster using a random forest
classification approach.
Parameters
----------
labels - numpy.array or str, optional, default None
Cluster labels to use for marker gene identification. If None,
assumes that one of SAM's clustering algor... | [
"Ranks",
"marker",
"genes",
"for",
"each",
"cluster",
"using",
"a",
"random",
"forest",
"classification",
"approach",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1404-L1471 | train | This function uses a random forest classification approach to identify marker genes for each cluster. |
atarashansky/self-assembling-manifold | SAM.py | SAM.identify_marker_genes_ratio | def identify_marker_genes_ratio(self, labels=None):
"""
Ranks marker genes for each cluster using a SAM-weighted
expression-ratio approach (works quite well).
Parameters
----------
labels - numpy.array or str, optional, default None
Cluster labels to use fo... | python | def identify_marker_genes_ratio(self, labels=None):
"""
Ranks marker genes for each cluster using a SAM-weighted
expression-ratio approach (works quite well).
Parameters
----------
labels - numpy.array or str, optional, default None
Cluster labels to use fo... | [
"def",
"identify_marker_genes_ratio",
"(",
"self",
",",
"labels",
"=",
"None",
")",
":",
"if",
"(",
"labels",
"is",
"None",
")",
":",
"try",
":",
"keys",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"adata",
".",
"obs_keys",
"(",
")",
")... | Ranks marker genes for each cluster using a SAM-weighted
expression-ratio approach (works quite well).
Parameters
----------
labels - numpy.array or str, optional, default None
Cluster labels to use for marker gene identification. If None,
assumes that one of S... | [
"Ranks",
"marker",
"genes",
"for",
"each",
"cluster",
"using",
"a",
"SAM",
"-",
"weighted",
"expression",
"-",
"ratio",
"approach",
"(",
"works",
"quite",
"well",
")",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1473-L1519 | train | This function is used to identify the ratio of each marker gene for each cluster. |
atarashansky/self-assembling-manifold | SAM.py | SAM.identify_marker_genes_corr | def identify_marker_genes_corr(self, labels=None, n_genes=4000):
"""
Ranking marker genes based on their respective magnitudes in the
correlation dot products with cluster-specific reference expression
profiles.
Parameters
----------
labels - numpy.array or str... | python | def identify_marker_genes_corr(self, labels=None, n_genes=4000):
"""
Ranking marker genes based on their respective magnitudes in the
correlation dot products with cluster-specific reference expression
profiles.
Parameters
----------
labels - numpy.array or str... | [
"def",
"identify_marker_genes_corr",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"n_genes",
"=",
"4000",
")",
":",
"if",
"(",
"labels",
"is",
"None",
")",
":",
"try",
":",
"keys",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"adata",
"... | Ranking marker genes based on their respective magnitudes in the
correlation dot products with cluster-specific reference expression
profiles.
Parameters
----------
labels - numpy.array or str, optional, default None
Cluster labels to use for marker gene identifica... | [
"Ranking",
"marker",
"genes",
"based",
"on",
"their",
"respective",
"magnitudes",
"in",
"the",
"correlation",
"dot",
"products",
"with",
"cluster",
"-",
"specific",
"reference",
"expression",
"profiles",
"."
] | 4db4793f65af62047492327716932ba81a67f679 | https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1521-L1575 | train | Identify marker genes based on their respective magnitudes in the cluster - specific reference expression. |
cocoakekeyu/cancan | cancan/ability.py | Ability.add | def add(self, action=None, subject=None, **conditions):
"""
Add ability are allowed using two arguments.
The first one is the action you're setting the permission for,
the second one is the class of object you're setting it on.
the third one is the subject's conditions must be m... | python | def add(self, action=None, subject=None, **conditions):
"""
Add ability are allowed using two arguments.
The first one is the action you're setting the permission for,
the second one is the class of object you're setting it on.
the third one is the subject's conditions must be m... | [
"def",
"add",
"(",
"self",
",",
"action",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"*",
"*",
"conditions",
")",
":",
"self",
".",
"add_rule",
"(",
"Rule",
"(",
"True",
",",
"action",
",",
"subject",
",",
"*",
"*",
"conditions",
")",
")"
] | Add ability are allowed using two arguments.
The first one is the action you're setting the permission for,
the second one is the class of object you're setting it on.
the third one is the subject's conditions must be matches or a function
to be test.
self.add('update', Article... | [
"Add",
"ability",
"are",
"allowed",
"using",
"two",
"arguments",
"."
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L21-L35 | train | Add a new entry to the cache. |
cocoakekeyu/cancan | cancan/ability.py | Ability.addnot | def addnot(self, action=None, subject=None, **conditions):
"""
Defines an ability which cannot be done.
"""
self.add_rule(Rule(False, action, subject, **conditions)) | python | def addnot(self, action=None, subject=None, **conditions):
"""
Defines an ability which cannot be done.
"""
self.add_rule(Rule(False, action, subject, **conditions)) | [
"def",
"addnot",
"(",
"self",
",",
"action",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"*",
"*",
"conditions",
")",
":",
"self",
".",
"add_rule",
"(",
"Rule",
"(",
"False",
",",
"action",
",",
"subject",
",",
"*",
"*",
"conditions",
")",
")"
] | Defines an ability which cannot be done. | [
"Defines",
"an",
"ability",
"which",
"cannot",
"be",
"done",
"."
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L37-L41 | train | Add a new not rule to the set. |
cocoakekeyu/cancan | cancan/ability.py | Ability.can | def can(self, action, subject, **conditions):
"""
Check if the user has permission to perform a given action on an object
"""
for rule in self.relevant_rules_for_match(action, subject):
if rule.matches_conditions(action, subject, **conditions):
return rule.bas... | python | def can(self, action, subject, **conditions):
"""
Check if the user has permission to perform a given action on an object
"""
for rule in self.relevant_rules_for_match(action, subject):
if rule.matches_conditions(action, subject, **conditions):
return rule.bas... | [
"def",
"can",
"(",
"self",
",",
"action",
",",
"subject",
",",
"*",
"*",
"conditions",
")",
":",
"for",
"rule",
"in",
"self",
".",
"relevant_rules_for_match",
"(",
"action",
",",
"subject",
")",
":",
"if",
"rule",
".",
"matches_conditions",
"(",
"action"... | Check if the user has permission to perform a given action on an object | [
"Check",
"if",
"the",
"user",
"has",
"permission",
"to",
"perform",
"a",
"given",
"action",
"on",
"an",
"object"
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L46-L53 | train | Check if the user has permission to perform a given action on an object |
cocoakekeyu/cancan | cancan/ability.py | Ability.relevant_rules_for_match | def relevant_rules_for_match(self, action, subject):
"""retrive match action and subject"""
matches = []
for rule in self.rules:
rule.expanded_actions = self.expand_actions(rule.actions)
if rule.is_relevant(action, subject):
matches.append(rule)
r... | python | def relevant_rules_for_match(self, action, subject):
"""retrive match action and subject"""
matches = []
for rule in self.rules:
rule.expanded_actions = self.expand_actions(rule.actions)
if rule.is_relevant(action, subject):
matches.append(rule)
r... | [
"def",
"relevant_rules_for_match",
"(",
"self",
",",
"action",
",",
"subject",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"rule",
"in",
"self",
".",
"rules",
":",
"rule",
".",
"expanded_actions",
"=",
"self",
".",
"expand_actions",
"(",
"rule",
".",
"act... | retrive match action and subject | [
"retrive",
"match",
"action",
"and",
"subject"
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L62-L70 | train | retrive match action and subject |
cocoakekeyu/cancan | cancan/ability.py | Ability.expand_actions | def expand_actions(self, actions):
"""
Accepts an array of actions and returns an array of actions which match
"""
r = []
for action in actions:
r.append(action)
if action in self.aliased_actions:
r.extend(self.aliased_actions[action])
... | python | def expand_actions(self, actions):
"""
Accepts an array of actions and returns an array of actions which match
"""
r = []
for action in actions:
r.append(action)
if action in self.aliased_actions:
r.extend(self.aliased_actions[action])
... | [
"def",
"expand_actions",
"(",
"self",
",",
"actions",
")",
":",
"r",
"=",
"[",
"]",
"for",
"action",
"in",
"actions",
":",
"r",
".",
"append",
"(",
"action",
")",
"if",
"action",
"in",
"self",
".",
"aliased_actions",
":",
"r",
".",
"extend",
"(",
"... | Accepts an array of actions and returns an array of actions which match | [
"Accepts",
"an",
"array",
"of",
"actions",
"and",
"returns",
"an",
"array",
"of",
"actions",
"which",
"match"
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L81-L90 | train | Accepts an array of actions and returns an array of actions which match
|
cocoakekeyu/cancan | cancan/ability.py | Ability.alias_action | def alias_action(self, *args, **kwargs):
"""
Alias one or more actions into another one.
self.alias_action('create', 'read', 'update', 'delete', to='crud')
"""
to = kwargs.pop('to', None)
if not to:
return
error_message = ("You can't specify target (... | python | def alias_action(self, *args, **kwargs):
"""
Alias one or more actions into another one.
self.alias_action('create', 'read', 'update', 'delete', to='crud')
"""
to = kwargs.pop('to', None)
if not to:
return
error_message = ("You can't specify target (... | [
"def",
"alias_action",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"to",
"=",
"kwargs",
".",
"pop",
"(",
"'to'",
",",
"None",
")",
"if",
"not",
"to",
":",
"return",
"error_message",
"=",
"(",
"\"You can't specify target ({}) as alia... | Alias one or more actions into another one.
self.alias_action('create', 'read', 'update', 'delete', to='crud') | [
"Alias",
"one",
"or",
"more",
"actions",
"into",
"another",
"one",
"."
] | f198d560e6e008e6c5580ba55581a939a5d544ed | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L92-L108 | train | Alias one or more actions into another one. |
suurjaak/InputScope | inputscope/db.py | fetch | def fetch(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT and fetch all."""
return select(table, cols, where, group, order, limit, **kwargs).fetchall() | python | def fetch(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT and fetch all."""
return select(table, cols, where, group, order, limit, **kwargs).fetchall() | [
"def",
"fetch",
"(",
"table",
",",
"cols",
"=",
"\"*\"",
",",
"where",
"=",
"(",
")",
",",
"group",
"=",
"\"\"",
",",
"order",
"=",
"(",
")",
",",
"limit",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"select",
"(",
"table",
",... | Convenience wrapper for database SELECT and fetch all. | [
"Convenience",
"wrapper",
"for",
"database",
"SELECT",
"and",
"fetch",
"all",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L24-L26 | train | Convenience wrapper for database SELECT and fetch all. |
suurjaak/InputScope | inputscope/db.py | fetchone | def fetchone(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT and fetch one."""
return select(table, cols, where, group, order, limit, **kwargs).fetchone() | python | def fetchone(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT and fetch one."""
return select(table, cols, where, group, order, limit, **kwargs).fetchone() | [
"def",
"fetchone",
"(",
"table",
",",
"cols",
"=",
"\"*\"",
",",
"where",
"=",
"(",
")",
",",
"group",
"=",
"\"\"",
",",
"order",
"=",
"(",
")",
",",
"limit",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"select",
"(",
"table",
... | Convenience wrapper for database SELECT and fetch one. | [
"Convenience",
"wrapper",
"for",
"database",
"SELECT",
"and",
"fetch",
"one",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L29-L31 | train | Convenience wrapper for database SELECT and fetch one. |
suurjaak/InputScope | inputscope/db.py | insert | def insert(table, values=(), **kwargs):
"""Convenience wrapper for database INSERT."""
values = dict(values, **kwargs).items()
sql, args = makeSQL("INSERT", table, values=values)
return execute(sql, args).lastrowid | python | def insert(table, values=(), **kwargs):
"""Convenience wrapper for database INSERT."""
values = dict(values, **kwargs).items()
sql, args = makeSQL("INSERT", table, values=values)
return execute(sql, args).lastrowid | [
"def",
"insert",
"(",
"table",
",",
"values",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"dict",
"(",
"values",
",",
"*",
"*",
"kwargs",
")",
".",
"items",
"(",
")",
"sql",
",",
"args",
"=",
"makeSQL",
"(",
"\"INSERT\"",
"... | Convenience wrapper for database INSERT. | [
"Convenience",
"wrapper",
"for",
"database",
"INSERT",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L34-L38 | train | Convenience wrapper for database INSERT. |
suurjaak/InputScope | inputscope/db.py | select | def select(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("SELECT", table, cols, where, group, order, limit)
return execute(sql, args) | python | def select(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
"""Convenience wrapper for database SELECT."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("SELECT", table, cols, where, group, order, limit)
return execute(sql, args) | [
"def",
"select",
"(",
"table",
",",
"cols",
"=",
"\"*\"",
",",
"where",
"=",
"(",
")",
",",
"group",
"=",
"\"\"",
",",
"order",
"=",
"(",
")",
",",
"limit",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"where",
"=",
"dict",
"(",
"where",... | Convenience wrapper for database SELECT. | [
"Convenience",
"wrapper",
"for",
"database",
"SELECT",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L41-L45 | train | Convenience wrapper for database SELECT. |
suurjaak/InputScope | inputscope/db.py | update | def update(table, values, where=(), **kwargs):
"""Convenience wrapper for database UPDATE."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("UPDATE", table, values=values, where=where)
return execute(sql, args).rowcount | python | def update(table, values, where=(), **kwargs):
"""Convenience wrapper for database UPDATE."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("UPDATE", table, values=values, where=where)
return execute(sql, args).rowcount | [
"def",
"update",
"(",
"table",
",",
"values",
",",
"where",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"where",
"=",
"dict",
"(",
"where",
",",
"*",
"*",
"kwargs",
")",
".",
"items",
"(",
")",
"sql",
",",
"args",
"=",
"makeSQL",
"(",
"... | Convenience wrapper for database UPDATE. | [
"Convenience",
"wrapper",
"for",
"database",
"UPDATE",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L48-L52 | train | Convenience wrapper for database UPDATE. |
suurjaak/InputScope | inputscope/db.py | delete | def delete(table, where=(), **kwargs):
"""Convenience wrapper for database DELETE."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("DELETE", table, where=where)
return execute(sql, args).rowcount | python | def delete(table, where=(), **kwargs):
"""Convenience wrapper for database DELETE."""
where = dict(where, **kwargs).items()
sql, args = makeSQL("DELETE", table, where=where)
return execute(sql, args).rowcount | [
"def",
"delete",
"(",
"table",
",",
"where",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"where",
"=",
"dict",
"(",
"where",
",",
"*",
"*",
"kwargs",
")",
".",
"items",
"(",
")",
"sql",
",",
"args",
"=",
"makeSQL",
"(",
"\"DELETE\"",
",",... | Convenience wrapper for database DELETE. | [
"Convenience",
"wrapper",
"for",
"database",
"DELETE",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L55-L59 | train | Convenience wrapper for database DELETE. |
suurjaak/InputScope | inputscope/db.py | make_cursor | def make_cursor(path, init_statements=(), _connectioncache={}):
"""Returns a cursor to the database, making new connection if not cached."""
connection = _connectioncache.get(path)
if not connection:
is_new = not os.path.exists(path) or not os.path.getsize(path)
try: is_new and os.maked... | python | def make_cursor(path, init_statements=(), _connectioncache={}):
"""Returns a cursor to the database, making new connection if not cached."""
connection = _connectioncache.get(path)
if not connection:
is_new = not os.path.exists(path) or not os.path.getsize(path)
try: is_new and os.maked... | [
"def",
"make_cursor",
"(",
"path",
",",
"init_statements",
"=",
"(",
")",
",",
"_connectioncache",
"=",
"{",
"}",
")",
":",
"connection",
"=",
"_connectioncache",
".",
"get",
"(",
"path",
")",
"if",
"not",
"connection",
":",
"is_new",
"=",
"not",
"os",
... | Returns a cursor to the database, making new connection if not cached. | [
"Returns",
"a",
"cursor",
"to",
"the",
"database",
"making",
"new",
"connection",
"if",
"not",
"cached",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L73-L87 | train | Returns a cursor to the database. |
suurjaak/InputScope | inputscope/db.py | makeSQL | def makeSQL(action, table, cols="*", where=(), group="", order=(), limit=(), values=()):
"""Returns (SQL statement string, parameter dict)."""
cols = cols if isinstance(cols, basestring) else ", ".join(cols)
group = group if isinstance(group, basestring) else ", ".join(group)
order = [order] ... | python | def makeSQL(action, table, cols="*", where=(), group="", order=(), limit=(), values=()):
"""Returns (SQL statement string, parameter dict)."""
cols = cols if isinstance(cols, basestring) else ", ".join(cols)
group = group if isinstance(group, basestring) else ", ".join(group)
order = [order] ... | [
"def",
"makeSQL",
"(",
"action",
",",
"table",
",",
"cols",
"=",
"\"*\"",
",",
"where",
"=",
"(",
")",
",",
"group",
"=",
"\"\"",
",",
"order",
"=",
"(",
")",
",",
"limit",
"=",
"(",
")",
",",
"values",
"=",
"(",
")",
")",
":",
"cols",
"=",
... | Returns (SQL statement string, parameter dict). | [
"Returns",
"(",
"SQL",
"statement",
"string",
"parameter",
"dict",
")",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L90-L129 | train | Returns a sql statement string and parameter dict. |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | continue_prompt | def continue_prompt(message=""):
"""Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool
"""
answer = False
message = message + "\n'Yes' or 'No' to continue: "
while answer not in ('Yes', 'No'):
... | python | def continue_prompt(message=""):
"""Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool
"""
answer = False
message = message + "\n'Yes' or 'No' to continue: "
while answer not in ('Yes', 'No'):
... | [
"def",
"continue_prompt",
"(",
"message",
"=",
"\"\"",
")",
":",
"answer",
"=",
"False",
"message",
"=",
"message",
"+",
"\"\\n'Yes' or 'No' to continue: \"",
"while",
"answer",
"not",
"in",
"(",
"'Yes'",
",",
"'No'",
")",
":",
"answer",
"=",
"prompt",
"(",
... | Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool | [
"Prompt",
"the",
"user",
"to",
"continue",
"or",
"not"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L216-L236 | train | Prompt the user to continue or not
Returns True when the user type Yes or False otherwise |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | printo | def printo(msg, encoding=None, errors='replace', std_type='stdout'):
"""Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3
"... | python | def printo(msg, encoding=None, errors='replace', std_type='stdout'):
"""Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3
"... | [
"def",
"printo",
"(",
"msg",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'replace'",
",",
"std_type",
"=",
"'stdout'",
")",
":",
"std",
"=",
"getattr",
"(",
"sys",
",",
"std_type",
",",
"sys",
".",
"stdout",
")",
"if",
"encoding",
"is",
"None"... | Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3 | [
"Write",
"msg",
"on",
"stdout",
".",
"If",
"no",
"encoding",
"is",
"specified",
"the",
"detected",
"encoding",
"of",
"stdout",
"is",
"used",
".",
"If",
"the",
"encoding",
"can",
"t",
"encode",
"some",
"chars",
"they",
"are",
"replaced",
"by",
"?"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L281-L304 | train | Write msg to stdout. |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | format_table | def format_table(rows, sep=' '):
"""Format table
:param sep: separator between columns
:type sep: unicode on python2 | str on python3
Given the table::
table = [
['foo', 'bar', 'foo'],
[1, 2, 3],
['54a5a05d-c83b-4bb5-bd95-d90d6ea4a878'],
['foo'... | python | def format_table(rows, sep=' '):
"""Format table
:param sep: separator between columns
:type sep: unicode on python2 | str on python3
Given the table::
table = [
['foo', 'bar', 'foo'],
[1, 2, 3],
['54a5a05d-c83b-4bb5-bd95-d90d6ea4a878'],
['foo'... | [
"def",
"format_table",
"(",
"rows",
",",
"sep",
"=",
"' '",
")",
":",
"max_col_length",
"=",
"[",
"0",
"]",
"*",
"100",
"# calculate max length for each col",
"for",
"row",
"in",
"rows",
":",
"for",
"index",
",",
"(",
"col",
",",
"length",
")",
"in",
... | Format table
:param sep: separator between columns
:type sep: unicode on python2 | str on python3
Given the table::
table = [
['foo', 'bar', 'foo'],
[1, 2, 3],
['54a5a05d-c83b-4bb5-bd95-d90d6ea4a878'],
['foo', 45, 'bar', 2345]
]
`format... | [
"Format",
"table"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L307-L342 | train | Format the table of the n - grams. |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | format_tree | def format_tree(tree):
"""Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{... | python | def format_tree(tree):
"""Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{... | [
"def",
"format_tree",
"(",
"tree",
")",
":",
"def",
"_traverse_tree",
"(",
"tree",
",",
"parents",
"=",
"None",
")",
":",
"tree",
"[",
"'parents'",
"]",
"=",
"parents",
"childs",
"=",
"tree",
".",
"get",
"(",
"'childs'",
",",
"[",
"]",
")",
"nb_child... | Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{
'node... | [
"Format",
"a",
"python",
"tree",
"structure"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L345-L434 | train | Format a python tree structure into a single object. |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | parallel_map | def parallel_map(func, iterable, args=None, kwargs=None, workers=None):
"""Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of fun... | python | def parallel_map(func, iterable, args=None, kwargs=None, workers=None):
"""Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of fun... | [
"def",
"parallel_map",
"(",
"func",
",",
"iterable",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"workers",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"(",
")",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
... | Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of func
:type args: tuple
:param kwargs: keyword arguments of func
:type ... | [
"Map",
"func",
"on",
"a",
"list",
"using",
"gevent",
"greenlets",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L437-L468 | train | Map a function over a list of elements |
crm416/semantic | semantic/numbers.py | NumberService.parse | def parse(self, words):
"""A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words.
"""
def exact(words):
... | python | def parse(self, words):
"""A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words.
"""
def exact(words):
... | [
"def",
"parse",
"(",
"self",
",",
"words",
")",
":",
"def",
"exact",
"(",
"words",
")",
":",
"\"\"\"If already represented as float or int, convert.\"\"\"",
"try",
":",
"return",
"float",
"(",
"words",
")",
"except",
":",
"return",
"None",
"guess",
"=",
"exact... | A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words. | [
"A",
"general",
"method",
"for",
"parsing",
"word",
"-",
"representations",
"of",
"numbers",
".",
"Supports",
"floats",
"and",
"integers",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L91-L122 | train | A general method for parsing word - representations of numbers. |
crm416/semantic | semantic/numbers.py | NumberService.parseFloat | def parseFloat(self, words):
"""Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Descriptio... | python | def parseFloat(self, words):
"""Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Descriptio... | [
"def",
"parseFloat",
"(",
"self",
",",
"words",
")",
":",
"def",
"pointFloat",
"(",
"words",
")",
":",
"m",
"=",
"re",
".",
"search",
"(",
"r'(.*) point (.*)'",
",",
"words",
")",
"if",
"m",
":",
"whole",
"=",
"m",
".",
"group",
"(",
"1",
")",
"f... | Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Description of the floating-point number.
... | [
"Convert",
"a",
"floating",
"-",
"point",
"number",
"described",
"in",
"words",
"to",
"a",
"double",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L124-L192 | train | Convert a floating - point number described in words to a double. |
crm416/semantic | semantic/numbers.py | NumberService.parseInt | def parseInt(self, words):
"""Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words.
"""
# Remove 'and', case-sensitivity
words = words.replace(" and ", " ").lowe... | python | def parseInt(self, words):
"""Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words.
"""
# Remove 'and', case-sensitivity
words = words.replace(" and ", " ").lowe... | [
"def",
"parseInt",
"(",
"self",
",",
"words",
")",
":",
"# Remove 'and', case-sensitivity",
"words",
"=",
"words",
".",
"replace",
"(",
"\" and \"",
",",
"\" \"",
")",
".",
"lower",
"(",
")",
"# 'a' -> 'one'",
"words",
"=",
"re",
".",
"sub",
"(",
"r'(\\b)a... | Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words. | [
"Parses",
"words",
"to",
"the",
"integer",
"they",
"describe",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L194-L232 | train | Parses the words to the integer representation of the words. |
crm416/semantic | semantic/numbers.py | NumberService.parseMagnitude | def parseMagnitude(m):
"""Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number.
... | python | def parseMagnitude(m):
"""Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number.
... | [
"def",
"parseMagnitude",
"(",
"m",
")",
":",
"m",
"=",
"NumberService",
"(",
")",
".",
"parse",
"(",
"m",
")",
"def",
"toDecimalPrecision",
"(",
"n",
",",
"k",
")",
":",
"return",
"float",
"(",
"\"%.*f\"",
"%",
"(",
"k",
",",
"round",
"(",
"n",
"... | Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number. | [
"Parses",
"a",
"number",
"m",
"into",
"a",
"human",
"-",
"ready",
"string",
"representation",
".",
"For",
"example",
"crops",
"off",
"floats",
"if",
"they",
"re",
"too",
"accurate",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L242-L282 | train | Parses a number m into a human - ready string representation. |
crm416/semantic | semantic/numbers.py | NumberService.longestNumber | def longestNumber(self, inp):
"""Extracts the longest valid numerical description from a string.
Not guaranteed to return a result even if some valid numerical
description exists (i.e., method is not particularly advanced).
Args:
inp (str): An arbitrary string, hopefully con... | python | def longestNumber(self, inp):
"""Extracts the longest valid numerical description from a string.
Not guaranteed to return a result even if some valid numerical
description exists (i.e., method is not particularly advanced).
Args:
inp (str): An arbitrary string, hopefully con... | [
"def",
"longestNumber",
"(",
"self",
",",
"inp",
")",
":",
"split",
"=",
"inp",
".",
"split",
"(",
"' '",
")",
"# Assume just a single number",
"numStart",
"=",
"None",
"numEnd",
"=",
"None",
"for",
"i",
",",
"w",
"in",
"enumerate",
"(",
"split",
")",
... | Extracts the longest valid numerical description from a string.
Not guaranteed to return a result even if some valid numerical
description exists (i.e., method is not particularly advanced).
Args:
inp (str): An arbitrary string, hopefully containing a number.
Returns:
... | [
"Extracts",
"the",
"longest",
"valid",
"numerical",
"description",
"from",
"a",
"string",
".",
"Not",
"guaranteed",
"to",
"return",
"a",
"result",
"even",
"if",
"some",
"valid",
"numerical",
"description",
"exists",
"(",
"i",
".",
"e",
".",
"method",
"is",
... | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L284-L314 | train | Extracts the longest valid numerical description from a string. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_keys.py | PrivateKey.serialize | def serialize(self, raw=False):
'''Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes
'''
if raw:
return self._key.encode()
return self._key.encode(nacl.encoding.Base64Encoder... | python | def serialize(self, raw=False):
'''Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes
'''
if raw:
return self._key.encode()
return self._key.encode(nacl.encoding.Base64Encoder... | [
"def",
"serialize",
"(",
"self",
",",
"raw",
"=",
"False",
")",
":",
"if",
"raw",
":",
"return",
"self",
".",
"_key",
".",
"encode",
"(",
")",
"return",
"self",
".",
"_key",
".",
"encode",
"(",
"nacl",
".",
"encoding",
".",
"Base64Encoder",
")"
] | Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes | [
"Encode",
"the",
"private",
"part",
"of",
"the",
"key",
"in",
"a",
"base64",
"format",
"by",
"default",
"but",
"when",
"raw",
"is",
"True",
"it",
"will",
"return",
"hex",
"encoded",
"bytes",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_keys.py#L37-L44 | train | Serialize the private part of the key in a base64 format by default. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_keys.py | PublicKey.deserialize | def deserialize(cls, serialized):
''' Create a PublicKey from a base64 encoded bytes.
:return: a PublicKey
'''
return PublicKey(
nacl.public.PublicKey(serialized,
encoder=nacl.encoding.Base64Encoder)) | python | def deserialize(cls, serialized):
''' Create a PublicKey from a base64 encoded bytes.
:return: a PublicKey
'''
return PublicKey(
nacl.public.PublicKey(serialized,
encoder=nacl.encoding.Base64Encoder)) | [
"def",
"deserialize",
"(",
"cls",
",",
"serialized",
")",
":",
"return",
"PublicKey",
"(",
"nacl",
".",
"public",
".",
"PublicKey",
"(",
"serialized",
",",
"encoder",
"=",
"nacl",
".",
"encoding",
".",
"Base64Encoder",
")",
")"
] | Create a PublicKey from a base64 encoded bytes.
:return: a PublicKey | [
"Create",
"a",
"PublicKey",
"from",
"a",
"base64",
"encoded",
"bytes",
".",
":",
"return",
":",
"a",
"PublicKey"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_keys.py#L84-L90 | train | Create a PublicKey from a base64 encoded bytes. |
swevm/scaleio-py | scaleiopy/api/scaleio/common/connection.py | Connection._do_get | def _do_get(self, url, **kwargs):
"""
Convenient method for GET requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_hea... | python | def _do_get(self, url, **kwargs):
"""
Convenient method for GET requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_hea... | [
"def",
"_do_get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"#TODO:",
"# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method",
"scaleioapi_post_headers",
"=",
"{",
"'Content-type'",
":",
"'application/json'"... | Convenient method for GET requests
Returns http request status value from a POST request | [
"Convenient",
"method",
"for",
"GET",
"requests",
"Returns",
"http",
"request",
"status",
"value",
"from",
"a",
"POST",
"request"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/common/connection.py#L104-L125 | train | Convenient method for GET requests returning http request status value from a POST request |
swevm/scaleio-py | scaleiopy/api/scaleio/common/connection.py | Connection._do_post | def _do_post(self, url, **kwargs):
"""
Convenient method for POST requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_h... | python | def _do_post(self, url, **kwargs):
"""
Convenient method for POST requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_h... | [
"def",
"_do_post",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"#TODO:",
"# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method",
"scaleioapi_post_headers",
"=",
"{",
"'Content-type'",
":",
"'application/json'... | Convenient method for POST requests
Returns http request status value from a POST request | [
"Convenient",
"method",
"for",
"POST",
"requests",
"Returns",
"http",
"request",
"status",
"value",
"from",
"a",
"POST",
"request"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/common/connection.py#L127-L148 | train | Convenient method for POST requests Returns http request status value from a POST request |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | discharge_required_response | def discharge_required_response(macaroon, path, cookie_suffix_name,
message=None):
''' Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL p... | python | def discharge_required_response(macaroon, path, cookie_suffix_name,
message=None):
''' Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL p... | [
"def",
"discharge_required_response",
"(",
"macaroon",
",",
"path",
",",
"cookie_suffix_name",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"'discharge required'",
"content",
"=",
"json",
".",
"dumps",
"(",
"{",
... | Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL path to be associated with the macaroon.
The macaroon is potentially valid for all URLs under the given path.
@param... | [
"Get",
"response",
"content",
"and",
"headers",
"from",
"a",
"discharge",
"macaroons",
"error",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L35-L65 | train | Returns a response content and headers that can be used to set a discharge macaroon. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | request_version | def request_version(req_headers):
''' Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardl... | python | def request_version(req_headers):
''' Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardl... | [
"def",
"request_version",
"(",
"req_headers",
")",
":",
"vs",
"=",
"req_headers",
".",
"get",
"(",
"BAKERY_PROTOCOL_HEADER",
")",
"if",
"vs",
"is",
"None",
":",
"# No header - use backward compatibility mode.",
"return",
"bakery",
".",
"VERSION_1",
"try",
":",
"x"... | Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardly compatible.
@param req_headers: the... | [
"Determines",
"the",
"bakery",
"protocol",
"version",
"from",
"a",
"client",
"request",
".",
"If",
"the",
"protocol",
"cannot",
"be",
"determined",
"or",
"is",
"invalid",
"the",
"original",
"version",
"of",
"the",
"protocol",
"is",
"used",
".",
"If",
"a",
... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L75-L97 | train | Determines the bakery protocol version from a client request headers. |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | Error.from_dict | def from_dict(cls, serialized):
'''Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict}
'''
# Some servers return lower case field names for message and code.
# The Go client is tolerant of this, so be similarly tolerant... | python | def from_dict(cls, serialized):
'''Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict}
'''
# Some servers return lower case field names for message and code.
# The Go client is tolerant of this, so be similarly tolerant... | [
"def",
"from_dict",
"(",
"cls",
",",
"serialized",
")",
":",
"# Some servers return lower case field names for message and code.",
"# The Go client is tolerant of this, so be similarly tolerant here.",
"def",
"field",
"(",
"name",
")",
":",
"return",
"serialized",
".",
"get",
... | Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict} | [
"Create",
"an",
"error",
"from",
"a",
"JSON",
"-",
"deserialized",
"object"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L105-L118 | train | Create an error from a JSON - deserialized object holding the serialized error. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.