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
38,100
toumorokoshi/sprinter
sprinter/formula/eggscript.py
EggscriptFormula.__add_paths
def __add_paths(self, config): """ add the proper resources into the environment """ bin_path = os.path.join(self.directory.install_directory(self.feature_name), 'bin') whitelist_executables = self._get_whitelisted_executables(config) for f in os.listdir(bin_path): for patter...
python
def __add_paths(self, config): """ add the proper resources into the environment """ bin_path = os.path.join(self.directory.install_directory(self.feature_name), 'bin') whitelist_executables = self._get_whitelisted_executables(config) for f in os.listdir(bin_path): for patter...
[ "def", "__add_paths", "(", "self", ",", "config", ")", ":", "bin_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ".", "install_directory", "(", "self", ".", "feature_name", ")", ",", "'bin'", ")", "whitelist_executables", "=", ...
add the proper resources into the environment
[ "add", "the", "proper", "resources", "into", "the", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/eggscript.py#L127-L137
38,101
inveniosoftware/kwalitee
kwalitee/cli/prepare.py
amended_commits
def amended_commits(commits): """Return those git commit sha1s that have been amended later.""" # which SHA1 are declared as amended later? amended_sha1s = [] for message in commits.values(): amended_sha1s.extend(re.findall(r'AMENDS\s([0-f]+)', message)) return amended_sha1s
python
def amended_commits(commits): """Return those git commit sha1s that have been amended later.""" # which SHA1 are declared as amended later? amended_sha1s = [] for message in commits.values(): amended_sha1s.extend(re.findall(r'AMENDS\s([0-f]+)', message)) return amended_sha1s
[ "def", "amended_commits", "(", "commits", ")", ":", "# which SHA1 are declared as amended later?", "amended_sha1s", "=", "[", "]", "for", "message", "in", "commits", ".", "values", "(", ")", ":", "amended_sha1s", ".", "extend", "(", "re", ".", "findall", "(", ...
Return those git commit sha1s that have been amended later.
[ "Return", "those", "git", "commit", "sha1s", "that", "have", "been", "amended", "later", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/cli/prepare.py#L90-L96
38,102
inveniosoftware/kwalitee
kwalitee/cli/prepare.py
enrich_git_log_dict
def enrich_git_log_dict(messages, labels): """Enrich git log with related information on tickets.""" for commit_sha1, message in messages.items(): # detect module and ticket numbers for each commit: component = None title = message.split('\n')[0] try: component, title...
python
def enrich_git_log_dict(messages, labels): """Enrich git log with related information on tickets.""" for commit_sha1, message in messages.items(): # detect module and ticket numbers for each commit: component = None title = message.split('\n')[0] try: component, title...
[ "def", "enrich_git_log_dict", "(", "messages", ",", "labels", ")", ":", "for", "commit_sha1", ",", "message", "in", "messages", ".", "items", "(", ")", ":", "# detect module and ticket numbers for each commit:", "component", "=", "None", "title", "=", "message", "...
Enrich git log with related information on tickets.
[ "Enrich", "git", "log", "with", "related", "information", "on", "tickets", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/cli/prepare.py#L99-L122
38,103
inveniosoftware/kwalitee
kwalitee/cli/prepare.py
release
def release(obj, commit='HEAD', components=False): """Generate release notes.""" options = obj.options repository = obj.repository try: sha = 'oid' commits = _pygit2_commits(commit, repository) except ImportError: try: sha = 'hexsha' commits = _git_co...
python
def release(obj, commit='HEAD', components=False): """Generate release notes.""" options = obj.options repository = obj.repository try: sha = 'oid' commits = _pygit2_commits(commit, repository) except ImportError: try: sha = 'hexsha' commits = _git_co...
[ "def", "release", "(", "obj", ",", "commit", "=", "'HEAD'", ",", "components", "=", "False", ")", ":", "options", "=", "obj", ".", "options", "repository", "=", "obj", ".", "repository", "try", ":", "sha", "=", "'oid'", "commits", "=", "_pygit2_commits",...
Generate release notes.
[ "Generate", "release", "notes", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/cli/prepare.py#L130-L196
38,104
frascoweb/frasco
frasco/actions/common.py
redirect
def redirect(view=None, url=None, **kwargs): """Redirects to the specified view or url """ if view: if url: kwargs["url"] = url url = flask.url_for(view, **kwargs) current_context.exit(flask.redirect(url))
python
def redirect(view=None, url=None, **kwargs): """Redirects to the specified view or url """ if view: if url: kwargs["url"] = url url = flask.url_for(view, **kwargs) current_context.exit(flask.redirect(url))
[ "def", "redirect", "(", "view", "=", "None", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "view", ":", "if", "url", ":", "kwargs", "[", "\"url\"", "]", "=", "url", "url", "=", "flask", ".", "url_for", "(", "view", ",", "*",...
Redirects to the specified view or url
[ "Redirects", "to", "the", "specified", "view", "or", "url" ]
ea519d69dd5ca6deaf3650175692ee4a1a02518f
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/common.py#L150-L157
38,105
wearpants/instrument
instrument/output/statsd.py
statsd_metric
def statsd_metric(name, count, elapsed): """Metric that records to statsd & graphite""" with statsd.pipeline() as pipe: pipe.incr(name, count) pipe.timing(name, int(round(1000 * elapsed)))
python
def statsd_metric(name, count, elapsed): """Metric that records to statsd & graphite""" with statsd.pipeline() as pipe: pipe.incr(name, count) pipe.timing(name, int(round(1000 * elapsed)))
[ "def", "statsd_metric", "(", "name", ",", "count", ",", "elapsed", ")", ":", "with", "statsd", ".", "pipeline", "(", ")", "as", "pipe", ":", "pipe", ".", "incr", "(", "name", ",", "count", ")", "pipe", ".", "timing", "(", "name", ",", "int", "(", ...
Metric that records to statsd & graphite
[ "Metric", "that", "records", "to", "statsd", "&", "graphite" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/statsd.py#L8-L12
38,106
nikcub/floyd
floyd/templating/jinja.py
compile_file
def compile_file(env, src_path, dst_path, encoding='utf-8', base_dir=''): """Compiles a Jinja2 template to python code. :param env: a Jinja2 Environment instance. :param src_path: path to the source file. :param dst_path: path to the destination file. :param encoding: template encoding. :param base_dir: th...
python
def compile_file(env, src_path, dst_path, encoding='utf-8', base_dir=''): """Compiles a Jinja2 template to python code. :param env: a Jinja2 Environment instance. :param src_path: path to the source file. :param dst_path: path to the destination file. :param encoding: template encoding. :param base_dir: th...
[ "def", "compile_file", "(", "env", ",", "src_path", ",", "dst_path", ",", "encoding", "=", "'utf-8'", ",", "base_dir", "=", "''", ")", ":", "src_file", "=", "file", "(", "src_path", ",", "'r'", ")", "source", "=", "src_file", ".", "read", "(", ")", "...
Compiles a Jinja2 template to python code. :param env: a Jinja2 Environment instance. :param src_path: path to the source file. :param dst_path: path to the destination file. :param encoding: template encoding. :param base_dir: the base path to be removed from the compiled template filename.
[ "Compiles", "a", "Jinja2", "template", "to", "python", "code", "." ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/templating/jinja.py#L242-L259
38,107
wearpants/instrument
instrument/output/plot.py
PlotMetric._pre_dump
def _pre_dump(cls): """Output all recorded stats""" shutil.rmtree(cls.outdir, ignore_errors=True) os.makedirs(cls.outdir) super(PlotMetric, cls)._pre_dump()
python
def _pre_dump(cls): """Output all recorded stats""" shutil.rmtree(cls.outdir, ignore_errors=True) os.makedirs(cls.outdir) super(PlotMetric, cls)._pre_dump()
[ "def", "_pre_dump", "(", "cls", ")", ":", "shutil", ".", "rmtree", "(", "cls", ".", "outdir", ",", "ignore_errors", "=", "True", ")", "os", ".", "makedirs", "(", "cls", ".", "outdir", ")", "super", "(", "PlotMetric", ",", "cls", ")", ".", "_pre_dump"...
Output all recorded stats
[ "Output", "all", "recorded", "stats" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/plot.py#L27-L31
38,108
wearpants/instrument
instrument/output/plot.py
PlotMetric._histogram
def _histogram(self, which, mu, sigma, data): """plot a histogram. For internal use only""" weights = np.ones_like(data)/len(data) # make bar heights sum to 100% n, bins, patches = plt.hist(data, bins=25, weights=weights, facecolor='blue', alpha=0.5) plt.title(r'%s %s: $\mu=%.2f$, $\si...
python
def _histogram(self, which, mu, sigma, data): """plot a histogram. For internal use only""" weights = np.ones_like(data)/len(data) # make bar heights sum to 100% n, bins, patches = plt.hist(data, bins=25, weights=weights, facecolor='blue', alpha=0.5) plt.title(r'%s %s: $\mu=%.2f$, $\si...
[ "def", "_histogram", "(", "self", ",", "which", ",", "mu", ",", "sigma", ",", "data", ")", ":", "weights", "=", "np", ".", "ones_like", "(", "data", ")", "/", "len", "(", "data", ")", "# make bar heights sum to 100%", "n", ",", "bins", ",", "patches", ...
plot a histogram. For internal use only
[ "plot", "a", "histogram", ".", "For", "internal", "use", "only" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/plot.py#L51-L60
38,109
wearpants/instrument
instrument/output/plot.py
PlotMetric._scatter
def _scatter(self): """plot a scatter plot of count vs. elapsed. For internal use only""" plt.scatter(self.count_arr, self.elapsed_arr) plt.title('{}: Count vs. Elapsed'.format(self.name)) plt.xlabel('Items') plt.ylabel('Seconds')
python
def _scatter(self): """plot a scatter plot of count vs. elapsed. For internal use only""" plt.scatter(self.count_arr, self.elapsed_arr) plt.title('{}: Count vs. Elapsed'.format(self.name)) plt.xlabel('Items') plt.ylabel('Seconds')
[ "def", "_scatter", "(", "self", ")", ":", "plt", ".", "scatter", "(", "self", ".", "count_arr", ",", "self", ".", "elapsed_arr", ")", "plt", ".", "title", "(", "'{}: Count vs. Elapsed'", ".", "format", "(", "self", ".", "name", ")", ")", "plt", ".", ...
plot a scatter plot of count vs. elapsed. For internal use only
[ "plot", "a", "scatter", "plot", "of", "count", "vs", ".", "elapsed", ".", "For", "internal", "use", "only" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/plot.py#L62-L68
38,110
NiklasRosenstein-Python/nr-deprecated
nr/futures.py
Future.bind
def bind(self, __fun, *args, **kwargs): """ Bind a worker function to the future. This worker function will be executed when the future is executed. """ with self._lock: if self._running or self._completed or self._cancelled: raise RuntimeError('Future object can not be reused') ...
python
def bind(self, __fun, *args, **kwargs): """ Bind a worker function to the future. This worker function will be executed when the future is executed. """ with self._lock: if self._running or self._completed or self._cancelled: raise RuntimeError('Future object can not be reused') ...
[ "def", "bind", "(", "self", ",", "__fun", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_running", "or", "self", ".", "_completed", "or", "self", ".", "_cancelled", ":", "raise", "Runtim...
Bind a worker function to the future. This worker function will be executed when the future is executed.
[ "Bind", "a", "worker", "function", "to", "the", "future", ".", "This", "worker", "function", "will", "be", "executed", "when", "the", "future", "is", "executed", "." ]
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/futures.py#L138-L150
38,111
NiklasRosenstein-Python/nr-deprecated
nr/futures.py
Future.set_result
def set_result(self, result): """ Allows you to set the result of the future without requiring the future to actually be executed. This can be used if the result is available before the future is run, allowing you to keep the future as the interface for retrieving the result data. :param result...
python
def set_result(self, result): """ Allows you to set the result of the future without requiring the future to actually be executed. This can be used if the result is available before the future is run, allowing you to keep the future as the interface for retrieving the result data. :param result...
[ "def", "set_result", "(", "self", ",", "result", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_enqueued", ":", "raise", "RuntimeError", "(", "'can not set result of enqueued Future'", ")", "self", ".", "_result", "=", "result", "self", "....
Allows you to set the result of the future without requiring the future to actually be executed. This can be used if the result is available before the future is run, allowing you to keep the future as the interface for retrieving the result data. :param result: The result of the future. :raise Run...
[ "Allows", "you", "to", "set", "the", "result", "of", "the", "future", "without", "requiring", "the", "future", "to", "actually", "be", "executed", ".", "This", "can", "be", "used", "if", "the", "result", "is", "available", "before", "the", "future", "is", ...
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/futures.py#L371-L388
38,112
NiklasRosenstein-Python/nr-deprecated
nr/futures.py
Future.set_exception
def set_exception(self, exc_info): """ This method allows you to set an exception in the future without requring that exception to be raised from the futures worker. This method can be called on an unbound future. :param exc_info: Either an exception info tuple or an exception value. In the l...
python
def set_exception(self, exc_info): """ This method allows you to set an exception in the future without requring that exception to be raised from the futures worker. This method can be called on an unbound future. :param exc_info: Either an exception info tuple or an exception value. In the l...
[ "def", "set_exception", "(", "self", ",", "exc_info", ")", ":", "if", "not", "isinstance", "(", "exc_info", ",", "tuple", ")", ":", "if", "not", "isinstance", "(", "exc_info", ",", "BaseException", ")", ":", "raise", "TypeError", "(", "'expected BaseExceptio...
This method allows you to set an exception in the future without requring that exception to be raised from the futures worker. This method can be called on an unbound future. :param exc_info: Either an exception info tuple or an exception value. In the latter case, the traceback will be automatically...
[ "This", "method", "allows", "you", "to", "set", "an", "exception", "in", "the", "future", "without", "requring", "that", "exception", "to", "be", "raised", "from", "the", "futures", "worker", ".", "This", "method", "can", "be", "called", "on", "an", "unbou...
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/futures.py#L390-L419
38,113
NiklasRosenstein-Python/nr-deprecated
nr/futures.py
ThreadPool.enqueue
def enqueue(self, future): """ Enqueue a future to be processed by one of the threads in the pool. The future must be bound to a worker and not have been started yet. """ future.enqueue() with self._lock: if self._shutdown: raise RuntimeError('ThreadPool has been shut down and can...
python
def enqueue(self, future): """ Enqueue a future to be processed by one of the threads in the pool. The future must be bound to a worker and not have been started yet. """ future.enqueue() with self._lock: if self._shutdown: raise RuntimeError('ThreadPool has been shut down and can...
[ "def", "enqueue", "(", "self", ",", "future", ")", ":", "future", ".", "enqueue", "(", ")", "with", "self", ".", "_lock", ":", "if", "self", ".", "_shutdown", ":", "raise", "RuntimeError", "(", "'ThreadPool has been shut down and can no '", "'longer accept futur...
Enqueue a future to be processed by one of the threads in the pool. The future must be bound to a worker and not have been started yet.
[ "Enqueue", "a", "future", "to", "be", "processed", "by", "one", "of", "the", "threads", "in", "the", "pool", ".", "The", "future", "must", "be", "bound", "to", "a", "worker", "and", "not", "have", "been", "started", "yet", "." ]
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/futures.py#L479-L493
38,114
NiklasRosenstein-Python/nr-deprecated
nr/futures.py
ThreadPool.submit
def submit(self, __fun, *args, **kwargs): """ Creates a new future and enqueues it. Returns the future. """ future = Future().bind(__fun, *args, **kwargs) self.enqueue(future) return future
python
def submit(self, __fun, *args, **kwargs): """ Creates a new future and enqueues it. Returns the future. """ future = Future().bind(__fun, *args, **kwargs) self.enqueue(future) return future
[ "def", "submit", "(", "self", ",", "__fun", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "future", "=", "Future", "(", ")", ".", "bind", "(", "__fun", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "enqueue", "(", "future"...
Creates a new future and enqueues it. Returns the future.
[ "Creates", "a", "new", "future", "and", "enqueues", "it", ".", "Returns", "the", "future", "." ]
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/futures.py#L495-L502
38,115
romaryd/python-awesome-decorators
awesomedecorators/timez.py
timeit
def timeit(func): """ Returns the number of seconds that a function took along with the result """ @wraps(func) def timer_wrapper(*args, **kwargs): """ Inner function that uses the Timer context object """ with Timer() as timer: result = func(*args, **kwa...
python
def timeit(func): """ Returns the number of seconds that a function took along with the result """ @wraps(func) def timer_wrapper(*args, **kwargs): """ Inner function that uses the Timer context object """ with Timer() as timer: result = func(*args, **kwa...
[ "def", "timeit", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "timer_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Inner function that uses the Timer context object\n \"\"\"", "with", "Timer", "(", ")", "...
Returns the number of seconds that a function took along with the result
[ "Returns", "the", "number", "of", "seconds", "that", "a", "function", "took", "along", "with", "the", "result" ]
8c83784149338ab69a25797e1097b214d33a5958
https://github.com/romaryd/python-awesome-decorators/blob/8c83784149338ab69a25797e1097b214d33a5958/awesomedecorators/timez.py#L18-L33
38,116
romaryd/python-awesome-decorators
awesomedecorators/timez.py
timeout
def timeout(seconds): """ Raises a TimeoutError if a function does not terminate within specified seconds. """ def _timeout_error(signal, frame): raise TimeoutError("Operation did not finish within \ {} seconds".format(seconds)) def timeout_decorator(func): @wraps(func)...
python
def timeout(seconds): """ Raises a TimeoutError if a function does not terminate within specified seconds. """ def _timeout_error(signal, frame): raise TimeoutError("Operation did not finish within \ {} seconds".format(seconds)) def timeout_decorator(func): @wraps(func)...
[ "def", "timeout", "(", "seconds", ")", ":", "def", "_timeout_error", "(", "signal", ",", "frame", ")", ":", "raise", "TimeoutError", "(", "\"Operation did not finish within \\\n {} seconds\"", ".", "format", "(", "seconds", ")", ")", "def", "timeout_decorator...
Raises a TimeoutError if a function does not terminate within specified seconds.
[ "Raises", "a", "TimeoutError", "if", "a", "function", "does", "not", "terminate", "within", "specified", "seconds", "." ]
8c83784149338ab69a25797e1097b214d33a5958
https://github.com/romaryd/python-awesome-decorators/blob/8c83784149338ab69a25797e1097b214d33a5958/awesomedecorators/timez.py#L36-L58
38,117
smarie/python-parsyfiles
parsyfiles/filesystem_mapping.py
FileMappingConfiguration.create_persisted_object
def create_persisted_object(self, location: str, logger: Logger) -> PersistedObject: """ Creates a PersistedObject representing the object at location 'location', and recursively creates all of its children :param location: :param logger: :return: """ #pr...
python
def create_persisted_object(self, location: str, logger: Logger) -> PersistedObject: """ Creates a PersistedObject representing the object at location 'location', and recursively creates all of its children :param location: :param logger: :return: """ #pr...
[ "def", "create_persisted_object", "(", "self", ",", "location", ":", "str", ",", "logger", ":", "Logger", ")", "->", "PersistedObject", ":", "#print('Checking all files under ' + location)", "logger", ".", "debug", "(", "'Checking all files under [{loc}]'", ".", "format...
Creates a PersistedObject representing the object at location 'location', and recursively creates all of its children :param location: :param logger: :return:
[ "Creates", "a", "PersistedObject", "representing", "the", "object", "at", "location", "location", "and", "recursively", "creates", "all", "of", "its", "children" ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/filesystem_mapping.py#L476-L491
38,118
smarie/python-parsyfiles
parsyfiles/filesystem_mapping.py
WrappedFileMappingConfiguration.is_multifile_object_without_children
def is_multifile_object_without_children(self, location: str) -> bool: """ Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a folder without any files in it :param location: :return: ...
python
def is_multifile_object_without_children(self, location: str) -> bool: """ Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a folder without any files in it :param location: :return: ...
[ "def", "is_multifile_object_without_children", "(", "self", ",", "location", ":", "str", ")", "->", "bool", ":", "return", "isdir", "(", "location", ")", "and", "len", "(", "self", ".", "find_multifile_object_children", "(", "location", ")", ")", "==", "0" ]
Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a folder without any files in it :param location: :return:
[ "Returns", "True", "if", "an", "item", "with", "this", "location", "is", "present", "as", "a", "multifile", "object", "without", "children", ".", "For", "this", "implementation", "this", "means", "that", "there", "is", "a", "folder", "without", "any", "files...
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/filesystem_mapping.py#L549-L557
38,119
smarie/python-parsyfiles
parsyfiles/filesystem_mapping.py
WrappedFileMappingConfiguration.get_multifile_object_child_location
def get_multifile_object_child_location(self, parent_item_prefix: str, child_name: str) -> str: """ Implementation of the parent abstract method. In this mode the attribute is a file inside the parent object folder :param parent_item_prefix: the absolute file prefix of the parent item. ...
python
def get_multifile_object_child_location(self, parent_item_prefix: str, child_name: str) -> str: """ Implementation of the parent abstract method. In this mode the attribute is a file inside the parent object folder :param parent_item_prefix: the absolute file prefix of the parent item. ...
[ "def", "get_multifile_object_child_location", "(", "self", ",", "parent_item_prefix", ":", "str", ",", "child_name", ":", "str", ")", "->", "str", ":", "check_var", "(", "parent_item_prefix", ",", "var_types", "=", "str", ",", "var_name", "=", "'parent_item_prefix...
Implementation of the parent abstract method. In this mode the attribute is a file inside the parent object folder :param parent_item_prefix: the absolute file prefix of the parent item. :return: the file prefix for this attribute
[ "Implementation", "of", "the", "parent", "abstract", "method", ".", "In", "this", "mode", "the", "attribute", "is", "a", "file", "inside", "the", "parent", "object", "folder" ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/filesystem_mapping.py#L559-L574
38,120
smarie/python-parsyfiles
parsyfiles/filesystem_mapping.py
FlatFileMappingConfiguration.is_multifile_object_without_children
def is_multifile_object_without_children(self, location: str) -> bool: """ Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a file with the appropriate name but without extension :param locati...
python
def is_multifile_object_without_children(self, location: str) -> bool: """ Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a file with the appropriate name but without extension :param locati...
[ "def", "is_multifile_object_without_children", "(", "self", ",", "location", ":", "str", ")", "->", "bool", ":", "# (1) Find the base directory and base name", "if", "isdir", "(", "location", ")", ":", "# special case: parent location is the root folder where all the files are....
Returns True if an item with this location is present as a multifile object without children. For this implementation, this means that there is a file with the appropriate name but without extension :param location: :return:
[ "Returns", "True", "if", "an", "item", "with", "this", "location", "is", "present", "as", "a", "multifile", "object", "without", "children", ".", "For", "this", "implementation", "this", "means", "that", "there", "is", "a", "file", "with", "the", "appropriat...
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/filesystem_mapping.py#L691-L708
38,121
thewca/wca-regulations-compiler
wrc/codegen/cghtml.py
special_links_replace
def special_links_replace(text, urls): ''' Replace simplified Regulations and Guidelines links into actual links. 'urls' dictionary is expected to provide actual links to the targeted Regulations and Guidelines, as well as to the PDF file. ''' match_number = r'([A-Za-z0-9]+)' + r'(\+*)' refe...
python
def special_links_replace(text, urls): ''' Replace simplified Regulations and Guidelines links into actual links. 'urls' dictionary is expected to provide actual links to the targeted Regulations and Guidelines, as well as to the PDF file. ''' match_number = r'([A-Za-z0-9]+)' + r'(\+*)' refe...
[ "def", "special_links_replace", "(", "text", ",", "urls", ")", ":", "match_number", "=", "r'([A-Za-z0-9]+)'", "+", "r'(\\+*)'", "reference_list", "=", "[", "(", "r'regulations:article:'", "+", "match_number", ",", "urls", "[", "'regulations'", "]", ")", ",", "("...
Replace simplified Regulations and Guidelines links into actual links. 'urls' dictionary is expected to provide actual links to the targeted Regulations and Guidelines, as well as to the PDF file.
[ "Replace", "simplified", "Regulations", "and", "Guidelines", "links", "into", "actual", "links", ".", "urls", "dictionary", "is", "expected", "to", "provide", "actual", "links", "to", "the", "targeted", "Regulations", "and", "Guidelines", "as", "well", "as", "to...
3ebbd8fe8fec7c9167296f59b2677696fe61a954
https://github.com/thewca/wca-regulations-compiler/blob/3ebbd8fe8fec7c9167296f59b2677696fe61a954/wrc/codegen/cghtml.py#L30-L53
38,122
thewca/wca-regulations-compiler
wrc/codegen/cghtml.py
link2html
def link2html(text): ''' Turns md links to html ''' match = r'\[([^\]]+)\]\(([^)]+)\)' replace = r'<a href="\2">\1</a>' return re.sub(match, replace, text)
python
def link2html(text): ''' Turns md links to html ''' match = r'\[([^\]]+)\]\(([^)]+)\)' replace = r'<a href="\2">\1</a>' return re.sub(match, replace, text)
[ "def", "link2html", "(", "text", ")", ":", "match", "=", "r'\\[([^\\]]+)\\]\\(([^)]+)\\)'", "replace", "=", "r'<a href=\"\\2\">\\1</a>'", "return", "re", ".", "sub", "(", "match", ",", "replace", ",", "text", ")" ]
Turns md links to html
[ "Turns", "md", "links", "to", "html" ]
3ebbd8fe8fec7c9167296f59b2677696fe61a954
https://github.com/thewca/wca-regulations-compiler/blob/3ebbd8fe8fec7c9167296f59b2677696fe61a954/wrc/codegen/cghtml.py#L70-L74
38,123
thewca/wca-regulations-compiler
wrc/codegen/cghtml.py
simple_md2html
def simple_md2html(text, urls): ''' Convert a text from md to html ''' retval = special_links_replace(text, urls) # Create a par break for double newlines retval = re.sub(r'\n\n', r'</p><p>', retval) # Create a visual br for every new line retval = re.sub(r'\n', r'<br />\n', retval) # Do we ...
python
def simple_md2html(text, urls): ''' Convert a text from md to html ''' retval = special_links_replace(text, urls) # Create a par break for double newlines retval = re.sub(r'\n\n', r'</p><p>', retval) # Create a visual br for every new line retval = re.sub(r'\n', r'<br />\n', retval) # Do we ...
[ "def", "simple_md2html", "(", "text", ",", "urls", ")", ":", "retval", "=", "special_links_replace", "(", "text", ",", "urls", ")", "# Create a par break for double newlines", "retval", "=", "re", ".", "sub", "(", "r'\\n\\n'", ",", "r'</p><p>'", ",", "retval", ...
Convert a text from md to html
[ "Convert", "a", "text", "from", "md", "to", "html" ]
3ebbd8fe8fec7c9167296f59b2677696fe61a954
https://github.com/thewca/wca-regulations-compiler/blob/3ebbd8fe8fec7c9167296f59b2677696fe61a954/wrc/codegen/cghtml.py#L76-L86
38,124
thewca/wca-regulations-compiler
wrc/codegen/cghtml.py
WCADocumentHtml.generate_ul
def generate_ul(self, a_list): ''' Determines if we should generate th 'ul' around the list 'a_list' ''' return len(a_list) > 0 and (isinstance(a_list[0], Rule) or isinstance(a_list[0], LabelDecl))
python
def generate_ul(self, a_list): ''' Determines if we should generate th 'ul' around the list 'a_list' ''' return len(a_list) > 0 and (isinstance(a_list[0], Rule) or isinstance(a_list[0], LabelDecl))
[ "def", "generate_ul", "(", "self", ",", "a_list", ")", ":", "return", "len", "(", "a_list", ")", ">", "0", "and", "(", "isinstance", "(", "a_list", "[", "0", "]", ",", "Rule", ")", "or", "isinstance", "(", "a_list", "[", "0", "]", ",", "LabelDecl",...
Determines if we should generate th 'ul' around the list 'a_list'
[ "Determines", "if", "we", "should", "generate", "th", "ul", "around", "the", "list", "a_list" ]
3ebbd8fe8fec7c9167296f59b2677696fe61a954
https://github.com/thewca/wca-regulations-compiler/blob/3ebbd8fe8fec7c9167296f59b2677696fe61a954/wrc/codegen/cghtml.py#L126-L129
38,125
mdickinson/refcycle
setup.py
get_version_info
def get_version_info(): """Extract version information as a dictionary from version.py.""" version_info = {} with open(os.path.join("refcycle", "version.py"), 'r') as f: version_code = compile(f.read(), "version.py", 'exec') exec(version_code, version_info) return version_info
python
def get_version_info(): """Extract version information as a dictionary from version.py.""" version_info = {} with open(os.path.join("refcycle", "version.py"), 'r') as f: version_code = compile(f.read(), "version.py", 'exec') exec(version_code, version_info) return version_info
[ "def", "get_version_info", "(", ")", ":", "version_info", "=", "{", "}", "with", "open", "(", "os", ".", "path", ".", "join", "(", "\"refcycle\"", ",", "\"version.py\"", ")", ",", "'r'", ")", "as", "f", ":", "version_code", "=", "compile", "(", "f", ...
Extract version information as a dictionary from version.py.
[ "Extract", "version", "information", "as", "a", "dictionary", "from", "version", ".", "py", "." ]
627fad74c74efc601209c96405f8118cd99b2241
https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/setup.py#L22-L28
38,126
bryanwweber/thermohw
thermohw/filters.py
div_filter
def div_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]: """Filter the JSON ``value`` for alert divs. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta informati...
python
def div_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]: """Filter the JSON ``value`` for alert divs. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta informati...
[ "def", "div_filter", "(", "key", ":", "str", ",", "value", ":", "list", ",", "format", ":", "str", ",", "meta", ":", "Any", ")", "->", "Optional", "[", "list", "]", ":", "if", "key", "!=", "\"Div\"", "or", "format", "!=", "\"latex\"", ":", "return"...
Filter the JSON ``value`` for alert divs. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta information
[ "Filter", "the", "JSON", "value", "for", "alert", "divs", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/filters.py#L25-L54
38,127
bryanwweber/thermohw
thermohw/filters.py
convert_div
def convert_div(text: str, format: Optional[str] = None) -> "applyJSONFilters": """Apply the `dev_filter` action to the text.""" return applyJSONFilters([div_filter], text, format=format)
python
def convert_div(text: str, format: Optional[str] = None) -> "applyJSONFilters": """Apply the `dev_filter` action to the text.""" return applyJSONFilters([div_filter], text, format=format)
[ "def", "convert_div", "(", "text", ":", "str", ",", "format", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "\"applyJSONFilters\"", ":", "return", "applyJSONFilters", "(", "[", "div_filter", "]", ",", "text", ",", "format", "=", "format", ")"...
Apply the `dev_filter` action to the text.
[ "Apply", "the", "dev_filter", "action", "to", "the", "text", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/filters.py#L57-L59
38,128
bryanwweber/thermohw
thermohw/filters.py
raw_html_filter
def raw_html_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]: """Filter the JSON ``value`` for raw html to convert to LaTeX. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta...
python
def raw_html_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]: """Filter the JSON ``value`` for raw html to convert to LaTeX. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta...
[ "def", "raw_html_filter", "(", "key", ":", "str", ",", "value", ":", "list", ",", "format", ":", "str", ",", "meta", ":", "Any", ")", "->", "Optional", "[", "list", "]", ":", "if", "key", "==", "\"RawInline\"", "and", "format", "==", "\"latex\"", "an...
Filter the JSON ``value`` for raw html to convert to LaTeX. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta information
[ "Filter", "the", "JSON", "value", "for", "raw", "html", "to", "convert", "to", "LaTeX", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/filters.py#L62-L89
38,129
bryanwweber/thermohw
thermohw/filters.py
convert_raw_html
def convert_raw_html(text: str, format: Optional[str] = None) -> "applyJSONFilters": """Apply the `raw_html_filter` action to the text.""" return applyJSONFilters([raw_html_filter], text, format=format)
python
def convert_raw_html(text: str, format: Optional[str] = None) -> "applyJSONFilters": """Apply the `raw_html_filter` action to the text.""" return applyJSONFilters([raw_html_filter], text, format=format)
[ "def", "convert_raw_html", "(", "text", ":", "str", ",", "format", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "\"applyJSONFilters\"", ":", "return", "applyJSONFilters", "(", "[", "raw_html_filter", "]", ",", "text", ",", "format", "=", "form...
Apply the `raw_html_filter` action to the text.
[ "Apply", "the", "raw_html_filter", "action", "to", "the", "text", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/filters.py#L92-L94
38,130
mdickinson/refcycle
refcycle/element_transform_set.py
ElementTransformSet.add
def add(self, element): """Add an element to this set.""" key = self._transform(element) if key not in self._elements: self._elements[key] = element
python
def add(self, element): """Add an element to this set.""" key = self._transform(element) if key not in self._elements: self._elements[key] = element
[ "def", "add", "(", "self", ",", "element", ")", ":", "key", "=", "self", ".", "_transform", "(", "element", ")", "if", "key", "not", "in", "self", ".", "_elements", ":", "self", ".", "_elements", "[", "key", "]", "=", "element" ]
Add an element to this set.
[ "Add", "an", "element", "to", "this", "set", "." ]
627fad74c74efc601209c96405f8118cd99b2241
https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/element_transform_set.py#L47-L51
38,131
jsmits/django-logutils
django_logutils/utils.py
add_items_to_message
def add_items_to_message(msg, log_dict): """Utility function to add dictionary items to a log message.""" out = msg for key, value in log_dict.items(): out += " {}={}".format(key, value) return out
python
def add_items_to_message(msg, log_dict): """Utility function to add dictionary items to a log message.""" out = msg for key, value in log_dict.items(): out += " {}={}".format(key, value) return out
[ "def", "add_items_to_message", "(", "msg", ",", "log_dict", ")", ":", "out", "=", "msg", "for", "key", ",", "value", "in", "log_dict", ".", "items", "(", ")", ":", "out", "+=", "\" {}={}\"", ".", "format", "(", "key", ",", "value", ")", "return", "ou...
Utility function to add dictionary items to a log message.
[ "Utility", "function", "to", "add", "dictionary", "items", "to", "a", "log", "message", "." ]
e88f6e0a08c6f3df9e61f96cfb6cd79bc5ea8a88
https://github.com/jsmits/django-logutils/blob/e88f6e0a08c6f3df9e61f96cfb6cd79bc5ea8a88/django_logutils/utils.py#L8-L13
38,132
wearpants/instrument
instrument/output/csv.py
CSVDirMetric.metric
def metric(cls, name, count, elapsed): """A metric function that writes multiple CSV files :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", sta...
python
def metric(cls, name, count, elapsed): """A metric function that writes multiple CSV files :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", sta...
[ "def", "metric", "(", "cls", ",", "name", ",", "count", ",", "elapsed", ")", ":", "if", "name", "is", "None", ":", "warnings", ".", "warn", "(", "\"Ignoring unnamed metric\"", ",", "stacklevel", "=", "3", ")", "return", "with", "cls", ".", "lock", ":",...
A metric function that writes multiple CSV files :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds
[ "A", "metric", "function", "that", "writes", "multiple", "CSV", "files" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/csv.py#L38-L63
38,133
wearpants/instrument
instrument/output/csv.py
CSVFileMetric.metric
def metric(self, name, count, elapsed): """A metric function that writes a single CSV file :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", sta...
python
def metric(self, name, count, elapsed): """A metric function that writes a single CSV file :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", sta...
[ "def", "metric", "(", "self", ",", "name", ",", "count", ",", "elapsed", ")", ":", "if", "name", "is", "None", ":", "warnings", ".", "warn", "(", "\"Ignoring unnamed metric\"", ",", "stacklevel", "=", "3", ")", "return", "with", "self", ".", "lock", ":...
A metric function that writes a single CSV file :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds
[ "A", "metric", "function", "that", "writes", "a", "single", "CSV", "file" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/csv.py#L102-L115
38,134
Cadasta/cadasta-workertoolbox
setup.py
read
def read(parts): """ Build an absolute path from parts array and and return the contents of the resulting file. Assume UTF-8 encoding. """ cur_dir = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.join(cur_dir, *parts), "rb", "utf-8") as f: return f.read()
python
def read(parts): """ Build an absolute path from parts array and and return the contents of the resulting file. Assume UTF-8 encoding. """ cur_dir = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.join(cur_dir, *parts), "rb", "utf-8") as f: return f.read()
[ "def", "read", "(", "parts", ")", ":", "cur_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "codecs", ".", "open", "(", "os", ".", "path", ".", "join", "(", "cur_dir", ",", ...
Build an absolute path from parts array and and return the contents of the resulting file. Assume UTF-8 encoding.
[ "Build", "an", "absolute", "path", "from", "parts", "array", "and", "and", "return", "the", "contents", "of", "the", "resulting", "file", ".", "Assume", "UTF", "-", "8", "encoding", "." ]
e17cf376538cee0b32c7a21afd5319e3549b954f
https://github.com/Cadasta/cadasta-workertoolbox/blob/e17cf376538cee0b32c7a21afd5319e3549b954f/setup.py#L28-L35
38,135
Cadasta/cadasta-workertoolbox
setup.py
ensure_clean_git
def ensure_clean_git(operation='operation'): """ Verify that git has no uncommitted changes """ if os.system('git diff-index --quiet HEAD --'): print("Unstaged or uncommitted changes detected. {} aborted.".format( operation.capitalize())) sys.exit()
python
def ensure_clean_git(operation='operation'): """ Verify that git has no uncommitted changes """ if os.system('git diff-index --quiet HEAD --'): print("Unstaged or uncommitted changes detected. {} aborted.".format( operation.capitalize())) sys.exit()
[ "def", "ensure_clean_git", "(", "operation", "=", "'operation'", ")", ":", "if", "os", ".", "system", "(", "'git diff-index --quiet HEAD --'", ")", ":", "print", "(", "\"Unstaged or uncommitted changes detected. {} aborted.\"", ".", "format", "(", "operation", ".", "c...
Verify that git has no uncommitted changes
[ "Verify", "that", "git", "has", "no", "uncommitted", "changes" ]
e17cf376538cee0b32c7a21afd5319e3549b954f
https://github.com/Cadasta/cadasta-workertoolbox/blob/e17cf376538cee0b32c7a21afd5319e3549b954f/setup.py#L54-L59
38,136
nikcub/floyd
floyd/util/object.py
hasmethod
def hasmethod(obj, meth): """ Checks if an object, obj, has a callable method, meth return True or False """ if hasattr(obj, meth): return callable(getattr(obj,meth)) return False
python
def hasmethod(obj, meth): """ Checks if an object, obj, has a callable method, meth return True or False """ if hasattr(obj, meth): return callable(getattr(obj,meth)) return False
[ "def", "hasmethod", "(", "obj", ",", "meth", ")", ":", "if", "hasattr", "(", "obj", ",", "meth", ")", ":", "return", "callable", "(", "getattr", "(", "obj", ",", "meth", ")", ")", "return", "False" ]
Checks if an object, obj, has a callable method, meth return True or False
[ "Checks", "if", "an", "object", "obj", "has", "a", "callable", "method", "meth", "return", "True", "or", "False" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/object.py#L19-L27
38,137
nikcub/floyd
floyd/util/object.py
hasvar
def hasvar(obj, var): """ Checks if object, obj has a variable var return True or False """ if hasattr(obj, var): return not callable(getattr(obj, var)) return False
python
def hasvar(obj, var): """ Checks if object, obj has a variable var return True or False """ if hasattr(obj, var): return not callable(getattr(obj, var)) return False
[ "def", "hasvar", "(", "obj", ",", "var", ")", ":", "if", "hasattr", "(", "obj", ",", "var", ")", ":", "return", "not", "callable", "(", "getattr", "(", "obj", ",", "var", ")", ")", "return", "False" ]
Checks if object, obj has a variable var return True or False
[ "Checks", "if", "object", "obj", "has", "a", "variable", "var", "return", "True", "or", "False" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/object.py#L29-L37
38,138
nikcub/floyd
floyd/util/object.py
getmethattr
def getmethattr(obj, meth): """ Returns either the variable value or method invocation """ if hasmethod(obj, meth): return getattr(obj, meth)() elif hasvar(obj, meth): return getattr(obj, meth) return None
python
def getmethattr(obj, meth): """ Returns either the variable value or method invocation """ if hasmethod(obj, meth): return getattr(obj, meth)() elif hasvar(obj, meth): return getattr(obj, meth) return None
[ "def", "getmethattr", "(", "obj", ",", "meth", ")", ":", "if", "hasmethod", "(", "obj", ",", "meth", ")", ":", "return", "getattr", "(", "obj", ",", "meth", ")", "(", ")", "elif", "hasvar", "(", "obj", ",", "meth", ")", ":", "return", "getattr", ...
Returns either the variable value or method invocation
[ "Returns", "either", "the", "variable", "value", "or", "method", "invocation" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/object.py#L39-L47
38,139
nikcub/floyd
floyd/util/object.py
assure_obj_child_dict
def assure_obj_child_dict(obj, var): """Assure the object has the specified child dict """ if not var in obj or type(obj[var]) != type({}): obj[var] = {} return obj
python
def assure_obj_child_dict(obj, var): """Assure the object has the specified child dict """ if not var in obj or type(obj[var]) != type({}): obj[var] = {} return obj
[ "def", "assure_obj_child_dict", "(", "obj", ",", "var", ")", ":", "if", "not", "var", "in", "obj", "or", "type", "(", "obj", "[", "var", "]", ")", "!=", "type", "(", "{", "}", ")", ":", "obj", "[", "var", "]", "=", "{", "}", "return", "obj" ]
Assure the object has the specified child dict
[ "Assure", "the", "object", "has", "the", "specified", "child", "dict" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/object.py#L50-L55
38,140
toumorokoshi/sprinter
sprinter/environment.py
warmup
def warmup(f): """ Decorator to run warmup before running a command """ @wraps(f) def wrapped(self, *args, **kwargs): if not self.warmed_up: self.warmup() return f(self, *args, **kwargs) return wrapped
python
def warmup(f): """ Decorator to run warmup before running a command """ @wraps(f) def wrapped(self, *args, **kwargs): if not self.warmed_up: self.warmup() return f(self, *args, **kwargs) return wrapped
[ "def", "warmup", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "warmed_up", ":", "self", ".", "warmup", "(", ")", "return", "f", ...
Decorator to run warmup before running a command
[ "Decorator", "to", "run", "warmup", "before", "running", "a", "command" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L20-L28
38,141
toumorokoshi/sprinter
sprinter/environment.py
install_required
def install_required(f): """ Return an exception if the namespace is not already installed """ @wraps(f) def wrapped(self, *args, **kwargs): if self.directory.new: raise SprinterException("Namespace %s is not yet installed!" % self.namespace) return f(self, *args, **kwargs) ...
python
def install_required(f): """ Return an exception if the namespace is not already installed """ @wraps(f) def wrapped(self, *args, **kwargs): if self.directory.new: raise SprinterException("Namespace %s is not yet installed!" % self.namespace) return f(self, *args, **kwargs) ...
[ "def", "install_required", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "directory", ".", "new", ":", "raise", "SprinterException", "(", "\"N...
Return an exception if the namespace is not already installed
[ "Return", "an", "exception", "if", "the", "namespace", "is", "not", "already", "installed" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L31-L39
38,142
toumorokoshi/sprinter
sprinter/environment.py
Environment.install
def install(self): """ Install the environment """ self.phase = PHASE.INSTALL if not self.directory.new: self.logger.info("Namespace %s directory already exists!" % self.namespace) self.source = load_manifest(self.directory.manifest_path) return self.update() ...
python
def install(self): """ Install the environment """ self.phase = PHASE.INSTALL if not self.directory.new: self.logger.info("Namespace %s directory already exists!" % self.namespace) self.source = load_manifest(self.directory.manifest_path) return self.update() ...
[ "def", "install", "(", "self", ")", ":", "self", ".", "phase", "=", "PHASE", ".", "INSTALL", "if", "not", "self", ".", "directory", ".", "new", ":", "self", ".", "logger", ".", "info", "(", "\"Namespace %s directory already exists!\"", "%", "self", ".", ...
Install the environment
[ "Install", "the", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L128-L154
38,143
toumorokoshi/sprinter
sprinter/environment.py
Environment.update
def update(self, reconfigure=False): """ update the environment """ try: self.phase = PHASE.UPDATE self.logger.info("Updating environment %s..." % self.namespace) self.install_sandboxes() self.instantiate_features() # We don't grab inputs, only...
python
def update(self, reconfigure=False): """ update the environment """ try: self.phase = PHASE.UPDATE self.logger.info("Updating environment %s..." % self.namespace) self.install_sandboxes() self.instantiate_features() # We don't grab inputs, only...
[ "def", "update", "(", "self", ",", "reconfigure", "=", "False", ")", ":", "try", ":", "self", ".", "phase", "=", "PHASE", ".", "UPDATE", "self", ".", "logger", ".", "info", "(", "\"Updating environment %s...\"", "%", "self", ".", "namespace", ")", "self"...
update the environment
[ "update", "the", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L158-L180
38,144
toumorokoshi/sprinter
sprinter/environment.py
Environment.remove
def remove(self): """ remove the environment """ try: self.phase = PHASE.REMOVE self.logger.info("Removing environment %s..." % self.namespace) self.instantiate_features() self._specialize() for feature in self.features.run_order: ...
python
def remove(self): """ remove the environment """ try: self.phase = PHASE.REMOVE self.logger.info("Removing environment %s..." % self.namespace) self.instantiate_features() self._specialize() for feature in self.features.run_order: ...
[ "def", "remove", "(", "self", ")", ":", "try", ":", "self", ".", "phase", "=", "PHASE", ".", "REMOVE", "self", ".", "logger", ".", "info", "(", "\"Removing environment %s...\"", "%", "self", ".", "namespace", ")", "self", ".", "instantiate_features", "(", ...
remove the environment
[ "remove", "the", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L184-L206
38,145
toumorokoshi/sprinter
sprinter/environment.py
Environment.deactivate
def deactivate(self): """ deactivate the environment """ try: self.phase = PHASE.DEACTIVATE self.logger.info("Deactivating environment %s..." % self.namespace) self.directory.rewrite_config = False self.instantiate_features() self._specialize()...
python
def deactivate(self): """ deactivate the environment """ try: self.phase = PHASE.DEACTIVATE self.logger.info("Deactivating environment %s..." % self.namespace) self.directory.rewrite_config = False self.instantiate_features() self._specialize()...
[ "def", "deactivate", "(", "self", ")", ":", "try", ":", "self", ".", "phase", "=", "PHASE", ".", "DEACTIVATE", "self", ".", "logger", ".", "info", "(", "\"Deactivating environment %s...\"", "%", "self", ".", "namespace", ")", "self", ".", "directory", ".",...
deactivate the environment
[ "deactivate", "the", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L210-L226
38,146
toumorokoshi/sprinter
sprinter/environment.py
Environment.validate
def validate(self): """ Validate the target environment """ self.phase = PHASE.VALIDATE self.logger.info("Validating %s..." % self.namespace) self.instantiate_features() context_dict = {} if self.target: for s in self.target.formula_sections(): ...
python
def validate(self): """ Validate the target environment """ self.phase = PHASE.VALIDATE self.logger.info("Validating %s..." % self.namespace) self.instantiate_features() context_dict = {} if self.target: for s in self.target.formula_sections(): ...
[ "def", "validate", "(", "self", ")", ":", "self", ".", "phase", "=", "PHASE", ".", "VALIDATE", "self", ".", "logger", ".", "info", "(", "\"Validating %s...\"", "%", "self", ".", "namespace", ")", "self", ".", "instantiate_features", "(", ")", "context_dict...
Validate the target environment
[ "Validate", "the", "target", "environment" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L249-L262
38,147
toumorokoshi/sprinter
sprinter/environment.py
Environment.clear_all
def clear_all(self): """ clear all files that were to be injected """ self.injections.clear_all() for config_file in CONFIG_FILES: self.injections.clear(os.path.join("~", config_file))
python
def clear_all(self): """ clear all files that were to be injected """ self.injections.clear_all() for config_file in CONFIG_FILES: self.injections.clear(os.path.join("~", config_file))
[ "def", "clear_all", "(", "self", ")", ":", "self", ".", "injections", ".", "clear_all", "(", ")", "for", "config_file", "in", "CONFIG_FILES", ":", "self", ".", "injections", ".", "clear", "(", "os", ".", "path", ".", "join", "(", "\"~\"", ",", "config_...
clear all files that were to be injected
[ "clear", "all", "files", "that", "were", "to", "be", "injected" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L299-L303
38,148
toumorokoshi/sprinter
sprinter/environment.py
Environment.write_debug_log
def write_debug_log(self, file_path): """ Write the debug log to a file """ with open(file_path, "wb+") as fh: fh.write(system.get_system_info().encode('utf-8')) # writing to debug stream self._debug_stream.seek(0) fh.write(self._debug_stream.read().encode...
python
def write_debug_log(self, file_path): """ Write the debug log to a file """ with open(file_path, "wb+") as fh: fh.write(system.get_system_info().encode('utf-8')) # writing to debug stream self._debug_stream.seek(0) fh.write(self._debug_stream.read().encode...
[ "def", "write_debug_log", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "\"wb+\"", ")", "as", "fh", ":", "fh", ".", "write", "(", "system", ".", "get_system_info", "(", ")", ".", "encode", "(", "'utf-8'", ")", ")", "...
Write the debug log to a file
[ "Write", "the", "debug", "log", "to", "a", "file" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L335-L349
38,149
toumorokoshi/sprinter
sprinter/environment.py
Environment.write_manifest
def write_manifest(self): """ Write the manifest to the file """ if os.path.exists(self.directory.manifest_path): self.main_manifest.write(open(self.directory.manifest_path, "w+"))
python
def write_manifest(self): """ Write the manifest to the file """ if os.path.exists(self.directory.manifest_path): self.main_manifest.write(open(self.directory.manifest_path, "w+"))
[ "def", "write_manifest", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "directory", ".", "manifest_path", ")", ":", "self", ".", "main_manifest", ".", "write", "(", "open", "(", "self", ".", "directory", ".", "manifes...
Write the manifest to the file
[ "Write", "the", "manifest", "to", "the", "file" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L351-L354
38,150
toumorokoshi/sprinter
sprinter/environment.py
Environment.message_failure
def message_failure(self): """ return a failure message, if one exists """ if not isinstance(self.main_manifest, Manifest): return None return self.main_manifest.get('config', 'message_failure', default=None)
python
def message_failure(self): """ return a failure message, if one exists """ if not isinstance(self.main_manifest, Manifest): return None return self.main_manifest.get('config', 'message_failure', default=None)
[ "def", "message_failure", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "main_manifest", ",", "Manifest", ")", ":", "return", "None", "return", "self", ".", "main_manifest", ".", "get", "(", "'config'", ",", "'message_failure'", ",", ...
return a failure message, if one exists
[ "return", "a", "failure", "message", "if", "one", "exists" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L356-L360
38,151
toumorokoshi/sprinter
sprinter/environment.py
Environment.warmup
def warmup(self): """ initialize variables necessary to perform a sprinter action """ self.logger.debug("Warming up...") try: if not isinstance(self.source, Manifest) and self.source: self.source = load_manifest(self.source) if not isinstance(self.target,...
python
def warmup(self): """ initialize variables necessary to perform a sprinter action """ self.logger.debug("Warming up...") try: if not isinstance(self.source, Manifest) and self.source: self.source = load_manifest(self.source) if not isinstance(self.target,...
[ "def", "warmup", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Warming up...\"", ")", "try", ":", "if", "not", "isinstance", "(", "self", ".", "source", ",", "Manifest", ")", "and", "self", ".", "source", ":", "self", ".", "sour...
initialize variables necessary to perform a sprinter action
[ "initialize", "variables", "necessary", "to", "perform", "a", "sprinter", "action" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L366-L408
38,152
toumorokoshi/sprinter
sprinter/environment.py
Environment._inject_config_source
def _inject_config_source(self, source_filename, files_to_inject): """ Inject existing environmental config with namespace sourcing. Returns a tuple of the first file name and path found. """ # src_path = os.path.join(self.directory.root_dir, source_filename) # src_exec =...
python
def _inject_config_source(self, source_filename, files_to_inject): """ Inject existing environmental config with namespace sourcing. Returns a tuple of the first file name and path found. """ # src_path = os.path.join(self.directory.root_dir, source_filename) # src_exec =...
[ "def", "_inject_config_source", "(", "self", ",", "source_filename", ",", "files_to_inject", ")", ":", "# src_path = os.path.join(self.directory.root_dir, source_filename)", "# src_exec = \"[ -r %s ] && . %s\" % (src_path, src_path)", "src_exec", "=", "\"[ -r {0} ] && . {0}\"", ".", ...
Inject existing environmental config with namespace sourcing. Returns a tuple of the first file name and path found.
[ "Inject", "existing", "environmental", "config", "with", "namespace", "sourcing", ".", "Returns", "a", "tuple", "of", "the", "first", "file", "name", "and", "path", "found", "." ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L410-L431
38,153
toumorokoshi/sprinter
sprinter/environment.py
Environment._finalize
def _finalize(self): """ command to run at the end of sprinter's run """ self.logger.info("Finalizing...") self.write_manifest() if self.directory.rewrite_config: # always ensure .rc is written (sourcing .env) self.directory.add_to_rc('') # prepend br...
python
def _finalize(self): """ command to run at the end of sprinter's run """ self.logger.info("Finalizing...") self.write_manifest() if self.directory.rewrite_config: # always ensure .rc is written (sourcing .env) self.directory.add_to_rc('') # prepend br...
[ "def", "_finalize", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Finalizing...\"", ")", "self", ".", "write_manifest", "(", ")", "if", "self", ".", "directory", ".", "rewrite_config", ":", "# always ensure .rc is written (sourcing .env)", "...
command to run at the end of sprinter's run
[ "command", "to", "run", "at", "the", "end", "of", "sprinter", "s", "run" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L433-L467
38,154
toumorokoshi/sprinter
sprinter/environment.py
Environment._build_logger
def _build_logger(self, level=logging.INFO): """ return a logger. if logger is none, generate a logger from stdout """ self._debug_stream = StringIO() logger = logging.getLogger('sprinter') # stdout log out_hdlr = logging.StreamHandler(sys.stdout) out_hdlr.setLevel(level)...
python
def _build_logger(self, level=logging.INFO): """ return a logger. if logger is none, generate a logger from stdout """ self._debug_stream = StringIO() logger = logging.getLogger('sprinter') # stdout log out_hdlr = logging.StreamHandler(sys.stdout) out_hdlr.setLevel(level)...
[ "def", "_build_logger", "(", "self", ",", "level", "=", "logging", ".", "INFO", ")", ":", "self", ".", "_debug_stream", "=", "StringIO", "(", ")", "logger", "=", "logging", ".", "getLogger", "(", "'sprinter'", ")", "# stdout log", "out_hdlr", "=", "logging...
return a logger. if logger is none, generate a logger from stdout
[ "return", "a", "logger", ".", "if", "logger", "is", "none", "generate", "a", "logger", "from", "stdout" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L475-L489
38,155
toumorokoshi/sprinter
sprinter/environment.py
Environment.run_action
def run_action(self, feature, action, run_if_error=False, raise_exception=True): """ Run an action, and log it's output in case of errors """ if len(self._error_dict[feature]) > 0 and not run_if_error: return error = None instance = self...
python
def run_action(self, feature, action, run_if_error=False, raise_exception=True): """ Run an action, and log it's output in case of errors """ if len(self._error_dict[feature]) > 0 and not run_if_error: return error = None instance = self...
[ "def", "run_action", "(", "self", ",", "feature", ",", "action", ",", "run_if_error", "=", "False", ",", "raise_exception", "=", "True", ")", ":", "if", "len", "(", "self", ".", "_error_dict", "[", "feature", "]", ")", ">", "0", "and", "not", "run_if_e...
Run an action, and log it's output in case of errors
[ "Run", "an", "action", "and", "log", "it", "s", "output", "in", "case", "of", "errors" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L509-L537
38,156
toumorokoshi/sprinter
sprinter/environment.py
Environment._specialize
def _specialize(self, reconfigure=False): """ Add variables and specialize contexts """ # add in the 'root_dir' directories to the context dictionaries for manifest in [self.source, self.target]: context_dict = {} if manifest: for s in manifest.formula_sec...
python
def _specialize(self, reconfigure=False): """ Add variables and specialize contexts """ # add in the 'root_dir' directories to the context dictionaries for manifest in [self.source, self.target]: context_dict = {} if manifest: for s in manifest.formula_sec...
[ "def", "_specialize", "(", "self", ",", "reconfigure", "=", "False", ")", ":", "# add in the 'root_dir' directories to the context dictionaries", "for", "manifest", "in", "[", "self", ".", "source", ",", "self", ".", "target", "]", ":", "context_dict", "=", "{", ...
Add variables and specialize contexts
[ "Add", "variables", "and", "specialize", "contexts" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L553-L571
38,157
toumorokoshi/sprinter
sprinter/environment.py
Environment._copy_source_to_target
def _copy_source_to_target(self): """ copy source user configuration to target """ if self.source and self.target: for k, v in self.source.items('config'): # always have source override target. self.target.set_input(k, v)
python
def _copy_source_to_target(self): """ copy source user configuration to target """ if self.source and self.target: for k, v in self.source.items('config'): # always have source override target. self.target.set_input(k, v)
[ "def", "_copy_source_to_target", "(", "self", ")", ":", "if", "self", ".", "source", "and", "self", ".", "target", ":", "for", "k", ",", "v", "in", "self", ".", "source", ".", "items", "(", "'config'", ")", ":", "# always have source override target.", "se...
copy source user configuration to target
[ "copy", "source", "user", "configuration", "to", "target" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L573-L578
38,158
toumorokoshi/sprinter
sprinter/environment.py
Environment.grab_inputs
def grab_inputs(self, reconfigure=False): """ Resolve the source and target config section """ self._copy_source_to_target() if self.target: self.target.grab_inputs(force=reconfigure)
python
def grab_inputs(self, reconfigure=False): """ Resolve the source and target config section """ self._copy_source_to_target() if self.target: self.target.grab_inputs(force=reconfigure)
[ "def", "grab_inputs", "(", "self", ",", "reconfigure", "=", "False", ")", ":", "self", ".", "_copy_source_to_target", "(", ")", "if", "self", ".", "target", ":", "self", ".", "target", ".", "grab_inputs", "(", "force", "=", "reconfigure", ")" ]
Resolve the source and target config section
[ "Resolve", "the", "source", "and", "target", "config", "section" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L580-L584
38,159
toumorokoshi/sprinter
sprinter/install.py
parse_domain
def parse_domain(url): """ parse the domain from the url """ domain_match = lib.DOMAIN_REGEX.match(url) if domain_match: return domain_match.group()
python
def parse_domain(url): """ parse the domain from the url """ domain_match = lib.DOMAIN_REGEX.match(url) if domain_match: return domain_match.group()
[ "def", "parse_domain", "(", "url", ")", ":", "domain_match", "=", "lib", ".", "DOMAIN_REGEX", ".", "match", "(", "url", ")", "if", "domain_match", ":", "return", "domain_match", ".", "group", "(", ")" ]
parse the domain from the url
[ "parse", "the", "domain", "from", "the", "url" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/install.py#L200-L204
38,160
toumorokoshi/sprinter
sprinter/install.py
get_credentials
def get_credentials(options, environment): """ Get credentials or prompt for them from options """ if options['--username'] or options['--auth']: if not options['--username']: options['<username>'] = lib.prompt("Please enter the username for %s..." % environment) if not options['--pa...
python
def get_credentials(options, environment): """ Get credentials or prompt for them from options """ if options['--username'] or options['--auth']: if not options['--username']: options['<username>'] = lib.prompt("Please enter the username for %s..." % environment) if not options['--pa...
[ "def", "get_credentials", "(", "options", ",", "environment", ")", ":", "if", "options", "[", "'--username'", "]", "or", "options", "[", "'--auth'", "]", ":", "if", "not", "options", "[", "'--username'", "]", ":", "options", "[", "'<username>'", "]", "=", ...
Get credentials or prompt for them from options
[ "Get", "credentials", "or", "prompt", "for", "them", "from", "options" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/install.py#L207-L214
38,161
NiklasRosenstein-Python/nr-deprecated
nr/tundras/field.py
Field.full_name
def full_name(self): """ The full name of the field. This is the field's entities name concatenated with the field's name. If the field is unnamed or not bound to an entity, the result respectively contains None. """ entity = self.entity.__name__ if self.entity is not None else None name = ...
python
def full_name(self): """ The full name of the field. This is the field's entities name concatenated with the field's name. If the field is unnamed or not bound to an entity, the result respectively contains None. """ entity = self.entity.__name__ if self.entity is not None else None name = ...
[ "def", "full_name", "(", "self", ")", ":", "entity", "=", "self", ".", "entity", ".", "__name__", "if", "self", ".", "entity", "is", "not", "None", "else", "None", "name", "=", "self", ".", "name", "if", "self", ".", "name", "is", "not", "None", "e...
The full name of the field. This is the field's entities name concatenated with the field's name. If the field is unnamed or not bound to an entity, the result respectively contains None.
[ "The", "full", "name", "of", "the", "field", ".", "This", "is", "the", "field", "s", "entities", "name", "concatenated", "with", "the", "field", "s", "name", ".", "If", "the", "field", "is", "unnamed", "or", "not", "bound", "to", "an", "entity", "the",...
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/tundras/field.py#L140-L156
38,162
NiklasRosenstein-Python/nr-deprecated
nr/tundras/field.py
Field.type_name
def type_name(self): """ Returns the full type identifier of the field. """ res = self.type.__name__ if self.type.__module__ not in ('__builtin__', 'builtins'): res = self.type.__module__ + '.' + res return res
python
def type_name(self): """ Returns the full type identifier of the field. """ res = self.type.__name__ if self.type.__module__ not in ('__builtin__', 'builtins'): res = self.type.__module__ + '.' + res return res
[ "def", "type_name", "(", "self", ")", ":", "res", "=", "self", ".", "type", ".", "__name__", "if", "self", ".", "type", ".", "__module__", "not", "in", "(", "'__builtin__'", ",", "'builtins'", ")", ":", "res", "=", "self", ".", "type", ".", "__module...
Returns the full type identifier of the field.
[ "Returns", "the", "full", "type", "identifier", "of", "the", "field", "." ]
f9f8b89ea1b084841a8ab65784eaf68852686b2a
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/tundras/field.py#L159-L167
38,163
toumorokoshi/sprinter
sprinter/lib/module.py
get_subclass_from_module
def get_subclass_from_module(module, parent_class): """ Get a subclass of parent_class from the module at module get_subclass_from_module performs reflection to find the first class that extends the parent_class in the module path, and returns it. """ try: r = __recursive_import(module)...
python
def get_subclass_from_module(module, parent_class): """ Get a subclass of parent_class from the module at module get_subclass_from_module performs reflection to find the first class that extends the parent_class in the module path, and returns it. """ try: r = __recursive_import(module)...
[ "def", "get_subclass_from_module", "(", "module", ",", "parent_class", ")", ":", "try", ":", "r", "=", "__recursive_import", "(", "module", ")", "member_dict", "=", "dict", "(", "inspect", ".", "getmembers", "(", "r", ")", ")", "sprinter_class", "=", "parent...
Get a subclass of parent_class from the module at module get_subclass_from_module performs reflection to find the first class that extends the parent_class in the module path, and returns it.
[ "Get", "a", "subclass", "of", "parent_class", "from", "the", "module", "at", "module" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/lib/module.py#L9-L29
38,164
toumorokoshi/sprinter
sprinter/lib/module.py
__recursive_import
def __recursive_import(module_name): """ Recursively looks for and imports the names, returning the module desired >>> __recursive_import("sprinter.formula.unpack") # doctest: +ELLIPSIS <module 'unpack' from '...'> currently module with relative imports don't work. """ names = module_n...
python
def __recursive_import(module_name): """ Recursively looks for and imports the names, returning the module desired >>> __recursive_import("sprinter.formula.unpack") # doctest: +ELLIPSIS <module 'unpack' from '...'> currently module with relative imports don't work. """ names = module_n...
[ "def", "__recursive_import", "(", "module_name", ")", ":", "names", "=", "module_name", ".", "split", "(", "\".\"", ")", "path", "=", "None", "module", "=", "None", "while", "len", "(", "names", ")", ">", "0", ":", "if", "module", ":", "path", "=", "...
Recursively looks for and imports the names, returning the module desired >>> __recursive_import("sprinter.formula.unpack") # doctest: +ELLIPSIS <module 'unpack' from '...'> currently module with relative imports don't work.
[ "Recursively", "looks", "for", "and", "imports", "the", "names", "returning", "the", "module", "desired" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/lib/module.py#L32-L51
38,165
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
err_exit
def err_exit(msg, rc=1): """Print msg to stderr and exit with rc. """ print(msg, file=sys.stderr) sys.exit(rc)
python
def err_exit(msg, rc=1): """Print msg to stderr and exit with rc. """ print(msg, file=sys.stderr) sys.exit(rc)
[ "def", "err_exit", "(", "msg", ",", "rc", "=", "1", ")", ":", "print", "(", "msg", ",", "file", "=", "sys", ".", "stderr", ")", "sys", ".", "exit", "(", "rc", ")" ]
Print msg to stderr and exit with rc.
[ "Print", "msg", "to", "stderr", "and", "exit", "with", "rc", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L195-L199
38,166
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.read_file
def read_file(self, infile): """Read a reST file into a string. """ try: with open(infile, 'rt') as file: return file.read() except UnicodeDecodeError as e: err_exit('Error reading %s: %s' % (infile, e)) except (IOError, OSError) as e: ...
python
def read_file(self, infile): """Read a reST file into a string. """ try: with open(infile, 'rt') as file: return file.read() except UnicodeDecodeError as e: err_exit('Error reading %s: %s' % (infile, e)) except (IOError, OSError) as e: ...
[ "def", "read_file", "(", "self", ",", "infile", ")", ":", "try", ":", "with", "open", "(", "infile", ",", "'rt'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", "except", "UnicodeDecodeError", "as", "e", ":", "err_exit", "(", "'Erro...
Read a reST file into a string.
[ "Read", "a", "reST", "file", "into", "a", "string", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L294-L303
38,167
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.write_file
def write_file(self, html, outfile): """Write an HTML string to a file. """ try: with open(outfile, 'wt') as file: file.write(html) except (IOError, OSError) as e: err_exit('Error writing %s: %s' % (outfile, e.strerror or e))
python
def write_file(self, html, outfile): """Write an HTML string to a file. """ try: with open(outfile, 'wt') as file: file.write(html) except (IOError, OSError) as e: err_exit('Error writing %s: %s' % (outfile, e.strerror or e))
[ "def", "write_file", "(", "self", ",", "html", ",", "outfile", ")", ":", "try", ":", "with", "open", "(", "outfile", ",", "'wt'", ")", "as", "file", ":", "file", ".", "write", "(", "html", ")", "except", "(", "IOError", ",", "OSError", ")", "as", ...
Write an HTML string to a file.
[ "Write", "an", "HTML", "string", "to", "a", "file", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L305-L312
38,168
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.convert_string
def convert_string(self, rest): """Convert a reST string to an HTML string. """ try: html = publish_string(rest, writer_name='html') except SystemExit as e: err_exit('HTML conversion failed with error: %s' % e.code) else: if sys.version_info[0]...
python
def convert_string(self, rest): """Convert a reST string to an HTML string. """ try: html = publish_string(rest, writer_name='html') except SystemExit as e: err_exit('HTML conversion failed with error: %s' % e.code) else: if sys.version_info[0]...
[ "def", "convert_string", "(", "self", ",", "rest", ")", ":", "try", ":", "html", "=", "publish_string", "(", "rest", ",", "writer_name", "=", "'html'", ")", "except", "SystemExit", "as", "e", ":", "err_exit", "(", "'HTML conversion failed with error: %s'", "%"...
Convert a reST string to an HTML string.
[ "Convert", "a", "reST", "string", "to", "an", "HTML", "string", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L314-L324
38,169
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.apply_styles
def apply_styles(self, html, styles): """Insert style information into the HTML string. """ index = html.find('</head>') if index >= 0: return ''.join((html[:index], styles, html[index:])) return html
python
def apply_styles(self, html, styles): """Insert style information into the HTML string. """ index = html.find('</head>') if index >= 0: return ''.join((html[:index], styles, html[index:])) return html
[ "def", "apply_styles", "(", "self", ",", "html", ",", "styles", ")", ":", "index", "=", "html", ".", "find", "(", "'</head>'", ")", "if", "index", ">=", "0", ":", "return", "''", ".", "join", "(", "(", "html", "[", ":", "index", "]", ",", "styles...
Insert style information into the HTML string.
[ "Insert", "style", "information", "into", "the", "HTML", "string", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L333-L339
38,170
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.publish_string
def publish_string(self, rest, outfile, styles=''): """Render a reST string as HTML. """ html = self.convert_string(rest) html = self.strip_xml_header(html) html = self.apply_styles(html, styles) self.write_file(html, outfile) return outfile
python
def publish_string(self, rest, outfile, styles=''): """Render a reST string as HTML. """ html = self.convert_string(rest) html = self.strip_xml_header(html) html = self.apply_styles(html, styles) self.write_file(html, outfile) return outfile
[ "def", "publish_string", "(", "self", ",", "rest", ",", "outfile", ",", "styles", "=", "''", ")", ":", "html", "=", "self", ".", "convert_string", "(", "rest", ")", "html", "=", "self", ".", "strip_xml_header", "(", "html", ")", "html", "=", "self", ...
Render a reST string as HTML.
[ "Render", "a", "reST", "string", "as", "HTML", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L341-L348
38,171
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Docutils.publish_file
def publish_file(self, infile, outfile, styles=''): """Render a reST file as HTML. """ rest = self.read_file(infile) return self.publish_string(rest, outfile, styles)
python
def publish_file(self, infile, outfile, styles=''): """Render a reST file as HTML. """ rest = self.read_file(infile) return self.publish_string(rest, outfile, styles)
[ "def", "publish_file", "(", "self", ",", "infile", ",", "outfile", ",", "styles", "=", "''", ")", ":", "rest", "=", "self", ".", "read_file", "(", "infile", ")", "return", "self", ".", "publish_string", "(", "rest", ",", "outfile", ",", "styles", ")" ]
Render a reST file as HTML.
[ "Render", "a", "reST", "file", "as", "HTML", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L350-L354
38,172
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Defaults.upgrade
def upgrade(self): """Upgrade the config file. """ warn('Upgrading ' + self.filename) if self.backup_config(self.filename): return self.write_default_config(self.filename) return False
python
def upgrade(self): """Upgrade the config file. """ warn('Upgrading ' + self.filename) if self.backup_config(self.filename): return self.write_default_config(self.filename) return False
[ "def", "upgrade", "(", "self", ")", ":", "warn", "(", "'Upgrading '", "+", "self", ".", "filename", ")", "if", "self", ".", "backup_config", "(", "self", ".", "filename", ")", ":", "return", "self", ".", "write_default_config", "(", "self", ".", "filenam...
Upgrade the config file.
[ "Upgrade", "the", "config", "file", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L389-L395
38,173
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Defaults.backup_config
def backup_config(self, filename): """Backup the current config file. """ backup_name = filename + '-' + self.version warn('Moving current configuration to ' + backup_name) try: shutil.copy2(filename, backup_name) return True except (IOError, OSErr...
python
def backup_config(self, filename): """Backup the current config file. """ backup_name = filename + '-' + self.version warn('Moving current configuration to ' + backup_name) try: shutil.copy2(filename, backup_name) return True except (IOError, OSErr...
[ "def", "backup_config", "(", "self", ",", "filename", ")", ":", "backup_name", "=", "filename", "+", "'-'", "+", "self", ".", "version", "warn", "(", "'Moving current configuration to '", "+", "backup_name", ")", "try", ":", "shutil", ".", "copy2", "(", "fil...
Backup the current config file.
[ "Backup", "the", "current", "config", "file", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L397-L407
38,174
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
Defaults.write_default_config
def write_default_config(self, filename): """Write the default config file. """ try: with open(filename, 'wt') as file: file.write(DEFAULT_CONFIG) return True except (IOError, OSError) as e: print('Error writing %s: %s' % (filename, e.s...
python
def write_default_config(self, filename): """Write the default config file. """ try: with open(filename, 'wt') as file: file.write(DEFAULT_CONFIG) return True except (IOError, OSError) as e: print('Error writing %s: %s' % (filename, e.s...
[ "def", "write_default_config", "(", "self", ",", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ",", "'wt'", ")", "as", "file", ":", "file", ".", "write", "(", "DEFAULT_CONFIG", ")", "return", "True", "except", "(", "IOError", ",", ...
Write the default config file.
[ "Write", "the", "default", "config", "file", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L409-L418
38,175
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.reset_defaults
def reset_defaults(self, config_file): """Reset defaults. """ if not exists(config_file): err_exit('No such file: %(config_file)s' % locals()) if not isfile(config_file): err_exit('Not a file: %(config_file)s' % locals()) if not os.access(config_file, os.R...
python
def reset_defaults(self, config_file): """Reset defaults. """ if not exists(config_file): err_exit('No such file: %(config_file)s' % locals()) if not isfile(config_file): err_exit('Not a file: %(config_file)s' % locals()) if not os.access(config_file, os.R...
[ "def", "reset_defaults", "(", "self", ",", "config_file", ")", ":", "if", "not", "exists", "(", "config_file", ")", ":", "err_exit", "(", "'No such file: %(config_file)s'", "%", "locals", "(", ")", ")", "if", "not", "isfile", "(", "config_file", ")", ":", ...
Reset defaults.
[ "Reset", "defaults", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L440-L449
38,176
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.write_defaults
def write_defaults(self): """Create default config file and reload. """ self.defaults.write() self.reset_defaults(self.defaults.filename)
python
def write_defaults(self): """Create default config file and reload. """ self.defaults.write() self.reset_defaults(self.defaults.filename)
[ "def", "write_defaults", "(", "self", ")", ":", "self", ".", "defaults", ".", "write", "(", ")", "self", ".", "reset_defaults", "(", "self", ".", "defaults", ".", "filename", ")" ]
Create default config file and reload.
[ "Create", "default", "config", "file", "and", "reload", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L451-L455
38,177
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.upgrade_defaults
def upgrade_defaults(self): """Upgrade config file and reload. """ self.defaults.upgrade() self.reset_defaults(self.defaults.filename)
python
def upgrade_defaults(self): """Upgrade config file and reload. """ self.defaults.upgrade() self.reset_defaults(self.defaults.filename)
[ "def", "upgrade_defaults", "(", "self", ")", ":", "self", ".", "defaults", ".", "upgrade", "(", ")", "self", ".", "reset_defaults", "(", "self", ".", "defaults", ".", "filename", ")" ]
Upgrade config file and reload.
[ "Upgrade", "config", "file", "and", "reload", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L457-L461
38,178
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.list_styles
def list_styles(self): """Print available styles and exit. """ known = sorted(self.defaults.known_styles) if not known: err_exit('No styles', 0) for style in known: if style == self.defaults.default_style: print(style, '(default)') ...
python
def list_styles(self): """Print available styles and exit. """ known = sorted(self.defaults.known_styles) if not known: err_exit('No styles', 0) for style in known: if style == self.defaults.default_style: print(style, '(default)') ...
[ "def", "list_styles", "(", "self", ")", ":", "known", "=", "sorted", "(", "self", ".", "defaults", ".", "known_styles", ")", "if", "not", "known", ":", "err_exit", "(", "'No styles'", ",", "0", ")", "for", "style", "in", "known", ":", "if", "style", ...
Print available styles and exit.
[ "Print", "available", "styles", "and", "exit", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L509-L520
38,179
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.render_file
def render_file(self, filename): """Convert a reST file to HTML. """ dirname, basename = split(filename) with changedir(dirname): infile = abspath(basename) outfile = abspath('.%s.html' % basename) self.docutils.publish_file(infile, outfile, self.style...
python
def render_file(self, filename): """Convert a reST file to HTML. """ dirname, basename = split(filename) with changedir(dirname): infile = abspath(basename) outfile = abspath('.%s.html' % basename) self.docutils.publish_file(infile, outfile, self.style...
[ "def", "render_file", "(", "self", ",", "filename", ")", ":", "dirname", ",", "basename", "=", "split", "(", "filename", ")", "with", "changedir", "(", "dirname", ")", ":", "infile", "=", "abspath", "(", "basename", ")", "outfile", "=", "abspath", "(", ...
Convert a reST file to HTML.
[ "Convert", "a", "reST", "file", "to", "HTML", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L522-L530
38,180
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.render_long_description
def render_long_description(self, dirname): """Convert a package's long description to HTML. """ with changedir(dirname): self.setuptools.check_valid_package() long_description = self.setuptools.get_long_description() outfile = abspath('.long-description.html'...
python
def render_long_description(self, dirname): """Convert a package's long description to HTML. """ with changedir(dirname): self.setuptools.check_valid_package() long_description = self.setuptools.get_long_description() outfile = abspath('.long-description.html'...
[ "def", "render_long_description", "(", "self", ",", "dirname", ")", ":", "with", "changedir", "(", "dirname", ")", ":", "self", ".", "setuptools", ".", "check_valid_package", "(", ")", "long_description", "=", "self", ".", "setuptools", ".", "get_long_descriptio...
Convert a package's long description to HTML.
[ "Convert", "a", "package", "s", "long", "description", "to", "HTML", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L532-L540
38,181
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.open_in_browser
def open_in_browser(self, outfile): """Open the given HTML file in a browser. """ if self.browser == 'default': webbrowser.open('file://%s' % outfile) else: browser = webbrowser.get(self.browser) browser.open('file://%s' % outfile)
python
def open_in_browser(self, outfile): """Open the given HTML file in a browser. """ if self.browser == 'default': webbrowser.open('file://%s' % outfile) else: browser = webbrowser.get(self.browser) browser.open('file://%s' % outfile)
[ "def", "open_in_browser", "(", "self", ",", "outfile", ")", ":", "if", "self", ".", "browser", "==", "'default'", ":", "webbrowser", ".", "open", "(", "'file://%s'", "%", "outfile", ")", "else", ":", "browser", "=", "webbrowser", ".", "get", "(", "self",...
Open the given HTML file in a browser.
[ "Open", "the", "given", "HTML", "file", "in", "a", "browser", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L542-L549
38,182
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
DocumentationViewer.run
def run(self): """Render and display Python package documentation. """ os.environ['JARN_RUN'] = '1' self.python.check_valid_python() args = self.parse_options(self.args) if args: arg = args[0] else: arg = os.curdir if arg: ...
python
def run(self): """Render and display Python package documentation. """ os.environ['JARN_RUN'] = '1' self.python.check_valid_python() args = self.parse_options(self.args) if args: arg = args[0] else: arg = os.curdir if arg: ...
[ "def", "run", "(", "self", ")", ":", "os", ".", "environ", "[", "'JARN_RUN'", "]", "=", "'1'", "self", ".", "python", ".", "check_valid_python", "(", ")", "args", "=", "self", ".", "parse_options", "(", "self", ".", "args", ")", "if", "args", ":", ...
Render and display Python package documentation.
[ "Render", "and", "display", "Python", "package", "documentation", "." ]
59ae82fd1658889c41096c1d8c08dcb1047dc349
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L551-L572
38,183
bryanwweber/thermohw
thermohw/extract_attachments.py
ExtractAttachmentsPreprocessor.preprocess_cell
def preprocess_cell( self, cell: "NotebookNode", resources: dict, cell_index: int ) -> Tuple["NotebookNode", dict]: """Apply a transformation on each cell. Parameters ---------- cell : NotebookNode cell Notebook cell being processed resources : dictionary...
python
def preprocess_cell( self, cell: "NotebookNode", resources: dict, cell_index: int ) -> Tuple["NotebookNode", dict]: """Apply a transformation on each cell. Parameters ---------- cell : NotebookNode cell Notebook cell being processed resources : dictionary...
[ "def", "preprocess_cell", "(", "self", ",", "cell", ":", "\"NotebookNode\"", ",", "resources", ":", "dict", ",", "cell_index", ":", "int", ")", "->", "Tuple", "[", "\"NotebookNode\"", ",", "dict", "]", ":", "# Get files directory if it has been specified", "output...
Apply a transformation on each cell. Parameters ---------- cell : NotebookNode cell Notebook cell being processed resources : dictionary Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine...
[ "Apply", "a", "transformation", "on", "each", "cell", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/extract_attachments.py#L98-L161
38,184
bryanwweber/thermohw
thermohw/utils.py
combine_pdf_as_bytes
def combine_pdf_as_bytes(pdfs: List[BytesIO]) -> bytes: """Combine PDFs and return a byte-string with the result. Arguments --------- pdfs A list of BytesIO representations of PDFs """ writer = PdfWriter() for pdf in pdfs: writer.addpages(PdfReader(pdf).pages) bio = Byt...
python
def combine_pdf_as_bytes(pdfs: List[BytesIO]) -> bytes: """Combine PDFs and return a byte-string with the result. Arguments --------- pdfs A list of BytesIO representations of PDFs """ writer = PdfWriter() for pdf in pdfs: writer.addpages(PdfReader(pdf).pages) bio = Byt...
[ "def", "combine_pdf_as_bytes", "(", "pdfs", ":", "List", "[", "BytesIO", "]", ")", "->", "bytes", ":", "writer", "=", "PdfWriter", "(", ")", "for", "pdf", "in", "pdfs", ":", "writer", ".", "addpages", "(", "PdfReader", "(", "pdf", ")", ".", "pages", ...
Combine PDFs and return a byte-string with the result. Arguments --------- pdfs A list of BytesIO representations of PDFs
[ "Combine", "PDFs", "and", "return", "a", "byte", "-", "string", "with", "the", "result", "." ]
b6be276c14f8adf6ae23f5498065de74f868ccaa
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/utils.py#L13-L30
38,185
iloob/python-periods
periods/period.py
Period.split
def split(self, granularity_after_split, exclude_partial=True): """ Split a period into a given granularity. Optionally include partial periods at the start and end of the period. """ if granularity_after_split == Granularity.DAY: return self.get_days() elif...
python
def split(self, granularity_after_split, exclude_partial=True): """ Split a period into a given granularity. Optionally include partial periods at the start and end of the period. """ if granularity_after_split == Granularity.DAY: return self.get_days() elif...
[ "def", "split", "(", "self", ",", "granularity_after_split", ",", "exclude_partial", "=", "True", ")", ":", "if", "granularity_after_split", "==", "Granularity", ".", "DAY", ":", "return", "self", ".", "get_days", "(", ")", "elif", "granularity_after_split", "==...
Split a period into a given granularity. Optionally include partial periods at the start and end of the period.
[ "Split", "a", "period", "into", "a", "given", "granularity", ".", "Optionally", "include", "partial", "periods", "at", "the", "start", "and", "end", "of", "the", "period", "." ]
8988373522907d72c0ee5896c2ffbb573a8500d9
https://github.com/iloob/python-periods/blob/8988373522907d72c0ee5896c2ffbb573a8500d9/periods/period.py#L80-L105
38,186
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/calibrate/impedance.py
apply_calibration
def apply_calibration(df, calibration_df, calibration): ''' Apply calibration values from `fit_fb_calibration` result to `calibration` object. ''' from dmf_control_board_firmware import FeedbackResults for i, (fb_resistor, R_fb, C_fb) in calibration_df[['fb_resistor', 'R_fb', 'C_fb']].iterrows(...
python
def apply_calibration(df, calibration_df, calibration): ''' Apply calibration values from `fit_fb_calibration` result to `calibration` object. ''' from dmf_control_board_firmware import FeedbackResults for i, (fb_resistor, R_fb, C_fb) in calibration_df[['fb_resistor', 'R_fb', 'C_fb']].iterrows(...
[ "def", "apply_calibration", "(", "df", ",", "calibration_df", ",", "calibration", ")", ":", "from", "dmf_control_board_firmware", "import", "FeedbackResults", "for", "i", ",", "(", "fb_resistor", ",", "R_fb", ",", "C_fb", ")", "in", "calibration_df", "[", "[", ...
Apply calibration values from `fit_fb_calibration` result to `calibration` object.
[ "Apply", "calibration", "values", "from", "fit_fb_calibration", "result", "to", "calibration", "object", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/impedance.py#L302-L323
38,187
jaraco/rst.linker
rst/linker.py
config_dict
def config_dict(config): """ Given a Sphinx config object, return a dictionary of config values. """ return dict( (key, getattr(config, key)) for key in config.values )
python
def config_dict(config): """ Given a Sphinx config object, return a dictionary of config values. """ return dict( (key, getattr(config, key)) for key in config.values )
[ "def", "config_dict", "(", "config", ")", ":", "return", "dict", "(", "(", "key", ",", "getattr", "(", "config", ",", "key", ")", ")", "for", "key", "in", "config", ".", "values", ")" ]
Given a Sphinx config object, return a dictionary of config values.
[ "Given", "a", "Sphinx", "config", "object", "return", "a", "dictionary", "of", "config", "values", "." ]
5d0ff09756c325c46c471c217bdefcfd11ce1de4
https://github.com/jaraco/rst.linker/blob/5d0ff09756c325c46c471c217bdefcfd11ce1de4/rst/linker.py#L191-L199
38,188
jaraco/rst.linker
rst/linker.py
Repl.from_defn
def from_defn(cls, defn): "Return the first Repl subclass that works with this" instances = (subcl(defn) for subcl in cls.__subclasses__()) return next(filter(None, instances))
python
def from_defn(cls, defn): "Return the first Repl subclass that works with this" instances = (subcl(defn) for subcl in cls.__subclasses__()) return next(filter(None, instances))
[ "def", "from_defn", "(", "cls", ",", "defn", ")", ":", "instances", "=", "(", "subcl", "(", "defn", ")", "for", "subcl", "in", "cls", ".", "__subclasses__", "(", ")", ")", "return", "next", "(", "filter", "(", "None", ",", "instances", ")", ")" ]
Return the first Repl subclass that works with this
[ "Return", "the", "first", "Repl", "subclass", "that", "works", "with", "this" ]
5d0ff09756c325c46c471c217bdefcfd11ce1de4
https://github.com/jaraco/rst.linker/blob/5d0ff09756c325c46c471c217bdefcfd11ce1de4/rst/linker.py#L22-L25
38,189
Chilipp/psy-simple
psy_simple/widgets/colors.py
ColormapDialog.show_colormap
def show_colormap(cls, names=[], N=10, show=True, *args, **kwargs): """Show a colormap dialog Parameters ---------- %(show_colormaps.parameters.no_use_qt)s""" names = safe_list(names) obj = cls(names, N, *args, **kwargs) vbox = obj.layout() buttons = QDia...
python
def show_colormap(cls, names=[], N=10, show=True, *args, **kwargs): """Show a colormap dialog Parameters ---------- %(show_colormaps.parameters.no_use_qt)s""" names = safe_list(names) obj = cls(names, N, *args, **kwargs) vbox = obj.layout() buttons = QDia...
[ "def", "show_colormap", "(", "cls", ",", "names", "=", "[", "]", ",", "N", "=", "10", ",", "show", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "names", "=", "safe_list", "(", "names", ")", "obj", "=", "cls", "(", "names", ...
Show a colormap dialog Parameters ---------- %(show_colormaps.parameters.no_use_qt)s
[ "Show", "a", "colormap", "dialog" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/widgets/colors.py#L221-L235
38,190
cwoebker/pen
pen/core.py
cmd_list
def cmd_list(args): """List all element in pen""" for penlist in penStore.data: puts(penlist + " (" + str(len(penStore.data[penlist])) + ")")
python
def cmd_list(args): """List all element in pen""" for penlist in penStore.data: puts(penlist + " (" + str(len(penStore.data[penlist])) + ")")
[ "def", "cmd_list", "(", "args", ")", ":", "for", "penlist", "in", "penStore", ".", "data", ":", "puts", "(", "penlist", "+", "\" (\"", "+", "str", "(", "len", "(", "penStore", ".", "data", "[", "penlist", "]", ")", ")", "+", "\")\"", ")" ]
List all element in pen
[ "List", "all", "element", "in", "pen" ]
996dfcdc018f2fc14a376835a2622fb4a7230a2f
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/core.py#L32-L35
38,191
cwoebker/pen
pen/core.py
cmd_all
def cmd_all(args): """List everything recursively""" for penlist in penStore.data: puts(penlist) with indent(4, ' -'): for penfile in penStore.data[penlist]: puts(penfile)
python
def cmd_all(args): """List everything recursively""" for penlist in penStore.data: puts(penlist) with indent(4, ' -'): for penfile in penStore.data[penlist]: puts(penfile)
[ "def", "cmd_all", "(", "args", ")", ":", "for", "penlist", "in", "penStore", ".", "data", ":", "puts", "(", "penlist", ")", "with", "indent", "(", "4", ",", "' -'", ")", ":", "for", "penfile", "in", "penStore", ".", "data", "[", "penlist", "]", ":...
List everything recursively
[ "List", "everything", "recursively" ]
996dfcdc018f2fc14a376835a2622fb4a7230a2f
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/core.py#L39-L45
38,192
cwoebker/pen
pen/core.py
cmd_create
def cmd_create(args): """Creates a list""" name = args.get(0) if name: penStore.createList(name) else: puts("not valid")
python
def cmd_create(args): """Creates a list""" name = args.get(0) if name: penStore.createList(name) else: puts("not valid")
[ "def", "cmd_create", "(", "args", ")", ":", "name", "=", "args", ".", "get", "(", "0", ")", "if", "name", ":", "penStore", ".", "createList", "(", "name", ")", "else", ":", "puts", "(", "\"not valid\"", ")" ]
Creates a list
[ "Creates", "a", "list" ]
996dfcdc018f2fc14a376835a2622fb4a7230a2f
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/core.py#L49-L55
38,193
cwoebker/pen
pen/core.py
cmd_touch_note
def cmd_touch_note(args): """Create a note""" major = args.get(0) minor = args.get(1) if major in penStore.data: if minor is None: # show items in list for note in penStore.data[major]: puts(note) elif minor in penStore.data[major]: penStore.openN...
python
def cmd_touch_note(args): """Create a note""" major = args.get(0) minor = args.get(1) if major in penStore.data: if minor is None: # show items in list for note in penStore.data[major]: puts(note) elif minor in penStore.data[major]: penStore.openN...
[ "def", "cmd_touch_note", "(", "args", ")", ":", "major", "=", "args", ".", "get", "(", "0", ")", "minor", "=", "args", ".", "get", "(", "1", ")", "if", "major", "in", "penStore", ".", "data", ":", "if", "minor", "is", "None", ":", "# show items in ...
Create a note
[ "Create", "a", "note" ]
996dfcdc018f2fc14a376835a2622fb4a7230a2f
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/core.py#L58-L72
38,194
cwoebker/pen
pen/core.py
cmd_delete
def cmd_delete(args): """Deletes a node""" major = args.get(0) minor = args.get(1) if major is not None: if major in penStore.data: if minor is None: if len(penStore.data[major]) > 0: if raw_input("are you sure (y/n)? ") not in ['y', 'Y', 'yes', 'Y...
python
def cmd_delete(args): """Deletes a node""" major = args.get(0) minor = args.get(1) if major is not None: if major in penStore.data: if minor is None: if len(penStore.data[major]) > 0: if raw_input("are you sure (y/n)? ") not in ['y', 'Y', 'yes', 'Y...
[ "def", "cmd_delete", "(", "args", ")", ":", "major", "=", "args", ".", "get", "(", "0", ")", "minor", "=", "args", ".", "get", "(", "1", ")", "if", "major", "is", "not", "None", ":", "if", "major", "in", "penStore", ".", "data", ":", "if", "min...
Deletes a node
[ "Deletes", "a", "node" ]
996dfcdc018f2fc14a376835a2622fb4a7230a2f
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/core.py#L76-L101
38,195
uw-it-aca/uw-restclients-django-utils
rc_django/decorators.py
restclient_admin_required
def restclient_admin_required(view_func): """ View decorator that checks whether the user is permitted to view proxy restclients. Calls login_required in case the user is not authenticated. """ def wrapper(request, *args, **kwargs): template = 'access_denied.html' if hasattr(settings...
python
def restclient_admin_required(view_func): """ View decorator that checks whether the user is permitted to view proxy restclients. Calls login_required in case the user is not authenticated. """ def wrapper(request, *args, **kwargs): template = 'access_denied.html' if hasattr(settings...
[ "def", "restclient_admin_required", "(", "view_func", ")", ":", "def", "wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "template", "=", "'access_denied.html'", "if", "hasattr", "(", "settings", ",", "'RESTCLIENTS_ADMIN_AUTH_MODULE...
View decorator that checks whether the user is permitted to view proxy restclients. Calls login_required in case the user is not authenticated.
[ "View", "decorator", "that", "checks", "whether", "the", "user", "is", "permitted", "to", "view", "proxy", "restclients", ".", "Calls", "login_required", "in", "case", "the", "user", "is", "not", "authenticated", "." ]
7e0d3ecd3075cd4e43867f426e6add2118a814f1
https://github.com/uw-it-aca/uw-restclients-django-utils/blob/7e0d3ecd3075cd4e43867f426e6add2118a814f1/rc_django/decorators.py#L7-L29
38,196
Nagasaki45/bibo
bibo/internals.py
destination_heuristic
def destination_heuristic(data): """ A heuristic to get the folder with all other files from bib, using majority vote. """ counter = collections.Counter() for entry in data: file_field = entry['fields'].get('file') if not file_field: continue path = os.path.di...
python
def destination_heuristic(data): """ A heuristic to get the folder with all other files from bib, using majority vote. """ counter = collections.Counter() for entry in data: file_field = entry['fields'].get('file') if not file_field: continue path = os.path.di...
[ "def", "destination_heuristic", "(", "data", ")", ":", "counter", "=", "collections", ".", "Counter", "(", ")", "for", "entry", "in", "data", ":", "file_field", "=", "entry", "[", "'fields'", "]", ".", "get", "(", "'file'", ")", "if", "not", "file_field"...
A heuristic to get the folder with all other files from bib, using majority vote.
[ "A", "heuristic", "to", "get", "the", "folder", "with", "all", "other", "files", "from", "bib", "using", "majority", "vote", "." ]
e6afb28711e78eb11475834d3f9455252ac9f347
https://github.com/Nagasaki45/bibo/blob/e6afb28711e78eb11475834d3f9455252ac9f347/bibo/internals.py#L39-L73
38,197
Nagasaki45/bibo
bibo/internals.py
remove_entry
def remove_entry(data, entry): ''' Remove an entry in place. ''' file_field = entry['fields'].get('file') if file_field: try: os.remove(file_field) except IOError: click.echo('This entry\'s file was missing') data.remove(entry)
python
def remove_entry(data, entry): ''' Remove an entry in place. ''' file_field = entry['fields'].get('file') if file_field: try: os.remove(file_field) except IOError: click.echo('This entry\'s file was missing') data.remove(entry)
[ "def", "remove_entry", "(", "data", ",", "entry", ")", ":", "file_field", "=", "entry", "[", "'fields'", "]", ".", "get", "(", "'file'", ")", "if", "file_field", ":", "try", ":", "os", ".", "remove", "(", "file_field", ")", "except", "IOError", ":", ...
Remove an entry in place.
[ "Remove", "an", "entry", "in", "place", "." ]
e6afb28711e78eb11475834d3f9455252ac9f347
https://github.com/Nagasaki45/bibo/blob/e6afb28711e78eb11475834d3f9455252ac9f347/bibo/internals.py#L76-L87
38,198
Nagasaki45/bibo
bibo/internals.py
string_to_basename
def string_to_basename(s): ''' Converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. ''' s = s.strip().lower() s = re.sub(r'[^\w\s-]', '', s) return re.sub(r'[\s-]+', '-', s)
python
def string_to_basename(s): ''' Converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. ''' s = s.strip().lower() s = re.sub(r'[^\w\s-]', '', s) return re.sub(r'[\s-]+', '-', s)
[ "def", "string_to_basename", "(", "s", ")", ":", "s", "=", "s", ".", "strip", "(", ")", ".", "lower", "(", ")", "s", "=", "re", ".", "sub", "(", "r'[^\\w\\s-]'", ",", "''", ",", "s", ")", "return", "re", ".", "sub", "(", "r'[\\s-]+'", ",", "'-'...
Converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.
[ "Converts", "to", "lowercase", "removes", "non", "-", "alpha", "characters", "and", "converts", "spaces", "to", "hyphens", "." ]
e6afb28711e78eb11475834d3f9455252ac9f347
https://github.com/Nagasaki45/bibo/blob/e6afb28711e78eb11475834d3f9455252ac9f347/bibo/internals.py#L90-L97
38,199
Nagasaki45/bibo
bibo/internals.py
editor
def editor(*args, **kwargs): ''' Wrapper for `click.edit` that raises an error when None is returned. ''' result = click.edit(*args, **kwargs) if result is None: msg = 'Editor exited without saving, command aborted' raise click.ClickException(msg) return result
python
def editor(*args, **kwargs): ''' Wrapper for `click.edit` that raises an error when None is returned. ''' result = click.edit(*args, **kwargs) if result is None: msg = 'Editor exited without saving, command aborted' raise click.ClickException(msg) return result
[ "def", "editor", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "click", ".", "edit", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "result", "is", "None", ":", "msg", "=", "'Editor exited without saving, command aborted'", ...
Wrapper for `click.edit` that raises an error when None is returned.
[ "Wrapper", "for", "click", ".", "edit", "that", "raises", "an", "error", "when", "None", "is", "returned", "." ]
e6afb28711e78eb11475834d3f9455252ac9f347
https://github.com/Nagasaki45/bibo/blob/e6afb28711e78eb11475834d3f9455252ac9f347/bibo/internals.py#L111-L119