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
subdownloader/subdownloader
subdownloader/client/arguments.py
get_argument_parser
def get_argument_parser(): """ Get a parser that is able to parse program arguments. :return: instance of arparse.ArgumentParser """ parser = argparse.ArgumentParser(description=project.get_description(), epilog=_('Visit us at {website}.').format(website=project....
python
def get_argument_parser(): """ Get a parser that is able to parse program arguments. :return: instance of arparse.ArgumentParser """ parser = argparse.ArgumentParser(description=project.get_description(), epilog=_('Visit us at {website}.').format(website=project....
[ "def", "get_argument_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "project", ".", "get_description", "(", ")", ",", "epilog", "=", "_", "(", "'Visit us at {website}.'", ")", ".", "format", "(", "website", ...
Get a parser that is able to parse program arguments. :return: instance of arparse.ArgumentParser
[ "Get", "a", "parser", "that", "is", "able", "to", "parse", "program", "arguments", ".", ":", "return", ":", "instance", "of", "arparse", ".", "ArgumentParser" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/arguments.py#L192-L290
cenkalti/kuyruk
kuyruk/kuyruk.py
Kuyruk.task
def task(self, queue: str = 'kuyruk', **kwargs: Any) -> Callable: """ Wrap functions with this decorator to convert them to *tasks*. After wrapping, calling the function will send a message to a queue instead of running the function. :param queue: Queue name for the tasks. ...
python
def task(self, queue: str = 'kuyruk', **kwargs: Any) -> Callable: """ Wrap functions with this decorator to convert them to *tasks*. After wrapping, calling the function will send a message to a queue instead of running the function. :param queue: Queue name for the tasks. ...
[ "def", "task", "(", "self", ",", "queue", ":", "str", "=", "'kuyruk'", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Callable", ":", "def", "wrapper", "(", "f", ":", "Callable", ")", "->", "Task", ":", "return", "Task", "(", "f", ",", "self", ...
Wrap functions with this decorator to convert them to *tasks*. After wrapping, calling the function will send a message to a queue instead of running the function. :param queue: Queue name for the tasks. :param kwargs: Keyword arguments will be passed to :class:`~kuyruk.Task...
[ "Wrap", "functions", "with", "this", "decorator", "to", "convert", "them", "to", "*", "tasks", "*", ".", "After", "wrapping", "calling", "the", "function", "will", "send", "a", "message", "to", "a", "queue", "instead", "of", "running", "the", "function", "...
train
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L37-L53
cenkalti/kuyruk
kuyruk/kuyruk.py
Kuyruk.channel
def channel(self) -> Iterator[amqp.Channel]: """Returns a new channel from a new connection as a context manager.""" with self.connection() as conn: ch = conn.channel() logger.info('Opened new channel') with _safe_close(ch): yield ch
python
def channel(self) -> Iterator[amqp.Channel]: """Returns a new channel from a new connection as a context manager.""" with self.connection() as conn: ch = conn.channel() logger.info('Opened new channel') with _safe_close(ch): yield ch
[ "def", "channel", "(", "self", ")", "->", "Iterator", "[", "amqp", ".", "Channel", "]", ":", "with", "self", ".", "connection", "(", ")", "as", "conn", ":", "ch", "=", "conn", ".", "channel", "(", ")", "logger", ".", "info", "(", "'Opened new channel...
Returns a new channel from a new connection as a context manager.
[ "Returns", "a", "new", "channel", "from", "a", "new", "connection", "as", "a", "context", "manager", "." ]
train
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L56-L62
cenkalti/kuyruk
kuyruk/kuyruk.py
Kuyruk.connection
def connection(self) -> Iterator[amqp.Connection]: """Returns a new connection as a context manager.""" TCP_USER_TIMEOUT = 18 # constant is available on Python 3.6+. socket_settings = {TCP_USER_TIMEOUT: self.config.TCP_USER_TIMEOUT} if sys.platform.startswith('darwin'): del...
python
def connection(self) -> Iterator[amqp.Connection]: """Returns a new connection as a context manager.""" TCP_USER_TIMEOUT = 18 # constant is available on Python 3.6+. socket_settings = {TCP_USER_TIMEOUT: self.config.TCP_USER_TIMEOUT} if sys.platform.startswith('darwin'): del...
[ "def", "connection", "(", "self", ")", "->", "Iterator", "[", "amqp", ".", "Connection", "]", ":", "TCP_USER_TIMEOUT", "=", "18", "# constant is available on Python 3.6+.", "socket_settings", "=", "{", "TCP_USER_TIMEOUT", ":", "self", ".", "config", ".", "TCP_USER...
Returns a new connection as a context manager.
[ "Returns", "a", "new", "connection", "as", "a", "context", "manager", "." ]
train
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L65-L87
subdownloader/subdownloader
subdownloader/filescan.py
scan_videopath
def scan_videopath(videopath, callback, recursive=False): """ Scan the videopath string for video files. :param videopath: Path object :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list of subti...
python
def scan_videopath(videopath, callback, recursive=False): """ Scan the videopath string for video files. :param videopath: Path object :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list of subti...
[ "def", "scan_videopath", "(", "videopath", ",", "callback", ",", "recursive", "=", "False", ")", ":", "log", ".", "debug", "(", "'scan_videopath(videopath=\"{videopath}\", recursive={recursive})'", ".", "format", "(", "videopath", "=", "videopath", ",", "recursive", ...
Scan the videopath string for video files. :param videopath: Path object :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list of subtitles (videos have matched subtitles)
[ "Scan", "the", "videopath", "string", "for", "video", "files", ".", ":", "param", "videopath", ":", "Path", "object", ":", "param", "callback", ":", "Instance", "of", "ProgressCallback", ":", "param", "recursive", ":", "True", "if", "the", "scanning", "shoul...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L30-L56
subdownloader/subdownloader
subdownloader/filescan.py
__scan_folder
def __scan_folder(folder_path, callback, recursive=False): """ Scan a folder for videos and subtitles :param folder_path: String of a directory :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list...
python
def __scan_folder(folder_path, callback, recursive=False): """ Scan a folder for videos and subtitles :param folder_path: String of a directory :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list...
[ "def", "__scan_folder", "(", "folder_path", ",", "callback", ",", "recursive", "=", "False", ")", ":", "log", ".", "debug", "(", "'__scan_folder(folder_path=\"{folder_path}\", recursive={recursive})'", ".", "format", "(", "folder_path", "=", "folder_path", ",", "recur...
Scan a folder for videos and subtitles :param folder_path: String of a directory :param callback: Instance of ProgressCallback :param recursive: True if the scanning should happen recursive :return: tuple with list of videos and list of subtitles (videos have matched subtitles)
[ "Scan", "a", "folder", "for", "videos", "and", "subtitles", ":", "param", "folder_path", ":", "String", "of", "a", "directory", ":", "param", "callback", ":", "Instance", "of", "ProgressCallback", ":", "param", "recursive", ":", "True", "if", "the", "scannin...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L59-L81
subdownloader/subdownloader
subdownloader/filescan.py
merge_path_subvideo
def merge_path_subvideo(path_subvideos, callback): """ Merge subtitles into videos. :param path_subvideos: a dict with paths as key and a list of lists of videos and subtitles :param callback: Instance of ProgressCallback :return: tuple with list of videos and list of subtitles (videos have matched ...
python
def merge_path_subvideo(path_subvideos, callback): """ Merge subtitles into videos. :param path_subvideos: a dict with paths as key and a list of lists of videos and subtitles :param callback: Instance of ProgressCallback :return: tuple with list of videos and list of subtitles (videos have matched ...
[ "def", "merge_path_subvideo", "(", "path_subvideos", ",", "callback", ")", ":", "log", ".", "debug", "(", "'merge_path_subvideo(path_subvideos=<#paths={nb_paths}>)'", ".", "format", "(", "nb_paths", "=", "len", "(", "path_subvideos", ")", ")", ")", "# FIXME: add loggi...
Merge subtitles into videos. :param path_subvideos: a dict with paths as key and a list of lists of videos and subtitles :param callback: Instance of ProgressCallback :return: tuple with list of videos and list of subtitles (videos have matched subtitles)
[ "Merge", "subtitles", "into", "videos", ".", ":", "param", "path_subvideos", ":", "a", "dict", "with", "paths", "as", "key", "and", "a", "list", "of", "lists", "of", "videos", "and", "subtitles", ":", "param", "callback", ":", "Instance", "of", "ProgressCa...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L84-L121
subdownloader/subdownloader
subdownloader/filescan.py
filter_files_extensions
def filter_files_extensions(files, extension_lists): """ Put the files in buckets according to extension_lists files=[movie.avi, movie.srt], extension_lists=[[avi],[srt]] ==> [[movie.avi],[movie.srt]] :param files: A list of files :param extension_lists: A list of list of extensions :return: The...
python
def filter_files_extensions(files, extension_lists): """ Put the files in buckets according to extension_lists files=[movie.avi, movie.srt], extension_lists=[[avi],[srt]] ==> [[movie.avi],[movie.srt]] :param files: A list of files :param extension_lists: A list of list of extensions :return: The...
[ "def", "filter_files_extensions", "(", "files", ",", "extension_lists", ")", ":", "log", ".", "debug", "(", "'filter_files_extensions: files=\"{}\"'", ".", "format", "(", "files", ")", ")", "result", "=", "[", "[", "]", "for", "_", "in", "extension_lists", "]"...
Put the files in buckets according to extension_lists files=[movie.avi, movie.srt], extension_lists=[[avi],[srt]] ==> [[movie.avi],[movie.srt]] :param files: A list of files :param extension_lists: A list of list of extensions :return: The files filtered and sorted according to extension_lists
[ "Put", "the", "files", "in", "buckets", "according", "to", "extension_lists", "files", "=", "[", "movie", ".", "avi", "movie", ".", "srt", "]", "extension_lists", "=", "[[", "avi", "]", "[", "srt", "]]", "==", ">", "[[", "movie", ".", "avi", "]", "["...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L124-L140
subdownloader/subdownloader
subdownloader/subtitle2.py
SubtitleFile.detect_language_filename
def detect_language_filename(cls, filename): """ Detect the language of a subtitle filename :param filename: filename of a subtitle :return: Language object, None if language could not be detected. """ log.debug('detect_language(filename="{}") ...'.format(filename)) ...
python
def detect_language_filename(cls, filename): """ Detect the language of a subtitle filename :param filename: filename of a subtitle :return: Language object, None if language could not be detected. """ log.debug('detect_language(filename="{}") ...'.format(filename)) ...
[ "def", "detect_language_filename", "(", "cls", ",", "filename", ")", ":", "log", ".", "debug", "(", "'detect_language(filename=\"{}\") ...'", ".", "format", "(", "filename", ")", ")", "root", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "filename"...
Detect the language of a subtitle filename :param filename: filename of a subtitle :return: Language object, None if language could not be detected.
[ "Detect", "the", "language", "of", "a", "subtitle", "filename", ":", "param", "filename", ":", "filename", "of", "a", "subtitle", ":", "return", ":", "Language", "object", "None", "if", "language", "could", "not", "be", "detected", "." ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/subtitle2.py#L57-L76
subdownloader/subdownloader
subdownloader/subtitle2.py
SubtitleFileStorage.matches_video_filename
def matches_video_filename(self, video): """ Detect whether the filename of videofile matches with this SubtitleFile. :param video: VideoFile instance :return: True if match """ vid_fn = video.get_filename() vid_base, _ = os.path.splitext(vid_fn) vid_base...
python
def matches_video_filename(self, video): """ Detect whether the filename of videofile matches with this SubtitleFile. :param video: VideoFile instance :return: True if match """ vid_fn = video.get_filename() vid_base, _ = os.path.splitext(vid_fn) vid_base...
[ "def", "matches_video_filename", "(", "self", ",", "video", ")", ":", "vid_fn", "=", "video", ".", "get_filename", "(", ")", "vid_base", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "vid_fn", ")", "vid_base", "=", "vid_base", ".", "lower", "...
Detect whether the filename of videofile matches with this SubtitleFile. :param video: VideoFile instance :return: True if match
[ "Detect", "whether", "the", "filename", "of", "videofile", "matches", "with", "this", "SubtitleFile", ".", ":", "param", "video", ":", "VideoFile", "instance", ":", "return", ":", "True", "if", "match" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/subtitle2.py#L159-L197
subdownloader/subdownloader
subdownloader/client/logger.py
logging_file_install
def logging_file_install(path): """ Install logger that will write to file. If this function has already installed a handler, replace it. :param path: path to the log file, Use None for default file location. """ if path is None: path = configuration_get_default_folder() / LOGGING_DEFAULTNAM...
python
def logging_file_install(path): """ Install logger that will write to file. If this function has already installed a handler, replace it. :param path: path to the log file, Use None for default file location. """ if path is None: path = configuration_get_default_folder() / LOGGING_DEFAULTNAM...
[ "def", "logging_file_install", "(", "path", ")", ":", "if", "path", "is", "None", ":", "path", "=", "configuration_get_default_folder", "(", ")", "/", "LOGGING_DEFAULTNAME", "if", "not", "path", ".", "parent", ".", "exists", "(", ")", ":", "log", ".", "err...
Install logger that will write to file. If this function has already installed a handler, replace it. :param path: path to the log file, Use None for default file location.
[ "Install", "logger", "that", "will", "write", "to", "file", ".", "If", "this", "function", "has", "already", "installed", "a", "handler", "replace", "it", ".", ":", "param", "path", ":", "path", "to", "the", "log", "file", "Use", "None", "for", "default"...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/logger.py#L24-L51
subdownloader/subdownloader
subdownloader/client/logger.py
logging_stream_install
def logging_stream_install(loglevel): """ Install logger that will output to stderr. If this function ha already installed a handler, replace it. :param loglevel: log level for the stream """ formatter = logging.Formatter(LOGGING_FORMAT) logger = logging.getLogger() logger.removeHandler(LOG...
python
def logging_stream_install(loglevel): """ Install logger that will output to stderr. If this function ha already installed a handler, replace it. :param loglevel: log level for the stream """ formatter = logging.Formatter(LOGGING_FORMAT) logger = logging.getLogger() logger.removeHandler(LOG...
[ "def", "logging_stream_install", "(", "loglevel", ")", ":", "formatter", "=", "logging", ".", "Formatter", "(", "LOGGING_FORMAT", ")", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "removeHandler", "(", "LOGGING_HANDLERS", "[", "'stream'",...
Install logger that will output to stderr. If this function ha already installed a handler, replace it. :param loglevel: log level for the stream
[ "Install", "logger", "that", "will", "output", "to", "stderr", ".", "If", "this", "function", "ha", "already", "installed", "a", "handler", "replace", "it", ".", ":", "param", "loglevel", ":", "log", "level", "for", "the", "stream" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/logger.py#L54-L74
stanfordnlp/python-corenlp-protobuf
corenlp_protobuf/__init__.py
parseFromDelimitedString
def parseFromDelimitedString(obj, buf, offset=0): """ Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consu...
python
def parseFromDelimitedString(obj, buf, offset=0): """ Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consu...
[ "def", "parseFromDelimitedString", "(", "obj", ",", "buf", ",", "offset", "=", "0", ")", ":", "size", ",", "pos", "=", "_DecodeVarint", "(", "buf", ",", "offset", ")", "obj", ".", "ParseFromString", "(", "buf", "[", "offset", "+", "pos", ":", "offset",...
Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consumed.
[ "Stanford", "CoreNLP", "uses", "the", "Java", "writeDelimitedTo", "function", "which", "writes", "the", "size", "(", "and", "offset", ")", "of", "the", "buffer", "before", "writing", "the", "object", ".", "This", "function", "handles", "parsing", "this", "mess...
train
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L9-L19
stanfordnlp/python-corenlp-protobuf
corenlp_protobuf/__init__.py
writeToDelimitedString
def writeToDelimitedString(obj, stream=None): """ Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consumed....
python
def writeToDelimitedString(obj, stream=None): """ Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consumed....
[ "def", "writeToDelimitedString", "(", "obj", ",", "stream", "=", "None", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "BytesIO", "(", ")", "_EncodeVarint", "(", "stream", ".", "write", ",", "obj", ".", "ByteSize", "(", ")", ",", "True", ...
Stanford CoreNLP uses the Java "writeDelimitedTo" function, which writes the size (and offset) of the buffer before writing the object. This function handles parsing this message starting from offset 0. @returns how many bytes of @buf were consumed.
[ "Stanford", "CoreNLP", "uses", "the", "Java", "writeDelimitedTo", "function", "which", "writes", "the", "size", "(", "and", "offset", ")", "of", "the", "buffer", "before", "writing", "the", "object", ".", "This", "function", "handles", "parsing", "this", "mess...
train
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L21-L34
stanfordnlp/python-corenlp-protobuf
corenlp_protobuf/__init__.py
to_text
def to_text(sentence): """ Helper routine that converts a Sentence protobuf to a string from its tokens. """ text = "" for i, tok in enumerate(sentence.token): if i != 0: text += tok.before text += tok.word return text
python
def to_text(sentence): """ Helper routine that converts a Sentence protobuf to a string from its tokens. """ text = "" for i, tok in enumerate(sentence.token): if i != 0: text += tok.before text += tok.word return text
[ "def", "to_text", "(", "sentence", ")", ":", "text", "=", "\"\"", "for", "i", ",", "tok", "in", "enumerate", "(", "sentence", ".", "token", ")", ":", "if", "i", "!=", "0", ":", "text", "+=", "tok", ".", "before", "text", "+=", "tok", ".", "word",...
Helper routine that converts a Sentence protobuf to a string from its tokens.
[ "Helper", "routine", "that", "converts", "a", "Sentence", "protobuf", "to", "a", "string", "from", "its", "tokens", "." ]
train
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L36-L46
subdownloader/subdownloader
subdownloader/client/gui/splashScreen.py
SplashScreen.showMessage
def showMessage(self, message, *args): """ Public method to show a message in the bottom part of the splashscreen. @param message message to be shown (string or QString) """ QSplashScreen.showMessage( self, message, Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute, ...
python
def showMessage(self, message, *args): """ Public method to show a message in the bottom part of the splashscreen. @param message message to be shown (string or QString) """ QSplashScreen.showMessage( self, message, Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute, ...
[ "def", "showMessage", "(", "self", ",", "message", ",", "*", "args", ")", ":", "QSplashScreen", ".", "showMessage", "(", "self", ",", "message", ",", "Qt", ".", "AlignBottom", "|", "Qt", ".", "AlignRight", "|", "Qt", ".", "AlignAbsolute", ",", "QColor", ...
Public method to show a message in the bottom part of the splashscreen. @param message message to be shown (string or QString)
[ "Public", "method", "to", "show", "a", "message", "in", "the", "bottom", "part", "of", "the", "splashscreen", "." ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/gui/splashScreen.py#L22-L29
subdownloader/subdownloader
subdownloader/metadata.py
PyMediaInfoParser.parse_path
def parse_path(path): """ Parse a video at filepath, using pymediainfo framework. :param path: path of video to parse as string """ import pymediainfo metadata = Metadata() log.debug('pymediainfo: parsing "{path}" ...'.format(path=path)) parseRes = pymedi...
python
def parse_path(path): """ Parse a video at filepath, using pymediainfo framework. :param path: path of video to parse as string """ import pymediainfo metadata = Metadata() log.debug('pymediainfo: parsing "{path}" ...'.format(path=path)) parseRes = pymedi...
[ "def", "parse_path", "(", "path", ")", ":", "import", "pymediainfo", "metadata", "=", "Metadata", "(", ")", "log", ".", "debug", "(", "'pymediainfo: parsing \"{path}\" ...'", ".", "format", "(", "path", "=", "path", ")", ")", "parseRes", "=", "pymediainfo", ...
Parse a video at filepath, using pymediainfo framework. :param path: path of video to parse as string
[ "Parse", "a", "video", "at", "filepath", "using", "pymediainfo", "framework", ".", ":", "param", "path", ":", "path", "of", "video", "to", "parse", "as", "string" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/metadata.py#L82-L112
subdownloader/subdownloader
subdownloader/video2.py
VideoFile._read_metadata
def _read_metadata(self): """ Private function to read (if not read already) and store the metadata of the local VideoFile. """ if self._is_metadata_init(): return try: log.debug('Reading metadata of "{path}" ...'.format(path=self._filepath)) d...
python
def _read_metadata(self): """ Private function to read (if not read already) and store the metadata of the local VideoFile. """ if self._is_metadata_init(): return try: log.debug('Reading metadata of "{path}" ...'.format(path=self._filepath)) d...
[ "def", "_read_metadata", "(", "self", ")", ":", "if", "self", ".", "_is_metadata_init", "(", ")", ":", "return", "try", ":", "log", ".", "debug", "(", "'Reading metadata of \"{path}\" ...'", ".", "format", "(", "path", "=", "self", ".", "_filepath", ")", "...
Private function to read (if not read already) and store the metadata of the local VideoFile.
[ "Private", "function", "to", "read", "(", "if", "not", "read", "already", ")", "and", "store", "the", "metadata", "of", "the", "local", "VideoFile", "." ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L81-L98
subdownloader/subdownloader
subdownloader/video2.py
VideoFile.get_size
def get_size(self): """ Get size of this VideoFile in bytes :return: size as integer """ if self._size is None: self._size = self._filepath.stat().st_size return self._size
python
def get_size(self): """ Get size of this VideoFile in bytes :return: size as integer """ if self._size is None: self._size = self._filepath.stat().st_size return self._size
[ "def", "get_size", "(", "self", ")", ":", "if", "self", ".", "_size", "is", "None", ":", "self", ".", "_size", "=", "self", ".", "_filepath", ".", "stat", "(", ")", ".", "st_size", "return", "self", ".", "_size" ]
Get size of this VideoFile in bytes :return: size as integer
[ "Get", "size", "of", "this", "VideoFile", "in", "bytes", ":", "return", ":", "size", "as", "integer" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L122-L129
subdownloader/subdownloader
subdownloader/video2.py
VideoFile.get_osdb_hash
def get_osdb_hash(self): """ Get the hash of this local videofile :return: hash as string """ if self._osdb_hash is None: self._osdb_hash = self._calculate_osdb_hash() return self._osdb_hash
python
def get_osdb_hash(self): """ Get the hash of this local videofile :return: hash as string """ if self._osdb_hash is None: self._osdb_hash = self._calculate_osdb_hash() return self._osdb_hash
[ "def", "get_osdb_hash", "(", "self", ")", ":", "if", "self", ".", "_osdb_hash", "is", "None", ":", "self", ".", "_osdb_hash", "=", "self", ".", "_calculate_osdb_hash", "(", ")", "return", "self", ".", "_osdb_hash" ]
Get the hash of this local videofile :return: hash as string
[ "Get", "the", "hash", "of", "this", "local", "videofile", ":", "return", ":", "hash", "as", "string" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L131-L138
subdownloader/subdownloader
subdownloader/video2.py
VideoFile._calculate_osdb_hash
def _calculate_osdb_hash(self): """ Calculate OSDB (OpenSubtitleDataBase) hash of this VideoFile :return: hash as string """ log.debug('_calculate_OSDB_hash() of "{path}" ...'.format(path=self._filepath)) f = self._filepath.open(mode='rb') file_size = self.get_si...
python
def _calculate_osdb_hash(self): """ Calculate OSDB (OpenSubtitleDataBase) hash of this VideoFile :return: hash as string """ log.debug('_calculate_OSDB_hash() of "{path}" ...'.format(path=self._filepath)) f = self._filepath.open(mode='rb') file_size = self.get_si...
[ "def", "_calculate_osdb_hash", "(", "self", ")", ":", "log", ".", "debug", "(", "'_calculate_OSDB_hash() of \"{path}\" ...'", ".", "format", "(", "path", "=", "self", ".", "_filepath", ")", ")", "f", "=", "self", ".", "_filepath", ".", "open", "(", "mode", ...
Calculate OSDB (OpenSubtitleDataBase) hash of this VideoFile :return: hash as string
[ "Calculate", "OSDB", "(", "OpenSubtitleDataBase", ")", "hash", "of", "this", "VideoFile", ":", "return", ":", "hash", "as", "string" ]
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L192-L227
cenkalti/kuyruk
kuyruk/importer.py
import_module
def import_module(name: str) -> ModuleType: """Import module by it's name from following places in order: - main module - current working directory - Python path """ logger.debug("Importing module: %s", name) if name == main_module_name(): return main_module return import...
python
def import_module(name: str) -> ModuleType: """Import module by it's name from following places in order: - main module - current working directory - Python path """ logger.debug("Importing module: %s", name) if name == main_module_name(): return main_module return import...
[ "def", "import_module", "(", "name", ":", "str", ")", "->", "ModuleType", ":", "logger", ".", "debug", "(", "\"Importing module: %s\"", ",", "name", ")", "if", "name", "==", "main_module_name", "(", ")", ":", "return", "main_module", "return", "importlib", "...
Import module by it's name from following places in order: - main module - current working directory - Python path
[ "Import", "module", "by", "it", "s", "name", "from", "following", "places", "in", "order", ":", "-", "main", "module", "-", "current", "working", "directory", "-", "Python", "path" ]
train
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/importer.py#L13-L24
cenkalti/kuyruk
kuyruk/importer.py
main_module_name
def main_module_name() -> str: """Returns main module and module name pair.""" if not hasattr(main_module, '__file__'): # running from interactive shell return None main_filename = os.path.basename(main_module.__file__) module_name, ext = os.path.splitext(main_filename) return modul...
python
def main_module_name() -> str: """Returns main module and module name pair.""" if not hasattr(main_module, '__file__'): # running from interactive shell return None main_filename = os.path.basename(main_module.__file__) module_name, ext = os.path.splitext(main_filename) return modul...
[ "def", "main_module_name", "(", ")", "->", "str", ":", "if", "not", "hasattr", "(", "main_module", ",", "'__file__'", ")", ":", "# running from interactive shell", "return", "None", "main_filename", "=", "os", ".", "path", ".", "basename", "(", "main_module", ...
Returns main module and module name pair.
[ "Returns", "main", "module", "and", "module", "name", "pair", "." ]
train
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/importer.py#L40-L48
subdownloader/subdownloader
subdownloader/util.py
write_stream
def write_stream(src_file, destination_path): """ Write the file-like src_file object to the string dest_path :param src_file: file-like data to be written :param destination_path: string of the destionation file """ with open(destination_path, 'wb') as destination_file: shutil.copyfileo...
python
def write_stream(src_file, destination_path): """ Write the file-like src_file object to the string dest_path :param src_file: file-like data to be written :param destination_path: string of the destionation file """ with open(destination_path, 'wb') as destination_file: shutil.copyfileo...
[ "def", "write_stream", "(", "src_file", ",", "destination_path", ")", ":", "with", "open", "(", "destination_path", ",", "'wb'", ")", "as", "destination_file", ":", "shutil", ".", "copyfileobj", "(", "fsrc", "=", "src_file", ",", "fdst", "=", "destination_file...
Write the file-like src_file object to the string dest_path :param src_file: file-like data to be written :param destination_path: string of the destionation file
[ "Write", "the", "file", "-", "like", "src_file", "object", "to", "the", "string", "dest_path", ":", "param", "src_file", ":", "file", "-", "like", "data", "to", "be", "written", ":", "param", "destination_path", ":", "string", "of", "the", "destionation", ...
train
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/util.py#L43-L50
jefflovejapan/drench
drench/switchboard.py
build_dirs
def build_dirs(files): ''' Build necessary directories based on a list of file paths ''' for i in files: if type(i) is list: build_dirs(i) continue else: if len(i['path']) > 1: addpath = os.path.join(os.getcwd(), *i['path'][:-1]) ...
python
def build_dirs(files): ''' Build necessary directories based on a list of file paths ''' for i in files: if type(i) is list: build_dirs(i) continue else: if len(i['path']) > 1: addpath = os.path.join(os.getcwd(), *i['path'][:-1]) ...
[ "def", "build_dirs", "(", "files", ")", ":", "for", "i", "in", "files", ":", "if", "type", "(", "i", ")", "is", "list", ":", "build_dirs", "(", "i", ")", "continue", "else", ":", "if", "len", "(", "i", "[", "'path'", "]", ")", ">", "1", ":", ...
Build necessary directories based on a list of file paths
[ "Build", "necessary", "directories", "based", "on", "a", "list", "of", "file", "paths" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L21-L35
jefflovejapan/drench
drench/switchboard.py
get_want_file_pos
def get_want_file_pos(file_list): ''' Ask the user which files in file_list he or she is interested in. Return indices for the files inside file_list ''' want_file_pos = [] print '\nFiles contained:\n' for i in file_list: print(os.path.join(*i['path'])) while 1: all_answe...
python
def get_want_file_pos(file_list): ''' Ask the user which files in file_list he or she is interested in. Return indices for the files inside file_list ''' want_file_pos = [] print '\nFiles contained:\n' for i in file_list: print(os.path.join(*i['path'])) while 1: all_answe...
[ "def", "get_want_file_pos", "(", "file_list", ")", ":", "want_file_pos", "=", "[", "]", "print", "'\\nFiles contained:\\n'", "for", "i", "in", "file_list", ":", "print", "(", "os", ".", "path", ".", "join", "(", "*", "i", "[", "'path'", "]", ")", ")", ...
Ask the user which files in file_list he or she is interested in. Return indices for the files inside file_list
[ "Ask", "the", "user", "which", "files", "in", "file_list", "he", "or", "she", "is", "interested", "in", ".", "Return", "indices", "for", "the", "files", "inside", "file_list" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L38-L68
jefflovejapan/drench
drench/switchboard.py
get_file_starts
def get_file_starts(file_list): ''' Return the starting position (in bytes) of a list of files by iteratively summing their lengths ''' starts = [] total = 0 for i in file_list: starts.append(total) total += i['length'] print starts return starts
python
def get_file_starts(file_list): ''' Return the starting position (in bytes) of a list of files by iteratively summing their lengths ''' starts = [] total = 0 for i in file_list: starts.append(total) total += i['length'] print starts return starts
[ "def", "get_file_starts", "(", "file_list", ")", ":", "starts", "=", "[", "]", "total", "=", "0", "for", "i", "in", "file_list", ":", "starts", ".", "append", "(", "total", ")", "total", "+=", "i", "[", "'length'", "]", "print", "starts", "return", "...
Return the starting position (in bytes) of a list of files by iteratively summing their lengths
[ "Return", "the", "starting", "position", "(", "in", "bytes", ")", "of", "a", "list", "of", "files", "by", "iteratively", "summing", "their", "lengths" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L71-L82
jefflovejapan/drench
drench/switchboard.py
get_rightmost_index
def get_rightmost_index(byte_index=0, file_starts=[0]): ''' Retrieve the highest-indexed file that starts at or before byte_index. ''' i = 1 while i <= len(file_starts): start = file_starts[-i] if start <= byte_index: return len(file_starts) - i else: ...
python
def get_rightmost_index(byte_index=0, file_starts=[0]): ''' Retrieve the highest-indexed file that starts at or before byte_index. ''' i = 1 while i <= len(file_starts): start = file_starts[-i] if start <= byte_index: return len(file_starts) - i else: ...
[ "def", "get_rightmost_index", "(", "byte_index", "=", "0", ",", "file_starts", "=", "[", "0", "]", ")", ":", "i", "=", "1", "while", "i", "<=", "len", "(", "file_starts", ")", ":", "start", "=", "file_starts", "[", "-", "i", "]", "if", "start", "<=...
Retrieve the highest-indexed file that starts at or before byte_index.
[ "Retrieve", "the", "highest", "-", "indexed", "file", "that", "starts", "at", "or", "before", "byte_index", "." ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L85-L98
jefflovejapan/drench
drench/switchboard.py
Switchboard.get_next_want_file
def get_next_want_file(self, byte_index, block): ''' Returns the leftmost file in the user's list of wanted files (want_file_pos). If the first file it finds isn't in the list, it will keep searching until the length of 'block' is exceeded. ''' while block: ri...
python
def get_next_want_file(self, byte_index, block): ''' Returns the leftmost file in the user's list of wanted files (want_file_pos). If the first file it finds isn't in the list, it will keep searching until the length of 'block' is exceeded. ''' while block: ri...
[ "def", "get_next_want_file", "(", "self", ",", "byte_index", ",", "block", ")", ":", "while", "block", ":", "rightmost", "=", "get_rightmost_index", "(", "byte_index", "=", "byte_index", ",", "file_starts", "=", "self", ".", "file_starts", ")", "if", "rightmos...
Returns the leftmost file in the user's list of wanted files (want_file_pos). If the first file it finds isn't in the list, it will keep searching until the length of 'block' is exceeded.
[ "Returns", "the", "leftmost", "file", "in", "the", "user", "s", "list", "of", "wanted", "files", "(", "want_file_pos", ")", ".", "If", "the", "first", "file", "it", "finds", "isn", "t", "in", "the", "list", "it", "will", "keep", "searching", "until", "...
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L208-L230
jefflovejapan/drench
drench/switchboard.py
Switchboard.vis_init
def vis_init(self): ''' Sends the state of the BTC at the time the visualizer connects, initializing it. ''' init_dict = {} init_dict['kind'] = 'init' assert len(self.want_file_pos) == len(self.heads_and_tails) init_dict['want_file_pos'] = self.want_file_p...
python
def vis_init(self): ''' Sends the state of the BTC at the time the visualizer connects, initializing it. ''' init_dict = {} init_dict['kind'] = 'init' assert len(self.want_file_pos) == len(self.heads_and_tails) init_dict['want_file_pos'] = self.want_file_p...
[ "def", "vis_init", "(", "self", ")", ":", "init_dict", "=", "{", "}", "init_dict", "[", "'kind'", "]", "=", "'init'", "assert", "len", "(", "self", ".", "want_file_pos", ")", "==", "len", "(", "self", ".", "heads_and_tails", ")", "init_dict", "[", "'wa...
Sends the state of the BTC at the time the visualizer connects, initializing it.
[ "Sends", "the", "state", "of", "the", "BTC", "at", "the", "time", "the", "visualizer", "connects", "initializing", "it", "." ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L291-L303
jefflovejapan/drench
drench/switchboard.py
Switchboard.broadcast
def broadcast(self, data_dict): ''' Send to the visualizer (if there is one) or enqueue for later ''' if self.vis_socket: self.queued_messages.append(data_dict) self.send_all_updates()
python
def broadcast(self, data_dict): ''' Send to the visualizer (if there is one) or enqueue for later ''' if self.vis_socket: self.queued_messages.append(data_dict) self.send_all_updates()
[ "def", "broadcast", "(", "self", ",", "data_dict", ")", ":", "if", "self", ".", "vis_socket", ":", "self", ".", "queued_messages", ".", "append", "(", "data_dict", ")", "self", ".", "send_all_updates", "(", ")" ]
Send to the visualizer (if there is one) or enqueue for later
[ "Send", "to", "the", "visualizer", "(", "if", "there", "is", "one", ")", "or", "enqueue", "for", "later" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L305-L311
jefflovejapan/drench
drench/tparser.py
bencode
def bencode(canonical): ''' Turns a dictionary into a bencoded str with alphabetized keys e.g., {'spam': 'eggs', 'cow': 'moo'} --> d3:cow3:moo4:spam4:eggse ''' in_dict = dict(canonical) def encode_str(in_str): out_str = str(len(in_str)) + ':' + in_str return out_str ...
python
def bencode(canonical): ''' Turns a dictionary into a bencoded str with alphabetized keys e.g., {'spam': 'eggs', 'cow': 'moo'} --> d3:cow3:moo4:spam4:eggse ''' in_dict = dict(canonical) def encode_str(in_str): out_str = str(len(in_str)) + ':' + in_str return out_str ...
[ "def", "bencode", "(", "canonical", ")", ":", "in_dict", "=", "dict", "(", "canonical", ")", "def", "encode_str", "(", "in_str", ")", ":", "out_str", "=", "str", "(", "len", "(", "in_str", ")", ")", "+", "':'", "+", "in_str", "return", "out_str", "de...
Turns a dictionary into a bencoded str with alphabetized keys e.g., {'spam': 'eggs', 'cow': 'moo'} --> d3:cow3:moo4:spam4:eggse
[ "Turns", "a", "dictionary", "into", "a", "bencoded", "str", "with", "alphabetized", "keys", "e", ".", "g", ".", "{", "spam", ":", "eggs", "cow", ":", "moo", "}", "--", ">", "d3", ":", "cow3", ":", "moo4", ":", "spam4", ":", "eggse" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/tparser.py#L8-L51
jefflovejapan/drench
drench/tparser.py
bdecode
def bdecode(bstring): ''' Bdecodes a bencoded string e.g., d3:cow3:moo4:spam4:eggse -> {'cow': 'moo', 'spam': 'eggs'} ''' def get_val(): i = reader.next() if i.isdigit(): str_len = get_len(i) return get_str(str_len) if i == 'd': re...
python
def bdecode(bstring): ''' Bdecodes a bencoded string e.g., d3:cow3:moo4:spam4:eggse -> {'cow': 'moo', 'spam': 'eggs'} ''' def get_val(): i = reader.next() if i.isdigit(): str_len = get_len(i) return get_str(str_len) if i == 'd': re...
[ "def", "bdecode", "(", "bstring", ")", ":", "def", "get_val", "(", ")", ":", "i", "=", "reader", ".", "next", "(", ")", "if", "i", ".", "isdigit", "(", ")", ":", "str_len", "=", "get_len", "(", "i", ")", "return", "get_str", "(", "str_len", ")", ...
Bdecodes a bencoded string e.g., d3:cow3:moo4:spam4:eggse -> {'cow': 'moo', 'spam': 'eggs'}
[ "Bdecodes", "a", "bencoded", "string", "e", ".", "g", ".", "d3", ":", "cow3", ":", "moo4", ":", "spam4", ":", "eggse", "-", ">", "{", "cow", ":", "moo", "spam", ":", "eggs", "}" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/tparser.py#L54-L120
jefflovejapan/drench
drench/drench.py
Torrent.build_payload
def build_payload(self): ''' Builds the payload that will be sent in tracker_request ''' payload = {} hashed_info = hashlib.sha1(tparser.bencode(self.torrent_dict['info'])) self.hash_string = hashed_info.digest() self.peer_id = ('-DR' + VERSION + ...
python
def build_payload(self): ''' Builds the payload that will be sent in tracker_request ''' payload = {} hashed_info = hashlib.sha1(tparser.bencode(self.torrent_dict['info'])) self.hash_string = hashed_info.digest() self.peer_id = ('-DR' + VERSION + ...
[ "def", "build_payload", "(", "self", ")", ":", "payload", "=", "{", "}", "hashed_info", "=", "hashlib", ".", "sha1", "(", "tparser", ".", "bencode", "(", "self", ".", "torrent_dict", "[", "'info'", "]", ")", ")", "self", ".", "hash_string", "=", "hashe...
Builds the payload that will be sent in tracker_request
[ "Builds", "the", "payload", "that", "will", "be", "sent", "in", "tracker_request" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L153-L172
jefflovejapan/drench
drench/drench.py
Torrent.tracker_request
def tracker_request(self): ''' Sends the initial request to the tracker, compiling list of all peers announcing to the tracker ''' assert self.torrent_dict['info'] payload = self.build_payload() if self.torrent_dict['announce'].startswith('udp'): rai...
python
def tracker_request(self): ''' Sends the initial request to the tracker, compiling list of all peers announcing to the tracker ''' assert self.torrent_dict['info'] payload = self.build_payload() if self.torrent_dict['announce'].startswith('udp'): rai...
[ "def", "tracker_request", "(", "self", ")", ":", "assert", "self", ".", "torrent_dict", "[", "'info'", "]", "payload", "=", "self", ".", "build_payload", "(", ")", "if", "self", ".", "torrent_dict", "[", "'announce'", "]", ".", "startswith", "(", "'udp'", ...
Sends the initial request to the tracker, compiling list of all peers announcing to the tracker
[ "Sends", "the", "initial", "request", "to", "the", "tracker", "compiling", "list", "of", "all", "peers", "announcing", "to", "the", "tracker" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L175-L193
jefflovejapan/drench
drench/drench.py
Torrent.get_peer_ips
def get_peer_ips(self): ''' Generates list of peer IPs from tracker response. Note: not all of these IPs might be good, which is why we only init peer objects for the subset that respond to handshake ''' presponse = [ord(i) for i in self.tracker_response['peers']] ...
python
def get_peer_ips(self): ''' Generates list of peer IPs from tracker response. Note: not all of these IPs might be good, which is why we only init peer objects for the subset that respond to handshake ''' presponse = [ord(i) for i in self.tracker_response['peers']] ...
[ "def", "get_peer_ips", "(", "self", ")", ":", "presponse", "=", "[", "ord", "(", "i", ")", "for", "i", "in", "self", ".", "tracker_response", "[", "'peers'", "]", "]", "while", "presponse", ":", "peer_ip", "=", "(", "(", "'.'", ".", "join", "(", "s...
Generates list of peer IPs from tracker response. Note: not all of these IPs might be good, which is why we only init peer objects for the subset that respond to handshake
[ "Generates", "list", "of", "peer", "IPs", "from", "tracker", "response", ".", "Note", ":", "not", "all", "of", "these", "IPs", "might", "be", "good", "which", "is", "why", "we", "only", "init", "peer", "objects", "for", "the", "subset", "that", "respond"...
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L195-L207
jefflovejapan/drench
drench/drench.py
Torrent.handshake_peers
def handshake_peers(self): ''' pstrlen = length of pstr as one byte pstr = BitTorrent protocol reserved = chr(0)*8 info_hash = 20-byte hash above (aka self.hash_string) peer_id = 20-byte string ''' pstr = 'BitTorrent protocol' pstrlen = len(pstr) ...
python
def handshake_peers(self): ''' pstrlen = length of pstr as one byte pstr = BitTorrent protocol reserved = chr(0)*8 info_hash = 20-byte hash above (aka self.hash_string) peer_id = 20-byte string ''' pstr = 'BitTorrent protocol' pstrlen = len(pstr) ...
[ "def", "handshake_peers", "(", "self", ")", ":", "pstr", "=", "'BitTorrent protocol'", "pstrlen", "=", "len", "(", "pstr", ")", "info_hash", "=", "self", ".", "hash_string", "peer_id", "=", "self", ".", "peer_id", "packet", "=", "''", ".", "join", "(", "...
pstrlen = length of pstr as one byte pstr = BitTorrent protocol reserved = chr(0)*8 info_hash = 20-byte hash above (aka self.hash_string) peer_id = 20-byte string
[ "pstrlen", "=", "length", "of", "pstr", "as", "one", "byte", "pstr", "=", "BitTorrent", "protocol", "reserved", "=", "chr", "(", "0", ")", "*", "8", "info_hash", "=", "20", "-", "byte", "hash", "above", "(", "aka", "self", ".", "hash_string", ")", "p...
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L211-L262
jefflovejapan/drench
drench/drench.py
Torrent.initpeer
def initpeer(self, sock): ''' Creates a new peer object for a nvalid socket and adds it to reactor's listen list ''' location_json = requests.request("GET", "http://freegeoip.net/json/" + sock.getpeername()[0]).content location = j...
python
def initpeer(self, sock): ''' Creates a new peer object for a nvalid socket and adds it to reactor's listen list ''' location_json = requests.request("GET", "http://freegeoip.net/json/" + sock.getpeername()[0]).content location = j...
[ "def", "initpeer", "(", "self", ",", "sock", ")", ":", "location_json", "=", "requests", ".", "request", "(", "\"GET\"", ",", "\"http://freegeoip.net/json/\"", "+", "sock", ".", "getpeername", "(", ")", "[", "0", "]", ")", ".", "content", "location", "=", ...
Creates a new peer object for a nvalid socket and adds it to reactor's listen list
[ "Creates", "a", "new", "peer", "object", "for", "a", "nvalid", "socket", "and", "adds", "it", "to", "reactor", "s", "listen", "list" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L264-L274
jefflovejapan/drench
drench/peer.py
Peer.read
def read(self): try: bytes = self.sock.recv(self.max_size) except: self.torrent.kill_peer(self) return ''' Chain of events: - process_input - check save_state and read length, id, and message accordingly - if we ...
python
def read(self): try: bytes = self.sock.recv(self.max_size) except: self.torrent.kill_peer(self) return ''' Chain of events: - process_input - check save_state and read length, id, and message accordingly - if we ...
[ "def", "read", "(", "self", ")", ":", "try", ":", "bytes", "=", "self", ".", "sock", ".", "recv", "(", "self", ".", "max_size", ")", "except", ":", "self", ".", "torrent", ".", "kill_peer", "(", "self", ")", "return", "if", "len", "(", "bytes", "...
Chain of events: - process_input - check save_state and read length, id, and message accordingly - if we have a piece (really a block), we piece.save it out inside call to ppiece - If we've completed a piece we: - Tell...
[ "Chain", "of", "events", ":", "-", "process_input", "-", "check", "save_state", "and", "read", "length", "id", "and", "message", "accordingly", "-", "if", "we", "have", "a", "piece", "(", "really", "a", "block", ")", "we", "piece", ".", "save", "it", "...
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/peer.py#L55-L74
jefflovejapan/drench
drench/peer.py
Peer.ppiece
def ppiece(self, content): ''' Process a piece that we've received from a peer, writing it out to one or more files ''' piece_index, byte_begin = struct.unpack('!ii', content[0:8]) # TODO -- figure out a better way to catch this error. # How is piece_index gettin...
python
def ppiece(self, content): ''' Process a piece that we've received from a peer, writing it out to one or more files ''' piece_index, byte_begin = struct.unpack('!ii', content[0:8]) # TODO -- figure out a better way to catch this error. # How is piece_index gettin...
[ "def", "ppiece", "(", "self", ",", "content", ")", ":", "piece_index", ",", "byte_begin", "=", "struct", ".", "unpack", "(", "'!ii'", ",", "content", "[", "0", ":", "8", "]", ")", "# TODO -- figure out a better way to catch this error.", "# How is piece_index gett...
Process a piece that we've received from a peer, writing it out to one or more files
[ "Process", "a", "piece", "that", "we", "ve", "received", "from", "a", "peer", "writing", "it", "out", "to", "one", "or", "more", "files" ]
train
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/peer.py#L208-L257
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.is_connected
def is_connected(self): """ Returns the connection status of the data store. Returns: bool: ``True`` if the data store is connected to the MongoDB server. """ if self._client is not None: try: self._client.server_info() except Connecti...
python
def is_connected(self): """ Returns the connection status of the data store. Returns: bool: ``True`` if the data store is connected to the MongoDB server. """ if self._client is not None: try: self._client.server_info() except Connecti...
[ "def", "is_connected", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "not", "None", ":", "try", ":", "self", ".", "_client", ".", "server_info", "(", ")", "except", "ConnectionFailure", ":", "return", "False", "return", "True", "else", ":", ...
Returns the connection status of the data store. Returns: bool: ``True`` if the data store is connected to the MongoDB server.
[ "Returns", "the", "connection", "status", "of", "the", "data", "store", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L84-L97
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.connect
def connect(self): """ Establishes a connection to the MongoDB server. Use the MongoProxy library in order to automatically handle AutoReconnect exceptions in a graceful and reliable way. """ mongodb_args = { 'host': self.host, 'port': self.port, ...
python
def connect(self): """ Establishes a connection to the MongoDB server. Use the MongoProxy library in order to automatically handle AutoReconnect exceptions in a graceful and reliable way. """ mongodb_args = { 'host': self.host, 'port': self.port, ...
[ "def", "connect", "(", "self", ")", ":", "mongodb_args", "=", "{", "'host'", ":", "self", ".", "host", ",", "'port'", ":", "self", ".", "port", ",", "'username'", ":", "self", ".", "_username", ",", "'password'", ":", "self", ".", "_password", ",", "...
Establishes a connection to the MongoDB server. Use the MongoProxy library in order to automatically handle AutoReconnect exceptions in a graceful and reliable way.
[ "Establishes", "a", "connection", "to", "the", "MongoDB", "server", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L99-L120
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.exists
def exists(self, workflow_id): """ Checks whether a document with the specified workflow id already exists. Args: workflow_id (str): The workflow id that should be checked. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns...
python
def exists(self, workflow_id): """ Checks whether a document with the specified workflow id already exists. Args: workflow_id (str): The workflow id that should be checked. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns...
[ "def", "exists", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "col", "=", "db", "[", "WORKFLOW_DATA_COLLECTION_NAME", "]", "return", "col", ".", "find_one", "(", "{", "\"_i...
Checks whether a document with the specified workflow id already exists. Args: workflow_id (str): The workflow id that should be checked. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns: bool: ``True`` if a document ...
[ "Checks", "whether", "a", "document", "with", "the", "specified", "workflow", "id", "already", "exists", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L139-L157
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.add
def add(self, payload=None): """ Adds a new document to the data store and returns its id. Args: payload (dict): Dictionary of initial data that should be stored in the new document in the meta section. Raises: DataStoreNotConnected: If the data store is...
python
def add(self, payload=None): """ Adds a new document to the data store and returns its id. Args: payload (dict): Dictionary of initial data that should be stored in the new document in the meta section. Raises: DataStoreNotConnected: If the data store is...
[ "def", "add", "(", "self", ",", "payload", "=", "None", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "col", "=", "db", "[", "WORKFLOW_DATA_COLLECTION_NAME", "]", "return", "str", "(", "col", ".", "insert...
Adds a new document to the data store and returns its id. Args: payload (dict): Dictionary of initial data that should be stored in the new document in the meta section. Raises: DataStoreNotConnected: If the data store is not connected to the server. Re...
[ "Adds", "a", "new", "document", "to", "the", "data", "store", "and", "returns", "its", "id", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L159-L182
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.remove
def remove(self, workflow_id): """ Removes a document specified by its id from the data store. All associated GridFs documents are deleted as well. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If...
python
def remove(self, workflow_id): """ Removes a document specified by its id from the data store. All associated GridFs documents are deleted as well. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If...
[ "def", "remove", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "fs", "=", "GridFSProxy", "(", "GridFS", "(", "db", ".", "unproxied_object", ")", ")", "for", "grid_doc", "i...
Removes a document specified by its id from the data store. All associated GridFs documents are deleted as well. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If the data store is not connected to the ser...
[ "Removes", "a", "document", "specified", "by", "its", "id", "from", "the", "data", "store", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L184-L207
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStore.get
def get(self, workflow_id): """ Returns the document for the given workflow id. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns: ...
python
def get(self, workflow_id): """ Returns the document for the given workflow id. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns: ...
[ "def", "get", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "fs", "=", "GridFSProxy", "(", "GridFS", "(", "db", ".", "unproxied_object", ")", ")", "return", "DataStoreDocume...
Returns the document for the given workflow id. Args: workflow_id (str): The id of the document that represents a workflow run. Raises: DataStoreNotConnected: If the data store is not connected to the server. Returns: DataStoreDocument: The document for the...
[ "Returns", "the", "document", "for", "the", "given", "workflow", "id", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L209-L227
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument.get
def get(self, key, default=None, *, section=DataStoreDocumentSection.Data): """ Return the field specified by its key from the specified section. This method access the specified section of the workflow document and returns the value for the given key. Args: key (str): The ...
python
def get(self, key, default=None, *, section=DataStoreDocumentSection.Data): """ Return the field specified by its key from the specified section. This method access the specified section of the workflow document and returns the value for the given key. Args: key (str): The ...
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ",", "*", ",", "section", "=", "DataStoreDocumentSection", ".", "Data", ")", ":", "key_notation", "=", "'.'", ".", "join", "(", "[", "section", ",", "key", "]", ")", "try", ":", "r...
Return the field specified by its key from the specified section. This method access the specified section of the workflow document and returns the value for the given key. Args: key (str): The key pointing to the value that should be retrieved. It supports MongoDB'...
[ "Return", "the", "field", "specified", "by", "its", "key", "from", "the", "specified", "section", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L248-L270
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument.set
def set(self, key, value, *, section=DataStoreDocumentSection.Data): """ Store a value under the specified key in the given section of the document. This method stores a value into the specified section of the workflow data store document. Any existing value is overridden. Before storing a valu...
python
def set(self, key, value, *, section=DataStoreDocumentSection.Data): """ Store a value under the specified key in the given section of the document. This method stores a value into the specified section of the workflow data store document. Any existing value is overridden. Before storing a valu...
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "*", ",", "section", "=", "DataStoreDocumentSection", ".", "Data", ")", ":", "key_notation", "=", "'.'", ".", "join", "(", "[", "section", ",", "key", "]", ")", "try", ":", "self", ".", "_de...
Store a value under the specified key in the given section of the document. This method stores a value into the specified section of the workflow data store document. Any existing value is overridden. Before storing a value, any linked GridFS document under the specified key is deleted. ...
[ "Store", "a", "value", "under", "the", "specified", "key", "in", "the", "given", "section", "of", "the", "document", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L272-L306
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument.push
def push(self, key, value, *, section=DataStoreDocumentSection.Data): """ Appends a value to a list in the specified section of the document. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. ...
python
def push(self, key, value, *, section=DataStoreDocumentSection.Data): """ Appends a value to a list in the specified section of the document. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. ...
[ "def", "push", "(", "self", ",", "key", ",", "value", ",", "*", ",", "section", "=", "DataStoreDocumentSection", ".", "Data", ")", ":", "key_notation", "=", "'.'", ".", "join", "(", "[", "section", ",", "key", "]", ")", "result", "=", "self", ".", ...
Appends a value to a list in the specified section of the document. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. value: The value that should be appended to a list in the data store. ...
[ "Appends", "a", "value", "to", "a", "list", "in", "the", "specified", "section", "of", "the", "document", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L308-L331
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument.extend
def extend(self, key, values, *, section=DataStoreDocumentSection.Data): """ Extends a list in the data store with the elements of values. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. ...
python
def extend(self, key, values, *, section=DataStoreDocumentSection.Data): """ Extends a list in the data store with the elements of values. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. ...
[ "def", "extend", "(", "self", ",", "key", ",", "values", ",", "*", ",", "section", "=", "DataStoreDocumentSection", ".", "Data", ")", ":", "key_notation", "=", "'.'", ".", "join", "(", "[", "section", ",", "key", "]", ")", "if", "not", "isinstance", ...
Extends a list in the data store with the elements of values. Args: key (str): The key pointing to the value that should be stored/updated. It supports MongoDB's dot notation for nested fields. values (list): A list of the values that should be used to extend the list ...
[ "Extends", "a", "list", "in", "the", "data", "store", "with", "the", "elements", "of", "values", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L333-L361
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument._data_from_dotnotation
def _data_from_dotnotation(self, key, default=None): """ Returns the MongoDB data from a key using dot notation. Args: key (str): The key to the field in the workflow document. Supports MongoDB's dot notation for embedded fields. default (object): The default val...
python
def _data_from_dotnotation(self, key, default=None): """ Returns the MongoDB data from a key using dot notation. Args: key (str): The key to the field in the workflow document. Supports MongoDB's dot notation for embedded fields. default (object): The default val...
[ "def", "_data_from_dotnotation", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "is", "None", ":", "raise", "KeyError", "(", "'NoneType is not a valid key!'", ")", "doc", "=", "self", ".", "_collection", ".", "find_one", "(", ...
Returns the MongoDB data from a key using dot notation. Args: key (str): The key to the field in the workflow document. Supports MongoDB's dot notation for embedded fields. default (object): The default value that is returned if the key does not exist. ...
[ "Returns", "the", "MongoDB", "data", "from", "a", "key", "using", "dot", "notation", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L363-L385
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument._encode_value
def _encode_value(self, value): """ Encodes the value such that it can be stored into MongoDB. Any primitive types are stored directly into MongoDB, while non-primitive types are pickled and stored as GridFS objects. The id pointing to a GridFS object replaces the original value. ...
python
def _encode_value(self, value): """ Encodes the value such that it can be stored into MongoDB. Any primitive types are stored directly into MongoDB, while non-primitive types are pickled and stored as GridFS objects. The id pointing to a GridFS object replaces the original value. ...
[ "def", "_encode_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "str", ",", "bool", ",", "datetime", ")", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "list",...
Encodes the value such that it can be stored into MongoDB. Any primitive types are stored directly into MongoDB, while non-primitive types are pickled and stored as GridFS objects. The id pointing to a GridFS object replaces the original value. Args: value (object): The obj...
[ "Encodes", "the", "value", "such", "that", "it", "can", "be", "stored", "into", "MongoDB", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L387-L411
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument._decode_value
def _decode_value(self, value): """ Decodes the value by turning any binary data back into Python objects. The method searches for ObjectId values, loads the associated binary data from GridFS and returns the decoded Python object. Args: value (object): The value that shoul...
python
def _decode_value(self, value): """ Decodes the value by turning any binary data back into Python objects. The method searches for ObjectId values, loads the associated binary data from GridFS and returns the decoded Python object. Args: value (object): The value that shoul...
[ "def", "_decode_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "str", ",", "bool", ",", "datetime", ")", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "list",...
Decodes the value by turning any binary data back into Python objects. The method searches for ObjectId values, loads the associated binary data from GridFS and returns the decoded Python object. Args: value (object): The value that should be decoded. Raises: D...
[ "Decodes", "the", "value", "by", "turning", "any", "binary", "data", "back", "into", "Python", "objects", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L413-L445
AustralianSynchrotron/lightflow
lightflow/models/datastore.py
DataStoreDocument._delete_gridfs_data
def _delete_gridfs_data(self, data): """ Delete all GridFS data that is linked by fields in the specified data. Args: data: The data that is parsed for MongoDB ObjectIDs. The linked GridFs object for any ObjectID is deleted. """ if isinstance(data, ObjectId):...
python
def _delete_gridfs_data(self, data): """ Delete all GridFS data that is linked by fields in the specified data. Args: data: The data that is parsed for MongoDB ObjectIDs. The linked GridFs object for any ObjectID is deleted. """ if isinstance(data, ObjectId):...
[ "def", "_delete_gridfs_data", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "ObjectId", ")", ":", "if", "self", ".", "_gridfs", ".", "exists", "(", "{", "\"_id\"", ":", "data", "}", ")", ":", "self", ".", "_gridfs", ".", ...
Delete all GridFS data that is linked by fields in the specified data. Args: data: The data that is parsed for MongoDB ObjectIDs. The linked GridFs object for any ObjectID is deleted.
[ "Delete", "all", "GridFS", "data", "that", "is", "linked", "by", "fields", "in", "the", "specified", "data", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L447-L464
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_homecall
def get_homecall(callsign): """Strips off country prefixes (HC2/DH1TW) and activity suffixes (DH1TW/P). Args: callsign (str): Amateur Radio callsign Returns: str: callsign without country/activity pre/suffixes Raises: ValueError: No callsign found i...
python
def get_homecall(callsign): """Strips off country prefixes (HC2/DH1TW) and activity suffixes (DH1TW/P). Args: callsign (str): Amateur Radio callsign Returns: str: callsign without country/activity pre/suffixes Raises: ValueError: No callsign found i...
[ "def", "get_homecall", "(", "callsign", ")", ":", "callsign", "=", "callsign", ".", "upper", "(", ")", "homecall", "=", "re", ".", "search", "(", "'[\\d]{0,1}[A-Z]{1,2}\\d([A-Z]{1,4}|\\d{3,3}|\\d{1,3}[A-Z])[A-Z]{0,5}'", ",", "callsign", ")", "if", "homecall", ":", ...
Strips off country prefixes (HC2/DH1TW) and activity suffixes (DH1TW/P). Args: callsign (str): Amateur Radio callsign Returns: str: callsign without country/activity pre/suffixes Raises: ValueError: No callsign found in string Example: ...
[ "Strips", "off", "country", "prefixes", "(", "HC2", "/", "DH1TW", ")", "and", "activity", "suffixes", "(", "DH1TW", "/", "P", ")", "." ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L50-L79
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo._iterate_prefix
def _iterate_prefix(self, callsign, timestamp=timestamp_now): """truncate call until it corresponds to a Prefix in the database""" prefix = callsign if re.search('(VK|AX|VI)9[A-Z]{3}', callsign): #special rule for VK9 calls if timestamp > datetime(2006,1,1, tzinfo=UTC): ...
python
def _iterate_prefix(self, callsign, timestamp=timestamp_now): """truncate call until it corresponds to a Prefix in the database""" prefix = callsign if re.search('(VK|AX|VI)9[A-Z]{3}', callsign): #special rule for VK9 calls if timestamp > datetime(2006,1,1, tzinfo=UTC): ...
[ "def", "_iterate_prefix", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "prefix", "=", "callsign", "if", "re", ".", "search", "(", "'(VK|AX|VI)9[A-Z]{3}'", ",", "callsign", ")", ":", "#special rule for VK9 calls", "if", "timesta...
truncate call until it corresponds to a Prefix in the database
[ "truncate", "call", "until", "it", "corresponds", "to", "a", "Prefix", "in", "the", "database" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L81-L95
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo._dismantle_callsign
def _dismantle_callsign(self, callsign, timestamp=timestamp_now): """ try to identify the callsign's identity by analyzing it in the following order: Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Raises: ...
python
def _dismantle_callsign(self, callsign, timestamp=timestamp_now): """ try to identify the callsign's identity by analyzing it in the following order: Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Raises: ...
[ "def", "_dismantle_callsign", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "entire_callsign", "=", "callsign", ".", "upper", "(", ")", "if", "re", ".", "search", "(", "'[/A-Z0-9\\-]{3,15}'", ",", "entire_callsign", ")", ":", ...
try to identify the callsign's identity by analyzing it in the following order: Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Raises: KeyError: Callsign could not be identified
[ "try", "to", "identify", "the", "callsign", "s", "identity", "by", "analyzing", "it", "in", "the", "following", "order", ":" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L112-L222
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_all
def get_all(self, callsign, timestamp=timestamp_now): """ Lookup a callsign and return all data available from the underlying database Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dic...
python
def get_all(self, callsign, timestamp=timestamp_now): """ Lookup a callsign and return all data available from the underlying database Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dic...
[ "def", "get_all", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "callsign_data", "=", "self", ".", "_lookup_callsign", "(", "callsign", ",", "timestamp", ")", "try", ":", "cqz", "=", "self", ".", "_lookuplib", ".", "lookup...
Lookup a callsign and return all data available from the underlying database Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Dictionary containing the callsign specific data Raise...
[ "Lookup", "a", "callsign", "and", "return", "all", "data", "available", "from", "the", "underlying", "database" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L267-L313
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.is_valid_callsign
def is_valid_callsign(self, callsign, timestamp=timestamp_now): """ Checks if a callsign is valid Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: bool: True / False Example: ...
python
def is_valid_callsign(self, callsign, timestamp=timestamp_now): """ Checks if a callsign is valid Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: bool: True / False Example: ...
[ "def", "is_valid_callsign", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "try", ":", "if", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", ":", "return", "True", "except", "KeyError", ":", "return", "False...
Checks if a callsign is valid Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: bool: True / False Example: The following checks if "DH1TW" is a valid callsign >>...
[ "Checks", "if", "a", "callsign", "is", "valid" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L315-L339
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_lat_long
def get_lat_long(self, callsign, timestamp=timestamp_now): """ Returns Latitude and Longitude for a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Containing Latitude and...
python
def get_lat_long(self, callsign, timestamp=timestamp_now): """ Returns Latitude and Longitude for a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Containing Latitude and...
[ "def", "get_lat_long", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "callsign_data", "=", "self", ".", "get_all", "(", "callsign", ",", "timestamp", "=", "timestamp", ")", "return", "{", "const", ".", "LATITUDE", ":", "ca...
Returns Latitude and Longitude for a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Containing Latitude and Longitude Raises: KeyError: No data found for cal...
[ "Returns", "Latitude", "and", "Longitude", "for", "a", "callsign" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L341-L376
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_cqz
def get_cqz(self, callsign, timestamp=timestamp_now): """ Returns CQ Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone Ra...
python
def get_cqz(self, callsign, timestamp=timestamp_now): """ Returns CQ Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone Ra...
[ "def", "get_cqz", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "return", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", "[", "const", ".", "CQZ", "]" ]
Returns CQ Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone Raises: KeyError: no CQ Zone found for callsign
[ "Returns", "CQ", "Zone", "of", "a", "callsign" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L378-L392
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_ituz
def get_ituz(self, callsign, timestamp=timestamp_now): """ Returns ITU Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone ...
python
def get_ituz(self, callsign, timestamp=timestamp_now): """ Returns ITU Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone ...
[ "def", "get_ituz", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "return", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", "[", "const", ".", "ITUZ", "]" ]
Returns ITU Zone of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the callsign's CQ Zone Raises: KeyError: No ITU Zone found for callsign ...
[ "Returns", "ITU", "Zone", "of", "a", "callsign" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L394-L411
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_country_name
def get_country_name(self, callsign, timestamp=timestamp_now): """ Returns the country name where the callsign is located Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: name of the...
python
def get_country_name(self, callsign, timestamp=timestamp_now): """ Returns the country name where the callsign is located Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: name of the...
[ "def", "get_country_name", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "return", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", "[", "const", ".", "COUNTRY", "]" ]
Returns the country name where the callsign is located Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: name of the Country Raises: KeyError: No Country found for callsi...
[ "Returns", "the", "country", "name", "where", "the", "callsign", "is", "located" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L413-L435
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_adif_id
def get_adif_id(self, callsign, timestamp=timestamp_now): """ Returns ADIF id of a callsign's country Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the country ADIF id ...
python
def get_adif_id(self, callsign, timestamp=timestamp_now): """ Returns ADIF id of a callsign's country Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the country ADIF id ...
[ "def", "get_adif_id", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "return", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", "[", "const", ".", "ADIF", "]" ]
Returns ADIF id of a callsign's country Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: int: containing the country ADIF id Raises: KeyError: No Country found for callsign
[ "Returns", "ADIF", "id", "of", "a", "callsign", "s", "country" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L437-L451
dh1tw/pyhamtools
pyhamtools/callinfo.py
Callinfo.get_continent
def get_continent(self, callsign, timestamp=timestamp_now): """ Returns the continent Identifier of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: continent identified ...
python
def get_continent(self, callsign, timestamp=timestamp_now): """ Returns the continent Identifier of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: continent identified ...
[ "def", "get_continent", "(", "self", ",", "callsign", ",", "timestamp", "=", "timestamp_now", ")", ":", "return", "self", ".", "get_all", "(", "callsign", ",", "timestamp", ")", "[", "const", ".", "CONTINENT", "]" ]
Returns the continent Identifier of a callsign Args: callsign (str): Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: str: continent identified Raises: KeyError: No Continent found for callsign ...
[ "Returns", "the", "continent", "Identifier", "of", "a", "callsign" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/callinfo.py#L453-L477
AustralianSynchrotron/lightflow
lightflow/models/utils.py
find_indices
def find_indices(lst, element): """ Returns the indices for all occurrences of 'element' in 'lst'. Args: lst (list): List to search. element: Element to find. Returns: list: List of indices or values """ result = [] offset = -1 while True: try: ...
python
def find_indices(lst, element): """ Returns the indices for all occurrences of 'element' in 'lst'. Args: lst (list): List to search. element: Element to find. Returns: list: List of indices or values """ result = [] offset = -1 while True: try: ...
[ "def", "find_indices", "(", "lst", ",", "element", ")", ":", "result", "=", "[", "]", "offset", "=", "-", "1", "while", "True", ":", "try", ":", "offset", "=", "lst", ".", "index", "(", "element", ",", "offset", "+", "1", ")", "except", "ValueError...
Returns the indices for all occurrences of 'element' in 'lst'. Args: lst (list): List to search. element: Element to find. Returns: list: List of indices or values
[ "Returns", "the", "indices", "for", "all", "occurrences", "of", "element", "in", "lst", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/utils.py#L2-L19
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow.from_name
def from_name(cls, name, *, queue=DefaultJobQueueName.Workflow, clear_data_store=True, arguments=None): """ Create a workflow object from a workflow script. Args: name (str): The name of the workflow script. queue (str): Name of the queue the workflow should be...
python
def from_name(cls, name, *, queue=DefaultJobQueueName.Workflow, clear_data_store=True, arguments=None): """ Create a workflow object from a workflow script. Args: name (str): The name of the workflow script. queue (str): Name of the queue the workflow should be...
[ "def", "from_name", "(", "cls", ",", "name", ",", "*", ",", "queue", "=", "DefaultJobQueueName", ".", "Workflow", ",", "clear_data_store", "=", "True", ",", "arguments", "=", "None", ")", ":", "new_workflow", "=", "cls", "(", "queue", "=", "queue", ",", ...
Create a workflow object from a workflow script. Args: name (str): The name of the workflow script. queue (str): Name of the queue the workflow should be scheduled to. clear_data_store (bool): Remove any documents created during the workflow ...
[ "Create", "a", "workflow", "object", "from", "a", "workflow", "script", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L59-L76
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow.load
def load(self, name, *, arguments=None, validate_arguments=True, strict_dag=False): """ Import the workflow script and load all known objects. The workflow script is treated like a module and imported into the Python namespace. After the import, the method looks for instances of known c...
python
def load(self, name, *, arguments=None, validate_arguments=True, strict_dag=False): """ Import the workflow script and load all known objects. The workflow script is treated like a module and imported into the Python namespace. After the import, the method looks for instances of known c...
[ "def", "load", "(", "self", ",", "name", ",", "*", ",", "arguments", "=", "None", ",", "validate_arguments", "=", "True", ",", "strict_dag", "=", "False", ")", ":", "arguments", "=", "{", "}", "if", "arguments", "is", "None", "else", "arguments", "try"...
Import the workflow script and load all known objects. The workflow script is treated like a module and imported into the Python namespace. After the import, the method looks for instances of known classes and stores a reference for further use in the workflow object. Args: ...
[ "Import", "the", "workflow", "script", "and", "load", "all", "known", "objects", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L108-L165
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow.run
def run(self, config, data_store, signal_server, workflow_id): """ Run all autostart dags in the workflow. Only the dags that are flagged as autostart are started. Args: config (Config): Reference to the configuration object from which the settings for ...
python
def run(self, config, data_store, signal_server, workflow_id): """ Run all autostart dags in the workflow. Only the dags that are flagged as autostart are started. Args: config (Config): Reference to the configuration object from which the settings for ...
[ "def", "run", "(", "self", ",", "config", ",", "data_store", ",", "signal_server", ",", "workflow_id", ")", ":", "self", ".", "_workflow_id", "=", "workflow_id", "self", ".", "_celery_app", "=", "create_app", "(", "config", ")", "# pre-fill the data store with s...
Run all autostart dags in the workflow. Only the dags that are flagged as autostart are started. Args: config (Config): Reference to the configuration object from which the settings for the workflow are retrieved. data_store (DataStore): A DataStore...
[ "Run", "all", "autostart", "dags", "in", "the", "workflow", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L167-L228
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._queue_dag
def _queue_dag(self, name, *, data=None): """ Add a new dag to the queue. If the stop workflow flag is set, no new dag can be queued. Args: name (str): The name of the dag that should be queued. data (MultiTaskData): The data that should be passed on to the new dag. ...
python
def _queue_dag(self, name, *, data=None): """ Add a new dag to the queue. If the stop workflow flag is set, no new dag can be queued. Args: name (str): The name of the dag that should be queued. data (MultiTaskData): The data that should be passed on to the new dag. ...
[ "def", "_queue_dag", "(", "self", ",", "name", ",", "*", ",", "data", "=", "None", ")", ":", "if", "self", ".", "_stop_workflow", ":", "return", "None", "if", "name", "not", "in", "self", ".", "_dags_blueprint", ":", "raise", "DagNameUnknown", "(", ")"...
Add a new dag to the queue. If the stop workflow flag is set, no new dag can be queued. Args: name (str): The name of the dag that should be queued. data (MultiTaskData): The data that should be passed on to the new dag. Raises: DagNameUnknown: If the speci...
[ "Add", "a", "new", "dag", "to", "the", "queue", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L230-L257
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_request
def _handle_request(self, request): """ Handle an incoming request by forwarding it to the appropriate method. Args: request (Request): Reference to a request object containing the incoming request. Raises: RequestActionUnknown: If the act...
python
def _handle_request(self, request): """ Handle an incoming request by forwarding it to the appropriate method. Args: request (Request): Reference to a request object containing the incoming request. Raises: RequestActionUnknown: If the act...
[ "def", "_handle_request", "(", "self", ",", "request", ")", ":", "if", "request", "is", "None", ":", "return", "Response", "(", "success", "=", "False", ",", "uid", "=", "request", ".", "uid", ")", "action_map", "=", "{", "'start_dag'", ":", "self", "....
Handle an incoming request by forwarding it to the appropriate method. Args: request (Request): Reference to a request object containing the incoming request. Raises: RequestActionUnknown: If the action specified in the request is not known. ...
[ "Handle", "an", "incoming", "request", "by", "forwarding", "it", "to", "the", "appropriate", "method", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L259-L287
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_start_dag
def _handle_start_dag(self, request): """ The handler for the start_dag request. The start_dag request creates a new dag and adds it to the queue. Args: request (Request): Reference to a request object containing the incoming request. The payload has ...
python
def _handle_start_dag(self, request): """ The handler for the start_dag request. The start_dag request creates a new dag and adds it to the queue. Args: request (Request): Reference to a request object containing the incoming request. The payload has ...
[ "def", "_handle_start_dag", "(", "self", ",", "request", ")", ":", "dag_name", "=", "self", ".", "_queue_dag", "(", "name", "=", "request", ".", "payload", "[", "'name'", "]", ",", "data", "=", "request", ".", "payload", "[", "'data'", "]", ")", "retur...
The handler for the start_dag request. The start_dag request creates a new dag and adds it to the queue. Args: request (Request): Reference to a request object containing the incoming request. The payload has to contain the foll...
[ "The", "handler", "for", "the", "start_dag", "request", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L289-L308
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_stop_workflow
def _handle_stop_workflow(self, request): """ The handler for the stop_workflow request. The stop_workflow request adds all running dags to the list of dags that should be stopped and prevents new dags from being started. The dags will then stop queueing new tasks, which will terminate ...
python
def _handle_stop_workflow(self, request): """ The handler for the stop_workflow request. The stop_workflow request adds all running dags to the list of dags that should be stopped and prevents new dags from being started. The dags will then stop queueing new tasks, which will terminate ...
[ "def", "_handle_stop_workflow", "(", "self", ",", "request", ")", ":", "self", ".", "_stop_workflow", "=", "True", "for", "name", ",", "dag", "in", "self", ".", "_dags_running", ".", "items", "(", ")", ":", "if", "name", "not", "in", "self", ".", "_sto...
The handler for the stop_workflow request. The stop_workflow request adds all running dags to the list of dags that should be stopped and prevents new dags from being started. The dags will then stop queueing new tasks, which will terminate the dags and in turn the workflow. Ar...
[ "The", "handler", "for", "the", "stop_workflow", "request", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L310-L331
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_join_dags
def _handle_join_dags(self, request): """ The handler for the join_dags request. If dag names are given in the payload only return a valid Response if none of the dags specified by the names are running anymore. If no dag names are given, wait for all dags except one, which by design is...
python
def _handle_join_dags(self, request): """ The handler for the join_dags request. If dag names are given in the payload only return a valid Response if none of the dags specified by the names are running anymore. If no dag names are given, wait for all dags except one, which by design is...
[ "def", "_handle_join_dags", "(", "self", ",", "request", ")", ":", "if", "request", ".", "payload", "[", "'names'", "]", "is", "None", ":", "send_response", "=", "len", "(", "self", ".", "_dags_running", ")", "<=", "1", "else", ":", "send_response", "=",...
The handler for the join_dags request. If dag names are given in the payload only return a valid Response if none of the dags specified by the names are running anymore. If no dag names are given, wait for all dags except one, which by design is the one that issued the request, to be fi...
[ "The", "handler", "for", "the", "join_dags", "request", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L333-L359
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_stop_dag
def _handle_stop_dag(self, request): """ The handler for the stop_dag request. The stop_dag request adds a dag to the list of dags that should be stopped. The dag will then stop queueing new tasks and will eventually stop running. Args: request (Request): Reference to a req...
python
def _handle_stop_dag(self, request): """ The handler for the stop_dag request. The stop_dag request adds a dag to the list of dags that should be stopped. The dag will then stop queueing new tasks and will eventually stop running. Args: request (Request): Reference to a req...
[ "def", "_handle_stop_dag", "(", "self", ",", "request", ")", ":", "if", "(", "request", ".", "payload", "[", "'name'", "]", "is", "not", "None", ")", "and", "(", "request", ".", "payload", "[", "'name'", "]", "not", "in", "self", ".", "_stop_dags", "...
The handler for the stop_dag request. The stop_dag request adds a dag to the list of dags that should be stopped. The dag will then stop queueing new tasks and will eventually stop running. Args: request (Request): Reference to a request object containing the ...
[ "The", "handler", "for", "the", "stop_dag", "request", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L361-L381
AustralianSynchrotron/lightflow
lightflow/models/workflow.py
Workflow._handle_is_dag_stopped
def _handle_is_dag_stopped(self, request): """ The handler for the dag_stopped request. The dag_stopped request checks whether a dag is flagged to be terminated. Args: request (Request): Reference to a request object containing the incoming request. T...
python
def _handle_is_dag_stopped(self, request): """ The handler for the dag_stopped request. The dag_stopped request checks whether a dag is flagged to be terminated. Args: request (Request): Reference to a request object containing the incoming request. T...
[ "def", "_handle_is_dag_stopped", "(", "self", ",", "request", ")", ":", "return", "Response", "(", "success", "=", "True", ",", "uid", "=", "request", ".", "uid", ",", "payload", "=", "{", "'is_stopped'", ":", "request", ".", "payload", "[", "'dag_name'", ...
The handler for the dag_stopped request. The dag_stopped request checks whether a dag is flagged to be terminated. Args: request (Request): Reference to a request object containing the incoming request. The payload has to contain the ...
[ "The", "handler", "for", "the", "dag_stopped", "request", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/workflow.py#L383-L402
AustralianSynchrotron/lightflow
lightflow/queue/worker.py
WorkerLifecycle.stop
def stop(self, consumer): """ This function is called when the worker received a request to terminate. Upon the termination of the worker, the workflows for all running jobs are stopped gracefully. Args: consumer (Consumer): Reference to the consumer object that handles mes...
python
def stop(self, consumer): """ This function is called when the worker received a request to terminate. Upon the termination of the worker, the workflows for all running jobs are stopped gracefully. Args: consumer (Consumer): Reference to the consumer object that handles mes...
[ "def", "stop", "(", "self", ",", "consumer", ")", ":", "stopped_workflows", "=", "[", "]", "for", "request", "in", "[", "r", "for", "r", "in", "consumer", ".", "controller", ".", "state", ".", "active_requests", "]", ":", "job", "=", "AsyncResult", "("...
This function is called when the worker received a request to terminate. Upon the termination of the worker, the workflows for all running jobs are stopped gracefully. Args: consumer (Consumer): Reference to the consumer object that handles messages ...
[ "This", "function", "is", "called", "when", "the", "worker", "received", "a", "request", "to", "terminate", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/worker.py#L10-L32
AustralianSynchrotron/lightflow
lightflow/models/task_signal.py
TaskSignal.start_dag
def start_dag(self, dag, *, data=None): """ Schedule the execution of a dag by sending a signal to the workflow. Args: dag (Dag, str): The dag object or the name of the dag that should be started. data (MultiTaskData): The data that should be passed on to the new dag. R...
python
def start_dag(self, dag, *, data=None): """ Schedule the execution of a dag by sending a signal to the workflow. Args: dag (Dag, str): The dag object or the name of the dag that should be started. data (MultiTaskData): The data that should be passed on to the new dag. R...
[ "def", "start_dag", "(", "self", ",", "dag", ",", "*", ",", "data", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "Request", "(", "action", "=", "'start_dag'", ",", "payload", "=", "{", "'name'", ":", "dag", ".", "name"...
Schedule the execution of a dag by sending a signal to the workflow. Args: dag (Dag, str): The dag object or the name of the dag that should be started. data (MultiTaskData): The data that should be passed on to the new dag. Returns: str: The name of the successfull...
[ "Schedule", "the", "execution", "of", "a", "dag", "by", "sending", "a", "signal", "to", "the", "workflow", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_signal.py#L18-L34
AustralianSynchrotron/lightflow
lightflow/models/task_signal.py
TaskSignal.join_dags
def join_dags(self, names=None): """ Wait for the specified dags to terminate. This function blocks until the specified dags terminate. If no dags are specified wait for all dags of the workflow, except the dag of the task calling this signal, to terminate. Args: na...
python
def join_dags(self, names=None): """ Wait for the specified dags to terminate. This function blocks until the specified dags terminate. If no dags are specified wait for all dags of the workflow, except the dag of the task calling this signal, to terminate. Args: na...
[ "def", "join_dags", "(", "self", ",", "names", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "Request", "(", "action", "=", "'join_dags'", ",", "payload", "=", "{", "'names'", ":", "names", "}", ")", ")", ".", "success" ]
Wait for the specified dags to terminate. This function blocks until the specified dags terminate. If no dags are specified wait for all dags of the workflow, except the dag of the task calling this signal, to terminate. Args: names (list): The names of the dags that have t...
[ "Wait", "for", "the", "specified", "dags", "to", "terminate", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_signal.py#L36-L54
AustralianSynchrotron/lightflow
lightflow/models/task_signal.py
TaskSignal.stop_dag
def stop_dag(self, name=None): """ Send a stop signal to the specified dag or the dag that hosts this task. Args: name str: The name of the dag that should be stopped. If no name is given the dag that hosts this task is stopped. Upon receiving the stop signal,...
python
def stop_dag(self, name=None): """ Send a stop signal to the specified dag or the dag that hosts this task. Args: name str: The name of the dag that should be stopped. If no name is given the dag that hosts this task is stopped. Upon receiving the stop signal,...
[ "def", "stop_dag", "(", "self", ",", "name", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "Request", "(", "action", "=", "'stop_dag'", ",", "payload", "=", "{", "'name'", ":", "name", "if", "name", "is", "not", "None", ...
Send a stop signal to the specified dag or the dag that hosts this task. Args: name str: The name of the dag that should be stopped. If no name is given the dag that hosts this task is stopped. Upon receiving the stop signal, the dag will not queue any new tasks and w...
[ "Send", "a", "stop", "signal", "to", "the", "specified", "dag", "or", "the", "dag", "that", "hosts", "this", "task", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_signal.py#L56-L74
AustralianSynchrotron/lightflow
lightflow/models/task_signal.py
TaskSignal.is_stopped
def is_stopped(self): """ Check whether the task received a stop signal from the workflow. Tasks can use the stop flag to gracefully terminate their work. This is particularly important for long running tasks and tasks that employ an infinite loop, such as trigger tasks. Return...
python
def is_stopped(self): """ Check whether the task received a stop signal from the workflow. Tasks can use the stop flag to gracefully terminate their work. This is particularly important for long running tasks and tasks that employ an infinite loop, such as trigger tasks. Return...
[ "def", "is_stopped", "(", "self", ")", ":", "resp", "=", "self", ".", "_client", ".", "send", "(", "Request", "(", "action", "=", "'is_dag_stopped'", ",", "payload", "=", "{", "'dag_name'", ":", "self", ".", "_dag_name", "}", ")", ")", "return", "resp"...
Check whether the task received a stop signal from the workflow. Tasks can use the stop flag to gracefully terminate their work. This is particularly important for long running tasks and tasks that employ an infinite loop, such as trigger tasks. Returns: bool: True if the t...
[ "Check", "whether", "the", "task", "received", "a", "stop", "signal", "from", "the", "workflow", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_signal.py#L90-L106
AustralianSynchrotron/lightflow
lightflow/queue/event.py
event_stream
def event_stream(app, *, filter_by_prefix=None): """ Generator function that returns celery events. This function turns the callback based celery event handling into a generator. Args: app: Reference to a celery application object. filter_by_prefix (str): If not None, only allow events tha...
python
def event_stream(app, *, filter_by_prefix=None): """ Generator function that returns celery events. This function turns the callback based celery event handling into a generator. Args: app: Reference to a celery application object. filter_by_prefix (str): If not None, only allow events tha...
[ "def", "event_stream", "(", "app", ",", "*", ",", "filter_by_prefix", "=", "None", ")", ":", "q", "=", "Queue", "(", ")", "def", "handle_event", "(", "event", ")", ":", "if", "filter_by_prefix", "is", "None", "or", "(", "filter_by_prefix", "is", "not", ...
Generator function that returns celery events. This function turns the callback based celery event handling into a generator. Args: app: Reference to a celery application object. filter_by_prefix (str): If not None, only allow events that have a type that start...
[ "Generator", "function", "that", "returns", "celery", "events", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/event.py#L10-L44
AustralianSynchrotron/lightflow
lightflow/queue/event.py
create_event_model
def create_event_model(event): """ Factory function that turns a celery event into an event object. Args: event (dict): A dictionary that represents a celery event. Returns: object: An event object representing the received event. Raises: JobEventTypeUnsupported: If an unsuppo...
python
def create_event_model(event): """ Factory function that turns a celery event into an event object. Args: event (dict): A dictionary that represents a celery event. Returns: object: An event object representing the received event. Raises: JobEventTypeUnsupported: If an unsuppo...
[ "def", "create_event_model", "(", "event", ")", ":", "if", "event", "[", "'type'", "]", ".", "startswith", "(", "'task'", ")", ":", "factory", "=", "{", "JobEventName", ".", "Started", ":", "JobStartedEvent", ",", "JobEventName", ".", "Succeeded", ":", "Jo...
Factory function that turns a celery event into an event object. Args: event (dict): A dictionary that represents a celery event. Returns: object: An event object representing the received event. Raises: JobEventTypeUnsupported: If an unsupported celery job event was received. ...
[ "Factory", "function", "that", "turns", "a", "celery", "event", "into", "an", "event", "object", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/event.py#L47-L77
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
config_required
def config_required(f): """ Decorator that checks whether a configuration file was set. """ def new_func(obj, *args, **kwargs): if 'config' not in obj: click.echo(_style(obj.get('show_color', False), 'Could not find a valid configuration file!', ...
python
def config_required(f): """ Decorator that checks whether a configuration file was set. """ def new_func(obj, *args, **kwargs): if 'config' not in obj: click.echo(_style(obj.get('show_color', False), 'Could not find a valid configuration file!', ...
[ "def", "config_required", "(", "f", ")", ":", "def", "new_func", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'config'", "not", "in", "obj", ":", "click", ".", "echo", "(", "_style", "(", "obj", ".", "get", "(", "'show_...
Decorator that checks whether a configuration file was set.
[ "Decorator", "that", "checks", "whether", "a", "configuration", "file", "was", "set", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L30-L40
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
ingest_config_obj
def ingest_config_obj(ctx, *, silent=True): """ Ingest the configuration object into the click context. """ try: ctx.obj['config'] = Config.from_file(ctx.obj['config_path']) except ConfigLoadError as err: click.echo(_style(ctx.obj['show_color'], str(err), fg='red', bold=True)) if not...
python
def ingest_config_obj(ctx, *, silent=True): """ Ingest the configuration object into the click context. """ try: ctx.obj['config'] = Config.from_file(ctx.obj['config_path']) except ConfigLoadError as err: click.echo(_style(ctx.obj['show_color'], str(err), fg='red', bold=True)) if not...
[ "def", "ingest_config_obj", "(", "ctx", ",", "*", ",", "silent", "=", "True", ")", ":", "try", ":", "ctx", ".", "obj", "[", "'config'", "]", "=", "Config", ".", "from_file", "(", "ctx", ".", "obj", "[", "'config_path'", "]", ")", "except", "ConfigLoa...
Ingest the configuration object into the click context.
[ "Ingest", "the", "configuration", "object", "into", "the", "click", "context", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L43-L50
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
cli
def cli(ctx, config, no_color): """ Command line client for lightflow. A lightweight, high performance pipeline system for synchrotrons. Lightflow is being developed at the Australian Synchrotron. """ ctx.obj = { 'show_color': not no_color if no_color is not None else True, 'config_...
python
def cli(ctx, config, no_color): """ Command line client for lightflow. A lightweight, high performance pipeline system for synchrotrons. Lightflow is being developed at the Australian Synchrotron. """ ctx.obj = { 'show_color': not no_color if no_color is not None else True, 'config_...
[ "def", "cli", "(", "ctx", ",", "config", ",", "no_color", ")", ":", "ctx", ".", "obj", "=", "{", "'show_color'", ":", "not", "no_color", "if", "no_color", "is", "not", "None", "else", "True", ",", "'config_path'", ":", "config", "}" ]
Command line client for lightflow. A lightweight, high performance pipeline system for synchrotrons. Lightflow is being developed at the Australian Synchrotron.
[ "Command", "line", "client", "for", "lightflow", ".", "A", "lightweight", "high", "performance", "pipeline", "system", "for", "synchrotrons", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L58-L67
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
config_default
def config_default(dest): """ Create a default configuration file. \b DEST: Path or file name for the configuration file. """ conf_path = Path(dest).resolve() if conf_path.is_dir(): conf_path = conf_path / LIGHTFLOW_CONFIG_NAME conf_path.write_text(Config.default()) click.echo(...
python
def config_default(dest): """ Create a default configuration file. \b DEST: Path or file name for the configuration file. """ conf_path = Path(dest).resolve() if conf_path.is_dir(): conf_path = conf_path / LIGHTFLOW_CONFIG_NAME conf_path.write_text(Config.default()) click.echo(...
[ "def", "config_default", "(", "dest", ")", ":", "conf_path", "=", "Path", "(", "dest", ")", ".", "resolve", "(", ")", "if", "conf_path", ".", "is_dir", "(", ")", ":", "conf_path", "=", "conf_path", "/", "LIGHTFLOW_CONFIG_NAME", "conf_path", ".", "write_tex...
Create a default configuration file. \b DEST: Path or file name for the configuration file.
[ "Create", "a", "default", "configuration", "file", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L78-L89
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
config_list
def config_list(ctx): """ List the current configuration. """ ingest_config_obj(ctx, silent=False) click.echo(json.dumps(ctx.obj['config'].to_dict(), indent=4))
python
def config_list(ctx): """ List the current configuration. """ ingest_config_obj(ctx, silent=False) click.echo(json.dumps(ctx.obj['config'].to_dict(), indent=4))
[ "def", "config_list", "(", "ctx", ")", ":", "ingest_config_obj", "(", "ctx", ",", "silent", "=", "False", ")", "click", ".", "echo", "(", "json", ".", "dumps", "(", "ctx", ".", "obj", "[", "'config'", "]", ".", "to_dict", "(", ")", ",", "indent", "...
List the current configuration.
[ "List", "the", "current", "configuration", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L94-L97
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
config_examples
def config_examples(dest, user_dir): """ Copy the example workflows to a directory. \b DEST: Path to which the examples should be copied. """ examples_path = Path(lightflow.__file__).parents[1] / 'examples' if examples_path.exists(): dest_path = Path(dest).resolve() if not user_...
python
def config_examples(dest, user_dir): """ Copy the example workflows to a directory. \b DEST: Path to which the examples should be copied. """ examples_path = Path(lightflow.__file__).parents[1] / 'examples' if examples_path.exists(): dest_path = Path(dest).resolve() if not user_...
[ "def", "config_examples", "(", "dest", ",", "user_dir", ")", ":", "examples_path", "=", "Path", "(", "lightflow", ".", "__file__", ")", ".", "parents", "[", "1", "]", "/", "'examples'", "if", "examples_path", ".", "exists", "(", ")", ":", "dest_path", "=...
Copy the example workflows to a directory. \b DEST: Path to which the examples should be copied.
[ "Copy", "the", "example", "workflows", "to", "a", "directory", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L104-L127
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
workflow_list
def workflow_list(obj): """ List all available workflows. """ try: for wf in list_workflows(config=obj['config']): click.echo('{:23} {}'.format( _style(obj['show_color'], wf.name, bold=True), wf.docstring.split('\n')[0] if wf.docstring is not None else '')) ...
python
def workflow_list(obj): """ List all available workflows. """ try: for wf in list_workflows(config=obj['config']): click.echo('{:23} {}'.format( _style(obj['show_color'], wf.name, bold=True), wf.docstring.split('\n')[0] if wf.docstring is not None else '')) ...
[ "def", "workflow_list", "(", "obj", ")", ":", "try", ":", "for", "wf", "in", "list_workflows", "(", "config", "=", "obj", "[", "'config'", "]", ")", ":", "click", ".", "echo", "(", "'{:23} {}'", ".", "format", "(", "_style", "(", "obj", "[", "'show_c...
List all available workflows.
[ "List", "all", "available", "workflows", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L140-L150
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
workflow_start
def workflow_start(obj, queue, keep_data, name, workflow_args): """ Send a workflow to the queue. \b NAME: The name of the workflow that should be started. WORKFLOW_ARGS: Workflow arguments in the form key1=value1 key2=value2. """ try: start_workflow(name=name, co...
python
def workflow_start(obj, queue, keep_data, name, workflow_args): """ Send a workflow to the queue. \b NAME: The name of the workflow that should be started. WORKFLOW_ARGS: Workflow arguments in the form key1=value1 key2=value2. """ try: start_workflow(name=name, co...
[ "def", "workflow_start", "(", "obj", ",", "queue", ",", "keep_data", ",", "name", ",", "workflow_args", ")", ":", "try", ":", "start_workflow", "(", "name", "=", "name", ",", "config", "=", "obj", "[", "'config'", "]", ",", "queue", "=", "queue", ",", ...
Send a workflow to the queue. \b NAME: The name of the workflow that should be started. WORKFLOW_ARGS: Workflow arguments in the form key1=value1 key2=value2.
[ "Send", "a", "workflow", "to", "the", "queue", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L163-L185
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
workflow_stop
def workflow_stop(obj, names): """ Stop one or more running workflows. \b NAMES: The names, ids or job ids of the workflows that should be stopped. Leave empty to stop all running workflows. """ if len(names) == 0: msg = 'Would you like to stop all workflows?' else: m...
python
def workflow_stop(obj, names): """ Stop one or more running workflows. \b NAMES: The names, ids or job ids of the workflows that should be stopped. Leave empty to stop all running workflows. """ if len(names) == 0: msg = 'Would you like to stop all workflows?' else: m...
[ "def", "workflow_stop", "(", "obj", ",", "names", ")", ":", "if", "len", "(", "names", ")", "==", "0", ":", "msg", "=", "'Would you like to stop all workflows?'", "else", ":", "msg", "=", "'\\n{}\\n\\n{}'", ".", "format", "(", "'\\n'", ".", "join", "(", ...
Stop one or more running workflows. \b NAMES: The names, ids or job ids of the workflows that should be stopped. Leave empty to stop all running workflows.
[ "Stop", "one", "or", "more", "running", "workflows", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L192-L206
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
workflow_status
def workflow_status(obj, details): """ Show the status of the workflows. """ show_colors = obj['show_color'] config_cli = obj['config'].cli if details: temp_form = '{:>{}} {:20} {:25} {:25} {:38} {}' else: temp_form = '{:>{}} {:20} {:25} {} {} {}' click.echo('\n') click.e...
python
def workflow_status(obj, details): """ Show the status of the workflows. """ show_colors = obj['show_color'] config_cli = obj['config'].cli if details: temp_form = '{:>{}} {:20} {:25} {:25} {:38} {}' else: temp_form = '{:>{}} {:20} {:25} {} {} {}' click.echo('\n') click.e...
[ "def", "workflow_status", "(", "obj", ",", "details", ")", ":", "show_colors", "=", "obj", "[", "'show_color'", "]", "config_cli", "=", "obj", "[", "'config'", "]", ".", "cli", "if", "details", ":", "temp_form", "=", "'{:>{}} {:20} {:25} {:25} {:38} {}'", "el...
Show the status of the workflows.
[ "Show", "the", "status", "of", "the", "workflows", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L213-L272
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
worker_start
def worker_start(obj, queues, name, celery_args): """ Start a worker process. \b CELERY_ARGS: Additional Celery worker command line arguments. """ try: start_worker(queues=queues.split(','), config=obj['config'], name=name, cele...
python
def worker_start(obj, queues, name, celery_args): """ Start a worker process. \b CELERY_ARGS: Additional Celery worker command line arguments. """ try: start_worker(queues=queues.split(','), config=obj['config'], name=name, cele...
[ "def", "worker_start", "(", "obj", ",", "queues", ",", "name", ",", "celery_args", ")", ":", "try", ":", "start_worker", "(", "queues", "=", "queues", ".", "split", "(", "','", ")", ",", "config", "=", "obj", "[", "'config'", "]", ",", "name", "=", ...
Start a worker process. \b CELERY_ARGS: Additional Celery worker command line arguments.
[ "Start", "a", "worker", "process", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L292-L306
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
worker_stop
def worker_stop(obj, worker_ids): """ Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all. """ if len(worker_ids) == 0: msg = 'Would you like to stop all workers?' else: msg = '\n{}\n\n{}'.format('\n'.join(worker_ids), ...
python
def worker_stop(obj, worker_ids): """ Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all. """ if len(worker_ids) == 0: msg = 'Would you like to stop all workers?' else: msg = '\n{}\n\n{}'.format('\n'.join(worker_ids), ...
[ "def", "worker_stop", "(", "obj", ",", "worker_ids", ")", ":", "if", "len", "(", "worker_ids", ")", "==", "0", ":", "msg", "=", "'Would you like to stop all workers?'", "else", ":", "msg", "=", "'\\n{}\\n\\n{}'", ".", "format", "(", "'\\n'", ".", "join", "...
Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all.
[ "Stop", "running", "workers", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L313-L327
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
worker_status
def worker_status(obj, filter_queues, details): """ Show the status of all running workers. """ show_colors = obj['show_color'] f_queues = filter_queues.split(',') if filter_queues is not None else None workers = list_workers(config=obj['config'], filter_by_queues=f_queues) if len(workers) == 0: ...
python
def worker_status(obj, filter_queues, details): """ Show the status of all running workers. """ show_colors = obj['show_color'] f_queues = filter_queues.split(',') if filter_queues is not None else None workers = list_workers(config=obj['config'], filter_by_queues=f_queues) if len(workers) == 0: ...
[ "def", "worker_status", "(", "obj", ",", "filter_queues", ",", "details", ")", ":", "show_colors", "=", "obj", "[", "'show_color'", "]", "f_queues", "=", "filter_queues", ".", "split", "(", "','", ")", "if", "filter_queues", "is", "not", "None", "else", "N...
Show the status of all running workers.
[ "Show", "the", "status", "of", "all", "running", "workers", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L336-L384
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
monitor
def monitor(ctx, details): """ Show the worker and workflow event stream. """ ingest_config_obj(ctx, silent=False) show_colors = ctx.obj['show_color'] event_display = { JobEventName.Started: {'color': 'blue', 'label': 'started'}, JobEventName.Succeeded: {'color': 'green', 'label': 'suc...
python
def monitor(ctx, details): """ Show the worker and workflow event stream. """ ingest_config_obj(ctx, silent=False) show_colors = ctx.obj['show_color'] event_display = { JobEventName.Started: {'color': 'blue', 'label': 'started'}, JobEventName.Succeeded: {'color': 'green', 'label': 'suc...
[ "def", "monitor", "(", "ctx", ",", "details", ")", ":", "ingest_config_obj", "(", "ctx", ",", "silent", "=", "False", ")", "show_colors", "=", "ctx", ".", "obj", "[", "'show_color'", "]", "event_display", "=", "{", "JobEventName", ".", "Started", ":", "{...
Show the worker and workflow event stream.
[ "Show", "the", "worker", "and", "workflow", "event", "stream", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L390-L426
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
ext
def ext(obj, ext_name, ext_args): """ Run an extension by its name. \b EXT_NAME: The name of the extension. EXT_ARGS: Arguments that are passed to the extension. """ try: mod = import_module('lightflow_{}.__main__'.format(ext_name)) mod.main(ext_args) except ImportError as e...
python
def ext(obj, ext_name, ext_args): """ Run an extension by its name. \b EXT_NAME: The name of the extension. EXT_ARGS: Arguments that are passed to the extension. """ try: mod = import_module('lightflow_{}.__main__'.format(ext_name)) mod.main(ext_args) except ImportError as e...
[ "def", "ext", "(", "obj", ",", "ext_name", ",", "ext_args", ")", ":", "try", ":", "mod", "=", "import_module", "(", "'lightflow_{}.__main__'", ".", "format", "(", "ext_name", ")", ")", "mod", ".", "main", "(", "ext_args", ")", "except", "ImportError", "a...
Run an extension by its name. \b EXT_NAME: The name of the extension. EXT_ARGS: Arguments that are passed to the extension.
[ "Run", "an", "extension", "by", "its", "name", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L433-L447
AustralianSynchrotron/lightflow
lightflow/scripts/cli.py
_style
def _style(enabled, text, **kwargs): """ Helper function to enable/disable styled output text. Args: enable (bool): Turn on or off styling. text (string): The string that should be styled. kwargs (dict): Parameters that are passed through to click.style Returns: string: The...
python
def _style(enabled, text, **kwargs): """ Helper function to enable/disable styled output text. Args: enable (bool): Turn on or off styling. text (string): The string that should be styled. kwargs (dict): Parameters that are passed through to click.style Returns: string: The...
[ "def", "_style", "(", "enabled", ",", "text", ",", "*", "*", "kwargs", ")", ":", "if", "enabled", ":", "return", "click", ".", "style", "(", "text", ",", "*", "*", "kwargs", ")", "else", ":", "return", "text" ]
Helper function to enable/disable styled output text. Args: enable (bool): Turn on or off styling. text (string): The string that should be styled. kwargs (dict): Parameters that are passed through to click.style Returns: string: The input with either the styling applied (enabl...
[ "Helper", "function", "to", "enable", "/", "disable", "styled", "output", "text", "." ]
train
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L450-L465
dh1tw/pyhamtools
pyhamtools/utils.py
freq_to_band
def freq_to_band(freq): """converts a Frequency [kHz] into the band and mode according to the IARU bandplan Note: **DEPRECATION NOTICE** This function has been moved to pyhamtools.frequency with PyHamTools 0.4.1 Please don't use this module/function anymore. It will be r...
python
def freq_to_band(freq): """converts a Frequency [kHz] into the band and mode according to the IARU bandplan Note: **DEPRECATION NOTICE** This function has been moved to pyhamtools.frequency with PyHamTools 0.4.1 Please don't use this module/function anymore. It will be r...
[ "def", "freq_to_band", "(", "freq", ")", ":", "band", "=", "None", "mode", "=", "None", "if", "(", "(", "freq", ">=", "135", ")", "and", "(", "freq", "<=", "138", ")", ")", ":", "band", "=", "2190", "mode", "=", "const", ".", "CW", "elif", "(",...
converts a Frequency [kHz] into the band and mode according to the IARU bandplan Note: **DEPRECATION NOTICE** This function has been moved to pyhamtools.frequency with PyHamTools 0.4.1 Please don't use this module/function anymore. It will be removed soon.
[ "converts", "a", "Frequency", "[", "kHz", "]", "into", "the", "band", "and", "mode", "according", "to", "the", "IARU", "bandplan" ]
train
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/utils.py#L4-L143