partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Worker._handle_sigusr2
Drop current task.
kuyruk/worker.py
def _handle_sigusr2(self, signum: int, frame: Any) -> None: """Drop current task.""" logger.warning("Catched SIGUSR2") if self.current_task: logger.warning("Dropping current task...") raise Discard
def _handle_sigusr2(self, signum: int, frame: Any) -> None: """Drop current task.""" logger.warning("Catched SIGUSR2") if self.current_task: logger.warning("Dropping current task...") raise Discard
[ "Drop", "current", "task", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/worker.py#L395-L400
[ "def", "_handle_sigusr2", "(", "self", ",", "signum", ":", "int", ",", "frame", ":", "Any", ")", "->", "None", ":", "logger", ".", "warning", "(", "\"Catched SIGUSR2\"", ")", "if", "self", ".", "current_task", ":", "logger", ".", "warning", "(", "\"Dropp...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
configuration_get_default_folder
Return the default folder where user-specific data is stored. This depends of the system on which Python is running, :return: path to the user-specific configuration data folder
subdownloader/client/configuration.py
def configuration_get_default_folder(): """ Return the default folder where user-specific data is stored. This depends of the system on which Python is running, :return: path to the user-specific configuration data folder """ system = platform.system() if system == 'Linux': # https:/...
def configuration_get_default_folder(): """ Return the default folder where user-specific data is stored. This depends of the system on which Python is running, :return: path to the user-specific configuration data folder """ system = platform.system() if system == 'Linux': # https:/...
[ "Return", "the", "default", "folder", "where", "user", "-", "specific", "data", "is", "stored", ".", "This", "depends", "of", "the", "system", "on", "which", "Python", "is", "running", ":", "return", ":", "path", "to", "the", "user", "-", "specific", "co...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/configuration.py#L95-L115
[ "def", "configuration_get_default_folder", "(", ")", ":", "system", "=", "platform", ".", "system", "(", ")", "if", "system", "==", "'Linux'", ":", "# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html", "sys_config_path", "=", "Path", "(", "os",...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_locale
Create a new Language instance from a locale string :param locale: locale as string :return: Language instance with instance.locale() == locale if locale is valid else instance of Unknown Language
subdownloader/languages/language.py
def from_locale(cls, locale): """ Create a new Language instance from a locale string :param locale: locale as string :return: Language instance with instance.locale() == locale if locale is valid else instance of Unknown Language """ locale = str(locale) if local...
def from_locale(cls, locale): """ Create a new Language instance from a locale string :param locale: locale as string :return: Language instance with instance.locale() == locale if locale is valid else instance of Unknown Language """ locale = str(locale) if local...
[ "Create", "a", "new", "Language", "instance", "from", "a", "locale", "string", ":", "param", "locale", ":", "locale", "as", "string", ":", "return", ":", "Language", "instance", "with", "instance", ".", "locale", "()", "==", "locale", "if", "locale", "is",...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L144-L157
[ "def", "from_locale", "(", "cls", ",", "locale", ")", ":", "locale", "=", "str", "(", "locale", ")", "if", "locale", "is", "'unknown'", ":", "return", "UnknownLanguage", "(", "locale", ")", "try", ":", "return", "cls", ".", "_from_xyz", "(", "'locale'", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_xx
Create a new Language instance from a ISO639 string :param xx: ISO639 as string :return: Language instance with instance.xx() == xx if xx is valid else instance of UnknownLanguage
subdownloader/languages/language.py
def from_xx(cls, xx): """ Create a new Language instance from a ISO639 string :param xx: ISO639 as string :return: Language instance with instance.xx() == xx if xx is valid else instance of UnknownLanguage """ xx = str(xx).lower() if xx is 'unknown': r...
def from_xx(cls, xx): """ Create a new Language instance from a ISO639 string :param xx: ISO639 as string :return: Language instance with instance.xx() == xx if xx is valid else instance of UnknownLanguage """ xx = str(xx).lower() if xx is 'unknown': r...
[ "Create", "a", "new", "Language", "instance", "from", "a", "ISO639", "string", ":", "param", "xx", ":", "ISO639", "as", "string", ":", "return", ":", "Language", "instance", "with", "instance", ".", "xx", "()", "==", "xx", "if", "xx", "is", "valid", "e...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L160-L173
[ "def", "from_xx", "(", "cls", ",", "xx", ")", ":", "xx", "=", "str", "(", "xx", ")", ".", "lower", "(", ")", "if", "xx", "is", "'unknown'", ":", "return", "UnknownLanguage", "(", "xx", ")", "try", ":", "return", "cls", ".", "_from_xyz", "(", "'IS...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_xxx
Create a new Language instance from a LanguageID string :param xxx: LanguageID as string :return: Language instance with instance.xxx() == xxx if xxx is valid else instance of UnknownLanguage
subdownloader/languages/language.py
def from_xxx(cls, xxx): """ Create a new Language instance from a LanguageID string :param xxx: LanguageID as string :return: Language instance with instance.xxx() == xxx if xxx is valid else instance of UnknownLanguage """ xxx = str(xxx).lower() if xxx is 'unknow...
def from_xxx(cls, xxx): """ Create a new Language instance from a LanguageID string :param xxx: LanguageID as string :return: Language instance with instance.xxx() == xxx if xxx is valid else instance of UnknownLanguage """ xxx = str(xxx).lower() if xxx is 'unknow...
[ "Create", "a", "new", "Language", "instance", "from", "a", "LanguageID", "string", ":", "param", "xxx", ":", "LanguageID", "as", "string", ":", "return", ":", "Language", "instance", "with", "instance", ".", "xxx", "()", "==", "xxx", "if", "xxx", "is", "...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L176-L189
[ "def", "from_xxx", "(", "cls", ",", "xxx", ")", ":", "xxx", "=", "str", "(", "xxx", ")", ".", "lower", "(", ")", "if", "xxx", "is", "'unknown'", ":", "return", "UnknownLanguage", "(", "xxx", ")", "try", ":", "return", "cls", ".", "_from_xyz", "(", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_name
Create a new Language instance from a name as string :param name: name as string :return: Language instance with instance.name() == name if name is valid else instance of UnknownLanguage
subdownloader/languages/language.py
def from_name(cls, name): """ Create a new Language instance from a name as string :param name: name as string :return: Language instance with instance.name() == name if name is valid else instance of UnknownLanguage """ name = str(name).lower() if name is 'unknow...
def from_name(cls, name): """ Create a new Language instance from a name as string :param name: name as string :return: Language instance with instance.name() == name if name is valid else instance of UnknownLanguage """ name = str(name).lower() if name is 'unknow...
[ "Create", "a", "new", "Language", "instance", "from", "a", "name", "as", "string", ":", "param", "name", ":", "name", "as", "string", ":", "return", ":", "Language", "instance", "with", "instance", ".", "name", "()", "==", "name", "if", "name", "is", "...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L192-L205
[ "def", "from_name", "(", "cls", ",", "name", ")", ":", "name", "=", "str", "(", "name", ")", ".", "lower", "(", ")", "if", "name", "is", "'unknown'", "or", "name", "is", "_", "(", "'unknown'", ")", ":", "return", "UnknownLanguage", "(", "name", ")"...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language._from_xyz
Private helper function to create new Language instance. :param xyzkey: one of ('locale', 'ISO639', 'LanguageID', 'LanguageName') :param xyzvalue: corresponding value of xyzkey :return: Language instance
subdownloader/languages/language.py
def _from_xyz(cls, xyzkey, xyzvalue): """ Private helper function to create new Language instance. :param xyzkey: one of ('locale', 'ISO639', 'LanguageID', 'LanguageName') :param xyzvalue: corresponding value of xyzkey :return: Language instance """ if xyzvalue ==...
def _from_xyz(cls, xyzkey, xyzvalue): """ Private helper function to create new Language instance. :param xyzkey: one of ('locale', 'ISO639', 'LanguageID', 'LanguageName') :param xyzvalue: corresponding value of xyzkey :return: Language instance """ if xyzvalue ==...
[ "Private", "helper", "function", "to", "create", "new", "Language", "instance", ".", ":", "param", "xyzkey", ":", "one", "of", "(", "locale", "ISO639", "LanguageID", "LanguageName", ")", ":", "param", "xyzvalue", ":", "corresponding", "value", "of", "xyzkey", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L208-L221
[ "def", "_from_xyz", "(", "cls", ",", "xyzkey", ",", "xyzvalue", ")", ":", "if", "xyzvalue", "==", "'unknown'", "or", "xyzvalue", "==", "_", "(", "'unknown'", ")", ":", "return", "UnknownLanguage", "(", "xyzvalue", ")", "for", "lang_id", ",", "lang_data", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_unknown
Try to create a Language instance having only some limited data about the Language. If no corresponding Language is found, a NotALanguageException is thrown. :param value: data known about the language as string :param xx: True if the value may be a locale :param xxx: True if the value m...
subdownloader/languages/language.py
def from_unknown(cls, value, xx=False, xxx=False, locale=False, name=False): """ Try to create a Language instance having only some limited data about the Language. If no corresponding Language is found, a NotALanguageException is thrown. :param value: data known about the language as st...
def from_unknown(cls, value, xx=False, xxx=False, locale=False, name=False): """ Try to create a Language instance having only some limited data about the Language. If no corresponding Language is found, a NotALanguageException is thrown. :param value: data known about the language as st...
[ "Try", "to", "create", "a", "Language", "instance", "having", "only", "some", "limited", "data", "about", "the", "Language", ".", "If", "no", "corresponding", "Language", "is", "found", "a", "NotALanguageException", "is", "thrown", ".", ":", "param", "value", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L224-L245
[ "def", "from_unknown", "(", "cls", ",", "value", ",", "xx", "=", "False", ",", "xxx", "=", "False", ",", "locale", "=", "False", ",", "name", "=", "False", ")", ":", "# Use 2 lists instead of dict ==> order known", "keys", "=", "[", "'ISO639'", ",", "'Lang...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Language.from_file
Try do determine the language of a text file. :param filepath: string file path :param chunk_size: amount of bytes of file to read to determine language :return: Language instance if detection succeeded, otherwise return UnknownLanguage
subdownloader/languages/language.py
def from_file(cls, filepath, chunk_size=None): """ Try do determine the language of a text file. :param filepath: string file path :param chunk_size: amount of bytes of file to read to determine language :return: Language instance if detection succeeded, otherwise return UnknownL...
def from_file(cls, filepath, chunk_size=None): """ Try do determine the language of a text file. :param filepath: string file path :param chunk_size: amount of bytes of file to read to determine language :return: Language instance if detection succeeded, otherwise return UnknownL...
[ "Try", "do", "determine", "the", "language", "of", "a", "text", "file", ".", ":", "param", "filepath", ":", "string", "file", "path", ":", "param", "chunk_size", ":", "amount", "of", "bytes", "of", "file", "to", "read", "to", "determine", "language", ":"...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/languages/language.py#L248-L262
[ "def", "from_file", "(", "cls", ",", "filepath", ",", "chunk_size", "=", "None", ")", ":", "log", ".", "debug", "(", "'Language.from_file: \"{}\", chunk={} ...'", ".", "format", "(", "filepath", ",", "chunk_size", ")", ")", "with", "filepath", ".", "open", "...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SearchFileWidget.onFolderTreeClicked
What to do when a Folder in the tree is clicked
subdownloader/client/gui/searchFileWidget.py
def onFolderTreeClicked(self, proxyIndex): """What to do when a Folder in the tree is clicked""" if not proxyIndex.isValid(): return index = self.proxyFileModel.mapToSource(proxyIndex) settings = QSettings() folder_path = self.fileModel.filePath(index) settin...
def onFolderTreeClicked(self, proxyIndex): """What to do when a Folder in the tree is clicked""" if not proxyIndex.isValid(): return index = self.proxyFileModel.mapToSource(proxyIndex) settings = QSettings() folder_path = self.fileModel.filePath(index) settin...
[ "What", "to", "do", "when", "a", "Folder", "in", "the", "tree", "is", "clicked" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/gui/searchFileWidget.py#L214-L222
[ "def", "onFolderTreeClicked", "(", "self", ",", "proxyIndex", ")", ":", "if", "not", "proxyIndex", ".", "isValid", "(", ")", ":", "return", "index", "=", "self", ".", "proxyFileModel", ".", "mapToSource", "(", "proxyIndex", ")", "settings", "=", "QSettings",...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Task.send_to_queue
Sends a message to the queue. A worker will run the task's function when it receives the message. :param args: Arguments that will be passed to task on execution. :param kwargs: Keyword arguments that will be passed to task on execution. :param host: Send this task to specif...
kuyruk/task.py
def send_to_queue( self, args: Tuple=(), kwargs: Dict[str, Any]={}, host: str=None, wait_result: Union[int, float]=None, message_ttl: Union[int, float]=None, ) -> Any: """ Sends a message to the queue. A worker will run ...
def send_to_queue( self, args: Tuple=(), kwargs: Dict[str, Any]={}, host: str=None, wait_result: Union[int, float]=None, message_ttl: Union[int, float]=None, ) -> Any: """ Sends a message to the queue. A worker will run ...
[ "Sends", "a", "message", "to", "the", "queue", ".", "A", "worker", "will", "run", "the", "task", "s", "function", "when", "it", "receives", "the", "message", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/task.py#L69-L130
[ "def", "send_to_queue", "(", "self", ",", "args", ":", "Tuple", "=", "(", ")", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "host", ":", "str", "=", "None", ",", "wait_result", ":", "Union", "[", "int", ",", "flo...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Task._get_description
Return the dictionary to be sent to the queue.
kuyruk/task.py
def _get_description(self, args: Tuple, kwargs: Dict[str, Any]) -> Dict[str, Any]: """Return the dictionary to be sent to the queue.""" return { 'id': uuid1().hex, 'args': args, 'kwargs': kwargs, 'module': self._module_name, 'function': self.f....
def _get_description(self, args: Tuple, kwargs: Dict[str, Any]) -> Dict[str, Any]: """Return the dictionary to be sent to the queue.""" return { 'id': uuid1().hex, 'args': args, 'kwargs': kwargs, 'module': self._module_name, 'function': self.f....
[ "Return", "the", "dictionary", "to", "be", "sent", "to", "the", "queue", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/task.py#L139-L151
[ "def", "_get_description", "(", "self", ",", "args", ":", "Tuple", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "'id'", ":", "uuid1", "(", ")", ".", "hex", ",", "'a...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Task.apply
Called by workers to run the wrapped function. You may call it yourself if you want to run the task in current process without sending to the queue. If task has a `retry` property it will be retried on failure. If task has a `max_run_time` property the task will not be allowed to ...
kuyruk/task.py
def apply(self, *args: Any, **kwargs: Any) -> Any: """Called by workers to run the wrapped function. You may call it yourself if you want to run the task in current process without sending to the queue. If task has a `retry` property it will be retried on failure. If task has a...
def apply(self, *args: Any, **kwargs: Any) -> Any: """Called by workers to run the wrapped function. You may call it yourself if you want to run the task in current process without sending to the queue. If task has a `retry` property it will be retried on failure. If task has a...
[ "Called", "by", "workers", "to", "run", "the", "wrapped", "function", ".", "You", "may", "call", "it", "yourself", "if", "you", "want", "to", "run", "the", "task", "in", "current", "process", "without", "sending", "to", "the", "queue", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/task.py#L156-L194
[ "def", "apply", "(", "self", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Any", ":", "def", "send_signal", "(", "sig", ":", "Signal", ",", "*", "*", "extra", ":", "Any", ")", "->", "None", ":", "self", ".", "...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Task._module_name
Module name of the wrapped function.
kuyruk/task.py
def _module_name(self) -> str: """Module name of the wrapped function.""" name = self.f.__module__ if name == '__main__': return importer.main_module_name() return name
def _module_name(self) -> str: """Module name of the wrapped function.""" name = self.f.__module__ if name == '__main__': return importer.main_module_name() return name
[ "Module", "name", "of", "the", "wrapped", "function", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/task.py#L205-L210
[ "def", "_module_name", "(", "self", ")", "->", "str", ":", "name", "=", "self", ".", "f", ".", "__module__", "if", "name", "==", "'__main__'", ":", "return", "importer", ".", "main_module_name", "(", ")", "return", "name" ]
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
i18n_install
Install internationalization support for the clients using the specified locale. If there is no support for the locale, the default locale will be used. As last resort, a null translator will be installed. :param lc: locale to install. If None, the system default locale will be used.
subdownloader/client/internationalization.py
def i18n_install(lc=None): """ Install internationalization support for the clients using the specified locale. If there is no support for the locale, the default locale will be used. As last resort, a null translator will be installed. :param lc: locale to install. If None, the system default local...
def i18n_install(lc=None): """ Install internationalization support for the clients using the specified locale. If there is no support for the locale, the default locale will be used. As last resort, a null translator will be installed. :param lc: locale to install. If None, the system default local...
[ "Install", "internationalization", "support", "for", "the", "clients", "using", "the", "specified", "locale", ".", "If", "there", "is", "no", "support", "for", "the", "locale", "the", "default", "locale", "will", "be", "used", ".", "As", "last", "resort", "a...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L17-L41
[ "def", "i18n_install", "(", "lc", "=", "None", ")", ":", "log", ".", "debug", "(", "'i18n_install( {lc} ) called.'", ".", "format", "(", "lc", "=", "lc", ")", ")", "if", "lc", "is", "None", ":", "lc", "=", "i18n_system_locale", "(", ")", "if", "lc", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
i18n_system_locale
Return the system locale :return: the system locale (as a string)
subdownloader/client/internationalization.py
def i18n_system_locale(): """ Return the system locale :return: the system locale (as a string) """ log.debug('i18n_system_locale() called') lc, encoding = locale.getlocale() log.debug('locale.getlocale() = (lc="{lc}", encoding="{encoding}).'.format(lc=lc, encoding=encoding)) if lc is No...
def i18n_system_locale(): """ Return the system locale :return: the system locale (as a string) """ log.debug('i18n_system_locale() called') lc, encoding = locale.getlocale() log.debug('locale.getlocale() = (lc="{lc}", encoding="{encoding}).'.format(lc=lc, encoding=encoding)) if lc is No...
[ "Return", "the", "system", "locale", ":", "return", ":", "the", "system", "locale", "(", "as", "a", "string", ")" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L44-L55
[ "def", "i18n_system_locale", "(", ")", ":", "log", ".", "debug", "(", "'i18n_system_locale() called'", ")", "lc", ",", "encoding", "=", "locale", ".", "getlocale", "(", ")", "log", ".", "debug", "(", "'locale.getlocale() = (lc=\"{lc}\", encoding=\"{encoding}).'", "....
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
i18n_locale_fallbacks_calculate
Calculate all child locales from a locale. e.g. for locale="pt_BR.us-ascii", returns ["pt_BR.us-ascii", "pt_BR.us", "pt_BR", "pt"] :param lc: locale for which the child locales are needed :return: all child locales (including the parameter lc)
subdownloader/client/internationalization.py
def i18n_locale_fallbacks_calculate(lc): """ Calculate all child locales from a locale. e.g. for locale="pt_BR.us-ascii", returns ["pt_BR.us-ascii", "pt_BR.us", "pt_BR", "pt"] :param lc: locale for which the child locales are needed :return: all child locales (including the parameter lc) """ ...
def i18n_locale_fallbacks_calculate(lc): """ Calculate all child locales from a locale. e.g. for locale="pt_BR.us-ascii", returns ["pt_BR.us-ascii", "pt_BR.us", "pt_BR", "pt"] :param lc: locale for which the child locales are needed :return: all child locales (including the parameter lc) """ ...
[ "Calculate", "all", "child", "locales", "from", "a", "locale", ".", "e", ".", "g", ".", "for", "locale", "=", "pt_BR", ".", "us", "-", "ascii", "returns", "[", "pt_BR", ".", "us", "-", "ascii", "pt_BR", ".", "us", "pt_BR", "pt", "]", ":", "param", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L58-L75
[ "def", "i18n_locale_fallbacks_calculate", "(", "lc", ")", ":", "log", ".", "debug", "(", "'i18n_locale_fallbacks_calculate( locale=\"{locale}\" ) called'", ".", "format", "(", "locale", "=", "lc", ")", ")", "locales", "=", "[", "]", "lc_original", "=", "lc", "whil...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
i18n_support_locale
Find out whether lc is supported. Returns all child locales (and eventually lc) which do have support. :param lc_parent: Locale for which we want to know the child locales that are supported :return: list of supported locales
subdownloader/client/internationalization.py
def i18n_support_locale(lc_parent): """ Find out whether lc is supported. Returns all child locales (and eventually lc) which do have support. :param lc_parent: Locale for which we want to know the child locales that are supported :return: list of supported locales """ log.debug('i18n_support_lo...
def i18n_support_locale(lc_parent): """ Find out whether lc is supported. Returns all child locales (and eventually lc) which do have support. :param lc_parent: Locale for which we want to know the child locales that are supported :return: list of supported locales """ log.debug('i18n_support_lo...
[ "Find", "out", "whether", "lc", "is", "supported", ".", "Returns", "all", "child", "locales", "(", "and", "eventually", "lc", ")", "which", "do", "have", "support", ".", ":", "param", "lc_parent", ":", "Locale", "for", "which", "we", "want", "to", "know"...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L78-L101
[ "def", "i18n_support_locale", "(", "lc_parent", ")", ":", "log", ".", "debug", "(", "'i18n_support_locale( locale=\"{locale}\" ) called'", ".", "format", "(", "locale", "=", "lc_parent", ")", ")", "lc_childs", "=", "i18n_locale_fallbacks_calculate", "(", "lc_parent", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
i18n_get_path
Get path to the internationalization data. :return: path as a string
subdownloader/client/internationalization.py
def i18n_get_path(): """ Get path to the internationalization data. :return: path as a string """ local_locale_path = client_get_path() / 'locale' if platform.system() == 'Linux': if local_locale_path.exists(): return local_locale_path else: return Path('/...
def i18n_get_path(): """ Get path to the internationalization data. :return: path as a string """ local_locale_path = client_get_path() / 'locale' if platform.system() == 'Linux': if local_locale_path.exists(): return local_locale_path else: return Path('/...
[ "Get", "path", "to", "the", "internationalization", "data", ".", ":", "return", ":", "path", "as", "a", "string" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L104-L116
[ "def", "i18n_get_path", "(", ")", ":", "local_locale_path", "=", "client_get_path", "(", ")", "/", "'locale'", "if", "platform", ".", "system", "(", ")", "==", "'Linux'", ":", "if", "local_locale_path", ".", "exists", "(", ")", ":", "return", "local_locale_p...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
i18n_get_supported_locales
List all locales that have internationalization data for this program :return: List of locales
subdownloader/client/internationalization.py
def i18n_get_supported_locales(): """ List all locales that have internationalization data for this program :return: List of locales """ locale_path = i18n_get_path() log.debug('Scanning translation files .mo in locale path: {}'.format(locale_path)) langs = [] mo_file = '{project}.mo'.fo...
def i18n_get_supported_locales(): """ List all locales that have internationalization data for this program :return: List of locales """ locale_path = i18n_get_path() log.debug('Scanning translation files .mo in locale path: {}'.format(locale_path)) langs = [] mo_file = '{project}.mo'.fo...
[ "List", "all", "locales", "that", "have", "internationalization", "data", "for", "this", "program", ":", "return", ":", "List", "of", "locales" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/internationalization.py#L119-L133
[ "def", "i18n_get_supported_locales", "(", ")", ":", "locale_path", "=", "i18n_get_path", "(", ")", "log", ".", "debug", "(", "'Scanning translation files .mo in locale path: {}'", ".", "format", "(", "locale_path", ")", ")", "langs", "=", "[", "]", "mo_file", "=",...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
Config.from_object
Load values from an object.
kuyruk/config.py
def from_object(self, obj: Union[str, Any]) -> None: """Load values from an object.""" if isinstance(obj, str): obj = importer.import_object_str(obj) for key in dir(obj): if key.isupper(): value = getattr(obj, key) self._setattr(key, value...
def from_object(self, obj: Union[str, Any]) -> None: """Load values from an object.""" if isinstance(obj, str): obj = importer.import_object_str(obj) for key in dir(obj): if key.isupper(): value = getattr(obj, key) self._setattr(key, value...
[ "Load", "values", "from", "an", "object", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/config.py#L62-L72
[ "def", "from_object", "(", "self", ",", "obj", ":", "Union", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "obj", "=", "importer", ".", "import_object_str", "(", "obj", ")", "for", "key",...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Config.from_dict
Load values from a dict.
kuyruk/config.py
def from_dict(self, d: Dict[str, Any]) -> None: """Load values from a dict.""" for key, value in d.items(): if key.isupper(): self._setattr(key, value) logger.info("Config is loaded from dict: %r", d)
def from_dict(self, d: Dict[str, Any]) -> None: """Load values from a dict.""" for key, value in d.items(): if key.isupper(): self._setattr(key, value) logger.info("Config is loaded from dict: %r", d)
[ "Load", "values", "from", "a", "dict", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/config.py#L74-L80
[ "def", "from_dict", "(", "self", ",", "d", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "for", "key", ",", "value", "in", "d", ".", "items", "(", ")", ":", "if", "key", ".", "isupper", "(", ")", ":", "self", ".", "_setatt...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Config.from_pyfile
Load values from a Python file.
kuyruk/config.py
def from_pyfile(self, filename: str) -> None: """Load values from a Python file.""" globals_ = {} # type: Dict[str, Any] locals_ = {} # type: Dict[str, Any] with open(filename, "rb") as f: exec(compile(f.read(), filename, 'exec'), globals_, locals_) for key, value ...
def from_pyfile(self, filename: str) -> None: """Load values from a Python file.""" globals_ = {} # type: Dict[str, Any] locals_ = {} # type: Dict[str, Any] with open(filename, "rb") as f: exec(compile(f.read(), filename, 'exec'), globals_, locals_) for key, value ...
[ "Load", "values", "from", "a", "Python", "file", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/config.py#L90-L101
[ "def", "from_pyfile", "(", "self", ",", "filename", ":", "str", ")", "->", "None", ":", "globals_", "=", "{", "}", "# type: Dict[str, Any]", "locals_", "=", "{", "}", "# type: Dict[str, Any]", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f",...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Config.from_env_vars
Load values from environment variables. Keys must start with `KUYRUK_`.
kuyruk/config.py
def from_env_vars(self) -> None: """Load values from environment variables. Keys must start with `KUYRUK_`.""" for key, value in os.environ.items(): if key.startswith('KUYRUK_'): key = key[7:] if hasattr(Config, key): try: ...
def from_env_vars(self) -> None: """Load values from environment variables. Keys must start with `KUYRUK_`.""" for key, value in os.environ.items(): if key.startswith('KUYRUK_'): key = key[7:] if hasattr(Config, key): try: ...
[ "Load", "values", "from", "environment", "variables", ".", "Keys", "must", "start", "with", "KUYRUK_", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/config.py#L103-L115
[ "def", "from_env_vars", "(", "self", ")", "->", "None", ":", "for", "key", ",", "value", "in", "os", ".", "environ", ".", "items", "(", ")", ":", "if", "key", ".", "startswith", "(", "'KUYRUK_'", ")", ":", "key", "=", "key", "[", "7", ":", "]", ...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
option
Context manager for temporarily setting a keyword argument and then restoring it to whatever it was before.
jinja_to_js/__init__.py
def option(current_kwargs, **kwargs): """ Context manager for temporarily setting a keyword argument and then restoring it to whatever it was before. """ tmp_kwargs = dict((key, current_kwargs.get(key)) for key, value in kwargs.items()) current_kwargs.update(kwargs) yield current_kwargs...
def option(current_kwargs, **kwargs): """ Context manager for temporarily setting a keyword argument and then restoring it to whatever it was before. """ tmp_kwargs = dict((key, current_kwargs.get(key)) for key, value in kwargs.items()) current_kwargs.update(kwargs) yield current_kwargs...
[ "Context", "manager", "for", "temporarily", "setting", "a", "keyword", "argument", "and", "then", "restoring", "it", "to", "whatever", "it", "was", "before", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L105-L114
[ "def", "option", "(", "current_kwargs", ",", "*", "*", "kwargs", ")", ":", "tmp_kwargs", "=", "dict", "(", "(", "key", ",", "current_kwargs", ".", "get", "(", "key", ")", ")", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ")",...
0a784b10a83d37a3171c5797547e9fc460c51289
train
is_method_call
Returns True if `node` is a method call for `method_name`. `method_name` can be either a string or an iterable of strings.
jinja_to_js/__init__.py
def is_method_call(node, method_name): """ Returns True if `node` is a method call for `method_name`. `method_name` can be either a string or an iterable of strings. """ if not isinstance(node, nodes.Call): return False if isinstance(node.node, nodes.Getattr): # e.g. foo.bar() ...
def is_method_call(node, method_name): """ Returns True if `node` is a method call for `method_name`. `method_name` can be either a string or an iterable of strings. """ if not isinstance(node, nodes.Call): return False if isinstance(node.node, nodes.Getattr): # e.g. foo.bar() ...
[ "Returns", "True", "if", "node", "is", "a", "method", "call", "for", "method_name", ".", "method_name", "can", "be", "either", "a", "string", "or", "an", "iterable", "of", "strings", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L117-L144
[ "def", "is_method_call", "(", "node", ",", "method_name", ")", ":", "if", "not", "isinstance", "(", "node", ",", "nodes", ".", "Call", ")", ":", "return", "False", "if", "isinstance", "(", "node", ".", "node", ",", "nodes", ".", "Getattr", ")", ":", ...
0a784b10a83d37a3171c5797547e9fc460c51289
train
is_loop_helper
Returns True is node is a loop helper e.g. {{ loop.index }} or {{ loop.first }}
jinja_to_js/__init__.py
def is_loop_helper(node): """ Returns True is node is a loop helper e.g. {{ loop.index }} or {{ loop.first }} """ return hasattr(node, 'node') and isinstance(node.node, nodes.Name) and node.node.name == 'loop'
def is_loop_helper(node): """ Returns True is node is a loop helper e.g. {{ loop.index }} or {{ loop.first }} """ return hasattr(node, 'node') and isinstance(node.node, nodes.Name) and node.node.name == 'loop'
[ "Returns", "True", "is", "node", "is", "a", "loop", "helper", "e", ".", "g", ".", "{{", "loop", ".", "index", "}}", "or", "{{", "loop", ".", "first", "}}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L147-L151
[ "def", "is_loop_helper", "(", "node", ")", ":", "return", "hasattr", "(", "node", ",", "'node'", ")", "and", "isinstance", "(", "node", ".", "node", ",", "nodes", ".", "Name", ")", "and", "node", ".", "node", ".", "name", "==", "'loop'" ]
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS.get_output
Returns the generated JavaScript code. Returns: str
jinja_to_js/__init__.py
def get_output(self): """ Returns the generated JavaScript code. Returns: str """ # generate the JS function string template_function = TEMPLATE_WRAPPER.format( function_name=self.js_function_name, template_code=self.output.getvalue() ...
def get_output(self): """ Returns the generated JavaScript code. Returns: str """ # generate the JS function string template_function = TEMPLATE_WRAPPER.format( function_name=self.js_function_name, template_code=self.output.getvalue() ...
[ "Returns", "the", "generated", "JavaScript", "code", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L251-L268
[ "def", "get_output", "(", "self", ")", ":", "# generate the JS function string", "template_function", "=", "TEMPLATE_WRAPPER", ".", "format", "(", "function_name", "=", "self", ".", "js_function_name", ",", "template_code", "=", "self", ".", "output", ".", "getvalue...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._get_depencency_var_name
Returns the variable name assigned to the given dependency or None if the dependency has not yet been registered. Args: dependency (str): Thet dependency that needs to be imported. Returns: str or None
jinja_to_js/__init__.py
def _get_depencency_var_name(self, dependency): """ Returns the variable name assigned to the given dependency or None if the dependency has not yet been registered. Args: dependency (str): Thet dependency that needs to be imported. Returns: str or None ...
def _get_depencency_var_name(self, dependency): """ Returns the variable name assigned to the given dependency or None if the dependency has not yet been registered. Args: dependency (str): Thet dependency that needs to be imported. Returns: str or None ...
[ "Returns", "the", "variable", "name", "assigned", "to", "the", "given", "dependency", "or", "None", "if", "the", "dependency", "has", "not", "yet", "been", "registered", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L270-L283
[ "def", "_get_depencency_var_name", "(", "self", ",", "dependency", ")", ":", "for", "dep_path", ",", "var_name", "in", "self", ".", "dependencies", ":", "if", "dep_path", "==", "dependency", ":", "return", "var_name" ]
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._add_dependency
Adds the given dependency and returns the variable name to use to access it. If `var_name` is not given then a random one will be created. Args: dependency (str): var_name (str, optional): Returns: str
jinja_to_js/__init__.py
def _add_dependency(self, dependency, var_name=None): """ Adds the given dependency and returns the variable name to use to access it. If `var_name` is not given then a random one will be created. Args: dependency (str): var_name (str, optional): Returns...
def _add_dependency(self, dependency, var_name=None): """ Adds the given dependency and returns the variable name to use to access it. If `var_name` is not given then a random one will be created. Args: dependency (str): var_name (str, optional): Returns...
[ "Adds", "the", "given", "dependency", "and", "returns", "the", "variable", "name", "to", "use", "to", "access", "it", ".", "If", "var_name", "is", "not", "given", "then", "a", "random", "one", "will", "be", "created", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L285-L302
[ "def", "_add_dependency", "(", "self", ",", "dependency", ",", "var_name", "=", "None", ")", ":", "if", "var_name", "is", "None", ":", "var_name", "=", "next", "(", "self", ".", "temp_var_names", ")", "# Don't add duplicate dependencies", "if", "(", "dependenc...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_extends
Processes an extends block e.g. `{% extends "some/template.jinja" %}`
jinja_to_js/__init__.py
def _process_extends(self, node, **kwargs): """ Processes an extends block e.g. `{% extends "some/template.jinja" %}` """ # find all the blocks in this template for b in self.ast.find_all(nodes.Block): # if not already in `child_blocks` then this is the first time a...
def _process_extends(self, node, **kwargs): """ Processes an extends block e.g. `{% extends "some/template.jinja" %}` """ # find all the blocks in this template for b in self.ast.find_all(nodes.Block): # if not already in `child_blocks` then this is the first time a...
[ "Processes", "an", "extends", "block", "e", ".", "g", ".", "{", "%", "extends", "some", "/", "template", ".", "jinja", "%", "}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L312-L347
[ "def", "_process_extends", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "# find all the blocks in this template", "for", "b", "in", "self", ".", "ast", ".", "find_all", "(", "nodes", ".", "Block", ")", ":", "# if not already in `child_blocks` the...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_block
Processes a block e.g. `{% block my_block %}{% endblock %}`
jinja_to_js/__init__.py
def _process_block(self, node, **kwargs): """ Processes a block e.g. `{% block my_block %}{% endblock %}` """ # check if this node already has a 'super_block' attribute if not hasattr(node, 'super_block'): # since it doesn't it must be the last block in the inherita...
def _process_block(self, node, **kwargs): """ Processes a block e.g. `{% block my_block %}{% endblock %}` """ # check if this node already has a 'super_block' attribute if not hasattr(node, 'super_block'): # since it doesn't it must be the last block in the inherita...
[ "Processes", "a", "block", "e", ".", "g", ".", "{", "%", "block", "my_block", "%", "}", "{", "%", "endblock", "%", "}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L349-L381
[ "def", "_process_block", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "# check if this node already has a 'super_block' attribute", "if", "not", "hasattr", "(", "node", ",", "'super_block'", ")", ":", "# since it doesn't it must be the last block in the in...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_output
Processes an output node, which will contain things like `Name` and `TemplateData` nodes.
jinja_to_js/__init__.py
def _process_output(self, node, **kwargs): """ Processes an output node, which will contain things like `Name` and `TemplateData` nodes. """ for n in node.nodes: self._process_node(n, **kwargs)
def _process_output(self, node, **kwargs): """ Processes an output node, which will contain things like `Name` and `TemplateData` nodes. """ for n in node.nodes: self._process_node(n, **kwargs)
[ "Processes", "an", "output", "node", "which", "will", "contain", "things", "like", "Name", "and", "TemplateData", "nodes", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L383-L388
[ "def", "_process_output", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "for", "n", "in", "node", ".", "nodes", ":", "self", ".", "_process_node", "(", "n", ",", "*", "*", "kwargs", ")" ]
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_templatedata
Processes a `TemplateData` node, this is just a bit of as-is text to be written to the output.
jinja_to_js/__init__.py
def _process_templatedata(self, node, **_): """ Processes a `TemplateData` node, this is just a bit of as-is text to be written to the output. """ # escape double quotes value = re.sub('"', r'\\"', node.data) # escape new lines value = re.sub('\n', r'\\n...
def _process_templatedata(self, node, **_): """ Processes a `TemplateData` node, this is just a bit of as-is text to be written to the output. """ # escape double quotes value = re.sub('"', r'\\"', node.data) # escape new lines value = re.sub('\n', r'\\n...
[ "Processes", "a", "TemplateData", "node", "this", "is", "just", "a", "bit", "of", "as", "-", "is", "text", "to", "be", "written", "to", "the", "output", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L390-L403
[ "def", "_process_templatedata", "(", "self", ",", "node", ",", "*", "*", "_", ")", ":", "# escape double quotes", "value", "=", "re", ".", "sub", "(", "'\"'", ",", "r'\\\\\"'", ",", "node", ".", "data", ")", "# escape new lines", "value", "=", "re", ".",...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_name
Processes a `Name` node. Some examples of `Name` nodes: {{ foo }} -> 'foo' is a Name {% if foo }} -> 'foo' is a Name
jinja_to_js/__init__.py
def _process_name(self, node, **kwargs): """ Processes a `Name` node. Some examples of `Name` nodes: {{ foo }} -> 'foo' is a Name {% if foo }} -> 'foo' is a Name """ with self._interpolation(): with self._python_bool_wrapper(**kwargs): ...
def _process_name(self, node, **kwargs): """ Processes a `Name` node. Some examples of `Name` nodes: {{ foo }} -> 'foo' is a Name {% if foo }} -> 'foo' is a Name """ with self._interpolation(): with self._python_bool_wrapper(**kwargs): ...
[ "Processes", "a", "Name", "node", ".", "Some", "examples", "of", "Name", "nodes", ":", "{{", "foo", "}}", "-", ">", "foo", "is", "a", "Name", "{", "%", "if", "foo", "}}", "-", ">", "foo", "is", "a", "Name" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L405-L422
[ "def", "_process_name", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_interpolation", "(", ")", ":", "with", "self", ".", "_python_bool_wrapper", "(", "*", "*", "kwargs", ")", ":", "if", "node", ".", "name", "not...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_getattr
Processes a `GetAttr` node. e.g. {{ foo.bar }}
jinja_to_js/__init__.py
def _process_getattr(self, node, **kwargs): """ Processes a `GetAttr` node. e.g. {{ foo.bar }} """ with self._interpolation(): with self._python_bool_wrapper(**kwargs) as new_kwargs: if is_loop_helper(node): self._process_loop_helper(node,...
def _process_getattr(self, node, **kwargs): """ Processes a `GetAttr` node. e.g. {{ foo.bar }} """ with self._interpolation(): with self._python_bool_wrapper(**kwargs) as new_kwargs: if is_loop_helper(node): self._process_loop_helper(node,...
[ "Processes", "a", "GetAttr", "node", ".", "e", ".", "g", ".", "{{", "foo", ".", "bar", "}}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L424-L436
[ "def", "_process_getattr", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_interpolation", "(", ")", ":", "with", "self", ".", "_python_bool_wrapper", "(", "*", "*", "kwargs", ")", "as", "new_kwargs", ":", "if", "is_...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_getitem
Processes a `GetItem` node e.g. {{ foo["bar"] }}
jinja_to_js/__init__.py
def _process_getitem(self, node, **kwargs): """ Processes a `GetItem` node e.g. {{ foo["bar"] }} """ with self._interpolation(): with self._python_bool_wrapper(**kwargs) as new_kwargs: self._process_node(node.node, **new_kwargs) if isinstance...
def _process_getitem(self, node, **kwargs): """ Processes a `GetItem` node e.g. {{ foo["bar"] }} """ with self._interpolation(): with self._python_bool_wrapper(**kwargs) as new_kwargs: self._process_node(node.node, **new_kwargs) if isinstance...
[ "Processes", "a", "GetItem", "node", "e", ".", "g", ".", "{{", "foo", "[", "bar", "]", "}}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L438-L467
[ "def", "_process_getitem", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_interpolation", "(", ")", ":", "with", "self", ".", "_python_bool_wrapper", "(", "*", "*", "kwargs", ")", "as", "new_kwargs", ":", "self", "....
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_for
Processes a for loop. e.g. {% for number in numbers %} {{ number }} {% endfor %} {% for key, value in somemap.items() %} {{ key }} -> {{ value }} {% %}
jinja_to_js/__init__.py
def _process_for(self, node, **kwargs): """ Processes a for loop. e.g. {% for number in numbers %} {{ number }} {% endfor %} {% for key, value in somemap.items() %} {{ key }} -> {{ value }} {% %} """ # since...
def _process_for(self, node, **kwargs): """ Processes a for loop. e.g. {% for number in numbers %} {{ number }} {% endfor %} {% for key, value in somemap.items() %} {{ key }} -> {{ value }} {% %} """ # since...
[ "Processes", "a", "for", "loop", ".", "e", ".", "g", ".", "{", "%", "for", "number", "in", "numbers", "%", "}", "{{", "number", "}}", "{", "%", "endfor", "%", "}", "{", "%", "for", "key", "value", "in", "somemap", ".", "items", "()", "%", "}", ...
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L469-L531
[ "def", "_process_for", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "# since a for loop can introduce new names into the context", "# we need to remember the ones that existed outside the loop", "previous_stored_names", "=", "self", ".", "stored_names", ".", "...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_if
Processes an if block e.g. `{% if foo %} do something {% endif %}`
jinja_to_js/__init__.py
def _process_if(self, node, execute_end=None, **kwargs): """ Processes an if block e.g. `{% if foo %} do something {% endif %}` """ with self._execution(): self.output.write('if') self.output.write('(') with option(kwargs, use_python_bool_wrapper=Tru...
def _process_if(self, node, execute_end=None, **kwargs): """ Processes an if block e.g. `{% if foo %} do something {% endif %}` """ with self._execution(): self.output.write('if') self.output.write('(') with option(kwargs, use_python_bool_wrapper=Tru...
[ "Processes", "an", "if", "block", "e", ".", "g", ".", "{", "%", "if", "foo", "%", "}", "do", "something", "{", "%", "endif", "%", "}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L533-L586
[ "def", "_process_if", "(", "self", ",", "node", ",", "execute_end", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_execution", "(", ")", ":", "self", ".", "output", ".", "write", "(", "'if'", ")", "self", ".", "output", ".",...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_math
Processes a math node e.g. `Div`, `Sub`, `Add`, `Mul` etc... If `function` is provided the expression is wrapped in a call to that function.
jinja_to_js/__init__.py
def _process_math(self, node, math_operator=None, function=None, **kwargs): """ Processes a math node e.g. `Div`, `Sub`, `Add`, `Mul` etc... If `function` is provided the expression is wrapped in a call to that function. """ with self._interpolation(): if function: ...
def _process_math(self, node, math_operator=None, function=None, **kwargs): """ Processes a math node e.g. `Div`, `Sub`, `Add`, `Mul` etc... If `function` is provided the expression is wrapped in a call to that function. """ with self._interpolation(): if function: ...
[ "Processes", "a", "math", "node", "e", ".", "g", ".", "Div", "Sub", "Add", "Mul", "etc", "...", "If", "function", "is", "provided", "the", "expression", "is", "wrapped", "in", "a", "call", "to", "that", "function", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L1010-L1026
[ "def", "_process_math", "(", "self", ",", "node", ",", "math_operator", "=", "None", ",", "function", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "_interpolation", "(", ")", ":", "if", "function", ":", "self", ".", "output", ...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._process_loop_helper
Processes a loop helper e.g. {{ loop.first }} or {{ loop.index }}
jinja_to_js/__init__.py
def _process_loop_helper(self, node, **kwargs): """ Processes a loop helper e.g. {{ loop.first }} or {{ loop.index }} """ if node.attr == LOOP_HELPER_INDEX: self.output.write('(arguments[1] + 1)') elif node.attr == LOOP_HELPER_INDEX_0: self.output.write('...
def _process_loop_helper(self, node, **kwargs): """ Processes a loop helper e.g. {{ loop.first }} or {{ loop.index }} """ if node.attr == LOOP_HELPER_INDEX: self.output.write('(arguments[1] + 1)') elif node.attr == LOOP_HELPER_INDEX_0: self.output.write('...
[ "Processes", "a", "loop", "helper", "e", ".", "g", ".", "{{", "loop", ".", "first", "}}", "or", "{{", "loop", ".", "index", "}}" ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L1028-L1042
[ "def", "_process_loop_helper", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "if", "node", ".", "attr", "==", "LOOP_HELPER_INDEX", ":", "self", ".", "output", ".", "write", "(", "'(arguments[1] + 1)'", ")", "elif", "node", ".", "attr", "==...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._execution
Context manager for executing some JavaScript inside a template.
jinja_to_js/__init__.py
def _execution(self): """ Context manager for executing some JavaScript inside a template. """ did_start_executing = False if self.state == STATE_DEFAULT: did_start_executing = True self.state = STATE_EXECUTING def close(): if did_st...
def _execution(self): """ Context manager for executing some JavaScript inside a template. """ did_start_executing = False if self.state == STATE_DEFAULT: did_start_executing = True self.state = STATE_EXECUTING def close(): if did_st...
[ "Context", "manager", "for", "executing", "some", "JavaScript", "inside", "a", "template", "." ]
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L1054-L1070
[ "def", "_execution", "(", "self", ")", ":", "did_start_executing", "=", "False", "if", "self", ".", "state", "==", "STATE_DEFAULT", ":", "did_start_executing", "=", "True", "self", ".", "state", "=", "STATE_EXECUTING", "def", "close", "(", ")", ":", "if", ...
0a784b10a83d37a3171c5797547e9fc460c51289
train
JinjaToJS._scoped_variables
Context manager for creating scoped variables defined by the nodes in `nodes_list`. These variables will be added to the context, and when the context manager exits the context object will be restored to it's previous state.
jinja_to_js/__init__.py
def _scoped_variables(self, nodes_list, **kwargs): """ Context manager for creating scoped variables defined by the nodes in `nodes_list`. These variables will be added to the context, and when the context manager exits the context object will be restored to it's previous state. ...
def _scoped_variables(self, nodes_list, **kwargs): """ Context manager for creating scoped variables defined by the nodes in `nodes_list`. These variables will be added to the context, and when the context manager exits the context object will be restored to it's previous state. ...
[ "Context", "manager", "for", "creating", "scoped", "variables", "defined", "by", "the", "nodes", "in", "nodes_list", ".", "These", "variables", "will", "be", "added", "to", "the", "context", "and", "when", "the", "context", "manager", "exits", "the", "context"...
jonbretman/jinja-to-js
python
https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L1094-L1133
[ "def", "_scoped_variables", "(", "self", ",", "nodes_list", ",", "*", "*", "kwargs", ")", ":", "tmp_vars", "=", "[", "]", "for", "node", "in", "nodes_list", ":", "is_assign_node", "=", "isinstance", "(", "node", ",", "nodes", ".", "Assign", ")", "name", ...
0a784b10a83d37a3171c5797547e9fc460c51289
train
download_raw
Download an url to a local file. :param url: url of the file to download :param local_path: path where the downloaded file should be saved :param callback: instance of ProgressCallback :return: True is succeeded
subdownloader/webutil.py
def download_raw(url, local_path, callback): """ Download an url to a local file. :param url: url of the file to download :param local_path: path where the downloaded file should be saved :param callback: instance of ProgressCallback :return: True is succeeded """ log.debug('download_raw...
def download_raw(url, local_path, callback): """ Download an url to a local file. :param url: url of the file to download :param local_path: path where the downloaded file should be saved :param callback: instance of ProgressCallback :return: True is succeeded """ log.debug('download_raw...
[ "Download", "an", "url", "to", "a", "local", "file", ".", ":", "param", "url", ":", "url", "of", "the", "file", "to", "download", ":", "param", "local_path", ":", "path", "where", "the", "downloaded", "file", "should", "be", "saved", ":", "param", "cal...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/webutil.py#L47-L67
[ "def", "download_raw", "(", "url", ",", "local_path", ",", "callback", ")", ":", "log", ".", "debug", "(", "'download_raw(url={url}, local_path={local_path})'", ".", "format", "(", "url", "=", "url", ",", "local_path", "=", "local_path", ")", ")", "raw_progress"...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
RawDownloadProgress.get_report_hook
Return a callback function suitable for using reporthook argument of urllib(.request).urlretrieve :return: function object
subdownloader/webutil.py
def get_report_hook(self): """ Return a callback function suitable for using reporthook argument of urllib(.request).urlretrieve :return: function object """ def report_hook(chunkNumber, chunkSize, totalSize): if totalSize != -1 and not self._callback.range_initialize...
def get_report_hook(self): """ Return a callback function suitable for using reporthook argument of urllib(.request).urlretrieve :return: function object """ def report_hook(chunkNumber, chunkSize, totalSize): if totalSize != -1 and not self._callback.range_initialize...
[ "Return", "a", "callback", "function", "suitable", "for", "using", "reporthook", "argument", "of", "urllib", "(", ".", "request", ")", ".", "urlretrieve", ":", "return", ":", "function", "object" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/webutil.py#L83-L99
[ "def", "get_report_hook", "(", "self", ")", ":", "def", "report_hook", "(", "chunkNumber", ",", "chunkSize", ",", "totalSize", ")", ":", "if", "totalSize", "!=", "-", "1", "and", "not", "self", ".", "_callback", ".", "range_initialized", "(", ")", ":", "...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
window_iterator
Instead of iterating element by element, get a number of elements at each iteration step. :param data: data to iterate on :param width: maximum number of elements to get in each iteration step :return:
subdownloader/provider/__init__.py
def window_iterator(data, width): """ Instead of iterating element by element, get a number of elements at each iteration step. :param data: data to iterate on :param width: maximum number of elements to get in each iteration step :return: """ start = 0 while start < len(data): y...
def window_iterator(data, width): """ Instead of iterating element by element, get a number of elements at each iteration step. :param data: data to iterate on :param width: maximum number of elements to get in each iteration step :return: """ start = 0 while start < len(data): y...
[ "Instead", "of", "iterating", "element", "by", "element", "get", "a", "number", "of", "elements", "at", "each", "iteration", "step", ".", ":", "param", "data", ":", "data", "to", "iterate", "on", ":", "param", "width", ":", "maximum", "number", "of", "el...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/provider/__init__.py#L5-L15
[ "def", "window_iterator", "(", "data", ",", "width", ")", ":", "start", "=", "0", "while", "start", "<", "len", "(", "data", ")", ":", "yield", "data", "[", "start", ":", "start", "+", "width", "]", "start", "+=", "width" ]
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
ProgressCallback.set_range
Set a range. The range is passed unchanged to the rangeChanged member function. :param minimum: minimum value of the range (None if no percentage is required) :param maximum: maximum value of the range (None if no percentage is required)
subdownloader/callback.py
def set_range(self, minimum, maximum): """ Set a range. The range is passed unchanged to the rangeChanged member function. :param minimum: minimum value of the range (None if no percentage is required) :param maximum: maximum value of the range (None if no percentage is required)...
def set_range(self, minimum, maximum): """ Set a range. The range is passed unchanged to the rangeChanged member function. :param minimum: minimum value of the range (None if no percentage is required) :param maximum: maximum value of the range (None if no percentage is required)...
[ "Set", "a", "range", ".", "The", "range", "is", "passed", "unchanged", "to", "the", "rangeChanged", "member", "function", ".", ":", "param", "minimum", ":", "minimum", "value", "of", "the", "range", "(", "None", "if", "no", "percentage", "is", "required", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/callback.py#L32-L41
[ "def", "set_range", "(", "self", ",", "minimum", ",", "maximum", ")", ":", "self", ".", "_min", "=", "minimum", "self", ".", "_max", "=", "maximum", "self", ".", "on_rangeChange", "(", "minimum", ",", "maximum", ")" ]
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
ProgressCallback.get_child_progress
Create a new child ProgressCallback. Minimum and maximum values of the child are mapped to parent_min and parent_max of this parent ProgressCallback. :param parent_min: minimum value of the child is mapped to parent_min of this parent ProgressCallback :param parent_max: maximum value of the chil...
subdownloader/callback.py
def get_child_progress(self, parent_min, parent_max): """ Create a new child ProgressCallback. Minimum and maximum values of the child are mapped to parent_min and parent_max of this parent ProgressCallback. :param parent_min: minimum value of the child is mapped to parent_min of this pa...
def get_child_progress(self, parent_min, parent_max): """ Create a new child ProgressCallback. Minimum and maximum values of the child are mapped to parent_min and parent_max of this parent ProgressCallback. :param parent_min: minimum value of the child is mapped to parent_min of this pa...
[ "Create", "a", "new", "child", "ProgressCallback", ".", "Minimum", "and", "maximum", "values", "of", "the", "child", "are", "mapped", "to", "parent_min", "and", "parent_max", "of", "this", "parent", "ProgressCallback", ".", ":", "param", "parent_min", ":", "mi...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/callback.py#L50-L58
[ "def", "get_child_progress", "(", "self", ",", "parent_min", ",", "parent_max", ")", ":", "return", "SubProgressCallback", "(", "parent", "=", "self", ",", "parent_min", "=", "parent_min", ",", "parent_max", "=", "parent_max", ")" ]
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
ProgressCallback.update
Call this function to inform that an update is available. This function does NOT call finish when value == maximum. :param value: The current index/position of the action. (Should be, but must not be, in the range [min, max]) :param args: extra positional arguments to pass on :param kwar...
subdownloader/callback.py
def update(self, value, *args, **kwargs): """ Call this function to inform that an update is available. This function does NOT call finish when value == maximum. :param value: The current index/position of the action. (Should be, but must not be, in the range [min, max]) :param a...
def update(self, value, *args, **kwargs): """ Call this function to inform that an update is available. This function does NOT call finish when value == maximum. :param value: The current index/position of the action. (Should be, but must not be, in the range [min, max]) :param a...
[ "Call", "this", "function", "to", "inform", "that", "an", "update", "is", "available", ".", "This", "function", "does", "NOT", "call", "finish", "when", "value", "==", "maximum", ".", ":", "param", "value", ":", "The", "current", "index", "/", "position", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/callback.py#L60-L69
[ "def", "update", "(", "self", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "log", ".", "debug", "(", "'update(value={value}, args={args}, kwargs={kwargs})'", ".", "format", "(", "value", "=", "value", ",", "args", "=", "args", ",", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
ProgressCallback.finish
Call this function to inform that the operation is finished. :param args: extra positional arguments to pass on :param kwargs: extra keyword arguments to pass on
subdownloader/callback.py
def finish(self, *args, **kwargs): """ Call this function to inform that the operation is finished. :param args: extra positional arguments to pass on :param kwargs: extra keyword arguments to pass on """ log.debug('finish(args={args}, kwargs={kwargs})'.format(args=args, ...
def finish(self, *args, **kwargs): """ Call this function to inform that the operation is finished. :param args: extra positional arguments to pass on :param kwargs: extra keyword arguments to pass on """ log.debug('finish(args={args}, kwargs={kwargs})'.format(args=args, ...
[ "Call", "this", "function", "to", "inform", "that", "the", "operation", "is", "finished", ".", ":", "param", "args", ":", "extra", "positional", "arguments", "to", "pass", "on", ":", "param", "kwargs", ":", "extra", "keyword", "arguments", "to", "pass", "o...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/callback.py#L71-L78
[ "def", "finish", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "log", ".", "debug", "(", "'finish(args={args}, kwargs={kwargs})'", ".", "format", "(", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")", ")", "self", ".", "on_fin...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SubProgressCallback.on_update
Inform the parent of progress. :param value: The value of this subprogresscallback :param args: Extra positional arguments :param kwargs: Extra keyword arguments
subdownloader/callback.py
def on_update(self, value, *args, **kwargs): """ Inform the parent of progress. :param value: The value of this subprogresscallback :param args: Extra positional arguments :param kwargs: Extra keyword arguments """ parent_value = self._parent_min if self._...
def on_update(self, value, *args, **kwargs): """ Inform the parent of progress. :param value: The value of this subprogresscallback :param args: Extra positional arguments :param kwargs: Extra keyword arguments """ parent_value = self._parent_min if self._...
[ "Inform", "the", "parent", "of", "progress", ".", ":", "param", "value", ":", "The", "value", "of", "this", "subprogresscallback", ":", "param", "args", ":", "Extra", "positional", "arguments", ":", "param", "kwargs", ":", "Extra", "keyword", "arguments" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/callback.py#L145-L156
[ "def", "on_update", "(", "self", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "parent_value", "=", "self", ".", "_parent_min", "if", "self", ".", "_max", "!=", "self", ".", "_min", ":", "sub_progress", "=", "(", "value", "-", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SDService._login
Login to the Server using username/password, empty parameters means an anonymously login Returns True if login sucessful, and False if not.
subdownloader/provider/SDService.py
def _login(self, username="", password=""): """Login to the Server using username/password, empty parameters means an anonymously login Returns True if login sucessful, and False if not. """ self.log.debug("----------------") self.log.debug("Logging in (username: %s)..." ...
def _login(self, username="", password=""): """Login to the Server using username/password, empty parameters means an anonymously login Returns True if login sucessful, and False if not. """ self.log.debug("----------------") self.log.debug("Logging in (username: %s)..." ...
[ "Login", "to", "the", "Server", "using", "username", "/", "password", "empty", "parameters", "means", "an", "anonymously", "login", "Returns", "True", "if", "login", "sucessful", "and", "False", "if", "not", "." ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/provider/SDService.py#L248-L277
[ "def", "_login", "(", "self", ",", "username", "=", "\"\"", ",", "password", "=", "\"\"", ")", ":", "self", ".", "log", ".", "debug", "(", "\"----------------\"", ")", "self", ".", "log", ".", "debug", "(", "\"Logging in (username: %s)...\"", "%", "usernam...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SDService._logout
Logout from current session(token) This functions doesn't return any boolean value, since it can 'fail' for anonymous logins
subdownloader/provider/SDService.py
def _logout(self): """Logout from current session(token) This functions doesn't return any boolean value, since it can 'fail' for anonymous logins """ self.log.debug("Logging out from session ID: %s" % self._token) try: info = self._xmlrpc_server.LogOut(self._token) ...
def _logout(self): """Logout from current session(token) This functions doesn't return any boolean value, since it can 'fail' for anonymous logins """ self.log.debug("Logging out from session ID: %s" % self._token) try: info = self._xmlrpc_server.LogOut(self._token) ...
[ "Logout", "from", "current", "session", "(", "token", ")", "This", "functions", "doesn", "t", "return", "any", "boolean", "value", "since", "it", "can", "fail", "for", "anonymous", "logins" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/provider/SDService.py#L288-L308
[ "def", "_logout", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Logging out from session ID: %s\"", "%", "self", ".", "_token", ")", "try", ":", "info", "=", "self", ".", "_xmlrpc_server", ".", "LogOut", "(", "self", ".", "_token", ")"...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
parse_arguments
Parse the program arguments. :return: argparse.Namespace object with the parsed arguments
subdownloader/client/arguments.py
def parse_arguments(args=None): """ Parse the program arguments. :return: argparse.Namespace object with the parsed arguments """ parser = get_argument_parser() # Autocomplete arguments autocomplete(parser) ns = parser.parse_args(args=args) return ArgumentSettings( program=...
def parse_arguments(args=None): """ Parse the program arguments. :return: argparse.Namespace object with the parsed arguments """ parser = get_argument_parser() # Autocomplete arguments autocomplete(parser) ns = parser.parse_args(args=args) return ArgumentSettings( program=...
[ "Parse", "the", "program", "arguments", ".", ":", "return", ":", "argparse", ".", "Namespace", "object", "with", "the", "parsed", "arguments" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/arguments.py#L18-L60
[ "def", "parse_arguments", "(", "args", "=", "None", ")", ":", "parser", "=", "get_argument_parser", "(", ")", "# Autocomplete arguments", "autocomplete", "(", "parser", ")", "ns", "=", "parser", ".", "parse_args", "(", "args", "=", "args", ")", "return", "Ar...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
get_argument_parser
Get a parser that is able to parse program arguments. :return: instance of arparse.ArgumentParser
subdownloader/client/arguments.py
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(): """ 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....
[ "Get", "a", "parser", "that", "is", "able", "to", "parse", "program", "arguments", ".", ":", "return", ":", "instance", "of", "arparse", ".", "ArgumentParser" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/arguments.py#L192-L290
[ "def", "get_argument_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "project", ".", "get_description", "(", ")", ",", "epilog", "=", "_", "(", "'Visit us at {website}.'", ")", ".", "format", "(", "website", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
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. :param queue: Queue name for the tasks. :param kwargs: Keyword arguments will be passed to :class:`~kuyruk.Task...
kuyruk/kuyruk.py
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: """ 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. ...
[ "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", "...
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L37-L53
[ "def", "task", "(", "self", ",", "queue", ":", "str", "=", "'kuyruk'", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Callable", ":", "def", "wrapper", "(", "f", ":", "Callable", ")", "->", "Task", ":", "return", "Task", "(", "f", ",", "self", ...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Kuyruk.channel
Returns a new channel from a new connection as a context manager.
kuyruk/kuyruk.py
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]: """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
[ "Returns", "a", "new", "channel", "from", "a", "new", "connection", "as", "a", "context", "manager", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L56-L62
[ "def", "channel", "(", "self", ")", "->", "Iterator", "[", "amqp", ".", "Channel", "]", ":", "with", "self", ".", "connection", "(", ")", "as", "conn", ":", "ch", "=", "conn", ".", "channel", "(", ")", "logger", ".", "info", "(", "'Opened new channel...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
Kuyruk.connection
Returns a new connection as a context manager.
kuyruk/kuyruk.py
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]: """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...
[ "Returns", "a", "new", "connection", "as", "a", "context", "manager", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L65-L87
[ "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...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
scan_videopath
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)
subdownloader/filescan.py
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): """ 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...
[ "Scan", "the", "videopath", "string", "for", "video", "files", ".", ":", "param", "videopath", ":", "Path", "object", ":", "param", "callback", ":", "Instance", "of", "ProgressCallback", ":", "param", "recursive", ":", "True", "if", "the", "scanning", "shoul...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L30-L56
[ "def", "scan_videopath", "(", "videopath", ",", "callback", ",", "recursive", "=", "False", ")", ":", "log", ".", "debug", "(", "'scan_videopath(videopath=\"{videopath}\", recursive={recursive})'", ".", "format", "(", "videopath", "=", "videopath", ",", "recursive", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
__scan_folder
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)
subdownloader/filescan.py
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): """ 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...
[ "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...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L59-L81
[ "def", "__scan_folder", "(", "folder_path", ",", "callback", ",", "recursive", "=", "False", ")", ":", "log", ".", "debug", "(", "'__scan_folder(folder_path=\"{folder_path}\", recursive={recursive})'", ".", "format", "(", "folder_path", "=", "folder_path", ",", "recur...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
merge_path_subvideo
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)
subdownloader/filescan.py
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): """ 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 ...
[ "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...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L84-L121
[ "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...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
filter_files_extensions
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
subdownloader/filescan.py
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): """ 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...
[ "Put", "the", "files", "in", "buckets", "according", "to", "extension_lists", "files", "=", "[", "movie", ".", "avi", "movie", ".", "srt", "]", "extension_lists", "=", "[[", "avi", "]", "[", "srt", "]]", "==", ">", "[[", "movie", ".", "avi", "]", "["...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/filescan.py#L124-L140
[ "def", "filter_files_extensions", "(", "files", ",", "extension_lists", ")", ":", "log", ".", "debug", "(", "'filter_files_extensions: files=\"{}\"'", ".", "format", "(", "files", ")", ")", "result", "=", "[", "[", "]", "for", "_", "in", "extension_lists", "]"...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SubtitleFile.detect_language_filename
Detect the language of a subtitle filename :param filename: filename of a subtitle :return: Language object, None if language could not be detected.
subdownloader/subtitle2.py
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): """ 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)) ...
[ "Detect", "the", "language", "of", "a", "subtitle", "filename", ":", "param", "filename", ":", "filename", "of", "a", "subtitle", ":", "return", ":", "Language", "object", "None", "if", "language", "could", "not", "be", "detected", "." ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/subtitle2.py#L57-L76
[ "def", "detect_language_filename", "(", "cls", ",", "filename", ")", ":", "log", ".", "debug", "(", "'detect_language(filename=\"{}\") ...'", ".", "format", "(", "filename", ")", ")", "root", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "filename"...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
SubtitleFileStorage.matches_video_filename
Detect whether the filename of videofile matches with this SubtitleFile. :param video: VideoFile instance :return: True if match
subdownloader/subtitle2.py
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): """ 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...
[ "Detect", "whether", "the", "filename", "of", "videofile", "matches", "with", "this", "SubtitleFile", ".", ":", "param", "video", ":", "VideoFile", "instance", ":", "return", ":", "True", "if", "match" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/subtitle2.py#L159-L197
[ "def", "matches_video_filename", "(", "self", ",", "video", ")", ":", "vid_fn", "=", "video", ".", "get_filename", "(", ")", "vid_base", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "vid_fn", ")", "vid_base", "=", "vid_base", ".", "lower", "...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
logging_file_install
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.
subdownloader/client/logger.py
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): """ 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...
[ "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"...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/logger.py#L24-L51
[ "def", "logging_file_install", "(", "path", ")", ":", "if", "path", "is", "None", ":", "path", "=", "configuration_get_default_folder", "(", ")", "/", "LOGGING_DEFAULTNAME", "if", "not", "path", ".", "parent", ".", "exists", "(", ")", ":", "log", ".", "err...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
logging_stream_install
Install logger that will output to stderr. If this function ha already installed a handler, replace it. :param loglevel: log level for the stream
subdownloader/client/logger.py
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): """ 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...
[ "Install", "logger", "that", "will", "output", "to", "stderr", ".", "If", "this", "function", "ha", "already", "installed", "a", "handler", "replace", "it", ".", ":", "param", "loglevel", ":", "log", "level", "for", "the", "stream" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/logger.py#L54-L74
[ "def", "logging_stream_install", "(", "loglevel", ")", ":", "formatter", "=", "logging", ".", "Formatter", "(", "LOGGING_FORMAT", ")", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "removeHandler", "(", "LOGGING_HANDLERS", "[", "'stream'",...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
parseFromDelimitedString
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.
corenlp_protobuf/__init__.py
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): """ 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...
[ "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...
stanfordnlp/python-corenlp-protobuf
python
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L9-L19
[ "def", "parseFromDelimitedString", "(", "obj", ",", "buf", ",", "offset", "=", "0", ")", ":", "size", ",", "pos", "=", "_DecodeVarint", "(", "buf", ",", "offset", ")", "obj", ".", "ParseFromString", "(", "buf", "[", "offset", "+", "pos", ":", "offset",...
508284aa16afaedba57e0e18dd82ebb6ec63101a
train
writeToDelimitedString
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.
corenlp_protobuf/__init__.py
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): """ 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...
stanfordnlp/python-corenlp-protobuf
python
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L21-L34
[ "def", "writeToDelimitedString", "(", "obj", ",", "stream", "=", "None", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "BytesIO", "(", ")", "_EncodeVarint", "(", "stream", ".", "write", ",", "obj", ".", "ByteSize", "(", ")", ",", "True", ...
508284aa16afaedba57e0e18dd82ebb6ec63101a
train
to_text
Helper routine that converts a Sentence protobuf to a string from its tokens.
corenlp_protobuf/__init__.py
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): """ 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
[ "Helper", "routine", "that", "converts", "a", "Sentence", "protobuf", "to", "a", "string", "from", "its", "tokens", "." ]
stanfordnlp/python-corenlp-protobuf
python
https://github.com/stanfordnlp/python-corenlp-protobuf/blob/508284aa16afaedba57e0e18dd82ebb6ec63101a/corenlp_protobuf/__init__.py#L36-L46
[ "def", "to_text", "(", "sentence", ")", ":", "text", "=", "\"\"", "for", "i", ",", "tok", "in", "enumerate", "(", "sentence", ".", "token", ")", ":", "if", "i", "!=", "0", ":", "text", "+=", "tok", ".", "before", "text", "+=", "tok", ".", "word",...
508284aa16afaedba57e0e18dd82ebb6ec63101a
train
SplashScreen.showMessage
Public method to show a message in the bottom part of the splashscreen. @param message message to be shown (string or QString)
subdownloader/client/gui/splashScreen.py
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): """ 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, ...
[ "Public", "method", "to", "show", "a", "message", "in", "the", "bottom", "part", "of", "the", "splashscreen", "." ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/gui/splashScreen.py#L22-L29
[ "def", "showMessage", "(", "self", ",", "message", ",", "*", "args", ")", ":", "QSplashScreen", ".", "showMessage", "(", "self", ",", "message", ",", "Qt", ".", "AlignBottom", "|", "Qt", ".", "AlignRight", "|", "Qt", ".", "AlignAbsolute", ",", "QColor", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
PyMediaInfoParser.parse_path
Parse a video at filepath, using pymediainfo framework. :param path: path of video to parse as string
subdownloader/metadata.py
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): """ 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...
[ "Parse", "a", "video", "at", "filepath", "using", "pymediainfo", "framework", ".", ":", "param", "path", ":", "path", "of", "video", "to", "parse", "as", "string" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/metadata.py#L82-L112
[ "def", "parse_path", "(", "path", ")", ":", "import", "pymediainfo", "metadata", "=", "Metadata", "(", ")", "log", ".", "debug", "(", "'pymediainfo: parsing \"{path}\" ...'", ".", "format", "(", "path", "=", "path", ")", ")", "parseRes", "=", "pymediainfo", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
VideoFile._read_metadata
Private function to read (if not read already) and store the metadata of the local VideoFile.
subdownloader/video2.py
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): """ 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...
[ "Private", "function", "to", "read", "(", "if", "not", "read", "already", ")", "and", "store", "the", "metadata", "of", "the", "local", "VideoFile", "." ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L81-L98
[ "def", "_read_metadata", "(", "self", ")", ":", "if", "self", ".", "_is_metadata_init", "(", ")", ":", "return", "try", ":", "log", ".", "debug", "(", "'Reading metadata of \"{path}\" ...'", ".", "format", "(", "path", "=", "self", ".", "_filepath", ")", "...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
VideoFile.get_size
Get size of this VideoFile in bytes :return: size as integer
subdownloader/video2.py
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): """ 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
[ "Get", "size", "of", "this", "VideoFile", "in", "bytes", ":", "return", ":", "size", "as", "integer" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L122-L129
[ "def", "get_size", "(", "self", ")", ":", "if", "self", ".", "_size", "is", "None", ":", "self", ".", "_size", "=", "self", ".", "_filepath", ".", "stat", "(", ")", ".", "st_size", "return", "self", ".", "_size" ]
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
VideoFile.get_osdb_hash
Get the hash of this local videofile :return: hash as string
subdownloader/video2.py
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): """ 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
[ "Get", "the", "hash", "of", "this", "local", "videofile", ":", "return", ":", "hash", "as", "string" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L131-L138
[ "def", "get_osdb_hash", "(", "self", ")", ":", "if", "self", ".", "_osdb_hash", "is", "None", ":", "self", ".", "_osdb_hash", "=", "self", ".", "_calculate_osdb_hash", "(", ")", "return", "self", ".", "_osdb_hash" ]
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
VideoFile._calculate_osdb_hash
Calculate OSDB (OpenSubtitleDataBase) hash of this VideoFile :return: hash as string
subdownloader/video2.py
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): """ 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...
[ "Calculate", "OSDB", "(", "OpenSubtitleDataBase", ")", "hash", "of", "this", "VideoFile", ":", "return", ":", "hash", "as", "string" ]
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/video2.py#L192-L227
[ "def", "_calculate_osdb_hash", "(", "self", ")", ":", "log", ".", "debug", "(", "'_calculate_OSDB_hash() of \"{path}\" ...'", ".", "format", "(", "path", "=", "self", ".", "_filepath", ")", ")", "f", "=", "self", ".", "_filepath", ".", "open", "(", "mode", ...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
import_module
Import module by it's name from following places in order: - main module - current working directory - Python path
kuyruk/importer.py
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: """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...
[ "Import", "module", "by", "it", "s", "name", "from", "following", "places", "in", "order", ":", "-", "main", "module", "-", "current", "working", "directory", "-", "Python", "path" ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/importer.py#L13-L24
[ "def", "import_module", "(", "name", ":", "str", ")", "->", "ModuleType", ":", "logger", ".", "debug", "(", "\"Importing module: %s\"", ",", "name", ")", "if", "name", "==", "main_module_name", "(", ")", ":", "return", "main_module", "return", "importlib", "...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
main_module_name
Returns main module and module name pair.
kuyruk/importer.py
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: """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...
[ "Returns", "main", "module", "and", "module", "name", "pair", "." ]
cenkalti/kuyruk
python
https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/importer.py#L40-L48
[ "def", "main_module_name", "(", ")", "->", "str", ":", "if", "not", "hasattr", "(", "main_module", ",", "'__file__'", ")", ":", "# running from interactive shell", "return", "None", "main_filename", "=", "os", ".", "path", ".", "basename", "(", "main_module", ...
c99d66be9d8fb077610f2fa883d5a1d268b42f04
train
write_stream
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
subdownloader/util.py
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): """ 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...
[ "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", ...
subdownloader/subdownloader
python
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/util.py#L43-L50
[ "def", "write_stream", "(", "src_file", ",", "destination_path", ")", ":", "with", "open", "(", "destination_path", ",", "'wb'", ")", "as", "destination_file", ":", "shutil", ".", "copyfileobj", "(", "fsrc", "=", "src_file", ",", "fdst", "=", "destination_file...
bbccedd11b18d925ad4c062b5eb65981e24d0433
train
build_dirs
Build necessary directories based on a list of file paths
drench/switchboard.py
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): ''' 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]) ...
[ "Build", "necessary", "directories", "based", "on", "a", "list", "of", "file", "paths" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L21-L35
[ "def", "build_dirs", "(", "files", ")", ":", "for", "i", "in", "files", ":", "if", "type", "(", "i", ")", "is", "list", ":", "build_dirs", "(", "i", ")", "continue", "else", ":", "if", "len", "(", "i", "[", "'path'", "]", ")", ">", "1", ":", ...
e99a8bf844a61d909d2d57629937ac672810469c
train
get_want_file_pos
Ask the user which files in file_list he or she is interested in. Return indices for the files inside file_list
drench/switchboard.py
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): ''' 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...
[ "Ask", "the", "user", "which", "files", "in", "file_list", "he", "or", "she", "is", "interested", "in", ".", "Return", "indices", "for", "the", "files", "inside", "file_list" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L38-L68
[ "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'", "]", ")", ")", ...
e99a8bf844a61d909d2d57629937ac672810469c
train
get_file_starts
Return the starting position (in bytes) of a list of files by iteratively summing their lengths
drench/switchboard.py
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): ''' 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
[ "Return", "the", "starting", "position", "(", "in", "bytes", ")", "of", "a", "list", "of", "files", "by", "iteratively", "summing", "their", "lengths" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L71-L82
[ "def", "get_file_starts", "(", "file_list", ")", ":", "starts", "=", "[", "]", "total", "=", "0", "for", "i", "in", "file_list", ":", "starts", ".", "append", "(", "total", ")", "total", "+=", "i", "[", "'length'", "]", "print", "starts", "return", "...
e99a8bf844a61d909d2d57629937ac672810469c
train
get_rightmost_index
Retrieve the highest-indexed file that starts at or before byte_index.
drench/switchboard.py
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]): ''' 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: ...
[ "Retrieve", "the", "highest", "-", "indexed", "file", "that", "starts", "at", "or", "before", "byte_index", "." ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L85-L98
[ "def", "get_rightmost_index", "(", "byte_index", "=", "0", ",", "file_starts", "=", "[", "0", "]", ")", ":", "i", "=", "1", "while", "i", "<=", "len", "(", "file_starts", ")", ":", "start", "=", "file_starts", "[", "-", "i", "]", "if", "start", "<=...
e99a8bf844a61d909d2d57629937ac672810469c
train
Switchboard.get_next_want_file
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.
drench/switchboard.py
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): ''' 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...
[ "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", "...
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L208-L230
[ "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...
e99a8bf844a61d909d2d57629937ac672810469c
train
Switchboard.vis_init
Sends the state of the BTC at the time the visualizer connects, initializing it.
drench/switchboard.py
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): ''' 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...
[ "Sends", "the", "state", "of", "the", "BTC", "at", "the", "time", "the", "visualizer", "connects", "initializing", "it", "." ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L291-L303
[ "def", "vis_init", "(", "self", ")", ":", "init_dict", "=", "{", "}", "init_dict", "[", "'kind'", "]", "=", "'init'", "assert", "len", "(", "self", ".", "want_file_pos", ")", "==", "len", "(", "self", ".", "heads_and_tails", ")", "init_dict", "[", "'wa...
e99a8bf844a61d909d2d57629937ac672810469c
train
Switchboard.broadcast
Send to the visualizer (if there is one) or enqueue for later
drench/switchboard.py
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): ''' 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()
[ "Send", "to", "the", "visualizer", "(", "if", "there", "is", "one", ")", "or", "enqueue", "for", "later" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/switchboard.py#L305-L311
[ "def", "broadcast", "(", "self", ",", "data_dict", ")", ":", "if", "self", ".", "vis_socket", ":", "self", ".", "queued_messages", ".", "append", "(", "data_dict", ")", "self", ".", "send_all_updates", "(", ")" ]
e99a8bf844a61d909d2d57629937ac672810469c
train
bencode
Turns a dictionary into a bencoded str with alphabetized keys e.g., {'spam': 'eggs', 'cow': 'moo'} --> d3:cow3:moo4:spam4:eggse
drench/tparser.py
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): ''' 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 ...
[ "Turns", "a", "dictionary", "into", "a", "bencoded", "str", "with", "alphabetized", "keys", "e", ".", "g", ".", "{", "spam", ":", "eggs", "cow", ":", "moo", "}", "--", ">", "d3", ":", "cow3", ":", "moo4", ":", "spam4", ":", "eggse" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/tparser.py#L8-L51
[ "def", "bencode", "(", "canonical", ")", ":", "in_dict", "=", "dict", "(", "canonical", ")", "def", "encode_str", "(", "in_str", ")", ":", "out_str", "=", "str", "(", "len", "(", "in_str", ")", ")", "+", "':'", "+", "in_str", "return", "out_str", "de...
e99a8bf844a61d909d2d57629937ac672810469c
train
bdecode
Bdecodes a bencoded string e.g., d3:cow3:moo4:spam4:eggse -> {'cow': 'moo', 'spam': 'eggs'}
drench/tparser.py
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): ''' 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...
[ "Bdecodes", "a", "bencoded", "string", "e", ".", "g", ".", "d3", ":", "cow3", ":", "moo4", ":", "spam4", ":", "eggse", "-", ">", "{", "cow", ":", "moo", "spam", ":", "eggs", "}" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/tparser.py#L54-L120
[ "def", "bdecode", "(", "bstring", ")", ":", "def", "get_val", "(", ")", ":", "i", "=", "reader", ".", "next", "(", ")", "if", "i", ".", "isdigit", "(", ")", ":", "str_len", "=", "get_len", "(", "i", ")", "return", "get_str", "(", "str_len", ")", ...
e99a8bf844a61d909d2d57629937ac672810469c
train
Torrent.build_payload
Builds the payload that will be sent in tracker_request
drench/drench.py
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): ''' 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 + ...
[ "Builds", "the", "payload", "that", "will", "be", "sent", "in", "tracker_request" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L153-L172
[ "def", "build_payload", "(", "self", ")", ":", "payload", "=", "{", "}", "hashed_info", "=", "hashlib", ".", "sha1", "(", "tparser", ".", "bencode", "(", "self", ".", "torrent_dict", "[", "'info'", "]", ")", ")", "self", ".", "hash_string", "=", "hashe...
e99a8bf844a61d909d2d57629937ac672810469c
train
Torrent.tracker_request
Sends the initial request to the tracker, compiling list of all peers announcing to the tracker
drench/drench.py
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): ''' 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...
[ "Sends", "the", "initial", "request", "to", "the", "tracker", "compiling", "list", "of", "all", "peers", "announcing", "to", "the", "tracker" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L175-L193
[ "def", "tracker_request", "(", "self", ")", ":", "assert", "self", ".", "torrent_dict", "[", "'info'", "]", "payload", "=", "self", ".", "build_payload", "(", ")", "if", "self", ".", "torrent_dict", "[", "'announce'", "]", ".", "startswith", "(", "'udp'", ...
e99a8bf844a61d909d2d57629937ac672810469c
train
Torrent.get_peer_ips
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
drench/drench.py
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): ''' 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']] ...
[ "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"...
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L195-L207
[ "def", "get_peer_ips", "(", "self", ")", ":", "presponse", "=", "[", "ord", "(", "i", ")", "for", "i", "in", "self", ".", "tracker_response", "[", "'peers'", "]", "]", "while", "presponse", ":", "peer_ip", "=", "(", "(", "'.'", ".", "join", "(", "s...
e99a8bf844a61d909d2d57629937ac672810469c
train
Torrent.handshake_peers
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
drench/drench.py
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): ''' 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) ...
[ "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...
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L211-L262
[ "def", "handshake_peers", "(", "self", ")", ":", "pstr", "=", "'BitTorrent protocol'", "pstrlen", "=", "len", "(", "pstr", ")", "info_hash", "=", "self", ".", "hash_string", "peer_id", "=", "self", ".", "peer_id", "packet", "=", "''", ".", "join", "(", "...
e99a8bf844a61d909d2d57629937ac672810469c
train
Torrent.initpeer
Creates a new peer object for a nvalid socket and adds it to reactor's listen list
drench/drench.py
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): ''' 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...
[ "Creates", "a", "new", "peer", "object", "for", "a", "nvalid", "socket", "and", "adds", "it", "to", "reactor", "s", "listen", "list" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/drench.py#L264-L274
[ "def", "initpeer", "(", "self", ",", "sock", ")", ":", "location_json", "=", "requests", ".", "request", "(", "\"GET\"", ",", "\"http://freegeoip.net/json/\"", "+", "sock", ".", "getpeername", "(", ")", "[", "0", "]", ")", ".", "content", "location", "=", ...
e99a8bf844a61d909d2d57629937ac672810469c
train
Peer.read
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...
drench/peer.py
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 ''' Chain of events: - process_input - check save_state and read length, id, and message accordingly - if we ...
[ "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", "...
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/peer.py#L55-L74
[ "def", "read", "(", "self", ")", ":", "try", ":", "bytes", "=", "self", ".", "sock", ".", "recv", "(", "self", ".", "max_size", ")", "except", ":", "self", ".", "torrent", ".", "kill_peer", "(", "self", ")", "return", "if", "len", "(", "bytes", "...
e99a8bf844a61d909d2d57629937ac672810469c
train
Peer.ppiece
Process a piece that we've received from a peer, writing it out to one or more files
drench/peer.py
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): ''' 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...
[ "Process", "a", "piece", "that", "we", "ve", "received", "from", "a", "peer", "writing", "it", "out", "to", "one", "or", "more", "files" ]
jefflovejapan/drench
python
https://github.com/jefflovejapan/drench/blob/e99a8bf844a61d909d2d57629937ac672810469c/drench/peer.py#L208-L257
[ "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...
e99a8bf844a61d909d2d57629937ac672810469c
train
DataStore.is_connected
Returns the connection status of the data store. Returns: bool: ``True`` if the data store is connected to the MongoDB server.
lightflow/models/datastore.py
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): """ 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...
[ "Returns", "the", "connection", "status", "of", "the", "data", "store", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L84-L97
[ "def", "is_connected", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "not", "None", ":", "try", ":", "self", ".", "_client", ".", "server_info", "(", ")", "except", "ConnectionFailure", ":", "return", "False", "return", "True", "else", ":", ...
dc53dbc1d961e20fb144273baca258060705c03e
train
DataStore.connect
Establishes a connection to the MongoDB server. Use the MongoProxy library in order to automatically handle AutoReconnect exceptions in a graceful and reliable way.
lightflow/models/datastore.py
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): """ 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, ...
[ "Establishes", "a", "connection", "to", "the", "MongoDB", "server", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L99-L120
[ "def", "connect", "(", "self", ")", ":", "mongodb_args", "=", "{", "'host'", ":", "self", ".", "host", ",", "'port'", ":", "self", ".", "port", ",", "'username'", ":", "self", ".", "_username", ",", "'password'", ":", "self", ".", "_password", ",", "...
dc53dbc1d961e20fb144273baca258060705c03e
train
DataStore.exists
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 ...
lightflow/models/datastore.py
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): """ 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...
[ "Checks", "whether", "a", "document", "with", "the", "specified", "workflow", "id", "already", "exists", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L139-L157
[ "def", "exists", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "col", "=", "db", "[", "WORKFLOW_DATA_COLLECTION_NAME", "]", "return", "col", ".", "find_one", "(", "{", "\"_i...
dc53dbc1d961e20fb144273baca258060705c03e
train
DataStore.add
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...
lightflow/models/datastore.py
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): """ 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...
[ "Adds", "a", "new", "document", "to", "the", "data", "store", "and", "returns", "its", "id", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L159-L182
[ "def", "add", "(", "self", ",", "payload", "=", "None", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "col", "=", "db", "[", "WORKFLOW_DATA_COLLECTION_NAME", "]", "return", "str", "(", "col", ".", "insert...
dc53dbc1d961e20fb144273baca258060705c03e
train
DataStore.remove
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...
lightflow/models/datastore.py
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): """ 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...
[ "Removes", "a", "document", "specified", "by", "its", "id", "from", "the", "data", "store", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L184-L207
[ "def", "remove", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "fs", "=", "GridFSProxy", "(", "GridFS", "(", "db", ".", "unproxied_object", ")", ")", "for", "grid_doc", "i...
dc53dbc1d961e20fb144273baca258060705c03e
train
DataStore.get
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...
lightflow/models/datastore.py
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): """ 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: ...
[ "Returns", "the", "document", "for", "the", "given", "workflow", "id", "." ]
AustralianSynchrotron/lightflow
python
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L209-L227
[ "def", "get", "(", "self", ",", "workflow_id", ")", ":", "try", ":", "db", "=", "self", ".", "_client", "[", "self", ".", "database", "]", "fs", "=", "GridFSProxy", "(", "GridFS", "(", "db", ".", "unproxied_object", ")", ")", "return", "DataStoreDocume...
dc53dbc1d961e20fb144273baca258060705c03e