id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
245,600 | rameshg87/pyremotevbox | pyremotevbox/ZSI/digest_auth.py | fetch_challenge | def fetch_challenge(http_header):
""" apparently keywords Basic and Digest are not being checked
anywhere and decisions are being made based on authorization
configuration of client, so I guess you better know what you are
doing. Here I am requiring one or the other be specified.
challenge Basic auth_... | python | def fetch_challenge(http_header):
""" apparently keywords Basic and Digest are not being checked
anywhere and decisions are being made based on authorization
configuration of client, so I guess you better know what you are
doing. Here I am requiring one or the other be specified.
challenge Basic auth_... | [
"def",
"fetch_challenge",
"(",
"http_header",
")",
":",
"m",
"=",
"fetch_challenge",
".",
"wwwauth_header_re",
".",
"match",
"(",
"http_header",
")",
"if",
"m",
"is",
"None",
":",
"raise",
"RuntimeError",
",",
"'expecting \"WWW-Authenticate header [Basic,Digest]\"'",
... | apparently keywords Basic and Digest are not being checked
anywhere and decisions are being made based on authorization
configuration of client, so I guess you better know what you are
doing. Here I am requiring one or the other be specified.
challenge Basic auth_param
challenge Digest auth_param | [
"apparently",
"keywords",
"Basic",
"and",
"Digest",
"are",
"not",
"being",
"checked",
"anywhere",
"and",
"decisions",
"are",
"being",
"made",
"based",
"on",
"authorization",
"configuration",
"of",
"client",
"so",
"I",
"guess",
"you",
"better",
"know",
"what",
... | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/digest_auth.py#L77-L97 |
245,601 | bwesterb/tkbd | src/mytimetable.py | MyTimetable.open_url | def open_url(self, url):
""" Open's URL with apiToken in the headers """
try:
c = pycurl.Curl()
c.setopt(pycurl.FAILONERROR, True)
c.setopt(pycurl.URL, "%s/api/v0/%s" % (self.url, url))
c.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % self.userAgent,
... | python | def open_url(self, url):
""" Open's URL with apiToken in the headers """
try:
c = pycurl.Curl()
c.setopt(pycurl.FAILONERROR, True)
c.setopt(pycurl.URL, "%s/api/v0/%s" % (self.url, url))
c.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % self.userAgent,
... | [
"def",
"open_url",
"(",
"self",
",",
"url",
")",
":",
"try",
":",
"c",
"=",
"pycurl",
".",
"Curl",
"(",
")",
"c",
".",
"setopt",
"(",
"pycurl",
".",
"FAILONERROR",
",",
"True",
")",
"c",
".",
"setopt",
"(",
"pycurl",
".",
"URL",
",",
"\"%s/api/v0... | Open's URL with apiToken in the headers | [
"Open",
"s",
"URL",
"with",
"apiToken",
"in",
"the",
"headers"
] | fcf16977d38a93fe9b7fa198513007ab9921b650 | https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/mytimetable.py#L27-L50 |
245,602 | Nixiware/viper | nx/viper/module.py | Module._loadConfiguration | def _loadConfiguration(self):
"""
Load module configuration files.
:return: <void>
"""
configPath = os.path.join(self.path, "config")
if not os.path.isdir(configPath):
return
config = Config(configPath)
Config.mergeDictionaries(config.getDat... | python | def _loadConfiguration(self):
"""
Load module configuration files.
:return: <void>
"""
configPath = os.path.join(self.path, "config")
if not os.path.isdir(configPath):
return
config = Config(configPath)
Config.mergeDictionaries(config.getDat... | [
"def",
"_loadConfiguration",
"(",
"self",
")",
":",
"configPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"\"config\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"configPath",
")",
":",
"return",
"config",
"=... | Load module configuration files.
:return: <void> | [
"Load",
"module",
"configuration",
"files",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L24-L36 |
245,603 | Nixiware/viper | nx/viper/module.py | Module._loadModels | def _loadModels(self):
"""
Load module models.
:return: <void>
"""
modelsPath = os.path.join(self.path, "model")
if not os.path.isdir(modelsPath):
return
for modelFile in os.listdir(modelsPath):
modelName = modelFile.replace(".py", "")
... | python | def _loadModels(self):
"""
Load module models.
:return: <void>
"""
modelsPath = os.path.join(self.path, "model")
if not os.path.isdir(modelsPath):
return
for modelFile in os.listdir(modelsPath):
modelName = modelFile.replace(".py", "")
... | [
"def",
"_loadModels",
"(",
"self",
")",
":",
"modelsPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"\"model\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"modelsPath",
")",
":",
"return",
"for",
"modelFile",
... | Load module models.
:return: <void> | [
"Load",
"module",
"models",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L38-L67 |
245,604 | Nixiware/viper | nx/viper/module.py | Module._loadServices | def _loadServices(self):
"""
Load module services.
:return: <void>
"""
servicesPath = os.path.join(self.path, "service")
if not os.path.isdir(servicesPath):
return
self._scanDirectoryForServices(servicesPath) | python | def _loadServices(self):
"""
Load module services.
:return: <void>
"""
servicesPath = os.path.join(self.path, "service")
if not os.path.isdir(servicesPath):
return
self._scanDirectoryForServices(servicesPath) | [
"def",
"_loadServices",
"(",
"self",
")",
":",
"servicesPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"\"service\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"servicesPath",
")",
":",
"return",
"self",
".",... | Load module services.
:return: <void> | [
"Load",
"module",
"services",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L69-L79 |
245,605 | Nixiware/viper | nx/viper/module.py | Module._loadService | def _loadService(self, servicePath):
"""
Check if an application service can be found at the specified path.
If found, instantiate it and add it to the application service pool.
:param: <str> service file path
:return: <void>
"""
serviceName = ntpath.basename(ser... | python | def _loadService(self, servicePath):
"""
Check if an application service can be found at the specified path.
If found, instantiate it and add it to the application service pool.
:param: <str> service file path
:return: <void>
"""
serviceName = ntpath.basename(ser... | [
"def",
"_loadService",
"(",
"self",
",",
"servicePath",
")",
":",
"serviceName",
"=",
"ntpath",
".",
"basename",
"(",
"servicePath",
")",
".",
"replace",
"(",
"\".py\"",
",",
"\"\"",
")",
"# importing service",
"serviceSpec",
"=",
"importlib",
".",
"util",
"... | Check if an application service can be found at the specified path.
If found, instantiate it and add it to the application service pool.
:param: <str> service file path
:return: <void> | [
"Check",
"if",
"an",
"application",
"service",
"can",
"be",
"found",
"at",
"the",
"specified",
"path",
".",
"If",
"found",
"instantiate",
"it",
"and",
"add",
"it",
"to",
"the",
"application",
"service",
"pool",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L108-L134 |
245,606 | colab/colab-superarchives-plugin | src/colab_superarchives/views.py | EmailView.post | def post(self, request, key):
"""Create new email address that will wait for validation"""
email = request.POST.get('email')
user_id = request.POST.get('user')
if not email:
return http.HttpResponseBadRequest()
try:
EmailAddressValidation.objects.create(... | python | def post(self, request, key):
"""Create new email address that will wait for validation"""
email = request.POST.get('email')
user_id = request.POST.get('user')
if not email:
return http.HttpResponseBadRequest()
try:
EmailAddressValidation.objects.create(... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"key",
")",
":",
"email",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'email'",
")",
"user_id",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'user'",
")",
"if",
"not",
"email",
":",
"return",
... | Create new email address that will wait for validation | [
"Create",
"new",
"email",
"address",
"that",
"will",
"wait",
"for",
"validation"
] | fe588a1d4fac874ccad2063ee19a857028a22721 | https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/views.py#L202-L219 |
245,607 | maxfischer2781/chainlet | chainlet/concurrency/base.py | multi_iter | def multi_iter(iterable, count=2):
"""Return `count` independent, thread-safe iterators for `iterable`"""
# no need to special-case re-usable, container-like iterables
if not isinstance(
iterable,
(
list, tuple, set,
FutureChainResults,
... | python | def multi_iter(iterable, count=2):
"""Return `count` independent, thread-safe iterators for `iterable`"""
# no need to special-case re-usable, container-like iterables
if not isinstance(
iterable,
(
list, tuple, set,
FutureChainResults,
... | [
"def",
"multi_iter",
"(",
"iterable",
",",
"count",
"=",
"2",
")",
":",
"# no need to special-case re-usable, container-like iterables",
"if",
"not",
"isinstance",
"(",
"iterable",
",",
"(",
"list",
",",
"tuple",
",",
"set",
",",
"FutureChainResults",
",",
"collec... | Return `count` independent, thread-safe iterators for `iterable` | [
"Return",
"count",
"independent",
"thread",
"-",
"safe",
"iterators",
"for",
"iterable"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L192-L203 |
245,608 | maxfischer2781/chainlet | chainlet/concurrency/base.py | StoredFuture.realise | def realise(self):
"""
Realise the future if possible
If the future has not been realised yet, do so in the current thread.
This will block execution until the future is realised.
Otherwise, do not block but return whether the result is already available.
This will not ... | python | def realise(self):
"""
Realise the future if possible
If the future has not been realised yet, do so in the current thread.
This will block execution until the future is realised.
Otherwise, do not block but return whether the result is already available.
This will not ... | [
"def",
"realise",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mutex",
".",
"acquire",
"(",
"False",
")",
":",
"# realise the future in this thread",
"try",
":",
"if",
"self",
".",
"_result",
"is",
"not",
"None",
":",
"return",
"True",
"call",
",",
"args"... | Realise the future if possible
If the future has not been realised yet, do so in the current thread.
This will block execution until the future is realised.
Otherwise, do not block but return whether the result is already available.
This will not return the result nor propagate any exc... | [
"Realise",
"the",
"future",
"if",
"possible"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L30-L60 |
245,609 | maxfischer2781/chainlet | chainlet/concurrency/base.py | StoredFuture.result | def result(self):
"""
The result from realising the future
If the result is not available, block until done.
:return: result of the future
:raises: any exception encountered during realising the future
"""
if self._result is None:
self.await_result()... | python | def result(self):
"""
The result from realising the future
If the result is not available, block until done.
:return: result of the future
:raises: any exception encountered during realising the future
"""
if self._result is None:
self.await_result()... | [
"def",
"result",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result",
"is",
"None",
":",
"self",
".",
"await_result",
"(",
")",
"chunks",
",",
"exception",
"=",
"self",
".",
"_result",
"if",
"exception",
"is",
"None",
":",
"return",
"chunks",
"raise",
... | The result from realising the future
If the result is not available, block until done.
:return: result of the future
:raises: any exception encountered during realising the future | [
"The",
"result",
"from",
"realising",
"the",
"future"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L71-L85 |
245,610 | msvana/warcreader | warcreader/warcreader.py | WarcFile.get_warcinfo | def get_warcinfo(self):
'''
Returns WARCINFO record from the archieve as a single string including
WARC header. Expects the record to be in the beginning of the archieve,
otherwise it will be not found.
'''
if self.searched_for_warcinfo:
return self.warcinfo
prev_line = None
in_warcinfo_rec... | python | def get_warcinfo(self):
'''
Returns WARCINFO record from the archieve as a single string including
WARC header. Expects the record to be in the beginning of the archieve,
otherwise it will be not found.
'''
if self.searched_for_warcinfo:
return self.warcinfo
prev_line = None
in_warcinfo_rec... | [
"def",
"get_warcinfo",
"(",
"self",
")",
":",
"if",
"self",
".",
"searched_for_warcinfo",
":",
"return",
"self",
".",
"warcinfo",
"prev_line",
"=",
"None",
"in_warcinfo_record",
"=",
"False",
"self",
".",
"searched_for_warcinfo",
"=",
"True",
"for",
"line",
"i... | Returns WARCINFO record from the archieve as a single string including
WARC header. Expects the record to be in the beginning of the archieve,
otherwise it will be not found. | [
"Returns",
"WARCINFO",
"record",
"from",
"the",
"archieve",
"as",
"a",
"single",
"string",
"including",
"WARC",
"header",
".",
"Expects",
"the",
"record",
"to",
"be",
"in",
"the",
"beginning",
"of",
"the",
"archieve",
"otherwise",
"it",
"will",
"be",
"not",
... | c61454ce95a7b6e3e8560852dfd319dd64351bf0 | https://github.com/msvana/warcreader/blob/c61454ce95a7b6e3e8560852dfd319dd64351bf0/warcreader/warcreader.py#L105-L132 |
245,611 | msvana/warcreader | warcreader/warcreader.py | WarcFile.init_state | def init_state(self):
''' Sets the initial state of the state machine. '''
self.in_warc_response = False
self.in_http_response = False
self.in_payload = False | python | def init_state(self):
''' Sets the initial state of the state machine. '''
self.in_warc_response = False
self.in_http_response = False
self.in_payload = False | [
"def",
"init_state",
"(",
"self",
")",
":",
"self",
".",
"in_warc_response",
"=",
"False",
"self",
".",
"in_http_response",
"=",
"False",
"self",
".",
"in_payload",
"=",
"False"
] | Sets the initial state of the state machine. | [
"Sets",
"the",
"initial",
"state",
"of",
"the",
"state",
"machine",
"."
] | c61454ce95a7b6e3e8560852dfd319dd64351bf0 | https://github.com/msvana/warcreader/blob/c61454ce95a7b6e3e8560852dfd319dd64351bf0/warcreader/warcreader.py#L134-L138 |
245,612 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore._keys_from_label | def _keys_from_label(self, label):
'''Convert a label into a kvl key.
'''
k1 = (label.content_id1, label.content_id2,
label.annotator_id, time_complement(label.epoch_ticks))
k2 = (label.content_id2, label.content_id1,
label.annotator_id, time_complement(label.... | python | def _keys_from_label(self, label):
'''Convert a label into a kvl key.
'''
k1 = (label.content_id1, label.content_id2,
label.annotator_id, time_complement(label.epoch_ticks))
k2 = (label.content_id2, label.content_id1,
label.annotator_id, time_complement(label.... | [
"def",
"_keys_from_label",
"(",
"self",
",",
"label",
")",
":",
"k1",
"=",
"(",
"label",
".",
"content_id1",
",",
"label",
".",
"content_id2",
",",
"label",
".",
"annotator_id",
",",
"time_complement",
"(",
"label",
".",
"epoch_ticks",
")",
")",
"k2",
"=... | Convert a label into a kvl key. | [
"Convert",
"a",
"label",
"into",
"a",
"kvl",
"key",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L218-L225 |
245,613 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore._value_from_label | def _value_from_label(self, label):
'''Convert a label into a kvl value.
'''
unser_val = (label.rel_strength.value, label.meta)
return cbor.dumps(unser_val) | python | def _value_from_label(self, label):
'''Convert a label into a kvl value.
'''
unser_val = (label.rel_strength.value, label.meta)
return cbor.dumps(unser_val) | [
"def",
"_value_from_label",
"(",
"self",
",",
"label",
")",
":",
"unser_val",
"=",
"(",
"label",
".",
"rel_strength",
".",
"value",
",",
"label",
".",
"meta",
")",
"return",
"cbor",
".",
"dumps",
"(",
"unser_val",
")"
] | Convert a label into a kvl value. | [
"Convert",
"a",
"label",
"into",
"a",
"kvl",
"value",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L227-L231 |
245,614 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore.get | def get(self, cid1, cid2, annotator_id):
'''Retrieve a relation label from the store.
'''
t = (cid1, cid2, annotator_id)
for k, v in self.kvl.scan(self.TABLE, (t, t)):
return self._label_from_kvlayer(k, v) | python | def get(self, cid1, cid2, annotator_id):
'''Retrieve a relation label from the store.
'''
t = (cid1, cid2, annotator_id)
for k, v in self.kvl.scan(self.TABLE, (t, t)):
return self._label_from_kvlayer(k, v) | [
"def",
"get",
"(",
"self",
",",
"cid1",
",",
"cid2",
",",
"annotator_id",
")",
":",
"t",
"=",
"(",
"cid1",
",",
"cid2",
",",
"annotator_id",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"kvl",
".",
"scan",
"(",
"self",
".",
"TABLE",
",",
"(",
... | Retrieve a relation label from the store. | [
"Retrieve",
"a",
"relation",
"label",
"from",
"the",
"store",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L256-L261 |
245,615 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore.get_related | def get_related(self, content_id, min_strength=None):
'''Get positive relation labels for ``cid``.
If ``min_strength`` is set, will restrict results to labels
with a ``rel_strength`` greater or equal to the provided
``RelationStrength`` value. Note: ``min_strength`` should be of
... | python | def get_related(self, content_id, min_strength=None):
'''Get positive relation labels for ``cid``.
If ``min_strength`` is set, will restrict results to labels
with a ``rel_strength`` greater or equal to the provided
``RelationStrength`` value. Note: ``min_strength`` should be of
... | [
"def",
"get_related",
"(",
"self",
",",
"content_id",
",",
"min_strength",
"=",
"None",
")",
":",
"def",
"is_related",
"(",
"label",
")",
":",
"if",
"min_strength",
"is",
"not",
"None",
":",
"return",
"label",
".",
"rel_strength",
">=",
"min_strength",
"el... | Get positive relation labels for ``cid``.
If ``min_strength`` is set, will restrict results to labels
with a ``rel_strength`` greater or equal to the provided
``RelationStrength`` value. Note: ``min_strength`` should be of
type ``RelationStrength``. | [
"Get",
"positive",
"relation",
"labels",
"for",
"cid",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L263-L278 |
245,616 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore.get_related_ids | def get_related_ids(self, content_id, min_strength=None):
'''Get identifiers for related identifiers.
'''
related_labels = self.get_related(content_id,
min_strength=min_strength)
related_idents = set()
for label in related_labels:
... | python | def get_related_ids(self, content_id, min_strength=None):
'''Get identifiers for related identifiers.
'''
related_labels = self.get_related(content_id,
min_strength=min_strength)
related_idents = set()
for label in related_labels:
... | [
"def",
"get_related_ids",
"(",
"self",
",",
"content_id",
",",
"min_strength",
"=",
"None",
")",
":",
"related_labels",
"=",
"self",
".",
"get_related",
"(",
"content_id",
",",
"min_strength",
"=",
"min_strength",
")",
"related_idents",
"=",
"set",
"(",
")",
... | Get identifiers for related identifiers. | [
"Get",
"identifiers",
"for",
"related",
"identifiers",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L280-L289 |
245,617 | dossier/dossier.label | dossier/label/relation_label.py | RelationLabelStore.get_relationships_for_idents | def get_relationships_for_idents(self, cid, idents):
'''Get relationships between ``idents`` and a ``cid``.
Returns a dictionary mapping the identifiers in ``idents``
to either None, if no relationship label is found between
the identifier and ``cid``, or a RelationshipType classifying
... | python | def get_relationships_for_idents(self, cid, idents):
'''Get relationships between ``idents`` and a ``cid``.
Returns a dictionary mapping the identifiers in ``idents``
to either None, if no relationship label is found between
the identifier and ``cid``, or a RelationshipType classifying
... | [
"def",
"get_relationships_for_idents",
"(",
"self",
",",
"cid",
",",
"idents",
")",
":",
"keys",
"=",
"[",
"(",
"cid",
",",
"ident",
",",
")",
"for",
"ident",
"in",
"idents",
"]",
"key_ranges",
"=",
"zip",
"(",
"keys",
",",
"keys",
")",
"mapping",
"=... | Get relationships between ``idents`` and a ``cid``.
Returns a dictionary mapping the identifiers in ``idents``
to either None, if no relationship label is found between
the identifier and ``cid``, or a RelationshipType classifying
the strength of the relationship between the identifier ... | [
"Get",
"relationships",
"between",
"idents",
"and",
"a",
"cid",
"."
] | d445e56b02ffd91ad46b0872cfbff62b9afef7ec | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L291-L309 |
245,618 | sassoo/goldman | goldman/queryparams/sort.py | _validate_field | def _validate_field(param, fields):
""" Ensure the sortable field exists on the model """
if param.field not in fields:
raise InvalidQueryParams(**{
'detail': 'The sort query param value of "%s" is '
'invalid. That field does not exist on the '
'r... | python | def _validate_field(param, fields):
""" Ensure the sortable field exists on the model """
if param.field not in fields:
raise InvalidQueryParams(**{
'detail': 'The sort query param value of "%s" is '
'invalid. That field does not exist on the '
'r... | [
"def",
"_validate_field",
"(",
"param",
",",
"fields",
")",
":",
"if",
"param",
".",
"field",
"not",
"in",
"fields",
":",
"raise",
"InvalidQueryParams",
"(",
"*",
"*",
"{",
"'detail'",
":",
"'The sort query param value of \"%s\" is '",
"'invalid. That field does not... | Ensure the sortable field exists on the model | [
"Ensure",
"the",
"sortable",
"field",
"exists",
"on",
"the",
"model"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L74-L84 |
245,619 | sassoo/goldman | goldman/queryparams/sort.py | _validate_no_rels | def _validate_no_rels(param, rels):
""" Ensure the sortable field is not on a relationship """
if param.field in rels:
raise InvalidQueryParams(**{
'detail': 'The sort query param value of "%s" is not '
'supported. Sorting on relationships is not '
... | python | def _validate_no_rels(param, rels):
""" Ensure the sortable field is not on a relationship """
if param.field in rels:
raise InvalidQueryParams(**{
'detail': 'The sort query param value of "%s" is not '
'supported. Sorting on relationships is not '
... | [
"def",
"_validate_no_rels",
"(",
"param",
",",
"rels",
")",
":",
"if",
"param",
".",
"field",
"in",
"rels",
":",
"raise",
"InvalidQueryParams",
"(",
"*",
"*",
"{",
"'detail'",
":",
"'The sort query param value of \"%s\" is not '",
"'supported. Sorting on relationships... | Ensure the sortable field is not on a relationship | [
"Ensure",
"the",
"sortable",
"field",
"is",
"not",
"on",
"a",
"relationship"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L87-L97 |
245,620 | sassoo/goldman | goldman/queryparams/sort.py | init | def init(req, model):
""" Determine the sorting preference by query parameter
Return an array of Sortable objects.
"""
rels = model.relationships
fields = model.all_fields
params = req.get_param_as_list('sort') or [goldman.config.SORT]
params = [Sortable(param.lower()) for param in params... | python | def init(req, model):
""" Determine the sorting preference by query parameter
Return an array of Sortable objects.
"""
rels = model.relationships
fields = model.all_fields
params = req.get_param_as_list('sort') or [goldman.config.SORT]
params = [Sortable(param.lower()) for param in params... | [
"def",
"init",
"(",
"req",
",",
"model",
")",
":",
"rels",
"=",
"model",
".",
"relationships",
"fields",
"=",
"model",
".",
"all_fields",
"params",
"=",
"req",
".",
"get_param_as_list",
"(",
"'sort'",
")",
"or",
"[",
"goldman",
".",
"config",
".",
"SOR... | Determine the sorting preference by query parameter
Return an array of Sortable objects. | [
"Determine",
"the",
"sorting",
"preference",
"by",
"query",
"parameter"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L100-L116 |
245,621 | xtream1101/web-wrapper | web_wrapper/driver_requests.py | DriverRequests._get_site | def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs):
"""
Try and return page content in the requested format using requests
"""
try:
# Headers and cookies are combined to the ones stored in the requests session
# Ones passed in here wi... | python | def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs):
"""
Try and return page content in the requested format using requests
"""
try:
# Headers and cookies are combined to the ones stored in the requests session
# Ones passed in here wi... | [
"def",
"_get_site",
"(",
"self",
",",
"url",
",",
"headers",
",",
"cookies",
",",
"timeout",
",",
"driver_args",
",",
"driver_kwargs",
")",
":",
"try",
":",
"# Headers and cookies are combined to the ones stored in the requests session",
"# Ones passed in here will overrid... | Try and return page content in the requested format using requests | [
"Try",
"and",
"return",
"page",
"content",
"in",
"the",
"requested",
"format",
"using",
"requests"
] | 2bfc63caa7d316564088951f01a490db493ea240 | https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_requests.py#L99-L125 |
245,622 | PyMLGame/pymlgame | pymlgame/controller.py | Controller._new_controller | def _new_controller(self, addr, port):
"""
Get an uid for your controller.
:param addr: Address of the controller
:param port: Port of the controller
:type addr: str
:type port: int
:return: Unique id of the controller
:rtype: str
"""
for ... | python | def _new_controller(self, addr, port):
"""
Get an uid for your controller.
:param addr: Address of the controller
:param port: Port of the controller
:type addr: str
:type port: int
:return: Unique id of the controller
:rtype: str
"""
for ... | [
"def",
"_new_controller",
"(",
"self",
",",
"addr",
",",
"port",
")",
":",
"for",
"uid",
",",
"controller",
"in",
"self",
".",
"controllers",
".",
"items",
"(",
")",
":",
"if",
"controller",
"[",
"0",
"]",
"==",
"addr",
":",
"# duplicate address. sending... | Get an uid for your controller.
:param addr: Address of the controller
:param port: Port of the controller
:type addr: str
:type port: int
:return: Unique id of the controller
:rtype: str | [
"Get",
"an",
"uid",
"for",
"your",
"controller",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L40-L70 |
245,623 | PyMLGame/pymlgame | pymlgame/controller.py | Controller._del_controller | def _del_controller(self, uid):
"""
Remove controller from internal list and tell the game.
:param uid: Unique id of the controller
:type uid: str
"""
try:
self.controllers.pop(uid)
e = Event(uid, E_DISCONNECT)
self.queue.put_nowait(e)... | python | def _del_controller(self, uid):
"""
Remove controller from internal list and tell the game.
:param uid: Unique id of the controller
:type uid: str
"""
try:
self.controllers.pop(uid)
e = Event(uid, E_DISCONNECT)
self.queue.put_nowait(e)... | [
"def",
"_del_controller",
"(",
"self",
",",
"uid",
")",
":",
"try",
":",
"self",
".",
"controllers",
".",
"pop",
"(",
"uid",
")",
"e",
"=",
"Event",
"(",
"uid",
",",
"E_DISCONNECT",
")",
"self",
".",
"queue",
".",
"put_nowait",
"(",
"e",
")",
"exce... | Remove controller from internal list and tell the game.
:param uid: Unique id of the controller
:type uid: str | [
"Remove",
"controller",
"from",
"internal",
"list",
"and",
"tell",
"the",
"game",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L72-L85 |
245,624 | PyMLGame/pymlgame | pymlgame/controller.py | Controller._ping | def _ping(self, uid, addr, port):
"""
Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted
after a while. This function is also used to update the address and port of the controller if it has changed.
:param uid: Unique id of the ... | python | def _ping(self, uid, addr, port):
"""
Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted
after a while. This function is also used to update the address and port of the controller if it has changed.
:param uid: Unique id of the ... | [
"def",
"_ping",
"(",
"self",
",",
"uid",
",",
"addr",
",",
"port",
")",
":",
"try",
":",
"self",
".",
"controllers",
"[",
"uid",
"]",
"[",
"0",
"]",
"=",
"addr",
"self",
".",
"controllers",
"[",
"uid",
"]",
"[",
"1",
"]",
"=",
"port",
"self",
... | Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted
after a while. This function is also used to update the address and port of the controller if it has changed.
:param uid: Unique id of the controller
:param addr: Address of the control... | [
"Just",
"say",
"hello",
"so",
"that",
"pymlgame",
"knows",
"that",
"your",
"controller",
"is",
"still",
"alive",
".",
"Unused",
"controllers",
"will",
"be",
"deleted",
"after",
"a",
"while",
".",
"This",
"function",
"is",
"also",
"used",
"to",
"update",
"t... | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L87-L108 |
245,625 | PyMLGame/pymlgame | pymlgame/controller.py | Controller._update_states | def _update_states(self, uid, states):
"""
Got states of all buttons from a controller. Now check if something changed and create events if neccesary.
:param uid: Unique id of the controller
:param states: Buttons states
:type uid: str
:type states: str
"""
... | python | def _update_states(self, uid, states):
"""
Got states of all buttons from a controller. Now check if something changed and create events if neccesary.
:param uid: Unique id of the controller
:param states: Buttons states
:type uid: str
:type states: str
"""
... | [
"def",
"_update_states",
"(",
"self",
",",
"uid",
",",
"states",
")",
":",
"#TODO: use try and catch all exceptions",
"# test if uid exists",
"if",
"self",
".",
"controllers",
"[",
"uid",
"]",
":",
"# test if states have correct lenght",
"if",
"len",
"(",
"states",
... | Got states of all buttons from a controller. Now check if something changed and create events if neccesary.
:param uid: Unique id of the controller
:param states: Buttons states
:type uid: str
:type states: str | [
"Got",
"states",
"of",
"all",
"buttons",
"from",
"a",
"controller",
".",
"Now",
"check",
"if",
"something",
"changed",
"and",
"create",
"events",
"if",
"neccesary",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L110-L134 |
245,626 | PyMLGame/pymlgame | pymlgame/controller.py | Controller._got_message | def _got_message(self, uid, text):
"""
The controller has send us a message.
:param uid: Unique id of the controller
:param text: Text to display
:type uid: str
:type text: str
"""
#TODO: use try
e = Event(uid, E_MESSAGE, text)
self.queue.... | python | def _got_message(self, uid, text):
"""
The controller has send us a message.
:param uid: Unique id of the controller
:param text: Text to display
:type uid: str
:type text: str
"""
#TODO: use try
e = Event(uid, E_MESSAGE, text)
self.queue.... | [
"def",
"_got_message",
"(",
"self",
",",
"uid",
",",
"text",
")",
":",
"#TODO: use try",
"e",
"=",
"Event",
"(",
"uid",
",",
"E_MESSAGE",
",",
"text",
")",
"self",
".",
"queue",
".",
"put_nowait",
"(",
"e",
")",
"self",
".",
"controllers",
"[",
"uid"... | The controller has send us a message.
:param uid: Unique id of the controller
:param text: Text to display
:type uid: str
:type text: str | [
"The",
"controller",
"has",
"send",
"us",
"a",
"message",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L136-L149 |
245,627 | PyMLGame/pymlgame | pymlgame/controller.py | Controller.send | def send(self, uid, event, payload=None):
"""
Send an event to a connected controller. Use pymlgame event type and correct payload.
To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload.
:param uid: Unique id of the controller
:param event: Eve... | python | def send(self, uid, event, payload=None):
"""
Send an event to a connected controller. Use pymlgame event type and correct payload.
To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload.
:param uid: Unique id of the controller
:param event: Eve... | [
"def",
"send",
"(",
"self",
",",
"uid",
",",
"event",
",",
"payload",
"=",
"None",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"if",
"uid",
"in",
"self",
".",
"controllers",
... | Send an event to a connected controller. Use pymlgame event type and correct payload.
To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload.
:param uid: Unique id of the controller
:param event: Event type
:param payload: Payload of the event
:... | [
"Send",
"an",
"event",
"to",
"a",
"connected",
"controller",
".",
"Use",
"pymlgame",
"event",
"type",
"and",
"correct",
"payload",
".",
"To",
"send",
"a",
"message",
"to",
"the",
"controller",
"use",
"pymlgame",
".",
"E_MESSAGE",
"event",
"and",
"a",
"stri... | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L151-L179 |
245,628 | PyMLGame/pymlgame | pymlgame/controller.py | Controller.run | def run(self):
"""
Listen for controllers.
"""
while True:
data, sender = self.sock.recvfrom(1024)
addr = sender[0]
msg = data.decode('utf-8')
if msg.startswith('/controller/'):
try:
uid = msg.split('/')[... | python | def run(self):
"""
Listen for controllers.
"""
while True:
data, sender = self.sock.recvfrom(1024)
addr = sender[0]
msg = data.decode('utf-8')
if msg.startswith('/controller/'):
try:
uid = msg.split('/')[... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"True",
":",
"data",
",",
"sender",
"=",
"self",
".",
"sock",
".",
"recvfrom",
"(",
"1024",
")",
"addr",
"=",
"sender",
"[",
"0",
"]",
"msg",
"=",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"... | Listen for controllers. | [
"Listen",
"for",
"controllers",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L181-L218 |
245,629 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | get_obj_frm_str | def get_obj_frm_str(obj_str, **kwargs):
"""
Returns a python object from a python object string
args:
obj_str: python object path expamle
"rdfframework.connections.ConnManager[{param1}]"
kwargs:
* kwargs used to format the 'obj_str'
"""
obj_str = obj_str.for... | python | def get_obj_frm_str(obj_str, **kwargs):
"""
Returns a python object from a python object string
args:
obj_str: python object path expamle
"rdfframework.connections.ConnManager[{param1}]"
kwargs:
* kwargs used to format the 'obj_str'
"""
obj_str = obj_str.for... | [
"def",
"get_obj_frm_str",
"(",
"obj_str",
",",
"*",
"*",
"kwargs",
")",
":",
"obj_str",
"=",
"obj_str",
".",
"format",
"(",
"*",
"*",
"kwargs",
")",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"params",
"=",
"[",
"]",
"# parse the call portion of t... | Returns a python object from a python object string
args:
obj_str: python object path expamle
"rdfframework.connections.ConnManager[{param1}]"
kwargs:
* kwargs used to format the 'obj_str' | [
"Returns",
"a",
"python",
"object",
"from",
"a",
"python",
"object",
"string"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L36-L83 |
245,630 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | pyfile_path | def pyfile_path(path):
""" converst a file path argment to the is path within the framework
args:
path: filepath to the python file
"""
if "/" in path:
parts = path.split("/")
join_term = "/"
elif "\\" in path:
parts =path.split("\\")
join_term = "\\"
par... | python | def pyfile_path(path):
""" converst a file path argment to the is path within the framework
args:
path: filepath to the python file
"""
if "/" in path:
parts = path.split("/")
join_term = "/"
elif "\\" in path:
parts =path.split("\\")
join_term = "\\"
par... | [
"def",
"pyfile_path",
"(",
"path",
")",
":",
"if",
"\"/\"",
"in",
"path",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"\"/\"",
")",
"join_term",
"=",
"\"/\"",
"elif",
"\"\\\\\"",
"in",
"path",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"\"\\\\\"... | converst a file path argment to the is path within the framework
args:
path: filepath to the python file | [
"converst",
"a",
"file",
"path",
"argment",
"to",
"the",
"is",
"path",
"within",
"the",
"framework"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L146-L161 |
245,631 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | nz | def nz(value, none_value, strict=True):
''' This function is named after an old VBA function. It returns a default
value if the passed in value is None. If strict is False it will
treat an empty string as None as well.
example:
x = None
nz(x,"hello")
--> "hello"
... | python | def nz(value, none_value, strict=True):
''' This function is named after an old VBA function. It returns a default
value if the passed in value is None. If strict is False it will
treat an empty string as None as well.
example:
x = None
nz(x,"hello")
--> "hello"
... | [
"def",
"nz",
"(",
"value",
",",
"none_value",
",",
"strict",
"=",
"True",
")",
":",
"if",
"not",
"DEBUG",
":",
"debug",
"=",
"False",
"else",
":",
"debug",
"=",
"False",
"if",
"debug",
":",
"print",
"(",
"\"START nz frameworkutilities.py --------------------... | This function is named after an old VBA function. It returns a default
value if the passed in value is None. If strict is False it will
treat an empty string as None as well.
example:
x = None
nz(x,"hello")
--> "hello"
nz(x,"")
--> ""
y = ""
... | [
"This",
"function",
"is",
"named",
"after",
"an",
"old",
"VBA",
"function",
".",
"It",
"returns",
"a",
"default",
"value",
"if",
"the",
"passed",
"in",
"value",
"is",
"None",
".",
"If",
"strict",
"is",
"False",
"it",
"will",
"treat",
"an",
"empty",
"st... | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L170-L202 |
245,632 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | make_set | def make_set(value):
''' Takes a value and turns it into a set
!!!! This is important because set(string) will parse a string to
individual characters vs. adding the string as an element of
the set i.e.
x = 'setvalue'
set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'}
make_set(x) = {'... | python | def make_set(value):
''' Takes a value and turns it into a set
!!!! This is important because set(string) will parse a string to
individual characters vs. adding the string as an element of
the set i.e.
x = 'setvalue'
set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'}
make_set(x) = {'... | [
"def",
"make_set",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"set",
"(",
"value",
")",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"set",
")",
":",
"value",
"=",
"set",
"(",
"[",
"value",
"... | Takes a value and turns it into a set
!!!! This is important because set(string) will parse a string to
individual characters vs. adding the string as an element of
the set i.e.
x = 'setvalue'
set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'}
make_set(x) = {'setvalue'}
or use set... | [
"Takes",
"a",
"value",
"and",
"turns",
"it",
"into",
"a",
"set"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L259-L274 |
245,633 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | make_triple | def make_triple(sub, pred, obj):
"""Takes a subject predicate and object and joins them with a space
in between
Args:
sub -- Subject
pred -- Predicate
obj -- Object
Returns
str
"""
return "{s} {p} {o} .".format(s=sub, p=pred, o=obj) | python | def make_triple(sub, pred, obj):
"""Takes a subject predicate and object and joins them with a space
in between
Args:
sub -- Subject
pred -- Predicate
obj -- Object
Returns
str
"""
return "{s} {p} {o} .".format(s=sub, p=pred, o=obj) | [
"def",
"make_triple",
"(",
"sub",
",",
"pred",
",",
"obj",
")",
":",
"return",
"\"{s} {p} {o} .\"",
".",
"format",
"(",
"s",
"=",
"sub",
",",
"p",
"=",
"pred",
",",
"o",
"=",
"obj",
")"
] | Takes a subject predicate and object and joins them with a space
in between
Args:
sub -- Subject
pred -- Predicate
obj -- Object
Returns
str | [
"Takes",
"a",
"subject",
"predicate",
"and",
"object",
"and",
"joins",
"them",
"with",
"a",
"space",
"in",
"between"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L277-L288 |
245,634 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | remove_null | def remove_null(obj):
''' reads through a list or set and strips any null values'''
if isinstance(obj, set):
try:
obj.remove(None)
except:
pass
elif isinstance(obj, list):
for item in obj:
if not is_not_null(item):
obj.remove(item)
... | python | def remove_null(obj):
''' reads through a list or set and strips any null values'''
if isinstance(obj, set):
try:
obj.remove(None)
except:
pass
elif isinstance(obj, list):
for item in obj:
if not is_not_null(item):
obj.remove(item)
... | [
"def",
"remove_null",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"set",
")",
":",
"try",
":",
"obj",
".",
"remove",
"(",
"None",
")",
"except",
":",
"pass",
"elif",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"for",
"item",
"... | reads through a list or set and strips any null values | [
"reads",
"through",
"a",
"list",
"or",
"set",
"and",
"strips",
"any",
"null",
"values"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L290-L301 |
245,635 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | delete_key_pattern | def delete_key_pattern(obj, regx_pattern):
''' takes a dictionary object and a regular expression pattern and removes
all keys that match the pattern.
args:
obj: dictionay object to search trhough
regx_pattern: string without beginning and ending / '''
if isinstance(obj, list):
... | python | def delete_key_pattern(obj, regx_pattern):
''' takes a dictionary object and a regular expression pattern and removes
all keys that match the pattern.
args:
obj: dictionay object to search trhough
regx_pattern: string without beginning and ending / '''
if isinstance(obj, list):
... | [
"def",
"delete_key_pattern",
"(",
"obj",
",",
"regx_pattern",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"_return_list",
"=",
"[",
"]",
"for",
"item",
"in",
"obj",
":",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"_r... | takes a dictionary object and a regular expression pattern and removes
all keys that match the pattern.
args:
obj: dictionay object to search trhough
regx_pattern: string without beginning and ending / | [
"takes",
"a",
"dictionary",
"object",
"and",
"a",
"regular",
"expression",
"pattern",
"and",
"removes",
"all",
"keys",
"that",
"match",
"the",
"pattern",
"."
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L423-L471 |
245,636 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | get_dict_key | def get_dict_key(data, key):
''' will serach a mulitdemensional dictionary for a key name and return a
value list of matching results '''
if isinstance(data, Mapping):
if key in data:
yield data[key]
for key_data in data.values():
for found in get_dict_key(key_da... | python | def get_dict_key(data, key):
''' will serach a mulitdemensional dictionary for a key name and return a
value list of matching results '''
if isinstance(data, Mapping):
if key in data:
yield data[key]
for key_data in data.values():
for found in get_dict_key(key_da... | [
"def",
"get_dict_key",
"(",
"data",
",",
"key",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Mapping",
")",
":",
"if",
"key",
"in",
"data",
":",
"yield",
"data",
"[",
"key",
"]",
"for",
"key_data",
"in",
"data",
".",
"values",
"(",
")",
":",
... | will serach a mulitdemensional dictionary for a key name and return a
value list of matching results | [
"will",
"serach",
"a",
"mulitdemensional",
"dictionary",
"for",
"a",
"key",
"name",
"and",
"return",
"a",
"value",
"list",
"of",
"matching",
"results"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L473-L482 |
245,637 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | get_attr | def get_attr(item, name, default=None):
''' similar to getattr and get but will test for class or dict '''
try:
val = item[name]
except (KeyError, TypeError):
try:
val = getattr(item, name)
except AttributeError:
val = default
return val | python | def get_attr(item, name, default=None):
''' similar to getattr and get but will test for class or dict '''
try:
val = item[name]
except (KeyError, TypeError):
try:
val = getattr(item, name)
except AttributeError:
val = default
return val | [
"def",
"get_attr",
"(",
"item",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"val",
"=",
"item",
"[",
"name",
"]",
"except",
"(",
"KeyError",
",",
"TypeError",
")",
":",
"try",
":",
"val",
"=",
"getattr",
"(",
"item",
",",
"nam... | similar to getattr and get but will test for class or dict | [
"similar",
"to",
"getattr",
"and",
"get",
"but",
"will",
"test",
"for",
"class",
"or",
"dict"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L484-L493 |
245,638 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | get2 | def get2(item, key, if_none=None, strict=True):
''' similar to dict.get functionality but None value will return then
if_none value
args:
item: dictionary to search
key: the dictionary key
if_none: the value to return if None is passed in
strict: if False an empty string... | python | def get2(item, key, if_none=None, strict=True):
''' similar to dict.get functionality but None value will return then
if_none value
args:
item: dictionary to search
key: the dictionary key
if_none: the value to return if None is passed in
strict: if False an empty string... | [
"def",
"get2",
"(",
"item",
",",
"key",
",",
"if_none",
"=",
"None",
",",
"strict",
"=",
"True",
")",
":",
"if",
"not",
"strict",
"and",
"item",
".",
"get",
"(",
"key",
")",
"==",
"\"\"",
":",
"return",
"if_none",
"elif",
"item",
".",
"get",
"(",... | similar to dict.get functionality but None value will return then
if_none value
args:
item: dictionary to search
key: the dictionary key
if_none: the value to return if None is passed in
strict: if False an empty string is treated as None | [
"similar",
"to",
"dict",
".",
"get",
"functionality",
"but",
"None",
"value",
"will",
"return",
"then",
"if_none",
"value"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L538-L553 |
245,639 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | initialized | def initialized(func):
""" decorator for testing if a class has been initialized
prior to calling any attribute """
def wrapper(self, *args, **kwargs):
""" internal wrapper function """
if not self.__is_initialized__:
return EmptyDot()
return func(self, *args, **kwar... | python | def initialized(func):
""" decorator for testing if a class has been initialized
prior to calling any attribute """
def wrapper(self, *args, **kwargs):
""" internal wrapper function """
if not self.__is_initialized__:
return EmptyDot()
return func(self, *args, **kwar... | [
"def",
"initialized",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\" internal wrapper function \"\"\"",
"if",
"not",
"self",
".",
"__is_initialized__",
":",
"return",
"EmptyDot",
"(",
")",
... | decorator for testing if a class has been initialized
prior to calling any attribute | [
"decorator",
"for",
"testing",
"if",
"a",
"class",
"has",
"been",
"initialized",
"prior",
"to",
"calling",
"any",
"attribute"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L750-L759 |
245,640 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | RegistryDictionary.find | def find(self, value):
"""
returns a dictionary of items based on the a lowercase search
args:
value: the value to search by
"""
value = str(value).lower()
rtn_dict = RegistryDictionary()
for key, item in self.items():
if value in key.lowe... | python | def find(self, value):
"""
returns a dictionary of items based on the a lowercase search
args:
value: the value to search by
"""
value = str(value).lower()
rtn_dict = RegistryDictionary()
for key, item in self.items():
if value in key.lowe... | [
"def",
"find",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
"rtn_dict",
"=",
"RegistryDictionary",
"(",
")",
"for",
"key",
",",
"item",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"valu... | returns a dictionary of items based on the a lowercase search
args:
value: the value to search by | [
"returns",
"a",
"dictionary",
"of",
"items",
"based",
"on",
"the",
"a",
"lowercase",
"search"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L89-L101 |
245,641 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | Dot.get | def get(self, prop):
""" get the value off the passed in dot notation
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c']
"""
prop_parts = prop.split(".")
val = None
for part in prop_parts:
if val i... | python | def get(self, prop):
""" get the value off the passed in dot notation
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c']
"""
prop_parts = prop.split(".")
val = None
for part in prop_parts:
if val i... | [
"def",
"get",
"(",
"self",
",",
"prop",
")",
":",
"prop_parts",
"=",
"prop",
".",
"split",
"(",
"\".\"",
")",
"val",
"=",
"None",
"for",
"part",
"in",
"prop_parts",
":",
"if",
"val",
"is",
"None",
":",
"val",
"=",
"self",
".",
"obj",
".",
"get",
... | get the value off the passed in dot notation
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c'] | [
"get",
"the",
"value",
"off",
"the",
"passed",
"in",
"dot",
"notation"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L365-L379 |
245,642 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | Dot.set | def set(self, prop, value):
""" sets the dot notated property to the passed in value
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c']
value: the value to set the prop object
"""
prop_parts = prop.split(".")
... | python | def set(self, prop, value):
""" sets the dot notated property to the passed in value
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c']
value: the value to set the prop object
"""
prop_parts = prop.split(".")
... | [
"def",
"set",
"(",
"self",
",",
"prop",
",",
"value",
")",
":",
"prop_parts",
"=",
"prop",
".",
"split",
"(",
"\".\"",
")",
"if",
"self",
".",
"copy_dict",
":",
"new_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"obj",
")",
"else",
":",
... | sets the dot notated property to the passed in value
args:
prop: a string of the property to retreive
"a.b.c" ~ dictionary['a']['b']['c']
value: the value to set the prop object | [
"sets",
"the",
"dot",
"notated",
"property",
"to",
"the",
"passed",
"in",
"value"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L381-L406 |
245,643 | KnowledgeLinks/rdfframework | rdfframework/utilities/baseutilities.py | DictClass.dict | def dict(self):
""" converts the class to a dictionary object """
return_obj = {}
for attr in dir(self):
if not attr.startswith('__') and attr not in self.__reserved:
if isinstance(getattr(self, attr), list):
return_val = []
for... | python | def dict(self):
""" converts the class to a dictionary object """
return_obj = {}
for attr in dir(self):
if not attr.startswith('__') and attr not in self.__reserved:
if isinstance(getattr(self, attr), list):
return_val = []
for... | [
"def",
"dict",
"(",
"self",
")",
":",
"return_obj",
"=",
"{",
"}",
"for",
"attr",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'__'",
")",
"and",
"attr",
"not",
"in",
"self",
".",
"__reserved",
":",
"if",
"isi... | converts the class to a dictionary object | [
"converts",
"the",
"class",
"to",
"a",
"dictionary",
"object"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L638-L662 |
245,644 | alexhayes/django-toolkit | django_toolkit/markup/html.py | get_anchor_href | def get_anchor_href(markup):
"""
Given HTML markup, return a list of hrefs for each anchor tag.
"""
soup = BeautifulSoup(markup, 'lxml')
return ['%s' % link.get('href') for link in soup.find_all('a')] | python | def get_anchor_href(markup):
"""
Given HTML markup, return a list of hrefs for each anchor tag.
"""
soup = BeautifulSoup(markup, 'lxml')
return ['%s' % link.get('href') for link in soup.find_all('a')] | [
"def",
"get_anchor_href",
"(",
"markup",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"markup",
",",
"'lxml'",
")",
"return",
"[",
"'%s'",
"%",
"link",
".",
"get",
"(",
"'href'",
")",
"for",
"link",
"in",
"soup",
".",
"find_all",
"(",
"'a'",
")",
"]"... | Given HTML markup, return a list of hrefs for each anchor tag. | [
"Given",
"HTML",
"markup",
"return",
"a",
"list",
"of",
"hrefs",
"for",
"each",
"anchor",
"tag",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/markup/html.py#L3-L8 |
245,645 | alexhayes/django-toolkit | django_toolkit/markup/html.py | get_anchor_contents | def get_anchor_contents(markup):
"""
Given HTML markup, return a list of href inner html for each anchor tag.
"""
soup = BeautifulSoup(markup, 'lxml')
return ['%s' % link.contents[0] for link in soup.find_all('a')] | python | def get_anchor_contents(markup):
"""
Given HTML markup, return a list of href inner html for each anchor tag.
"""
soup = BeautifulSoup(markup, 'lxml')
return ['%s' % link.contents[0] for link in soup.find_all('a')] | [
"def",
"get_anchor_contents",
"(",
"markup",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"markup",
",",
"'lxml'",
")",
"return",
"[",
"'%s'",
"%",
"link",
".",
"contents",
"[",
"0",
"]",
"for",
"link",
"in",
"soup",
".",
"find_all",
"(",
"'a'",
")",
... | Given HTML markup, return a list of href inner html for each anchor tag. | [
"Given",
"HTML",
"markup",
"return",
"a",
"list",
"of",
"href",
"inner",
"html",
"for",
"each",
"anchor",
"tag",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/markup/html.py#L10-L15 |
245,646 | abe-winter/pg13-py | pg13/weval.py | names_from_exp | def names_from_exp(exp):
"Return a list of AttrX and NameX from the expression."
def match(exp):
return isinstance(exp, (sqparse2.NameX, sqparse2.AttrX))
paths = treepath.sub_slots(exp, match, match=True, recurse_into_matches=False)
return [exp[path] for path in paths] | python | def names_from_exp(exp):
"Return a list of AttrX and NameX from the expression."
def match(exp):
return isinstance(exp, (sqparse2.NameX, sqparse2.AttrX))
paths = treepath.sub_slots(exp, match, match=True, recurse_into_matches=False)
return [exp[path] for path in paths] | [
"def",
"names_from_exp",
"(",
"exp",
")",
":",
"def",
"match",
"(",
"exp",
")",
":",
"return",
"isinstance",
"(",
"exp",
",",
"(",
"sqparse2",
".",
"NameX",
",",
"sqparse2",
".",
"AttrX",
")",
")",
"paths",
"=",
"treepath",
".",
"sub_slots",
"(",
"ex... | Return a list of AttrX and NameX from the expression. | [
"Return",
"a",
"list",
"of",
"AttrX",
"and",
"NameX",
"from",
"the",
"expression",
"."
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/weval.py#L31-L36 |
245,647 | lizardsystem/tags2sdists | tags2sdists/packagedir.py | PackageDir.add_tarball | def add_tarball(self, tarball, package):
"""Add a tarball, possibly creating the directory if needed."""
if tarball is None:
logger.error(
"No tarball found for %s: probably a renamed project?",
package)
return
target_dir = os.path.join(sel... | python | def add_tarball(self, tarball, package):
"""Add a tarball, possibly creating the directory if needed."""
if tarball is None:
logger.error(
"No tarball found for %s: probably a renamed project?",
package)
return
target_dir = os.path.join(sel... | [
"def",
"add_tarball",
"(",
"self",
",",
"tarball",
",",
"package",
")",
":",
"if",
"tarball",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"No tarball found for %s: probably a renamed project?\"",
",",
"package",
")",
"return",
"target_dir",
"=",
"os",
".",... | Add a tarball, possibly creating the directory if needed. | [
"Add",
"a",
"tarball",
"possibly",
"creating",
"the",
"directory",
"if",
"needed",
"."
] | 72f3c664940133e3238fca4d87edcc36b9775e48 | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/packagedir.py#L37-L49 |
245,648 | oubiwann/carapace | carapace/app/shell/pythonshell.py | CommandAPI.ls | def ls(self):
"""
List the objects in the current namespace, in alphabetical order.
"""
width = max([len(x) for x in self.namespace.keys()])
for key, value in sorted(self.namespace.items()):
if key == "_":
continue
info = ""
if ... | python | def ls(self):
"""
List the objects in the current namespace, in alphabetical order.
"""
width = max([len(x) for x in self.namespace.keys()])
for key, value in sorted(self.namespace.items()):
if key == "_":
continue
info = ""
if ... | [
"def",
"ls",
"(",
"self",
")",
":",
"width",
"=",
"max",
"(",
"[",
"len",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"namespace",
".",
"keys",
"(",
")",
"]",
")",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"self",
".",
"namespace",
"... | List the objects in the current namespace, in alphabetical order. | [
"List",
"the",
"objects",
"in",
"the",
"current",
"namespace",
"in",
"alphabetical",
"order",
"."
] | 88470b12c198bea5067dcff1a26aa4400b73632c | https://github.com/oubiwann/carapace/blob/88470b12c198bea5067dcff1a26aa4400b73632c/carapace/app/shell/pythonshell.py#L51-L72 |
245,649 | cogniteev/docido-python-sdk | docido_sdk/toolbox/text.py | to_unicode | def to_unicode(text, charset=None):
"""Convert input to an `unicode` object.
For a `str` object, we'll first try to decode the bytes using the given
`charset` encoding (or UTF-8 if none is specified), then we fall back to
the latin1 encoding which might be correct or not, but at least preserves
the... | python | def to_unicode(text, charset=None):
"""Convert input to an `unicode` object.
For a `str` object, we'll first try to decode the bytes using the given
`charset` encoding (or UTF-8 if none is specified), then we fall back to
the latin1 encoding which might be correct or not, but at least preserves
the... | [
"def",
"to_unicode",
"(",
"text",
",",
"charset",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"try",
":",
"return",
"unicode",
"(",
"text",
",",
"charset",
"or",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"re... | Convert input to an `unicode` object.
For a `str` object, we'll first try to decode the bytes using the given
`charset` encoding (or UTF-8 if none is specified), then we fall back to
the latin1 encoding which might be correct or not, but at least preserves
the original byte sequence by mapping each byt... | [
"Convert",
"input",
"to",
"an",
"unicode",
"object",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L4-L37 |
245,650 | cogniteev/docido-python-sdk | docido_sdk/toolbox/text.py | exception_to_unicode | def exception_to_unicode(e, traceback=False):
"""Convert an `Exception` to an `unicode` object.
In addition to `to_unicode`, this representation of the exception
also contains the class name and optionally the traceback.
"""
message = '%s: %s' % (e.__class__.__name__, to_unicode(e))
if tracebac... | python | def exception_to_unicode(e, traceback=False):
"""Convert an `Exception` to an `unicode` object.
In addition to `to_unicode`, this representation of the exception
also contains the class name and optionally the traceback.
"""
message = '%s: %s' % (e.__class__.__name__, to_unicode(e))
if tracebac... | [
"def",
"exception_to_unicode",
"(",
"e",
",",
"traceback",
"=",
"False",
")",
":",
"message",
"=",
"'%s: %s'",
"%",
"(",
"e",
".",
"__class__",
".",
"__name__",
",",
"to_unicode",
"(",
"e",
")",
")",
"if",
"traceback",
":",
"from",
"docido_sdk",
".",
"... | Convert an `Exception` to an `unicode` object.
In addition to `to_unicode`, this representation of the exception
also contains the class name and optionally the traceback. | [
"Convert",
"an",
"Exception",
"to",
"an",
"unicode",
"object",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L40-L51 |
245,651 | cogniteev/docido-python-sdk | docido_sdk/toolbox/text.py | levenshtein | def levenshtein(s, t):
""" Compute the Levenshtein distance between 2 strings, which
is the minimum number of operations required to perform on a string to
get another one.
code taken from https://en.wikibooks.org
:param basestring s:
:param basestring t:
:rtype: int
"""
''' From W... | python | def levenshtein(s, t):
""" Compute the Levenshtein distance between 2 strings, which
is the minimum number of operations required to perform on a string to
get another one.
code taken from https://en.wikibooks.org
:param basestring s:
:param basestring t:
:rtype: int
"""
''' From W... | [
"def",
"levenshtein",
"(",
"s",
",",
"t",
")",
":",
"''' From Wikipedia article; Iterative with two matrix rows. '''",
"if",
"s",
"==",
"t",
":",
"return",
"0",
"elif",
"len",
"(",
"s",
")",
"==",
"0",
":",
"return",
"len",
"(",
"t",
")",
"elif",
"len",
... | Compute the Levenshtein distance between 2 strings, which
is the minimum number of operations required to perform on a string to
get another one.
code taken from https://en.wikibooks.org
:param basestring s:
:param basestring t:
:rtype: int | [
"Compute",
"the",
"Levenshtein",
"distance",
"between",
"2",
"strings",
"which",
"is",
"the",
"minimum",
"number",
"of",
"operations",
"required",
"to",
"perform",
"on",
"a",
"string",
"to",
"get",
"another",
"one",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L54-L84 |
245,652 | etscrivner/nose-perfdump | perfdump/console.py | Console.do_help | def do_help(self, line):
"""Displays help information."""
print ""
print "Perfdump CLI provides a handful of simple ways to query your"
print "performance data."
print ""
print "The simplest queries are of the form:"
print ""
print "\t[slowest|fastest] [te... | python | def do_help(self, line):
"""Displays help information."""
print ""
print "Perfdump CLI provides a handful of simple ways to query your"
print "performance data."
print ""
print "The simplest queries are of the form:"
print ""
print "\t[slowest|fastest] [te... | [
"def",
"do_help",
"(",
"self",
",",
"line",
")",
":",
"print",
"\"\"",
"print",
"\"Perfdump CLI provides a handful of simple ways to query your\"",
"print",
"\"performance data.\"",
"print",
"\"\"",
"print",
"\"The simplest queries are of the form:\"",
"print",
"\"\"",
"print... | Displays help information. | [
"Displays",
"help",
"information",
"."
] | a203a68495d30346fab43fb903cb60cd29b17d49 | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/console.py#L139-L162 |
245,653 | Phasemix/phasetumblr | phasetumblr/phasetumblr.py | TumblrBlog.get_allposts | def get_allposts(self):
''' Return all posts in blog sorted by date
'''
result = self.client.posts(self.blog, offset = 0, limit = 1)
try:
total_posts = result['total_posts']
except:
raise phasetumblr_errors.TumblrBlogException(result['meta']['msg'])
delta = (total_posts / 10) + 1
all_posts = []
... | python | def get_allposts(self):
''' Return all posts in blog sorted by date
'''
result = self.client.posts(self.blog, offset = 0, limit = 1)
try:
total_posts = result['total_posts']
except:
raise phasetumblr_errors.TumblrBlogException(result['meta']['msg'])
delta = (total_posts / 10) + 1
all_posts = []
... | [
"def",
"get_allposts",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"client",
".",
"posts",
"(",
"self",
".",
"blog",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"1",
")",
"try",
":",
"total_posts",
"=",
"result",
"[",
"'total_posts'",
"]",
"... | Return all posts in blog sorted by date | [
"Return",
"all",
"posts",
"in",
"blog",
"sorted",
"by",
"date"
] | 1b699ac3fc6a903fc0a9bfdc9d1f76cb57f679f1 | https://github.com/Phasemix/phasetumblr/blob/1b699ac3fc6a903fc0a9bfdc9d1f76cb57f679f1/phasetumblr/phasetumblr.py#L24-L60 |
245,654 | eddiejessup/metropack | metropack/pack.py | n_to_pf | def n_to_pf(L, n, R):
"""Returns the packing fraction for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
System lengths.
n: integer
Number of spheres.
R: float
Sphere radius.
Returns
-------
pf: float
Fraction ... | python | def n_to_pf(L, n, R):
"""Returns the packing fraction for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
System lengths.
n: integer
Number of spheres.
R: float
Sphere radius.
Returns
-------
pf: float
Fraction ... | [
"def",
"n_to_pf",
"(",
"L",
",",
"n",
",",
"R",
")",
":",
"dim",
"=",
"L",
".",
"shape",
"[",
"0",
"]",
"return",
"(",
"n",
"*",
"sphere_volume",
"(",
"R",
"=",
"R",
",",
"n",
"=",
"dim",
")",
")",
"/",
"np",
".",
"product",
"(",
"L",
")"... | Returns the packing fraction for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
System lengths.
n: integer
Number of spheres.
R: float
Sphere radius.
Returns
-------
pf: float
Fraction of space occupied by the sphe... | [
"Returns",
"the",
"packing",
"fraction",
"for",
"a",
"number",
"of",
"non",
"-",
"intersecting",
"spheres",
"."
] | 528b47d0f2f70f39e1490e41433f2da8c8b9d63c | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L14-L32 |
245,655 | eddiejessup/metropack | metropack/pack.py | pf_to_n | def pf_to_n(L, pf, R):
"""Returns the number of non-intersecting spheres required to achieve
as close to a given packing fraction as possible, along with the actual
achieved packing fraction. for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
Syst... | python | def pf_to_n(L, pf, R):
"""Returns the number of non-intersecting spheres required to achieve
as close to a given packing fraction as possible, along with the actual
achieved packing fraction. for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
Syst... | [
"def",
"pf_to_n",
"(",
"L",
",",
"pf",
",",
"R",
")",
":",
"dim",
"=",
"L",
".",
"shape",
"[",
"0",
"]",
"n",
"=",
"int",
"(",
"round",
"(",
"pf",
"*",
"np",
".",
"product",
"(",
"L",
")",
"/",
"sphere_volume",
"(",
"R",
",",
"dim",
")",
... | Returns the number of non-intersecting spheres required to achieve
as close to a given packing fraction as possible, along with the actual
achieved packing fraction. for a number of non-intersecting spheres.
Parameters
----------
L: float array, shape (d,)
System lengths.
pf: float
... | [
"Returns",
"the",
"number",
"of",
"non",
"-",
"intersecting",
"spheres",
"required",
"to",
"achieve",
"as",
"close",
"to",
"a",
"given",
"packing",
"fraction",
"as",
"possible",
"along",
"with",
"the",
"actual",
"achieved",
"packing",
"fraction",
".",
"for",
... | 528b47d0f2f70f39e1490e41433f2da8c8b9d63c | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L35-L60 |
245,656 | eddiejessup/metropack | metropack/pack.py | pack_simple | def pack_simple(R, L, pf=None, n=None, rng=None, periodic=False):
"""Pack a number of non-intersecting spheres into a system.
Can specify packing by number of spheres or packing fraction.
This implementation uses a naive uniform distribution of spheres,
and the Tabula Rasa rule (start from scratch if ... | python | def pack_simple(R, L, pf=None, n=None, rng=None, periodic=False):
"""Pack a number of non-intersecting spheres into a system.
Can specify packing by number of spheres or packing fraction.
This implementation uses a naive uniform distribution of spheres,
and the Tabula Rasa rule (start from scratch if ... | [
"def",
"pack_simple",
"(",
"R",
",",
"L",
",",
"pf",
"=",
"None",
",",
"n",
"=",
"None",
",",
"rng",
"=",
"None",
",",
"periodic",
"=",
"False",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"np",
".",
"random",
"if",
"pf",
"is",
"not... | Pack a number of non-intersecting spheres into a system.
Can specify packing by number of spheres or packing fraction.
This implementation uses a naive uniform distribution of spheres,
and the Tabula Rasa rule (start from scratch if an intersection occurs).
This is likely to be very slow for high pac... | [
"Pack",
"a",
"number",
"of",
"non",
"-",
"intersecting",
"spheres",
"into",
"a",
"system",
"."
] | 528b47d0f2f70f39e1490e41433f2da8c8b9d63c | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L85-L134 |
245,657 | eddiejessup/metropack | metropack/pack.py | pack | def pack(R, L, pf=None, n=None, rng=None, periodic=False,
beta_max=1e4, dL_max=0.02, dr_max=0.02):
"""Pack a number of non-intersecting spheres into a periodic system.
Can specify packing by number of spheres or packing fraction.
This implementation uses the Metropolis-Hastings algorithm for an
... | python | def pack(R, L, pf=None, n=None, rng=None, periodic=False,
beta_max=1e4, dL_max=0.02, dr_max=0.02):
"""Pack a number of non-intersecting spheres into a periodic system.
Can specify packing by number of spheres or packing fraction.
This implementation uses the Metropolis-Hastings algorithm for an
... | [
"def",
"pack",
"(",
"R",
",",
"L",
",",
"pf",
"=",
"None",
",",
"n",
"=",
"None",
",",
"rng",
"=",
"None",
",",
"periodic",
"=",
"False",
",",
"beta_max",
"=",
"1e4",
",",
"dL_max",
"=",
"0.02",
",",
"dr_max",
"=",
"0.02",
")",
":",
"if",
"pf... | Pack a number of non-intersecting spheres into a periodic system.
Can specify packing by number of spheres or packing fraction.
This implementation uses the Metropolis-Hastings algorithm for an
NPT system.
Parameters
----------
R: float
Sphere radius.
L: float array, shape (d,)
... | [
"Pack",
"a",
"number",
"of",
"non",
"-",
"intersecting",
"spheres",
"into",
"a",
"periodic",
"system",
"."
] | 528b47d0f2f70f39e1490e41433f2da8c8b9d63c | https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L137-L218 |
245,658 | delfick/gitmit | gitmit/mit.py | GitTimes.relpath_for | def relpath_for(self, path):
"""Find the relative path from here from the parent_dir"""
if self.parent_dir in (".", ""):
return path
if path == self.parent_dir:
return ""
dirname = os.path.dirname(path) or "."
basename = os.path.basename(path)
c... | python | def relpath_for(self, path):
"""Find the relative path from here from the parent_dir"""
if self.parent_dir in (".", ""):
return path
if path == self.parent_dir:
return ""
dirname = os.path.dirname(path) or "."
basename = os.path.basename(path)
c... | [
"def",
"relpath_for",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"parent_dir",
"in",
"(",
"\".\"",
",",
"\"\"",
")",
":",
"return",
"path",
"if",
"path",
"==",
"self",
".",
"parent_dir",
":",
"return",
"\"\"",
"dirname",
"=",
"os",
".",
... | Find the relative path from here from the parent_dir | [
"Find",
"the",
"relative",
"path",
"from",
"here",
"from",
"the",
"parent_dir"
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L57-L72 |
245,659 | delfick/gitmit | gitmit/mit.py | GitTimes.find | def find(self):
"""
Find all the files we want to find commit times for, and any extra files
under symlinks.
Then find the commit times for those files and return a dictionary of
{relative_path: commit_time_as_epoch}
"""
mtimes = {}
git = Repo(self.root_... | python | def find(self):
"""
Find all the files we want to find commit times for, and any extra files
under symlinks.
Then find the commit times for those files and return a dictionary of
{relative_path: commit_time_as_epoch}
"""
mtimes = {}
git = Repo(self.root_... | [
"def",
"find",
"(",
"self",
")",
":",
"mtimes",
"=",
"{",
"}",
"git",
"=",
"Repo",
"(",
"self",
".",
"root_folder",
")",
"all_files",
"=",
"git",
".",
"all_files",
"(",
")",
"use_files",
"=",
"set",
"(",
"self",
".",
"find_files_for_use",
"(",
"all_f... | Find all the files we want to find commit times for, and any extra files
under symlinks.
Then find the commit times for those files and return a dictionary of
{relative_path: commit_time_as_epoch} | [
"Find",
"all",
"the",
"files",
"we",
"want",
"to",
"find",
"commit",
"times",
"for",
"and",
"any",
"extra",
"files",
"under",
"symlinks",
"."
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L74-L101 |
245,660 | delfick/gitmit | gitmit/mit.py | GitTimes.commit_times_for | def commit_times_for(self, git, use_files):
"""
Return commit times for the use_files specified.
We will use a cache of commit times if self.with_cache is Truthy.
Finally, we yield (relpath: epoch) pairs where path is relative
to self.parent_dir and epoch is the commit time in ... | python | def commit_times_for(self, git, use_files):
"""
Return commit times for the use_files specified.
We will use a cache of commit times if self.with_cache is Truthy.
Finally, we yield (relpath: epoch) pairs where path is relative
to self.parent_dir and epoch is the commit time in ... | [
"def",
"commit_times_for",
"(",
"self",
",",
"git",
",",
"use_files",
")",
":",
"# Use real_relpath if it exists (SymlinkdPath) and default to just the path",
"# This is because we _want_ to compare the commits to the _real paths_",
"# As git only cares about the symlink itself, rather than ... | Return commit times for the use_files specified.
We will use a cache of commit times if self.with_cache is Truthy.
Finally, we yield (relpath: epoch) pairs where path is relative
to self.parent_dir and epoch is the commit time in UTC for that path. | [
"Return",
"commit",
"times",
"for",
"the",
"use_files",
"specified",
"."
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L103-L150 |
245,661 | delfick/gitmit | gitmit/mit.py | GitTimes.extra_symlinked_files | def extra_symlinked_files(self, potential_symlinks):
"""
Find any symlinkd folders and yield SymlinkdPath objects for each file
that is found under the symlink.
"""
for key in list(potential_symlinks):
location = os.path.join(self.root_folder, key.path)
re... | python | def extra_symlinked_files(self, potential_symlinks):
"""
Find any symlinkd folders and yield SymlinkdPath objects for each file
that is found under the symlink.
"""
for key in list(potential_symlinks):
location = os.path.join(self.root_folder, key.path)
re... | [
"def",
"extra_symlinked_files",
"(",
"self",
",",
"potential_symlinks",
")",
":",
"for",
"key",
"in",
"list",
"(",
"potential_symlinks",
")",
":",
"location",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"root_folder",
",",
"key",
".",
"path",
... | Find any symlinkd folders and yield SymlinkdPath objects for each file
that is found under the symlink. | [
"Find",
"any",
"symlinkd",
"folders",
"and",
"yield",
"SymlinkdPath",
"objects",
"for",
"each",
"file",
"that",
"is",
"found",
"under",
"the",
"symlink",
"."
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L152-L181 |
245,662 | delfick/gitmit | gitmit/mit.py | GitTimes.find_files_for_use | def find_files_for_use(self, all_files):
"""
Given a list of all the files to consider, only yield Path objects
for those we care about, given our filters
"""
for path in all_files:
# Find the path relative to the parent dir
relpath = self.relpath_for(path... | python | def find_files_for_use(self, all_files):
"""
Given a list of all the files to consider, only yield Path objects
for those we care about, given our filters
"""
for path in all_files:
# Find the path relative to the parent dir
relpath = self.relpath_for(path... | [
"def",
"find_files_for_use",
"(",
"self",
",",
"all_files",
")",
":",
"for",
"path",
"in",
"all_files",
":",
"# Find the path relative to the parent dir",
"relpath",
"=",
"self",
".",
"relpath_for",
"(",
"path",
")",
"# Don't care about the ./",
"if",
"relpath",
"."... | Given a list of all the files to consider, only yield Path objects
for those we care about, given our filters | [
"Given",
"a",
"list",
"of",
"all",
"the",
"files",
"to",
"consider",
"only",
"yield",
"Path",
"objects",
"for",
"those",
"we",
"care",
"about",
"given",
"our",
"filters"
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L183-L198 |
245,663 | delfick/gitmit | gitmit/mit.py | GitTimes.is_filtered | def is_filtered(self, relpath):
"""Say whether this relpath is filtered out"""
# Only include files under the parent_dir
if relpath.startswith("../"):
return True
# Ignore files that we don't want timestamps from
if self.timestamps_for is not None and type(self.times... | python | def is_filtered(self, relpath):
"""Say whether this relpath is filtered out"""
# Only include files under the parent_dir
if relpath.startswith("../"):
return True
# Ignore files that we don't want timestamps from
if self.timestamps_for is not None and type(self.times... | [
"def",
"is_filtered",
"(",
"self",
",",
"relpath",
")",
":",
"# Only include files under the parent_dir",
"if",
"relpath",
".",
"startswith",
"(",
"\"../\"",
")",
":",
"return",
"True",
"# Ignore files that we don't want timestamps from",
"if",
"self",
".",
"timestamps_... | Say whether this relpath is filtered out | [
"Say",
"whether",
"this",
"relpath",
"is",
"filtered",
"out"
] | ae0aef14a06b25ad2811f8f47cc97e68a0910eae | https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L200-L234 |
245,664 | bertrandvidal/parse_this | parse_this/core.py | _get_args_and_defaults | def _get_args_and_defaults(args, defaults):
"""Return a list of 2-tuples - the argument name and its default value or
a special value that indicates there is no default value.
Args:
args: list of argument name
defaults: tuple of default values
"""
defaults = defaults or []
a... | python | def _get_args_and_defaults(args, defaults):
"""Return a list of 2-tuples - the argument name and its default value or
a special value that indicates there is no default value.
Args:
args: list of argument name
defaults: tuple of default values
"""
defaults = defaults or []
a... | [
"def",
"_get_args_and_defaults",
"(",
"args",
",",
"defaults",
")",
":",
"defaults",
"=",
"defaults",
"or",
"[",
"]",
"args_and_defaults",
"=",
"[",
"(",
"argument",
",",
"default",
")",
"for",
"(",
"argument",
",",
"default",
")",
"in",
"zip_longest",
"("... | Return a list of 2-tuples - the argument name and its default value or
a special value that indicates there is no default value.
Args:
args: list of argument name
defaults: tuple of default values | [
"Return",
"a",
"list",
"of",
"2",
"-",
"tuples",
"-",
"the",
"argument",
"name",
"and",
"its",
"default",
"value",
"or",
"a",
"special",
"value",
"that",
"indicates",
"there",
"is",
"no",
"default",
"value",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L51-L63 |
245,665 | bertrandvidal/parse_this | parse_this/core.py | _prepare_doc | def _prepare_doc(func, args, delimiter_chars):
"""From the function docstring get the arg parse description and arguments
help message. If there is no docstring simple description and help
message are created.
Args:
func: the function that needs argument parsing
args: name of th... | python | def _prepare_doc(func, args, delimiter_chars):
"""From the function docstring get the arg parse description and arguments
help message. If there is no docstring simple description and help
message are created.
Args:
func: the function that needs argument parsing
args: name of th... | [
"def",
"_prepare_doc",
"(",
"func",
",",
"args",
",",
"delimiter_chars",
")",
":",
"_LOG",
".",
"debug",
"(",
"\"Preparing doc for '%s'\"",
",",
"func",
".",
"__name__",
")",
"if",
"not",
"func",
".",
"__doc__",
":",
"return",
"_get_default_help_message",
"(",... | From the function docstring get the arg parse description and arguments
help message. If there is no docstring simple description and help
message are created.
Args:
func: the function that needs argument parsing
args: name of the function arguments
delimiter_chars: characte... | [
"From",
"the",
"function",
"docstring",
"get",
"the",
"arg",
"parse",
"description",
"and",
"arguments",
"help",
"message",
".",
"If",
"there",
"is",
"no",
"docstring",
"simple",
"description",
"and",
"help",
"message",
"are",
"created",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L66-L115 |
245,666 | bertrandvidal/parse_this | parse_this/core.py | _get_default_help_message | def _get_default_help_message(func, args, description=None, args_help=None):
"""Create a default description for the parser and help message for the
agurments if they are missing.
Args:
func: the method we are creating a parser for
args: the argument names of the method
description:... | python | def _get_default_help_message(func, args, description=None, args_help=None):
"""Create a default description for the parser and help message for the
agurments if they are missing.
Args:
func: the method we are creating a parser for
args: the argument names of the method
description:... | [
"def",
"_get_default_help_message",
"(",
"func",
",",
"args",
",",
"description",
"=",
"None",
",",
"args_help",
"=",
"None",
")",
":",
"if",
"description",
"is",
"None",
":",
"description",
"=",
"\"Argument parsing for %s\"",
"%",
"func",
".",
"__name__",
"ar... | Create a default description for the parser and help message for the
agurments if they are missing.
Args:
func: the method we are creating a parser for
args: the argument names of the method
description: a potentially existing description created from the
function docstring
... | [
"Create",
"a",
"default",
"description",
"for",
"the",
"parser",
"and",
"help",
"message",
"for",
"the",
"agurments",
"if",
"they",
"are",
"missing",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L151-L172 |
245,667 | bertrandvidal/parse_this | parse_this/core.py | _get_arg_parser | def _get_arg_parser(func, types, args_and_defaults, delimiter_chars):
"""Return an ArgumentParser for the given function. Arguments are defined
from the function arguments and their associated defaults.
Args:
func: function for which we want an ArgumentParser
types: types to which the c... | python | def _get_arg_parser(func, types, args_and_defaults, delimiter_chars):
"""Return an ArgumentParser for the given function. Arguments are defined
from the function arguments and their associated defaults.
Args:
func: function for which we want an ArgumentParser
types: types to which the c... | [
"def",
"_get_arg_parser",
"(",
"func",
",",
"types",
",",
"args_and_defaults",
",",
"delimiter_chars",
")",
":",
"_LOG",
".",
"debug",
"(",
"\"Creating ArgumentParser for '%s'\"",
",",
"func",
".",
"__name__",
")",
"(",
"description",
",",
"arg_help",
")",
"=",
... | Return an ArgumentParser for the given function. Arguments are defined
from the function arguments and their associated defaults.
Args:
func: function for which we want an ArgumentParser
types: types to which the command line arguments should be converted to
args_and_defaults: list ... | [
"Return",
"an",
"ArgumentParser",
"for",
"the",
"given",
"function",
".",
"Arguments",
"are",
"defined",
"from",
"the",
"function",
"arguments",
"and",
"their",
"associated",
"defaults",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L175-L221 |
245,668 | bertrandvidal/parse_this | parse_this/core.py | _get_args_to_parse | def _get_args_to_parse(args, sys_argv):
"""Return the given arguments if it is not None else sys.argv if it contains
something, an empty list otherwise.
Args:
args: argument to be parsed
sys_argv: arguments of the command line i.e. sys.argv
"""
arguments = args if args is not No... | python | def _get_args_to_parse(args, sys_argv):
"""Return the given arguments if it is not None else sys.argv if it contains
something, an empty list otherwise.
Args:
args: argument to be parsed
sys_argv: arguments of the command line i.e. sys.argv
"""
arguments = args if args is not No... | [
"def",
"_get_args_to_parse",
"(",
"args",
",",
"sys_argv",
")",
":",
"arguments",
"=",
"args",
"if",
"args",
"is",
"not",
"None",
"else",
"sys_argv",
"[",
"1",
":",
"]",
"_LOG",
".",
"debug",
"(",
"\"Parsing arguments: %s\"",
",",
"arguments",
")",
"return... | Return the given arguments if it is not None else sys.argv if it contains
something, an empty list otherwise.
Args:
args: argument to be parsed
sys_argv: arguments of the command line i.e. sys.argv | [
"Return",
"the",
"given",
"arguments",
"if",
"it",
"is",
"not",
"None",
"else",
"sys",
".",
"argv",
"if",
"it",
"contains",
"something",
"an",
"empty",
"list",
"otherwise",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L224-L234 |
245,669 | bertrandvidal/parse_this | parse_this/core.py | _get_parser_call_method | def _get_parser_call_method(func):
"""Returns the method that is linked to the 'call' method of the parser
Args:
func: the decorated function
Raises:
ParseThisError if the decorated method is __init__, __init__ can
only be decorated in a class decorated by parse_class
"""
f... | python | def _get_parser_call_method(func):
"""Returns the method that is linked to the 'call' method of the parser
Args:
func: the decorated function
Raises:
ParseThisError if the decorated method is __init__, __init__ can
only be decorated in a class decorated by parse_class
"""
f... | [
"def",
"_get_parser_call_method",
"(",
"func",
")",
":",
"func_name",
"=",
"func",
".",
"__name__",
"parser",
"=",
"func",
".",
"parser",
"def",
"inner_call",
"(",
"instance",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"\"\"\"This is method attached to <... | Returns the method that is linked to the 'call' method of the parser
Args:
func: the decorated function
Raises:
ParseThisError if the decorated method is __init__, __init__ can
only be decorated in a class decorated by parse_class | [
"Returns",
"the",
"method",
"that",
"is",
"linked",
"to",
"the",
"call",
"method",
"of",
"the",
"parser"
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L264-L299 |
245,670 | bertrandvidal/parse_this | parse_this/core.py | _get_args_name_from_parser | def _get_args_name_from_parser(parser):
"""Retrieve the name of the function argument linked to the given parser.
Args:
parser: a function parser
"""
# Retrieve the 'action' destination of the method parser i.e. its
# argument name. The HelpAction is ignored.
return [action.dest for act... | python | def _get_args_name_from_parser(parser):
"""Retrieve the name of the function argument linked to the given parser.
Args:
parser: a function parser
"""
# Retrieve the 'action' destination of the method parser i.e. its
# argument name. The HelpAction is ignored.
return [action.dest for act... | [
"def",
"_get_args_name_from_parser",
"(",
"parser",
")",
":",
"# Retrieve the 'action' destination of the method parser i.e. its",
"# argument name. The HelpAction is ignored.",
"return",
"[",
"action",
".",
"dest",
"for",
"action",
"in",
"parser",
".",
"_actions",
"if",
"not... | Retrieve the name of the function argument linked to the given parser.
Args:
parser: a function parser | [
"Retrieve",
"the",
"name",
"of",
"the",
"function",
"argument",
"linked",
"to",
"the",
"given",
"parser",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L302-L311 |
245,671 | bertrandvidal/parse_this | parse_this/core.py | _call | def _call(callable_obj, arg_names, namespace):
"""Actually calls the callable with the namespace parsed from the command
line.
Args:
callable_obj: a callable object
arg_names: name of the function arguments
namespace: the namespace object parsed from the command line
"""
arg... | python | def _call(callable_obj, arg_names, namespace):
"""Actually calls the callable with the namespace parsed from the command
line.
Args:
callable_obj: a callable object
arg_names: name of the function arguments
namespace: the namespace object parsed from the command line
"""
arg... | [
"def",
"_call",
"(",
"callable_obj",
",",
"arg_names",
",",
"namespace",
")",
":",
"arguments",
"=",
"{",
"arg_name",
":",
"getattr",
"(",
"namespace",
",",
"arg_name",
")",
"for",
"arg_name",
"in",
"arg_names",
"}",
"return",
"callable_obj",
"(",
"*",
"*"... | Actually calls the callable with the namespace parsed from the command
line.
Args:
callable_obj: a callable object
arg_names: name of the function arguments
namespace: the namespace object parsed from the command line | [
"Actually",
"calls",
"the",
"callable",
"with",
"the",
"namespace",
"parsed",
"from",
"the",
"command",
"line",
"."
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L314-L325 |
245,672 | bertrandvidal/parse_this | parse_this/core.py | _call_method_from_namespace | def _call_method_from_namespace(obj, method_name, namespace):
"""Call the method, retrieved from obj, with the correct arguments via
the namespace
Args:
obj: any kind of object
method_name: method to be called
namespace: an argparse.Namespace object containing parsed command
... | python | def _call_method_from_namespace(obj, method_name, namespace):
"""Call the method, retrieved from obj, with the correct arguments via
the namespace
Args:
obj: any kind of object
method_name: method to be called
namespace: an argparse.Namespace object containing parsed command
... | [
"def",
"_call_method_from_namespace",
"(",
"obj",
",",
"method_name",
",",
"namespace",
")",
":",
"method",
"=",
"getattr",
"(",
"obj",
",",
"method_name",
")",
"method_parser",
"=",
"method",
".",
"parser",
"arg_names",
"=",
"_get_args_name_from_parser",
"(",
"... | Call the method, retrieved from obj, with the correct arguments via
the namespace
Args:
obj: any kind of object
method_name: method to be called
namespace: an argparse.Namespace object containing parsed command
line arguments | [
"Call",
"the",
"method",
"retrieved",
"from",
"obj",
"with",
"the",
"correct",
"arguments",
"via",
"the",
"namespace"
] | aa2e3737f19642300ef1ca65cae21c90049718a2 | https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L328-L343 |
245,673 | jtpaasch/simplygithub | simplygithub/internals/api.py | get_url | def get_url(profile, resource):
"""Get the URL for a resource.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
... | python | def get_url(profile, resource):
"""Get the URL for a resource.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
... | [
"def",
"get_url",
"(",
"profile",
",",
"resource",
")",
":",
"repo",
"=",
"profile",
"[",
"\"repo\"",
"]",
"url",
"=",
"GITHUB_API_BASE_URL",
"+",
"\"repos/\"",
"+",
"repo",
"+",
"\"/git\"",
"+",
"resource",
"return",
"url"
] | Get the URL for a resource.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
The part of a Github API URL ... | [
"Get",
"the",
"URL",
"for",
"a",
"resource",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L23-L43 |
245,674 | jtpaasch/simplygithub | simplygithub/internals/api.py | post_merge_request | def post_merge_request(profile, payload):
"""Do a POST request to Github's API to merge.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect ... | python | def post_merge_request(profile, payload):
"""Do a POST request to Github's API to merge.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect ... | [
"def",
"post_merge_request",
"(",
"profile",
",",
"payload",
")",
":",
"repo",
"=",
"profile",
"[",
"\"repo\"",
"]",
"url",
"=",
"GITHUB_API_BASE_URL",
"+",
"\"repos/\"",
"+",
"repo",
"+",
"\"/merges\"",
"headers",
"=",
"get_headers",
"(",
"profile",
")",
"r... | Do a POST request to Github's API to merge.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
payload
A dict of info... | [
"Do",
"a",
"POST",
"request",
"to",
"Github",
"s",
"API",
"to",
"merge",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L46-L71 |
245,675 | jtpaasch/simplygithub | simplygithub/internals/api.py | get_request | def get_request(profile, resource):
"""Do a GET request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
r... | python | def get_request(profile, resource):
"""Do a GET request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
r... | [
"def",
"get_request",
"(",
"profile",
",",
"resource",
")",
":",
"url",
"=",
"get_url",
"(",
"profile",
",",
"resource",
")",
"headers",
"=",
"get_headers",
"(",
"profile",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
... | Do a GET request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
The part of a Github AP... | [
"Do",
"a",
"GET",
"request",
"to",
"Github",
"s",
"API",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L95-L116 |
245,676 | jtpaasch/simplygithub | simplygithub/internals/api.py | post_request | def post_request(profile, resource, payload):
"""Do a POST request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.... | python | def post_request(profile, resource, payload):
"""Do a POST request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.... | [
"def",
"post_request",
"(",
"profile",
",",
"resource",
",",
"payload",
")",
":",
"url",
"=",
"get_url",
"(",
"profile",
",",
"resource",
")",
"headers",
"=",
"get_headers",
"(",
"profile",
")",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
... | Do a POST request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
The part of a Github A... | [
"Do",
"a",
"POST",
"request",
"to",
"Github",
"s",
"API",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L119-L144 |
245,677 | jtpaasch/simplygithub | simplygithub/internals/api.py | delete_request | def delete_request(profile, resource):
"""Do a DELETE request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | python | def delete_request(profile, resource):
"""Do a DELETE request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | [
"def",
"delete_request",
"(",
"profile",
",",
"resource",
")",
":",
"url",
"=",
"get_url",
"(",
"profile",
",",
"resource",
")",
"headers",
"=",
"get_headers",
"(",
"profile",
")",
"return",
"requests",
".",
"delete",
"(",
"url",
",",
"headers",
"=",
"he... | Do a DELETE request to Github's API.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
resource
The part of a Github... | [
"Do",
"a",
"DELETE",
"request",
"to",
"Github",
"s",
"API",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L175-L196 |
245,678 | koheimiya/extheano | extheano/nodebuffer.py | NodeBuffer._extract_updater | def _extract_updater(self):
""" Get the update and reset the buffer.
Return `None` if there is no update. """
if self._node is self._buffer:
return None
else:
updater = (self._node, self._buffer)
self._buffer = self._node
return updater | python | def _extract_updater(self):
""" Get the update and reset the buffer.
Return `None` if there is no update. """
if self._node is self._buffer:
return None
else:
updater = (self._node, self._buffer)
self._buffer = self._node
return updater | [
"def",
"_extract_updater",
"(",
"self",
")",
":",
"if",
"self",
".",
"_node",
"is",
"self",
".",
"_buffer",
":",
"return",
"None",
"else",
":",
"updater",
"=",
"(",
"self",
".",
"_node",
",",
"self",
".",
"_buffer",
")",
"self",
".",
"_buffer",
"=",
... | Get the update and reset the buffer.
Return `None` if there is no update. | [
"Get",
"the",
"update",
"and",
"reset",
"the",
"buffer",
".",
"Return",
"None",
"if",
"there",
"is",
"no",
"update",
"."
] | ea099a6395ca8772660b2c715fb26cde12738181 | https://github.com/koheimiya/extheano/blob/ea099a6395ca8772660b2c715fb26cde12738181/extheano/nodebuffer.py#L32-L40 |
245,679 | hmartiniano/faz | faz/graph.py | DependencyGraph._build_graph | def _build_graph(self):
""" Produce a dependency graph based on a list
of tasks produced by the parser.
"""
self._graph.add_nodes_from(self.tasks)
for node1 in self._graph.nodes:
for node2 in self._graph.nodes:
for input_file in node1.inputs:
... | python | def _build_graph(self):
""" Produce a dependency graph based on a list
of tasks produced by the parser.
"""
self._graph.add_nodes_from(self.tasks)
for node1 in self._graph.nodes:
for node2 in self._graph.nodes:
for input_file in node1.inputs:
... | [
"def",
"_build_graph",
"(",
"self",
")",
":",
"self",
".",
"_graph",
".",
"add_nodes_from",
"(",
"self",
".",
"tasks",
")",
"for",
"node1",
"in",
"self",
".",
"_graph",
".",
"nodes",
":",
"for",
"node2",
"in",
"self",
".",
"_graph",
".",
"nodes",
":"... | Produce a dependency graph based on a list
of tasks produced by the parser. | [
"Produce",
"a",
"dependency",
"graph",
"based",
"on",
"a",
"list",
"of",
"tasks",
"produced",
"by",
"the",
"parser",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/graph.py#L48-L61 |
245,680 | blubberdiblub/eztemplate | eztemplate/engines/string_formatter_engine.py | FormatterWrapper.get_value | def get_value(self, key, args, kwargs):
"""Get value only from mapping and possibly convert key to string."""
if (self.tolerant and
not isinstance(key, basestring) and
key not in kwargs):
key = str(key)
return kwargs[key] | python | def get_value(self, key, args, kwargs):
"""Get value only from mapping and possibly convert key to string."""
if (self.tolerant and
not isinstance(key, basestring) and
key not in kwargs):
key = str(key)
return kwargs[key] | [
"def",
"get_value",
"(",
"self",
",",
"key",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"(",
"self",
".",
"tolerant",
"and",
"not",
"isinstance",
"(",
"key",
",",
"basestring",
")",
"and",
"key",
"not",
"in",
"kwargs",
")",
":",
"key",
"=",
"str",... | Get value only from mapping and possibly convert key to string. | [
"Get",
"value",
"only",
"from",
"mapping",
"and",
"possibly",
"convert",
"key",
"to",
"string",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L49-L56 |
245,681 | blubberdiblub/eztemplate | eztemplate/engines/string_formatter_engine.py | FormatterWrapper.get_field | def get_field(self, field_name, args, kwargs):
"""Create a special value when field missing and tolerant."""
try:
obj, arg_used = super(FormatterWrapper, self).get_field(
field_name, args, kwargs)
except (KeyError, IndexError, AttributeError):
if not s... | python | def get_field(self, field_name, args, kwargs):
"""Create a special value when field missing and tolerant."""
try:
obj, arg_used = super(FormatterWrapper, self).get_field(
field_name, args, kwargs)
except (KeyError, IndexError, AttributeError):
if not s... | [
"def",
"get_field",
"(",
"self",
",",
"field_name",
",",
"args",
",",
"kwargs",
")",
":",
"try",
":",
"obj",
",",
"arg_used",
"=",
"super",
"(",
"FormatterWrapper",
",",
"self",
")",
".",
"get_field",
"(",
"field_name",
",",
"args",
",",
"kwargs",
")",... | Create a special value when field missing and tolerant. | [
"Create",
"a",
"special",
"value",
"when",
"field",
"missing",
"and",
"tolerant",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L58-L70 |
245,682 | blubberdiblub/eztemplate | eztemplate/engines/string_formatter_engine.py | FormatterWrapper.convert_field | def convert_field(self, value, conversion):
"""When field missing, store conversion specifier."""
if isinstance(value, MissingField):
if conversion is not None:
value.conversion = conversion
return value
return super(FormatterWrapper, self).convert_field(... | python | def convert_field(self, value, conversion):
"""When field missing, store conversion specifier."""
if isinstance(value, MissingField):
if conversion is not None:
value.conversion = conversion
return value
return super(FormatterWrapper, self).convert_field(... | [
"def",
"convert_field",
"(",
"self",
",",
"value",
",",
"conversion",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"MissingField",
")",
":",
"if",
"conversion",
"is",
"not",
"None",
":",
"value",
".",
"conversion",
"=",
"conversion",
"return",
"value",... | When field missing, store conversion specifier. | [
"When",
"field",
"missing",
"store",
"conversion",
"specifier",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L72-L79 |
245,683 | blubberdiblub/eztemplate | eztemplate/engines/string_formatter_engine.py | FormatterWrapper.format_field | def format_field(self, value, format_spec):
"""When field missing, return original spec."""
if isinstance(value, MissingField):
if format_spec is not None:
value.format_spec = format_spec
return str(value)
return super(FormatterWrapper, self).format_field... | python | def format_field(self, value, format_spec):
"""When field missing, return original spec."""
if isinstance(value, MissingField):
if format_spec is not None:
value.format_spec = format_spec
return str(value)
return super(FormatterWrapper, self).format_field... | [
"def",
"format_field",
"(",
"self",
",",
"value",
",",
"format_spec",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"MissingField",
")",
":",
"if",
"format_spec",
"is",
"not",
"None",
":",
"value",
".",
"format_spec",
"=",
"format_spec",
"return",
"str"... | When field missing, return original spec. | [
"When",
"field",
"missing",
"return",
"original",
"spec",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L81-L88 |
245,684 | emencia/emencia-django-forum | forum/models.py | Category.get_last_thread | def get_last_thread(self):
"""
Return the last modified thread
"""
cache_key = '_get_last_thread_cache'
if not hasattr(self, cache_key):
item = None
res = self.thread_set.filter(visible=True).order_by('-modified')[0:1]
if len(res)>0:
... | python | def get_last_thread(self):
"""
Return the last modified thread
"""
cache_key = '_get_last_thread_cache'
if not hasattr(self, cache_key):
item = None
res = self.thread_set.filter(visible=True).order_by('-modified')[0:1]
if len(res)>0:
... | [
"def",
"get_last_thread",
"(",
"self",
")",
":",
"cache_key",
"=",
"'_get_last_thread_cache'",
"if",
"not",
"hasattr",
"(",
"self",
",",
"cache_key",
")",
":",
"item",
"=",
"None",
"res",
"=",
"self",
".",
"thread_set",
".",
"filter",
"(",
"visible",
"=",
... | Return the last modified thread | [
"Return",
"the",
"last",
"modified",
"thread"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L31-L42 |
245,685 | emencia/emencia-django-forum | forum/models.py | Thread.save | def save(self, *args, **kwargs):
"""
Fill 'created' and 'modified' attributes on first create
"""
if self.created is None:
self.created = tz_now()
if self.modified is None:
self.modified = self.created
super(Thread, self).save... | python | def save(self, *args, **kwargs):
"""
Fill 'created' and 'modified' attributes on first create
"""
if self.created is None:
self.created = tz_now()
if self.modified is None:
self.modified = self.created
super(Thread, self).save... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"created",
"is",
"None",
":",
"self",
".",
"created",
"=",
"tz_now",
"(",
")",
"if",
"self",
".",
"modified",
"is",
"None",
":",
"self",
".",
"m... | Fill 'created' and 'modified' attributes on first create | [
"Fill",
"created",
"and",
"modified",
"attributes",
"on",
"first",
"create"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L99-L109 |
245,686 | emencia/emencia-django-forum | forum/models.py | Post.get_paginated_urlargs | def get_paginated_urlargs(self):
"""
Return url arguments to retrieve the Post in a paginated list
"""
position = self.get_paginated_position()
if not position:
return '#forum-post-{0}'.format(self.id)
return '?page={0}#forum-post-{1}'.format... | python | def get_paginated_urlargs(self):
"""
Return url arguments to retrieve the Post in a paginated list
"""
position = self.get_paginated_position()
if not position:
return '#forum-post-{0}'.format(self.id)
return '?page={0}#forum-post-{1}'.format... | [
"def",
"get_paginated_urlargs",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"get_paginated_position",
"(",
")",
"if",
"not",
"position",
":",
"return",
"'#forum-post-{0}'",
".",
"format",
"(",
"self",
".",
"id",
")",
"return",
"'?page={0}#forum-post-{1}... | Return url arguments to retrieve the Post in a paginated list | [
"Return",
"url",
"arguments",
"to",
"retrieve",
"the",
"Post",
"in",
"a",
"paginated",
"list"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L150-L159 |
245,687 | emencia/emencia-django-forum | forum/models.py | Post.get_paginated_position | def get_paginated_position(self):
"""
Return the Post position in the paginated list
"""
# If Post list is not paginated
if not settings.FORUM_THREAD_DETAIL_PAGINATE:
return 0
count = Post.objects.filter(thread=self.thread_id, created__lt=self.created... | python | def get_paginated_position(self):
"""
Return the Post position in the paginated list
"""
# If Post list is not paginated
if not settings.FORUM_THREAD_DETAIL_PAGINATE:
return 0
count = Post.objects.filter(thread=self.thread_id, created__lt=self.created... | [
"def",
"get_paginated_position",
"(",
"self",
")",
":",
"# If Post list is not paginated",
"if",
"not",
"settings",
".",
"FORUM_THREAD_DETAIL_PAGINATE",
":",
"return",
"0",
"count",
"=",
"Post",
".",
"objects",
".",
"filter",
"(",
"thread",
"=",
"self",
".",
"th... | Return the Post position in the paginated list | [
"Return",
"the",
"Post",
"position",
"in",
"the",
"paginated",
"list"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L161-L171 |
245,688 | emencia/emencia-django-forum | forum/models.py | Post.save | def save(self, *args, **kwargs):
"""
Fill 'created' and 'modified' attributes on first create and allways update
the thread's 'modified' attribute
"""
edited = not(self.created is None)
if self.created is None:
self.created = tz_now()
... | python | def save(self, *args, **kwargs):
"""
Fill 'created' and 'modified' attributes on first create and allways update
the thread's 'modified' attribute
"""
edited = not(self.created is None)
if self.created is None:
self.created = tz_now()
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"edited",
"=",
"not",
"(",
"self",
".",
"created",
"is",
"None",
")",
"if",
"self",
".",
"created",
"is",
"None",
":",
"self",
".",
"created",
"=",
"tz_now",
"(",
... | Fill 'created' and 'modified' attributes on first create and allways update
the thread's 'modified' attribute | [
"Fill",
"created",
"and",
"modified",
"attributes",
"on",
"first",
"create",
"and",
"allways",
"update",
"the",
"thread",
"s",
"modified",
"attribute"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L173-L194 |
245,689 | opinkerfi/nago | nago/extensions/plugins.py | get | def get(search="unsigned"):
""" List all available plugins"""
plugins = []
for i in os.walk('/usr/lib/nagios/plugins'):
for f in i[2]:
plugins.append(f)
return plugins | python | def get(search="unsigned"):
""" List all available plugins"""
plugins = []
for i in os.walk('/usr/lib/nagios/plugins'):
for f in i[2]:
plugins.append(f)
return plugins | [
"def",
"get",
"(",
"search",
"=",
"\"unsigned\"",
")",
":",
"plugins",
"=",
"[",
"]",
"for",
"i",
"in",
"os",
".",
"walk",
"(",
"'/usr/lib/nagios/plugins'",
")",
":",
"for",
"f",
"in",
"i",
"[",
"2",
"]",
":",
"plugins",
".",
"append",
"(",
"f",
... | List all available plugins | [
"List",
"all",
"available",
"plugins"
] | 85e1bdd1de0122f56868a483e7599e1b36a439b0 | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/plugins.py#L13-L19 |
245,690 | opinkerfi/nago | nago/extensions/plugins.py | run | def run(plugin_name, *args, **kwargs):
""" Run a specific plugin """
plugindir = nago.settings.get_option('plugin_dir')
plugin = plugindir + "/" + plugin_name
if not os.path.isfile(plugin):
raise ValueError("Plugin %s not found" % plugin)
command = [plugin] + list(args)
p = subprocess.P... | python | def run(plugin_name, *args, **kwargs):
""" Run a specific plugin """
plugindir = nago.settings.get_option('plugin_dir')
plugin = plugindir + "/" + plugin_name
if not os.path.isfile(plugin):
raise ValueError("Plugin %s not found" % plugin)
command = [plugin] + list(args)
p = subprocess.P... | [
"def",
"run",
"(",
"plugin_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"plugindir",
"=",
"nago",
".",
"settings",
".",
"get_option",
"(",
"'plugin_dir'",
")",
"plugin",
"=",
"plugindir",
"+",
"\"/\"",
"+",
"plugin_name",
"if",
"not",
"o... | Run a specific plugin | [
"Run",
"a",
"specific",
"plugin"
] | 85e1bdd1de0122f56868a483e7599e1b36a439b0 | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/plugins.py#L22-L36 |
245,691 | b3j0f/utils | b3j0f/utils/property.py | find_ctx | def find_ctx(elt):
"""Get the right ctx related to input elt.
In order to keep safe memory as much as possible, it is important to find
the right context element. For example, instead of putting properties on
a function at the level of an instance, it is important to save such
property on the insta... | python | def find_ctx(elt):
"""Get the right ctx related to input elt.
In order to keep safe memory as much as possible, it is important to find
the right context element. For example, instead of putting properties on
a function at the level of an instance, it is important to save such
property on the insta... | [
"def",
"find_ctx",
"(",
"elt",
")",
":",
"result",
"=",
"elt",
"# by default, result is ctx",
"# if elt is ctx and elt is a method, it is possible to find the best ctx",
"if",
"ismethod",
"(",
"elt",
")",
":",
"# get instance and class of the elt",
"instance",
"=",
"get_metho... | Get the right ctx related to input elt.
In order to keep safe memory as much as possible, it is important to find
the right context element. For example, instead of putting properties on
a function at the level of an instance, it is important to save such
property on the instance because the function._... | [
"Get",
"the",
"right",
"ctx",
"related",
"to",
"input",
"elt",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L81-L107 |
245,692 | b3j0f/utils | b3j0f/utils/property.py | free_cache | def free_cache(ctx, *elts):
"""Free properties bound to input cached elts. If empty, free the whole
cache.
"""
for elt in elts:
if isinstance(elt, Hashable):
cache = __STATIC_ELEMENTS_CACHE__
else:
cache = __UNHASHABLE_ELTS_CACHE__
elt = id(elt)
... | python | def free_cache(ctx, *elts):
"""Free properties bound to input cached elts. If empty, free the whole
cache.
"""
for elt in elts:
if isinstance(elt, Hashable):
cache = __STATIC_ELEMENTS_CACHE__
else:
cache = __UNHASHABLE_ELTS_CACHE__
elt = id(elt)
... | [
"def",
"free_cache",
"(",
"ctx",
",",
"*",
"elts",
")",
":",
"for",
"elt",
"in",
"elts",
":",
"if",
"isinstance",
"(",
"elt",
",",
"Hashable",
")",
":",
"cache",
"=",
"__STATIC_ELEMENTS_CACHE__",
"else",
":",
"cache",
"=",
"__UNHASHABLE_ELTS_CACHE__",
"elt... | Free properties bound to input cached elts. If empty, free the whole
cache. | [
"Free",
"properties",
"bound",
"to",
"input",
"cached",
"elts",
".",
"If",
"empty",
"free",
"the",
"whole",
"cache",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L110-L126 |
245,693 | b3j0f/utils | b3j0f/utils/property.py | _ctx_elt_properties | def _ctx_elt_properties(elt, ctx=None, create=False):
"""Get elt properties related to a ctx.
:param elt: property component elt. Not None methods or unhashable types.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or insta... | python | def _ctx_elt_properties(elt, ctx=None, create=False):
"""Get elt properties related to a ctx.
:param elt: property component elt. Not None methods or unhashable types.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or insta... | [
"def",
"_ctx_elt_properties",
"(",
"elt",
",",
"ctx",
"=",
"None",
",",
"create",
"=",
"False",
")",
":",
"result",
"=",
"None",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"find_ctx",
"(",
"elt",
"=",
"elt",
")",
"ctx_properties",
"=",
"None",
"# in... | Get elt properties related to a ctx.
:param elt: property component elt. Not None methods or unhashable types.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or instance if
related function is defined in base class.
... | [
"Get",
"elt",
"properties",
"related",
"to",
"a",
"ctx",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L129-L184 |
245,694 | b3j0f/utils | b3j0f/utils/property.py | get_properties | def get_properties(elt, keys=None, ctx=None):
"""Get elt properties.
:param elt: properties elt. Not None methods or unhashable types.
:param keys: key(s) of properties to get from elt.
If None, get all properties.
:type keys: list or str
:param ctx: elt ctx from where get properties. Equal... | python | def get_properties(elt, keys=None, ctx=None):
"""Get elt properties.
:param elt: properties elt. Not None methods or unhashable types.
:param keys: key(s) of properties to get from elt.
If None, get all properties.
:type keys: list or str
:param ctx: elt ctx from where get properties. Equal... | [
"def",
"get_properties",
"(",
"elt",
",",
"keys",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"# initialize keys if str",
"if",
"isinstance",
"(",
"keys",
",",
"string_types",
")",
":",
"keys",
"=",
"(",
"keys",
",",
")",
"result",
"=",
"_get_propert... | Get elt properties.
:param elt: properties elt. Not None methods or unhashable types.
:param keys: key(s) of properties to get from elt.
If None, get all properties.
:type keys: list or str
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function prop... | [
"Get",
"elt",
"properties",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L187-L208 |
245,695 | b3j0f/utils | b3j0f/utils/property.py | get_property | def get_property(elt, key, ctx=None):
"""Get elt key property.
:param elt: property elt. Not None methods.
:param key: property key to get from elt.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or instance if
... | python | def get_property(elt, key, ctx=None):
"""Get elt key property.
:param elt: property elt. Not None methods.
:param key: property key to get from elt.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or instance if
... | [
"def",
"get_property",
"(",
"elt",
",",
"key",
",",
"ctx",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"properties",
"=",
"get_properties",
"(",
"elt",
"=",
"elt",
",",
"ctx",
"=",
"ctx",
",",
"keys",
"=",
"key",
")",
"if",
"key",
"in",
"prop... | Get elt key property.
:param elt: property elt. Not None methods.
:param key: property key to get from elt.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or instance if
related function is defined in base class.
... | [
"Get",
"elt",
"key",
"property",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L211-L231 |
245,696 | b3j0f/utils | b3j0f/utils/property.py | get_first_properties | def get_first_properties(elt, keys=None, ctx=None):
"""Get first properties related to one input key.
:param elt: first property elt. Not None methods.
:param list keys: property keys to get.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties... | python | def get_first_properties(elt, keys=None, ctx=None):
"""Get first properties related to one input key.
:param elt: first property elt. Not None methods.
:param list keys: property keys to get.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties... | [
"def",
"get_first_properties",
"(",
"elt",
",",
"keys",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"# ensure keys is an iterable if not None",
"if",
"isinstance",
"(",
"keys",
",",
"string_types",
")",
":",
"keys",
"=",
"(",
"keys",
",",
")",
"result",
... | Get first properties related to one input key.
:param elt: first property elt. Not None methods.
:param list keys: property keys to get.
:param ctx: elt ctx from where get properties. Equals elt if None. It
allows to get function properties related to a class or instance if
related function... | [
"Get",
"first",
"properties",
"related",
"to",
"one",
"input",
"key",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L234-L252 |
245,697 | b3j0f/utils | b3j0f/utils/property.py | get_first_property | def get_first_property(elt, key, default=None, ctx=None):
"""Get first property related to one input key.
:param elt: first property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt.
properties
:param ctx: elt c... | python | def get_first_property(elt, key, default=None, ctx=None):
"""Get first property related to one input key.
:param elt: first property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt.
properties
:param ctx: elt c... | [
"def",
"get_first_property",
"(",
"elt",
",",
"key",
",",
"default",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"result",
"=",
"default",
"properties",
"=",
"_get_properties",
"(",
"elt",
",",
"keys",
"=",
"(",
"key",
",",
")",
",",
"ctx",
"=",
... | Get first property related to one input key.
:param elt: first property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt.
properties
:param ctx: elt ctx from where get properties. Equals elt if None. It
allo... | [
"Get",
"first",
"property",
"related",
"to",
"one",
"input",
"key",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L255-L275 |
245,698 | b3j0f/utils | b3j0f/utils/property.py | get_local_property | def get_local_property(elt, key, default=None, ctx=None):
"""Get one local property related to one input key or default value if key
is not found.
:param elt: local property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in ... | python | def get_local_property(elt, key, default=None, ctx=None):
"""Get one local property related to one input key or default value if key
is not found.
:param elt: local property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in ... | [
"def",
"get_local_property",
"(",
"elt",
",",
"key",
",",
"default",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"result",
"=",
"default",
"local_properties",
"=",
"get_local_properties",
"(",
"elt",
"=",
"elt",
",",
"keys",
"=",
"(",
"key",
",",
"... | Get one local property related to one input key or default value if key
is not found.
:param elt: local property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt
properties.
:param ctx: elt ctx from where get pr... | [
"Get",
"one",
"local",
"property",
"related",
"to",
"one",
"input",
"key",
"or",
"default",
"value",
"if",
"key",
"is",
"not",
"found",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L299-L321 |
245,699 | b3j0f/utils | b3j0f/utils/property.py | put | def put(properties, ttl=None, ctx=None):
"""Decorator dedicated to put properties on an element.
"""
def put_on(elt):
return put_properties(elt=elt, properties=properties, ttl=ttl, ctx=ctx)
return put_on | python | def put(properties, ttl=None, ctx=None):
"""Decorator dedicated to put properties on an element.
"""
def put_on(elt):
return put_properties(elt=elt, properties=properties, ttl=ttl, ctx=ctx)
return put_on | [
"def",
"put",
"(",
"properties",
",",
"ttl",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"def",
"put_on",
"(",
"elt",
")",
":",
"return",
"put_properties",
"(",
"elt",
"=",
"elt",
",",
"properties",
"=",
"properties",
",",
"ttl",
"=",
"ttl",
",... | Decorator dedicated to put properties on an element. | [
"Decorator",
"dedicated",
"to",
"put",
"properties",
"on",
"an",
"element",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L569-L576 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.