repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_line_break_property
def get_line_break_property(value, is_bytes=False): """Get `LINE BREAK` property.""" obj = unidata.ascii_line_break if is_bytes else unidata.unicode_line_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['linebreak'].get(negated, negated) else: ...
python
def get_line_break_property(value, is_bytes=False): """Get `LINE BREAK` property.""" obj = unidata.ascii_line_break if is_bytes else unidata.unicode_line_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['linebreak'].get(negated, negated) else: ...
[ "def", "get_line_break_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_line_break", "if", "is_bytes", "else", "unidata", ".", "unicode_line_break", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "...
Get `LINE BREAK` property.
[ "Get", "LINE", "BREAK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L112-L123
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_sentence_break_property
def get_sentence_break_property(value, is_bytes=False): """Get `SENTENCE BREAK` property.""" obj = unidata.ascii_sentence_break if is_bytes else unidata.unicode_sentence_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['sentencebreak'].get(negated, ne...
python
def get_sentence_break_property(value, is_bytes=False): """Get `SENTENCE BREAK` property.""" obj = unidata.ascii_sentence_break if is_bytes else unidata.unicode_sentence_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['sentencebreak'].get(negated, ne...
[ "def", "get_sentence_break_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_sentence_break", "if", "is_bytes", "else", "unidata", ".", "unicode_sentence_break", "if", "value", ".", "startswith", "(", "'^'", ")"...
Get `SENTENCE BREAK` property.
[ "Get", "SENTENCE", "BREAK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L126-L137
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_word_break_property
def get_word_break_property(value, is_bytes=False): """Get `WORD BREAK` property.""" obj = unidata.ascii_word_break if is_bytes else unidata.unicode_word_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['wordbreak'].get(negated, negated) else: ...
python
def get_word_break_property(value, is_bytes=False): """Get `WORD BREAK` property.""" obj = unidata.ascii_word_break if is_bytes else unidata.unicode_word_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['wordbreak'].get(negated, negated) else: ...
[ "def", "get_word_break_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_word_break", "if", "is_bytes", "else", "unidata", ".", "unicode_word_break", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "...
Get `WORD BREAK` property.
[ "Get", "WORD", "BREAK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L140-L151
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_hangul_syllable_type_property
def get_hangul_syllable_type_property(value, is_bytes=False): """Get `HANGUL SYLLABLE TYPE` property.""" obj = unidata.ascii_hangul_syllable_type if is_bytes else unidata.unicode_hangul_syllable_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['hanguls...
python
def get_hangul_syllable_type_property(value, is_bytes=False): """Get `HANGUL SYLLABLE TYPE` property.""" obj = unidata.ascii_hangul_syllable_type if is_bytes else unidata.unicode_hangul_syllable_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['hanguls...
[ "def", "get_hangul_syllable_type_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_hangul_syllable_type", "if", "is_bytes", "else", "unidata", ".", "unicode_hangul_syllable_type", "if", "value", ".", "startswith", "...
Get `HANGUL SYLLABLE TYPE` property.
[ "Get", "HANGUL", "SYLLABLE", "TYPE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L154-L165
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_indic_positional_category_property
def get_indic_positional_category_property(value, is_bytes=False): """Get `INDIC POSITIONAL/MATRA CATEGORY` property.""" if PY35: obj = unidata.ascii_indic_positional_category if is_bytes else unidata.unicode_indic_positional_category alias_key = 'indicpositionalcategory' else: obj ...
python
def get_indic_positional_category_property(value, is_bytes=False): """Get `INDIC POSITIONAL/MATRA CATEGORY` property.""" if PY35: obj = unidata.ascii_indic_positional_category if is_bytes else unidata.unicode_indic_positional_category alias_key = 'indicpositionalcategory' else: obj ...
[ "def", "get_indic_positional_category_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "if", "PY35", ":", "obj", "=", "unidata", ".", "ascii_indic_positional_category", "if", "is_bytes", "else", "unidata", ".", "unicode_indic_positional_category", "al...
Get `INDIC POSITIONAL/MATRA CATEGORY` property.
[ "Get", "INDIC", "POSITIONAL", "/", "MATRA", "CATEGORY", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L168-L184
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_indic_syllabic_category_property
def get_indic_syllabic_category_property(value, is_bytes=False): """Get `INDIC SYLLABIC CATEGORY` property.""" obj = unidata.ascii_indic_syllabic_category if is_bytes else unidata.unicode_indic_syllabic_category if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_al...
python
def get_indic_syllabic_category_property(value, is_bytes=False): """Get `INDIC SYLLABIC CATEGORY` property.""" obj = unidata.ascii_indic_syllabic_category if is_bytes else unidata.unicode_indic_syllabic_category if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_al...
[ "def", "get_indic_syllabic_category_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_indic_syllabic_category", "if", "is_bytes", "else", "unidata", ".", "unicode_indic_syllabic_category", "if", "value", ".", "startsw...
Get `INDIC SYLLABIC CATEGORY` property.
[ "Get", "INDIC", "SYLLABIC", "CATEGORY", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L187-L198
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_decomposition_type_property
def get_decomposition_type_property(value, is_bytes=False): """Get `DECOMPOSITION TYPE` property.""" obj = unidata.ascii_decomposition_type if is_bytes else unidata.unicode_decomposition_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['decompositionty...
python
def get_decomposition_type_property(value, is_bytes=False): """Get `DECOMPOSITION TYPE` property.""" obj = unidata.ascii_decomposition_type if is_bytes else unidata.unicode_decomposition_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['decompositionty...
[ "def", "get_decomposition_type_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_decomposition_type", "if", "is_bytes", "else", "unidata", ".", "unicode_decomposition_type", "if", "value", ".", "startswith", "(", ...
Get `DECOMPOSITION TYPE` property.
[ "Get", "DECOMPOSITION", "TYPE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L201-L212
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_nfc_quick_check_property
def get_nfc_quick_check_property(value, is_bytes=False): """Get `NFC QUICK CHECK` property.""" obj = unidata.ascii_nfc_quick_check if is_bytes else unidata.unicode_nfc_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfcquickcheck'].get(negated...
python
def get_nfc_quick_check_property(value, is_bytes=False): """Get `NFC QUICK CHECK` property.""" obj = unidata.ascii_nfc_quick_check if is_bytes else unidata.unicode_nfc_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfcquickcheck'].get(negated...
[ "def", "get_nfc_quick_check_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_nfc_quick_check", "if", "is_bytes", "else", "unidata", ".", "unicode_nfc_quick_check", "if", "value", ".", "startswith", "(", "'^'", ...
Get `NFC QUICK CHECK` property.
[ "Get", "NFC", "QUICK", "CHECK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L215-L226
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_nfd_quick_check_property
def get_nfd_quick_check_property(value, is_bytes=False): """Get `NFD QUICK CHECK` property.""" obj = unidata.ascii_nfd_quick_check if is_bytes else unidata.unicode_nfd_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfdquickcheck'].get(negated...
python
def get_nfd_quick_check_property(value, is_bytes=False): """Get `NFD QUICK CHECK` property.""" obj = unidata.ascii_nfd_quick_check if is_bytes else unidata.unicode_nfd_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfdquickcheck'].get(negated...
[ "def", "get_nfd_quick_check_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_nfd_quick_check", "if", "is_bytes", "else", "unidata", ".", "unicode_nfd_quick_check", "if", "value", ".", "startswith", "(", "'^'", ...
Get `NFD QUICK CHECK` property.
[ "Get", "NFD", "QUICK", "CHECK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L229-L240
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_nfkc_quick_check_property
def get_nfkc_quick_check_property(value, is_bytes=False): """Get `NFKC QUICK CHECK` property.""" obj = unidata.ascii_nfkc_quick_check if is_bytes else unidata.unicode_nfkc_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfkcquickcheck'].get(ne...
python
def get_nfkc_quick_check_property(value, is_bytes=False): """Get `NFKC QUICK CHECK` property.""" obj = unidata.ascii_nfkc_quick_check if is_bytes else unidata.unicode_nfkc_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfkcquickcheck'].get(ne...
[ "def", "get_nfkc_quick_check_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_nfkc_quick_check", "if", "is_bytes", "else", "unidata", ".", "unicode_nfkc_quick_check", "if", "value", ".", "startswith", "(", "'^'",...
Get `NFKC QUICK CHECK` property.
[ "Get", "NFKC", "QUICK", "CHECK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L243-L254
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_nfkd_quick_check_property
def get_nfkd_quick_check_property(value, is_bytes=False): """Get `NFKD QUICK CHECK` property.""" obj = unidata.ascii_nfkd_quick_check if is_bytes else unidata.unicode_nfkd_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfkdquickcheck'].get(ne...
python
def get_nfkd_quick_check_property(value, is_bytes=False): """Get `NFKD QUICK CHECK` property.""" obj = unidata.ascii_nfkd_quick_check if is_bytes else unidata.unicode_nfkd_quick_check if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['nfkdquickcheck'].get(ne...
[ "def", "get_nfkd_quick_check_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_nfkd_quick_check", "if", "is_bytes", "else", "unidata", ".", "unicode_nfkd_quick_check", "if", "value", ".", "startswith", "(", "'^'",...
Get `NFKD QUICK CHECK` property.
[ "Get", "NFKD", "QUICK", "CHECK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L257-L268
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_numeric_type_property
def get_numeric_type_property(value, is_bytes=False): """Get `NUMERIC TYPE` property.""" obj = unidata.ascii_numeric_type if is_bytes else unidata.unicode_numeric_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['numerictype'].get(negated, negated) ...
python
def get_numeric_type_property(value, is_bytes=False): """Get `NUMERIC TYPE` property.""" obj = unidata.ascii_numeric_type if is_bytes else unidata.unicode_numeric_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['numerictype'].get(negated, negated) ...
[ "def", "get_numeric_type_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_numeric_type", "if", "is_bytes", "else", "unidata", ".", "unicode_numeric_type", "if", "value", ".", "startswith", "(", "'^'", ")", ":...
Get `NUMERIC TYPE` property.
[ "Get", "NUMERIC", "TYPE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L271-L282
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_numeric_value_property
def get_numeric_value_property(value, is_bytes=False): """Get `NUMERIC VALUE` property.""" obj = unidata.ascii_numeric_values if is_bytes else unidata.unicode_numeric_values if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['numericvalue'].get(negated, negat...
python
def get_numeric_value_property(value, is_bytes=False): """Get `NUMERIC VALUE` property.""" obj = unidata.ascii_numeric_values if is_bytes else unidata.unicode_numeric_values if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['numericvalue'].get(negated, negat...
[ "def", "get_numeric_value_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_numeric_values", "if", "is_bytes", "else", "unidata", ".", "unicode_numeric_values", "if", "value", ".", "startswith", "(", "'^'", ")",...
Get `NUMERIC VALUE` property.
[ "Get", "NUMERIC", "VALUE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L285-L296
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_age_property
def get_age_property(value, is_bytes=False): """Get `AGE` property.""" obj = unidata.ascii_age if is_bytes else unidata.unicode_age if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['age'].get(negated, negated) else: value = unidata.unicode_alias...
python
def get_age_property(value, is_bytes=False): """Get `AGE` property.""" obj = unidata.ascii_age if is_bytes else unidata.unicode_age if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['age'].get(negated, negated) else: value = unidata.unicode_alias...
[ "def", "get_age_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_age", "if", "is_bytes", "else", "unidata", ".", "unicode_age", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "negated", "=", "v...
Get `AGE` property.
[ "Get", "AGE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L299-L310
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_joining_type_property
def get_joining_type_property(value, is_bytes=False): """Get `JOINING TYPE` property.""" obj = unidata.ascii_joining_type if is_bytes else unidata.unicode_joining_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['joiningtype'].get(negated, negated) ...
python
def get_joining_type_property(value, is_bytes=False): """Get `JOINING TYPE` property.""" obj = unidata.ascii_joining_type if is_bytes else unidata.unicode_joining_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['joiningtype'].get(negated, negated) ...
[ "def", "get_joining_type_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_joining_type", "if", "is_bytes", "else", "unidata", ".", "unicode_joining_type", "if", "value", ".", "startswith", "(", "'^'", ")", ":...
Get `JOINING TYPE` property.
[ "Get", "JOINING", "TYPE", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L313-L324
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_joining_group_property
def get_joining_group_property(value, is_bytes=False): """Get `JOINING GROUP` property.""" obj = unidata.ascii_joining_group if is_bytes else unidata.unicode_joining_group if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['joininggroup'].get(negated, negated...
python
def get_joining_group_property(value, is_bytes=False): """Get `JOINING GROUP` property.""" obj = unidata.ascii_joining_group if is_bytes else unidata.unicode_joining_group if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['joininggroup'].get(negated, negated...
[ "def", "get_joining_group_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_joining_group", "if", "is_bytes", "else", "unidata", ".", "unicode_joining_group", "if", "value", ".", "startswith", "(", "'^'", ")", ...
Get `JOINING GROUP` property.
[ "Get", "JOINING", "GROUP", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L327-L338
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_script_property
def get_script_property(value, is_bytes=False): """Get `SC` property.""" obj = unidata.ascii_scripts if is_bytes else unidata.unicode_scripts if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['script'].get(negated, negated) else: value = unidata....
python
def get_script_property(value, is_bytes=False): """Get `SC` property.""" obj = unidata.ascii_scripts if is_bytes else unidata.unicode_scripts if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['script'].get(negated, negated) else: value = unidata....
[ "def", "get_script_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_scripts", "if", "is_bytes", "else", "unidata", ".", "unicode_scripts", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "negated", ...
Get `SC` property.
[ "Get", "SC", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L341-L352
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_script_extension_property
def get_script_extension_property(value, is_bytes=False): """Get `SCX` property.""" obj = unidata.ascii_script_extensions if is_bytes else unidata.unicode_script_extensions if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['script'].get(negated, negated) ...
python
def get_script_extension_property(value, is_bytes=False): """Get `SCX` property.""" obj = unidata.ascii_script_extensions if is_bytes else unidata.unicode_script_extensions if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['script'].get(negated, negated) ...
[ "def", "get_script_extension_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_script_extensions", "if", "is_bytes", "else", "unidata", ".", "unicode_script_extensions", "if", "value", ".", "startswith", "(", "'^'...
Get `SCX` property.
[ "Get", "SCX", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L355-L366
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_block_property
def get_block_property(value, is_bytes=False): """Get `BLK` property.""" obj = unidata.ascii_blocks if is_bytes else unidata.unicode_blocks if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['block'].get(negated, negated) else: value = unidata.uni...
python
def get_block_property(value, is_bytes=False): """Get `BLK` property.""" obj = unidata.ascii_blocks if is_bytes else unidata.unicode_blocks if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['block'].get(negated, negated) else: value = unidata.uni...
[ "def", "get_block_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_blocks", "if", "is_bytes", "else", "unidata", ".", "unicode_blocks", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "negated", "...
Get `BLK` property.
[ "Get", "BLK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L369-L380
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_bidi_property
def get_bidi_property(value, is_bytes=False): """Get `BC` property.""" obj = unidata.ascii_bidi_classes if is_bytes else unidata.unicode_bidi_classes if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['bidiclass'].get(negated, negated) else: value...
python
def get_bidi_property(value, is_bytes=False): """Get `BC` property.""" obj = unidata.ascii_bidi_classes if is_bytes else unidata.unicode_bidi_classes if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['bidiclass'].get(negated, negated) else: value...
[ "def", "get_bidi_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_bidi_classes", "if", "is_bytes", "else", "unidata", ".", "unicode_bidi_classes", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "ne...
Get `BC` property.
[ "Get", "BC", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L383-L394
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_bidi_paired_bracket_type_property
def get_bidi_paired_bracket_type_property(value, is_bytes=False): """Get `BPT` property.""" obj = unidata.ascii_bidi_paired_bracket_type if is_bytes else unidata.unicode_bidi_paired_bracket_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['bidipairedbr...
python
def get_bidi_paired_bracket_type_property(value, is_bytes=False): """Get `BPT` property.""" obj = unidata.ascii_bidi_paired_bracket_type if is_bytes else unidata.unicode_bidi_paired_bracket_type if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['bidipairedbr...
[ "def", "get_bidi_paired_bracket_type_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_bidi_paired_bracket_type", "if", "is_bytes", "else", "unidata", ".", "unicode_bidi_paired_bracket_type", "if", "value", ".", "star...
Get `BPT` property.
[ "Get", "BPT", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L397-L408
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_vertical_orientation_property
def get_vertical_orientation_property(value, is_bytes=False): """Get `VO` property.""" obj = unidata.ascii_vertical_orientation if is_bytes else unidata.unicode_vertical_orientation if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['verticalorientation'].get...
python
def get_vertical_orientation_property(value, is_bytes=False): """Get `VO` property.""" obj = unidata.ascii_vertical_orientation if is_bytes else unidata.unicode_vertical_orientation if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['verticalorientation'].get...
[ "def", "get_vertical_orientation_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_vertical_orientation", "if", "is_bytes", "else", "unidata", ".", "unicode_vertical_orientation", "if", "value", ".", "startswith", "...
Get `VO` property.
[ "Get", "VO", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L411-L422
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_is_property
def get_is_property(value, is_bytes=False): """Get shortcut for `SC` or `Binary` property.""" if value.startswith('^'): prefix = value[1:3] temp = value[3:] negate = '^' else: prefix = value[:2] temp = value[2:] negate = '' if prefix != 'is': rai...
python
def get_is_property(value, is_bytes=False): """Get shortcut for `SC` or `Binary` property.""" if value.startswith('^'): prefix = value[1:3] temp = value[3:] negate = '^' else: prefix = value[:2] temp = value[2:] negate = '' if prefix != 'is': rai...
[ "def", "get_is_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "prefix", "=", "value", "[", "1", ":", "3", "]", "temp", "=", "value", "[", "3", ":", "]", "negate", "=", "'^...
Get shortcut for `SC` or `Binary` property.
[ "Get", "shortcut", "for", "SC", "or", "Binary", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L425-L451
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_in_property
def get_in_property(value, is_bytes=False): """Get shortcut for `Block` property.""" if value.startswith('^'): prefix = value[1:3] temp = value[3:] negate = '^' else: prefix = value[:2] temp = value[2:] negate = '' if prefix != 'in': raise ValueE...
python
def get_in_property(value, is_bytes=False): """Get shortcut for `Block` property.""" if value.startswith('^'): prefix = value[1:3] temp = value[3:] negate = '^' else: prefix = value[:2] temp = value[2:] negate = '' if prefix != 'in': raise ValueE...
[ "def", "get_in_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "prefix", "=", "value", "[", "1", ":", "3", "]", "temp", "=", "value", "[", "3", ":", "]", "negate", "=", "'^...
Get shortcut for `Block` property.
[ "Get", "shortcut", "for", "Block", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L454-L472
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_unicode_property
def get_unicode_property(value, prop=None, is_bytes=False): """Retrieve the Unicode category from the table.""" if prop is not None: prop = unidata.unicode_alias['_'].get(prop, prop) try: if prop == 'generalcategory': return get_gc_property(value, is_bytes) ...
python
def get_unicode_property(value, prop=None, is_bytes=False): """Retrieve the Unicode category from the table.""" if prop is not None: prop = unidata.unicode_alias['_'].get(prop, prop) try: if prop == 'generalcategory': return get_gc_property(value, is_bytes) ...
[ "def", "get_unicode_property", "(", "value", ",", "prop", "=", "None", ",", "is_bytes", "=", "False", ")", ":", "if", "prop", "is", "not", "None", ":", "prop", "=", "unidata", ".", "unicode_alias", "[", "'_'", "]", ".", "get", "(", "prop", ",", "prop...
Retrieve the Unicode category from the table.
[ "Retrieve", "the", "Unicode", "category", "from", "the", "table", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L481-L578
facelessuser/backrefs
backrefs/bre.py
_cached_search_compile
def _cached_search_compile(pattern, re_verbose, re_version, pattern_type): """Cached search compile.""" return _bre_parse._SearchParser(pattern, re_verbose, re_version).parse()
python
def _cached_search_compile(pattern, re_verbose, re_version, pattern_type): """Cached search compile.""" return _bre_parse._SearchParser(pattern, re_verbose, re_version).parse()
[ "def", "_cached_search_compile", "(", "pattern", ",", "re_verbose", ",", "re_version", ",", "pattern_type", ")", ":", "return", "_bre_parse", ".", "_SearchParser", "(", "pattern", ",", "re_verbose", ",", "re_version", ")", ".", "parse", "(", ")" ]
Cached search compile.
[ "Cached", "search", "compile", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L72-L75
facelessuser/backrefs
backrefs/bre.py
_apply_search_backrefs
def _apply_search_backrefs(pattern, flags=0): """Apply the search backrefs to the search pattern.""" if isinstance(pattern, (str, bytes)): re_verbose = bool(VERBOSE & flags) re_unicode = None if bool((ASCII | LOCALE) & flags): re_unicode = False elif bool(UNICODE & f...
python
def _apply_search_backrefs(pattern, flags=0): """Apply the search backrefs to the search pattern.""" if isinstance(pattern, (str, bytes)): re_verbose = bool(VERBOSE & flags) re_unicode = None if bool((ASCII | LOCALE) & flags): re_unicode = False elif bool(UNICODE & f...
[ "def", "_apply_search_backrefs", "(", "pattern", ",", "flags", "=", "0", ")", ":", "if", "isinstance", "(", "pattern", ",", "(", "str", ",", "bytes", ")", ")", ":", "re_verbose", "=", "bool", "(", "VERBOSE", "&", "flags", ")", "re_unicode", "=", "None"...
Apply the search backrefs to the search pattern.
[ "Apply", "the", "search", "backrefs", "to", "the", "search", "pattern", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L120-L143
facelessuser/backrefs
backrefs/bre.py
compile
def compile(pattern, flags=0, auto_compile=None): # noqa A001 """Compile both the search or search and replace into one object.""" if isinstance(pattern, Bre): if auto_compile is not None: raise ValueError("Cannot compile Bre with a different auto_compile!") elif flags != 0: ...
python
def compile(pattern, flags=0, auto_compile=None): # noqa A001 """Compile both the search or search and replace into one object.""" if isinstance(pattern, Bre): if auto_compile is not None: raise ValueError("Cannot compile Bre with a different auto_compile!") elif flags != 0: ...
[ "def", "compile", "(", "pattern", ",", "flags", "=", "0", ",", "auto_compile", "=", "None", ")", ":", "# noqa A001", "if", "isinstance", "(", "pattern", ",", "Bre", ")", ":", "if", "auto_compile", "is", "not", "None", ":", "raise", "ValueError", "(", "...
Compile both the search or search and replace into one object.
[ "Compile", "both", "the", "search", "or", "search", "and", "replace", "into", "one", "object", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L310-L323
facelessuser/backrefs
backrefs/bre.py
compile_replace
def compile_replace(pattern, repl, flags=0): """Construct a method that can be used as a replace method for `sub`, `subn`, etc.""" call = None if pattern is not None and isinstance(pattern, _RE_TYPE): if isinstance(repl, (str, bytes)): if not (pattern.flags & DEBUG): cal...
python
def compile_replace(pattern, repl, flags=0): """Construct a method that can be used as a replace method for `sub`, `subn`, etc.""" call = None if pattern is not None and isinstance(pattern, _RE_TYPE): if isinstance(repl, (str, bytes)): if not (pattern.flags & DEBUG): cal...
[ "def", "compile_replace", "(", "pattern", ",", "repl", ",", "flags", "=", "0", ")", ":", "call", "=", "None", "if", "pattern", "is", "not", "None", "and", "isinstance", "(", "pattern", ",", "_RE_TYPE", ")", ":", "if", "isinstance", "(", "repl", ",", ...
Construct a method that can be used as a replace method for `sub`, `subn`, etc.
[ "Construct", "a", "method", "that", "can", "be", "used", "as", "a", "replace", "method", "for", "sub", "subn", "etc", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L332-L352
facelessuser/backrefs
backrefs/bre.py
findall
def findall(pattern, string, *args, **kwargs): """Apply `findall` after applying backrefs.""" flags = args[2] if len(args) > 2 else kwargs.get('flags', 0) return _re.findall(_apply_search_backrefs(pattern, flags), string, *args, **kwargs)
python
def findall(pattern, string, *args, **kwargs): """Apply `findall` after applying backrefs.""" flags = args[2] if len(args) > 2 else kwargs.get('flags', 0) return _re.findall(_apply_search_backrefs(pattern, flags), string, *args, **kwargs)
[ "def", "findall", "(", "pattern", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "flags", "=", "args", "[", "2", "]", "if", "len", "(", "args", ")", ">", "2", "else", "kwargs", ".", "get", "(", "'flags'", ",", "0", ")", "...
Apply `findall` after applying backrefs.
[ "Apply", "findall", "after", "applying", "backrefs", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L405-L409
facelessuser/backrefs
backrefs/bre.py
sub
def sub(pattern, repl, string, *args, **kwargs): """Apply `sub` after applying backrefs.""" flags = args[4] if len(args) > 4 else kwargs.get('flags', 0) is_replace = _is_replace(repl) is_string = isinstance(repl, (str, bytes)) if is_replace and repl.use_format: raise ValueError("Compiled re...
python
def sub(pattern, repl, string, *args, **kwargs): """Apply `sub` after applying backrefs.""" flags = args[4] if len(args) > 4 else kwargs.get('flags', 0) is_replace = _is_replace(repl) is_string = isinstance(repl, (str, bytes)) if is_replace and repl.use_format: raise ValueError("Compiled re...
[ "def", "sub", "(", "pattern", ",", "repl", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "flags", "=", "args", "[", "4", "]", "if", "len", "(", "args", ")", ">", "4", "else", "kwargs", ".", "get", "(", "'flags'", ",", "0...
Apply `sub` after applying backrefs.
[ "Apply", "sub", "after", "applying", "backrefs", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L419-L431
pinax/pinax-webanalytics
pinax/webanalytics/activity.py
add
def add(request, kind, method, *args): """ add(request, "mixpanel", "track", "purchase", {order: "1234", amount: "100"}) add(request, "google", "push", ["_addTrans", "1234", "Gondor", "100"]) """ request.session.setdefault(_key_name(kind), []).append({ "method": method, "args": args ...
python
def add(request, kind, method, *args): """ add(request, "mixpanel", "track", "purchase", {order: "1234", amount: "100"}) add(request, "google", "push", ["_addTrans", "1234", "Gondor", "100"]) """ request.session.setdefault(_key_name(kind), []).append({ "method": method, "args": args ...
[ "def", "add", "(", "request", ",", "kind", ",", "method", ",", "*", "args", ")", ":", "request", ".", "session", ".", "setdefault", "(", "_key_name", "(", "kind", ")", ",", "[", "]", ")", ".", "append", "(", "{", "\"method\"", ":", "method", ",", ...
add(request, "mixpanel", "track", "purchase", {order: "1234", amount: "100"}) add(request, "google", "push", ["_addTrans", "1234", "Gondor", "100"])
[ "add", "(", "request", "mixpanel", "track", "purchase", "{", "order", ":", "1234", "amount", ":", "100", "}", ")", "add", "(", "request", "google", "push", "[", "_addTrans", "1234", "Gondor", "100", "]", ")" ]
train
https://github.com/pinax/pinax-webanalytics/blob/bc84f6bcefa022bfd2532187e5a949a391494578/pinax/webanalytics/activity.py#L25-L33
joesecurity/jbxapi
setup.py
get_version
def get_version(): """ Extract the version number from the code. """ here = os.path.abspath(os.path.dirname(__file__)) jbxapi_file = os.path.join(here, "jbxapi.py") with open(jbxapi_file) as f: content = f.read() match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M) ...
python
def get_version(): """ Extract the version number from the code. """ here = os.path.abspath(os.path.dirname(__file__)) jbxapi_file = os.path.join(here, "jbxapi.py") with open(jbxapi_file) as f: content = f.read() match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M) ...
[ "def", "get_version", "(", ")", ":", "here", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "jbxapi_file", "=", "os", ".", "path", ".", "join", "(", "here", ",", "\"jbxapi.py\"", ")", "wit...
Extract the version number from the code.
[ "Extract", "the", "version", "number", "from", "the", "code", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/setup.py#L7-L18
joesecurity/jbxapi
jbxapi.py
JoeSandbox.analysis_list
def analysis_list(self): """ Fetch a list of all analyses. """ response = self._post(self.apiurl + '/v2/analysis/list', data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def analysis_list(self): """ Fetch a list of all analyses. """ response = self._post(self.apiurl + '/v2/analysis/list', data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "analysis_list", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "'/v2/analysis/list'", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", "_raise_or_extra...
Fetch a list of all analyses.
[ "Fetch", "a", "list", "of", "all", "analyses", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L158-L164
joesecurity/jbxapi
jbxapi.py
JoeSandbox.submit_sample
def submit_sample(self, sample, cookbook=None, params={}, _extra_params={}): """ Submit a sample and returns the submission id. Parameters: sample: The sample to submit. Needs to be a file-like object or a tuple in the shape (filename, file-like object). ...
python
def submit_sample(self, sample, cookbook=None, params={}, _extra_params={}): """ Submit a sample and returns the submission id. Parameters: sample: The sample to submit. Needs to be a file-like object or a tuple in the shape (filename, file-like object). ...
[ "def", "submit_sample", "(", "self", ",", "sample", ",", "cookbook", "=", "None", ",", "params", "=", "{", "}", ",", "_extra_params", "=", "{", "}", ")", ":", "self", ".", "_check_user_parameters", "(", "params", ")", "files", "=", "{", "'sample'", ":"...
Submit a sample and returns the submission id. Parameters: sample: The sample to submit. Needs to be a file-like object or a tuple in the shape (filename, file-like object). cookbook: Uploads a cookbook together with the sample. Needs to be a file-like obje...
[ "Submit", "a", "sample", "and", "returns", "the", "submission", "id", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L166-L202
joesecurity/jbxapi
jbxapi.py
JoeSandbox.submit_sample_url
def submit_sample_url(self, url, params={}, _extra_params={}): """ Submit a sample at a given URL for analysis. """ self._check_user_parameters(params) params = copy.copy(params) params['sample-url'] = url return self._submit(params, _extra_params=_extra_params)
python
def submit_sample_url(self, url, params={}, _extra_params={}): """ Submit a sample at a given URL for analysis. """ self._check_user_parameters(params) params = copy.copy(params) params['sample-url'] = url return self._submit(params, _extra_params=_extra_params)
[ "def", "submit_sample_url", "(", "self", ",", "url", ",", "params", "=", "{", "}", ",", "_extra_params", "=", "{", "}", ")", ":", "self", ".", "_check_user_parameters", "(", "params", ")", "params", "=", "copy", ".", "copy", "(", "params", ")", "params...
Submit a sample at a given URL for analysis.
[ "Submit", "a", "sample", "at", "a", "given", "URL", "for", "analysis", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L204-L211
joesecurity/jbxapi
jbxapi.py
JoeSandbox.submit_url
def submit_url(self, url, params={}, _extra_params={}): """ Submit a website for analysis. """ self._check_user_parameters(params) params = copy.copy(params) params['url'] = url return self._submit(params, _extra_params=_extra_params)
python
def submit_url(self, url, params={}, _extra_params={}): """ Submit a website for analysis. """ self._check_user_parameters(params) params = copy.copy(params) params['url'] = url return self._submit(params, _extra_params=_extra_params)
[ "def", "submit_url", "(", "self", ",", "url", ",", "params", "=", "{", "}", ",", "_extra_params", "=", "{", "}", ")", ":", "self", ".", "_check_user_parameters", "(", "params", ")", "params", "=", "copy", ".", "copy", "(", "params", ")", "params", "[...
Submit a website for analysis.
[ "Submit", "a", "website", "for", "analysis", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L213-L220
joesecurity/jbxapi
jbxapi.py
JoeSandbox.submit_cookbook
def submit_cookbook(self, cookbook, params={}, _extra_params={}): """ Submit a cookbook. """ self._check_user_parameters(params) files = {'cookbook': cookbook} return self._submit(params, files, _extra_params=_extra_params)
python
def submit_cookbook(self, cookbook, params={}, _extra_params={}): """ Submit a cookbook. """ self._check_user_parameters(params) files = {'cookbook': cookbook} return self._submit(params, files, _extra_params=_extra_params)
[ "def", "submit_cookbook", "(", "self", ",", "cookbook", ",", "params", "=", "{", "}", ",", "_extra_params", "=", "{", "}", ")", ":", "self", ".", "_check_user_parameters", "(", "params", ")", "files", "=", "{", "'cookbook'", ":", "cookbook", "}", "return...
Submit a cookbook.
[ "Submit", "a", "cookbook", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L222-L228
joesecurity/jbxapi
jbxapi.py
JoeSandbox.submission_delete
def submission_delete(self, submission_id): """ Delete a submission. """ response = self._post(self.apiurl + '/v2/submission/delete', data={'apikey': self.apikey, 'submission_id': submission_id}) return self._raise_or_extract(response)
python
def submission_delete(self, submission_id): """ Delete a submission. """ response = self._post(self.apiurl + '/v2/submission/delete', data={'apikey': self.apikey, 'submission_id': submission_id}) return self._raise_or_extract(response)
[ "def", "submission_delete", "(", "self", ",", "submission_id", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "'/v2/submission/delete'", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", ",", "'submission_id'",...
Delete a submission.
[ "Delete", "a", "submission", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L271-L277
joesecurity/jbxapi
jbxapi.py
JoeSandbox.server_online
def server_online(self): """ Returns True if the Joe Sandbox servers are running or False if they are in maintenance mode. """ response = self._post(self.apiurl + '/v2/server/online', data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def server_online(self): """ Returns True if the Joe Sandbox servers are running or False if they are in maintenance mode. """ response = self._post(self.apiurl + '/v2/server/online', data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "server_online", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "'/v2/server/online'", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", "_raise_or_extra...
Returns True if the Joe Sandbox servers are running or False if they are in maintenance mode.
[ "Returns", "True", "if", "the", "Joe", "Sandbox", "servers", "are", "running", "or", "False", "if", "they", "are", "in", "maintenance", "mode", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L279-L285
joesecurity/jbxapi
jbxapi.py
JoeSandbox.analysis_info
def analysis_info(self, webid): """ Show the status and most important attributes of an analysis. """ response = self._post(self.apiurl + "/v2/analysis/info", data={'apikey': self.apikey, 'webid': webid}) return self._raise_or_extract(response)
python
def analysis_info(self, webid): """ Show the status and most important attributes of an analysis. """ response = self._post(self.apiurl + "/v2/analysis/info", data={'apikey': self.apikey, 'webid': webid}) return self._raise_or_extract(response)
[ "def", "analysis_info", "(", "self", ",", "webid", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/analysis/info\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", ",", "'webid'", ":", "webid", "...
Show the status and most important attributes of an analysis.
[ "Show", "the", "status", "and", "most", "important", "attributes", "of", "an", "analysis", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L287-L293
joesecurity/jbxapi
jbxapi.py
JoeSandbox.analysis_download
def analysis_download(self, webid, type, run=None, file=None): """ Download a resource for an analysis. E.g. the full report, binaries, screenshots. The full list of resources can be found in our API documentation. When `file` is given, the return value is the filename specified by the ...
python
def analysis_download(self, webid, type, run=None, file=None): """ Download a resource for an analysis. E.g. the full report, binaries, screenshots. The full list of resources can be found in our API documentation. When `file` is given, the return value is the filename specified by the ...
[ "def", "analysis_download", "(", "self", ",", "webid", ",", "type", ",", "run", "=", "None", ",", "file", "=", "None", ")", ":", "# when no file is specified, we create our own", "if", "file", "is", "None", ":", "_file", "=", "io", ".", "BytesIO", "(", ")"...
Download a resource for an analysis. E.g. the full report, binaries, screenshots. The full list of resources can be found in our API documentation. When `file` is given, the return value is the filename specified by the server, otherwise it's a tuple of (filename, bytes). Parameters: ...
[ "Download", "a", "resource", "for", "an", "analysis", ".", "E", ".", "g", ".", "the", "full", "report", "binaries", "screenshots", ".", "The", "full", "list", "of", "resources", "can", "be", "found", "in", "our", "API", "documentation", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L303-L363
joesecurity/jbxapi
jbxapi.py
JoeSandbox.analysis_search
def analysis_search(self, query): """ Lists the webids of the analyses that match the given query. Searches in MD5, SHA1, SHA256, filename, cookbook name, comment, url and report id. """ response = self._post(self.apiurl + "/v2/analysis/search", data={'apikey': self.apikey, 'q':...
python
def analysis_search(self, query): """ Lists the webids of the analyses that match the given query. Searches in MD5, SHA1, SHA256, filename, cookbook name, comment, url and report id. """ response = self._post(self.apiurl + "/v2/analysis/search", data={'apikey': self.apikey, 'q':...
[ "def", "analysis_search", "(", "self", ",", "query", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/analysis/search\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", ",", "'q'", ":", "query", "...
Lists the webids of the analyses that match the given query. Searches in MD5, SHA1, SHA256, filename, cookbook name, comment, url and report id.
[ "Lists", "the", "webids", "of", "the", "analyses", "that", "match", "the", "given", "query", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L365-L373
joesecurity/jbxapi
jbxapi.py
JoeSandbox.server_systems
def server_systems(self): """ Retrieve a list of available systems. """ response = self._post(self.apiurl + "/v2/server/systems", data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def server_systems(self): """ Retrieve a list of available systems. """ response = self._post(self.apiurl + "/v2/server/systems", data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "server_systems", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/server/systems\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", "_raise_or_e...
Retrieve a list of available systems.
[ "Retrieve", "a", "list", "of", "available", "systems", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L375-L381
joesecurity/jbxapi
jbxapi.py
JoeSandbox.account_info
def account_info(self): """ Only available on Joe Sandbox Cloud Show information about the account. """ response = self._post(self.apiurl + "/v2/account/info", data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def account_info(self): """ Only available on Joe Sandbox Cloud Show information about the account. """ response = self._post(self.apiurl + "/v2/account/info", data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "account_info", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/account/info\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", "_raise_or_extra...
Only available on Joe Sandbox Cloud Show information about the account.
[ "Only", "available", "on", "Joe", "Sandbox", "Cloud" ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L383-L391
joesecurity/jbxapi
jbxapi.py
JoeSandbox.server_info
def server_info(self): """ Query information about the server. """ response = self._post(self.apiurl + "/v2/server/info", data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def server_info(self): """ Query information about the server. """ response = self._post(self.apiurl + "/v2/server/info", data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "server_info", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/server/info\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", "_raise_or_extract...
Query information about the server.
[ "Query", "information", "about", "the", "server", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L393-L399
joesecurity/jbxapi
jbxapi.py
JoeSandbox.server_lia_countries
def server_lia_countries(self): """ Show the available localized internet anonymization countries. """ response = self._post(self.apiurl + "/v2/server/lia_countries", data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def server_lia_countries(self): """ Show the available localized internet anonymization countries. """ response = self._post(self.apiurl + "/v2/server/lia_countries", data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "server_lia_countries", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/server/lia_countries\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "self", ".", ...
Show the available localized internet anonymization countries.
[ "Show", "the", "available", "localized", "internet", "anonymization", "countries", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L401-L407
joesecurity/jbxapi
jbxapi.py
JoeSandbox.server_languages_and_locales
def server_languages_and_locales(self): """ Show the available languages and locales """ response = self._post(self.apiurl + "/v2/server/languages_and_locales", data={'apikey': self.apikey}) return self._raise_or_extract(response)
python
def server_languages_and_locales(self): """ Show the available languages and locales """ response = self._post(self.apiurl + "/v2/server/languages_and_locales", data={'apikey': self.apikey}) return self._raise_or_extract(response)
[ "def", "server_languages_and_locales", "(", "self", ")", ":", "response", "=", "self", ".", "_post", "(", "self", ".", "apiurl", "+", "\"/v2/server/languages_and_locales\"", ",", "data", "=", "{", "'apikey'", ":", "self", ".", "apikey", "}", ")", "return", "...
Show the available languages and locales
[ "Show", "the", "available", "languages", "and", "locales" ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L409-L415
joesecurity/jbxapi
jbxapi.py
JoeSandbox._post
def _post(self, url, data=None, **kwargs): """ Wrapper around requests.post which (a) always inserts a timeout (b) converts errors to ConnectionError (c) re-tries a few times (d) converts file names to ASCII """ # Remove non-ASCII charact...
python
def _post(self, url, data=None, **kwargs): """ Wrapper around requests.post which (a) always inserts a timeout (b) converts errors to ConnectionError (c) re-tries a few times (d) converts file names to ASCII """ # Remove non-ASCII charact...
[ "def", "_post", "(", "self", ",", "url", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Remove non-ASCII characters from filenames due to a limitation of the combination of", "# urllib3 (via python-requests) and our server", "# https://github.com/requests/request...
Wrapper around requests.post which (a) always inserts a timeout (b) converts errors to ConnectionError (c) re-tries a few times (d) converts file names to ASCII
[ "Wrapper", "around", "requests", ".", "post", "which" ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L417-L463
joesecurity/jbxapi
jbxapi.py
JoeSandbox._check_user_parameters
def _check_user_parameters(self, user_parameters): """ Verifies that the parameter dict given by the user only contains known keys. This ensures that the user detects typos faster. """ if not user_parameters: return # sanity check against typos for ke...
python
def _check_user_parameters(self, user_parameters): """ Verifies that the parameter dict given by the user only contains known keys. This ensures that the user detects typos faster. """ if not user_parameters: return # sanity check against typos for ke...
[ "def", "_check_user_parameters", "(", "self", ",", "user_parameters", ")", ":", "if", "not", "user_parameters", ":", "return", "# sanity check against typos", "for", "key", "in", "user_parameters", ":", "if", "key", "not", "in", "submission_defaults", ":", "raise", ...
Verifies that the parameter dict given by the user only contains known keys. This ensures that the user detects typos faster.
[ "Verifies", "that", "the", "parameter", "dict", "given", "by", "the", "user", "only", "contains", "known", "keys", ".", "This", "ensures", "that", "the", "user", "detects", "typos", "faster", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L465-L476
joesecurity/jbxapi
jbxapi.py
JoeSandbox._raise_or_extract
def _raise_or_extract(self, response): """ Raises an exception if the response indicates an API error. Otherwise returns the object at the 'data' key of the API response. """ try: data = response.json() except ValueError: raise JoeException("The ...
python
def _raise_or_extract(self, response): """ Raises an exception if the response indicates an API error. Otherwise returns the object at the 'data' key of the API response. """ try: data = response.json() except ValueError: raise JoeException("The ...
[ "def", "_raise_or_extract", "(", "self", ",", "response", ")", ":", "try", ":", "data", "=", "response", ".", "json", "(", ")", "except", "ValueError", ":", "raise", "JoeException", "(", "\"The server responded with an unexpected format ({}). Is the API url correct?\"",...
Raises an exception if the response indicates an API error. Otherwise returns the object at the 'data' key of the API response.
[ "Raises", "an", "exception", "if", "the", "response", "indicates", "an", "API", "error", "." ]
train
https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L478-L497
nir0s/distro
distro.py
LinuxDistribution._parse_os_release_content
def _parse_os_release_content(lines): """ Parse the lines of an os-release file. Parameters: * lines: Iterable through the lines in the os-release file. Each line must be a unicode string or a UTF-8 encoded byte string. Returns: A ...
python
def _parse_os_release_content(lines): """ Parse the lines of an os-release file. Parameters: * lines: Iterable through the lines in the os-release file. Each line must be a unicode string or a UTF-8 encoded byte string. Returns: A ...
[ "def", "_parse_os_release_content", "(", "lines", ")", ":", "props", "=", "{", "}", "lexer", "=", "shlex", ".", "shlex", "(", "lines", ",", "posix", "=", "True", ")", "lexer", ".", "whitespace_split", "=", "True", "# The shlex module defines its `wordchars` vari...
Parse the lines of an os-release file. Parameters: * lines: Iterable through the lines in the os-release file. Each line must be a unicode string or a UTF-8 encoded byte string. Returns: A dictionary containing all information items.
[ "Parse", "the", "lines", "of", "an", "os", "-", "release", "file", "." ]
train
https://github.com/nir0s/distro/blob/f3e164cf085ad68822a4be9b7b1531ea8ce14499/distro.py#L933-L997
merenlab/illumina-utils
IlluminaUtils/utils/helperfunctions.py
visualize_qual_stats_dict_single
def visualize_qual_stats_dict_single(D, dest, title): """ same as visualize_qual_stats_dict, but puts all tiles together. """ # first find out how many cycles were there. it is going to be about 101 for # hiseq runs, and 251 in miseq runs, but these values may change from run to # run. although...
python
def visualize_qual_stats_dict_single(D, dest, title): """ same as visualize_qual_stats_dict, but puts all tiles together. """ # first find out how many cycles were there. it is going to be about 101 for # hiseq runs, and 251 in miseq runs, but these values may change from run to # run. although...
[ "def", "visualize_qual_stats_dict_single", "(", "D", ",", "dest", ",", "title", ")", ":", "# first find out how many cycles were there. it is going to be about 101 for", "# hiseq runs, and 251 in miseq runs, but these values may change from run to", "# run. although all lanes are expected to...
same as visualize_qual_stats_dict, but puts all tiles together.
[ "same", "as", "visualize_qual_stats_dict", "but", "puts", "all", "tiles", "together", "." ]
train
https://github.com/merenlab/illumina-utils/blob/246d0611f976471783b83d2aba309b0cb57210f6/IlluminaUtils/utils/helperfunctions.py#L572-L654
merenlab/illumina-utils
IlluminaUtils/utils/terminal.py
pretty_print
def pretty_print(n): """Pretty print function for very big integers""" if type(n) != int: return n ret = [] n = str(n) for i in range(len(n) - 1, -1, -1): ret.append(n[i]) if (len(n) - i) % 3 == 0: ret.append(',') ret.reverse() return ''.join(ret[1:]) if ...
python
def pretty_print(n): """Pretty print function for very big integers""" if type(n) != int: return n ret = [] n = str(n) for i in range(len(n) - 1, -1, -1): ret.append(n[i]) if (len(n) - i) % 3 == 0: ret.append(',') ret.reverse() return ''.join(ret[1:]) if ...
[ "def", "pretty_print", "(", "n", ")", ":", "if", "type", "(", "n", ")", "!=", "int", ":", "return", "n", "ret", "=", "[", "]", "n", "=", "str", "(", "n", ")", "for", "i", "in", "range", "(", "len", "(", "n", ")", "-", "1", ",", "-", "1", ...
Pretty print function for very big integers
[ "Pretty", "print", "function", "for", "very", "big", "integers" ]
train
https://github.com/merenlab/illumina-utils/blob/246d0611f976471783b83d2aba309b0cb57210f6/IlluminaUtils/utils/terminal.py#L170-L182
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/neutron_ext/extensions/a10Certificate.py
A10Certificate.get_resources
def get_resources(cls): """Returns external resources.""" my_plurals = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) attributes.PLURALS.update(my_plurals) attr_map = RESOURCE_ATTRIBUTE_MAP ext_resources = resource_helper.build_resource_info(my_plu...
python
def get_resources(cls): """Returns external resources.""" my_plurals = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) attributes.PLURALS.update(my_plurals) attr_map = RESOURCE_ATTRIBUTE_MAP ext_resources = resource_helper.build_resource_info(my_plu...
[ "def", "get_resources", "(", "cls", ")", ":", "my_plurals", "=", "resource_helper", ".", "build_plural_mappings", "(", "{", "}", ",", "RESOURCE_ATTRIBUTE_MAP", ")", "attributes", ".", "PLURALS", ".", "update", "(", "my_plurals", ")", "attr_map", "=", "RESOURCE_A...
Returns external resources.
[ "Returns", "external", "resources", "." ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/neutron_ext/extensions/a10Certificate.py#L78-L88
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/neutron_ext/services/a10_device_instance/plugin.py
A10DeviceInstancePlugin.create_a10_device_instance
def create_a10_device_instance(self, context, a10_device_instance): """Attempt to create instance using neutron context""" LOG.debug("A10DeviceInstancePlugin.create(): a10_device_instance=%s", a10_device_instance) config = a10_config.A10Config() vthunder_defaults = config.get_vthunder_c...
python
def create_a10_device_instance(self, context, a10_device_instance): """Attempt to create instance using neutron context""" LOG.debug("A10DeviceInstancePlugin.create(): a10_device_instance=%s", a10_device_instance) config = a10_config.A10Config() vthunder_defaults = config.get_vthunder_c...
[ "def", "create_a10_device_instance", "(", "self", ",", "context", ",", "a10_device_instance", ")", ":", "LOG", ".", "debug", "(", "\"A10DeviceInstancePlugin.create(): a10_device_instance=%s\"", ",", "a10_device_instance", ")", "config", "=", "a10_config", ".", "A10Config"...
Attempt to create instance using neutron context
[ "Attempt", "to", "create", "instance", "using", "neutron", "context" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/neutron_ext/services/a10_device_instance/plugin.py#L95-L122
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/v1/handler_vip.py
VipHandler.vport_meta
def vport_meta(self, vip): """Get the vport meta, no matter which name was used""" vport_meta = self.meta(vip, 'vport', None) if vport_meta is None: vport_meta = self.meta(vip, 'port', {}) return vport_meta
python
def vport_meta(self, vip): """Get the vport meta, no matter which name was used""" vport_meta = self.meta(vip, 'vport', None) if vport_meta is None: vport_meta = self.meta(vip, 'port', {}) return vport_meta
[ "def", "vport_meta", "(", "self", ",", "vip", ")", ":", "vport_meta", "=", "self", ".", "meta", "(", "vip", ",", "'vport'", ",", "None", ")", "if", "vport_meta", "is", "None", ":", "vport_meta", "=", "self", ".", "meta", "(", "vip", ",", "'port'", ...
Get the vport meta, no matter which name was used
[ "Get", "the", "vport", "meta", "no", "matter", "which", "name", "was", "used" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/v1/handler_vip.py#L28-L33
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/neutron_ext/common/resources.py
apply_template
def apply_template(template, *args, **kw): """Applies every callable in any Mapping or Iterable""" if six.callable(template): return template(*args, **kw) if isinstance(template, six.string_types): return template if isinstance(template, collections.Mapping): return template.__cl...
python
def apply_template(template, *args, **kw): """Applies every callable in any Mapping or Iterable""" if six.callable(template): return template(*args, **kw) if isinstance(template, six.string_types): return template if isinstance(template, collections.Mapping): return template.__cl...
[ "def", "apply_template", "(", "template", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "six", ".", "callable", "(", "template", ")", ":", "return", "template", "(", "*", "args", ",", "*", "*", "kw", ")", "if", "isinstance", "(", "template...
Applies every callable in any Mapping or Iterable
[ "Applies", "every", "callable", "in", "any", "Mapping", "or", "Iterable" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/neutron_ext/common/resources.py#L26-L36
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/neutron_ext/extensions/a10DeviceInstance.py
A10deviceinstance.get_resources
def get_resources(cls): """Returns external resources.""" my_plurals = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) attributes.PLURALS.update(my_plurals) attr_map = RESOURCE_ATTRIBUTE_MAP resources = resource_helper.build_resource_info(my_plurals...
python
def get_resources(cls): """Returns external resources.""" my_plurals = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) attributes.PLURALS.update(my_plurals) attr_map = RESOURCE_ATTRIBUTE_MAP resources = resource_helper.build_resource_info(my_plurals...
[ "def", "get_resources", "(", "cls", ")", ":", "my_plurals", "=", "resource_helper", ".", "build_plural_mappings", "(", "{", "}", ",", "RESOURCE_ATTRIBUTE_MAP", ")", "attributes", ".", "PLURALS", ".", "update", "(", "my_plurals", ")", "attr_map", "=", "RESOURCE_A...
Returns external resources.
[ "Returns", "external", "resources", "." ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/neutron_ext/extensions/a10DeviceInstance.py#L78-L88
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/vthunder/instance_initialization.py
initialize_vthunder
def initialize_vthunder(a10_cfg, device_cfg, client): """Perform initialization of system-wide settings""" vth = a10_cfg.get_vthunder_config() initialize_interfaces(vth, device_cfg, client) initialize_dns(vth, device_cfg, client) initialize_licensing(vth, device_cfg, client) initialize_sflow(vt...
python
def initialize_vthunder(a10_cfg, device_cfg, client): """Perform initialization of system-wide settings""" vth = a10_cfg.get_vthunder_config() initialize_interfaces(vth, device_cfg, client) initialize_dns(vth, device_cfg, client) initialize_licensing(vth, device_cfg, client) initialize_sflow(vt...
[ "def", "initialize_vthunder", "(", "a10_cfg", ",", "device_cfg", ",", "client", ")", ":", "vth", "=", "a10_cfg", ".", "get_vthunder_config", "(", ")", "initialize_interfaces", "(", "vth", ",", "device_cfg", ",", "client", ")", "initialize_dns", "(", "vth", ","...
Perform initialization of system-wide settings
[ "Perform", "initialization", "of", "system", "-", "wide", "settings" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/vthunder/instance_initialization.py#L74-L81
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/db/api.py
magic_session
def magic_session(db_session=None, url=None): """Either does nothing with the session you already have or makes one that commits and closes no matter what happens """ if db_session is not None: yield db_session else: session = get_session(url, expire_on_commit=False) try: ...
python
def magic_session(db_session=None, url=None): """Either does nothing with the session you already have or makes one that commits and closes no matter what happens """ if db_session is not None: yield db_session else: session = get_session(url, expire_on_commit=False) try: ...
[ "def", "magic_session", "(", "db_session", "=", "None", ",", "url", "=", "None", ")", ":", "if", "db_session", "is", "not", "None", ":", "yield", "db_session", "else", ":", "session", "=", "get_session", "(", "url", ",", "expire_on_commit", "=", "False", ...
Either does nothing with the session you already have or makes one that commits and closes no matter what happens
[ "Either", "does", "nothing", "with", "the", "session", "you", "already", "have", "or", "makes", "one", "that", "commits", "and", "closes", "no", "matter", "what", "happens" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/db/api.py#L50-L65
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/vthunder/instance_manager.py
InstanceManager._plumb_port
def _plumb_port(self, server, network_id, wrong_ips): """Look for an existing port on the network Add one if it doesn't exist """ for attached_interface in server.interface_list(): if attached_interface.net_id == network_id: if any(map(lambda x: x['ip_address...
python
def _plumb_port(self, server, network_id, wrong_ips): """Look for an existing port on the network Add one if it doesn't exist """ for attached_interface in server.interface_list(): if attached_interface.net_id == network_id: if any(map(lambda x: x['ip_address...
[ "def", "_plumb_port", "(", "self", ",", "server", ",", "network_id", ",", "wrong_ips", ")", ":", "for", "attached_interface", "in", "server", ".", "interface_list", "(", ")", ":", "if", "attached_interface", ".", "net_id", "==", "network_id", ":", "if", "any...
Look for an existing port on the network Add one if it doesn't exist
[ "Look", "for", "an", "existing", "port", "on", "the", "network", "Add", "one", "if", "it", "doesn", "t", "exist" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/vthunder/instance_manager.py#L349-L360
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/plumbing/wrappers.py
NeutronDbWrapper.allocate_ip_for_subnet
def allocate_ip_for_subnet(self, subnet_id, mac, port_id): """Allocates an IP from the specified subnet and creates a port""" # Get an available IP and mark it as used before someone else does # If there's no IP, , log it and return an error # If we successfully get an IP, create a port ...
python
def allocate_ip_for_subnet(self, subnet_id, mac, port_id): """Allocates an IP from the specified subnet and creates a port""" # Get an available IP and mark it as used before someone else does # If there's no IP, , log it and return an error # If we successfully get an IP, create a port ...
[ "def", "allocate_ip_for_subnet", "(", "self", ",", "subnet_id", ",", "mac", ",", "port_id", ")", ":", "# Get an available IP and mark it as used before someone else does", "# If there's no IP, , log it and return an error", "# If we successfully get an IP, create a port with the specifie...
Allocates an IP from the specified subnet and creates a port
[ "Allocates", "an", "IP", "from", "the", "specified", "subnet", "and", "creates", "a", "port" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/plumbing/wrappers.py#L132-L140
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/plumbing/wrappers.py
NeutronDbWrapper.a10_allocate_ip_from_dhcp_range
def a10_allocate_ip_from_dhcp_range(self, subnet, interface_id, mac, port_id): """Search for an available IP.addr from unallocated nmodels.IPAllocationPool range. If no addresses are available then an error is raised. Returns the address as a string. This search is conducted by a difference of t...
python
def a10_allocate_ip_from_dhcp_range(self, subnet, interface_id, mac, port_id): """Search for an available IP.addr from unallocated nmodels.IPAllocationPool range. If no addresses are available then an error is raised. Returns the address as a string. This search is conducted by a difference of t...
[ "def", "a10_allocate_ip_from_dhcp_range", "(", "self", ",", "subnet", ",", "interface_id", ",", "mac", ",", "port_id", ")", ":", "subnet_id", "=", "subnet", "[", "\"id\"", "]", "network_id", "=", "subnet", "[", "\"network_id\"", "]", "iprange_result", "=", "se...
Search for an available IP.addr from unallocated nmodels.IPAllocationPool range. If no addresses are available then an error is raised. Returns the address as a string. This search is conducted by a difference of the nmodels.IPAllocationPool set_a and the current IP allocations.
[ "Search", "for", "an", "available", "IP", ".", "addr", "from", "unallocated", "nmodels", ".", "IPAllocationPool", "range", ".", "If", "no", "addresses", "are", "available", "then", "an", "error", "is", "raised", ".", "Returns", "the", "address", "as", "a", ...
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/plumbing/wrappers.py#L195-L225
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/v1/handler_hm.py
HealthMonitorHandler._dissociate
def _dissociate(self, c, context, hm, pool_id): """Remove a pool association""" pool_name = self._pool_name(context, pool_id) c.client.slb.service_group.update(pool_name, health_monitor="", health_check_disable=True)
python
def _dissociate(self, c, context, hm, pool_id): """Remove a pool association""" pool_name = self._pool_name(context, pool_id) c.client.slb.service_group.update(pool_name, health_monitor="", health_check_disable=True)
[ "def", "_dissociate", "(", "self", ",", "c", ",", "context", ",", "hm", ",", "pool_id", ")", ":", "pool_name", "=", "self", ".", "_pool_name", "(", "context", ",", "pool_id", ")", "c", ".", "client", ".", "slb", ".", "service_group", ".", "update", "...
Remove a pool association
[ "Remove", "a", "pool", "association" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/v1/handler_hm.py#L75-L79
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/v1/handler_hm.py
HealthMonitorHandler.dissociate
def dissociate(self, c, context, hm, pool_id): """Remove a pool association, and the healthmonitor if its the last one""" self._dissociate(c, context, hm, pool_id) pools = hm.get("pools", []) if not any(p for p in pools if p.get("pool_id") != pool_id): self._delete_unused(c,...
python
def dissociate(self, c, context, hm, pool_id): """Remove a pool association, and the healthmonitor if its the last one""" self._dissociate(c, context, hm, pool_id) pools = hm.get("pools", []) if not any(p for p in pools if p.get("pool_id") != pool_id): self._delete_unused(c,...
[ "def", "dissociate", "(", "self", ",", "c", ",", "context", ",", "hm", ",", "pool_id", ")", ":", "self", ".", "_dissociate", "(", "c", ",", "context", ",", "hm", ",", "pool_id", ")", "pools", "=", "hm", ".", "get", "(", "\"pools\"", ",", "[", "]"...
Remove a pool association, and the healthmonitor if its the last one
[ "Remove", "a", "pool", "association", "and", "the", "healthmonitor", "if", "its", "the", "last", "one" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/v1/handler_hm.py#L81-L87
a10networks/a10-neutron-lbaas
a10_neutron_lbaas/v1/handler_hm.py
HealthMonitorHandler._delete
def _delete(self, c, context, hm): """Delete a healthmonitor and ALL its pool associations""" pools = hm.get("pools", []) for pool in pools: pool_id = pool.get("pool_id") self._dissociate(c, context, hm, pool_id) self._delete_unused(c, context, hm)
python
def _delete(self, c, context, hm): """Delete a healthmonitor and ALL its pool associations""" pools = hm.get("pools", []) for pool in pools: pool_id = pool.get("pool_id") self._dissociate(c, context, hm, pool_id) self._delete_unused(c, context, hm)
[ "def", "_delete", "(", "self", ",", "c", ",", "context", ",", "hm", ")", ":", "pools", "=", "hm", ".", "get", "(", "\"pools\"", ",", "[", "]", ")", "for", "pool", "in", "pools", ":", "pool_id", "=", "pool", ".", "get", "(", "\"pool_id\"", ")", ...
Delete a healthmonitor and ALL its pool associations
[ "Delete", "a", "healthmonitor", "and", "ALL", "its", "pool", "associations" ]
train
https://github.com/a10networks/a10-neutron-lbaas/blob/ff834c295c8019874ca4b209d864367e40cc9881/a10_neutron_lbaas/v1/handler_hm.py#L89-L97
Dallinger/Dallinger
demos/dlgr/demos/rogers/models.py
RogersAgent.calculate_fitness
def calculate_fitness(self): """Calculcate your fitness.""" if self.fitness is not None: raise Exception( "You are calculating the fitness of agent {}, ".format(self.id) + "but they already have a fitness" ) said_blue = self.infos(type=Mem...
python
def calculate_fitness(self): """Calculcate your fitness.""" if self.fitness is not None: raise Exception( "You are calculating the fitness of agent {}, ".format(self.id) + "but they already have a fitness" ) said_blue = self.infos(type=Mem...
[ "def", "calculate_fitness", "(", "self", ")", ":", "if", "self", ".", "fitness", "is", "not", "None", ":", "raise", "Exception", "(", "\"You are calculating the fitness of agent {}, \"", ".", "format", "(", "self", ".", "id", ")", "+", "\"but they already have a f...
Calculcate your fitness.
[ "Calculcate", "your", "fitness", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/models.py#L94-L125
Dallinger/Dallinger
demos/dlgr/demos/rogers/models.py
RogersAgent.update
def update(self, infos): """Process received infos.""" genes = [i for i in infos if isinstance(i, LearningGene)] for gene in genes: if ( self.network.role == "experiment" and self.generation > 0 and random.random() < 0.10 ):...
python
def update(self, infos): """Process received infos.""" genes = [i for i in infos if isinstance(i, LearningGene)] for gene in genes: if ( self.network.role == "experiment" and self.generation > 0 and random.random() < 0.10 ):...
[ "def", "update", "(", "self", ",", "infos", ")", ":", "genes", "=", "[", "i", "for", "i", "in", "infos", "if", "isinstance", "(", "i", ",", "LearningGene", ")", "]", "for", "gene", "in", "genes", ":", "if", "(", "self", ".", "network", ".", "role...
Process received infos.
[ "Process", "received", "infos", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/models.py#L127-L138
Dallinger/Dallinger
demos/dlgr/demos/bartlett1932/experiment.py
Bartlett1932.setup
def setup(self): """Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network. ""...
python
def setup(self): """Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network. ""...
[ "def", "setup", "(", "self", ")", ":", "if", "not", "self", ".", "networks", "(", ")", ":", "super", "(", "Bartlett1932", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "self", ".", "networks", "(", ")", ":", "self", ".", "models",...
Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network.
[ "Setup", "the", "networks", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/bartlett1932/experiment.py#L47-L58
Dallinger/Dallinger
demos/dlgr/demos/bartlett1932/experiment.py
Bartlett1932.add_node_to_network
def add_node_to_network(self, node, network): """Add node to the chain and receive transmissions.""" network.add_node(node) parents = node.neighbors(direction="from") if len(parents): parent = parents[0] parent.transmit() node.receive()
python
def add_node_to_network(self, node, network): """Add node to the chain and receive transmissions.""" network.add_node(node) parents = node.neighbors(direction="from") if len(parents): parent = parents[0] parent.transmit() node.receive()
[ "def", "add_node_to_network", "(", "self", ",", "node", ",", "network", ")", ":", "network", ".", "add_node", "(", "node", ")", "parents", "=", "node", ".", "neighbors", "(", "direction", "=", "\"from\"", ")", "if", "len", "(", "parents", ")", ":", "pa...
Add node to the chain and receive transmissions.
[ "Add", "node", "to", "the", "chain", "and", "receive", "transmissions", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/bartlett1932/experiment.py#L64-L71
Dallinger/Dallinger
demos/dlgr/demos/bartlett1932/experiment.py
Bartlett1932.recruit
def recruit(self): """Recruit one participant at a time until all networks are full.""" if self.networks(full=False): self.recruiter.recruit(n=1) else: self.recruiter.close_recruitment()
python
def recruit(self): """Recruit one participant at a time until all networks are full.""" if self.networks(full=False): self.recruiter.recruit(n=1) else: self.recruiter.close_recruitment()
[ "def", "recruit", "(", "self", ")", ":", "if", "self", ".", "networks", "(", "full", "=", "False", ")", ":", "self", ".", "recruiter", ".", "recruit", "(", "n", "=", "1", ")", "else", ":", "self", ".", "recruiter", ".", "close_recruitment", "(", ")...
Recruit one participant at a time until all networks are full.
[ "Recruit", "one", "participant", "at", "a", "time", "until", "all", "networks", "are", "full", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/bartlett1932/experiment.py#L73-L78
Dallinger/Dallinger
demos/dlgr/demos/bartlett1932/experiment.py
Bot.participate
def participate(self): """Finish reading and send text""" try: logger.info("Entering participate method") ready = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, "finish-reading")) ) stimulus = self.driver.find_elem...
python
def participate(self): """Finish reading and send text""" try: logger.info("Entering participate method") ready = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, "finish-reading")) ) stimulus = self.driver.find_elem...
[ "def", "participate", "(", "self", ")", ":", "try", ":", "logger", ".", "info", "(", "\"Entering participate method\"", ")", "ready", "=", "WebDriverWait", "(", "self", ".", "driver", ",", "10", ")", ".", "until", "(", "EC", ".", "element_to_be_clickable", ...
Finish reading and send text
[ "Finish", "reading", "and", "send", "text" ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/bartlett1932/experiment.py#L84-L111
Dallinger/Dallinger
dallinger/nodes.py
Source.create_information
def create_information(self): """Create new infos on demand.""" info = self._info_type()(origin=self, contents=self._contents()) return info
python
def create_information(self): """Create new infos on demand.""" info = self._info_type()(origin=self, contents=self._contents()) return info
[ "def", "create_information", "(", "self", ")", ":", "info", "=", "self", ".", "_info_type", "(", ")", "(", "origin", "=", "self", ",", "contents", "=", "self", ".", "_contents", "(", ")", ")", "return", "info" ]
Create new infos on demand.
[ "Create", "new", "infos", "on", "demand", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/nodes.py#L63-L66
Dallinger/Dallinger
demos/dlgr/demos/iterated_drawing/experiment.py
IteratedDrawing.setup
def setup(self): """Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network. ""...
python
def setup(self): """Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network. ""...
[ "def", "setup", "(", "self", ")", ":", "if", "not", "self", ".", "networks", "(", ")", ":", "super", "(", "IteratedDrawing", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "self", ".", "networks", "(", ")", ":", "self", ".", "model...
Setup the networks. Setup only does stuff if there are no networks, this is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in dallinger). Then it adds a source to each network.
[ "Setup", "the", "networks", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/iterated_drawing/experiment.py#L28-L39
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.setup
def setup(self): """First time setup.""" super(RogersExperiment, self).setup() for net in random.sample(self.networks(role="experiment"), self.catch_repeats): net.role = "catch" for net in self.networks(): source = self.models.RogersSource(network=net) ...
python
def setup(self): """First time setup.""" super(RogersExperiment, self).setup() for net in random.sample(self.networks(role="experiment"), self.catch_repeats): net.role = "catch" for net in self.networks(): source = self.models.RogersSource(network=net) ...
[ "def", "setup", "(", "self", ")", ":", "super", "(", "RogersExperiment", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "random", ".", "sample", "(", "self", ".", "networks", "(", "role", "=", "\"experiment\"", ")", ",", "self", ".", ...
First time setup.
[ "First", "time", "setup", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L82-L95
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.create_network
def create_network(self): """Create a new network.""" return DiscreteGenerational( generations=self.generations, generation_size=self.generation_size, initial_source=True, )
python
def create_network(self): """Create a new network.""" return DiscreteGenerational( generations=self.generations, generation_size=self.generation_size, initial_source=True, )
[ "def", "create_network", "(", "self", ")", ":", "return", "DiscreteGenerational", "(", "generations", "=", "self", ".", "generations", ",", "generation_size", "=", "self", ".", "generation_size", ",", "initial_source", "=", "True", ",", ")" ]
Create a new network.
[ "Create", "a", "new", "network", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L105-L111
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.create_node
def create_node(self, network, participant): """Make a new node for participants.""" return self.models.RogersAgent(network=network, participant=participant)
python
def create_node(self, network, participant): """Make a new node for participants.""" return self.models.RogersAgent(network=network, participant=participant)
[ "def", "create_node", "(", "self", ",", "network", ",", "participant", ")", ":", "return", "self", ".", "models", ".", "RogersAgent", "(", "network", "=", "network", ",", "participant", "=", "participant", ")" ]
Make a new node for participants.
[ "Make", "a", "new", "node", "for", "participants", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L113-L115
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.submission_successful
def submission_successful(self, participant): """Run when a participant submits successfully.""" num_approved = len(Participant.query.filter_by(status="approved").all()) current_generation = participant.nodes()[0].generation if ( num_approved % self.generation_size == 0 ...
python
def submission_successful(self, participant): """Run when a participant submits successfully.""" num_approved = len(Participant.query.filter_by(status="approved").all()) current_generation = participant.nodes()[0].generation if ( num_approved % self.generation_size == 0 ...
[ "def", "submission_successful", "(", "self", ",", "participant", ")", ":", "num_approved", "=", "len", "(", "Participant", ".", "query", ".", "filter_by", "(", "status", "=", "\"approved\"", ")", ".", "all", "(", ")", ")", "current_generation", "=", "partici...
Run when a participant submits successfully.
[ "Run", "when", "a", "participant", "submits", "successfully", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L121-L130
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.recruit
def recruit(self): """Recruit participants if necessary.""" num_approved = len(Participant.query.filter_by(status="approved").all()) end_of_generation = num_approved % self.generation_size == 0 complete = num_approved >= (self.generations * self.generation_size) if complete: ...
python
def recruit(self): """Recruit participants if necessary.""" num_approved = len(Participant.query.filter_by(status="approved").all()) end_of_generation = num_approved % self.generation_size == 0 complete = num_approved >= (self.generations * self.generation_size) if complete: ...
[ "def", "recruit", "(", "self", ")", ":", "num_approved", "=", "len", "(", "Participant", ".", "query", ".", "filter_by", "(", "status", "=", "\"approved\"", ")", ".", "all", "(", ")", ")", "end_of_generation", "=", "num_approved", "%", "self", ".", "gene...
Recruit participants if necessary.
[ "Recruit", "participants", "if", "necessary", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L132-L142
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.bonus
def bonus(self, participant): """Calculate a participants bonus.""" scores = [ n.score for n in participant.nodes() if n.network.role == "experiment" ] average = float(sum(scores)) / float(len(scores)) bonus = round(max(0.0, ((average - 0.5) * 2)) * self.bonus_paymen...
python
def bonus(self, participant): """Calculate a participants bonus.""" scores = [ n.score for n in participant.nodes() if n.network.role == "experiment" ] average = float(sum(scores)) / float(len(scores)) bonus = round(max(0.0, ((average - 0.5) * 2)) * self.bonus_paymen...
[ "def", "bonus", "(", "self", ",", "participant", ")", ":", "scores", "=", "[", "n", ".", "score", "for", "n", "in", "participant", ".", "nodes", "(", ")", "if", "n", ".", "network", ".", "role", "==", "\"experiment\"", "]", "average", "=", "float", ...
Calculate a participants bonus.
[ "Calculate", "a", "participants", "bonus", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L144-L152
Dallinger/Dallinger
demos/dlgr/demos/rogers/experiment.py
RogersExperiment.attention_check
def attention_check(self, participant=None): """Check a participant paid attention.""" if self.catch_repeats == 0: return True scores = [n.score for n in participant.nodes() if n.network.role == "catch"] avg = float(sum(scores)) / float(len(scores)) return avg >= sel...
python
def attention_check(self, participant=None): """Check a participant paid attention.""" if self.catch_repeats == 0: return True scores = [n.score for n in participant.nodes() if n.network.role == "catch"] avg = float(sum(scores)) / float(len(scores)) return avg >= sel...
[ "def", "attention_check", "(", "self", ",", "participant", "=", "None", ")", ":", "if", "self", ".", "catch_repeats", "==", "0", ":", "return", "True", "scores", "=", "[", "n", ".", "score", "for", "n", "in", "participant", ".", "nodes", "(", ")", "i...
Check a participant paid attention.
[ "Check", "a", "participant", "paid", "attention", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/rogers/experiment.py#L154-L161
Dallinger/Dallinger
dallinger/deployment.py
size_on_copy
def size_on_copy(root="."): """Return the size of the experiment directory in bytes, excluding any files and directories which would be excluded on copy. """ total_size = 0 exclusions = exclusion_policy() for dirpath, dirnames, filenames in os.walk(root, topdown=True): current_exclusions...
python
def size_on_copy(root="."): """Return the size of the experiment directory in bytes, excluding any files and directories which would be excluded on copy. """ total_size = 0 exclusions = exclusion_policy() for dirpath, dirnames, filenames in os.walk(root, topdown=True): current_exclusions...
[ "def", "size_on_copy", "(", "root", "=", "\".\"", ")", ":", "total_size", "=", "0", "exclusions", "=", "exclusion_policy", "(", ")", "for", "dirpath", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "root", ",", "topdown", "=", "True", ...
Return the size of the experiment directory in bytes, excluding any files and directories which would be excluded on copy.
[ "Return", "the", "size", "of", "the", "experiment", "directory", "in", "bytes", "excluding", "any", "files", "and", "directories", "which", "would", "be", "excluded", "on", "copy", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L97-L113
Dallinger/Dallinger
dallinger/deployment.py
assemble_experiment_temp_dir
def assemble_experiment_temp_dir(config): """Create a temp directory from which to run an experiment. The new directory will include: - Copies of custom experiment files which don't match the exclusion policy - Templates and static resources from Dallinger - An export of the loaded configuration ...
python
def assemble_experiment_temp_dir(config): """Create a temp directory from which to run an experiment. The new directory will include: - Copies of custom experiment files which don't match the exclusion policy - Templates and static resources from Dallinger - An export of the loaded configuration ...
[ "def", "assemble_experiment_temp_dir", "(", "config", ")", ":", "app_id", "=", "config", ".", "get", "(", "\"id\"", ")", "dst", "=", "os", ".", "path", ".", "join", "(", "tempfile", ".", "mkdtemp", "(", ")", ",", "app_id", ")", "# Copy local experiment fil...
Create a temp directory from which to run an experiment. The new directory will include: - Copies of custom experiment files which don't match the exclusion policy - Templates and static resources from Dallinger - An export of the loaded configuration - Heroku-specific files (Procile, runtime.txt) f...
[ "Create", "a", "temp", "directory", "from", "which", "to", "run", "an", "experiment", ".", "The", "new", "directory", "will", "include", ":", "-", "Copies", "of", "custom", "experiment", "files", "which", "don", "t", "match", "the", "exclusion", "policy", ...
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L116-L186
Dallinger/Dallinger
dallinger/deployment.py
setup_experiment
def setup_experiment(log, debug=True, verbose=False, app=None, exp_config=None): """Checks the experiment's python dependencies, then prepares a temp directory with files merged from the custom experiment and Dallinger. The resulting directory includes all the files necessary to deploy to Heroku. "...
python
def setup_experiment(log, debug=True, verbose=False, app=None, exp_config=None): """Checks the experiment's python dependencies, then prepares a temp directory with files merged from the custom experiment and Dallinger. The resulting directory includes all the files necessary to deploy to Heroku. "...
[ "def", "setup_experiment", "(", "log", ",", "debug", "=", "True", ",", "verbose", "=", "False", ",", "app", "=", "None", ",", "exp_config", "=", "None", ")", ":", "# Verify that the Postgres server is running.", "try", ":", "db", ".", "check_connection", "(", ...
Checks the experiment's python dependencies, then prepares a temp directory with files merged from the custom experiment and Dallinger. The resulting directory includes all the files necessary to deploy to Heroku.
[ "Checks", "the", "experiment", "s", "python", "dependencies", "then", "prepares", "a", "temp", "directory", "with", "files", "merged", "from", "the", "custom", "experiment", "and", "Dallinger", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L189-L241
Dallinger/Dallinger
dallinger/deployment.py
deploy_sandbox_shared_setup
def deploy_sandbox_shared_setup(log, verbose=True, app=None, exp_config=None): """Set up Git, push to Heroku, and launch the app.""" if verbose: out = None else: out = open(os.devnull, "w") config = get_config() if not config.ready: config.load() heroku.sanity_check(conf...
python
def deploy_sandbox_shared_setup(log, verbose=True, app=None, exp_config=None): """Set up Git, push to Heroku, and launch the app.""" if verbose: out = None else: out = open(os.devnull, "w") config = get_config() if not config.ready: config.load() heroku.sanity_check(conf...
[ "def", "deploy_sandbox_shared_setup", "(", "log", ",", "verbose", "=", "True", ",", "app", "=", "None", ",", "exp_config", "=", "None", ")", ":", "if", "verbose", ":", "out", "=", "None", "else", ":", "out", "=", "open", "(", "os", ".", "devnull", ",...
Set up Git, push to Heroku, and launch the app.
[ "Set", "up", "Git", "push", "to", "Heroku", "and", "launch", "the", "app", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L282-L406
Dallinger/Dallinger
dallinger/deployment.py
HerokuLocalDeployment.run
def run(self): """Set up the environment, get a HerokuLocalWrapper instance, and pass it to the concrete class's execute() method. """ self.configure() self.setup() self.update_dir() db.init_db(drop_all=True) self.out.log("Starting up the server...") ...
python
def run(self): """Set up the environment, get a HerokuLocalWrapper instance, and pass it to the concrete class's execute() method. """ self.configure() self.setup() self.update_dir() db.init_db(drop_all=True) self.out.log("Starting up the server...") ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "configure", "(", ")", "self", ".", "setup", "(", ")", "self", ".", "update_dir", "(", ")", "db", ".", "init_db", "(", "drop_all", "=", "True", ")", "self", ".", "out", ".", "log", "(", "\"Startin...
Set up the environment, get a HerokuLocalWrapper instance, and pass it to the concrete class's execute() method.
[ "Set", "up", "the", "environment", "get", "a", "HerokuLocalWrapper", "instance", "and", "pass", "it", "to", "the", "concrete", "class", "s", "execute", "()", "method", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L445-L462
Dallinger/Dallinger
dallinger/deployment.py
HerokuLocalDeployment.notify
def notify(self, message): """Callback function which checks lines of output, tries to match against regex defined in subclass's "dispatch" dict, and passes through to a handler on match. """ for regex, handler in self.dispatch.items(): match = re.search(regex, messag...
python
def notify(self, message): """Callback function which checks lines of output, tries to match against regex defined in subclass's "dispatch" dict, and passes through to a handler on match. """ for regex, handler in self.dispatch.items(): match = re.search(regex, messag...
[ "def", "notify", "(", "self", ",", "message", ")", ":", "for", "regex", ",", "handler", "in", "self", ".", "dispatch", ".", "items", "(", ")", ":", "match", "=", "re", ".", "search", "(", "regex", ",", "message", ")", "if", "match", ":", "handler",...
Callback function which checks lines of output, tries to match against regex defined in subclass's "dispatch" dict, and passes through to a handler on match.
[ "Callback", "function", "which", "checks", "lines", "of", "output", "tries", "to", "match", "against", "regex", "defined", "in", "subclass", "s", "dispatch", "dict", "and", "passes", "through", "to", "a", "handler", "on", "match", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L464-L473
Dallinger/Dallinger
dallinger/deployment.py
DebugDeployment.new_recruit
def new_recruit(self, match): """Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging). """ self.out.log("new recruitment request!") url = match.group(1) ...
python
def new_recruit(self, match): """Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging). """ self.out.log("new recruitment request!") url = match.group(1) ...
[ "def", "new_recruit", "(", "self", ",", "match", ")", ":", "self", ".", "out", ".", "log", "(", "\"new recruitment request!\"", ")", "url", "=", "match", ".", "group", "(", "1", ")", "if", "self", ".", "proxy_port", "is", "not", "None", ":", "self", ...
Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging).
[ "Dispatched", "to", "by", "notify", "()", ".", "If", "a", "recruitment", "request", "has", "been", "issued", "open", "a", "browser", "window", "for", "the", "a", "new", "participant", "(", "in", "this", "case", "the", "person", "doing", "local", "debugging...
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L527-L537
Dallinger/Dallinger
dallinger/deployment.py
DebugDeployment.recruitment_closed
def recruitment_closed(self, match): """Recruitment is closed. Start a thread to check the experiment summary. """ if self.status_thread is None: self.status_thread = threading.Thread(target=self.check_status) self.status_thread.start()
python
def recruitment_closed(self, match): """Recruitment is closed. Start a thread to check the experiment summary. """ if self.status_thread is None: self.status_thread = threading.Thread(target=self.check_status) self.status_thread.start()
[ "def", "recruitment_closed", "(", "self", ",", "match", ")", ":", "if", "self", ".", "status_thread", "is", "None", ":", "self", ".", "status_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "check_status", ")", "self", ".", "st...
Recruitment is closed. Start a thread to check the experiment summary.
[ "Recruitment", "is", "closed", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L539-L546
Dallinger/Dallinger
dallinger/deployment.py
DebugDeployment.check_status
def check_status(self): """Check the output of the summary route until the experiment is complete, then we can stop monitoring Heroku subprocess output. """ self.out.log("Recruitment is complete. Waiting for experiment completion...") base_url = get_base_url() sta...
python
def check_status(self): """Check the output of the summary route until the experiment is complete, then we can stop monitoring Heroku subprocess output. """ self.out.log("Recruitment is complete. Waiting for experiment completion...") base_url = get_base_url() sta...
[ "def", "check_status", "(", "self", ")", ":", "self", ".", "out", ".", "log", "(", "\"Recruitment is complete. Waiting for experiment completion...\"", ")", "base_url", "=", "get_base_url", "(", ")", "status_url", "=", "base_url", "+", "\"/summary\"", "while", "not"...
Check the output of the summary route until the experiment is complete, then we can stop monitoring Heroku subprocess output.
[ "Check", "the", "output", "of", "the", "summary", "route", "until", "the", "experiment", "is", "complete", "then", "we", "can", "stop", "monitoring", "Heroku", "subprocess", "output", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L548-L568
Dallinger/Dallinger
dallinger/deployment.py
DebugDeployment.notify
def notify(self, message): """Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete. """ if self.complete: return HerokuLocalWrappe...
python
def notify(self, message): """Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete. """ if self.complete: return HerokuLocalWrappe...
[ "def", "notify", "(", "self", ",", "message", ")", ":", "if", "self", ".", "complete", ":", "return", "HerokuLocalWrapper", ".", "MONITOR_STOP", "return", "super", "(", "DebugDeployment", ",", "self", ")", ".", "notify", "(", "message", ")" ]
Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete.
[ "Monitor", "output", "from", "heroku", "process", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L570-L579
Dallinger/Dallinger
dallinger/deployment.py
LoaderDeployment.execute
def execute(self, heroku): """Start the server, load the zip file into the database, then loop until terminated with <control>-c. """ db.init_db(drop_all=True) self.out.log( "Ingesting dataset from {}...".format(os.path.basename(self.zip_path)) ) data....
python
def execute(self, heroku): """Start the server, load the zip file into the database, then loop until terminated with <control>-c. """ db.init_db(drop_all=True) self.out.log( "Ingesting dataset from {}...".format(os.path.basename(self.zip_path)) ) data....
[ "def", "execute", "(", "self", ",", "heroku", ")", ":", "db", ".", "init_db", "(", "drop_all", "=", "True", ")", "self", ".", "out", ".", "log", "(", "\"Ingesting dataset from {}...\"", ".", "format", "(", "os", ".", "path", ".", "basename", "(", "self...
Start the server, load the zip file into the database, then loop until terminated with <control>-c.
[ "Start", "the", "server", "load", "the", "zip", "file", "into", "the", "database", "then", "loop", "until", "terminated", "with", "<control", ">", "-", "c", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L606-L626
Dallinger/Dallinger
dallinger/deployment.py
LoaderDeployment.start_replay
def start_replay(self, match): """Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging). """ self.out.log("replay ready!") url = match.group(1) new_webbr...
python
def start_replay(self, match): """Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging). """ self.out.log("replay ready!") url = match.group(1) new_webbr...
[ "def", "start_replay", "(", "self", ",", "match", ")", ":", "self", ".", "out", ".", "log", "(", "\"replay ready!\"", ")", "url", "=", "match", ".", "group", "(", "1", ")", "new_webbrowser_profile", "(", ")", ".", "open", "(", "url", ",", "new", "=",...
Dispatched to by notify(). If a recruitment request has been issued, open a browser window for the a new participant (in this case the person doing local debugging).
[ "Dispatched", "to", "by", "notify", "()", ".", "If", "a", "recruitment", "request", "has", "been", "issued", "open", "a", "browser", "window", "for", "the", "a", "new", "participant", "(", "in", "this", "case", "the", "person", "doing", "local", "debugging...
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L628-L635
Dallinger/Dallinger
dallinger/experiment_server/gunicorn.py
StandaloneServer.load
def load(self): """Return our application to be run.""" app = util.import_app("dallinger.experiment_server.sockets:app") if self.options.get("mode") == "debug": app.debug = True return app
python
def load(self): """Return our application to be run.""" app = util.import_app("dallinger.experiment_server.sockets:app") if self.options.get("mode") == "debug": app.debug = True return app
[ "def", "load", "(", "self", ")", ":", "app", "=", "util", ".", "import_app", "(", "\"dallinger.experiment_server.sockets:app\"", ")", "if", "self", ".", "options", ".", "get", "(", "\"mode\"", ")", "==", "\"debug\"", ":", "app", ".", "debug", "=", "True", ...
Return our application to be run.
[ "Return", "our", "application", "to", "be", "run", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/gunicorn.py#L52-L57
Dallinger/Dallinger
demos/dlgr/demos/mcmcp/models.py
AnimalInfo.perturbed_contents
def perturbed_contents(self): """Perturb the given animal.""" animal = json.loads(self.contents) for prop, prop_range in self.properties.items(): range = prop_range[1] - prop_range[0] jittered = animal[prop] + random.gauss(0, 0.1 * range) animal[prop] = max(m...
python
def perturbed_contents(self): """Perturb the given animal.""" animal = json.loads(self.contents) for prop, prop_range in self.properties.items(): range = prop_range[1] - prop_range[0] jittered = animal[prop] + random.gauss(0, 0.1 * range) animal[prop] = max(m...
[ "def", "perturbed_contents", "(", "self", ")", ":", "animal", "=", "json", ".", "loads", "(", "self", ".", "contents", ")", "for", "prop", ",", "prop_range", "in", "self", ".", "properties", ".", "items", "(", ")", ":", "range", "=", "prop_range", "[",...
Perturb the given animal.
[ "Perturb", "the", "given", "animal", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/mcmcp/models.py#L94-L103
Dallinger/Dallinger
dallinger/networks.py
DelayedChain.add_node
def add_node(self, node): """Add an agent, connecting it to the previous node.""" other_nodes = [n for n in self.nodes() if n.id != node.id] if len(self.nodes()) > 11: parents = [max(other_nodes, key=attrgetter("creation_time"))] else: parents = [n for n in other_...
python
def add_node(self, node): """Add an agent, connecting it to the previous node.""" other_nodes = [n for n in self.nodes() if n.id != node.id] if len(self.nodes()) > 11: parents = [max(other_nodes, key=attrgetter("creation_time"))] else: parents = [n for n in other_...
[ "def", "add_node", "(", "self", ",", "node", ")", ":", "other_nodes", "=", "[", "n", "for", "n", "in", "self", ".", "nodes", "(", ")", "if", "n", ".", "id", "!=", "node", ".", "id", "]", "if", "len", "(", "self", ".", "nodes", "(", ")", ")", ...
Add an agent, connecting it to the previous node.
[ "Add", "an", "agent", "connecting", "it", "to", "the", "previous", "node", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/networks.py#L23-L32
Dallinger/Dallinger
dallinger/networks.py
FullyConnected.add_node
def add_node(self, node): """Add a node, connecting it to everyone and back.""" other_nodes = [n for n in self.nodes() if n.id != node.id] for n in other_nodes: if isinstance(n, Source): node.connect(direction="from", whom=n) else: node.co...
python
def add_node(self, node): """Add a node, connecting it to everyone and back.""" other_nodes = [n for n in self.nodes() if n.id != node.id] for n in other_nodes: if isinstance(n, Source): node.connect(direction="from", whom=n) else: node.co...
[ "def", "add_node", "(", "self", ",", "node", ")", ":", "other_nodes", "=", "[", "n", "for", "n", "in", "self", ".", "nodes", "(", ")", "if", "n", ".", "id", "!=", "node", ".", "id", "]", "for", "n", "in", "other_nodes", ":", "if", "isinstance", ...
Add a node, connecting it to everyone and back.
[ "Add", "a", "node", "connecting", "it", "to", "everyone", "and", "back", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/networks.py#L60-L68
Dallinger/Dallinger
dallinger/networks.py
Empty.add_source
def add_source(self, source): """Connect the source to all existing other nodes.""" nodes = [n for n in self.nodes() if not isinstance(n, Source)] source.connect(whom=nodes)
python
def add_source(self, source): """Connect the source to all existing other nodes.""" nodes = [n for n in self.nodes() if not isinstance(n, Source)] source.connect(whom=nodes)
[ "def", "add_source", "(", "self", ",", "source", ")", ":", "nodes", "=", "[", "n", "for", "n", "in", "self", ".", "nodes", "(", ")", "if", "not", "isinstance", "(", "n", ",", "Source", ")", "]", "source", ".", "connect", "(", "whom", "=", "nodes"...
Connect the source to all existing other nodes.
[ "Connect", "the", "source", "to", "all", "existing", "other", "nodes", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/networks.py#L80-L83
Dallinger/Dallinger
dallinger/networks.py
Star.add_node
def add_node(self, node): """Add a node and connect it to the center.""" nodes = self.nodes() if len(nodes) > 1: first_node = min(nodes, key=attrgetter("creation_time")) first_node.connect(direction="both", whom=node)
python
def add_node(self, node): """Add a node and connect it to the center.""" nodes = self.nodes() if len(nodes) > 1: first_node = min(nodes, key=attrgetter("creation_time")) first_node.connect(direction="both", whom=node)
[ "def", "add_node", "(", "self", ",", "node", ")", ":", "nodes", "=", "self", ".", "nodes", "(", ")", "if", "len", "(", "nodes", ")", ">", "1", ":", "first_node", "=", "min", "(", "nodes", ",", "key", "=", "attrgetter", "(", "\"creation_time\"", ")"...
Add a node and connect it to the center.
[ "Add", "a", "node", "and", "connect", "it", "to", "the", "center", "." ]
train
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/networks.py#L95-L101