text stringlengths 0 828 |
|---|
"""""" |
out = 0 |
for key, value in self.items(): |
out |= value |
return out" |
1709,"def base(self, value, recurse=True): |
"""""" |
Returns the root base for the given value from this enumeration. |
:param value | <variant> |
recurse | <bool> |
"""""" |
while value in self._bases: |
value = self._bases[value] |
if not recurse: |
break |
return value" |
1710,"def displayText(self, value, blank='', joiner=', '): |
"""""" |
Returns the display text for the value associated with |
the inputted text. This will result in a comma separated |
list of labels for the value, or the blank text provided if |
no text is found. |
:param value | <variant> |
blank | <str> |
joiner | <str> |
:return <str> |
"""""" |
if value is None: |
return '' |
labels = [] |
for key, my_value in sorted(self.items(), key=lambda x: x[1]): |
if value & my_value: |
labels.append(self._labels.get(my_value, text.pretty(key))) |
return joiner.join(labels) or blank" |
1711,"def extend(self, base, key, value=None): |
"""""" |
Adds a new definition to this enumerated type, extending the given |
base type. This will create a new key for the type and register |
it as a new viable option from the system, however, it will also |
register its base information so you can use enum.base to retrieve |
the root type. |
:param base | <variant> | value for this enumeration |
key | <str> | new key for the value |
value | <variant> | if None is supplied, it will be auto-assigned |
:usage |>>> from projex.enum import enum |
|>>> Types = enum('Integer', 'Boolean') |
|>>> Types.Integer |
|1 |
|>>> Types.Boolean |
|2 |
|>>> Types.extend(Types.Integer, 'BigInteger') |
|>>> Types.BigInteger |
|4 |
|>>> Types.base(Types.BigInteger) |
|1 |
"""""" |
new_val = self.add(key, value) |
self._bases[new_val] = base" |
1712,"def fromSet(self, values): |
"""""" |
Generates a flag value based on the given set of values. |
:param values: <set> |
:return: <int> |
"""""" |
value = 0 |
for flag in values: |
value |= self(flag) |
return value" |
1713,"def label(self, value): |
"""""" |
Returns a pretty text version of the key for the inputted value. |
:param value | <variant> |
:return <str> |
"""""" |
return self._labels.get(value) or text.pretty(self(value))" |
1714,"def labels(self): |
"""""" |
Return a list of ""user friendly"" labels. |
:return <list> [ <str>, .. ] |
"""""" |
return [self._labels.get(value) or text.pretty(key) |
for key, value in sorted(self.items(), key=lambda x: x[1])]" |
1715,"def setLabel(self, value, label): |
"""""" |
Sets the label text for the inputted value. This will override the default pretty |
text label that is used for the key. |
:param value | <variant> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.