repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
vmonaco/pohmm
pohmm/pohmm.py
Pohmm.sample_df
def sample_df(self, pstates=None, n_obs=None, random_state=None, pstate_col=PSTATE_COL, hstate_col=HSTATE_COL): """ Convenience function to generate samples a model and create a dataframe """ try: import pandas as pd except Exception as e: raise e ...
python
def sample_df(self, pstates=None, n_obs=None, random_state=None, pstate_col=PSTATE_COL, hstate_col=HSTATE_COL): """ Convenience function to generate samples a model and create a dataframe """ try: import pandas as pd except Exception as e: raise e ...
[ "def", "sample_df", "(", "self", ",", "pstates", "=", "None", ",", "n_obs", "=", "None", ",", "random_state", "=", "None", ",", "pstate_col", "=", "PSTATE_COL", ",", "hstate_col", "=", "HSTATE_COL", ")", ":", "try", ":", "import", "pandas", "as", "pd", ...
Convenience function to generate samples a model and create a dataframe
[ "Convenience", "function", "to", "generate", "samples", "a", "model", "and", "create", "a", "dataframe" ]
c00f8a62d3005a171d424549a55d46c421859ae9
https://github.com/vmonaco/pohmm/blob/c00f8a62d3005a171d424549a55d46c421859ae9/pohmm/pohmm.py#L919-L939
train
Convenience function to generate samples a model and create a dataframe
vmonaco/pohmm
pohmm/pohmm.py
Pohmm.expected_value
def expected_value(self, feature=None, pstate=None, hstate=None, pstate_prob=None, hstate_prob=None): """ Determine the joint maximum likelihood estimate """ # Use the first feature by default if feature is None: feature = self.emission_name[0] # Will default...
python
def expected_value(self, feature=None, pstate=None, hstate=None, pstate_prob=None, hstate_prob=None): """ Determine the joint maximum likelihood estimate """ # Use the first feature by default if feature is None: feature = self.emission_name[0] # Will default...
[ "def", "expected_value", "(", "self", ",", "feature", "=", "None", ",", "pstate", "=", "None", ",", "hstate", "=", "None", ",", "pstate_prob", "=", "None", ",", "hstate_prob", "=", "None", ")", ":", "# Use the first feature by default", "if", "feature", "is"...
Determine the joint maximum likelihood estimate
[ "Determine", "the", "joint", "maximum", "likelihood", "estimate" ]
c00f8a62d3005a171d424549a55d46c421859ae9
https://github.com/vmonaco/pohmm/blob/c00f8a62d3005a171d424549a55d46c421859ae9/pohmm/pohmm.py#L989-L1049
train
Determine the expected value of a particular feature.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.set_prev_sonorus
def set_prev_sonorus(self): """ Выставляет параметры звонкости/глухости, для предыдущих согласных. """ prev = self.get_prev_letter() if not prev: return if not (self.is_consonant() and prev.is_consonant()): return if self.is_sonorus() and s...
python
def set_prev_sonorus(self): """ Выставляет параметры звонкости/глухости, для предыдущих согласных. """ prev = self.get_prev_letter() if not prev: return if not (self.is_consonant() and prev.is_consonant()): return if self.is_sonorus() and s...
[ "def", "set_prev_sonorus", "(", "self", ")", ":", "prev", "=", "self", ".", "get_prev_letter", "(", ")", "if", "not", "prev", ":", "return", "if", "not", "(", "self", ".", "is_consonant", "(", ")", "and", "prev", ".", "is_consonant", "(", ")", ")", "...
Выставляет параметры звонкости/глухости, для предыдущих согласных.
[ "Выставляет", "параметры", "звонкости", "/", "глухости", "для", "предыдущих", "согласных", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L203-L218
train
Sets the previous sonorus flag for the current instance.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.set_prev_hard
def set_prev_hard(self): """ Выставляет параметры твёрдости/мягкости, для предыдущих согласных. """ prev = self.get_prev_letter() if not prev: return if not prev.is_consonant(): return if self.is_softener(prev): prev.set_hard(Fa...
python
def set_prev_hard(self): """ Выставляет параметры твёрдости/мягкости, для предыдущих согласных. """ prev = self.get_prev_letter() if not prev: return if not prev.is_consonant(): return if self.is_softener(prev): prev.set_hard(Fa...
[ "def", "set_prev_hard", "(", "self", ")", ":", "prev", "=", "self", ".", "get_prev_letter", "(", ")", "if", "not", "prev", ":", "return", "if", "not", "prev", ".", "is_consonant", "(", ")", ":", "return", "if", "self", ".", "is_softener", "(", "prev", ...
Выставляет параметры твёрдости/мягкости, для предыдущих согласных.
[ "Выставляет", "параметры", "твёрдости", "/", "мягкости", "для", "предыдущих", "согласных", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L220-L232
train
Выставляет параметры �
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.is_after_acc
def is_after_acc(self): """ Буква распологается после ударения. """ prev = self._prev_letter() while True: if not prev: return False if prev.is_shock(): return True prev = prev._prev_letter()
python
def is_after_acc(self): """ Буква распологается после ударения. """ prev = self._prev_letter() while True: if not prev: return False if prev.is_shock(): return True prev = prev._prev_letter()
[ "def", "is_after_acc", "(", "self", ")", ":", "prev", "=", "self", ".", "_prev_letter", "(", ")", "while", "True", ":", "if", "not", "prev", ":", "return", "False", "if", "prev", ".", "is_shock", "(", ")", ":", "return", "True", "prev", "=", "prev", ...
Буква распологается после ударения.
[ "Буква", "распологается", "после", "ударения", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L234-L244
train
Returns True if the current instance is after the exchange.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.get_prev_letter
def get_prev_letter(self): """ Возвращает предыдущий объект буквы, если она не является знаком. Если знак, то рекурсивно спускается, до ближайшей. """ prev = self._prev_letter() while True: if not prev: return prev if prev.letter in...
python
def get_prev_letter(self): """ Возвращает предыдущий объект буквы, если она не является знаком. Если знак, то рекурсивно спускается, до ближайшей. """ prev = self._prev_letter() while True: if not prev: return prev if prev.letter in...
[ "def", "get_prev_letter", "(", "self", ")", ":", "prev", "=", "self", ".", "_prev_letter", "(", ")", "while", "True", ":", "if", "not", "prev", ":", "return", "prev", "if", "prev", ".", "letter", "in", "prev", ".", "marks", ":", "prev", "=", "prev", ...
Возвращает предыдущий объект буквы, если она не является знаком. Если знак, то рекурсивно спускается, до ближайшей.
[ "Возвращает", "предыдущий", "объект", "буквы", "если", "она", "не", "является", "знаком", ".", "Если", "знак", "то", "рекурсивно", "спускается", "до", "ближайшей", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L307-L319
train
Returns the previous letter.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.get_variant
def get_variant(self, return_deaf): """ Возвращает вариант буквы. :return_deaf: True - вернуть глухой вариант. Если False - звонкий. """ return_deaf = bool(return_deaf) for variants in self.sonorus_deaf_pairs: if self.__letter in variants: ...
python
def get_variant(self, return_deaf): """ Возвращает вариант буквы. :return_deaf: True - вернуть глухой вариант. Если False - звонкий. """ return_deaf = bool(return_deaf) for variants in self.sonorus_deaf_pairs: if self.__letter in variants: ...
[ "def", "get_variant", "(", "self", ",", "return_deaf", ")", ":", "return_deaf", "=", "bool", "(", "return_deaf", ")", "for", "variants", "in", "self", ".", "sonorus_deaf_pairs", ":", "if", "self", ".", "__letter", "in", "variants", ":", "return", "variants",...
Возвращает вариант буквы. :return_deaf: True - вернуть глухой вариант. Если False - звонкий.
[ "Возвращает", "вариант", "буквы", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L327-L338
train
Returns the first available variant for this item.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.is_paired_consonant
def is_paired_consonant(self): """ Парная ли согласная. """ if not self.is_consonant(): return False for variants in self.sonorus_deaf_pairs: if self.letter in variants: return True return False
python
def is_paired_consonant(self): """ Парная ли согласная. """ if not self.is_consonant(): return False for variants in self.sonorus_deaf_pairs: if self.letter in variants: return True return False
[ "def", "is_paired_consonant", "(", "self", ")", ":", "if", "not", "self", ".", "is_consonant", "(", ")", ":", "return", "False", "for", "variants", "in", "self", ".", "sonorus_deaf_pairs", ":", "if", "self", ".", "letter", "in", "variants", ":", "return", ...
Парная ли согласная.
[ "Парная", "ли", "согласная", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L340-L349
train
Returns True if this is a consonant.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.is_sonorus
def is_sonorus(self): """ Звонкая ли согласная. """ if not self.is_consonant(): return False if self.letter in self.forever_sonorus: return True if self.letter in self.forever_deaf: return False if self.__forsed_sonorus: ...
python
def is_sonorus(self): """ Звонкая ли согласная. """ if not self.is_consonant(): return False if self.letter in self.forever_sonorus: return True if self.letter in self.forever_deaf: return False if self.__forsed_sonorus: ...
[ "def", "is_sonorus", "(", "self", ")", ":", "if", "not", "self", ".", "is_consonant", "(", ")", ":", "return", "False", "if", "self", ".", "letter", "in", "self", ".", "forever_sonorus", ":", "return", "True", "if", "self", ".", "letter", "in", "self",...
Звонкая ли согласная.
[ "Звонкая", "ли", "согласная", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L351-L368
train
Return True if the user is a sonorus.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.is_deaf
def is_deaf(self): """ Глухая ли согласная. """ if not self.is_consonant(): return False if self.letter in self.forever_deaf: return True if self.letter in self.forever_sonorus: return False if self.__forsed_sonorus: ...
python
def is_deaf(self): """ Глухая ли согласная. """ if not self.is_consonant(): return False if self.letter in self.forever_deaf: return True if self.letter in self.forever_sonorus: return False if self.__forsed_sonorus: ...
[ "def", "is_deaf", "(", "self", ")", ":", "if", "not", "self", ".", "is_consonant", "(", ")", ":", "return", "False", "if", "self", ".", "letter", "in", "self", ".", "forever_deaf", ":", "return", "True", "if", "self", ".", "letter", "in", "self", "."...
Глухая ли согласная.
[ "Глухая", "ли", "согласная", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L370-L387
train
Return True if the user is a deaf.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.end
def end(self, string): """ Проверяет, заканчивается ли последовательность букв переданной строкой. Скан производится, без учёта текущей. """ prev = self._prev_letter() for s in reversed(string): if prev.letter != s: return False if ...
python
def end(self, string): """ Проверяет, заканчивается ли последовательность букв переданной строкой. Скан производится, без учёта текущей. """ prev = self._prev_letter() for s in reversed(string): if prev.letter != s: return False if ...
[ "def", "end", "(", "self", ",", "string", ")", ":", "prev", "=", "self", ".", "_prev_letter", "(", ")", "for", "s", "in", "reversed", "(", "string", ")", ":", "if", "prev", ".", "letter", "!=", "s", ":", "return", "False", "if", "not", "prev", ":...
Проверяет, заканчивается ли последовательность букв переданной строкой. Скан производится, без учёта текущей.
[ "Проверяет", "заканчивается", "ли", "последовательность", "букв", "переданной", "строкой", ".", "Скан", "производится", "без", "учёта", "текущей", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L411-L423
train
Return True if the string ends with the current character.
NyashniyVladya/RusPhonetic
RusPhonetic/phonetic_module.py
Letter.is_softener
def is_softener(self, let): """ Является ли символ смягчающим. :let: Объект буквы, которую пытаемся смягчить. """ if let.letter in let.forever_hard: return False if not let.is_consonant(): return False if self.letter in self.vovels_set_sof...
python
def is_softener(self, let): """ Является ли символ смягчающим. :let: Объект буквы, которую пытаемся смягчить. """ if let.letter in let.forever_hard: return False if not let.is_consonant(): return False if self.letter in self.vovels_set_sof...
[ "def", "is_softener", "(", "self", ",", "let", ")", ":", "if", "let", ".", "letter", "in", "let", ".", "forever_hard", ":", "return", "False", "if", "not", "let", ".", "is_consonant", "(", ")", ":", "return", "False", "if", "self", ".", "letter", "in...
Является ли символ смягчающим. :let: Объект буквы, которую пытаемся смягчить.
[ "Является", "ли", "символ", "смягчающим", "." ]
4ecf19c59b8e84fc6376282adec2b6d84758c0af
https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L425-L444
train
returns True if the current locale is softener
nickpandolfi/Cyther
cyther/__main__.py
main
def main(args=None): """ Entry point for cyther-script, generated by setup.py on installation """ if args is None: args = sys.argv[1:] if not args: args = ['-h'] namespace = parser.parse_args(args) entry_function = namespace.func del namespace.func kwargs = namespac...
python
def main(args=None): """ Entry point for cyther-script, generated by setup.py on installation """ if args is None: args = sys.argv[1:] if not args: args = ['-h'] namespace = parser.parse_args(args) entry_function = namespace.func del namespace.func kwargs = namespac...
[ "def", "main", "(", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "if", "not", "args", ":", "args", "=", "[", "'-h'", "]", "namespace", "=", "parser", ".", "parse_args", "("...
Entry point for cyther-script, generated by setup.py on installation
[ "Entry", "point", "for", "cyther", "-", "script", "generated", "by", "setup", ".", "py", "on", "installation" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/__main__.py#L11-L25
train
Entry point for cyther - script generated by setup. py on installation
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.get_ldap_users
def get_ldap_users(self): """Retrieve user data from LDAP server.""" if (not self.conf_LDAP_SYNC_USER): return (None, None) user_keys = set(self.conf_LDAP_SYNC_USER_ATTRIBUTES.keys()) user_keys.update(self.conf_LDAP_SYNC_USER_EXTRA_ATTRIBUTES) uri_users_server, users ...
python
def get_ldap_users(self): """Retrieve user data from LDAP server.""" if (not self.conf_LDAP_SYNC_USER): return (None, None) user_keys = set(self.conf_LDAP_SYNC_USER_ATTRIBUTES.keys()) user_keys.update(self.conf_LDAP_SYNC_USER_EXTRA_ATTRIBUTES) uri_users_server, users ...
[ "def", "get_ldap_users", "(", "self", ")", ":", "if", "(", "not", "self", ".", "conf_LDAP_SYNC_USER", ")", ":", "return", "(", "None", ",", "None", ")", "user_keys", "=", "set", "(", "self", ".", "conf_LDAP_SYNC_USER_ATTRIBUTES", ".", "keys", "(", ")", "...
Retrieve user data from LDAP server.
[ "Retrieve", "user", "data", "from", "LDAP", "server", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L290-L298
train
Retrieve user data from LDAP server.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.sync_ldap_users
def sync_ldap_users(self, ldap_users): """Synchronize users with local user model.""" model = get_user_model() #Load total User starts self.stats_user_total = len(ldap_users) list_profiles = [] #Load extra profiles. This way we don't even need a callback. The same code ...
python
def sync_ldap_users(self, ldap_users): """Synchronize users with local user model.""" model = get_user_model() #Load total User starts self.stats_user_total = len(ldap_users) list_profiles = [] #Load extra profiles. This way we don't even need a callback. The same code ...
[ "def", "sync_ldap_users", "(", "self", ",", "ldap_users", ")", ":", "model", "=", "get_user_model", "(", ")", "#Load total User starts", "self", ".", "stats_user_total", "=", "len", "(", "ldap_users", ")", "list_profiles", "=", "[", "]", "#Load extra profiles. Thi...
Synchronize users with local user model.
[ "Synchronize", "users", "with", "local", "user", "model", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L300-L556
train
Synchronize LDAP users with local user model.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.get_ldap_groups
def get_ldap_groups(self): """Retrieve groups from LDAP server.""" if (not self.conf_LDAP_SYNC_GROUP): return (None, None) uri_groups_server, groups = self.ldap_search(self.conf_LDAP_SYNC_GROUP_FILTER, self.conf_LDAP_SYNC_GROUP_ATTRIBUTES.keys(), self.conf_LDAP_SYNC_GROUP_INCREMENTAL...
python
def get_ldap_groups(self): """Retrieve groups from LDAP server.""" if (not self.conf_LDAP_SYNC_GROUP): return (None, None) uri_groups_server, groups = self.ldap_search(self.conf_LDAP_SYNC_GROUP_FILTER, self.conf_LDAP_SYNC_GROUP_ATTRIBUTES.keys(), self.conf_LDAP_SYNC_GROUP_INCREMENTAL...
[ "def", "get_ldap_groups", "(", "self", ")", ":", "if", "(", "not", "self", ".", "conf_LDAP_SYNC_GROUP", ")", ":", "return", "(", "None", ",", "None", ")", "uri_groups_server", ",", "groups", "=", "self", ".", "ldap_search", "(", "self", ".", "conf_LDAP_SYN...
Retrieve groups from LDAP server.
[ "Retrieve", "groups", "from", "LDAP", "server", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L558-L564
train
Retrieve groups from LDAP server.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.sync_ldap_groups
def sync_ldap_groups(self, ldap_groups): """Synchronize LDAP groups with local group model.""" groupname_field = 'name' self.stats_group_total = len(ldap_groups) for cname, ldap_attributes in ldap_groups: defaults = {} try: for name, attribute in ...
python
def sync_ldap_groups(self, ldap_groups): """Synchronize LDAP groups with local group model.""" groupname_field = 'name' self.stats_group_total = len(ldap_groups) for cname, ldap_attributes in ldap_groups: defaults = {} try: for name, attribute in ...
[ "def", "sync_ldap_groups", "(", "self", ",", "ldap_groups", ")", ":", "groupname_field", "=", "'name'", "self", ".", "stats_group_total", "=", "len", "(", "ldap_groups", ")", "for", "cname", ",", "ldap_attributes", "in", "ldap_groups", ":", "defaults", "=", "{...
Synchronize LDAP groups with local group model.
[ "Synchronize", "LDAP", "groups", "with", "local", "group", "model", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L566-L601
train
Synchronize LDAP groups with local group model.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.get_ldap_user_membership
def get_ldap_user_membership(self, user_dn): """Retrieve user membership from LDAP server.""" #Escape parenthesis in DN membership_filter = self.conf_LDAP_SYNC_GROUP_MEMBERSHIP_FILTER.replace('{distinguishedName}', user_dn.replace('(', "\(").replace(')', "\)")) try: uri, grou...
python
def get_ldap_user_membership(self, user_dn): """Retrieve user membership from LDAP server.""" #Escape parenthesis in DN membership_filter = self.conf_LDAP_SYNC_GROUP_MEMBERSHIP_FILTER.replace('{distinguishedName}', user_dn.replace('(', "\(").replace(')', "\)")) try: uri, grou...
[ "def", "get_ldap_user_membership", "(", "self", ",", "user_dn", ")", ":", "#Escape parenthesis in DN", "membership_filter", "=", "self", ".", "conf_LDAP_SYNC_GROUP_MEMBERSHIP_FILTER", ".", "replace", "(", "'{distinguishedName}'", ",", "user_dn", ".", "replace", "(", "'(...
Retrieve user membership from LDAP server.
[ "Retrieve", "user", "membership", "from", "LDAP", "server", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L603-L613
train
Retrieve LDAP user membership from LDAP server.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.sync_ldap_user_membership
def sync_ldap_user_membership(self, user, ldap_groups): """Synchronize LDAP membership to Django membership""" groupname_field = 'name' actualGroups = user.groups.values_list('name', flat=True) user_Membership_total = len(ldap_groups) user_Membership_added = 0 user_Member...
python
def sync_ldap_user_membership(self, user, ldap_groups): """Synchronize LDAP membership to Django membership""" groupname_field = 'name' actualGroups = user.groups.values_list('name', flat=True) user_Membership_total = len(ldap_groups) user_Membership_added = 0 user_Member...
[ "def", "sync_ldap_user_membership", "(", "self", ",", "user", ",", "ldap_groups", ")", ":", "groupname_field", "=", "'name'", "actualGroups", "=", "user", ".", "groups", ".", "values_list", "(", "'name'", ",", "flat", "=", "True", ")", "user_Membership_total", ...
Synchronize LDAP membership to Django membership
[ "Synchronize", "LDAP", "membership", "to", "Django", "membership" ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L615-L686
train
Synchronize LDAP membership to Django membership
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
Command.ldap_search
def ldap_search(self, filter, attributes, incremental, incremental_filter): """ Query the configured LDAP server with the provided search filter and attribute list. """ for uri in self.conf_LDAP_SYNC_BIND_URI: #Read record of this uri if (self.working_uri ...
python
def ldap_search(self, filter, attributes, incremental, incremental_filter): """ Query the configured LDAP server with the provided search filter and attribute list. """ for uri in self.conf_LDAP_SYNC_BIND_URI: #Read record of this uri if (self.working_uri ...
[ "def", "ldap_search", "(", "self", ",", "filter", ",", "attributes", ",", "incremental", ",", "incremental_filter", ")", ":", "for", "uri", "in", "self", ".", "conf_LDAP_SYNC_BIND_URI", ":", "#Read record of this uri", "if", "(", "self", ".", "working_uri", "=="...
Query the configured LDAP server with the provided search filter and attribute list.
[ "Query", "the", "configured", "LDAP", "server", "with", "the", "provided", "search", "filter", "and", "attribute", "list", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L688-L735
train
Search LDAP server with the provided filter and attributes.
marchete/django-adldap-sync
adldap_sync/management/commands/syncldap.py
PagedResultsSearchObject.paged_search_ext_s
def paged_search_ext_s(self, base, scope, filterstr='(objectClass=*)', attrlist=None, attrsonly=0, serverctrls=None, clientctrls=None, timeout=-1, sizelimit=0): """ Behaves exactly like LDAPObject.search_ext_s() but internally uses the simple paged results control to r...
python
def paged_search_ext_s(self, base, scope, filterstr='(objectClass=*)', attrlist=None, attrsonly=0, serverctrls=None, clientctrls=None, timeout=-1, sizelimit=0): """ Behaves exactly like LDAPObject.search_ext_s() but internally uses the simple paged results control to r...
[ "def", "paged_search_ext_s", "(", "self", ",", "base", ",", "scope", ",", "filterstr", "=", "'(objectClass=*)'", ",", "attrlist", "=", "None", ",", "attrsonly", "=", "0", ",", "serverctrls", "=", "None", ",", "clientctrls", "=", "None", ",", "timeout", "="...
Behaves exactly like LDAPObject.search_ext_s() but internally uses the simple paged results control to retrieve search results in chunks.
[ "Behaves", "exactly", "like", "LDAPObject", ".", "search_ext_s", "()", "but", "internally", "uses", "the", "simple", "paged", "results", "control", "to", "retrieve", "search", "results", "in", "chunks", "." ]
f6be226a4fb2a433d22e95043bd656ce902f8254
https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/management/commands/syncldap.py#L745-L773
train
This method is used to retrieve search results in chunks.
mjirik/imtools
imtools/datasets.py
sliver_reader
def sliver_reader(filename_end_mask="*[0-9].mhd", sliver_reference_dir="~/data/medical/orig/sliver07/training/", read_orig=True, read_seg=False): """ Generator for reading sliver data from directory structure. :param filename_end_mask: file selection can be controlled with this parameter :param sliver_...
python
def sliver_reader(filename_end_mask="*[0-9].mhd", sliver_reference_dir="~/data/medical/orig/sliver07/training/", read_orig=True, read_seg=False): """ Generator for reading sliver data from directory structure. :param filename_end_mask: file selection can be controlled with this parameter :param sliver_...
[ "def", "sliver_reader", "(", "filename_end_mask", "=", "\"*[0-9].mhd\"", ",", "sliver_reference_dir", "=", "\"~/data/medical/orig/sliver07/training/\"", ",", "read_orig", "=", "True", ",", "read_seg", "=", "False", ")", ":", "sliver_reference_dir", "=", "op", ".", "ex...
Generator for reading sliver data from directory structure. :param filename_end_mask: file selection can be controlled with this parameter :param sliver_reference_dir: directory with sliver .mhd and .raw files :param read_orig: read image data if is set True :param read_seg: read segmentation data if i...
[ "Generator", "for", "reading", "sliver", "data", "from", "directory", "structure", "." ]
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/datasets.py#L14-L47
train
Generator for reading sliver data from directory structure.
EVEprosper/ProsperCommon
prosper/common/flask_utils.py
make_gunicorn_config
def make_gunicorn_config( _gunicorn_config_path='', ): """makes gunicorn.conf file for launching in docker Notes: https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/ renders gunicorn.config (python) file in running dir looks for GUNICORN_{option} in envir...
python
def make_gunicorn_config( _gunicorn_config_path='', ): """makes gunicorn.conf file for launching in docker Notes: https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/ renders gunicorn.config (python) file in running dir looks for GUNICORN_{option} in envir...
[ "def", "make_gunicorn_config", "(", "_gunicorn_config_path", "=", "''", ",", ")", ":", "gunicorn_py", "=", "'''\"\"\"AUTOGENERATED BY: prosper.common.flask_utils:gunicorn_config\nBased off: https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/\n\"\"\"\nfrom os import envi...
makes gunicorn.conf file for launching in docker Notes: https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/ renders gunicorn.config (python) file in running dir looks for GUNICORN_{option} in environment vars Args: _gunicorn_config_path (str): TEST HOOK, ...
[ "makes", "gunicorn", ".", "conf", "file", "for", "launching", "in", "docker" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/flask_utils.py#L4-L34
train
creates gunicorn. conf file for launching in docker
polysquare/cmake-ast
cmakeast/printer.py
_parse_arguments
def _parse_arguments(): """Return a parser context result.""" parser = argparse.ArgumentParser(description="CMake AST Dumper") parser.add_argument("filename", nargs=1, metavar=("FILE"), help="read FILE") return parser.parse_args()
python
def _parse_arguments(): """Return a parser context result.""" parser = argparse.ArgumentParser(description="CMake AST Dumper") parser.add_argument("filename", nargs=1, metavar=("FILE"), help="read FILE") return parser.parse_args()
[ "def", "_parse_arguments", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"CMake AST Dumper\"", ")", "parser", ".", "add_argument", "(", "\"filename\"", ",", "nargs", "=", "1", ",", "metavar", "=", "(", "\"FILE\"", ...
Return a parser context result.
[ "Return", "a", "parser", "context", "result", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/printer.py#L16-L21
train
Return a parser context result.
polysquare/cmake-ast
cmakeast/printer.py
_print_details
def _print_details(extra=None): """Return a function that prints node details.""" def print_node_handler(name, node, depth): """Standard printer for a node.""" line = "{0}{1} {2} ({3}:{4})".format(depth, (" " * depth), ...
python
def _print_details(extra=None): """Return a function that prints node details.""" def print_node_handler(name, node, depth): """Standard printer for a node.""" line = "{0}{1} {2} ({3}:{4})".format(depth, (" " * depth), ...
[ "def", "_print_details", "(", "extra", "=", "None", ")", ":", "def", "print_node_handler", "(", "name", ",", "node", ",", "depth", ")", ":", "\"\"\"Standard printer for a node.\"\"\"", "line", "=", "\"{0}{1} {2} ({3}:{4})\"", ".", "format", "(", "depth", ",", "(...
Return a function that prints node details.
[ "Return", "a", "function", "that", "prints", "node", "details", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/printer.py#L24-L38
train
Return a function that prints node details.
polysquare/cmake-ast
cmakeast/printer.py
do_print
def do_print(filename): """Print the AST of filename.""" with open(filename) as cmake_file: body = ast.parse(cmake_file.read()) word_print = _print_details(lambda n: "{0} {1}".format(n.type, n.contents)) ast_visitor.recurse(...
python
def do_print(filename): """Print the AST of filename.""" with open(filename) as cmake_file: body = ast.parse(cmake_file.read()) word_print = _print_details(lambda n: "{0} {1}".format(n.type, n.contents)) ast_visitor.recurse(...
[ "def", "do_print", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "cmake_file", ":", "body", "=", "ast", ".", "parse", "(", "cmake_file", ".", "read", "(", ")", ")", "word_print", "=", "_print_details", "(", "lambda", "n", ":", ...
Print the AST of filename.
[ "Print", "the", "AST", "of", "filename", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/printer.py#L41-L58
train
Print the AST of filename.
teepark/greenhouse
greenhouse/util.py
Event.set
def set(self): """set the event to triggered after calling this method, all greenlets waiting on the event will be rescheduled, and calling :meth:`wait` will not block until :meth:`clear` has been called """ self._is_set = True scheduler.state.awoken_from_events....
python
def set(self): """set the event to triggered after calling this method, all greenlets waiting on the event will be rescheduled, and calling :meth:`wait` will not block until :meth:`clear` has been called """ self._is_set = True scheduler.state.awoken_from_events....
[ "def", "set", "(", "self", ")", ":", "self", ".", "_is_set", "=", "True", "scheduler", ".", "state", ".", "awoken_from_events", ".", "update", "(", "self", ".", "_waiters", ")", "del", "self", ".", "_waiters", "[", ":", "]" ]
set the event to triggered after calling this method, all greenlets waiting on the event will be rescheduled, and calling :meth:`wait` will not block until :meth:`clear` has been called
[ "set", "the", "event", "to", "triggered" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L35-L44
train
set the event to triggered after calling this method
teepark/greenhouse
greenhouse/util.py
Event.wait
def wait(self, timeout=None): """pause the current coroutine until this event is set .. note:: this method will block the current coroutine if :meth:`set` has not been called. :param timeout: the maximum amount of time to block in seconds. the default of ...
python
def wait(self, timeout=None): """pause the current coroutine until this event is set .. note:: this method will block the current coroutine if :meth:`set` has not been called. :param timeout: the maximum amount of time to block in seconds. the default of ...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "_is_set", ":", "return", "False", "current", "=", "compat", ".", "getcurrent", "(", ")", "# the waiting greenlet", "waketime", "=", "None", "if", "timeout", "is", "Non...
pause the current coroutine until this event is set .. note:: this method will block the current coroutine if :meth:`set` has not been called. :param timeout: the maximum amount of time to block in seconds. the default of ``None`` allows indefinite bloc...
[ "pause", "the", "current", "coroutine", "until", "this", "event", "is", "set" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L54-L89
train
pause the current coroutine until the event is set
teepark/greenhouse
greenhouse/util.py
RLock.acquire
def acquire(self, blocking=True): """acquire ownership of the lock if the lock is already owned by the calling greenlet, a counter simply gets incremented. if it is owned by a different greenlet then it will block until the lock becomes available. .. note:: this me...
python
def acquire(self, blocking=True): """acquire ownership of the lock if the lock is already owned by the calling greenlet, a counter simply gets incremented. if it is owned by a different greenlet then it will block until the lock becomes available. .. note:: this me...
[ "def", "acquire", "(", "self", ",", "blocking", "=", "True", ")", ":", "current", "=", "compat", ".", "getcurrent", "(", ")", "if", "self", ".", "_owner", "is", "current", ":", "self", ".", "_count", "+=", "1", "return", "True", "if", "self", ".", ...
acquire ownership of the lock if the lock is already owned by the calling greenlet, a counter simply gets incremented. if it is owned by a different greenlet then it will block until the lock becomes available. .. note:: this method will block the current coroutine if the ...
[ "acquire", "ownership", "of", "the", "lock" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L186-L221
train
acquire ownership of the lock.
teepark/greenhouse
greenhouse/util.py
RLock.release
def release(self): """release one ownership of the lock if the calling greenlet has :meth:`acquired <acquire>` the lock more than once this will simply decrement the counter. if this is a final release then a waiting greenlet is awoken :raises: `RuntimeError` if the...
python
def release(self): """release one ownership of the lock if the calling greenlet has :meth:`acquired <acquire>` the lock more than once this will simply decrement the counter. if this is a final release then a waiting greenlet is awoken :raises: `RuntimeError` if the...
[ "def", "release", "(", "self", ")", ":", "if", "not", "self", ".", "_locked", "or", "self", ".", "_owner", "is", "not", "compat", ".", "getcurrent", "(", ")", ":", "raise", "RuntimeError", "(", "\"cannot release un-acquired lock\"", ")", "self", ".", "_cou...
release one ownership of the lock if the calling greenlet has :meth:`acquired <acquire>` the lock more than once this will simply decrement the counter. if this is a final release then a waiting greenlet is awoken :raises: `RuntimeError` if the calling greenlet is not the l...
[ "release", "one", "ownership", "of", "the", "lock" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L223-L245
train
release one ownership of the lock more than once
teepark/greenhouse
greenhouse/util.py
Condition.wait
def wait(self, timeout=None): """wait to be woken up by the condition .. note:: this method will block the current coroutine until a :meth:`notify` wakes it back up. :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Loc...
python
def wait(self, timeout=None): """wait to be woken up by the condition .. note:: this method will block the current coroutine until a :meth:`notify` wakes it back up. :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Loc...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_is_owned", "(", ")", ":", "raise", "RuntimeError", "(", "\"cannot wait on un-acquired lock\"", ")", "current", "=", "compat", ".", "getcurrent", "(", ")", "waket...
wait to be woken up by the condition .. note:: this method will block the current coroutine until a :meth:`notify` wakes it back up. :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>`
[ "wait", "to", "be", "woken", "up", "by", "the", "condition" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L274-L306
train
wait for the current lock to be woken up by the condition
teepark/greenhouse
greenhouse/util.py
Condition.notify
def notify(self, num=1): """wake one or more waiting greenlets :param num: the number of waiters to wake (default 1) :type num: int :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>` """ if not self._is_own...
python
def notify(self, num=1): """wake one or more waiting greenlets :param num: the number of waiters to wake (default 1) :type num: int :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>` """ if not self._is_own...
[ "def", "notify", "(", "self", ",", "num", "=", "1", ")", ":", "if", "not", "self", ".", "_is_owned", "(", ")", ":", "raise", "RuntimeError", "(", "\"cannot wait on un-acquired lock\"", ")", "for", "i", "in", "xrange", "(", "min", "(", "num", ",", "len"...
wake one or more waiting greenlets :param num: the number of waiters to wake (default 1) :type num: int :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>`
[ "wake", "one", "or", "more", "waiting", "greenlets" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L308-L321
train
wake one or more waiting greenlets
teepark/greenhouse
greenhouse/util.py
Condition.notify_all
def notify_all(self): """wake all waiting greenlets :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>` """ if not self._is_owned(): raise RuntimeError("cannot wait on un-acquired lock") scheduler.state.a...
python
def notify_all(self): """wake all waiting greenlets :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>` """ if not self._is_owned(): raise RuntimeError("cannot wait on un-acquired lock") scheduler.state.a...
[ "def", "notify_all", "(", "self", ")", ":", "if", "not", "self", ".", "_is_owned", "(", ")", ":", "raise", "RuntimeError", "(", "\"cannot wait on un-acquired lock\"", ")", "scheduler", ".", "state", ".", "awoken_from_events", ".", "update", "(", "x", "[", "0...
wake all waiting greenlets :raises: `RuntimeError` if the underlying lock hasn't been :meth:`acquired <Lock.acquire>`
[ "wake", "all", "waiting", "greenlets" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L323-L333
train
wake all waiting greenlets
teepark/greenhouse
greenhouse/util.py
Semaphore.acquire
def acquire(self, blocking=True): """decrement the counter, waiting if it is already at 0 .. note:: if the counter is already at 0, this method will block the current coroutine until a :meth:`release` increments it again. :param blocking: whether or not to ...
python
def acquire(self, blocking=True): """decrement the counter, waiting if it is already at 0 .. note:: if the counter is already at 0, this method will block the current coroutine until a :meth:`release` increments it again. :param blocking: whether or not to ...
[ "def", "acquire", "(", "self", ",", "blocking", "=", "True", ")", ":", "if", "self", ".", "_value", ":", "self", ".", "_value", "-=", "1", "return", "True", "if", "not", "blocking", ":", "return", "False", "self", ".", "_waiters", ".", "append", "(",...
decrement the counter, waiting if it is already at 0 .. note:: if the counter is already at 0, this method will block the current coroutine until a :meth:`release` increments it again. :param blocking: whether or not to block if the counter is already at 0 (default...
[ "decrement", "the", "counter", "waiting", "if", "it", "is", "already", "at", "0" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L351-L376
train
decrement the counter blocking if it is already at 0
teepark/greenhouse
greenhouse/util.py
Semaphore.release
def release(self): "increment the counter, waking up a waiter if there was any" if self._waiters: scheduler.state.awoken_from_events.add(self._waiters.popleft()) else: self._value += 1
python
def release(self): "increment the counter, waking up a waiter if there was any" if self._waiters: scheduler.state.awoken_from_events.add(self._waiters.popleft()) else: self._value += 1
[ "def", "release", "(", "self", ")", ":", "if", "self", ".", "_waiters", ":", "scheduler", ".", "state", ".", "awoken_from_events", ".", "add", "(", "self", ".", "_waiters", ".", "popleft", "(", ")", ")", "else", ":", "self", ".", "_value", "+=", "1" ...
increment the counter, waking up a waiter if there was any
[ "increment", "the", "counter", "waking", "up", "a", "waiter", "if", "there", "was", "any" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L378-L383
train
increment the counter waking up a waiter if there was any
teepark/greenhouse
greenhouse/util.py
Thread.start
def start(self): """schedule to start the greenlet that runs this thread's function :raises: `RuntimeError` if the thread has already been started """ if self._started: raise RuntimeError("thread already started") def run(): try: self.run...
python
def start(self): """schedule to start the greenlet that runs this thread's function :raises: `RuntimeError` if the thread has already been started """ if self._started: raise RuntimeError("thread already started") def run(): try: self.run...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_started", ":", "raise", "RuntimeError", "(", "\"thread already started\"", ")", "def", "run", "(", ")", ":", "try", ":", "self", ".", "run", "(", "*", "self", ".", "_args", ",", "*", "*", ...
schedule to start the greenlet that runs this thread's function :raises: `RuntimeError` if the thread has already been started
[ "schedule", "to", "start", "the", "greenlet", "that", "runs", "this", "thread", "s", "function" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L512-L532
train
start the greenlet that runs this thread s function
teepark/greenhouse
greenhouse/util.py
Thread.join
def join(self, timeout=None): """block until this thread terminates .. note:: this method can block the calling coroutine if the thread has not yet completed. :param timeout: the maximum time to wait. with the default of ``None``, waits indefini...
python
def join(self, timeout=None): """block until this thread terminates .. note:: this method can block the calling coroutine if the thread has not yet completed. :param timeout: the maximum time to wait. with the default of ``None``, waits indefini...
[ "def", "join", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_started", ":", "raise", "RuntimeError", "(", "\"cannot join thread before it is started\"", ")", "if", "compat", ".", "getcurrent", "(", ")", "is", "self", ".", ...
block until this thread terminates .. note:: this method can block the calling coroutine if the thread has not yet completed. :param timeout: the maximum time to wait. with the default of ``None``, waits indefinitely :type timeout: int, float or...
[ "block", "until", "this", "thread", "terminates" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L542-L563
train
block until this thread terminates the current thread
teepark/greenhouse
greenhouse/util.py
Timer.cancel
def cancel(self): """attempt to prevent the timer from ever running its function :returns: ``True`` if it was successful, ``False`` if the timer had already run or been cancelled """ done = self.finished.is_set() self.finished.set() return not don...
python
def cancel(self): """attempt to prevent the timer from ever running its function :returns: ``True`` if it was successful, ``False`` if the timer had already run or been cancelled """ done = self.finished.is_set() self.finished.set() return not don...
[ "def", "cancel", "(", "self", ")", ":", "done", "=", "self", ".", "finished", ".", "is_set", "(", ")", "self", ".", "finished", ".", "set", "(", ")", "return", "not", "done" ]
attempt to prevent the timer from ever running its function :returns: ``True`` if it was successful, ``False`` if the timer had already run or been cancelled
[ "attempt", "to", "prevent", "the", "timer", "from", "ever", "running", "its", "function" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L655-L664
train
attempt to prevent the timer from ever running its function
teepark/greenhouse
greenhouse/util.py
Timer.wrap
def wrap(cls, secs, args=(), kwargs=None): """a classmethod decorator to immediately turn a function into a timer .. note:: you won't find this on `threading.Timer`, it is an extension to that API this is a function *returning a decorator*, so it is used like so: ...
python
def wrap(cls, secs, args=(), kwargs=None): """a classmethod decorator to immediately turn a function into a timer .. note:: you won't find this on `threading.Timer`, it is an extension to that API this is a function *returning a decorator*, so it is used like so: ...
[ "def", "wrap", "(", "cls", ",", "secs", ",", "args", "=", "(", ")", ",", "kwargs", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "return", "cls", "(", "secs", ",", "func", ",", "args", ",", "kwargs", ")", "return", "decorator"...
a classmethod decorator to immediately turn a function into a timer .. note:: you won't find this on `threading.Timer`, it is an extension to that API this is a function *returning a decorator*, so it is used like so: >>> @Timer.wrap(5, args=("world",)) >>> de...
[ "a", "classmethod", "decorator", "to", "immediately", "turn", "a", "function", "into", "a", "timer" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L673-L700
train
a classmethod decorator to immediately turn a function into a Timer
teepark/greenhouse
greenhouse/util.py
Queue.get
def get(self, block=True, timeout=None): """get an item out of the queue .. note:: if `block` is ``True`` (the default) and the queue is :meth`empty`, this method will block the current coroutine until something has been :meth:`put`. :param block: ...
python
def get(self, block=True, timeout=None): """get an item out of the queue .. note:: if `block` is ``True`` (the default) and the queue is :meth`empty`, this method will block the current coroutine until something has been :meth:`put`. :param block: ...
[ "def", "get", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_data", ":", "if", "not", "block", ":", "raise", "Empty", "(", ")", "current", "=", "compat", ".", "getcurrent", "(", ")", "wa...
get an item out of the queue .. note:: if `block` is ``True`` (the default) and the queue is :meth`empty`, this method will block the current coroutine until something has been :meth:`put`. :param block: whether to block if there is no data yet availabl...
[ "get", "an", "item", "out", "of", "the", "queue" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L743-L789
train
get an item from the queue
teepark/greenhouse
greenhouse/util.py
Queue.put
def put(self, item, block=True, timeout=None): """put an item into the queue .. note:: if the queue was created with a `maxsize` and it is currently :meth:`full`, this method will block the calling coroutine until another coroutine :meth:`get`\ s an item. :...
python
def put(self, item, block=True, timeout=None): """put an item into the queue .. note:: if the queue was created with a `maxsize` and it is currently :meth:`full`, this method will block the calling coroutine until another coroutine :meth:`get`\ s an item. :...
[ "def", "put", "(", "self", ",", "item", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "full", "(", ")", ":", "if", "not", "block", ":", "raise", "Full", "(", ")", "current", "=", "compat", ".", "getcurrent",...
put an item into the queue .. note:: if the queue was created with a `maxsize` and it is currently :meth:`full`, this method will block the calling coroutine until another coroutine :meth:`get`\ s an item. :param item: the object to put into the queue, can be any t...
[ "put", "an", "item", "into", "the", "queue" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L803-L852
train
put an item into the queue.
teepark/greenhouse
greenhouse/util.py
Queue.task_done
def task_done(self): """mark that a "job" (corresponding to a :meth:`put` or :meth:`put_nowait` call) is finished the :meth:`join` method won't complete until the number of :meth:`task_done` calls equals the number of :meth:`put` calls """ if not self._open_tasks: ...
python
def task_done(self): """mark that a "job" (corresponding to a :meth:`put` or :meth:`put_nowait` call) is finished the :meth:`join` method won't complete until the number of :meth:`task_done` calls equals the number of :meth:`put` calls """ if not self._open_tasks: ...
[ "def", "task_done", "(", "self", ")", ":", "if", "not", "self", ".", "_open_tasks", ":", "raise", "ValueError", "(", "\"task_done() called too many times\"", ")", "self", ".", "_open_tasks", "-=", "1", "if", "not", "self", ".", "_open_tasks", ":", "self", "....
mark that a "job" (corresponding to a :meth:`put` or :meth:`put_nowait` call) is finished the :meth:`join` method won't complete until the number of :meth:`task_done` calls equals the number of :meth:`put` calls
[ "mark", "that", "a", "job", "(", "corresponding", "to", "a", ":", "meth", ":", "put", "or", ":", "meth", ":", "put_nowait", "call", ")", "is", "finished" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L870-L881
train
mark that a job is done
teepark/greenhouse
greenhouse/util.py
Counter.increment
def increment(self): "increment the counter, and wake anyone waiting for the new value" self._count += 1 waiters = self._waiters.pop(self._count, []) if waiters: scheduler.state.awoken_from_events.update(waiters)
python
def increment(self): "increment the counter, and wake anyone waiting for the new value" self._count += 1 waiters = self._waiters.pop(self._count, []) if waiters: scheduler.state.awoken_from_events.update(waiters)
[ "def", "increment", "(", "self", ")", ":", "self", ".", "_count", "+=", "1", "waiters", "=", "self", ".", "_waiters", ".", "pop", "(", "self", ".", "_count", ",", "[", "]", ")", "if", "waiters", ":", "scheduler", ".", "state", ".", "awoken_from_event...
increment the counter, and wake anyone waiting for the new value
[ "increment", "the", "counter", "and", "wake", "anyone", "waiting", "for", "the", "new", "value" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L952-L957
train
increment the counter and wake anyone waiting for the new value
teepark/greenhouse
greenhouse/util.py
Counter.wait
def wait(self, until=0): """wait until the count has reached a particular number .. note:: this method can block the current greenlet :param until: the number to wait for the count to get down (or up) to. default 0 :type until: int """ if self._count != unti...
python
def wait(self, until=0): """wait until the count has reached a particular number .. note:: this method can block the current greenlet :param until: the number to wait for the count to get down (or up) to. default 0 :type until: int """ if self._count != unti...
[ "def", "wait", "(", "self", ",", "until", "=", "0", ")", ":", "if", "self", ".", "_count", "!=", "until", ":", "self", ".", "_waiters", ".", "setdefault", "(", "until", ",", "[", "]", ")", ".", "append", "(", "compat", ".", "getcurrent", "(", ")"...
wait until the count has reached a particular number .. note:: this method can block the current greenlet :param until: the number to wait for the count to get down (or up) to. default 0 :type until: int
[ "wait", "until", "the", "count", "has", "reached", "a", "particular", "number" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L976-L987
train
wait until the count has reached a particular number
teepark/greenhouse
greenhouse/ext/psycopg2.py
wait_callback
def wait_callback(connection): """callback function suitable for ``psycopg2.set_wait_callback`` pass this function to ``psycopg2.extensions.set_wait_callack`` to force any blocking operations from psycopg2 to only block the current coroutine, rather than the entire thread or process to undo the ch...
python
def wait_callback(connection): """callback function suitable for ``psycopg2.set_wait_callback`` pass this function to ``psycopg2.extensions.set_wait_callack`` to force any blocking operations from psycopg2 to only block the current coroutine, rather than the entire thread or process to undo the ch...
[ "def", "wait_callback", "(", "connection", ")", ":", "while", "1", ":", "state", "=", "connection", ".", "poll", "(", ")", "if", "state", "==", "extensions", ".", "POLL_OK", ":", "break", "elif", "state", "==", "extensions", ".", "POLL_READ", ":", "descr...
callback function suitable for ``psycopg2.set_wait_callback`` pass this function to ``psycopg2.extensions.set_wait_callack`` to force any blocking operations from psycopg2 to only block the current coroutine, rather than the entire thread or process to undo the change and return to normal blocking ope...
[ "callback", "function", "suitable", "for", "psycopg2", ".", "set_wait_callback" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/ext/psycopg2.py#L12-L32
train
wait for a coroutine to complete
CenturyLinkCloud/clc-python-sdk
src/clc/APIv1/user.py
User.GetUserDetails
def GetUserDetails(user, alias=None): """Gets the details of a specific user associated with a given account. https://t3n.zendesk.com/entries/22427672-GetUserDetails :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an ema...
python
def GetUserDetails(user, alias=None): """Gets the details of a specific user associated with a given account. https://t3n.zendesk.com/entries/22427672-GetUserDetails :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an ema...
[ "def", "GetUserDetails", "(", "user", ",", "alias", "=", "None", ")", ":", "if", "alias", "is", "None", ":", "alias", "=", "clc", ".", "v1", ".", "Account", ".", "GetAlias", "(", ")", "r", "=", "clc", ".", "v1", ".", "API", ".", "Call", "(", "'...
Gets the details of a specific user associated with a given account. https://t3n.zendesk.com/entries/22427672-GetUserDetails :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an email address
[ "Gets", "the", "details", "of", "a", "specific", "user", "associated", "with", "a", "given", "account", ".", "https", ":", "//", "t3n", ".", "zendesk", ".", "com", "/", "entries", "/", "22427672", "-", "GetUserDetails" ]
f4dba40c627cb08dd4b7d0d277e8d67578010b05
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/user.py#L28-L40
train
Get details of a specific user associated with a given account.
CenturyLinkCloud/clc-python-sdk
src/clc/APIv1/user.py
User.GetUsers
def GetUsers(alias=None): """Gets all of users assigned to a given account. https://t3n.zendesk.com/entries/22427662-GetUsers :param alias: short code for a particular account. If none will use account's default alias """ if alias is None: alias = clc.v1.Account.GetAlias() r = clc.v1.API.Call('post','...
python
def GetUsers(alias=None): """Gets all of users assigned to a given account. https://t3n.zendesk.com/entries/22427662-GetUsers :param alias: short code for a particular account. If none will use account's default alias """ if alias is None: alias = clc.v1.Account.GetAlias() r = clc.v1.API.Call('post','...
[ "def", "GetUsers", "(", "alias", "=", "None", ")", ":", "if", "alias", "is", "None", ":", "alias", "=", "clc", ".", "v1", ".", "Account", ".", "GetAlias", "(", ")", "r", "=", "clc", ".", "v1", ".", "API", ".", "Call", "(", "'post'", ",", "'User...
Gets all of users assigned to a given account. https://t3n.zendesk.com/entries/22427662-GetUsers :param alias: short code for a particular account. If none will use account's default alias
[ "Gets", "all", "of", "users", "assigned", "to", "a", "given", "account", ".", "https", ":", "//", "t3n", ".", "zendesk", ".", "com", "/", "entries", "/", "22427662", "-", "GetUsers" ]
f4dba40c627cb08dd4b7d0d277e8d67578010b05
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/user.py#L44-L54
train
Gets all of users assigned to a given account.
CenturyLinkCloud/clc-python-sdk
src/clc/APIv1/user.py
User.UpdateUser
def UpdateUser(user, email, first_name, last_name, roles,alias=None): """Update existing user within a given account. https://t3n.zendesk.com/entries/22454018-UpdateUser :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an...
python
def UpdateUser(user, email, first_name, last_name, roles,alias=None): """Update existing user within a given account. https://t3n.zendesk.com/entries/22454018-UpdateUser :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an...
[ "def", "UpdateUser", "(", "user", ",", "email", ",", "first_name", ",", "last_name", ",", "roles", ",", "alias", "=", "None", ")", ":", "if", "alias", "is", "None", ":", "alias", "=", "clc", ".", "v1", ".", "Account", ".", "GetAlias", "(", ")", "pa...
Update existing user within a given account. https://t3n.zendesk.com/entries/22454018-UpdateUser :param alias: short code for a particular account. If none will use account's default alias :param user: user name, which is typically an email address :param email: email address. Password credentials are ema...
[ "Update", "existing", "user", "within", "a", "given", "account", ".", "https", ":", "//", "t3n", ".", "zendesk", ".", "com", "/", "entries", "/", "22454018", "-", "UpdateUser" ]
f4dba40c627cb08dd4b7d0d277e8d67578010b05
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/user.py#L120-L143
train
Update existing user in a given account.
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/dependency.py
Cdependency_extractor.get_path_to_root
def get_path_to_root(self,termid): """ Returns the dependency path from the term to the root @type termid: string @param termid: the term identifier @rtype: list @return: list of dependency relations """ # Get the sentence for the term root...
python
def get_path_to_root(self,termid): """ Returns the dependency path from the term to the root @type termid: string @param termid: the term identifier @rtype: list @return: list of dependency relations """ # Get the sentence for the term root...
[ "def", "get_path_to_root", "(", "self", ",", "termid", ")", ":", "# Get the sentence for the term", "root", "=", "None", "sentence", "=", "self", ".", "sentence_for_termid", ".", "get", "(", "termid", ")", "if", "sentence", "is", "None", ":", "#try with the top ...
Returns the dependency path from the term to the root @type termid: string @param termid: the term identifier @rtype: list @return: list of dependency relations
[ "Returns", "the", "dependency", "path", "from", "the", "term", "to", "the", "root" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/dependency.py#L307-L333
train
Returns the dependency path from the term to the root node
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/dependency.py
Cdependency_extractor.get_full_dependents
def get_full_dependents(self, term_id, relations, counter = 0): """ Returns the complete list of dependents and embedded dependents of a certain term. """ counter += 1 deps = self.relations_for_term if term_id in deps and len(deps.get(term_id)) > 0: for dep in...
python
def get_full_dependents(self, term_id, relations, counter = 0): """ Returns the complete list of dependents and embedded dependents of a certain term. """ counter += 1 deps = self.relations_for_term if term_id in deps and len(deps.get(term_id)) > 0: for dep in...
[ "def", "get_full_dependents", "(", "self", ",", "term_id", ",", "relations", ",", "counter", "=", "0", ")", ":", "counter", "+=", "1", "deps", "=", "self", ".", "relations_for_term", "if", "term_id", "in", "deps", "and", "len", "(", "deps", ".", "get", ...
Returns the complete list of dependents and embedded dependents of a certain term.
[ "Returns", "the", "complete", "list", "of", "dependents", "and", "embedded", "dependents", "of", "a", "certain", "term", "." ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/dependency.py#L354-L370
train
Returns the complete list of dependents and embedded dependents of a certain term.
nickpandolfi/Cyther
cyther/configuration.py
getDirsToInclude
def getDirsToInclude(string): """ Given a string of module names, it will return the 'include' directories essential to their compilation as long as the module has the conventional 'get_include' function. """ dirs = [] a = string.strip() obj = a.split('-') if len(obj) == 1 and obj[0...
python
def getDirsToInclude(string): """ Given a string of module names, it will return the 'include' directories essential to their compilation as long as the module has the conventional 'get_include' function. """ dirs = [] a = string.strip() obj = a.split('-') if len(obj) == 1 and obj[0...
[ "def", "getDirsToInclude", "(", "string", ")", ":", "dirs", "=", "[", "]", "a", "=", "string", ".", "strip", "(", ")", "obj", "=", "a", ".", "split", "(", "'-'", ")", "if", "len", "(", "obj", ")", "==", "1", "and", "obj", "[", "0", "]", ":", ...
Given a string of module names, it will return the 'include' directories essential to their compilation as long as the module has the conventional 'get_include' function.
[ "Given", "a", "string", "of", "module", "names", "it", "will", "return", "the", "include", "directories", "essential", "to", "their", "compilation", "as", "long", "as", "the", "module", "has", "the", "conventional", "get_include", "function", "." ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L42-L63
train
Given a string of module names it will return the include directories essential to their compilation as long as the module has the conventional get_include function.
nickpandolfi/Cyther
cyther/configuration.py
purge_configs
def purge_configs(): """ These will delete any configs found in either the current directory or the user's home directory """ user_config = path(CONFIG_FILE_NAME, root=USER) inplace_config = path(CONFIG_FILE_NAME) if os.path.isfile(user_config): os.remove(user_config) if os.pat...
python
def purge_configs(): """ These will delete any configs found in either the current directory or the user's home directory """ user_config = path(CONFIG_FILE_NAME, root=USER) inplace_config = path(CONFIG_FILE_NAME) if os.path.isfile(user_config): os.remove(user_config) if os.pat...
[ "def", "purge_configs", "(", ")", ":", "user_config", "=", "path", "(", "CONFIG_FILE_NAME", ",", "root", "=", "USER", ")", "inplace_config", "=", "path", "(", "CONFIG_FILE_NAME", ")", "if", "os", ".", "path", ".", "isfile", "(", "user_config", ")", ":", ...
These will delete any configs found in either the current directory or the user's home directory
[ "These", "will", "delete", "any", "configs", "found", "in", "either", "the", "current", "directory", "or", "the", "user", "s", "home", "directory" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L66-L78
train
Purge any configs found in the current directory or the user s home directory.
nickpandolfi/Cyther
cyther/configuration.py
find_config_file
def find_config_file(): """ Returns the path to the config file if found in either the current working directory, or the user's home directory. If a config file is not found, the function will return None. """ local_config_name = path(CONFIG_FILE_NAME) if os.path.isfile(local_config_name): ...
python
def find_config_file(): """ Returns the path to the config file if found in either the current working directory, or the user's home directory. If a config file is not found, the function will return None. """ local_config_name = path(CONFIG_FILE_NAME) if os.path.isfile(local_config_name): ...
[ "def", "find_config_file", "(", ")", ":", "local_config_name", "=", "path", "(", "CONFIG_FILE_NAME", ")", "if", "os", ".", "path", ".", "isfile", "(", "local_config_name", ")", ":", "return", "local_config_name", "else", ":", "user_config_name", "=", "path", "...
Returns the path to the config file if found in either the current working directory, or the user's home directory. If a config file is not found, the function will return None.
[ "Returns", "the", "path", "to", "the", "config", "file", "if", "found", "in", "either", "the", "current", "working", "directory", "or", "the", "user", "s", "home", "directory", ".", "If", "a", "config", "file", "is", "not", "found", "the", "function", "w...
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L95-L109
train
Returns the path to the config file if found in either the current working directory or the user s home directory.
nickpandolfi/Cyther
cyther/configuration.py
get_config
def get_config(): """ Get the config data structure that is supposed to exist in the form: (Status, Data) """ config_path = find_config_file() if not config_path: return CONFIG_NOT_FOUND, None try: config_data = read_config_file(config_path) except Exception as error...
python
def get_config(): """ Get the config data structure that is supposed to exist in the form: (Status, Data) """ config_path = find_config_file() if not config_path: return CONFIG_NOT_FOUND, None try: config_data = read_config_file(config_path) except Exception as error...
[ "def", "get_config", "(", ")", ":", "config_path", "=", "find_config_file", "(", ")", "if", "not", "config_path", ":", "return", "CONFIG_NOT_FOUND", ",", "None", "try", ":", "config_data", "=", "read_config_file", "(", "config_path", ")", "except", "Exception", ...
Get the config data structure that is supposed to exist in the form: (Status, Data)
[ "Get", "the", "config", "data", "structure", "that", "is", "supposed", "to", "exist", "in", "the", "form", ":", "(", "Status", "Data", ")" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L117-L131
train
Get the config data structure that is supposed to exist in the form CONFIG_VALID CONFIG_DATA
nickpandolfi/Cyther
cyther/configuration.py
make_config_data
def make_config_data(*, guided): """ Makes the data necessary to construct a functional config file """ config_data = {} config_data[INCLUDE_DIRS_KEY] = _make_include_dirs(guided=guided) config_data[RUNTIME_DIRS_KEY] = _make_runtime_dirs(guided=guided) config_data[RUNTIME_KEY] = _make_runtim...
python
def make_config_data(*, guided): """ Makes the data necessary to construct a functional config file """ config_data = {} config_data[INCLUDE_DIRS_KEY] = _make_include_dirs(guided=guided) config_data[RUNTIME_DIRS_KEY] = _make_runtime_dirs(guided=guided) config_data[RUNTIME_KEY] = _make_runtim...
[ "def", "make_config_data", "(", "*", ",", "guided", ")", ":", "config_data", "=", "{", "}", "config_data", "[", "INCLUDE_DIRS_KEY", "]", "=", "_make_include_dirs", "(", "guided", "=", "guided", ")", "config_data", "[", "RUNTIME_DIRS_KEY", "]", "=", "_make_runt...
Makes the data necessary to construct a functional config file
[ "Makes", "the", "data", "necessary", "to", "construct", "a", "functional", "config", "file" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L308-L317
train
Makes the data necessary to construct a functional config file.
nickpandolfi/Cyther
cyther/configuration.py
make_config_file
def make_config_file(guided=False): """ Options: --auto, --guided, --manual Places for the file: --inplace, --user """ config_path = _make_config_location(guided=guided) config_data = make_config_data(guided=guided) write_config_file(config_path, config_data)
python
def make_config_file(guided=False): """ Options: --auto, --guided, --manual Places for the file: --inplace, --user """ config_path = _make_config_location(guided=guided) config_data = make_config_data(guided=guided) write_config_file(config_path, config_data)
[ "def", "make_config_file", "(", "guided", "=", "False", ")", ":", "config_path", "=", "_make_config_location", "(", "guided", "=", "guided", ")", "config_data", "=", "make_config_data", "(", "guided", "=", "guided", ")", "write_config_file", "(", "config_path", ...
Options: --auto, --guided, --manual Places for the file: --inplace, --user
[ "Options", ":", "--", "auto", "--", "guided", "--", "manual", "Places", "for", "the", "file", ":", "--", "inplace", "--", "user" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L320-L329
train
Create a config file for the current language.
nickpandolfi/Cyther
cyther/configuration.py
generate_configurations
def generate_configurations(*, guided=False, fresh_start=False, save=False): """ If a config file is found in the standard locations, it will be loaded and the config data would be retuned. If not found, then generate the data on the fly, and return it """ if fresh_start: purge_configs(...
python
def generate_configurations(*, guided=False, fresh_start=False, save=False): """ If a config file is found in the standard locations, it will be loaded and the config data would be retuned. If not found, then generate the data on the fly, and return it """ if fresh_start: purge_configs(...
[ "def", "generate_configurations", "(", "*", ",", "guided", "=", "False", ",", "fresh_start", "=", "False", ",", "save", "=", "False", ")", ":", "if", "fresh_start", ":", "purge_configs", "(", ")", "loaded_status", ",", "loaded_data", "=", "get_config", "(", ...
If a config file is found in the standard locations, it will be loaded and the config data would be retuned. If not found, then generate the data on the fly, and return it
[ "If", "a", "config", "file", "is", "found", "in", "the", "standard", "locations", "it", "will", "be", "loaded", "and", "the", "config", "data", "would", "be", "retuned", ".", "If", "not", "found", "then", "generate", "the", "data", "on", "the", "fly", ...
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L333-L353
train
Generates the data for the current node.
iron-io/iron_mq_python
iron_mq.py
Queue.info
def info(self): """Execute an HTTP request to get details on a queue, and return it. """ url = "queues/%s" % (self.name,) result = self.client.get(url) return result['body']['queue']
python
def info(self): """Execute an HTTP request to get details on a queue, and return it. """ url = "queues/%s" % (self.name,) result = self.client.get(url) return result['body']['queue']
[ "def", "info", "(", "self", ")", ":", "url", "=", "\"queues/%s\"", "%", "(", "self", ".", "name", ",", ")", "result", "=", "self", ".", "client", ".", "get", "(", "url", ")", "return", "result", "[", "'body'", "]", "[", "'queue'", "]" ]
Execute an HTTP request to get details on a queue, and return it.
[ "Execute", "an", "HTTP", "request", "to", "get", "details", "on", "a", "queue", "and", "return", "it", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L33-L40
train
Execute an HTTP request to get details on a queue and return it.
iron-io/iron_mq_python
iron_mq.py
Queue.clear
def clear(self): """Executes an HTTP request to clear all contents of a queue.""" url = "queues/%s/messages" % self.name result = self.client.delete(url = url, body = json.dumps({}), headers={'Content-Type': 'application/jso...
python
def clear(self): """Executes an HTTP request to clear all contents of a queue.""" url = "queues/%s/messages" % self.name result = self.client.delete(url = url, body = json.dumps({}), headers={'Content-Type': 'application/jso...
[ "def", "clear", "(", "self", ")", ":", "url", "=", "\"queues/%s/messages\"", "%", "self", ".", "name", "result", "=", "self", ".", "client", ".", "delete", "(", "url", "=", "url", ",", "body", "=", "json", ".", "dumps", "(", "{", "}", ")", ",", "...
Executes an HTTP request to clear all contents of a queue.
[ "Executes", "an", "HTTP", "request", "to", "clear", "all", "contents", "of", "a", "queue", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L54-L61
train
Executes an HTTP request to clear all contents of a queue.
iron-io/iron_mq_python
iron_mq.py
Queue.delete
def delete(self, message_id, reservation_id=None, subscriber_name=None): """Execute an HTTP request to delete a message from queue. Arguments: message_id -- The ID of the message to be deleted. reservation_id -- Reservation Id of the message. Reserved message could not be deleted witho...
python
def delete(self, message_id, reservation_id=None, subscriber_name=None): """Execute an HTTP request to delete a message from queue. Arguments: message_id -- The ID of the message to be deleted. reservation_id -- Reservation Id of the message. Reserved message could not be deleted witho...
[ "def", "delete", "(", "self", ",", "message_id", ",", "reservation_id", "=", "None", ",", "subscriber_name", "=", "None", ")", ":", "url", "=", "\"queues/%s/messages/%s\"", "%", "(", "self", ".", "name", ",", "message_id", ")", "qitems", "=", "{", "}", "...
Execute an HTTP request to delete a message from queue. Arguments: message_id -- The ID of the message to be deleted. reservation_id -- Reservation Id of the message. Reserved message could not be deleted without reservation Id. subscriber_name -- This is required to acknowledge push af...
[ "Execute", "an", "HTTP", "request", "to", "delete", "a", "message", "from", "queue", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L63-L82
train
Delete a reserved message from the queue.
iron-io/iron_mq_python
iron_mq.py
Queue.delete_multiple
def delete_multiple(self, ids=None, messages=None): """Execute an HTTP request to delete messages from queue. Arguments: ids -- A list of messages id to be deleted from the queue. messages -- Response to message reserving. """ url = "queues/%s/messages" % self.name ...
python
def delete_multiple(self, ids=None, messages=None): """Execute an HTTP request to delete messages from queue. Arguments: ids -- A list of messages id to be deleted from the queue. messages -- Response to message reserving. """ url = "queues/%s/messages" % self.name ...
[ "def", "delete_multiple", "(", "self", ",", "ids", "=", "None", ",", "messages", "=", "None", ")", ":", "url", "=", "\"queues/%s/messages\"", "%", "self", ".", "name", "items", "=", "None", "if", "ids", "is", "None", "and", "messages", "is", "None", ":...
Execute an HTTP request to delete messages from queue. Arguments: ids -- A list of messages id to be deleted from the queue. messages -- Response to message reserving.
[ "Execute", "an", "HTTP", "request", "to", "delete", "messages", "from", "queue", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L84-L106
train
Execute an HTTP request to delete multiple messages from the queue.
iron-io/iron_mq_python
iron_mq.py
Queue.post
def post(self, *messages): """Executes an HTTP request to create message on the queue. Creates queue if not existed. Arguments: messages -- An array of messages to be added to the queue. """ url = "queues/%s/messages" % self.name msgs = [{'body': msg} if isinsta...
python
def post(self, *messages): """Executes an HTTP request to create message on the queue. Creates queue if not existed. Arguments: messages -- An array of messages to be added to the queue. """ url = "queues/%s/messages" % self.name msgs = [{'body': msg} if isinsta...
[ "def", "post", "(", "self", ",", "*", "messages", ")", ":", "url", "=", "\"queues/%s/messages\"", "%", "self", ".", "name", "msgs", "=", "[", "{", "'body'", ":", "msg", "}", "if", "isinstance", "(", "msg", ",", "basestring", ")", "else", "msg", "for"...
Executes an HTTP request to create message on the queue. Creates queue if not existed. Arguments: messages -- An array of messages to be added to the queue.
[ "Executes", "an", "HTTP", "request", "to", "create", "message", "on", "the", "queue", ".", "Creates", "queue", "if", "not", "existed", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L108-L124
train
Executes an HTTP request to create a message on the queue. Returns the JSON response.
iron-io/iron_mq_python
iron_mq.py
Queue.get
def get(self, max=None, timeout=None, wait=None): """Deprecated. Use Queue.reserve() instead. Executes an HTTP request to get a message off of a queue. Keyword arguments: max -- The maximum number of messages to pull. Defaults to 1. """ response = self.reserve(max, timeout, wait...
python
def get(self, max=None, timeout=None, wait=None): """Deprecated. Use Queue.reserve() instead. Executes an HTTP request to get a message off of a queue. Keyword arguments: max -- The maximum number of messages to pull. Defaults to 1. """ response = self.reserve(max, timeout, wait...
[ "def", "get", "(", "self", ",", "max", "=", "None", ",", "timeout", "=", "None", ",", "wait", "=", "None", ")", ":", "response", "=", "self", ".", "reserve", "(", "max", ",", "timeout", ",", "wait", ")", "return", "response" ]
Deprecated. Use Queue.reserve() instead. Executes an HTTP request to get a message off of a queue. Keyword arguments: max -- The maximum number of messages to pull. Defaults to 1.
[ "Deprecated", ".", "Use", "Queue", ".", "reserve", "()", "instead", ".", "Executes", "an", "HTTP", "request", "to", "get", "a", "message", "off", "of", "a", "queue", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L126-L133
train
Deprecated. Use Queue. reserve to get a message off of a queue.
iron-io/iron_mq_python
iron_mq.py
Queue.reserve
def reserve(self, max=None, timeout=None, wait=None, delete=None): """Retrieves Messages from the queue and reserves it. Arguments: max -- The maximum number of messages to reserve. Defaults to 1. timeout -- Timeout in seconds. wait -- Time to long poll for messages, in seconds....
python
def reserve(self, max=None, timeout=None, wait=None, delete=None): """Retrieves Messages from the queue and reserves it. Arguments: max -- The maximum number of messages to reserve. Defaults to 1. timeout -- Timeout in seconds. wait -- Time to long poll for messages, in seconds....
[ "def", "reserve", "(", "self", ",", "max", "=", "None", ",", "timeout", "=", "None", ",", "wait", "=", "None", ",", "delete", "=", "None", ")", ":", "url", "=", "\"queues/%s/reservations\"", "%", "self", ".", "name", "qitems", "=", "{", "}", "if", ...
Retrieves Messages from the queue and reserves it. Arguments: max -- The maximum number of messages to reserve. Defaults to 1. timeout -- Timeout in seconds. wait -- Time to long poll for messages, in seconds. Max is 30 seconds. Default 0. delete -- If true, do not put each mess...
[ "Retrieves", "Messages", "from", "the", "queue", "and", "reserves", "it", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L136-L160
train
Retrieves Messages from the queue and reserves it.
iron-io/iron_mq_python
iron_mq.py
Queue.touch
def touch(self, message_id, reservation_id, timeout=None): """Touching a reserved message extends its timeout to the duration specified when the message was created. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. timeout -- Optio...
python
def touch(self, message_id, reservation_id, timeout=None): """Touching a reserved message extends its timeout to the duration specified when the message was created. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. timeout -- Optio...
[ "def", "touch", "(", "self", ",", "message_id", ",", "reservation_id", ",", "timeout", "=", "None", ")", ":", "url", "=", "\"queues/%s/messages/%s/touch\"", "%", "(", "self", ".", "name", ",", "message_id", ")", "qitems", "=", "{", "'reservation_id'", ":", ...
Touching a reserved message extends its timeout to the duration specified when the message was created. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. timeout -- Optional. The timeout in seconds after which new reservation will expire.
[ "Touching", "a", "reserved", "message", "extends", "its", "timeout", "to", "the", "duration", "specified", "when", "the", "message", "was", "created", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L177-L194
train
Touching a reserved message extends its timeout to the duration specified when the message was created.
iron-io/iron_mq_python
iron_mq.py
Queue.release
def release(self, message_id, reservation_id, delay=0): """Release locked message after specified time. If there is no message with such id on the queue. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. delay -- The time after whic...
python
def release(self, message_id, reservation_id, delay=0): """Release locked message after specified time. If there is no message with such id on the queue. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. delay -- The time after whic...
[ "def", "release", "(", "self", ",", "message_id", ",", "reservation_id", ",", "delay", "=", "0", ")", ":", "url", "=", "\"queues/%s/messages/%s/release\"", "%", "(", "self", ".", "name", ",", "message_id", ")", "body", "=", "{", "'reservation_id'", ":", "r...
Release locked message after specified time. If there is no message with such id on the queue. Arguments: message_id -- The ID of the message. reservation_id -- Reservation Id of the message. delay -- The time after which the message will be released.
[ "Release", "locked", "message", "after", "specified", "time", ".", "If", "there", "is", "no", "message", "with", "such", "id", "on", "the", "queue", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L196-L213
train
Release a locked message.
iron-io/iron_mq_python
iron_mq.py
IronMQ.queues
def queues(self, page=None, per_page=None, previous=None, prefix=None): """Execute an HTTP request to get a list of queues and return it. Keyword arguments: page -- The 0-based page to get queues from. Defaults to None, which omits the parameter. """ options = {}...
python
def queues(self, page=None, per_page=None, previous=None, prefix=None): """Execute an HTTP request to get a list of queues and return it. Keyword arguments: page -- The 0-based page to get queues from. Defaults to None, which omits the parameter. """ options = {}...
[ "def", "queues", "(", "self", ",", "page", "=", "None", ",", "per_page", "=", "None", ",", "previous", "=", "None", ",", "prefix", "=", "None", ")", ":", "options", "=", "{", "}", "if", "page", "is", "not", "None", ":", "raise", "Exception", "(", ...
Execute an HTTP request to get a list of queues and return it. Keyword arguments: page -- The 0-based page to get queues from. Defaults to None, which omits the parameter.
[ "Execute", "an", "HTTP", "request", "to", "get", "a", "list", "of", "queues", "and", "return", "it", "." ]
d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L318-L341
train
Execute an HTTP request to get a list of queues and return it.
cltl/KafNafParserPy
KafNafParserPy/time_data.py
CtimeExpressions.get_timex
def get_timex(self, timex_id): """ Returns the timex object for the supplied identifier @type timex_id: string @param timex_id: timex identifier """ if timex_id in self.idx: return Ctime(self.idx[timex_id]) else: return None
python
def get_timex(self, timex_id): """ Returns the timex object for the supplied identifier @type timex_id: string @param timex_id: timex identifier """ if timex_id in self.idx: return Ctime(self.idx[timex_id]) else: return None
[ "def", "get_timex", "(", "self", ",", "timex_id", ")", ":", "if", "timex_id", "in", "self", ".", "idx", ":", "return", "Ctime", "(", "self", ".", "idx", "[", "timex_id", "]", ")", "else", ":", "return", "None" ]
Returns the timex object for the supplied identifier @type timex_id: string @param timex_id: timex identifier
[ "Returns", "the", "timex", "object", "for", "the", "supplied", "identifier" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/time_data.py#L346-L355
train
Returns the timex object for the supplied timex_id
cltl/KafNafParserPy
KafNafParserPy/time_data.py
CtimeExpressions.add_timex
def add_timex(self, timex_obj): """ Adds a timex object to the layer. @type timex_obj: L{Ctime} @param timex_obj: the timex object """ timex_id = timex_obj.get_id() #check if id is not already present if not timex_id in self.idx: t...
python
def add_timex(self, timex_obj): """ Adds a timex object to the layer. @type timex_obj: L{Ctime} @param timex_obj: the timex object """ timex_id = timex_obj.get_id() #check if id is not already present if not timex_id in self.idx: t...
[ "def", "add_timex", "(", "self", ",", "timex_obj", ")", ":", "timex_id", "=", "timex_obj", ".", "get_id", "(", ")", "#check if id is not already present", "if", "not", "timex_id", "in", "self", ".", "idx", ":", "timex_node", "=", "timex_obj", ".", "get_node", ...
Adds a timex object to the layer. @type timex_obj: L{Ctime} @param timex_obj: the timex object
[ "Adds", "a", "timex", "object", "to", "the", "layer", "." ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/time_data.py#L367-L383
train
Adds a timex object to the layer.
cltl/KafNafParserPy
KafNafParserPy/time_data.py
CtimeExpressions.remove_timex3s
def remove_timex3s(self, list_timex_ids): """ Removes a list of terms from the layer @type list_timex_ids: list (of strings) @param list_timex_ids: list of timex identifier to be removed """ nodes_to_remove = set() for timex in self: if timex.get_id() ...
python
def remove_timex3s(self, list_timex_ids): """ Removes a list of terms from the layer @type list_timex_ids: list (of strings) @param list_timex_ids: list of timex identifier to be removed """ nodes_to_remove = set() for timex in self: if timex.get_id() ...
[ "def", "remove_timex3s", "(", "self", ",", "list_timex_ids", ")", ":", "nodes_to_remove", "=", "set", "(", ")", "for", "timex", "in", "self", ":", "if", "timex", ".", "get_id", "(", ")", "in", "list_timex_ids", ":", "nodes_to_remove", ".", "add", "(", "t...
Removes a list of terms from the layer @type list_timex_ids: list (of strings) @param list_timex_ids: list of timex identifier to be removed
[ "Removes", "a", "list", "of", "terms", "from", "the", "layer" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/time_data.py#L386-L402
train
Removes a list of terms from the layer
sio2project/filetracker
filetracker/scripts/recover.py
ensure_storage_format
def ensure_storage_format(root_dir): """Checks if the directory looks like a filetracker storage. Exits with error if it doesn't. """ if not os.path.isdir(os.path.join(root_dir, 'blobs')): print('"blobs/" directory not found') sys.exit(1) if not os.path.isdir(os.path.join(root_...
python
def ensure_storage_format(root_dir): """Checks if the directory looks like a filetracker storage. Exits with error if it doesn't. """ if not os.path.isdir(os.path.join(root_dir, 'blobs')): print('"blobs/" directory not found') sys.exit(1) if not os.path.isdir(os.path.join(root_...
[ "def", "ensure_storage_format", "(", "root_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "root_dir", ",", "'blobs'", ")", ")", ":", "print", "(", "'\"blobs/\" directory not found'", ")", "sys", "....
Checks if the directory looks like a filetracker storage. Exits with error if it doesn't.
[ "Checks", "if", "the", "directory", "looks", "like", "a", "filetracker", "storage", ".", "Exits", "with", "error", "if", "it", "doesn", "t", "." ]
359b474850622e3d0c25ee2596d7242c02f84efb
https://github.com/sio2project/filetracker/blob/359b474850622e3d0c25ee2596d7242c02f84efb/filetracker/scripts/recover.py#L132-L147
train
Checks if the directory looks like a filetracker storage. Exits with error if it doesn t.
sio2project/filetracker
filetracker/scripts/recover.py
_read_stream_for_size
def _read_stream_for_size(stream, buf_size=65536): """Reads a stream discarding the data read and returns its size.""" size = 0 while True: buf = stream.read(buf_size) size += len(buf) if not buf: break return size
python
def _read_stream_for_size(stream, buf_size=65536): """Reads a stream discarding the data read and returns its size.""" size = 0 while True: buf = stream.read(buf_size) size += len(buf) if not buf: break return size
[ "def", "_read_stream_for_size", "(", "stream", ",", "buf_size", "=", "65536", ")", ":", "size", "=", "0", "while", "True", ":", "buf", "=", "stream", ".", "read", "(", "buf_size", ")", "size", "+=", "len", "(", "buf", ")", "if", "not", "buf", ":", ...
Reads a stream discarding the data read and returns its size.
[ "Reads", "a", "stream", "discarding", "the", "data", "read", "and", "returns", "its", "size", "." ]
359b474850622e3d0c25ee2596d7242c02f84efb
https://github.com/sio2project/filetracker/blob/359b474850622e3d0c25ee2596d7242c02f84efb/filetracker/scripts/recover.py#L150-L158
train
Reads a stream discarding the data read and returns its size.
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_deepest_phrase_for_termid
def get_deepest_phrase_for_termid(self,termid): """ Returns the deepest phrase type for the term identifier and the list of subsumed by the same element @type termid: string @param termid: term identifier @rtype: (string,list) @return: the label and list of terms subsumed...
python
def get_deepest_phrase_for_termid(self,termid): """ Returns the deepest phrase type for the term identifier and the list of subsumed by the same element @type termid: string @param termid: term identifier @rtype: (string,list) @return: the label and list of terms subsumed...
[ "def", "get_deepest_phrase_for_termid", "(", "self", ",", "termid", ")", ":", "terminal_id", "=", "self", ".", "terminal_for_term", ".", "get", "(", "termid", ")", "label", "=", "None", "subsumed", "=", "[", "]", "if", "terminal_id", "is", "not", "None", "...
Returns the deepest phrase type for the term identifier and the list of subsumed by the same element @type termid: string @param termid: term identifier @rtype: (string,list) @return: the label and list of terms subsumed
[ "Returns", "the", "deepest", "phrase", "type", "for", "the", "term", "identifier", "and", "the", "list", "of", "subsumed", "by", "the", "same", "element" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L89-L105
train
Returns the deepest phrase type for the term identifier and the list of subsumed by the same element.
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_least_common_subsumer
def get_least_common_subsumer(self,from_tid,to_tid): """ Returns the deepest common subsumer among two terms @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: string @return: the term identifier...
python
def get_least_common_subsumer(self,from_tid,to_tid): """ Returns the deepest common subsumer among two terms @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: string @return: the term identifier...
[ "def", "get_least_common_subsumer", "(", "self", ",", "from_tid", ",", "to_tid", ")", ":", "termid_from", "=", "self", ".", "terminal_for_term", ".", "get", "(", "from_tid", ")", "termid_to", "=", "self", ".", "terminal_for_term", ".", "get", "(", "to_tid", ...
Returns the deepest common subsumer among two terms @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: string @return: the term identifier of the common subsumer
[ "Returns", "the", "deepest", "common", "subsumer", "among", "two", "terms" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L108-L134
train
Returns the deepest common subsumer among two terms AttributeNames
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_path_from_to
def get_path_from_to(self,from_tid, to_tid): """ This function returns the path (in terms of phrase types) from one term to another @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: list @return...
python
def get_path_from_to(self,from_tid, to_tid): """ This function returns the path (in terms of phrase types) from one term to another @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: list @return...
[ "def", "get_path_from_to", "(", "self", ",", "from_tid", ",", "to_tid", ")", ":", "shortest_subsumer", "=", "self", ".", "get_least_common_subsumer", "(", "from_tid", ",", "to_tid", ")", "#print 'From:',self.naf.get_term(from_tid).get_lemma()", "#print 'To:',self.naf.get_te...
This function returns the path (in terms of phrase types) from one term to another @type from_tid: string @param from_tid: one term id @type to_tid: string @param to_tid: another term id @rtype: list @return: the path, list of phrase types
[ "This", "function", "returns", "the", "path", "(", "in", "terms", "of", "phrase", "types", ")", "from", "one", "term", "to", "another" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L137-L173
train
This function returns the path of the terms of phrase types from one term to another term.
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_path_for_termid
def get_path_for_termid(self,termid): """ This function returns the path (in terms of phrase types) from one term the root @type termid: string @param termid: one term id @rtype: list @return: the path, list of phrase types """ terminal_id = self.term...
python
def get_path_for_termid(self,termid): """ This function returns the path (in terms of phrase types) from one term the root @type termid: string @param termid: one term id @rtype: list @return: the path, list of phrase types """ terminal_id = self.term...
[ "def", "get_path_for_termid", "(", "self", ",", "termid", ")", ":", "terminal_id", "=", "self", ".", "terminal_for_term", ".", "get", "(", "termid", ")", "paths", "=", "self", ".", "paths_for_terminal", "[", "terminal_id", "]", "labels", "=", "[", "self", ...
This function returns the path (in terms of phrase types) from one term the root @type termid: string @param termid: one term id @rtype: list @return: the path, list of phrase types
[ "This", "function", "returns", "the", "path", "(", "in", "terms", "of", "phrase", "types", ")", "from", "one", "term", "the", "root" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L176-L187
train
This function returns the path and the list of phrase types from one term the root
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_deepest_subsumer
def get_deepest_subsumer(self,list_terms): ''' Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided ''' #To store with how many terms every nonterminal appears count_per_no_terminal = defaultdict(int) #To ...
python
def get_deepest_subsumer(self,list_terms): ''' Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided ''' #To store with how many terms every nonterminal appears count_per_no_terminal = defaultdict(int) #To ...
[ "def", "get_deepest_subsumer", "(", "self", ",", "list_terms", ")", ":", "#To store with how many terms every nonterminal appears", "count_per_no_terminal", "=", "defaultdict", "(", "int", ")", "#To store the total deep of each noter for all the term ides (as we want the deepest)", "...
Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided
[ "Returns", "the", "labels", "of", "the", "deepest", "node", "that", "subsumes", "all", "the", "terms", "in", "the", "list", "of", "terms", "id", "s", "provided" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L218-L248
train
Returns the labels of the deepest node that subsumes all the terms in the list of terms id s provided
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_chunks
def get_chunks(self,chunk_type): """ Returns the chunks for a certain type @type chunk_type: string @param chunk_type: type of the chunk @rtype: list @return: the chunks for that type """ for nonter,this_type in self.label_for_nonter.items(): i...
python
def get_chunks(self,chunk_type): """ Returns the chunks for a certain type @type chunk_type: string @param chunk_type: type of the chunk @rtype: list @return: the chunks for that type """ for nonter,this_type in self.label_for_nonter.items(): i...
[ "def", "get_chunks", "(", "self", ",", "chunk_type", ")", ":", "for", "nonter", ",", "this_type", "in", "self", ".", "label_for_nonter", ".", "items", "(", ")", ":", "if", "this_type", "==", "chunk_type", ":", "subsumed", "=", "self", ".", "terms_subsumed_...
Returns the chunks for a certain type @type chunk_type: string @param chunk_type: type of the chunk @rtype: list @return: the chunks for that type
[ "Returns", "the", "chunks", "for", "a", "certain", "type" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L270-L282
train
Returns the list of chunks for a certain type of entry in the cache.
cltl/KafNafParserPy
KafNafParserPy/feature_extractor/constituency.py
Cconstituency_extractor.get_all_chunks_for_term
def get_all_chunks_for_term(self,termid): """ Returns all the chunks in which the term is contained @type termid: string @param termid: the term identifier @rtype: list @return: list of chunks """ terminal_id = self.terminal_for_term.get(termid) pa...
python
def get_all_chunks_for_term(self,termid): """ Returns all the chunks in which the term is contained @type termid: string @param termid: the term identifier @rtype: list @return: list of chunks """ terminal_id = self.terminal_for_term.get(termid) pa...
[ "def", "get_all_chunks_for_term", "(", "self", ",", "termid", ")", ":", "terminal_id", "=", "self", ".", "terminal_for_term", ".", "get", "(", "termid", ")", "paths", "=", "self", ".", "paths_for_terminal", "[", "terminal_id", "]", "for", "path", "in", "path...
Returns all the chunks in which the term is contained @type termid: string @param termid: the term identifier @rtype: list @return: list of chunks
[ "Returns", "all", "the", "chunks", "in", "which", "the", "term", "is", "contained" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L331-L346
train
Returns all the chunks in which the term is contained in the term.
mjirik/imtools
imtools/surface_measurement.py
surface_density
def surface_density(segmentation, voxelsize_mm, aoi=None, sond_raster_mm=None): """ :segmentation: is ndarray with 0 and 1 :voxelsize_mm: is array of three numbers specifiing size of voxel for each axis :aoi: is specify area of interest. It is ndarray with 0 and 1 :sond_raster_mm: unimplemen...
python
def surface_density(segmentation, voxelsize_mm, aoi=None, sond_raster_mm=None): """ :segmentation: is ndarray with 0 and 1 :voxelsize_mm: is array of three numbers specifiing size of voxel for each axis :aoi: is specify area of interest. It is ndarray with 0 and 1 :sond_raster_mm: unimplemen...
[ "def", "surface_density", "(", "segmentation", ",", "voxelsize_mm", ",", "aoi", "=", "None", ",", "sond_raster_mm", "=", "None", ")", ":", "axis", "=", "0", "if", "sond_raster_mm", "is", "None", ":", "sond_raster_mm", "=", "voxelsize_mm", "if", "aoi", "is", ...
:segmentation: is ndarray with 0 and 1 :voxelsize_mm: is array of three numbers specifiing size of voxel for each axis :aoi: is specify area of interest. It is ndarray with 0 and 1 :sond_raster_mm: unimplemented. It is parametr of sonds design
[ ":", "segmentation", ":", "is", "ndarray", "with", "0", "and", "1", ":", "voxelsize_mm", ":", "is", "array", "of", "three", "numbers", "specifiing", "size", "of", "voxel", "for", "each", "axis", ":", "aoi", ":", "is", "specify", "area", "of", "interest",...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/surface_measurement.py#L24-L72
train
Compute the surface density of the image.
polysquare/cmake-ast
cmakeast/ast.py
_lookup_enum_in_ns
def _lookup_enum_in_ns(namespace, value): """Return the attribute of namespace corresponding to value.""" for attribute in dir(namespace): if getattr(namespace, attribute) == value: return attribute
python
def _lookup_enum_in_ns(namespace, value): """Return the attribute of namespace corresponding to value.""" for attribute in dir(namespace): if getattr(namespace, attribute) == value: return attribute
[ "def", "_lookup_enum_in_ns", "(", "namespace", ",", "value", ")", ":", "for", "attribute", "in", "dir", "(", "namespace", ")", ":", "if", "getattr", "(", "namespace", ",", "attribute", ")", "==", "value", ":", "return", "attribute" ]
Return the attribute of namespace corresponding to value.
[ "Return", "the", "attribute", "of", "namespace", "corresponding", "to", "value", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L88-L92
train
Look up the attribute of namespace corresponding to value.
polysquare/cmake-ast
cmakeast/ast.py
_is_word_type
def _is_word_type(token_type): """Return true if this is a word-type token.""" return token_type in [TokenType.Word, TokenType.QuotedLiteral, TokenType.UnquotedLiteral, TokenType.Number, TokenType.Deref]
python
def _is_word_type(token_type): """Return true if this is a word-type token.""" return token_type in [TokenType.Word, TokenType.QuotedLiteral, TokenType.UnquotedLiteral, TokenType.Number, TokenType.Deref]
[ "def", "_is_word_type", "(", "token_type", ")", ":", "return", "token_type", "in", "[", "TokenType", ".", "Word", ",", "TokenType", ".", "QuotedLiteral", ",", "TokenType", ".", "UnquotedLiteral", ",", "TokenType", ".", "Number", ",", "TokenType", ".", "Deref",...
Return true if this is a word-type token.
[ "Return", "true", "if", "this", "is", "a", "word", "-", "type", "token", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L174-L180
train
Return true if this is a word - type token.
polysquare/cmake-ast
cmakeast/ast.py
_is_in_comment_type
def _is_in_comment_type(token_type): """Return true if this kind of token can be inside a comment.""" return token_type in [TokenType.Comment, TokenType.Newline, TokenType.Whitespace, TokenType.RST, TokenType...
python
def _is_in_comment_type(token_type): """Return true if this kind of token can be inside a comment.""" return token_type in [TokenType.Comment, TokenType.Newline, TokenType.Whitespace, TokenType.RST, TokenType...
[ "def", "_is_in_comment_type", "(", "token_type", ")", ":", "return", "token_type", "in", "[", "TokenType", ".", "Comment", ",", "TokenType", ".", "Newline", ",", "TokenType", ".", "Whitespace", ",", "TokenType", ".", "RST", ",", "TokenType", ".", "BeginRSTComm...
Return true if this kind of token can be inside a comment.
[ "Return", "true", "if", "this", "kind", "of", "token", "can", "be", "inside", "a", "comment", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L183-L191
train
Return true if this kind of token can be inside a comment.
polysquare/cmake-ast
cmakeast/ast.py
_get_string_type_from_token
def _get_string_type_from_token(token_type): """Return 'Single' or 'Double' depending on what kind of string this is.""" return_value = None if token_type in [TokenType.BeginSingleQuotedLiteral, TokenType.EndSingleQuotedLiteral]: return_value = "Single" elif token_type in [...
python
def _get_string_type_from_token(token_type): """Return 'Single' or 'Double' depending on what kind of string this is.""" return_value = None if token_type in [TokenType.BeginSingleQuotedLiteral, TokenType.EndSingleQuotedLiteral]: return_value = "Single" elif token_type in [...
[ "def", "_get_string_type_from_token", "(", "token_type", ")", ":", "return_value", "=", "None", "if", "token_type", "in", "[", "TokenType", ".", "BeginSingleQuotedLiteral", ",", "TokenType", ".", "EndSingleQuotedLiteral", "]", ":", "return_value", "=", "\"Single\"", ...
Return 'Single' or 'Double' depending on what kind of string this is.
[ "Return", "Single", "or", "Double", "depending", "on", "what", "kind", "of", "string", "this", "is", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L212-L223
train
Return Single or Double depending on what kind of string this is.
polysquare/cmake-ast
cmakeast/ast.py
_make_header_body_handler
def _make_header_body_handler(end_body_regex, node_factory, has_footer=True): """Utility function to make a handler for header-body node. A header-body node is any node which has a single function-call header and a body of statements inside of it ...
python
def _make_header_body_handler(end_body_regex, node_factory, has_footer=True): """Utility function to make a handler for header-body node. A header-body node is any node which has a single function-call header and a body of statements inside of it ...
[ "def", "_make_header_body_handler", "(", "end_body_regex", ",", "node_factory", ",", "has_footer", "=", "True", ")", ":", "def", "handler", "(", "tokens", ",", "tokens_len", ",", "body_index", ",", "function_call", ")", ":", "\"\"\"Handler function.\"\"\"", "def", ...
Utility function to make a handler for header-body node. A header-body node is any node which has a single function-call header and a body of statements inside of it
[ "Utility", "function", "to", "make", "a", "handler", "for", "header", "-", "body", "node", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L248-L289
train
Utility function to make a handler for header - body nodes.
polysquare/cmake-ast
cmakeast/ast.py
_handle_if_block
def _handle_if_block(tokens, tokens_len, body_index, function_call): """Special handler for if-blocks. If blocks are special because they can have multiple bodies and have multiple terminating keywords for each of those sub-bodies """ # First handle the if statement and body next_index, if_stat...
python
def _handle_if_block(tokens, tokens_len, body_index, function_call): """Special handler for if-blocks. If blocks are special because they can have multiple bodies and have multiple terminating keywords for each of those sub-bodies """ # First handle the if statement and body next_index, if_stat...
[ "def", "_handle_if_block", "(", "tokens", ",", "tokens_len", ",", "body_index", ",", "function_call", ")", ":", "# First handle the if statement and body", "next_index", ",", "if_statement", "=", "_IF_BLOCK_IF_HANDLER", "(", "tokens", ",", "tokens_len", ",", "body_index...
Special handler for if-blocks. If blocks are special because they can have multiple bodies and have multiple terminating keywords for each of those sub-bodies
[ "Special", "handler", "for", "if", "-", "blocks", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L302-L355
train
Handle the if - blocks.
polysquare/cmake-ast
cmakeast/ast.py
_handle_function_call
def _handle_function_call(tokens, tokens_len, index): """Handle function calls, which could include a control statement. In CMake, all control flow statements are also function calls, so handle the function call first and then direct tree construction to the appropriate control flow statement construct...
python
def _handle_function_call(tokens, tokens_len, index): """Handle function calls, which could include a control statement. In CMake, all control flow statements are also function calls, so handle the function call first and then direct tree construction to the appropriate control flow statement construct...
[ "def", "_handle_function_call", "(", "tokens", ",", "tokens_len", ",", "index", ")", ":", "def", "_end_function_call", "(", "token_index", ",", "tokens", ")", ":", "\"\"\"Function call termination detector.\"\"\"", "return", "tokens", "[", "token_index", "]", ".", "...
Handle function calls, which could include a control statement. In CMake, all control flow statements are also function calls, so handle the function call first and then direct tree construction to the appropriate control flow statement constructor found in _FUNCTION_CALL_DISAMBIGUATE
[ "Handle", "function", "calls", "which", "could", "include", "a", "control", "statement", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L368-L400
train
Handle function calls in the CMake tree.
polysquare/cmake-ast
cmakeast/ast.py
_ast_worker
def _ast_worker(tokens, tokens_len, index, term): """The main collector for all AST functions. This function is called recursively to find both variable use and function calls and returns a GenericBody with both those variables and function calls hanging off of it. The caller can figure out what to do ...
python
def _ast_worker(tokens, tokens_len, index, term): """The main collector for all AST functions. This function is called recursively to find both variable use and function calls and returns a GenericBody with both those variables and function calls hanging off of it. The caller can figure out what to do ...
[ "def", "_ast_worker", "(", "tokens", ",", "tokens_len", ",", "index", ",", "term", ")", ":", "statements", "=", "[", "]", "arguments", "=", "[", "]", "while", "index", "<", "tokens_len", ":", "if", "term", ":", "if", "term", "(", "index", ",", "token...
The main collector for all AST functions. This function is called recursively to find both variable use and function calls and returns a GenericBody with both those variables and function calls hanging off of it. The caller can figure out what to do with both of those
[ "The", "main", "collector", "for", "all", "AST", "functions", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L403-L438
train
The main collector for all AST functions.
polysquare/cmake-ast
cmakeast/ast.py
_scan_for_tokens
def _scan_for_tokens(contents): """Scan a string for tokens and return immediate form tokens.""" # Regexes are in priority order. Changing the order may alter the # behavior of the lexer scanner = re.Scanner([ # Things inside quotes (r"(?<![^\s\(])([\"\'])(?:(?=(\\?))\2.)*?\1(?![^\s\)])"...
python
def _scan_for_tokens(contents): """Scan a string for tokens and return immediate form tokens.""" # Regexes are in priority order. Changing the order may alter the # behavior of the lexer scanner = re.Scanner([ # Things inside quotes (r"(?<![^\s\(])([\"\'])(?:(?=(\\?))\2.)*?\1(?![^\s\)])"...
[ "def", "_scan_for_tokens", "(", "contents", ")", ":", "# Regexes are in priority order. Changing the order may alter the", "# behavior of the lexer", "scanner", "=", "re", ".", "Scanner", "(", "[", "# Things inside quotes", "(", "r\"(?<![^\\s\\(])([\\\"\\'])(?:(?=(\\\\?))\\2.)*?\\1...
Scan a string for tokens and return immediate form tokens.
[ "Scan", "a", "string", "for", "tokens", "and", "return", "immediate", "form", "tokens", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L441-L513
train
Scan a string for tokens and return immediate form tokens.
polysquare/cmake-ast
cmakeast/ast.py
_replace_token_range
def _replace_token_range(tokens, start, end, replacement): """For a range indicated from start to end, replace with replacement.""" tokens = tokens[:start] + replacement + tokens[end:] return tokens
python
def _replace_token_range(tokens, start, end, replacement): """For a range indicated from start to end, replace with replacement.""" tokens = tokens[:start] + replacement + tokens[end:] return tokens
[ "def", "_replace_token_range", "(", "tokens", ",", "start", ",", "end", ",", "replacement", ")", ":", "tokens", "=", "tokens", "[", ":", "start", "]", "+", "replacement", "+", "tokens", "[", "end", ":", "]", "return", "tokens" ]
For a range indicated from start to end, replace with replacement.
[ "For", "a", "range", "indicated", "from", "start", "to", "end", "replace", "with", "replacement", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L516-L519
train
Replace a range of tokens with replacement.
polysquare/cmake-ast
cmakeast/ast.py
_is_really_comment
def _is_really_comment(tokens, index): """Return true if the token at index is really a comment.""" if tokens[index].type == TokenType.Comment: return True # Really a comment in disguise! try: if tokens[index].content.lstrip()[0] == "#": return True except IndexError: ...
python
def _is_really_comment(tokens, index): """Return true if the token at index is really a comment.""" if tokens[index].type == TokenType.Comment: return True # Really a comment in disguise! try: if tokens[index].content.lstrip()[0] == "#": return True except IndexError: ...
[ "def", "_is_really_comment", "(", "tokens", ",", "index", ")", ":", "if", "tokens", "[", "index", "]", ".", "type", "==", "TokenType", ".", "Comment", ":", "return", "True", "# Really a comment in disguise!", "try", ":", "if", "tokens", "[", "index", "]", ...
Return true if the token at index is really a comment.
[ "Return", "true", "if", "the", "token", "at", "index", "is", "really", "a", "comment", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L522-L532
train
Return true if the token at index is really a comment.
polysquare/cmake-ast
cmakeast/ast.py
_paste_tokens_line_by_line
def _paste_tokens_line_by_line(tokens, token_type, begin, end): """Return lines of tokens pasted together, line by line.""" block_index = begin while block_index < end: rst_line = tokens[block_index].line line_traversal_index = block_index pasted = "" try: while ...
python
def _paste_tokens_line_by_line(tokens, token_type, begin, end): """Return lines of tokens pasted together, line by line.""" block_index = begin while block_index < end: rst_line = tokens[block_index].line line_traversal_index = block_index pasted = "" try: while ...
[ "def", "_paste_tokens_line_by_line", "(", "tokens", ",", "token_type", ",", "begin", ",", "end", ")", ":", "block_index", "=", "begin", "while", "block_index", "<", "end", ":", "rst_line", "=", "tokens", "[", "block_index", "]", ".", "line", "line_traversal_in...
Return lines of tokens pasted together, line by line.
[ "Return", "lines", "of", "tokens", "pasted", "together", "line", "by", "line", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L585-L611
train
Return lines of tokens pasted together line by line.
polysquare/cmake-ast
cmakeast/ast.py
_find_recorder
def _find_recorder(recorder, tokens, index): """Given a current recorder and a token index, try to find a recorder.""" if recorder is None: # See if we can start recording something for recorder_factory in _RECORDERS: recorder = recorder_factory.maybe_start_recording(tokens, ...
python
def _find_recorder(recorder, tokens, index): """Given a current recorder and a token index, try to find a recorder.""" if recorder is None: # See if we can start recording something for recorder_factory in _RECORDERS: recorder = recorder_factory.maybe_start_recording(tokens, ...
[ "def", "_find_recorder", "(", "recorder", ",", "tokens", ",", "index", ")", ":", "if", "recorder", "is", "None", ":", "# See if we can start recording something", "for", "recorder_factory", "in", "_RECORDERS", ":", "recorder", "=", "recorder_factory", ".", "maybe_st...
Given a current recorder and a token index, try to find a recorder.
[ "Given", "a", "current", "recorder", "and", "a", "token", "index", "try", "to", "find", "a", "recorder", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L814-L824
train
Given a current recorder and a token index try to find a recorder.
polysquare/cmake-ast
cmakeast/ast.py
_compress_tokens
def _compress_tokens(tokens): """Paste multi-line strings, comments, RST etc together. This function works by iterating over each over the _RECORDERS to determine if we should start recording a token sequence for pasting together. If it finds one, then we keep recording until that recorder is done and ...
python
def _compress_tokens(tokens): """Paste multi-line strings, comments, RST etc together. This function works by iterating over each over the _RECORDERS to determine if we should start recording a token sequence for pasting together. If it finds one, then we keep recording until that recorder is done and ...
[ "def", "_compress_tokens", "(", "tokens", ")", ":", "recorder", "=", "None", "def", "_edge_case_stray_end_quoted", "(", "tokens", ",", "index", ")", ":", "\"\"\"Convert stray end_quoted_literals to unquoted_literals.\"\"\"", "# In this case, \"tokenize\" the matched token into wh...
Paste multi-line strings, comments, RST etc together. This function works by iterating over each over the _RECORDERS to determine if we should start recording a token sequence for pasting together. If it finds one, then we keep recording until that recorder is done and returns a pasted together token s...
[ "Paste", "multi", "-", "line", "strings", "comments", "RST", "etc", "together", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L827-L880
train
Takes a list of tokens and returns a new list of all the tokens that are pasted together.
polysquare/cmake-ast
cmakeast/ast.py
tokenize
def tokenize(contents): """Parse a string called contents for CMake tokens.""" tokens = _scan_for_tokens(contents) tokens = _compress_tokens(tokens) tokens = [token for token in tokens if token.type != TokenType.Whitespace] return tokens
python
def tokenize(contents): """Parse a string called contents for CMake tokens.""" tokens = _scan_for_tokens(contents) tokens = _compress_tokens(tokens) tokens = [token for token in tokens if token.type != TokenType.Whitespace] return tokens
[ "def", "tokenize", "(", "contents", ")", ":", "tokens", "=", "_scan_for_tokens", "(", "contents", ")", "tokens", "=", "_compress_tokens", "(", "tokens", ")", "tokens", "=", "[", "token", "for", "token", "in", "tokens", "if", "token", ".", "type", "!=", "...
Parse a string called contents for CMake tokens.
[ "Parse", "a", "string", "called", "contents", "for", "CMake", "tokens", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L883-L888
train
Parse a string called contents for CMake tokens.
polysquare/cmake-ast
cmakeast/ast.py
parse
def parse(contents, tokens=None): """Parse a string called contents for an AST and return it.""" # Shortcut for users who are interested in tokens if tokens is None: tokens = [t for t in tokenize(contents)] token_index, body = _ast_worker(tokens, len(tokens), 0, None) assert token_index ==...
python
def parse(contents, tokens=None): """Parse a string called contents for an AST and return it.""" # Shortcut for users who are interested in tokens if tokens is None: tokens = [t for t in tokenize(contents)] token_index, body = _ast_worker(tokens, len(tokens), 0, None) assert token_index ==...
[ "def", "parse", "(", "contents", ",", "tokens", "=", "None", ")", ":", "# Shortcut for users who are interested in tokens", "if", "tokens", "is", "None", ":", "tokens", "=", "[", "t", "for", "t", "in", "tokenize", "(", "contents", ")", "]", "token_index", ",...
Parse a string called contents for an AST and return it.
[ "Parse", "a", "string", "called", "contents", "for", "an", "AST", "and", "return", "it", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L891-L902
train
Parse a string called contents for an AST and return it.
polysquare/cmake-ast
cmakeast/ast.py
_CommentedLineRecorder.maybe_start_recording
def maybe_start_recording(tokens, index): """Return a new _CommentedLineRecorder when it is time to record.""" if _is_really_comment(tokens, index): return _CommentedLineRecorder(index, tokens[index].line) return None
python
def maybe_start_recording(tokens, index): """Return a new _CommentedLineRecorder when it is time to record.""" if _is_really_comment(tokens, index): return _CommentedLineRecorder(index, tokens[index].line) return None
[ "def", "maybe_start_recording", "(", "tokens", ",", "index", ")", ":", "if", "_is_really_comment", "(", "tokens", ",", "index", ")", ":", "return", "_CommentedLineRecorder", "(", "index", ",", "tokens", "[", "index", "]", ".", "line", ")", "return", "None" ]
Return a new _CommentedLineRecorder when it is time to record.
[ "Return", "a", "new", "_CommentedLineRecorder", "when", "it", "is", "time", "to", "record", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L545-L550
train
Return a new _CommentedLineRecorder when it is time to record.
polysquare/cmake-ast
cmakeast/ast.py
_CommentedLineRecorder.consume_token
def consume_token(self, tokens, index, tokens_len): """Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together. """ finished = False if tokens[index].line > self.line: finished = True...
python
def consume_token(self, tokens, index, tokens_len): """Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together. """ finished = False if tokens[index].line > self.line: finished = True...
[ "def", "consume_token", "(", "self", ",", "tokens", ",", "index", ",", "tokens_len", ")", ":", "finished", "=", "False", "if", "tokens", "[", "index", "]", ".", "line", ">", "self", ".", "line", ":", "finished", "=", "True", "end", "=", "index", "eli...
Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together.
[ "Consume", "a", "token", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L552-L582
train
Consume a token.
polysquare/cmake-ast
cmakeast/ast.py
_RSTCommentBlockRecorder.maybe_start_recording
def maybe_start_recording(tokens, index): """Return a new _RSTCommentBlockRecorder when its time to record.""" if tokens[index].type == TokenType.BeginRSTComment: return _RSTCommentBlockRecorder(index, tokens[index].line) return None
python
def maybe_start_recording(tokens, index): """Return a new _RSTCommentBlockRecorder when its time to record.""" if tokens[index].type == TokenType.BeginRSTComment: return _RSTCommentBlockRecorder(index, tokens[index].line) return None
[ "def", "maybe_start_recording", "(", "tokens", ",", "index", ")", ":", "if", "tokens", "[", "index", "]", ".", "type", "==", "TokenType", ".", "BeginRSTComment", ":", "return", "_RSTCommentBlockRecorder", "(", "index", ",", "tokens", "[", "index", "]", ".", ...
Return a new _RSTCommentBlockRecorder when its time to record.
[ "Return", "a", "new", "_RSTCommentBlockRecorder", "when", "its", "time", "to", "record", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L624-L629
train
Return a new _RSTCommentBlockRecorder when its time to record.
polysquare/cmake-ast
cmakeast/ast.py
_RSTCommentBlockRecorder.consume_token
def consume_token(self, tokens, index, tokens_len): """Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together. """ if _is_really_comment(tokens, index): self.last_line_with_comment = tokens[i...
python
def consume_token(self, tokens, index, tokens_len): """Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together. """ if _is_really_comment(tokens, index): self.last_line_with_comment = tokens[i...
[ "def", "consume_token", "(", "self", ",", "tokens", ",", "index", ",", "tokens_len", ")", ":", "if", "_is_really_comment", "(", "tokens", ",", "index", ")", ":", "self", ".", "last_line_with_comment", "=", "tokens", "[", "index", "]", ".", "line", "finishe...
Consume a token. Returns a tuple of (tokens, tokens_len, index) when consumption is completed and tokens have been merged together.
[ "Consume", "a", "token", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L631-L654
train
Consume a token.