repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
cdeboever3/cdpybio | cdpybio/bedtools.py | AnnotatedInteractions.load_saved_bts | def load_saved_bts(self):
"""If the AnnotatedInteractions object was saved to a pickle and
reloaded, this method remakes the BedTool objects."""
if self._bt1_path:
self.bt1 = pbt.BedTool(self._bt1_path)
if self._bt2_path:
self.bt2 = pbt.BedTool(self._bt2_path)
... | python | def load_saved_bts(self):
"""If the AnnotatedInteractions object was saved to a pickle and
reloaded, this method remakes the BedTool objects."""
if self._bt1_path:
self.bt1 = pbt.BedTool(self._bt1_path)
if self._bt2_path:
self.bt2 = pbt.BedTool(self._bt2_path)
... | [
"def",
"load_saved_bts",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bt1_path",
":",
"self",
".",
"bt1",
"=",
"pbt",
".",
"BedTool",
"(",
"self",
".",
"_bt1_path",
")",
"if",
"self",
".",
"_bt2_path",
":",
"self",
".",
"bt2",
"=",
"pbt",
".",
"BedT... | If the AnnotatedInteractions object was saved to a pickle and
reloaded, this method remakes the BedTool objects. | [
"If",
"the",
"AnnotatedInteractions",
"object",
"was",
"saved",
"to",
"a",
"pickle",
"and",
"reloaded",
"this",
"method",
"remakes",
"the",
"BedTool",
"objects",
"."
] | train | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/bedtools.py#L89-L99 |
cdeboever3/cdpybio | cdpybio/bedtools.py | AnnotatedInteractions.save | def save(
self,
path,
name,
):
"""
Save AnnotatedInteractions object and bed files. The object is stored in
a pickle and the bed files are saved as separate bed files. The object
can be reloaded by reading the pickle using cPickle and the BedTool
objec... | python | def save(
self,
path,
name,
):
"""
Save AnnotatedInteractions object and bed files. The object is stored in
a pickle and the bed files are saved as separate bed files. The object
can be reloaded by reading the pickle using cPickle and the BedTool
objec... | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"name",
",",
")",
":",
"t",
"=",
"'track type=bed name=\"{}_anchor1\"'",
".",
"format",
"(",
"name",
")",
"self",
".",
"bt1",
".",
"saveas",
"(",
"path",
"+",
"'_anchor1.bed'",
",",
"trackline",
"=",
"t",
"... | Save AnnotatedInteractions object and bed files. The object is stored in
a pickle and the bed files are saved as separate bed files. The object
can be reloaded by reading the pickle using cPickle and the BedTool
objects can be recreated using .load_saved_bts().
Parameters
... | [
"Save",
"AnnotatedInteractions",
"object",
"and",
"bed",
"files",
".",
"The",
"object",
"is",
"stored",
"in",
"a",
"pickle",
"and",
"the",
"bed",
"files",
"are",
"saved",
"as",
"separate",
"bed",
"files",
".",
"The",
"object",
"can",
"be",
"reloaded",
"by"... | train | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/bedtools.py#L101-L135 |
cdeboever3/cdpybio | cdpybio/bedtools.py | AnnotatedInteractions.annotate_bed | def annotate_bed(
self,
bt,
name,
col_name,
complete=None,
df_col=None,
):
"""
Annotate the input bed file using one of the annotation beds.
Parameters
----------
bt : pybedtools.BedTool
BedTool for either one of the... | python | def annotate_bed(
self,
bt,
name,
col_name,
complete=None,
df_col=None,
):
"""
Annotate the input bed file using one of the annotation beds.
Parameters
----------
bt : pybedtools.BedTool
BedTool for either one of the... | [
"def",
"annotate_bed",
"(",
"self",
",",
"bt",
",",
"name",
",",
"col_name",
",",
"complete",
"=",
"None",
",",
"df_col",
"=",
"None",
",",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"has_name_col",
"=",
"len",
"(",
"sel... | Annotate the input bed file using one of the annotation beds.
Parameters
----------
bt : pybedtools.BedTool
BedTool for either one of the anchors, the loops,
or the loop inners.
name : str
The key for the annoation bed file in annot_beds.
... | [
"Annotate",
"the",
"input",
"bed",
"file",
"using",
"one",
"of",
"the",
"annotation",
"beds",
".",
"Parameters",
"----------",
"bt",
":",
"pybedtools",
".",
"BedTool",
"BedTool",
"for",
"either",
"one",
"of",
"the",
"anchors",
"the",
"loops",
"or",
"the",
... | train | https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/bedtools.py#L137-L210 |
scivision/histutils | histutils/get1Dcut.py | get1Dcut | def get1Dcut(cam: List[Cam], odir: Path=None, verbose: bool=False) -> List[Cam]:
"""
i. get az/el of each pixel (rotated/transposed as appropriate)
ii. get cartesian ECEF of each pixel end, a point outside the grid (to create rays to check intersections with grid)
iii. put cameras in same frame, gett... | python | def get1Dcut(cam: List[Cam], odir: Path=None, verbose: bool=False) -> List[Cam]:
"""
i. get az/el of each pixel (rotated/transposed as appropriate)
ii. get cartesian ECEF of each pixel end, a point outside the grid (to create rays to check intersections with grid)
iii. put cameras in same frame, gett... | [
"def",
"get1Dcut",
"(",
"cam",
":",
"List",
"[",
"Cam",
"]",
",",
"odir",
":",
"Path",
"=",
"None",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"Cam",
"]",
":",
"# %% determine slant range between other camera and magnetic zenith to eval... | i. get az/el of each pixel (rotated/transposed as appropriate)
ii. get cartesian ECEF of each pixel end, a point outside the grid (to create rays to check intersections with grid)
iii. put cameras in same frame, getting az/el to each other's pixel ends
iv. find the indices corresponding to those angles
... | [
"i",
".",
"get",
"az",
"/",
"el",
"of",
"each",
"pixel",
"(",
"rotated",
"/",
"transposed",
"as",
"appropriate",
")",
"ii",
".",
"get",
"cartesian",
"ECEF",
"of",
"each",
"pixel",
"end",
"a",
"point",
"outside",
"the",
"grid",
"(",
"to",
"create",
"r... | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/get1Dcut.py#L11-L51 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | File.delete | def delete(self):
"""Delete the file."""
self.close()
if self.does_file_exist():
os.remove(self.path) | python | def delete(self):
"""Delete the file."""
self.close()
if self.does_file_exist():
os.remove(self.path) | [
"def",
"delete",
"(",
"self",
")",
":",
"self",
".",
"close",
"(",
")",
"if",
"self",
".",
"does_file_exist",
"(",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")"
] | Delete the file. | [
"Delete",
"the",
"file",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L63-L67 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | File.open | def open(self, mode='read'):
"""Open the file."""
if self.file:
self.close()
raise 'Close file before opening.'
if mode == 'write':
self.file = open(self.path, 'w')
elif mode == 'overwrite':
# Delete file if exist.
self.file = ... | python | def open(self, mode='read'):
"""Open the file."""
if self.file:
self.close()
raise 'Close file before opening.'
if mode == 'write':
self.file = open(self.path, 'w')
elif mode == 'overwrite':
# Delete file if exist.
self.file = ... | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"'read'",
")",
":",
"if",
"self",
".",
"file",
":",
"self",
".",
"close",
"(",
")",
"raise",
"'Close file before opening.'",
"if",
"mode",
"==",
"'write'",
":",
"self",
".",
"file",
"=",
"open",
"(",
"sel... | Open the file. | [
"Open",
"the",
"file",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L73-L94 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | RawEvents.add_hit | def add_hit(self, hit):
"""Add a hit to the file."""
if not self._csv:
raise 'Open before write'
self._csv.writerow(hit)
self.number_of_hits += 1
# Todo: check performance for timestamp check
# assert self._path == self.get_filename_by_timestamp(timestamp)
... | python | def add_hit(self, hit):
"""Add a hit to the file."""
if not self._csv:
raise 'Open before write'
self._csv.writerow(hit)
self.number_of_hits += 1
# Todo: check performance for timestamp check
# assert self._path == self.get_filename_by_timestamp(timestamp)
... | [
"def",
"add_hit",
"(",
"self",
",",
"hit",
")",
":",
"if",
"not",
"self",
".",
"_csv",
":",
"raise",
"'Open before write'",
"self",
".",
"_csv",
".",
"writerow",
"(",
"hit",
")",
"self",
".",
"number_of_hits",
"+=",
"1",
"# Todo: check performance for timest... | Add a hit to the file. | [
"Add",
"a",
"hit",
"to",
"the",
"file",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L116-L126 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | RawEvents.get_records | def get_records(self):
"""
Get all stored records.
Returns: (timestamp, user, recid,...)
"""
self.close()
with open(self.path, 'r') as filep:
first_line = filep.readline().split(',')
if first_line[0] != self.fields[0]:
yield first_... | python | def get_records(self):
"""
Get all stored records.
Returns: (timestamp, user, recid,...)
"""
self.close()
with open(self.path, 'r') as filep:
first_line = filep.readline().split(',')
if first_line[0] != self.fields[0]:
yield first_... | [
"def",
"get_records",
"(",
"self",
")",
":",
"self",
".",
"close",
"(",
")",
"with",
"open",
"(",
"self",
".",
"path",
",",
"'r'",
")",
"as",
"filep",
":",
"first_line",
"=",
"filep",
".",
"readline",
"(",
")",
".",
"split",
"(",
"','",
")",
"if"... | Get all stored records.
Returns: (timestamp, user, recid,...) | [
"Get",
"all",
"stored",
"records",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L128-L141 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | UserProfiles.add_user | def add_user(self, uid, nodes, weights):
"""Add a user."""
for i, node in enumerate(nodes):
self.file.write("{},{},{}\n".format(uid, node, weights[i])) | python | def add_user(self, uid, nodes, weights):
"""Add a user."""
for i, node in enumerate(nodes):
self.file.write("{},{},{}\n".format(uid, node, weights[i])) | [
"def",
"add_user",
"(",
"self",
",",
"uid",
",",
"nodes",
",",
"weights",
")",
":",
"for",
"i",
",",
"node",
"in",
"enumerate",
"(",
"nodes",
")",
":",
"self",
".",
"file",
".",
"write",
"(",
"\"{},{},{}\\n\"",
".",
"format",
"(",
"uid",
",",
"node... | Add a user. | [
"Add",
"a",
"user",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L152-L155 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | RedisStore.get | def get(self, key, default=None):
"""Get a key."""
key = "{0}{1}".format(self.prefix, key)
data = self.redis.get(key)
# Redis returns None not an exception
if data is None:
data = default
else:
data = json.loads(data)
return data | python | def get(self, key, default=None):
"""Get a key."""
key = "{0}{1}".format(self.prefix, key)
data = self.redis.get(key)
# Redis returns None not an exception
if data is None:
data = default
else:
data = json.loads(data)
return data | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"key",
"=",
"\"{0}{1}\"",
".",
"format",
"(",
"self",
".",
"prefix",
",",
"key",
")",
"data",
"=",
"self",
".",
"redis",
".",
"get",
"(",
"key",
")",
"# Redis returns Non... | Get a key. | [
"Get",
"a",
"key",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L182-L193 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | RedisStore.set | def set(self, key, value):
"""Set a key, value pair."""
key = "{0}{1}".format(self.prefix, key)
value = json.dumps(value, cls=NumpyEncoder)
self.redis.set(key, value) | python | def set(self, key, value):
"""Set a key, value pair."""
key = "{0}{1}".format(self.prefix, key)
value = json.dumps(value, cls=NumpyEncoder)
self.redis.set(key, value) | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"key",
"=",
"\"{0}{1}\"",
".",
"format",
"(",
"self",
".",
"prefix",
",",
"key",
")",
"value",
"=",
"json",
".",
"dumps",
"(",
"value",
",",
"cls",
"=",
"NumpyEncoder",
")",
"self",
"... | Set a key, value pair. | [
"Set",
"a",
"key",
"value",
"pair",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L195-L200 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | FileStore.get_by_timestamp | def get_by_timestamp(self, prefix, timestamp):
"""Get the cache file to a given timestamp."""
year, week = get_year_week(timestamp)
return self.get(prefix, year, week) | python | def get_by_timestamp(self, prefix, timestamp):
"""Get the cache file to a given timestamp."""
year, week = get_year_week(timestamp)
return self.get(prefix, year, week) | [
"def",
"get_by_timestamp",
"(",
"self",
",",
"prefix",
",",
"timestamp",
")",
":",
"year",
",",
"week",
"=",
"get_year_week",
"(",
"timestamp",
")",
"return",
"self",
".",
"get",
"(",
"prefix",
",",
"year",
",",
"week",
")"
] | Get the cache file to a given timestamp. | [
"Get",
"the",
"cache",
"file",
"to",
"a",
"given",
"timestamp",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L242-L245 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | FileStore.get | def get(self, prefix, year, week):
"""Get the cache file."""
filename = self._format_filename(prefix, year, week)
return RawEvents(filename, prefix, year, week) | python | def get(self, prefix, year, week):
"""Get the cache file."""
filename = self._format_filename(prefix, year, week)
return RawEvents(filename, prefix, year, week) | [
"def",
"get",
"(",
"self",
",",
"prefix",
",",
"year",
",",
"week",
")",
":",
"filename",
"=",
"self",
".",
"_format_filename",
"(",
"prefix",
",",
"year",
",",
"week",
")",
"return",
"RawEvents",
"(",
"filename",
",",
"prefix",
",",
"year",
",",
"we... | Get the cache file. | [
"Get",
"the",
"cache",
"file",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L247-L250 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | FileStore.get_user_profiles | def get_user_profiles(self, prefix):
"""Get the user profil from the cache to the given prefix."""
filepath = "{}{}".format(self.base_path, prefix)
return UserProfiles(filepath, prefix) | python | def get_user_profiles(self, prefix):
"""Get the user profil from the cache to the given prefix."""
filepath = "{}{}".format(self.base_path, prefix)
return UserProfiles(filepath, prefix) | [
"def",
"get_user_profiles",
"(",
"self",
",",
"prefix",
")",
":",
"filepath",
"=",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"base_path",
",",
"prefix",
")",
"return",
"UserProfiles",
"(",
"filepath",
",",
"prefix",
")"
] | Get the user profil from the cache to the given prefix. | [
"Get",
"the",
"user",
"profil",
"from",
"the",
"cache",
"to",
"the",
"given",
"prefix",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L252-L255 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | FileStore._format_filename | def _format_filename(self, prefix, year, week):
"""Construct the file name based on the path and options."""
return "{}{}_{}-{}.csv".format(self.base_path, prefix, year, week) | python | def _format_filename(self, prefix, year, week):
"""Construct the file name based on the path and options."""
return "{}{}_{}-{}.csv".format(self.base_path, prefix, year, week) | [
"def",
"_format_filename",
"(",
"self",
",",
"prefix",
",",
"year",
",",
"week",
")",
":",
"return",
"\"{}{}_{}-{}.csv\"",
".",
"format",
"(",
"self",
".",
"base_path",
",",
"prefix",
",",
"year",
",",
"week",
")"
] | Construct the file name based on the path and options. | [
"Construct",
"the",
"file",
"name",
"based",
"on",
"the",
"path",
"and",
"options",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L257-L259 |
inveniosoftware-contrib/record-recommender | record_recommender/storage.py | FileStore.get_recommendation_store | def get_recommendation_store(self):
"""Get the configured recommendation store."""
return RedisStore(self.config['host'],
self.config['port'],
self.config['db'],
self.config['prefix']) | python | def get_recommendation_store(self):
"""Get the configured recommendation store."""
return RedisStore(self.config['host'],
self.config['port'],
self.config['db'],
self.config['prefix']) | [
"def",
"get_recommendation_store",
"(",
"self",
")",
":",
"return",
"RedisStore",
"(",
"self",
".",
"config",
"[",
"'host'",
"]",
",",
"self",
".",
"config",
"[",
"'port'",
"]",
",",
"self",
".",
"config",
"[",
"'db'",
"]",
",",
"self",
".",
"config",
... | Get the configured recommendation store. | [
"Get",
"the",
"configured",
"recommendation",
"store",
"."
] | train | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/storage.py#L261-L266 |
esterhui/pypu | pypu/pusher.py | status.GetStatus | def GetStatus(self,directory,files=None,service=None):
""" Scans through all files in direcotory,
opens DB (if any), and returns dictionary (where filename is key)
of files and their status
- Returns dictionary where filename is key
- Status can be:
- ? : Not tracked... | python | def GetStatus(self,directory,files=None,service=None):
""" Scans through all files in direcotory,
opens DB (if any), and returns dictionary (where filename is key)
of files and their status
- Returns dictionary where filename is key
- Status can be:
- ? : Not tracked... | [
"def",
"GetStatus",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
",",
"service",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"GetStatus dir=%s\"",
"%",
"(",
"directory",
")",
")",
"db",
"=",
"self",
".",
"_loadDB",
"(",
"director... | Scans through all files in direcotory,
opens DB (if any), and returns dictionary (where filename is key)
of files and their status
- Returns dictionary where filename is key
- Status can be:
- ? : Not tracked
- S : Synched, in DB and on FLICKR
- A : A... | [
"Scans",
"through",
"all",
"files",
"in",
"direcotory",
"opens",
"DB",
"(",
"if",
"any",
")",
"and",
"returns",
"dictionary",
"(",
"where",
"filename",
"is",
"key",
")",
"of",
"files",
"and",
"their",
"status"
] | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L28-L87 |
esterhui/pypu | pypu/pusher.py | status._computeStatus | def _computeStatus(self, dfile, service):
"""Computes status for file, basically this means if
more than one service handles the file, it will place
a 'C' (for complicated) otherwise if status matches
between all services, will place that status"""
# If only one service request... | python | def _computeStatus(self, dfile, service):
"""Computes status for file, basically this means if
more than one service handles the file, it will place
a 'C' (for complicated) otherwise if status matches
between all services, will place that status"""
# If only one service request... | [
"def",
"_computeStatus",
"(",
"self",
",",
"dfile",
",",
"service",
")",
":",
"# If only one service requested",
"if",
"service",
":",
"if",
"not",
"dfile",
"[",
"'services'",
"]",
".",
"has_key",
"(",
"service",
")",
":",
"return",
"self",
".",
"ST_UNTRACKE... | Computes status for file, basically this means if
more than one service handles the file, it will place
a 'C' (for complicated) otherwise if status matches
between all services, will place that status | [
"Computes",
"status",
"for",
"file",
"basically",
"this",
"means",
"if",
"more",
"than",
"one",
"service",
"handles",
"the",
"file",
"it",
"will",
"place",
"a",
"C",
"(",
"for",
"complicated",
")",
"otherwise",
"if",
"status",
"matches",
"between",
"all",
... | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L89-L118 |
esterhui/pypu | pypu/pusher.py | status.UpdateStatus | def UpdateStatus(self,directory,files,status,service):
"""Given a list of files in a certain directory,
updates to the given status
If status is ST_UPTODATE, and no files given
will go through current DB and push files
with the "A" flag
service: If none, assumes all servi... | python | def UpdateStatus(self,directory,files,status,service):
"""Given a list of files in a certain directory,
updates to the given status
If status is ST_UPTODATE, and no files given
will go through current DB and push files
with the "A" flag
service: If none, assumes all servi... | [
"def",
"UpdateStatus",
"(",
"self",
",",
"directory",
",",
"files",
",",
"status",
",",
"service",
")",
":",
"# First get a list of all files in dir",
"# as well as current status",
"dfiles",
",",
"db",
"=",
"self",
".",
"GetStatus",
"(",
"directory",
",",
"files"... | Given a list of files in a certain directory,
updates to the given status
If status is ST_UPTODATE, and no files given
will go through current DB and push files
with the "A" flag
service: If none, assumes all services, looks for matching service | [
"Given",
"a",
"list",
"of",
"files",
"in",
"a",
"certain",
"directory",
"updates",
"to",
"the",
"given",
"status",
"If",
"status",
"is",
"ST_UPTODATE",
"and",
"no",
"files",
"given",
"will",
"go",
"through",
"current",
"DB",
"and",
"push",
"files",
"with",... | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L120-L217 |
esterhui/pypu | pypu/pusher.py | status._deleteFile | def _deleteFile(self,directory,fn,dentry,db,service):
"""Deletets file and changes status to '?' if no
more services manages the file
"""
# FIXME : can switch back to only managing once service
# at a time
logger.debug("%s - Deleting"%(fn))
if fn not in db:
... | python | def _deleteFile(self,directory,fn,dentry,db,service):
"""Deletets file and changes status to '?' if no
more services manages the file
"""
# FIXME : can switch back to only managing once service
# at a time
logger.debug("%s - Deleting"%(fn))
if fn not in db:
... | [
"def",
"_deleteFile",
"(",
"self",
",",
"directory",
",",
"fn",
",",
"dentry",
",",
"db",
",",
"service",
")",
":",
"# FIXME : can switch back to only managing once service",
"# at a time",
"logger",
".",
"debug",
"(",
"\"%s - Deleting\"",
"%",
"(",
"fn",
")",
"... | Deletets file and changes status to '?' if no
more services manages the file | [
"Deletets",
"file",
"and",
"changes",
"status",
"to",
"?",
"if",
"no",
"more",
"services",
"manages",
"the",
"file"
] | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L219-L263 |
esterhui/pypu | pypu/pusher.py | status._uploadFile | def _uploadFile(self,directory,fn,dentry,db,service):
"""Uploads file and changes status to 'S'. Looks
up service name with service string
"""
# Create a hash of the file
if fn not in db:
print("%s - Not in DB, must run 'add' first!"%(fn))
else:
# ... | python | def _uploadFile(self,directory,fn,dentry,db,service):
"""Uploads file and changes status to 'S'. Looks
up service name with service string
"""
# Create a hash of the file
if fn not in db:
print("%s - Not in DB, must run 'add' first!"%(fn))
else:
# ... | [
"def",
"_uploadFile",
"(",
"self",
",",
"directory",
",",
"fn",
",",
"dentry",
",",
"db",
",",
"service",
")",
":",
"# Create a hash of the file",
"if",
"fn",
"not",
"in",
"db",
":",
"print",
"(",
"\"%s - Not in DB, must run 'add' first!\"",
"%",
"(",
"fn",
... | Uploads file and changes status to 'S'. Looks
up service name with service string | [
"Uploads",
"file",
"and",
"changes",
"status",
"to",
"S",
".",
"Looks",
"up",
"service",
"name",
"with",
"service",
"string"
] | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L266-L300 |
esterhui/pypu | pypu/pusher.py | status._updateToDeleted | def _updateToDeleted(self,directory,fn,dentry,db,service):
"""Changes to status to 'D' as long as a handler exists,
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db - pusher DB for this directo... | python | def _updateToDeleted(self,directory,fn,dentry,db,service):
"""Changes to status to 'D' as long as a handler exists,
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db - pusher DB for this directo... | [
"def",
"_updateToDeleted",
"(",
"self",
",",
"directory",
",",
"fn",
",",
"dentry",
",",
"db",
",",
"service",
")",
":",
"# Create a hash of the file",
"if",
"fn",
"not",
"in",
"db",
":",
"print",
"(",
"\"%s - rm: not in DB, skipping!\"",
"%",
"(",
"fn",
")"... | Changes to status to 'D' as long as a handler exists,
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db - pusher DB for this directory
service - service to delete, None means all | [
"Changes",
"to",
"status",
"to",
"D",
"as",
"long",
"as",
"a",
"handler",
"exists",
"directory",
"-",
"DIR",
"where",
"stuff",
"is",
"happening",
"fn",
"-",
"File",
"name",
"to",
"be",
"added",
"dentry",
"-",
"dictionary",
"entry",
"as",
"returned",
"by"... | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L302-L333 |
esterhui/pypu | pypu/pusher.py | status._updateToAdded | def _updateToAdded(self,directory,fn,dentry,db,service):
"""Changes to status to 'A' as long as a handler exists,
also generates a hash
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db ... | python | def _updateToAdded(self,directory,fn,dentry,db,service):
"""Changes to status to 'A' as long as a handler exists,
also generates a hash
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db ... | [
"def",
"_updateToAdded",
"(",
"self",
",",
"directory",
",",
"fn",
",",
"dentry",
",",
"db",
",",
"service",
")",
":",
"services",
"=",
"self",
".",
"sman",
".",
"GetServices",
"(",
"fn",
")",
"# If nobody manages this file, just skip it",
"if",
"services",
... | Changes to status to 'A' as long as a handler exists,
also generates a hash
directory - DIR where stuff is happening
fn - File name to be added
dentry - dictionary entry as returned by GetStatus for this file
db - pusher DB for this directory
service - None means all serv... | [
"Changes",
"to",
"status",
"to",
"A",
"as",
"long",
"as",
"a",
"handler",
"exists",
"also",
"generates",
"a",
"hash",
"directory",
"-",
"DIR",
"where",
"stuff",
"is",
"happening",
"fn",
"-",
"File",
"name",
"to",
"be",
"added",
"dentry",
"-",
"dictionary... | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L336-L392 |
esterhui/pypu | pypu/pusher.py | status._hashfile | def _hashfile(self,filename,blocksize=65536):
"""Hashes the file and returns hash"""
logger.debug("Hashing file %s"%(filename))
hasher=hashlib.sha256()
afile=open(filename,'rb')
buf=afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf =... | python | def _hashfile(self,filename,blocksize=65536):
"""Hashes the file and returns hash"""
logger.debug("Hashing file %s"%(filename))
hasher=hashlib.sha256()
afile=open(filename,'rb')
buf=afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf =... | [
"def",
"_hashfile",
"(",
"self",
",",
"filename",
",",
"blocksize",
"=",
"65536",
")",
":",
"logger",
".",
"debug",
"(",
"\"Hashing file %s\"",
"%",
"(",
"filename",
")",
")",
"hasher",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"afile",
"=",
"open",
"("... | Hashes the file and returns hash | [
"Hashes",
"the",
"file",
"and",
"returns",
"hash"
] | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L454-L463 |
esterhui/pypu | pypu/pusher.py | status._findFiles | def _findFiles(self,pushdir,files=None):
"""Find all files, return dict, where key is filename
files[filename]=dictionary
where dictionary has keys:
['mtime'] = modification time
"""
#If no file list given, go through all
if not files:
fil... | python | def _findFiles(self,pushdir,files=None):
"""Find all files, return dict, where key is filename
files[filename]=dictionary
where dictionary has keys:
['mtime'] = modification time
"""
#If no file list given, go through all
if not files:
fil... | [
"def",
"_findFiles",
"(",
"self",
",",
"pushdir",
",",
"files",
"=",
"None",
")",
":",
"#If no file list given, go through all",
"if",
"not",
"files",
":",
"files",
"=",
"os",
".",
"listdir",
"(",
"pushdir",
")",
"dfiles",
"=",
"{",
"}",
"for",
"fn",
"in... | Find all files, return dict, where key is filename
files[filename]=dictionary
where dictionary has keys:
['mtime'] = modification time | [
"Find",
"all",
"files",
"return",
"dict",
"where",
"key",
"is",
"filename",
"files",
"[",
"filename",
"]",
"=",
"dictionary",
"where",
"dictionary",
"has",
"keys",
":",
"[",
"mtime",
"]",
"=",
"modification",
"time"
] | train | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/pusher.py#L466-L487 |
romaryd/python-jsonrepo | jsonrepo/mixin.py | StorageMixin.storage | def storage(self):
"""
Instantiates and returns a storage instance
"""
if self.backend == 'redis':
return RedisBackend(self.prefix, self.secondary_indexes)
if self.backend == 'dynamodb':
return DynamoDBBackend(self.prefix, self.key, self.sort_key,
... | python | def storage(self):
"""
Instantiates and returns a storage instance
"""
if self.backend == 'redis':
return RedisBackend(self.prefix, self.secondary_indexes)
if self.backend == 'dynamodb':
return DynamoDBBackend(self.prefix, self.key, self.sort_key,
... | [
"def",
"storage",
"(",
"self",
")",
":",
"if",
"self",
".",
"backend",
"==",
"'redis'",
":",
"return",
"RedisBackend",
"(",
"self",
".",
"prefix",
",",
"self",
".",
"secondary_indexes",
")",
"if",
"self",
".",
"backend",
"==",
"'dynamodb'",
":",
"return"... | Instantiates and returns a storage instance | [
"Instantiates",
"and",
"returns",
"a",
"storage",
"instance"
] | train | https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/mixin.py#L18-L27 |
drongo-framework/drongo | drongo/utils/dict2.py | dict2.get_property | def get_property(self, prop):
"""Access nested value using dot separated keys
Args:
prop (:obj:`str`): Property in the form of dot separated keys
Returns:
Property value if exists, else `None`
"""
prop = prop.split('.')
root = self
for p ... | python | def get_property(self, prop):
"""Access nested value using dot separated keys
Args:
prop (:obj:`str`): Property in the form of dot separated keys
Returns:
Property value if exists, else `None`
"""
prop = prop.split('.')
root = self
for p ... | [
"def",
"get_property",
"(",
"self",
",",
"prop",
")",
":",
"prop",
"=",
"prop",
".",
"split",
"(",
"'.'",
")",
"root",
"=",
"self",
"for",
"p",
"in",
"prop",
":",
"if",
"p",
"in",
"root",
":",
"root",
"=",
"root",
"[",
"p",
"]",
"else",
":",
... | Access nested value using dot separated keys
Args:
prop (:obj:`str`): Property in the form of dot separated keys
Returns:
Property value if exists, else `None` | [
"Access",
"nested",
"value",
"using",
"dot",
"separated",
"keys"
] | train | https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/utils/dict2.py#L25-L41 |
drongo-framework/drongo | drongo/utils/dict2.py | dict2.from_dict | def from_dict(cls, val):
"""Creates dict2 object from dict object
Args:
val (:obj:`dict`): Value to create from
Returns:
Equivalent dict2 object.
"""
if isinstance(val, dict2):
return val
elif isinstance(val, dict):
res =... | python | def from_dict(cls, val):
"""Creates dict2 object from dict object
Args:
val (:obj:`dict`): Value to create from
Returns:
Equivalent dict2 object.
"""
if isinstance(val, dict2):
return val
elif isinstance(val, dict):
res =... | [
"def",
"from_dict",
"(",
"cls",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict2",
")",
":",
"return",
"val",
"elif",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"res",
"=",
"cls",
"(",
")",
"for",
"k",
",",
"v",
"in",
"va... | Creates dict2 object from dict object
Args:
val (:obj:`dict`): Value to create from
Returns:
Equivalent dict2 object. | [
"Creates",
"dict2",
"object",
"from",
"dict",
"object"
] | train | https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/utils/dict2.py#L51-L75 |
drongo-framework/drongo | drongo/utils/dict2.py | dict2.to_dict | def to_dict(self, val=UNSET):
"""Creates dict object from dict2 object
Args:
val (:obj:`dict2`): Value to create from
Returns:
Equivalent dict object.
"""
if val is UNSET:
val = self
if isinstance(val, dict2) or isinstance(val, dict)... | python | def to_dict(self, val=UNSET):
"""Creates dict object from dict2 object
Args:
val (:obj:`dict2`): Value to create from
Returns:
Equivalent dict object.
"""
if val is UNSET:
val = self
if isinstance(val, dict2) or isinstance(val, dict)... | [
"def",
"to_dict",
"(",
"self",
",",
"val",
"=",
"UNSET",
")",
":",
"if",
"val",
"is",
"UNSET",
":",
"val",
"=",
"self",
"if",
"isinstance",
"(",
"val",
",",
"dict2",
")",
"or",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"res",
"=",
"dict",
... | Creates dict object from dict2 object
Args:
val (:obj:`dict2`): Value to create from
Returns:
Equivalent dict object. | [
"Creates",
"dict",
"object",
"from",
"dict2",
"object"
] | train | https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/utils/dict2.py#L77-L100 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Left_click | def Left_click(self, x, y, n = 1, dl = 0):
"""在屏幕某点左键点击若干次
"""
self.Delay(dl)
self.mouse.click(x, y, 1, n) | python | def Left_click(self, x, y, n = 1, dl = 0):
"""在屏幕某点左键点击若干次
"""
self.Delay(dl)
self.mouse.click(x, y, 1, n) | [
"def",
"Left_click",
"(",
"self",
",",
"x",
",",
"y",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"mouse",
".",
"click",
"(",
"x",
",",
"y",
",",
"1",
",",
"n",
")"
] | 在屏幕某点左键点击若干次 | [
"在屏幕某点左键点击若干次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L42-L46 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Scroll_up | def Scroll_up(self, n, dl = 0):
"""鼠标滚轮向上n次
"""
self.Delay(dl)
self.mouse.scroll(vertical = n) | python | def Scroll_up(self, n, dl = 0):
"""鼠标滚轮向上n次
"""
self.Delay(dl)
self.mouse.scroll(vertical = n) | [
"def",
"Scroll_up",
"(",
"self",
",",
"n",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"mouse",
".",
"scroll",
"(",
"vertical",
"=",
"n",
")"
] | 鼠标滚轮向上n次 | [
"鼠标滚轮向上n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L60-L64 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Scroll_down | def Scroll_down(self, n, dl = 0):
"""鼠标滚轮向下n次
"""
self.Delay(dl)
self.mouse.scroll(vertical = -n) | python | def Scroll_down(self, n, dl = 0):
"""鼠标滚轮向下n次
"""
self.Delay(dl)
self.mouse.scroll(vertical = -n) | [
"def",
"Scroll_down",
"(",
"self",
",",
"n",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"mouse",
".",
"scroll",
"(",
"vertical",
"=",
"-",
"n",
")"
] | 鼠标滚轮向下n次 | [
"鼠标滚轮向下n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L66-L70 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Move_to | def Move_to(self, x, y, dl = 0):
"""鼠标移动到x, y的坐标处
"""
self.Delay(dl)
self.mouse.move(x, y) | python | def Move_to(self, x, y, dl = 0):
"""鼠标移动到x, y的坐标处
"""
self.Delay(dl)
self.mouse.move(x, y) | [
"def",
"Move_to",
"(",
"self",
",",
"x",
",",
"y",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"mouse",
".",
"move",
"(",
"x",
",",
"y",
")"
] | 鼠标移动到x, y的坐标处 | [
"鼠标移动到x",
"y的坐标处"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L72-L76 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Drag_and_release | def Drag_and_release(self, start, end, dl = 0):
"""从start的坐标处鼠标左键单击拖曳到end的坐标处
start, end是tuple. 格式是(x, y)
"""
self.Delay(dl)
self.mouse.press(start[0], start[1], 1)
self.mouse.drag(end[0], end[1])
self.Delay(0.1)
self.mouse.release(end[0], end[1], 1) | python | def Drag_and_release(self, start, end, dl = 0):
"""从start的坐标处鼠标左键单击拖曳到end的坐标处
start, end是tuple. 格式是(x, y)
"""
self.Delay(dl)
self.mouse.press(start[0], start[1], 1)
self.mouse.drag(end[0], end[1])
self.Delay(0.1)
self.mouse.release(end[0], end[1], 1) | [
"def",
"Drag_and_release",
"(",
"self",
",",
"start",
",",
"end",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"mouse",
".",
"press",
"(",
"start",
"[",
"0",
"]",
",",
"start",
"[",
"1",
"]",
",",
"1",
")"... | 从start的坐标处鼠标左键单击拖曳到end的坐标处
start, end是tuple. 格式是(x, y) | [
"从start的坐标处鼠标左键单击拖曳到end的坐标处",
"start",
"end是tuple",
".",
"格式是",
"(",
"x",
"y",
")"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L78-L86 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Ctrl_c | def Ctrl_c(self, dl = 0):
"""Ctrl + c 复制
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.control_key)
self.keyboard.tap_key("c")
self.keyboard.release_key(self.keyboard.control_key) | python | def Ctrl_c(self, dl = 0):
"""Ctrl + c 复制
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.control_key)
self.keyboard.tap_key("c")
self.keyboard.release_key(self.keyboard.control_key) | [
"def",
"Ctrl_c",
"(",
"self",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"press_key",
"(",
"self",
".",
"keyboard",
".",
"control_key",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"\"c\... | Ctrl + c 复制 | [
"Ctrl",
"+",
"c",
"复制"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L100-L106 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Ctrl_Fn | def Ctrl_Fn(self, n, dl = 0):
"""Ctrl + Fn1~12 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.control_key)
self.keyboard.tap_key(self.keyboard.function_keys[n])
self.keyboard.release_key(self.keyboard.control_key) | python | def Ctrl_Fn(self, n, dl = 0):
"""Ctrl + Fn1~12 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.control_key)
self.keyboard.tap_key(self.keyboard.function_keys[n])
self.keyboard.release_key(self.keyboard.control_key) | [
"def",
"Ctrl_Fn",
"(",
"self",
",",
"n",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"press_key",
"(",
"self",
".",
"keyboard",
".",
"control_key",
")",
"self",
".",
"keyboard",
".",
"tap_key",... | Ctrl + Fn1~12 组合键 | [
"Ctrl",
"+",
"Fn1~12",
"组合键"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L148-L154 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Alt_Tab | def Alt_Tab(self, dl = 0):
"""Alt + Tab 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.alt_key)
self.keyboard.tap_key(self.keyboard.tab_key)
self.keyboard.release_key(self.keyboard.alt_key) | python | def Alt_Tab(self, dl = 0):
"""Alt + Tab 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.alt_key)
self.keyboard.tap_key(self.keyboard.tab_key)
self.keyboard.release_key(self.keyboard.alt_key) | [
"def",
"Alt_Tab",
"(",
"self",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"press_key",
"(",
"self",
".",
"keyboard",
".",
"alt_key",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
... | Alt + Tab 组合键 | [
"Alt",
"+",
"Tab",
"组合键"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L157-L163 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Alt_Fn | def Alt_Fn(self, n, dl = 0):
"""Alt + Fn1~12 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.alt_key)
self.keyboard.tap_key(self.keyboard.function_keys[n])
self.keyboard.release_key(self.keyboard.alt_key) | python | def Alt_Fn(self, n, dl = 0):
"""Alt + Fn1~12 组合键
"""
self.Delay(dl)
self.keyboard.press_key(self.keyboard.alt_key)
self.keyboard.tap_key(self.keyboard.function_keys[n])
self.keyboard.release_key(self.keyboard.alt_key) | [
"def",
"Alt_Fn",
"(",
"self",
",",
"n",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"press_key",
"(",
"self",
".",
"keyboard",
".",
"alt_key",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(... | Alt + Fn1~12 组合键 | [
"Alt",
"+",
"Fn1~12",
"组合键"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L165-L171 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Up | def Up(self, n = 1, dl = 0):
"""上方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.up_key, n) | python | def Up(self, n = 1, dl = 0):
"""上方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.up_key, n) | [
"def",
"Up",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"up_key",
",",
"n",
")"
] | 上方向键n次 | [
"上方向键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L175-L179 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Down | def Down(self, n = 1, dl = 0):
"""下方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.down_key, n) | python | def Down(self, n = 1, dl = 0):
"""下方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.down_key, n) | [
"def",
"Down",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"down_key",
",",
"n",
")"
] | 下方向键n次 | [
"下方向键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L181-L185 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Left | def Left(self, n = 1, dl = 0):
"""左方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.left_key, n) | python | def Left(self, n = 1, dl = 0):
"""左方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.left_key, n) | [
"def",
"Left",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"left_key",
",",
"n",
")"
] | 左方向键n次 | [
"左方向键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L187-L191 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Right | def Right(self, n = 1, dl = 0):
"""右方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.right_key, n) | python | def Right(self, n = 1, dl = 0):
"""右方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.right_key, n) | [
"def",
"Right",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"right_key",
",",
"n",
")"
] | 右方向键n次 | [
"右方向键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L193-L197 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Enter | def Enter(self, n = 1, dl = 0):
"""回车键/换行键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.enter_key, n) | python | def Enter(self, n = 1, dl = 0):
"""回车键/换行键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.enter_key, n) | [
"def",
"Enter",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"enter_key",
",",
"n",
")"
] | 回车键/换行键n次 | [
"回车键",
"/",
"换行键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L199-L203 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Delete | def Delete(self, n = 1, dl = 0):
"""删除键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.delete_key, n) | python | def Delete(self, n = 1, dl = 0):
"""删除键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.delete_key, n) | [
"def",
"Delete",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"delete_key",
",",
"n",
")"
] | 删除键n次 | [
"删除键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L205-L209 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Back | def Back(self, n = 1, dl = 0):
"""退格键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.backspace_key, n) | python | def Back(self, n = 1, dl = 0):
"""退格键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.backspace_key, n) | [
"def",
"Back",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"backspace_key",
",",
"n",
")"
] | 退格键n次 | [
"退格键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L211-L215 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Space | def Space(self, n = 1, dl = 0):
"""空格键n次
"""
self.Delay(dl)
self.keyboard.tap_key(" ", n) | python | def Space(self, n = 1, dl = 0):
"""空格键n次
"""
self.Delay(dl)
self.keyboard.tap_key(" ", n) | [
"def",
"Space",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"\" \"",
",",
"n",
")"
] | 空格键n次 | [
"空格键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L217-L221 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Fn | def Fn(self, n, dl = 0):
"""功能键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.function_keys[n]) | python | def Fn(self, n, dl = 0):
"""功能键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.function_keys[n]) | [
"def",
"Fn",
"(",
"self",
",",
"n",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"function_keys",
"[",
"n",
"]",
")"
] | 功能键n次 | [
"功能键n次"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L223-L227 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Char | def Char(self, char, n = 1, dl = 0):
"""输入任意单字符n次,只要能在键盘上打出来的字符都可以
"""
if len(char) == 1:
self.Delay(dl)
self.keyboard.tap_key(char)
else:
raise Exception("""method "Char()" can only take one character.""") | python | def Char(self, char, n = 1, dl = 0):
"""输入任意单字符n次,只要能在键盘上打出来的字符都可以
"""
if len(char) == 1:
self.Delay(dl)
self.keyboard.tap_key(char)
else:
raise Exception("""method "Char()" can only take one character.""") | [
"def",
"Char",
"(",
"self",
",",
"char",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"if",
"len",
"(",
"char",
")",
"==",
"1",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"char",
")",
"els... | 输入任意单字符n次,只要能在键盘上打出来的字符都可以 | [
"输入任意单字符n次,只要能在键盘上打出来的字符都可以"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L229-L236 |
MacHu-GWU/angora-project | angora/bot/macro.py | Bot.Type_string | def Type_string(self, text, interval = 0, dl = 0):
"""键盘输入字符串,interval是字符间输入时间间隔,单位"秒"
"""
self.Delay(dl)
self.keyboard.type_string(text, interval) | python | def Type_string(self, text, interval = 0, dl = 0):
"""键盘输入字符串,interval是字符间输入时间间隔,单位"秒"
"""
self.Delay(dl)
self.keyboard.type_string(text, interval) | [
"def",
"Type_string",
"(",
"self",
",",
"text",
",",
"interval",
"=",
"0",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"type_string",
"(",
"text",
",",
"interval",
")"
] | 键盘输入字符串,interval是字符间输入时间间隔,单位"秒" | [
"键盘输入字符串,interval是字符间输入时间间隔,单位",
"秒"
] | train | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L238-L242 |
mirukan/whratio | whratio/__main__.py | main | def main():
"Process CLI arguments and call appropriate functions."
try:
args = docopt.docopt(__doc__, version=__about__.__version__)
except docopt.DocoptExit:
if len(sys.argv) > 1:
print(f"{Fore.RED}Invalid command syntax, "
f"check help:{Fore.RESET}\n")
... | python | def main():
"Process CLI arguments and call appropriate functions."
try:
args = docopt.docopt(__doc__, version=__about__.__version__)
except docopt.DocoptExit:
if len(sys.argv) > 1:
print(f"{Fore.RED}Invalid command syntax, "
f"check help:{Fore.RESET}\n")
... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"args",
"=",
"docopt",
".",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"__about__",
".",
"__version__",
")",
"except",
"docopt",
".",
"DocoptExit",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
">",
"... | Process CLI arguments and call appropriate functions. | [
"Process",
"CLI",
"arguments",
"and",
"call",
"appropriate",
"functions",
"."
] | train | https://github.com/mirukan/whratio/blob/e19cf7346351649d196d2eb3369870841f7bfea5/whratio/__main__.py#L33-L68 |
webadmin87/midnight | midnight_catalog/services.py | get_all | def get_all(slug=None):
"""
Возвращает QuerySet содержащий выборку товаров
:param slug: символьный код категории каталога, если не задан выбираются товары в не зависимости от категории
:return:
"""
if slug is None:
q = Product.objects.published()
else:
q = Product.objects.pub... | python | def get_all(slug=None):
"""
Возвращает QuerySet содержащий выборку товаров
:param slug: символьный код категории каталога, если не задан выбираются товары в не зависимости от категории
:return:
"""
if slug is None:
q = Product.objects.published()
else:
q = Product.objects.pub... | [
"def",
"get_all",
"(",
"slug",
"=",
"None",
")",
":",
"if",
"slug",
"is",
"None",
":",
"q",
"=",
"Product",
".",
"objects",
".",
"published",
"(",
")",
"else",
":",
"q",
"=",
"Product",
".",
"objects",
".",
"published",
"(",
")",
".",
"filter",
"... | Возвращает QuerySet содержащий выборку товаров
:param slug: символьный код категории каталога, если не задан выбираются товары в не зависимости от категории
:return: | [
"Возвращает",
"QuerySet",
"содержащий",
"выборку",
"товаров",
":",
"param",
"slug",
":",
"символьный",
"код",
"категории",
"каталога",
"если",
"не",
"задан",
"выбираются",
"товары",
"в",
"не",
"зависимости",
"от",
"категории",
":",
"return",
":"
] | train | https://github.com/webadmin87/midnight/blob/b60b3b257b4d633550b82a692f3ea3756c62a0a9/midnight_catalog/services.py#L6-L22 |
webadmin87/midnight | midnight_catalog/services.py | get_one | def get_one(slug):
"""
Возвращает один товар
:param slug: символьный код товара
:return:
"""
item = Product.objects.published()\
.prefetch_related(Prefetch("paramvalue_set", queryset=ParamValue.objects.published().order_by('sort').prefetch_related("param")))\
.filter(slug=slug).f... | python | def get_one(slug):
"""
Возвращает один товар
:param slug: символьный код товара
:return:
"""
item = Product.objects.published()\
.prefetch_related(Prefetch("paramvalue_set", queryset=ParamValue.objects.published().order_by('sort').prefetch_related("param")))\
.filter(slug=slug).f... | [
"def",
"get_one",
"(",
"slug",
")",
":",
"item",
"=",
"Product",
".",
"objects",
".",
"published",
"(",
")",
".",
"prefetch_related",
"(",
"Prefetch",
"(",
"\"paramvalue_set\"",
",",
"queryset",
"=",
"ParamValue",
".",
"objects",
".",
"published",
"(",
")"... | Возвращает один товар
:param slug: символьный код товара
:return: | [
"Возвращает",
"один",
"товар",
":",
"param",
"slug",
":",
"символьный",
"код",
"товара",
":",
"return",
":"
] | train | https://github.com/webadmin87/midnight/blob/b60b3b257b4d633550b82a692f3ea3756c62a0a9/midnight_catalog/services.py#L25-L34 |
pyvec/pyvodb | pyvodb/tables.py | Event.start | def start(self):
"""The event's start time, as a timezone-aware datetime object"""
if self.start_time is None:
time = datetime.time(hour=19, tzinfo=CET)
else:
time = self.start_time.replace(tzinfo=CET)
return datetime.datetime.combine(self.date, time) | python | def start(self):
"""The event's start time, as a timezone-aware datetime object"""
if self.start_time is None:
time = datetime.time(hour=19, tzinfo=CET)
else:
time = self.start_time.replace(tzinfo=CET)
return datetime.datetime.combine(self.date, time) | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"start_time",
"is",
"None",
":",
"time",
"=",
"datetime",
".",
"time",
"(",
"hour",
"=",
"19",
",",
"tzinfo",
"=",
"CET",
")",
"else",
":",
"time",
"=",
"self",
".",
"start_time",
".",
"re... | The event's start time, as a timezone-aware datetime object | [
"The",
"event",
"s",
"start",
"time",
"as",
"a",
"timezone",
"-",
"aware",
"datetime",
"object"
] | train | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/tables.py#L103-L109 |
pyvec/pyvodb | pyvodb/tables.py | Series.next_occurrences | def next_occurrences(self, n=None, since=None):
"""Yield the next planned occurrences after the date "since"
The `since` argument can be either a date or datetime onject.
If not given, it defaults to the date of the last event that's
already planned.
If `n` is given, the result... | python | def next_occurrences(self, n=None, since=None):
"""Yield the next planned occurrences after the date "since"
The `since` argument can be either a date or datetime onject.
If not given, it defaults to the date of the last event that's
already planned.
If `n` is given, the result... | [
"def",
"next_occurrences",
"(",
"self",
",",
"n",
"=",
"None",
",",
"since",
"=",
"None",
")",
":",
"scheme",
"=",
"self",
".",
"recurrence_scheme",
"if",
"scheme",
"is",
"None",
":",
"return",
"(",
")",
"db",
"=",
"Session",
".",
"object_session",
"("... | Yield the next planned occurrences after the date "since"
The `since` argument can be either a date or datetime onject.
If not given, it defaults to the date of the last event that's
already planned.
If `n` is given, the result is limited to that many dates;
otherwise, infinite... | [
"Yield",
"the",
"next",
"planned",
"occurrences",
"after",
"the",
"date",
"since"
] | train | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/tables.py#L215-L260 |
edsu/summoner | summoner.py | Summon.search | def search(self, q, **kwargs):
"""
You can pass in any of the Summon Search API parameters
(without the "s." prefix). For example to remove highlighting:
result = api.search("Web", hl=False)
See the Summon API documentation for the full list of possible
parameters:... | python | def search(self, q, **kwargs):
"""
You can pass in any of the Summon Search API parameters
(without the "s." prefix). For example to remove highlighting:
result = api.search("Web", hl=False)
See the Summon API documentation for the full list of possible
parameters:... | [
"def",
"search",
"(",
"self",
",",
"q",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"\"s.q\"",
":",
"q",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"params",
"[",
"\"s.\"",
"+",
"k",
"]",
"=",
"v",
"r... | You can pass in any of the Summon Search API parameters
(without the "s." prefix). For example to remove highlighting:
result = api.search("Web", hl=False)
See the Summon API documentation for the full list of possible
parameters:
http://api.summon.serialssolutions.com/he... | [
"You",
"can",
"pass",
"in",
"any",
"of",
"the",
"Summon",
"Search",
"API",
"parameters",
"(",
"without",
"the",
"s",
".",
"prefix",
")",
".",
"For",
"example",
"to",
"remove",
"highlighting",
":"
] | train | https://github.com/edsu/summoner/blob/cf669c058f76307bccc36680f11adc9dce2d384a/summoner.py#L28-L44 |
inveniosoftware-attic/invenio-knowledge | invenio_knowledge/upgrades/knowledge_2015_07_14_innodb.py | do_upgrade | def do_upgrade():
"""Carry out the upgrade."""
op.alter_column(
table_name='knwKBRVAL',
column_name='id_knwKB',
type_=db.MediumInteger(8, unsigned=True),
existing_nullable=False,
existing_server_default='0'
) | python | def do_upgrade():
"""Carry out the upgrade."""
op.alter_column(
table_name='knwKBRVAL',
column_name='id_knwKB',
type_=db.MediumInteger(8, unsigned=True),
existing_nullable=False,
existing_server_default='0'
) | [
"def",
"do_upgrade",
"(",
")",
":",
"op",
".",
"alter_column",
"(",
"table_name",
"=",
"'knwKBRVAL'",
",",
"column_name",
"=",
"'id_knwKB'",
",",
"type_",
"=",
"db",
".",
"MediumInteger",
"(",
"8",
",",
"unsigned",
"=",
"True",
")",
",",
"existing_nullable... | Carry out the upgrade. | [
"Carry",
"out",
"the",
"upgrade",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/upgrades/knowledge_2015_07_14_innodb.py#L35-L43 |
cwoebker/paxo | paxo/text.py | spark_string | def spark_string(ints):
"""Returns a spark string from given iterable of ints."""
ticks = u'▁▂▃▅▆▇'
ints = [i for i in ints if type(i) == int]
if len(ints) == 0:
return ""
step = (max(ints) / float(len(ticks) - 1)) or 1
return u''.join(
ticks[int(round(i / step))] if type(i) == i... | python | def spark_string(ints):
"""Returns a spark string from given iterable of ints."""
ticks = u'▁▂▃▅▆▇'
ints = [i for i in ints if type(i) == int]
if len(ints) == 0:
return ""
step = (max(ints) / float(len(ticks) - 1)) or 1
return u''.join(
ticks[int(round(i / step))] if type(i) == i... | [
"def",
"spark_string",
"(",
"ints",
")",
":",
"ticks",
"=",
"u'▁▂▃▅▆▇'",
"ints",
"=",
"[",
"i",
"for",
"i",
"in",
"ints",
"if",
"type",
"(",
"i",
")",
"==",
"int",
"]",
"if",
"len",
"(",
"ints",
")",
"==",
"0",
":",
"return",
"\"\"",
"step",
"=... | Returns a spark string from given iterable of ints. | [
"Returns",
"a",
"spark",
"string",
"from",
"given",
"iterable",
"of",
"ints",
"."
] | train | https://github.com/cwoebker/paxo/blob/b97518a830948faaaf31aeacda3f8d4f6364eb07/paxo/text.py#L16-L24 |
arcus-io/puppetdb-python | puppetdb/v2/facts.py | get_facts | def get_facts(api_url=None, query='', verify=False, cert=list()):
"""
Returns facts
:param api_url: Base PuppetDB API url
"""
return utils._make_api_request(api_url, '/facts', verify, cert, params={'query': query}) | python | def get_facts(api_url=None, query='', verify=False, cert=list()):
"""
Returns facts
:param api_url: Base PuppetDB API url
"""
return utils._make_api_request(api_url, '/facts', verify, cert, params={'query': query}) | [
"def",
"get_facts",
"(",
"api_url",
"=",
"None",
",",
"query",
"=",
"''",
",",
"verify",
"=",
"False",
",",
"cert",
"=",
"list",
"(",
")",
")",
":",
"return",
"utils",
".",
"_make_api_request",
"(",
"api_url",
",",
"'/facts'",
",",
"verify",
",",
"ce... | Returns facts
:param api_url: Base PuppetDB API url | [
"Returns",
"facts"
] | train | https://github.com/arcus-io/puppetdb-python/blob/d772eb80a1dfb1154a1f421c7ecdc1ac951b5ea2/puppetdb/v2/facts.py#L25-L32 |
arcus-io/puppetdb-python | puppetdb/v2/facts.py | get_facts_by_name | def get_facts_by_name(api_url=None, fact_name=None, verify=False, cert=list()):
"""
Returns facts by name
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact
"""
return utils._make_api_request(api_url, '/facts/{0}'.format(fact_name), verify, cert) | python | def get_facts_by_name(api_url=None, fact_name=None, verify=False, cert=list()):
"""
Returns facts by name
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact
"""
return utils._make_api_request(api_url, '/facts/{0}'.format(fact_name), verify, cert) | [
"def",
"get_facts_by_name",
"(",
"api_url",
"=",
"None",
",",
"fact_name",
"=",
"None",
",",
"verify",
"=",
"False",
",",
"cert",
"=",
"list",
"(",
")",
")",
":",
"return",
"utils",
".",
"_make_api_request",
"(",
"api_url",
",",
"'/facts/{0}'",
".",
"for... | Returns facts by name
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact | [
"Returns",
"facts",
"by",
"name"
] | train | https://github.com/arcus-io/puppetdb-python/blob/d772eb80a1dfb1154a1f421c7ecdc1ac951b5ea2/puppetdb/v2/facts.py#L34-L42 |
arcus-io/puppetdb-python | puppetdb/v2/facts.py | get_facts_by_name_and_value | def get_facts_by_name_and_value(api_url=None, fact_name=None, fact_value=None, verify=False, cert=list()):
"""
Returns facts by name and value
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact
:param fact_value: Value of fact
"""
return utils._make_api_request(api_url, '... | python | def get_facts_by_name_and_value(api_url=None, fact_name=None, fact_value=None, verify=False, cert=list()):
"""
Returns facts by name and value
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact
:param fact_value: Value of fact
"""
return utils._make_api_request(api_url, '... | [
"def",
"get_facts_by_name_and_value",
"(",
"api_url",
"=",
"None",
",",
"fact_name",
"=",
"None",
",",
"fact_value",
"=",
"None",
",",
"verify",
"=",
"False",
",",
"cert",
"=",
"list",
"(",
")",
")",
":",
"return",
"utils",
".",
"_make_api_request",
"(",
... | Returns facts by name and value
:param api_url: Base PuppetDB API url
:param fact_name: Name of fact
:param fact_value: Value of fact | [
"Returns",
"facts",
"by",
"name",
"and",
"value"
] | train | https://github.com/arcus-io/puppetdb-python/blob/d772eb80a1dfb1154a1f421c7ecdc1ac951b5ea2/puppetdb/v2/facts.py#L44-L53 |
fr33jc/bang | bang/util.py | sanitize_config_loglevel | def sanitize_config_loglevel(level):
'''
Kinda sorta backport of loglevel sanitization for Python 2.6.
'''
if sys.version_info[:2] != (2, 6) or isinstance(level, (int, long)):
return level
lvl = None
if isinstance(level, basestring):
lvl = logging._levelNames.get(level)
if no... | python | def sanitize_config_loglevel(level):
'''
Kinda sorta backport of loglevel sanitization for Python 2.6.
'''
if sys.version_info[:2] != (2, 6) or isinstance(level, (int, long)):
return level
lvl = None
if isinstance(level, basestring):
lvl = logging._levelNames.get(level)
if no... | [
"def",
"sanitize_config_loglevel",
"(",
"level",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"!=",
"(",
"2",
",",
"6",
")",
"or",
"isinstance",
"(",
"level",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"return",
"level",
"lvl",... | Kinda sorta backport of loglevel sanitization for Python 2.6. | [
"Kinda",
"sorta",
"backport",
"of",
"loglevel",
"sanitization",
"for",
"Python",
"2",
".",
"6",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L217-L228 |
fr33jc/bang | bang/util.py | poll_with_timeout | def poll_with_timeout(timeout_s, break_func, wake_every_s=60):
"""
Calls :attr:`break_func` every :attr:`wake_every_s` seconds for a total
duration of :attr:`timeout_s` seconds, or until :attr:`break_func` returns
something other than ``None``.
If :attr:`break_func` returns anything other than ``No... | python | def poll_with_timeout(timeout_s, break_func, wake_every_s=60):
"""
Calls :attr:`break_func` every :attr:`wake_every_s` seconds for a total
duration of :attr:`timeout_s` seconds, or until :attr:`break_func` returns
something other than ``None``.
If :attr:`break_func` returns anything other than ``No... | [
"def",
"poll_with_timeout",
"(",
"timeout_s",
",",
"break_func",
",",
"wake_every_s",
"=",
"60",
")",
":",
"time_slept",
"=",
"0",
"if",
"wake_every_s",
">",
"60",
":",
"msg",
"=",
"'... sleeping for %0.2f minutes'",
"%",
"(",
"wake_every_s",
"/",
"60.0",
")",... | Calls :attr:`break_func` every :attr:`wake_every_s` seconds for a total
duration of :attr:`timeout_s` seconds, or until :attr:`break_func` returns
something other than ``None``.
If :attr:`break_func` returns anything other than ``None``, that value is
returned immediately.
Otherwise, continues pol... | [
"Calls",
":",
"attr",
":",
"break_func",
"every",
":",
"attr",
":",
"wake_every_s",
"seconds",
"for",
"a",
"total",
"duration",
"of",
":",
"attr",
":",
"timeout_s",
"seconds",
"or",
"until",
":",
"attr",
":",
"break_func",
"returns",
"something",
"other",
... | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L292-L316 |
fr33jc/bang | bang/util.py | redact_secrets | def redact_secrets(line):
"""
Returns a sanitized string for any ``line`` that looks like it contains a
secret (i.e. matches SECRET_PATTERN).
"""
def redact(match):
if match.group(2) in SECRET_WHITELIST:
return match.group(0)
return match.group(1) + 'TOO_TOO_SEXY'
ret... | python | def redact_secrets(line):
"""
Returns a sanitized string for any ``line`` that looks like it contains a
secret (i.e. matches SECRET_PATTERN).
"""
def redact(match):
if match.group(2) in SECRET_WHITELIST:
return match.group(0)
return match.group(1) + 'TOO_TOO_SEXY'
ret... | [
"def",
"redact_secrets",
"(",
"line",
")",
":",
"def",
"redact",
"(",
"match",
")",
":",
"if",
"match",
".",
"group",
"(",
"2",
")",
"in",
"SECRET_WHITELIST",
":",
"return",
"match",
".",
"group",
"(",
"0",
")",
"return",
"match",
".",
"group",
"(",
... | Returns a sanitized string for any ``line`` that looks like it contains a
secret (i.e. matches SECRET_PATTERN). | [
"Returns",
"a",
"sanitized",
"string",
"for",
"any",
"line",
"that",
"looks",
"like",
"it",
"contains",
"a",
"secret",
"(",
"i",
".",
"e",
".",
"matches",
"SECRET_PATTERN",
")",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L336-L345 |
fr33jc/bang | bang/util.py | count_to_deploy | def count_to_deploy(stack, descriptor, config_count):
"""
takes the max of config_count and number of instances running
with this stack/descriptor combo
"""
live_count = count_by_tag(stack, descriptor)
if config_count > live_count:
live_count = config_count
return live_count | python | def count_to_deploy(stack, descriptor, config_count):
"""
takes the max of config_count and number of instances running
with this stack/descriptor combo
"""
live_count = count_by_tag(stack, descriptor)
if config_count > live_count:
live_count = config_count
return live_count | [
"def",
"count_to_deploy",
"(",
"stack",
",",
"descriptor",
",",
"config_count",
")",
":",
"live_count",
"=",
"count_by_tag",
"(",
"stack",
",",
"descriptor",
")",
"if",
"config_count",
">",
"live_count",
":",
"live_count",
"=",
"config_count",
"return",
"live_co... | takes the max of config_count and number of instances running
with this stack/descriptor combo | [
"takes",
"the",
"max",
"of",
"config_count",
"and",
"number",
"of",
"instances",
"running",
"with",
"this",
"stack",
"/",
"descriptor",
"combo"
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L357-L366 |
fr33jc/bang | bang/util.py | count_by_tag | def count_by_tag(stack, descriptor):
"""
Returns the count of currently running or pending instances
that match the given stack and deployer combo
"""
ec2_conn = boto.ec2.connection.EC2Connection()
resses = ec2_conn.get_all_instances(
filters={
'tag:st... | python | def count_by_tag(stack, descriptor):
"""
Returns the count of currently running or pending instances
that match the given stack and deployer combo
"""
ec2_conn = boto.ec2.connection.EC2Connection()
resses = ec2_conn.get_all_instances(
filters={
'tag:st... | [
"def",
"count_by_tag",
"(",
"stack",
",",
"descriptor",
")",
":",
"ec2_conn",
"=",
"boto",
".",
"ec2",
".",
"connection",
".",
"EC2Connection",
"(",
")",
"resses",
"=",
"ec2_conn",
".",
"get_all_instances",
"(",
"filters",
"=",
"{",
"'tag:stack'",
":",
"st... | Returns the count of currently running or pending instances
that match the given stack and deployer combo | [
"Returns",
"the",
"count",
"of",
"currently",
"running",
"or",
"pending",
"instances",
"that",
"match",
"the",
"given",
"stack",
"and",
"deployer",
"combo"
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L369-L384 |
fr33jc/bang | bang/util.py | deep_merge_dicts | def deep_merge_dicts(base, incoming):
"""
Performs an *in-place* deep-merge of key-values from :attr:`incoming`
into :attr:`base`. No attempt is made to preserve the original state of
the objects passed in as arguments.
:param dict base: The target container for the merged values. This will
... | python | def deep_merge_dicts(base, incoming):
"""
Performs an *in-place* deep-merge of key-values from :attr:`incoming`
into :attr:`base`. No attempt is made to preserve the original state of
the objects passed in as arguments.
:param dict base: The target container for the merged values. This will
... | [
"def",
"deep_merge_dicts",
"(",
"base",
",",
"incoming",
")",
":",
"for",
"ki",
",",
"vi",
"in",
"incoming",
".",
"iteritems",
"(",
")",
":",
"if",
"(",
"ki",
"in",
"base",
"and",
"isinstance",
"(",
"vi",
",",
"collections",
".",
"MutableMapping",
")",... | Performs an *in-place* deep-merge of key-values from :attr:`incoming`
into :attr:`base`. No attempt is made to preserve the original state of
the objects passed in as arguments.
:param dict base: The target container for the merged values. This will
be modified *in-place*.
:type base: Any :... | [
"Performs",
"an",
"*",
"in",
"-",
"place",
"*",
"deep",
"-",
"merge",
"of",
"key",
"-",
"values",
"from",
":",
"attr",
":",
"incoming",
"into",
":",
"attr",
":",
"base",
".",
"No",
"attempt",
"is",
"made",
"to",
"preserve",
"the",
"original",
"state"... | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L397-L421 |
fr33jc/bang | bang/util.py | fork_exec | def fork_exec(cmd_list, input_data=None):
"""
Like the subprocess.check_*() helper functions, but tailored to bang.
``cmd_list`` is the command to run, and its arguments as a list of strings.
``input_data`` is the optional data to pass to the command's stdin.
On success, returns the output (i.e. ... | python | def fork_exec(cmd_list, input_data=None):
"""
Like the subprocess.check_*() helper functions, but tailored to bang.
``cmd_list`` is the command to run, and its arguments as a list of strings.
``input_data`` is the optional data to pass to the command's stdin.
On success, returns the output (i.e. ... | [
"def",
"fork_exec",
"(",
"cmd_list",
",",
"input_data",
"=",
"None",
")",
":",
"# log.debug('fork_exec: cmd_list = %s, input_data = ^%s^' %",
"# (cmd_list, input_data))",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd_list",
",",
"stdin",
"=",
"subprocess",
"."... | Like the subprocess.check_*() helper functions, but tailored to bang.
``cmd_list`` is the command to run, and its arguments as a list of strings.
``input_data`` is the optional data to pass to the command's stdin.
On success, returns the output (i.e. stdout) of the remote command.
On failure, raises... | [
"Like",
"the",
"subprocess",
".",
"check_",
"*",
"()",
"helper",
"functions",
"but",
"tailored",
"to",
"bang",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L424-L448 |
fr33jc/bang | bang/util.py | SharedMap.append | def append(self, list_name, value):
"""Appends :attr:`value` to the list named :attr:`list_name`."""
with self.lock:
l = self.lists.get(list_name)
if l:
l.append(value)
else:
l = [value]
self.lists[list_name] = l | python | def append(self, list_name, value):
"""Appends :attr:`value` to the list named :attr:`list_name`."""
with self.lock:
l = self.lists.get(list_name)
if l:
l.append(value)
else:
l = [value]
self.lists[list_name] = l | [
"def",
"append",
"(",
"self",
",",
"list_name",
",",
"value",
")",
":",
"with",
"self",
".",
"lock",
":",
"l",
"=",
"self",
".",
"lists",
".",
"get",
"(",
"list_name",
")",
"if",
"l",
":",
"l",
".",
"append",
"(",
"value",
")",
"else",
":",
"l"... | Appends :attr:`value` to the list named :attr:`list_name`. | [
"Appends",
":",
"attr",
":",
"value",
"to",
"the",
"list",
"named",
":",
"attr",
":",
"list_name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L105-L113 |
fr33jc/bang | bang/util.py | SharedMap.merge | def merge(self, dict_name, values):
"""
Performs deep-merge of :attr:`values` onto the :class:`Mapping` object
named :attr:`dict_name`.
If :attr:`dict_name` does not yet exist, then a deep copy of
:attr:`values` is assigned as the initial mapping object for the given
nam... | python | def merge(self, dict_name, values):
"""
Performs deep-merge of :attr:`values` onto the :class:`Mapping` object
named :attr:`dict_name`.
If :attr:`dict_name` does not yet exist, then a deep copy of
:attr:`values` is assigned as the initial mapping object for the given
nam... | [
"def",
"merge",
"(",
"self",
",",
"dict_name",
",",
"values",
")",
":",
"with",
"self",
".",
"lock",
":",
"d",
"=",
"self",
".",
"dicts",
".",
"get",
"(",
"dict_name",
")",
"if",
"d",
":",
"deep_merge_dicts",
"(",
"d",
",",
"values",
")",
"else",
... | Performs deep-merge of :attr:`values` onto the :class:`Mapping` object
named :attr:`dict_name`.
If :attr:`dict_name` does not yet exist, then a deep copy of
:attr:`values` is assigned as the initial mapping object for the given
name.
:param str dict_name: The name of the dict ... | [
"Performs",
"deep",
"-",
"merge",
"of",
":",
"attr",
":",
"values",
"onto",
"the",
":",
"class",
":",
"Mapping",
"object",
"named",
":",
"attr",
":",
"dict_name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L115-L135 |
fr33jc/bang | bang/util.py | SharedNamespace.add_if_unique | def add_if_unique(self, name):
"""
Returns ``True`` on success.
Returns ``False`` if the name already exists in the namespace.
"""
with self.lock:
if name not in self.names:
self.names.append(name)
return True
return False | python | def add_if_unique(self, name):
"""
Returns ``True`` on success.
Returns ``False`` if the name already exists in the namespace.
"""
with self.lock:
if name not in self.names:
self.names.append(name)
return True
return False | [
"def",
"add_if_unique",
"(",
"self",
",",
"name",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"name",
"not",
"in",
"self",
".",
"names",
":",
"self",
".",
"names",
".",
"append",
"(",
"name",
")",
"return",
"True",
"return",
"False"
] | Returns ``True`` on success.
Returns ``False`` if the name already exists in the namespace. | [
"Returns",
"True",
"on",
"success",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/util.py#L149-L159 |
openp2pdesign/makerlabs | makerlabs/makery_info.py | get_labs | def get_labs(format):
"""Gets Lab data from makery.info."""
labs_json = data_from_makery_info(makery_info_labs_api_url)
labs = {}
# Load all the FabLabs
for i in labs_json["labs"]:
current_lab = MakeryLab()
current_lab.address_1 = i["address_1"]
current_lab.address_2 = i["a... | python | def get_labs(format):
"""Gets Lab data from makery.info."""
labs_json = data_from_makery_info(makery_info_labs_api_url)
labs = {}
# Load all the FabLabs
for i in labs_json["labs"]:
current_lab = MakeryLab()
current_lab.address_1 = i["address_1"]
current_lab.address_2 = i["a... | [
"def",
"get_labs",
"(",
"format",
")",
":",
"labs_json",
"=",
"data_from_makery_info",
"(",
"makery_info_labs_api_url",
")",
"labs",
"=",
"{",
"}",
"# Load all the FabLabs",
"for",
"i",
"in",
"labs_json",
"[",
"\"labs\"",
"]",
":",
"current_lab",
"=",
"MakeryLab... | Gets Lab data from makery.info. | [
"Gets",
"Lab",
"data",
"from",
"makery",
".",
"info",
"."
] | train | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makery_info.py#L44-L129 |
NegativeMjark/mockingmirror | mockingmirror.py | mirrored | def mirrored(setup):
"""Convience decorator for setUp in testcases::
@mirrored
def setUp(self, mirror, mock):
...
is the same as::
def setUp(self):
self.mirror, self.mock = mirror()
mirror, mock = self.mirror, self.mock
...
"""
@... | python | def mirrored(setup):
"""Convience decorator for setUp in testcases::
@mirrored
def setUp(self, mirror, mock):
...
is the same as::
def setUp(self):
self.mirror, self.mock = mirror()
mirror, mock = self.mirror, self.mock
...
"""
@... | [
"def",
"mirrored",
"(",
"setup",
")",
":",
"@",
"wraps",
"(",
"setup",
")",
"def",
"wrapped_setup",
"(",
"self",
")",
":",
"self",
".",
"mirror",
",",
"self",
".",
"mock",
"=",
"mirror",
"(",
")",
"return",
"setup",
"(",
"self",
",",
"self",
".",
... | Convience decorator for setUp in testcases::
@mirrored
def setUp(self, mirror, mock):
...
is the same as::
def setUp(self):
self.mirror, self.mock = mirror()
mirror, mock = self.mirror, self.mock
... | [
"Convience",
"decorator",
"for",
"setUp",
"in",
"testcases",
"::"
] | train | https://github.com/NegativeMjark/mockingmirror/blob/75cf7d56ab18922394db89725ae9b37f1d4b3711/mockingmirror.py#L27-L45 |
NegativeMjark/mockingmirror | mockingmirror.py | Mirror._add_to_spec | def _add_to_spec(self, name):
"""The spec of the mirrored mock object is updated whenever the mirror
gains new attributes"""
self._spec.add(name)
self._mock.mock_add_spec(list(self._spec), True) | python | def _add_to_spec(self, name):
"""The spec of the mirrored mock object is updated whenever the mirror
gains new attributes"""
self._spec.add(name)
self._mock.mock_add_spec(list(self._spec), True) | [
"def",
"_add_to_spec",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_spec",
".",
"add",
"(",
"name",
")",
"self",
".",
"_mock",
".",
"mock_add_spec",
"(",
"list",
"(",
"self",
".",
"_spec",
")",
",",
"True",
")"
] | The spec of the mirrored mock object is updated whenever the mirror
gains new attributes | [
"The",
"spec",
"of",
"the",
"mirrored",
"mock",
"object",
"is",
"updated",
"whenever",
"the",
"mirror",
"gains",
"new",
"attributes"
] | train | https://github.com/NegativeMjark/mockingmirror/blob/75cf7d56ab18922394db89725ae9b37f1d4b3711/mockingmirror.py#L120-L124 |
pacificclimate/cfmeta | cfmeta/cmip3file.py | get_fp_meta | def get_fp_meta(fp):
"""Processes a CMIP3 style file path.
The standard CMIP3 directory structure:
<experiment>/<variable_name>/<model>/<ensemble_member>/<CMOR filename>.nc
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str):... | python | def get_fp_meta(fp):
"""Processes a CMIP3 style file path.
The standard CMIP3 directory structure:
<experiment>/<variable_name>/<model>/<ensemble_member>/<CMOR filename>.nc
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str):... | [
"def",
"get_fp_meta",
"(",
"fp",
")",
":",
"# Copy metadata list then reverse to start at end of path",
"directory_meta",
"=",
"list",
"(",
"DIR_ATTS",
")",
"# Prefer meta extracted from filename",
"meta",
"=",
"get_dir_meta",
"(",
"fp",
",",
"directory_meta",
")",
"meta"... | Processes a CMIP3 style file path.
The standard CMIP3 directory structure:
<experiment>/<variable_name>/<model>/<ensemble_member>/<CMOR filename>.nc
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str): A file path conforming to C... | [
"Processes",
"a",
"CMIP3",
"style",
"file",
"path",
"."
] | train | https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmip3file.py#L74-L100 |
pacificclimate/cfmeta | cfmeta/cmip3file.py | get_fname_meta | def get_fname_meta(fp):
"""Processes a CMIP3 style file name.
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str): A file path/name conforming to DRS spec.
Returns:
dict: Metadata as extracted from the filename.
.. _Data ... | python | def get_fname_meta(fp):
"""Processes a CMIP3 style file name.
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str): A file path/name conforming to DRS spec.
Returns:
dict: Metadata as extracted from the filename.
.. _Data ... | [
"def",
"get_fname_meta",
"(",
"fp",
")",
":",
"# Strip directory, extension, then split",
"if",
"'/'",
"in",
"fp",
":",
"fp",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fp",
")",
"[",
"1",
"]",
"fname",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
... | Processes a CMIP3 style file name.
Filename is of pattern:
<model>-<experiment>-<variable_name>-<ensemble_member>.nc
Arguments:
fp (str): A file path/name conforming to DRS spec.
Returns:
dict: Metadata as extracted from the filename.
.. _Data Reference Syntax:
http:/... | [
"Processes",
"a",
"CMIP3",
"style",
"file",
"name",
"."
] | train | https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/cmip3file.py#L102-L133 |
Arvedui/picuplib | picuplib/misc.py | gen_user_agent | def gen_user_agent(version):
"""
generating the user agent witch will be used for most requests
monkey patching system and release functions from platform module
to prevent disclosure of the OS and it's version
"""
def monkey_patch():
"""
small monkey patch
"""
r... | python | def gen_user_agent(version):
"""
generating the user agent witch will be used for most requests
monkey patching system and release functions from platform module
to prevent disclosure of the OS and it's version
"""
def monkey_patch():
"""
small monkey patch
"""
r... | [
"def",
"gen_user_agent",
"(",
"version",
")",
":",
"def",
"monkey_patch",
"(",
")",
":",
"\"\"\"\n small monkey patch\n \"\"\"",
"raise",
"IOError",
"# saving original functions",
"orig_system",
"=",
"platform",
".",
"system",
"orig_release",
"=",
"platform"... | generating the user agent witch will be used for most requests
monkey patching system and release functions from platform module
to prevent disclosure of the OS and it's version | [
"generating",
"the",
"user",
"agent",
"witch",
"will",
"be",
"used",
"for",
"most",
"requests"
] | train | https://github.com/Arvedui/picuplib/blob/c8a5d1542dbd421e84afd5ee81fe76efec89fb95/picuplib/misc.py#L27-L54 |
ryanhorn/tyoiOAuth2 | tyoi/oauth2/__init__.py | AccessTokenRequest.build_url_request | def build_url_request(self):
"""
Consults the authenticator and grant for HTTP request parameters and
headers to send with the access token request, builds the request using
the stored endpoint and returns it.
"""
params = {}
headers = {}
self._authenticat... | python | def build_url_request(self):
"""
Consults the authenticator and grant for HTTP request parameters and
headers to send with the access token request, builds the request using
the stored endpoint and returns it.
"""
params = {}
headers = {}
self._authenticat... | [
"def",
"build_url_request",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"headers",
"=",
"{",
"}",
"self",
".",
"_authenticator",
"(",
"params",
",",
"headers",
")",
"self",
".",
"_grant",
"(",
"params",
")",
"return",
"Request",
"(",
"self",
".",
... | Consults the authenticator and grant for HTTP request parameters and
headers to send with the access token request, builds the request using
the stored endpoint and returns it. | [
"Consults",
"the",
"authenticator",
"and",
"grant",
"for",
"HTTP",
"request",
"parameters",
"and",
"headers",
"to",
"send",
"with",
"the",
"access",
"token",
"request",
"builds",
"the",
"request",
"using",
"the",
"stored",
"endpoint",
"and",
"returns",
"it",
"... | train | https://github.com/ryanhorn/tyoiOAuth2/blob/e6a388868ee05c5fef3bec795c5efd88c19b0955/tyoi/oauth2/__init__.py#L93-L103 |
ryanhorn/tyoiOAuth2 | tyoi/oauth2/__init__.py | AccessTokenRequest.send | def send(self, response_decoder=None):
"""
Creates and sends a request to the OAuth server, decodes the response
and returns the resulting token object.
response_decoder - A custom callable can be supplied to override
the default method of extracting AccessToken parame... | python | def send(self, response_decoder=None):
"""
Creates and sends a request to the OAuth server, decodes the response
and returns the resulting token object.
response_decoder - A custom callable can be supplied to override
the default method of extracting AccessToken parame... | [
"def",
"send",
"(",
"self",
",",
"response_decoder",
"=",
"None",
")",
":",
"decoder",
"=",
"loads",
"if",
"response_decoder",
"is",
"not",
"None",
"and",
"callable",
"(",
"response_decoder",
")",
":",
"decoder",
"=",
"response_decoder",
"request",
"=",
"sel... | Creates and sends a request to the OAuth server, decodes the response
and returns the resulting token object.
response_decoder - A custom callable can be supplied to override
the default method of extracting AccessToken parameters from the
response. This is necessary for... | [
"Creates",
"and",
"sends",
"a",
"request",
"to",
"the",
"OAuth",
"server",
"decodes",
"the",
"response",
"and",
"returns",
"the",
"resulting",
"token",
"object",
"."
] | train | https://github.com/ryanhorn/tyoiOAuth2/blob/e6a388868ee05c5fef3bec795c5efd88c19b0955/tyoi/oauth2/__init__.py#L105-L147 |
jpablo128/simplystatic | bin/addrandompages.py | setup_parser | def setup_parser():
'''Set up the command-line options.'''
parser = argparse.ArgumentParser(description='Add random pages to existing site.')
parser.add_argument('-d','--directory', action='store', default= os.getcwd(),
help='Site directory (must be a valid s2 structure).')
... | python | def setup_parser():
'''Set up the command-line options.'''
parser = argparse.ArgumentParser(description='Add random pages to existing site.')
parser.add_argument('-d','--directory', action='store', default= os.getcwd(),
help='Site directory (must be a valid s2 structure).')
... | [
"def",
"setup_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Add random pages to existing site.'",
")",
"parser",
".",
"add_argument",
"(",
"'-d'",
",",
"'--directory'",
",",
"action",
"=",
"'store'",
",",
"d... | Set up the command-line options. | [
"Set",
"up",
"the",
"command",
"-",
"line",
"options",
"."
] | train | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/addrandompages.py#L17-L25 |
jpablo128/simplystatic | bin/addrandompages.py | make_site_obj | def make_site_obj(argdict):
'''Instantiate and return the site. This will be used for all commands'''
d = os.getcwd() #'.'
if 'directory' in argdict:
d = argdict['directory']
try:
s = s2site.Site(d)
except:
print "Could not instantiate site object."
sys.exit()
ret... | python | def make_site_obj(argdict):
'''Instantiate and return the site. This will be used for all commands'''
d = os.getcwd() #'.'
if 'directory' in argdict:
d = argdict['directory']
try:
s = s2site.Site(d)
except:
print "Could not instantiate site object."
sys.exit()
ret... | [
"def",
"make_site_obj",
"(",
"argdict",
")",
":",
"d",
"=",
"os",
".",
"getcwd",
"(",
")",
"#'.'",
"if",
"'directory'",
"in",
"argdict",
":",
"d",
"=",
"argdict",
"[",
"'directory'",
"]",
"try",
":",
"s",
"=",
"s2site",
".",
"Site",
"(",
"d",
")",
... | Instantiate and return the site. This will be used for all commands | [
"Instantiate",
"and",
"return",
"the",
"site",
".",
"This",
"will",
"be",
"used",
"for",
"all",
"commands"
] | train | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/addrandompages.py#L27-L37 |
mikkeljans/pyconomic | pyconomic/base.py | build_model_code | def build_model_code(client):
"""
Generate source code for e-conomic models based on WSDL connection.
This is based on the assumption that the API follows a specific method naming-convention.
Not all models and attributes has been tested.
The source-generation is mostly to help improve readability a... | python | def build_model_code(client):
"""
Generate source code for e-conomic models based on WSDL connection.
This is based on the assumption that the API follows a specific method naming-convention.
Not all models and attributes has been tested.
The source-generation is mostly to help improve readability a... | [
"def",
"build_model_code",
"(",
"client",
")",
":",
"models",
"=",
"{",
"}",
"references",
"=",
"{",
"}",
"for",
"method",
"in",
"client",
".",
"wsdl",
".",
"services",
"[",
"0",
"]",
".",
"ports",
"[",
"0",
"]",
".",
"methods",
".",
"values",
"(",... | Generate source code for e-conomic models based on WSDL connection.
This is based on the assumption that the API follows a specific method naming-convention.
Not all models and attributes has been tested.
The source-generation is mostly to help improve readability and IDE auto-completion.
:param client... | [
"Generate",
"source",
"code",
"for",
"e",
"-",
"conomic",
"models",
"based",
"on",
"WSDL",
"connection",
".",
"This",
"is",
"based",
"on",
"the",
"assumption",
"that",
"the",
"API",
"follows",
"a",
"specific",
"method",
"naming",
"-",
"convention",
".",
"N... | train | https://github.com/mikkeljans/pyconomic/blob/845b8148a364cf5be9065f8a70133d4f16ab645d/pyconomic/base.py#L477-L585 |
mikkeljans/pyconomic | pyconomic/base.py | EConomicsService.__find_handles | def __find_handles(self, model, **spec):
""" find model instances based on given filter (spec)
The filter is based on available server-calls, so some values might not be available for filtering.
Multiple filter-values is going to do multiple server-calls.
For complex filters in small dat... | python | def __find_handles(self, model, **spec):
""" find model instances based on given filter (spec)
The filter is based on available server-calls, so some values might not be available for filtering.
Multiple filter-values is going to do multiple server-calls.
For complex filters in small dat... | [
"def",
"__find_handles",
"(",
"self",
",",
"model",
",",
"*",
"*",
"spec",
")",
":",
"server_calls",
"=",
"[",
"]",
"filter_names",
"=",
"dict",
"(",
"[",
"(",
"f",
"[",
"'name'",
"]",
",",
"f",
"[",
"'method'",
"]",
",",
")",
"for",
"f",
"in",
... | find model instances based on given filter (spec)
The filter is based on available server-calls, so some values might not be available for filtering.
Multiple filter-values is going to do multiple server-calls.
For complex filters in small datasets, it might be faster to fetch all and do your ow... | [
"find",
"model",
"instances",
"based",
"on",
"given",
"filter",
"(",
"spec",
")",
"The",
"filter",
"is",
"based",
"on",
"available",
"server",
"-",
"calls",
"so",
"some",
"values",
"might",
"not",
"be",
"available",
"for",
"filtering",
".",
"Multiple",
"fi... | train | https://github.com/mikkeljans/pyconomic/blob/845b8148a364cf5be9065f8a70133d4f16ab645d/pyconomic/base.py#L76-L117 |
mikkeljans/pyconomic | pyconomic/base.py | EConomicsService.get | def get(self, model, **spec):
"""get a single model instance by handle
:param model: model
:param handle: instance handle
:return:
"""
handles = self.__find_handles(model, **spec)
if len(handles) > 1:
raise MultipleObjectsReturned()
if not ha... | python | def get(self, model, **spec):
"""get a single model instance by handle
:param model: model
:param handle: instance handle
:return:
"""
handles = self.__find_handles(model, **spec)
if len(handles) > 1:
raise MultipleObjectsReturned()
if not ha... | [
"def",
"get",
"(",
"self",
",",
"model",
",",
"*",
"*",
"spec",
")",
":",
"handles",
"=",
"self",
".",
"__find_handles",
"(",
"model",
",",
"*",
"*",
"spec",
")",
"if",
"len",
"(",
"handles",
")",
">",
"1",
":",
"raise",
"MultipleObjectsReturned",
... | get a single model instance by handle
:param model: model
:param handle: instance handle
:return: | [
"get",
"a",
"single",
"model",
"instance",
"by",
"handle"
] | train | https://github.com/mikkeljans/pyconomic/blob/845b8148a364cf5be9065f8a70133d4f16ab645d/pyconomic/base.py#L123-L136 |
oxalorg/ghPublish | ghPublish/ghPublish.py | Publish.get_sha_blob | def get_sha_blob(self):
"""
if the current file exists
returns the sha blob
else
returns None
"""
r = requests.get(self.api_url, auth=self.get_auth_details())
try:
return r.json()['sha']
except KeyError:
return None | python | def get_sha_blob(self):
"""
if the current file exists
returns the sha blob
else
returns None
"""
r = requests.get(self.api_url, auth=self.get_auth_details())
try:
return r.json()['sha']
except KeyError:
return None | [
"def",
"get_sha_blob",
"(",
"self",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"api_url",
",",
"auth",
"=",
"self",
".",
"get_auth_details",
"(",
")",
")",
"try",
":",
"return",
"r",
".",
"json",
"(",
")",
"[",
"'sha'",
"]",
"e... | if the current file exists
returns the sha blob
else
returns None | [
"if",
"the",
"current",
"file",
"exists",
"returns",
"the",
"sha",
"blob",
"else",
"returns",
"None"
] | train | https://github.com/oxalorg/ghPublish/blob/aa3ec8fd2187efd99cffc1a5a76eda4ff2a3b636/ghPublish/ghPublish.py#L31-L42 |
oxalorg/ghPublish | ghPublish/ghPublish.py | Publish.publish_post | def publish_post(self):
"""
If it's a new file, add it.
Else, update it.
"""
payload = {'content': self.content_base64.decode('utf-8')}
sha_blob = self.get_sha_blob()
if sha_blob:
commit_msg = 'ghPublish UPDATE: {}'.format(self.title)
payl... | python | def publish_post(self):
"""
If it's a new file, add it.
Else, update it.
"""
payload = {'content': self.content_base64.decode('utf-8')}
sha_blob = self.get_sha_blob()
if sha_blob:
commit_msg = 'ghPublish UPDATE: {}'.format(self.title)
payl... | [
"def",
"publish_post",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'content'",
":",
"self",
".",
"content_base64",
".",
"decode",
"(",
"'utf-8'",
")",
"}",
"sha_blob",
"=",
"self",
".",
"get_sha_blob",
"(",
")",
"if",
"sha_blob",
":",
"commit_msg",
"=",... | If it's a new file, add it.
Else, update it. | [
"If",
"it",
"s",
"a",
"new",
"file",
"add",
"it",
".",
"Else",
"update",
"it",
"."
] | train | https://github.com/oxalorg/ghPublish/blob/aa3ec8fd2187efd99cffc1a5a76eda4ff2a3b636/ghPublish/ghPublish.py#L44-L67 |
rmorshea/dstruct | dstruct/utils.py | find_file | def find_file(filename, path_dirs=None):
"""Find a file by looking through a sequence of paths.
This iterates through a sequence of paths looking for a file and returns
the full, absolute path of the first occurence of the file. If no set of
path dirs is given, the filename is tested as is, after runni... | python | def find_file(filename, path_dirs=None):
"""Find a file by looking through a sequence of paths.
This iterates through a sequence of paths looking for a file and returns
the full, absolute path of the first occurence of the file. If no set of
path dirs is given, the filename is tested as is, after runni... | [
"def",
"find_file",
"(",
"filename",
",",
"path_dirs",
"=",
"None",
")",
":",
"# If paths are quoted, abspath gets confused, strip them...",
"filename",
"=",
"filename",
".",
"strip",
"(",
"'\"'",
")",
".",
"strip",
"(",
"\"'\"",
")",
"# If the input is an absolute pa... | Find a file by looking through a sequence of paths.
This iterates through a sequence of paths looking for a file and returns
the full, absolute path of the first occurence of the file. If no set of
path dirs is given, the filename is tested as is, after running through
:func:`expandvars` and :func:`exp... | [
"Find",
"a",
"file",
"by",
"looking",
"through",
"a",
"sequence",
"of",
"paths",
".",
"This",
"iterates",
"through",
"a",
"sequence",
"of",
"paths",
"looking",
"for",
"a",
"file",
"and",
"returns",
"the",
"full",
"absolute",
"path",
"of",
"the",
"first",
... | train | https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/utils.py#L21-L65 |
the01/python-paps | examples/gpio_detector.py | GPIODetector._gpio_callback | def _gpio_callback(self, gpio):
"""
Gets triggered whenever the the gpio state changes
:param gpio: Number of gpio that changed
:type gpio: int
:rtype: None
"""
self.debug(u"Triggered #{}".format(gpio))
try:
index = self.gpios.index(gpio)
... | python | def _gpio_callback(self, gpio):
"""
Gets triggered whenever the the gpio state changes
:param gpio: Number of gpio that changed
:type gpio: int
:rtype: None
"""
self.debug(u"Triggered #{}".format(gpio))
try:
index = self.gpios.index(gpio)
... | [
"def",
"_gpio_callback",
"(",
"self",
",",
"gpio",
")",
":",
"self",
".",
"debug",
"(",
"u\"Triggered #{}\"",
".",
"format",
"(",
"gpio",
")",
")",
"try",
":",
"index",
"=",
"self",
".",
"gpios",
".",
"index",
"(",
"gpio",
")",
"except",
"ValueError",
... | Gets triggered whenever the the gpio state changes
:param gpio: Number of gpio that changed
:type gpio: int
:rtype: None | [
"Gets",
"triggered",
"whenever",
"the",
"the",
"gpio",
"state",
"changes"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/gpio_detector.py#L64-L98 |
the01/python-paps | examples/gpio_detector.py | GPIODetector.start | def start(self, blocking=False):
"""
Start the interface
:param blocking: Should the call block until stop() is called
(default: False)
:type blocking: bool
:rtype: None
"""
self.debug("()")
# Init GPIO
# Enable warnings
GPIO.s... | python | def start(self, blocking=False):
"""
Start the interface
:param blocking: Should the call block until stop() is called
(default: False)
:type blocking: bool
:rtype: None
"""
self.debug("()")
# Init GPIO
# Enable warnings
GPIO.s... | [
"def",
"start",
"(",
"self",
",",
"blocking",
"=",
"False",
")",
":",
"self",
".",
"debug",
"(",
"\"()\"",
")",
"# Init GPIO",
"# Enable warnings",
"GPIO",
".",
"setwarnings",
"(",
"True",
")",
"# Careful - numbering between different pi version might differ",
"if",... | Start the interface
:param blocking: Should the call block until stop() is called
(default: False)
:type blocking: bool
:rtype: None | [
"Start",
"the",
"interface"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/gpio_detector.py#L100-L133 |
the01/python-paps | examples/gpio_detector.py | GPIODetector.stop | def stop(self):
"""
Stop the interface
:rtype: None
"""
self.debug("()")
# Not sure if this is necessary, but good form
if self._is_running:
for gpio in self.gpios:
GPIO.remove_event_detect(gpio)
# Cleanup - includes used n... | python | def stop(self):
"""
Stop the interface
:rtype: None
"""
self.debug("()")
# Not sure if this is necessary, but good form
if self._is_running:
for gpio in self.gpios:
GPIO.remove_event_detect(gpio)
# Cleanup - includes used n... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"debug",
"(",
"\"()\"",
")",
"# Not sure if this is necessary, but good form",
"if",
"self",
".",
"_is_running",
":",
"for",
"gpio",
"in",
"self",
".",
"gpios",
":",
"GPIO",
".",
"remove_event_detect",
"(",
... | Stop the interface
:rtype: None | [
"Stop",
"the",
"interface"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/gpio_detector.py#L135-L153 |
pavelsof/ipalint | ipalint/report.py | Reporter.add | def add(self, lines, message):
"""
Adds a lint issue to the report. The first arg should be [] of lines on
which the issue is present. The second arg should be the error message.
"""
error = Error(message)
if error not in self.errors:
self.errors[error] = []
self.errors[error].extend(lines) | python | def add(self, lines, message):
"""
Adds a lint issue to the report. The first arg should be [] of lines on
which the issue is present. The second arg should be the error message.
"""
error = Error(message)
if error not in self.errors:
self.errors[error] = []
self.errors[error].extend(lines) | [
"def",
"add",
"(",
"self",
",",
"lines",
",",
"message",
")",
":",
"error",
"=",
"Error",
"(",
"message",
")",
"if",
"error",
"not",
"in",
"self",
".",
"errors",
":",
"self",
".",
"errors",
"[",
"error",
"]",
"=",
"[",
"]",
"self",
".",
"errors",... | Adds a lint issue to the report. The first arg should be [] of lines on
which the issue is present. The second arg should be the error message. | [
"Adds",
"a",
"lint",
"issue",
"to",
"the",
"report",
".",
"The",
"first",
"arg",
"should",
"be",
"[]",
"of",
"lines",
"on",
"which",
"the",
"issue",
"is",
"present",
".",
"The",
"second",
"arg",
"should",
"be",
"the",
"error",
"message",
"."
] | train | https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/report.py#L28-L38 |
pavelsof/ipalint | ipalint/report.py | Reporter._get_linewise_report | def _get_linewise_report(self):
"""
Returns a report each line of which comprises a pair of an input line
and an error. Unlike in the standard report, errors will appear as many
times as they occur.
Helper for the get_report method.
"""
d = defaultdict(list) # line: [] of errors
for error, lines in s... | python | def _get_linewise_report(self):
"""
Returns a report each line of which comprises a pair of an input line
and an error. Unlike in the standard report, errors will appear as many
times as they occur.
Helper for the get_report method.
"""
d = defaultdict(list) # line: [] of errors
for error, lines in s... | [
"def",
"_get_linewise_report",
"(",
"self",
")",
":",
"d",
"=",
"defaultdict",
"(",
"list",
")",
"# line: [] of errors",
"for",
"error",
",",
"lines",
"in",
"self",
".",
"errors",
".",
"items",
"(",
")",
":",
"for",
"line_num",
"in",
"lines",
":",
"d",
... | Returns a report each line of which comprises a pair of an input line
and an error. Unlike in the standard report, errors will appear as many
times as they occur.
Helper for the get_report method. | [
"Returns",
"a",
"report",
"each",
"line",
"of",
"which",
"comprises",
"a",
"pair",
"of",
"an",
"input",
"line",
"and",
"an",
"error",
".",
"Unlike",
"in",
"the",
"standard",
"report",
"errors",
"will",
"appear",
"as",
"many",
"times",
"as",
"they",
"occu... | train | https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/report.py#L49-L66 |
pavelsof/ipalint | ipalint/report.py | Reporter._get_report | def _get_report(self, with_line_nums=True):
"""
Returns a report which includes each distinct error only once, together
with a list of the input lines where the error occurs. The latter will
be omitted if flag is set to False.
Helper for the get_report method.
"""
templ = '{} ← {}' if with_line_nums else... | python | def _get_report(self, with_line_nums=True):
"""
Returns a report which includes each distinct error only once, together
with a list of the input lines where the error occurs. The latter will
be omitted if flag is set to False.
Helper for the get_report method.
"""
templ = '{} ← {}' if with_line_nums else... | [
"def",
"_get_report",
"(",
"self",
",",
"with_line_nums",
"=",
"True",
")",
":",
"templ",
"=",
"'{} ← {}' i",
" w",
"th_line_nums e",
"se '",
"}'",
"return",
"'\\n'",
".",
"join",
"(",
"[",
"templ",
".",
"format",
"(",
"error",
".",
"string",
",",
"','",... | Returns a report which includes each distinct error only once, together
with a list of the input lines where the error occurs. The latter will
be omitted if flag is set to False.
Helper for the get_report method. | [
"Returns",
"a",
"report",
"which",
"includes",
"each",
"distinct",
"error",
"only",
"once",
"together",
"with",
"a",
"list",
"of",
"the",
"input",
"lines",
"where",
"the",
"error",
"occurs",
".",
"The",
"latter",
"will",
"be",
"omitted",
"if",
"flag",
"is"... | train | https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/report.py#L69-L81 |
pavelsof/ipalint | ipalint/report.py | Reporter.get_report | def get_report(self, linewise=False, no_lines=False):
"""
Returns a string describing all the errors collected so far (the
report). The first flag determines the type of report. The second flag
is ignored if the first is set to True.
"""
if linewise:
return self._get_linewise_report()
else:
return s... | python | def get_report(self, linewise=False, no_lines=False):
"""
Returns a string describing all the errors collected so far (the
report). The first flag determines the type of report. The second flag
is ignored if the first is set to True.
"""
if linewise:
return self._get_linewise_report()
else:
return s... | [
"def",
"get_report",
"(",
"self",
",",
"linewise",
"=",
"False",
",",
"no_lines",
"=",
"False",
")",
":",
"if",
"linewise",
":",
"return",
"self",
".",
"_get_linewise_report",
"(",
")",
"else",
":",
"return",
"self",
".",
"_get_report",
"(",
"not",
"no_l... | Returns a string describing all the errors collected so far (the
report). The first flag determines the type of report. The second flag
is ignored if the first is set to True. | [
"Returns",
"a",
"string",
"describing",
"all",
"the",
"errors",
"collected",
"so",
"far",
"(",
"the",
"report",
")",
".",
"The",
"first",
"flag",
"determines",
"the",
"type",
"of",
"report",
".",
"The",
"second",
"flag",
"is",
"ignored",
"if",
"the",
"fi... | train | https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/report.py#L84-L93 |
davidmiller/letter | letter/sms.py | TwillioPostie.send | def send(self, to, from_, body):
"""
Send BODY to TO from FROM as an SMS!
"""
try:
msg = self.client.sms.messages.create(
body=body,
to=to,
from_=from_
)
print msg.sid
except twilio.TwilioRest... | python | def send(self, to, from_, body):
"""
Send BODY to TO from FROM as an SMS!
"""
try:
msg = self.client.sms.messages.create(
body=body,
to=to,
from_=from_
)
print msg.sid
except twilio.TwilioRest... | [
"def",
"send",
"(",
"self",
",",
"to",
",",
"from_",
",",
"body",
")",
":",
"try",
":",
"msg",
"=",
"self",
".",
"client",
".",
"sms",
".",
"messages",
".",
"create",
"(",
"body",
"=",
"body",
",",
"to",
"=",
"to",
",",
"from_",
"=",
"from_",
... | Send BODY to TO from FROM as an SMS! | [
"Send",
"BODY",
"to",
"TO",
"from",
"FROM",
"as",
"an",
"SMS!"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/sms.py#L14-L26 |
ravenac95/pippy | pippy/utils.py | tar_gzip_dir | def tar_gzip_dir(directory, destination, base=None):
"""Creates a tar.gz from a directory."""
dest_file = tarfile.open(destination, 'w:gz')
abs_dir_path = os.path.abspath(directory)
base_name = abs_dir_path + "/"
base = base or os.path.basename(directory)
for path, dirnames, filenames in os.walk... | python | def tar_gzip_dir(directory, destination, base=None):
"""Creates a tar.gz from a directory."""
dest_file = tarfile.open(destination, 'w:gz')
abs_dir_path = os.path.abspath(directory)
base_name = abs_dir_path + "/"
base = base or os.path.basename(directory)
for path, dirnames, filenames in os.walk... | [
"def",
"tar_gzip_dir",
"(",
"directory",
",",
"destination",
",",
"base",
"=",
"None",
")",
":",
"dest_file",
"=",
"tarfile",
".",
"open",
"(",
"destination",
",",
"'w:gz'",
")",
"abs_dir_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
"... | Creates a tar.gz from a directory. | [
"Creates",
"a",
"tar",
".",
"gz",
"from",
"a",
"directory",
"."
] | train | https://github.com/ravenac95/pippy/blob/8ae26e0a3f20d99103a421d9b94dc8d2169688b1/pippy/utils.py#L14-L33 |
bioasp/ingranalyze | src/sif_parser.py | Parser.p_statement_expr | def p_statement_expr(self, t):
'''statement : node_expression PLUS node_expression
| node_expression MINUS node_expression'''
if len(t)<3 :
self.accu.add(Term('input', [t[1]]))
print('input', t[1])
else :
#print(t[1], t[2], t[3]
self.accu.add(Term('edge', ... | python | def p_statement_expr(self, t):
'''statement : node_expression PLUS node_expression
| node_expression MINUS node_expression'''
if len(t)<3 :
self.accu.add(Term('input', [t[1]]))
print('input', t[1])
else :
#print(t[1], t[2], t[3]
self.accu.add(Term('edge', ... | [
"def",
"p_statement_expr",
"(",
"self",
",",
"t",
")",
":",
"if",
"len",
"(",
"t",
")",
"<",
"3",
":",
"self",
".",
"accu",
".",
"add",
"(",
"Term",
"(",
"'input'",
",",
"[",
"t",
"[",
"1",
"]",
"]",
")",
")",
"print",
"(",
"'input'",
",",
... | statement : node_expression PLUS node_expression
| node_expression MINUS node_expression | [
"statement",
":",
"node_expression",
"PLUS",
"node_expression",
"|",
"node_expression",
"MINUS",
"node_expression"
] | train | https://github.com/bioasp/ingranalyze/blob/60bdd679b6044a4d142abbca5bbe3cd5e9fd7596/src/sif_parser.py#L64-L73 |
bioasp/ingranalyze | src/sif_parser.py | Parser.p_node_expression | def p_node_expression(self, t):
'''node_expression : IDENT'''
if len(t)<3 :
t[0]=t[1]
#print(t[1]
self.accu.add(Term('vertex', ["gen(\""+t[1]+"\")"]))
else : t[0] = "unknown" | python | def p_node_expression(self, t):
'''node_expression : IDENT'''
if len(t)<3 :
t[0]=t[1]
#print(t[1]
self.accu.add(Term('vertex', ["gen(\""+t[1]+"\")"]))
else : t[0] = "unknown" | [
"def",
"p_node_expression",
"(",
"self",
",",
"t",
")",
":",
"if",
"len",
"(",
"t",
")",
"<",
"3",
":",
"t",
"[",
"0",
"]",
"=",
"t",
"[",
"1",
"]",
"#print(t[1]",
"self",
".",
"accu",
".",
"add",
"(",
"Term",
"(",
"'vertex'",
",",
"[",
"\"ge... | node_expression : IDENT | [
"node_expression",
":",
"IDENT"
] | train | https://github.com/bioasp/ingranalyze/blob/60bdd679b6044a4d142abbca5bbe3cd5e9fd7596/src/sif_parser.py#L77-L83 |
aquatix/python-utilkit | utilkit/datetimeutil.py | tuple_to_string | def tuple_to_string(date_tuple):
"""
Create a yyyy-mm(-dd) string from a tuple containing (yyyy, m) (or one with the day too)
"""
if len(date_tuple) == 2:
# It's yyyy-mm
return str(date_tuple[0]).zfill(4) + '-' + str(date_tuple[1]).zfill(2)
# It's yyyy-mm-dd
return str(date_tuple... | python | def tuple_to_string(date_tuple):
"""
Create a yyyy-mm(-dd) string from a tuple containing (yyyy, m) (or one with the day too)
"""
if len(date_tuple) == 2:
# It's yyyy-mm
return str(date_tuple[0]).zfill(4) + '-' + str(date_tuple[1]).zfill(2)
# It's yyyy-mm-dd
return str(date_tuple... | [
"def",
"tuple_to_string",
"(",
"date_tuple",
")",
":",
"if",
"len",
"(",
"date_tuple",
")",
"==",
"2",
":",
"# It's yyyy-mm",
"return",
"str",
"(",
"date_tuple",
"[",
"0",
"]",
")",
".",
"zfill",
"(",
"4",
")",
"+",
"'-'",
"+",
"str",
"(",
"date_tupl... | Create a yyyy-mm(-dd) string from a tuple containing (yyyy, m) (or one with the day too) | [
"Create",
"a",
"yyyy",
"-",
"mm",
"(",
"-",
"dd",
")",
"string",
"from",
"a",
"tuple",
"containing",
"(",
"yyyy",
"m",
")",
"(",
"or",
"one",
"with",
"the",
"day",
"too",
")"
] | train | https://github.com/aquatix/python-utilkit/blob/1b4a4175381d2175592208619315f399610f915c/utilkit/datetimeutil.py#L52-L60 |
za-creature/gulpless | gulpless/__init__.py | main | def main():
"""Entry point for command line usage."""
import colorama
import argparse
import logging
import sys
import os
parser = argparse.ArgumentParser(prog="gulpless",
description="Simple build system.")
parser.add_argument("-v", "--version",
... | python | def main():
"""Entry point for command line usage."""
import colorama
import argparse
import logging
import sys
import os
parser = argparse.ArgumentParser(prog="gulpless",
description="Simple build system.")
parser.add_argument("-v", "--version",
... | [
"def",
"main",
"(",
")",
":",
"import",
"colorama",
"import",
"argparse",
"import",
"logging",
"import",
"sys",
"import",
"os",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"gulpless\"",
",",
"description",
"=",
"\"Simple build system.\"... | Entry point for command line usage. | [
"Entry",
"point",
"for",
"command",
"line",
"usage",
"."
] | train | https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/__init__.py#L11-L70 |
inveniosoftware-attic/invenio-knowledge | invenio_knowledge/models.py | del_kwnkb | def del_kwnkb(mapper, connection, target):
"""Remove taxonomy file."""
if(target.kbtype == KnwKB.KNWKB_TYPES['taxonomy']):
# Delete taxonomy file
if os.path.isfile(target.get_filename()):
os.remove(target.get_filename()) | python | def del_kwnkb(mapper, connection, target):
"""Remove taxonomy file."""
if(target.kbtype == KnwKB.KNWKB_TYPES['taxonomy']):
# Delete taxonomy file
if os.path.isfile(target.get_filename()):
os.remove(target.get_filename()) | [
"def",
"del_kwnkb",
"(",
"mapper",
",",
"connection",
",",
"target",
")",
":",
"if",
"(",
"target",
".",
"kbtype",
"==",
"KnwKB",
".",
"KNWKB_TYPES",
"[",
"'taxonomy'",
"]",
")",
":",
"# Delete taxonomy file",
"if",
"os",
".",
"path",
".",
"isfile",
"(",... | Remove taxonomy file. | [
"Remove",
"taxonomy",
"file",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/models.py#L239-L244 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.