repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
vladimarius/pyap
pyap/parser.py
AddressParser._get_addresses
def _get_addresses(self, text): '''Returns a list of addresses found in text''' # find addresses addresses = [] matches = utils.findall( self.rules, text, flags=re.VERBOSE | re.U) if(matches): for match in matches: ...
python
def _get_addresses(self, text): '''Returns a list of addresses found in text''' # find addresses addresses = [] matches = utils.findall( self.rules, text, flags=re.VERBOSE | re.U) if(matches): for match in matches: ...
[ "def", "_get_addresses", "(", "self", ",", "text", ")", ":", "# find addresses", "addresses", "=", "[", "]", "matches", "=", "utils", ".", "findall", "(", "self", ".", "rules", ",", "text", ",", "flags", "=", "re", ".", "VERBOSE", "|", "re", ".", "U"...
Returns a list of addresses found in text
[ "Returns", "a", "list", "of", "addresses", "found", "in", "text" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/parser.py#L129-L141
train
58,900
vladimarius/pyap
pyap/api.py
parse
def parse(some_text, **kwargs): """Creates request to AddressParser and returns list of Address objects """ ap = parser.AddressParser(**kwargs) return ap.parse(some_text)
python
def parse(some_text, **kwargs): """Creates request to AddressParser and returns list of Address objects """ ap = parser.AddressParser(**kwargs) return ap.parse(some_text)
[ "def", "parse", "(", "some_text", ",", "*", "*", "kwargs", ")", ":", "ap", "=", "parser", ".", "AddressParser", "(", "*", "*", "kwargs", ")", "return", "ap", ".", "parse", "(", "some_text", ")" ]
Creates request to AddressParser and returns list of Address objects
[ "Creates", "request", "to", "AddressParser", "and", "returns", "list", "of", "Address", "objects" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/api.py#L16-L21
train
58,901
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
setAttribute
def setAttribute(values, value): """ Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type. """ if isinstance(value, int): values.add().int32_value = value elif isinstance(value, float): values.add().doub...
python
def setAttribute(values, value): """ Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type. """ if isinstance(value, int): values.add().int32_value = value elif isinstance(value, float): values.add().doub...
[ "def", "setAttribute", "(", "values", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "values", ".", "add", "(", ")", ".", "int32_value", "=", "value", "elif", "isinstance", "(", "value", ",", "float", ")", ":", "value...
Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type.
[ "Takes", "the", "values", "of", "an", "attribute", "value", "list", "and", "attempts", "to", "append", "attributes", "of", "the", "proper", "type", "inferred", "from", "their", "Python", "type", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L49-L72
train
58,902
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
deepSetAttr
def deepSetAttr(obj, path, val): """ Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`. """ first, _, rest = path.rpartition('.') return setattr(deepGetAttr(obj, first) if first else obj, rest, val)
python
def deepSetAttr(obj, path, val): """ Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`. """ first, _, rest = path.rpartition('.') return setattr(deepGetAttr(obj, first) if first else obj, rest, val)
[ "def", "deepSetAttr", "(", "obj", ",", "path", ",", "val", ")", ":", "first", ",", "_", ",", "rest", "=", "path", ".", "rpartition", "(", "'.'", ")", "return", "setattr", "(", "deepGetAttr", "(", "obj", ",", "first", ")", "if", "first", "else", "ob...
Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`.
[ "Sets", "a", "deep", "attribute", "on", "an", "object", "by", "resolving", "a", "dot", "-", "delimited", "path", ".", "If", "path", "does", "not", "exist", "an", "AttributeError", "will", "be", "raised", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L83-L89
train
58,903
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
convertDatetime
def convertDatetime(t): """ Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch. """ epoch = datetime.datetime.utcfromtimestamp(0) delta = t - epoch millis = delta.total_seconds() * 1000 return int(millis)
python
def convertDatetime(t): """ Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch. """ epoch = datetime.datetime.utcfromtimestamp(0) delta = t - epoch millis = delta.total_seconds() * 1000 return int(millis)
[ "def", "convertDatetime", "(", "t", ")", ":", "epoch", "=", "datetime", ".", "datetime", ".", "utcfromtimestamp", "(", "0", ")", "delta", "=", "t", "-", "epoch", "millis", "=", "delta", ".", "total_seconds", "(", ")", "*", "1000", "return", "int", "(",...
Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch.
[ "Converts", "the", "specified", "datetime", "object", "into", "its", "appropriate", "protocol", "value", ".", "This", "is", "the", "number", "of", "milliseconds", "from", "the", "epoch", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L110-L118
train
58,904
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
getValueFromValue
def getValueFromValue(value): """ Extract the currently set field from a Value structure """ if type(value) != common.AttributeValue: raise TypeError( "Expected an AttributeValue, but got {}".format(type(value))) if value.WhichOneof("value") is None: raise AttributeError(...
python
def getValueFromValue(value): """ Extract the currently set field from a Value structure """ if type(value) != common.AttributeValue: raise TypeError( "Expected an AttributeValue, but got {}".format(type(value))) if value.WhichOneof("value") is None: raise AttributeError(...
[ "def", "getValueFromValue", "(", "value", ")", ":", "if", "type", "(", "value", ")", "!=", "common", ".", "AttributeValue", ":", "raise", "TypeError", "(", "\"Expected an AttributeValue, but got {}\"", ".", "format", "(", "type", "(", "value", ")", ")", ")", ...
Extract the currently set field from a Value structure
[ "Extract", "the", "currently", "set", "field", "from", "a", "Value", "structure" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L121-L130
train
58,905
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
toJson
def toJson(protoObject, indent=None): """ Serialises a protobuf object as json """ # Using the internal method because this way we can reformat the JSON js = json_format.MessageToDict(protoObject, False) return json.dumps(js, indent=indent)
python
def toJson(protoObject, indent=None): """ Serialises a protobuf object as json """ # Using the internal method because this way we can reformat the JSON js = json_format.MessageToDict(protoObject, False) return json.dumps(js, indent=indent)
[ "def", "toJson", "(", "protoObject", ",", "indent", "=", "None", ")", ":", "# Using the internal method because this way we can reformat the JSON", "js", "=", "json_format", ".", "MessageToDict", "(", "protoObject", ",", "False", ")", "return", "json", ".", "dumps", ...
Serialises a protobuf object as json
[ "Serialises", "a", "protobuf", "object", "as", "json" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L133-L139
train
58,906
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
getProtocolClasses
def getProtocolClasses(superclass=message.Message): """ Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol. """ # We keep a manual list of the superclasses that we defin...
python
def getProtocolClasses(superclass=message.Message): """ Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol. """ # We keep a manual list of the superclasses that we defin...
[ "def", "getProtocolClasses", "(", "superclass", "=", "message", ".", "Message", ")", ":", "# We keep a manual list of the superclasses that we define here", "# so we can filter them out when we're getting the protocol", "# classes.", "superclasses", "=", "set", "(", "[", "message...
Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol.
[ "Returns", "all", "the", "protocol", "classes", "that", "are", "subclasses", "of", "the", "specified", "superclass", ".", "Only", "leaf", "classes", "are", "returned", "corresponding", "directly", "to", "the", "classes", "defined", "in", "the", "protocol", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L170-L187
train
58,907
ga4gh/ga4gh-schemas
scripts/process_schemas.py
runCommandSplits
def runCommandSplits(splits, silent=False, shell=False): """ Run a shell command given the command's parsed command line """ try: if silent: with open(os.devnull, 'w') as devnull: subprocess.check_call( splits, stdout=devnull, stderr=devnull, shell...
python
def runCommandSplits(splits, silent=False, shell=False): """ Run a shell command given the command's parsed command line """ try: if silent: with open(os.devnull, 'w') as devnull: subprocess.check_call( splits, stdout=devnull, stderr=devnull, shell...
[ "def", "runCommandSplits", "(", "splits", ",", "silent", "=", "False", ",", "shell", "=", "False", ")", ":", "try", ":", "if", "silent", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "subprocess", ".", "check_...
Run a shell command given the command's parsed command line
[ "Run", "a", "shell", "command", "given", "the", "command", "s", "parsed", "command", "line" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L30-L46
train
58,908
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._createSchemaFiles
def _createSchemaFiles(self, destPath, schemasPath): """ Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy """ # Create the target directory hierarchy, if neccessary ga4ghPath = os.path.join(destPath, 'ga4gh') if n...
python
def _createSchemaFiles(self, destPath, schemasPath): """ Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy """ # Create the target directory hierarchy, if neccessary ga4ghPath = os.path.join(destPath, 'ga4gh') if n...
[ "def", "_createSchemaFiles", "(", "self", ",", "destPath", ",", "schemasPath", ")", ":", "# Create the target directory hierarchy, if neccessary", "ga4ghPath", "=", "os", ".", "path", ".", "join", "(", "destPath", ",", "'ga4gh'", ")", "if", "not", "os", ".", "pa...
Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy
[ "Create", "a", "hierarchy", "of", "proto", "files", "in", "a", "destination", "directory", "copied", "from", "the", "schemasPath", "hierarchy" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L64-L94
train
58,909
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._doLineReplacements
def _doLineReplacements(self, line): """ Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile """ # ga4gh packages packageString = 'package ga4gh;' if packageString in line: return line.r...
python
def _doLineReplacements(self, line): """ Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile """ # ga4gh packages packageString = 'package ga4gh;' if packageString in line: return line.r...
[ "def", "_doLineReplacements", "(", "self", ",", "line", ")", ":", "# ga4gh packages", "packageString", "=", "'package ga4gh;'", "if", "packageString", "in", "line", ":", "return", "line", ".", "replace", "(", "packageString", ",", "'package ga4gh.schemas.ga4gh;'", "...
Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile
[ "Given", "a", "line", "of", "a", "proto", "file", "replace", "the", "line", "with", "one", "that", "is", "appropriate", "for", "the", "hierarchy", "that", "we", "want", "to", "compile" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L96-L128
train
58,910
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._copySchemaFile
def _copySchemaFile(self, src, dst): """ Copy a proto file to the temporary directory, with appropriate line replacements """ with open(src) as srcFile, open(dst, 'w') as dstFile: srcLines = srcFile.readlines() for srcLine in srcLines: toWr...
python
def _copySchemaFile(self, src, dst): """ Copy a proto file to the temporary directory, with appropriate line replacements """ with open(src) as srcFile, open(dst, 'w') as dstFile: srcLines = srcFile.readlines() for srcLine in srcLines: toWr...
[ "def", "_copySchemaFile", "(", "self", ",", "src", ",", "dst", ")", ":", "with", "open", "(", "src", ")", "as", "srcFile", ",", "open", "(", "dst", ",", "'w'", ")", "as", "dstFile", ":", "srcLines", "=", "srcFile", ".", "readlines", "(", ")", "for"...
Copy a proto file to the temporary directory, with appropriate line replacements
[ "Copy", "a", "proto", "file", "to", "the", "temporary", "directory", "with", "appropriate", "line", "replacements" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L130-L139
train
58,911
ga4gh/ga4gh-schemas
tools/sphinx/protobuf-json-docs.py
convert_protodef_to_editable
def convert_protodef_to_editable(proto): """ Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so """ class Editable(object): def __init__(self, prot): self.kind = type(prot) ...
python
def convert_protodef_to_editable(proto): """ Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so """ class Editable(object): def __init__(self, prot): self.kind = type(prot) ...
[ "def", "convert_protodef_to_editable", "(", "proto", ")", ":", "class", "Editable", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "prot", ")", ":", "self", ".", "kind", "=", "type", "(", "prot", ")", "self", ".", "name", "=", "prot", ...
Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so
[ "Protobuf", "objects", "can", "t", "have", "arbitrary", "fields", "addedd", "and", "we", "need", "to", "later", "on", "add", "comments", "to", "them", "so", "we", "instead", "make", "Editable", "objects", "that", "can", "do", "so" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/tools/sphinx/protobuf-json-docs.py#L25-L58
train
58,912
mapado/haversine
haversine/haversine.py
haversine
def haversine(point1, point2, unit='km'): """ Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurem...
python
def haversine(point1, point2, unit='km'): """ Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurem...
[ "def", "haversine", "(", "point1", ",", "point2", ",", "unit", "=", "'km'", ")", ":", "# mean earth radius - https://en.wikipedia.org/wiki/Earth_radius#Mean_radius", "AVG_EARTH_RADIUS_KM", "=", "6371.0088", "# Units values taken from http://www.unitconversion.org/unit_converter/lengt...
Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurement (i.e. miles = mi) default 'km' (ki...
[ "Calculate", "the", "great", "-", "circle", "distance", "between", "two", "points", "on", "the", "Earth", "surface", "." ]
221d9ebd368b4e035873aaa57bd42d98e1d83282
https://github.com/mapado/haversine/blob/221d9ebd368b4e035873aaa57bd42d98e1d83282/haversine/haversine.py#L4-L50
train
58,913
Illumina/interop
src/examples/python/summary.py
main
def main(): """ Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read """ logging.basicConfig(level=logging.INFO) run_metrics = py_interop_run_metrics.run_metrics...
python
def main(): """ Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read """ logging.basicConfig(level=logging.INFO) run_metrics = py_interop_run_metrics.run_metrics...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ")", "run_metrics", "=", "py_interop_run_metrics", ".", "run_metrics", "(", ")", "summary", "=", "py_interop_summary", ".", "run_summary", "(", ")", "vali...
Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read
[ "Retrieve", "run", "folder", "paths", "from", "the", "command", "line", "Ensure", "only", "metrics", "required", "for", "summary", "are", "loaded", "Load", "the", "run", "metrics", "Calculate", "the", "summary", "metrics", "Display", "error", "by", "lane", "re...
a55b40bde4b764e3652758f6cdf72aef5f473370
https://github.com/Illumina/interop/blob/a55b40bde4b764e3652758f6cdf72aef5f473370/src/examples/python/summary.py#L17-L49
train
58,914
SteveMcGrath/pySecurityCenter
examples/sc4/csv_gen/sccsv/generator.py
gen_csv
def gen_csv(sc, filename, field_list, source, filters): '''csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) header = [] ...
python
def gen_csv(sc, filename, field_list, source, filters): '''csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) header = [] ...
[ "def", "gen_csv", "(", "sc", ",", "filename", ",", "field_list", ",", "source", ",", "filters", ")", ":", "# First thing we need to do is initialize the csvfile and build the header", "# for the file.", "datafile", "=", "open", "(", "filename", ",", "'wb'", ")", "csvf...
csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress
[ "csv", "SecurityCenterObj", "AssetListName", "CSVFields", "EmailAddress" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/csv_gen/sccsv/generator.py#L46-L70
train
58,915
SteveMcGrath/pySecurityCenter
securitycenter/sc5.py
SecurityCenter5.login
def login(self, user, passwd): '''Logs the user into SecurityCenter and stores the needed token and cookies.''' resp = self.post('token', json={'username': user, 'password': passwd}) self._token = resp.json()['response']['token']
python
def login(self, user, passwd): '''Logs the user into SecurityCenter and stores the needed token and cookies.''' resp = self.post('token', json={'username': user, 'password': passwd}) self._token = resp.json()['response']['token']
[ "def", "login", "(", "self", ",", "user", ",", "passwd", ")", ":", "resp", "=", "self", ".", "post", "(", "'token'", ",", "json", "=", "{", "'username'", ":", "user", ",", "'password'", ":", "passwd", "}", ")", "self", ".", "_token", "=", "resp", ...
Logs the user into SecurityCenter and stores the needed token and cookies.
[ "Logs", "the", "user", "into", "SecurityCenter", "and", "stores", "the", "needed", "token", "and", "cookies", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc5.py#L42-L45
train
58,916
SteveMcGrath/pySecurityCenter
examples/sc5/download_scans/downloader.py
download_scans
def download_scans(sc, age=0, unzip=False, path='scans'): '''Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress...
python
def download_scans(sc, age=0, unzip=False, path='scans'): '''Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress...
[ "def", "download_scans", "(", "sc", ",", "age", "=", "0", ",", "unzip", "=", "False", ",", "path", "=", "'scans'", ")", ":", "# if the download path doesn't exist, we need to create it.", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", ...
Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress the nessus files? (default: False) path = Path where the res...
[ "Scan", "Downloader", "Here", "we", "will", "attempt", "to", "download", "all", "of", "the", "scans", "that", "have", "completed", "between", "now", "and", "AGE", "days", "ago", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/download_scans/downloader.py#L15-L79
train
58,917
SteveMcGrath/pySecurityCenter
examples/sc4/populate_asset_list/dns_populate.py
update
def update(sc, filename, asset_id): ''' Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter. ''' addresses = [] ...
python
def update(sc, filename, asset_id): ''' Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter. ''' addresses = [] ...
[ "def", "update", "(", "sc", ",", "filename", ",", "asset_id", ")", ":", "addresses", "=", "[", "]", "with", "open", "(", "filename", ")", "as", "hostfile", ":", "for", "line", "in", "hostfile", ".", "readlines", "(", ")", ":", "addresses", ".", "appe...
Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter.
[ "Updates", "a", "DNS", "Asset", "List", "with", "the", "contents", "of", "the", "filename", ".", "The", "assumed", "format", "of", "the", "file", "is", "1", "entry", "per", "line", ".", "This", "function", "will", "convert", "the", "file", "contents", "i...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/populate_asset_list/dns_populate.py#L9-L20
train
58,918
SteveMcGrath/pySecurityCenter
examples/sc5/software_change/swchange/reporter.py
generate_html_report
def generate_html_report(base_path, asset_id): ''' Generates the HTML report and dumps it into the specified filename ''' jenv = Environment(loader=PackageLoader('swchange', 'templates')) s = Session() #hosts = s.query(Host).filter_by(asset_id=asset_id).all() asset = s.query(AssetList).filte...
python
def generate_html_report(base_path, asset_id): ''' Generates the HTML report and dumps it into the specified filename ''' jenv = Environment(loader=PackageLoader('swchange', 'templates')) s = Session() #hosts = s.query(Host).filter_by(asset_id=asset_id).all() asset = s.query(AssetList).filte...
[ "def", "generate_html_report", "(", "base_path", ",", "asset_id", ")", ":", "jenv", "=", "Environment", "(", "loader", "=", "PackageLoader", "(", "'swchange'", ",", "'templates'", ")", ")", "s", "=", "Session", "(", ")", "#hosts = s.query(Host).filter_by(asset_id=...
Generates the HTML report and dumps it into the specified filename
[ "Generates", "the", "HTML", "report", "and", "dumps", "it", "into", "the", "specified", "filename" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/software_change/swchange/reporter.py#L7-L27
train
58,919
SteveMcGrath/pySecurityCenter
examples/sc4/gen_software_report/sccsv/generator.py
gen_csv
def gen_csv(sc, filename): '''csv SecurityCenterObj, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) csvfile.writerow(['Software Package Name', 'Count']) debug.wri...
python
def gen_csv(sc, filename): '''csv SecurityCenterObj, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) csvfile.writerow(['Software Package Name', 'Count']) debug.wri...
[ "def", "gen_csv", "(", "sc", ",", "filename", ")", ":", "# First thing we need to do is initialize the csvfile and build the header", "# for the file.", "datafile", "=", "open", "(", "filename", ",", "'wb'", ")", "csvfile", "=", "csv", ".", "writer", "(", "datafile", ...
csv SecurityCenterObj, EmailAddress
[ "csv", "SecurityCenterObj", "EmailAddress" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/gen_software_report/sccsv/generator.py#L17-L37
train
58,920
SteveMcGrath/pySecurityCenter
examples/sc5/download_reports/report_downloader.py
download
def download(sc, age=0, path='reports', **args): '''Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the ...
python
def download(sc, age=0, path='reports', **args): '''Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the ...
[ "def", "download", "(", "sc", ",", "age", "=", "0", ",", "path", "=", "'reports'", ",", "*", "*", "args", ")", ":", "# if the download path doesn't exist, we need to create it.", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "logger...
Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the search. path = The path to the dow...
[ "Report", "Downloader", "The", "report", "downloader", "will", "pull", "reports", "down", "from", "SecurityCenter", "based", "on", "the", "conditions", "provided", "to", "the", "path", "provided", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/download_reports/report_downloader.py#L11-L76
train
58,921
SteveMcGrath/pySecurityCenter
securitycenter/base.py
BaseAPI.post
def post(self, path, **kwargs): '''Calls the specified path with the POST method''' resp = self._session.post(self._url(path), **self._builder(**kwargs)) if 'stream' in kwargs: return resp else: return self._resp_error_check(resp)
python
def post(self, path, **kwargs): '''Calls the specified path with the POST method''' resp = self._session.post(self._url(path), **self._builder(**kwargs)) if 'stream' in kwargs: return resp else: return self._resp_error_check(resp)
[ "def", "post", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "self", ".", "_session", ".", "post", "(", "self", ".", "_url", "(", "path", ")", ",", "*", "*", "self", ".", "_builder", "(", "*", "*", "kwargs", ")", "...
Calls the specified path with the POST method
[ "Calls", "the", "specified", "path", "with", "the", "POST", "method" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/base.py#L90-L96
train
58,922
SteveMcGrath/pySecurityCenter
examples/sc5/import_repo/import_repo.py
ExtendedSecurityCenter.import_repo
def import_repo(self, repo_id, fileobj): ''' Imports a repository package using the repository ID specified. ''' # Step 1, lets upload the file filename = self.upload(fileobj).json()['response']['filename'] # Step 2, lets tell SecurityCenter what to do with the file ...
python
def import_repo(self, repo_id, fileobj): ''' Imports a repository package using the repository ID specified. ''' # Step 1, lets upload the file filename = self.upload(fileobj).json()['response']['filename'] # Step 2, lets tell SecurityCenter what to do with the file ...
[ "def", "import_repo", "(", "self", ",", "repo_id", ",", "fileobj", ")", ":", "# Step 1, lets upload the file", "filename", "=", "self", ".", "upload", "(", "fileobj", ")", ".", "json", "(", ")", "[", "'response'", "]", "[", "'filename'", "]", "# Step 2, lets...
Imports a repository package using the repository ID specified.
[ "Imports", "a", "repository", "package", "using", "the", "repository", "ID", "specified", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/import_repo/import_repo.py#L6-L14
train
58,923
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._revint
def _revint(self, version): ''' Internal function to convert a version string to an integer. ''' intrev = 0 vsplit = version.split('.') for c in range(len(vsplit)): item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2))) intrev += item ...
python
def _revint(self, version): ''' Internal function to convert a version string to an integer. ''' intrev = 0 vsplit = version.split('.') for c in range(len(vsplit)): item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2))) intrev += item ...
[ "def", "_revint", "(", "self", ",", "version", ")", ":", "intrev", "=", "0", "vsplit", "=", "version", ".", "split", "(", "'.'", ")", "for", "c", "in", "range", "(", "len", "(", "vsplit", ")", ")", ":", "item", "=", "int", "(", "vsplit", "[", "...
Internal function to convert a version string to an integer.
[ "Internal", "function", "to", "convert", "a", "version", "string", "to", "an", "integer", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L41-L50
train
58,924
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._revcheck
def _revcheck(self, func, version): ''' Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist. ''' current...
python
def _revcheck(self, func, version): ''' Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist. ''' current...
[ "def", "_revcheck", "(", "self", ",", "func", ",", "version", ")", ":", "current", "=", "self", ".", "_revint", "(", "self", ".", "version", ")", "check", "=", "self", ".", "_revint", "(", "version", ")", "if", "func", "in", "(", "'lt'", ",", "'<='...
Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist.
[ "Internal", "function", "to", "see", "if", "a", "version", "is", "func", "than", "what", "we", "have", "determined", "to", "be", "talking", "to", ".", "This", "is", "very", "useful", "for", "newer", "API", "calls", "to", "make", "sure", "we", "don", "t...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L52-L68
train
58,925
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._build_xrefs
def _build_xrefs(self): ''' Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well. ''' xrefs = set() plugins = self.plugins() for plugin in plugins: fo...
python
def _build_xrefs(self): ''' Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well. ''' xrefs = set() plugins = self.plugins() for plugin in plugins: fo...
[ "def", "_build_xrefs", "(", "self", ")", ":", "xrefs", "=", "set", "(", ")", "plugins", "=", "self", ".", "plugins", "(", ")", "for", "plugin", "in", "plugins", ":", "for", "xref", "in", "plugin", "[", "'xrefs'", "]", ".", "split", "(", "', '", ")"...
Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well.
[ "Internal", "function", "to", "populate", "the", "xrefs", "list", "with", "the", "external", "references", "to", "be", "used", "in", "searching", "plugins", "and", "potentially", "other", "functions", "as", "well", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L70-L84
train
58,926
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.login
def login(self, user, passwd): """login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries. """ data = self.raw_query('auth', 'login', da...
python
def login(self, user, passwd): """login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries. """ data = self.raw_query('auth', 'login', da...
[ "def", "login", "(", "self", ",", "user", ",", "passwd", ")", ":", "data", "=", "self", ".", "raw_query", "(", "'auth'", ",", "'login'", ",", "data", "=", "{", "'username'", ":", "user", ",", "'password'", ":", "passwd", "}", ")", "self", ".", "_to...
login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries.
[ "login", "user", "passwd", "Performs", "the", "login", "operation", "for", "Security", "Center", "storing", "the", "token", "that", "Security", "Center", "has", "generated", "for", "this", "login", "session", "for", "future", "queries", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L259-L268
train
58,927
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_add
def credential_add(self, name, cred_type, **options): ''' Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be ...
python
def credential_add(self, name, cred_type, **options): ''' Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be ...
[ "def", "credential_add", "(", "self", ",", "name", ",", "cred_type", ",", "*", "*", "options", ")", ":", "if", "'pirvateKey'", "in", "options", ":", "options", "[", "'privateKey'", "]", "=", "self", ".", "_upload", "(", "options", "[", "'privateKey'", "]...
Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be associated to this credential :param cred_type: The type of creden...
[ "Adds", "a", "new", "credential", "into", "SecurityCenter", ".", "As", "credentials", "can", "be", "of", "multiple", "types", "we", "have", "different", "options", "to", "specify", "for", "each", "type", "of", "credential", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L419-L527
train
58,928
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_delete_simulate
def credential_delete_simulate(self, *ids): """Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "deleteSimulate", data={ "credentials": [{"id": str(id)} for id in ids] ...
python
def credential_delete_simulate(self, *ids): """Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "deleteSimulate", data={ "credentials": [{"id": str(id)} for id in ids] ...
[ "def", "credential_delete_simulate", "(", "self", ",", "*", "ids", ")", ":", "return", "self", ".", "raw_query", "(", "\"credential\"", ",", "\"deleteSimulate\"", ",", "data", "=", "{", "\"credentials\"", ":", "[", "{", "\"id\"", ":", "str", "(", "id", ")"...
Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids
[ "Show", "the", "relationships", "and", "dependencies", "for", "one", "or", "more", "credentials", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L551-L558
train
58,929
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_delete
def credential_delete(self, *ids): """Delete one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "delete", data={ "credentials": [{"id": str(id)} for id in ids] })
python
def credential_delete(self, *ids): """Delete one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "delete", data={ "credentials": [{"id": str(id)} for id in ids] })
[ "def", "credential_delete", "(", "self", ",", "*", "ids", ")", ":", "return", "self", ".", "raw_query", "(", "\"credential\"", ",", "\"delete\"", ",", "data", "=", "{", "\"credentials\"", ":", "[", "{", "\"id\"", ":", "str", "(", "id", ")", "}", "for",...
Delete one or more credentials. :param ids: one or more credential ids
[ "Delete", "one", "or", "more", "credentials", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L560-L567
train
58,930
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.plugins
def plugins(self, plugin_type='all', sort='id', direction='asc', size=1000, offset=0, all=True, loops=0, since=None, **filterset): """plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into th...
python
def plugins(self, plugin_type='all', sort='id', direction='asc', size=1000, offset=0, all=True, loops=0, since=None, **filterset): """plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into th...
[ "def", "plugins", "(", "self", ",", "plugin_type", "=", "'all'", ",", "sort", "=", "'id'", ",", "direction", "=", "'asc'", ",", "size", "=", "1000", ",", "offset", "=", "0", ",", "all", "=", "True", ",", "loops", "=", "0", ",", "since", "=", "Non...
plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into the plugin data so that only 1 list is returned back with all of the information.
[ "plugins", "Returns", "a", "list", "of", "of", "the", "plugins", "and", "their", "associated", "families", ".", "For", "simplicity", "purposes", "the", "plugin", "family", "names", "will", "be", "injected", "into", "the", "plugin", "data", "so", "that", "onl...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L569-L639
train
58,931
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.plugin_counts
def plugin_counts(self): """plugin_counts Returns the plugin counts as dictionary with the last updated info if its available. """ ret = { 'total': 0, } # As ususal, we need data before we can actually do anything ;) data = self.raw_query('plu...
python
def plugin_counts(self): """plugin_counts Returns the plugin counts as dictionary with the last updated info if its available. """ ret = { 'total': 0, } # As ususal, we need data before we can actually do anything ;) data = self.raw_query('plu...
[ "def", "plugin_counts", "(", "self", ")", ":", "ret", "=", "{", "'total'", ":", "0", ",", "}", "# As ususal, we need data before we can actually do anything ;)", "data", "=", "self", ".", "raw_query", "(", "'plugin'", ",", "'init'", ")", "# For backwards compatabili...
plugin_counts Returns the plugin counts as dictionary with the last updated info if its available.
[ "plugin_counts", "Returns", "the", "plugin", "counts", "as", "dictionary", "with", "the", "last", "updated", "info", "if", "its", "available", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L641-L671
train
58,932
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.ip_info
def ip_info(self, ip, repository_ids=None): """ip_info Returns information about the IP specified in the repository ids defined. """ if not repository_ids: repository_ids = [] repos = [] for rid in repository_ids: repos.append({'id': rid}) ...
python
def ip_info(self, ip, repository_ids=None): """ip_info Returns information about the IP specified in the repository ids defined. """ if not repository_ids: repository_ids = [] repos = [] for rid in repository_ids: repos.append({'id': rid}) ...
[ "def", "ip_info", "(", "self", ",", "ip", ",", "repository_ids", "=", "None", ")", ":", "if", "not", "repository_ids", ":", "repository_ids", "=", "[", "]", "repos", "=", "[", "]", "for", "rid", "in", "repository_ids", ":", "repos", ".", "append", "(",...
ip_info Returns information about the IP specified in the repository ids defined.
[ "ip_info", "Returns", "information", "about", "the", "IP", "specified", "in", "the", "repository", "ids", "defined", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L717-L728
train
58,933
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.scan_list
def scan_list(self, start_time=None, end_time=None, **kwargs): """List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not ...
python
def scan_list(self, start_time=None, end_time=None, **kwargs): """List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not ...
[ "def", "scan_list", "(", "self", ",", "start_time", "=", "None", ",", "end_time", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "end_time", "=", "datetime", ".", "utcfromtimestamp", "(", "int", "(", "end_time", ")", ")", "except", "TypeEr...
List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not specified it is 30 days previous from `end_time`. :param start_ti...
[ "List", "scans", "stored", "in", "Security", "Center", "in", "a", "given", "time", "range", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L736-L769
train
58,934
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.dashboard_import
def dashboard_import(self, name, fileobj): """dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(fileobj) return self.raw_query('...
python
def dashboard_import(self, name, fileobj): """dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(fileobj) return self.raw_query('...
[ "def", "dashboard_import", "(", "self", ",", "name", ",", "fileobj", ")", ":", "data", "=", "self", ".", "_upload", "(", "fileobj", ")", "return", "self", ".", "raw_query", "(", "'dashboard'", ",", "'importTab'", ",", "data", "=", "{", "'filename'", ":",...
dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable.
[ "dashboard_import", "Dashboard_Name", "filename", "Uploads", "a", "dashboard", "template", "to", "the", "current", "user", "s", "dashboard", "tabs", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L801-L811
train
58,935
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.report_import
def report_import(self, name, filename): """report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(filename) return self.raw_query('report', 'import',...
python
def report_import(self, name, filename): """report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(filename) return self.raw_query('report', 'import',...
[ "def", "report_import", "(", "self", ",", "name", ",", "filename", ")", ":", "data", "=", "self", ".", "_upload", "(", "filename", ")", "return", "self", ".", "raw_query", "(", "'report'", ",", "'import'", ",", "data", "=", "{", "'filename'", ":", "dat...
report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable.
[ "report_import", "Report_Name", "filename", "Uploads", "a", "report", "template", "to", "the", "current", "user", "s", "reports" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L813-L823
train
58,936
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.asset_create
def asset_create(self, name, items, tag='', description='', atype='static'): '''asset_create_static name, ips, tags, description Create a new asset list with the defined information. UN-DOCUMENTED CALL: This function is not considered stable. :param name: asset list name (must be uniqu...
python
def asset_create(self, name, items, tag='', description='', atype='static'): '''asset_create_static name, ips, tags, description Create a new asset list with the defined information. UN-DOCUMENTED CALL: This function is not considered stable. :param name: asset list name (must be uniqu...
[ "def", "asset_create", "(", "self", ",", "name", ",", "items", ",", "tag", "=", "''", ",", "description", "=", "''", ",", "atype", "=", "'static'", ")", ":", "data", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "description", ",", "'ty...
asset_create_static name, ips, tags, description Create a new asset list with the defined information. UN-DOCUMENTED CALL: This function is not considered stable. :param name: asset list name (must be unique) :type name: string :param items: list of IP Addresses, CIDR, and Netw...
[ "asset_create_static", "name", "ips", "tags", "description", "Create", "a", "new", "asset", "list", "with", "the", "defined", "information", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L837-L863
train
58,937
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.asset_create_combo
def asset_create_combo(self, name, combo, tag='', description=''): '''asset_create_combo name, combination, tag, description Creates a new combination asset list. Operands can be either asset list IDs or be a nested combination asset list. UN-DOCUMENTED CALL: This function is not consi...
python
def asset_create_combo(self, name, combo, tag='', description=''): '''asset_create_combo name, combination, tag, description Creates a new combination asset list. Operands can be either asset list IDs or be a nested combination asset list. UN-DOCUMENTED CALL: This function is not consi...
[ "def", "asset_create_combo", "(", "self", ",", "name", ",", "combo", ",", "tag", "=", "''", ",", "description", "=", "''", ")", ":", "return", "self", ".", "raw_query", "(", "'asset'", ",", "'add'", ",", "data", "=", "{", "'name'", ":", "name", ",", ...
asset_create_combo name, combination, tag, description Creates a new combination asset list. Operands can be either asset list IDs or be a nested combination asset list. UN-DOCUMENTED CALL: This function is not considered stable. AND = intersection OR = union operand =...
[ "asset_create_combo", "name", "combination", "tag", "description", "Creates", "a", "new", "combination", "asset", "list", ".", "Operands", "can", "be", "either", "asset", "list", "IDs", "or", "be", "a", "nested", "combination", "asset", "list", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L866-L904
train
58,938
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.risk_rule
def risk_rule(self, rule_type, rule_value, port, proto, plugin_id, repo_ids, comment='', expires='-1', severity=None): '''accept_risk rule_type, rule_value, port, proto, plugin_id, comment Creates an accept rick rule based on information provided. UN-DOCUMENTED CALL: This func...
python
def risk_rule(self, rule_type, rule_value, port, proto, plugin_id, repo_ids, comment='', expires='-1', severity=None): '''accept_risk rule_type, rule_value, port, proto, plugin_id, comment Creates an accept rick rule based on information provided. UN-DOCUMENTED CALL: This func...
[ "def", "risk_rule", "(", "self", ",", "rule_type", ",", "rule_value", ",", "port", ",", "proto", ",", "plugin_id", ",", "repo_ids", ",", "comment", "=", "''", ",", "expires", "=", "'-1'", ",", "severity", "=", "None", ")", ":", "data", "=", "{", "'ho...
accept_risk rule_type, rule_value, port, proto, plugin_id, comment Creates an accept rick rule based on information provided. UN-DOCUMENTED CALL: This function is not considered stable. :param rule_type: Valid options: ip, asset, all. :type rule_type: string :param rule_value: ...
[ "accept_risk", "rule_type", "rule_value", "port", "proto", "plugin_id", "comment", "Creates", "an", "accept", "rick", "rule", "based", "on", "information", "provided", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L907-L948
train
58,939
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.group_add
def group_add(self, name, restrict, repos, lces=[], assets=[], queries=[], policies=[], dashboards=[], credentials=[], description=''): '''group_add name, restrict, repos ''' return self.raw_query('group', 'add', data={ 'lces': [{'id': i} for i in lces], ...
python
def group_add(self, name, restrict, repos, lces=[], assets=[], queries=[], policies=[], dashboards=[], credentials=[], description=''): '''group_add name, restrict, repos ''' return self.raw_query('group', 'add', data={ 'lces': [{'id': i} for i in lces], ...
[ "def", "group_add", "(", "self", ",", "name", ",", "restrict", ",", "repos", ",", "lces", "=", "[", "]", ",", "assets", "=", "[", "]", ",", "queries", "=", "[", "]", ",", "policies", "=", "[", "]", ",", "dashboards", "=", "[", "]", ",", "creden...
group_add name, restrict, repos
[ "group_add", "name", "restrict", "repos" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L951-L968
train
58,940
ozak/georasters
georasters/georasters.py
get_geo_info
def get_geo_info(filename, band=1): ''' Gets information from a Raster data set ''' sourceds = gdal.Open(filename, GA_ReadOnly) ndv = sourceds.GetRasterBand(band).GetNoDataValue() xsize = sourceds.RasterXSize ysize = sourceds.RasterYSize geot = sourceds.GetGeoTransform() projection = osr...
python
def get_geo_info(filename, band=1): ''' Gets information from a Raster data set ''' sourceds = gdal.Open(filename, GA_ReadOnly) ndv = sourceds.GetRasterBand(band).GetNoDataValue() xsize = sourceds.RasterXSize ysize = sourceds.RasterYSize geot = sourceds.GetGeoTransform() projection = osr...
[ "def", "get_geo_info", "(", "filename", ",", "band", "=", "1", ")", ":", "sourceds", "=", "gdal", ".", "Open", "(", "filename", ",", "GA_ReadOnly", ")", "ndv", "=", "sourceds", ".", "GetRasterBand", "(", "band", ")", ".", "GetNoDataValue", "(", ")", "x...
Gets information from a Raster data set
[ "Gets", "information", "from", "a", "Raster", "data", "set" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L48-L60
train
58,941
ozak/georasters
georasters/georasters.py
create_geotiff
def create_geotiff(name, Array, driver, ndv, xsize, ysize, geot, projection, datatype, band=1): ''' Creates new geotiff from array ''' if isinstance(datatype, np.int) == False: if datatype.startswith('gdal.GDT_') == False: datatype = eval('gdal.GDT_'+datatype) newfilename = name+...
python
def create_geotiff(name, Array, driver, ndv, xsize, ysize, geot, projection, datatype, band=1): ''' Creates new geotiff from array ''' if isinstance(datatype, np.int) == False: if datatype.startswith('gdal.GDT_') == False: datatype = eval('gdal.GDT_'+datatype) newfilename = name+...
[ "def", "create_geotiff", "(", "name", ",", "Array", ",", "driver", ",", "ndv", ",", "xsize", ",", "ysize", ",", "geot", ",", "projection", ",", "datatype", ",", "band", "=", "1", ")", ":", "if", "isinstance", "(", "datatype", ",", "np", ".", "int", ...
Creates new geotiff from array
[ "Creates", "new", "geotiff", "from", "array" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L137-L155
train
58,942
ozak/georasters
georasters/georasters.py
load_tiff
def load_tiff(file): """ Load a geotiff raster keeping ndv values using a masked array Usage: data = load_tiff(file) """ ndv, xsize, ysize, geot, projection, datatype = get_geo_info(file) data = gdalnumeric.LoadFile(file) data = np.ma.masked_array(data, mask=data == ndv, fill_va...
python
def load_tiff(file): """ Load a geotiff raster keeping ndv values using a masked array Usage: data = load_tiff(file) """ ndv, xsize, ysize, geot, projection, datatype = get_geo_info(file) data = gdalnumeric.LoadFile(file) data = np.ma.masked_array(data, mask=data == ndv, fill_va...
[ "def", "load_tiff", "(", "file", ")", ":", "ndv", ",", "xsize", ",", "ysize", ",", "geot", ",", "projection", ",", "datatype", "=", "get_geo_info", "(", "file", ")", "data", "=", "gdalnumeric", ".", "LoadFile", "(", "file", ")", "data", "=", "np", "....
Load a geotiff raster keeping ndv values using a masked array Usage: data = load_tiff(file)
[ "Load", "a", "geotiff", "raster", "keeping", "ndv", "values", "using", "a", "masked", "array" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L231-L241
train
58,943
ozak/georasters
georasters/georasters.py
from_file
def from_file(filename, **kwargs): """ Create a GeoRaster object from a file """ ndv, xsize, ysize, geot, projection, datatype = get_geo_info(filename, **kwargs) data = gdalnumeric.LoadFile(filename, **kwargs) data = np.ma.masked_array(data, mask=data == ndv, fill_value=ndv) return GeoRaster...
python
def from_file(filename, **kwargs): """ Create a GeoRaster object from a file """ ndv, xsize, ysize, geot, projection, datatype = get_geo_info(filename, **kwargs) data = gdalnumeric.LoadFile(filename, **kwargs) data = np.ma.masked_array(data, mask=data == ndv, fill_value=ndv) return GeoRaster...
[ "def", "from_file", "(", "filename", ",", "*", "*", "kwargs", ")", ":", "ndv", ",", "xsize", ",", "ysize", ",", "geot", ",", "projection", ",", "datatype", "=", "get_geo_info", "(", "filename", ",", "*", "*", "kwargs", ")", "data", "=", "gdalnumeric", ...
Create a GeoRaster object from a file
[ "Create", "a", "GeoRaster", "object", "from", "a", "file" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L1250-L1257
train
58,944
ozak/georasters
georasters/georasters.py
GeoRaster.copy
def copy(self): """Returns copy of itself""" return GeoRaster(self.raster.copy(), self.geot, nodata_value=self.nodata_value, projection=self.projection, datatype=self.datatype)
python
def copy(self): """Returns copy of itself""" return GeoRaster(self.raster.copy(), self.geot, nodata_value=self.nodata_value, projection=self.projection, datatype=self.datatype)
[ "def", "copy", "(", "self", ")", ":", "return", "GeoRaster", "(", "self", ".", "raster", ".", "copy", "(", ")", ",", "self", ".", "geot", ",", "nodata_value", "=", "self", ".", "nodata_value", ",", "projection", "=", "self", ".", "projection", ",", "...
Returns copy of itself
[ "Returns", "copy", "of", "itself" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L477-L480
train
58,945
ozak/georasters
georasters/georasters.py
GeoRaster.clip
def clip(self, shp, keep=False, *args, **kwargs): ''' Clip raster using shape, where shape is either a GeoPandas DataFrame, shapefile, or some other geometry format used by python-raster-stats Returns list of GeoRasters or Pandas DataFrame with GeoRasters and additional information ...
python
def clip(self, shp, keep=False, *args, **kwargs): ''' Clip raster using shape, where shape is either a GeoPandas DataFrame, shapefile, or some other geometry format used by python-raster-stats Returns list of GeoRasters or Pandas DataFrame with GeoRasters and additional information ...
[ "def", "clip", "(", "self", ",", "shp", ",", "keep", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "zonal_stats", "(", "shp", ",", "self", ".", "raster", ",", "nodata", "=", "self", "...
Clip raster using shape, where shape is either a GeoPandas DataFrame, shapefile, or some other geometry format used by python-raster-stats Returns list of GeoRasters or Pandas DataFrame with GeoRasters and additional information Usage: clipped = geo.clip(shape, keep=False) wh...
[ "Clip", "raster", "using", "shape", "where", "shape", "is", "either", "a", "GeoPandas", "DataFrame", "shapefile", "or", "some", "other", "geometry", "format", "used", "by", "python", "-", "raster", "-", "stats" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L706-L742
train
58,946
ozak/georasters
georasters/georasters.py
GeoRaster.pysal_Gamma
def pysal_Gamma(self, **kwargs): """ Compute Gamma Index of Spatial Autocorrelation for GeoRaster Usage: geo.pysal_Gamma(permutations = 1000, rook=True, operation='c') arguments passed to raster_weights() and pysal.Gamma See help(gr.raster_weights), help(pysal.Gamma) fo...
python
def pysal_Gamma(self, **kwargs): """ Compute Gamma Index of Spatial Autocorrelation for GeoRaster Usage: geo.pysal_Gamma(permutations = 1000, rook=True, operation='c') arguments passed to raster_weights() and pysal.Gamma See help(gr.raster_weights), help(pysal.Gamma) fo...
[ "def", "pysal_Gamma", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "weights", "is", "None", ":", "self", ".", "raster_weights", "(", "*", "*", "kwargs", ")", "rasterf", "=", "self", ".", "raster", ".", "flatten", "(", ")", "ra...
Compute Gamma Index of Spatial Autocorrelation for GeoRaster Usage: geo.pysal_Gamma(permutations = 1000, rook=True, operation='c') arguments passed to raster_weights() and pysal.Gamma See help(gr.raster_weights), help(pysal.Gamma) for options
[ "Compute", "Gamma", "Index", "of", "Spatial", "Autocorrelation", "for", "GeoRaster" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L973-L987
train
58,947
ozak/georasters
georasters/georasters.py
GeoRaster.pysal_Join_Counts
def pysal_Join_Counts(self, **kwargs): """ Compute join count statistics for GeoRaster Usage: geo.pysal_Join_Counts(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Join_Counts See help(gr.raster_weights), help(pysal.Join_Counts) for option...
python
def pysal_Join_Counts(self, **kwargs): """ Compute join count statistics for GeoRaster Usage: geo.pysal_Join_Counts(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Join_Counts See help(gr.raster_weights), help(pysal.Join_Counts) for option...
[ "def", "pysal_Join_Counts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "weights", "is", "None", ":", "self", ".", "raster_weights", "(", "*", "*", "kwargs", ")", "rasterf", "=", "self", ".", "raster", ".", "flatten", "(", ")",...
Compute join count statistics for GeoRaster Usage: geo.pysal_Join_Counts(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Join_Counts See help(gr.raster_weights), help(pysal.Join_Counts) for options
[ "Compute", "join", "count", "statistics", "for", "GeoRaster" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L990-L1004
train
58,948
ozak/georasters
georasters/georasters.py
GeoRaster.pysal_Moran
def pysal_Moran(self, **kwargs): """ Compute Moran's I measure of global spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran See help(gr.raster_weights), help(pysal.Moran) for ...
python
def pysal_Moran(self, **kwargs): """ Compute Moran's I measure of global spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran See help(gr.raster_weights), help(pysal.Moran) for ...
[ "def", "pysal_Moran", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "weights", "is", "None", ":", "self", ".", "raster_weights", "(", "*", "*", "kwargs", ")", "rasterf", "=", "self", ".", "raster", ".", "flatten", "(", ")", "ra...
Compute Moran's I measure of global spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran See help(gr.raster_weights), help(pysal.Moran) for options
[ "Compute", "Moran", "s", "I", "measure", "of", "global", "spatial", "autocorrelation", "for", "GeoRaster" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L1007-L1021
train
58,949
ozak/georasters
georasters/georasters.py
GeoRaster.pysal_Moran_Local
def pysal_Moran_Local(self, **kwargs): """ Compute Local Moran's I measure of local spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran_Local(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran_Local See help(gr.raster_weights),...
python
def pysal_Moran_Local(self, **kwargs): """ Compute Local Moran's I measure of local spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran_Local(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran_Local See help(gr.raster_weights),...
[ "def", "pysal_Moran_Local", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "weights", "is", "None", ":", "self", ".", "raster_weights", "(", "*", "*", "kwargs", ")", "rasterf", "=", "self", ".", "raster", ".", "flatten", "(", ")",...
Compute Local Moran's I measure of local spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran_Local(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran_Local See help(gr.raster_weights), help(pysal.Moran_Local) for options
[ "Compute", "Local", "Moran", "s", "I", "measure", "of", "local", "spatial", "autocorrelation", "for", "GeoRaster" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L1041-L1060
train
58,950
ozak/georasters
georasters/georasters.py
GeoRaster.mcp
def mcp(self, *args, **kwargs): """ Setup MCP_Geometric object from skimage for optimal travel time computations """ # Create Cost surface to work on self.mcp_cost = graph.MCP_Geometric(self.raster, *args, **kwargs)
python
def mcp(self, *args, **kwargs): """ Setup MCP_Geometric object from skimage for optimal travel time computations """ # Create Cost surface to work on self.mcp_cost = graph.MCP_Geometric(self.raster, *args, **kwargs)
[ "def", "mcp", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Create Cost surface to work on", "self", ".", "mcp_cost", "=", "graph", ".", "MCP_Geometric", "(", "self", ".", "raster", ",", "*", "args", ",", "*", "*", "kwargs", ")" ...
Setup MCP_Geometric object from skimage for optimal travel time computations
[ "Setup", "MCP_Geometric", "object", "from", "skimage", "for", "optimal", "travel", "time", "computations" ]
0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L1101-L1106
train
58,951
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint.notify
def notify(self, method, params=None): """Send a JSON RPC notification to the client. Args: method (str): The method name of the notification to send params (any): The payload of the notification """ log.debug('Sending notification: %s %s', method, params) ...
python
def notify(self, method, params=None): """Send a JSON RPC notification to the client. Args: method (str): The method name of the notification to send params (any): The payload of the notification """ log.debug('Sending notification: %s %s', method, params) ...
[ "def", "notify", "(", "self", ",", "method", ",", "params", "=", "None", ")", ":", "log", ".", "debug", "(", "'Sending notification: %s %s'", ",", "method", ",", "params", ")", "message", "=", "{", "'jsonrpc'", ":", "JSONRPC_VERSION", ",", "'method'", ":",...
Send a JSON RPC notification to the client. Args: method (str): The method name of the notification to send params (any): The payload of the notification
[ "Send", "a", "JSON", "RPC", "notification", "to", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L39-L55
train
58,952
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint.request
def request(self, method, params=None): """Send a JSON RPC request to the client. Args: method (str): The method name of the message to send params (any): The payload of the message Returns: Future that will resolve once a response has been received ...
python
def request(self, method, params=None): """Send a JSON RPC request to the client. Args: method (str): The method name of the message to send params (any): The payload of the message Returns: Future that will resolve once a response has been received ...
[ "def", "request", "(", "self", ",", "method", ",", "params", "=", "None", ")", ":", "msg_id", "=", "self", ".", "_id_generator", "(", ")", "log", ".", "debug", "(", "'Sending request with id %s: %s %s'", ",", "msg_id", ",", "method", ",", "params", ")", ...
Send a JSON RPC request to the client. Args: method (str): The method name of the message to send params (any): The payload of the message Returns: Future that will resolve once a response has been received
[ "Send", "a", "JSON", "RPC", "request", "to", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L57-L84
train
58,953
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._cancel_callback
def _cancel_callback(self, request_id): """Construct a cancellation callback for the given request ID.""" def callback(future): if future.cancelled(): self.notify(CANCEL_METHOD, {'id': request_id}) future.set_exception(JsonRpcRequestCancelled()) return...
python
def _cancel_callback(self, request_id): """Construct a cancellation callback for the given request ID.""" def callback(future): if future.cancelled(): self.notify(CANCEL_METHOD, {'id': request_id}) future.set_exception(JsonRpcRequestCancelled()) return...
[ "def", "_cancel_callback", "(", "self", ",", "request_id", ")", ":", "def", "callback", "(", "future", ")", ":", "if", "future", ".", "cancelled", "(", ")", ":", "self", ".", "notify", "(", "CANCEL_METHOD", ",", "{", "'id'", ":", "request_id", "}", ")"...
Construct a cancellation callback for the given request ID.
[ "Construct", "a", "cancellation", "callback", "for", "the", "given", "request", "ID", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L86-L92
train
58,954
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint.consume
def consume(self, message): """Consume a JSON RPC message from the client. Args: message (dict): The JSON RPC message sent by the client """ if 'jsonrpc' not in message or message['jsonrpc'] != JSONRPC_VERSION: log.warn("Unknown message type %s", message) ...
python
def consume(self, message): """Consume a JSON RPC message from the client. Args: message (dict): The JSON RPC message sent by the client """ if 'jsonrpc' not in message or message['jsonrpc'] != JSONRPC_VERSION: log.warn("Unknown message type %s", message) ...
[ "def", "consume", "(", "self", ",", "message", ")", ":", "if", "'jsonrpc'", "not", "in", "message", "or", "message", "[", "'jsonrpc'", "]", "!=", "JSONRPC_VERSION", ":", "log", ".", "warn", "(", "\"Unknown message type %s\"", ",", "message", ")", "return", ...
Consume a JSON RPC message from the client. Args: message (dict): The JSON RPC message sent by the client
[ "Consume", "a", "JSON", "RPC", "message", "from", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L94-L127
train
58,955
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._handle_notification
def _handle_notification(self, method, params): """Handle a notification from the client.""" if method == CANCEL_METHOD: self._handle_cancel_notification(params['id']) return try: handler = self._dispatcher[method] except KeyError: log.war...
python
def _handle_notification(self, method, params): """Handle a notification from the client.""" if method == CANCEL_METHOD: self._handle_cancel_notification(params['id']) return try: handler = self._dispatcher[method] except KeyError: log.war...
[ "def", "_handle_notification", "(", "self", ",", "method", ",", "params", ")", ":", "if", "method", "==", "CANCEL_METHOD", ":", "self", ".", "_handle_cancel_notification", "(", "params", "[", "'id'", "]", ")", "return", "try", ":", "handler", "=", "self", ...
Handle a notification from the client.
[ "Handle", "a", "notification", "from", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L129-L150
train
58,956
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._notification_callback
def _notification_callback(method, params): """Construct a notification callback for the given request ID.""" def callback(future): try: future.result() log.debug("Successfully handled async notification %s %s", method, params) except Exception: #...
python
def _notification_callback(method, params): """Construct a notification callback for the given request ID.""" def callback(future): try: future.result() log.debug("Successfully handled async notification %s %s", method, params) except Exception: #...
[ "def", "_notification_callback", "(", "method", ",", "params", ")", ":", "def", "callback", "(", "future", ")", ":", "try", ":", "future", ".", "result", "(", ")", "log", ".", "debug", "(", "\"Successfully handled async notification %s %s\"", ",", "method", ",...
Construct a notification callback for the given request ID.
[ "Construct", "a", "notification", "callback", "for", "the", "given", "request", "ID", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L153-L161
train
58,957
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._handle_cancel_notification
def _handle_cancel_notification(self, msg_id): """Handle a cancel notification from the client.""" request_future = self._client_request_futures.pop(msg_id, None) if not request_future: log.warn("Received cancel notification for unknown message id %s", msg_id) return ...
python
def _handle_cancel_notification(self, msg_id): """Handle a cancel notification from the client.""" request_future = self._client_request_futures.pop(msg_id, None) if not request_future: log.warn("Received cancel notification for unknown message id %s", msg_id) return ...
[ "def", "_handle_cancel_notification", "(", "self", ",", "msg_id", ")", ":", "request_future", "=", "self", ".", "_client_request_futures", ".", "pop", "(", "msg_id", ",", "None", ")", "if", "not", "request_future", ":", "log", ".", "warn", "(", "\"Received can...
Handle a cancel notification from the client.
[ "Handle", "a", "cancel", "notification", "from", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L163-L173
train
58,958
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._handle_request
def _handle_request(self, msg_id, method, params): """Handle a request from the client.""" try: handler = self._dispatcher[method] except KeyError: raise JsonRpcMethodNotFound.of(method) handler_result = handler(params) if callable(handler_result): ...
python
def _handle_request(self, msg_id, method, params): """Handle a request from the client.""" try: handler = self._dispatcher[method] except KeyError: raise JsonRpcMethodNotFound.of(method) handler_result = handler(params) if callable(handler_result): ...
[ "def", "_handle_request", "(", "self", ",", "msg_id", ",", "method", ",", "params", ")", ":", "try", ":", "handler", "=", "self", ".", "_dispatcher", "[", "method", "]", "except", "KeyError", ":", "raise", "JsonRpcMethodNotFound", ".", "of", "(", "method",...
Handle a request from the client.
[ "Handle", "a", "request", "from", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L175-L195
train
58,959
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._request_callback
def _request_callback(self, request_id): """Construct a request callback for the given request ID.""" def callback(future): # Remove the future from the client requests map self._client_request_futures.pop(request_id, None) if future.cancelled(): futu...
python
def _request_callback(self, request_id): """Construct a request callback for the given request ID.""" def callback(future): # Remove the future from the client requests map self._client_request_futures.pop(request_id, None) if future.cancelled(): futu...
[ "def", "_request_callback", "(", "self", ",", "request_id", ")", ":", "def", "callback", "(", "future", ")", ":", "# Remove the future from the client requests map", "self", ".", "_client_request_futures", ".", "pop", "(", "request_id", ",", "None", ")", "if", "fu...
Construct a request callback for the given request ID.
[ "Construct", "a", "request", "callback", "for", "the", "given", "request", "ID", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L197-L222
train
58,960
palantir/python-jsonrpc-server
pyls_jsonrpc/endpoint.py
Endpoint._handle_response
def _handle_response(self, msg_id, result=None, error=None): """Handle a response from the client.""" request_future = self._server_request_futures.pop(msg_id, None) if not request_future: log.warn("Received response to unknown message id %s", msg_id) return if ...
python
def _handle_response(self, msg_id, result=None, error=None): """Handle a response from the client.""" request_future = self._server_request_futures.pop(msg_id, None) if not request_future: log.warn("Received response to unknown message id %s", msg_id) return if ...
[ "def", "_handle_response", "(", "self", ",", "msg_id", ",", "result", "=", "None", ",", "error", "=", "None", ")", ":", "request_future", "=", "self", ".", "_server_request_futures", ".", "pop", "(", "msg_id", ",", "None", ")", "if", "not", "request_future...
Handle a response from the client.
[ "Handle", "a", "response", "from", "the", "client", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L224-L237
train
58,961
palantir/python-jsonrpc-server
pyls_jsonrpc/streams.py
JsonRpcStreamReader.listen
def listen(self, message_consumer): """Blocking call to listen for messages on the rfile. Args: message_consumer (fn): function that is passed each message as it is read off the socket. """ while not self._rfile.closed: request_str = self._read_message() ...
python
def listen(self, message_consumer): """Blocking call to listen for messages on the rfile. Args: message_consumer (fn): function that is passed each message as it is read off the socket. """ while not self._rfile.closed: request_str = self._read_message() ...
[ "def", "listen", "(", "self", ",", "message_consumer", ")", ":", "while", "not", "self", ".", "_rfile", ".", "closed", ":", "request_str", "=", "self", ".", "_read_message", "(", ")", "if", "request_str", "is", "None", ":", "break", "try", ":", "message_...
Blocking call to listen for messages on the rfile. Args: message_consumer (fn): function that is passed each message as it is read off the socket.
[ "Blocking", "call", "to", "listen", "for", "messages", "on", "the", "rfile", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/streams.py#L17-L33
train
58,962
palantir/python-jsonrpc-server
pyls_jsonrpc/streams.py
JsonRpcStreamReader._read_message
def _read_message(self): """Reads the contents of a message. Returns: body of message if parsable else None """ line = self._rfile.readline() if not line: return None content_length = self._content_length(line) # Blindly consume all hea...
python
def _read_message(self): """Reads the contents of a message. Returns: body of message if parsable else None """ line = self._rfile.readline() if not line: return None content_length = self._content_length(line) # Blindly consume all hea...
[ "def", "_read_message", "(", "self", ")", ":", "line", "=", "self", ".", "_rfile", ".", "readline", "(", ")", "if", "not", "line", ":", "return", "None", "content_length", "=", "self", ".", "_content_length", "(", "line", ")", "# Blindly consume all header l...
Reads the contents of a message. Returns: body of message if parsable else None
[ "Reads", "the", "contents", "of", "a", "message", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/streams.py#L35-L56
train
58,963
palantir/python-jsonrpc-server
pyls_jsonrpc/streams.py
JsonRpcStreamReader._content_length
def _content_length(line): """Extract the content length from an input line.""" if line.startswith(b'Content-Length: '): _, value = line.split(b'Content-Length: ') value = value.strip() try: return int(value) except ValueError: ...
python
def _content_length(line): """Extract the content length from an input line.""" if line.startswith(b'Content-Length: '): _, value = line.split(b'Content-Length: ') value = value.strip() try: return int(value) except ValueError: ...
[ "def", "_content_length", "(", "line", ")", ":", "if", "line", ".", "startswith", "(", "b'Content-Length: '", ")", ":", "_", ",", "value", "=", "line", ".", "split", "(", "b'Content-Length: '", ")", "value", "=", "value", ".", "strip", "(", ")", "try", ...
Extract the content length from an input line.
[ "Extract", "the", "content", "length", "from", "an", "input", "line", "." ]
7021d849901705ab53c141e483a71d0779aff3d2
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/streams.py#L59-L69
train
58,964
bastibe/PySoundCard
pysoundcard.py
hostapi_info
def hostapi_info(index=None): """Return a generator with information about each host API. If index is given, only one dictionary for the given host API is returned. """ if index is None: return (hostapi_info(i) for i in range(_pa.Pa_GetHostApiCount())) else: info = _pa.Pa_GetHo...
python
def hostapi_info(index=None): """Return a generator with information about each host API. If index is given, only one dictionary for the given host API is returned. """ if index is None: return (hostapi_info(i) for i in range(_pa.Pa_GetHostApiCount())) else: info = _pa.Pa_GetHo...
[ "def", "hostapi_info", "(", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "return", "(", "hostapi_info", "(", "i", ")", "for", "i", "in", "range", "(", "_pa", ".", "Pa_GetHostApiCount", "(", ")", ")", ")", "else", ":", "info", "...
Return a generator with information about each host API. If index is given, only one dictionary for the given host API is returned.
[ "Return", "a", "generator", "with", "information", "about", "each", "host", "API", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L254-L270
train
58,965
bastibe/PySoundCard
pysoundcard.py
device_info
def device_info(index=None): """Return a generator with information about each device. If index is given, only one dictionary for the given device is returned. """ if index is None: return (device_info(i) for i in range(_pa.Pa_GetDeviceCount())) else: info = _pa.Pa_GetDeviceInf...
python
def device_info(index=None): """Return a generator with information about each device. If index is given, only one dictionary for the given device is returned. """ if index is None: return (device_info(i) for i in range(_pa.Pa_GetDeviceCount())) else: info = _pa.Pa_GetDeviceInf...
[ "def", "device_info", "(", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "return", "(", "device_info", "(", "i", ")", "for", "i", "in", "range", "(", "_pa", ".", "Pa_GetDeviceCount", "(", ")", ")", ")", "else", ":", "info", "=",...
Return a generator with information about each device. If index is given, only one dictionary for the given device is returned.
[ "Return", "a", "generator", "with", "information", "about", "each", "device", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L273-L302
train
58,966
bastibe/PySoundCard
pysoundcard.py
_get_stream_parameters
def _get_stream_parameters(kind, device, channels, dtype, latency, samplerate): """Generate PaStreamParameters struct.""" if device is None: if kind == 'input': device = _pa.Pa_GetDefaultInputDevice() elif kind == 'output': device = _pa.Pa_GetDefaultOutputDevice() in...
python
def _get_stream_parameters(kind, device, channels, dtype, latency, samplerate): """Generate PaStreamParameters struct.""" if device is None: if kind == 'input': device = _pa.Pa_GetDefaultInputDevice() elif kind == 'output': device = _pa.Pa_GetDefaultOutputDevice() in...
[ "def", "_get_stream_parameters", "(", "kind", ",", "device", ",", "channels", ",", "dtype", ",", "latency", ",", "samplerate", ")", ":", "if", "device", "is", "None", ":", "if", "kind", "==", "'input'", ":", "device", "=", "_pa", ".", "Pa_GetDefaultInputDe...
Generate PaStreamParameters struct.
[ "Generate", "PaStreamParameters", "struct", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L710-L731
train
58,967
bastibe/PySoundCard
pysoundcard.py
_frombuffer
def _frombuffer(ptr, frames, channels, dtype): """Create NumPy array from a pointer to some memory.""" framesize = channels * dtype.itemsize data = np.frombuffer(ffi.buffer(ptr, frames * framesize), dtype=dtype) data.shape = -1, channels return data
python
def _frombuffer(ptr, frames, channels, dtype): """Create NumPy array from a pointer to some memory.""" framesize = channels * dtype.itemsize data = np.frombuffer(ffi.buffer(ptr, frames * framesize), dtype=dtype) data.shape = -1, channels return data
[ "def", "_frombuffer", "(", "ptr", ",", "frames", ",", "channels", ",", "dtype", ")", ":", "framesize", "=", "channels", "*", "dtype", ".", "itemsize", "data", "=", "np", ".", "frombuffer", "(", "ffi", ".", "buffer", "(", "ptr", ",", "frames", "*", "f...
Create NumPy array from a pointer to some memory.
[ "Create", "NumPy", "array", "from", "a", "pointer", "to", "some", "memory", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L734-L739
train
58,968
bastibe/PySoundCard
pysoundcard.py
_StreamBase.start
def start(self): """Commence audio processing. If successful, the stream is considered active. """ err = _pa.Pa_StartStream(self._stream) if err == _pa.paStreamIsNotStopped: return self._handle_error(err)
python
def start(self): """Commence audio processing. If successful, the stream is considered active. """ err = _pa.Pa_StartStream(self._stream) if err == _pa.paStreamIsNotStopped: return self._handle_error(err)
[ "def", "start", "(", "self", ")", ":", "err", "=", "_pa", ".", "Pa_StartStream", "(", "self", ".", "_stream", ")", "if", "err", "==", "_pa", ".", "paStreamIsNotStopped", ":", "return", "self", ".", "_handle_error", "(", "err", ")" ]
Commence audio processing. If successful, the stream is considered active.
[ "Commence", "audio", "processing", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L416-L425
train
58,969
bastibe/PySoundCard
pysoundcard.py
_StreamBase.stop
def stop(self): """Terminate audio processing. This waits until all pending audio buffers have been played before it returns. If successful, the stream is considered inactive. """ err = _pa.Pa_StopStream(self._stream) if err == _pa.paStreamIsStopped: ...
python
def stop(self): """Terminate audio processing. This waits until all pending audio buffers have been played before it returns. If successful, the stream is considered inactive. """ err = _pa.Pa_StopStream(self._stream) if err == _pa.paStreamIsStopped: ...
[ "def", "stop", "(", "self", ")", ":", "err", "=", "_pa", ".", "Pa_StopStream", "(", "self", ".", "_stream", ")", "if", "err", "==", "_pa", ".", "paStreamIsStopped", ":", "return", "self", ".", "_handle_error", "(", "err", ")" ]
Terminate audio processing. This waits until all pending audio buffers have been played before it returns. If successful, the stream is considered inactive.
[ "Terminate", "audio", "processing", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L427-L438
train
58,970
bastibe/PySoundCard
pysoundcard.py
_StreamBase.abort
def abort(self): """Terminate audio processing immediately. This does not wait for pending audio buffers. If successful, the stream is considered inactive. """ err = _pa.Pa_AbortStream(self._stream) if err == _pa.paStreamIsStopped: return self._handl...
python
def abort(self): """Terminate audio processing immediately. This does not wait for pending audio buffers. If successful, the stream is considered inactive. """ err = _pa.Pa_AbortStream(self._stream) if err == _pa.paStreamIsStopped: return self._handl...
[ "def", "abort", "(", "self", ")", ":", "err", "=", "_pa", ".", "Pa_AbortStream", "(", "self", ".", "_stream", ")", "if", "err", "==", "_pa", ".", "paStreamIsStopped", ":", "return", "self", ".", "_handle_error", "(", "err", ")" ]
Terminate audio processing immediately. This does not wait for pending audio buffers. If successful, the stream is considered inactive.
[ "Terminate", "audio", "processing", "immediately", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L440-L450
train
58,971
bastibe/PySoundCard
pysoundcard.py
InputStream.read
def read(self, frames, raw=False): """Read samples from an input stream. The function does not return until the required number of frames has been read. This may involve waiting for the operating system to supply the data. If raw data is requested, the raw cffi data buffer is ...
python
def read(self, frames, raw=False): """Read samples from an input stream. The function does not return until the required number of frames has been read. This may involve waiting for the operating system to supply the data. If raw data is requested, the raw cffi data buffer is ...
[ "def", "read", "(", "self", ",", "frames", ",", "raw", "=", "False", ")", ":", "channels", ",", "_", "=", "_split", "(", "self", ".", "channels", ")", "dtype", ",", "_", "=", "_split", "(", "self", ".", "dtype", ")", "data", "=", "ffi", ".", "n...
Read samples from an input stream. The function does not return until the required number of frames has been read. This may involve waiting for the operating system to supply the data. If raw data is requested, the raw cffi data buffer is returned. Otherwise, a numpy array of t...
[ "Read", "samples", "from", "an", "input", "stream", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L534-L553
train
58,972
bastibe/PySoundCard
pysoundcard.py
OutputStream.write
def write(self, data): """Write samples to an output stream. As much as one blocksize of audio data will be played without blocking. If more than one blocksize was provided, the function will only return when all but one blocksize has been played. Data will be converted...
python
def write(self, data): """Write samples to an output stream. As much as one blocksize of audio data will be played without blocking. If more than one blocksize was provided, the function will only return when all but one blocksize has been played. Data will be converted...
[ "def", "write", "(", "self", ",", "data", ")", ":", "frames", "=", "len", "(", "data", ")", "_", ",", "channels", "=", "_split", "(", "self", ".", "channels", ")", "_", ",", "dtype", "=", "_split", "(", "self", ".", "dtype", ")", "if", "(", "no...
Write samples to an output stream. As much as one blocksize of audio data will be played without blocking. If more than one blocksize was provided, the function will only return when all but one blocksize has been played. Data will be converted to a numpy matrix. Multichannel d...
[ "Write", "samples", "to", "an", "output", "stream", "." ]
fb16460b75a1bb416089ebecdf700fa954faa5b7
https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L580-L617
train
58,973
rfk/django-supervisor
djsupervisor/management/commands/supervisor.py
Command._handle_shell
def _handle_shell(self,cfg_file,*args,**options): """Command 'supervisord shell' runs the interactive command shell.""" args = ("--interactive",) + args return supervisorctl.main(("-c",cfg_file) + args)
python
def _handle_shell(self,cfg_file,*args,**options): """Command 'supervisord shell' runs the interactive command shell.""" args = ("--interactive",) + args return supervisorctl.main(("-c",cfg_file) + args)
[ "def", "_handle_shell", "(", "self", ",", "cfg_file", ",", "*", "args", ",", "*", "*", "options", ")", ":", "args", "=", "(", "\"--interactive\"", ",", ")", "+", "args", "return", "supervisorctl", ".", "main", "(", "(", "\"-c\"", ",", "cfg_file", ")", ...
Command 'supervisord shell' runs the interactive command shell.
[ "Command", "supervisord", "shell", "runs", "the", "interactive", "command", "shell", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/management/commands/supervisor.py#L210-L213
train
58,974
rfk/django-supervisor
djsupervisor/management/commands/supervisor.py
Command._handle_getconfig
def _handle_getconfig(self,cfg_file,*args,**options): """Command 'supervisor getconfig' prints merged config to stdout.""" if args: raise CommandError("supervisor getconfig takes no arguments") print cfg_file.read() return 0
python
def _handle_getconfig(self,cfg_file,*args,**options): """Command 'supervisor getconfig' prints merged config to stdout.""" if args: raise CommandError("supervisor getconfig takes no arguments") print cfg_file.read() return 0
[ "def", "_handle_getconfig", "(", "self", ",", "cfg_file", ",", "*", "args", ",", "*", "*", "options", ")", ":", "if", "args", ":", "raise", "CommandError", "(", "\"supervisor getconfig takes no arguments\"", ")", "print", "cfg_file", ".", "read", "(", ")", "...
Command 'supervisor getconfig' prints merged config to stdout.
[ "Command", "supervisor", "getconfig", "prints", "merged", "config", "to", "stdout", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/management/commands/supervisor.py#L215-L220
train
58,975
rfk/django-supervisor
djsupervisor/management/commands/supervisor.py
Command._handle_autoreload
def _handle_autoreload(self,cfg_file,*args,**options): """Command 'supervisor autoreload' watches for code changes. This command provides a simulation of the Django dev server's auto-reloading mechanism that will restart all supervised processes. It's not quite as accurate as Django's ...
python
def _handle_autoreload(self,cfg_file,*args,**options): """Command 'supervisor autoreload' watches for code changes. This command provides a simulation of the Django dev server's auto-reloading mechanism that will restart all supervised processes. It's not quite as accurate as Django's ...
[ "def", "_handle_autoreload", "(", "self", ",", "cfg_file", ",", "*", "args", ",", "*", "*", "options", ")", ":", "if", "args", ":", "raise", "CommandError", "(", "\"supervisor autoreload takes no arguments\"", ")", "live_dirs", "=", "self", ".", "_find_live_code...
Command 'supervisor autoreload' watches for code changes. This command provides a simulation of the Django dev server's auto-reloading mechanism that will restart all supervised processes. It's not quite as accurate as Django's autoreloader because it runs in a separate process, so it ...
[ "Command", "supervisor", "autoreload", "watches", "for", "code", "changes", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/management/commands/supervisor.py#L222-L289
train
58,976
rfk/django-supervisor
djsupervisor/management/commands/supervisor.py
Command._get_autoreload_programs
def _get_autoreload_programs(self,cfg_file): """Get the set of programs to auto-reload when code changes. Such programs will have autoreload=true in their config section. This can be affected by config file sections or command-line arguments, so we need to read it out of the merged conf...
python
def _get_autoreload_programs(self,cfg_file): """Get the set of programs to auto-reload when code changes. Such programs will have autoreload=true in their config section. This can be affected by config file sections or command-line arguments, so we need to read it out of the merged conf...
[ "def", "_get_autoreload_programs", "(", "self", ",", "cfg_file", ")", ":", "cfg", "=", "RawConfigParser", "(", ")", "cfg", ".", "readfp", "(", "cfg_file", ")", "reload_progs", "=", "[", "]", "for", "section", "in", "cfg", ".", "sections", "(", ")", ":", ...
Get the set of programs to auto-reload when code changes. Such programs will have autoreload=true in their config section. This can be affected by config file sections or command-line arguments, so we need to read it out of the merged config.
[ "Get", "the", "set", "of", "programs", "to", "auto", "-", "reload", "when", "code", "changes", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/management/commands/supervisor.py#L291-L308
train
58,977
rfk/django-supervisor
djsupervisor/management/commands/supervisor.py
Command._find_live_code_dirs
def _find_live_code_dirs(self): """Find all directories in which we might have live python code. This walks all of the currently-imported modules and adds their containing directory to the list of live dirs. After normalization and de-duplication, we get a pretty good approximation of ...
python
def _find_live_code_dirs(self): """Find all directories in which we might have live python code. This walks all of the currently-imported modules and adds their containing directory to the list of live dirs. After normalization and de-duplication, we get a pretty good approximation of ...
[ "def", "_find_live_code_dirs", "(", "self", ")", ":", "live_dirs", "=", "[", "]", "for", "mod", "in", "sys", ".", "modules", ".", "values", "(", ")", ":", "# Get the directory containing that module.", "# This is deliberately casting a wide net.", "try", ":", "dir...
Find all directories in which we might have live python code. This walks all of the currently-imported modules and adds their containing directory to the list of live dirs. After normalization and de-duplication, we get a pretty good approximation of the directories on sys.path that ar...
[ "Find", "all", "directories", "in", "which", "we", "might", "have", "live", "python", "code", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/management/commands/supervisor.py#L310-L342
train
58,978
rfk/django-supervisor
djsupervisor/config.py
render_config
def render_config(data,ctx): """Render the given config data using Django's template system. This function takes a config data string and a dict of context variables, renders the data through Django's template system, and returns the result. """ djsupervisor_tags.current_context = ctx data = "{...
python
def render_config(data,ctx): """Render the given config data using Django's template system. This function takes a config data string and a dict of context variables, renders the data through Django's template system, and returns the result. """ djsupervisor_tags.current_context = ctx data = "{...
[ "def", "render_config", "(", "data", ",", "ctx", ")", ":", "djsupervisor_tags", ".", "current_context", "=", "ctx", "data", "=", "\"{% load djsupervisor_tags %}\"", "+", "data", "t", "=", "template", ".", "Template", "(", "data", ")", "c", "=", "template", "...
Render the given config data using Django's template system. This function takes a config data string and a dict of context variables, renders the data through Django's template system, and returns the result.
[ "Render", "the", "given", "config", "data", "using", "Django", "s", "template", "system", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/config.py#L141-L151
train
58,979
rfk/django-supervisor
djsupervisor/config.py
get_config_from_options
def get_config_from_options(**options): """Get config file fragment reflecting command-line options.""" data = [] # Set whether or not to daemonize. # Unlike supervisord, our default is to stay in the foreground. data.append("[supervisord]\n") if options.get("daemonize",False): data.ap...
python
def get_config_from_options(**options): """Get config file fragment reflecting command-line options.""" data = [] # Set whether or not to daemonize. # Unlike supervisord, our default is to stay in the foreground. data.append("[supervisord]\n") if options.get("daemonize",False): data.ap...
[ "def", "get_config_from_options", "(", "*", "*", "options", ")", ":", "data", "=", "[", "]", "# Set whether or not to daemonize.", "# Unlike supervisord, our default is to stay in the foreground.", "data", ".", "append", "(", "\"[supervisord]\\n\"", ")", "if", "options", ...
Get config file fragment reflecting command-line options.
[ "Get", "config", "file", "fragment", "reflecting", "command", "-", "line", "options", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/config.py#L154-L189
train
58,980
rfk/django-supervisor
djsupervisor/config.py
guess_project_dir
def guess_project_dir(): """Find the top-level Django project directory. This function guesses the top-level Django project directory based on the current environment. It looks for module containing the currently- active settings module, in both pre-1.4 and post-1.4 layours. """ projname = set...
python
def guess_project_dir(): """Find the top-level Django project directory. This function guesses the top-level Django project directory based on the current environment. It looks for module containing the currently- active settings module, in both pre-1.4 and post-1.4 layours. """ projname = set...
[ "def", "guess_project_dir", "(", ")", ":", "projname", "=", "settings", ".", "SETTINGS_MODULE", ".", "split", "(", "\".\"", ",", "1", ")", "[", "0", "]", "projmod", "=", "import_module", "(", "projname", ")", "projdir", "=", "os", ".", "path", ".", "di...
Find the top-level Django project directory. This function guesses the top-level Django project directory based on the current environment. It looks for module containing the currently- active settings module, in both pre-1.4 and post-1.4 layours.
[ "Find", "the", "top", "-", "level", "Django", "project", "directory", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/config.py#L192-L216
train
58,981
rfk/django-supervisor
djsupervisor/config.py
set_if_missing
def set_if_missing(cfg,section,option,value): """If the given option is missing, set to the given value.""" try: cfg.get(section,option) except NoSectionError: cfg.add_section(section) cfg.set(section,option,value) except NoOptionError: cfg.set(section,option,value)
python
def set_if_missing(cfg,section,option,value): """If the given option is missing, set to the given value.""" try: cfg.get(section,option) except NoSectionError: cfg.add_section(section) cfg.set(section,option,value) except NoOptionError: cfg.set(section,option,value)
[ "def", "set_if_missing", "(", "cfg", ",", "section", ",", "option", ",", "value", ")", ":", "try", ":", "cfg", ".", "get", "(", "section", ",", "option", ")", "except", "NoSectionError", ":", "cfg", ".", "add_section", "(", "section", ")", "cfg", ".", ...
If the given option is missing, set to the given value.
[ "If", "the", "given", "option", "is", "missing", "set", "to", "the", "given", "value", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/config.py#L219-L227
train
58,982
rfk/django-supervisor
djsupervisor/config.py
rerender_options
def rerender_options(options): """Helper function to re-render command-line options. This assumes that command-line options use the same name as their key in the options dictionary. """ args = [] for name,value in options.iteritems(): name = name.replace("_","-") if value is Non...
python
def rerender_options(options): """Helper function to re-render command-line options. This assumes that command-line options use the same name as their key in the options dictionary. """ args = [] for name,value in options.iteritems(): name = name.replace("_","-") if value is Non...
[ "def", "rerender_options", "(", "options", ")", ":", "args", "=", "[", "]", "for", "name", ",", "value", "in", "options", ".", "iteritems", "(", ")", ":", "name", "=", "name", ".", "replace", "(", "\"_\"", ",", "\"-\"", ")", "if", "value", "is", "N...
Helper function to re-render command-line options. This assumes that command-line options use the same name as their key in the options dictionary.
[ "Helper", "function", "to", "re", "-", "render", "command", "-", "line", "options", "." ]
545a379d4a73ed2ae21c4aee6b8009ded8aeedc6
https://github.com/rfk/django-supervisor/blob/545a379d4a73ed2ae21c4aee6b8009ded8aeedc6/djsupervisor/config.py#L230-L249
train
58,983
pyapi-gitlab/pyapi-gitlab
gitlab/session.py
Session.login
def login(self, email=None, password=None, user=None): """ Logs the user in and setups the header with the private token :param email: Gitlab user Email :param user: Gitlab username :param password: Gitlab user password :return: True if login successful :raise: H...
python
def login(self, email=None, password=None, user=None): """ Logs the user in and setups the header with the private token :param email: Gitlab user Email :param user: Gitlab username :param password: Gitlab user password :return: True if login successful :raise: H...
[ "def", "login", "(", "self", ",", "email", "=", "None", ",", "password", "=", "None", ",", "user", "=", "None", ")", ":", "if", "user", "is", "not", "None", ":", "data", "=", "{", "'login'", ":", "user", ",", "'password'", ":", "password", "}", "...
Logs the user in and setups the header with the private token :param email: Gitlab user Email :param user: Gitlab username :param password: Gitlab user password :return: True if login successful :raise: HttpError :raise: ValueError
[ "Logs", "the", "user", "in", "and", "setups", "the", "header", "with", "the", "private", "token" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/session.py#L5-L29
train
58,984
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.getuser
def getuser(self, user_id): """ Get info for a user identified by id :param user_id: id of the user :return: False if not found, a dictionary if found """ request = requests.get( '{0}/{1}'.format(self.users_url, user_id), headers=self.headers, ver...
python
def getuser(self, user_id): """ Get info for a user identified by id :param user_id: id of the user :return: False if not found, a dictionary if found """ request = requests.get( '{0}/{1}'.format(self.users_url, user_id), headers=self.headers, ver...
[ "def", "getuser", "(", "self", ",", "user_id", ")", ":", "request", "=", "requests", ".", "get", "(", "'{0}/{1}'", ".", "format", "(", "self", ".", "users_url", ",", "user_id", ")", ",", "headers", "=", "self", ".", "headers", ",", "verify", "=", "se...
Get info for a user identified by id :param user_id: id of the user :return: False if not found, a dictionary if found
[ "Get", "info", "for", "a", "user", "identified", "by", "id" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L38-L52
train
58,985
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.deleteuser
def deleteuser(self, user_id): """ Deletes a user. Available only for administrators. This is an idempotent function, calling this function for a non-existent user id still returns a status code 200 OK. The JSON response differs if the user was actually deleted or not. In...
python
def deleteuser(self, user_id): """ Deletes a user. Available only for administrators. This is an idempotent function, calling this function for a non-existent user id still returns a status code 200 OK. The JSON response differs if the user was actually deleted or not. In...
[ "def", "deleteuser", "(", "self", ",", "user_id", ")", ":", "deleted", "=", "self", ".", "delete_user", "(", "user_id", ")", "if", "deleted", "is", "False", ":", "return", "False", "else", ":", "return", "True" ]
Deletes a user. Available only for administrators. This is an idempotent function, calling this function for a non-existent user id still returns a status code 200 OK. The JSON response differs if the user was actually deleted or not. In the former the user is returned and in the latter ...
[ "Deletes", "a", "user", ".", "Available", "only", "for", "administrators", ".", "This", "is", "an", "idempotent", "function", "calling", "this", "function", "for", "a", "non", "-", "existent", "user", "id", "still", "returns", "a", "status", "code", "200", ...
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L94-L112
train
58,986
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.currentuser
def currentuser(self): """ Returns the current user parameters. The current user is linked to the secret token :return: a list with the current user properties """ request = requests.get( '{0}/api/v3/user'.format(self.host), headers=self.headers, verify=s...
python
def currentuser(self): """ Returns the current user parameters. The current user is linked to the secret token :return: a list with the current user properties """ request = requests.get( '{0}/api/v3/user'.format(self.host), headers=self.headers, verify=s...
[ "def", "currentuser", "(", "self", ")", ":", "request", "=", "requests", ".", "get", "(", "'{0}/api/v3/user'", ".", "format", "(", "self", ".", "host", ")", ",", "headers", "=", "self", ".", "headers", ",", "verify", "=", "self", ".", "verify_ssl", ","...
Returns the current user parameters. The current user is linked to the secret token :return: a list with the current user properties
[ "Returns", "the", "current", "user", "parameters", ".", "The", "current", "user", "is", "linked", "to", "the", "secret", "token" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L114-L124
train
58,987
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.edituser
def edituser(self, user_id, **kwargs): """ Edits an user data. :param user_id: id of the user to change :param kwargs: Any param the the Gitlab API supports :return: Dict of the user """ data = {} if kwargs: data.update(kwargs) reque...
python
def edituser(self, user_id, **kwargs): """ Edits an user data. :param user_id: id of the user to change :param kwargs: Any param the the Gitlab API supports :return: Dict of the user """ data = {} if kwargs: data.update(kwargs) reque...
[ "def", "edituser", "(", "self", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "}", "if", "kwargs", ":", "data", ".", "update", "(", "kwargs", ")", "request", "=", "requests", ".", "put", "(", "'{0}/{1}'", ".", "format", "(", ...
Edits an user data. :param user_id: id of the user to change :param kwargs: Any param the the Gitlab API supports :return: Dict of the user
[ "Edits", "an", "user", "data", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L126-L146
train
58,988
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.getsshkeys
def getsshkeys(self): """ Gets all the ssh keys for the current user :return: a dictionary with the lists """ request = requests.get( self.keys_url, headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout) if request.status_code ==...
python
def getsshkeys(self): """ Gets all the ssh keys for the current user :return: a dictionary with the lists """ request = requests.get( self.keys_url, headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout) if request.status_code ==...
[ "def", "getsshkeys", "(", "self", ")", ":", "request", "=", "requests", ".", "get", "(", "self", ".", "keys_url", ",", "headers", "=", "self", ".", "headers", ",", "verify", "=", "self", ".", "verify_ssl", ",", "auth", "=", "self", ".", "auth", ",", ...
Gets all the ssh keys for the current user :return: a dictionary with the lists
[ "Gets", "all", "the", "ssh", "keys", "for", "the", "current", "user" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L170-L182
train
58,989
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.addsshkey
def addsshkey(self, title, key): """ Add a new ssh key for the current user :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists) """ data = {'title': t...
python
def addsshkey(self, title, key): """ Add a new ssh key for the current user :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists) """ data = {'title': t...
[ "def", "addsshkey", "(", "self", ",", "title", ",", "key", ")", ":", "data", "=", "{", "'title'", ":", "title", ",", "'key'", ":", "key", "}", "request", "=", "requests", ".", "post", "(", "self", ".", "keys_url", ",", "headers", "=", "self", ".", ...
Add a new ssh key for the current user :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists)
[ "Add", "a", "new", "ssh", "key", "for", "the", "current", "user" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L184-L201
train
58,990
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.addsshkeyuser
def addsshkeyuser(self, user_id, title, key): """ Add a new ssh key for the user identified by id :param user_id: id of the user to add the key to :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be...
python
def addsshkeyuser(self, user_id, title, key): """ Add a new ssh key for the user identified by id :param user_id: id of the user to add the key to :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be...
[ "def", "addsshkeyuser", "(", "self", ",", "user_id", ",", "title", ",", "key", ")", ":", "data", "=", "{", "'title'", ":", "title", ",", "'key'", ":", "key", "}", "request", "=", "requests", ".", "post", "(", "'{0}/{1}/keys'", ".", "format", "(", "se...
Add a new ssh key for the user identified by id :param user_id: id of the user to add the key to :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists)
[ "Add", "a", "new", "ssh", "key", "for", "the", "user", "identified", "by", "id" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L203-L221
train
58,991
pyapi-gitlab/pyapi-gitlab
gitlab/users.py
Users.deletesshkey
def deletesshkey(self, key_id): """ Deletes an sshkey for the current user identified by id :param key_id: the id of the key :return: False if it didn't delete it, True if it was deleted """ request = requests.delete( '{0}/{1}'.format(self.keys_url, key_id), ...
python
def deletesshkey(self, key_id): """ Deletes an sshkey for the current user identified by id :param key_id: the id of the key :return: False if it didn't delete it, True if it was deleted """ request = requests.delete( '{0}/{1}'.format(self.keys_url, key_id), ...
[ "def", "deletesshkey", "(", "self", ",", "key_id", ")", ":", "request", "=", "requests", ".", "delete", "(", "'{0}/{1}'", ".", "format", "(", "self", ".", "keys_url", ",", "key_id", ")", ",", "headers", "=", "self", ".", "headers", ",", "verify", "=", ...
Deletes an sshkey for the current user identified by id :param key_id: the id of the key :return: False if it didn't delete it, True if it was deleted
[ "Deletes", "an", "sshkey", "for", "the", "current", "user", "identified", "by", "id" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/users.py#L223-L237
train
58,992
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.get
def get(self, uri, default_response=None, **kwargs): """ Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for ...
python
def get(self, uri, default_response=None, **kwargs): """ Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for ...
[ "def", "get", "(", "self", ",", "uri", ",", "default_response", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "api_url", "+", "uri", "response", "=", "requests", ".", "get", "(", "url", ",", "params", "=", "kwargs", ",", ...
Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for the endpoint to GET from :param default_response: Return value if...
[ "Call", "GET", "on", "the", "Gitlab", "server" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L55-L74
train
58,993
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.post
def post(self, uri, default_response=None, **kwargs): """ Call POST on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> password = 'MyTestPassword1' >>> email = 'example@example....
python
def post(self, uri, default_response=None, **kwargs): """ Call POST on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> password = 'MyTestPassword1' >>> email = 'example@example....
[ "def", "post", "(", "self", ",", "uri", ",", "default_response", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "api_url", "+", "uri", "response", "=", "requests", ".", "post", "(", "url", ",", "headers", "=", "self", ".",...
Call POST on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> password = 'MyTestPassword1' >>> email = 'example@example.com' >>> data = {'name': 'test', 'username': 'test1', 'password': ...
[ "Call", "POST", "on", "the", "Gitlab", "server" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L76-L99
train
58,994
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.delete
def delete(self, uri, default_response=None): """ Call DELETE on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.delete('/users/5') :param uri: String with the URI you w...
python
def delete(self, uri, default_response=None): """ Call DELETE on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.delete('/users/5') :param uri: String with the URI you w...
[ "def", "delete", "(", "self", ",", "uri", ",", "default_response", "=", "None", ")", ":", "url", "=", "self", ".", "api_url", "+", "uri", "response", "=", "requests", ".", "delete", "(", "url", ",", "headers", "=", "self", ".", "headers", ",", "verif...
Call DELETE on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.delete('/users/5') :param uri: String with the URI you wish to delete :param default_response: Return value if JSO...
[ "Call", "DELETE", "on", "the", "Gitlab", "server" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L101-L119
train
58,995
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.success_or_raise
def success_or_raise(self, response, default_response=None): """ Check if request was successful or raises an HttpError :param response: Response Object to check :param default_response: Return value if JSONDecodeError :returns dict: Dictionary containing response data :...
python
def success_or_raise(self, response, default_response=None): """ Check if request was successful or raises an HttpError :param response: Response Object to check :param default_response: Return value if JSONDecodeError :returns dict: Dictionary containing response data :...
[ "def", "success_or_raise", "(", "self", ",", "response", ",", "default_response", "=", "None", ")", ":", "if", "self", ".", "suppress_http_error", "and", "not", "response", ".", "ok", ":", "return", "False", "response_json", "=", "default_response", "if", "res...
Check if request was successful or raises an HttpError :param response: Response Object to check :param default_response: Return value if JSONDecodeError :returns dict: Dictionary containing response data :returns bool: :obj:`False` on failure when exceptions are suppressed :rai...
[ "Check", "if", "request", "was", "successful", "or", "raises", "an", "HttpError" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L121-L145
train
58,996
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.getall
def getall(fn, page=None, *args, **kwargs): """ Auto-iterate over the paginated results of various methods of the API. Pass the GitLabAPI method as the first argument, followed by the other parameters as normal. Include `page` to determine first page to poll. Remaining kwargs are...
python
def getall(fn, page=None, *args, **kwargs): """ Auto-iterate over the paginated results of various methods of the API. Pass the GitLabAPI method as the first argument, followed by the other parameters as normal. Include `page` to determine first page to poll. Remaining kwargs are...
[ "def", "getall", "(", "fn", ",", "page", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "page", ":", "page", "=", "1", "while", "True", ":", "results", "=", "fn", "(", "*", "args", ",", "page", "=", "page", ","...
Auto-iterate over the paginated results of various methods of the API. Pass the GitLabAPI method as the first argument, followed by the other parameters as normal. Include `page` to determine first page to poll. Remaining kwargs are passed on to the called method, including `per_page`. ...
[ "Auto", "-", "iterate", "over", "the", "paginated", "results", "of", "various", "methods", "of", "the", "API", ".", "Pass", "the", "GitLabAPI", "method", "as", "the", "first", "argument", "followed", "by", "the", "other", "parameters", "as", "normal", ".", ...
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L148-L172
train
58,997
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.setsudo
def setsudo(self, user=None): """ Set the subsequent API calls to the user provided :param user: User id or username to change to, None to return to the logged user :return: Nothing """ if user is None: try: self.headers.pop('SUDO') ...
python
def setsudo(self, user=None): """ Set the subsequent API calls to the user provided :param user: User id or username to change to, None to return to the logged user :return: Nothing """ if user is None: try: self.headers.pop('SUDO') ...
[ "def", "setsudo", "(", "self", ",", "user", "=", "None", ")", ":", "if", "user", "is", "None", ":", "try", ":", "self", ".", "headers", ".", "pop", "(", "'SUDO'", ")", "except", "KeyError", ":", "pass", "else", ":", "self", ".", "headers", "[", "...
Set the subsequent API calls to the user provided :param user: User id or username to change to, None to return to the logged user :return: Nothing
[ "Set", "the", "subsequent", "API", "calls", "to", "the", "user", "provided" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L31-L44
train
58,998
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.createproject
def createproject(self, name, **kwargs): """ Creates a new project owned by the authenticated user. :param name: new project name :param path: custom repository name for new project. By default generated based on name :param namespace_id: namespace for the new project (defaults ...
python
def createproject(self, name, **kwargs): """ Creates a new project owned by the authenticated user. :param name: new project name :param path: custom repository name for new project. By default generated based on name :param namespace_id: namespace for the new project (defaults ...
[ "def", "createproject", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'name'", ":", "name", "}", "if", "kwargs", ":", "data", ".", "update", "(", "kwargs", ")", "request", "=", "requests", ".", "post", "(", "self",...
Creates a new project owned by the authenticated user. :param name: new project name :param path: custom repository name for new project. By default generated based on name :param namespace_id: namespace for the new project (defaults to user) :param description: short project descriptio...
[ "Creates", "a", "new", "project", "owned", "by", "the", "authenticated", "user", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L101-L135
train
58,999