repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
gear11/pypelogs
pypein/wikip.py
depipe
def depipe(s): """Convert a string of the form DD or DD|MM or DD|MM|SS to decimal degrees""" n = 0 for i in reversed(s.split('|')): n = n / 60.0 + float(i) return n
python
def depipe(s): """Convert a string of the form DD or DD|MM or DD|MM|SS to decimal degrees""" n = 0 for i in reversed(s.split('|')): n = n / 60.0 + float(i) return n
[ "def", "depipe", "(", "s", ")", ":", "n", "=", "0", "for", "i", "in", "reversed", "(", "s", ".", "split", "(", "'|'", ")", ")", ":", "n", "=", "n", "/", "60.0", "+", "float", "(", "i", ")", "return", "n" ]
Convert a string of the form DD or DD|MM or DD|MM|SS to decimal degrees
[ "Convert", "a", "string", "of", "the", "form", "DD", "or", "DD|MM", "or", "DD|MM|SS", "to", "decimal", "degrees" ]
train
https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypein/wikip.py#L179-L184
gear11/pypelogs
pypein/wikip.py
skip_coords
def skip_coords(c): """Skip coordinate strings that are not valid""" if c == "{{coord|LAT|LONG|display=inline,title}}": # Unpopulated coord template return True if c.find("globe:") >= 0 and c.find("globe:earth") == -1: # Moon, venus, etc. return True return False
python
def skip_coords(c): """Skip coordinate strings that are not valid""" if c == "{{coord|LAT|LONG|display=inline,title}}": # Unpopulated coord template return True if c.find("globe:") >= 0 and c.find("globe:earth") == -1: # Moon, venus, etc. return True return False
[ "def", "skip_coords", "(", "c", ")", ":", "if", "c", "==", "\"{{coord|LAT|LONG|display=inline,title}}\"", ":", "# Unpopulated coord template", "return", "True", "if", "c", ".", "find", "(", "\"globe:\"", ")", ">=", "0", "and", "c", ".", "find", "(", "\"globe:e...
Skip coordinate strings that are not valid
[ "Skip", "coordinate", "strings", "that", "are", "not", "valid" ]
train
https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypein/wikip.py#L186-L192
lukaszb/porunga
porunga/procme.py
Command.iter_output
def iter_output(self, pause=0.05): """ Returns iterator of chunked output. :param cmd: command that would be passed to ``subprocess.Popen`` :param shell: Tells if process should be run within a shell. Default: False :param timeout: If command exceeds given ``timeout`` in seconds...
python
def iter_output(self, pause=0.05): """ Returns iterator of chunked output. :param cmd: command that would be passed to ``subprocess.Popen`` :param shell: Tells if process should be run within a shell. Default: False :param timeout: If command exceeds given ``timeout`` in seconds...
[ "def", "iter_output", "(", "self", ",", "pause", "=", "0.05", ")", ":", "with", "self", ".", "stream", "as", "temp", ":", "for", "chunk", "in", "self", ".", "iter_output_for_stream", "(", "temp", ",", "pause", "=", "pause", ")", ":", "yield", "chunk" ]
Returns iterator of chunked output. :param cmd: command that would be passed to ``subprocess.Popen`` :param shell: Tells if process should be run within a shell. Default: False :param timeout: If command exceeds given ``timeout`` in seconds, ``TimeoutExceeded`` exception would be raised...
[ "Returns", "iterator", "of", "chunked", "output", "." ]
train
https://github.com/lukaszb/porunga/blob/13177ff9bc654ac25cf09def6b526eb38e40e483/porunga/procme.py#L74-L93
peepall/FancyLogger
FancyLogger/__init__.py
TaskProgress.set_progress
def set_progress(self, progress): """ Defines the current progress for this progress bar in iteration units (not percent). :param progress: Current progress in iteration units regarding its total (not percent). :return: True if the progress has changed. If the given progres...
python
def set_progress(self, progress): """ Defines the current progress for this progress bar in iteration units (not percent). :param progress: Current progress in iteration units regarding its total (not percent). :return: True if the progress has changed. If the given progres...
[ "def", "set_progress", "(", "self", ",", "progress", ")", ":", "_progress", "=", "progress", "if", "_progress", ">", "self", ".", "total", ":", "_progress", "=", "self", ".", "total", "elif", "_progress", "<", "0", ":", "_progress", "=", "0", "# Stop tas...
Defines the current progress for this progress bar in iteration units (not percent). :param progress: Current progress in iteration units regarding its total (not percent). :return: True if the progress has changed. If the given progress is higher than the total or lower ...
[ "Defines", "the", "current", "progress", "for", "this", "progress", "bar", "in", "iteration", "units", "(", "not", "percent", ")", ".", ":", "param", "progress", ":", "Current", "progress", "in", "iteration", "units", "regarding", "its", "total", "(", "not",...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L70-L96
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.terminate
def terminate(self): """ Tells the logger process to exit immediately. If you do not call 'flush' method before, you may lose some messages of progresses that have not been displayed yet. This method blocks until logger process has stopped. """ self.queue.put(dill.dumps(ExitComma...
python
def terminate(self): """ Tells the logger process to exit immediately. If you do not call 'flush' method before, you may lose some messages of progresses that have not been displayed yet. This method blocks until logger process has stopped. """ self.queue.put(dill.dumps(ExitComma...
[ "def", "terminate", "(", "self", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "ExitCommand", "(", ")", ")", ")", "if", "self", ".", "process", ":", "self", ".", "process", ".", "join", "(", ")" ]
Tells the logger process to exit immediately. If you do not call 'flush' method before, you may lose some messages of progresses that have not been displayed yet. This method blocks until logger process has stopped.
[ "Tells", "the", "logger", "process", "to", "exit", "immediately", ".", "If", "you", "do", "not", "call", "flush", "method", "before", "you", "may", "lose", "some", "messages", "of", "progresses", "that", "have", "not", "been", "displayed", "yet", ".", "Thi...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L217-L225
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.set_configuration
def set_configuration(self, message_number=default_message_number, exception_number=default_exception_number, permanent_progressbar_slots=default_permanent_progressbar_slots, redraw_frequency_millis=default_redraw_fr...
python
def set_configuration(self, message_number=default_message_number, exception_number=default_exception_number, permanent_progressbar_slots=default_permanent_progressbar_slots, redraw_frequency_millis=default_redraw_fr...
[ "def", "set_configuration", "(", "self", ",", "message_number", "=", "default_message_number", ",", "exception_number", "=", "default_exception_number", ",", "permanent_progressbar_slots", "=", "default_permanent_progressbar_slots", ",", "redraw_frequency_millis", "=", "default...
Defines the current configuration of the logger. Can be used at any moment during runtime to modify the logger behavior. :param message_number: [Optional] Number of simultaneously displayed messages below progress bars. :param exception_number: [Optional] Number of simult...
[ "Defines", "the", "current", "configuration", "of", "the", "logger", ".", "Can", "be", "used", "at", "any", "moment", "during", "runtime", "to", "modify", "the", "logger", "behavior", ".", ":", "param", "message_number", ":", "[", "Optional", "]", "Number", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L227-L275
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.set_level
def set_level(self, level, console_only=False): """ Defines the logging level (from standard logging module) for log messages. :param level: Level of logging for the file logger. :param console_only: [Optional] If True then the file logger...
python
def set_level(self, level, console_only=False): """ Defines the logging level (from standard logging module) for log messages. :param level: Level of logging for the file logger. :param console_only: [Optional] If True then the file logger...
[ "def", "set_level", "(", "self", ",", "level", ",", "console_only", "=", "False", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "SetLevelCommand", "(", "level", "=", "level", ",", "console_only", "=", "console_only", ")", ...
Defines the logging level (from standard logging module) for log messages. :param level: Level of logging for the file logger. :param console_only: [Optional] If True then the file logger will not be affected.
[ "Defines", "the", "logging", "level", "(", "from", "standard", "logging", "module", ")", "for", "log", "messages", ".", ":", "param", "level", ":", "Level", "of", "logging", "for", "the", "file", "logger", ".", ":", "param", "console_only", ":", "[", "Op...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L277-L286
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.set_task_object
def set_task_object(self, task_id, task_progress_object): """ Defines a new progress bar with the given information using a TaskProgress object. :param task_id: Unique identifier for this progress bar. Will erase if already existing...
python
def set_task_object(self, task_id, task_progress_object): """ Defines a new progress bar with the given information using a TaskProgress object. :param task_id: Unique identifier for this progress bar. Will erase if already existing...
[ "def", "set_task_object", "(", "self", ",", "task_id", ",", "task_progress_object", ")", ":", "self", ".", "set_task", "(", "task_id", "=", "task_id", ",", "total", "=", "task_progress_object", ".", "total", ",", "prefix", "=", "task_progress_object", ".", "pr...
Defines a new progress bar with the given information using a TaskProgress object. :param task_id: Unique identifier for this progress bar. Will erase if already existing. :param task_progress_object: TaskProgress object holding the progress bar information.
[ "Defines", "a", "new", "progress", "bar", "with", "the", "given", "information", "using", "a", "TaskProgress", "object", ".", ":", "param", "task_id", ":", "Unique", "identifier", "for", "this", "progress", "bar", ".", "Will", "erase", "if", "already", "exis...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L288-L303
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.set_task
def set_task(self, task_id, total, prefix, suffix='', decimals=0, bar_length=60, keep_alive=False, display_time=False): """ Defines a new progress bar with the given in...
python
def set_task(self, task_id, total, prefix, suffix='', decimals=0, bar_length=60, keep_alive=False, display_time=False): """ Defines a new progress bar with the given in...
[ "def", "set_task", "(", "self", ",", "task_id", ",", "total", ",", "prefix", ",", "suffix", "=", "''", ",", "decimals", "=", "0", ",", "bar_length", "=", "60", ",", "keep_alive", "=", "False", ",", "display_time", "=", "False", ")", ":", "self", ".",...
Defines a new progress bar with the given information. :param task_id: Unique identifier for this progress bar. Will erase if already existing. :param total: The total number of iteration for this progress bar. :param prefix: The text that should be displayed at the le...
[ "Defines", "a", "new", "progress", "bar", "with", "the", "given", "information", ".", ":", "param", "task_id", ":", "Unique", "identifier", "for", "this", "progress", "bar", ".", "Will", "erase", "if", "already", "existing", ".", ":", "param", "total", ":"...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L305-L336
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.update
def update(self, task_id, progress): """ Defines the current progress for this progress bar id in iteration units (not percent). If the given id does not exist or the given progress is identical to the current, then does nothing. Logger uses a redraw rate be...
python
def update(self, task_id, progress): """ Defines the current progress for this progress bar id in iteration units (not percent). If the given id does not exist or the given progress is identical to the current, then does nothing. Logger uses a redraw rate be...
[ "def", "update", "(", "self", ",", "task_id", ",", "progress", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "UpdateProgressCommand", "(", "task_id", "=", "task_id", ",", "progress", "=", "progress", ")", ")", ")" ]
Defines the current progress for this progress bar id in iteration units (not percent). If the given id does not exist or the given progress is identical to the current, then does nothing. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress ...
[ "Defines", "the", "current", "progress", "for", "this", "progress", "bar", "id", "in", "iteration", "units", "(", "not", "percent", ")", ".", "If", "the", "given", "id", "does", "not", "exist", "or", "the", "given", "progress", "is", "identical", "to", "...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L338-L352
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.debug
def debug(self, text): """ Posts a debug message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their t...
python
def debug(self, text): """ Posts a debug message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their t...
[ "def", "debug", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "DEBUG", ")", ")", ")" ]
Posts a debug message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right time...
[ "Posts", "a", "debug", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", "...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L354-L363
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.info
def info(self, text): """ Posts an info message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their ti...
python
def info(self, text): """ Posts an info message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their ti...
[ "def", "info", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "INFO", ")", ")", ")" ]
Posts an info message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right time...
[ "Posts", "an", "info", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", "...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L365-L374
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.warning
def warning(self, text): """ Posts a warning message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but the...
python
def warning(self, text): """ Posts a warning message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but the...
[ "def", "warning", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "WARNING", ")", ")", ")" ]
Posts a warning message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right ti...
[ "Posts", "a", "warning", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L376-L385
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.error
def error(self, text): """ Posts an error message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their ...
python
def error(self, text): """ Posts an error message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their ...
[ "def", "error", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "ERROR", ")", ")", ")" ]
Posts an error message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right tim...
[ "Posts", "an", "error", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L387-L396
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.critical
def critical(self, text): """ Posts a critical message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but t...
python
def critical(self, text): """ Posts a critical message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but t...
[ "def", "critical", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "CRITICAL", ")", ")", ")" ]
Posts a critical message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right t...
[ "Posts", "a", "critical", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L398-L407
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.throw
def throw(self, stacktrace, process_title=None): """ Sends an exception to the logger so it can display it as a special message. Prevents console refresh cycles from hiding exceptions that could be thrown by processes. :param stacktrace: Stacktrace string as returned by 'traceback.f...
python
def throw(self, stacktrace, process_title=None): """ Sends an exception to the logger so it can display it as a special message. Prevents console refresh cycles from hiding exceptions that could be thrown by processes. :param stacktrace: Stacktrace string as returned by 'traceback.f...
[ "def", "throw", "(", "self", ",", "stacktrace", ",", "process_title", "=", "None", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "StacktraceCommand", "(", "pid", "=", "os", ".", "getpid", "(", ")", ",", "stacktrace", "="...
Sends an exception to the logger so it can display it as a special message. Prevents console refresh cycles from hiding exceptions that could be thrown by processes. :param stacktrace: Stacktrace string as returned by 'traceback.format_exc()' in an 'except' block. :param process_title: [O...
[ "Sends", "an", "exception", "to", "the", "logger", "so", "it", "can", "display", "it", "as", "a", "special", "message", ".", "Prevents", "console", "refresh", "cycles", "from", "hiding", "exceptions", "that", "could", "be", "thrown", "by", "processes", ".", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L409-L419
peepall/FancyLogger
FancyLogger/__init__.py
FancyLogger.progress
def progress(self, enumerable, task_progress_object=None): """ Enables the object to be used as an iterator. Each iteration will produce a progress update in the logger. :param enumerable: Collection to iterate over. :param task_progress_obj...
python
def progress(self, enumerable, task_progress_object=None): """ Enables the object to be used as an iterator. Each iteration will produce a progress update in the logger. :param enumerable: Collection to iterate over. :param task_progress_obj...
[ "def", "progress", "(", "self", ",", "enumerable", ",", "task_progress_object", "=", "None", ")", ":", "self", ".", "list", "=", "enumerable", "self", ".", "list_length", "=", "len", "(", "enumerable", ")", "self", ".", "task_id", "=", "uuid", ".", "uuid...
Enables the object to be used as an iterator. Each iteration will produce a progress update in the logger. :param enumerable: Collection to iterate over. :param task_progress_object: [Optional] TaskProgress object holding the progress bar information. :return: ...
[ "Enables", "the", "object", "to", "be", "used", "as", "an", "iterator", ".", "Each", "iteration", "will", "produce", "a", "progress", "update", "in", "the", "logger", ".", ":", "param", "enumerable", ":", "Collection", "to", "iterate", "over", ".", ":", ...
train
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L423-L449
Fuyukai/ConfigMaster
configmaster/ConfigKey.py
ConfigKey.dump
def dump(self) -> dict: """ Dumps data from the ConfigKey into a dict. :return: The keys and values from the ConfigKey encapsulated in a dict. """ d = {} for item in self.__dict__: if item in ['parsed', 'dump', 'parse_data', 'iter_list', 'safe_load']: ...
python
def dump(self) -> dict: """ Dumps data from the ConfigKey into a dict. :return: The keys and values from the ConfigKey encapsulated in a dict. """ d = {} for item in self.__dict__: if item in ['parsed', 'dump', 'parse_data', 'iter_list', 'safe_load']: ...
[ "def", "dump", "(", "self", ")", "->", "dict", ":", "d", "=", "{", "}", "for", "item", "in", "self", ".", "__dict__", ":", "if", "item", "in", "[", "'parsed'", ",", "'dump'", ",", "'parse_data'", ",", "'iter_list'", ",", "'safe_load'", "]", ":", "c...
Dumps data from the ConfigKey into a dict. :return: The keys and values from the ConfigKey encapsulated in a dict.
[ "Dumps", "data", "from", "the", "ConfigKey", "into", "a", "dict", ".", ":", "return", ":", "The", "keys", "and", "values", "from", "the", "ConfigKey", "encapsulated", "in", "a", "dict", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigKey.py#L37-L52
Fuyukai/ConfigMaster
configmaster/ConfigKey.py
ConfigKey.load_from_dict
def load_from_dict(self, data: dict, overwrite: bool=True): """ Loads key/values from dicts or list into the ConfigKey. :param data: The data object to load. This can be a dict, or a list of key/value tuples. :param overwrite: Should the ConfigKey overwrite data a...
python
def load_from_dict(self, data: dict, overwrite: bool=True): """ Loads key/values from dicts or list into the ConfigKey. :param data: The data object to load. This can be a dict, or a list of key/value tuples. :param overwrite: Should the ConfigKey overwrite data a...
[ "def", "load_from_dict", "(", "self", ",", "data", ":", "dict", ",", "overwrite", ":", "bool", "=", "True", ")", ":", "if", "data", "is", "None", "or", "data", "==", "{", "}", ":", "return", "False", "# Loop over items", "if", "isinstance", "(", "data"...
Loads key/values from dicts or list into the ConfigKey. :param data: The data object to load. This can be a dict, or a list of key/value tuples. :param overwrite: Should the ConfigKey overwrite data already in it?
[ "Loads", "key", "/", "values", "from", "dicts", "or", "list", "into", "the", "ConfigKey", ".", ":", "param", "data", ":", "The", "data", "object", "to", "load", ".", "This", "can", "be", "a", "dict", "or", "a", "list", "of", "key", "/", "value", "t...
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigKey.py#L79-L129
alkivi-sas/python-alkivi-logger
alkivi/logger/handlers.py
AlkiviEmailHandler.generate_mail
def generate_mail(self): """Generate the email as MIMEText """ # Script info msg = "Script info : \r\n" msg = msg + "%-9s: %s" % ('Script', SOURCEDIR) + "\r\n" msg = msg + "%-9s: %s" % ('User', USER) + "\r\n" msg = msg + "%-9s: %s" % ('Host', HOST) + "\r\n" ...
python
def generate_mail(self): """Generate the email as MIMEText """ # Script info msg = "Script info : \r\n" msg = msg + "%-9s: %s" % ('Script', SOURCEDIR) + "\r\n" msg = msg + "%-9s: %s" % ('User', USER) + "\r\n" msg = msg + "%-9s: %s" % ('Host', HOST) + "\r\n" ...
[ "def", "generate_mail", "(", "self", ")", ":", "# Script info", "msg", "=", "\"Script info : \\r\\n\"", "msg", "=", "msg", "+", "\"%-9s: %s\"", "%", "(", "'Script'", ",", "SOURCEDIR", ")", "+", "\"\\r\\n\"", "msg", "=", "msg", "+", "\"%-9s: %s\"", "%", "(", ...
Generate the email as MIMEText
[ "Generate", "the", "email", "as", "MIMEText" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/handlers.py#L57-L100
alkivi-sas/python-alkivi-logger
alkivi/logger/handlers.py
AlkiviEmailHandler.get_subject
def get_subject(self): """Generate the subject.""" level = logging.getLevelName(self.flush_level) message = self.current_buffer[0].split("\n")[0] message = message.split(']')[-1] return '{0} : {1}{2}'.format(level, SOURCE, message)
python
def get_subject(self): """Generate the subject.""" level = logging.getLevelName(self.flush_level) message = self.current_buffer[0].split("\n")[0] message = message.split(']')[-1] return '{0} : {1}{2}'.format(level, SOURCE, message)
[ "def", "get_subject", "(", "self", ")", ":", "level", "=", "logging", ".", "getLevelName", "(", "self", ".", "flush_level", ")", "message", "=", "self", ".", "current_buffer", "[", "0", "]", ".", "split", "(", "\"\\n\"", ")", "[", "0", "]", "message", ...
Generate the subject.
[ "Generate", "the", "subject", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/handlers.py#L102-L107
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigEntryFormatter.format_query_result
def format_query_result(self, query_result, query_path, return_type=list, preceding_depth=None): """ Formats the query result based on the return type requested. :param query_result: (dict or str or list), yaml query result :param query_path: (str, list(str)), representing query path :p...
python
def format_query_result(self, query_result, query_path, return_type=list, preceding_depth=None): """ Formats the query result based on the return type requested. :param query_result: (dict or str or list), yaml query result :param query_path: (str, list(str)), representing query path :p...
[ "def", "format_query_result", "(", "self", ",", "query_result", ",", "query_path", ",", "return_type", "=", "list", ",", "preceding_depth", "=", "None", ")", ":", "if", "type", "(", "query_result", ")", "!=", "return_type", ":", "converted_result", "=", "self"...
Formats the query result based on the return type requested. :param query_result: (dict or str or list), yaml query result :param query_path: (str, list(str)), representing query path :param return_type: type, return type of object user desires :param preceding_depth: int, the depth to ...
[ "Formats", "the", "query", "result", "based", "on", "the", "return", "type", "requested", "." ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L13-L29
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigEntryFormatter.format_with_handler
def format_with_handler(self, query_result, return_type): """ Uses the callable handler to format the query result to the desired return type :param query_result: the result value of our query :param return_type: desired return type :return: type, the query value as the return type requ...
python
def format_with_handler(self, query_result, return_type): """ Uses the callable handler to format the query result to the desired return type :param query_result: the result value of our query :param return_type: desired return type :return: type, the query value as the return type requ...
[ "def", "format_with_handler", "(", "self", ",", "query_result", ",", "return_type", ")", ":", "handler", "=", "self", ".", "get_handler", "(", "type", "(", "query_result", ")", ",", "return_type", ")", "return", "handler", ".", "format_result", "(", "query_res...
Uses the callable handler to format the query result to the desired return type :param query_result: the result value of our query :param return_type: desired return type :return: type, the query value as the return type requested
[ "Uses", "the", "callable", "handler", "to", "format", "the", "query", "result", "to", "the", "desired", "return", "type" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L31-L39
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigEntryFormatter.get_handler
def get_handler(query_result_type, return_type): """ Find the appropriate return type handler to convert the query result to the desired return type :param query_result_type: type, desired return type :param return_type: type, actual return type :return: callable, function that will han...
python
def get_handler(query_result_type, return_type): """ Find the appropriate return type handler to convert the query result to the desired return type :param query_result_type: type, desired return type :param return_type: type, actual return type :return: callable, function that will han...
[ "def", "get_handler", "(", "query_result_type", ",", "return_type", ")", ":", "try", ":", "return", "FormatterRegistry", ".", "get_by_take_and_return_type", "(", "query_result_type", ",", "return_type", ")", "except", "(", "IndexError", ",", "AttributeError", ",", "...
Find the appropriate return type handler to convert the query result to the desired return type :param query_result_type: type, desired return type :param return_type: type, actual return type :return: callable, function that will handle the conversion
[ "Find", "the", "appropriate", "return", "type", "handler", "to", "convert", "the", "query", "result", "to", "the", "desired", "return", "type" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L42-L54
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigEntryFormatter.add_preceding_dict
def add_preceding_dict(config_entry, query_path, preceding_depth): """ Adds the preceeding config keys to the config_entry to simulate the original full path to the config entry :param config_entry: object, the entry that was requested and returned from the config :param query_path: (str, list(...
python
def add_preceding_dict(config_entry, query_path, preceding_depth): """ Adds the preceeding config keys to the config_entry to simulate the original full path to the config entry :param config_entry: object, the entry that was requested and returned from the config :param query_path: (str, list(...
[ "def", "add_preceding_dict", "(", "config_entry", ",", "query_path", ",", "preceding_depth", ")", ":", "if", "preceding_depth", "is", "None", ":", "return", "config_entry", "preceding_dict", "=", "{", "query_path", "[", "-", "1", "]", ":", "config_entry", "}", ...
Adds the preceeding config keys to the config_entry to simulate the original full path to the config entry :param config_entry: object, the entry that was requested and returned from the config :param query_path: (str, list(str)), the original path to the config_entry :param preceding_depth: in...
[ "Adds", "the", "preceeding", "config", "keys", "to", "the", "config_entry", "to", "simulate", "the", "original", "full", "path", "to", "the", "config", "entry" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L57-L75
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse.resolve_config_file_path
def resolve_config_file_path(self, config_filepath): """ Determines whether given path is valid, and if so uses it. Otherwise searches both the working directory and nomenclate/core for the specified config file. :param config_filepath: str, file path or relative file name within package ...
python
def resolve_config_file_path(self, config_filepath): """ Determines whether given path is valid, and if so uses it. Otherwise searches both the working directory and nomenclate/core for the specified config file. :param config_filepath: str, file path or relative file name within package ...
[ "def", "resolve_config_file_path", "(", "self", ",", "config_filepath", ")", ":", "search_paths", "=", "[", "config_filepath", ",", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "config_...
Determines whether given path is valid, and if so uses it. Otherwise searches both the working directory and nomenclate/core for the specified config file. :param config_filepath: str, file path or relative file name within package :return: str, resolved full file path to the config file
[ "Determines", "whether", "given", "path", "is", "valid", "and", "if", "so", "uses", "it", ".", "Otherwise", "searches", "both", "the", "working", "directory", "and", "nomenclate", "/", "core", "for", "the", "specified", "config", "file", "." ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L90-L109
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse.rebuild_config_cache
def rebuild_config_cache(self, config_filepath): """ Loads from file and caches all data from the config file in the form of an OrderedDict to self.data :param config_filepath: str, the full filepath to the config file :return: bool, success status """ self.validate_config_file(...
python
def rebuild_config_cache(self, config_filepath): """ Loads from file and caches all data from the config file in the form of an OrderedDict to self.data :param config_filepath: str, the full filepath to the config file :return: bool, success status """ self.validate_config_file(...
[ "def", "rebuild_config_cache", "(", "self", ",", "config_filepath", ")", ":", "self", ".", "validate_config_file", "(", "config_filepath", ")", "config_data", "=", "None", "try", ":", "with", "open", "(", "config_filepath", ",", "'r'", ")", "as", "f", ":", "...
Loads from file and caches all data from the config file in the form of an OrderedDict to self.data :param config_filepath: str, the full filepath to the config file :return: bool, success status
[ "Loads", "from", "file", "and", "caches", "all", "data", "from", "the", "config", "file", "in", "the", "form", "of", "an", "OrderedDict", "to", "self", ".", "data" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L111-L128
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse.get
def get(self, query_path=None, return_type=list, preceding_depth=None, throw_null_return_error=False): """ Traverses the list of query paths to find the data requested :param query_path: (list(str), str), list of query path branches or query string Default b...
python
def get(self, query_path=None, return_type=list, preceding_depth=None, throw_null_return_error=False): """ Traverses the list of query paths to find the data requested :param query_path: (list(str), str), list of query path branches or query string Default b...
[ "def", "get", "(", "self", ",", "query_path", "=", "None", ",", "return_type", "=", "list", ",", "preceding_depth", "=", "None", ",", "throw_null_return_error", "=", "False", ")", ":", "function_type_lookup", "=", "{", "str", ":", "self", ".", "_get_path_ent...
Traverses the list of query paths to find the data requested :param query_path: (list(str), str), list of query path branches or query string Default behavior: returns list(str) of possible config headers :param return_type: (list, str, dict, OrderedDict), d...
[ "Traverses", "the", "list", "of", "query", "paths", "to", "find", "the", "data", "requested" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L130-L158
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse._get_path_entry_from_string
def _get_path_entry_from_string(self, query_string, first_found=True, full_path=False): """ Parses a string to form a list of strings that represents a possible config entry header :param query_string: str, query string we are looking for :param first_found: bool, return first found entry or en...
python
def _get_path_entry_from_string(self, query_string, first_found=True, full_path=False): """ Parses a string to form a list of strings that represents a possible config entry header :param query_string: str, query string we are looking for :param first_found: bool, return first found entry or en...
[ "def", "_get_path_entry_from_string", "(", "self", ",", "query_string", ",", "first_found", "=", "True", ",", "full_path", "=", "False", ")", ":", "iter_matches", "=", "gen_dict_key_matches", "(", "query_string", ",", "self", ".", "config_file_contents", ",", "ful...
Parses a string to form a list of strings that represents a possible config entry header :param query_string: str, query string we are looking for :param first_found: bool, return first found entry or entire list :param full_path: bool, whether to return each entry with their corresponding conf...
[ "Parses", "a", "string", "to", "form", "a", "list", "of", "strings", "that", "represents", "a", "possible", "config", "entry", "header" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L160-L174
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse._get_path_entry_from_list
def _get_path_entry_from_list(self, query_path): """ Returns the config entry at query path :param query_path: list(str), config header path to follow for entry :return: (list, str, dict, OrderedDict), config entry requested :raises: exceptions.ResourceNotFoundError """ ...
python
def _get_path_entry_from_list(self, query_path): """ Returns the config entry at query path :param query_path: list(str), config header path to follow for entry :return: (list, str, dict, OrderedDict), config entry requested :raises: exceptions.ResourceNotFoundError """ ...
[ "def", "_get_path_entry_from_list", "(", "self", ",", "query_path", ")", ":", "cur_data", "=", "self", ".", "config_file_contents", "try", ":", "for", "child", "in", "query_path", ":", "cur_data", "=", "cur_data", "[", "child", "]", "return", "cur_data", "exce...
Returns the config entry at query path :param query_path: list(str), config header path to follow for entry :return: (list, str, dict, OrderedDict), config entry requested :raises: exceptions.ResourceNotFoundError
[ "Returns", "the", "config", "entry", "at", "query", "path" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L176-L190
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse._default_config
def _default_config(self, return_type): """ Generates a default instance of whatever the type requested was (in case of miss) :param return_type: type, type of object requested :return: object, instance of return_type """ if return_type == list: return [k for k in se...
python
def _default_config(self, return_type): """ Generates a default instance of whatever the type requested was (in case of miss) :param return_type: type, type of object requested :return: object, instance of return_type """ if return_type == list: return [k for k in se...
[ "def", "_default_config", "(", "self", ",", "return_type", ")", ":", "if", "return_type", "==", "list", ":", "return", "[", "k", "for", "k", "in", "self", ".", "config_file_contents", "]", "return", "return_type", "(", ")" ]
Generates a default instance of whatever the type requested was (in case of miss) :param return_type: type, type of object requested :return: object, instance of return_type
[ "Generates", "a", "default", "instance", "of", "whatever", "the", "type", "requested", "was", "(", "in", "case", "of", "miss", ")" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L192-L200
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
ConfigParse.validate_config_file
def validate_config_file(cls, config_filepath): """ Validates the filepath to the config. Detects whether it is a true YAML file + existance :param config_filepath: str, file path to the config file to query :return: None :raises: IOError """ is_file = os.path.isfile(co...
python
def validate_config_file(cls, config_filepath): """ Validates the filepath to the config. Detects whether it is a true YAML file + existance :param config_filepath: str, file path to the config file to query :return: None :raises: IOError """ is_file = os.path.isfile(co...
[ "def", "validate_config_file", "(", "cls", ",", "config_filepath", ")", ":", "is_file", "=", "os", ".", "path", ".", "isfile", "(", "config_filepath", ")", "if", "not", "is_file", "and", "os", ".", "path", ".", "isabs", "(", "config_filepath", ")", ":", ...
Validates the filepath to the config. Detects whether it is a true YAML file + existance :param config_filepath: str, file path to the config file to query :return: None :raises: IOError
[ "Validates", "the", "filepath", "to", "the", "config", ".", "Detects", "whether", "it", "is", "a", "true", "YAML", "file", "+", "existance" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L203-L220
AndresMWeber/Nomenclate
nomenclate/core/configurator.py
DictToOrderedDict.format_result
def format_result(input): """From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python """ items = list(iteritems(input)) return OrderedDict(sorted(items, key=lambda x: x[0]))
python
def format_result(input): """From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python """ items = list(iteritems(input)) return OrderedDict(sorted(items, key=lambda x: x[0]))
[ "def", "format_result", "(", "input", ")", ":", "items", "=", "list", "(", "iteritems", "(", "input", ")", ")", "return", "OrderedDict", "(", "sorted", "(", "items", ",", "key", "=", "lambda", "x", ":", "x", "[", "0", "]", ")", ")" ]
From: http://stackoverflow.com/questions/13062300/convert-a-dict-to-sorted-dict-in-python
[ "From", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "13062300", "/", "convert", "-", "a", "-", "dict", "-", "to", "-", "sorted", "-", "dict", "-", "in", "-", "python" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L293-L297
luismasuelli/python-cantrips
cantrips/features.py
Feature.import_it
def import_it(cls): """ Performs the import only once. """ if not cls in cls._FEATURES: try: cls._FEATURES[cls] = cls._import_it() except ImportError: raise cls.Error(cls._import_error_message(), cls.Error.UNSATISFIED_IMPORT_REQ) ...
python
def import_it(cls): """ Performs the import only once. """ if not cls in cls._FEATURES: try: cls._FEATURES[cls] = cls._import_it() except ImportError: raise cls.Error(cls._import_error_message(), cls.Error.UNSATISFIED_IMPORT_REQ) ...
[ "def", "import_it", "(", "cls", ")", ":", "if", "not", "cls", "in", "cls", ".", "_FEATURES", ":", "try", ":", "cls", ".", "_FEATURES", "[", "cls", "]", "=", "cls", ".", "_import_it", "(", ")", "except", "ImportError", ":", "raise", "cls", ".", "Err...
Performs the import only once.
[ "Performs", "the", "import", "only", "once", "." ]
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/features.py#L12-L21
fr33jc/bang
bang/providers/hpcloud/__init__.py
HPRedDwarf.create_db
def create_db(self, instance_name, instance_type, admin_username, admin_password, security_groups=None, db_name=None, storage_size_gb=DEFAULT_STORAGE_SIZE_GB, timeout_s=DEFAULT_TIMEOUT_S): """ Creates a database instance. This method blocks until the db insta...
python
def create_db(self, instance_name, instance_type, admin_username, admin_password, security_groups=None, db_name=None, storage_size_gb=DEFAULT_STORAGE_SIZE_GB, timeout_s=DEFAULT_TIMEOUT_S): """ Creates a database instance. This method blocks until the db insta...
[ "def", "create_db", "(", "self", ",", "instance_name", ",", "instance_type", ",", "admin_username", ",", "admin_password", ",", "security_groups", "=", "None", ",", "db_name", "=", "None", ",", "storage_size_gb", "=", "DEFAULT_STORAGE_SIZE_GB", ",", "timeout_s", "...
Creates a database instance. This method blocks until the db instance is active, or until :attr:`timeout_s` has elapsed. By default, hpcloud *assigns* an automatically-generated set of credentials for an admin user. In addition to launching the db instance, this method uses th...
[ "Creates", "a", "database", "instance", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/__init__.py#L29-L104
fr33jc/bang
bang/providers/hpcloud/__init__.py
HPCloud.authenticate
def authenticate(self): """ Authenticate against the HP Cloud Identity Service. This is the first step in any hpcloud.com session, although this method is automatically called when accessing higher-level methods/attributes. **Examples of Credentials Configuration** - B...
python
def authenticate(self): """ Authenticate against the HP Cloud Identity Service. This is the first step in any hpcloud.com session, although this method is automatically called when accessing higher-level methods/attributes. **Examples of Credentials Configuration** - B...
[ "def", "authenticate", "(", "self", ")", ":", "log", ".", "info", "(", "\"Authenticating to HP Cloud...\"", ")", "creds", "=", "self", ".", "creds", "access_key_id", "=", "creds", ".", "get", "(", "'access_key_id'", ",", "''", ")", "secret_access_key", "=", ...
Authenticate against the HP Cloud Identity Service. This is the first step in any hpcloud.com session, although this method is automatically called when accessing higher-level methods/attributes. **Examples of Credentials Configuration** - Bare minimum for authentication using HP API ...
[ "Authenticate", "against", "the", "HP", "Cloud", "Identity", "Service", ".", "This", "is", "the", "first", "step", "in", "any", "hpcloud", ".", "com", "session", "although", "this", "method", "is", "automatically", "called", "when", "accessing", "higher", "-",...
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/__init__.py#L136-L193
goldsborough/li
li/cache.py
read
def read(author, kind): """ Attempts to read the cache to fetch missing arguments. This method will attempt to find a '.license' file in the 'CACHE_DIRECTORY', to read any arguments that were not passed to the license utility. Arguments: author (str): The author passed, if any. k...
python
def read(author, kind): """ Attempts to read the cache to fetch missing arguments. This method will attempt to find a '.license' file in the 'CACHE_DIRECTORY', to read any arguments that were not passed to the license utility. Arguments: author (str): The author passed, if any. k...
[ "def", "read", "(", "author", ",", "kind", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "CACHE_PATH", ")", ":", "raise", "LicenseError", "(", "'No cache found. You must '", "'supply at least -a and -k.'", ")", "cache", "=", "read_cache", "(", ...
Attempts to read the cache to fetch missing arguments. This method will attempt to find a '.license' file in the 'CACHE_DIRECTORY', to read any arguments that were not passed to the license utility. Arguments: author (str): The author passed, if any. kind (str): The kind of license pas...
[ "Attempts", "to", "read", "the", "cache", "to", "fetch", "missing", "arguments", "." ]
train
https://github.com/goldsborough/li/blob/8ea4f8b55183aadaa96bc70cfcfcb7b198874319/li/cache.py#L26-L53
Baguage/django-auth-pubtkt
django_auth_pubtkt/auth_pubtkt.py
Authpubtkt.verify_ticket_signature
def verify_ticket_signature(self, data, sig): """Verify ticket signature. """ try: signature = base64.b64decode(sig) except TypeError as e: if hasattr(self, "debug"): print("Exception in function base64.b64decode. File %s" % (__file__)) ...
python
def verify_ticket_signature(self, data, sig): """Verify ticket signature. """ try: signature = base64.b64decode(sig) except TypeError as e: if hasattr(self, "debug"): print("Exception in function base64.b64decode. File %s" % (__file__)) ...
[ "def", "verify_ticket_signature", "(", "self", ",", "data", ",", "sig", ")", ":", "try", ":", "signature", "=", "base64", ".", "b64decode", "(", "sig", ")", "except", "TypeError", "as", "e", ":", "if", "hasattr", "(", "self", ",", "\"debug\"", ")", ":"...
Verify ticket signature.
[ "Verify", "ticket", "signature", "." ]
train
https://github.com/Baguage/django-auth-pubtkt/blob/d3f4284212ffbfdc3588929a31e36a4cc7f39786/django_auth_pubtkt/auth_pubtkt.py#L45-L73
krukas/Trionyx
trionyx/trionyx/apps.py
Config.ready
def ready(self): """Auto load Trionyx""" models_config.auto_load_configs() self.auto_load_app_modules(['layouts', 'signals']) app_menu.auto_load_model_menu() auto_register_search_models() tabs.auto_generate_missing_tabs()
python
def ready(self): """Auto load Trionyx""" models_config.auto_load_configs() self.auto_load_app_modules(['layouts', 'signals']) app_menu.auto_load_model_menu() auto_register_search_models() tabs.auto_generate_missing_tabs()
[ "def", "ready", "(", "self", ")", ":", "models_config", ".", "auto_load_configs", "(", ")", "self", ".", "auto_load_app_modules", "(", "[", "'layouts'", ",", "'signals'", "]", ")", "app_menu", ".", "auto_load_model_menu", "(", ")", "auto_register_search_models", ...
Auto load Trionyx
[ "Auto", "load", "Trionyx" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/apps.py#L36-L45
krukas/Trionyx
trionyx/trionyx/apps.py
Config.auto_load_app_modules
def auto_load_app_modules(self, modules): """Auto load app modules""" for app in apps.get_app_configs(): for module in modules: try: import_module('{}.{}'.format(app.module.__package__, module)) except ImportError: pass
python
def auto_load_app_modules(self, modules): """Auto load app modules""" for app in apps.get_app_configs(): for module in modules: try: import_module('{}.{}'.format(app.module.__package__, module)) except ImportError: pass
[ "def", "auto_load_app_modules", "(", "self", ",", "modules", ")", ":", "for", "app", "in", "apps", ".", "get_app_configs", "(", ")", ":", "for", "module", "in", "modules", ":", "try", ":", "import_module", "(", "'{}.{}'", ".", "format", "(", "app", ".", ...
Auto load app modules
[ "Auto", "load", "app", "modules" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/apps.py#L47-L54
goldsborough/li
scripts/bump.py
bump
def bump(match): """Bumps the version""" before, old_version, after = match.groups() major, minor, patch = map(int, old_version.split('.')) patch += 1 if patch == 10: patch = 0 minor += 1 if minor == 10: minor = 0 major += 1 new_version = '{0}.{1}.{2}'.format(major, minor, patch) print('{0} => {1}'....
python
def bump(match): """Bumps the version""" before, old_version, after = match.groups() major, minor, patch = map(int, old_version.split('.')) patch += 1 if patch == 10: patch = 0 minor += 1 if minor == 10: minor = 0 major += 1 new_version = '{0}.{1}.{2}'.format(major, minor, patch) print('{0} => {1}'....
[ "def", "bump", "(", "match", ")", ":", "before", ",", "old_version", ",", "after", "=", "match", ".", "groups", "(", ")", "major", ",", "minor", ",", "patch", "=", "map", "(", "int", ",", "old_version", ".", "split", "(", "'.'", ")", ")", "patch", ...
Bumps the version
[ "Bumps", "the", "version" ]
train
https://github.com/goldsborough/li/blob/8ea4f8b55183aadaa96bc70cfcfcb7b198874319/scripts/bump.py#L11-L26
mnboos/airtiler
airtiler/__init__.py
Airtiler._tiles_from_bbox
def _tiles_from_bbox(bbox, zoom_level): """ * Returns all tiles for the specified bounding box """ if isinstance(bbox, dict): point_min = Point.from_latitude_longitude(latitude=bbox['tl'], longitude=bbox['tr']) point_max = Point.from_latitude_longitude(latitude=...
python
def _tiles_from_bbox(bbox, zoom_level): """ * Returns all tiles for the specified bounding box """ if isinstance(bbox, dict): point_min = Point.from_latitude_longitude(latitude=bbox['tl'], longitude=bbox['tr']) point_max = Point.from_latitude_longitude(latitude=...
[ "def", "_tiles_from_bbox", "(", "bbox", ",", "zoom_level", ")", ":", "if", "isinstance", "(", "bbox", ",", "dict", ")", ":", "point_min", "=", "Point", ".", "from_latitude_longitude", "(", "latitude", "=", "bbox", "[", "'tl'", "]", ",", "longitude", "=", ...
* Returns all tiles for the specified bounding box
[ "*", "Returns", "all", "tiles", "for", "the", "specified", "bounding", "box" ]
train
https://github.com/mnboos/airtiler/blob/6e79cdf22c5cd8a9cfffe07b58824fc1d1027104/airtiler/__init__.py#L44-L63
mnboos/airtiler
airtiler/__init__.py
Airtiler._update_mask
def _update_mask(self, mask: np.ndarray, polygons: Iterable, separate_instances: bool = False) -> None: """ * The first polygon is the exterior ring. All others are treated as interior rings and will just invert the corresponding area of the mask. :param separate_instances: :...
python
def _update_mask(self, mask: np.ndarray, polygons: Iterable, separate_instances: bool = False) -> None: """ * The first polygon is the exterior ring. All others are treated as interior rings and will just invert the corresponding area of the mask. :param separate_instances: :...
[ "def", "_update_mask", "(", "self", ",", "mask", ":", "np", ".", "ndarray", ",", "polygons", ":", "Iterable", ",", "separate_instances", ":", "bool", "=", "False", ")", "->", "None", ":", "for", "i", ",", "p", "in", "enumerate", "(", "polygons", ")", ...
* The first polygon is the exterior ring. All others are treated as interior rings and will just invert the corresponding area of the mask. :param separate_instances: :param mask: :param polygons: :return:
[ "*", "The", "first", "polygon", "is", "the", "exterior", "ring", ".", "All", "others", "are", "treated", "as", "interior", "rings", "and", "will", "just", "invert", "the", "corresponding", "area", "of", "the", "mask", ".", ":", "param", "separate_instances",...
train
https://github.com/mnboos/airtiler/blob/6e79cdf22c5cd8a9cfffe07b58824fc1d1027104/airtiler/__init__.py#L267-L289
mnboos/airtiler
airtiler/__init__.py
Airtiler._process_internal
def _process_internal(self, config: dict) -> bool: """ * Processes the config. Throw :param config: :return: """ if "boundingboxes" not in config: raise RuntimeError("No 'boundingboxes' were specified in the config.") bboxes = config['boundingboxes'...
python
def _process_internal(self, config: dict) -> bool: """ * Processes the config. Throw :param config: :return: """ if "boundingboxes" not in config: raise RuntimeError("No 'boundingboxes' were specified in the config.") bboxes = config['boundingboxes'...
[ "def", "_process_internal", "(", "self", ",", "config", ":", "dict", ")", "->", "bool", ":", "if", "\"boundingboxes\"", "not", "in", "config", ":", "raise", "RuntimeError", "(", "\"No 'boundingboxes' were specified in the config.\"", ")", "bboxes", "=", "config", ...
* Processes the config. Throw :param config: :return:
[ "*", "Processes", "the", "config", ".", "Throw", ":", "param", "config", ":", ":", "return", ":" ]
train
https://github.com/mnboos/airtiler/blob/6e79cdf22c5cd8a9cfffe07b58824fc1d1027104/airtiler/__init__.py#L291-L341
wadoon/ansitagcolor
ansitagcolor.py
term.set_raw
def set_raw(self, *args): """ writes all *args as styled commands 'm' to the handle """ if not self.enabled: return args = map(lambda x: str(x), [x for x in args if x is not None]) self._write_raw(';'.join(args) + 'm')
python
def set_raw(self, *args): """ writes all *args as styled commands 'm' to the handle """ if not self.enabled: return args = map(lambda x: str(x), [x for x in args if x is not None]) self._write_raw(';'.join(args) + 'm')
[ "def", "set_raw", "(", "self", ",", "*", "args", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "args", "=", "map", "(", "lambda", "x", ":", "str", "(", "x", ")", ",", "[", "x", "for", "x", "in", "args", "if", "x", "is", "not",...
writes all *args as styled commands 'm' to the handle
[ "writes", "all", "*", "args", "as", "styled", "commands", "m", "to", "the", "handle" ]
train
https://github.com/wadoon/ansitagcolor/blob/7247ee8ec3b91590a07c68a7889ec87c5137b82d/ansitagcolor.py#L183-L189
wadoon/ansitagcolor
ansitagcolor.py
term._write_raw
def _write_raw(self, suffix): """ writes a the suffix prefixed by the CSI to the handle """ if not self.enabled: return self.buffer.write(CSI) self.buffer.write(suffix)
python
def _write_raw(self, suffix): """ writes a the suffix prefixed by the CSI to the handle """ if not self.enabled: return self.buffer.write(CSI) self.buffer.write(suffix)
[ "def", "_write_raw", "(", "self", ",", "suffix", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "self", ".", "buffer", ".", "write", "(", "CSI", ")", "self", ".", "buffer", ".", "write", "(", "suffix", ")" ]
writes a the suffix prefixed by the CSI to the handle
[ "writes", "a", "the", "suffix", "prefixed", "by", "the", "CSI", "to", "the", "handle" ]
train
https://github.com/wadoon/ansitagcolor/blob/7247ee8ec3b91590a07c68a7889ec87c5137b82d/ansitagcolor.py#L191-L198
Kopachris/seshet
seshet/config.py
build_db_tables
def build_db_tables(db): """Build Seshet's basic database schema. Requires one parameter, `db` as `pydal.DAL` instance. """ if not isinstance(db, DAL) or not db._uri: raise Exception("Need valid DAL object to define tables") # event log - self-explanatory, logs all events db.define...
python
def build_db_tables(db): """Build Seshet's basic database schema. Requires one parameter, `db` as `pydal.DAL` instance. """ if not isinstance(db, DAL) or not db._uri: raise Exception("Need valid DAL object to define tables") # event log - self-explanatory, logs all events db.define...
[ "def", "build_db_tables", "(", "db", ")", ":", "if", "not", "isinstance", "(", "db", ",", "DAL", ")", "or", "not", "db", ".", "_uri", ":", "raise", "Exception", "(", "\"Need valid DAL object to define tables\"", ")", "# event log - self-explanatory, logs all events"...
Build Seshet's basic database schema. Requires one parameter, `db` as `pydal.DAL` instance.
[ "Build", "Seshet", "s", "basic", "database", "schema", ".", "Requires", "one", "parameter", "db", "as", "pydal", ".", "DAL", "instance", "." ]
train
https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/config.py#L121-L153
Kopachris/seshet
seshet/config.py
build_bot
def build_bot(config_file=None): """Parse a config and return a SeshetBot instance. After, the bot can be run simply by calling .connect() and then .start() Optional arguments: config_file - valid file path or ConfigParser instance If config_file is None, will read default conf...
python
def build_bot(config_file=None): """Parse a config and return a SeshetBot instance. After, the bot can be run simply by calling .connect() and then .start() Optional arguments: config_file - valid file path or ConfigParser instance If config_file is None, will read default conf...
[ "def", "build_bot", "(", "config_file", "=", "None", ")", ":", "from", ".", "import", "bot", "config", "=", "ConfigParser", "(", "interpolation", "=", "None", ")", "if", "config_file", "is", "None", ":", "config", ".", "read_string", "(", "default_config", ...
Parse a config and return a SeshetBot instance. After, the bot can be run simply by calling .connect() and then .start() Optional arguments: config_file - valid file path or ConfigParser instance If config_file is None, will read default config defined in this module.
[ "Parse", "a", "config", "and", "return", "a", "SeshetBot", "instance", ".", "After", "the", "bot", "can", "be", "run", "simply", "by", "calling", ".", "connect", "()", "and", "then", ".", "start", "()", "Optional", "arguments", ":", "config_file", "-", "...
train
https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/config.py#L156-L222
dschien/PyExcelModelingHelper
excel_helper/__init__.py
growth_coefficients
def growth_coefficients(start_date, end_date, ref_date, alpha, samples): """ Build a matrix of growth factors according to the CAGR formula y'=y0 (1+a)^(t'-t0). a growth rate alpha t0 start date t' end date y' output y0 start value """ start_offset = 0 if ref_date < start_dat...
python
def growth_coefficients(start_date, end_date, ref_date, alpha, samples): """ Build a matrix of growth factors according to the CAGR formula y'=y0 (1+a)^(t'-t0). a growth rate alpha t0 start date t' end date y' output y0 start value """ start_offset = 0 if ref_date < start_dat...
[ "def", "growth_coefficients", "(", "start_date", ",", "end_date", ",", "ref_date", ",", "alpha", ",", "samples", ")", ":", "start_offset", "=", "0", "if", "ref_date", "<", "start_date", ":", "offset_delta", "=", "rdelta", ".", "relativedelta", "(", "start_date...
Build a matrix of growth factors according to the CAGR formula y'=y0 (1+a)^(t'-t0). a growth rate alpha t0 start date t' end date y' output y0 start value
[ "Build", "a", "matrix", "of", "growth", "factors", "according", "to", "the", "CAGR", "formula", "y", "=", "y0", "(", "1", "+", "a", ")", "^", "(", "t", "-", "t0", ")", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L379-L422
dschien/PyExcelModelingHelper
excel_helper/__init__.py
DistributionFunctionGenerator.get_mean
def get_mean(self, distribution_function): """Get the mean value for a distribution. If the distribution function is [normal, uniform,choice,triangular] the analytic value is being calculted. Else, the distribution is instantiated and then the mean is being calculated. :param distributi...
python
def get_mean(self, distribution_function): """Get the mean value for a distribution. If the distribution function is [normal, uniform,choice,triangular] the analytic value is being calculted. Else, the distribution is instantiated and then the mean is being calculated. :param distributi...
[ "def", "get_mean", "(", "self", ",", "distribution_function", ")", ":", "name", "=", "self", ".", "distribution_name", "params", "=", "self", ".", "random_function_params", "if", "name", "==", "'normal'", ":", "return", "params", "[", "0", "]", "if", "name",...
Get the mean value for a distribution. If the distribution function is [normal, uniform,choice,triangular] the analytic value is being calculted. Else, the distribution is instantiated and then the mean is being calculated. :param distribution_function: :return: the mean as a scalar
[ "Get", "the", "mean", "value", "for", "a", "distribution", ".", "If", "the", "distribution", "function", "is", "[", "normal", "uniform", "choice", "triangular", "]", "the", "analytic", "value", "is", "being", "calculted", ".", "Else", "the", "distribution", ...
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L92-L110
dschien/PyExcelModelingHelper
excel_helper/__init__.py
DistributionFunctionGenerator.generate_values
def generate_values(self, *args, **kwargs): """ Generate a sample of values by sampling from a distribution. The size of the sample can be overriden with the 'size' kwarg. If `self.sample_mean_value == True` the sample will contain "size" times the mean value. :param args: :par...
python
def generate_values(self, *args, **kwargs): """ Generate a sample of values by sampling from a distribution. The size of the sample can be overriden with the 'size' kwarg. If `self.sample_mean_value == True` the sample will contain "size" times the mean value. :param args: :par...
[ "def", "generate_values", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sample_size", "=", "kwargs", ".", "get", "(", "'size'", ",", "self", ".", "size", ")", "f", "=", "self", ".", "instantiate_distribution_function", "(", "self", ...
Generate a sample of values by sampling from a distribution. The size of the sample can be overriden with the 'size' kwarg. If `self.sample_mean_value == True` the sample will contain "size" times the mean value. :param args: :param kwargs: :return: sample as vector of given size
[ "Generate", "a", "sample", "of", "values", "by", "sampling", "from", "a", "distribution", ".", "The", "size", "of", "the", "sample", "can", "be", "overriden", "with", "the", "size", "kwarg", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L112-L132
dschien/PyExcelModelingHelper
excel_helper/__init__.py
GrowthTimeSeriesGenerator.generate_values
def generate_values(self, *args, **kwargs): """ Instantiate a random variable and apply annual growth factors. :return: """ assert 'ref value' in self.kwargs # 1. Generate $\mu$ start_date = self.times[0].to_pydatetime() end_date = self.times[-1].to_pyda...
python
def generate_values(self, *args, **kwargs): """ Instantiate a random variable and apply annual growth factors. :return: """ assert 'ref value' in self.kwargs # 1. Generate $\mu$ start_date = self.times[0].to_pydatetime() end_date = self.times[-1].to_pyda...
[ "def", "generate_values", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "'ref value'", "in", "self", ".", "kwargs", "# 1. Generate $\\mu$", "start_date", "=", "self", ".", "times", "[", "0", "]", ".", "to_pydatetime", "(", "...
Instantiate a random variable and apply annual growth factors. :return:
[ "Instantiate", "a", "random", "variable", "and", "apply", "annual", "growth", "factors", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L241-L301
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ConstantUncertaintyExponentialGrowthTimeSeriesGenerator.generate_values
def generate_values(self, *args, **kwargs): """ Instantiate a random variable and apply annual growth factors. :return: """ values = super().generate_values(*args, **kwargs, size=(len(self.times) * self.size,)) alpha = self.cagr # @todo - fill to cover the entir...
python
def generate_values(self, *args, **kwargs): """ Instantiate a random variable and apply annual growth factors. :return: """ values = super().generate_values(*args, **kwargs, size=(len(self.times) * self.size,)) alpha = self.cagr # @todo - fill to cover the entir...
[ "def", "generate_values", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "values", "=", "super", "(", ")", ".", "generate_values", "(", "*", "args", ",", "*", "*", "kwargs", ",", "size", "=", "(", "len", "(", "self", ".", "time...
Instantiate a random variable and apply annual growth factors. :return:
[ "Instantiate", "a", "random", "variable", "and", "apply", "annual", "growth", "factors", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L347-L376
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ParameterScenarioSet.add_scenario
def add_scenario(self, parameter: 'Parameter', scenario_name: str = default_scenario): """ Add a scenario for this parameter. :param scenario_name: :param parameter: :return: """ self.scenarios[scenario_name] = parameter
python
def add_scenario(self, parameter: 'Parameter', scenario_name: str = default_scenario): """ Add a scenario for this parameter. :param scenario_name: :param parameter: :return: """ self.scenarios[scenario_name] = parameter
[ "def", "add_scenario", "(", "self", ",", "parameter", ":", "'Parameter'", ",", "scenario_name", ":", "str", "=", "default_scenario", ")", ":", "self", ".", "scenarios", "[", "scenario_name", "]", "=", "parameter" ]
Add a scenario for this parameter. :param scenario_name: :param parameter: :return:
[ "Add", "a", "scenario", "for", "this", "parameter", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L438-L446
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ParameterRepository.add_parameter
def add_parameter(self, parameter: Parameter): """ A parameter can have several scenarios. They are specified as a comma-separated list in a string. :param parameter: :return: """ # try reading the scenarios from the function arg or from the parameter attribute s...
python
def add_parameter(self, parameter: Parameter): """ A parameter can have several scenarios. They are specified as a comma-separated list in a string. :param parameter: :return: """ # try reading the scenarios from the function arg or from the parameter attribute s...
[ "def", "add_parameter", "(", "self", ",", "parameter", ":", "Parameter", ")", ":", "# try reading the scenarios from the function arg or from the parameter attribute", "scenario_string", "=", "parameter", ".", "source_scenarios_string", "if", "scenario_string", ":", "_scenarios...
A parameter can have several scenarios. They are specified as a comma-separated list in a string. :param parameter: :return:
[ "A", "parameter", "can", "have", "several", "scenarios", ".", "They", "are", "specified", "as", "a", "comma", "-", "separated", "list", "in", "a", "string", ".", ":", "param", "parameter", ":", ":", "return", ":" ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L480-L504
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ParameterRepository.fill_missing_attributes_from_default_parameter
def fill_missing_attributes_from_default_parameter(self, param): """ Empty fields in Parameter definitions in scenarios are populated with default values. E.g. in the example below, the source for the Power_TV variable in the 8K scenario would also be EnergyStar. | name | scenario ...
python
def fill_missing_attributes_from_default_parameter(self, param): """ Empty fields in Parameter definitions in scenarios are populated with default values. E.g. in the example below, the source for the Power_TV variable in the 8K scenario would also be EnergyStar. | name | scenario ...
[ "def", "fill_missing_attributes_from_default_parameter", "(", "self", ",", "param", ")", ":", "if", "not", "self", ".", "exists", "(", "param", ".", "name", ")", "or", "not", "ParameterScenarioSet", ".", "default_scenario", "in", "self", ".", "parameter_sets", "...
Empty fields in Parameter definitions in scenarios are populated with default values. E.g. in the example below, the source for the Power_TV variable in the 8K scenario would also be EnergyStar. | name | scenario | val | tags | source | |----------|----------|-----|--------|---------...
[ "Empty", "fields", "in", "Parameter", "definitions", "in", "scenarios", "are", "populated", "with", "default", "values", "." ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L506-L541
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ParameterRepository.find_by_tag
def find_by_tag(self, tag) -> Dict[str, Set[Parameter]]: """ Get all registered dicts that are registered for a tag :param tag: str - single tag :return: a dict of {param name: set[Parameter]} that contains all ParameterScenarioSets for all parameter names with a given tag ...
python
def find_by_tag(self, tag) -> Dict[str, Set[Parameter]]: """ Get all registered dicts that are registered for a tag :param tag: str - single tag :return: a dict of {param name: set[Parameter]} that contains all ParameterScenarioSets for all parameter names with a given tag ...
[ "def", "find_by_tag", "(", "self", ",", "tag", ")", "->", "Dict", "[", "str", ",", "Set", "[", "Parameter", "]", "]", ":", "return", "self", ".", "tags", "[", "tag", "]" ]
Get all registered dicts that are registered for a tag :param tag: str - single tag :return: a dict of {param name: set[Parameter]} that contains all ParameterScenarioSets for all parameter names with a given tag
[ "Get", "all", "registered", "dicts", "that", "are", "registered", "for", "a", "tag" ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L560-L568
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ExcelParameterLoader.load_parameter_definitions
def load_parameter_definitions(self, sheet_name: str = None): """ Load variable text from rows in excel file. If no spreadsheet arg is given, all spreadsheets are loaded. The first cell in the first row in a spreadsheet must contain the keyword 'variable' or the sheet is ignored. ...
python
def load_parameter_definitions(self, sheet_name: str = None): """ Load variable text from rows in excel file. If no spreadsheet arg is given, all spreadsheets are loaded. The first cell in the first row in a spreadsheet must contain the keyword 'variable' or the sheet is ignored. ...
[ "def", "load_parameter_definitions", "(", "self", ",", "sheet_name", ":", "str", "=", "None", ")", ":", "definitions", "=", "self", ".", "excel_handler", ".", "load_definitions", "(", "sheet_name", ",", "filename", "=", "self", ".", "filename", ")", "self", ...
Load variable text from rows in excel file. If no spreadsheet arg is given, all spreadsheets are loaded. The first cell in the first row in a spreadsheet must contain the keyword 'variable' or the sheet is ignored. Any cells used as titles (with no associated value) are also added to the return...
[ "Load", "variable", "text", "from", "rows", "in", "excel", "file", ".", "If", "no", "spreadsheet", "arg", "is", "given", "all", "spreadsheets", "are", "loaded", ".", "The", "first", "cell", "in", "the", "first", "row", "in", "a", "spreadsheet", "must", "...
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L787-L812
dschien/PyExcelModelingHelper
excel_helper/__init__.py
ExcelParameterLoader.load_into_repo
def load_into_repo(self, repository: ParameterRepository = None, sheet_name: str = None): """ Create a Repo from an excel file. :param repository: the repository to load into :param sheet_name: :return: """ repository.add_all(self.load_parameters(sheet_name))
python
def load_into_repo(self, repository: ParameterRepository = None, sheet_name: str = None): """ Create a Repo from an excel file. :param repository: the repository to load into :param sheet_name: :return: """ repository.add_all(self.load_parameters(sheet_name))
[ "def", "load_into_repo", "(", "self", ",", "repository", ":", "ParameterRepository", "=", "None", ",", "sheet_name", ":", "str", "=", "None", ")", ":", "repository", ".", "add_all", "(", "self", ".", "load_parameters", "(", "sheet_name", ")", ")" ]
Create a Repo from an excel file. :param repository: the repository to load into :param sheet_name: :return:
[ "Create", "a", "Repo", "from", "an", "excel", "file", ".", ":", "param", "repository", ":", "the", "repository", "to", "load", "into", ":", "param", "sheet_name", ":", ":", "return", ":" ]
train
https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L814-L821
smarter-travel-media/stac
stac/http.py
VersionApiDao.get_most_recent_release
def get_most_recent_release(self, group, artifact, remote=False): """Get the version number of the most recent release (non-integration version) of a particular group and artifact combination. :param str group: Group of the artifact to get the version of :param str artifact: Name of the...
python
def get_most_recent_release(self, group, artifact, remote=False): """Get the version number of the most recent release (non-integration version) of a particular group and artifact combination. :param str group: Group of the artifact to get the version of :param str artifact: Name of the...
[ "def", "get_most_recent_release", "(", "self", ",", "group", ",", "artifact", ",", "remote", "=", "False", ")", ":", "url", "=", "self", ".", "_base_url", "+", "'/api/search/latestVersion'", "params", "=", "{", "'g'", ":", "group", ",", "'a'", ":", "artifa...
Get the version number of the most recent release (non-integration version) of a particular group and artifact combination. :param str group: Group of the artifact to get the version of :param str artifact: Name of the artifact to get the version of :param bool remote: Should remote rep...
[ "Get", "the", "version", "number", "of", "the", "most", "recent", "release", "(", "non", "-", "integration", "version", ")", "of", "a", "particular", "group", "and", "artifact", "combination", "." ]
train
https://github.com/smarter-travel-media/stac/blob/cdb29a17ede0924b122b3905a500442c62ae53b7/stac/http.py#L48-L67
smarter-travel-media/stac
stac/http.py
VersionApiDao.get_most_recent_versions
def get_most_recent_versions(self, group, artifact, limit, remote=False, integration=False): """Get a list of the version numbers of the most recent artifacts (integration or non-integration), ordered by the version number, for a particular group and artifact combination. :param str gro...
python
def get_most_recent_versions(self, group, artifact, limit, remote=False, integration=False): """Get a list of the version numbers of the most recent artifacts (integration or non-integration), ordered by the version number, for a particular group and artifact combination. :param str gro...
[ "def", "get_most_recent_versions", "(", "self", ",", "group", ",", "artifact", ",", "limit", ",", "remote", "=", "False", ",", "integration", "=", "False", ")", ":", "if", "limit", "<", "1", ":", "raise", "ValueError", "(", "\"Releases limit must be positive\"...
Get a list of the version numbers of the most recent artifacts (integration or non-integration), ordered by the version number, for a particular group and artifact combination. :param str group: Group of the artifact to get versions of :param str artifact: Name of the artifact to get ve...
[ "Get", "a", "list", "of", "the", "version", "numbers", "of", "the", "most", "recent", "artifacts", "(", "integration", "or", "non", "-", "integration", ")", "ordered", "by", "the", "version", "number", "for", "a", "particular", "group", "and", "artifact", ...
train
https://github.com/smarter-travel-media/stac/blob/cdb29a17ede0924b122b3905a500442c62ae53b7/stac/http.py#L69-L102
Naught0/lolrune
lolrune/runeclient.py
RuneClient._get
def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request. Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ Run...
python
def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request. Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ Run...
[ "def", "_get", "(", "self", ",", "url", ":", "str", ")", "->", "str", ":", "resp", "=", "self", ".", "session", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "HEADERS", ")", "if", "resp", ".", "status_code", "is", "200", ":", "return"...
A small wrapper method which makes a quick GET request. Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ RuneConnectionError If the GET resp...
[ "A", "small", "wrapper", "method", "which", "makes", "a", "quick", "GET", "request", "." ]
train
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/runeclient.py#L52-L74
edwards-lab/libGWAS
libgwas/__init__.py
sys_call
def sys_call(cmd): """Execute cmd and capture stdout and stderr :param cmd: command to be executed :return: (stdout, stderr) """ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) return p.stdout.readlines(), p.stderr.readlines()
python
def sys_call(cmd): """Execute cmd and capture stdout and stderr :param cmd: command to be executed :return: (stdout, stderr) """ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) return p.stdout.readlines(), p.stderr.readlines()
[ "def", "sys_call", "(", "cmd", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ",", "close_fds", "=", "True", ")", ...
Execute cmd and capture stdout and stderr :param cmd: command to be executed :return: (stdout, stderr)
[ "Execute", "cmd", "and", "capture", "stdout", "and", "stderr" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/__init__.py#L51-L58
edwards-lab/libGWAS
libgwas/__init__.py
Exit
def Exit(msg, code=1): """Exit execution with return code and message :param msg: Message displayed prior to exit :param code: code returned upon exiting """ print >> sys.stderr, msg sys.exit(code)
python
def Exit(msg, code=1): """Exit execution with return code and message :param msg: Message displayed prior to exit :param code: code returned upon exiting """ print >> sys.stderr, msg sys.exit(code)
[ "def", "Exit", "(", "msg", ",", "code", "=", "1", ")", ":", "print", ">>", "sys", ".", "stderr", ",", "msg", "sys", ".", "exit", "(", "code", ")" ]
Exit execution with return code and message :param msg: Message displayed prior to exit :param code: code returned upon exiting
[ "Exit", "execution", "with", "return", "code", "and", "message", ":", "param", "msg", ":", "Message", "displayed", "prior", "to", "exit", ":", "param", "code", ":", "code", "returned", "upon", "exiting" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/__init__.py#L61-L67
edwards-lab/libGWAS
libgwas/__init__.py
BuildReportLine
def BuildReportLine(key, value, offset=None): """Prepare key/value for reporting in configuration report :param key: configuration 'keyword' :param value: value reported to be associated with keyword :return: formatted line starting with a comment """ reportline = "# " + key.ljust(20) + " : " ...
python
def BuildReportLine(key, value, offset=None): """Prepare key/value for reporting in configuration report :param key: configuration 'keyword' :param value: value reported to be associated with keyword :return: formatted line starting with a comment """ reportline = "# " + key.ljust(20) + " : " ...
[ "def", "BuildReportLine", "(", "key", ",", "value", ",", "offset", "=", "None", ")", ":", "reportline", "=", "\"# \"", "+", "key", ".", "ljust", "(", "20", ")", "+", "\" : \"", "if", "offset", "is", "None", ":", "return", "reportline", "+", "str", "(...
Prepare key/value for reporting in configuration report :param key: configuration 'keyword' :param value: value reported to be associated with keyword :return: formatted line starting with a comment
[ "Prepare", "key", "/", "value", "for", "reporting", "in", "configuration", "report" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/__init__.py#L79-L101
AndresMWeber/Nomenclate
nomenclate/core/rendering.py
InputRenderer.cleanup_formatted_string
def cleanup_formatted_string(cls, formatted_string): """ Removes unused tokens/removes surrounding and double underscores :param formatted_string: str, string that has had tokens replaced :return: str, cleaned up name of object """ # Remove whitespace result = formatted_...
python
def cleanup_formatted_string(cls, formatted_string): """ Removes unused tokens/removes surrounding and double underscores :param formatted_string: str, string that has had tokens replaced :return: str, cleaned up name of object """ # Remove whitespace result = formatted_...
[ "def", "cleanup_formatted_string", "(", "cls", ",", "formatted_string", ")", ":", "# Remove whitespace", "result", "=", "formatted_string", ".", "replace", "(", "' '", ",", "''", ")", "# Remove any static token parentheses", "result", "=", "re", ".", "sub", "(", "...
Removes unused tokens/removes surrounding and double underscores :param formatted_string: str, string that has had tokens replaced :return: str, cleaned up name of object
[ "Removes", "unused", "tokens", "/", "removes", "surrounding", "and", "double", "underscores" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/rendering.py#L82-L102
AndresMWeber/Nomenclate
nomenclate/core/rendering.py
InputRenderer._get_alphanumeric_index
def _get_alphanumeric_index(query_string): """ Given an input string of either int or char, returns what index in the alphabet and case it is :param query_string: str, query string :return: (int, str), list of the index and type """ # TODO: could probably rework this. it works, ...
python
def _get_alphanumeric_index(query_string): """ Given an input string of either int or char, returns what index in the alphabet and case it is :param query_string: str, query string :return: (int, str), list of the index and type """ # TODO: could probably rework this. it works, ...
[ "def", "_get_alphanumeric_index", "(", "query_string", ")", ":", "# TODO: could probably rework this. it works, but it's ugly as hell.", "try", ":", "return", "[", "int", "(", "query_string", ")", ",", "'int'", "]", "except", "ValueError", ":", "if", "len", "(", "quer...
Given an input string of either int or char, returns what index in the alphabet and case it is :param query_string: str, query string :return: (int, str), list of the index and type
[ "Given", "an", "input", "string", "of", "either", "int", "or", "char", "returns", "what", "index", "in", "the", "alphabet", "and", "case", "it", "is" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/rendering.py#L105-L121
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
unzip
def unzip(source_file, destination_dir): """ Unzips <source_file> into <destination_dir>. :param str|unicode source_file: The name of the file to read :param str|unicode destination_dir: The name of the directory to write the unzipped files """ with zipfile.ZipFile(source_file) as zf: zf...
python
def unzip(source_file, destination_dir): """ Unzips <source_file> into <destination_dir>. :param str|unicode source_file: The name of the file to read :param str|unicode destination_dir: The name of the directory to write the unzipped files """ with zipfile.ZipFile(source_file) as zf: zf...
[ "def", "unzip", "(", "source_file", ",", "destination_dir", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "source_file", ")", "as", "zf", ":", "zf", ".", "extractall", "(", "destination_dir", ")" ]
Unzips <source_file> into <destination_dir>. :param str|unicode source_file: The name of the file to read :param str|unicode destination_dir: The name of the directory to write the unzipped files
[ "Unzips", "<source_file", ">", "into", "<destination_dir", ">", ".", ":", "param", "str|unicode", "source_file", ":", "The", "name", "of", "the", "file", "to", "read", ":", "param", "str|unicode", "destination_dir", ":", "The", "name", "of", "the", "directory"...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L29-L36
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
add_contents_to_zip
def add_contents_to_zip(zip_file, path): """ Zip the contents of <path> into <zip_file>. :param str|unicode zip_file: The file name of the zip file :param str|unicode path: Full path of the directory to zip up """ path = path.rstrip(os.sep) with zipfile.ZipFile(zip_file, 'a') as zf: ...
python
def add_contents_to_zip(zip_file, path): """ Zip the contents of <path> into <zip_file>. :param str|unicode zip_file: The file name of the zip file :param str|unicode path: Full path of the directory to zip up """ path = path.rstrip(os.sep) with zipfile.ZipFile(zip_file, 'a') as zf: ...
[ "def", "add_contents_to_zip", "(", "zip_file", ",", "path", ")", ":", "path", "=", "path", ".", "rstrip", "(", "os", ".", "sep", ")", "with", "zipfile", ".", "ZipFile", "(", "zip_file", ",", "'a'", ")", "as", "zf", ":", "for", "root", ",", "dirs", ...
Zip the contents of <path> into <zip_file>. :param str|unicode zip_file: The file name of the zip file :param str|unicode path: Full path of the directory to zip up
[ "Zip", "the", "contents", "of", "<path", ">", "into", "<zip_file", ">", ".", ":", "param", "str|unicode", "zip_file", ":", "The", "file", "name", "of", "the", "zip", "file", ":", "param", "str|unicode", "path", ":", "Full", "path", "of", "the", "director...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L39-L50
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
add_file_to_zip
def add_file_to_zip(zip_file, filename, archname=None, compress_type=None): """ Zip <filename> into <zip_file> as <archname>. :param str|unicode zip_file: The file name of the zip file :param str|unicode filename: The name of the file to add, including the path :param str|unicode archname: The new n...
python
def add_file_to_zip(zip_file, filename, archname=None, compress_type=None): """ Zip <filename> into <zip_file> as <archname>. :param str|unicode zip_file: The file name of the zip file :param str|unicode filename: The name of the file to add, including the path :param str|unicode archname: The new n...
[ "def", "add_file_to_zip", "(", "zip_file", ",", "filename", ",", "archname", "=", "None", ",", "compress_type", "=", "None", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "zip_file", ",", "'a'", ")", "as", "zf", ":", "zf", ".", "write", "(", "filen...
Zip <filename> into <zip_file> as <archname>. :param str|unicode zip_file: The file name of the zip file :param str|unicode filename: The name of the file to add, including the path :param str|unicode archname: The new name, with directories, of the file, the same as filename if not given :param str|uni...
[ "Zip", "<filename", ">", "into", "<zip_file", ">", "as", "<archname", ">", ".", ":", "param", "str|unicode", "zip_file", ":", "The", "file", "name", "of", "the", "zip", "file", ":", "param", "str|unicode", "filename", ":", "The", "name", "of", "the", "fi...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L53-L62
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
make_dir
def make_dir(dir_name, linux_mode=0o755, error_if_not_writable=False): """ Creates a directory, if it doesn't exist already. If the directory does exist, and <error_if_not_writable> is True, the directory will be checked for writability. :param str|unicode dir_name: The name of the directory to create ...
python
def make_dir(dir_name, linux_mode=0o755, error_if_not_writable=False): """ Creates a directory, if it doesn't exist already. If the directory does exist, and <error_if_not_writable> is True, the directory will be checked for writability. :param str|unicode dir_name: The name of the directory to create ...
[ "def", "make_dir", "(", "dir_name", ",", "linux_mode", "=", "0o755", ",", "error_if_not_writable", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dir_name", ")", ":", "os", ".", "makedirs", "(", "dir_name", ",", "linux_mode"...
Creates a directory, if it doesn't exist already. If the directory does exist, and <error_if_not_writable> is True, the directory will be checked for writability. :param str|unicode dir_name: The name of the directory to create :param int linux_mode: The mode/permissions to set for the new directory express...
[ "Creates", "a", "directory", "if", "it", "doesn", "t", "exist", "already", ".", "If", "the", "directory", "does", "exist", "and", "<error_if_not_writable", ">", "is", "True", "the", "directory", "will", "be", "checked", "for", "writability", ".", ":", "param...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L65-L77
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
load_json_object
def load_json_object(file_name, default=None): """ Deserialized <file_name> into a Python object :param str|unicode file_name: The name of the file to read :param default: The value to return if the file is not found """ if not os.path.isfile(file_name): return default # use utf-8-s...
python
def load_json_object(file_name, default=None): """ Deserialized <file_name> into a Python object :param str|unicode file_name: The name of the file to read :param default: The value to return if the file is not found """ if not os.path.isfile(file_name): return default # use utf-8-s...
[ "def", "load_json_object", "(", "file_name", ",", "default", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file_name", ")", ":", "return", "default", "# use utf-8-sig in case the file has a Byte Order Mark", "with", "codecs", ".", "...
Deserialized <file_name> into a Python object :param str|unicode file_name: The name of the file to read :param default: The value to return if the file is not found
[ "Deserialized", "<file_name", ">", "into", "a", "Python", "object", ":", "param", "str|unicode", "file_name", ":", "The", "name", "of", "the", "file", "to", "read", ":", "param", "default", ":", "The", "value", "to", "return", "if", "the", "file", "is", ...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L80-L98
unfoldingWord-dev/tx-shared-tools
general_tools/file_utils.py
write_file
def write_file(file_name, file_contents, indent=None): """ Writes the <file_contents> to <file_name>. If <file_contents> is not a string, it is serialized as JSON. :param str|unicode file_name: The name of the file to write :param str|unicode|object file_contents: The string to write or the object to se...
python
def write_file(file_name, file_contents, indent=None): """ Writes the <file_contents> to <file_name>. If <file_contents> is not a string, it is serialized as JSON. :param str|unicode file_name: The name of the file to write :param str|unicode|object file_contents: The string to write or the object to se...
[ "def", "write_file", "(", "file_name", ",", "file_contents", ",", "indent", "=", "None", ")", ":", "# make sure the directory exists", "make_dir", "(", "os", ".", "path", ".", "dirname", "(", "file_name", ")", ")", "if", "isinstance", "(", "file_contents", ","...
Writes the <file_contents> to <file_name>. If <file_contents> is not a string, it is serialized as JSON. :param str|unicode file_name: The name of the file to write :param str|unicode|object file_contents: The string to write or the object to serialize :param int indent: Specify a value if you want the outp...
[ "Writes", "the", "<file_contents", ">", "to", "<file_name", ">", ".", "If", "<file_contents", ">", "is", "not", "a", "string", "it", "is", "serialized", "as", "JSON", ".", ":", "param", "str|unicode", "file_name", ":", "The", "name", "of", "the", "file", ...
train
https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/file_utils.py#L106-L122
honzamach/pynspect
pynspect/traversers.py
_to_numeric
def _to_numeric(val): """ Helper function for conversion of various data types into numeric representation. """ if isinstance(val, (int, float, datetime.datetime, datetime.timedelta)): return val return float(val)
python
def _to_numeric(val): """ Helper function for conversion of various data types into numeric representation. """ if isinstance(val, (int, float, datetime.datetime, datetime.timedelta)): return val return float(val)
[ "def", "_to_numeric", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "(", "int", ",", "float", ",", "datetime", ".", "datetime", ",", "datetime", ".", "timedelta", ")", ")", ":", "return", "val", "return", "float", "(", "val", ")" ]
Helper function for conversion of various data types into numeric representation.
[ "Helper", "function", "for", "conversion", "of", "various", "data", "types", "into", "numeric", "representation", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L517-L523
honzamach/pynspect
pynspect/traversers.py
HTMLTreeTraverser.list
def list(self, rule, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ListRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param dict kwargs: Optional callback arguments. """ ...
python
def list(self, rule, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ListRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param dict kwargs: Optional callback arguments. """ ...
[ "def", "list", "(", "self", ",", "rule", ",", "*", "*", "kwargs", ")", ":", "return", "'<ul class=\"pynspect-rule-list\">{}</ul>'", ".", "format", "(", "''", ".", "join", "(", "[", "'<li class=\"pynspect-rule-list-item\">{}</li>'", ".", "format", "(", "v", ".", ...
Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ListRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param dict kwargs: Optional callback arguments.
[ "Callback", "method", "for", "rule", "tree", "traversing", ".", "Will", "be", "called", "at", "proper", "time", "from", ":", "py", ":", "class", ":", "pynspect", ".", "rules", ".", "ListRule", ".", "traverse", "method", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L445-L453
honzamach/pynspect
pynspect/traversers.py
HTMLTreeTraverser.binary_operation_logical
def binary_operation_logical(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.LogicalBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left op...
python
def binary_operation_logical(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.LogicalBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left op...
[ "def", "binary_operation_logical", "(", "self", ",", "rule", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "return", "'<div class=\"pynspect-rule-operation pynspect-rule-operation-logical\"><h3 class=\"pynspect-rule-operation-name\">{}</h3><ul class=\"pynspect-rule-...
Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.LogicalBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left operand for operation. :param right: right operand for operation. :para...
[ "Callback", "method", "for", "rule", "tree", "traversing", ".", "Will", "be", "called", "at", "proper", "time", "from", ":", "py", ":", "class", ":", "pynspect", ".", "rules", ".", "LogicalBinOpRule", ".", "traverse", "method", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L455-L465
honzamach/pynspect
pynspect/traversers.py
HTMLTreeTraverser.binary_operation_comparison
def binary_operation_comparison(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ComparisonBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: L...
python
def binary_operation_comparison(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ComparisonBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: L...
[ "def", "binary_operation_comparison", "(", "self", ",", "rule", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "return", "'<div class=\"pynspect-rule-operation pynspect-rule-operation-comparison\"><h3 class=\"pynspect-rule-operation-name\">{}</h3><ul class=\"pynspect...
Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.ComparisonBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left operand for operation. :param right: right operand for operation. :p...
[ "Callback", "method", "for", "rule", "tree", "traversing", ".", "Will", "be", "called", "at", "proper", "time", "from", ":", "py", ":", "class", ":", "pynspect", ".", "rules", ".", "ComparisonBinOpRule", ".", "traverse", "method", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L467-L477
honzamach/pynspect
pynspect/traversers.py
HTMLTreeTraverser.binary_operation_math
def binary_operation_math(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.MathBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left operand ...
python
def binary_operation_math(self, rule, left, right, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.MathBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left operand ...
[ "def", "binary_operation_math", "(", "self", ",", "rule", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "return", "'<div class=\"pynspect-rule-operation pynspect-rule-operation-math\"><h3 class=\"pynspect-rule-operation-name\">{}</h3><ul class=\"pynspect-rule-operat...
Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.MathBinOpRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param left: Left operand for operation. :param right: right operand for operation. :param d...
[ "Callback", "method", "for", "rule", "tree", "traversing", ".", "Will", "be", "called", "at", "proper", "time", "from", ":", "py", ":", "class", ":", "pynspect", ".", "rules", ".", "MathBinOpRule", ".", "traverse", "method", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L479-L489
honzamach/pynspect
pynspect/traversers.py
HTMLTreeTraverser.function
def function(self, rule, args, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.FunctionRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param args: Optional function arguments. ...
python
def function(self, rule, args, **kwargs): """ Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.FunctionRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param args: Optional function arguments. ...
[ "def", "function", "(", "self", ",", "rule", ",", "args", ",", "*", "*", "kwargs", ")", ":", "return", "'<div class=\"pynspect-rule-function\"><h3 class=\"pynspect-rule-function-name\">{}</h3><ul class=\"pynspect-rule-function-arguments>{}</ul></div>'", ".", "format", "(", "rul...
Callback method for rule tree traversing. Will be called at proper time from :py:class:`pynspect.rules.FunctionRule.traverse` method. :param pynspect.rules.Rule rule: Reference to rule. :param args: Optional function arguments. :param dict kwargs: Optional callback arguments.
[ "Callback", "method", "for", "rule", "tree", "traversing", ".", "Will", "be", "called", "at", "proper", "time", "from", ":", "py", ":", "class", ":", "pynspect", ".", "rules", ".", "FunctionRule", ".", "traverse", "method", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L502-L511
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.evaluate_binop_logical
def evaluate_binop_logical(self, operation, left, right, **kwargs): """ Evaluate given logical binary operation with given operands. """ if not operation in self.binops_logical: raise ValueError("Invalid logical binary operation '{}'".format(operation)) result = self....
python
def evaluate_binop_logical(self, operation, left, right, **kwargs): """ Evaluate given logical binary operation with given operands. """ if not operation in self.binops_logical: raise ValueError("Invalid logical binary operation '{}'".format(operation)) result = self....
[ "def", "evaluate_binop_logical", "(", "self", ",", "operation", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "if", "not", "operation", "in", "self", ".", "binops_logical", ":", "raise", "ValueError", "(", "\"Invalid logical binary operation '{}'...
Evaluate given logical binary operation with given operands.
[ "Evaluate", "given", "logical", "binary", "operation", "with", "given", "operands", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L642-L649
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.evaluate_binop_comparison
def evaluate_binop_comparison(self, operation, left, right, **kwargs): """ Evaluate given comparison binary operation with given operands. """ if not operation in self.binops_comparison: raise ValueError("Invalid comparison binary operation '{}'".format(operation)) if...
python
def evaluate_binop_comparison(self, operation, left, right, **kwargs): """ Evaluate given comparison binary operation with given operands. """ if not operation in self.binops_comparison: raise ValueError("Invalid comparison binary operation '{}'".format(operation)) if...
[ "def", "evaluate_binop_comparison", "(", "self", ",", "operation", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "if", "not", "operation", "in", "self", ".", "binops_comparison", ":", "raise", "ValueError", "(", "\"Invalid comparison binary opera...
Evaluate given comparison binary operation with given operands.
[ "Evaluate", "given", "comparison", "binary", "operation", "with", "given", "operands", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L651-L684
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser._calculate_vector
def _calculate_vector(self, operation, left, right): """ Calculate vector result from two list operands with given mathematical operation. """ result = [] if len(right) == 1: right = _to_numeric(right[0]) for iteml in left: iteml = _to_nume...
python
def _calculate_vector(self, operation, left, right): """ Calculate vector result from two list operands with given mathematical operation. """ result = [] if len(right) == 1: right = _to_numeric(right[0]) for iteml in left: iteml = _to_nume...
[ "def", "_calculate_vector", "(", "self", ",", "operation", ",", "left", ",", "right", ")", ":", "result", "=", "[", "]", "if", "len", "(", "right", ")", "==", "1", ":", "right", "=", "_to_numeric", "(", "right", "[", "0", "]", ")", "for", "iteml", ...
Calculate vector result from two list operands with given mathematical operation.
[ "Calculate", "vector", "result", "from", "two", "list", "operands", "with", "given", "mathematical", "operation", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L686-L708
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.evaluate_binop_math
def evaluate_binop_math(self, operation, left, right, **kwargs): """ Evaluate given mathematical binary operation with given operands. """ if not operation in self.binops_math: raise ValueError("Invalid math binary operation '{}'".format(operation)) if left is None or...
python
def evaluate_binop_math(self, operation, left, right, **kwargs): """ Evaluate given mathematical binary operation with given operands. """ if not operation in self.binops_math: raise ValueError("Invalid math binary operation '{}'".format(operation)) if left is None or...
[ "def", "evaluate_binop_math", "(", "self", ",", "operation", ",", "left", ",", "right", ",", "*", "*", "kwargs", ")", ":", "if", "not", "operation", "in", "self", ".", "binops_math", ":", "raise", "ValueError", "(", "\"Invalid math binary operation '{}'\"", "....
Evaluate given mathematical binary operation with given operands.
[ "Evaluate", "given", "mathematical", "binary", "operation", "with", "given", "operands", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L710-L730
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.evaluate_unop
def evaluate_unop(self, operation, right, **kwargs): """ Evaluate given unary operation with given operand. """ if not operation in self.unops: raise ValueError("Invalid unary operation '{}'".format(operation)) if right is None: return None return ...
python
def evaluate_unop(self, operation, right, **kwargs): """ Evaluate given unary operation with given operand. """ if not operation in self.unops: raise ValueError("Invalid unary operation '{}'".format(operation)) if right is None: return None return ...
[ "def", "evaluate_unop", "(", "self", ",", "operation", ",", "right", ",", "*", "*", "kwargs", ")", ":", "if", "not", "operation", "in", "self", ".", "unops", ":", "raise", "ValueError", "(", "\"Invalid unary operation '{}'\"", ".", "format", "(", "operation"...
Evaluate given unary operation with given operand.
[ "Evaluate", "given", "unary", "operation", "with", "given", "operand", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L732-L740
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.decorate_function
def decorate_function(self, name, decorator): """ Decorate function with given name with given decorator. :param str name: Name of the function. :param callable decorator: Decorator callback. """ self.functions[name] = decorator(self.functions[name])
python
def decorate_function(self, name, decorator): """ Decorate function with given name with given decorator. :param str name: Name of the function. :param callable decorator: Decorator callback. """ self.functions[name] = decorator(self.functions[name])
[ "def", "decorate_function", "(", "self", ",", "name", ",", "decorator", ")", ":", "self", ".", "functions", "[", "name", "]", "=", "decorator", "(", "self", ".", "functions", "[", "name", "]", ")" ]
Decorate function with given name with given decorator. :param str name: Name of the function. :param callable decorator: Decorator callback.
[ "Decorate", "function", "with", "given", "name", "with", "given", "decorator", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L753-L760
honzamach/pynspect
pynspect/traversers.py
BaseFilteringTreeTraverser.function
def function(self, rule, args, **kwargs): """ Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.function` interface. """ fname = rule.function try: return self.functions[fname](args) except KeyError: raise FilteringRuleException("In...
python
def function(self, rule, args, **kwargs): """ Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.function` interface. """ fname = rule.function try: return self.functions[fname](args) except KeyError: raise FilteringRuleException("In...
[ "def", "function", "(", "self", ",", "rule", ",", "args", ",", "*", "*", "kwargs", ")", ":", "fname", "=", "rule", ".", "function", "try", ":", "return", "self", ".", "functions", "[", "fname", "]", "(", "args", ")", "except", "KeyError", ":", "rai...
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.function` interface.
[ "Implementation", "of", ":", "py", ":", "func", ":", "pynspect", ".", "traversers", ".", "RuleTreeTraverser", ".", "function", "interface", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/traversers.py#L762-L770
a1fred/django-model-render
model_render/__init__.py
ModelRenderMixin.render
def render(self, template=None, additional=None): """ Render single model to its html representation. You may set template path in render function argument, or model's variable named 'template_path', or get default name: $app_label$/models/$model_name$.html Sett...
python
def render(self, template=None, additional=None): """ Render single model to its html representation. You may set template path in render function argument, or model's variable named 'template_path', or get default name: $app_label$/models/$model_name$.html Sett...
[ "def", "render", "(", "self", ",", "template", "=", "None", ",", "additional", "=", "None", ")", ":", "template_path", "=", "template", "or", "self", ".", "get_template_path", "(", ")", "template_vars", "=", "{", "'model'", ":", "self", "}", "if", "addit...
Render single model to its html representation. You may set template path in render function argument, or model's variable named 'template_path', or get default name: $app_label$/models/$model_name$.html Settings: * MODEL_RENDER_DEFAULT_EXTENSION set default...
[ "Render", "single", "model", "to", "its", "html", "representation", "." ]
train
https://github.com/a1fred/django-model-render/blob/0912b2ec9d33bada8875a57f7af9eb18d24e1e84/model_render/__init__.py#L18-L40
mrstephenneal/dirutility
dirutility/system.py
SystemCommand.execute
def execute(self): """Execute a system command.""" if self._decode_output: # Capture and decode system output with Popen(self.command, shell=True, stdout=PIPE) as process: self._output = [i.decode("utf-8").strip() for i in process.stdout] self._suc...
python
def execute(self): """Execute a system command.""" if self._decode_output: # Capture and decode system output with Popen(self.command, shell=True, stdout=PIPE) as process: self._output = [i.decode("utf-8").strip() for i in process.stdout] self._suc...
[ "def", "execute", "(", "self", ")", ":", "if", "self", ".", "_decode_output", ":", "# Capture and decode system output", "with", "Popen", "(", "self", ".", "command", ",", "shell", "=", "True", ",", "stdout", "=", "PIPE", ")", "as", "process", ":", "self",...
Execute a system command.
[ "Execute", "a", "system", "command", "." ]
train
https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/system.py#L51-L62
Vito2015/pyextend
pyextend/core/wrappers/accepts.py
accepts
def accepts(exception=TypeError, **types): """ A wrapper of function for checking function parameters type Example 1: @accepts(a=int, b='__iter__', c=str) def test(a, b=None, c=None): print('accepts OK') test(13, b=[], c='abc') -- OK test('aaa', b=(), c='abc') ...
python
def accepts(exception=TypeError, **types): """ A wrapper of function for checking function parameters type Example 1: @accepts(a=int, b='__iter__', c=str) def test(a, b=None, c=None): print('accepts OK') test(13, b=[], c='abc') -- OK test('aaa', b=(), c='abc') ...
[ "def", "accepts", "(", "exception", "=", "TypeError", ",", "*", "*", "types", ")", ":", "def", "check_param", "(", "v", ",", "type_or_funcname", ")", ":", "if", "isinstance", "(", "type_or_funcname", ",", "tuple", ")", ":", "results1", "=", "[", "check_p...
A wrapper of function for checking function parameters type Example 1: @accepts(a=int, b='__iter__', c=str) def test(a, b=None, c=None): print('accepts OK') test(13, b=[], c='abc') -- OK test('aaa', b=(), c='abc') --Failed Example 2: @accepts(a=int, b=('__...
[ "A", "wrapper", "of", "function", "for", "checking", "function", "parameters", "type" ]
train
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/wrappers/accepts.py#L15-L77
radhermit/vimball
vimball/base.py
is_vimball
def is_vimball(fd): """Test for vimball archive format compliance. Simple check to see if the first line of the file starts with standard vimball archive header. """ fd.seek(0) try: header = fd.readline() except UnicodeDecodeError: # binary files will raise exceptions when t...
python
def is_vimball(fd): """Test for vimball archive format compliance. Simple check to see if the first line of the file starts with standard vimball archive header. """ fd.seek(0) try: header = fd.readline() except UnicodeDecodeError: # binary files will raise exceptions when t...
[ "def", "is_vimball", "(", "fd", ")", ":", "fd", ".", "seek", "(", "0", ")", "try", ":", "header", "=", "fd", ".", "readline", "(", ")", "except", "UnicodeDecodeError", ":", "# binary files will raise exceptions when trying to decode raw bytes to", "# str objects in ...
Test for vimball archive format compliance. Simple check to see if the first line of the file starts with standard vimball archive header.
[ "Test", "for", "vimball", "archive", "format", "compliance", "." ]
train
https://github.com/radhermit/vimball/blob/3998bdb8d8c4852a388a259778f971f562f9ef37/vimball/base.py#L24-L39
radhermit/vimball
vimball/base.py
Vimball.readline
def readline(self): """Readline wrapper to force readline() to return str objects.""" line = self.fd.__class__.readline(self.fd) if isinstance(line, bytes): line = line.decode() return line
python
def readline(self): """Readline wrapper to force readline() to return str objects.""" line = self.fd.__class__.readline(self.fd) if isinstance(line, bytes): line = line.decode() return line
[ "def", "readline", "(", "self", ")", ":", "line", "=", "self", ".", "fd", ".", "__class__", ".", "readline", "(", "self", ".", "fd", ")", "if", "isinstance", "(", "line", ",", "bytes", ")", ":", "line", "=", "line", ".", "decode", "(", ")", "retu...
Readline wrapper to force readline() to return str objects.
[ "Readline", "wrapper", "to", "force", "readline", "()", "to", "return", "str", "objects", "." ]
train
https://github.com/radhermit/vimball/blob/3998bdb8d8c4852a388a259778f971f562f9ef37/vimball/base.py#L74-L79
radhermit/vimball
vimball/base.py
Vimball.files
def files(self): """Yields archive file information.""" # try new file header format first, then fallback on old for header in (r"(.*)\t\[\[\[1\n", r"^(\d+)\n$"): header = re.compile(header) filename = None self.fd.seek(0) line = self.readline() ...
python
def files(self): """Yields archive file information.""" # try new file header format first, then fallback on old for header in (r"(.*)\t\[\[\[1\n", r"^(\d+)\n$"): header = re.compile(header) filename = None self.fd.seek(0) line = self.readline() ...
[ "def", "files", "(", "self", ")", ":", "# try new file header format first, then fallback on old", "for", "header", "in", "(", "r\"(.*)\\t\\[\\[\\[1\\n\"", ",", "r\"^(\\d+)\\n$\"", ")", ":", "header", "=", "re", ".", "compile", "(", "header", ")", "filename", "=", ...
Yields archive file information.
[ "Yields", "archive", "file", "information", "." ]
train
https://github.com/radhermit/vimball/blob/3998bdb8d8c4852a388a259778f971f562f9ef37/vimball/base.py#L82-L102
radhermit/vimball
vimball/base.py
Vimball.extract
def extract(self, extractdir=None, verbose=False): """Extract archive files to a directory.""" if extractdir is None: filebase, ext = os.path.splitext(self.path) if ext in ('.gz', '.bz2', '.xz'): filebase, _ext = os.path.splitext(filebase) extractdir =...
python
def extract(self, extractdir=None, verbose=False): """Extract archive files to a directory.""" if extractdir is None: filebase, ext = os.path.splitext(self.path) if ext in ('.gz', '.bz2', '.xz'): filebase, _ext = os.path.splitext(filebase) extractdir =...
[ "def", "extract", "(", "self", ",", "extractdir", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "extractdir", "is", "None", ":", "filebase", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "self", ".", "path", ")", "if", "ext...
Extract archive files to a directory.
[ "Extract", "archive", "files", "to", "a", "directory", "." ]
train
https://github.com/radhermit/vimball/blob/3998bdb8d8c4852a388a259778f971f562f9ef37/vimball/base.py#L104-L128
Fuyukai/ConfigMaster
configmaster/INIConfigFile.py
ini_load_hook
def ini_load_hook(cfg, **kwargs): """ This handles automatically opening/creating the INI configuration files. >>> import configmaster.INIConfigFile >>> cfg = configmaster.INIConfigFile.INIConfigFile("tesr.ini") # Accepts a string for input >>> fd = open("test.ini") # Accepts a file descriptor too...
python
def ini_load_hook(cfg, **kwargs): """ This handles automatically opening/creating the INI configuration files. >>> import configmaster.INIConfigFile >>> cfg = configmaster.INIConfigFile.INIConfigFile("tesr.ini") # Accepts a string for input >>> fd = open("test.ini") # Accepts a file descriptor too...
[ "def", "ini_load_hook", "(", "cfg", ",", "*", "*", "kwargs", ")", ":", "# Load the data from the INI file.", "cfg", ".", "tmpini", "=", "configparser", ".", "ConfigParser", "(", ")", "try", ":", "cfg", ".", "tmpini", ".", "read_file", "(", "cfg", ".", "fd"...
This handles automatically opening/creating the INI configuration files. >>> import configmaster.INIConfigFile >>> cfg = configmaster.INIConfigFile.INIConfigFile("tesr.ini") # Accepts a string for input >>> fd = open("test.ini") # Accepts a file descriptor too >>> cfg2 = configmaster.INIConfigFile.INI...
[ "This", "handles", "automatically", "opening", "/", "creating", "the", "INI", "configuration", "files", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/INIConfigFile.py#L7-L37
Fuyukai/ConfigMaster
configmaster/INIConfigFile.py
ini_dump_hook
def ini_dump_hook(cfg, text: bool=False): """ Dumps all the data into a INI file. This will automatically kill anything with a '_' in the keyname, replacing it with a dot. You have been warned. """ data = cfg.config.dump() # Load data back into the goddamned ini file. ndict = {} for ke...
python
def ini_dump_hook(cfg, text: bool=False): """ Dumps all the data into a INI file. This will automatically kill anything with a '_' in the keyname, replacing it with a dot. You have been warned. """ data = cfg.config.dump() # Load data back into the goddamned ini file. ndict = {} for ke...
[ "def", "ini_dump_hook", "(", "cfg", ",", "text", ":", "bool", "=", "False", ")", ":", "data", "=", "cfg", ".", "config", ".", "dump", "(", ")", "# Load data back into the goddamned ini file.", "ndict", "=", "{", "}", "for", "key", ",", "item", "in", "dat...
Dumps all the data into a INI file. This will automatically kill anything with a '_' in the keyname, replacing it with a dot. You have been warned.
[ "Dumps", "all", "the", "data", "into", "a", "INI", "file", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/INIConfigFile.py#L40-L60
waltermoreira/tartpy
tartpy/runtime.py
exception_message
def exception_message(): """Create a message with details on the exception.""" exc_type, exc_value, exc_tb = exc_info = sys.exc_info() return {'exception': {'type': exc_type, 'value': exc_value, 'traceback': exc_tb}, 'traceback': traceback.form...
python
def exception_message(): """Create a message with details on the exception.""" exc_type, exc_value, exc_tb = exc_info = sys.exc_info() return {'exception': {'type': exc_type, 'value': exc_value, 'traceback': exc_tb}, 'traceback': traceback.form...
[ "def", "exception_message", "(", ")", ":", "exc_type", ",", "exc_value", ",", "exc_tb", "=", "exc_info", "=", "sys", ".", "exc_info", "(", ")", "return", "{", "'exception'", ":", "{", "'type'", ":", "exc_type", ",", "'value'", ":", "exc_value", ",", "'tr...
Create a message with details on the exception.
[ "Create", "a", "message", "with", "details", "on", "the", "exception", "." ]
train
https://github.com/waltermoreira/tartpy/blob/d9f66c8b373bd55a7b055c0fd39b516490bb0235/tartpy/runtime.py#L97-L103
waltermoreira/tartpy
tartpy/runtime.py
behavior
def behavior(f): """Decorator for declaring a function as behavior. Use as:: @behavior def fun(x, y, self, msg): ... And create or become this behavior by passing the two arguments `x` and `y`. """ @wraps(f) def wrapper(*args): message = args[-1] ...
python
def behavior(f): """Decorator for declaring a function as behavior. Use as:: @behavior def fun(x, y, self, msg): ... And create or become this behavior by passing the two arguments `x` and `y`. """ @wraps(f) def wrapper(*args): message = args[-1] ...
[ "def", "behavior", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ")", ":", "message", "=", "args", "[", "-", "1", "]", "if", "isinstance", "(", "message", ",", "MutableMapping", ")", ":", "message", "=", "Me...
Decorator for declaring a function as behavior. Use as:: @behavior def fun(x, y, self, msg): ... And create or become this behavior by passing the two arguments `x` and `y`.
[ "Decorator", "for", "declaring", "a", "function", "as", "behavior", "." ]
train
https://github.com/waltermoreira/tartpy/blob/d9f66c8b373bd55a7b055c0fd39b516490bb0235/tartpy/runtime.py#L148-L167
bsvetchine/django-payzen
django_payzen/templatetags/payzen_extras.py
payzen_form
def payzen_form(payment_request, auto_submit=False): """TODO docstring.""" if auto_submit: template_used = "django_payzen/auto_submit_form.html" else: template_used = "django_payzen/form.html" payment_request.update() t = template.loader.get_template(template_used) return t.rende...
python
def payzen_form(payment_request, auto_submit=False): """TODO docstring.""" if auto_submit: template_used = "django_payzen/auto_submit_form.html" else: template_used = "django_payzen/form.html" payment_request.update() t = template.loader.get_template(template_used) return t.rende...
[ "def", "payzen_form", "(", "payment_request", ",", "auto_submit", "=", "False", ")", ":", "if", "auto_submit", ":", "template_used", "=", "\"django_payzen/auto_submit_form.html\"", "else", ":", "template_used", "=", "\"django_payzen/form.html\"", "payment_request", ".", ...
TODO docstring.
[ "TODO", "docstring", "." ]
train
https://github.com/bsvetchine/django-payzen/blob/944c3026120151495310cb1eb3c6370dc2db3db9/django_payzen/templatetags/payzen_extras.py#L10-L21
MacHu-GWU/angora-project
angora/math/interp.py
fromtimestamp
def fromtimestamp(timestamp): """Because python doesn't support negative timestamp to datetime so we have to implement my own method """ if timestamp >= 0: return datetime.fromtimestamp(timestamp) else: return datetime(1969, 12, 31, 20, 0) + timedelta(seconds=timestamp)
python
def fromtimestamp(timestamp): """Because python doesn't support negative timestamp to datetime so we have to implement my own method """ if timestamp >= 0: return datetime.fromtimestamp(timestamp) else: return datetime(1969, 12, 31, 20, 0) + timedelta(seconds=timestamp)
[ "def", "fromtimestamp", "(", "timestamp", ")", ":", "if", "timestamp", ">=", "0", ":", "return", "datetime", ".", "fromtimestamp", "(", "timestamp", ")", "else", ":", "return", "datetime", "(", "1969", ",", "12", ",", "31", ",", "20", ",", "0", ")", ...
Because python doesn't support negative timestamp to datetime so we have to implement my own method
[ "Because", "python", "doesn", "t", "support", "negative", "timestamp", "to", "datetime", "so", "we", "have", "to", "implement", "my", "own", "method" ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/interp.py#L111-L118
MacHu-GWU/angora-project
angora/math/interp.py
locate
def locate(x1, y1, x2, y2, x3): """An equation solver to solve: given two points on a line and x, solve the y coordinate on the same line. Suppose p1 = (x1, y1), p2 = (x2, y2), p3 = (x3, y3) on the same line. given x1, y1, x2, y2, x3, find y3:: y3 = y1 - (y1 - y2) * (x1 - x3) / (x1 - x3) "...
python
def locate(x1, y1, x2, y2, x3): """An equation solver to solve: given two points on a line and x, solve the y coordinate on the same line. Suppose p1 = (x1, y1), p2 = (x2, y2), p3 = (x3, y3) on the same line. given x1, y1, x2, y2, x3, find y3:: y3 = y1 - (y1 - y2) * (x1 - x3) / (x1 - x3) "...
[ "def", "locate", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x3", ")", ":", "return", "y1", "-", "1.0", "*", "(", "y1", "-", "y2", ")", "*", "(", "x1", "-", "x3", ")", "/", "(", "x1", "-", "x2", ")" ]
An equation solver to solve: given two points on a line and x, solve the y coordinate on the same line. Suppose p1 = (x1, y1), p2 = (x2, y2), p3 = (x3, y3) on the same line. given x1, y1, x2, y2, x3, find y3:: y3 = y1 - (y1 - y2) * (x1 - x3) / (x1 - x3)
[ "An", "equation", "solver", "to", "solve", ":", "given", "two", "points", "on", "a", "line", "and", "x", "solve", "the", "y", "coordinate", "on", "the", "same", "line", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/interp.py#L125-L134