id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
250,400 | abe-winter/pg13-py | pg13/pg.py | Row.updatewhere | def updatewhere(clas,pool_or_cursor,where_keys,**update_keys):
"this doesn't allow raw_keys for now"
# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?
if not where_keys or not update_keys: raise ValueError
setclause=','.join(k+'=%s' ... | python | def updatewhere(clas,pool_or_cursor,where_keys,**update_keys):
"this doesn't allow raw_keys for now"
# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?
if not where_keys or not update_keys: raise ValueError
setclause=','.join(k+'=%s' ... | [
"def",
"updatewhere",
"(",
"clas",
",",
"pool_or_cursor",
",",
"where_keys",
",",
"*",
"*",
"update_keys",
")",
":",
"# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?\r",
"if",
"not",
"where_keys",
"or",
"not",... | this doesn't allow raw_keys for now | [
"this",
"doesn",
"t",
"allow",
"raw_keys",
"for",
"now"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L277-L285 |
250,401 | ulf1/oxyba | oxyba/clean_to_decimal.py | clean_to_decimal | def clean_to_decimal(x, prec=28):
"""Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
... | python | def clean_to_decimal(x, prec=28):
"""Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
... | [
"def",
"clean_to_decimal",
"(",
"x",
",",
"prec",
"=",
"28",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"import",
"decimal",
"def",
"proc_elem",
"(",
"e",
")",
":",
"try",
":",
"return",
"decimal",
".",
"Decimal",
"(",
"... | Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
Set the getcontext precision
Return... | [
"Convert",
"an",
"string",
"int",
"or",
"float",
"to",
"Decimal",
"object"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_to_decimal.py#L2-L69 |
250,402 | minhhoit/yacms | yacms/generic/templatetags/rating_tags.py | rating_for | def rating_for(context, obj):
"""
Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form.
"""
context["rating_object"] = context["rating_obj"] = obj
context["rating_form"] = RatingForm(context["request"], obj)
ratings = context["reque... | python | def rating_for(context, obj):
"""
Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form.
"""
context["rating_object"] = context["rating_obj"] = obj
context["rating_form"] = RatingForm(context["request"], obj)
ratings = context["reque... | [
"def",
"rating_for",
"(",
"context",
",",
"obj",
")",
":",
"context",
"[",
"\"rating_object\"",
"]",
"=",
"context",
"[",
"\"rating_obj\"",
"]",
"=",
"obj",
"context",
"[",
"\"rating_form\"",
"]",
"=",
"RatingForm",
"(",
"context",
"[",
"\"request\"",
"]",
... | Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form. | [
"Provides",
"a",
"generic",
"context",
"variable",
"name",
"for",
"the",
"object",
"that",
"ratings",
"are",
"being",
"rendered",
"for",
"and",
"the",
"rating",
"form",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/rating_tags.py#L11-L24 |
250,403 | jldantas/libmft | libmft/attribute.py | get_attr_info | def get_attr_info(binary_view):
'''Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearr... | python | def get_attr_info(binary_view):
'''Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearr... | [
"def",
"get_attr_info",
"(",
"binary_view",
")",
":",
"global",
"_ATTR_BASIC",
"attr_type",
",",
"attr_len",
",",
"non_resident",
"=",
"_ATTR_BASIC",
".",
"unpack",
"(",
"binary_view",
"[",
":",
"9",
"]",
")",
"return",
"(",
"AttrTypes",
"(",
"attr_type",
")... | Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"Gets",
"basic",
"information",
"from",
"a",
"binary",
"stream",
"to",
"allow",
"correct",
"processing",
"of",
"the",
"attribute",
"header",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L59-L78 |
250,404 | jldantas/libmft | libmft/attribute.py | _create_attrcontent_class | def _create_attrcontent_class(name, fields, inheritance=(object,), data_structure=None, extra_functions=None, docstring=""):
'''Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in ... | python | def _create_attrcontent_class(name, fields, inheritance=(object,), data_structure=None, extra_functions=None, docstring=""):
'''Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in ... | [
"def",
"_create_attrcontent_class",
"(",
"name",
",",
"fields",
",",
"inheritance",
"=",
"(",
"object",
",",
")",
",",
"data_structure",
"=",
"None",
",",
"extra_functions",
"=",
"None",
",",
"docstring",
"=",
"\"\"",
")",
":",
"def",
"create_func_from_str",
... | Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in the same way for all classes.
Once it executes it defines a dynamic class with the methods "__init__",
"__repr__" and "__eq... | [
"Helper",
"function",
"that",
"creates",
"a",
"class",
"for",
"attribute",
"contents",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L80-L210 |
250,405 | jldantas/libmft | libmft/attribute.py | _astimezone_ts | def _astimezone_ts(self, timezone):
"""Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise return... | python | def _astimezone_ts(self, timezone):
"""Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise return... | [
"def",
"_astimezone_ts",
"(",
"self",
",",
"timezone",
")",
":",
"if",
"self",
".",
"created",
".",
"tzinfo",
"is",
"timezone",
":",
"return",
"self",
"else",
":",
"nw_obj",
"=",
"Timestamps",
"(",
"(",
"None",
",",
")",
"*",
"4",
")",
"nw_obj",
".",... | Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise returns ``self``. | [
"Changes",
"the",
"time",
"zones",
"of",
"all",
"timestamps",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L695-L715 |
250,406 | jldantas/libmft | libmft/attribute.py | _len_objid | def _len_objid(self):
'''Get the actual size of the content, as some attributes have variable sizes'''
try:
return self._size
except AttributeError:
temp = (self.object_id, self.birth_vol_id, self.birth_object_id, self.birth_domain_id)
self._size = sum([ObjectID._UUID_SIZE for data i... | python | def _len_objid(self):
'''Get the actual size of the content, as some attributes have variable sizes'''
try:
return self._size
except AttributeError:
temp = (self.object_id, self.birth_vol_id, self.birth_object_id, self.birth_domain_id)
self._size = sum([ObjectID._UUID_SIZE for data i... | [
"def",
"_len_objid",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_size",
"except",
"AttributeError",
":",
"temp",
"=",
"(",
"self",
".",
"object_id",
",",
"self",
".",
"birth_vol_id",
",",
"self",
".",
"birth_object_id",
",",
"self",
".",
... | Get the actual size of the content, as some attributes have variable sizes | [
"Get",
"the",
"actual",
"size",
"of",
"the",
"content",
"as",
"some",
"attributes",
"have",
"variable",
"sizes"
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L978-L985 |
250,407 | jldantas/libmft | libmft/attribute.py | _allocated_entries_bitmap | def _allocated_entries_bitmap(self):
'''Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries.
'''
for entry_number in range(len(self._bitmap) * 8):
if self.entry_allocated(entry_number):
yield entry_nu... | python | def _allocated_entries_bitmap(self):
'''Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries.
'''
for entry_number in range(len(self._bitmap) * 8):
if self.entry_allocated(entry_number):
yield entry_nu... | [
"def",
"_allocated_entries_bitmap",
"(",
"self",
")",
":",
"for",
"entry_number",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_bitmap",
")",
"*",
"8",
")",
":",
"if",
"self",
".",
"entry_allocated",
"(",
"entry_number",
")",
":",
"yield",
"entry_number"
... | Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries. | [
"Creates",
"a",
"generator",
"that",
"returns",
"all",
"allocated",
"entries",
"in",
"the",
"bitmap",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1427-L1437 |
250,408 | jldantas/libmft | libmft/attribute.py | _entry_allocated_bitmap | def _entry_allocated_bitmap(self, entry_number):
"""Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise.
"""
index, offset = divmod(entry_number, 8)
return bool(self._bitmap[index] & (1 << ... | python | def _entry_allocated_bitmap(self, entry_number):
"""Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise.
"""
index, offset = divmod(entry_number, 8)
return bool(self._bitmap[index] & (1 << ... | [
"def",
"_entry_allocated_bitmap",
"(",
"self",
",",
"entry_number",
")",
":",
"index",
",",
"offset",
"=",
"divmod",
"(",
"entry_number",
",",
"8",
")",
"return",
"bool",
"(",
"self",
".",
"_bitmap",
"[",
"index",
"]",
"&",
"(",
"1",
"<<",
"offset",
")... | Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise. | [
"Checks",
"if",
"a",
"particular",
"index",
"is",
"allocated",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1439-L1449 |
250,409 | jldantas/libmft | libmft/attribute.py | _get_next_empty_bitmap | def _get_next_empty_bitmap(self):
"""Returns the next empty entry.
Returns:
int: The value of the empty entry
"""
#TODO probably not the best way, redo
for i, byte in enumerate(self._bitmap):
if byte != 255:
for offset in range(8):
if not byte & (1 << off... | python | def _get_next_empty_bitmap(self):
"""Returns the next empty entry.
Returns:
int: The value of the empty entry
"""
#TODO probably not the best way, redo
for i, byte in enumerate(self._bitmap):
if byte != 255:
for offset in range(8):
if not byte & (1 << off... | [
"def",
"_get_next_empty_bitmap",
"(",
"self",
")",
":",
"#TODO probably not the best way, redo",
"for",
"i",
",",
"byte",
"in",
"enumerate",
"(",
"self",
".",
"_bitmap",
")",
":",
"if",
"byte",
"!=",
"255",
":",
"for",
"offset",
"in",
"range",
"(",
"8",
")... | Returns the next empty entry.
Returns:
int: The value of the empty entry | [
"Returns",
"the",
"next",
"empty",
"entry",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1451-L1462 |
250,410 | jldantas/libmft | libmft/attribute.py | _len_ea_entry | def _len_ea_entry(self):
'''Returns the size of the entry'''
return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len | python | def _len_ea_entry(self):
'''Returns the size of the entry'''
return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len | [
"def",
"_len_ea_entry",
"(",
"self",
")",
":",
"return",
"EaEntry",
".",
"_REPR",
".",
"size",
"+",
"len",
"(",
"self",
".",
"name",
".",
"encode",
"(",
"\"ascii\"",
")",
")",
"+",
"self",
".",
"value_len"
] | Returns the size of the entry | [
"Returns",
"the",
"size",
"of",
"the",
"entry"
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1750-L1752 |
250,411 | jldantas/libmft | libmft/attribute.py | _str_sid | def _str_sid(self):
'Return a nicely formatted representation string'
sub_auths = "-".join([str(sub) for sub in self.sub_authorities])
return f'S-{self.revision_number}-{self.authority}-{sub_auths}' | python | def _str_sid(self):
'Return a nicely formatted representation string'
sub_auths = "-".join([str(sub) for sub in self.sub_authorities])
return f'S-{self.revision_number}-{self.authority}-{sub_auths}' | [
"def",
"_str_sid",
"(",
"self",
")",
":",
"sub_auths",
"=",
"\"-\"",
".",
"join",
"(",
"[",
"str",
"(",
"sub",
")",
"for",
"sub",
"in",
"self",
".",
"sub_authorities",
"]",
")",
"return",
"f'S-{self.revision_number}-{self.authority}-{sub_auths}'"
] | Return a nicely formatted representation string | [
"Return",
"a",
"nicely",
"formatted",
"representation",
"string"
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1982-L1985 |
250,412 | jldantas/libmft | libmft/attribute.py | _len_sec_desc | def _len_sec_desc(self):
'''Returns the logical size of the file'''
return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl) | python | def _len_sec_desc(self):
'''Returns the logical size of the file'''
return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl) | [
"def",
"_len_sec_desc",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"header",
")",
"+",
"len",
"(",
"self",
".",
"owner_sid",
")",
"+",
"len",
"(",
"self",
".",
"group_sid",
")",
"+",
"len",
"(",
"self",
".",
"sacl",
")",
"+",
"len"... | Returns the logical size of the file | [
"Returns",
"the",
"logical",
"size",
"of",
"the",
"file"
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2269-L2271 |
250,413 | jldantas/libmft | libmft/attribute.py | DataRuns.create_from_binary | def create_from_binary(cls, binary_view):
'''Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | python | def create_from_binary(cls, binary_view):
'''Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"binary_view",
")",
":",
"nw_obj",
"=",
"cls",
"(",
")",
"offset",
"=",
"0",
"previous_dr_offset",
"=",
"0",
"header_size",
"=",
"cls",
".",
"_INFO",
".",
"size",
"#\"header\" of a data run is always a byte",
"while"... | Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
information of the attribute
Returns... | [
"Creates",
"a",
"new",
"object",
"DataRuns",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L276-L311 |
250,414 | jldantas/libmft | libmft/attribute.py | ResidentAttrHeader.create_from_binary | def create_from_binary(cls, binary_view):
'''Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | python | def create_from_binary(cls, binary_view):
'''Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"binary_view",
")",
":",
"attr_type",
",",
"attr_len",
",",
"non_resident",
",",
"name_len",
",",
"name_offset",
",",
"flags",
",",
"attr_id",
",",
"content_len",
",",
"content_offset",
",",
"indexed_flag",
"=",
"c... | Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
information of the attribute
... | [
"Creates",
"a",
"new",
"object",
"AttributeHeader",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L470-L493 |
250,415 | jldantas/libmft | libmft/attribute.py | NonResidentAttrHeader.create_from_binary | def create_from_binary(cls, load_dataruns, binary_view):
'''Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the datar... | python | def create_from_binary(cls, load_dataruns, binary_view):
'''Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the datar... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"load_dataruns",
",",
"binary_view",
")",
":",
"attr_type",
",",
"attr_len",
",",
"non_resident",
",",
"name_len",
",",
"name_offset",
",",
"flags",
",",
"attr_id",
",",
"start_vcn",
",",
"end_vcn",
",",
"rl_offset... | Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the dataruns are to be loaded
binary_view (memoryview of bytearra... | [
"Creates",
"a",
"new",
"object",
"NonResidentAttrHeader",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L561-L593 |
250,416 | openbermuda/ripl | ripl/slide2png.py | Slide2png.write_slide_list | def write_slide_list(self, logname, slides):
""" Write list of slides to logfile """
# Write slides.txt with list of slides
with open('%s/%s' % (self.cache, logname), 'w') as logfile:
for slide in slides:
heading = slide['heading']['text']
filename = s... | python | def write_slide_list(self, logname, slides):
""" Write list of slides to logfile """
# Write slides.txt with list of slides
with open('%s/%s' % (self.cache, logname), 'w') as logfile:
for slide in slides:
heading = slide['heading']['text']
filename = s... | [
"def",
"write_slide_list",
"(",
"self",
",",
"logname",
",",
"slides",
")",
":",
"# Write slides.txt with list of slides",
"with",
"open",
"(",
"'%s/%s'",
"%",
"(",
"self",
".",
"cache",
",",
"logname",
")",
",",
"'w'",
")",
"as",
"logfile",
":",
"for",
"s... | Write list of slides to logfile | [
"Write",
"list",
"of",
"slides",
"to",
"logfile"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L58-L67 |
250,417 | openbermuda/ripl | ripl/slide2png.py | Slide2png.rotate | def rotate(self, img):
""" Rotate image if exif says it needs it """
try:
exif = image2exif.get_exif(img)
except AttributeError:
# image format doesn't support exif
return img
orientation = exif.get('Orientation', 1)
landscape = img.h... | python | def rotate(self, img):
""" Rotate image if exif says it needs it """
try:
exif = image2exif.get_exif(img)
except AttributeError:
# image format doesn't support exif
return img
orientation = exif.get('Orientation', 1)
landscape = img.h... | [
"def",
"rotate",
"(",
"self",
",",
"img",
")",
":",
"try",
":",
"exif",
"=",
"image2exif",
".",
"get_exif",
"(",
"img",
")",
"except",
"AttributeError",
":",
"# image format doesn't support exif",
"return",
"img",
"orientation",
"=",
"exif",
".",
"get",
"(",... | Rotate image if exif says it needs it | [
"Rotate",
"image",
"if",
"exif",
"says",
"it",
"needs",
"it"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L147-L163 |
250,418 | openbermuda/ripl | ripl/slide2png.py | Slide2png.draw_image | def draw_image(self, image, item, source):
""" Add an image to the image """
top, left = item['top'], item['left']
width, height = item['width'], item['height']
image_file = item['image']
img = Image.open(source)
img = self.rotate(img)
iwidth, iheight = img.siz... | python | def draw_image(self, image, item, source):
""" Add an image to the image """
top, left = item['top'], item['left']
width, height = item['width'], item['height']
image_file = item['image']
img = Image.open(source)
img = self.rotate(img)
iwidth, iheight = img.siz... | [
"def",
"draw_image",
"(",
"self",
",",
"image",
",",
"item",
",",
"source",
")",
":",
"top",
",",
"left",
"=",
"item",
"[",
"'top'",
"]",
",",
"item",
"[",
"'left'",
"]",
"width",
",",
"height",
"=",
"item",
"[",
"'width'",
"]",
",",
"item",
"[",... | Add an image to the image | [
"Add",
"an",
"image",
"to",
"the",
"image"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L166-L198 |
250,419 | openbermuda/ripl | ripl/slide2png.py | Slide2png.slugify | def slugify(self, name):
""" Turn name into a slug suitable for an image file name """
slug = ''
last = ''
for char in name.replace('#', '').lower().strip():
if not char.isalnum():
char = '_'
if last == '_' and char == '_':
continu... | python | def slugify(self, name):
""" Turn name into a slug suitable for an image file name """
slug = ''
last = ''
for char in name.replace('#', '').lower().strip():
if not char.isalnum():
char = '_'
if last == '_' and char == '_':
continu... | [
"def",
"slugify",
"(",
"self",
",",
"name",
")",
":",
"slug",
"=",
"''",
"last",
"=",
"''",
"for",
"char",
"in",
"name",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
":",
"if",
"not",
"char",
"."... | Turn name into a slug suitable for an image file name | [
"Turn",
"name",
"into",
"a",
"slug",
"suitable",
"for",
"an",
"image",
"file",
"name"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L201-L215 |
250,420 | hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.list_keys | def list_keys(self):
"""
Returns list of the available keys
:return: List of the keys available in the storage
:rtype list
"""
return [k for k, el in self._keystore.items() if not el.is_expired] | python | def list_keys(self):
"""
Returns list of the available keys
:return: List of the keys available in the storage
:rtype list
"""
return [k for k, el in self._keystore.items() if not el.is_expired] | [
"def",
"list_keys",
"(",
"self",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"el",
"in",
"self",
".",
"_keystore",
".",
"items",
"(",
")",
"if",
"not",
"el",
".",
"is_expired",
"]"
] | Returns list of the available keys
:return: List of the keys available in the storage
:rtype list | [
"Returns",
"list",
"of",
"the",
"available",
"keys"
] | 5d185616feda27e6e21273307161471ef11a3518 | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L59-L66 |
250,421 | hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.set | def set(self, key, value, expire_in=None):
"""
Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int
"""
if key not in self._keystore:
self._keysto... | python | def set(self, key, value, expire_in=None):
"""
Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int
"""
if key not in self._keystore:
self._keysto... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"expire_in",
"=",
"None",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_keystore",
":",
"self",
".",
"_keystore",
"[",
"key",
"]",
"=",
"InMemoryItemValue",
"(",
"expire_in",
"=",
"expire... | Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int | [
"Function",
"to",
"set",
"or",
"change",
"particular",
"property",
"in",
"the",
"storage"
] | 5d185616feda27e6e21273307161471ef11a3518 | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L68-L84 |
250,422 | hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.get | def get(self, key):
"""
Retrieves previously stored key from the storage
:return value, stored in the storage
"""
if key not in self._keystore:
return None
rec = self._keystore[key]
""":type rec InMemoryItemValue"""
if rec.is_expired:
self.delete(key)
return None
... | python | def get(self, key):
"""
Retrieves previously stored key from the storage
:return value, stored in the storage
"""
if key not in self._keystore:
return None
rec = self._keystore[key]
""":type rec InMemoryItemValue"""
if rec.is_expired:
self.delete(key)
return None
... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_keystore",
":",
"return",
"None",
"rec",
"=",
"self",
".",
"_keystore",
"[",
"key",
"]",
"\"\"\":type rec InMemoryItemValue\"\"\"",
"if",
"rec",
".",
"is_expired",
... | Retrieves previously stored key from the storage
:return value, stored in the storage | [
"Retrieves",
"previously",
"stored",
"key",
"from",
"the",
"storage"
] | 5d185616feda27e6e21273307161471ef11a3518 | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L86-L102 |
250,423 | hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.exists | def exists(self, key):
"""
Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool
"""
if key in self._keystore and not self._keystore[key].is_expired:
return True
elif key in self._ke... | python | def exists(self, key):
"""
Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool
"""
if key in self._keystore and not self._keystore[key].is_expired:
return True
elif key in self._ke... | [
"def",
"exists",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_keystore",
"and",
"not",
"self",
".",
"_keystore",
"[",
"key",
"]",
".",
"is_expired",
":",
"return",
"True",
"elif",
"key",
"in",
"self",
".",
"_keystore",
"and",
... | Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool | [
"Check",
"if",
"the",
"particular",
"key",
"exists",
"in",
"the",
"storage"
] | 5d185616feda27e6e21273307161471ef11a3518 | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L104-L120 |
250,424 | calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.plot_2d_single | def plot_2d_single(x, y, pdffilename, **kwargs):
"""
Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
... | python | def plot_2d_single(x, y, pdffilename, **kwargs):
"""
Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
... | [
"def",
"plot_2d_single",
"(",
"x",
",",
"y",
",",
"pdffilename",
",",
"*",
"*",
"kwargs",
")",
":",
"pdffilepath",
"=",
"DataSets",
".",
"get_pdffilepath",
"(",
"pdffilename",
")",
"plotsingle2d",
"=",
"PlotSingle2D",
"(",
"x",
",",
"y",
",",
"pdffilepath"... | Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
figure_options: passed to matplotlib.pyplot.figure
... | [
"Do",
"make_2d_single_plot",
"and",
"pass",
"all",
"arguments"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L73-L129 |
250,425 | calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.get_pdffilepath | def get_pdffilepath(pdffilename):
"""
Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf
"""
return FILEPATHSTR.format(
root_dir=ROOT_DIR, os_sep=os.sep, os_extsep=os.extsep,
... | python | def get_pdffilepath(pdffilename):
"""
Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf
"""
return FILEPATHSTR.format(
root_dir=ROOT_DIR, os_sep=os.sep, os_extsep=os.extsep,
... | [
"def",
"get_pdffilepath",
"(",
"pdffilename",
")",
":",
"return",
"FILEPATHSTR",
".",
"format",
"(",
"root_dir",
"=",
"ROOT_DIR",
",",
"os_sep",
"=",
"os",
".",
"sep",
",",
"os_extsep",
"=",
"os",
".",
"extsep",
",",
"name",
"=",
"pdffilename",
",",
"fol... | Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf | [
"Returns",
"the",
"path",
"for",
"the",
"pdf",
"file"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L132-L145 |
250,426 | calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.make_tex_table | def make_tex_table(inputlist, outputfilename, fmt=None, **kwargs):
"""
Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
... | python | def make_tex_table(inputlist, outputfilename, fmt=None, **kwargs):
"""
Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
... | [
"def",
"make_tex_table",
"(",
"inputlist",
",",
"outputfilename",
",",
"fmt",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"outputfilepath",
"=",
"FILEPATHSTR",
".",
"format",
"(",
"root_dir",
"=",
"ROOT_DIR",
",",
"os_sep",
"=",
"os",
".",
"sep",
","... | Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
values: string
format string. eg "{:g}"
**kwarg... | [
"Do",
"make_tex_table",
"and",
"pass",
"all",
"arguments"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L148-L171 |
250,427 | calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.make_compute_file | def make_compute_file(self):
"""
Make the compute file from the self.vardict and self.vardictformat
"""
string = ""
try:
vardict_items = self.vardict.iteritems()
except AttributeError:
vardict_items = self.vardict.items()
for key, val in va... | python | def make_compute_file(self):
"""
Make the compute file from the self.vardict and self.vardictformat
"""
string = ""
try:
vardict_items = self.vardict.iteritems()
except AttributeError:
vardict_items = self.vardict.items()
for key, val in va... | [
"def",
"make_compute_file",
"(",
"self",
")",
":",
"string",
"=",
"\"\"",
"try",
":",
"vardict_items",
"=",
"self",
".",
"vardict",
".",
"iteritems",
"(",
")",
"except",
"AttributeError",
":",
"vardict_items",
"=",
"self",
".",
"vardict",
".",
"items",
"("... | Make the compute file from the self.vardict and self.vardictformat | [
"Make",
"the",
"compute",
"file",
"from",
"the",
"self",
".",
"vardict",
"and",
"self",
".",
"vardictformat"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L173-L196 |
250,428 | KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.get_es_mappings | def get_es_mappings(self):
"""
Returns the mapping defitions presetn in elasticsearh
"""
es_mappings = json.loads(requests.get(self.mapping_url).text)
es_mappings = {"_".join(key.split("_")[:-1]): value['mappings'] \
for key, value in es_mappings.it... | python | def get_es_mappings(self):
"""
Returns the mapping defitions presetn in elasticsearh
"""
es_mappings = json.loads(requests.get(self.mapping_url).text)
es_mappings = {"_".join(key.split("_")[:-1]): value['mappings'] \
for key, value in es_mappings.it... | [
"def",
"get_es_mappings",
"(",
"self",
")",
":",
"es_mappings",
"=",
"json",
".",
"loads",
"(",
"requests",
".",
"get",
"(",
"self",
".",
"mapping_url",
")",
".",
"text",
")",
"es_mappings",
"=",
"{",
"\"_\"",
".",
"join",
"(",
"key",
".",
"split",
"... | Returns the mapping defitions presetn in elasticsearh | [
"Returns",
"the",
"mapping",
"defitions",
"presetn",
"in",
"elasticsearh"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L225-L233 |
250,429 | shaunduncan/helga-reminders | helga_reminders.py | readable_time_delta | def readable_time_delta(seconds):
"""
Convert a number of seconds into readable days, hours, and minutes
"""
days = seconds // 86400
seconds -= days * 86400
hours = seconds // 3600
seconds -= hours * 3600
minutes = seconds // 60
m_suffix = 's' if minutes != 1 else ''
h_suffix = ... | python | def readable_time_delta(seconds):
"""
Convert a number of seconds into readable days, hours, and minutes
"""
days = seconds // 86400
seconds -= days * 86400
hours = seconds // 3600
seconds -= hours * 3600
minutes = seconds // 60
m_suffix = 's' if minutes != 1 else ''
h_suffix = ... | [
"def",
"readable_time_delta",
"(",
"seconds",
")",
":",
"days",
"=",
"seconds",
"//",
"86400",
"seconds",
"-=",
"days",
"*",
"86400",
"hours",
"=",
"seconds",
"//",
"3600",
"seconds",
"-=",
"hours",
"*",
"3600",
"minutes",
"=",
"seconds",
"//",
"60",
"m_... | Convert a number of seconds into readable days, hours, and minutes | [
"Convert",
"a",
"number",
"of",
"seconds",
"into",
"readable",
"days",
"hours",
"and",
"minutes"
] | e2b88cb65eade270ed175ceb6a4d6339554b893b | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L82-L104 |
250,430 | shaunduncan/helga-reminders | helga_reminders.py | next_occurrence | def next_occurrence(reminder):
"""
Calculate the next occurrence of a repeatable reminder
"""
now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
now_dow = now.weekday()
# Start/end dow starting from tomorrow
start_dow = now_dow + 1
end_dow = start_dow + 7
# Modded range from... | python | def next_occurrence(reminder):
"""
Calculate the next occurrence of a repeatable reminder
"""
now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
now_dow = now.weekday()
# Start/end dow starting from tomorrow
start_dow = now_dow + 1
end_dow = start_dow + 7
# Modded range from... | [
"def",
"next_occurrence",
"(",
"reminder",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"UTC",
")",
"now_dow",
"=",
"now",
".",
"weekday",
"(",
")",
"# Start/end dow starting... | Calculate the next occurrence of a repeatable reminder | [
"Calculate",
"the",
"next",
"occurrence",
"of",
"a",
"repeatable",
"reminder"
] | e2b88cb65eade270ed175ceb6a4d6339554b893b | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L107-L143 |
250,431 | shaunduncan/helga-reminders | helga_reminders.py | at_reminder | def at_reminder(client, channel, nick, args):
"""
Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of ... | python | def at_reminder(client, channel, nick, args):
"""
Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of ... | [
"def",
"at_reminder",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"args",
")",
":",
"global",
"_scheduled",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"UTC",
")",
"# Parse the... | Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of reminders are repeatable, should the last two words of the... | [
"Schedule",
"a",
"reminder",
"to",
"occur",
"at",
"a",
"specific",
"time",
".",
"The",
"given",
"time",
"can",
"optionally",
"be",
"specified",
"to",
"occur",
"at",
"a",
"specific",
"timezone",
"but",
"will",
"default",
"to",
"the",
"value",
"of",
"setting... | e2b88cb65eade270ed175ceb6a4d6339554b893b | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L223-L324 |
250,432 | minhhoit/yacms | yacms/bin/management/commands/yacms_project.py | Command.handle_template | def handle_template(self, template, subdir):
"""
Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand.
"""
if template is None:
return six.text_type(os.path.join(yacms.__path__[0], subdir)... | python | def handle_template(self, template, subdir):
"""
Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand.
"""
if template is None:
return six.text_type(os.path.join(yacms.__path__[0], subdir)... | [
"def",
"handle_template",
"(",
"self",
",",
"template",
",",
"subdir",
")",
":",
"if",
"template",
"is",
"None",
":",
"return",
"six",
".",
"text_type",
"(",
"os",
".",
"path",
".",
"join",
"(",
"yacms",
".",
"__path__",
"[",
"0",
"]",
",",
"subdir",... | Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand. | [
"Use",
"yacms",
"s",
"project",
"template",
"by",
"default",
".",
"The",
"method",
"of",
"picking",
"the",
"default",
"directory",
"is",
"copied",
"from",
"Django",
"s",
"TemplateCommand",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/bin/management/commands/yacms_project.py#L80-L88 |
250,433 | praekelt/jmbo-gallery | gallery/models.py | VideoEmbed.save | def save(self, *args, **kwargs):
"""Automatically set image"""
if not self.image:
# Fetch image
url = "http://img.youtube.com/vi/%s/0.jpg" % self.youtube_id
response = None
try:
response = requests.get(url)
except requests.exc... | python | def save(self, *args, **kwargs):
"""Automatically set image"""
if not self.image:
# Fetch image
url = "http://img.youtube.com/vi/%s/0.jpg" % self.youtube_id
response = None
try:
response = requests.get(url)
except requests.exc... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"image",
":",
"# Fetch image",
"url",
"=",
"\"http://img.youtube.com/vi/%s/0.jpg\"",
"%",
"self",
".",
"youtube_id",
"response",
"=",
"None",
"try",
... | Automatically set image | [
"Automatically",
"set",
"image"
] | 064e005913d79e456ba014b50205c7916df4714a | https://github.com/praekelt/jmbo-gallery/blob/064e005913d79e456ba014b50205c7916df4714a/gallery/models.py#L71-L140 |
250,434 | kodexlab/reliure | reliure/engine.py | PlayMeta.name | def name(self):
""" Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
... | python | def name(self):
""" Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
... | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"\"%s:[%s]\"",
"%",
"(",
"self",
".",
"_name",
",",
"\", \"",
".",
"join",
"(",
"meta",
".",
"name",
"for",
"meta",
"in",
"self",
".",
"_metas",
")",
")"
] | Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
>>> gres.name
'o... | [
"Compute",
"a",
"name",
"according",
"to",
"sub",
"meta",
"results",
"names"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L163-L174 |
250,435 | kodexlab/reliure | reliure/engine.py | PlayMeta.errors | def errors(self):
""" get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>... | python | def errors(self):
""" get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>... | [
"def",
"errors",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"meta",
"in",
"self",
":",
"errors",
".",
"extend",
"(",
"meta",
".",
"errors",
")",
"return",
"errors"
] | get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_moins)
... | [
"get",
"all",
"the",
"errors"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L193-L209 |
250,436 | kodexlab/reliure | reliure/engine.py | Block.defaults | def defaults(self):
""" component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected.
"""
default = self._defaults
... | python | def defaults(self):
""" component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected.
"""
default = self._defaults
... | [
"def",
"defaults",
"(",
"self",
")",
":",
"default",
"=",
"self",
".",
"_defaults",
"# if require and no default, the first component as default",
"if",
"not",
"len",
"(",
"default",
")",
"and",
"self",
".",
"required",
"and",
"len",
"(",
"self",
".",
"_componen... | component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected. | [
"component",
"default",
"component"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L340-L351 |
250,437 | kodexlab/reliure | reliure/engine.py | Block.selected | def selected(self):
""" returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected.
"""
selected = self._selected
... | python | def selected(self):
""" returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected.
"""
selected = self._selected
... | [
"def",
"selected",
"(",
"self",
")",
":",
"selected",
"=",
"self",
".",
"_selected",
"if",
"len",
"(",
"self",
".",
"_selected",
")",
"==",
"0",
"and",
"self",
".",
"required",
":",
"# nothing has been selected yet BUT the component is required",
"selected",
"="... | returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected. | [
"returns",
"the",
"list",
"of",
"selected",
"component",
"names",
"."
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L362-L373 |
250,438 | kodexlab/reliure | reliure/engine.py | Block.as_dict | def as_dict(self):
""" returns a dictionary representation of the block and of all
component options
"""
#TODO/FIXME: add selected information
if self.hidden:
rdict = {}
else:
def_selected = self.selected()
comps = [
{
... | python | def as_dict(self):
""" returns a dictionary representation of the block and of all
component options
"""
#TODO/FIXME: add selected information
if self.hidden:
rdict = {}
else:
def_selected = self.selected()
comps = [
{
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"#TODO/FIXME: add selected information",
"if",
"self",
".",
"hidden",
":",
"rdict",
"=",
"{",
"}",
"else",
":",
"def_selected",
"=",
"self",
".",
"selected",
"(",
")",
"comps",
"=",
"[",
"{",
"'name'",
":",
"comp"... | returns a dictionary representation of the block and of all
component options | [
"returns",
"a",
"dictionary",
"representation",
"of",
"the",
"block",
"and",
"of",
"all",
"component",
"options"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L375-L400 |
250,439 | kodexlab/reliure | reliure/engine.py | Block.reset | def reset(self):
""" Removes all the components of the block
"""
self._components = OrderedDict()
self.clear_selections()
self._logger.info("<block: %s> reset component list" % (self.name)) | python | def reset(self):
""" Removes all the components of the block
"""
self._components = OrderedDict()
self.clear_selections()
self._logger.info("<block: %s> reset component list" % (self.name)) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_components",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"clear_selections",
"(",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"<block: %s> reset component list\"",
"%",
"(",
"self",
".",
"name",
")"... | Removes all the components of the block | [
"Removes",
"all",
"the",
"components",
"of",
"the",
"block"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L402-L407 |
250,440 | kodexlab/reliure | reliure/engine.py | Block.setup | def setup(self, in_name=None, out_name=None, required=None, hidden=None,
multiple=None, defaults=None):
""" Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) ... | python | def setup(self, in_name=None, out_name=None, required=None, hidden=None,
multiple=None, defaults=None):
""" Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) ... | [
"def",
"setup",
"(",
"self",
",",
"in_name",
"=",
"None",
",",
"out_name",
"=",
"None",
",",
"required",
"=",
"None",
",",
"hidden",
"=",
"None",
",",
"multiple",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"if",
"in_name",
"is",
"not",
"N... | Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) of the block input data
:type in_name: str or list of str
:param out_name: name of the block output data
:ty... | [
"Set",
"the",
"options",
"of",
"the",
"block",
".",
"Only",
"the",
"not",
"None",
"given",
"options",
"are",
"set"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L422-L454 |
250,441 | kodexlab/reliure | reliure/engine.py | Block.validate | def validate(self):
""" check that the block can be run
"""
if self.required and len(self.selected()) == 0:
raise ReliureError("No component selected for block '%s'" % self.name) | python | def validate(self):
""" check that the block can be run
"""
if self.required and len(self.selected()) == 0:
raise ReliureError("No component selected for block '%s'" % self.name) | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"required",
"and",
"len",
"(",
"self",
".",
"selected",
"(",
")",
")",
"==",
"0",
":",
"raise",
"ReliureError",
"(",
"\"No component selected for block '%s'\"",
"%",
"self",
".",
"name",
")"
] | check that the block can be run | [
"check",
"that",
"the",
"block",
"can",
"be",
"run"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L599-L603 |
250,442 | kodexlab/reliure | reliure/engine.py | Engine.requires | def requires(self, *names):
""" Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task.
"""
if len(names) == 0:
raise ValueError("You should give at least one block na... | python | def requires(self, *names):
""" Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task.
"""
if len(names) == 0:
raise ValueError("You should give at least one block na... | [
"def",
"requires",
"(",
"self",
",",
"*",
"names",
")",
":",
"if",
"len",
"(",
"names",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"You should give at least one block name\"",
")",
"if",
"self",
".",
"_blocks",
"is",
"not",
"None",
"and",
"len",
... | Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task. | [
"Declare",
"what",
"block",
"will",
"be",
"used",
"in",
"this",
"engine",
"."
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L713-L728 |
250,443 | kodexlab/reliure | reliure/engine.py | Engine.needed_inputs | def needed_inputs(self):
""" List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
... | python | def needed_inputs(self):
""" List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
... | [
"def",
"needed_inputs",
"(",
"self",
")",
":",
"needed",
"=",
"set",
"(",
")",
"available",
"=",
"set",
"(",
")",
"# set of available data",
"for",
"bnum",
",",
"block",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"not",
"block",
".",
"selected",
"... | List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
>>> engine.op2.append(lambda x:x*2... | [
"List",
"all",
"the",
"needed",
"inputs",
"of",
"a",
"configured",
"engine"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L892-L942 |
250,444 | kodexlab/reliure | reliure/engine.py | Engine.as_dict | def as_dict(self):
""" dict repr of the components """
drepr = {
'blocks': [
block.as_dict() for block in self if block.hidden == False
],
'args': list(self.needed_inputs())
}
return drepr | python | def as_dict(self):
""" dict repr of the components """
drepr = {
'blocks': [
block.as_dict() for block in self if block.hidden == False
],
'args': list(self.needed_inputs())
}
return drepr | [
"def",
"as_dict",
"(",
"self",
")",
":",
"drepr",
"=",
"{",
"'blocks'",
":",
"[",
"block",
".",
"as_dict",
"(",
")",
"for",
"block",
"in",
"self",
"if",
"block",
".",
"hidden",
"==",
"False",
"]",
",",
"'args'",
":",
"list",
"(",
"self",
".",
"ne... | dict repr of the components | [
"dict",
"repr",
"of",
"the",
"components"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L1033-L1041 |
250,445 | messense/extender | extender/manager.py | InstanceManager.all | def all(self):
"""
Returns a list of cached instances.
"""
class_list = list(self.get_class_list())
if not class_list:
self.cache = []
return []
if self.cache is not None:
return self.cache
results = []
for cls_path in... | python | def all(self):
"""
Returns a list of cached instances.
"""
class_list = list(self.get_class_list())
if not class_list:
self.cache = []
return []
if self.cache is not None:
return self.cache
results = []
for cls_path in... | [
"def",
"all",
"(",
"self",
")",
":",
"class_list",
"=",
"list",
"(",
"self",
".",
"get_class_list",
"(",
")",
")",
"if",
"not",
"class_list",
":",
"self",
".",
"cache",
"=",
"[",
"]",
"return",
"[",
"]",
"if",
"self",
".",
"cache",
"is",
"not",
"... | Returns a list of cached instances. | [
"Returns",
"a",
"list",
"of",
"cached",
"instances",
"."
] | 511a1712494d65133a0dbabca3d849e2f8c500c2 | https://github.com/messense/extender/blob/511a1712494d65133a0dbabca3d849e2f8c500c2/extender/manager.py#L38-L65 |
250,446 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig._download_initial_config | def _download_initial_config(self):
"""Loads the initial config."""
_initial_config = self._download_running_config() # this is a bit slow!
self._last_working_config = _initial_config
self._config_history.append(_initial_config)
self._config_history.append(_initial_config) | python | def _download_initial_config(self):
"""Loads the initial config."""
_initial_config = self._download_running_config() # this is a bit slow!
self._last_working_config = _initial_config
self._config_history.append(_initial_config)
self._config_history.append(_initial_config) | [
"def",
"_download_initial_config",
"(",
"self",
")",
":",
"_initial_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"# this is a bit slow!",
"self",
".",
"_last_working_config",
"=",
"_initial_config",
"self",
".",
"_config_history",
".",
"append",
"(... | Loads the initial config. | [
"Loads",
"the",
"initial",
"config",
"."
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L52-L57 |
250,447 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig._upload_config_content | def _upload_config_content(self, configuration, rollbacked=False):
"""Will try to upload a specific configuration on the device."""
try:
for configuration_line in configuration.splitlines():
self._device.cli(configuration_line)
self._config_changed = True # confi... | python | def _upload_config_content(self, configuration, rollbacked=False):
"""Will try to upload a specific configuration on the device."""
try:
for configuration_line in configuration.splitlines():
self._device.cli(configuration_line)
self._config_changed = True # confi... | [
"def",
"_upload_config_content",
"(",
"self",
",",
"configuration",
",",
"rollbacked",
"=",
"False",
")",
":",
"try",
":",
"for",
"configuration_line",
"in",
"configuration",
".",
"splitlines",
"(",
")",
":",
"self",
".",
"_device",
".",
"cli",
"(",
"configu... | Will try to upload a specific configuration on the device. | [
"Will",
"try",
"to",
"upload",
"a",
"specific",
"configuration",
"on",
"the",
"device",
"."
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L63-L78 |
250,448 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.load_candidate | def load_candidate(self, filename=None, config=None):
"""
Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
... | python | def load_candidate(self, filename=None, config=None):
"""
Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
... | [
"def",
"load_candidate",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"configuration",
"=",
"''",
"if",
"filename",
"is",
"None",
":",
"configuration",
"=",
"config",
"else",
":",
"with",
"open",
"(",
"filename",
")",
... | Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
:param config: New configuration to be uploaded on the device.
:... | [
"Loads",
"a",
"candidate",
"configuration",
"on",
"the",
"device",
".",
"In",
"case",
"the",
"load",
"fails",
"at",
"any",
"point",
"will",
"automatically",
"rollback",
"to",
"last",
"working",
"configuration",
"."
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L88-L106 |
250,449 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.discard | def discard(self): # pylint: disable=no-self-use
"""
Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded.
"""
try:
self.rollback(0)
except pyPluribus.exceptions.RollbackError as ... | python | def discard(self): # pylint: disable=no-self-use
"""
Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded.
"""
try:
self.rollback(0)
except pyPluribus.exceptions.RollbackError as ... | [
"def",
"discard",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"try",
":",
"self",
".",
"rollback",
"(",
"0",
")",
"except",
"pyPluribus",
".",
"exceptions",
".",
"RollbackError",
"as",
"rbackerr",
":",
"raise",
"pyPluribus",
".",
"exceptions",
".",... | Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded. | [
"Clears",
"uncommited",
"changes",
"."
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L108-L118 |
250,450 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.commit | def commit(self): # pylint: disable=no-self-use
"""Will commit the changes on the device"""
if self._config_changed:
self._last_working_config = self._download_running_config()
self._config_history.append(self._last_working_config)
self._committed = True # comfigura... | python | def commit(self): # pylint: disable=no-self-use
"""Will commit the changes on the device"""
if self._config_changed:
self._last_working_config = self._download_running_config()
self._config_history.append(self._last_working_config)
self._committed = True # comfigura... | [
"def",
"commit",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"if",
"self",
".",
"_config_changed",
":",
"self",
".",
"_last_working_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"self",
".",
"_config_history",
".",
"append",
"(",
"... | Will commit the changes on the device | [
"Will",
"commit",
"the",
"changes",
"on",
"the",
"device"
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L120-L130 |
250,451 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.compare | def compare(self): # pylint: disable=no-self-use
"""
Computes the difference between the candidate config and the running config.
"""
# becuase we emulate the configuration history
# the difference is between the last committed config and the running-config
running_confi... | python | def compare(self): # pylint: disable=no-self-use
"""
Computes the difference between the candidate config and the running config.
"""
# becuase we emulate the configuration history
# the difference is between the last committed config and the running-config
running_confi... | [
"def",
"compare",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"# becuase we emulate the configuration history",
"# the difference is between the last committed config and the running-config",
"running_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"runni... | Computes the difference between the candidate config and the running config. | [
"Computes",
"the",
"difference",
"between",
"the",
"candidate",
"config",
"and",
"the",
"running",
"config",
"."
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L132-L143 |
250,452 | mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.rollback | def rollback(self, number=0):
"""
Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled b... | python | def rollback(self, number=0):
"""
Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled b... | [
"def",
"rollback",
"(",
"self",
",",
"number",
"=",
"0",
")",
":",
"if",
"number",
"<",
"0",
":",
"raise",
"pyPluribus",
".",
"exceptions",
".",
"RollbackError",
"(",
"\"Please provide a positive number to rollback to!\"",
")",
"available_configs",
"=",
"len",
"... | Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled back. | [
"Will",
"rollback",
"the",
"configuration",
"to",
"a",
"previous",
"state",
".",
"Can",
"be",
"called",
"also",
"when"
] | 99bb9b6de40a0e465e3f0e6636b26acdeabbbd90 | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L145-L176 |
250,453 | nens/turn | turn/core.py | Queue.draw | def draw(self, label, expire):
"""
Return a Serial number for this resource queue, after bootstrapping.
"""
# get next number
with self.client.pipeline() as pipe:
pipe.msetnx({self.keys.dispenser: 0, self.keys.indicator: 1})
pipe.incr(self.keys.dispenser)
... | python | def draw(self, label, expire):
"""
Return a Serial number for this resource queue, after bootstrapping.
"""
# get next number
with self.client.pipeline() as pipe:
pipe.msetnx({self.keys.dispenser: 0, self.keys.indicator: 1})
pipe.incr(self.keys.dispenser)
... | [
"def",
"draw",
"(",
"self",
",",
"label",
",",
"expire",
")",
":",
"# get next number",
"with",
"self",
".",
"client",
".",
"pipeline",
"(",
")",
"as",
"pipe",
":",
"pipe",
".",
"msetnx",
"(",
"{",
"self",
".",
"keys",
".",
"dispenser",
":",
"0",
"... | Return a Serial number for this resource queue, after bootstrapping. | [
"Return",
"a",
"Serial",
"number",
"for",
"this",
"resource",
"queue",
"after",
"bootstrapping",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L98-L126 |
250,454 | nens/turn | turn/core.py | Queue.wait | def wait(self, number, patience):
""" Waits and resets if necessary. """
# inspect indicator for our number
waiting = int(self.client.get(self.keys.indicator)) != number
# wait until someone announces our number
while waiting:
message = self.subscription.listen(patie... | python | def wait(self, number, patience):
""" Waits and resets if necessary. """
# inspect indicator for our number
waiting = int(self.client.get(self.keys.indicator)) != number
# wait until someone announces our number
while waiting:
message = self.subscription.listen(patie... | [
"def",
"wait",
"(",
"self",
",",
"number",
",",
"patience",
")",
":",
"# inspect indicator for our number",
"waiting",
"=",
"int",
"(",
"self",
".",
"client",
".",
"get",
"(",
"self",
".",
"keys",
".",
"indicator",
")",
")",
"!=",
"number",
"# wait until s... | Waits and resets if necessary. | [
"Waits",
"and",
"resets",
"if",
"necessary",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L128-L147 |
250,455 | nens/turn | turn/core.py | Queue.message | def message(self, text):
""" Public message. """
self.client.publish(self.keys.external,
'{}: {}'.format(self.resource, text)) | python | def message(self, text):
""" Public message. """
self.client.publish(self.keys.external,
'{}: {}'.format(self.resource, text)) | [
"def",
"message",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"client",
".",
"publish",
"(",
"self",
".",
"keys",
".",
"external",
",",
"'{}: {}'",
".",
"format",
"(",
"self",
".",
"resource",
",",
"text",
")",
")"
] | Public message. | [
"Public",
"message",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L149-L152 |
250,456 | nens/turn | turn/core.py | Queue.announce | def announce(self, number):
""" Announce an indicator change on both channels. """
self.client.publish(self.keys.internal, self.keys.key(number))
self.message('{} granted'.format(number)) | python | def announce(self, number):
""" Announce an indicator change on both channels. """
self.client.publish(self.keys.internal, self.keys.key(number))
self.message('{} granted'.format(number)) | [
"def",
"announce",
"(",
"self",
",",
"number",
")",
":",
"self",
".",
"client",
".",
"publish",
"(",
"self",
".",
"keys",
".",
"internal",
",",
"self",
".",
"keys",
".",
"key",
"(",
"number",
")",
")",
"self",
".",
"message",
"(",
"'{} granted'",
"... | Announce an indicator change on both channels. | [
"Announce",
"an",
"indicator",
"change",
"on",
"both",
"channels",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L154-L157 |
250,457 | nens/turn | turn/core.py | Queue.bump | def bump(self):
""" Fix indicator in case of unnanounced departments. """
# read client
values = self.client.mget(self.keys.indicator, self.keys.dispenser)
indicator, dispenser = map(int, values)
# determine active users
numbers = range(indicator, dispenser + 1)
... | python | def bump(self):
""" Fix indicator in case of unnanounced departments. """
# read client
values = self.client.mget(self.keys.indicator, self.keys.dispenser)
indicator, dispenser = map(int, values)
# determine active users
numbers = range(indicator, dispenser + 1)
... | [
"def",
"bump",
"(",
"self",
")",
":",
"# read client",
"values",
"=",
"self",
".",
"client",
".",
"mget",
"(",
"self",
".",
"keys",
".",
"indicator",
",",
"self",
".",
"keys",
".",
"dispenser",
")",
"indicator",
",",
"dispenser",
"=",
"map",
"(",
"in... | Fix indicator in case of unnanounced departments. | [
"Fix",
"indicator",
"in",
"case",
"of",
"unnanounced",
"departments",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L159-L184 |
250,458 | nens/turn | turn/core.py | Locker.lock | def lock(self, resource, label='', expire=60, patience=60):
"""
Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds
"""
queue = Queue(client=s... | python | def lock(self, resource, label='', expire=60, patience=60):
"""
Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds
"""
queue = Queue(client=s... | [
"def",
"lock",
"(",
"self",
",",
"resource",
",",
"label",
"=",
"''",
",",
"expire",
"=",
"60",
",",
"patience",
"=",
"60",
")",
":",
"queue",
"=",
"Queue",
"(",
"client",
"=",
"self",
".",
"client",
",",
"resource",
"=",
"resource",
")",
"with",
... | Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds | [
"Lock",
"a",
"resource",
"."
] | 98e806a0749ada0ddfd04b3c29fb04c15bf5ac18 | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L205-L218 |
250,459 | jtpaasch/simplygithub | simplygithub/internals/refs.py | list_refs | def list_refs(profile, ref_type=None):
"""List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
... | python | def list_refs(profile, ref_type=None):
"""List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
... | [
"def",
"list_refs",
"(",
"profile",
",",
"ref_type",
"=",
"None",
")",
":",
"resource",
"=",
"\"/refs\"",
"if",
"ref_type",
":",
"resource",
"+=",
"\"/\"",
"+",
"ref_type",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"re... | List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
The type of ref you want. For heads, it's ... | [
"List",
"all",
"refs",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L16-L40 |
250,460 | jtpaasch/simplygithub | simplygithub/internals/refs.py | get_ref | def get_ref(profile, ref):
"""Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetc... | python | def get_ref(profile, ref):
"""Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetc... | [
"def",
"get_ref",
"(",
"profile",
",",
"ref",
")",
":",
"resource",
"=",
"\"/refs/\"",
"+",
"ref",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"return",
"prepare",
"(",
"data",
")"
] | Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetch, e.g., ``heads/my-feature-branch... | [
"Fetch",
"a",
"ref",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L43-L62 |
250,461 | jtpaasch/simplygithub | simplygithub/internals/refs.py | create_ref | def create_ref(profile, ref, sha):
"""Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The re... | python | def create_ref(profile, ref, sha):
"""Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The re... | [
"def",
"create_ref",
"(",
"profile",
",",
"ref",
",",
"sha",
")",
":",
"resource",
"=",
"\"/refs\"",
"payload",
"=",
"{",
"\"ref\"",
":",
"\"refs/\"",
"+",
"ref",
",",
"\"sha\"",
":",
"sha",
"}",
"data",
"=",
"api",
".",
"post_request",
"(",
"profile",... | Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to create, e.g., ``heads/my-feature-bran... | [
"Create",
"a",
"ref",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L65-L88 |
250,462 | jtpaasch/simplygithub | simplygithub/internals/refs.py | update_ref | def update_ref(profile, ref, sha):
"""Point a ref to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
... | python | def update_ref(profile, ref, sha):
"""Point a ref to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
... | [
"def",
"update_ref",
"(",
"profile",
",",
"ref",
",",
"sha",
")",
":",
"resource",
"=",
"\"/refs/\"",
"+",
"ref",
"payload",
"=",
"{",
"\"sha\"",
":",
"sha",
"}",
"data",
"=",
"api",
".",
"patch_request",
"(",
"profile",
",",
"resource",
",",
"payload"... | Point a ref to a new SHA.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to update, e.g., ``heads/my-... | [
"Point",
"a",
"ref",
"to",
"a",
"new",
"SHA",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L91-L114 |
250,463 | jamieleshaw/lurklib | lurklib/connection.py | _Connection.latency | def latency(self):
""" Checks the connection latency. """
with self.lock:
self.send('PING %s' % self.server)
ctime = self._m_time.time()
msg = self._recv(expected_replies=('PONG',))
if msg[0] == 'PONG':
latency = self._m_time.time() - ctim... | python | def latency(self):
""" Checks the connection latency. """
with self.lock:
self.send('PING %s' % self.server)
ctime = self._m_time.time()
msg = self._recv(expected_replies=('PONG',))
if msg[0] == 'PONG':
latency = self._m_time.time() - ctim... | [
"def",
"latency",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"send",
"(",
"'PING %s'",
"%",
"self",
".",
"server",
")",
"ctime",
"=",
"self",
".",
"_m_time",
".",
"time",
"(",
")",
"msg",
"=",
"self",
".",
"_recv",
"(",... | Checks the connection latency. | [
"Checks",
"the",
"connection",
"latency",
"."
] | a861f35d880140422103dd78ec3239814e85fd7e | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/connection.py#L357-L366 |
250,464 | armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/utils.py | get_section_relations | def get_section_relations(Section):
"""Find every relationship between section and the item model."""
all_rels = (Section._meta.get_all_related_objects() +
Section._meta.get_all_related_many_to_many_objects())
return filter_item_rels(all_rels) | python | def get_section_relations(Section):
"""Find every relationship between section and the item model."""
all_rels = (Section._meta.get_all_related_objects() +
Section._meta.get_all_related_many_to_many_objects())
return filter_item_rels(all_rels) | [
"def",
"get_section_relations",
"(",
"Section",
")",
":",
"all_rels",
"=",
"(",
"Section",
".",
"_meta",
".",
"get_all_related_objects",
"(",
")",
"+",
"Section",
".",
"_meta",
".",
"get_all_related_many_to_many_objects",
"(",
")",
")",
"return",
"filter_item_rels... | Find every relationship between section and the item model. | [
"Find",
"every",
"relationship",
"between",
"section",
"and",
"the",
"item",
"model",
"."
] | 39c999c93771da909359e53b35afefe4846f77cb | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/utils.py#L30-L34 |
250,465 | mattimck/python-exist | exist/auth.py | ExistAuth.authorize_url | def authorize_url(self):
"""
Build the authorization url and save the state. Return the
authorization url
"""
url, self.state = self.oauth.authorization_url(
'%sauthorize' % OAUTH_URL)
return url | python | def authorize_url(self):
"""
Build the authorization url and save the state. Return the
authorization url
"""
url, self.state = self.oauth.authorization_url(
'%sauthorize' % OAUTH_URL)
return url | [
"def",
"authorize_url",
"(",
"self",
")",
":",
"url",
",",
"self",
".",
"state",
"=",
"self",
".",
"oauth",
".",
"authorization_url",
"(",
"'%sauthorize'",
"%",
"OAUTH_URL",
")",
"return",
"url"
] | Build the authorization url and save the state. Return the
authorization url | [
"Build",
"the",
"authorization",
"url",
"and",
"save",
"the",
"state",
".",
"Return",
"the",
"authorization",
"url"
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L75-L82 |
250,466 | mattimck/python-exist | exist/auth.py | ExistAuth.fetch_token | def fetch_token(self, code, state):
"""
Fetch the token, using the verification code. Also, make sure the state
received in the response matches the one in the request. Returns the
access_token.
"""
if self.state != state:
raise MismatchingStateError()
... | python | def fetch_token(self, code, state):
"""
Fetch the token, using the verification code. Also, make sure the state
received in the response matches the one in the request. Returns the
access_token.
"""
if self.state != state:
raise MismatchingStateError()
... | [
"def",
"fetch_token",
"(",
"self",
",",
"code",
",",
"state",
")",
":",
"if",
"self",
".",
"state",
"!=",
"state",
":",
"raise",
"MismatchingStateError",
"(",
")",
"self",
".",
"token",
"=",
"self",
".",
"oauth",
".",
"fetch_token",
"(",
"'%saccess_token... | Fetch the token, using the verification code. Also, make sure the state
received in the response matches the one in the request. Returns the
access_token. | [
"Fetch",
"the",
"token",
"using",
"the",
"verification",
"code",
".",
"Also",
"make",
"sure",
"the",
"state",
"received",
"in",
"the",
"response",
"matches",
"the",
"one",
"in",
"the",
"request",
".",
"Returns",
"the",
"access_token",
"."
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L84-L95 |
250,467 | mattimck/python-exist | exist/auth.py | ExistAuth.refresh_token | def refresh_token(self, refresh_token):
"""
Get a new token, using the provided refresh token. Returns the new
access_token.
"""
response = requests.post('%saccess_token' % OAUTH_URL, {
'refresh_token': refresh_token,
... | python | def refresh_token(self, refresh_token):
"""
Get a new token, using the provided refresh token. Returns the new
access_token.
"""
response = requests.post('%saccess_token' % OAUTH_URL, {
'refresh_token': refresh_token,
... | [
"def",
"refresh_token",
"(",
"self",
",",
"refresh_token",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'%saccess_token'",
"%",
"OAUTH_URL",
",",
"{",
"'refresh_token'",
":",
"refresh_token",
",",
"'grant_type'",
":",
"'refresh_token'",
",",
"'clien... | Get a new token, using the provided refresh token. Returns the new
access_token. | [
"Get",
"a",
"new",
"token",
"using",
"the",
"provided",
"refresh",
"token",
".",
"Returns",
"the",
"new",
"access_token",
"."
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L97-L114 |
250,468 | mattimck/python-exist | exist/auth.py | ExistAuth.browser_authorize | def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url = self.authorize_url()
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open... | python | def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url = self.authorize_url()
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open... | [
"def",
"browser_authorize",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"authorize_url",
"(",
")",
"# Open the web browser in a new thread for command-line browser support",
"threading",
".",
"Timer",
"(",
"1",
",",
"webbrowser",
".",
"open",
",",
"args",
"=",
... | Open a browser to the authorization url and spool up a CherryPy
server to accept the response | [
"Open",
"a",
"browser",
"to",
"the",
"authorization",
"url",
"and",
"spool",
"up",
"a",
"CherryPy",
"server",
"to",
"accept",
"the",
"response"
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L116-L135 |
250,469 | mattimck/python-exist | exist/auth.py | ExistAuth.index | def index(self, state, code=None, error=None):
"""
Receive a Exist response containing a verification code. Use the code
to fetch the access_token.
"""
error = None
if code:
try:
auth_token = self.fetch_token(code, state)
except Mis... | python | def index(self, state, code=None, error=None):
"""
Receive a Exist response containing a verification code. Use the code
to fetch the access_token.
"""
error = None
if code:
try:
auth_token = self.fetch_token(code, state)
except Mis... | [
"def",
"index",
"(",
"self",
",",
"state",
",",
"code",
"=",
"None",
",",
"error",
"=",
"None",
")",
":",
"error",
"=",
"None",
"if",
"code",
":",
"try",
":",
"auth_token",
"=",
"self",
".",
"fetch_token",
"(",
"code",
",",
"state",
")",
"except",
... | Receive a Exist response containing a verification code. Use the code
to fetch the access_token. | [
"Receive",
"a",
"Exist",
"response",
"containing",
"a",
"verification",
"code",
".",
"Use",
"the",
"code",
"to",
"fetch",
"the",
"access_token",
"."
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L138-L157 |
250,470 | mattimck/python-exist | exist/auth.py | ExistAuth._shutdown_cherrypy | def _shutdown_cherrypy(self):
""" Shutdown cherrypy in one second, if it's running """
if cherrypy.engine.state == cherrypy.engine.states.STARTED:
threading.Timer(1, cherrypy.engine.exit).start() | python | def _shutdown_cherrypy(self):
""" Shutdown cherrypy in one second, if it's running """
if cherrypy.engine.state == cherrypy.engine.states.STARTED:
threading.Timer(1, cherrypy.engine.exit).start() | [
"def",
"_shutdown_cherrypy",
"(",
"self",
")",
":",
"if",
"cherrypy",
".",
"engine",
".",
"state",
"==",
"cherrypy",
".",
"engine",
".",
"states",
".",
"STARTED",
":",
"threading",
".",
"Timer",
"(",
"1",
",",
"cherrypy",
".",
"engine",
".",
"exit",
")... | Shutdown cherrypy in one second, if it's running | [
"Shutdown",
"cherrypy",
"in",
"one",
"second",
"if",
"it",
"s",
"running"
] | 2c4be9d176d8e8007c4e020ee7cd6263a2096abb | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L164-L167 |
250,471 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | roundup | def roundup(x, order):
'''Round a number to the passed order
Args
----
x: float
Number to be rounded
order: int
Order to which `x` should be rounded
Returns
-------
x_round: float
The passed value rounded to the passed order
'''
return x if x % 10**order... | python | def roundup(x, order):
'''Round a number to the passed order
Args
----
x: float
Number to be rounded
order: int
Order to which `x` should be rounded
Returns
-------
x_round: float
The passed value rounded to the passed order
'''
return x if x % 10**order... | [
"def",
"roundup",
"(",
"x",
",",
"order",
")",
":",
"return",
"x",
"if",
"x",
"%",
"10",
"**",
"order",
"==",
"0",
"else",
"x",
"+",
"10",
"**",
"order",
"-",
"x",
"%",
"10",
"**",
"order"
] | Round a number to the passed order
Args
----
x: float
Number to be rounded
order: int
Order to which `x` should be rounded
Returns
-------
x_round: float
The passed value rounded to the passed order | [
"Round",
"a",
"number",
"to",
"the",
"passed",
"order"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L7-L22 |
250,472 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | hourminsec | def hourminsec(n_seconds):
'''Generate a string of hours and minutes from total number of seconds
Args
----
n_seconds: int
Total number of seconds to calculate hours, minutes, and seconds from
Returns
-------
hours: int
Number of hours in `n_seconds`
minutes: int
... | python | def hourminsec(n_seconds):
'''Generate a string of hours and minutes from total number of seconds
Args
----
n_seconds: int
Total number of seconds to calculate hours, minutes, and seconds from
Returns
-------
hours: int
Number of hours in `n_seconds`
minutes: int
... | [
"def",
"hourminsec",
"(",
"n_seconds",
")",
":",
"hours",
",",
"remainder",
"=",
"divmod",
"(",
"n_seconds",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"remainder",
",",
"60",
")",
"return",
"abs",
"(",
"hours",
")",
",",
"abs",
... | Generate a string of hours and minutes from total number of seconds
Args
----
n_seconds: int
Total number of seconds to calculate hours, minutes, and seconds from
Returns
-------
hours: int
Number of hours in `n_seconds`
minutes: int
Remaining minutes in `n_seconds`... | [
"Generate",
"a",
"string",
"of",
"hours",
"and",
"minutes",
"from",
"total",
"number",
"of",
"seconds"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L42-L63 |
250,473 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | add_alpha_labels | def add_alpha_labels(axes, xpos=0.03, ypos=0.95, suffix='', color=None,
fontsize=14, fontweight='normal', boxstyle='square', facecolor='white',
edgecolor='white', alpha=1.0):
'''Add sequential alphbet labels to subplot axes
Args
----
axes: list of pyplot.ax
A list of matplotlib ... | python | def add_alpha_labels(axes, xpos=0.03, ypos=0.95, suffix='', color=None,
fontsize=14, fontweight='normal', boxstyle='square', facecolor='white',
edgecolor='white', alpha=1.0):
'''Add sequential alphbet labels to subplot axes
Args
----
axes: list of pyplot.ax
A list of matplotlib ... | [
"def",
"add_alpha_labels",
"(",
"axes",
",",
"xpos",
"=",
"0.03",
",",
"ypos",
"=",
"0.95",
",",
"suffix",
"=",
"''",
",",
"color",
"=",
"None",
",",
"fontsize",
"=",
"14",
",",
"fontweight",
"=",
"'normal'",
",",
"boxstyle",
"=",
"'square'",
",",
"f... | Add sequential alphbet labels to subplot axes
Args
----
axes: list of pyplot.ax
A list of matplotlib axes to add the label labels to
xpos: float or array_like
X position(s) of labels in figure coordinates
ypos: float or array_like
Y position(s) of labels in figure coordinate... | [
"Add",
"sequential",
"alphbet",
"labels",
"to",
"subplot",
"axes"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L104-L179 |
250,474 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | merge_limits | def merge_limits(axes, xlim=True, ylim=True):
'''Set maximum and minimum limits from list of axis objects to each axis
Args
----
axes: iterable
list of `matplotlib.pyplot` axis objects whose limits should be modified
xlim: bool
Flag to set modification of x axis limits
ylim: boo... | python | def merge_limits(axes, xlim=True, ylim=True):
'''Set maximum and minimum limits from list of axis objects to each axis
Args
----
axes: iterable
list of `matplotlib.pyplot` axis objects whose limits should be modified
xlim: bool
Flag to set modification of x axis limits
ylim: boo... | [
"def",
"merge_limits",
"(",
"axes",
",",
"xlim",
"=",
"True",
",",
"ylim",
"=",
"True",
")",
":",
"# Compile lists of all x/y limits",
"xlims",
"=",
"list",
"(",
")",
"ylims",
"=",
"list",
"(",
")",
"for",
"ax",
"in",
"axes",
":",
"[",
"xlims",
".",
... | Set maximum and minimum limits from list of axis objects to each axis
Args
----
axes: iterable
list of `matplotlib.pyplot` axis objects whose limits should be modified
xlim: bool
Flag to set modification of x axis limits
ylim: bool
Flag to set modification of y axis limits | [
"Set",
"maximum",
"and",
"minimum",
"limits",
"from",
"list",
"of",
"axis",
"objects",
"to",
"each",
"axis"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L182-L209 |
250,475 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | plot_noncontiguous | def plot_noncontiguous(ax, data, ind, color='black', label='', offset=0,
linewidth=0.5, linestyle='-'):
'''Plot non-contiguous slice of data
Args
----
data: ndarray
The data with non continguous regions to plot
ind: ndarray
indices of data to be plotted
color: matplotlib... | python | def plot_noncontiguous(ax, data, ind, color='black', label='', offset=0,
linewidth=0.5, linestyle='-'):
'''Plot non-contiguous slice of data
Args
----
data: ndarray
The data with non continguous regions to plot
ind: ndarray
indices of data to be plotted
color: matplotlib... | [
"def",
"plot_noncontiguous",
"(",
"ax",
",",
"data",
",",
"ind",
",",
"color",
"=",
"'black'",
",",
"label",
"=",
"''",
",",
"offset",
"=",
"0",
",",
"linewidth",
"=",
"0.5",
",",
"linestyle",
"=",
"'-'",
")",
":",
"def",
"slice_with_nans",
"(",
"ind... | Plot non-contiguous slice of data
Args
----
data: ndarray
The data with non continguous regions to plot
ind: ndarray
indices of data to be plotted
color: matplotlib color
Color of plotted line
label: str
Name to be shown in legend
offset: int
The numb... | [
"Plot",
"non",
"-",
"contiguous",
"slice",
"of",
"data"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L212-L261 |
250,476 | ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | plot_shade_mask | def plot_shade_mask(ax, ind, mask, facecolor='gray', alpha=0.5):
'''Shade across x values where boolean mask is `True`
Args
----
ax: pyplot.ax
Axes object to plot with a shaded region
ind: ndarray
The indices to use for the x-axis values of the data
mask: ndarray
Boolean... | python | def plot_shade_mask(ax, ind, mask, facecolor='gray', alpha=0.5):
'''Shade across x values where boolean mask is `True`
Args
----
ax: pyplot.ax
Axes object to plot with a shaded region
ind: ndarray
The indices to use for the x-axis values of the data
mask: ndarray
Boolean... | [
"def",
"plot_shade_mask",
"(",
"ax",
",",
"ind",
",",
"mask",
",",
"facecolor",
"=",
"'gray'",
",",
"alpha",
"=",
"0.5",
")",
":",
"ymin",
",",
"ymax",
"=",
"ax",
".",
"get_ylim",
"(",
")",
"ax",
".",
"fill_between",
"(",
"ind",
",",
"ymin",
",",
... | Shade across x values where boolean mask is `True`
Args
----
ax: pyplot.ax
Axes object to plot with a shaded region
ind: ndarray
The indices to use for the x-axis values of the data
mask: ndarray
Boolean mask array to determine which regions should be shaded
facecolor: m... | [
"Shade",
"across",
"x",
"values",
"where",
"boolean",
"mask",
"is",
"True"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L264-L286 |
250,477 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.fields | def fields(self, new_fieldnames):
"""
Overwrite all field names with new field names. Mass renaming.
"""
if len(new_fieldnames) != len(self.fields):
raise Exception("Cannot replace fieldnames (len: %s) with list of "
"incorrect length (len: %s)" % ... | python | def fields(self, new_fieldnames):
"""
Overwrite all field names with new field names. Mass renaming.
"""
if len(new_fieldnames) != len(self.fields):
raise Exception("Cannot replace fieldnames (len: %s) with list of "
"incorrect length (len: %s)" % ... | [
"def",
"fields",
"(",
"self",
",",
"new_fieldnames",
")",
":",
"if",
"len",
"(",
"new_fieldnames",
")",
"!=",
"len",
"(",
"self",
".",
"fields",
")",
":",
"raise",
"Exception",
"(",
"\"Cannot replace fieldnames (len: %s) with list of \"",
"\"incorrect length (len: %... | Overwrite all field names with new field names. Mass renaming. | [
"Overwrite",
"all",
"field",
"names",
"with",
"new",
"field",
"names",
".",
"Mass",
"renaming",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L140-L150 |
250,478 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.fromcsvstring | def fromcsvstring(cls, csvstring, delimiter=",", quotechar="\""):
"""
Takes one string that represents the entire contents of the CSV
file, or similar delimited file.
If you have a list of lists, where the first list is the headers,
then use the main constructor.
If you... | python | def fromcsvstring(cls, csvstring, delimiter=",", quotechar="\""):
"""
Takes one string that represents the entire contents of the CSV
file, or similar delimited file.
If you have a list of lists, where the first list is the headers,
then use the main constructor.
If you... | [
"def",
"fromcsvstring",
"(",
"cls",
",",
"csvstring",
",",
"delimiter",
"=",
"\",\"",
",",
"quotechar",
"=",
"\"\\\"\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"csvstring",
",",
"basestring",
")",
":",
"raise",
"Exception",
"(",
"\"If trying to construct a ... | Takes one string that represents the entire contents of the CSV
file, or similar delimited file.
If you have a list of lists, where the first list is the headers,
then use the main constructor.
If you see an excess of whitespace in the first column of your data,
this is probabl... | [
"Takes",
"one",
"string",
"that",
"represents",
"the",
"entire",
"contents",
"of",
"the",
"CSV",
"file",
"or",
"similar",
"delimited",
"file",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L175-L228 |
250,479 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.fromexcel | def fromexcel(cls, path, sheet_name_or_num=0, headers=None):
"""
Constructs a new DataTable from an Excel file.
Specify sheet_name_or_number to load that specific sheet.
Headers will be inferred automatically, but if you'd prefer
to load only a subset of all the headers, pass i... | python | def fromexcel(cls, path, sheet_name_or_num=0, headers=None):
"""
Constructs a new DataTable from an Excel file.
Specify sheet_name_or_number to load that specific sheet.
Headers will be inferred automatically, but if you'd prefer
to load only a subset of all the headers, pass i... | [
"def",
"fromexcel",
"(",
"cls",
",",
"path",
",",
"sheet_name_or_num",
"=",
"0",
",",
"headers",
"=",
"None",
")",
":",
"reader",
"=",
"ExcelRW",
".",
"UnicodeDictReader",
"(",
"path",
",",
"sheet_name_or_num",
")",
"return",
"cls",
"(",
"reader",
",",
"... | Constructs a new DataTable from an Excel file.
Specify sheet_name_or_number to load that specific sheet.
Headers will be inferred automatically, but if you'd prefer
to load only a subset of all the headers, pass in a list of the
headers you'd like as `headers`.
---
Al... | [
"Constructs",
"a",
"new",
"DataTable",
"from",
"an",
"Excel",
"file",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L256-L275 |
250,480 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.__print_table | def __print_table(self, row_delim, header_delim=None,
header_pad=u"", pad=u""):
"""
row_delim default delimiter inserted between columns of every
row in the table.
header_delim delimiter inserted within the headers. by default
... | python | def __print_table(self, row_delim, header_delim=None,
header_pad=u"", pad=u""):
"""
row_delim default delimiter inserted between columns of every
row in the table.
header_delim delimiter inserted within the headers. by default
... | [
"def",
"__print_table",
"(",
"self",
",",
"row_delim",
",",
"header_delim",
"=",
"None",
",",
"header_pad",
"=",
"u\"\"",
",",
"pad",
"=",
"u\"\"",
")",
":",
"if",
"header_delim",
"is",
"None",
":",
"header_delim",
"=",
"row_delim",
"num_cols",
"=",
"len",... | row_delim default delimiter inserted between columns of every
row in the table.
header_delim delimiter inserted within the headers. by default
takes the value of `row_delim`
header_pad put on the sides of the row of headers.
... | [
"row_delim",
"default",
"delimiter",
"inserted",
"between",
"columns",
"of",
"every",
"row",
"in",
"the",
"table",
".",
"header_delim",
"delimiter",
"inserted",
"within",
"the",
"headers",
".",
"by",
"default",
"takes",
"the",
"value",
"of",
"row_delim",
"header... | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L373-L393 |
250,481 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.apply | def apply(self, func, *fields):
"""
Applies the function, `func`, to every row in the DataTable.
If no fields are supplied, the entire row is passed to `func`.
If fields are supplied, the values at all of those fields
are passed into func in that order.
---
data[... | python | def apply(self, func, *fields):
"""
Applies the function, `func`, to every row in the DataTable.
If no fields are supplied, the entire row is passed to `func`.
If fields are supplied, the values at all of those fields
are passed into func in that order.
---
data[... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"*",
"fields",
")",
":",
"results",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
":",
"if",
"not",
"fields",
":",
"results",
".",
"append",
"(",
"func",
"(",
"row",
")",
")",
"else",
":",
"if",
"any"... | Applies the function, `func`, to every row in the DataTable.
If no fields are supplied, the entire row is passed to `func`.
If fields are supplied, the values at all of those fields
are passed into func in that order.
---
data['diff'] = data.apply(short_diff, 'old_count', 'new_c... | [
"Applies",
"the",
"function",
"func",
"to",
"every",
"row",
"in",
"the",
"DataTable",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L486-L507 |
250,482 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.col | def col(self, col_name_or_num):
"""
Returns the col at index `colnum` or name `colnum`.
"""
if isinstance(col_name_or_num, basestring):
return self[col_name_or_num]
elif isinstance(col_name_or_num, (int, long)):
if col_name_or_num > len(self.fields):
... | python | def col(self, col_name_or_num):
"""
Returns the col at index `colnum` or name `colnum`.
"""
if isinstance(col_name_or_num, basestring):
return self[col_name_or_num]
elif isinstance(col_name_or_num, (int, long)):
if col_name_or_num > len(self.fields):
... | [
"def",
"col",
"(",
"self",
",",
"col_name_or_num",
")",
":",
"if",
"isinstance",
"(",
"col_name_or_num",
",",
"basestring",
")",
":",
"return",
"self",
"[",
"col_name_or_num",
"]",
"elif",
"isinstance",
"(",
"col_name_or_num",
",",
"(",
"int",
",",
"long",
... | Returns the col at index `colnum` or name `colnum`. | [
"Returns",
"the",
"col",
"at",
"index",
"colnum",
"or",
"name",
"colnum",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L509-L519 |
250,483 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.distinct | def distinct(self, fieldname, key=None):
"""
Returns the unique values seen at `fieldname`.
"""
return tuple(unique_everseen(self[fieldname], key=key)) | python | def distinct(self, fieldname, key=None):
"""
Returns the unique values seen at `fieldname`.
"""
return tuple(unique_everseen(self[fieldname], key=key)) | [
"def",
"distinct",
"(",
"self",
",",
"fieldname",
",",
"key",
"=",
"None",
")",
":",
"return",
"tuple",
"(",
"unique_everseen",
"(",
"self",
"[",
"fieldname",
"]",
",",
"key",
"=",
"key",
")",
")"
] | Returns the unique values seen at `fieldname`. | [
"Returns",
"the",
"unique",
"values",
"seen",
"at",
"fieldname",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L566-L570 |
250,484 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.mask | def mask(self, masklist):
"""
`masklist` is an array of Bools or equivalent.
This returns a new DataTable using only the rows that were True
(or equivalent) in the mask.
"""
if not hasattr(masklist, '__len__'):
masklist = tuple(masklist)
if len(maskl... | python | def mask(self, masklist):
"""
`masklist` is an array of Bools or equivalent.
This returns a new DataTable using only the rows that were True
(or equivalent) in the mask.
"""
if not hasattr(masklist, '__len__'):
masklist = tuple(masklist)
if len(maskl... | [
"def",
"mask",
"(",
"self",
",",
"masklist",
")",
":",
"if",
"not",
"hasattr",
"(",
"masklist",
",",
"'__len__'",
")",
":",
"masklist",
"=",
"tuple",
"(",
"masklist",
")",
"if",
"len",
"(",
"masklist",
")",
"!=",
"len",
"(",
"self",
")",
":",
"rais... | `masklist` is an array of Bools or equivalent.
This returns a new DataTable using only the rows that were True
(or equivalent) in the mask. | [
"masklist",
"is",
"an",
"array",
"of",
"Bools",
"or",
"equivalent",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L625-L642 |
250,485 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.mutapply | def mutapply(self, function, fieldname):
"""
Applies `function` in-place to the field name specified.
In other words, `mutapply` overwrites column `fieldname`
ith the results of applying `function` to each element of that column.
"""
self[fieldname] = self.apply(function... | python | def mutapply(self, function, fieldname):
"""
Applies `function` in-place to the field name specified.
In other words, `mutapply` overwrites column `fieldname`
ith the results of applying `function` to each element of that column.
"""
self[fieldname] = self.apply(function... | [
"def",
"mutapply",
"(",
"self",
",",
"function",
",",
"fieldname",
")",
":",
"self",
"[",
"fieldname",
"]",
"=",
"self",
".",
"apply",
"(",
"function",
",",
"fieldname",
")"
] | Applies `function` in-place to the field name specified.
In other words, `mutapply` overwrites column `fieldname`
ith the results of applying `function` to each element of that column. | [
"Applies",
"function",
"in",
"-",
"place",
"to",
"the",
"field",
"name",
"specified",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L644-L651 |
250,486 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.rename | def rename(self, old_fieldname, new_fieldname):
"""
Renames a specific field, and preserves the underlying order.
"""
if old_fieldname not in self:
raise Exception("DataTable does not have field `%s`" %
old_fieldname)
if not isinstance(new... | python | def rename(self, old_fieldname, new_fieldname):
"""
Renames a specific field, and preserves the underlying order.
"""
if old_fieldname not in self:
raise Exception("DataTable does not have field `%s`" %
old_fieldname)
if not isinstance(new... | [
"def",
"rename",
"(",
"self",
",",
"old_fieldname",
",",
"new_fieldname",
")",
":",
"if",
"old_fieldname",
"not",
"in",
"self",
":",
"raise",
"Exception",
"(",
"\"DataTable does not have field `%s`\"",
"%",
"old_fieldname",
")",
"if",
"not",
"isinstance",
"(",
"... | Renames a specific field, and preserves the underlying order. | [
"Renames",
"a",
"specific",
"field",
"and",
"preserves",
"the",
"underlying",
"order",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L656-L675 |
250,487 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.reorder | def reorder(self, fields_in_new_order):
"""
Pass in field names in the order you wish them to be swapped.
"""
if not len(fields_in_new_order) == len(self.fields):
raise Exception("Fields to reorder with are not the same length "
"(%s) as the origin... | python | def reorder(self, fields_in_new_order):
"""
Pass in field names in the order you wish them to be swapped.
"""
if not len(fields_in_new_order) == len(self.fields):
raise Exception("Fields to reorder with are not the same length "
"(%s) as the origin... | [
"def",
"reorder",
"(",
"self",
",",
"fields_in_new_order",
")",
":",
"if",
"not",
"len",
"(",
"fields_in_new_order",
")",
"==",
"len",
"(",
"self",
".",
"fields",
")",
":",
"raise",
"Exception",
"(",
"\"Fields to reorder with are not the same length \"",
"\"(%s) a... | Pass in field names in the order you wish them to be swapped. | [
"Pass",
"in",
"field",
"names",
"in",
"the",
"order",
"you",
"wish",
"them",
"to",
"be",
"swapped",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L677-L691 |
250,488 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.sample | def sample(self, num):
"""
Returns a new table with rows randomly sampled.
We create a mask with `num` True bools, and fill it with False bools
until it is the length of the table. We shuffle it, and apply that
mask to the table.
"""
if num > len(self):
... | python | def sample(self, num):
"""
Returns a new table with rows randomly sampled.
We create a mask with `num` True bools, and fill it with False bools
until it is the length of the table. We shuffle it, and apply that
mask to the table.
"""
if num > len(self):
... | [
"def",
"sample",
"(",
"self",
",",
"num",
")",
":",
"if",
"num",
">",
"len",
"(",
"self",
")",
":",
"return",
"self",
".",
"copy",
"(",
")",
"elif",
"num",
"<",
"0",
":",
"raise",
"IndexError",
"(",
"\"Cannot sample a negative number of rows \"",
"\"from... | Returns a new table with rows randomly sampled.
We create a mask with `num` True bools, and fill it with False bools
until it is the length of the table. We shuffle it, and apply that
mask to the table. | [
"Returns",
"a",
"new",
"table",
"with",
"rows",
"randomly",
"sampled",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L706-L731 |
250,489 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.select | def select(self, *cols):
"""
Returns DataTable with a subset of columns in this table
"""
return DataTable([cols] + zip(*[self[col] for col in cols])) | python | def select(self, *cols):
"""
Returns DataTable with a subset of columns in this table
"""
return DataTable([cols] + zip(*[self[col] for col in cols])) | [
"def",
"select",
"(",
"self",
",",
"*",
"cols",
")",
":",
"return",
"DataTable",
"(",
"[",
"cols",
"]",
"+",
"zip",
"(",
"*",
"[",
"self",
"[",
"col",
"]",
"for",
"col",
"in",
"cols",
"]",
")",
")"
] | Returns DataTable with a subset of columns in this table | [
"Returns",
"DataTable",
"with",
"a",
"subset",
"of",
"columns",
"in",
"this",
"table"
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L733-L737 |
250,490 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.sort | def sort(self, fieldname, key=lambda x: x, desc=False, inplace=False):
"""
This matches Python's built-in sorting signature closely.
By default, a new DataTable will be returned and the original will
not be mutated. If preferred, specify `inplace=True` in order to
mutate the ori... | python | def sort(self, fieldname, key=lambda x: x, desc=False, inplace=False):
"""
This matches Python's built-in sorting signature closely.
By default, a new DataTable will be returned and the original will
not be mutated. If preferred, specify `inplace=True` in order to
mutate the ori... | [
"def",
"sort",
"(",
"self",
",",
"fieldname",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
",",
"desc",
"=",
"False",
",",
"inplace",
"=",
"False",
")",
":",
"try",
":",
"field_index",
"=",
"tuple",
"(",
"self",
".",
"fields",
")",
".",
"index",
"("... | This matches Python's built-in sorting signature closely.
By default, a new DataTable will be returned and the original will
not be mutated. If preferred, specify `inplace=True` in order to
mutate the original table. Either way, a reference to the relevant
table will be returned. | [
"This",
"matches",
"Python",
"s",
"built",
"-",
"in",
"sorting",
"signature",
"closely",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L739-L766 |
250,491 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.where | def where(self, fieldname, value, negate=False):
"""
Returns a new DataTable with rows only where the value at
`fieldname` == `value`.
"""
if negate:
return self.mask([elem != value
for elem in self[fieldname]])
else:
... | python | def where(self, fieldname, value, negate=False):
"""
Returns a new DataTable with rows only where the value at
`fieldname` == `value`.
"""
if negate:
return self.mask([elem != value
for elem in self[fieldname]])
else:
... | [
"def",
"where",
"(",
"self",
",",
"fieldname",
",",
"value",
",",
"negate",
"=",
"False",
")",
":",
"if",
"negate",
":",
"return",
"self",
".",
"mask",
"(",
"[",
"elem",
"!=",
"value",
"for",
"elem",
"in",
"self",
"[",
"fieldname",
"]",
"]",
")",
... | Returns a new DataTable with rows only where the value at
`fieldname` == `value`. | [
"Returns",
"a",
"new",
"DataTable",
"with",
"rows",
"only",
"where",
"the",
"value",
"at",
"fieldname",
"==",
"value",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L768-L778 |
250,492 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.wheregreater | def wheregreater(self, fieldname, value):
"""
Returns a new DataTable with rows only where the value at
`fieldname` > `value`.
"""
return self.mask([elem > value for elem in self[fieldname]]) | python | def wheregreater(self, fieldname, value):
"""
Returns a new DataTable with rows only where the value at
`fieldname` > `value`.
"""
return self.mask([elem > value for elem in self[fieldname]]) | [
"def",
"wheregreater",
"(",
"self",
",",
"fieldname",
",",
"value",
")",
":",
"return",
"self",
".",
"mask",
"(",
"[",
"elem",
">",
"value",
"for",
"elem",
"in",
"self",
"[",
"fieldname",
"]",
"]",
")"
] | Returns a new DataTable with rows only where the value at
`fieldname` > `value`. | [
"Returns",
"a",
"new",
"DataTable",
"with",
"rows",
"only",
"where",
"the",
"value",
"at",
"fieldname",
">",
"value",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L815-L820 |
250,493 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.whereless | def whereless(self, fieldname, value):
"""
Returns a new DataTable with rows only where the value at
`fieldname` < `value`.
"""
return self.mask([elem < value for elem in self[fieldname]]) | python | def whereless(self, fieldname, value):
"""
Returns a new DataTable with rows only where the value at
`fieldname` < `value`.
"""
return self.mask([elem < value for elem in self[fieldname]]) | [
"def",
"whereless",
"(",
"self",
",",
"fieldname",
",",
"value",
")",
":",
"return",
"self",
".",
"mask",
"(",
"[",
"elem",
"<",
"value",
"for",
"elem",
"in",
"self",
"[",
"fieldname",
"]",
"]",
")"
] | Returns a new DataTable with rows only where the value at
`fieldname` < `value`. | [
"Returns",
"a",
"new",
"DataTable",
"with",
"rows",
"only",
"where",
"the",
"value",
"at",
"fieldname",
"<",
"value",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L822-L827 |
250,494 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.wherenot | def wherenot(self, fieldname, value):
"""
Logical opposite of `where`.
"""
return self.where(fieldname, value, negate=True) | python | def wherenot(self, fieldname, value):
"""
Logical opposite of `where`.
"""
return self.where(fieldname, value, negate=True) | [
"def",
"wherenot",
"(",
"self",
",",
"fieldname",
",",
"value",
")",
":",
"return",
"self",
".",
"where",
"(",
"fieldname",
",",
"value",
",",
"negate",
"=",
"True",
")"
] | Logical opposite of `where`. | [
"Logical",
"opposite",
"of",
"where",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L829-L833 |
250,495 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.wherenotin | def wherenotin(self, fieldname, value):
"""
Logical opposite of `wherein`.
"""
return self.wherein(fieldname, value, negate=True) | python | def wherenotin(self, fieldname, value):
"""
Logical opposite of `wherein`.
"""
return self.wherein(fieldname, value, negate=True) | [
"def",
"wherenotin",
"(",
"self",
",",
"fieldname",
",",
"value",
")",
":",
"return",
"self",
".",
"wherein",
"(",
"fieldname",
",",
"value",
",",
"negate",
"=",
"True",
")"
] | Logical opposite of `wherein`. | [
"Logical",
"opposite",
"of",
"wherein",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L841-L845 |
250,496 | emlazzarin/acrylic | acrylic/datatable.py | DataTable.writexlsx | def writexlsx(self, path, sheetname="default"):
"""
Writes this table to an .xlsx file at the specified path.
If you'd like to specify a sheetname, you may do so.
If you'd like to write one workbook with different DataTables
for each sheet, import the `excel` function from acry... | python | def writexlsx(self, path, sheetname="default"):
"""
Writes this table to an .xlsx file at the specified path.
If you'd like to specify a sheetname, you may do so.
If you'd like to write one workbook with different DataTables
for each sheet, import the `excel` function from acry... | [
"def",
"writexlsx",
"(",
"self",
",",
"path",
",",
"sheetname",
"=",
"\"default\"",
")",
":",
"writer",
"=",
"ExcelRW",
".",
"UnicodeWriter",
"(",
"path",
")",
"writer",
".",
"set_active_sheet",
"(",
"sheetname",
")",
"writer",
".",
"writerow",
"(",
"self"... | Writes this table to an .xlsx file at the specified path.
If you'd like to specify a sheetname, you may do so.
If you'd like to write one workbook with different DataTables
for each sheet, import the `excel` function from acrylic. You
can see that code in `utils.py`.
Note that... | [
"Writes",
"this",
"table",
"to",
"an",
".",
"xlsx",
"file",
"at",
"the",
"specified",
"path",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L856-L873 |
250,497 | KnowledgeLinks/rdfframework | rdfframework/datatypes/uriformatters.py | pyuri_formatter | def pyuri_formatter(namespace, value):
""" Formats a namespace and ending value into a python friendly format
args:
namespace: RdfNamespace or tuple in the format of (prefix, uri,)
value: end value to attach to the namespace
"""
if namespace[0]:
return "%s_%s" %(namespace[0], va... | python | def pyuri_formatter(namespace, value):
""" Formats a namespace and ending value into a python friendly format
args:
namespace: RdfNamespace or tuple in the format of (prefix, uri,)
value: end value to attach to the namespace
"""
if namespace[0]:
return "%s_%s" %(namespace[0], va... | [
"def",
"pyuri_formatter",
"(",
"namespace",
",",
"value",
")",
":",
"if",
"namespace",
"[",
"0",
"]",
":",
"return",
"\"%s_%s\"",
"%",
"(",
"namespace",
"[",
"0",
"]",
",",
"value",
")",
"else",
":",
"return",
"\"pyuri_%s_%s\"",
"%",
"(",
"base64",
"."... | Formats a namespace and ending value into a python friendly format
args:
namespace: RdfNamespace or tuple in the format of (prefix, uri,)
value: end value to attach to the namespace | [
"Formats",
"a",
"namespace",
"and",
"ending",
"value",
"into",
"a",
"python",
"friendly",
"format"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/uriformatters.py#L38-L50 |
250,498 | dlancer/django-pages-cms | pages/models/pagecontenttypes.py | PageMetaContent.robots | def robots(self):
"""Return values for robots html meta key"""
r = 'noindex' if self.is_noindex else 'index'
r += ','
r += 'nofollow' if self.is_nofollow else 'follow'
return r | python | def robots(self):
"""Return values for robots html meta key"""
r = 'noindex' if self.is_noindex else 'index'
r += ','
r += 'nofollow' if self.is_nofollow else 'follow'
return r | [
"def",
"robots",
"(",
"self",
")",
":",
"r",
"=",
"'noindex'",
"if",
"self",
".",
"is_noindex",
"else",
"'index'",
"r",
"+=",
"','",
"r",
"+=",
"'nofollow'",
"if",
"self",
".",
"is_nofollow",
"else",
"'follow'",
"return",
"r"
] | Return values for robots html meta key | [
"Return",
"values",
"for",
"robots",
"html",
"meta",
"key"
] | 441fad674d5ad4f6e05c953508950525dc0fa789 | https://github.com/dlancer/django-pages-cms/blob/441fad674d5ad4f6e05c953508950525dc0fa789/pages/models/pagecontenttypes.py#L115-L120 |
250,499 | rackerlabs/rackspace-python-neutronclient | neutronclient/neutron/v2_0/fw/firewallrule.py | _add_common_args | def _add_common_args(parser, is_create=True):
"""If is_create is True, protocol and action become mandatory arguments.
CreateCommand = is_create : True
UpdateCommand = is_create : False
"""
parser.add_argument(
'--name',
help=_('Name for the firewall rule.'))
parser.add_argument... | python | def _add_common_args(parser, is_create=True):
"""If is_create is True, protocol and action become mandatory arguments.
CreateCommand = is_create : True
UpdateCommand = is_create : False
"""
parser.add_argument(
'--name',
help=_('Name for the firewall rule.'))
parser.add_argument... | [
"def",
"_add_common_args",
"(",
"parser",
",",
"is_create",
"=",
"True",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--name'",
",",
"help",
"=",
"_",
"(",
"'Name for the firewall rule.'",
")",
")",
"parser",
".",
"add_argument",
"(",
"'--description'",
","... | If is_create is True, protocol and action become mandatory arguments.
CreateCommand = is_create : True
UpdateCommand = is_create : False | [
"If",
"is_create",
"is",
"True",
"protocol",
"and",
"action",
"become",
"mandatory",
"arguments",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/v2_0/fw/firewallrule.py#L24-L62 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.